@miden-sdk/miden-sdk 0.14.5 → 0.15.0-alpha.4

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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -9
  3. package/dist/{Cargo-M3382VZc.js → Cargo-CVlXCH_2.js} +7129 -6225
  4. package/dist/Cargo-CVlXCH_2.js.map +1 -0
  5. package/dist/api-types.d.ts +19 -65
  6. package/dist/assets/miden_client_web.wasm +0 -0
  7. package/dist/crates/miden_client_web.d.ts +122 -172
  8. package/dist/docs-entry.d.ts +5 -2
  9. package/dist/eager.js +7 -4
  10. package/dist/eager.js.map +1 -1
  11. package/dist/index.d.ts +107 -14
  12. package/dist/index.js +529 -415
  13. package/dist/index.js.map +1 -1
  14. package/dist/wasm.js +1 -1
  15. package/dist/workers/{Cargo-M3382VZc-Dfw4tXwh.js → Cargo-CVlXCH_2-CWA-5vlh.js} +7129 -6225
  16. package/dist/workers/Cargo-CVlXCH_2-CWA-5vlh.js.map +1 -0
  17. package/dist/workers/assets/miden_client_web.wasm +0 -0
  18. package/dist/workers/web-client-methods-worker.js +7153 -6243
  19. package/dist/workers/web-client-methods-worker.js.map +1 -1
  20. package/dist/workers/web-client-methods-worker.module.js +23 -19
  21. package/dist/workers/web-client-methods-worker.module.js.map +1 -1
  22. package/js/client.js +327 -0
  23. package/js/node/client-factory.js +117 -0
  24. package/js/node/loader.js +138 -0
  25. package/js/node/napi-compat.js +238 -0
  26. package/js/node-index.js +195 -0
  27. package/js/resources/accounts.js +224 -0
  28. package/js/resources/compiler.js +74 -0
  29. package/js/resources/keystore.js +54 -0
  30. package/js/resources/notes.js +124 -0
  31. package/js/resources/settings.js +30 -0
  32. package/js/resources/tags.js +31 -0
  33. package/js/resources/transactions.js +533 -0
  34. package/js/standalone.js +109 -0
  35. package/js/utils.js +232 -0
  36. package/lazy/package.json +4 -0
  37. package/package.json +62 -40
  38. package/dist/Cargo-M3382VZc.js.map +0 -1
  39. package/dist/workers/Cargo-M3382VZc-Dfw4tXwh.js.map +0 -1
@@ -32,17 +32,17 @@ import type {
32
32
  NoteScript,
33
33
  AdviceInputs,
34
34
  FeltArray,
35
- } from "./crates/miden_client_web";
35
+ } from "./crates/miden_client_web.js";
36
36
 
37
37
  // Import the full namespace for the MidenArrayConstructors type
38
- import type * as WasmExports from "./crates/miden_client_web";
38
+ import type * as WasmExports from "./crates/miden_client_web.js";
39
39
 
40
40
  // Source of truth for standalone-wrapper return types. By deriving them from
41
41
  // the wasm-bindgen-generated namespace (rather than hand-writing `: Note`),
42
42
  // the declarations below cannot drift from the actual runtime behavior — the
43
43
  // exact class of bug behind #2042. Any forwarder-style wrapper should follow
44
44
  // the same pattern: `ReturnType<WasmModule["Class"]["method"]>`.
45
- type WasmModule = typeof import("./crates/miden_client_web");
45
+ type WasmModule = typeof import("./crates/miden_client_web.js");
46
46
 
47
47
  // ════════════════════════════════════════════════════════════════
48
48
  // Callback types for external keystore support
@@ -84,25 +84,9 @@ export declare const AuthScheme: {
84
84
  };
85
85
 
86
86
  /**
87
- * Union of all string values in the AuthScheme const. Merges with the
88
- * `AuthScheme` value so `authScheme?: AuthScheme` resolves to
89
- * `"falcon" | "ecdsa"` in type position while `AuthScheme.Falcon` /
90
- * `AuthScheme.ECDSA` still work in value position.
87
+ * Union of all values in the AuthScheme const.
91
88
  */
92
- export type AuthScheme = (typeof AuthScheme)[keyof typeof AuthScheme];
93
-
94
- /** @deprecated Alias for `AuthScheme` (the string union). */
95
- export type AuthSchemeType = AuthScheme;
96
-
97
- /**
98
- * Resolves an `AuthScheme` string to the numeric value expected by low-level
99
- * wasm-bindgen methods such as
100
- * `AccountComponent.createAuthComponentFromCommitment(commitment, scheme)`.
101
- *
102
- * @param scheme - `AuthScheme.Falcon` or `AuthScheme.ECDSA`. Defaults to `"falcon"`.
103
- * @returns The numeric AuthScheme enum value.
104
- */
105
- export declare function resolveAuthScheme(scheme?: AuthScheme): number;
89
+ export type AuthSchemeType = (typeof AuthScheme)[keyof typeof AuthScheme];
106
90
 
107
91
  /**
108
92
  * User-friendly note visibility constants.
@@ -203,6 +187,8 @@ export interface ClientOptions {
203
187
  storeName?: string;
204
188
  /** Sync state on creation (default: false). */
205
189
  autoSync?: boolean;
190
+ /** Enable debug mode for transaction execution (default: false). */
191
+ debugMode?: boolean;
206
192
  /** External keystore callbacks. */
207
193
  keystore?: {
208
194
  getKey: GetKeyCallback;
@@ -452,11 +438,18 @@ export interface PreviewSwapOptions {
452
438
  paybackType?: NoteVisibility;
453
439
  }
454
440
 
441
+ export interface PreviewCustomOptions {
442
+ operation: "custom";
443
+ account: AccountRef;
444
+ request: TransactionRequest;
445
+ }
446
+
455
447
  export type PreviewOptions =
456
448
  | PreviewSendOptions
457
449
  | PreviewMintOptions
458
450
  | PreviewConsumeOptions
459
- | PreviewSwapOptions;
451
+ | PreviewSwapOptions
452
+ | PreviewCustomOptions;
460
453
 
461
454
  /** Status values reported during waitFor polling. */
462
455
  export type WaitStatus = "pending" | "submitted" | "committed";
@@ -536,12 +529,6 @@ export interface MockOptions {
536
529
  serializedNoteTransport?: Uint8Array;
537
530
  }
538
531
 
539
- /** Versioned store snapshot for backup/restore. */
540
- export interface StoreSnapshot {
541
- version: number;
542
- data: unknown;
543
- }
544
-
545
532
  // ════════════════════════════════════════════════════════════════
546
533
  // Swap tag options
547
534
  // ════════════════════════════════════════════════════════════════
@@ -937,15 +924,6 @@ export declare class MidenClient {
937
924
  static createDevnet(options?: ClientOptions): Promise<MidenClient>;
938
925
  /** Creates a mock client for testing. */
939
926
  static createMock(options?: MockOptions): Promise<MidenClient>;
940
- /**
941
- * Resolves once the WASM module is initialized and safe to use.
942
- *
943
- * Idempotent and shared across callers — concurrent invocations await the
944
- * same in-flight promise, and post-init callers resolve immediately.
945
- * Primarily useful on the `/lazy` entry (Next.js / Capacitor) where no
946
- * top-level await runs at import time; harmless on the eager entry.
947
- */
948
- static ready(): Promise<void>;
949
927
 
950
928
  readonly accounts: AccountsResource;
951
929
  readonly transactions: TransactionsResource;
@@ -959,46 +937,22 @@ export declare class MidenClient {
959
937
  sync(options?: { timeout?: number }): Promise<SyncSummary>;
960
938
  /** Returns the current sync height. */
961
939
  getSyncHeight(): Promise<number>;
962
- /**
963
- * Resolves once every serialized WASM call that was already on the
964
- * internal call chain when `waitForIdle()` was called (execute, submit,
965
- * prove, apply, sync, or account creation) has settled. Use this from
966
- * callers that need to perform a non-WASM-side action — e.g. clearing
967
- * an in-memory auth key on wallet lock — after the kernel finishes, so
968
- * its auth callback doesn't race with the key being cleared. Does NOT
969
- * wait for calls enqueued after `waitForIdle()` returns.
970
- *
971
- * Caveat for `sync`: a `syncState` blocked on its sync lock (Web
972
- * Locks) has not yet reached the internal chain, so `waitForIdle`
973
- * does not await it. Other serialized methods are always observed.
974
- *
975
- * Returns immediately if nothing was in flight.
976
- */
977
- waitForIdle(): Promise<void>;
978
- /**
979
- * Returns the raw JS value that the most recent sign-callback invocation
980
- * threw, or `null` if the last sign call succeeded (or no call has
981
- * happened yet). Useful for recovering structured metadata (e.g. a
982
- * `reason: 'locked'` property) that the kernel-level `auth::request`
983
- * diagnostic would otherwise erase.
984
- */
985
- lastAuthError(): unknown;
986
940
  /** Returns the client-level default prover. */
987
941
  readonly defaultProver: TransactionProver | null;
988
942
  /** Terminates the underlying Web Worker. After this, all method calls throw. */
989
943
  terminate(): void;
990
944
 
991
945
  /** Returns the identifier of the underlying store (e.g. IndexedDB database name, file path). */
992
- storeIdentifier(): string;
946
+ storeIdentifier(): Promise<string>;
993
947
 
994
948
  /** Advances the mock chain by one block. Only available on mock clients. */
995
- proveBlock(): void;
949
+ proveBlock(): Promise<void>;
996
950
  /** Returns true if this client uses a mock chain. */
997
951
  usesMockChain(): boolean;
998
952
  /** Serializes the mock chain state for snapshot/restore in tests. */
999
- serializeMockChain(): Uint8Array;
953
+ serializeMockChain(): Promise<Uint8Array>;
1000
954
  /** Serializes the mock note transport node state. */
1001
- serializeMockNoteTransportNode(): Uint8Array;
955
+ serializeMockNoteTransportNode(): Promise<Uint8Array>;
1002
956
 
1003
957
  [Symbol.dispose](): void;
1004
958
  [Symbol.asyncDispose](): Promise<void>;
Binary file