@oneaddress/partner-sdk 1.8.0 → 2.0.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 +52 -0
- package/LICENSE +201 -0
- package/README.md +99 -1
- package/dist/{chunk-O2D5XGSN.mjs → chunk-DUVPNFU6.mjs} +146 -7
- package/dist/{chunk-PUB6ZVJ2.mjs → chunk-UPJU4HFR.mjs} +131 -39
- package/dist/edge.d.mts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +283 -45
- package/dist/edge.mjs +2 -2
- package/dist/index.d.mts +130 -6
- package/dist/index.d.ts +130 -6
- package/dist/index.js +283 -45
- package/dist/index.mjs +2 -2
- package/dist/{src-UOJOUUGB.mjs → src-UACTYQGX.mjs} +15 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -429,7 +429,14 @@ interface OneAddressIdVerification {
|
|
|
429
429
|
platform: string;
|
|
430
430
|
}
|
|
431
431
|
interface OneAddressUpdateEvent {
|
|
432
|
-
|
|
432
|
+
/**
|
|
433
|
+
* `address.updated` when the dispatch carries an address (alone or beside a
|
|
434
|
+
* contact detail); `contact.updated` when it carries no address at all. Both
|
|
435
|
+
* reach `onUpdate`: from a receiver's side each means "apply these new values
|
|
436
|
+
* to this customer", and two callbacks invite an integration that implements
|
|
437
|
+
* one and quietly ignores the other. Route on `update_types`, not on this.
|
|
438
|
+
*/
|
|
439
|
+
event: 'address.updated' | 'contact.updated';
|
|
433
440
|
version: string;
|
|
434
441
|
id: string;
|
|
435
442
|
timestamp: number;
|
|
@@ -462,7 +469,36 @@ interface OneAddressUpdateEvent {
|
|
|
462
469
|
* Kept on the type for backwards compatibility with older payload shapes;
|
|
463
470
|
* do not rely on it. See {@link OneAddressCustomerMatch}. */
|
|
464
471
|
customer_match?: OneAddressCustomerMatch;
|
|
465
|
-
|
|
472
|
+
/**
|
|
473
|
+
* Which kinds of detail this dispatch carries, read LITERALLY off the
|
|
474
|
+
* decrypted envelope. Absent on the wire means `['address']`: every envelope
|
|
475
|
+
* written before the field existed carried an address and nothing else.
|
|
476
|
+
*
|
|
477
|
+
* A phone-only update is `['phone']`, not `['address', 'phone']`; widening it
|
|
478
|
+
* would tell you an address changed when it did not. You only ever receive a
|
|
479
|
+
* kind you declared in {@link OneAddressHandlerOptions.acceptedUpdateTypes};
|
|
480
|
+
* anything else is refused with 422 before this callback runs.
|
|
481
|
+
*/
|
|
482
|
+
update_types: SessionUpdateType[];
|
|
483
|
+
/**
|
|
484
|
+
* The new postal address, decrypted. Present when `update_types` includes
|
|
485
|
+
* `'address'`, which is every dispatch that existed before September 2026.
|
|
486
|
+
*
|
|
487
|
+
* OPTIONAL because a contact-only update (`contact.updated`) genuinely has
|
|
488
|
+
* none, and an empty or stale placeholder would be worse: you could not tell
|
|
489
|
+
* it from an instruction to overwrite. If your integration accepts addresses
|
|
490
|
+
* only (the default) it will never see the absent case, so narrow once:
|
|
491
|
+
* `const address = event.address; if (!address) throw new Error('no address');`
|
|
492
|
+
*/
|
|
493
|
+
address?: OneAddressAddress;
|
|
494
|
+
/** The new telephone number, E.164 (`+61412345678`). Present exactly when
|
|
495
|
+
* `update_types` includes `'phone'`, which requires you to have declared it.
|
|
496
|
+
* OneAddress has confirmed the consumer holds this number. */
|
|
497
|
+
new_phone?: string;
|
|
498
|
+
/** The new email address, lowercased. Present exactly when `update_types`
|
|
499
|
+
* includes `'email'`, which requires you to have declared it. OneAddress has
|
|
500
|
+
* confirmed the consumer receives mail there. */
|
|
501
|
+
new_email?: string;
|
|
466
502
|
/** The Letter of Authority. On D5 dispatches this is the structured
|
|
467
503
|
* {@link OneAddressD5LOA} recovered by decrypting `loa_encrypted`; on legacy
|
|
468
504
|
* dispatches it is the freeform {@link OneAddressLOA}. Verify with
|
|
@@ -583,6 +619,29 @@ interface OneAddressHandlerOptions {
|
|
|
583
619
|
webhookSecretGraceUntil?: string | number;
|
|
584
620
|
/** PKCS#8 PEM-encoded ECDH P-256 private key for address decryption */
|
|
585
621
|
privateKeyPem: string;
|
|
622
|
+
/**
|
|
623
|
+
* OPTIONAL — the `key_id` of the private key you hold (shown in the Partner
|
|
624
|
+
* Portal next to your encryption key). Set this to make key-rotation crossovers
|
|
625
|
+
* seamless.
|
|
626
|
+
*
|
|
627
|
+
* During a rotation OneAddress briefly sends the SAME update twice — once
|
|
628
|
+
* sealed to your OLD key and once to your NEW key — so a copy always arrives in
|
|
629
|
+
* a form you can open regardless of which key your receiver currently holds.
|
|
630
|
+
* Each copy names the other key_ids the update was also sent to
|
|
631
|
+
* (`crossover_key_ids`). When set, this handler SKIP-ACKS (200) a copy whose
|
|
632
|
+
* `session_key_share.key_id` is not yours **iff** your `keyId` is listed among
|
|
633
|
+
* those siblings — because a copy sealed to YOUR key is then guaranteed to
|
|
634
|
+
* arrive too. A single dispatch to a key_id you do not hold that names no such
|
|
635
|
+
* sibling still errors loudly, exactly as before, so a genuine
|
|
636
|
+
* misconfiguration is never silently swallowed.
|
|
637
|
+
*
|
|
638
|
+
* Leave it unset and behaviour is unchanged: a copy sealed to a key you do not
|
|
639
|
+
* hold fails to decrypt and returns 500 (OneAddress retries), which is today's
|
|
640
|
+
* behaviour — the verify-gate protects the cutover regardless. Set it to the
|
|
641
|
+
* key_id you actually hold; a value you do not hold a key for would cause every
|
|
642
|
+
* crossover copy naming it to be skipped with none arriving.
|
|
643
|
+
*/
|
|
644
|
+
keyId?: string;
|
|
586
645
|
/**
|
|
587
646
|
* OPTIONAL — OneAddress's ECDSA P-256 LOA signing public key (SPKI PEM), from
|
|
588
647
|
* {@link fetchLoaPublicKey}. Applies to `address.updated` ONLY (both the D5
|
|
@@ -713,6 +772,54 @@ interface OneAddressHandlerOptions {
|
|
|
713
772
|
* });
|
|
714
773
|
*/
|
|
715
774
|
idempotencyStore?: IdempotencyStore;
|
|
775
|
+
/**
|
|
776
|
+
* The kinds of changed detail this receiver's CODE can handle. Default
|
|
777
|
+
* `['address']`, so every integration written before September 2026 is
|
|
778
|
+
* unchanged.
|
|
779
|
+
*
|
|
780
|
+
* ── THIS IS A DECLARATION THE RELAY READS, NOT A FILTER ──────────────────
|
|
781
|
+
*
|
|
782
|
+
* The handler puts it in the body of every authenticated 2xx acknowledgement
|
|
783
|
+
* as `accepted_update_types`. The conformance run reads it off the first
|
|
784
|
+
* check, probes each kind you declared with a real contact-only envelope,
|
|
785
|
+
* probes one kind you did NOT declare and requires a refusal, and records the
|
|
786
|
+
* result. So the partner portal cannot promise a kind this code does not
|
|
787
|
+
* handle: what you ACCEPT in the portal is consent, what you declare HERE is
|
|
788
|
+
* capability, and a kind is dispatched only where both hold.
|
|
789
|
+
*
|
|
790
|
+
* ── WHAT HAPPENS TO A KIND YOU DID NOT DECLARE ───────────────────────────
|
|
791
|
+
*
|
|
792
|
+
* It is refused with `422 update_type_not_accepted` and `onUpdate` never
|
|
793
|
+
* runs. Acknowledging it would look identical to success on both sides while
|
|
794
|
+
* the consumer has already paid. The 4xx also leaves the dispatch incomplete
|
|
795
|
+
* in your idempotency store, so a retry after you widen this list is
|
|
796
|
+
* reprocessed rather than dismissed as a duplicate.
|
|
797
|
+
*
|
|
798
|
+
* `address` is always included whatever you pass, and a value the protocol
|
|
799
|
+
* does not define is dropped. Declare a kind only once `onUpdate` reads
|
|
800
|
+
* `event.new_phone` or `event.new_email` AND your storage has a column for it:
|
|
801
|
+
* the conformance run proves the envelope was accepted, not that the value
|
|
802
|
+
* was written.
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* createOneAddressHandler({
|
|
806
|
+
* webhookSecret, privateKeyPem,
|
|
807
|
+
* acceptedUpdateTypes: ['address', 'phone'],
|
|
808
|
+
* async onUpdate(event) {
|
|
809
|
+
* const account = event.customer?.account_number;
|
|
810
|
+
* if (!account) throw new Error('no account number');
|
|
811
|
+
* if (event.new_phone) await db.updatePhone(account, event.new_phone);
|
|
812
|
+
* if (event.address) await db.updateAddress(account, event.address);
|
|
813
|
+
* },
|
|
814
|
+
* });
|
|
815
|
+
*/
|
|
816
|
+
acceptedUpdateTypes?: readonly SessionUpdateType[];
|
|
817
|
+
/**
|
|
818
|
+
* Extra hostnames `sendVerifyResult` may POST an `address.verify` result to,
|
|
819
|
+
* beside `oneaddress.io` and its subdomains. For a staging or self-hosted
|
|
820
|
+
* relay ONLY. See {@link VerifyResultCallbackParams.allowedCallbackHosts}.
|
|
821
|
+
*/
|
|
822
|
+
allowedCallbackHosts?: readonly string[];
|
|
716
823
|
}
|
|
717
824
|
/**
|
|
718
825
|
* What a {@link IdempotencyStore.claim} call found.
|
|
@@ -889,9 +996,12 @@ interface SessionKeyShare {
|
|
|
889
996
|
/**
|
|
890
997
|
* The kinds of changed detail an envelope can carry.
|
|
891
998
|
*
|
|
892
|
-
* The vocabulary is closed.
|
|
893
|
-
*
|
|
894
|
-
*
|
|
999
|
+
* The vocabulary is closed. `createOneAddressHandler` REFUSES an envelope that
|
|
1000
|
+
* names a kind this build does not know (`422 invalid_update_types`) rather
|
|
1001
|
+
* than dropping the kind and processing the rest: a dropped kind is a dispatch
|
|
1002
|
+
* that charges the consumer, reports success and delivers less than they asked
|
|
1003
|
+
* for, and the 4xx is what makes OneAddress retry it once you have updated the
|
|
1004
|
+
* SDK. If you decrypt envelopes yourself with `decryptSession`, do the same.
|
|
895
1005
|
*/
|
|
896
1006
|
type SessionUpdateType = 'address' | 'phone' | 'email';
|
|
897
1007
|
interface SessionData {
|
|
@@ -992,6 +1102,12 @@ interface SessionData {
|
|
|
992
1102
|
* @param envelopeB64 - The `session_envelope` base64url string from the webhook.
|
|
993
1103
|
* @param privateKeyPem - Your PKCS#8 PEM private key whose key_id matches `share.key_id`.
|
|
994
1104
|
* @param partnerId - Your partner UUID (from the outer webhook payload).
|
|
1105
|
+
* @param expectedAlg - OPTIONAL. The wrap algorithm this key was provisioned
|
|
1106
|
+
* for. When supplied, a `share.alg` that differs is refused
|
|
1107
|
+
* up front as an algorithm downgrade. The webhook HMAC
|
|
1108
|
+
* already binds `share.alg` on the wire, so this is a
|
|
1109
|
+
* belt-and-suspenders pin; leaving it unset preserves the
|
|
1110
|
+
* pre-existing behaviour.
|
|
995
1111
|
* @returns The decrypted `SessionData`.
|
|
996
1112
|
* @throws AES-GCM authentication-tag error if:
|
|
997
1113
|
* - the wrong private key was supplied for `share.key_id`,
|
|
@@ -1015,7 +1131,7 @@ interface SessionData {
|
|
|
1015
1131
|
* );
|
|
1016
1132
|
* // data.new_address.street, data.account_number, etc.
|
|
1017
1133
|
*/
|
|
1018
|
-
declare function decryptSession(share: SessionKeyShare, envelopeB64: string, privateKeyPem: string | PrivateKeyOperations, partnerId: string): Promise<SessionData>;
|
|
1134
|
+
declare function decryptSession(share: SessionKeyShare, envelopeB64: string, privateKeyPem: string | PrivateKeyOperations, partnerId: string, expectedAlg?: SessionKeyShare['alg'] | null): Promise<SessionData>;
|
|
1019
1135
|
/**
|
|
1020
1136
|
* Decrypt a OneAddress payload and immediately re-encrypt it to a different
|
|
1021
1137
|
* ECDH P-256 public key — for example, your internal KMS or HSM public key.
|
|
@@ -1396,6 +1512,14 @@ interface VerifyResultCallbackParams {
|
|
|
1396
1512
|
match: boolean;
|
|
1397
1513
|
/** Optional free-text note (recorded by OneAddress; not shown to the consumer). */
|
|
1398
1514
|
note?: string;
|
|
1515
|
+
/**
|
|
1516
|
+
* Extra hostnames the callback may be POSTed to, beside `oneaddress.io` and
|
|
1517
|
+
* its subdomains. `OA_CALLBACK_HOST_ALLOWLIST` (comma-separated) does the
|
|
1518
|
+
* same from the environment. Both are for a staging or self-hosted relay
|
|
1519
|
+
* ONLY: `callback_url` arrives on the wire, so every host added here is a
|
|
1520
|
+
* host a forged `address.verify` could send your callback token to.
|
|
1521
|
+
*/
|
|
1522
|
+
allowedCallbackHosts?: readonly string[];
|
|
1399
1523
|
}
|
|
1400
1524
|
/**
|
|
1401
1525
|
* POST an `address.verify` result back to OneAddress, closing the verify loop.
|
package/dist/index.d.ts
CHANGED
|
@@ -429,7 +429,14 @@ interface OneAddressIdVerification {
|
|
|
429
429
|
platform: string;
|
|
430
430
|
}
|
|
431
431
|
interface OneAddressUpdateEvent {
|
|
432
|
-
|
|
432
|
+
/**
|
|
433
|
+
* `address.updated` when the dispatch carries an address (alone or beside a
|
|
434
|
+
* contact detail); `contact.updated` when it carries no address at all. Both
|
|
435
|
+
* reach `onUpdate`: from a receiver's side each means "apply these new values
|
|
436
|
+
* to this customer", and two callbacks invite an integration that implements
|
|
437
|
+
* one and quietly ignores the other. Route on `update_types`, not on this.
|
|
438
|
+
*/
|
|
439
|
+
event: 'address.updated' | 'contact.updated';
|
|
433
440
|
version: string;
|
|
434
441
|
id: string;
|
|
435
442
|
timestamp: number;
|
|
@@ -462,7 +469,36 @@ interface OneAddressUpdateEvent {
|
|
|
462
469
|
* Kept on the type for backwards compatibility with older payload shapes;
|
|
463
470
|
* do not rely on it. See {@link OneAddressCustomerMatch}. */
|
|
464
471
|
customer_match?: OneAddressCustomerMatch;
|
|
465
|
-
|
|
472
|
+
/**
|
|
473
|
+
* Which kinds of detail this dispatch carries, read LITERALLY off the
|
|
474
|
+
* decrypted envelope. Absent on the wire means `['address']`: every envelope
|
|
475
|
+
* written before the field existed carried an address and nothing else.
|
|
476
|
+
*
|
|
477
|
+
* A phone-only update is `['phone']`, not `['address', 'phone']`; widening it
|
|
478
|
+
* would tell you an address changed when it did not. You only ever receive a
|
|
479
|
+
* kind you declared in {@link OneAddressHandlerOptions.acceptedUpdateTypes};
|
|
480
|
+
* anything else is refused with 422 before this callback runs.
|
|
481
|
+
*/
|
|
482
|
+
update_types: SessionUpdateType[];
|
|
483
|
+
/**
|
|
484
|
+
* The new postal address, decrypted. Present when `update_types` includes
|
|
485
|
+
* `'address'`, which is every dispatch that existed before September 2026.
|
|
486
|
+
*
|
|
487
|
+
* OPTIONAL because a contact-only update (`contact.updated`) genuinely has
|
|
488
|
+
* none, and an empty or stale placeholder would be worse: you could not tell
|
|
489
|
+
* it from an instruction to overwrite. If your integration accepts addresses
|
|
490
|
+
* only (the default) it will never see the absent case, so narrow once:
|
|
491
|
+
* `const address = event.address; if (!address) throw new Error('no address');`
|
|
492
|
+
*/
|
|
493
|
+
address?: OneAddressAddress;
|
|
494
|
+
/** The new telephone number, E.164 (`+61412345678`). Present exactly when
|
|
495
|
+
* `update_types` includes `'phone'`, which requires you to have declared it.
|
|
496
|
+
* OneAddress has confirmed the consumer holds this number. */
|
|
497
|
+
new_phone?: string;
|
|
498
|
+
/** The new email address, lowercased. Present exactly when `update_types`
|
|
499
|
+
* includes `'email'`, which requires you to have declared it. OneAddress has
|
|
500
|
+
* confirmed the consumer receives mail there. */
|
|
501
|
+
new_email?: string;
|
|
466
502
|
/** The Letter of Authority. On D5 dispatches this is the structured
|
|
467
503
|
* {@link OneAddressD5LOA} recovered by decrypting `loa_encrypted`; on legacy
|
|
468
504
|
* dispatches it is the freeform {@link OneAddressLOA}. Verify with
|
|
@@ -583,6 +619,29 @@ interface OneAddressHandlerOptions {
|
|
|
583
619
|
webhookSecretGraceUntil?: string | number;
|
|
584
620
|
/** PKCS#8 PEM-encoded ECDH P-256 private key for address decryption */
|
|
585
621
|
privateKeyPem: string;
|
|
622
|
+
/**
|
|
623
|
+
* OPTIONAL — the `key_id` of the private key you hold (shown in the Partner
|
|
624
|
+
* Portal next to your encryption key). Set this to make key-rotation crossovers
|
|
625
|
+
* seamless.
|
|
626
|
+
*
|
|
627
|
+
* During a rotation OneAddress briefly sends the SAME update twice — once
|
|
628
|
+
* sealed to your OLD key and once to your NEW key — so a copy always arrives in
|
|
629
|
+
* a form you can open regardless of which key your receiver currently holds.
|
|
630
|
+
* Each copy names the other key_ids the update was also sent to
|
|
631
|
+
* (`crossover_key_ids`). When set, this handler SKIP-ACKS (200) a copy whose
|
|
632
|
+
* `session_key_share.key_id` is not yours **iff** your `keyId` is listed among
|
|
633
|
+
* those siblings — because a copy sealed to YOUR key is then guaranteed to
|
|
634
|
+
* arrive too. A single dispatch to a key_id you do not hold that names no such
|
|
635
|
+
* sibling still errors loudly, exactly as before, so a genuine
|
|
636
|
+
* misconfiguration is never silently swallowed.
|
|
637
|
+
*
|
|
638
|
+
* Leave it unset and behaviour is unchanged: a copy sealed to a key you do not
|
|
639
|
+
* hold fails to decrypt and returns 500 (OneAddress retries), which is today's
|
|
640
|
+
* behaviour — the verify-gate protects the cutover regardless. Set it to the
|
|
641
|
+
* key_id you actually hold; a value you do not hold a key for would cause every
|
|
642
|
+
* crossover copy naming it to be skipped with none arriving.
|
|
643
|
+
*/
|
|
644
|
+
keyId?: string;
|
|
586
645
|
/**
|
|
587
646
|
* OPTIONAL — OneAddress's ECDSA P-256 LOA signing public key (SPKI PEM), from
|
|
588
647
|
* {@link fetchLoaPublicKey}. Applies to `address.updated` ONLY (both the D5
|
|
@@ -713,6 +772,54 @@ interface OneAddressHandlerOptions {
|
|
|
713
772
|
* });
|
|
714
773
|
*/
|
|
715
774
|
idempotencyStore?: IdempotencyStore;
|
|
775
|
+
/**
|
|
776
|
+
* The kinds of changed detail this receiver's CODE can handle. Default
|
|
777
|
+
* `['address']`, so every integration written before September 2026 is
|
|
778
|
+
* unchanged.
|
|
779
|
+
*
|
|
780
|
+
* ── THIS IS A DECLARATION THE RELAY READS, NOT A FILTER ──────────────────
|
|
781
|
+
*
|
|
782
|
+
* The handler puts it in the body of every authenticated 2xx acknowledgement
|
|
783
|
+
* as `accepted_update_types`. The conformance run reads it off the first
|
|
784
|
+
* check, probes each kind you declared with a real contact-only envelope,
|
|
785
|
+
* probes one kind you did NOT declare and requires a refusal, and records the
|
|
786
|
+
* result. So the partner portal cannot promise a kind this code does not
|
|
787
|
+
* handle: what you ACCEPT in the portal is consent, what you declare HERE is
|
|
788
|
+
* capability, and a kind is dispatched only where both hold.
|
|
789
|
+
*
|
|
790
|
+
* ── WHAT HAPPENS TO A KIND YOU DID NOT DECLARE ───────────────────────────
|
|
791
|
+
*
|
|
792
|
+
* It is refused with `422 update_type_not_accepted` and `onUpdate` never
|
|
793
|
+
* runs. Acknowledging it would look identical to success on both sides while
|
|
794
|
+
* the consumer has already paid. The 4xx also leaves the dispatch incomplete
|
|
795
|
+
* in your idempotency store, so a retry after you widen this list is
|
|
796
|
+
* reprocessed rather than dismissed as a duplicate.
|
|
797
|
+
*
|
|
798
|
+
* `address` is always included whatever you pass, and a value the protocol
|
|
799
|
+
* does not define is dropped. Declare a kind only once `onUpdate` reads
|
|
800
|
+
* `event.new_phone` or `event.new_email` AND your storage has a column for it:
|
|
801
|
+
* the conformance run proves the envelope was accepted, not that the value
|
|
802
|
+
* was written.
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* createOneAddressHandler({
|
|
806
|
+
* webhookSecret, privateKeyPem,
|
|
807
|
+
* acceptedUpdateTypes: ['address', 'phone'],
|
|
808
|
+
* async onUpdate(event) {
|
|
809
|
+
* const account = event.customer?.account_number;
|
|
810
|
+
* if (!account) throw new Error('no account number');
|
|
811
|
+
* if (event.new_phone) await db.updatePhone(account, event.new_phone);
|
|
812
|
+
* if (event.address) await db.updateAddress(account, event.address);
|
|
813
|
+
* },
|
|
814
|
+
* });
|
|
815
|
+
*/
|
|
816
|
+
acceptedUpdateTypes?: readonly SessionUpdateType[];
|
|
817
|
+
/**
|
|
818
|
+
* Extra hostnames `sendVerifyResult` may POST an `address.verify` result to,
|
|
819
|
+
* beside `oneaddress.io` and its subdomains. For a staging or self-hosted
|
|
820
|
+
* relay ONLY. See {@link VerifyResultCallbackParams.allowedCallbackHosts}.
|
|
821
|
+
*/
|
|
822
|
+
allowedCallbackHosts?: readonly string[];
|
|
716
823
|
}
|
|
717
824
|
/**
|
|
718
825
|
* What a {@link IdempotencyStore.claim} call found.
|
|
@@ -889,9 +996,12 @@ interface SessionKeyShare {
|
|
|
889
996
|
/**
|
|
890
997
|
* The kinds of changed detail an envelope can carry.
|
|
891
998
|
*
|
|
892
|
-
* The vocabulary is closed.
|
|
893
|
-
*
|
|
894
|
-
*
|
|
999
|
+
* The vocabulary is closed. `createOneAddressHandler` REFUSES an envelope that
|
|
1000
|
+
* names a kind this build does not know (`422 invalid_update_types`) rather
|
|
1001
|
+
* than dropping the kind and processing the rest: a dropped kind is a dispatch
|
|
1002
|
+
* that charges the consumer, reports success and delivers less than they asked
|
|
1003
|
+
* for, and the 4xx is what makes OneAddress retry it once you have updated the
|
|
1004
|
+
* SDK. If you decrypt envelopes yourself with `decryptSession`, do the same.
|
|
895
1005
|
*/
|
|
896
1006
|
type SessionUpdateType = 'address' | 'phone' | 'email';
|
|
897
1007
|
interface SessionData {
|
|
@@ -992,6 +1102,12 @@ interface SessionData {
|
|
|
992
1102
|
* @param envelopeB64 - The `session_envelope` base64url string from the webhook.
|
|
993
1103
|
* @param privateKeyPem - Your PKCS#8 PEM private key whose key_id matches `share.key_id`.
|
|
994
1104
|
* @param partnerId - Your partner UUID (from the outer webhook payload).
|
|
1105
|
+
* @param expectedAlg - OPTIONAL. The wrap algorithm this key was provisioned
|
|
1106
|
+
* for. When supplied, a `share.alg` that differs is refused
|
|
1107
|
+
* up front as an algorithm downgrade. The webhook HMAC
|
|
1108
|
+
* already binds `share.alg` on the wire, so this is a
|
|
1109
|
+
* belt-and-suspenders pin; leaving it unset preserves the
|
|
1110
|
+
* pre-existing behaviour.
|
|
995
1111
|
* @returns The decrypted `SessionData`.
|
|
996
1112
|
* @throws AES-GCM authentication-tag error if:
|
|
997
1113
|
* - the wrong private key was supplied for `share.key_id`,
|
|
@@ -1015,7 +1131,7 @@ interface SessionData {
|
|
|
1015
1131
|
* );
|
|
1016
1132
|
* // data.new_address.street, data.account_number, etc.
|
|
1017
1133
|
*/
|
|
1018
|
-
declare function decryptSession(share: SessionKeyShare, envelopeB64: string, privateKeyPem: string | PrivateKeyOperations, partnerId: string): Promise<SessionData>;
|
|
1134
|
+
declare function decryptSession(share: SessionKeyShare, envelopeB64: string, privateKeyPem: string | PrivateKeyOperations, partnerId: string, expectedAlg?: SessionKeyShare['alg'] | null): Promise<SessionData>;
|
|
1019
1135
|
/**
|
|
1020
1136
|
* Decrypt a OneAddress payload and immediately re-encrypt it to a different
|
|
1021
1137
|
* ECDH P-256 public key — for example, your internal KMS or HSM public key.
|
|
@@ -1396,6 +1512,14 @@ interface VerifyResultCallbackParams {
|
|
|
1396
1512
|
match: boolean;
|
|
1397
1513
|
/** Optional free-text note (recorded by OneAddress; not shown to the consumer). */
|
|
1398
1514
|
note?: string;
|
|
1515
|
+
/**
|
|
1516
|
+
* Extra hostnames the callback may be POSTed to, beside `oneaddress.io` and
|
|
1517
|
+
* its subdomains. `OA_CALLBACK_HOST_ALLOWLIST` (comma-separated) does the
|
|
1518
|
+
* same from the environment. Both are for a staging or self-hosted relay
|
|
1519
|
+
* ONLY: `callback_url` arrives on the wire, so every host added here is a
|
|
1520
|
+
* host a forged `address.verify` could send your callback token to.
|
|
1521
|
+
*/
|
|
1522
|
+
allowedCallbackHosts?: readonly string[];
|
|
1399
1523
|
}
|
|
1400
1524
|
/**
|
|
1401
1525
|
* POST an `address.verify` result back to OneAddress, closing the verify loop.
|