@spinajs/rbac-http 2.0.491 → 2.0.494

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 CHANGED
@@ -1,11 +1,11 @@
1
- # `rbac-http`
2
-
3
- > TODO: description
4
-
5
- ## Usage
6
-
7
- ```
8
- const rbacHttp = require('rbac-http');
9
-
10
- // TODO: DEMONSTRATE API
11
- ```
1
+ # `rbac-http`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const rbacHttp = require('rbac-http');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,374 @@
1
+ /**
2
+ * One metadata row as dehydrated onto the wire.
3
+ *
4
+ * `Value` is a string regardless of `Type`: the column stores text and `Type`
5
+ * says how to read it. A client that wants the decoded value decodes it itself.
6
+ */
7
+ export declare const UserMetadataEntrySchema: {
8
+ $schema: string;
9
+ title: string;
10
+ type: string;
11
+ properties: {
12
+ Id: {
13
+ type: string;
14
+ };
15
+ Key: {
16
+ type: string;
17
+ };
18
+ Type: {
19
+ type: string;
20
+ enum: string[];
21
+ };
22
+ Value: {
23
+ type: string;
24
+ nullable: boolean;
25
+ };
26
+ };
27
+ };
28
+ /** `IUserWithGrants` — the payload a completed login or 2FA verification returns. */
29
+ export declare const UserWithGrantsSchema: {
30
+ $schema: string;
31
+ title: string;
32
+ type: string;
33
+ properties: {
34
+ ActiveRole: {
35
+ type: string;
36
+ description: string;
37
+ };
38
+ Grants: {
39
+ readonly type: "object";
40
+ readonly description: string;
41
+ readonly properties: {
42
+ readonly $extend: {
43
+ readonly type: "array";
44
+ readonly items: {
45
+ readonly type: "string";
46
+ };
47
+ readonly description: "Roles this one inherits from. Sits alongside the resources, and is not one.";
48
+ };
49
+ };
50
+ readonly additionalProperties: {
51
+ readonly type: "object";
52
+ readonly description: "One resource's permissions, keyed 'action:possession' (e.g. 'read:any')";
53
+ readonly additionalProperties: {
54
+ readonly type: "array";
55
+ readonly items: {
56
+ readonly type: "string";
57
+ };
58
+ };
59
+ };
60
+ };
61
+ Uuid: {
62
+ readonly type: "string";
63
+ };
64
+ Email: {
65
+ readonly type: "string";
66
+ readonly format: "email";
67
+ };
68
+ Login: {
69
+ readonly type: "string";
70
+ };
71
+ Role: {
72
+ readonly type: "array";
73
+ readonly items: {
74
+ readonly type: "string";
75
+ };
76
+ readonly description: "Every role assigned to the user — the set /auth/active-role may switch between";
77
+ };
78
+ IsActive: {
79
+ readonly type: "integer";
80
+ readonly description: "1 when the account is active";
81
+ };
82
+ CreatedAt: {
83
+ readonly type: "string";
84
+ readonly format: "date-time";
85
+ };
86
+ RegisteredAt: {
87
+ readonly type: "string";
88
+ readonly format: "date-time";
89
+ readonly nullable: true;
90
+ };
91
+ DeletedAt: {
92
+ readonly type: "string";
93
+ readonly format: "date-time";
94
+ readonly nullable: true;
95
+ };
96
+ LastLoginAt: {
97
+ readonly type: "string";
98
+ readonly format: "date-time";
99
+ readonly nullable: true;
100
+ };
101
+ Metadata: {
102
+ readonly type: "array";
103
+ readonly items: {
104
+ readonly description: "IUserMetadataEntry";
105
+ };
106
+ };
107
+ };
108
+ required: string[];
109
+ };
110
+ /**
111
+ * `ITwoFactorAuthRequired` — password accepted, TOTP still owed.
112
+ *
113
+ * The flag is a plain boolean, not `const: true`. A single-value const becomes a
114
+ * one-member enum in the emitted spec, and an enum inside a `oneOf` arm is what
115
+ * makes generators reach for `Union["TheKey"]` — a key only one arm has. The
116
+ * discriminator is which key is PRESENT, which `required` already states.
117
+ */
118
+ export declare const TwoFactorAuthRequiredSchema: {
119
+ $schema: string;
120
+ title: string;
121
+ type: string;
122
+ properties: {
123
+ TwoFactorAuthRequired: {
124
+ type: string;
125
+ description: string;
126
+ };
127
+ };
128
+ required: string[];
129
+ };
130
+ /** `ITwoFactorInitRequired` — password accepted, enrolment owed before TOTP. */
131
+ export declare const TwoFactorInitRequiredSchema: {
132
+ $schema: string;
133
+ title: string;
134
+ type: string;
135
+ properties: {
136
+ TwoFactorInitRequired: {
137
+ type: string;
138
+ description: string;
139
+ };
140
+ };
141
+ required: string[];
142
+ };
143
+ /**
144
+ * `ILoginResponse` — the three shapes `/auth/login` can answer with.
145
+ *
146
+ * A discriminated union rather than one object with everything optional: the
147
+ * caller branches on which key is present, and a schema that makes all of them
148
+ * optional would validate a response carrying none.
149
+ */
150
+ export declare const LoginResponseSchema: {
151
+ $schema: string;
152
+ title: string;
153
+ oneOf: ({
154
+ $schema: string;
155
+ title: string;
156
+ type: string;
157
+ properties: {
158
+ ActiveRole: {
159
+ type: string;
160
+ description: string;
161
+ };
162
+ Grants: {
163
+ readonly type: "object";
164
+ readonly description: string;
165
+ readonly properties: {
166
+ readonly $extend: {
167
+ readonly type: "array";
168
+ readonly items: {
169
+ readonly type: "string";
170
+ };
171
+ readonly description: "Roles this one inherits from. Sits alongside the resources, and is not one.";
172
+ };
173
+ };
174
+ readonly additionalProperties: {
175
+ readonly type: "object";
176
+ readonly description: "One resource's permissions, keyed 'action:possession' (e.g. 'read:any')";
177
+ readonly additionalProperties: {
178
+ readonly type: "array";
179
+ readonly items: {
180
+ readonly type: "string";
181
+ };
182
+ };
183
+ };
184
+ };
185
+ Uuid: {
186
+ readonly type: "string";
187
+ };
188
+ Email: {
189
+ readonly type: "string";
190
+ readonly format: "email";
191
+ };
192
+ Login: {
193
+ readonly type: "string";
194
+ };
195
+ Role: {
196
+ readonly type: "array";
197
+ readonly items: {
198
+ readonly type: "string";
199
+ };
200
+ readonly description: "Every role assigned to the user — the set /auth/active-role may switch between";
201
+ };
202
+ IsActive: {
203
+ readonly type: "integer";
204
+ readonly description: "1 when the account is active";
205
+ };
206
+ CreatedAt: {
207
+ readonly type: "string";
208
+ readonly format: "date-time";
209
+ };
210
+ RegisteredAt: {
211
+ readonly type: "string";
212
+ readonly format: "date-time";
213
+ readonly nullable: true;
214
+ };
215
+ DeletedAt: {
216
+ readonly type: "string";
217
+ readonly format: "date-time";
218
+ readonly nullable: true;
219
+ };
220
+ LastLoginAt: {
221
+ readonly type: "string";
222
+ readonly format: "date-time";
223
+ readonly nullable: true;
224
+ };
225
+ Metadata: {
226
+ readonly type: "array";
227
+ readonly items: {
228
+ readonly description: "IUserMetadataEntry";
229
+ };
230
+ };
231
+ };
232
+ required: string[];
233
+ } | {
234
+ $schema: string;
235
+ title: string;
236
+ type: string;
237
+ properties: {
238
+ TwoFactorAuthRequired: {
239
+ type: string;
240
+ description: string;
241
+ };
242
+ };
243
+ required: string[];
244
+ } | {
245
+ $schema: string;
246
+ title: string;
247
+ type: string;
248
+ properties: {
249
+ TwoFactorInitRequired: {
250
+ type: string;
251
+ description: string;
252
+ };
253
+ };
254
+ required: string[];
255
+ })[];
256
+ };
257
+ /** `IActiveRoleResponse` — what both `/auth/active-role` operations answer with. */
258
+ export declare const ActiveRoleResponseSchema: {
259
+ $schema: string;
260
+ title: string;
261
+ type: string;
262
+ properties: {
263
+ ActiveRole: {
264
+ type: string;
265
+ description: string;
266
+ };
267
+ Grants: {
268
+ readonly type: "object";
269
+ readonly description: string;
270
+ readonly properties: {
271
+ readonly $extend: {
272
+ readonly type: "array";
273
+ readonly items: {
274
+ readonly type: "string";
275
+ };
276
+ readonly description: "Roles this one inherits from. Sits alongside the resources, and is not one.";
277
+ };
278
+ };
279
+ readonly additionalProperties: {
280
+ readonly type: "object";
281
+ readonly description: "One resource's permissions, keyed 'action:possession' (e.g. 'read:any')";
282
+ readonly additionalProperties: {
283
+ readonly type: "array";
284
+ readonly items: {
285
+ readonly type: "string";
286
+ };
287
+ };
288
+ };
289
+ };
290
+ };
291
+ };
292
+ /**
293
+ * `IWhoamiResponse` — `/auth/whoami`.
294
+ *
295
+ * The user's own columns plus the two fields the session contributes. It is NOT
296
+ * the `User` ORM model, which is what this endpoint used to be documented as:
297
+ * that model knows nothing of `ActiveRole` or `Authorized` — the two fields a
298
+ * client needs most here — and does carry `Password`.
299
+ */
300
+ export declare const WhoamiResponseSchema: {
301
+ $schema: string;
302
+ title: string;
303
+ type: string;
304
+ properties: {
305
+ ActiveRole: {
306
+ type: string;
307
+ description: string;
308
+ };
309
+ Authorized: {
310
+ type: string;
311
+ description: string;
312
+ };
313
+ Uuid: {
314
+ readonly type: "string";
315
+ };
316
+ Email: {
317
+ readonly type: "string";
318
+ readonly format: "email";
319
+ };
320
+ Login: {
321
+ readonly type: "string";
322
+ };
323
+ Role: {
324
+ readonly type: "array";
325
+ readonly items: {
326
+ readonly type: "string";
327
+ };
328
+ readonly description: "Every role assigned to the user — the set /auth/active-role may switch between";
329
+ };
330
+ IsActive: {
331
+ readonly type: "integer";
332
+ readonly description: "1 when the account is active";
333
+ };
334
+ CreatedAt: {
335
+ readonly type: "string";
336
+ readonly format: "date-time";
337
+ };
338
+ RegisteredAt: {
339
+ readonly type: "string";
340
+ readonly format: "date-time";
341
+ readonly nullable: true;
342
+ };
343
+ DeletedAt: {
344
+ readonly type: "string";
345
+ readonly format: "date-time";
346
+ readonly nullable: true;
347
+ };
348
+ LastLoginAt: {
349
+ readonly type: "string";
350
+ readonly format: "date-time";
351
+ readonly nullable: true;
352
+ };
353
+ Metadata: {
354
+ readonly type: "array";
355
+ readonly items: {
356
+ readonly description: "IUserMetadataEntry";
357
+ };
358
+ };
359
+ };
360
+ required: string[];
361
+ };
362
+ /** `IEnable2faResponse` — the OTP provisioning URI from `/auth/2fa/setup`. */
363
+ export declare const Enable2faResponseSchema: {
364
+ $schema: string;
365
+ title: string;
366
+ type: string;
367
+ properties: {
368
+ otp: {
369
+ type: string;
370
+ description: string;
371
+ };
372
+ };
373
+ };
374
+ //# sourceMappingURL=auth-responses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-responses.d.ts","sourceRoot":"","sources":["../../../src/dto/auth-responses.ts"],"names":[],"mappings":"AA6CA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;CAanC,CAAC;AA0FF,qFAAqF;AACrF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAahC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;CAWvC,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,2BAA2B;;;;;;;;;;;CAWvC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAO/B,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQpC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBhC,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB;;;;;;;;;;CAUnC,CAAC"}
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Enable2faResponseSchema = exports.WhoamiResponseSchema = exports.ActiveRoleResponseSchema = exports.LoginResponseSchema = exports.TwoFactorInitRequiredSchema = exports.TwoFactorAuthRequiredSchema = exports.UserWithGrantsSchema = exports.UserMetadataEntrySchema = void 0;
4
+ const di_1 = require("@spinajs/di");
5
+ /**
6
+ * JSON schemas for the auth endpoints' RESPONSE bodies.
7
+ *
8
+ * ---------------------------------------------------------------------------
9
+ * Why this file exists
10
+ * ---------------------------------------------------------------------------
11
+ * The auth controllers already annotate their returns with the interface names
12
+ * from `interfaces.ts` (`@returns {ILoginResponse}`, `{IActiveRoleResponse}`,
13
+ * …). Those annotations resolved to nothing: the swagger builder asks its
14
+ * `SchemaProvider`s for a schema by name, no provider knows a plain TypeScript
15
+ * interface, and `inferSchemaFromString` then falls back to
16
+ * `{ type: 'object', description: '<name>' }` — an object with no properties.
17
+ *
18
+ * The published spec therefore described `/auth/login`, `/auth/2fa/verify` and
19
+ * both `/auth/active-role` operations as returning an empty object. Generated
20
+ * clients believed it: every one of those responses typed as `object`, and
21
+ * codegen that builds models from response schemas had nothing to build from.
22
+ *
23
+ * Registering the schemas under the SAME names the annotations already use is
24
+ * what makes them resolve — no controller annotation changes, and the component
25
+ * names in the spec are the ones the code has always claimed.
26
+ *
27
+ * ---------------------------------------------------------------------------
28
+ * Why raw registration and not `@Schema`
29
+ * ---------------------------------------------------------------------------
30
+ * `@Schema` is sugar for exactly the call below, keyed on the decorated class's
31
+ * name. Using it here would mean declaring classes called `ILoginResponse` and
32
+ * friends purely to carry a name — and they would collide with the interfaces of
33
+ * that name this package already exports. These describe responses; there is
34
+ * nothing to construct.
35
+ *
36
+ * ---------------------------------------------------------------------------
37
+ * Keep in sync with `interfaces.ts`
38
+ * ---------------------------------------------------------------------------
39
+ * The schemas below describe what the endpoints really put on the wire, which is
40
+ * what a client validator has to accept. Where that differs from the interface,
41
+ * the wire wins and the difference is called out in a comment.
42
+ */
43
+ /** `format: date-time` as the backend emits it — `dateTimeFormat: 'iso'`, offset included. */
44
+ const dateTime = { type: 'string', format: 'date-time' };
45
+ const nullableDateTime = { type: 'string', format: 'date-time', nullable: true };
46
+ /**
47
+ * One metadata row as dehydrated onto the wire.
48
+ *
49
+ * `Value` is a string regardless of `Type`: the column stores text and `Type`
50
+ * says how to read it. A client that wants the decoded value decodes it itself.
51
+ */
52
+ exports.UserMetadataEntrySchema = {
53
+ $schema: 'http://json-schema.org/draft-07/schema#',
54
+ title: 'User metadata entry',
55
+ type: 'object',
56
+ properties: {
57
+ Id: { type: 'integer' },
58
+ Key: { type: 'string' },
59
+ Type: {
60
+ type: 'string',
61
+ enum: ['number', 'float', 'string', 'json', 'boolean', 'datetime'],
62
+ },
63
+ Value: { type: 'string', nullable: true },
64
+ },
65
+ };
66
+ /**
67
+ * A reference to the entry schema above, by the tag the builder resolves.
68
+ *
69
+ * `expandNamedSchemas` turns any node whose `description` names a registered
70
+ * schema into a `$ref` to that component — this is how the builder expresses a
71
+ * reference, and it is worth using rather than inlining the object three times.
72
+ *
73
+ * Not merely tidier: the metadata entry carries an enum, and an enum inline
74
+ * inside a `oneOf` arm (which `ILoginResponse` is) makes generators emit type
75
+ * references that index the union by a key only one arm has. Giving the entry
76
+ * its own component takes the enum out of the union entirely.
77
+ */
78
+ const userMetadataEntryRef = { description: 'IUserMetadataEntry' };
79
+ /**
80
+ * The user's own columns, as `dehydrateWithRelations({ dateTimeFormat: 'iso' })`
81
+ * produces them.
82
+ *
83
+ * `Password` is deliberately absent. It is a column on the ORM model, so any
84
+ * endpoint documented as returning the model advertises it as part of the
85
+ * response — it is never actually sent, and a spec must not say otherwise.
86
+ *
87
+ * `IsActive` is an integer, not a boolean: the column is a tinyint and the
88
+ * driver hands back 0/1.
89
+ */
90
+ const userProperties = {
91
+ Uuid: { type: 'string' },
92
+ Email: { type: 'string', format: 'email' },
93
+ Login: { type: 'string' },
94
+ Role: {
95
+ type: 'array',
96
+ items: { type: 'string' },
97
+ description: 'Every role assigned to the user — the set /auth/active-role may switch between',
98
+ },
99
+ IsActive: { type: 'integer', description: '1 when the account is active' },
100
+ CreatedAt: dateTime,
101
+ RegisteredAt: nullableDateTime,
102
+ DeletedAt: nullableDateTime,
103
+ LastLoginAt: nullableDateTime,
104
+ Metadata: { type: 'array', items: userMetadataEntryRef },
105
+ };
106
+ /**
107
+ * `required` on a RESPONSE, kept to the bare minimum on purpose.
108
+ *
109
+ * A response schema describes what a client must ACCEPT, not what it may send,
110
+ * and `required` there is a promise a client validator will enforce — one this
111
+ * codebase has already been bitten by, when response components were built from
112
+ * the write contract and `User.Password` came out `required`. Every ordinary row
113
+ * then failed validation. Response components are built without `required` for
114
+ * that reason, and hand-written ones have no business reinstating it.
115
+ *
116
+ * The practical edge: a client generated from this spec and deployed before the
117
+ * backend that fills a new field would reject every response outright, instead of
118
+ * seeing the field missing and saying so.
119
+ *
120
+ * `Uuid` is the one exception, and it is structural rather than a data guarantee:
121
+ * `ILoginResponse` is a union, and an arm with nothing required matches any
122
+ * object at all — including the two-factor replies, which would then never reach
123
+ * their own arms.
124
+ */
125
+ const USER_REQUIRED = ['Uuid'];
126
+ /**
127
+ * Flattened RBAC grants: resource → action → permission descriptor.
128
+ *
129
+ * The resource and action keys are data, so the schema can only describe the
130
+ * shape two levels down. `additionalProperties` carries it.
131
+ */
132
+ const grantsMap = {
133
+ type: 'object',
134
+ description: "Resolved grants for the active role, in accesscontrol's own format: " +
135
+ "resource → 'action:possession' → attributes. Feed it back into new AccessControl().",
136
+ properties: {
137
+ $extend: {
138
+ type: 'array',
139
+ items: { type: 'string' },
140
+ description: 'Roles this one inherits from. Sits alongside the resources, and is not one.',
141
+ },
142
+ },
143
+ additionalProperties: {
144
+ type: 'object',
145
+ description: "One resource's permissions, keyed 'action:possession' (e.g. 'read:any')",
146
+ additionalProperties: { type: 'array', items: { type: 'string' } },
147
+ },
148
+ };
149
+ /** `IUserWithGrants` — the payload a completed login or 2FA verification returns. */
150
+ exports.UserWithGrantsSchema = {
151
+ $schema: 'http://json-schema.org/draft-07/schema#',
152
+ title: 'User with grants',
153
+ type: 'object',
154
+ properties: {
155
+ ...userProperties,
156
+ ActiveRole: {
157
+ type: 'string',
158
+ description: 'Role whose grants are in effect; defaults to Role[0] at login',
159
+ },
160
+ Grants: grantsMap,
161
+ },
162
+ required: USER_REQUIRED,
163
+ };
164
+ /**
165
+ * `ITwoFactorAuthRequired` — password accepted, TOTP still owed.
166
+ *
167
+ * The flag is a plain boolean, not `const: true`. A single-value const becomes a
168
+ * one-member enum in the emitted spec, and an enum inside a `oneOf` arm is what
169
+ * makes generators reach for `Union["TheKey"]` — a key only one arm has. The
170
+ * discriminator is which key is PRESENT, which `required` already states.
171
+ */
172
+ exports.TwoFactorAuthRequiredSchema = {
173
+ $schema: 'http://json-schema.org/draft-07/schema#',
174
+ title: 'Two-factor verification required',
175
+ type: 'object',
176
+ properties: {
177
+ TwoFactorAuthRequired: {
178
+ type: 'boolean',
179
+ description: 'Always true; the session is parked awaiting a TOTP code',
180
+ },
181
+ },
182
+ required: ['TwoFactorAuthRequired'],
183
+ };
184
+ /** `ITwoFactorInitRequired` — password accepted, enrolment owed before TOTP. */
185
+ exports.TwoFactorInitRequiredSchema = {
186
+ $schema: 'http://json-schema.org/draft-07/schema#',
187
+ title: 'Two-factor enrolment required',
188
+ type: 'object',
189
+ properties: {
190
+ TwoFactorInitRequired: {
191
+ type: 'boolean',
192
+ description: 'Always true; the user must enrol a TOTP device before continuing',
193
+ },
194
+ },
195
+ required: ['TwoFactorInitRequired'],
196
+ };
197
+ /**
198
+ * `ILoginResponse` — the three shapes `/auth/login` can answer with.
199
+ *
200
+ * A discriminated union rather than one object with everything optional: the
201
+ * caller branches on which key is present, and a schema that makes all of them
202
+ * optional would validate a response carrying none.
203
+ */
204
+ exports.LoginResponseSchema = {
205
+ $schema: 'http://json-schema.org/draft-07/schema#',
206
+ title: 'Login response',
207
+ // Two-factor arms first. A validator walks the arms in order and takes the
208
+ // first that matches; the user arm requires only `Uuid` (see USER_REQUIRED),
209
+ // so putting it first would let it swallow a two-factor reply.
210
+ oneOf: [exports.TwoFactorAuthRequiredSchema, exports.TwoFactorInitRequiredSchema, exports.UserWithGrantsSchema],
211
+ };
212
+ /** `IActiveRoleResponse` — what both `/auth/active-role` operations answer with. */
213
+ exports.ActiveRoleResponseSchema = {
214
+ $schema: 'http://json-schema.org/draft-07/schema#',
215
+ title: 'Active role',
216
+ type: 'object',
217
+ properties: {
218
+ ActiveRole: { type: 'string', description: 'Role whose grants are now in effect' },
219
+ Grants: grantsMap,
220
+ },
221
+ };
222
+ /**
223
+ * `IWhoamiResponse` — `/auth/whoami`.
224
+ *
225
+ * The user's own columns plus the two fields the session contributes. It is NOT
226
+ * the `User` ORM model, which is what this endpoint used to be documented as:
227
+ * that model knows nothing of `ActiveRole` or `Authorized` — the two fields a
228
+ * client needs most here — and does carry `Password`.
229
+ */
230
+ exports.WhoamiResponseSchema = {
231
+ $schema: 'http://json-schema.org/draft-07/schema#',
232
+ title: 'Current session user',
233
+ type: 'object',
234
+ properties: {
235
+ ...userProperties,
236
+ ActiveRole: {
237
+ type: 'string',
238
+ description: 'Role whose grants are in effect for this session',
239
+ },
240
+ Authorized: {
241
+ type: 'boolean',
242
+ description: 'False while the session has passed the password step but still owes 2FA. ' +
243
+ 'Absent on sessions minted before this field existed, which were fully authorized.',
244
+ },
245
+ },
246
+ required: USER_REQUIRED,
247
+ };
248
+ /** `IEnable2faResponse` — the OTP provisioning URI from `/auth/2fa/setup`. */
249
+ exports.Enable2faResponseSchema = {
250
+ $schema: 'http://json-schema.org/draft-07/schema#',
251
+ title: 'Two-factor enrolment',
252
+ type: 'object',
253
+ properties: {
254
+ otp: {
255
+ type: 'string',
256
+ description: 'OTP provisioning URI to scan with an authenticator app',
257
+ },
258
+ },
259
+ };
260
+ /**
261
+ * Registers a schema under the name controllers reference it by.
262
+ *
263
+ * Same registry and same call `@Schema` makes, so `DtoSchemaProvider` resolves
264
+ * these exactly as it resolves a decorated DTO.
265
+ */
266
+ function registerResponseSchema(name, schema) {
267
+ di_1.DI.register(schema).asMapValue('__schemas__', name);
268
+ }
269
+ registerResponseSchema('IUserMetadataEntry', exports.UserMetadataEntrySchema);
270
+ // `/user/grants` and `/grants` answer with the map on its own.
271
+ registerResponseSchema('IGrantsMap', { $schema: 'http://json-schema.org/draft-07/schema#', title: 'Grants map', ...grantsMap });
272
+ registerResponseSchema('IUserWithGrants', exports.UserWithGrantsSchema);
273
+ registerResponseSchema('ITwoFactorAuthRequired', exports.TwoFactorAuthRequiredSchema);
274
+ registerResponseSchema('ITwoFactorInitRequired', exports.TwoFactorInitRequiredSchema);
275
+ registerResponseSchema('ILoginResponse', exports.LoginResponseSchema);
276
+ registerResponseSchema('IActiveRoleResponse', exports.ActiveRoleResponseSchema);
277
+ registerResponseSchema('IWhoamiResponse', exports.WhoamiResponseSchema);
278
+ registerResponseSchema('IEnable2faResponse', exports.Enable2faResponseSchema);
279
+ //# sourceMappingURL=auth-responses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-responses.js","sourceRoot":"","sources":["../../../src/dto/auth-responses.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,8FAA8F;AAC9F,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAW,CAAC;AAClE,MAAM,gBAAgB,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAW,CAAC;AAE1F;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG;IACrC,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,qBAAqB;IAC5B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QACvB,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACvB,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC;SACnE;QACD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC1C;CACF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,oBAAoB,GAAG,EAAE,WAAW,EAAE,oBAAoB,EAAW,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACxB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,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