aws-appsync-subscription-link 3.0.7 → 3.0.10

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,38 @@
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="3.0.10"></a>
7
+ ## [3.0.10](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.9...aws-appsync-subscription-link@3.0.10) (2022-03-04)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * Port over Amplify fix for subscription race conditions ([#509](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/509)) ([#704](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/704)) ([92b50c4](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/92b50c4))
13
+
14
+
15
+
16
+
17
+ <a name="3.0.9"></a>
18
+ ## [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)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * 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))
24
+ * **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))
25
+ * 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))
26
+
27
+
28
+
29
+
30
+ <a name="3.0.8"></a>
31
+ ## [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)
32
+
33
+
34
+
35
+
36
+ **Note:** Version bump only for package aws-appsync-subscription-link
37
+
6
38
  <a name="3.0.7"></a>
7
39
  ## [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)
8
40
 
@@ -6,7 +6,7 @@ import { AppSyncRealTimeSubscriptionHandshakeLink } from '../../src/realtime-sub
6
6
  const query = gql`subscription { someSubscription { aField } }`
7
7
 
8
8
  class myWebSocket implements WebSocket {
9
- binaryType: BinaryType; bufferedAmount: number;
9
+ binaryType: BinaryType; bufferedAmount: number;
10
10
  extensions: string;
11
11
  onclose: (this: WebSocket, ev: CloseEvent) => any;
12
12
  onerror: (this: WebSocket, ev: Event) => any;
@@ -167,4 +167,38 @@ describe("RealTime subscription link", () => {
167
167
  });
168
168
  });
169
169
 
170
+ test('Initialize WebSocket correctly for AWS_LAMBDA', (done) => {
171
+ expect.assertions(2);
172
+ jest.spyOn(Date.prototype, 'toISOString').mockImplementation(jest.fn(() => {
173
+ return "2019-11-13T18:47:04.733Z";
174
+ }));
175
+ AppSyncRealTimeSubscriptionHandshakeLink.createWebSocket = jest.fn((url, protocol) => {
176
+ expect(url).toBe('wss://xxxxx.appsync-realtime-api.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoidG9rZW4iLCJob3N0IjoieHh4eHguYXBwc3luYy1hcGkuYW1hem9uYXdzLmNvbSJ9&payload=e30=');
177
+ expect(protocol).toBe('graphql-ws');
178
+ done();
179
+ return new myWebSocket();
180
+ });
181
+ const link = new AppSyncRealTimeSubscriptionHandshakeLink({
182
+ auth: {
183
+ type: AUTH_TYPE.AWS_LAMBDA,
184
+ token: 'token'
185
+ },
186
+ region: 'us-east-1',
187
+ url: 'https://xxxxx.appsync-api.amazonaws.com/graphql'
188
+ });
189
+
190
+ execute(link, { query }).subscribe({
191
+ error: (err) => {
192
+ fail;
193
+ },
194
+ next: (data) => {
195
+ done();
196
+ },
197
+ complete: () => {
198
+ done();
199
+ }
200
+
201
+ });
202
+ })
203
+
170
204
  });
package/lib/index.js CHANGED
@@ -28,7 +28,7 @@ function createSubscriptionHandshakeLink(infoOrUrl, theResultsFetcherLink) {
28
28
  link: new core_1.ApolloLink(function (operation, _forward) {
29
29
  return new core_1.Observable(function (observer) {
30
30
  var _a;
31
- var _b = operation.variables, _c = subscription_handshake_link_1.CONTROL_EVENTS_KEY, controlEvents = _b[_c], variables = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
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") {
33
33
  operation.variables = variables;
34
34
  }
@@ -2,12 +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/client/core';
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): any;
14
+ request(operation: any, forward?: NextLink): Observable<FetchResult>;
13
15
  }
@@ -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 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,7 +94,7 @@ 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
100
  }(core_1.ApolloLink));
@@ -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, Operation } from "@apollo/client/core";
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,15 +16,15 @@ 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): any;
19
+ request(operation: Operation): Observable<FetchResult<Record<string, any>, Record<string, any>, Record<string, any>>>;
20
20
  private _verifySubscriptionAlreadyStarted;
21
21
  private _sendUnsubscriptionMessage;
22
22
  private _removeSubscriptionObserver;
23
- private _closeSocketWhenFlushed;
23
+ private _closeSocketIfRequired;
24
24
  private _startSubscriptionWithAWSAppSyncRealTime;
25
25
  private _initializeWebSocketConnection;
26
26
  private _awsRealTimeHeaderBasedAuth;
27
- private _awsRealTimeOPENIDHeader;
27
+ private _awsRealTimeAuthorizationHeader;
28
28
  private _awsRealTimeApiKeyHeader;
29
29
  private _awsRealTimeIAMHeader;
30
30
  private _initializeRetryableHandshake;
@@ -125,6 +125,11 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
125
125
  }
126
126
  else {
127
127
  var subscriptionId_1 = uuid_1.v4();
128
+ var token = _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.AMAZON_COGNITO_USER_POOLS ||
129
+ _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.OPENID_CONNECT
130
+ ? _this.auth.jwtToken
131
+ : null;
132
+ token = _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.AWS_LAMBDA ? _this.auth.token : token;
128
133
  var options = {
129
134
  appSyncGraphqlEndpoint: _this.url,
130
135
  authenticationType: _this.auth.type,
@@ -134,10 +139,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
134
139
  variables: variables,
135
140
  apiKey: _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.API_KEY ? _this.auth.apiKey : "",
136
141
  credentials: _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.AWS_IAM ? _this.auth.credentials : null,
137
- jwtToken: _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.AMAZON_COGNITO_USER_POOLS ||
138
- _this.auth.type === aws_appsync_auth_link_1.AUTH_TYPE.OPENID_CONNECT
139
- ? _this.auth.jwtToken
140
- : null
142
+ token: token
141
143
  };
142
144
  _this._startSubscriptionWithAWSAppSyncRealTime({
143
145
  options: options,
@@ -218,22 +220,25 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
218
220
  };
219
221
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._removeSubscriptionObserver = function (subscriptionId) {
220
222
  this.subscriptionObserverMap.delete(subscriptionId);
221
- if (this.subscriptionObserverMap.size === 0) {
222
- // Socket could be sending data to unsubscribe so is required to wait until is flushed
223
- this._closeSocketWhenFlushed();
224
- }
223
+ // Verifying for 1000ms after removing subscription in case there are new subscriptions on mount / unmount
224
+ setTimeout(this._closeSocketIfRequired.bind(this), 1000);
225
225
  };
226
- AppSyncRealTimeSubscriptionHandshakeLink.prototype._closeSocketWhenFlushed = function () {
227
- logger("closing WebSocket...");
228
- clearTimeout(this.keepAliveTimeoutId);
226
+ AppSyncRealTimeSubscriptionHandshakeLink.prototype._closeSocketIfRequired = function () {
227
+ if (this.subscriptionObserverMap.size > 0) {
228
+ // There are active subscriptions on the WebSocket
229
+ return;
230
+ }
229
231
  if (!this.awsRealTimeSocket) {
230
232
  this.socketStatus = types_1.SOCKET_STATUS.CLOSED;
231
233
  return;
232
234
  }
233
235
  if (this.awsRealTimeSocket.bufferedAmount > 0) {
234
- setTimeout(this._closeSocketWhenFlushed.bind(this), 1000);
236
+ // There is still data on the WebSocket
237
+ setTimeout(this._closeSocketIfRequired.bind(this), 1000);
235
238
  }
236
239
  else {
240
+ logger("closing WebSocket...");
241
+ clearTimeout(this.keepAliveTimeoutId);
237
242
  var tempSocket = this.awsRealTimeSocket;
238
243
  tempSocket.close(1000);
239
244
  this.awsRealTimeSocket = null;
@@ -243,13 +248,13 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
243
248
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._startSubscriptionWithAWSAppSyncRealTime = function (_a) {
244
249
  var options = _a.options, observer = _a.observer, subscriptionId = _a.subscriptionId;
245
250
  return __awaiter(this, void 0, void 0, function () {
246
- var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _b, graphql_headers, credentials, jwtToken, subscriptionState, data, dataString, headerObj, _c, _d, subscriptionMessage, stringToAWSRealTime, err_1, _e, message, subscriptionFailedCallback_1, _f, subscriptionFailedCallback, subscriptionReadyCallback;
247
- var _g;
251
+ 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;
252
+ var _f;
248
253
  var _this = this;
249
- return __generator(this, function (_h) {
250
- switch (_h.label) {
254
+ return __generator(this, function (_g) {
255
+ switch (_g.label) {
251
256
  case 0:
252
- 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, jwtToken = options.jwtToken;
257
+ 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;
253
258
  subscriptionState = types_1.SUBSCRIPTION_STATUS.PENDING;
254
259
  data = {
255
260
  query: query,
@@ -273,13 +278,11 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
273
278
  canonicalUri: "",
274
279
  region: region,
275
280
  credentials: credentials,
276
- jwtToken: jwtToken
281
+ token: token,
282
+ graphql_headers: graphql_headers
277
283
  })];
278
284
  case 1:
279
- _d = [__assign.apply(void 0, _c.concat([(_h.sent())]))];
280
- return [4 /*yield*/, graphql_headers()];
281
- case 2:
282
- 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)]);
285
+ 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)]);
283
286
  subscriptionMessage = {
284
287
  id: subscriptionId,
285
288
  payload: {
@@ -291,23 +294,23 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
291
294
  type: types_1.MESSAGE_TYPES.GQL_START
292
295
  };
293
296
  stringToAWSRealTime = JSON.stringify(subscriptionMessage);
294
- _h.label = 3;
295
- case 3:
296
- _h.trys.push([3, 5, , 6]);
297
+ _g.label = 2;
298
+ case 2:
299
+ _g.trys.push([2, 4, , 5]);
297
300
  return [4 /*yield*/, this._initializeWebSocketConnection({
298
301
  apiKey: apiKey,
299
302
  appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
300
303
  authenticationType: authenticationType,
301
304
  region: region,
302
305
  credentials: credentials,
303
- jwtToken: jwtToken
306
+ token: token
304
307
  })];
308
+ case 3:
309
+ _g.sent();
310
+ return [3 /*break*/, 5];
305
311
  case 4:
306
- _h.sent();
307
- return [3 /*break*/, 6];
308
- case 5:
309
- err_1 = _h.sent();
310
- _e = err_1.message, message = _e === void 0 ? "" : _e;
312
+ err_1 = _g.sent();
313
+ _d = err_1.message, message = _d === void 0 ? "" : _d;
311
314
  observer.error({
312
315
  errors: [
313
316
  __assign({}, new graphql_1.GraphQLError("Connection failed: " + message))
@@ -320,8 +323,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
320
323
  subscriptionFailedCallback_1();
321
324
  }
322
325
  return [2 /*return*/];
323
- case 6:
324
- _f = this.subscriptionObserverMap.get(subscriptionId), subscriptionFailedCallback = _f.subscriptionFailedCallback, subscriptionReadyCallback = _f.subscriptionReadyCallback;
326
+ case 5:
327
+ _e = this.subscriptionObserverMap.get(subscriptionId), subscriptionFailedCallback = _e.subscriptionFailedCallback, subscriptionReadyCallback = _e.subscriptionReadyCallback;
325
328
  // This must be done before sending the message in order to be listening immediately
326
329
  this.subscriptionObserverMap.set(subscriptionId, {
327
330
  observer: observer,
@@ -344,7 +347,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
344
347
  };
345
348
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._initializeWebSocketConnection = function (_a) {
346
349
  var _this = this;
347
- var appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, authenticationType = _a.authenticationType, apiKey = _a.apiKey, region = _a.region, credentials = _a.credentials, jwtToken = _a.jwtToken;
350
+ var appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, authenticationType = _a.authenticationType, apiKey = _a.apiKey, region = _a.region, credentials = _a.credentials, token = _a.token;
348
351
  if (this.socketStatus === types_1.SOCKET_STATUS.READY) {
349
352
  return;
350
353
  }
@@ -370,7 +373,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
370
373
  appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
371
374
  region: region,
372
375
  credentials: credentials,
373
- jwtToken: jwtToken
376
+ token: token,
377
+ graphql_headers: function () { }
374
378
  })];
375
379
  case 2:
376
380
  headerString = _b.apply(_a, [_c.sent()]);
@@ -408,7 +412,7 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
408
412
  }); });
409
413
  };
410
414
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._awsRealTimeHeaderBasedAuth = function (_a) {
411
- var authenticationType = _a.authenticationType, payload = _a.payload, canonicalUri = _a.canonicalUri, appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, apiKey = _a.apiKey, region = _a.region, credentials = _a.credentials, jwtToken = _a.jwtToken;
415
+ 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;
412
416
  return __awaiter(this, void 0, void 0, function () {
413
417
  var headerHandler, handler, host, result;
414
418
  return __generator(this, function (_b) {
@@ -417,8 +421,9 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
417
421
  headerHandler = {
418
422
  API_KEY: this._awsRealTimeApiKeyHeader.bind(this),
419
423
  AWS_IAM: this._awsRealTimeIAMHeader.bind(this),
420
- OPENID_CONNECT: this._awsRealTimeOPENIDHeader.bind(this),
421
- AMAZON_COGNITO_USER_POOLS: this._awsRealTimeOPENIDHeader.bind(this)
424
+ OPENID_CONNECT: this._awsRealTimeAuthorizationHeader.bind(this),
425
+ AMAZON_COGNITO_USER_POOLS: this._awsRealTimeAuthorizationHeader.bind(this),
426
+ AWS_LAMBDA: this._awsRealTimeAuthorizationHeader.bind(this)
422
427
  };
423
428
  handler = headerHandler[authenticationType];
424
429
  if (typeof handler !== "function") {
@@ -434,7 +439,8 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
434
439
  region: region,
435
440
  host: host,
436
441
  credentials: credentials,
437
- jwtToken: jwtToken
442
+ token: token,
443
+ graphql_headers: graphql_headers
438
444
  })];
439
445
  case 1:
440
446
  result = _b.sent();
@@ -443,42 +449,44 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
443
449
  });
444
450
  });
445
451
  };
446
- AppSyncRealTimeSubscriptionHandshakeLink.prototype._awsRealTimeOPENIDHeader = function (_a) {
447
- var host = _a.host, jwtToken = _a.jwtToken;
452
+ AppSyncRealTimeSubscriptionHandshakeLink.prototype._awsRealTimeAuthorizationHeader = function (_a) {
453
+ var host = _a.host, token = _a.token, graphql_headers = _a.graphql_headers;
448
454
  return __awaiter(this, void 0, void 0, function () {
449
- var _b, _c;
450
- return __generator(this, function (_d) {
451
- switch (_d.label) {
455
+ var _b, _c, _d;
456
+ return __generator(this, function (_e) {
457
+ switch (_e.label) {
452
458
  case 0:
453
459
  _b = {};
454
- if (!(typeof jwtToken === "function")) return [3 /*break*/, 2];
455
- return [4 /*yield*/, jwtToken.call(undefined)];
460
+ if (!(typeof token === "function")) return [3 /*break*/, 2];
461
+ return [4 /*yield*/, token.call(undefined)];
456
462
  case 1:
457
- _c = _d.sent();
463
+ _c = _e.sent();
458
464
  return [3 /*break*/, 4];
459
- case 2: return [4 /*yield*/, jwtToken];
465
+ case 2: return [4 /*yield*/, token];
460
466
  case 3:
461
- _c = _d.sent();
462
- _d.label = 4;
463
- case 4: return [2 /*return*/, (_b.Authorization = _c,
464
- _b.host = host,
465
- _b)];
467
+ _c = _e.sent();
468
+ _e.label = 4;
469
+ case 4:
470
+ _d = [(_b.Authorization = _c, _b.host = host, _b)];
471
+ return [4 /*yield*/, graphql_headers()];
472
+ case 5: return [2 /*return*/, __assign.apply(void 0, _d.concat([(_e.sent())]))];
466
473
  }
467
474
  });
468
475
  });
469
476
  };
470
477
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._awsRealTimeApiKeyHeader = function (_a) {
471
- var apiKey = _a.apiKey, host = _a.host;
478
+ var apiKey = _a.apiKey, host = _a.host, graphql_headers = _a.graphql_headers;
472
479
  return __awaiter(this, void 0, void 0, function () {
473
- var dt, dtStr;
474
- return __generator(this, function (_b) {
475
- dt = new Date();
476
- dtStr = dt.toISOString().replace(/[:\-]|\.\d{3}/g, "");
477
- return [2 /*return*/, {
478
- host: host,
479
- "x-amz-date": dtStr,
480
- "x-api-key": apiKey
481
- }];
480
+ var dt, dtStr, _b;
481
+ return __generator(this, function (_c) {
482
+ switch (_c.label) {
483
+ case 0:
484
+ dt = new Date();
485
+ dtStr = dt.toISOString().replace(/[:\-]|\.\d{3}/g, "");
486
+ _b = [{ host: host, "x-amz-date": dtStr, "x-api-key": apiKey }];
487
+ return [4 /*yield*/, graphql_headers()];
488
+ case 1: return [2 /*return*/, __assign.apply(void 0, _b.concat([(_c.sent())]))];
489
+ }
482
490
  });
483
491
  });
484
492
  };
@@ -2,7 +2,7 @@
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, Operation, FetchResult } from "@apollo/client/core";
5
+ import { ApolloLink, Observable, Operation, FetchResult } from "@apollo/client/core";
6
6
  declare type MqttConnectionInfo = {
7
7
  client: string;
8
8
  url: string;
@@ -14,7 +14,7 @@ export declare class SubscriptionHandshakeLink extends ApolloLink {
14
14
  private topicObservers;
15
15
  private clientObservers;
16
16
  constructor(subsInfoContextKey: any);
17
- request(operation: Operation): any;
17
+ request(operation: Operation): Observable<unknown>;
18
18
  connectNewClients(connectionInfo: MqttConnectionInfo[], observer: ZenObservable.Observer<FetchResult>, operation: Operation): Promise<any[]>;
19
19
  connectNewClient(connectionInfo: MqttConnectionInfo, observer: ZenObservable.Observer<FetchResult>, selectionNames: string[]): Promise<any>;
20
20
  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": "3.0.7",
3
+ "version": "3.0.10",
4
4
  "main": "lib/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "description": "AWS Mobile AppSync SDK for JavaScript",
@@ -19,7 +19,7 @@
19
19
  "test-watch": "jest --watch"
20
20
  },
21
21
  "dependencies": {
22
- "aws-appsync-auth-link": "^3.0.5",
22
+ "aws-appsync-auth-link": "^3.0.7",
23
23
  "debug": "2.6.9",
24
24
  "url": "^0.11.0"
25
25
  },