From cbb46e5fb1771fe6e2634361768ff2f9e6430464 Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Fri, 22 Jul 2022 11:31:39 +0200 Subject: [PATCH] Restore previously exported types --- index.d.ts | 29 +++++++++++++++++++---------- react-native/index.d.ts | 22 ++++++++++++++++++---- src/core/auth/options.ts | 9 ++++++++- src/core/config.ts | 9 +++------ src/core/defaults.ts | 9 ++++----- src/core/options.ts | 9 ++++----- types/src/core/auth/options.d.ts | 4 +++- types/src/core/defaults.d.ts | 6 +++--- types/src/core/options.d.ts | 6 +++--- with-encryption/index.d.ts | 22 ++++++++++++++++++---- worker/index.d.ts | 22 ++++++++++++++++++---- worker/with-encryption/index.d.ts | 22 ++++++++++++++++++---- 12 files changed, 119 insertions(+), 50 deletions(-) diff --git a/index.d.ts b/index.d.ts index 526cf035e..965bf7e6b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,20 +1,29 @@ export { DeprecatedAuthOptions, - ChannelAuthorizerGenerator, + ChannelAuthorizerGenerator } from './types/src/core/auth/deprecated_channel_authorizer'; export { - AuthOptions, + UserAuthenticationOptions, + ChannelAuthorizationOptions, ChannelAuthorizationHandler, UserAuthenticationHandler, ChannelAuthorizationCallback, - UserAuthenticationCallback, + UserAuthenticationCallback } from './types/src/core/auth/options'; -export { Options } from './types/src/core/options' +export { Options } from './types/src/core/options'; -export {default as Channel} from './types/src/core/channels/channel'; -export {default as PresenceChannel} from './types/src/core/channels/presence_channel'; -export {default as Members} from './types/src/core/channels/members'; -export {default as Runtime} from './types/src/runtimes/interface' -export {default as ConnectionManager} from './types/src/core/connection/connection_manager' +export { default as Channel } from './types/src/core/channels/channel'; +export { default as PresenceChannel } from './types/src/core/channels/presence_channel'; +export { default as Members } from './types/src/core/channels/members'; +export { default as Runtime } from './types/src/runtimes/interface'; +export { default as ConnectionManager } from './types/src/core/connection/connection_manager'; -export {default} from './types/src/core/pusher' +export { default } from './types/src/core/pusher'; + +// The following types are provided for backward compatability +export { + DeprecatedAuthOptions as AuthOptions, + DeprecatedChannelAuthorizer as Authorizer, + ChannelAuthorizerGenerator as AuthorizerGenerator +} from './types/src/core/auth/deprecated_channel_authorizer'; +export { ChannelAuthorizationCallback as AuthorizerCallback } from './types/src/core/auth/options'; diff --git a/react-native/index.d.ts b/react-native/index.d.ts index 2531a8ead..f95ccaf75 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -1,8 +1,14 @@ export { - Authorizer, - AuthOptions, - AuthorizerGenerator, - AuthorizerCallback, + DeprecatedAuthOptions, + ChannelAuthorizerGenerator +} from '../types/src/core/auth/deprecated_channel_authorizer'; +export { + UserAuthenticationOptions, + ChannelAuthorizationOptions, + ChannelAuthorizationHandler, + UserAuthenticationHandler, + ChannelAuthorizationCallback, + UserAuthenticationCallback } from '../types/src/core/auth/options'; export { Options } from '../types/src/core/options'; @@ -13,3 +19,11 @@ export { default as Runtime } from '../types/src/runtimes/interface'; export { default as ConnectionManager } from '../types/src/core/connection/connection_manager'; export { default } from '../types/src/core/pusher'; + +// The following types are provided for backward compatability +export { + DeprecatedAuthOptions as AuthOptions, + DeprecatedChannelAuthorizer as Authorizer, + ChannelAuthorizerGenerator as AuthorizerGenerator +} from '../types/src/core/auth/deprecated_channel_authorizer'; +export { ChannelAuthorizationCallback as AuthorizerCallback } from '../types/src/core/auth/options'; diff --git a/src/core/auth/options.ts b/src/core/auth/options.ts index 8d1f65696..518743468 100644 --- a/src/core/auth/options.ts +++ b/src/core/auth/options.ts @@ -51,7 +51,7 @@ export type AuthTransportCallback = | ChannelAuthorizationCallback | UserAuthenticationCallback; -export interface AuthOptions { +export interface AuthOptionsT { transport: 'ajax' | 'jsonp'; endpoint: string; params?: any; @@ -59,6 +59,13 @@ export interface AuthOptions { customHandler?: AuthHandler; } +export declare type UserAuthenticationOptions = AuthOptionsT< + UserAuthenticationHandler +>; +export declare type ChannelAuthorizationOptions = AuthOptionsT< + ChannelAuthorizationHandler +>; + export interface InternalAuthOptions { transport: 'ajax' | 'jsonp'; endpoint: string; diff --git a/src/core/config.ts b/src/core/config.ts index 57a276e41..fcf88c51d 100644 --- a/src/core/config.ts +++ b/src/core/config.ts @@ -3,7 +3,7 @@ import Defaults from './defaults'; import { ChannelAuthorizationHandler, UserAuthenticationHandler, - AuthOptions + ChannelAuthorizationOptions } from './auth/options'; import UserAuthenticator from './auth/user_authenticator'; import ChannelAuthorizer from './auth/channel_authorizer'; @@ -150,11 +150,8 @@ function buildUserAuthenticator(opts: Options): UserAuthenticationHandler { return UserAuthenticator(userAuthentication); } -function buildChannelAuth( - opts: Options, - pusher -): AuthOptions { - let channelAuthorization: AuthOptions; +function buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions { + let channelAuthorization: ChannelAuthorizationOptions; if ('channelAuthorization' in opts) { channelAuthorization = { ...Defaults.channelAuthorization, diff --git a/src/core/defaults.ts b/src/core/defaults.ts index f6d9d5398..f430cde69 100644 --- a/src/core/defaults.ts +++ b/src/core/defaults.ts @@ -1,7 +1,6 @@ import { - AuthOptions, - ChannelAuthorizationHandler, - UserAuthenticationHandler + ChannelAuthorizationOptions, + UserAuthenticationOptions } from './auth/options'; import { AuthTransport } from './config'; @@ -22,8 +21,8 @@ export interface DefaultConfig { pongTimeout: number; unavailableTimeout: number; cluster: string; - userAuthentication: AuthOptions; - channelAuthorization: AuthOptions; + userAuthentication: UserAuthenticationOptions; + channelAuthorization: ChannelAuthorizationOptions; cdn_http?: string; cdn_https?: string; diff --git a/src/core/options.ts b/src/core/options.ts index 51cb95e71..3a95c1eda 100644 --- a/src/core/options.ts +++ b/src/core/options.ts @@ -1,8 +1,7 @@ import ConnectionManager from './connection/connection_manager'; import { - AuthOptions, - ChannelAuthorizationHandler, - UserAuthenticationHandler + ChannelAuthorizationOptions, + UserAuthenticationOptions } from './auth/options'; import { ChannelAuthorizerGenerator, @@ -19,8 +18,8 @@ export interface Options { authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead - channelAuthorization?: AuthOptions; - userAuthentication?: AuthOptions; + channelAuthorization?: ChannelAuthorizationOptions; + userAuthentication?: UserAuthenticationOptions; cluster?: string; enableStats?: boolean; diff --git a/types/src/core/auth/options.d.ts b/types/src/core/auth/options.d.ts index 6bf7db693..3e9c103dc 100644 --- a/types/src/core/auth/options.d.ts +++ b/types/src/core/auth/options.d.ts @@ -27,13 +27,15 @@ export interface UserAuthenticationHandler { (params: UserAuthenticationRequestParams, callback: UserAuthenticationCallback): void; } export declare type AuthTransportCallback = ChannelAuthorizationCallback | UserAuthenticationCallback; -export interface AuthOptions { +export interface AuthOptionsT { transport: 'ajax' | 'jsonp'; endpoint: string; params?: any; headers?: any; customHandler?: AuthHandler; } +export declare type UserAuthenticationOptions = AuthOptionsT; +export declare type ChannelAuthorizationOptions = AuthOptionsT; export interface InternalAuthOptions { transport: 'ajax' | 'jsonp'; endpoint: string; diff --git a/types/src/core/defaults.d.ts b/types/src/core/defaults.d.ts index 72ad8097a..34aec27ca 100644 --- a/types/src/core/defaults.d.ts +++ b/types/src/core/defaults.d.ts @@ -1,4 +1,4 @@ -import { AuthOptions, ChannelAuthorizationHandler, UserAuthenticationHandler } from './auth/options'; +import { ChannelAuthorizationOptions, UserAuthenticationOptions } from './auth/options'; import { AuthTransport } from './config'; export interface DefaultConfig { VERSION: string; @@ -17,8 +17,8 @@ export interface DefaultConfig { pongTimeout: number; unavailableTimeout: number; cluster: string; - userAuthentication: AuthOptions; - channelAuthorization: AuthOptions; + userAuthentication: UserAuthenticationOptions; + channelAuthorization: ChannelAuthorizationOptions; cdn_http?: string; cdn_https?: string; dependency_suffix?: string; diff --git a/types/src/core/options.d.ts b/types/src/core/options.d.ts index 25fcb9aa3..281a1d97b 100644 --- a/types/src/core/options.d.ts +++ b/types/src/core/options.d.ts @@ -1,4 +1,4 @@ -import { AuthOptions, ChannelAuthorizationHandler, UserAuthenticationHandler } from './auth/options'; +import { ChannelAuthorizationOptions, UserAuthenticationOptions } from './auth/options'; import { ChannelAuthorizerGenerator, DeprecatedAuthOptions } from './auth/deprecated_channel_authorizer'; import { AuthTransport, Transport } from './config'; import * as nacl from 'tweetnacl'; @@ -8,8 +8,8 @@ export interface Options { authEndpoint?: string; authTransport?: AuthTransport; authorizer?: ChannelAuthorizerGenerator; - channelAuthorization?: AuthOptions; - userAuthentication?: AuthOptions; + channelAuthorization?: ChannelAuthorizationOptions; + userAuthentication?: UserAuthenticationOptions; cluster?: string; enableStats?: boolean; disableStats?: boolean; diff --git a/with-encryption/index.d.ts b/with-encryption/index.d.ts index b4c4d1ab6..516792c53 100644 --- a/with-encryption/index.d.ts +++ b/with-encryption/index.d.ts @@ -1,8 +1,14 @@ export { - Authorizer, - AuthOptions, - AuthorizerGenerator, - AuthorizerCallback + DeprecatedAuthOptions, + ChannelAuthorizerGenerator +} from '../types/src/core/auth/deprecated_channel_authorizer'; +export { + ChannelAuthorizationOptions, + UserAuthenticationOptions, + ChannelAuthorizationHandler, + UserAuthenticationHandler, + ChannelAuthorizationCallback, + UserAuthenticationCallback } from '../types/src/core/auth/options'; export { Options } from '../types/src/core/options'; @@ -13,3 +19,11 @@ export { default as Runtime } from '../types/src/runtimes/interface'; export { default as ConnectionManager } from '../types/src/core/connection/connection_manager'; export { default } from '../types/src/core/pusher'; + +// The following types are provided for backward compatability +export { + DeprecatedAuthOptions as AuthOptions, + DeprecatedChannelAuthorizer as Authorizer, + ChannelAuthorizerGenerator as AuthorizerGenerator +} from '../types/src/core/auth/deprecated_channel_authorizer'; +export { ChannelAuthorizationCallback as AuthorizerCallback } from '../types/src/core/auth/options'; diff --git a/worker/index.d.ts b/worker/index.d.ts index 2531a8ead..516792c53 100644 --- a/worker/index.d.ts +++ b/worker/index.d.ts @@ -1,8 +1,14 @@ export { - Authorizer, - AuthOptions, - AuthorizerGenerator, - AuthorizerCallback, + DeprecatedAuthOptions, + ChannelAuthorizerGenerator +} from '../types/src/core/auth/deprecated_channel_authorizer'; +export { + ChannelAuthorizationOptions, + UserAuthenticationOptions, + ChannelAuthorizationHandler, + UserAuthenticationHandler, + ChannelAuthorizationCallback, + UserAuthenticationCallback } from '../types/src/core/auth/options'; export { Options } from '../types/src/core/options'; @@ -13,3 +19,11 @@ export { default as Runtime } from '../types/src/runtimes/interface'; export { default as ConnectionManager } from '../types/src/core/connection/connection_manager'; export { default } from '../types/src/core/pusher'; + +// The following types are provided for backward compatability +export { + DeprecatedAuthOptions as AuthOptions, + DeprecatedChannelAuthorizer as Authorizer, + ChannelAuthorizerGenerator as AuthorizerGenerator +} from '../types/src/core/auth/deprecated_channel_authorizer'; +export { ChannelAuthorizationCallback as AuthorizerCallback } from '../types/src/core/auth/options'; diff --git a/worker/with-encryption/index.d.ts b/worker/with-encryption/index.d.ts index 818c6ffc5..9b3772323 100644 --- a/worker/with-encryption/index.d.ts +++ b/worker/with-encryption/index.d.ts @@ -1,8 +1,14 @@ export { - Authorizer, - AuthOptions, - AuthorizerGenerator, - AuthorizerCallback, + DeprecatedAuthOptions, + ChannelAuthorizerGenerator +} from '../../types/src/core/auth/deprecated_channel_authorizer'; +export { + ChannelAuthorizationOptions, + UserAuthenticationOptions, + ChannelAuthorizationHandler, + UserAuthenticationHandler, + ChannelAuthorizationCallback, + UserAuthenticationCallback } from '../../types/src/core/auth/options'; export { Options } from '../../types/src/core/options'; @@ -13,3 +19,11 @@ export { default as Runtime } from '../../types/src/runtimes/interface'; export { default as ConnectionManager } from '../../types/src/core/connection/connection_manager'; export { default } from '../../types/src/core/pusher'; + +// The following types are provided for backward compatability +export { + DeprecatedAuthOptions as AuthOptions, + DeprecatedChannelAuthorizer as Authorizer, + ChannelAuthorizerGenerator as AuthorizerGenerator +} from '../../types/src/core/auth/deprecated_channel_authorizer'; +export { ChannelAuthorizationCallback as AuthorizerCallback } from '../../types/src/core/auth/options';