@sip-protocol/sdk 0.2.9 → 0.3.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.
- package/dist/browser.d.mts +100 -2
- package/dist/browser.d.ts +100 -2
- package/dist/browser.js +2116 -321
- package/dist/browser.mjs +516 -16
- package/dist/chunk-4IFOPYJF.mjs +11950 -0
- package/dist/chunk-7IMRM7LN.mjs +12149 -0
- package/dist/chunk-JNNXNTSS.mjs +11034 -0
- package/dist/chunk-W3YXIQ7L.mjs +11950 -0
- package/dist/chunk-XLEPIR2P.mjs +884 -0
- package/dist/index-Ba7njCU3.d.ts +6925 -0
- package/dist/index-Co26-vbG.d.mts +6925 -0
- package/dist/index-DqZoHYKI.d.mts +6418 -0
- package/dist/index-dTtK_DTl.d.ts +6762 -0
- package/dist/index-jnkYu-Z4.d.mts +6762 -0
- package/dist/index-vB1N1mHd.d.ts +6418 -0
- package/dist/index.d.mts +2 -5897
- package/dist/index.d.ts +2 -5897
- package/dist/index.js +1334 -199
- package/dist/index.mjs +19 -1
- package/dist/noir-BTyLXLlZ.d.mts +467 -0
- package/dist/noir-BTyLXLlZ.d.ts +467 -0
- package/dist/proofs/noir.d.mts +1 -1
- package/dist/proofs/noir.d.ts +1 -1
- package/dist/proofs/noir.js +11 -112
- package/dist/proofs/noir.mjs +10 -13
- package/package.json +3 -3
- package/src/browser.ts +23 -0
- package/src/index.ts +32 -0
- package/src/proofs/browser-utils.ts +389 -0
- package/src/proofs/browser.ts +246 -19
- package/src/proofs/circuits/funding_proof.json +1 -1
- package/src/proofs/noir.ts +14 -14
- package/src/proofs/worker.ts +426 -0
- package/src/settlement/README.md +439 -0
- package/src/settlement/backends/direct-chain.ts +569 -0
- package/src/settlement/backends/index.ts +22 -0
- package/src/settlement/backends/near-intents.ts +480 -0
- package/src/settlement/backends/zcash-native.ts +516 -0
- package/src/settlement/index.ts +47 -0
- package/src/settlement/interface.ts +397 -0
- package/src/settlement/registry.ts +269 -0
- package/src/settlement/router.ts +383 -0
package/dist/browser.d.mts
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
export { ATTESTATION_VERSION, AttestationRequest, AttestationResult, BaseWalletAdapter, BridgeProvider, B as BrowserNoirProvider, BrowserNoirProviderConfig, CHAIN_NUMERIC_IDS, CommitmentPoint, ComplianceManager, CreateIntentOptions, CreatePaymentOptions, CryptoError, DEFAULT_THRESHOLD, DEFAULT_TOTAL_ORACLES, DerivationPath, EIP1193ConnectInfo, EIP1193Event, EIP1193Provider, EIP1193ProviderRpcError, EIP1193RequestArguments, EIP712Domain, EIP712TypeDefinition, EIP712TypedData, EIP712Types, EncryptionNotImplementedError, ErrorCode, EthereumAdapterConfig, EthereumChainId, EthereumChainIdType, EthereumChainMetadata, EthereumTokenMetadata, EthereumTransactionReceipt, EthereumTransactionRequest, EthereumWalletAdapter, EthereumWalletName, ExportedViewingKey, HardwareAccount, HardwareConnectionStatus, HardwareDeviceInfo, HardwareErrorCode, HardwareErrorCodeType, HardwareEthereumTx, HardwareSignRequest, HardwareSignature, HardwareTransport, HardwareWalletConfig, HardwareWalletError, HardwareWalletType, IntentBuilder, IntentError, LedgerConfig, LedgerModel, LedgerWalletAdapter, MockEthereumAdapter, MockEthereumAdapterConfig, MockHardwareConfig, MockLedgerAdapter, MockProofProvider, MockSolanaAdapter, MockSolanaAdapterConfig, MockSolver, MockSolverConfig, MockTrezorAdapter, MockWalletAdapter, NEARIntentsAdapter, NEARIntentsAdapterConfig, NetworkError, ORACLE_DOMAIN, OneClickClient, OracleAttestationMessage, OracleId, OracleInfo, OracleRegistry, OracleRegistryConfig, OracleSignature, OracleStatus, PaymentBuilder, PedersenCommitment, PreparedSwap, PriceFeed, PrivacyConfig, ProductionQuote, ProofError, ProofNotImplementedError, ProofProgressCallback, ReceivedNote, SIP, SIPConfig, SIPError, STABLECOIN_ADDRESSES, STABLECOIN_DECIMALS, STABLECOIN_INFO, SerializedError, ShieldedBalance, ShieldedSendParams, ShieldedSendResult, SignedOracleAttestation, SolanaAdapterConfig, SolanaCluster, SolanaConnection, SolanaPublicKey, SolanaSendOptions, SolanaSignature, SolanaTransaction, SolanaUnsignedTransaction, SolanaVersionedTransaction, SolanaWalletAdapter, SolanaWalletName, SolanaWalletProvider, StablecoinInfo, StealthCurve, SwapRequest, SwapResult, TransactionData, TransportType, Treasury, TrezorConfig, TrezorModel, TrezorWalletAdapter, ValidationError, VerificationResult, WalletAdapter, WalletError, ZcashQuote, ZcashQuoteParams, ZcashRPCClient, ZcashRPCError, ZcashShieldedService, ZcashShieldedServiceConfig, ZcashSwapParams, ZcashSwapResult, ZcashSwapService, ZcashSwapServiceConfig, ZcashSwapSourceChain, ZcashSwapSourceToken, ZcashSwapStatus, addBlindings, addCommitments, addOracle, attachProofs, base58ToHex, browserBytesToHex, browserHexToBytes, checkEd25519StealthAddress, checkStealthAddress, commit, commitZero, computeAttestationHash, createCommitment, createEthereumAdapter, createLedgerAdapter, createMockEthereumAdapter, createMockEthereumProvider, createMockLedgerAdapter, createMockSolanaAdapter, createMockSolanaConnection, createMockSolanaProvider, createMockSolver, createMockTrezorAdapter, createNEARIntentsAdapter, createOracleRegistry, createProductionSIP, createSIP, createShieldedIntent, createShieldedPayment, createSolanaAdapter, createTrezorAdapter, createWalletFactory, createZcashClient, createZcashShieldedService, createZcashSwapService, decodeStealthMetaAddress, decryptMemo, decryptWithViewing, deriveEd25519StealthPrivateKey, deriveOracleId, deriveStealthPrivateKey, deriveViewingKey, deserializeAttestationMessage, deserializeIntent, deserializePayment, detectEthereumWallets, detectSolanaWallets, ed25519PublicKeyToNearAddress, ed25519PublicKeyToSolanaAddress, encodeStealthMetaAddress, encryptForViewing, featureNotSupportedError, formatStablecoinAmount, fromHex, fromStablecoinUnits, generateBlinding, generateEd25519StealthAddress, generateEd25519StealthMetaAddress, generateIntentId, generateRandomBytes, generateStealthAddress, generateStealthMetaAddress, generateViewingKey, getActiveOracles, getAvailableTransports, getBrowserInfo, getChainNumericId, getChainsForStablecoin, getCurveForChain, getDefaultRpcEndpoint, getDerivationPath, getErrorMessage, getEthereumProvider, getGenerators, getIntentSummary, getPaymentSummary, getPaymentTimeRemaining, getPrivacyConfig, getPrivacyDescription, getSolanaProvider, getStablecoin, getStablecoinInfo, getStablecoinsForChain, getSupportedStablecoins, getTimeRemaining, hasEnoughOracles, hasErrorCode, hasRequiredProofs, hash, hexToNumber, isBrowser, isEd25519Chain, isExpired, isNonNegativeAmount, isPaymentExpired, isPrivateWalletAdapter, isSIPError, isStablecoin, isStablecoinOnChain, isValidAmount, isValidChainId, isValidCompressedPublicKey, isValidEd25519PublicKey, isValidHex, isValidHexLength, isValidNearAccountId, isValidNearImplicitAddress, isValidPrivacyLevel, isValidPrivateKey, isValidScalar, isValidSlippage, isValidSolanaAddress, isValidStealthMetaAddress, nearAddressToEd25519PublicKey, normalizeAddress, notConnectedError, publicKeyToEthAddress, registerWallet, removeOracle, secureWipe, secureWipeAll, serializeAttestationMessage, serializeIntent, serializePayment, signAttestationMessage, solanaAddressToEd25519PublicKey, solanaPublicKeyToHex, subtractBlindings, subtractCommitments, supportsSharedArrayBuffer, supportsWebBluetooth, supportsWebHID, supportsWebUSB, supportsWebWorkers, toHex, toStablecoinUnits, trackIntent, trackPayment, updateOracleStatus, validateAsset, validateCreateIntentParams, validateIntentInput, validateIntentOutput, validateScalar, validateViewingKey, verifyAttestation, verifyCommitment, verifyOpening, verifyOracleSignature, walletRegistry, withSecureBuffer, withSecureBufferSync, wrapError } from './index.mjs';
|
|
2
|
-
|
|
1
|
+
export { bj as ATTESTATION_VERSION, bv as AttestationRequest, bw as AttestationResult, bT as BackendCapabilities, cT as BaseWalletAdapter, cr as BridgeProvider, B as BrowserNoirProvider, t as BrowserNoirProviderConfig, bm as CHAIN_NUMERIC_IDS, aM as CommitmentPoint, cS as ComplianceManager, $ as CreateIntentOptions, cP as CreatePaymentOptions, C as CryptoError, bk as DEFAULT_THRESHOLD, bl as DEFAULT_TOTAL_ORACLES, dq as DerivationPath, dT as EIP1193ConnectInfo, dS as EIP1193Event, dQ as EIP1193Provider, dU as EIP1193ProviderRpcError, dR as EIP1193RequestArguments, dV as EIP712Domain, dW as EIP712TypeDefinition, dY as EIP712TypedData, dX as EIP712Types, w as EncryptionNotImplementedError, E as ErrorCode, e2 as EthereumAdapterConfig, dm as EthereumChainId, e3 as EthereumChainIdType, e0 as EthereumChainMetadata, d$ as EthereumTokenMetadata, d_ as EthereumTransactionReceipt, dZ as EthereumTransactionRequest, da as EthereumWalletAdapter, e1 as EthereumWalletName, ci as ExportedViewingKey, c0 as FindBestRouteParams, eh as HardwareAccount, e8 as HardwareConnectionStatus, ea as HardwareDeviceInfo, dn as HardwareErrorCode, ej as HardwareErrorCodeType, ef as HardwareEthereumTx, ee as HardwareSignRequest, eg as HardwareSignature, ei as HardwareTransport, eb as HardwareWalletConfig, dp as HardwareWalletError, e5 as HardwareWalletType, L as IntentBuilder, I as IntentError, ec as LedgerConfig, e6 as LedgerModel, dw as LedgerWalletAdapter, p as MobileBrowser, q as MobileDeviceInfo, M as MobilePlatform, r as MobileWASMCompatibility, dc as MockEthereumAdapter, e4 as MockEthereumAdapterConfig, ek as MockHardwareConfig, dA as MockLedgerAdapter, b3 as MockProofProvider, d2 as MockSolanaAdapter, dP as MockSolanaAdapterConfig, bF as MockSolver, bH as MockSolverConfig, dB as MockTrezorAdapter, cU as MockWalletAdapter, bz as NEARIntentsAdapter, bE as NEARIntentsAdapterConfig, c1 as NEARIntentsBackend, N as NetworkError, bi as ORACLE_DOMAIN, by as OneClickClient, bq as OracleAttestationMessage, bn as OracleId, bp as OracleInfo, bt as OracleRegistry, bu as OracleRegistryConfig, br as OracleSignature, bo as OracleStatus, ct as PaymentBuilder, aL as PedersenCommitment, bC as PreparedSwap, cs as PriceFeed, ar as PrivacyConfig, K as ProductionQuote, u as ProofError, v as ProofNotImplementedError, P as ProofProgressCallback, b$ as QuoteComparison, cg as ReceivedNote, bX as Route, b_ as RouteWithQuote, F as SIP, J as SIPConfig, S as SIPError, cD as STABLECOIN_ADDRESSES, cE as STABLECOIN_DECIMALS, cC as STABLECOIN_INFO, D as SerializedError, bU as SettlementBackend, bV as SettlementBackendFactory, bL as SettlementBackendName, bW as SettlementBackendRegistry, bN as SettlementQuote, bM as SettlementQuoteParams, bJ as SettlementRegistry, bK as SettlementRegistryError, bQ as SettlementSwapParams, bR as SettlementSwapResult, bO as SettlementSwapRoute, bP as SettlementSwapRouteStep, ch as ShieldedBalance, ce as ShieldedSendParams, cf as ShieldedSendResult, bs as SignedOracleAttestation, bY as SmartRouter, dK as SolanaAdapterConfig, dJ as SolanaCluster, dL as SolanaConnection, dE as SolanaPublicKey, dM as SolanaSendOptions, dO as SolanaSignature, dF as SolanaTransaction, dN as SolanaUnsignedTransaction, dG as SolanaVersionedTransaction, d0 as SolanaWalletAdapter, dI as SolanaWalletName, dH as SolanaWalletProvider, cQ as StablecoinInfo, ak as StealthCurve, bB as SwapRequest, bD as SwapResult, bI as SwapStatus, bS as SwapStatusResponse, as as TransactionData, e9 as TransportType, cR as Treasury, ed as TrezorConfig, e7 as TrezorModel, dy as TrezorWalletAdapter, V as ValidationError, bx as VerificationResult, W as WalletAdapter, cV as WalletError, c3 as ZcashNativeBackend, c5 as ZcashNativeBackendConfig, cn as ZcashQuote, cm as ZcashQuoteParams, c6 as ZcashRPCClient, c7 as ZcashRPCError, c9 as ZcashShieldedService, cd as ZcashShieldedServiceConfig, co as ZcashSwapParams, cp as ZcashSwapResult, cb as ZcashSwapService, cj as ZcashSwapServiceConfig, ck as ZcashSwapSourceChain, cl as ZcashSwapSourceToken, cq as ZcashSwapStatus, aH as addBlindings, aF as addCommitments, b9 as addOracle, Q as attachProofs, d9 as base58ToHex, b as browserBytesToHex, h as browserHexToBytes, ac as checkEd25519StealthAddress, f as checkMobileWASMCompatibility, a3 as checkStealthAddress, aC as commit, aE as commitZero, bg as computeAttestationHash, at as createCommitment, db as createEthereumAdapter, dx as createLedgerAdapter, dd as createMockEthereumAdapter, de as createMockEthereumProvider, dC as createMockLedgerAdapter, d3 as createMockSolanaAdapter, d5 as createMockSolanaConnection, d4 as createMockSolanaProvider, bG as createMockSolver, dD as createMockTrezorAdapter, bA as createNEARIntentsAdapter, c2 as createNEARIntentsBackend, b8 as createOracleRegistry, H as createProductionSIP, G as createSIP, O as createShieldedIntent, cu as createShieldedPayment, bZ as createSmartRouter, d1 as createSolanaAdapter, dz as createTrezorAdapter, c_ as createWalletFactory, c8 as createZcashClient, c4 as createZcashNativeBackend, ca as createZcashShieldedService, cc as createZcashSwapService, a5 as decodeStealthMetaAddress, cv as decryptMemo, ap as decryptWithViewing, ab as deriveEd25519StealthPrivateKey, b7 as deriveOracleId, a2 as deriveStealthPrivateKey, an as deriveViewingKey, bf as deserializeAttestationMessage, Z as deserializeIntent, cA as deserializePayment, dg as detectEthereumWallets, c as detectMobileBrowser, d as detectMobilePlatform, d7 as detectSolanaWallets, ag as ed25519PublicKeyToNearAddress, ad as ed25519PublicKeyToSolanaAddress, a4 as encodeStealthMetaAddress, ao as encryptForViewing, cX as featureNotSupportedError, cO as formatStablecoinAmount, di as fromHex, cN as fromStablecoinUnits, aK as generateBlinding, aa as generateEd25519StealthAddress, a9 as generateEd25519StealthMetaAddress, av as generateIntentId, ax as generateRandomBytes, a1 as generateStealthAddress, a0 as generateStealthMetaAddress, am as generateViewingKey, bc as getActiveOracles, dv as getAvailableTransports, g as getBrowserInfo, j as getBrowserVersion, bh as getChainNumericId, cL as getChainsForStablecoin, a8 as getCurveForChain, dl as getDefaultRpcEndpoint, dr as getDerivationPath, A as getErrorMessage, df as getEthereumProvider, aJ as getGenerators, _ as getIntentSummary, e as getMobileDeviceInfo, k as getOSVersion, cB as getPaymentSummary, cy as getPaymentTimeRemaining, al as getPrivacyConfig, aq as getPrivacyDescription, d6 as getSolanaProvider, cF as getStablecoin, cI as getStablecoinInfo, cG as getStablecoinsForChain, cJ as getSupportedStablecoins, X as getTimeRemaining, bd as hasEnoughOracles, y as hasErrorCode, R as hasRequiredProofs, aw as hash, dj as hexToNumber, i as isBrowser, a7 as isEd25519Chain, U as isExpired, aS as isNonNegativeAmount, cx as isPaymentExpired, c$ as isPrivateWalletAdapter, x as isSIPError, cH as isStablecoin, cK as isStablecoinOnChain, l as isTablet, aR as isValidAmount, aN as isValidChainId, aV as isValidCompressedPublicKey, aW as isValidEd25519PublicKey, aP as isValidHex, aQ as isValidHexLength, aj as isValidNearAccountId, ai as isValidNearImplicitAddress, aO as isValidPrivacyLevel, aX as isValidPrivateKey, aY as isValidScalar, aT as isValidSlippage, af as isValidSolanaAddress, aU as isValidStealthMetaAddress, ah as nearAddressToEd25519PublicKey, dk as normalizeAddress, cW as notConnectedError, a6 as publicKeyToEthAddress, cZ as registerWallet, ba as removeOracle, ay as secureWipe, az as secureWipeAll, be as serializeAttestationMessage, Y as serializeIntent, cz as serializePayment, b6 as signAttestationMessage, ae as solanaAddressToEd25519PublicKey, d8 as solanaPublicKeyToHex, aI as subtractBlindings, aG as subtractCommitments, a as supportsSharedArrayBuffer, m as supportsTouch, o as supportsWASMBulkMemory, n as supportsWASMSimd, du as supportsWebBluetooth, dt as supportsWebHID, ds as supportsWebUSB, s as supportsWebWorkers, dh as toHex, cM as toStablecoinUnits, T as trackIntent, cw as trackPayment, bb as updateOracleStatus, a_ as validateAsset, aZ as validateCreateIntentParams, a$ as validateIntentInput, b0 as validateIntentOutput, b2 as validateScalar, b1 as validateViewingKey, b4 as verifyAttestation, au as verifyCommitment, aD as verifyOpening, b5 as verifyOracleSignature, cY as walletRegistry, aA as withSecureBuffer, aB as withSecureBufferSync, z as wrapError } from './index-Co26-vbG.mjs';
|
|
2
|
+
import { F as FundingProofParams, V as ValidityProofParams, a as FulfillmentProofParams, P as ProofResult } from './noir-BTyLXLlZ.mjs';
|
|
3
|
+
export { N as NoirProviderConfig, O as OracleAttestation, d as ProofFramework, b as ProofGenerationError, c as ProofProvider } from './noir-BTyLXLlZ.mjs';
|
|
3
4
|
export { Asset, AuditLogEntry, AuditScope, AuditorRegistration, AuditorViewingKey, BatchPaymentRecipient, BatchPaymentRequest, ChainId, Commitment, ComplianceConfig, ComplianceReport, ComplianceRole, CreateBatchProposalParams, CreateComplianceConfigParams, CreateIntentParams, CreatePaymentParams, CreatePaymentProposalParams, CreateTreasuryParams, DefuseAssetId, DisclosedTransaction, DisclosureRequest, FulfillmentCommitment, FulfillmentProof, FulfillmentRequest, FulfillmentResult, FulfillmentStatus, GenerateReportParams, Hash, HexString, WalletAdapter as IWalletAdapter, IntentStatus, NATIVE_TOKENS, OneClickConfig, OneClickDepositMode, OneClickErrorCode, OneClickQuoteRequest, OneClickQuoteResponse, OneClickStatusResponse, OneClickSwapStatus, OneClickSwapType, PaymentPurpose, PaymentReceipt, PaymentStatus, PaymentStatusType, PrivacyLevel, PrivateWalletAdapter, ProposalSignature, ProposalStatus, ProposalStatusType, ProposalType, Quote, RegisterAuditorParams, ReportData, ReportFormat, ReportStatus, ReportStatusType, ReportType, SIPSolver, SIP_VERSION, ShieldedIntent, ShieldedPayment, Signature, SignedTransaction, Solver, SolverCapabilities, SolverEvent, SolverEventListener, SolverQuote, SolverVisibleIntent, StablecoinSymbol, StealthAddress, StealthAddressRecovery, StealthMetaAddress, SwapRoute, SwapRouteStep, TrackedIntent, TrackedPayment, TransactionReceipt, TreasuryBalance, TreasuryConfig, TreasuryMember, TreasuryProposal, TreasuryRole, TreasuryTransaction, UnsignedTransaction, ViewingKey, WalletAccountChangedEvent, WalletAdapterFactory, WalletChainChangedEvent, WalletConnectEvent, WalletConnectionState, WalletDisconnectEvent, WalletErrorCode, WalletErrorEvent, WalletEvent, WalletEventHandler, WalletEventType, WalletInfo, WalletRegistryEntry, WalletShieldedSendParams, WalletShieldedSendResult, ZKProof, ZcashAccountAddress, ZcashAccountBalance, ZcashAddressInfo, ZcashAddressType, ZcashBlock, ZcashBlockHeader, ZcashBlockchainInfo, ZcashConfig, ZcashErrorCode, ZcashNetwork, ZcashNetworkInfo, ZcashNewAccount, ZcashOperation, ZcashOperationError, ZcashOperationStatus, ZcashOperationTxResult, ZcashPool, ZcashPoolBalance, ZcashPrivacyPolicy, ZcashReceiverType, ZcashSendRecipient, ZcashShieldedSendParams, ZcashUnspentNote, isPrivate, supportsViewingKey } from '@sip-protocol/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Proof Generation Web Worker
|
|
8
|
+
*
|
|
9
|
+
* Runs proof generation off the main thread to keep UI responsive.
|
|
10
|
+
* Communicates via postMessage with the main thread.
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/sip-protocol/sip-protocol/issues/140
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
type WorkerMessageType = 'init' | 'generateFundingProof' | 'generateValidityProof' | 'generateFulfillmentProof' | 'destroy';
|
|
16
|
+
interface WorkerRequest {
|
|
17
|
+
id: string;
|
|
18
|
+
type: WorkerMessageType;
|
|
19
|
+
params?: FundingProofParams | ValidityProofParams | FulfillmentProofParams;
|
|
20
|
+
config?: {
|
|
21
|
+
verbose?: boolean;
|
|
22
|
+
oraclePublicKey?: {
|
|
23
|
+
x: number[];
|
|
24
|
+
y: number[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface WorkerResponse {
|
|
29
|
+
id: string;
|
|
30
|
+
type: 'success' | 'error' | 'progress';
|
|
31
|
+
result?: ProofResult;
|
|
32
|
+
error?: string;
|
|
33
|
+
progress?: {
|
|
34
|
+
stage: string;
|
|
35
|
+
percent: number;
|
|
36
|
+
message: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create inline worker code as a blob URL
|
|
41
|
+
* This approach works with most bundlers without special configuration
|
|
42
|
+
*/
|
|
43
|
+
declare function createWorkerBlobURL(): string;
|
|
44
|
+
/**
|
|
45
|
+
* ProofWorker class for managing Web Worker proof generation
|
|
46
|
+
*
|
|
47
|
+
* Provides a clean API for generating proofs in a Web Worker,
|
|
48
|
+
* with progress callbacks and automatic fallback to main thread.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const worker = new ProofWorker()
|
|
53
|
+
* await worker.initialize()
|
|
54
|
+
*
|
|
55
|
+
* const result = await worker.generateProof('funding', params, (progress) => {
|
|
56
|
+
* console.log(`${progress.stage}: ${progress.percent}%`)
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare class ProofWorker {
|
|
61
|
+
private worker;
|
|
62
|
+
private pendingRequests;
|
|
63
|
+
private _isReady;
|
|
64
|
+
private requestCounter;
|
|
65
|
+
/**
|
|
66
|
+
* Check if Web Workers are supported
|
|
67
|
+
*/
|
|
68
|
+
static isSupported(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Check if worker is initialized and ready
|
|
71
|
+
*/
|
|
72
|
+
get isReady(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Initialize the worker
|
|
75
|
+
*/
|
|
76
|
+
initialize(config?: {
|
|
77
|
+
verbose?: boolean;
|
|
78
|
+
oraclePublicKey?: {
|
|
79
|
+
x: number[];
|
|
80
|
+
y: number[];
|
|
81
|
+
};
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Generate a proof using the worker
|
|
85
|
+
*/
|
|
86
|
+
generateProof(type: 'funding' | 'validity' | 'fulfillment', params: FundingProofParams | ValidityProofParams | FulfillmentProofParams, onProgress?: (progress: NonNullable<WorkerResponse['progress']>) => void): Promise<ProofResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Destroy the worker and free resources
|
|
89
|
+
*/
|
|
90
|
+
destroy(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Send a request to the worker
|
|
93
|
+
*/
|
|
94
|
+
private sendRequest;
|
|
95
|
+
/**
|
|
96
|
+
* Handle messages from the worker
|
|
97
|
+
*/
|
|
98
|
+
private handleWorkerMessage;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { FulfillmentProofParams, FundingProofParams, ProofResult, ProofWorker, ValidityProofParams, type WorkerMessageType, type WorkerRequest, type WorkerResponse, createWorkerBlobURL };
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
export { ATTESTATION_VERSION, AttestationRequest, AttestationResult, BaseWalletAdapter, BridgeProvider, B as BrowserNoirProvider, BrowserNoirProviderConfig, CHAIN_NUMERIC_IDS, CommitmentPoint, ComplianceManager, CreateIntentOptions, CreatePaymentOptions, CryptoError, DEFAULT_THRESHOLD, DEFAULT_TOTAL_ORACLES, DerivationPath, EIP1193ConnectInfo, EIP1193Event, EIP1193Provider, EIP1193ProviderRpcError, EIP1193RequestArguments, EIP712Domain, EIP712TypeDefinition, EIP712TypedData, EIP712Types, EncryptionNotImplementedError, ErrorCode, EthereumAdapterConfig, EthereumChainId, EthereumChainIdType, EthereumChainMetadata, EthereumTokenMetadata, EthereumTransactionReceipt, EthereumTransactionRequest, EthereumWalletAdapter, EthereumWalletName, ExportedViewingKey, HardwareAccount, HardwareConnectionStatus, HardwareDeviceInfo, HardwareErrorCode, HardwareErrorCodeType, HardwareEthereumTx, HardwareSignRequest, HardwareSignature, HardwareTransport, HardwareWalletConfig, HardwareWalletError, HardwareWalletType, IntentBuilder, IntentError, LedgerConfig, LedgerModel, LedgerWalletAdapter, MockEthereumAdapter, MockEthereumAdapterConfig, MockHardwareConfig, MockLedgerAdapter, MockProofProvider, MockSolanaAdapter, MockSolanaAdapterConfig, MockSolver, MockSolverConfig, MockTrezorAdapter, MockWalletAdapter, NEARIntentsAdapter, NEARIntentsAdapterConfig, NetworkError, ORACLE_DOMAIN, OneClickClient, OracleAttestationMessage, OracleId, OracleInfo, OracleRegistry, OracleRegistryConfig, OracleSignature, OracleStatus, PaymentBuilder, PedersenCommitment, PreparedSwap, PriceFeed, PrivacyConfig, ProductionQuote, ProofError, ProofNotImplementedError, ProofProgressCallback, ReceivedNote, SIP, SIPConfig, SIPError, STABLECOIN_ADDRESSES, STABLECOIN_DECIMALS, STABLECOIN_INFO, SerializedError, ShieldedBalance, ShieldedSendParams, ShieldedSendResult, SignedOracleAttestation, SolanaAdapterConfig, SolanaCluster, SolanaConnection, SolanaPublicKey, SolanaSendOptions, SolanaSignature, SolanaTransaction, SolanaUnsignedTransaction, SolanaVersionedTransaction, SolanaWalletAdapter, SolanaWalletName, SolanaWalletProvider, StablecoinInfo, StealthCurve, SwapRequest, SwapResult, TransactionData, TransportType, Treasury, TrezorConfig, TrezorModel, TrezorWalletAdapter, ValidationError, VerificationResult, WalletAdapter, WalletError, ZcashQuote, ZcashQuoteParams, ZcashRPCClient, ZcashRPCError, ZcashShieldedService, ZcashShieldedServiceConfig, ZcashSwapParams, ZcashSwapResult, ZcashSwapService, ZcashSwapServiceConfig, ZcashSwapSourceChain, ZcashSwapSourceToken, ZcashSwapStatus, addBlindings, addCommitments, addOracle, attachProofs, base58ToHex, browserBytesToHex, browserHexToBytes, checkEd25519StealthAddress, checkStealthAddress, commit, commitZero, computeAttestationHash, createCommitment, createEthereumAdapter, createLedgerAdapter, createMockEthereumAdapter, createMockEthereumProvider, createMockLedgerAdapter, createMockSolanaAdapter, createMockSolanaConnection, createMockSolanaProvider, createMockSolver, createMockTrezorAdapter, createNEARIntentsAdapter, createOracleRegistry, createProductionSIP, createSIP, createShieldedIntent, createShieldedPayment, createSolanaAdapter, createTrezorAdapter, createWalletFactory, createZcashClient, createZcashShieldedService, createZcashSwapService, decodeStealthMetaAddress, decryptMemo, decryptWithViewing, deriveEd25519StealthPrivateKey, deriveOracleId, deriveStealthPrivateKey, deriveViewingKey, deserializeAttestationMessage, deserializeIntent, deserializePayment, detectEthereumWallets, detectSolanaWallets, ed25519PublicKeyToNearAddress, ed25519PublicKeyToSolanaAddress, encodeStealthMetaAddress, encryptForViewing, featureNotSupportedError, formatStablecoinAmount, fromHex, fromStablecoinUnits, generateBlinding, generateEd25519StealthAddress, generateEd25519StealthMetaAddress, generateIntentId, generateRandomBytes, generateStealthAddress, generateStealthMetaAddress, generateViewingKey, getActiveOracles, getAvailableTransports, getBrowserInfo, getChainNumericId, getChainsForStablecoin, getCurveForChain, getDefaultRpcEndpoint, getDerivationPath, getErrorMessage, getEthereumProvider, getGenerators, getIntentSummary, getPaymentSummary, getPaymentTimeRemaining, getPrivacyConfig, getPrivacyDescription, getSolanaProvider, getStablecoin, getStablecoinInfo, getStablecoinsForChain, getSupportedStablecoins, getTimeRemaining, hasEnoughOracles, hasErrorCode, hasRequiredProofs, hash, hexToNumber, isBrowser, isEd25519Chain, isExpired, isNonNegativeAmount, isPaymentExpired, isPrivateWalletAdapter, isSIPError, isStablecoin, isStablecoinOnChain, isValidAmount, isValidChainId, isValidCompressedPublicKey, isValidEd25519PublicKey, isValidHex, isValidHexLength, isValidNearAccountId, isValidNearImplicitAddress, isValidPrivacyLevel, isValidPrivateKey, isValidScalar, isValidSlippage, isValidSolanaAddress, isValidStealthMetaAddress, nearAddressToEd25519PublicKey, normalizeAddress, notConnectedError, publicKeyToEthAddress, registerWallet, removeOracle, secureWipe, secureWipeAll, serializeAttestationMessage, serializeIntent, serializePayment, signAttestationMessage, solanaAddressToEd25519PublicKey, solanaPublicKeyToHex, subtractBlindings, subtractCommitments, supportsSharedArrayBuffer, supportsWebBluetooth, supportsWebHID, supportsWebUSB, supportsWebWorkers, toHex, toStablecoinUnits, trackIntent, trackPayment, updateOracleStatus, validateAsset, validateCreateIntentParams, validateIntentInput, validateIntentOutput, validateScalar, validateViewingKey, verifyAttestation, verifyCommitment, verifyOpening, verifyOracleSignature, walletRegistry, withSecureBuffer, withSecureBufferSync, wrapError } from './index.js';
|
|
2
|
-
|
|
1
|
+
export { bj as ATTESTATION_VERSION, bv as AttestationRequest, bw as AttestationResult, bT as BackendCapabilities, cT as BaseWalletAdapter, cr as BridgeProvider, B as BrowserNoirProvider, t as BrowserNoirProviderConfig, bm as CHAIN_NUMERIC_IDS, aM as CommitmentPoint, cS as ComplianceManager, $ as CreateIntentOptions, cP as CreatePaymentOptions, C as CryptoError, bk as DEFAULT_THRESHOLD, bl as DEFAULT_TOTAL_ORACLES, dq as DerivationPath, dT as EIP1193ConnectInfo, dS as EIP1193Event, dQ as EIP1193Provider, dU as EIP1193ProviderRpcError, dR as EIP1193RequestArguments, dV as EIP712Domain, dW as EIP712TypeDefinition, dY as EIP712TypedData, dX as EIP712Types, w as EncryptionNotImplementedError, E as ErrorCode, e2 as EthereumAdapterConfig, dm as EthereumChainId, e3 as EthereumChainIdType, e0 as EthereumChainMetadata, d$ as EthereumTokenMetadata, d_ as EthereumTransactionReceipt, dZ as EthereumTransactionRequest, da as EthereumWalletAdapter, e1 as EthereumWalletName, ci as ExportedViewingKey, c0 as FindBestRouteParams, eh as HardwareAccount, e8 as HardwareConnectionStatus, ea as HardwareDeviceInfo, dn as HardwareErrorCode, ej as HardwareErrorCodeType, ef as HardwareEthereumTx, ee as HardwareSignRequest, eg as HardwareSignature, ei as HardwareTransport, eb as HardwareWalletConfig, dp as HardwareWalletError, e5 as HardwareWalletType, L as IntentBuilder, I as IntentError, ec as LedgerConfig, e6 as LedgerModel, dw as LedgerWalletAdapter, p as MobileBrowser, q as MobileDeviceInfo, M as MobilePlatform, r as MobileWASMCompatibility, dc as MockEthereumAdapter, e4 as MockEthereumAdapterConfig, ek as MockHardwareConfig, dA as MockLedgerAdapter, b3 as MockProofProvider, d2 as MockSolanaAdapter, dP as MockSolanaAdapterConfig, bF as MockSolver, bH as MockSolverConfig, dB as MockTrezorAdapter, cU as MockWalletAdapter, bz as NEARIntentsAdapter, bE as NEARIntentsAdapterConfig, c1 as NEARIntentsBackend, N as NetworkError, bi as ORACLE_DOMAIN, by as OneClickClient, bq as OracleAttestationMessage, bn as OracleId, bp as OracleInfo, bt as OracleRegistry, bu as OracleRegistryConfig, br as OracleSignature, bo as OracleStatus, ct as PaymentBuilder, aL as PedersenCommitment, bC as PreparedSwap, cs as PriceFeed, ar as PrivacyConfig, K as ProductionQuote, u as ProofError, v as ProofNotImplementedError, P as ProofProgressCallback, b$ as QuoteComparison, cg as ReceivedNote, bX as Route, b_ as RouteWithQuote, F as SIP, J as SIPConfig, S as SIPError, cD as STABLECOIN_ADDRESSES, cE as STABLECOIN_DECIMALS, cC as STABLECOIN_INFO, D as SerializedError, bU as SettlementBackend, bV as SettlementBackendFactory, bL as SettlementBackendName, bW as SettlementBackendRegistry, bN as SettlementQuote, bM as SettlementQuoteParams, bJ as SettlementRegistry, bK as SettlementRegistryError, bQ as SettlementSwapParams, bR as SettlementSwapResult, bO as SettlementSwapRoute, bP as SettlementSwapRouteStep, ch as ShieldedBalance, ce as ShieldedSendParams, cf as ShieldedSendResult, bs as SignedOracleAttestation, bY as SmartRouter, dK as SolanaAdapterConfig, dJ as SolanaCluster, dL as SolanaConnection, dE as SolanaPublicKey, dM as SolanaSendOptions, dO as SolanaSignature, dF as SolanaTransaction, dN as SolanaUnsignedTransaction, dG as SolanaVersionedTransaction, d0 as SolanaWalletAdapter, dI as SolanaWalletName, dH as SolanaWalletProvider, cQ as StablecoinInfo, ak as StealthCurve, bB as SwapRequest, bD as SwapResult, bI as SwapStatus, bS as SwapStatusResponse, as as TransactionData, e9 as TransportType, cR as Treasury, ed as TrezorConfig, e7 as TrezorModel, dy as TrezorWalletAdapter, V as ValidationError, bx as VerificationResult, W as WalletAdapter, cV as WalletError, c3 as ZcashNativeBackend, c5 as ZcashNativeBackendConfig, cn as ZcashQuote, cm as ZcashQuoteParams, c6 as ZcashRPCClient, c7 as ZcashRPCError, c9 as ZcashShieldedService, cd as ZcashShieldedServiceConfig, co as ZcashSwapParams, cp as ZcashSwapResult, cb as ZcashSwapService, cj as ZcashSwapServiceConfig, ck as ZcashSwapSourceChain, cl as ZcashSwapSourceToken, cq as ZcashSwapStatus, aH as addBlindings, aF as addCommitments, b9 as addOracle, Q as attachProofs, d9 as base58ToHex, b as browserBytesToHex, h as browserHexToBytes, ac as checkEd25519StealthAddress, f as checkMobileWASMCompatibility, a3 as checkStealthAddress, aC as commit, aE as commitZero, bg as computeAttestationHash, at as createCommitment, db as createEthereumAdapter, dx as createLedgerAdapter, dd as createMockEthereumAdapter, de as createMockEthereumProvider, dC as createMockLedgerAdapter, d3 as createMockSolanaAdapter, d5 as createMockSolanaConnection, d4 as createMockSolanaProvider, bG as createMockSolver, dD as createMockTrezorAdapter, bA as createNEARIntentsAdapter, c2 as createNEARIntentsBackend, b8 as createOracleRegistry, H as createProductionSIP, G as createSIP, O as createShieldedIntent, cu as createShieldedPayment, bZ as createSmartRouter, d1 as createSolanaAdapter, dz as createTrezorAdapter, c_ as createWalletFactory, c8 as createZcashClient, c4 as createZcashNativeBackend, ca as createZcashShieldedService, cc as createZcashSwapService, a5 as decodeStealthMetaAddress, cv as decryptMemo, ap as decryptWithViewing, ab as deriveEd25519StealthPrivateKey, b7 as deriveOracleId, a2 as deriveStealthPrivateKey, an as deriveViewingKey, bf as deserializeAttestationMessage, Z as deserializeIntent, cA as deserializePayment, dg as detectEthereumWallets, c as detectMobileBrowser, d as detectMobilePlatform, d7 as detectSolanaWallets, ag as ed25519PublicKeyToNearAddress, ad as ed25519PublicKeyToSolanaAddress, a4 as encodeStealthMetaAddress, ao as encryptForViewing, cX as featureNotSupportedError, cO as formatStablecoinAmount, di as fromHex, cN as fromStablecoinUnits, aK as generateBlinding, aa as generateEd25519StealthAddress, a9 as generateEd25519StealthMetaAddress, av as generateIntentId, ax as generateRandomBytes, a1 as generateStealthAddress, a0 as generateStealthMetaAddress, am as generateViewingKey, bc as getActiveOracles, dv as getAvailableTransports, g as getBrowserInfo, j as getBrowserVersion, bh as getChainNumericId, cL as getChainsForStablecoin, a8 as getCurveForChain, dl as getDefaultRpcEndpoint, dr as getDerivationPath, A as getErrorMessage, df as getEthereumProvider, aJ as getGenerators, _ as getIntentSummary, e as getMobileDeviceInfo, k as getOSVersion, cB as getPaymentSummary, cy as getPaymentTimeRemaining, al as getPrivacyConfig, aq as getPrivacyDescription, d6 as getSolanaProvider, cF as getStablecoin, cI as getStablecoinInfo, cG as getStablecoinsForChain, cJ as getSupportedStablecoins, X as getTimeRemaining, bd as hasEnoughOracles, y as hasErrorCode, R as hasRequiredProofs, aw as hash, dj as hexToNumber, i as isBrowser, a7 as isEd25519Chain, U as isExpired, aS as isNonNegativeAmount, cx as isPaymentExpired, c$ as isPrivateWalletAdapter, x as isSIPError, cH as isStablecoin, cK as isStablecoinOnChain, l as isTablet, aR as isValidAmount, aN as isValidChainId, aV as isValidCompressedPublicKey, aW as isValidEd25519PublicKey, aP as isValidHex, aQ as isValidHexLength, aj as isValidNearAccountId, ai as isValidNearImplicitAddress, aO as isValidPrivacyLevel, aX as isValidPrivateKey, aY as isValidScalar, aT as isValidSlippage, af as isValidSolanaAddress, aU as isValidStealthMetaAddress, ah as nearAddressToEd25519PublicKey, dk as normalizeAddress, cW as notConnectedError, a6 as publicKeyToEthAddress, cZ as registerWallet, ba as removeOracle, ay as secureWipe, az as secureWipeAll, be as serializeAttestationMessage, Y as serializeIntent, cz as serializePayment, b6 as signAttestationMessage, ae as solanaAddressToEd25519PublicKey, d8 as solanaPublicKeyToHex, aI as subtractBlindings, aG as subtractCommitments, a as supportsSharedArrayBuffer, m as supportsTouch, o as supportsWASMBulkMemory, n as supportsWASMSimd, du as supportsWebBluetooth, dt as supportsWebHID, ds as supportsWebUSB, s as supportsWebWorkers, dh as toHex, cM as toStablecoinUnits, T as trackIntent, cw as trackPayment, bb as updateOracleStatus, a_ as validateAsset, aZ as validateCreateIntentParams, a$ as validateIntentInput, b0 as validateIntentOutput, b2 as validateScalar, b1 as validateViewingKey, b4 as verifyAttestation, au as verifyCommitment, aD as verifyOpening, b5 as verifyOracleSignature, cY as walletRegistry, aA as withSecureBuffer, aB as withSecureBufferSync, z as wrapError } from './index-Ba7njCU3.js';
|
|
2
|
+
import { F as FundingProofParams, V as ValidityProofParams, a as FulfillmentProofParams, P as ProofResult } from './noir-BTyLXLlZ.js';
|
|
3
|
+
export { N as NoirProviderConfig, O as OracleAttestation, d as ProofFramework, b as ProofGenerationError, c as ProofProvider } from './noir-BTyLXLlZ.js';
|
|
3
4
|
export { Asset, AuditLogEntry, AuditScope, AuditorRegistration, AuditorViewingKey, BatchPaymentRecipient, BatchPaymentRequest, ChainId, Commitment, ComplianceConfig, ComplianceReport, ComplianceRole, CreateBatchProposalParams, CreateComplianceConfigParams, CreateIntentParams, CreatePaymentParams, CreatePaymentProposalParams, CreateTreasuryParams, DefuseAssetId, DisclosedTransaction, DisclosureRequest, FulfillmentCommitment, FulfillmentProof, FulfillmentRequest, FulfillmentResult, FulfillmentStatus, GenerateReportParams, Hash, HexString, WalletAdapter as IWalletAdapter, IntentStatus, NATIVE_TOKENS, OneClickConfig, OneClickDepositMode, OneClickErrorCode, OneClickQuoteRequest, OneClickQuoteResponse, OneClickStatusResponse, OneClickSwapStatus, OneClickSwapType, PaymentPurpose, PaymentReceipt, PaymentStatus, PaymentStatusType, PrivacyLevel, PrivateWalletAdapter, ProposalSignature, ProposalStatus, ProposalStatusType, ProposalType, Quote, RegisterAuditorParams, ReportData, ReportFormat, ReportStatus, ReportStatusType, ReportType, SIPSolver, SIP_VERSION, ShieldedIntent, ShieldedPayment, Signature, SignedTransaction, Solver, SolverCapabilities, SolverEvent, SolverEventListener, SolverQuote, SolverVisibleIntent, StablecoinSymbol, StealthAddress, StealthAddressRecovery, StealthMetaAddress, SwapRoute, SwapRouteStep, TrackedIntent, TrackedPayment, TransactionReceipt, TreasuryBalance, TreasuryConfig, TreasuryMember, TreasuryProposal, TreasuryRole, TreasuryTransaction, UnsignedTransaction, ViewingKey, WalletAccountChangedEvent, WalletAdapterFactory, WalletChainChangedEvent, WalletConnectEvent, WalletConnectionState, WalletDisconnectEvent, WalletErrorCode, WalletErrorEvent, WalletEvent, WalletEventHandler, WalletEventType, WalletInfo, WalletRegistryEntry, WalletShieldedSendParams, WalletShieldedSendResult, ZKProof, ZcashAccountAddress, ZcashAccountBalance, ZcashAddressInfo, ZcashAddressType, ZcashBlock, ZcashBlockHeader, ZcashBlockchainInfo, ZcashConfig, ZcashErrorCode, ZcashNetwork, ZcashNetworkInfo, ZcashNewAccount, ZcashOperation, ZcashOperationError, ZcashOperationStatus, ZcashOperationTxResult, ZcashPool, ZcashPoolBalance, ZcashPrivacyPolicy, ZcashReceiverType, ZcashSendRecipient, ZcashShieldedSendParams, ZcashUnspentNote, isPrivate, supportsViewingKey } from '@sip-protocol/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Proof Generation Web Worker
|
|
8
|
+
*
|
|
9
|
+
* Runs proof generation off the main thread to keep UI responsive.
|
|
10
|
+
* Communicates via postMessage with the main thread.
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/sip-protocol/sip-protocol/issues/140
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
type WorkerMessageType = 'init' | 'generateFundingProof' | 'generateValidityProof' | 'generateFulfillmentProof' | 'destroy';
|
|
16
|
+
interface WorkerRequest {
|
|
17
|
+
id: string;
|
|
18
|
+
type: WorkerMessageType;
|
|
19
|
+
params?: FundingProofParams | ValidityProofParams | FulfillmentProofParams;
|
|
20
|
+
config?: {
|
|
21
|
+
verbose?: boolean;
|
|
22
|
+
oraclePublicKey?: {
|
|
23
|
+
x: number[];
|
|
24
|
+
y: number[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface WorkerResponse {
|
|
29
|
+
id: string;
|
|
30
|
+
type: 'success' | 'error' | 'progress';
|
|
31
|
+
result?: ProofResult;
|
|
32
|
+
error?: string;
|
|
33
|
+
progress?: {
|
|
34
|
+
stage: string;
|
|
35
|
+
percent: number;
|
|
36
|
+
message: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create inline worker code as a blob URL
|
|
41
|
+
* This approach works with most bundlers without special configuration
|
|
42
|
+
*/
|
|
43
|
+
declare function createWorkerBlobURL(): string;
|
|
44
|
+
/**
|
|
45
|
+
* ProofWorker class for managing Web Worker proof generation
|
|
46
|
+
*
|
|
47
|
+
* Provides a clean API for generating proofs in a Web Worker,
|
|
48
|
+
* with progress callbacks and automatic fallback to main thread.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const worker = new ProofWorker()
|
|
53
|
+
* await worker.initialize()
|
|
54
|
+
*
|
|
55
|
+
* const result = await worker.generateProof('funding', params, (progress) => {
|
|
56
|
+
* console.log(`${progress.stage}: ${progress.percent}%`)
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare class ProofWorker {
|
|
61
|
+
private worker;
|
|
62
|
+
private pendingRequests;
|
|
63
|
+
private _isReady;
|
|
64
|
+
private requestCounter;
|
|
65
|
+
/**
|
|
66
|
+
* Check if Web Workers are supported
|
|
67
|
+
*/
|
|
68
|
+
static isSupported(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Check if worker is initialized and ready
|
|
71
|
+
*/
|
|
72
|
+
get isReady(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Initialize the worker
|
|
75
|
+
*/
|
|
76
|
+
initialize(config?: {
|
|
77
|
+
verbose?: boolean;
|
|
78
|
+
oraclePublicKey?: {
|
|
79
|
+
x: number[];
|
|
80
|
+
y: number[];
|
|
81
|
+
};
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Generate a proof using the worker
|
|
85
|
+
*/
|
|
86
|
+
generateProof(type: 'funding' | 'validity' | 'fulfillment', params: FundingProofParams | ValidityProofParams | FulfillmentProofParams, onProgress?: (progress: NonNullable<WorkerResponse['progress']>) => void): Promise<ProofResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Destroy the worker and free resources
|
|
89
|
+
*/
|
|
90
|
+
destroy(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Send a request to the worker
|
|
93
|
+
*/
|
|
94
|
+
private sendRequest;
|
|
95
|
+
/**
|
|
96
|
+
* Handle messages from the worker
|
|
97
|
+
*/
|
|
98
|
+
private handleWorkerMessage;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { FulfillmentProofParams, FundingProofParams, ProofResult, ProofWorker, ValidityProofParams, type WorkerMessageType, type WorkerRequest, type WorkerResponse, createWorkerBlobURL };
|