@certen.io/sdk 0.9.0 → 0.11.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/CHANGELOG.md +153 -0
- package/README.md +111 -0
- package/dist/address.d.ts +12 -0
- package/dist/address.d.ts.map +1 -0
- package/dist/address.js +48 -0
- package/dist/address.js.map +1 -0
- package/dist/agent.d.ts +8 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +12 -0
- package/dist/agent.js.map +1 -1
- package/dist/browser.d.ts +47 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +55 -0
- package/dist/browser.js.map +1 -0
- package/dist/bytes.d.ts +14 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +47 -0
- package/dist/bytes.js.map +1 -0
- package/dist/chains.d.ts +218 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +295 -0
- package/dist/chains.js.map +1 -0
- package/dist/client.d.ts +17 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +54 -8
- package/dist/client.js.map +1 -1
- package/dist/defaults.d.ts +3 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +3 -0
- package/dist/defaults.js.map +1 -0
- package/dist/doctor.d.ts +10 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +42 -27
- package/dist/doctor.js.map +1 -1
- package/dist/effect.d.ts +99 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +139 -0
- package/dist/effect.js.map +1 -0
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error-codes.js +17 -0
- package/dist/error-codes.js.map +1 -1
- package/dist/errors.d.ts +76 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +108 -0
- package/dist/errors.js.map +1 -1
- package/dist/evm-rpc.d.ts +55 -0
- package/dist/evm-rpc.d.ts.map +1 -0
- package/dist/evm-rpc.js +126 -0
- package/dist/evm-rpc.js.map +1 -0
- package/dist/execution-proof.d.ts.map +1 -1
- package/dist/execution-proof.js +2 -1
- package/dist/execution-proof.js.map +1 -1
- package/dist/funding.d.ts +214 -6
- package/dist/funding.d.ts.map +1 -1
- package/dist/funding.js +251 -29
- package/dist/funding.js.map +1 -1
- package/dist/header-fields.d.ts +68 -0
- package/dist/header-fields.d.ts.map +1 -0
- package/dist/header-fields.js +147 -0
- package/dist/header-fields.js.map +1 -0
- package/dist/index.d.ts +9 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -26
- package/dist/index.js.map +1 -1
- package/dist/intent-states.d.ts +75 -0
- package/dist/intent-states.d.ts.map +1 -0
- package/dist/intent-states.js +66 -0
- package/dist/intent-states.js.map +1 -0
- package/dist/internal.d.ts +18 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +44 -0
- package/dist/internal.js.map +1 -1
- package/dist/key-page.d.ts +67 -0
- package/dist/key-page.d.ts.map +1 -0
- package/dist/key-page.js +154 -0
- package/dist/key-page.js.map +1 -0
- package/dist/origin.d.ts +19 -0
- package/dist/origin.d.ts.map +1 -0
- package/dist/origin.js +80 -0
- package/dist/origin.js.map +1 -0
- package/dist/random.d.ts +27 -0
- package/dist/random.d.ts.map +1 -0
- package/dist/random.js +30 -0
- package/dist/random.js.map +1 -0
- package/dist/readiness.d.ts +133 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +467 -0
- package/dist/readiness.js.map +1 -0
- package/dist/reason-codes.d.ts +15 -0
- package/dist/reason-codes.d.ts.map +1 -0
- package/dist/reason-codes.js +30 -0
- package/dist/reason-codes.js.map +1 -0
- package/dist/receipt.d.ts +233 -0
- package/dist/receipt.d.ts.map +1 -0
- package/dist/receipt.js +318 -0
- package/dist/receipt.js.map +1 -0
- package/dist/resources/admin.d.ts +5 -2
- package/dist/resources/admin.d.ts.map +1 -1
- package/dist/resources/admin.js +8 -3
- package/dist/resources/admin.js.map +1 -1
- package/dist/resources/billing.d.ts.map +1 -1
- package/dist/resources/billing.js +5 -4
- package/dist/resources/billing.js.map +1 -1
- package/dist/resources/chains.d.ts +10 -0
- package/dist/resources/chains.d.ts.map +1 -1
- package/dist/resources/chains.js +15 -1
- package/dist/resources/chains.js.map +1 -1
- package/dist/resources/device.d.ts.map +1 -1
- package/dist/resources/device.js +2 -1
- package/dist/resources/device.js.map +1 -1
- package/dist/resources/execute.d.ts +110 -4
- package/dist/resources/execute.d.ts.map +1 -1
- package/dist/resources/execute.js +207 -35
- package/dist/resources/execute.js.map +1 -1
- package/dist/resources/governance.js +3 -3
- package/dist/resources/governance.js.map +1 -1
- package/dist/resources/identity.js +5 -5
- package/dist/resources/identity.js.map +1 -1
- package/dist/resources/oauth-clients.d.ts.map +1 -1
- package/dist/resources/oauth-clients.js +3 -2
- package/dist/resources/oauth-clients.js.map +1 -1
- package/dist/resources/proof.d.ts +10 -2
- package/dist/resources/proof.d.ts.map +1 -1
- package/dist/resources/proof.js +33 -11
- package/dist/resources/proof.js.map +1 -1
- package/dist/resources/registration-tokens.d.ts.map +1 -1
- package/dist/resources/registration-tokens.js +2 -1
- package/dist/resources/registration-tokens.js.map +1 -1
- package/dist/resources/sign.js +2 -2
- package/dist/resources/sign.js.map +1 -1
- package/dist/resources/transaction.d.ts.map +1 -1
- package/dist/resources/transaction.js +7 -3
- package/dist/resources/transaction.js.map +1 -1
- package/dist/resources/transparency.d.ts.map +1 -1
- package/dist/resources/transparency.js +3 -2
- package/dist/resources/transparency.js.map +1 -1
- package/dist/resources/webhooks.d.ts +5 -3
- package/dist/resources/webhooks.d.ts.map +1 -1
- package/dist/resources/webhooks.js +12 -8
- package/dist/resources/webhooks.js.map +1 -1
- package/dist/sha256.d.ts +10 -0
- package/dist/sha256.d.ts.map +1 -0
- package/dist/sha256.js +71 -0
- package/dist/sha256.js.map +1 -0
- package/dist/share-target.d.ts +10 -0
- package/dist/share-target.d.ts.map +1 -0
- package/dist/share-target.js +25 -0
- package/dist/share-target.js.map +1 -0
- package/dist/shared-proof.d.ts +1 -5
- package/dist/shared-proof.d.ts.map +1 -1
- package/dist/shared-proof.js +27 -21
- package/dist/shared-proof.js.map +1 -1
- package/dist/signing-check.d.ts +66 -0
- package/dist/signing-check.d.ts.map +1 -0
- package/dist/signing-check.js +171 -0
- package/dist/signing-check.js.map +1 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/verify-receipt.d.ts.map +1 -1
- package/dist/verify-receipt.js +68 -28
- package/dist/verify-receipt.js.map +1 -1
- package/dist/verify.d.ts +206 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +369 -0
- package/dist/verify.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/package.json +25 -7
package/dist/funding.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CertenError } from './errors.js';
|
|
2
|
+
import { chainInfo, chainSlug, nativeSymbolFor, readNativeBalance, describeUnverifiable, gasReserveFor, parseUnits, formatUnits, } from './chains.js';
|
|
2
3
|
/**
|
|
3
4
|
* The unfunded abstract account guard.
|
|
4
5
|
*
|
|
@@ -11,11 +12,22 @@ import { CertenError } from './errors.js';
|
|
|
11
12
|
*
|
|
12
13
|
* So the SDK refuses before submitting, and says why.
|
|
13
14
|
*
|
|
14
|
-
* **
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* **What it refuses, and what it lets through.**
|
|
16
|
+
*
|
|
17
|
+
* - A positively observed zero gas balance is refused ({@link CertenUnfundedAccountError}).
|
|
18
|
+
* - A balance that is positive but cannot cover the amount being moved plus the gas to move it is
|
|
19
|
+
* refused ({@link CertenUnderfundedAccountError}). Zero is the extreme case of this and keeps its
|
|
20
|
+
* own error. The gas half is an ESTIMATE (see {@link assessGas}); the amount half is not.
|
|
21
|
+
* - A gas balance that cannot be IDENTIFIED is refused by name
|
|
22
|
+
* ({@link CertenFundingUnverifiableError}): the chain's gas token is unknown to the catalogue,
|
|
23
|
+
* the gateway reported balances none of which is that token, or it reported the gas row as
|
|
24
|
+
* unreadable. The first two used to pass silently on any chain whose gas is not called `ETH` —
|
|
25
|
+
* the guard looked for an `ETH` row, found none, and waved the intent through.
|
|
26
|
+
* - The portfolio being unreachable, or the chain not appearing in it at all, lets the intent
|
|
27
|
+
* proceed. A guard that blocked every time the portfolio view lagged would break legitimate work,
|
|
28
|
+
* which is a worse failure than the one it prevents.
|
|
29
|
+
*
|
|
30
|
+
* `skipFundingCheck: true` bypasses all of it, deliberately and visibly.
|
|
19
31
|
*/
|
|
20
32
|
/** Thrown instead of submitting an intent that could never execute. */
|
|
21
33
|
export class CertenUnfundedAccountError extends CertenError {
|
|
@@ -38,7 +50,99 @@ export class CertenUnfundedAccountError extends CertenError {
|
|
|
38
50
|
}
|
|
39
51
|
}
|
|
40
52
|
/**
|
|
41
|
-
*
|
|
53
|
+
* Thrown instead of submitting a value-moving intent from an account that holds some gas, but not enough: either less than the amount
|
|
54
|
+
* being moved, or too little left over once it is.
|
|
55
|
+
*
|
|
56
|
+
* `kind: 'amount'` is a fact (the account holds less than it is about to send). `kind: 'gas'` is judged against an ESTIMATE of what one
|
|
57
|
+
* execution costs, which is why it is overridable and says so.
|
|
58
|
+
*/
|
|
59
|
+
export class CertenUnderfundedAccountError extends CertenError {
|
|
60
|
+
address;
|
|
61
|
+
chain;
|
|
62
|
+
kind;
|
|
63
|
+
/** Whole native units, as strings, so nothing here is a float. */
|
|
64
|
+
balance;
|
|
65
|
+
needed;
|
|
66
|
+
symbol;
|
|
67
|
+
constructor(address, chain, shortfall) {
|
|
68
|
+
super(shortfall.kind === 'amount'
|
|
69
|
+
? `The abstract account ${address} on ${chain} holds ${shortfall.balance} ${shortfall.symbol}, less than the ${shortfall.amount} ${shortfall.symbol} this intent moves. `
|
|
70
|
+
+ 'It would be accepted, signed and submitted, and then never execute. Fund it first, or pass skipFundingCheck: true to submit anyway.'
|
|
71
|
+
: `The abstract account ${address} on ${chain} holds ${shortfall.balance} ${shortfall.symbol}; moving ${shortfall.amount} ${shortfall.symbol} and paying for the execution needs about `
|
|
72
|
+
+ `${shortfall.needed} ${shortfall.symbol}${shortfall.reserve === '0' ? ' (nothing would be left over for gas)' : ` (the gas share, ${shortfall.reserve} ${shortfall.symbol}, is an estimate, not a quote)`}. `
|
|
73
|
+
+ 'Without gas the intent is accepted, signed and submitted, and then parks at "anchoring" forever. Fund it first, or pass skipFundingCheck: true to submit anyway.', 0, 'ABSTRACT_ACCOUNT_UNDERFUNDED');
|
|
74
|
+
this.name = 'CertenUnderfundedAccountError';
|
|
75
|
+
this.address = address;
|
|
76
|
+
this.chain = chain;
|
|
77
|
+
this.kind = shortfall.kind;
|
|
78
|
+
this.balance = shortfall.balance;
|
|
79
|
+
this.needed = shortfall.needed;
|
|
80
|
+
this.symbol = shortfall.symbol;
|
|
81
|
+
}
|
|
82
|
+
/** Never. Funding is a human act; retrying changes nothing. */
|
|
83
|
+
get isRetryable() {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function assessGas(p) {
|
|
88
|
+
const reading = p.reading;
|
|
89
|
+
if (reading.state !== 'funded' && reading.state !== 'empty')
|
|
90
|
+
return { state: 'unknown', reading };
|
|
91
|
+
const decimals = chainInfo(p.chain)?.nativeDecimals;
|
|
92
|
+
if (decimals === undefined)
|
|
93
|
+
return { state: 'unknown', reading: { state: 'unknown-native', chain: chainSlug(p.chain) } };
|
|
94
|
+
const balance = parseUnits(reading.balance, decimals);
|
|
95
|
+
// A number that is not a plain decimal ("1e-7", "unavailable") is not something to do arithmetic on. Unreadable, not zero.
|
|
96
|
+
if (balance === undefined)
|
|
97
|
+
return { state: 'unknown', reading: { state: 'unreadable', symbol: reading.symbol, balance: reading.balance } };
|
|
98
|
+
// An amount that is not a decimal cannot be compared; the reserve is still judged.
|
|
99
|
+
const amount = p.amount === undefined ? 0n : parseUnits(p.amount, decimals) ?? 0n;
|
|
100
|
+
const reserveText = p.reserve === undefined ? gasReserveFor(p.chain) : p.reserve ?? undefined;
|
|
101
|
+
const reserve = reserveText === undefined ? 0n : parseUnits(reserveText, decimals) ?? 0n;
|
|
102
|
+
const needed = amount + reserve;
|
|
103
|
+
const out = {
|
|
104
|
+
symbol: reading.symbol,
|
|
105
|
+
balance: formatUnits(balance, decimals),
|
|
106
|
+
amount: formatUnits(amount, decimals),
|
|
107
|
+
reserve: formatUnits(reserve, decimals),
|
|
108
|
+
needed: formatUnits(needed, decimals),
|
|
109
|
+
};
|
|
110
|
+
if (balance === 0n)
|
|
111
|
+
return { state: 'empty', ...out };
|
|
112
|
+
const shortfall = needed > balance ? formatUnits(needed - balance, decimals) : null;
|
|
113
|
+
if (balance < amount)
|
|
114
|
+
return { state: 'short', kind: 'amount', ...out, shortfall };
|
|
115
|
+
// Moving the whole balance leaves nothing to pay gas with, estimate or no estimate.
|
|
116
|
+
if (balance < needed || (amount > 0n && balance === amount))
|
|
117
|
+
return { state: 'short', kind: 'gas', ...out, shortfall };
|
|
118
|
+
return { state: 'sufficient', ...out, estimated: reserve > 0n };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Thrown instead of submitting a value-moving intent whose gas balance could not be identified.
|
|
122
|
+
*
|
|
123
|
+
* Not the same claim as {@link CertenUnfundedAccountError}: the account may well be funded. What is
|
|
124
|
+
* known is that this client cannot tell, and an unfunded account is a silent, permanent stall.
|
|
125
|
+
*/
|
|
126
|
+
export class CertenFundingUnverifiableError extends CertenError {
|
|
127
|
+
address;
|
|
128
|
+
chain;
|
|
129
|
+
reason;
|
|
130
|
+
constructor(address, chain, reason, why) {
|
|
131
|
+
super(`Cannot verify that the abstract account${address ? ` ${address}` : ''} on ${chain} holds gas: ${why}. `
|
|
132
|
+
+ 'An intent from an unfunded account is accepted, signed and submitted, and then parks at '
|
|
133
|
+
+ '"anchoring" forever. Check the account\'s gas yourself, then pass skipFundingCheck: true to submit.', 0, 'ABSTRACT_ACCOUNT_FUNDING_UNVERIFIABLE');
|
|
134
|
+
this.name = 'CertenFundingUnverifiableError';
|
|
135
|
+
this.address = address;
|
|
136
|
+
this.chain = chain;
|
|
137
|
+
this.reason = reason;
|
|
138
|
+
}
|
|
139
|
+
/** Only an unreadable balance can change on its own; the other two are facts about the chain. */
|
|
140
|
+
get isRetryable() {
|
|
141
|
+
return this.reason === 'unreadable';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Numeric EVM chain id → registry slug, from the chain catalogue (`chains.ts`).
|
|
42
146
|
*
|
|
43
147
|
* `GET /v1/portfolio` used to return `chain_id` as a slug on some chain accounts and as a numeric
|
|
44
148
|
* EVM id on others, in the same response, because the gateway stored whatever the caller sent.
|
|
@@ -50,18 +154,8 @@ export class CertenUnfundedAccountError extends CertenError {
|
|
|
50
154
|
* independently and is routinely pointed at a gateway older than itself. A guard that silently
|
|
51
155
|
* stops guarding against an older peer is worse than no guard, because nothing signals the gap.
|
|
52
156
|
*/
|
|
53
|
-
const NUMERIC_CHAIN_IDS = {
|
|
54
|
-
11155111: 'ethereum-sepolia',
|
|
55
|
-
84532: 'base-sepolia',
|
|
56
|
-
421614: 'arbitrum-sepolia',
|
|
57
|
-
11155420: 'optimism-sepolia',
|
|
58
|
-
80002: 'polygon-amoy',
|
|
59
|
-
};
|
|
60
157
|
export function normalizeChainId(value) {
|
|
61
|
-
|
|
62
|
-
return '';
|
|
63
|
-
const raw = String(value).trim();
|
|
64
|
-
return NUMERIC_CHAIN_IDS[raw] ?? raw;
|
|
158
|
+
return chainSlug(value);
|
|
65
159
|
}
|
|
66
160
|
/** Does this amount move value? A zero or absent amount needs no funded account. */
|
|
67
161
|
export function movesValue(amount) {
|
|
@@ -74,7 +168,8 @@ export function movesValue(amount) {
|
|
|
74
168
|
return Number.isFinite(n) ? n > 0 : true;
|
|
75
169
|
}
|
|
76
170
|
/**
|
|
77
|
-
* Refuse a value-moving intent from an abstract account positively known to be empty
|
|
171
|
+
* Refuse a value-moving intent from an abstract account positively known to be empty, or whose gas
|
|
172
|
+
* balance cannot be identified.
|
|
78
173
|
*
|
|
79
174
|
* Reads the portfolio directly rather than taking a client, so this stays usable from inside
|
|
80
175
|
* `ExecuteResource`, which holds only an axios instance.
|
|
@@ -82,24 +177,31 @@ export function movesValue(amount) {
|
|
|
82
177
|
export async function assertFundedForValue(http, params) {
|
|
83
178
|
if (!params.chain || !movesValue(params.amount))
|
|
84
179
|
return;
|
|
180
|
+
const want = normalizeChainId(params.chain);
|
|
181
|
+
// Before any read: on a chain whose gas token is unknown, no balance row can be identified as the
|
|
182
|
+
// gas, so the answer is already known to be unknowable.
|
|
183
|
+
if (nativeSymbolFor(want) === undefined) {
|
|
184
|
+
const reading = { state: 'unknown-native', chain: want };
|
|
185
|
+
throw new CertenFundingUnverifiableError(undefined, want, 'unknown-native', describeUnverifiable(want, reading));
|
|
186
|
+
}
|
|
85
187
|
let address;
|
|
86
|
-
let
|
|
188
|
+
let reading;
|
|
87
189
|
try {
|
|
88
190
|
const { data } = await http.get('/v1/portfolio', { params: { identity: params.identityId } });
|
|
89
|
-
const want = normalizeChainId(params.chain);
|
|
90
191
|
const identities = data.identities ?? [];
|
|
91
192
|
for (const identity of identities) {
|
|
92
193
|
for (const chain of identity.chains ?? []) {
|
|
93
194
|
if (normalizeChainId(chain.chain_id) !== want)
|
|
94
195
|
continue;
|
|
95
196
|
// The NATIVE balance is what pays for execution. A token balance on the same account does
|
|
96
|
-
// not make the execution leg runnable
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
197
|
+
// not make the execution leg runnable — and on a chain whose gas is not ETH, an `ETH` row
|
|
198
|
+
// is not the gas either.
|
|
199
|
+
const r = readNativeBalance(want, chain.balances);
|
|
200
|
+
// Nothing reported for the account yet (not deployed, not indexed): not evidence of zero.
|
|
201
|
+
if (r.state === 'no-balances')
|
|
100
202
|
return;
|
|
101
203
|
address = chain.address;
|
|
102
|
-
|
|
204
|
+
reading = r;
|
|
103
205
|
}
|
|
104
206
|
}
|
|
105
207
|
}
|
|
@@ -107,10 +209,130 @@ export async function assertFundedForValue(http, params) {
|
|
|
107
209
|
// An unavailable portfolio must never block a transaction.
|
|
108
210
|
return;
|
|
109
211
|
}
|
|
110
|
-
if (address === undefined ||
|
|
111
|
-
return;
|
|
112
|
-
if (Number(balance) > 0)
|
|
212
|
+
if (address === undefined || reading === undefined)
|
|
113
213
|
return;
|
|
114
|
-
|
|
214
|
+
const assessment = assessGas({
|
|
215
|
+
chain: want,
|
|
216
|
+
reading,
|
|
217
|
+
amount: nativeAmountOf(want, params),
|
|
218
|
+
reserve: params.gasReserve,
|
|
219
|
+
});
|
|
220
|
+
switch (assessment.state) {
|
|
221
|
+
case 'sufficient':
|
|
222
|
+
return;
|
|
223
|
+
case 'empty':
|
|
224
|
+
throw new CertenUnfundedAccountError(address, want);
|
|
225
|
+
case 'short':
|
|
226
|
+
throw new CertenUnderfundedAccountError(address, want, assessment);
|
|
227
|
+
case 'unknown': {
|
|
228
|
+
const r = assessment.reading;
|
|
229
|
+
if (r.state === 'unknown-native' || r.state === 'native-not-reported' || r.state === 'unreadable') {
|
|
230
|
+
throw new CertenFundingUnverifiableError(address, want, r.state, describeUnverifiable(want, r));
|
|
231
|
+
}
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The part of an intent's amount that is paid in the chain's native token, in whole units, or undefined when none of it is.
|
|
238
|
+
*
|
|
239
|
+
* A token transfer's amount is in the token and does not draw down the gas balance; counting it would refuse an account that holds the
|
|
240
|
+
* token and plenty of gas. A base-unit (wei) value is converted so one comparison serves both spellings.
|
|
241
|
+
*/
|
|
242
|
+
export function nativeAmountOf(chain, p) {
|
|
243
|
+
const info = chainInfo(chain);
|
|
244
|
+
if (!info || p.amount === undefined || p.amount === null)
|
|
245
|
+
return undefined;
|
|
246
|
+
if (p.tokenSymbol && p.tokenSymbol.toUpperCase() !== info.nativeSymbol.toUpperCase())
|
|
247
|
+
return undefined;
|
|
248
|
+
const text = String(p.amount).trim();
|
|
249
|
+
if (p.amountUnit === 'base')
|
|
250
|
+
return /^\d+$/.test(text) ? formatUnits(BigInt(text), info.nativeDecimals) : undefined;
|
|
251
|
+
return text;
|
|
252
|
+
}
|
|
253
|
+
// ── telling someone how to fund an account ──────────────────────────────────────────────────────────
|
|
254
|
+
const ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
255
|
+
/**
|
|
256
|
+
* An EIP-681 payment request for a NATIVE transfer: `ethereum:<address>@<chainId>?value=<wei>`.
|
|
257
|
+
*
|
|
258
|
+
* Opens a wallet with the recipient, the network and the amount already set, which is the only way to move a value from a terminal to a wallet
|
|
259
|
+
* without retyping it. A mistyped recipient is the one error in this product that loses money and cannot be undone, so this builds a link only
|
|
260
|
+
* when every part of it is certain, and says `undefined` otherwise:
|
|
261
|
+
*
|
|
262
|
+
* - the chain must be in the catalogue (a link for a guessed network sends value somewhere nobody chose);
|
|
263
|
+
* - the address must be 20 bytes of hex, and is used exactly as given (the gateway's checksum case is preserved, never re-derived);
|
|
264
|
+
* - the amount is whole units and becomes integer wei by BigInt arithmetic. More decimals than the token has is refused rather than rounded:
|
|
265
|
+
* rounding would change what is paid.
|
|
266
|
+
*
|
|
267
|
+
* The value is a plain integer. EIP-681 also allows `1e15`, but a plain integer is read by more wallets.
|
|
268
|
+
*/
|
|
269
|
+
export function nativeTransferUri(p) {
|
|
270
|
+
const info = chainInfo(p.chain);
|
|
271
|
+
if (!info || !ADDRESS_RE.test(p.address))
|
|
272
|
+
return undefined;
|
|
273
|
+
const base = `ethereum:${p.address}@${info.chainId}`;
|
|
274
|
+
if (p.amount === undefined)
|
|
275
|
+
return base;
|
|
276
|
+
const wei = parseUnits(p.amount, info.nativeDecimals);
|
|
277
|
+
return wei === undefined ? undefined : `${base}?value=${wei.toString()}`;
|
|
278
|
+
}
|
|
279
|
+
export function gasFundingPlan(p) {
|
|
280
|
+
const info = chainInfo(p.chain);
|
|
281
|
+
if (!info)
|
|
282
|
+
return undefined;
|
|
283
|
+
const decimals = info.nativeDecimals;
|
|
284
|
+
const symbol = info.nativeSymbol;
|
|
285
|
+
const slug = info.slug;
|
|
286
|
+
const held = p.balance === undefined || p.balance === null ? undefined : parseUnits(p.balance, decimals);
|
|
287
|
+
const reserveText = p.reserve === undefined ? gasReserveFor(slug) : p.reserve ?? undefined;
|
|
288
|
+
const reserve = reserveText === undefined ? undefined : parseUnits(reserveText, decimals);
|
|
289
|
+
const amount = p.amount === undefined ? 0n : parseUnits(p.amount, decimals) ?? 0n;
|
|
290
|
+
const minimumWei = reserve === undefined ? (amount > 0n ? amount : undefined) : reserve + amount;
|
|
291
|
+
const suggestedWei = minimumWei === undefined ? undefined : (reserve !== undefined && reserve * 10n > minimumWei ? reserve * 10n : minimumWei);
|
|
292
|
+
const sendWei = suggestedWei === undefined ? undefined : (held !== undefined && held < suggestedWei ? suggestedWei - held : (held === undefined ? suggestedWei : 0n));
|
|
293
|
+
const leastWei = minimumWei === undefined ? undefined : (held !== undefined && held < minimumWei ? minimumWei - held : (held === undefined ? minimumWei : 0n));
|
|
294
|
+
// With nothing estimated, any positive balance clears it: the readiness check then judges the amount alone.
|
|
295
|
+
const satisfied = held === undefined ? false : minimumWei === undefined ? held > 0n : held >= minimumWei;
|
|
296
|
+
const fmt = (v) => (v === undefined ? null : formatUnits(v, decimals));
|
|
297
|
+
const send = fmt(sendWei);
|
|
298
|
+
const faucet = info.faucet ?? null;
|
|
299
|
+
const paymentUri = nativeTransferUri({ chain: slug, address: p.address, amount: send && sendWei !== 0n ? send : undefined }) ?? null;
|
|
300
|
+
const where = `${p.address} on ${slug}`;
|
|
301
|
+
const estimated = reserve !== undefined;
|
|
302
|
+
const steps = [];
|
|
303
|
+
if (send && sendWei !== 0n && leastWei === 0n) {
|
|
304
|
+
// Already enough to act; this only tops it up.
|
|
305
|
+
steps.push(`${where} already holds ${fmt(held)} ${symbol}, enough to act. To top it up to ${fmt(suggestedWei)} ${symbol}, send ${send} ${symbol}.`);
|
|
306
|
+
}
|
|
307
|
+
else if (send && sendWei !== 0n) {
|
|
308
|
+
// The suggestion is more than the minimum: say both, and which is which. "At least" would contradict "the least that works".
|
|
309
|
+
const split = leastWei !== undefined && sendWei !== undefined && leastWei < sendWei;
|
|
310
|
+
steps.push(split
|
|
311
|
+
? `Send ${send} ${symbol} to ${where} (${fmt(leastWei)} ${symbol}${held !== undefined && held > 0n ? ' more' : ''} is the least that works; the rest saves a second trip).`
|
|
312
|
+
: `Send at least ${send} ${symbol} to ${where}.`);
|
|
313
|
+
}
|
|
314
|
+
else if (send === null) {
|
|
315
|
+
steps.push(`Send some ${symbol} to ${where}. There is no estimate of what one execution costs on ${slug}, so there is no figure to give: any positive amount lets the account act, and an amount too small will fail at execution.`);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
steps.push(`${where} already holds ${fmt(held)} ${symbol}.`);
|
|
319
|
+
}
|
|
320
|
+
if (faucet)
|
|
321
|
+
steps.push(`Testnet gas is free from the faucet: ${faucet}`);
|
|
322
|
+
if (paymentUri)
|
|
323
|
+
steps.push(`A wallet link with the network, the address${send && sendWei !== 0n ? ' and the amount' : ''} already set: ${paymentUri}`);
|
|
324
|
+
if (estimated)
|
|
325
|
+
steps.push(`The amounts are planning figures, not a quote: the gas share of ${fmt(reserve)} ${symbol} is an estimate.`);
|
|
326
|
+
const twoStep = [
|
|
327
|
+
'Some faucets refuse a contract address, and this account is one. If yours does, send the gas to a wallet you control first.',
|
|
328
|
+
`Then, from that wallet, send ${send && sendWei !== 0n ? `${send} ${symbol}` : symbol} to ${p.address} on ${slug}${paymentUri ? ' (the wallet link opens that transfer pre-filled)' : ''}.`,
|
|
329
|
+
];
|
|
330
|
+
steps.push(...twoStep);
|
|
331
|
+
return {
|
|
332
|
+
chain: slug, symbol, address: p.address,
|
|
333
|
+
balance: fmt(held),
|
|
334
|
+
minimum: fmt(minimumWei), suggested: fmt(suggestedWei), send, least: fmt(leastWei),
|
|
335
|
+
satisfied, estimated, faucet, paymentUri, steps, twoStep,
|
|
336
|
+
};
|
|
115
337
|
}
|
|
116
338
|
//# sourceMappingURL=funding.js.map
|
package/dist/funding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funding.js","sourceRoot":"","sources":["../src/funding.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AAEH,uEAAuE;AACvE,MAAM,OAAO,0BAA2B,SAAQ,WAAW;IAChD,OAAO,CAAS;IAChB,KAAK,CAAS;IAEvB,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CACH,wBAAwB,OAAO,OAAO,KAAK,gDAAgD;cACzF,8FAA8F;cAC9F,sFAAsF;QACxF,0FAA0F;QAC1F,4DAA4D;QAC5D,CAAC,EACD,2BAA2B,CAC5B,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,+DAA+D;IAC/D,IAAI,WAAW;QACb,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,iBAAiB,GAA2B;IAChD,QAAQ,EAAE,kBAAkB;IAC5B,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE,kBAAkB;IAC1B,QAAQ,EAAE,kBAAkB;IAC5B,KAAK,EAAE,cAAc;CACtB,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,KAAyC;IACxE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,OAAO,iBAAiB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carry: extra authorities and a deadline.
|
|
3
|
+
*
|
|
4
|
+
* Both are forwarded to Accumulate as part of the transaction header. They are validated here with
|
|
5
|
+
* the same rules the gateway applies, so a mistake is refused before an Idempotency-Key is spent and
|
|
6
|
+
* before anything is signed — not after a round trip that names a snake_case field the caller never
|
|
7
|
+
* typed.
|
|
8
|
+
*
|
|
9
|
+
* Header authorities are REFUSED by the gateway by default (HTTP 422,
|
|
10
|
+
* `HEADER_AUTHORITY_NOT_EXECUTABLE`): the validators do not yet count a header authority's
|
|
11
|
+
* signature, so an intent carrying one would sit pending, collect every signature, and then never
|
|
12
|
+
* execute. Put a party that must co-sign on the ACCOUNT's authorities instead. The field is exposed
|
|
13
|
+
* so a deployment that has turned the gateway guard off can use it, and so the SDK does not need a
|
|
14
|
+
* release when the validator fix lands.
|
|
15
|
+
*/
|
|
16
|
+
/** The gateway's limit on DISTINCT books, counted after normalisation. More is refused with a 400. */
|
|
17
|
+
export declare const MAX_ADDITIONAL_AUTHORITIES = 8;
|
|
18
|
+
/** The gateway's longest accepted authority URL, checked on the raw entry. */
|
|
19
|
+
export declare const MAX_AUTHORITY_URL_LENGTH = 512;
|
|
20
|
+
/**
|
|
21
|
+
* The gateway's default deadline window: 60 s to 7 days from its clock, in whole seconds
|
|
22
|
+
* (`INTENT_EXPIRY_MIN_S` / `INTENT_EXPIRY_MAX_S`, refused as `EXPIRES_AT_OUT_OF_RANGE`).
|
|
23
|
+
*/
|
|
24
|
+
export declare const GATEWAY_EXPIRY_MIN_S = 60;
|
|
25
|
+
export declare const GATEWAY_EXPIRY_MAX_S: number;
|
|
26
|
+
/**
|
|
27
|
+
* The minimum refused LOCALLY. Higher than the gateway's 60 s on purpose: the deadline is measured
|
|
28
|
+
* when the call is made and checked when the request lands, and a signing prompt, a funding check
|
|
29
|
+
* and the round trip all sit in between. A deadline that passes the local check and fails the remote
|
|
30
|
+
* one costs a request and reads as a gateway fault; 30 s of margin makes that practically impossible.
|
|
31
|
+
*/
|
|
32
|
+
export declare const LOCAL_EXPIRY_MIN_S = 90;
|
|
33
|
+
/**
|
|
34
|
+
* Validate and normalise `additionalAuthorities` exactly as the gateway does: each entry a string of
|
|
35
|
+
* at most 512 characters; trimmed, lowercased and stripped of trailing slashes; then an `acc://` URL
|
|
36
|
+
* with a non-empty host; de-duplicated in caller order; and only THEN at most eight distinct books.
|
|
37
|
+
*
|
|
38
|
+
* Returns `undefined` for an absent or empty list, so the request body carries the field only when
|
|
39
|
+
* it means something. (The gateway additionally refuses the identity's own key book, which needs
|
|
40
|
+
* server-side knowledge and is not mirrored here.)
|
|
41
|
+
*/
|
|
42
|
+
export declare function normalizeAdditionalAuthorities(value: unknown, where?: string): string[] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Validate `expiresAt` and render it as RFC 3339.
|
|
45
|
+
*
|
|
46
|
+
* A `Date` becomes its ISO string; a string must be RFC 3339 with a timezone and is passed through
|
|
47
|
+
* trimmed. The deadline, in whole seconds as the gateway counts it, must be between 90 s (local
|
|
48
|
+
* margin over the gateway's 60 s minimum) and 7 days from now.
|
|
49
|
+
*/
|
|
50
|
+
export declare function normalizeExpiresAt(value: unknown, now?: number, where?: string): string | undefined;
|
|
51
|
+
/** Codes of the local header-field refusals above. Status 0: raised before any request. */
|
|
52
|
+
export declare const HEADER_FIELD_ERROR_CODES: readonly string[];
|
|
53
|
+
/**
|
|
54
|
+
* `"90s"`, `"30m"`, `"2h"`, `"7d"` → milliseconds. One positive integer and one unit; anything else
|
|
55
|
+
* throws, because a deadline is not a place to guess what a caller meant.
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseDuration(text: string): number;
|
|
58
|
+
/** A deadline `duration` from now, for `expiresAt`: `expiresAt: expiresIn('30m')`. */
|
|
59
|
+
export declare function expiresIn(duration: string | number, now?: number): Date;
|
|
60
|
+
/** Both header fields, validated, as the snake_case body keys the gateway expects. */
|
|
61
|
+
export declare function headerFieldsBody(p: {
|
|
62
|
+
additionalAuthorities?: unknown;
|
|
63
|
+
expiresAt?: unknown;
|
|
64
|
+
}): {
|
|
65
|
+
additional_authorities?: string[];
|
|
66
|
+
expires_at?: string;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=header-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-fields.d.ts","sourceRoot":"","sources":["../src/header-fields.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH,sGAAsG;AACtG,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAC5C,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,oBAAoB,QAAgB,CAAC;AAClD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAYrC;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAA0B,GAAG,MAAM,EAAE,GAAG,SAAS,CA6BpH;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,GAAE,MAAmB,EAAE,KAAK,SAAc,GAAG,MAAM,GAAG,SAAS,CAyCpH;AAED,2FAA2F;AAC3F,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAErD,CAAC;AAIF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED,sFAAsF;AACtF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,IAAI,CAMnF;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG;IAC7F,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAKA"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { CertenError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Transaction-header fields an intent may carry: extra authorities and a deadline.
|
|
4
|
+
*
|
|
5
|
+
* Both are forwarded to Accumulate as part of the transaction header. They are validated here with
|
|
6
|
+
* the same rules the gateway applies, so a mistake is refused before an Idempotency-Key is spent and
|
|
7
|
+
* before anything is signed — not after a round trip that names a snake_case field the caller never
|
|
8
|
+
* typed.
|
|
9
|
+
*
|
|
10
|
+
* Header authorities are REFUSED by the gateway by default (HTTP 422,
|
|
11
|
+
* `HEADER_AUTHORITY_NOT_EXECUTABLE`): the validators do not yet count a header authority's
|
|
12
|
+
* signature, so an intent carrying one would sit pending, collect every signature, and then never
|
|
13
|
+
* execute. Put a party that must co-sign on the ACCOUNT's authorities instead. The field is exposed
|
|
14
|
+
* so a deployment that has turned the gateway guard off can use it, and so the SDK does not need a
|
|
15
|
+
* release when the validator fix lands.
|
|
16
|
+
*/
|
|
17
|
+
/** The gateway's limit on DISTINCT books, counted after normalisation. More is refused with a 400. */
|
|
18
|
+
export const MAX_ADDITIONAL_AUTHORITIES = 8;
|
|
19
|
+
/** The gateway's longest accepted authority URL, checked on the raw entry. */
|
|
20
|
+
export const MAX_AUTHORITY_URL_LENGTH = 512;
|
|
21
|
+
/**
|
|
22
|
+
* The gateway's default deadline window: 60 s to 7 days from its clock, in whole seconds
|
|
23
|
+
* (`INTENT_EXPIRY_MIN_S` / `INTENT_EXPIRY_MAX_S`, refused as `EXPIRES_AT_OUT_OF_RANGE`).
|
|
24
|
+
*/
|
|
25
|
+
export const GATEWAY_EXPIRY_MIN_S = 60;
|
|
26
|
+
export const GATEWAY_EXPIRY_MAX_S = 7 * 24 * 3600;
|
|
27
|
+
/**
|
|
28
|
+
* The minimum refused LOCALLY. Higher than the gateway's 60 s on purpose: the deadline is measured
|
|
29
|
+
* when the call is made and checked when the request lands, and a signing prompt, a funding check
|
|
30
|
+
* and the round trip all sit in between. A deadline that passes the local check and fails the remote
|
|
31
|
+
* one costs a request and reads as a gateway fault; 30 s of margin makes that practically impossible.
|
|
32
|
+
*/
|
|
33
|
+
export const LOCAL_EXPIRY_MIN_S = 90;
|
|
34
|
+
/** RFC 3339 date-time with a timezone — the gateway's exact pattern. */
|
|
35
|
+
const RFC3339 = /^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(\.\d+)?([Zz]|[+-]\d{2}:\d{2})$/;
|
|
36
|
+
/** An Accumulate URL with a non-empty host and no whitespace — the gateway's exact pattern. */
|
|
37
|
+
const ACC_URL = /^acc:\/\/[^\s/][^\s]*$/;
|
|
38
|
+
/** The gateway's normalisation: trim, lowercase, strip trailing slashes. */
|
|
39
|
+
function normalizeUrl(u) {
|
|
40
|
+
return u.trim().toLowerCase().replace(/\/+$/, '');
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate and normalise `additionalAuthorities` exactly as the gateway does: each entry a string of
|
|
44
|
+
* at most 512 characters; trimmed, lowercased and stripped of trailing slashes; then an `acc://` URL
|
|
45
|
+
* with a non-empty host; de-duplicated in caller order; and only THEN at most eight distinct books.
|
|
46
|
+
*
|
|
47
|
+
* Returns `undefined` for an absent or empty list, so the request body carries the field only when
|
|
48
|
+
* it means something. (The gateway additionally refuses the identity's own key book, which needs
|
|
49
|
+
* server-side knowledge and is not mirrored here.)
|
|
50
|
+
*/
|
|
51
|
+
export function normalizeAdditionalAuthorities(value, where = 'additionalAuthorities') {
|
|
52
|
+
if (value === undefined || value === null)
|
|
53
|
+
return undefined;
|
|
54
|
+
if (!Array.isArray(value)) {
|
|
55
|
+
throw new CertenError(`${where} must be an array of acc:// key book URLs`, 0, 'INVALID_ADDITIONAL_AUTHORITIES');
|
|
56
|
+
}
|
|
57
|
+
const out = [];
|
|
58
|
+
for (const [i, entry] of value.entries()) {
|
|
59
|
+
if (typeof entry !== 'string' || entry.length > MAX_AUTHORITY_URL_LENGTH) {
|
|
60
|
+
throw new CertenError(`${where}[${i}] must be a string of at most ${MAX_AUTHORITY_URL_LENGTH} characters`, 0, 'INVALID_ADDITIONAL_AUTHORITIES');
|
|
61
|
+
}
|
|
62
|
+
const url = normalizeUrl(entry);
|
|
63
|
+
if (!ACC_URL.test(url)) {
|
|
64
|
+
throw new CertenError(`${where}[${i}] ${JSON.stringify(entry)} is not an Accumulate URL — expected acc://<host>…, e.g. acc://firm.acme/book`, 0, 'INVALID_ADDITIONAL_AUTHORITIES');
|
|
65
|
+
}
|
|
66
|
+
if (!out.includes(url))
|
|
67
|
+
out.push(url);
|
|
68
|
+
}
|
|
69
|
+
if (out.length > MAX_ADDITIONAL_AUTHORITIES) {
|
|
70
|
+
throw new CertenError(`${where} names ${out.length} distinct books; at most ${MAX_ADDITIONAL_AUTHORITIES} are allowed`, 0, 'INVALID_ADDITIONAL_AUTHORITIES');
|
|
71
|
+
}
|
|
72
|
+
return out.length > 0 ? out : undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Validate `expiresAt` and render it as RFC 3339.
|
|
76
|
+
*
|
|
77
|
+
* A `Date` becomes its ISO string; a string must be RFC 3339 with a timezone and is passed through
|
|
78
|
+
* trimmed. The deadline, in whole seconds as the gateway counts it, must be between 90 s (local
|
|
79
|
+
* margin over the gateway's 60 s minimum) and 7 days from now.
|
|
80
|
+
*/
|
|
81
|
+
export function normalizeExpiresAt(value, now = Date.now(), where = 'expiresAt') {
|
|
82
|
+
if (value === undefined || value === null)
|
|
83
|
+
return undefined;
|
|
84
|
+
let iso;
|
|
85
|
+
let at;
|
|
86
|
+
if (value instanceof Date) {
|
|
87
|
+
at = value.getTime();
|
|
88
|
+
if (!Number.isFinite(at))
|
|
89
|
+
throw new CertenError(`${where} is an invalid Date`, 0, 'INVALID_EXPIRES_AT');
|
|
90
|
+
iso = value.toISOString();
|
|
91
|
+
}
|
|
92
|
+
else if (typeof value === 'string') {
|
|
93
|
+
iso = value.trim();
|
|
94
|
+
at = Date.parse(iso);
|
|
95
|
+
if (!RFC3339.test(iso) || !Number.isFinite(at)) {
|
|
96
|
+
throw new CertenError(`${where} "${value}" is not an RFC 3339 date-time with a timezone, e.g. 2026-09-14T12:00:00Z`, 0, 'INVALID_EXPIRES_AT');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw new CertenError(`${where} must be a Date or an RFC 3339 string`, 0, 'INVALID_EXPIRES_AT');
|
|
101
|
+
}
|
|
102
|
+
const deltaS = Math.floor(at / 1000) - Math.floor(now / 1000);
|
|
103
|
+
if (deltaS <= 0) {
|
|
104
|
+
throw new CertenError(`${where} ${iso} is in the past — it must be between ${LOCAL_EXPIRY_MIN_S}s and ${GATEWAY_EXPIRY_MAX_S}s (7 days) from now`, 0, 'INVALID_EXPIRES_AT');
|
|
105
|
+
}
|
|
106
|
+
if (deltaS < LOCAL_EXPIRY_MIN_S) {
|
|
107
|
+
throw new CertenError(`${where} is only ${deltaS}s away. The gateway requires at least ${GATEWAY_EXPIRY_MIN_S}s when the request arrives; `
|
|
108
|
+
+ `the SDK asks for ${LOCAL_EXPIRY_MIN_S}s so signing and network time cannot push it under. Use a later deadline.`, 0, 'INVALID_EXPIRES_AT');
|
|
109
|
+
}
|
|
110
|
+
if (deltaS > GATEWAY_EXPIRY_MAX_S) {
|
|
111
|
+
throw new CertenError(`${where} is ${deltaS}s away; the gateway allows at most ${GATEWAY_EXPIRY_MAX_S}s (7 days)`, 0, 'INVALID_EXPIRES_AT');
|
|
112
|
+
}
|
|
113
|
+
return iso;
|
|
114
|
+
}
|
|
115
|
+
/** Codes of the local header-field refusals above. Status 0: raised before any request. */
|
|
116
|
+
export const HEADER_FIELD_ERROR_CODES = [
|
|
117
|
+
'INVALID_ADDITIONAL_AUTHORITIES', 'INVALID_EXPIRES_AT', 'INVALID_DURATION',
|
|
118
|
+
];
|
|
119
|
+
const UNIT_MS = { s: 1_000, m: 60_000, h: 3_600_000, d: 86_400_000 };
|
|
120
|
+
/**
|
|
121
|
+
* `"90s"`, `"30m"`, `"2h"`, `"7d"` → milliseconds. One positive integer and one unit; anything else
|
|
122
|
+
* throws, because a deadline is not a place to guess what a caller meant.
|
|
123
|
+
*/
|
|
124
|
+
export function parseDuration(text) {
|
|
125
|
+
const m = /^\s*(\d+)\s*([smhd])\s*$/i.exec(String(text ?? ''));
|
|
126
|
+
const n = m ? Number(m[1]) : NaN;
|
|
127
|
+
if (!m || !Number.isSafeInteger(n) || n <= 0) {
|
|
128
|
+
throw new CertenError(`duration "${text}" is not valid — use a positive whole number followed by s, m, h or d, e.g. 30m`, 0, 'INVALID_DURATION');
|
|
129
|
+
}
|
|
130
|
+
return n * UNIT_MS[m[2].toLowerCase()];
|
|
131
|
+
}
|
|
132
|
+
/** A deadline `duration` from now, for `expiresAt`: `expiresAt: expiresIn('30m')`. */
|
|
133
|
+
export function expiresIn(duration, now = Date.now()) {
|
|
134
|
+
const ms = typeof duration === 'number' ? duration : parseDuration(duration);
|
|
135
|
+
if (!Number.isFinite(ms) || ms <= 0) {
|
|
136
|
+
throw new CertenError(`expiresIn needs a positive duration, got ${JSON.stringify(duration)}`, 0, 'INVALID_DURATION');
|
|
137
|
+
}
|
|
138
|
+
return new Date(now + ms);
|
|
139
|
+
}
|
|
140
|
+
/** Both header fields, validated, as the snake_case body keys the gateway expects. */
|
|
141
|
+
export function headerFieldsBody(p) {
|
|
142
|
+
return {
|
|
143
|
+
additional_authorities: normalizeAdditionalAuthorities(p.additionalAuthorities),
|
|
144
|
+
expires_at: normalizeExpiresAt(p.expiresAt),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=header-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-fields.js","sourceRoot":"","sources":["../src/header-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;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,CAAC,4CAA4C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACvH,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;AAC5B,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,gBAAgB,CAAC,CAA2D;IAI1F,OAAO;QACL,sBAAsB,EAAE,8BAA8B,CAAC,CAAC,CAAC,qBAAqB,CAAC;QAC/E,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export {
|
|
7
|
-
export { fetchSharedProof, parseShareTarget, decodeSharedBundle } from './shared-proof.js';
|
|
8
|
-
export { verifyExecutionProof, checkAgainstHeader, executionComponentOf, decodeReceipt, verifyTrieProof, keccak256, rlpDecode, rlpEncodeUint, bytesFrom, } from './execution-proof.js';
|
|
9
|
-
export type { ExecutionProofComponent, ExecutionVerification, DecodedReceipt, DecodedLog } from './execution-proof.js';
|
|
10
|
-
export { fetchOAuthToken, refreshOAuthToken, revokeOAuthToken } from './oauth.js';
|
|
11
|
-
export { parseMnemonicTarget } from './resources/identity.js';
|
|
12
|
-
export { redeemRegistrationToken } from './registration.js';
|
|
13
|
-
export { selfSignup, requestSignupChallenge, completeSignup } from './self-signup.js';
|
|
14
|
-
export { CertenUnfundedAccountError, movesValue, normalizeChainId } from './funding.js';
|
|
15
|
-
export { resolveSignTarget } from './sign-target.js';
|
|
1
|
+
/**
|
|
2
|
+
* The SDK's default entry (Node): everything in the browser-safe surface, plus the two parts that need Node.
|
|
3
|
+
* See browser.ts for the portable half and why the split exists.
|
|
4
|
+
*/
|
|
5
|
+
export * from './browser.js';
|
|
6
|
+
export { fetchSharedProof, decodeSharedBundle } from './shared-proof.js';
|
|
16
7
|
export { CertenAgent, ed25519Signer } from './agent.js';
|
|
17
8
|
export type { AgentSigner, CertenAgentState, ProvisionParams } from './agent.js';
|
|
18
|
-
export
|
|
19
|
-
export type {
|
|
9
|
+
export { CertenSigningDataError, checkIntentSigning, checkCosigning, checkGovernanceSigning, inspectSigningData, legsFromIntent, toBaseUnits, SIGNING_DATA_MISMATCH, SIGNING_DATA_ABSENT, SIGNING_VERIFIER_UNAVAILABLE, SIGNING_EXPECTATION_UNAVAILABLE, } from './signing-check.js';
|
|
10
|
+
export type { SigningSummary, ExpectedLeg, ExpectedOperation, Expectation } from './signing-check.js';
|
|
11
|
+
export type { BeforeSign } from './resources/execute.js';
|
|
20
12
|
//# sourceMappingURL=index.d.ts.map
|