@andco/protocol 0.0.13 → 0.0.15
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/README.md +2 -2
- package/dist/api-errors.d.ts +9 -9
- package/dist/api-errors.js +9 -9
- package/dist/authorization-preparation.js +2 -2
- package/dist/authorization.d.ts +1 -1
- package/dist/authorization.js +1 -1
- package/dist/consent.d.ts +2 -2
- package/dist/consent.js +2 -2
- package/dist/constants.d.ts +15 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +17 -3
- package/dist/errors.d.ts +36 -9
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +49 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/intent-input.d.ts +431 -872
- package/dist/intent-input.d.ts.map +1 -1
- package/dist/intent-input.js +142 -121
- package/dist/miniapp-icon.js +1 -1
- package/dist/miniapp-manifest.d.ts +1 -1
- package/dist/native-intent.d.ts +82 -68
- package/dist/native-intent.d.ts.map +1 -1
- package/dist/native-intent.js +134 -84
- package/dist/native.d.ts +1 -1
- package/dist/rar/account-matchers.d.ts +35 -30
- package/dist/rar/account-matchers.d.ts.map +1 -1
- package/dist/rar/account-matchers.js +27 -21
- package/dist/rar/bank.d.ts +81 -81
- package/dist/rar/bank.js +1 -1
- package/dist/rar/catalog.d.ts +48 -48
- package/dist/rar/catalog.js +6 -6
- package/dist/rar/detail.d.ts +1 -1
- package/dist/rar/detail.js +1 -1
- package/dist/rar/json-schemas.generated.d.ts +1 -1
- package/dist/rar/json-schemas.generated.d.ts.map +1 -1
- package/dist/rar/json-schemas.generated.js +25 -21
- package/dist/rar/subject-data.d.ts +1 -1
- package/dist/rar/subject-data.js +1 -1
- package/dist/rar/subject.d.ts +1 -1
- package/dist/rar/subject.js +1 -1
- package/dist/rest/accounts.d.ts +28 -28
- package/dist/rest/accounts.d.ts.map +1 -1
- package/dist/rest/accounts.js +22 -22
- package/dist/rest/api-error.d.ts +1 -1
- package/dist/rest/api-error.js +1 -1
- package/dist/rest/catalog.d.ts +3 -3
- package/dist/rest/catalog.js +2 -2
- package/dist/rest/common.d.ts +3 -3
- package/dist/rest/common.js +3 -3
- package/dist/rest/contract.d.ts +905 -528
- package/dist/rest/contract.d.ts.map +1 -1
- package/dist/rest/contract.js +17 -5
- package/dist/rest/events.d.ts +1 -1
- package/dist/rest/events.d.ts.map +1 -1
- package/dist/rest/events.js +2 -2
- package/dist/rest/identity.d.ts +22 -22
- package/dist/rest/identity.js +5 -5
- package/dist/rest/index.d.ts +1 -0
- package/dist/rest/index.d.ts.map +1 -1
- package/dist/rest/index.js +1 -0
- package/dist/rest/intents.d.ts +787 -716
- package/dist/rest/intents.d.ts.map +1 -1
- package/dist/rest/intents.js +62 -53
- package/dist/rest/signatures.d.ts +11 -5
- package/dist/rest/signatures.d.ts.map +1 -1
- package/dist/rest/signatures.js +10 -0
- package/dist/rest/subjects.d.ts +1 -1
- package/dist/rest/subjects.d.ts.map +1 -1
- package/dist/rest/subjects.js +3 -2
- package/dist/rest/transfers.d.ts +612 -0
- package/dist/rest/transfers.d.ts.map +1 -0
- package/dist/rest/transfers.js +115 -0
- package/dist/scopes.d.ts +1 -1
- package/dist/signing.d.ts +13 -2
- package/dist/signing.d.ts.map +1 -1
- package/dist/signing.js +13 -0
- package/dist/transfer.d.ts +363 -0
- package/dist/transfer.d.ts.map +1 -0
- package/dist/transfer.js +287 -0
- package/dist/transport/financial-events.d.ts +21 -17
- package/dist/transport/financial-events.d.ts.map +1 -1
- package/dist/transport/generated/oauth-api.d.ts +1017 -194
- package/dist/transport/generated/oauth-api.d.ts.map +1 -1
- package/dist/transport/intents.d.ts +28 -12
- package/dist/transport/intents.d.ts.map +1 -1
- package/dist/transport/intents.js +1 -1
- package/dist/transport/rest.d.ts +4 -4
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/transport/rest.js +33 -4
- package/dist/urls.d.ts +25 -2
- package/dist/urls.d.ts.map +1 -1
- package/dist/urls.js +47 -4
- package/dist/userinfo.d.ts +2 -2
- package/dist/userinfo.js +2 -2
- package/dist/webhooks.d.ts +19 -15
- package/dist/webhooks.d.ts.map +1 -1
- package/dist/webhooks.js +17 -15
- package/dist/window-features.d.ts +2 -2
- package/dist/window-features.js +2 -2
- package/package.json +2 -2
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import type { components, operations } from "./generated/oauth-api.js";
|
|
2
2
|
/**
|
|
3
|
-
* One
|
|
3
|
+
* One AndCo account of the Grant's subject, by Account Key or by identifier: a transfer's source,
|
|
4
4
|
* a deposit's destination and the account a closure closes.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* const account: AndCoIntentAccount = { type: "account_key", accountKey: "ventas" };
|
|
8
8
|
*/
|
|
9
9
|
export type AndCoIntentAccount = components["schemas"]["IntentAccount"];
|
|
10
|
-
/** Where a signed transfer's money lands: an Andco account, or an account at another Chilean bank. */
|
|
11
|
-
export type AndCoTransferDestination = components["schemas"]["TransferDestination"];
|
|
12
10
|
/**
|
|
13
|
-
*
|
|
11
|
+
* The Receptor of a transfer, with nothing left to complete: an AndCo account, or a Receptor at a
|
|
12
|
+
* Chilean bank in Core's vocabulary. How an event reports it.
|
|
13
|
+
*/
|
|
14
|
+
export type AndCoTransferIntentReceiver = components["schemas"]["TransferIntentReceiver"];
|
|
15
|
+
/**
|
|
16
|
+
* The Receptor of a proposed transfer, in the request and in the answered Intent alike;
|
|
14
17
|
* `editable: false` locks it on the confirmation screen.
|
|
15
18
|
*/
|
|
16
|
-
export type
|
|
19
|
+
export type AndCoTransferIntentReceiverProposal = components["schemas"]["TransferIntentReceiverProposal"];
|
|
20
|
+
/** The comment a transfer asks for, `{ value, editable? }`: at most 60 bytes, as Core's `comment`. */
|
|
21
|
+
export type AndCoTransferCommentProposal = components["schemas"]["TransferCommentProposal"];
|
|
17
22
|
/**
|
|
18
23
|
* The amount a request asks for, `{ currency, value, editable? }`. It is never what moved.
|
|
19
24
|
*
|
|
@@ -21,7 +26,7 @@ export type AndCoTransferDestinationProposal = components["schemas"]["TransferDe
|
|
|
21
26
|
* const amount: AndCoIntentAmount = { currency: "CLP", value: "40000" };
|
|
22
27
|
*/
|
|
23
28
|
export type AndCoIntentAmount = components["schemas"]["IntentAmount"];
|
|
24
|
-
/**
|
|
29
|
+
/** An amount with nothing left to choose: `{ currency, value }`. How an event reports one. */
|
|
25
30
|
export type AndCoSignedAmount = components["schemas"]["SignedAmount"];
|
|
26
31
|
/** The money a transfer actually moved and when; null on the Intent until it `succeeded`. */
|
|
27
32
|
export type AndCoTransferSettlement = components["schemas"]["TransferSettlement"];
|
|
@@ -45,17 +50,28 @@ export type AndCoTransferIntentCreate = components["schemas"]["TransferIntentCre
|
|
|
45
50
|
* if (transfer.settled) await markPaid(invoice.id, transfer.settled.value);
|
|
46
51
|
*/
|
|
47
52
|
export type AndCoTransferIntent = components["schemas"]["TransferIntent"];
|
|
48
|
-
/** The verified claims of a Signed Instruction: the `application/jwt` half of the same creation. */
|
|
49
|
-
export type AndCoSignedTransferClaims = components["schemas"]["SignedTransferIntentClaims"];
|
|
50
53
|
/**
|
|
51
|
-
*
|
|
54
|
+
* The claims of a signed transfer, version 2: Core's `POST /api/transfer` body plus `iss`, `aud`,
|
|
55
|
+
* `jti`, `exp` and `approved` (ADR 0092). Uploaded to `POST /transfers`, never to `POST /intents`.
|
|
56
|
+
*/
|
|
57
|
+
export type AndCoSignedTransferClaims = components["schemas"]["SignedTransferClaims"];
|
|
58
|
+
/**
|
|
59
|
+
* A signed transfer as it travels to `POST /transfers`: a JWS in the General JSON Serialization
|
|
60
|
+
* (RFC 7515 §7.2.1), sent as `application/jose+json`.
|
|
61
|
+
*/
|
|
62
|
+
export type AndCoSignedTransferEnvelope = components["schemas"]["SignedTransferEnvelope"];
|
|
63
|
+
/** A Transfer uploaded as a Signed Instruction, as `POST /transfers` and `GET /transfers/{transfer_id}` answer it. */
|
|
64
|
+
export type AndCoTransfer = components["schemas"]["Transfer"];
|
|
65
|
+
/**
|
|
66
|
+
* One Signed Instruction on the wire for `POST /intents`: the compact JWS whose payload opens or
|
|
67
|
+
* closes an account ({@link AndCoSignedAccountOpeningClaims}).
|
|
52
68
|
*
|
|
53
69
|
* It is the request body itself rather than a field inside one, which is why the `application/jwt`
|
|
54
70
|
* half of `POST /intents` is a string and not an object. Producing it is signing, and signing is
|
|
55
71
|
* not this transport's job: it takes an instruction somebody already signed and sends it.
|
|
56
72
|
*/
|
|
57
73
|
export type AndCoSignedInstruction = operations["createIntent"]["requestBody"]["content"]["application/jwt"];
|
|
58
|
-
/** Input accepted when opening a
|
|
74
|
+
/** Input accepted when opening a cuenta digital over `application/json`, born waiting for an Approval. */
|
|
59
75
|
export type AndCoAccountOpeningIntentCreate = components["schemas"]["AccountOpeningIntentCreate"];
|
|
60
76
|
/** The verified claims of a Signed Instruction that opens an account. */
|
|
61
77
|
export type AndCoSignedAccountOpeningClaims = components["schemas"]["SignedAccountOpeningIntentClaims"];
|
|
@@ -65,7 +81,7 @@ export type AndCoSignedAccountOpeningClaims = components["schemas"]["SignedAccou
|
|
|
65
81
|
* the account's own event stream rather than in this response.
|
|
66
82
|
*/
|
|
67
83
|
export type AndCoAccountOpeningIntent = components["schemas"]["AccountOpeningIntent"];
|
|
68
|
-
/** Input accepted when closing a
|
|
84
|
+
/** Input accepted when closing a cuenta digital over `application/json`, born waiting for an Approval. */
|
|
69
85
|
export type AndCoAccountClosureIntentCreate = components["schemas"]["AccountClosureIntentCreate"];
|
|
70
86
|
/** The verified claims of a Signed Instruction that closes an account. */
|
|
71
87
|
export type AndCoSignedAccountClosureClaims = components["schemas"]["SignedAccountClosureIntentClaims"];
|
|
@@ -74,7 +90,7 @@ export type AndCoAccountClosureIntent = components["schemas"]["AccountClosureInt
|
|
|
74
90
|
/** Any currently supported intent. */
|
|
75
91
|
export type AndCoIntent = AndCoDepositIntent | AndCoTransferIntent | AndCoAccountOpeningIntent | AndCoAccountClosureIntent;
|
|
76
92
|
/**
|
|
77
|
-
* Validates the
|
|
93
|
+
* Validates the AndCo-owned interaction URL returned for an Intent.
|
|
78
94
|
*
|
|
79
95
|
* @throws {AndcoError} `invalid_response` when it is not an https URL on the interaction origin.
|
|
80
96
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intents.d.ts","sourceRoot":"","sources":["../../src/transport/intents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;AACxE
|
|
1
|
+
{"version":3,"file":"intents.d.ts","sourceRoot":"","sources":["../../src/transport/intents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;AACxE;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,wBAAwB,CAAC,CAAC;AAC1F;;;GAGG;AACH,MAAM,MAAM,mCAAmC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,gCAAgC,CAAC,CAAC;AAC1G,sGAAsG;AACtG,MAAM,MAAM,4BAA4B,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,yBAAyB,CAAC,CAAC;AAC5F;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC;AACtE,8FAA8F;AAC9F,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC;AACtE,6FAA6F;AAC7F,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAA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C,sBAAsB,CAAC,CAAC;AACtF,0GAA0G;AAC1G,MAAM,MAAM,+BAA+B,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,4BAA4B,CAAC,CAAC;AAClG,0EAA0E;AAC1E,MAAM,MAAM,+BAA+B,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,kCAAkC,CAAC,CAAC;AACxG,iGAAiG;AACjG,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,sBAAsB,CAAC,CAAC;AACtF,sCAAsC;AACtC,MAAM,MAAM,WAAW,GACnB,kBAAkB,GAClB,mBAAmB,GACnB,yBAAyB,GACzB,yBAAyB,CAAC;AAE9B;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,GAAG,GAAG,GAAG,GAAG,CAcxG;AAID;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
|
@@ -2,7 +2,7 @@ import * as v from "valibot";
|
|
|
2
2
|
import { ANDCO_ERROR_CODES, AndcoError } from "../errors.js";
|
|
3
3
|
import { SafeURL } from "../urls.js";
|
|
4
4
|
/**
|
|
5
|
-
* Validates the
|
|
5
|
+
* Validates the AndCo-owned interaction URL returned for an Intent.
|
|
6
6
|
*
|
|
7
7
|
* @throws {AndcoError} `invalid_response` when it is not an https URL on the interaction origin.
|
|
8
8
|
*/
|
package/dist/transport/rest.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type AndCoRestAccessToken = string | null | ((request: Request) => string
|
|
|
23
23
|
*/
|
|
24
24
|
export type AndCoProfileIdentity = components["schemas"]["ProfileIdentity"];
|
|
25
25
|
/**
|
|
26
|
-
* What
|
|
26
|
+
* What AndCo Core validated about a Profile's identity: who (`validated_by`), when (`validated_at`), the kinds of
|
|
27
27
|
* evidence and Core's `verification_id`, which is the reference to keep.
|
|
28
28
|
*/
|
|
29
29
|
export type AndCoIdentityValidation = components["schemas"]["IdentityValidation"];
|
|
@@ -51,13 +51,13 @@ export type AndCoAccountPage = components["schemas"]["AccountPage"];
|
|
|
51
51
|
*/
|
|
52
52
|
export type AndCoBankTransaction = components["schemas"]["BankTransaction"];
|
|
53
53
|
/**
|
|
54
|
-
* One page of an account's Transactions, newest first.
|
|
54
|
+
* One page of an account's Transactions, newest first. AndCo walks forward only and issues one cursor per
|
|
55
55
|
* page: `pageInfo["endCursor"]` goes back as `after`; an edge's `cursor` is `null`.
|
|
56
56
|
*/
|
|
57
57
|
export type AndCoBankTransactionPage = components["schemas"]["BankTransactionPage"];
|
|
58
58
|
/**
|
|
59
|
-
* One bank a transfer can be sent to, read from `GET /catalog/banks`. `id` is the
|
|
60
|
-
*
|
|
59
|
+
* One bank a transfer can be sent to, read from `GET /catalog/banks`. `id` is the bank's four-digit code in
|
|
60
|
+
* Core's catalog, the `bank_code` of a Receptor; `name` is the bank's own name.
|
|
61
61
|
*/
|
|
62
62
|
export type AndCoBankCatalogEntry = components["schemas"]["BankCatalogEntry"];
|
|
63
63
|
/** The whole list of banks as one page: `pageInfo["hasNextPage"]` is `false` and no edge carries a cursor. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/transport/rest.ts"],"names":[],"mappings":"AAAA,OAAqB,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/transport/rest.ts"],"names":[],"mappings":"AAAA,OAAqB,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAA0C,MAAM,eAAe,CAAC;AAKtH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC;AACn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AC/E,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CAChC,CAAC;AA8BF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CA4B3F"}
|
package/dist/transport/rest.js
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
|
-
import createClient from "openapi-fetch";
|
|
2
|
-
import { ANDCO_API_ORIGIN, ANDCO_OAUTH_API_URL } from "../constants.js";
|
|
3
|
-
import {
|
|
1
|
+
import createClient, { defaultPathSerializer } from "openapi-fetch";
|
|
2
|
+
import { ANDCO_API_ORIGIN, ANDCO_OAUTH_API_URL, ORGANIZATION_ID_PARAMETER_PATTERN } from "../constants.js";
|
|
3
|
+
import { ANDCO_ERROR_CODES, AndcoError } from "../errors.js";
|
|
4
|
+
import { ACCOUNT_KEY_SYNTAX } from "../rar/account-matchers.js";
|
|
5
|
+
import { EndpointURL } from "../urls.js";
|
|
6
|
+
import { IS_UUID_SHAPED } from "./intents.js";
|
|
4
7
|
import { createRuntimeFetch } from "./runtime.js";
|
|
8
|
+
const ORGANIZATION_ID_PARAMETER = /* @__PURE__ */ new RegExp(ORGANIZATION_ID_PARAMETER_PATTERN);
|
|
9
|
+
const ACCOUNT_KEY = /* @__PURE__ */ new RegExp(ACCOUNT_KEY_SYNTAX);
|
|
10
|
+
/** The path parameters that are not always a UUID, and what each one must look like. */
|
|
11
|
+
const PATH_PARAMETER_CHECKS = {
|
|
12
|
+
organization_id: (value) => ORGANIZATION_ID_PARAMETER.test(value),
|
|
13
|
+
// `/accounts/{bank_account_id}/transactions` names the account by its UUID or its Account Key.
|
|
14
|
+
bank_account_id: (value) => IS_UUID_SHAPED(value) || ACCOUNT_KEY.test(value),
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Checks each path parameter before it becomes a segment: an Organization against
|
|
18
|
+
* {@link ORGANIZATION_ID_PARAMETER_PATTERN}, an account as a UUID or an Account Key, every other
|
|
19
|
+
* identifier as a UUID. `encodeURIComponent` leaves `.` and `..` as they are and the URL parser
|
|
20
|
+
* resolves them, so an unchecked identifier could send the request, with its token, to another
|
|
21
|
+
* route. A failure throws `invalid_identifier`, since no request was made to answer with
|
|
22
|
+
* `{ data, error }`.
|
|
23
|
+
*/
|
|
24
|
+
function checkedPathSerializer(pathname, pathParams) {
|
|
25
|
+
for (const [name, value] of Object.entries(pathParams)) {
|
|
26
|
+
const check = PATH_PARAMETER_CHECKS[name] ?? IS_UUID_SHAPED;
|
|
27
|
+
if (!check(String(value))) {
|
|
28
|
+
throw new AndcoError(ANDCO_ERROR_CODES.INVALID_IDENTIFIER, { message: `${name} is not a valid identifier` });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return defaultPathSerializer(pathname, pathParams);
|
|
32
|
+
}
|
|
5
33
|
/**
|
|
6
34
|
* Creates a lightweight typed client for the OAuth resource API.
|
|
7
35
|
*
|
|
@@ -23,10 +51,11 @@ export function createAndCoRestClient(options = {}) {
|
|
|
23
51
|
if (version !== "_" && !/^\d{10}$/.test(version)) {
|
|
24
52
|
throw new TypeError("apiVersion must be `_` or a Unix timestamp in seconds");
|
|
25
53
|
}
|
|
26
|
-
const endpoint = new
|
|
54
|
+
const endpoint = new EndpointURL(options.endpoint ?? ANDCO_API_ORIGIN);
|
|
27
55
|
const client = createClient({
|
|
28
56
|
baseUrl: ANDCO_OAUTH_API_URL(endpoint, version),
|
|
29
57
|
fetch: options.fetch ?? createRuntimeFetch(),
|
|
58
|
+
pathSerializer: checkedPathSerializer,
|
|
30
59
|
});
|
|
31
60
|
const authorization = {
|
|
32
61
|
async onRequest({ request }) {
|
package/dist/urls.d.ts
CHANGED
|
@@ -48,8 +48,9 @@ export declare class BetterURL<const TUrl extends string | URL = string | URL> e
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* A {@link BetterURL} that is HTTPS (or plaintext HTTP on a loopback development host), and carries no
|
|
51
|
-
* credentials or
|
|
52
|
-
* `password`, or `hash` afterward is not re-validated, so treat a SafeURL as safe
|
|
51
|
+
* credentials, fragment or `%` in its host. These checks run once, at construction: mutating `protocol`,
|
|
52
|
+
* `username`, `password`, `host`, or `hash` afterward is not re-validated, so treat a SafeURL as safe
|
|
53
|
+
* only until mutated.
|
|
53
54
|
*
|
|
54
55
|
* Because a fragment fails construction, `.hashParams` is always empty on a valid SafeURL.
|
|
55
56
|
*
|
|
@@ -59,6 +60,28 @@ export declare class BetterURL<const TUrl extends string | URL = string | URL> e
|
|
|
59
60
|
export declare class SafeURL<const TUrl extends string | URL = string | URL> extends BetterURL<TUrl> {
|
|
60
61
|
constructor(url: TUrl, base?: string | URL, overwrite?: BetterURLOverwrite<TUrl>);
|
|
61
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* A {@link SafeURL} for an AndCo endpoint: a base URL the SDK joins a path to, such as the API or the
|
|
65
|
+
* Authorization Server. It carries no query or fragment, not even an empty `?` or `#`, since one would
|
|
66
|
+
* take the joined path. A URL the SDK adds query parameters to, such as an authorization endpoint, is a
|
|
67
|
+
* plain SafeURL. Every AndCo SDK refuses the same endpoints and keeps an endpoint's path when it joins
|
|
68
|
+
* one; ADR 0043 records both rules.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const api = new EndpointURL("https://api.andco.com");
|
|
72
|
+
*/
|
|
73
|
+
export declare class EndpointURL extends SafeURL {
|
|
74
|
+
constructor(url: string | URL);
|
|
75
|
+
/**
|
|
76
|
+
* Builds the URL of `path` under this endpoint. The endpoint's own path stays as a prefix, and a
|
|
77
|
+
* trailing slash on the endpoint changes nothing. The endpoint itself does not change.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* new EndpointURL("https://auth.localhost/auth/v1/").join("oauth/token").href;
|
|
81
|
+
* // "https://auth.localhost/auth/v1/oauth/token"
|
|
82
|
+
*/
|
|
83
|
+
join(path: string): URL;
|
|
84
|
+
}
|
|
62
85
|
/** Creates the AndCo Console URL for registering an OAuth project. */
|
|
63
86
|
export declare function ANDCO_PROJECT_URL({ redirectUris, clientName, clientType, framework, scopes, }: {
|
|
64
87
|
redirectUris: string[];
|
package/dist/urls.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../src/urls.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,WAKhD;AAED,QAAA,MAAM,iBAAiB,yGAUb,CAAC;AACX,KAAK,kBAAkB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,yEAAyE;AACzE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,MAAM,CAAC,IAAI,MAAM,IAAI,EAAE,GAC7F,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAC5B,KAAK,CAAC;AAEV,KAAK,gBAAgB,CAAC,IAAI,SAAS,MAAM,GAAG,GAAG,IAAI,IAAI,SAAS,MAAM,GAClE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACxC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,GAC5D,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAEpC,MAAM,MAAM,kBAAkB,CAAC,IAAI,SAAS,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,GAAG;IAClH,4GAA4G;IAC5G,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,i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-104,8 +104,9 @@ export class BetterURL extends URL {
|
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* A {@link BetterURL} that is HTTPS (or plaintext HTTP on a loopback development host), and carries no
|
|
107
|
-
* credentials or
|
|
108
|
-
* `password`, or `hash` afterward is not re-validated, so treat a SafeURL as safe
|
|
107
|
+
* credentials, fragment or `%` in its host. These checks run once, at construction: mutating `protocol`,
|
|
108
|
+
* `username`, `password`, `host`, or `hash` afterward is not re-validated, so treat a SafeURL as safe
|
|
109
|
+
* only until mutated.
|
|
109
110
|
*
|
|
110
111
|
* Because a fragment fails construction, `.hashParams` is always empty on a valid SafeURL.
|
|
111
112
|
*
|
|
@@ -116,9 +117,51 @@ export class SafeURL extends BetterURL {
|
|
|
116
117
|
constructor(url, base, overwrite) {
|
|
117
118
|
super(url, base, overwrite);
|
|
118
119
|
const secureTransport = this.protocol === "https:" || (this.protocol === "http:" && IS_LOOPBACK_HOST(this.hostname));
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
// WHATWG URL percent-decodes a host: `ex%61mple.com` is `example.com` here, where other parsers keep
|
|
121
|
+
// the `%` or refuse it. Escaped as `%25`, a `%` in the host outlives that one decoding, and no host may
|
|
122
|
+
// hold one, so the escaped input fails to parse exactly when the host had a `%`.
|
|
123
|
+
let percentInHost = Boolean(overwrite?.host?.includes("%") || overwrite?.hostname?.includes("%"));
|
|
124
|
+
try {
|
|
125
|
+
new URL(String(url).replaceAll("%", "%25"), base === undefined ? undefined : String(base).replaceAll("%", "%25"));
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
percentInHost = true;
|
|
121
129
|
}
|
|
130
|
+
if (!secureTransport || this.username || this.password || this.hash || percentInHost) {
|
|
131
|
+
throw new TypeError("AndCo URLs require HTTPS, except for loopback development hosts, and cannot contain credentials, a fragment or a `%` in the host");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A {@link SafeURL} for an AndCo endpoint: a base URL the SDK joins a path to, such as the API or the
|
|
137
|
+
* Authorization Server. It carries no query or fragment, not even an empty `?` or `#`, since one would
|
|
138
|
+
* take the joined path. A URL the SDK adds query parameters to, such as an authorization endpoint, is a
|
|
139
|
+
* plain SafeURL. Every AndCo SDK refuses the same endpoints and keeps an endpoint's path when it joins
|
|
140
|
+
* one; ADR 0043 records both rules.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* const api = new EndpointURL("https://api.andco.com");
|
|
144
|
+
*/
|
|
145
|
+
export class EndpointURL extends SafeURL {
|
|
146
|
+
constructor(url) {
|
|
147
|
+
super(url);
|
|
148
|
+
// `search` and `hash` are empty for a bare `?` or `#`, but the serialized URL keeps the character.
|
|
149
|
+
if (this.href.includes("?") || this.href.includes("#")) {
|
|
150
|
+
throw new TypeError("An AndCo endpoint cannot contain a query or a fragment, not even an empty one");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Builds the URL of `path` under this endpoint. The endpoint's own path stays as a prefix, and a
|
|
155
|
+
* trailing slash on the endpoint changes nothing. The endpoint itself does not change.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* new EndpointURL("https://auth.localhost/auth/v1/").join("oauth/token").href;
|
|
159
|
+
* // "https://auth.localhost/auth/v1/oauth/token"
|
|
160
|
+
*/
|
|
161
|
+
join(path) {
|
|
162
|
+
const url = new URL(this.href);
|
|
163
|
+
url.pathname = `${this.pathname.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
|
164
|
+
return url;
|
|
122
165
|
}
|
|
123
166
|
}
|
|
124
167
|
/** Creates the AndCo Console URL for registering an OAuth project. */
|
package/dist/userinfo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
/**
|
|
3
|
-
* The claims
|
|
3
|
+
* The claims AndCo's UserInfo endpoint answers, filtered by the scopes of the token: `email` and
|
|
4
4
|
* `email_verified` with the `email` scope, `name` and `picture` with `profile`, `phone` and
|
|
5
5
|
* `phone_verified` with `phone`.
|
|
6
6
|
*/
|
|
@@ -14,7 +14,7 @@ export declare const UserInfo: v.ObjectSchema<{
|
|
|
14
14
|
readonly phone_verified: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Present and `true` when the `phone` scope is granted and the number was confirmed.">]>, undefined>;
|
|
15
15
|
}, undefined>;
|
|
16
16
|
/**
|
|
17
|
-
* Scope-filtered claims returned by
|
|
17
|
+
* Scope-filtered claims returned by AndCo's UserInfo endpoint, read by a client that tolerates the
|
|
18
18
|
* claims a later version adds.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
package/dist/userinfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
/**
|
|
3
|
-
* The claims
|
|
3
|
+
* The claims AndCo's UserInfo endpoint answers, filtered by the scopes of the token: `email` and
|
|
4
4
|
* `email_verified` with the `email` scope, `name` and `picture` with `profile`, `phone` and
|
|
5
5
|
* `phone_verified` with `phone`.
|
|
6
6
|
*/
|
|
@@ -14,7 +14,7 @@ export const UserInfo = /* @__PURE__ */ v.object({
|
|
|
14
14
|
phone_verified: v.optional(v.pipe(v.boolean(), v.description("Present and `true` when the `phone` scope is granted and the number was confirmed."))),
|
|
15
15
|
});
|
|
16
16
|
/**
|
|
17
|
-
* Scope-filtered claims returned by
|
|
17
|
+
* Scope-filtered claims returned by AndCo's UserInfo endpoint, read by a client that tolerates the
|
|
18
18
|
* claims a later version adds.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/** Header names of a signed
|
|
1
|
+
/** Header names of a signed AndCo webhook delivery. */
|
|
2
2
|
export declare const ANDCO_WEBHOOK_HEADERS: {
|
|
3
3
|
readonly eventId: "andco-event-id";
|
|
4
4
|
readonly timestamp: "andco-timestamp";
|
|
5
5
|
readonly signature: "andco-signature";
|
|
6
6
|
};
|
|
7
|
-
/** The only signature algorithm
|
|
7
|
+
/** The only signature algorithm AndCo signs webhook deliveries with. */
|
|
8
8
|
export declare const ANDCO_WEBHOOK_ALGORITHM: "Ed25519";
|
|
9
9
|
/** How far a delivery timestamp may drift from the receiver's clock, in seconds. */
|
|
10
10
|
export declare const ANDCO_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
11
|
-
/**
|
|
11
|
+
/** AndCo's public webhook keys. Platform serves the same document at its own origin. */
|
|
12
12
|
export declare const ANDCO_WEBHOOK_JWKS_URL: "https://api.andco.com/.well-known/webhook-keys.json";
|
|
13
13
|
/**
|
|
14
14
|
* How long a fetched JWKS is trusted, in milliseconds. Past it, the next delivery reloads the keys
|
|
15
|
-
* even when its `kid` is known, so a key
|
|
15
|
+
* even when its `kid` is known, so a key AndCo withdrew stops verifying.
|
|
16
16
|
*/
|
|
17
17
|
export declare const ANDCO_WEBHOOK_KEYS_TTL_MS: number;
|
|
18
18
|
/**
|
|
19
|
-
* The exact string
|
|
19
|
+
* The exact string AndCo signs for one delivery: `${eventId}.${timestamp}.${rawBody}`.
|
|
20
20
|
*
|
|
21
21
|
* Binding the event id and the timestamp into the signed bytes means a captured body can be
|
|
22
22
|
* replayed neither under a later timestamp nor as a different event.
|
|
@@ -54,7 +54,7 @@ export declare const ANDCO_WEBHOOK_ERROR_CODES: {
|
|
|
54
54
|
export type AndcoWebhookErrorCode = (typeof ANDCO_WEBHOOK_ERROR_CODES)[keyof typeof ANDCO_WEBHOOK_ERROR_CODES];
|
|
55
55
|
/**
|
|
56
56
|
* A webhook delivery that must not be trusted. Answer it with a 4xx and do not act on its body;
|
|
57
|
-
*
|
|
57
|
+
* AndCo retries deliveries that are not acknowledged with a 2xx.
|
|
58
58
|
*
|
|
59
59
|
* @example
|
|
60
60
|
* try {
|
|
@@ -72,7 +72,7 @@ export declare class AndcoWebhookError extends Error {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
* The envelope every
|
|
75
|
+
* The envelope every AndCo webhook event shares, with its `type` and `payload`.
|
|
76
76
|
*
|
|
77
77
|
* @example
|
|
78
78
|
* ```ts
|
|
@@ -96,7 +96,7 @@ export type AndcoWebhookEnvelope<T extends string, P> = {
|
|
|
96
96
|
/** Event-specific facts. Money values are strings. */
|
|
97
97
|
payload: P;
|
|
98
98
|
};
|
|
99
|
-
/** Why a Grant was revoked: by the person (Platform, the native Host,
|
|
99
|
+
/** Why a Grant was revoked: by the person (Platform, the native Host, AndCo) or by the client (`/oauth/revoke`). */
|
|
100
100
|
export type AndcoGrantRevocationReason = "revoked_by_person" | "revoked_by_client";
|
|
101
101
|
/**
|
|
102
102
|
* A Grant was revoked (ADR 0034): its tokens are useless now; delete the ones you keep and ask for
|
|
@@ -131,7 +131,7 @@ export type AndcoGrantWebhookEvent = AndcoGrantRevokedEvent | AndcoGrantExpiredE
|
|
|
131
131
|
/** The Grant lifecycle event types the verifier checks and types. */
|
|
132
132
|
export declare const ANDCO_WEBHOOK_GRANT_EVENT_TYPES: readonly ["grant.revoked", "grant.expired", "grant.updated"];
|
|
133
133
|
/**
|
|
134
|
-
* One
|
|
134
|
+
* One AndCo event as delivered to a Project's webhook endpoint. Every event of every client of the
|
|
135
135
|
* Project arrives at the same endpoint: filter by `client_id`, `grant_id` or `type` yourself.
|
|
136
136
|
*
|
|
137
137
|
* Grant lifecycle events arrive typed and their payload is checked; narrow with
|
|
@@ -155,7 +155,11 @@ export type AndcoWebhookDelivery = {
|
|
|
155
155
|
headers: Headers | Record<string, string | string[] | undefined>;
|
|
156
156
|
};
|
|
157
157
|
export type AndcoWebhookVerifierOptions = {
|
|
158
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Where to fetch AndCo's public webhook keys. Defaults to {@link ANDCO_WEBHOOK_JWKS_URL}. Like every
|
|
160
|
+
* AndCo URL it must be HTTPS (plain HTTP only on a loopback development host) without credentials or a
|
|
161
|
+
* fragment: `verifier` throws a `TypeError` otherwise, before any delivery arrives.
|
|
162
|
+
*/
|
|
159
163
|
jwksUrl?: string | URL;
|
|
160
164
|
/** Accepted clock drift, in seconds. Defaults to {@link ANDCO_WEBHOOK_TOLERANCE_SECONDS}. */
|
|
161
165
|
toleranceSeconds?: number;
|
|
@@ -189,12 +193,12 @@ export type AndcoWebhookVerify = (delivery: Request | AndcoWebhookDelivery) => P
|
|
|
189
193
|
*/
|
|
190
194
|
declare function isGrantEvent(event: AndcoWebhookEvent): event is AndcoGrantWebhookEvent;
|
|
191
195
|
/**
|
|
192
|
-
* Creates a verifier for
|
|
196
|
+
* Creates a verifier for AndCo webhook deliveries.
|
|
193
197
|
*
|
|
194
|
-
*
|
|
195
|
-
* `kid` in `andco-signature`. The verifier fetches
|
|
198
|
+
* AndCo signs `${eventId}.${timestamp}.${rawBody}` with an Ed25519 key it owns and names the key by
|
|
199
|
+
* `kid` in `andco-signature`. The verifier fetches AndCo's public JWKS once, caches every key by
|
|
196
200
|
* `kid`, and refetches when a delivery names a `kid` it has not seen or the cache is older than
|
|
197
|
-
* {@link ANDCO_WEBHOOK_KEYS_TTL_MS}. Each fetch replaces the key set, so
|
|
201
|
+
* {@link ANDCO_WEBHOOK_KEYS_TTL_MS}. Each fetch replaces the key set, so AndCo rotates and withdraws keys
|
|
198
202
|
* without any change on the receiver. Fetch attempts are rate-limited, failed ones included. Verification uses Web Crypto only, so it runs on Node,
|
|
199
203
|
* Deno, Bun, Cloudflare Workers and edge runtimes alike.
|
|
200
204
|
*
|
|
@@ -226,7 +230,7 @@ declare function isGrantEvent(event: AndcoWebhookEvent): event is AndcoGrantWebh
|
|
|
226
230
|
*/
|
|
227
231
|
declare function verifier(options?: AndcoWebhookVerifierOptions): AndcoWebhookVerify;
|
|
228
232
|
/**
|
|
229
|
-
* Receiving
|
|
233
|
+
* Receiving AndCo webhooks. See {@link verifier} and {@link isGrantEvent}.
|
|
230
234
|
*
|
|
231
235
|
* @example
|
|
232
236
|
* const verify = andcoWebhooks.verifier();
|
package/dist/webhooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":"AAGA,uDAAuD;AACvD,eAAO,MAAM,qBAAqB;;;;CAIxB,CAAC;AAEX,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,EAAG,SAAkB,CAAC;AAE1D,oFAAoF;AACpF,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAEnD,wFAAwF;AACxF,eAAO,MAAM,sBAAsB,uDAA+D,CAAC;AAEnG;;;GAGG;AACH,eAAO,MAAM,yBAAyB,QAAc,CAAC;AAErD;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAExG;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAErF;AAED,6FAA6F;AAC7F,eAAO,MAAM,yBAAyB;IACpC,2EAA2E;;IAE3E,4DAA4D;;IAE5D,0EAA0E;;IAE1E,yEAAyE;;IAEzE,uDAAuD;;IAEvD,6GAA6G;;IAE7G,sDAAsD;;CAE9C,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,OAAO,yBAAyB,CAAC,CAAC;AAE/G;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;aAGxB,IAAI,EAAE,qBAAqB;IAF7C,SAAyB,IAAI,uBAAuB;gBAElC,IAAI,EAAE,qBAAqB,EAC3C,OAAO,GAAE,MAAa,EACtB,OAAO,CAAC,EAAE;QA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;;;;;;;;;;;;;GAmCG;AACH,iBAAS,QAAQ,CAAC,OAAO,GAAE,2BAAgC,GAAG,kBAAkB,CA4H/E;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;CAAsC,CAAC"}
|
package/dist/webhooks.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { ANDCO_API_ORIGIN } from "./constants.js";
|
|
2
|
-
|
|
2
|
+
import { SafeURL } from "./urls.js";
|
|
3
|
+
/** Header names of a signed AndCo webhook delivery. */
|
|
3
4
|
export const ANDCO_WEBHOOK_HEADERS = {
|
|
4
5
|
eventId: "andco-event-id",
|
|
5
6
|
timestamp: "andco-timestamp",
|
|
6
7
|
signature: "andco-signature",
|
|
7
8
|
};
|
|
8
|
-
/** The only signature algorithm
|
|
9
|
+
/** The only signature algorithm AndCo signs webhook deliveries with. */
|
|
9
10
|
export const ANDCO_WEBHOOK_ALGORITHM = "Ed25519";
|
|
10
11
|
/** How far a delivery timestamp may drift from the receiver's clock, in seconds. */
|
|
11
12
|
export const ANDCO_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
12
|
-
/**
|
|
13
|
+
/** AndCo's public webhook keys. Platform serves the same document at its own origin. */
|
|
13
14
|
export const ANDCO_WEBHOOK_JWKS_URL = `${ANDCO_API_ORIGIN}/.well-known/webhook-keys.json`;
|
|
14
15
|
/**
|
|
15
16
|
* How long a fetched JWKS is trusted, in milliseconds. Past it, the next delivery reloads the keys
|
|
16
|
-
* even when its `kid` is known, so a key
|
|
17
|
+
* even when its `kid` is known, so a key AndCo withdrew stops verifying.
|
|
17
18
|
*/
|
|
18
19
|
export const ANDCO_WEBHOOK_KEYS_TTL_MS = 60 * 60_000;
|
|
19
20
|
/**
|
|
20
|
-
* The exact string
|
|
21
|
+
* The exact string AndCo signs for one delivery: `${eventId}.${timestamp}.${rawBody}`.
|
|
21
22
|
*
|
|
22
23
|
* Binding the event id and the timestamp into the signed bytes means a captured body can be
|
|
23
24
|
* replayed neither under a later timestamp nor as a different event.
|
|
@@ -58,7 +59,7 @@ export const ANDCO_WEBHOOK_ERROR_CODES = {
|
|
|
58
59
|
};
|
|
59
60
|
/**
|
|
60
61
|
* A webhook delivery that must not be trusted. Answer it with a 4xx and do not act on its body;
|
|
61
|
-
*
|
|
62
|
+
* AndCo retries deliveries that are not acknowledged with a 2xx.
|
|
62
63
|
*
|
|
63
64
|
* @example
|
|
64
65
|
* try {
|
|
@@ -79,7 +80,7 @@ export class AndcoWebhookError extends Error {
|
|
|
79
80
|
/** The Grant lifecycle event types the verifier checks and types. */
|
|
80
81
|
export const ANDCO_WEBHOOK_GRANT_EVENT_TYPES = ["grant.revoked", "grant.expired", "grant.updated"];
|
|
81
82
|
const SIGNATURE_HEADER = /^\s*kid=([A-Za-z0-9._:-]{1,128})\s*,\s*alg=([A-Za-z0-9]+)\s*,\s*sig=([A-Za-z0-9_-]+)\s*$/;
|
|
82
|
-
/** JWKS fetch attempts, successful or not, are at most one per this interval, so forged kids cannot flood
|
|
83
|
+
/** JWKS fetch attempts, successful or not, are at most one per this interval, so forged kids cannot flood AndCo. */
|
|
83
84
|
const UNKNOWN_KID_REFRESH_MS = 60_000;
|
|
84
85
|
function headerOf(headers, name) {
|
|
85
86
|
if (typeof headers.get === "function")
|
|
@@ -155,12 +156,12 @@ function hasLifecyclePayload(event) {
|
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
/**
|
|
158
|
-
* Creates a verifier for
|
|
159
|
+
* Creates a verifier for AndCo webhook deliveries.
|
|
159
160
|
*
|
|
160
|
-
*
|
|
161
|
-
* `kid` in `andco-signature`. The verifier fetches
|
|
161
|
+
* AndCo signs `${eventId}.${timestamp}.${rawBody}` with an Ed25519 key it owns and names the key by
|
|
162
|
+
* `kid` in `andco-signature`. The verifier fetches AndCo's public JWKS once, caches every key by
|
|
162
163
|
* `kid`, and refetches when a delivery names a `kid` it has not seen or the cache is older than
|
|
163
|
-
* {@link ANDCO_WEBHOOK_KEYS_TTL_MS}. Each fetch replaces the key set, so
|
|
164
|
+
* {@link ANDCO_WEBHOOK_KEYS_TTL_MS}. Each fetch replaces the key set, so AndCo rotates and withdraws keys
|
|
164
165
|
* without any change on the receiver. Fetch attempts are rate-limited, failed ones included. Verification uses Web Crypto only, so it runs on Node,
|
|
165
166
|
* Deno, Bun, Cloudflare Workers and edge runtimes alike.
|
|
166
167
|
*
|
|
@@ -191,7 +192,7 @@ function hasLifecyclePayload(event) {
|
|
|
191
192
|
* ```
|
|
192
193
|
*/
|
|
193
194
|
function verifier(options = {}) {
|
|
194
|
-
const jwksUrl =
|
|
195
|
+
const jwksUrl = new SafeURL(options.jwksUrl ?? ANDCO_WEBHOOK_JWKS_URL).href;
|
|
195
196
|
const tolerance = options.toleranceSeconds ?? ANDCO_WEBHOOK_TOLERANCE_SECONDS;
|
|
196
197
|
const now = options.now ?? (() => Math.floor(Date.now() / 1000));
|
|
197
198
|
const ttl = options.keysTtlMs ?? ANDCO_WEBHOOK_KEYS_TTL_MS;
|
|
@@ -204,7 +205,8 @@ function verifier(options = {}) {
|
|
|
204
205
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
205
206
|
let response;
|
|
206
207
|
try {
|
|
207
|
-
|
|
208
|
+
// A redirect could lead the key fetch off HTTPS or to a host that does not speak for AndCo.
|
|
209
|
+
response = await fetchImpl(jwksUrl, { headers: { Accept: "application/json" }, redirect: "error" });
|
|
208
210
|
}
|
|
209
211
|
catch (error) {
|
|
210
212
|
throw new AndcoWebhookError(ANDCO_WEBHOOK_ERROR_CODES.JWKS_UNAVAILABLE, `Could not fetch ${jwksUrl}`, {
|
|
@@ -216,7 +218,7 @@ function verifier(options = {}) {
|
|
|
216
218
|
if (!Array.isArray(entries)) {
|
|
217
219
|
throw new AndcoWebhookError(ANDCO_WEBHOOK_ERROR_CODES.JWKS_UNAVAILABLE, `${jwksUrl} answered ${response.status} without a JWKS`);
|
|
218
220
|
}
|
|
219
|
-
// Replace, never merge: a kid
|
|
221
|
+
// Replace, never merge: a kid AndCo withdrew must stop verifying.
|
|
220
222
|
const next = new Map();
|
|
221
223
|
for (const entry of entries) {
|
|
222
224
|
if (entry?.["kty"] !== "OKP" || entry["crv"] !== "Ed25519" || typeof entry["x"] !== "string")
|
|
@@ -317,7 +319,7 @@ function verifier(options = {}) {
|
|
|
317
319
|
};
|
|
318
320
|
}
|
|
319
321
|
/**
|
|
320
|
-
* Receiving
|
|
322
|
+
* Receiving AndCo webhooks. See {@link verifier} and {@link isGrantEvent}.
|
|
321
323
|
*
|
|
322
324
|
* @example
|
|
323
325
|
* const verify = andcoWebhooks.verifier();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Browser popup geometry shared by every
|
|
1
|
+
/** Browser popup geometry shared by every AndCo surface that opens one. */
|
|
2
2
|
export type AndcoPopupPosition = "center" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
3
3
|
export type AndcoPopupGeometry = {
|
|
4
4
|
width?: number | string;
|
|
@@ -18,7 +18,7 @@ export declare function windowFeaturesFrom({ position, ...options }: AndcoPopupG
|
|
|
18
18
|
/** Whether this runtime has a DOM. A pure predicate both sides use before touching `window`. */
|
|
19
19
|
export declare function isBrowser(): boolean;
|
|
20
20
|
/**
|
|
21
|
-
* Prefix of the `window.name` an
|
|
21
|
+
* Prefix of the `window.name` an AndCo popup carries, followed by its Presentation ID.
|
|
22
22
|
*
|
|
23
23
|
* Part of the Protocol Contract because both sides read it: whoever opens the popup writes the
|
|
24
24
|
* name, and the callback document uses it to recognise that the result is its to relay. Two
|
package/dist/window-features.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Browser popup geometry shared by every
|
|
1
|
+
/** Browser popup geometry shared by every AndCo surface that opens one. */
|
|
2
2
|
/**
|
|
3
3
|
* Builds a `window.open` features string.
|
|
4
4
|
*
|
|
@@ -46,7 +46,7 @@ export function isBrowser() {
|
|
|
46
46
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* Prefix of the `window.name` an
|
|
49
|
+
* Prefix of the `window.name` an AndCo popup carries, followed by its Presentation ID.
|
|
50
50
|
*
|
|
51
51
|
* Part of the Protocol Contract because both sides read it: whoever opens the popup writes the
|
|
52
52
|
* name, and the callback document uses it to recognise that the result is its to relay. Two
|