@aws-amplify/api-graphql 4.8.6-unstable.3246992.0 → 4.8.6
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/dist/cjs/Providers/AWSWebSocketProvider/index.js +28 -0
- package/dist/cjs/Providers/AWSWebSocketProvider/index.js.map +1 -1
- package/dist/esm/Providers/AWSWebSocketProvider/index.mjs +28 -0
- package/dist/esm/Providers/AWSWebSocketProvider/index.mjs.map +1 -1
- package/package.json +5 -6
- package/src/Providers/AWSWebSocketProvider/index.ts +33 -0
- package/LICENSE +0 -201
|
@@ -481,14 +481,42 @@ class AWSWebSocketProvider {
|
|
|
481
481
|
subscriptionState,
|
|
482
482
|
});
|
|
483
483
|
let errorMessage = JSON.stringify(payload ?? data);
|
|
484
|
+
let isAuthError = false;
|
|
485
|
+
const AUTH_ERROR_TYPES = [
|
|
486
|
+
'UnauthorizedException',
|
|
487
|
+
'Unauthorized',
|
|
488
|
+
'NotAuthorizedException',
|
|
489
|
+
];
|
|
484
490
|
if (type === constants_1.MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {
|
|
485
491
|
const { errors } = JSON.parse(String(message.data));
|
|
486
492
|
if (Array.isArray(errors) && errors.length > 0) {
|
|
487
493
|
const error = errors[0];
|
|
488
494
|
errorMessage = `${error.errorType}: ${error.message}`;
|
|
495
|
+
isAuthError =
|
|
496
|
+
AUTH_ERROR_TYPES.includes(error.errorType) ||
|
|
497
|
+
error.message?.includes('Token expired');
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
else if (type === constants_1.MESSAGE_TYPES.GQL_ERROR &&
|
|
501
|
+
payload &&
|
|
502
|
+
typeof payload === 'object') {
|
|
503
|
+
const { errors } = payload;
|
|
504
|
+
if (Array.isArray(errors) && errors.length > 0) {
|
|
505
|
+
const error = errors[0];
|
|
506
|
+
isAuthError =
|
|
507
|
+
AUTH_ERROR_TYPES.includes(error.errorType) ||
|
|
508
|
+
error.message?.includes('Token expired');
|
|
489
509
|
}
|
|
490
510
|
}
|
|
491
511
|
this.logger.debug(`${PubSub_1.CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`);
|
|
512
|
+
// On auth errors, close the socket to trigger reconnection with fresh tokens.
|
|
513
|
+
// The onclose handler fires _errorDisconnect → CONNECTION_CLOSED, which the
|
|
514
|
+
// ConnectionStateMonitor picks up as ConnectionDisrupted and the
|
|
515
|
+
// ReconnectionMonitor reconnects with refreshed credentials.
|
|
516
|
+
if (isAuthError && this.awsRealTimeSocket) {
|
|
517
|
+
this.logger.warn('Subscription failed due to auth error, closing WebSocket to trigger reconnection with fresh tokens');
|
|
518
|
+
this.awsRealTimeSocket.close(1000, 'Auth error - reconnecting');
|
|
519
|
+
}
|
|
492
520
|
observer.error({
|
|
493
521
|
errors: [
|
|
494
522
|
{
|
|
@@ -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 } = 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 });\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 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 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 }\n }\n this.logger.debug(`${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 } = 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, }) {\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 });\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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,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 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 } = 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 });\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 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 isAuthError =\n AUTH_ERROR_TYPES.includes(error.errorType) ||\n error.message?.includes('Token expired');\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, }) {\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 });\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(`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AAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,iBAAiB,CAAC;AACzE,QAAQ,CAAC;AACT,IAAI;AACJ;AACA,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;;"}
|
|
@@ -478,14 +478,42 @@ class AWSWebSocketProvider {
|
|
|
478
478
|
subscriptionState,
|
|
479
479
|
});
|
|
480
480
|
let errorMessage = JSON.stringify(payload ?? data);
|
|
481
|
+
let isAuthError = false;
|
|
482
|
+
const AUTH_ERROR_TYPES = [
|
|
483
|
+
'UnauthorizedException',
|
|
484
|
+
'Unauthorized',
|
|
485
|
+
'NotAuthorizedException',
|
|
486
|
+
];
|
|
481
487
|
if (type === MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {
|
|
482
488
|
const { errors } = JSON.parse(String(message.data));
|
|
483
489
|
if (Array.isArray(errors) && errors.length > 0) {
|
|
484
490
|
const error = errors[0];
|
|
485
491
|
errorMessage = `${error.errorType}: ${error.message}`;
|
|
492
|
+
isAuthError =
|
|
493
|
+
AUTH_ERROR_TYPES.includes(error.errorType) ||
|
|
494
|
+
error.message?.includes('Token expired');
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
else if (type === MESSAGE_TYPES.GQL_ERROR &&
|
|
498
|
+
payload &&
|
|
499
|
+
typeof payload === 'object') {
|
|
500
|
+
const { errors } = payload;
|
|
501
|
+
if (Array.isArray(errors) && errors.length > 0) {
|
|
502
|
+
const error = errors[0];
|
|
503
|
+
isAuthError =
|
|
504
|
+
AUTH_ERROR_TYPES.includes(error.errorType) ||
|
|
505
|
+
error.message?.includes('Token expired');
|
|
486
506
|
}
|
|
487
507
|
}
|
|
488
508
|
this.logger.debug(`${CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`);
|
|
509
|
+
// On auth errors, close the socket to trigger reconnection with fresh tokens.
|
|
510
|
+
// The onclose handler fires _errorDisconnect → CONNECTION_CLOSED, which the
|
|
511
|
+
// ConnectionStateMonitor picks up as ConnectionDisrupted and the
|
|
512
|
+
// ReconnectionMonitor reconnects with refreshed credentials.
|
|
513
|
+
if (isAuthError && this.awsRealTimeSocket) {
|
|
514
|
+
this.logger.warn('Subscription failed due to auth error, closing WebSocket to trigger reconnection with fresh tokens');
|
|
515
|
+
this.awsRealTimeSocket.close(1000, 'Auth error - reconnecting');
|
|
516
|
+
}
|
|
489
517
|
observer.error({
|
|
490
518
|
errors: [
|
|
491
519
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/Providers/AWSWebSocketProvider/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable } from 'rxjs';\nimport { GraphQLError } from 'graphql';\nimport { ConsoleLogger, Hub } from '@aws-amplify/core';\nimport { NonRetryableError, amplifyUuid, base64Encoder, isNonRetryableError, jitteredExponentialRetry, } from '@aws-amplify/core/internals/utils';\nimport { CONTROL_MSG, ConnectionState, } from '../../types/PubSub';\nimport { AMPLIFY_SYMBOL, CONNECTION_INIT_TIMEOUT, CONNECTION_STATE_CHANGE, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT, DEFAULT_KEEP_ALIVE_HEARTBEAT_TIMEOUT, MAX_DELAY_MS, MESSAGE_TYPES, NON_RETRYABLE_CODES, NON_RETRYABLE_ERROR_TYPES, SOCKET_STATUS, START_ACK_TIMEOUT, SUBSCRIPTION_STATUS, } from '../constants';\nimport { CONNECTION_CHANGE, ConnectionStateMonitor, } from '../../utils/ConnectionStateMonitor';\nimport { ReconnectEvent, ReconnectionMonitor, } from '../../utils/ReconnectionMonitor';\nimport { additionalHeadersFromOptions, queryParamsFromCustomHeaders, realtimeUrlWithQueryString, } from './appsyncUrl';\nimport { awsRealTimeHeaderBasedAuth } from './authHeaders';\nconst dispatchApiEvent = (payload) => {\n Hub.dispatch('api', payload, 'PubSub', AMPLIFY_SYMBOL);\n};\nexport class AWSWebSocketProvider {\n constructor(args) {\n this.subscriptionObserverMap = new Map();\n this.allowNoSubscriptions = false;\n this.socketStatus = SOCKET_STATUS.CLOSED;\n this.keepAliveTimestamp = Date.now();\n this.promiseArray = [];\n this.connectionStateMonitor = new ConnectionStateMonitor();\n this.reconnectionMonitor = new 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 (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 NON_RETRYABLE_ERROR_TYPES.includes(errorType)) {\n throw new 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 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 = SOCKET_STATUS.CLOSED;\n this.connectionStateMonitor.record(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 Observable(observer => {\n if (!options?.appSyncGraphqlEndpoint) {\n observer.error({\n errors: [\n {\n ...new GraphQLError(`Subscribe only available for AWS AppSync endpoint`),\n },\n ],\n });\n observer.complete();\n return;\n }\n let subscriptionStartInProgress = false;\n const subscriptionId = 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(`${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 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 === SOCKET_STATUS.READY) {\n return;\n }\n await this._connectWebSocket(options);\n }\n async publish(options, customUserAgentDetails) {\n if (this.socketStatus !== 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 } = options;\n const { additionalCustomHeaders } = await additionalHeadersFromOptions(options);\n this.connectionStateMonitor.record(CONNECTION_CHANGE.OPENING_CONNECTION);\n await this._initializeWebSocketConnection({\n apiKey,\n appSyncGraphqlEndpoint,\n authenticationType,\n region,\n additionalCustomHeaders,\n });\n }\n async _publishMessage(options, customUserAgentDetails) {\n const subscriptionId = amplifyUuid();\n const { additionalCustomHeaders, libraryConfigHeaders } = await 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 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 === 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: 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 === ConnectionState.ConnectionDisrupted) {\n this.reconnectionMonitor.record(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 ConnectionState.Connected,\n ConnectionState.ConnectedPendingDisconnect,\n ConnectionState.ConnectedPendingKeepAlive,\n ConnectionState.ConnectedPendingNetwork,\n ConnectionState.ConnectionDisruptedPendingNetwork,\n ConnectionState.Disconnected,\n ].includes(connectionState)) {\n this.reconnectionMonitor.record(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: SUBSCRIPTION_STATUS.PENDING,\n startAckTimeoutId: undefined,\n });\n const { additionalCustomHeaders, libraryConfigHeaders } = await 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: SUBSCRIPTION_STATUS.PENDING,\n query: query ?? '',\n variables: variables ?? {},\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n startAckTimeoutId: setTimeout(() => {\n this._timeoutStartSubscriptionAck(subscriptionId);\n }, 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 !== ConnectionState.ConnectionDisruptedPendingNetwork) {\n // When the error is non-retriable, error out the observable\n if (isNonRetryableError(err)) {\n observer.error({\n errors: [\n {\n ...new GraphQLError(`${CONTROL_MSG.CONNECTION_FAILED}: ${message}`),\n },\n ],\n });\n }\n else {\n this.logger.debug(`${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 === 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 === 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 = SOCKET_STATUS.CLOSED;\n return;\n }\n this.connectionStateMonitor.record(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 = 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 DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT) {\n this.connectionStateMonitor.record(CONNECTION_CHANGE.KEEP_ALIVE_MISSED);\n }\n else {\n this.connectionStateMonitor.record(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(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 === MESSAGE_TYPES.GQL_START_ACK ||\n type === 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: CONTROL_MSG.SUBSCRIPTION_ACK,\n data: { query, variables },\n message: 'Connection established for subscription',\n });\n const subscriptionState = 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(CONNECTION_CHANGE.CONNECTION_ESTABLISHED);\n return;\n }\n if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {\n this.maintainKeepAlive();\n return;\n }\n if (type === MESSAGE_TYPES.GQL_ERROR ||\n type === MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {\n const subscriptionState = 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 if (type === 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 }\n }\n this.logger.debug(`${CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`);\n observer.error({\n errors: [\n {\n ...new GraphQLError(`${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 = SOCKET_STATUS.CLOSED;\n }\n _closeSocket() {\n if (this.keepAliveHeartbeatIntervalId) {\n clearInterval(this.keepAliveHeartbeatIntervalId);\n this.keepAliveHeartbeatIntervalId = undefined;\n }\n this.connectionStateMonitor.record(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: 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, }) {\n if (this.socketStatus === 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 === SOCKET_STATUS.CLOSED) {\n try {\n this.socketStatus = SOCKET_STATUS.CONNECTING;\n // Empty payload on connect\n const payloadString = '{}';\n const authHeader = await awsRealTimeHeaderBasedAuth({\n authenticationType,\n payload: payloadString,\n canonicalUri: this.wsConnectUri,\n apiKey,\n appSyncGraphqlEndpoint,\n region,\n additionalCustomHeaders,\n });\n const headerString = authHeader ? JSON.stringify(authHeader) : '';\n // base64url-encoded string\n const encodedHeader = base64Encoder.convert(headerString, {\n urlSafe: true,\n skipPadding: true,\n });\n const authTokenSubprotocol = `header-${encodedHeader}`;\n const queryParams = queryParamsFromCustomHeaders(additionalCustomHeaders);\n const awsRealTimeUrl = 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 = 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 = SOCKET_STATUS.CLOSED;\n }\n }\n });\n }\n async _establishRetryableConnection(awsRealTimeUrl, subprotocol) {\n this.logger.debug(`Establishing retryable connection`);\n await jitteredExponentialRetry(this._establishConnection.bind(this), [awsRealTimeUrl, subprotocol], 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 === MESSAGE_TYPES.GQL_CONNECTION_ACK) {\n ackOk = true;\n this._registerWebsocketHandlers(connectionTimeoutMs);\n resolve('Connected to AWS AppSyncRealTime');\n return;\n }\n if (type === 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: MESSAGE_TYPES.GQL_CONNECTION_INIT,\n };\n this.awsRealTimeSocket.send(JSON.stringify(gqlInit));\n const checkAckOk = (targetAckOk) => {\n if (!targetAckOk) {\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_FAILED);\n reject(new Error(`Connection timeout: ack from AWSAppSyncRealTime was not received after ${CONNECTION_INIT_TIMEOUT} ms`));\n }\n };\n setTimeout(() => {\n checkAckOk(ackOk);\n }, 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 }, 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(CONTROL_MSG.CONNECTION_CLOSED);\n };\n this.awsRealTimeSocket.onclose = event => {\n this.logger.debug(`WebSocket closed ${event.reason}`);\n this._closeSocket();\n this._errorDisconnect(CONTROL_MSG.CONNECTION_CLOSED);\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAWA,MAAM,gBAAgB,GAAG,CAAC,OAAO,KAAK;AACtC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC;AAC1D,CAAC;AACM,MAAM,oBAAoB,CAAC;AAClC,IAAI,WAAW,CAAC,IAAI,EAAE;AACtB,QAAQ,IAAI,CAAC,uBAAuB,GAAG,IAAI,GAAG,EAAE;AAChD,QAAQ,IAAI,CAAC,oBAAoB,GAAG,KAAK;AACzC,QAAQ,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,MAAM;AAChD,QAAQ,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,EAAE;AAC5C,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE;AAC9B,QAAQ,IAAI,CAAC,sBAAsB,GAAG,IAAI,sBAAsB,EAAE;AAClE,QAAQ,IAAI,CAAC,mBAAmB,GAAG,IAAI,mBAAmB,EAAE;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,oBAAoB,GAAG,OAAO,cAAc,EAAE,WAAW,KAAK;AAC3E,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,qCAAqC,EAAE,cAAc,CAAC,CAAC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":["../../../../src/Providers/AWSWebSocketProvider/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable } from 'rxjs';\nimport { GraphQLError } from 'graphql';\nimport { ConsoleLogger, Hub } from '@aws-amplify/core';\nimport { NonRetryableError, amplifyUuid, base64Encoder, isNonRetryableError, jitteredExponentialRetry, } from '@aws-amplify/core/internals/utils';\nimport { CONTROL_MSG, ConnectionState, } from '../../types/PubSub';\nimport { AMPLIFY_SYMBOL, CONNECTION_INIT_TIMEOUT, CONNECTION_STATE_CHANGE, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT, DEFAULT_KEEP_ALIVE_HEARTBEAT_TIMEOUT, MAX_DELAY_MS, MESSAGE_TYPES, NON_RETRYABLE_CODES, NON_RETRYABLE_ERROR_TYPES, SOCKET_STATUS, START_ACK_TIMEOUT, SUBSCRIPTION_STATUS, } from '../constants';\nimport { CONNECTION_CHANGE, ConnectionStateMonitor, } from '../../utils/ConnectionStateMonitor';\nimport { ReconnectEvent, ReconnectionMonitor, } from '../../utils/ReconnectionMonitor';\nimport { additionalHeadersFromOptions, queryParamsFromCustomHeaders, realtimeUrlWithQueryString, } from './appsyncUrl';\nimport { awsRealTimeHeaderBasedAuth } from './authHeaders';\nconst dispatchApiEvent = (payload) => {\n Hub.dispatch('api', payload, 'PubSub', AMPLIFY_SYMBOL);\n};\nexport class AWSWebSocketProvider {\n constructor(args) {\n this.subscriptionObserverMap = new Map();\n this.allowNoSubscriptions = false;\n this.socketStatus = SOCKET_STATUS.CLOSED;\n this.keepAliveTimestamp = Date.now();\n this.promiseArray = [];\n this.connectionStateMonitor = new ConnectionStateMonitor();\n this.reconnectionMonitor = new 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 (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 NON_RETRYABLE_ERROR_TYPES.includes(errorType)) {\n throw new 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 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 = SOCKET_STATUS.CLOSED;\n this.connectionStateMonitor.record(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 Observable(observer => {\n if (!options?.appSyncGraphqlEndpoint) {\n observer.error({\n errors: [\n {\n ...new GraphQLError(`Subscribe only available for AWS AppSync endpoint`),\n },\n ],\n });\n observer.complete();\n return;\n }\n let subscriptionStartInProgress = false;\n const subscriptionId = 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(`${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 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 === SOCKET_STATUS.READY) {\n return;\n }\n await this._connectWebSocket(options);\n }\n async publish(options, customUserAgentDetails) {\n if (this.socketStatus !== 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 } = options;\n const { additionalCustomHeaders } = await additionalHeadersFromOptions(options);\n this.connectionStateMonitor.record(CONNECTION_CHANGE.OPENING_CONNECTION);\n await this._initializeWebSocketConnection({\n apiKey,\n appSyncGraphqlEndpoint,\n authenticationType,\n region,\n additionalCustomHeaders,\n });\n }\n async _publishMessage(options, customUserAgentDetails) {\n const subscriptionId = amplifyUuid();\n const { additionalCustomHeaders, libraryConfigHeaders } = await 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 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 === 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: 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 === ConnectionState.ConnectionDisrupted) {\n this.reconnectionMonitor.record(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 ConnectionState.Connected,\n ConnectionState.ConnectedPendingDisconnect,\n ConnectionState.ConnectedPendingKeepAlive,\n ConnectionState.ConnectedPendingNetwork,\n ConnectionState.ConnectionDisruptedPendingNetwork,\n ConnectionState.Disconnected,\n ].includes(connectionState)) {\n this.reconnectionMonitor.record(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: SUBSCRIPTION_STATUS.PENDING,\n startAckTimeoutId: undefined,\n });\n const { additionalCustomHeaders, libraryConfigHeaders } = await 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: SUBSCRIPTION_STATUS.PENDING,\n query: query ?? '',\n variables: variables ?? {},\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n startAckTimeoutId: setTimeout(() => {\n this._timeoutStartSubscriptionAck(subscriptionId);\n }, 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 !== ConnectionState.ConnectionDisruptedPendingNetwork) {\n // When the error is non-retriable, error out the observable\n if (isNonRetryableError(err)) {\n observer.error({\n errors: [\n {\n ...new GraphQLError(`${CONTROL_MSG.CONNECTION_FAILED}: ${message}`),\n },\n ],\n });\n }\n else {\n this.logger.debug(`${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 === 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 === 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 = SOCKET_STATUS.CLOSED;\n return;\n }\n this.connectionStateMonitor.record(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 = 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 DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT) {\n this.connectionStateMonitor.record(CONNECTION_CHANGE.KEEP_ALIVE_MISSED);\n }\n else {\n this.connectionStateMonitor.record(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(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 === MESSAGE_TYPES.GQL_START_ACK ||\n type === 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: CONTROL_MSG.SUBSCRIPTION_ACK,\n data: { query, variables },\n message: 'Connection established for subscription',\n });\n const subscriptionState = 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(CONNECTION_CHANGE.CONNECTION_ESTABLISHED);\n return;\n }\n if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {\n this.maintainKeepAlive();\n return;\n }\n if (type === MESSAGE_TYPES.GQL_ERROR ||\n type === MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {\n const subscriptionState = 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 === 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 isAuthError =\n AUTH_ERROR_TYPES.includes(error.errorType) ||\n error.message?.includes('Token expired');\n }\n }\n else if (type === 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(`${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 GraphQLError(`${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 = SOCKET_STATUS.CLOSED;\n }\n _closeSocket() {\n if (this.keepAliveHeartbeatIntervalId) {\n clearInterval(this.keepAliveHeartbeatIntervalId);\n this.keepAliveHeartbeatIntervalId = undefined;\n }\n this.connectionStateMonitor.record(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: 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, }) {\n if (this.socketStatus === 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 === SOCKET_STATUS.CLOSED) {\n try {\n this.socketStatus = SOCKET_STATUS.CONNECTING;\n // Empty payload on connect\n const payloadString = '{}';\n const authHeader = await awsRealTimeHeaderBasedAuth({\n authenticationType,\n payload: payloadString,\n canonicalUri: this.wsConnectUri,\n apiKey,\n appSyncGraphqlEndpoint,\n region,\n additionalCustomHeaders,\n });\n const headerString = authHeader ? JSON.stringify(authHeader) : '';\n // base64url-encoded string\n const encodedHeader = base64Encoder.convert(headerString, {\n urlSafe: true,\n skipPadding: true,\n });\n const authTokenSubprotocol = `header-${encodedHeader}`;\n const queryParams = queryParamsFromCustomHeaders(additionalCustomHeaders);\n const awsRealTimeUrl = 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 = 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 = SOCKET_STATUS.CLOSED;\n }\n }\n });\n }\n async _establishRetryableConnection(awsRealTimeUrl, subprotocol) {\n this.logger.debug(`Establishing retryable connection`);\n await jitteredExponentialRetry(this._establishConnection.bind(this), [awsRealTimeUrl, subprotocol], 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 === MESSAGE_TYPES.GQL_CONNECTION_ACK) {\n ackOk = true;\n this._registerWebsocketHandlers(connectionTimeoutMs);\n resolve('Connected to AWS AppSyncRealTime');\n return;\n }\n if (type === 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: MESSAGE_TYPES.GQL_CONNECTION_INIT,\n };\n this.awsRealTimeSocket.send(JSON.stringify(gqlInit));\n const checkAckOk = (targetAckOk) => {\n if (!targetAckOk) {\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_FAILED);\n reject(new Error(`Connection timeout: ack from AWSAppSyncRealTime was not received after ${CONNECTION_INIT_TIMEOUT} ms`));\n }\n };\n setTimeout(() => {\n checkAckOk(ackOk);\n }, 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 }, 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(CONTROL_MSG.CONNECTION_CLOSED);\n };\n this.awsRealTimeSocket.onclose = event => {\n this.logger.debug(`WebSocket closed ${event.reason}`);\n this._closeSocket();\n this._errorDisconnect(CONTROL_MSG.CONNECTION_CLOSED);\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAWA,MAAM,gBAAgB,GAAG,CAAC,OAAO,KAAK;AACtC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC;AAC1D,CAAC;AACM,MAAM,oBAAoB,CAAC;AAClC,IAAI,WAAW,CAAC,IAAI,EAAE;AACtB,QAAQ,IAAI,CAAC,uBAAuB,GAAG,IAAI,GAAG,EAAE;AAChD,QAAQ,IAAI,CAAC,oBAAoB,GAAG,KAAK;AACzC,QAAQ,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,MAAM;AAChD,QAAQ,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,EAAE;AAC5C,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE;AAC9B,QAAQ,IAAI,CAAC,sBAA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AAC,iBAAiB,CAAC;AAChE,QAAQ,CAAC;AACT,IAAI;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/api-graphql",
|
|
3
|
-
"version": "4.8.6
|
|
3
|
+
"version": "4.8.6",
|
|
4
4
|
"description": "Api-graphql category of aws-amplify",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -79,10 +79,10 @@
|
|
|
79
79
|
"server"
|
|
80
80
|
],
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@aws-amplify/api-rest": "4.6.4
|
|
83
|
-
"@aws-amplify/core": "6.16.2
|
|
82
|
+
"@aws-amplify/api-rest": "4.6.4",
|
|
83
|
+
"@aws-amplify/core": "6.16.2",
|
|
84
84
|
"@aws-amplify/data-schema": "^1.7.0",
|
|
85
|
-
"@aws-sdk/types": "3.973.
|
|
85
|
+
"@aws-sdk/types": "^3.973.6",
|
|
86
86
|
"graphql": "15.8.0",
|
|
87
87
|
"rxjs": "^7.8.1",
|
|
88
88
|
"tslib": "^2.5.0",
|
|
@@ -95,6 +95,5 @@
|
|
|
95
95
|
"import": "{ Amplify, GraphQLAPI }",
|
|
96
96
|
"limit": "91.7 kB"
|
|
97
97
|
}
|
|
98
|
-
]
|
|
99
|
-
"gitHead": "324699261cfef10c9783db6533c3e446ad99e510"
|
|
98
|
+
]
|
|
100
99
|
}
|
|
@@ -701,17 +701,50 @@ export abstract class AWSWebSocketProvider {
|
|
|
701
701
|
});
|
|
702
702
|
|
|
703
703
|
let errorMessage = JSON.stringify(payload ?? data);
|
|
704
|
+
let isAuthError = false;
|
|
705
|
+
|
|
706
|
+
const AUTH_ERROR_TYPES = [
|
|
707
|
+
'UnauthorizedException',
|
|
708
|
+
'Unauthorized',
|
|
709
|
+
'NotAuthorizedException',
|
|
710
|
+
];
|
|
704
711
|
|
|
705
712
|
if (type === MESSAGE_TYPES.EVENT_SUBSCRIBE_ERROR) {
|
|
706
713
|
const { errors } = JSON.parse(String(message.data));
|
|
707
714
|
if (Array.isArray(errors) && errors.length > 0) {
|
|
708
715
|
const error = errors[0];
|
|
709
716
|
errorMessage = `${error.errorType}: ${error.message}`;
|
|
717
|
+
isAuthError =
|
|
718
|
+
AUTH_ERROR_TYPES.includes(error.errorType) ||
|
|
719
|
+
error.message?.includes('Token expired');
|
|
720
|
+
}
|
|
721
|
+
} else if (
|
|
722
|
+
type === MESSAGE_TYPES.GQL_ERROR &&
|
|
723
|
+
payload &&
|
|
724
|
+
typeof payload === 'object'
|
|
725
|
+
) {
|
|
726
|
+
const { errors } = payload as Record<string, unknown>;
|
|
727
|
+
if (Array.isArray(errors) && errors.length > 0) {
|
|
728
|
+
const error = errors[0] as Record<string, string>;
|
|
729
|
+
isAuthError =
|
|
730
|
+
AUTH_ERROR_TYPES.includes(error.errorType) ||
|
|
731
|
+
error.message?.includes('Token expired');
|
|
710
732
|
}
|
|
711
733
|
}
|
|
712
734
|
|
|
713
735
|
this.logger.debug(`${CONTROL_MSG.CONNECTION_FAILED}: ${errorMessage}`);
|
|
714
736
|
|
|
737
|
+
// On auth errors, close the socket to trigger reconnection with fresh tokens.
|
|
738
|
+
// The onclose handler fires _errorDisconnect → CONNECTION_CLOSED, which the
|
|
739
|
+
// ConnectionStateMonitor picks up as ConnectionDisrupted and the
|
|
740
|
+
// ReconnectionMonitor reconnects with refreshed credentials.
|
|
741
|
+
if (isAuthError && this.awsRealTimeSocket) {
|
|
742
|
+
this.logger.warn(
|
|
743
|
+
'Subscription failed due to auth error, closing WebSocket to trigger reconnection with fresh tokens',
|
|
744
|
+
);
|
|
745
|
+
this.awsRealTimeSocket.close(1000, 'Auth error - reconnecting');
|
|
746
|
+
}
|
|
747
|
+
|
|
715
748
|
observer.error({
|
|
716
749
|
errors: [
|
|
717
750
|
{
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|