@andco/protocol 0.0.3 → 0.0.5
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/LICENSE +1 -1
- package/README.md +51 -3
- package/dist/api-errors.d.ts +114 -0
- package/dist/api-errors.d.ts.map +1 -0
- package/dist/api-errors.js +116 -0
- package/dist/authorization-preparation.d.ts +52 -543
- package/dist/authorization-preparation.d.ts.map +1 -1
- package/dist/authorization-preparation.js +19 -42
- package/dist/authorization.d.ts +64 -22
- package/dist/authorization.d.ts.map +1 -1
- package/dist/authorization.js +136 -55
- package/dist/consent.d.ts +5 -8
- package/dist/consent.d.ts.map +1 -1
- package/dist/consent.js +5 -62
- package/dist/constants.d.ts +19 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +19 -3
- package/dist/errors.d.ts +154 -58
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +174 -57
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/intent-input.d.ts +1022 -288
- package/dist/intent-input.d.ts.map +1 -1
- package/dist/intent-input.js +284 -40
- package/dist/messages/error.d.ts +1 -2
- package/dist/messages/error.d.ts.map +1 -1
- package/dist/messages/error.js +5 -2
- package/dist/messages/index.d.ts +1 -1
- package/dist/native-copy.d.ts +23 -2
- package/dist/native-copy.d.ts.map +1 -1
- package/dist/native-copy.js +65 -117
- package/dist/native-intent.d.ts +126 -75
- package/dist/native-intent.d.ts.map +1 -1
- package/dist/native-intent.js +140 -48
- package/dist/rar/account-matchers.d.ts +579 -0
- package/dist/rar/account-matchers.d.ts.map +1 -0
- package/dist/rar/account-matchers.js +480 -0
- package/dist/rar/bank.d.ts +1549 -0
- package/dist/rar/bank.d.ts.map +1 -0
- package/dist/rar/bank.js +379 -0
- package/dist/rar/catalog.d.ts +1155 -0
- package/dist/rar/catalog.d.ts.map +1 -0
- package/dist/rar/catalog.js +175 -0
- package/dist/rar/detail.d.ts +39 -0
- package/dist/rar/detail.d.ts.map +1 -0
- package/dist/rar/detail.js +44 -0
- package/dist/rar/index.d.ts +9 -0
- package/dist/rar/index.d.ts.map +1 -0
- package/dist/rar/index.js +8 -0
- package/dist/rar/money.d.ts +58 -0
- package/dist/rar/money.d.ts.map +1 -0
- package/dist/rar/money.js +61 -0
- package/dist/rar/project-users.d.ts +43 -0
- package/dist/rar/project-users.d.ts.map +1 -0
- package/dist/rar/project-users.js +63 -0
- package/dist/rar/subject-data.d.ts +170 -0
- package/dist/rar/subject-data.d.ts.map +1 -0
- package/dist/rar/subject-data.js +127 -0
- package/dist/rar/subject.d.ts +166 -0
- package/dist/rar/subject.d.ts.map +1 -0
- package/dist/rar/subject.js +119 -0
- package/dist/scopes.d.ts +5 -30
- package/dist/scopes.d.ts.map +1 -1
- package/dist/scopes.js +0 -13
- package/dist/service-grants.d.ts +44 -0
- package/dist/service-grants.d.ts.map +1 -0
- package/dist/service-grants.js +45 -0
- package/dist/signing.d.ts +56 -0
- package/dist/signing.d.ts.map +1 -0
- package/dist/signing.js +233 -0
- package/dist/transport/financial-events.d.ts +90 -35
- package/dist/transport/financial-events.d.ts.map +1 -1
- package/dist/transport/financial-events.js +7 -1
- package/dist/transport/generated/oauth-api.d.ts +932 -441
- package/dist/transport/generated/oauth-api.d.ts.map +1 -1
- package/dist/transport/index.d.ts +0 -1
- package/dist/transport/index.d.ts.map +1 -1
- package/dist/transport/index.js +0 -1
- package/dist/transport/intents.d.ts +155 -23
- package/dist/transport/intents.d.ts.map +1 -1
- package/dist/transport/intents.js +192 -59
- package/dist/transport/rest.d.ts +19 -8
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/transport/rest.js +1 -1
- package/dist/urls.d.ts.map +1 -1
- package/dist/urls.js +1 -1
- package/dist/userinfo.d.ts +10 -1
- package/dist/userinfo.d.ts.map +1 -1
- package/dist/userinfo.js +10 -1
- package/dist/utils.d.ts +15 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +31 -0
- package/dist/webhooks.d.ts +154 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +249 -0
- package/package.json +21 -2
- package/dist/automatic-charge.d.ts +0 -314
- package/dist/automatic-charge.d.ts.map +0 -1
- package/dist/automatic-charge.js +0 -126
- package/dist/bank-account-authorization.d.ts +0 -6
- package/dist/bank-account-authorization.d.ts.map +0 -1
- package/dist/bank-account-authorization.js +0 -13
- package/dist/transport/webhooks.d.ts +0 -27
- package/dist/transport/webhooks.d.ts.map +0 -1
- package/dist/transport/webhooks.js +0 -68
- package/dist/webhook-input.d.ts +0 -22
- package/dist/webhook-input.d.ts.map +0 -1
- package/dist/webhook-input.js +0 -11
- package/dist/webhook-signature.d.ts +0 -54
- package/dist/webhook-signature.d.ts.map +0 -1
- package/dist/webhook-signature.js +0 -74
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-preparation.d.ts","sourceRoot":"","sources":["../src/authorization-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"authorization-preparation.d.ts","sourceRoot":"","sources":["../src/authorization-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,uEAAuE;AACvE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;aAkBlC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;aAgBrC,CAAC;AAiHH,qGAAqG;AACrG,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAS9C,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;aAI7C,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;aAMxC,CAAC;AAEH,6EAA6E;AAC7E,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mCAAmC,CAAC,CAAC;AACtG,mFAAmF;AACnF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kCAAkC,CAAC,CAAC;AACpG,wEAAwE;AACxE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,6BAA6B,CAAC,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { AutomaticChargeAuthorizationSchema } from "./automatic-charge.js";
|
|
3
|
-
import { BANK_ACCOUNT_AUTHORIZATION_ACTIONS, BankAccountAuthorizationActionSchema, } from "./bank-account-authorization.js";
|
|
4
2
|
import { AndCoOAuthScopePolicySchema } from "./miniapp-manifest.js";
|
|
5
3
|
/** Server-resolved scope policy and provider-owned consent content. */
|
|
6
4
|
export const AndCoConsentScopeSchema = /* @__PURE__ */ v.object({
|
|
7
5
|
...AndCoOAuthScopePolicySchema.entries,
|
|
8
6
|
resourceServerId: v.optional(v.string()),
|
|
9
7
|
resourceServerName: v.optional(v.pipe(v.string(), v.maxLength(255))),
|
|
8
|
+
resourceProjectId: v.optional(v.pipe(v.string(), v.uuid())),
|
|
9
|
+
resourceProjectName: v.optional(v.pipe(v.string(), v.maxLength(256))),
|
|
10
|
+
resourceProjectHomeUri: v.optional(v.nullable(v.pipe(v.string(), v.url()))),
|
|
11
|
+
resourcePublisherName: v.optional(v.pipe(v.string(), v.maxLength(256))),
|
|
10
12
|
scopeDescription: v.optional(v.pipe(v.string(), v.maxLength(1024))),
|
|
11
13
|
// Date of the active OAuth Grant on this Connection that already covers this Scope, null when none
|
|
12
14
|
// does. A fact of this person's history, not Client configuration -- kept separate from `mode`,
|
|
@@ -18,43 +20,26 @@ export const AndCoConsentScopeSchema = /* @__PURE__ */ v.object({
|
|
|
18
20
|
// without touching what `optional` means on a brand-new Connection. See ADR 0041.
|
|
19
21
|
connectionHasPriorGrant: v.boolean(),
|
|
20
22
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
productName: v.nullable(v.string()),
|
|
27
|
-
currency: v.pipe(v.string(), v.minLength(1), v.maxLength(16)),
|
|
28
|
-
})), v.minLength(1), v.maxLength(100)),
|
|
29
|
-
});
|
|
30
|
-
/** Platform-resolved Company, installation and provider permission context. */
|
|
23
|
+
/**
|
|
24
|
+
* Platform-resolved subject and provider permission context of a third-party authorization.
|
|
25
|
+
* `organizationId` and `organizationName` are `null` when the third-party details reach the
|
|
26
|
+
* consenting Profile rather than one of their Organizations.
|
|
27
|
+
*/
|
|
31
28
|
export const AndCoResourceConsentSchema = /* @__PURE__ */ v.object({
|
|
32
29
|
allowed: v.boolean(),
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
organizationId: v.nullable(v.string()),
|
|
31
|
+
organizationName: v.nullable(v.string()),
|
|
35
32
|
details: v.array(v.object({ name: v.string(), actions: v.array(v.object({ id: v.string(), description: v.string() })) })),
|
|
36
33
|
errorCode: v.nullable(v.string()),
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
clientProjectName: v.string(),
|
|
35
|
+
resourceServerId: v.optional(v.pipe(v.string(), v.uuid())),
|
|
39
36
|
resourceProjectId: v.pipe(v.string(), v.uuid()),
|
|
37
|
+
resourceProjectName: v.optional(v.string()),
|
|
38
|
+
resourceProjectHomeUri: v.optional(v.nullable(v.pipe(v.string(), v.url()))),
|
|
39
|
+
resourcePublisherName: v.optional(v.string()),
|
|
40
40
|
resourceName: v.string(),
|
|
41
41
|
resource: v.string(),
|
|
42
42
|
});
|
|
43
|
-
/** Company accounts and immutable constraints resolved by Platform for automatic charges. */
|
|
44
|
-
export const AndCoChargeConsentSchema = /* @__PURE__ */ v.object({
|
|
45
|
-
orgId: v.pipe(v.number(), v.integer()),
|
|
46
|
-
companyName: v.string(),
|
|
47
|
-
projectId: v.pipe(v.string(), v.uuid()),
|
|
48
|
-
projectName: v.string(),
|
|
49
|
-
operatorName: v.string(),
|
|
50
|
-
request: AutomaticChargeAuthorizationSchema,
|
|
51
|
-
bindingAccountId: v.nullable(v.pipe(v.string(), v.uuid())),
|
|
52
|
-
openingName: v.optional(v.nullable(v.string())),
|
|
53
|
-
workflowId: v.nullable(v.pipe(v.string(), v.uuid())),
|
|
54
|
-
bankStatus: v.nullable(v.string()),
|
|
55
|
-
budgetAnchor: v.nullable(v.string()),
|
|
56
|
-
accounts: v.array(v.object({ id: v.pipe(v.string(), v.uuid()), number: v.nullable(v.string()), name: v.nullable(v.string()) })),
|
|
57
|
-
});
|
|
58
43
|
const AndCoAuthorizationClientSchema = /* @__PURE__ */ v.object({
|
|
59
44
|
id: v.pipe(v.string(), v.minLength(1), v.maxLength(255)),
|
|
60
45
|
name: v.pipe(v.string(), v.minLength(1), v.maxLength(255)),
|
|
@@ -94,11 +79,9 @@ const AndCoAuthorizationConsentRequiredSchema = /* @__PURE__ */ v.object({
|
|
|
94
79
|
client: AndCoAuthorizationClientSchema,
|
|
95
80
|
redirectHost: v.pipe(v.string(), v.minLength(1), v.maxLength(255)),
|
|
96
81
|
scopes: v.pipe(v.array(AndCoConsentScopeSchema), v.maxLength(50)),
|
|
97
|
-
bankAccountAuthorization: v.optional(BankAccountAuthorizationSchema),
|
|
98
82
|
resourceAuthorization: v.optional(AndCoResourceConsentSchema),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// Kept alongside `companySubject` for the native producer's still-current selection UI (consent-drawer.tsx,
|
|
83
|
+
organizationSubject: v.optional(v.object({ organizationId: v.number(), organizationName: v.string() })),
|
|
84
|
+
// Kept alongside `organizationSubject` for the native producer's still-current selection UI (consent-drawer.tsx,
|
|
102
85
|
// Tauri app.tsx): `organization_subject_required` (reason: "selection") absorbs this case once the platform's
|
|
103
86
|
// decision module (Phase 4) derives it instead. Not part of the design session's consent_required shape.
|
|
104
87
|
organizationSelection: v.optional(v.object({
|
|
@@ -107,12 +90,6 @@ const AndCoAuthorizationConsentRequiredSchema = /* @__PURE__ */ v.object({
|
|
|
107
90
|
})),
|
|
108
91
|
user: v.object({ email: v.pipe(v.string(), v.minLength(1), v.maxLength(320)) }),
|
|
109
92
|
});
|
|
110
|
-
const AndCoAuthorizationChargeAccountPreparationRequiredSchema = /* @__PURE__ */ v.object({
|
|
111
|
-
status: v.literal("charge_account_preparation_required"),
|
|
112
|
-
authorizationId: v.pipe(v.string(), v.minLength(1), v.maxLength(128)),
|
|
113
|
-
client: AndCoAuthorizationClientSchema,
|
|
114
|
-
charge: AndCoChargeConsentSchema,
|
|
115
|
-
});
|
|
116
93
|
const AndCoAuthorizationOrganizationSubjectRequiredSchema = /* @__PURE__ */ v.object({
|
|
117
94
|
status: v.literal("organization_subject_required"),
|
|
118
95
|
authorizationId: v.pipe(v.string(), v.minLength(1), v.maxLength(128)),
|
|
@@ -141,6 +118,7 @@ const AndCoAuthorizationConsentAlreadyGrantedSchema = /* @__PURE__ */ v.object({
|
|
|
141
118
|
redirectHost: v.pipe(v.string(), v.minLength(1), v.maxLength(255)),
|
|
142
119
|
grantedAt: v.pipe(v.string(), v.minLength(1), v.maxLength(64)),
|
|
143
120
|
scopes: v.pipe(v.array(AndCoConsentScopeSchema), v.maxLength(50)),
|
|
121
|
+
organizationSubject: v.optional(v.object({ organizationId: v.number(), organizationName: v.string() })),
|
|
144
122
|
user: v.object({ email: v.pipe(v.string(), v.minLength(1), v.maxLength(320)) }),
|
|
145
123
|
});
|
|
146
124
|
// Admitted by the contract so incremental consent (a separate task) does not need a breaking change to add it.
|
|
@@ -166,7 +144,6 @@ export const AndCoAuthorizationPreparationSchema = /* @__PURE__ */ v.variant("st
|
|
|
166
144
|
AndCoAuthorizationSignInRequiredSchema,
|
|
167
145
|
AndCoAuthorizationPrerequisiteRequiredSchema,
|
|
168
146
|
AndCoAuthorizationConsentRequiredSchema,
|
|
169
|
-
AndCoAuthorizationChargeAccountPreparationRequiredSchema,
|
|
170
147
|
AndCoAuthorizationOrganizationSubjectRequiredSchema,
|
|
171
148
|
AndCoAuthorizationAlreadyAuthorizedSchema,
|
|
172
149
|
AndCoAuthorizationConsentAlreadyGrantedSchema,
|
package/dist/authorization.d.ts
CHANGED
|
@@ -11,26 +11,21 @@ export type AndCoAuthorizationTransportOptions = {
|
|
|
11
11
|
/** Receives redacted transport warnings. Defaults to `console.warn`. */
|
|
12
12
|
warn?: (message: string) => void;
|
|
13
13
|
};
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* OAuth parameter names that automatically require PAR.
|
|
16
|
+
* These parameters often contain sensitive information that should not be exposed in the URL.
|
|
17
|
+
* Hence requiring the more secure Pushed Authorization Request (PAR) method.
|
|
18
|
+
*/
|
|
15
19
|
export declare const ANDCO_SENSITIVE_AUTHORIZATION_PARAMETERS: readonly ["authorization_details", "country", "document_kind", "document_value", "email", "external_id", "id", "login_hint", "subject"];
|
|
16
20
|
/** Fine-grained authorization detail contributed by one Resource Server. */
|
|
17
21
|
export type AndCoAuthorizationDetail = Readonly<Record<string, unknown>>;
|
|
18
|
-
/** Human Profile selected for a personal-resource authorization. */
|
|
19
|
-
export type AndCoAuthorizationSubject = {
|
|
20
|
-
readonly type: "profile";
|
|
21
|
-
readonly identifier?: string;
|
|
22
|
-
};
|
|
23
|
-
/** Explicit Company context; omission authorizes personal resources. */
|
|
24
|
-
export type AndCoOrganizationContext = {
|
|
25
|
-
readonly orgId?: string | "select";
|
|
26
|
-
};
|
|
27
22
|
/** Immutable authorization contribution created by a Resource Server definition. */
|
|
28
23
|
export type AndCoResourceAuthorization<Scope extends string = string, Detail extends AndCoAuthorizationDetail = AndCoAuthorizationDetail> = {
|
|
29
|
-
readonly orgId?: string;
|
|
30
24
|
readonly resourceServerId: string;
|
|
31
25
|
readonly resource: string;
|
|
32
26
|
readonly scopes: readonly Scope[];
|
|
33
|
-
|
|
27
|
+
/** Omitted when the contribution asks for scopes only, as the SDK builders allow. */
|
|
28
|
+
readonly authorizationDetails?: readonly Detail[];
|
|
34
29
|
};
|
|
35
30
|
/** Options shared by immutable Resource Server authorization builders. */
|
|
36
31
|
export type AndCoResourceAuthorizationOptions<Scope extends string, Detail extends AndCoAuthorizationDetail> = {
|
|
@@ -52,7 +47,6 @@ export type AndCoResourceServerDefinition<Client> = {
|
|
|
52
47
|
};
|
|
53
48
|
/** Complete normalized authorization plan contributed by Resource Servers. */
|
|
54
49
|
export type AndCoAuthorizationPlan = {
|
|
55
|
-
readonly orgId?: string;
|
|
56
50
|
readonly resources: readonly string[];
|
|
57
51
|
readonly scopes: readonly string[];
|
|
58
52
|
readonly authorizationDetails: readonly AndCoAuthorizationDetail[];
|
|
@@ -80,19 +74,67 @@ export type AndCoResolveAuthorizationOptions = {
|
|
|
80
74
|
};
|
|
81
75
|
/** Error raised while validating or delivering an authorization request. */
|
|
82
76
|
export declare class AndCoAuthorizationRequestError extends Error {
|
|
83
|
-
readonly code: "invalid_authorization_request" | "sensitive_authorization_request" | "pushed_authorization_failed" | "invalid_pushed_authorization_response";
|
|
77
|
+
readonly code: "invalid_authorization_request" | "sensitive_authorization_request" | "pushed_authorization_failed" | "invalid_pushed_authorization_response" | "not_implemented";
|
|
84
78
|
readonly status?: number | undefined;
|
|
85
|
-
constructor(code: "invalid_authorization_request" | "sensitive_authorization_request" | "pushed_authorization_failed" | "invalid_pushed_authorization_response", message?: string, status?: number | undefined);
|
|
79
|
+
constructor(code: "invalid_authorization_request" | "sensitive_authorization_request" | "pushed_authorization_failed" | "invalid_pushed_authorization_response" | "not_implemented", message?: string, status?: number | undefined, options?: ErrorOptions);
|
|
86
80
|
}
|
|
87
81
|
/** Validates the opaque destination reference bound to an OAuth Client authorization. */
|
|
88
82
|
export declare function assertAndCoExternalId(value: string): void;
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Validates a resource indicator (RFC 8707): an absolute HTTPS URL -- or plaintext HTTP on a loopback
|
|
85
|
+
* development host -- carrying no credentials and no fragment.
|
|
86
|
+
*
|
|
87
|
+
* The parsed URL is discarded on purpose, and this is an assertion rather than a parse for that
|
|
88
|
+
* reason. An Authorization Server compares a resource as an exact string, so adopting whatever
|
|
89
|
+
* `URL` normalization produces -- a dropped default port, an added trailing slash -- would turn an
|
|
90
|
+
* audience that matches into one that does not.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* assertAndCoResource("https://api.andco.com"); // returns
|
|
94
|
+
* assertAndCoResource("https://api.andco.com/#section"); // throws: a fragment is not an audience
|
|
95
|
+
*/
|
|
96
|
+
export declare function assertAndCoResource(resource: string): void;
|
|
97
|
+
/**
|
|
98
|
+
* Ceiling of a PostgreSQL `serial` (`int4`), which is the type `organizations.organization_id`
|
|
99
|
+
* uses. An Organization identifier above this can never exist, and a validator that admits more
|
|
100
|
+
* digits than this passes a value straight through to a column that rejects it.
|
|
101
|
+
*/
|
|
102
|
+
export declare const ANDCO_MAX_ORGANIZATION_ID = 2147483647;
|
|
103
|
+
/**
|
|
104
|
+
* Composes Resource Server contributions without losing their audience association.
|
|
105
|
+
*
|
|
106
|
+
* Every detail, Andco's or a third party's, names whose resources it asks for in its own `subject`
|
|
107
|
+
* (`{ type: "profile" }`, `{ type: "organization", identifier? }`, or absent for the signed-in
|
|
108
|
+
* Profile). The plan binds each detail to its Resource Server through `locations` and refuses, with
|
|
109
|
+
* `not_implemented`, details that name different subjects: the Authorization Server answers the
|
|
110
|
+
* same, and failing here saves the round trip. A detail without a subject is left to the server,
|
|
111
|
+
* which applies the type's default.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const plan = createAndCoAuthorizationPlan([
|
|
116
|
+
* {
|
|
117
|
+
* resourceServerId: "00000000-0000-0000-0000-00000000f301",
|
|
118
|
+
* resource: "https://openfactura.localhost/api",
|
|
119
|
+
* scopes: [],
|
|
120
|
+
* authorizationDetails: [
|
|
121
|
+
* { type: "documents", actions: ["read"], subject: { type: "organization", identifier: "2" } },
|
|
122
|
+
* ],
|
|
123
|
+
* },
|
|
124
|
+
* ]);
|
|
125
|
+
* plan.authorizationDetails[0].locations; // ["https://openfactura.localhost/api"]
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function createAndCoAuthorizationPlan(authorizations?: readonly Partial<AndCoResourceAuthorization>[]): AndCoAuthorizationPlan;
|
|
129
|
+
/**
|
|
130
|
+
* Returns a copy of OAuth authorization parameters with one normalized Resource Server plan applied.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* const parameters = applyAndCoAuthorizationPlan(new URLSearchParams({ scope: "openid" }), plan);
|
|
135
|
+
* parameters.getAll("resource"); // plan.resources
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
96
138
|
export declare function applyAndCoAuthorizationPlan(parameters: URLSearchParams, plan: AndCoAuthorizationPlan): URLSearchParams;
|
|
97
139
|
/** Resolves and executes the configured GET/PAR authorization transport. */
|
|
98
140
|
export declare function resolveAndCoAuthorization(options: AndCoResolveAuthorizationOptions): Promise<AndCoResolvedAuthorization>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"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"}
|
package/dist/authorization.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
+
import { SubjectPickerSchema } from "./rar/subject.js";
|
|
2
3
|
import { SafeURL } from "./urls.js";
|
|
3
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* OAuth parameter names that automatically require PAR.
|
|
6
|
+
* These parameters often contain sensitive information that should not be exposed in the URL.
|
|
7
|
+
* Hence requiring the more secure Pushed Authorization Request (PAR) method.
|
|
8
|
+
*/
|
|
4
9
|
export const ANDCO_SENSITIVE_AUTHORIZATION_PARAMETERS = [
|
|
5
10
|
"authorization_details",
|
|
6
11
|
"country",
|
|
@@ -16,8 +21,8 @@ export const ANDCO_SENSITIVE_AUTHORIZATION_PARAMETERS = [
|
|
|
16
21
|
export class AndCoAuthorizationRequestError extends Error {
|
|
17
22
|
code;
|
|
18
23
|
status;
|
|
19
|
-
constructor(code, message = code, status) {
|
|
20
|
-
super(message);
|
|
24
|
+
constructor(code, message = code, status, options) {
|
|
25
|
+
super(message, options);
|
|
21
26
|
this.code = code;
|
|
22
27
|
this.status = status;
|
|
23
28
|
}
|
|
@@ -28,80 +33,144 @@ export function assertAndCoExternalId(value) {
|
|
|
28
33
|
throw new AndCoAuthorizationRequestError("invalid_authorization_request", "externalId must be a non-blank UTF-8 string no longer than 256 bytes");
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Validates a resource indicator (RFC 8707): an absolute HTTPS URL -- or plaintext HTTP on a loopback
|
|
38
|
+
* development host -- carrying no credentials and no fragment.
|
|
39
|
+
*
|
|
40
|
+
* The parsed URL is discarded on purpose, and this is an assertion rather than a parse for that
|
|
41
|
+
* reason. An Authorization Server compares a resource as an exact string, so adopting whatever
|
|
42
|
+
* `URL` normalization produces -- a dropped default port, an added trailing slash -- would turn an
|
|
43
|
+
* audience that matches into one that does not.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* assertAndCoResource("https://api.andco.com"); // returns
|
|
47
|
+
* assertAndCoResource("https://api.andco.com/#section"); // throws: a fragment is not an audience
|
|
48
|
+
*/
|
|
49
|
+
export function assertAndCoResource(resource) {
|
|
50
|
+
try {
|
|
51
|
+
new SafeURL(resource);
|
|
37
52
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export function applyAndCoOrganizationContext(search, context) {
|
|
41
|
-
assertAndCoOrganizationContext(context);
|
|
42
|
-
const next = new URLSearchParams(search);
|
|
43
|
-
if (context.orgId !== undefined) {
|
|
44
|
-
if (next.has("org_id") && next.get("org_id") !== context.orgId) {
|
|
45
|
-
throw new AndCoAuthorizationRequestError("invalid_authorization_request", "Conflicting Company contexts");
|
|
46
|
-
}
|
|
47
|
-
next.set("org_id", context.orgId);
|
|
53
|
+
catch (error) {
|
|
54
|
+
throw new AndCoAuthorizationRequestError("invalid_authorization_request", `resource must be an absolute HTTPS URL without credentials or a fragment: ${resource}`, undefined, { cause: error });
|
|
48
55
|
}
|
|
49
|
-
return next;
|
|
50
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Ceiling of a PostgreSQL `serial` (`int4`), which is the type `organizations.organization_id`
|
|
59
|
+
* uses. An Organization identifier above this can never exist, and a validator that admits more
|
|
60
|
+
* digits than this passes a value straight through to a column that rejects it.
|
|
61
|
+
*/
|
|
62
|
+
export const ANDCO_MAX_ORGANIZATION_ID = 2147483647;
|
|
51
63
|
const PushedAuthorizationResponseSchema = /* @__PURE__ */ v.object({
|
|
52
64
|
expires_in: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
53
65
|
request_uri: v.pipe(v.string(), v.regex(/^urn:ietf:params:oauth:request_uri:[A-Za-z0-9._~:+/-]{1,1900}$/)),
|
|
54
66
|
});
|
|
55
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Composes Resource Server contributions without losing their audience association.
|
|
69
|
+
*
|
|
70
|
+
* Every detail, Andco's or a third party's, names whose resources it asks for in its own `subject`
|
|
71
|
+
* (`{ type: "profile" }`, `{ type: "organization", identifier? }`, or absent for the signed-in
|
|
72
|
+
* Profile). The plan binds each detail to its Resource Server through `locations` and refuses, with
|
|
73
|
+
* `not_implemented`, details that name different subjects: the Authorization Server answers the
|
|
74
|
+
* same, and failing here saves the round trip. A detail without a subject is left to the server,
|
|
75
|
+
* which applies the type's default.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const plan = createAndCoAuthorizationPlan([
|
|
80
|
+
* {
|
|
81
|
+
* resourceServerId: "00000000-0000-0000-0000-00000000f301",
|
|
82
|
+
* resource: "https://openfactura.localhost/api",
|
|
83
|
+
* scopes: [],
|
|
84
|
+
* authorizationDetails: [
|
|
85
|
+
* { type: "documents", actions: ["read"], subject: { type: "organization", identifier: "2" } },
|
|
86
|
+
* ],
|
|
87
|
+
* },
|
|
88
|
+
* ]);
|
|
89
|
+
* plan.authorizationDetails[0].locations; // ["https://openfactura.localhost/api"]
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
56
92
|
export function createAndCoAuthorizationPlan(authorizations = []) {
|
|
57
|
-
let
|
|
93
|
+
let subject;
|
|
58
94
|
const resources = new Set();
|
|
59
95
|
const scopes = new Set();
|
|
60
96
|
const authorizationDetails = [];
|
|
61
97
|
for (const authorization of authorizations) {
|
|
62
|
-
assertAndCoOrganizationContext(authorization);
|
|
63
|
-
if (authorization.orgId !== undefined) {
|
|
64
|
-
if (orgId !== undefined && orgId !== authorization.orgId)
|
|
65
|
-
throw new AndCoAuthorizationRequestError("invalid_authorization_request", "Conflicting Company contexts");
|
|
66
|
-
orgId = authorization.orgId;
|
|
67
|
-
}
|
|
68
|
-
new SafeURL(authorization.resource);
|
|
69
|
-
// A resource is an exact audience identifier, not a navigation URL to normalize.
|
|
70
98
|
const resource = authorization.resource;
|
|
71
|
-
if (
|
|
72
|
-
|
|
99
|
+
if (resource !== undefined) {
|
|
100
|
+
assertAndCoResource(resource);
|
|
101
|
+
// Several contributions may target one Resource Server (each `bank.*.authorization()` builder
|
|
102
|
+
// returns its own): they share the resource and add their details to one request.
|
|
103
|
+
resources.add(resource);
|
|
73
104
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
105
|
+
if (authorization.scopes) {
|
|
106
|
+
for (const scope of authorization.scopes) {
|
|
107
|
+
// TODO: overkill. remove.
|
|
108
|
+
if (!/^[\x21\x23-\x5b\x5d-\x7e]{1,128}$/.test(scope)) {
|
|
109
|
+
throw new AndCoAuthorizationRequestError("invalid_authorization_request", "Invalid OAuth scope");
|
|
110
|
+
}
|
|
111
|
+
scopes.add(scope);
|
|
78
112
|
}
|
|
79
|
-
scopes.add(scope);
|
|
80
113
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
114
|
+
if (authorization.authorizationDetails) {
|
|
115
|
+
for (const detail of authorization.authorizationDetails) {
|
|
116
|
+
// TODO: use valibot?
|
|
117
|
+
if (!detail || typeof detail !== "object" || Array.isArray(detail)) {
|
|
118
|
+
throw new AndCoAuthorizationRequestError("invalid_authorization_request", "Invalid authorization detail");
|
|
119
|
+
}
|
|
120
|
+
// TODO: use valibot? overkill again?
|
|
121
|
+
const locations = detail["locations"];
|
|
122
|
+
if (locations !== undefined &&
|
|
123
|
+
(!Array.isArray(locations) || (resource !== undefined && locations.some((location) => location !== resource)))) {
|
|
124
|
+
throw new AndCoAuthorizationRequestError("invalid_authorization_request", "Authorization detail locations must match its Resource Server");
|
|
125
|
+
}
|
|
126
|
+
const key = SUBJECT_KEY(detail["subject"]);
|
|
127
|
+
if (key !== null) {
|
|
128
|
+
if (subject !== undefined && subject.key !== key) {
|
|
129
|
+
console.debug("[createAndCoAuthorizationPlan] refused different subjects %o and %o", subject.value, detail["subject"]);
|
|
130
|
+
throw new AndCoAuthorizationRequestError("not_implemented", "multiple_subjects: every authorization detail of one request must name the same subject");
|
|
131
|
+
}
|
|
132
|
+
subject = { key, value: detail["subject"] };
|
|
133
|
+
}
|
|
134
|
+
authorizationDetails.push({ ...detail, locations: resource === undefined ? locations : [resource] });
|
|
89
135
|
}
|
|
90
|
-
authorizationDetails.push({ ...detail, locations: [resource] });
|
|
91
136
|
}
|
|
92
137
|
}
|
|
93
|
-
return {
|
|
138
|
+
return { resources: [...resources], scopes: [...scopes], authorizationDetails };
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Identity of a detail's subject for comparison, or `null` when the detail leaves it to the
|
|
142
|
+
* signed-in Profile. `editable` is a consent control, not part of whose resources are asked for.
|
|
143
|
+
*/
|
|
144
|
+
function SUBJECT_KEY(input) {
|
|
145
|
+
if (input === undefined || input === null)
|
|
146
|
+
return null;
|
|
147
|
+
const parsed = v.safeParse(SubjectPickerSchema, input);
|
|
148
|
+
if (!parsed.success || !parsed.output) {
|
|
149
|
+
throw new AndCoAuthorizationRequestError("invalid_authorization_request", 'An authorization detail subject is { type: "profile" | "organization", identifier? }');
|
|
150
|
+
}
|
|
151
|
+
return `${parsed.output.type}:${parsed.output.identifier ?? ""}`;
|
|
94
152
|
}
|
|
95
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Returns a copy of OAuth authorization parameters with one normalized Resource Server plan applied.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* const parameters = applyAndCoAuthorizationPlan(new URLSearchParams({ scope: "openid" }), plan);
|
|
159
|
+
* parameters.getAll("resource"); // plan.resources
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
96
162
|
export function applyAndCoAuthorizationPlan(parameters, plan) {
|
|
97
|
-
const next =
|
|
98
|
-
for (const resource of plan.resources)
|
|
163
|
+
const next = new URLSearchParams(parameters);
|
|
164
|
+
for (const resource of plan.resources) {
|
|
99
165
|
next.append("resource", resource);
|
|
166
|
+
}
|
|
100
167
|
const scopes = new Set((next.get("scope") ?? "").split(/\s+/).filter(Boolean));
|
|
101
|
-
for (const scope of plan.scopes)
|
|
168
|
+
for (const scope of plan.scopes) {
|
|
102
169
|
scopes.add(scope);
|
|
103
|
-
|
|
170
|
+
}
|
|
171
|
+
if (scopes.size > 0) {
|
|
104
172
|
next.set("scope", [...scopes].join(" "));
|
|
173
|
+
}
|
|
105
174
|
if (plan.authorizationDetails.length > 0) {
|
|
106
175
|
next.set("authorization_details", JSON.stringify(plan.authorizationDetails));
|
|
107
176
|
}
|
|
@@ -166,11 +235,13 @@ function ANDCO_AUTHORIZATION_TRANSPORT_FROM(authorizationUrl, options = {}) {
|
|
|
166
235
|
}
|
|
167
236
|
const sensitive = new Set(ANDCO_SENSITIVE_AUTHORIZATION_PARAMETERS);
|
|
168
237
|
for (const parameter of options.sensitiveParameters ?? []) {
|
|
238
|
+
// TODO: overkill. remove it.
|
|
169
239
|
if (!/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(parameter)) {
|
|
170
240
|
throw new TypeError("Invalid sensitive OAuth parameter name");
|
|
171
241
|
}
|
|
172
242
|
sensitive.add(parameter);
|
|
173
243
|
}
|
|
244
|
+
// TODO: why not sensitive.has(parameter) instead of creating a new array?
|
|
174
245
|
const hasSensitiveParameter = [...sensitive].some((parameter) => authorizationUrl.searchParams.has(parameter));
|
|
175
246
|
if (mode === "get") {
|
|
176
247
|
if (hasSensitiveParameter) {
|
|
@@ -178,9 +249,16 @@ function ANDCO_AUTHORIZATION_TRANSPORT_FROM(authorizationUrl, options = {}) {
|
|
|
178
249
|
}
|
|
179
250
|
return "get";
|
|
180
251
|
}
|
|
181
|
-
if (mode === "par")
|
|
252
|
+
else if (mode === "par") {
|
|
253
|
+
return "par";
|
|
254
|
+
}
|
|
255
|
+
else if (hasSensitiveParameter) {
|
|
256
|
+
return "par";
|
|
257
|
+
}
|
|
258
|
+
else if (authorizationUrl.href.length > maxGetUrlLength) {
|
|
182
259
|
return "par";
|
|
183
|
-
|
|
260
|
+
}
|
|
261
|
+
return "get";
|
|
184
262
|
}
|
|
185
263
|
async function PUSHED_AUTHORIZATION_URL_FROM(options, authorizationUrl) {
|
|
186
264
|
const parEndpoint = new SafeURL(options.pushedAuthorizationRequestEndpoint);
|
|
@@ -206,6 +284,7 @@ async function PUSHED_AUTHORIZATION_URL_FROM(options, authorizationUrl) {
|
|
|
206
284
|
if (!parsed.success) {
|
|
207
285
|
throw new AndCoAuthorizationRequestError("invalid_pushed_authorization_response", "PAR returned an invalid response", response.status);
|
|
208
286
|
}
|
|
287
|
+
// TODO: use SafeURL constructor instead of using URLSearchParams
|
|
209
288
|
const browserUrl = new SafeURL(options.authorizationEndpoint);
|
|
210
289
|
browserUrl.search = new URLSearchParams({
|
|
211
290
|
client_id: authorizationUrl.searchParams.get("client_id"),
|
|
@@ -218,7 +297,9 @@ function PAR_FAILURE_ALLOWS_GET(error) {
|
|
|
218
297
|
return false;
|
|
219
298
|
if (error.code === "invalid_pushed_authorization_response")
|
|
220
299
|
return true;
|
|
221
|
-
return (
|
|
300
|
+
return (
|
|
301
|
+
// TODO: refactor.
|
|
302
|
+
error.code === "pushed_authorization_failed" &&
|
|
222
303
|
(error.status === undefined ||
|
|
223
304
|
error.status === 404 ||
|
|
224
305
|
error.status === 405 ||
|
package/dist/consent.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ export declare function ANDCO_CONSENT_SCOPES(consent: Extract<AndCoAuthorization
|
|
|
21
21
|
locked: boolean;
|
|
22
22
|
resourceServerId?: string | undefined;
|
|
23
23
|
resourceServerName?: string | undefined;
|
|
24
|
+
resourceProjectId?: string | undefined;
|
|
25
|
+
resourceProjectName?: string | undefined;
|
|
26
|
+
resourceProjectHomeUri?: string | null | undefined;
|
|
27
|
+
resourcePublisherName?: string | undefined;
|
|
24
28
|
scopeDescription?: string | undefined;
|
|
25
29
|
grantedAt: string | null;
|
|
26
30
|
connectionHasPriorGrant: boolean;
|
|
@@ -36,13 +40,6 @@ export declare function ANDCO_CONSENT_INITIAL_SCOPES(consent: Extract<AndCoAutho
|
|
|
36
40
|
/** Whether the in-progress selection is complete enough to submit; the server still authorizes on submit. */
|
|
37
41
|
export declare function ANDCO_CONSENT_CAN_SUBMIT(consent: Extract<AndCoAuthorizationPreparation, {
|
|
38
42
|
status: "consent_required";
|
|
39
|
-
}>, scopes: ReadonlySet<string
|
|
40
|
-
/** Presents the same charge restrictions in both native renderers. */
|
|
41
|
-
export declare function ANDCO_CHARGE_SUMMARY(charge: NonNullable<Extract<AndCoAuthorizationPreparation, {
|
|
42
|
-
status: "consent_required";
|
|
43
|
-
}>["chargeAuthorization"]>, locale?: "es" | "en" | "pt"): {
|
|
44
|
-
label: string;
|
|
45
|
-
value: string;
|
|
46
|
-
}[];
|
|
43
|
+
}>, scopes: ReadonlySet<string>): boolean;
|
|
47
44
|
export {};
|
|
48
45
|
//# sourceMappingURL=consent.d.ts.map
|
package/dist/consent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent.d.ts","sourceRoot":"","sources":["../src/consent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"consent.d.ts","sourceRoot":"","sources":["../src/consent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAWpF,KAAK,oBAAoB,GAAG,OAAO,CAAC,6BAA6B,EAAE;IAAE,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAErH;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,WAAW,CAAC,WAEpG;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,CAAC,6BAA6B,EAAE;IAAE,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,EAC/E,MAAM,GAAE,IAAI,GAAG,IAAI,GAAG,IAAW;;;;;;;;;;;;;;;;;;IAsBlC;AAED,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhF,uGAAuG;AACvG,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,OAAO,CAAC,6BAA6B,EAAE;IAAE,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,eAOhF;AAED,6GAA6G;AAC7G,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,CAAC,6BAA6B,EAAE;IAAE,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,EAC/E,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,WAQ5B"}
|