@twilio/conversations 2.0.1-rc.5 → 2.0.1-rc.9

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 (95) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/{dist → builds}/browser.js +1 -1
  3. package/{dist → builds}/browser.js.map +0 -0
  4. package/{dist → builds}/lib.d.ts +0 -0
  5. package/{dist → builds}/lib.js +1 -1
  6. package/{dist → builds}/lib.js.map +0 -0
  7. package/{dist → builds}/twilio-conversations.js +8 -188
  8. package/{dist → builds}/twilio-conversations.min.js +2 -2
  9. package/dist/aggregated-delivery-receipt.js +227 -0
  10. package/dist/aggregated-delivery-receipt.js.map +1 -0
  11. package/dist/client.js +872 -0
  12. package/dist/client.js.map +1 -0
  13. package/dist/command-executor.js +203 -0
  14. package/dist/command-executor.js.map +1 -0
  15. package/dist/configuration.js +196 -0
  16. package/dist/configuration.js.map +1 -0
  17. package/dist/conversation.js +973 -0
  18. package/dist/conversation.js.map +1 -0
  19. package/dist/data/conversations.js +443 -0
  20. package/dist/data/conversations.js.map +1 -0
  21. package/dist/data/messages.js +341 -0
  22. package/dist/data/messages.js.map +1 -0
  23. package/dist/data/participants.js +313 -0
  24. package/dist/data/participants.js.map +1 -0
  25. package/dist/data/users.js +228 -0
  26. package/dist/data/users.js.map +1 -0
  27. package/dist/detailed-delivery-receipt.js +154 -0
  28. package/dist/detailed-delivery-receipt.js.map +1 -0
  29. package/dist/index.js +167 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/interfaces/notification-types.js +143 -0
  32. package/dist/interfaces/notification-types.js.map +1 -0
  33. package/dist/logger.js +190 -0
  34. package/dist/logger.js.map +1 -0
  35. package/dist/media.js +213 -0
  36. package/dist/media.js.map +1 -0
  37. package/dist/message-builder.js +209 -0
  38. package/dist/message-builder.js.map +1 -0
  39. package/dist/message.js +450 -0
  40. package/dist/message.js.map +1 -0
  41. package/dist/node_modules/tslib/tslib.es6.js +161 -0
  42. package/dist/node_modules/tslib/tslib.es6.js.map +1 -0
  43. package/dist/packages/conversations/package.json.js +136 -0
  44. package/dist/packages/conversations/package.json.js.map +1 -0
  45. package/dist/participant.js +346 -0
  46. package/dist/participant.js.map +1 -0
  47. package/dist/push-notification.js +152 -0
  48. package/dist/push-notification.js.map +1 -0
  49. package/dist/rest-paginator.js +175 -0
  50. package/dist/rest-paginator.js.map +1 -0
  51. package/dist/services/network.js +205 -0
  52. package/dist/services/network.js.map +1 -0
  53. package/dist/services/typing-indicator.js +235 -0
  54. package/dist/services/typing-indicator.js.map +1 -0
  55. package/dist/unsent-message.js +159 -0
  56. package/dist/unsent-message.js.map +1 -0
  57. package/dist/user.js +392 -0
  58. package/dist/user.js.map +1 -0
  59. package/dist/util/deferred.js +154 -0
  60. package/dist/util/deferred.js.map +1 -0
  61. package/dist/util/index.js +206 -0
  62. package/dist/util/index.js.map +1 -0
  63. package/{dist/docs → docs}/assets/css/main.css +0 -0
  64. package/{dist/docs → docs}/assets/images/icons.png +0 -0
  65. package/{dist/docs → docs}/assets/images/icons@2x.png +0 -0
  66. package/{dist/docs → docs}/assets/images/widgets.png +0 -0
  67. package/{dist/docs → docs}/assets/images/widgets@2x.png +0 -0
  68. package/{dist/docs → docs}/assets/js/main.js +0 -0
  69. package/{dist/docs → docs}/assets/js/search.js +0 -0
  70. package/{dist/docs → docs}/classes/AggregatedDeliveryReceipt.html +0 -0
  71. package/{dist/docs → docs}/classes/Client.html +0 -0
  72. package/{dist/docs → docs}/classes/Conversation.html +0 -0
  73. package/{dist/docs → docs}/classes/DetailedDeliveryReceipt.html +0 -0
  74. package/{dist/docs → docs}/classes/Media.html +0 -0
  75. package/{dist/docs → docs}/classes/Message.html +0 -0
  76. package/{dist/docs → docs}/classes/MessageBuilder.html +0 -0
  77. package/{dist/docs → docs}/classes/Participant.html +0 -0
  78. package/{dist/docs → docs}/classes/PushNotification.html +0 -0
  79. package/{dist/docs → docs}/classes/RestPaginator.html +0 -0
  80. package/{dist/docs → docs}/classes/UnsentMessage.html +0 -0
  81. package/{dist/docs → docs}/classes/User.html +0 -0
  82. package/{dist/docs → docs}/index.html +0 -0
  83. package/{dist/docs → docs}/interfaces/ClientOptions.html +0 -0
  84. package/{dist/docs → docs}/interfaces/ConversationState.html +0 -0
  85. package/{dist/docs → docs}/interfaces/CreateConversationOptions.html +0 -0
  86. package/{dist/docs → docs}/interfaces/LastMessage.html +0 -0
  87. package/{dist/docs → docs}/interfaces/Paginator.html +0 -0
  88. package/{dist/docs → docs}/interfaces/PushNotificationData.html +0 -0
  89. package/{dist/docs → docs}/interfaces/SendEmailOptions.html +0 -0
  90. package/{dist/docs → docs}/interfaces/SendMediaOptions.html +0 -0
  91. package/{dist/docs → docs}/modules.html +0 -0
  92. package/package.json +23 -24
  93. package/dist/post-install.js +0 -29
  94. package/dist/react-native.js +0 -4035
  95. package/dist/react-native.js.map +0 -1
package/dist/client.js ADDED
@@ -0,0 +1,872 @@
1
+ /*
2
+ @license
3
+ The following license applies to all parts of this software except as
4
+ documented below.
5
+
6
+ Copyright (c) 2019, Twilio, inc.
7
+ All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are
11
+ met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright
17
+ notice, this list of conditions and the following disclaimer in
18
+ the documentation and/or other materials provided with the
19
+ distribution.
20
+
21
+ 3. Neither the name of Twilio nor the names of its contributors may
22
+ be used to endorse or promote products derived from this software
23
+ without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+
37
+ This software includes javascript-state-machine under the following license.
38
+
39
+ Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining a copy
42
+ of this software and associated documentation files (the "Software"), to deal
43
+ in the Software without restriction, including without limitation the rights
44
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45
+ copies of the Software, and to permit persons to whom the Software is
46
+ furnished to do so, subject to the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be included in all
49
+ copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
54
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
57
+
58
+ This software includes loglevel under the following license.
59
+
60
+ Copyright (c) 2013 Tim Perry
61
+
62
+ Permission is hereby granted, free of charge, to any person
63
+ obtaining a copy of this software and associated documentation
64
+ files (the "Software"), to deal in the Software without
65
+ restriction, including without limitation the rights to use,
66
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
67
+ copies of the Software, and to permit persons to whom the
68
+ Software is furnished to do so, subject to the following
69
+ conditions:
70
+
71
+ The above copyright notice and this permission notice shall be
72
+ included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
75
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
76
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
77
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
78
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
79
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
80
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
81
+ OTHER DEALINGS IN THE SOFTWARE.
82
+
83
+ This software includes q under the following license.
84
+
85
+ Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
86
+ Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ of this software and associated documentation files (the "Software"), to
88
+ deal in the Software without restriction, including without limitation the
89
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
90
+ sell copies of the Software, and to permit persons to whom the Software is
91
+ furnished to do so, subject to the following conditions:
92
+
93
+ The above copyright notice and this permission notice shall be included in
94
+ all copies or substantial portions of the Software.
95
+
96
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
101
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
102
+ IN THE SOFTWARE.
103
+
104
+ This software includes platform.js under the following license.
105
+
106
+ Copyright 2014 Benjamin Tan <https://d10.github.io/>
107
+ Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
108
+
109
+ Permission is hereby granted, free of charge, to any person obtaining
110
+ a copy of this software and associated documentation files (the
111
+ "Software"), to deal in the Software without restriction, including
112
+ without limitation the rights to use, copy, modify, merge, publish,
113
+ distribute, sublicense, and/or sell copies of the Software, and to
114
+ permit persons to whom the Software is furnished to do so, subject to
115
+ the following conditions:
116
+
117
+ The above copyright notice and this permission notice shall be
118
+ included in all copies or substantial portions of the Software.
119
+
120
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
121
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
122
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
123
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
124
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
125
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
126
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
+
128
+ */
129
+ 'use strict';
130
+
131
+ Object.defineProperty(exports, '__esModule', { value: true });
132
+
133
+ var tslib_es6 = require('./node_modules/tslib/tslib.es6.js');
134
+ var logger = require('./logger.js');
135
+ var configuration = require('./configuration.js');
136
+ var user = require('./user.js');
137
+ var network = require('./services/network.js');
138
+ var notificationTypes = require('./interfaces/notification-types.js');
139
+ var twilsock = require('twilsock');
140
+ var notifications = require('@twilio/notifications');
141
+ var twilioSync = require('twilio-sync');
142
+ var mcsClient = require('@twilio/mcs-client');
143
+ var conversations = require('./data/conversations.js');
144
+ var users = require('./data/users.js');
145
+ var typingIndicator = require('./services/typing-indicator.js');
146
+ var pushNotification = require('./push-notification.js');
147
+ var index = require('./util/index.js');
148
+ var declarativeTypeValidator = require('@twilio/declarative-type-validator');
149
+ var _package = require('./packages/conversations/package.json.js');
150
+ var commandExecutor = require('./command-executor.js');
151
+ var replayEventEmitter = require('@twilio/replay-event-emitter');
152
+
153
+ var Client_1;
154
+ const log = logger.Logger.scope('Client');
155
+ const SDK_VERSION = _package.version;
156
+ class ClientServices {
157
+ }
158
+ /**
159
+ * A client is the starting point to the Twilio Conversations functionality.
160
+ */
161
+ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventEmitter {
162
+ /**
163
+ * Returned Conversations instance is not yet fully initialized. Calling any operations will block until it is.
164
+ * Use connection events to monitor when client becomes fully available (connectionStateChanged with state
165
+ * 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).
166
+ *
167
+ * @param fpaToken Access token
168
+ * @param options Options to customize the Client
169
+ * @returns A not yet fully-initialized client.
170
+ */
171
+ constructor(fpaToken, options = {}) {
172
+ var _a, _b, _c, _d, _e;
173
+ super();
174
+ /**
175
+ * Client connection state.
176
+ */
177
+ this.connectionState = 'unknown';
178
+ this.conversationsPromise = null;
179
+ this._ensureReady = null;
180
+ this._resolveEnsureReady = null;
181
+ this._rejectEnsureReady = null;
182
+ /**
183
+ * Current version of the Conversations client.
184
+ */
185
+ this.version = SDK_VERSION;
186
+ this.parsePushNotification = Client_1.parsePushNotification;
187
+ this.fpaToken = fpaToken;
188
+ this.options = options;
189
+ if (!this.options.disableDeepClone) {
190
+ let options = Object.assign(Object.assign({}, this.options), { transport: undefined, twilsockClient: undefined });
191
+ options = index.deepClone(options);
192
+ options.transport = this.options.transport;
193
+ options.twilsockClient = this.options.twilsockClient;
194
+ this.options = options;
195
+ }
196
+ this.options.logLevel = (_a = this.options.logLevel) !== null && _a !== void 0 ? _a : 'silent';
197
+ log.setLevel(this.options.logLevel);
198
+ const productId = this.options.productId = 'ip_messaging';
199
+ // Filling ClientMetadata
200
+ this.options.clientMetadata = this.options.clientMetadata || {};
201
+ if (!this.options.clientMetadata.hasOwnProperty('type')) {
202
+ this.options.clientMetadata.type = 'conversations';
203
+ }
204
+ if (!this.options.clientMetadata.hasOwnProperty('sdk')) {
205
+ this.options.clientMetadata.sdk = 'JS';
206
+ this.options.clientMetadata.sdkv = SDK_VERSION;
207
+ }
208
+ // Enable session local storage for Sync
209
+ this.options.Sync = this.options.Sync || {};
210
+ if (typeof this.options.Sync.enableSessionStorage === 'undefined') {
211
+ this.options.Sync.enableSessionStorage = true;
212
+ }
213
+ if (this.options.region) {
214
+ this.options.Sync.region = this.options.region;
215
+ }
216
+ if (!fpaToken) {
217
+ throw new Error('A valid Twilio token should be provided');
218
+ }
219
+ this.services = new ClientServices();
220
+ this._myself = new user.User('', '', null, this.services);
221
+ const startTwilsock = !this.options.twilsockClient;
222
+ // Create default init registrations if none were provided.
223
+ // Otherwise, the outside party have to list all the init registrations they
224
+ // need.
225
+ // Init registrations passed to the Conversations client will be passed down
226
+ // to the Sync client as well.
227
+ if (!this.options.initRegistrations) {
228
+ const initRegistration = new twilsock.InitRegistration(productId);
229
+ Client_1.populateInitRegistrations(initRegistration);
230
+ this.options.initRegistrations = [initRegistration];
231
+ }
232
+ this.services.twilsockClient = (this.options.twilsockClient = (_b = this.options.twilsockClient) !== null && _b !== void 0 ? _b : new twilsock.TwilsockClient(fpaToken, productId, this.options));
233
+ this.services.twilsockClient.on('tokenAboutToExpire', ttl => this.emit('tokenAboutToExpire', ttl));
234
+ this.services.twilsockClient.on('tokenExpired', () => this.emit('tokenExpired'));
235
+ this.services.twilsockClient.on('connectionError', (error) => this.emit('connectionError', error));
236
+ this.services.twilsockClient.on('stateChanged', (state) => {
237
+ log.debug(`Handling stateChanged for ConversationsClient: new state ${state}`);
238
+ if (state !== this.connectionState) {
239
+ this.connectionState = state;
240
+ this.emit('connectionStateChanged', this.connectionState);
241
+ }
242
+ });
243
+ this.services.transport = (this.options.transport = ((_c = this.options.transport) !== null && _c !== void 0 ? _c : this.options.twilsockClient));
244
+ this.services.notificationClient = (this.options.notificationsClient = (_d = this.options.notificationsClient) !== null && _d !== void 0 ? _d : new notifications.Notifications(fpaToken, this.options));
245
+ this.services.syncClient = (this.options.syncClient = (_e = this.options.syncClient) !== null && _e !== void 0 ? _e : new twilioSync.SyncClient(fpaToken, this.options));
246
+ const configurationOptions = options.Chat || options.IPMessaging || options || {};
247
+ const region = configurationOptions.region || options.region;
248
+ const baseUrl = configurationOptions.apiUri
249
+ || configurationOptions.typingUri
250
+ || `https://aim.${region || 'us1'}.twilio.com`;
251
+ this.services.commandExecutor = new commandExecutor.CommandExecutor(baseUrl, { transport: this.options.transport }, productId);
252
+ const emitFailed = (err) => {
253
+ this._rejectEnsureReady(err);
254
+ this.emit('stateChanged', 'failed');
255
+ };
256
+ this.services.twilsockClient.once('connectionError', emitFailed);
257
+ this.services.twilsockClient.once('disconnected', emitFailed);
258
+ // ConversationsClient will be able to initialize only after twilsock is connected
259
+ this.services.twilsockClient.once('connected', async () => {
260
+ log.debug(`ConversationsClient started INITIALIZING`);
261
+ this.services.twilsockClient.off('connectionError', emitFailed);
262
+ this.services.twilsockClient.off('disconnected', emitFailed);
263
+ try {
264
+ const startupEvent = 'conversations.client.startup';
265
+ this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription(startupEvent, 'Conversations client startup', new Date()), startupEvent, twilsock.TelemetryPoint.Start);
266
+ await this._initialize();
267
+ this.services.twilsockClient.addPartialTelemetryEvent(new twilsock.TelemetryEventDescription('', '', new Date()), startupEvent, twilsock.TelemetryPoint.End);
268
+ }
269
+ catch (err) {
270
+ // Fail ChatClient if initialization is incomplete
271
+ this._rejectEnsureReady(err);
272
+ this.emit('stateChanged', 'failed');
273
+ }
274
+ });
275
+ this._ensureReady = new Promise((resolve, reject) => {
276
+ this._resolveEnsureReady = resolve;
277
+ this._rejectEnsureReady = reject;
278
+ }).catch((err) => { }); // @todo How to process unhandled rejection here?
279
+ if (startTwilsock) {
280
+ this.services.twilsockClient.connect();
281
+ }
282
+ }
283
+ static populateInitRegistrations(reg) {
284
+ reg.populateInitRegistrations([notificationTypes.NotificationTypes.TYPING_INDICATOR]);
285
+ twilioSync.SyncClient.populateInitRegistrations(reg);
286
+ }
287
+ /**
288
+ * @deprecated Call constructor directly.
289
+ *
290
+ * Factory method to create a Conversations client instance.
291
+ *
292
+ * The factory method will automatically trigger connection.
293
+ * Do not use it if you need finer-grained control.
294
+ *
295
+ * Since this method returns an already-initialized client, some of the events
296
+ * will be lost because they happen *before* the initialization. It is
297
+ * recommended that `client.onWithReplay` is used as opposed to `client.on`
298
+ * for subscribing to client events. The `client.onWithReplay` will re-emit
299
+ * the most recent value for a given event if it emitted before the
300
+ * subscription.
301
+ *
302
+ * @param token Access token.
303
+ * @param options Options to customize the client.
304
+ * @returns Returns a fully initialized client.
305
+ */
306
+ static async create(token, options) {
307
+ // The logic is as follows:
308
+ // - If twilsock is not passed in, then the ConversationsClient constructor will call twilsock.connect() by itself
309
+ // and we do not need to do it here.
310
+ // - If twilsock was passed in from the outside, but customer called ConversationsClient.create() then they are
311
+ // using an obsolete workflow and the startup sequence will never complete.
312
+ if (options === null || options === void 0 ? void 0 : options.twilsockClient) {
313
+ throw new Error('Obsolete usage of ConversationsClient.create() ' +
314
+ 'factory method: if you pass twilsock from the outside then you must ' +
315
+ 'use ConversationsClient constructor and be prepared to work with ' +
316
+ 'uninitialized client.');
317
+ }
318
+ const client = new Client_1(token, options);
319
+ await client._ensureReady;
320
+ return client;
321
+ }
322
+ /**
323
+ * Information of the logged-in user. Before client initialization, returns an
324
+ * uninitialized user. Will trigger a {@link Client.userUpdated} event after
325
+ * initialization.
326
+ */
327
+ get user() { return this._myself; }
328
+ /**
329
+ * Client reachability state. Throws if accessed before the client
330
+ * initialization was completed.
331
+ */
332
+ get reachabilityEnabled() {
333
+ if (!this.configuration) {
334
+ throw new Error('Reachability information could not yet be accessed as the client ' +
335
+ "has not yet been initialized. Subscribe to the 'stateChanged' event " +
336
+ 'to properly react to the client initialization.');
337
+ }
338
+ return this.configuration.reachabilityEnabled;
339
+ }
340
+ get token() { return this.fpaToken; }
341
+ _subscribeToPushNotifications(channelType) {
342
+ [notificationTypes.NotificationTypes.NEW_MESSAGE,
343
+ notificationTypes.NotificationTypes.ADDED_TO_CONVERSATION,
344
+ notificationTypes.NotificationTypes.REMOVED_FROM_CONVERSATION,
345
+ notificationTypes.NotificationTypes.TYPING_INDICATOR,
346
+ notificationTypes.NotificationTypes.CONSUMPTION_UPDATE]
347
+ .forEach(messageType => {
348
+ this.services.notificationClient.subscribe(channelType, messageType);
349
+ });
350
+ }
351
+ _unsubscribeFromPushNotifications(channelType) {
352
+ [notificationTypes.NotificationTypes.NEW_MESSAGE,
353
+ notificationTypes.NotificationTypes.ADDED_TO_CONVERSATION,
354
+ notificationTypes.NotificationTypes.REMOVED_FROM_CONVERSATION,
355
+ notificationTypes.NotificationTypes.TYPING_INDICATOR,
356
+ notificationTypes.NotificationTypes.CONSUMPTION_UPDATE]
357
+ .forEach(messageType => {
358
+ this.services.notificationClient.unsubscribe(channelType, messageType);
359
+ });
360
+ }
361
+ async _initialize() {
362
+ const configurationResponse = await this.services.commandExecutor.fetchResource('Client/v2/Configuration');
363
+ this.configuration = new configuration.Configuration(this.options, configurationResponse, log);
364
+ this._myself._resolveInitialization(this.configuration, this.configuration.userIdentity, this.configuration.userInfo, true);
365
+ this.services.typingIndicator = new typingIndicator.TypingIndicator(this.getConversationBySid.bind(this), this.configuration, this.services);
366
+ this.services.network = new network.Network(this.configuration, this.services);
367
+ this.services.users = new users.Users(this._myself, this.configuration, this.services);
368
+ this.services.users.on('userSubscribed', this.emit.bind(this, 'userSubscribed'));
369
+ this.services.users.on('userUpdated', (args) => this.emit('userUpdated', args));
370
+ this.services.users.on('userUnsubscribed', this.emit.bind(this, 'userUnsubscribed'));
371
+ this.conversations = new conversations.Conversations(this.configuration, this.services);
372
+ this.conversations.on('conversationAdded', this.emit.bind(this, 'conversationAdded'));
373
+ this.conversations.on('conversationRemoved', this.emit.bind(this, 'conversationRemoved'));
374
+ this.conversations.on('conversationJoined', this.emit.bind(this, 'conversationJoined'));
375
+ this.conversations.on('conversationLeft', this.emit.bind(this, 'conversationLeft'));
376
+ this.conversations.on('conversationUpdated', (args) => this.emit('conversationUpdated', args));
377
+ this.conversations.on('participantJoined', this.emit.bind(this, 'participantJoined'));
378
+ this.conversations.on('participantLeft', this.emit.bind(this, 'participantLeft'));
379
+ this.conversations.on('participantUpdated', (args) => this.emit('participantUpdated', args));
380
+ this.conversations.on('messageAdded', this.emit.bind(this, 'messageAdded'));
381
+ this.conversations.on('messageUpdated', (args) => this.emit('messageUpdated', args));
382
+ this.conversations.on('messageRemoved', this.emit.bind(this, 'messageRemoved'));
383
+ this.conversations.on('typingStarted', this.emit.bind(this, 'typingStarted'));
384
+ this.conversations.on('typingEnded', this.emit.bind(this, 'typingEnded'));
385
+ this.conversationsPromise = this.conversations.fetchConversations()
386
+ .then(() => this.conversations)
387
+ .catch((error) => {
388
+ throw error;
389
+ });
390
+ await this.services.users.myself._ensureFetched();
391
+ Client_1.supportedPushChannels.forEach(channelType => this._subscribeToPushNotifications(channelType));
392
+ this.services.typingIndicator.initialize();
393
+ this.services.mcsClient = new mcsClient.McsClient(this.fpaToken, this.configuration.links.mediaService, this.configuration.links.mediaSetService, Object.assign(Object.assign({}, this.options), { transport: null }));
394
+ this._resolveEnsureReady();
395
+ this.emit('stateChanged', 'initialized');
396
+ }
397
+ /**
398
+ * Gracefully shut down the client.
399
+ */
400
+ async shutdown() {
401
+ await this._ensureReady;
402
+ await this.services.twilsockClient.disconnect();
403
+ }
404
+ /**
405
+ * Update the token used by the client and re-register with the Conversations services.
406
+ * @param token New access token.
407
+ */
408
+ async updateToken(token) {
409
+ await this._ensureReady;
410
+ log.info('updateToken');
411
+ if (this.fpaToken === token) {
412
+ return this;
413
+ }
414
+ await this.services.twilsockClient.updateToken(token);
415
+ await this.services.notificationClient.updateToken(token);
416
+ await this.services.mcsClient.updateToken(token);
417
+ this.fpaToken = token;
418
+ return this;
419
+ }
420
+ /**
421
+ * Get a known conversation by its SID.
422
+ * @param conversationSid Conversation sid
423
+ */
424
+ async getConversationBySid(conversationSid) {
425
+ await this._ensureReady;
426
+ await this.conversations.myConversationsRead.promise;
427
+ let conversation = await this.conversations.getConversation(conversationSid);
428
+ if (!conversation) {
429
+ conversation = await this.conversations.peekConversation(conversationSid);
430
+ }
431
+ if (!conversation) {
432
+ throw new Error(`Conversation with SID ${conversationSid} is not found.`);
433
+ }
434
+ return conversation;
435
+ }
436
+ /**
437
+ * Get a known conversation by its unique identifier name.
438
+ * @param uniqueName The unique identifier name of the conversation.
439
+ */
440
+ async getConversationByUniqueName(uniqueName) {
441
+ await this._ensureReady;
442
+ await this.conversations.myConversationsRead.promise;
443
+ const conversation = await this.conversations.getConversationByUniqueName(uniqueName);
444
+ if (!conversation) {
445
+ throw new Error(`Conversation with unique name ${uniqueName} is not found.`);
446
+ }
447
+ return conversation;
448
+ }
449
+ /**
450
+ * Get the current list of all the subscribed conversations.
451
+ */
452
+ async getSubscribedConversations(args) {
453
+ await this._ensureReady;
454
+ return this.conversationsPromise.then(conversations => conversations.getConversations(args));
455
+ }
456
+ /**
457
+ * Create a conversation on the server and subscribe to its events.
458
+ * The default is a conversation with an empty friendly name.
459
+ * @param options Options for the conversation.
460
+ */
461
+ async createConversation(options) {
462
+ await this._ensureReady;
463
+ options = options || {};
464
+ return this.conversationsPromise.then(conversationsEntity => conversationsEntity.addConversation(options));
465
+ }
466
+ /**
467
+ * Register for push notifications.
468
+ * @param channelType Channel type.
469
+ * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
470
+ */
471
+ async setPushRegistrationId(channelType, registrationId) {
472
+ await this._ensureReady;
473
+ this._subscribeToPushNotifications(channelType);
474
+ this.services.notificationClient.setPushRegistrationId(channelType, registrationId);
475
+ await this.services.notificationClient.commitChanges(); // Committing before this point is useless because we have no push id
476
+ }
477
+ /**
478
+ * Unregister from push notifications.
479
+ * @param channelType Channel type.
480
+ * @deprecated Use removePushRegistrations() instead.
481
+ */
482
+ async unsetPushRegistrationId(channelType) {
483
+ await this._ensureReady;
484
+ this._unsubscribeFromPushNotifications(channelType);
485
+ await this.services.notificationClient.commitChanges();
486
+ }
487
+ /**
488
+ * Clear existing registrations directly using provided device token.
489
+ * This is useful to ensure stopped subscriptions without resubscribing.
490
+ *
491
+ * This function goes completely beside the state machine and removes all registrations.
492
+ * Use with caution: if it races with current state machine operations, madness will ensue.
493
+ *
494
+ * @param channelType Channel type.
495
+ * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
496
+ */
497
+ async removePushRegistrations(channelType, registrationId) {
498
+ // do not await this._ensureReady() here - it could be called at any moment
499
+ await this.services.notificationClient.removeRegistrations(channelType, registrationId);
500
+ }
501
+ static parsePushNotificationChatData(data) {
502
+ const result = {};
503
+ for (let key in Client_1.supportedPushDataFields) {
504
+ if (typeof data[key] === 'undefined' || data[key] === null) {
505
+ continue;
506
+ }
507
+ if (key !== 'message_index') {
508
+ result[Client_1.supportedPushDataFields[key]] = data[key];
509
+ continue;
510
+ }
511
+ if (index.parseToNumber(data[key]) !== null) {
512
+ result[Client_1.supportedPushDataFields[key]] = Number(data[key]);
513
+ }
514
+ }
515
+ return result;
516
+ }
517
+ /**
518
+ * Static method for push notification payload parsing. Returns parsed push as a {@link PushNotification} object.
519
+ * @param notificationPayload Push notification payload.
520
+ */
521
+ static parsePushNotification(notificationPayload) {
522
+ log.debug('parsePushNotification, notificationPayload=', notificationPayload);
523
+ // APNS specifics
524
+ if (typeof notificationPayload.aps !== 'undefined') {
525
+ if (!notificationPayload.twi_message_type) {
526
+ throw new Error('Provided push notification payload does not contain Programmable Chat push notification type');
527
+ }
528
+ let data = Client_1.parsePushNotificationChatData(notificationPayload);
529
+ let apsPayload = notificationPayload.aps;
530
+ let body = null;
531
+ let title = null;
532
+ if (typeof apsPayload.alert === 'string') {
533
+ body = apsPayload.alert || null;
534
+ }
535
+ else {
536
+ body = apsPayload.alert.body || null;
537
+ title = apsPayload.alert.title || null;
538
+ }
539
+ return new pushNotification.PushNotification({
540
+ title: title,
541
+ body: body,
542
+ sound: apsPayload.sound || null,
543
+ badge: apsPayload.badge || null,
544
+ action: apsPayload.category || null,
545
+ type: notificationPayload.twi_message_type,
546
+ data: data
547
+ });
548
+ }
549
+ // FCM specifics
550
+ if (typeof notificationPayload.data !== 'undefined') {
551
+ let dataPayload = notificationPayload.data;
552
+ if (!dataPayload.twi_message_type) {
553
+ throw new Error('Provided push notification payload does not contain Programmable Chat push notification type');
554
+ }
555
+ let data = Client_1.parsePushNotificationChatData(notificationPayload.data);
556
+ return new pushNotification.PushNotification({
557
+ title: dataPayload.twi_title || null,
558
+ body: dataPayload.twi_body || null,
559
+ sound: dataPayload.twi_sound || null,
560
+ badge: null,
561
+ action: dataPayload.twi_action || null,
562
+ type: dataPayload.twi_message_type,
563
+ data: data
564
+ });
565
+ }
566
+ throw new Error('Provided push notification payload is not Programmable Chat notification');
567
+ }
568
+ /**
569
+ * Handle push notification payload parsing and emit the {@link Client.pushNotification} event on this {@link Client} instance.
570
+ * @param notificationPayload Push notification payload
571
+ */
572
+ async handlePushNotification(notificationPayload) {
573
+ await this._ensureReady;
574
+ log.debug('handlePushNotification, notificationPayload=', notificationPayload);
575
+ this.emit('pushNotification', Client_1.parsePushNotification(notificationPayload));
576
+ }
577
+ /**
578
+ * Gets a user with the given identity. If it's in the subscribed list, then return the user object from it;
579
+ * if not, then subscribe and add user to the subscribed list.
580
+ * @param identity Identity of the user.
581
+ * @returns A fully initialized user.
582
+ */
583
+ async getUser(identity) {
584
+ await this._ensureReady;
585
+ return this.services.users.getUser(identity);
586
+ }
587
+ /**
588
+ * Get a list of subscribed user objects.
589
+ */
590
+ async getSubscribedUsers() {
591
+ await this._ensureReady;
592
+ return this.services.users.getSubscribedUsers();
593
+ }
594
+ };
595
+ /**
596
+ * Current version of the Conversations client.
597
+ */
598
+ exports.Client.version = SDK_VERSION;
599
+ exports.Client.supportedPushChannels = ['fcm', 'apn'];
600
+ exports.Client.supportedPushDataFields = {
601
+ 'conversation_sid': 'conversationSid',
602
+ 'message_sid': 'messageSid',
603
+ 'message_index': 'messageIndex'
604
+ };
605
+ /**
606
+ * Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.
607
+ * Fired for all conversations client has joined.
608
+ *
609
+ * Parameters:
610
+ * 1. {@link Conversation} `conversation` - the conversation in question
611
+ * @event
612
+ */
613
+ exports.Client.conversationAdded = 'conversationAdded';
614
+ /**
615
+ * Fired when the client joins a conversation.
616
+ *
617
+ * Parameters:
618
+ * 1. {@link Conversation} `conversation` - the conversation in question
619
+ * @event
620
+ */
621
+ exports.Client.conversationJoined = 'conversationJoined';
622
+ /**
623
+ * Fired when the client leaves a conversation.
624
+ *
625
+ * Parameters:
626
+ * 1. {@link Conversation} `conversation` - the conversation in question
627
+ * @event
628
+ */
629
+ exports.Client.conversationLeft = 'conversationLeft';
630
+ /**
631
+ * Fired when a conversation is no longer visible to the client.
632
+ *
633
+ * Parameters:
634
+ * 1. {@link Conversation} `conversation` - the conversation in question
635
+ * @event
636
+ */
637
+ exports.Client.conversationRemoved = 'conversationRemoved';
638
+ /**
639
+ * Fired when the attributes or the metadata of a conversation have been updated.
640
+ * During conversation's creation and initialization, this event might be fired multiple times
641
+ * for same joined or created conversation as new data is arriving from different sources.
642
+ *
643
+ * Parameters:
644
+ * 1. object `data` - info object provided with the event. It has the following properties:
645
+ * * {@link Conversation} `conversation` - the conversation in question
646
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for the update
647
+ * @event
648
+ */
649
+ exports.Client.conversationUpdated = 'conversationUpdated';
650
+ /**
651
+ * Fired when a participant has joined a conversation.
652
+ *
653
+ * Parameters:
654
+ * 1. {@link Participant} `participant` - the participant in question
655
+ * @event
656
+ */
657
+ exports.Client.participantJoined = 'participantJoined';
658
+ /**
659
+ * Fired when a participant has left a conversation.
660
+ *
661
+ * Parameters:
662
+ * 1. {@link Participant} `participant` - the participant in question
663
+ * @event
664
+ */
665
+ exports.Client.participantLeft = 'participantLeft';
666
+ /**
667
+ * Fired when a participant's fields have been updated.
668
+ *
669
+ * Parameters:
670
+ * 1. object `data` - info object provided with the event. It has the following properties:
671
+ * * {@link Participant} `participant` - the participant in question
672
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for the update
673
+ * @event
674
+ */
675
+ exports.Client.participantUpdated = 'participantUpdated';
676
+ /**
677
+ * Fired when a new message has been added to the conversation on the server.
678
+ *
679
+ * Parameters:
680
+ * 1. {@link Message} `message` - the message in question
681
+ * @event
682
+ */
683
+ exports.Client.messageAdded = 'messageAdded';
684
+ /**
685
+ * Fired when a message is removed from the message list of a conversation.
686
+ *
687
+ * Parameters:
688
+ * 1. {@link Message} `message` - the message in question
689
+ * @event
690
+ */
691
+ exports.Client.messageRemoved = 'messageRemoved';
692
+ /**
693
+ * Fired when the fields of an existing message are updated with new values.
694
+ *
695
+ * Parameters:
696
+ * 1. object `data` - info object provided with the event. It has the following properties:
697
+ * * {@link Message} `message` - the message in question
698
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for the update
699
+ * @event
700
+ */
701
+ exports.Client.messageUpdated = 'messageUpdated';
702
+ /**
703
+ * Fired when the token is about to expire and needs to be updated.
704
+ * * Parameters:
705
+ * 1. number `message` - token's time to live
706
+ * @event
707
+ */
708
+ exports.Client.tokenAboutToExpire = 'tokenAboutToExpire';
709
+ /**
710
+ * Fired when the token has expired.
711
+ * @event
712
+ */
713
+ exports.Client.tokenExpired = 'tokenExpired';
714
+ /**
715
+ * Fired when a participant has stopped typing.
716
+ *
717
+ * Parameters:
718
+ * 1. {@link Participant} `participant` - the participant in question
719
+ * @event
720
+ */
721
+ exports.Client.typingEnded = 'typingEnded';
722
+ /**
723
+ * Fired when a participant has started typing.
724
+ *
725
+ * Parameters:
726
+ * 1. {@link Participant} `participant` - the participant in question
727
+ * @event
728
+ */
729
+ exports.Client.typingStarted = 'typingStarted';
730
+ /**
731
+ * Fired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).
732
+ *
733
+ * Parameters:
734
+ * 1. {@link PushNotification} `pushNotification` - the push notification in question
735
+ * @event
736
+ */
737
+ exports.Client.pushNotification = 'pushNotification';
738
+ /**
739
+ * Fired when the client has subscribed to a user.
740
+ *
741
+ * Parameters:
742
+ * 1. {@link User} `user` - the user in question
743
+ * @event
744
+ */
745
+ exports.Client.userSubscribed = 'userSubscribed';
746
+ /**
747
+ * Fired when the client has unsubscribed from a user.
748
+ *
749
+ * Parameters:
750
+ * 1. {@link User} `user` - the user in question
751
+ * @event
752
+ */
753
+ exports.Client.userUnsubscribed = 'userUnsubscribed';
754
+ /**
755
+ * Fired when the properties or the reachability status of a user have been updated.
756
+ *
757
+ * Parameters:
758
+ * 1. object `data` - info object provided with the event. It has the following properties:
759
+ * * {@link User} `user` - the user in question
760
+ * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
761
+ * @event
762
+ */
763
+ exports.Client.userUpdated = 'userUpdated';
764
+ /**
765
+ * Fired when the state of the client has been changed.
766
+ *
767
+ * Parameters:
768
+ * 1. {@link State} `state` - the new client state
769
+ * @event
770
+ */
771
+ exports.Client.stateChanged = 'stateChanged';
772
+ /**
773
+ * Fired when the connection state of the client has been changed.
774
+ *
775
+ * Paremeters:
776
+ * 1. {@link ConnectionState} `state` - the new connection state
777
+ * @event
778
+ */
779
+ exports.Client.connectionStateChanged = 'connectionStateChanged';
780
+ /**
781
+ * Fired when the connection is interrupted for an unexpected reason.
782
+ *
783
+ * Parameters:
784
+ * 1. object `data` - info object provided with the event. It has the following properties:
785
+ * * boolean `terminal` - Twilsock will stop connection attempts if true
786
+ * * string `message` - the error message of the root cause
787
+ * * number? `httpStatusCode` - http status code if available
788
+ * * number? `errorCode` - Twilio public error code if available
789
+ * @event
790
+ */
791
+ exports.Client.connectionError = 'connectionError';
792
+ tslib_es6.__decorate([
793
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
794
+ tslib_es6.__metadata("design:type", Function),
795
+ tslib_es6.__metadata("design:paramtypes", [String]),
796
+ tslib_es6.__metadata("design:returntype", Promise)
797
+ ], exports.Client.prototype, "updateToken", null);
798
+ tslib_es6.__decorate([
799
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
800
+ tslib_es6.__metadata("design:type", Function),
801
+ tslib_es6.__metadata("design:paramtypes", [String]),
802
+ tslib_es6.__metadata("design:returntype", Promise)
803
+ ], exports.Client.prototype, "getConversationBySid", null);
804
+ tslib_es6.__decorate([
805
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
806
+ tslib_es6.__metadata("design:type", Function),
807
+ tslib_es6.__metadata("design:paramtypes", [String]),
808
+ tslib_es6.__metadata("design:returntype", Promise)
809
+ ], exports.Client.prototype, "getConversationByUniqueName", null);
810
+ tslib_es6.__decorate([
811
+ declarativeTypeValidator.validateTypesAsync([
812
+ 'undefined',
813
+ declarativeTypeValidator.objectSchema('conversation options', {
814
+ friendlyName: ['string', 'undefined'],
815
+ isPrivate: ['boolean', 'undefined'],
816
+ uniqueName: ['string', 'undefined']
817
+ })
818
+ ]),
819
+ tslib_es6.__metadata("design:type", Function),
820
+ tslib_es6.__metadata("design:paramtypes", [Object]),
821
+ tslib_es6.__metadata("design:returntype", Promise)
822
+ ], exports.Client.prototype, "createConversation", null);
823
+ tslib_es6.__decorate([
824
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal('fcm', 'apn'), 'string'),
825
+ tslib_es6.__metadata("design:type", Function),
826
+ tslib_es6.__metadata("design:paramtypes", [String, String]),
827
+ tslib_es6.__metadata("design:returntype", Promise)
828
+ ], exports.Client.prototype, "setPushRegistrationId", null);
829
+ tslib_es6.__decorate([
830
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal('fcm', 'apn')),
831
+ tslib_es6.__metadata("design:type", Function),
832
+ tslib_es6.__metadata("design:paramtypes", [String]),
833
+ tslib_es6.__metadata("design:returntype", Promise)
834
+ ], exports.Client.prototype, "unsetPushRegistrationId", null);
835
+ tslib_es6.__decorate([
836
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal('fcm', 'apn'), declarativeTypeValidator.nonEmptyString),
837
+ tslib_es6.__metadata("design:type", Function),
838
+ tslib_es6.__metadata("design:paramtypes", [String, String]),
839
+ tslib_es6.__metadata("design:returntype", Promise)
840
+ ], exports.Client.prototype, "removePushRegistrations", null);
841
+ tslib_es6.__decorate([
842
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.pureObject),
843
+ tslib_es6.__metadata("design:type", Function),
844
+ tslib_es6.__metadata("design:paramtypes", [Object]),
845
+ tslib_es6.__metadata("design:returntype", Promise)
846
+ ], exports.Client.prototype, "handlePushNotification", null);
847
+ tslib_es6.__decorate([
848
+ declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
849
+ tslib_es6.__metadata("design:type", Function),
850
+ tslib_es6.__metadata("design:paramtypes", [String]),
851
+ tslib_es6.__metadata("design:returntype", Promise)
852
+ ], exports.Client.prototype, "getUser", null);
853
+ tslib_es6.__decorate([
854
+ declarativeTypeValidator.validateTypesAsync('string', ['undefined', declarativeTypeValidator.pureObject]),
855
+ tslib_es6.__metadata("design:type", Function),
856
+ tslib_es6.__metadata("design:paramtypes", [String, Object]),
857
+ tslib_es6.__metadata("design:returntype", Promise)
858
+ ], exports.Client, "create", null);
859
+ tslib_es6.__decorate([
860
+ declarativeTypeValidator.validateTypes(declarativeTypeValidator.pureObject),
861
+ tslib_es6.__metadata("design:type", Function),
862
+ tslib_es6.__metadata("design:paramtypes", [Object]),
863
+ tslib_es6.__metadata("design:returntype", pushNotification.PushNotification)
864
+ ], exports.Client, "parsePushNotification", null);
865
+ exports.Client = Client_1 = tslib_es6.__decorate([
866
+ declarativeTypeValidator.validateConstructorTypes(declarativeTypeValidator.nonEmptyString, [
867
+ declarativeTypeValidator.pureObject,
868
+ 'undefined'
869
+ ]),
870
+ tslib_es6.__metadata("design:paramtypes", [String, Object])
871
+ ], exports.Client);
872
+ //# sourceMappingURL=client.js.map