@dynamic-labs/message-transport 4.18.8 → 4.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +6 -6
- package/src/index.cjs +3 -0
- package/src/index.d.ts +2 -2
- package/src/index.js +1 -0
- package/src/messageTransport/decorators/applyRecoveryManager/applyRecoveryManager.cjs +43 -0
- package/src/messageTransport/decorators/applyRecoveryManager/applyRecoveryManager.d.ts +26 -0
- package/src/messageTransport/decorators/applyRecoveryManager/applyRecoveryManager.js +38 -0
- package/src/messageTransport/decorators/applyRecoveryManager/index.d.ts +1 -0
- package/src/messageTransport/decorators/index.d.ts +1 -0
- package/src/messageTypes/ViemMessages.d.ts +51 -0
- package/src/messageTypes/ZeroDevExtensionMessages.d.ts +1 -0
- package/src/messageTypes/index.d.ts +1 -0
- package/src/requestChannel/createRequestChannelMessageSender/createRequestChannelMessageSender.cjs +13 -1
- package/src/requestChannel/createRequestChannelMessageSender/createRequestChannelMessageSender.js +13 -1
- package/src/requestChannel/requestChannel.cjs +2 -2
- package/src/requestChannel/requestChannel.js +2 -2
- package/src/requestChannel/utils/utils.cjs +1 -1
- package/src/requestChannel/utils/utils.d.ts +1 -1
- package/src/requestChannel/utils/utils.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.19.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.0...v4.19.1) (2025-05-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **react-native:** reload webview when disconnected ([#8765](https://github.com/dynamic-labs/dynamic-auth/issues/8765)) ([addf90b](https://github.com/dynamic-labs/dynamic-auth/commit/addf90b6fccbe4b883e9778cf7a07e0471f85318))
|
|
8
|
+
|
|
9
|
+
## [4.19.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.8...v4.19.0) (2025-05-23)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* expose 7702 kernel and add viem controller ([#8786](https://github.com/dynamic-labs/dynamic-auth/issues/8786)) ([eea710e](https://github.com/dynamic-labs/dynamic-auth/commit/eea710e238ccbc36e6be37d8f7493954b99858ef))
|
|
15
|
+
* use browser wallet client & iframe for waas operations ([#8697](https://github.com/dynamic-labs/dynamic-auth/issues/8697)) ([13a47b1](https://github.com/dynamic-labs/dynamic-auth/commit/13a47b1c9a2984f08682e833ca8c87605a3a872f))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **global-wallet:** close popup when page unloads to prevent orphaned popup windows ([#8787](https://github.com/dynamic-labs/dynamic-auth/issues/8787)) ([441b04c](https://github.com/dynamic-labs/dynamic-auth/commit/441b04ca04a02feb37473e43bca0e66c5d772ce2))
|
|
21
|
+
* override network when requesting BTC networks in useTokenBalances ([#8773](https://github.com/dynamic-labs/dynamic-auth/issues/8773)) ([fd07d09](https://github.com/dynamic-labs/dynamic-auth/commit/fd07d09de970c7e6f85b251a88854e8eca57e249))
|
|
22
|
+
* remove libmpc executor dependency global wallet ([#8792](https://github.com/dynamic-labs/dynamic-auth/issues/8792)) ([7502585](https://github.com/dynamic-labs/dynamic-auth/commit/75025859d2f952915322cf65504117ec2506152b))
|
|
23
|
+
* standardize font on headers ([#8734](https://github.com/dynamic-labs/dynamic-auth/issues/8734)) ([9f0900c](https://github.com/dynamic-labs/dynamic-auth/commit/9f0900cb7c4294201cc952ae7538648bdea83ff5))
|
|
24
|
+
|
|
2
25
|
### [4.18.8](https://github.com/dynamic-labs/dynamic-auth/compare/v4.18.7...v4.18.8) (2025-05-22)
|
|
3
26
|
|
|
4
27
|
### Bug Fixes
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/message-transport",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.19.1",
|
|
4
4
|
"description": "Defines the interface to communicate with dynamic's webview",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@dynamic-labs/sdk-api-core": "0.0.672",
|
|
22
22
|
"@vue/reactivity": "^3.4.21",
|
|
23
|
-
"@dynamic-labs/types": "4.
|
|
23
|
+
"@dynamic-labs/types": "4.19.1",
|
|
24
24
|
"eventemitter3": "5.0.1",
|
|
25
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
26
|
-
"@dynamic-labs/logger": "4.
|
|
27
|
-
"@dynamic-labs/utils": "4.
|
|
28
|
-
"@dynamic-labs/webauthn": "4.
|
|
25
|
+
"@dynamic-labs/assert-package-version": "4.19.1",
|
|
26
|
+
"@dynamic-labs/logger": "4.19.1",
|
|
27
|
+
"@dynamic-labs/utils": "4.19.1",
|
|
28
|
+
"@dynamic-labs/webauthn": "4.19.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {}
|
|
31
31
|
}
|
package/src/index.cjs
CHANGED
|
@@ -9,6 +9,7 @@ var messageTransport = require('./messageTransport/messageTransport.cjs');
|
|
|
9
9
|
var applyDefaultMessageOrigin = require('./messageTransport/decorators/applyDefaultMessageOrigin/applyDefaultMessageOrigin.cjs');
|
|
10
10
|
var makeWaitForInitEvent = require('./messageTransport/decorators/makeWaitForInitEvent/makeWaitForInitEvent.cjs');
|
|
11
11
|
var makeWaitForUnblock = require('./messageTransport/decorators/makeWaitForUnblock/makeWaitForUnblock.cjs');
|
|
12
|
+
var applyRecoveryManager = require('./messageTransport/decorators/applyRecoveryManager/applyRecoveryManager.cjs');
|
|
12
13
|
var requestChannel = require('./requestChannel/requestChannel.cjs');
|
|
13
14
|
var utils = require('./requestChannel/utils/utils.cjs');
|
|
14
15
|
var parseErrorFromTransport = require('./utils/parseErrorFromTransport/parseErrorFromTransport.cjs');
|
|
@@ -31,6 +32,8 @@ exports.createMessageTransport = messageTransport.createMessageTransport;
|
|
|
31
32
|
exports.applyDefaultMessageOrigin = applyDefaultMessageOrigin.applyDefaultMessageOrigin;
|
|
32
33
|
exports.makeWaitForInitEvent = makeWaitForInitEvent.makeWaitForInitEvent;
|
|
33
34
|
exports.makeWaitForUnblock = makeWaitForUnblock.makeWaitForUnblock;
|
|
35
|
+
exports.applyRecoveryManager = applyRecoveryManager.applyRecoveryManager;
|
|
36
|
+
exports.hasRecoveryManager = applyRecoveryManager.hasRecoveryManager;
|
|
34
37
|
exports.createRequestChannel = requestChannel.createRequestChannel;
|
|
35
38
|
exports.getAckMessageType = utils.getAckMessageType;
|
|
36
39
|
exports.getRejectMessageType = utils.getRejectMessageType;
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { applyDefaultMessageOrigin, createMessageTransport, makeWaitForInitEvent, makeWaitForUnblock, type BypassBlockCallback, type MessageTransport, type MessageTransportCallback, type MessageTransportData, type MessageTransportDataOptionalOrigin, type MessageTransportWithDefaultOrigin, } from './messageTransport';
|
|
1
|
+
export { applyDefaultMessageOrigin, createMessageTransport, makeWaitForInitEvent, makeWaitForUnblock, applyRecoveryManager, hasRecoveryManager, type BypassBlockCallback, type MessageTransport, type MessageTransportCallback, type MessageTransportData, type MessageTransportDataOptionalOrigin, type MessageTransportWithDefaultOrigin, } from './messageTransport';
|
|
2
2
|
export { createRequestChannel, type RequestChannel, type RequestTypes, type TypesExpectingResponse, getAckMessageType, getRejectMessageType, getResolveMessageType, isAckMessageType, isRejectMessageType, isResolveMessageType, isRequestMessageType, } from './requestChannel';
|
|
3
3
|
export { parseErrorFromTransport } from './utils/parseErrorFromTransport';
|
|
4
4
|
export { parseMessageTransportData } from './utils/parseMessageTransportData';
|
|
@@ -7,4 +7,4 @@ export { isSerializedError } from './utils/isSerializedError';
|
|
|
7
7
|
export { createEventEmitterForMessages, createStore, createStoreSetter, type CreateStoreProps, } from './store';
|
|
8
8
|
export type { Store, StoreEventListeners, StoreKeys, StoreSetter, StoreStateChangeEvent, StoreStateEvents, StoreStateGetters, } from './store/types';
|
|
9
9
|
export type { PickedEventListeners } from './types';
|
|
10
|
-
export { authEventNames, emailEventNames, embeddedWalletsEventNames, sdkHasLoadedEventName, smsEventNames, userInterfaceEventNames, userWalletsEventNames, type AccountAbstractionGetEOAWalletArgs, type AccountAbstractionGetSmartWalletArgs, type AccountAbstractionIsSmartWalletArgs, type AccountAbstractionMessages, type AuthModuleMessages, type AuthModuleState, type ClientManifest, type ConsoleMessages, type CreateEmbeddedWalletArgs, type DeleteStorageItemArgs, type EmailOtpParams, type EmbeddedWalletsModuleMessages, type EmbeddedWalletsModuleState, type EthMessages, type EthRequestParams, type EthRequestWithAddressParams, type EthRequestWithChainIdParams, type ExternalAuthMessages, type FetchMessages, type GetStorageItemArgs, type KernelAccountSettings, type NetworksModuleState, type OtpData, type OtpMessages, type PasskeyMessages, type PlatformServiceMessages, type ProjectSettingsMessages, type SdkModuleMessages, type SdkModuleState, type SetStorageItemArgs, type SignInWithExternalJwtParams, type SmsOtpParams, type SocialAuthModuleMessages, type SocialProvider, type SolanaMessages, type StorageMessages, type StorageMessageSource, type TurnkeyIframeEventProxyMessages, type UserInterfaceModuleMessages, type VerifyWithExternalJwtParams, type WalletEvents, type WalletsModuleMessages, type WalletsModuleState, type WebViewVisibilityMessages, type ZeroDevExtensionMessages, } from './messageTypes';
|
|
10
|
+
export { authEventNames, emailEventNames, embeddedWalletsEventNames, sdkHasLoadedEventName, smsEventNames, userInterfaceEventNames, userWalletsEventNames, type AccountAbstractionGetEOAWalletArgs, type AccountAbstractionGetSmartWalletArgs, type AccountAbstractionIsSmartWalletArgs, type AccountAbstractionMessages, type AuthModuleMessages, type AuthModuleState, type ClientManifest, type ConsoleMessages, type CreateEmbeddedWalletArgs, type DeleteStorageItemArgs, type EmailOtpParams, type EmbeddedWalletsModuleMessages, type EmbeddedWalletsModuleState, type EthMessages, type EthRequestParams, type EthRequestWithAddressParams, type EthRequestWithChainIdParams, type ExternalAuthMessages, type FetchMessages, type GetStorageItemArgs, type KernelAccountSettings, type NetworksModuleState, type OtpData, type OtpMessages, type PasskeyMessages, type PlatformServiceMessages, type ProjectSettingsMessages, type SdkModuleMessages, type SdkModuleState, type SetStorageItemArgs, type SignInWithExternalJwtParams, type SmsOtpParams, type SocialAuthModuleMessages, type SocialProvider, type SolanaMessages, type StorageMessages, type StorageMessageSource, type TurnkeyIframeEventProxyMessages, type UserInterfaceModuleMessages, type ViemMessages, type VerifyWithExternalJwtParams, type WalletEvents, type WalletsModuleMessages, type WalletsModuleState, type WebViewVisibilityMessages, type ZeroDevExtensionMessages, } from './messageTypes';
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { createMessageTransport } from './messageTransport/messageTransport.js';
|
|
|
5
5
|
export { applyDefaultMessageOrigin } from './messageTransport/decorators/applyDefaultMessageOrigin/applyDefaultMessageOrigin.js';
|
|
6
6
|
export { makeWaitForInitEvent } from './messageTransport/decorators/makeWaitForInitEvent/makeWaitForInitEvent.js';
|
|
7
7
|
export { makeWaitForUnblock } from './messageTransport/decorators/makeWaitForUnblock/makeWaitForUnblock.js';
|
|
8
|
+
export { applyRecoveryManager, hasRecoveryManager } from './messageTransport/decorators/applyRecoveryManager/applyRecoveryManager.js';
|
|
8
9
|
export { createRequestChannel } from './requestChannel/requestChannel.js';
|
|
9
10
|
export { getAckMessageType, getRejectMessageType, getResolveMessageType, isAckMessageType, isRejectMessageType, isRequestMessageType, isResolveMessageType } from './requestChannel/utils/utils.js';
|
|
10
11
|
export { parseErrorFromTransport } from './utils/parseErrorFromTransport/parseErrorFromTransport.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var EventEmitter = require('eventemitter3');
|
|
7
|
+
|
|
8
|
+
const MAX_RETRIES = 1;
|
|
9
|
+
/**
|
|
10
|
+
* Applies recovery management functionality to a MessageTransport
|
|
11
|
+
* This allows for handling message delivery failures and connection recovery
|
|
12
|
+
*/
|
|
13
|
+
const applyRecoveryManager = ({ messageTransport, }) => {
|
|
14
|
+
const eventEmitter = new EventEmitter.EventEmitter();
|
|
15
|
+
const messageRetryCounts = new Map();
|
|
16
|
+
return Object.assign(Object.assign({}, messageTransport), { recoveryManager: {
|
|
17
|
+
canRetryMessageSessionId: (messageSessionId) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const currentCount = (_a = messageRetryCounts.get(messageSessionId)) !== null && _a !== void 0 ? _a : 0;
|
|
20
|
+
return currentCount < MAX_RETRIES;
|
|
21
|
+
},
|
|
22
|
+
onRecoveryRequested: (callback) => {
|
|
23
|
+
eventEmitter.on('recoveryRequested', callback);
|
|
24
|
+
return () => eventEmitter.off('recoveryRequested', callback);
|
|
25
|
+
},
|
|
26
|
+
triggerRecovery: (messageSessionId) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const currentCount = (_a = messageRetryCounts.get(messageSessionId)) !== null && _a !== void 0 ? _a : 0;
|
|
29
|
+
messageRetryCounts.set(messageSessionId, currentCount + 1);
|
|
30
|
+
if (messageTransport.isBlocked()) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
eventEmitter.emit('recoveryRequested');
|
|
34
|
+
},
|
|
35
|
+
} });
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Type guard to check if a MessageTransport has recovery management functionality
|
|
39
|
+
*/
|
|
40
|
+
const hasRecoveryManager = (messageTransport) => 'recoveryManager' in messageTransport;
|
|
41
|
+
|
|
42
|
+
exports.applyRecoveryManager = applyRecoveryManager;
|
|
43
|
+
exports.hasRecoveryManager = hasRecoveryManager;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MessageTransport } from '../../messageTransport';
|
|
2
|
+
import { WithBlock } from '../makeWaitForUnblock';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for the recovery management functionality that can be added to a MessageTransport
|
|
5
|
+
*/
|
|
6
|
+
export type WithRecoveryManager<T extends MessageTransport> = T & {
|
|
7
|
+
recoveryManager: {
|
|
8
|
+
/** Check if a specific message session can be retried */
|
|
9
|
+
canRetryMessageSessionId: (messageSessionId: string) => boolean;
|
|
10
|
+
/** Trigger a recovery attempt for a specific message session */
|
|
11
|
+
triggerRecovery: (messageSessionId: string) => void;
|
|
12
|
+
/** Register a callback to be called when recovery is requested */
|
|
13
|
+
onRecoveryRequested: (callback: () => void) => () => void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Applies recovery management functionality to a MessageTransport
|
|
18
|
+
* This allows for handling message delivery failures and connection recovery
|
|
19
|
+
*/
|
|
20
|
+
export declare const applyRecoveryManager: <T extends WithBlock<MessageTransport>>({ messageTransport, }: {
|
|
21
|
+
messageTransport: T;
|
|
22
|
+
}) => WithRecoveryManager<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Type guard to check if a MessageTransport has recovery management functionality
|
|
25
|
+
*/
|
|
26
|
+
export declare const hasRecoveryManager: (messageTransport: MessageTransport) => messageTransport is WithRecoveryManager<MessageTransport>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
|
+
|
|
4
|
+
const MAX_RETRIES = 1;
|
|
5
|
+
/**
|
|
6
|
+
* Applies recovery management functionality to a MessageTransport
|
|
7
|
+
* This allows for handling message delivery failures and connection recovery
|
|
8
|
+
*/
|
|
9
|
+
const applyRecoveryManager = ({ messageTransport, }) => {
|
|
10
|
+
const eventEmitter = new EventEmitter();
|
|
11
|
+
const messageRetryCounts = new Map();
|
|
12
|
+
return Object.assign(Object.assign({}, messageTransport), { recoveryManager: {
|
|
13
|
+
canRetryMessageSessionId: (messageSessionId) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const currentCount = (_a = messageRetryCounts.get(messageSessionId)) !== null && _a !== void 0 ? _a : 0;
|
|
16
|
+
return currentCount < MAX_RETRIES;
|
|
17
|
+
},
|
|
18
|
+
onRecoveryRequested: (callback) => {
|
|
19
|
+
eventEmitter.on('recoveryRequested', callback);
|
|
20
|
+
return () => eventEmitter.off('recoveryRequested', callback);
|
|
21
|
+
},
|
|
22
|
+
triggerRecovery: (messageSessionId) => {
|
|
23
|
+
var _a;
|
|
24
|
+
const currentCount = (_a = messageRetryCounts.get(messageSessionId)) !== null && _a !== void 0 ? _a : 0;
|
|
25
|
+
messageRetryCounts.set(messageSessionId, currentCount + 1);
|
|
26
|
+
if (messageTransport.isBlocked()) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
eventEmitter.emit('recoveryRequested');
|
|
30
|
+
},
|
|
31
|
+
} });
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Type guard to check if a MessageTransport has recovery management functionality
|
|
35
|
+
*/
|
|
36
|
+
const hasRecoveryManager = (messageTransport) => 'recoveryManager' in messageTransport;
|
|
37
|
+
|
|
38
|
+
export { applyRecoveryManager, hasRecoveryManager };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { applyRecoveryManager, hasRecoveryManager, type WithRecoveryManager, } from './applyRecoveryManager';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
type Hex = `0x${string}`;
|
|
2
|
+
type ByteArray = Uint8Array;
|
|
3
|
+
type SignableMessage = string | {
|
|
4
|
+
raw: Hex | ByteArray;
|
|
5
|
+
};
|
|
6
|
+
type TransactionSerializable = {
|
|
7
|
+
to?: Hex | null;
|
|
8
|
+
data?: Hex;
|
|
9
|
+
value?: bigint;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
type TypedDataParameter = {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
export type TypedData = {
|
|
17
|
+
types: {
|
|
18
|
+
[key: string]: TypedDataParameter[];
|
|
19
|
+
};
|
|
20
|
+
primaryType: string;
|
|
21
|
+
domain: {
|
|
22
|
+
name?: string;
|
|
23
|
+
version?: string;
|
|
24
|
+
chainId?: number;
|
|
25
|
+
verifyingContract?: Hex;
|
|
26
|
+
salt?: Hex;
|
|
27
|
+
};
|
|
28
|
+
message: Record<string, unknown>;
|
|
29
|
+
};
|
|
30
|
+
type SignAuthorizationReturnType = {
|
|
31
|
+
address: Hex;
|
|
32
|
+
chainId: number;
|
|
33
|
+
nonce: number;
|
|
34
|
+
r: Hex;
|
|
35
|
+
s: Hex;
|
|
36
|
+
v?: bigint;
|
|
37
|
+
yParity?: number;
|
|
38
|
+
};
|
|
39
|
+
type SignAuthorizationParametersWithoutPrivateKey = {
|
|
40
|
+
address?: Hex;
|
|
41
|
+
contractAddress?: Hex;
|
|
42
|
+
chainId: number;
|
|
43
|
+
nonce: number;
|
|
44
|
+
};
|
|
45
|
+
export type ViemMessages = {
|
|
46
|
+
viem_signAuthorization: (walletId: string, parameters: SignAuthorizationParametersWithoutPrivateKey) => Promise<SignAuthorizationReturnType>;
|
|
47
|
+
viem_signMessage: (walletId: string, message: SignableMessage) => Promise<Hex>;
|
|
48
|
+
viem_signTransaction: (walletId: string, transaction: TransactionSerializable) => Promise<Hex>;
|
|
49
|
+
viem_signTypedData: (walletId: string, typedData: TypedData) => Promise<Hex>;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -16,6 +16,7 @@ export * from './SolanaMessages';
|
|
|
16
16
|
export * from './StorageMessages';
|
|
17
17
|
export * from './TurnkeyIframeEventProxyMessages';
|
|
18
18
|
export * from './UserInterfaceModuleMessages';
|
|
19
|
+
export * from './ViemMessages';
|
|
19
20
|
export * from './WalletsModuleMessages';
|
|
20
21
|
export * from './WebViewVisibilityMessages';
|
|
21
22
|
export * from './ZeroDevExtensionMessages';
|
package/src/requestChannel/createRequestChannelMessageSender/createRequestChannelMessageSender.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var applyRecoveryManager = require('../../messageTransport/decorators/applyRecoveryManager/applyRecoveryManager.cjs');
|
|
6
7
|
var utils = require('../utils/utils.cjs');
|
|
7
8
|
|
|
8
9
|
const createRequestChannelMessageSender = ({ requestType, messageSessionId, timeoutMap, onReceiveAck, messageTransport, onTimeout, params, }) => {
|
|
@@ -23,7 +24,18 @@ const createRequestChannelMessageSender = ({ requestType, messageSessionId, time
|
|
|
23
24
|
};
|
|
24
25
|
const sendMessage = () => {
|
|
25
26
|
const startTimer = () => {
|
|
26
|
-
const timeoutTimer = setTimeout(
|
|
27
|
+
const timeoutTimer = setTimeout(() => {
|
|
28
|
+
// Try to recover connection if available
|
|
29
|
+
if (applyRecoveryManager.hasRecoveryManager(messageTransport) &&
|
|
30
|
+
messageTransport.recoveryManager.canRetryMessageSessionId(messageSessionId)) {
|
|
31
|
+
messageTransport.recoveryManager.triggerRecovery(messageSessionId);
|
|
32
|
+
sendMessage();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// If no recovery is available, send an error
|
|
36
|
+
onTimeout();
|
|
37
|
+
}
|
|
38
|
+
}, utils.TIMEOUT_DURATION);
|
|
27
39
|
timeoutMap[messageSessionId] = timeoutTimer;
|
|
28
40
|
};
|
|
29
41
|
// If this message transport is currently blocked, we must only start
|
package/src/requestChannel/createRequestChannelMessageSender/createRequestChannelMessageSender.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { hasRecoveryManager } from '../../messageTransport/decorators/applyRecoveryManager/applyRecoveryManager.js';
|
|
2
3
|
import { getAckMessageType, TIMEOUT_DURATION } from '../utils/utils.js';
|
|
3
4
|
|
|
4
5
|
const createRequestChannelMessageSender = ({ requestType, messageSessionId, timeoutMap, onReceiveAck, messageTransport, onTimeout, params, }) => {
|
|
@@ -19,7 +20,18 @@ const createRequestChannelMessageSender = ({ requestType, messageSessionId, time
|
|
|
19
20
|
};
|
|
20
21
|
const sendMessage = () => {
|
|
21
22
|
const startTimer = () => {
|
|
22
|
-
const timeoutTimer = setTimeout(
|
|
23
|
+
const timeoutTimer = setTimeout(() => {
|
|
24
|
+
// Try to recover connection if available
|
|
25
|
+
if (hasRecoveryManager(messageTransport) &&
|
|
26
|
+
messageTransport.recoveryManager.canRetryMessageSessionId(messageSessionId)) {
|
|
27
|
+
messageTransport.recoveryManager.triggerRecovery(messageSessionId);
|
|
28
|
+
sendMessage();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// If no recovery is available, send an error
|
|
32
|
+
onTimeout();
|
|
33
|
+
}
|
|
34
|
+
}, TIMEOUT_DURATION);
|
|
23
35
|
timeoutMap[messageSessionId] = timeoutTimer;
|
|
24
36
|
};
|
|
25
37
|
// If this message transport is currently blocked, we must only start
|
|
@@ -51,8 +51,8 @@ const createRequestChannel = (messageTransport) => {
|
|
|
51
51
|
resolve();
|
|
52
52
|
},
|
|
53
53
|
onTimeout: () => {
|
|
54
|
-
cleanupMessageHandler();
|
|
55
54
|
reject(utils.createNoHandlerError(requestType));
|
|
55
|
+
cleanupMessageHandler();
|
|
56
56
|
},
|
|
57
57
|
params,
|
|
58
58
|
requestType,
|
|
@@ -109,8 +109,8 @@ const createRequestChannel = (messageTransport) => {
|
|
|
109
109
|
messageSessionId,
|
|
110
110
|
messageTransport,
|
|
111
111
|
onTimeout: () => {
|
|
112
|
-
cleanupMessageHandler();
|
|
113
112
|
reject(utils.createNoHandlerError(requestType));
|
|
113
|
+
cleanupMessageHandler();
|
|
114
114
|
},
|
|
115
115
|
params,
|
|
116
116
|
requestType,
|
|
@@ -47,8 +47,8 @@ const createRequestChannel = (messageTransport) => {
|
|
|
47
47
|
resolve();
|
|
48
48
|
},
|
|
49
49
|
onTimeout: () => {
|
|
50
|
-
cleanupMessageHandler();
|
|
51
50
|
reject(createNoHandlerError(requestType));
|
|
51
|
+
cleanupMessageHandler();
|
|
52
52
|
},
|
|
53
53
|
params,
|
|
54
54
|
requestType,
|
|
@@ -105,8 +105,8 @@ const createRequestChannel = (messageTransport) => {
|
|
|
105
105
|
messageSessionId,
|
|
106
106
|
messageTransport,
|
|
107
107
|
onTimeout: () => {
|
|
108
|
-
cleanupMessageHandler();
|
|
109
108
|
reject(createNoHandlerError(requestType));
|
|
109
|
+
cleanupMessageHandler();
|
|
110
110
|
},
|
|
111
111
|
params,
|
|
112
112
|
requestType,
|
|
@@ -34,7 +34,7 @@ const createNoHandlerError = (type) => {
|
|
|
34
34
|
*
|
|
35
35
|
* This controls how many ms we should wait before we time out.
|
|
36
36
|
*/
|
|
37
|
-
const TIMEOUT_DURATION =
|
|
37
|
+
const TIMEOUT_DURATION = 1000;
|
|
38
38
|
|
|
39
39
|
exports.TIMEOUT_DURATION = TIMEOUT_DURATION;
|
|
40
40
|
exports.createNoHandlerError = createNoHandlerError;
|
|
@@ -30,6 +30,6 @@ const createNoHandlerError = (type) => {
|
|
|
30
30
|
*
|
|
31
31
|
* This controls how many ms we should wait before we time out.
|
|
32
32
|
*/
|
|
33
|
-
const TIMEOUT_DURATION =
|
|
33
|
+
const TIMEOUT_DURATION = 1000;
|
|
34
34
|
|
|
35
35
|
export { TIMEOUT_DURATION, createNoHandlerError, getAckMessageType, getRejectMessageType, getResolveMessageType, isAckMessageType, isRejectMessageType, isRequestMessageType, isResolveMessageType };
|