@oneaddress/partner-sdk 2.8.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/CHANGELOG.md +37 -3
- package/README.md +19 -1
- package/dist/{chunk-BFSYMDJI.mjs → chunk-OKPEOGR5.mjs} +75 -1
- package/dist/edge.js +57 -1
- package/dist/edge.mjs +1 -1
- package/dist/index.d.mts +54 -2
- package/dist/index.d.ts +54 -2
- package/dist/index.js +77 -1
- package/dist/index.mjs +5 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [2.
|
|
10
|
+
## [2.9.0] - unreleased (repo bump only, not published)
|
|
11
|
+
|
|
12
|
+
### Added: `effective_date` on scheduled moves
|
|
13
|
+
|
|
14
|
+
- **`OneAddressUpdateEvent.effective_date`** (`YYYY-MM-DD`), the day the change
|
|
15
|
+
takes effect. OneAddress sends a scheduled move early enough for your declared
|
|
16
|
+
notice period, so it can arrive before the customer moves; apply it from this
|
|
17
|
+
date. Absent on an immediate update.
|
|
18
|
+
- **A malformed `effective_date` is refused with 400 `invalid_effective_date`**
|
|
19
|
+
before `onUpdate` runs, and the idempotency claim is left incomplete.
|
|
20
|
+
- **`buildSignedTestWebhook` takes `effectiveDate`** to rehearse a scheduled move.
|
|
21
|
+
- **The date is also sealed inside the envelope** (`SessionData.effective_date`).
|
|
22
|
+
A body date that differs from the sealed one, or either without the other, is
|
|
23
|
+
refused (500, `EffectiveDateMismatchError`) before `onUpdate`, like the other
|
|
24
|
+
consent bindings. Validated against the shared `session_effective_date` vectors.
|
|
11
25
|
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **`checkRegistryHead` with `keyId` and no `holdsKey`** now reports
|
|
29
|
+
`names-key-we-lack` (`alarm: true`) when the signed head names a different
|
|
30
|
+
key for your partner id. It used to report `key-identity-unknown`. Treat the
|
|
31
|
+
new verdict as an alarm: either you rotated and have not updated `keyId`, or
|
|
32
|
+
the head names a key you do not hold.
|
|
33
|
+
- **`confirmUpdate` refuses a `partnerId` that is not a UUID** with
|
|
34
|
+
`{ ok: false, status: 0 }` and a message naming the value, before signing or
|
|
35
|
+
sending anything. Use the partner id from the portal.
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- **`onUpdate` may return `note`** beside `status`. With auto-confirm on
|
|
40
|
+
(`confirm` set), it is sent as the confirm's `note`, so a `failed` can say
|
|
41
|
+
why. Shown to OneAddress support, never to the consumer. Never put the
|
|
42
|
+
address or any other decrypted detail in it.
|
|
43
|
+
|
|
44
|
+
## [2.8.0] - 2026-10-25
|
|
45
|
+
|
|
46
|
+
Published at registry timestamp `2026-10-25T10:35:14.828Z`. Everything below,
|
|
47
|
+
down to 2.7.0, ships in 2.8.0.
|
|
14
48
|
|
|
15
49
|
### Changed: the consent proof is required and verified by default
|
|
16
50
|
|
package/README.md
CHANGED
|
@@ -329,7 +329,7 @@ Under D5 your `partner_keys` registry holds your **active** key plus zero-or-mor
|
|
|
329
329
|
|
|
330
330
|
**Your contractual obligations:**
|
|
331
331
|
|
|
332
|
-
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.
|
|
332
|
+
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. A retired key's `destroy_after` can move LATER, never earlier: a consumer can schedule an update up to three months ahead, sealed to the key that was live when they booked it, and the date moves out to cover it plus your retention window. We email your contacts when it moves, and the partner portal always shows the current date. Check that date, not one you were given earlier, before you destroy a key.
|
|
333
333
|
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.
|
|
334
334
|
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.
|
|
335
335
|
|
|
@@ -822,6 +822,24 @@ async onUpdate(event) {
|
|
|
822
822
|
|
|
823
823
|
---
|
|
824
824
|
|
|
825
|
+
## Scheduled moves and `effective_date`
|
|
826
|
+
|
|
827
|
+
A customer can book an update for a future move date. OneAddress sends it to you early enough for the notice period you set on the portal's Notice card (in business days), so it can arrive before the customer moves. Every scheduled-move dispatch carries the move date as `effective_date` (`YYYY-MM-DD`):
|
|
828
|
+
|
|
829
|
+
```ts
|
|
830
|
+
onUpdate: async (event) => {
|
|
831
|
+
// Apply from the move date, not from receipt. Absent means "now".
|
|
832
|
+
const effectiveFrom = event.effective_date ?? today();
|
|
833
|
+
await accounts.scheduleAddressChange(event.customer, event.address, effectiveFrom);
|
|
834
|
+
},
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
If you start charging from the date you receive an address, use `effective_date` instead, or the customer is billed at the new address before they live there. An immediate update carries no `effective_date`.
|
|
838
|
+
|
|
839
|
+
The customer's device also seals the move date inside the envelope. The handler compares the two after decrypting and refuses the dispatch (500) when they differ or only one is present, so the date you are handed is the one the customer authorised. A body whose `effective_date` is not a real `YYYY-MM-DD` date is refused with 400 `invalid_effective_date` before anything is decrypted.
|
|
840
|
+
|
|
841
|
+
Rehearse it with `buildSignedTestWebhook({ ..., effectiveDate: '2026-12-07' })`, which puts the date in the body and seals it in the session.
|
|
842
|
+
|
|
825
843
|
## Secret rotation grace window
|
|
826
844
|
|
|
827
845
|
**Rotate with an overlap.** Staging a new secret in the Partner Portal does **not** change what we sign with: we keep using your current secret until you press *Switch over*. So the safe sequence is stage, deploy the new secret alongside the current one, verify with both, then switch. At every point the secret we sign with is one your receiver already holds.
|
|
@@ -14,6 +14,19 @@ import crypto from "crypto";
|
|
|
14
14
|
var CURRENT_VERSION = "2026.1";
|
|
15
15
|
var SUPPORTED_VERSIONS = ["2026.1"];
|
|
16
16
|
|
|
17
|
+
// ../protocol/src/notice-period.ts
|
|
18
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
19
|
+
function isIsoDate(value) {
|
|
20
|
+
if (typeof value !== "string") return false;
|
|
21
|
+
const m = ISO_DATE.exec(value);
|
|
22
|
+
if (!m) return false;
|
|
23
|
+
const d = new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));
|
|
24
|
+
return toIso(d) === value;
|
|
25
|
+
}
|
|
26
|
+
function toIso(d) {
|
|
27
|
+
return d.toISOString().slice(0, 10);
|
|
28
|
+
}
|
|
29
|
+
|
|
17
30
|
// ../protocol/src/d5-body.ts
|
|
18
31
|
var D5_BODY_ALWAYS = [
|
|
19
32
|
"event",
|
|
@@ -43,7 +56,18 @@ var D5_BODY_CONDITIONAL = {
|
|
|
43
56
|
*/
|
|
44
57
|
id: "key-crossover copy only",
|
|
45
58
|
/** The sibling marker naming the other key_ids this update was sealed to. */
|
|
46
|
-
crossover_key_ids: "key-crossover copy only"
|
|
59
|
+
crossover_key_ids: "key-crossover copy only",
|
|
60
|
+
/**
|
|
61
|
+
* The day the change takes effect, `YYYY-MM-DD` (31 Oct 2026). Set on every
|
|
62
|
+
* dispatch made for a SCHEDULED MOVE, which is its move date. A scheduled
|
|
63
|
+
* move sends each recipient early enough for its own notice period
|
|
64
|
+
* (`resolveRecipientSendPlan` in `notice-period.ts`), so the update can
|
|
65
|
+
* arrive days before the customer moves; a recipient that treated it as
|
|
66
|
+
* immediate could start charging at the new address from the day it arrived.
|
|
67
|
+
* Absent on an immediate update, which takes effect on receipt. Optional for
|
|
68
|
+
* receivers: an SDK that does not know the field ignores it.
|
|
69
|
+
*/
|
|
70
|
+
effective_date: "scheduled move only"
|
|
47
71
|
};
|
|
48
72
|
var D5_BODY_DRILL_ONLY = ["conformance"];
|
|
49
73
|
var D5_BODY_ADDED_AT_SEND = ["dispatch_id"];
|
|
@@ -694,6 +718,18 @@ async function checkRegistryHead(opts) {
|
|
|
694
718
|
headExpiresAt: expires
|
|
695
719
|
};
|
|
696
720
|
}
|
|
721
|
+
if (expectedKeyId) {
|
|
722
|
+
return {
|
|
723
|
+
verdict: "names-key-we-lack",
|
|
724
|
+
checked: true,
|
|
725
|
+
alarm: true,
|
|
726
|
+
detail: `the head names ${named} as the current key for this partner id, not ${expectedKeyId}, the key this recipient is configured with. If you did not rotate to ${named}, address envelopes are being sealed to a key you cannot read: contact OneAddress through a channel that is not oneaddress.io. If you did rotate, update keyId, or pass holdsKey so a key you hold is recognised.`,
|
|
727
|
+
namedKeyId: named,
|
|
728
|
+
expectedKeyId,
|
|
729
|
+
headIssuedAt: issued,
|
|
730
|
+
headExpiresAt: expires
|
|
731
|
+
};
|
|
732
|
+
}
|
|
697
733
|
return {
|
|
698
734
|
verdict: "key-identity-unknown",
|
|
699
735
|
checked: false,
|
|
@@ -1010,6 +1046,13 @@ async function confirmUpdate(opts) {
|
|
|
1010
1046
|
} = opts;
|
|
1011
1047
|
if (!partnerId) return { ok: false, status: 0, error: "partnerId is required" };
|
|
1012
1048
|
if (!secret) return { ok: false, status: 0, error: "secret is required" };
|
|
1049
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(partnerId)) {
|
|
1050
|
+
return {
|
|
1051
|
+
ok: false,
|
|
1052
|
+
status: 0,
|
|
1053
|
+
error: `partnerId must be your partner UUID from the portal, received ${JSON.stringify(partnerId)}`
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1013
1056
|
const id = typeof dispatchId === "string" ? Number(dispatchId) : dispatchId;
|
|
1014
1057
|
if (!Number.isInteger(id) || id <= 0) {
|
|
1015
1058
|
return {
|
|
@@ -1582,6 +1625,21 @@ function requirePemFor(purpose, key) {
|
|
|
1582
1625
|
`[OneAddress SDK] ${purpose} needs the raw private key; a PrivateKeyOperations delegate ("${key.name}") covers session envelopes only`
|
|
1583
1626
|
);
|
|
1584
1627
|
}
|
|
1628
|
+
var EffectiveDateMismatchError = class extends Error {
|
|
1629
|
+
constructor(sealed, body) {
|
|
1630
|
+
super(
|
|
1631
|
+
`[OneAddress SDK] effective_date in the body (${JSON.stringify(body ?? null)}) does not match the one sealed in the envelope (${JSON.stringify(sealed ?? null)}); refusing rather than applying a date the consumer did not seal`
|
|
1632
|
+
);
|
|
1633
|
+
this.sealed = sealed;
|
|
1634
|
+
this.body = body;
|
|
1635
|
+
this.name = "EffectiveDateMismatchError";
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
function assertEffectiveDateBound(sealed, body) {
|
|
1639
|
+
if (sealed === void 0 && body === void 0) return;
|
|
1640
|
+
if (sealed !== void 0 && body !== void 0 && sealed === body) return;
|
|
1641
|
+
throw new EffectiveDateMismatchError(sealed, body);
|
|
1642
|
+
}
|
|
1585
1643
|
function assertLoaBoundToEnvelope(loa, envelopeUpdateUid) {
|
|
1586
1644
|
if (typeof loa.update_uid !== "string" || typeof envelopeUpdateUid !== "string") return;
|
|
1587
1645
|
if (loa.update_uid !== envelopeUpdateUid) {
|
|
@@ -1722,6 +1780,7 @@ function createOneAddressHandler(options) {
|
|
|
1722
1780
|
customer.known_names = typedAliasesOf(loa);
|
|
1723
1781
|
}
|
|
1724
1782
|
}
|
|
1783
|
+
assertEffectiveDateBound(data.effective_date, body.effective_date);
|
|
1725
1784
|
return { updateTypes, address, newPhone, newEmail, customer, loa, loa_ref, raw: data };
|
|
1726
1785
|
}
|
|
1727
1786
|
function isD5Body(body) {
|
|
@@ -1837,6 +1896,12 @@ function createOneAddressHandler(options) {
|
|
|
1837
1896
|
let event;
|
|
1838
1897
|
enforceLoaPresence(body);
|
|
1839
1898
|
if (isD5Body(body)) {
|
|
1899
|
+
if (body.effective_date !== void 0 && !isIsoDate(body.effective_date)) {
|
|
1900
|
+
return declared(400, {
|
|
1901
|
+
error: "invalid_effective_date",
|
|
1902
|
+
detail: "effective_date must be a YYYY-MM-DD calendar date. Nothing was processed."
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1840
1905
|
let d5;
|
|
1841
1906
|
try {
|
|
1842
1907
|
d5 = await buildD5Pieces(body, partnerId);
|
|
@@ -1888,6 +1953,7 @@ function createOneAddressHandler(options) {
|
|
|
1888
1953
|
loa: d5.loa,
|
|
1889
1954
|
loa_ref: d5.loa_ref,
|
|
1890
1955
|
id_verification: body.id_verification,
|
|
1956
|
+
...body.effective_date !== void 0 ? { effective_date: body.effective_date } : {},
|
|
1891
1957
|
raw: d5.raw
|
|
1892
1958
|
};
|
|
1893
1959
|
} else {
|
|
@@ -1970,11 +2036,13 @@ function createOneAddressHandler(options) {
|
|
|
1970
2036
|
}
|
|
1971
2037
|
if (confirm && dispatchId) {
|
|
1972
2038
|
const status = result && typeof result === "object" && result.status ? result.status : "confirmed";
|
|
2039
|
+
const note = result && typeof result === "object" && typeof result.note === "string" ? result.note : void 0;
|
|
1973
2040
|
void confirmUpdate({
|
|
1974
2041
|
partnerId: confirm.partnerId,
|
|
1975
2042
|
secret: confirm.confirmSecret,
|
|
1976
2043
|
dispatchId,
|
|
1977
2044
|
status,
|
|
2045
|
+
...note !== void 0 ? { note } : {},
|
|
1978
2046
|
loaRef: event.loa_ref,
|
|
1979
2047
|
...confirm.oneAddressApi ? { appBaseUrl: confirm.oneAddressApi } : {},
|
|
1980
2048
|
...confirm.allowedHosts ? { allowedHosts: confirm.allowedHosts } : {},
|
|
@@ -2209,6 +2277,9 @@ async function buildSignedTestWebhook(opts) {
|
|
|
2209
2277
|
account_number: "TEST-0001",
|
|
2210
2278
|
id_verification_ref: crypto.randomUUID(),
|
|
2211
2279
|
known_names: [],
|
|
2280
|
+
// Sealed beside the body copy, as the relay's pay step does, so a
|
|
2281
|
+
// rehearsed scheduled move passes the handler's binding check.
|
|
2282
|
+
...opts.effectiveDate !== void 0 ? { effective_date: opts.effectiveDate } : {},
|
|
2212
2283
|
...opts.session ?? {}
|
|
2213
2284
|
};
|
|
2214
2285
|
const envelope = await encryptSessionForPartner(sessionData, partnerKey);
|
|
@@ -2271,6 +2342,7 @@ async function buildSignedTestWebhook(opts) {
|
|
|
2271
2342
|
key_share_expiry: keyShareExpiryIso(new Date(nowSecs * 1e3), opts.retentionPeriodDays),
|
|
2272
2343
|
id_verification: { method: "identity_document", verified_at: nowIso, verified: true, platform: "oneaddress/v1" },
|
|
2273
2344
|
...loa_encrypted ? { loa_encrypted } : {},
|
|
2345
|
+
...opts.effectiveDate !== void 0 ? { effective_date: opts.effectiveDate } : {},
|
|
2274
2346
|
// On the wire with a `null` value when no PaymentIntent backed the update,
|
|
2275
2347
|
// so the KEY is present either way.
|
|
2276
2348
|
// `id` and `crossover_key_ids` are crossover-only and therefore NOT emitted
|
|
@@ -2360,6 +2432,8 @@ export {
|
|
|
2360
2432
|
sendVerifyResult,
|
|
2361
2433
|
_resetOnceWarningsForTests,
|
|
2362
2434
|
DEFAULT_MAX_BODY_BYTES,
|
|
2435
|
+
EffectiveDateMismatchError,
|
|
2436
|
+
assertEffectiveDateBound,
|
|
2363
2437
|
createOneAddressHandler,
|
|
2364
2438
|
toExpressHandler,
|
|
2365
2439
|
buildSignedTestWebhook
|
package/dist/edge.js
CHANGED
|
@@ -5848,6 +5848,19 @@ init_src();
|
|
|
5848
5848
|
var CURRENT_VERSION = "2026.1";
|
|
5849
5849
|
var SUPPORTED_VERSIONS = ["2026.1"];
|
|
5850
5850
|
|
|
5851
|
+
// ../protocol/src/notice-period.ts
|
|
5852
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
5853
|
+
function isIsoDate(value) {
|
|
5854
|
+
if (typeof value !== "string") return false;
|
|
5855
|
+
const m = ISO_DATE.exec(value);
|
|
5856
|
+
if (!m) return false;
|
|
5857
|
+
const d = new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));
|
|
5858
|
+
return toIso(d) === value;
|
|
5859
|
+
}
|
|
5860
|
+
function toIso(d) {
|
|
5861
|
+
return d.toISOString().slice(0, 10);
|
|
5862
|
+
}
|
|
5863
|
+
|
|
5851
5864
|
// ../protocol/src/d5-body.ts
|
|
5852
5865
|
var D5_BODY_ALWAYS = [
|
|
5853
5866
|
"event",
|
|
@@ -5877,7 +5890,18 @@ var D5_BODY_CONDITIONAL = {
|
|
|
5877
5890
|
*/
|
|
5878
5891
|
id: "key-crossover copy only",
|
|
5879
5892
|
/** The sibling marker naming the other key_ids this update was sealed to. */
|
|
5880
|
-
crossover_key_ids: "key-crossover copy only"
|
|
5893
|
+
crossover_key_ids: "key-crossover copy only",
|
|
5894
|
+
/**
|
|
5895
|
+
* The day the change takes effect, `YYYY-MM-DD` (31 Oct 2026). Set on every
|
|
5896
|
+
* dispatch made for a SCHEDULED MOVE, which is its move date. A scheduled
|
|
5897
|
+
* move sends each recipient early enough for its own notice period
|
|
5898
|
+
* (`resolveRecipientSendPlan` in `notice-period.ts`), so the update can
|
|
5899
|
+
* arrive days before the customer moves; a recipient that treated it as
|
|
5900
|
+
* immediate could start charging at the new address from the day it arrived.
|
|
5901
|
+
* Absent on an immediate update, which takes effect on receipt. Optional for
|
|
5902
|
+
* receivers: an SDK that does not know the field ignores it.
|
|
5903
|
+
*/
|
|
5904
|
+
effective_date: "scheduled move only"
|
|
5881
5905
|
};
|
|
5882
5906
|
var D5_BODY_DRILL_ONLY = ["conformance"];
|
|
5883
5907
|
var D5_BODY_ADDED_AT_SEND = ["dispatch_id"];
|
|
@@ -6259,6 +6283,13 @@ async function confirmUpdate(opts2) {
|
|
|
6259
6283
|
} = opts2;
|
|
6260
6284
|
if (!partnerId) return { ok: false, status: 0, error: "partnerId is required" };
|
|
6261
6285
|
if (!secret) return { ok: false, status: 0, error: "secret is required" };
|
|
6286
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(partnerId)) {
|
|
6287
|
+
return {
|
|
6288
|
+
ok: false,
|
|
6289
|
+
status: 0,
|
|
6290
|
+
error: `partnerId must be your partner UUID from the portal, received ${JSON.stringify(partnerId)}`
|
|
6291
|
+
};
|
|
6292
|
+
}
|
|
6262
6293
|
const id = typeof dispatchId === "string" ? Number(dispatchId) : dispatchId;
|
|
6263
6294
|
if (!Number.isInteger(id) || id <= 0) {
|
|
6264
6295
|
return {
|
|
@@ -6795,6 +6826,21 @@ function requirePemFor(purpose, key) {
|
|
|
6795
6826
|
`[OneAddress SDK] ${purpose} needs the raw private key; a PrivateKeyOperations delegate ("${key.name}") covers session envelopes only`
|
|
6796
6827
|
);
|
|
6797
6828
|
}
|
|
6829
|
+
var EffectiveDateMismatchError = class extends Error {
|
|
6830
|
+
constructor(sealed, body) {
|
|
6831
|
+
super(
|
|
6832
|
+
`[OneAddress SDK] effective_date in the body (${JSON.stringify(body ?? null)}) does not match the one sealed in the envelope (${JSON.stringify(sealed ?? null)}); refusing rather than applying a date the consumer did not seal`
|
|
6833
|
+
);
|
|
6834
|
+
this.sealed = sealed;
|
|
6835
|
+
this.body = body;
|
|
6836
|
+
this.name = "EffectiveDateMismatchError";
|
|
6837
|
+
}
|
|
6838
|
+
};
|
|
6839
|
+
function assertEffectiveDateBound(sealed, body) {
|
|
6840
|
+
if (sealed === void 0 && body === void 0) return;
|
|
6841
|
+
if (sealed !== void 0 && body !== void 0 && sealed === body) return;
|
|
6842
|
+
throw new EffectiveDateMismatchError(sealed, body);
|
|
6843
|
+
}
|
|
6798
6844
|
function assertLoaBoundToEnvelope(loa, envelopeUpdateUid) {
|
|
6799
6845
|
if (typeof loa.update_uid !== "string" || typeof envelopeUpdateUid !== "string") return;
|
|
6800
6846
|
if (loa.update_uid !== envelopeUpdateUid) {
|
|
@@ -6935,6 +6981,7 @@ function createOneAddressHandler(options) {
|
|
|
6935
6981
|
customer.known_names = typedAliasesOf(loa);
|
|
6936
6982
|
}
|
|
6937
6983
|
}
|
|
6984
|
+
assertEffectiveDateBound(data.effective_date, body.effective_date);
|
|
6938
6985
|
return { updateTypes, address, newPhone, newEmail, customer, loa, loa_ref, raw: data };
|
|
6939
6986
|
}
|
|
6940
6987
|
function isD5Body(body) {
|
|
@@ -7050,6 +7097,12 @@ function createOneAddressHandler(options) {
|
|
|
7050
7097
|
let event;
|
|
7051
7098
|
enforceLoaPresence(body);
|
|
7052
7099
|
if (isD5Body(body)) {
|
|
7100
|
+
if (body.effective_date !== void 0 && !isIsoDate(body.effective_date)) {
|
|
7101
|
+
return declared(400, {
|
|
7102
|
+
error: "invalid_effective_date",
|
|
7103
|
+
detail: "effective_date must be a YYYY-MM-DD calendar date. Nothing was processed."
|
|
7104
|
+
});
|
|
7105
|
+
}
|
|
7053
7106
|
let d5;
|
|
7054
7107
|
try {
|
|
7055
7108
|
d5 = await buildD5Pieces(body, partnerId);
|
|
@@ -7101,6 +7154,7 @@ function createOneAddressHandler(options) {
|
|
|
7101
7154
|
loa: d5.loa,
|
|
7102
7155
|
loa_ref: d5.loa_ref,
|
|
7103
7156
|
id_verification: body.id_verification,
|
|
7157
|
+
...body.effective_date !== void 0 ? { effective_date: body.effective_date } : {},
|
|
7104
7158
|
raw: d5.raw
|
|
7105
7159
|
};
|
|
7106
7160
|
} else {
|
|
@@ -7183,11 +7237,13 @@ function createOneAddressHandler(options) {
|
|
|
7183
7237
|
}
|
|
7184
7238
|
if (confirm && dispatchId) {
|
|
7185
7239
|
const status = result && typeof result === "object" && result.status ? result.status : "confirmed";
|
|
7240
|
+
const note = result && typeof result === "object" && typeof result.note === "string" ? result.note : void 0;
|
|
7186
7241
|
void confirmUpdate({
|
|
7187
7242
|
partnerId: confirm.partnerId,
|
|
7188
7243
|
secret: confirm.confirmSecret,
|
|
7189
7244
|
dispatchId,
|
|
7190
7245
|
status,
|
|
7246
|
+
...note !== void 0 ? { note } : {},
|
|
7191
7247
|
loaRef: event.loa_ref,
|
|
7192
7248
|
...confirm.oneAddressApi ? { appBaseUrl: confirm.oneAddressApi } : {},
|
|
7193
7249
|
...confirm.allowedHosts ? { allowedHosts: confirm.allowedHosts } : {},
|
package/dist/edge.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -507,7 +507,8 @@ interface RegistryHeadCheckOptions {
|
|
|
507
507
|
* Optional, because a recipient holding several keys through a resolver may
|
|
508
508
|
* have no single primary. Without it, and without `holdsKey`, the check can
|
|
509
509
|
* verify the head but cannot say whether the named key is ours, and reports
|
|
510
|
-
* `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`.
|
|
511
512
|
*/
|
|
512
513
|
keyId?: string;
|
|
513
514
|
/**
|
|
@@ -853,6 +854,16 @@ interface OneAddressUpdateEvent {
|
|
|
853
854
|
* See {@link OneAddressIdVerification}.
|
|
854
855
|
*/
|
|
855
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;
|
|
856
867
|
/** Raw decrypted + parsed payload (in case fields are extended) */
|
|
857
868
|
raw: Record<string, unknown>;
|
|
858
869
|
}
|
|
@@ -1181,6 +1192,12 @@ interface OneAddressHandlerOptions {
|
|
|
1181
1192
|
onUpdate: (event: OneAddressUpdateEvent) => Promise<{
|
|
1182
1193
|
status?: OneAddressConfirmStatus;
|
|
1183
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;
|
|
1184
1201
|
} | void>;
|
|
1185
1202
|
/**
|
|
1186
1203
|
* Called when a consumer runs an address verification check.
|
|
@@ -1688,6 +1705,12 @@ interface SessionData {
|
|
|
1688
1705
|
* match against your own record, never a key to look one up by.
|
|
1689
1706
|
*/
|
|
1690
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;
|
|
1691
1714
|
}
|
|
1692
1715
|
/**
|
|
1693
1716
|
* Decrypt a D5 session envelope using your retained private key matching
|
|
@@ -2410,6 +2433,27 @@ interface OneAddressTestEvent {
|
|
|
2410
2433
|
declare function _resetOnceWarningsForTests(): void;
|
|
2411
2434
|
/** Default {@link OneAddressHandlerOptions.maxBodyBytes}: 1 MiB. */
|
|
2412
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;
|
|
2413
2457
|
/**
|
|
2414
2458
|
* Create a framework-agnostic OneAddress webhook handler.
|
|
2415
2459
|
* Returns a function compatible with Next.js App Router route handlers,
|
|
@@ -2561,6 +2605,14 @@ interface SignedTestWebhookOptions {
|
|
|
2561
2605
|
* assuming the body always carries an `id`.
|
|
2562
2606
|
*/
|
|
2563
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;
|
|
2564
2616
|
/**
|
|
2565
2617
|
* Extra top-level body fields, merged last.
|
|
2566
2618
|
*
|
|
@@ -2623,4 +2675,4 @@ interface SignedTestWebhook {
|
|
|
2623
2675
|
*/
|
|
2624
2676
|
declare function buildSignedTestWebhook(opts: SignedTestWebhookOptions): Promise<SignedTestWebhook>;
|
|
2625
2677
|
|
|
2626
|
-
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, 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, 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -507,7 +507,8 @@ interface RegistryHeadCheckOptions {
|
|
|
507
507
|
* Optional, because a recipient holding several keys through a resolver may
|
|
508
508
|
* have no single primary. Without it, and without `holdsKey`, the check can
|
|
509
509
|
* verify the head but cannot say whether the named key is ours, and reports
|
|
510
|
-
* `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`.
|
|
511
512
|
*/
|
|
512
513
|
keyId?: string;
|
|
513
514
|
/**
|
|
@@ -853,6 +854,16 @@ interface OneAddressUpdateEvent {
|
|
|
853
854
|
* See {@link OneAddressIdVerification}.
|
|
854
855
|
*/
|
|
855
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;
|
|
856
867
|
/** Raw decrypted + parsed payload (in case fields are extended) */
|
|
857
868
|
raw: Record<string, unknown>;
|
|
858
869
|
}
|
|
@@ -1181,6 +1192,12 @@ interface OneAddressHandlerOptions {
|
|
|
1181
1192
|
onUpdate: (event: OneAddressUpdateEvent) => Promise<{
|
|
1182
1193
|
status?: OneAddressConfirmStatus;
|
|
1183
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;
|
|
1184
1201
|
} | void>;
|
|
1185
1202
|
/**
|
|
1186
1203
|
* Called when a consumer runs an address verification check.
|
|
@@ -1688,6 +1705,12 @@ interface SessionData {
|
|
|
1688
1705
|
* match against your own record, never a key to look one up by.
|
|
1689
1706
|
*/
|
|
1690
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;
|
|
1691
1714
|
}
|
|
1692
1715
|
/**
|
|
1693
1716
|
* Decrypt a D5 session envelope using your retained private key matching
|
|
@@ -2410,6 +2433,27 @@ interface OneAddressTestEvent {
|
|
|
2410
2433
|
declare function _resetOnceWarningsForTests(): void;
|
|
2411
2434
|
/** Default {@link OneAddressHandlerOptions.maxBodyBytes}: 1 MiB. */
|
|
2412
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;
|
|
2413
2457
|
/**
|
|
2414
2458
|
* Create a framework-agnostic OneAddress webhook handler.
|
|
2415
2459
|
* Returns a function compatible with Next.js App Router route handlers,
|
|
@@ -2561,6 +2605,14 @@ interface SignedTestWebhookOptions {
|
|
|
2561
2605
|
* assuming the body always carries an `id`.
|
|
2562
2606
|
*/
|
|
2563
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;
|
|
2564
2616
|
/**
|
|
2565
2617
|
* Extra top-level body fields, merged last.
|
|
2566
2618
|
*
|
|
@@ -2623,4 +2675,4 @@ interface SignedTestWebhook {
|
|
|
2623
2675
|
*/
|
|
2624
2676
|
declare function buildSignedTestWebhook(opts: SignedTestWebhookOptions): Promise<SignedTestWebhook>;
|
|
2625
2677
|
|
|
2626
|
-
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, 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, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -5803,6 +5803,7 @@ __export(index_exports, {
|
|
|
5803
5803
|
DEFAULT_IDEMPOTENCY_LEASE_SECS: () => DEFAULT_IDEMPOTENCY_LEASE_SECS,
|
|
5804
5804
|
DEFAULT_MAX_BODY_BYTES: () => DEFAULT_MAX_BODY_BYTES,
|
|
5805
5805
|
DEFAULT_REPLAY_WINDOW_SECS: () => DEFAULT_REPLAY_WINDOW_SECS,
|
|
5806
|
+
EffectiveDateMismatchError: () => EffectiveDateMismatchError,
|
|
5806
5807
|
LOA_MAX_TYPED_ALIASES: () => LOA_MAX_TYPED_ALIASES,
|
|
5807
5808
|
LOA_MIN_SHORT_FORM_LETTERS: () => LOA_MIN_SHORT_FORM_LETTERS,
|
|
5808
5809
|
LOA_PUBLIC_KEY_CACHE_MS: () => LOA_PUBLIC_KEY_CACHE_MS,
|
|
@@ -5815,6 +5816,7 @@ __export(index_exports, {
|
|
|
5815
5816
|
_resetLoaKeyCacheForTests: () => _resetLoaKeyCacheForTests,
|
|
5816
5817
|
_resetOnceWarningsForTests: () => _resetOnceWarningsForTests,
|
|
5817
5818
|
acceptTypedAliases: () => acceptTypedAliases,
|
|
5819
|
+
assertEffectiveDateBound: () => assertEffectiveDateBound,
|
|
5818
5820
|
buildSignedTestWebhook: () => buildSignedTestWebhook,
|
|
5819
5821
|
cachedLoaPublicKey: () => cachedLoaPublicKey,
|
|
5820
5822
|
canonicalD5LoaForm: () => canonicalD5LoaForm,
|
|
@@ -5874,6 +5876,19 @@ init_src();
|
|
|
5874
5876
|
var CURRENT_VERSION = "2026.1";
|
|
5875
5877
|
var SUPPORTED_VERSIONS = ["2026.1"];
|
|
5876
5878
|
|
|
5879
|
+
// ../protocol/src/notice-period.ts
|
|
5880
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
5881
|
+
function isIsoDate(value) {
|
|
5882
|
+
if (typeof value !== "string") return false;
|
|
5883
|
+
const m = ISO_DATE.exec(value);
|
|
5884
|
+
if (!m) return false;
|
|
5885
|
+
const d = new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));
|
|
5886
|
+
return toIso(d) === value;
|
|
5887
|
+
}
|
|
5888
|
+
function toIso(d) {
|
|
5889
|
+
return d.toISOString().slice(0, 10);
|
|
5890
|
+
}
|
|
5891
|
+
|
|
5877
5892
|
// ../protocol/src/d5-body.ts
|
|
5878
5893
|
var D5_BODY_ALWAYS = [
|
|
5879
5894
|
"event",
|
|
@@ -5903,7 +5918,18 @@ var D5_BODY_CONDITIONAL = {
|
|
|
5903
5918
|
*/
|
|
5904
5919
|
id: "key-crossover copy only",
|
|
5905
5920
|
/** The sibling marker naming the other key_ids this update was sealed to. */
|
|
5906
|
-
crossover_key_ids: "key-crossover copy only"
|
|
5921
|
+
crossover_key_ids: "key-crossover copy only",
|
|
5922
|
+
/**
|
|
5923
|
+
* The day the change takes effect, `YYYY-MM-DD` (31 Oct 2026). Set on every
|
|
5924
|
+
* dispatch made for a SCHEDULED MOVE, which is its move date. A scheduled
|
|
5925
|
+
* move sends each recipient early enough for its own notice period
|
|
5926
|
+
* (`resolveRecipientSendPlan` in `notice-period.ts`), so the update can
|
|
5927
|
+
* arrive days before the customer moves; a recipient that treated it as
|
|
5928
|
+
* immediate could start charging at the new address from the day it arrived.
|
|
5929
|
+
* Absent on an immediate update, which takes effect on receipt. Optional for
|
|
5930
|
+
* receivers: an SDK that does not know the field ignores it.
|
|
5931
|
+
*/
|
|
5932
|
+
effective_date: "scheduled move only"
|
|
5907
5933
|
};
|
|
5908
5934
|
var D5_BODY_DRILL_ONLY = ["conformance"];
|
|
5909
5935
|
var D5_BODY_ADDED_AT_SEND = ["dispatch_id"];
|
|
@@ -6559,6 +6585,18 @@ async function checkRegistryHead(opts2) {
|
|
|
6559
6585
|
headExpiresAt: expires
|
|
6560
6586
|
};
|
|
6561
6587
|
}
|
|
6588
|
+
if (expectedKeyId) {
|
|
6589
|
+
return {
|
|
6590
|
+
verdict: "names-key-we-lack",
|
|
6591
|
+
checked: true,
|
|
6592
|
+
alarm: true,
|
|
6593
|
+
detail: `the head names ${named} as the current key for this partner id, not ${expectedKeyId}, the key this recipient is configured with. If you did not rotate to ${named}, address envelopes are being sealed to a key you cannot read: contact OneAddress through a channel that is not oneaddress.io. If you did rotate, update keyId, or pass holdsKey so a key you hold is recognised.`,
|
|
6594
|
+
namedKeyId: named,
|
|
6595
|
+
expectedKeyId,
|
|
6596
|
+
headIssuedAt: issued,
|
|
6597
|
+
headExpiresAt: expires
|
|
6598
|
+
};
|
|
6599
|
+
}
|
|
6562
6600
|
return {
|
|
6563
6601
|
verdict: "key-identity-unknown",
|
|
6564
6602
|
checked: false,
|
|
@@ -6875,6 +6913,13 @@ async function confirmUpdate(opts2) {
|
|
|
6875
6913
|
} = opts2;
|
|
6876
6914
|
if (!partnerId) return { ok: false, status: 0, error: "partnerId is required" };
|
|
6877
6915
|
if (!secret) return { ok: false, status: 0, error: "secret is required" };
|
|
6916
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(partnerId)) {
|
|
6917
|
+
return {
|
|
6918
|
+
ok: false,
|
|
6919
|
+
status: 0,
|
|
6920
|
+
error: `partnerId must be your partner UUID from the portal, received ${JSON.stringify(partnerId)}`
|
|
6921
|
+
};
|
|
6922
|
+
}
|
|
6878
6923
|
const id = typeof dispatchId === "string" ? Number(dispatchId) : dispatchId;
|
|
6879
6924
|
if (!Number.isInteger(id) || id <= 0) {
|
|
6880
6925
|
return {
|
|
@@ -7447,6 +7492,21 @@ function requirePemFor(purpose, key) {
|
|
|
7447
7492
|
`[OneAddress SDK] ${purpose} needs the raw private key; a PrivateKeyOperations delegate ("${key.name}") covers session envelopes only`
|
|
7448
7493
|
);
|
|
7449
7494
|
}
|
|
7495
|
+
var EffectiveDateMismatchError = class extends Error {
|
|
7496
|
+
constructor(sealed, body) {
|
|
7497
|
+
super(
|
|
7498
|
+
`[OneAddress SDK] effective_date in the body (${JSON.stringify(body ?? null)}) does not match the one sealed in the envelope (${JSON.stringify(sealed ?? null)}); refusing rather than applying a date the consumer did not seal`
|
|
7499
|
+
);
|
|
7500
|
+
this.sealed = sealed;
|
|
7501
|
+
this.body = body;
|
|
7502
|
+
this.name = "EffectiveDateMismatchError";
|
|
7503
|
+
}
|
|
7504
|
+
};
|
|
7505
|
+
function assertEffectiveDateBound(sealed, body) {
|
|
7506
|
+
if (sealed === void 0 && body === void 0) return;
|
|
7507
|
+
if (sealed !== void 0 && body !== void 0 && sealed === body) return;
|
|
7508
|
+
throw new EffectiveDateMismatchError(sealed, body);
|
|
7509
|
+
}
|
|
7450
7510
|
function assertLoaBoundToEnvelope(loa, envelopeUpdateUid) {
|
|
7451
7511
|
if (typeof loa.update_uid !== "string" || typeof envelopeUpdateUid !== "string") return;
|
|
7452
7512
|
if (loa.update_uid !== envelopeUpdateUid) {
|
|
@@ -7587,6 +7647,7 @@ function createOneAddressHandler(options) {
|
|
|
7587
7647
|
customer.known_names = typedAliasesOf(loa);
|
|
7588
7648
|
}
|
|
7589
7649
|
}
|
|
7650
|
+
assertEffectiveDateBound(data.effective_date, body.effective_date);
|
|
7590
7651
|
return { updateTypes, address, newPhone, newEmail, customer, loa, loa_ref, raw: data };
|
|
7591
7652
|
}
|
|
7592
7653
|
function isD5Body(body) {
|
|
@@ -7702,6 +7763,12 @@ function createOneAddressHandler(options) {
|
|
|
7702
7763
|
let event;
|
|
7703
7764
|
enforceLoaPresence(body);
|
|
7704
7765
|
if (isD5Body(body)) {
|
|
7766
|
+
if (body.effective_date !== void 0 && !isIsoDate(body.effective_date)) {
|
|
7767
|
+
return declared(400, {
|
|
7768
|
+
error: "invalid_effective_date",
|
|
7769
|
+
detail: "effective_date must be a YYYY-MM-DD calendar date. Nothing was processed."
|
|
7770
|
+
});
|
|
7771
|
+
}
|
|
7705
7772
|
let d5;
|
|
7706
7773
|
try {
|
|
7707
7774
|
d5 = await buildD5Pieces(body, partnerId);
|
|
@@ -7753,6 +7820,7 @@ function createOneAddressHandler(options) {
|
|
|
7753
7820
|
loa: d5.loa,
|
|
7754
7821
|
loa_ref: d5.loa_ref,
|
|
7755
7822
|
id_verification: body.id_verification,
|
|
7823
|
+
...body.effective_date !== void 0 ? { effective_date: body.effective_date } : {},
|
|
7756
7824
|
raw: d5.raw
|
|
7757
7825
|
};
|
|
7758
7826
|
} else {
|
|
@@ -7835,11 +7903,13 @@ function createOneAddressHandler(options) {
|
|
|
7835
7903
|
}
|
|
7836
7904
|
if (confirm && dispatchId) {
|
|
7837
7905
|
const status = result && typeof result === "object" && result.status ? result.status : "confirmed";
|
|
7906
|
+
const note = result && typeof result === "object" && typeof result.note === "string" ? result.note : void 0;
|
|
7838
7907
|
void confirmUpdate({
|
|
7839
7908
|
partnerId: confirm.partnerId,
|
|
7840
7909
|
secret: confirm.confirmSecret,
|
|
7841
7910
|
dispatchId,
|
|
7842
7911
|
status,
|
|
7912
|
+
...note !== void 0 ? { note } : {},
|
|
7843
7913
|
loaRef: event.loa_ref,
|
|
7844
7914
|
...confirm.oneAddressApi ? { appBaseUrl: confirm.oneAddressApi } : {},
|
|
7845
7915
|
...confirm.allowedHosts ? { allowedHosts: confirm.allowedHosts } : {},
|
|
@@ -8074,6 +8144,9 @@ async function buildSignedTestWebhook(opts2) {
|
|
|
8074
8144
|
account_number: "TEST-0001",
|
|
8075
8145
|
id_verification_ref: import_crypto2.default.randomUUID(),
|
|
8076
8146
|
known_names: [],
|
|
8147
|
+
// Sealed beside the body copy, as the relay's pay step does, so a
|
|
8148
|
+
// rehearsed scheduled move passes the handler's binding check.
|
|
8149
|
+
...opts2.effectiveDate !== void 0 ? { effective_date: opts2.effectiveDate } : {},
|
|
8077
8150
|
...opts2.session ?? {}
|
|
8078
8151
|
};
|
|
8079
8152
|
const envelope = await encryptSessionForPartner(sessionData, partnerKey);
|
|
@@ -8136,6 +8209,7 @@ async function buildSignedTestWebhook(opts2) {
|
|
|
8136
8209
|
key_share_expiry: keyShareExpiryIso(new Date(nowSecs * 1e3), opts2.retentionPeriodDays),
|
|
8137
8210
|
id_verification: { method: "identity_document", verified_at: nowIso, verified: true, platform: "oneaddress/v1" },
|
|
8138
8211
|
...loa_encrypted ? { loa_encrypted } : {},
|
|
8212
|
+
...opts2.effectiveDate !== void 0 ? { effective_date: opts2.effectiveDate } : {},
|
|
8139
8213
|
// On the wire with a `null` value when no PaymentIntent backed the update,
|
|
8140
8214
|
// so the KEY is present either way.
|
|
8141
8215
|
// `id` and `crossover_key_ids` are crossover-only and therefore NOT emitted
|
|
@@ -8174,6 +8248,7 @@ async function buildSignedTestWebhook(opts2) {
|
|
|
8174
8248
|
DEFAULT_IDEMPOTENCY_LEASE_SECS,
|
|
8175
8249
|
DEFAULT_MAX_BODY_BYTES,
|
|
8176
8250
|
DEFAULT_REPLAY_WINDOW_SECS,
|
|
8251
|
+
EffectiveDateMismatchError,
|
|
8177
8252
|
LOA_MAX_TYPED_ALIASES,
|
|
8178
8253
|
LOA_MIN_SHORT_FORM_LETTERS,
|
|
8179
8254
|
LOA_PUBLIC_KEY_CACHE_MS,
|
|
@@ -8186,6 +8261,7 @@ async function buildSignedTestWebhook(opts2) {
|
|
|
8186
8261
|
_resetLoaKeyCacheForTests,
|
|
8187
8262
|
_resetOnceWarningsForTests,
|
|
8188
8263
|
acceptTypedAliases,
|
|
8264
|
+
assertEffectiveDateBound,
|
|
8189
8265
|
buildSignedTestWebhook,
|
|
8190
8266
|
cachedLoaPublicKey,
|
|
8191
8267
|
canonicalD5LoaForm,
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
CURRENT_VERSION,
|
|
3
3
|
DEFAULT_IDEMPOTENCY_LEASE_SECS,
|
|
4
4
|
DEFAULT_MAX_BODY_BYTES,
|
|
5
|
+
EffectiveDateMismatchError,
|
|
5
6
|
LOA_MAX_TYPED_ALIASES,
|
|
6
7
|
LOA_MIN_SHORT_FORM_LETTERS,
|
|
7
8
|
LOA_PUBLIC_KEY_CACHE_MS,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
_resetLoaKeyCacheForTests,
|
|
15
16
|
_resetOnceWarningsForTests,
|
|
16
17
|
acceptTypedAliases,
|
|
18
|
+
assertEffectiveDateBound,
|
|
17
19
|
buildSignedTestWebhook,
|
|
18
20
|
cachedLoaPublicKey,
|
|
19
21
|
canonicalD5LoaForm,
|
|
@@ -57,7 +59,7 @@ import {
|
|
|
57
59
|
verifyLOA,
|
|
58
60
|
verifySignature,
|
|
59
61
|
verifyWithGrace
|
|
60
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-OKPEOGR5.mjs";
|
|
61
63
|
import {
|
|
62
64
|
DEFAULT_REPLAY_WINDOW_SECS,
|
|
63
65
|
computeBlindIndex,
|
|
@@ -69,6 +71,7 @@ export {
|
|
|
69
71
|
DEFAULT_IDEMPOTENCY_LEASE_SECS,
|
|
70
72
|
DEFAULT_MAX_BODY_BYTES,
|
|
71
73
|
DEFAULT_REPLAY_WINDOW_SECS,
|
|
74
|
+
EffectiveDateMismatchError,
|
|
72
75
|
LOA_MAX_TYPED_ALIASES,
|
|
73
76
|
LOA_MIN_SHORT_FORM_LETTERS,
|
|
74
77
|
LOA_PUBLIC_KEY_CACHE_MS,
|
|
@@ -81,6 +84,7 @@ export {
|
|
|
81
84
|
_resetLoaKeyCacheForTests,
|
|
82
85
|
_resetOnceWarningsForTests,
|
|
83
86
|
acceptTypedAliases,
|
|
87
|
+
assertEffectiveDateBound,
|
|
84
88
|
buildSignedTestWebhook,
|
|
85
89
|
cachedLoaPublicKey,
|
|
86
90
|
canonicalD5LoaForm,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneaddress/partner-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.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",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"@oneaddress/protocol": "^0.1.0",
|
|
62
62
|
"tsup": "^8.0.0",
|
|
63
63
|
"typescript": "^5.0.0",
|
|
64
|
-
"vitest": "^4.1.
|
|
64
|
+
"vitest": "^4.1.12"
|
|
65
65
|
}
|
|
66
66
|
}
|