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