@docknetwork/wallet-sdk-wasm 1.7.6 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -7
- package/rollup.config.mjs +1 -0
- package/src/globals.d.ts +4 -1
- package/src/services/blockchain/cached-did-resolver.ts +4 -3
- package/src/services/blockchain/normalize-did-document.ts +73 -0
- package/src/services/blockchain/service.ts +0 -2
- package/src/services/credential/bbs-revocation.test.js +147 -0
- package/src/services/credential/bbs-revocation.ts +65 -18
- package/src/services/credential/config.ts +7 -0
- package/src/services/credential/index.test.js +261 -17
- package/src/services/credential/oid4vci.js +44 -0
- package/src/services/credential/oid4vci.test.js +162 -0
- package/src/services/credential/pex-helpers.js +77 -31
- package/src/services/credential/pex-helpers.test.js +4 -4
- package/src/services/credential/sd-jwt.ts +41 -5
- package/src/services/credential/service-rpc.js +6 -0
- package/src/services/credential/service.ts +171 -16
- package/src/services/credential/utils.js +3 -5
- package/src/services/delegation/index.android.js +3 -0
- package/src/services/delegation/index.ios.js +3 -0
- package/src/services/delegation/index.ts +1 -0
- package/src/services/delegation/service-rpc.ts +21 -0
- package/src/services/delegation/service.ts +59 -0
- package/src/services/edv/service-rpc.js +18 -2
- package/src/services/edv/service.test.js +327 -0
- package/src/services/edv/service.ts +103 -13
- package/src/services/index.js +2 -0
- package/src/wallet/rpc-storage-interface.js +9 -4
- package/lib/core/crypto.js +0 -45
- package/lib/core/crypto.mjs +0 -33
- package/lib/core/format-utils.js +0 -51
- package/lib/core/format-utils.mjs +0 -42
- package/lib/core/keychain.js +0 -61
- package/lib/core/keychain.mjs +0 -37
- package/lib/core/logger.js +0 -13
- package/lib/core/logger.mjs +0 -9
- package/lib/core/storage.js +0 -14
- package/lib/core/storage.mjs +0 -9
- package/lib/core/validation.js +0 -29
- package/lib/core/validation.mjs +0 -16
- package/lib/core/webview-logger.js +0 -49
- package/lib/core/webview-logger.mjs +0 -41
- package/lib/errors.js +0 -17
- package/lib/errors.mjs +0 -12
- package/lib/events.js +0 -18
- package/lib/events.mjs +0 -13
- package/lib/index.js +0 -146
- package/lib/index.mjs +0 -144
- package/lib/logger.js +0 -22
- package/lib/logger.mjs +0 -17
- package/lib/modules/event-manager.js +0 -46
- package/lib/modules/event-manager.mjs +0 -37
- package/lib/modules/network-manager.js +0 -80
- package/lib/modules/network-manager.mjs +0 -71
- package/lib/mrklt.js +0 -2
- package/lib/mrklt.mjs +0 -1
- package/lib/rpc-client.js +0 -83
- package/lib/rpc-client.mjs +0 -73
- package/lib/rpc-server.js +0 -97
- package/lib/rpc-server.mjs +0 -95
- package/lib/rpc-util.js +0 -113
- package/lib/rpc-util.mjs +0 -103
- package/lib/sandbox-rpc-server.js +0 -28
- package/lib/sandbox-rpc-server.mjs +0 -26
- package/lib/sandbox.js +0 -102
- package/lib/sandbox.mjs +0 -100
- package/lib/services/blockchain/cached-did-resolver.js +0 -113
- package/lib/services/blockchain/cached-did-resolver.mjs +0 -109
- package/lib/services/blockchain/configs.js +0 -7
- package/lib/services/blockchain/configs.mjs +0 -3
- package/lib/services/blockchain/index.android.js +0 -18
- package/lib/services/blockchain/index.android.mjs +0 -14
- package/lib/services/blockchain/index.ios.js +0 -18
- package/lib/services/blockchain/index.ios.mjs +0 -14
- package/lib/services/blockchain/index.js +0 -36
- package/lib/services/blockchain/index.mjs +0 -28
- package/lib/services/blockchain/service-rpc.js +0 -72
- package/lib/services/blockchain/service-rpc.mjs +0 -68
- package/lib/services/blockchain/service.js +0 -312
- package/lib/services/blockchain/service.mjs +0 -306
- package/lib/services/credential/bbs-revocation.js +0 -92
- package/lib/services/credential/bbs-revocation.mjs +0 -87
- package/lib/services/credential/bound-check.js +0 -77
- package/lib/services/credential/bound-check.mjs +0 -64
- package/lib/services/credential/config.js +0 -56
- package/lib/services/credential/config.mjs +0 -47
- package/lib/services/credential/delegatable-credentials.js +0 -300
- package/lib/services/credential/delegatable-credentials.mjs +0 -263
- package/lib/services/credential/index.android.js +0 -19
- package/lib/services/credential/index.android.mjs +0 -15
- package/lib/services/credential/index.ios.js +0 -19
- package/lib/services/credential/index.ios.mjs +0 -15
- package/lib/services/credential/index.js +0 -106
- package/lib/services/credential/index.mjs +0 -67
- package/lib/services/credential/pex-helpers.js +0 -333
- package/lib/services/credential/pex-helpers.mjs +0 -319
- package/lib/services/credential/range-proofs-example.js +0 -107
- package/lib/services/credential/range-proofs-example.mjs +0 -103
- package/lib/services/credential/sd-jwt.js +0 -214
- package/lib/services/credential/sd-jwt.mjs +0 -200
- package/lib/services/credential/service-rpc.js +0 -61
- package/lib/services/credential/service-rpc.mjs +0 -57
- package/lib/services/credential/service.js +0 -683
- package/lib/services/credential/service.mjs +0 -672
- package/lib/services/credential/utils.js +0 -103
- package/lib/services/credential/utils.mjs +0 -78
- package/lib/services/dids/config.js +0 -40
- package/lib/services/dids/config.mjs +0 -31
- package/lib/services/dids/index.android.js +0 -19
- package/lib/services/dids/index.android.mjs +0 -15
- package/lib/services/dids/index.ios.js +0 -19
- package/lib/services/dids/index.ios.mjs +0 -15
- package/lib/services/dids/index.js +0 -23
- package/lib/services/dids/index.mjs +0 -19
- package/lib/services/dids/keypair-utils.js +0 -142
- package/lib/services/dids/keypair-utils.mjs +0 -113
- package/lib/services/dids/service-rpc.js +0 -37
- package/lib/services/dids/service-rpc.mjs +0 -33
- package/lib/services/dids/service.js +0 -100
- package/lib/services/dids/service.mjs +0 -92
- package/lib/services/edv/configs.js +0 -25
- package/lib/services/edv/configs.mjs +0 -16
- package/lib/services/edv/hmac.js +0 -88
- package/lib/services/edv/hmac.mjs +0 -63
- package/lib/services/edv/index.android.js +0 -19
- package/lib/services/edv/index.android.mjs +0 -15
- package/lib/services/edv/index.ios.js +0 -19
- package/lib/services/edv/index.ios.mjs +0 -15
- package/lib/services/edv/index.js +0 -32
- package/lib/services/edv/index.mjs +0 -24
- package/lib/services/edv/service-rpc.js +0 -78
- package/lib/services/edv/service-rpc.mjs +0 -74
- package/lib/services/edv/service.js +0 -370
- package/lib/services/edv/service.mjs +0 -357
- package/lib/services/index.js +0 -94
- package/lib/services/index.mjs +0 -92
- package/lib/services/pex/config.js +0 -29
- package/lib/services/pex/config.mjs +0 -20
- package/lib/services/pex/index.android.js +0 -19
- package/lib/services/pex/index.android.mjs +0 -15
- package/lib/services/pex/index.ios.js +0 -19
- package/lib/services/pex/index.ios.mjs +0 -15
- package/lib/services/pex/index.js +0 -12
- package/lib/services/pex/index.mjs +0 -4
- package/lib/services/pex/service-rpc.js +0 -39
- package/lib/services/pex/service-rpc.mjs +0 -35
- package/lib/services/pex/service.js +0 -91
- package/lib/services/pex/service.mjs +0 -86
- package/lib/services/pex/tests/jest.config.js +0 -25
- package/lib/services/pex/tests/jest.config.mjs +0 -23
- package/lib/services/relay-service/configs.js +0 -45
- package/lib/services/relay-service/configs.mjs +0 -36
- package/lib/services/relay-service/index.android.js +0 -21
- package/lib/services/relay-service/index.android.mjs +0 -17
- package/lib/services/relay-service/index.ios.js +0 -21
- package/lib/services/relay-service/index.ios.mjs +0 -17
- package/lib/services/relay-service/index.js +0 -14
- package/lib/services/relay-service/index.mjs +0 -6
- package/lib/services/relay-service/service-rpc.js +0 -47
- package/lib/services/relay-service/service-rpc.mjs +0 -43
- package/lib/services/relay-service/service.js +0 -181
- package/lib/services/relay-service/service.mjs +0 -173
- package/lib/services/rpc-service-client.js +0 -36
- package/lib/services/rpc-service-client.mjs +0 -28
- package/lib/services/sandbox.js +0 -10
- package/lib/services/sandbox.mjs +0 -8
- package/lib/services/storage/configs.js +0 -7
- package/lib/services/storage/configs.mjs +0 -3
- package/lib/services/storage/index.android.js +0 -18
- package/lib/services/storage/index.android.mjs +0 -14
- package/lib/services/storage/index.ios.js +0 -18
- package/lib/services/storage/index.ios.mjs +0 -14
- package/lib/services/storage/index.js +0 -26
- package/lib/services/storage/index.mjs +0 -24
- package/lib/services/storage/service-rpc.js +0 -37
- package/lib/services/storage/service-rpc.mjs +0 -33
- package/lib/services/storage/service.js +0 -32
- package/lib/services/storage/service.mjs +0 -27
- package/lib/services/test-utils.js +0 -98
- package/lib/services/test-utils.mjs +0 -84
- package/lib/services/util-crypto/configs.js +0 -23
- package/lib/services/util-crypto/configs.mjs +0 -15
- package/lib/services/util-crypto/index.android.js +0 -19
- package/lib/services/util-crypto/index.android.mjs +0 -15
- package/lib/services/util-crypto/index.ios.js +0 -19
- package/lib/services/util-crypto/index.ios.mjs +0 -15
- package/lib/services/util-crypto/index.js +0 -14
- package/lib/services/util-crypto/index.mjs +0 -6
- package/lib/services/util-crypto/service-rpc.js +0 -42
- package/lib/services/util-crypto/service-rpc.mjs +0 -38
- package/lib/services/util-crypto/service.js +0 -108
- package/lib/services/util-crypto/service.mjs +0 -83
- package/lib/services/wallet/configs.js +0 -32
- package/lib/services/wallet/configs.mjs +0 -23
- package/lib/services/wallet/index.android.js +0 -21
- package/lib/services/wallet/index.android.mjs +0 -17
- package/lib/services/wallet/index.ios.js +0 -21
- package/lib/services/wallet/index.ios.mjs +0 -17
- package/lib/services/wallet/index.js +0 -17
- package/lib/services/wallet/index.mjs +0 -9
- package/lib/services/wallet/service-rpc.js +0 -33
- package/lib/services/wallet/service-rpc.mjs +0 -29
- package/lib/services/wallet/service.js +0 -62
- package/lib/services/wallet/service.mjs +0 -57
- package/lib/setup-nodejs.js +0 -93
- package/lib/setup-nodejs.mjs +0 -91
- package/lib/setup-tests.js +0 -92
- package/lib/setup-tests.mjs +0 -90
- package/lib/src/core/crypto.d.ts +0 -8
- package/lib/src/core/crypto.d.ts.map +0 -1
- package/lib/src/core/format-utils.d.ts +0 -26
- package/lib/src/core/format-utils.d.ts.map +0 -1
- package/lib/src/core/logger.d.ts +0 -3
- package/lib/src/core/logger.d.ts.map +0 -1
- package/lib/src/core/storage.d.ts +0 -8
- package/lib/src/core/storage.d.ts.map +0 -1
- package/lib/src/core/validation.d.ts +0 -6
- package/lib/src/core/validation.d.ts.map +0 -1
- package/lib/src/errors.d.ts +0 -7
- package/lib/src/errors.d.ts.map +0 -1
- package/lib/src/logger.d.ts +0 -5
- package/lib/src/logger.d.ts.map +0 -1
- package/lib/src/modules/event-manager.d.ts +0 -12
- package/lib/src/modules/event-manager.d.ts.map +0 -1
- package/lib/src/modules/network-manager.d.ts +0 -32
- package/lib/src/modules/network-manager.d.ts.map +0 -1
- package/lib/src/rpc-client.d.ts +0 -4
- package/lib/src/rpc-client.d.ts.map +0 -1
- package/lib/src/rpc-util.d.ts +0 -11
- package/lib/src/rpc-util.d.ts.map +0 -1
- package/lib/src/services/blockchain/cached-did-resolver.d.ts +0 -28
- package/lib/src/services/blockchain/cached-did-resolver.d.ts.map +0 -1
- package/lib/src/services/blockchain/cached-did-resolver.test.d.ts +0 -2
- package/lib/src/services/blockchain/cached-did-resolver.test.d.ts.map +0 -1
- package/lib/src/services/blockchain/configs.d.ts +0 -7
- package/lib/src/services/blockchain/configs.d.ts.map +0 -1
- package/lib/src/services/blockchain/service.d.ts +0 -155
- package/lib/src/services/blockchain/service.d.ts.map +0 -1
- package/lib/src/services/credential/bbs-revocation.d.ts +0 -10
- package/lib/src/services/credential/bbs-revocation.d.ts.map +0 -1
- package/lib/src/services/credential/bound-check.d.ts +0 -61
- package/lib/src/services/credential/bound-check.d.ts.map +0 -1
- package/lib/src/services/credential/bound-check.test.d.ts +0 -2
- package/lib/src/services/credential/bound-check.test.d.ts.map +0 -1
- package/lib/src/services/credential/config.d.ts +0 -10
- package/lib/src/services/credential/config.d.ts.map +0 -1
- package/lib/src/services/credential/delegatable-credentials.d.ts +0 -272
- package/lib/src/services/credential/delegatable-credentials.d.ts.map +0 -1
- package/lib/src/services/credential/index.d.ts +0 -35
- package/lib/src/services/credential/index.d.ts.map +0 -1
- package/lib/src/services/credential/pex-helpers.d.ts +0 -23
- package/lib/src/services/credential/pex-helpers.d.ts.map +0 -1
- package/lib/src/services/credential/range-proofs-example.d.ts +0 -2
- package/lib/src/services/credential/range-proofs-example.d.ts.map +0 -1
- package/lib/src/services/credential/sd-jwt.test.d.ts +0 -2
- package/lib/src/services/credential/sd-jwt.test.d.ts.map +0 -1
- package/lib/src/services/credential/service.d.ts +0 -313
- package/lib/src/services/credential/service.d.ts.map +0 -1
- package/lib/src/services/credential/utils.d.ts +0 -3
- package/lib/src/services/credential/utils.d.ts.map +0 -1
- package/lib/src/services/dids/config.d.ts +0 -24
- package/lib/src/services/dids/config.d.ts.map +0 -1
- package/lib/src/services/dids/keypair-utils.d.ts +0 -15
- package/lib/src/services/dids/keypair-utils.d.ts.map +0 -1
- package/lib/src/services/dids/service-rpc.d.ts +0 -11
- package/lib/src/services/dids/service-rpc.d.ts.map +0 -1
- package/lib/src/services/dids/service.d.ts +0 -70
- package/lib/src/services/dids/service.d.ts.map +0 -1
- package/lib/src/services/edv/configs.d.ts +0 -12
- package/lib/src/services/edv/configs.d.ts.map +0 -1
- package/lib/src/services/edv/hmac.d.ts +0 -29
- package/lib/src/services/edv/hmac.d.ts.map +0 -1
- package/lib/src/services/edv/service.d.ts +0 -229
- package/lib/src/services/edv/service.d.ts.map +0 -1
- package/lib/src/services/pex/config.d.ts +0 -21
- package/lib/src/services/pex/config.d.ts.map +0 -1
- package/lib/src/services/pex/service.d.ts +0 -21
- package/lib/src/services/pex/service.d.ts.map +0 -1
- package/lib/src/services/relay-service/configs.d.ts +0 -35
- package/lib/src/services/relay-service/configs.d.ts.map +0 -1
- package/lib/src/services/relay-service/service-rpc.d.ts +0 -12
- package/lib/src/services/relay-service/service-rpc.d.ts.map +0 -1
- package/lib/src/services/relay-service/service.d.ts +0 -159
- package/lib/src/services/relay-service/service.d.ts.map +0 -1
- package/lib/src/services/rpc-service-client.d.ts +0 -7
- package/lib/src/services/rpc-service-client.d.ts.map +0 -1
- package/lib/src/services/storage/configs.d.ts +0 -2
- package/lib/src/services/storage/configs.d.ts.map +0 -1
- package/lib/src/services/storage/index.d.ts +0 -2
- package/lib/src/services/storage/index.d.ts.map +0 -1
- package/lib/src/services/storage/service-rpc.d.ts +0 -9
- package/lib/src/services/storage/service-rpc.d.ts.map +0 -1
- package/lib/src/services/storage/service.d.ts +0 -10
- package/lib/src/services/storage/service.d.ts.map +0 -1
- package/lib/src/services/util-crypto/configs.d.ts +0 -5
- package/lib/src/services/util-crypto/configs.d.ts.map +0 -1
- package/lib/src/services/util-crypto/index.d.ts +0 -2
- package/lib/src/services/util-crypto/index.d.ts.map +0 -1
- package/lib/src/services/util-crypto/service.d.ts +0 -10
- package/lib/src/services/util-crypto/service.d.ts.map +0 -1
- package/lib/src/services/wallet/configs.d.ts +0 -13
- package/lib/src/services/wallet/configs.d.ts.map +0 -1
- package/lib/src/services/wallet/service.d.ts +0 -13
- package/lib/src/services/wallet/service.d.ts.map +0 -1
- package/lib/src/types.d.ts +0 -12
- package/lib/src/types.d.ts.map +0 -1
- package/lib/src/wallet/memory-storage-interface.d.ts +0 -31
- package/lib/src/wallet/memory-storage-interface.d.ts.map +0 -1
- package/lib/src/wallet/memory-storage-wallet.d.ts +0 -6
- package/lib/src/wallet/memory-storage-wallet.d.ts.map +0 -1
- package/lib/src/wallet/rpc-storage-interface.d.ts +0 -32
- package/lib/src/wallet/rpc-storage-interface.d.ts.map +0 -1
- package/lib/src/wallet/rpc-storage-wallet.d.ts +0 -6
- package/lib/src/wallet/rpc-storage-wallet.d.ts.map +0 -1
- package/lib/test-utils.js +0 -46
- package/lib/test-utils.mjs +0 -38
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types.js +0 -7
- package/lib/types.mjs +0 -3
- package/lib/wallet/memory-storage-interface.js +0 -101
- package/lib/wallet/memory-storage-interface.mjs +0 -95
- package/lib/wallet/memory-storage-wallet.js +0 -30
- package/lib/wallet/memory-storage-wallet.mjs +0 -24
- package/lib/wallet/rpc-storage-interface.js +0 -134
- package/lib/wallet/rpc-storage-interface.mjs +0 -128
- package/lib/wallet/rpc-storage-wallet.js +0 -46
- package/lib/wallet/rpc-storage-wallet.mjs +0 -40
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module relay-service
|
|
3
|
-
* @description DIDComm message relay service for the Wallet SDK.
|
|
4
|
-
* This module provides functionality for sending, receiving, and managing DIDComm messages
|
|
5
|
-
* through a relay service, including push notification support.
|
|
6
|
-
*/
|
|
7
|
-
import { SendMessageParams, GetMessagesParams, ResolveDidcommMessageParams, RegisterDIDPushNotificationParams, AckMessagesParams } from './configs';
|
|
8
|
-
import { RelayService as relayServiceClient } from '@docknetwork/wallet-sdk-relay-service/lib';
|
|
9
|
-
/**
|
|
10
|
-
* Service class for managing DIDComm message relay operations
|
|
11
|
-
* @class
|
|
12
|
-
* @description Provides methods for sending, receiving, and acknowledging DIDComm messages
|
|
13
|
-
* through a relay service infrastructure
|
|
14
|
-
*/
|
|
15
|
-
export declare class RelayService {
|
|
16
|
-
name: string;
|
|
17
|
-
rpcMethods: (((params: AckMessagesParams) => Promise<import("axios").AxiosResponse<any, any>>) | ((params: GetMessagesParams) => Promise<any>) | ((params: RegisterDIDPushNotificationParams) => Promise<any>) | ((params: ResolveDidcommMessageParams) => Promise<any>) | ((params: SendMessageParams) => Promise<{
|
|
18
|
-
success: boolean;
|
|
19
|
-
endpoint: any;
|
|
20
|
-
} | {
|
|
21
|
-
success: any;
|
|
22
|
-
endpoint?: undefined;
|
|
23
|
-
}>))[];
|
|
24
|
-
/**
|
|
25
|
-
* Creates a new RelayService instance
|
|
26
|
-
* @constructor
|
|
27
|
-
*/
|
|
28
|
-
constructor();
|
|
29
|
-
/**
|
|
30
|
-
* Sends a DIDComm message through the relay service
|
|
31
|
-
* @param {SendMessageParams} params - Message parameters
|
|
32
|
-
* @param {Object} params.keyPairDoc - Key pair document for message encryption
|
|
33
|
-
* @param {Object} params.message - The message payload to send
|
|
34
|
-
* @param {string} params.recipientDid - DID of the message recipient
|
|
35
|
-
* @param {string} [params.type] - Message type identifier
|
|
36
|
-
* @returns {Promise<Object>} Result of the send operation
|
|
37
|
-
* @throws {Error} If validation fails or sending fails
|
|
38
|
-
* @example
|
|
39
|
-
* const result = await relayService.sendMessage({
|
|
40
|
-
* keyPairDoc: senderKeyPair,
|
|
41
|
-
* message: { content: 'Hello' },
|
|
42
|
-
* recipientDid: 'did:key:recipient123',
|
|
43
|
-
* type: 'basic-message'
|
|
44
|
-
* });
|
|
45
|
-
*/
|
|
46
|
-
sendMessage(params: SendMessageParams): Promise<{
|
|
47
|
-
success: boolean;
|
|
48
|
-
endpoint: any;
|
|
49
|
-
} | {
|
|
50
|
-
success: any;
|
|
51
|
-
endpoint?: undefined;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* Acknowledges receipt of messages from the relay service
|
|
55
|
-
* @param {AckMessagesParams} params - Acknowledgment parameters
|
|
56
|
-
* @param {string} params.did - DID acknowledging the messages
|
|
57
|
-
* @param {Array<string>} params.messageIds - Array of message IDs to acknowledge
|
|
58
|
-
* @returns {Promise<Object>} Result of the acknowledgment operation
|
|
59
|
-
* @example
|
|
60
|
-
* await relayService.ackMessages({
|
|
61
|
-
* did: 'did:key:holder123',
|
|
62
|
-
* messageIds: ['msg-1', 'msg-2']
|
|
63
|
-
* });
|
|
64
|
-
*/
|
|
65
|
-
ackMessages(params: AckMessagesParams): Promise<import("axios").AxiosResponse<any, any>>;
|
|
66
|
-
/**
|
|
67
|
-
* Resolves and decrypts a DIDComm message
|
|
68
|
-
* @param {ResolveDidcommMessageParams} params - Resolution parameters
|
|
69
|
-
* @param {Object} params.encryptedMessage - The encrypted message to resolve
|
|
70
|
-
* @param {Object} params.keyPairDoc - Key pair document for decryption
|
|
71
|
-
* @returns {Promise<Object>} The decrypted and resolved message
|
|
72
|
-
* @throws {Error} If validation fails or resolution fails
|
|
73
|
-
* @example
|
|
74
|
-
* const decrypted = await relayService.resolveDidcommMessage({
|
|
75
|
-
* encryptedMessage: encryptedData,
|
|
76
|
-
* keyPairDoc: recipientKeyPair
|
|
77
|
-
* });
|
|
78
|
-
*/
|
|
79
|
-
resolveDidcommMessage(params: ResolveDidcommMessageParams): Promise<any>;
|
|
80
|
-
/**
|
|
81
|
-
* Signs a JWT using the provided key pair
|
|
82
|
-
* @param {ResolveDidcommMessageParams} params - Signing parameters
|
|
83
|
-
* @param {Object} params.payload - JWT payload to sign
|
|
84
|
-
* @param {Object} params.keyPairDoc - Key pair document for signing
|
|
85
|
-
* @returns {Promise<string>} The signed JWT token
|
|
86
|
-
* @throws {Error} If validation fails or signing fails
|
|
87
|
-
* @example
|
|
88
|
-
* const jwt = await relayService.signJwt({
|
|
89
|
-
* payload: { sub: 'did:key:123', iat: Date.now() },
|
|
90
|
-
* keyPairDoc: signerKeyPair
|
|
91
|
-
* });
|
|
92
|
-
*/
|
|
93
|
-
signJwt(params: ResolveDidcommMessageParams): Promise<string>;
|
|
94
|
-
/**
|
|
95
|
-
* Retrieves messages from the relay service
|
|
96
|
-
* @param {GetMessagesParams} params - Retrieval parameters
|
|
97
|
-
* @param {Object} params.keyPairDocs - Key pair documents for decryption
|
|
98
|
-
* @param {number} [params.limit] - Maximum number of messages to retrieve
|
|
99
|
-
* @param {boolean} [params.skipMessageResolution] - Whether to skip message resolution
|
|
100
|
-
* @returns {Promise<Array>} Array of retrieved messages
|
|
101
|
-
* @throws {Error} If validation fails or retrieval fails
|
|
102
|
-
* @example
|
|
103
|
-
* const messages = await relayService.getMessages({
|
|
104
|
-
* keyPairDocs: [keyPairDoc1, keyPairDoc2],
|
|
105
|
-
* limit: 50,
|
|
106
|
-
* skipMessageResolution: false
|
|
107
|
-
* });
|
|
108
|
-
*/
|
|
109
|
-
getMessages(params: GetMessagesParams): Promise<any>;
|
|
110
|
-
/**
|
|
111
|
-
* Registers a DID for push notifications
|
|
112
|
-
* @param {RegisterDIDPushNotificationParams} params - Registration parameters
|
|
113
|
-
* @param {string} params.did - The DID to register for notifications
|
|
114
|
-
* @param {string} params.deviceToken - Device token for push notifications
|
|
115
|
-
* @param {string} [params.platform] - Platform identifier (ios, android, etc.)
|
|
116
|
-
* @returns {Promise<Object>} Result of the registration
|
|
117
|
-
* @throws {Error} If validation fails or registration fails
|
|
118
|
-
* @example
|
|
119
|
-
* await relayService.registerDIDPushNotification({
|
|
120
|
-
* did: 'did:key:holder123',
|
|
121
|
-
* deviceToken: 'fcm-token-123',
|
|
122
|
-
* platform: 'android'
|
|
123
|
-
* });
|
|
124
|
-
*/
|
|
125
|
-
registerDIDPushNotification(params: RegisterDIDPushNotificationParams): Promise<any>;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Low-level relay service client for direct API access
|
|
129
|
-
* @type {Object}
|
|
130
|
-
* @see {@link RelayService} - Higher-level service wrapper
|
|
131
|
-
*/
|
|
132
|
-
export { relayServiceClient };
|
|
133
|
-
/**
|
|
134
|
-
* Singleton instance of the relay service
|
|
135
|
-
* @type {RelayService}
|
|
136
|
-
* @example
|
|
137
|
-
* import { relayService } from '@docknetwork/wallet-sdk-wasm/services/relay-service';
|
|
138
|
-
*
|
|
139
|
-
* // Send a DIDComm message
|
|
140
|
-
* await relayService.sendMessage({
|
|
141
|
-
* keyPairDoc: senderKeyPair,
|
|
142
|
-
* message: { type: 'greeting', content: 'Hello!' },
|
|
143
|
-
* recipientDid: 'did:key:recipient123'
|
|
144
|
-
* });
|
|
145
|
-
*
|
|
146
|
-
* // Retrieve messages
|
|
147
|
-
* const messages = await relayService.getMessages({
|
|
148
|
-
* keyPairDocs: [recipientKeyPair],
|
|
149
|
-
* limit: 10
|
|
150
|
-
* });
|
|
151
|
-
*
|
|
152
|
-
* // Acknowledge messages
|
|
153
|
-
* await relayService.ackMessages({
|
|
154
|
-
* did: 'did:key:recipient123',
|
|
155
|
-
* messageIds: messages.map(m => m.id)
|
|
156
|
-
* });
|
|
157
|
-
*/
|
|
158
|
-
export declare const relayService: RelayService;
|
|
159
|
-
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/services/relay-service/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,2BAA2B,EAC3B,iCAAiC,EAGjC,iBAAiB,EAClB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAC,YAAY,IAAI,kBAAkB,EAAC,MAAM,2CAA2C,CAAC;AAE7F;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,IAAI,EAAE,MAAM,CAAC;IAEb,UAAU,aAmDU,iBAAiB,mEAuDjB,iBAAiB,+BAoBD,iCAAiC,+BA1DvC,2BAA2B,+BAlCrC,iBAAiB;;;;;;WA3BnC;IAEF;;;OAGG;;IAKH;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,CAAC,MAAM,EAAE,iBAAiB;;;;;;;IAKrC;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,MAAM,EAAE,iBAAiB;IAIrC;;;;;;;;;;;;OAYG;IACH,qBAAqB,CAAC,MAAM,EAAE,2BAA2B;IAKzD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,MAAM,EAAE,2BAA2B;IAK3C;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,MAAM,EAAE,iBAAiB;IAKrC;;;;;;;;;;;;;;OAcG;IACH,2BAA2B,CAAC,MAAM,EAAE,iCAAiC;CAItE;AAED;;;;GAIG;AACH,OAAO,EAAC,kBAAkB,EAAC,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,YAAY,EAAE,YAAiC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-service-client.d.ts","sourceRoot":"","sources":["../../../src/services/rpc-service-client.js"],"names":[],"mappings":"AAGA;IACE,8BAKC;IAFC,iBAA8B;IAC9B,iBAAoB;IAGtB,kDAOC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/services/storage/configs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,IAAK,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/storage/index.js"],"names":[],"mappings":"AAGA,+BAAmB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export class StorageServiceRpc extends RpcService {
|
|
2
|
-
constructor();
|
|
3
|
-
setItem(...args: any[]): Promise<any>;
|
|
4
|
-
removeItem(...args: any[]): Promise<any>;
|
|
5
|
-
getItem(...args: any[]): Promise<any>;
|
|
6
|
-
getAllKeys(): Promise<any>;
|
|
7
|
-
}
|
|
8
|
-
import { RpcService } from '../rpc-service-client';
|
|
9
|
-
//# sourceMappingURL=service-rpc.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-rpc.d.ts","sourceRoot":"","sources":["../../../../src/services/storage/service-rpc.js"],"names":[],"mappings":"AAEA;IACE,cAEC;IAED,sCAEC;IAED,yCAEC;IAED,sCAEC;IAED,2BAEC;CACF;2BAtBwB,uBAAuB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class StorageService {
|
|
2
|
-
rpcMethods: ((...args: any[]) => Promise<any>)[];
|
|
3
|
-
constructor();
|
|
4
|
-
setItem(...args: any[]): Promise<any>;
|
|
5
|
-
removeItem(...args: any[]): Promise<any>;
|
|
6
|
-
getItem(...args: any[]): Promise<any>;
|
|
7
|
-
getAllKeys(): Promise<string[]>;
|
|
8
|
-
}
|
|
9
|
-
export declare const storageService: StorageService;
|
|
10
|
-
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/services/storage/service.ts"],"names":[],"mappings":"AACA,qBAAa,cAAc;IACzB,UAAU,uBAWQ,OAAO,CAAC,GAAG,CAAC,IAN5B;;IAMF,OAAO,CAAC,GAAG,IAAI,OAAA,GAAG,OAAO,CAAC,GAAG,CAAC;IAI9B,UAAU,CAAC,GAAG,IAAI,OAAA,GAAG,OAAO,CAAC,GAAG,CAAC;IAIjC,OAAO,CAAC,GAAG,IAAI,OAAA,GAAG,OAAO,CAAC,GAAG,CAAC;IAI9B,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAGhC;AAED,eAAO,MAAM,cAAc,EAAE,cAAqC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/services/util-crypto/configs.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU;+BACM,MAAM;iCAMJ,MAAM;CAGpC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/util-crypto/index.js"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class UtilCryptoService {
|
|
2
|
-
rpcMethods: (((value: any) => boolean) | ((numWords?: number) => string) | ((phrase: any) => Uint8Array<ArrayBuffer>) | ((hex: string) => string))[];
|
|
3
|
-
constructor();
|
|
4
|
-
mnemonicGenerate(numWords?: number): string;
|
|
5
|
-
mnemonicToMiniSecret(phrase: any): Uint8Array<ArrayBuffer>;
|
|
6
|
-
isBase64(value: any): boolean;
|
|
7
|
-
hexToString(hex: string): string;
|
|
8
|
-
}
|
|
9
|
-
export declare const utilCryptoService: UtilCryptoService;
|
|
10
|
-
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/services/util-crypto/service.ts"],"names":[],"mappings":"AAeA,qBAAa,iBAAiB;IAC5B,UAAU,qHA4EO,MAAM,KAAG,MAAM,KAvE9B;;IAMF,gBAAgB,CAAC,QAAQ,SAAK;IAqB9B,oBAAoB,CAAC,MAAM,KAAA;IAiB3B,QAAQ,CAAC,KAAK,KAAA;IA2Bd,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAUjC;AAED,eAAO,MAAM,iBAAiB,EAAE,iBAA2C,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const validation: {
|
|
2
|
-
getDocumentsFromEncryptedWallet({ encryptedJSONWallet, password, }: GetDocumentsFromEncryptedWallet): void;
|
|
3
|
-
exportDocuments({ documents, password }: ExportDocuments): void;
|
|
4
|
-
};
|
|
5
|
-
export declare const serviceName = "wallet";
|
|
6
|
-
export type GetDocumentsFromEncryptedWallet = {
|
|
7
|
-
encryptedJSONWallet: any;
|
|
8
|
-
password: string;
|
|
9
|
-
};
|
|
10
|
-
export type ExportDocuments = {
|
|
11
|
-
documents: Array<any>;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=configs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/services/wallet/configs.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU;wEAIlB,+BAA+B;6CAOK,eAAe;CAavD,CAAC;AAEF,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,MAAM,MAAM,+BAA+B,GAAG;IAC5C,mBAAmB,EAAE,GAAG,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;CACvB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import StorageWallet from '@docknetwork/universal-wallet/storage-wallet';
|
|
2
|
-
/**
|
|
3
|
-
* WalletService
|
|
4
|
-
*/
|
|
5
|
-
export declare class WalletService {
|
|
6
|
-
wallet: StorageWallet;
|
|
7
|
-
rpcMethods: ((params: any) => Promise<any>)[];
|
|
8
|
-
constructor();
|
|
9
|
-
getDocumentsFromEncryptedWallet(params: any): Promise<any>;
|
|
10
|
-
exportDocuments(params: any): Promise<any>;
|
|
11
|
-
}
|
|
12
|
-
export declare const walletService: WalletService;
|
|
13
|
-
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/services/wallet/service.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,8CAA8C,CAAC;AAgBzE;;GAEG;AACH,qBAAa,aAAa;IACxB,MAAM,EAAE,aAAa,CAAC;IAEtB,UAAU,oCAGR;;IAMI,+BAA+B,CAAC,MAAM,KAAA;IAoBtC,eAAe,CAAC,MAAM,KAAA;CAgB7B;AAED,eAAO,MAAM,aAAa,EAAE,aAAmC,CAAC"}
|
package/lib/src/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type KeypairType = 'sr25519' | 'ed25519' | 'ecdsa';
|
|
2
|
-
export declare const KeypairTypes: string[];
|
|
3
|
-
export type DocumentType = 'Mnemonic' | 'KeyringPair' | 'Address' | 'Currency' | 'Metadata' | 'VerifiableCredential' | 'Key' | 'DID' | 'generic';
|
|
4
|
-
export type WalletDocument = {
|
|
5
|
-
context?: string[];
|
|
6
|
-
id?: any;
|
|
7
|
-
name: any;
|
|
8
|
-
type: DocumentType;
|
|
9
|
-
value: any;
|
|
10
|
-
correlation?: any[];
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=types.d.ts.map
|
package/lib/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE1D,eAAO,MAAM,YAAY,UAAkC,CAAC;AAE5D,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,aAAa,GACb,SAAS,GACT,UAAU,GACV,UAAU,GACV,sBAAsB,GACtB,KAAK,GACL,KAAK,GACL,SAAS,CAAC;AAEd,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,GAAG,CAAC;IACX,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC;CACrB,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export default MemoryStorageInterface;
|
|
2
|
-
declare class MemoryStorageInterface {
|
|
3
|
-
constructor(directory: any);
|
|
4
|
-
directory: any;
|
|
5
|
-
documents: any;
|
|
6
|
-
updateLocalStorage(): void;
|
|
7
|
-
get({ id }: {
|
|
8
|
-
id: any;
|
|
9
|
-
}): Promise<{
|
|
10
|
-
id: any;
|
|
11
|
-
content: any;
|
|
12
|
-
}>;
|
|
13
|
-
update(options: any): Promise<any>;
|
|
14
|
-
delete({ document }: {
|
|
15
|
-
document: any;
|
|
16
|
-
}): Promise<void>;
|
|
17
|
-
insert({ document }: {
|
|
18
|
-
document: any;
|
|
19
|
-
}): Promise<any>;
|
|
20
|
-
count(query: any): Promise<any>;
|
|
21
|
-
find({ has, equals }?: {
|
|
22
|
-
has?: any;
|
|
23
|
-
equals?: any;
|
|
24
|
-
}): Promise<{
|
|
25
|
-
documents: {
|
|
26
|
-
id: string;
|
|
27
|
-
content: any;
|
|
28
|
-
}[];
|
|
29
|
-
}>;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=memory-storage-interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory-storage-interface.d.ts","sourceRoot":"","sources":["../../../src/wallet/memory-storage-interface.js"],"names":[],"mappings":";AAOA;IACE,4BAeC;IAZC,eAA0B;IAGxB,eAAmE;IAWvE,2BAEC;IAED;;;;;OAMC;IAED,mCAEC;IAED;;sBAGC;IAED;;qBAWC;IAED,gCAGC;IAED;;;;;;;;OA2BC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory-storage-wallet.d.ts","sourceRoot":"","sources":["../../../src/wallet/memory-storage-wallet.js"],"names":[],"mappings":";AAGA;IACE,0CAKC;IAED,+CAQC;CACF"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export default RpcStorageInterface;
|
|
2
|
-
declare class RpcStorageInterface {
|
|
3
|
-
constructor(directory: any);
|
|
4
|
-
directory: any;
|
|
5
|
-
loadStorage(directory: any): Promise<void>;
|
|
6
|
-
documents: any;
|
|
7
|
-
updateLocalStorage(): void;
|
|
8
|
-
get({ id }: {
|
|
9
|
-
id: any;
|
|
10
|
-
}): Promise<{
|
|
11
|
-
id: any;
|
|
12
|
-
content: any;
|
|
13
|
-
}>;
|
|
14
|
-
update(options: any): Promise<any>;
|
|
15
|
-
delete({ document }: {
|
|
16
|
-
document: any;
|
|
17
|
-
}): Promise<void>;
|
|
18
|
-
insert({ document }: {
|
|
19
|
-
document: any;
|
|
20
|
-
}): Promise<any>;
|
|
21
|
-
count(query: any): Promise<any>;
|
|
22
|
-
find({ has, equals }?: {
|
|
23
|
-
has?: any;
|
|
24
|
-
equals?: any;
|
|
25
|
-
}): Promise<{
|
|
26
|
-
documents: {
|
|
27
|
-
id: string;
|
|
28
|
-
content: any;
|
|
29
|
-
}[];
|
|
30
|
-
}>;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=rpc-storage-interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-storage-interface.d.ts","sourceRoot":"","sources":["../../../src/wallet/rpc-storage-interface.js"],"names":[],"mappings":";AAUA;IACE,4BAIC;IAFC,eAA0B;IAI5B,2CAuBC;IAjBG,eAAmE;IAmBvE,2BAEC;IAED;;;;;OAMC;IAED,mCAEC;IAED;;sBAGC;IAED;;qBAWC;IAED,gCAGC;IAED;;;;;;;;OAiCC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-storage-wallet.d.ts","sourceRoot":"","sources":["../../../src/wallet/rpc-storage-wallet.js"],"names":[],"mappings":";AAGA;IACE,0CAKC;IAED,+CAWC;CACF"}
|
package/lib/test-utils.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var rpcClient = require('./rpc-client.js');
|
|
6
|
-
require('assert');
|
|
7
|
-
require('json-rpc-2.0');
|
|
8
|
-
require('./core/crypto.js');
|
|
9
|
-
require('crypto');
|
|
10
|
-
require('./core/logger.js');
|
|
11
|
-
require('./logger.js');
|
|
12
|
-
require('./rpc-util.js');
|
|
13
|
-
|
|
14
|
-
let request;
|
|
15
|
-
|
|
16
|
-
function mockRpcClient() {
|
|
17
|
-
request = rpcClient.getRpcClient().request;
|
|
18
|
-
rpcClient.getRpcClient().request = jest.fn(() => Promise.resolve({}));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function restoreRpcClient() {
|
|
22
|
-
rpcClient.getRpcClient().request = request;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function resolveServiceEndpoint(service, method) {
|
|
26
|
-
return `${service.name}.${method.name}`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function testRpcEndpoint(service, rpcMethod, ...params) {
|
|
30
|
-
rpcMethod(...params);
|
|
31
|
-
const endpoint = resolveServiceEndpoint(
|
|
32
|
-
service,
|
|
33
|
-
service.routes[rpcMethod.name],
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
expect(rpcClient.getRpcClient().request).toBeCalled();
|
|
37
|
-
expect(rpcClient.getRpcClient().request.mock.calls[0][0]).toBe(endpoint);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const waitFor = timeout => new Promise(res => setTimeout(res, timeout));
|
|
41
|
-
|
|
42
|
-
exports.mockRpcClient = mockRpcClient;
|
|
43
|
-
exports.resolveServiceEndpoint = resolveServiceEndpoint;
|
|
44
|
-
exports.restoreRpcClient = restoreRpcClient;
|
|
45
|
-
exports.testRpcEndpoint = testRpcEndpoint;
|
|
46
|
-
exports.waitFor = waitFor;
|
package/lib/test-utils.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { getRpcClient } from './rpc-client.mjs';
|
|
2
|
-
import 'assert';
|
|
3
|
-
import 'json-rpc-2.0';
|
|
4
|
-
import './core/crypto.mjs';
|
|
5
|
-
import 'crypto';
|
|
6
|
-
import './core/logger.mjs';
|
|
7
|
-
import './logger.mjs';
|
|
8
|
-
import './rpc-util.mjs';
|
|
9
|
-
|
|
10
|
-
let request;
|
|
11
|
-
|
|
12
|
-
function mockRpcClient() {
|
|
13
|
-
request = getRpcClient().request;
|
|
14
|
-
getRpcClient().request = jest.fn(() => Promise.resolve({}));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function restoreRpcClient() {
|
|
18
|
-
getRpcClient().request = request;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function resolveServiceEndpoint(service, method) {
|
|
22
|
-
return `${service.name}.${method.name}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function testRpcEndpoint(service, rpcMethod, ...params) {
|
|
26
|
-
rpcMethod(...params);
|
|
27
|
-
const endpoint = resolveServiceEndpoint(
|
|
28
|
-
service,
|
|
29
|
-
service.routes[rpcMethod.name],
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
expect(getRpcClient().request).toBeCalled();
|
|
33
|
-
expect(getRpcClient().request.mock.calls[0][0]).toBe(endpoint);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const waitFor = timeout => new Promise(res => setTimeout(res, timeout));
|
|
37
|
-
|
|
38
|
-
export { mockRpcClient, resolveServiceEndpoint, restoreRpcClient, testRpcEndpoint, waitFor };
|