aws-appsync-subscription-link 2.2.5 → 3.0.9

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 CHANGED
@@ -3,35 +3,72 @@
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="2.2.5"></a>
7
- ## [2.2.5](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.4...aws-appsync-subscription-link@2.2.5) (2021-09-24)
6
+ <a name="3.0.9"></a>
7
+ ## [3.0.9](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.8...aws-appsync-subscription-link@3.0.9) (2021-09-24)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * add type fix to subscription link to fix 'prepare' script ([#669](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/669)) ([c5202dc](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/c5202dc))
13
+ * **aws-appsync-subscription-link:** graphql header refactor to fix IAM-based auth ([#619](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/619)) ([#671](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/671)) ([dbf4959](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/dbf4959))
14
+ * remove aws-sdk V2; import aws-sdk V3 packages ([#637](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/637)); refactor auth-link, signer, and types ([0996740](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/0996740))
15
+
16
+
17
+
18
+
19
+ <a name="3.0.8"></a>
20
+ ## [3.0.8](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.7...aws-appsync-subscription-link@3.0.8) (2021-07-28)
8
21
 
9
22
 
10
23
 
11
24
 
12
25
  **Note:** Version bump only for package aws-appsync-subscription-link
13
26
 
14
- <a name="2.2.4"></a>
15
- ## [2.2.4](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.3...aws-appsync-subscription-link@2.2.4) (2021-09-24)
27
+ <a name="3.0.7"></a>
28
+ ## [3.0.7](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.6...aws-appsync-subscription-link@3.0.7) (2021-07-09)
16
29
 
17
30
 
18
- ### Bug Fixes
19
31
 
20
- * add type fixes to fix 'prepare' scripts ([#670](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/670)) ([bf5676a](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/bf5676a))
32
+
33
+ **Note:** Version bump only for package aws-appsync-subscription-link
34
+
35
+ <a name="3.0.6"></a>
36
+ ## [3.0.6](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.5...aws-appsync-subscription-link@3.0.6) (2021-02-12)
37
+
38
+
21
39
 
22
40
 
41
+ **Note:** Version bump only for package aws-appsync-subscription-link
42
+
43
+ <a name="3.0.5"></a>
44
+ ## [3.0.5](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.4...aws-appsync-subscription-link@3.0.5) (2021-01-26)
23
45
 
24
46
 
25
- <a name="2.2.3"></a>
26
- ## [2.2.3](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.2...aws-appsync-subscription-link@2.2.3) (2021-07-28)
47
+
48
+
49
+ **Note:** Version bump only for package aws-appsync-subscription-link
50
+
51
+ <a name="3.0.4"></a>
52
+ ## [3.0.4](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.3...aws-appsync-subscription-link@3.0.4) (2021-01-08)
27
53
 
28
54
 
29
55
 
30
56
 
31
57
  **Note:** Version bump only for package aws-appsync-subscription-link
32
58
 
33
- <a name="2.2.2"></a>
34
- ## [2.2.2](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.1...aws-appsync-subscription-link@2.2.2) (2021-07-09)
59
+ <a name="3.0.3"></a>
60
+ ## [3.0.3](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.2...aws-appsync-subscription-link@3.0.3) (2020-10-01)
61
+
62
+
63
+ ### Bug Fixes
64
+
65
+ * Add apollo-utilities dependency to subscription link ([3eeb77e](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/3eeb77e))
66
+
67
+
68
+
69
+
70
+ <a name="3.0.2"></a>
71
+ ## [3.0.2](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.1...aws-appsync-subscription-link@3.0.2) (2020-10-01)
35
72
 
36
73
 
37
74
 
@@ -1,13 +1,12 @@
1
1
  import { AUTH_TYPE } from "aws-appsync-auth-link";
2
- import { execute } from "apollo-link";
2
+ import { execute } from "@apollo/client/core";
3
3
  import gql from 'graphql-tag';
4
4
  import { AppSyncRealTimeSubscriptionHandshakeLink } from '../../src/realtime-subscription-handshake-link';
5
5
 
6
6
  const query = gql`subscription { someSubscription { aField } }`
7
7
 
8
8
  class myWebSocket implements WebSocket {
9
- binaryType: BinaryType;
10
- bufferedAmount: number;
9
+ binaryType: BinaryType; bufferedAmount: number;
11
10
  extensions: string;
12
11
  onclose: (this: WebSocket, ev: CloseEvent) => any;
13
12
  onerror: (this: WebSocket, ev: Event) => any;
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CONTROL_EVENTS_KEY } from "./subscription-handshake-link";
2
- import { ApolloLink } from "apollo-link";
2
+ import { ApolloLink } from "@apollo/client/core";
3
3
  import { UrlInfo } from "./types";
4
4
  declare function createSubscriptionHandshakeLink(args: UrlInfo, resultsFetcherLink?: ApolloLink): ApolloLink;
5
5
  declare function createSubscriptionHandshakeLink(url: string, resultsFetcherLink?: ApolloLink): ApolloLink;
package/lib/index.js CHANGED
@@ -13,20 +13,20 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  var subscription_handshake_link_1 = require("./subscription-handshake-link");
15
15
  exports.CONTROL_EVENTS_KEY = subscription_handshake_link_1.CONTROL_EVENTS_KEY;
16
- var apollo_link_1 = require("apollo-link");
17
- var apollo_link_http_1 = require("apollo-link-http");
18
- var apollo_utilities_1 = require("apollo-utilities");
16
+ var core_1 = require("@apollo/client/core");
17
+ var http_1 = require("@apollo/client/link/http");
18
+ var utilities_1 = require("@apollo/client/utilities");
19
19
  var non_terminating_link_1 = require("./non-terminating-link");
20
20
  var realtime_subscription_handshake_link_1 = require("./realtime-subscription-handshake-link");
21
21
  function createSubscriptionHandshakeLink(infoOrUrl, theResultsFetcherLink) {
22
22
  var resultsFetcherLink, subscriptionLinks;
23
23
  if (typeof infoOrUrl === "string") {
24
24
  resultsFetcherLink =
25
- theResultsFetcherLink || apollo_link_http_1.createHttpLink({ uri: infoOrUrl });
26
- subscriptionLinks = apollo_link_1.ApolloLink.from([
25
+ theResultsFetcherLink || http_1.createHttpLink({ uri: infoOrUrl });
26
+ subscriptionLinks = core_1.ApolloLink.from([
27
27
  new non_terminating_link_1.NonTerminatingLink("controlMessages", {
28
- link: new apollo_link_1.ApolloLink(function (operation, _forward) {
29
- return new apollo_link_1.Observable(function (observer) {
28
+ link: new core_1.ApolloLink(function (operation, _forward) {
29
+ return new core_1.Observable(function (observer) {
30
30
  var _a;
31
31
  var _b = operation, _c = _b.variables, _d = subscription_handshake_link_1.CONTROL_EVENTS_KEY, controlEvents = _c[_d], variables = __rest(_c, [typeof _d === "symbol" ? _d : _d + ""]);
32
32
  if (typeof controlEvents !== "undefined") {
@@ -43,12 +43,12 @@ function createSubscriptionHandshakeLink(infoOrUrl, theResultsFetcherLink) {
43
43
  }
44
44
  else {
45
45
  var url = infoOrUrl.url;
46
- resultsFetcherLink = theResultsFetcherLink || apollo_link_http_1.createHttpLink({ uri: url });
46
+ resultsFetcherLink = theResultsFetcherLink || http_1.createHttpLink({ uri: url });
47
47
  subscriptionLinks = new realtime_subscription_handshake_link_1.AppSyncRealTimeSubscriptionHandshakeLink(infoOrUrl);
48
48
  }
49
- return apollo_link_1.ApolloLink.split(function (operation) {
49
+ return core_1.ApolloLink.split(function (operation) {
50
50
  var query = operation.query;
51
- var _a = apollo_utilities_1.getMainDefinition(query), kind = _a.kind, graphqlOperation = _a.operation;
51
+ var _a = utilities_1.getMainDefinition(query), kind = _a.kind, graphqlOperation = _a.operation;
52
52
  var isSubscription = kind === "OperationDefinition" && graphqlOperation === "subscription";
53
53
  return isSubscription;
54
54
  }, subscriptionLinks, resultsFetcherLink);
@@ -2,8 +2,8 @@
2
2
  * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { FetchOptions } from 'apollo-link-http';
5
+ import { HttpOptions } from '@apollo/client/link/http';
6
6
  import { NonTerminatingLink } from './non-terminating-link';
7
7
  export declare class NonTerminatingHttpLink extends NonTerminatingLink {
8
- constructor(contextKey: string, options: FetchOptions);
8
+ constructor(contextKey: string, options: HttpOptions);
9
9
  }
@@ -17,13 +17,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
18
18
  * SPDX-License-Identifier: Apache-2.0
19
19
  */
20
- var apollo_link_http_1 = require("apollo-link-http");
20
+ var http_1 = require("@apollo/client/link/http");
21
21
  var non_terminating_link_1 = require("./non-terminating-link");
22
22
  var NonTerminatingHttpLink = /** @class */ (function (_super) {
23
23
  __extends(NonTerminatingHttpLink, _super);
24
24
  function NonTerminatingHttpLink(contextKey, options) {
25
25
  var _this = this;
26
- var link = apollo_link_http_1.createHttpLink(options);
26
+ var link = http_1.createHttpLink(options);
27
27
  _this = _super.call(this, contextKey, { link: link }) || this;
28
28
  return _this;
29
29
  }
@@ -2,14 +2,14 @@
2
2
  * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { ApolloLink, NextLink } from 'apollo-link';
5
+ import { ApolloLink } from '@apollo/client/core';
6
+ import type { NextLink, FetchResult } from '@apollo/client/core';
7
+ import type { Observable } from 'zen-observable-ts';
6
8
  export declare class NonTerminatingLink extends ApolloLink {
7
9
  private contextKey;
8
10
  private link;
9
11
  constructor(contextKey: string, { link }: {
10
12
  link: ApolloLink;
11
13
  });
12
- request(operation: any, forward?: NextLink): import("apollo-link").Observable<import("apollo-link").FetchResult<{
13
- [key: string]: any;
14
- }, Record<string, any>, Record<string, any>>>;
14
+ request(operation: any, forward?: NextLink): Observable<FetchResult>;
15
15
  }
@@ -64,8 +64,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
64
64
  * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
65
65
  * SPDX-License-Identifier: Apache-2.0
66
66
  */
67
- var apollo_link_1 = require("apollo-link");
68
- var apollo_link_context_1 = require("apollo-link-context");
67
+ var core_1 = require("@apollo/client/core");
68
+ var context_1 = require("@apollo/client/link/context");
69
69
  var NonTerminatingLink = /** @class */ (function (_super) {
70
70
  __extends(NonTerminatingLink, _super);
71
71
  function NonTerminatingLink(contextKey, _a) {
@@ -77,7 +77,7 @@ var NonTerminatingLink = /** @class */ (function (_super) {
77
77
  }
78
78
  NonTerminatingLink.prototype.request = function (operation, forward) {
79
79
  var _this = this;
80
- return apollo_link_context_1.setContext(function (_request, prevContext) { return __awaiter(_this, void 0, void 0, function () {
80
+ return (context_1.setContext(function (_request, prevContext) { return __awaiter(_this, void 0, void 0, function () {
81
81
  var result;
82
82
  var _a;
83
83
  var _this = this;
@@ -94,8 +94,8 @@ var NonTerminatingLink = /** @class */ (function (_super) {
94
94
  return [2 /*return*/, __assign(__assign({}, prevContext), (_a = {}, _a[this.contextKey] = result, _a))];
95
95
  }
96
96
  });
97
- }); }).request(operation, forward);
97
+ }); })).request(operation, forward);
98
98
  };
99
99
  return NonTerminatingLink;
100
- }(apollo_link_1.ApolloLink));
100
+ }(core_1.ApolloLink));
101
101
  exports.NonTerminatingLink = NonTerminatingLink;
@@ -2,7 +2,7 @@
2
2
  * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { ApolloLink, Observable, Operation } from "apollo-link";
5
+ import { ApolloLink, Observable, Operation, FetchResult } from "@apollo/client/core";
6
6
  import { UrlInfo } from "./types";
7
7
  export declare const CONTROL_EVENTS_KEY = "@@controlEvents";
8
8
  export declare class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink {
@@ -16,7 +16,9 @@ export declare class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink
16
16
  private subscriptionObserverMap;
17
17
  private promiseArray;
18
18
  constructor({ url: theUrl, region: theRegion, auth: theAuth }: UrlInfo);
19
- request(operation: Operation): Observable<any>;
19
+ request(operation: Operation): Observable<FetchResult<{
20
+ [key: string]: any;
21
+ }, Record<string, any>, Record<string, any>>>;
20
22
  private _verifySubscriptionAlreadyStarted;
21
23
  private _sendUnsubscriptionMessage;
22
24
  private _removeSubscriptionObserver;
@@ -64,7 +64,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
64
64
  * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
65
65
  * SPDX-License-Identifier: Apache-2.0
66
66
  */
67
- var apollo_link_1 = require("apollo-link");
67
+ var core_1 = require("@apollo/client/core");
68
68
  var utils_1 = require("./utils");
69
69
  var aws_appsync_auth_link_1 = require("aws-appsync-auth-link");
70
70
  var graphql_1 = require("graphql");
@@ -114,7 +114,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
114
114
  var _b = operation.getContext(), _c = _b.controlMessages, _d = exports.CONTROL_EVENTS_KEY, controlEvents = (_c === void 0 ? (_a = {},
115
115
  _a[exports.CONTROL_EVENTS_KEY] = undefined,
116
116
  _a) : _c)[_d], headers = _b.headers;
117
- return new apollo_link_1.Observable(function (observer) {
117
+ return new core_1.Observable(function (observer) {
118
118
  if (!_this.url) {
119
119
  observer.error({
120
120
  errors: [
@@ -245,11 +245,11 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
245
245
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._startSubscriptionWithAWSAppSyncRealTime = function (_a) {
246
246
  var options = _a.options, observer = _a.observer, subscriptionId = _a.subscriptionId;
247
247
  return __awaiter(this, void 0, void 0, function () {
248
- var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _b, graphql_headers, credentials, token, subscriptionState, data, dataString, headerObj, _c, _d, subscriptionMessage, stringToAWSRealTime, err_1, _e, message, subscriptionFailedCallback_1, _f, subscriptionFailedCallback, subscriptionReadyCallback;
249
- var _g;
248
+ var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _b, graphql_headers, credentials, token, subscriptionState, data, dataString, headerObj, _c, subscriptionMessage, stringToAWSRealTime, err_1, _d, message, subscriptionFailedCallback_1, _e, subscriptionFailedCallback, subscriptionReadyCallback;
249
+ var _f;
250
250
  var _this = this;
251
- return __generator(this, function (_h) {
252
- switch (_h.label) {
251
+ return __generator(this, function (_g) {
252
+ switch (_g.label) {
253
253
  case 0:
254
254
  appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region, _b = options.graphql_headers, graphql_headers = _b === void 0 ? function () { return ({}); } : _b, credentials = options.credentials, token = options.token;
255
255
  subscriptionState = types_1.SUBSCRIPTION_STATUS.PENDING;
@@ -275,13 +275,11 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
275
275
  canonicalUri: "",
276
276
  region: region,
277
277
  credentials: credentials,
278
- token: token
278
+ token: token,
279
+ graphql_headers: graphql_headers
279
280
  })];
280
281
  case 1:
281
- _d = [__assign.apply(void 0, _c.concat([(_h.sent())]))];
282
- return [4 /*yield*/, graphql_headers()];
283
- case 2:
284
- headerObj = __assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_h.sent())])), (_g = {}, _g[aws_appsync_auth_link_1.USER_AGENT_HEADER] = aws_appsync_auth_link_1.USER_AGENT, _g)]);
282
+ headerObj = __assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_g.sent())])), (_f = {}, _f[aws_appsync_auth_link_1.USER_AGENT_HEADER] = aws_appsync_auth_link_1.USER_AGENT, _f)]);
285
283
  subscriptionMessage = {
286
284
  id: subscriptionId,
287
285
  payload: {
@@ -293,9 +291,9 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
293
291
  type: types_1.MESSAGE_TYPES.GQL_START
294
292
  };
295
293
  stringToAWSRealTime = JSON.stringify(subscriptionMessage);
296
- _h.label = 3;
297
- case 3:
298
- _h.trys.push([3, 5, , 6]);
294
+ _g.label = 2;
295
+ case 2:
296
+ _g.trys.push([2, 4, , 5]);
299
297
  return [4 /*yield*/, this._initializeWebSocketConnection({
300
298
  apiKey: apiKey,
301
299
  appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
@@ -304,12 +302,12 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
304
302
  credentials: credentials,
305
303
  token: token
306
304
  })];
305
+ case 3:
306
+ _g.sent();
307
+ return [3 /*break*/, 5];
307
308
  case 4:
308
- _h.sent();
309
- return [3 /*break*/, 6];
310
- case 5:
311
- err_1 = _h.sent();
312
- _e = err_1.message, message = _e === void 0 ? "" : _e;
309
+ err_1 = _g.sent();
310
+ _d = err_1.message, message = _d === void 0 ? "" : _d;
313
311
  observer.error({
314
312
  errors: [
315
313
  __assign({}, new graphql_1.GraphQLError("Connection failed: " + message))
@@ -322,8 +320,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
322
320
  subscriptionFailedCallback_1();
323
321
  }
324
322
  return [2 /*return*/];
325
- case 6:
326
- _f = this.subscriptionObserverMap.get(subscriptionId), subscriptionFailedCallback = _f.subscriptionFailedCallback, subscriptionReadyCallback = _f.subscriptionReadyCallback;
323
+ case 5:
324
+ _e = this.subscriptionObserverMap.get(subscriptionId), subscriptionFailedCallback = _e.subscriptionFailedCallback, subscriptionReadyCallback = _e.subscriptionReadyCallback;
327
325
  // This must be done before sending the message in order to be listening immediately
328
326
  this.subscriptionObserverMap.set(subscriptionId, {
329
327
  observer: observer,
@@ -372,7 +370,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
372
370
  appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
373
371
  region: region,
374
372
  credentials: credentials,
375
- token: token
373
+ token: token,
374
+ graphql_headers: function () { }
376
375
  })];
377
376
  case 2:
378
377
  headerString = _b.apply(_a, [_c.sent()]);
@@ -410,7 +409,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
410
409
  }); });
411
410
  };
412
411
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._awsRealTimeHeaderBasedAuth = function (_a) {
413
- var authenticationType = _a.authenticationType, payload = _a.payload, canonicalUri = _a.canonicalUri, appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, apiKey = _a.apiKey, region = _a.region, credentials = _a.credentials, token = _a.token;
412
+ var authenticationType = _a.authenticationType, payload = _a.payload, canonicalUri = _a.canonicalUri, appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, apiKey = _a.apiKey, region = _a.region, credentials = _a.credentials, token = _a.token, graphql_headers = _a.graphql_headers;
414
413
  return __awaiter(this, void 0, void 0, function () {
415
414
  var headerHandler, handler, host, result;
416
415
  return __generator(this, function (_b) {
@@ -437,7 +436,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
437
436
  region: region,
438
437
  host: host,
439
438
  credentials: credentials,
440
- token: token
439
+ token: token,
440
+ graphql_headers: graphql_headers
441
441
  })];
442
442
  case 1:
443
443
  result = _b.sent();
@@ -447,41 +447,43 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
447
447
  });
448
448
  };
449
449
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._awsRealTimeAuthorizationHeader = function (_a) {
450
- var host = _a.host, token = _a.token;
450
+ var host = _a.host, token = _a.token, graphql_headers = _a.graphql_headers;
451
451
  return __awaiter(this, void 0, void 0, function () {
452
- var _b, _c;
453
- return __generator(this, function (_d) {
454
- switch (_d.label) {
452
+ var _b, _c, _d;
453
+ return __generator(this, function (_e) {
454
+ switch (_e.label) {
455
455
  case 0:
456
456
  _b = {};
457
457
  if (!(typeof token === "function")) return [3 /*break*/, 2];
458
458
  return [4 /*yield*/, token.call(undefined)];
459
459
  case 1:
460
- _c = _d.sent();
460
+ _c = _e.sent();
461
461
  return [3 /*break*/, 4];
462
462
  case 2: return [4 /*yield*/, token];
463
463
  case 3:
464
- _c = _d.sent();
465
- _d.label = 4;
466
- case 4: return [2 /*return*/, (_b.Authorization = _c,
467
- _b.host = host,
468
- _b)];
464
+ _c = _e.sent();
465
+ _e.label = 4;
466
+ case 4:
467
+ _d = [(_b.Authorization = _c, _b.host = host, _b)];
468
+ return [4 /*yield*/, graphql_headers()];
469
+ case 5: return [2 /*return*/, __assign.apply(void 0, _d.concat([(_e.sent())]))];
469
470
  }
470
471
  });
471
472
  });
472
473
  };
473
474
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._awsRealTimeApiKeyHeader = function (_a) {
474
- var apiKey = _a.apiKey, host = _a.host;
475
+ var apiKey = _a.apiKey, host = _a.host, graphql_headers = _a.graphql_headers;
475
476
  return __awaiter(this, void 0, void 0, function () {
476
- var dt, dtStr;
477
- return __generator(this, function (_b) {
478
- dt = new Date();
479
- dtStr = dt.toISOString().replace(/[:\-]|\.\d{3}/g, "");
480
- return [2 /*return*/, {
481
- host: host,
482
- "x-amz-date": dtStr,
483
- "x-api-key": apiKey
484
- }];
477
+ var dt, dtStr, _b;
478
+ return __generator(this, function (_c) {
479
+ switch (_c.label) {
480
+ case 0:
481
+ dt = new Date();
482
+ dtStr = dt.toISOString().replace(/[:\-]|\.\d{3}/g, "");
483
+ _b = [{ host: host, "x-amz-date": dtStr, "x-api-key": apiKey }];
484
+ return [4 /*yield*/, graphql_headers()];
485
+ case 1: return [2 /*return*/, __assign.apply(void 0, _b.concat([(_c.sent())]))];
486
+ }
485
487
  });
486
488
  });
487
489
  };
@@ -763,5 +765,5 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
763
765
  .replace("gogi-beta", "grt-beta");
764
766
  };
765
767
  return AppSyncRealTimeSubscriptionHandshakeLink;
766
- }(apollo_link_1.ApolloLink));
768
+ }(core_1.ApolloLink));
767
769
  exports.AppSyncRealTimeSubscriptionHandshakeLink = AppSyncRealTimeSubscriptionHandshakeLink;
@@ -1,9 +1,8 @@
1
- /// <reference types="zen-observable" />
2
1
  /*!
3
2
  * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
3
  * SPDX-License-Identifier: Apache-2.0
5
4
  */
6
- import { ApolloLink, Observable, Operation, FetchResult } from "apollo-link";
5
+ import { ApolloLink, Observable, Operation, FetchResult } from "@apollo/client/core";
7
6
  declare type MqttConnectionInfo = {
8
7
  client: string;
9
8
  url: string;
@@ -15,7 +14,7 @@ export declare class SubscriptionHandshakeLink extends ApolloLink {
15
14
  private topicObservers;
16
15
  private clientObservers;
17
16
  constructor(subsInfoContextKey: any);
18
- request(operation: Operation): Observable<any>;
17
+ request(operation: Operation): Observable<unknown>;
19
18
  connectNewClients(connectionInfo: MqttConnectionInfo[], observer: ZenObservable.Observer<FetchResult>, operation: Operation): Promise<any[]>;
20
19
  connectNewClient(connectionInfo: MqttConnectionInfo, observer: ZenObservable.Observer<FetchResult>, selectionNames: string[]): Promise<any>;
21
20
  subscribeToTopics<T>(client: any, topics: string[], observer: ZenObservable.Observer<T>): Promise<unknown[]>;
@@ -75,11 +75,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
75
75
  * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
76
76
  * SPDX-License-Identifier: Apache-2.0
77
77
  */
78
- var apollo_link_1 = require("apollo-link");
78
+ var core_1 = require("@apollo/client/core");
79
79
  var utils_1 = require("./utils");
80
80
  var Paho = require("./vendor/paho-mqtt");
81
- var apollo_client_1 = require("apollo-client");
82
- var apollo_utilities_1 = require("apollo-utilities");
81
+ var utilities_1 = require("@apollo/client/utilities");
83
82
  var logger = utils_1.rootLogger.extend('subscriptions');
84
83
  var mqttLogger = logger.extend('mqtt');
85
84
  exports.CONTROL_EVENTS_KEY = '@@controlEvents';
@@ -112,8 +111,8 @@ var SubscriptionHandshakeLink = /** @class */ (function (_super) {
112
111
  var _b = operation.getContext(), _c = this.subsInfoContextKey, subsInfo = _b[_c], _d = _b.controlMessages, _e = exports.CONTROL_EVENTS_KEY, controlEvents = (_d === void 0 ? (_a = {}, _a[exports.CONTROL_EVENTS_KEY] = undefined, _a) : _d)[_e];
113
112
  var _f = subsInfo.extensions, _g = (_f === void 0 ? { subscription: { newSubscriptions: {}, mqttConnections: [] } } : _f).subscription, newSubscriptions = _g.newSubscriptions, mqttConnections = _g.mqttConnections, _h = subsInfo.errors, errors = _h === void 0 ? [] : _h;
114
113
  if (errors && errors.length) {
115
- return new apollo_link_1.Observable(function (observer) {
116
- observer.error(new apollo_client_1.ApolloError({
114
+ return new core_1.Observable(function (observer) {
115
+ observer.error(new core_1.ApolloError({
117
116
  errorMessage: 'Error during subscription handshake',
118
117
  extraInfo: { errors: errors },
119
118
  graphQLErrors: errors
@@ -124,7 +123,7 @@ var SubscriptionHandshakeLink = /** @class */ (function (_super) {
124
123
  var newSubscriptionTopics = Object.keys(newSubscriptions).map(function (subKey) { return newSubscriptions[subKey].topic; });
125
124
  var existingTopicsWithObserver = new Set(newSubscriptionTopics.filter(function (t) { return _this.topicObservers.has(t); }));
126
125
  var newTopics = new Set(newSubscriptionTopics.filter(function (t) { return !existingTopicsWithObserver.has(t); }));
127
- return new apollo_link_1.Observable(function (observer) {
126
+ return new core_1.Observable(function (observer) {
128
127
  existingTopicsWithObserver.forEach(function (t) {
129
128
  _this.topicObservers.get(t).add(observer);
130
129
  var anObserver = Array.from(_this.topicObservers.get(t)).find(function () { return true; });
@@ -182,7 +181,7 @@ var SubscriptionHandshakeLink = /** @class */ (function (_super) {
182
181
  var _this = this;
183
182
  return __generator(this, function (_a) {
184
183
  query = operation.query;
185
- selectionNames = apollo_utilities_1.getMainDefinition(query).selectionSet.selections.map(function (_a) {
184
+ selectionNames = utilities_1.getMainDefinition(query).selectionSet.selections.map(function (_a) {
186
185
  var value = _a.name.value;
187
186
  return value;
188
187
  });
@@ -269,5 +268,5 @@ var SubscriptionHandshakeLink = /** @class */ (function (_super) {
269
268
  });
270
269
  };
271
270
  return SubscriptionHandshakeLink;
272
- }(apollo_link_1.ApolloLink));
271
+ }(core_1.ApolloLink));
273
272
  exports.SubscriptionHandshakeLink = SubscriptionHandshakeLink;
@@ -1,4 +1,3 @@
1
- /// <reference types="zen-observable" />
2
1
  import { AuthOptions } from "aws-appsync-auth-link";
3
2
  export declare enum SUBSCRIPTION_STATUS {
4
3
  PENDING = 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-appsync-subscription-link",
3
- "version": "2.2.5",
3
+ "version": "3.0.9",
4
4
  "main": "lib/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "description": "AWS Mobile AppSync SDK for JavaScript",
@@ -19,18 +19,15 @@
19
19
  "test-watch": "jest --watch"
20
20
  },
21
21
  "dependencies": {
22
- "apollo-link": "1.2.5",
23
- "apollo-link-context": "1.0.11",
24
- "apollo-link-http": "1.5.8",
25
- "apollo-link-retry": "2.2.7",
26
- "aws-appsync-auth-link": "^2.0.6",
22
+ "aws-appsync-auth-link": "^3.0.7",
27
23
  "debug": "2.6.9",
28
24
  "url": "^0.11.0"
29
25
  },
30
26
  "devDependencies": {
27
+ "@apollo/client": "^3.2.0",
31
28
  "@redux-offline/redux-offline": "2.5.2-native.0"
32
29
  },
33
30
  "peerDependencies": {
34
- "apollo-client": "2.x"
31
+ "@apollo/client": "3.x"
35
32
  }
36
33
  }