@dynamic-labs-wallet/node 0.0.354 → 0.1.0-request-signing
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/index.cjs +2887 -825
- package/index.esm.js +2831 -798
- package/internal/core/ed_bls12_377.cjs +1 -1
- package/internal/core/ed_bls12_377.d.ts +1 -0
- package/internal/core/ed_bls12_377.js +1 -1
- package/internal/core/native.d.ts +1 -0
- package/internal/node/native/libmpc_executor_linux_arm64_nodejs.node +0 -0
- package/internal/node/native/libmpc_executor_linux_x86_64_nodejs.node +0 -0
- package/internal/node/native/libmpc_executor_macos_arm64_nodejs.node +0 -0
- package/internal/node/native/libmpc_executor_macos_x86_64_nodejs.node +0 -0
- package/package.json +8 -7
- package/src/api.d.ts +18 -0
- package/src/api.d.ts.map +1 -0
- package/src/authClient.d.ts +73 -0
- package/src/authClient.d.ts.map +1 -0
- package/src/businessAccounts/canonicalizeJson.d.ts +3 -0
- package/src/businessAccounts/canonicalizeJson.d.ts.map +1 -0
- package/src/businessAccounts/client.d.ts +25 -0
- package/src/businessAccounts/client.d.ts.map +1 -0
- package/src/businessAccounts/consentSigning.d.ts +14 -0
- package/src/businessAccounts/consentSigning.d.ts.map +1 -0
- package/src/client.d.ts +296 -112
- package/src/client.d.ts.map +1 -1
- package/src/clientValidationError.d.ts +4 -0
- package/src/clientValidationError.d.ts.map +1 -0
- package/src/constants.d.ts +1 -0
- package/src/constants.d.ts.map +1 -1
- package/src/core/createCore.d.ts +11 -2
- package/src/core/createCore.d.ts.map +1 -1
- package/src/delegatedClient/createDelegatedClient.d.ts +3 -3
- package/src/delegatedClient/createDelegatedClient.d.ts.map +1 -1
- package/src/delegatedClient/index.d.ts +2 -1
- package/src/delegatedClient/index.d.ts.map +1 -1
- package/src/delegatedClient/modules/decryptWebhookData.d.ts +17 -8
- package/src/delegatedClient/modules/decryptWebhookData.d.ts.map +1 -1
- package/src/delegatedClient/modules/revokeDelegation.d.ts +3 -1
- package/src/delegatedClient/modules/revokeDelegation.d.ts.map +1 -1
- package/src/delegatedClient/modules/serverAuth.d.ts +16 -0
- package/src/delegatedClient/modules/serverAuth.d.ts.map +1 -0
- package/src/delegatedClient/modules/sign.d.ts +27 -6
- package/src/delegatedClient/modules/sign.d.ts.map +1 -1
- package/src/deviceGrant.d.ts +90 -0
- package/src/deviceGrant.d.ts.map +1 -0
- package/src/index.d.ts +20 -2
- package/src/index.d.ts.map +1 -1
- package/src/mpc/mpc.d.ts +13 -6
- package/src/mpc/mpc.d.ts.map +1 -1
- package/src/observability/createErrorForwardingLogger.d.ts +7 -0
- package/src/observability/createErrorForwardingLogger.d.ts.map +1 -0
- package/src/observability/errorTelemetry.d.ts +29 -0
- package/src/observability/errorTelemetry.d.ts.map +1 -0
- package/src/observability/resolveLogger.d.ts +17 -0
- package/src/observability/resolveLogger.d.ts.map +1 -0
- package/src/observability/signRaceTelemetry.d.ts +42 -0
- package/src/observability/signRaceTelemetry.d.ts.map +1 -0
- package/src/requestSigning/es256.d.ts +17 -0
- package/src/requestSigning/es256.d.ts.map +1 -0
- package/src/requestSigning/index.d.ts +17 -0
- package/src/requestSigning/index.d.ts.map +1 -0
- package/src/requestSigning/noncePool.d.ts +23 -0
- package/src/requestSigning/noncePool.d.ts.map +1 -0
- package/src/requestSigning/proof.d.ts +15 -0
- package/src/requestSigning/proof.d.ts.map +1 -0
- package/src/requestSigning/signer.d.ts +35 -0
- package/src/requestSigning/signer.d.ts.map +1 -0
- package/src/requestSigning/signingKey.d.ts +9 -0
- package/src/requestSigning/signingKey.d.ts.map +1 -0
- package/src/sessionKeys.d.ts +27 -0
- package/src/sessionKeys.d.ts.map +1 -0
- package/src/signingContext.d.ts +17 -0
- package/src/signingContext.d.ts.map +1 -0
- package/src/siweUtils.d.ts +25 -0
- package/src/siweUtils.d.ts.map +1 -0
- package/src/types.d.ts +54 -2
- package/src/types.d.ts.map +1 -1
- package/src/utils.d.ts +27 -2
- package/src/utils.d.ts.map +1 -1
- package/src/version.d.ts +2 -0
- package/src/version.d.ts.map +1 -0
package/src/client.d.ts
CHANGED
|
@@ -1,91 +1,192 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BackupLocation, DynamicApiClient, ThresholdSignatureScheme, type ILogger, WalletOperation, type BitcoinConfig, type KeyShareBackupInfo, type RequestWithElevatedAccessToken } from '@dynamic-labs-wallet/core';
|
|
1
|
+
import { BIP340, Ecdsa, EcdsaKeygenResult, EcdsaSignature, ExportableEd25519, MessageHash, type EcdsaPublicKey } from '#internal/node';
|
|
2
|
+
import { BackupLocation, DynamicApiClient, EarnClient, ThresholdSignatureScheme, type ILogger, WalletOperation, type BitcoinConfig, type BusinessAccountActionRequired, type BusinessAccountSignedIntent, type SignerTarget, type WaasPolicyRule, type CreateCeremonyComplete, type CreateWalletAccountApiRequest, type KeyShareBackupInfo, type RequestWithElevatedAccessToken, type RequestSigner, type SignMessageContext } from '@dynamic-labs-wallet/core';
|
|
3
3
|
import { ForwardMPCClientV2 } from '@dynamic-labs-wallet/forward-mpc-client';
|
|
4
|
-
import
|
|
4
|
+
import { ServerBusinessAccountClient } from './businessAccounts/client.js';
|
|
5
5
|
import type { ServerKeyShare } from './mpc/index.js';
|
|
6
6
|
import type { ServerInitKeygenResult } from './mpc/types.js';
|
|
7
|
-
import type { DynamicWalletClientProps, WalletProperties } from './types.js';
|
|
7
|
+
import type { DynamicWalletClientProps, WalletMetadata, WalletProperties } from './types.js';
|
|
8
|
+
type RawPublicKey = EcdsaPublicKey | Uint8Array | string | undefined;
|
|
8
9
|
export declare class DynamicWalletClient {
|
|
9
10
|
environmentId: string;
|
|
10
11
|
debug: boolean;
|
|
12
|
+
/** Earn (yield vault) reads and unsigned-transaction builders. */
|
|
13
|
+
readonly earn: EarnClient;
|
|
11
14
|
protected logger: ILogger;
|
|
12
15
|
protected apiClient: DynamicApiClient;
|
|
13
|
-
protected walletMap: Record<string, WalletProperties>;
|
|
14
16
|
protected baseMPCRelayApiUrl?: string;
|
|
17
|
+
protected baseClientKeysharesRelayApiUrl?: string;
|
|
15
18
|
protected baseJWTAuthToken?: string;
|
|
16
19
|
protected baseApiUrl?: string;
|
|
17
20
|
protected isApiClientAuthenticated: boolean;
|
|
18
21
|
protected forwardMPCEnabled: boolean;
|
|
19
22
|
protected resolvedForwardMPCClient: ForwardMPCClientV2 | undefined;
|
|
20
|
-
|
|
23
|
+
protected getSessionSignature?: (message: string) => Promise<string>;
|
|
24
|
+
protected requestSigningSigner?: RequestSigner;
|
|
25
|
+
private readonly businessAccountConsentSigner?;
|
|
26
|
+
private nonceApiClient?;
|
|
27
|
+
private readonly sessionNonces;
|
|
28
|
+
constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, baseClientKeysharesRelayApiUrl, debug, forwardMPCClient, enableMPCAccelerator, logger, errorLogging, requestSigning, }: DynamicWalletClientProps);
|
|
29
|
+
private authenticateWithRequestSigning;
|
|
30
|
+
private nonceFetcher;
|
|
21
31
|
private ensureApiClientAuthenticated;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Guards against silent operate-on-different-wallet bugs when callers pass
|
|
34
|
+
* both `accountAddress` and `walletMetadata`. Throws when either is missing
|
|
35
|
+
* or when they disagree.
|
|
36
|
+
*
|
|
37
|
+
* Comparison is case-insensitive only for EVM (where checksum casing is
|
|
38
|
+
* decoration over an underlying hex address). SVM (base58), BTC base58,
|
|
39
|
+
* and TON (base64url) are case-sensitive — two addresses that differ only
|
|
40
|
+
* in case are different addresses.
|
|
41
|
+
*/
|
|
42
|
+
private assertAddressMatchesMetadata;
|
|
43
|
+
/**
|
|
44
|
+
* Installs a Dynamic JWT as the bearer token for all subsequent API calls
|
|
45
|
+
* and rebuilds the API client, preserving the forward-MPC client.
|
|
46
|
+
*/
|
|
47
|
+
private setAuthenticatedJwt;
|
|
48
|
+
/**
|
|
49
|
+
* Resolves the session key to bind into `authenticateApiToken`'s JWT.
|
|
50
|
+
*
|
|
51
|
+
* Defaults to generating a fresh session key per call (never persisted),
|
|
52
|
+
* mirroring the browser's rotate-on-reauth behavior. Pass `signingPublicKey`
|
|
53
|
+
* + `getSessionSignature` together to supply your own instead — e.g. a
|
|
54
|
+
* stable key reused across calls, or one backed by a KMS/HSM/enclave signer.
|
|
55
|
+
*/
|
|
56
|
+
private resolveSessionKey;
|
|
57
|
+
authenticateApiToken(authToken: string, options?: {
|
|
58
|
+
/** Compressed P-256 public key hex, bound into the JWT's `session_public_key` claim. Must be supplied together with `getSessionSignature`. */
|
|
59
|
+
signingPublicKey?: string;
|
|
60
|
+
/** Signs with the private key backing `signingPublicKey` (see `signSessionMessage`, or your own KMS/HSM/enclave signer). Must be supplied together with `signingPublicKey`. */
|
|
61
|
+
getSessionSignature?: (message: string) => Promise<string>;
|
|
62
|
+
}): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Authenticates the client with a Dynamic user JWT obtained outside the SDK —
|
|
65
|
+
* e.g. by an agent that completed a Dynamic sign-in (external auth, email OTP)
|
|
66
|
+
* on behalf of a user. Unlike authenticateApiToken, no token exchange happens:
|
|
67
|
+
* the JWT is used directly as the bearer token. The server validates it on
|
|
68
|
+
* every request; this method only checks the token's structure.
|
|
69
|
+
*
|
|
70
|
+
* `options.getSessionSignature` must return the signature as lowercase hex
|
|
71
|
+
* (raw ECDSA r‖s, as produced by `signSessionMessage`). Other encodings —
|
|
72
|
+
* notably base64, which can contain `/` — corrupt the `/`-delimited
|
|
73
|
+
* signed-session composite sent to the keyshares relay.
|
|
74
|
+
*/
|
|
75
|
+
authenticateJwt(jwt: string, options?: {
|
|
76
|
+
getSessionSignature?: (message: string) => Promise<string>;
|
|
77
|
+
}): Promise<void>;
|
|
78
|
+
private buildSignedSessionId;
|
|
79
|
+
/**
|
|
80
|
+
* Refreshes the Dynamic JWT using the current session and installs the new
|
|
81
|
+
* token for all subsequent API calls. Returns the new JWT so callers can
|
|
82
|
+
* persist it. The server enforces a hard refresh limit (the JWT's
|
|
83
|
+
* `refreshExp` claim) — once reached, this rejects with a 401 and the user
|
|
84
|
+
* must re-authenticate.
|
|
85
|
+
*/
|
|
86
|
+
refreshAuthToken(): Promise<string>;
|
|
87
|
+
/**
|
|
88
|
+
* Resolves this environment's server identity — a real userId the server
|
|
89
|
+
* itself is authenticated as, with no email/externalUserId of its own.
|
|
90
|
+
* Feed the returned userId into a business-account `addMember` call to add
|
|
91
|
+
* the server as a member.
|
|
92
|
+
*/
|
|
93
|
+
getServerIdentity(): Promise<{
|
|
94
|
+
userId: string;
|
|
95
|
+
}>;
|
|
96
|
+
/** Business-account reads, membership calls and proposal consent signing, made as the authenticated server. */
|
|
97
|
+
get businessAccounts(): ServerBusinessAccountClient;
|
|
98
|
+
/**
|
|
99
|
+
* Fetches wallet identity and signer-scoped backup pointers from the Dynamic
|
|
100
|
+
* API by `accountAddress`.
|
|
101
|
+
*
|
|
102
|
+
* Does not cache, does not mutate SDK state.
|
|
103
|
+
*/
|
|
104
|
+
fetchWalletMetadata(accountAddress: string): Promise<WalletMetadata>;
|
|
105
|
+
/**
|
|
106
|
+
* Returns cached backup info when available, otherwise refreshes it from the
|
|
107
|
+
* signer-scoped wallet lookup.
|
|
108
|
+
*/
|
|
109
|
+
protected resolveBackupInfo(walletMetadata: WalletMetadata): Promise<KeyShareBackupInfo>;
|
|
110
|
+
dynamicServerInitializeKeyGen({ onError, onCeremonyComplete, ...createWalletAccountRequest }: CreateWalletAccountApiRequest & {
|
|
30
111
|
onError?: (error: Error) => void;
|
|
31
|
-
onCeremonyComplete?: (
|
|
112
|
+
onCeremonyComplete?: (completion: CreateCeremonyComplete) => void;
|
|
32
113
|
}): Promise<import("@dynamic-labs-wallet/core").KeygenCompleteResponse>;
|
|
33
|
-
externalServerInitializeKeyGen({ chainName, thresholdSignatureScheme, bitcoinConfig, }: {
|
|
114
|
+
externalServerInitializeKeyGen({ chainName, dynamicRequestId, thresholdSignatureScheme, bitcoinConfig, }: {
|
|
34
115
|
chainName: string;
|
|
116
|
+
dynamicRequestId?: string;
|
|
35
117
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
36
118
|
bitcoinConfig?: BitcoinConfig;
|
|
37
119
|
}): Promise<ServerInitKeygenResult[]>;
|
|
38
|
-
derivePublicKey({ chainName, keyShare, derivationPath, bitcoinConfig, }: {
|
|
120
|
+
derivePublicKey({ chainName, keyShare, derivationPath, bitcoinConfig, dynamicRequestId, }: {
|
|
39
121
|
chainName: string;
|
|
40
122
|
keyShare: ServerKeyShare;
|
|
41
123
|
derivationPath: Uint32Array | undefined;
|
|
42
124
|
bitcoinConfig?: BitcoinConfig;
|
|
125
|
+
dynamicRequestId?: string;
|
|
43
126
|
}): Promise<string | EcdsaPublicKey | Uint8Array | undefined>;
|
|
44
|
-
forwardMPCExternalServerKeyGen({ chainName, roomId, dynamicServerKeygenIds, externalServerInitKeygenResults, thresholdSignatureScheme, bitcoinConfig, }: {
|
|
127
|
+
forwardMPCExternalServerKeyGen({ chainName, roomId, dynamicServerKeygenIds, externalServerInitKeygenResults, dynamicRequestId, thresholdSignatureScheme, bitcoinConfig, }: {
|
|
45
128
|
chainName: string;
|
|
46
129
|
roomId: string;
|
|
47
130
|
dynamicServerKeygenIds: string[];
|
|
48
131
|
externalServerInitKeygenResults: ServerInitKeygenResult[];
|
|
132
|
+
dynamicRequestId: string;
|
|
49
133
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
50
134
|
bitcoinConfig?: BitcoinConfig;
|
|
51
135
|
}): Promise<{
|
|
52
|
-
rawPublicKey:
|
|
136
|
+
rawPublicKey: RawPublicKey;
|
|
53
137
|
externalServerKeyGenResults: ServerKeyShare[];
|
|
54
138
|
}>;
|
|
55
|
-
externalServerKeyGen({ chainName, roomId, dynamicServerKeygenIds, externalServerInitKeygenResults, thresholdSignatureScheme, bitcoinConfig, }: {
|
|
139
|
+
externalServerKeyGen({ chainName, roomId, dynamicRequestId, dynamicServerKeygenIds, externalServerInitKeygenResults, thresholdSignatureScheme, bitcoinConfig, }: {
|
|
56
140
|
chainName: string;
|
|
57
141
|
roomId: string;
|
|
142
|
+
dynamicRequestId: string;
|
|
58
143
|
dynamicServerKeygenIds: string[];
|
|
59
144
|
externalServerInitKeygenResults: ServerInitKeygenResult[];
|
|
60
145
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
61
146
|
bitcoinConfig?: BitcoinConfig;
|
|
62
147
|
}): Promise<{
|
|
63
|
-
rawPublicKey:
|
|
148
|
+
rawPublicKey: RawPublicKey;
|
|
64
149
|
externalServerKeyGenResults: ServerKeyShare[];
|
|
65
150
|
}>;
|
|
66
|
-
|
|
151
|
+
private relayExternalServerKeyGen;
|
|
152
|
+
protected validatePasswordForBackup({ password, backUpToDynamic }: {
|
|
153
|
+
password?: string;
|
|
154
|
+
backUpToDynamic?: boolean;
|
|
155
|
+
}): void;
|
|
156
|
+
protected createCeremonyCompletionTracker(): {
|
|
157
|
+
completion: Partial<CreateCeremonyComplete>;
|
|
158
|
+
onCeremonyComplete: (completion: CreateCeremonyComplete) => void;
|
|
159
|
+
promise: Promise<void>;
|
|
160
|
+
};
|
|
161
|
+
keyGen({ chainName, thresholdSignatureScheme, skipLock, bitcoinConfig, password, backUpToDynamic, returnEncryptedWalletApiKey, onError, onCeremonyComplete, }: {
|
|
67
162
|
chainName: string;
|
|
68
163
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
69
164
|
skipLock?: boolean;
|
|
70
165
|
bitcoinConfig?: BitcoinConfig;
|
|
166
|
+
password?: string;
|
|
167
|
+
backUpToDynamic?: boolean;
|
|
168
|
+
/** Opt in to a wallet API key for this wallet; needs a delegated-access key registered for the environment. */
|
|
169
|
+
returnEncryptedWalletApiKey?: boolean;
|
|
71
170
|
onError?: (error: Error) => void;
|
|
72
|
-
onCeremonyComplete?: (
|
|
171
|
+
onCeremonyComplete?: (completion: CreateCeremonyComplete) => void;
|
|
73
172
|
}): Promise<{
|
|
74
|
-
rawPublicKey:
|
|
173
|
+
rawPublicKey: RawPublicKey;
|
|
75
174
|
externalServerKeyShares: ServerKeyShare[];
|
|
76
175
|
}>;
|
|
77
|
-
importRawPrivateKey({ chainName, privateKey, thresholdSignatureScheme, bitcoinConfig, onError, onCeremonyComplete, }: {
|
|
176
|
+
importRawPrivateKey({ chainName, privateKey, thresholdSignatureScheme, bitcoinConfig, password, backUpToDynamic, onError, onCeremonyComplete, }: {
|
|
78
177
|
chainName: string;
|
|
79
178
|
privateKey: string;
|
|
80
179
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
81
180
|
bitcoinConfig?: BitcoinConfig;
|
|
181
|
+
password?: string;
|
|
182
|
+
backUpToDynamic?: boolean;
|
|
82
183
|
onError?: (error: Error) => void;
|
|
83
|
-
onCeremonyComplete?: (
|
|
184
|
+
onCeremonyComplete?: (completion: CreateCeremonyComplete) => void;
|
|
84
185
|
}): Promise<{
|
|
85
|
-
rawPublicKey:
|
|
186
|
+
rawPublicKey: RawPublicKey;
|
|
86
187
|
externalServerKeyShares: ServerKeyShare[];
|
|
87
188
|
}>;
|
|
88
|
-
dynamicServerSign({ walletId, message, isFormatted, context, bitcoinConfig, onError, dynamicRequestId: providedRequestId, }: {
|
|
189
|
+
dynamicServerSign({ walletId, message, isFormatted, context, bitcoinConfig, onError, dynamicRequestId: providedRequestId, shareSetId, }: {
|
|
89
190
|
walletId: string;
|
|
90
191
|
message: string | Uint8Array;
|
|
91
192
|
isFormatted?: boolean;
|
|
@@ -93,12 +194,19 @@ export declare class DynamicWalletClient {
|
|
|
93
194
|
bitcoinConfig?: BitcoinConfig;
|
|
94
195
|
onError?: (error: Error) => void;
|
|
95
196
|
dynamicRequestId?: string;
|
|
197
|
+
shareSetId?: string;
|
|
96
198
|
}): Promise<{
|
|
97
199
|
dynamicRequestId: string;
|
|
98
200
|
roomId: string;
|
|
99
|
-
serverKeygenIds: string
|
|
201
|
+
serverKeygenIds: Array<string>;
|
|
202
|
+
newServerKeygenIds?: Array<string>;
|
|
203
|
+
walletId?: string;
|
|
204
|
+
accountAddress?: string;
|
|
205
|
+
encryptedWalletApiKey?: import("@dynamic-labs/sdk-api-core").EncryptedWalletApiKey | null;
|
|
206
|
+
shareSetId?: string | null;
|
|
207
|
+
shareSetType?: import("@dynamic-labs/sdk-api-core").WaasWalletShareSetType;
|
|
100
208
|
}>;
|
|
101
|
-
externalServerSign({ chainName, message, roomId, keyShare, derivationPath, isFormatted, bitcoinConfig, }: {
|
|
209
|
+
externalServerSign({ chainName, message, roomId, keyShare, derivationPath, isFormatted, bitcoinConfig, dynamicRequestId, }: {
|
|
102
210
|
chainName: string;
|
|
103
211
|
message: string | Uint8Array;
|
|
104
212
|
roomId: string;
|
|
@@ -106,8 +214,10 @@ export declare class DynamicWalletClient {
|
|
|
106
214
|
derivationPath: Uint32Array | undefined;
|
|
107
215
|
isFormatted?: boolean;
|
|
108
216
|
bitcoinConfig?: BitcoinConfig;
|
|
217
|
+
dynamicRequestId: string;
|
|
109
218
|
}): Promise<Uint8Array | EcdsaSignature>;
|
|
110
|
-
|
|
219
|
+
private convertTweakForBIP340;
|
|
220
|
+
forwardMPCClientSign({ chainName, message, roomId, keyShare, derivationPath, formattedMessage, dynamicRequestId, isFormatted, walletId, bitcoinConfig, }: {
|
|
111
221
|
chainName: string;
|
|
112
222
|
message: string | Uint8Array;
|
|
113
223
|
roomId: string;
|
|
@@ -117,14 +227,13 @@ export declare class DynamicWalletClient {
|
|
|
117
227
|
dynamicRequestId: string;
|
|
118
228
|
isFormatted?: boolean;
|
|
119
229
|
walletId?: string;
|
|
230
|
+
bitcoinConfig?: BitcoinConfig;
|
|
120
231
|
}): Promise<Uint8Array | EcdsaSignature>;
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
private trySignViaForwardMpc;
|
|
127
|
-
sign({ accountAddress, externalServerKeyShares, message, chainName, password, isFormatted, context, onError, bitcoinConfig, }: {
|
|
232
|
+
/** Forward MPC does not support Aleo or Midnight yet; use relay MPC until it does. */
|
|
233
|
+
private shouldSkipForwardMPC;
|
|
234
|
+
/** The forward-MPC sign for a room, or undefined when forward MPC is not used for this chain. */
|
|
235
|
+
private forwardSignFor;
|
|
236
|
+
sign({ accountAddress, externalServerKeyShares, message, chainName, password, isFormatted, context, onError, bitcoinConfig, walletMetadata, walletOperation, passwordPreVerified, }: {
|
|
128
237
|
accountAddress: string;
|
|
129
238
|
externalServerKeyShares?: ServerKeyShare[];
|
|
130
239
|
message: string | Uint8Array;
|
|
@@ -134,14 +243,29 @@ export declare class DynamicWalletClient {
|
|
|
134
243
|
context?: SignMessageContext;
|
|
135
244
|
bitcoinConfig?: BitcoinConfig;
|
|
136
245
|
onError?: (error: Error) => void;
|
|
246
|
+
walletMetadata: WalletMetadata;
|
|
247
|
+
/** Drives recovery shape (e.g. SIGN_MESSAGE vs SIGN_TRANSACTION). */
|
|
248
|
+
walletOperation?: WalletOperation;
|
|
249
|
+
/**
|
|
250
|
+
* BTC pre-resolves shares to derive the public key for BIP-322 / Taproot
|
|
251
|
+
* formatting. When it does, password was already validated by that
|
|
252
|
+
* recovery, so this flag tells `sign()` to skip a second verifyPassword
|
|
253
|
+
* round-trip. Other chains pass shares straight through and don't set it.
|
|
254
|
+
*/
|
|
255
|
+
passwordPreVerified?: boolean;
|
|
137
256
|
}): Promise<Uint8Array | EcdsaSignature>;
|
|
138
|
-
refreshWalletAccountShares({ accountAddress, chainName, password, externalServerKeyShares,
|
|
257
|
+
refreshWalletAccountShares({ accountAddress, chainName, password, externalServerKeyShares, backUpToDynamic, walletMetadata, }: {
|
|
139
258
|
accountAddress: string;
|
|
140
259
|
chainName: string;
|
|
141
260
|
password?: string;
|
|
142
261
|
externalServerKeyShares?: ServerKeyShare[];
|
|
143
|
-
|
|
144
|
-
|
|
262
|
+
backUpToDynamic?: boolean;
|
|
263
|
+
walletMetadata: WalletMetadata;
|
|
264
|
+
}): Promise<{
|
|
265
|
+
externalServerKeyShares: (EcdsaKeygenResult | import("#internal/node").Ed25519KeygenResult)[];
|
|
266
|
+
backupInfo: KeyShareBackupInfo;
|
|
267
|
+
walletMetadata: WalletMetadata;
|
|
268
|
+
}>;
|
|
145
269
|
getExportId({ chainName, serverKeyShare, bitcoinConfig, }: {
|
|
146
270
|
chainName: string;
|
|
147
271
|
serverKeyShare: ServerKeyShare;
|
|
@@ -163,7 +287,7 @@ export declare class DynamicWalletClient {
|
|
|
163
287
|
*/
|
|
164
288
|
reshareStrategy({ chainName, wallet, oldThresholdSignatureScheme, newThresholdSignatureScheme, }: {
|
|
165
289
|
chainName: string;
|
|
166
|
-
wallet: WalletProperties
|
|
290
|
+
wallet: Pick<WalletProperties, 'addressType' | 'externalServerKeyShares'>;
|
|
167
291
|
oldThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
168
292
|
newThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
169
293
|
}): Promise<{
|
|
@@ -172,28 +296,80 @@ export declare class DynamicWalletClient {
|
|
|
172
296
|
existingExternalServerKeygenIds: string[];
|
|
173
297
|
existingExternalServerKeyShares: ServerKeyShare[];
|
|
174
298
|
}>;
|
|
175
|
-
reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, externalServerKeyShares,
|
|
299
|
+
reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, externalServerKeyShares, backUpToDynamic, walletMetadata, }: {
|
|
176
300
|
chainName: string;
|
|
177
301
|
accountAddress: string;
|
|
178
302
|
oldThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
179
303
|
newThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
180
304
|
password?: string;
|
|
181
305
|
externalServerKeyShares?: ServerKeyShare[];
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
306
|
+
backUpToDynamic?: boolean;
|
|
307
|
+
walletMetadata: WalletMetadata;
|
|
308
|
+
}): Promise<{
|
|
309
|
+
externalServerKeyShares: (EcdsaKeygenResult | import("#internal/node").Ed25519KeygenResult)[];
|
|
310
|
+
backupInfo: KeyShareBackupInfo;
|
|
311
|
+
walletMetadata: WalletMetadata;
|
|
312
|
+
}>;
|
|
313
|
+
/**
|
|
314
|
+
* Adds an end user as a signer of a business-account wallet this server holds a share of: reshares into a
|
|
315
|
+
* new 2/2 share set for the target, writes the target's share to CKS on their behalf with the single-use
|
|
316
|
+
* grant, and activates the share set. The server's own share set is untouched.
|
|
317
|
+
*
|
|
318
|
+
* A governed account answers with {@link BusinessAccountActionRequired} (no key material moved) instead.
|
|
319
|
+
*/
|
|
320
|
+
reshareToNewSignerShareSet({ businessAccountId, walletMetadata, externalServerKeyShares, signerType, targetSignerIdentity, targetSignerPassword, initialSignerRules, intent, intentSignature, elevatedAccessToken, }: {
|
|
321
|
+
businessAccountId: string;
|
|
322
|
+
walletMetadata: WalletMetadata;
|
|
323
|
+
/** The server's own share of the wallet (e.g. restored from CKS). */
|
|
324
|
+
externalServerKeyShares: ServerKeyShare[];
|
|
325
|
+
targetSignerPassword?: string;
|
|
326
|
+
initialSignerRules?: WaasPolicyRule[];
|
|
327
|
+
/** Signed intent for a governed account, added once a first call answered `BusinessAccountActionRequired`. */
|
|
328
|
+
intent?: BusinessAccountSignedIntent['intent'];
|
|
329
|
+
intentSignature?: string;
|
|
330
|
+
elevatedAccessToken?: string;
|
|
331
|
+
} & SignerTarget): Promise<{
|
|
332
|
+
shareSetId: string;
|
|
333
|
+
targetUserId: string;
|
|
334
|
+
} | BusinessAccountActionRequired>;
|
|
335
|
+
/**
|
|
336
|
+
* Runs the MPC export ceremony and returns the raw master key material,
|
|
337
|
+
* before any derivation-path derivation is applied.
|
|
338
|
+
*
|
|
339
|
+
* `protected` on purpose: chains whose key hierarchy needs more than the one
|
|
340
|
+
* key at `walletMetadata.derivationPath` (Midnight derives unshielded,
|
|
341
|
+
* shielded, and dust roles from a single master) subclass this client and
|
|
342
|
+
* derive from the xprv themselves. Public callers get {@link exportKey},
|
|
343
|
+
* which returns only the single derived key. Never log or persist the value
|
|
344
|
+
* returned here.
|
|
345
|
+
*/
|
|
346
|
+
protected exportMasterKeyMaterial({ accountAddress, chainName, password, externalServerKeyShares, bitcoinConfig, elevatedAccessToken, walletMetadata, }: RequestWithElevatedAccessToken<{
|
|
347
|
+
accountAddress: string;
|
|
348
|
+
chainName: string;
|
|
349
|
+
password?: string;
|
|
350
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
351
|
+
bitcoinConfig?: BitcoinConfig;
|
|
352
|
+
walletMetadata: WalletMetadata;
|
|
353
|
+
}>): Promise<{
|
|
354
|
+
keyExportRaw: string;
|
|
355
|
+
derivationPath: Uint32Array | undefined;
|
|
356
|
+
mpcSigner: Ecdsa | import("#internal/node").Ed25519 | ExportableEd25519 | BIP340;
|
|
357
|
+
}>;
|
|
358
|
+
exportKey(params: RequestWithElevatedAccessToken<{
|
|
185
359
|
accountAddress: string;
|
|
186
360
|
chainName: string;
|
|
187
361
|
password?: string;
|
|
188
362
|
externalServerKeyShares?: ServerKeyShare[];
|
|
189
363
|
bitcoinConfig?: BitcoinConfig;
|
|
364
|
+
walletMetadata: WalletMetadata;
|
|
190
365
|
}>): Promise<{
|
|
191
366
|
derivedPrivateKey: string | undefined;
|
|
192
367
|
}>;
|
|
193
|
-
offlineExportKey({ chainName, keyShares, derivationPath, }: {
|
|
368
|
+
offlineExportKey({ chainName, keyShares, derivationPath, thresholdSignatureScheme, }: {
|
|
194
369
|
chainName: string;
|
|
195
370
|
keyShares: ServerKeyShare[];
|
|
196
371
|
derivationPath?: string;
|
|
372
|
+
thresholdSignatureScheme?: ThresholdSignatureScheme;
|
|
197
373
|
}): Promise<{
|
|
198
374
|
derivedPrivateKey: string | undefined;
|
|
199
375
|
}>;
|
|
@@ -201,37 +377,49 @@ export declare class DynamicWalletClient {
|
|
|
201
377
|
keyShare: ServerKeyShare;
|
|
202
378
|
password?: string;
|
|
203
379
|
}): Promise<string>;
|
|
204
|
-
|
|
205
|
-
accountAddress: string;
|
|
206
|
-
}): Promise<void>;
|
|
207
|
-
storeEncryptedBackupByWallet({ accountAddress, externalServerKeyShares, password, backUpToClientShareService, }: {
|
|
380
|
+
storeEncryptedBackupByWallet({ accountAddress, externalServerKeyShares, password, backUpToDynamic, walletMetadata, shareSetId, }: {
|
|
208
381
|
accountAddress: string;
|
|
209
382
|
externalServerKeyShares?: ServerKeyShare[];
|
|
210
383
|
password?: string;
|
|
211
|
-
|
|
384
|
+
backUpToDynamic: boolean;
|
|
385
|
+
walletMetadata: WalletMetadata;
|
|
386
|
+
shareSetId?: string;
|
|
212
387
|
}): Promise<{
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
388
|
+
keySharesWithBackupStatus: {
|
|
389
|
+
share: ServerKeyShare;
|
|
390
|
+
backedUpToClientKeyShareService: boolean;
|
|
391
|
+
}[];
|
|
392
|
+
backupInfo: KeyShareBackupInfo;
|
|
393
|
+
}>;
|
|
394
|
+
storeEncryptedBackupByWalletWithRetry({ accountAddress, externalServerKeyShares, password, backUpToDynamic, walletMetadata, }: {
|
|
217
395
|
accountAddress: string;
|
|
218
396
|
externalServerKeyShares?: ServerKeyShare[];
|
|
219
397
|
password?: string;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
398
|
+
backUpToDynamic: boolean;
|
|
399
|
+
walletMetadata: WalletMetadata;
|
|
400
|
+
}): Promise<{
|
|
401
|
+
keySharesWithBackupStatus: Array<{
|
|
402
|
+
share: ServerKeyShare;
|
|
403
|
+
backedUpToClientKeyShareService: boolean;
|
|
404
|
+
}>;
|
|
405
|
+
backupInfo: KeyShareBackupInfo;
|
|
406
|
+
}>;
|
|
407
|
+
getExternalServerKeyShares({ accountAddress, password, walletMetadata, backupInfo, }: {
|
|
226
408
|
accountAddress: string;
|
|
227
409
|
password?: string;
|
|
410
|
+
walletMetadata: WalletMetadata;
|
|
411
|
+
backupInfo?: KeyShareBackupInfo;
|
|
228
412
|
}): Promise<any[]>;
|
|
229
|
-
updatePassword({ accountAddress, existingPassword, newPassword,
|
|
413
|
+
updatePassword({ accountAddress, existingPassword, newPassword, backUpToDynamic, externalServerKeyShares, walletMetadata, }: {
|
|
230
414
|
accountAddress: string;
|
|
231
415
|
existingPassword?: string;
|
|
232
416
|
newPassword?: string;
|
|
233
|
-
|
|
234
|
-
|
|
417
|
+
backUpToDynamic: boolean;
|
|
418
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
419
|
+
walletMetadata: WalletMetadata;
|
|
420
|
+
}): Promise<{
|
|
421
|
+
backupInfo: KeyShareBackupInfo;
|
|
422
|
+
}>;
|
|
235
423
|
decryptKeyShare({ keyShare, password }: {
|
|
236
424
|
keyShare: string;
|
|
237
425
|
password?: string;
|
|
@@ -258,102 +446,98 @@ export declare class DynamicWalletClient {
|
|
|
258
446
|
requiredShareCount: number;
|
|
259
447
|
};
|
|
260
448
|
/**
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
* @param accountAddress - The account address to
|
|
449
|
+
* Resolves and returns key shares for wallet operations.
|
|
450
|
+
* Checks in order: provided shares, then attempts recovery from backup.
|
|
451
|
+
* @param accountAddress - The account address to get shares for
|
|
264
452
|
* @param password - The password to decrypt the shares
|
|
265
453
|
* @param walletOperation - The wallet operation being performed
|
|
266
454
|
* @param externalServerKeyShares - The provided key shares (if any)
|
|
267
|
-
* @param errorMessage - The error message to throw if
|
|
268
|
-
* @
|
|
455
|
+
* @param errorMessage - The error message to throw if no shares are found
|
|
456
|
+
* @param walletMetadata - Required wallet metadata identifying the target wallet
|
|
457
|
+
* @returns The resolved key shares
|
|
458
|
+
* @throws Error if no shares are found and recovery fails
|
|
269
459
|
*/
|
|
270
|
-
protected
|
|
460
|
+
protected resolveKeyShares({ accountAddress, password, walletOperation, externalServerKeyShares, errorMessage, walletMetadata, backupInfo, }: {
|
|
271
461
|
accountAddress: string;
|
|
272
462
|
password?: string;
|
|
273
463
|
walletOperation: WalletOperation;
|
|
274
464
|
externalServerKeyShares?: ServerKeyShare[];
|
|
275
465
|
errorMessage: string;
|
|
276
|
-
|
|
277
|
-
|
|
466
|
+
walletMetadata: WalletMetadata;
|
|
467
|
+
backupInfo?: KeyShareBackupInfo;
|
|
468
|
+
}): Promise<ServerKeyShare[]>;
|
|
469
|
+
recoverEncryptedBackupByWallet({ accountAddress, password, walletOperation, shareCount, walletMetadata, backupInfo, }: {
|
|
278
470
|
accountAddress: string;
|
|
279
471
|
password?: string;
|
|
280
472
|
walletOperation: WalletOperation;
|
|
281
473
|
shareCount?: number;
|
|
282
|
-
|
|
474
|
+
walletMetadata: WalletMetadata;
|
|
475
|
+
backupInfo?: KeyShareBackupInfo;
|
|
283
476
|
}): Promise<any[]>;
|
|
284
|
-
exportExternalServerKeyShares({ accountAddress, password }: {
|
|
477
|
+
exportExternalServerKeyShares({ accountAddress, password, walletMetadata, }: {
|
|
285
478
|
accountAddress: string;
|
|
286
479
|
password?: string;
|
|
480
|
+
walletMetadata: WalletMetadata;
|
|
287
481
|
}): Promise<any[]>;
|
|
288
|
-
/**
|
|
289
|
-
* Helper function to check if the required wallet fields are present and valid
|
|
290
|
-
* @param accountAddress - The account address of the wallet to check
|
|
291
|
-
* @param walletOperation - The wallet operation that determines required fields
|
|
292
|
-
* @returns boolean indicating if wallet needs to be re-fetched and restored from server
|
|
293
|
-
*/
|
|
294
|
-
private checkWalletFields;
|
|
295
482
|
/**
|
|
296
483
|
* verifyPassword attempts to recover and decrypt a single client key share using the provided password.
|
|
297
484
|
* If successful, the key share is encrypted with the new password. This method solely performs the recovery
|
|
298
485
|
* and decryption without storing the restored key shares. If unsuccessful, it throws an error.
|
|
299
486
|
*/
|
|
300
|
-
verifyPassword({ accountAddress, password }: {
|
|
487
|
+
verifyPassword({ accountAddress, password, walletMetadata, backupInfo, }: {
|
|
301
488
|
accountAddress: string;
|
|
302
489
|
password?: string;
|
|
490
|
+
walletMetadata: WalletMetadata;
|
|
491
|
+
backupInfo?: KeyShareBackupInfo;
|
|
303
492
|
}): Promise<void>;
|
|
304
|
-
isPasswordEncrypted({ accountAddress }: {
|
|
493
|
+
isPasswordEncrypted({ accountAddress, walletMetadata, backupInfo, }: {
|
|
305
494
|
accountAddress: string;
|
|
495
|
+
walletMetadata: WalletMetadata;
|
|
496
|
+
backupInfo?: KeyShareBackupInfo;
|
|
306
497
|
}): Promise<boolean>;
|
|
307
498
|
/**
|
|
308
499
|
* check if the operation requires a password
|
|
309
500
|
*/
|
|
310
|
-
requiresPasswordForOperation({ accountAddress, walletOperation, }: {
|
|
501
|
+
requiresPasswordForOperation({ accountAddress, walletOperation, walletMetadata, backupInfo, }: {
|
|
311
502
|
accountAddress: string;
|
|
312
503
|
walletOperation?: WalletOperation;
|
|
504
|
+
walletMetadata: WalletMetadata;
|
|
505
|
+
backupInfo?: KeyShareBackupInfo;
|
|
313
506
|
}): Promise<boolean>;
|
|
314
507
|
/**
|
|
315
508
|
* check if the operation requires restoring backup shares
|
|
316
509
|
*/
|
|
317
|
-
requiresRestoreBackupSharesForOperation({ accountAddress, walletOperation, }: {
|
|
510
|
+
requiresRestoreBackupSharesForOperation({ accountAddress, walletOperation, walletMetadata, backupInfo, }: {
|
|
318
511
|
accountAddress: string;
|
|
319
512
|
walletOperation?: WalletOperation;
|
|
513
|
+
walletMetadata: WalletMetadata;
|
|
514
|
+
backupInfo?: KeyShareBackupInfo;
|
|
320
515
|
}): Promise<boolean>;
|
|
321
|
-
getWalletExternalServerKeyShareBackupInfo({
|
|
322
|
-
|
|
516
|
+
getWalletExternalServerKeyShareBackupInfo({ walletMetadata, }: {
|
|
517
|
+
walletMetadata: WalletMetadata;
|
|
323
518
|
}): Promise<KeyShareBackupInfo>;
|
|
324
|
-
getWallet({ accountAddress, walletOperation, shareCount, password, }: {
|
|
325
|
-
accountAddress: string;
|
|
326
|
-
walletOperation?: WalletOperation;
|
|
327
|
-
shareCount?: number;
|
|
328
|
-
password?: string;
|
|
329
|
-
}): Promise<WalletProperties>;
|
|
330
519
|
/**
|
|
331
|
-
* Get a single wallet by address
|
|
332
|
-
* First tries the efficient getWaasWalletByAddress endpoint, falls back to
|
|
520
|
+
* Get a single wallet by address.
|
|
521
|
+
* First tries the efficient `getWaasWalletByAddress` endpoint, falls back to
|
|
522
|
+
* `getUser()` if not available.
|
|
523
|
+
*
|
|
524
|
+
* Prefer `fetchWalletMetadata(accountAddress)` when the legacy `getUser`
|
|
525
|
+
* fallback is not needed.
|
|
333
526
|
*/
|
|
334
527
|
getWalletByAddress(accountAddress: string): Promise<WalletProperties | null>;
|
|
335
528
|
/**
|
|
336
529
|
* Get all wallets (kept for backward compatibility but now uses lazy loading)
|
|
337
530
|
* @deprecated Consider using getWalletByAddress for better performance with large wallet counts
|
|
338
531
|
*/
|
|
339
|
-
getWallets(): Promise<
|
|
340
|
-
/**
|
|
341
|
-
* Helper method to initialize or update a wallet entry in the walletMap.
|
|
342
|
-
* This provides a consistent way to set up wallet properties across different operations.
|
|
343
|
-
* @param accountAddress - The account address for the wallet
|
|
344
|
-
* @param walletId - The wallet ID
|
|
345
|
-
* @param chainName - The chain name (e.g., 'BTC', 'EVM')
|
|
346
|
-
* @param thresholdSignatureScheme - The threshold signature scheme
|
|
347
|
-
* @param derivationPath - Optional derivation path for the wallet
|
|
348
|
-
* @param additionalProps - Optional additional properties to merge into the wallet entry
|
|
349
|
-
*/
|
|
350
|
-
protected initializeWalletMapEntry({ accountAddress, walletId, chainName, thresholdSignatureScheme, derivationPath, additionalProps, }: {
|
|
351
|
-
accountAddress: string;
|
|
532
|
+
getWallets(): Promise<{
|
|
352
533
|
walletId: string;
|
|
353
534
|
chainName: string;
|
|
535
|
+
accountAddress: string;
|
|
536
|
+
externalServerKeySharesBackupInfo: KeyShareBackupInfo;
|
|
537
|
+
externalServerKeyShares: never[];
|
|
538
|
+
derivationPath: string | undefined;
|
|
354
539
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
355
|
-
|
|
356
|
-
additionalProps?: Record<string, unknown>;
|
|
357
|
-
}): void;
|
|
540
|
+
}[]>;
|
|
358
541
|
}
|
|
542
|
+
export {};
|
|
359
543
|
//# sourceMappingURL=client.d.ts.map
|