@permissionless-technologies/upp-sdk 0.2.1 → 0.3.1

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 (68) hide show
  1. package/dist/chunk-3YZSIYJC.cjs +154 -0
  2. package/dist/chunk-3YZSIYJC.cjs.map +1 -0
  3. package/dist/{chunk-64RTC5ML.js → chunk-4EDTZQ44.js} +2 -2
  4. package/dist/{chunk-64RTC5ML.js.map → chunk-4EDTZQ44.js.map} +1 -1
  5. package/dist/{chunk-43U5RGYE.cjs → chunk-4EMXHMJ5.cjs} +2 -2
  6. package/dist/{chunk-43U5RGYE.cjs.map → chunk-4EMXHMJ5.cjs.map} +1 -1
  7. package/dist/{chunk-46GGZ3TC.cjs → chunk-4MOXKZSE.cjs} +17 -17
  8. package/dist/{chunk-46GGZ3TC.cjs.map → chunk-4MOXKZSE.cjs.map} +1 -1
  9. package/dist/{chunk-C7QQOJ7T.cjs → chunk-52PPS4AT.cjs} +4 -22
  10. package/dist/chunk-52PPS4AT.cjs.map +1 -0
  11. package/dist/{chunk-CZ23JMAQ.js → chunk-56LZ2RV6.js} +17 -17
  12. package/dist/{chunk-CZ23JMAQ.js.map → chunk-56LZ2RV6.js.map} +1 -1
  13. package/dist/{chunk-NUIQHTSA.js → chunk-7F75NGNB.js} +76 -3
  14. package/dist/chunk-7F75NGNB.js.map +1 -0
  15. package/dist/{chunk-SGZZL5AC.js → chunk-GS4UCMW4.js} +4 -20
  16. package/dist/chunk-GS4UCMW4.js.map +1 -0
  17. package/dist/{chunk-GXZ3MTCQ.cjs → chunk-IYOR5TCO.cjs} +77 -2
  18. package/dist/chunk-IYOR5TCO.cjs.map +1 -0
  19. package/dist/{chunk-GQV47S3N.cjs → chunk-PTDVGWHU.cjs} +2 -2
  20. package/dist/{chunk-GQV47S3N.cjs.map → chunk-PTDVGWHU.cjs.map} +1 -1
  21. package/dist/{chunk-NCW4AE7L.js → chunk-UAVWYXDN.js} +2 -2
  22. package/dist/chunk-UAVWYXDN.js.map +1 -0
  23. package/dist/chunk-XBNYAAMU.js +140 -0
  24. package/dist/chunk-XBNYAAMU.js.map +1 -0
  25. package/dist/core/index.cjs +68 -62
  26. package/dist/core/index.d.cts +3 -2
  27. package/dist/core/index.d.ts +3 -2
  28. package/dist/core/index.js +6 -4
  29. package/dist/{index-BGvapsJy.d.cts → index-B45-okum.d.cts} +19 -3
  30. package/dist/{index-ChGaGPzP.d.ts → index-BIcvNMPt.d.ts} +19 -3
  31. package/dist/{index-BBzvvrhG.d.ts → index-DwAJBoU7.d.ts} +122 -96
  32. package/dist/{index-C-jSNw6j.d.cts → index-o-Ds3YAq.d.cts} +122 -96
  33. package/dist/index.cjs +229 -176
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +4 -3
  36. package/dist/index.d.ts +4 -3
  37. package/dist/index.js +8 -7
  38. package/dist/index.js.map +1 -1
  39. package/dist/indexer/index.cjs +6 -6
  40. package/dist/indexer/index.d.cts +6 -5
  41. package/dist/indexer/index.d.ts +6 -5
  42. package/dist/indexer/index.js +1 -1
  43. package/dist/react/index.cjs +107 -102
  44. package/dist/react/index.cjs.map +1 -1
  45. package/dist/react/index.d.cts +2 -2
  46. package/dist/react/index.d.ts +2 -2
  47. package/dist/react/index.js +100 -95
  48. package/dist/react/index.js.map +1 -1
  49. package/dist/stark-BcTD1OaJ.d.cts +185 -0
  50. package/dist/stark-BcTD1OaJ.d.ts +185 -0
  51. package/dist/{transfer-4OF2JWXX.js → transfer-4GJJTWMH.js} +4 -4
  52. package/dist/{transfer-4OF2JWXX.js.map → transfer-4GJJTWMH.js.map} +1 -1
  53. package/dist/{transfer-DKZuJnRM.d.cts → transfer-BzyernBd.d.cts} +1 -3
  54. package/dist/{transfer-SA4NHNJ7.cjs → transfer-CLBDOA63.cjs} +10 -10
  55. package/dist/{transfer-SA4NHNJ7.cjs.map → transfer-CLBDOA63.cjs.map} +1 -1
  56. package/dist/{transfer-BlmbO-Rd.d.ts → transfer-sqS6mJko.d.ts} +1 -3
  57. package/dist/utils/index.cjs +54 -1
  58. package/dist/utils/index.d.cts +2 -0
  59. package/dist/utils/index.d.ts +2 -0
  60. package/dist/utils/index.js +2 -1
  61. package/package.json +2 -2
  62. package/src/deployments/11155111.json +13 -13
  63. package/src/deployments/31337.json +1 -1
  64. package/dist/chunk-C7QQOJ7T.cjs.map +0 -1
  65. package/dist/chunk-GXZ3MTCQ.cjs.map +0 -1
  66. package/dist/chunk-NCW4AE7L.js.map +0 -1
  67. package/dist/chunk-NUIQHTSA.js.map +0 -1
  68. package/dist/chunk-SGZZL5AC.js.map +0 -1
@@ -1,8 +1,9 @@
1
1
  import { PublicClient, WalletClient, Address, Hex } from 'viem';
2
- import { r as ShieldParams, h as Note, O as TransferParams, M as MergeParams, Y as WithdrawParams, E as EncryptedNote } from './transfer-DKZuJnRM.cjs';
2
+ import { q as ShieldParams, h as Note, L as TransferParams, M as MergeParams, X as WithdrawParams, E as EncryptedNote } from './transfer-BzyernBd.cjs';
3
3
  import { M as MasterKeys, O as OneTimeKeys, b as StarkMasterKeys } from './types-CJSbxv4q.cjs';
4
4
  import { a as M31Digest } from './keccak-m31-B_AqBbRF.cjs';
5
5
  import { P as Point } from './merkle-mteVOlDf.cjs';
6
+ import './stark-BcTD1OaJ.cjs';
6
7
 
7
8
  /**
8
9
  * Main UPP Client
@@ -274,100 +275,6 @@ declare function generateStarkStealthAddress(keys: StarkMasterKeys, chainId?: nu
274
275
  */
275
276
  declare function detectAddressType(address: string): 'snark' | 'stark' | 'unknown';
276
277
 
277
- /**
278
- * Account Adapter — Pluggable account creation
279
- *
280
- * Abstracts how master keys are derived/loaded.
281
- * The SDK doesn't care if keys come from a wallet signature,
282
- * seed phrase, hardware wallet, or external KMS.
283
- */
284
-
285
- /**
286
- * Account adapter interface — pluggable key source.
287
- *
288
- * Implement this to bring your own key derivation:
289
- * - SignatureAccountAdapter: EIP-712 wallet signature (built-in)
290
- * - DirectAccountAdapter: pre-derived keys (built-in, for testing/KMS)
291
- * - SeedPhraseAccountAdapter: BIP-39 seed phrase (custom)
292
- * - HardwareWalletAccountAdapter: Ledger/Trezor (custom)
293
- */
294
- interface IAccountAdapter {
295
- /** Derive or load SNARK master keys */
296
- getKeys(): Promise<MasterKeys>;
297
- /** Derive or load STARK master keys (optional) */
298
- getStarkKeys?(): Promise<StarkMasterKeys>;
299
- /** Persist keys (adapter decides where/how) */
300
- save?(): Promise<void>;
301
- /** Clear persisted keys */
302
- clear?(): Promise<void>;
303
- }
304
- /**
305
- * Direct account adapter — accepts pre-derived keys.
306
- *
307
- * Use for testing, external KMS, or when keys are derived
308
- * outside the SDK (e.g., from a seed phrase).
309
- *
310
- * @example
311
- * ```ts
312
- * const adapter = new DirectAccountAdapter({
313
- * spendingSecret: 12345n,
314
- * ownerHash: await poseidon([12345n]),
315
- * viewingSecret: 67890n,
316
- * viewingHash: await poseidon([67890n]),
317
- * })
318
- * const keys = await adapter.getKeys()
319
- * ```
320
- */
321
- declare class DirectAccountAdapter implements IAccountAdapter {
322
- private keys;
323
- private starkKeys?;
324
- constructor(keys: MasterKeys, starkKeys?: StarkMasterKeys | undefined);
325
- getKeys(): Promise<MasterKeys>;
326
- getStarkKeys(): Promise<StarkMasterKeys>;
327
- }
328
-
329
- /**
330
- * ASP Provider — Pluggable compliance layer
331
- *
332
- * Abstracts where ASP membership proofs come from.
333
- * The pool protocol doesn't care which ASP you use —
334
- * it's the operator who makes the rules.
335
- *
336
- * Built-in: none (ASP is optional, ragequit always available)
337
- * Implementations:
338
- * - RestASPProvider: fetch from ASP service API (e.g., asp-whitelist.upd.io)
339
- * - LocalASPProvider: generate from local tree (via upc-sdk)
340
- * - Custom: any source that can provide Merkle proofs
341
- */
342
-
343
- interface ASPMembershipProof {
344
- /** Merkle root of the ASP tree */
345
- root: bigint;
346
- /** Path elements (siblings) */
347
- pathElements: bigint[];
348
- /** Path indices (0 = left, 1 = right) */
349
- pathIndices: number[];
350
- }
351
- /**
352
- * ASP provider interface — pluggable compliance.
353
- *
354
- * Implement this to bring your own ASP:
355
- * - Each operator runs their own ASP service
356
- * - Users are whitelisted by the operator's rules
357
- * - Proofs are fetched from the operator's service
358
- *
359
- * If no ASP is configured, users can always ragequit
360
- * (withdraw their own deposits without ASP approval).
361
- */
362
- interface IASPProvider {
363
- /** ASP ID registered on-chain */
364
- getASPId(): bigint;
365
- /** Fetch a membership proof for an address */
366
- getProof(address: Address): Promise<ASPMembershipProof | null>;
367
- /** Check if an address is whitelisted (without fetching full proof) */
368
- isWhitelisted(address: Address): Promise<boolean>;
369
- }
370
-
371
278
  /**
372
279
  * Indexer Types
373
280
  *
@@ -672,6 +579,125 @@ interface NullifiedArgs {
672
579
  nullifier: Hex;
673
580
  }
674
581
 
582
+ /**
583
+ * Account Adapter — Pluggable account creation and persistence
584
+ *
585
+ * Abstracts how master keys are derived/loaded/stored.
586
+ * The SDK doesn't care if keys come from a wallet signature,
587
+ * seed phrase, hardware wallet, or external KMS.
588
+ *
589
+ * Persistence is handled via StorageAdapter (IndexedDB, localStorage, etc.)
590
+ */
591
+
592
+ /**
593
+ * Account adapter interface — pluggable key source.
594
+ *
595
+ * Implement this to bring your own key derivation:
596
+ * - StorableAccountAdapter: persists keys via StorageAdapter (built-in)
597
+ * - DirectAccountAdapter: pre-derived keys, no persistence (built-in, for testing)
598
+ * - Custom: seed phrase, hardware wallet, external KMS
599
+ */
600
+ interface IAccountAdapter {
601
+ /** Load persisted keys (returns null if no saved account) */
602
+ load(): Promise<{
603
+ keys: MasterKeys;
604
+ starkKeys?: StarkMasterKeys;
605
+ } | null>;
606
+ /** Save keys to storage */
607
+ save(keys: MasterKeys, starkKeys?: StarkMasterKeys): Promise<void>;
608
+ /** Clear persisted keys */
609
+ clear(): Promise<void>;
610
+ }
611
+ /**
612
+ * Account adapter that persists keys via a pluggable StorageAdapter.
613
+ *
614
+ * Works with IndexedDB, localStorage, memory, Redis, Postgres — anything
615
+ * that implements StorageAdapter.
616
+ *
617
+ * @example
618
+ * ```ts
619
+ * const storage = createAutoAdapter('upp_account')
620
+ * const adapter = new StorableAccountAdapter(storage, ethAddress)
621
+ * const saved = await adapter.load()
622
+ * if (!saved) {
623
+ * const keys = await deriveKeysFromSignature(sig)
624
+ * await adapter.save(keys, starkKeys)
625
+ * }
626
+ * ```
627
+ */
628
+ declare class StorableAccountAdapter implements IAccountAdapter {
629
+ private storage;
630
+ private storageKey;
631
+ constructor(storage: StorageAdapter, ethAddress: string);
632
+ load(): Promise<{
633
+ keys: MasterKeys;
634
+ starkKeys?: StarkMasterKeys;
635
+ } | null>;
636
+ save(keys: MasterKeys, starkKeys?: StarkMasterKeys): Promise<void>;
637
+ clear(): Promise<void>;
638
+ }
639
+ /**
640
+ * Direct account adapter — accepts pre-derived keys, no persistence.
641
+ *
642
+ * @example
643
+ * ```ts
644
+ * const adapter = new DirectAccountAdapter(masterKeys, starkKeys)
645
+ * ```
646
+ */
647
+ declare class DirectAccountAdapter implements IAccountAdapter {
648
+ private keys;
649
+ private starkKeys?;
650
+ constructor(keys: MasterKeys, starkKeys?: StarkMasterKeys | undefined);
651
+ load(): Promise<{
652
+ keys: MasterKeys;
653
+ starkKeys: StarkMasterKeys | undefined;
654
+ }>;
655
+ save(): Promise<void>;
656
+ clear(): Promise<void>;
657
+ }
658
+
659
+ /**
660
+ * ASP Provider — Pluggable compliance layer
661
+ *
662
+ * Abstracts where ASP membership proofs come from.
663
+ * The pool protocol doesn't care which ASP you use —
664
+ * it's the operator who makes the rules.
665
+ *
666
+ * Built-in: none (ASP is optional, ragequit always available)
667
+ * Implementations:
668
+ * - RestASPProvider: fetch from ASP service API (e.g., asp-whitelist.upd.io)
669
+ * - LocalASPProvider: generate from local tree (via upc-sdk)
670
+ * - Custom: any source that can provide Merkle proofs
671
+ */
672
+
673
+ interface ASPMembershipProof {
674
+ /** Merkle root of the ASP tree */
675
+ root: bigint;
676
+ /** Path elements (siblings) */
677
+ pathElements: bigint[];
678
+ /** Path indices (0 = left, 1 = right) */
679
+ pathIndices: number[];
680
+ }
681
+ /**
682
+ * ASP provider interface — pluggable compliance.
683
+ *
684
+ * Implement this to bring your own ASP:
685
+ * - Each operator runs their own ASP service
686
+ * - Users are whitelisted by the operator's rules
687
+ * - Proofs are fetched from the operator's service
688
+ *
689
+ * If no ASP is configured, users can always ragequit
690
+ * (withdraw their own deposits without ASP approval).
691
+ */
692
+ interface IASPProvider {
693
+ /** ASP ID registered on-chain */
694
+ getASPId(): bigint;
695
+ /** Fetch a membership proof for an address */
696
+ getProof(address: Address): Promise<ASPMembershipProof | null>;
697
+ /** Check if an address is whitelisted (without fetching full proof) */
698
+ isWhitelisted(address: Address): Promise<boolean>;
699
+ }
700
+
675
701
  /**
676
702
  * NoteStore — Single source of truth for note state
677
703
  *
@@ -754,4 +780,4 @@ declare class NoteStore implements INoteStore {
754
780
  private notify;
755
781
  }
756
782
 
757
- export { ADDRESS_VERSION as A, decryptNote as B, type CommitmentInsertedArgs as C, DirectAccountAdapter as D, detectAddressType as E, encodeStarkStealthAddress as F, encodeStealthAddress as G, encryptNote as H, type Indexer as I, generateStarkStealthAddress as J, generateStealthAddress as K, type LiveSyncConfig as L, isValidStarkStealthAddress as M, type NoteStatus$1 as N, isValidStealthAddress as O, type ProofSystem as P, verifyOwnership as Q, type RpcIndexerConfig as R, type StorageAdapter as S, type NoteStatus as T, type UPPClient as U, type IndexedNote as a, type NoteFilters as b, type SyncResult as c, type SyncProgress as d, type SyncConfig as e, type IndexerState as f, type SyncState as g, type SerializedNote as h, type StealthTransactArgs as i, type NullifiedArgs as j, type ASPMembershipProof as k, type IASPProvider as l, type IAccountAdapter as m, type INoteStore as n, NoteStore as o, STARK_ADDRESS_VERSION as p, STARK_STEALTH_ADDRESS_PREFIX as q, STEALTH_ADDRESS_PREFIX as r, type ShieldedNote as s, type UPPClientConfig as t, computeNoteEncryptionKey as u, createNote as v, createOneTimeKeys as w, createUPPClient as x, decodeStarkStealthAddress as y, decodeStealthAddress as z };
783
+ export { ADDRESS_VERSION as A, decodeStealthAddress as B, type CommitmentInsertedArgs as C, DirectAccountAdapter as D, decryptNote as E, detectAddressType as F, encodeStarkStealthAddress as G, encodeStealthAddress as H, type Indexer as I, encryptNote as J, generateStarkStealthAddress as K, type LiveSyncConfig as L, generateStealthAddress as M, type NoteStatus$1 as N, isValidStarkStealthAddress as O, type ProofSystem as P, isValidStealthAddress as Q, type RpcIndexerConfig as R, type StorageAdapter as S, verifyOwnership as T, type UPPClient as U, type NoteStatus as V, type IndexedNote as a, type NoteFilters as b, type SyncResult as c, type SyncProgress as d, type SyncConfig as e, type IndexerState as f, type SyncState as g, type SerializedNote as h, type StealthTransactArgs as i, type NullifiedArgs as j, type ASPMembershipProof as k, type IASPProvider as l, type IAccountAdapter as m, type INoteStore as n, NoteStore as o, STARK_ADDRESS_VERSION as p, STARK_STEALTH_ADDRESS_PREFIX as q, STEALTH_ADDRESS_PREFIX as r, type ShieldedNote as s, StorableAccountAdapter as t, type UPPClientConfig as u, computeNoteEncryptionKey as v, createNote as w, createOneTimeKeys as x, createUPPClient as y, decodeStarkStealthAddress as z };