wallaby-cash 3.22.0 → 4.0.0-rc.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 (110) hide show
  1. package/README.md +27 -27
  2. package/dist/api.cjs +1 -1
  3. package/dist/api.js +1 -1
  4. package/dist/api.mjs +1 -1
  5. package/dist/base.d.ts +11 -3
  6. package/dist/generated/api.d.ts +566 -1551
  7. package/dist/generated/validators.d.ts +4 -4
  8. package/dist/helpers/bytes.d.ts +2 -0
  9. package/dist/helpers/ed25519-hd.d.ts +11 -0
  10. package/dist/helpers/logger.d.ts +1 -1
  11. package/dist/helpers/pick.d.ts +1 -0
  12. package/dist/index.cjs +13 -11
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +6 -3
  15. package/dist/index.js +13 -11
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +13 -11
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/lib/attestation/attestation.service.d.ts +6 -11
  20. package/dist/lib/attestation/identity-signature.d.ts +17 -1
  21. package/dist/lib/attestation/index.d.ts +6 -2
  22. package/dist/lib/attestation/verify-sealed-derivation-response.d.ts +36 -0
  23. package/dist/lib/attestation/verify-sealed-seed-response.d.ts +80 -0
  24. package/dist/lib/attestation/verify-sealed-signing-response.d.ts +56 -6
  25. package/dist/lib/auth/auth.service.d.ts +1 -1
  26. package/dist/lib/auth/device-key.d.ts +26 -0
  27. package/dist/lib/sealed/sealed-nonce-ledger.d.ts +35 -0
  28. package/dist/lib/sealed/sealed-session.d.ts +38 -0
  29. package/dist/lib/swap/index.d.ts +5 -18
  30. package/dist/lib/swap/sealed-swap-intent.d.ts +44 -0
  31. package/dist/lib/transactions/index.d.ts +30 -63
  32. package/dist/lib/transactions/sealed-signing.schemas.d.ts +20 -6
  33. package/dist/lib/utils/cipher-core.d.ts +6 -0
  34. package/dist/lib/utils/cipher.service.d.ts +4 -57
  35. package/dist/lib/utils/constants.d.ts +2 -0
  36. package/dist/lib/wallet/derived-address.d.ts +9 -0
  37. package/dist/lib/wallet/wallet-data.service.d.ts +34 -11
  38. package/dist/lib/wallet/wallet-handlers.service.d.ts +101 -2
  39. package/dist/lib/wallet/wallet.service.d.ts +83 -22
  40. package/dist/package.json +8 -15
  41. package/dist/r/oci-BpYishbP.cjs +1 -0
  42. package/dist/r/oci-BpYishbP.cjs.map +1 -0
  43. package/dist/r/oci-DXErFBZ2.js +1 -0
  44. package/dist/r/oci-DXErFBZ2.js.map +1 -0
  45. package/dist/r/oci-DXErFBZ2.mjs +1 -0
  46. package/dist/r/oci-DXErFBZ2.mjs.map +1 -0
  47. package/dist/routes/auth.d.ts +5 -0
  48. package/dist/routes/swap.d.ts +0 -5
  49. package/dist/routes/transactions.d.ts +0 -20
  50. package/dist/routes/wallet.d.ts +5 -5
  51. package/dist/types/auth.d.ts +0 -1
  52. package/dist/types/base.d.ts +9 -12
  53. package/dist/types/common.d.ts +3 -0
  54. package/dist/types/error-response-codes.d.ts +15 -1
  55. package/dist/types/index.d.ts +2 -0
  56. package/dist/types/sealed-derivation.d.ts +137 -0
  57. package/dist/types/sealed-seed.d.ts +119 -0
  58. package/dist/types/sealed-signing.d.ts +351 -36
  59. package/dist/types/storage.d.ts +3 -1
  60. package/dist/types/swap.d.ts +0 -18
  61. package/dist/types/transactions.d.ts +1 -42
  62. package/dist/types/verification.d.ts +15 -19
  63. package/dist/types/wallet.d.ts +43 -5
  64. package/dist/verification/algorand/sealed.d.ts +59 -0
  65. package/dist/verification/algorand/transaction.d.ts +19 -0
  66. package/dist/verification/aptos/sealed.d.ts +44 -0
  67. package/dist/verification/aptos/transaction.d.ts +45 -0
  68. package/dist/verification/bitcoin/sealed.d.ts +63 -0
  69. package/dist/verification/bitcoin/transaction.d.ts +89 -0
  70. package/dist/verification/canton/hash.d.ts +35 -0
  71. package/dist/verification/canton/packages.d.ts +17 -0
  72. package/dist/verification/canton/prepared-transaction.d.ts +16 -0
  73. package/dist/verification/canton/sealed.d.ts +108 -0
  74. package/dist/verification/canton/topology.d.ts +15 -0
  75. package/dist/verification/canton/transfer.d.ts +40 -0
  76. package/dist/verification/canton/verify.d.ts +36 -0
  77. package/dist/verification/chain-context.d.ts +26 -3
  78. package/dist/verification/codecs/base58.d.ts +11 -0
  79. package/dist/verification/codecs/bcs.d.ts +46 -0
  80. package/dist/verification/codecs/bech32.d.ts +18 -0
  81. package/dist/verification/codecs/units.d.ts +5 -0
  82. package/dist/verification/derivation-context.d.ts +131 -0
  83. package/dist/verification/evm/lifi.d.ts +92 -0
  84. package/dist/verification/evm/verify.d.ts +108 -10
  85. package/dist/verification/fee-ceiling-table.d.ts +50 -0
  86. package/dist/verification/fee-ceilings.d.ts +28 -0
  87. package/dist/verification/injective/sealed.d.ts +37 -0
  88. package/dist/verification/injective/transaction.d.ts +68 -0
  89. package/dist/verification/pinned-spenders.d.ts +42 -0
  90. package/dist/verification/polymesh/codecs.d.ts +146 -75
  91. package/dist/verification/polymesh/context.d.ts +27 -24
  92. package/dist/verification/polymesh/payload.d.ts +40 -0
  93. package/dist/verification/polymesh/sealed.d.ts +48 -0
  94. package/dist/verification/polymesh/ss58.d.ts +7 -0
  95. package/dist/verification/polymesh/verify.d.ts +13 -4
  96. package/dist/verification/sealed.d.ts +13 -0
  97. package/dist/verification/solana/address.d.ts +21 -0
  98. package/dist/verification/solana/instructions.d.ts +55 -0
  99. package/dist/verification/solana/message.d.ts +34 -0
  100. package/dist/verification/solana/sealed.d.ts +32 -0
  101. package/dist/verification/sui/sealed.d.ts +47 -0
  102. package/dist/verification/sui/transaction.d.ts +121 -0
  103. package/package.json +8 -15
  104. package/dist/r/oci-DmlO5Nzi.cjs +0 -1
  105. package/dist/r/oci-DmlO5Nzi.cjs.map +0 -1
  106. package/dist/r/oci-_5u5jJ2e.js +0 -1
  107. package/dist/r/oci-_5u5jJ2e.js.map +0 -1
  108. package/dist/r/oci-_5u5jJ2e.mjs +0 -1
  109. package/dist/r/oci-_5u5jJ2e.mjs.map +0 -1
  110. package/dist/verification/polymesh/base58.d.ts +0 -7
package/README.md CHANGED
@@ -136,7 +136,7 @@ const wallaby = new Wallaby(config)
136
136
 
137
137
  wallaby.auth.refreshAuthTokens()
138
138
  wallaby.walletData.getTokenBalance(/* … */)
139
- wallaby.transactions.transfer(/* … */)
139
+ wallaby.transactions.prepare(/* intent */) // then wallaby.transactions.execute(prepared, authenticationOptions)
140
140
  wallaby.system.getSupportedBlockchains()
141
141
  ```
142
142
 
@@ -180,36 +180,40 @@ discriminant (`'api' | 'network' | 'validation' | 'sdk'`) and a `toJSON()` for l
180
180
  See [RUNTIME_VALIDATION.md](./RUNTIME_VALIDATION.md) for how it works, what's covered, and what's
181
181
  still in progress.
182
182
 
183
- ## Enclave attestation verification (opt-in)
183
+ ## Enclave attestation verification
184
184
 
185
- > **Opt-in and not yet load-bearing.** This is off by default, so existing integrations see no
186
- > behavior change. Its presence is **not** the attestation guarantee having landed: the binding between
187
- > the attested identity and the keys seed material is encrypted to is still being rolled out. Don't treat
188
- > enabling it as a security boundary yet.
185
+ Since **v4.0.0** (WAL-1808) the SDK sends seed or share material **only sealed to an attested enclave
186
+ session**: transaction signing (`transactions.prepare` / `transactions.execute`), address derivation
187
+ (`wallet.generateWalletAddresses`, the check `wallet.create` runs), `wallet.verifyAccess`, `wallet.import`,
188
+ `wallet.export` from a key share and `wallet.convertToPasskey`. There is no unsealed route left to fall back
189
+ to, so attestation is always enforced: `options.attestationVerification` accepts only `'throw'`, its default.
190
+ `'warn'` and `'off'` were removed and are refused at construction (`sdk_invalid_parameter`).
189
191
 
190
- `options.attestationVerification` makes the SDK verify the enclave's image **before** it decrypts
191
- and re-encrypts any seed material for transport to it:
192
+ **Not covered yet: wallet creation.** `wallet.create` is still unattested. The enclave generates the seed and
193
+ the API relays it, and the shares, wrapped to this device's key, with no session and no signed receipt. The
194
+ address check `wallet.create` runs proves the addresses match the seed this device received, not that the API
195
+ can't also read that seed. A sealed create is follow-up work.
192
196
 
193
197
  ```javascript
194
198
  const wallaby = new Wallaby({
195
199
  ...config,
196
- options: { attestationVerification: 'throw' }, // 'throw' | 'warn' | 'off' — default 'off'
200
+ options: { attestationVerification: 'throw' }, // the default, and the only accepted value
197
201
  });
198
202
  ```
199
203
 
200
- - **`'off'`** (default): nothing is fetched or checked.
201
- - **`'warn'`**: the enclave is verified; a failure is logged via the SDK logger and the request proceeds.
202
- - **`'throw'`**: the enclave is verified; a failure aborts the request before any seed material is prepared.
204
+ Every sealed call opens its own session: the API returns a session attestation document with a fresh nonce,
205
+ and the SDK verifies it before any key material is decrypted, seals the material to the session's attested
206
+ key, and accepts the result only if the session signed it over the exact envelope sent. Any failure throws.
203
207
 
204
- On each guarded request the SDK fetches a fresh attestation document (a new CSPRNG nonce per call,
205
- verified on echo) and runs the five checks: decode, certificate chain to the pinned AWS Nitro root,
208
+ For each sealed call the SDK verifies the session attestation document (a new CSPRNG nonce per call,
209
+ verified on echo) with the five checks: decode, certificate chain to the pinned AWS Nitro root,
206
210
  ES384 signature, PCR0/1/2 triple against the enclave manifest's permitted builds, and nonce.
207
211
 
208
212
  The permitted PCR triples are not baked into the SDK. They come from a signed manifest, shaped
209
213
  `{ payload, signatures }`, that `resolveManifest()` finds in this order, **the first authentic one winning**:
210
214
 
211
- 1. **Network:** `GET https://enclave-manifest.wallaby.cash/manifest.json` (the `dev-` host unless
212
- `options.environment` is `'production'`), straight to the CDN and never through the Wallaby API.
215
+ 1. **Network:** `GET https://enclave-manifest.wallaby.cash/manifest.json` (the `dev-` host only when
216
+ `options.environment` isn't `'production'` and `options.network` isn't `'mainnet'`), straight to the CDN and never through the Wallaby API.
213
217
  2. **Cache:** the last verified envelope, kept in `options.storage` through the SDK's `StorageService`
214
218
  (`saveGeneric` / `fetchGeneric`) under `wallaby-enclave-manifest-<env>`, encrypted with the SDK key and
215
219
  verified again every time it is read. It is device-wide: the key carries no user id, so every user on the
@@ -233,23 +237,19 @@ signed by an unknown key, for the wrong environment, or simply empty. The reques
233
237
  8 KB limit on the decoded response. You can read the verified PCRs yourself with
234
238
  `getEnclavePcrs({ isProduction })`.
235
239
 
236
- The same service is public as `wallaby.attestation`, for callers that want to verify on demand rather than
237
- gate requests: `await wallaby.attestation.verify()` fetches an attestation document (fresh nonce) and the
240
+ The same service is public as `wallaby.attestation`, for callers that want to verify the enclave on demand: `await wallaby.attestation.verify()` fetches an attestation document (fresh nonce) and the
238
241
  signed manifest, runs all five checks, and returns `{ verified: true, documentInfo }` — the decoded, verified
239
242
  attestation document, including its PCRs and the enclave identity public key — or throws as below.
240
243
 
241
- In `'throw'` mode a failed check is raised as the matching `AttestationVerificationError` subclass
244
+ A failed check is raised as the matching `AttestationVerificationError` subclass
242
245
  (`AttestationDecodeError`, `AttestationChainError`, `AttestationSignatureError`, `AttestationPcrError`,
243
246
  `AttestationNonceError`), whose `step` and `reason` name what failed.
244
247
 
245
- The gate currently covers operations that go through `prepareTransactionAuth` /
246
- `prepareWalletOperationAuth` (transfers, allowances, pending-transaction resolution, address
247
- generation, access verification, adding tokens), and `wallet.export()` when it has to send the primary
248
- key share to the enclave to reconstruct the seed phrase (an export served from a locally stored seed
249
- phrase or key shares never contacts the enclave, so it is not gated). It does **not** yet cover swaps,
250
- wallet import, or wallet creation/recovery.
251
-
252
- Each guarded request costs one extra round trip plus a certificate-chain verification.
248
+ The unsealed `swap.executeSwap` was removed in v4.0.0 with its API route. Execute a quote from `swap.getQuote`
249
+ through sealed signing instead: `transactions.prepare(sealedSwapIntent(quote, { walletId, originAddress }))`, then
250
+ `transactions.execute(prepared, authenticationOptions)` (WAL-2259). Swaps from Bitcoin and within one EVM chain are
251
+ supported; cross-chain EVM swaps and swaps from Solana and Sui are refused with `sdk_intent_unverifiable`. See
252
+ GUIDE.md, "Sealed swaps", for what the SDK checks. Quotes and history (`swap.getQuote`, `swap.getSwaps`) are unchanged.
253
253
 
254
254
  ## Generated API
255
255
 
package/dist/api.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./r/oci-DmlO5Nzi.cjs");exports.Api=e.A,exports.HttpClient=e.H;//# sourceMappingURL=api.cjs.map
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./r/oci-BpYishbP.cjs");exports.Api=e.A,exports.HttpClient=e.H;//# sourceMappingURL=api.cjs.map
package/dist/api.js CHANGED
@@ -1 +1 @@
1
- export{A as Api,H as HttpClient}from"./r/oci-_5u5jJ2e.js";//# sourceMappingURL=api.js.map
1
+ export{A as Api,H as HttpClient}from"./r/oci-DXErFBZ2.js";//# sourceMappingURL=api.js.map
package/dist/api.mjs CHANGED
@@ -1 +1 @@
1
- export{A as Api,H as HttpClient}from"./r/oci-_5u5jJ2e.mjs";//# sourceMappingURL=api.mjs.map
1
+ export{A as Api,H as HttpClient}from"./r/oci-DXErFBZ2.mjs";//# sourceMappingURL=api.mjs.map
package/dist/base.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AuthType, WallabyConfig, RequestOptions, RequestRoute, WallabyConfigOptions, WallabyError, WallabyErrorPayload } from './types';
1
+ import { AuthType, WallabyConfig, RequestOptions, RequestRoute, WallabyConfigOptions, WallabyError, WallabyErrorPayload, AttestationVerificationMode } from './types';
2
2
  import { StorageService } from './lib/utils/storage.service';
3
3
  import { LocalStorage } from './types/storage';
4
4
  import { LockManagerService } from './helpers/lock-manager.service';
@@ -19,9 +19,17 @@ export declare abstract class Base {
19
19
  private _localStorageService?;
20
20
  protected api: GeneratedApiClient<any>;
21
21
  constructor(config: WallabyConfig, ports?: Partial<Ports>);
22
+ /**
23
+ * Rotates the client JWT. The replacement (and the auth type it implies) reaches this service's generated client and
24
+ * every service it holds, at any depth, so a nested call such as the salt lookup a Canton registration's migration
25
+ * check makes never sends the JWT the service was constructed with.
26
+ */
22
27
  set setClientAuthToken(token: string);
28
+ private _rotateClientAuthToken;
29
+ /** The generated client sends the security data it was last given, so it is refreshed whenever the JWT changes. */
30
+ private _syncSecurityData;
23
31
  get version(): string;
24
- private _initializeClientAuthToken;
32
+ protected _initializeClientAuthToken(token: string): void;
25
33
  /**
26
34
  * This library uses `localStorage` as the default storage.
27
35
  * If you want to use a different storage, you can pass it in the options object of the Wallaby config.
@@ -35,7 +43,7 @@ export declare abstract class Base {
35
43
  * the signed enclave manifest is resolved without a cache when there is no storage engine.
36
44
  */
37
45
  protected get localStorageServiceIfAvailable(): StorageService | undefined;
38
- get attestationVerificationMode(): import("./types").AttestationVerificationMode;
46
+ get attestationVerificationMode(): AttestationVerificationMode;
39
47
  /**
40
48
  * Whether the SDK is configured for production (`options.environment`, defaulting to `NODE_ENV`, is `'production'`).
41
49
  * Selects which signed enclave manifest — and which trusted signing keys — apply.