@prism-ing/wallet 0.1.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.
Files changed (113) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +596 -0
  4. package/SPEC.md +192 -0
  5. package/dist/backends/squads-recovery-backend.d.ts +59 -0
  6. package/dist/backends/squads-recovery-backend.d.ts.map +1 -0
  7. package/dist/backends/squads-recovery-backend.js +81 -0
  8. package/dist/backends/squads-recovery-backend.js.map +1 -0
  9. package/dist/backends/squads-types.d.ts +74 -0
  10. package/dist/backends/squads-types.d.ts.map +1 -0
  11. package/dist/backends/squads-types.js +22 -0
  12. package/dist/backends/squads-types.js.map +1 -0
  13. package/dist/backends/zerodev-policy-mapper.d.ts +41 -0
  14. package/dist/backends/zerodev-policy-mapper.d.ts.map +1 -0
  15. package/dist/backends/zerodev-policy-mapper.js +127 -0
  16. package/dist/backends/zerodev-policy-mapper.js.map +1 -0
  17. package/dist/backends/zerodev-session-backend.d.ts +43 -0
  18. package/dist/backends/zerodev-session-backend.d.ts.map +1 -0
  19. package/dist/backends/zerodev-session-backend.js +63 -0
  20. package/dist/backends/zerodev-session-backend.js.map +1 -0
  21. package/dist/backends/zerodev-types.d.ts +104 -0
  22. package/dist/backends/zerodev-types.d.ts.map +1 -0
  23. package/dist/backends/zerodev-types.js +13 -0
  24. package/dist/backends/zerodev-types.js.map +1 -0
  25. package/dist/create-wallet.d.ts +89 -0
  26. package/dist/create-wallet.d.ts.map +1 -0
  27. package/dist/create-wallet.js +235 -0
  28. package/dist/create-wallet.js.map +1 -0
  29. package/dist/cross-chain.d.ts +64 -0
  30. package/dist/cross-chain.d.ts.map +1 -0
  31. package/dist/cross-chain.js +200 -0
  32. package/dist/cross-chain.js.map +1 -0
  33. package/dist/errors.d.ts +115 -0
  34. package/dist/errors.d.ts.map +1 -0
  35. package/dist/errors.js +97 -0
  36. package/dist/errors.js.map +1 -0
  37. package/dist/index.d.ts +55 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +52 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/internal/base58.d.ts +8 -0
  42. package/dist/internal/base58.d.ts.map +1 -0
  43. package/dist/internal/base58.js +34 -0
  44. package/dist/internal/base58.js.map +1 -0
  45. package/dist/internal/eip712.d.ts +41 -0
  46. package/dist/internal/eip712.d.ts.map +1 -0
  47. package/dist/internal/eip712.js +182 -0
  48. package/dist/internal/eip712.js.map +1 -0
  49. package/dist/internal/file-spend-persistence.d.ts +9 -0
  50. package/dist/internal/file-spend-persistence.d.ts.map +1 -0
  51. package/dist/internal/file-spend-persistence.js +58 -0
  52. package/dist/internal/file-spend-persistence.js.map +1 -0
  53. package/dist/internal/onebalance-client.d.ts +59 -0
  54. package/dist/internal/onebalance-client.d.ts.map +1 -0
  55. package/dist/internal/onebalance-client.js +2 -0
  56. package/dist/internal/onebalance-client.js.map +1 -0
  57. package/dist/internal/onebalance-http-client.d.ts +25 -0
  58. package/dist/internal/onebalance-http-client.d.ts.map +1 -0
  59. package/dist/internal/onebalance-http-client.js +161 -0
  60. package/dist/internal/onebalance-http-client.js.map +1 -0
  61. package/dist/internal/onebalance-types.d.ts +201 -0
  62. package/dist/internal/onebalance-types.d.ts.map +1 -0
  63. package/dist/internal/onebalance-types.js +39 -0
  64. package/dist/internal/onebalance-types.js.map +1 -0
  65. package/dist/internal/platform.d.ts +14 -0
  66. package/dist/internal/platform.d.ts.map +1 -0
  67. package/dist/internal/platform.js +22 -0
  68. package/dist/internal/platform.js.map +1 -0
  69. package/dist/internal/quote-verifier.d.ts +71 -0
  70. package/dist/internal/quote-verifier.d.ts.map +1 -0
  71. package/dist/internal/quote-verifier.js +172 -0
  72. package/dist/internal/quote-verifier.js.map +1 -0
  73. package/dist/internal/recovery-manager.d.ts +29 -0
  74. package/dist/internal/recovery-manager.d.ts.map +1 -0
  75. package/dist/internal/recovery-manager.js +161 -0
  76. package/dist/internal/recovery-manager.js.map +1 -0
  77. package/dist/result.d.ts +132 -0
  78. package/dist/result.d.ts.map +1 -0
  79. package/dist/result.js +114 -0
  80. package/dist/result.js.map +1 -0
  81. package/dist/schemas.d.ts +184 -0
  82. package/dist/schemas.d.ts.map +1 -0
  83. package/dist/schemas.js +76 -0
  84. package/dist/schemas.js.map +1 -0
  85. package/dist/session-keys.d.ts +53 -0
  86. package/dist/session-keys.d.ts.map +1 -0
  87. package/dist/session-keys.js +345 -0
  88. package/dist/session-keys.js.map +1 -0
  89. package/dist/signers/node-signing-backend.d.ts +11 -0
  90. package/dist/signers/node-signing-backend.d.ts.map +1 -0
  91. package/dist/signers/node-signing-backend.js +120 -0
  92. package/dist/signers/node-signing-backend.js.map +1 -0
  93. package/dist/signers/ows-adapter.d.ts +70 -0
  94. package/dist/signers/ows-adapter.d.ts.map +1 -0
  95. package/dist/signers/ows-adapter.js +53 -0
  96. package/dist/signers/ows-adapter.js.map +1 -0
  97. package/dist/signers/ows-signing-backend.d.ts +25 -0
  98. package/dist/signers/ows-signing-backend.d.ts.map +1 -0
  99. package/dist/signers/ows-signing-backend.js +192 -0
  100. package/dist/signers/ows-signing-backend.js.map +1 -0
  101. package/dist/signers/secure-enclave-backend.d.ts +19 -0
  102. package/dist/signers/secure-enclave-backend.d.ts.map +1 -0
  103. package/dist/signers/secure-enclave-backend.js +201 -0
  104. package/dist/signers/secure-enclave-backend.js.map +1 -0
  105. package/dist/signers/secure-enclave-types.d.ts +98 -0
  106. package/dist/signers/secure-enclave-types.d.ts.map +1 -0
  107. package/dist/signers/secure-enclave-types.js +12 -0
  108. package/dist/signers/secure-enclave-types.js.map +1 -0
  109. package/dist/types.d.ts +371 -0
  110. package/dist/types.d.ts.map +1 -0
  111. package/dist/types.js +2 -0
  112. package/dist/types.js.map +1 -0
  113. package/package.json +85 -0
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Recovery manager — rotates the smart contract's authorized signer.
3
+ *
4
+ * @remarks
5
+ * Never touches private keys. EVM recovery uses ZeroDev Social Recovery
6
+ * (removeValidator(old) + addValidator(new)). Solana recovery uses Squads V4
7
+ * (multisigAddMember(new) + multisigRemoveMember(old)).
8
+ *
9
+ * Both on-chain backends are injected via {@link RecoveryBackends} so
10
+ * that the wallet package itself carries no runtime dependency on
11
+ * `@zerodev/sdk` or `@sqds/multisig`.
12
+ *
13
+ * @internal
14
+ */
15
+ import { bytesToHex, concatBytes } from '@noble/hashes/utils';
16
+ import { keccak_256 } from '@noble/hashes/sha3';
17
+ import { toAddress } from '../result.js';
18
+ import { walletErrors } from '../errors.js';
19
+ const textEncoder = new TextEncoder();
20
+ const RECOVERY_DOMAIN_TAG = textEncoder.encode('prism-recovery-v1');
21
+ // ---------------------------------------------------------------------------
22
+ // Factory
23
+ // ---------------------------------------------------------------------------
24
+ /**
25
+ * Create a recovery manager for the given wallet signer.
26
+ *
27
+ * @param currentSignerEvmAddress - The EVM address of the current authorized signer.
28
+ * @param currentSignerSolanaAddress - The Solana address of the current authorized signer.
29
+ * @param backends - Injected on-chain recovery backends.
30
+ * @returns A fully-wired {@link RecoveryManager}.
31
+ *
32
+ * @internal
33
+ */
34
+ export function createRecoveryManager(currentSignerEvmAddress, currentSignerSolanaAddress, backends) {
35
+ let passkeyCredentialId;
36
+ const manager = {
37
+ async setupPasskey() {
38
+ if (backends.passkey === undefined) {
39
+ throw toWalletErrorException(walletErrors.enclaveUnavailable('passkey'));
40
+ }
41
+ const credential = await backends.passkey.register('prism.xyz');
42
+ passkeyCredentialId = credential.id;
43
+ if (backends.evm !== undefined) {
44
+ // Derive a temporary guardian address from passkey pubkey bytes
45
+ const passkeyGuardianAddress = deriveAddressFromPasskey(credential.publicKey);
46
+ await backends.evm.addGuardian(passkeyGuardianAddress);
47
+ }
48
+ return { id: credential.id, type: 'passkey' };
49
+ },
50
+ async addDeviceGuardian(deviceEvmAddress, deviceSolanaAddress) {
51
+ if (backends.evm !== undefined) {
52
+ await backends.evm.addGuardian(deviceEvmAddress);
53
+ }
54
+ if (backends.solana !== undefined) {
55
+ await backends.solana.addMember(deviceSolanaAddress);
56
+ }
57
+ },
58
+ async addContactGuardian(ethAddress) {
59
+ if (backends.evm === undefined) {
60
+ throw toWalletErrorException(walletErrors.recoveryGuardianInvalid(ethAddress, 'EVM recovery backend not configured'));
61
+ }
62
+ await backends.evm.addGuardian(ethAddress);
63
+ },
64
+ async initiateRecovery(newSigner) {
65
+ // Generate guardian proof with dynamic challenge (prevents replay attacks)
66
+ const guardianProof = await getGuardianProof(backends, passkeyCredentialId, currentSignerEvmAddress, newSigner.evmAddress);
67
+ // Reject recovery when no backends can verify the proof.
68
+ // If EVM or Solana backends are present, they handle proof validation.
69
+ // If only a passkey backend exists but no proof was obtained, reject.
70
+ const hasRecoveryBackend = backends.evm !== undefined || backends.solana !== undefined;
71
+ if (guardianProof.length === 0 && !hasRecoveryBackend) {
72
+ throw toWalletErrorException(walletErrors.recoveryGuardianInvalid(newSigner.evmAddress, 'No guardian proof available and no recovery backends configured. Set up a passkey, device, or contact guardian before initiating recovery.'));
73
+ }
74
+ // Rotate EVM signer
75
+ let evmTxId = '';
76
+ if (backends.evm !== undefined) {
77
+ evmTxId = await backends.evm.rotateValidator(currentSignerEvmAddress, newSigner.evmAddress, guardianProof);
78
+ }
79
+ // Rotate Solana signer
80
+ let solanaTxId = '';
81
+ if (backends.solana !== undefined) {
82
+ solanaTxId = await backends.solana.rotateMember(currentSignerSolanaAddress, newSigner.solanaAddress, guardianProof);
83
+ }
84
+ return {
85
+ recoveryId: evmTxId || solanaTxId || 'recovery-pending',
86
+ status: 'pending',
87
+ newEvmAddress: newSigner.evmAddress,
88
+ newSolanaAddress: newSigner.solanaAddress,
89
+ };
90
+ },
91
+ };
92
+ return manager;
93
+ }
94
+ // ---------------------------------------------------------------------------
95
+ // Helpers
96
+ // ---------------------------------------------------------------------------
97
+ /**
98
+ * Derive a deterministic EVM address from a passkey public key.
99
+ * Hashes the public key with keccak256 and takes the last 20 bytes,
100
+ * matching standard Ethereum address derivation from a public key.
101
+ *
102
+ * @internal
103
+ */
104
+ function deriveAddressFromPasskey(publicKey) {
105
+ const hash = keccak_256(publicKey);
106
+ const raw = `0x${bytesToHex(hash.slice(12))}`;
107
+ // Safe to use value directly — keccak256 output always produces valid 20-byte addresses
108
+ const result = toAddress(raw);
109
+ if (!result.ok) {
110
+ throw new Error(`Invalid derived address: ${raw}`);
111
+ }
112
+ return result.value;
113
+ }
114
+ /**
115
+ * Build a dynamic recovery challenge that binds to the specific recovery operation.
116
+ *
117
+ * @remarks
118
+ * The challenge includes:
119
+ * - A domain tag ("prism-recovery-v1") to prevent cross-protocol replay
120
+ * - The current signer address being rotated away
121
+ * - The new signer address being rotated to
122
+ * - A timestamp to prevent replay of old proofs
123
+ *
124
+ * This is hashed with keccak256 to produce a fixed-size challenge.
125
+ *
126
+ * @internal
127
+ */
128
+ export function buildRecoveryChallenge(currentSigner, newSigner) {
129
+ const currentBytes = textEncoder.encode(currentSigner);
130
+ const newBytes = textEncoder.encode(newSigner);
131
+ // Quantize timestamp to 5-minute windows to allow for clock drift
132
+ // while still preventing replay beyond that window
133
+ const timestampWindow = Math.floor(Date.now() / (5 * 60 * 1000));
134
+ const timestampBytes = textEncoder.encode(String(timestampWindow));
135
+ return keccak_256(concatBytes(RECOVERY_DOMAIN_TAG, currentBytes, newBytes, timestampBytes));
136
+ }
137
+ /**
138
+ * Obtain a guardian proof for recovery.
139
+ * If a passkey was registered, signs a dynamic recovery challenge.
140
+ * Otherwise returns an empty proof (for testing or when guardian
141
+ * approval happens out-of-band).
142
+ */
143
+ async function getGuardianProof(backends, passkeyCredentialId, currentSigner, newSigner) {
144
+ if (backends.passkey !== undefined && passkeyCredentialId !== undefined) {
145
+ const challenge = buildRecoveryChallenge(currentSigner, newSigner);
146
+ return backends.passkey.sign(passkeyCredentialId, challenge);
147
+ }
148
+ // No passkey — return empty proof (guardian approval via other mechanism)
149
+ return new Uint8Array(0);
150
+ }
151
+ /**
152
+ * Convert a WalletError to an exception for throwing at the boundary.
153
+ * RecoveryManager methods throw because the interface uses bare Promises,
154
+ * not Result types.
155
+ */
156
+ function toWalletErrorException(error) {
157
+ const err = new Error(error.code);
158
+ err.walletError = error;
159
+ return err;
160
+ }
161
+ //# sourceMappingURL=recovery-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recovery-manager.js","sourceRoot":"","sources":["../../src/internal/recovery-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,MAAM,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAEpE,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CACnC,uBAAgC,EAChC,0BAAkC,EAClC,QAA0B;IAE1B,IAAI,mBAAuC,CAAC;IAE5C,MAAM,OAAO,GAAoB;QAC/B,KAAK,CAAC,YAAY;YAChB,IAAI,QAAQ,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBACnC,MAAM,sBAAsB,CAC1B,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAC3C,CAAC;YACJ,CAAC;YAED,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAChE,mBAAmB,GAAG,UAAU,CAAC,EAAE,CAAC;YAEpC,IAAI,QAAQ,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;gBAC/B,gEAAgE;gBAChE,MAAM,sBAAsB,GAAG,wBAAwB,CACrD,UAAU,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G,CAAC;AACb,CAAC"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Core Result type and branded primitives for `@prism-ing/wallet`.
3
+ *
4
+ * @remarks
5
+ * Every function that can fail returns `Result<T, E>` instead of throwing.
6
+ * Branded types enforce domain safety at compile time — construct once via
7
+ * `toAddress()` / `toHex()` etc., then trust downstream.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ /**
12
+ * Base error type for all Prism packages.
13
+ * Each package extends this with its own error codes.
14
+ */
15
+ export type PrismError = {
16
+ readonly code: string;
17
+ readonly message?: string;
18
+ readonly cause?: unknown;
19
+ };
20
+ /**
21
+ * A discriminated union representing success or failure.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const result = await createWallet(config, deps);
26
+ * if (!result.ok) {
27
+ * console.error(result.error.code);
28
+ * return;
29
+ * }
30
+ * // result.value is narrowed here
31
+ * ```
32
+ */
33
+ export type Result<T, E = PrismError> = {
34
+ readonly ok: true;
35
+ readonly value: T;
36
+ } | {
37
+ readonly ok: false;
38
+ readonly error: E;
39
+ };
40
+ /** Construct a successful Result. */
41
+ export declare const Ok: <T>(value: T) => Result<T, never>;
42
+ /** Construct a failed Result. */
43
+ export declare const Err: <E>(error: E) => Result<never, E>;
44
+ /**
45
+ * Map over a successful Result, leaving errors untouched.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const doubled = mapResult(getAmount(), (n) => n * 2n);
50
+ * ```
51
+ */
52
+ export declare const mapResult: <T, U, E>(result: Result<T, E>, fn: (value: T) => U) => Result<U, E>;
53
+ /**
54
+ * Chain Results — flatMap for the Result type.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const result = flatMapResult(
59
+ * parseAddress(raw),
60
+ * (addr) => getBalance(addr),
61
+ * );
62
+ * ```
63
+ */
64
+ export declare const flatMapResult: <T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>) => Result<U, E>;
65
+ /**
66
+ * Unwrap a Result or throw. Only use at the outermost boundary
67
+ * (CLI entry point, HTTP handler). Never in business logic.
68
+ */
69
+ export declare const unwrapResult: <T>(result: Result<T>) => T;
70
+ /**
71
+ * Wrap a Promise that might reject into a Result.
72
+ * Use at the boundary when calling third-party code that throws.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const result = await fromPromise(
77
+ * fetch(url),
78
+ * (e) => ({ code: 'NETWORK_ERROR' as const, cause: String(e) }),
79
+ * );
80
+ * ```
81
+ */
82
+ export declare const fromPromise: <T, E>(promise: Promise<T>, mapError: (error: unknown) => E) => Promise<Result<T, E>>;
83
+ /** An EVM address (0x-prefixed, 42 chars). */
84
+ export type Address = string & {
85
+ readonly __brand: 'Address';
86
+ };
87
+ /** A hex-encoded string (0x-prefixed). */
88
+ export type Hex = string & {
89
+ readonly __brand: 'Hex';
90
+ };
91
+ /** A Solana public key (base58-encoded). */
92
+ export type SolanaPublicKey = string & {
93
+ readonly __brand: 'SolanaPublicKey';
94
+ };
95
+ /** Basis points (0–10000). */
96
+ export type Bps = number & {
97
+ readonly __brand: 'Bps';
98
+ };
99
+ /** Lamports (Solana's smallest unit). */
100
+ export type Lamports = bigint & {
101
+ readonly __brand: 'Lamports';
102
+ };
103
+ /** Brand validation error. */
104
+ export type BrandError = {
105
+ readonly code: 'INVALID_ADDRESS' | 'INVALID_HEX' | 'INVALID_SOLANA_PUBKEY' | 'INVALID_BPS' | 'INVALID_LAMPORTS';
106
+ readonly raw: string;
107
+ };
108
+ /** Parse a raw string into a branded {@link Address}. */
109
+ export declare const toAddress: (raw: string) => Result<Address, BrandError>;
110
+ /** Parse a raw string into a branded {@link Hex}. */
111
+ export declare const toHex: (raw: string) => Result<Hex, BrandError>;
112
+ /** Parse a raw string into a branded {@link SolanaPublicKey}. */
113
+ export declare const toSolanaPublicKey: (raw: string) => Result<SolanaPublicKey, BrandError>;
114
+ /** Parse a raw number into branded {@link Bps}. */
115
+ export declare const toBps: (raw: number) => Result<Bps, BrandError>;
116
+ /** Parse a raw bigint into branded {@link Lamports}. */
117
+ export declare const toLamports: (raw: bigint) => Result<Lamports, BrandError>;
118
+ /**
119
+ * Assert that a code path is unreachable.
120
+ * Use in the default branch of switch/if chains on discriminated unions.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * switch (action.type) {
125
+ * case 'deposit': return handleDeposit(action);
126
+ * case 'withdraw': return handleWithdraw(action);
127
+ * default: return assertNever(action.type);
128
+ * }
129
+ * ```
130
+ */
131
+ export declare const assertNever: (value: never) => never;
132
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,UAAU,IAChC;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAE9C,qCAAqC;AACrC,eAAO,MAAM,EAAE,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAG9C,CAAC;AAEH,iCAAiC;AACjC,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAG/C,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC/B,QAAQ,MAAM,CAAC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IAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC;AAMjE,8BAA8B;AAC9B,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EACT,iBAAiB,GACjB,aAAa,GACb,uBAAuB,GACvB,aAAa,GACb,kBAAkB,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAMF,yDAAyD;AACzD,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,OAAO,EAAE,UAAU,CAGvB,CAAC;AAE5C,qDAAqD;AACrD,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,GAAG,EAAE,UAAU,CAGnB,CAAC;AAExC,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,GAC5B,KAAK,MAAM,KACV,MAAM,CAAC,eAAe,EAAE,UAAU,CAGY,CAAC;AAElD,mDAAmD;AACnD,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,GAAG,EAAE,UAAU,CAGN,CAAC;AAErD,wDAAwD;AACxD,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,QAAQ,EAAE,UAAU,CAGX,CAAC;AAM1D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,KAAK,KAAG,KAE1C,CAAC"}
package/dist/result.js ADDED
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Core Result type and branded primitives for `@prism-ing/wallet`.
3
+ *
4
+ * @remarks
5
+ * Every function that can fail returns `Result<T, E>` instead of throwing.
6
+ * Branded types enforce domain safety at compile time — construct once via
7
+ * `toAddress()` / `toHex()` etc., then trust downstream.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ /** Construct a successful Result. */
12
+ export const Ok = (value) => ({
13
+ ok: true,
14
+ value,
15
+ });
16
+ /** Construct a failed Result. */
17
+ export const Err = (error) => ({
18
+ ok: false,
19
+ error,
20
+ });
21
+ /**
22
+ * Map over a successful Result, leaving errors untouched.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const doubled = mapResult(getAmount(), (n) => n * 2n);
27
+ * ```
28
+ */
29
+ export const mapResult = (result, fn) => (result.ok ? Ok(fn(result.value)) : result);
30
+ /**
31
+ * Chain Results — flatMap for the Result type.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const result = flatMapResult(
36
+ * parseAddress(raw),
37
+ * (addr) => getBalance(addr),
38
+ * );
39
+ * ```
40
+ */
41
+ export const flatMapResult = (result, fn) => (result.ok ? fn(result.value) : result);
42
+ /**
43
+ * Unwrap a Result or throw. Only use at the outermost boundary
44
+ * (CLI entry point, HTTP handler). Never in business logic.
45
+ */
46
+ export const unwrapResult = (result) => {
47
+ if (result.ok)
48
+ return result.value;
49
+ throw new Error(`Unwrap called on Err: ${JSON.stringify(result.error)}`);
50
+ };
51
+ /**
52
+ * Wrap a Promise that might reject into a Result.
53
+ * Use at the boundary when calling third-party code that throws.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const result = await fromPromise(
58
+ * fetch(url),
59
+ * (e) => ({ code: 'NETWORK_ERROR' as const, cause: String(e) }),
60
+ * );
61
+ * ```
62
+ */
63
+ export const fromPromise = async (promise, mapError) => {
64
+ try {
65
+ const value = await promise;
66
+ return Ok(value);
67
+ }
68
+ catch (error) {
69
+ return Err(mapError(error));
70
+ }
71
+ };
72
+ const EVM_ADDRESS_RE = /^0x[a-fA-F0-9]{40}$/;
73
+ const HEX_RE = /^0x[a-fA-F0-9]*$/;
74
+ const BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
75
+ /** Parse a raw string into a branded {@link Address}. */
76
+ export const toAddress = (raw) => EVM_ADDRESS_RE.test(raw)
77
+ ? Ok(raw)
78
+ : Err({ code: 'INVALID_ADDRESS', raw });
79
+ /** Parse a raw string into a branded {@link Hex}. */
80
+ export const toHex = (raw) => HEX_RE.test(raw)
81
+ ? Ok(raw)
82
+ : Err({ code: 'INVALID_HEX', raw });
83
+ /** Parse a raw string into a branded {@link SolanaPublicKey}. */
84
+ export const toSolanaPublicKey = (raw) => BASE58_RE.test(raw)
85
+ ? Ok(raw)
86
+ : Err({ code: 'INVALID_SOLANA_PUBKEY', raw });
87
+ /** Parse a raw number into branded {@link Bps}. */
88
+ export const toBps = (raw) => Number.isInteger(raw) && raw >= 0 && raw <= 10_000
89
+ ? Ok(raw)
90
+ : Err({ code: 'INVALID_BPS', raw: String(raw) });
91
+ /** Parse a raw bigint into branded {@link Lamports}. */
92
+ export const toLamports = (raw) => raw >= 0n
93
+ ? Ok(raw)
94
+ : Err({ code: 'INVALID_LAMPORTS', raw: String(raw) });
95
+ // ---------------------------------------------------------------------------
96
+ // Exhaustiveness
97
+ // ---------------------------------------------------------------------------
98
+ /**
99
+ * Assert that a code path is unreachable.
100
+ * Use in the default branch of switch/if chains on discriminated unions.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * switch (action.type) {
105
+ * case 'deposit': return handleDeposit(action);
106
+ * case 'withdraw': return handleWithdraw(action);
107
+ * default: return assertNever(action.type);
108
+ * }
109
+ * ```
110
+ */
111
+ export const assertNever = (value) => {
112
+ throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
113
+ };
114
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiCH,qCAAqC;AACrC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAI,KAAQ,EAAoB,EAAE,CAAC,CAAC;IACpD,EAAE,EAAE,IAAI;IACR,KAAK;CACN,CAAC,CAAC;AAEH,iCAAiC;AACjC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAI,KAAQ,EAAoB,EAAE,CAAC,CAAC;IACrD,EAAE,EAAE,KAAK;IACT,KAAK;CACN,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,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D,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAY,EAAS,EAAE;IACjD,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC,CAAC"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Zod schemas for @prism-ing/wallet input validation.
3
+ *
4
+ * @remarks
5
+ * External data enters the system exactly once, through these schemas.
6
+ * After parsing, the inferred types are trusted everywhere downstream.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { z } from 'zod';
11
+ import type { Address } from './result.js';
12
+ /** Schema for an EVM address (0x-prefixed, 40 hex chars). */
13
+ export declare const AddressSchema: z.ZodType<Address>;
14
+ /** Schema for a Solana public key (base58, 32-44 chars). */
15
+ export declare const SolanaPublicKeySchema: z.ZodString;
16
+ /** Schema for a positive bigint amount. */
17
+ export declare const PositiveBigIntSchema: z.ZodEffects<z.ZodBigInt, bigint, bigint>;
18
+ /** Schema for basis points (0-10000). */
19
+ export declare const BpsSchema: z.ZodNumber;
20
+ export declare const SignerConfigSchema: z.ZodObject<{
21
+ walletName: z.ZodString;
22
+ passphrase: z.ZodOptional<z.ZodString>;
23
+ apiKey: z.ZodOptional<z.ZodString>;
24
+ vaultPath: z.ZodOptional<z.ZodString>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ walletName: string;
27
+ passphrase?: string | undefined;
28
+ apiKey?: string | undefined;
29
+ vaultPath?: string | undefined;
30
+ }, {
31
+ walletName: string;
32
+ passphrase?: string | undefined;
33
+ apiKey?: string | undefined;
34
+ vaultPath?: string | undefined;
35
+ }>;
36
+ export declare const RecoveryConfigSchema: z.ZodObject<{
37
+ evm: z.ZodOptional<z.ZodObject<{
38
+ guardians: z.ZodArray<z.ZodType<Address, z.ZodTypeDef, Address>, "many">;
39
+ threshold: z.ZodNumber;
40
+ }, "strip", z.ZodTypeAny, {
41
+ guardians: Address[];
42
+ threshold: number;
43
+ }, {
44
+ guardians: Address[];
45
+ threshold: number;
46
+ }>>;
47
+ }, "strip", z.ZodTypeAny, {
48
+ evm?: {
49
+ guardians: Address[];
50
+ threshold: number;
51
+ } | undefined;
52
+ }, {
53
+ evm?: {
54
+ guardians: Address[];
55
+ threshold: number;
56
+ } | undefined;
57
+ }>;
58
+ export declare const AccountTypeSchema: z.ZodLiteral<"kernel-v3.1-ecdsa">;
59
+ export declare const WalletConfigSchema: z.ZodObject<{
60
+ signer: z.ZodObject<{
61
+ walletName: z.ZodString;
62
+ passphrase: z.ZodOptional<z.ZodString>;
63
+ apiKey: z.ZodOptional<z.ZodString>;
64
+ vaultPath: z.ZodOptional<z.ZodString>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ walletName: string;
67
+ passphrase?: string | undefined;
68
+ apiKey?: string | undefined;
69
+ vaultPath?: string | undefined;
70
+ }, {
71
+ walletName: string;
72
+ passphrase?: string | undefined;
73
+ apiKey?: string | undefined;
74
+ vaultPath?: string | undefined;
75
+ }>;
76
+ oneBalanceApiKey: z.ZodString;
77
+ accountType: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"kernel-v3.1-ecdsa">>>;
78
+ chains: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
79
+ recovery: z.ZodOptional<z.ZodObject<{
80
+ evm: z.ZodOptional<z.ZodObject<{
81
+ guardians: z.ZodArray<z.ZodType<Address, z.ZodTypeDef, Address>, "many">;
82
+ threshold: z.ZodNumber;
83
+ }, "strip", z.ZodTypeAny, {
84
+ guardians: Address[];
85
+ threshold: number;
86
+ }, {
87
+ guardians: Address[];
88
+ threshold: number;
89
+ }>>;
90
+ }, "strip", z.ZodTypeAny, {
91
+ evm?: {
92
+ guardians: Address[];
93
+ threshold: number;
94
+ } | undefined;
95
+ }, {
96
+ evm?: {
97
+ guardians: Address[];
98
+ threshold: number;
99
+ } | undefined;
100
+ }>>;
101
+ }, "strip", z.ZodTypeAny, {
102
+ signer: {
103
+ walletName: string;
104
+ passphrase?: string | undefined;
105
+ apiKey?: string | undefined;
106
+ vaultPath?: string | undefined;
107
+ };
108
+ oneBalanceApiKey: string;
109
+ accountType: "kernel-v3.1-ecdsa";
110
+ chains?: number[] | undefined;
111
+ recovery?: {
112
+ evm?: {
113
+ guardians: Address[];
114
+ threshold: number;
115
+ } | undefined;
116
+ } | undefined;
117
+ }, {
118
+ signer: {
119
+ walletName: string;
120
+ passphrase?: string | undefined;
121
+ apiKey?: string | undefined;
122
+ vaultPath?: string | undefined;
123
+ };
124
+ oneBalanceApiKey: string;
125
+ accountType?: "kernel-v3.1-ecdsa" | undefined;
126
+ chains?: number[] | undefined;
127
+ recovery?: {
128
+ evm?: {
129
+ guardians: Address[];
130
+ threshold: number;
131
+ } | undefined;
132
+ } | undefined;
133
+ }>;
134
+ export declare const DepositParamsSchema: z.ZodObject<{
135
+ token: z.ZodType<Address, z.ZodTypeDef, Address>;
136
+ amount: z.ZodEffects<z.ZodBigInt, bigint, bigint>;
137
+ chainId: z.ZodNumber;
138
+ }, "strip", z.ZodTypeAny, {
139
+ chainId: number;
140
+ token: string & {
141
+ readonly __brand: "Address";
142
+ };
143
+ amount: bigint;
144
+ }, {
145
+ chainId: number;
146
+ token: string & {
147
+ readonly __brand: "Address";
148
+ };
149
+ amount: bigint;
150
+ }>;
151
+ export declare const CrossChainSwapParamsSchema: z.ZodObject<{
152
+ tokenIn: z.ZodType<Address, z.ZodTypeDef, Address>;
153
+ chainIn: z.ZodNumber;
154
+ tokenOut: z.ZodType<Address, z.ZodTypeDef, Address>;
155
+ chainOut: z.ZodNumber;
156
+ amount: z.ZodEffects<z.ZodBigInt, bigint, bigint>;
157
+ slippageBps: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
158
+ }, "strip", z.ZodTypeAny, {
159
+ amount: bigint;
160
+ tokenIn: string & {
161
+ readonly __brand: "Address";
162
+ };
163
+ chainIn: number;
164
+ tokenOut: string & {
165
+ readonly __brand: "Address";
166
+ };
167
+ chainOut: number;
168
+ slippageBps: number;
169
+ }, {
170
+ amount: bigint;
171
+ tokenIn: string & {
172
+ readonly __brand: "Address";
173
+ };
174
+ chainIn: number;
175
+ tokenOut: string & {
176
+ readonly __brand: "Address";
177
+ };
178
+ chainOut: number;
179
+ slippageBps?: number | undefined;
180
+ }>;
181
+ export type ParsedWalletConfig = z.infer<typeof WalletConfigSchema>;
182
+ export type ParsedDepositParams = z.infer<typeof DepositParamsSchema>;
183
+ export type ParsedCrossChainSwapParams = z.infer<typeof CrossChainSwapParamsSchema>;
184
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAM3C,6DAA6D;AAC7D,eAAO,MAAM,aAAa,EAKR,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAErC,4DAA4D;AAC5D,eAAO,MAAM,qBAAqB,aAEoC,CAAC;AAEvE,2CAA2C;AAC3C,eAAO,MAAM,oBAAoB,2CAEkB,CAAC;AAEpD,yCAAyC;AACzC,eAAO,MAAM,SAAS,aAIR,CAAC;AAMf,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAK7B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;EAO/B,CAAC;AAEH,eAAO,MAAM,iBAAiB,mCAAiC,CAAC;AAEhE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM7B,CAAC;AAMH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;EAI9B,CAAC;AAMH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOrC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}