@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Rewrites a raw 64-byte ES256 signature to low-S (`s → n − s` when `s > n / 2`), which verifiers require. */
|
|
2
|
+
export declare const toLowS: (signature: Buffer) => Buffer;
|
|
3
|
+
/** Signs raw bytes with an ECDSA P-256 key that cannot be exported (KMS, HSM, enclave): SHA-256, raw `r || s`. */
|
|
4
|
+
export type Es256RawSigner = (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
5
|
+
/**
|
|
6
|
+
* A compact ES256 JWS signed through a callback. The signature is normalized to low-S; anything other than
|
|
7
|
+
* raw 64-byte `r || s` (a DER signature, say) throws a `RangeError`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const signJwsEs256WithSigner: ({ payload, sign, kid, typ, }: {
|
|
10
|
+
/** Its exact `JSON.stringify` bytes become the JWS payload. */
|
|
11
|
+
payload: object;
|
|
12
|
+
sign: Es256RawSigner;
|
|
13
|
+
kid: string;
|
|
14
|
+
/** Media type binding the JWS to its artifact family. */
|
|
15
|
+
typ: string;
|
|
16
|
+
}) => Promise<string>;
|
|
17
|
+
//# sourceMappingURL=es256.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"es256.d.ts","sourceRoot":"","sources":["../../src/requestSigning/es256.ts"],"names":[],"mappings":"AAqBA,+GAA+G;AAC/G,eAAO,MAAM,MAAM,cAAe,MAAM,KAAG,MAO1C,CAAC;AAEF,kHAAkH;AAClH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,iCAKhC;IACD,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC;CACb,KAAG,OAAO,CAAC,MAAM,CAKjB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RequestSigner } from '@dynamic-labs-wallet/core';
|
|
2
|
+
import { type RequestSigningOption } from './signer.js';
|
|
3
|
+
export { NoncePool } from './noncePool.js';
|
|
4
|
+
export { REQUEST_SIGNING_PROOF_HEADER, WALLET_API_KEY_HEADER, buildRequestProof } from './proof.js';
|
|
5
|
+
export { resolveRequestSigning } from './signer.js';
|
|
6
|
+
export type { ResolvedRequestSigning, RequestSigning, RequestSigningOption } from './signer.js';
|
|
7
|
+
export interface RequestSigningSignerOptions {
|
|
8
|
+
requestSigning: RequestSigningOption;
|
|
9
|
+
environmentId: string;
|
|
10
|
+
/** Nonces issued by auth-service (`auth…`), single-use. */
|
|
11
|
+
fetchNonces: (count: number) => Promise<string[]>;
|
|
12
|
+
/** The registered key's kid, if known: a mismatch fails at construction rather than as a 401. */
|
|
13
|
+
expectedKid?: string;
|
|
14
|
+
}
|
|
15
|
+
/** A {@link RequestSigner} that adds a request-signing proof, and the wallet's key where it has one, to every request. */
|
|
16
|
+
export declare const createRequestSigningSigner: ({ requestSigning, environmentId, fetchNonces, expectedKid, }: RequestSigningSignerOptions) => RequestSigner;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/requestSigning/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,OAAO,EAAyB,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpG,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,sBAAsB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEhG,MAAM,WAAW,2BAA2B;IAC1C,cAAc,EAAE,oBAAoB,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD,iGAAiG;IACjG,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,0HAA0H;AAC1H,eAAO,MAAM,0BAA0B,iEAKpC,2BAA2B,KAAG,aAmBhC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface NoncePoolOptions {
|
|
2
|
+
fetchNonces: (count: number) => Promise<string[]>;
|
|
3
|
+
batchSize?: number;
|
|
4
|
+
/** Pooled nonces older than this are dropped (backend TTL must exceed it plus the proof lifetime). */
|
|
5
|
+
maxAgeMs?: number;
|
|
6
|
+
now?: () => number;
|
|
7
|
+
}
|
|
8
|
+
/** Single-use nonce pool: refills in coalesced batches and never hands out an expired nonce. */
|
|
9
|
+
export declare class NoncePool {
|
|
10
|
+
private readonly pool;
|
|
11
|
+
private refill?;
|
|
12
|
+
private generation;
|
|
13
|
+
private readonly batchSize;
|
|
14
|
+
private readonly maxAgeMs;
|
|
15
|
+
private readonly now;
|
|
16
|
+
private readonly fetchNonces;
|
|
17
|
+
constructor({ fetchNonces, batchSize, maxAgeMs, now, }: NoncePoolOptions);
|
|
18
|
+
take(): Promise<string>;
|
|
19
|
+
/** Drops pooled nonces and any refill in flight, e.g. when the session they were issued under ends. */
|
|
20
|
+
clear(): void;
|
|
21
|
+
private fill;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=noncePool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noncePool.d.ts","sourceRoot":"","sources":["../../src/requestSigning/noncePool.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAMD,gGAAgG;AAChG,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA8C;IACnE,OAAO,CAAC,MAAM,CAAC,CAAgB;IAE/B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAkC;gBAElD,EACV,WAAW,EACX,SAA8B,EAC9B,QAA6B,EAC7B,GAAc,GACf,EAAE,gBAAgB;IAOb,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAW7B,uGAAuG;IACvG,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,IAAI;CAcb"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SignableRequest } from '@dynamic-labs-wallet/core';
|
|
2
|
+
import type { ResolvedRequestSigning } from './signer.js';
|
|
3
|
+
export declare const REQUEST_SIGNING_PROOF_HEADER = "x-dyn-request-signing-proof";
|
|
4
|
+
/** Per-wallet key a proof-signed request presents next to its proof. */
|
|
5
|
+
export declare const WALLET_API_KEY_HEADER = "x-dyn-wallet-api-key";
|
|
6
|
+
export declare const PROOF_LIFETIME_SECONDS = 120;
|
|
7
|
+
/** The request proof: binds the request's method, path and body digest, signed by the registered key. */
|
|
8
|
+
export declare const buildRequestProof: ({ signer, environmentId, request, nonce, now, }: {
|
|
9
|
+
signer: ResolvedRequestSigning;
|
|
10
|
+
environmentId: string;
|
|
11
|
+
request: SignableRequest;
|
|
12
|
+
nonce: string;
|
|
13
|
+
now?: number;
|
|
14
|
+
}) => Promise<string>;
|
|
15
|
+
//# sourceMappingURL=proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof.d.ts","sourceRoot":"","sources":["../../src/requestSigning/proof.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,eAAO,MAAM,4BAA4B,gCAAgC,CAAC;AAC1E,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,yBAAyB,CAAC;AAI5D,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAI1C,yGAAyG;AACzG,eAAO,MAAM,iBAAiB,oDAM3B;IACD,MAAM,EAAE,sBAAsB,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,eAAe,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,KAAG,OAAO,CAAC,MAAM,CAed,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type JsonWebKey, type KeyObject } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* A server's registered signing key. `sign` is ECDSA P-256 over SHA-256 of `bytes` (the signer hashes), returning
|
|
4
|
+
* raw 64-byte `r || s`: what WebCrypto ECDSA/SHA-256 or KMS ECDSA_SHA_256 produce. Low-S is applied by the SDK.
|
|
5
|
+
*/
|
|
6
|
+
export interface RequestSigning {
|
|
7
|
+
/** The registered P-256 public key, SEC1 hex (compressed or uncompressed). */
|
|
8
|
+
publicKey: string;
|
|
9
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A signer, or an in-memory P-256 key pair (which the SDK wraps in a low-S signer). With `apiToken` set the client
|
|
13
|
+
* is authenticated at construction, so `authenticateApiToken` need not be called.
|
|
14
|
+
*/
|
|
15
|
+
export type RequestSigningOption = (RequestSigning | {
|
|
16
|
+
publicKey: string;
|
|
17
|
+
privateKey: KeyObject | string | JsonWebKey;
|
|
18
|
+
}) & {
|
|
19
|
+
apiToken?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Looks up the per-wallet key a wallet answers to besides the signing proof (the `walletApiKey` decrypted from
|
|
22
|
+
* its creation webhook). Called with the wallet id of each wallet-scoped request; return undefined to send none.
|
|
23
|
+
*/
|
|
24
|
+
walletApiKey?: (walletId: string) => string | undefined | Promise<string | undefined>;
|
|
25
|
+
};
|
|
26
|
+
export interface ResolvedRequestSigning extends RequestSigning {
|
|
27
|
+
/** Thumbprint of the public key, as registered. */
|
|
28
|
+
kid: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Normalizes the `requestSigning` option. The `kid` comes from the public key (a KMS signer cannot derive
|
|
32
|
+
* it from the private key); an in-memory private key that is not the public key's pair fails here.
|
|
33
|
+
*/
|
|
34
|
+
export declare const resolveRequestSigning: (option: RequestSigningOption) => ResolvedRequestSigning;
|
|
35
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/requestSigning/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuD,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAInH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC9C;AAOD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAC/B,cAAc,GACd;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,GAAG,MAAM,GAAG,UAAU,CAAA;CAAE,CACrE,GAAG;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACvF,CAAC;AAEF,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;CACb;AASD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,WAAY,oBAAoB,KAAG,sBAQpE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type KeyObject } from 'node:crypto';
|
|
2
|
+
/** A P-256 public key as lowercase uncompressed SEC1 hex (`04 || x || y`), the form a registered key is sent in. */
|
|
3
|
+
export declare const publicKeyToHex: (publicKey: KeyObject) => string;
|
|
4
|
+
/** Parses a registered SEC1-hex P-256 public key (compressed or uncompressed) into its `kid`; off-curve points throw. */
|
|
5
|
+
export declare const parseRequestSigningKey: (publicKey: string) => {
|
|
6
|
+
publicKeyHex: string;
|
|
7
|
+
kid: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=signingKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signingKey.d.ts","sourceRoot":"","sources":["../../src/requestSigning/signingKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAO9D,oHAAoH;AACpH,eAAO,MAAM,cAAc,cAAe,SAAS,KAAG,MACuB,CAAC;AAE9E,yHAAyH;AACzH,eAAO,MAAM,sBAAsB,cAAe,MAAM,KAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAQ7F,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { JsonWebKey } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Generates a P-256 session key pair for the signed-session flow.
|
|
4
|
+
*
|
|
5
|
+
* Returns the compressed public-key hex (bind it into the Dynamic JWT via the
|
|
6
|
+
* `x-dyn-session-public-key` header when you sign in) and the private JWK.
|
|
7
|
+
*
|
|
8
|
+
* Stateless and custody-agnostic: the SDK does NOT persist the key. YOU store
|
|
9
|
+
* `privateKeyJwk` wherever you keep secrets. The returned JWK is extractable
|
|
10
|
+
* (so it can be handed back to you) and is therefore a convenience path, not a
|
|
11
|
+
* security boundary — if you need a non-extractable key (so a host/operator
|
|
12
|
+
* cannot exfiltrate it), generate it in a KMS/HSM/enclave instead and supply a
|
|
13
|
+
* `getSessionSignature` that signs there.
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateSessionKeyPair(): Promise<{
|
|
16
|
+
publicKeyHex: string;
|
|
17
|
+
privateKeyJwk: JsonWebKey;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Signs a message with a P-256 session private JWK using the exact encoding the
|
|
21
|
+
* keyshares relay expects: ECDSA P-256 / SHA-256 over UTF-8(message), raw r‖s
|
|
22
|
+
* (64 bytes), lowercase hex. Use it to implement `getSessionSignature`:
|
|
23
|
+
* getSessionSignature: (message) => signSessionMessage(message, privateKeyJwk)
|
|
24
|
+
* The JWK is imported non-extractable for signing.
|
|
25
|
+
*/
|
|
26
|
+
export declare function signSessionMessage(message: string, privateKeyJwk: JsonWebKey): Promise<string>;
|
|
27
|
+
//# sourceMappingURL=sessionKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionKeys.d.ts","sourceRoot":"","sources":["../../packages/src/sessionKeys.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAgB9C;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,UAAU,CAAA;CAAE,CAAC,CAM3G;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAIpG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SignMessageContext, SignMessageRawSign } from '@dynamic-labs-wallet/core';
|
|
2
|
+
export declare const ERROR_RAW_SIGN_CONTEXT_REQUIRED = "Raw digest signing requires a rawSign pre-image ({ payload, hashFunction }) or an explicit context. A bare digest carries no policy meaning, so a policy-enabled wallet rejects it with missing_context.";
|
|
3
|
+
/**
|
|
4
|
+
* Pre-image a raw digest is derived from: the signed digest must equal
|
|
5
|
+
* `hashFunction(prefix ‖ payload)`, which is what binds a chain-agnostic raw
|
|
6
|
+
* sign to something policy can evaluate.
|
|
7
|
+
*/
|
|
8
|
+
export type RawSignPreImage = SignMessageRawSign;
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the signing context for a raw (already-hashed) message. An explicit
|
|
11
|
+
* `context` always wins; otherwise the `rawSign` pre-image is turned into a
|
|
12
|
+
* `rawSign` context. Throws when neither is available rather than sending a
|
|
13
|
+
* context-less request the server can only reject.
|
|
14
|
+
*/
|
|
15
|
+
export declare const resolveRawSignContext: (context: SignMessageContext | undefined, rawSign: RawSignPreImage | undefined) => SignMessageContext;
|
|
16
|
+
export { SignMessageRawSignHashFunctionEnum } from '@dynamic-labs/sdk-api-core';
|
|
17
|
+
//# sourceMappingURL=signingContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signingContext.d.ts","sourceRoot":"","sources":["../../packages/src/signingContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAExF,eAAO,MAAM,+BAA+B,6MACgK,CAAC;AAE7M;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,YACvB,kBAAkB,GAAG,SAAS,WAC9B,eAAe,GAAG,SAAS,KACnC,kBAoBF,CAAC;AAEF,OAAO,EAAE,kCAAkC,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface SiweMessageParams {
|
|
2
|
+
domain: string;
|
|
3
|
+
address: string;
|
|
4
|
+
uri: string;
|
|
5
|
+
/** EVM-specific; omitted from the message when absent (e.g. Solana). */
|
|
6
|
+
chainId?: number;
|
|
7
|
+
nonce: string;
|
|
8
|
+
statement?: string;
|
|
9
|
+
issuedAt?: string;
|
|
10
|
+
/** Chain the account lives on, per the JS SDK's chain-generic formatter. Default 'Ethereum'. */
|
|
11
|
+
blockchainName?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Formats an EIP-4361-style sign-in message in the exact shape Dynamic's verifier accepts. */
|
|
14
|
+
export declare function formatSiweMessage(params: SiweMessageParams): string;
|
|
15
|
+
/** Throws unless `address` is a 0x-prefixed 20-byte hex EVM address. SIWS adds a base58 sibling. */
|
|
16
|
+
export declare function assertEvmAddress(address: string): void;
|
|
17
|
+
/** Resolves which origin a SIWE sign-in presents as. Throws before any network call. */
|
|
18
|
+
export declare function resolveSiweOrigin(appOrigin: string | undefined, params: {
|
|
19
|
+
domain?: string;
|
|
20
|
+
uri?: string;
|
|
21
|
+
}): {
|
|
22
|
+
domain: string;
|
|
23
|
+
uri: string;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=siweUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siweUtils.d.ts","sourceRoot":"","sources":["../../packages/src/siweUtils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAYnE;AAED,oGAAoG;AACpG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAItD;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAYjC"}
|
package/src/types.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { ThresholdSignatureScheme, KeyShareBackupInfo, ILogger } from '@dynamic-labs-wallet/core';
|
|
1
|
+
import type { EncryptedWalletApiKey, ThresholdSignatureScheme, KeyShareBackupInfo, ILogger, ShareSet, ShareSetType } from '@dynamic-labs-wallet/core';
|
|
2
2
|
import type { ForwardMPCClientV2 } from '@dynamic-labs-wallet/forward-mpc-client';
|
|
3
3
|
import type { ServerKeyShare } from './mpc/types.js';
|
|
4
|
+
import type { RequestSigningOption } from './requestSigning/index.js';
|
|
4
5
|
export interface DynamicWalletClientProps {
|
|
5
6
|
environmentId: string;
|
|
6
7
|
baseApiUrl?: string;
|
|
7
8
|
baseMPCRelayApiUrl?: string;
|
|
9
|
+
/** Client key share service base URL; defaults to the one for the environment `baseApiUrl` resolves to. */
|
|
10
|
+
baseClientKeysharesRelayApiUrl?: string;
|
|
8
11
|
/**
|
|
9
12
|
* Enables verbose debug-level logging when `true`.
|
|
10
13
|
*
|
|
@@ -27,6 +30,27 @@ export interface DynamicWalletClientProps {
|
|
|
27
30
|
* When omitted, a built-in logger is used with verbosity controlled by `debug`.
|
|
28
31
|
*/
|
|
29
32
|
logger?: ILogger;
|
|
33
|
+
/**
|
|
34
|
+
* Forwards error-level logs to Dynamic's log-ingestion endpoint so WaaS
|
|
35
|
+
* errors from your server are visible to Dynamic support without you
|
|
36
|
+
* needing your own Datadog account. Applies on top of whichever logger
|
|
37
|
+
* (default or custom) you're using; set `false` to disable entirely.
|
|
38
|
+
*
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
errorLogging?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The server's registered signing key. With it set, no `authenticate` call is
|
|
44
|
+
* made: every API request carries the DYN token plus a proof signed by this
|
|
45
|
+
* key. Pass `{ publicKey, privateKey }` for an in-memory P-256 key, or
|
|
46
|
+
* `{ publicKey, sign }` for a KMS/HSM/enclave signer (raw 64-byte low-S r‖s
|
|
47
|
+
* over SHA-256 of the bytes). Add `apiToken` to authenticate at construction;
|
|
48
|
+
* otherwise call `authenticateApiToken`.
|
|
49
|
+
*/
|
|
50
|
+
requestSigning?: RequestSigningOption;
|
|
51
|
+
}
|
|
52
|
+
export interface WalletApiKeyCreationResult {
|
|
53
|
+
encryptedWalletApiKey?: EncryptedWalletApiKey;
|
|
30
54
|
}
|
|
31
55
|
export interface WalletProperties {
|
|
32
56
|
chainName: string;
|
|
@@ -36,6 +60,34 @@ export interface WalletProperties {
|
|
|
36
60
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
37
61
|
derivationPath?: string;
|
|
38
62
|
addressType?: string;
|
|
39
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Per-share pointer metadata. Populated when the source provides key-share
|
|
65
|
+
* pointers, including the signer-scoped `getWaasWalletByAddress` response.
|
|
66
|
+
*/
|
|
67
|
+
externalServerKeySharesBackupInfo?: KeyShareBackupInfo;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Non-sensitive wallet metadata, safe to cache in Redis / Postgres / any
|
|
71
|
+
* normal datastore. Pair with `ServerKeyShare[]` (sensitive — secure store)
|
|
72
|
+
* to perform signing, export, or reshare operations.
|
|
73
|
+
*
|
|
74
|
+
* `externalServerKeySharesBackupInfo` carries the per-share pointer metadata
|
|
75
|
+
* the SDK needs to drive recovery (wallet operations that depend on backup
|
|
76
|
+
* state). It is technically optional on the type for serialization
|
|
77
|
+
* convenience. Operations that need it use the signer-scoped wallet lookup
|
|
78
|
+
* when the cached value is missing. Persist refreshed `backupInfo` after
|
|
79
|
+
* refresh, reshare, or updatePassword before re-caching.
|
|
80
|
+
*/
|
|
81
|
+
export interface WalletMetadata {
|
|
82
|
+
walletId: string;
|
|
83
|
+
accountAddress: string;
|
|
84
|
+
chainName: string;
|
|
85
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
86
|
+
derivationPath?: string;
|
|
87
|
+
addressType?: string;
|
|
88
|
+
externalServerKeySharesBackupInfo?: KeyShareBackupInfo;
|
|
89
|
+
shareSetId?: string;
|
|
90
|
+
shareSetType?: ShareSetType;
|
|
91
|
+
otherShareSets?: ShareSet[];
|
|
40
92
|
}
|
|
41
93
|
//# sourceMappingURL=types.d.ts.map
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../packages/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../packages/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,OAAO,EACP,QAAQ,EACR,YAAY,EACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAA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E,MAAM,CAAC;IAMpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAK5B,cAAc,CAAC,EAAE,QAAQ,EAAE,CAAC;CAC7B"}
|
package/src/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MessageHash } from '#internal/node';
|
|
2
|
-
import {
|
|
2
|
+
import { BackupLocation, type KeyShareBackupInfo } from '@dynamic-labs-wallet/core';
|
|
3
3
|
import type { ServerKeyShare } from './mpc/types.js';
|
|
4
4
|
export declare const createLogError: (clientTag: string) => ({ message, error, context }: {
|
|
5
5
|
message: string;
|
|
@@ -19,8 +19,33 @@ export declare const ensureBase64Padding: (str: string) => string;
|
|
|
19
19
|
export declare const stripHexPrefix: (str: string) => string;
|
|
20
20
|
export declare const isHexString: (str: string) => boolean;
|
|
21
21
|
export declare const getExternalServerKeyShareBackupInfo: (params?: {
|
|
22
|
-
walletProperties:
|
|
22
|
+
walletProperties: {
|
|
23
|
+
keyShares?: Array<{
|
|
24
|
+
backupLocation: BackupLocation;
|
|
25
|
+
id: string;
|
|
26
|
+
keygenId?: string;
|
|
27
|
+
externalKeyShareId?: string;
|
|
28
|
+
passwordEncrypted?: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
23
31
|
}) => KeyShareBackupInfo;
|
|
32
|
+
/**
|
|
33
|
+
* Parses the `derivationPath` string carried by `walletMetadata` into the
|
|
34
|
+
* `Uint32Array` the MPC signers expect.
|
|
35
|
+
*
|
|
36
|
+
* The encoding is a JSON-serialized index map — `{"0":44,"1":60,"2":0,"3":0,"4":0}`
|
|
37
|
+
* — and `Object.values` also flattens the equivalent JSON array form. This is the
|
|
38
|
+
* convention already used to read `walletMetadata.derivationPath` and by
|
|
39
|
+
* `getAddressTypeFromDerivationPath`.
|
|
40
|
+
*
|
|
41
|
+
* A BIP-32 path (`"m/44'/60'/0'/0/0"`) is **not** accepted. It is called out
|
|
42
|
+
* explicitly because `offlineExportKey` previously used this string only as an
|
|
43
|
+
* on/off flag and always derived at the chain default, so a BIP-32 path was
|
|
44
|
+
* silently tolerated while producing a key for the wrong path. Failing loudly with
|
|
45
|
+
* the expected shape beats a bare `SyntaxError`, and beats returning the wrong
|
|
46
|
+
* private key.
|
|
47
|
+
*/
|
|
48
|
+
export declare const parseIndexMapDerivationPath: (derivationPath?: string) => Uint32Array | undefined;
|
|
24
49
|
/**
|
|
25
50
|
* Helper function to merge keyshares and remove duplicates based on pubkey and secretShare
|
|
26
51
|
* @param existingKeyShares - Array of existing keyshares
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,cAAc,EAEd,KAAK,kBAAkB,EAIxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,eAAO,MAAM,cAAc,cACb,MAAM,mCACY;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,KAAG,IAClD,CAAC;AAErD,eAAO,MAAM,QAAQ,4CAKlB;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,KAAG,IAiBH,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,UAAU,WAE5C,CAAC;AAEF,eAAO,MA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