@miden-sdk/miden-sdk 0.14.8 → 0.14.9
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/dist/mt/{Cargo-CUP4fvtE.js → Cargo-DKB2aRX-.js} +95 -68
- package/dist/mt/{Cargo-CUP4fvtE.js.map → Cargo-DKB2aRX-.js.map} +1 -1
- package/dist/mt/api-types.d.ts +15 -0
- package/dist/mt/assets/miden_client_web.wasm +0 -0
- package/dist/mt/crates/miden_client_web.d.ts +22 -0
- package/dist/mt/eager.js +1 -1
- package/dist/mt/index.d.ts +4 -2
- package/dist/mt/index.js +57 -13
- package/dist/mt/index.js.map +1 -1
- package/dist/mt/wasm.js +1 -1
- package/dist/mt/workerHelpers.js +1 -1
- package/dist/mt/workers/{Cargo-CUP4fvtE-DQbaP5ul.js → Cargo-DKB2aRX--C6T4l3AF.js} +95 -68
- package/dist/mt/workers/{Cargo-CUP4fvtE-DQbaP5ul.js.map → Cargo-DKB2aRX--C6T4l3AF.js.map} +1 -1
- package/dist/mt/workers/assets/miden_client_web.wasm +0 -0
- package/dist/mt/workers/web-client-methods-worker.js +96 -69
- package/dist/mt/workers/web-client-methods-worker.js.map +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js +1 -1
- package/dist/mt/workers/web-client-methods-worker.module.js.map +1 -1
- package/dist/mt/workers/workerHelpers.js +1 -1
- package/dist/st/{Cargo-C35FdGuj.js → Cargo-jOTNoFyS.js} +97 -70
- package/dist/st/{Cargo-C35FdGuj.js.map → Cargo-jOTNoFyS.js.map} +1 -1
- package/dist/st/api-types.d.ts +15 -0
- package/dist/st/assets/miden_client_web.wasm +0 -0
- package/dist/st/crates/miden_client_web.d.ts +22 -0
- package/dist/st/eager.js +1 -1
- package/dist/st/index.d.ts +4 -2
- package/dist/st/index.js +57 -13
- package/dist/st/index.js.map +1 -1
- package/dist/st/wasm.js +1 -1
- package/dist/st/workers/{Cargo-C35FdGuj-DAEzC4n9.js → Cargo-jOTNoFyS-DRTcF6wf.js} +97 -70
- package/dist/st/workers/{Cargo-C35FdGuj-DAEzC4n9.js.map → Cargo-jOTNoFyS-DRTcF6wf.js.map} +1 -1
- package/dist/st/workers/assets/miden_client_web.wasm +0 -0
- package/dist/st/workers/web-client-methods-worker.js +98 -71
- package/dist/st/workers/web-client-methods-worker.js.map +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js +1 -1
- package/dist/st/workers/web-client-methods-worker.module.js.map +1 -1
- package/package.json +1 -1
package/dist/mt/api-types.d.ts
CHANGED
|
@@ -209,6 +209,21 @@ export interface ClientOptions {
|
|
|
209
209
|
insertKey: InsertKeyCallback;
|
|
210
210
|
sign: SignCallback;
|
|
211
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* Enable the Web Worker shim that runs WASM calls off the main thread.
|
|
214
|
+
* Defaults to `true` — leave it that way in browsers/extensions so the UI
|
|
215
|
+
* stays responsive while WASM is busy.
|
|
216
|
+
*
|
|
217
|
+
* Set to `false` when:
|
|
218
|
+
* - You pass a `CallbackProver` via `TransactionProver.newCallbackProver(jsFn)`.
|
|
219
|
+
* The worker boundary serializes the prover with `TransactionProver.serialize()`,
|
|
220
|
+
* which has no encoding for the callback variant and silently downgrades
|
|
221
|
+
* to `"local"` — your callback would never fire.
|
|
222
|
+
* - You're embedding the client in a single-WebView native shell (iOS/Android
|
|
223
|
+
* Capacitor host, Tauri, Electron preload), where the UI thread isn't
|
|
224
|
+
* competing with the WASM thread anyway.
|
|
225
|
+
*/
|
|
226
|
+
useWorker?: boolean;
|
|
212
227
|
}
|
|
213
228
|
|
|
214
229
|
// ════════════════════════════════════════════════════════════════
|
|
Binary file
|
|
@@ -3885,6 +3885,28 @@ export class TransactionProver {
|
|
|
3885
3885
|
* Returns the endpoint if this is a remote prover.
|
|
3886
3886
|
*/
|
|
3887
3887
|
endpoint(): string | undefined;
|
|
3888
|
+
/**
|
|
3889
|
+
* Creates a prover that delegates `prove()` to a JavaScript callback.
|
|
3890
|
+
*
|
|
3891
|
+
* The callback receives the serialized [`TransactionInputs`] as a
|
|
3892
|
+
* `Uint8Array` and must return a `Promise<Uint8Array>` resolving to a
|
|
3893
|
+
* serialized [`ProvenTransaction`] (same encoding the gRPC remote
|
|
3894
|
+
* prover uses: `tx_inputs.to_bytes()` in, `ProvenTransaction::read_from_bytes`
|
|
3895
|
+
* out).
|
|
3896
|
+
*
|
|
3897
|
+
* Use case: routing prove to a native iOS / Android plugin
|
|
3898
|
+
* (`@miden/native-prover`) so mobile builds skip WASM prove entirely
|
|
3899
|
+
* — `WKWebView` can't be made cross-origin-isolated reliably and the
|
|
3900
|
+
* MT WASM bundle can't instantiate without `SharedArrayBuffer`, so the
|
|
3901
|
+
* host wraps a native Rust prover (built with the same `miden_tx`
|
|
3902
|
+
* crate) and exposes a JS-shaped callback over the Capacitor bridge.
|
|
3903
|
+
*
|
|
3904
|
+
* The SDK does NOT serialize the prover for persistence across
|
|
3905
|
+
* reloads (unlike `newRemoteProver`), since the callback is a
|
|
3906
|
+
* runtime JS reference. Hosts must recreate the prover on every
|
|
3907
|
+
* page load.
|
|
3908
|
+
*/
|
|
3909
|
+
static newCallbackProver(callback: Function): TransactionProver;
|
|
3888
3910
|
/**
|
|
3889
3911
|
* Creates a prover that uses the local proving backend.
|
|
3890
3912
|
*/
|
package/dist/mt/eager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getWasmOrThrow } from './index.js';
|
|
2
2
|
export { AccountArray, AccountIdArray, AccountType, AuthScheme, CompilerResource, FeltArray, ForeignAccountArray, Linking, MidenArrays, MidenClient, MockWasmWebClient, NoteAndArgsArray, NoteArray, NoteIdAndArgsArray, NoteRecipientArray, NoteVisibility, OutputNoteArray, StorageMode, StorageSlotArray, TransactionScriptInputPairArray, WasmWebClient, buildSwapTag, createP2IDENote, createP2IDNote, resolveAuthScheme } from './index.js';
|
|
3
|
-
export { Account, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapInfo, StorageMapUpdate, StorageSlot, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-
|
|
3
|
+
export { Account, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapInfo, StorageMapUpdate, StorageSlot, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-DKB2aRX-.js';
|
|
4
4
|
import './wasm.js';
|
|
5
5
|
|
|
6
6
|
// Eager entry point for @miden-sdk/miden-sdk.
|
package/dist/mt/index.d.ts
CHANGED
|
@@ -51,7 +51,8 @@ export declare class WasmWebClient extends WasmWebClientBase {
|
|
|
51
51
|
noteTransportUrl?: string,
|
|
52
52
|
seed?: Uint8Array,
|
|
53
53
|
storeName?: string,
|
|
54
|
-
logLevel?: LogLevel
|
|
54
|
+
logLevel?: LogLevel,
|
|
55
|
+
useWorker?: boolean
|
|
55
56
|
): Promise<WasmWebClient>;
|
|
56
57
|
|
|
57
58
|
static createClientWithExternalKeystore(
|
|
@@ -62,7 +63,8 @@ export declare class WasmWebClient extends WasmWebClientBase {
|
|
|
62
63
|
getKeyCb?: GetKeyCallback,
|
|
63
64
|
insertKeyCb?: InsertKeyCallback,
|
|
64
65
|
signCb?: SignCallback,
|
|
65
|
-
logLevel?: LogLevel
|
|
66
|
+
logLevel?: LogLevel,
|
|
67
|
+
useWorker?: boolean
|
|
66
68
|
): Promise<WasmWebClient>;
|
|
67
69
|
|
|
68
70
|
syncState(): Promise<SyncSummary>;
|
package/dist/mt/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import loadWasm from './wasm.js';
|
|
2
|
-
import { AccountArray as AccountArray$1, AccountIdArray as AccountIdArray$1, FeltArray as FeltArray$1, ForeignAccountArray as ForeignAccountArray$1, NoteAndArgsArray as NoteAndArgsArray$1, NoteArray as NoteArray$1, NoteIdAndArgsArray as NoteIdAndArgsArray$1, NoteRecipientArray as NoteRecipientArray$1, OutputNoteArray as OutputNoteArray$1, StorageSlotArray as StorageSlotArray$1, TransactionScriptInputPairArray as TransactionScriptInputPairArray$1 } from './Cargo-
|
|
3
|
-
export { Account, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapInfo, StorageMapUpdate, StorageSlot, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-
|
|
2
|
+
import { AccountArray as AccountArray$1, AccountIdArray as AccountIdArray$1, FeltArray as FeltArray$1, ForeignAccountArray as ForeignAccountArray$1, NoteAndArgsArray as NoteAndArgsArray$1, NoteArray as NoteArray$1, NoteIdAndArgsArray as NoteIdAndArgsArray$1, NoteRecipientArray as NoteRecipientArray$1, OutputNoteArray as OutputNoteArray$1, StorageSlotArray as StorageSlotArray$1, TransactionScriptInputPairArray as TransactionScriptInputPairArray$1 } from './Cargo-DKB2aRX-.js';
|
|
3
|
+
export { Account, AccountBuilder, AccountBuilderResult, AccountCode, AccountComponent, AccountComponentCode, AccountDelta, AccountFile, AccountHeader, AccountId, AccountInterface, AccountProof, AccountReader, AccountStatus, AccountStorage, AccountStorageDelta, AccountStorageMode, AccountStorageRequirements, AccountVaultDelta, Address, AdviceInputs, AdviceMap, AssetVault, AuthFalcon512RpoMultisigConfig, AuthSecretKey, BasicFungibleFaucetComponent, BlockHeader, CodeBuilder, CommittedNote, ConsumableNoteRecord, Endpoint, ExecutedTransaction, Felt, FetchedAccount, FetchedNote, FlattenedU8Vec, ForeignAccount, FungibleAsset, FungibleAssetDelta, FungibleAssetDeltaItem, GetProceduresResultItem, InputNote, InputNoteRecord, InputNoteState, InputNotes, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, JsAccountUpdate, JsStateSyncUpdate, JsStorageMapEntry, JsStorageSlot, JsVaultAsset, Library, MerklePath, NetworkId, NetworkType, Note, NoteAndArgs, NoteAssets, NoteAttachment, NoteAttachmentKind, NoteAttachmentScheme, NoteConsumability, NoteConsumptionStatus, NoteDetails, NoteDetailsAndTag, NoteDetailsAndTagArray, NoteExecutionHint, NoteExportFormat, NoteFile, NoteFilter, NoteFilterTypes, NoteHeader, NoteId, NoteIdAndArgs, NoteInclusionProof, NoteLocation, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteSyncBlock, NoteSyncInfo, NoteTag, NoteType, OutputNote, OutputNoteRecord, OutputNoteState, OutputNotes, Package, PartialNote, Poseidon2, ProcedureThreshold, Program, ProvenTransaction, PublicKey, RpcClient, Rpo256, SerializedInputNoteData, SerializedOutputNoteData, SerializedTransactionData, Signature, SigningInputs, SigningInputsType, SlotAndKeys, SparseMerklePath, StorageMap, StorageMapEntry, StorageMapInfo, StorageMapUpdate, StorageSlot, SyncSummary, TestUtils, TokenSymbol, TransactionArgs, TransactionFilter, TransactionId, TransactionProver, TransactionRecord, TransactionRequest, TransactionRequestBuilder, TransactionResult, TransactionScript, TransactionScriptInputPair, TransactionStatus, TransactionStoreUpdate, TransactionSummary, WebClient, WebKeystoreApi, Word, createAuthFalcon512RpoMultisig, exportStore, importStore, initSync, initThreadPool, parallelSumBench, rayonThreadCount, sequentialSumBench, setupLogging, wbg_rayon_PoolBuilder, wbg_rayon_start_worker } from './Cargo-DKB2aRX-.js';
|
|
4
4
|
|
|
5
5
|
const WorkerAction = Object.freeze({
|
|
6
6
|
INIT: "init",
|
|
@@ -1633,6 +1633,13 @@ class MidenClient {
|
|
|
1633
1633
|
const rpcUrl = resolveRpcUrl(options?.rpcUrl);
|
|
1634
1634
|
const noteTransportUrl = resolveNoteTransportUrl(options?.noteTransportUrl);
|
|
1635
1635
|
|
|
1636
|
+
// `useWorker: false` opts out of the Web Worker shim that wraps every
|
|
1637
|
+
// WASM call. The shim exists to keep the main thread responsive in
|
|
1638
|
+
// browser/extension contexts, but it serializes the prover via
|
|
1639
|
+
// `TransactionProver.serialize()` — a format that has no encoding for
|
|
1640
|
+
// `newCallbackProver(jsFn)` and silently downgrades it to `"local"`.
|
|
1641
|
+
// Mobile/Tauri/native-prover consumers must pass `useWorker: false`.
|
|
1642
|
+
const useWorker = options?.useWorker;
|
|
1636
1643
|
let inner;
|
|
1637
1644
|
if (options?.keystore) {
|
|
1638
1645
|
inner = await WebClientClass.createClientWithExternalKeystore(
|
|
@@ -1642,14 +1649,18 @@ class MidenClient {
|
|
|
1642
1649
|
options?.storeName,
|
|
1643
1650
|
options.keystore.getKey,
|
|
1644
1651
|
options.keystore.insertKey,
|
|
1645
|
-
options.keystore.sign
|
|
1652
|
+
options.keystore.sign,
|
|
1653
|
+
undefined,
|
|
1654
|
+
useWorker
|
|
1646
1655
|
);
|
|
1647
1656
|
} else {
|
|
1648
1657
|
inner = await WebClientClass.createClient(
|
|
1649
1658
|
rpcUrl,
|
|
1650
1659
|
noteTransportUrl,
|
|
1651
1660
|
seed,
|
|
1652
|
-
options?.storeName
|
|
1661
|
+
options?.storeName,
|
|
1662
|
+
undefined,
|
|
1663
|
+
useWorker
|
|
1653
1664
|
);
|
|
1654
1665
|
}
|
|
1655
1666
|
|
|
@@ -2393,6 +2404,15 @@ class WebClient {
|
|
|
2393
2404
|
* @param {string | undefined} [logLevel] - Optional log verbosity level
|
|
2394
2405
|
* ("error", "warn", "info", "debug", "trace", "off", or "none").
|
|
2395
2406
|
* When set, Rust tracing output is routed to the browser console.
|
|
2407
|
+
* @param {boolean} [useWorker=true] - When `false`, skip the Web Worker shim
|
|
2408
|
+
* and call the wasm-bindgen `WebClient` directly on the current thread.
|
|
2409
|
+
* The worker exists to keep the main thread responsive during WASM work
|
|
2410
|
+
* in browser/extension contexts, but it serializes the prover argument
|
|
2411
|
+
* via `TransactionProver.serialize()` — a format that has no encoding
|
|
2412
|
+
* for `newCallbackProver(jsFn)` and silently downgrades it to `"local"`.
|
|
2413
|
+
* Consumers that hand a `CallbackProver` (e.g. native iOS/Android plug-in
|
|
2414
|
+
* provers in Capacitor apps, or any other JS-side prover bridge) need
|
|
2415
|
+
* `useWorker: false` so the prover handle reaches the WASM binding intact.
|
|
2396
2416
|
*/
|
|
2397
2417
|
constructor(
|
|
2398
2418
|
rpcUrl,
|
|
@@ -2402,7 +2422,8 @@ class WebClient {
|
|
|
2402
2422
|
getKeyCb,
|
|
2403
2423
|
insertKeyCb,
|
|
2404
2424
|
signCb,
|
|
2405
|
-
logLevel
|
|
2425
|
+
logLevel,
|
|
2426
|
+
useWorker = true
|
|
2406
2427
|
) {
|
|
2407
2428
|
this.rpcUrl = rpcUrl;
|
|
2408
2429
|
this.noteTransportUrl = noteTransportUrl;
|
|
@@ -2412,9 +2433,12 @@ class WebClient {
|
|
|
2412
2433
|
this.insertKeyCb = insertKeyCb;
|
|
2413
2434
|
this.signCb = signCb;
|
|
2414
2435
|
this.logLevel = logLevel;
|
|
2436
|
+
this.useWorker = useWorker !== false;
|
|
2415
2437
|
|
|
2416
|
-
// Check if Web Workers are available
|
|
2417
|
-
|
|
2438
|
+
// Check if Web Workers are available AND the caller didn't opt out via
|
|
2439
|
+
// `useWorker: false`. The opt-out is load-bearing for `CallbackProver`
|
|
2440
|
+
// consumers — see the constructor doc above.
|
|
2441
|
+
if (this.useWorker && typeof Worker !== "undefined") {
|
|
2418
2442
|
console.log("WebClient: Web Workers are available.");
|
|
2419
2443
|
// Pick between the module and classic worker variants at runtime — see
|
|
2420
2444
|
// `WebClient.workerMode` below. Both branches keep the
|
|
@@ -2528,8 +2552,12 @@ class WebClient {
|
|
|
2528
2552
|
// Once the worker script has loaded, initialize the worker.
|
|
2529
2553
|
this.loaded.then(() => this.initializeWorker());
|
|
2530
2554
|
} else {
|
|
2531
|
-
console.log(
|
|
2532
|
-
|
|
2555
|
+
console.log(
|
|
2556
|
+
this.useWorker
|
|
2557
|
+
? "WebClient: Web Workers are not available."
|
|
2558
|
+
: "WebClient: Web Worker shim disabled by caller (useWorker=false)."
|
|
2559
|
+
);
|
|
2560
|
+
// Worker not available or explicitly disabled; set up fallback values.
|
|
2533
2561
|
this.worker = null;
|
|
2534
2562
|
this.pendingRequests = null;
|
|
2535
2563
|
this.loaded = Promise.resolve();
|
|
@@ -2656,9 +2684,19 @@ class WebClient {
|
|
|
2656
2684
|
* @param {string} seed - The seed for the account.
|
|
2657
2685
|
* @param {string | undefined} network - Optional name for the store. Setting this allows multiple clients to be used in the same browser.
|
|
2658
2686
|
* @param {string | undefined} logLevel - Optional log verbosity level ("error", "warn", "info", "debug", "trace", "off", or "none").
|
|
2687
|
+
* @param {boolean} [useWorker=true] - When `false`, bypass the Web Worker shim
|
|
2688
|
+
* and run WASM calls on the current thread. Required for `CallbackProver`
|
|
2689
|
+
* consumers (the worker path serializes the prover and loses the callback).
|
|
2659
2690
|
* @returns {Promise<WebClient>} The fully initialized WebClient.
|
|
2660
2691
|
*/
|
|
2661
|
-
static async createClient(
|
|
2692
|
+
static async createClient(
|
|
2693
|
+
rpcUrl,
|
|
2694
|
+
noteTransportUrl,
|
|
2695
|
+
seed,
|
|
2696
|
+
network,
|
|
2697
|
+
logLevel,
|
|
2698
|
+
useWorker = true
|
|
2699
|
+
) {
|
|
2662
2700
|
// Construct the instance (synchronously).
|
|
2663
2701
|
const instance = new WebClient(
|
|
2664
2702
|
rpcUrl,
|
|
@@ -2668,7 +2706,8 @@ class WebClient {
|
|
|
2668
2706
|
undefined,
|
|
2669
2707
|
undefined,
|
|
2670
2708
|
undefined,
|
|
2671
|
-
logLevel
|
|
2709
|
+
logLevel,
|
|
2710
|
+
useWorker
|
|
2672
2711
|
);
|
|
2673
2712
|
|
|
2674
2713
|
// Set up logging on the main thread before creating the client.
|
|
@@ -2699,6 +2738,9 @@ class WebClient {
|
|
|
2699
2738
|
* @param {Function | undefined} insertKeyCb - The insert key callback.
|
|
2700
2739
|
* @param {Function | undefined} signCb - The sign callback.
|
|
2701
2740
|
* @param {string | undefined} logLevel - Optional log verbosity level ("error", "warn", "info", "debug", "trace", "off", or "none").
|
|
2741
|
+
* @param {boolean} [useWorker=true] - When `false`, bypass the Web Worker shim
|
|
2742
|
+
* and run WASM calls on the current thread. Required for `CallbackProver`
|
|
2743
|
+
* consumers (the worker path serializes the prover and loses the callback).
|
|
2702
2744
|
* @returns {Promise<WebClient>} The fully initialized WebClient.
|
|
2703
2745
|
*/
|
|
2704
2746
|
static async createClientWithExternalKeystore(
|
|
@@ -2709,7 +2751,8 @@ class WebClient {
|
|
|
2709
2751
|
getKeyCb,
|
|
2710
2752
|
insertKeyCb,
|
|
2711
2753
|
signCb,
|
|
2712
|
-
logLevel
|
|
2754
|
+
logLevel,
|
|
2755
|
+
useWorker = true
|
|
2713
2756
|
) {
|
|
2714
2757
|
// Construct the instance (synchronously).
|
|
2715
2758
|
const instance = new WebClient(
|
|
@@ -2720,7 +2763,8 @@ class WebClient {
|
|
|
2720
2763
|
getKeyCb,
|
|
2721
2764
|
insertKeyCb,
|
|
2722
2765
|
signCb,
|
|
2723
|
-
logLevel
|
|
2766
|
+
logLevel,
|
|
2767
|
+
useWorker
|
|
2724
2768
|
);
|
|
2725
2769
|
|
|
2726
2770
|
// Set up logging on the main thread before creating the client.
|