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