@twilio/conversations 2.1.0-rc.1 → 2.1.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/NOTICE.txt +679 -0
  3. package/builds/browser.js +676 -587
  4. package/builds/browser.js.map +1 -1
  5. package/builds/lib.d.ts +287 -117
  6. package/builds/lib.js +676 -587
  7. package/builds/lib.js.map +1 -1
  8. package/builds/twilio-conversations.js +854 -909
  9. package/builds/twilio-conversations.min.js +2 -14
  10. package/dist/aggregated-delivery-receipt.js +6 -1
  11. package/dist/aggregated-delivery-receipt.js.map +1 -1
  12. package/dist/client.js +165 -142
  13. package/dist/client.js.map +1 -1
  14. package/dist/command-executor.js +16 -14
  15. package/dist/command-executor.js.map +1 -1
  16. package/dist/configuration.js +14 -10
  17. package/dist/configuration.js.map +1 -1
  18. package/dist/conversation.js +212 -153
  19. package/dist/conversation.js.map +1 -1
  20. package/dist/data/conversations.js +81 -77
  21. package/dist/data/conversations.js.map +1 -1
  22. package/dist/data/messages.js +42 -38
  23. package/dist/data/messages.js.map +1 -1
  24. package/dist/data/participants.js +93 -75
  25. package/dist/data/participants.js.map +1 -1
  26. package/dist/data/users.js +24 -22
  27. package/dist/data/users.js.map +1 -1
  28. package/dist/detailed-delivery-receipt.js +1 -1
  29. package/dist/detailed-delivery-receipt.js.map +1 -1
  30. package/dist/interfaces/attributes.js +4 -4
  31. package/dist/interfaces/attributes.js.map +1 -1
  32. package/dist/interfaces/notification-types.js +5 -5
  33. package/dist/interfaces/notification-types.js.map +1 -1
  34. package/dist/logger.js +36 -15
  35. package/dist/logger.js.map +1 -1
  36. package/dist/media.js +21 -9
  37. package/dist/media.js.map +1 -1
  38. package/dist/message-builder.js +10 -9
  39. package/dist/message-builder.js.map +1 -1
  40. package/dist/message.js +130 -81
  41. package/dist/message.js.map +1 -1
  42. package/dist/packages/conversations/package.json.js +1 -1
  43. package/dist/participant.js +85 -51
  44. package/dist/participant.js.map +1 -1
  45. package/dist/push-notification.js.map +1 -1
  46. package/dist/rest-paginator.js +16 -6
  47. package/dist/rest-paginator.js.map +1 -1
  48. package/dist/services/network.js +18 -14
  49. package/dist/services/network.js.map +1 -1
  50. package/dist/services/typing-indicator.js +20 -17
  51. package/dist/services/typing-indicator.js.map +1 -1
  52. package/dist/unsent-message.js.map +1 -1
  53. package/dist/user.js +85 -59
  54. package/dist/user.js.map +1 -1
  55. package/dist/util/deferred.js +3 -1
  56. package/dist/util/deferred.js.map +1 -1
  57. package/dist/util/index.js +6 -6
  58. package/dist/util/index.js.map +1 -1
  59. package/docs/classes/Client.html +24 -30
  60. package/docs/classes/Conversation.html +30 -30
  61. package/docs/classes/DetailedDeliveryReceipt.html +1 -1
  62. package/docs/classes/Message.html +7 -7
  63. package/docs/classes/MessageBuilder.html +2 -2
  64. package/docs/classes/Participant.html +7 -7
  65. package/docs/classes/User.html +7 -7
  66. package/docs/interfaces/CreateConversationOptions.html +1 -1
  67. package/package.json +23 -17
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sources":["../src/client.ts"],"sourcesContent":["import { Logger } from './logger';\nimport { Configuration } from './configuration';\n\nimport { User, UserUpdatedEventArgs, UserUpdateReason } from './user';\nimport { Network } from './services/network';\n\nimport { NotificationTypes } from './interfaces/notification-types';\n\nimport { TwilsockClient, InitRegistration, ConnectionState as TwilsockConnectionState, Transport } from 'twilsock';\nimport { ChannelType, Notifications as NotificationClient } from '@twilio/notifications';\nimport { SyncClient } from 'twilio-sync';\nimport { McsClient } from '@twilio/mcs-client';\n\nimport { Conversation, Conversations as ConversationsEntity } from './data/conversations';\n\nimport { Users } from './data/users';\nimport { TypingIndicator } from './services/typing-indicator';\nimport { Paginator } from './interfaces/paginator';\nimport { PushNotification } from './push-notification';\nimport { deepClone, parseToNumber } from './util';\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason\n} from './participant';\nimport { Message, MessageUpdatedEventArgs, MessageUpdateReason } from './message';\nimport { TelemetryEventDescription, TelemetryPoint } from 'twilsock';\nimport {\n validateTypesAsync,\n validateTypes,\n literal,\n nonEmptyString,\n pureObject,\n objectSchema,\n validateConstructorTypes\n} from '@twilio/declarative-type-validator';\nimport { version } from '../package.json';\nimport {\n ConversationUpdatedEventArgs,\n ConversationUpdateReason\n} from './conversation';\nimport { CommandExecutor } from './command-executor';\nimport { ConfigurationResponse } from './interfaces/commands/configuration';\nimport { ReplayEventEmitter } from '@twilio/replay-event-emitter';\n\nconst log = Logger.scope('Client');\n\nconst SDK_VERSION = version;\n\nclass ClientServices {\n commandExecutor: CommandExecutor;\n twilsockClient: TwilsockClient;\n users: Users;\n notificationClient: NotificationClient;\n network: Network;\n typingIndicator: TypingIndicator;\n syncClient: SyncClient;\n mcsClient: McsClient;\n transport: Transport;\n}\n\ntype ClientEvents = {\n conversationAdded: (conversation: Conversation) => void;\n conversationJoined: (conversation: Conversation) => void;\n conversationLeft: (conversation: Conversation) => void;\n conversationRemoved: (conversation: Conversation) => void;\n conversationUpdated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n tokenAboutToExpire: (ttl: number) => void;\n tokenExpired: () => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n pushNotification: (pushNotification: PushNotification) => void;\n userSubscribed: (user: User) => void;\n userUnsubscribed: (user: User) => void;\n userUpdated: (data: {\n user: User;\n updateReasons: UserUpdateReason[];\n }) => void;\n stateChanged: (state: State) => void;\n connectionStateChanged: (state: TwilsockConnectionState) => void;\n connectionError: (data: {\n terminal: boolean;\n message: string;\n httpStatusCode?: number;\n errorCode?: number;\n }) => void;\n};\n\n/**\n * Connection state of the client. Possible values are as follows:\n * * `'connecting'` - client is offline and connection attempt is in process\n * * `'connected'` - client is online and ready\n * * `'disconnecting'` - client is going offline as disconnection is in process\n * * `'disconnected'` - client is offline and no connection attempt is in process\n * * `'denied'` - client connection is denied because of invalid JWT access token. User must refresh token in order to proceed\n */\ntype ConnectionState = TwilsockConnectionState;\n\n/**\n * State of the client. Possible values are as follows:\n * * `'failed'` - the client failed to initialize\n * * `'initialized'` - the client successfully initialized\n */\ntype State = 'failed' | 'initialized';\n\n/**\n * Notifications channel type. Possible values are as follows:\n * * `'fcm'`\n * * `'apn'`\n */\ntype NotificationsChannelType = ChannelType;\n\ntype LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent' | null;\n\n/**\n * Conversations client options.\n */\ninterface ClientOptions {\n /**\n * The level of logging to enable.\n */\n logLevel?: LogLevel;\n region?: string;\n productId?: string;\n twilsockClient?: TwilsockClient;\n transport?: Transport;\n notificationsClient?: NotificationClient;\n syncClient?: SyncClient;\n typingIndicatorTimeoutOverride?: number;\n consumptionReportIntervalOverride?: string;\n httpCacheIntervalOverride?: string;\n userInfosToSubscribeOverride?: number;\n retryWhenThrottledOverride?: boolean;\n backoffConfigOverride?: any;\n Chat?: any;\n IPMessaging?: any;\n Sync?: any;\n Notification?: any;\n Twilsock?: any;\n clientMetadata?: any;\n initRegistrations?: InitRegistration[];\n disableDeepClone?: boolean;\n}\n\n/**\n * Options for {@link Client.createConversation}.\n */\ninterface CreateConversationOptions {\n /**\n * Any custom attributes to attach to the conversation.\n */\n attributes?: any;\n\n /**\n * A non-unique display name of the conversation.\n */\n friendlyName?: string;\n\n /**\n * A unique identifier of the conversation.\n */\n uniqueName?: string;\n}\n\n/**\n * A client is the starting point to the Twilio Conversations functionality.\n */\n@validateConstructorTypes(nonEmptyString, [\n pureObject,\n 'undefined'\n])\nclass Client extends ReplayEventEmitter<ClientEvents> {\n /**\n * Client connection state.\n */\n public connectionState: ConnectionState = 'unknown';\n private conversationsPromise: Promise<any> | null = null;\n private _ensureReady: Promise<any> = null;\n private _resolveEnsureReady: (value?: any) => void = null;\n private _rejectEnsureReady: (err: Error) => void = null;\n private fpaToken: string;\n private configuration: Configuration;\n private conversations: any;\n private readonly options: ClientOptions;\n private services: ClientServices;\n private readonly _myself: User;\n\n /**\n * Current version of the Conversations client.\n */\n public static readonly version: string = SDK_VERSION;\n\n /**\n * Current version of the Conversations client.\n */\n public readonly version: string = SDK_VERSION;\n\n private static readonly supportedPushChannels: NotificationsChannelType[] = ['fcm', 'apn'];\n private static readonly supportedPushDataFields = {\n 'conversation_sid': 'conversationSid',\n 'message_sid': 'messageSid',\n 'message_index': 'messageIndex'\n };\n\n /**\n * Returned Conversations instance is not yet fully initialized. Calling any operations will block until it is.\n * Use connection events to monitor when client becomes fully available (connectionStateChanged with state\n * 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).\n *\n * @param fpaToken Access token\n * @param options Options to customize the Client\n * @returns A not yet fully-initialized client.\n */\n public constructor(fpaToken: string, options: ClientOptions = {}) {\n super();\n\n this.fpaToken = fpaToken;\n this.options = options;\n\n if (!this.options.disableDeepClone) {\n let options = {\n ...this.options,\n transport: undefined,\n twilsockClient: undefined\n };\n\n options = deepClone(options);\n options.transport = this.options.transport;\n options.twilsockClient = this.options.twilsockClient;\n\n this.options = options;\n }\n\n this.options.logLevel = this.options.logLevel ?? 'silent';\n log.setLevel(this.options.logLevel);\n\n const productId = this.options.productId = 'ip_messaging';\n\n // Filling ClientMetadata\n this.options.clientMetadata = this.options.clientMetadata || {};\n\n if (!this.options.clientMetadata.hasOwnProperty('type')) {\n this.options.clientMetadata.type = 'conversations';\n }\n\n if (!this.options.clientMetadata.hasOwnProperty('sdk')) {\n this.options.clientMetadata.sdk = 'JS';\n this.options.clientMetadata.sdkv = SDK_VERSION;\n }\n\n // Enable session local storage for Sync\n this.options.Sync = this.options.Sync || {};\n\n if (typeof this.options.Sync.enableSessionStorage === 'undefined') {\n this.options.Sync.enableSessionStorage = true;\n }\n\n if (this.options.region) {\n this.options.Sync.region = this.options.region;\n }\n\n if (!fpaToken) {\n throw new Error('A valid Twilio token should be provided');\n }\n\n this.services = new ClientServices();\n\n this._myself = new User(\n '',\n '',\n null,\n this.services\n );\n\n const startTwilsock = !this.options.twilsockClient;\n\n // Create default init registrations if none were provided.\n // Otherwise, the outside party have to list all the init registrations they\n // need.\n // Init registrations passed to the Conversations client will be passed down\n // to the Sync client as well.\n if (!this.options.initRegistrations) {\n const initRegistration = new InitRegistration(productId);\n Client.populateInitRegistrations(initRegistration);\n this.options.initRegistrations = [initRegistration];\n }\n\n this.services.twilsockClient = (this.options.twilsockClient = this.options.twilsockClient\n ?? new TwilsockClient(fpaToken, productId, this.options));\n\n this.services.twilsockClient.on('tokenAboutToExpire', ttl => this.emit('tokenAboutToExpire', ttl));\n this.services.twilsockClient.on('tokenExpired', () => this.emit('tokenExpired'));\n this.services.twilsockClient.on('connectionError', (error) => this.emit('connectionError', error));\n this.services.twilsockClient.on('stateChanged', (state: ConnectionState) => {\n log.debug(`Handling stateChanged for ConversationsClient: new state ${state}`);\n if (state !== this.connectionState) {\n this.connectionState = state;\n this.emit('connectionStateChanged', this.connectionState);\n }\n });\n\n this.services.transport = (this.options.transport = (this.options.transport ?? this.options.twilsockClient) as Transport);\n this.services.notificationClient = (this.options.notificationsClient = this.options.notificationsClient\n ?? new NotificationClient(fpaToken, this.options));\n this.services.syncClient = (this.options.syncClient = this.options.syncClient\n ?? new SyncClient(fpaToken, this.options));\n\n const configurationOptions = options.Chat || options.IPMessaging || options || {};\n const region = configurationOptions.region || options.region;\n const baseUrl = configurationOptions.apiUri\n || configurationOptions.typingUri\n || `https://aim.${region || 'us1'}.twilio.com`;\n\n this.services.commandExecutor = new CommandExecutor(\n baseUrl,\n { transport: this.options.transport },\n productId\n );\n\n const emitFailed = (err): void => {\n this._rejectEnsureReady(err);\n this.emit('stateChanged', 'failed');\n };\n\n this.services.twilsockClient.once('connectionError', emitFailed);\n this.services.twilsockClient.once('disconnected', emitFailed);\n\n // ConversationsClient will be able to initialize only after twilsock is connected\n this.services.twilsockClient.once('connected', async () => {\n log.debug(`ConversationsClient started INITIALIZING`);\n this.services.twilsockClient.off('connectionError', emitFailed);\n this.services.twilsockClient.off('disconnected', emitFailed);\n try {\n const startupEvent = 'conversations.client.startup';\n\n this.services.twilsockClient.addPartialTelemetryEvent(new TelemetryEventDescription(\n startupEvent,\n 'Conversations client startup',\n new Date()\n ), startupEvent, TelemetryPoint.Start);\n\n await this._initialize();\n\n this.services.twilsockClient.addPartialTelemetryEvent(\n new TelemetryEventDescription('', '', new Date()),\n startupEvent,\n TelemetryPoint.End);\n } catch (err) {\n // Fail ChatClient if initialization is incomplete\n this._rejectEnsureReady(err);\n this.emit('stateChanged', 'failed');\n }\n });\n\n this._ensureReady = new Promise((resolve, reject) => {\n this._resolveEnsureReady = resolve;\n this._rejectEnsureReady = reject;\n }).catch((err) => {}); // @todo How to process unhandled rejection here?\n\n if (startTwilsock) {\n this.services.twilsockClient.connect();\n }\n }\n\n public static populateInitRegistrations(reg: InitRegistration) {\n reg.populateInitRegistrations([NotificationTypes.TYPING_INDICATOR]);\n SyncClient.populateInitRegistrations(reg);\n }\n\n /**\n * Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.\n * Fired for all conversations client has joined.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n static readonly conversationAdded = 'conversationAdded';\n\n /**\n * Fired when the client joins a conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n static readonly conversationJoined = 'conversationJoined';\n\n /**\n * Fired when the client leaves a conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n static readonly conversationLeft = 'conversationLeft';\n\n /**\n * Fired when a conversation is no longer visible to the client.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n static readonly conversationRemoved = 'conversationRemoved';\n\n /**\n * Fired when the attributes or the metadata of a conversation have been updated.\n * During conversation's creation and initialization, this event might be fired multiple times\n * for same joined or created conversation as new data is arriving from different sources.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Conversation} `conversation` - the conversation in question\n * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n static readonly conversationUpdated = 'conversationUpdated';\n\n /**\n * Fired when a participant has joined a conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly participantJoined = 'participantJoined';\n\n /**\n * Fired when a participant has left a conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly participantLeft = 'participantLeft';\n\n /**\n * Fired when a participant's fields have been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Participant} `participant` - the participant in question\n * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n static readonly participantUpdated = 'participantUpdated';\n\n /**\n * Fired when a new message has been added to the conversation on the server.\n *\n * Parameters:\n * 1. {@link Message} `message` - the message in question\n * @event\n */\n static readonly messageAdded = 'messageAdded';\n\n /**\n * Fired when a message is removed from the message list of a conversation.\n *\n * Parameters:\n * 1. {@link Message} `message` - the message in question\n * @event\n */\n static readonly messageRemoved = 'messageRemoved';\n\n /**\n * Fired when the fields of an existing message are updated with new values.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Message} `message` - the message in question\n * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n static readonly messageUpdated = 'messageUpdated';\n\n /**\n * Fired when the token is about to expire and needs to be updated.\n * * Parameters:\n * 1. number `message` - token's time to live\n * @event\n */\n static readonly tokenAboutToExpire = 'tokenAboutToExpire';\n\n /**\n * Fired when the token has expired.\n * @event\n */\n static readonly tokenExpired = 'tokenExpired';\n\n /**\n * Fired when a participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingEnded = 'typingEnded';\n\n /**\n * Fired when a participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingStarted = 'typingStarted';\n\n /**\n * Fired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).\n *\n * Parameters:\n * 1. {@link PushNotification} `pushNotification` - the push notification in question\n * @event\n */\n static readonly pushNotification = 'pushNotification';\n\n /**\n * Fired when the client has subscribed to a user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n static readonly userSubscribed = 'userSubscribed';\n\n /**\n * Fired when the client has unsubscribed from a user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n static readonly userUnsubscribed = 'userUnsubscribed';\n\n /**\n * Fired when the properties or the reachability status of a user have been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link User} `user` - the user in question\n * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n static readonly userUpdated = 'userUpdated';\n\n /**\n * Fired when the state of the client has been changed.\n *\n * Parameters:\n * 1. {@link State} `state` - the new client state\n * @event\n */\n static readonly stateChanged = 'stateChanged';\n\n /**\n * Fired when the connection state of the client has been changed.\n *\n * Paremeters:\n * 1. {@link ConnectionState} `state` - the new connection state\n * @event\n */\n static readonly connectionStateChanged = 'connectionStateChanged';\n\n /**\n * Fired when the connection is interrupted for an unexpected reason.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * boolean `terminal` - Twilsock will stop connection attempts if true\n * * string `message` - the error message of the root cause\n * * number? `httpStatusCode` - http status code if available\n * * number? `errorCode` - Twilio public error code if available\n * @event\n */\n static readonly connectionError = 'connectionError';\n\n /**\n * @deprecated Call constructor directly.\n *\n * Factory method to create a Conversations client instance.\n *\n * The factory method will automatically trigger connection.\n * Do not use it if you need finer-grained control.\n *\n * Since this method returns an already-initialized client, some of the events\n * will be lost because they happen *before* the initialization. It is\n * recommended that `client.onWithReplay` is used as opposed to `client.on`\n * for subscribing to client events. The `client.onWithReplay` will re-emit\n * the most recent value for a given event if it emitted before the\n * subscription.\n *\n * @param token Access token.\n * @param options Options to customize the client.\n * @returns Returns a fully initialized client.\n */\n @validateTypesAsync('string', ['undefined', pureObject])\n static async create(token: string, options?: ClientOptions): Promise<Client> {\n // The logic is as follows:\n // - If twilsock is not passed in, then the ConversationsClient constructor will call twilsock.connect() by itself\n // and we do not need to do it here.\n // - If twilsock was passed in from the outside, but customer called ConversationsClient.create() then they are\n // using an obsolete workflow and the startup sequence will never complete.\n if (options?.twilsockClient) {\n throw new Error('Obsolete usage of ConversationsClient.create() ' +\n 'factory method: if you pass twilsock from the outside then you must ' +\n 'use ConversationsClient constructor and be prepared to work with ' +\n 'uninitialized client.');\n }\n\n const client = new Client(token, options);\n await client._ensureReady;\n\n return client;\n }\n\n /**\n * Information of the logged-in user. Before client initialization, returns an\n * uninitialized user. Will trigger a {@link Client.userUpdated} event after\n * initialization.\n */\n public get user(): User { return this._myself; }\n\n /**\n * Client reachability state. Throws if accessed before the client\n * initialization was completed.\n */\n public get reachabilityEnabled(): boolean {\n if (!this.configuration) {\n throw new Error(\n 'Reachability information could not yet be accessed as the client ' +\n \"has not yet been initialized. Subscribe to the 'stateChanged' event \" +\n 'to properly react to the client initialization.'\n );\n }\n\n return this.configuration.reachabilityEnabled;\n }\n\n public get token(): string { return this.fpaToken; }\n\n private _subscribeToPushNotifications(channelType: NotificationsChannelType) {\n [NotificationTypes.NEW_MESSAGE,\n NotificationTypes.ADDED_TO_CONVERSATION,\n NotificationTypes.REMOVED_FROM_CONVERSATION,\n NotificationTypes.TYPING_INDICATOR,\n NotificationTypes.CONSUMPTION_UPDATE]\n .forEach(messageType => {\n this.services.notificationClient.subscribe(channelType, messageType);\n });\n }\n\n private _unsubscribeFromPushNotifications(channelType: NotificationsChannelType) {\n [NotificationTypes.NEW_MESSAGE,\n NotificationTypes.ADDED_TO_CONVERSATION,\n NotificationTypes.REMOVED_FROM_CONVERSATION,\n NotificationTypes.TYPING_INDICATOR,\n NotificationTypes.CONSUMPTION_UPDATE]\n .forEach(messageType => {\n this.services.notificationClient.unsubscribe(channelType, messageType);\n });\n }\n\n private async _initialize() {\n const configurationResponse = await this.services.commandExecutor.fetchResource<void, ConfigurationResponse>(\n 'Client/v2/Configuration'\n );\n\n this.configuration = new Configuration(this.options, configurationResponse, log);\n\n this._myself._resolveInitialization(\n this.configuration,\n this.configuration.userIdentity,\n this.configuration.userInfo,\n true\n );\n\n this.services.typingIndicator = new TypingIndicator(this.getConversationBySid.bind(this), this.configuration, this.services);\n this.services.network = new Network(this.configuration, this.services);\n\n this.services.users = new Users(this._myself, this.configuration, this.services);\n this.services.users.on('userSubscribed', this.emit.bind(this, 'userSubscribed'));\n this.services.users.on('userUpdated', (args: UserUpdatedEventArgs) => this.emit('userUpdated', args));\n this.services.users.on('userUnsubscribed', this.emit.bind(this, 'userUnsubscribed'));\n\n this.conversations = new ConversationsEntity(this.configuration, this.services);\n\n this.conversations.on('conversationAdded', this.emit.bind(this, 'conversationAdded'));\n this.conversations.on('conversationRemoved', this.emit.bind(this, 'conversationRemoved'));\n this.conversations.on('conversationJoined', this.emit.bind(this, 'conversationJoined'));\n this.conversations.on('conversationLeft', this.emit.bind(this, 'conversationLeft'));\n this.conversations.on('conversationUpdated',\n (args: ConversationUpdatedEventArgs) => this.emit('conversationUpdated', args));\n\n this.conversations.on('participantJoined', this.emit.bind(this, 'participantJoined'));\n this.conversations.on('participantLeft', this.emit.bind(this, 'participantLeft'));\n this.conversations.on('participantUpdated',\n (args: ParticipantUpdatedEventArgs) => this.emit('participantUpdated', args));\n\n this.conversations.on('messageAdded', this.emit.bind(this, 'messageAdded'));\n this.conversations.on('messageUpdated',\n (args: MessageUpdatedEventArgs) => this.emit('messageUpdated', args));\n this.conversations.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));\n\n this.conversations.on('typingStarted', this.emit.bind(this, 'typingStarted'));\n this.conversations.on('typingEnded', this.emit.bind(this, 'typingEnded'));\n\n this.conversationsPromise = this.conversations.fetchConversations()\n .then(() => this.conversations)\n .catch((error) => {\n throw error;\n });\n\n await this.services.users.myself._ensureFetched();\n\n Client.supportedPushChannels.forEach(channelType => this._subscribeToPushNotifications(channelType));\n this.services.typingIndicator.initialize();\n\n this.services.mcsClient = new McsClient(this.fpaToken, this.configuration.links.mediaService, this.configuration.links.mediaSetService, {\n ...this.options,\n transport: null,\n });\n\n this._resolveEnsureReady();\n this.emit('stateChanged', 'initialized');\n }\n\n /**\n * Gracefully shut down the client.\n */\n async shutdown(): Promise<void> {\n await this._ensureReady;\n await this.services.twilsockClient.disconnect();\n }\n\n /**\n * Update the token used by the client and re-register with the Conversations services.\n * @param token New access token.\n */\n @validateTypesAsync(nonEmptyString)\n async updateToken(token: string): Promise<Client> {\n await this._ensureReady;\n log.info('updateToken');\n\n if (this.fpaToken === token) {\n return this;\n }\n\n await this.services.twilsockClient.updateToken(token);\n await this.services.notificationClient.updateToken(token);\n await this.services.mcsClient.updateToken(token);\n this.fpaToken = token;\n\n return this;\n }\n\n /**\n * Get a known conversation by its SID.\n * @param conversationSid Conversation sid\n */\n @validateTypesAsync(nonEmptyString)\n async getConversationBySid(conversationSid: string): Promise<Conversation> {\n await this._ensureReady;\n await this.conversations.myConversationsRead.promise;\n let conversation = await this.conversations.getConversation(conversationSid);\n\n if (!conversation) {\n conversation = await this.conversations.peekConversation(conversationSid);\n }\n\n if (!conversation) {\n throw new Error(`Conversation with SID ${conversationSid} is not found.`);\n }\n\n return conversation;\n }\n\n /**\n * Get a known conversation by its unique identifier name.\n * @param uniqueName The unique identifier name of the conversation.\n */\n @validateTypesAsync(nonEmptyString)\n async getConversationByUniqueName(uniqueName: string): Promise<Conversation> {\n await this._ensureReady;\n await this.conversations.myConversationsRead.promise;\n const conversation = await this.conversations.getConversationByUniqueName(uniqueName);\n\n if (!conversation) {\n throw new Error(`Conversation with unique name ${uniqueName} is not found.`);\n }\n\n return conversation;\n }\n\n /**\n * Get the current list of all the subscribed conversations.\n */\n public async getSubscribedConversations(args?): Promise<Paginator<Conversation>> {\n await this._ensureReady;\n return this.conversationsPromise.then(conversations => conversations.getConversations(args));\n }\n\n /**\n * Create a conversation on the server and subscribe to its events.\n * The default is a conversation with an empty friendly name.\n * @param options Options for the conversation.\n */\n @validateTypesAsync([\n 'undefined',\n objectSchema('conversation options', {\n friendlyName: ['string', 'undefined'],\n isPrivate: ['boolean', 'undefined'],\n uniqueName: ['string', 'undefined']\n })\n ])\n public async createConversation(options?: CreateConversationOptions): Promise<Conversation> {\n await this._ensureReady;\n options = options || {};\n return this.conversationsPromise.then(conversationsEntity => conversationsEntity.addConversation(options));\n }\n\n /**\n * Register for push notifications.\n * @param channelType Channel type.\n * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.\n */\n @validateTypesAsync(literal('fcm', 'apn'), 'string')\n public async setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void> {\n await this._ensureReady;\n this._subscribeToPushNotifications(channelType);\n this.services.notificationClient.setPushRegistrationId(channelType, registrationId);\n await this.services.notificationClient.commitChanges(); // Committing before this point is useless because we have no push id\n }\n\n /**\n * Unregister from push notifications.\n * @param channelType Channel type.\n * @deprecated Use removePushRegistrations() instead.\n */\n @validateTypesAsync(literal('fcm', 'apn'))\n public async unsetPushRegistrationId(channelType: NotificationsChannelType): Promise<void> {\n await this._ensureReady;\n this._unsubscribeFromPushNotifications(channelType);\n await this.services.notificationClient.commitChanges();\n }\n\n /**\n * Clear existing registrations directly using provided device token.\n * This is useful to ensure stopped subscriptions without resubscribing.\n *\n * This function goes completely beside the state machine and removes all registrations.\n * Use with caution: if it races with current state machine operations, madness will ensue.\n *\n * @param channelType Channel type.\n * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.\n */\n @validateTypesAsync(literal('fcm', 'apn'), nonEmptyString)\n public async removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void> {\n // do not await this._ensureReady() here - it could be called at any moment\n await this.services.notificationClient.removeRegistrations(channelType, registrationId);\n }\n\n private static parsePushNotificationChatData(data: Object): Object {\n const result: Record<string, unknown> = {};\n\n for (let key in Client.supportedPushDataFields) {\n if (typeof data[key] === 'undefined' || data[key] === null) {\n continue;\n }\n\n if (key !== 'message_index') {\n result[Client.supportedPushDataFields[key]] = data[key];\n continue;\n }\n\n if (parseToNumber(data[key]) !== null) {\n result[Client.supportedPushDataFields[key]] = Number(data[key]);\n }\n }\n\n return result;\n }\n\n /**\n * Static method for push notification payload parsing. Returns parsed push as a {@link PushNotification} object.\n * @param notificationPayload Push notification payload.\n */\n @validateTypes(pureObject)\n static parsePushNotification(notificationPayload): PushNotification {\n log.debug('parsePushNotification, notificationPayload=', notificationPayload);\n\n // APNS specifics\n if (typeof notificationPayload.aps !== 'undefined') {\n if (!notificationPayload.twi_message_type) {\n throw new Error('Provided push notification payload does not contain Programmable Chat push notification type');\n }\n\n let data = Client.parsePushNotificationChatData(notificationPayload);\n\n let apsPayload = notificationPayload.aps;\n let body: string = null;\n let title: string = null;\n if (typeof apsPayload.alert === 'string') {\n body = apsPayload.alert || null;\n } else {\n body = apsPayload.alert.body || null;\n title = apsPayload.alert.title || null;\n }\n\n return new PushNotification({\n title: title,\n body: body,\n sound: apsPayload.sound || null,\n badge: apsPayload.badge || null,\n action: apsPayload.category || null,\n type: notificationPayload.twi_message_type,\n data: data\n });\n }\n\n // FCM specifics\n if (typeof notificationPayload.data !== 'undefined') {\n let dataPayload = notificationPayload.data;\n if (!dataPayload.twi_message_type) {\n throw new Error('Provided push notification payload does not contain Programmable Chat push notification type');\n }\n\n let data = Client.parsePushNotificationChatData(notificationPayload.data);\n return new PushNotification({\n title: dataPayload.twi_title || null,\n body: dataPayload.twi_body || null,\n sound: dataPayload.twi_sound || null,\n badge: null,\n action: dataPayload.twi_action || null,\n type: dataPayload.twi_message_type,\n data: data\n });\n }\n\n throw new Error('Provided push notification payload is not Programmable Chat notification');\n }\n\n public parsePushNotification = Client.parsePushNotification;\n\n /**\n * Handle push notification payload parsing and emit the {@link Client.pushNotification} event on this {@link Client} instance.\n * @param notificationPayload Push notification payload\n */\n @validateTypesAsync(pureObject)\n async handlePushNotification(notificationPayload): Promise<void> {\n await this._ensureReady;\n log.debug('handlePushNotification, notificationPayload=', notificationPayload);\n this.emit('pushNotification', Client.parsePushNotification(notificationPayload));\n }\n\n /**\n * Gets a user with the given identity. If it's in the subscribed list, then return the user object from it;\n * if not, then subscribe and add user to the subscribed list.\n * @param identity Identity of the user.\n * @returns A fully initialized user.\n */\n @validateTypesAsync(nonEmptyString)\n public async getUser(identity: string): Promise<User> {\n await this._ensureReady;\n return this.services.users.getUser(identity);\n }\n\n /**\n * Get a list of subscribed user objects.\n */\n public async getSubscribedUsers(): Promise<Array<User>> {\n await this._ensureReady;\n return this.services.users.getSubscribedUsers();\n }\n}\n\nexport {\n Client,\n State,\n ConnectionState,\n NotificationsChannelType,\n LogLevel,\n ClientOptions,\n CreateConversationOptions\n};\n"],"names":["Logger","version","Client","ReplayEventEmitter","deepClone","User","InitRegistration","TwilsockClient","NotificationClient","SyncClient","CommandExecutor","TelemetryEventDescription","TelemetryPoint","NotificationTypes","Configuration","TypingIndicator","Network","Users","ConversationsEntity","McsClient","parseToNumber","PushNotification","__decorate","validateTypesAsync","nonEmptyString","objectSchema","literal","pureObject","validateTypes","validateConstructorTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAEnC,MAAM,WAAW,GAAGC,gBAAO,CAAC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CAACC,uCAAc,CAAC;;;;0DAelC;AAODF;IADCC,2CAAkB,CAACC,uCAAc,CAAC;;;;iEAWlC;AAuBDF;IARCC,2CAAkB,CAAC;QAClB,WAAW;QACXE,qCAAY,CAAC,sBAAsB,EAAE;YACnC,YAAY,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;YACrC,SAAS,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC;YACnC,UAAU,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;SACpC,CAAC;KACH,CAAC;;;;wDAKD;AAQDH;IADCC,2CAAkB,CAACG,gCAAO,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC;;;;2DAMnD;AAQDJ;IADCC,2CAAkB,CAACG,gCAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;;;;6DAKzC;AAaDJ;IADCC,2CAAkB,CAACG,gCAAO,CAAC,KAAK,EAAE,KAAK,CAAC,EAAEF,uCAAc,CAAC;;;;6DAIzD;AAyFDF;IADCC,2CAAkB,CAACI,mCAAU,CAAC;;;;4DAK9B;AASDL;IADCC,2CAAkB,CAACC,uCAAc,CAAC;;;;6CAIlC;AAhXDF;IADCC,2CAAkB,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAEI,mCAAU,CAAC,CAAC;;;;kCAkBvD;AAkRDL;IADCM,sCAAa,CAACD,mCAAU,CAAC;;;8CACyBN,iCAAgB;iDAoDlE;AAlwBGnB,cAAM;IAJX2B,iDAAwB,CAACL,uCAAc,EAAE;QACxCG,mCAAU;QACV,WAAW;KACZ,CAAC;;GACIzB,cAAM,CAoyBX;;"}
1
+ {"version":3,"file":"client.js","sources":["../src/client.ts"],"sourcesContent":["import { Logger } from \"./logger\";\nimport { Configuration } from \"./configuration\";\n\nimport { User, UserUpdatedEventArgs, UserUpdateReason } from \"./user\";\nimport { Network } from \"./services/network\";\n\nimport { NotificationTypes } from \"./interfaces/notification-types\";\n\nimport {\n TwilsockClient,\n InitRegistration,\n ConnectionState as TwilsockConnectionState,\n Transport,\n} from \"twilsock\";\nimport {\n ChannelType,\n Notifications as NotificationClient,\n} from \"@twilio/notifications\";\nimport { SyncClient } from \"twilio-sync\";\nimport { McsClient } from \"@twilio/mcs-client\";\n\nimport {\n Conversation,\n Conversations,\n Conversations as ConversationsEntity,\n} from \"./data/conversations\";\n\nimport { Users } from \"./data/users\";\nimport { TypingIndicator } from \"./services/typing-indicator\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { PushNotification } from \"./push-notification\";\nimport { deepClone, parseToNumber } from \"./util\";\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n} from \"./participant\";\nimport {\n Message,\n MessageUpdatedEventArgs,\n MessageUpdateReason,\n} from \"./message\";\nimport { TelemetryEventDescription, TelemetryPoint } from \"twilsock\";\nimport {\n validateTypesAsync,\n validateTypes,\n literal,\n nonEmptyString,\n pureObject,\n objectSchema,\n validateConstructorTypes,\n} from \"@twilio/declarative-type-validator\";\nimport { version } from \"../package.json\";\nimport {\n ConversationUpdatedEventArgs,\n ConversationUpdateReason,\n} from \"./conversation\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { ConfigurationResponse } from \"./interfaces/commands/configuration\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport { JSONValue } from \"./types\";\n\nconst log = Logger.scope(\"Client\");\n\nconst SDK_VERSION = version;\n\nclass ClientServices {\n commandExecutor!: CommandExecutor;\n twilsockClient!: TwilsockClient;\n users!: Users;\n notificationClient!: NotificationClient;\n network!: Network;\n typingIndicator!: TypingIndicator;\n syncClient!: SyncClient;\n mcsClient!: McsClient;\n transport!: Transport;\n}\n\ntype ClientEvents = {\n conversationAdded: (conversation: Conversation) => void;\n conversationJoined: (conversation: Conversation) => void;\n conversationLeft: (conversation: Conversation) => void;\n conversationRemoved: (conversation: Conversation) => void;\n conversationUpdated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n tokenAboutToExpire: (ttl: number) => void;\n tokenExpired: () => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n pushNotification: (pushNotification: PushNotification) => void;\n userSubscribed: (user: User) => void;\n userUnsubscribed: (user: User) => void;\n userUpdated: (data: {\n user: User;\n updateReasons: UserUpdateReason[];\n }) => void;\n stateChanged: (state: State) => void;\n connectionStateChanged: (state: TwilsockConnectionState) => void;\n connectionError: (data: {\n terminal: boolean;\n message: string;\n httpStatusCode?: number;\n errorCode?: number;\n }) => void;\n};\n\n/**\n * Connection state of the client. Possible values are as follows:\n * * `'connecting'` - client is offline and connection attempt is in process\n * * `'connected'` - client is online and ready\n * * `'disconnecting'` - client is going offline as disconnection is in process\n * * `'disconnected'` - client is offline and no connection attempt is in process\n * * `'denied'` - client connection is denied because of invalid JWT access token. User must refresh token in order to proceed\n */\ntype ConnectionState = TwilsockConnectionState;\n\n/**\n * State of the client. Possible values are as follows:\n * * `'failed'` - the client failed to initialize\n * * `'initialized'` - the client successfully initialized\n */\ntype State = \"failed\" | \"initialized\";\n\n/**\n * Notifications channel type. Possible values are as follows:\n * * `'fcm'`\n * * `'apn'`\n */\ntype NotificationsChannelType = ChannelType;\n\ntype LogLevel = \"trace\" | \"debug\" | \"info\" | \"warn\" | \"error\" | \"silent\";\n\n/**\n * Conversations client options.\n */\ninterface ClientOptions {\n /**\n * The level of logging to enable.\n */\n logLevel?: LogLevel;\n region?: string;\n productId?: string;\n twilsockClient?: TwilsockClient;\n transport?: Transport;\n notificationsClient?: NotificationClient;\n syncClient?: SyncClient;\n typingIndicatorTimeoutOverride?: number;\n consumptionReportIntervalOverride?: string;\n httpCacheIntervalOverride?: string;\n userInfosToSubscribeOverride?: number;\n retryWhenThrottledOverride?: boolean;\n backoffConfigOverride?: Record<string, unknown>;\n Chat?: ClientOptions;\n IPMessaging?: ClientOptions;\n Sync?: Record<string, unknown>;\n Notification?: Record<string, unknown>;\n Twilsock?: Record<string, unknown>;\n clientMetadata?: Record<string, unknown>;\n initRegistrations?: InitRegistration[];\n disableDeepClone?: boolean;\n typingUri?: string;\n apiUri?: string;\n}\n\n/**\n * Options for {@link Client.createConversation}.\n */\ninterface CreateConversationOptions {\n /**\n * Any custom attributes to attach to the conversation.\n */\n attributes?: JSONValue;\n\n /**\n * A non-unique display name of the conversation.\n */\n friendlyName?: string;\n\n /**\n * A unique identifier of the conversation.\n */\n uniqueName?: string;\n}\n\n/**\n * A client is the starting point to the Twilio Conversations functionality.\n */\n@validateConstructorTypes(nonEmptyString, [pureObject, \"undefined\"])\nclass Client extends ReplayEventEmitter<ClientEvents> {\n /**\n * Client connection state.\n */\n public connectionState: ConnectionState = \"unknown\";\n private conversationsPromise!: Promise<Conversations>;\n private _ensureReady!: Promise<void>;\n private _resolveEnsureReady!: () => void;\n private _rejectEnsureReady!: (err: Error) => void;\n private fpaToken: string;\n private configuration!: Configuration;\n private conversations!: Conversations;\n private readonly options: Partial<ClientOptions>;\n private services: ClientServices;\n private readonly _myself: User;\n\n /**\n * Current version of the Conversations client.\n */\n public static readonly version: string = SDK_VERSION;\n\n /**\n * Current version of the Conversations client.\n */\n public readonly version: string = SDK_VERSION;\n\n private static readonly supportedPushChannels: NotificationsChannelType[] = [\n \"fcm\",\n \"apn\",\n ];\n private static readonly supportedPushDataFields = {\n conversation_sid: \"conversationSid\",\n message_sid: \"messageSid\",\n message_index: \"messageIndex\",\n };\n\n /**\n * Returned Conversations instance is not yet fully initialized. Calling any operations will block until it is.\n * Use connection events to monitor when client becomes fully available (connectionStateChanged with state\n * 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).\n *\n * @param fpaToken Access token\n * @param options Options to customize the Client\n * @returns A not yet fully-initialized client.\n */\n public constructor(fpaToken: string, options: ClientOptions | null = {}) {\n super();\n\n this.fpaToken = fpaToken ?? \"\";\n this.options = options ?? {};\n\n if (!this.options.disableDeepClone) {\n let options: Partial<ClientOptions> = {\n ...this.options,\n transport: undefined,\n twilsockClient: undefined,\n };\n\n options = deepClone(options);\n options.transport = this.options.transport;\n options.twilsockClient = this.options.twilsockClient;\n\n this.options = options;\n }\n\n this.options.logLevel = this.options.logLevel ?? \"silent\";\n log.setLevel(this.options.logLevel);\n\n const productId = (this.options.productId = \"ip_messaging\");\n\n // Filling ClientMetadata\n this.options.clientMetadata = this.options.clientMetadata || {};\n\n if (!this.options.clientMetadata.hasOwnProperty(\"type\")) {\n this.options.clientMetadata.type = \"conversations\";\n }\n\n if (!this.options.clientMetadata.hasOwnProperty(\"sdk\")) {\n this.options.clientMetadata.sdk = \"JS\";\n this.options.clientMetadata.sdkv = SDK_VERSION;\n }\n\n // Enable session local storage for Sync\n this.options.Sync = this.options.Sync || {};\n\n if (typeof this.options.Sync.enableSessionStorage === \"undefined\") {\n this.options.Sync.enableSessionStorage = true;\n }\n\n if (this.options.region) {\n this.options.Sync.region = this.options.region;\n }\n\n if (!fpaToken) {\n throw new Error(\"A valid Twilio token should be provided\");\n }\n\n this.services = new ClientServices();\n\n this._myself = new User(\"\", \"\", null, this.services);\n\n const startTwilsock = !this.options.twilsockClient;\n\n // Create default init registrations if none were provided.\n // Otherwise, the outside party have to list all the init registrations they\n // need.\n // Init registrations passed to the Conversations client will be passed down\n // to the Sync client as well.\n if (!this.options.initRegistrations) {\n const initRegistration = new InitRegistration(productId);\n Client.populateInitRegistrations(initRegistration);\n this.options.initRegistrations = [initRegistration];\n }\n\n this.services.twilsockClient = this.options.twilsockClient =\n this.options.twilsockClient ??\n new TwilsockClient(fpaToken, productId, this.options);\n\n this.services.twilsockClient.on(\"tokenAboutToExpire\", (ttl) =>\n this.emit(\"tokenAboutToExpire\", ttl)\n );\n this.services.twilsockClient.on(\"tokenExpired\", () =>\n this.emit(\"tokenExpired\")\n );\n this.services.twilsockClient.on(\"connectionError\", (error) =>\n this.emit(\"connectionError\", error)\n );\n this.services.twilsockClient.on(\n \"stateChanged\",\n (state: ConnectionState) => {\n log.debug(\n `Handling stateChanged for ConversationsClient: new state ${state}`\n );\n if (state !== this.connectionState) {\n this.connectionState = state;\n this.emit(\"connectionStateChanged\", this.connectionState);\n }\n }\n );\n\n this.services.transport = this.options.transport = (this.options\n .transport ?? this.options.twilsockClient) as Transport;\n this.services.notificationClient = this.options.notificationsClient =\n this.options.notificationsClient ??\n new NotificationClient(fpaToken, this.options);\n this.services.syncClient = this.options.syncClient =\n this.options.syncClient ?? new SyncClient(fpaToken, this.options);\n\n const configurationOptions =\n options?.Chat || options?.IPMessaging || options || {};\n const region = configurationOptions.region || options?.region;\n const baseUrl: string =\n configurationOptions.apiUri ||\n configurationOptions.typingUri ||\n `https://aim.${region || \"us1\"}.twilio.com`;\n\n this.services.commandExecutor = new CommandExecutor(\n baseUrl,\n { transport: this.options.transport },\n productId\n );\n\n const emitFailed = (err): void => {\n this._rejectEnsureReady(err);\n this.emit(\"stateChanged\", \"failed\");\n };\n\n this.services.twilsockClient.once(\"connectionError\", emitFailed);\n this.services.twilsockClient.once(\"disconnected\", emitFailed);\n\n // ConversationsClient will be able to initialize only after twilsock is connected\n this.services.twilsockClient.once(\"connected\", async () => {\n log.debug(`ConversationsClient started INITIALIZING`);\n this.services.twilsockClient.off(\"connectionError\", emitFailed);\n this.services.twilsockClient.off(\"disconnected\", emitFailed);\n try {\n const startupEvent = \"conversations.client.startup\";\n\n this.services.twilsockClient.addPartialTelemetryEvent(\n new TelemetryEventDescription(\n startupEvent,\n \"Conversations client startup\",\n new Date()\n ),\n startupEvent,\n TelemetryPoint.Start\n );\n\n await this._initialize();\n\n this.services.twilsockClient.addPartialTelemetryEvent(\n new TelemetryEventDescription(\"\", \"\", new Date()),\n startupEvent,\n TelemetryPoint.End\n );\n } catch (err) {\n // Fail ChatClient if initialization is incomplete\n this._rejectEnsureReady(err);\n this.emit(\"stateChanged\", \"failed\");\n }\n });\n\n this._ensureReady = new Promise<void>((resolve, reject) => {\n this._resolveEnsureReady = resolve;\n this._rejectEnsureReady = reject;\n }).catch(() => void 0); // @todo How to process unhandled rejection here?\n\n if (startTwilsock) {\n this.services.twilsockClient.connect();\n }\n }\n\n public static populateInitRegistrations(reg: InitRegistration) {\n reg.populateInitRegistrations([NotificationTypes.TYPING_INDICATOR]);\n SyncClient.populateInitRegistrations(reg);\n }\n\n /**\n * Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.\n * Fired for all conversations client has joined.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n static readonly conversationAdded = \"conversationAdded\";\n\n /**\n * Fired when the client joins a conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n static readonly conversationJoined = \"conversationJoined\";\n\n /**\n * Fired when the client leaves a conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n static readonly conversationLeft = \"conversationLeft\";\n\n /**\n * Fired when a conversation is no longer visible to the client.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - the conversation in question\n * @event\n */\n static readonly conversationRemoved = \"conversationRemoved\";\n\n /**\n * Fired when the attributes or the metadata of a conversation have been updated.\n * During conversation's creation and initialization, this event might be fired multiple times\n * for same joined or created conversation as new data is arriving from different sources.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Conversation} `conversation` - the conversation in question\n * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n static readonly conversationUpdated = \"conversationUpdated\";\n\n /**\n * Fired when a participant has joined a conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly participantJoined = \"participantJoined\";\n\n /**\n * Fired when a participant has left a conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly participantLeft = \"participantLeft\";\n\n /**\n * Fired when a participant's fields have been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Participant} `participant` - the participant in question\n * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n static readonly participantUpdated = \"participantUpdated\";\n\n /**\n * Fired when a new message has been added to the conversation on the server.\n *\n * Parameters:\n * 1. {@link Message} `message` - the message in question\n * @event\n */\n static readonly messageAdded = \"messageAdded\";\n\n /**\n * Fired when a message is removed from the message list of a conversation.\n *\n * Parameters:\n * 1. {@link Message} `message` - the message in question\n * @event\n */\n static readonly messageRemoved = \"messageRemoved\";\n\n /**\n * Fired when the fields of an existing message are updated with new values.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Message} `message` - the message in question\n * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n static readonly messageUpdated = \"messageUpdated\";\n\n /**\n * Fired when the token is about to expire and needs to be updated.\n * * Parameters:\n * 1. number `message` - token's time to live\n * @event\n */\n static readonly tokenAboutToExpire = \"tokenAboutToExpire\";\n\n /**\n * Fired when the token has expired.\n * @event\n */\n static readonly tokenExpired = \"tokenExpired\";\n\n /**\n * Fired when a participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingEnded = \"typingEnded\";\n\n /**\n * Fired when a participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingStarted = \"typingStarted\";\n\n /**\n * Fired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).\n *\n * Parameters:\n * 1. {@link PushNotification} `pushNotification` - the push notification in question\n * @event\n */\n static readonly pushNotification = \"pushNotification\";\n\n /**\n * Fired when the client has subscribed to a user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n static readonly userSubscribed = \"userSubscribed\";\n\n /**\n * Fired when the client has unsubscribed from a user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n static readonly userUnsubscribed = \"userUnsubscribed\";\n\n /**\n * Fired when the properties or the reachability status of a user have been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link User} `user` - the user in question\n * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n static readonly userUpdated = \"userUpdated\";\n\n /**\n * Fired when the state of the client has been changed.\n *\n * Parameters:\n * 1. {@link State} `state` - the new client state\n * @event\n */\n static readonly stateChanged = \"stateChanged\";\n\n /**\n * Fired when the connection state of the client has been changed.\n *\n * Paremeters:\n * 1. {@link ConnectionState} `state` - the new connection state\n * @event\n */\n static readonly connectionStateChanged = \"connectionStateChanged\";\n\n /**\n * Fired when the connection is interrupted for an unexpected reason.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * boolean `terminal` - Twilsock will stop connection attempts if true\n * * string `message` - the error message of the root cause\n * * number? `httpStatusCode` - http status code if available\n * * number? `errorCode` - Twilio public error code if available\n * @event\n */\n static readonly connectionError = \"connectionError\";\n\n /**\n * @deprecated Call constructor directly.\n *\n * Factory method to create a Conversations client instance.\n *\n * The factory method will automatically trigger connection.\n * Do not use it if you need finer-grained control.\n *\n * Since this method returns an already-initialized client, some of the events\n * will be lost because they happen *before* the initialization. It is\n * recommended that `client.onWithReplay` is used as opposed to `client.on`\n * for subscribing to client events. The `client.onWithReplay` will re-emit\n * the most recent value for a given event if it emitted before the\n * subscription.\n *\n * @param token Access token.\n * @param options Options to customize the client.\n * @returns Returns a fully initialized client.\n */\n @validateTypesAsync(\"string\", [\"undefined\", pureObject])\n static async create(\n token: string,\n options?: ClientOptions | null\n ): Promise<Client> {\n // The logic is as follows:\n // - If twilsock is not passed in, then the ConversationsClient constructor will call twilsock.connect() by itself\n // and we do not need to do it here.\n // - If twilsock was passed in from the outside, but customer called ConversationsClient.create() then they are\n // using an obsolete workflow and the startup sequence will never complete.\n if (options?.twilsockClient) {\n throw new Error(\n \"Obsolete usage of ConversationsClient.create() \" +\n \"factory method: if you pass twilsock from the outside then you must \" +\n \"use ConversationsClient constructor and be prepared to work with \" +\n \"uninitialized client.\"\n );\n }\n\n const client = new Client(token, options);\n await client._ensureReady;\n\n return client;\n }\n\n /**\n * Information of the logged-in user. Before client initialization, returns an\n * uninitialized user. Will trigger a {@link Client.userUpdated} event after\n * initialization.\n */\n public get user(): User {\n return this._myself;\n }\n\n /**\n * Client reachability state. Throws if accessed before the client\n * initialization was completed.\n */\n public get reachabilityEnabled(): boolean {\n if (!this.configuration) {\n throw new Error(\n \"Reachability information could not yet be accessed as the client \" +\n \"has not yet been initialized. Subscribe to the 'stateChanged' event \" +\n \"to properly react to the client initialization.\"\n );\n }\n\n return this.configuration.reachabilityEnabled;\n }\n\n public get token(): string {\n return this.fpaToken;\n }\n\n private _subscribeToPushNotifications(channelType: NotificationsChannelType) {\n [\n NotificationTypes.NEW_MESSAGE,\n NotificationTypes.ADDED_TO_CONVERSATION,\n NotificationTypes.REMOVED_FROM_CONVERSATION,\n NotificationTypes.TYPING_INDICATOR,\n NotificationTypes.CONSUMPTION_UPDATE,\n ].forEach((messageType) => {\n this.services.notificationClient.subscribe(channelType, messageType);\n });\n }\n\n private _unsubscribeFromPushNotifications(\n channelType: NotificationsChannelType\n ) {\n [\n NotificationTypes.NEW_MESSAGE,\n NotificationTypes.ADDED_TO_CONVERSATION,\n NotificationTypes.REMOVED_FROM_CONVERSATION,\n NotificationTypes.TYPING_INDICATOR,\n NotificationTypes.CONSUMPTION_UPDATE,\n ].forEach((messageType) => {\n this.services.notificationClient.unsubscribe(channelType, messageType);\n });\n }\n\n private async _initialize() {\n const configurationResponse =\n await this.services.commandExecutor.fetchResource<\n void,\n ConfigurationResponse\n >(\"Client/v2/Configuration\");\n\n this.configuration = new Configuration(\n this.options as ClientOptions,\n configurationResponse,\n log\n );\n\n this._myself._resolveInitialization(\n this.configuration,\n this.configuration.userIdentity,\n this.configuration.userInfo,\n true\n );\n\n this.services.typingIndicator = new TypingIndicator(\n this.getConversationBySid.bind(this),\n this.configuration,\n this.services\n );\n this.services.network = new Network(this.configuration, this.services);\n\n this.services.users = new Users(\n this._myself,\n this.configuration,\n this.services\n );\n this.services.users.on(\"userSubscribed\", (user) => {\n this.emit(\"userSubscribed\", user);\n });\n this.services.users.on(\"userUpdated\", (args: UserUpdatedEventArgs) =>\n this.emit(\"userUpdated\", args)\n );\n this.services.users.on(\"userUnsubscribed\", (user) => {\n this.emit(\"userUnsubscribed\", user);\n });\n\n this.conversations = new ConversationsEntity(\n this.configuration,\n this.services\n );\n\n this.conversations.on(\"conversationAdded\", (conversation) => {\n this.emit(\"conversationAdded\", conversation);\n });\n this.conversations.on(\"conversationRemoved\", (conversation) => {\n this.emit(\"conversationRemoved\", conversation);\n });\n this.conversations.on(\"conversationJoined\", (conversation) => {\n this.emit(\"conversationJoined\", conversation);\n });\n this.conversations.on(\"conversationLeft\", (conversation) => {\n this.emit(\"conversationLeft\", conversation);\n });\n this.conversations.on(\n \"conversationUpdated\",\n (args: ConversationUpdatedEventArgs) =>\n this.emit(\"conversationUpdated\", args)\n );\n\n this.conversations.on(\"participantJoined\", (participant) => {\n this.emit(\"participantJoined\", participant);\n });\n this.conversations.on(\"participantLeft\", (participant) => {\n this.emit(\"participantLeft\", participant);\n });\n this.conversations.on(\n \"participantUpdated\",\n (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n\n this.conversations.on(\"messageAdded\", (message) =>\n this.emit(\"messageAdded\", message)\n );\n this.conversations.on(\"messageUpdated\", (args: MessageUpdatedEventArgs) =>\n this.emit(\"messageUpdated\", args)\n );\n this.conversations.on(\"messageRemoved\", (message) =>\n this.emit(\"messageRemoved\", message)\n );\n\n this.conversations.on(\"typingStarted\", (participant) =>\n this.emit(\"typingStarted\", participant)\n );\n this.conversations.on(\"typingEnded\", (participant) =>\n this.emit(\"typingEnded\", participant)\n );\n\n this.conversationsPromise = this.conversations\n .fetchConversations()\n .then(() => this.conversations)\n .catch((error) => {\n throw error;\n });\n\n await this.services.users.myself._ensureFetched();\n\n Client.supportedPushChannels.forEach((channelType) =>\n this._subscribeToPushNotifications(channelType)\n );\n this.services.typingIndicator.initialize();\n\n this.services.mcsClient = new McsClient(\n this.fpaToken,\n this.configuration.links.mediaService,\n this.configuration.links.mediaSetService,\n {\n ...this.options,\n transport: undefined,\n }\n );\n\n this._resolveEnsureReady();\n this.emit(\"stateChanged\", \"initialized\");\n }\n\n /**\n * Gracefully shut down the client.\n */\n async shutdown(): Promise<void> {\n await this._ensureReady;\n await this.services.twilsockClient.disconnect();\n }\n\n /**\n * Update the token used by the client and re-register with the Conversations services.\n * @param token New access token.\n */\n @validateTypesAsync(nonEmptyString)\n async updateToken(token: string): Promise<Client> {\n await this._ensureReady;\n log.info(\"updateToken\");\n\n if (this.fpaToken === token) {\n return this;\n }\n\n await this.services.twilsockClient.updateToken(token);\n await this.services.notificationClient.updateToken(token);\n await this.services.mcsClient.updateToken(token);\n this.fpaToken = token;\n\n return this;\n }\n\n /**\n * Get a known conversation by its SID.\n * @param conversationSid Conversation sid\n */\n @validateTypesAsync(nonEmptyString)\n async getConversationBySid(conversationSid: string): Promise<Conversation> {\n await this._ensureReady;\n await this.conversations.myConversationsRead.promise;\n let conversation = await this.conversations.getConversation(\n conversationSid\n );\n\n if (!conversation) {\n conversation = await this.conversations.peekConversation(conversationSid);\n }\n\n if (!conversation) {\n throw new Error(`Conversation with SID ${conversationSid} is not found.`);\n }\n\n return conversation;\n }\n\n /**\n * Get a known conversation by its unique identifier name.\n * @param uniqueName The unique identifier name of the conversation.\n */\n @validateTypesAsync(nonEmptyString)\n async getConversationByUniqueName(uniqueName: string): Promise<Conversation> {\n await this._ensureReady;\n await this.conversations.myConversationsRead.promise;\n const conversation = await this.conversations.getConversationByUniqueName(\n uniqueName\n );\n\n if (!conversation) {\n throw new Error(\n `Conversation with unique name ${uniqueName} is not found.`\n );\n }\n\n return conversation;\n }\n\n /**\n * Get the current list of all the subscribed conversations.\n */\n public async getSubscribedConversations(): Promise<Paginator<Conversation>> {\n await this._ensureReady;\n return this.conversationsPromise.then((conversations) =>\n conversations.getConversations()\n );\n }\n\n /**\n * Create a conversation on the server and subscribe to its events.\n * The default is a conversation with an empty friendly name.\n * @param options Options for the conversation.\n */\n @validateTypesAsync([\n \"undefined\",\n objectSchema(\"conversation options\", {\n friendlyName: [\"string\", \"undefined\"],\n isPrivate: [\"boolean\", \"undefined\"],\n uniqueName: [\"string\", \"undefined\"],\n }),\n ])\n public async createConversation(\n options?: CreateConversationOptions\n ): Promise<Conversation> {\n await this._ensureReady;\n options = options || {};\n return this.conversationsPromise.then((conversationsEntity) =>\n conversationsEntity.addConversation(options)\n );\n }\n\n /**\n * Register for push notifications.\n * @param channelType Channel type.\n * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.\n */\n @validateTypesAsync(literal(\"fcm\", \"apn\"), \"string\")\n public async setPushRegistrationId(\n channelType: NotificationsChannelType,\n registrationId: string\n ): Promise<void> {\n await this._ensureReady;\n this._subscribeToPushNotifications(channelType);\n this.services.notificationClient.setPushRegistrationId(\n channelType,\n registrationId\n );\n await this.services.notificationClient.commitChanges(); // Committing before this point is useless because we have no push id\n }\n\n /**\n * Unregister from push notifications.\n * @param channelType Channel type.\n * @deprecated Use removePushRegistrations() instead.\n */\n @validateTypesAsync(literal(\"fcm\", \"apn\"))\n public async unsetPushRegistrationId(\n channelType: NotificationsChannelType\n ): Promise<void> {\n await this._ensureReady;\n this._unsubscribeFromPushNotifications(channelType);\n await this.services.notificationClient.commitChanges();\n }\n\n /**\n * Clear existing registrations directly using provided device token.\n * This is useful to ensure stopped subscriptions without resubscribing.\n *\n * This function goes completely beside the state machine and removes all registrations.\n * Use with caution: if it races with current state machine operations, madness will ensue.\n *\n * @param channelType Channel type.\n * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.\n */\n @validateTypesAsync(literal(\"fcm\", \"apn\"), nonEmptyString)\n public async removePushRegistrations(\n channelType: ChannelType,\n registrationId: string\n ): Promise<void> {\n // do not await this._ensureReady() here - it could be called at any moment\n await this.services.notificationClient.removeRegistrations(\n channelType,\n registrationId\n );\n }\n\n private static parsePushNotificationChatData(\n data: Record<string, unknown>\n ): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const key in Client.supportedPushDataFields) {\n if (typeof data[key] === \"undefined\" || data[key] === null) {\n continue;\n }\n\n if (key !== \"message_index\") {\n result[Client.supportedPushDataFields[key]] = data[key];\n continue;\n }\n\n if (parseToNumber(data[key]) !== null) {\n result[Client.supportedPushDataFields[key]] = Number(data[key]);\n }\n }\n\n return result;\n }\n\n /**\n * Static method for push notification payload parsing. Returns parsed push as a {@link PushNotification} object.\n * @param notificationPayload Push notification payload.\n */\n @validateTypes(pureObject)\n static parsePushNotification(notificationPayload): PushNotification {\n log.debug(\n \"parsePushNotification, notificationPayload=\",\n notificationPayload\n );\n\n // APNS specifics\n if (typeof notificationPayload.aps !== \"undefined\") {\n if (!notificationPayload.twi_message_type) {\n throw new Error(\n \"Provided push notification payload does not contain Programmable Chat push notification type\"\n );\n }\n\n const data = Client.parsePushNotificationChatData(notificationPayload);\n\n const apsPayload = notificationPayload.aps;\n let body: string | null;\n let title: string | null = null;\n if (typeof apsPayload.alert === \"string\") {\n body = apsPayload.alert || null;\n } else {\n body = apsPayload.alert.body || null;\n title = apsPayload.alert.title || null;\n }\n\n return new PushNotification({\n title,\n body,\n sound: apsPayload.sound || null,\n badge: apsPayload.badge || null,\n action: apsPayload.category || null,\n type: notificationPayload.twi_message_type,\n data: data,\n });\n }\n\n // FCM specifics\n if (typeof notificationPayload.data !== \"undefined\") {\n const dataPayload = notificationPayload.data;\n if (!dataPayload.twi_message_type) {\n throw new Error(\n \"Provided push notification payload does not contain Programmable Chat push notification type\"\n );\n }\n\n const data = Client.parsePushNotificationChatData(\n notificationPayload.data\n );\n return new PushNotification({\n title: dataPayload.twi_title || null,\n body: dataPayload.twi_body || null,\n sound: dataPayload.twi_sound || null,\n badge: null,\n action: dataPayload.twi_action || null,\n type: dataPayload.twi_message_type,\n data: data,\n });\n }\n\n throw new Error(\n \"Provided push notification payload is not Programmable Chat notification\"\n );\n }\n\n public parsePushNotification = Client.parsePushNotification;\n\n /**\n * Handle push notification payload parsing and emit the {@link Client.pushNotification} event on this {@link Client} instance.\n * @param notificationPayload Push notification payload\n */\n @validateTypesAsync(pureObject)\n async handlePushNotification(notificationPayload): Promise<void> {\n await this._ensureReady;\n log.debug(\n \"handlePushNotification, notificationPayload=\",\n notificationPayload\n );\n this.emit(\n \"pushNotification\",\n Client.parsePushNotification(notificationPayload)\n );\n }\n\n /**\n * Gets a user with the given identity. If it's in the subscribed list, then return the user object from it;\n * if not, then subscribe and add user to the subscribed list.\n * @param identity Identity of the user.\n * @returns A fully initialized user.\n */\n @validateTypesAsync(nonEmptyString)\n public async getUser(identity: string): Promise<User> {\n await this._ensureReady;\n return this.services.users.getUser(identity);\n }\n\n /**\n * Get a list of subscribed user objects.\n */\n public async getSubscribedUsers(): Promise<Array<User>> {\n await this._ensureReady;\n return this.services.users.getSubscribedUsers();\n }\n}\n\nexport {\n Client,\n State,\n ConnectionState,\n NotificationsChannelType,\n LogLevel,\n ClientOptions,\n CreateConversationOptions,\n};\n"],"names":["Logger","version","Client","ReplayEventEmitter","deepClone","User","InitRegistration","TwilsockClient","NotificationClient","SyncClient","CommandExecutor","TelemetryEventDescription","TelemetryPoint","NotificationTypes","Configuration","TypingIndicator","Network","Users","ConversationsEntity","McsClient","parseToNumber","PushNotification","__decorate","validateTypesAsync","nonEmptyString","objectSchema","literal","pureObject","validateTypes","validateConstructorTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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GAC9DzB,cAAM,CA26BX;;"}
@@ -133,7 +133,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
133
133
  var uuid = require('uuid');
134
134
  var operationRetrier = require('@twilio/operation-retrier');
135
135
 
136
- const trimSlashes = (url) => url.replace(/(^\/+|\/+$)/g, '');
136
+ const trimSlashes = (url) => url.replace(/(^\/+|\/+$)/g, "");
137
137
  const isMutationConflictResponse = (response) => response.status.code === 202;
138
138
  class CommandExecutor {
139
139
  constructor(_serviceUrl, _services, _productId) {
@@ -150,25 +150,25 @@ class CommandExecutor {
150
150
  }
151
151
  async _makeRequest(method, url, requestBody, headers) {
152
152
  const preProcessedUrl = this._preProcessUrl(url);
153
- const finalHeaders = Object.assign({ 'Content-Type': 'application/json; charset=utf-8' }, (headers || {}));
153
+ const finalHeaders = Object.assign({ "Content-Type": "application/json; charset=utf-8" }, (headers || {}));
154
154
  let response;
155
155
  switch (method) {
156
- case 'get':
156
+ case "get":
157
157
  let getUrl = preProcessedUrl;
158
158
  if (requestBody) {
159
159
  getUrl +=
160
- '?' +
160
+ "?" +
161
161
  Object.entries(requestBody)
162
- .map((entry) => entry.map(encodeURIComponent).join('='))
163
- .join('&');
162
+ .map((entry) => entry.map(encodeURIComponent).join("="))
163
+ .join("&");
164
164
  }
165
165
  response = await this._services.transport.get(getUrl, finalHeaders, this._productId);
166
166
  break;
167
- case 'post':
167
+ case "post":
168
168
  response = await this._services.transport.post(preProcessedUrl, finalHeaders, JSON.stringify(requestBody), this._productId);
169
169
  break;
170
- case 'delete':
171
- response = await this._services.transport.delete(preProcessedUrl, finalHeaders, null, this._productId);
170
+ case "delete":
171
+ response = await this._services.transport.delete(preProcessedUrl, finalHeaders, {}, this._productId);
172
172
  break;
173
173
  }
174
174
  if (response.status.code < 200 || response.status.code >= 300) {
@@ -178,19 +178,21 @@ class CommandExecutor {
178
178
  }
179
179
  async fetchResource(url, requestBody) {
180
180
  const maxAttemptsCount = 6;
181
- let result;
182
181
  try {
183
- result = await new operationRetrier.AsyncRetrier({ min: 50, max: 1600, maxAttemptsCount })
184
- .run(() => this._makeRequest('get', url, requestBody));
182
+ const result = await new operationRetrier.AsyncRetrier({
183
+ min: 50,
184
+ max: 1600,
185
+ maxAttemptsCount,
186
+ }).run(() => this._makeRequest("get", url, requestBody));
187
+ return result.body;
185
188
  }
186
189
  catch (_a) {
187
190
  throw new Error(`Fetch resource from "${url}" failed.`);
188
191
  }
189
- return result.body;
190
192
  }
191
193
  async mutateResource(method, url, requestBody) {
192
194
  const result = await this._makeRequest(method, url, requestBody, {
193
- 'X-Twilio-Mutation-Id': uuid.v4()
195
+ "X-Twilio-Mutation-Id": uuid.v4(),
194
196
  });
195
197
  if (isMutationConflictResponse(result)) {
196
198
  return await this.fetchResource(result.body.resource_url);
@@ -1 +1 @@
1
- {"version":3,"file":"command-executor.js","sources":["../src/command-executor.ts"],"sourcesContent":["import { TransportResult as Result, Transport } from 'twilsock';\nimport { MutationConflictResponse } from './interfaces/commands/mutation-conflict';\nimport { v4 as uuidv4 } from 'uuid';\nimport { AsyncRetrier } from '@twilio/operation-retrier';\n\nexport interface CommandExecutorServices {\n transport: Transport;\n}\n\nconst trimSlashes = (url: string): string =>\n url.replace(/(^\\/+|\\/+$)/g, '');\n\nconst isMutationConflictResponse = (response: Result<unknown>): response is Result<MutationConflictResponse> =>\n response.status.code === 202;\n\nclass CommandExecutor {\n constructor(\n private _serviceUrl: string,\n private _services: CommandExecutorServices,\n private _productId?: string\n ) {}\n\n private _preProcessUrl(url: string): string {\n const trimmedUrl = trimSlashes(url);\n\n if (/^https?:\\/\\//.test(url)) {\n return trimmedUrl;\n }\n\n return `${trimSlashes(this._serviceUrl)}/${trimmedUrl}`;\n }\n\n private async _makeRequest<REQ = void, RESP = void>(\n method: 'get' | 'post' | 'delete',\n url: string,\n requestBody?: REQ,\n headers?: Record<string, string>\n ): Promise<Result<RESP>> {\n const preProcessedUrl = this._preProcessUrl(url);\n const finalHeaders = {\n 'Content-Type': 'application/json; charset=utf-8',\n ...(headers || {})\n };\n let response: Result<RESP>;\n\n switch (method) {\n case 'get':\n let getUrl = preProcessedUrl;\n\n if (requestBody) {\n getUrl +=\n '?' +\n Object.entries(requestBody)\n .map((entry) => entry.map(encodeURIComponent).join('='))\n .join('&');\n }\n\n response = await this._services.transport.get(getUrl, finalHeaders, this._productId);\n break;\n case 'post':\n response = await this._services.transport.post(preProcessedUrl, finalHeaders, JSON.stringify(requestBody), this._productId);\n break;\n case 'delete':\n response = await this._services.transport.delete(preProcessedUrl, finalHeaders, null, this._productId);\n break;\n }\n\n if (response.status.code < 200 || response.status.code >= 300) {\n throw new Error(`Request responded with a non-success code ${response.status.code}`);\n }\n\n return response;\n }\n\n public async fetchResource<REQ = void, RESP = void>(\n url: string,\n requestBody?: REQ\n ): Promise<RESP> {\n const maxAttemptsCount = 6;\n let result: Result<RESP>;\n\n try {\n result = await new AsyncRetrier({ min: 50, max: 1600, maxAttemptsCount })\n .run(() => this._makeRequest<REQ, RESP>('get', url, requestBody));\n } catch {\n throw new Error(`Fetch resource from \"${url}\" failed.`);\n }\n\n return result.body;\n }\n\n public async mutateResource<REQ = void, RESP = void>(\n method: 'post' | 'delete',\n url: string,\n requestBody?: REQ\n ): Promise<RESP> {\n const result = await this._makeRequest<REQ, RESP>(method, url, requestBody, {\n 'X-Twilio-Mutation-Id': uuidv4()\n });\n\n if (isMutationConflictResponse(result)) {\n return await this.fetchResource<undefined, RESP>(result.body.resource_url);\n }\n\n return result.body;\n }\n}\n\nexport { CommandExecutor };"],"names":["AsyncRetrier","uuidv4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,WAAW,GAAG,CAAC,GAAW,KAC9B,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;AAElC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AAE;SACjC,CAAC,CAAC;QAEH,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAE;YACtC,OAAO,MAAM,IAAI,CAAC,aAAa,CAAkB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAC5E;QAED,OAAO,MAAM,CAAC,IAAI,CAAC;KACpB;;;;;"}
1
+ {"version":3,"file":"command-executor.js","sources":["../src/command-executor.ts"],"sourcesContent":["import { TransportResult as Result, Transport } from \"twilsock\";\nimport { MutationConflictResponse } from \"./interfaces/commands/mutation-conflict\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { AsyncRetrier } from \"@twilio/operation-retrier\";\n\nexport interface CommandExecutorServices {\n transport: Transport;\n}\n\nconst trimSlashes = (url: string): string => url.replace(/(^\\/+|\\/+$)/g, \"\");\n\nconst isMutationConflictResponse = (\n response: Result<unknown>\n): response is Result<MutationConflictResponse> => response.status.code === 202;\n\nclass CommandExecutor {\n constructor(\n private _serviceUrl: string,\n private _services: CommandExecutorServices,\n private _productId?: string\n ) {}\n\n private _preProcessUrl(url: string): string {\n const trimmedUrl = trimSlashes(url);\n\n if (/^https?:\\/\\//.test(url)) {\n return trimmedUrl;\n }\n\n return `${trimSlashes(this._serviceUrl)}/${trimmedUrl}`;\n }\n\n private async _makeRequest<REQ = void, RESP = void>(\n method: \"get\" | \"post\" | \"delete\",\n url: string,\n requestBody?: REQ,\n headers?: Record<string, string>\n ): Promise<Result<RESP>> {\n const preProcessedUrl = this._preProcessUrl(url);\n const finalHeaders = {\n \"Content-Type\": \"application/json; charset=utf-8\",\n ...(headers || {}),\n };\n let response: Result<RESP>;\n\n switch (method) {\n case \"get\":\n let getUrl = preProcessedUrl;\n\n if (requestBody) {\n getUrl +=\n \"?\" +\n Object.entries(requestBody)\n .map((entry) => entry.map(encodeURIComponent).join(\"=\"))\n .join(\"&\");\n }\n\n response = await this._services.transport.get(\n getUrl,\n finalHeaders,\n this._productId\n );\n break;\n case \"post\":\n response = await this._services.transport.post(\n preProcessedUrl,\n finalHeaders,\n JSON.stringify(requestBody),\n this._productId\n );\n break;\n case \"delete\":\n response = await this._services.transport.delete(\n preProcessedUrl,\n finalHeaders,\n {},\n this._productId\n );\n break;\n }\n\n if (response.status.code < 200 || response.status.code >= 300) {\n throw new Error(\n `Request responded with a non-success code ${response.status.code}`\n );\n }\n\n return response;\n }\n\n public async fetchResource<REQ = void, RESP = void>(\n url: string,\n requestBody?: REQ\n ): Promise<RESP> {\n const maxAttemptsCount = 6;\n\n try {\n const result = await new AsyncRetrier({\n min: 50,\n max: 1600,\n maxAttemptsCount,\n }).run(() => this._makeRequest<REQ, RESP>(\"get\", url, requestBody));\n return result.body;\n } catch {\n throw new Error(`Fetch resource from \"${url}\" failed.`);\n }\n }\n\n public async mutateResource<REQ = void, RESP = void>(\n method: \"post\" | \"delete\",\n url: string,\n requestBody?: REQ\n ): Promise<RESP> {\n const result = await this._makeRequest<REQ, RESP>(\n method,\n url,\n requestBody,\n {\n \"X-Twilio-Mutation-Id\": uuidv4(),\n }\n );\n\n if (isMutationConflictResponse(result)) {\n return await this.fetchResource<undefined, RESP>(\n result.body.resource_url\n );\n }\n\n return result.body;\n }\n}\n\nexport { CommandExecutor };\n"],"names":["AsyncRetrier","uuidv4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,WAAW,GAAG,CAAC,GAAW,KAAa,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;AAE7E,MAAM,0BAA0B,GAAG,CACjC,QAAyB,KACwB,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,GAAG,CAAC;AAEhF,MAAM,eAAe;IACnB,YACU,WAAmB,EACnB,SAAkC,EAClC,UAAmB;QAFnB,gBAAW,GAAX,WAAW,CAAQ;QACn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object.defineProperty(exports, '__esModule', { value: true });
133
133
  var iso8601Duration = require('iso8601-duration');
134
134
 
135
135
  const TYPING_TIMEOUT = 5;
136
- const HTTP_CACHE_LIFETIME = 'PT5S';
137
- const CONSUMPTION_HORIZON_SENDING_INTERVAL = 'PT5S';
136
+ const HTTP_CACHE_LIFETIME = "PT5S";
137
+ const CONSUMPTION_HORIZON_SENDING_INTERVAL = "PT5S";
138
138
  const USER_INFOS_TO_SUBSCRIBE = 100;
139
139
  const MINIMUM_RETRY_DELAY = 1000;
140
140
  const MAXIMUM_RETRY_DELAY = 4000;
@@ -154,22 +154,26 @@ class Configuration {
154
154
  typing: configurationResponse.links.typing,
155
155
  mediaService: configurationResponse.links.media_service,
156
156
  mediaSetService: configurationResponse.links.media_set_service,
157
- messagesReceipts: configurationResponse.links.messages_receipts
157
+ messagesReceipts: configurationResponse.links.messages_receipts,
158
158
  };
159
159
  this.limits = {
160
160
  mediaAttachmentsCountLimit: configurationResponse.options.media_attachments_count_limit,
161
161
  mediaAttachmentSizeLimitInMb: configurationResponse.options.media_attachment_size_limit_in_mb,
162
162
  mediaAttachmentsTotalSizeLimitInMb: configurationResponse.options.media_attachments_total_size_limit_in_mb,
163
163
  emailHistoriesAllowedMimeTypes: configurationResponse.options.email_histories_allowed_mime_types,
164
- emailBodiesAllowedMimeTypes: configurationResponse.options.email_bodies_allowed_mime_types
164
+ emailBodiesAllowedMimeTypes: configurationResponse.options.email_bodies_allowed_mime_types,
165
165
  };
166
- this.typingIndicatorTimeoutOverride = constructorOptions.typingIndicatorTimeoutOverride;
166
+ this.typingIndicatorTimeoutOverride =
167
+ constructorOptions.typingIndicatorTimeoutOverride;
167
168
  this.backoffConfiguration = Object.assign({ min: MINIMUM_RETRY_DELAY, max: MAXIMUM_RETRY_DELAY, maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT }, constructorOptions.backoffConfigOverride);
168
- this.retryWhenThrottled = constructorOptions.retryWhenThrottledOverride !== undefined
169
- ? constructorOptions.retryWhenThrottledOverride
170
- : RETRY_WHEN_THROTTLED;
171
- this.userInfosToSubscribe = (_b = (_a = constructorOptions.userInfosToSubscribeOverride) !== null && _a !== void 0 ? _a : configurationResponse.options.user_infos_to_subscribe) !== null && _b !== void 0 ? _b : USER_INFOS_TO_SUBSCRIBE;
172
- this.reachabilityEnabled = configurationResponse.options.reachability_enabled;
169
+ this.retryWhenThrottled =
170
+ constructorOptions.retryWhenThrottledOverride !== undefined
171
+ ? constructorOptions.retryWhenThrottledOverride
172
+ : RETRY_WHEN_THROTTLED;
173
+ this.userInfosToSubscribe =
174
+ (_b = (_a = constructorOptions.userInfosToSubscribeOverride) !== null && _a !== void 0 ? _a : configurationResponse.options.user_infos_to_subscribe) !== null && _b !== void 0 ? _b : USER_INFOS_TO_SUBSCRIBE;
175
+ this.reachabilityEnabled =
176
+ configurationResponse.options.reachability_enabled;
173
177
  this.userIdentity = configurationResponse.identity;
174
178
  this.userInfo = configurationResponse.sync_objects.my_user_info;
175
179
  this.myConversations = configurationResponse.sync_objects.my_conversations;
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sources":["../src/configuration.ts"],"sourcesContent":["import { ConfigurationResponse } from './interfaces/commands/configuration';\nimport { parse as parseDuration, toSeconds } from 'iso8601-duration';\nimport { Logger } from './logger';\nimport { Limits } from './interfaces/limits';\n\nconst TYPING_TIMEOUT = 5;\nconst HTTP_CACHE_LIFETIME = 'PT5S';\nconst CONSUMPTION_HORIZON_SENDING_INTERVAL = 'PT5S';\nconst USER_INFOS_TO_SUBSCRIBE = 100;\n\nconst MINIMUM_RETRY_DELAY = 1000;\nconst MAXIMUM_RETRY_DELAY = 4000;\nconst MAXIMUM_ATTEMPTS_COUNT = 3;\nconst RETRY_WHEN_THROTTLED = true;\n\ninterface BackoffConfiguration {\n min: number;\n max: number;\n maxAttemptsCount: number;\n}\n\nclass Configuration {\n public readonly links: {\n myConversations: string;\n conversations: string;\n users: string;\n currentUser: string;\n typing: string;\n mediaService: string;\n mediaSetService: string;\n messagesReceipts: string;\n };\n\n public readonly limits: Limits;\n\n public readonly productId?: string;\n\n public readonly typingIndicatorTimeoutOverride?: number;\n public readonly typingIndicatorTimeoutDefault: number = TYPING_TIMEOUT * 1000;\n public readonly backoffConfiguration: BackoffConfiguration;\n public readonly retryWhenThrottled: boolean;\n\n public readonly consumptionReportInterval: number;\n public readonly userInfosToSubscribe: number;\n public readonly httpCacheInterval: number;\n public readonly reachabilityEnabled: boolean;\n\n public readonly userIdentity: string;\n public readonly userInfo: string;\n public readonly myConversations: string;\n\n constructor(\n options: Record<string, any> = {},\n configurationResponse: ConfigurationResponse,\n logger: Logger\n ) {\n const constructorOptions = options.Chat || options.IPMessaging || options || {};\n\n this.productId = constructorOptions.productId;\n\n this.links = {\n myConversations: configurationResponse.links.my_conversations,\n conversations: configurationResponse.links.conversations,\n users: configurationResponse.links.users,\n currentUser: configurationResponse.links.current_user,\n typing: configurationResponse.links.typing,\n mediaService: configurationResponse.links.media_service,\n mediaSetService: configurationResponse.links.media_set_service,\n messagesReceipts: configurationResponse.links.messages_receipts\n };\n\n this.limits = {\n mediaAttachmentsCountLimit: configurationResponse.options.media_attachments_count_limit,\n mediaAttachmentSizeLimitInMb: configurationResponse.options.media_attachment_size_limit_in_mb,\n mediaAttachmentsTotalSizeLimitInMb: configurationResponse.options.media_attachments_total_size_limit_in_mb,\n emailHistoriesAllowedMimeTypes: configurationResponse.options.email_histories_allowed_mime_types,\n emailBodiesAllowedMimeTypes: configurationResponse.options.email_bodies_allowed_mime_types\n };\n\n this.typingIndicatorTimeoutOverride = constructorOptions.typingIndicatorTimeoutOverride;\n this.backoffConfiguration = {\n min: MINIMUM_RETRY_DELAY,\n max: MAXIMUM_RETRY_DELAY,\n maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT,\n ...constructorOptions.backoffConfigOverride\n };\n this.retryWhenThrottled = constructorOptions.retryWhenThrottledOverride !== undefined\n ? constructorOptions.retryWhenThrottledOverride\n : RETRY_WHEN_THROTTLED;\n this.userInfosToSubscribe = constructorOptions.userInfosToSubscribeOverride\n ?? configurationResponse.options.user_infos_to_subscribe\n ?? USER_INFOS_TO_SUBSCRIBE;\n this.reachabilityEnabled = configurationResponse.options.reachability_enabled;\n this.userIdentity = configurationResponse.identity;\n this.userInfo = configurationResponse.sync_objects.my_user_info;\n this.myConversations = configurationResponse.sync_objects.my_conversations;\n\n const httpCacheInterval = constructorOptions.httpCacheIntervalOverride\n ?? configurationResponse.options.http_cache_interval\n ?? HTTP_CACHE_LIFETIME;\n\n try {\n this.httpCacheInterval = toSeconds(parseDuration(httpCacheInterval));\n } catch {\n logger.error(`Failed to parse http cache interval ${httpCacheInterval}, using default value ${HTTP_CACHE_LIFETIME}`);\n this.httpCacheInterval = toSeconds(parseDuration(HTTP_CACHE_LIFETIME));\n }\n\n const consumptionReportInterval = constructorOptions.consumptionReportIntervalOverride\n ?? configurationResponse.options.consumption_report_interval\n ?? CONSUMPTION_HORIZON_SENDING_INTERVAL;\n\n try {\n this.consumptionReportInterval = toSeconds(parseDuration(consumptionReportInterval));\n } catch {\n logger.error(\n `Failed to parse consumption report interval ${consumptionReportInterval}, using default value ${CONSUMPTION_HORIZON_SENDING_INTERVAL}`\n );\n this.consumptionReportInterval = toSeconds(parseDuration(CONSUMPTION_HORIZON_SENDING_INTERVAL));\n }\n }\n}\n\nexport { Configuration };\n"],"names":["toSeconds","parseDuration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,oCAAoC,GAAG,MAAM,CAAC;AACpD,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,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IAAI,CAAC,yBAAyB,GAAGD,yBAAS,CAACC,qBAAa,CAAC,yBAAyB,CAAC,CAAC,CAAC;SACtF;QAAC,WAAM;YACN,MAAM,CAAC,KAAK,CACV,+CAA+C,yBAAyB,yBAAyB,oCAAoC,EAAE,CACxI,CAAC;YACF,IAAI,CAAC,yBAAyB,GAAGD,yBAAS,CAACC,qBAAa,CAAC,oCAAoC,CAAC,CAAC,CAAC;SACjG;KACF;;;;;"}
1
+ {"version":3,"file":"configuration.js","sources":["../src/configuration.ts"],"sourcesContent":["import { ConfigurationResponse } from \"./interfaces/commands/configuration\";\nimport { parse as parseDuration, toSeconds } from \"iso8601-duration\";\nimport { Logger } from \"./logger\";\nimport { Limits } from \"./interfaces/limits\";\nimport { ClientOptions } from \"./client\";\n\nconst TYPING_TIMEOUT = 5;\nconst HTTP_CACHE_LIFETIME = \"PT5S\";\nconst CONSUMPTION_HORIZON_SENDING_INTERVAL = \"PT5S\";\nconst USER_INFOS_TO_SUBSCRIBE = 100;\n\nconst MINIMUM_RETRY_DELAY = 1000;\nconst MAXIMUM_RETRY_DELAY = 4000;\nconst MAXIMUM_ATTEMPTS_COUNT = 3;\nconst RETRY_WHEN_THROTTLED = true;\n\ninterface BackoffConfiguration {\n min: number;\n max: number;\n maxAttemptsCount: number;\n}\n\nclass Configuration {\n public readonly links: {\n myConversations: string;\n conversations: string;\n users: string;\n currentUser: string;\n typing: string;\n mediaService: string;\n mediaSetService: string;\n messagesReceipts: string;\n };\n\n public readonly limits: Limits;\n\n public readonly productId?: string;\n\n public readonly typingIndicatorTimeoutOverride?: number;\n public readonly typingIndicatorTimeoutDefault: number = TYPING_TIMEOUT * 1000;\n public readonly backoffConfiguration: BackoffConfiguration;\n public readonly retryWhenThrottled: boolean;\n\n public readonly consumptionReportInterval: number;\n public readonly userInfosToSubscribe: number;\n public readonly httpCacheInterval: number;\n public readonly reachabilityEnabled: boolean;\n\n public readonly userIdentity: string;\n public readonly userInfo: string;\n public readonly myConversations: string;\n\n constructor(\n options: ClientOptions = {},\n configurationResponse: ConfigurationResponse,\n logger: Logger\n ) {\n const constructorOptions =\n options.Chat || options.IPMessaging || options || {};\n\n this.productId = constructorOptions.productId;\n\n this.links = {\n myConversations: configurationResponse.links.my_conversations,\n conversations: configurationResponse.links.conversations,\n users: configurationResponse.links.users,\n currentUser: configurationResponse.links.current_user,\n typing: configurationResponse.links.typing,\n mediaService: configurationResponse.links.media_service,\n mediaSetService: configurationResponse.links.media_set_service,\n messagesReceipts: configurationResponse.links.messages_receipts,\n };\n\n this.limits = {\n mediaAttachmentsCountLimit:\n configurationResponse.options.media_attachments_count_limit,\n mediaAttachmentSizeLimitInMb:\n configurationResponse.options.media_attachment_size_limit_in_mb,\n mediaAttachmentsTotalSizeLimitInMb:\n configurationResponse.options.media_attachments_total_size_limit_in_mb,\n emailHistoriesAllowedMimeTypes:\n configurationResponse.options.email_histories_allowed_mime_types,\n emailBodiesAllowedMimeTypes:\n configurationResponse.options.email_bodies_allowed_mime_types,\n };\n\n this.typingIndicatorTimeoutOverride =\n constructorOptions.typingIndicatorTimeoutOverride;\n this.backoffConfiguration = {\n min: MINIMUM_RETRY_DELAY,\n max: MAXIMUM_RETRY_DELAY,\n maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT,\n ...constructorOptions.backoffConfigOverride,\n };\n this.retryWhenThrottled =\n constructorOptions.retryWhenThrottledOverride !== undefined\n ? constructorOptions.retryWhenThrottledOverride\n : RETRY_WHEN_THROTTLED;\n this.userInfosToSubscribe =\n constructorOptions.userInfosToSubscribeOverride ??\n configurationResponse.options.user_infos_to_subscribe ??\n USER_INFOS_TO_SUBSCRIBE;\n this.reachabilityEnabled =\n configurationResponse.options.reachability_enabled;\n this.userIdentity = configurationResponse.identity;\n this.userInfo = configurationResponse.sync_objects.my_user_info;\n this.myConversations = configurationResponse.sync_objects.my_conversations;\n\n const httpCacheInterval =\n constructorOptions.httpCacheIntervalOverride ??\n configurationResponse.options.http_cache_interval ??\n HTTP_CACHE_LIFETIME;\n\n try {\n this.httpCacheInterval = toSeconds(parseDuration(httpCacheInterval));\n } catch {\n logger.error(\n `Failed to parse http cache interval ${httpCacheInterval}, using default value ${HTTP_CACHE_LIFETIME}`\n );\n this.httpCacheInterval = toSeconds(parseDuration(HTTP_CACHE_LIFETIME));\n }\n\n const consumptionReportInterval =\n constructorOptions.consumptionReportIntervalOverride ??\n configurationResponse.options.consumption_report_interval ??\n CONSUMPTION_HORIZON_SENDING_INTERVAL;\n\n try {\n this.consumptionReportInterval = toSeconds(\n parseDuration(consumptionReportInterval)\n );\n } catch {\n logger.error(\n `Failed to parse consumption report interval ${consumptionReportInterval}, using default value ${CONSUMPTION_HORIZON_SENDING_INTERVAL}`\n );\n this.consumptionReportInterval = toSeconds(\n parseDuration(CONSUMPTION_HORIZON_SENDING_INTERVAL)\n );\n }\n }\n}\n\nexport { Configuration };\n"],"names":["toSeconds","parseDuration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,oCAAoC,GAAG,MAAM,CAAC;AACpD,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAQlC,MAAM,aAAa;IA8BjB,YACE,UAAyB,EAAE,EAC3B,qBAA4C,EAC5C,MAAc;;QAhBA,kCAA6B,GAAW,cAAc,GAAG,IAAI,CAAC;QAkB5E,MAAM,kBAAkB,GACtB,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,WAA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