@oneaddress/partner-sdk 2.5.0 → 2.6.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 +28 -0
- package/README.md +39 -0
- package/dist/{chunk-ZY2K54LD.mjs → chunk-QAOGKPD3.mjs} +77 -19
- package/dist/{chunk-DIUGEFIK.mjs → chunk-XPQERNNN.mjs} +261 -30
- package/dist/edge.js +148 -70
- package/dist/edge.mjs +2 -2
- package/dist/index.d.mts +192 -1
- package/dist/index.d.ts +192 -1
- package/dist/index.js +378 -79
- package/dist/index.mjs +6 -2
- package/dist/{src-RBLFVBGY.mjs → src-BPES2DKY.mjs} +13 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -321,6 +321,197 @@ interface OutboxConsumer {
|
|
|
321
321
|
}
|
|
322
322
|
declare function createOutboxConsumer(opts: OutboxConsumerOptions): OutboxConsumer;
|
|
323
323
|
|
|
324
|
+
/**
|
|
325
|
+
* The recipient-side registry head self-check.
|
|
326
|
+
*
|
|
327
|
+
* A recipient asks OneAddress, periodically and on its own schedule: which key
|
|
328
|
+
* do you currently tell the world is mine? Then it checks the answer against a
|
|
329
|
+
* root it pinned itself, and against the key ids it actually holds.
|
|
330
|
+
*
|
|
331
|
+
* ── WHY THE CONSUMER-SIDE CHECK CANNOT DO THIS ──────────────────────────────
|
|
332
|
+
*
|
|
333
|
+
* The consumer browser has verified the root-signed head since 16 September
|
|
334
|
+
* 2026, and refuses rather than warns. It closes key resurrection (R1) against
|
|
335
|
+
* an attacker with database write access, which is what it was written for.
|
|
336
|
+
*
|
|
337
|
+
* It cannot close the case where the OneAddress DEPLOYMENT itself is the
|
|
338
|
+
* attacker. The browser fetches the head from us, fetches the root set it
|
|
339
|
+
* checks the head against from us as well (`/.well-known/
|
|
340
|
+
* oneaddress-key-registry.json`, which reads `PARTNER_KEY_REGISTRY_ROOT_KEYS`
|
|
341
|
+
* out of the deployment environment), and runs the comparison in JavaScript we
|
|
342
|
+
* served it seconds earlier. One party supplies the statement, the authority and
|
|
343
|
+
* the checker. Each is genuine and the composition proves nothing against that
|
|
344
|
+
* party. Pinning the root inside our own bundle moves the trust from one
|
|
345
|
+
* deployment-controlled place to another and buys exactly nothing.
|
|
346
|
+
*
|
|
347
|
+
* The recipient is the first participant in this system that is NOT us. It runs
|
|
348
|
+
* on its own infrastructure, and it knows which key ids it holds without having
|
|
349
|
+
* to ask anybody. So the root set pinned HERE is the first authority in the
|
|
350
|
+
* chain that the party being checked does not control.
|
|
351
|
+
*
|
|
352
|
+
* ── WHAT IT DETECTS, AND WHAT IT CANNOT ─────────────────────────────────────
|
|
353
|
+
*
|
|
354
|
+
* It detects a head that names, as current for this recipient, a key the
|
|
355
|
+
* recipient has never held. That is the observable shadow of a substituted key:
|
|
356
|
+
* the envelope is sealed to someone else, and the honest recipient never sees
|
|
357
|
+
* the dispatch at all. It is detection after the fact, not prevention, and it
|
|
358
|
+
* reports to the recipient's own operators rather than to us, which is the
|
|
359
|
+
* property that makes it worth having.
|
|
360
|
+
*
|
|
361
|
+
* It cannot prevent the substitution, it cannot tell a malicious deployment from
|
|
362
|
+
* a badly broken one, and it says nothing about envelopes already sent.
|
|
363
|
+
*
|
|
364
|
+
* ── THREE DESIGN POINTS THAT ARE EASY TO UNDO ───────────────────────────────
|
|
365
|
+
*
|
|
366
|
+
* 1. **Unpinned roots are a verdict, never a pass.** With no pinned root set
|
|
367
|
+
* this returns `roots-not-pinned` and `checked: false`. It specifically does
|
|
368
|
+
* NOT fall back to fetching the root set from the same origin as the head,
|
|
369
|
+
* which would restore the circularity above and report success while proving
|
|
370
|
+
* nothing. A future "convenience" that auto-fetches the roots deletes the
|
|
371
|
+
* entire value of this module while leaving every test green.
|
|
372
|
+
*
|
|
373
|
+
* 2. **A named key the recipient HOLDS is a cutover, not an alarm.** Rotation
|
|
374
|
+
* legitimately moves the head onto a key the recipient staged, and a check
|
|
375
|
+
* that cried wolf on every rotation would be turned off within a month. The
|
|
376
|
+
* named id is resolved through the recipient's own key source, so "a key I
|
|
377
|
+
* hold" and "a key I have never seen" are different answers.
|
|
378
|
+
*
|
|
379
|
+
* 3. **It is periodic, not per-dispatch.** The attack diverts the envelope away
|
|
380
|
+
* from the honest recipient, so there may be no dispatch to hang a check on.
|
|
381
|
+
* A per-request check is silent in precisely the case it exists for.
|
|
382
|
+
*
|
|
383
|
+
* `staged` is deliberately NOT consulted. During a rotation `heads` still names
|
|
384
|
+
* the outgoing key, which the recipient holds, so the staged map changes none of
|
|
385
|
+
* the answers here; and a `heads` entry naming a key the recipient lacks is the
|
|
386
|
+
* alarm whether or not something is staged beside it.
|
|
387
|
+
*/
|
|
388
|
+
/**
|
|
389
|
+
* One pinned registry root, in the same shape the published root document uses.
|
|
390
|
+
*
|
|
391
|
+
* Deliberately identical so a recipient can take the published document once,
|
|
392
|
+
* check it out of band (ask us, compare with a second channel, read it from a
|
|
393
|
+
* printed fingerprint), and paste it into their own configuration. The pin is a
|
|
394
|
+
* one-time out-of-band act, which is the whole mechanism.
|
|
395
|
+
*/
|
|
396
|
+
interface PinnedRegistryRoot {
|
|
397
|
+
root_key_id: string;
|
|
398
|
+
algorithm: string;
|
|
399
|
+
public_key_b64: string;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Every answer this check can give. One per distinguishable operator problem,
|
|
403
|
+
* because collapsing two of them sends somebody looking in the wrong place.
|
|
404
|
+
*/
|
|
405
|
+
type RegistryHeadCheckVerdict =
|
|
406
|
+
/** The head names exactly the key id this recipient expects. */
|
|
407
|
+
'ok'
|
|
408
|
+
/** The head names a different key that this recipient does hold: a cutover. */
|
|
409
|
+
| 'names-key-we-hold'
|
|
410
|
+
/** The head names a key this recipient has never held. THE alarm. */
|
|
411
|
+
| 'names-key-we-lack'
|
|
412
|
+
/** The head verified and does not mention this recipient at all. */
|
|
413
|
+
| 'partner-absent'
|
|
414
|
+
/** Verified, but nothing was configured to compare the named key against. */
|
|
415
|
+
| 'key-identity-unknown'
|
|
416
|
+
/** No root set pinned, so nothing can be checked. Not a pass. */
|
|
417
|
+
| 'roots-not-pinned'
|
|
418
|
+
/** A root set was configured and could not be read. Different remedy. */
|
|
419
|
+
| 'roots-malformed'
|
|
420
|
+
/** OneAddress is serving no head (HTTP 503 from the well-known route). */
|
|
421
|
+
| 'head-absent'
|
|
422
|
+
/** Network, DNS, timeout, or an unexpected HTTP status. */
|
|
423
|
+
| 'head-unreachable'
|
|
424
|
+
/** Served something that is not a head document this build understands. */
|
|
425
|
+
| 'head-malformed'
|
|
426
|
+
/** Signed by a root that is not in the pinned set. */
|
|
427
|
+
| 'head-unknown-root'
|
|
428
|
+
/** Root signature did not verify. */
|
|
429
|
+
| 'head-bad-signature'
|
|
430
|
+
/** Authentic head, past its expiry. */
|
|
431
|
+
| 'head-expired';
|
|
432
|
+
interface RegistryHeadCheckResult {
|
|
433
|
+
verdict: RegistryHeadCheckVerdict;
|
|
434
|
+
/**
|
|
435
|
+
* Did this run actually establish which key is current for this recipient?
|
|
436
|
+
*
|
|
437
|
+
* The separate boolean exists because "no root pinned" and "head names my
|
|
438
|
+
* key" must never be reportable as the same thing. A dashboard that only
|
|
439
|
+
* reads `alarm` would show a green light for a check that never ran.
|
|
440
|
+
*/
|
|
441
|
+
checked: boolean;
|
|
442
|
+
/** Should a human look at this now. */
|
|
443
|
+
alarm: boolean;
|
|
444
|
+
/** One line, safe to log. Never carries key material. */
|
|
445
|
+
detail: string;
|
|
446
|
+
/** The key id the head names for this recipient, when one was read. */
|
|
447
|
+
namedKeyId?: string;
|
|
448
|
+
/** The key id this recipient was configured to expect. */
|
|
449
|
+
expectedKeyId?: string;
|
|
450
|
+
headIssuedAt?: string;
|
|
451
|
+
headExpiresAt?: string;
|
|
452
|
+
}
|
|
453
|
+
interface RegistryHeadCheckOptions {
|
|
454
|
+
/** This recipient's OneAddress partner id. */
|
|
455
|
+
partnerId: string;
|
|
456
|
+
/**
|
|
457
|
+
* The key id this recipient primarily expects to be named.
|
|
458
|
+
*
|
|
459
|
+
* Optional, because a recipient holding several keys through a resolver may
|
|
460
|
+
* have no single primary. Without it, and without `holdsKey`, the check can
|
|
461
|
+
* verify the head but cannot say whether the named key is ours, and reports
|
|
462
|
+
* `key-identity-unknown` rather than claiming a pass.
|
|
463
|
+
*/
|
|
464
|
+
keyId?: string;
|
|
465
|
+
/**
|
|
466
|
+
* Root set, pinned by the recipient. Required, and an empty array is treated
|
|
467
|
+
* as not configured rather than as nothing to check.
|
|
468
|
+
*/
|
|
469
|
+
pinnedRoots: ReadonlyArray<PinnedRegistryRoot>;
|
|
470
|
+
/**
|
|
471
|
+
* Does this recipient hold the named key id?
|
|
472
|
+
*
|
|
473
|
+
* Takes a predicate rather than the key material so no private key reaches
|
|
474
|
+
* this module. A receiver wires it to its own key resolver.
|
|
475
|
+
*/
|
|
476
|
+
holdsKey?: (keyId: string) => Promise<boolean>;
|
|
477
|
+
/** Override the consumer-app base URL. Defaults to https://oneaddress.io */
|
|
478
|
+
appBaseUrl?: string;
|
|
479
|
+
/** Injectable for tests. */
|
|
480
|
+
fetchImpl?: typeof fetch;
|
|
481
|
+
/** Per-call timeout. Default 10s. */
|
|
482
|
+
timeoutMs?: number;
|
|
483
|
+
/** Injectable for tests. Defaults to the recipient's clock. */
|
|
484
|
+
now?: Date;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Read a pinned root set out of configuration.
|
|
488
|
+
*
|
|
489
|
+
* Accepts the published root document verbatim (`{"version":…,"keys":[…]}`) or
|
|
490
|
+
* a bare array of roots, because a recipient pasting what they fetched should
|
|
491
|
+
* not have to unwrap it first.
|
|
492
|
+
*
|
|
493
|
+
* Absent and malformed are different results on purpose. A recipient who pasted
|
|
494
|
+
* broken JSON and one who pasted nothing have the same verdict available to
|
|
495
|
+
* them (`checked: false`) and completely different things to do about it.
|
|
496
|
+
*/
|
|
497
|
+
declare function parsePinnedRegistryRoots(raw: string | undefined | null): {
|
|
498
|
+
ok: true;
|
|
499
|
+
roots: PinnedRegistryRoot[];
|
|
500
|
+
} | {
|
|
501
|
+
ok: false;
|
|
502
|
+
configured: boolean;
|
|
503
|
+
reason: string;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Run the check once.
|
|
507
|
+
*
|
|
508
|
+
* Never throws for anything it is checking: every outcome is a verdict, because
|
|
509
|
+
* an exception in a background self-check is the easiest thing in the world to
|
|
510
|
+
* swallow. It DOES throw for a base URL pointing somewhere other than
|
|
511
|
+
* OneAddress, which is a programming error in the caller and not an outcome.
|
|
512
|
+
*/
|
|
513
|
+
declare function checkRegistryHead(opts: RegistryHeadCheckOptions): Promise<RegistryHeadCheckResult>;
|
|
514
|
+
|
|
324
515
|
/**
|
|
325
516
|
* @oneaddress/partner-sdk
|
|
326
517
|
*
|
|
@@ -2069,4 +2260,4 @@ interface SignedTestWebhook {
|
|
|
2069
2260
|
*/
|
|
2070
2261
|
declare function buildSignedTestWebhook(opts: SignedTestWebhookOptions): Promise<SignedTestWebhook>;
|
|
2071
2262
|
|
|
2072
|
-
export { type AddressParts, type BlindIndexField, CURRENT_VERSION, type ComparableAddress, type ConfirmUpdateOptions, type ConfirmUpdateResult, DEFAULT_REPLAY_WINDOW_SECS, type EncryptedPayload, type ExpressLikeRequest, type ExpressLikeResponse, type HandlerConfirmOptions, type HandlerRequest, type HandlerResponse, type IdempotencyClaim, type IdempotencyDialect, type IdempotencyStore, OUTBOX_LEASE_COLUMNS, type OneAddressAccountVerifyEvent, type OneAddressAddress, type OneAddressConfirmStatus, type OneAddressCustomer, type OneAddressCustomerMatch, type OneAddressD5LOA, type OneAddressHandlerOptions, type OneAddressIdVerification, type OneAddressLOA, type OneAddressTestEvent, type OneAddressUpdateEvent, type OneAddressVerifyEvent, type OutboxBacklog, type OutboxConsumer, type OutboxConsumerOptions, type OutboxDialect, type OutboxQueryFn, type OutboxRow, type PrivateKeyOperations, SUPPORTED_VERSIONS, type SessionData, type SessionKeyShare, type SessionUpdateType, type SignedTestWebhook, type SignedTestWebhookOptions, type VerifyResultCallbackParams, _resetOnceWarningsForTests, buildSignedTestWebhook, canonicalD5LoaForm, compareAddresses, computeBlindIndex, confirmUpdate, createOneAddressHandler, createOutboxConsumer, createSqlIdempotencyStore, d5LoaRef, decryptAddress as decrypt, decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, formatAddressParts, fromOutboxTimestamp, isEmailLike, isFreshTimestamp, namePoolMatches, normalizeForBlindIndex, readAddressParts, sendVerifyResult, toExpressHandler, toOutboxTimestamp, transformAddress as transform, transformAddress, transformSession, validateAddress, verifySignature as verify, verifyD5LOA, verifyWithGrace as verifyGrace, verifyLOA, verifySignature, verifyWithGrace };
|
|
2263
|
+
export { type AddressParts, type BlindIndexField, CURRENT_VERSION, type ComparableAddress, type ConfirmUpdateOptions, type ConfirmUpdateResult, DEFAULT_REPLAY_WINDOW_SECS, type EncryptedPayload, type ExpressLikeRequest, type ExpressLikeResponse, type HandlerConfirmOptions, type HandlerRequest, type HandlerResponse, type IdempotencyClaim, type IdempotencyDialect, type IdempotencyStore, OUTBOX_LEASE_COLUMNS, type OneAddressAccountVerifyEvent, type OneAddressAddress, type OneAddressConfirmStatus, type OneAddressCustomer, type OneAddressCustomerMatch, type OneAddressD5LOA, type OneAddressHandlerOptions, type OneAddressIdVerification, type OneAddressLOA, type OneAddressTestEvent, type OneAddressUpdateEvent, type OneAddressVerifyEvent, type OutboxBacklog, type OutboxConsumer, type OutboxConsumerOptions, type OutboxDialect, type OutboxQueryFn, type OutboxRow, type PinnedRegistryRoot, type PrivateKeyOperations, type RegistryHeadCheckOptions, type RegistryHeadCheckResult, type RegistryHeadCheckVerdict, SUPPORTED_VERSIONS, type SessionData, type SessionKeyShare, type SessionUpdateType, type SignedTestWebhook, type SignedTestWebhookOptions, type VerifyResultCallbackParams, _resetOnceWarningsForTests, buildSignedTestWebhook, canonicalD5LoaForm, checkRegistryHead, compareAddresses, computeBlindIndex, confirmUpdate, createOneAddressHandler, createOutboxConsumer, createSqlIdempotencyStore, d5LoaRef, decryptAddress as decrypt, decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, formatAddressParts, fromOutboxTimestamp, isEmailLike, isFreshTimestamp, namePoolMatches, normalizeForBlindIndex, parsePinnedRegistryRoots, readAddressParts, sendVerifyResult, toExpressHandler, toOutboxTimestamp, transformAddress as transform, transformAddress, transformSession, validateAddress, verifySignature as verify, verifyD5LOA, verifyWithGrace as verifyGrace, verifyLOA, verifySignature, verifyWithGrace };
|
package/dist/index.d.ts
CHANGED
|
@@ -321,6 +321,197 @@ interface OutboxConsumer {
|
|
|
321
321
|
}
|
|
322
322
|
declare function createOutboxConsumer(opts: OutboxConsumerOptions): OutboxConsumer;
|
|
323
323
|
|
|
324
|
+
/**
|
|
325
|
+
* The recipient-side registry head self-check.
|
|
326
|
+
*
|
|
327
|
+
* A recipient asks OneAddress, periodically and on its own schedule: which key
|
|
328
|
+
* do you currently tell the world is mine? Then it checks the answer against a
|
|
329
|
+
* root it pinned itself, and against the key ids it actually holds.
|
|
330
|
+
*
|
|
331
|
+
* ── WHY THE CONSUMER-SIDE CHECK CANNOT DO THIS ──────────────────────────────
|
|
332
|
+
*
|
|
333
|
+
* The consumer browser has verified the root-signed head since 16 September
|
|
334
|
+
* 2026, and refuses rather than warns. It closes key resurrection (R1) against
|
|
335
|
+
* an attacker with database write access, which is what it was written for.
|
|
336
|
+
*
|
|
337
|
+
* It cannot close the case where the OneAddress DEPLOYMENT itself is the
|
|
338
|
+
* attacker. The browser fetches the head from us, fetches the root set it
|
|
339
|
+
* checks the head against from us as well (`/.well-known/
|
|
340
|
+
* oneaddress-key-registry.json`, which reads `PARTNER_KEY_REGISTRY_ROOT_KEYS`
|
|
341
|
+
* out of the deployment environment), and runs the comparison in JavaScript we
|
|
342
|
+
* served it seconds earlier. One party supplies the statement, the authority and
|
|
343
|
+
* the checker. Each is genuine and the composition proves nothing against that
|
|
344
|
+
* party. Pinning the root inside our own bundle moves the trust from one
|
|
345
|
+
* deployment-controlled place to another and buys exactly nothing.
|
|
346
|
+
*
|
|
347
|
+
* The recipient is the first participant in this system that is NOT us. It runs
|
|
348
|
+
* on its own infrastructure, and it knows which key ids it holds without having
|
|
349
|
+
* to ask anybody. So the root set pinned HERE is the first authority in the
|
|
350
|
+
* chain that the party being checked does not control.
|
|
351
|
+
*
|
|
352
|
+
* ── WHAT IT DETECTS, AND WHAT IT CANNOT ─────────────────────────────────────
|
|
353
|
+
*
|
|
354
|
+
* It detects a head that names, as current for this recipient, a key the
|
|
355
|
+
* recipient has never held. That is the observable shadow of a substituted key:
|
|
356
|
+
* the envelope is sealed to someone else, and the honest recipient never sees
|
|
357
|
+
* the dispatch at all. It is detection after the fact, not prevention, and it
|
|
358
|
+
* reports to the recipient's own operators rather than to us, which is the
|
|
359
|
+
* property that makes it worth having.
|
|
360
|
+
*
|
|
361
|
+
* It cannot prevent the substitution, it cannot tell a malicious deployment from
|
|
362
|
+
* a badly broken one, and it says nothing about envelopes already sent.
|
|
363
|
+
*
|
|
364
|
+
* ── THREE DESIGN POINTS THAT ARE EASY TO UNDO ───────────────────────────────
|
|
365
|
+
*
|
|
366
|
+
* 1. **Unpinned roots are a verdict, never a pass.** With no pinned root set
|
|
367
|
+
* this returns `roots-not-pinned` and `checked: false`. It specifically does
|
|
368
|
+
* NOT fall back to fetching the root set from the same origin as the head,
|
|
369
|
+
* which would restore the circularity above and report success while proving
|
|
370
|
+
* nothing. A future "convenience" that auto-fetches the roots deletes the
|
|
371
|
+
* entire value of this module while leaving every test green.
|
|
372
|
+
*
|
|
373
|
+
* 2. **A named key the recipient HOLDS is a cutover, not an alarm.** Rotation
|
|
374
|
+
* legitimately moves the head onto a key the recipient staged, and a check
|
|
375
|
+
* that cried wolf on every rotation would be turned off within a month. The
|
|
376
|
+
* named id is resolved through the recipient's own key source, so "a key I
|
|
377
|
+
* hold" and "a key I have never seen" are different answers.
|
|
378
|
+
*
|
|
379
|
+
* 3. **It is periodic, not per-dispatch.** The attack diverts the envelope away
|
|
380
|
+
* from the honest recipient, so there may be no dispatch to hang a check on.
|
|
381
|
+
* A per-request check is silent in precisely the case it exists for.
|
|
382
|
+
*
|
|
383
|
+
* `staged` is deliberately NOT consulted. During a rotation `heads` still names
|
|
384
|
+
* the outgoing key, which the recipient holds, so the staged map changes none of
|
|
385
|
+
* the answers here; and a `heads` entry naming a key the recipient lacks is the
|
|
386
|
+
* alarm whether or not something is staged beside it.
|
|
387
|
+
*/
|
|
388
|
+
/**
|
|
389
|
+
* One pinned registry root, in the same shape the published root document uses.
|
|
390
|
+
*
|
|
391
|
+
* Deliberately identical so a recipient can take the published document once,
|
|
392
|
+
* check it out of band (ask us, compare with a second channel, read it from a
|
|
393
|
+
* printed fingerprint), and paste it into their own configuration. The pin is a
|
|
394
|
+
* one-time out-of-band act, which is the whole mechanism.
|
|
395
|
+
*/
|
|
396
|
+
interface PinnedRegistryRoot {
|
|
397
|
+
root_key_id: string;
|
|
398
|
+
algorithm: string;
|
|
399
|
+
public_key_b64: string;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Every answer this check can give. One per distinguishable operator problem,
|
|
403
|
+
* because collapsing two of them sends somebody looking in the wrong place.
|
|
404
|
+
*/
|
|
405
|
+
type RegistryHeadCheckVerdict =
|
|
406
|
+
/** The head names exactly the key id this recipient expects. */
|
|
407
|
+
'ok'
|
|
408
|
+
/** The head names a different key that this recipient does hold: a cutover. */
|
|
409
|
+
| 'names-key-we-hold'
|
|
410
|
+
/** The head names a key this recipient has never held. THE alarm. */
|
|
411
|
+
| 'names-key-we-lack'
|
|
412
|
+
/** The head verified and does not mention this recipient at all. */
|
|
413
|
+
| 'partner-absent'
|
|
414
|
+
/** Verified, but nothing was configured to compare the named key against. */
|
|
415
|
+
| 'key-identity-unknown'
|
|
416
|
+
/** No root set pinned, so nothing can be checked. Not a pass. */
|
|
417
|
+
| 'roots-not-pinned'
|
|
418
|
+
/** A root set was configured and could not be read. Different remedy. */
|
|
419
|
+
| 'roots-malformed'
|
|
420
|
+
/** OneAddress is serving no head (HTTP 503 from the well-known route). */
|
|
421
|
+
| 'head-absent'
|
|
422
|
+
/** Network, DNS, timeout, or an unexpected HTTP status. */
|
|
423
|
+
| 'head-unreachable'
|
|
424
|
+
/** Served something that is not a head document this build understands. */
|
|
425
|
+
| 'head-malformed'
|
|
426
|
+
/** Signed by a root that is not in the pinned set. */
|
|
427
|
+
| 'head-unknown-root'
|
|
428
|
+
/** Root signature did not verify. */
|
|
429
|
+
| 'head-bad-signature'
|
|
430
|
+
/** Authentic head, past its expiry. */
|
|
431
|
+
| 'head-expired';
|
|
432
|
+
interface RegistryHeadCheckResult {
|
|
433
|
+
verdict: RegistryHeadCheckVerdict;
|
|
434
|
+
/**
|
|
435
|
+
* Did this run actually establish which key is current for this recipient?
|
|
436
|
+
*
|
|
437
|
+
* The separate boolean exists because "no root pinned" and "head names my
|
|
438
|
+
* key" must never be reportable as the same thing. A dashboard that only
|
|
439
|
+
* reads `alarm` would show a green light for a check that never ran.
|
|
440
|
+
*/
|
|
441
|
+
checked: boolean;
|
|
442
|
+
/** Should a human look at this now. */
|
|
443
|
+
alarm: boolean;
|
|
444
|
+
/** One line, safe to log. Never carries key material. */
|
|
445
|
+
detail: string;
|
|
446
|
+
/** The key id the head names for this recipient, when one was read. */
|
|
447
|
+
namedKeyId?: string;
|
|
448
|
+
/** The key id this recipient was configured to expect. */
|
|
449
|
+
expectedKeyId?: string;
|
|
450
|
+
headIssuedAt?: string;
|
|
451
|
+
headExpiresAt?: string;
|
|
452
|
+
}
|
|
453
|
+
interface RegistryHeadCheckOptions {
|
|
454
|
+
/** This recipient's OneAddress partner id. */
|
|
455
|
+
partnerId: string;
|
|
456
|
+
/**
|
|
457
|
+
* The key id this recipient primarily expects to be named.
|
|
458
|
+
*
|
|
459
|
+
* Optional, because a recipient holding several keys through a resolver may
|
|
460
|
+
* have no single primary. Without it, and without `holdsKey`, the check can
|
|
461
|
+
* verify the head but cannot say whether the named key is ours, and reports
|
|
462
|
+
* `key-identity-unknown` rather than claiming a pass.
|
|
463
|
+
*/
|
|
464
|
+
keyId?: string;
|
|
465
|
+
/**
|
|
466
|
+
* Root set, pinned by the recipient. Required, and an empty array is treated
|
|
467
|
+
* as not configured rather than as nothing to check.
|
|
468
|
+
*/
|
|
469
|
+
pinnedRoots: ReadonlyArray<PinnedRegistryRoot>;
|
|
470
|
+
/**
|
|
471
|
+
* Does this recipient hold the named key id?
|
|
472
|
+
*
|
|
473
|
+
* Takes a predicate rather than the key material so no private key reaches
|
|
474
|
+
* this module. A receiver wires it to its own key resolver.
|
|
475
|
+
*/
|
|
476
|
+
holdsKey?: (keyId: string) => Promise<boolean>;
|
|
477
|
+
/** Override the consumer-app base URL. Defaults to https://oneaddress.io */
|
|
478
|
+
appBaseUrl?: string;
|
|
479
|
+
/** Injectable for tests. */
|
|
480
|
+
fetchImpl?: typeof fetch;
|
|
481
|
+
/** Per-call timeout. Default 10s. */
|
|
482
|
+
timeoutMs?: number;
|
|
483
|
+
/** Injectable for tests. Defaults to the recipient's clock. */
|
|
484
|
+
now?: Date;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Read a pinned root set out of configuration.
|
|
488
|
+
*
|
|
489
|
+
* Accepts the published root document verbatim (`{"version":…,"keys":[…]}`) or
|
|
490
|
+
* a bare array of roots, because a recipient pasting what they fetched should
|
|
491
|
+
* not have to unwrap it first.
|
|
492
|
+
*
|
|
493
|
+
* Absent and malformed are different results on purpose. A recipient who pasted
|
|
494
|
+
* broken JSON and one who pasted nothing have the same verdict available to
|
|
495
|
+
* them (`checked: false`) and completely different things to do about it.
|
|
496
|
+
*/
|
|
497
|
+
declare function parsePinnedRegistryRoots(raw: string | undefined | null): {
|
|
498
|
+
ok: true;
|
|
499
|
+
roots: PinnedRegistryRoot[];
|
|
500
|
+
} | {
|
|
501
|
+
ok: false;
|
|
502
|
+
configured: boolean;
|
|
503
|
+
reason: string;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Run the check once.
|
|
507
|
+
*
|
|
508
|
+
* Never throws for anything it is checking: every outcome is a verdict, because
|
|
509
|
+
* an exception in a background self-check is the easiest thing in the world to
|
|
510
|
+
* swallow. It DOES throw for a base URL pointing somewhere other than
|
|
511
|
+
* OneAddress, which is a programming error in the caller and not an outcome.
|
|
512
|
+
*/
|
|
513
|
+
declare function checkRegistryHead(opts: RegistryHeadCheckOptions): Promise<RegistryHeadCheckResult>;
|
|
514
|
+
|
|
324
515
|
/**
|
|
325
516
|
* @oneaddress/partner-sdk
|
|
326
517
|
*
|
|
@@ -2069,4 +2260,4 @@ interface SignedTestWebhook {
|
|
|
2069
2260
|
*/
|
|
2070
2261
|
declare function buildSignedTestWebhook(opts: SignedTestWebhookOptions): Promise<SignedTestWebhook>;
|
|
2071
2262
|
|
|
2072
|
-
export { type AddressParts, type BlindIndexField, CURRENT_VERSION, type ComparableAddress, type ConfirmUpdateOptions, type ConfirmUpdateResult, DEFAULT_REPLAY_WINDOW_SECS, type EncryptedPayload, type ExpressLikeRequest, type ExpressLikeResponse, type HandlerConfirmOptions, type HandlerRequest, type HandlerResponse, type IdempotencyClaim, type IdempotencyDialect, type IdempotencyStore, OUTBOX_LEASE_COLUMNS, type OneAddressAccountVerifyEvent, type OneAddressAddress, type OneAddressConfirmStatus, type OneAddressCustomer, type OneAddressCustomerMatch, type OneAddressD5LOA, type OneAddressHandlerOptions, type OneAddressIdVerification, type OneAddressLOA, type OneAddressTestEvent, type OneAddressUpdateEvent, type OneAddressVerifyEvent, type OutboxBacklog, type OutboxConsumer, type OutboxConsumerOptions, type OutboxDialect, type OutboxQueryFn, type OutboxRow, type PrivateKeyOperations, SUPPORTED_VERSIONS, type SessionData, type SessionKeyShare, type SessionUpdateType, type SignedTestWebhook, type SignedTestWebhookOptions, type VerifyResultCallbackParams, _resetOnceWarningsForTests, buildSignedTestWebhook, canonicalD5LoaForm, compareAddresses, computeBlindIndex, confirmUpdate, createOneAddressHandler, createOutboxConsumer, createSqlIdempotencyStore, d5LoaRef, decryptAddress as decrypt, decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, formatAddressParts, fromOutboxTimestamp, isEmailLike, isFreshTimestamp, namePoolMatches, normalizeForBlindIndex, readAddressParts, sendVerifyResult, toExpressHandler, toOutboxTimestamp, transformAddress as transform, transformAddress, transformSession, validateAddress, verifySignature as verify, verifyD5LOA, verifyWithGrace as verifyGrace, verifyLOA, verifySignature, verifyWithGrace };
|
|
2263
|
+
export { type AddressParts, type BlindIndexField, CURRENT_VERSION, type ComparableAddress, type ConfirmUpdateOptions, type ConfirmUpdateResult, DEFAULT_REPLAY_WINDOW_SECS, type EncryptedPayload, type ExpressLikeRequest, type ExpressLikeResponse, type HandlerConfirmOptions, type HandlerRequest, type HandlerResponse, type IdempotencyClaim, type IdempotencyDialect, type IdempotencyStore, OUTBOX_LEASE_COLUMNS, type OneAddressAccountVerifyEvent, type OneAddressAddress, type OneAddressConfirmStatus, type OneAddressCustomer, type OneAddressCustomerMatch, type OneAddressD5LOA, type OneAddressHandlerOptions, type OneAddressIdVerification, type OneAddressLOA, type OneAddressTestEvent, type OneAddressUpdateEvent, type OneAddressVerifyEvent, type OutboxBacklog, type OutboxConsumer, type OutboxConsumerOptions, type OutboxDialect, type OutboxQueryFn, type OutboxRow, type PinnedRegistryRoot, type PrivateKeyOperations, type RegistryHeadCheckOptions, type RegistryHeadCheckResult, type RegistryHeadCheckVerdict, SUPPORTED_VERSIONS, type SessionData, type SessionKeyShare, type SessionUpdateType, type SignedTestWebhook, type SignedTestWebhookOptions, type VerifyResultCallbackParams, _resetOnceWarningsForTests, buildSignedTestWebhook, canonicalD5LoaForm, checkRegistryHead, compareAddresses, computeBlindIndex, confirmUpdate, createOneAddressHandler, createOutboxConsumer, createSqlIdempotencyStore, d5LoaRef, decryptAddress as decrypt, decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, formatAddressParts, fromOutboxTimestamp, isEmailLike, isFreshTimestamp, namePoolMatches, normalizeForBlindIndex, parsePinnedRegistryRoots, readAddressParts, sendVerifyResult, toExpressHandler, toOutboxTimestamp, transformAddress as transform, transformAddress, transformSession, validateAddress, verifySignature as verify, verifyD5LOA, verifyWithGrace as verifyGrace, verifyLOA, verifySignature, verifyWithGrace };
|