@enonic-types/lib-auth 8.0.0-B2 → 8.0.0-B5

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 (2) hide show
  1. package/auth.d.ts +102 -10
  2. package/package.json +2 -2
package/auth.d.ts CHANGED
@@ -136,6 +136,7 @@ export interface CreateUserParams {
136
136
  * @param {string} params.name User login name to set.
137
137
  * @param {string} [params.displayName] User display name.
138
138
  * @param {string} [params.email] User email.
139
+ * @returns {User} The created user.
139
140
  */
140
141
  export declare function createUser(params: CreateUserParams): User;
141
142
  export interface ModifyUserParams {
@@ -150,7 +151,7 @@ export interface ModifyUserParams {
150
151
  * @param {object} params JSON parameters.
151
152
  * @param {string} params.key Principal key of the user to modify.
152
153
  * @param {function} params.editor User editor function to apply to user.
153
- * @returns {User} the updated user or null if a user not found.
154
+ * @returns {User | null} The updated user, or null if user not found.
154
155
  */
155
156
  export declare function modifyUser(params: ModifyUserParams): User | null;
156
157
  export interface CreateGroupParams {
@@ -168,7 +169,8 @@ export interface CreateGroupParams {
168
169
  * @param {string} params.idProvider Key for id provider where group has to be created.
169
170
  * @param {string} params.name Group name.
170
171
  * @param {string} [params.displayName] Group display name.
171
- * @param {string} [params.description] as principal description .
172
+ * @param {string} [params.description] Group description.
173
+ * @returns {Group} The created group.
172
174
  */
173
175
  export declare function createGroup(params: CreateGroupParams): Group;
174
176
  export interface ModifyGroupParams {
@@ -183,25 +185,25 @@ export interface ModifyGroupParams {
183
185
  * @param {object} params JSON parameters.
184
186
  * @param {string} params.key Principal key of the group to modify.
185
187
  * @param {function} params.editor Group editor function to apply to group.
186
- * @returns {Group} the updated group or null if a group not found.
188
+ * @returns {Group | null} The updated group, or null if group not found.
187
189
  */
188
190
  export declare function modifyGroup(params: ModifyGroupParams): Group | null;
189
191
  /**
190
- * Adds members to a principal (user or role).
192
+ * Adds members to a principal (group or role).
191
193
  *
192
194
  * @example-ref examples/auth/addMembers.js
193
195
  *
194
196
  * @param {string} principalKey Key of the principal to add members to.
195
- * @param {Array<string>} members Keys of users and groups to add.
197
+ * @param {string[]} members Keys of users and groups to add.
196
198
  */
197
199
  export declare function addMembers(principalKey: GroupKey | RoleKey, members: (UserKey | GroupKey)[]): void;
198
200
  /**
199
- * Removes members from a principal (user or role).
201
+ * Removes members from a principal (group or role).
200
202
  *
201
203
  * @example-ref examples/auth/removeMembers.js
202
204
  *
203
205
  * @param {string} principalKey Key of the principal to remove members from.
204
- * @param {string} members Keys of the principals to remove.
206
+ * @param {string[]} members Keys of the principals to remove.
205
207
  */
206
208
  export declare function removeMembers(principalKey: GroupKey | RoleKey, members: (UserKey | GroupKey)[]): void;
207
209
  export interface FindPrincipalsParams {
@@ -249,7 +251,7 @@ export declare function deletePrincipal(principalKey: PrincipalKey): boolean;
249
251
  *
250
252
  * @returns {object} The ID provider configuration as JSON.
251
253
  */
252
- export declare function getIdProviderConfig<IdProviderConfig extends Record<string, unknown>>(): IdProviderConfig | null;
254
+ export declare function getIdProviderConfig<Config extends Record<string, unknown>>(): Config | null;
253
255
  export interface GetProfileParams {
254
256
  key: UserKey;
255
257
  scope?: string;
@@ -306,9 +308,11 @@ export interface CreateRoleParams {
306
308
  *
307
309
  * @example-ref examples/auth/createRole.js
308
310
  *
311
+ * @param {object} params JSON parameters.
309
312
  * @param {string} params.name Role name.
310
313
  * @param {string} [params.displayName] Role display name.
311
- * @param {string} [params.description] as principal description .
314
+ * @param {string} [params.description] Role description.
315
+ * @returns {Role} The created role.
312
316
  */
313
317
  export declare function createRole(params: CreateRoleParams): Role;
314
318
  export interface ModifyRoleParams {
@@ -323,6 +327,94 @@ export interface ModifyRoleParams {
323
327
  * @param {object} params JSON parameters.
324
328
  * @param {string} params.key Principal key of the role to modify.
325
329
  * @param {function} params.editor Role editor function to apply to role.
326
- * @returns {Role} the updated role or null if a role not found.
330
+ * @returns {Role | null} The updated role, or null if role not found.
327
331
  */
328
332
  export declare function modifyRole(params: ModifyRoleParams): Role | null;
333
+ export type IdProviderAccess = 'READ' | 'CREATE_USERS' | 'WRITE_USERS' | 'ID_PROVIDER_MANAGER' | 'ADMINISTRATOR';
334
+ export interface IdProviderAccessControlEntry {
335
+ principal: PrincipalKey;
336
+ access: IdProviderAccess;
337
+ }
338
+ /**
339
+ * Configuration that binds an id provider to the application implementing
340
+ * its authentication flow.
341
+ *
342
+ * An id provider can be bound to at most **one** application via
343
+ * `applicationKey`. The same application may, in turn, back several id
344
+ * providers — each with its own `config` tree (e.g. a `staff` and a
345
+ * `customers` provider both implemented by the same id-provider app).
346
+ *
347
+ * An id provider without `idProviderConfig` is incomplete and most
348
+ * flows that rely on it won't work until a binding is added.
349
+ */
350
+ export interface IdProviderConfig {
351
+ /**
352
+ * Key of the application whose handlers serve requests for this
353
+ * provider.
354
+ */
355
+ applicationKey: string;
356
+ /**
357
+ * Per-instance configuration tree, exposed to the bound application.
358
+ */
359
+ config?: Record<string, unknown>;
360
+ }
361
+ /**
362
+ * An id provider. Has 0 or 1 bound application via `idProviderConfig`;
363
+ * the binding determines which app handles login, logout, registration,
364
+ * and similar flows for this provider.
365
+ */
366
+ export interface IdProvider {
367
+ /** Unique key identifying this provider (e.g. `system`, `simpleid`). */
368
+ key: string;
369
+ /** Human-readable label shown in admin UIs. */
370
+ displayName: string;
371
+ /** Optional free-text description. */
372
+ description?: string;
373
+ /**
374
+ * Application binding. Absent ⇒ the provider is incomplete and
375
+ * dependent flows generally won't work.
376
+ */
377
+ idProviderConfig?: IdProviderConfig;
378
+ }
379
+ /**
380
+ * Parameters for {@link createIdProvider}. See {@link IdProvider} for the
381
+ * meaning of each field; without `idProviderConfig` the provider is
382
+ * incomplete.
383
+ */
384
+ export interface CreateIdProviderParams {
385
+ key: string;
386
+ displayName: string;
387
+ description?: string;
388
+ idProviderConfig?: IdProviderConfig;
389
+ permissions?: IdProviderAccessControlEntry[];
390
+ }
391
+ /**
392
+ * Creates an id provider.
393
+ *
394
+ * An id provider can be bound to at most one application via
395
+ * `params.idProviderConfig`. Without it the provider is incomplete and
396
+ * most flows that rely on it won't work until a binding is added.
397
+ *
398
+ * @example-ref examples/auth/createIdProvider.js
399
+ *
400
+ * @param {object} params JSON parameters.
401
+ * @param {string} params.key Id provider key.
402
+ * @param {string} params.displayName Id provider display name.
403
+ * @param {string} [params.description] Id provider description.
404
+ * @param {object} [params.idProviderConfig] Binds this provider to one application. Without it the provider is incomplete.
405
+ * @param {string} params.idProviderConfig.applicationKey Application that handles requests for this provider. Required when `idProviderConfig` is set.
406
+ * @param {object} [params.idProviderConfig.config] Per-instance configuration tree passed to the bound application.
407
+ * @param {Array<object>} [params.permissions] Id provider permissions.
408
+ * @returns {IdProvider} The created id provider.
409
+ */
410
+ export declare function createIdProvider(params: CreateIdProviderParams): IdProvider;
411
+ /**
412
+ * Returns all id providers. Each entry's `idProviderConfig` is present
413
+ * only when the provider is bound to an application; incomplete
414
+ * providers come back without it.
415
+ *
416
+ * @example-ref examples/auth/getIdProviders.js
417
+ *
418
+ * @returns {Array<IdProvider>} List of id providers.
419
+ */
420
+ export declare function getIdProviders(): IdProvider[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic-types/lib-auth",
3
- "version": "8.0.0-B2",
3
+ "version": "8.0.0-B5",
4
4
  "description": "Type definitions for lib-auth.",
5
5
  "types": "auth.d.ts",
6
6
  "files": [
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/enonic/xp/tree/master#readme",
29
29
  "dependencies": {
30
- "@enonic-types/core": "8.0.0-B2"
30
+ "@enonic-types/core": "8.0.0-B5"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"