@sip-protocol/sdk 0.7.2 → 0.7.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.
- package/LICENSE +21 -0
- package/README.md +267 -0
- package/dist/{TransportWebUSB-TQ7WZ4LE.mjs → TransportWebUSB-YQMAGJAJ.mjs} +12 -9
- package/dist/browser.d.mts +10 -4
- package/dist/browser.d.ts +10 -4
- package/dist/browser.js +48874 -18336
- package/dist/browser.mjs +674 -48
- package/dist/chunk-4GRJ5MAW.mjs +152 -0
- package/dist/chunk-5D7A3L3W.mjs +717 -0
- package/dist/chunk-64AYA5F5.mjs +7834 -0
- package/dist/chunk-GMDGB22A.mjs +379 -0
- package/dist/chunk-I534WKN7.mjs +328 -0
- package/dist/chunk-IBZVA5Y7.mjs +1003 -0
- package/dist/chunk-PRRZAWJE.mjs +223 -0
- package/dist/{chunk-UJCSKKID.mjs → chunk-XGB3TDIC.mjs} +13 -1
- package/dist/chunk-YWGJ77A2.mjs +33806 -0
- package/dist/{chunk-6WGN57S2.mjs → chunk-Z3K7W5S3.mjs} +48 -0
- package/dist/constants-LHAAUC2T.mjs +51 -0
- package/dist/dist-2OGQ7FED.mjs +3957 -0
- package/dist/dist-IFHPYLDX.mjs +254 -0
- package/dist/fulfillment_proof-ANHVPKTB.mjs +21 -0
- package/dist/funding_proof-ICFZ5LHY.mjs +21 -0
- package/dist/index-DXh2IGkz.d.ts +24681 -0
- package/dist/index-DeE1ZzA4.d.mts +24681 -0
- package/dist/index.d.mts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +48676 -17318
- package/dist/index.mjs +583 -19
- package/dist/interface-Bf7w1PLW.d.mts +679 -0
- package/dist/interface-Bf7w1PLW.d.ts +679 -0
- package/dist/{noir-DKfEzWy9.d.mts → noir-kzbLVTei.d.mts} +31 -21
- package/dist/{noir-DKfEzWy9.d.ts → noir-kzbLVTei.d.ts} +31 -21
- package/dist/proofs/halo2.d.mts +151 -0
- package/dist/proofs/halo2.d.ts +151 -0
- package/dist/proofs/halo2.js +350 -0
- package/dist/proofs/halo2.mjs +11 -0
- package/dist/proofs/kimchi.d.mts +160 -0
- package/dist/proofs/kimchi.d.ts +160 -0
- package/dist/proofs/kimchi.js +431 -0
- package/dist/proofs/kimchi.mjs +13 -0
- package/dist/proofs/noir.d.mts +1 -1
- package/dist/proofs/noir.d.ts +1 -1
- package/dist/proofs/noir.js +74 -18
- package/dist/proofs/noir.mjs +84 -24
- package/dist/solana-U3MEGU7W.mjs +280 -0
- package/dist/validity_proof-3POXLPNY.mjs +21 -0
- package/package.json +54 -21
- package/src/adapters/index.ts +41 -0
- package/src/adapters/jupiter.ts +571 -0
- package/src/adapters/near-intents.ts +135 -0
- package/src/advisor/advisor.ts +653 -0
- package/src/advisor/index.ts +54 -0
- package/src/advisor/tools.ts +303 -0
- package/src/advisor/types.ts +164 -0
- package/src/chains/ethereum/announcement.ts +536 -0
- package/src/chains/ethereum/bnb-optimizations.ts +474 -0
- package/src/chains/ethereum/commitment.ts +522 -0
- package/src/chains/ethereum/constants.ts +462 -0
- package/src/chains/ethereum/deployment.ts +596 -0
- package/src/chains/ethereum/gas-estimation.ts +538 -0
- package/src/chains/ethereum/index.ts +268 -0
- package/src/chains/ethereum/optimizations.ts +614 -0
- package/src/chains/ethereum/privacy-adapter.ts +855 -0
- package/src/chains/ethereum/registry.ts +584 -0
- package/src/chains/ethereum/rpc.ts +905 -0
- package/src/chains/ethereum/stealth.ts +491 -0
- package/src/chains/ethereum/token.ts +790 -0
- package/src/chains/ethereum/transfer.ts +637 -0
- package/src/chains/ethereum/types.ts +456 -0
- package/src/chains/ethereum/viewing-key.ts +455 -0
- package/src/chains/near/commitment.ts +608 -0
- package/src/chains/near/constants.ts +284 -0
- package/src/chains/near/function-call.ts +871 -0
- package/src/chains/near/history.ts +654 -0
- package/src/chains/near/implicit-account.ts +840 -0
- package/src/chains/near/index.ts +393 -0
- package/src/chains/near/native-transfer.ts +658 -0
- package/src/chains/near/nep141.ts +775 -0
- package/src/chains/near/privacy-adapter.ts +889 -0
- package/src/chains/near/resolver.ts +971 -0
- package/src/chains/near/rpc.ts +1016 -0
- package/src/chains/near/stealth.ts +419 -0
- package/src/chains/near/types.ts +317 -0
- package/src/chains/near/viewing-key.ts +876 -0
- package/src/chains/solana/anchor-transfer.ts +386 -0
- package/src/chains/solana/commitment.ts +577 -0
- package/src/chains/solana/constants.ts +126 -12
- package/src/chains/solana/ephemeral-keys.ts +543 -0
- package/src/chains/solana/index.ts +276 -1
- package/src/chains/solana/key-derivation.ts +418 -0
- package/src/chains/solana/kit-compat.ts +334 -0
- package/src/chains/solana/optimizations.ts +560 -0
- package/src/chains/solana/privacy-adapter.ts +605 -0
- package/src/chains/solana/providers/generic.ts +201 -0
- package/src/chains/solana/providers/helius-enhanced-types.ts +336 -0
- package/src/chains/solana/providers/helius-enhanced.ts +623 -0
- package/src/chains/solana/providers/helius.ts +402 -0
- package/src/chains/solana/providers/index.ts +85 -0
- package/src/chains/solana/providers/interface.ts +221 -0
- package/src/chains/solana/providers/quicknode.ts +409 -0
- package/src/chains/solana/providers/triton.ts +426 -0
- package/src/chains/solana/providers/webhook.ts +790 -0
- package/src/chains/solana/rpc-client.ts +1150 -0
- package/src/chains/solana/scan.ts +170 -73
- package/src/chains/solana/sol-transfer.ts +732 -0
- package/src/chains/solana/spl-transfer.ts +886 -0
- package/src/chains/solana/stealth-scanner.ts +703 -0
- package/src/chains/solana/sunspot-verifier.ts +453 -0
- package/src/chains/solana/transaction-builder.ts +755 -0
- package/src/chains/solana/transfer.ts +74 -5
- package/src/chains/solana/types.ts +77 -7
- package/src/chains/solana/utils.ts +110 -0
- package/src/chains/solana/viewing-key.ts +807 -0
- package/src/compliance/fireblocks.ts +921 -0
- package/src/compliance/index.ts +37 -0
- package/src/compliance/range-sas.ts +956 -0
- package/src/config/endpoints.ts +100 -0
- package/src/crypto.ts +11 -8
- package/src/errors.ts +82 -0
- package/src/evm/erc4337-relayer.ts +830 -0
- package/src/evm/index.ts +47 -0
- package/src/fees/calculator.ts +396 -0
- package/src/fees/index.ts +87 -0
- package/src/fees/near-contract.ts +429 -0
- package/src/fees/types.ts +268 -0
- package/src/index.ts +785 -1
- package/src/intent.ts +6 -3
- package/src/logger.ts +324 -0
- package/src/network/index.ts +80 -0
- package/src/network/proxy.ts +691 -0
- package/src/optimizations/index.ts +541 -0
- package/src/oracle/types.ts +1 -0
- package/src/privacy-backends/arcium-types.ts +727 -0
- package/src/privacy-backends/arcium.ts +719 -0
- package/src/privacy-backends/combined-privacy.ts +866 -0
- package/src/privacy-backends/cspl-token.ts +595 -0
- package/src/privacy-backends/cspl-types.ts +512 -0
- package/src/privacy-backends/cspl.ts +907 -0
- package/src/privacy-backends/health.ts +488 -0
- package/src/privacy-backends/inco-types.ts +323 -0
- package/src/privacy-backends/inco.ts +616 -0
- package/src/privacy-backends/index.ts +336 -0
- package/src/privacy-backends/interface.ts +906 -0
- package/src/privacy-backends/lru-cache.ts +343 -0
- package/src/privacy-backends/magicblock.ts +458 -0
- package/src/privacy-backends/mock.ts +258 -0
- package/src/privacy-backends/privacycash-types.ts +278 -0
- package/src/privacy-backends/privacycash.ts +456 -0
- package/src/privacy-backends/private-swap.ts +570 -0
- package/src/privacy-backends/rate-limiter.ts +683 -0
- package/src/privacy-backends/registry.ts +690 -0
- package/src/privacy-backends/router.ts +626 -0
- package/src/privacy-backends/shadowwire.ts +449 -0
- package/src/privacy-backends/sip-native.ts +256 -0
- package/src/privacy-logger.ts +191 -0
- package/src/production-safety.ts +373 -0
- package/src/proofs/aggregator.ts +1029 -0
- package/src/proofs/browser-composer.ts +1150 -0
- package/src/proofs/browser.ts +113 -25
- package/src/proofs/cache/index.ts +127 -0
- package/src/proofs/cache/interface.ts +545 -0
- package/src/proofs/cache/key-generator.ts +188 -0
- package/src/proofs/cache/lru-cache.ts +481 -0
- package/src/proofs/cache/multi-tier-cache.ts +575 -0
- package/src/proofs/cache/persistent-cache.ts +788 -0
- package/src/proofs/compliance-proof.ts +872 -0
- package/src/proofs/composer/base.ts +923 -0
- package/src/proofs/composer/index.ts +25 -0
- package/src/proofs/composer/interface.ts +518 -0
- package/src/proofs/composer/types.ts +383 -0
- package/src/proofs/converters/halo2.ts +452 -0
- package/src/proofs/converters/index.ts +208 -0
- package/src/proofs/converters/interface.ts +363 -0
- package/src/proofs/converters/kimchi.ts +462 -0
- package/src/proofs/converters/noir.ts +451 -0
- package/src/proofs/fallback.ts +888 -0
- package/src/proofs/halo2.ts +42 -0
- package/src/proofs/index.ts +471 -0
- package/src/proofs/interface.ts +13 -0
- package/src/proofs/kimchi.ts +42 -0
- package/src/proofs/lazy.ts +1004 -0
- package/src/proofs/mock.ts +25 -1
- package/src/proofs/noir.ts +111 -30
- package/src/proofs/orchestrator.ts +960 -0
- package/src/proofs/parallel/concurrency.ts +297 -0
- package/src/proofs/parallel/dependency-graph.ts +602 -0
- package/src/proofs/parallel/executor.ts +420 -0
- package/src/proofs/parallel/index.ts +131 -0
- package/src/proofs/parallel/interface.ts +685 -0
- package/src/proofs/parallel/worker-pool.ts +644 -0
- package/src/proofs/providers/halo2.ts +560 -0
- package/src/proofs/providers/index.ts +34 -0
- package/src/proofs/providers/kimchi.ts +641 -0
- package/src/proofs/validator.ts +881 -0
- package/src/proofs/verifier.ts +867 -0
- package/src/quantum/index.ts +112 -0
- package/src/quantum/winternitz-vault.ts +639 -0
- package/src/quantum/wots.ts +611 -0
- package/src/settlement/backends/direct-chain.ts +1 -0
- package/src/settlement/index.ts +9 -0
- package/src/settlement/router.ts +732 -46
- package/src/solana/index.ts +72 -0
- package/src/solana/jito-relayer.ts +687 -0
- package/src/solana/noir-verifier-types.ts +430 -0
- package/src/solana/noir-verifier.ts +816 -0
- package/src/stealth/address-derivation.ts +193 -0
- package/src/stealth/ed25519.ts +431 -0
- package/src/stealth/index.ts +233 -0
- package/src/stealth/meta-address.ts +221 -0
- package/src/stealth/secp256k1.ts +368 -0
- package/src/stealth/utils.ts +194 -0
- package/src/stealth.ts +50 -1504
- package/src/surveillance/algorithms/address-reuse.ts +143 -0
- package/src/surveillance/algorithms/cluster.ts +247 -0
- package/src/surveillance/algorithms/exchange.ts +295 -0
- package/src/surveillance/algorithms/temporal.ts +337 -0
- package/src/surveillance/analyzer.ts +442 -0
- package/src/surveillance/index.ts +64 -0
- package/src/surveillance/scoring.ts +372 -0
- package/src/surveillance/types.ts +264 -0
- package/src/sync/index.ts +106 -0
- package/src/sync/manager.ts +504 -0
- package/src/sync/mock-provider.ts +318 -0
- package/src/sync/oblivious.ts +625 -0
- package/src/tokens/index.ts +15 -0
- package/src/tokens/registry.ts +301 -0
- package/src/utils/deprecation.ts +94 -0
- package/src/utils/index.ts +9 -0
- package/src/wallet/ethereum/index.ts +68 -0
- package/src/wallet/ethereum/metamask-privacy.ts +420 -0
- package/src/wallet/ethereum/multi-wallet.ts +646 -0
- package/src/wallet/ethereum/privacy-adapter.ts +700 -0
- package/src/wallet/ethereum/types.ts +3 -1
- package/src/wallet/ethereum/walletconnect-adapter.ts +675 -0
- package/src/wallet/hardware/index.ts +10 -0
- package/src/wallet/hardware/ledger-privacy.ts +414 -0
- package/src/wallet/index.ts +71 -0
- package/src/wallet/near/adapter.ts +626 -0
- package/src/wallet/near/index.ts +86 -0
- package/src/wallet/near/meteor-wallet.ts +1153 -0
- package/src/wallet/near/my-near-wallet.ts +790 -0
- package/src/wallet/near/wallet-selector.ts +702 -0
- package/src/wallet/solana/adapter.ts +6 -4
- package/src/wallet/solana/index.ts +13 -0
- package/src/wallet/solana/privacy-adapter.ts +567 -0
- package/src/wallet/sui/types.ts +6 -4
- package/src/zcash/rpc-client.ts +13 -6
- package/dist/chunk-3INS3PR5.mjs +0 -884
- package/dist/chunk-3OVABDRH.mjs +0 -17096
- package/dist/chunk-DLDWZFYC.mjs +0 -1495
- package/dist/chunk-E6SZWREQ.mjs +0 -57
- package/dist/chunk-G33LB27A.mjs +0 -16166
- package/dist/chunk-HGU6HZRC.mjs +0 -231
- package/dist/chunk-L2K34JCU.mjs +0 -1496
- package/dist/chunk-SN4ZDTVW.mjs +0 -16166
- package/dist/constants-VOI7BSLK.mjs +0 -27
- package/dist/index-BYZbDjal.d.ts +0 -11390
- package/dist/index-CHB3KuOB.d.mts +0 -11859
- package/dist/index-CzWPI6Le.d.ts +0 -11859
- package/dist/index-xbWjohNq.d.mts +0 -11390
- package/dist/solana-5EMCTPTS.mjs +0 -46
- package/dist/solana-Q4NAVBTS.mjs +0 -46
package/dist/chunk-HGU6HZRC.mjs
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
// src/errors.ts
|
|
2
|
-
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
3
|
-
ErrorCode2["UNKNOWN"] = "SIP_1000";
|
|
4
|
-
ErrorCode2["INTERNAL"] = "SIP_1001";
|
|
5
|
-
ErrorCode2["NOT_IMPLEMENTED"] = "SIP_1002";
|
|
6
|
-
ErrorCode2["VALIDATION_FAILED"] = "SIP_2000";
|
|
7
|
-
ErrorCode2["INVALID_INPUT"] = "SIP_2001";
|
|
8
|
-
ErrorCode2["INVALID_CHAIN"] = "SIP_2002";
|
|
9
|
-
ErrorCode2["INVALID_PRIVACY_LEVEL"] = "SIP_2003";
|
|
10
|
-
ErrorCode2["INVALID_AMOUNT"] = "SIP_2004";
|
|
11
|
-
ErrorCode2["INVALID_HEX"] = "SIP_2005";
|
|
12
|
-
ErrorCode2["INVALID_KEY"] = "SIP_2006";
|
|
13
|
-
ErrorCode2["INVALID_ADDRESS"] = "SIP_2007";
|
|
14
|
-
ErrorCode2["MISSING_REQUIRED"] = "SIP_2008";
|
|
15
|
-
ErrorCode2["OUT_OF_RANGE"] = "SIP_2009";
|
|
16
|
-
ErrorCode2["CRYPTO_FAILED"] = "SIP_3000";
|
|
17
|
-
ErrorCode2["ENCRYPTION_FAILED"] = "SIP_3001";
|
|
18
|
-
ErrorCode2["DECRYPTION_FAILED"] = "SIP_3002";
|
|
19
|
-
ErrorCode2["KEY_DERIVATION_FAILED"] = "SIP_3003";
|
|
20
|
-
ErrorCode2["COMMITMENT_FAILED"] = "SIP_3004";
|
|
21
|
-
ErrorCode2["SIGNATURE_FAILED"] = "SIP_3005";
|
|
22
|
-
ErrorCode2["INVALID_CURVE_POINT"] = "SIP_3006";
|
|
23
|
-
ErrorCode2["INVALID_SCALAR"] = "SIP_3007";
|
|
24
|
-
ErrorCode2["INVALID_KEY_SIZE"] = "SIP_3008";
|
|
25
|
-
ErrorCode2["INVALID_ENCRYPTED_DATA"] = "SIP_3009";
|
|
26
|
-
ErrorCode2["INVALID_COMMITMENT"] = "SIP_3010";
|
|
27
|
-
ErrorCode2["INVALID_TIME_LOCK"] = "SIP_3011";
|
|
28
|
-
ErrorCode2["INVALID_SHARE"] = "SIP_3012";
|
|
29
|
-
ErrorCode2["INVALID_THRESHOLD"] = "SIP_3013";
|
|
30
|
-
ErrorCode2["CRYPTO_OPERATION_FAILED"] = "SIP_3014";
|
|
31
|
-
ErrorCode2["INVALID_FORMAT"] = "SIP_3015";
|
|
32
|
-
ErrorCode2["PROOF_FAILED"] = "SIP_4000";
|
|
33
|
-
ErrorCode2["PROOF_GENERATION_FAILED"] = "SIP_4001";
|
|
34
|
-
ErrorCode2["PROOF_VERIFICATION_FAILED"] = "SIP_4002";
|
|
35
|
-
ErrorCode2["PROOF_NOT_IMPLEMENTED"] = "SIP_4003";
|
|
36
|
-
ErrorCode2["PROOF_PROVIDER_NOT_READY"] = "SIP_4004";
|
|
37
|
-
ErrorCode2["INVALID_PROOF_PARAMS"] = "SIP_4005";
|
|
38
|
-
ErrorCode2["INTENT_FAILED"] = "SIP_5000";
|
|
39
|
-
ErrorCode2["INTENT_EXPIRED"] = "SIP_5001";
|
|
40
|
-
ErrorCode2["INTENT_CANCELLED"] = "SIP_5002";
|
|
41
|
-
ErrorCode2["INTENT_NOT_FOUND"] = "SIP_5003";
|
|
42
|
-
ErrorCode2["INTENT_INVALID_STATE"] = "SIP_5004";
|
|
43
|
-
ErrorCode2["PROOFS_REQUIRED"] = "SIP_5005";
|
|
44
|
-
ErrorCode2["QUOTE_EXPIRED"] = "SIP_5006";
|
|
45
|
-
ErrorCode2["NETWORK_FAILED"] = "SIP_6000";
|
|
46
|
-
ErrorCode2["NETWORK_TIMEOUT"] = "SIP_6001";
|
|
47
|
-
ErrorCode2["NETWORK_UNAVAILABLE"] = "SIP_6002";
|
|
48
|
-
ErrorCode2["RPC_ERROR"] = "SIP_6003";
|
|
49
|
-
ErrorCode2["API_ERROR"] = "SIP_6004";
|
|
50
|
-
ErrorCode2["RATE_LIMITED"] = "SIP_6005";
|
|
51
|
-
ErrorCode2["WALLET_ERROR"] = "SIP_7000";
|
|
52
|
-
ErrorCode2["WALLET_NOT_CONNECTED"] = "SIP_7001";
|
|
53
|
-
ErrorCode2["WALLET_CONNECTION_FAILED"] = "SIP_7002";
|
|
54
|
-
ErrorCode2["WALLET_SIGNING_FAILED"] = "SIP_7003";
|
|
55
|
-
ErrorCode2["WALLET_TRANSACTION_FAILED"] = "SIP_7004";
|
|
56
|
-
return ErrorCode2;
|
|
57
|
-
})(ErrorCode || {});
|
|
58
|
-
var SIPError = class extends Error {
|
|
59
|
-
/** Machine-readable error code */
|
|
60
|
-
code;
|
|
61
|
-
/** Additional debugging context */
|
|
62
|
-
context;
|
|
63
|
-
/** Timestamp when error was created */
|
|
64
|
-
timestamp;
|
|
65
|
-
constructor(message, code = "SIP_1000" /* UNKNOWN */, options) {
|
|
66
|
-
super(message, { cause: options?.cause });
|
|
67
|
-
this.name = "SIPError";
|
|
68
|
-
this.code = code;
|
|
69
|
-
this.context = options?.context;
|
|
70
|
-
this.timestamp = /* @__PURE__ */ new Date();
|
|
71
|
-
if (Error.captureStackTrace) {
|
|
72
|
-
Error.captureStackTrace(this, this.constructor);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Serialize error for logging or transmission
|
|
77
|
-
*/
|
|
78
|
-
toJSON() {
|
|
79
|
-
return {
|
|
80
|
-
name: this.name,
|
|
81
|
-
code: this.code,
|
|
82
|
-
message: this.message,
|
|
83
|
-
context: this.context,
|
|
84
|
-
cause: this.cause instanceof Error ? this.cause.message : void 0,
|
|
85
|
-
stack: this.stack,
|
|
86
|
-
timestamp: this.timestamp.toISOString()
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Create a string representation for logging
|
|
91
|
-
*/
|
|
92
|
-
toString() {
|
|
93
|
-
let result = `[${this.code}] ${this.name}: ${this.message}`;
|
|
94
|
-
if (this.cause instanceof Error) {
|
|
95
|
-
result += `
|
|
96
|
-
Caused by: ${this.cause.message}`;
|
|
97
|
-
}
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var ValidationError = class extends SIPError {
|
|
102
|
-
/** The field that failed validation (if applicable) */
|
|
103
|
-
field;
|
|
104
|
-
constructor(message, field, context, code = "SIP_2000" /* VALIDATION_FAILED */) {
|
|
105
|
-
const fullMessage = field ? `Validation failed for '${field}': ${message}` : `Validation failed: ${message}`;
|
|
106
|
-
super(fullMessage, code, { context });
|
|
107
|
-
this.name = "ValidationError";
|
|
108
|
-
this.field = field;
|
|
109
|
-
}
|
|
110
|
-
toJSON() {
|
|
111
|
-
return {
|
|
112
|
-
...super.toJSON(),
|
|
113
|
-
field: this.field
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
var CryptoError = class extends SIPError {
|
|
118
|
-
/** The cryptographic operation that failed */
|
|
119
|
-
operation;
|
|
120
|
-
constructor(message, code = "SIP_3000" /* CRYPTO_FAILED */, options) {
|
|
121
|
-
super(message, code, options);
|
|
122
|
-
this.name = "CryptoError";
|
|
123
|
-
this.operation = options?.operation;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
var EncryptionNotImplementedError = class extends CryptoError {
|
|
127
|
-
/** The type of encryption operation */
|
|
128
|
-
operationType;
|
|
129
|
-
/** Reference to the specification document */
|
|
130
|
-
specReference;
|
|
131
|
-
constructor(operation, specReference) {
|
|
132
|
-
const message = `${operation.charAt(0).toUpperCase() + operation.slice(1)}ion is not implemented. Real authenticated encryption (ChaCha20-Poly1305) is required. See specification: ${specReference}`;
|
|
133
|
-
super(message, "SIP_1002" /* NOT_IMPLEMENTED */, {
|
|
134
|
-
context: { operation, specReference }
|
|
135
|
-
});
|
|
136
|
-
this.name = "EncryptionNotImplementedError";
|
|
137
|
-
this.operationType = operation;
|
|
138
|
-
this.specReference = specReference;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
var ProofError = class extends SIPError {
|
|
142
|
-
/** The type of proof involved */
|
|
143
|
-
proofType;
|
|
144
|
-
constructor(message, code = "SIP_4000" /* PROOF_FAILED */, options) {
|
|
145
|
-
super(message, code, options);
|
|
146
|
-
this.name = "ProofError";
|
|
147
|
-
this.proofType = options?.proofType;
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
var ProofNotImplementedError = class extends ProofError {
|
|
151
|
-
/** Reference to the specification document */
|
|
152
|
-
specReference;
|
|
153
|
-
constructor(proofType, specReference) {
|
|
154
|
-
const message = `${proofType.charAt(0).toUpperCase() + proofType.slice(1)} proof generation is not implemented. Real ZK proofs are required for production use. See specification: ${specReference}`;
|
|
155
|
-
super(message, "SIP_4003" /* PROOF_NOT_IMPLEMENTED */, {
|
|
156
|
-
context: { specReference },
|
|
157
|
-
proofType
|
|
158
|
-
});
|
|
159
|
-
this.name = "ProofNotImplementedError";
|
|
160
|
-
this.specReference = specReference;
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
var IntentError = class extends SIPError {
|
|
164
|
-
/** The intent ID involved (if available) */
|
|
165
|
-
intentId;
|
|
166
|
-
constructor(message, code = "SIP_5000" /* INTENT_FAILED */, options) {
|
|
167
|
-
super(message, code, options);
|
|
168
|
-
this.name = "IntentError";
|
|
169
|
-
this.intentId = options?.intentId;
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
var NetworkError = class extends SIPError {
|
|
173
|
-
/** The endpoint that failed (if applicable) */
|
|
174
|
-
endpoint;
|
|
175
|
-
/** HTTP status code (if applicable) */
|
|
176
|
-
statusCode;
|
|
177
|
-
constructor(message, code = "SIP_6000" /* NETWORK_FAILED */, options) {
|
|
178
|
-
super(message, code, options);
|
|
179
|
-
this.name = "NetworkError";
|
|
180
|
-
this.endpoint = options?.endpoint;
|
|
181
|
-
this.statusCode = options?.statusCode;
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
function isSIPError(error) {
|
|
185
|
-
return error instanceof SIPError;
|
|
186
|
-
}
|
|
187
|
-
function hasErrorCode(error, code) {
|
|
188
|
-
return isSIPError(error) && error.code === code;
|
|
189
|
-
}
|
|
190
|
-
function wrapError(error, message, code = "SIP_1001" /* INTERNAL */, context) {
|
|
191
|
-
if (error instanceof SIPError) {
|
|
192
|
-
return error;
|
|
193
|
-
}
|
|
194
|
-
const cause = error instanceof Error ? error : new Error(String(error));
|
|
195
|
-
return new SIPError(message, code, { cause, context });
|
|
196
|
-
}
|
|
197
|
-
function getErrorMessage(error) {
|
|
198
|
-
if (error instanceof Error) {
|
|
199
|
-
return error.message;
|
|
200
|
-
}
|
|
201
|
-
return String(error);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// src/proofs/interface.ts
|
|
205
|
-
var ProofGenerationError = class extends Error {
|
|
206
|
-
proofType;
|
|
207
|
-
cause;
|
|
208
|
-
constructor(proofType, message, cause) {
|
|
209
|
-
super(`${proofType} proof generation failed: ${message}`);
|
|
210
|
-
this.name = "ProofGenerationError";
|
|
211
|
-
this.proofType = proofType;
|
|
212
|
-
this.cause = cause;
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export {
|
|
217
|
-
ErrorCode,
|
|
218
|
-
SIPError,
|
|
219
|
-
ValidationError,
|
|
220
|
-
CryptoError,
|
|
221
|
-
EncryptionNotImplementedError,
|
|
222
|
-
ProofError,
|
|
223
|
-
ProofNotImplementedError,
|
|
224
|
-
IntentError,
|
|
225
|
-
NetworkError,
|
|
226
|
-
isSIPError,
|
|
227
|
-
hasErrorCode,
|
|
228
|
-
wrapError,
|
|
229
|
-
getErrorMessage,
|
|
230
|
-
ProofGenerationError
|
|
231
|
-
};
|