@axonflow/sdk 9.1.0 → 9.3.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 +238 -22
- package/dist/cjs/adapters/langgraph.d.ts.map +1 -1
- package/dist/cjs/adapters/langgraph.js +20 -0
- package/dist/cjs/adapters/langgraph.js.map +1 -1
- package/dist/cjs/authzen.d.ts +353 -0
- package/dist/cjs/authzen.d.ts.map +1 -0
- package/dist/cjs/authzen.js +901 -0
- package/dist/cjs/authzen.js.map +1 -0
- package/dist/cjs/client.d.ts +135 -9
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +397 -30
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/heartbeat.d.ts +55 -4
- package/dist/cjs/heartbeat.d.ts.map +1 -1
- package/dist/cjs/heartbeat.js +86 -7
- package/dist/cjs/heartbeat.js.map +1 -1
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +55 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/read-identity.d.ts +267 -0
- package/dist/cjs/read-identity.d.ts.map +1 -0
- package/dist/cjs/read-identity.js +329 -0
- package/dist/cjs/read-identity.js.map +1 -0
- package/dist/cjs/telemetry.d.ts +176 -13
- package/dist/cjs/telemetry.d.ts.map +1 -1
- package/dist/cjs/telemetry.js +403 -37
- package/dist/cjs/telemetry.js.map +1 -1
- package/dist/cjs/types/authzen.gen.d.ts +407 -0
- package/dist/cjs/types/authzen.gen.d.ts.map +1 -0
- package/dist/cjs/types/authzen.gen.js +804 -0
- package/dist/cjs/types/authzen.gen.js.map +1 -0
- package/dist/cjs/types/config.d.ts +43 -1
- package/dist/cjs/types/config.d.ts.map +1 -1
- package/dist/cjs/types/hitl.js +1 -1
- package/dist/cjs/types/hitl.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/adapters/langgraph.d.ts.map +1 -1
- package/dist/esm/adapters/langgraph.js +20 -0
- package/dist/esm/adapters/langgraph.js.map +1 -1
- package/dist/esm/authzen.d.ts +353 -0
- package/dist/esm/authzen.d.ts.map +1 -0
- package/dist/esm/authzen.js +886 -0
- package/dist/esm/authzen.js.map +1 -0
- package/dist/esm/client.d.ts +135 -9
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +397 -30
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/heartbeat.d.ts +55 -4
- package/dist/esm/heartbeat.d.ts.map +1 -1
- package/dist/esm/heartbeat.js +85 -7
- package/dist/esm/heartbeat.js.map +1 -1
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/read-identity.d.ts +267 -0
- package/dist/esm/read-identity.d.ts.map +1 -0
- package/dist/esm/read-identity.js +320 -0
- package/dist/esm/read-identity.js.map +1 -0
- package/dist/esm/telemetry.d.ts +176 -13
- package/dist/esm/telemetry.d.ts.map +1 -1
- package/dist/esm/telemetry.js +397 -37
- package/dist/esm/telemetry.js.map +1 -1
- package/dist/esm/types/authzen.gen.d.ts +407 -0
- package/dist/esm/types/authzen.gen.d.ts.map +1 -0
- package/dist/esm/types/authzen.gen.js +779 -0
- package/dist/esm/types/authzen.gen.js.map +1 -0
- package/dist/esm/types/config.d.ts +43 -1
- package/dist/esm/types/config.d.ts.map +1 -1
- package/dist/esm/types/hitl.js +1 -1
- package/dist/esm/types/hitl.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,779 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthZEN wire types and validators. GENERATED FILE — DO NOT EDIT.
|
|
3
|
+
*
|
|
4
|
+
* Source: tests/fixtures/authzen-surface.json
|
|
5
|
+
* artifact: axonflow-authzen-surface v1
|
|
6
|
+
* profile: axonflow-authzen-profile-2026-08-29
|
|
7
|
+
* contract schema: 2026-08-29
|
|
8
|
+
* schema digest: sha256:04f63f4d97215faa9fbf2b6a5152630f7310edbe47440b975d0f66ad63df811f
|
|
9
|
+
*
|
|
10
|
+
* Regenerate with:
|
|
11
|
+
*
|
|
12
|
+
* node scripts/gen-authzen-types/generate.js
|
|
13
|
+
*
|
|
14
|
+
* Editing this file by hand is pointless: tests/authzen-generator.test.ts
|
|
15
|
+
* regenerates it in memory and compares bytes, so a hand edit fails CI on the
|
|
16
|
+
* next run.
|
|
17
|
+
*/
|
|
18
|
+
// The profile a Policy Enforcement Point negotiates to receive anything beyond the
|
|
19
|
+
// boolean decision. AuthZEN 1.0's response is a bare boolean; the four-valued state,
|
|
20
|
+
// the obligations, the approval challenge and the safe reason code all ride in the
|
|
21
|
+
// response context and are returned ONLY to a caller that asked for them by version.
|
|
22
|
+
export const AUTHZEN_PROFILE_V1 = 'axonflow-authzen-profile-2026-08-29';
|
|
23
|
+
// The contract version these types were generated from. It is the value the server
|
|
24
|
+
// echoes in AuthZENResponseContext.schema_version.
|
|
25
|
+
export const AUTHZEN_CONTRACT_SCHEMA_VERSION = '2026-08-29';
|
|
26
|
+
// The one route the AuthZEN surface is served on, and the request header the profile
|
|
27
|
+
// is negotiated with. Both are generated from the platform's contract through the
|
|
28
|
+
// artifact, not written here: a rename on the platform is a regenerate-and-diff
|
|
29
|
+
// failure in this SDK, not a 404 in production (axonflow-enterprise#3603).
|
|
30
|
+
export const AUTHZEN_PATH = '/api/v1/access/evaluation';
|
|
31
|
+
export const AUTHZEN_PROFILE_HEADER = 'X-Axonflow-AuthZEN-Profile';
|
|
32
|
+
// The digest of the JSON Schema the artifact was reduced from. It is carried so a
|
|
33
|
+
// support conversation can establish which contract a deployed SDK was built against
|
|
34
|
+
// without reading its dependency tree.
|
|
35
|
+
export const AUTHZEN_SOURCE_SCHEMA_SHA256 = 'sha256:04f63f4d97215faa9fbf2b6a5152630f7310edbe47440b975d0f66ad63df811f';
|
|
36
|
+
/**
|
|
37
|
+
* Raised when a value does not match the AuthZEN contract. The message always
|
|
38
|
+
* names a JSON Pointer, because on this surface the pointer IS the diagnosis:
|
|
39
|
+
* "unsupported_subject" without the offending member is a puzzle.
|
|
40
|
+
*/
|
|
41
|
+
export class AuthZENSchemaError extends Error {
|
|
42
|
+
constructor(pointer, detail) {
|
|
43
|
+
super(`${pointer || '/'} ${detail}`);
|
|
44
|
+
this.name = 'AuthZENSchemaError';
|
|
45
|
+
this.pointer = pointer;
|
|
46
|
+
Object.setPrototypeOf(this, AuthZENSchemaError.prototype);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function authzenFail(pointer, detail) {
|
|
50
|
+
throw new AuthZENSchemaError(pointer, detail);
|
|
51
|
+
}
|
|
52
|
+
export function authzenObject(value, at) {
|
|
53
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
54
|
+
authzenFail(at, 'must be an object');
|
|
55
|
+
}
|
|
56
|
+
return { ...value };
|
|
57
|
+
}
|
|
58
|
+
export function authzenString(value, at) {
|
|
59
|
+
if (typeof value !== 'string') {
|
|
60
|
+
authzenFail(at, 'must be a string');
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
export function authzenBoolean(value, at) {
|
|
65
|
+
if (typeof value !== 'boolean') {
|
|
66
|
+
authzenFail(at, 'must be a boolean');
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
// An integer, not merely a number. The artifact distinguishes them, and a
|
|
71
|
+
// fractional schema_version is not a schema_version.
|
|
72
|
+
export function authzenInteger(value, at) {
|
|
73
|
+
if (typeof value !== 'number' || !Number.isInteger(value)) {
|
|
74
|
+
authzenFail(at, 'must be an integer');
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
export function authzenArray(value, at) {
|
|
79
|
+
if (!Array.isArray(value)) {
|
|
80
|
+
authzenFail(at, 'must be an array');
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Refuse a member the contract does not declare.
|
|
86
|
+
*
|
|
87
|
+
* On the RESPONSE path this is the whole strictness argument: a member this
|
|
88
|
+
* build has never heard of means the server is speaking a profile it cannot
|
|
89
|
+
* fully read, and dropping it silently would mean acting on a partial reading
|
|
90
|
+
* of an authorization decision. On the REQUEST path it catches a member the
|
|
91
|
+
* caller invented before it becomes a 422.
|
|
92
|
+
*/
|
|
93
|
+
export function authzenNoExtraMembers(obj, at, known) {
|
|
94
|
+
const extra = Object.keys(obj)
|
|
95
|
+
.filter(key => !known.includes(key))
|
|
96
|
+
.sort();
|
|
97
|
+
if (extra.length > 0) {
|
|
98
|
+
authzenFail(at, `carries members this build does not understand: ${extra.join(', ')}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export const AUTHZEN_ERROR_CODE_MALFORMED_ENVELOPE = 'malformed_envelope';
|
|
102
|
+
export const AUTHZEN_ERROR_CODE_INCOMPLETE_EVALUATION = 'incomplete_evaluation';
|
|
103
|
+
export const AUTHZEN_ERROR_CODE_UNSUPPORTED_SUBJECT = 'unsupported_subject';
|
|
104
|
+
export const AUTHZEN_ERROR_CODE_UNSUPPORTED_ACTION = 'unsupported_action';
|
|
105
|
+
export const AUTHZEN_ERROR_CODE_UNSUPPORTED_RESOURCE = 'unsupported_resource';
|
|
106
|
+
export const AUTHZEN_ERROR_CODE_UNEVALUABLE_ATTRIBUTE = 'unevaluable_attribute';
|
|
107
|
+
export const AUTHZEN_ERROR_CODE_MISSING_EVALUABLE_CONTENT = 'missing_evaluable_content';
|
|
108
|
+
export const AUTHZEN_ERROR_CODE_EVALUATION_UNAVAILABLE = 'evaluation_unavailable';
|
|
109
|
+
// Every value of authzen_error_code this build knows, in the artifact's order.
|
|
110
|
+
export const AUTHZEN_ERROR_CODE_VALUES = [
|
|
111
|
+
AUTHZEN_ERROR_CODE_MALFORMED_ENVELOPE,
|
|
112
|
+
AUTHZEN_ERROR_CODE_INCOMPLETE_EVALUATION,
|
|
113
|
+
AUTHZEN_ERROR_CODE_UNSUPPORTED_SUBJECT,
|
|
114
|
+
AUTHZEN_ERROR_CODE_UNSUPPORTED_ACTION,
|
|
115
|
+
AUTHZEN_ERROR_CODE_UNSUPPORTED_RESOURCE,
|
|
116
|
+
AUTHZEN_ERROR_CODE_UNEVALUABLE_ATTRIBUTE,
|
|
117
|
+
AUTHZEN_ERROR_CODE_MISSING_EVALUABLE_CONTENT,
|
|
118
|
+
AUTHZEN_ERROR_CODE_EVALUATION_UNAVAILABLE,
|
|
119
|
+
];
|
|
120
|
+
export const AUTHZEN_CATEGORY_ALLOWED = 'allowed';
|
|
121
|
+
export const AUTHZEN_CATEGORY_NOT_PERMITTED = 'not_permitted';
|
|
122
|
+
export const AUTHZEN_CATEGORY_APPROVAL_REQUIRED = 'approval_required';
|
|
123
|
+
export const AUTHZEN_CATEGORY_TEMPORARILY_UNAVAILABLE = 'temporarily_unavailable';
|
|
124
|
+
export const AUTHZEN_CATEGORY_INVALID_REQUEST = 'invalid_request';
|
|
125
|
+
// Every value of category this build knows, in the artifact's order.
|
|
126
|
+
export const AUTHZEN_CATEGORY_VALUES = [
|
|
127
|
+
AUTHZEN_CATEGORY_ALLOWED,
|
|
128
|
+
AUTHZEN_CATEGORY_NOT_PERMITTED,
|
|
129
|
+
AUTHZEN_CATEGORY_APPROVAL_REQUIRED,
|
|
130
|
+
AUTHZEN_CATEGORY_TEMPORARILY_UNAVAILABLE,
|
|
131
|
+
AUTHZEN_CATEGORY_INVALID_REQUEST,
|
|
132
|
+
];
|
|
133
|
+
export const AUTHZEN_IDENTIFIER_KIND_ORGANIZATION = 'organization';
|
|
134
|
+
export const AUTHZEN_IDENTIFIER_KIND_PRINCIPAL = 'principal';
|
|
135
|
+
export const AUTHZEN_IDENTIFIER_KIND_GROUP = 'group';
|
|
136
|
+
export const AUTHZEN_IDENTIFIER_KIND_RESOURCE = 'resource';
|
|
137
|
+
export const AUTHZEN_IDENTIFIER_KIND_ACTION = 'action';
|
|
138
|
+
export const AUTHZEN_IDENTIFIER_KIND_TOOL = 'tool';
|
|
139
|
+
export const AUTHZEN_IDENTIFIER_KIND_CLIENT = 'client';
|
|
140
|
+
export const AUTHZEN_IDENTIFIER_KIND_SESSION = 'session';
|
|
141
|
+
// Every value of identifier_kind this build knows, in the artifact's order.
|
|
142
|
+
export const AUTHZEN_IDENTIFIER_KIND_VALUES = [
|
|
143
|
+
AUTHZEN_IDENTIFIER_KIND_ORGANIZATION,
|
|
144
|
+
AUTHZEN_IDENTIFIER_KIND_PRINCIPAL,
|
|
145
|
+
AUTHZEN_IDENTIFIER_KIND_GROUP,
|
|
146
|
+
AUTHZEN_IDENTIFIER_KIND_RESOURCE,
|
|
147
|
+
AUTHZEN_IDENTIFIER_KIND_ACTION,
|
|
148
|
+
AUTHZEN_IDENTIFIER_KIND_TOOL,
|
|
149
|
+
AUTHZEN_IDENTIFIER_KIND_CLIENT,
|
|
150
|
+
AUTHZEN_IDENTIFIER_KIND_SESSION,
|
|
151
|
+
];
|
|
152
|
+
export const AUTHZEN_OBLIGATION_TYPE_APPROVAL_CHALLENGE = 'approval_challenge';
|
|
153
|
+
export const AUTHZEN_OBLIGATION_TYPE_FIELD_REMOVE = 'field_remove';
|
|
154
|
+
export const AUTHZEN_OBLIGATION_TYPE_FIELD_REDACT = 'field_redact';
|
|
155
|
+
export const AUTHZEN_OBLIGATION_TYPE_FIELD_HASH = 'field_hash';
|
|
156
|
+
export const AUTHZEN_OBLIGATION_TYPE_FIELD_MASK = 'field_mask';
|
|
157
|
+
export const AUTHZEN_OBLIGATION_TYPE_FIELD_ANNOTATE = 'field_annotate';
|
|
158
|
+
export const AUTHZEN_OBLIGATION_TYPE_FIELD_TOKENIZE = 'field_tokenize';
|
|
159
|
+
export const AUTHZEN_OBLIGATION_TYPE_SCHEMA_TRANSFORM = 'schema_transform';
|
|
160
|
+
export const AUTHZEN_OBLIGATION_TYPE_RESPONSE_FILTER = 'response_filter';
|
|
161
|
+
export const AUTHZEN_OBLIGATION_TYPE_ROUTE_RESTRICTION = 'route_restriction';
|
|
162
|
+
export const AUTHZEN_OBLIGATION_TYPE_STEP_UP_AUTHENTICATION = 'step_up_authentication';
|
|
163
|
+
export const AUTHZEN_OBLIGATION_TYPE_QUOTA_RESERVATION = 'quota_reservation';
|
|
164
|
+
export const AUTHZEN_OBLIGATION_TYPE_IMMUTABLE_AUDIT = 'immutable_audit';
|
|
165
|
+
export const AUTHZEN_OBLIGATION_TYPE_NOTIFICATION = 'notification';
|
|
166
|
+
// Every value of obligation_type this build knows, in the artifact's order.
|
|
167
|
+
export const AUTHZEN_OBLIGATION_TYPE_VALUES = [
|
|
168
|
+
AUTHZEN_OBLIGATION_TYPE_APPROVAL_CHALLENGE,
|
|
169
|
+
AUTHZEN_OBLIGATION_TYPE_FIELD_REMOVE,
|
|
170
|
+
AUTHZEN_OBLIGATION_TYPE_FIELD_REDACT,
|
|
171
|
+
AUTHZEN_OBLIGATION_TYPE_FIELD_HASH,
|
|
172
|
+
AUTHZEN_OBLIGATION_TYPE_FIELD_MASK,
|
|
173
|
+
AUTHZEN_OBLIGATION_TYPE_FIELD_ANNOTATE,
|
|
174
|
+
AUTHZEN_OBLIGATION_TYPE_FIELD_TOKENIZE,
|
|
175
|
+
AUTHZEN_OBLIGATION_TYPE_SCHEMA_TRANSFORM,
|
|
176
|
+
AUTHZEN_OBLIGATION_TYPE_RESPONSE_FILTER,
|
|
177
|
+
AUTHZEN_OBLIGATION_TYPE_ROUTE_RESTRICTION,
|
|
178
|
+
AUTHZEN_OBLIGATION_TYPE_STEP_UP_AUTHENTICATION,
|
|
179
|
+
AUTHZEN_OBLIGATION_TYPE_QUOTA_RESERVATION,
|
|
180
|
+
AUTHZEN_OBLIGATION_TYPE_IMMUTABLE_AUDIT,
|
|
181
|
+
AUTHZEN_OBLIGATION_TYPE_NOTIFICATION,
|
|
182
|
+
];
|
|
183
|
+
export const AUTHZEN_OPERATIONAL_STATE_ALLOW = 'ALLOW';
|
|
184
|
+
export const AUTHZEN_OPERATIONAL_STATE_DENY = 'DENY';
|
|
185
|
+
export const AUTHZEN_OPERATIONAL_STATE_CHALLENGE = 'CHALLENGE';
|
|
186
|
+
export const AUTHZEN_OPERATIONAL_STATE_ERROR = 'ERROR';
|
|
187
|
+
// Every value of operational_state this build knows, in the artifact's order.
|
|
188
|
+
export const AUTHZEN_OPERATIONAL_STATE_VALUES = [
|
|
189
|
+
AUTHZEN_OPERATIONAL_STATE_ALLOW,
|
|
190
|
+
AUTHZEN_OPERATIONAL_STATE_DENY,
|
|
191
|
+
AUTHZEN_OPERATIONAL_STATE_CHALLENGE,
|
|
192
|
+
AUTHZEN_OPERATIONAL_STATE_ERROR,
|
|
193
|
+
];
|
|
194
|
+
export const AUTHZEN_REASON_CODE_PERMITTED = 'permitted';
|
|
195
|
+
export const AUTHZEN_REASON_CODE_APPROVAL_REQUIRED = 'approval_required';
|
|
196
|
+
export const AUTHZEN_REASON_CODE_EXPLICIT_CONSTRAINT = 'explicit_constraint';
|
|
197
|
+
export const AUTHZEN_REASON_CODE_NO_MATCHING_PERMISSION = 'no_matching_permission';
|
|
198
|
+
export const AUTHZEN_REASON_CODE_UNKNOWN_CONSTRAINT = 'unknown_constraint';
|
|
199
|
+
export const AUTHZEN_REASON_CODE_UNKNOWN_PERMISSION = 'unknown_permission';
|
|
200
|
+
export const AUTHZEN_REASON_CODE_UNKNOWN_REQUIREMENT = 'unknown_requirement';
|
|
201
|
+
export const AUTHZEN_REASON_CODE_INVALID_INPUT = 'invalid_input';
|
|
202
|
+
export const AUTHZEN_REASON_CODE_EVALUATION_ERROR = 'evaluation_error';
|
|
203
|
+
export const AUTHZEN_REASON_CODE_UNSUPPORTED_OBLIGATION = 'unsupported_obligation';
|
|
204
|
+
export const AUTHZEN_REASON_CODE_OBLIGATION_CONFLICT = 'obligation_conflict';
|
|
205
|
+
export const AUTHZEN_REASON_CODE_UNKNOWN_ACTION = 'unknown_action';
|
|
206
|
+
export const AUTHZEN_REASON_CODE_UNKNOWN_REALM = 'unknown_realm';
|
|
207
|
+
export const AUTHZEN_REASON_CODE_SCHEMA_VIOLATION = 'schema_violation';
|
|
208
|
+
export const AUTHZEN_REASON_CODE_DELEGATION_DEPTH_EXCEEDED = 'delegation_depth_exceeded';
|
|
209
|
+
export const AUTHZEN_REASON_CODE_BUDGET_EXHAUSTED = 'budget_exhausted';
|
|
210
|
+
export const AUTHZEN_REASON_CODE_BINDING_MISMATCH = 'binding_mismatch';
|
|
211
|
+
export const AUTHZEN_REASON_CODE_APPROVAL_UNSATISFIABLE = 'approval_unsatisfiable';
|
|
212
|
+
export const AUTHZEN_REASON_CODE_APPROVAL_EXPIRED = 'approval_expired';
|
|
213
|
+
export const AUTHZEN_REASON_CODE_AUTHORING_REJECTED = 'authoring_rejected';
|
|
214
|
+
// Every value of reason_code this build knows, in the artifact's order.
|
|
215
|
+
export const AUTHZEN_REASON_CODE_VALUES = [
|
|
216
|
+
AUTHZEN_REASON_CODE_PERMITTED,
|
|
217
|
+
AUTHZEN_REASON_CODE_APPROVAL_REQUIRED,
|
|
218
|
+
AUTHZEN_REASON_CODE_EXPLICIT_CONSTRAINT,
|
|
219
|
+
AUTHZEN_REASON_CODE_NO_MATCHING_PERMISSION,
|
|
220
|
+
AUTHZEN_REASON_CODE_UNKNOWN_CONSTRAINT,
|
|
221
|
+
AUTHZEN_REASON_CODE_UNKNOWN_PERMISSION,
|
|
222
|
+
AUTHZEN_REASON_CODE_UNKNOWN_REQUIREMENT,
|
|
223
|
+
AUTHZEN_REASON_CODE_INVALID_INPUT,
|
|
224
|
+
AUTHZEN_REASON_CODE_EVALUATION_ERROR,
|
|
225
|
+
AUTHZEN_REASON_CODE_UNSUPPORTED_OBLIGATION,
|
|
226
|
+
AUTHZEN_REASON_CODE_OBLIGATION_CONFLICT,
|
|
227
|
+
AUTHZEN_REASON_CODE_UNKNOWN_ACTION,
|
|
228
|
+
AUTHZEN_REASON_CODE_UNKNOWN_REALM,
|
|
229
|
+
AUTHZEN_REASON_CODE_SCHEMA_VIOLATION,
|
|
230
|
+
AUTHZEN_REASON_CODE_DELEGATION_DEPTH_EXCEEDED,
|
|
231
|
+
AUTHZEN_REASON_CODE_BUDGET_EXHAUSTED,
|
|
232
|
+
AUTHZEN_REASON_CODE_BINDING_MISMATCH,
|
|
233
|
+
AUTHZEN_REASON_CODE_APPROVAL_UNSATISFIABLE,
|
|
234
|
+
AUTHZEN_REASON_CODE_APPROVAL_EXPIRED,
|
|
235
|
+
AUTHZEN_REASON_CODE_AUTHORING_REJECTED,
|
|
236
|
+
];
|
|
237
|
+
/**
|
|
238
|
+
* Validate an unknown value as AuthZENApprovalClause, or throw naming the member at
|
|
239
|
+
* fault. Unknown members are REFUSED rather than dropped: on the response path an
|
|
240
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
241
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
242
|
+
* decision.
|
|
243
|
+
*/
|
|
244
|
+
export function validateAuthZENApprovalClause(value, at) {
|
|
245
|
+
const obj = authzenObject(value, at);
|
|
246
|
+
authzenNoExtraMembers(obj, at, ['quorum', 'eligible']);
|
|
247
|
+
if (obj['quorum'] === undefined || obj['quorum'] === null) {
|
|
248
|
+
authzenFail(`${at}/quorum`, 'is required');
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
authzenInteger(obj['quorum'], `${at}/quorum`);
|
|
252
|
+
}
|
|
253
|
+
if (obj['eligible'] === undefined || obj['eligible'] === null) {
|
|
254
|
+
authzenFail(`${at}/eligible`, 'is required');
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
const items = authzenArray(obj['eligible'], `${at}/eligible`);
|
|
258
|
+
if (items.length < 1) {
|
|
259
|
+
authzenFail(`${at}/eligible`, 'needs at least 1 entry');
|
|
260
|
+
}
|
|
261
|
+
obj['eligible'] = items.map((item, index) => validateAuthZENIdentifier(item, `${`${at}/eligible`}/${index}`));
|
|
262
|
+
}
|
|
263
|
+
return obj;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Validate an unknown value as AuthZENApprovalRequirement, or throw naming the member
|
|
267
|
+
* at fault. Unknown members are REFUSED rather than dropped: on the response path an
|
|
268
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
269
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
270
|
+
* decision.
|
|
271
|
+
*/
|
|
272
|
+
export function validateAuthZENApprovalRequirement(value, at) {
|
|
273
|
+
const obj = authzenObject(value, at);
|
|
274
|
+
authzenNoExtraMembers(obj, at, ['all_of', 'separation_of_duties', 'expires_at']);
|
|
275
|
+
if (obj['all_of'] === undefined || obj['all_of'] === null) {
|
|
276
|
+
authzenFail(`${at}/all_of`, 'is required');
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
const items = authzenArray(obj['all_of'], `${at}/all_of`);
|
|
280
|
+
if (items.length < 1) {
|
|
281
|
+
authzenFail(`${at}/all_of`, 'needs at least 1 entry');
|
|
282
|
+
}
|
|
283
|
+
obj['all_of'] = items.map((item, index) => validateAuthZENApprovalClause(item, `${`${at}/all_of`}/${index}`));
|
|
284
|
+
}
|
|
285
|
+
if (obj['separation_of_duties'] === undefined || obj['separation_of_duties'] === null) {
|
|
286
|
+
authzenFail(`${at}/separation_of_duties`, 'is required');
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
authzenBoolean(obj['separation_of_duties'], `${at}/separation_of_duties`);
|
|
290
|
+
}
|
|
291
|
+
if (obj['expires_at'] === undefined || obj['expires_at'] === null) {
|
|
292
|
+
authzenFail(`${at}/expires_at`, 'is required');
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
authzenString(obj['expires_at'], `${at}/expires_at`);
|
|
296
|
+
}
|
|
297
|
+
return obj;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Validate an unknown value as AuthZENAction, or throw naming the member at fault.
|
|
301
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
302
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
303
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
304
|
+
* decision.
|
|
305
|
+
*/
|
|
306
|
+
export function validateAuthZENAction(value, at) {
|
|
307
|
+
const obj = authzenObject(value, at);
|
|
308
|
+
authzenNoExtraMembers(obj, at, ['name', 'properties']);
|
|
309
|
+
if (obj['name'] === undefined || obj['name'] === null) {
|
|
310
|
+
authzenFail(`${at}/name`, 'is required');
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
const raw = authzenString(obj['name'], `${at}/name`);
|
|
314
|
+
if (raw.length < 1) {
|
|
315
|
+
authzenFail(`${at}/name`, 'must be at least 1 character(s); it is present but too short');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (obj['properties'] === undefined || obj['properties'] === null) {
|
|
319
|
+
delete obj['properties'];
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
authzenObject(obj['properties'], `${at}/properties`);
|
|
323
|
+
}
|
|
324
|
+
return obj;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Validate an unknown value as AuthZENBulk, or throw naming the member at fault.
|
|
328
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
329
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
330
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
331
|
+
* decision.
|
|
332
|
+
*/
|
|
333
|
+
export function validateAuthZENBulk(value, at) {
|
|
334
|
+
const obj = authzenObject(value, at);
|
|
335
|
+
authzenNoExtraMembers(obj, at, ['subject', 'action', 'resource', 'context', 'evaluations']);
|
|
336
|
+
if (obj['subject'] === undefined || obj['subject'] === null) {
|
|
337
|
+
delete obj['subject'];
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
obj['subject'] = validateAuthZENSubject(obj['subject'], `${at}/subject`);
|
|
341
|
+
}
|
|
342
|
+
if (obj['action'] === undefined || obj['action'] === null) {
|
|
343
|
+
delete obj['action'];
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
obj['action'] = validateAuthZENAction(obj['action'], `${at}/action`);
|
|
347
|
+
}
|
|
348
|
+
if (obj['resource'] === undefined || obj['resource'] === null) {
|
|
349
|
+
delete obj['resource'];
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
obj['resource'] = validateAuthZENResource(obj['resource'], `${at}/resource`);
|
|
353
|
+
}
|
|
354
|
+
if (obj['context'] === undefined || obj['context'] === null) {
|
|
355
|
+
delete obj['context'];
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
authzenObject(obj['context'], `${at}/context`);
|
|
359
|
+
}
|
|
360
|
+
if (obj['evaluations'] === undefined || obj['evaluations'] === null) {
|
|
361
|
+
authzenFail(`${at}/evaluations`, 'is required');
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
const items = authzenArray(obj['evaluations'], `${at}/evaluations`);
|
|
365
|
+
if (items.length < 1) {
|
|
366
|
+
authzenFail(`${at}/evaluations`, 'needs at least 1 entry');
|
|
367
|
+
}
|
|
368
|
+
obj['evaluations'] = items.map((item, index) => validateAuthZENRequest(item, `${`${at}/evaluations`}/${index}`));
|
|
369
|
+
}
|
|
370
|
+
return obj;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Validate an unknown value as AuthZENEnvelope, or throw naming the member at fault.
|
|
374
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
375
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
376
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
377
|
+
* decision.
|
|
378
|
+
*/
|
|
379
|
+
export function validateAuthZENEnvelope(value, at) {
|
|
380
|
+
const obj = authzenObject(value, at);
|
|
381
|
+
authzenNoExtraMembers(obj, at, ['evaluation', 'evaluations']);
|
|
382
|
+
if (obj['evaluation'] === undefined || obj['evaluation'] === null) {
|
|
383
|
+
delete obj['evaluation'];
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
obj['evaluation'] = validateAuthZENRequest(obj['evaluation'], `${at}/evaluation`);
|
|
387
|
+
}
|
|
388
|
+
if (obj['evaluations'] === undefined || obj['evaluations'] === null) {
|
|
389
|
+
delete obj['evaluations'];
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
obj['evaluations'] = validateAuthZENBulk(obj['evaluations'], `${at}/evaluations`);
|
|
393
|
+
}
|
|
394
|
+
{
|
|
395
|
+
const set = [obj['evaluation'] !== undefined, obj['evaluations'] !== undefined].filter(Boolean).length;
|
|
396
|
+
if (set !== 1) {
|
|
397
|
+
authzenFail(at, `exactly one of evaluation or evaluations must be set, ${set} are`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (obj['evaluation'] !== undefined) {
|
|
401
|
+
const nested = obj['evaluation'];
|
|
402
|
+
if (nested['action'] === undefined || nested['action'] === null) {
|
|
403
|
+
authzenFail(`${at}/evaluation`, 'has no action; it has no shared base to inherit one from');
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (obj['evaluation'] !== undefined) {
|
|
407
|
+
const nested = obj['evaluation'];
|
|
408
|
+
if (nested['resource'] === undefined || nested['resource'] === null) {
|
|
409
|
+
authzenFail(`${at}/evaluation`, 'has no resource; it has no shared base to inherit one from');
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (obj['evaluation'] !== undefined) {
|
|
413
|
+
const nested = obj['evaluation'];
|
|
414
|
+
if (nested['subject'] === undefined || nested['subject'] === null) {
|
|
415
|
+
authzenFail(`${at}/evaluation`, 'has no subject; it has no shared base to inherit one from');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return obj;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Validate an unknown value as AuthZENError, or throw naming the member at fault.
|
|
422
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
423
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
424
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
425
|
+
* decision.
|
|
426
|
+
*/
|
|
427
|
+
export function validateAuthZENError(value, at) {
|
|
428
|
+
const obj = authzenObject(value, at);
|
|
429
|
+
authzenNoExtraMembers(obj, at, ['code', 'pointer', 'message', 'supported', 'request_id']);
|
|
430
|
+
if (obj['code'] === undefined || obj['code'] === null) {
|
|
431
|
+
authzenFail(`${at}/code`, 'is required');
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
authzenString(obj['code'], `${at}/code`);
|
|
435
|
+
}
|
|
436
|
+
if (obj['pointer'] === undefined || obj['pointer'] === null) {
|
|
437
|
+
delete obj['pointer'];
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
authzenString(obj['pointer'], `${at}/pointer`);
|
|
441
|
+
}
|
|
442
|
+
if (obj['message'] === undefined || obj['message'] === null) {
|
|
443
|
+
authzenFail(`${at}/message`, 'is required');
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
const raw = authzenString(obj['message'], `${at}/message`);
|
|
447
|
+
if (raw.length < 1) {
|
|
448
|
+
authzenFail(`${at}/message`, 'must be at least 1 character(s); it is present but too short');
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (obj['supported'] === undefined || obj['supported'] === null) {
|
|
452
|
+
delete obj['supported'];
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
const items = authzenArray(obj['supported'], `${at}/supported`);
|
|
456
|
+
items.forEach((item, index) => {
|
|
457
|
+
authzenString(item, `${`${at}/supported`}/${index}`);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
if (obj['request_id'] === undefined || obj['request_id'] === null) {
|
|
461
|
+
delete obj['request_id'];
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
authzenString(obj['request_id'], `${at}/request_id`);
|
|
465
|
+
}
|
|
466
|
+
return obj;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Validate an unknown value as AuthZENRequest, or throw naming the member at fault.
|
|
470
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
471
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
472
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
473
|
+
* decision.
|
|
474
|
+
*/
|
|
475
|
+
export function validateAuthZENRequest(value, at) {
|
|
476
|
+
const obj = authzenObject(value, at);
|
|
477
|
+
authzenNoExtraMembers(obj, at, ['subject', 'action', 'resource', 'context']);
|
|
478
|
+
if (obj['subject'] === undefined || obj['subject'] === null) {
|
|
479
|
+
delete obj['subject'];
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
obj['subject'] = validateAuthZENSubject(obj['subject'], `${at}/subject`);
|
|
483
|
+
}
|
|
484
|
+
if (obj['action'] === undefined || obj['action'] === null) {
|
|
485
|
+
delete obj['action'];
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
obj['action'] = validateAuthZENAction(obj['action'], `${at}/action`);
|
|
489
|
+
}
|
|
490
|
+
if (obj['resource'] === undefined || obj['resource'] === null) {
|
|
491
|
+
delete obj['resource'];
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
obj['resource'] = validateAuthZENResource(obj['resource'], `${at}/resource`);
|
|
495
|
+
}
|
|
496
|
+
if (obj['context'] === undefined || obj['context'] === null) {
|
|
497
|
+
delete obj['context'];
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
authzenObject(obj['context'], `${at}/context`);
|
|
501
|
+
}
|
|
502
|
+
return obj;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Validate an unknown value as AuthZENResource, or throw naming the member at fault.
|
|
506
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
507
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
508
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
509
|
+
* decision.
|
|
510
|
+
*/
|
|
511
|
+
export function validateAuthZENResource(value, at) {
|
|
512
|
+
const obj = authzenObject(value, at);
|
|
513
|
+
authzenNoExtraMembers(obj, at, ['type', 'id', 'properties']);
|
|
514
|
+
if (obj['type'] === undefined || obj['type'] === null) {
|
|
515
|
+
authzenFail(`${at}/type`, 'is required');
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
const raw = authzenString(obj['type'], `${at}/type`);
|
|
519
|
+
if (raw.length < 1) {
|
|
520
|
+
authzenFail(`${at}/type`, 'must be at least 1 character(s); it is present but too short');
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
if (obj['id'] === undefined || obj['id'] === null) {
|
|
524
|
+
authzenFail(`${at}/id`, 'is required');
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
const raw = authzenString(obj['id'], `${at}/id`);
|
|
528
|
+
if (raw.length < 1) {
|
|
529
|
+
authzenFail(`${at}/id`, 'must be at least 1 character(s); it is present but too short');
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (obj['properties'] === undefined || obj['properties'] === null) {
|
|
533
|
+
delete obj['properties'];
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
authzenObject(obj['properties'], `${at}/properties`);
|
|
537
|
+
}
|
|
538
|
+
return obj;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Validate an unknown value as AuthZENResponse, or throw naming the member at fault.
|
|
542
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
543
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
544
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
545
|
+
* decision.
|
|
546
|
+
*/
|
|
547
|
+
export function validateAuthZENResponse(value, at) {
|
|
548
|
+
const obj = authzenObject(value, at);
|
|
549
|
+
authzenNoExtraMembers(obj, at, ['decision', 'context']);
|
|
550
|
+
if (obj['decision'] === undefined || obj['decision'] === null) {
|
|
551
|
+
authzenFail(`${at}/decision`, 'is required');
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
authzenBoolean(obj['decision'], `${at}/decision`);
|
|
555
|
+
}
|
|
556
|
+
if (obj['context'] === undefined || obj['context'] === null) {
|
|
557
|
+
delete obj['context'];
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
obj['context'] = validateAuthZENResponseContext(obj['context'], `${at}/context`);
|
|
561
|
+
}
|
|
562
|
+
return obj;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Validate an unknown value as AuthZENResponseContext, or throw naming the member at
|
|
566
|
+
* fault. Unknown members are REFUSED rather than dropped: on the response path an
|
|
567
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
568
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
569
|
+
* decision.
|
|
570
|
+
*/
|
|
571
|
+
export function validateAuthZENResponseContext(value, at) {
|
|
572
|
+
const obj = authzenObject(value, at);
|
|
573
|
+
authzenNoExtraMembers(obj, at, [
|
|
574
|
+
'profile',
|
|
575
|
+
'state',
|
|
576
|
+
'category',
|
|
577
|
+
'reason',
|
|
578
|
+
'obligations',
|
|
579
|
+
'approval',
|
|
580
|
+
'decision_id',
|
|
581
|
+
'schema_version',
|
|
582
|
+
]);
|
|
583
|
+
if (obj['profile'] === undefined || obj['profile'] === null) {
|
|
584
|
+
authzenFail(`${at}/profile`, 'is required');
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
authzenString(obj['profile'], `${at}/profile`);
|
|
588
|
+
}
|
|
589
|
+
if (obj['state'] === undefined || obj['state'] === null) {
|
|
590
|
+
authzenFail(`${at}/state`, 'is required');
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
authzenString(obj['state'], `${at}/state`);
|
|
594
|
+
}
|
|
595
|
+
if (obj['category'] === undefined || obj['category'] === null) {
|
|
596
|
+
authzenFail(`${at}/category`, 'is required');
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
authzenString(obj['category'], `${at}/category`);
|
|
600
|
+
}
|
|
601
|
+
if (obj['reason'] === undefined || obj['reason'] === null) {
|
|
602
|
+
delete obj['reason'];
|
|
603
|
+
}
|
|
604
|
+
else {
|
|
605
|
+
authzenString(obj['reason'], `${at}/reason`);
|
|
606
|
+
}
|
|
607
|
+
if (obj['obligations'] === undefined || obj['obligations'] === null) {
|
|
608
|
+
delete obj['obligations'];
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
const items = authzenArray(obj['obligations'], `${at}/obligations`);
|
|
612
|
+
obj['obligations'] = items.map((item, index) => validateAuthZENObligation(item, `${`${at}/obligations`}/${index}`));
|
|
613
|
+
}
|
|
614
|
+
if (obj['approval'] === undefined || obj['approval'] === null) {
|
|
615
|
+
delete obj['approval'];
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
obj['approval'] = validateAuthZENApprovalRequirement(obj['approval'], `${at}/approval`);
|
|
619
|
+
}
|
|
620
|
+
if (obj['decision_id'] === undefined || obj['decision_id'] === null) {
|
|
621
|
+
authzenFail(`${at}/decision_id`, 'is required');
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
const raw = authzenString(obj['decision_id'], `${at}/decision_id`);
|
|
625
|
+
if (raw.length < 1) {
|
|
626
|
+
authzenFail(`${at}/decision_id`, 'must be at least 1 character(s); it is present but too short');
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (obj['schema_version'] === undefined || obj['schema_version'] === null) {
|
|
630
|
+
authzenFail(`${at}/schema_version`, 'is required');
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
const raw = authzenString(obj['schema_version'], `${at}/schema_version`);
|
|
634
|
+
if (raw.length < 1) {
|
|
635
|
+
authzenFail(`${at}/schema_version`, 'must be at least 1 character(s); it is present but too short');
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return obj;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Validate an unknown value as AuthZENSubject, or throw naming the member at fault.
|
|
642
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
643
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
644
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
645
|
+
* decision.
|
|
646
|
+
*/
|
|
647
|
+
export function validateAuthZENSubject(value, at) {
|
|
648
|
+
const obj = authzenObject(value, at);
|
|
649
|
+
authzenNoExtraMembers(obj, at, ['type', 'id', 'properties']);
|
|
650
|
+
if (obj['type'] === undefined || obj['type'] === null) {
|
|
651
|
+
authzenFail(`${at}/type`, 'is required');
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
const raw = authzenString(obj['type'], `${at}/type`);
|
|
655
|
+
if (raw.length < 1) {
|
|
656
|
+
authzenFail(`${at}/type`, 'must be at least 1 character(s); it is present but too short');
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (obj['id'] === undefined || obj['id'] === null) {
|
|
660
|
+
authzenFail(`${at}/id`, 'is required');
|
|
661
|
+
}
|
|
662
|
+
else {
|
|
663
|
+
const raw = authzenString(obj['id'], `${at}/id`);
|
|
664
|
+
if (raw.length < 1) {
|
|
665
|
+
authzenFail(`${at}/id`, 'must be at least 1 character(s); it is present but too short');
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (obj['properties'] === undefined || obj['properties'] === null) {
|
|
669
|
+
delete obj['properties'];
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
authzenObject(obj['properties'], `${at}/properties`);
|
|
673
|
+
}
|
|
674
|
+
return obj;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Validate an unknown value as AuthZENIdentifier, or throw naming the member at fault.
|
|
678
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
679
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
680
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
681
|
+
* decision.
|
|
682
|
+
*/
|
|
683
|
+
export function validateAuthZENIdentifier(value, at) {
|
|
684
|
+
const obj = authzenObject(value, at);
|
|
685
|
+
authzenNoExtraMembers(obj, at, ['kind', 'type', 'qualifier', 'local']);
|
|
686
|
+
if (obj['kind'] === undefined || obj['kind'] === null) {
|
|
687
|
+
authzenFail(`${at}/kind`, 'is required');
|
|
688
|
+
}
|
|
689
|
+
else {
|
|
690
|
+
authzenString(obj['kind'], `${at}/kind`);
|
|
691
|
+
}
|
|
692
|
+
if (obj['type'] === undefined || obj['type'] === null) {
|
|
693
|
+
authzenFail(`${at}/type`, 'is required');
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
authzenString(obj['type'], `${at}/type`);
|
|
697
|
+
}
|
|
698
|
+
if (obj['qualifier'] === undefined || obj['qualifier'] === null) {
|
|
699
|
+
delete obj['qualifier'];
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
authzenString(obj['qualifier'], `${at}/qualifier`);
|
|
703
|
+
}
|
|
704
|
+
if (obj['local'] === undefined || obj['local'] === null) {
|
|
705
|
+
authzenFail(`${at}/local`, 'is required');
|
|
706
|
+
}
|
|
707
|
+
else {
|
|
708
|
+
const raw = authzenString(obj['local'], `${at}/local`);
|
|
709
|
+
if (raw.length < 1) {
|
|
710
|
+
authzenFail(`${at}/local`, 'must be at least 1 character(s); it is present but too short');
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return obj;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Validate an unknown value as AuthZENObligation, or throw naming the member at fault.
|
|
717
|
+
* Unknown members are REFUSED rather than dropped: on the response path an
|
|
718
|
+
* unrecognised member is a server speaking a profile this build does not understand,
|
|
719
|
+
* and quietly ignoring it would mean acting on a partial reading of an authorization
|
|
720
|
+
* decision.
|
|
721
|
+
*/
|
|
722
|
+
export function validateAuthZENObligation(value, at) {
|
|
723
|
+
const obj = authzenObject(value, at);
|
|
724
|
+
authzenNoExtraMembers(obj, at, [
|
|
725
|
+
'type',
|
|
726
|
+
'target',
|
|
727
|
+
'params',
|
|
728
|
+
'mandatory',
|
|
729
|
+
'source_policy',
|
|
730
|
+
'schema_version',
|
|
731
|
+
]);
|
|
732
|
+
if (obj['type'] === undefined || obj['type'] === null) {
|
|
733
|
+
authzenFail(`${at}/type`, 'is required');
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
authzenString(obj['type'], `${at}/type`);
|
|
737
|
+
}
|
|
738
|
+
if (obj['target'] === undefined || obj['target'] === null) {
|
|
739
|
+
delete obj['target'];
|
|
740
|
+
}
|
|
741
|
+
else {
|
|
742
|
+
const raw = authzenString(obj['target'], `${at}/target`);
|
|
743
|
+
if (raw.length < 1) {
|
|
744
|
+
authzenFail(`${at}/target`, 'must be at least 1 character(s); it is present but too short');
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
if (obj['params'] === undefined || obj['params'] === null) {
|
|
748
|
+
delete obj['params'];
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
const entries = authzenObject(obj['params'], `${at}/params`);
|
|
752
|
+
Object.keys(entries).forEach(key => {
|
|
753
|
+
authzenString(entries[key], `${`${at}/params`}/${key}`);
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
if (obj['mandatory'] === undefined || obj['mandatory'] === null) {
|
|
757
|
+
authzenFail(`${at}/mandatory`, 'is required');
|
|
758
|
+
}
|
|
759
|
+
else {
|
|
760
|
+
authzenBoolean(obj['mandatory'], `${at}/mandatory`);
|
|
761
|
+
}
|
|
762
|
+
if (obj['source_policy'] === undefined || obj['source_policy'] === null) {
|
|
763
|
+
authzenFail(`${at}/source_policy`, 'is required');
|
|
764
|
+
}
|
|
765
|
+
else {
|
|
766
|
+
const raw = authzenString(obj['source_policy'], `${at}/source_policy`);
|
|
767
|
+
if (raw.length < 1) {
|
|
768
|
+
authzenFail(`${at}/source_policy`, 'must be at least 1 character(s); it is present but too short');
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
if (obj['schema_version'] === undefined || obj['schema_version'] === null) {
|
|
772
|
+
authzenFail(`${at}/schema_version`, 'is required');
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
authzenInteger(obj['schema_version'], `${at}/schema_version`);
|
|
776
|
+
}
|
|
777
|
+
return obj;
|
|
778
|
+
}
|
|
779
|
+
//# sourceMappingURL=authzen.gen.js.map
|