@oneaddress/partner-sdk 2.1.0 → 2.2.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,52 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.2.0] - 2026-09-27
11
+
12
+ A minor rather than a patch, and it started life numbered 2.1.1. The change was
13
+ believed to be README prose alone, for which a patch is right. Diffing the built
14
+ tarball against published 2.1.0 showed an added optional option on an exported
15
+ interface, which is additive and therefore a minor. **A version number is cheap
16
+ until published and permanent after**, so it was corrected before the publish
17
+ rather than explained afterwards.
18
+
19
+ ### Added
20
+
21
+ - **`buildSignedTestWebhook` takes `retentionPeriodDays`.** Optional, defaulting
22
+ to 90 so existing callers are unaffected. Pass your own configured window to
23
+ rehearse the `key_share_expiry` you will actually receive.
24
+
25
+ ### Fixed
26
+
27
+ - **`buildSignedTestWebhook` advertised a `key_share_expiry` the relay does not
28
+ send.** It was hard-coded to `dispatch_at + 90 days`. The relay derives that
29
+ field per recipient from the retention window the recipient chooses themselves
30
+ (14 to 365 days, on the portal's Data Retention card), so the helper taught
31
+ every handler tested against it that the horizon is a constant. A handler built
32
+ on that assumption passes its own tests and then mis-handles its own 14-day
33
+ window against a real dispatch. The helper now computes the field from the same
34
+ resolver the relay uses.
35
+
36
+ ### Documentation
37
+
38
+ - **Recipient obligation 2 restated to say what a recipient may do, not only what
39
+ OneAddress will not do.** It reads as a permission to destroy the
40
+ `session_key_share` on or after `key_share_expiry`, states that the date on the
41
+ dispatch you received is the one that binds you and is not extended later, and
42
+ says a reconstruction request should be treated as something that may or may not
43
+ still be possible by then rather than as something the date guarantees.
44
+ - **The guarantee table's declaration row scoped to contact kinds.** It said a
45
+ kind you did not declare is refused; that is true of `phone` and `email` and not
46
+ of `address`, which is not declinable. Stated explicitly beside the table.
47
+
10
48
  ## [2.1.0] - 2026-09-20
11
49
 
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
50
+ **PUBLISHED 2026-09-26, registry timestamp `2026-09-26T02:09:11.018Z`.** This
51
+ paragraph said "unpublished as at this entry, and still unpublished on 25 Sep
52
+ 2026" until 27 Sep, which is the shape a version entry rots into: the statement
53
+ was true when written and nothing brings it back for a second look. The
54
+ dispatch-simulator correction below was folded into this version rather than given
55
+ one of its own — a version number is cheap until published and permanent
15
56
  after, so work accumulates into the unpublished one.
16
57
 
17
58
  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.
@@ -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("@");
@@ -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
@@ -4771,6 +4771,9 @@ var D5_BODY_ALL_ALLOWED = [
4771
4771
  ...D5_BODY_DRILL_ONLY
4772
4772
  ];
4773
4773
 
4774
+ // ../protocol/src/retention.ts
4775
+ var DAY_MS = 24 * 60 * 60 * 1e3;
4776
+
4774
4777
  // src/index.ts
4775
4778
  init_src();
4776
4779
  init_src();
package/dist/edge.mjs CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  verifyLOA,
21
21
  verifySignature,
22
22
  verifyWithGrace
23
- } from "./chunk-P55E2BQT.mjs";
23
+ } from "./chunk-PCYKV7RJ.mjs";
24
24
  import {
25
25
  DEFAULT_REPLAY_WINDOW_SECS,
26
26
  computeBlindIndex,
package/dist/index.d.mts CHANGED
@@ -1907,6 +1907,22 @@ interface SignedTestWebhookOptions {
1907
1907
  * `body.stripe_session_id != null`.
1908
1908
  */
1909
1909
  stripeSessionId?: string | null;
1910
+ /**
1911
+ * The retention window to advertise as `key_share_expiry`, in days.
1912
+ *
1913
+ * Defaults to 90, which is the default of `partners.retention_period_days` and
1914
+ * therefore what an unconfigured recipient really receives. The relay derives
1915
+ * this PER RECIPIENT from that column (14 to 365, chosen by the recipient on
1916
+ * the portal's Data Retention card), so it is not a constant on the wire and a
1917
+ * handler must not treat it as one.
1918
+ *
1919
+ * Pass your OWN configured window to rehearse the horizon you will actually
1920
+ * get. Worth doing rather than skipping: a handler that hard-codes "the expiry
1921
+ * is 90 days out" passes against this helper's default and then mis-handles its
1922
+ * own 14-day window in production, which is the same class of mistake as
1923
+ * assuming the body always carries an `id`.
1924
+ */
1925
+ retentionPeriodDays?: number | null;
1910
1926
  /**
1911
1927
  * Extra top-level body fields, merged last.
1912
1928
  *
package/dist/index.d.ts CHANGED
@@ -1907,6 +1907,22 @@ interface SignedTestWebhookOptions {
1907
1907
  * `body.stripe_session_id != null`.
1908
1908
  */
1909
1909
  stripeSessionId?: string | null;
1910
+ /**
1911
+ * The retention window to advertise as `key_share_expiry`, in days.
1912
+ *
1913
+ * Defaults to 90, which is the default of `partners.retention_period_days` and
1914
+ * therefore what an unconfigured recipient really receives. The relay derives
1915
+ * this PER RECIPIENT from that column (14 to 365, chosen by the recipient on
1916
+ * the portal's Data Retention card), so it is not a constant on the wire and a
1917
+ * handler must not treat it as one.
1918
+ *
1919
+ * Pass your OWN configured window to rehearse the horizon you will actually
1920
+ * get. Worth doing rather than skipping: a handler that hard-codes "the expiry
1921
+ * is 90 days out" passes against this helper's default and then mis-handles its
1922
+ * own 14-day window in production, which is the same class of mistake as
1923
+ * assuming the body always carries an `id`.
1924
+ */
1925
+ retentionPeriodDays?: number | null;
1910
1926
  /**
1911
1927
  * Extra top-level body fields, merged last.
1912
1928
  *
package/dist/index.js CHANGED
@@ -4784,6 +4784,24 @@ var D5_BODY_ALL_ALLOWED = [
4784
4784
  ...D5_BODY_DRILL_ONLY
4785
4785
  ];
4786
4786
 
4787
+ // ../protocol/src/retention.ts
4788
+ var MIN_RETENTION_DAYS = 14;
4789
+ var MAX_RETENTION_DAYS = 365;
4790
+ var DEFAULT_RETENTION_DAYS = 90;
4791
+ function resolveRetentionDays(retentionPeriodDays) {
4792
+ if (typeof retentionPeriodDays !== "number" || !Number.isFinite(retentionPeriodDays)) {
4793
+ return DEFAULT_RETENTION_DAYS;
4794
+ }
4795
+ const days = Math.trunc(retentionPeriodDays);
4796
+ if (days < MIN_RETENTION_DAYS || days > MAX_RETENTION_DAYS) return DEFAULT_RETENTION_DAYS;
4797
+ return days;
4798
+ }
4799
+ var DAY_MS = 24 * 60 * 60 * 1e3;
4800
+ function keyShareExpiryIso(dispatchAt, retentionPeriodDays) {
4801
+ const days = resolveRetentionDays(retentionPeriodDays);
4802
+ return new Date(dispatchAt.getTime() + days * DAY_MS).toISOString();
4803
+ }
4804
+
4787
4805
  // src/index.ts
4788
4806
  init_src();
4789
4807
  init_src();
@@ -6244,7 +6262,8 @@ async function buildSignedTestWebhook(opts2) {
6244
6262
  timestamp: nowIso,
6245
6263
  session_envelope: envelope.session_envelope,
6246
6264
  session_key_share: envelope.session_key_share,
6247
- key_share_expiry: new Date((nowSecs + 90 * 24 * 3600) * 1e3).toISOString(),
6265
+ // Per RECIPIENT, from the same resolver the relay uses, not a constant.
6266
+ key_share_expiry: keyShareExpiryIso(new Date(nowSecs * 1e3), opts2.retentionPeriodDays),
6248
6267
  id_verification: { method: "identity_document", verified_at: nowIso, verified: true, platform: "oneaddress/v1" },
6249
6268
  ...loa_encrypted ? { loa_encrypted } : {},
6250
6269
  // On the wire with a `null` value when no PaymentIntent backed the update,
package/dist/index.mjs CHANGED
@@ -31,7 +31,7 @@ import {
31
31
  verifyLOA,
32
32
  verifySignature,
33
33
  verifyWithGrace
34
- } from "./chunk-P55E2BQT.mjs";
34
+ } from "./chunk-PCYKV7RJ.mjs";
35
35
  import {
36
36
  DEFAULT_REPLAY_WINDOW_SECS,
37
37
  computeBlindIndex,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneaddress/partner-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.2.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",