@oneaddress/partner-sdk 2.1.0 → 2.3.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 CHANGED
@@ -7,11 +7,120 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.3.0] - 2026-10-01
11
+
12
+ Documentation, and nothing in this package's own API. **No exported symbol was
13
+ added, removed or changed**: the built bundle exports the same 40 names as
14
+ published 2.2.0, and every changed line in `dist/index.d.ts` is a comment. A
15
+ minor rather than a patch because the deprecation tags reach a consumer's editor
16
+ and linter through the `.d.ts`, which is a visible change in what the package
17
+ says about itself, and because they are the notice that these names go in the
18
+ next major.
19
+
20
+ **One thing in the bundle is not a comment, and it is not ours to call an API
21
+ change.** Diffing the built tarball against the published 2.2.0 tarball shows
22
+ `blockedPublicKeyReason` and its blocklist newly present in `dist/index.js`,
23
+ `dist/edge.js` and the ESM chunks: 22 added lines, +12 kB unpacked. It arrives
24
+ from `@oneaddress/crypto`, which this package bundles whole, and which gained
25
+ that export after 2.2.0 was cut. **The SDK neither calls it nor re-exports it**
26
+ - it sits inside the bundled crypto module's own namespace, unreachable from
27
+ either entry point - so it changes nothing a consumer can use. Recorded here
28
+ because the diff is the record: a tarball can ship a mechanism the package does
29
+ not implement, and the honest answer to "why is the bundle bigger" is better
30
+ written down than rediscovered.
31
+
32
+ ### Deprecated
33
+
34
+ - **Blind-index matching, in four places.** `computeBlindIndex`,
35
+ `normalizeForBlindIndex`, the `BlindIndexField` type, the
36
+ `OneAddressCustomerMatch` interface, and the `customer` / `customer_match`
37
+ fields on `OneAddressVerifyEvent`. Nothing is removed, so an existing import
38
+ still compiles; they go in the next major.
39
+
40
+ The shape they describe is not one OneAddress emits. `customer` and
41
+ `customer_match` are both in the body contract's refused list
42
+ (`D5_BODY_NEVER` in `@oneaddress/protocol`), so a dispatch body carrying
43
+ either fails the shape check before it is sent, and the portal control that
44
+ once enabled blind-index matching no longer exists. Nothing about the
45
+ consumer is knowable before decryption, so there is no cleartext or indexed
46
+ matching block to compare against. **Locate a record by decrypting
47
+ `session_envelope` and matching on the verified name, known names or account
48
+ number in the resulting `SessionData`.**
49
+
50
+ Why this mattered enough to say rather than leave quiet: the previous text
51
+ read as live guidance, down to "exactly one of `customer` / `customer_match`
52
+ is present on any given dispatch". A receiver written to it would branch on a
53
+ block that never arrives and conclude it could not identify the customer.
54
+
55
+ ### Documentation
56
+
57
+ - **One confirmation status covers a whole delivery, not one kind of detail.**
58
+ A dispatch can carry an address together with a new phone number or email
59
+ address. None of the four statuses can say one kind applied and another did
60
+ not, and OneAddress cannot detect a partial application from its side, so
61
+ write every kind named in `event.update_types` in the same unit of work. If
62
+ your system cannot, stop accepting that kind under **My Profile** in the
63
+ partner portal rather than applying it best-effort: refusing is honest and
64
+ visible, because we then never send it and the consumer is told. A partial
65
+ application reads to the consumer as a complete one.
66
+
67
+ - **The first confirmation for a dispatch is the one that counts.** All four
68
+ statuses resolve to a terminal record and a later confirm for the same
69
+ `dispatchId` cannot move it, deliberately, so a retry or replay cannot turn a
70
+ recorded success into a failure. The consequence worth stating: two calls
71
+ cannot report two kinds separately. The second is a no-op on what the
72
+ consumer sees, not a correction. `note` is free text and is kept, but nothing
73
+ is driven off it.
74
+
75
+ Covers `OneAddressConfirmStatus`, `onUpdate` in `OneAddressHandlerOptions`,
76
+ `confirmUpdate`, and the README's confirm section.
77
+
78
+ ## [2.2.0] - 2026-09-27
79
+
80
+ A minor rather than a patch, and it started life numbered 2.1.1. The change was
81
+ believed to be README prose alone, for which a patch is right. Diffing the built
82
+ tarball against published 2.1.0 showed an added optional option on an exported
83
+ interface, which is additive and therefore a minor. **A version number is cheap
84
+ until published and permanent after**, so it was corrected before the publish
85
+ rather than explained afterwards.
86
+
87
+ ### Added
88
+
89
+ - **`buildSignedTestWebhook` takes `retentionPeriodDays`.** Optional, defaulting
90
+ to 90 so existing callers are unaffected. Pass your own configured window to
91
+ rehearse the `key_share_expiry` you will actually receive.
92
+
93
+ ### Fixed
94
+
95
+ - **`buildSignedTestWebhook` advertised a `key_share_expiry` the relay does not
96
+ send.** It was hard-coded to `dispatch_at + 90 days`. The relay derives that
97
+ field per recipient from the retention window the recipient chooses themselves
98
+ (14 to 365 days, on the portal's Data Retention card), so the helper taught
99
+ every handler tested against it that the horizon is a constant. A handler built
100
+ on that assumption passes its own tests and then mis-handles its own 14-day
101
+ window against a real dispatch. The helper now computes the field from the same
102
+ resolver the relay uses.
103
+
104
+ ### Documentation
105
+
106
+ - **Recipient obligation 2 restated to say what a recipient may do, not only what
107
+ OneAddress will not do.** It reads as a permission to destroy the
108
+ `session_key_share` on or after `key_share_expiry`, states that the date on the
109
+ dispatch you received is the one that binds you and is not extended later, and
110
+ says a reconstruction request should be treated as something that may or may not
111
+ still be possible by then rather than as something the date guarantees.
112
+ - **The guarantee table's declaration row scoped to contact kinds.** It said a
113
+ kind you did not declare is refused; that is true of `phone` and `email` and not
114
+ of `address`, which is not declinable. Stated explicitly beside the table.
115
+
10
116
  ## [2.1.0] - 2026-09-20
11
117
 
12
- Unpublished as at this entry, and **still unpublished on 25 Sep 2026**, when the
13
- dispatch-simulator correction below was folded into it rather than given a
14
- version of its own — a version number is cheap until published and permanent
118
+ **PUBLISHED 2026-09-26, registry timestamp `2026-09-26T02:09:11.018Z`.** This
119
+ paragraph said "unpublished as at this entry, and still unpublished on 25 Sep
120
+ 2026" until 27 Sep, which is the shape a version entry rots into: the statement
121
+ was true when written and nothing brings it back for a second look. The
122
+ dispatch-simulator correction below was folded into this version rather than given
123
+ one of its own — a version number is cheap until published and permanent
15
124
  after, so work accumulates into the unpublished one.
16
125
 
17
126
  A minor version: every change is additive or tightens a check that was
package/README.md CHANGED
@@ -154,7 +154,7 @@ What the handler guarantees:
154
154
  | Situation | Response | `onUpdate` |
155
155
  |---|---|---|
156
156
  | Every kind in the envelope is declared | `200 { ok: true, accepted_update_types }` | runs |
157
- | A kind you did not declare | `422 update_type_not_accepted` | never runs |
157
+ | A **contact** kind you did not declare | `422 update_type_not_accepted` | never runs |
158
158
  | A kind name this SDK build does not know | `422 invalid_update_types` | never runs |
159
159
  | `contact.updated` without a session envelope | `400 missing_session_envelope` | never runs |
160
160
 
@@ -166,8 +166,20 @@ What the handler guarantees:
166
166
  September 2026 has one, and if you declare nothing you will never see the
167
167
  absent case, but TypeScript will ask you to narrow: bind it to a local and
168
168
  check it, or test it with `if` as the example does.
169
+ - **`address` is not declinable, and it is the one kind the row above does not
170
+ cover.** Whatever you pass, `address` is forced into `acceptedUpdateTypes`, so
171
+ writing `['phone']` declares *and enforces* `['address', 'phone']`: an address
172
+ dispatch reaches `onUpdate` rather than being refused, and the
173
+ `accepted_update_types` on your acknowledgement says `['address', 'phone']`.
174
+ The portal side matches: a consent set without `address` is refused there with
175
+ a 400, and a database constraint backs that up. Every OneAddress partner
176
+ receives addresses; the declaration decides which **contact** kinds ride with
177
+ them. If you do not want addresses, the thing you are asking for is to be
178
+ deactivated, which is a separate control.
169
179
  - **`update_types` is literal.** `['phone']` means the phone number changed and
170
- nothing else. It is never widened to include `address`.
180
+ nothing else. It is never widened to include `address`. This is the envelope's
181
+ own field and is the opposite direction from the point above: your DECLARATION
182
+ always contains `address`, a DISPATCH says only what actually changed.
171
183
  - **Refusal is deliberate.** Acknowledging a kind you cannot store would look
172
184
  identical to success on both sides while the consumer has already paid. The
173
185
  422 leaves the dispatch incomplete in your idempotency store, so once you
@@ -260,7 +272,7 @@ Under D5 your `partner_keys` registry holds your **active** key plus zero-or-mor
260
272
  **Your contractual obligations:**
261
273
 
262
274
  1. **Retain** the private key for any `key_id` whose paired public key has a `destroy_after` date in the future. You may destroy the private key on or after `destroy_after` — the corresponding session ciphertext on OneAddress's side has been purged by then.
263
- 2. **Retain** the `session_key_share` object alongside the update record until `key_share_expiry`. After that date OneAddress will not request reconstruction.
275
+ 2. **Retain** the `session_key_share` object alongside the update record until `key_share_expiry`, and **you may destroy it on or after that date**. OneAddress will not request reconstruction beyond it. The date on the dispatch you received is the one that binds you; it is not extended later. Treat a reconstruction request as something that may or may not still be possible by then, never as something the date guarantees.
264
276
  3. **Cooperate** in good faith with OneAddress reconstruction requests for in-window envelopes citing a legitimate `reason_code` — by decrypting the relevant share and returning SK<sub>n</sub> over the mutually-authenticated reconstruction channel.
265
277
 
266
278
  See the partner portal documentation at partners.oneaddress.io for the full integration spec.
@@ -406,6 +418,16 @@ if (!res.ok) console.error('[oneaddress] confirm failed', res.status, res.error)
406
418
 
407
419
  The last two cost different people money. `failed` for a stranger bills a refund against a receiver that behaved correctly; `no_match` during a real outage tells a genuine customer to fix an account number that was never wrong. **If you cannot tell the two apart, send `failed`**, which is the one that is safe to be wrong about.
408
420
 
421
+ ### One status per delivery, not per kind
422
+
423
+ A dispatch can carry an address together with a new phone number or email address, and this status covers all of it. None of the four values can say you applied one kind and not another, so a partial application cannot be reported and cannot be detected from our side.
424
+
425
+ **Write every kind in `event.update_types` in the same unit of work**, so they succeed or fail together. If your system cannot do that for a kind, stop accepting that kind under **My Profile** in the partner portal rather than applying it best-effort. Refusing is honest and visible: we never send it, and the consumer is told. A partial application is neither — it reads to the consumer as a complete one.
426
+
427
+ **The first confirmation for a dispatch is the one that counts.** All four statuses resolve to a terminal record, and a later confirm for the same `dispatchId` cannot move it. That guard is deliberate, so a retry or a replay cannot turn a recorded success into a failure — but it also means two calls cannot report two kinds separately. The second is a no-op on what the consumer sees, not a correction.
428
+
429
+ `note` is free text and is kept, so it can say what did not apply. Nothing is driven off it: the consumer's dashboard reads the status alone.
430
+
409
431
  ### Which secret
410
432
 
411
433
  If you have minted a **confirm secret** in the Partner Portal, use that one — once it exists it is the only secret `/api/confirm` accepts, so that a leaked webhook secret cannot forge confirmations. If you have not, use your webhook signing secret. The same secret authenticates the request and signs the body.
@@ -3178,6 +3178,19 @@ function isSafeWebhookUrl(url, opts2 = {}) {
3178
3178
  return { ok: true };
3179
3179
  }
3180
3180
 
3181
+ // ../crypto/src/blocked-public-keys.ts
3182
+ var BLOCKED_PUBLIC_KEYS_B64 = /* @__PURE__ */ new Set([
3183
+ // @oneaddress/conformance → TEST_PARTNER_PUBLIC_KEY_SPKI_B64.
3184
+ // Its TEST_PARTNER_PRIVATE_KEY_PEM ships in the same file, published on npm.
3185
+ "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqFmYg3ct73DoAR3WHO5pUr/bVtaKUlLb9bd+g0KwJGZkgUhGop6JhSzQZw08zuvLbvkJXZnz0BHfsXy4MfeTjg=="
3186
+ ]);
3187
+ function normalise(publicKeyB64) {
3188
+ return (publicKeyB64 ?? "").replace(/\s+/g, "");
3189
+ }
3190
+ function blockedPublicKeyReason(publicKeyB64) {
3191
+ return BLOCKED_PUBLIC_KEYS_B64.has(normalise(publicKeyB64)) ? "published_test_key" : null;
3192
+ }
3193
+
3181
3194
  // ../crypto/src/endpoint-health.ts
3182
3195
  var ENDPOINT_FAILURE_THRESHOLD = 3;
3183
3196
  var MISSING_STATUSES = /* @__PURE__ */ new Set([404, 405, 410]);
@@ -4414,6 +4427,7 @@ export {
4414
4427
  isFreshTimestamp,
4415
4428
  isIpLiteralHost,
4416
4429
  isSafeWebhookUrl,
4430
+ blockedPublicKeyReason,
4417
4431
  ENDPOINT_FAILURE_THRESHOLD,
4418
4432
  classifyEndpointProbe,
4419
4433
  countsAsFailure,
@@ -3,7 +3,7 @@ import {
3
3
  encryptSessionForPartner,
4
4
  isFreshTimestamp,
5
5
  isSafeWebhookUrl
6
- } from "./chunk-LIHXDUUA.mjs";
6
+ } from "./chunk-FDMB4BNC.mjs";
7
7
 
8
8
  // src/index.ts
9
9
  import crypto from "crypto";
@@ -51,6 +51,24 @@ var D5_BODY_ALL_ALLOWED = [
51
51
  ...D5_BODY_DRILL_ONLY
52
52
  ];
53
53
 
54
+ // ../protocol/src/retention.ts
55
+ var MIN_RETENTION_DAYS = 14;
56
+ var MAX_RETENTION_DAYS = 365;
57
+ var DEFAULT_RETENTION_DAYS = 90;
58
+ function resolveRetentionDays(retentionPeriodDays) {
59
+ if (typeof retentionPeriodDays !== "number" || !Number.isFinite(retentionPeriodDays)) {
60
+ return DEFAULT_RETENTION_DAYS;
61
+ }
62
+ const days = Math.trunc(retentionPeriodDays);
63
+ if (days < MIN_RETENTION_DAYS || days > MAX_RETENTION_DAYS) return DEFAULT_RETENTION_DAYS;
64
+ return days;
65
+ }
66
+ var DAY_MS = 24 * 60 * 60 * 1e3;
67
+ function keyShareExpiryIso(dispatchAt, retentionPeriodDays) {
68
+ const days = resolveRetentionDays(retentionPeriodDays);
69
+ return new Date(dispatchAt.getTime() + days * DAY_MS).toISOString();
70
+ }
71
+
54
72
  // ../name-match/src/index.ts
55
73
  function isEmailLike(value) {
56
74
  return value.includes("@");
@@ -483,7 +501,7 @@ async function decryptAddress(payload, privateKeyPem, partnerId) {
483
501
  return JSON.parse(new TextDecoder().decode(plaintext));
484
502
  }
485
503
  async function decryptSession(share, envelopeB64, privateKeyPem, partnerId, expectedAlg) {
486
- const { decryptSession: decryptSessionCrypto } = await import("./src-ENJJ6YZU.mjs");
504
+ const { decryptSession: decryptSessionCrypto } = await import("./src-SNMMZ4BT.mjs");
487
505
  return decryptSessionCrypto(
488
506
  share,
489
507
  envelopeB64,
@@ -1507,7 +1525,8 @@ async function buildSignedTestWebhook(opts) {
1507
1525
  timestamp: nowIso,
1508
1526
  session_envelope: envelope.session_envelope,
1509
1527
  session_key_share: envelope.session_key_share,
1510
- key_share_expiry: new Date((nowSecs + 90 * 24 * 3600) * 1e3).toISOString(),
1528
+ // Per RECIPIENT, from the same resolver the relay uses, not a constant.
1529
+ key_share_expiry: keyShareExpiryIso(new Date(nowSecs * 1e3), opts.retentionPeriodDays),
1511
1530
  id_verification: { method: "identity_document", verified_at: nowIso, verified: true, platform: "oneaddress/v1" },
1512
1531
  ...loa_encrypted ? { loa_encrypted } : {},
1513
1532
  // On the wire with a `null` value when no PaymentIntent backed the update,
package/dist/edge.js CHANGED
@@ -3364,6 +3364,25 @@ var init_safe_url = __esm({
3364
3364
  }
3365
3365
  });
3366
3366
 
3367
+ // ../crypto/src/blocked-public-keys.ts
3368
+ function normalise(publicKeyB64) {
3369
+ return (publicKeyB64 ?? "").replace(/\s+/g, "");
3370
+ }
3371
+ function blockedPublicKeyReason(publicKeyB64) {
3372
+ return BLOCKED_PUBLIC_KEYS_B64.has(normalise(publicKeyB64)) ? "published_test_key" : null;
3373
+ }
3374
+ var BLOCKED_PUBLIC_KEYS_B64;
3375
+ var init_blocked_public_keys = __esm({
3376
+ "../crypto/src/blocked-public-keys.ts"() {
3377
+ "use strict";
3378
+ BLOCKED_PUBLIC_KEYS_B64 = /* @__PURE__ */ new Set([
3379
+ // @oneaddress/conformance → TEST_PARTNER_PUBLIC_KEY_SPKI_B64.
3380
+ // Its TEST_PARTNER_PRIVATE_KEY_PEM ships in the same file, published on npm.
3381
+ "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqFmYg3ct73DoAR3WHO5pUr/bVtaKUlLb9bd+g0KwJGZkgUhGop6JhSzQZw08zuvLbvkJXZnz0BHfsXy4MfeTjg=="
3382
+ ]);
3383
+ }
3384
+ });
3385
+
3367
3386
  // ../crypto/src/endpoint-health.ts
3368
3387
  function classifyEndpointProbe(input) {
3369
3388
  const status = typeof input.httpStatus === "number" && Number.isFinite(input.httpStatus) ? input.httpStatus : null;
@@ -3991,6 +4010,7 @@ __export(src_exports, {
3991
4010
  REGISTRY_HEAD_V1: () => REGISTRY_HEAD_V1,
3992
4011
  REGISTRY_HEAD_V2: () => REGISTRY_HEAD_V2,
3993
4012
  SENDER_HELD_KEY_ALGORITHM: () => SENDER_HELD_KEY_ALGORITHM,
4013
+ blockedPublicKeyReason: () => blockedPublicKeyReason,
3994
4014
  buildPartnerKeyAttestation: () => buildPartnerKeyAttestation,
3995
4015
  buildRegistryHeadStatement: () => buildRegistryHeadStatement,
3996
4016
  classifyEndpointProbe: () => classifyEndpointProbe,
@@ -4653,6 +4673,7 @@ var init_src = __esm({
4653
4673
  init_hybrid();
4654
4674
  init_replay_window();
4655
4675
  init_safe_url();
4676
+ init_blocked_public_keys();
4656
4677
  init_endpoint_health();
4657
4678
  init_partner_key_attestation();
4658
4679
  init_registry_head();
@@ -4771,6 +4792,9 @@ var D5_BODY_ALL_ALLOWED = [
4771
4792
  ...D5_BODY_DRILL_ONLY
4772
4793
  ];
4773
4794
 
4795
+ // ../protocol/src/retention.ts
4796
+ var DAY_MS = 24 * 60 * 60 * 1e3;
4797
+
4774
4798
  // src/index.ts
4775
4799
  init_src();
4776
4800
  init_src();
package/dist/edge.mjs CHANGED
@@ -20,13 +20,13 @@ import {
20
20
  verifyLOA,
21
21
  verifySignature,
22
22
  verifyWithGrace
23
- } from "./chunk-P55E2BQT.mjs";
23
+ } from "./chunk-VGE5OE4D.mjs";
24
24
  import {
25
25
  DEFAULT_REPLAY_WINDOW_SECS,
26
26
  computeBlindIndex,
27
27
  isFreshTimestamp,
28
28
  normalizeForBlindIndex
29
- } from "./chunk-LIHXDUUA.mjs";
29
+ } from "./chunk-FDMB4BNC.mjs";
30
30
  export {
31
31
  CURRENT_VERSION,
32
32
  DEFAULT_REPLAY_WINDOW_SECS,
package/dist/index.d.mts CHANGED
@@ -393,6 +393,26 @@ declare function createOutboxConsumer(opts: OutboxConsumerOptions): OutboxConsum
393
393
  * number that was never wrong. **When you cannot tell the two apart, send
394
394
  * `failed`** - it is the one that is safe to be wrong about, because the
395
395
  * retry either clears it or the refund makes the consumer whole.
396
+ *
397
+ * ## ONE STATUS PER DELIVERY, NOT PER KIND
398
+ *
399
+ * A dispatch can carry an address together with a new phone number or email
400
+ * address (see `update_types` on {@link OneAddressUpdateEvent}), and this
401
+ * status covers the whole delivery. None of the four values can say you
402
+ * applied one kind and not another, so there is no way to report a partial
403
+ * application and no way for OneAddress to detect one.
404
+ *
405
+ * Write every kind named in `update_types` in the SAME unit of work, so they
406
+ * succeed or fail together. If your system cannot do that for a kind, stop
407
+ * accepting that kind (My Profile in the partner portal) rather than applying
408
+ * it on a best-effort basis. Refusing it is honest and visible: OneAddress
409
+ * never sends it and tells the consumer so. A partial application is neither -
410
+ * it reads to the consumer as a complete one, and neither side can tell the
411
+ * two apart.
412
+ *
413
+ * If you need to record that something did not apply, `note` on
414
+ * {@link confirmUpdate} is free text and is kept, but nothing is driven off
415
+ * it: the consumer's dashboard reads the status alone.
396
416
  */
397
417
  type OneAddressConfirmStatus = 'confirmed' | 'already_current' | 'failed' | 'no_match';
398
418
  interface OneAddressAddress {
@@ -417,16 +437,20 @@ interface OneAddressCustomer {
417
437
  known_names: string[];
418
438
  }
419
439
  /**
420
- * Blind-index match block — present INSTEAD of the cleartext `customer` block
421
- * for partners who enabled blind-index matching in the portal. Each value is
422
- * `base64url( HMAC-SHA256(yourBlindIndexSecret, normalize(field)) )`.
423
- *
424
- * Match a record by recomputing the same blind index over your own stored
425
- * fields (with {@link computeBlindIndex} and your shared secret) and comparing
426
- * for equality — no plaintext name/email/account crosses the wire and you do
427
- * not need to decrypt the envelope to locate the record. The decrypted
428
- * `SessionData` still carries the verified name + account number once you do
429
- * decrypt.
440
+ * @deprecated NO DISPATCH CARRIES THIS BLOCK.
441
+ *
442
+ * It described a matching shape where each value was
443
+ * `base64url( HMAC-SHA256(yourBlindIndexSecret, normalize(field)) )`, so a
444
+ * receiver could locate a record WITHOUT decrypting the envelope. That shape
445
+ * is gone: `customer_match` is refused by the body contract, and the portal
446
+ * control that enabled it has been removed.
447
+ *
448
+ * Nothing about the consumer is knowable before decryption. Decrypt
449
+ * `session_envelope` and match on the verified name, known names or account
450
+ * number in the resulting `SessionData`.
451
+ *
452
+ * The type is retained so an existing import compiles; it will go in the next
453
+ * major.
430
454
  */
431
455
  interface OneAddressCustomerMatch {
432
456
  /** Blind index of the consumer's email, when present. */
@@ -573,12 +597,17 @@ interface OneAddressVerifyEvent {
573
597
  dispatchId: string;
574
598
  batch_id: number;
575
599
  user_id: string;
576
- /** Cleartext matching block. Present by default; ABSENT for partners who
577
- * enabled blind-index matching (see `customer_match`). Exactly one of
578
- * `customer` / `customer_match` is present on any given dispatch. */
600
+ /** @deprecated NOT SENT. `customer` is in the body contract's refused list
601
+ * (`D5_BODY_NEVER`), so a body carrying one fails the shape check. Nothing
602
+ * about the consumer travels outside the encrypted envelope, so there is no
603
+ * cleartext matching block to read: decrypt
604
+ * `session_envelope` and match on the verified name, known names or account
605
+ * number it carries. Kept optional so an existing narrowing check still
606
+ * compiles; it will never be populated. */
579
607
  customer?: OneAddressCustomer;
580
- /** Blind-index matching block — present instead of `customer` for blind-index
581
- * partners. See {@link OneAddressCustomerMatch}. */
608
+ /** @deprecated NOT SENT, and likewise refused by the body contract. See
609
+ * {@link OneAddressCustomerMatch}. Neither this nor `customer` is present:
610
+ * the earlier "exactly one of" described a shape that no longer exists. */
582
611
  customer_match?: OneAddressCustomerMatch;
583
612
  address: OneAddressAddress;
584
613
  /** The Letter of Authority. On D5 dispatches this is the structured
@@ -834,6 +863,12 @@ interface OneAddressHandlerOptions {
834
863
  * The status is a union rather than a bare `string`: `/api/confirm` rejects
835
864
  * anything outside the four with a 400, and a typo used to surface as an
836
865
  * unexplained rejection at runtime instead of a compile error.
866
+ *
867
+ * ONE STATUS COVERS THE WHOLE DELIVERY. If `event.update_types` names more
868
+ * than one kind, this single value speaks for all of them: there is no way
869
+ * to say the address went in and the phone number did not. Write every kind
870
+ * it names in one unit of work, or stop accepting that kind. See
871
+ * {@link OneAddressConfirmStatus}.
837
872
  */
838
873
  onUpdate: (event: OneAddressUpdateEvent) => Promise<{
839
874
  status?: OneAddressConfirmStatus;
@@ -1472,6 +1507,23 @@ interface ConfirmUpdateResult {
1472
1507
  * something your code can see and log; an exception in a fire-and-forget
1473
1508
  * `.catch()` is how a dropped confirmation stays invisible.
1474
1509
  *
1510
+ * ## One call per dispatch, and one status for everything in it
1511
+ *
1512
+ * `dispatchId` identifies a DELIVERY, not a kind of detail. A delivery that
1513
+ * carried an address and a new phone number is confirmed once, with one
1514
+ * status covering both.
1515
+ *
1516
+ * **The FIRST confirmation for a dispatch is the one that counts.** Every one
1517
+ * of the four statuses resolves to a terminal record, and a later confirm for
1518
+ * the same `dispatchId` cannot move it - that guard is deliberate, so a retry
1519
+ * or a replay cannot turn a recorded success into a failure. It also means you
1520
+ * cannot send two calls to report two kinds separately: the second is a no-op
1521
+ * on what the consumer is shown, not a correction.
1522
+ *
1523
+ * So make one call, with a status that is true of the whole delivery. See
1524
+ * {@link OneAddressConfirmStatus} for what to do when your system cannot
1525
+ * apply every kind atomically.
1526
+ *
1475
1527
  * @example
1476
1528
  * const res = await confirmUpdate({
1477
1529
  * partnerId: process.env.OA_PARTNER_ID!,
@@ -1907,6 +1959,22 @@ interface SignedTestWebhookOptions {
1907
1959
  * `body.stripe_session_id != null`.
1908
1960
  */
1909
1961
  stripeSessionId?: string | null;
1962
+ /**
1963
+ * The retention window to advertise as `key_share_expiry`, in days.
1964
+ *
1965
+ * Defaults to 90, which is the default of `partners.retention_period_days` and
1966
+ * therefore what an unconfigured recipient really receives. The relay derives
1967
+ * this PER RECIPIENT from that column (14 to 365, chosen by the recipient on
1968
+ * the portal's Data Retention card), so it is not a constant on the wire and a
1969
+ * handler must not treat it as one.
1970
+ *
1971
+ * Pass your OWN configured window to rehearse the horizon you will actually
1972
+ * get. Worth doing rather than skipping: a handler that hard-codes "the expiry
1973
+ * is 90 days out" passes against this helper's default and then mis-handles its
1974
+ * own 14-day window in production, which is the same class of mistake as
1975
+ * assuming the body always carries an `id`.
1976
+ */
1977
+ retentionPeriodDays?: number | null;
1910
1978
  /**
1911
1979
  * Extra top-level body fields, merged last.
1912
1980
  *
package/dist/index.d.ts CHANGED
@@ -393,6 +393,26 @@ declare function createOutboxConsumer(opts: OutboxConsumerOptions): OutboxConsum
393
393
  * number that was never wrong. **When you cannot tell the two apart, send
394
394
  * `failed`** - it is the one that is safe to be wrong about, because the
395
395
  * retry either clears it or the refund makes the consumer whole.
396
+ *
397
+ * ## ONE STATUS PER DELIVERY, NOT PER KIND
398
+ *
399
+ * A dispatch can carry an address together with a new phone number or email
400
+ * address (see `update_types` on {@link OneAddressUpdateEvent}), and this
401
+ * status covers the whole delivery. None of the four values can say you
402
+ * applied one kind and not another, so there is no way to report a partial
403
+ * application and no way for OneAddress to detect one.
404
+ *
405
+ * Write every kind named in `update_types` in the SAME unit of work, so they
406
+ * succeed or fail together. If your system cannot do that for a kind, stop
407
+ * accepting that kind (My Profile in the partner portal) rather than applying
408
+ * it on a best-effort basis. Refusing it is honest and visible: OneAddress
409
+ * never sends it and tells the consumer so. A partial application is neither -
410
+ * it reads to the consumer as a complete one, and neither side can tell the
411
+ * two apart.
412
+ *
413
+ * If you need to record that something did not apply, `note` on
414
+ * {@link confirmUpdate} is free text and is kept, but nothing is driven off
415
+ * it: the consumer's dashboard reads the status alone.
396
416
  */
397
417
  type OneAddressConfirmStatus = 'confirmed' | 'already_current' | 'failed' | 'no_match';
398
418
  interface OneAddressAddress {
@@ -417,16 +437,20 @@ interface OneAddressCustomer {
417
437
  known_names: string[];
418
438
  }
419
439
  /**
420
- * Blind-index match block — present INSTEAD of the cleartext `customer` block
421
- * for partners who enabled blind-index matching in the portal. Each value is
422
- * `base64url( HMAC-SHA256(yourBlindIndexSecret, normalize(field)) )`.
423
- *
424
- * Match a record by recomputing the same blind index over your own stored
425
- * fields (with {@link computeBlindIndex} and your shared secret) and comparing
426
- * for equality — no plaintext name/email/account crosses the wire and you do
427
- * not need to decrypt the envelope to locate the record. The decrypted
428
- * `SessionData` still carries the verified name + account number once you do
429
- * decrypt.
440
+ * @deprecated NO DISPATCH CARRIES THIS BLOCK.
441
+ *
442
+ * It described a matching shape where each value was
443
+ * `base64url( HMAC-SHA256(yourBlindIndexSecret, normalize(field)) )`, so a
444
+ * receiver could locate a record WITHOUT decrypting the envelope. That shape
445
+ * is gone: `customer_match` is refused by the body contract, and the portal
446
+ * control that enabled it has been removed.
447
+ *
448
+ * Nothing about the consumer is knowable before decryption. Decrypt
449
+ * `session_envelope` and match on the verified name, known names or account
450
+ * number in the resulting `SessionData`.
451
+ *
452
+ * The type is retained so an existing import compiles; it will go in the next
453
+ * major.
430
454
  */
431
455
  interface OneAddressCustomerMatch {
432
456
  /** Blind index of the consumer's email, when present. */
@@ -573,12 +597,17 @@ interface OneAddressVerifyEvent {
573
597
  dispatchId: string;
574
598
  batch_id: number;
575
599
  user_id: string;
576
- /** Cleartext matching block. Present by default; ABSENT for partners who
577
- * enabled blind-index matching (see `customer_match`). Exactly one of
578
- * `customer` / `customer_match` is present on any given dispatch. */
600
+ /** @deprecated NOT SENT. `customer` is in the body contract's refused list
601
+ * (`D5_BODY_NEVER`), so a body carrying one fails the shape check. Nothing
602
+ * about the consumer travels outside the encrypted envelope, so there is no
603
+ * cleartext matching block to read: decrypt
604
+ * `session_envelope` and match on the verified name, known names or account
605
+ * number it carries. Kept optional so an existing narrowing check still
606
+ * compiles; it will never be populated. */
579
607
  customer?: OneAddressCustomer;
580
- /** Blind-index matching block — present instead of `customer` for blind-index
581
- * partners. See {@link OneAddressCustomerMatch}. */
608
+ /** @deprecated NOT SENT, and likewise refused by the body contract. See
609
+ * {@link OneAddressCustomerMatch}. Neither this nor `customer` is present:
610
+ * the earlier "exactly one of" described a shape that no longer exists. */
582
611
  customer_match?: OneAddressCustomerMatch;
583
612
  address: OneAddressAddress;
584
613
  /** The Letter of Authority. On D5 dispatches this is the structured
@@ -834,6 +863,12 @@ interface OneAddressHandlerOptions {
834
863
  * The status is a union rather than a bare `string`: `/api/confirm` rejects
835
864
  * anything outside the four with a 400, and a typo used to surface as an
836
865
  * unexplained rejection at runtime instead of a compile error.
866
+ *
867
+ * ONE STATUS COVERS THE WHOLE DELIVERY. If `event.update_types` names more
868
+ * than one kind, this single value speaks for all of them: there is no way
869
+ * to say the address went in and the phone number did not. Write every kind
870
+ * it names in one unit of work, or stop accepting that kind. See
871
+ * {@link OneAddressConfirmStatus}.
837
872
  */
838
873
  onUpdate: (event: OneAddressUpdateEvent) => Promise<{
839
874
  status?: OneAddressConfirmStatus;
@@ -1472,6 +1507,23 @@ interface ConfirmUpdateResult {
1472
1507
  * something your code can see and log; an exception in a fire-and-forget
1473
1508
  * `.catch()` is how a dropped confirmation stays invisible.
1474
1509
  *
1510
+ * ## One call per dispatch, and one status for everything in it
1511
+ *
1512
+ * `dispatchId` identifies a DELIVERY, not a kind of detail. A delivery that
1513
+ * carried an address and a new phone number is confirmed once, with one
1514
+ * status covering both.
1515
+ *
1516
+ * **The FIRST confirmation for a dispatch is the one that counts.** Every one
1517
+ * of the four statuses resolves to a terminal record, and a later confirm for
1518
+ * the same `dispatchId` cannot move it - that guard is deliberate, so a retry
1519
+ * or a replay cannot turn a recorded success into a failure. It also means you
1520
+ * cannot send two calls to report two kinds separately: the second is a no-op
1521
+ * on what the consumer is shown, not a correction.
1522
+ *
1523
+ * So make one call, with a status that is true of the whole delivery. See
1524
+ * {@link OneAddressConfirmStatus} for what to do when your system cannot
1525
+ * apply every kind atomically.
1526
+ *
1475
1527
  * @example
1476
1528
  * const res = await confirmUpdate({
1477
1529
  * partnerId: process.env.OA_PARTNER_ID!,
@@ -1907,6 +1959,22 @@ interface SignedTestWebhookOptions {
1907
1959
  * `body.stripe_session_id != null`.
1908
1960
  */
1909
1961
  stripeSessionId?: string | null;
1962
+ /**
1963
+ * The retention window to advertise as `key_share_expiry`, in days.
1964
+ *
1965
+ * Defaults to 90, which is the default of `partners.retention_period_days` and
1966
+ * therefore what an unconfigured recipient really receives. The relay derives
1967
+ * this PER RECIPIENT from that column (14 to 365, chosen by the recipient on
1968
+ * the portal's Data Retention card), so it is not a constant on the wire and a
1969
+ * handler must not treat it as one.
1970
+ *
1971
+ * Pass your OWN configured window to rehearse the horizon you will actually
1972
+ * get. Worth doing rather than skipping: a handler that hard-codes "the expiry
1973
+ * is 90 days out" passes against this helper's default and then mis-handles its
1974
+ * own 14-day window in production, which is the same class of mistake as
1975
+ * assuming the body always carries an `id`.
1976
+ */
1977
+ retentionPeriodDays?: number | null;
1910
1978
  /**
1911
1979
  * Extra top-level body fields, merged last.
1912
1980
  *
package/dist/index.js CHANGED
@@ -3364,6 +3364,25 @@ var init_safe_url = __esm({
3364
3364
  }
3365
3365
  });
3366
3366
 
3367
+ // ../crypto/src/blocked-public-keys.ts
3368
+ function normalise(publicKeyB64) {
3369
+ return (publicKeyB64 ?? "").replace(/\s+/g, "");
3370
+ }
3371
+ function blockedPublicKeyReason(publicKeyB64) {
3372
+ return BLOCKED_PUBLIC_KEYS_B64.has(normalise(publicKeyB64)) ? "published_test_key" : null;
3373
+ }
3374
+ var BLOCKED_PUBLIC_KEYS_B64;
3375
+ var init_blocked_public_keys = __esm({
3376
+ "../crypto/src/blocked-public-keys.ts"() {
3377
+ "use strict";
3378
+ BLOCKED_PUBLIC_KEYS_B64 = /* @__PURE__ */ new Set([
3379
+ // @oneaddress/conformance → TEST_PARTNER_PUBLIC_KEY_SPKI_B64.
3380
+ // Its TEST_PARTNER_PRIVATE_KEY_PEM ships in the same file, published on npm.
3381
+ "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqFmYg3ct73DoAR3WHO5pUr/bVtaKUlLb9bd+g0KwJGZkgUhGop6JhSzQZw08zuvLbvkJXZnz0BHfsXy4MfeTjg=="
3382
+ ]);
3383
+ }
3384
+ });
3385
+
3367
3386
  // ../crypto/src/endpoint-health.ts
3368
3387
  function classifyEndpointProbe(input) {
3369
3388
  const status = typeof input.httpStatus === "number" && Number.isFinite(input.httpStatus) ? input.httpStatus : null;
@@ -3991,6 +4010,7 @@ __export(src_exports, {
3991
4010
  REGISTRY_HEAD_V1: () => REGISTRY_HEAD_V1,
3992
4011
  REGISTRY_HEAD_V2: () => REGISTRY_HEAD_V2,
3993
4012
  SENDER_HELD_KEY_ALGORITHM: () => SENDER_HELD_KEY_ALGORITHM,
4013
+ blockedPublicKeyReason: () => blockedPublicKeyReason,
3994
4014
  buildPartnerKeyAttestation: () => buildPartnerKeyAttestation,
3995
4015
  buildRegistryHeadStatement: () => buildRegistryHeadStatement,
3996
4016
  classifyEndpointProbe: () => classifyEndpointProbe,
@@ -4653,6 +4673,7 @@ var init_src = __esm({
4653
4673
  init_hybrid();
4654
4674
  init_replay_window();
4655
4675
  init_safe_url();
4676
+ init_blocked_public_keys();
4656
4677
  init_endpoint_health();
4657
4678
  init_partner_key_attestation();
4658
4679
  init_registry_head();
@@ -4784,6 +4805,24 @@ var D5_BODY_ALL_ALLOWED = [
4784
4805
  ...D5_BODY_DRILL_ONLY
4785
4806
  ];
4786
4807
 
4808
+ // ../protocol/src/retention.ts
4809
+ var MIN_RETENTION_DAYS = 14;
4810
+ var MAX_RETENTION_DAYS = 365;
4811
+ var DEFAULT_RETENTION_DAYS = 90;
4812
+ function resolveRetentionDays(retentionPeriodDays) {
4813
+ if (typeof retentionPeriodDays !== "number" || !Number.isFinite(retentionPeriodDays)) {
4814
+ return DEFAULT_RETENTION_DAYS;
4815
+ }
4816
+ const days = Math.trunc(retentionPeriodDays);
4817
+ if (days < MIN_RETENTION_DAYS || days > MAX_RETENTION_DAYS) return DEFAULT_RETENTION_DAYS;
4818
+ return days;
4819
+ }
4820
+ var DAY_MS = 24 * 60 * 60 * 1e3;
4821
+ function keyShareExpiryIso(dispatchAt, retentionPeriodDays) {
4822
+ const days = resolveRetentionDays(retentionPeriodDays);
4823
+ return new Date(dispatchAt.getTime() + days * DAY_MS).toISOString();
4824
+ }
4825
+
4787
4826
  // src/index.ts
4788
4827
  init_src();
4789
4828
  init_src();
@@ -6244,7 +6283,8 @@ async function buildSignedTestWebhook(opts2) {
6244
6283
  timestamp: nowIso,
6245
6284
  session_envelope: envelope.session_envelope,
6246
6285
  session_key_share: envelope.session_key_share,
6247
- key_share_expiry: new Date((nowSecs + 90 * 24 * 3600) * 1e3).toISOString(),
6286
+ // Per RECIPIENT, from the same resolver the relay uses, not a constant.
6287
+ key_share_expiry: keyShareExpiryIso(new Date(nowSecs * 1e3), opts2.retentionPeriodDays),
6248
6288
  id_verification: { method: "identity_document", verified_at: nowIso, verified: true, platform: "oneaddress/v1" },
6249
6289
  ...loa_encrypted ? { loa_encrypted } : {},
6250
6290
  // On the wire with a `null` value when no PaymentIntent backed the update,
package/dist/index.mjs CHANGED
@@ -31,13 +31,13 @@ import {
31
31
  verifyLOA,
32
32
  verifySignature,
33
33
  verifyWithGrace
34
- } from "./chunk-P55E2BQT.mjs";
34
+ } from "./chunk-VGE5OE4D.mjs";
35
35
  import {
36
36
  DEFAULT_REPLAY_WINDOW_SECS,
37
37
  computeBlindIndex,
38
38
  isFreshTimestamp,
39
39
  normalizeForBlindIndex
40
- } from "./chunk-LIHXDUUA.mjs";
40
+ } from "./chunk-FDMB4BNC.mjs";
41
41
  export {
42
42
  CURRENT_VERSION,
43
43
  DEFAULT_REPLAY_WINDOW_SECS,
@@ -8,6 +8,7 @@ import {
8
8
  REGISTRY_HEAD_V1,
9
9
  REGISTRY_HEAD_V2,
10
10
  SENDER_HELD_KEY_ALGORITHM,
11
+ blockedPublicKeyReason,
11
12
  buildPartnerKeyAttestation,
12
13
  buildRegistryHeadStatement,
13
14
  classifyEndpointProbe,
@@ -47,7 +48,7 @@ import {
47
48
  verifyPartnerKeyAttestationWithRoots,
48
49
  verifyRegistryHead,
49
50
  verifyWebhookSignature
50
- } from "./chunk-LIHXDUUA.mjs";
51
+ } from "./chunk-FDMB4BNC.mjs";
51
52
  export {
52
53
  DEFAULT_REPLAY_WINDOW_SECS,
53
54
  ENDPOINT_FAILURE_THRESHOLD,
@@ -58,6 +59,7 @@ export {
58
59
  REGISTRY_HEAD_V1,
59
60
  REGISTRY_HEAD_V2,
60
61
  SENDER_HELD_KEY_ALGORITHM,
62
+ blockedPublicKeyReason,
61
63
  buildPartnerKeyAttestation,
62
64
  buildRegistryHeadStatement,
63
65
  classifyEndpointProbe,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneaddress/partner-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "Official OneAddress partner integration SDK — webhook verification, address decryption (legacy + D5 session-envelope), LOA validation",
5
5
  "repository": {
6
6
  "type": "git",