@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 +11 -11
- package/lib/cjs/dto/auth-responses.d.ts +374 -0
- package/lib/cjs/dto/auth-responses.d.ts.map +1 -0
- package/lib/cjs/dto/auth-responses.js +279 -0
- package/lib/cjs/dto/auth-responses.js.map +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +6 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces.d.ts +36 -4
- package/lib/cjs/interfaces.d.ts.map +1 -1
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/mjs/dto/auth-responses.d.ts +374 -0
- package/lib/mjs/dto/auth-responses.d.ts.map +1 -0
- package/lib/mjs/dto/auth-responses.js +276 -0
- package/lib/mjs/dto/auth-responses.js.map +1 -0
- package/lib/mjs/index.d.ts +1 -0
- package/lib/mjs/index.d.ts.map +1 -1
- package/lib/mjs/index.js +6 -0
- package/lib/mjs/index.js.map +1 -1
- package/lib/mjs/interfaces.d.ts +36 -4
- package/lib/mjs/interfaces.d.ts.map +1 -1
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +71 -69
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { DI } from '@spinajs/di';
|
|
2
|
+
/**
|
|
3
|
+
* JSON schemas for the auth endpoints' RESPONSE bodies.
|
|
4
|
+
*
|
|
5
|
+
* ---------------------------------------------------------------------------
|
|
6
|
+
* Why this file exists
|
|
7
|
+
* ---------------------------------------------------------------------------
|
|
8
|
+
* The auth controllers already annotate their returns with the interface names
|
|
9
|
+
* from `interfaces.ts` (`@returns {ILoginResponse}`, `{IActiveRoleResponse}`,
|
|
10
|
+
* …). Those annotations resolved to nothing: the swagger builder asks its
|
|
11
|
+
* `SchemaProvider`s for a schema by name, no provider knows a plain TypeScript
|
|
12
|
+
* interface, and `inferSchemaFromString` then falls back to
|
|
13
|
+
* `{ type: 'object', description: '<name>' }` — an object with no properties.
|
|
14
|
+
*
|
|
15
|
+
* The published spec therefore described `/auth/login`, `/auth/2fa/verify` and
|
|
16
|
+
* both `/auth/active-role` operations as returning an empty object. Generated
|
|
17
|
+
* clients believed it: every one of those responses typed as `object`, and
|
|
18
|
+
* codegen that builds models from response schemas had nothing to build from.
|
|
19
|
+
*
|
|
20
|
+
* Registering the schemas under the SAME names the annotations already use is
|
|
21
|
+
* what makes them resolve — no controller annotation changes, and the component
|
|
22
|
+
* names in the spec are the ones the code has always claimed.
|
|
23
|
+
*
|
|
24
|
+
* ---------------------------------------------------------------------------
|
|
25
|
+
* Why raw registration and not `@Schema`
|
|
26
|
+
* ---------------------------------------------------------------------------
|
|
27
|
+
* `@Schema` is sugar for exactly the call below, keyed on the decorated class's
|
|
28
|
+
* name. Using it here would mean declaring classes called `ILoginResponse` and
|
|
29
|
+
* friends purely to carry a name — and they would collide with the interfaces of
|
|
30
|
+
* that name this package already exports. These describe responses; there is
|
|
31
|
+
* nothing to construct.
|
|
32
|
+
*
|
|
33
|
+
* ---------------------------------------------------------------------------
|
|
34
|
+
* Keep in sync with `interfaces.ts`
|
|
35
|
+
* ---------------------------------------------------------------------------
|
|
36
|
+
* The schemas below describe what the endpoints really put on the wire, which is
|
|
37
|
+
* what a client validator has to accept. Where that differs from the interface,
|
|
38
|
+
* the wire wins and the difference is called out in a comment.
|
|
39
|
+
*/
|
|
40
|
+
/** `format: date-time` as the backend emits it — `dateTimeFormat: 'iso'`, offset included. */
|
|
41
|
+
const dateTime = { type: 'string', format: 'date-time' };
|
|
42
|
+
const nullableDateTime = { type: 'string', format: 'date-time', nullable: true };
|
|
43
|
+
/**
|
|
44
|
+
* One metadata row as dehydrated onto the wire.
|
|
45
|
+
*
|
|
46
|
+
* `Value` is a string regardless of `Type`: the column stores text and `Type`
|
|
47
|
+
* says how to read it. A client that wants the decoded value decodes it itself.
|
|
48
|
+
*/
|
|
49
|
+
export const UserMetadataEntrySchema = {
|
|
50
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
51
|
+
title: 'User metadata entry',
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
Id: { type: 'integer' },
|
|
55
|
+
Key: { type: 'string' },
|
|
56
|
+
Type: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
enum: ['number', 'float', 'string', 'json', 'boolean', 'datetime'],
|
|
59
|
+
},
|
|
60
|
+
Value: { type: 'string', nullable: true },
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* A reference to the entry schema above, by the tag the builder resolves.
|
|
65
|
+
*
|
|
66
|
+
* `expandNamedSchemas` turns any node whose `description` names a registered
|
|
67
|
+
* schema into a `$ref` to that component — this is how the builder expresses a
|
|
68
|
+
* reference, and it is worth using rather than inlining the object three times.
|
|
69
|
+
*
|
|
70
|
+
* Not merely tidier: the metadata entry carries an enum, and an enum inline
|
|
71
|
+
* inside a `oneOf` arm (which `ILoginResponse` is) makes generators emit type
|
|
72
|
+
* references that index the union by a key only one arm has. Giving the entry
|
|
73
|
+
* its own component takes the enum out of the union entirely.
|
|
74
|
+
*/
|
|
75
|
+
const userMetadataEntryRef = { description: 'IUserMetadataEntry' };
|
|
76
|
+
/**
|
|
77
|
+
* The user's own columns, as `dehydrateWithRelations({ dateTimeFormat: 'iso' })`
|
|
78
|
+
* produces them.
|
|
79
|
+
*
|
|
80
|
+
* `Password` is deliberately absent. It is a column on the ORM model, so any
|
|
81
|
+
* endpoint documented as returning the model advertises it as part of the
|
|
82
|
+
* response — it is never actually sent, and a spec must not say otherwise.
|
|
83
|
+
*
|
|
84
|
+
* `IsActive` is an integer, not a boolean: the column is a tinyint and the
|
|
85
|
+
* driver hands back 0/1.
|
|
86
|
+
*/
|
|
87
|
+
const userProperties = {
|
|
88
|
+
Uuid: { type: 'string' },
|
|
89
|
+
Email: { type: 'string', format: 'email' },
|
|
90
|
+
Login: { type: 'string' },
|
|
91
|
+
Role: {
|
|
92
|
+
type: 'array',
|
|
93
|
+
items: { type: 'string' },
|
|
94
|
+
description: 'Every role assigned to the user — the set /auth/active-role may switch between',
|
|
95
|
+
},
|
|
96
|
+
IsActive: { type: 'integer', description: '1 when the account is active' },
|
|
97
|
+
CreatedAt: dateTime,
|
|
98
|
+
RegisteredAt: nullableDateTime,
|
|
99
|
+
DeletedAt: nullableDateTime,
|
|
100
|
+
LastLoginAt: nullableDateTime,
|
|
101
|
+
Metadata: { type: 'array', items: userMetadataEntryRef },
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* `required` on a RESPONSE, kept to the bare minimum on purpose.
|
|
105
|
+
*
|
|
106
|
+
* A response schema describes what a client must ACCEPT, not what it may send,
|
|
107
|
+
* and `required` there is a promise a client validator will enforce — one this
|
|
108
|
+
* codebase has already been bitten by, when response components were built from
|
|
109
|
+
* the write contract and `User.Password` came out `required`. Every ordinary row
|
|
110
|
+
* then failed validation. Response components are built without `required` for
|
|
111
|
+
* that reason, and hand-written ones have no business reinstating it.
|
|
112
|
+
*
|
|
113
|
+
* The practical edge: a client generated from this spec and deployed before the
|
|
114
|
+
* backend that fills a new field would reject every response outright, instead of
|
|
115
|
+
* seeing the field missing and saying so.
|
|
116
|
+
*
|
|
117
|
+
* `Uuid` is the one exception, and it is structural rather than a data guarantee:
|
|
118
|
+
* `ILoginResponse` is a union, and an arm with nothing required matches any
|
|
119
|
+
* object at all — including the two-factor replies, which would then never reach
|
|
120
|
+
* their own arms.
|
|
121
|
+
*/
|
|
122
|
+
const USER_REQUIRED = ['Uuid'];
|
|
123
|
+
/**
|
|
124
|
+
* Flattened RBAC grants: resource → action → permission descriptor.
|
|
125
|
+
*
|
|
126
|
+
* The resource and action keys are data, so the schema can only describe the
|
|
127
|
+
* shape two levels down. `additionalProperties` carries it.
|
|
128
|
+
*/
|
|
129
|
+
const grantsMap = {
|
|
130
|
+
type: 'object',
|
|
131
|
+
description: "Resolved grants for the active role, in accesscontrol's own format: " +
|
|
132
|
+
"resource → 'action:possession' → attributes. Feed it back into new AccessControl().",
|
|
133
|
+
properties: {
|
|
134
|
+
$extend: {
|
|
135
|
+
type: 'array',
|
|
136
|
+
items: { type: 'string' },
|
|
137
|
+
description: 'Roles this one inherits from. Sits alongside the resources, and is not one.',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
additionalProperties: {
|
|
141
|
+
type: 'object',
|
|
142
|
+
description: "One resource's permissions, keyed 'action:possession' (e.g. 'read:any')",
|
|
143
|
+
additionalProperties: { type: 'array', items: { type: 'string' } },
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
/** `IUserWithGrants` — the payload a completed login or 2FA verification returns. */
|
|
147
|
+
export const UserWithGrantsSchema = {
|
|
148
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
149
|
+
title: 'User with grants',
|
|
150
|
+
type: 'object',
|
|
151
|
+
properties: {
|
|
152
|
+
...userProperties,
|
|
153
|
+
ActiveRole: {
|
|
154
|
+
type: 'string',
|
|
155
|
+
description: 'Role whose grants are in effect; defaults to Role[0] at login',
|
|
156
|
+
},
|
|
157
|
+
Grants: grantsMap,
|
|
158
|
+
},
|
|
159
|
+
required: USER_REQUIRED,
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* `ITwoFactorAuthRequired` — password accepted, TOTP still owed.
|
|
163
|
+
*
|
|
164
|
+
* The flag is a plain boolean, not `const: true`. A single-value const becomes a
|
|
165
|
+
* one-member enum in the emitted spec, and an enum inside a `oneOf` arm is what
|
|
166
|
+
* makes generators reach for `Union["TheKey"]` — a key only one arm has. The
|
|
167
|
+
* discriminator is which key is PRESENT, which `required` already states.
|
|
168
|
+
*/
|
|
169
|
+
export const TwoFactorAuthRequiredSchema = {
|
|
170
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
171
|
+
title: 'Two-factor verification required',
|
|
172
|
+
type: 'object',
|
|
173
|
+
properties: {
|
|
174
|
+
TwoFactorAuthRequired: {
|
|
175
|
+
type: 'boolean',
|
|
176
|
+
description: 'Always true; the session is parked awaiting a TOTP code',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
required: ['TwoFactorAuthRequired'],
|
|
180
|
+
};
|
|
181
|
+
/** `ITwoFactorInitRequired` — password accepted, enrolment owed before TOTP. */
|
|
182
|
+
export const TwoFactorInitRequiredSchema = {
|
|
183
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
184
|
+
title: 'Two-factor enrolment required',
|
|
185
|
+
type: 'object',
|
|
186
|
+
properties: {
|
|
187
|
+
TwoFactorInitRequired: {
|
|
188
|
+
type: 'boolean',
|
|
189
|
+
description: 'Always true; the user must enrol a TOTP device before continuing',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
required: ['TwoFactorInitRequired'],
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* `ILoginResponse` — the three shapes `/auth/login` can answer with.
|
|
196
|
+
*
|
|
197
|
+
* A discriminated union rather than one object with everything optional: the
|
|
198
|
+
* caller branches on which key is present, and a schema that makes all of them
|
|
199
|
+
* optional would validate a response carrying none.
|
|
200
|
+
*/
|
|
201
|
+
export const LoginResponseSchema = {
|
|
202
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
203
|
+
title: 'Login response',
|
|
204
|
+
// Two-factor arms first. A validator walks the arms in order and takes the
|
|
205
|
+
// first that matches; the user arm requires only `Uuid` (see USER_REQUIRED),
|
|
206
|
+
// so putting it first would let it swallow a two-factor reply.
|
|
207
|
+
oneOf: [TwoFactorAuthRequiredSchema, TwoFactorInitRequiredSchema, UserWithGrantsSchema],
|
|
208
|
+
};
|
|
209
|
+
/** `IActiveRoleResponse` — what both `/auth/active-role` operations answer with. */
|
|
210
|
+
export const ActiveRoleResponseSchema = {
|
|
211
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
212
|
+
title: 'Active role',
|
|
213
|
+
type: 'object',
|
|
214
|
+
properties: {
|
|
215
|
+
ActiveRole: { type: 'string', description: 'Role whose grants are now in effect' },
|
|
216
|
+
Grants: grantsMap,
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* `IWhoamiResponse` — `/auth/whoami`.
|
|
221
|
+
*
|
|
222
|
+
* The user's own columns plus the two fields the session contributes. It is NOT
|
|
223
|
+
* the `User` ORM model, which is what this endpoint used to be documented as:
|
|
224
|
+
* that model knows nothing of `ActiveRole` or `Authorized` — the two fields a
|
|
225
|
+
* client needs most here — and does carry `Password`.
|
|
226
|
+
*/
|
|
227
|
+
export const WhoamiResponseSchema = {
|
|
228
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
229
|
+
title: 'Current session user',
|
|
230
|
+
type: 'object',
|
|
231
|
+
properties: {
|
|
232
|
+
...userProperties,
|
|
233
|
+
ActiveRole: {
|
|
234
|
+
type: 'string',
|
|
235
|
+
description: 'Role whose grants are in effect for this session',
|
|
236
|
+
},
|
|
237
|
+
Authorized: {
|
|
238
|
+
type: 'boolean',
|
|
239
|
+
description: 'False while the session has passed the password step but still owes 2FA. ' +
|
|
240
|
+
'Absent on sessions minted before this field existed, which were fully authorized.',
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
required: USER_REQUIRED,
|
|
244
|
+
};
|
|
245
|
+
/** `IEnable2faResponse` — the OTP provisioning URI from `/auth/2fa/setup`. */
|
|
246
|
+
export const Enable2faResponseSchema = {
|
|
247
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
248
|
+
title: 'Two-factor enrolment',
|
|
249
|
+
type: 'object',
|
|
250
|
+
properties: {
|
|
251
|
+
otp: {
|
|
252
|
+
type: 'string',
|
|
253
|
+
description: 'OTP provisioning URI to scan with an authenticator app',
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Registers a schema under the name controllers reference it by.
|
|
259
|
+
*
|
|
260
|
+
* Same registry and same call `@Schema` makes, so `DtoSchemaProvider` resolves
|
|
261
|
+
* these exactly as it resolves a decorated DTO.
|
|
262
|
+
*/
|
|
263
|
+
function registerResponseSchema(name, schema) {
|
|
264
|
+
DI.register(schema).asMapValue('__schemas__', name);
|
|
265
|
+
}
|
|
266
|
+
registerResponseSchema('IUserMetadataEntry', UserMetadataEntrySchema);
|
|
267
|
+
// `/user/grants` and `/grants` answer with the map on its own.
|
|
268
|
+
registerResponseSchema('IGrantsMap', { $schema: 'http://json-schema.org/draft-07/schema#', title: 'Grants map', ...grantsMap });
|
|
269
|
+
registerResponseSchema('IUserWithGrants', UserWithGrantsSchema);
|
|
270
|
+
registerResponseSchema('ITwoFactorAuthRequired', TwoFactorAuthRequiredSchema);
|
|
271
|
+
registerResponseSchema('ITwoFactorInitRequired', TwoFactorInitRequiredSchema);
|
|
272
|
+
registerResponseSchema('ILoginResponse', LoginResponseSchema);
|
|
273
|
+
registerResponseSchema('IActiveRoleResponse', ActiveRoleResponseSchema);
|
|
274
|
+
registerResponseSchema('IWhoamiResponse', WhoamiResponseSchema);
|
|
275
|
+
registerResponseSchema('IEnable2faResponse', Enable2faResponseSchema);
|
|
276
|
+
//# 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,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;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,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C;AAEF;;;;;GAKG;AACH,SAAS,sBAAsB,CAAC,IAAY,EAAE,MAAc;IAC1D,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC;AAED,sBAAsB,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAC;AACtE,+DAA+D;AAC/D,sBAAsB,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,yCAAyC,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;AAChI,sBAAsB,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AAChE,sBAAsB,CAAC,wBAAwB,EAAE,2BAA2B,CAAC,CAAC;AAC9E,sBAAsB,CAAC,wBAAwB,EAAE,2BAA2B,CAAC,CAAC;AAC9E,sBAAsB,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;AAC9D,sBAAsB,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,CAAC;AACxE,sBAAsB,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AAChE,sBAAsB,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAC"}
|
package/lib/mjs/index.d.ts
CHANGED
package/lib/mjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,yBAAyB,CAAC;AAEjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAE/C,cAAc,mCAAmC,CAAC"}
|
package/lib/mjs/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// Side-effect import, not `export *`: this module registers the auth response
|
|
2
|
+
// schemas under the interface names the controllers annotate with, and the
|
|
3
|
+
// classes-free registration means there is nothing to re-export. Importing it
|
|
4
|
+
// here is what guarantees the registration has happened by the time the swagger
|
|
5
|
+
// builder asks for those names.
|
|
6
|
+
import './dto/auth-responses.js';
|
|
1
7
|
export * from './decorators.js';
|
|
2
8
|
export * from './interfaces.js';
|
|
3
9
|
export * from './middlewares.js';
|
package/lib/mjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAE/C,cAAc,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,gFAAgF;AAChF,gCAAgC;AAChC,OAAO,yBAAyB,CAAC;AAEjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAE/C,cAAc,mCAAmC,CAAC"}
|
package/lib/mjs/interfaces.d.ts
CHANGED
|
@@ -24,10 +24,23 @@ export interface IUserProfile {
|
|
|
24
24
|
export interface IUserData extends IUserProfile {
|
|
25
25
|
Metadata?: IUserMetadataEntry[];
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Flattened RBAC grants for a user: resource → `'action:possession'` → attributes.
|
|
29
|
+
*
|
|
30
|
+
* This is `accesscontrol`'s own grants format, which is what `_unwindGrants`
|
|
31
|
+
* produces and what a client feeds straight back into `new AccessControl(...)`.
|
|
32
|
+
* The attribute list is a bare `string[]` (`['*']`), NOT a `{ attributes }`
|
|
33
|
+
* wrapper — that wrapper is what this type used to claim, and it described no
|
|
34
|
+
* payload the API has ever sent.
|
|
35
|
+
*
|
|
36
|
+
* `$extend` rides at the same level as the resources when the role inherits from
|
|
37
|
+
* others; its value is the list of inherited role names, so a consumer that
|
|
38
|
+
* treats every key as a resource has to skip it.
|
|
39
|
+
*/
|
|
40
|
+
export type IGrantsMap = {
|
|
41
|
+
/** Roles this one inherits from — present only on a role that extends others. */
|
|
42
|
+
$extend?: string[];
|
|
43
|
+
} & Record<string, Record<string, string[]> | string[] | undefined>;
|
|
31
44
|
/** Successful authentication response — user profile merged with RBAC grants */
|
|
32
45
|
export interface IUserWithGrants extends IUserProfile {
|
|
33
46
|
/**
|
|
@@ -42,6 +55,25 @@ export interface IActiveRoleResponse {
|
|
|
42
55
|
ActiveRole: string;
|
|
43
56
|
Grants: IGrantsMap;
|
|
44
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Response for GET /auth/whoami — the session's user plus what the session
|
|
60
|
+
* itself knows about it.
|
|
61
|
+
*
|
|
62
|
+
* Not `IUserWithGrants`: whoami resolves no grants, because grants belong to the
|
|
63
|
+
* active role and /auth/active-role is what answers with them.
|
|
64
|
+
*/
|
|
65
|
+
export interface IWhoamiResponse extends IUserData {
|
|
66
|
+
/** Role whose grants are in effect for this session. */
|
|
67
|
+
ActiveRole: string;
|
|
68
|
+
/**
|
|
69
|
+
* False while the session has passed the password step but still owes 2FA.
|
|
70
|
+
*
|
|
71
|
+
* Absent on sessions minted before this field existed; those predate 2FA
|
|
72
|
+
* gating and were by definition fully authorized, which is why the endpoint
|
|
73
|
+
* defaults it to true rather than false.
|
|
74
|
+
*/
|
|
75
|
+
Authorized: boolean;
|
|
76
|
+
}
|
|
45
77
|
/** Response for /auth/impersonate when an impersonation has just been started or queried */
|
|
46
78
|
export interface IImpersonationResponse {
|
|
47
79
|
/** Target user (whose identity is now in effect) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAO/D,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IACtE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oFAAoF;AACpF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAA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,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAEvD;;;;OAIG;aACa,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAE3D;;;;;OAKG;aACa,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAClE;AAED,8BAAsB,mBAAmB;CAAG;AAE5C,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAmMA,MAAM,OAAgB,qBAAqB;CA0C1C;AAED,MAAM,OAAgB,mBAAmB;CAAG"}
|