@oneaddress/partner-sdk 2.4.0 → 2.5.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 +78 -0
- package/README.md +25 -4
- package/dist/{chunk-4WYW6BM3.mjs → chunk-DIUGEFIK.mjs} +41 -3
- package/dist/{chunk-FDMB4BNC.mjs → chunk-ZY2K54LD.mjs} +1030 -1187
- package/dist/edge.js +1079 -1223
- package/dist/edge.mjs +2 -2
- package/dist/index.d.mts +27 -8
- package/dist/index.d.ts +27 -8
- package/dist/index.js +1079 -1223
- package/dist/index.mjs +2 -2
- package/dist/{src-SNMMZ4BT.mjs → src-RBLFVBGY.mjs} +7 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,84 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.5.0] - 2026-10-14
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **A key you do not hold no longer answers the same as your database being
|
|
15
|
+
down.** The handler holds one key and never looks one up, so a dispatch
|
|
16
|
+
sealed to a key it does not hold reached `decryptSession`, failed inside
|
|
17
|
+
AES-GCM tag verification, and fell through to the catch-all:
|
|
18
|
+
`500 {"error":"Internal handler error"}`. That is also this SDK's answer for
|
|
19
|
+
a database outage, a bug in your own `onUpdate`, and a missing LOA key, so
|
|
20
|
+
neither you nor OneAddress could tell them apart. OneAddress stores that body
|
|
21
|
+
verbatim, which means the one record that would have named a key mismatch
|
|
22
|
+
said nothing.
|
|
23
|
+
|
|
24
|
+
Two refusals now, because only one of them is yours to fix:
|
|
25
|
+
|
|
26
|
+
- `503` with `{"error":"missing_key","key_id":"..."}` when the dispatch names
|
|
27
|
+
a `key_id` that is not the one you configured. Refused before any crypto
|
|
28
|
+
runs, and retryable: installing the key fixes it. Only possible when you
|
|
29
|
+
pass the `keyId` option, since without it the SDK cannot know which key it
|
|
30
|
+
holds.
|
|
31
|
+
- `422` with `{"error":"decrypt_failed","detail":"..."}` when the unwrap
|
|
32
|
+
itself fails. Ambiguous by nature (wrong key, wrong `partner_id`, tampered
|
|
33
|
+
or truncated ciphertext), so it says so rather than guessing, and `detail`
|
|
34
|
+
carries the underlying message. An algorithm downgrade and a key-source
|
|
35
|
+
capability refusal still name themselves there rather than being relabelled
|
|
36
|
+
as a key problem.
|
|
37
|
+
|
|
38
|
+
Both still write the same `console.error` line they always did. The response
|
|
39
|
+
is for OneAddress; the log is for you.
|
|
40
|
+
|
|
41
|
+
**If you monitor on status codes, this is the change to read.** A receiver
|
|
42
|
+
that treated 500 as the signal for an undecryptable dispatch will now see 503
|
|
43
|
+
or 422. Nothing about the envelope, the wire format or the crypto changed.
|
|
44
|
+
|
|
45
|
+
This is the behaviour the drop-in receiver has had since it was written, so
|
|
46
|
+
the two now agree.
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- **The `decryptSession` docstring described a record we do not keep.** It said
|
|
51
|
+
a destroyed retired key is recorded on the OneAddress side as a
|
|
52
|
+
`partner_key_custody_failure` outcome on the reconstruction audit log. No such
|
|
53
|
+
outcome and no such log exist. Destroying a retired key before your configured
|
|
54
|
+
retention window closes is still a key-custody breach under the partner terms,
|
|
55
|
+
which is unchanged; what was wrong was the claim about what we record.
|
|
56
|
+
|
|
57
|
+
- **The same docstring called the retention window "90-day".** It is the window
|
|
58
|
+
you configure, with a 14 day minimum, and the authoritative horizon for any
|
|
59
|
+
key is its own `destroy_after` date. 90 is a column default. A partner on 14
|
|
60
|
+
days would have over-retained; one on 365 would have destroyed early.
|
|
61
|
+
|
|
62
|
+
## [2.4.1] - 2026-10-06
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- **The retry table told partners that a `401` is retried, and that every 4xx is
|
|
67
|
+
filed as an authentication failure. Neither was true of the relay.** Both
|
|
68
|
+
sentences described an earlier version of the dispatch classifier and had
|
|
69
|
+
survived it, so a partner reading the published table built their handler
|
|
70
|
+
against behaviour the relay does not have.
|
|
71
|
+
|
|
72
|
+
What the relay actually does: a `401` or a `403` is **not retried** - the
|
|
73
|
+
dispatch is marked `auth_failed` and stops, because retrying a rejected
|
|
74
|
+
signature only repeats the rejection. A `400` or a `422` is classified
|
|
75
|
+
`partner_error`, not `auth_failed`, so the consumer's dashboard does not blame
|
|
76
|
+
the signature for a malformed body or an undeclared update kind. `403` was
|
|
77
|
+
absent from the table entirely.
|
|
78
|
+
|
|
79
|
+
Documentation only. No runtime code, no exported type and no wire format
|
|
80
|
+
changes in this release; `dist/index.js` is byte-identical to 2.4.0.
|
|
81
|
+
|
|
82
|
+
- **`verified: true` read as an assurance signal, and it is only a presence
|
|
83
|
+
marker.** It is `true` on a `mock` dispatch as well, so a recipient treating it
|
|
84
|
+
as "an identity check stands behind this" is wrong for sandbox runs, product
|
|
85
|
+
demonstrations and internal tests. The doc comments on `method` and `verified`
|
|
86
|
+
now say so, and name `method === 'identity_document'` as the field to route on.
|
|
87
|
+
|
|
10
88
|
## [2.4.0] - 2026-10-01
|
|
11
89
|
|
|
12
90
|
### Added
|
package/README.md
CHANGED
|
@@ -463,13 +463,34 @@ What each response status means to us:
|
|
|
463
463
|
| You answer | We record | We do |
|
|
464
464
|
|---|---|---|
|
|
465
465
|
| `2xx` (and no `ok: false`) | delivered, awaiting your confirm | Wait for `confirmUpdate`. |
|
|
466
|
-
| `400` |
|
|
467
|
-
| `401` | auth failed
|
|
468
|
-
| `422` |
|
|
466
|
+
| `400` | partner error | Retry on the backoff. A malformed request cannot be fixed by retrying, but the class of problem (a stale timestamp, a body that is not JSON) usually clears on the next attempt. |
|
|
467
|
+
| `401` or `403` | **auth failed** | **Not retried.** See the warning below. |
|
|
468
|
+
| `422` | partner error | Retry. The handler sends this for a kind you have not declared in `acceptedUpdateTypes`; once you widen the declaration the retry is processed. |
|
|
469
469
|
| `500` | partner error | Retry. This is what the handler answers for a decrypt failure, a missing or invalid consent proof, or a throwing `onUpdate`, and it is the right answer for anything you want retried. |
|
|
470
470
|
| no response / timeout | unreachable | Retry. |
|
|
471
471
|
|
|
472
|
-
|
|
472
|
+
> **A 401 or 403 ends the delivery. It is not retried, and this README said the
|
|
473
|
+
> opposite until 5 October 2026.**
|
|
474
|
+
>
|
|
475
|
+
> Those two statuses are the only ones we read as a **rejected signature**, and
|
|
476
|
+
> a rejected signature does not fix itself: nothing about waiting and sending
|
|
477
|
+
> the same bytes again makes them verify. So the dispatch is parked in the
|
|
478
|
+
> `auth_failed` state and the retry cron excludes it from its candidate set.
|
|
479
|
+
> Once a dispatch is parked there, nothing moves it except a fresh address
|
|
480
|
+
> change, and the consumer has already paid for this one. Recovery is a support
|
|
481
|
+
> request to OneAddress.
|
|
482
|
+
>
|
|
483
|
+
> This is why the staged rotation exists (see **Rotating your webhook secret**
|
|
484
|
+
> below): stage the new secret, deploy it alongside the current one so your
|
|
485
|
+
> receiver accepts BOTH, verify, and only then press Switch over. Done in that
|
|
486
|
+
> order a 401 never happens. Deploying the new secret before switching over is
|
|
487
|
+
> the sequence that produces one, and it costs the consumer their update.
|
|
488
|
+
>
|
|
489
|
+
> A run of 401s across several partners at once is an alert on OUR side - a
|
|
490
|
+
> broken signing deploy or an unsynced secret - and worth telling us about
|
|
491
|
+
> rather than waiting out.
|
|
492
|
+
|
|
493
|
+
Every 4xx EXCEPT 401 and 403 is filed as "partner error" and retried; 401 and 403 are filed as "auth failed" and are not. Either way a 4xx you send deliberately reads, to the consumer, as a problem between you and OneAddress. Prefer a 500 for "try again" and a confirm of `no_match` for "not my customer".
|
|
473
494
|
|
|
474
495
|
---
|
|
475
496
|
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
encryptSessionForPartner,
|
|
4
4
|
isFreshTimestamp,
|
|
5
5
|
isSafeWebhookUrl
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZY2K54LD.mjs";
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
9
|
import crypto from "crypto";
|
|
@@ -501,7 +501,7 @@ async function decryptAddress(payload, privateKeyPem, partnerId) {
|
|
|
501
501
|
return JSON.parse(new TextDecoder().decode(plaintext));
|
|
502
502
|
}
|
|
503
503
|
async function decryptSession(share, envelopeB64, privateKeyPem, partnerId, expectedAlg) {
|
|
504
|
-
const { decryptSession: decryptSessionCrypto } = await import("./src-
|
|
504
|
+
const { decryptSession: decryptSessionCrypto } = await import("./src-RBLFVBGY.mjs");
|
|
505
505
|
return decryptSessionCrypto(
|
|
506
506
|
share,
|
|
507
507
|
envelopeB64,
|
|
@@ -909,6 +909,21 @@ var InvalidUpdateTypesError = class extends Error {
|
|
|
909
909
|
this.name = "InvalidUpdateTypesError";
|
|
910
910
|
}
|
|
911
911
|
};
|
|
912
|
+
var MissingKeyError = class extends Error {
|
|
913
|
+
constructor(keyId) {
|
|
914
|
+
super(`[OneAddress SDK] no private key for key_id ${keyId}`);
|
|
915
|
+
this.keyId = keyId;
|
|
916
|
+
this.name = "MissingKeyError";
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
var SessionDecryptError = class extends Error {
|
|
920
|
+
constructor(keyId, detail) {
|
|
921
|
+
super(`[OneAddress SDK] session decrypt failed${keyId ? ` for key_id ${keyId}` : ""}`);
|
|
922
|
+
this.keyId = keyId;
|
|
923
|
+
this.detail = detail;
|
|
924
|
+
this.name = "SessionDecryptError";
|
|
925
|
+
}
|
|
926
|
+
};
|
|
912
927
|
function requireContactValue(kind, value) {
|
|
913
928
|
if (typeof value !== "string" || value === "") {
|
|
914
929
|
throw new Error(
|
|
@@ -1026,7 +1041,14 @@ function createOneAddressHandler(options) {
|
|
|
1026
1041
|
}
|
|
1027
1042
|
async function buildD5Pieces(body, partnerId) {
|
|
1028
1043
|
const share = body.session_key_share;
|
|
1029
|
-
const
|
|
1044
|
+
const shareKeyId = typeof share?.key_id === "string" ? share.key_id : "";
|
|
1045
|
+
if (keyId && shareKeyId && shareKeyId !== keyId) throw new MissingKeyError(shareKeyId);
|
|
1046
|
+
let data;
|
|
1047
|
+
try {
|
|
1048
|
+
data = await decryptSession(share, body.session_envelope, privateKeyPem, partnerId, expectedAlg);
|
|
1049
|
+
} catch (err) {
|
|
1050
|
+
throw new SessionDecryptError(shareKeyId, err instanceof Error ? err.message : String(err));
|
|
1051
|
+
}
|
|
1030
1052
|
const updateTypes = readUpdateTypes(data.update_types);
|
|
1031
1053
|
if (updateTypes === null) throw new InvalidUpdateTypesError(data.update_types);
|
|
1032
1054
|
const address = updateTypes.includes("address") ? validateAddress({
|
|
@@ -1159,6 +1181,22 @@ function createOneAddressHandler(options) {
|
|
|
1159
1181
|
detail: "update_types must be an array of " + UPDATE_TYPE_ORDER.join("|") + ". A name this build does not know was refused rather than dropped. Update @oneaddress/partner-sdk."
|
|
1160
1182
|
});
|
|
1161
1183
|
}
|
|
1184
|
+
if (err instanceof MissingKeyError) {
|
|
1185
|
+
console.error("[OneAddress SDK] Handler error:", err.message);
|
|
1186
|
+
return declared(503, {
|
|
1187
|
+
error: "missing_key",
|
|
1188
|
+
key_id: err.keyId,
|
|
1189
|
+
detail: "This receiver is configured for a different key_id and holds no private key for the one this dispatch names. Retry once the key is installed. If the key was retired and destroyed before its destroy_after date, it cannot be recovered from either side."
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
if (err instanceof SessionDecryptError) {
|
|
1193
|
+
console.error("[OneAddress SDK] Handler error:", err.detail);
|
|
1194
|
+
return declared(422, {
|
|
1195
|
+
error: "decrypt_failed",
|
|
1196
|
+
...err.keyId ? { key_id: err.keyId } : {},
|
|
1197
|
+
detail: err.detail
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1162
1200
|
throw err;
|
|
1163
1201
|
}
|
|
1164
1202
|
const notAccepted = d5.updateTypes.filter((t) => !acceptedUpdateTypes.includes(t));
|