@aws-amplify/pubsub 4.2.10-cloud-logging.7 → 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 +24 -49
- package/dist/aws-amplify-pubsub.js +238 -202
- 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 +174 -154
- 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 +174 -154
- 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 +247 -191
- 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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import Observable from 'zen-observable-ts';
|
|
2
2
|
import { MqttOverWSProvider } from './MqttOverWSProvider';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Unused, all usecases have migrated to AWSAppSyncRealtimeProvider
|
|
5
|
+
*/
|
|
3
6
|
export declare class AWSAppSyncProvider extends MqttOverWSProvider {
|
|
4
7
|
protected get endpoint(): void;
|
|
5
8
|
getProviderName(): string;
|
|
@@ -87,6 +87,9 @@ var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
|
|
|
87
87
|
var core_1 = require("@aws-amplify/core");
|
|
88
88
|
var MqttOverWSProvider_1 = require("./MqttOverWSProvider");
|
|
89
89
|
var logger = new core_1.ConsoleLogger('AWSAppSyncProvider');
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Unused, all usecases have migrated to AWSAppSyncRealtimeProvider
|
|
92
|
+
*/
|
|
90
93
|
var AWSAppSyncProvider = /** @class */ (function (_super) {
|
|
91
94
|
__extends(AWSAppSyncProvider, _super);
|
|
92
95
|
function AWSAppSyncProvider() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AWSAppSyncProvider.js","sourceRoot":"","sources":["../../src/Providers/AWSAppSyncProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,wEAA2C;AAC3C,0CAA4D;AAE5D,2DAA0D;AAE1D,IAAM,MAAM,GAAG,IAAI,oBAAM,CAAC,oBAAoB,CAAC,CAAC;AAEhD;IAAwC,sCAAkB;IAA1D;QAAA,
|
|
1
|
+
{"version":3,"file":"AWSAppSyncProvider.js","sourceRoot":"","sources":["../../src/Providers/AWSAppSyncProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,wEAA2C;AAC3C,0CAA4D;AAE5D,2DAA0D;AAE1D,IAAM,MAAM,GAAG,IAAI,oBAAM,CAAC,oBAAoB,CAAC,CAAC;AAEhD;;GAEG;AACH;IAAwC,sCAAkB;IAA1D;QAAA,qEAoLC;QApIQ,kBAAY,GAAwB,IAAI,GAAG,EAAE,CAAC;QAE9C,iBAAW,GAAwB,IAAI,GAAG,EAAE,CAAC;;IAkItD,CAAC;IAnLA,sBAAc,wCAAQ;aAAtB;YACC,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QAClC,CAAC;;;OAAA;IAED,4CAAe,GAAf;QACC,OAAO,oBAAoB,CAAC;IAC7B,CAAC;IAEY,oCAAO,GAApB,UAAqB,MAAyB,EAAE,GAAQ,EAAE,OAAa;;;gBACtE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;;;KAC3C;IAEO,qCAA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QL_AUTH_MODE } from '@aws-amplify/auth';
|
|
3
4
|
import { AbstractPubSubProvider } from './PubSubProvider';
|
|
5
|
+
declare type GraphqlAuthModes = keyof typeof GRAPHQL_AUTH_MODE;
|
|
6
|
+
export interface AWSAppSyncRealTimeProviderOptions extends ProviderOptions {
|
|
7
|
+
appSyncGraphqlEndpoint?: string;
|
|
8
|
+
authenticationType?: GraphqlAuthModes;
|
|
9
|
+
query?: string;
|
|
10
|
+
variables?: object;
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
region?: string;
|
|
13
|
+
graphql_headers?: () => {} | (() => Promise<{}>);
|
|
14
|
+
additionalHeaders?: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
4
18
|
export declare class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
5
|
-
private awsRealTimeSocket
|
|
19
|
+
private awsRealTimeSocket?;
|
|
6
20
|
private socketStatus;
|
|
7
|
-
private keepAliveTimeoutId
|
|
21
|
+
private keepAliveTimeoutId?;
|
|
8
22
|
private keepAliveTimeout;
|
|
9
23
|
private subscriptionObserverMap;
|
|
10
24
|
private promiseArray;
|
|
@@ -12,7 +26,7 @@ export declare class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
12
26
|
newClient(): Promise<any>;
|
|
13
27
|
publish(_topics: string[] | string, _msg: any, _options?: any): Promise<void>;
|
|
14
28
|
private isCustomDomain;
|
|
15
|
-
subscribe(_topics: string[] | string, options?:
|
|
29
|
+
subscribe(_topics: string[] | string, options?: AWSAppSyncRealTimeProviderOptions): Observable<any>;
|
|
16
30
|
protected get isSSLEnabled(): boolean;
|
|
17
31
|
private _startSubscriptionWithAWSAppSyncRealTime;
|
|
18
32
|
private _waitForSubscriptionToBeConnected;
|
|
@@ -36,3 +50,4 @@ export declare class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
36
50
|
*/
|
|
37
51
|
_ensureCredentials(): any;
|
|
38
52
|
}
|
|
53
|
+
export {};
|
|
@@ -230,9 +230,9 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
230
230
|
};
|
|
231
231
|
AWSAppSyncRealTimeProvider.prototype.subscribe = function (_topics, options) {
|
|
232
232
|
var _this = this;
|
|
233
|
-
var appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint;
|
|
233
|
+
var appSyncGraphqlEndpoint = options === null || options === void 0 ? void 0 : options.appSyncGraphqlEndpoint;
|
|
234
234
|
return new zen_observable_ts_1.default(function (observer) {
|
|
235
|
-
if (!appSyncGraphqlEndpoint) {
|
|
235
|
+
if (!options || !appSyncGraphqlEndpoint) {
|
|
236
236
|
observer.error({
|
|
237
237
|
errors: [
|
|
238
238
|
__assign({}, new graphql_1.GraphQLError("Subscribe only available for AWS AppSync endpoint")),
|
|
@@ -301,14 +301,15 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
301
301
|
});
|
|
302
302
|
AWSAppSyncRealTimeProvider.prototype._startSubscriptionWithAWSAppSyncRealTime = function (_a) {
|
|
303
303
|
var options = _a.options, observer = _a.observer, subscriptionId = _a.subscriptionId;
|
|
304
|
+
var _b, _c;
|
|
304
305
|
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
-
var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region,
|
|
306
|
-
var
|
|
306
|
+
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;
|
|
307
|
+
var _j;
|
|
307
308
|
var _this = this;
|
|
308
|
-
return __generator(this, function (
|
|
309
|
-
switch (
|
|
309
|
+
return __generator(this, function (_k) {
|
|
310
|
+
switch (_k.label) {
|
|
310
311
|
case 0:
|
|
311
|
-
appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region,
|
|
312
|
+
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 () { return ({}); } : _d, _e = options.additionalHeaders, additionalHeaders = _e === void 0 ? {} : _e;
|
|
312
313
|
subscriptionState = SUBSCRIPTION_STATUS.PENDING;
|
|
313
314
|
data = {
|
|
314
315
|
query: query,
|
|
@@ -317,13 +318,13 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
317
318
|
// Having a subscription id map will make it simple to forward messages received
|
|
318
319
|
this.subscriptionObserverMap.set(subscriptionId, {
|
|
319
320
|
observer: observer,
|
|
320
|
-
query: query,
|
|
321
|
-
variables: variables,
|
|
321
|
+
query: query !== null && query !== void 0 ? query : '',
|
|
322
|
+
variables: variables !== null && variables !== void 0 ? variables : {},
|
|
322
323
|
subscriptionState: subscriptionState,
|
|
323
|
-
startAckTimeoutId:
|
|
324
|
+
startAckTimeoutId: undefined,
|
|
324
325
|
});
|
|
325
326
|
dataString = JSON.stringify(data);
|
|
326
|
-
|
|
327
|
+
_f = [{}];
|
|
327
328
|
return [4 /*yield*/, this._awsRealTimeHeaderBasedAuth({
|
|
328
329
|
apiKey: apiKey,
|
|
329
330
|
appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
|
|
@@ -334,10 +335,10 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
334
335
|
additionalHeaders: additionalHeaders,
|
|
335
336
|
})];
|
|
336
337
|
case 1:
|
|
337
|
-
|
|
338
|
+
_g = [__assign.apply(void 0, _f.concat([(_k.sent())]))];
|
|
338
339
|
return [4 /*yield*/, graphql_headers()];
|
|
339
340
|
case 2:
|
|
340
|
-
headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0,
|
|
341
|
+
headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _g.concat([(_k.sent())])), additionalHeaders]), (_j = {}, _j[core_1.USER_AGENT_HEADER] = core_1.Constants.userAgent, _j)]);
|
|
341
342
|
subscriptionMessage = {
|
|
342
343
|
id: subscriptionId,
|
|
343
344
|
payload: {
|
|
@@ -349,9 +350,9 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
349
350
|
type: MESSAGE_TYPES.GQL_START,
|
|
350
351
|
};
|
|
351
352
|
stringToAWSRealTime = JSON.stringify(subscriptionMessage);
|
|
352
|
-
|
|
353
|
+
_k.label = 3;
|
|
353
354
|
case 3:
|
|
354
|
-
|
|
355
|
+
_k.trys.push([3, 5, , 6]);
|
|
355
356
|
return [4 /*yield*/, this._initializeWebSocketConnection({
|
|
356
357
|
apiKey: apiKey,
|
|
357
358
|
appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
|
|
@@ -360,12 +361,12 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
360
361
|
additionalHeaders: additionalHeaders,
|
|
361
362
|
})];
|
|
362
363
|
case 4:
|
|
363
|
-
|
|
364
|
+
_k.sent();
|
|
364
365
|
return [3 /*break*/, 6];
|
|
365
366
|
case 5:
|
|
366
|
-
err_2 =
|
|
367
|
+
err_2 = _k.sent();
|
|
367
368
|
logger.debug({ err: err_2 });
|
|
368
|
-
|
|
369
|
+
message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
|
|
369
370
|
observer.error({
|
|
370
371
|
errors: [
|
|
371
372
|
__assign({}, new graphql_1.GraphQLError(index_1.CONTROL_MSG.CONNECTION_FAILED + ": " + message)),
|
|
@@ -379,13 +380,13 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
379
380
|
}
|
|
380
381
|
return [2 /*return*/];
|
|
381
382
|
case 6:
|
|
382
|
-
|
|
383
|
+
_h = (_c = this.subscriptionObserverMap.get(subscriptionId)) !== null && _c !== void 0 ? _c : {}, subscriptionFailedCallback = _h.subscriptionFailedCallback, subscriptionReadyCallback = _h.subscriptionReadyCallback;
|
|
383
384
|
// This must be done before sending the message in order to be listening immediately
|
|
384
385
|
this.subscriptionObserverMap.set(subscriptionId, {
|
|
385
386
|
observer: observer,
|
|
386
387
|
subscriptionState: subscriptionState,
|
|
387
|
-
|
|
388
|
-
|
|
388
|
+
query: query !== null && query !== void 0 ? query : '',
|
|
389
|
+
variables: variables !== null && variables !== void 0 ? variables : {},
|
|
389
390
|
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
390
391
|
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
391
392
|
startAckTimeoutId: setTimeout(function () {
|
|
@@ -403,23 +404,26 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
403
404
|
// Waiting that subscription has been connected before trying to unsubscribe
|
|
404
405
|
AWSAppSyncRealTimeProvider.prototype._waitForSubscriptionToBeConnected = function (subscriptionId) {
|
|
405
406
|
return __awaiter(this, void 0, void 0, function () {
|
|
406
|
-
var subscriptionState;
|
|
407
|
+
var subscriptionObserver, subscriptionState;
|
|
407
408
|
var _this = this;
|
|
408
409
|
return __generator(this, function (_a) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
observer
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
410
|
+
subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
|
|
411
|
+
if (subscriptionObserver) {
|
|
412
|
+
subscriptionState = subscriptionObserver.subscriptionState;
|
|
413
|
+
// This in case unsubscribe is invoked before sending start subscription message
|
|
414
|
+
if (subscriptionState === SUBSCRIPTION_STATUS.PENDING) {
|
|
415
|
+
return [2 /*return*/, new Promise(function (res, rej) {
|
|
416
|
+
var observer = subscriptionObserver.observer, subscriptionState = subscriptionObserver.subscriptionState, variables = subscriptionObserver.variables, query = subscriptionObserver.query;
|
|
417
|
+
_this.subscriptionObserverMap.set(subscriptionId, {
|
|
418
|
+
observer: observer,
|
|
419
|
+
subscriptionState: subscriptionState,
|
|
420
|
+
variables: variables,
|
|
421
|
+
query: query,
|
|
422
|
+
subscriptionReadyCallback: res,
|
|
423
|
+
subscriptionFailedCallback: rej,
|
|
424
|
+
});
|
|
425
|
+
})];
|
|
426
|
+
}
|
|
423
427
|
}
|
|
424
428
|
return [2 /*return*/];
|
|
425
429
|
});
|
|
@@ -464,13 +468,14 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
464
468
|
}
|
|
465
469
|
else {
|
|
466
470
|
logger.debug('closing WebSocket...');
|
|
467
|
-
|
|
471
|
+
if (this.keepAliveTimeoutId)
|
|
472
|
+
clearTimeout(this.keepAliveTimeoutId);
|
|
468
473
|
var tempSocket = this.awsRealTimeSocket;
|
|
469
474
|
// Cleaning callbacks to avoid race condition, socket still exists
|
|
470
|
-
tempSocket.onclose =
|
|
471
|
-
tempSocket.onerror =
|
|
475
|
+
tempSocket.onclose = null;
|
|
476
|
+
tempSocket.onerror = null;
|
|
472
477
|
tempSocket.close(1000);
|
|
473
|
-
this.awsRealTimeSocket =
|
|
478
|
+
this.awsRealTimeSocket = undefined;
|
|
474
479
|
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
475
480
|
}
|
|
476
481
|
};
|
|
@@ -503,46 +508,53 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
503
508
|
if (typeof subscriptionReadyCallback === 'function') {
|
|
504
509
|
subscriptionReadyCallback();
|
|
505
510
|
}
|
|
506
|
-
|
|
511
|
+
if (startAckTimeoutId)
|
|
512
|
+
clearTimeout(startAckTimeoutId);
|
|
507
513
|
dispatchApiEvent(index_1.CONTROL_MSG.SUBSCRIPTION_ACK, { query: query, variables: variables }, 'Connection established for subscription');
|
|
508
514
|
var subscriptionState = SUBSCRIPTION_STATUS.CONNECTED;
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
515
|
+
if (observer) {
|
|
516
|
+
this.subscriptionObserverMap.set(id, {
|
|
517
|
+
observer: observer,
|
|
518
|
+
query: query,
|
|
519
|
+
variables: variables,
|
|
520
|
+
startAckTimeoutId: undefined,
|
|
521
|
+
subscriptionState: subscriptionState,
|
|
522
|
+
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
523
|
+
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
518
526
|
// TODO: emit event on hub but it requires to store the id first
|
|
519
527
|
return;
|
|
520
528
|
}
|
|
521
529
|
if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {
|
|
522
|
-
|
|
530
|
+
if (this.keepAliveTimeoutId)
|
|
531
|
+
clearTimeout(this.keepAliveTimeoutId);
|
|
523
532
|
this.keepAliveTimeoutId = setTimeout(this._errorDisconnect.bind(this, index_1.CONTROL_MSG.TIMEOUT_DISCONNECT), this.keepAliveTimeout);
|
|
524
533
|
return;
|
|
525
534
|
}
|
|
526
535
|
if (type === MESSAGE_TYPES.GQL_ERROR) {
|
|
527
536
|
var subscriptionState = SUBSCRIPTION_STATUS.FAILED;
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
537
|
+
if (observer) {
|
|
538
|
+
this.subscriptionObserverMap.set(id, {
|
|
539
|
+
observer: observer,
|
|
540
|
+
query: query,
|
|
541
|
+
variables: variables,
|
|
542
|
+
startAckTimeoutId: startAckTimeoutId,
|
|
543
|
+
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
544
|
+
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
545
|
+
subscriptionState: subscriptionState,
|
|
546
|
+
});
|
|
547
|
+
observer.error({
|
|
548
|
+
errors: [
|
|
549
|
+
__assign({}, new graphql_1.GraphQLError(index_1.CONTROL_MSG.CONNECTION_FAILED + ": " + JSON.stringify(payload))),
|
|
550
|
+
],
|
|
551
|
+
});
|
|
552
|
+
if (startAckTimeoutId)
|
|
553
|
+
clearTimeout(startAckTimeoutId);
|
|
554
|
+
observer.complete();
|
|
555
|
+
if (typeof subscriptionFailedCallback === 'function') {
|
|
556
|
+
subscriptionFailedCallback();
|
|
557
|
+
}
|
|
546
558
|
}
|
|
547
559
|
}
|
|
548
560
|
};
|
|
@@ -563,29 +575,32 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
563
575
|
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
564
576
|
};
|
|
565
577
|
AWSAppSyncRealTimeProvider.prototype._timeoutStartSubscriptionAck = function (subscriptionId) {
|
|
566
|
-
var
|
|
567
|
-
if (
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
observer.error({
|
|
578
|
-
errors: [
|
|
579
|
-
__assign({}, new graphql_1.GraphQLError("Subscription timeout " + JSON.stringify({
|
|
580
|
-
query: query,
|
|
581
|
-
variables: variables,
|
|
582
|
-
}))),
|
|
583
|
-
],
|
|
578
|
+
var subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
|
|
579
|
+
if (subscriptionObserver) {
|
|
580
|
+
var observer = subscriptionObserver.observer, query = subscriptionObserver.query, variables = subscriptionObserver.variables;
|
|
581
|
+
if (!observer) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
this.subscriptionObserverMap.set(subscriptionId, {
|
|
585
|
+
observer: observer,
|
|
586
|
+
query: query,
|
|
587
|
+
variables: variables,
|
|
588
|
+
subscriptionState: SUBSCRIPTION_STATUS.FAILED,
|
|
584
589
|
});
|
|
585
|
-
|
|
586
|
-
|
|
590
|
+
if (observer && !observer.closed) {
|
|
591
|
+
observer.error({
|
|
592
|
+
errors: [
|
|
593
|
+
__assign({}, new graphql_1.GraphQLError("Subscription timeout " + JSON.stringify({
|
|
594
|
+
query: query,
|
|
595
|
+
variables: variables,
|
|
596
|
+
}))),
|
|
597
|
+
],
|
|
598
|
+
});
|
|
599
|
+
// Cleanup will be automatically executed
|
|
600
|
+
observer.complete();
|
|
601
|
+
}
|
|
602
|
+
logger.debug('timeoutStartSubscription', JSON.stringify({ query: query, variables: variables }));
|
|
587
603
|
}
|
|
588
|
-
logger.debug('timeoutStartSubscription', JSON.stringify({ query: query, variables: variables }));
|
|
589
604
|
};
|
|
590
605
|
AWSAppSyncRealTimeProvider.prototype._initializeWebSocketConnection = function (_a) {
|
|
591
606
|
var _this = this;
|
|
@@ -619,7 +634,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
619
634
|
headerString = _b.apply(_a, [_c.sent()]);
|
|
620
635
|
headerQs = buffer_1.Buffer.from(headerString).toString('base64');
|
|
621
636
|
payloadQs = buffer_1.Buffer.from(payloadString).toString('base64');
|
|
622
|
-
discoverableEndpoint = appSyncGraphqlEndpoint;
|
|
637
|
+
discoverableEndpoint = appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '';
|
|
623
638
|
if (this.isCustomDomain(discoverableEndpoint)) {
|
|
624
639
|
discoverableEndpoint =
|
|
625
640
|
discoverableEndpoint.concat(customDomainPath);
|
|
@@ -634,7 +649,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
634
649
|
.replace('https://', protocol)
|
|
635
650
|
.replace('http://', protocol);
|
|
636
651
|
awsRealTimeUrl = discoverableEndpoint + "?header=" + headerQs + "&payload=" + payloadQs;
|
|
637
|
-
return [4 /*yield*/, this._initializeRetryableHandshake(
|
|
652
|
+
return [4 /*yield*/, this._initializeRetryableHandshake(awsRealTimeUrl)];
|
|
638
653
|
case 3:
|
|
639
654
|
_c.sent();
|
|
640
655
|
this.promiseArray.forEach(function (_a) {
|
|
@@ -656,7 +671,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
656
671
|
this.awsRealTimeSocket.readyState === WebSocket.OPEN) {
|
|
657
672
|
this.awsRealTimeSocket.close(3001);
|
|
658
673
|
}
|
|
659
|
-
this.awsRealTimeSocket =
|
|
674
|
+
this.awsRealTimeSocket = undefined;
|
|
660
675
|
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
661
676
|
return [3 /*break*/, 5];
|
|
662
677
|
case 5: return [2 /*return*/];
|
|
@@ -664,25 +679,23 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
664
679
|
});
|
|
665
680
|
}); });
|
|
666
681
|
};
|
|
667
|
-
AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (
|
|
668
|
-
var awsRealTimeUrl = _a.awsRealTimeUrl;
|
|
682
|
+
AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (awsRealTimeUrl) {
|
|
669
683
|
return __awaiter(this, void 0, void 0, function () {
|
|
670
|
-
return __generator(this, function (
|
|
671
|
-
switch (
|
|
684
|
+
return __generator(this, function (_a) {
|
|
685
|
+
switch (_a.label) {
|
|
672
686
|
case 0:
|
|
673
687
|
logger.debug("Initializaling retryable Handshake");
|
|
674
|
-
return [4 /*yield*/, core_1.jitteredExponentialRetry(this._initializeHandshake.bind(this), [
|
|
688
|
+
return [4 /*yield*/, core_1.jitteredExponentialRetry(this._initializeHandshake.bind(this), [awsRealTimeUrl], MAX_DELAY_MS)];
|
|
675
689
|
case 1:
|
|
676
|
-
|
|
690
|
+
_a.sent();
|
|
677
691
|
return [2 /*return*/];
|
|
678
692
|
}
|
|
679
693
|
});
|
|
680
694
|
});
|
|
681
695
|
};
|
|
682
|
-
AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (
|
|
683
|
-
var awsRealTimeUrl = _a.awsRealTimeUrl;
|
|
696
|
+
AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (awsRealTimeUrl) {
|
|
684
697
|
return __awaiter(this, void 0, void 0, function () {
|
|
685
|
-
var err_4, errorType, errorCode;
|
|
698
|
+
var err_4, _a, errorType, errorCode;
|
|
686
699
|
var _this = this;
|
|
687
700
|
return __generator(this, function (_b) {
|
|
688
701
|
switch (_b.label) {
|
|
@@ -711,49 +724,53 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
711
724
|
// Step 2: wait for ack from AWS AppSyncReaTime after sending init
|
|
712
725
|
return [4 /*yield*/, (function () {
|
|
713
726
|
return new Promise(function (res, rej) {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
727
|
+
if (_this.awsRealTimeSocket) {
|
|
728
|
+
var ackOk_1 = false;
|
|
729
|
+
_this.awsRealTimeSocket.onerror = function (error) {
|
|
730
|
+
logger.debug("WebSocket error " + JSON.stringify(error));
|
|
731
|
+
};
|
|
732
|
+
_this.awsRealTimeSocket.onclose = function (event) {
|
|
733
|
+
logger.debug("WebSocket closed " + event.reason);
|
|
734
|
+
rej(new Error(JSON.stringify(event)));
|
|
735
|
+
};
|
|
736
|
+
_this.awsRealTimeSocket.onmessage = function (message) {
|
|
737
|
+
logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
|
|
738
|
+
var data = JSON.parse(message.data);
|
|
739
|
+
var type = data.type, _a = data.payload, _b = (_a === void 0 ? {} : _a).connectionTimeoutMs, connectionTimeoutMs = _b === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _b;
|
|
740
|
+
if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
|
|
741
|
+
ackOk_1 = true;
|
|
742
|
+
if (_this.awsRealTimeSocket) {
|
|
743
|
+
_this.keepAliveTimeout = connectionTimeoutMs;
|
|
744
|
+
_this.awsRealTimeSocket.onmessage =
|
|
745
|
+
_this._handleIncomingSubscriptionMessage.bind(_this);
|
|
746
|
+
_this.awsRealTimeSocket.onerror = function (err) {
|
|
747
|
+
logger.debug(err);
|
|
748
|
+
_this._errorDisconnect(index_1.CONTROL_MSG.CONNECTION_CLOSED);
|
|
749
|
+
};
|
|
750
|
+
_this.awsRealTimeSocket.onclose = function (event) {
|
|
751
|
+
logger.debug("WebSocket closed " + event.reason);
|
|
752
|
+
_this._errorDisconnect(index_1.CONTROL_MSG.CONNECTION_CLOSED);
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
res('Cool, connected to AWS AppSyncRealTime');
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
|
|
759
|
+
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;
|
|
760
|
+
rej({ errorType: errorType, errorCode: errorCode });
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
var gqlInit = {
|
|
764
|
+
type: MESSAGE_TYPES.GQL_CONNECTION_INIT,
|
|
765
|
+
};
|
|
766
|
+
_this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
|
|
767
|
+
setTimeout(checkAckOk.bind(_this, ackOk_1), CONNECTION_INIT_TIMEOUT);
|
|
768
|
+
}
|
|
769
|
+
function checkAckOk(ackOk) {
|
|
752
770
|
if (!ackOk) {
|
|
753
771
|
rej(new Error("Connection timeout: ack from AWSRealTime was not received on " + CONNECTION_INIT_TIMEOUT + " ms"));
|
|
754
772
|
}
|
|
755
773
|
}
|
|
756
|
-
setTimeout(checkAckOk.bind(_this), CONNECTION_INIT_TIMEOUT);
|
|
757
774
|
});
|
|
758
775
|
})()];
|
|
759
776
|
case 3:
|
|
@@ -762,7 +779,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
762
779
|
return [3 /*break*/, 5];
|
|
763
780
|
case 4:
|
|
764
781
|
err_4 = _b.sent();
|
|
765
|
-
errorType =
|
|
782
|
+
_a = err_4, errorType = _a.errorType, errorCode = _a.errorCode;
|
|
766
783
|
if (NON_RETRYABLE_CODES.includes(errorCode)) {
|
|
767
784
|
throw new core_1.NonRetryableError(errorType);
|
|
768
785
|
}
|
|
@@ -792,12 +809,12 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
792
809
|
AMAZON_COGNITO_USER_POOLS: this._awsRealTimeCUPHeader.bind(this),
|
|
793
810
|
AWS_LAMBDA: this._customAuthHeader,
|
|
794
811
|
};
|
|
812
|
+
if (!(!authenticationType || !headerHandler[authenticationType])) return [3 /*break*/, 1];
|
|
813
|
+
logger.debug("Authentication type " + authenticationType + " not supported");
|
|
814
|
+
return [2 /*return*/, ''];
|
|
815
|
+
case 1:
|
|
795
816
|
handler = headerHandler[authenticationType];
|
|
796
|
-
|
|
797
|
-
logger.debug("Authentication type " + authenticationType + " not supported");
|
|
798
|
-
return [2 /*return*/, ''];
|
|
799
|
-
}
|
|
800
|
-
host = url.parse(appSyncGraphqlEndpoint).host;
|
|
817
|
+
host = url.parse(appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
|
|
801
818
|
return [4 /*yield*/, handler({
|
|
802
819
|
payload: payload,
|
|
803
820
|
canonicalUri: canonicalUri,
|
|
@@ -807,7 +824,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
807
824
|
host: host,
|
|
808
825
|
additionalHeaders: additionalHeaders,
|
|
809
826
|
})];
|
|
810
|
-
case
|
|
827
|
+
case 2:
|
|
811
828
|
result = _b.sent();
|
|
812
829
|
return [2 /*return*/, result];
|
|
813
830
|
}
|
|
@@ -894,11 +911,14 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
894
911
|
if (!credentialsOK) {
|
|
895
912
|
throw new Error('No credentials');
|
|
896
913
|
}
|
|
897
|
-
return [4 /*yield*/, core_1.Credentials.get().then(function (credentials) {
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
914
|
+
return [4 /*yield*/, core_1.Credentials.get().then(function (credentials) {
|
|
915
|
+
var _a = credentials, secretAccessKey = _a.secretAccessKey, accessKeyId = _a.accessKeyId, sessionToken = _a.sessionToken;
|
|
916
|
+
return {
|
|
917
|
+
secret_key: secretAccessKey,
|
|
918
|
+
access_key: accessKeyId,
|
|
919
|
+
session_token: sessionToken,
|
|
920
|
+
};
|
|
921
|
+
})];
|
|
902
922
|
case 2:
|
|
903
923
|
creds = _b.sent();
|
|
904
924
|
request = {
|
|
@@ -915,7 +935,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function (_super) {
|
|
|
915
935
|
};
|
|
916
936
|
AWSAppSyncRealTimeProvider.prototype._customAuthHeader = function (_a) {
|
|
917
937
|
var host = _a.host, additionalHeaders = _a.additionalHeaders;
|
|
918
|
-
if (!additionalHeaders
|
|
938
|
+
if (!additionalHeaders || !additionalHeaders['Authorization']) {
|
|
919
939
|
throw new Error('No auth token specified');
|
|
920
940
|
}
|
|
921
941
|
return {
|