@simple-auth-kit/cli 1.5.1 → 1.6.1
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/package.json +1 -1
- package/registry/combos/express-drizzle/shared/src/{ability.ts → ability/ability.ts} +8 -2
- package/registry/combos/express-drizzle/shared/src/{permission-cache.ts → cache/permission-cache.ts} +25 -9
- package/registry/combos/express-drizzle/shared/src/{rate-limit.store.ts → cache/rate-limit.store.ts} +4 -1
- package/registry/combos/{express-prisma/shared/src → express-drizzle/shared/src/config}/auth.config.ts +1 -1
- package/registry/combos/express-drizzle/shared/src/{db.ts → config/db.ts} +1 -1
- package/registry/combos/express-drizzle/shared/src/{key-provider.ts → config/key-provider.ts} +6 -2
- package/registry/combos/express-drizzle/shared/src/{id.helper.ts → helpers/id.helper.ts} +6 -2
- package/registry/combos/{nestjs-drizzle/shared/src → express-drizzle/shared/src/helpers}/pagination.ts +17 -3
- package/registry/combos/express-drizzle/shared/src/middleware/auth-core-error.middleware.ts +6 -8
- package/registry/combos/express-drizzle/shared/src/middleware/auth.middleware.ts +6 -8
- package/registry/combos/{express-prisma/shared/src → express-drizzle/shared/src/openapi}/openapi-fragment.ts +13 -4
- package/registry/combos/express-drizzle/shared/src/{openapi-spec.ts → openapi/openapi-spec.ts} +251 -52
- package/registry/combos/express-drizzle/shared/src/repositories/oauth.repository.ts +2 -2
- package/registry/combos/express-drizzle/shared/src/repositories/password-reset.repository.ts +2 -4
- package/registry/combos/express-drizzle/shared/src/repositories/session.repository.ts +3 -3
- package/registry/combos/express-drizzle/shared/src/request-context.ts +1 -1
- package/registry/combos/express-drizzle/shared/src/route-tiers.ts +52 -11
- package/registry/combos/express-drizzle/shared/src/routers/auth.router.ts +2 -2
- package/registry/combos/express-drizzle/test/bootstrap.ts +4 -2
- package/registry/combos/express-drizzle/test/prove-cycle.ts +1095 -308
- package/registry/combos/express-drizzle/variants/base/src/create-auth-app.ts +5 -5
- package/registry/combos/express-drizzle/variants/base/src/index.ts +8 -0
- package/registry/combos/express-drizzle/variants/base/src/middleware/authz.middleware.ts +2 -2
- package/registry/combos/express-drizzle/variants/base/src/openapi/openapi-admin.ts +1082 -0
- package/registry/combos/express-drizzle/variants/base/src/rbac.defaults.ts +60 -17
- package/registry/combos/express-drizzle/variants/base/src/repositories/audit-log.repository.ts +2 -2
- package/registry/combos/express-drizzle/variants/base/src/repositories/rbac.repository.ts +5 -5
- package/registry/combos/express-drizzle/variants/base/src/routers/admin.router.ts +18 -22
- package/registry/combos/express-drizzle/variants/base/src/seed.ts +76 -17
- package/registry/combos/express-drizzle/variants/base/src/services/auth.service.ts +7 -9
- package/registry/combos/express-drizzle/variants/base/test/variant-hooks.ts +167 -45
- package/registry/combos/express-drizzle/variants/workspaces/src/create-auth-app.ts +5 -5
- package/registry/combos/express-drizzle/variants/workspaces/src/index.ts +8 -0
- package/registry/combos/express-drizzle/variants/workspaces/src/middleware/authz.middleware.ts +3 -3
- package/registry/combos/express-drizzle/variants/workspaces/src/openapi/openapi-admin.ts +1176 -0
- package/registry/combos/express-drizzle/variants/workspaces/src/openapi-workspace.ts +1 -1
- package/registry/combos/express-drizzle/variants/workspaces/src/rbac.defaults.ts +66 -19
- package/registry/combos/express-drizzle/variants/workspaces/src/repositories/audit-log.repository.ts +2 -2
- package/registry/combos/express-drizzle/variants/workspaces/src/repositories/rbac.repository.ts +5 -5
- package/registry/combos/express-drizzle/variants/workspaces/src/repositories/workspace.repository.ts +9 -11
- package/registry/combos/express-drizzle/variants/workspaces/src/routers/admin.router.ts +18 -22
- package/registry/combos/express-drizzle/variants/workspaces/src/routers/workspace.router.ts +1 -1
- package/registry/combos/express-drizzle/variants/workspaces/src/seed.ts +168 -35
- package/registry/combos/express-drizzle/variants/workspaces/src/services/auth.service.ts +7 -9
- package/registry/combos/express-drizzle/variants/workspaces/test/variant-hooks.ts +539 -133
- package/registry/combos/express-prisma/shared/src/{ability.ts → ability/ability.ts} +8 -2
- package/registry/combos/express-prisma/shared/src/{permission-cache.ts → cache/permission-cache.ts} +25 -9
- package/registry/combos/express-prisma/shared/src/{rate-limit.store.ts → cache/rate-limit.store.ts} +4 -1
- package/registry/combos/{express-drizzle/shared/src → express-prisma/shared/src/config}/auth.config.ts +1 -1
- package/registry/combos/express-prisma/shared/src/{key-provider.ts → config/key-provider.ts} +6 -2
- package/registry/combos/{nestjs-prisma/shared/src → express-prisma/shared/src/helpers}/id.helper.ts +6 -2
- package/registry/combos/{express-drizzle/shared/src → express-prisma/shared/src/helpers}/pagination.ts +17 -3
- package/registry/combos/express-prisma/shared/src/middleware/auth-core-error.middleware.ts +6 -8
- package/registry/combos/express-prisma/shared/src/middleware/auth.middleware.ts +6 -8
- package/registry/combos/{express-drizzle/shared/src → express-prisma/shared/src/openapi}/openapi-fragment.ts +13 -4
- package/registry/combos/express-prisma/shared/src/{openapi-spec.ts → openapi/openapi-spec.ts} +313 -55
- package/registry/combos/express-prisma/shared/src/repositories/oauth.repository.ts +2 -2
- package/registry/combos/express-prisma/shared/src/repositories/password-reset.repository.ts +2 -4
- package/registry/combos/express-prisma/shared/src/repositories/session.repository.ts +2 -2
- package/registry/combos/express-prisma/shared/src/request-context.ts +1 -1
- package/registry/combos/express-prisma/shared/src/route-tiers.ts +52 -11
- package/registry/combos/express-prisma/shared/src/routers/auth.router.ts +2 -2
- package/registry/combos/express-prisma/test/bootstrap.ts +7 -3
- package/registry/combos/express-prisma/test/prove-cycle.ts +1095 -308
- package/registry/combos/express-prisma/variants/base/src/create-auth-app.ts +6 -6
- package/registry/combos/express-prisma/variants/base/src/index.ts +8 -0
- package/registry/combos/express-prisma/variants/base/src/middleware/authz.middleware.ts +2 -2
- package/registry/combos/express-prisma/variants/base/src/openapi/openapi-admin.ts +1102 -0
- package/registry/combos/express-prisma/variants/base/src/rbac.defaults.ts +1 -1
- package/registry/combos/express-prisma/variants/base/src/repositories/audit-log.repository.ts +2 -2
- package/registry/combos/express-prisma/variants/base/src/repositories/rbac.repository.ts +4 -4
- package/registry/combos/express-prisma/variants/base/src/routers/admin.router.ts +18 -22
- package/registry/combos/express-prisma/variants/base/src/seed.ts +1 -1
- package/registry/combos/express-prisma/variants/base/src/services/auth.service.ts +6 -8
- package/registry/combos/express-prisma/variants/base/test/variant-hooks.ts +176 -47
- package/registry/combos/express-prisma/variants/workspaces/src/create-auth-app.ts +6 -6
- package/registry/combos/express-prisma/variants/workspaces/src/index.ts +8 -0
- package/registry/combos/express-prisma/variants/workspaces/src/middleware/authz.middleware.ts +3 -3
- package/registry/combos/express-prisma/variants/workspaces/src/openapi/openapi-admin.ts +1218 -0
- package/registry/combos/express-prisma/variants/workspaces/src/openapi-workspace.ts +1 -1
- package/registry/combos/express-prisma/variants/workspaces/src/rbac.defaults.ts +1 -1
- package/registry/combos/express-prisma/variants/workspaces/src/repositories/audit-log.repository.ts +2 -2
- package/registry/combos/express-prisma/variants/workspaces/src/repositories/rbac.repository.ts +4 -4
- package/registry/combos/express-prisma/variants/workspaces/src/repositories/workspace.repository.ts +2 -2
- package/registry/combos/express-prisma/variants/workspaces/src/routers/admin.router.ts +18 -22
- package/registry/combos/express-prisma/variants/workspaces/src/routers/workspace.router.ts +1 -1
- package/registry/combos/express-prisma/variants/workspaces/src/seed.ts +1 -1
- package/registry/combos/express-prisma/variants/workspaces/src/services/auth.service.ts +6 -8
- package/registry/combos/express-prisma/variants/workspaces/test/variant-hooks.ts +538 -134
- package/registry/combos/nestjs-drizzle/shared/src/{guards → ability}/ability.guard.ts +1 -1
- package/registry/combos/nestjs-drizzle/shared/src/{ability.ts → ability/ability.ts} +8 -2
- package/registry/combos/nestjs-drizzle/shared/src/{permission-cache.ts → cache/permission-cache.ts} +27 -10
- package/registry/combos/{nestjs-prisma/shared/src → nestjs-drizzle/shared/src/cache}/rate-limit.store.ts +4 -1
- package/registry/combos/nestjs-drizzle/shared/src/{auth.config.ts → config/auth.config.ts} +1 -1
- package/registry/combos/nestjs-drizzle/shared/src/{db.ts → config/db.ts} +1 -1
- package/registry/combos/nestjs-drizzle/shared/src/{key-provider.ts → config/key-provider.ts} +6 -2
- package/registry/combos/nestjs-drizzle/shared/src/controllers/auth.controller.ts +1 -1
- package/registry/combos/nestjs-drizzle/shared/src/guards/auth.guard.ts +1 -1
- package/registry/combos/nestjs-drizzle/shared/src/{id.helper.ts → helpers/id.helper.ts} +6 -2
- package/registry/combos/{express-prisma/shared/src → nestjs-drizzle/shared/src/helpers}/pagination.ts +17 -3
- package/registry/combos/nestjs-drizzle/shared/src/repositories/oauth.repository.ts +2 -2
- package/registry/combos/nestjs-drizzle/shared/src/repositories/password-reset.repository.ts +8 -12
- package/registry/combos/nestjs-drizzle/shared/src/repositories/session.repository.ts +3 -3
- package/registry/combos/nestjs-drizzle/shared/src/repositories/two-factor.repository.ts +1 -1
- package/registry/combos/nestjs-drizzle/shared/src/request-context.ts +1 -1
- package/registry/combos/nestjs-drizzle/test/bootstrap.ts +1 -1
- package/registry/combos/nestjs-drizzle/test/prove-cycle.ts +1 -1
- package/registry/combos/nestjs-drizzle/variants/base/src/auth.module.ts +10 -6
- package/registry/combos/nestjs-drizzle/variants/base/src/controllers/admin.controller.ts +1 -1
- package/registry/combos/nestjs-drizzle/variants/base/src/guards/authz.guard.ts +2 -2
- package/registry/combos/nestjs-drizzle/variants/base/src/index.ts +9 -0
- package/registry/combos/nestjs-drizzle/variants/base/src/rbac.defaults.ts +58 -16
- package/registry/combos/nestjs-drizzle/variants/base/src/repositories/audit-log.repository.ts +3 -3
- package/registry/combos/nestjs-drizzle/variants/base/src/repositories/rbac.repository.ts +4 -4
- package/registry/combos/nestjs-drizzle/variants/base/src/seed.ts +76 -17
- package/registry/combos/nestjs-drizzle/variants/base/src/services/auth.service.ts +7 -9
- package/registry/combos/nestjs-drizzle/variants/base/test/variant-hooks.ts +167 -45
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/auth.module.ts +10 -6
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/controllers/admin.controller.ts +1 -1
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/controllers/workspace.controller.ts +1 -1
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/guards/authz.guard.ts +2 -2
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/index.ts +9 -0
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/rbac.defaults.ts +64 -18
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/repositories/audit-log.repository.ts +3 -3
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/repositories/rbac.repository.ts +4 -4
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/repositories/workspace.repository.ts +8 -10
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/seed.ts +171 -36
- package/registry/combos/nestjs-drizzle/variants/workspaces/src/services/auth.service.ts +7 -9
- package/registry/combos/nestjs-drizzle/variants/workspaces/test/variant-hooks.ts +539 -133
- package/registry/combos/nestjs-prisma/shared/src/{guards → ability}/ability.guard.ts +1 -1
- package/registry/combos/nestjs-prisma/shared/src/{ability.ts → ability/ability.ts} +8 -2
- package/registry/combos/nestjs-prisma/shared/src/{permission-cache.ts → cache/permission-cache.ts} +27 -10
- package/registry/combos/{nestjs-drizzle/shared/src → nestjs-prisma/shared/src/cache}/rate-limit.store.ts +4 -1
- package/registry/combos/nestjs-prisma/shared/src/{auth.config.ts → config/auth.config.ts} +1 -1
- package/registry/combos/nestjs-prisma/shared/src/{key-provider.ts → config/key-provider.ts} +6 -2
- package/registry/combos/nestjs-prisma/shared/src/controllers/auth.controller.ts +1 -1
- package/registry/combos/nestjs-prisma/shared/src/guards/auth.guard.ts +1 -1
- package/registry/combos/{express-prisma/shared/src → nestjs-prisma/shared/src/helpers}/id.helper.ts +6 -2
- package/registry/combos/nestjs-prisma/shared/src/{pagination.ts → helpers/pagination.ts} +17 -3
- package/registry/combos/nestjs-prisma/shared/src/repositories/oauth.repository.ts +1 -1
- package/registry/combos/nestjs-prisma/shared/src/repositories/password-reset.repository.ts +2 -4
- package/registry/combos/nestjs-prisma/shared/src/repositories/session.repository.ts +2 -2
- package/registry/combos/nestjs-prisma/shared/src/request-context.ts +1 -1
- package/registry/combos/nestjs-prisma/test/bootstrap.ts +1 -1
- package/registry/combos/nestjs-prisma/test/prove-cycle.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/base/src/auth.module.ts +10 -6
- package/registry/combos/nestjs-prisma/variants/base/src/controllers/admin.controller.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/base/src/gateways/audit-log.gateway.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/base/src/guards/authz.guard.ts +2 -2
- package/registry/combos/nestjs-prisma/variants/base/src/index.ts +9 -0
- package/registry/combos/nestjs-prisma/variants/base/src/{docs.ts → openapi/docs.ts} +23 -6
- package/registry/combos/nestjs-prisma/variants/base/src/rbac.defaults.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/base/src/repositories/audit-log.repository.ts +2 -2
- package/registry/combos/nestjs-prisma/variants/base/src/repositories/country.repository.ts +2 -2
- package/registry/combos/nestjs-prisma/variants/base/src/repositories/customer.repository.ts +6 -5
- package/registry/combos/nestjs-prisma/variants/base/src/repositories/language.repository.ts +2 -2
- package/registry/combos/nestjs-prisma/variants/base/src/repositories/rbac.repository.ts +3 -3
- package/registry/combos/nestjs-prisma/variants/base/src/seed.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/base/src/services/auth.service.ts +6 -8
- package/registry/combos/nestjs-prisma/variants/base/test/variant-hooks.ts +176 -47
- package/registry/combos/nestjs-prisma/variants/workspaces/src/auth.module.ts +10 -6
- package/registry/combos/nestjs-prisma/variants/workspaces/src/controllers/admin.controller.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/workspaces/src/controllers/workspace.controller.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/workspaces/src/guards/authz.guard.ts +2 -2
- package/registry/combos/nestjs-prisma/variants/workspaces/src/index.ts +9 -0
- package/registry/combos/nestjs-prisma/variants/workspaces/src/rbac.defaults.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/audit-log.repository.ts +2 -2
- package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/country.repository.ts +2 -2
- package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/customer.repository.ts +6 -5
- package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/language.repository.ts +2 -2
- package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/rbac.repository.ts +3 -3
- package/registry/combos/nestjs-prisma/variants/workspaces/src/repositories/workspace.repository.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/workspaces/src/seed.ts +1 -1
- package/registry/combos/nestjs-prisma/variants/workspaces/src/services/auth.service.ts +6 -8
- package/registry/combos/nestjs-prisma/variants/workspaces/test/variant-hooks.ts +538 -134
- package/registry/combos/express-drizzle/variants/base/src/openapi-admin.ts +0 -565
- package/registry/combos/express-drizzle/variants/workspaces/src/openapi-admin.ts +0 -596
- package/registry/combos/express-prisma/variants/base/src/openapi-admin.ts +0 -569
- package/registry/combos/express-prisma/variants/workspaces/src/openapi-admin.ts +0 -601
- /package/registry/combos/express-drizzle/shared/src/{http-error.ts → errors/http-error.ts} +0 -0
- /package/registry/combos/express-prisma/shared/src/{http-error.ts → errors/http-error.ts} +0 -0
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
// a permission nothing can ever grant.
|
|
29
29
|
import { Router } from "express";
|
|
30
30
|
import type { NextFunction, Request, RequestHandler, Response } from "express";
|
|
31
|
-
import { ABILITY_SUBJECT } from "./ability.js";
|
|
31
|
+
import { ABILITY_SUBJECT } from "./ability/ability.js";
|
|
32
32
|
import { PERMISSION_CATALOG, type PermissionSlug } from "./rbac.defaults.js";
|
|
33
33
|
import "./request-context.js";
|
|
34
34
|
|
|
@@ -39,7 +39,10 @@ export type TieredMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
|
39
39
|
* What a route declares about itself. There is deliberately no fourth shape and no default: the
|
|
40
40
|
* union is closed, so adding a route means picking one of these three.
|
|
41
41
|
*/
|
|
42
|
-
export type RouteTier =
|
|
42
|
+
export type RouteTier =
|
|
43
|
+
| { kind: "public" }
|
|
44
|
+
| { kind: "authenticated" }
|
|
45
|
+
| { kind: "ability"; abilities: PermissionSlug[] };
|
|
43
46
|
|
|
44
47
|
/** Tier 1: reachable with no token at all. Carries no middleware, which is exactly why it has to be said out loud. */
|
|
45
48
|
export const publicRoute = (): RouteTier => ({ kind: "public" });
|
|
@@ -57,7 +60,10 @@ export const authenticated = (): RouteTier => ({ kind: "authenticated" });
|
|
|
57
60
|
* hold the slug is entirely a matter of rows.
|
|
58
61
|
*/
|
|
59
62
|
export const ability = (...abilities: PermissionSlug[]): RouteTier => {
|
|
60
|
-
if (!abilities.length)
|
|
63
|
+
if (!abilities.length)
|
|
64
|
+
throw new Error(
|
|
65
|
+
"ability() names no permission — use authenticated() if any logged-in caller may call the route",
|
|
66
|
+
);
|
|
61
67
|
for (const slug of abilities) assertInCatalog(slug);
|
|
62
68
|
return { kind: "ability", abilities };
|
|
63
69
|
};
|
|
@@ -72,15 +78,31 @@ export const ability = (...abilities: PermissionSlug[]): RouteTier => {
|
|
|
72
78
|
* incapable of disagreeing.
|
|
73
79
|
*/
|
|
74
80
|
export function requireAbility(abilities: PermissionSlug[]): RequestHandler {
|
|
75
|
-
return function abilityMiddleware(
|
|
81
|
+
return function abilityMiddleware(
|
|
82
|
+
req: Request,
|
|
83
|
+
res: Response,
|
|
84
|
+
next: NextFunction,
|
|
85
|
+
): void {
|
|
76
86
|
// No ability at all means the authz middleware resolved nothing — fail closed.
|
|
77
87
|
if (!req.ability) {
|
|
78
|
-
res
|
|
88
|
+
res
|
|
89
|
+
.status(403)
|
|
90
|
+
.json({
|
|
91
|
+
statusCode: 403,
|
|
92
|
+
code: "FORBIDDEN",
|
|
93
|
+
message: "no authorization context for this request",
|
|
94
|
+
});
|
|
79
95
|
return;
|
|
80
96
|
}
|
|
81
97
|
for (const slug of abilities) {
|
|
82
98
|
if (!req.ability.can(slug, ABILITY_SUBJECT)) {
|
|
83
|
-
res
|
|
99
|
+
res
|
|
100
|
+
.status(403)
|
|
101
|
+
.json({
|
|
102
|
+
statusCode: 403,
|
|
103
|
+
code: "FORBIDDEN",
|
|
104
|
+
message: `missing permission: ${slug}`,
|
|
105
|
+
});
|
|
84
106
|
return;
|
|
85
107
|
}
|
|
86
108
|
}
|
|
@@ -95,7 +117,12 @@ export interface TieredRouter {
|
|
|
95
117
|
* adds a route without one, and the middleware the tier implies is always inserted immediately
|
|
96
118
|
* before `handler` — the two cannot come apart.
|
|
97
119
|
*/
|
|
98
|
-
route(
|
|
120
|
+
route(
|
|
121
|
+
method: TieredMethod,
|
|
122
|
+
path: string,
|
|
123
|
+
tier: RouteTier,
|
|
124
|
+
...handlers: RequestHandler[]
|
|
125
|
+
): void;
|
|
99
126
|
/**
|
|
100
127
|
* The composed middleware, for `app.use(...)`. Deliberately typed as `RequestHandler` and not
|
|
101
128
|
* as `Router`, even though that is what it is at runtime: the `.get`/`.post`/… methods are
|
|
@@ -123,26 +150,40 @@ export function createTieredRouter(middleware: TierMiddleware): TieredRouter {
|
|
|
123
150
|
const router = Router();
|
|
124
151
|
|
|
125
152
|
return {
|
|
126
|
-
route(
|
|
153
|
+
route(
|
|
154
|
+
method: TieredMethod,
|
|
155
|
+
path: string,
|
|
156
|
+
tier: RouteTier,
|
|
157
|
+
...handlers: RequestHandler[]
|
|
158
|
+
): void {
|
|
127
159
|
router[method](path, ...tierMiddleware(tier, middleware), ...handlers);
|
|
128
160
|
},
|
|
129
161
|
handler: router,
|
|
130
162
|
};
|
|
131
163
|
}
|
|
132
164
|
|
|
133
|
-
function tierMiddleware(
|
|
165
|
+
function tierMiddleware(
|
|
166
|
+
tier: RouteTier,
|
|
167
|
+
middleware: TierMiddleware,
|
|
168
|
+
): RequestHandler[] {
|
|
134
169
|
switch (tier.kind) {
|
|
135
170
|
case "public":
|
|
136
171
|
return [];
|
|
137
172
|
case "authenticated":
|
|
138
173
|
return [middleware.authentication, middleware.authorization];
|
|
139
174
|
case "ability":
|
|
140
|
-
return [
|
|
175
|
+
return [
|
|
176
|
+
middleware.authentication,
|
|
177
|
+
middleware.authorization,
|
|
178
|
+
requireAbility(tier.abilities),
|
|
179
|
+
];
|
|
141
180
|
}
|
|
142
181
|
}
|
|
143
182
|
|
|
144
183
|
function assertInCatalog(slug: string): void {
|
|
145
184
|
if (!Object.prototype.hasOwnProperty.call(PERMISSION_CATALOG, slug)) {
|
|
146
|
-
throw new Error(
|
|
185
|
+
throw new Error(
|
|
186
|
+
`"${slug}" is not in PERMISSION_CATALOG — add it to rbac.defaults.ts (the seeder provisions exactly that catalog)`,
|
|
187
|
+
);
|
|
147
188
|
}
|
|
148
189
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NextFunction, Request, RequestHandler, Response } from "express";
|
|
2
|
-
import type { AuthConfig } from "../auth.config.js";
|
|
2
|
+
import type { AuthConfig } from "../config/auth.config.js";
|
|
3
3
|
import { AuthService } from "../services/auth.service.js";
|
|
4
|
-
import { HttpError } from "../http-error.js";
|
|
4
|
+
import { HttpError } from "../errors/http-error.js";
|
|
5
5
|
import {
|
|
6
6
|
authenticated,
|
|
7
7
|
createTieredRouter,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
2
|
import type { Server } from "node:http";
|
|
3
3
|
import { createAuthApp } from "../src/create-auth-app.js";
|
|
4
|
-
import { InMemoryPermissionCacheStore } from "../src/permission-cache.js";
|
|
4
|
+
import { InMemoryPermissionCacheStore } from "../src/cache/permission-cache.js";
|
|
5
5
|
|
|
6
6
|
// No mailer is wired up for the proof, so this stands in for one — prove-cycle.ts reads the
|
|
7
7
|
// raw token back out of here the same way a test inbox would, to exercise the reset flow.
|
|
@@ -14,7 +14,9 @@ export const capturedResetTokens = new Map<string, string>();
|
|
|
14
14
|
*/
|
|
15
15
|
export const permissionCacheStore = new InMemoryPermissionCacheStore();
|
|
16
16
|
|
|
17
|
-
export async function bootstrap(
|
|
17
|
+
export async function bootstrap(
|
|
18
|
+
port: number,
|
|
19
|
+
): Promise<{ close: () => Promise<void> }> {
|
|
18
20
|
const app = createAuthApp({
|
|
19
21
|
// Was 2 seconds, "so the proof can exercise expiry-adjacent paths quickly" — except no
|
|
20
22
|
// assertion in the proof waits for an access token to expire, so it bought nothing and
|