aws-appsync-subscription-link 4.0.2 → 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 +8 -0
- package/lib/index.js +51 -33
- package/lib/index.mjs +47 -29
- package/package.json +5 -2
- package/__tests__/link/realtime-subscription-handshake-link-test.ts +0 -770
- 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,14 @@
|
|
|
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
|
+
|
|
6
14
|
<a name="4.0.2"></a>
|
|
7
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)
|
|
8
16
|
|
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
|
};
|
|
@@ -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
|
};
|
|
@@ -2750,7 +2768,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
2750
2768
|
authenticationType: _this.auth.type,
|
|
2751
2769
|
query: (0, import_graphql.print)(query),
|
|
2752
2770
|
region: _this.region,
|
|
2753
|
-
graphql_headers: function() {
|
|
2771
|
+
graphql_headers: function graphql_headers() {
|
|
2754
2772
|
return headers;
|
|
2755
2773
|
},
|
|
2756
2774
|
variables: variables,
|
|
@@ -3043,7 +3061,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3043
3061
|
region: region,
|
|
3044
3062
|
credentials: credentials,
|
|
3045
3063
|
token: token,
|
|
3046
|
-
graphql_headers: function() {}
|
|
3064
|
+
graphql_headers: function graphql_headers() {}
|
|
3047
3065
|
})
|
|
3048
3066
|
];
|
|
3049
3067
|
case 2:
|
|
@@ -3393,9 +3411,9 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(_import_co
|
|
|
3393
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;
|
|
3394
3412
|
logger3("subscription message from AWS AppSyncRealTime: ".concat(type));
|
|
3395
3413
|
if (type === "connection_ack" /* GQL_CONNECTION_ACK */ ) {
|
|
3414
|
+
var _this_keepAliveTimeout;
|
|
3396
3415
|
ackOk = true;
|
|
3397
3416
|
var validTimeout = typeof connectionTimeoutMs === "number" && connectionTimeoutMs >= SERVER_KEEP_ALIVE_TIMEOUT ? connectionTimeoutMs : DEFAULT_KEEP_ALIVE_TIMEOUT;
|
|
3398
|
-
var _this_keepAliveTimeout;
|
|
3399
3417
|
_this.keepAliveTimeout = (_this_keepAliveTimeout = _this.keepAliveTimeout) !== null && _this_keepAliveTimeout !== void 0 ? _this_keepAliveTimeout : validTimeout;
|
|
3400
3418
|
_this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
|
|
3401
3419
|
_this.awsRealTimeSocket.onerror = function(err) {
|
|
@@ -3616,9 +3634,9 @@ function createSubscriptionHandshakeLink(infoOrUrl, theResultsFetcherLink) {
|
|
|
3616
3634
|
subscriptionLinks = import_core4.ApolloLink.from([
|
|
3617
3635
|
new NonTerminatingLink("controlMessages", _define_property({}, "link", new import_core4.ApolloLink(function(operation, _forward) {
|
|
3618
3636
|
return new import_core4.Observable(function(observer) {
|
|
3619
|
-
var
|
|
3620
|
-
CONTROL_EVENTS_KEY
|
|
3621
|
-
]
|
|
3637
|
+
var _ref = operation.variables, controlEvents = _ref[CONTROL_EVENTS_KEY], variables = _object_without_properties(_ref, [
|
|
3638
|
+
_to_property_key(CONTROL_EVENTS_KEY)
|
|
3639
|
+
]);
|
|
3622
3640
|
if (typeof controlEvents !== "undefined") {
|
|
3623
3641
|
operation.variables = variables;
|
|
3624
3642
|
}
|
package/lib/index.mjs
CHANGED
|
@@ -117,6 +117,7 @@ function _inherits(subClass, superClass) {
|
|
|
117
117
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
118
118
|
}
|
|
119
119
|
function _instanceof(left, right) {
|
|
120
|
+
"@swc/helpers - instanceof";
|
|
120
121
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
121
122
|
return !!right[Symbol.hasInstance](left);
|
|
122
123
|
} else {
|
|
@@ -200,12 +201,22 @@ function _object_spread_props(target, source) {
|
|
|
200
201
|
}
|
|
201
202
|
function _object_without_properties(source, excluded) {
|
|
202
203
|
if (source == null) return {};
|
|
203
|
-
var target =
|
|
204
|
-
|
|
204
|
+
var target = {}, sourceKeys, key, i;
|
|
205
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
206
|
+
sourceKeys = Reflect.ownKeys(Object(source));
|
|
207
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
208
|
+
key = sourceKeys[i];
|
|
209
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
210
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
211
|
+
target[key] = source[key];
|
|
212
|
+
}
|
|
213
|
+
return target;
|
|
214
|
+
}
|
|
215
|
+
target = _object_without_properties_loose(source, excluded);
|
|
205
216
|
if (Object.getOwnPropertySymbols) {
|
|
206
|
-
|
|
207
|
-
for(i = 0; i <
|
|
208
|
-
key =
|
|
217
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
218
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
219
|
+
key = sourceKeys[i];
|
|
209
220
|
if (excluded.indexOf(key) >= 0) continue;
|
|
210
221
|
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
211
222
|
target[key] = source[key];
|
|
@@ -215,12 +226,11 @@ function _object_without_properties(source, excluded) {
|
|
|
215
226
|
}
|
|
216
227
|
function _object_without_properties_loose(source, excluded) {
|
|
217
228
|
if (source == null) return {};
|
|
218
|
-
var target = {};
|
|
219
|
-
var sourceKeys = Object.keys(source);
|
|
220
|
-
var key, i;
|
|
229
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
221
230
|
for(i = 0; i < sourceKeys.length; i++){
|
|
222
231
|
key = sourceKeys[i];
|
|
223
232
|
if (excluded.indexOf(key) >= 0) continue;
|
|
233
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
224
234
|
target[key] = source[key];
|
|
225
235
|
}
|
|
226
236
|
return target;
|
|
@@ -313,9 +323,17 @@ function _ts_generator(thisArg, body) {
|
|
|
313
323
|
},
|
|
314
324
|
trys: [],
|
|
315
325
|
ops: []
|
|
316
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
317
|
-
return
|
|
318
|
-
|
|
326
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
327
|
+
return d(g, "next", {
|
|
328
|
+
value: verb(0)
|
|
329
|
+
}), d(g, "throw", {
|
|
330
|
+
value: verb(1)
|
|
331
|
+
}), d(g, "return", {
|
|
332
|
+
value: verb(2)
|
|
333
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
334
|
+
value: function() {
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
319
337
|
}), g;
|
|
320
338
|
function verb(n) {
|
|
321
339
|
return function(v) {
|
|
@@ -401,21 +419,21 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
401
419
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
402
420
|
var __getProtoOf = Object.getPrototypeOf;
|
|
403
421
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
404
|
-
var __commonJS = function(cb, mod) {
|
|
422
|
+
var __commonJS = function __commonJS(cb, mod) {
|
|
405
423
|
return function __require() {
|
|
406
424
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
|
|
407
425
|
exports: {}
|
|
408
426
|
}).exports, mod), mod.exports;
|
|
409
427
|
};
|
|
410
428
|
};
|
|
411
|
-
var __copyProps = function(to, from, except, desc) {
|
|
429
|
+
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
412
430
|
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
413
431
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
414
432
|
try {
|
|
415
433
|
var _loop = function() {
|
|
416
434
|
var key = _step.value;
|
|
417
435
|
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
418
|
-
get: function() {
|
|
436
|
+
get: function get() {
|
|
419
437
|
return from[key];
|
|
420
438
|
},
|
|
421
439
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
@@ -439,7 +457,7 @@ var __copyProps = function(to, from, except, desc) {
|
|
|
439
457
|
}
|
|
440
458
|
return to;
|
|
441
459
|
};
|
|
442
|
-
var __toESM = function(mod, isNodeMode, target) {
|
|
460
|
+
var __toESM = function __toESM(mod, isNodeMode, target) {
|
|
443
461
|
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
444
462
|
// file that has been converted to a CommonJS file using a Babel-
|
|
445
463
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
@@ -2297,8 +2315,8 @@ var SubscriptionHandshakeLink = /*#__PURE__*/ function(ApolloLink) {
|
|
|
2297
2315
|
return c.topics.some(function(t) {
|
|
2298
2316
|
return newTopics.has(t);
|
|
2299
2317
|
});
|
|
2300
|
-
}).map(function(
|
|
2301
|
-
var topics =
|
|
2318
|
+
}).map(function(_0) {
|
|
2319
|
+
var topics = _0.topics, rest = _object_without_properties(_0, [
|
|
2302
2320
|
"topics"
|
|
2303
2321
|
]);
|
|
2304
2322
|
return _object_spread_props(_object_spread({}, rest), {
|
|
@@ -2391,8 +2409,8 @@ var SubscriptionHandshakeLink = /*#__PURE__*/ function(ApolloLink) {
|
|
|
2391
2409
|
clientId = connectionInfo.client, url2 = connectionInfo.url, topics = connectionInfo.topics;
|
|
2392
2410
|
client = new Paho.Client(url2, clientId);
|
|
2393
2411
|
client.trace = mqttLogger.bind(null, clientId);
|
|
2394
|
-
client.onConnectionLost = function(
|
|
2395
|
-
var errorCode =
|
|
2412
|
+
client.onConnectionLost = function(_0) {
|
|
2413
|
+
var errorCode = _0.errorCode, args = _object_without_properties(_0, [
|
|
2396
2414
|
"errorCode"
|
|
2397
2415
|
]);
|
|
2398
2416
|
if (errorCode !== 0) {
|
|
@@ -2420,7 +2438,7 @@ var SubscriptionHandshakeLink = /*#__PURE__*/ function(ApolloLink) {
|
|
|
2420
2438
|
client.connect({
|
|
2421
2439
|
useSSL: url2.indexOf("wss://") === 0,
|
|
2422
2440
|
mqttVersion: 3,
|
|
2423
|
-
onSuccess: function() {
|
|
2441
|
+
onSuccess: function onSuccess() {
|
|
2424
2442
|
return resolve(client);
|
|
2425
2443
|
},
|
|
2426
2444
|
onFailure: reject
|
|
@@ -2459,7 +2477,7 @@ var SubscriptionHandshakeLink = /*#__PURE__*/ function(ApolloLink) {
|
|
|
2459
2477
|
var _this = this;
|
|
2460
2478
|
return new Promise(function(resolve, reject) {
|
|
2461
2479
|
client.subscribe(topic, {
|
|
2462
|
-
onSuccess: function() {
|
|
2480
|
+
onSuccess: function onSuccess() {
|
|
2463
2481
|
if (!_this.topicObservers.has(topic)) {
|
|
2464
2482
|
_this.topicObservers.set(topic, /* @__PURE__ */ new Set());
|
|
2465
2483
|
}
|
|
@@ -2560,7 +2578,7 @@ var NonRetryableError = /*#__PURE__*/ function(Error1) {
|
|
|
2560
2578
|
}
|
|
2561
2579
|
return NonRetryableError;
|
|
2562
2580
|
}(_wrap_native_super(Error));
|
|
2563
|
-
var isNonRetryableError = function(obj) {
|
|
2581
|
+
var isNonRetryableError = function isNonRetryableError(obj) {
|
|
2564
2582
|
var key = "nonRetryable";
|
|
2565
2583
|
return obj && obj[key];
|
|
2566
2584
|
};
|
|
@@ -2643,7 +2661,7 @@ function jitteredBackoff(maxDelayMs) {
|
|
|
2643
2661
|
return delay > maxDelayMs ? false : delay;
|
|
2644
2662
|
};
|
|
2645
2663
|
}
|
|
2646
|
-
var jitteredExponentialRetry = function(functionToRetry, args) {
|
|
2664
|
+
var jitteredExponentialRetry = function jitteredExponentialRetry(functionToRetry, args) {
|
|
2647
2665
|
var maxDelayMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : MAX_DELAY_MS;
|
|
2648
2666
|
return retry(functionToRetry, args, jitteredBackoff(maxDelayMs));
|
|
2649
2667
|
};
|
|
@@ -2727,7 +2745,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(ApolloLink
|
|
|
2727
2745
|
authenticationType: _this.auth.type,
|
|
2728
2746
|
query: print(query),
|
|
2729
2747
|
region: _this.region,
|
|
2730
|
-
graphql_headers: function() {
|
|
2748
|
+
graphql_headers: function graphql_headers() {
|
|
2731
2749
|
return headers;
|
|
2732
2750
|
},
|
|
2733
2751
|
variables: variables,
|
|
@@ -3020,7 +3038,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(ApolloLink
|
|
|
3020
3038
|
region: region,
|
|
3021
3039
|
credentials: credentials,
|
|
3022
3040
|
token: token,
|
|
3023
|
-
graphql_headers: function() {}
|
|
3041
|
+
graphql_headers: function graphql_headers() {}
|
|
3024
3042
|
})
|
|
3025
3043
|
];
|
|
3026
3044
|
case 2:
|
|
@@ -3370,9 +3388,9 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /*#__PURE__*/ function(ApolloLink
|
|
|
3370
3388
|
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;
|
|
3371
3389
|
logger3("subscription message from AWS AppSyncRealTime: ".concat(type));
|
|
3372
3390
|
if (type === "connection_ack" /* GQL_CONNECTION_ACK */ ) {
|
|
3391
|
+
var _this_keepAliveTimeout;
|
|
3373
3392
|
ackOk = true;
|
|
3374
3393
|
var validTimeout = typeof connectionTimeoutMs === "number" && connectionTimeoutMs >= SERVER_KEEP_ALIVE_TIMEOUT ? connectionTimeoutMs : DEFAULT_KEEP_ALIVE_TIMEOUT;
|
|
3375
|
-
var _this_keepAliveTimeout;
|
|
3376
3394
|
_this.keepAliveTimeout = (_this_keepAliveTimeout = _this.keepAliveTimeout) !== null && _this_keepAliveTimeout !== void 0 ? _this_keepAliveTimeout : validTimeout;
|
|
3377
3395
|
_this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
|
|
3378
3396
|
_this.awsRealTimeSocket.onerror = function(err) {
|
|
@@ -3593,9 +3611,9 @@ function createSubscriptionHandshakeLink(infoOrUrl, theResultsFetcherLink) {
|
|
|
3593
3611
|
subscriptionLinks = ApolloLink4.from([
|
|
3594
3612
|
new NonTerminatingLink("controlMessages", _define_property({}, "link", new ApolloLink4(function(operation, _forward) {
|
|
3595
3613
|
return new Observable3(function(observer) {
|
|
3596
|
-
var
|
|
3597
|
-
CONTROL_EVENTS_KEY
|
|
3598
|
-
]
|
|
3614
|
+
var _ref = operation.variables, controlEvents = _ref[CONTROL_EVENTS_KEY], variables = _object_without_properties(_ref, [
|
|
3615
|
+
_to_property_key(CONTROL_EVENTS_KEY)
|
|
3616
|
+
]);
|
|
3599
3617
|
if (typeof controlEvents !== "undefined") {
|
|
3600
3618
|
operation.variables = variables;
|
|
3601
3619
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-appsync-subscription-link",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "lib/index.mjs",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib"
|
|
9
|
+
],
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
9
12
|
"types": "./lib/index.d.ts",
|
|
@@ -30,7 +33,7 @@
|
|
|
30
33
|
"test-watch": "jest --watch"
|
|
31
34
|
},
|
|
32
35
|
"dependencies": {
|
|
33
|
-
"aws-appsync-auth-link": "^4.0.
|
|
36
|
+
"aws-appsync-auth-link": "^4.0.2",
|
|
34
37
|
"debug": "2.6.9",
|
|
35
38
|
"url": "^0.11.0",
|
|
36
39
|
"zen-observable-ts": "^1.2.5"
|
|
@@ -1,770 +0,0 @@
|
|
|
1
|
-
import { AUTH_TYPE } from "aws-appsync-auth-link";
|
|
2
|
-
import { execute, ApolloClient } from "@apollo/client/core";
|
|
3
|
-
import gql from "graphql-tag";
|
|
4
|
-
import { AppSyncRealTimeSubscriptionHandshakeLink } from "../../src/realtime-subscription-handshake-link";
|
|
5
|
-
import { MESSAGE_TYPES } from "../../src/types";
|
|
6
|
-
import { v4 as uuid } from "uuid";
|
|
7
|
-
jest.mock("uuid", () => ({ v4: jest.fn() }));
|
|
8
|
-
|
|
9
|
-
const query = gql`
|
|
10
|
-
subscription {
|
|
11
|
-
someSubscription {
|
|
12
|
-
aField
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
// Mock ApolloClient for execute context
|
|
18
|
-
const mockClient = {} as ApolloClient;
|
|
19
|
-
|
|
20
|
-
class myWebSocket implements WebSocket {
|
|
21
|
-
binaryType: BinaryType = "arraybuffer";
|
|
22
|
-
bufferedAmount: number;
|
|
23
|
-
extensions: string;
|
|
24
|
-
onclose: (this: WebSocket, ev: CloseEvent) => any;
|
|
25
|
-
onerror: (this: WebSocket, ev: Event) => any;
|
|
26
|
-
onmessage: (this: WebSocket, ev: MessageEvent) => any;
|
|
27
|
-
onopen: (this: WebSocket, ev: Event) => any;
|
|
28
|
-
protocol: string;
|
|
29
|
-
readyState: number;
|
|
30
|
-
url: string;
|
|
31
|
-
close(code?: number, reason?: string): void {
|
|
32
|
-
throw new Error("Method not implemented.");
|
|
33
|
-
}
|
|
34
|
-
send(data: string | ArrayBuffer | Blob | ArrayBufferView): void {
|
|
35
|
-
throw new Error("Method not implemented.");
|
|
36
|
-
}
|
|
37
|
-
CLOSED: number;
|
|
38
|
-
CLOSING: number;
|
|
39
|
-
CONNECTING: number;
|
|
40
|
-
OPEN: number;
|
|
41
|
-
addEventListener<K extends "close" | "error" | "message" | "open">(
|
|
42
|
-
type: K,
|
|
43
|
-
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => void,
|
|
44
|
-
options?: boolean | AddEventListenerOptions
|
|
45
|
-
): void;
|
|
46
|
-
addEventListener(
|
|
47
|
-
type: string,
|
|
48
|
-
listener: EventListenerOrEventListenerObject,
|
|
49
|
-
options?: boolean | AddEventListenerOptions
|
|
50
|
-
): void;
|
|
51
|
-
addEventListener(type: any, listener: any, options?: any) {
|
|
52
|
-
throw new Error("Method not implemented.");
|
|
53
|
-
}
|
|
54
|
-
removeEventListener<K extends "close" | "error" | "message" | "open">(
|
|
55
|
-
type: K,
|
|
56
|
-
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => void,
|
|
57
|
-
options?: boolean | EventListenerOptions
|
|
58
|
-
): void;
|
|
59
|
-
removeEventListener(
|
|
60
|
-
type: string,
|
|
61
|
-
listener: EventListenerOrEventListenerObject,
|
|
62
|
-
options?: boolean | EventListenerOptions
|
|
63
|
-
): void;
|
|
64
|
-
removeEventListener(type: any, listener: any, options?: any) {
|
|
65
|
-
throw new Error("Method not implemented.");
|
|
66
|
-
}
|
|
67
|
-
dispatchEvent(event: Event): boolean {
|
|
68
|
-
throw new Error("Method not implemented.");
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Helper to decode a base64url-encoded header from the Sec-WebSocket-Protocol value.
|
|
74
|
-
* The protocol value is prefixed with "header-".
|
|
75
|
-
*/
|
|
76
|
-
function decodeProtocolHeader(protocols: string | string[]): Record<string, string> {
|
|
77
|
-
const arr = Array.isArray(protocols) ? protocols : [protocols];
|
|
78
|
-
const headerProtocol = arr.find(p => p.startsWith("header-"));
|
|
79
|
-
if (!headerProtocol) throw new Error("No header- protocol found");
|
|
80
|
-
const base64url = headerProtocol.slice("header-".length);
|
|
81
|
-
// Convert base64url back to standard base64
|
|
82
|
-
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
83
|
-
return JSON.parse(Buffer.from(base64, "base64").toString());
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
describe("RealTime subscription link", () => {
|
|
87
|
-
test("Can instantiate link", () => {
|
|
88
|
-
expect.assertions(1);
|
|
89
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
90
|
-
auth: {
|
|
91
|
-
type: AUTH_TYPE.API_KEY,
|
|
92
|
-
apiKey: "xxxxx",
|
|
93
|
-
},
|
|
94
|
-
region: "us-west-2",
|
|
95
|
-
url: "https://firsttesturl12345678901234.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test("Can instantiate link with custom domain", () => {
|
|
102
|
-
expect.assertions(1);
|
|
103
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
104
|
-
auth: {
|
|
105
|
-
type: AUTH_TYPE.API_KEY,
|
|
106
|
-
apiKey: "xxxxx",
|
|
107
|
-
},
|
|
108
|
-
region: "us-west-2",
|
|
109
|
-
url: "https://test1.testcustomdomain.com/graphql",
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test("Initialize WebSocket correctly for API KEY", (done) => {
|
|
116
|
-
expect.assertions(3);
|
|
117
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
118
|
-
jest.fn(() => {
|
|
119
|
-
return "2019-11-13T18:47:04.733Z";
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
123
|
-
(url, protocol) => {
|
|
124
|
-
// URL should be clean — no query string with credentials
|
|
125
|
-
expect(url).toBe(
|
|
126
|
-
"wss://apikeytesturl1234567890123.appsync-realtime-api.us-west-2.amazonaws.com/graphql"
|
|
127
|
-
);
|
|
128
|
-
// Protocol should be an array with graphql-ws and header- prefix
|
|
129
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
130
|
-
const header = decodeProtocolHeader(protocol);
|
|
131
|
-
expect(header["x-api-key"]).toBe("xxxxx");
|
|
132
|
-
done();
|
|
133
|
-
return new myWebSocket();
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
137
|
-
auth: {
|
|
138
|
-
type: AUTH_TYPE.API_KEY,
|
|
139
|
-
apiKey: "xxxxx",
|
|
140
|
-
},
|
|
141
|
-
region: "us-west-2",
|
|
142
|
-
url: "https://apikeytesturl1234567890123.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
146
|
-
error: (err) => {
|
|
147
|
-
console.log(JSON.stringify(err));
|
|
148
|
-
fail;
|
|
149
|
-
},
|
|
150
|
-
next: (data) => {
|
|
151
|
-
console.log({ data });
|
|
152
|
-
done();
|
|
153
|
-
},
|
|
154
|
-
complete: () => {
|
|
155
|
-
console.log("done with this");
|
|
156
|
-
done();
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test("Initialize WebSocket correctly for API KEY with custom domain", (done) => {
|
|
162
|
-
expect.assertions(3);
|
|
163
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
164
|
-
jest.fn(() => {
|
|
165
|
-
return "2019-11-13T18:47:04.733Z";
|
|
166
|
-
})
|
|
167
|
-
);
|
|
168
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
169
|
-
(url, protocol) => {
|
|
170
|
-
expect(url).toBe(
|
|
171
|
-
"wss://apikeytest.testcustomdomain.com/graphql/realtime"
|
|
172
|
-
);
|
|
173
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
174
|
-
const header = decodeProtocolHeader(protocol);
|
|
175
|
-
expect(header["x-api-key"]).toBe("xxxxx");
|
|
176
|
-
done();
|
|
177
|
-
return new myWebSocket();
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
181
|
-
auth: {
|
|
182
|
-
type: AUTH_TYPE.API_KEY,
|
|
183
|
-
apiKey: "xxxxx",
|
|
184
|
-
},
|
|
185
|
-
region: "us-west-2",
|
|
186
|
-
url: "https://apikeytest.testcustomdomain.com/graphql",
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
190
|
-
error: (err) => {
|
|
191
|
-
console.log(JSON.stringify(err));
|
|
192
|
-
fail;
|
|
193
|
-
},
|
|
194
|
-
next: (data) => {
|
|
195
|
-
console.log({ data });
|
|
196
|
-
done();
|
|
197
|
-
},
|
|
198
|
-
complete: () => {
|
|
199
|
-
console.log("done with this");
|
|
200
|
-
done();
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test("Initialize WebSocket correctly for COGNITO USER POOLS", (done) => {
|
|
206
|
-
expect.assertions(3);
|
|
207
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
208
|
-
jest.fn(() => {
|
|
209
|
-
return "2019-11-13T18:47:04.733Z";
|
|
210
|
-
})
|
|
211
|
-
);
|
|
212
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
213
|
-
(url, protocol) => {
|
|
214
|
-
expect(url).toBe(
|
|
215
|
-
"wss://cognitouserpooltesturl1234.appsync-realtime-api.us-west-2.amazonaws.com/graphql"
|
|
216
|
-
);
|
|
217
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
218
|
-
const header = decodeProtocolHeader(protocol);
|
|
219
|
-
expect(header["Authorization"]).toBe("token");
|
|
220
|
-
done();
|
|
221
|
-
return new myWebSocket();
|
|
222
|
-
}
|
|
223
|
-
);
|
|
224
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
225
|
-
auth: {
|
|
226
|
-
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
|
|
227
|
-
jwtToken: "token",
|
|
228
|
-
},
|
|
229
|
-
region: "us-west-2",
|
|
230
|
-
url: "https://cognitouserpooltesturl1234.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
234
|
-
error: (err) => {
|
|
235
|
-
console.log(JSON.stringify(err));
|
|
236
|
-
fail;
|
|
237
|
-
},
|
|
238
|
-
next: (data) => {
|
|
239
|
-
console.log({ data });
|
|
240
|
-
done();
|
|
241
|
-
},
|
|
242
|
-
complete: () => {
|
|
243
|
-
console.log("done with this");
|
|
244
|
-
done();
|
|
245
|
-
},
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
test("Initialize WebSocket correctly for COGNITO USER POOLS with custom domain", (done) => {
|
|
250
|
-
expect.assertions(3);
|
|
251
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
252
|
-
jest.fn(() => {
|
|
253
|
-
return "2019-11-13T18:47:04.733Z";
|
|
254
|
-
})
|
|
255
|
-
);
|
|
256
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
257
|
-
(url, protocol) => {
|
|
258
|
-
expect(url).toBe(
|
|
259
|
-
"wss://cognitouserpools.testcustomdomain.com/graphql/realtime"
|
|
260
|
-
);
|
|
261
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
262
|
-
const header = decodeProtocolHeader(protocol);
|
|
263
|
-
expect(header["Authorization"]).toBe("token");
|
|
264
|
-
done();
|
|
265
|
-
return new myWebSocket();
|
|
266
|
-
}
|
|
267
|
-
);
|
|
268
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
269
|
-
auth: {
|
|
270
|
-
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
|
|
271
|
-
jwtToken: "token",
|
|
272
|
-
},
|
|
273
|
-
region: "us-west-2",
|
|
274
|
-
url: "https://cognitouserpools.testcustomdomain.com/graphql",
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
278
|
-
error: (err) => {
|
|
279
|
-
console.log(JSON.stringify(err));
|
|
280
|
-
fail;
|
|
281
|
-
},
|
|
282
|
-
next: (data) => {
|
|
283
|
-
console.log({ data });
|
|
284
|
-
done();
|
|
285
|
-
},
|
|
286
|
-
complete: () => {
|
|
287
|
-
console.log("done with this");
|
|
288
|
-
done();
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
test("Initialize WebSocket correctly for OPENID_CONNECT", (done) => {
|
|
294
|
-
expect.assertions(3);
|
|
295
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
296
|
-
jest.fn(() => {
|
|
297
|
-
return "2019-11-13T18:47:04.733Z";
|
|
298
|
-
})
|
|
299
|
-
);
|
|
300
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
301
|
-
(url, protocol) => {
|
|
302
|
-
expect(url).toBe(
|
|
303
|
-
"wss://openidconnecttesturl123456.appsync-realtime-api.us-west-2.amazonaws.com/graphql"
|
|
304
|
-
);
|
|
305
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
306
|
-
const header = decodeProtocolHeader(protocol);
|
|
307
|
-
expect(header["Authorization"]).toBe("token");
|
|
308
|
-
done();
|
|
309
|
-
return new myWebSocket();
|
|
310
|
-
}
|
|
311
|
-
);
|
|
312
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
313
|
-
auth: {
|
|
314
|
-
type: AUTH_TYPE.OPENID_CONNECT,
|
|
315
|
-
jwtToken: "token",
|
|
316
|
-
},
|
|
317
|
-
region: "us-west-2",
|
|
318
|
-
url: "https://openidconnecttesturl123456.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
322
|
-
error: (err) => {
|
|
323
|
-
console.log(JSON.stringify(err));
|
|
324
|
-
fail;
|
|
325
|
-
},
|
|
326
|
-
next: (data) => {
|
|
327
|
-
console.log({ data });
|
|
328
|
-
done();
|
|
329
|
-
},
|
|
330
|
-
complete: () => {
|
|
331
|
-
console.log("done with this");
|
|
332
|
-
done();
|
|
333
|
-
},
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
test("Initialize WebSocket correctly for OPENID_CONNECT with custom domain", (done) => {
|
|
338
|
-
expect.assertions(3);
|
|
339
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
340
|
-
jest.fn(() => {
|
|
341
|
-
return "2019-11-13T18:47:04.733Z";
|
|
342
|
-
})
|
|
343
|
-
);
|
|
344
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
345
|
-
(url, protocol) => {
|
|
346
|
-
expect(url).toBe(
|
|
347
|
-
"wss://openidconnecttesturl.testcustomdomain.com/graphql/realtime"
|
|
348
|
-
);
|
|
349
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
350
|
-
const header = decodeProtocolHeader(protocol);
|
|
351
|
-
expect(header["Authorization"]).toBe("token");
|
|
352
|
-
done();
|
|
353
|
-
return new myWebSocket();
|
|
354
|
-
}
|
|
355
|
-
);
|
|
356
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
357
|
-
auth: {
|
|
358
|
-
type: AUTH_TYPE.OPENID_CONNECT,
|
|
359
|
-
jwtToken: "token",
|
|
360
|
-
},
|
|
361
|
-
region: "us-west-2",
|
|
362
|
-
url: "https://openidconnecttesturl.testcustomdomain.com/graphql",
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
366
|
-
error: (err) => {
|
|
367
|
-
console.log(JSON.stringify(err));
|
|
368
|
-
fail;
|
|
369
|
-
},
|
|
370
|
-
next: (data) => {
|
|
371
|
-
console.log({ data });
|
|
372
|
-
done();
|
|
373
|
-
},
|
|
374
|
-
complete: () => {
|
|
375
|
-
console.log("done with this");
|
|
376
|
-
done();
|
|
377
|
-
},
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
test("Initialize WebSocket correctly for AWS_LAMBDA", (done) => {
|
|
382
|
-
expect.assertions(3);
|
|
383
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
384
|
-
jest.fn(() => {
|
|
385
|
-
return "2019-11-13T18:47:04.733Z";
|
|
386
|
-
})
|
|
387
|
-
);
|
|
388
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
389
|
-
(url, protocol) => {
|
|
390
|
-
expect(url).toBe(
|
|
391
|
-
"wss://awslambdatesturl1234567890.appsync-realtime-api.us-west-2.amazonaws.com/graphql"
|
|
392
|
-
);
|
|
393
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
394
|
-
const header = decodeProtocolHeader(protocol);
|
|
395
|
-
expect(header["Authorization"]).toBe("token");
|
|
396
|
-
done();
|
|
397
|
-
return new myWebSocket();
|
|
398
|
-
}
|
|
399
|
-
);
|
|
400
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
401
|
-
auth: {
|
|
402
|
-
type: AUTH_TYPE.AWS_LAMBDA,
|
|
403
|
-
token: "token",
|
|
404
|
-
},
|
|
405
|
-
region: "us-west-2",
|
|
406
|
-
url: "https://awslambdatesturl1234567890.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
410
|
-
error: (err) => {
|
|
411
|
-
fail;
|
|
412
|
-
},
|
|
413
|
-
next: (data) => {
|
|
414
|
-
done();
|
|
415
|
-
},
|
|
416
|
-
complete: () => {
|
|
417
|
-
done();
|
|
418
|
-
},
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
test("Initialize WebSocket correctly for AWS_LAMBDA with custom domain", (done) => {
|
|
423
|
-
expect.assertions(3);
|
|
424
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
425
|
-
jest.fn(() => {
|
|
426
|
-
return "2019-11-13T18:47:04.733Z";
|
|
427
|
-
})
|
|
428
|
-
);
|
|
429
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
430
|
-
(url, protocol) => {
|
|
431
|
-
expect(url).toBe(
|
|
432
|
-
"wss://awslambdatesturl.testcustomdomain.com/graphql/realtime"
|
|
433
|
-
);
|
|
434
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
435
|
-
const header = decodeProtocolHeader(protocol);
|
|
436
|
-
expect(header["Authorization"]).toBe("token");
|
|
437
|
-
done();
|
|
438
|
-
return new myWebSocket();
|
|
439
|
-
}
|
|
440
|
-
);
|
|
441
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
442
|
-
auth: {
|
|
443
|
-
type: AUTH_TYPE.AWS_LAMBDA,
|
|
444
|
-
token: "token",
|
|
445
|
-
},
|
|
446
|
-
region: "us-west-2",
|
|
447
|
-
url: "https://awslambdatesturl.testcustomdomain.com/graphql",
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
451
|
-
error: (err) => {
|
|
452
|
-
fail;
|
|
453
|
-
},
|
|
454
|
-
next: (data) => {
|
|
455
|
-
done();
|
|
456
|
-
},
|
|
457
|
-
complete: () => {
|
|
458
|
-
done();
|
|
459
|
-
},
|
|
460
|
-
});
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
test("Can instantiate link with proxy config", () => {
|
|
464
|
-
expect.assertions(1);
|
|
465
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
466
|
-
auth: {
|
|
467
|
-
type: AUTH_TYPE.API_KEY,
|
|
468
|
-
apiKey: "xxxxx",
|
|
469
|
-
},
|
|
470
|
-
region: "us-west-2",
|
|
471
|
-
url: "https://firsttesturl12345678901234.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
472
|
-
proxy: {
|
|
473
|
-
url: "https://d111111abcdef8.cloudfront.net/graphql",
|
|
474
|
-
},
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
test("Initialize WebSocket through proxy for API KEY - routes to proxy URL with AppSync host in auth", (done) => {
|
|
481
|
-
expect.assertions(2);
|
|
482
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
483
|
-
jest.fn(() => {
|
|
484
|
-
return "2019-11-13T18:47:04.733Z";
|
|
485
|
-
})
|
|
486
|
-
);
|
|
487
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
488
|
-
(url, protocol) => {
|
|
489
|
-
// WebSocket should connect to the proxy, not directly to AppSync
|
|
490
|
-
expect(url).toBe(
|
|
491
|
-
"wss://d111111abcdef8.cloudfront.net/realtime"
|
|
492
|
-
);
|
|
493
|
-
// Decode the header from the protocol to verify the host is the AppSync endpoint, not CloudFront
|
|
494
|
-
const header = decodeProtocolHeader(protocol);
|
|
495
|
-
expect(header.host).toBe(
|
|
496
|
-
"proxytesturl12345678901234567.appsync-api.us-west-2.amazonaws.com"
|
|
497
|
-
);
|
|
498
|
-
done();
|
|
499
|
-
return new myWebSocket();
|
|
500
|
-
}
|
|
501
|
-
);
|
|
502
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
503
|
-
auth: {
|
|
504
|
-
type: AUTH_TYPE.API_KEY,
|
|
505
|
-
apiKey: "xxxxx",
|
|
506
|
-
},
|
|
507
|
-
region: "us-west-2",
|
|
508
|
-
url: "https://proxytesturl12345678901234567.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
509
|
-
proxy: {
|
|
510
|
-
url: "https://d111111abcdef8.cloudfront.net/graphql",
|
|
511
|
-
},
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
515
|
-
error: (err) => {
|
|
516
|
-
fail;
|
|
517
|
-
},
|
|
518
|
-
next: (data) => {
|
|
519
|
-
done();
|
|
520
|
-
},
|
|
521
|
-
complete: () => {
|
|
522
|
-
done();
|
|
523
|
-
},
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
test("Initialize WebSocket through proxy for COGNITO USER POOLS - host in auth is AppSync not proxy", (done) => {
|
|
528
|
-
expect.assertions(2);
|
|
529
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
530
|
-
jest.fn(() => {
|
|
531
|
-
return "2019-11-13T18:47:04.733Z";
|
|
532
|
-
})
|
|
533
|
-
);
|
|
534
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
535
|
-
(url, protocol) => {
|
|
536
|
-
expect(url).toBe(
|
|
537
|
-
"wss://mycdn.example.com/realtime"
|
|
538
|
-
);
|
|
539
|
-
const header = decodeProtocolHeader(protocol);
|
|
540
|
-
expect(header.host).toBe(
|
|
541
|
-
"cognitoproxytesturl123456789.appsync-api.us-west-2.amazonaws.com"
|
|
542
|
-
);
|
|
543
|
-
done();
|
|
544
|
-
return new myWebSocket();
|
|
545
|
-
}
|
|
546
|
-
);
|
|
547
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
548
|
-
auth: {
|
|
549
|
-
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
|
|
550
|
-
jwtToken: "token",
|
|
551
|
-
},
|
|
552
|
-
region: "us-west-2",
|
|
553
|
-
url: "https://cognitoproxytesturl123456789.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
554
|
-
proxy: {
|
|
555
|
-
url: "https://mycdn.example.com/graphql",
|
|
556
|
-
},
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
560
|
-
error: (err) => {
|
|
561
|
-
fail;
|
|
562
|
-
},
|
|
563
|
-
next: (data) => {
|
|
564
|
-
done();
|
|
565
|
-
},
|
|
566
|
-
complete: () => {
|
|
567
|
-
done();
|
|
568
|
-
},
|
|
569
|
-
});
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
test("Can use a custom keepAliveTimeoutMs", (done) => {
|
|
573
|
-
const id = "abcd-efgh-ijkl-mnop";
|
|
574
|
-
jest.mocked(uuid).mockImplementationOnce(() => id);
|
|
575
|
-
|
|
576
|
-
expect.assertions(5);
|
|
577
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
578
|
-
jest.fn(() => {
|
|
579
|
-
return "2019-11-13T18:47:04.733Z";
|
|
580
|
-
})
|
|
581
|
-
);
|
|
582
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
583
|
-
(url, protocol) => {
|
|
584
|
-
expect(url).toBe(
|
|
585
|
-
"wss://apikeytest.testcustomdomain.com/graphql/realtime"
|
|
586
|
-
);
|
|
587
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
588
|
-
const socket = new myWebSocket();
|
|
589
|
-
|
|
590
|
-
setTimeout(() => {
|
|
591
|
-
socket.close = () => {};
|
|
592
|
-
socket.onopen.call(socket, undefined as unknown as Event);
|
|
593
|
-
socket.send = (msg: string) => {
|
|
594
|
-
const { type } = JSON.parse(msg);
|
|
595
|
-
|
|
596
|
-
switch (type) {
|
|
597
|
-
case MESSAGE_TYPES.GQL_CONNECTION_INIT:
|
|
598
|
-
socket.onmessage.call(socket, {
|
|
599
|
-
data: JSON.stringify({
|
|
600
|
-
type: MESSAGE_TYPES.GQL_CONNECTION_ACK,
|
|
601
|
-
payload: {
|
|
602
|
-
connectionTimeoutMs: 99999,
|
|
603
|
-
},
|
|
604
|
-
}),
|
|
605
|
-
} as MessageEvent);
|
|
606
|
-
setTimeout(() => {
|
|
607
|
-
socket.onmessage.call(socket, {
|
|
608
|
-
data: JSON.stringify({
|
|
609
|
-
id,
|
|
610
|
-
type: MESSAGE_TYPES.GQL_DATA,
|
|
611
|
-
payload: {
|
|
612
|
-
data: { something: 123 },
|
|
613
|
-
},
|
|
614
|
-
}),
|
|
615
|
-
} as MessageEvent);
|
|
616
|
-
}, 100);
|
|
617
|
-
break;
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
}, 100);
|
|
621
|
-
|
|
622
|
-
return socket;
|
|
623
|
-
}
|
|
624
|
-
);
|
|
625
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
626
|
-
auth: {
|
|
627
|
-
type: AUTH_TYPE.API_KEY,
|
|
628
|
-
apiKey: "xxxxx",
|
|
629
|
-
},
|
|
630
|
-
region: "us-west-2",
|
|
631
|
-
url: "https://apikeytest.testcustomdomain.com/graphql",
|
|
632
|
-
keepAliveTimeoutMs: 123456,
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
636
|
-
expect((link as any).keepAliveTimeout).toBe(123456);
|
|
637
|
-
|
|
638
|
-
const sub = execute(link, { query }, { client: mockClient }).subscribe({
|
|
639
|
-
error: (err) => {
|
|
640
|
-
console.log(JSON.stringify(err));
|
|
641
|
-
fail();
|
|
642
|
-
},
|
|
643
|
-
next: (data) => {
|
|
644
|
-
expect((link as any).keepAliveTimeout).toBe(123456);
|
|
645
|
-
done();
|
|
646
|
-
sub.unsubscribe();
|
|
647
|
-
},
|
|
648
|
-
complete: () => {
|
|
649
|
-
console.log("done with this");
|
|
650
|
-
fail();
|
|
651
|
-
},
|
|
652
|
-
});
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
test("Uses service-provided timeout when no custom keepAliveTimeoutMs is configured", (done) => {
|
|
656
|
-
const id = "abcd-efgh-ijkl-mnop";
|
|
657
|
-
jest.mocked(uuid).mockImplementationOnce(() => id);
|
|
658
|
-
|
|
659
|
-
expect.assertions(5);
|
|
660
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
661
|
-
jest.fn(() => {
|
|
662
|
-
return "2019-11-13T18:47:04.733Z";
|
|
663
|
-
})
|
|
664
|
-
);
|
|
665
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
666
|
-
(url, protocol) => {
|
|
667
|
-
expect(url).toBe(
|
|
668
|
-
"wss://apikeytest.testcustomdomain.com/graphql/realtime"
|
|
669
|
-
);
|
|
670
|
-
expect(Array.isArray(protocol)).toBe(true);
|
|
671
|
-
const socket = new myWebSocket();
|
|
672
|
-
|
|
673
|
-
setTimeout(() => {
|
|
674
|
-
socket.close = () => {};
|
|
675
|
-
socket.onopen.call(socket, undefined as unknown as Event);
|
|
676
|
-
socket.send = (msg: string) => {
|
|
677
|
-
const { type } = JSON.parse(msg);
|
|
678
|
-
|
|
679
|
-
switch (type) {
|
|
680
|
-
case MESSAGE_TYPES.GQL_CONNECTION_INIT:
|
|
681
|
-
socket.onmessage.call(socket, {
|
|
682
|
-
data: JSON.stringify({
|
|
683
|
-
type: MESSAGE_TYPES.GQL_CONNECTION_ACK,
|
|
684
|
-
payload: {
|
|
685
|
-
connectionTimeoutMs: 99999,
|
|
686
|
-
},
|
|
687
|
-
}),
|
|
688
|
-
} as MessageEvent);
|
|
689
|
-
setTimeout(() => {
|
|
690
|
-
socket.onmessage.call(socket, {
|
|
691
|
-
data: JSON.stringify({
|
|
692
|
-
id,
|
|
693
|
-
type: MESSAGE_TYPES.GQL_DATA,
|
|
694
|
-
payload: {
|
|
695
|
-
data: { something: 123 },
|
|
696
|
-
},
|
|
697
|
-
}),
|
|
698
|
-
} as MessageEvent);
|
|
699
|
-
}, 100);
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
}, 100);
|
|
704
|
-
|
|
705
|
-
return socket;
|
|
706
|
-
}
|
|
707
|
-
);
|
|
708
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
709
|
-
auth: {
|
|
710
|
-
type: AUTH_TYPE.API_KEY,
|
|
711
|
-
apiKey: "xxxxx",
|
|
712
|
-
},
|
|
713
|
-
region: "us-west-2",
|
|
714
|
-
url: "https://apikeytest.testcustomdomain.com/graphql",
|
|
715
|
-
});
|
|
716
|
-
|
|
717
|
-
expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
|
|
718
|
-
expect((link as any).keepAliveTimeout).toBeUndefined();
|
|
719
|
-
|
|
720
|
-
const sub = execute(link, { query }, { client: mockClient }).subscribe({
|
|
721
|
-
error: (err) => {
|
|
722
|
-
console.log(JSON.stringify(err));
|
|
723
|
-
fail();
|
|
724
|
-
},
|
|
725
|
-
next: (data) => {
|
|
726
|
-
expect((link as any).keepAliveTimeout).toBe(99999);
|
|
727
|
-
done();
|
|
728
|
-
sub.unsubscribe();
|
|
729
|
-
},
|
|
730
|
-
complete: () => {
|
|
731
|
-
console.log("done with this");
|
|
732
|
-
fail();
|
|
733
|
-
},
|
|
734
|
-
});
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
test("URL does not contain credentials in query string", (done) => {
|
|
738
|
-
expect.assertions(2);
|
|
739
|
-
jest.spyOn(Date.prototype, "toISOString").mockImplementation(
|
|
740
|
-
jest.fn(() => {
|
|
741
|
-
return "2019-11-13T18:47:04.733Z";
|
|
742
|
-
})
|
|
743
|
-
);
|
|
744
|
-
AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn(
|
|
745
|
-
(url, protocol) => {
|
|
746
|
-
// The URL must not contain any query parameters with auth material
|
|
747
|
-
expect(url.includes("?")).toBe(false);
|
|
748
|
-
// Auth should be in the protocol header instead
|
|
749
|
-
const header = decodeProtocolHeader(protocol);
|
|
750
|
-
expect(header["x-api-key"]).toBe("my-secret-key");
|
|
751
|
-
done();
|
|
752
|
-
return new myWebSocket();
|
|
753
|
-
}
|
|
754
|
-
);
|
|
755
|
-
const link = new AppSyncRealTimeSubscriptionHandshakeLink({
|
|
756
|
-
auth: {
|
|
757
|
-
type: AUTH_TYPE.API_KEY,
|
|
758
|
-
apiKey: "my-secret-key",
|
|
759
|
-
},
|
|
760
|
-
region: "us-west-2",
|
|
761
|
-
url: "https://securitytesturl12345678901.appsync-api.us-west-2.amazonaws.com/graphql",
|
|
762
|
-
});
|
|
763
|
-
|
|
764
|
-
execute(link, { query }, { client: mockClient }).subscribe({
|
|
765
|
-
error: () => { fail; },
|
|
766
|
-
next: () => { done(); },
|
|
767
|
-
complete: () => { done(); },
|
|
768
|
-
});
|
|
769
|
-
});
|
|
770
|
-
});
|
package/jest.config.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
transform: {
|
|
3
|
-
"^.+\\.tsx?$": ["ts-jest", {
|
|
4
|
-
tsconfig: {
|
|
5
|
-
target: "es2017"
|
|
6
|
-
}
|
|
7
|
-
}]
|
|
8
|
-
},
|
|
9
|
-
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
|
10
|
-
collectCoverageFrom: [
|
|
11
|
-
"src/**/*",
|
|
12
|
-
"!src/vendor/**"
|
|
13
|
-
],
|
|
14
|
-
moduleFileExtensions: [
|
|
15
|
-
"ts",
|
|
16
|
-
"tsx",
|
|
17
|
-
"js",
|
|
18
|
-
"jsx",
|
|
19
|
-
"json",
|
|
20
|
-
"node"
|
|
21
|
-
],
|
|
22
|
-
testEnvironment: "node"
|
|
23
|
-
};
|
package/tsup.config.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ["src/index.ts"],
|
|
5
|
-
format: ["cjs", "esm"],
|
|
6
|
-
dts: true,
|
|
7
|
-
clean: true,
|
|
8
|
-
outDir: "lib",
|
|
9
|
-
external: [
|
|
10
|
-
"@apollo/client",
|
|
11
|
-
"@redux-offline/redux-offline",
|
|
12
|
-
"aws-appsync-auth-link",
|
|
13
|
-
"debug",
|
|
14
|
-
"rxjs",
|
|
15
|
-
"url",
|
|
16
|
-
"zen-observable-ts",
|
|
17
|
-
"graphql",
|
|
18
|
-
"uuid",
|
|
19
|
-
],
|
|
20
|
-
onSuccess: "cp -r src/vendor lib/vendor",
|
|
21
|
-
});
|
|
File without changes
|