@certen.io/sdk 0.5.0 → 0.7.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 +576 -0
- package/README.md +133 -119
- package/dist/client.d.ts +96 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +258 -20
- package/dist/client.js.map +1 -1
- package/dist/doctor.d.ts +53 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +451 -0
- package/dist/doctor.js.map +1 -0
- package/dist/error-codes.d.ts +14 -0
- package/dist/error-codes.d.ts.map +1 -0
- package/dist/error-codes.js +55 -0
- package/dist/error-codes.js.map +1 -0
- package/dist/errors.d.ts +13 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +18 -1
- package/dist/errors.js.map +1 -1
- package/dist/funding.d.ts +43 -0
- package/dist/funding.d.ts.map +1 -0
- package/dist/funding.js +116 -0
- package/dist/funding.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/oauth.d.ts +56 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +68 -0
- package/dist/oauth.js.map +1 -0
- package/dist/registration.d.ts +33 -0
- package/dist/registration.d.ts.map +1 -0
- package/dist/registration.js +49 -0
- package/dist/registration.js.map +1 -0
- package/dist/resources/admin.d.ts +52 -1
- package/dist/resources/admin.d.ts.map +1 -1
- package/dist/resources/admin.js +55 -0
- package/dist/resources/admin.js.map +1 -1
- package/dist/resources/billing.d.ts +198 -19
- package/dist/resources/billing.d.ts.map +1 -1
- package/dist/resources/billing.js +297 -7
- package/dist/resources/billing.js.map +1 -1
- package/dist/resources/chains.d.ts +38 -0
- package/dist/resources/chains.d.ts.map +1 -0
- package/dist/resources/chains.js +46 -0
- package/dist/resources/chains.js.map +1 -0
- package/dist/resources/device.d.ts +43 -0
- package/dist/resources/device.d.ts.map +1 -0
- package/dist/resources/device.js +49 -0
- package/dist/resources/device.js.map +1 -0
- package/dist/resources/execute.d.ts +10 -0
- package/dist/resources/execute.d.ts.map +1 -1
- package/dist/resources/execute.js +18 -0
- package/dist/resources/execute.js.map +1 -1
- package/dist/resources/health.d.ts +34 -0
- package/dist/resources/health.d.ts.map +1 -0
- package/dist/resources/health.js +43 -0
- package/dist/resources/health.js.map +1 -0
- package/dist/resources/identity.d.ts +83 -2
- package/dist/resources/identity.d.ts.map +1 -1
- package/dist/resources/identity.js +154 -2
- package/dist/resources/identity.js.map +1 -1
- package/dist/resources/oauth-clients.d.ts +71 -0
- package/dist/resources/oauth-clients.d.ts.map +1 -0
- package/dist/resources/oauth-clients.js +75 -0
- package/dist/resources/oauth-clients.js.map +1 -0
- package/dist/resources/pending.d.ts +13 -1
- package/dist/resources/pending.d.ts.map +1 -1
- package/dist/resources/pending.js +15 -0
- package/dist/resources/pending.js.map +1 -1
- package/dist/resources/proof.d.ts +75 -0
- package/dist/resources/proof.d.ts.map +1 -0
- package/dist/resources/proof.js +103 -0
- package/dist/resources/proof.js.map +1 -0
- package/dist/resources/registration-tokens.d.ts +51 -0
- package/dist/resources/registration-tokens.d.ts.map +1 -0
- package/dist/resources/registration-tokens.js +54 -0
- package/dist/resources/registration-tokens.js.map +1 -0
- package/dist/resources/transaction.d.ts +20 -0
- package/dist/resources/transaction.d.ts.map +1 -1
- package/dist/resources/transaction.js +28 -0
- package/dist/resources/transaction.js.map +1 -1
- package/dist/resources/transparency.d.ts +68 -0
- package/dist/resources/transparency.d.ts.map +1 -0
- package/dist/resources/transparency.js +83 -0
- package/dist/resources/transparency.js.map +1 -0
- package/dist/resources/webhooks.d.ts +97 -0
- package/dist/resources/webhooks.d.ts.map +1 -0
- package/dist/resources/webhooks.js +112 -0
- package/dist/resources/webhooks.js.map +1 -0
- package/dist/self-signup.d.ts +66 -0
- package/dist/self-signup.d.ts.map +1 -0
- package/dist/self-signup.js +76 -0
- package/dist/self-signup.js.map +1 -0
- package/dist/shared-proof.d.ts +34 -0
- package/dist/shared-proof.d.ts.map +1 -0
- package/dist/shared-proof.js +78 -0
- package/dist/shared-proof.js.map +1 -0
- package/dist/types.d.ts +790 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/verify-receipt.d.ts +32 -0
- package/dist/verify-receipt.d.ts.map +1 -0
- package/dist/verify-receipt.js +176 -0
- package/dist/verify-receipt.js.map +1 -0
- package/package.json +6 -5
package/dist/doctor.js
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { CertenError } from './errors.js';
|
|
2
|
+
import { VENDORED_ERROR_CODES } from './error-codes.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks that cannot run without a working credential, in the order they are reported.
|
|
5
|
+
*
|
|
6
|
+
* Exported because the CLI needs the same list: it knows things the SDK cannot (whether a key is
|
|
7
|
+
* configured on this machine at all) and has to mark the same checks skipped. It kept its own copy
|
|
8
|
+
* once, the two drifted, and a machine with no API key showed a verdict for the check that had been
|
|
9
|
+
* added to only one of them. One list, imported, makes that impossible rather than merely
|
|
10
|
+
* discouraged.
|
|
11
|
+
*/
|
|
12
|
+
export const CREDENTIALLED_CHECKS = [
|
|
13
|
+
'identity can sign',
|
|
14
|
+
'abstract accounts funded',
|
|
15
|
+
'billing balance',
|
|
16
|
+
'credit / trial',
|
|
17
|
+
'intents executing',
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* States in which an intent is waiting on the PLATFORM to do something.
|
|
21
|
+
*
|
|
22
|
+
* `signing_required` is deliberately absent. That state means the intent is waiting on a human
|
|
23
|
+
* co-signer, and on a multi-signature panel that legitimately takes hours or weeks — flagging it as
|
|
24
|
+
* stalled would cry wolf on the one state that is supposed to sit still.
|
|
25
|
+
*/
|
|
26
|
+
const AWAITING_EXECUTION = ['anchoring', 'submitted', 'executing', 'proving'];
|
|
27
|
+
/**
|
|
28
|
+
* How long before "still working" becomes "not working".
|
|
29
|
+
*
|
|
30
|
+
* A proof cycle is 60–110 seconds of real validator work and `execute.wait()` budgets 360s. Fifteen
|
|
31
|
+
* minutes is far enough past both that a queue backlog is not mistaken for a stall.
|
|
32
|
+
*/
|
|
33
|
+
const STALL_AFTER_MS = 15 * 60_000;
|
|
34
|
+
/**
|
|
35
|
+
* Numeric EVM chain id → registry slug, for chains where the portfolio may report either.
|
|
36
|
+
*
|
|
37
|
+
* `GET /v1/portfolio` used to return `chain_id` as a slug on some chain accounts and as a numeric
|
|
38
|
+
* EVM id on others, in the same response. Anything that compares or de-duplicates on that field
|
|
39
|
+
* had to normalize first, or it reported one chain twice and found no faucet for the numeric copy.
|
|
40
|
+
*
|
|
41
|
+
* The gateway now canonicalizes on write and has backfilled the old rows. This is kept because the
|
|
42
|
+
* SDK is versioned independently of the gateway and may be pointed at an older one — and `doctor`
|
|
43
|
+
* of all things must not be the command that misreports when talking to an older peer.
|
|
44
|
+
*/
|
|
45
|
+
const NUMERIC_CHAIN_IDS = {
|
|
46
|
+
11155111: 'ethereum-sepolia',
|
|
47
|
+
84532: 'base-sepolia',
|
|
48
|
+
421614: 'arbitrum-sepolia',
|
|
49
|
+
11155420: 'optimism-sepolia',
|
|
50
|
+
80002: 'polygon-amoy',
|
|
51
|
+
};
|
|
52
|
+
function normalizeChain(value) {
|
|
53
|
+
if (value === null || value === undefined)
|
|
54
|
+
return '';
|
|
55
|
+
const raw = String(value).trim();
|
|
56
|
+
return NUMERIC_CHAIN_IDS[raw] ?? raw;
|
|
57
|
+
}
|
|
58
|
+
function summarize(items, max = 3) {
|
|
59
|
+
if (items.length <= max)
|
|
60
|
+
return items.join(', ');
|
|
61
|
+
return `${items.slice(0, max).join(', ')} and ${items.length - max} more`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Is anything actually EXECUTING?
|
|
65
|
+
*
|
|
66
|
+
* The check that exists because everything above it can pass while the platform still does no work.
|
|
67
|
+
* A proof-gated intent has two halves: the authorization, which the gateway writes to Accumulate and
|
|
68
|
+
* anchors, and the execution on the destination chain. The first can succeed perfectly while the
|
|
69
|
+
* second never runs — observed on a deployment where the gateway was healthy, the account was
|
|
70
|
+
* funded, the authorization anchored correctly, and no cross-chain executor was deployed at all.
|
|
71
|
+
*
|
|
72
|
+
* Every other check reported a clean bill of health, because every other check was true.
|
|
73
|
+
*/
|
|
74
|
+
function executionCheck(list) {
|
|
75
|
+
// Takes the already-fetched list rather than fetching its own. It is the last check reported, but
|
|
76
|
+
// its data depends on nothing above it, so making it wait cost a round trip of pure latency on the
|
|
77
|
+
// command whose whole job is to answer a stuck user quickly.
|
|
78
|
+
if (!list) {
|
|
79
|
+
return { name: 'intents executing', status: 'skipped', detail: 'could not list transactions' };
|
|
80
|
+
}
|
|
81
|
+
const rows = (list.transactions
|
|
82
|
+
?? list.intents
|
|
83
|
+
?? []);
|
|
84
|
+
if (rows.length === 0) {
|
|
85
|
+
return { name: 'intents executing', status: 'ok', detail: 'no intents yet' };
|
|
86
|
+
}
|
|
87
|
+
const now = Date.now();
|
|
88
|
+
const stalled = rows.filter((r) => {
|
|
89
|
+
if (!AWAITING_EXECUTION.includes(String(r.status ?? '')))
|
|
90
|
+
return false;
|
|
91
|
+
const since = Date.parse(String(r.updated_at ?? r.created_at ?? ''));
|
|
92
|
+
return Number.isFinite(since) && now - since > STALL_AFTER_MS;
|
|
93
|
+
});
|
|
94
|
+
if (stalled.length === 0) {
|
|
95
|
+
return {
|
|
96
|
+
name: 'intents executing',
|
|
97
|
+
status: 'ok',
|
|
98
|
+
detail: `${rows.length} recent intent(s), none stalled`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const oldest = stalled
|
|
102
|
+
.map((r) => now - Date.parse(String(r.updated_at ?? r.created_at)))
|
|
103
|
+
.sort((a, b) => b - a)[0];
|
|
104
|
+
const hours = Math.round(oldest / 3_600_000);
|
|
105
|
+
const age = hours >= 1 ? `${hours}h` : `${Math.round(oldest / 60_000)}m`;
|
|
106
|
+
const example = String(stalled[0].intent_id ?? stalled[0].id ?? '<id>');
|
|
107
|
+
return {
|
|
108
|
+
name: 'intents executing',
|
|
109
|
+
// A warning, not a failure: the caller's own setup is fine, and saying "you have a problem"
|
|
110
|
+
// about someone else's infrastructure would be wrong. But it must be visible, because until it
|
|
111
|
+
// resolves no proof-gated call this account makes will complete.
|
|
112
|
+
status: 'warn',
|
|
113
|
+
detail: `${stalled.length} intent(s) awaiting execution for over ${age}. The authorization `
|
|
114
|
+
+ 'anchored; the execution leg has not completed. This is usually the cross-chain executor, '
|
|
115
|
+
+ 'not your integration.',
|
|
116
|
+
fix: `certen proof get ${example} — if anchored:true and the destination chain shows no change, `
|
|
117
|
+
+ 'the authorization succeeded and execution never ran.',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Run the diagnostic.
|
|
122
|
+
*
|
|
123
|
+
* Never throws for a failed check — a diagnosis that cannot report a broken setup is useless. It
|
|
124
|
+
* throws only if something outside the checks goes wrong.
|
|
125
|
+
*/
|
|
126
|
+
export async function runDoctor(client) {
|
|
127
|
+
const checks = [];
|
|
128
|
+
let unreachable = false;
|
|
129
|
+
// ── 1. Is the gateway there at all? ─────────────────────────────────────────────────────────
|
|
130
|
+
// `GET /v1/chains` is public, so this distinguishes "wrong address / network down" from "bad
|
|
131
|
+
// credential" before any credential is involved.
|
|
132
|
+
try {
|
|
133
|
+
const registry = await client.chains.list();
|
|
134
|
+
checks.push({
|
|
135
|
+
name: 'gateway reachable',
|
|
136
|
+
status: 'ok',
|
|
137
|
+
detail: `registry v${registry.version}, ${registry.count} chains`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
unreachable = true;
|
|
142
|
+
checks.push({
|
|
143
|
+
name: 'gateway reachable',
|
|
144
|
+
status: 'fail',
|
|
145
|
+
detail: err instanceof Error ? err.message : String(err),
|
|
146
|
+
fix: 'Check the base URL and network. Nothing else can be diagnosed until this passes.',
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// ── 1b. Can the platform actually serve? ────────────────────────────────────────────────────
|
|
150
|
+
//
|
|
151
|
+
// Check 1 proves the gateway is answering HTTP, and nothing more: `GET /v1/chains` is a static
|
|
152
|
+
// registry read that keeps returning 200 while the database, the api-bridge, the proof service or
|
|
153
|
+
// Accumulate are down. So a CERTEN-side outage was indistinguishable from a broken local setup,
|
|
154
|
+
// and the report said "gateway reachable: ok" while sending the reader to look at their own
|
|
155
|
+
// configuration for a fault that was never theirs.
|
|
156
|
+
//
|
|
157
|
+
// `sponsor_below_floor` is the reason this check earns its round trip. When the onboarding
|
|
158
|
+
// sponsor runs dry, identity creation returns 202 and then never completes — every visible signal
|
|
159
|
+
// says it worked. Nothing else in this report can see that.
|
|
160
|
+
if (!unreachable) {
|
|
161
|
+
try {
|
|
162
|
+
const readiness = await client.health.ready();
|
|
163
|
+
if (readiness.ready) {
|
|
164
|
+
const warning = (readiness.reasons ?? []).includes('sponsor_low_warning');
|
|
165
|
+
checks.push({
|
|
166
|
+
name: 'platform ready',
|
|
167
|
+
status: warning ? 'warn' : 'ok',
|
|
168
|
+
detail: warning
|
|
169
|
+
? 'Serving normally. CERTEN reports its onboarding sponsor is running low'
|
|
170
|
+
+ (readiness.sponsor_identities_remaining != null
|
|
171
|
+
? ` (~${readiness.sponsor_identities_remaining} identities left)` : '')
|
|
172
|
+
+ ' — not an outage, but identity creation may be affected soon.'
|
|
173
|
+
: 'All components serving.',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const reasons = readiness.reasons ?? [];
|
|
178
|
+
const sponsorDry = reasons.includes('sponsor_below_floor');
|
|
179
|
+
// Named separately because the consequence differs: a dry sponsor stops identity CREATION
|
|
180
|
+
// (silently, with a 202), while an entitlement gap stops EXECUTION of work already created.
|
|
181
|
+
const gateShut = reasons.includes('entitlement_unpublished')
|
|
182
|
+
|| reasons.includes('entitlement_expired');
|
|
183
|
+
checks.push({
|
|
184
|
+
name: 'platform ready',
|
|
185
|
+
status: 'fail',
|
|
186
|
+
detail: sponsorDry
|
|
187
|
+
? 'CERTEN is not ready: the onboarding sponsor is below its floor. Identity creation '
|
|
188
|
+
+ 'will return 202 and then NEVER complete.'
|
|
189
|
+
+ (reasons.length > 1 ? ` Also down: ${reasons.filter((r) => r !== 'sponsor_below_floor').join(', ')}.` : '')
|
|
190
|
+
: gateShut
|
|
191
|
+
? 'CERTEN is not ready: no valid entitlement epoch is published, so validators are '
|
|
192
|
+
+ 'refusing every intent. Work will not execute until this clears.'
|
|
193
|
+
+ (reasons.length > 1 ? ` Also affected: ${reasons.filter((r) => !r.startsWith('entitlement_')).join(', ')}.` : '')
|
|
194
|
+
: `CERTEN is not ready. Affected: ${reasons.join(', ') || 'unspecified'}.`,
|
|
195
|
+
// Deliberately not a configuration instruction. The whole value of this check is telling
|
|
196
|
+
// someone to STOP looking at their own setup, so the fix must not send them back to it.
|
|
197
|
+
fix: sponsorDry
|
|
198
|
+
? 'Nothing on your side to change. Do not create identities until this clears — they '
|
|
199
|
+
+ 'will appear to succeed and never finish. Retry later or contact CERTEN.'
|
|
200
|
+
: 'Nothing on your side to change — this is a CERTEN-side outage. Retry later.',
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
// The probe is public and cheap; failing it while `/v1/chains` succeeded is odd enough to
|
|
206
|
+
// report, but it is not evidence that anything is broken for this caller.
|
|
207
|
+
checks.push({
|
|
208
|
+
name: 'platform ready',
|
|
209
|
+
status: 'warn',
|
|
210
|
+
detail: `Could not read the readiness probe: ${err instanceof Error ? err.message : String(err)}`,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
checks.push({ name: 'platform ready', status: 'skipped', detail: 'gateway unreachable' });
|
|
216
|
+
}
|
|
217
|
+
// ── 2. Does the gateway accept this credential? ─────────────────────────────────────────────
|
|
218
|
+
let credentialOk = false;
|
|
219
|
+
// The credential probe's answer, kept rather than discarded.
|
|
220
|
+
//
|
|
221
|
+
// Check 2 asks the gateway whether it accepts this key, and the cheapest question that proves it
|
|
222
|
+
// is a balance read. Check 5 then needs the balance — and used to fetch it AGAIN, so `doctor`
|
|
223
|
+
// spent two of its six round trips asking one question twice. Measured against the live gateway:
|
|
224
|
+
// 6 calls, 1785ms, with `/v1/billing/balance` at 190ms and 179ms.
|
|
225
|
+
//
|
|
226
|
+
// Reusing it is sound: these are moments apart, and this is a diagnosis, not a settlement.
|
|
227
|
+
let probedBalance = null;
|
|
228
|
+
if (unreachable) {
|
|
229
|
+
checks.push({ name: 'api key', status: 'skipped', detail: 'gateway unreachable' });
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
try {
|
|
233
|
+
probedBalance = await client.billing.balance();
|
|
234
|
+
credentialOk = true;
|
|
235
|
+
checks.push({ name: 'api key', status: 'ok', detail: 'accepted' });
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
if (err instanceof CertenError && err.status === 403) {
|
|
239
|
+
// The key is real; it simply cannot read billing. Not a blocker for signing work, so the
|
|
240
|
+
// checks that depend on a working credential still run.
|
|
241
|
+
credentialOk = true;
|
|
242
|
+
checks.push({
|
|
243
|
+
name: 'api key',
|
|
244
|
+
status: 'warn',
|
|
245
|
+
detail: 'accepted, but has no billing:read scope',
|
|
246
|
+
fix: 'Balance and credit checks below will be skipped.',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
else if (err instanceof CertenError && err.status === 401) {
|
|
250
|
+
checks.push({
|
|
251
|
+
name: 'api key',
|
|
252
|
+
status: 'fail',
|
|
253
|
+
detail: 'The gateway rejected this key.',
|
|
254
|
+
fix: 'Mint a new key, or check which one is configured.',
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
// Inconclusive is not the same as broken. Say so, and carry on rather than blocking every
|
|
259
|
+
// check below on one unexplained status.
|
|
260
|
+
credentialOk = true;
|
|
261
|
+
checks.push({
|
|
262
|
+
name: 'api key',
|
|
263
|
+
status: 'warn',
|
|
264
|
+
detail: `Could not confirm the key (gateway answered ${err instanceof CertenError ? err.status : '?'}).`,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (!credentialOk) {
|
|
270
|
+
for (const name of CREDENTIALLED_CHECKS) {
|
|
271
|
+
checks.push({ name, status: 'skipped', detail: 'needs a working API key' });
|
|
272
|
+
}
|
|
273
|
+
return { ok: checks.every((c) => c.status !== 'fail'), unreachable, checks };
|
|
274
|
+
}
|
|
275
|
+
// Everything still needed, fetched CONCURRENTLY.
|
|
276
|
+
//
|
|
277
|
+
// These three answer unrelated questions and were awaited one after another, so `doctor` cost the
|
|
278
|
+
// sum of them — on the command whose entire job is to answer a stuck user quickly. The checks are
|
|
279
|
+
// still emitted in their original order below; only the I/O overlaps.
|
|
280
|
+
//
|
|
281
|
+
// `balance` reuses the credential probe when it succeeded, so the duplicate read is gone.
|
|
282
|
+
const [portfolio, balance, recentIntents] = await Promise.all([
|
|
283
|
+
client.portfolio.get().catch(() => null),
|
|
284
|
+
probedBalance ? Promise.resolve(probedBalance) : client.billing.balance().catch(() => null),
|
|
285
|
+
client.transaction.list({ limit: 25 }).catch(() => null),
|
|
286
|
+
]);
|
|
287
|
+
// Commitments now ride along with the balance, so the dedicated `/v1/billing/obligations` read is
|
|
288
|
+
// gone — doctor used its response for one field, `remaining_usd`, and paid a whole round trip for
|
|
289
|
+
// it. Against a gateway that predates the change the field is absent and the old call is made,
|
|
290
|
+
// because the alternative is reporting `spendable_usd` as if it were safe to commit.
|
|
291
|
+
const commitments = balance?.remaining_usd !== undefined
|
|
292
|
+
? {
|
|
293
|
+
remaining_usd: balance.remaining_usd,
|
|
294
|
+
pending_intents: balance.pending_intents ?? 0,
|
|
295
|
+
}
|
|
296
|
+
: await client.billing.obligations().catch(() => null);
|
|
297
|
+
// ── 3-4. Identities, and whether their abstract accounts can execute ────────────────────────
|
|
298
|
+
if (!portfolio) {
|
|
299
|
+
checks.push({ name: 'identity can sign', status: 'warn', detail: 'Could not read the portfolio.' });
|
|
300
|
+
checks.push({ name: 'abstract accounts funded', status: 'skipped', detail: 'portfolio unavailable' });
|
|
301
|
+
}
|
|
302
|
+
else if ((portfolio.identities ?? []).length === 0) {
|
|
303
|
+
checks.push({
|
|
304
|
+
name: 'identity can sign',
|
|
305
|
+
status: 'fail',
|
|
306
|
+
detail: 'No identities in this organization.',
|
|
307
|
+
fix: 'Create one with identity.create(), then poll until can_sign is true.',
|
|
308
|
+
});
|
|
309
|
+
checks.push({ name: 'abstract accounts funded', status: 'skipped', detail: 'no identities' });
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
const active = portfolio.identities.filter((i) => i.status === 'active');
|
|
313
|
+
checks.push(active.length > 0
|
|
314
|
+
? {
|
|
315
|
+
name: 'identity can sign',
|
|
316
|
+
status: 'ok',
|
|
317
|
+
detail: `${active.length} active: ${summarize(active.map((i) => i.adi_url))}`,
|
|
318
|
+
}
|
|
319
|
+
: {
|
|
320
|
+
name: 'identity can sign',
|
|
321
|
+
status: 'fail',
|
|
322
|
+
detail: `${portfolio.identities.length} identity(ies), none active.`,
|
|
323
|
+
fix: 'Check identity.get(id).error_message for why provisioning did not complete.',
|
|
324
|
+
});
|
|
325
|
+
// The silent failure this check exists for: an intent that moves value from an empty abstract
|
|
326
|
+
// account is accepted, signed and submitted, and then parks at `anchoring` forever, because
|
|
327
|
+
// the execution leg cannot run on chain. Nothing in any API response says so.
|
|
328
|
+
const empty = [];
|
|
329
|
+
let accounts = 0;
|
|
330
|
+
for (const identity of portfolio.identities) {
|
|
331
|
+
for (const chain of identity.chains ?? []) {
|
|
332
|
+
const native = (chain.balances ?? [])
|
|
333
|
+
.find((b) => !b.token || b.token === 'ETH' || b.token === 'native');
|
|
334
|
+
if (!native)
|
|
335
|
+
continue;
|
|
336
|
+
accounts += 1;
|
|
337
|
+
if (Number(native.balance) === 0)
|
|
338
|
+
empty.push(normalizeChain(chain.chain_id));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const emptyChains = [...new Set(empty)];
|
|
342
|
+
checks.push(emptyChains.length === 0
|
|
343
|
+
? { name: 'abstract accounts funded', status: 'ok', detail: `all ${accounts} chain account(s) have gas` }
|
|
344
|
+
: {
|
|
345
|
+
name: 'abstract accounts funded',
|
|
346
|
+
status: 'warn',
|
|
347
|
+
detail: `${empty.length} of ${accounts} chain account(s) have no gas, on ${emptyChains.join(', ')}. `
|
|
348
|
+
+ 'A value transfer from an empty one parks at "anchoring" forever.',
|
|
349
|
+
fix: 'Fund the abstract account on that chain before moving value from it.',
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
// ── 5. Is there anything left to spend? ─────────────────────────────────────────────────────
|
|
353
|
+
if (!balance) {
|
|
354
|
+
checks.push({ name: 'billing balance', status: 'skipped', detail: 'balance unavailable' });
|
|
355
|
+
checks.push({ name: 'credit / trial', status: 'skipped', detail: 'balance unavailable' });
|
|
356
|
+
checks.push(executionCheck(recentIntents));
|
|
357
|
+
return { ok: checks.every((c) => c.status !== 'fail'), unreachable, checks };
|
|
358
|
+
}
|
|
359
|
+
if (balance.status !== 'active') {
|
|
360
|
+
checks.push({
|
|
361
|
+
name: 'billing balance',
|
|
362
|
+
status: 'fail',
|
|
363
|
+
detail: `Account is ${balance.status}${balance.suspended_reason ? `: ${balance.suspended_reason}` : ''}.`,
|
|
364
|
+
fix: 'Add funds.',
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
else if (commitments && Number(commitments.remaining_usd) <= 0) {
|
|
368
|
+
// A balance can read healthy while every cent is committed to intents awaiting quorum, and
|
|
369
|
+
// multi-signature intents can wait weeks. `remaining_usd` is the number that decides whether
|
|
370
|
+
// new work is accepted.
|
|
371
|
+
checks.push({
|
|
372
|
+
name: 'billing balance',
|
|
373
|
+
status: 'fail',
|
|
374
|
+
detail: `Nothing left to commit — ${commitments.pending_intents} pending intent(s) have claimed it.`,
|
|
375
|
+
fix: 'Add funds.',
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
checks.push({
|
|
380
|
+
name: 'billing balance',
|
|
381
|
+
status: 'ok',
|
|
382
|
+
detail: `${balance.spendable_usd} spendable`
|
|
383
|
+
+ (commitments ? `, ${commitments.remaining_usd} left to commit` : ''),
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
// ── 6. Is a trial about to end? ─────────────────────────────────────────────────────────────
|
|
387
|
+
const credit = balance.credit;
|
|
388
|
+
if (!credit || credit.kind === 'none') {
|
|
389
|
+
checks.push({ name: 'credit / trial', status: 'ok', detail: 'no credit line in play' });
|
|
390
|
+
}
|
|
391
|
+
else if (credit.expired) {
|
|
392
|
+
checks.push({
|
|
393
|
+
name: 'credit / trial',
|
|
394
|
+
status: 'fail',
|
|
395
|
+
detail: `The ${credit.kind} credit has expired.`,
|
|
396
|
+
fix: 'Add funds.',
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
const days = credit.expires_at
|
|
401
|
+
? Math.max(0, Math.round((new Date(credit.expires_at).getTime() - Date.now()) / 86_400_000))
|
|
402
|
+
: null;
|
|
403
|
+
checks.push(days !== null && days <= 3
|
|
404
|
+
? {
|
|
405
|
+
name: 'credit / trial',
|
|
406
|
+
status: 'warn',
|
|
407
|
+
detail: `${credit.label ?? credit.kind} ends in ${days} day(s).`,
|
|
408
|
+
fix: 'Add funds before it lapses.',
|
|
409
|
+
}
|
|
410
|
+
: {
|
|
411
|
+
name: 'credit / trial',
|
|
412
|
+
status: 'ok',
|
|
413
|
+
detail: `${credit.label ?? credit.kind}${days !== null ? `, ${days} day(s) left` : ''}`,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
checks.push(executionCheck(recentIntents));
|
|
417
|
+
// ── Is this SDK older than the gateway it is talking to? ────────────────────────────────────
|
|
418
|
+
//
|
|
419
|
+
// Clients and the gateway deploy separately, so one is routinely ahead of the other — and the
|
|
420
|
+
// symptoms of that are the most misleading failures on the surface. A method calling a path the
|
|
421
|
+
// deployment does not serve 404s, which reads as "wrong URL" or "no such resource" until someone
|
|
422
|
+
// thinks to compare versions. `ENDPOINT_NOT_ON_GATEWAY` names it once it happens; this says it
|
|
423
|
+
// BEFORE, which is the point of a diagnostic.
|
|
424
|
+
//
|
|
425
|
+
// The error catalogue is the cheapest possible probe: public, one request, and its size is a
|
|
426
|
+
// direct proxy for how far apart the two are. A gateway raising codes this SDK has never heard of
|
|
427
|
+
// means its surface has moved.
|
|
428
|
+
//
|
|
429
|
+
// A warning, never a failure. Version skew is normal for hours at a time during a release, and an
|
|
430
|
+
// SDK that refused to work would be worse than one that mentions it.
|
|
431
|
+
const live = await client.admin.errors().catch(() => null);
|
|
432
|
+
if (live?.errors?.length) {
|
|
433
|
+
const known = new Set(VENDORED_ERROR_CODES);
|
|
434
|
+
const unknown = live.errors.map((e) => e.code).filter((c) => !known.has(c));
|
|
435
|
+
checks.push(unknown.length === 0
|
|
436
|
+
? {
|
|
437
|
+
name: 'client matches gateway',
|
|
438
|
+
status: 'ok',
|
|
439
|
+
detail: `${live.errors.length} error codes, all known to this SDK`,
|
|
440
|
+
}
|
|
441
|
+
: {
|
|
442
|
+
name: 'client matches gateway',
|
|
443
|
+
status: 'warn',
|
|
444
|
+
detail: `The gateway raises ${unknown.length} code(s) this SDK does not know: `
|
|
445
|
+
+ `${unknown.slice(0, 5).join(', ')}${unknown.length > 5 ? '…' : ''}`,
|
|
446
|
+
fix: 'The gateway is ahead of this client. Upgrade @certen.io/sdk.',
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
return { ok: checks.every((c) => c.status !== 'fail'), unreachable, checks };
|
|
450
|
+
}
|
|
451
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EA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,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every error code this SDK's release knew about.
|
|
3
|
+
*
|
|
4
|
+
* Vendored deliberately. `spec/errors.json` sits at the monorepo root and is not shipped inside this
|
|
5
|
+
* package, and `doctor` needs a baseline at RUNTIME to notice that the gateway has moved ahead of
|
|
6
|
+
* it. Version skew between a client and a gateway is routine — they deploy separately — and its
|
|
7
|
+
* symptoms are the most misleading on the surface: a call to a path the deployment does not serve
|
|
8
|
+
* 404s, which reads as "wrong URL" until somebody thinks to compare versions.
|
|
9
|
+
*
|
|
10
|
+
* Generated from the vendored catalogue. `packages/sdk/test/error-catalog.test.ts` asserts this list
|
|
11
|
+
* matches it exactly, so the two cannot drift without a test failing.
|
|
12
|
+
*/
|
|
13
|
+
export declare const VENDORED_ERROR_CODES: readonly string[];
|
|
14
|
+
//# sourceMappingURL=error-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAyCjD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every error code this SDK's release knew about.
|
|
3
|
+
*
|
|
4
|
+
* Vendored deliberately. `spec/errors.json` sits at the monorepo root and is not shipped inside this
|
|
5
|
+
* package, and `doctor` needs a baseline at RUNTIME to notice that the gateway has moved ahead of
|
|
6
|
+
* it. Version skew between a client and a gateway is routine — they deploy separately — and its
|
|
7
|
+
* symptoms are the most misleading on the surface: a call to a path the deployment does not serve
|
|
8
|
+
* 404s, which reads as "wrong URL" until somebody thinks to compare versions.
|
|
9
|
+
*
|
|
10
|
+
* Generated from the vendored catalogue. `packages/sdk/test/error-catalog.test.ts` asserts this list
|
|
11
|
+
* matches it exactly, so the two cannot drift without a test failing.
|
|
12
|
+
*/
|
|
13
|
+
export const VENDORED_ERROR_CODES = [
|
|
14
|
+
'BAD_GATEWAY',
|
|
15
|
+
'BAD_REQUEST',
|
|
16
|
+
'BILLING_DISABLED',
|
|
17
|
+
'CHAIN_NOT_PRICEABLE',
|
|
18
|
+
'CHAIN_SUSPENDED',
|
|
19
|
+
'CHAIN_UNRESOLVED',
|
|
20
|
+
'COMMITMENT_EXCEEDED',
|
|
21
|
+
'CONFLICT',
|
|
22
|
+
'ENTITLEMENT_UNAVAILABLE',
|
|
23
|
+
'FORBIDDEN',
|
|
24
|
+
'FX_UNAVAILABLE',
|
|
25
|
+
'IDEMPOTENCY_KEY_IN_FLIGHT',
|
|
26
|
+
'IDEMPOTENCY_KEY_MISMATCH',
|
|
27
|
+
'INSUFFICIENT_BALANCE',
|
|
28
|
+
'INTERNAL_ERROR',
|
|
29
|
+
'LEDGER_ACCOUNT_NOT_LOCKED',
|
|
30
|
+
'LEDGER_MISSING_ORG',
|
|
31
|
+
'LEDGER_NEGATIVE_HOLD',
|
|
32
|
+
'LEDGER_UNBALANCED',
|
|
33
|
+
'LEDGER_UNEXPECTED_ORG',
|
|
34
|
+
'LEDGER_ZERO_LEG',
|
|
35
|
+
'LOG_DIVERGENCE',
|
|
36
|
+
'NOT_FOUND',
|
|
37
|
+
'NO_PRICE_BOOK',
|
|
38
|
+
'PAYMENT_REQUIRED',
|
|
39
|
+
'PLAN_QUOTA_EXCEEDED',
|
|
40
|
+
'QUOTE_EXPIRED',
|
|
41
|
+
'QUOTE_MISMATCH',
|
|
42
|
+
'RATE_LIMIT_EXCEEDED',
|
|
43
|
+
'RECEIPT_COMPUTATION_MISMATCH',
|
|
44
|
+
'RECEIPT_KEY_NOT_REGISTERED',
|
|
45
|
+
'RECEIPT_KEY_UNAVAILABLE',
|
|
46
|
+
'SCHEMA_CONSTRAINT',
|
|
47
|
+
'SERVICE_TOKEN_UNCONFIGURED',
|
|
48
|
+
'SHARE_NO_LONGER_VALID',
|
|
49
|
+
'SLOW_DOWN',
|
|
50
|
+
'TIMESTAMP_SERVICE_UNAVAILABLE',
|
|
51
|
+
'TOO_MANY_REQUESTS',
|
|
52
|
+
'UNAUTHORIZED',
|
|
53
|
+
'VALIDATION_ERROR',
|
|
54
|
+
];
|
|
55
|
+
//# sourceMappingURL=error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,aAAa;IACb,aAAa;IACb,kBAAkB;IAClB,qBAAqB;IACrB,iBAAiB;IACjB,kBAAkB;IAClB,qBAAqB;IACrB,UAAU;IACV,yBAAyB;IACzB,WAAW;IACX,gBAAgB;IAChB,2BAA2B;IAC3B,0BAA0B;IAC1B,sBAAsB;IACtB,gBAAgB;IAChB,2BAA2B;IAC3B,oBAAoB;IACpB,sBAAsB;IACtB,mBAAmB;IACnB,uBAAuB;IACvB,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;IACX,eAAe;IACf,kBAAkB;IAClB,qBAAqB;IACrB,eAAe;IACf,gBAAgB;IAChB,qBAAqB;IACrB,8BAA8B;IAC9B,4BAA4B;IAC5B,yBAAyB;IACzB,mBAAmB;IACnB,4BAA4B;IAC5B,uBAAuB;IACvB,WAAW;IACX,+BAA+B;IAC/B,mBAAmB;IACnB,cAAc;IACd,kBAAkB;CACnB,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -22,7 +22,19 @@ export declare class CertenError extends Error {
|
|
|
22
22
|
details?: unknown;
|
|
23
23
|
body?: unknown;
|
|
24
24
|
});
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* True when repeating this identical request can eventually succeed on its own.
|
|
27
|
+
*
|
|
28
|
+
* Status alone gets two cases wrong, and both are decided by the CODE:
|
|
29
|
+
*
|
|
30
|
+
* - `IDEMPOTENCY_KEY_IN_FLIGHT` is a 409, which status-wise reads as "do not retry" — but the
|
|
31
|
+
* whole point of that code is that an identical request is already running, and retrying the
|
|
32
|
+
* SAME key is precisely the correct response. Treating it as terminal fails a request that
|
|
33
|
+
* would have succeeded a moment later.
|
|
34
|
+
* - `PLAN_QUOTA_EXCEEDED` is a 429, which reads as "back off and retry" — but it is a quota for
|
|
35
|
+
* the billing period, not a per-second rate. No amount of backing off clears it, so retrying
|
|
36
|
+
* only burns the attempts a genuinely transient failure would need.
|
|
37
|
+
*/
|
|
26
38
|
get isRetryable(): boolean;
|
|
27
39
|
/** True for client-side input mistakes. Never auto-retry these. */
|
|
28
40
|
get isClientError(): boolean;
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;;OAOG;IACH,SAAgB,IAAI,CAAC,EAAE,OAAO,CAAC;gBAG7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO;IAWtE
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,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UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,0BAA2B,SAAQ,WAAW;IACzD,OAAO,KAAK,OAAO,GAIlB;IAED,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,GAAG;IAKX,8EAA8E;IAC9E,IAAI,oBAAoB,IAAI,OAAO,CAElC;IAED,8DAA8D;IAC9D,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAGrC;IAED,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,oFAAoF;IACpF,IAAI,cAAc,IAAI,MAAM,GAAG,SAAS,CAGvC;IAED,wEAAwE;IACxE,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,2EAA2E;IAC3E,IAAI,cAAc,IAAI,MAAM,GAAG,SAAS,CAGvC;IAED,wEAAwE;IACxE,IAAI,UAAU,IAAI,iBAAiB,GAAG,IAAI,CAKzC;IAED,yDAAyD;IACzD,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,2DAA2D;IAC3D,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAEnC;IAED;;;;;;OAMG;IACH,IAAI,OAAO,IAAI,MAAM,CAUpB;CACF"}
|
package/dist/errors.js
CHANGED
|
@@ -26,10 +26,27 @@ export class CertenError extends Error {
|
|
|
26
26
|
this.details = opts.details;
|
|
27
27
|
this.body = opts.body;
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* True when repeating this identical request can eventually succeed on its own.
|
|
31
|
+
*
|
|
32
|
+
* Status alone gets two cases wrong, and both are decided by the CODE:
|
|
33
|
+
*
|
|
34
|
+
* - `IDEMPOTENCY_KEY_IN_FLIGHT` is a 409, which status-wise reads as "do not retry" — but the
|
|
35
|
+
* whole point of that code is that an identical request is already running, and retrying the
|
|
36
|
+
* SAME key is precisely the correct response. Treating it as terminal fails a request that
|
|
37
|
+
* would have succeeded a moment later.
|
|
38
|
+
* - `PLAN_QUOTA_EXCEEDED` is a 429, which reads as "back off and retry" — but it is a quota for
|
|
39
|
+
* the billing period, not a per-second rate. No amount of backing off clears it, so retrying
|
|
40
|
+
* only burns the attempts a genuinely transient failure would need.
|
|
41
|
+
*/
|
|
30
42
|
get isRetryable() {
|
|
31
43
|
if (this.code === 'NETWORK_ERROR')
|
|
32
44
|
return true;
|
|
45
|
+
// Code beats status, in both directions.
|
|
46
|
+
if (this.code === 'IDEMPOTENCY_KEY_IN_FLIGHT')
|
|
47
|
+
return true;
|
|
48
|
+
if (this.code === 'PLAN_QUOTA_EXCEEDED')
|
|
49
|
+
return false;
|
|
33
50
|
if (this.status >= 500 && this.status < 600)
|
|
34
51
|
return true;
|
|
35
52
|
if (this.status === 429)
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpB,MAAM,CAAS;IACf,IAAI,CAAS;IACb,SAAS,CAAU;IACnB,OAAO,CAAW;IAClC;;;;;;;OAOG;IACa,IAAI,CAAW;IAE/B,YACE,OAAe,EACf,MAAc,EACd,IAAY,EACZ,OAAkE,EAAE;QAEpE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI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