@aws-amplify/pubsub 4.2.9-unstable.9 → 4.2.10-cloud-logging.8
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/CHANGELOG.md +27 -44
- package/dist/aws-amplify-pubsub.js +258 -209
- package/dist/aws-amplify-pubsub.js.map +1 -1
- package/dist/aws-amplify-pubsub.min.js +2 -2
- package/dist/aws-amplify-pubsub.min.js.map +1 -1
- package/lib/Providers/AWSAppSyncProvider.d.ts +3 -0
- package/lib/Providers/AWSAppSyncProvider.js +3 -0
- package/lib/Providers/AWSAppSyncProvider.js.map +1 -1
- package/lib/Providers/AWSAppSyncRealTimeProvider.d.ts +19 -4
- package/lib/Providers/AWSAppSyncRealTimeProvider.js +192 -159
- package/lib/Providers/AWSAppSyncRealTimeProvider.js.map +1 -1
- package/lib/Providers/AWSIotProvider.d.ts +6 -1
- package/lib/Providers/AWSIotProvider.js +3 -2
- package/lib/Providers/AWSIotProvider.js.map +1 -1
- package/lib/Providers/MqttOverWSProvider.d.ts +14 -11
- package/lib/Providers/MqttOverWSProvider.js +17 -10
- package/lib/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib/Providers/PubSubProvider.d.ts +7 -7
- package/lib/Providers/PubSubProvider.js.map +1 -1
- package/lib/PubSub.d.ts +6 -6
- package/lib/PubSub.js +2 -2
- package/lib/PubSub.js.map +1 -1
- package/lib/types/Provider.d.ts +3 -3
- package/lib/types/PubSub.d.ts +5 -1
- package/lib-esm/Providers/AWSAppSyncProvider.d.ts +3 -0
- package/lib-esm/Providers/AWSAppSyncProvider.js +3 -0
- package/lib-esm/Providers/AWSAppSyncProvider.js.map +1 -1
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider.d.ts +19 -4
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider.js +192 -159
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider.js.map +1 -1
- package/lib-esm/Providers/AWSIotProvider.d.ts +6 -1
- package/lib-esm/Providers/AWSIotProvider.js +3 -2
- package/lib-esm/Providers/AWSIotProvider.js.map +1 -1
- package/lib-esm/Providers/MqttOverWSProvider.d.ts +14 -11
- package/lib-esm/Providers/MqttOverWSProvider.js +17 -10
- package/lib-esm/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib-esm/Providers/PubSubProvider.d.ts +7 -7
- package/lib-esm/Providers/PubSubProvider.js.map +1 -1
- package/lib-esm/PubSub.d.ts +6 -6
- package/lib-esm/PubSub.js +2 -2
- package/lib-esm/PubSub.js.map +1 -1
- package/lib-esm/types/Provider.d.ts +3 -3
- package/lib-esm/types/PubSub.d.ts +5 -1
- package/package.json +5 -5
- package/src/Providers/AWSAppSyncProvider.ts +27 -26
- package/src/Providers/AWSAppSyncRealTimeProvider.ts +276 -214
- package/src/Providers/AWSIotProvider.ts +10 -1
- package/src/Providers/MqttOverWSProvider.ts +52 -33
- package/src/Providers/PubSubProvider.ts +8 -8
- package/src/PubSub.ts +10 -10
- package/src/types/Provider.ts +3 -7
- package/src/types/PubSub.ts +6 -1
|
@@ -7305,6 +7305,9 @@ var __spread = undefined && undefined.__spread || function () {
|
|
|
7305
7305
|
|
|
7306
7306
|
|
|
7307
7307
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('AWSAppSyncProvider');
|
|
7308
|
+
/**
|
|
7309
|
+
* @deprecated Unused, all usecases have migrated to AWSAppSyncRealtimeProvider
|
|
7310
|
+
*/
|
|
7308
7311
|
|
|
7309
7312
|
var AWSAppSyncProvider =
|
|
7310
7313
|
/** @class */
|
|
@@ -8028,9 +8031,9 @@ function (_super) {
|
|
|
8028
8031
|
AWSAppSyncRealTimeProvider.prototype.subscribe = function (_topics, options) {
|
|
8029
8032
|
var _this = this;
|
|
8030
8033
|
|
|
8031
|
-
var appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint;
|
|
8034
|
+
var appSyncGraphqlEndpoint = options === null || options === void 0 ? void 0 : options.appSyncGraphqlEndpoint;
|
|
8032
8035
|
return new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (observer) {
|
|
8033
|
-
if (!appSyncGraphqlEndpoint) {
|
|
8036
|
+
if (!options || !appSyncGraphqlEndpoint) {
|
|
8034
8037
|
observer.error({
|
|
8035
8038
|
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscribe only available for AWS AppSync endpoint"))]
|
|
8036
8039
|
});
|
|
@@ -8123,19 +8126,22 @@ function (_super) {
|
|
|
8123
8126
|
var options = _a.options,
|
|
8124
8127
|
observer = _a.observer,
|
|
8125
8128
|
subscriptionId = _a.subscriptionId;
|
|
8129
|
+
|
|
8130
|
+
var _b, _c;
|
|
8131
|
+
|
|
8126
8132
|
return __awaiter(this, void 0, void 0, function () {
|
|
8127
|
-
var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region,
|
|
8133
|
+
var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _d, graphql_headers, _e, additionalHeaders, subscriptionState, data, dataString, headerObj, _f, _g, subscriptionMessage, stringToAWSRealTime, err_2, message, subscriptionFailedCallback_1, _h, subscriptionFailedCallback, subscriptionReadyCallback;
|
|
8128
8134
|
|
|
8129
|
-
var
|
|
8135
|
+
var _j;
|
|
8130
8136
|
|
|
8131
8137
|
var _this = this;
|
|
8132
8138
|
|
|
8133
|
-
return __generator(this, function (
|
|
8134
|
-
switch (
|
|
8139
|
+
return __generator(this, function (_k) {
|
|
8140
|
+
switch (_k.label) {
|
|
8135
8141
|
case 0:
|
|
8136
|
-
appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region,
|
|
8142
|
+
appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region, _d = options.graphql_headers, graphql_headers = _d === void 0 ? function () {
|
|
8137
8143
|
return {};
|
|
8138
|
-
} :
|
|
8144
|
+
} : _d, _e = options.additionalHeaders, additionalHeaders = _e === void 0 ? {} : _e;
|
|
8139
8145
|
subscriptionState = SUBSCRIPTION_STATUS.PENDING;
|
|
8140
8146
|
data = {
|
|
8141
8147
|
query: query,
|
|
@@ -8144,13 +8150,13 @@ function (_super) {
|
|
|
8144
8150
|
|
|
8145
8151
|
this.subscriptionObserverMap.set(subscriptionId, {
|
|
8146
8152
|
observer: observer,
|
|
8147
|
-
query: query,
|
|
8148
|
-
variables: variables,
|
|
8153
|
+
query: query !== null && query !== void 0 ? query : '',
|
|
8154
|
+
variables: variables !== null && variables !== void 0 ? variables : {},
|
|
8149
8155
|
subscriptionState: subscriptionState,
|
|
8150
|
-
startAckTimeoutId:
|
|
8156
|
+
startAckTimeoutId: undefined
|
|
8151
8157
|
});
|
|
8152
8158
|
dataString = JSON.stringify(data);
|
|
8153
|
-
|
|
8159
|
+
_f = [{}];
|
|
8154
8160
|
return [4
|
|
8155
8161
|
/*yield*/
|
|
8156
8162
|
, this._awsRealTimeHeaderBasedAuth({
|
|
@@ -8164,13 +8170,13 @@ function (_super) {
|
|
|
8164
8170
|
})];
|
|
8165
8171
|
|
|
8166
8172
|
case 1:
|
|
8167
|
-
|
|
8173
|
+
_g = [__assign.apply(void 0, _f.concat([_k.sent()]))];
|
|
8168
8174
|
return [4
|
|
8169
8175
|
/*yield*/
|
|
8170
8176
|
, graphql_headers()];
|
|
8171
8177
|
|
|
8172
8178
|
case 2:
|
|
8173
|
-
headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0,
|
|
8179
|
+
headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _g.concat([_k.sent()])), additionalHeaders]), (_j = {}, _j[_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["USER_AGENT_HEADER"]] = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Constants"].userAgent, _j)]);
|
|
8174
8180
|
subscriptionMessage = {
|
|
8175
8181
|
id: subscriptionId,
|
|
8176
8182
|
payload: {
|
|
@@ -8182,10 +8188,10 @@ function (_super) {
|
|
|
8182
8188
|
type: MESSAGE_TYPES.GQL_START
|
|
8183
8189
|
};
|
|
8184
8190
|
stringToAWSRealTime = JSON.stringify(subscriptionMessage);
|
|
8185
|
-
|
|
8191
|
+
_k.label = 3;
|
|
8186
8192
|
|
|
8187
8193
|
case 3:
|
|
8188
|
-
|
|
8194
|
+
_k.trys.push([3, 5,, 6]);
|
|
8189
8195
|
|
|
8190
8196
|
return [4
|
|
8191
8197
|
/*yield*/
|
|
@@ -8198,18 +8204,18 @@ function (_super) {
|
|
|
8198
8204
|
})];
|
|
8199
8205
|
|
|
8200
8206
|
case 4:
|
|
8201
|
-
|
|
8207
|
+
_k.sent();
|
|
8202
8208
|
|
|
8203
8209
|
return [3
|
|
8204
8210
|
/*break*/
|
|
8205
8211
|
, 6];
|
|
8206
8212
|
|
|
8207
8213
|
case 5:
|
|
8208
|
-
err_2 =
|
|
8214
|
+
err_2 = _k.sent();
|
|
8209
8215
|
logger.debug({
|
|
8210
8216
|
err: err_2
|
|
8211
8217
|
});
|
|
8212
|
-
|
|
8218
|
+
message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
|
|
8213
8219
|
observer.error({
|
|
8214
8220
|
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
|
|
8215
8221
|
});
|
|
@@ -8225,13 +8231,13 @@ function (_super) {
|
|
|
8225
8231
|
];
|
|
8226
8232
|
|
|
8227
8233
|
case 6:
|
|
8228
|
-
|
|
8234
|
+
_h = (_c = this.subscriptionObserverMap.get(subscriptionId)) !== null && _c !== void 0 ? _c : {}, subscriptionFailedCallback = _h.subscriptionFailedCallback, subscriptionReadyCallback = _h.subscriptionReadyCallback; // This must be done before sending the message in order to be listening immediately
|
|
8229
8235
|
|
|
8230
8236
|
this.subscriptionObserverMap.set(subscriptionId, {
|
|
8231
8237
|
observer: observer,
|
|
8232
8238
|
subscriptionState: subscriptionState,
|
|
8233
|
-
|
|
8234
|
-
|
|
8239
|
+
query: query !== null && query !== void 0 ? query : '',
|
|
8240
|
+
variables: variables !== null && variables !== void 0 ? variables : {},
|
|
8235
8241
|
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
8236
8242
|
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
8237
8243
|
startAckTimeoutId: setTimeout(function () {
|
|
@@ -8254,32 +8260,35 @@ function (_super) {
|
|
|
8254
8260
|
|
|
8255
8261
|
AWSAppSyncRealTimeProvider.prototype._waitForSubscriptionToBeConnected = function (subscriptionId) {
|
|
8256
8262
|
return __awaiter(this, void 0, void 0, function () {
|
|
8257
|
-
var subscriptionState;
|
|
8263
|
+
var subscriptionObserver, subscriptionState;
|
|
8258
8264
|
|
|
8259
8265
|
var _this = this;
|
|
8260
8266
|
|
|
8261
8267
|
return __generator(this, function (_a) {
|
|
8262
|
-
|
|
8268
|
+
subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
|
|
8263
8269
|
|
|
8264
|
-
if (
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8270
|
+
if (subscriptionObserver) {
|
|
8271
|
+
subscriptionState = subscriptionObserver.subscriptionState; // This in case unsubscribe is invoked before sending start subscription message
|
|
8272
|
+
|
|
8273
|
+
if (subscriptionState === SUBSCRIPTION_STATUS.PENDING) {
|
|
8274
|
+
return [2
|
|
8275
|
+
/*return*/
|
|
8276
|
+
, new Promise(function (res, rej) {
|
|
8277
|
+
var observer = subscriptionObserver.observer,
|
|
8278
|
+
subscriptionState = subscriptionObserver.subscriptionState,
|
|
8279
|
+
variables = subscriptionObserver.variables,
|
|
8280
|
+
query = subscriptionObserver.query;
|
|
8281
|
+
|
|
8282
|
+
_this.subscriptionObserverMap.set(subscriptionId, {
|
|
8283
|
+
observer: observer,
|
|
8284
|
+
subscriptionState: subscriptionState,
|
|
8285
|
+
variables: variables,
|
|
8286
|
+
query: query,
|
|
8287
|
+
subscriptionReadyCallback: res,
|
|
8288
|
+
subscriptionFailedCallback: rej
|
|
8289
|
+
});
|
|
8290
|
+
})];
|
|
8291
|
+
}
|
|
8283
8292
|
}
|
|
8284
8293
|
|
|
8285
8294
|
return [2
|
|
@@ -8330,19 +8339,23 @@ function (_super) {
|
|
|
8330
8339
|
setTimeout(this._closeSocketIfRequired.bind(this), 1000);
|
|
8331
8340
|
} else {
|
|
8332
8341
|
logger.debug('closing WebSocket...');
|
|
8333
|
-
clearTimeout(this.keepAliveTimeoutId);
|
|
8342
|
+
if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
|
|
8334
8343
|
var tempSocket = this.awsRealTimeSocket; // Cleaning callbacks to avoid race condition, socket still exists
|
|
8335
8344
|
|
|
8336
|
-
tempSocket.onclose =
|
|
8337
|
-
tempSocket.onerror =
|
|
8345
|
+
tempSocket.onclose = null;
|
|
8346
|
+
tempSocket.onerror = null;
|
|
8338
8347
|
tempSocket.close(1000);
|
|
8339
|
-
this.awsRealTimeSocket =
|
|
8348
|
+
this.awsRealTimeSocket = undefined;
|
|
8340
8349
|
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
8341
8350
|
}
|
|
8342
8351
|
};
|
|
8343
8352
|
|
|
8344
8353
|
AWSAppSyncRealTimeProvider.prototype._handleIncomingSubscriptionMessage = function (message) {
|
|
8345
|
-
|
|
8354
|
+
if (message.data && message.data === '{"type":"ka"}') {
|
|
8355
|
+
logger.verbose("subscription message from AWS AppSync RealTime: " + message.data);
|
|
8356
|
+
} else {
|
|
8357
|
+
logger.debug("subscription message from AWS AppSync RealTime: " + message.data);
|
|
8358
|
+
}
|
|
8346
8359
|
|
|
8347
8360
|
var _a = JSON.parse(message.data),
|
|
8348
8361
|
_b = _a.id,
|
|
@@ -8361,12 +8374,21 @@ function (_super) {
|
|
|
8361
8374
|
subscriptionReadyCallback = _c.subscriptionReadyCallback,
|
|
8362
8375
|
subscriptionFailedCallback = _c.subscriptionFailedCallback;
|
|
8363
8376
|
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8377
|
+
if (!id && !observer && !query && Object.keys(variables).length === 0) {
|
|
8378
|
+
logger.verbose({
|
|
8379
|
+
id: id,
|
|
8380
|
+
observer: observer,
|
|
8381
|
+
query: query,
|
|
8382
|
+
variables: variables
|
|
8383
|
+
});
|
|
8384
|
+
} else {
|
|
8385
|
+
logger.debug({
|
|
8386
|
+
id: id,
|
|
8387
|
+
observer: observer,
|
|
8388
|
+
query: query,
|
|
8389
|
+
variables: variables
|
|
8390
|
+
});
|
|
8391
|
+
}
|
|
8370
8392
|
|
|
8371
8393
|
if (type === MESSAGE_TYPES.GQL_DATA && payload && payload.data) {
|
|
8372
8394
|
if (observer) {
|
|
@@ -8388,50 +8410,57 @@ function (_super) {
|
|
|
8388
8410
|
subscriptionReadyCallback();
|
|
8389
8411
|
}
|
|
8390
8412
|
|
|
8391
|
-
clearTimeout(startAckTimeoutId);
|
|
8413
|
+
if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
|
|
8392
8414
|
dispatchApiEvent(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].SUBSCRIPTION_ACK, {
|
|
8393
8415
|
query: query,
|
|
8394
8416
|
variables: variables
|
|
8395
8417
|
}, 'Connection established for subscription');
|
|
8396
8418
|
var subscriptionState = SUBSCRIPTION_STATUS.CONNECTED;
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8419
|
+
|
|
8420
|
+
if (observer) {
|
|
8421
|
+
this.subscriptionObserverMap.set(id, {
|
|
8422
|
+
observer: observer,
|
|
8423
|
+
query: query,
|
|
8424
|
+
variables: variables,
|
|
8425
|
+
startAckTimeoutId: undefined,
|
|
8426
|
+
subscriptionState: subscriptionState,
|
|
8427
|
+
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
8428
|
+
subscriptionFailedCallback: subscriptionFailedCallback
|
|
8429
|
+
});
|
|
8430
|
+
} // TODO: emit event on hub but it requires to store the id first
|
|
8431
|
+
|
|
8406
8432
|
|
|
8407
8433
|
return;
|
|
8408
8434
|
}
|
|
8409
8435
|
|
|
8410
8436
|
if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {
|
|
8411
|
-
clearTimeout(this.keepAliveTimeoutId);
|
|
8437
|
+
if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
|
|
8412
8438
|
this.keepAliveTimeoutId = setTimeout(this._errorDisconnect.bind(this, _index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT), this.keepAliveTimeout);
|
|
8413
8439
|
return;
|
|
8414
8440
|
}
|
|
8415
8441
|
|
|
8416
8442
|
if (type === MESSAGE_TYPES.GQL_ERROR) {
|
|
8417
8443
|
var subscriptionState = SUBSCRIPTION_STATUS.FAILED;
|
|
8418
|
-
this.subscriptionObserverMap.set(id, {
|
|
8419
|
-
observer: observer,
|
|
8420
|
-
query: query,
|
|
8421
|
-
variables: variables,
|
|
8422
|
-
startAckTimeoutId: startAckTimeoutId,
|
|
8423
|
-
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
8424
|
-
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
8425
|
-
subscriptionState: subscriptionState
|
|
8426
|
-
});
|
|
8427
|
-
observer.error({
|
|
8428
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
|
|
8429
|
-
});
|
|
8430
|
-
clearTimeout(startAckTimeoutId);
|
|
8431
|
-
observer.complete();
|
|
8432
8444
|
|
|
8433
|
-
if (
|
|
8434
|
-
|
|
8445
|
+
if (observer) {
|
|
8446
|
+
this.subscriptionObserverMap.set(id, {
|
|
8447
|
+
observer: observer,
|
|
8448
|
+
query: query,
|
|
8449
|
+
variables: variables,
|
|
8450
|
+
startAckTimeoutId: startAckTimeoutId,
|
|
8451
|
+
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
8452
|
+
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
8453
|
+
subscriptionState: subscriptionState
|
|
8454
|
+
});
|
|
8455
|
+
observer.error({
|
|
8456
|
+
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
|
|
8457
|
+
});
|
|
8458
|
+
if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
|
|
8459
|
+
observer.complete();
|
|
8460
|
+
|
|
8461
|
+
if (typeof subscriptionFailedCallback === 'function') {
|
|
8462
|
+
subscriptionFailedCallback();
|
|
8463
|
+
}
|
|
8435
8464
|
}
|
|
8436
8465
|
}
|
|
8437
8466
|
};
|
|
@@ -8457,37 +8486,40 @@ function (_super) {
|
|
|
8457
8486
|
};
|
|
8458
8487
|
|
|
8459
8488
|
AWSAppSyncRealTimeProvider.prototype._timeoutStartSubscriptionAck = function (subscriptionId) {
|
|
8460
|
-
var
|
|
8461
|
-
observer = _a.observer,
|
|
8462
|
-
query = _a.query,
|
|
8463
|
-
variables = _a.variables;
|
|
8489
|
+
var subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
|
|
8464
8490
|
|
|
8465
|
-
if (
|
|
8466
|
-
|
|
8467
|
-
|
|
8491
|
+
if (subscriptionObserver) {
|
|
8492
|
+
var observer = subscriptionObserver.observer,
|
|
8493
|
+
query = subscriptionObserver.query,
|
|
8494
|
+
variables = subscriptionObserver.variables;
|
|
8468
8495
|
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
variables: variables,
|
|
8473
|
-
subscriptionState: SUBSCRIPTION_STATUS.FAILED
|
|
8474
|
-
});
|
|
8496
|
+
if (!observer) {
|
|
8497
|
+
return;
|
|
8498
|
+
}
|
|
8475
8499
|
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
}); // Cleanup will be automatically executed
|
|
8500
|
+
this.subscriptionObserverMap.set(subscriptionId, {
|
|
8501
|
+
observer: observer,
|
|
8502
|
+
query: query,
|
|
8503
|
+
variables: variables,
|
|
8504
|
+
subscriptionState: SUBSCRIPTION_STATUS.FAILED
|
|
8505
|
+
});
|
|
8483
8506
|
|
|
8484
|
-
observer.
|
|
8485
|
-
|
|
8507
|
+
if (observer && !observer.closed) {
|
|
8508
|
+
observer.error({
|
|
8509
|
+
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
|
|
8510
|
+
query: query,
|
|
8511
|
+
variables: variables
|
|
8512
|
+
})))]
|
|
8513
|
+
}); // Cleanup will be automatically executed
|
|
8514
|
+
|
|
8515
|
+
observer.complete();
|
|
8516
|
+
}
|
|
8486
8517
|
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8518
|
+
logger.debug('timeoutStartSubscription', JSON.stringify({
|
|
8519
|
+
query: query,
|
|
8520
|
+
variables: variables
|
|
8521
|
+
}));
|
|
8522
|
+
}
|
|
8491
8523
|
};
|
|
8492
8524
|
|
|
8493
8525
|
AWSAppSyncRealTimeProvider.prototype._initializeWebSocketConnection = function (_a) {
|
|
@@ -8541,7 +8573,7 @@ function (_super) {
|
|
|
8541
8573
|
headerString = _b.apply(_a, [_c.sent()]);
|
|
8542
8574
|
headerQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(headerString).toString('base64');
|
|
8543
8575
|
payloadQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(payloadString).toString('base64');
|
|
8544
|
-
discoverableEndpoint = appSyncGraphqlEndpoint;
|
|
8576
|
+
discoverableEndpoint = appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '';
|
|
8545
8577
|
|
|
8546
8578
|
if (this.isCustomDomain(discoverableEndpoint)) {
|
|
8547
8579
|
discoverableEndpoint = discoverableEndpoint.concat(customDomainPath);
|
|
@@ -8554,9 +8586,7 @@ function (_super) {
|
|
|
8554
8586
|
awsRealTimeUrl = discoverableEndpoint + "?header=" + headerQs + "&payload=" + payloadQs;
|
|
8555
8587
|
return [4
|
|
8556
8588
|
/*yield*/
|
|
8557
|
-
, this._initializeRetryableHandshake(
|
|
8558
|
-
awsRealTimeUrl: awsRealTimeUrl
|
|
8559
|
-
})];
|
|
8589
|
+
, this._initializeRetryableHandshake(awsRealTimeUrl)];
|
|
8560
8590
|
|
|
8561
8591
|
case 3:
|
|
8562
8592
|
_c.sent();
|
|
@@ -8584,7 +8614,7 @@ function (_super) {
|
|
|
8584
8614
|
this.awsRealTimeSocket.close(3001);
|
|
8585
8615
|
}
|
|
8586
8616
|
|
|
8587
|
-
this.awsRealTimeSocket =
|
|
8617
|
+
this.awsRealTimeSocket = undefined;
|
|
8588
8618
|
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
8589
8619
|
return [3
|
|
8590
8620
|
/*break*/
|
|
@@ -8600,21 +8630,18 @@ function (_super) {
|
|
|
8600
8630
|
});
|
|
8601
8631
|
};
|
|
8602
8632
|
|
|
8603
|
-
AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (
|
|
8604
|
-
var awsRealTimeUrl = _a.awsRealTimeUrl;
|
|
8633
|
+
AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (awsRealTimeUrl) {
|
|
8605
8634
|
return __awaiter(this, void 0, void 0, function () {
|
|
8606
|
-
return __generator(this, function (
|
|
8607
|
-
switch (
|
|
8635
|
+
return __generator(this, function (_a) {
|
|
8636
|
+
switch (_a.label) {
|
|
8608
8637
|
case 0:
|
|
8609
8638
|
logger.debug("Initializaling retryable Handshake");
|
|
8610
8639
|
return [4
|
|
8611
8640
|
/*yield*/
|
|
8612
|
-
, Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [
|
|
8613
|
-
awsRealTimeUrl: awsRealTimeUrl
|
|
8614
|
-
}], MAX_DELAY_MS)];
|
|
8641
|
+
, Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [awsRealTimeUrl], MAX_DELAY_MS)];
|
|
8615
8642
|
|
|
8616
8643
|
case 1:
|
|
8617
|
-
|
|
8644
|
+
_a.sent();
|
|
8618
8645
|
|
|
8619
8646
|
return [2
|
|
8620
8647
|
/*return*/
|
|
@@ -8624,10 +8651,9 @@ function (_super) {
|
|
|
8624
8651
|
});
|
|
8625
8652
|
};
|
|
8626
8653
|
|
|
8627
|
-
AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (
|
|
8628
|
-
var awsRealTimeUrl = _a.awsRealTimeUrl;
|
|
8654
|
+
AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (awsRealTimeUrl) {
|
|
8629
8655
|
return __awaiter(this, void 0, void 0, function () {
|
|
8630
|
-
var err_4, errorType, errorCode;
|
|
8656
|
+
var err_4, _a, errorType, errorCode;
|
|
8631
8657
|
|
|
8632
8658
|
var _this = this;
|
|
8633
8659
|
|
|
@@ -8669,77 +8695,82 @@ function (_super) {
|
|
|
8669
8695
|
/*yield*/
|
|
8670
8696
|
, function () {
|
|
8671
8697
|
return new Promise(function (res, rej) {
|
|
8672
|
-
|
|
8698
|
+
if (_this.awsRealTimeSocket) {
|
|
8699
|
+
var ackOk_1 = false;
|
|
8673
8700
|
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8701
|
+
_this.awsRealTimeSocket.onerror = function (error) {
|
|
8702
|
+
logger.debug("WebSocket error " + JSON.stringify(error));
|
|
8703
|
+
};
|
|
8677
8704
|
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8705
|
+
_this.awsRealTimeSocket.onclose = function (event) {
|
|
8706
|
+
logger.debug("WebSocket closed " + event.reason);
|
|
8707
|
+
rej(new Error(JSON.stringify(event)));
|
|
8708
|
+
};
|
|
8682
8709
|
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8710
|
+
_this.awsRealTimeSocket.onmessage = function (message) {
|
|
8711
|
+
logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
|
|
8712
|
+
var data = JSON.parse(message.data);
|
|
8713
|
+
var type = data.type,
|
|
8714
|
+
_a = data.payload,
|
|
8715
|
+
_b = (_a === void 0 ? {} : _a).connectionTimeoutMs,
|
|
8716
|
+
connectionTimeoutMs = _b === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _b;
|
|
8690
8717
|
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
_this.keepAliveTimeout = connectionTimeoutMs;
|
|
8694
|
-
_this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
|
|
8718
|
+
if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
|
|
8719
|
+
ackOk_1 = true;
|
|
8695
8720
|
|
|
8696
|
-
|
|
8697
|
-
|
|
8721
|
+
if (_this.awsRealTimeSocket) {
|
|
8722
|
+
_this.keepAliveTimeout = connectionTimeoutMs;
|
|
8723
|
+
_this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
|
|
8698
8724
|
|
|
8699
|
-
|
|
8700
|
-
|
|
8725
|
+
_this.awsRealTimeSocket.onerror = function (err) {
|
|
8726
|
+
logger.debug(err);
|
|
8701
8727
|
|
|
8702
|
-
|
|
8703
|
-
|
|
8728
|
+
_this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
|
|
8729
|
+
};
|
|
8704
8730
|
|
|
8705
|
-
|
|
8706
|
-
|
|
8731
|
+
_this.awsRealTimeSocket.onclose = function (event) {
|
|
8732
|
+
logger.debug("WebSocket closed " + event.reason);
|
|
8707
8733
|
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8734
|
+
_this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
|
|
8735
|
+
};
|
|
8736
|
+
}
|
|
8711
8737
|
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
_e = __read(_d === void 0 ? [] : _d, 1),
|
|
8716
|
-
_f = _e[0],
|
|
8717
|
-
_g = _f === void 0 ? {} : _f,
|
|
8718
|
-
_h = _g.errorType,
|
|
8719
|
-
errorType = _h === void 0 ? '' : _h,
|
|
8720
|
-
_j = _g.errorCode,
|
|
8721
|
-
errorCode = _j === void 0 ? 0 : _j;
|
|
8722
|
-
|
|
8723
|
-
rej({
|
|
8724
|
-
errorType: errorType,
|
|
8725
|
-
errorCode: errorCode
|
|
8726
|
-
});
|
|
8727
|
-
}
|
|
8728
|
-
};
|
|
8738
|
+
res('Cool, connected to AWS AppSyncRealTime');
|
|
8739
|
+
return;
|
|
8740
|
+
}
|
|
8729
8741
|
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8742
|
+
if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
|
|
8743
|
+
var _c = data.payload,
|
|
8744
|
+
_d = (_c === void 0 ? {} : _c).errors,
|
|
8745
|
+
_e = __read(_d === void 0 ? [] : _d, 1),
|
|
8746
|
+
_f = _e[0],
|
|
8747
|
+
_g = _f === void 0 ? {} : _f,
|
|
8748
|
+
_h = _g.errorType,
|
|
8749
|
+
errorType = _h === void 0 ? '' : _h,
|
|
8750
|
+
_j = _g.errorCode,
|
|
8751
|
+
errorCode = _j === void 0 ? 0 : _j;
|
|
8752
|
+
|
|
8753
|
+
rej({
|
|
8754
|
+
errorType: errorType,
|
|
8755
|
+
errorCode: errorCode
|
|
8756
|
+
});
|
|
8757
|
+
}
|
|
8758
|
+
};
|
|
8759
|
+
|
|
8760
|
+
var gqlInit = {
|
|
8761
|
+
type: MESSAGE_TYPES.GQL_CONNECTION_INIT
|
|
8762
|
+
};
|
|
8733
8763
|
|
|
8734
|
-
|
|
8764
|
+
_this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
|
|
8735
8765
|
|
|
8736
|
-
|
|
8766
|
+
setTimeout(checkAckOk.bind(_this, ackOk_1), CONNECTION_INIT_TIMEOUT);
|
|
8767
|
+
}
|
|
8768
|
+
|
|
8769
|
+
function checkAckOk(ackOk) {
|
|
8737
8770
|
if (!ackOk) {
|
|
8738
8771
|
rej(new Error("Connection timeout: ack from AWSRealTime was not received on " + CONNECTION_INIT_TIMEOUT + " ms"));
|
|
8739
8772
|
}
|
|
8740
8773
|
}
|
|
8741
|
-
|
|
8742
|
-
setTimeout(checkAckOk.bind(_this), CONNECTION_INIT_TIMEOUT);
|
|
8743
8774
|
});
|
|
8744
8775
|
}()];
|
|
8745
8776
|
|
|
@@ -8753,7 +8784,7 @@ function (_super) {
|
|
|
8753
8784
|
|
|
8754
8785
|
case 4:
|
|
8755
8786
|
err_4 = _b.sent();
|
|
8756
|
-
errorType =
|
|
8787
|
+
_a = err_4, errorType = _a.errorType, errorCode = _a.errorCode;
|
|
8757
8788
|
|
|
8758
8789
|
if (NON_RETRYABLE_CODES.includes(errorCode)) {
|
|
8759
8790
|
throw new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["NonRetryableError"](errorType);
|
|
@@ -8796,16 +8827,17 @@ function (_super) {
|
|
|
8796
8827
|
AMAZON_COGNITO_USER_POOLS: this._awsRealTimeCUPHeader.bind(this),
|
|
8797
8828
|
AWS_LAMBDA: this._customAuthHeader
|
|
8798
8829
|
};
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
}
|
|
8830
|
+
if (!(!authenticationType || !headerHandler[authenticationType])) return [3
|
|
8831
|
+
/*break*/
|
|
8832
|
+
, 1];
|
|
8833
|
+
logger.debug("Authentication type " + authenticationType + " not supported");
|
|
8834
|
+
return [2
|
|
8835
|
+
/*return*/
|
|
8836
|
+
, ''];
|
|
8807
8837
|
|
|
8808
|
-
|
|
8838
|
+
case 1:
|
|
8839
|
+
handler = headerHandler[authenticationType];
|
|
8840
|
+
host = url__WEBPACK_IMPORTED_MODULE_2__["parse"](appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
|
|
8809
8841
|
return [4
|
|
8810
8842
|
/*yield*/
|
|
8811
8843
|
, handler({
|
|
@@ -8818,7 +8850,7 @@ function (_super) {
|
|
|
8818
8850
|
additionalHeaders: additionalHeaders
|
|
8819
8851
|
})];
|
|
8820
8852
|
|
|
8821
|
-
case
|
|
8853
|
+
case 2:
|
|
8822
8854
|
result = _b.sent();
|
|
8823
8855
|
return [2
|
|
8824
8856
|
/*return*/
|
|
@@ -8950,10 +8982,14 @@ function (_super) {
|
|
|
8950
8982
|
return [4
|
|
8951
8983
|
/*yield*/
|
|
8952
8984
|
, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Credentials"].get().then(function (credentials) {
|
|
8985
|
+
var _a = credentials,
|
|
8986
|
+
secretAccessKey = _a.secretAccessKey,
|
|
8987
|
+
accessKeyId = _a.accessKeyId,
|
|
8988
|
+
sessionToken = _a.sessionToken;
|
|
8953
8989
|
return {
|
|
8954
|
-
secret_key:
|
|
8955
|
-
access_key:
|
|
8956
|
-
session_token:
|
|
8990
|
+
secret_key: secretAccessKey,
|
|
8991
|
+
access_key: accessKeyId,
|
|
8992
|
+
session_token: sessionToken
|
|
8957
8993
|
};
|
|
8958
8994
|
})];
|
|
8959
8995
|
|
|
@@ -8978,7 +9014,7 @@ function (_super) {
|
|
|
8978
9014
|
var host = _a.host,
|
|
8979
9015
|
additionalHeaders = _a.additionalHeaders;
|
|
8980
9016
|
|
|
8981
|
-
if (!additionalHeaders
|
|
9017
|
+
if (!additionalHeaders || !additionalHeaders['Authorization']) {
|
|
8982
9018
|
throw new Error('No auth token specified');
|
|
8983
9019
|
}
|
|
8984
9020
|
|
|
@@ -9215,8 +9251,12 @@ var AWSIoTProvider =
|
|
|
9215
9251
|
function (_super) {
|
|
9216
9252
|
__extends(AWSIoTProvider, _super);
|
|
9217
9253
|
|
|
9218
|
-
function AWSIoTProvider() {
|
|
9219
|
-
|
|
9254
|
+
function AWSIoTProvider(options) {
|
|
9255
|
+
if (options === void 0) {
|
|
9256
|
+
options = {};
|
|
9257
|
+
}
|
|
9258
|
+
|
|
9259
|
+
return _super.call(this, options) || this;
|
|
9220
9260
|
}
|
|
9221
9261
|
|
|
9222
9262
|
Object.defineProperty(AWSIoTProvider.prototype, "region", {
|
|
@@ -9546,21 +9586,27 @@ function () {
|
|
|
9546
9586
|
|
|
9547
9587
|
ClientsQueue.prototype.get = function (clientId, clientFactory) {
|
|
9548
9588
|
return __awaiter(this, void 0, void 0, function () {
|
|
9549
|
-
var
|
|
9589
|
+
var cachedPromise, newPromise;
|
|
9550
9590
|
return __generator(this, function (_a) {
|
|
9551
|
-
|
|
9591
|
+
cachedPromise = this.promises.get(clientId);
|
|
9592
|
+
|
|
9593
|
+
if (cachedPromise) {
|
|
9594
|
+
return [2
|
|
9595
|
+
/*return*/
|
|
9596
|
+
, cachedPromise];
|
|
9597
|
+
}
|
|
9552
9598
|
|
|
9553
|
-
if (
|
|
9599
|
+
if (clientFactory) {
|
|
9600
|
+
newPromise = clientFactory(clientId);
|
|
9601
|
+
this.promises.set(clientId, newPromise);
|
|
9554
9602
|
return [2
|
|
9555
9603
|
/*return*/
|
|
9556
|
-
,
|
|
9604
|
+
, newPromise];
|
|
9557
9605
|
}
|
|
9558
9606
|
|
|
9559
|
-
promise = clientFactory(clientId);
|
|
9560
|
-
this.promises.set(clientId, promise);
|
|
9561
9607
|
return [2
|
|
9562
9608
|
/*return*/
|
|
9563
|
-
,
|
|
9609
|
+
, undefined];
|
|
9564
9610
|
});
|
|
9565
9611
|
});
|
|
9566
9612
|
};
|
|
@@ -9652,6 +9698,10 @@ function (_super) {
|
|
|
9652
9698
|
}, args), null, 2));
|
|
9653
9699
|
var topicsToDelete_1 = [];
|
|
9654
9700
|
|
|
9701
|
+
if (!clientId) {
|
|
9702
|
+
return;
|
|
9703
|
+
}
|
|
9704
|
+
|
|
9655
9705
|
var clientIdObservers = this._clientIdObservers.get(clientId);
|
|
9656
9706
|
|
|
9657
9707
|
if (!clientIdObservers) {
|
|
@@ -9770,9 +9820,7 @@ function (_super) {
|
|
|
9770
9820
|
case 0:
|
|
9771
9821
|
return [4
|
|
9772
9822
|
/*yield*/
|
|
9773
|
-
, this.clientsQueue.get(clientId
|
|
9774
|
-
return null;
|
|
9775
|
-
})];
|
|
9823
|
+
, this.clientsQueue.get(clientId)];
|
|
9776
9824
|
|
|
9777
9825
|
case 1:
|
|
9778
9826
|
client = _a.sent();
|
|
@@ -9951,13 +9999,14 @@ function (_super) {
|
|
|
9951
9999
|
})();
|
|
9952
10000
|
|
|
9953
10001
|
return function () {
|
|
10002
|
+
var _a, _b;
|
|
10003
|
+
|
|
9954
10004
|
logger.debug('Unsubscribing from topic(s)', targetTopics.join(','));
|
|
9955
10005
|
|
|
9956
10006
|
if (client) {
|
|
9957
|
-
_this._clientIdObservers.get(clientId)["delete"](observer); // No more observers per client => client not needed anymore
|
|
9958
|
-
|
|
10007
|
+
(_a = _this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
|
|
9959
10008
|
|
|
9960
|
-
if (_this._clientIdObservers.get(clientId).size === 0) {
|
|
10009
|
+
if (((_b = _this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
|
|
9961
10010
|
_this.disconnect(clientId);
|
|
9962
10011
|
|
|
9963
10012
|
_this._clientIdObservers["delete"](clientId);
|
|
@@ -10292,7 +10341,7 @@ function () {
|
|
|
10292
10341
|
* @param {PubSubOptions} options - Configuration object for PubSub
|
|
10293
10342
|
*/
|
|
10294
10343
|
function PubSubClass(options) {
|
|
10295
|
-
this._options = options;
|
|
10344
|
+
this._options = options !== null && options !== void 0 ? options : {};
|
|
10296
10345
|
logger.debug('PubSub Options', this._options);
|
|
10297
10346
|
this._pluggables = [];
|
|
10298
10347
|
this.subscribe = this.subscribe.bind(this);
|
|
@@ -10481,7 +10530,7 @@ function () {
|
|
|
10481
10530
|
}();
|
|
10482
10531
|
|
|
10483
10532
|
|
|
10484
|
-
var PubSub = new PubSubClass(
|
|
10533
|
+
var PubSub = new PubSubClass();
|
|
10485
10534
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
|
|
10486
10535
|
|
|
10487
10536
|
/***/ }),
|