@byline/admin 0.9.3
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/LICENSE +373 -0
- package/README.md +19 -0
- package/dist/abilities.d.ts +22 -0
- package/dist/abilities.d.ts.map +1 -0
- package/dist/abilities.js +29 -0
- package/dist/abilities.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/assert-admin-actor.d.ts +58 -0
- package/dist/lib/assert-admin-actor.d.ts.map +1 -0
- package/dist/lib/assert-admin-actor.js +82 -0
- package/dist/lib/assert-admin-actor.js.map +1 -0
- package/dist/modules/admin-account/commands.d.ts +30 -0
- package/dist/modules/admin-account/commands.d.ts.map +1 -0
- package/dist/modules/admin-account/commands.js +36 -0
- package/dist/modules/admin-account/commands.js.map +1 -0
- package/dist/modules/admin-account/errors.d.ts +52 -0
- package/dist/modules/admin-account/errors.d.ts.map +1 -0
- package/dist/modules/admin-account/errors.js +52 -0
- package/dist/modules/admin-account/errors.js.map +1 -0
- package/dist/modules/admin-account/index.d.ts +37 -0
- package/dist/modules/admin-account/index.d.ts.map +1 -0
- package/dist/modules/admin-account/index.js +35 -0
- package/dist/modules/admin-account/index.js.map +1 -0
- package/dist/modules/admin-account/schemas.d.ts +31 -0
- package/dist/modules/admin-account/schemas.d.ts.map +1 -0
- package/dist/modules/admin-account/schemas.js +69 -0
- package/dist/modules/admin-account/schemas.js.map +1 -0
- package/dist/modules/admin-account/service.d.ts +44 -0
- package/dist/modules/admin-account/service.d.ts.map +1 -0
- package/dist/modules/admin-account/service.js +76 -0
- package/dist/modules/admin-account/service.js.map +1 -0
- package/dist/modules/admin-permissions/abilities.d.ts +27 -0
- package/dist/modules/admin-permissions/abilities.d.ts.map +1 -0
- package/dist/modules/admin-permissions/abilities.js +40 -0
- package/dist/modules/admin-permissions/abilities.js.map +1 -0
- package/dist/modules/admin-permissions/commands.d.ts +30 -0
- package/dist/modules/admin-permissions/commands.d.ts.map +1 -0
- package/dist/modules/admin-permissions/commands.js +39 -0
- package/dist/modules/admin-permissions/commands.js.map +1 -0
- package/dist/modules/admin-permissions/dto.d.ts +18 -0
- package/dist/modules/admin-permissions/dto.d.ts.map +1 -0
- package/dist/modules/admin-permissions/dto.js +24 -0
- package/dist/modules/admin-permissions/dto.js.map +1 -0
- package/dist/modules/admin-permissions/errors.d.ts +34 -0
- package/dist/modules/admin-permissions/errors.d.ts.map +1 -0
- package/dist/modules/admin-permissions/errors.js +34 -0
- package/dist/modules/admin-permissions/errors.js.map +1 -0
- package/dist/modules/admin-permissions/index.d.ts +30 -0
- package/dist/modules/admin-permissions/index.d.ts.map +1 -0
- package/dist/modules/admin-permissions/index.js +27 -0
- package/dist/modules/admin-permissions/index.js.map +1 -0
- package/dist/modules/admin-permissions/repository.d.ts +48 -0
- package/dist/modules/admin-permissions/repository.d.ts.map +1 -0
- package/dist/modules/admin-permissions/repository.js +9 -0
- package/dist/modules/admin-permissions/repository.js.map +1 -0
- package/dist/modules/admin-permissions/schemas.d.ts +137 -0
- package/dist/modules/admin-permissions/schemas.d.ts.map +1 -0
- package/dist/modules/admin-permissions/schemas.js +99 -0
- package/dist/modules/admin-permissions/schemas.js.map +1 -0
- package/dist/modules/admin-permissions/service.d.ts +42 -0
- package/dist/modules/admin-permissions/service.d.ts.map +1 -0
- package/dist/modules/admin-permissions/service.js +114 -0
- package/dist/modules/admin-permissions/service.js.map +1 -0
- package/dist/modules/admin-roles/abilities.d.ts +33 -0
- package/dist/modules/admin-roles/abilities.d.ts.map +1 -0
- package/dist/modules/admin-roles/abilities.js +56 -0
- package/dist/modules/admin-roles/abilities.js.map +1 -0
- package/dist/modules/admin-roles/commands.d.ts +37 -0
- package/dist/modules/admin-roles/commands.d.ts.map +1 -0
- package/dist/modules/admin-roles/commands.js +70 -0
- package/dist/modules/admin-roles/commands.js.map +1 -0
- package/dist/modules/admin-roles/dto.d.ts +18 -0
- package/dist/modules/admin-roles/dto.d.ts.map +1 -0
- package/dist/modules/admin-roles/dto.js +27 -0
- package/dist/modules/admin-roles/dto.js.map +1 -0
- package/dist/modules/admin-roles/errors.d.ts +49 -0
- package/dist/modules/admin-roles/errors.d.ts.map +1 -0
- package/dist/modules/admin-roles/errors.js +49 -0
- package/dist/modules/admin-roles/errors.js.map +1 -0
- package/dist/modules/admin-roles/index.d.ts +30 -0
- package/dist/modules/admin-roles/index.d.ts.map +1 -0
- package/dist/modules/admin-roles/index.js +27 -0
- package/dist/modules/admin-roles/index.js.map +1 -0
- package/dist/modules/admin-roles/repository.d.ts +91 -0
- package/dist/modules/admin-roles/repository.d.ts.map +1 -0
- package/dist/modules/admin-roles/repository.js +9 -0
- package/dist/modules/admin-roles/repository.js.map +1 -0
- package/dist/modules/admin-roles/schemas.d.ts +99 -0
- package/dist/modules/admin-roles/schemas.d.ts.map +1 -0
- package/dist/modules/admin-roles/schemas.js +105 -0
- package/dist/modules/admin-roles/schemas.js.map +1 -0
- package/dist/modules/admin-roles/service.d.ts +49 -0
- package/dist/modules/admin-roles/service.d.ts.map +1 -0
- package/dist/modules/admin-roles/service.js +110 -0
- package/dist/modules/admin-roles/service.js.map +1 -0
- package/dist/modules/admin-users/abilities.d.ts +41 -0
- package/dist/modules/admin-users/abilities.d.ts.map +1 -0
- package/dist/modules/admin-users/abilities.js +70 -0
- package/dist/modules/admin-users/abilities.js.map +1 -0
- package/dist/modules/admin-users/commands.d.ts +45 -0
- package/dist/modules/admin-users/commands.d.ts.map +1 -0
- package/dist/modules/admin-users/commands.js +63 -0
- package/dist/modules/admin-users/commands.js.map +1 -0
- package/dist/modules/admin-users/dto.d.ts +20 -0
- package/dist/modules/admin-users/dto.d.ts.map +1 -0
- package/dist/modules/admin-users/dto.js +36 -0
- package/dist/modules/admin-users/dto.js.map +1 -0
- package/dist/modules/admin-users/errors.d.ts +53 -0
- package/dist/modules/admin-users/errors.d.ts.map +1 -0
- package/dist/modules/admin-users/errors.js +53 -0
- package/dist/modules/admin-users/errors.js.map +1 -0
- package/dist/modules/admin-users/index.d.ts +31 -0
- package/dist/modules/admin-users/index.d.ts.map +1 -0
- package/dist/modules/admin-users/index.js +28 -0
- package/dist/modules/admin-users/index.js.map +1 -0
- package/dist/modules/admin-users/repository.d.ts +147 -0
- package/dist/modules/admin-users/repository.d.ts.map +1 -0
- package/dist/modules/admin-users/repository.js +9 -0
- package/dist/modules/admin-users/repository.js.map +1 -0
- package/dist/modules/admin-users/schemas.d.ts +136 -0
- package/dist/modules/admin-users/schemas.d.ts.map +1 -0
- package/dist/modules/admin-users/schemas.js +137 -0
- package/dist/modules/admin-users/schemas.js.map +1 -0
- package/dist/modules/admin-users/seed-super-admin.d.ts +44 -0
- package/dist/modules/admin-users/seed-super-admin.d.ts.map +1 -0
- package/dist/modules/admin-users/seed-super-admin.js +70 -0
- package/dist/modules/admin-users/seed-super-admin.js.map +1 -0
- package/dist/modules/admin-users/service.d.ts +53 -0
- package/dist/modules/admin-users/service.d.ts.map +1 -0
- package/dist/modules/admin-users/service.js +143 -0
- package/dist/modules/admin-users/service.js.map +1 -0
- package/dist/modules/auth/index.d.ts +26 -0
- package/dist/modules/auth/index.d.ts.map +1 -0
- package/dist/modules/auth/index.js +25 -0
- package/dist/modules/auth/index.js.map +1 -0
- package/dist/modules/auth/jwt-session-provider.d.ts +47 -0
- package/dist/modules/auth/jwt-session-provider.d.ts.map +1 -0
- package/dist/modules/auth/jwt-session-provider.js +215 -0
- package/dist/modules/auth/jwt-session-provider.js.map +1 -0
- package/dist/modules/auth/password.d.ts +16 -0
- package/dist/modules/auth/password.d.ts.map +1 -0
- package/dist/modules/auth/password.js +48 -0
- package/dist/modules/auth/password.js.map +1 -0
- package/dist/modules/auth/refresh-tokens-repository.d.ts +71 -0
- package/dist/modules/auth/refresh-tokens-repository.d.ts.map +1 -0
- package/dist/modules/auth/refresh-tokens-repository.js +9 -0
- package/dist/modules/auth/refresh-tokens-repository.js.map +1 -0
- package/dist/modules/auth/resolve-actor.d.ts +25 -0
- package/dist/modules/auth/resolve-actor.d.ts.map +1 -0
- package/dist/modules/auth/resolve-actor.js +36 -0
- package/dist/modules/auth/resolve-actor.js.map +1 -0
- package/dist/store.d.ts +31 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +9 -0
- package/dist/store.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-admin-actor.js","sourceRoot":"","sources":["../../src/lib/assert-admin-actor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAkB,mBAAmB,EAAE,WAAW,EAAuB,MAAM,cAAc,CAAA;AAEpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAmC,EAAE,OAAe;IACnF,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,EAAE,2BAA2B,OAAO,GAAG,CAAC,CAAA;IAC/E,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC5B,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAmC,EACnC,YAAoB;IAEpB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,mBAAmB,CAAC;YACxB,OAAO,EACL,6BAA6B,YAAY,mCAAmC;gBAC5E,uFAAuF;gBACvF,uCAAuC;SAC1C,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IACzB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,MAAM,mBAAmB,CAAC;YACxB,OAAO,EAAE,mCAAmC,YAAY,EAAE;SAC3D,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,mBAAmB,CAAC;YACxB,OAAO,EAAE,kCAAkC,YAAY,EAAE;SAC1D,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import type { RequestContext } from '@byline/auth';
|
|
9
|
+
import type { AdminStore } from '../../store.js';
|
|
10
|
+
import type { AccountResponse } from './schemas.js';
|
|
11
|
+
/**
|
|
12
|
+
* Transport-agnostic commands for admin-account self-service.
|
|
13
|
+
*
|
|
14
|
+
* Same shape as the other admin module commands (`*-users`, `*-roles`,
|
|
15
|
+
* `*-permissions`) with one deliberate difference: enforcement uses
|
|
16
|
+
* `requireAdminActor` rather than `assertAdminActor`. There is no
|
|
17
|
+
* ability key to gate against — the security property is "you may
|
|
18
|
+
* only mutate your own row," and these commands enforce it
|
|
19
|
+
* structurally by sourcing the target id from `actor.id` rather than
|
|
20
|
+
* from the request payload. A request with an `id` field would have
|
|
21
|
+
* no way to express "operate on someone else" because the schemas
|
|
22
|
+
* don't accept one.
|
|
23
|
+
*/
|
|
24
|
+
export interface AdminAccountCommandDeps {
|
|
25
|
+
store: AdminStore;
|
|
26
|
+
}
|
|
27
|
+
export declare function getAccountCommand(context: RequestContext | undefined, input: unknown, deps: AdminAccountCommandDeps): Promise<AccountResponse>;
|
|
28
|
+
export declare function updateAccountCommand(context: RequestContext | undefined, input: unknown, deps: AdminAccountCommandDeps): Promise<AccountResponse>;
|
|
29
|
+
export declare function changeAccountPasswordCommand(context: RequestContext | undefined, input: unknown, deps: AdminAccountCommandDeps): Promise<AccountResponse>;
|
|
30
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-account/commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAUlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,UAAU,CAAA;CAClB;AAMD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,eAAe,CAAC,CAQ1B;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,eAAe,CAAC,CAK1B;AAED,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,eAAe,CAAC,CAK1B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import { requireAdminActor } from '../../lib/assert-admin-actor.js';
|
|
9
|
+
import { adminUserResponseSchema } from '../admin-users/schemas.js';
|
|
10
|
+
import { changeAccountPasswordRequestSchema, getAccountRequestSchema, updateAccountRequestSchema, } from './schemas.js';
|
|
11
|
+
import { AdminAccountService } from './service.js';
|
|
12
|
+
function serviceOf(deps) {
|
|
13
|
+
return new AdminAccountService({ repo: deps.store.adminUsers });
|
|
14
|
+
}
|
|
15
|
+
export async function getAccountCommand(context, input, deps) {
|
|
16
|
+
// No-op parse — `getAccountRequestSchema` is `{}.strict()` so it
|
|
17
|
+
// rejects stray payloads but yields no usable data. The schema is
|
|
18
|
+
// validated for shape consistency with the other commands.
|
|
19
|
+
getAccountRequestSchema.parse(input ?? {});
|
|
20
|
+
const actor = requireAdminActor(context, 'reading own admin account');
|
|
21
|
+
const result = await serviceOf(deps).getAccount(actor.id);
|
|
22
|
+
return adminUserResponseSchema.parse(result);
|
|
23
|
+
}
|
|
24
|
+
export async function updateAccountCommand(context, input, deps) {
|
|
25
|
+
const parsed = updateAccountRequestSchema.parse(input);
|
|
26
|
+
const actor = requireAdminActor(context, 'updating own admin account');
|
|
27
|
+
const result = await serviceOf(deps).updateAccount(actor.id, parsed);
|
|
28
|
+
return adminUserResponseSchema.parse(result);
|
|
29
|
+
}
|
|
30
|
+
export async function changeAccountPasswordCommand(context, input, deps) {
|
|
31
|
+
const parsed = changeAccountPasswordRequestSchema.parse(input);
|
|
32
|
+
const actor = requireAdminActor(context, 'changing own admin password');
|
|
33
|
+
const result = await serviceOf(deps).changePassword(actor.id, parsed);
|
|
34
|
+
return adminUserResponseSchema.parse(result);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../src/modules/admin-account/commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EACL,kCAAkC,EAClC,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAsBlD,SAAS,SAAS,CAAC,IAA6B;IAC9C,OAAO,IAAI,mBAAmB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAA;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAmC,EACnC,KAAc,EACd,IAA6B;IAE7B,iEAAiE;IACjE,kEAAkE;IAClE,2DAA2D;IAC3D,uBAAuB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IAC1C,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAA;IACrE,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACzD,OAAO,uBAAuB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAmC,EACnC,KAAc,EACd,IAA6B;IAE7B,MAAM,MAAM,GAAG,0BAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACtD,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAAA;IACtE,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IACpE,OAAO,uBAAuB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,OAAmC,EACnC,KAAc,EACd,IAA6B;IAE7B,MAAM,MAAM,GAAG,kCAAkC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAC9D,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAA;IACvE,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IACrE,OAAO,uBAAuB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Module-local error codes for admin-account self-service.
|
|
10
|
+
*
|
|
11
|
+
* Same `code + factory` shape as the other admin modules. The codes are
|
|
12
|
+
* prefixed `admin.account.*` so they sort alongside any future
|
|
13
|
+
* `admin.account` ability keys (today there are none — self-service is
|
|
14
|
+
* gated only by "you must be authenticated and you can only act on
|
|
15
|
+
* yourself") and so transport layers can branch on them distinctly
|
|
16
|
+
* from `admin.users.*`. Note that `admin.users.versionConflict` and
|
|
17
|
+
* `admin.users.emailInUse` are also reachable here because the service
|
|
18
|
+
* delegates to `AdminUsersRepository.update` / `setPasswordHash`; both
|
|
19
|
+
* are deliberately surfaced unmodified so the UI sees a single error
|
|
20
|
+
* code per condition.
|
|
21
|
+
*/
|
|
22
|
+
export declare const AdminAccountErrorCodes: {
|
|
23
|
+
readonly NOT_FOUND: "admin.account.notFound";
|
|
24
|
+
readonly INVALID_CURRENT_PASSWORD: "admin.account.invalidCurrentPassword";
|
|
25
|
+
};
|
|
26
|
+
export type AdminAccountErrorCode = (typeof AdminAccountErrorCodes)[keyof typeof AdminAccountErrorCodes];
|
|
27
|
+
export interface AdminAccountErrorOptions {
|
|
28
|
+
message?: string;
|
|
29
|
+
cause?: unknown;
|
|
30
|
+
}
|
|
31
|
+
export declare class AdminAccountError extends Error {
|
|
32
|
+
readonly code: AdminAccountErrorCode;
|
|
33
|
+
constructor(code: AdminAccountErrorCode, options: {
|
|
34
|
+
message: string;
|
|
35
|
+
cause?: unknown;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The actor's admin-user id no longer resolves to a row. Typically
|
|
40
|
+
* means the session refers to a user that has been deleted out of band
|
|
41
|
+
* — the transport handler should clear cookies and redirect to
|
|
42
|
+
* sign-in.
|
|
43
|
+
*/
|
|
44
|
+
export declare const ERR_ADMIN_ACCOUNT_NOT_FOUND: (options?: AdminAccountErrorOptions) => AdminAccountError;
|
|
45
|
+
/**
|
|
46
|
+
* The supplied current password did not verify against the stored hash.
|
|
47
|
+
* Returned for the change-password flow — message is intentionally
|
|
48
|
+
* generic so it can be surfaced verbatim to end users without leaking
|
|
49
|
+
* timing or existence signals.
|
|
50
|
+
*/
|
|
51
|
+
export declare const ERR_ADMIN_ACCOUNT_INVALID_CURRENT_PASSWORD: (options?: AdminAccountErrorOptions) => AdminAccountError;
|
|
52
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-account/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,sBAAsB;;;CAGzB,CAAA;AAEV,MAAM,MAAM,qBAAqB,GAC/B,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAA;AAEtE,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAgB,IAAI,EAAE,qBAAqB,CAAA;gBAE/B,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAKvF;AAUD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,aAZ3B,wBAAwB,KAAG,iBAevC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,0CAA0C,aAvB1C,wBAAwB,KAAG,iBA0BvC,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Module-local error codes for admin-account self-service.
|
|
10
|
+
*
|
|
11
|
+
* Same `code + factory` shape as the other admin modules. The codes are
|
|
12
|
+
* prefixed `admin.account.*` so they sort alongside any future
|
|
13
|
+
* `admin.account` ability keys (today there are none — self-service is
|
|
14
|
+
* gated only by "you must be authenticated and you can only act on
|
|
15
|
+
* yourself") and so transport layers can branch on them distinctly
|
|
16
|
+
* from `admin.users.*`. Note that `admin.users.versionConflict` and
|
|
17
|
+
* `admin.users.emailInUse` are also reachable here because the service
|
|
18
|
+
* delegates to `AdminUsersRepository.update` / `setPasswordHash`; both
|
|
19
|
+
* are deliberately surfaced unmodified so the UI sees a single error
|
|
20
|
+
* code per condition.
|
|
21
|
+
*/
|
|
22
|
+
export const AdminAccountErrorCodes = {
|
|
23
|
+
NOT_FOUND: 'admin.account.notFound',
|
|
24
|
+
INVALID_CURRENT_PASSWORD: 'admin.account.invalidCurrentPassword',
|
|
25
|
+
};
|
|
26
|
+
export class AdminAccountError extends Error {
|
|
27
|
+
code;
|
|
28
|
+
constructor(code, options) {
|
|
29
|
+
super(options.message, options.cause != null ? { cause: options.cause } : undefined);
|
|
30
|
+
this.name = 'AdminAccountError';
|
|
31
|
+
this.code = code;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const make = (code, defaultMessage) => (options) => new AdminAccountError(code, {
|
|
35
|
+
message: options?.message ?? defaultMessage,
|
|
36
|
+
cause: options?.cause,
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* The actor's admin-user id no longer resolves to a row. Typically
|
|
40
|
+
* means the session refers to a user that has been deleted out of band
|
|
41
|
+
* — the transport handler should clear cookies and redirect to
|
|
42
|
+
* sign-in.
|
|
43
|
+
*/
|
|
44
|
+
export const ERR_ADMIN_ACCOUNT_NOT_FOUND = make(AdminAccountErrorCodes.NOT_FOUND, 'admin account not found');
|
|
45
|
+
/**
|
|
46
|
+
* The supplied current password did not verify against the stored hash.
|
|
47
|
+
* Returned for the change-password flow — message is intentionally
|
|
48
|
+
* generic so it can be surfaced verbatim to end users without leaking
|
|
49
|
+
* timing or existence signals.
|
|
50
|
+
*/
|
|
51
|
+
export const ERR_ADMIN_ACCOUNT_INVALID_CURRENT_PASSWORD = make(AdminAccountErrorCodes.INVALID_CURRENT_PASSWORD, 'current password is incorrect');
|
|
52
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/modules/admin-account/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,SAAS,EAAE,wBAAwB;IACnC,wBAAwB,EAAE,sCAAsC;CACxD,CAAA;AAUV,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1B,IAAI,CAAuB;IAE3C,YAAY,IAA2B,EAAE,OAA6C;QACpF,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QACpF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED,MAAM,IAAI,GACR,CAAC,IAA2B,EAAE,cAAsB,EAAE,EAAE,CACxD,CAAC,OAAkC,EAAqB,EAAE,CACxD,IAAI,iBAAiB,CAAC,IAAI,EAAE;IAC1B,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,cAAc;IAC3C,KAAK,EAAE,OAAO,EAAE,KAAK;CACtB,CAAC,CAAA;AAEN;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAC7C,sBAAsB,CAAC,SAAS,EAChC,yBAAyB,CAC1B,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,IAAI,CAC5D,sBAAsB,CAAC,wBAAwB,EAC/C,+BAA+B,CAChC,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* `@byline/admin/admin-account` — self-service surfaces for the currently
|
|
10
|
+
* signed-in admin user.
|
|
11
|
+
*
|
|
12
|
+
* Distinct from `@byline/admin/admin-users` in two ways:
|
|
13
|
+
*
|
|
14
|
+
* 1. The actor IS the target. Commands take no `id` field — the
|
|
15
|
+
* target is sourced from `actor.id` on the authenticated
|
|
16
|
+
* `RequestContext`. There is no way at the command surface to
|
|
17
|
+
* ask "operate on someone else."
|
|
18
|
+
* 2. There is no ability gate. The other admin modules use
|
|
19
|
+
* `assertAdminActor(context, ability)`; this module uses
|
|
20
|
+
* `requireAdminActor(context)` — authn-only. "Anyone may change
|
|
21
|
+
* their own password" is the policy.
|
|
22
|
+
*
|
|
23
|
+
* Reuses `AdminUsersRepository` from `@byline/admin/admin-users` rather
|
|
24
|
+
* than introducing a parallel repo — the table is the same and the
|
|
25
|
+
* narrower self-service surface is structural rather than physical.
|
|
26
|
+
*
|
|
27
|
+
* Active-session listing / revocation is intentionally not included
|
|
28
|
+
* yet — that depends on `RefreshTokensRepository` semantics and a
|
|
29
|
+
* "sign out everywhere on password change" follow-up.
|
|
30
|
+
*/
|
|
31
|
+
export { changeAccountPasswordCommand, getAccountCommand, updateAccountCommand, } from './commands.js';
|
|
32
|
+
export { AdminAccountError, type AdminAccountErrorCode, AdminAccountErrorCodes, ERR_ADMIN_ACCOUNT_INVALID_CURRENT_PASSWORD, ERR_ADMIN_ACCOUNT_NOT_FOUND, } from './errors.js';
|
|
33
|
+
export { accountResponseSchema, changeAccountPasswordRequestSchema, getAccountRequestSchema, okResponseSchema, updateAccountRequestSchema, } from './schemas.js';
|
|
34
|
+
export { AdminAccountService } from './service.js';
|
|
35
|
+
export type { AdminAccountCommandDeps } from './commands.js';
|
|
36
|
+
export type { AccountResponse, ChangeAccountPasswordRequest, GetAccountRequest, OkResponse, UpdateAccountRequest, } from './schemas.js';
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-account/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,sBAAsB,EACtB,0CAA0C,EAC1C,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,qBAAqB,EACrB,kCAAkC,EAClC,uBAAuB,EACvB,gBAAgB,EAChB,0BAA0B,GAC3B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAC5D,YAAY,EACV,eAAe,EACf,4BAA4B,EAC5B,iBAAiB,EACjB,UAAU,EACV,oBAAoB,GACrB,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* `@byline/admin/admin-account` — self-service surfaces for the currently
|
|
10
|
+
* signed-in admin user.
|
|
11
|
+
*
|
|
12
|
+
* Distinct from `@byline/admin/admin-users` in two ways:
|
|
13
|
+
*
|
|
14
|
+
* 1. The actor IS the target. Commands take no `id` field — the
|
|
15
|
+
* target is sourced from `actor.id` on the authenticated
|
|
16
|
+
* `RequestContext`. There is no way at the command surface to
|
|
17
|
+
* ask "operate on someone else."
|
|
18
|
+
* 2. There is no ability gate. The other admin modules use
|
|
19
|
+
* `assertAdminActor(context, ability)`; this module uses
|
|
20
|
+
* `requireAdminActor(context)` — authn-only. "Anyone may change
|
|
21
|
+
* their own password" is the policy.
|
|
22
|
+
*
|
|
23
|
+
* Reuses `AdminUsersRepository` from `@byline/admin/admin-users` rather
|
|
24
|
+
* than introducing a parallel repo — the table is the same and the
|
|
25
|
+
* narrower self-service surface is structural rather than physical.
|
|
26
|
+
*
|
|
27
|
+
* Active-session listing / revocation is intentionally not included
|
|
28
|
+
* yet — that depends on `RefreshTokensRepository` semantics and a
|
|
29
|
+
* "sign out everywhere on password change" follow-up.
|
|
30
|
+
*/
|
|
31
|
+
export { changeAccountPasswordCommand, getAccountCommand, updateAccountCommand, } from './commands.js';
|
|
32
|
+
export { AdminAccountError, AdminAccountErrorCodes, ERR_ADMIN_ACCOUNT_INVALID_CURRENT_PASSWORD, ERR_ADMIN_ACCOUNT_NOT_FOUND, } from './errors.js';
|
|
33
|
+
export { accountResponseSchema, changeAccountPasswordRequestSchema, getAccountRequestSchema, okResponseSchema, updateAccountRequestSchema, } from './schemas.js';
|
|
34
|
+
export { AdminAccountService } from './service.js';
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/admin-account/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,iBAAiB,EAEjB,sBAAsB,EACtB,0CAA0C,EAC1C,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,qBAAqB,EACrB,kCAAkC,EAClC,uBAAuB,EACvB,gBAAgB,EAChB,0BAA0B,GAC3B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { adminUserResponseSchema, okResponseSchema } from '../admin-users/schemas.js';
|
|
10
|
+
/** No payload — target is the actor on context. */
|
|
11
|
+
export declare const getAccountRequestSchema: z.ZodObject<{}, z.core.$strict>;
|
|
12
|
+
export type GetAccountRequest = z.infer<typeof getAccountRequestSchema>;
|
|
13
|
+
export declare const updateAccountRequestSchema: z.ZodObject<{
|
|
14
|
+
vid: z.ZodNumber;
|
|
15
|
+
patch: z.ZodObject<{
|
|
16
|
+
email: z.ZodOptional<z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>>;
|
|
17
|
+
given_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
family_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
19
|
+
username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type UpdateAccountRequest = z.infer<typeof updateAccountRequestSchema>;
|
|
23
|
+
export declare const changeAccountPasswordRequestSchema: z.ZodObject<{
|
|
24
|
+
vid: z.ZodNumber;
|
|
25
|
+
currentPassword: z.ZodString;
|
|
26
|
+
newPassword: z.ZodString;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type ChangeAccountPasswordRequest = z.infer<typeof changeAccountPasswordRequestSchema>;
|
|
29
|
+
export { adminUserResponseSchema as accountResponseSchema, okResponseSchema };
|
|
30
|
+
export type { AdminUserResponse as AccountResponse, OkResponse } from '../admin-users/schemas.js';
|
|
31
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-account/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2BH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAmBrF,mDAAmD;AACnD,eAAO,MAAM,uBAAuB,iCAAwB,CAAA;AAC5D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE,eAAO,MAAM,0BAA0B;;;;;;;;iBAUrC,CAAA;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E,eAAO,MAAM,kCAAkC;;;;iBAI7C,CAAA;AACF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAM7F,OAAO,EAAE,uBAAuB,IAAI,qBAAqB,EAAE,gBAAgB,EAAE,CAAA;AAC7E,YAAY,EAAE,iBAAiB,IAAI,eAAe,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Zod schemas for the admin-account commands.
|
|
10
|
+
*
|
|
11
|
+
* Self-service is intentionally narrower than admin-users:
|
|
12
|
+
*
|
|
13
|
+
* - The actor IS the target. None of the request schemas accept an
|
|
14
|
+
* `id` field — the command resolves the target from
|
|
15
|
+
* `actor.id`. Persisting `id` in the request shape would
|
|
16
|
+
* immediately invite "but what if I pass someone else's id?"
|
|
17
|
+
* mistakes downstream.
|
|
18
|
+
* - The update patch excludes `is_super_admin`, `is_enabled`, and
|
|
19
|
+
* `is_email_verified`. Self-service must never let a user grant
|
|
20
|
+
* themselves super-admin or flip their own enabled state. Those
|
|
21
|
+
* fields stay editable through the admin-users module by an admin
|
|
22
|
+
* who holds the relevant ability.
|
|
23
|
+
* - `changePassword` requires the *current* password as a defence
|
|
24
|
+
* against session-hijack abuse: an attacker with a stolen session
|
|
25
|
+
* cookie still needs the password they don't have to swap it out.
|
|
26
|
+
*
|
|
27
|
+
* The response shape is the same as `adminUserResponseSchema` so the
|
|
28
|
+
* admin-account UI and the admin-users UI render the same row shape
|
|
29
|
+
* — re-exported here for convenience.
|
|
30
|
+
*/
|
|
31
|
+
import { passwordSchema } from '@byline/core/validation';
|
|
32
|
+
import { z } from 'zod';
|
|
33
|
+
import { adminUserResponseSchema, okResponseSchema } from '../admin-users/schemas.js';
|
|
34
|
+
const vidSchema = z
|
|
35
|
+
.number({ message: 'vid is required' })
|
|
36
|
+
.int({ message: 'vid must be an integer' })
|
|
37
|
+
.positive({ message: 'vid must be positive' });
|
|
38
|
+
const emailSchema = z
|
|
39
|
+
.email({ message: 'email must be a valid address' })
|
|
40
|
+
.min(3)
|
|
41
|
+
.max(254)
|
|
42
|
+
.transform((v) => v.toLowerCase());
|
|
43
|
+
const nameSchema = z.string().min(1).max(100);
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Requests
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
/** No payload — target is the actor on context. */
|
|
48
|
+
export const getAccountRequestSchema = z.object({}).strict();
|
|
49
|
+
export const updateAccountRequestSchema = z.object({
|
|
50
|
+
vid: vidSchema,
|
|
51
|
+
patch: z
|
|
52
|
+
.object({
|
|
53
|
+
email: emailSchema.optional(),
|
|
54
|
+
given_name: nameSchema.nullish(),
|
|
55
|
+
family_name: nameSchema.nullish(),
|
|
56
|
+
username: z.string().min(1).max(100).nullish(),
|
|
57
|
+
})
|
|
58
|
+
.refine((p) => Object.keys(p).length > 0, { message: 'patch cannot be empty' }),
|
|
59
|
+
});
|
|
60
|
+
export const changeAccountPasswordRequestSchema = z.object({
|
|
61
|
+
vid: vidSchema,
|
|
62
|
+
currentPassword: z.string().min(1, { message: 'current password is required' }),
|
|
63
|
+
newPassword: passwordSchema,
|
|
64
|
+
});
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// Responses (re-exports — same shape as the admin-users module)
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
export { adminUserResponseSchema as accountResponseSchema, okResponseSchema };
|
|
69
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/modules/admin-account/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAErF,MAAM,SAAS,GAAG,CAAC;KAChB,MAAM,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;KACtC,GAAG,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;KAC1C,QAAQ,CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC,CAAA;AAEhD,MAAM,WAAW,GAAG,CAAC;KAClB,KAAK,CAAC,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC;KACnD,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AAEpC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAE7C,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAE9E,mDAAmD;AACnD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAA;AAG5D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,CAAC;SACL,MAAM,CAAC;QACN,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE;QAC7B,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE;QAChC,WAAW,EAAE,UAAU,CAAC,OAAO,EAAE;QACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE;KAC/C,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;CAClF,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC;IACzD,GAAG,EAAE,SAAS;IACd,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC;IAC/E,WAAW,EAAE,cAAc;CAC5B,CAAC,CAAA;AAGF,8EAA8E;AAC9E,gEAAgE;AAChE,8EAA8E;AAE9E,OAAO,EAAE,uBAAuB,IAAI,qBAAqB,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import type { AdminUsersRepository } from '../admin-users/repository.js';
|
|
9
|
+
import type { AccountResponse, ChangeAccountPasswordRequest, UpdateAccountRequest } from './schemas.js';
|
|
10
|
+
/**
|
|
11
|
+
* Self-service business logic for the currently signed-in admin user.
|
|
12
|
+
*
|
|
13
|
+
* Reuses `AdminUsersRepository` rather than introducing a parallel
|
|
14
|
+
* repository — the underlying table is the same, and self-service is
|
|
15
|
+
* just a narrower surface over it. The narrowing is structural:
|
|
16
|
+
*
|
|
17
|
+
* - Every method takes `actorId` (sourced server-side from the
|
|
18
|
+
* authenticated `RequestContext`) and uses it as the target id.
|
|
19
|
+
* Callers cannot supply a target id; commands look it up from
|
|
20
|
+
* `actor.id` and pass it in.
|
|
21
|
+
* - `updateAccount` excludes `is_super_admin`, `is_enabled`, and
|
|
22
|
+
* `is_email_verified` from the writable surface. The schema
|
|
23
|
+
* already strips them, but the service signature reinforces it.
|
|
24
|
+
* - `changePassword` verifies the *current* password before swapping
|
|
25
|
+
* in the new hash. A hijacked session cannot use this flow to lock
|
|
26
|
+
* out the legitimate owner.
|
|
27
|
+
*
|
|
28
|
+
* Note on session revocation: changing a password here does **not**
|
|
29
|
+
* currently revoke other refresh tokens — existing access tokens stay
|
|
30
|
+
* valid until their 15-minute expiry, and other refresh tokens remain
|
|
31
|
+
* useable. A "sign out everywhere on password change" follow-up should
|
|
32
|
+
* call `RefreshTokensRepository.revokeAllExcept(adminUserId, currentJti)`
|
|
33
|
+
* once that lands.
|
|
34
|
+
*/
|
|
35
|
+
export declare class AdminAccountService {
|
|
36
|
+
#private;
|
|
37
|
+
constructor(deps: {
|
|
38
|
+
repo: AdminUsersRepository;
|
|
39
|
+
});
|
|
40
|
+
getAccount(actorId: string): Promise<AccountResponse>;
|
|
41
|
+
updateAccount(actorId: string, request: UpdateAccountRequest): Promise<AccountResponse>;
|
|
42
|
+
changePassword(actorId: string, request: ChangeAccountPasswordRequest): Promise<AccountResponse>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-account/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,KAAK,EACV,eAAe,EACf,4BAA4B,EAC5B,oBAAoB,EACrB,MAAM,cAAc,CAAA;AAErB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,mBAAmB;;gBAGlB,IAAI,EAAE;QAAE,IAAI,EAAE,oBAAoB,CAAA;KAAE;IAI1C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAMrD,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IAavF,cAAc,CAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,eAAe,CAAC;CAe5B"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import { toAdminUser } from '../admin-users/dto.js';
|
|
9
|
+
import { ERR_ADMIN_USER_EMAIL_IN_USE } from '../admin-users/errors.js';
|
|
10
|
+
import { hashPassword, verifyPassword } from '../auth/password.js';
|
|
11
|
+
import { ERR_ADMIN_ACCOUNT_INVALID_CURRENT_PASSWORD, ERR_ADMIN_ACCOUNT_NOT_FOUND, } from './errors.js';
|
|
12
|
+
/**
|
|
13
|
+
* Self-service business logic for the currently signed-in admin user.
|
|
14
|
+
*
|
|
15
|
+
* Reuses `AdminUsersRepository` rather than introducing a parallel
|
|
16
|
+
* repository — the underlying table is the same, and self-service is
|
|
17
|
+
* just a narrower surface over it. The narrowing is structural:
|
|
18
|
+
*
|
|
19
|
+
* - Every method takes `actorId` (sourced server-side from the
|
|
20
|
+
* authenticated `RequestContext`) and uses it as the target id.
|
|
21
|
+
* Callers cannot supply a target id; commands look it up from
|
|
22
|
+
* `actor.id` and pass it in.
|
|
23
|
+
* - `updateAccount` excludes `is_super_admin`, `is_enabled`, and
|
|
24
|
+
* `is_email_verified` from the writable surface. The schema
|
|
25
|
+
* already strips them, but the service signature reinforces it.
|
|
26
|
+
* - `changePassword` verifies the *current* password before swapping
|
|
27
|
+
* in the new hash. A hijacked session cannot use this flow to lock
|
|
28
|
+
* out the legitimate owner.
|
|
29
|
+
*
|
|
30
|
+
* Note on session revocation: changing a password here does **not**
|
|
31
|
+
* currently revoke other refresh tokens — existing access tokens stay
|
|
32
|
+
* valid until their 15-minute expiry, and other refresh tokens remain
|
|
33
|
+
* useable. A "sign out everywhere on password change" follow-up should
|
|
34
|
+
* call `RefreshTokensRepository.revokeAllExcept(adminUserId, currentJti)`
|
|
35
|
+
* once that lands.
|
|
36
|
+
*/
|
|
37
|
+
export class AdminAccountService {
|
|
38
|
+
#repo;
|
|
39
|
+
constructor(deps) {
|
|
40
|
+
this.#repo = deps.repo;
|
|
41
|
+
}
|
|
42
|
+
async getAccount(actorId) {
|
|
43
|
+
const row = await this.#repo.getById(actorId);
|
|
44
|
+
if (!row)
|
|
45
|
+
throw ERR_ADMIN_ACCOUNT_NOT_FOUND();
|
|
46
|
+
return toAdminUser(row);
|
|
47
|
+
}
|
|
48
|
+
async updateAccount(actorId, request) {
|
|
49
|
+
const current = await this.#repo.getById(actorId);
|
|
50
|
+
if (!current)
|
|
51
|
+
throw ERR_ADMIN_ACCOUNT_NOT_FOUND();
|
|
52
|
+
if (request.patch.email != null && request.patch.email !== current.email) {
|
|
53
|
+
const owner = await this.#repo.getByEmail(request.patch.email);
|
|
54
|
+
if (owner && owner.id !== actorId)
|
|
55
|
+
throw ERR_ADMIN_USER_EMAIL_IN_USE();
|
|
56
|
+
}
|
|
57
|
+
const row = await this.#repo.update(actorId, request.vid, request.patch);
|
|
58
|
+
return toAdminUser(row);
|
|
59
|
+
}
|
|
60
|
+
async changePassword(actorId, request) {
|
|
61
|
+
// Pull the row *with* the password hash so we can verify the
|
|
62
|
+
// supplied current password before persisting a new one. The
|
|
63
|
+
// sign-in-shaped row is treated as ephemeral here — the hash
|
|
64
|
+
// string is never propagated outside this method.
|
|
65
|
+
const withHash = await this.#repo.getByIdForSignIn(actorId);
|
|
66
|
+
if (!withHash)
|
|
67
|
+
throw ERR_ADMIN_ACCOUNT_NOT_FOUND();
|
|
68
|
+
const ok = await verifyPassword(request.currentPassword, withHash.password_hash);
|
|
69
|
+
if (!ok)
|
|
70
|
+
throw ERR_ADMIN_ACCOUNT_INVALID_CURRENT_PASSWORD();
|
|
71
|
+
const newHash = await hashPassword(request.newPassword);
|
|
72
|
+
const row = await this.#repo.setPasswordHash(actorId, request.vid, newHash);
|
|
73
|
+
return toAdminUser(row);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/modules/admin-account/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EACL,0CAA0C,EAC1C,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAQpB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,mBAAmB;IACrB,KAAK,CAAsB;IAEpC,YAAY,IAAoC;QAC9C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC7C,IAAI,CAAC,GAAG;YAAE,MAAM,2BAA2B,EAAE,CAAA;QAC7C,OAAO,WAAW,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAe,EAAE,OAA6B;QAChE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QACjD,IAAI,CAAC,OAAO;YAAE,MAAM,2BAA2B,EAAE,CAAA;QAEjD,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC;YACzE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAC9D,IAAI,KAAK,IAAI,KAAK,CAAC,EAAE,KAAK,OAAO;gBAAE,MAAM,2BAA2B,EAAE,CAAA;QACxE,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;QACxE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,OAAe,EACf,OAAqC;QAErC,6DAA6D;QAC7D,6DAA6D;QAC7D,6DAA6D;QAC7D,kDAAkD;QAClD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;QAC3D,IAAI,CAAC,QAAQ;YAAE,MAAM,2BAA2B,EAAE,CAAA;QAElD,MAAM,EAAE,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAA;QAChF,IAAI,CAAC,EAAE;YAAE,MAAM,0CAA0C,EAAE,CAAA;QAE3D,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QACvD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC3E,OAAO,WAAW,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import type { AbilityRegistry } from '@byline/auth';
|
|
9
|
+
/**
|
|
10
|
+
* Ability keys for the admin-permissions module.
|
|
11
|
+
*
|
|
12
|
+
* `read` gates the inspector view (Phase 8 in AUTHN-AUTHZ-ANALYSIS.md).
|
|
13
|
+
* `update` will gate the per-role ability editor mounted on the
|
|
14
|
+
* admin-roles role detail page — declared here so the role editor can
|
|
15
|
+
* assert against it once that surface lands. The per-role editor shares
|
|
16
|
+
* the `update` key rather than minting `grant` / `revoke` keys: granting
|
|
17
|
+
* abilities to a role is a single editorial operation from the admin's
|
|
18
|
+
* perspective, and a granular split would force a redundant key on
|
|
19
|
+
* every permission-managing role.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ADMIN_PERMISSIONS_ABILITIES: {
|
|
22
|
+
readonly read: "admin.permissions.read";
|
|
23
|
+
readonly update: "admin.permissions.update";
|
|
24
|
+
};
|
|
25
|
+
export type AdminPermissionsAbilityKey = (typeof ADMIN_PERMISSIONS_ABILITIES)[keyof typeof ADMIN_PERMISSIONS_ABILITIES];
|
|
26
|
+
export declare function registerAdminPermissionsAbilities(registry: AbilityRegistry): void;
|
|
27
|
+
//# sourceMappingURL=abilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abilities.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-permissions/abilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B;;;CAG9B,CAAA;AAEV,MAAM,MAAM,0BAA0B,GACpC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,OAAO,2BAA2B,CAAC,CAAA;AAEhF,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAejF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Ability keys for the admin-permissions module.
|
|
10
|
+
*
|
|
11
|
+
* `read` gates the inspector view (Phase 8 in AUTHN-AUTHZ-ANALYSIS.md).
|
|
12
|
+
* `update` will gate the per-role ability editor mounted on the
|
|
13
|
+
* admin-roles role detail page — declared here so the role editor can
|
|
14
|
+
* assert against it once that surface lands. The per-role editor shares
|
|
15
|
+
* the `update` key rather than minting `grant` / `revoke` keys: granting
|
|
16
|
+
* abilities to a role is a single editorial operation from the admin's
|
|
17
|
+
* perspective, and a granular split would force a redundant key on
|
|
18
|
+
* every permission-managing role.
|
|
19
|
+
*/
|
|
20
|
+
export const ADMIN_PERMISSIONS_ABILITIES = {
|
|
21
|
+
read: 'admin.permissions.read',
|
|
22
|
+
update: 'admin.permissions.update',
|
|
23
|
+
};
|
|
24
|
+
export function registerAdminPermissionsAbilities(registry) {
|
|
25
|
+
registry.register({
|
|
26
|
+
key: ADMIN_PERMISSIONS_ABILITIES.read,
|
|
27
|
+
label: 'Read admin permissions',
|
|
28
|
+
description: 'View the abilities inspector and per-role ability grants.',
|
|
29
|
+
group: 'admin.permissions',
|
|
30
|
+
source: 'admin',
|
|
31
|
+
});
|
|
32
|
+
registry.register({
|
|
33
|
+
key: ADMIN_PERMISSIONS_ABILITIES.update,
|
|
34
|
+
label: 'Update admin permissions',
|
|
35
|
+
description: "Edit a role's ability grants.",
|
|
36
|
+
group: 'admin.permissions',
|
|
37
|
+
source: 'admin',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=abilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abilities.js","sourceRoot":"","sources":["../../../src/modules/admin-permissions/abilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,wBAAwB;IAC9B,MAAM,EAAE,0BAA0B;CAC1B,CAAA;AAKV,MAAM,UAAU,iCAAiC,CAAC,QAAyB;IACzE,QAAQ,CAAC,QAAQ,CAAC;QAChB,GAAG,EAAE,2BAA2B,CAAC,IAAI;QACrC,KAAK,EAAE,wBAAwB;QAC/B,WAAW,EAAE,2DAA2D;QACxE,KAAK,EAAE,mBAAmB;QAC1B,MAAM,EAAE,OAAO;KAChB,CAAC,CAAA;IACF,QAAQ,CAAC,QAAQ,CAAC;QAChB,GAAG,EAAE,2BAA2B,CAAC,MAAM;QACvC,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,+BAA+B;QAC5C,KAAK,EAAE,mBAAmB;QAC1B,MAAM,EAAE,OAAO;KAChB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import type { AbilityRegistry, RequestContext } from '@byline/auth';
|
|
9
|
+
import type { AdminStore } from '../../store.js';
|
|
10
|
+
import type { GetRoleAbilitiesResponse, ListRegisteredAbilitiesResponse, SetRoleAbilitiesResponse, WhoHasAbilityResponse } from './schemas.js';
|
|
11
|
+
/**
|
|
12
|
+
* Transport-agnostic commands for the admin-permissions inspector.
|
|
13
|
+
*
|
|
14
|
+
* Same four-step shape as the other modules — Zod-validate, assert the
|
|
15
|
+
* admin actor + ability, call the service, validate the output. The
|
|
16
|
+
* inspector commands all gate on `admin.permissions.read`.
|
|
17
|
+
*
|
|
18
|
+
* Deps include the `AbilityRegistry` alongside the `AdminStore` because
|
|
19
|
+
* the inspector reads the registered abilities directly from the
|
|
20
|
+
* registry (no DB). The webapp threads `bylineCore.abilities` in.
|
|
21
|
+
*/
|
|
22
|
+
export interface AdminPermissionsCommandDeps {
|
|
23
|
+
store: AdminStore;
|
|
24
|
+
abilities: AbilityRegistry;
|
|
25
|
+
}
|
|
26
|
+
export declare function listRegisteredAbilitiesCommand(context: RequestContext | undefined, input: unknown, deps: AdminPermissionsCommandDeps): Promise<ListRegisteredAbilitiesResponse>;
|
|
27
|
+
export declare function whoHasAbilityCommand(context: RequestContext | undefined, input: unknown, deps: AdminPermissionsCommandDeps): Promise<WhoHasAbilityResponse>;
|
|
28
|
+
export declare function getRoleAbilitiesCommand(context: RequestContext | undefined, input: unknown, deps: AdminPermissionsCommandDeps): Promise<GetRoleAbilitiesResponse>;
|
|
29
|
+
export declare function setRoleAbilitiesCommand(context: RequestContext | undefined, input: unknown, deps: AdminPermissionsCommandDeps): Promise<SetRoleAbilitiesResponse>;
|
|
30
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-permissions/commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAenE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EACV,wBAAwB,EACxB,+BAA+B,EAC/B,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,cAAc,CAAA;AAErB;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,UAAU,CAAA;IACjB,SAAS,EAAE,eAAe,CAAA;CAC3B;AAMD,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,+BAA+B,CAAC,CAK1C;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,qBAAqB,CAAC,CAKhC;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,wBAAwB,CAAC,CAKnC;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,wBAAwB,CAAC,CAKnC"}
|