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