@ocap/tx-pipeline 1.30.26 → 1.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/appchain-sovereign-hub.d.mts +160 -0
- package/esm/appchain-sovereign-hub.mjs +348 -0
- package/esm/arcvault-external-adapter.d.mts +166 -0
- package/esm/arcvault-external-adapter.mjs +376 -0
- package/esm/encrypted-nft-envelope.d.mts +172 -0
- package/esm/encrypted-nft-envelope.mjs +458 -0
- package/esm/evm-simplified-bridge.d.mts +1370 -0
- package/esm/evm-simplified-bridge.mjs +3875 -0
- package/esm/give-to-mint-karma.d.mts +472 -0
- package/esm/give-to-mint-karma.mjs +1057 -0
- package/esm/helpers/replay-guard.d.mts +15 -0
- package/esm/helpers/replay-guard.mjs +23 -0
- package/esm/index.d.mts +10 -5
- package/esm/index.mjs +14 -10
- package/esm/legacy-protocol-sunset.d.mts +251 -0
- package/esm/legacy-protocol-sunset.mjs +1519 -0
- package/esm/library.d.mts +16 -0
- package/esm/library.mjs +17 -0
- package/esm/native-abt-exchange.d.mts +2055 -0
- package/esm/native-abt-exchange.mjs +7250 -0
- package/esm/ofac-screening.d.mts +17 -0
- package/esm/ofac-screening.mjs +39 -0
- package/esm/pipes/anti-land-attack.mjs +1 -1
- package/esm/pipes/decode-itx.mjs +46 -4
- package/esm/pipes/decode-tx.d.mts +2 -3
- package/esm/pipes/decode-tx.mjs +56 -115
- package/esm/pipes/extract-signer.mjs +2 -2
- package/esm/pipes/extract-state.mjs +14 -3
- package/esm/pipes/post-execution-invariant-gate.d.mts +61 -0
- package/esm/pipes/post-execution-invariant-gate.mjs +789 -0
- package/esm/pipes/pre-flight-waf.d.mts +73 -0
- package/esm/pipes/pre-flight-waf.mjs +756 -0
- package/esm/pipes/take-state-snapshot.mjs +3 -2
- package/esm/pipes/update-owner.mjs +39 -4
- package/esm/pipes/verify-account-migration.mjs +14 -4
- package/esm/pipes/verify-blocked.mjs +1 -1
- package/esm/pipes/verify-delegation.d.mts +22 -3
- package/esm/pipes/verify-delegation.mjs +259 -36
- package/esm/pipes/verify-list-size.mjs +1 -1
- package/esm/pipes/verify-multisig-v2.mjs +15 -7
- package/esm/pipes/verify-multisig.mjs +15 -7
- package/esm/pipes/verify-sender.mjs +1 -1
- package/esm/pipes/verify-signature.mjs +35 -6
- package/esm/pipes/verify-signer.mjs +2 -2
- package/esm/pipes/verify-state-diff.mjs +3 -3
- package/esm/pipes/verify-token-access.mjs +1 -1
- package/esm/pipes/verify-token-balance.mjs +13 -5
- package/esm/pipes/verify-transferrable.d.mts +8 -1
- package/esm/pipes/verify-transferrable.mjs +3 -3
- package/esm/pipes/verify-tx-input.mjs +2 -2
- package/esm/pipes/verify-tx-size.mjs +46 -2
- package/esm/pipes/verify-tx.mjs +5 -7
- package/esm/pipes/verify-updater.mjs +1 -1
- package/esm/social-economy-factories.d.mts +346 -0
- package/esm/social-economy-factories.mjs +845 -0
- package/esm/super-suites-foundation.d.mts +513 -0
- package/esm/super-suites-foundation.mjs +1241 -0
- package/esm/transaction-block.d.mts +471 -0
- package/esm/transaction-block.mjs +1906 -0
- package/esm/uniswap-erc7683-solver.d.mts +201 -0
- package/esm/uniswap-erc7683-solver.mjs +321 -0
- package/esm/uniswap-lp-copilot.d.mts +113 -0
- package/esm/uniswap-lp-copilot.mjs +320 -0
- package/esm/uniswap-router.d.mts +335 -0
- package/esm/uniswap-router.mjs +578 -0
- package/esm/uniswap-token-factory-graduation.d.mts +187 -0
- package/esm/uniswap-token-factory-graduation.mjs +426 -0
- package/esm/uniswap-v4-hook.d.mts +173 -0
- package/esm/uniswap-v4-hook.mjs +517 -0
- package/lib/appchain-sovereign-hub.cjs +352 -0
- package/lib/appchain-sovereign-hub.d.cts +160 -0
- package/lib/arcvault-external-adapter.cjs +383 -0
- package/lib/arcvault-external-adapter.d.cts +166 -0
- package/lib/encrypted-nft-envelope.cjs +477 -0
- package/lib/encrypted-nft-envelope.d.cts +172 -0
- package/lib/evm-simplified-bridge.cjs +3943 -0
- package/lib/evm-simplified-bridge.d.cts +1370 -0
- package/lib/give-to-mint-karma.cjs +1084 -0
- package/lib/give-to-mint-karma.d.cts +472 -0
- package/lib/helpers/replay-guard.cjs +27 -0
- package/lib/helpers/replay-guard.d.cts +15 -0
- package/lib/index.cjs +49 -16
- package/lib/index.d.cts +10 -5
- package/lib/legacy-protocol-sunset.cjs +1543 -0
- package/lib/legacy-protocol-sunset.d.cts +251 -0
- package/lib/library.cjs +303 -0
- package/lib/library.d.cts +16 -0
- package/lib/native-abt-exchange.cjs +7322 -0
- package/lib/native-abt-exchange.d.cts +2055 -0
- package/lib/ofac-screening.cjs +42 -0
- package/lib/ofac-screening.d.cts +17 -0
- package/lib/pipes/anti-land-attack.cjs +2 -2
- package/lib/pipes/decode-itx.cjs +46 -4
- package/lib/pipes/decode-itx.d.cts +1 -1
- package/lib/pipes/decode-tx.cjs +55 -116
- package/lib/pipes/decode-tx.d.cts +3 -4
- package/lib/pipes/extract-signer.cjs +2 -2
- package/lib/pipes/extract-state.cjs +14 -3
- package/lib/pipes/post-execution-invariant-gate.cjs +800 -0
- package/lib/pipes/post-execution-invariant-gate.d.cts +61 -0
- package/lib/pipes/pre-flight-waf.cjs +772 -0
- package/lib/pipes/pre-flight-waf.d.cts +73 -0
- package/lib/pipes/take-state-snapshot.cjs +3 -2
- package/lib/pipes/update-owner.cjs +40 -5
- package/lib/pipes/update-owner.d.cts +1 -1
- package/lib/pipes/verify-account-migration.cjs +14 -4
- package/lib/pipes/verify-blocked.cjs +1 -1
- package/lib/pipes/verify-delegation.cjs +259 -36
- package/lib/pipes/verify-delegation.d.cts +22 -3
- package/lib/pipes/verify-list-size.cjs +1 -1
- package/lib/pipes/verify-multisig-v2.cjs +15 -7
- package/lib/pipes/verify-multisig.cjs +15 -7
- package/lib/pipes/verify-sender.cjs +1 -1
- package/lib/pipes/verify-service-fee.d.cts +1 -1
- package/lib/pipes/verify-signature.cjs +35 -6
- package/lib/pipes/verify-signature.d.cts +1 -1
- package/lib/pipes/verify-signer.cjs +2 -2
- package/lib/pipes/verify-state-diff.cjs +4 -4
- package/lib/pipes/verify-token-access.cjs +2 -2
- package/lib/pipes/verify-token-balance.cjs +13 -5
- package/lib/pipes/verify-transferrable.cjs +3 -3
- package/lib/pipes/verify-transferrable.d.cts +8 -1
- package/lib/pipes/verify-tx-input.cjs +3 -3
- package/lib/pipes/verify-tx-size.cjs +46 -2
- package/lib/pipes/verify-tx-size.d.cts +1 -1
- package/lib/pipes/verify-tx.cjs +6 -8
- package/lib/pipes/verify-tx.d.cts +1 -1
- package/lib/pipes/verify-updater.cjs +1 -1
- package/lib/social-economy-factories.cjs +852 -0
- package/lib/social-economy-factories.d.cts +346 -0
- package/lib/super-suites-foundation.cjs +1257 -0
- package/lib/super-suites-foundation.d.cts +513 -0
- package/lib/transaction-block.cjs +1941 -0
- package/lib/transaction-block.d.cts +471 -0
- package/lib/uniswap-erc7683-solver.cjs +327 -0
- package/lib/uniswap-erc7683-solver.d.cts +201 -0
- package/lib/uniswap-lp-copilot.cjs +328 -0
- package/lib/uniswap-lp-copilot.d.cts +113 -0
- package/lib/uniswap-router.cjs +593 -0
- package/lib/uniswap-router.d.cts +335 -0
- package/lib/uniswap-token-factory-graduation.cjs +431 -0
- package/lib/uniswap-token-factory-graduation.d.cts +187 -0
- package/lib/uniswap-v4-hook.cjs +527 -0
- package/lib/uniswap-v4-hook.d.cts +173 -0
- package/package.json +11 -10
- package/esm/helpers/dedup-height.d.mts +0 -16
- package/esm/helpers/dedup-height.mjs +0 -61
- package/lib/helpers/dedup-height.cjs +0 -72
- package/lib/helpers/dedup-height.d.cts +0 -16
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
//#region src/uniswap-v4-hook.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Maximum allowed TTL for stateless edge-signed Hook tickets (15 minutes = 900 seconds).
|
|
4
|
+
*/
|
|
5
|
+
declare const MAX_HOOK_TICKET_TTL_SECONDS = 900;
|
|
6
|
+
/**
|
|
7
|
+
* Default minimum continuous holding blocks on OCAP to prevent flash-borrow VIP ticket abuse.
|
|
8
|
+
*/
|
|
9
|
+
declare const DEFAULT_MIN_HOLDING_BLOCKS = 300;
|
|
10
|
+
/**
|
|
11
|
+
* Minimum percentage of MEV penalty surcharge that MUST be returned to Uniswap V4 LPs (80% = 8000 bps).
|
|
12
|
+
*/
|
|
13
|
+
declare const MIN_LP_MEV_REBATE_SHARE_BPS = 8000;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum dynamic LP fee override in Uniswap V4 (5.00% = 500 bps).
|
|
16
|
+
*/
|
|
17
|
+
declare const MAX_V4_DYNAMIC_FEE_BPS = 500;
|
|
18
|
+
type HookFeeTierName = 'VIP_LOYALTY' | 'ABT_STAKER' | 'VERIFIED_DID' | 'STANDARD_RETAIL' | 'MEV_SURCHARGE';
|
|
19
|
+
type V4PoolComplianceMode = 'LOYALTY_PUBLIC' | 'PERMISSIONED_RWA';
|
|
20
|
+
interface OcapHookTicketClaims {
|
|
21
|
+
chainId: string;
|
|
22
|
+
poolId: string;
|
|
23
|
+
hookAddress: string;
|
|
24
|
+
traderAddress: string;
|
|
25
|
+
holderDid: string;
|
|
26
|
+
tier: HookFeeTierName;
|
|
27
|
+
feeBpsOverride: number;
|
|
28
|
+
maxAmountIn: string;
|
|
29
|
+
holdingBlocks: number;
|
|
30
|
+
kycVerified: boolean;
|
|
31
|
+
kycIssuerDid?: string;
|
|
32
|
+
issuedAt: number;
|
|
33
|
+
validUntil: number;
|
|
34
|
+
nonce: string;
|
|
35
|
+
}
|
|
36
|
+
interface SignedOcapHookTicket {
|
|
37
|
+
claims: OcapHookTicketClaims;
|
|
38
|
+
signerDid: string;
|
|
39
|
+
signerPk: string;
|
|
40
|
+
signature: string;
|
|
41
|
+
digest: string;
|
|
42
|
+
}
|
|
43
|
+
interface V4PoolHookConfig {
|
|
44
|
+
chainId: string;
|
|
45
|
+
poolId: string;
|
|
46
|
+
hookAddress: string;
|
|
47
|
+
poolMode: V4PoolComplianceMode;
|
|
48
|
+
authorizedSignerDids: string[];
|
|
49
|
+
trustedKycIssuerDids?: string[];
|
|
50
|
+
authorizedPoolCreator?: string;
|
|
51
|
+
/** Standard public swap fee in bps (e.g. 30 = 0.30%) */
|
|
52
|
+
baseFeeBps: number;
|
|
53
|
+
/** Discounted fee for VIP NFT / ABT stakers (e.g. 5 = 0.05%) */
|
|
54
|
+
vipFeeBps: number;
|
|
55
|
+
/** Discounted fee for ABT stakers (e.g. 10 = 0.10%) */
|
|
56
|
+
abtStakerFeeBps: number;
|
|
57
|
+
/** Discounted fee for verified DID holders (e.g. 15 = 0.15%) */
|
|
58
|
+
verifiedDidFeeBps: number;
|
|
59
|
+
/** Dynamic penalty fee for unverified large/MEV swaps (e.g. 100 = 1.00%) */
|
|
60
|
+
mevPenaltyFeeBps: number;
|
|
61
|
+
/** Swap input threshold above which unverified orders trigger MEV surcharge */
|
|
62
|
+
unverifiedMevThresholdAmountIn: string;
|
|
63
|
+
/** Minimum continuous holding blocks required for VIP_LOYALTY or ABT_STAKER tiers */
|
|
64
|
+
minHoldingBlocks?: number;
|
|
65
|
+
/** Share of MEV surcharge returned directly to Uniswap V4 LPs (must be >= 8000 bps = 80%) */
|
|
66
|
+
lpMevRebateShareBps?: number;
|
|
67
|
+
ofacBlocklist?: Iterable<string>;
|
|
68
|
+
}
|
|
69
|
+
interface BeforeSwapEvaluationResult {
|
|
70
|
+
allowed: boolean;
|
|
71
|
+
appliedTier: HookFeeTierName;
|
|
72
|
+
lpFeeBpsOverride: number;
|
|
73
|
+
usedFallbackBaseFee: boolean;
|
|
74
|
+
synchronousCrossChainRpcCalls: 0;
|
|
75
|
+
feeBreakdown: {
|
|
76
|
+
totalFeeAmount: string;
|
|
77
|
+
baseLpFeeAmount: string;
|
|
78
|
+
mevSurchargeAmount: string;
|
|
79
|
+
lpMevRebateAmount: string;
|
|
80
|
+
protocolEcosystemShareAmount: string;
|
|
81
|
+
lpMevRebateShareBps: number;
|
|
82
|
+
};
|
|
83
|
+
fallbackReason?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Recursively scans an object or array for any forbidden PII field names (case/snake/hyphen-insensitive)
|
|
87
|
+
* and enforces a strict maximum nesting depth of 8 to guarantee Zero-PII On-Chain (GDPR Safe Harbor).
|
|
88
|
+
*/
|
|
89
|
+
declare function assertZeroPiiInHookData(payload: unknown, depth?: number): void;
|
|
90
|
+
/**
|
|
91
|
+
* Computes the canonical digest for an OCAP Uniswap V4 Hook attestation ticket.
|
|
92
|
+
*/
|
|
93
|
+
declare function computeOcapHookTicketDigest(claims: OcapHookTicketClaims): string;
|
|
94
|
+
/**
|
|
95
|
+
* Edge Attestation Signer: Issues a short-lived, stateless Hook ticket from an OCAP Read-Replica.
|
|
96
|
+
* Enforces:
|
|
97
|
+
* - Zero PII on-chain (GDPR Safe Harbor)
|
|
98
|
+
* - Time-weighted holding guard (`holdingBlocks >= minHoldingBlocks`) to block flash-borrow VIP abuse
|
|
99
|
+
* - Maximum TTL cap (`<= 900` seconds)
|
|
100
|
+
* - OFAC sanctions screening
|
|
101
|
+
*/
|
|
102
|
+
declare function issueOcapHookTicket(claimsInput: OcapHookTicketClaims, signerWallet: {
|
|
103
|
+
address: string;
|
|
104
|
+
publicKey: string;
|
|
105
|
+
sign: (data: Uint8Array | string, hash?: boolean) => Promise<string> | string;
|
|
106
|
+
}, options?: {
|
|
107
|
+
minHoldingBlocks?: number;
|
|
108
|
+
trustedKycIssuerDids?: string[];
|
|
109
|
+
ofacBlocklist?: Iterable<string>;
|
|
110
|
+
}): Promise<SignedOcapHookTicket>;
|
|
111
|
+
/**
|
|
112
|
+
* Verifies a signed OcapHookTicket purely from its cryptographic signature and claims
|
|
113
|
+
* (0 synchronous network/RPC calls to OCAP nodes).
|
|
114
|
+
*/
|
|
115
|
+
declare function verifyOcapHookTicketSignature(ticket: SignedOcapHookTicket): Promise<boolean>;
|
|
116
|
+
/**
|
|
117
|
+
* Deterministic `OcapVerifiedHook` Engine modeling the on-chain Uniswap V4 Hook lifecycle:
|
|
118
|
+
* - `beforeInitialize`: Protects pool creation against tick-sniping front-running
|
|
119
|
+
* - `beforeAddLiquidity`: Enforces OFAC sanctions screening + RWA KYC permissioning
|
|
120
|
+
* - `beforeSwap`: Purely stateless ticket verification + graceful router-friendly fallback + anti-MEV LP rebate split
|
|
121
|
+
*/
|
|
122
|
+
declare class OcapVerifiedHookEngine {
|
|
123
|
+
private readonly config;
|
|
124
|
+
private readonly consumedNonces;
|
|
125
|
+
private readonly rwaAllowlistCache;
|
|
126
|
+
constructor(config: V4PoolHookConfig);
|
|
127
|
+
private pruneExpiredCaches;
|
|
128
|
+
/**
|
|
129
|
+
* `beforeInitialize`: Protects newly graduating or official pools from front-running bots
|
|
130
|
+
* initializing the same V4 PoolKey at a manipulated initial tick/sqrtPriceX96.
|
|
131
|
+
*/
|
|
132
|
+
beforeInitialize(params: {
|
|
133
|
+
callerAddress: string;
|
|
134
|
+
}): {
|
|
135
|
+
allowed: true;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* `beforeAddLiquidity`: Screens LPs against OFAC sanctions and enforces KYC VC for PERMISSIONED_RWA pools.
|
|
139
|
+
*/
|
|
140
|
+
beforeAddLiquidity(params: {
|
|
141
|
+
lpAddress: string;
|
|
142
|
+
currentTimestamp: number;
|
|
143
|
+
ticket?: SignedOcapHookTicket;
|
|
144
|
+
}): Promise<{
|
|
145
|
+
allowed: true;
|
|
146
|
+
cachedRwaValidUntil?: number;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* `beforeSwap`: Evaluates swap permissions, dynamic fee overrides, and anti-MEV LP rebates.
|
|
150
|
+
*
|
|
151
|
+
* Key Guarantees:
|
|
152
|
+
* 1. Zero synchronous cross-chain RPC calls (`synchronousCrossChainRpcCalls: 0`).
|
|
153
|
+
* 2. Hard-reverts ONLY on OFAC sanctions, GDPR PII violations, or unverified callers in `PERMISSIONED_RWA` pools.
|
|
154
|
+
* 3. In `LOYALTY_PUBLIC` pools, missing/expired/invalid tickets NEVER revert standard router swaps —
|
|
155
|
+
* they gracefully fall back to `baseFeeBps` (or `mevPenaltyFeeBps` for large unverified arbitrage orders).
|
|
156
|
+
*/
|
|
157
|
+
beforeSwap(params: {
|
|
158
|
+
traderAddress: string;
|
|
159
|
+
amountIn: string;
|
|
160
|
+
currentTimestamp: number;
|
|
161
|
+
ticket?: SignedOcapHookTicket;
|
|
162
|
+
}): Promise<BeforeSwapEvaluationResult>;
|
|
163
|
+
private validateTicketInternal;
|
|
164
|
+
}
|
|
165
|
+
declare const OCAP_VERIFIED_HOOK_SOLIDITY_SPEC: {
|
|
166
|
+
readonly contractName: "OcapVerifiedHook";
|
|
167
|
+
readonly uniswapVersion: "v4-core";
|
|
168
|
+
readonly implementedHooks: readonly ["beforeInitialize", "beforeAddLiquidity", "beforeSwap"];
|
|
169
|
+
readonly ofacOracleAddress: "0x40C57923924B5c5c5455c48D93317139ADDaC8fb";
|
|
170
|
+
readonly synchronousCrossChainRpcDependency: false;
|
|
171
|
+
};
|
|
172
|
+
//#endregion
|
|
173
|
+
export { BeforeSwapEvaluationResult, DEFAULT_MIN_HOLDING_BLOCKS, HookFeeTierName, MAX_HOOK_TICKET_TTL_SECONDS, MAX_V4_DYNAMIC_FEE_BPS, MIN_LP_MEV_REBATE_SHARE_BPS, OCAP_VERIFIED_HOOK_SOLIDITY_SPEC, OcapHookTicketClaims, OcapVerifiedHookEngine, SignedOcapHookTicket, V4PoolComplianceMode, V4PoolHookConfig, assertZeroPiiInHookData, computeOcapHookTicketDigest, issueOcapHookTicket, verifyOcapHookTicketSignature };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.31.1",
|
|
7
7
|
"description": "Pipeline runner and common pipelines to process transactions",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -49,15 +49,16 @@
|
|
|
49
49
|
"elliptic": "6.5.3"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@arcblock/did": "1.
|
|
53
|
-
"@arcblock/did-util": "1.
|
|
54
|
-
"@ocap/client": "1.
|
|
55
|
-
"@ocap/mcrypto": "1.
|
|
56
|
-
"@ocap/message": "1.
|
|
57
|
-
"@ocap/state": "1.
|
|
58
|
-
"@ocap/types": "1.
|
|
59
|
-
"@ocap/util": "1.
|
|
60
|
-
"@ocap/wallet": "1.
|
|
52
|
+
"@arcblock/did": "1.31.1",
|
|
53
|
+
"@arcblock/did-util": "1.31.1",
|
|
54
|
+
"@ocap/client": "1.31.1",
|
|
55
|
+
"@ocap/mcrypto": "1.31.1",
|
|
56
|
+
"@ocap/message": "1.31.1",
|
|
57
|
+
"@ocap/state": "1.31.1",
|
|
58
|
+
"@ocap/types": "1.31.1",
|
|
59
|
+
"@ocap/util": "1.31.1",
|
|
60
|
+
"@ocap/wallet": "1.31.1",
|
|
61
|
+
"elliptic": "6.6.1",
|
|
61
62
|
"debug": "^4.4.3",
|
|
62
63
|
"lodash": "^4.17.23"
|
|
63
64
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS, EXPLICIT_HEIGHT_PATHS, PENDING_DEDUP_ACTIVATION_HEIGHT, parseNonceBn, readExplicitHeight, resolveDedupActivationHeight } from "@ocap/state";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/dedup-height.d.ts
|
|
4
|
-
declare function resolveEffectiveHeight(context: unknown): Promise<number>;
|
|
5
|
-
declare function tryResolveDedupHeightActiveSync(context: unknown): boolean | null;
|
|
6
|
-
declare function isDedupHeightActive(context: unknown): Promise<boolean>;
|
|
7
|
-
/**
|
|
8
|
-
* Validate that a passkey Multisig.extra payload is a JSON object containing
|
|
9
|
-
* non-empty string `authenticatorData` and `clientDataJSON`.
|
|
10
|
-
* Does not restrict key ordering or additional client fields (such as iOS
|
|
11
|
-
* DIDConnect `signature` and `userHandle`), relying on `unsignedTxHash`
|
|
12
|
-
* deduplication and `nonce > 0` for replay protection.
|
|
13
|
-
*/
|
|
14
|
-
declare function isCanonicalPasskeyExtra(extra: string): boolean;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS, EXPLICIT_HEIGHT_PATHS, PENDING_DEDUP_ACTIVATION_HEIGHT, isCanonicalPasskeyExtra, isDedupHeightActive, parseNonceBn, readExplicitHeight, resolveDedupActivationHeight, resolveEffectiveHeight, tryResolveDedupHeightActiveSync };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS, EXPLICIT_HEIGHT_PATHS, PENDING_DEDUP_ACTIVATION_HEIGHT, parseNonceBn, readExplicitHeight, resolveDedupActivationHeight } from "@ocap/state";
|
|
2
|
-
import get from "lodash/get.js";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/dedup-height.ts
|
|
5
|
-
const hasLedgerSequenceProvider = (context) => {
|
|
6
|
-
const ledger = context?.ledger;
|
|
7
|
-
return typeof ledger?.getLatestSequence === "function" || typeof ledger?.getSequence === "function";
|
|
8
|
-
};
|
|
9
|
-
async function resolveEffectiveHeight(context) {
|
|
10
|
-
const explicit = readExplicitHeight(context);
|
|
11
|
-
if (explicit !== void 0) return explicit;
|
|
12
|
-
const ledger = context?.ledger;
|
|
13
|
-
const getSeqFn = typeof ledger?.getLatestSequence === "function" ? () => ledger.getLatestSequence() : typeof ledger?.getSequence === "function" ? () => ledger.getSequence() : null;
|
|
14
|
-
if (getSeqFn) try {
|
|
15
|
-
const seq = await getSeqFn();
|
|
16
|
-
const num = Number(seq);
|
|
17
|
-
if (Number.isFinite(num) && num >= 0) {
|
|
18
|
-
const nextSeq = num + 1;
|
|
19
|
-
if (context && typeof context === "object") context.expectedLedgerSequence = nextSeq;
|
|
20
|
-
return nextSeq;
|
|
21
|
-
}
|
|
22
|
-
} catch (err) {
|
|
23
|
-
if (!(err instanceof Error ? err.message : String(err)).includes("No read ledger configured on the sequencer-driven ledger facade")) throw err;
|
|
24
|
-
}
|
|
25
|
-
return 0;
|
|
26
|
-
}
|
|
27
|
-
function tryResolveDedupHeightActiveSync(context) {
|
|
28
|
-
const explicitFlag = get(context, "dedupActive");
|
|
29
|
-
if (typeof explicitFlag === "boolean") return explicitFlag;
|
|
30
|
-
const dedupHeight = resolveDedupActivationHeight(context);
|
|
31
|
-
if (dedupHeight <= 0) return true;
|
|
32
|
-
const explicitHeight = readExplicitHeight(context);
|
|
33
|
-
if (explicitHeight !== void 0) return explicitHeight >= dedupHeight;
|
|
34
|
-
if (!hasLedgerSequenceProvider(context) || dedupHeight >= PENDING_DEDUP_ACTIVATION_HEIGHT) return dedupHeight < PENDING_DEDUP_ACTIVATION_HEIGHT;
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
async function isDedupHeightActive(context) {
|
|
38
|
-
const syncResult = tryResolveDedupHeightActiveSync(context);
|
|
39
|
-
if (syncResult !== null) return syncResult;
|
|
40
|
-
const dedupHeight = resolveDedupActivationHeight(context);
|
|
41
|
-
return await resolveEffectiveHeight(context) >= dedupHeight;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Validate that a passkey Multisig.extra payload is a JSON object containing
|
|
45
|
-
* non-empty string `authenticatorData` and `clientDataJSON`.
|
|
46
|
-
* Does not restrict key ordering or additional client fields (such as iOS
|
|
47
|
-
* DIDConnect `signature` and `userHandle`), relying on `unsignedTxHash`
|
|
48
|
-
* deduplication and `nonce > 0` for replay protection.
|
|
49
|
-
*/
|
|
50
|
-
function isCanonicalPasskeyExtra(extra) {
|
|
51
|
-
try {
|
|
52
|
-
const parsed = JSON.parse(extra);
|
|
53
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return false;
|
|
54
|
-
return typeof parsed.authenticatorData === "string" && parsed.authenticatorData.length > 0 && typeof parsed.clientDataJSON === "string" && parsed.clientDataJSON.length > 0;
|
|
55
|
-
} catch {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
export { CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS, EXPLICIT_HEIGHT_PATHS, PENDING_DEDUP_ACTIVATION_HEIGHT, isCanonicalPasskeyExtra, isDedupHeightActive, parseNonceBn, readExplicitHeight, resolveDedupActivationHeight, resolveEffectiveHeight, tryResolveDedupHeightActiveSync };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let _ocap_state = require("@ocap/state");
|
|
3
|
-
let lodash_get = require("lodash/get");
|
|
4
|
-
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/dedup-height.ts
|
|
7
|
-
const hasLedgerSequenceProvider = (context) => {
|
|
8
|
-
const ledger = context?.ledger;
|
|
9
|
-
return typeof ledger?.getLatestSequence === "function" || typeof ledger?.getSequence === "function";
|
|
10
|
-
};
|
|
11
|
-
async function resolveEffectiveHeight(context) {
|
|
12
|
-
const explicit = (0, _ocap_state.readExplicitHeight)(context);
|
|
13
|
-
if (explicit !== void 0) return explicit;
|
|
14
|
-
const ledger = context?.ledger;
|
|
15
|
-
const getSeqFn = typeof ledger?.getLatestSequence === "function" ? () => ledger.getLatestSequence() : typeof ledger?.getSequence === "function" ? () => ledger.getSequence() : null;
|
|
16
|
-
if (getSeqFn) try {
|
|
17
|
-
const seq = await getSeqFn();
|
|
18
|
-
const num = Number(seq);
|
|
19
|
-
if (Number.isFinite(num) && num >= 0) {
|
|
20
|
-
const nextSeq = num + 1;
|
|
21
|
-
if (context && typeof context === "object") context.expectedLedgerSequence = nextSeq;
|
|
22
|
-
return nextSeq;
|
|
23
|
-
}
|
|
24
|
-
} catch (err) {
|
|
25
|
-
if (!(err instanceof Error ? err.message : String(err)).includes("No read ledger configured on the sequencer-driven ledger facade")) throw err;
|
|
26
|
-
}
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
29
|
-
function tryResolveDedupHeightActiveSync(context) {
|
|
30
|
-
const explicitFlag = (0, lodash_get.default)(context, "dedupActive");
|
|
31
|
-
if (typeof explicitFlag === "boolean") return explicitFlag;
|
|
32
|
-
const dedupHeight = (0, _ocap_state.resolveDedupActivationHeight)(context);
|
|
33
|
-
if (dedupHeight <= 0) return true;
|
|
34
|
-
const explicitHeight = (0, _ocap_state.readExplicitHeight)(context);
|
|
35
|
-
if (explicitHeight !== void 0) return explicitHeight >= dedupHeight;
|
|
36
|
-
if (!hasLedgerSequenceProvider(context) || dedupHeight >= _ocap_state.PENDING_DEDUP_ACTIVATION_HEIGHT) return dedupHeight < _ocap_state.PENDING_DEDUP_ACTIVATION_HEIGHT;
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
async function isDedupHeightActive(context) {
|
|
40
|
-
const syncResult = tryResolveDedupHeightActiveSync(context);
|
|
41
|
-
if (syncResult !== null) return syncResult;
|
|
42
|
-
const dedupHeight = (0, _ocap_state.resolveDedupActivationHeight)(context);
|
|
43
|
-
return await resolveEffectiveHeight(context) >= dedupHeight;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Validate that a passkey Multisig.extra payload is a JSON object containing
|
|
47
|
-
* non-empty string `authenticatorData` and `clientDataJSON`.
|
|
48
|
-
* Does not restrict key ordering or additional client fields (such as iOS
|
|
49
|
-
* DIDConnect `signature` and `userHandle`), relying on `unsignedTxHash`
|
|
50
|
-
* deduplication and `nonce > 0` for replay protection.
|
|
51
|
-
*/
|
|
52
|
-
function isCanonicalPasskeyExtra(extra) {
|
|
53
|
-
try {
|
|
54
|
-
const parsed = JSON.parse(extra);
|
|
55
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return false;
|
|
56
|
-
return typeof parsed.authenticatorData === "string" && parsed.authenticatorData.length > 0 && typeof parsed.clientDataJSON === "string" && parsed.clientDataJSON.length > 0;
|
|
57
|
-
} catch {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
exports.CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS = _ocap_state.CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS;
|
|
64
|
-
exports.EXPLICIT_HEIGHT_PATHS = _ocap_state.EXPLICIT_HEIGHT_PATHS;
|
|
65
|
-
exports.PENDING_DEDUP_ACTIVATION_HEIGHT = _ocap_state.PENDING_DEDUP_ACTIVATION_HEIGHT;
|
|
66
|
-
exports.isCanonicalPasskeyExtra = isCanonicalPasskeyExtra;
|
|
67
|
-
exports.isDedupHeightActive = isDedupHeightActive;
|
|
68
|
-
exports.parseNonceBn = _ocap_state.parseNonceBn;
|
|
69
|
-
exports.readExplicitHeight = _ocap_state.readExplicitHeight;
|
|
70
|
-
exports.resolveDedupActivationHeight = _ocap_state.resolveDedupActivationHeight;
|
|
71
|
-
exports.resolveEffectiveHeight = resolveEffectiveHeight;
|
|
72
|
-
exports.tryResolveDedupHeightActiveSync = tryResolveDedupHeightActiveSync;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS, EXPLICIT_HEIGHT_PATHS, PENDING_DEDUP_ACTIVATION_HEIGHT, parseNonceBn, readExplicitHeight, resolveDedupActivationHeight } from "@ocap/state";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/dedup-height.d.ts
|
|
4
|
-
declare function resolveEffectiveHeight(context: unknown): Promise<number>;
|
|
5
|
-
declare function tryResolveDedupHeightActiveSync(context: unknown): boolean | null;
|
|
6
|
-
declare function isDedupHeightActive(context: unknown): Promise<boolean>;
|
|
7
|
-
/**
|
|
8
|
-
* Validate that a passkey Multisig.extra payload is a JSON object containing
|
|
9
|
-
* non-empty string `authenticatorData` and `clientDataJSON`.
|
|
10
|
-
* Does not restrict key ordering or additional client fields (such as iOS
|
|
11
|
-
* DIDConnect `signature` and `userHandle`), relying on `unsignedTxHash`
|
|
12
|
-
* deduplication and `nonce > 0` for replay protection.
|
|
13
|
-
*/
|
|
14
|
-
declare function isCanonicalPasskeyExtra(extra: string): boolean;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS, EXPLICIT_HEIGHT_PATHS, PENDING_DEDUP_ACTIVATION_HEIGHT, isCanonicalPasskeyExtra, isDedupHeightActive, parseNonceBn, readExplicitHeight, resolveDedupActivationHeight, resolveEffectiveHeight, tryResolveDedupHeightActiveSync };
|