@oneaddress/partner-sdk 2.4.1 → 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/dist/edge.mjs CHANGED
@@ -20,13 +20,13 @@ import {
20
20
  verifyLOA,
21
21
  verifySignature,
22
22
  verifyWithGrace
23
- } from "./chunk-4WYW6BM3.mjs";
23
+ } from "./chunk-XPQERNNN.mjs";
24
24
  import {
25
25
  DEFAULT_REPLAY_WINDOW_SECS,
26
26
  computeBlindIndex,
27
27
  isFreshTimestamp,
28
28
  normalizeForBlindIndex
29
- } from "./chunk-FDMB4BNC.mjs";
29
+ } from "./chunk-QAOGKPD3.mjs";
30
30
  export {
31
31
  CURRENT_VERSION,
32
32
  DEFAULT_REPLAY_WINDOW_SECS,
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
  *
@@ -1330,15 +1521,16 @@ interface SessionData {
1330
1521
  *
1331
1522
  * **Important — `key_id` routing.** Under D5 you may hold multiple
1332
1523
  * private keys at once: one active (for new dispatches) plus zero-or-more
1333
- * retired keys still within their 90-day retention window. Look up the
1524
+ * retired keys still within the retention window you configured in the
1525
+ * partner portal (minimum 14 days). Look up the
1334
1526
  * private key by `share.key_id` from your local key store before calling
1335
1527
  * this function. The function does NOT pick a key for you.
1336
1528
  *
1337
1529
  * **Destroyed retired keys.** If you destroyed the private key for
1338
1530
  * `share.key_id` before its `destroy_after`, you cannot decrypt this
1339
- * envelope. That is a key-custody breach of the partner agreement and is
1340
- * recorded on the OneAddress side as a `partner_key_custody_failure`
1341
- * outcome on the reconstruction audit log.
1531
+ * envelope and neither can we: we hold no copy of your private key.
1532
+ * Destroying a retired key before your configured retention window closes
1533
+ * is a key-custody breach under the partner terms.
1342
1534
  *
1343
1535
  * @param share - The structured `session_key_share` block from the webhook.
1344
1536
  * @param envelopeB64 - The `session_envelope` base64url string from the webhook.
@@ -1600,7 +1792,7 @@ declare function fetchLoaPublicKey(appBaseUrl?: string): Promise<string>;
1600
1792
  * async onUpdate(event) {
1601
1793
  * if (event.loa) {
1602
1794
  * const valid = await verifyLOA(event.loa, loaPublicKey);
1603
- * if (!valid) throw new Error('LOA signature invalid — possible tampering');
1795
+ * if (!valid) throw new Error('LOA signature invalid, possible tampering');
1604
1796
  * }
1605
1797
  * await db.updateAddress(event.address);
1606
1798
  * },
@@ -2068,4 +2260,4 @@ interface SignedTestWebhook {
2068
2260
  */
2069
2261
  declare function buildSignedTestWebhook(opts: SignedTestWebhookOptions): Promise<SignedTestWebhook>;
2070
2262
 
2071
- 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
  *
@@ -1330,15 +1521,16 @@ interface SessionData {
1330
1521
  *
1331
1522
  * **Important — `key_id` routing.** Under D5 you may hold multiple
1332
1523
  * private keys at once: one active (for new dispatches) plus zero-or-more
1333
- * retired keys still within their 90-day retention window. Look up the
1524
+ * retired keys still within the retention window you configured in the
1525
+ * partner portal (minimum 14 days). Look up the
1334
1526
  * private key by `share.key_id` from your local key store before calling
1335
1527
  * this function. The function does NOT pick a key for you.
1336
1528
  *
1337
1529
  * **Destroyed retired keys.** If you destroyed the private key for
1338
1530
  * `share.key_id` before its `destroy_after`, you cannot decrypt this
1339
- * envelope. That is a key-custody breach of the partner agreement and is
1340
- * recorded on the OneAddress side as a `partner_key_custody_failure`
1341
- * outcome on the reconstruction audit log.
1531
+ * envelope and neither can we: we hold no copy of your private key.
1532
+ * Destroying a retired key before your configured retention window closes
1533
+ * is a key-custody breach under the partner terms.
1342
1534
  *
1343
1535
  * @param share - The structured `session_key_share` block from the webhook.
1344
1536
  * @param envelopeB64 - The `session_envelope` base64url string from the webhook.
@@ -1600,7 +1792,7 @@ declare function fetchLoaPublicKey(appBaseUrl?: string): Promise<string>;
1600
1792
  * async onUpdate(event) {
1601
1793
  * if (event.loa) {
1602
1794
  * const valid = await verifyLOA(event.loa, loaPublicKey);
1603
- * if (!valid) throw new Error('LOA signature invalid — possible tampering');
1795
+ * if (!valid) throw new Error('LOA signature invalid, possible tampering');
1604
1796
  * }
1605
1797
  * await db.updateAddress(event.address);
1606
1798
  * },
@@ -2068,4 +2260,4 @@ interface SignedTestWebhook {
2068
2260
  */
2069
2261
  declare function buildSignedTestWebhook(opts: SignedTestWebhookOptions): Promise<SignedTestWebhook>;
2070
2262
 
2071
- 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 };