@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/client.js
CHANGED
|
@@ -10,6 +10,16 @@ import { PortfolioResource } from './resources/portfolio.js';
|
|
|
10
10
|
import { BillingResource } from './resources/billing.js';
|
|
11
11
|
import { AdminResource } from './resources/admin.js';
|
|
12
12
|
import { ExecuteResource } from './resources/execute.js';
|
|
13
|
+
import { ChainsResource } from './resources/chains.js';
|
|
14
|
+
import { TransparencyResource } from './resources/transparency.js';
|
|
15
|
+
import { HealthResource } from './resources/health.js';
|
|
16
|
+
import { WebhooksResource } from './resources/webhooks.js';
|
|
17
|
+
import { ProofResource } from './resources/proof.js';
|
|
18
|
+
import { DeviceResource } from './resources/device.js';
|
|
19
|
+
import { OAuthClientsResource } from './resources/oauth-clients.js';
|
|
20
|
+
import { RegistrationTokensResource } from './resources/registration-tokens.js';
|
|
21
|
+
import { fetchOAuthToken } from './oauth.js';
|
|
22
|
+
import { runDoctor } from './doctor.js';
|
|
13
23
|
/**
|
|
14
24
|
* The gateway this SDK talks to when the caller does not say.
|
|
15
25
|
*
|
|
@@ -78,14 +88,137 @@ export class CertenClient {
|
|
|
78
88
|
billing;
|
|
79
89
|
/** The proof-gated execution flow as one call: open, sign, submit, poll, prove. See resources/execute.ts. */
|
|
80
90
|
execute;
|
|
91
|
+
/** The public contract registry — which chains CERTEN is on, and where. Needs no API key. */
|
|
92
|
+
chains;
|
|
93
|
+
/**
|
|
94
|
+
* The public transparency log — signed tree heads, consistency proofs, published price books.
|
|
95
|
+
* What makes a receipt checkable rather than merely signed. Needs no API key.
|
|
96
|
+
*/
|
|
97
|
+
transparency;
|
|
98
|
+
/**
|
|
99
|
+
* Whether CERTEN can serve right now, and what is wrong when it cannot. Needs no API key —
|
|
100
|
+
* a caller whose credential is rejected can still learn whether the platform is the problem.
|
|
101
|
+
*/
|
|
102
|
+
health;
|
|
103
|
+
/**
|
|
104
|
+
* Webhook endpoints and their delivery history. The gateway has pushed events all along; nothing
|
|
105
|
+
* on this side could register an endpoint or see why a delivery failed.
|
|
106
|
+
*/
|
|
107
|
+
webhooks;
|
|
108
|
+
/** Reading and sharing proofs. See resources/proof.ts. */
|
|
109
|
+
proof;
|
|
110
|
+
/** Device authorization, so a terminal can obtain its own key. Needs no API key. */
|
|
111
|
+
device;
|
|
112
|
+
/**
|
|
113
|
+
* The OAuth2 clients your organization owns. Tokens could be obtained and revoked from code all
|
|
114
|
+
* along; the client that issues them could only be created by hand in the portal.
|
|
115
|
+
*/
|
|
116
|
+
oauthClients;
|
|
117
|
+
/**
|
|
118
|
+
* Registration tokens — letting a new organization be created without a browser. Minting needs
|
|
119
|
+
* `org:invite`; redeeming needs nothing, and is the standalone `redeemRegistrationToken`.
|
|
120
|
+
*/
|
|
121
|
+
registrationTokens;
|
|
122
|
+
/**
|
|
123
|
+
* Diagnose this setup and say what is blocking it.
|
|
124
|
+
*
|
|
125
|
+
* Never throws for a failed check — a diagnosis that cannot report a broken setup is useless.
|
|
126
|
+
* `report.ok` is false when something failed; warnings do not clear it and do not set it.
|
|
127
|
+
* See doctor.ts for what each check exists to catch.
|
|
128
|
+
*/
|
|
129
|
+
/**
|
|
130
|
+
* Who this credential is, and what it may do.
|
|
131
|
+
*
|
|
132
|
+
* One call, and the only way to learn your own organization and scopes. It accepted a portal
|
|
133
|
+
* session only until the gateway's 2026-08 change, so a machine holding an API key could not ask
|
|
134
|
+
* — clients resorted to probing endpoints and reading the 403s to guess what they were allowed
|
|
135
|
+
* to do.
|
|
136
|
+
*
|
|
137
|
+
* Check `scopes` before a flow rather than after: a missing scope surfaces otherwise as a 403
|
|
138
|
+
* partway through, when some of the work may already have happened.
|
|
139
|
+
*/
|
|
140
|
+
me() {
|
|
141
|
+
return this.http.get('/v1/me').then((r) => r.data);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* How this client authenticates. Set once at construction.
|
|
145
|
+
*
|
|
146
|
+
* Not readonly-by-type only for the minted token, which is replaced as it is refreshed.
|
|
147
|
+
*/
|
|
148
|
+
auth;
|
|
149
|
+
/** The current minted token and when it stops being usable. */
|
|
150
|
+
minted;
|
|
151
|
+
/** In-flight mint, so N concurrent requests cause ONE token request rather than N. */
|
|
152
|
+
minting;
|
|
153
|
+
/**
|
|
154
|
+
* A usable bearer token, minting or re-minting as needed.
|
|
155
|
+
*
|
|
156
|
+
* Re-mints 60 seconds BEFORE expiry rather than on the 401 that expiry would otherwise cause.
|
|
157
|
+
* Waiting for the rejection means at least one request fails for a reason the caller can do
|
|
158
|
+
* nothing about, and on a long-running agent that is a failure every hour, forever.
|
|
159
|
+
*
|
|
160
|
+
* The single-flight guard matters more than it looks: a process that fires ten concurrent calls
|
|
161
|
+
* on a cold client would otherwise mint ten tokens, and every one but the last is immediately
|
|
162
|
+
* abandoned — an invisible leak of live credentials.
|
|
163
|
+
*/
|
|
164
|
+
async bearerToken() {
|
|
165
|
+
// Narrowed on a LOCAL. `this.auth` is a property, so TypeScript discards a narrowing of it
|
|
166
|
+
// across the awaits below and the union widens back to include the api-key branch.
|
|
167
|
+
const auth = this.auth;
|
|
168
|
+
if (auth.kind === 'apiKey')
|
|
169
|
+
throw new CertenError('certen: not a bearer credential', 0, 'NO_CREDENTIAL');
|
|
170
|
+
if (auth.kind === 'token')
|
|
171
|
+
return auth.accessToken;
|
|
172
|
+
const REFRESH_MARGIN_MS = 60_000;
|
|
173
|
+
if (this.minted && this.minted.expiresAt - REFRESH_MARGIN_MS > Date.now()) {
|
|
174
|
+
return this.minted.accessToken;
|
|
175
|
+
}
|
|
176
|
+
if (this.minting)
|
|
177
|
+
return this.minting;
|
|
178
|
+
this.minting = fetchOAuthToken({ clientId: auth.clientId, clientSecret: auth.clientSecret, scope: auth.scope }, { baseUrl: this.http.defaults.baseURL ?? undefined }).then((tokens) => {
|
|
179
|
+
// A gateway that omits `expires_in` is treated as one hour — the documented lifetime — rather
|
|
180
|
+
// than as "never expires", which would strand this client on a dead token indefinitely.
|
|
181
|
+
const ttlMs = (tokens.expires_in ?? 3600) * 1000;
|
|
182
|
+
this.minted = { accessToken: tokens.access_token, expiresAt: Date.now() + ttlMs };
|
|
183
|
+
return tokens.access_token;
|
|
184
|
+
}).finally(() => {
|
|
185
|
+
this.minting = undefined;
|
|
186
|
+
});
|
|
187
|
+
return this.minting;
|
|
188
|
+
}
|
|
189
|
+
doctor() {
|
|
190
|
+
return runDoctor(this);
|
|
191
|
+
}
|
|
81
192
|
constructor(options) {
|
|
82
193
|
this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
83
194
|
this.baseBackoffMs = options.baseBackoffMs ?? DEFAULT_BASE_BACKOFF_MS;
|
|
84
195
|
this.maxBackoffMs = options.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
|
|
196
|
+
// Exactly one credential, checked here rather than at the first 401. A client constructed with
|
|
197
|
+
// none of them used to send `X-API-Key: undefined` and fail on whatever call happened to run
|
|
198
|
+
// first, which points the blame at that call instead of at the construction.
|
|
199
|
+
const credentials = [options.apiKey, options.accessToken, options.clientId].filter(Boolean);
|
|
200
|
+
if (credentials.length === 0) {
|
|
201
|
+
throw new CertenError('certen: no credential. Pass `apiKey`, or `clientId` and `clientSecret` for an unattended '
|
|
202
|
+
+ 'process, or an `accessToken` you already hold.', 0, 'NO_CREDENTIAL');
|
|
203
|
+
}
|
|
204
|
+
if (options.clientId && !options.clientSecret) {
|
|
205
|
+
throw new CertenError('certen: `clientId` was given without `clientSecret`. Both are needed to mint a token.', 0, 'INCOMPLETE_CLIENT_CREDENTIALS');
|
|
206
|
+
}
|
|
207
|
+
this.auth = options.apiKey
|
|
208
|
+
? { kind: 'apiKey', apiKey: options.apiKey }
|
|
209
|
+
: options.accessToken
|
|
210
|
+
? { kind: 'token', accessToken: options.accessToken }
|
|
211
|
+
: {
|
|
212
|
+
kind: 'clientCredentials',
|
|
213
|
+
clientId: options.clientId,
|
|
214
|
+
clientSecret: options.clientSecret,
|
|
215
|
+
scope: options.scope,
|
|
216
|
+
};
|
|
85
217
|
this.http = axios.create({
|
|
86
218
|
baseURL: options.baseUrl ?? envBaseUrl() ?? DEFAULT_BASE_URL,
|
|
87
219
|
headers: {
|
|
88
|
-
|
|
220
|
+
// The credential header is set per-request by the interceptor below, because a minted token
|
|
221
|
+
// changes over the client's life and a header baked in here never would.
|
|
89
222
|
'Content-Type': 'application/json',
|
|
90
223
|
'User-Agent': `certen-sdk-node/${process.env.npm_package_version ?? 'dev'}`,
|
|
91
224
|
},
|
|
@@ -109,6 +242,16 @@ export class CertenClient {
|
|
|
109
242
|
// Auto-stamp Idempotency-Key on every POST that didn't already supply one.
|
|
110
243
|
this.http.interceptors.request.use(async (req) => {
|
|
111
244
|
const reqPath = req.url ?? '';
|
|
245
|
+
// Attach the credential here, not at construction: a minted token is refreshed over this
|
|
246
|
+
// client's life, and a header fixed in the axios defaults could never change.
|
|
247
|
+
const headers = (req.headers ?? {});
|
|
248
|
+
if (this.auth.kind === 'apiKey') {
|
|
249
|
+
headers['X-API-Key'] = this.auth.apiKey;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
headers.Authorization = `Bearer ${await this.bearerToken()}`;
|
|
253
|
+
}
|
|
254
|
+
req.headers = req.headers ?? headers;
|
|
112
255
|
if (autoIdem && (req.method ?? 'GET').toUpperCase() === 'POST' && !shouldSkip(reqPath)) {
|
|
113
256
|
const headers = req.headers ?? {};
|
|
114
257
|
if (!('Idempotency-Key' in headers) && !('idempotency-key' in headers)) {
|
|
@@ -116,9 +259,15 @@ export class CertenClient {
|
|
|
116
259
|
req.headers = headers;
|
|
117
260
|
}
|
|
118
261
|
}
|
|
119
|
-
// Respect
|
|
262
|
+
// Respect a rate-limit window the gateway already told us about — but BOUNDED.
|
|
263
|
+
//
|
|
264
|
+
// This slept for the entire remaining window with no ceiling, so a 429 carrying
|
|
265
|
+
// `Retry-After: 3600` parked the next request for an hour inside the HTTP client, ignoring
|
|
266
|
+
// both `maxBackoffMs` and the per-request timeout, with no way for the caller to escape it.
|
|
267
|
+
// Capping at `maxBackoffMs` keeps the wait to something the caller agreed to; if the window
|
|
268
|
+
// has genuinely not reopened the next attempt returns 429 and the retry path handles it.
|
|
120
269
|
if (this.rateLimit.resetAt && Date.now() < this.rateLimit.resetAt) {
|
|
121
|
-
const wait = this.rateLimit.resetAt - Date.now();
|
|
270
|
+
const wait = Math.min(this.rateLimit.resetAt - Date.now(), this.maxBackoffMs);
|
|
122
271
|
await sleep(wait);
|
|
123
272
|
this.rateLimit.resetAt = null;
|
|
124
273
|
}
|
|
@@ -126,10 +275,21 @@ export class CertenClient {
|
|
|
126
275
|
});
|
|
127
276
|
// Wrap errors into the typed taxonomy + retry transient failures.
|
|
128
277
|
this.http.interceptors.response.use((response) => {
|
|
129
|
-
//
|
|
278
|
+
// Self-throttle ONLY once the window is actually exhausted.
|
|
279
|
+
//
|
|
280
|
+
// Two things were wrong here. `x-ratelimit-reset` is SECONDS REMAINING, not a Unix
|
|
281
|
+
// timestamp — the gateway sends `56` with a 60-second window — so `Number(reset) * 1000`
|
|
282
|
+
// produced 56000, an instant in 1970, and the guard above never fired. The throttle has
|
|
283
|
+
// never run.
|
|
284
|
+
//
|
|
285
|
+
// Simply correcting the arithmetic would have been far worse than the bug: `reset` comes
|
|
286
|
+
// back on EVERY response, so setting the window from it unconditionally would sleep the
|
|
287
|
+
// full remaining window before every single request. It is only meaningful when
|
|
288
|
+
// `x-ratelimit-remaining` has reached zero.
|
|
130
289
|
const reset = response.headers['x-ratelimit-reset'];
|
|
131
|
-
|
|
132
|
-
|
|
290
|
+
const remaining = response.headers['x-ratelimit-remaining'];
|
|
291
|
+
if (remaining === '0' && typeof reset === 'string' && /^\d+$/.test(reset)) {
|
|
292
|
+
this.rateLimit.resetAt = Date.now() + Number(reset) * 1000;
|
|
133
293
|
}
|
|
134
294
|
return response;
|
|
135
295
|
}, async (error) => {
|
|
@@ -139,13 +299,49 @@ export class CertenClient {
|
|
|
139
299
|
// `data?.code` is undefined — fall back to the status map rather than to UNKNOWN_ERROR.
|
|
140
300
|
const body = error.response?.data;
|
|
141
301
|
const sentCode = typeof body === 'object' && body !== null ? body.code : undefined;
|
|
302
|
+
// "This gateway has no such endpoint" and "that thing does not exist" are both 404s, and
|
|
303
|
+
// collapsing them produced the least useful message on the surface: `certen pricing`, a
|
|
304
|
+
// command the CLI advertises in its own --help, answered `Error [NOT_FOUND]: Not Found`.
|
|
305
|
+
// Nothing in that says whether the key lacks access, the resource is missing, or — the
|
|
306
|
+
// actual cause — the deployed gateway is older than this client.
|
|
307
|
+
//
|
|
308
|
+
// The two are cleanly distinguishable. Fastify's unmatched-route 404 carries `statusCode`
|
|
309
|
+
// and a `Route GET:/v1/x not found` message and NO `code`; every handler-raised 404 carries
|
|
310
|
+
// a `code`. So an absent `code` plus that message shape means the route is not registered.
|
|
311
|
+
//
|
|
312
|
+
// This matters on every release: clients and gateway deploy separately, and the window
|
|
313
|
+
// where one is ahead of the other is exactly when someone hits it.
|
|
314
|
+
const skew = status === 404 && sentCode === undefined
|
|
315
|
+
&& typeof body?.message === 'string'
|
|
316
|
+
&& /^Route\s+\w+:/.test(body.message);
|
|
142
317
|
const code = sentCode
|
|
143
|
-
?? (
|
|
318
|
+
?? (skew ? 'ENDPOINT_NOT_ON_GATEWAY'
|
|
319
|
+
: status === 0 ? 'NETWORK_ERROR' : CODE_BY_STATUS[status] ?? 'UNKNOWN_ERROR');
|
|
144
320
|
const sentMessage = typeof body === 'object' && body !== null ? body.error : undefined;
|
|
145
|
-
const
|
|
321
|
+
const method = (error.config?.method ?? 'GET').toUpperCase();
|
|
322
|
+
const path = error.config?.url ?? 'that endpoint';
|
|
323
|
+
const message = skew
|
|
324
|
+
? `certen: this gateway does not serve ${method} ${path}. `
|
|
325
|
+
+ 'The deployed gateway is older than this client — upgrade the gateway, or pin an '
|
|
326
|
+
+ 'older client version.'
|
|
327
|
+
: sentMessage ?? error.message;
|
|
146
328
|
const requestId = error.response?.headers?.['x-request-id'] ?? undefined;
|
|
147
329
|
const retryAfter = error.response?.headers?.['retry-after'];
|
|
148
|
-
|
|
330
|
+
// `details` carries whatever is STRUCTURED about this failure, from either side.
|
|
331
|
+
//
|
|
332
|
+
// It used to hold only `retryAfter`, so the gateway's own `details` — the per-field
|
|
333
|
+
// validation entries naming exactly what was wrong — reached callers only via `body`,
|
|
334
|
+
// which is not where anyone looks. A tool rendering `error.details` therefore showed
|
|
335
|
+
// nothing for the one error class where structure is most useful.
|
|
336
|
+
//
|
|
337
|
+
// `retryAfter` keeps its place: `CertenError.retryAfterSeconds` reads it from here.
|
|
338
|
+
const serverDetails = body?.details;
|
|
339
|
+
const details = retryAfter || serverDetails !== undefined
|
|
340
|
+
? {
|
|
341
|
+
...(retryAfter ? { retryAfter: Number(retryAfter) } : {}),
|
|
342
|
+
...(serverDetails !== undefined ? { validation: serverDetails } : {}),
|
|
343
|
+
}
|
|
344
|
+
: undefined;
|
|
149
345
|
if (status === 429 && typeof retryAfter === 'string') {
|
|
150
346
|
this.rateLimit.resetAt = Date.now() + Number(retryAfter) * 1000;
|
|
151
347
|
}
|
|
@@ -161,9 +357,20 @@ export class CertenClient {
|
|
|
161
357
|
if (cfg && wrapped.isRetryable) {
|
|
162
358
|
cfg.__retryCount = (cfg.__retryCount ?? 0) + 1;
|
|
163
359
|
if (cfg.__retryCount <= this.maxRetries) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
360
|
+
// The server's own `Retry-After` wins over the local curve.
|
|
361
|
+
//
|
|
362
|
+
// Exponential backoff is a guess made without information; `Retry-After` is the
|
|
363
|
+
// gateway stating when the window actually reopens. Ignoring it — as this did — meant
|
|
364
|
+
// retrying early, which cannot succeed, and each failed attempt still counts against
|
|
365
|
+
// the limit. Capped at `maxBackoffMs` so a large server value cannot park a caller
|
|
366
|
+
// for longer than they agreed to wait, and jittered like the fallback so a fleet
|
|
367
|
+
// released at the same instant does not stampede.
|
|
368
|
+
const serverHint = retryAfter ? Number(retryAfter) * 1000 : NaN;
|
|
369
|
+
const base = Number.isFinite(serverHint) && serverHint > 0
|
|
370
|
+
? Math.min(this.maxBackoffMs, serverHint)
|
|
371
|
+
: Math.min(this.maxBackoffMs, this.baseBackoffMs * Math.pow(2, cfg.__retryCount - 1));
|
|
372
|
+
const jitter = Math.floor(Math.random() * Math.min(base, 1_000));
|
|
373
|
+
await sleep(base + jitter);
|
|
167
374
|
return this.http.request(cfg);
|
|
168
375
|
}
|
|
169
376
|
}
|
|
@@ -176,8 +383,16 @@ export class CertenClient {
|
|
|
176
383
|
this.sign = new SignResource(this.http);
|
|
177
384
|
this.portfolio = new PortfolioResource(this.http);
|
|
178
385
|
this.admin = new AdminResource(this.http);
|
|
179
|
-
this.billing = new BillingResource(this.http);
|
|
386
|
+
this.billing = new BillingResource(this.http, this);
|
|
180
387
|
this.execute = new ExecuteResource(this.http, generateIdempotencyKey);
|
|
388
|
+
this.chains = new ChainsResource(this.http);
|
|
389
|
+
this.transparency = new TransparencyResource(this.http);
|
|
390
|
+
this.health = new HealthResource(this.http);
|
|
391
|
+
this.webhooks = new WebhooksResource(this.http);
|
|
392
|
+
this.proof = new ProofResource(this.http);
|
|
393
|
+
this.device = new DeviceResource(this.http);
|
|
394
|
+
this.oauthClients = new OAuthClientsResource(this.http);
|
|
395
|
+
this.registrationTokens = new RegistrationTokensResource(this.http);
|
|
181
396
|
}
|
|
182
397
|
}
|
|
183
398
|
function sleep(ms) {
|
|
@@ -188,20 +403,43 @@ function generateIdempotencyKey() {
|
|
|
188
403
|
return `sdk_${Date.now().toString(36)}_${randomBytes(8).toString('hex')}`;
|
|
189
404
|
}
|
|
190
405
|
/**
|
|
191
|
-
* Async iterator helper for paginated list endpoints.
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
406
|
+
* Async iterator helper for paginated list endpoints.
|
|
407
|
+
*
|
|
408
|
+
* **Prefer the `listAll()` method on the resource** — `certen.transaction.listAll()`,
|
|
409
|
+
* `certen.pending.listAll()`. They call this internally and need no adapter.
|
|
410
|
+
*
|
|
411
|
+
* This takes a callback returning `{ items }`, and no SDK method returns that shape: `list()`
|
|
412
|
+
* returns `{ transactions }`, `shares()` returns `{ shares }`. So using it directly meant writing
|
|
413
|
+
* the adapter that should have shipped with it. Since 0.7.0 that adapter lives on the resources,
|
|
414
|
+
* and this stays exported for list endpoints the SDK does not model yet, and for callers paginating
|
|
415
|
+
* their own API.
|
|
195
416
|
*
|
|
196
|
-
*
|
|
417
|
+
* `paginateWithTotal` exposes `{ item, index, total }` for progress UIs that need to render
|
|
418
|
+
* "27 of 412". When the server does not return `total`, the yielded object's `total` is undefined.
|
|
197
419
|
*/
|
|
198
420
|
export async function* paginate(fetchPage, pageSize = 100) {
|
|
199
421
|
let offset = 0;
|
|
200
422
|
for (;;) {
|
|
201
|
-
const { items } = await fetchPage(pageSize, offset);
|
|
423
|
+
const { items, hasMore } = await fetchPage(pageSize, offset);
|
|
202
424
|
for (const it of items)
|
|
203
425
|
yield it;
|
|
204
|
-
|
|
426
|
+
// `hasMore` when the endpoint reports it; a short page otherwise.
|
|
427
|
+
//
|
|
428
|
+
// The fallback is not equivalent, and the difference is the reason the gateway now sends the
|
|
429
|
+
// field. A final page that lands EXACTLY on the page size is indistinguishable from a full one,
|
|
430
|
+
// so short-page inference either stops a page early — reporting a partial ledger as complete,
|
|
431
|
+
// which for a reconciliation is worse than an error — or spends an extra request discovering an
|
|
432
|
+
// empty page. It stays only because the SDK is regularly pointed at an older gateway.
|
|
433
|
+
if (hasMore !== undefined) {
|
|
434
|
+
if (!hasMore)
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
else if (items.length < pageSize) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
// Guard against a server that reports more while returning nothing: without this the loop
|
|
441
|
+
// never advances and never ends.
|
|
442
|
+
if (items.length === 0)
|
|
205
443
|
return;
|
|
206
444
|
offset += items.length;
|
|
207
445
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,+BAA+B,CAAC;AAEhE;kEACkE;AAClE,SAAS,UAAU;IACjB,IAAI,CAAC;QACH,OAAO,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AACD,MAAM,mBAAmB,GAAG,CAAC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C,CAAC;QAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;QACrD,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,GAAG,QAAQ;YAAE,OAAO;QACpC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IACzB,CAAC;AACH,CAAC"}
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { CertenClient } from './client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Diagnose a setup and say what is blocking it.
|
|
4
|
+
*
|
|
5
|
+
* The CLI grew this first, and it turned out not to be a CLI concern: every integration hits the
|
|
6
|
+
* same handful of conditions, and each one is invisible until it produces a failure somewhere far
|
|
7
|
+
* away from its cause. A key with no `billing:read` scope, an organization with no active identity,
|
|
8
|
+
* an abstract account with no gas, a balance entirely committed to pending intents — none of these
|
|
9
|
+
* announce themselves, and three of them surface as a transaction that is accepted and then never
|
|
10
|
+
* completes.
|
|
11
|
+
*
|
|
12
|
+
* Checks are ordered by dependency and stop being evaluated once a prerequisite fails: nothing
|
|
13
|
+
* below an unusable credential is meaningful, so nothing below it is run. A skipped check is
|
|
14
|
+
* reported as skipped rather than omitted — a list whose length depends on how far the run got is
|
|
15
|
+
* one a caller cannot index into.
|
|
16
|
+
*
|
|
17
|
+
* This deliberately does NOT check anything machine-local (a signing key on disk, where the API key
|
|
18
|
+
* is stored). Those are real checks and the CLI makes them, but an SDK embedded in a server has no
|
|
19
|
+
* such state and inventing an opinion about it would be wrong.
|
|
20
|
+
*/
|
|
21
|
+
export type CheckStatus = 'ok' | 'warn' | 'fail' | 'skipped';
|
|
22
|
+
export interface DoctorCheck {
|
|
23
|
+
name: string;
|
|
24
|
+
status: CheckStatus;
|
|
25
|
+
detail: string;
|
|
26
|
+
/** What resolves it. Absent when the check passed. */
|
|
27
|
+
fix?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface DoctorReport {
|
|
30
|
+
/** True when nothing FAILED. Warnings do not clear this flag but do not set it either. */
|
|
31
|
+
ok: boolean;
|
|
32
|
+
/** True when the gateway could not be reached at all — nothing below it was evaluated. */
|
|
33
|
+
unreachable: boolean;
|
|
34
|
+
checks: DoctorCheck[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Checks that cannot run without a working credential, in the order they are reported.
|
|
38
|
+
*
|
|
39
|
+
* Exported because the CLI needs the same list: it knows things the SDK cannot (whether a key is
|
|
40
|
+
* configured on this machine at all) and has to mark the same checks skipped. It kept its own copy
|
|
41
|
+
* once, the two drifted, and a machine with no API key showed a verdict for the check that had been
|
|
42
|
+
* added to only one of them. One list, imported, makes that impossible rather than merely
|
|
43
|
+
* discouraged.
|
|
44
|
+
*/
|
|
45
|
+
export declare const CREDENTIALLED_CHECKS: readonly ["identity can sign", "abstract accounts funded", "billing balance", "credit / trial", "intents executing"];
|
|
46
|
+
/**
|
|
47
|
+
* Run the diagnostic.
|
|
48
|
+
*
|
|
49
|
+
* Never throws for a failed check — a diagnosis that cannot report a broken setup is useless. It
|
|
50
|
+
* throws only if something outside the checks goes wrong.
|
|
51
|
+
*/
|
|
52
|
+
export declare function runDoctor(client: CertenClient): Promise<DoctorReport>;
|
|
53
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,0FAA0F;IAC1F,EAAE,EAAE,OAAO,CAAC;IACZ,0FAA0F;IAC1F,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,sHAMvB,CAAC;AA+GX;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAmU3E"}
|