@aws-amplify/api-graphql 3.4.11 → 4.0.1-console-preview.047a1dd.0

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 (114) hide show
  1. package/README.md +3 -0
  2. package/lib/GraphQLAPI.js +0 -5
  3. package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +67 -0
  4. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +817 -0
  5. package/lib/Providers/constants.d.ts +95 -0
  6. package/lib/Providers/constants.js +103 -0
  7. package/lib/index.d.ts +0 -3
  8. package/lib/index.js +3 -9
  9. package/lib/internals/InternalGraphQLAPI.d.ts +4 -40
  10. package/lib/internals/InternalGraphQLAPI.js +89 -243
  11. package/lib/internals/index.d.ts +1 -0
  12. package/lib/internals/index.js +2 -1
  13. package/lib/internals/v6.d.ts +89 -0
  14. package/lib/internals/v6.js +99 -0
  15. package/lib/tsconfig.tsbuildinfo +5790 -0
  16. package/lib/types/PubSub.d.ts +27 -0
  17. package/lib/types/PubSub.js +46 -0
  18. package/lib/types/index.d.ts +184 -4
  19. package/lib/types/index.js +0 -3
  20. package/lib/utils/ConnectionStateMonitor.d.ts +41 -0
  21. package/lib/utils/ConnectionStateMonitor.js +143 -0
  22. package/lib/utils/ReachabilityMonitor/index.d.ts +3 -0
  23. package/lib/utils/ReachabilityMonitor/index.js +6 -0
  24. package/lib/utils/ReachabilityMonitor/index.native.d.ts +3 -0
  25. package/lib/utils/ReachabilityMonitor/index.native.js +10 -0
  26. package/lib/utils/ReconnectionMonitor.d.ts +29 -0
  27. package/lib/utils/ReconnectionMonitor.js +72 -0
  28. package/lib/utils/errors/APIError.d.ts +7 -0
  29. package/lib/utils/errors/APIError.js +22 -0
  30. package/lib/utils/errors/assertValidationError.d.ts +5 -0
  31. package/lib/utils/errors/assertValidationError.js +16 -0
  32. package/lib/utils/errors/index.d.ts +3 -0
  33. package/lib/utils/errors/index.js +11 -0
  34. package/lib/utils/errors/validation.d.ts +8 -0
  35. package/lib/utils/errors/validation.js +26 -0
  36. package/lib/utils/index.d.ts +2 -0
  37. package/lib/utils/index.js +8 -0
  38. package/lib/utils/resolveConfig.d.ts +8 -0
  39. package/lib/utils/resolveConfig.js +17 -0
  40. package/lib/utils/resolveCredentials.d.ts +12 -0
  41. package/lib/utils/resolveCredentials.js +22 -0
  42. package/lib-esm/GraphQLAPI.js +0 -5
  43. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +67 -0
  44. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +815 -0
  45. package/lib-esm/Providers/constants.d.ts +95 -0
  46. package/lib-esm/Providers/constants.js +100 -0
  47. package/lib-esm/index.d.ts +0 -3
  48. package/lib-esm/index.js +0 -4
  49. package/lib-esm/internals/InternalGraphQLAPI.d.ts +4 -40
  50. package/lib-esm/internals/InternalGraphQLAPI.js +90 -244
  51. package/lib-esm/internals/index.d.ts +1 -0
  52. package/lib-esm/internals/index.js +1 -1
  53. package/lib-esm/internals/v6.d.ts +89 -0
  54. package/lib-esm/internals/v6.js +96 -0
  55. package/lib-esm/tsconfig.tsbuildinfo +5790 -0
  56. package/lib-esm/types/PubSub.d.ts +27 -0
  57. package/lib-esm/types/PubSub.js +44 -0
  58. package/lib-esm/types/index.d.ts +184 -4
  59. package/lib-esm/types/index.js +0 -3
  60. package/lib-esm/utils/ConnectionStateMonitor.d.ts +41 -0
  61. package/lib-esm/utils/ConnectionStateMonitor.js +141 -0
  62. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +3 -0
  63. package/lib-esm/utils/ReachabilityMonitor/index.js +4 -0
  64. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +3 -0
  65. package/lib-esm/utils/ReachabilityMonitor/index.native.js +7 -0
  66. package/lib-esm/utils/ReconnectionMonitor.d.ts +29 -0
  67. package/lib-esm/utils/ReconnectionMonitor.js +70 -0
  68. package/lib-esm/utils/errors/APIError.d.ts +7 -0
  69. package/lib-esm/utils/errors/APIError.js +20 -0
  70. package/lib-esm/utils/errors/assertValidationError.d.ts +5 -0
  71. package/lib-esm/utils/errors/assertValidationError.js +13 -0
  72. package/lib-esm/utils/errors/index.d.ts +3 -0
  73. package/lib-esm/utils/errors/index.js +5 -0
  74. package/lib-esm/utils/errors/validation.d.ts +8 -0
  75. package/lib-esm/utils/errors/validation.js +24 -0
  76. package/lib-esm/utils/index.d.ts +2 -0
  77. package/lib-esm/utils/index.js +4 -0
  78. package/lib-esm/utils/resolveConfig.d.ts +8 -0
  79. package/lib-esm/utils/resolveConfig.js +15 -0
  80. package/lib-esm/utils/resolveCredentials.d.ts +12 -0
  81. package/lib-esm/utils/resolveCredentials.js +20 -0
  82. package/package.json +114 -114
  83. package/src/GraphQLAPI.ts +0 -2
  84. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +1003 -0
  85. package/src/Providers/constants.ts +110 -0
  86. package/src/index.ts +0 -3
  87. package/src/internals/InternalGraphQLAPI.ts +62 -221
  88. package/src/internals/index.ts +2 -0
  89. package/src/internals/v6.ts +106 -0
  90. package/src/types/PubSub.ts +58 -0
  91. package/src/types/index.ts +234 -7
  92. package/src/utils/ConnectionStateMonitor.ts +195 -0
  93. package/src/utils/ReachabilityMonitor/index.native.ts +7 -0
  94. package/src/utils/ReachabilityMonitor/index.ts +4 -0
  95. package/src/utils/ReconnectionMonitor.ts +76 -0
  96. package/src/utils/errors/APIError.ts +18 -0
  97. package/src/utils/errors/assertValidationError.ts +19 -0
  98. package/src/utils/errors/index.ts +6 -0
  99. package/src/utils/errors/validation.ts +26 -0
  100. package/src/utils/index.ts +5 -0
  101. package/src/utils/resolveConfig.ts +20 -0
  102. package/src/utils/resolveCredentials.ts +14 -0
  103. package/lib/.tsbuildinfo +0 -3
  104. package/lib/GraphQLAPI.js.map +0 -1
  105. package/lib/index.js.map +0 -1
  106. package/lib/internals/InternalGraphQLAPI.js.map +0 -1
  107. package/lib/internals/index.js.map +0 -1
  108. package/lib/types/index.js.map +0 -1
  109. package/lib-esm/.tsbuildinfo +0 -3
  110. package/lib-esm/GraphQLAPI.js.map +0 -1
  111. package/lib-esm/index.js.map +0 -1
  112. package/lib-esm/internals/InternalGraphQLAPI.js.map +0 -1
  113. package/lib-esm/internals/index.js.map +0 -1
  114. package/lib-esm/types/index.js.map +0 -1
@@ -0,0 +1,815 @@
1
+ import { __assign, __awaiter, __generator, __read } from "tslib";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import Observable from 'zen-observable-ts';
5
+ import { GraphQLError } from 'graphql';
6
+ import * as url from 'url';
7
+ import { v4 as uuid } from 'uuid';
8
+ import { Buffer } from 'buffer';
9
+ import { Hub, fetchAuthSession } from '@aws-amplify/core';
10
+ import { CONTROL_MSG, ConnectionState, } from '../../types/PubSub';
11
+ import { signRequest } from '@aws-amplify/core/internals/aws-client-utils';
12
+ import { AMPLIFY_SYMBOL, AWS_APPSYNC_REALTIME_HEADERS, CONNECTION_INIT_TIMEOUT, DEFAULT_KEEP_ALIVE_TIMEOUT, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT, MAX_DELAY_MS, MESSAGE_TYPES, NON_RETRYABLE_CODES, SOCKET_STATUS, START_ACK_TIMEOUT, SUBSCRIPTION_STATUS, CONNECTION_STATE_CHANGE, } from '../constants';
13
+ import { ConnectionStateMonitor, CONNECTION_CHANGE, } from '../../utils/ConnectionStateMonitor';
14
+ import { ReconnectEvent, ReconnectionMonitor, } from '../../utils/ReconnectionMonitor';
15
+ import { Logger, NonRetryableError, USER_AGENT_HEADER, getAmplifyUserAgent, isNonRetryableError, jitteredExponentialRetry, } from '@aws-amplify/core/internals/utils';
16
+ var logger = new Logger('AWSAppSyncRealTimeProvider');
17
+ var dispatchApiEvent = function (payload) {
18
+ Hub.dispatch('api', payload, 'PubSub', AMPLIFY_SYMBOL);
19
+ };
20
+ var standardDomainPattern = /^https:\/\/\w{26}\.appsync\-api\.\w{2}(?:(?:\-\w{2,})+)\-\d\.amazonaws.com(?:\.cn)?\/graphql$/i;
21
+ var customDomainPath = '/realtime';
22
+ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
23
+ function AWSAppSyncRealTimeProvider(options) {
24
+ var _this = this;
25
+ if (options === void 0) { options = {}; }
26
+ this.socketStatus = SOCKET_STATUS.CLOSED;
27
+ this.keepAliveTimeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
28
+ this.subscriptionObserverMap = new Map();
29
+ this.promiseArray = [];
30
+ this.connectionStateMonitor = new ConnectionStateMonitor();
31
+ this.reconnectionMonitor = new ReconnectionMonitor();
32
+ // Monitor the connection state and pass changes along to Hub
33
+ this.connectionStateMonitorSubscription =
34
+ this.connectionStateMonitor.connectionStateObservable.subscribe(function (connectionState) {
35
+ dispatchApiEvent({
36
+ event: CONNECTION_STATE_CHANGE,
37
+ data: {
38
+ provider: _this,
39
+ connectionState: connectionState,
40
+ },
41
+ message: "Connection state is " + connectionState,
42
+ });
43
+ _this.connectionState = connectionState;
44
+ // Trigger START_RECONNECT when the connection is disrupted
45
+ if (connectionState === ConnectionState.ConnectionDisrupted) {
46
+ _this.reconnectionMonitor.record(ReconnectEvent.START_RECONNECT);
47
+ }
48
+ // Trigger HALT_RECONNECT to halt reconnection attempts when the state is anything other than
49
+ // ConnectionDisrupted or Connecting
50
+ if ([
51
+ ConnectionState.Connected,
52
+ ConnectionState.ConnectedPendingDisconnect,
53
+ ConnectionState.ConnectedPendingKeepAlive,
54
+ ConnectionState.ConnectedPendingNetwork,
55
+ ConnectionState.ConnectionDisruptedPendingNetwork,
56
+ ConnectionState.Disconnected,
57
+ ].includes(connectionState)) {
58
+ _this.reconnectionMonitor.record(ReconnectEvent.HALT_RECONNECT);
59
+ }
60
+ });
61
+ }
62
+ /**
63
+ * Mark the socket closed and release all active listeners
64
+ */
65
+ AWSAppSyncRealTimeProvider.prototype.close = function () {
66
+ // Mark the socket closed both in status and the connection monitor
67
+ this.socketStatus = SOCKET_STATUS.CLOSED;
68
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_FAILED);
69
+ // Turn off the subscription monitor Hub publishing
70
+ this.connectionStateMonitorSubscription.unsubscribe();
71
+ // Complete all reconnect observers
72
+ this.reconnectionMonitor.close();
73
+ };
74
+ AWSAppSyncRealTimeProvider.prototype.getNewWebSocket = function (url, protocol) {
75
+ return new WebSocket(url, protocol);
76
+ };
77
+ AWSAppSyncRealTimeProvider.prototype.getProviderName = function () {
78
+ return 'AWSAppSyncRealTimeProvider';
79
+ };
80
+ // Check if url matches standard domain pattern
81
+ AWSAppSyncRealTimeProvider.prototype.isCustomDomain = function (url) {
82
+ return url.match(standardDomainPattern) === null;
83
+ };
84
+ AWSAppSyncRealTimeProvider.prototype.subscribe = function (options, customUserAgentDetails) {
85
+ var _this = this;
86
+ var appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, region = options.region, query = options.query, variables = options.variables, authenticationType = options.authenticationType;
87
+ return new Observable(function (observer) {
88
+ if (!options || !appSyncGraphqlEndpoint) {
89
+ observer.error({
90
+ errors: [
91
+ __assign({}, new GraphQLError("Subscribe only available for AWS AppSync endpoint")),
92
+ ],
93
+ });
94
+ observer.complete();
95
+ }
96
+ else {
97
+ var subscriptionStartActive_1 = false;
98
+ var subscriptionId_1 = uuid();
99
+ var startSubscription_1 = function () {
100
+ if (!subscriptionStartActive_1) {
101
+ subscriptionStartActive_1 = true;
102
+ var startSubscriptionPromise = _this._startSubscriptionWithAWSAppSyncRealTime({
103
+ options: {
104
+ query: query,
105
+ variables: variables,
106
+ region: region,
107
+ authenticationType: authenticationType,
108
+ appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
109
+ },
110
+ observer: observer,
111
+ subscriptionId: subscriptionId_1,
112
+ customUserAgentDetails: customUserAgentDetails,
113
+ }).catch(function (err) {
114
+ logger.debug(CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR + ": " + err);
115
+ _this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
116
+ });
117
+ startSubscriptionPromise.finally(function () {
118
+ subscriptionStartActive_1 = false;
119
+ });
120
+ }
121
+ };
122
+ var reconnectSubscription_1;
123
+ // Add an observable to the reconnection list to manage reconnection for this subscription
124
+ reconnectSubscription_1 = new Observable(function (observer) {
125
+ _this.reconnectionMonitor.addObserver(observer);
126
+ }).subscribe(function () {
127
+ startSubscription_1();
128
+ });
129
+ startSubscription_1();
130
+ return function () { return __awaiter(_this, void 0, void 0, function () {
131
+ var subscriptionState, err_1;
132
+ return __generator(this, function (_a) {
133
+ switch (_a.label) {
134
+ case 0:
135
+ // Cleanup reconnection subscription
136
+ reconnectSubscription_1 === null || reconnectSubscription_1 === void 0 ? void 0 : reconnectSubscription_1.unsubscribe();
137
+ _a.label = 1;
138
+ case 1:
139
+ _a.trys.push([1, 3, 4, 5]);
140
+ // Waiting that subscription has been connected before trying to unsubscribe
141
+ return [4 /*yield*/, this._waitForSubscriptionToBeConnected(subscriptionId_1)];
142
+ case 2:
143
+ // Waiting that subscription has been connected before trying to unsubscribe
144
+ _a.sent();
145
+ subscriptionState = (this.subscriptionObserverMap.get(subscriptionId_1) || {}).subscriptionState;
146
+ if (!subscriptionState) {
147
+ // subscription already unsubscribed
148
+ return [2 /*return*/];
149
+ }
150
+ if (subscriptionState === SUBSCRIPTION_STATUS.CONNECTED) {
151
+ this._sendUnsubscriptionMessage(subscriptionId_1);
152
+ }
153
+ else {
154
+ throw new Error('Subscription never connected');
155
+ }
156
+ return [3 /*break*/, 5];
157
+ case 3:
158
+ err_1 = _a.sent();
159
+ logger.debug("Error while unsubscribing " + err_1);
160
+ return [3 /*break*/, 5];
161
+ case 4:
162
+ this._removeSubscriptionObserver(subscriptionId_1);
163
+ return [7 /*endfinally*/];
164
+ case 5: return [2 /*return*/];
165
+ }
166
+ });
167
+ }); };
168
+ }
169
+ });
170
+ };
171
+ AWSAppSyncRealTimeProvider.prototype._startSubscriptionWithAWSAppSyncRealTime = function (_a) {
172
+ var options = _a.options, observer = _a.observer, subscriptionId = _a.subscriptionId, customUserAgentDetails = _a.customUserAgentDetails;
173
+ var _b;
174
+ return __awaiter(this, void 0, void 0, function () {
175
+ var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _c, graphql_headers, _d, additionalHeaders, subscriptionState, data, dataString, headerObj, _e, _f, subscriptionMessage, stringToAWSRealTime, err_2, _g, subscriptionFailedCallback, subscriptionReadyCallback;
176
+ var _h;
177
+ var _this = this;
178
+ return __generator(this, function (_j) {
179
+ switch (_j.label) {
180
+ case 0:
181
+ appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region, _c = options.graphql_headers, graphql_headers = _c === void 0 ? function () { return ({}); } : _c, _d = options.additionalHeaders, additionalHeaders = _d === void 0 ? {} : _d;
182
+ subscriptionState = SUBSCRIPTION_STATUS.PENDING;
183
+ data = {
184
+ query: query,
185
+ variables: variables,
186
+ };
187
+ // Having a subscription id map will make it simple to forward messages received
188
+ this.subscriptionObserverMap.set(subscriptionId, {
189
+ observer: observer,
190
+ query: query !== null && query !== void 0 ? query : '',
191
+ variables: variables !== null && variables !== void 0 ? variables : {},
192
+ subscriptionState: subscriptionState,
193
+ startAckTimeoutId: undefined,
194
+ });
195
+ dataString = JSON.stringify(data);
196
+ _e = [{}];
197
+ return [4 /*yield*/, this._awsRealTimeHeaderBasedAuth({
198
+ apiKey: apiKey,
199
+ appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
200
+ authenticationType: authenticationType,
201
+ payload: dataString,
202
+ canonicalUri: '',
203
+ region: region,
204
+ additionalHeaders: additionalHeaders,
205
+ })];
206
+ case 1:
207
+ _f = [__assign.apply(void 0, _e.concat([(_j.sent())]))];
208
+ return [4 /*yield*/, graphql_headers()];
209
+ case 2:
210
+ headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _f.concat([(_j.sent())])), additionalHeaders]), (_h = {}, _h[USER_AGENT_HEADER] = getAmplifyUserAgent(customUserAgentDetails), _h)]);
211
+ subscriptionMessage = {
212
+ id: subscriptionId,
213
+ payload: {
214
+ data: dataString,
215
+ extensions: {
216
+ authorization: __assign({}, headerObj),
217
+ },
218
+ },
219
+ type: MESSAGE_TYPES.GQL_START,
220
+ };
221
+ stringToAWSRealTime = JSON.stringify(subscriptionMessage);
222
+ _j.label = 3;
223
+ case 3:
224
+ _j.trys.push([3, 5, , 6]);
225
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.OPENING_CONNECTION);
226
+ return [4 /*yield*/, this._initializeWebSocketConnection({
227
+ apiKey: apiKey,
228
+ appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
229
+ authenticationType: authenticationType,
230
+ region: region,
231
+ additionalHeaders: additionalHeaders,
232
+ })];
233
+ case 4:
234
+ _j.sent();
235
+ return [3 /*break*/, 6];
236
+ case 5:
237
+ err_2 = _j.sent();
238
+ this._logStartSubscriptionError(subscriptionId, observer, err_2);
239
+ return [2 /*return*/];
240
+ case 6:
241
+ _g = (_b = this.subscriptionObserverMap.get(subscriptionId)) !== null && _b !== void 0 ? _b : {}, subscriptionFailedCallback = _g.subscriptionFailedCallback, subscriptionReadyCallback = _g.subscriptionReadyCallback;
242
+ // This must be done before sending the message in order to be listening immediately
243
+ this.subscriptionObserverMap.set(subscriptionId, {
244
+ observer: observer,
245
+ subscriptionState: subscriptionState,
246
+ query: query !== null && query !== void 0 ? query : '',
247
+ variables: variables !== null && variables !== void 0 ? variables : {},
248
+ subscriptionReadyCallback: subscriptionReadyCallback,
249
+ subscriptionFailedCallback: subscriptionFailedCallback,
250
+ startAckTimeoutId: setTimeout(function () {
251
+ _this._timeoutStartSubscriptionAck.call(_this, subscriptionId);
252
+ }, START_ACK_TIMEOUT),
253
+ });
254
+ if (this.awsRealTimeSocket) {
255
+ this.awsRealTimeSocket.send(stringToAWSRealTime);
256
+ }
257
+ return [2 /*return*/];
258
+ }
259
+ });
260
+ });
261
+ };
262
+ // Log logic for start subscription failures
263
+ AWSAppSyncRealTimeProvider.prototype._logStartSubscriptionError = function (subscriptionId, observer, err) {
264
+ var _a;
265
+ logger.debug({ err: err });
266
+ var message = String((_a = err.message) !== null && _a !== void 0 ? _a : '');
267
+ // Resolving to give the state observer time to propogate the update
268
+ Promise.resolve(this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED));
269
+ // Capture the error only when the network didn't cause disruption
270
+ if (this.connectionState !== ConnectionState.ConnectionDisruptedPendingNetwork) {
271
+ // When the error is non-retriable, error out the observable
272
+ if (isNonRetryableError(err)) {
273
+ observer.error({
274
+ errors: [
275
+ __assign({}, new GraphQLError(CONTROL_MSG.CONNECTION_FAILED + ": " + message)),
276
+ ],
277
+ });
278
+ }
279
+ else {
280
+ logger.debug(CONTROL_MSG.CONNECTION_FAILED + ": " + message);
281
+ }
282
+ var subscriptionFailedCallback = (this.subscriptionObserverMap.get(subscriptionId) || {}).subscriptionFailedCallback;
283
+ // Notify concurrent unsubscription
284
+ if (typeof subscriptionFailedCallback === 'function') {
285
+ subscriptionFailedCallback();
286
+ }
287
+ }
288
+ };
289
+ // Waiting that subscription has been connected before trying to unsubscribe
290
+ AWSAppSyncRealTimeProvider.prototype._waitForSubscriptionToBeConnected = function (subscriptionId) {
291
+ return __awaiter(this, void 0, void 0, function () {
292
+ var subscriptionObserver, subscriptionState;
293
+ var _this = this;
294
+ return __generator(this, function (_a) {
295
+ subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
296
+ if (subscriptionObserver) {
297
+ subscriptionState = subscriptionObserver.subscriptionState;
298
+ // This in case unsubscribe is invoked before sending start subscription message
299
+ if (subscriptionState === SUBSCRIPTION_STATUS.PENDING) {
300
+ return [2 /*return*/, new Promise(function (res, rej) {
301
+ var observer = subscriptionObserver.observer, subscriptionState = subscriptionObserver.subscriptionState, variables = subscriptionObserver.variables, query = subscriptionObserver.query;
302
+ _this.subscriptionObserverMap.set(subscriptionId, {
303
+ observer: observer,
304
+ subscriptionState: subscriptionState,
305
+ variables: variables,
306
+ query: query,
307
+ subscriptionReadyCallback: res,
308
+ subscriptionFailedCallback: rej,
309
+ });
310
+ })];
311
+ }
312
+ }
313
+ return [2 /*return*/];
314
+ });
315
+ });
316
+ };
317
+ AWSAppSyncRealTimeProvider.prototype._sendUnsubscriptionMessage = function (subscriptionId) {
318
+ try {
319
+ if (this.awsRealTimeSocket &&
320
+ this.awsRealTimeSocket.readyState === WebSocket.OPEN &&
321
+ this.socketStatus === SOCKET_STATUS.READY) {
322
+ // Preparing unsubscribe message to stop receiving messages for that subscription
323
+ var unsubscribeMessage = {
324
+ id: subscriptionId,
325
+ type: MESSAGE_TYPES.GQL_STOP,
326
+ };
327
+ var stringToAWSRealTime = JSON.stringify(unsubscribeMessage);
328
+ this.awsRealTimeSocket.send(stringToAWSRealTime);
329
+ }
330
+ }
331
+ catch (err) {
332
+ // If GQL_STOP is not sent because of disconnection issue, then there is nothing the client can do
333
+ logger.debug({ err: err });
334
+ }
335
+ };
336
+ AWSAppSyncRealTimeProvider.prototype._removeSubscriptionObserver = function (subscriptionId) {
337
+ this.subscriptionObserverMap.delete(subscriptionId);
338
+ // Verifying 1000ms after removing subscription in case there are new subscription unmount/mount
339
+ setTimeout(this._closeSocketIfRequired.bind(this), 1000);
340
+ };
341
+ AWSAppSyncRealTimeProvider.prototype._closeSocketIfRequired = function () {
342
+ if (this.subscriptionObserverMap.size > 0) {
343
+ // Active subscriptions on the WebSocket
344
+ return;
345
+ }
346
+ if (!this.awsRealTimeSocket) {
347
+ this.socketStatus = SOCKET_STATUS.CLOSED;
348
+ return;
349
+ }
350
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSING_CONNECTION);
351
+ if (this.awsRealTimeSocket.bufferedAmount > 0) {
352
+ // Still data on the WebSocket
353
+ setTimeout(this._closeSocketIfRequired.bind(this), 1000);
354
+ }
355
+ else {
356
+ logger.debug('closing WebSocket...');
357
+ if (this.keepAliveTimeoutId) {
358
+ clearTimeout(this.keepAliveTimeoutId);
359
+ }
360
+ if (this.keepAliveAlertTimeoutId) {
361
+ clearTimeout(this.keepAliveAlertTimeoutId);
362
+ }
363
+ var tempSocket = this.awsRealTimeSocket;
364
+ // Cleaning callbacks to avoid race condition, socket still exists
365
+ tempSocket.onclose = null;
366
+ tempSocket.onerror = null;
367
+ tempSocket.close(1000);
368
+ this.awsRealTimeSocket = undefined;
369
+ this.socketStatus = SOCKET_STATUS.CLOSED;
370
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
371
+ }
372
+ };
373
+ AWSAppSyncRealTimeProvider.prototype._handleIncomingSubscriptionMessage = function (message) {
374
+ var _this = this;
375
+ if (typeof message.data !== 'string') {
376
+ return;
377
+ }
378
+ logger.debug("subscription message from AWS AppSync RealTime: " + message.data);
379
+ var _a = JSON.parse(String(message.data)), _b = _a.id, id = _b === void 0 ? '' : _b, payload = _a.payload, type = _a.type;
380
+ var _c = this.subscriptionObserverMap.get(id) || {}, _d = _c.observer, observer = _d === void 0 ? null : _d, _e = _c.query, query = _e === void 0 ? '' : _e, _f = _c.variables, variables = _f === void 0 ? {} : _f, startAckTimeoutId = _c.startAckTimeoutId, subscriptionReadyCallback = _c.subscriptionReadyCallback, subscriptionFailedCallback = _c.subscriptionFailedCallback;
381
+ logger.debug({ id: id, observer: observer, query: query, variables: variables });
382
+ if (type === MESSAGE_TYPES.GQL_DATA && payload && payload.data) {
383
+ if (observer) {
384
+ observer.next(payload);
385
+ }
386
+ else {
387
+ logger.debug("observer not found for id: " + id);
388
+ }
389
+ return;
390
+ }
391
+ if (type === MESSAGE_TYPES.GQL_START_ACK) {
392
+ logger.debug("subscription ready for " + JSON.stringify({ query: query, variables: variables }));
393
+ if (typeof subscriptionReadyCallback === 'function') {
394
+ subscriptionReadyCallback();
395
+ }
396
+ if (startAckTimeoutId)
397
+ clearTimeout(startAckTimeoutId);
398
+ // dispatchApiEvent(
399
+ // CONTROL_MSG.SUBSCRIPTION_ACK,
400
+ // { query, variables },
401
+ // 'Connection established for subscription'
402
+ // );
403
+ var subscriptionState = SUBSCRIPTION_STATUS.CONNECTED;
404
+ if (observer) {
405
+ this.subscriptionObserverMap.set(id, {
406
+ observer: observer,
407
+ query: query,
408
+ variables: variables,
409
+ startAckTimeoutId: undefined,
410
+ subscriptionState: subscriptionState,
411
+ subscriptionReadyCallback: subscriptionReadyCallback,
412
+ subscriptionFailedCallback: subscriptionFailedCallback,
413
+ });
414
+ }
415
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_ESTABLISHED);
416
+ return;
417
+ }
418
+ if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {
419
+ if (this.keepAliveTimeoutId)
420
+ clearTimeout(this.keepAliveTimeoutId);
421
+ if (this.keepAliveAlertTimeoutId)
422
+ clearTimeout(this.keepAliveAlertTimeoutId);
423
+ this.keepAliveTimeoutId = setTimeout(function () { return _this._errorDisconnect(CONTROL_MSG.TIMEOUT_DISCONNECT); }, this.keepAliveTimeout);
424
+ this.keepAliveAlertTimeoutId = setTimeout(function () {
425
+ _this.connectionStateMonitor.record(CONNECTION_CHANGE.KEEP_ALIVE_MISSED);
426
+ }, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT);
427
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.KEEP_ALIVE);
428
+ return;
429
+ }
430
+ if (type === MESSAGE_TYPES.GQL_ERROR) {
431
+ var subscriptionState = SUBSCRIPTION_STATUS.FAILED;
432
+ if (observer) {
433
+ this.subscriptionObserverMap.set(id, {
434
+ observer: observer,
435
+ query: query,
436
+ variables: variables,
437
+ startAckTimeoutId: startAckTimeoutId,
438
+ subscriptionReadyCallback: subscriptionReadyCallback,
439
+ subscriptionFailedCallback: subscriptionFailedCallback,
440
+ subscriptionState: subscriptionState,
441
+ });
442
+ logger.debug(CONTROL_MSG.CONNECTION_FAILED + ": " + JSON.stringify(payload));
443
+ observer.error({
444
+ errors: [
445
+ __assign({}, new GraphQLError(CONTROL_MSG.CONNECTION_FAILED + ": " + JSON.stringify(payload))),
446
+ ],
447
+ });
448
+ if (startAckTimeoutId)
449
+ clearTimeout(startAckTimeoutId);
450
+ if (typeof subscriptionFailedCallback === 'function') {
451
+ subscriptionFailedCallback();
452
+ }
453
+ }
454
+ }
455
+ };
456
+ AWSAppSyncRealTimeProvider.prototype._errorDisconnect = function (msg) {
457
+ logger.debug("Disconnect error: " + msg);
458
+ if (this.awsRealTimeSocket) {
459
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
460
+ this.awsRealTimeSocket.close();
461
+ }
462
+ this.socketStatus = SOCKET_STATUS.CLOSED;
463
+ };
464
+ AWSAppSyncRealTimeProvider.prototype._timeoutStartSubscriptionAck = function (subscriptionId) {
465
+ var subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
466
+ if (subscriptionObserver) {
467
+ var observer = subscriptionObserver.observer, query = subscriptionObserver.query, variables = subscriptionObserver.variables;
468
+ if (!observer) {
469
+ return;
470
+ }
471
+ this.subscriptionObserverMap.set(subscriptionId, {
472
+ observer: observer,
473
+ query: query,
474
+ variables: variables,
475
+ subscriptionState: SUBSCRIPTION_STATUS.FAILED,
476
+ });
477
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
478
+ logger.debug('timeoutStartSubscription', JSON.stringify({ query: query, variables: variables }));
479
+ }
480
+ };
481
+ AWSAppSyncRealTimeProvider.prototype._initializeWebSocketConnection = function (_a) {
482
+ var _this = this;
483
+ var appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, authenticationType = _a.authenticationType, apiKey = _a.apiKey, region = _a.region, additionalHeaders = _a.additionalHeaders;
484
+ if (this.socketStatus === SOCKET_STATUS.READY) {
485
+ return;
486
+ }
487
+ return new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
488
+ var payloadString, authHeader, headerString, headerQs, payloadQs, discoverableEndpoint, protocol, awsRealTimeUrl, err_3;
489
+ return __generator(this, function (_a) {
490
+ switch (_a.label) {
491
+ case 0:
492
+ this.promiseArray.push({ res: res, rej: rej });
493
+ if (!(this.socketStatus === SOCKET_STATUS.CLOSED)) return [3 /*break*/, 5];
494
+ _a.label = 1;
495
+ case 1:
496
+ _a.trys.push([1, 4, , 5]);
497
+ this.socketStatus = SOCKET_STATUS.CONNECTING;
498
+ payloadString = '{}';
499
+ return [4 /*yield*/, this._awsRealTimeHeaderBasedAuth({
500
+ authenticationType: authenticationType,
501
+ payload: payloadString,
502
+ canonicalUri: '/connect',
503
+ apiKey: apiKey,
504
+ appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
505
+ region: region,
506
+ additionalHeaders: additionalHeaders,
507
+ })];
508
+ case 2:
509
+ authHeader = _a.sent();
510
+ headerString = authHeader ? JSON.stringify(authHeader) : '';
511
+ headerQs = Buffer.from(headerString).toString('base64');
512
+ payloadQs = Buffer.from(payloadString).toString('base64');
513
+ discoverableEndpoint = appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '';
514
+ if (this.isCustomDomain(discoverableEndpoint)) {
515
+ discoverableEndpoint =
516
+ discoverableEndpoint.concat(customDomainPath);
517
+ }
518
+ else {
519
+ discoverableEndpoint = discoverableEndpoint
520
+ .replace('appsync-api', 'appsync-realtime-api')
521
+ .replace('gogi-beta', 'grt-beta');
522
+ }
523
+ protocol = 'wss://';
524
+ discoverableEndpoint = discoverableEndpoint
525
+ .replace('https://', protocol)
526
+ .replace('http://', protocol);
527
+ awsRealTimeUrl = discoverableEndpoint + "?header=" + headerQs + "&payload=" + payloadQs;
528
+ return [4 /*yield*/, this._initializeRetryableHandshake(awsRealTimeUrl)];
529
+ case 3:
530
+ _a.sent();
531
+ this.promiseArray.forEach(function (_a) {
532
+ var res = _a.res;
533
+ logger.debug('Notifying connection successful');
534
+ res();
535
+ });
536
+ this.socketStatus = SOCKET_STATUS.READY;
537
+ this.promiseArray = [];
538
+ return [3 /*break*/, 5];
539
+ case 4:
540
+ err_3 = _a.sent();
541
+ logger.debug('Connection exited with', err_3);
542
+ this.promiseArray.forEach(function (_a) {
543
+ var rej = _a.rej;
544
+ return rej(err_3);
545
+ });
546
+ this.promiseArray = [];
547
+ if (this.awsRealTimeSocket &&
548
+ this.awsRealTimeSocket.readyState === WebSocket.OPEN) {
549
+ this.awsRealTimeSocket.close(3001);
550
+ }
551
+ this.awsRealTimeSocket = undefined;
552
+ this.socketStatus = SOCKET_STATUS.CLOSED;
553
+ return [3 /*break*/, 5];
554
+ case 5: return [2 /*return*/];
555
+ }
556
+ });
557
+ }); });
558
+ };
559
+ AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (awsRealTimeUrl) {
560
+ return __awaiter(this, void 0, void 0, function () {
561
+ return __generator(this, function (_a) {
562
+ switch (_a.label) {
563
+ case 0:
564
+ logger.debug("Initializaling retryable Handshake");
565
+ return [4 /*yield*/, jitteredExponentialRetry(this._initializeHandshake.bind(this), [awsRealTimeUrl], MAX_DELAY_MS)];
566
+ case 1:
567
+ _a.sent();
568
+ return [2 /*return*/];
569
+ }
570
+ });
571
+ });
572
+ };
573
+ AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (awsRealTimeUrl) {
574
+ return __awaiter(this, void 0, void 0, function () {
575
+ var err_4, _a, errorType, errorCode;
576
+ var _this = this;
577
+ return __generator(this, function (_b) {
578
+ switch (_b.label) {
579
+ case 0:
580
+ logger.debug("Initializing handshake " + awsRealTimeUrl);
581
+ _b.label = 1;
582
+ case 1:
583
+ _b.trys.push([1, 4, , 5]);
584
+ return [4 /*yield*/, (function () {
585
+ return new Promise(function (res, rej) {
586
+ var newSocket = _this.getNewWebSocket(awsRealTimeUrl, 'graphql-ws');
587
+ newSocket.onerror = function () {
588
+ logger.debug("WebSocket connection error");
589
+ };
590
+ newSocket.onclose = function () {
591
+ rej(new Error('Connection handshake error'));
592
+ };
593
+ newSocket.onopen = function () {
594
+ _this.awsRealTimeSocket = newSocket;
595
+ return res();
596
+ };
597
+ });
598
+ })()];
599
+ case 2:
600
+ _b.sent();
601
+ // Step 2: wait for ack from AWS AppSyncReaTime after sending init
602
+ return [4 /*yield*/, (function () {
603
+ return new Promise(function (res, rej) {
604
+ if (_this.awsRealTimeSocket) {
605
+ var ackOk_1 = false;
606
+ _this.awsRealTimeSocket.onerror = function (error) {
607
+ logger.debug("WebSocket error " + JSON.stringify(error));
608
+ };
609
+ _this.awsRealTimeSocket.onclose = function (event) {
610
+ logger.debug("WebSocket closed " + event.reason);
611
+ rej(new Error(JSON.stringify(event)));
612
+ };
613
+ _this.awsRealTimeSocket.onmessage = function (message) {
614
+ if (typeof message.data !== 'string') {
615
+ return;
616
+ }
617
+ logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
618
+ var data = JSON.parse(message.data);
619
+ var type = data.type, _a = data.payload, _b = (_a === void 0 ? {} : _a).connectionTimeoutMs, connectionTimeoutMs = _b === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _b;
620
+ if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
621
+ ackOk_1 = true;
622
+ if (_this.awsRealTimeSocket) {
623
+ _this.keepAliveTimeout = connectionTimeoutMs;
624
+ _this.awsRealTimeSocket.onmessage =
625
+ _this._handleIncomingSubscriptionMessage.bind(_this);
626
+ _this.awsRealTimeSocket.onerror = function (err) {
627
+ logger.debug(err);
628
+ _this._errorDisconnect(CONTROL_MSG.CONNECTION_CLOSED);
629
+ };
630
+ _this.awsRealTimeSocket.onclose = function (event) {
631
+ logger.debug("WebSocket closed " + event.reason);
632
+ _this._errorDisconnect(CONTROL_MSG.CONNECTION_CLOSED);
633
+ };
634
+ }
635
+ res('Cool, connected to AWS AppSyncRealTime');
636
+ return;
637
+ }
638
+ if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
639
+ var _c = data.payload, _d = (_c === void 0 ? {} : _c).errors, _e = __read(_d === void 0 ? [] : _d, 1), _f = _e[0], _g = _f === void 0 ? {} : _f, _h = _g.errorType, errorType = _h === void 0 ? '' : _h, _j = _g.errorCode, errorCode = _j === void 0 ? 0 : _j;
640
+ rej({ errorType: errorType, errorCode: errorCode });
641
+ }
642
+ };
643
+ var gqlInit = {
644
+ type: MESSAGE_TYPES.GQL_CONNECTION_INIT,
645
+ };
646
+ _this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
647
+ var checkAckOk_1 = function (ackOk) {
648
+ if (!ackOk) {
649
+ _this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_FAILED);
650
+ rej(new Error("Connection timeout: ack from AWSAppSyncRealTime was not received after " + CONNECTION_INIT_TIMEOUT + " ms"));
651
+ }
652
+ };
653
+ setTimeout(function () { return checkAckOk_1(ackOk_1); }, CONNECTION_INIT_TIMEOUT);
654
+ }
655
+ });
656
+ })()];
657
+ case 3:
658
+ // Step 2: wait for ack from AWS AppSyncReaTime after sending init
659
+ _b.sent();
660
+ return [3 /*break*/, 5];
661
+ case 4:
662
+ err_4 = _b.sent();
663
+ _a = err_4, errorType = _a.errorType, errorCode = _a.errorCode;
664
+ if (NON_RETRYABLE_CODES.includes(errorCode)) {
665
+ throw new NonRetryableError(errorType);
666
+ }
667
+ else if (errorType) {
668
+ throw new Error(errorType);
669
+ }
670
+ else {
671
+ throw err_4;
672
+ }
673
+ return [3 /*break*/, 5];
674
+ case 5: return [2 /*return*/];
675
+ }
676
+ });
677
+ });
678
+ };
679
+ AWSAppSyncRealTimeProvider.prototype._awsRealTimeHeaderBasedAuth = function (_a) {
680
+ var authenticationType = _a.authenticationType, payload = _a.payload, canonicalUri = _a.canonicalUri, appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, region = _a.region, additionalHeaders = _a.additionalHeaders;
681
+ return __awaiter(this, void 0, void 0, function () {
682
+ var headerHandler, handler, host, apiKey, result;
683
+ return __generator(this, function (_b) {
684
+ switch (_b.label) {
685
+ case 0:
686
+ headerHandler = {
687
+ apiKey: this._awsRealTimeApiKeyHeader.bind(this),
688
+ iam: this._awsRealTimeIAMHeader.bind(this),
689
+ jwt: this._awsRealTimeOPENIDHeader.bind(this),
690
+ custom: this._customAuthHeader,
691
+ };
692
+ if (!(!authenticationType || !headerHandler[authenticationType.type])) return [3 /*break*/, 1];
693
+ logger.debug("Authentication type " + authenticationType + " not supported");
694
+ return [2 /*return*/, undefined];
695
+ case 1:
696
+ handler = headerHandler[authenticationType.type];
697
+ host = url.parse(appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
698
+ logger.debug("Authenticating with " + authenticationType);
699
+ apiKey = void 0;
700
+ if (authenticationType.type === 'apiKey') {
701
+ apiKey = authenticationType.apiKey;
702
+ }
703
+ return [4 /*yield*/, handler({
704
+ payload: payload,
705
+ canonicalUri: canonicalUri,
706
+ appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
707
+ apiKey: apiKey,
708
+ region: region,
709
+ host: host,
710
+ additionalHeaders: additionalHeaders,
711
+ })];
712
+ case 2:
713
+ result = _b.sent();
714
+ return [2 /*return*/, result];
715
+ }
716
+ });
717
+ });
718
+ };
719
+ AWSAppSyncRealTimeProvider.prototype._awsRealTimeCUPHeader = function (_a) {
720
+ var host = _a.host;
721
+ return __awaiter(this, void 0, void 0, function () {
722
+ var session;
723
+ return __generator(this, function (_b) {
724
+ switch (_b.label) {
725
+ case 0: return [4 /*yield*/, fetchAuthSession()];
726
+ case 1:
727
+ session = _b.sent();
728
+ return [2 /*return*/, {
729
+ Authorization: session.tokens.accessToken.toString(),
730
+ host: host,
731
+ }];
732
+ }
733
+ });
734
+ });
735
+ };
736
+ AWSAppSyncRealTimeProvider.prototype._awsRealTimeOPENIDHeader = function (_a) {
737
+ var host = _a.host;
738
+ return __awaiter(this, void 0, void 0, function () {
739
+ var session;
740
+ return __generator(this, function (_b) {
741
+ switch (_b.label) {
742
+ case 0: return [4 /*yield*/, fetchAuthSession()];
743
+ case 1:
744
+ session = _b.sent();
745
+ return [2 /*return*/, {
746
+ Authorization: session.tokens.accessToken.toString(),
747
+ host: host,
748
+ }];
749
+ }
750
+ });
751
+ });
752
+ };
753
+ AWSAppSyncRealTimeProvider.prototype._awsRealTimeApiKeyHeader = function (_a) {
754
+ var apiKey = _a.apiKey, host = _a.host;
755
+ return __awaiter(this, void 0, void 0, function () {
756
+ var dt, dtStr;
757
+ return __generator(this, function (_b) {
758
+ dt = new Date();
759
+ dtStr = dt.toISOString().replace(/[:\-]|\.\d{3}/g, '');
760
+ return [2 /*return*/, {
761
+ host: host,
762
+ 'x-amz-date': dtStr,
763
+ 'x-api-key': apiKey,
764
+ }];
765
+ });
766
+ });
767
+ };
768
+ AWSAppSyncRealTimeProvider.prototype._awsRealTimeIAMHeader = function (_a) {
769
+ var payload = _a.payload, canonicalUri = _a.canonicalUri, appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, region = _a.region;
770
+ return __awaiter(this, void 0, void 0, function () {
771
+ var endpointInfo, creds, request, signed_params;
772
+ return __generator(this, function (_b) {
773
+ switch (_b.label) {
774
+ case 0:
775
+ endpointInfo = {
776
+ region: region,
777
+ service: 'appsync',
778
+ };
779
+ return [4 /*yield*/, fetchAuthSession()];
780
+ case 1:
781
+ creds = (_b.sent()).credentials;
782
+ request = {
783
+ url: "" + appSyncGraphqlEndpoint + canonicalUri,
784
+ data: payload,
785
+ method: 'POST',
786
+ headers: __assign({}, AWS_APPSYNC_REALTIME_HEADERS),
787
+ };
788
+ signed_params = signRequest({
789
+ headers: request.headers,
790
+ method: request.method,
791
+ url: new URL(request.url),
792
+ body: request.data,
793
+ }, {
794
+ credentials: creds,
795
+ signingRegion: endpointInfo.region,
796
+ signingService: endpointInfo.service,
797
+ });
798
+ return [2 /*return*/, signed_params.headers];
799
+ }
800
+ });
801
+ });
802
+ };
803
+ AWSAppSyncRealTimeProvider.prototype._customAuthHeader = function (_a) {
804
+ var host = _a.host, additionalHeaders = _a.additionalHeaders;
805
+ if (!additionalHeaders || !additionalHeaders['Authorization']) {
806
+ throw new Error('No auth token specified');
807
+ }
808
+ return {
809
+ Authorization: additionalHeaders.Authorization,
810
+ host: host,
811
+ };
812
+ };
813
+ return AWSAppSyncRealTimeProvider;
814
+ }());
815
+ export { AWSAppSyncRealTimeProvider };