@aws-amplify/api-graphql 4.9.1-unstable-d8f5356-20260918081218 → 4.10.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.
@@ -92,6 +92,19 @@ class AWSWebSocketProvider {
92
92
  subscribe(options, customUserAgentDetails) {
93
93
  return new rxjs_1.Observable(observer => {
94
94
  if (!options?.appSyncGraphqlEndpoint) {
95
+ // This guard fires ONLY for a MISSING/empty endpoint. For the Events
96
+ // layer it is effectively unreachable: events.connect() connects
97
+ // EAGERLY (awaited before any subscribe), and a missing endpoint fails
98
+ // there in getRealtimeEndpointUrl -> new AmplifyUrl(''), so connect()
99
+ // rejects and no channel is ever returned to subscribe on. Note
100
+ // configure() does NOT reject a missing endpoint: it only throws when
101
+ // the whole API.Events block is absent. We don't surface
102
+ // onSubscriptionError here (no subscriptionId exists yet), and an
103
+ // empty-id callback would be misleading; if this branch ever became
104
+ // reachable it would leave `ready` pending (there is no built-in
105
+ // timeout). An INVALID (present) endpoint is a DIFFERENT path: it passes
106
+ // this guard, fails later in _connectWebSocket, and DOES reject `ready`
107
+ // via _logStartSubscriptionError.
95
108
  observer.error({
96
109
  errors: [
97
110
  {
@@ -286,6 +299,8 @@ class AWSWebSocketProvider {
286
299
  query: query ?? '',
287
300
  variables: variables ?? {},
288
301
  subscriptionState: constants_1.SUBSCRIPTION_STATUS.PENDING,
302
+ onSubscriptionReady: options.onSubscriptionReady,
303
+ onSubscriptionError: options.onSubscriptionError,
289
304
  startAckTimeoutId: undefined,
290
305
  });
291
306
  const { additionalCustomHeaders, libraryConfigHeaders } = await (0, appsyncUrl_1.additionalHeadersFromOptions)(options);
@@ -315,6 +330,8 @@ class AWSWebSocketProvider {
315
330
  variables: variables ?? {},
316
331
  subscriptionReadyCallback,
317
332
  subscriptionFailedCallback,
333
+ onSubscriptionReady: options.onSubscriptionReady,
334
+ onSubscriptionError: options.onSubscriptionError,
318
335
  startAckTimeoutId: setTimeout(() => {
319
336
  this._timeoutStartSubscriptionAck(subscriptionId);
320
337
  }, constants_1.START_ACK_TIMEOUT),
@@ -331,6 +348,22 @@ class AWSWebSocketProvider {
331
348
  this._closeSocket();
332
349
  // Capture the error only when the network didn't cause disruption
333
350
  if (this.connectionState !== PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork) {
351
+ const { onSubscriptionError } = this.subscriptionObserverMap.get(subscriptionId) || {};
352
+ // Surface the connect failure to the caller's `ready` promise BEFORE
353
+ // observer.error(...) so the real error wins the settle race: rxjs's
354
+ // Subscriber.error() synchronously unsubscribes, which the events layer
355
+ // would otherwise turn into a generic `ready` rejection (see
356
+ // internals/events/index.ts). Only onSubscriptionError is hoisted here;
357
+ // subscriptionFailedCallback is read and invoked AFTER observer.error
358
+ // (below), because on this connect-init failure path the subscription is
359
+ // still PENDING and subscriptionFailedCallback is not yet set. rxjs's
360
+ // synchronous teardown inside observer.error() runs
361
+ // _waitForSubscriptionToBeConnected, which re-points
362
+ // subscriptionFailedCallback to its own promise's reject; invoking it
363
+ // afterward drives that internal unsubscribe-during-connect self-heal so
364
+ // _removeSubscriptionObserver runs and the subscriptionObserverMap entry
365
+ // does not leak.
366
+ onSubscriptionError?.(subscriptionId, new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${message}`));
334
367
  // When the error is non-retriable, error out the observable
335
368
  if ((0, utils_1.isNonRetryableError)(err)) {
336
369
  observer.error({
@@ -344,8 +377,12 @@ class AWSWebSocketProvider {
344
377
  else {
345
378
  this.logger.debug(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${message}`);
346
379
  }
380
+ // Notify concurrent unsubscription. Re-read the map here (not above)
381
+ // because observer.error()'s synchronous teardown may have re-pointed
382
+ // subscriptionFailedCallback to _waitForSubscriptionToBeConnected's
383
+ // reject; picking it up now self-heals the unsubscribe-during-connect
384
+ // race and lets _removeSubscriptionObserver clean up.
347
385
  const { subscriptionFailedCallback } = this.subscriptionObserverMap.get(subscriptionId) || {};
348
- // Notify concurrent unsubscription
349
386
  if (typeof subscriptionFailedCallback === 'function') {
350
387
  subscriptionFailedCallback();
351
388
  }
@@ -449,30 +486,33 @@ class AWSWebSocketProvider {
449
486
  return;
450
487
  }
451
488
  const { type, id, payload } = data;
452
- const { observer = null, query = '', variables = {}, startAckTimeoutId, subscriptionReadyCallback, subscriptionFailedCallback, } = this.subscriptionObserverMap.get(id) || {};
489
+ const { observer = null, query = '', variables = {}, startAckTimeoutId, subscriptionReadyCallback, subscriptionFailedCallback, onSubscriptionReady, onSubscriptionError, } = this.subscriptionObserverMap.get(id) || {};
453
490
  if (type === constants_1.MESSAGE_TYPES.GQL_START_ACK ||
454
491
  type === constants_1.MESSAGE_TYPES.EVENT_SUBSCRIBE_ACK) {
455
492
  this.logger.debug(`subscription ready for ${JSON.stringify({ query, variables })}`);
456
493
  if (typeof subscriptionReadyCallback === 'function') {
457
494
  subscriptionReadyCallback();
458
495
  }
496
+ onSubscriptionReady?.(id);
459
497
  if (startAckTimeoutId)
460
498
  clearTimeout(startAckTimeoutId);
461
499
  dispatchApiEvent({
462
500
  event: PubSub_1.CONTROL_MSG.SUBSCRIPTION_ACK,
463
- data: { query, variables },
501
+ data: { id, query, variables },
464
502
  message: 'Connection established for subscription',
465
503
  });
466
504
  const subscriptionState = constants_1.SUBSCRIPTION_STATUS.CONNECTED;
467
505
  if (observer) {
506
+ const existing = this.subscriptionObserverMap.get(id);
468
507
  this.subscriptionObserverMap.set(id, {
508
+ ...existing,
469
509
  observer,
470
510
  query,
471
511
  variables,
472
- startAckTimeoutId: undefined,
473
512
  subscriptionState,
474
513
  subscriptionReadyCallback,
475
514
  subscriptionFailedCallback,
515
+ startAckTimeoutId: undefined,
476
516
  });
477
517
  }
478
518
  this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CONNECTION_ESTABLISHED);
@@ -486,7 +526,9 @@ class AWSWebSocketProvider {
486
526
  type === constants_1.MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {
487
527
  const subscriptionState = constants_1.SUBSCRIPTION_STATUS.FAILED;
488
528
  if (observer) {
529
+ const existing = this.subscriptionObserverMap.get(id);
489
530
  this.subscriptionObserverMap.set(id, {
531
+ ...existing,
490
532
  observer,
491
533
  query,
492
534
  variables,
@@ -539,6 +581,13 @@ class AWSWebSocketProvider {
539
581
  this.logger.warn('Subscription failed due to auth error, closing WebSocket to trigger reconnection with fresh tokens');
540
582
  this.awsRealTimeSocket.close(1000, 'Auth error - reconnecting');
541
583
  }
584
+ // Surface the real subscription error to the caller's `ready`
585
+ // promise BEFORE observer.error(...). rxjs's Subscriber.error()
586
+ // synchronously calls this.unsubscribe(); if onSubscriptionError ran
587
+ // after observer.error, the events layer's caller-unsubscribe
588
+ // fallback could settle `ready` first with a generic reason and mask
589
+ // this real error. onSubscriptionError must win that race.
590
+ onSubscriptionError?.(id, new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`));
542
591
  observer.error({
543
592
  errors: [
544
593
  {
@@ -572,16 +621,19 @@ class AWSWebSocketProvider {
572
621
  _timeoutStartSubscriptionAck(subscriptionId) {
573
622
  const subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
574
623
  if (subscriptionObserver) {
575
- const { observer, query, variables } = subscriptionObserver;
624
+ const { observer, query, variables, onSubscriptionError } = subscriptionObserver;
576
625
  if (!observer) {
577
626
  return;
578
627
  }
579
628
  this.subscriptionObserverMap.set(subscriptionId, {
629
+ ...subscriptionObserver,
580
630
  observer,
581
631
  query,
582
632
  variables,
583
633
  subscriptionState: constants_1.SUBSCRIPTION_STATUS.FAILED,
634
+ startAckTimeoutId: undefined,
584
635
  });
636
+ onSubscriptionError?.(subscriptionId, new Error('Subscription start ack timeout'));
585
637
  this._closeSocket();
586
638
  this.logger.debug('timeoutStartSubscription', JSON.stringify({ query, variables }));
587
639
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/Providers/AWSWebSocketProvider/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AWSWebSocketProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst rxjs_1 = require(\"rxjs\");\nconst graphql_1 = require(\"graphql\");\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst PubSub_1 = require(\"../../types/PubSub\");\nconst constants_1 = require(\"../constants\");\nconst ConnectionStateMonitor_1 = require(\"../../utils/ConnectionStateMonitor\");\nconst ReconnectionMonitor_1 = require(\"../../utils/ReconnectionMonitor\");\nconst appsyncUrl_1 = require(\"./appsyncUrl\");\nconst authHeaders_1 = require(\"./authHeaders\");\nconst dispatchApiEvent = (payload) => {\n core_1.Hub.dispatch('api', payload, 'PubSub', constants_1.AMPLIFY_SYMBOL);\n};\nclass AWSWebSocketProvider {\n constructor(args) {\n this.subscriptionObserverMap = new Map();\n this.allowNoSubscriptions = false;\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n this.keepAliveTimestamp = Date.now();\n this.promiseArray = [];\n this.connectionStateMonitor = new ConnectionStateMonitor_1.ConnectionStateMonitor();\n this.reconnectionMonitor = new ReconnectionMonitor_1.ReconnectionMonitor();\n /**\n * Open WebSocket connection & perform handshake\n * Ref: https://docs.aws.amazon.com/appsync/latest/devguide/real-time-websocket-client.html#appsynclong-real-time-websocket-client-implementation-guide-for-graphql-subscriptions\n *\n * @param subprotocol -\n */\n this._establishConnection = async (awsRealTimeUrl, subprotocol) => {\n this.logger.debug(`Establishing WebSocket connection to ${awsRealTimeUrl}`);\n try {\n await this._openConnection(awsRealTimeUrl, subprotocol);\n await this._initiateHandshake();\n }\n catch (err) {\n const { errorType, errorCode } = err;\n if (constants_1.NON_RETRYABLE_CODES.includes(errorCode) ||\n // Event API does not currently return `errorCode`. This may change in the future.\n // For now fall back to also checking known non-retryable error types\n constants_1.NON_RETRYABLE_ERROR_TYPES.includes(errorType)) {\n throw new utils_1.NonRetryableError(errorType);\n }\n else if (errorType) {\n throw new Error(errorType);\n }\n else {\n throw err;\n }\n }\n };\n this.logger = new core_1.ConsoleLogger(args.providerName);\n this.wsProtocolName = args.wsProtocolName;\n this.wsConnectUri = args.connectUri;\n this.connectionStateMonitorSubscription =\n this._startConnectionStateMonitoring();\n }\n /**\n * Mark the socket closed and release all active listeners\n */\n close() {\n // Mark the socket closed both in status and the connection monitor\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CONNECTION_FAILED);\n // Turn off the subscription monitor Hub publishing\n this.connectionStateMonitorSubscription.unsubscribe();\n // Complete all reconnect observers\n this.reconnectionMonitor.close();\n return new Promise((resolve, reject) => {\n if (this.awsRealTimeSocket) {\n this.awsRealTimeSocket.onclose = (_) => {\n this._closeSocket();\n this.subscriptionObserverMap = new Map();\n this.awsRealTimeSocket = undefined;\n resolve();\n };\n this.awsRealTimeSocket.onerror = (err) => {\n reject(err);\n };\n this.awsRealTimeSocket.close();\n }\n else {\n resolve();\n }\n });\n }\n subscribe(options, customUserAgentDetails) {\n return new rxjs_1.Observable(observer => {\n if (!options?.appSyncGraphqlEndpoint) {\n observer.error({\n errors: [\n {\n ...new graphql_1.GraphQLError(`Subscribe only available for AWS AppSync endpoint`),\n },\n ],\n });\n observer.complete();\n return;\n }\n let subscriptionStartInProgress = false;\n const subscriptionId = (0, utils_1.amplifyUuid)();\n const startSubscription = () => {\n if (!subscriptionStartInProgress) {\n subscriptionStartInProgress = true;\n this._startSubscriptionWithAWSAppSyncRealTime({\n options,\n observer,\n subscriptionId,\n customUserAgentDetails,\n })\n .catch(err => {\n this.logger.debug(`${PubSub_1.CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR}: ${err}`);\n this._closeSocket();\n })\n .finally(() => {\n subscriptionStartInProgress = false;\n });\n }\n };\n // Add an observable to the reconnection list to manage reconnection for this subscription\n const reconnectSubscription = new rxjs_1.Observable(reconnectSubscriptionObserver => {\n this.reconnectionMonitor.addObserver(reconnectSubscriptionObserver);\n }).subscribe(() => {\n startSubscription();\n });\n startSubscription();\n return async () => {\n await this._cleanupSubscription(subscriptionId, reconnectSubscription);\n };\n });\n }\n async connect(options) {\n if (this.socketStatus === constants_1.SOCKET_STATUS.READY) {\n return;\n }\n await this._connectWebSocket(options);\n }\n async publish(options, customUserAgentDetails) {\n if (this.socketStatus !== constants_1.SOCKET_STATUS.READY) {\n throw new Error('Subscription has not been initialized');\n }\n return this._publishMessage(options, customUserAgentDetails);\n }\n async _connectWebSocket(options) {\n const { apiKey, appSyncGraphqlEndpoint, authenticationType, region, ctx } = options;\n const { additionalCustomHeaders } = await (0, appsyncUrl_1.additionalHeadersFromOptions)(options);\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.OPENING_CONNECTION);\n await this._initializeWebSocketConnection({\n apiKey,\n appSyncGraphqlEndpoint,\n authenticationType,\n region,\n additionalCustomHeaders,\n ctx,\n });\n }\n async _publishMessage(options, customUserAgentDetails) {\n const subscriptionId = (0, utils_1.amplifyUuid)();\n const { additionalCustomHeaders, libraryConfigHeaders } = await (0, appsyncUrl_1.additionalHeadersFromOptions)(options);\n const serializedSubscriptionMessage = await this._prepareSubscriptionPayload({\n options,\n subscriptionId,\n customUserAgentDetails,\n additionalCustomHeaders,\n libraryConfigHeaders,\n publish: true,\n });\n return new Promise((resolve, reject) => {\n if (this.awsRealTimeSocket) {\n const publishListener = (event) => {\n const data = JSON.parse(event.data);\n if (data.id === subscriptionId && data.type === 'publish_success') {\n this.awsRealTimeSocket &&\n this.awsRealTimeSocket.removeEventListener('message', publishListener);\n cleanup();\n resolve();\n }\n if (data.errors && data.errors.length > 0) {\n // Only reject on the terminal `publish_error` frame correlated to\n // THIS publish's operation id. AppSync Events guarantees that every\n // publish response frame (`publish_success`/`publish_error`) carries\n // the operation `id`, so error frames are correlated by `id` exactly\n // like the `publish_success` branch above, and the `data.type` gate\n // mirrors that branch's specificity. The socket is multiplexed, so an\n // error frame (e.g. a `subscribe_error`) can belong to an unrelated\n // operation on another channel; likewise an uncorrelated or id-less\n // error frame is not this publish's response. Such frames are\n // intentionally ignored for this publish and must not settle its\n // promise.\n if (data.id !== subscriptionId || data.type !== 'publish_error') {\n return;\n }\n const errorTypes = data.errors.map((error) => error.errorType);\n cleanup();\n reject(new Error(`Publish errors: ${errorTypes.join(', ')}`));\n }\n };\n const errorListener = (error) => {\n cleanup();\n reject(new Error(`WebSocket error: ${error}`));\n };\n const closeListener = () => {\n cleanup();\n reject(new Error('WebSocket is closed'));\n };\n const cleanup = () => {\n this.awsRealTimeSocket?.removeEventListener('message', publishListener);\n this.awsRealTimeSocket?.removeEventListener('error', errorListener);\n this.awsRealTimeSocket?.removeEventListener('close', closeListener);\n };\n this.awsRealTimeSocket.addEventListener('message', publishListener);\n this.awsRealTimeSocket.addEventListener('error', errorListener);\n this.awsRealTimeSocket.addEventListener('close', closeListener);\n this.awsRealTimeSocket.send(serializedSubscriptionMessage);\n }\n else {\n reject(new Error('WebSocket is not connected'));\n }\n });\n }\n async _cleanupSubscription(subscriptionId, reconnectSubscription) {\n // Cleanup reconnection subscription\n reconnectSubscription?.unsubscribe();\n // Cleanup after unsubscribing or observer.complete was called after _startSubscriptionWithAWSAppSyncRealTime\n try {\n // Waiting that subscription has been connected before trying to unsubscribe\n await this._waitForSubscriptionToBeConnected(subscriptionId);\n const { subscriptionState } = this.subscriptionObserverMap.get(subscriptionId) || {};\n if (!subscriptionState) {\n // subscription already unsubscribed\n return;\n }\n if (subscriptionState === constants_1.SUBSCRIPTION_STATUS.CONNECTED) {\n this._sendUnsubscriptionMessage(subscriptionId);\n }\n else {\n throw new Error('Subscription never connected');\n }\n }\n catch (err) {\n this.logger.debug(`Error while unsubscribing ${err}`);\n }\n finally {\n this._removeSubscriptionObserver(subscriptionId);\n }\n }\n // Monitor the connection state and pass changes along to Hub\n _startConnectionStateMonitoring() {\n return this.connectionStateMonitor.connectionStateObservable.subscribe(connectionState => {\n dispatchApiEvent({\n event: constants_1.CONNECTION_STATE_CHANGE,\n data: {\n provider: this,\n connectionState,\n },\n message: `Connection state is ${connectionState}`,\n });\n this.connectionState = connectionState;\n // Trigger START_RECONNECT when the connection is disrupted\n if (connectionState === PubSub_1.ConnectionState.ConnectionDisrupted) {\n this.reconnectionMonitor.record(ReconnectionMonitor_1.ReconnectEvent.START_RECONNECT);\n }\n // Trigger HALT_RECONNECT to halt reconnection attempts when the state is anything other than\n // ConnectionDisrupted or Connecting\n if ([\n PubSub_1.ConnectionState.Connected,\n PubSub_1.ConnectionState.ConnectedPendingDisconnect,\n PubSub_1.ConnectionState.ConnectedPendingKeepAlive,\n PubSub_1.ConnectionState.ConnectedPendingNetwork,\n PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork,\n PubSub_1.ConnectionState.Disconnected,\n ].includes(connectionState)) {\n this.reconnectionMonitor.record(ReconnectionMonitor_1.ReconnectEvent.HALT_RECONNECT);\n }\n });\n }\n async _startSubscriptionWithAWSAppSyncRealTime({ options, observer, subscriptionId, customUserAgentDetails, }) {\n const { query, variables } = options;\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n query: query ?? '',\n variables: variables ?? {},\n subscriptionState: constants_1.SUBSCRIPTION_STATUS.PENDING,\n startAckTimeoutId: undefined,\n });\n const { additionalCustomHeaders, libraryConfigHeaders } = await (0, appsyncUrl_1.additionalHeadersFromOptions)(options);\n const serializedSubscriptionMessage = await this._prepareSubscriptionPayload({\n options,\n subscriptionId,\n customUserAgentDetails,\n additionalCustomHeaders,\n libraryConfigHeaders,\n });\n try {\n await this._connectWebSocket(options);\n }\n catch (err) {\n this._logStartSubscriptionError(subscriptionId, observer, err);\n return;\n }\n // Potential race condition can occur when unsubscribe is called during _initializeWebSocketConnection.\n // E.g.unsubscribe gets invoked prior to finishing WebSocket handshake or START_ACK.\n // Both subscriptionFailedCallback and subscriptionReadyCallback are used to synchronized this.\n const { subscriptionFailedCallback, subscriptionReadyCallback } = this.subscriptionObserverMap.get(subscriptionId) ?? {};\n // This must be done before sending the message in order to be listening immediately\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n subscriptionState: constants_1.SUBSCRIPTION_STATUS.PENDING,\n query: query ?? '',\n variables: variables ?? {},\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n startAckTimeoutId: setTimeout(() => {\n this._timeoutStartSubscriptionAck(subscriptionId);\n }, constants_1.START_ACK_TIMEOUT),\n });\n if (this.awsRealTimeSocket) {\n this.awsRealTimeSocket.send(serializedSubscriptionMessage);\n }\n }\n // Log logic for start subscription failures\n _logStartSubscriptionError(subscriptionId, observer, err) {\n this.logger.debug({ err });\n const message = String(err.message ?? '');\n // Resolving to give the state observer time to propogate the update\n this._closeSocket();\n // Capture the error only when the network didn't cause disruption\n if (this.connectionState !== PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork) {\n // When the error is non-retriable, error out the observable\n if ((0, utils_1.isNonRetryableError)(err)) {\n observer.error({\n errors: [\n {\n ...new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${message}`),\n },\n ],\n });\n }\n else {\n this.logger.debug(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${message}`);\n }\n const { subscriptionFailedCallback } = this.subscriptionObserverMap.get(subscriptionId) || {};\n // Notify concurrent unsubscription\n if (typeof subscriptionFailedCallback === 'function') {\n subscriptionFailedCallback();\n }\n }\n }\n // Waiting that subscription has been connected before trying to unsubscribe\n async _waitForSubscriptionToBeConnected(subscriptionId) {\n const subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);\n if (subscriptionObserver) {\n const { subscriptionState } = subscriptionObserver;\n // This in case unsubscribe is invoked before sending start subscription message\n if (subscriptionState === constants_1.SUBSCRIPTION_STATUS.PENDING) {\n return new Promise((resolve, reject) => {\n const { observer, subscriptionState: observedSubscriptionState, variables, query, } = subscriptionObserver;\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n subscriptionState: observedSubscriptionState,\n variables,\n query,\n subscriptionReadyCallback: resolve,\n subscriptionFailedCallback: reject,\n });\n });\n }\n }\n }\n _sendUnsubscriptionMessage(subscriptionId) {\n try {\n if (this.awsRealTimeSocket &&\n this.awsRealTimeSocket.readyState === WebSocket.OPEN &&\n this.socketStatus === constants_1.SOCKET_STATUS.READY) {\n // Preparing unsubscribe message to stop receiving messages for that subscription\n const unsubscribeMessage = this._unsubscribeMessage(subscriptionId);\n const stringToAWSRealTime = JSON.stringify(unsubscribeMessage);\n this.awsRealTimeSocket.send(stringToAWSRealTime);\n }\n }\n catch (err) {\n // If GQL_STOP is not sent because of disconnection issue, then there is nothing the client can do\n this.logger.debug({ err });\n }\n }\n _removeSubscriptionObserver(subscriptionId) {\n this.subscriptionObserverMap.delete(subscriptionId);\n // Verifying 1000ms after removing subscription in case there are new subscription unmount/mount\n if (!this.allowNoSubscriptions) {\n setTimeout(this._closeSocketIfRequired.bind(this), 1000);\n }\n }\n _closeSocketIfRequired() {\n if (this.subscriptionObserverMap.size > 0) {\n // Active subscriptions on the WebSocket\n return;\n }\n if (!this.awsRealTimeSocket) {\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n return;\n }\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CLOSING_CONNECTION);\n if (this.awsRealTimeSocket.bufferedAmount > 0) {\n // Still data on the WebSocket\n setTimeout(this._closeSocketIfRequired.bind(this), 1000);\n }\n else {\n this.logger.debug('closing WebSocket...');\n const tempSocket = this.awsRealTimeSocket;\n // Cleaning callbacks to avoid race condition, socket still exists\n tempSocket.onclose = null;\n tempSocket.onerror = null;\n tempSocket.close(1000);\n this.awsRealTimeSocket = undefined;\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n this._closeSocket();\n }\n }\n maintainKeepAlive() {\n this.keepAliveTimestamp = Date.now();\n }\n keepAliveHeartbeat(connectionTimeoutMs) {\n const currentTime = Date.now();\n // Check for missed KA message\n if (currentTime - this.keepAliveTimestamp >\n constants_1.DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT) {\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.KEEP_ALIVE_MISSED);\n }\n else {\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.KEEP_ALIVE);\n }\n // Recognize we are disconnected if we haven't seen messages in the keep alive timeout period\n if (currentTime - this.keepAliveTimestamp > connectionTimeoutMs) {\n this._errorDisconnect(PubSub_1.CONTROL_MSG.TIMEOUT_DISCONNECT);\n }\n }\n _handleIncomingSubscriptionMessage(message) {\n if (typeof message.data !== 'string') {\n return;\n }\n const [isData, data] = this._handleSubscriptionData(message);\n if (isData) {\n this.maintainKeepAlive();\n return;\n }\n const { type, id, payload } = data;\n const { observer = null, query = '', variables = {}, startAckTimeoutId, subscriptionReadyCallback, subscriptionFailedCallback, } = this.subscriptionObserverMap.get(id) || {};\n if (type === constants_1.MESSAGE_TYPES.GQL_START_ACK ||\n type === constants_1.MESSAGE_TYPES.EVENT_SUBSCRIBE_ACK) {\n this.logger.debug(`subscription ready for ${JSON.stringify({ query, variables })}`);\n if (typeof subscriptionReadyCallback === 'function') {\n subscriptionReadyCallback();\n }\n if (startAckTimeoutId)\n clearTimeout(startAckTimeoutId);\n dispatchApiEvent({\n event: PubSub_1.CONTROL_MSG.SUBSCRIPTION_ACK,\n data: { query, variables },\n message: 'Connection established for subscription',\n });\n const subscriptionState = constants_1.SUBSCRIPTION_STATUS.CONNECTED;\n if (observer) {\n this.subscriptionObserverMap.set(id, {\n observer,\n query,\n variables,\n startAckTimeoutId: undefined,\n subscriptionState,\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n });\n }\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CONNECTION_ESTABLISHED);\n return;\n }\n if (type === constants_1.MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {\n this.maintainKeepAlive();\n return;\n }\n if (type === constants_1.MESSAGE_TYPES.GQL_ERROR ||\n type === constants_1.MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {\n const subscriptionState = constants_1.SUBSCRIPTION_STATUS.FAILED;\n if (observer) {\n this.subscriptionObserverMap.set(id, {\n observer,\n query,\n variables,\n startAckTimeoutId,\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n subscriptionState,\n });\n let errorMessage = JSON.stringify(payload ?? data);\n let isAuthError = false;\n const AUTH_ERROR_TYPES = [\n 'UnauthorizedException',\n 'Unauthorized',\n 'NotAuthorizedException',\n ];\n if (type === constants_1.MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {\n const { errors } = JSON.parse(String(message.data));\n if (Array.isArray(errors) && errors.length > 0) {\n const error = errors[0];\n errorMessage = `${error.errorType}: ${error.message}`;\n // An Events subscribe_error (e.g. a per-subscription\n // util.unauthorized() deny, which surfaces as errorType\n // 'Unauthorized', or an error whose message incidentally\n // contains 'Token expired') is terminal to only this\n // subscription. It must NOT close the shared socket: doing so\n // tears down sibling subscriptions and, for a permanently\n // denied channel, produces an unbounded deny/reconnect loop.\n // So isAuthError stays false here — only connection-level\n // GQL_ERROR auth failures below trigger a socket-closing\n // reconnect.\n }\n }\n else if (type === constants_1.MESSAGE_TYPES.GQL_ERROR &&\n payload &&\n typeof payload === 'object') {\n const { errors } = payload;\n if (Array.isArray(errors) && errors.length > 0) {\n const error = errors[0];\n isAuthError =\n AUTH_ERROR_TYPES.includes(error.errorType) ||\n error.message?.includes('Token expired');\n }\n }\n this.logger.debug(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`);\n // On auth errors, close the socket to trigger reconnection with fresh tokens.\n // The onclose handler fires _errorDisconnect → CONNECTION_CLOSED, which the\n // ConnectionStateMonitor picks up as ConnectionDisrupted and the\n // ReconnectionMonitor reconnects with refreshed credentials.\n if (isAuthError && this.awsRealTimeSocket) {\n this.logger.warn('Subscription failed due to auth error, closing WebSocket to trigger reconnection with fresh tokens');\n this.awsRealTimeSocket.close(1000, 'Auth error - reconnecting');\n }\n observer.error({\n errors: [\n {\n ...new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`),\n },\n ],\n });\n if (startAckTimeoutId)\n clearTimeout(startAckTimeoutId);\n if (typeof subscriptionFailedCallback === 'function') {\n subscriptionFailedCallback();\n }\n }\n }\n }\n _errorDisconnect(msg) {\n this.logger.debug(`Disconnect error: ${msg}`);\n if (this.awsRealTimeSocket) {\n this._closeSocket();\n this.awsRealTimeSocket.close();\n }\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n }\n _closeSocket() {\n if (this.keepAliveHeartbeatIntervalId) {\n clearInterval(this.keepAliveHeartbeatIntervalId);\n this.keepAliveHeartbeatIntervalId = undefined;\n }\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CLOSED);\n }\n _timeoutStartSubscriptionAck(subscriptionId) {\n const subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);\n if (subscriptionObserver) {\n const { observer, query, variables } = subscriptionObserver;\n if (!observer) {\n return;\n }\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n query,\n variables,\n subscriptionState: constants_1.SUBSCRIPTION_STATUS.FAILED,\n });\n this._closeSocket();\n this.logger.debug('timeoutStartSubscription', JSON.stringify({ query, variables }));\n }\n }\n _initializeWebSocketConnection({ appSyncGraphqlEndpoint, authenticationType, apiKey, region, additionalCustomHeaders, ctx, }) {\n if (this.socketStatus === constants_1.SOCKET_STATUS.READY) {\n return;\n }\n // TODO(Eslint): refactor to now use async function as the promise executor\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n this.promiseArray.push({ res: resolve, rej: reject });\n if (this.socketStatus === constants_1.SOCKET_STATUS.CLOSED) {\n try {\n this.socketStatus = constants_1.SOCKET_STATUS.CONNECTING;\n // Empty payload on connect\n const payloadString = '{}';\n const authHeader = await (0, authHeaders_1.awsRealTimeHeaderBasedAuth)({\n authenticationType,\n payload: payloadString,\n canonicalUri: this.wsConnectUri,\n apiKey,\n appSyncGraphqlEndpoint,\n region,\n additionalCustomHeaders,\n }, ctx);\n const headerString = authHeader ? JSON.stringify(authHeader) : '';\n // base64url-encoded string\n const encodedHeader = utils_1.base64Encoder.convert(headerString, {\n urlSafe: true,\n skipPadding: true,\n });\n const authTokenSubprotocol = `header-${encodedHeader}`;\n const queryParams = (0, appsyncUrl_1.queryParamsFromCustomHeaders)(additionalCustomHeaders);\n const awsRealTimeUrl = (0, appsyncUrl_1.realtimeUrlWithQueryString)(appSyncGraphqlEndpoint, queryParams);\n await this._establishRetryableConnection(awsRealTimeUrl, authTokenSubprotocol);\n this.promiseArray.forEach(({ res }) => {\n this.logger.debug('Notifying connection successful');\n res();\n });\n this.socketStatus = constants_1.SOCKET_STATUS.READY;\n this.promiseArray = [];\n }\n catch (err) {\n this.logger.debug('Connection exited with', err);\n this.promiseArray.forEach(({ rej }) => {\n rej(err);\n });\n this.promiseArray = [];\n if (this.awsRealTimeSocket &&\n this.awsRealTimeSocket.readyState === WebSocket.OPEN) {\n this.awsRealTimeSocket.close(3001);\n }\n this.awsRealTimeSocket = undefined;\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n }\n }\n });\n }\n async _establishRetryableConnection(awsRealTimeUrl, subprotocol) {\n this.logger.debug(`Establishing retryable connection`);\n await (0, utils_1.jitteredExponentialRetry)(this._establishConnection.bind(this), [awsRealTimeUrl, subprotocol], constants_1.MAX_DELAY_MS);\n }\n async _openConnection(awsRealTimeUrl, subprotocol) {\n return new Promise((resolve, reject) => {\n const newSocket = this._getNewWebSocket(awsRealTimeUrl, [\n this.wsProtocolName,\n subprotocol,\n ]);\n newSocket.onerror = () => {\n this.logger.debug(`WebSocket connection error`);\n };\n newSocket.onclose = () => {\n this._closeSocket();\n reject(new Error('Connection handshake error'));\n };\n newSocket.onopen = () => {\n this.awsRealTimeSocket = newSocket;\n resolve();\n };\n });\n }\n _getNewWebSocket(url, protocol) {\n return new WebSocket(url, protocol);\n }\n async _initiateHandshake() {\n return new Promise((resolve, reject) => {\n if (!this.awsRealTimeSocket) {\n reject(new Error('awsRealTimeSocket undefined'));\n return;\n }\n let ackOk = false;\n this.awsRealTimeSocket.onerror = error => {\n this.logger.debug(`WebSocket error ${JSON.stringify(error)}`);\n };\n this.awsRealTimeSocket.onclose = event => {\n this.logger.debug(`WebSocket closed ${event.reason}`);\n this._closeSocket();\n reject(new Error(JSON.stringify(event)));\n };\n this.awsRealTimeSocket.onmessage = (message) => {\n if (typeof message.data !== 'string') {\n return;\n }\n this.logger.debug(`subscription message from AWS AppSyncRealTime: ${message.data} `);\n const data = JSON.parse(message.data);\n const { type } = data;\n const connectionTimeoutMs = this._extractConnectionTimeout(data);\n if (type === constants_1.MESSAGE_TYPES.GQL_CONNECTION_ACK) {\n ackOk = true;\n this._registerWebsocketHandlers(connectionTimeoutMs);\n resolve('Connected to AWS AppSyncRealTime');\n return;\n }\n if (type === constants_1.MESSAGE_TYPES.GQL_CONNECTION_ERROR) {\n const { errorType, errorCode } = this._extractErrorCodeAndType(data);\n // TODO(Eslint): refactor to reject an Error object instead of a plain object\n // eslint-disable-next-line prefer-promise-reject-errors\n reject({ errorType, errorCode });\n }\n };\n const gqlInit = {\n type: constants_1.MESSAGE_TYPES.GQL_CONNECTION_INIT,\n };\n this.awsRealTimeSocket.send(JSON.stringify(gqlInit));\n const checkAckOk = (targetAckOk) => {\n if (!targetAckOk) {\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CONNECTION_FAILED);\n reject(new Error(`Connection timeout: ack from AWSAppSyncRealTime was not received after ${constants_1.CONNECTION_INIT_TIMEOUT} ms`));\n }\n };\n setTimeout(() => {\n checkAckOk(ackOk);\n }, constants_1.CONNECTION_INIT_TIMEOUT);\n });\n }\n _registerWebsocketHandlers(connectionTimeoutMs) {\n if (!this.awsRealTimeSocket) {\n return;\n }\n // Set up a keep alive heartbeat for this connection\n this.keepAliveHeartbeatIntervalId = setInterval(() => {\n this.keepAliveHeartbeat(connectionTimeoutMs);\n }, constants_1.DEFAULT_KEEP_ALIVE_HEARTBEAT_TIMEOUT);\n this.awsRealTimeSocket.onmessage =\n this._handleIncomingSubscriptionMessage.bind(this);\n this.awsRealTimeSocket.onerror = err => {\n this.logger.debug(err);\n this._errorDisconnect(PubSub_1.CONTROL_MSG.CONNECTION_CLOSED);\n };\n this.awsRealTimeSocket.onclose = event => {\n this.logger.debug(`WebSocket closed ${event.reason}`);\n this._closeSocket();\n this._errorDisconnect(PubSub_1.CONTROL_MSG.CONNECTION_CLOSED);\n };\n }\n}\nexports.AWSWebSocketProvider = AWSWebSocketProvider;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,oBAAoB,GAAG,MAAM;AACrC;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;AACpC,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;AAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC;AAC3C,MAAM,wBAAwB,GAAG,OAAO,CAAC,oCAAoC,CAAC;AAC9E,MAAM,qBAAqB,GAAG,OAAO,CAAC,iCAAiC,CAAC;AACxE,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;AAC5C,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;AAC9C,MAAM,gBAAgB,GAAG,CAAC,OAAO,KAAK;AACtC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,SAAS;AACxC,YAAY,IAAI,CAAC,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC;AAC9D,QAAQ,IAAI,CAAC,iBAAiB,CAAC,OAAO,GAAG,GAAG,IAAI;AAChD,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;AAClC,YAAY,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,iBAAiB,CAAC;AACzE,QAAQ,CAAC;AACT,QAAQ,IAAI,CAAC,iBAAiB,CAAC,OAAO,GAAG,KAAK,IAAI;AAClD,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AACjE,YAAY,IAAI,CAAC,YAAY,EAAE;AAC/B,YAAY,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,iBAAiB,CAAC;AACzE,QAAQ,CAAC;AACT,IAAI;AACJ;AACA,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/Providers/AWSWebSocketProvider/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AWSWebSocketProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst rxjs_1 = require(\"rxjs\");\nconst graphql_1 = require(\"graphql\");\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst PubSub_1 = require(\"../../types/PubSub\");\nconst constants_1 = require(\"../constants\");\nconst ConnectionStateMonitor_1 = require(\"../../utils/ConnectionStateMonitor\");\nconst ReconnectionMonitor_1 = require(\"../../utils/ReconnectionMonitor\");\nconst appsyncUrl_1 = require(\"./appsyncUrl\");\nconst authHeaders_1 = require(\"./authHeaders\");\nconst dispatchApiEvent = (payload) => {\n core_1.Hub.dispatch('api', payload, 'PubSub', constants_1.AMPLIFY_SYMBOL);\n};\nclass AWSWebSocketProvider {\n constructor(args) {\n this.subscriptionObserverMap = new Map();\n this.allowNoSubscriptions = false;\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n this.keepAliveTimestamp = Date.now();\n this.promiseArray = [];\n this.connectionStateMonitor = new ConnectionStateMonitor_1.ConnectionStateMonitor();\n this.reconnectionMonitor = new ReconnectionMonitor_1.ReconnectionMonitor();\n /**\n * Open WebSocket connection & perform handshake\n * Ref: https://docs.aws.amazon.com/appsync/latest/devguide/real-time-websocket-client.html#appsynclong-real-time-websocket-client-implementation-guide-for-graphql-subscriptions\n *\n * @param subprotocol -\n */\n this._establishConnection = async (awsRealTimeUrl, subprotocol) => {\n this.logger.debug(`Establishing WebSocket connection to ${awsRealTimeUrl}`);\n try {\n await this._openConnection(awsRealTimeUrl, subprotocol);\n await this._initiateHandshake();\n }\n catch (err) {\n const { errorType, errorCode } = err;\n if (constants_1.NON_RETRYABLE_CODES.includes(errorCode) ||\n // Event API does not currently return `errorCode`. This may change in the future.\n // For now fall back to also checking known non-retryable error types\n constants_1.NON_RETRYABLE_ERROR_TYPES.includes(errorType)) {\n throw new utils_1.NonRetryableError(errorType);\n }\n else if (errorType) {\n throw new Error(errorType);\n }\n else {\n throw err;\n }\n }\n };\n this.logger = new core_1.ConsoleLogger(args.providerName);\n this.wsProtocolName = args.wsProtocolName;\n this.wsConnectUri = args.connectUri;\n this.connectionStateMonitorSubscription =\n this._startConnectionStateMonitoring();\n }\n /**\n * Mark the socket closed and release all active listeners\n */\n close() {\n // Mark the socket closed both in status and the connection monitor\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CONNECTION_FAILED);\n // Turn off the subscription monitor Hub publishing\n this.connectionStateMonitorSubscription.unsubscribe();\n // Complete all reconnect observers\n this.reconnectionMonitor.close();\n return new Promise((resolve, reject) => {\n if (this.awsRealTimeSocket) {\n this.awsRealTimeSocket.onclose = (_) => {\n this._closeSocket();\n this.subscriptionObserverMap = new Map();\n this.awsRealTimeSocket = undefined;\n resolve();\n };\n this.awsRealTimeSocket.onerror = (err) => {\n reject(err);\n };\n this.awsRealTimeSocket.close();\n }\n else {\n resolve();\n }\n });\n }\n subscribe(options, customUserAgentDetails) {\n return new rxjs_1.Observable(observer => {\n if (!options?.appSyncGraphqlEndpoint) {\n // This guard fires ONLY for a MISSING/empty endpoint. For the Events\n // layer it is effectively unreachable: events.connect() connects\n // EAGERLY (awaited before any subscribe), and a missing endpoint fails\n // there in getRealtimeEndpointUrl -> new AmplifyUrl(''), so connect()\n // rejects and no channel is ever returned to subscribe on. Note\n // configure() does NOT reject a missing endpoint: it only throws when\n // the whole API.Events block is absent. We don't surface\n // onSubscriptionError here (no subscriptionId exists yet), and an\n // empty-id callback would be misleading; if this branch ever became\n // reachable it would leave `ready` pending (there is no built-in\n // timeout). An INVALID (present) endpoint is a DIFFERENT path: it passes\n // this guard, fails later in _connectWebSocket, and DOES reject `ready`\n // via _logStartSubscriptionError.\n observer.error({\n errors: [\n {\n ...new graphql_1.GraphQLError(`Subscribe only available for AWS AppSync endpoint`),\n },\n ],\n });\n observer.complete();\n return;\n }\n let subscriptionStartInProgress = false;\n const subscriptionId = (0, utils_1.amplifyUuid)();\n const startSubscription = () => {\n if (!subscriptionStartInProgress) {\n subscriptionStartInProgress = true;\n this._startSubscriptionWithAWSAppSyncRealTime({\n options,\n observer,\n subscriptionId,\n customUserAgentDetails,\n })\n .catch(err => {\n this.logger.debug(`${PubSub_1.CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR}: ${err}`);\n this._closeSocket();\n })\n .finally(() => {\n subscriptionStartInProgress = false;\n });\n }\n };\n // Add an observable to the reconnection list to manage reconnection for this subscription\n const reconnectSubscription = new rxjs_1.Observable(reconnectSubscriptionObserver => {\n this.reconnectionMonitor.addObserver(reconnectSubscriptionObserver);\n }).subscribe(() => {\n startSubscription();\n });\n startSubscription();\n return async () => {\n await this._cleanupSubscription(subscriptionId, reconnectSubscription);\n };\n });\n }\n async connect(options) {\n if (this.socketStatus === constants_1.SOCKET_STATUS.READY) {\n return;\n }\n await this._connectWebSocket(options);\n }\n async publish(options, customUserAgentDetails) {\n if (this.socketStatus !== constants_1.SOCKET_STATUS.READY) {\n throw new Error('Subscription has not been initialized');\n }\n return this._publishMessage(options, customUserAgentDetails);\n }\n async _connectWebSocket(options) {\n const { apiKey, appSyncGraphqlEndpoint, authenticationType, region, ctx } = options;\n const { additionalCustomHeaders } = await (0, appsyncUrl_1.additionalHeadersFromOptions)(options);\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.OPENING_CONNECTION);\n await this._initializeWebSocketConnection({\n apiKey,\n appSyncGraphqlEndpoint,\n authenticationType,\n region,\n additionalCustomHeaders,\n ctx,\n });\n }\n async _publishMessage(options, customUserAgentDetails) {\n const subscriptionId = (0, utils_1.amplifyUuid)();\n const { additionalCustomHeaders, libraryConfigHeaders } = await (0, appsyncUrl_1.additionalHeadersFromOptions)(options);\n const serializedSubscriptionMessage = await this._prepareSubscriptionPayload({\n options,\n subscriptionId,\n customUserAgentDetails,\n additionalCustomHeaders,\n libraryConfigHeaders,\n publish: true,\n });\n return new Promise((resolve, reject) => {\n if (this.awsRealTimeSocket) {\n const publishListener = (event) => {\n const data = JSON.parse(event.data);\n if (data.id === subscriptionId && data.type === 'publish_success') {\n this.awsRealTimeSocket &&\n this.awsRealTimeSocket.removeEventListener('message', publishListener);\n cleanup();\n resolve();\n }\n if (data.errors && data.errors.length > 0) {\n // Only reject on the terminal `publish_error` frame correlated to\n // THIS publish's operation id. AppSync Events guarantees that every\n // publish response frame (`publish_success`/`publish_error`) carries\n // the operation `id`, so error frames are correlated by `id` exactly\n // like the `publish_success` branch above, and the `data.type` gate\n // mirrors that branch's specificity. The socket is multiplexed, so an\n // error frame (e.g. a `subscribe_error`) can belong to an unrelated\n // operation on another channel; likewise an uncorrelated or id-less\n // error frame is not this publish's response. Such frames are\n // intentionally ignored for this publish and must not settle its\n // promise.\n if (data.id !== subscriptionId || data.type !== 'publish_error') {\n return;\n }\n const errorTypes = data.errors.map((error) => error.errorType);\n cleanup();\n reject(new Error(`Publish errors: ${errorTypes.join(', ')}`));\n }\n };\n const errorListener = (error) => {\n cleanup();\n reject(new Error(`WebSocket error: ${error}`));\n };\n const closeListener = () => {\n cleanup();\n reject(new Error('WebSocket is closed'));\n };\n const cleanup = () => {\n this.awsRealTimeSocket?.removeEventListener('message', publishListener);\n this.awsRealTimeSocket?.removeEventListener('error', errorListener);\n this.awsRealTimeSocket?.removeEventListener('close', closeListener);\n };\n this.awsRealTimeSocket.addEventListener('message', publishListener);\n this.awsRealTimeSocket.addEventListener('error', errorListener);\n this.awsRealTimeSocket.addEventListener('close', closeListener);\n this.awsRealTimeSocket.send(serializedSubscriptionMessage);\n }\n else {\n reject(new Error('WebSocket is not connected'));\n }\n });\n }\n async _cleanupSubscription(subscriptionId, reconnectSubscription) {\n // Cleanup reconnection subscription\n reconnectSubscription?.unsubscribe();\n // Cleanup after unsubscribing or observer.complete was called after _startSubscriptionWithAWSAppSyncRealTime\n try {\n // Waiting that subscription has been connected before trying to unsubscribe\n await this._waitForSubscriptionToBeConnected(subscriptionId);\n const { subscriptionState } = this.subscriptionObserverMap.get(subscriptionId) || {};\n if (!subscriptionState) {\n // subscription already unsubscribed\n return;\n }\n if (subscriptionState === constants_1.SUBSCRIPTION_STATUS.CONNECTED) {\n this._sendUnsubscriptionMessage(subscriptionId);\n }\n else {\n throw new Error('Subscription never connected');\n }\n }\n catch (err) {\n this.logger.debug(`Error while unsubscribing ${err}`);\n }\n finally {\n this._removeSubscriptionObserver(subscriptionId);\n }\n }\n // Monitor the connection state and pass changes along to Hub\n _startConnectionStateMonitoring() {\n return this.connectionStateMonitor.connectionStateObservable.subscribe(connectionState => {\n dispatchApiEvent({\n event: constants_1.CONNECTION_STATE_CHANGE,\n data: {\n provider: this,\n connectionState,\n },\n message: `Connection state is ${connectionState}`,\n });\n this.connectionState = connectionState;\n // Trigger START_RECONNECT when the connection is disrupted\n if (connectionState === PubSub_1.ConnectionState.ConnectionDisrupted) {\n this.reconnectionMonitor.record(ReconnectionMonitor_1.ReconnectEvent.START_RECONNECT);\n }\n // Trigger HALT_RECONNECT to halt reconnection attempts when the state is anything other than\n // ConnectionDisrupted or Connecting\n if ([\n PubSub_1.ConnectionState.Connected,\n PubSub_1.ConnectionState.ConnectedPendingDisconnect,\n PubSub_1.ConnectionState.ConnectedPendingKeepAlive,\n PubSub_1.ConnectionState.ConnectedPendingNetwork,\n PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork,\n PubSub_1.ConnectionState.Disconnected,\n ].includes(connectionState)) {\n this.reconnectionMonitor.record(ReconnectionMonitor_1.ReconnectEvent.HALT_RECONNECT);\n }\n });\n }\n async _startSubscriptionWithAWSAppSyncRealTime({ options, observer, subscriptionId, customUserAgentDetails, }) {\n const { query, variables } = options;\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n query: query ?? '',\n variables: variables ?? {},\n subscriptionState: constants_1.SUBSCRIPTION_STATUS.PENDING,\n onSubscriptionReady: options.onSubscriptionReady,\n onSubscriptionError: options.onSubscriptionError,\n startAckTimeoutId: undefined,\n });\n const { additionalCustomHeaders, libraryConfigHeaders } = await (0, appsyncUrl_1.additionalHeadersFromOptions)(options);\n const serializedSubscriptionMessage = await this._prepareSubscriptionPayload({\n options,\n subscriptionId,\n customUserAgentDetails,\n additionalCustomHeaders,\n libraryConfigHeaders,\n });\n try {\n await this._connectWebSocket(options);\n }\n catch (err) {\n this._logStartSubscriptionError(subscriptionId, observer, err);\n return;\n }\n // Potential race condition can occur when unsubscribe is called during _initializeWebSocketConnection.\n // E.g.unsubscribe gets invoked prior to finishing WebSocket handshake or START_ACK.\n // Both subscriptionFailedCallback and subscriptionReadyCallback are used to synchronized this.\n const { subscriptionFailedCallback, subscriptionReadyCallback } = this.subscriptionObserverMap.get(subscriptionId) ?? {};\n // This must be done before sending the message in order to be listening immediately\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n subscriptionState: constants_1.SUBSCRIPTION_STATUS.PENDING,\n query: query ?? '',\n variables: variables ?? {},\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n onSubscriptionReady: options.onSubscriptionReady,\n onSubscriptionError: options.onSubscriptionError,\n startAckTimeoutId: setTimeout(() => {\n this._timeoutStartSubscriptionAck(subscriptionId);\n }, constants_1.START_ACK_TIMEOUT),\n });\n if (this.awsRealTimeSocket) {\n this.awsRealTimeSocket.send(serializedSubscriptionMessage);\n }\n }\n // Log logic for start subscription failures\n _logStartSubscriptionError(subscriptionId, observer, err) {\n this.logger.debug({ err });\n const message = String(err.message ?? '');\n // Resolving to give the state observer time to propogate the update\n this._closeSocket();\n // Capture the error only when the network didn't cause disruption\n if (this.connectionState !== PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork) {\n const { onSubscriptionError } = this.subscriptionObserverMap.get(subscriptionId) || {};\n // Surface the connect failure to the caller's `ready` promise BEFORE\n // observer.error(...) so the real error wins the settle race: rxjs's\n // Subscriber.error() synchronously unsubscribes, which the events layer\n // would otherwise turn into a generic `ready` rejection (see\n // internals/events/index.ts). Only onSubscriptionError is hoisted here;\n // subscriptionFailedCallback is read and invoked AFTER observer.error\n // (below), because on this connect-init failure path the subscription is\n // still PENDING and subscriptionFailedCallback is not yet set. rxjs's\n // synchronous teardown inside observer.error() runs\n // _waitForSubscriptionToBeConnected, which re-points\n // subscriptionFailedCallback to its own promise's reject; invoking it\n // afterward drives that internal unsubscribe-during-connect self-heal so\n // _removeSubscriptionObserver runs and the subscriptionObserverMap entry\n // does not leak.\n onSubscriptionError?.(subscriptionId, new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${message}`));\n // When the error is non-retriable, error out the observable\n if ((0, utils_1.isNonRetryableError)(err)) {\n observer.error({\n errors: [\n {\n ...new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${message}`),\n },\n ],\n });\n }\n else {\n this.logger.debug(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${message}`);\n }\n // Notify concurrent unsubscription. Re-read the map here (not above)\n // because observer.error()'s synchronous teardown may have re-pointed\n // subscriptionFailedCallback to _waitForSubscriptionToBeConnected's\n // reject; picking it up now self-heals the unsubscribe-during-connect\n // race and lets _removeSubscriptionObserver clean up.\n const { subscriptionFailedCallback } = this.subscriptionObserverMap.get(subscriptionId) || {};\n if (typeof subscriptionFailedCallback === 'function') {\n subscriptionFailedCallback();\n }\n }\n }\n // Waiting that subscription has been connected before trying to unsubscribe\n async _waitForSubscriptionToBeConnected(subscriptionId) {\n const subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);\n if (subscriptionObserver) {\n const { subscriptionState } = subscriptionObserver;\n // This in case unsubscribe is invoked before sending start subscription message\n if (subscriptionState === constants_1.SUBSCRIPTION_STATUS.PENDING) {\n return new Promise((resolve, reject) => {\n const { observer, subscriptionState: observedSubscriptionState, variables, query, } = subscriptionObserver;\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n subscriptionState: observedSubscriptionState,\n variables,\n query,\n subscriptionReadyCallback: resolve,\n subscriptionFailedCallback: reject,\n });\n });\n }\n }\n }\n _sendUnsubscriptionMessage(subscriptionId) {\n try {\n if (this.awsRealTimeSocket &&\n this.awsRealTimeSocket.readyState === WebSocket.OPEN &&\n this.socketStatus === constants_1.SOCKET_STATUS.READY) {\n // Preparing unsubscribe message to stop receiving messages for that subscription\n const unsubscribeMessage = this._unsubscribeMessage(subscriptionId);\n const stringToAWSRealTime = JSON.stringify(unsubscribeMessage);\n this.awsRealTimeSocket.send(stringToAWSRealTime);\n }\n }\n catch (err) {\n // If GQL_STOP is not sent because of disconnection issue, then there is nothing the client can do\n this.logger.debug({ err });\n }\n }\n _removeSubscriptionObserver(subscriptionId) {\n this.subscriptionObserverMap.delete(subscriptionId);\n // Verifying 1000ms after removing subscription in case there are new subscription unmount/mount\n if (!this.allowNoSubscriptions) {\n setTimeout(this._closeSocketIfRequired.bind(this), 1000);\n }\n }\n _closeSocketIfRequired() {\n if (this.subscriptionObserverMap.size > 0) {\n // Active subscriptions on the WebSocket\n return;\n }\n if (!this.awsRealTimeSocket) {\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n return;\n }\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CLOSING_CONNECTION);\n if (this.awsRealTimeSocket.bufferedAmount > 0) {\n // Still data on the WebSocket\n setTimeout(this._closeSocketIfRequired.bind(this), 1000);\n }\n else {\n this.logger.debug('closing WebSocket...');\n const tempSocket = this.awsRealTimeSocket;\n // Cleaning callbacks to avoid race condition, socket still exists\n tempSocket.onclose = null;\n tempSocket.onerror = null;\n tempSocket.close(1000);\n this.awsRealTimeSocket = undefined;\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n this._closeSocket();\n }\n }\n maintainKeepAlive() {\n this.keepAliveTimestamp = Date.now();\n }\n keepAliveHeartbeat(connectionTimeoutMs) {\n const currentTime = Date.now();\n // Check for missed KA message\n if (currentTime - this.keepAliveTimestamp >\n constants_1.DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT) {\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.KEEP_ALIVE_MISSED);\n }\n else {\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.KEEP_ALIVE);\n }\n // Recognize we are disconnected if we haven't seen messages in the keep alive timeout period\n if (currentTime - this.keepAliveTimestamp > connectionTimeoutMs) {\n this._errorDisconnect(PubSub_1.CONTROL_MSG.TIMEOUT_DISCONNECT);\n }\n }\n _handleIncomingSubscriptionMessage(message) {\n if (typeof message.data !== 'string') {\n return;\n }\n const [isData, data] = this._handleSubscriptionData(message);\n if (isData) {\n this.maintainKeepAlive();\n return;\n }\n const { type, id, payload } = data;\n const { observer = null, query = '', variables = {}, startAckTimeoutId, subscriptionReadyCallback, subscriptionFailedCallback, onSubscriptionReady, onSubscriptionError, } = this.subscriptionObserverMap.get(id) || {};\n if (type === constants_1.MESSAGE_TYPES.GQL_START_ACK ||\n type === constants_1.MESSAGE_TYPES.EVENT_SUBSCRIBE_ACK) {\n this.logger.debug(`subscription ready for ${JSON.stringify({ query, variables })}`);\n if (typeof subscriptionReadyCallback === 'function') {\n subscriptionReadyCallback();\n }\n onSubscriptionReady?.(id);\n if (startAckTimeoutId)\n clearTimeout(startAckTimeoutId);\n dispatchApiEvent({\n event: PubSub_1.CONTROL_MSG.SUBSCRIPTION_ACK,\n data: { id, query, variables },\n message: 'Connection established for subscription',\n });\n const subscriptionState = constants_1.SUBSCRIPTION_STATUS.CONNECTED;\n if (observer) {\n const existing = this.subscriptionObserverMap.get(id);\n this.subscriptionObserverMap.set(id, {\n ...existing,\n observer,\n query,\n variables,\n subscriptionState,\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n startAckTimeoutId: undefined,\n });\n }\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CONNECTION_ESTABLISHED);\n return;\n }\n if (type === constants_1.MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {\n this.maintainKeepAlive();\n return;\n }\n if (type === constants_1.MESSAGE_TYPES.GQL_ERROR ||\n type === constants_1.MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {\n const subscriptionState = constants_1.SUBSCRIPTION_STATUS.FAILED;\n if (observer) {\n const existing = this.subscriptionObserverMap.get(id);\n this.subscriptionObserverMap.set(id, {\n ...existing,\n observer,\n query,\n variables,\n startAckTimeoutId,\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n subscriptionState,\n });\n let errorMessage = JSON.stringify(payload ?? data);\n let isAuthError = false;\n const AUTH_ERROR_TYPES = [\n 'UnauthorizedException',\n 'Unauthorized',\n 'NotAuthorizedException',\n ];\n if (type === constants_1.MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {\n const { errors } = JSON.parse(String(message.data));\n if (Array.isArray(errors) && errors.length > 0) {\n const error = errors[0];\n errorMessage = `${error.errorType}: ${error.message}`;\n // An Events subscribe_error (e.g. a per-subscription\n // util.unauthorized() deny, which surfaces as errorType\n // 'Unauthorized', or an error whose message incidentally\n // contains 'Token expired') is terminal to only this\n // subscription. It must NOT close the shared socket: doing so\n // tears down sibling subscriptions and, for a permanently\n // denied channel, produces an unbounded deny/reconnect loop.\n // So isAuthError stays false here — only connection-level\n // GQL_ERROR auth failures below trigger a socket-closing\n // reconnect.\n }\n }\n else if (type === constants_1.MESSAGE_TYPES.GQL_ERROR &&\n payload &&\n typeof payload === 'object') {\n const { errors } = payload;\n if (Array.isArray(errors) && errors.length > 0) {\n const error = errors[0];\n isAuthError =\n AUTH_ERROR_TYPES.includes(error.errorType) ||\n error.message?.includes('Token expired');\n }\n }\n this.logger.debug(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`);\n // On auth errors, close the socket to trigger reconnection with fresh tokens.\n // The onclose handler fires _errorDisconnect → CONNECTION_CLOSED, which the\n // ConnectionStateMonitor picks up as ConnectionDisrupted and the\n // ReconnectionMonitor reconnects with refreshed credentials.\n if (isAuthError && this.awsRealTimeSocket) {\n this.logger.warn('Subscription failed due to auth error, closing WebSocket to trigger reconnection with fresh tokens');\n this.awsRealTimeSocket.close(1000, 'Auth error - reconnecting');\n }\n // Surface the real subscription error to the caller's `ready`\n // promise BEFORE observer.error(...). rxjs's Subscriber.error()\n // synchronously calls this.unsubscribe(); if onSubscriptionError ran\n // after observer.error, the events layer's caller-unsubscribe\n // fallback could settle `ready` first with a generic reason and mask\n // this real error. onSubscriptionError must win that race.\n onSubscriptionError?.(id, new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`));\n observer.error({\n errors: [\n {\n ...new graphql_1.GraphQLError(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`),\n },\n ],\n });\n if (startAckTimeoutId)\n clearTimeout(startAckTimeoutId);\n if (typeof subscriptionFailedCallback === 'function') {\n subscriptionFailedCallback();\n }\n }\n }\n }\n _errorDisconnect(msg) {\n this.logger.debug(`Disconnect error: ${msg}`);\n if (this.awsRealTimeSocket) {\n this._closeSocket();\n this.awsRealTimeSocket.close();\n }\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n }\n _closeSocket() {\n if (this.keepAliveHeartbeatIntervalId) {\n clearInterval(this.keepAliveHeartbeatIntervalId);\n this.keepAliveHeartbeatIntervalId = undefined;\n }\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CLOSED);\n }\n _timeoutStartSubscriptionAck(subscriptionId) {\n const subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);\n if (subscriptionObserver) {\n const { observer, query, variables, onSubscriptionError } = subscriptionObserver;\n if (!observer) {\n return;\n }\n this.subscriptionObserverMap.set(subscriptionId, {\n ...subscriptionObserver,\n observer,\n query,\n variables,\n subscriptionState: constants_1.SUBSCRIPTION_STATUS.FAILED,\n startAckTimeoutId: undefined,\n });\n onSubscriptionError?.(subscriptionId, new Error('Subscription start ack timeout'));\n this._closeSocket();\n this.logger.debug('timeoutStartSubscription', JSON.stringify({ query, variables }));\n }\n }\n _initializeWebSocketConnection({ appSyncGraphqlEndpoint, authenticationType, apiKey, region, additionalCustomHeaders, ctx, }) {\n if (this.socketStatus === constants_1.SOCKET_STATUS.READY) {\n return;\n }\n // TODO(Eslint): refactor to now use async function as the promise executor\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n this.promiseArray.push({ res: resolve, rej: reject });\n if (this.socketStatus === constants_1.SOCKET_STATUS.CLOSED) {\n try {\n this.socketStatus = constants_1.SOCKET_STATUS.CONNECTING;\n // Empty payload on connect\n const payloadString = '{}';\n const authHeader = await (0, authHeaders_1.awsRealTimeHeaderBasedAuth)({\n authenticationType,\n payload: payloadString,\n canonicalUri: this.wsConnectUri,\n apiKey,\n appSyncGraphqlEndpoint,\n region,\n additionalCustomHeaders,\n }, ctx);\n const headerString = authHeader ? JSON.stringify(authHeader) : '';\n // base64url-encoded string\n const encodedHeader = utils_1.base64Encoder.convert(headerString, {\n urlSafe: true,\n skipPadding: true,\n });\n const authTokenSubprotocol = `header-${encodedHeader}`;\n const queryParams = (0, appsyncUrl_1.queryParamsFromCustomHeaders)(additionalCustomHeaders);\n const awsRealTimeUrl = (0, appsyncUrl_1.realtimeUrlWithQueryString)(appSyncGraphqlEndpoint, queryParams);\n await this._establishRetryableConnection(awsRealTimeUrl, authTokenSubprotocol);\n this.promiseArray.forEach(({ res }) => {\n this.logger.debug('Notifying connection successful');\n res();\n });\n this.socketStatus = constants_1.SOCKET_STATUS.READY;\n this.promiseArray = [];\n }\n catch (err) {\n this.logger.debug('Connection exited with', err);\n this.promiseArray.forEach(({ rej }) => {\n rej(err);\n });\n this.promiseArray = [];\n if (this.awsRealTimeSocket &&\n this.awsRealTimeSocket.readyState === WebSocket.OPEN) {\n this.awsRealTimeSocket.close(3001);\n }\n this.awsRealTimeSocket = undefined;\n this.socketStatus = constants_1.SOCKET_STATUS.CLOSED;\n }\n }\n });\n }\n async _establishRetryableConnection(awsRealTimeUrl, subprotocol) {\n this.logger.debug(`Establishing retryable connection`);\n await (0, utils_1.jitteredExponentialRetry)(this._establishConnection.bind(this), [awsRealTimeUrl, subprotocol], constants_1.MAX_DELAY_MS);\n }\n async _openConnection(awsRealTimeUrl, subprotocol) {\n return new Promise((resolve, reject) => {\n const newSocket = this._getNewWebSocket(awsRealTimeUrl, [\n this.wsProtocolName,\n subprotocol,\n ]);\n newSocket.onerror = () => {\n this.logger.debug(`WebSocket connection error`);\n };\n newSocket.onclose = () => {\n this._closeSocket();\n reject(new Error('Connection handshake error'));\n };\n newSocket.onopen = () => {\n this.awsRealTimeSocket = newSocket;\n resolve();\n };\n });\n }\n _getNewWebSocket(url, protocol) {\n return new WebSocket(url, protocol);\n }\n async _initiateHandshake() {\n return new Promise((resolve, reject) => {\n if (!this.awsRealTimeSocket) {\n reject(new Error('awsRealTimeSocket undefined'));\n return;\n }\n let ackOk = false;\n this.awsRealTimeSocket.onerror = error => {\n this.logger.debug(`WebSocket error ${JSON.stringify(error)}`);\n };\n this.awsRealTimeSocket.onclose = event => {\n this.logger.debug(`WebSocket closed ${event.reason}`);\n this._closeSocket();\n reject(new Error(JSON.stringify(event)));\n };\n this.awsRealTimeSocket.onmessage = (message) => {\n if (typeof message.data !== 'string') {\n return;\n }\n this.logger.debug(`subscription message from AWS AppSyncRealTime: ${message.data} `);\n const data = JSON.parse(message.data);\n const { type } = data;\n const connectionTimeoutMs = this._extractConnectionTimeout(data);\n if (type === constants_1.MESSAGE_TYPES.GQL_CONNECTION_ACK) {\n ackOk = true;\n this._registerWebsocketHandlers(connectionTimeoutMs);\n resolve('Connected to AWS AppSyncRealTime');\n return;\n }\n if (type === constants_1.MESSAGE_TYPES.GQL_CONNECTION_ERROR) {\n const { errorType, errorCode } = this._extractErrorCodeAndType(data);\n // TODO(Eslint): refactor to reject an Error object instead of a plain object\n // eslint-disable-next-line prefer-promise-reject-errors\n reject({ errorType, errorCode });\n }\n };\n const gqlInit = {\n type: constants_1.MESSAGE_TYPES.GQL_CONNECTION_INIT,\n };\n this.awsRealTimeSocket.send(JSON.stringify(gqlInit));\n const checkAckOk = (targetAckOk) => {\n if (!targetAckOk) {\n this.connectionStateMonitor.record(ConnectionStateMonitor_1.CONNECTION_CHANGE.CONNECTION_FAILED);\n reject(new Error(`Connection timeout: ack from AWSAppSyncRealTime was not received after ${constants_1.CONNECTION_INIT_TIMEOUT} ms`));\n }\n };\n setTimeout(() => {\n checkAckOk(ackOk);\n }, constants_1.CONNECTION_INIT_TIMEOUT);\n });\n }\n _registerWebsocketHandlers(connectionTimeoutMs) {\n if (!this.awsRealTimeSocket) {\n return;\n }\n // Set up a keep alive heartbeat for this connection\n this.keepAliveHeartbeatIntervalId = setInterval(() => {\n this.keepAliveHeartbeat(connectionTimeoutMs);\n }, constants_1.DEFAULT_KEEP_ALIVE_HEARTBEAT_TIMEOUT);\n this.awsRealTimeSocket.onmessage =\n this._handleIncomingSubscriptionMessage.bind(this);\n this.awsRealTimeSocket.onerror = err => {\n this.logger.debug(err);\n this._errorDisconnect(PubSub_1.CONTROL_MSG.CONNECTION_CLOSED);\n };\n this.awsRealTimeSocket.onclose = event => {\n this.logger.debug(`WebSocket closed ${event.reason}`);\n this._closeSocket();\n this._errorDisconnect(PubSub_1.CONTROL_MSG.CONNECTION_CLOSED);\n };\n }\n}\nexports.AWSWebSocketProvider = AWSWebSocketProvider;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,oBAAoB,GAAG,MAAM;AACrC;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;AACpC,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;AAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC;AAC3C,MAAM,wBAAwB,GAAG,OAAO,CAAC,oCAAoC,CAAC;AAC9E,MAAM,qBAAqB,GAAG,OAAO,CAAC,iCAAiC,CAAC;AACxE,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;AAC5C,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;AAC9C,MAAM,gBAAgB,GAAG,CAAC,OAAO,KAAK;AACtC,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CA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CAAC,IAAI,CAAC;AAC9D,QAAQ,IAAI,CAAC,iBAAiB,CAAC,OAAO,GAAG,GAAG,IAAI;AAChD,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;AAClC,YAAY,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,iBAAiB,CAAC;AACzE,QAAQ,CAAC;AACT,QAAQ,IAAI,CAAC,iBAAiB,CAAC,OAAO,GAAG,KAAK,IAAI;AAClD,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AACjE,YAAY,IAAI,CAAC,YAAY,EAAE;AAC/B,YAAY,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,iBAAiB,CAAC;AACzE,QAAQ,CAAC;AACT,IAAI;AACJ;AACA,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
@@ -32,10 +32,78 @@ async function connect(...args) {
32
32
  subscribeOptions.apiKey = subOptions?.apiKey || subscribeOptions.apiKey;
33
33
  subscribeOptions.authToken =
34
34
  subOptions?.authToken || subscribeOptions.authToken;
35
- _subscription = AWSAppSyncEventsProvider_1.AppSyncEventProvider
36
- .subscribe({ ...subscribeOptions, ctx })
35
+ // One-shot readiness signal for THIS subscribe call. The promise state
36
+ // (`settled`/`resolveReady`/`rejectReady`) is kept in locals so the
37
+ // resolve/reject callbacks below close over this specific subscribe call.
38
+ // NOTE: the channel-level `_subscription` closure var is overwritten on
39
+ // each subscribe, so `close()` only rejects the MOST RECENT subscription's
40
+ // `ready`; rejecting `ready` for earlier concurrent subscriptions on the
41
+ // same channel is a pre-existing limitation (not addressed here).
42
+ let settled = false;
43
+ let resolveReady;
44
+ let rejectReady;
45
+ const ready = new Promise((resolve, reject) => {
46
+ resolveReady = resolve;
47
+ rejectReady = reject;
48
+ });
49
+ // Avoid unhandled-rejection noise before the caller reads `.ready`.
50
+ ready.catch(() => undefined);
51
+ const providerSubscription = AWSAppSyncEventsProvider_1.AppSyncEventProvider
52
+ .subscribe({
53
+ ...subscribeOptions,
54
+ ctx,
55
+ onSubscriptionReady: (subscriptionId) => {
56
+ if (!settled) {
57
+ settled = true;
58
+ resolveReady({ subscriptionId });
59
+ }
60
+ },
61
+ onSubscriptionError: (_subscriptionId, error) => {
62
+ if (!settled) {
63
+ settled = true;
64
+ // `error` is optional on the provider callback; default it so
65
+ // `ready` never rejects with `undefined`.
66
+ rejectReady(error ?? new Error('Subscription failed before ready'));
67
+ }
68
+ },
69
+ })
37
70
  .subscribe(observer);
38
- return _subscription;
71
+ // Expose the readiness promise on a DELEGATING wrapper instead of mutating
72
+ // the rxjs Subscriber returned above. rxjs calls `this.unsubscribe()`
73
+ // internally from Subscriber.error()/complete(); if we patched the
74
+ // subscriber's own `unsubscribe`, a provider-driven error would fire it and
75
+ // reject `ready` with a generic reason, masking the real error. Delegating
76
+ // through a prototype wrapper keeps rxjs's internal `this.unsubscribe()`
77
+ // hitting the ORIGINAL subscriber, so only a CALLER-initiated unsubscribe
78
+ // (via this returned object) or a channel close rejects `ready`. The
79
+ // provider-side onSubscriptionError is the PRIMARY reject signal; this is
80
+ // the fallback for a genuine caller unsubscribe / close-before-ack. rxjs
81
+ // Subscription methods/props (`closed`, `add`, etc.) resolve through the
82
+ // prototype, so the returned object still satisfies the Subscription
83
+ // contract (backward compatible for existing callers).
84
+ const eventsSubscription = Object.create(providerSubscription);
85
+ Object.defineProperty(eventsSubscription, 'unsubscribe', {
86
+ value: () => {
87
+ if (!settled) {
88
+ settled = true;
89
+ rejectReady(new Error('Subscription closed before ready'));
90
+ }
91
+ providerSubscription.unsubscribe();
92
+ },
93
+ writable: true,
94
+ enumerable: false,
95
+ configurable: true,
96
+ });
97
+ Object.defineProperty(eventsSubscription, 'ready', {
98
+ value: ready,
99
+ writable: false,
100
+ enumerable: true,
101
+ configurable: true,
102
+ });
103
+ // `close()` unsubscribes the most recent subscription through this closure
104
+ // var (the delegate above), which rejects its `ready` if still pending.
105
+ _subscription = eventsSubscription;
106
+ return eventsSubscription;
39
107
  };
40
108
  const pub = async (event, pubOptions) => {
41
109
  if (!openChannels.has(channelId)) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/internals/events/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.connect = connect;\nexports.post = post;\nexports.closeAll = closeAll;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst AWSAppSyncEventsProvider_1 = require(\"../../Providers/AWSAppSyncEventsProvider\");\nconst appsyncRequest_1 = require(\"./appsyncRequest\");\nconst utils_2 = require(\"./utils\");\n// Keeps a list of open channels in the websocket\nconst openChannels = new Set();\nasync function connect(...args) {\n const [ctx, channel, options] = (0, utils_1.resolveCtxArgs)(args);\n const providerOptions = (0, utils_2.configure)(ctx);\n providerOptions.authenticationType = (0, utils_2.normalizeAuth)(options?.authMode, providerOptions.authenticationType);\n providerOptions.apiKey = options?.apiKey || providerOptions.apiKey;\n providerOptions.authToken = options?.authToken || providerOptions.authToken;\n // Pass ctx to the provider so WebSocket auth uses the correct credentials\n await AWSAppSyncEventsProvider_1.AppSyncEventProvider.connect({ ...providerOptions, ctx });\n const channelId = (0, utils_1.amplifyUuid)();\n openChannels.add(channelId);\n let _subscription;\n const sub = (observer, subOptions) => {\n if (!openChannels.has(channelId)) {\n throw new Error('Channel is closed');\n }\n const subscribeOptions = { ...providerOptions, query: channel };\n subscribeOptions.authenticationType = (0, utils_2.normalizeAuth)(subOptions?.authMode, subscribeOptions.authenticationType);\n subscribeOptions.apiKey = subOptions?.apiKey || subscribeOptions.apiKey;\n subscribeOptions.authToken =\n subOptions?.authToken || subscribeOptions.authToken;\n _subscription = AWSAppSyncEventsProvider_1.AppSyncEventProvider\n .subscribe({ ...subscribeOptions, ctx })\n .subscribe(observer);\n return _subscription;\n };\n const pub = async (event, pubOptions) => {\n if (!openChannels.has(channelId)) {\n throw new Error('Channel is closed');\n }\n const publishOptions = {\n ...providerOptions,\n query: channel,\n variables: event,\n };\n publishOptions.authenticationType = (0, utils_2.normalizeAuth)(pubOptions?.authMode, publishOptions.authenticationType);\n publishOptions.apiKey = pubOptions?.apiKey || publishOptions.apiKey;\n publishOptions.authToken =\n pubOptions?.authToken || publishOptions.authToken;\n return AWSAppSyncEventsProvider_1.AppSyncEventProvider.publish({ ...publishOptions, ctx });\n };\n const close = async () => {\n _subscription && _subscription.unsubscribe();\n openChannels.delete(channelId);\n setTimeout(() => {\n if (openChannels.size === 0) {\n AWSAppSyncEventsProvider_1.AppSyncEventProvider.closeIfNoActiveSubscription();\n }\n }, 1000);\n };\n return {\n subscribe: sub,\n close,\n publish: pub,\n };\n}\nasync function post(...args) {\n const [ctx, channel, event, options] = (0, utils_1.resolveCtxArgs)(args);\n const providerOptions = (0, utils_2.configure)(ctx);\n providerOptions.authenticationType = (0, utils_2.normalizeAuth)(options?.authMode, providerOptions.authenticationType);\n providerOptions.apiKey = options?.apiKey || providerOptions.apiKey;\n providerOptions.authToken = options?.authToken || providerOptions.authToken;\n // trailing slash required in publish\n const normalizedChannelName = channel[0] === '/' ? channel : `/${channel}`;\n const publishOptions = {\n ...providerOptions,\n query: normalizedChannelName,\n variables: (0, utils_2.serializeEvents)(event),\n };\n const abortController = new AbortController();\n const res = await (0, appsyncRequest_1.appsyncRequest)(ctx, publishOptions, {}, abortController);\n if (res.failed?.length > 0) {\n return res.failed;\n }\n}\n/**\n * @experimental API may change in future versions\n *\n * Close WebSocket connection, disconnect listeners and reconnect observers\n *\n * @example\n * await events.closeAll()\n *\n * @returns void on success\n * @throws on error\n */\nasync function closeAll() {\n await AWSAppSyncEventsProvider_1.AppSyncEventProvider.close();\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,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AAG,GAAG,OAAO,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAC9E,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,GAAG,eAAe;AAC1B,QAAQ,KAAK,EAAE,qBAAqB;AACpC,QAAQ,SAAS,EAAE,IAAI,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC;AACtD,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE;AACjD,IAAI,MAAM,GAAG,GAAG,MAAM,IAAI,gBAAgB,CAAC,cAAc,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,eAAe,CAAC;AACpG,IAAI,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE;AAChC,QAAQ,OAAO,GAAG,CAAC,MAAM;AACzB,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ,GAAG;AAC1B,IAAI,MAAM,0BAA0B,CAAC,oBAAoB,CAAC,KAAK,EAAE;AACjE;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/internals/events/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.connect = connect;\nexports.post = post;\nexports.closeAll = closeAll;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst AWSAppSyncEventsProvider_1 = require(\"../../Providers/AWSAppSyncEventsProvider\");\nconst appsyncRequest_1 = require(\"./appsyncRequest\");\nconst utils_2 = require(\"./utils\");\n// Keeps a list of open channels in the websocket\nconst openChannels = new Set();\nasync function connect(...args) {\n const [ctx, channel, options] = (0, utils_1.resolveCtxArgs)(args);\n const providerOptions = (0, utils_2.configure)(ctx);\n providerOptions.authenticationType = (0, utils_2.normalizeAuth)(options?.authMode, providerOptions.authenticationType);\n providerOptions.apiKey = options?.apiKey || providerOptions.apiKey;\n providerOptions.authToken = options?.authToken || providerOptions.authToken;\n // Pass ctx to the provider so WebSocket auth uses the correct credentials\n await AWSAppSyncEventsProvider_1.AppSyncEventProvider.connect({ ...providerOptions, ctx });\n const channelId = (0, utils_1.amplifyUuid)();\n openChannels.add(channelId);\n let _subscription;\n const sub = (observer, subOptions) => {\n if (!openChannels.has(channelId)) {\n throw new Error('Channel is closed');\n }\n const subscribeOptions = { ...providerOptions, query: channel };\n subscribeOptions.authenticationType = (0, utils_2.normalizeAuth)(subOptions?.authMode, subscribeOptions.authenticationType);\n subscribeOptions.apiKey = subOptions?.apiKey || subscribeOptions.apiKey;\n subscribeOptions.authToken =\n subOptions?.authToken || subscribeOptions.authToken;\n // One-shot readiness signal for THIS subscribe call. The promise state\n // (`settled`/`resolveReady`/`rejectReady`) is kept in locals so the\n // resolve/reject callbacks below close over this specific subscribe call.\n // NOTE: the channel-level `_subscription` closure var is overwritten on\n // each subscribe, so `close()` only rejects the MOST RECENT subscription's\n // `ready`; rejecting `ready` for earlier concurrent subscriptions on the\n // same channel is a pre-existing limitation (not addressed here).\n let settled = false;\n let resolveReady;\n let rejectReady;\n const ready = new Promise((resolve, reject) => {\n resolveReady = resolve;\n rejectReady = reject;\n });\n // Avoid unhandled-rejection noise before the caller reads `.ready`.\n ready.catch(() => undefined);\n const providerSubscription = AWSAppSyncEventsProvider_1.AppSyncEventProvider\n .subscribe({\n ...subscribeOptions,\n ctx,\n onSubscriptionReady: (subscriptionId) => {\n if (!settled) {\n settled = true;\n resolveReady({ subscriptionId });\n }\n },\n onSubscriptionError: (_subscriptionId, error) => {\n if (!settled) {\n settled = true;\n // `error` is optional on the provider callback; default it so\n // `ready` never rejects with `undefined`.\n rejectReady(error ?? new Error('Subscription failed before ready'));\n }\n },\n })\n .subscribe(observer);\n // Expose the readiness promise on a DELEGATING wrapper instead of mutating\n // the rxjs Subscriber returned above. rxjs calls `this.unsubscribe()`\n // internally from Subscriber.error()/complete(); if we patched the\n // subscriber's own `unsubscribe`, a provider-driven error would fire it and\n // reject `ready` with a generic reason, masking the real error. Delegating\n // through a prototype wrapper keeps rxjs's internal `this.unsubscribe()`\n // hitting the ORIGINAL subscriber, so only a CALLER-initiated unsubscribe\n // (via this returned object) or a channel close rejects `ready`. The\n // provider-side onSubscriptionError is the PRIMARY reject signal; this is\n // the fallback for a genuine caller unsubscribe / close-before-ack. rxjs\n // Subscription methods/props (`closed`, `add`, etc.) resolve through the\n // prototype, so the returned object still satisfies the Subscription\n // contract (backward compatible for existing callers).\n const eventsSubscription = Object.create(providerSubscription);\n Object.defineProperty(eventsSubscription, 'unsubscribe', {\n value: () => {\n if (!settled) {\n settled = true;\n rejectReady(new Error('Subscription closed before ready'));\n }\n providerSubscription.unsubscribe();\n },\n writable: true,\n enumerable: false,\n configurable: true,\n });\n Object.defineProperty(eventsSubscription, 'ready', {\n value: ready,\n writable: false,\n enumerable: true,\n configurable: true,\n });\n // `close()` unsubscribes the most recent subscription through this closure\n // var (the delegate above), which rejects its `ready` if still pending.\n _subscription = eventsSubscription;\n return eventsSubscription;\n };\n const pub = async (event, pubOptions) => {\n if (!openChannels.has(channelId)) {\n throw new Error('Channel is closed');\n }\n const publishOptions = {\n ...providerOptions,\n query: channel,\n variables: event,\n };\n publishOptions.authenticationType = (0, utils_2.normalizeAuth)(pubOptions?.authMode, publishOptions.authenticationType);\n publishOptions.apiKey = pubOptions?.apiKey || publishOptions.apiKey;\n publishOptions.authToken =\n pubOptions?.authToken || publishOptions.authToken;\n return AWSAppSyncEventsProvider_1.AppSyncEventProvider.publish({ ...publishOptions, ctx });\n };\n const close = async () => {\n _subscription && _subscription.unsubscribe();\n openChannels.delete(channelId);\n setTimeout(() => {\n if (openChannels.size === 0) {\n AWSAppSyncEventsProvider_1.AppSyncEventProvider.closeIfNoActiveSubscription();\n }\n }, 1000);\n };\n return {\n subscribe: sub,\n close,\n publish: pub,\n };\n}\nasync function post(...args) {\n const [ctx, channel, event, options] = (0, utils_1.resolveCtxArgs)(args);\n const providerOptions = (0, utils_2.configure)(ctx);\n providerOptions.authenticationType = (0, utils_2.normalizeAuth)(options?.authMode, providerOptions.authenticationType);\n providerOptions.apiKey = options?.apiKey || providerOptions.apiKey;\n providerOptions.authToken = options?.authToken || providerOptions.authToken;\n // trailing slash required in publish\n const normalizedChannelName = channel[0] === '/' ? channel : `/${channel}`;\n const publishOptions = {\n ...providerOptions,\n query: normalizedChannelName,\n variables: (0, utils_2.serializeEvents)(event),\n };\n const abortController = new AbortController();\n const res = await (0, appsyncRequest_1.appsyncRequest)(ctx, publishOptions, {}, abortController);\n if (res.failed?.length > 0) {\n return res.failed;\n }\n}\n/**\n * @experimental API may change in future versions\n *\n * Close WebSocket connection, disconnect listeners and reconnect observers\n *\n * @example\n * await events.closeAll()\n *\n * @returns void on success\n * @throws on error\n */\nasync function closeAll() {\n await AWSAppSyncEventsProvider_1.AppSyncEventProvider.close();\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,OAAO,GAAG,OAAO;AACzB,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,OAAO,CAAC,QAAQ,GAAG,QAAQ;AAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,0BAA0B,GAAG,OAAO,CAAC,0CAA0C,CAAC;AACtF,MAAM,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;AACpD,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;AAClC;AACA,MAAM,YAAY,GAAG,IAAI,GAAG,EAAE;AAC9B,eAAe,OAAO,CAAC,GAAG,IAAI,EAAE;AAChC,IAAI,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC;AACrE,IAAI,MAAM,eAAe,G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