@aws-amplify/api-graphql 2.2.13-unstable.4 → 2.2.13-unstable.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.
@@ -11346,7 +11346,7 @@ var __read = undefined && undefined.__read || function (o, n) {
11346
11346
  return ar;
11347
11347
  };
11348
11348
  /*
11349
- * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
11349
+ * Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
11350
11350
  *
11351
11351
  * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
11352
11352
  * the License. A copy of the License is located at
@@ -11482,6 +11482,8 @@ var START_ACK_TIMEOUT = 15000;
11482
11482
  */
11483
11483
 
11484
11484
  var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
11485
+ var standardDomainPattern = /^https:\/\/\w{26}\.appsync\-api\.\w{2}(?:(?:\-\w{2,})+)\-\d\.amazonaws.com\/graphql$/i;
11486
+ var customDomainPath = '/realtime';
11485
11487
 
11486
11488
  var AWSAppSyncRealTimeProvider =
11487
11489
  /** @class */
@@ -11512,6 +11514,11 @@ function (_super) {
11512
11514
  throw new Error('Operation not supported');
11513
11515
  });
11514
11516
  });
11517
+ }; // Check if url matches standard domain pattern
11518
+
11519
+
11520
+ AWSAppSyncRealTimeProvider.prototype.isCustomDomain = function (url) {
11521
+ return url.match(standardDomainPattern) === null;
11515
11522
  };
11516
11523
 
11517
11524
  AWSAppSyncRealTimeProvider.prototype.subscribe = function (_topics, options) {
@@ -11994,7 +12001,7 @@ function (_super) {
11994
12001
 
11995
12002
  return new Promise(function (res, rej) {
11996
12003
  return __awaiter(_this, void 0, void 0, function () {
11997
- var protocol, discoverableEndpoint, payloadString, headerString, _a, _b, headerQs, payloadQs, awsRealTimeUrl, err_3;
12004
+ var payloadString, headerString, _a, _b, headerQs, payloadQs, discoverableEndpoint, protocol, awsRealTimeUrl, err_3;
11998
12005
 
11999
12006
  return __generator(this, function (_c) {
12000
12007
  switch (_c.label) {
@@ -12012,8 +12019,6 @@ function (_super) {
12012
12019
  _c.trys.push([1, 4,, 5]);
12013
12020
 
12014
12021
  this.socketStatus = SOCKET_STATUS.CONNECTING;
12015
- protocol = this.isSSLEnabled ? 'wss://' : 'ws://';
12016
- discoverableEndpoint = appSyncGraphqlEndpoint.replace('https://', protocol).replace('http://', protocol).replace('appsync-api', 'appsync-realtime-api').replace('gogi-beta', 'grt-beta');
12017
12022
  payloadString = '{}';
12018
12023
  _b = (_a = JSON).stringify;
12019
12024
  return [4
@@ -12032,6 +12037,16 @@ function (_super) {
12032
12037
  headerString = _b.apply(_a, [_c.sent()]);
12033
12038
  headerQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(headerString).toString('base64');
12034
12039
  payloadQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(payloadString).toString('base64');
12040
+ discoverableEndpoint = appSyncGraphqlEndpoint;
12041
+
12042
+ if (this.isCustomDomain(discoverableEndpoint)) {
12043
+ discoverableEndpoint = discoverableEndpoint.concat(customDomainPath);
12044
+ } else {
12045
+ discoverableEndpoint = discoverableEndpoint.replace('appsync-api', 'appsync-realtime-api').replace('gogi-beta', 'grt-beta');
12046
+ }
12047
+
12048
+ protocol = this.isSSLEnabled ? 'wss://' : 'ws://';
12049
+ discoverableEndpoint = discoverableEndpoint.replace('https://', protocol).replace('http://', protocol);
12035
12050
  awsRealTimeUrl = discoverableEndpoint + "?header=" + headerQs + "&payload=" + payloadQs;
12036
12051
  return [4
12037
12052
  /*yield*/