@andco/protocol 0.0.14 → 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/errors.d.ts +9 -9
- package/dist/errors.js +9 -9
- 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-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/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 +12 -2
- package/dist/signing.d.ts.map +1 -1
- package/dist/signing.js +6 -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/urls.d.ts +2 -2
- package/dist/urls.js +3 -3
- package/dist/userinfo.d.ts +2 -2
- package/dist/userinfo.js +2 -2
- package/dist/webhooks.d.ts +16 -16
- package/dist/webhooks.js +14 -14
- 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,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,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. */
|
package/dist/urls.d.ts
CHANGED
|
@@ -61,10 +61,10 @@ export declare class SafeURL<const TUrl extends string | URL = string | URL> ext
|
|
|
61
61
|
constructor(url: TUrl, base?: string | URL, overwrite?: BetterURLOverwrite<TUrl>);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* A {@link SafeURL} for an
|
|
64
|
+
* A {@link SafeURL} for an AndCo endpoint: a base URL the SDK joins a path to, such as the API or the
|
|
65
65
|
* Authorization Server. It carries no query or fragment, not even an empty `?` or `#`, since one would
|
|
66
66
|
* take the joined path. A URL the SDK adds query parameters to, such as an authorization endpoint, is a
|
|
67
|
-
* plain SafeURL. Every
|
|
67
|
+
* plain SafeURL. Every AndCo SDK refuses the same endpoints and keeps an endpoint's path when it joins
|
|
68
68
|
* one; ADR 0043 records both rules.
|
|
69
69
|
*
|
|
70
70
|
* @example
|
package/dist/urls.js
CHANGED
|
@@ -133,10 +133,10 @@ export class SafeURL extends BetterURL {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
* A {@link SafeURL} for an
|
|
136
|
+
* A {@link SafeURL} for an AndCo endpoint: a base URL the SDK joins a path to, such as the API or the
|
|
137
137
|
* Authorization Server. It carries no query or fragment, not even an empty `?` or `#`, since one would
|
|
138
138
|
* take the joined path. A URL the SDK adds query parameters to, such as an authorization endpoint, is a
|
|
139
|
-
* plain SafeURL. Every
|
|
139
|
+
* plain SafeURL. Every AndCo SDK refuses the same endpoints and keeps an endpoint's path when it joins
|
|
140
140
|
* one; ADR 0043 records both rules.
|
|
141
141
|
*
|
|
142
142
|
* @example
|
|
@@ -147,7 +147,7 @@ export class EndpointURL extends SafeURL {
|
|
|
147
147
|
super(url);
|
|
148
148
|
// `search` and `hash` are empty for a bare `?` or `#`, but the serialized URL keeps the character.
|
|
149
149
|
if (this.href.includes("?") || this.href.includes("#")) {
|
|
150
|
-
throw new TypeError("An
|
|
150
|
+
throw new TypeError("An AndCo endpoint cannot contain a query or a fragment, not even an empty one");
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
/**
|
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
|
|
@@ -156,8 +156,8 @@ export type AndcoWebhookDelivery = {
|
|
|
156
156
|
};
|
|
157
157
|
export type AndcoWebhookVerifierOptions = {
|
|
158
158
|
/**
|
|
159
|
-
* Where to fetch
|
|
160
|
-
*
|
|
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
161
|
* fragment: `verifier` throws a `TypeError` otherwise, before any delivery arrives.
|
|
162
162
|
*/
|
|
163
163
|
jwksUrl?: string | URL;
|
|
@@ -193,12 +193,12 @@ export type AndcoWebhookVerify = (delivery: Request | AndcoWebhookDelivery) => P
|
|
|
193
193
|
*/
|
|
194
194
|
declare function isGrantEvent(event: AndcoWebhookEvent): event is AndcoGrantWebhookEvent;
|
|
195
195
|
/**
|
|
196
|
-
* Creates a verifier for
|
|
196
|
+
* Creates a verifier for AndCo webhook deliveries.
|
|
197
197
|
*
|
|
198
|
-
*
|
|
199
|
-
* `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
|
|
200
200
|
* `kid`, and refetches when a delivery names a `kid` it has not seen or the cache is older than
|
|
201
|
-
* {@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
|
|
202
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,
|
|
203
203
|
* Deno, Bun, Cloudflare Workers and edge runtimes alike.
|
|
204
204
|
*
|
|
@@ -230,7 +230,7 @@ declare function isGrantEvent(event: AndcoWebhookEvent): event is AndcoGrantWebh
|
|
|
230
230
|
*/
|
|
231
231
|
declare function verifier(options?: AndcoWebhookVerifierOptions): AndcoWebhookVerify;
|
|
232
232
|
/**
|
|
233
|
-
* Receiving
|
|
233
|
+
* Receiving AndCo webhooks. See {@link verifier} and {@link isGrantEvent}.
|
|
234
234
|
*
|
|
235
235
|
* @example
|
|
236
236
|
* const verify = andcoWebhooks.verifier();
|
package/dist/webhooks.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { ANDCO_API_ORIGIN } from "./constants.js";
|
|
2
2
|
import { SafeURL } from "./urls.js";
|
|
3
|
-
/** Header names of a signed
|
|
3
|
+
/** Header names of a signed AndCo webhook delivery. */
|
|
4
4
|
export const ANDCO_WEBHOOK_HEADERS = {
|
|
5
5
|
eventId: "andco-event-id",
|
|
6
6
|
timestamp: "andco-timestamp",
|
|
7
7
|
signature: "andco-signature",
|
|
8
8
|
};
|
|
9
|
-
/** The only signature algorithm
|
|
9
|
+
/** The only signature algorithm AndCo signs webhook deliveries with. */
|
|
10
10
|
export const ANDCO_WEBHOOK_ALGORITHM = "Ed25519";
|
|
11
11
|
/** How far a delivery timestamp may drift from the receiver's clock, in seconds. */
|
|
12
12
|
export const ANDCO_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
13
|
-
/**
|
|
13
|
+
/** AndCo's public webhook keys. Platform serves the same document at its own origin. */
|
|
14
14
|
export const ANDCO_WEBHOOK_JWKS_URL = `${ANDCO_API_ORIGIN}/.well-known/webhook-keys.json`;
|
|
15
15
|
/**
|
|
16
16
|
* How long a fetched JWKS is trusted, in milliseconds. Past it, the next delivery reloads the keys
|
|
17
|
-
* even when its `kid` is known, so a key
|
|
17
|
+
* even when its `kid` is known, so a key AndCo withdrew stops verifying.
|
|
18
18
|
*/
|
|
19
19
|
export const ANDCO_WEBHOOK_KEYS_TTL_MS = 60 * 60_000;
|
|
20
20
|
/**
|
|
21
|
-
* The exact string
|
|
21
|
+
* The exact string AndCo signs for one delivery: `${eventId}.${timestamp}.${rawBody}`.
|
|
22
22
|
*
|
|
23
23
|
* Binding the event id and the timestamp into the signed bytes means a captured body can be
|
|
24
24
|
* replayed neither under a later timestamp nor as a different event.
|
|
@@ -59,7 +59,7 @@ export const ANDCO_WEBHOOK_ERROR_CODES = {
|
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
61
|
* A webhook delivery that must not be trusted. Answer it with a 4xx and do not act on its body;
|
|
62
|
-
*
|
|
62
|
+
* AndCo retries deliveries that are not acknowledged with a 2xx.
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
65
|
* try {
|
|
@@ -80,7 +80,7 @@ export class AndcoWebhookError extends Error {
|
|
|
80
80
|
/** The Grant lifecycle event types the verifier checks and types. */
|
|
81
81
|
export const ANDCO_WEBHOOK_GRANT_EVENT_TYPES = ["grant.revoked", "grant.expired", "grant.updated"];
|
|
82
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*$/;
|
|
83
|
-
/** 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. */
|
|
84
84
|
const UNKNOWN_KID_REFRESH_MS = 60_000;
|
|
85
85
|
function headerOf(headers, name) {
|
|
86
86
|
if (typeof headers.get === "function")
|
|
@@ -156,12 +156,12 @@ function hasLifecyclePayload(event) {
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
|
-
* Creates a verifier for
|
|
159
|
+
* Creates a verifier for AndCo webhook deliveries.
|
|
160
160
|
*
|
|
161
|
-
*
|
|
162
|
-
* `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
|
|
163
163
|
* `kid`, and refetches when a delivery names a `kid` it has not seen or the cache is older than
|
|
164
|
-
* {@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
|
|
165
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,
|
|
166
166
|
* Deno, Bun, Cloudflare Workers and edge runtimes alike.
|
|
167
167
|
*
|
|
@@ -205,7 +205,7 @@ function verifier(options = {}) {
|
|
|
205
205
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
206
206
|
let response;
|
|
207
207
|
try {
|
|
208
|
-
// A redirect could lead the key fetch off HTTPS or to a host that does not speak for
|
|
208
|
+
// A redirect could lead the key fetch off HTTPS or to a host that does not speak for AndCo.
|
|
209
209
|
response = await fetchImpl(jwksUrl, { headers: { Accept: "application/json" }, redirect: "error" });
|
|
210
210
|
}
|
|
211
211
|
catch (error) {
|
|
@@ -218,7 +218,7 @@ function verifier(options = {}) {
|
|
|
218
218
|
if (!Array.isArray(entries)) {
|
|
219
219
|
throw new AndcoWebhookError(ANDCO_WEBHOOK_ERROR_CODES.JWKS_UNAVAILABLE, `${jwksUrl} answered ${response.status} without a JWKS`);
|
|
220
220
|
}
|
|
221
|
-
// Replace, never merge: a kid
|
|
221
|
+
// Replace, never merge: a kid AndCo withdrew must stop verifying.
|
|
222
222
|
const next = new Map();
|
|
223
223
|
for (const entry of entries) {
|
|
224
224
|
if (entry?.["kty"] !== "OKP" || entry["crv"] !== "Ed25519" || typeof entry["x"] !== "string")
|
|
@@ -319,7 +319,7 @@ function verifier(options = {}) {
|
|
|
319
319
|
};
|
|
320
320
|
}
|
|
321
321
|
/**
|
|
322
|
-
* Receiving
|
|
322
|
+
* Receiving AndCo webhooks. See {@link verifier} and {@link isGrantEvent}.
|
|
323
323
|
*
|
|
324
324
|
* @example
|
|
325
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andco/protocol",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"andco": {
|
|
5
5
|
"release": 1780358400
|
|
6
6
|
},
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yaml": "2.9.1"
|
|
67
67
|
},
|
|
68
68
|
"license": "Apache-2.0",
|
|
69
|
-
"description": "Shared protocol types, message schemas and transport contracts for the
|
|
69
|
+
"description": "Shared protocol types, message schemas and transport contracts for the AndCo SDK.",
|
|
70
70
|
"author": "Patricio Lopez Juri <patricio.lopez@haulmer.com>",
|
|
71
71
|
"repository": {
|
|
72
72
|
"type": "git",
|