@oneaddress/partner-sdk 2.7.0 → 2.9.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/index.d.mts CHANGED
@@ -150,19 +150,6 @@ declare function normalizeForBlindIndex(field: BlindIndexField, value: string):
150
150
  */
151
151
  declare function computeBlindIndex(secret: string, field: BlindIndexField, value: string): Promise<string>;
152
152
 
153
- /** True when a value looks like an email address rather than a person's name. */
154
- declare function isEmailLike(value: string): boolean;
155
- declare function namePoolMatches(providedNames: string[], storedName: string): boolean;
156
- /**
157
- * Find the first stored candidate (a customer's full name plus any known
158
- * aliases) that the provided pool matches, or undefined if none does.
159
- *
160
- * Thin convenience wrapper - `namePoolMatches` takes the whole pool per call,
161
- * so matching against a customer with several stored aliases means trying
162
- * each one; this is that loop, shared so callers don't re-derive it.
163
- */
164
- declare function findMatchingStoredName(providedNames: string[], storedCandidates: readonly string[]): string | undefined;
165
-
166
153
  /**
167
154
  * @oneaddress/protocol
168
155
  *
@@ -178,6 +165,67 @@ declare const CURRENT_VERSION: "2026.1";
178
165
  /** All protocol versions this build of the SDK recognises. */
179
166
  declare const SUPPORTED_VERSIONS: readonly ["2026.1"];
180
167
 
168
+ /** The most typed aliases a v2 record carries. A longer list is malformed. */
169
+ declare const LOA_MAX_TYPED_ALIASES = 3;
170
+ /** The name normalisation every SDK applies before comparing. See the module notes. */
171
+ declare function normaliseLoaName(name: string): string;
172
+ /** The last token of the normalised name, or `''` for a name with none. */
173
+ declare function loaSurname(name: string): string;
174
+ /** The first token of the normalised name, or `''` for a name with none. */
175
+ declare function loaFirstName(name: string): string;
176
+ /** True when the two names are equal after {@link normaliseLoaName}, and not empty. */
177
+ declare function loaNamesMatch(a: string, b: string): boolean;
178
+ /** The shortest first name {@link isAcceptableAlias} treats as a short form. */
179
+ declare const LOA_MIN_SHORT_FORM_LETTERS = 3;
180
+ /**
181
+ * Whether `alias` may stand beside `verifiedName` as a typed alias, compared
182
+ * after {@link normaliseLoaName}:
183
+ *
184
+ * 1. the alias first name (first word) equals the verified first name, OR
185
+ * 2. one first name is a prefix of the other and the shorter has at least
186
+ * {@link LOA_MIN_SHORT_FORM_LETTERS} letters (Tim/Timothy yes, Al/Alexander no).
187
+ *
188
+ * A shared surname alone no longer admits an alias (24 Oct 2026): "Robert
189
+ * Hooper" beside "Timothy Hooper" names a relative as readily as the consumer,
190
+ * and a married or changed surname is the case aliases exist for, which keeps
191
+ * the first name. A single word is its own first name. An empty name on
192
+ * either side is never acceptable. "Letters" are Unicode code points of the
193
+ * normalised token, so every language counts the same way.
194
+ */
195
+ declare function isAcceptableAlias(verifiedName: string, alias: string): boolean;
196
+ /**
197
+ * The typed aliases a record may carry, in their original order and spelling:
198
+ * strings only, not the verified name itself, no duplicates (compared
199
+ * normalised), encodable by {@link canonicalLoaV2}, admitted by
200
+ * {@link isAcceptableAlias}, then the first {@link LOA_MAX_TYPED_ALIASES}.
201
+ *
202
+ * Filter first, then cap, so a refused alias never takes a slot. Every caller
203
+ * (the browser before sealing, the relay before signing, every SDK before
204
+ * handing names to a recipient) runs this one function, so the three agree on
205
+ * the same input. Dropped, never refused: a stale or wrong alias is the
206
+ * consumer's typing and not an attack on the update.
207
+ */
208
+ declare function acceptTypedAliases(verifiedName: string, aliases: readonly unknown[] | null | undefined): string[];
209
+ /**
210
+ * Codes an SDK refuses a v2 LOA with. Shared so a recipient's logs read the same
211
+ * whichever language received the dispatch.
212
+ */
213
+ declare const LOA_V2_REFUSALS: readonly ["loa_v2_malformed", "loa_v2_signature_invalid", "loa_v2_partner_mismatch", "loa_v2_update_mismatch", "loa_v2_envelope_mismatch", "loa_v2_name_mismatch"];
214
+ type LoaV2Refusal = typeof LOA_V2_REFUSALS[number];
215
+
216
+ /** True when a value looks like an email address rather than a person's name. */
217
+ declare function isEmailLike(value: string): boolean;
218
+ declare function namePoolMatches(providedNames: string[], storedName: string): boolean;
219
+ /**
220
+ * Find the first stored candidate (a customer's full name plus any known
221
+ * aliases) that the provided pool matches, or undefined if none does.
222
+ *
223
+ * Thin convenience wrapper - `namePoolMatches` takes the whole pool per call,
224
+ * so matching against a customer with several stored aliases means trying
225
+ * each one; this is that loop, shared so callers don't re-derive it.
226
+ */
227
+ declare function findMatchingStoredName(providedNames: string[], storedCandidates: readonly string[]): string | undefined;
228
+
181
229
  /**
182
230
  * Draining the outbox.
183
231
  *
@@ -459,7 +507,8 @@ interface RegistryHeadCheckOptions {
459
507
  * Optional, because a recipient holding several keys through a resolver may
460
508
  * have no single primary. Without it, and without `holdsKey`, the check can
461
509
  * verify the head but cannot say whether the named key is ours, and reports
462
- * `key-identity-unknown` rather than claiming a pass.
510
+ * `key-identity-unknown` rather than claiming a pass. With it and no
511
+ * `holdsKey`, a head naming any other key is `names-key-we-lack`.
463
512
  */
464
513
  keyId?: string;
465
514
  /**
@@ -616,6 +665,8 @@ interface OneAddressAddress {
616
665
  }
617
666
  interface OneAddressCustomer {
618
667
  email: string;
668
+ /** The name the consumer gave. Consumer-supplied and unverified; see
669
+ * `known_names` for how to use it. */
619
670
  name: string;
620
671
  /** Account/policy/membership number the customer provided for this service.
621
672
  * Null when the guest did not enter an account ref, or for account-flow
@@ -623,8 +674,13 @@ interface OneAddressCustomer {
623
674
  * your records. */
624
675
  account_number: string | null;
625
676
  /** Additional names the customer is known by (maiden name, nickname, etc.).
626
- * Always an array; empty when no aliases were provided. Partners should
627
- * check `name` and each entry in `known_names` when matching their records. */
677
+ * Always an array; empty when no aliases were provided.
678
+ *
679
+ * `name` and `known_names` are CONSUMER-SUPPLIED: typed by the consumer and
680
+ * sealed in their browser, not checked by OneAddress against any document.
681
+ * Find the record by your own key (the account number you issued), then
682
+ * match these against the name on it with {@link namePoolMatches}. Never
683
+ * pick a record because one of these names matched it. */
628
684
  known_names: string[];
629
685
  }
630
686
  /**
@@ -641,7 +697,7 @@ interface OneAddressCustomer {
641
697
  * Nothing about the consumer is knowable before decryption, so match on the
642
698
  * decrypted payload. Which field holds the ciphertext depends on the event: a
643
699
  * D5 dispatch carries `session_envelope`, whose `SessionData` gives the
644
- * verified name, known names and account number; the legacy-shaped
700
+ * consumer-supplied name, known names and account number; the legacy-shaped
645
701
  * `address.verify` carries `address_encrypted` instead, which this SDK decrypts
646
702
  * for you (see {@link OneAddressVerifyEvent.raw}).
647
703
  *
@@ -798,6 +854,16 @@ interface OneAddressUpdateEvent {
798
854
  * See {@link OneAddressIdVerification}.
799
855
  */
800
856
  id_verification?: OneAddressIdVerification;
857
+ /**
858
+ * The day the change takes effect, `YYYY-MM-DD`. Present on a SCHEDULED
859
+ * MOVE, which OneAddress sends early enough for your declared notice period
860
+ * (Notice card in the portal), so it can arrive days before the customer
861
+ * moves. Apply the change from this date, not from receipt: for example,
862
+ * start billing at the new address on this date. Absent on an immediate
863
+ * update, which takes effect on receipt. A body carrying a malformed value
864
+ * is refused with 400 before this callback runs.
865
+ */
866
+ effective_date?: string;
801
867
  /** Raw decrypted + parsed payload (in case fields are extended) */
802
868
  raw: Record<string, unknown>;
803
869
  }
@@ -911,8 +977,11 @@ interface HandlerConfirmOptions {
911
977
  * confirm secret is the ONLY thing accepted once it exists.
912
978
  */
913
979
  confirmSecret: string;
914
- /** Override the OneAddress base URL. Defaults to https://oneaddress.io */
980
+ /** Override the OneAddress base URL. Defaults to https://oneaddress.io.
981
+ * Checked as {@link ConfirmUpdateOptions.appBaseUrl} is. */
915
982
  oneAddressApi?: string;
983
+ /** Extra hosts `oneAddressApi` may name. See {@link ConfirmUpdateOptions.allowedHosts}. */
984
+ allowedHosts?: readonly string[];
916
985
  /** Inject a fetch implementation, mainly for tests. */
917
986
  fetchImpl?: typeof fetch;
918
987
  }
@@ -986,12 +1055,19 @@ interface OneAddressHandlerOptions {
986
1055
  /**
987
1056
  * OPTIONAL — OneAddress's ECDSA P-256 LOA signing public key (SPKI PEM), from
988
1057
  * {@link fetchLoaPublicKey}. Applies to `address.updated` ONLY (both the D5
989
- * and legacy sub-paths, wherever `loa_encrypted` is present). When set, the
990
- * handler decrypts `loa_encrypted`, verifies the signed D5 LOA, and REJECTS
991
- * the dispatch (500) if the signature is invalid - you never process an
992
- * update whose consent proof doesn't verify. When unset, the decrypted LOA
993
- * is still passed to your handler as `event.loa` (and `event.loa_ref`) for
994
- * you to verify yourself. Cache the key; it only changes on a planned rotation.
1058
+ * and legacy sub-paths, wherever `loa_encrypted` is present). The handler
1059
+ * decrypts `loa_encrypted`, verifies the signed D5 LOA, and REJECTS the
1060
+ * dispatch (500) if the signature is invalid - you never process an update
1061
+ * whose consent proof doesn't verify.
1062
+ *
1063
+ * WHEN UNSET (2.8.0), the handler fetches the published key from
1064
+ * `{loaPublicKeyBaseUrl}/.well-known/oneaddress-loa-key.pem` on first use and
1065
+ * caches it for a day, because {@link OneAddressHandlerOptions.requireLoa} is
1066
+ * now on by default and a required consent proof that nobody checks is not a
1067
+ * control. An unreachable key refuses the dispatch (500, so OneAddress
1068
+ * retries) with an error naming both ways out. Pin it here to avoid the
1069
+ * fetch. Only with `requireLoa: false` and no key is the LOA left unverified,
1070
+ * passed to your handler as `event.loa` for you to check yourself.
995
1071
  *
996
1072
  * `address.verify`'s `event.loa` is a separate, still-cleartext legacy
997
1073
  * shape ({@link OneAddressLOA}) read directly off the wire - this option
@@ -1006,9 +1082,16 @@ interface OneAddressHandlerOptions {
1006
1082
  loaPublicKeyPem?: string;
1007
1083
  /**
1008
1084
  * Refuse an `address.updated` / `contact.updated` dispatch that carries no
1009
- * `loa_encrypted` at all. Defaults to `true` when `loaPublicKeyPem` is set
1010
- * and `false` otherwise.
1011
- *
1085
+ * `loa_encrypted` at all, or one whose LOA does not verify against
1086
+ * OneAddress's key. **Defaults to `true` (2.8.0).** It used to default to
1087
+ * `true` only when `loaPublicKeyPem` was set, so a receiver configured with
1088
+ * a webhook secret and nothing else accepted any dispatch that secret
1089
+ * signed: whoever held the secret could impersonate OneAddress. With it on,
1090
+ * a dispatch also needs a consent proof signed by OneAddress's offline LOA
1091
+ * key, which the webhook secret cannot produce. Opt out only with an
1092
+ * explicit `requireLoa: false`.
1093
+ *
1094
+ * BEFORE 2.8.0 the default followed the key:
1012
1095
  * WHY THE DEFAULT FOLLOWS THE KEY. Until 2.1.0 setting `loaPublicKeyPem`
1013
1096
  * verified the consent proof only when one arrived: a dispatch with the
1014
1097
  * block simply omitted was processed with no check at all, so "verified"
@@ -1024,6 +1107,13 @@ interface OneAddressHandlerOptions {
1024
1107
  * in the log rather than silent.
1025
1108
  */
1026
1109
  requireLoa?: boolean;
1110
+ /**
1111
+ * Where the handler fetches OneAddress's LOA public key from when
1112
+ * `loaPublicKeyPem` is unset and `requireLoa` is on. Default
1113
+ * `https://oneaddress.io`. Held to the same host allowlist and https rule as
1114
+ * {@link fetchLoaPublicKey}; a disallowed value throws at construction.
1115
+ */
1116
+ loaPublicKeyBaseUrl?: string;
1027
1117
  /**
1028
1118
  * OPTIONAL. Close the confirm loop from inside the handler.
1029
1119
  *
@@ -1042,6 +1132,13 @@ interface OneAddressHandlerOptions {
1042
1132
  * count against you.
1043
1133
  */
1044
1134
  confirm?: HandlerConfirmOptions;
1135
+ /**
1136
+ * Your partner UUID. Optional. When set (or when `confirm.partnerId` is), a
1137
+ * v2 LOA must have been signed for exactly this id; otherwise it is compared
1138
+ * with the `partner_id` of the HMAC-signed body, which is what every decrypt
1139
+ * step already uses. Setting it is the stronger check.
1140
+ */
1141
+ partnerId?: string;
1045
1142
  /**
1046
1143
  * Called when a consumer dispatches an address update to you.
1047
1144
  *
@@ -1095,6 +1192,12 @@ interface OneAddressHandlerOptions {
1095
1192
  onUpdate: (event: OneAddressUpdateEvent) => Promise<{
1096
1193
  status?: OneAddressConfirmStatus;
1097
1194
  reference?: string;
1195
+ /**
1196
+ * Sent as the confirm's `note` when `confirm` is set, so a `failed` can say
1197
+ * why. Shown to OneAddress support, never to the consumer. NEVER the
1198
+ * address or any other decrypted detail: see {@link ConfirmUpdateOptions.note}.
1199
+ */
1200
+ note?: string;
1098
1201
  } | void>;
1099
1202
  /**
1100
1203
  * Called when a consumer runs an address verification check.
@@ -1153,6 +1256,21 @@ interface OneAddressHandlerOptions {
1153
1256
  * else is refused at construction, since `NaN` here accepts every timestamp.
1154
1257
  */
1155
1258
  timestampToleranceSecs?: number;
1259
+ /**
1260
+ * The largest request body the handler will read, in bytes. Default
1261
+ * 1 MiB (1048576); a real dispatch is a few kilobytes.
1262
+ *
1263
+ * WHY IT EXISTS. The signature is an HMAC over the whole body, so the body
1264
+ * has to be read before anyone knows whether the sender holds the secret.
1265
+ * Until this option the handler read it with no cap at all, which let an
1266
+ * unauthenticated caller make the receiver buffer and hash as much as it
1267
+ * cared to send. Now a declared `Content-Length` over the cap is refused
1268
+ * before reading, and the stream is read with the cap enforced as it
1269
+ * arrives, both BEFORE the HMAC. Either answers `413`.
1270
+ *
1271
+ * Refused at construction unless it is a positive integer.
1272
+ */
1273
+ maxBodyBytes?: number;
1156
1274
  /**
1157
1275
  * Idempotency store for deduplicating repeated webhook deliveries.
1158
1276
  *
@@ -1243,10 +1361,26 @@ interface OneAddressHandlerOptions {
1243
1361
  * completion. **Process it again.** This is the case a naive "seen set" gets
1244
1362
  * wrong: if the first attempt died after being recorded, skipping the retry
1245
1363
  * loses the update permanently while both sides report success.
1364
+ * - `in-progress` - seen, not completed, and the earlier claim is still
1365
+ * inside its lease: another delivery of the same dispatch is being
1366
+ * processed right now. **Do not process it.** The handler answers
1367
+ * `503 dispatch_in_progress` with `Retry-After`, so OneAddress comes back
1368
+ * once the first attempt has either completed (the retry is then a
1369
+ * `duplicate`) or died (the lease expires and the retry is a
1370
+ * `retry-after-incomplete`).
1246
1371
  * - `duplicate` — seen and completed. Skip; the handler responds
1247
1372
  * `200 { ok: true, duplicate: true }`.
1373
+ *
1374
+ * WHY `in-progress` EXISTS (Oct 2026 audit). Without it a store could only say
1375
+ * "incomplete", and incomplete covers two different states: an attempt that
1376
+ * died, and an attempt that is still running. Both were answered
1377
+ * `retry-after-incomplete`, so a second delivery arriving while the first was
1378
+ * mid-`onUpdate` (OneAddress times a slow receiver out at about ten seconds
1379
+ * and retries) ran the update a second time, concurrently. A lease is what
1380
+ * tells the two apart. A store written before this value existed never returns
1381
+ * it and behaves exactly as it did.
1248
1382
  */
1249
- type IdempotencyClaim = 'fresh' | 'retry-after-incomplete' | 'duplicate';
1383
+ type IdempotencyClaim = 'fresh' | 'retry-after-incomplete' | 'in-progress' | 'duplicate';
1250
1384
  interface IdempotencyStore {
1251
1385
  /**
1252
1386
  * Legacy check. Ignored when {@link IdempotencyStore.claim} is present.
@@ -1263,7 +1397,12 @@ interface IdempotencyStore {
1263
1397
  *
1264
1398
  * Must be a single atomic operation (an `INSERT … ON CONFLICT DO NOTHING`,
1265
1399
  * a Redis `SET NX`, a conditional write) — otherwise concurrent retries can
1266
- * both claim the same dispatch.
1400
+ * both claim the same dispatch. Taking over a STALE claim must be atomic
1401
+ * too (a conditional update on the claim time), or two retries arriving
1402
+ * after a crash both take it over.
1403
+ *
1404
+ * Return `in-progress` for a claim that is incomplete and still inside its
1405
+ * lease; see {@link IdempotencyClaim}.
1267
1406
  */
1268
1407
  claim?(dispatchId: string): Promise<IdempotencyClaim>;
1269
1408
  /**
@@ -1272,6 +1411,18 @@ interface IdempotencyStore {
1272
1411
  * incomplete so the next retry re-processes it.
1273
1412
  */
1274
1413
  complete?(dispatchId: string): Promise<void>;
1414
+ /**
1415
+ * OPTIONAL. Give up a claim that did not complete, so the next delivery can
1416
+ * take it at once instead of waiting out the lease. The handler calls it on
1417
+ * every exit after a successful `claim` that did not reach `complete`: a
1418
+ * throwing `onUpdate` (500), a refused update kind (422), a missing key
1419
+ * (503), and the events that never complete a claim at all.
1420
+ *
1421
+ * Without it a lease-keeping store makes the retry of a failed attempt wait
1422
+ * for the lease to expire, answering `in-progress` meanwhile. That is safe
1423
+ * (nothing runs twice) and only slower.
1424
+ */
1425
+ release?(dispatchId: string): Promise<void>;
1275
1426
  }
1276
1427
 
1277
1428
  /**
@@ -1311,6 +1462,8 @@ interface IdempotencyStore {
1311
1462
  */
1312
1463
  /** The databases {@link createSqlIdempotencyStore} generates SQL for. */
1313
1464
  type IdempotencyDialect = 'postgres' | 'sqlite' | 'mysql' | 'mssql';
1465
+ /** Default `leaseSeconds` for {@link createSqlIdempotencyStore}. */
1466
+ declare const DEFAULT_IDEMPOTENCY_LEASE_SECS = 120;
1314
1467
  declare function createSqlIdempotencyStore(opts: {
1315
1468
  /**
1316
1469
  * Run parameterised SQL and return the result rows. Must not swallow errors —
@@ -1337,6 +1490,24 @@ declare function createSqlIdempotencyStore(opts: {
1337
1490
  * for mssql). Override only if your driver rewrites placeholders.
1338
1491
  */
1339
1492
  placeholder?: (n: number) => string;
1493
+ /**
1494
+ * How long an incomplete claim is presumed still running, in seconds.
1495
+ * Default 120. Inside it a second delivery of the same dispatch is answered
1496
+ * `in-progress` (the handler says `503` with `Retry-After`) instead of being
1497
+ * processed alongside the first; past it the claim is presumed dead and the
1498
+ * next delivery takes it over as `retry-after-incomplete`.
1499
+ *
1500
+ * Set it above the longest your `onUpdate` can run. `0` turns the lease off
1501
+ * and restores the behaviour before it existed, where every incomplete
1502
+ * claim was retried at once, including one still running.
1503
+ *
1504
+ * THE CLAIM TIME IS `received_at`, the column the table already has, so no
1505
+ * schema change is needed: a fresh claim stamps it by its `DEFAULT`, and a
1506
+ * takeover re-stamps it in the same conditional `UPDATE` that decides who
1507
+ * won. All the time arithmetic runs in the database, against the same clock
1508
+ * that wrote the column.
1509
+ */
1510
+ leaseSeconds?: number;
1340
1511
  }): IdempotencyStore;
1341
1512
  /**
1342
1513
  * Verify the HMAC-SHA256 webhook signature.
@@ -1457,6 +1628,16 @@ interface SessionData {
1457
1628
  v: 2;
1458
1629
  update_uid?: string;
1459
1630
  dispatch_timestamp?: string;
1631
+ /**
1632
+ * The name the consumer gave, for you to match against YOUR record.
1633
+ *
1634
+ * NOT VERIFIED, whatever the field is called (the name is wire format and
1635
+ * stays). The envelope is sealed in the consumer's browser, so this is
1636
+ * whatever they typed. Identity verification proves who authorised the
1637
+ * dispatch; it does not prove this string is the name on your account.
1638
+ * Look the account up by your own key and compare with
1639
+ * {@link namePoolMatches}; never use this to choose the record.
1640
+ */
1460
1641
  verified_name: string;
1461
1642
  /**
1462
1643
  * Which kinds of detail this envelope concerns.
@@ -1518,7 +1699,18 @@ interface SessionData {
1518
1699
  new_email?: string;
1519
1700
  account_number: string;
1520
1701
  id_verification_ref: string;
1702
+ /**
1703
+ * Other names the consumer says they go by. Consumer-supplied and
1704
+ * unverified, exactly as {@link SessionData.verified_name} is: a pool to
1705
+ * match against your own record, never a key to look one up by.
1706
+ */
1521
1707
  known_names?: string[];
1708
+ /**
1709
+ * The day the change takes effect, `YYYY-MM-DD`, sealed by the consumer's
1710
+ * browser on a scheduled move. The handler refuses a dispatch whose body
1711
+ * `effective_date` differs from this one, or where only one is present.
1712
+ */
1713
+ effective_date?: string;
1522
1714
  }
1523
1715
  /**
1524
1716
  * Decrypt a D5 session envelope using your retained private key matching
@@ -1566,10 +1758,18 @@ interface SessionData {
1566
1758
  * - or the share was forged.
1567
1759
  *
1568
1760
  * @example
1569
- * import { decryptSession } from '@oneaddress/partner-sdk';
1761
+ * import { decryptSession, isFreshTimestamp, verifySignature } from '@oneaddress/partner-sdk';
1570
1762
  *
1571
1763
  * // Body of an address.updated webhook.
1572
- * const body = await req.json();
1764
+ * // Freshness and signature FIRST, over the raw bytes. Decrypting a body
1765
+ * // you have not verified trusts whoever sent it.
1766
+ * const rawBody = await req.text();
1767
+ * const ts = req.headers.get('x-oneaddress-timestamp') ?? '';
1768
+ * const sig = req.headers.get('x-oneaddress-signature') ?? '';
1769
+ * if (!isFreshTimestamp(ts) || !verifySignature(rawBody, sig, ts, process.env.OA_WEBHOOK_SECRET!)) {
1770
+ * return new Response('invalid signature', { status: 401 });
1771
+ * }
1772
+ * const body = JSON.parse(rawBody);
1573
1773
  * const myPrivateKey = keyStore.get(body.session_key_share.key_id);
1574
1774
  * if (!myPrivateKey) throw new Error(`No private key for ${body.session_key_share.key_id}`);
1575
1775
  *
@@ -1579,7 +1779,8 @@ interface SessionData {
1579
1779
  * myPrivateKey,
1580
1780
  * body.partner_id,
1581
1781
  * );
1582
- * // data.new_address.street, data.account_number, etc.
1782
+ * // data.new_address.street, data.account_number, etc. data.verified_name and
1783
+ * // data.known_names are consumer-supplied: match them against your record.
1583
1784
  */
1584
1785
  declare function decryptSession(share: SessionKeyShare, envelopeB64: string, privateKeyPem: string | PrivateKeyOperations, partnerId: string, expectedAlg?: SessionKeyShare['alg'] | null): Promise<SessionData>;
1585
1786
  /**
@@ -1602,16 +1803,27 @@ declare function decryptSession(share: SessionKeyShare, envelopeB64: string, pri
1602
1803
  * @returns A fresh `EncryptedPayload` encrypted to `recipientSpkiPem`
1603
1804
  *
1604
1805
  * @example
1806
+ * // From your own route, on the raw webhook body. Inside `onUpdate` the
1807
+ * // payload is already decrypted and `event.raw` holds plaintext, not this.
1808
+ * // Freshness and signature FIRST, over the raw bytes. Decrypting a body
1809
+ * // you have not verified trusts whoever sent it.
1810
+ * const rawBody = await req.text();
1811
+ * const ts = req.headers.get('x-oneaddress-timestamp') ?? '';
1812
+ * const sig = req.headers.get('x-oneaddress-signature') ?? '';
1813
+ * if (!isFreshTimestamp(ts) || !verifySignature(rawBody, sig, ts, process.env.OA_WEBHOOK_SECRET!)) {
1814
+ * return new Response('invalid signature', { status: 401 });
1815
+ * }
1816
+ * const body = JSON.parse(rawBody);
1605
1817
  * const kmsBlob = await transformAddress(
1606
- * event.raw.address_encrypted as EncryptedPayload,
1818
+ * body.address_encrypted as EncryptedPayload,
1607
1819
  * process.env.OA_PRIVATE_KEY_PEM!,
1608
- * event.partner_id,
1820
+ * body.partner_id,
1609
1821
  * process.env.KMS_PUBLIC_KEY_SPKI_PEM!,
1610
1822
  * );
1611
- * // Key on the account number, NOT on `customer.email`: that field is always
1612
- * // '' on a dispatch, so keying on it files every partner's addresses under
1613
- * // one empty-string row, silently and without an error.
1614
- * await db.storeEncryptedAddress(event.customer?.account_number, kmsBlob);
1823
+ * // File by dispatch, NOT on `customer.email`: that field is always '' on a
1824
+ * // dispatch, so keying on it files every partner's addresses under one
1825
+ * // empty-string row, silently and without an error.
1826
+ * await db.storeEncryptedAddress(body.dispatch_id, kmsBlob);
1615
1827
  */
1616
1828
  declare function transformAddress(payload: EncryptedPayload, privateKeyPem: string, partnerId: string, recipientSpkiPem: string): Promise<EncryptedPayload>;
1617
1829
  /**
@@ -1647,9 +1859,17 @@ declare function transformAddress(payload: EncryptedPayload, privateKeyPem: stri
1647
1859
  * @returns A fresh `EncryptedPayload` encrypted to `recipientSpkiPem`.
1648
1860
  *
1649
1861
  * @example
1650
- * import { transformSession } from '@oneaddress/partner-sdk';
1651
- *
1652
- * const body = await req.json();
1862
+ * import { transformSession, isFreshTimestamp, verifySignature } from '@oneaddress/partner-sdk';
1863
+ *
1864
+ * // Freshness and signature FIRST, over the raw bytes. Decrypting a body
1865
+ * // you have not verified trusts whoever sent it.
1866
+ * const rawBody = await req.text();
1867
+ * const ts = req.headers.get('x-oneaddress-timestamp') ?? '';
1868
+ * const sig = req.headers.get('x-oneaddress-signature') ?? '';
1869
+ * if (!isFreshTimestamp(ts) || !verifySignature(rawBody, sig, ts, process.env.OA_WEBHOOK_SECRET!)) {
1870
+ * return new Response('invalid signature', { status: 401 });
1871
+ * }
1872
+ * const body = JSON.parse(rawBody);
1653
1873
  * const myPrivateKey = keyStore.get(body.session_key_share.key_id);
1654
1874
  * const kmsBlob = await transformSession(
1655
1875
  * body.session_key_share,
@@ -1658,7 +1878,8 @@ declare function transformAddress(payload: EncryptedPayload, privateKeyPem: stri
1658
1878
  * body.partner_id,
1659
1879
  * process.env.KMS_PUBLIC_KEY_SPKI_PEM!,
1660
1880
  * );
1661
- * await db.storeEncryptedAddress(body.customer.email, kmsBlob);
1881
+ * // No cleartext customer block exists under D5: file by dispatch.
1882
+ * await db.storeEncryptedAddress(body.dispatch_id, kmsBlob);
1662
1883
  */
1663
1884
  declare function transformSession(share: SessionKeyShare, envelopeB64: string, privateKeyPem: string | PrivateKeyOperations, partnerId: string, recipientSpkiPem: string): Promise<EncryptedPayload>;
1664
1885
  /**
@@ -1704,8 +1925,18 @@ interface ConfirmUpdateOptions {
1704
1925
  loaRef?: string;
1705
1926
  /** The name you matched in your own records, if you want it recorded. */
1706
1927
  memberName?: string;
1707
- /** Override the consumer-app base URL. Defaults to https://oneaddress.io */
1928
+ /**
1929
+ * Override the consumer-app base URL. Defaults to https://oneaddress.io.
1930
+ * Must be https on `oneaddress.io` or `app.oneaddress.io` (or a host in
1931
+ * `allowedHosts`); plain http is accepted for localhost outside production
1932
+ * only. Anything else is refused before the secret leaves the process.
1933
+ */
1708
1934
  appBaseUrl?: string;
1935
+ /**
1936
+ * Extra hostnames `appBaseUrl` may name, for a staging or self-hosted relay
1937
+ * ONLY. Every host added here is a host your confirm secret is sent to.
1938
+ */
1939
+ allowedHosts?: readonly string[];
1709
1940
  /** Inject a fetch implementation, mainly for tests. */
1710
1941
  fetchImpl?: typeof fetch;
1711
1942
  }
@@ -1788,6 +2019,23 @@ declare function confirmUpdate(opts: ConfirmUpdateOptions): Promise<ConfirmUpdat
1788
2019
  * const ok = await verifyLOA(event.loa, loaPublicKey);
1789
2020
  */
1790
2021
  declare function fetchLoaPublicKey(appBaseUrl?: string): Promise<string>;
2022
+ /** How long a fetched LOA key is reused before it is fetched again. */
2023
+ declare const LOA_PUBLIC_KEY_CACHE_MS: number;
2024
+ /** Thrown when the handler needs OneAddress's LOA key and cannot get it. */
2025
+ declare class LoaPublicKeyUnavailableError extends Error {
2026
+ readonly from: string;
2027
+ constructor(from: string, cause: string);
2028
+ }
2029
+ /**
2030
+ * The LOA key for `appBaseUrl`, fetched once and reused for
2031
+ * {@link LOA_PUBLIC_KEY_CACHE_MS}. Concurrent first calls share one fetch. A
2032
+ * failed refresh falls back to the key already held, because the key changes
2033
+ * only on an announced rotation and an outage of our well-known endpoint
2034
+ * should not stop a receiver that already holds it. Never caches a failure.
2035
+ */
2036
+ declare function cachedLoaPublicKey(appBaseUrl?: string, now?: number): Promise<string>;
2037
+ /** Forget every cached LOA key. Exported for the SDK's own tests. */
2038
+ declare function _resetLoaKeyCacheForTests(): void;
1791
2039
  /**
1792
2040
  * Verify the ECDSA P-256 signature on a OneAddress Letter of Authority.
1793
2041
  *
@@ -1831,13 +2079,42 @@ declare function verifyLOA(loa: OneAddressLOA, publicKeyPem: string): Promise<bo
1831
2079
  * key — it never travels in cleartext.
1832
2080
  */
1833
2081
  interface OneAddressD5LOA {
2082
+ /**
2083
+ * The identity-verified legal name of the person who authorised the update.
2084
+ * Since 24 Oct 2026 OneAddress fills this from the identity check, never from
2085
+ * anything the consumer typed. Compare the envelope's `verified_name` with it
2086
+ * through {@link loaNamesMatch}; the handler does so whenever v2 is present.
2087
+ */
1834
2088
  consumer_name: string;
1835
2089
  authorisation_date: string;
1836
2090
  scope: string;
1837
2091
  update_uid: string;
1838
2092
  oneaddress_acn: string;
2093
+ /** Version 1 signature, over {@link canonicalD5LoaForm}. Always present. */
1839
2094
  oneaddress_signature: string;
1840
2095
  signature_algorithm: 'ECDSA-P256' | 'HMAC-SHA256';
2096
+ /**
2097
+ * VERSION 2 (24 Oct 2026). Present on every LOA OneAddress signs from that
2098
+ * date; absent on earlier ones, which verify exactly as before.
2099
+ *
2100
+ * v2 is signed once per recipient and binds the recipient (`partner_id`) and
2101
+ * the envelope it travels beside (`envelope_sha256`), so a genuine LOA cannot
2102
+ * be reused at another recipient or beside a different envelope. See
2103
+ * {@link checkLoaV2} for what is checked and in which order.
2104
+ */
2105
+ partner_id?: string;
2106
+ /** Lowercase hex SHA-256 of the envelope as received. See {@link loaEnvelopeSha256}. */
2107
+ envelope_sha256?: string;
2108
+ /**
2109
+ * Names the CONSUMER typed, never verified: at most three, admitted by the
2110
+ * alias rule (same first name, or a short form of it of at least three letters). Always
2111
+ * present on a v2 LOA, possibly empty. Kept apart from `consumer_name` so a
2112
+ * typed alias can never be read as the verified name. Read them through
2113
+ * {@link typedAliasesOf}, which re-applies the rule.
2114
+ */
2115
+ consumer_typed_aliases?: string[];
2116
+ /** Signature over {@link canonicalD5LoaFormV2}, same key and encoding as v1. */
2117
+ oneaddress_signature_v2?: string;
1841
2118
  }
1842
2119
  /**
1843
2120
  * The exact canonical string OneAddress signs for a D5 LOA — must be
@@ -1877,12 +2154,97 @@ declare function decryptLoaEncrypted(loaEncrypted: {
1877
2154
  }, privateKeyPem: string | PrivateKeyOperations, partnerId: string,
1878
2155
  /** Same pin as {@link decryptSession}'s `expectedAlg`; the LOA is wrapped to the same key. */
1879
2156
  expectedAlg?: SessionKeyShare['alg'] | null): Promise<OneAddressD5LOA>;
2157
+ /** True when this LOA carries a v2 signature, so {@link checkLoaV2} applies. */
2158
+ declare function hasLoaV2(loa: OneAddressD5LOA): boolean;
2159
+ /**
2160
+ * The exact string OneAddress signs for a v2 LOA: length-prefixed rather than
2161
+ * pipe-joined, so no field can shift another's boundary. Throws when a field is
2162
+ * missing or contains a control character, which {@link checkLoaV2} reports as
2163
+ * `loa_v2_malformed`. The definition and its test vectors live in
2164
+ * `@oneaddress/protocol` and every SDK reproduces them byte for byte.
2165
+ */
2166
+ declare function canonicalD5LoaFormV2(loa: OneAddressD5LOA): string;
2167
+ /**
2168
+ * `envelope_sha256` for what you received: the `session_envelope` string exactly
2169
+ * as it arrived, or for a legacy dispatch the `address_encrypted` object's four
2170
+ * fields in a fixed encoding. Lowercase hex.
2171
+ */
2172
+ declare function loaEnvelopeSha256(envelope: string | EncryptedPayload): string;
2173
+ /** Verify the v2 signature. `false` for an invalid signature, a malformed LOA, or HMAC. */
2174
+ declare function verifyD5LOAv2(loa: OneAddressD5LOA, publicKeyPem: string): Promise<boolean>;
2175
+ /** What {@link checkLoaV2} compares a v2 LOA against. */
2176
+ interface LoaV2Context {
2177
+ /** The partner id this receiver is configured as. */
2178
+ partnerId: string;
2179
+ /** `update_id` from the signed webhook body, as parsed. */
2180
+ updateId: unknown;
2181
+ /** The envelope as received: `session_envelope`, or the legacy `address_encrypted`. */
2182
+ envelope: string | EncryptedPayload;
2183
+ /** The decrypted envelope's name: `verified_name`, or the legacy blob's `fullName`. */
2184
+ envelopeVerifiedName: unknown;
2185
+ /** OneAddress's LOA key. Omit and the signature is not checked; the bindings still are. */
2186
+ publicKeyPem?: string;
2187
+ }
2188
+ /**
2189
+ * The typed aliases a recipient may rely on, from a v2 LOA: its signed
2190
+ * `consumer_typed_aliases`, re-checked against the verified name by the shared
2191
+ * rule and capped at three. The envelope's `known_names` are NOT used for a v2
2192
+ * LOA: the signed list is the one OneAddress vouches for. `[]` for a v1 LOA.
2193
+ */
2194
+ declare function typedAliasesOf(loa: OneAddressD5LOA): string[];
2195
+ /**
2196
+ * Every check a v2 LOA must pass, in the shared order, returning the first
2197
+ * refusal or `null`:
2198
+ *
2199
+ * 1. `loa_v2_malformed` a v2 field missing, or one the form refuses
2200
+ * 2. `loa_v2_signature_invalid` when `publicKeyPem` is given
2201
+ * 3. `loa_v2_partner_mismatch` signed for another recipient
2202
+ * 4. `loa_v2_update_mismatch` `update_uid` is not the body's `update_id`
2203
+ * 5. `loa_v2_envelope_mismatch` signed beside a different envelope
2204
+ * 6. `loa_v2_name_mismatch` the envelope's verified name is not the LOA's
2205
+ *
2206
+ * The name comparison is {@link loaNamesMatch}: case, whitespace and diacritics
2207
+ * are folded, nothing else is. Only the VERIFIED name is compared here: a typed
2208
+ * alias never satisfies it. Aliases come second, from {@link typedAliasesOf},
2209
+ * and are dropped rather than refused. The handler runs this whenever
2210
+ * {@link hasLoaV2}, and an LOA without v2 is handled exactly as it was before
2211
+ * v2 existed.
2212
+ */
2213
+ declare function checkLoaV2(loa: OneAddressD5LOA, ctx: LoaV2Context): Promise<LoaV2Refusal | null>;
2214
+ /** Thrown by the handler for a v2 LOA that fails {@link checkLoaV2}; carries the refusal code. */
2215
+ declare class LoaV2RefusedError extends Error {
2216
+ readonly code: LoaV2Refusal;
2217
+ constructor(code: LoaV2Refusal);
2218
+ }
1880
2219
  /**
1881
- * Validate and narrow the decrypted address payload to `OneAddressAddress`.
2220
+ * The longest value any one address field may carry, in characters.
1882
2221
  *
1883
- * Throws a descriptive `Error` if any required field is absent or not a string.
1884
- * Call this after `decryptAddress()` when you want explicit failure rather than
1885
- * silently receiving `undefined` for a missing field.
2222
+ * Generous for any real street line, and far short of what a consumer could
2223
+ * otherwise seal into the blob for a receiver to write into a VARCHAR column,
2224
+ * a log line or a CRM field. A field over it is refused, not truncated: a
2225
+ * truncated street is a different address that still looks like one.
2226
+ */
2227
+ declare const MAX_ADDRESS_FIELD_CHARS = 512;
2228
+ /**
2229
+ * Validate the decrypted address payload and return a NEW `OneAddressAddress`
2230
+ * built from its six named fields and nothing else.
2231
+ *
2232
+ * Throws a descriptive `Error` if any required field is absent, not a string,
2233
+ * or longer than {@link MAX_ADDRESS_FIELD_CHARS}. `updated_at` is optional on
2234
+ * the way in (a string or a number; absent reads as `''`).
2235
+ *
2236
+ * ── WHY IT COPIES RATHER THAN NARROWS (Oct 2026 audit) ─────────────────────
2237
+ *
2238
+ * Until this release it returned the object it was given, cast. On the legacy
2239
+ * `address_encrypted` paths that object is the whole decrypted blob, and the
2240
+ * blob is sealed in the CONSUMER's browser, so every key in it is the
2241
+ * consumer's choice. The README's own examples then spread it into the
2242
+ * partner's row, `{ id: record.id, ...event.address }`, and a blob carrying
2243
+ * `id` or `accountNumber` redirected the write to another customer's record.
2244
+ * The D5 path always built the address from named fields; every path now
2245
+ * does, so `event.address` holds exactly the six keys its type names. The
2246
+ * whole blob is still on `event.raw` for anyone who needs it, and is
2247
+ * consumer-supplied there too.
1886
2248
  *
1887
2249
  * `createOneAddressHandler` runs this automatically before calling `onUpdate`
1888
2250
  * and `onVerify`, so SDK users get validation for free.
@@ -1890,7 +2252,7 @@ expectedAlg?: SessionKeyShare['alg'] | null): Promise<OneAddressD5LOA>;
1890
2252
  * @example
1891
2253
  * const raw = await decryptAddress(payload, privateKeyPem, partnerId);
1892
2254
  * const address = validateAddress(raw); // throws if malformed
1893
- * await db.updateAddress(address);
2255
+ * await db.updateAddress(customerId, address);
1894
2256
  */
1895
2257
  declare function validateAddress(raw: unknown): OneAddressAddress;
1896
2258
  /**
@@ -1915,6 +2277,7 @@ interface AddressParts {
1915
2277
  * one copy silently left the others behind. Prefer this over re-implementing it.
1916
2278
  *
1917
2279
  * @example
2280
+ * // Only after verifySignature has passed on the raw body; see decryptSession.
1918
2281
  * const data = await decryptSession(share, envelope, privateKeyPem, partnerId);
1919
2282
  * const parts = readAddressParts(data.new_address);
1920
2283
  * await db.updateAddress({ id, line1: parts.line1 || row.line1, ... });
@@ -2068,6 +2431,29 @@ interface OneAddressTestEvent {
2068
2431
  }
2069
2432
  /** Reset the once-per-process warning flags. Exported for the SDK's own tests. */
2070
2433
  declare function _resetOnceWarningsForTests(): void;
2434
+ /** Default {@link OneAddressHandlerOptions.maxBodyBytes}: 1 MiB. */
2435
+ declare const DEFAULT_MAX_BODY_BYTES = 1048576;
2436
+ /**
2437
+ * The consent proof and the envelope must be about the same update.
2438
+ *
2439
+ * Both carry `update_uid` when they were written after the field existed. A
2440
+ * genuine, correctly-signed LOA for update A placed beside the envelope of
2441
+ * update B would otherwise verify, so a relay that held one real consent
2442
+ * could reuse it. Older dispatches lack the field on one side or the other
2443
+ * and are let through: the check is a binding, not a requirement.
2444
+ */
2445
+ /**
2446
+ * Thrown when the body's `effective_date` and the one sealed inside the
2447
+ * envelope disagree, or only one of them is present. Refused like the other
2448
+ * binding failures: OneAddress sees the dispatch fail and nothing is applied.
2449
+ */
2450
+ declare class EffectiveDateMismatchError extends Error {
2451
+ readonly sealed: unknown;
2452
+ readonly body: unknown;
2453
+ constructor(sealed: unknown, body: unknown);
2454
+ }
2455
+ /** Both absent, or both present and equal. Anything else throws {@link EffectiveDateMismatchError}. */
2456
+ declare function assertEffectiveDateBound(sealed: unknown, body: unknown): void;
2071
2457
  /**
2072
2458
  * Create a framework-agnostic OneAddress webhook handler.
2073
2459
  * Returns a function compatible with Next.js App Router route handlers,
@@ -2167,6 +2553,12 @@ interface SignedTestWebhookOptions {
2167
2553
  * envelope's `update_uid`, with a PLACEHOLDER signature that fails
2168
2554
  * {@link verifyD5LOA}. Pass `loaSigningKeyPem` to sign it for real, or
2169
2555
  * `false` to omit `loa_encrypted` entirely (to test `requireLoa`).
2556
+ *
2557
+ * Carries v2 by default, as the relay has since 24 Oct 2026: bound to
2558
+ * `partnerId` and to this envelope's digest, both signatures placeholders
2559
+ * unless `loaSigningKeyPem` is given. Pass
2560
+ * `{ oneaddress_signature_v2: undefined }` to send a v1-only LOA, the shape
2561
+ * of every dispatch before that date.
2170
2562
  */
2171
2563
  loa?: false | Partial<OneAddressD5LOA>;
2172
2564
  /**
@@ -2192,10 +2584,9 @@ interface SignedTestWebhookOptions {
2192
2584
  */
2193
2585
  userId?: string;
2194
2586
  /**
2195
- * `stripe_session_id`. Defaults to `null`, which is what the relay sends when
2196
- * no PaymentIntent backed the update — the KEY is present either way, and
2197
- * `'stripe_session_id' in body` is a different question from
2198
- * `body.stripe_session_id != null`.
2587
+ * @deprecated Ignored since 2.8.0. The relay no longer sends
2588
+ * `stripe_session_id` (it was the same PaymentIntent id at every recipient of
2589
+ * one update), so the builder does not either.
2199
2590
  */
2200
2591
  stripeSessionId?: string | null;
2201
2592
  /**
@@ -2214,6 +2605,14 @@ interface SignedTestWebhookOptions {
2214
2605
  * assuming the body always carries an `id`.
2215
2606
  */
2216
2607
  retentionPeriodDays?: number | null;
2608
+ /**
2609
+ * Rehearse a scheduled move: sent as `effective_date` (`YYYY-MM-DD`), the
2610
+ * day the change takes effect, in the body AND sealed in the session, as
2611
+ * the relay does on every scheduled move paid through the pay step. Pass a
2612
+ * different `session.effective_date` to rehearse the mismatch refusal.
2613
+ * Omitted by default, as on an immediate update.
2614
+ */
2615
+ effectiveDate?: string;
2217
2616
  /**
2218
2617
  * Extra top-level body fields, merged last.
2219
2618
  *
@@ -2276,4 +2675,4 @@ interface SignedTestWebhook {
2276
2675
  */
2277
2676
  declare function buildSignedTestWebhook(opts: SignedTestWebhookOptions): Promise<SignedTestWebhook>;
2278
2677
 
2279
- 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, signPullRequest, toExpressHandler, toOutboxTimestamp, transformAddress as transform, transformAddress, transformSession, validateAddress, verifySignature as verify, verifyD5LOA, verifyWithGrace as verifyGrace, verifyLOA, verifySignature, verifyWithGrace };
2678
+ export { type AddressParts, type BlindIndexField, CURRENT_VERSION, type ComparableAddress, type ConfirmUpdateOptions, type ConfirmUpdateResult, DEFAULT_IDEMPOTENCY_LEASE_SECS, DEFAULT_MAX_BODY_BYTES, DEFAULT_REPLAY_WINDOW_SECS, EffectiveDateMismatchError, type EncryptedPayload, type ExpressLikeRequest, type ExpressLikeResponse, type HandlerConfirmOptions, type HandlerRequest, type HandlerResponse, type IdempotencyClaim, type IdempotencyDialect, type IdempotencyStore, LOA_MAX_TYPED_ALIASES, LOA_MIN_SHORT_FORM_LETTERS, LOA_PUBLIC_KEY_CACHE_MS, LOA_V2_REFUSALS, LoaPublicKeyUnavailableError, type LoaV2Context, type LoaV2Refusal, LoaV2RefusedError, MAX_ADDRESS_FIELD_CHARS, 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, _resetLoaKeyCacheForTests, _resetOnceWarningsForTests, acceptTypedAliases, assertEffectiveDateBound, buildSignedTestWebhook, cachedLoaPublicKey, canonicalD5LoaForm, canonicalD5LoaFormV2, checkLoaV2, checkRegistryHead, compareAddresses, computeBlindIndex, confirmUpdate, createOneAddressHandler, createOutboxConsumer, createSqlIdempotencyStore, d5LoaRef, decryptAddress as decrypt, decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, formatAddressParts, fromOutboxTimestamp, hasLoaV2, isAcceptableAlias, isEmailLike, isFreshTimestamp, loaEnvelopeSha256, loaFirstName, loaNamesMatch, loaSurname, namePoolMatches, normaliseLoaName, normalizeForBlindIndex, parsePinnedRegistryRoots, readAddressParts, sendVerifyResult, signPullRequest, toExpressHandler, toOutboxTimestamp, transformAddress as transform, transformAddress, transformSession, typedAliasesOf, validateAddress, verifySignature as verify, verifyD5LOA, verifyD5LOAv2, verifyWithGrace as verifyGrace, verifyLOA, verifySignature, verifyWithGrace };