@pegasimed.com/pegasi-sail-connect-shared 0.2.0-dev.1 → 0.2.0-dev.11
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 +355 -30
- package/dist/authorization/index.d.ts +1 -0
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +1 -0
- package/dist/authorization/index.js.map +1 -1
- package/dist/authorization/work-grants.d.ts +151 -0
- package/dist/authorization/work-grants.d.ts.map +1 -0
- package/dist/authorization/work-grants.js +306 -0
- package/dist/authorization/work-grants.js.map +1 -0
- package/dist/authorization-testing.d.ts +229 -0
- package/dist/authorization-testing.d.ts.map +1 -0
- package/dist/authorization-testing.js +744 -0
- package/dist/authorization-testing.js.map +1 -0
- package/dist/capabilities/canonical-json.d.ts +3 -0
- package/dist/capabilities/canonical-json.d.ts.map +1 -0
- package/dist/capabilities/canonical-json.js +83 -0
- package/dist/capabilities/canonical-json.js.map +1 -0
- package/dist/capabilities/catalog-data.d.ts +559 -281
- package/dist/capabilities/catalog-data.d.ts.map +1 -1
- package/dist/capabilities/catalog-data.js +582 -287
- package/dist/capabilities/catalog-data.js.map +1 -1
- package/dist/capabilities/catalog.d.ts.map +1 -1
- package/dist/capabilities/catalog.js +4 -4
- package/dist/capabilities/catalog.js.map +1 -1
- package/dist/capabilities/index.d.ts +4 -0
- package/dist/capabilities/index.d.ts.map +1 -1
- package/dist/capabilities/index.js +7 -0
- package/dist/capabilities/index.js.map +1 -1
- package/dist/capabilities/migration-data.d.ts +105 -190
- package/dist/capabilities/migration-data.d.ts.map +1 -1
- package/dist/capabilities/migration-data.js +83 -144
- package/dist/capabilities/migration-data.js.map +1 -1
- package/dist/capabilities/migration.d.ts +20 -20
- package/dist/capabilities/migration.d.ts.map +1 -1
- package/dist/capabilities/migration.js +25 -40
- package/dist/capabilities/migration.js.map +1 -1
- package/dist/capabilities/sha256.d.ts +18 -0
- package/dist/capabilities/sha256.d.ts.map +1 -0
- package/dist/capabilities/sha256.js +180 -0
- package/dist/capabilities/sha256.js.map +1 -0
- package/dist/capabilities/types.d.ts +3 -2
- package/dist/capabilities/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/organization/index.d.ts +135 -0
- package/dist/organization/index.d.ts.map +1 -0
- package/dist/organization/index.js +92 -0
- package/dist/organization/index.js.map +1 -0
- package/dist/worker-logger.d.ts +46 -4
- package/dist/worker-logger.d.ts.map +1 -1
- package/dist/worker-logger.js +33 -11
- package/dist/worker-logger.js.map +1 -1
- package/package.json +11 -3
- package/scripts/check-service-keys.mjs +30 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/** Resource domains of a work grant (access-domain.ts:41). */
|
|
2
|
+
export declare const WORK_GRANT_DOMAINS: readonly ["clinical-organization", "agenda", "warehouse"];
|
|
3
|
+
/** Relations of a work grant (access-domain.ts:42). */
|
|
4
|
+
export declare const WORK_GRANT_RELATIONS: readonly ["owner", "administrator", "assigned"];
|
|
5
|
+
/** Longest workGrants list Access signs (access-domain.ts:261). */
|
|
6
|
+
export declare const MAX_WORK_GRANTS = 256;
|
|
7
|
+
/** Longest resourceId (and parent resourceId) Access accepts (access-domain.ts:294, 306). */
|
|
8
|
+
export declare const MAX_WORK_GRANT_RESOURCE_ID_LENGTH = 256;
|
|
9
|
+
/** Prefix of every work grant id (access-domain.ts:140). */
|
|
10
|
+
export declare const WORK_GRANT_ID_PREFIX: "sha256:v1:";
|
|
11
|
+
export type WorkGrantDomain = (typeof WORK_GRANT_DOMAINS)[number];
|
|
12
|
+
export type WorkGrantRelation = (typeof WORK_GRANT_RELATIONS)[number];
|
|
13
|
+
/** The only parent a work grant can have: a clinical organization (access-domain.ts:56-59). */
|
|
14
|
+
export interface WorkGrantParentResource {
|
|
15
|
+
readonly domain: "clinical-organization";
|
|
16
|
+
readonly resourceId: string;
|
|
17
|
+
}
|
|
18
|
+
/** What the id of a work grant depends on (besides the tenant and the user). */
|
|
19
|
+
export interface WorkGrantIdentity {
|
|
20
|
+
readonly domain: WorkGrantDomain;
|
|
21
|
+
readonly resourceId: string;
|
|
22
|
+
readonly relation: WorkGrantRelation;
|
|
23
|
+
readonly parentResource?: WorkGrantParentResource | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface OrganizationWorkGrant {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly domain: "clinical-organization";
|
|
28
|
+
readonly resourceId: string;
|
|
29
|
+
readonly relation: "owner" | "administrator";
|
|
30
|
+
}
|
|
31
|
+
export interface AgendaWorkGrant {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly domain: "agenda";
|
|
34
|
+
readonly resourceId: string;
|
|
35
|
+
readonly relation: "assigned";
|
|
36
|
+
readonly parentResource?: WorkGrantParentResource;
|
|
37
|
+
}
|
|
38
|
+
export interface WarehouseWorkGrant {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly domain: "warehouse";
|
|
41
|
+
readonly resourceId: string;
|
|
42
|
+
readonly relation: "assigned";
|
|
43
|
+
readonly parentResource?: WorkGrantParentResource;
|
|
44
|
+
/** Required in the token (access-domain.ts:250-253): a safe integer >= 1. */
|
|
45
|
+
readonly grantVersion: number;
|
|
46
|
+
readonly notBefore?: number;
|
|
47
|
+
readonly expiresAt?: number;
|
|
48
|
+
}
|
|
49
|
+
/** A work grant of the v2 token, validated (Access's WorkGrant, access-domain.ts:91-92). */
|
|
50
|
+
export type WorkGrantV2 = OrganizationWorkGrant | AgendaWorkGrant | WarehouseWorkGrant;
|
|
51
|
+
/**
|
|
52
|
+
* Whether a domain admits a relation (access-domain.ts:220-224): a clinical
|
|
53
|
+
* organization is owned or administered; an agenda or a warehouse is assigned.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isValidWorkGrantRelation(domain: WorkGrantDomain, relation: WorkGrantRelation): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The deterministic id Access gives a work grant (access-domain.ts:139-141,
|
|
58
|
+
* 155-176): `sha256:v1:` followed by the base64url (no padding) SHA-256 of the
|
|
59
|
+
* UTF-8 JSON of `[tenantId, userId, domain, resourceId, relation, parent]`,
|
|
60
|
+
* where parent is `[parentResource.domain, parentResource.resourceId]` or
|
|
61
|
+
* null. In the token, tenantId is the `tenantId` claim and userId the `sub`
|
|
62
|
+
* claim. It validates nothing else (use validateWorkGrantsV2 for token data)
|
|
63
|
+
* and runs anywhere: the SHA-256 is plain TypeScript, without node:crypto.
|
|
64
|
+
* Every identity field (tenantId, userId, domain, resourceId, relation and,
|
|
65
|
+
* when there is a parent, its domain and resourceId) must be a string, read
|
|
66
|
+
* from own data properties; otherwise it throws a TypeError. The tuple is
|
|
67
|
+
* serialized without ever calling a (possibly polluted) toJSON.
|
|
68
|
+
*/
|
|
69
|
+
export declare function workGrantId(tenantId: string, userId: string, grant: WorkGrantIdentity): string;
|
|
70
|
+
/** Why validateWorkGrantsV2 rejected the list. Stable values; the message never carries token data. */
|
|
71
|
+
export type WorkGrantsInvalidReason =
|
|
72
|
+
/** tenantId or sub of the caller is not a non-empty string. */
|
|
73
|
+
"context-invalid"
|
|
74
|
+
/** workGrants is not an array, or its length or an element is an accessor. */
|
|
75
|
+
| "not-array"
|
|
76
|
+
/** Reading the input threw (for example a revoked proxy or a throwing trap). */
|
|
77
|
+
| "unreadable"
|
|
78
|
+
/** More than MAX_WORK_GRANTS entries. */
|
|
79
|
+
| "too-many"
|
|
80
|
+
/** An entry is not a plain record, or has an accessor or non-string key. */
|
|
81
|
+
| "entry-invalid"
|
|
82
|
+
/** domain is not one of WORK_GRANT_DOMAINS. */
|
|
83
|
+
| "domain-invalid"
|
|
84
|
+
/** relation is not one of WORK_GRANT_RELATIONS, or the domain does not admit it. */
|
|
85
|
+
| "relation-invalid"
|
|
86
|
+
/** A field the domain does not allow (grantVersion, notBefore and expiresAt only for warehouse). */
|
|
87
|
+
| "field-not-allowed"
|
|
88
|
+
/** grantVersion is not a safe integer >= 1, or notBefore/expiresAt not a safe integer >= 0. */
|
|
89
|
+
| "validity-invalid"
|
|
90
|
+
/** notBefore is not before expiresAt. */
|
|
91
|
+
| "window-invalid"
|
|
92
|
+
/** A warehouse grant without grantVersion. */
|
|
93
|
+
| "grant-version-required"
|
|
94
|
+
/** resourceId is not a non-empty string without surrounding spaces of at most 256 characters. */
|
|
95
|
+
| "resource-id-invalid"
|
|
96
|
+
/** parentResource is not a clinical organization of the same shape, or the grant is itself an organization. */
|
|
97
|
+
| "parent-invalid"
|
|
98
|
+
/** id is not the one workGrantId gives for the tenantId and sub of the caller. */
|
|
99
|
+
| "id-invalid"
|
|
100
|
+
/** Two entries with the same identity. */
|
|
101
|
+
| "duplicate";
|
|
102
|
+
/** Stable code of WorkGrantsInvalidError. */
|
|
103
|
+
export declare const WORK_GRANTS_INVALID: "WORK_GRANTS_INVALID";
|
|
104
|
+
/**
|
|
105
|
+
* Thrown by validateWorkGrantsV2. Carries the stable `code`, the rule
|
|
106
|
+
* (`reason`) and the index of the entry at fault when there is one, never a
|
|
107
|
+
* value of the token. The service maps it to a 401, like a rejection of
|
|
108
|
+
* readInternalAuthorization.
|
|
109
|
+
*/
|
|
110
|
+
export declare class WorkGrantsInvalidError extends Error {
|
|
111
|
+
readonly code: "WORK_GRANTS_INVALID";
|
|
112
|
+
readonly reason: WorkGrantsInvalidReason;
|
|
113
|
+
readonly index: number | undefined;
|
|
114
|
+
constructor(reason: WorkGrantsInvalidReason, index?: number);
|
|
115
|
+
}
|
|
116
|
+
/** Who the token is for: its `tenantId` and `sub` claims (already verified by the caller). */
|
|
117
|
+
export interface WorkGrantsContext {
|
|
118
|
+
readonly tenantId: string;
|
|
119
|
+
readonly sub: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Validates the `workGrants` claim of a v2 token the way Access builds it
|
|
123
|
+
* (access-domain.ts:240-342 in snapshot mode, plus requireWarehouseVersions)
|
|
124
|
+
* and returns it typed. readInternalAuthorization does NOT validate
|
|
125
|
+
* workGrants: it passes the list through, so every service that scopes by work
|
|
126
|
+
* grant (or wants to refuse a token Access would not have signed) calls this
|
|
127
|
+
* with the token's verified `tenantId` and `sub`:
|
|
128
|
+
*
|
|
129
|
+
* - an array of at most MAX_WORK_GRANTS plain records;
|
|
130
|
+
* - each with only id, domain, resourceId, relation and parentResource, plus
|
|
131
|
+
* grantVersion, notBefore and expiresAt for domain warehouse;
|
|
132
|
+
* - domain in WORK_GRANT_DOMAINS and a relation the domain admits
|
|
133
|
+
* (organization owner/administrator, agenda and warehouse assigned);
|
|
134
|
+
* - resourceId a non-empty string without surrounding spaces of at most 256
|
|
135
|
+
* characters; parentResource only `{ domain: "clinical-organization",
|
|
136
|
+
* resourceId }` with the same resourceId rule, and never on an organization;
|
|
137
|
+
* - grantVersion a safe integer >= 1, required on warehouse; notBefore and
|
|
138
|
+
* expiresAt safe integers >= 0 with notBefore < expiresAt;
|
|
139
|
+
* - id equal to workGrantId(tenantId, sub, grant) (the legacy `|`-joined id
|
|
140
|
+
* that Access still reads from storage is never signed, so it is refused);
|
|
141
|
+
* - no two entries with the same identity.
|
|
142
|
+
*
|
|
143
|
+
* Returns a frozen copy in the token's order: frozen null-prototype records
|
|
144
|
+
* with only the fields present. Throws WorkGrantsInvalidError (code
|
|
145
|
+
* WORK_GRANTS_INVALID, a stable `reason` and the entry index) on the first
|
|
146
|
+
* violation, also for a hostile input (proxies, accessors, throwing traps):
|
|
147
|
+
* only own data properties are read, no getter runs and nothing of the input
|
|
148
|
+
* is modified. Pure and without node:crypto: it also runs in a browser.
|
|
149
|
+
*/
|
|
150
|
+
export declare function validateWorkGrantsV2(grants: unknown, context: WorkGrantsContext): readonly WorkGrantV2[];
|
|
151
|
+
//# sourceMappingURL=work-grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work-grants.d.ts","sourceRoot":"","sources":["../../src/authorization/work-grants.ts"],"names":[],"mappings":"AAUA,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB,2DAA4D,CAAC;AAC5F,uDAAuD;AACvD,eAAO,MAAM,oBAAoB,iDAAkD,CAAC;AACpF,mEAAmE;AACnE,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,6FAA6F;AAC7F,eAAO,MAAM,iCAAiC,MAAM,CAAC;AACrD,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,EAAG,YAAqB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAClE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,+FAA+F;AAC/F,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM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,MAAM,CAAC;CACtB;AAyLD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,GAAG,SAAS,WAAW,EAAE,CASxG"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { OWN_ACCESSOR, appendOwn, ownDataValue, readList } from "../capabilities/list.js";
|
|
2
|
+
import { sha256Base64Url } from "../capabilities/sha256.js";
|
|
3
|
+
// Work grants of the v2 envelope, as Access signs them. Source of truth:
|
|
4
|
+
// pegasi-sail-connect-access-api origin/dev aee642b, src/access-domain.ts:
|
|
5
|
+
// WORK_GRANT_DOMAINS and WORK_GRANT_RELATIONS (41-42), sha256Identity (139-141),
|
|
6
|
+
// workGrantIdentityValue and workGrantId (155-176), validRelation (220-224) and
|
|
7
|
+
// validateGrants in "snapshot" mode plus requireWarehouseVersions (240-342),
|
|
8
|
+
// which is what the signer emits (validateAccessWorkGrants, seed-auth.ts:611-630).
|
|
9
|
+
/** Resource domains of a work grant (access-domain.ts:41). */
|
|
10
|
+
export const WORK_GRANT_DOMAINS = ["clinical-organization", "agenda", "warehouse"];
|
|
11
|
+
/** Relations of a work grant (access-domain.ts:42). */
|
|
12
|
+
export const WORK_GRANT_RELATIONS = ["owner", "administrator", "assigned"];
|
|
13
|
+
/** Longest workGrants list Access signs (access-domain.ts:261). */
|
|
14
|
+
export const MAX_WORK_GRANTS = 256;
|
|
15
|
+
/** Longest resourceId (and parent resourceId) Access accepts (access-domain.ts:294, 306). */
|
|
16
|
+
export const MAX_WORK_GRANT_RESOURCE_ID_LENGTH = 256;
|
|
17
|
+
/** Prefix of every work grant id (access-domain.ts:140). */
|
|
18
|
+
export const WORK_GRANT_ID_PREFIX = "sha256:v1:";
|
|
19
|
+
/**
|
|
20
|
+
* Whether a domain admits a relation (access-domain.ts:220-224): a clinical
|
|
21
|
+
* organization is owned or administered; an agenda or a warehouse is assigned.
|
|
22
|
+
*/
|
|
23
|
+
export function isValidWorkGrantRelation(domain, relation) {
|
|
24
|
+
return domain === "clinical-organization" ? relation === "owner" || relation === "administrator" : relation === "assigned";
|
|
25
|
+
}
|
|
26
|
+
// JSON text of one string. JSON.stringify of a primitive string never looks up
|
|
27
|
+
// toJSON (ECMA-262 SerializeJSONProperty: only an Object or a BigInt is asked
|
|
28
|
+
// for toJSON, and the wrapper holder's "" property is its own data property),
|
|
29
|
+
// so a polluted String.prototype.toJSON is never called.
|
|
30
|
+
function jsonString(value) {
|
|
31
|
+
if (typeof value !== "string") {
|
|
32
|
+
throw new TypeError("Work grant identity fields must be strings.");
|
|
33
|
+
}
|
|
34
|
+
return JSON.stringify(value);
|
|
35
|
+
}
|
|
36
|
+
// access-domain.ts:155-168: `JSON.stringify([tenantId, userId, domain,
|
|
37
|
+
// resourceId, relation, parent ? [parent.domain, parent.resourceId] : null])`,
|
|
38
|
+
// built here as text from the JSON of each string. The result is byte-identical
|
|
39
|
+
// for strings, but no array is serialized, so a polluted Array.prototype.toJSON
|
|
40
|
+
// or Object.prototype.toJSON can never run or change the tuple.
|
|
41
|
+
function identityValue(tenantId, userId, domain, resourceId, relation, parentResource) {
|
|
42
|
+
const parent = parentResource ? `[${jsonString(parentResource.domain)},${jsonString(parentResource.resourceId)}]` : "null";
|
|
43
|
+
return `[${jsonString(tenantId)},${jsonString(userId)},${jsonString(domain)},${jsonString(resourceId)},${jsonString(relation)},${parent}]`;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The deterministic id Access gives a work grant (access-domain.ts:139-141,
|
|
47
|
+
* 155-176): `sha256:v1:` followed by the base64url (no padding) SHA-256 of the
|
|
48
|
+
* UTF-8 JSON of `[tenantId, userId, domain, resourceId, relation, parent]`,
|
|
49
|
+
* where parent is `[parentResource.domain, parentResource.resourceId]` or
|
|
50
|
+
* null. In the token, tenantId is the `tenantId` claim and userId the `sub`
|
|
51
|
+
* claim. It validates nothing else (use validateWorkGrantsV2 for token data)
|
|
52
|
+
* and runs anywhere: the SHA-256 is plain TypeScript, without node:crypto.
|
|
53
|
+
* Every identity field (tenantId, userId, domain, resourceId, relation and,
|
|
54
|
+
* when there is a parent, its domain and resourceId) must be a string, read
|
|
55
|
+
* from own data properties; otherwise it throws a TypeError. The tuple is
|
|
56
|
+
* serialized without ever calling a (possibly polluted) toJSON.
|
|
57
|
+
*/
|
|
58
|
+
export function workGrantId(tenantId, userId, grant) {
|
|
59
|
+
// Only own data properties count (an inherited or accessor field reads as
|
|
60
|
+
// absent), so a polluted Object.prototype.parentResource never changes the id.
|
|
61
|
+
const own = (record, field) => {
|
|
62
|
+
if (typeof record !== "object" || record === null) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const value = ownDataValue(record, field);
|
|
66
|
+
return value === OWN_ACCESSOR ? undefined : value;
|
|
67
|
+
};
|
|
68
|
+
const parent = own(grant, "parentResource");
|
|
69
|
+
const parentResource = parent ? { domain: own(parent, "domain"), resourceId: own(parent, "resourceId") } : undefined;
|
|
70
|
+
const identity = identityValue(tenantId, userId, own(grant, "domain"), own(grant, "resourceId"), own(grant, "relation"), parentResource);
|
|
71
|
+
return `${WORK_GRANT_ID_PREFIX}${sha256Base64Url(identity)}`;
|
|
72
|
+
}
|
|
73
|
+
/** Stable code of WorkGrantsInvalidError. */
|
|
74
|
+
export const WORK_GRANTS_INVALID = "WORK_GRANTS_INVALID";
|
|
75
|
+
/**
|
|
76
|
+
* Thrown by validateWorkGrantsV2. Carries the stable `code`, the rule
|
|
77
|
+
* (`reason`) and the index of the entry at fault when there is one, never a
|
|
78
|
+
* value of the token. The service maps it to a 401, like a rejection of
|
|
79
|
+
* readInternalAuthorization.
|
|
80
|
+
*/
|
|
81
|
+
export class WorkGrantsInvalidError extends Error {
|
|
82
|
+
code = WORK_GRANTS_INVALID;
|
|
83
|
+
reason;
|
|
84
|
+
index;
|
|
85
|
+
constructor(reason, index) {
|
|
86
|
+
super(`Work grants are invalid: ${reason}${index === undefined ? "" : ` at index ${index}`}.`);
|
|
87
|
+
this.name = "WorkGrantsInvalidError";
|
|
88
|
+
this.reason = reason;
|
|
89
|
+
this.index = index;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const DOMAINS = new Set(WORK_GRANT_DOMAINS);
|
|
93
|
+
const RELATIONS = new Set(WORK_GRANT_RELATIONS);
|
|
94
|
+
// access-domain.ts:276-280 (snapshot mode: warehouse also carries grantVersion).
|
|
95
|
+
const GRANT_FIELDS = new Set(["id", "domain", "resourceId", "relation", "parentResource"]);
|
|
96
|
+
const WAREHOUSE_FIELDS = new Set([...GRANT_FIELDS, "notBefore", "expiresAt", "grantVersion"]);
|
|
97
|
+
const PARENT_FIELDS = new Set(["domain", "resourceId"]);
|
|
98
|
+
// access-domain.ts:284-289: minimum of each validity field.
|
|
99
|
+
const VALIDITY_MINIMUMS = [
|
|
100
|
+
["grantVersion", 1],
|
|
101
|
+
["notBefore", 0],
|
|
102
|
+
["expiresAt", 0]
|
|
103
|
+
];
|
|
104
|
+
// Thrown inside the validator only and recognised by identity (never with
|
|
105
|
+
// instanceof or a trap of a value the input threw).
|
|
106
|
+
class Invalid extends Error {
|
|
107
|
+
reason;
|
|
108
|
+
index;
|
|
109
|
+
constructor(reason, index) {
|
|
110
|
+
super(reason);
|
|
111
|
+
this.reason = reason;
|
|
112
|
+
this.index = index;
|
|
113
|
+
this.name = "Invalid";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const INVALIDS = new WeakSet();
|
|
117
|
+
function invalid(reason, index) {
|
|
118
|
+
const error = new Invalid(reason, index);
|
|
119
|
+
INVALIDS.add(error);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
function isPlainRecord(value) {
|
|
123
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const prototype = Object.getPrototypeOf(value);
|
|
127
|
+
return prototype === Object.prototype || prototype === null;
|
|
128
|
+
}
|
|
129
|
+
// The own data properties of a plain record, by name; only string keys of
|
|
130
|
+
// `allowed`, never an accessor. Reads descriptors only (no getter, no get trap).
|
|
131
|
+
function ownFields(record, allowed, index, notAllowed) {
|
|
132
|
+
const fields = new Map();
|
|
133
|
+
for (const key of Reflect.ownKeys(record)) {
|
|
134
|
+
if (typeof key !== "string") {
|
|
135
|
+
invalid("entry-invalid", index);
|
|
136
|
+
}
|
|
137
|
+
if (!allowed.has(key)) {
|
|
138
|
+
invalid(notAllowed, index);
|
|
139
|
+
}
|
|
140
|
+
const value = ownDataValue(record, key);
|
|
141
|
+
if (value === OWN_ACCESSOR) {
|
|
142
|
+
invalid("entry-invalid", index);
|
|
143
|
+
}
|
|
144
|
+
fields.set(key, value);
|
|
145
|
+
}
|
|
146
|
+
return fields;
|
|
147
|
+
}
|
|
148
|
+
// access-domain.ts:293-296 and 302-306: a non-empty string equal to its trim, at most 256 characters.
|
|
149
|
+
function isResourceId(value) {
|
|
150
|
+
return typeof value === "string" && value.length > 0 && value === value.trim() && value.length <= MAX_WORK_GRANT_RESOURCE_ID_LENGTH;
|
|
151
|
+
}
|
|
152
|
+
// Null-prototype frozen record: an absent optional field reads as undefined
|
|
153
|
+
// even under a polluted Object.prototype.
|
|
154
|
+
function nullRecord(fields) {
|
|
155
|
+
return Object.freeze(Object.assign(Object.create(null), fields));
|
|
156
|
+
}
|
|
157
|
+
function readParent(value, domain, index) {
|
|
158
|
+
if (value === undefined) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
if (!isPlainRecord(value) || domain === "clinical-organization") {
|
|
162
|
+
return invalid("parent-invalid", index);
|
|
163
|
+
}
|
|
164
|
+
const fields = ownFields(value, PARENT_FIELDS, index, "parent-invalid");
|
|
165
|
+
const resourceId = fields.get("resourceId");
|
|
166
|
+
if (fields.get("domain") !== "clinical-organization" || !isResourceId(resourceId)) {
|
|
167
|
+
return invalid("parent-invalid", index);
|
|
168
|
+
}
|
|
169
|
+
return nullRecord({ domain: "clinical-organization", resourceId });
|
|
170
|
+
}
|
|
171
|
+
function readGrant(item, index, context, identities) {
|
|
172
|
+
if (!isPlainRecord(item)) {
|
|
173
|
+
return invalid("entry-invalid", index);
|
|
174
|
+
}
|
|
175
|
+
// Every own key must be a field the record may have; the domain decides which.
|
|
176
|
+
const all = ownFields(item, WAREHOUSE_FIELDS, index, "field-not-allowed");
|
|
177
|
+
const domain = all.get("domain");
|
|
178
|
+
const relation = all.get("relation");
|
|
179
|
+
if (!DOMAINS.has(domain)) {
|
|
180
|
+
return invalid("domain-invalid", index);
|
|
181
|
+
}
|
|
182
|
+
const grantDomain = domain;
|
|
183
|
+
if (!RELATIONS.has(relation) || !isValidWorkGrantRelation(grantDomain, relation)) {
|
|
184
|
+
return invalid("relation-invalid", index);
|
|
185
|
+
}
|
|
186
|
+
const grantRelation = relation;
|
|
187
|
+
const allowed = grantDomain === "warehouse" ? WAREHOUSE_FIELDS : GRANT_FIELDS;
|
|
188
|
+
for (const key of all.keys()) {
|
|
189
|
+
if (!allowed.has(key)) {
|
|
190
|
+
invalid("field-not-allowed", index);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const validity = new Map();
|
|
194
|
+
for (const [field, minimum] of VALIDITY_MINIMUMS) {
|
|
195
|
+
if (all.has(field)) {
|
|
196
|
+
const value = all.get(field);
|
|
197
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum) {
|
|
198
|
+
invalid("validity-invalid", index);
|
|
199
|
+
}
|
|
200
|
+
validity.set(field, value);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const notBefore = validity.get("notBefore");
|
|
204
|
+
const expiresAt = validity.get("expiresAt");
|
|
205
|
+
if (notBefore !== undefined && expiresAt !== undefined && notBefore >= expiresAt) {
|
|
206
|
+
invalid("window-invalid", index);
|
|
207
|
+
}
|
|
208
|
+
const grantVersion = validity.get("grantVersion");
|
|
209
|
+
if (grantDomain === "warehouse" && grantVersion === undefined) {
|
|
210
|
+
invalid("grant-version-required", index);
|
|
211
|
+
}
|
|
212
|
+
const resourceId = all.get("resourceId");
|
|
213
|
+
if (!isResourceId(resourceId)) {
|
|
214
|
+
return invalid("resource-id-invalid", index);
|
|
215
|
+
}
|
|
216
|
+
const parentResource = readParent(all.get("parentResource"), grantDomain, index);
|
|
217
|
+
const identity = identityValue(context.tenantId, context.sub, grantDomain, resourceId, grantRelation, parentResource);
|
|
218
|
+
const id = all.get("id");
|
|
219
|
+
if (typeof id !== "string" || id !== `${WORK_GRANT_ID_PREFIX}${sha256Base64Url(identity)}`) {
|
|
220
|
+
return invalid("id-invalid", index);
|
|
221
|
+
}
|
|
222
|
+
// Access merges grants by identity before signing (access-domain.ts:332-337): a duplicate is never signed.
|
|
223
|
+
if (identities.has(identity)) {
|
|
224
|
+
return invalid("duplicate", index);
|
|
225
|
+
}
|
|
226
|
+
identities.add(identity);
|
|
227
|
+
return nullRecord({
|
|
228
|
+
id,
|
|
229
|
+
domain: grantDomain,
|
|
230
|
+
resourceId,
|
|
231
|
+
relation: grantRelation,
|
|
232
|
+
...(parentResource !== undefined ? { parentResource } : {}),
|
|
233
|
+
...(grantVersion !== undefined ? { grantVersion } : {}),
|
|
234
|
+
...(notBefore !== undefined ? { notBefore } : {}),
|
|
235
|
+
...(expiresAt !== undefined ? { expiresAt } : {})
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function validate(grants, context) {
|
|
239
|
+
const tenantId = isPlainRecord(context) ? ownDataValue(context, "tenantId") : undefined;
|
|
240
|
+
const sub = isPlainRecord(context) ? ownDataValue(context, "sub") : undefined;
|
|
241
|
+
if (typeof tenantId !== "string" || tenantId.length === 0 || typeof sub !== "string" || sub.length === 0) {
|
|
242
|
+
return invalid("context-invalid");
|
|
243
|
+
}
|
|
244
|
+
if (Array.isArray(grants)) {
|
|
245
|
+
const length = ownDataValue(grants, "length");
|
|
246
|
+
if (typeof length === "number" && length > MAX_WORK_GRANTS) {
|
|
247
|
+
return invalid("too-many");
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const read = readList(grants);
|
|
251
|
+
if (read.status !== "ok") {
|
|
252
|
+
return invalid("not-array");
|
|
253
|
+
}
|
|
254
|
+
// Checked again on the copy: a hostile proxy may report one length to the
|
|
255
|
+
// first read and another to readList's.
|
|
256
|
+
if (read.items.length > MAX_WORK_GRANTS) {
|
|
257
|
+
return invalid("too-many");
|
|
258
|
+
}
|
|
259
|
+
const identities = new Set();
|
|
260
|
+
const result = [];
|
|
261
|
+
for (let index = 0; index < read.items.length; index += 1) {
|
|
262
|
+
appendOwn(result, readGrant(read.items[index], index, { tenantId, sub }, identities));
|
|
263
|
+
}
|
|
264
|
+
return Object.freeze(result);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Validates the `workGrants` claim of a v2 token the way Access builds it
|
|
268
|
+
* (access-domain.ts:240-342 in snapshot mode, plus requireWarehouseVersions)
|
|
269
|
+
* and returns it typed. readInternalAuthorization does NOT validate
|
|
270
|
+
* workGrants: it passes the list through, so every service that scopes by work
|
|
271
|
+
* grant (or wants to refuse a token Access would not have signed) calls this
|
|
272
|
+
* with the token's verified `tenantId` and `sub`:
|
|
273
|
+
*
|
|
274
|
+
* - an array of at most MAX_WORK_GRANTS plain records;
|
|
275
|
+
* - each with only id, domain, resourceId, relation and parentResource, plus
|
|
276
|
+
* grantVersion, notBefore and expiresAt for domain warehouse;
|
|
277
|
+
* - domain in WORK_GRANT_DOMAINS and a relation the domain admits
|
|
278
|
+
* (organization owner/administrator, agenda and warehouse assigned);
|
|
279
|
+
* - resourceId a non-empty string without surrounding spaces of at most 256
|
|
280
|
+
* characters; parentResource only `{ domain: "clinical-organization",
|
|
281
|
+
* resourceId }` with the same resourceId rule, and never on an organization;
|
|
282
|
+
* - grantVersion a safe integer >= 1, required on warehouse; notBefore and
|
|
283
|
+
* expiresAt safe integers >= 0 with notBefore < expiresAt;
|
|
284
|
+
* - id equal to workGrantId(tenantId, sub, grant) (the legacy `|`-joined id
|
|
285
|
+
* that Access still reads from storage is never signed, so it is refused);
|
|
286
|
+
* - no two entries with the same identity.
|
|
287
|
+
*
|
|
288
|
+
* Returns a frozen copy in the token's order: frozen null-prototype records
|
|
289
|
+
* with only the fields present. Throws WorkGrantsInvalidError (code
|
|
290
|
+
* WORK_GRANTS_INVALID, a stable `reason` and the entry index) on the first
|
|
291
|
+
* violation, also for a hostile input (proxies, accessors, throwing traps):
|
|
292
|
+
* only own data properties are read, no getter runs and nothing of the input
|
|
293
|
+
* is modified. Pure and without node:crypto: it also runs in a browser.
|
|
294
|
+
*/
|
|
295
|
+
export function validateWorkGrantsV2(grants, context) {
|
|
296
|
+
let failure;
|
|
297
|
+
try {
|
|
298
|
+
return validate(grants, context);
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
// Identity check only: no trap of a value thrown by the input runs here.
|
|
302
|
+
failure = INVALIDS.has(error) ? error : new Invalid("unreadable", undefined);
|
|
303
|
+
}
|
|
304
|
+
throw new WorkGrantsInvalidError(failure.reason, failure.index);
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=work-grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work-grants.js","sourceRoot":"","sources":["../../src/authorization/work-grants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,yEAAyE;AACzE,2EAA2E;AAC3E,iFAAiF;AACjF,gFAAgF;AAChF,6EAA6E;AAC7E,mFAAmF;AAEnF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,uBAAuB,EAAE,QAAQ,EAAE,WAAW,CAAU,CAAC;AAC5F,uDAAuD;AACvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,eAAe,EAAE,U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