aws-appsync-subscription-link 2.2.5 → 2.3.0

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,6 +3,40 @@
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.3.0"></a>
7
+ # [2.3.0](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.7...aws-appsync-subscription-link@2.3.0) (2022-05-02)
8
+
9
+
10
+ ### Features
11
+
12
+ * add custom domain support for Apollo V2 ([#698](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/698)) ([42db16d](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/42db16d))
13
+
14
+
15
+
16
+
17
+ <a name="2.2.7"></a>
18
+ ## [2.2.7](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.5...aws-appsync-subscription-link@2.2.7) (2022-03-04)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * Port over Amplify fix for subscription race conditions for ApolloV2 ([#509](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/509)) ([#705](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/705)) ([f5022ba](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/f5022ba))
24
+ * **aws-appsync-subscription-link:** graphql header refactor to fix IAM-based auth for Apollo V2 packages ([#679](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/679)) ([09fc430](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/09fc430))
25
+
26
+
27
+
28
+
29
+ <a name="2.2.6"></a>
30
+ ## [2.2.6](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.5...aws-appsync-subscription-link@2.2.6) (2021-10-18)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **aws-appsync-subscription-link:** graphql header refactor to fix IAM-based auth for Apollo V2 packages ([#679](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/679)) ([09fc430](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/09fc430))
36
+
37
+
38
+
39
+
6
40
  <a name="2.2.5"></a>
7
41
  ## [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)
8
42
 
@@ -50,8 +50,22 @@ describe("RealTime subscription link", () => {
50
50
  type: AUTH_TYPE.API_KEY,
51
51
  apiKey: 'xxxxx'
52
52
  },
53
- region: 'us-east-1',
54
- url: 'https://xxxxx.appsync-api.amazonaws.com/graphql'
53
+ region: 'us-west-2',
54
+ url: 'https://firsttesturl12345678901234.appsync-api.us-west-2.amazonaws.com/graphql'
55
+ });
56
+
57
+ expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
58
+ });
59
+
60
+ test("Can instantiate link with custom domain", () => {
61
+ expect.assertions(1);
62
+ const link = new AppSyncRealTimeSubscriptionHandshakeLink({
63
+ auth: {
64
+ type: AUTH_TYPE.API_KEY,
65
+ apiKey: 'xxxxx'
66
+ },
67
+ region: 'us-west-2',
68
+ url: 'https://test1.testcustomdomain.com/graphql'
55
69
  });
56
70
 
57
71
  expect(link).toBeInstanceOf(AppSyncRealTimeSubscriptionHandshakeLink);
@@ -63,7 +77,7 @@ describe("RealTime subscription link", () => {
63
77
  return "2019-11-13T18:47:04.733Z";
64
78
  }));
65
79
  AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
66
- expect(url).toBe('wss://xxxxx.appsync-realtime-api.amazonaws.com/graphql?header=eyJob3N0IjoieHh4eHguYXBwc3luYy1hcGkuYW1hem9uYXdzLmNvbSIsIngtYW16LWRhdGUiOiIyMDE5MTExM1QxODQ3MDRaIiwieC1hcGkta2V5IjoieHh4eHgifQ==&payload=e30=');
80
+ expect(url).toBe('wss://apikeytesturl1234567890123.appsync-realtime-api.us-west-2.amazonaws.com/graphql?header=eyJob3N0IjoiYXBpa2V5dGVzdHVybDEyMzQ1Njc4OTAxMjMuYXBwc3luYy1hcGkudXMtd2VzdC0yLmFtYXpvbmF3cy5jb20iLCJ4LWFtei1kYXRlIjoiMjAxOTExMTNUMTg0NzA0WiIsIngtYXBpLWtleSI6Inh4eHh4In0=&payload=e30=');
67
81
  expect(protocol).toBe('graphql-ws');
68
82
  done();
69
83
  return new myWebSocket();
@@ -73,13 +87,50 @@ describe("RealTime subscription link", () => {
73
87
  type: AUTH_TYPE.API_KEY,
74
88
  apiKey: 'xxxxx'
75
89
  },
76
- region: 'us-east-1',
77
- url: 'https://xxxxx.appsync-api.amazonaws.com/graphql'
90
+ region: 'us-west-2',
91
+ url: 'https://apikeytesturl1234567890123.appsync-api.us-west-2.amazonaws.com/graphql'
78
92
  });
79
93
 
80
94
  execute(link, { query }).subscribe({
81
95
  error: (err) => {
82
- console.log({ err });
96
+ console.log(JSON.stringify(err));
97
+ fail;
98
+ },
99
+ next: (data) => {
100
+ console.log({ data });
101
+ done();
102
+ },
103
+ complete: () => {
104
+ console.log('done with this');
105
+ done();
106
+ }
107
+
108
+ });
109
+ });
110
+
111
+ test("Initialize WebSocket correctly for API KEY with custom domain", (done) => {
112
+ expect.assertions(2);
113
+ jest.spyOn(Date.prototype, 'toISOString').mockImplementation(jest.fn(() => {
114
+ return "2019-11-13T18:47:04.733Z";
115
+ }));
116
+ AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
117
+ expect(url).toBe('wss://apikeytest.testcustomdomain.com/graphql/realtime?header=eyJob3N0IjoiYXBpa2V5dGVzdC50ZXN0Y3VzdG9tZG9tYWluLmNvbSIsIngtYW16LWRhdGUiOiIyMDE5MTExM1QxODQ3MDRaIiwieC1hcGkta2V5IjoieHh4eHgifQ==&payload=e30=');
118
+ expect(protocol).toBe('graphql-ws');
119
+ done();
120
+ return new myWebSocket();
121
+ });
122
+ const link = new AppSyncRealTimeSubscriptionHandshakeLink({
123
+ auth: {
124
+ type: AUTH_TYPE.API_KEY,
125
+ apiKey: 'xxxxx'
126
+ },
127
+ region: 'us-west-2',
128
+ url: 'https://apikeytest.testcustomdomain.com/graphql'
129
+ });
130
+
131
+ execute(link, { query }).subscribe({
132
+ error: (err) => {
133
+ console.log(JSON.stringify(err));
83
134
  fail;
84
135
  },
85
136
  next: (data) => {
@@ -100,7 +151,7 @@ describe("RealTime subscription link", () => {
100
151
  return "2019-11-13T18:47:04.733Z";
101
152
  }));
102
153
  AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
103
- expect(url).toBe('wss://xxxxx.appsync-realtime-api.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoieHh4eHguYXBwc3luYy1hcGkuYW1hem9uYXdzLmNvbSJ9&payload=e30=');
154
+ expect(url).toBe('wss://cognitouserpooltesturl1234.appsync-realtime-api.us-west-2.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoiY29nbml0b3VzZXJwb29sdGVzdHVybDEyMzQuYXBwc3luYy1hcGkudXMtd2VzdC0yLmFtYXpvbmF3cy5jb20ifQ==&payload=e30=');
104
155
  expect(protocol).toBe('graphql-ws');
105
156
  done();
106
157
  return new myWebSocket();
@@ -110,13 +161,50 @@ describe("RealTime subscription link", () => {
110
161
  type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
111
162
  jwtToken: 'token'
112
163
  },
113
- region: 'us-east-1',
114
- url: 'https://xxxxx.appsync-api.amazonaws.com/graphql'
164
+ region: 'us-west-2',
165
+ url: 'https://cognitouserpooltesturl1234.appsync-api.us-west-2.amazonaws.com/graphql'
115
166
  });
116
167
 
117
168
  execute(link, { query }).subscribe({
118
169
  error: (err) => {
119
- console.log({ err });
170
+ console.log(JSON.stringify(err));
171
+ fail;
172
+ },
173
+ next: (data) => {
174
+ console.log({ data });
175
+ done();
176
+ },
177
+ complete: () => {
178
+ console.log('done with this');
179
+ done();
180
+ }
181
+
182
+ });
183
+ });
184
+
185
+ test("Initialize WebSocket correctly for COGNITO USER POOLS with custom domain", (done) => {
186
+ expect.assertions(2);
187
+ jest.spyOn(Date.prototype, 'toISOString').mockImplementation(jest.fn(() => {
188
+ return "2019-11-13T18:47:04.733Z";
189
+ }));
190
+ AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
191
+ expect(url).toBe('wss://cognitouserpools.testcustomdomain.com/graphql/realtime?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoiY29nbml0b3VzZXJwb29scy50ZXN0Y3VzdG9tZG9tYWluLmNvbSJ9&payload=e30=');
192
+ expect(protocol).toBe('graphql-ws');
193
+ done();
194
+ return new myWebSocket();
195
+ });
196
+ const link = new AppSyncRealTimeSubscriptionHandshakeLink({
197
+ auth: {
198
+ type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
199
+ jwtToken: 'token'
200
+ },
201
+ region: 'us-west-2',
202
+ url: 'https://cognitouserpools.testcustomdomain.com/graphql'
203
+ });
204
+
205
+ execute(link, { query }).subscribe({
206
+ error: (err) => {
207
+ console.log(JSON.stringify(err));
120
208
  fail;
121
209
  },
122
210
  next: (data) => {
@@ -137,7 +225,44 @@ describe("RealTime subscription link", () => {
137
225
  return "2019-11-13T18:47:04.733Z";
138
226
  }));
139
227
  AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
140
- expect(url).toBe('wss://xxxxx.appsync-realtime-api.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoieHh4eHguYXBwc3luYy1hcGkuYW1hem9uYXdzLmNvbSJ9&payload=e30=');
228
+ expect(url).toBe('wss://openidconnecttesturl123456.appsync-realtime-api.us-west-2.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0Ijoib3BlbmlkY29ubmVjdHRlc3R1cmwxMjM0NTYuYXBwc3luYy1hcGkudXMtd2VzdC0yLmFtYXpvbmF3cy5jb20ifQ==&payload=e30=');
229
+ expect(protocol).toBe('graphql-ws');
230
+ done();
231
+ return new myWebSocket();
232
+ });
233
+ const link = new AppSyncRealTimeSubscriptionHandshakeLink({
234
+ auth: {
235
+ type: AUTH_TYPE.OPENID_CONNECT,
236
+ jwtToken: 'token'
237
+ },
238
+ region: 'us-west-2',
239
+ url: 'https://openidconnecttesturl123456.appsync-api.us-west-2.amazonaws.com/graphql'
240
+ });
241
+
242
+ execute(link, { query }).subscribe({
243
+ error: (err) => {
244
+ console.log(JSON.stringify(err));
245
+ fail;
246
+ },
247
+ next: (data) => {
248
+ console.log({ data });
249
+ done();
250
+ },
251
+ complete: () => {
252
+ console.log('done with this');
253
+ done();
254
+ }
255
+
256
+ });
257
+ });
258
+
259
+ test("Initialize WebSocket correctly for OPENID_CONNECT with custom domain", (done) => {
260
+ expect.assertions(2);
261
+ jest.spyOn(Date.prototype, 'toISOString').mockImplementation(jest.fn(() => {
262
+ return "2019-11-13T18:47:04.733Z";
263
+ }));
264
+ AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
265
+ expect(url).toBe('wss://openidconnecttesturl.testcustomdomain.com/graphql/realtime?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0Ijoib3BlbmlkY29ubmVjdHRlc3R1cmwudGVzdGN1c3RvbWRvbWFpbi5jb20ifQ==&payload=e30=');
141
266
  expect(protocol).toBe('graphql-ws');
142
267
  done();
143
268
  return new myWebSocket();
@@ -147,13 +272,13 @@ describe("RealTime subscription link", () => {
147
272
  type: AUTH_TYPE.OPENID_CONNECT,
148
273
  jwtToken: 'token'
149
274
  },
150
- region: 'us-east-1',
151
- url: 'https://xxxxx.appsync-api.amazonaws.com/graphql'
275
+ region: 'us-west-2',
276
+ url: 'https://openidconnecttesturl.testcustomdomain.com/graphql'
152
277
  });
153
278
 
154
279
  execute(link, { query }).subscribe({
155
280
  error: (err) => {
156
- console.log({ err });
281
+ console.log(JSON.stringify(err));
157
282
  fail;
158
283
  },
159
284
  next: (data) => {
@@ -174,7 +299,41 @@ describe("RealTime subscription link", () => {
174
299
  return "2019-11-13T18:47:04.733Z";
175
300
  }));
176
301
  AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
177
- expect(url).toBe('wss://xxxxx.appsync-realtime-api.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoieHh4eHguYXBwc3luYy1hcGkuYW1hem9uYXdzLmNvbSJ9&payload=e30=');
302
+ expect(url).toBe('wss://awslambdatesturl1234567890.appsync-realtime-api.us-west-2.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoiYXdzbGFtYmRhdGVzdHVybDEyMzQ1Njc4OTAuYXBwc3luYy1hcGkudXMtd2VzdC0yLmFtYXpvbmF3cy5jb20ifQ==&payload=e30=');
303
+ expect(protocol).toBe('graphql-ws');
304
+ done();
305
+ return new myWebSocket();
306
+ });
307
+ const link = new AppSyncRealTimeSubscriptionHandshakeLink({
308
+ auth: {
309
+ type: AUTH_TYPE.AWS_LAMBDA,
310
+ token: 'token'
311
+ },
312
+ region: 'us-west-2',
313
+ url: 'https://awslambdatesturl1234567890.appsync-api.us-west-2.amazonaws.com/graphql'
314
+ });
315
+
316
+ execute(link, { query }).subscribe({
317
+ error: (err) => {
318
+ fail;
319
+ },
320
+ next: (data) => {
321
+ done();
322
+ },
323
+ complete: () => {
324
+ done();
325
+ }
326
+
327
+ });
328
+ })
329
+
330
+ test('Initialize WebSocket correctly for AWS_LAMBDA with custom domain', (done) => {
331
+ expect.assertions(2);
332
+ jest.spyOn(Date.prototype, 'toISOString').mockImplementation(jest.fn(() => {
333
+ return "2019-11-13T18:47:04.733Z";
334
+ }));
335
+ AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
336
+ expect(url).toBe('wss://awslambdatesturl.testcustomdomain.com/graphql/realtime?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoiYXdzbGFtYmRhdGVzdHVybC50ZXN0Y3VzdG9tZG9tYWluLmNvbSJ9&payload=e30=');
178
337
  expect(protocol).toBe('graphql-ws');
179
338
  done();
180
339
  return new myWebSocket();
@@ -184,8 +343,8 @@ describe("RealTime subscription link", () => {
184
343
  type: AUTH_TYPE.AWS_LAMBDA,
185
344
  token: 'token'
186
345
  },
187
- region: 'us-east-1',
188
- url: 'https://xxxxx.appsync-api.amazonaws.com/graphql'
346
+ region: 'us-west-2',
347
+ url: 'https://awslambdatesturl.testcustomdomain.com/graphql'
189
348
  });
190
349
 
191
350
  execute(link, { query }).subscribe({
@@ -9,7 +9,5 @@ export declare class NonTerminatingLink extends ApolloLink {
9
9
  constructor(contextKey: string, { link }: {
10
10
  link: ApolloLink;
11
11
  });
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>>>;
12
+ request(operation: any, forward?: NextLink): ReturnType<ApolloLink['request']>;
15
13
  }
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ * Copyright 2017-2021 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-link";
6
6
  import { UrlInfo } from "./types";
7
7
  export declare const CONTROL_EVENTS_KEY = "@@controlEvents";
8
8
  export declare class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink {
@@ -16,11 +16,14 @@ 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
+ private isCustomDomain;
20
+ request(operation: Operation): Observable<FetchResult<{
21
+ [key: string]: any;
22
+ }, Record<string, any>, Record<string, any>>>;
20
23
  private _verifySubscriptionAlreadyStarted;
21
24
  private _sendUnsubscriptionMessage;
22
25
  private _removeSubscriptionObserver;
23
- private _closeSocketWhenFlushed;
26
+ private _closeSocketIfRequired;
24
27
  private _startSubscriptionWithAWSAppSyncRealTime;
25
28
  private _initializeWebSocketConnection;
26
29
  private _awsRealTimeHeaderBasedAuth;
@@ -33,5 +36,4 @@ export declare class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink
33
36
  private _errorDisconnect;
34
37
  private _timeoutStartSubscriptionAck;
35
38
  static createWebSocket(awsRealTimeUrl: string, protocol: string): WebSocket;
36
- private static _discoverAppSyncRealTimeEndpoint;
37
39
  }
@@ -61,7 +61,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
61
61
  };
62
62
  Object.defineProperty(exports, "__esModule", { value: true });
63
63
  /*!
64
- * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
64
+ * Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
65
65
  * SPDX-License-Identifier: Apache-2.0
66
66
  */
67
67
  var apollo_link_1 = require("apollo-link");
@@ -77,9 +77,9 @@ exports.CONTROL_EVENTS_KEY = "@@controlEvents";
77
77
  var NON_RETRYABLE_CODES = [400, 401, 403];
78
78
  var SERVICE = "appsync";
79
79
  var APPSYNC_REALTIME_HEADERS = {
80
- accept: 'application/json, text/javascript',
81
- 'content-encoding': 'amz-1.0',
82
- 'content-type': 'application/json; charset=UTF-8'
80
+ accept: "application/json, text/javascript",
81
+ "content-encoding": "amz-1.0",
82
+ "content-type": "application/json; charset=UTF-8",
83
83
  };
84
84
  /**
85
85
  * Time in milliseconds to wait for GQL_CONNECTION_INIT message
@@ -93,6 +93,8 @@ var START_ACK_TIMEOUT = 15000;
93
93
  * Default Time in milliseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
94
94
  */
95
95
  var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
96
+ var standardDomainPattern = /^https:\/\/\w{26}\.appsync\-api\.\w{2}(?:(?:\-\w{2,})+)\-\d\.amazonaws.com\/graphql$/i;
97
+ var customDomainPath = '/realtime';
96
98
  var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super) {
97
99
  __extends(AppSyncRealTimeSubscriptionHandshakeLink, _super);
98
100
  function AppSyncRealTimeSubscriptionHandshakeLink(_a) {
@@ -107,6 +109,10 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
107
109
  _this.auth = theAuth;
108
110
  return _this;
109
111
  }
112
+ // Check if url matches standard domain pattern
113
+ AppSyncRealTimeSubscriptionHandshakeLink.prototype.isCustomDomain = function (url) {
114
+ return url.match(standardDomainPattern) === null;
115
+ };
110
116
  AppSyncRealTimeSubscriptionHandshakeLink.prototype.request = function (operation) {
111
117
  var _a;
112
118
  var _this = this;
@@ -129,22 +135,23 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
129
135
  _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.OPENID_CONNECT
130
136
  ? _this.auth.jwtToken
131
137
  : null;
132
- token = _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.AWS_LAMBDA ? _this.auth.token : token;
138
+ token =
139
+ _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.AWS_LAMBDA ? _this.auth.token : token;
133
140
  var options = {
134
141
  appSyncGraphqlEndpoint: _this.url,
135
142
  authenticationType: _this.auth.type,
136
143
  query: graphql_1.print(query),
137
144
  region: _this.region,
138
- graphql_headers: function () { return (headers); },
145
+ graphql_headers: function () { return headers; },
139
146
  variables: variables,
140
147
  apiKey: _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.API_KEY ? _this.auth.apiKey : "",
141
148
  credentials: _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.AWS_IAM ? _this.auth.credentials : null,
142
- token: token
149
+ token: token,
143
150
  };
144
151
  _this._startSubscriptionWithAWSAppSyncRealTime({
145
152
  options: options,
146
153
  observer: observer,
147
- subscriptionId: subscriptionId_1
154
+ subscriptionId: subscriptionId_1,
148
155
  });
149
156
  return function () { return __awaiter(_this, void 0, void 0, function () {
150
157
  var subscriptionState;
@@ -190,7 +197,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
190
197
  variables: variables,
191
198
  query: query,
192
199
  subscriptionReadyCallback: res,
193
- subscriptionFailedCallback: rej
200
+ subscriptionFailedCallback: rej,
194
201
  });
195
202
  })];
196
203
  }
@@ -206,7 +213,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
206
213
  // Preparing unsubscribe message to stop receiving messages for that subscription
207
214
  var unsubscribeMessage = {
208
215
  id: subscriptionId,
209
- type: types_1.MESSAGE_TYPES.GQL_STOP
216
+ type: types_1.MESSAGE_TYPES.GQL_STOP,
210
217
  };
211
218
  var stringToAWSRealTime = JSON.stringify(unsubscribeMessage);
212
219
  this.awsRealTimeSocket.send(stringToAWSRealTime);
@@ -220,22 +227,25 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
220
227
  };
221
228
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._removeSubscriptionObserver = function (subscriptionId) {
222
229
  this.subscriptionObserverMap.delete(subscriptionId);
223
- if (this.subscriptionObserverMap.size === 0) {
224
- // Socket could be sending data to unsubscribe so is required to wait until is flushed
225
- this._closeSocketWhenFlushed();
226
- }
230
+ // Verifying for 1000ms after removing subscription in case there are new subscriptions on mount / unmount
231
+ setTimeout(this._closeSocketIfRequired.bind(this), 1000);
227
232
  };
228
- AppSyncRealTimeSubscriptionHandshakeLink.prototype._closeSocketWhenFlushed = function () {
229
- logger("closing WebSocket...");
230
- clearTimeout(this.keepAliveTimeoutId);
233
+ AppSyncRealTimeSubscriptionHandshakeLink.prototype._closeSocketIfRequired = function () {
234
+ if (this.subscriptionObserverMap.size > 0) {
235
+ // There are active subscriptions on the WebSocket
236
+ return;
237
+ }
231
238
  if (!this.awsRealTimeSocket) {
232
239
  this.socketStatus = types_1.SOCKET_STATUS.CLOSED;
233
240
  return;
234
241
  }
235
242
  if (this.awsRealTimeSocket.bufferedAmount > 0) {
236
- setTimeout(this._closeSocketWhenFlushed.bind(this), 1000);
243
+ // There is still data on the WebSocket
244
+ setTimeout(this._closeSocketIfRequired.bind(this), 1000);
237
245
  }
238
246
  else {
247
+ logger("closing WebSocket...");
248
+ clearTimeout(this.keepAliveTimeoutId);
239
249
  var tempSocket = this.awsRealTimeSocket;
240
250
  tempSocket.close(1000);
241
251
  this.awsRealTimeSocket = null;
@@ -245,17 +255,17 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
245
255
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._startSubscriptionWithAWSAppSyncRealTime = function (_a) {
246
256
  var options = _a.options, observer = _a.observer, subscriptionId = _a.subscriptionId;
247
257
  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;
258
+ 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;
259
+ var _f;
250
260
  var _this = this;
251
- return __generator(this, function (_h) {
252
- switch (_h.label) {
261
+ return __generator(this, function (_g) {
262
+ switch (_g.label) {
253
263
  case 0:
254
264
  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
265
  subscriptionState = types_1.SUBSCRIPTION_STATUS.PENDING;
256
266
  data = {
257
267
  query: query,
258
- variables: variables
268
+ variables: variables,
259
269
  };
260
270
  // Having a subscription id map will make it simple to forward messages received
261
271
  this.subscriptionObserverMap.set(subscriptionId, {
@@ -275,45 +285,43 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
275
285
  canonicalUri: "",
276
286
  region: region,
277
287
  credentials: credentials,
278
- token: token
288
+ token: token,
289
+ graphql_headers: graphql_headers,
279
290
  })];
280
291
  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)]);
292
+ 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
293
  subscriptionMessage = {
286
294
  id: subscriptionId,
287
295
  payload: {
288
296
  data: dataString,
289
297
  extensions: {
290
- authorization: __assign({}, headerObj)
291
- }
298
+ authorization: __assign({}, headerObj),
299
+ },
292
300
  },
293
- type: types_1.MESSAGE_TYPES.GQL_START
301
+ type: types_1.MESSAGE_TYPES.GQL_START,
294
302
  };
295
303
  stringToAWSRealTime = JSON.stringify(subscriptionMessage);
296
- _h.label = 3;
297
- case 3:
298
- _h.trys.push([3, 5, , 6]);
304
+ _g.label = 2;
305
+ case 2:
306
+ _g.trys.push([2, 4, , 5]);
299
307
  return [4 /*yield*/, this._initializeWebSocketConnection({
300
308
  apiKey: apiKey,
301
309
  appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
302
310
  authenticationType: authenticationType,
303
311
  region: region,
304
312
  credentials: credentials,
305
- token: token
313
+ token: token,
306
314
  })];
315
+ case 3:
316
+ _g.sent();
317
+ return [3 /*break*/, 5];
307
318
  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;
319
+ err_1 = _g.sent();
320
+ _d = err_1.message, message = _d === void 0 ? "" : _d;
313
321
  observer.error({
314
322
  errors: [
315
- __assign({}, new graphql_1.GraphQLError("Connection failed: " + message))
316
- ]
323
+ __assign({}, new graphql_1.GraphQLError("Connection failed: " + message)),
324
+ ],
317
325
  });
318
326
  observer.complete();
319
327
  subscriptionFailedCallback_1 = (this.subscriptionObserverMap.get(subscriptionId) || {}).subscriptionFailedCallback;
@@ -322,8 +330,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
322
330
  subscriptionFailedCallback_1();
323
331
  }
324
332
  return [2 /*return*/];
325
- case 6:
326
- _f = this.subscriptionObserverMap.get(subscriptionId), subscriptionFailedCallback = _f.subscriptionFailedCallback, subscriptionReadyCallback = _f.subscriptionReadyCallback;
333
+ case 5:
334
+ _e = this.subscriptionObserverMap.get(subscriptionId), subscriptionFailedCallback = _e.subscriptionFailedCallback, subscriptionReadyCallback = _e.subscriptionReadyCallback;
327
335
  // This must be done before sending the message in order to be listening immediately
328
336
  this.subscriptionObserverMap.set(subscriptionId, {
329
337
  observer: observer,
@@ -334,7 +342,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
334
342
  subscriptionFailedCallback: subscriptionFailedCallback,
335
343
  startAckTimeoutId: setTimeout(function () {
336
344
  _this._timeoutStartSubscriptionAck.call(_this, subscriptionId);
337
- }, START_ACK_TIMEOUT)
345
+ }, START_ACK_TIMEOUT),
338
346
  });
339
347
  if (this.awsRealTimeSocket) {
340
348
  this.awsRealTimeSocket.send(stringToAWSRealTime);
@@ -351,7 +359,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
351
359
  return;
352
360
  }
353
361
  return new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
354
- var discoverableEndpoint, payloadString, headerString, _a, _b, headerQs, payloadQs, awsRealTimeUrl, err_2;
362
+ var payloadString, headerString, _a, _b, headerQs, payloadQs, discoverableEndpoint, awsRealTimeUrl, err_2;
355
363
  return __generator(this, function (_c) {
356
364
  switch (_c.label) {
357
365
  case 0:
@@ -361,7 +369,6 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
361
369
  case 1:
362
370
  _c.trys.push([1, 4, , 5]);
363
371
  this.socketStatus = types_1.SOCKET_STATUS.CONNECTING;
364
- discoverableEndpoint = AppSyncRealTimeSubscriptionHandshakeLink._discoverAppSyncRealTimeEndpoint(this.url);
365
372
  payloadString = "{}";
366
373
  _b = (_a = JSON).stringify;
367
374
  return [4 /*yield*/, this._awsRealTimeHeaderBasedAuth({
@@ -372,12 +379,23 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
372
379
  appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
373
380
  region: region,
374
381
  credentials: credentials,
375
- token: token
382
+ token: token,
383
+ graphql_headers: function () { },
376
384
  })];
377
385
  case 2:
378
386
  headerString = _b.apply(_a, [_c.sent()]);
379
387
  headerQs = Buffer.from(headerString).toString("base64");
380
388
  payloadQs = Buffer.from(payloadString).toString("base64");
389
+ discoverableEndpoint = appSyncGraphqlEndpoint;
390
+ if (this.isCustomDomain(discoverableEndpoint)) {
391
+ discoverableEndpoint = discoverableEndpoint.concat(customDomainPath);
392
+ }
393
+ else {
394
+ discoverableEndpoint = discoverableEndpoint.replace('appsync-api', 'appsync-realtime-api').replace('gogi-beta', 'grt-beta');
395
+ }
396
+ discoverableEndpoint = discoverableEndpoint
397
+ .replace("https://", "wss://")
398
+ .replace('http://', 'ws://');
381
399
  awsRealTimeUrl = discoverableEndpoint + "?header=" + headerQs + "&payload=" + payloadQs;
382
400
  return [4 /*yield*/, this._initializeRetryableHandshake({ awsRealTimeUrl: awsRealTimeUrl })];
383
401
  case 3:
@@ -410,7 +428,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
410
428
  }); });
411
429
  };
412
430
  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;
431
+ 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
432
  return __awaiter(this, void 0, void 0, function () {
415
433
  var headerHandler, handler, host, result;
416
434
  return __generator(this, function (_b) {
@@ -421,7 +439,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
421
439
  AWS_IAM: this._awsRealTimeIAMHeader.bind(this),
422
440
  OPENID_CONNECT: this._awsRealTimeAuthorizationHeader.bind(this),
423
441
  AMAZON_COGNITO_USER_POOLS: this._awsRealTimeAuthorizationHeader.bind(this),
424
- AWS_LAMBDA: this._awsRealTimeAuthorizationHeader.bind(this)
442
+ AWS_LAMBDA: this._awsRealTimeAuthorizationHeader.bind(this),
425
443
  };
426
444
  handler = headerHandler[authenticationType];
427
445
  if (typeof handler !== "function") {
@@ -437,7 +455,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
437
455
  region: region,
438
456
  host: host,
439
457
  credentials: credentials,
440
- token: token
458
+ token: token,
459
+ graphql_headers: graphql_headers,
441
460
  })];
442
461
  case 1:
443
462
  result = _b.sent();
@@ -447,41 +466,43 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
447
466
  });
448
467
  };
449
468
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._awsRealTimeAuthorizationHeader = function (_a) {
450
- var host = _a.host, token = _a.token;
469
+ var host = _a.host, token = _a.token, graphql_headers = _a.graphql_headers;
451
470
  return __awaiter(this, void 0, void 0, function () {
452
- var _b, _c;
453
- return __generator(this, function (_d) {
454
- switch (_d.label) {
471
+ var _b, _c, _d;
472
+ return __generator(this, function (_e) {
473
+ switch (_e.label) {
455
474
  case 0:
456
475
  _b = {};
457
476
  if (!(typeof token === "function")) return [3 /*break*/, 2];
458
477
  return [4 /*yield*/, token.call(undefined)];
459
478
  case 1:
460
- _c = _d.sent();
479
+ _c = _e.sent();
461
480
  return [3 /*break*/, 4];
462
481
  case 2: return [4 /*yield*/, token];
463
482
  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)];
483
+ _c = _e.sent();
484
+ _e.label = 4;
485
+ case 4:
486
+ _d = [(_b.Authorization = _c, _b.host = host, _b)];
487
+ return [4 /*yield*/, graphql_headers()];
488
+ case 5: return [2 /*return*/, __assign.apply(void 0, _d.concat([(_e.sent())]))];
469
489
  }
470
490
  });
471
491
  });
472
492
  };
473
493
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._awsRealTimeApiKeyHeader = function (_a) {
474
- var apiKey = _a.apiKey, host = _a.host;
494
+ var apiKey = _a.apiKey, host = _a.host, graphql_headers = _a.graphql_headers;
475
495
  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
- }];
496
+ var dt, dtStr, _b;
497
+ return __generator(this, function (_c) {
498
+ switch (_c.label) {
499
+ case 0:
500
+ dt = new Date();
501
+ dtStr = dt.toISOString().replace(/[:\-]|\.\d{3}/g, "");
502
+ _b = [{ host: host, "x-amz-date": dtStr, "x-api-key": apiKey }];
503
+ return [4 /*yield*/, graphql_headers()];
504
+ case 1: return [2 /*return*/, __assign.apply(void 0, _b.concat([(_c.sent())]))];
505
+ }
485
506
  });
486
507
  });
487
508
  };
@@ -494,7 +515,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
494
515
  case 0:
495
516
  endpointInfo = {
496
517
  region: region,
497
- service: SERVICE
518
+ service: SERVICE,
498
519
  };
499
520
  creds = typeof credentials === "function"
500
521
  ? credentials.call()
@@ -514,13 +535,13 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
514
535
  formattedCredentials = {
515
536
  access_key: accessKeyId,
516
537
  secret_key: secretAccessKey,
517
- session_token: sessionToken
538
+ session_token: sessionToken,
518
539
  };
519
540
  request = {
520
541
  url: "" + appSyncGraphqlEndpoint + canonicalUri,
521
542
  body: payload,
522
543
  method: "POST",
523
- headers: __assign({}, APPSYNC_REALTIME_HEADERS)
544
+ headers: __assign({}, APPSYNC_REALTIME_HEADERS),
524
545
  };
525
546
  signed_params = aws_appsync_auth_link_1.Signer.sign(request, formattedCredentials, endpointInfo);
526
547
  return [2 /*return*/, signed_params.headers];
@@ -536,7 +557,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
536
557
  case 0:
537
558
  logger("Initializaling retryable Handshake");
538
559
  return [4 /*yield*/, retry_1.jitteredExponentialRetry(this._initializeHandshake.bind(this), [
539
- { awsRealTimeUrl: awsRealTimeUrl }
560
+ { awsRealTimeUrl: awsRealTimeUrl },
540
561
  ])];
541
562
  case 1:
542
563
  _b.sent();
@@ -592,7 +613,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
592
613
  if (type === types_1.MESSAGE_TYPES.GQL_CONNECTION_ACK) {
593
614
  ackOk = true;
594
615
  _this.keepAliveTimeout = connectionTimeoutMs;
595
- _this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
616
+ _this.awsRealTimeSocket.onmessage =
617
+ _this._handleIncomingSubscriptionMessage.bind(_this);
596
618
  _this.awsRealTimeSocket.onerror = function (err) {
597
619
  logger(err);
598
620
  _this._errorDisconnect(types_1.CONTROL_MSG.CONNECTION_CLOSED);
@@ -610,7 +632,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
610
632
  }
611
633
  };
612
634
  var gqlInit = {
613
- type: types_1.MESSAGE_TYPES.GQL_CONNECTION_INIT
635
+ type: types_1.MESSAGE_TYPES.GQL_CONNECTION_INIT,
614
636
  };
615
637
  _this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
616
638
  function checkAckOk() {
@@ -667,8 +689,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
667
689
  observer.next({
668
690
  data: payload,
669
691
  extensions: {
670
- controlMsgType: "CONNECTED"
671
- }
692
+ controlMsgType: "CONNECTED",
693
+ },
672
694
  });
673
695
  }
674
696
  else {
@@ -682,7 +704,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
682
704
  startAckTimeoutId: null,
683
705
  subscriptionState: subscriptionState,
684
706
  subscriptionReadyCallback: subscriptionReadyCallback,
685
- subscriptionFailedCallback: subscriptionFailedCallback
707
+ subscriptionFailedCallback: subscriptionFailedCallback,
686
708
  });
687
709
  return;
688
710
  }
@@ -700,12 +722,12 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
700
722
  startAckTimeoutId: startAckTimeoutId,
701
723
  subscriptionReadyCallback: subscriptionReadyCallback,
702
724
  subscriptionFailedCallback: subscriptionFailedCallback,
703
- subscriptionState: subscriptionState
725
+ subscriptionState: subscriptionState,
704
726
  });
705
727
  observer.error({
706
728
  errors: [
707
- __assign({}, new graphql_1.GraphQLError("Connection failed: " + JSON.stringify(payload)))
708
- ]
729
+ __assign({}, new graphql_1.GraphQLError("Connection failed: " + JSON.stringify(payload))),
730
+ ],
709
731
  });
710
732
  clearTimeout(startAckTimeoutId);
711
733
  observer.complete();
@@ -739,13 +761,13 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
739
761
  observer: observer,
740
762
  query: query,
741
763
  variables: variables,
742
- subscriptionState: types_1.SUBSCRIPTION_STATUS.FAILED
764
+ subscriptionState: types_1.SUBSCRIPTION_STATUS.FAILED,
743
765
  });
744
766
  if (observer && !observer.closed) {
745
767
  observer.error({
746
768
  errors: [
747
- __assign({}, new graphql_1.GraphQLError("Subscription timeout " + JSON.stringify({ query: query, variables: variables })))
748
- ]
769
+ __assign({}, new graphql_1.GraphQLError("Subscription timeout " + JSON.stringify({ query: query, variables: variables }))),
770
+ ],
749
771
  });
750
772
  // Cleanup will be automatically executed
751
773
  observer.complete();
@@ -755,13 +777,6 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
755
777
  AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = function (awsRealTimeUrl, protocol) {
756
778
  return new WebSocket(awsRealTimeUrl, protocol);
757
779
  };
758
- AppSyncRealTimeSubscriptionHandshakeLink._discoverAppSyncRealTimeEndpoint = function (url) {
759
- return url
760
- .replace("https://", "wss://")
761
- .replace('http://', 'ws://')
762
- .replace("appsync-api", "appsync-realtime-api")
763
- .replace("gogi-beta", "grt-beta");
764
- };
765
780
  return AppSyncRealTimeSubscriptionHandshakeLink;
766
781
  }(apollo_link_1.ApolloLink));
767
782
  exports.AppSyncRealTimeSubscriptionHandshakeLink = AppSyncRealTimeSubscriptionHandshakeLink;
@@ -15,7 +15,7 @@ export declare class SubscriptionHandshakeLink extends ApolloLink {
15
15
  private topicObservers;
16
16
  private clientObservers;
17
17
  constructor(subsInfoContextKey: any);
18
- request(operation: Operation): Observable<any>;
18
+ request(operation: Operation): Observable<unknown>;
19
19
  connectNewClients(connectionInfo: MqttConnectionInfo[], observer: ZenObservable.Observer<FetchResult>, operation: Operation): Promise<any[]>;
20
20
  connectNewClient(connectionInfo: MqttConnectionInfo, observer: ZenObservable.Observer<FetchResult>, selectionNames: string[]): Promise<any>;
21
21
  subscribeToTopics<T>(client: any, topics: string[], observer: ZenObservable.Observer<T>): Promise<unknown[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-appsync-subscription-link",
3
- "version": "2.2.5",
3
+ "version": "2.3.0",
4
4
  "main": "lib/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "description": "AWS Mobile AppSync SDK for JavaScript",
@@ -23,12 +23,13 @@
23
23
  "apollo-link-context": "1.0.11",
24
24
  "apollo-link-http": "1.5.8",
25
25
  "apollo-link-retry": "2.2.7",
26
- "aws-appsync-auth-link": "^2.0.6",
26
+ "aws-appsync-auth-link": "^2.0.8",
27
27
  "debug": "2.6.9",
28
28
  "url": "^0.11.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@redux-offline/redux-offline": "2.5.2-native.0"
31
+ "@redux-offline/redux-offline": "2.5.2-native.0",
32
+ "apollo-client": "2.x"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "apollo-client": "2.x"