@gleb216/warden-angular 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -2
- package/fesm2022/gleb216-warden-angular-contracts.mjs +0 -0
- package/fesm2022/gleb216-warden-angular.mjs +544 -0
- package/fesm2022/gleb216-warden-angular.mjs.map +1 -0
- package/package.json +37 -3
- package/types/gleb216-warden-angular-contracts.d.ts +361 -0
- package/types/gleb216-warden-angular-contracts.d.ts.map +1 -0
- package/types/gleb216-warden-angular.d.ts +552 -0
- package/types/gleb216-warden-angular.d.ts.map +1 -0
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { InjectionToken, Provider } from "@angular/core";
|
|
6
|
+
import { HttpInterceptorFn } from "@angular/common/http";
|
|
7
|
+
import { CanMatchFn } from "@angular/router";
|
|
8
|
+
interface WardenAngularConfig {
|
|
9
|
+
/** Base of the API of @gleb216/warden-nest, same origin: `/api`. */
|
|
10
|
+
apiBase: string;
|
|
11
|
+
/** Sign-in page of the application. */
|
|
12
|
+
loginPath: string;
|
|
13
|
+
/** Page shown instead of a route the user has no right to open. */
|
|
14
|
+
forbiddenPath: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const WARDEN_ANGULAR_CONFIG: InjectionToken<WardenAngularConfig>;
|
|
17
|
+
/**
|
|
18
|
+
* Called when the server refused an action the UI offered (403 `forbidden`), after the rights were re-read.
|
|
19
|
+
* The application shows its own message (texts and i18n stay in the application).
|
|
20
|
+
*/
|
|
21
|
+
export declare const WARDEN_ON_FORBIDDEN: InjectionToken<() => void>;
|
|
22
|
+
/** Overrides the defaults (`/api`, `/login`, `/forbidden`). */
|
|
23
|
+
export declare function provideWarden(config?: Partial<WardenAngularConfig>): Array<Provider>;
|
|
24
|
+
/** A calendar date without time and time zone: `'2026-10-25'`. Matches PostgreSQL `date`. */
|
|
25
|
+
type IsoDate = string;
|
|
26
|
+
/** A moment in UTC, ISO 8601: `'2026-10-25T11:03:11.123456+00:00'`. Matches PostgreSQL `timestamptz`. */
|
|
27
|
+
type IsoDateTime = string;
|
|
28
|
+
/** Machine codes of API errors; the client picks the user-facing text by the code. */
|
|
29
|
+
type WardenErrorCode = 'unauthenticated' | 'session_invalid' | 'forbidden' | 'invalid_credentials' | 'too_many_attempts' | 'origin_forbidden' | 'login_forbidden' | 'oidc_email_not_verified' | 'oidc_user_unknown' | 'oidc_failed' | 'validation_failed' | 'not_found' | 'duplicate' | 'email_taken' | 'last_login_method' | 'link_invalid' | 'internal_error';
|
|
30
|
+
/** Body of every error response. `code` may also be a domain-specific code raised by a DB function. */
|
|
31
|
+
interface ApiError {
|
|
32
|
+
statusCode: number;
|
|
33
|
+
code: WardenErrorCode | (string & {});
|
|
34
|
+
message: string;
|
|
35
|
+
/** Seconds until the next login attempt is allowed (`too_many_attempts` only). */
|
|
36
|
+
retryAfterSeconds?: number;
|
|
37
|
+
}
|
|
38
|
+
interface LoginRequestDto {
|
|
39
|
+
email: string;
|
|
40
|
+
password: string;
|
|
41
|
+
}
|
|
42
|
+
interface MeUserDto {
|
|
43
|
+
id: string;
|
|
44
|
+
email: string;
|
|
45
|
+
firstName: string | null;
|
|
46
|
+
secondName: string | null;
|
|
47
|
+
middleName: string | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Where the user has an action: everywhere, or on these nodes of the hierarchy and everything below them. For
|
|
51
|
+
* showing the interface only: the server checks every request.
|
|
52
|
+
*/
|
|
53
|
+
type PermissionScopeDto = {
|
|
54
|
+
action: string;
|
|
55
|
+
global: true;
|
|
56
|
+
} | {
|
|
57
|
+
action: string;
|
|
58
|
+
global: false;
|
|
59
|
+
entityIds: Array<string>;
|
|
60
|
+
};
|
|
61
|
+
interface MeDto {
|
|
62
|
+
user: MeUserDto;
|
|
63
|
+
/** Every action of the user (e.g. `'orders.read'`) with its scope, sorted by action. */
|
|
64
|
+
permissions: Array<PermissionScopeDto>;
|
|
65
|
+
}
|
|
66
|
+
interface AuthSessionDto extends MeDto {
|
|
67
|
+
/** Short-lived access token; keep it in memory only. */
|
|
68
|
+
accessToken: string;
|
|
69
|
+
accessExpiresAt: IsoDateTime;
|
|
70
|
+
}
|
|
71
|
+
interface AuthProviderDto {
|
|
72
|
+
id: string;
|
|
73
|
+
label: string;
|
|
74
|
+
}
|
|
75
|
+
interface LoginIdentityDto {
|
|
76
|
+
id: string;
|
|
77
|
+
provider: string;
|
|
78
|
+
email: string | null;
|
|
79
|
+
linkedAt: IsoDateTime;
|
|
80
|
+
lastLoginAt: IsoDateTime | null;
|
|
81
|
+
}
|
|
82
|
+
interface LoginMethodsDto {
|
|
83
|
+
hasPassword: boolean;
|
|
84
|
+
identities: Array<LoginIdentityDto>;
|
|
85
|
+
}
|
|
86
|
+
interface ChangePasswordDto {
|
|
87
|
+
/** Required when the user already has a password. */
|
|
88
|
+
currentPassword?: string;
|
|
89
|
+
newPassword: string;
|
|
90
|
+
}
|
|
91
|
+
/** Which users the administration list shows (specs/003-settings-users). */
|
|
92
|
+
type AdminUserState = 'all' | 'active' | 'blocked';
|
|
93
|
+
type AdminUserSort = 'createdAt' | 'name';
|
|
94
|
+
type SortDirection = 'asc' | 'desc';
|
|
95
|
+
/** Query of `GET /admin/users`; omitted fields take the defaults (all, createdAt desc, page 1, 25 per page). */
|
|
96
|
+
interface AdminUserListQuery {
|
|
97
|
+
search?: string;
|
|
98
|
+
state?: AdminUserState;
|
|
99
|
+
sort?: AdminUserSort;
|
|
100
|
+
direction?: SortDirection;
|
|
101
|
+
page?: number;
|
|
102
|
+
pageSize?: 10 | 25 | 50 | 100;
|
|
103
|
+
}
|
|
104
|
+
/** A user in the administration list: no password hash and no block reason. */
|
|
105
|
+
interface AdminUserRowDto {
|
|
106
|
+
id: string;
|
|
107
|
+
email: string;
|
|
108
|
+
firstName: string | null;
|
|
109
|
+
secondName: string | null;
|
|
110
|
+
middleName: string | null;
|
|
111
|
+
/** The system groups (without an owner organization), by name. */
|
|
112
|
+
groups: Array<AdminGroupNameDto>;
|
|
113
|
+
/** Ids of the linked login providers (`'google'`, `'microsoft'`). */
|
|
114
|
+
providers: Array<string>;
|
|
115
|
+
hasPassword: boolean;
|
|
116
|
+
isBlocked: boolean;
|
|
117
|
+
createdAt: IsoDateTime;
|
|
118
|
+
}
|
|
119
|
+
interface AdminUserListDto {
|
|
120
|
+
items: Array<AdminUserRowDto>;
|
|
121
|
+
/** Users matching the search and the state. */
|
|
122
|
+
total: number;
|
|
123
|
+
/** The page actually returned: the last one when a larger page was asked for. */
|
|
124
|
+
page: number;
|
|
125
|
+
pageSize: number;
|
|
126
|
+
/** Users matching the search, by state (without the state filter). */
|
|
127
|
+
counts: {
|
|
128
|
+
all: number;
|
|
129
|
+
active: number;
|
|
130
|
+
blocked: number;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/** Another user referred to by a record, e.g. who issued a grant. */
|
|
134
|
+
interface AdminUserRefDto {
|
|
135
|
+
id: string;
|
|
136
|
+
email: string | null;
|
|
137
|
+
firstName: string | null;
|
|
138
|
+
secondName: string | null;
|
|
139
|
+
isSystem: boolean;
|
|
140
|
+
}
|
|
141
|
+
/** Who blocked a user, when and why: the card only, the list has no reason (specs/007-user-block-password). */
|
|
142
|
+
interface AdminUserBlockDto {
|
|
143
|
+
at: IsoDateTime;
|
|
144
|
+
/** The author; null when that user no longer exists. */
|
|
145
|
+
by: AdminUserRefDto | null;
|
|
146
|
+
reason: string;
|
|
147
|
+
}
|
|
148
|
+
/** A user in the administration card: a row of the list plus the block details; `isBlocked === (block !== null)`. */
|
|
149
|
+
interface AdminUserDto extends AdminUserRowDto {
|
|
150
|
+
block: AdminUserBlockDto | null;
|
|
151
|
+
/** The last invitation of an active user without a password (specs/015); `null` — none. */
|
|
152
|
+
invitation: AdminInvitationStateDto | null;
|
|
153
|
+
}
|
|
154
|
+
/** Language of a letter (specs/014): the build of the interface the request came from. */
|
|
155
|
+
type MailLang = 'uk' | 'en';
|
|
156
|
+
/** State of a letter in the mail queue (specs/014) as the card shows it. */
|
|
157
|
+
interface MailStateDto {
|
|
158
|
+
status: 'pending' | 'sent' | 'failed' | 'disabled';
|
|
159
|
+
attempts: number;
|
|
160
|
+
}
|
|
161
|
+
/** The invitation of a user on the card (specs/015 data-model.md). */
|
|
162
|
+
interface AdminInvitationStateDto {
|
|
163
|
+
createdAt: IsoDateTime;
|
|
164
|
+
createdBy: {
|
|
165
|
+
id: string;
|
|
166
|
+
name: string;
|
|
167
|
+
} | null;
|
|
168
|
+
expiresAt: IsoDateTime;
|
|
169
|
+
expired: boolean;
|
|
170
|
+
/** `null` — no letter (removed after 30 days). */
|
|
171
|
+
mail: MailStateDto | null;
|
|
172
|
+
}
|
|
173
|
+
/** Body of `POST /admin/users` (specs/015). */
|
|
174
|
+
interface AdminUserCreateRequest {
|
|
175
|
+
email: string;
|
|
176
|
+
firstName?: string | null;
|
|
177
|
+
secondName?: string | null;
|
|
178
|
+
middleName?: string | null;
|
|
179
|
+
method: 'invite' | 'password';
|
|
180
|
+
/** For `password` only. */
|
|
181
|
+
password?: string;
|
|
182
|
+
lang?: MailLang;
|
|
183
|
+
}
|
|
184
|
+
/** A new invitation link: shown only in the response that created it. */
|
|
185
|
+
interface AdminInvitationLinkDto {
|
|
186
|
+
link: string;
|
|
187
|
+
expiresAt: IsoDateTime;
|
|
188
|
+
/** `false` — no letter was sent; the administrator passes the link on. */
|
|
189
|
+
mailEnabled: boolean;
|
|
190
|
+
}
|
|
191
|
+
/** The created user (core.user_json). */
|
|
192
|
+
interface AdminCreatedUserDto {
|
|
193
|
+
id: string;
|
|
194
|
+
email: string;
|
|
195
|
+
firstName: string | null;
|
|
196
|
+
secondName: string | null;
|
|
197
|
+
middleName: string | null;
|
|
198
|
+
hasPassword: boolean;
|
|
199
|
+
}
|
|
200
|
+
interface AdminUserCreateResponse {
|
|
201
|
+
user: AdminCreatedUserDto;
|
|
202
|
+
invitation: AdminInvitationLinkDto | null;
|
|
203
|
+
}
|
|
204
|
+
/** Body of `POST /admin/users/:id/invitation` (specs/015). */
|
|
205
|
+
interface AdminInvitationRequest {
|
|
206
|
+
lang?: MailLang;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Codes (`ApiError.code`) of the administration of users and groups (specs/005, 007, 008, 011): what the routes
|
|
210
|
+
* `/admin/users/…` and `/admin/groups/…` refuse with. The application gives each its text.
|
|
211
|
+
*/
|
|
212
|
+
type AdminErrorCode = 'not_found' | 'forbidden' | 'validation_failed' | 'system_user' | 'self_block' | 'self_password' | 'reason_required' | 'reason_too_long' | 'last_access_manager' | 'self_grant' | 'self_revoke' | 'grant_too_wide' | 'grant_subject_required' | 'action_not_in_catalog' | 'role_not_found' | 'name_required' | 'name_too_long' | 'description_too_long' | 'group_name_taken' | 'group_too_wide' | 'user_not_found' | 'email_taken' | 'has_password' | 'user_blocked' | 'invalid_arguments';
|
|
213
|
+
/** A system role for the page «Roles and actions» (specs/010-settings-roles). */
|
|
214
|
+
interface AdminRoleDto {
|
|
215
|
+
code: string;
|
|
216
|
+
title: string;
|
|
217
|
+
description: string | null;
|
|
218
|
+
/** Own actions of the role, sorted. */
|
|
219
|
+
actions: Array<string>;
|
|
220
|
+
/** Every action of the role with the included roles at any depth, sorted, without repeats. */
|
|
221
|
+
allActions: Array<string>;
|
|
222
|
+
/** Codes of the directly included roles, sorted. */
|
|
223
|
+
includes: Array<string>;
|
|
224
|
+
}
|
|
225
|
+
/** An action of the catalog with where it can be granted. */
|
|
226
|
+
interface AdminActionDto {
|
|
227
|
+
action: string;
|
|
228
|
+
grantScope: 'global' | 'node';
|
|
229
|
+
description: string | null;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Why a role or an action cannot be granted to this user or group now (specs/008-user-grants, 011); `global_only` —
|
|
233
|
+
* on a node of the hierarchy, while the subject holds an action granted only globally (specs/012).
|
|
234
|
+
*/
|
|
235
|
+
type AdminGrantOptionState = 'available' | 'granted' | 'wider' | 'global_only';
|
|
236
|
+
/** A role of the catalog for the grant dialog. */
|
|
237
|
+
interface AdminGrantRoleOptionDto {
|
|
238
|
+
code: string;
|
|
239
|
+
title: string;
|
|
240
|
+
description: string | null;
|
|
241
|
+
/** Every action of the role with the included roles, sorted. */
|
|
242
|
+
actions: Array<string>;
|
|
243
|
+
state: AdminGrantOptionState;
|
|
244
|
+
}
|
|
245
|
+
/** An action of the catalog for the grant dialog. */
|
|
246
|
+
interface AdminGrantActionOptionDto {
|
|
247
|
+
action: string;
|
|
248
|
+
description: string | null;
|
|
249
|
+
state: AdminGrantOptionState;
|
|
250
|
+
}
|
|
251
|
+
/** What the signed-in administrator can grant to the user or the group globally. */
|
|
252
|
+
interface AdminGrantOptionsDto {
|
|
253
|
+
roles: Array<AdminGrantRoleOptionDto>;
|
|
254
|
+
actions: Array<AdminGrantActionOptionDto>;
|
|
255
|
+
}
|
|
256
|
+
/** Body of `POST /admin/users/:id/grants` and `POST /admin/groups/:id/grants`: exactly one of the two. */
|
|
257
|
+
interface AdminGrantRequest {
|
|
258
|
+
role?: string;
|
|
259
|
+
action?: string;
|
|
260
|
+
}
|
|
261
|
+
/** Body of `POST /admin/users/:id/block`: the reason, 1–500 characters after trimming. */
|
|
262
|
+
interface AdminUserBlockRequest {
|
|
263
|
+
reason: string;
|
|
264
|
+
}
|
|
265
|
+
/** Body of `PUT /admin/users/:id/password`: the new password (at least 10 characters). */
|
|
266
|
+
interface AdminUserPasswordRequest {
|
|
267
|
+
password: string;
|
|
268
|
+
}
|
|
269
|
+
/** A global grant of a user (personal) or of a group: a role or an action. */
|
|
270
|
+
interface AdminGrantDto {
|
|
271
|
+
id: number;
|
|
272
|
+
kind: 'role' | 'action';
|
|
273
|
+
code: string;
|
|
274
|
+
title: string | null;
|
|
275
|
+
grantedAt: IsoDateTime;
|
|
276
|
+
/** `null` when the issuer is unknown. */
|
|
277
|
+
grantedBy: AdminUserRefDto | null;
|
|
278
|
+
}
|
|
279
|
+
/** A system group as a user refers to it (specs/011). */
|
|
280
|
+
interface AdminGroupNameDto {
|
|
281
|
+
id: string;
|
|
282
|
+
name: string;
|
|
283
|
+
}
|
|
284
|
+
/** A system group in the list of Settings › Groups (specs/011-settings-groups). */
|
|
285
|
+
interface AdminGroupRowDto {
|
|
286
|
+
id: string;
|
|
287
|
+
name: string;
|
|
288
|
+
description: string | null;
|
|
289
|
+
/** Always `null` on this page; the CLI lists groups of an organization with it. */
|
|
290
|
+
ownerEntityId: string | null;
|
|
291
|
+
/** The number of members. */
|
|
292
|
+
members: number;
|
|
293
|
+
/** Global grants of the group: roles first, then actions, by code. */
|
|
294
|
+
grants: Array<{
|
|
295
|
+
kind: 'role' | 'action';
|
|
296
|
+
code: string;
|
|
297
|
+
}>;
|
|
298
|
+
}
|
|
299
|
+
/** A group as creating or changing it answers. */
|
|
300
|
+
interface AdminGroupRefDto {
|
|
301
|
+
id: string;
|
|
302
|
+
name: string;
|
|
303
|
+
description: string | null;
|
|
304
|
+
ownerEntityId: string | null;
|
|
305
|
+
}
|
|
306
|
+
/** A member of a group. */
|
|
307
|
+
interface AdminGroupMemberDto {
|
|
308
|
+
id: string;
|
|
309
|
+
email: string;
|
|
310
|
+
firstName: string | null;
|
|
311
|
+
secondName: string | null;
|
|
312
|
+
middleName: string | null;
|
|
313
|
+
isBlocked: boolean;
|
|
314
|
+
addedAt: IsoDateTime;
|
|
315
|
+
}
|
|
316
|
+
/** A system group with its members; its grants come separately. */
|
|
317
|
+
interface AdminGroupDto {
|
|
318
|
+
id: string;
|
|
319
|
+
name: string;
|
|
320
|
+
description: string | null;
|
|
321
|
+
createdAt: IsoDateTime;
|
|
322
|
+
/** The signed-in administrator has every action of the grants of the group: may change the members and delete it. */
|
|
323
|
+
canManage: boolean;
|
|
324
|
+
/** By second name, then first name, then email. */
|
|
325
|
+
members: Array<AdminGroupMemberDto>;
|
|
326
|
+
}
|
|
327
|
+
/** Body of `POST /admin/groups` and `PATCH /admin/groups/:id`: name 1–100, description up to 500 after trimming. */
|
|
328
|
+
interface AdminGroupRequest {
|
|
329
|
+
name: string;
|
|
330
|
+
description?: string | null;
|
|
331
|
+
}
|
|
332
|
+
/** Body of `POST /admin/groups/:id/members`: the user found by `GET /admin/users/find` (specs/012 FR-024). */
|
|
333
|
+
interface AdminGroupMemberRequest {
|
|
334
|
+
userId: string;
|
|
335
|
+
}
|
|
336
|
+
/** A user found by the exact email before granting or adding to a group (`GET /admin/users/find`, specs/012 R5). */
|
|
337
|
+
interface UserLookupDto {
|
|
338
|
+
id: string;
|
|
339
|
+
name: string | null;
|
|
340
|
+
email: string;
|
|
341
|
+
isBlocked: boolean;
|
|
342
|
+
}
|
|
343
|
+
/** An effective action of a user with where it applies and where it comes from. */
|
|
344
|
+
interface AdminUserPermissionDto {
|
|
345
|
+
action: string;
|
|
346
|
+
title: string | null;
|
|
347
|
+
/** `null` — globally; otherwise the node of the hierarchy. */
|
|
348
|
+
entityId: string | null;
|
|
349
|
+
via: 'direct' | 'group';
|
|
350
|
+
group: string | null;
|
|
351
|
+
/** The role that was granted, when the action comes through a role. */
|
|
352
|
+
role: string | null;
|
|
353
|
+
/** From the granted role down to the role that holds the action; `[]` without a role. */
|
|
354
|
+
rolePath: Array<string>;
|
|
355
|
+
}
|
|
356
|
+
/** Kind of a one-time link (specs/015). */
|
|
357
|
+
type AuthLinkKind = 'invite' | 'reset';
|
|
358
|
+
/** Body of `POST /auth/link`: the secret from the fragment of the link. */
|
|
359
|
+
interface AuthLinkRequestDto {
|
|
360
|
+
kind: AuthLinkKind;
|
|
361
|
+
token: string;
|
|
362
|
+
}
|
|
363
|
+
/** A valid link: the email of its owner, shown read-only. */
|
|
364
|
+
interface AuthLinkDto {
|
|
365
|
+
email: string;
|
|
366
|
+
}
|
|
367
|
+
/** Body of `POST /auth/link/password`: answered like `/auth/login`. */
|
|
368
|
+
interface AuthLinkPasswordRequestDto extends AuthLinkRequestDto {
|
|
369
|
+
password: string;
|
|
370
|
+
}
|
|
371
|
+
/** `GET /auth/password-reset`: whether «Forgot password?» can send a letter. */
|
|
372
|
+
interface PasswordResetAvailabilityDto {
|
|
373
|
+
available: boolean;
|
|
374
|
+
}
|
|
375
|
+
/** Body of `POST /auth/password-reset`. */
|
|
376
|
+
interface PasswordResetRequestDto {
|
|
377
|
+
email: string;
|
|
378
|
+
lang?: MailLang;
|
|
379
|
+
}
|
|
380
|
+
/** HTTP calls of the login routes (specs/001-warden-nest contracts/http-api.md). The refresh cookie travels by itself. */
|
|
381
|
+
export declare class AuthApi {
|
|
382
|
+
#private;
|
|
383
|
+
login(request: LoginRequestDto): Promise<AuthSessionDto>;
|
|
384
|
+
refresh(): Promise<AuthSessionDto>;
|
|
385
|
+
/** The email of the owner of a valid one-time link (specs/015); `404 link_invalid` otherwise. */
|
|
386
|
+
checkLink(request: AuthLinkRequestDto): Promise<AuthLinkDto>;
|
|
387
|
+
/** Sets the password by a one-time link and signs in, like `login`. */
|
|
388
|
+
setPasswordByLink(request: AuthLinkPasswordRequestDto): Promise<AuthSessionDto>;
|
|
389
|
+
/** Whether «Forgot password?» can send a letter. */
|
|
390
|
+
passwordResetAvailability(): Promise<PasswordResetAvailabilityDto>;
|
|
391
|
+
/** Asks for a reset letter; the answer is the same for any address (`429 too_many_attempts` over the limit). */
|
|
392
|
+
requestPasswordReset(request: PasswordResetRequestDto): Promise<void>;
|
|
393
|
+
logout(): Promise<void>;
|
|
394
|
+
me(): Promise<MeDto>;
|
|
395
|
+
providers(): Promise<Array<AuthProviderDto>>;
|
|
396
|
+
/** Where the browser goes to sign in at a provider; the server answers with a redirect to it. */
|
|
397
|
+
providerStartUrl(providerId: string): string;
|
|
398
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthApi, never>;
|
|
399
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
400
|
+
}
|
|
401
|
+
/** The user's own login methods (`/me/…`); the interceptor adds the access token. */
|
|
402
|
+
export declare class ProfileApi {
|
|
403
|
+
#private;
|
|
404
|
+
loginMethods(): Promise<LoginMethodsDto>;
|
|
405
|
+
changePassword(request: ChangePasswordDto): Promise<void>;
|
|
406
|
+
unlink(identityId: string): Promise<void>;
|
|
407
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ProfileApi, never>;
|
|
408
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
409
|
+
}
|
|
410
|
+
/** Administration of the core (`/admin/…`, needs `users.manage`); the interceptor adds the access token. */
|
|
411
|
+
export declare class AdminApi {
|
|
412
|
+
#private;
|
|
413
|
+
/** A page of the users; omitted fields take the server defaults and are not sent. */
|
|
414
|
+
listUsers(query: AdminUserListQuery): Promise<AdminUserListDto>;
|
|
415
|
+
/** A user by the exact email with the name, before granting or adding to a group (`access.manage` anywhere, specs/012 R5); `null` — none. */
|
|
416
|
+
findUser(email: string): Promise<UserLookupDto | null>;
|
|
417
|
+
/** A new user with an invitation or a password (`users.manage`, specs/015). */
|
|
418
|
+
createUser(request: AdminUserCreateRequest): Promise<AdminUserCreateResponse>;
|
|
419
|
+
/** A new invitation for a user without a password; the old link stops working (`users.manage`, specs/015). */
|
|
420
|
+
createInvitation(id: string, request: AdminInvitationRequest): Promise<AdminInvitationLinkDto>;
|
|
421
|
+
/** One user for the card (`users.manage`). */
|
|
422
|
+
getUser(id: string): Promise<AdminUserDto>;
|
|
423
|
+
/** Personal global grants of the user (`access.manage`). */
|
|
424
|
+
listUserGrants(id: string): Promise<Array<AdminGrantDto>>;
|
|
425
|
+
/** Effective actions of the user with their origin (`access.manage`). */
|
|
426
|
+
listUserPermissions(id: string): Promise<Array<AdminUserPermissionDto>>;
|
|
427
|
+
/** Blocks the user with a reason and ends the sessions; the updated card (`users.manage`, specs/007). */
|
|
428
|
+
blockUser(id: string, reason: string): Promise<AdminUserDto>;
|
|
429
|
+
/** Unblocks the user; the updated card (`users.manage`). */
|
|
430
|
+
unblockUser(id: string): Promise<AdminUserDto>;
|
|
431
|
+
/** Sets a new password and ends the sessions of the user (`users.manage`). */
|
|
432
|
+
setUserPassword(id: string, password: string): Promise<void>;
|
|
433
|
+
/** Roles and actions with whether they can be granted to the user (`access.manage`, specs/008). */
|
|
434
|
+
getUserGrantOptions(id: string): Promise<AdminGrantOptionsDto>;
|
|
435
|
+
/** A personal global grant of a role or an action (`access.manage`). */
|
|
436
|
+
createUserGrant(id: string, request: AdminGrantRequest): Promise<AdminGrantDto>;
|
|
437
|
+
/** System roles with every action of the included roles (`access.manage` globally, specs/010). */
|
|
438
|
+
listRoles(): Promise<Array<AdminRoleDto>>;
|
|
439
|
+
/** Actions of the catalog with where they can be granted (`access.manage` globally). */
|
|
440
|
+
listActions(): Promise<Array<AdminActionDto>>;
|
|
441
|
+
/** Revokes a personal global grant (`access.manage`). */
|
|
442
|
+
deleteUserGrant(id: string, grantId: number): Promise<void>;
|
|
443
|
+
/** The system groups with the number of members and their global grants (`access.manage` globally, specs/011). */
|
|
444
|
+
listGroups(): Promise<Array<AdminGroupRowDto>>;
|
|
445
|
+
createGroup(request: AdminGroupRequest): Promise<AdminGroupRefDto>;
|
|
446
|
+
/** A system group with its members and whether the signed-in administrator may change them. */
|
|
447
|
+
getGroup(id: string): Promise<AdminGroupDto>;
|
|
448
|
+
updateGroup(id: string, request: AdminGroupRequest): Promise<AdminGroupRefDto>;
|
|
449
|
+
/** Deletes the group with its members and grants. */
|
|
450
|
+
deleteGroup(id: string): Promise<void>;
|
|
451
|
+
/** Adds a user found by `findUser`; adding again changes nothing. */
|
|
452
|
+
addGroupMember(id: string, userId: string): Promise<AdminGroupMemberDto>;
|
|
453
|
+
removeGroupMember(id: string, userId: string): Promise<void>;
|
|
454
|
+
listGroupGrants(id: string): Promise<Array<AdminGrantDto>>;
|
|
455
|
+
/** Every role and action with whether the signed-in administrator can grant it to this group. */
|
|
456
|
+
getGroupGrantOptions(id: string): Promise<AdminGrantOptionsDto>;
|
|
457
|
+
createGroupGrant(id: string, request: AdminGrantRequest): Promise<AdminGrantDto>;
|
|
458
|
+
deleteGroupGrant(id: string, grantId: number): Promise<void>;
|
|
459
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AdminApi, never>;
|
|
460
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
461
|
+
}
|
|
462
|
+
type AuthStatus = 'unknown' | 'authenticated' | 'anonymous';
|
|
463
|
+
/**
|
|
464
|
+
* Session state of the browser tab. The access token lives only in memory; after a reload the session is
|
|
465
|
+
* restored by a silent refresh. Refreshes are serialized across tabs with Web Locks and deduplicated inside a
|
|
466
|
+
* tab, so parallel tabs never present the same refresh token twice (that would revoke the session).
|
|
467
|
+
*/
|
|
468
|
+
export declare class AuthStore {
|
|
469
|
+
#private;
|
|
470
|
+
readonly status: import("@angular/core").Signal<AuthStatus>;
|
|
471
|
+
readonly user: import("@angular/core").Signal<import("@gleb216/warden-angular").MeUserDto | null>;
|
|
472
|
+
readonly accessToken: import("@angular/core").Signal<string | null>;
|
|
473
|
+
/** Restores the session once per tab; on the server the user is always anonymous (no tokens in SSR). */
|
|
474
|
+
init(): Promise<void>;
|
|
475
|
+
/** Throws the HTTP error of a failed sign-in; the caller maps its `code` to a message. */
|
|
476
|
+
login(email: string, password: string): Promise<void>;
|
|
477
|
+
/** Sets the password by a one-time link (specs/015) and keeps the new session; throws the HTTP error like `login`. */
|
|
478
|
+
completeLink(kind: AuthLinkKind, token: string, password: string): Promise<void>;
|
|
479
|
+
/** Leaves the application for the provider; `returnUrl` is restored by `takeReturnUrl()` on the callback page. */
|
|
480
|
+
startProviderLogin(providerId: string, returnUrl: string | null): void;
|
|
481
|
+
/** The return address saved by `startProviderLogin`, once; `/` when there is none. */
|
|
482
|
+
takeReturnUrl(): string;
|
|
483
|
+
/** `true` when the session is alive. Concurrent calls share one request. */
|
|
484
|
+
refresh(): Promise<boolean>;
|
|
485
|
+
/** Re-reads the rights after the server refused an action they promised (403). */
|
|
486
|
+
reloadPermissions(): Promise<void>;
|
|
487
|
+
/** Ends the session on the server and in this tab. */
|
|
488
|
+
logout(): Promise<void>;
|
|
489
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthStore, never>;
|
|
490
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Actions of the signed-in user with their scope, for the UI. They arrive with every login and refresh and only
|
|
494
|
+
* hide what the user cannot do: the server checks every request itself (constitution, principle IX).
|
|
495
|
+
*/
|
|
496
|
+
export declare class Permissions {
|
|
497
|
+
#private;
|
|
498
|
+
readonly current: import("@angular/core").Signal<readonly PermissionScopeDto[]>;
|
|
499
|
+
set(scopes: ReadonlyArray<PermissionScopeDto> | null): void;
|
|
500
|
+
/**
|
|
501
|
+
* Without `path` — the user has the action anywhere (globally or on some node). With `path` (nodes from the top
|
|
502
|
+
* down to the object) — globally or on a node of the path. Reactive: reads a signal.
|
|
503
|
+
*/
|
|
504
|
+
can(action: string, path?: ReadonlyArray<string>): boolean;
|
|
505
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Permissions, never>;
|
|
506
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Adds the in-memory access token to API requests. On 401 (`unauthenticated`, or `session_invalid` when the
|
|
510
|
+
* user was blocked or the session revoked) it refreshes the session once (shared by concurrent requests) and
|
|
511
|
+
* retries; when that fails it sends the user to the sign-in page. On 403 `forbidden` it re-reads the rights
|
|
512
|
+
* and calls `WARDEN_ON_FORBIDDEN`.
|
|
513
|
+
*/
|
|
514
|
+
export declare const authInterceptor: HttpInterceptorFn;
|
|
515
|
+
/** Pages behind sign-in: waits for the session restore and sends anonymous users to the sign-in page. */
|
|
516
|
+
export declare const authGuard: CanMatchFn;
|
|
517
|
+
/** The sign-in page is not shown to a user who is already signed in. */
|
|
518
|
+
export declare const guestGuard: CanMatchFn;
|
|
519
|
+
/**
|
|
520
|
+
* A page that needs an action anywhere (globally or on some node): without it the user sees the forbidden page.
|
|
521
|
+
* Use under `authGuard`; the object itself is checked by the server.
|
|
522
|
+
*/
|
|
523
|
+
export declare function requirePermission(action: string): CanMatchFn;
|
|
524
|
+
/**
|
|
525
|
+
* Renders the element only when the user has the action: `*wardenCan="'users.manage'"` — anywhere,
|
|
526
|
+
* `*wardenCan="'folder.create'; path: folderPath"` — on the object with that path. Display only — the server decides.
|
|
527
|
+
*/
|
|
528
|
+
export declare class Can {
|
|
529
|
+
readonly action: import("@angular/core").InputSignal<string>;
|
|
530
|
+
/** Nodes from the top down to the object; without it the action may be anywhere. */
|
|
531
|
+
readonly path: import("@angular/core").InputSignal<readonly string[] | undefined>;
|
|
532
|
+
constructor();
|
|
533
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Can, never>;
|
|
534
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<Can, "[wardenCan]", never, {
|
|
535
|
+
"action": {
|
|
536
|
+
"alias": "wardenCan";
|
|
537
|
+
"required": true;
|
|
538
|
+
"isSignal": true;
|
|
539
|
+
};
|
|
540
|
+
"path": {
|
|
541
|
+
"alias": "wardenCanPath";
|
|
542
|
+
"required": false;
|
|
543
|
+
"isSignal": true;
|
|
544
|
+
};
|
|
545
|
+
}, {}, never, never, true, never>;
|
|
546
|
+
}
|
|
547
|
+
/** Code of a failed API call (`ApiError.code`), `network` when the server was not reached, `unknown` otherwise. */
|
|
548
|
+
export declare function errorCode(error: unknown): string;
|
|
549
|
+
/** Only relative in-app paths are accepted as a return address (no open redirect). */
|
|
550
|
+
export declare function safeReturnUrl(value: string | null | undefined): string;
|
|
551
|
+
export type { AdminActionDto, AdminCreatedUserDto, AdminErrorCode, AdminGrantActionOptionDto, AdminGrantDto, AdminGrantOptionState, AdminGrantOptionsDto, AdminGrantRequest, AdminGrantRoleOptionDto, AdminGroupDto, AdminGroupMemberDto, AdminGroupMemberRequest, AdminGroupNameDto, AdminGroupRefDto, AdminGroupRequest, AdminGroupRowDto, AdminInvitationLinkDto, AdminInvitationRequest, AdminInvitationStateDto, AdminRoleDto, AdminUserBlockDto, AdminUserBlockRequest, AdminUserCreateRequest, AdminUserCreateResponse, AdminUserDto, AdminUserListDto, AdminUserListQuery, AdminUserPasswordRequest, AdminUserPermissionDto, AdminUserRefDto, AdminUserRowDto, AdminUserSort, AdminUserState, ApiError, AuthLinkDto, AuthLinkKind, AuthLinkPasswordRequestDto, AuthLinkRequestDto, AuthProviderDto, AuthSessionDto, AuthStatus, ChangePasswordDto, IsoDate, IsoDateTime, LoginIdentityDto, LoginMethodsDto, LoginRequestDto, MailLang, MailStateDto, MeDto, MeUserDto, PasswordResetAvailabilityDto, PasswordResetRequestDto, PermissionScopeDto, SortDirection, UserLookupDto, WardenAngularConfig, WardenErrorCode };
|
|
552
|
+
//# sourceMappingURL=gleb216-warden-angular.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gleb216-warden-angular.d.ts","names":[],"sources":["../../src/config.ts","../../src/contracts/index.ts","../../src/auth-api.ts","../../src/profile-api.ts","../../src/admin-api.ts","../../src/auth-store.ts","../../src/permissions.ts","../../src/auth-interceptor.ts","../../src/guards.ts","../../src/can.ts","../../src/errors.ts"],"mappings":";;;;;;;UAGiB;;EAEf;;EAEA;;EAEA;;qBAGW,uBAAqB,eAAA;;;;;qBASrB,qBAAmB;;wBAGhB,cAAc,SAAQ,QAAQ,uBAA4B,MAAM;;KCpBpE;;KAGA;;KAGA;;UAoBK;EACf;EACA,MAAM;EACN;;EAEA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;;;;;;KAOU;EAAuB;EAAgB;;EAAmB;EAAgB;EAAe,WAAW;;UAE/F;EACf,MAAM;;EAEN,aAAa,MAAM;;UAGJ,uBAAuB;;EAEtC;EACA,iBAAiB;;UAGF;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA,UAAU;EACV,aAAa;;UAGE;EACf;EACA,YAAY,MAAM;;UAGH;;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