aws-appsync-subscription-link 4.0.1 → 4.0.3
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 +19 -0
- package/lib/index.js +95 -59
- package/lib/index.mjs +91 -55
- package/package.json +5 -2
- package/__tests__/link/realtime-subscription-handshake-link-test.ts +0 -709
- package/jest.config.js +0 -23
- package/tsup.config.ts +0 -21
- /package/lib/vendor/{vendor/paho-mqtt.js → paho-mqtt.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
<a name="4.0.3"></a>
|
|
7
|
+
## [4.0.3](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@4.0.2...aws-appsync-subscription-link@4.0.3) (2026-03-30)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package aws-appsync-subscription-link
|
|
13
|
+
|
|
14
|
+
<a name="4.0.2"></a>
|
|
15
|
+
## [4.0.2](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@4.0.1...aws-appsync-subscription-link@4.0.2) (2026-03-19)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **subscription-link:** move auth credentials from URL query string to Sec-WebSocket-Protocol header ([fb5dd3e](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/fb5dd3e))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
<a name="4.1.0"></a>
|
|
7
26
|
# [4.1.0] (Unreleased)
|
|
8
27
|
|
package/lib/index.js
CHANGED
|
@@ -118,6 +118,7 @@ function _inherits(subClass, superClass) {
|
|
|
118
118
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
119
119
|
}
|
|
120
120
|
function _instanceof(left, right) {
|
|
121
|
+
"@swc/helpers - instanceof";
|
|
121
122
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
122
123
|
return !!right[Symbol.hasInstance](left);
|
|
123
124
|
} else {
|
|
@@ -201,12 +202,22 @@ function _object_spread_props(target, source) {
|
|
|
201
202
|
}
|
|
202
203
|
function _object_without_properties(source, excluded) {
|
|
203
204
|
if (source == null) return {};
|
|
204
|
-
var target =
|
|
205
|
-
|
|
205
|
+
var target = {}, sourceKeys, key, i;
|
|
206
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
207
|
+
sourceKeys = Reflect.ownKeys(Object(source));
|
|
208
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
209
|
+
key = sourceKeys[i];
|
|
210
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
211
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
212
|
+
target[key] = source[key];
|
|
213
|
+
}
|
|
214
|
+
return target;
|
|
215
|
+
}
|
|
216
|
+
target = _object_without_properties_loose(source, excluded);
|
|
206
217
|
if (Object.getOwnPropertySymbols) {
|
|
207
|
-
|
|
208
|
-
for(i = 0; i <
|
|
209
|
-
key =
|
|
218
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
219
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
220
|
+
key = sourceKeys[i];
|
|
210
221
|
if (excluded.indexOf(key) >= 0) continue;
|
|
211
222
|
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
212
223
|
target[key] = source[key];
|
|
@@ -216,12 +227,11 @@ function _object_without_properties(source, excluded) {
|
|
|
216
227
|
}
|
|
217
228
|
function _object_without_properties_loose(source, excluded) {
|
|
218
229
|
if (source == null) return {};
|
|
219
|
-
var target = {};
|
|
220
|
-
var sourceKeys = Object.keys(source);
|
|
221
|
-
var key, i;
|
|
230
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
222
231
|
for(i = 0; i < sourceKeys.length; i++){
|
|
223
232
|
key = sourceKeys[i];
|
|
224
233
|
if (excluded.indexOf(key) >= 0) continue;
|
|
234
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
225
235
|
target[key] = source[key];
|
|
226
236
|
}
|
|
227
237
|
return target;
|
|
@@ -314,9 +324,17 @@ function _ts_generator(thisArg, body) {
|
|
|
314
324
|
},
|
|
315
325
|
trys: [],
|
|
316
326
|
ops: []
|
|
317
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
318
|
-
return
|
|
319
|
-
|
|
327
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
328
|
+
return d(g, "next", {
|
|
329
|
+
value: verb(0)
|
|
330
|
+
}), d(g, "throw", {
|
|
331
|
+
value: verb(1)
|
|
332
|
+
}), d(g, "return", {
|
|
333
|
+
value: verb(2)
|
|
334
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
335
|
+
value: function() {
|
|
336
|
+
return this;
|
|
337
|
+
}
|
|
320
338
|
}), g;
|
|
321
339
|
function verb(n) {
|
|
322
340
|
return function(v) {
|
|
@@ -402,27 +420,27 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
402
420
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
403
421
|
var __getProtoOf = Object.getPrototypeOf;
|
|
404
422
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
405
|
-
var __commonJS = function(cb, mod) {
|
|
423
|
+
var __commonJS = function __commonJS(cb, mod) {
|
|
406
424
|
return function __require() {
|
|
407
425
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
|
|
408
426
|
exports: {}
|
|
409
427
|
}).exports, mod), mod.exports;
|
|
410
428
|
};
|
|
411
429
|
};
|
|
412
|
-
var __export = function(target, all) {
|
|
430
|
+
var __export = function __export(target, all) {
|
|
413
431
|
for(var name in all)__defProp(target, name, {
|
|
414
432
|
get: all[name],
|
|
415
433
|
enumerable: true
|
|
416
434
|
});
|
|
417
435
|
};
|
|
418
|
-
var __copyProps = function(to, from, except, desc) {
|
|
436
|
+
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
419
437
|
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
420
438
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
421
439
|
try {
|
|
422
440
|
var _loop = function() {
|
|
423
441
|
var key = _step.value;
|
|
424
442
|
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
425
|
-
get: function() {
|
|
443
|
+
get: function get() {
|
|
426
444
|
return from[key];
|
|
427
445
|
},
|
|
428
446
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
@@ -446,7 +464,7 @@ var __copyProps = function(to, from, except, desc) {
|
|
|
446
464
|
}
|
|
447
465
|
return to;
|
|
448
466
|
};
|
|
449
|
-
var __toESM = function(mod, isNodeMode, target) {
|
|
467
|
+
var __toESM = function __toESM(mod, isNodeMode, target) {
|
|
450
468
|
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
451
469
|
// file that has been converted to a CommonJS file using a Babel-
|
|
452
470
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
@@ -456,7 +474,7 @@ var __toESM = function(mod, isNodeMode, target) {
|
|
|
456
474
|
enumerable: true
|
|
457
475
|
}) : target, mod);
|
|
458
476
|
};
|
|
459
|
-
var __toCommonJS = function(mod) {
|
|
477
|
+
var __toCommonJS = function __toCommonJS(mod) {
|
|
460
478
|
return __copyProps(__defProp({}, "__esModule", {
|
|
461
479
|
value: true
|
|
462
480
|
}), mod);
|
|
@@ -2209,10 +2227,10 @@ var require_paho_mqtt = __commonJS({
|
|
|
2209
2227
|
// src/index.ts
|
|
2210
2228
|
var index_exports = {};
|
|
2211
2229
|
__export(index_exports, {
|
|
2212
|
-
CONTROL_EVENTS_KEY: function() {
|
|
2230
|
+
CONTROL_EVENTS_KEY: function CONTROL_EVENTS_KEY1() {
|
|
2213
2231
|
return CONTROL_EVENTS_KEY;
|
|
2214
2232
|
},
|
|
2215
|
-
createSubscriptionHandshakeLink: function() {
|
|
2233
|
+
createSubscriptionHandshakeLink: function createSubscriptionHandshakeLink1() {
|
|
2216
2234
|
return createSubscriptionHandshakeLink;
|
|
2217
2235
|
}
|
|
2218
2236
|
});
|
|
@@ -2320,8 +2338,8 @@ var SubscriptionHandshakeLink = /*#__PURE__*/ function(_import_core_ApolloLink)
|
|
|
2320
2338
|
return c.topics.some(function(t) {
|
|
2321
2339
|
return newTopics.has(t);
|
|
2322
2340
|
});
|
|
2323
|
-
}).map(function(
|
|
2324
|
-
var topics =
|
|
2341
|
+
}).map(function(_0) {
|
|
2342
|
+
var topics = _0.topics, rest = _object_without_properties(_0, [
|
|
2325
2343
|
"topics"
|
|
2326
2344
|
]);
|
|
2327
2345
|
return _object_spread_props(_object_spread({}, rest), {
|
|
@@ -2414,8 +2432,8 @@ var SubscriptionHandshakeLink = /*#__PURE__*/ function(_import_core_ApolloLink)
|
|
|
2414
2432
|
clientId = connectionInfo.client, url2 = connectionInfo.url, topics = connectionInfo.topics;
|
|
2415
2433
|
client = new Paho.Client(url2, clientId);
|
|
2416
2434
|
client.trace = mqttLogger.bind(null, clientId);
|
|
2417
|
-
client.onConnectionLost = function(
|
|
2418
|
-
var errorCode =
|
|
2435
|
+
client.onConnectionLost = function(_0) {
|
|
2436
|
+
var errorCode = _0.errorCode, args = _object_without_properties(_0, [
|
|
2419
2437
|
"errorCode"
|
|
2420
2438
|
]);
|
|
2421
2439
|
if (errorCode !== 0) {
|
|
@@ -2443,7 +2461,7 @@ var SubscriptionHandshakeLink = /*#__PURE__*/ function(_import_core_ApolloLink)
|
|
|
2443
2461
|
client.connect({
|
|
2444
2462
|
useSSL: url2.indexOf("wss://") === 0,
|
|
2445
2463
|
mqttVersion: 3,
|
|
2446
|
-
onSuccess: function() {
|
|
2464
|
+
onSuccess: function onSuccess() {
|
|
2447
2465
|
return resolve(client);
|
|
2448
2466
|
},
|
|
2449
2467
|
onFailure: reject
|
|
@@ -2482,7 +2500,7 @@ var SubscriptionHandshakeLink = /*#__PURE__*/ function(_import_core_ApolloLink)
|
|
|
2482
2500
|
var _this = this;
|
|
2483
2501
|
return new Promise(function(resolve, reject) {
|
|
2484
2502
|
client.subscribe(topic, {
|
|
2485
|
-
onSuccess: function() {
|
|
2503
|
+
onSuccess: function onSuccess() {
|
|
2486
2504
|
if (!_this.topicObservers.has(topic)) {
|
|
2487
2505
|
_this.topicObservers.set(topic, /* @__PURE__ */ new Set());
|
|
2488
2506
|
}
|
|
@@ -2583,7 +2601,7 @@ var NonRetryableError = /*#__PURE__*/ function(Error1) {
|
|
|
2583
2601
|
}
|
|
2584
2602
|
return NonRetryableError;
|
|
2585
2603
|
}(_wrap_native_super(Error));
|
|
2586
|
-
var isNonRetryableError = function(obj) {
|
|
2604
|
+
var isNonRetryableError = function isNonRetryableError(obj) {
|
|
2587
2605
|
var key = "nonRetryable";
|
|
2588
2606
|
return obj && obj[key];
|
|
2589
2607
|
};
|
|
@@ -2594,7 +2612,7 @@ function retry(functionToRetry, args, delayFn) {
|
|
|
2594
2612
|
return _ts_generator(this, function(_state) {
|
|
2595
2613
|
switch(_state.label){
|
|
2596
2614
|
case 0:
|
|
2597
|
-
logger2("Attempt #".concat(attempt
|
|
2615
|
+
logger2("Attempt #".concat(attempt));
|
|
2598
2616
|
_state.label = 1;
|
|
2599
2617
|
case 1:
|
|
2600
2618
|
_state.trys.push([
|
|
@@ -2666,7 +2684,7 @@ function jitteredBackoff(maxDelayMs) {
|
|
|
2666
2684
|
return delay > maxDelayMs ? false : delay;
|
|
2667
2685
|
};
|
|
2668
2686
|
}
|
|
2669
|
-
var jitteredExponentialRetry = function(functionToRetry, args) {
|
|
2687
|
+
var jitteredExponentialRetry = function jitteredExponentialRetry(functionToRetry, args) {
|
|
2670
2688
|
var maxDelayMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : MAX_DELAY_MS;
|
|
2671
2689
|
return retry(functionToRetry, args, jitteredBackoff(maxDelayMs));
|
|
2672
2690
|
};
|
|
@@ -2707,6 +2725,12 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
2707
2725
|
_this.auth = theAuth;
|
|
2708
2726
|
_this.proxyUrl = proxy === null || proxy === void 0 ? void 0 : proxy.url;
|
|
2709
2727
|
_this.keepAliveTimeout = keepAliveTimeoutMs;
|
|
2728
|
+
if (_this.url && !_this.url.startsWith("https://")) {
|
|
2729
|
+
logger3("WARNING: AppSync endpoint URL is not using HTTPS. Credentials may be sent unencrypted: ".concat(_this.url));
|
|
2730
|
+
}
|
|
2731
|
+
if (_this.proxyUrl && !_this.proxyUrl.startsWith("https://")) {
|
|
2732
|
+
logger3("WARNING: Proxy URL is not using HTTPS. Credentials may be sent unencrypted: ".concat(_this.proxyUrl));
|
|
2733
|
+
}
|
|
2710
2734
|
if (_this.keepAliveTimeout < SERVER_KEEP_ALIVE_TIMEOUT) {
|
|
2711
2735
|
var configName = "keepAliveTimeoutMs";
|
|
2712
2736
|
throw new Error("".concat(configName, " must be greater than or equal to ").concat(SERVER_KEEP_ALIVE_TIMEOUT, " (").concat(_this.keepAliveTimeout, " used)."));
|
|
@@ -2744,7 +2768,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
2744
2768
|
authenticationType: _this.auth.type,
|
|
2745
2769
|
query: (0, import_graphql.print)(query),
|
|
2746
2770
|
region: _this.region,
|
|
2747
|
-
graphql_headers: function() {
|
|
2771
|
+
graphql_headers: function graphql_headers() {
|
|
2748
2772
|
return headers;
|
|
2749
2773
|
},
|
|
2750
2774
|
variables: variables,
|
|
@@ -3004,7 +3028,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3004
3028
|
}
|
|
3005
3029
|
return new Promise(function(res, rej) {
|
|
3006
3030
|
return _async_to_generator(function() {
|
|
3007
|
-
var payloadString,
|
|
3031
|
+
var payloadString, headerObj, headerString, headerBase64url, discoverableEndpoint, protocols, err;
|
|
3008
3032
|
return _ts_generator(this, function(_state) {
|
|
3009
3033
|
switch(_state.label){
|
|
3010
3034
|
case 0:
|
|
@@ -3026,7 +3050,6 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3026
3050
|
]);
|
|
3027
3051
|
this.socketStatus = 2 /* CONNECTING */ ;
|
|
3028
3052
|
payloadString = "{}";
|
|
3029
|
-
_ = JSON.stringify;
|
|
3030
3053
|
return [
|
|
3031
3054
|
4,
|
|
3032
3055
|
this._awsRealTimeHeaderBasedAuth({
|
|
@@ -3038,15 +3061,13 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3038
3061
|
region: region,
|
|
3039
3062
|
credentials: credentials,
|
|
3040
3063
|
token: token,
|
|
3041
|
-
graphql_headers: function() {}
|
|
3064
|
+
graphql_headers: function graphql_headers() {}
|
|
3042
3065
|
})
|
|
3043
3066
|
];
|
|
3044
3067
|
case 2:
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
headerQs = Buffer.from(headerString).toString("base64");
|
|
3049
|
-
payloadQs = Buffer.from(payloadString).toString("base64");
|
|
3068
|
+
headerObj = _state.sent();
|
|
3069
|
+
headerString = JSON.stringify(headerObj);
|
|
3070
|
+
headerBase64url = Buffer.from(headerString).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
3050
3071
|
if (this.proxyUrl) {
|
|
3051
3072
|
discoverableEndpoint = this.proxyUrl.replace(/\/graphql$/, "").concat(customDomainPath).replace("https://", "wss://").replace("http://", "ws://");
|
|
3052
3073
|
} else if (this.isCustomDomain(appSyncGraphqlEndpoint)) {
|
|
@@ -3056,11 +3077,15 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3056
3077
|
discoverableEndpoint = appSyncGraphqlEndpoint.replace("appsync-api", "appsync-realtime-api").replace("gogi-beta", "grt-beta");
|
|
3057
3078
|
discoverableEndpoint = discoverableEndpoint.replace("https://", "wss://").replace("http://", "ws://");
|
|
3058
3079
|
}
|
|
3059
|
-
|
|
3080
|
+
protocols = [
|
|
3081
|
+
"graphql-ws",
|
|
3082
|
+
"header-".concat(headerBase64url)
|
|
3083
|
+
];
|
|
3060
3084
|
return [
|
|
3061
3085
|
4,
|
|
3062
3086
|
this._initializeRetryableHandshake({
|
|
3063
|
-
awsRealTimeUrl:
|
|
3087
|
+
awsRealTimeUrl: discoverableEndpoint,
|
|
3088
|
+
protocols: protocols
|
|
3064
3089
|
})
|
|
3065
3090
|
];
|
|
3066
3091
|
case 3:
|
|
@@ -3120,11 +3145,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3120
3145
|
};
|
|
3121
3146
|
handler = headerHandler[authenticationType];
|
|
3122
3147
|
if (typeof handler !== "function") {
|
|
3123
|
-
|
|
3124
|
-
return [
|
|
3125
|
-
2,
|
|
3126
|
-
{}
|
|
3127
|
-
];
|
|
3148
|
+
throw new NonRetryableError("Authentication type ".concat(authenticationType, " not supported"));
|
|
3128
3149
|
}
|
|
3129
3150
|
host = url.parse(this.url).host;
|
|
3130
3151
|
return [
|
|
@@ -3298,17 +3319,18 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3298
3319
|
key: "_initializeRetryableHandshake",
|
|
3299
3320
|
value: function _initializeRetryableHandshake(_0) {
|
|
3300
3321
|
return _async_to_generator(function(param) {
|
|
3301
|
-
var awsRealTimeUrl;
|
|
3322
|
+
var awsRealTimeUrl, protocols;
|
|
3302
3323
|
return _ts_generator(this, function(_state) {
|
|
3303
3324
|
switch(_state.label){
|
|
3304
3325
|
case 0:
|
|
3305
|
-
awsRealTimeUrl = param.awsRealTimeUrl;
|
|
3326
|
+
awsRealTimeUrl = param.awsRealTimeUrl, protocols = param.protocols;
|
|
3306
3327
|
logger3("Initializaling retryable Handshake");
|
|
3307
3328
|
return [
|
|
3308
3329
|
4,
|
|
3309
3330
|
jitteredExponentialRetry(this._initializeHandshake.bind(this), [
|
|
3310
3331
|
{
|
|
3311
|
-
awsRealTimeUrl: awsRealTimeUrl
|
|
3332
|
+
awsRealTimeUrl: awsRealTimeUrl,
|
|
3333
|
+
protocols: protocols
|
|
3312
3334
|
}
|
|
3313
3335
|
])
|
|
3314
3336
|
];
|
|
@@ -3326,12 +3348,12 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3326
3348
|
key: "_initializeHandshake",
|
|
3327
3349
|
value: function _initializeHandshake(_0) {
|
|
3328
3350
|
return _async_to_generator(function(param) {
|
|
3329
|
-
var _this, awsRealTimeUrl, err, errorType, errorCode;
|
|
3351
|
+
var _this, awsRealTimeUrl, protocols, err, errorType, errorCode;
|
|
3330
3352
|
return _ts_generator(this, function(_state) {
|
|
3331
3353
|
switch(_state.label){
|
|
3332
3354
|
case 0:
|
|
3333
3355
|
_this = this;
|
|
3334
|
-
awsRealTimeUrl = param.awsRealTimeUrl;
|
|
3356
|
+
awsRealTimeUrl = param.awsRealTimeUrl, protocols = param.protocols;
|
|
3335
3357
|
logger3("Initializing handshake ".concat(awsRealTimeUrl));
|
|
3336
3358
|
_state.label = 1;
|
|
3337
3359
|
case 1:
|
|
@@ -3345,7 +3367,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3345
3367
|
4,
|
|
3346
3368
|
function() {
|
|
3347
3369
|
return new Promise(function(res, rej) {
|
|
3348
|
-
var newSocket = _AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket(awsRealTimeUrl,
|
|
3370
|
+
var newSocket = _AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket(awsRealTimeUrl, protocols);
|
|
3349
3371
|
newSocket.onerror = function() {
|
|
3350
3372
|
logger3("WebSocket connection error");
|
|
3351
3373
|
};
|
|
@@ -3379,13 +3401,20 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3379
3401
|
rej(new Error(JSON.stringify(event)));
|
|
3380
3402
|
};
|
|
3381
3403
|
_this.awsRealTimeSocket.onmessage = function(message) {
|
|
3382
|
-
|
|
3383
|
-
|
|
3404
|
+
var data;
|
|
3405
|
+
try {
|
|
3406
|
+
data = JSON.parse(message.data);
|
|
3407
|
+
} catch (e) {
|
|
3408
|
+
logger3("Failed to parse WebSocket message");
|
|
3409
|
+
return;
|
|
3410
|
+
}
|
|
3384
3411
|
var type = data.type, tmp = data.payload, _ref = tmp === void 0 ? {} : tmp, _ref_connectionTimeoutMs = _ref.connectionTimeoutMs, connectionTimeoutMs = _ref_connectionTimeoutMs === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _ref_connectionTimeoutMs;
|
|
3412
|
+
logger3("subscription message from AWS AppSyncRealTime: ".concat(type));
|
|
3385
3413
|
if (type === "connection_ack" /* GQL_CONNECTION_ACK */ ) {
|
|
3386
|
-
ackOk = true;
|
|
3387
3414
|
var _this_keepAliveTimeout;
|
|
3388
|
-
|
|
3415
|
+
ackOk = true;
|
|
3416
|
+
var validTimeout = typeof connectionTimeoutMs === "number" && connectionTimeoutMs >= SERVER_KEEP_ALIVE_TIMEOUT ? connectionTimeoutMs : DEFAULT_KEEP_ALIVE_TIMEOUT;
|
|
3417
|
+
_this.keepAliveTimeout = (_this_keepAliveTimeout = _this.keepAliveTimeout) !== null && _this_keepAliveTimeout !== void 0 ? _this_keepAliveTimeout : validTimeout;
|
|
3389
3418
|
_this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
|
|
3390
3419
|
_this.awsRealTimeSocket.onerror = function(err) {
|
|
3391
3420
|
logger3(err);
|
|
@@ -3446,8 +3475,15 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3446
3475
|
{
|
|
3447
3476
|
key: "_handleIncomingSubscriptionMessage",
|
|
3448
3477
|
value: function _handleIncomingSubscriptionMessage(message) {
|
|
3449
|
-
|
|
3450
|
-
|
|
3478
|
+
var parsed;
|
|
3479
|
+
try {
|
|
3480
|
+
parsed = JSON.parse(message.data);
|
|
3481
|
+
} catch (e) {
|
|
3482
|
+
logger3("Failed to parse incoming subscription message");
|
|
3483
|
+
return;
|
|
3484
|
+
}
|
|
3485
|
+
var _parsed_id = parsed.id, id = _parsed_id === void 0 ? "" : _parsed_id, payload = parsed.payload, type = parsed.type;
|
|
3486
|
+
logger3("subscription message from AWS AppSync RealTime: ".concat(type, " id: ").concat(id));
|
|
3451
3487
|
var _ref = this.subscriptionObserverMap.get(id) || {}, _ref_observer = _ref.observer, observer = _ref_observer === void 0 ? null : _ref_observer, _ref_query = _ref.query, query = _ref_query === void 0 ? "" : _ref_query, _ref_variables = _ref.variables, variables = _ref_variables === void 0 ? {} : _ref_variables, _ref_startAckTimeoutId = _ref.startAckTimeoutId, startAckTimeoutId = _ref_startAckTimeoutId === void 0 ? 0 : _ref_startAckTimeoutId, _ref_subscriptionReadyCallback = _ref.subscriptionReadyCallback, subscriptionReadyCallback = _ref_subscriptionReadyCallback === void 0 ? null : _ref_subscriptionReadyCallback, _ref_subscriptionFailedCallback = _ref.subscriptionFailedCallback, subscriptionFailedCallback = _ref_subscriptionFailedCallback === void 0 ? null : _ref_subscriptionFailedCallback;
|
|
3452
3488
|
logger3({
|
|
3453
3489
|
id: id,
|
|
@@ -3598,9 +3634,9 @@ function createSubscriptionHandshakeLink(infoOrUrl, theResultsFetcherLink) {
|
|
|
3598
3634
|
subscriptionLinks = import_core4.ApolloLink.from([
|
|
3599
3635
|
new NonTerminatingLink("controlMessages", _define_property({}, "link", new import_core4.ApolloLink(function(operation, _forward) {
|
|
3600
3636
|
return new import_core4.Observable(function(observer) {
|
|
3601
|
-
var
|
|
3602
|
-
CONTROL_EVENTS_KEY
|
|
3603
|
-
]
|
|
3637
|
+
var _ref = operation.variables, controlEvents = _ref[CONTROL_EVENTS_KEY], variables = _object_without_properties(_ref, [
|
|
3638
|
+
_to_property_key(CONTROL_EVENTS_KEY)
|
|
3639
|
+
]);
|
|
3604
3640
|
if (typeof controlEvents !== "undefined") {
|
|
3605
3641
|
operation.variables = variables;
|
|
3606
3642
|
}
|