@pegasimed.com/pegasi-sail-connect-shared 0.1.0-dev.0 → 0.2.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +398 -125
- package/dist/authorization/index.d.ts +3 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +3 -0
- package/dist/authorization/index.js.map +1 -0
- package/dist/authorization/internal-authorization.d.ts +105 -0
- package/dist/authorization/internal-authorization.d.ts.map +1 -0
- package/dist/authorization/internal-authorization.js +287 -0
- package/dist/authorization/internal-authorization.js.map +1 -0
- package/dist/capabilities/catalog-data.d.ts +3917 -0
- package/dist/capabilities/catalog-data.d.ts.map +1 -0
- package/dist/capabilities/catalog-data.js +4244 -0
- package/dist/capabilities/catalog-data.js.map +1 -0
- package/dist/capabilities/catalog.d.ts +38 -0
- package/dist/capabilities/catalog.d.ts.map +1 -0
- package/dist/capabilities/catalog.js +91 -0
- package/dist/capabilities/catalog.js.map +1 -0
- package/dist/capabilities/index.d.ts +8 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +8 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/list.d.ts +46 -0
- package/dist/capabilities/list.d.ts.map +1 -0
- package/dist/capabilities/list.js +80 -0
- package/dist/capabilities/list.js.map +1 -0
- package/dist/capabilities/match.d.ts +42 -0
- package/dist/capabilities/match.d.ts.map +1 -0
- package/dist/capabilities/match.js +139 -0
- package/dist/capabilities/match.js.map +1 -0
- package/dist/capabilities/migration-data.d.ts +2424 -0
- package/dist/capabilities/migration-data.d.ts.map +1 -0
- package/dist/capabilities/migration-data.js +2646 -0
- package/dist/capabilities/migration-data.js.map +1 -0
- package/dist/capabilities/migration.d.ts +176 -0
- package/dist/capabilities/migration.d.ts.map +1 -0
- package/dist/capabilities/migration.js +209 -0
- package/dist/capabilities/migration.js.map +1 -0
- package/dist/capabilities/types.d.ts +124 -0
- package/dist/capabilities/types.d.ts.map +1 -0
- package/dist/capabilities/types.js +2 -0
- package/dist/capabilities/types.js.map +1 -0
- package/dist/capabilities/validate.d.ts +19 -0
- package/dist/capabilities/validate.d.ts.map +1 -0
- package/dist/capabilities/validate.js +235 -0
- package/dist/capabilities/validate.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +111 -102
- package/scripts/check-service-keys.mjs +250 -0
- package/scripts/lint-phi.mjs +266 -266
|
@@ -0,0 +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"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { PermissionKey } from "../capabilities/catalog.js";
|
|
2
|
+
import type { CapabilityProduct } from "../capabilities/types.js";
|
|
3
|
+
/** Envelope of the internal authorization token Access signs and every service accepts. */
|
|
4
|
+
export declare const AUTHORIZATION_SCHEMA_VERSION: "sail-work-authorization.v2";
|
|
5
|
+
/** `tokenUse` of the internal authorization token (access-api src/seed-auth.ts:614). */
|
|
6
|
+
export declare const INTERNAL_AUTHORIZATION_TOKEN_USE: "internal-forward-auth";
|
|
7
|
+
/** Why readInternalAuthorization rejected a payload. The service maps every code to a 401. */
|
|
8
|
+
export type AuthorizationRejectionCode =
|
|
9
|
+
/** Not a plain object, or reading it threw. */
|
|
10
|
+
"AUTHORIZATION_PAYLOAD_INVALID"
|
|
11
|
+
/** `tokenUse` is not `internal-forward-auth`. */
|
|
12
|
+
| "AUTHORIZATION_TOKEN_USE_INVALID"
|
|
13
|
+
/** `schemaVersion` is not AUTHORIZATION_SCHEMA_VERSION (v1 included). */
|
|
14
|
+
| "AUTHORIZATION_SCHEMA_UNSUPPORTED"
|
|
15
|
+
/** `authorizationVersion` is not a safe integer >= 1. */
|
|
16
|
+
| "AUTHORIZATION_VERSION_INVALID"
|
|
17
|
+
/** A permission contains `*` or is not a key of this package's catalog. */
|
|
18
|
+
| "AUTHORIZATION_KEY_UNKNOWN"
|
|
19
|
+
/** Another claim is missing or has the wrong shape (named in `claim`). */
|
|
20
|
+
| "AUTHORIZATION_CLAIM_INVALID";
|
|
21
|
+
/** A legacy permission level (access-api src/access-domain.ts:53-57). Kept while a service still gates on levels. */
|
|
22
|
+
export interface PermissionLevelClaim {
|
|
23
|
+
readonly module: string;
|
|
24
|
+
readonly feature: string;
|
|
25
|
+
readonly level: 0 | 1 | 2 | 3 | 4;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The typed v2 payload: what Access signs (signInternalAuthorizationToken) and
|
|
29
|
+
* what a service reads after verifying the signature. `permissions` holds only
|
|
30
|
+
* explicit catalog keys. `workGrants`, `practitionerLink` and `money` keep the
|
|
31
|
+
* shapes Access and each service already validate; this package does not own
|
|
32
|
+
* them and passes them through as read.
|
|
33
|
+
*/
|
|
34
|
+
export interface InternalAuthorizationV2 {
|
|
35
|
+
readonly tokenUse: typeof INTERNAL_AUTHORIZATION_TOKEN_USE;
|
|
36
|
+
readonly iss: string;
|
|
37
|
+
readonly aud: string;
|
|
38
|
+
readonly sub: string;
|
|
39
|
+
readonly tenantId: string;
|
|
40
|
+
readonly licenseKey: string;
|
|
41
|
+
readonly sid: string;
|
|
42
|
+
readonly iat: number;
|
|
43
|
+
readonly exp: number;
|
|
44
|
+
readonly schemaVersion: typeof AUTHORIZATION_SCHEMA_VERSION;
|
|
45
|
+
/** Membership authorization counter (>= 1); a change invalidates the session. */
|
|
46
|
+
readonly authorizationVersion: number;
|
|
47
|
+
readonly licenseStatus: string;
|
|
48
|
+
readonly role?: string;
|
|
49
|
+
readonly username?: string;
|
|
50
|
+
/** Absent in the token when empty (access-api seed-auth.ts:627); read as []. */
|
|
51
|
+
readonly enabledProducts: readonly CapabilityProduct[];
|
|
52
|
+
/** Explicit catalog keys, sorted and without duplicates. Absent in the token when empty; read as []. */
|
|
53
|
+
readonly permissions: readonly PermissionKey[];
|
|
54
|
+
/** CAPABILITY_CATALOG_VERSION of the package Access signed with. */
|
|
55
|
+
readonly capabilityCatalogVersion: string;
|
|
56
|
+
readonly permissionLevels?: readonly PermissionLevelClaim[];
|
|
57
|
+
readonly workGrants: readonly unknown[];
|
|
58
|
+
readonly practitionerLink?: unknown;
|
|
59
|
+
readonly money?: unknown;
|
|
60
|
+
}
|
|
61
|
+
/** The token's catalog version against this package's: recorded, never blocking (E5). */
|
|
62
|
+
export interface CatalogVersionCheck {
|
|
63
|
+
readonly token: string;
|
|
64
|
+
readonly package: string;
|
|
65
|
+
readonly matches: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface InternalAuthorizationAccepted {
|
|
68
|
+
readonly ok: true;
|
|
69
|
+
readonly authorization: InternalAuthorizationV2;
|
|
70
|
+
readonly catalogVersion: CatalogVersionCheck;
|
|
71
|
+
}
|
|
72
|
+
export interface InternalAuthorizationRejected {
|
|
73
|
+
readonly ok: false;
|
|
74
|
+
readonly code: AuthorizationRejectionCode;
|
|
75
|
+
/** The claim at fault, when one is. */
|
|
76
|
+
readonly claim?: string;
|
|
77
|
+
/** For AUTHORIZATION_KEY_UNKNOWN: the offending permissions, sorted (keys are not secrets). */
|
|
78
|
+
readonly unknownKeys?: readonly string[];
|
|
79
|
+
}
|
|
80
|
+
export type InternalAuthorizationReadResult = InternalAuthorizationAccepted | InternalAuthorizationRejected;
|
|
81
|
+
/**
|
|
82
|
+
* Reads the payload of an internal authorization token that the caller has
|
|
83
|
+
* ALREADY verified (HS256 signature with rotation, `iss`, `aud` and timing,
|
|
84
|
+
* e.g. with `./jwt`). It verifies no signature, holds no secret and does no
|
|
85
|
+
* I/O. Fail-closed: it rejects a schemaVersion other than
|
|
86
|
+
* AUTHORIZATION_SCHEMA_VERSION (v1 included), a tokenUse other than
|
|
87
|
+
* `internal-forward-auth`, an authorizationVersion that is not a safe integer
|
|
88
|
+
* >= 1, any permission with `*` or outside this package's catalog
|
|
89
|
+
* (AUTHORIZATION_KEY_UNKNOWN) and any claim with the wrong shape. Only the
|
|
90
|
+
* payload's own data properties are read: an inherited claim is absent
|
|
91
|
+
* (`permissions` and `enabledProducts` then read as [], a required claim is
|
|
92
|
+
* rejected), an accessor claim is rejected without running it
|
|
93
|
+
* (AUTHORIZATION_CLAIM_INVALID) and a payload whose prototype is neither
|
|
94
|
+
* Object.prototype nor null is AUTHORIZATION_PAYLOAD_INVALID. A
|
|
95
|
+
* capabilityCatalogVersion different from this package's is recorded in
|
|
96
|
+
* `catalogVersion.matches`, never rejected (E5): log it as drift. Never
|
|
97
|
+
* throws, whatever the input (proxies, throwing getters, huge or unreadable
|
|
98
|
+
* lists become a rejection). The result and every object in it are frozen and
|
|
99
|
+
* have a null prototype (an absent optional claim reads as undefined even
|
|
100
|
+
* under a polluted Object.prototype); every list is copied with own data
|
|
101
|
+
* properties only (appendOwn), so no inherited setter can change it. The
|
|
102
|
+
* caller's objects are never modified.
|
|
103
|
+
*/
|
|
104
|
+
export declare function readInternalAuthorization(payload: unknown): InternalAuthorizationReadResult;
|
|
105
|
+
//# sourceMappingURL=internal-authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-authorization.d.ts","sourceRoot":"","sources":["../../src/authorization/internal-authorization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,2FAA2F;AAC3F,eAAO,MAAM,4BAA4B,EAA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 +1,287 @@
|
|
|
1
|
+
import { CAPABILITY_CATALOG_VERSION } from "../capabilities/catalog-data.js";
|
|
2
|
+
import { findUnknownPermissionKeys } from "../capabilities/catalog.js";
|
|
3
|
+
import { OWN_ACCESSOR, appendOwn, ownDataValue, readList } from "../capabilities/list.js";
|
|
4
|
+
/** Envelope of the internal authorization token Access signs and every service accepts. */
|
|
5
|
+
export const AUTHORIZATION_SCHEMA_VERSION = "sail-work-authorization.v2";
|
|
6
|
+
/** `tokenUse` of the internal authorization token (access-api src/seed-auth.ts:614). */
|
|
7
|
+
export const INTERNAL_AUTHORIZATION_TOKEN_USE = "internal-forward-auth";
|
|
8
|
+
const PRODUCTS = new Set(["sail", "connect"]);
|
|
9
|
+
const MAX_PERMISSION_LEVEL = 4;
|
|
10
|
+
// Thrown inside the reader only, to stop at the first rejection; never escapes
|
|
11
|
+
// it. The catch recognises its own rejections by identity (a WeakSet), so it
|
|
12
|
+
// never runs a trap (getPrototypeOf, get) of a value the input threw.
|
|
13
|
+
class Rejection extends Error {
|
|
14
|
+
result;
|
|
15
|
+
constructor(result) {
|
|
16
|
+
super(result.code);
|
|
17
|
+
this.result = result;
|
|
18
|
+
this.name = "Rejection";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const REJECTIONS = new WeakSet();
|
|
22
|
+
// Every object the reader returns has a null prototype and is frozen: reading
|
|
23
|
+
// an absent optional claim (`role`, `username`, `permissionLevels`,
|
|
24
|
+
// `practitionerLink`, `money`) or any other absent field gives undefined, never
|
|
25
|
+
// a value or a getter of a polluted Object.prototype. Object.assign onto a
|
|
26
|
+
// null-prototype object only defines own properties (no inherited setter).
|
|
27
|
+
function nullRecord(fields) {
|
|
28
|
+
return Object.freeze(Object.assign(Object.create(null), fields));
|
|
29
|
+
}
|
|
30
|
+
function reject(code, claim, unknownKeys) {
|
|
31
|
+
const rejection = new Rejection(nullRecord({
|
|
32
|
+
ok: false,
|
|
33
|
+
code,
|
|
34
|
+
...(claim !== undefined ? { claim } : {}),
|
|
35
|
+
...(unknownKeys !== undefined ? { unknownKeys: Object.freeze([...unknownKeys]) } : {})
|
|
36
|
+
}));
|
|
37
|
+
REJECTIONS.add(rejection);
|
|
38
|
+
throw rejection;
|
|
39
|
+
}
|
|
40
|
+
// The claims the reader looks at. Only the payload's OWN data properties
|
|
41
|
+
// count: an inherited claim (a prototype that provides `permissions`, or a
|
|
42
|
+
// polluted Object.prototype after JSON.parse) is absent, and an accessor is
|
|
43
|
+
// rejected without running it.
|
|
44
|
+
const CLAIMS = [
|
|
45
|
+
"tokenUse",
|
|
46
|
+
"iss",
|
|
47
|
+
"aud",
|
|
48
|
+
"sub",
|
|
49
|
+
"tenantId",
|
|
50
|
+
"licenseKey",
|
|
51
|
+
"sid",
|
|
52
|
+
"iat",
|
|
53
|
+
"exp",
|
|
54
|
+
"schemaVersion",
|
|
55
|
+
"authorizationVersion",
|
|
56
|
+
"licenseStatus",
|
|
57
|
+
"role",
|
|
58
|
+
"username",
|
|
59
|
+
"enabledProducts",
|
|
60
|
+
"permissions",
|
|
61
|
+
"capabilityCatalogVersion",
|
|
62
|
+
"permissionLevels",
|
|
63
|
+
"workGrants",
|
|
64
|
+
"practitionerLink",
|
|
65
|
+
"money"
|
|
66
|
+
];
|
|
67
|
+
// A plain record as JSON.parse builds it: an object (not an array) whose
|
|
68
|
+
// prototype is Object.prototype or null. Any other prototype is refused, so no
|
|
69
|
+
// class instance, proxy of one or crafted prototype chain is read.
|
|
70
|
+
function isPlainRecord(value) {
|
|
71
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const prototype = Object.getPrototypeOf(value);
|
|
75
|
+
return prototype === Object.prototype || prototype === null;
|
|
76
|
+
}
|
|
77
|
+
// Own data value of a claim of a plain record; rejects an accessor.
|
|
78
|
+
function ownClaim(record, property, claim) {
|
|
79
|
+
const value = ownDataValue(record, property);
|
|
80
|
+
return value === OWN_ACCESSOR ? reject("AUTHORIZATION_CLAIM_INVALID", claim) : value;
|
|
81
|
+
}
|
|
82
|
+
function readClaims(payload) {
|
|
83
|
+
if (!isPlainRecord(payload)) {
|
|
84
|
+
return reject("AUTHORIZATION_PAYLOAD_INVALID");
|
|
85
|
+
}
|
|
86
|
+
const claims = Object.create(null);
|
|
87
|
+
for (const claim of CLAIMS) {
|
|
88
|
+
claims[claim] = ownClaim(payload, claim, claim);
|
|
89
|
+
}
|
|
90
|
+
return claims;
|
|
91
|
+
}
|
|
92
|
+
function isNonEmptyString(value) {
|
|
93
|
+
return typeof value === "string" && value.length > 0;
|
|
94
|
+
}
|
|
95
|
+
function requiredString(claims, claim) {
|
|
96
|
+
const value = claims[claim];
|
|
97
|
+
return isNonEmptyString(value) ? value : reject("AUTHORIZATION_CLAIM_INVALID", claim);
|
|
98
|
+
}
|
|
99
|
+
function optionalString(claims, claim) {
|
|
100
|
+
const value = claims[claim];
|
|
101
|
+
if (value === undefined) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
return isNonEmptyString(value) ? value : reject("AUTHORIZATION_CLAIM_INVALID", claim);
|
|
105
|
+
}
|
|
106
|
+
function safeInteger(claims, claim) {
|
|
107
|
+
const value = claims[claim];
|
|
108
|
+
return typeof value === "number" && Number.isSafeInteger(value) ? value : reject("AUTHORIZATION_CLAIM_INVALID", claim);
|
|
109
|
+
}
|
|
110
|
+
// Plain copy of an array claim (readList: own elements by index, bounded,
|
|
111
|
+
// never its iterator nor an inherited element); rejects anything that is not a
|
|
112
|
+
// readable array.
|
|
113
|
+
function listClaim(value, claim) {
|
|
114
|
+
const read = readList(value);
|
|
115
|
+
return read.status === "ok" ? read.items : reject("AUTHORIZATION_CLAIM_INVALID", claim);
|
|
116
|
+
}
|
|
117
|
+
function sortedUnique(values) {
|
|
118
|
+
return [...new Set(values)].sort((left, right) => (left < right ? -1 : left > right ? 1 : 0));
|
|
119
|
+
}
|
|
120
|
+
function readProducts(value) {
|
|
121
|
+
if (value === undefined) {
|
|
122
|
+
return Object.freeze([]);
|
|
123
|
+
}
|
|
124
|
+
const items = listClaim(value, "enabledProducts");
|
|
125
|
+
const products = [];
|
|
126
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
127
|
+
const item = items[index];
|
|
128
|
+
if (!PRODUCTS.has(item)) {
|
|
129
|
+
reject("AUTHORIZATION_CLAIM_INVALID", "enabledProducts");
|
|
130
|
+
}
|
|
131
|
+
appendOwn(products, item);
|
|
132
|
+
}
|
|
133
|
+
return Object.freeze(sortedUnique(products));
|
|
134
|
+
}
|
|
135
|
+
function readPermissions(value) {
|
|
136
|
+
if (value === undefined) {
|
|
137
|
+
return Object.freeze([]);
|
|
138
|
+
}
|
|
139
|
+
const items = listClaim(value, "permissions");
|
|
140
|
+
const keys = [];
|
|
141
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
142
|
+
const item = items[index];
|
|
143
|
+
if (typeof item !== "string") {
|
|
144
|
+
reject("AUTHORIZATION_CLAIM_INVALID", "permissions");
|
|
145
|
+
}
|
|
146
|
+
appendOwn(keys, item);
|
|
147
|
+
}
|
|
148
|
+
// Any value with `*` or outside this package's catalog: fail closed.
|
|
149
|
+
const unknown = findUnknownPermissionKeys(keys);
|
|
150
|
+
if (unknown.length > 0) {
|
|
151
|
+
reject("AUTHORIZATION_KEY_UNKNOWN", "permissions", unknown);
|
|
152
|
+
}
|
|
153
|
+
return Object.freeze(sortedUnique(keys));
|
|
154
|
+
}
|
|
155
|
+
function readPermissionLevels(value) {
|
|
156
|
+
if (value === undefined) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
const items = listClaim(value, "permissionLevels");
|
|
160
|
+
const levels = [];
|
|
161
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
162
|
+
const item = items[index];
|
|
163
|
+
if (!isPlainRecord(item)) {
|
|
164
|
+
return reject("AUTHORIZATION_CLAIM_INVALID", "permissionLevels");
|
|
165
|
+
}
|
|
166
|
+
const module = ownClaim(item, "module", "permissionLevels");
|
|
167
|
+
const feature = ownClaim(item, "feature", "permissionLevels");
|
|
168
|
+
const level = ownClaim(item, "level", "permissionLevels");
|
|
169
|
+
if (!isNonEmptyString(module) ||
|
|
170
|
+
!isNonEmptyString(feature) ||
|
|
171
|
+
typeof level !== "number" ||
|
|
172
|
+
!Number.isInteger(level) ||
|
|
173
|
+
level < 0 ||
|
|
174
|
+
level > MAX_PERMISSION_LEVEL) {
|
|
175
|
+
reject("AUTHORIZATION_CLAIM_INVALID", "permissionLevels");
|
|
176
|
+
}
|
|
177
|
+
appendOwn(levels, nullRecord({ module, feature, level: level }));
|
|
178
|
+
}
|
|
179
|
+
return Object.freeze(levels);
|
|
180
|
+
}
|
|
181
|
+
function optionalObject(claims, claim) {
|
|
182
|
+
const value = claims[claim];
|
|
183
|
+
if (value === undefined || isPlainRecord(value)) {
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
return reject("AUTHORIZATION_CLAIM_INVALID", claim);
|
|
187
|
+
}
|
|
188
|
+
function read(payload) {
|
|
189
|
+
const claims = readClaims(payload);
|
|
190
|
+
if (claims.tokenUse !== INTERNAL_AUTHORIZATION_TOKEN_USE) {
|
|
191
|
+
reject("AUTHORIZATION_TOKEN_USE_INVALID", "tokenUse");
|
|
192
|
+
}
|
|
193
|
+
if (claims.schemaVersion !== AUTHORIZATION_SCHEMA_VERSION) {
|
|
194
|
+
reject("AUTHORIZATION_SCHEMA_UNSUPPORTED", "schemaVersion");
|
|
195
|
+
}
|
|
196
|
+
const authorizationVersion = claims.authorizationVersion;
|
|
197
|
+
if (typeof authorizationVersion !== "number" || !Number.isSafeInteger(authorizationVersion) || authorizationVersion < 1) {
|
|
198
|
+
reject("AUTHORIZATION_VERSION_INVALID", "authorizationVersion");
|
|
199
|
+
}
|
|
200
|
+
const iss = requiredString(claims, "iss");
|
|
201
|
+
const aud = requiredString(claims, "aud");
|
|
202
|
+
const sub = requiredString(claims, "sub");
|
|
203
|
+
const tenantId = requiredString(claims, "tenantId");
|
|
204
|
+
const licenseKey = requiredString(claims, "licenseKey");
|
|
205
|
+
const sid = requiredString(claims, "sid");
|
|
206
|
+
const licenseStatus = requiredString(claims, "licenseStatus");
|
|
207
|
+
const iat = safeInteger(claims, "iat");
|
|
208
|
+
const exp = safeInteger(claims, "exp");
|
|
209
|
+
if (exp <= iat) {
|
|
210
|
+
reject("AUTHORIZATION_CLAIM_INVALID", "exp");
|
|
211
|
+
}
|
|
212
|
+
const role = optionalString(claims, "role");
|
|
213
|
+
const username = optionalString(claims, "username");
|
|
214
|
+
const enabledProducts = readProducts(claims.enabledProducts);
|
|
215
|
+
const permissions = readPermissions(claims.permissions);
|
|
216
|
+
const capabilityCatalogVersion = requiredString(claims, "capabilityCatalogVersion");
|
|
217
|
+
const permissionLevels = readPermissionLevels(claims.permissionLevels);
|
|
218
|
+
const workGrants = Object.freeze([...listClaim(claims.workGrants, "workGrants")]);
|
|
219
|
+
const practitionerLink = optionalObject(claims, "practitionerLink");
|
|
220
|
+
const money = optionalObject(claims, "money");
|
|
221
|
+
const authorization = nullRecord({
|
|
222
|
+
tokenUse: INTERNAL_AUTHORIZATION_TOKEN_USE,
|
|
223
|
+
iss,
|
|
224
|
+
aud,
|
|
225
|
+
sub,
|
|
226
|
+
tenantId,
|
|
227
|
+
licenseKey,
|
|
228
|
+
sid,
|
|
229
|
+
iat,
|
|
230
|
+
exp,
|
|
231
|
+
schemaVersion: AUTHORIZATION_SCHEMA_VERSION,
|
|
232
|
+
authorizationVersion,
|
|
233
|
+
licenseStatus,
|
|
234
|
+
...(role !== undefined ? { role } : {}),
|
|
235
|
+
...(username !== undefined ? { username } : {}),
|
|
236
|
+
enabledProducts,
|
|
237
|
+
permissions,
|
|
238
|
+
capabilityCatalogVersion,
|
|
239
|
+
...(permissionLevels !== undefined ? { permissionLevels } : {}),
|
|
240
|
+
workGrants,
|
|
241
|
+
...(practitionerLink !== undefined ? { practitionerLink } : {}),
|
|
242
|
+
...(money !== undefined ? { money } : {})
|
|
243
|
+
});
|
|
244
|
+
return nullRecord({
|
|
245
|
+
ok: true,
|
|
246
|
+
authorization,
|
|
247
|
+
catalogVersion: nullRecord({
|
|
248
|
+
token: capabilityCatalogVersion,
|
|
249
|
+
package: CAPABILITY_CATALOG_VERSION,
|
|
250
|
+
matches: capabilityCatalogVersion === CAPABILITY_CATALOG_VERSION
|
|
251
|
+
})
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
const PAYLOAD_INVALID = nullRecord({ ok: false, code: "AUTHORIZATION_PAYLOAD_INVALID" });
|
|
255
|
+
/**
|
|
256
|
+
* Reads the payload of an internal authorization token that the caller has
|
|
257
|
+
* ALREADY verified (HS256 signature with rotation, `iss`, `aud` and timing,
|
|
258
|
+
* e.g. with `./jwt`). It verifies no signature, holds no secret and does no
|
|
259
|
+
* I/O. Fail-closed: it rejects a schemaVersion other than
|
|
260
|
+
* AUTHORIZATION_SCHEMA_VERSION (v1 included), a tokenUse other than
|
|
261
|
+
* `internal-forward-auth`, an authorizationVersion that is not a safe integer
|
|
262
|
+
* >= 1, any permission with `*` or outside this package's catalog
|
|
263
|
+
* (AUTHORIZATION_KEY_UNKNOWN) and any claim with the wrong shape. Only the
|
|
264
|
+
* payload's own data properties are read: an inherited claim is absent
|
|
265
|
+
* (`permissions` and `enabledProducts` then read as [], a required claim is
|
|
266
|
+
* rejected), an accessor claim is rejected without running it
|
|
267
|
+
* (AUTHORIZATION_CLAIM_INVALID) and a payload whose prototype is neither
|
|
268
|
+
* Object.prototype nor null is AUTHORIZATION_PAYLOAD_INVALID. A
|
|
269
|
+
* capabilityCatalogVersion different from this package's is recorded in
|
|
270
|
+
* `catalogVersion.matches`, never rejected (E5): log it as drift. Never
|
|
271
|
+
* throws, whatever the input (proxies, throwing getters, huge or unreadable
|
|
272
|
+
* lists become a rejection). The result and every object in it are frozen and
|
|
273
|
+
* have a null prototype (an absent optional claim reads as undefined even
|
|
274
|
+
* under a polluted Object.prototype); every list is copied with own data
|
|
275
|
+
* properties only (appendOwn), so no inherited setter can change it. The
|
|
276
|
+
* caller's objects are never modified.
|
|
277
|
+
*/
|
|
278
|
+
export function readInternalAuthorization(payload) {
|
|
279
|
+
try {
|
|
280
|
+
return read(payload);
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
// Identity check only: no trap of a value thrown by the input runs here.
|
|
284
|
+
return REJECTIONS.has(error) ? error.result : PAYLOAD_INVALID;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=internal-authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-authorization.js","sourceRoot":"","sources":["../../src/authorization/internal-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG1F,2FAA2F;AAC3F,MAAM,CAAC,MAAM,4BAA4B,GAAG,4BAAqC,CAAC;AAElF,wFAAwF;AACxF,MAAM,CAAC,MAAM,gCAAgC,GAAG,uBAAgC,CAAC;AAEjF,MAAM,QAAQ,GAAyB,IAAI,GAAG,CAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AACvF,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAmF/B,+EAA+E;AAC/E,6EAA6E;AAC7E,sEAAsE;AACtE,MAAM,SAAU,SAAQ,KAAK;IACN;IAArB,YAAqB,MAAqC;QACxD,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QADA,WAAM,GAAN,MAAM,CAA+B;QAExD,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,UAAU,GAAG,IAAI,OAAO,EAAa,CAAC;AAE5C,8EAA8E;AAC9E,oEAAoE;AAC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