@oneaddress/partner-sdk 2.9.0 → 2.10.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 +45 -1
- package/README.md +35 -0
- package/dist/{chunk-PP2TM7HN.mjs → chunk-JJ2B5VFO.mjs} +147 -25
- package/dist/{chunk-OKPEOGR5.mjs → chunk-NJGZ6ISS.mjs} +193 -11
- package/dist/edge.d.mts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +254 -35
- package/dist/edge.mjs +12 -2
- package/dist/index.d.mts +186 -1
- package/dist/index.d.ts +186 -1
- package/dist/index.js +360 -35
- package/dist/index.mjs +32 -2
- package/dist/{src-P3LR7F4A.mjs → src-XBG2QHG4.mjs} +11 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -213,6 +213,63 @@ declare function acceptTypedAliases(verifiedName: string, aliases: readonly unkn
|
|
|
213
213
|
declare const LOA_V2_REFUSALS: readonly ["loa_v2_malformed", "loa_v2_signature_invalid", "loa_v2_partner_mismatch", "loa_v2_update_mismatch", "loa_v2_envelope_mismatch", "loa_v2_name_mismatch"];
|
|
214
214
|
type LoaV2Refusal = typeof LOA_V2_REFUSALS[number];
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* The verification commitment (3 Nov 2026, new-matter register row of that date).
|
|
218
|
+
*
|
|
219
|
+
* A receiver that decrypts an indexed `address.test` answers
|
|
220
|
+
* `{ verification: true, index, commitment }`, where
|
|
221
|
+
*
|
|
222
|
+
* commitment = lowercase hex HMAC-SHA256(webhook_secret, verificationCommitmentString(...))
|
|
223
|
+
*
|
|
224
|
+
* and the relay builds the same string over the record it fabricated and
|
|
225
|
+
* compares in constant time. The name and address travel only inside the sealed
|
|
226
|
+
* envelope, so nobody can compute the commitment without decrypting; the secret
|
|
227
|
+
* means only the partner's own receiver can answer; the verification id and
|
|
228
|
+
* index stop an earlier answer being replayed.
|
|
229
|
+
*
|
|
230
|
+
* ONE STRING BUILDER, AND IT IS THIS ONE. The 20 Aug 2026 connection
|
|
231
|
+
* verification failed 0 of 5 because the two sides normalised differently (one
|
|
232
|
+
* dropped the country token, the other kept it). So the normalisation is part
|
|
233
|
+
* of the wire contract, defined here once, and every implementation is pinned
|
|
234
|
+
* to `verification_commitment` in `test-vectors.json`: the relay, the TS SDK,
|
|
235
|
+
* the drop-in receiver, conformance and the test receiver import this function,
|
|
236
|
+
* and the Python, Go, Java and C# SDKs reproduce it byte for byte against the
|
|
237
|
+
* same vectors.
|
|
238
|
+
*
|
|
239
|
+
* Inputs are STRUCTURED fields taken from the decrypted envelope, never a
|
|
240
|
+
* formatted one-line address, because a formatter is exactly where two sides
|
|
241
|
+
* drift. Normalisation is deliberately small and ASCII-only so it is identical
|
|
242
|
+
* in every language: a non-string is the empty string; runs of ASCII whitespace
|
|
243
|
+
* (space, tab, LF, VT, FF, CR) become one space; leading and trailing spaces
|
|
244
|
+
* are removed. No case folding and no Unicode normalisation: both sides start
|
|
245
|
+
* from the same decrypted UTF-8 bytes, and either step is a place for two
|
|
246
|
+
* runtimes to disagree.
|
|
247
|
+
*
|
|
248
|
+
* The leading `oa-verify.v1` line keeps this string disjoint from the webhook
|
|
249
|
+
* signing string `${timestamp}.${body}`, whose first character is a digit, so
|
|
250
|
+
* the two HMACs under one secret can never stand in for each other.
|
|
251
|
+
*/
|
|
252
|
+
declare const VERIFICATION_COMMITMENT_VERSION = "oa-verify.v1";
|
|
253
|
+
/** The decrypted fields a commitment covers, read from the session envelope. */
|
|
254
|
+
interface VerificationCommitmentRecord {
|
|
255
|
+
/** `verified_name` from the envelope. */
|
|
256
|
+
name: unknown;
|
|
257
|
+
/** `new_address.street` (the drop-in receiver calls it `line1`). */
|
|
258
|
+
street: unknown;
|
|
259
|
+
suburb: unknown;
|
|
260
|
+
state: unknown;
|
|
261
|
+
postcode: unknown;
|
|
262
|
+
country: unknown;
|
|
263
|
+
}
|
|
264
|
+
/** The per-field normalisation. Part of the wire contract: see the file header. */
|
|
265
|
+
declare function normaliseCommitmentField(value: unknown): string;
|
|
266
|
+
/**
|
|
267
|
+
* The exact string a commitment is the HMAC of. Nine lines joined by `\n`:
|
|
268
|
+
* the version, the verification id, the decimal index, then name, street,
|
|
269
|
+
* suburb, state, postcode and country.
|
|
270
|
+
*/
|
|
271
|
+
declare function verificationCommitmentString(verificationId: string, index: number, record: VerificationCommitmentRecord): string;
|
|
272
|
+
|
|
216
273
|
/** True when a value looks like an email address rather than a person's name. */
|
|
217
274
|
declare function isEmailLike(value: string): boolean;
|
|
218
275
|
declare function namePoolMatches(providedNames: string[], storedName: string): boolean;
|
|
@@ -561,6 +618,74 @@ declare function parsePinnedRegistryRoots(raw: string | undefined | null): {
|
|
|
561
618
|
*/
|
|
562
619
|
declare function checkRegistryHead(opts: RegistryHeadCheckOptions): Promise<RegistryHeadCheckResult>;
|
|
563
620
|
|
|
621
|
+
/**
|
|
622
|
+
* Tells a partner that a newer SDK exists. Reads only, never installs.
|
|
623
|
+
*
|
|
624
|
+
* A receiver built on this SDK holds a decryption key, so it must never
|
|
625
|
+
* update itself: an auto-update is a path from whoever controls the registry
|
|
626
|
+
* to that key. This module asks the public npm registry for one version
|
|
627
|
+
* number, at most once a day, and logs one line when it is behind. Updating
|
|
628
|
+
* stays a change the partner reviews and deploys.
|
|
629
|
+
*
|
|
630
|
+
* What goes out: a GET of a public document, with no partner id, no customer
|
|
631
|
+
* data and no header identifying the installation. A refused connection, a
|
|
632
|
+
* proxy 403 or a timeout is reported as `unknown` and logs nothing.
|
|
633
|
+
* `ONEADDRESS_UPDATE_CHECK=off` turns it off.
|
|
634
|
+
*/
|
|
635
|
+
/** Must equal `version` in this package's package.json. Pinned by test. */
|
|
636
|
+
declare const SDK_VERSION = "2.10.0";
|
|
637
|
+
/** The partner guide's page on updating safely. Behind portal sign-in. */
|
|
638
|
+
declare const UPDATE_GUIDE_URL = "https://partners.oneaddress.io/#updating-safely";
|
|
639
|
+
type UpdateCheckState = 'current' | 'available' | 'unknown' | 'disabled';
|
|
640
|
+
interface UpdateCheckResult {
|
|
641
|
+
state: UpdateCheckState;
|
|
642
|
+
running: string;
|
|
643
|
+
/** Present when the registry answered with a valid version. */
|
|
644
|
+
latest?: string;
|
|
645
|
+
/** When the registry was last asked, ms since epoch. */
|
|
646
|
+
checkedAt?: number;
|
|
647
|
+
}
|
|
648
|
+
/** `off`, `never`, `0` and `false` turn the check off. Anything else leaves it on. */
|
|
649
|
+
declare function updateCheckEnabled(setting: string | undefined): boolean;
|
|
650
|
+
/** Numeric per field: a string compare puts 2.9.0 above 2.10.0. */
|
|
651
|
+
declare function isNewerVersion(latest: string, running: string): boolean;
|
|
652
|
+
/** The one log line. */
|
|
653
|
+
declare function updateAvailableLine(running: string, latest: string): string;
|
|
654
|
+
/**
|
|
655
|
+
* A Prometheus line for a receiver's `/metrics`: 1 when an update is
|
|
656
|
+
* available, 0 otherwise, with the two versions as labels. Both labels have
|
|
657
|
+
* already passed `parseVersion`, so they cannot carry a quote.
|
|
658
|
+
*/
|
|
659
|
+
declare function updateCheckMetric(result: UpdateCheckResult, product?: string): string;
|
|
660
|
+
interface CheckForUpdateOptions {
|
|
661
|
+
running?: string;
|
|
662
|
+
registryUrl?: string;
|
|
663
|
+
fetchImpl?: typeof fetch;
|
|
664
|
+
timeoutMs?: number;
|
|
665
|
+
env?: Record<string, string | undefined>;
|
|
666
|
+
now?: () => number;
|
|
667
|
+
}
|
|
668
|
+
/** One bounded request. Never throws. */
|
|
669
|
+
declare function checkForUpdate(opts?: CheckForUpdateOptions): Promise<UpdateCheckResult>;
|
|
670
|
+
interface StartUpdateCheckOptions extends CheckForUpdateOptions {
|
|
671
|
+
/** Where the one line goes. Defaults to `console.warn`. */
|
|
672
|
+
log?: (line: string) => void;
|
|
673
|
+
/** Called after every check, for a `/ready` field or a metric. */
|
|
674
|
+
onResult?: (result: UpdateCheckResult) => void;
|
|
675
|
+
/** Defaults to 24 hours. Values under an hour are raised to an hour. */
|
|
676
|
+
intervalMs?: number;
|
|
677
|
+
}
|
|
678
|
+
interface UpdateCheckHandle {
|
|
679
|
+
/** The most recent result, `unknown` until the first check finishes. */
|
|
680
|
+
current(): UpdateCheckResult;
|
|
681
|
+
stop(): void;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Checks now, then once a day, without holding the process open. The line is
|
|
685
|
+
* logged once per newer version found, not on every check.
|
|
686
|
+
*/
|
|
687
|
+
declare function startUpdateCheck(opts?: StartUpdateCheckOptions): UpdateCheckHandle;
|
|
688
|
+
|
|
564
689
|
/**
|
|
565
690
|
* @oneaddress/partner-sdk
|
|
566
691
|
*
|
|
@@ -864,6 +989,13 @@ interface OneAddressUpdateEvent {
|
|
|
864
989
|
* is refused with 400 before this callback runs.
|
|
865
990
|
*/
|
|
866
991
|
effective_date?: string;
|
|
992
|
+
/**
|
|
993
|
+
* The product line this customer's account sits under, when you have set up
|
|
994
|
+
* product lines in the partner portal: route on `product.code`. `null` for a
|
|
995
|
+
* plain account and on every legacy dispatch. A malformed sealed value is
|
|
996
|
+
* also `null` (logged as a warning), and the update is still delivered here.
|
|
997
|
+
*/
|
|
998
|
+
product?: OneAddressProduct | null;
|
|
867
999
|
/** Raw decrypted + parsed payload (in case fields are extended) */
|
|
868
1000
|
raw: Record<string, unknown>;
|
|
869
1001
|
}
|
|
@@ -1563,6 +1695,33 @@ declare function signPullRequest(opts: {
|
|
|
1563
1695
|
* if (!ok) return res.status(401).end();
|
|
1564
1696
|
*/
|
|
1565
1697
|
declare function verifyWithGrace(rawBody: string, timestamp: string, signature: string, currentSecret: string, previousSecret?: string, graceUntil?: string | number): boolean;
|
|
1698
|
+
/**
|
|
1699
|
+
* The secret that verified this request, or null when neither did. Same rule
|
|
1700
|
+
* as {@link verifyWithGrace}, which is a wrapper over it, so the two cannot
|
|
1701
|
+
* disagree about which requests are authentic.
|
|
1702
|
+
*
|
|
1703
|
+
* It exists for the connection-verification commitment: the receiver keys its
|
|
1704
|
+
* answer with the secret the relay SIGNED with, and during a rotation grace
|
|
1705
|
+
* window that may be the previous one. Committing under the current secret
|
|
1706
|
+
* then would turn a correctly decrypted probe into a mismatch.
|
|
1707
|
+
*/
|
|
1708
|
+
declare function matchingWebhookSecret(rawBody: string, timestamp: string, signature: string, currentSecret: string, previousSecret?: string, graceUntil?: string | number): string | null;
|
|
1709
|
+
/**
|
|
1710
|
+
* The connection-verification commitment (3 Nov 2026): lowercase hex
|
|
1711
|
+
* HMAC-SHA256 under the webhook secret of the shared canonical string over the
|
|
1712
|
+
* verification id, the record index and the DECRYPTED name and structured
|
|
1713
|
+
* address. A receiver returns it as `commitment` beside `verification: true`
|
|
1714
|
+
* when it answers an indexed `address.test`, and OneAddress recomputes it over
|
|
1715
|
+
* the record it sent. It cannot be produced without decrypting the envelope,
|
|
1716
|
+
* which is the point: `verification: true` on its own is only a claim.
|
|
1717
|
+
*
|
|
1718
|
+
* `createOneAddressHandler` does this for you when `onTest` is wired. Call it
|
|
1719
|
+
* yourself only if you answer `address.test` without the handler, passing the
|
|
1720
|
+
* secret that verified the request's signature (see {@link matchingWebhookSecret})
|
|
1721
|
+
* and the fields exactly as decrypted: `verified_name`, and `new_address`'s
|
|
1722
|
+
* `street`, `suburb`, `state`, `postcode` and `country`.
|
|
1723
|
+
*/
|
|
1724
|
+
declare function computeVerificationCommitment(secret: string, verificationId: string, index: number, record: VerificationCommitmentRecord): string;
|
|
1566
1725
|
/**
|
|
1567
1726
|
* Decrypt an ECDH P-256 + HKDF-SHA256 + AES-256-GCM encrypted address payload.
|
|
1568
1727
|
*
|
|
@@ -1711,7 +1870,33 @@ interface SessionData {
|
|
|
1711
1870
|
* `effective_date` differs from this one, or where only one is present.
|
|
1712
1871
|
*/
|
|
1713
1872
|
effective_date?: string;
|
|
1873
|
+
/**
|
|
1874
|
+
* The partner product line this account sits under, sealed beside
|
|
1875
|
+
* `account_number`. Route on `code`. Absent for a plain account.
|
|
1876
|
+
* {@link decryptSession} reads it tolerantly: a malformed value comes back
|
|
1877
|
+
* as `null` and the update is still handled. See {@link readSessionProduct}.
|
|
1878
|
+
*/
|
|
1879
|
+
product?: OneAddressProduct | null;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* One of your product lines, as sealed in the session envelope. `code` is your
|
|
1883
|
+
* own routing key and survives a rename; `id` is stable; `name` is the display
|
|
1884
|
+
* name at the time of sealing.
|
|
1885
|
+
*/
|
|
1886
|
+
interface OneAddressProduct {
|
|
1887
|
+
id: string;
|
|
1888
|
+
code: string;
|
|
1889
|
+
name: string;
|
|
1714
1890
|
}
|
|
1891
|
+
/** What a product `code` must look like for this SDK to expose it. */
|
|
1892
|
+
declare const PRODUCT_CODE_PATTERN: RegExp;
|
|
1893
|
+
/**
|
|
1894
|
+
* Read a sealed `product` tolerantly. Anything that is not an object with a
|
|
1895
|
+
* string `id` and a string `code` matching {@link PRODUCT_CODE_PATTERN} is
|
|
1896
|
+
* `null`, never an error: refusing a change of address over a routing hint
|
|
1897
|
+
* would lose the change. A missing or empty `name` reads as the `code`.
|
|
1898
|
+
*/
|
|
1899
|
+
declare function readSessionProduct(raw: unknown): OneAddressProduct | null;
|
|
1715
1900
|
/**
|
|
1716
1901
|
* Decrypt a D5 session envelope using your retained private key matching
|
|
1717
1902
|
* `share.key_id`.
|
|
@@ -2675,4 +2860,4 @@ interface SignedTestWebhook {
|
|
|
2675
2860
|
*/
|
|
2676
2861
|
declare function buildSignedTestWebhook(opts: SignedTestWebhookOptions): Promise<SignedTestWebhook>;
|
|
2677
2862
|
|
|
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 };
|
|
2863
|
+
export { type AddressParts, type BlindIndexField, CURRENT_VERSION, type CheckForUpdateOptions, 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 OneAddressProduct, type OneAddressTestEvent, type OneAddressUpdateEvent, type OneAddressVerifyEvent, type OutboxBacklog, type OutboxConsumer, type OutboxConsumerOptions, type OutboxDialect, type OutboxQueryFn, type OutboxRow, PRODUCT_CODE_PATTERN, type PinnedRegistryRoot, type PrivateKeyOperations, type RegistryHeadCheckOptions, type RegistryHeadCheckResult, type RegistryHeadCheckVerdict, SDK_VERSION, SUPPORTED_VERSIONS, type SessionData, type SessionKeyShare, type SessionUpdateType, type SignedTestWebhook, type SignedTestWebhookOptions, type StartUpdateCheckOptions, UPDATE_GUIDE_URL, type UpdateCheckHandle, type UpdateCheckResult, type UpdateCheckState, VERIFICATION_COMMITMENT_VERSION, type VerificationCommitmentRecord, type VerifyResultCallbackParams, _resetLoaKeyCacheForTests, _resetOnceWarningsForTests, acceptTypedAliases, assertEffectiveDateBound, buildSignedTestWebhook, cachedLoaPublicKey, canonicalD5LoaForm, canonicalD5LoaFormV2, checkForUpdate, checkLoaV2, checkRegistryHead, compareAddresses, computeBlindIndex, computeVerificationCommitment, confirmUpdate, createOneAddressHandler, createOutboxConsumer, createSqlIdempotencyStore, d5LoaRef, decryptAddress as decrypt, decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, formatAddressParts, fromOutboxTimestamp, hasLoaV2, isAcceptableAlias, isEmailLike, isFreshTimestamp, isNewerVersion, loaEnvelopeSha256, loaFirstName, loaNamesMatch, loaSurname, matchingWebhookSecret, namePoolMatches, normaliseCommitmentField, normaliseLoaName, normalizeForBlindIndex, parsePinnedRegistryRoots, readAddressParts, readSessionProduct, sendVerifyResult, signPullRequest, startUpdateCheck, toExpressHandler, toOutboxTimestamp, transformAddress as transform, transformAddress, transformSession, typedAliasesOf, updateAvailableLine, updateCheckEnabled, updateCheckMetric, validateAddress, verificationCommitmentString, verifySignature as verify, verifyD5LOA, verifyD5LOAv2, verifyWithGrace as verifyGrace, verifyLOA, verifySignature, verifyWithGrace };
|
package/dist/index.d.ts
CHANGED
|
@@ -213,6 +213,63 @@ declare function acceptTypedAliases(verifiedName: string, aliases: readonly unkn
|
|
|
213
213
|
declare const LOA_V2_REFUSALS: readonly ["loa_v2_malformed", "loa_v2_signature_invalid", "loa_v2_partner_mismatch", "loa_v2_update_mismatch", "loa_v2_envelope_mismatch", "loa_v2_name_mismatch"];
|
|
214
214
|
type LoaV2Refusal = typeof LOA_V2_REFUSALS[number];
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* The verification commitment (3 Nov 2026, new-matter register row of that date).
|
|
218
|
+
*
|
|
219
|
+
* A receiver that decrypts an indexed `address.test` answers
|
|
220
|
+
* `{ verification: true, index, commitment }`, where
|
|
221
|
+
*
|
|
222
|
+
* commitment = lowercase hex HMAC-SHA256(webhook_secret, verificationCommitmentString(...))
|
|
223
|
+
*
|
|
224
|
+
* and the relay builds the same string over the record it fabricated and
|
|
225
|
+
* compares in constant time. The name and address travel only inside the sealed
|
|
226
|
+
* envelope, so nobody can compute the commitment without decrypting; the secret
|
|
227
|
+
* means only the partner's own receiver can answer; the verification id and
|
|
228
|
+
* index stop an earlier answer being replayed.
|
|
229
|
+
*
|
|
230
|
+
* ONE STRING BUILDER, AND IT IS THIS ONE. The 20 Aug 2026 connection
|
|
231
|
+
* verification failed 0 of 5 because the two sides normalised differently (one
|
|
232
|
+
* dropped the country token, the other kept it). So the normalisation is part
|
|
233
|
+
* of the wire contract, defined here once, and every implementation is pinned
|
|
234
|
+
* to `verification_commitment` in `test-vectors.json`: the relay, the TS SDK,
|
|
235
|
+
* the drop-in receiver, conformance and the test receiver import this function,
|
|
236
|
+
* and the Python, Go, Java and C# SDKs reproduce it byte for byte against the
|
|
237
|
+
* same vectors.
|
|
238
|
+
*
|
|
239
|
+
* Inputs are STRUCTURED fields taken from the decrypted envelope, never a
|
|
240
|
+
* formatted one-line address, because a formatter is exactly where two sides
|
|
241
|
+
* drift. Normalisation is deliberately small and ASCII-only so it is identical
|
|
242
|
+
* in every language: a non-string is the empty string; runs of ASCII whitespace
|
|
243
|
+
* (space, tab, LF, VT, FF, CR) become one space; leading and trailing spaces
|
|
244
|
+
* are removed. No case folding and no Unicode normalisation: both sides start
|
|
245
|
+
* from the same decrypted UTF-8 bytes, and either step is a place for two
|
|
246
|
+
* runtimes to disagree.
|
|
247
|
+
*
|
|
248
|
+
* The leading `oa-verify.v1` line keeps this string disjoint from the webhook
|
|
249
|
+
* signing string `${timestamp}.${body}`, whose first character is a digit, so
|
|
250
|
+
* the two HMACs under one secret can never stand in for each other.
|
|
251
|
+
*/
|
|
252
|
+
declare const VERIFICATION_COMMITMENT_VERSION = "oa-verify.v1";
|
|
253
|
+
/** The decrypted fields a commitment covers, read from the session envelope. */
|
|
254
|
+
interface VerificationCommitmentRecord {
|
|
255
|
+
/** `verified_name` from the envelope. */
|
|
256
|
+
name: unknown;
|
|
257
|
+
/** `new_address.street` (the drop-in receiver calls it `line1`). */
|
|
258
|
+
street: unknown;
|
|
259
|
+
suburb: unknown;
|
|
260
|
+
state: unknown;
|
|
261
|
+
postcode: unknown;
|
|
262
|
+
country: unknown;
|
|
263
|
+
}
|
|
264
|
+
/** The per-field normalisation. Part of the wire contract: see the file header. */
|
|
265
|
+
declare function normaliseCommitmentField(value: unknown): string;
|
|
266
|
+
/**
|
|
267
|
+
* The exact string a commitment is the HMAC of. Nine lines joined by `\n`:
|
|
268
|
+
* the version, the verification id, the decimal index, then name, street,
|
|
269
|
+
* suburb, state, postcode and country.
|
|
270
|
+
*/
|
|
271
|
+
declare function verificationCommitmentString(verificationId: string, index: number, record: VerificationCommitmentRecord): string;
|
|
272
|
+
|
|
216
273
|
/** True when a value looks like an email address rather than a person's name. */
|
|
217
274
|
declare function isEmailLike(value: string): boolean;
|
|
218
275
|
declare function namePoolMatches(providedNames: string[], storedName: string): boolean;
|
|
@@ -561,6 +618,74 @@ declare function parsePinnedRegistryRoots(raw: string | undefined | null): {
|
|
|
561
618
|
*/
|
|
562
619
|
declare function checkRegistryHead(opts: RegistryHeadCheckOptions): Promise<RegistryHeadCheckResult>;
|
|
563
620
|
|
|
621
|
+
/**
|
|
622
|
+
* Tells a partner that a newer SDK exists. Reads only, never installs.
|
|
623
|
+
*
|
|
624
|
+
* A receiver built on this SDK holds a decryption key, so it must never
|
|
625
|
+
* update itself: an auto-update is a path from whoever controls the registry
|
|
626
|
+
* to that key. This module asks the public npm registry for one version
|
|
627
|
+
* number, at most once a day, and logs one line when it is behind. Updating
|
|
628
|
+
* stays a change the partner reviews and deploys.
|
|
629
|
+
*
|
|
630
|
+
* What goes out: a GET of a public document, with no partner id, no customer
|
|
631
|
+
* data and no header identifying the installation. A refused connection, a
|
|
632
|
+
* proxy 403 or a timeout is reported as `unknown` and logs nothing.
|
|
633
|
+
* `ONEADDRESS_UPDATE_CHECK=off` turns it off.
|
|
634
|
+
*/
|
|
635
|
+
/** Must equal `version` in this package's package.json. Pinned by test. */
|
|
636
|
+
declare const SDK_VERSION = "2.10.0";
|
|
637
|
+
/** The partner guide's page on updating safely. Behind portal sign-in. */
|
|
638
|
+
declare const UPDATE_GUIDE_URL = "https://partners.oneaddress.io/#updating-safely";
|
|
639
|
+
type UpdateCheckState = 'current' | 'available' | 'unknown' | 'disabled';
|
|
640
|
+
interface UpdateCheckResult {
|
|
641
|
+
state: UpdateCheckState;
|
|
642
|
+
running: string;
|
|
643
|
+
/** Present when the registry answered with a valid version. */
|
|
644
|
+
latest?: string;
|
|
645
|
+
/** When the registry was last asked, ms since epoch. */
|
|
646
|
+
checkedAt?: number;
|
|
647
|
+
}
|
|
648
|
+
/** `off`, `never`, `0` and `false` turn the check off. Anything else leaves it on. */
|
|
649
|
+
declare function updateCheckEnabled(setting: string | undefined): boolean;
|
|
650
|
+
/** Numeric per field: a string compare puts 2.9.0 above 2.10.0. */
|
|
651
|
+
declare function isNewerVersion(latest: string, running: string): boolean;
|
|
652
|
+
/** The one log line. */
|
|
653
|
+
declare function updateAvailableLine(running: string, latest: string): string;
|
|
654
|
+
/**
|
|
655
|
+
* A Prometheus line for a receiver's `/metrics`: 1 when an update is
|
|
656
|
+
* available, 0 otherwise, with the two versions as labels. Both labels have
|
|
657
|
+
* already passed `parseVersion`, so they cannot carry a quote.
|
|
658
|
+
*/
|
|
659
|
+
declare function updateCheckMetric(result: UpdateCheckResult, product?: string): string;
|
|
660
|
+
interface CheckForUpdateOptions {
|
|
661
|
+
running?: string;
|
|
662
|
+
registryUrl?: string;
|
|
663
|
+
fetchImpl?: typeof fetch;
|
|
664
|
+
timeoutMs?: number;
|
|
665
|
+
env?: Record<string, string | undefined>;
|
|
666
|
+
now?: () => number;
|
|
667
|
+
}
|
|
668
|
+
/** One bounded request. Never throws. */
|
|
669
|
+
declare function checkForUpdate(opts?: CheckForUpdateOptions): Promise<UpdateCheckResult>;
|
|
670
|
+
interface StartUpdateCheckOptions extends CheckForUpdateOptions {
|
|
671
|
+
/** Where the one line goes. Defaults to `console.warn`. */
|
|
672
|
+
log?: (line: string) => void;
|
|
673
|
+
/** Called after every check, for a `/ready` field or a metric. */
|
|
674
|
+
onResult?: (result: UpdateCheckResult) => void;
|
|
675
|
+
/** Defaults to 24 hours. Values under an hour are raised to an hour. */
|
|
676
|
+
intervalMs?: number;
|
|
677
|
+
}
|
|
678
|
+
interface UpdateCheckHandle {
|
|
679
|
+
/** The most recent result, `unknown` until the first check finishes. */
|
|
680
|
+
current(): UpdateCheckResult;
|
|
681
|
+
stop(): void;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Checks now, then once a day, without holding the process open. The line is
|
|
685
|
+
* logged once per newer version found, not on every check.
|
|
686
|
+
*/
|
|
687
|
+
declare function startUpdateCheck(opts?: StartUpdateCheckOptions): UpdateCheckHandle;
|
|
688
|
+
|
|
564
689
|
/**
|
|
565
690
|
* @oneaddress/partner-sdk
|
|
566
691
|
*
|
|
@@ -864,6 +989,13 @@ interface OneAddressUpdateEvent {
|
|
|
864
989
|
* is refused with 400 before this callback runs.
|
|
865
990
|
*/
|
|
866
991
|
effective_date?: string;
|
|
992
|
+
/**
|
|
993
|
+
* The product line this customer's account sits under, when you have set up
|
|
994
|
+
* product lines in the partner portal: route on `product.code`. `null` for a
|
|
995
|
+
* plain account and on every legacy dispatch. A malformed sealed value is
|
|
996
|
+
* also `null` (logged as a warning), and the update is still delivered here.
|
|
997
|
+
*/
|
|
998
|
+
product?: OneAddressProduct | null;
|
|
867
999
|
/** Raw decrypted + parsed payload (in case fields are extended) */
|
|
868
1000
|
raw: Record<string, unknown>;
|
|
869
1001
|
}
|
|
@@ -1563,6 +1695,33 @@ declare function signPullRequest(opts: {
|
|
|
1563
1695
|
* if (!ok) return res.status(401).end();
|
|
1564
1696
|
*/
|
|
1565
1697
|
declare function verifyWithGrace(rawBody: string, timestamp: string, signature: string, currentSecret: string, previousSecret?: string, graceUntil?: string | number): boolean;
|
|
1698
|
+
/**
|
|
1699
|
+
* The secret that verified this request, or null when neither did. Same rule
|
|
1700
|
+
* as {@link verifyWithGrace}, which is a wrapper over it, so the two cannot
|
|
1701
|
+
* disagree about which requests are authentic.
|
|
1702
|
+
*
|
|
1703
|
+
* It exists for the connection-verification commitment: the receiver keys its
|
|
1704
|
+
* answer with the secret the relay SIGNED with, and during a rotation grace
|
|
1705
|
+
* window that may be the previous one. Committing under the current secret
|
|
1706
|
+
* then would turn a correctly decrypted probe into a mismatch.
|
|
1707
|
+
*/
|
|
1708
|
+
declare function matchingWebhookSecret(rawBody: string, timestamp: string, signature: string, currentSecret: string, previousSecret?: string, graceUntil?: string | number): string | null;
|
|
1709
|
+
/**
|
|
1710
|
+
* The connection-verification commitment (3 Nov 2026): lowercase hex
|
|
1711
|
+
* HMAC-SHA256 under the webhook secret of the shared canonical string over the
|
|
1712
|
+
* verification id, the record index and the DECRYPTED name and structured
|
|
1713
|
+
* address. A receiver returns it as `commitment` beside `verification: true`
|
|
1714
|
+
* when it answers an indexed `address.test`, and OneAddress recomputes it over
|
|
1715
|
+
* the record it sent. It cannot be produced without decrypting the envelope,
|
|
1716
|
+
* which is the point: `verification: true` on its own is only a claim.
|
|
1717
|
+
*
|
|
1718
|
+
* `createOneAddressHandler` does this for you when `onTest` is wired. Call it
|
|
1719
|
+
* yourself only if you answer `address.test` without the handler, passing the
|
|
1720
|
+
* secret that verified the request's signature (see {@link matchingWebhookSecret})
|
|
1721
|
+
* and the fields exactly as decrypted: `verified_name`, and `new_address`'s
|
|
1722
|
+
* `street`, `suburb`, `state`, `postcode` and `country`.
|
|
1723
|
+
*/
|
|
1724
|
+
declare function computeVerificationCommitment(secret: string, verificationId: string, index: number, record: VerificationCommitmentRecord): string;
|
|
1566
1725
|
/**
|
|
1567
1726
|
* Decrypt an ECDH P-256 + HKDF-SHA256 + AES-256-GCM encrypted address payload.
|
|
1568
1727
|
*
|
|
@@ -1711,7 +1870,33 @@ interface SessionData {
|
|
|
1711
1870
|
* `effective_date` differs from this one, or where only one is present.
|
|
1712
1871
|
*/
|
|
1713
1872
|
effective_date?: string;
|
|
1873
|
+
/**
|
|
1874
|
+
* The partner product line this account sits under, sealed beside
|
|
1875
|
+
* `account_number`. Route on `code`. Absent for a plain account.
|
|
1876
|
+
* {@link decryptSession} reads it tolerantly: a malformed value comes back
|
|
1877
|
+
* as `null` and the update is still handled. See {@link readSessionProduct}.
|
|
1878
|
+
*/
|
|
1879
|
+
product?: OneAddressProduct | null;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* One of your product lines, as sealed in the session envelope. `code` is your
|
|
1883
|
+
* own routing key and survives a rename; `id` is stable; `name` is the display
|
|
1884
|
+
* name at the time of sealing.
|
|
1885
|
+
*/
|
|
1886
|
+
interface OneAddressProduct {
|
|
1887
|
+
id: string;
|
|
1888
|
+
code: string;
|
|
1889
|
+
name: string;
|
|
1714
1890
|
}
|
|
1891
|
+
/** What a product `code` must look like for this SDK to expose it. */
|
|
1892
|
+
declare const PRODUCT_CODE_PATTERN: RegExp;
|
|
1893
|
+
/**
|
|
1894
|
+
* Read a sealed `product` tolerantly. Anything that is not an object with a
|
|
1895
|
+
* string `id` and a string `code` matching {@link PRODUCT_CODE_PATTERN} is
|
|
1896
|
+
* `null`, never an error: refusing a change of address over a routing hint
|
|
1897
|
+
* would lose the change. A missing or empty `name` reads as the `code`.
|
|
1898
|
+
*/
|
|
1899
|
+
declare function readSessionProduct(raw: unknown): OneAddressProduct | null;
|
|
1715
1900
|
/**
|
|
1716
1901
|
* Decrypt a D5 session envelope using your retained private key matching
|
|
1717
1902
|
* `share.key_id`.
|
|
@@ -2675,4 +2860,4 @@ interface SignedTestWebhook {
|
|
|
2675
2860
|
*/
|
|
2676
2861
|
declare function buildSignedTestWebhook(opts: SignedTestWebhookOptions): Promise<SignedTestWebhook>;
|
|
2677
2862
|
|
|
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 };
|
|
2863
|
+
export { type AddressParts, type BlindIndexField, CURRENT_VERSION, type CheckForUpdateOptions, 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 OneAddressProduct, type OneAddressTestEvent, type OneAddressUpdateEvent, type OneAddressVerifyEvent, type OutboxBacklog, type OutboxConsumer, type OutboxConsumerOptions, type OutboxDialect, type OutboxQueryFn, type OutboxRow, PRODUCT_CODE_PATTERN, type PinnedRegistryRoot, type PrivateKeyOperations, type RegistryHeadCheckOptions, type RegistryHeadCheckResult, type RegistryHeadCheckVerdict, SDK_VERSION, SUPPORTED_VERSIONS, type SessionData, type SessionKeyShare, type SessionUpdateType, type SignedTestWebhook, type SignedTestWebhookOptions, type StartUpdateCheckOptions, UPDATE_GUIDE_URL, type UpdateCheckHandle, type UpdateCheckResult, type UpdateCheckState, VERIFICATION_COMMITMENT_VERSION, type VerificationCommitmentRecord, type VerifyResultCallbackParams, _resetLoaKeyCacheForTests, _resetOnceWarningsForTests, acceptTypedAliases, assertEffectiveDateBound, buildSignedTestWebhook, cachedLoaPublicKey, canonicalD5LoaForm, canonicalD5LoaFormV2, checkForUpdate, checkLoaV2, checkRegistryHead, compareAddresses, computeBlindIndex, computeVerificationCommitment, confirmUpdate, createOneAddressHandler, createOutboxConsumer, createSqlIdempotencyStore, d5LoaRef, decryptAddress as decrypt, decryptAddress, decryptLoaEncrypted, decryptSession, fetchLoaPublicKey, findMatchingStoredName, formatAddressParts, fromOutboxTimestamp, hasLoaV2, isAcceptableAlias, isEmailLike, isFreshTimestamp, isNewerVersion, loaEnvelopeSha256, loaFirstName, loaNamesMatch, loaSurname, matchingWebhookSecret, namePoolMatches, normaliseCommitmentField, normaliseLoaName, normalizeForBlindIndex, parsePinnedRegistryRoots, readAddressParts, readSessionProduct, sendVerifyResult, signPullRequest, startUpdateCheck, toExpressHandler, toOutboxTimestamp, transformAddress as transform, transformAddress, transformSession, typedAliasesOf, updateAvailableLine, updateCheckEnabled, updateCheckMetric, validateAddress, verificationCommitmentString, verifySignature as verify, verifyD5LOA, verifyD5LOAv2, verifyWithGrace as verifyGrace, verifyLOA, verifySignature, verifyWithGrace };
|