@shipfox/api-auth 9.1.0 → 9.3.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +41 -0
- package/README.md +44 -2
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +26 -0
- package/dist/config.js.map +1 -1
- package/dist/core/admin-role-model.d.ts +5 -0
- package/dist/core/admin-role-model.d.ts.map +1 -0
- package/dist/core/admin-role-model.js +18 -0
- package/dist/core/admin-role-model.js.map +1 -0
- package/dist/core/admin-role.d.ts +13 -0
- package/dist/core/admin-role.d.ts.map +1 -0
- package/dist/core/admin-role.js +21 -0
- package/dist/core/admin-role.js.map +1 -0
- package/dist/core/administration.d.ts +27 -0
- package/dist/core/administration.d.ts.map +1 -0
- package/dist/core/administration.js +122 -0
- package/dist/core/administration.js.map +1 -0
- package/dist/core/auth.d.ts +9 -0
- package/dist/core/auth.d.ts.map +1 -1
- package/dist/core/auth.js +68 -20
- package/dist/core/auth.js.map +1 -1
- package/dist/core/entities/admin-grant.d.ts +10 -0
- package/dist/core/entities/admin-grant.d.ts.map +1 -0
- package/dist/core/entities/admin-grant.js +3 -0
- package/dist/core/entities/admin-grant.js.map +1 -0
- package/dist/core/errors.d.ts +25 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +49 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/ports.d.ts +13 -0
- package/dist/core/ports.d.ts.map +1 -0
- package/dist/core/ports.js +3 -0
- package/dist/core/ports.js.map +1 -0
- package/dist/core/signup-policy.d.ts +10 -0
- package/dist/core/signup-policy.d.ts.map +1 -0
- package/dist/core/signup-policy.js +39 -0
- package/dist/core/signup-policy.js.map +1 -0
- package/dist/db/admin-grants.d.ts +33 -0
- package/dist/db/admin-grants.d.ts.map +1 -0
- package/dist/db/admin-grants.js +193 -0
- package/dist/db/admin-grants.js.map +1 -0
- package/dist/db/db.d.ts +474 -0
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +4 -0
- package/dist/db/db.js.map +1 -1
- package/dist/db/schema/admin-command-results.d.ts +142 -0
- package/dist/db/schema/admin-command-results.d.ts.map +1 -0
- package/dist/db/schema/admin-command-results.js +21 -0
- package/dist/db/schema/admin-command-results.js.map +1 -0
- package/dist/db/schema/admin-grants.d.ts +115 -0
- package/dist/db/schema/admin-grants.d.ts.map +1 -0
- package/dist/db/schema/admin-grants.js +42 -0
- package/dist/db/schema/admin-grants.js.map +1 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -4
- package/dist/index.js.map +1 -1
- package/dist/metrics/instance.d.ts +1 -1
- package/dist/metrics/instance.d.ts.map +1 -1
- package/dist/metrics/instance.js.map +1 -1
- package/dist/presentation/dto/user.d.ts +2 -1
- package/dist/presentation/dto/user.d.ts.map +1 -1
- package/dist/presentation/dto/user.js +2 -1
- package/dist/presentation/dto/user.js.map +1 -1
- package/dist/presentation/inter-module.d.ts.map +1 -1
- package/dist/presentation/inter-module.js +26 -2
- package/dist/presentation/inter-module.js.map +1 -1
- package/dist/presentation/routes/administration.d.ts +3 -0
- package/dist/presentation/routes/administration.d.ts.map +1 -0
- package/dist/presentation/routes/administration.js +186 -0
- package/dist/presentation/routes/administration.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +2 -1
- package/dist/presentation/routes/index.d.ts.map +1 -1
- package/dist/presentation/routes/index.js +2 -2
- package/dist/presentation/routes/index.js.map +1 -1
- package/dist/presentation/routes/rate-limit.d.ts +1 -0
- package/dist/presentation/routes/rate-limit.d.ts.map +1 -1
- package/dist/presentation/routes/rate-limit.js +20 -1
- package/dist/presentation/routes/rate-limit.js.map +1 -1
- package/dist/presentation/routes/registration/signup.d.ts +2 -1
- package/dist/presentation/routes/registration/signup.d.ts.map +1 -1
- package/dist/presentation/routes/registration/signup.js +14 -3
- package/dist/presentation/routes/registration/signup.js.map +1 -1
- package/dist/presentation/routes/session/me.d.ts.map +1 -1
- package/dist/presentation/routes/session/me.js +5 -1
- package/dist/presentation/routes/session/me.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/drizzle/0001_brainy_shriek.sql +14 -0
- package/drizzle/0002_burly_whizzer.sql +12 -0
- package/drizzle/meta/0001_snapshot.json +702 -0
- package/drizzle/meta/0002_snapshot.json +791 -0
- package/drizzle/meta/_journal.json +14 -0
- package/package.json +10 -9
- package/src/config.test.ts +39 -0
- package/src/config.ts +34 -0
- package/src/core/admin-role-model.ts +25 -0
- package/src/core/admin-role.test.ts +39 -0
- package/src/core/admin-role.ts +25 -0
- package/src/core/administration.ts +172 -0
- package/src/core/auth-default-signup-policy.test.ts +65 -0
- package/src/core/auth.test.ts +115 -0
- package/src/core/auth.ts +77 -21
- package/src/core/entities/admin-grant.ts +10 -0
- package/src/core/errors.ts +59 -0
- package/src/core/jwt.test.ts +1 -0
- package/src/core/ports.ts +7 -0
- package/src/core/signup-policy.test.ts +78 -0
- package/src/core/signup-policy.ts +42 -0
- package/src/db/admin-grants.test.ts +57 -0
- package/src/db/admin-grants.ts +340 -0
- package/src/db/db.ts +4 -0
- package/src/db/schema/admin-command-results.ts +41 -0
- package/src/db/schema/admin-grants.ts +49 -0
- package/src/index.test.ts +58 -1
- package/src/index.ts +47 -6
- package/src/metrics/instance.ts +1 -1
- package/src/presentation/auth/refresh-cookie.test.ts +4 -0
- package/src/presentation/dto/user.ts +7 -2
- package/src/presentation/e2eRoutes/index.test.ts +1 -0
- package/src/presentation/inter-module.test.ts +47 -0
- package/src/presentation/inter-module.ts +22 -1
- package/src/presentation/routes/administration.test.ts +253 -0
- package/src/presentation/routes/administration.ts +195 -0
- package/src/presentation/routes/index.test.ts +1 -0
- package/src/presentation/routes/index.ts +3 -1
- package/src/presentation/routes/rate-limit.ts +23 -2
- package/src/presentation/routes/registration/signup.test.ts +26 -0
- package/src/presentation/routes/registration/signup.ts +22 -2
- package/src/presentation/routes/session/login.test.ts +1 -0
- package/src/presentation/routes/session/me.test.ts +18 -2
- package/src/presentation/routes/session/me.ts +5 -1
- package/test/globalSetup.ts +6 -2
- package/test/routes.ts +7 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { uuidv7PrimaryKey } from '@shipfox/node-drizzle';
|
|
2
|
+
import { jsonb, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { pgTable } from './common.js';
|
|
4
|
+
import { users } from './users.js';
|
|
5
|
+
export const adminCommandResults = pgTable('admin_command_results', {
|
|
6
|
+
id: uuidv7PrimaryKey(),
|
|
7
|
+
actorId: uuid('actor_id').notNull().references(()=>users.id, {
|
|
8
|
+
onDelete: 'cascade'
|
|
9
|
+
}),
|
|
10
|
+
idempotencyKeyFingerprint: text('idempotency_key_fingerprint').notNull(),
|
|
11
|
+
command: text('command').notNull(),
|
|
12
|
+
requestFingerprint: text('request_fingerprint').notNull(),
|
|
13
|
+
result: jsonb('result').$type().notNull(),
|
|
14
|
+
createdAt: timestamp('created_at', {
|
|
15
|
+
withTimezone: true
|
|
16
|
+
}).notNull().defaultNow()
|
|
17
|
+
}, (table)=>[
|
|
18
|
+
uniqueIndex('auth_admin_command_results_actor_key_unique').on(table.actorId, table.idempotencyKeyFingerprint)
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=admin-command-results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/admin-command-results.ts"],"sourcesContent":["import type {AdminRole} from '@shipfox/api-auth-dto';\nimport {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {jsonb, text, timestamp, uniqueIndex, uuid} from 'drizzle-orm/pg-core';\nimport {pgTable} from './common.js';\nimport {users} from './users.js';\n\nexport interface StoredAdminGrant {\n id: string;\n userId: string;\n role: AdminRole;\n revokedAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface StoredAdminCommandResult {\n grant: StoredAdminGrant;\n}\n\nexport const adminCommandResults = pgTable(\n 'admin_command_results',\n {\n id: uuidv7PrimaryKey(),\n actorId: uuid('actor_id')\n .notNull()\n .references(() => users.id, {onDelete: 'cascade'}),\n idempotencyKeyFingerprint: text('idempotency_key_fingerprint').notNull(),\n command: text('command').notNull(),\n requestFingerprint: text('request_fingerprint').notNull(),\n result: jsonb('result').$type<StoredAdminCommandResult>().notNull(),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [\n uniqueIndex('auth_admin_command_results_actor_key_unique').on(\n table.actorId,\n table.idempotencyKeyFingerprint,\n ),\n ],\n);\n\nexport type AdminCommandResultDb = typeof adminCommandResults.$inferSelect;\n"],"names":["uuidv7PrimaryKey","jsonb","text","timestamp","uniqueIndex","uuid","pgTable","users","adminCommandResults","id","actorId","notNull","references","onDelete","idempotencyKeyFingerprint","command","requestFingerprint","result","$type","createdAt","withTimezone","defaultNow","table","on"],"mappings":"AACA,SAAQA,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,KAAK,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,EAAEC,IAAI,QAAO,sBAAsB;AAC9E,SAAQC,OAAO,QAAO,cAAc;AACpC,SAAQC,KAAK,QAAO,aAAa;AAejC,OAAO,MAAMC,sBAAsBF,QACjC,yBACA;IACEG,IAAIT;IACJU,SAASL,KAAK,YACXM,OAAO,GACPC,UAAU,CAAC,IAAML,MAAME,EAAE,EAAE;QAACI,UAAU;IAAS;IAClDC,2BAA2BZ,KAAK,+BAA+BS,OAAO;IACtEI,SAASb,KAAK,WAAWS,OAAO;IAChCK,oBAAoBd,KAAK,uBAAuBS,OAAO;IACvDM,QAAQhB,MAAM,UAAUiB,KAAK,GAA6BP,OAAO;IACjEQ,WAAWhB,UAAU,cAAc;QAACiB,cAAc;IAAI,GAAGT,OAAO,GAAGU,UAAU;AAC/E,GACA,CAACC,QAAU;QACTlB,YAAY,+CAA+CmB,EAAE,CAC3DD,MAAMZ,OAAO,EACbY,MAAMR,yBAAyB;KAElC,EACD"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { AdminGrant } from '#core/entities/admin-grant.js';
|
|
2
|
+
export declare const adminRoleEnum: import("drizzle-orm/pg-core").PgEnum<["admin-observer", "admin-operator", "admin-owner"]>;
|
|
3
|
+
export declare const adminGrants: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4
|
+
name: "admin_grants";
|
|
5
|
+
schema: undefined;
|
|
6
|
+
columns: {
|
|
7
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
8
|
+
name: "id";
|
|
9
|
+
tableName: "admin_grants";
|
|
10
|
+
dataType: "string";
|
|
11
|
+
columnType: "PgUUID";
|
|
12
|
+
data: string;
|
|
13
|
+
driverParam: string;
|
|
14
|
+
notNull: true;
|
|
15
|
+
hasDefault: true;
|
|
16
|
+
isPrimaryKey: true;
|
|
17
|
+
isAutoincrement: false;
|
|
18
|
+
hasRuntimeDefault: false;
|
|
19
|
+
enumValues: undefined;
|
|
20
|
+
baseColumn: never;
|
|
21
|
+
identity: undefined;
|
|
22
|
+
generated: undefined;
|
|
23
|
+
}, {}, {}>;
|
|
24
|
+
userId: import("drizzle-orm/pg-core").PgColumn<{
|
|
25
|
+
name: "user_id";
|
|
26
|
+
tableName: "admin_grants";
|
|
27
|
+
dataType: "string";
|
|
28
|
+
columnType: "PgUUID";
|
|
29
|
+
data: string;
|
|
30
|
+
driverParam: string;
|
|
31
|
+
notNull: true;
|
|
32
|
+
hasDefault: false;
|
|
33
|
+
isPrimaryKey: false;
|
|
34
|
+
isAutoincrement: false;
|
|
35
|
+
hasRuntimeDefault: false;
|
|
36
|
+
enumValues: undefined;
|
|
37
|
+
baseColumn: never;
|
|
38
|
+
identity: undefined;
|
|
39
|
+
generated: undefined;
|
|
40
|
+
}, {}, {}>;
|
|
41
|
+
role: import("drizzle-orm/pg-core").PgColumn<{
|
|
42
|
+
name: "role";
|
|
43
|
+
tableName: "admin_grants";
|
|
44
|
+
dataType: "string";
|
|
45
|
+
columnType: "PgEnumColumn";
|
|
46
|
+
data: "admin-observer" | "admin-operator" | "admin-owner";
|
|
47
|
+
driverParam: string;
|
|
48
|
+
notNull: true;
|
|
49
|
+
hasDefault: false;
|
|
50
|
+
isPrimaryKey: false;
|
|
51
|
+
isAutoincrement: false;
|
|
52
|
+
hasRuntimeDefault: false;
|
|
53
|
+
enumValues: ["admin-observer", "admin-operator", "admin-owner"];
|
|
54
|
+
baseColumn: never;
|
|
55
|
+
identity: undefined;
|
|
56
|
+
generated: undefined;
|
|
57
|
+
}, {}, {}>;
|
|
58
|
+
revokedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
59
|
+
name: "revoked_at";
|
|
60
|
+
tableName: "admin_grants";
|
|
61
|
+
dataType: "date";
|
|
62
|
+
columnType: "PgTimestamp";
|
|
63
|
+
data: Date;
|
|
64
|
+
driverParam: string;
|
|
65
|
+
notNull: false;
|
|
66
|
+
hasDefault: false;
|
|
67
|
+
isPrimaryKey: false;
|
|
68
|
+
isAutoincrement: false;
|
|
69
|
+
hasRuntimeDefault: false;
|
|
70
|
+
enumValues: undefined;
|
|
71
|
+
baseColumn: never;
|
|
72
|
+
identity: undefined;
|
|
73
|
+
generated: undefined;
|
|
74
|
+
}, {}, {}>;
|
|
75
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
76
|
+
name: "created_at";
|
|
77
|
+
tableName: "admin_grants";
|
|
78
|
+
dataType: "date";
|
|
79
|
+
columnType: "PgTimestamp";
|
|
80
|
+
data: Date;
|
|
81
|
+
driverParam: string;
|
|
82
|
+
notNull: true;
|
|
83
|
+
hasDefault: true;
|
|
84
|
+
isPrimaryKey: false;
|
|
85
|
+
isAutoincrement: false;
|
|
86
|
+
hasRuntimeDefault: false;
|
|
87
|
+
enumValues: undefined;
|
|
88
|
+
baseColumn: never;
|
|
89
|
+
identity: undefined;
|
|
90
|
+
generated: undefined;
|
|
91
|
+
}, {}, {}>;
|
|
92
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
93
|
+
name: "updated_at";
|
|
94
|
+
tableName: "admin_grants";
|
|
95
|
+
dataType: "date";
|
|
96
|
+
columnType: "PgTimestamp";
|
|
97
|
+
data: Date;
|
|
98
|
+
driverParam: string;
|
|
99
|
+
notNull: true;
|
|
100
|
+
hasDefault: true;
|
|
101
|
+
isPrimaryKey: false;
|
|
102
|
+
isAutoincrement: false;
|
|
103
|
+
hasRuntimeDefault: false;
|
|
104
|
+
enumValues: undefined;
|
|
105
|
+
baseColumn: never;
|
|
106
|
+
identity: undefined;
|
|
107
|
+
generated: undefined;
|
|
108
|
+
}, {}, {}>;
|
|
109
|
+
};
|
|
110
|
+
dialect: "pg";
|
|
111
|
+
}>;
|
|
112
|
+
export type AdminGrantDb = typeof adminGrants.$inferSelect;
|
|
113
|
+
export type AdminGrantCreateDb = typeof adminGrants.$inferInsert;
|
|
114
|
+
export declare function toAdminGrant(row: AdminGrantDb): AdminGrant;
|
|
115
|
+
//# sourceMappingURL=admin-grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-grants.d.ts","sourceRoot":"","sources":["../../../src/db/schema/admin-grants.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAC;AAI9D,eAAO,MAAM,aAAa,2FAIxB,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,WAAW,CAAC,YAAY,CAAC;AAC3D,MAAM,MAAM,kBAAkB,GAAG,OAAO,WAAW,CAAC,YAAY,CAAC;AAEjE,wBAAgB,YAAY,CAAC,GAAG,EAAE,YAAY,GAAG,UAAU,CAS1D"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { uuidv7PrimaryKey } from '@shipfox/node-drizzle';
|
|
2
|
+
import { sql } from 'drizzle-orm';
|
|
3
|
+
import { index, pgEnum, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
|
|
4
|
+
import { pgTable } from './common.js';
|
|
5
|
+
import { users } from './users.js';
|
|
6
|
+
export const adminRoleEnum = pgEnum('auth_admin_role', [
|
|
7
|
+
'admin-observer',
|
|
8
|
+
'admin-operator',
|
|
9
|
+
'admin-owner'
|
|
10
|
+
]);
|
|
11
|
+
export const adminGrants = pgTable('admin_grants', {
|
|
12
|
+
id: uuidv7PrimaryKey(),
|
|
13
|
+
userId: uuid('user_id').notNull().references(()=>users.id, {
|
|
14
|
+
onDelete: 'cascade'
|
|
15
|
+
}),
|
|
16
|
+
role: adminRoleEnum('role').notNull(),
|
|
17
|
+
revokedAt: timestamp('revoked_at', {
|
|
18
|
+
withTimezone: true
|
|
19
|
+
}),
|
|
20
|
+
createdAt: timestamp('created_at', {
|
|
21
|
+
withTimezone: true
|
|
22
|
+
}).notNull().defaultNow(),
|
|
23
|
+
updatedAt: timestamp('updated_at', {
|
|
24
|
+
withTimezone: true
|
|
25
|
+
}).notNull().defaultNow()
|
|
26
|
+
}, (table)=>[
|
|
27
|
+
index('auth_admin_grants_user_id_idx').on(table.userId),
|
|
28
|
+
index('auth_admin_grants_active_owners_idx').on(table.userId).where(sql`${table.role} = 'admin-owner' AND ${table.revokedAt} IS NULL`),
|
|
29
|
+
uniqueIndex('auth_admin_grants_active_user_role_unique').on(table.userId, table.role).where(sql`${table.revokedAt} IS NULL`)
|
|
30
|
+
]);
|
|
31
|
+
export function toAdminGrant(row) {
|
|
32
|
+
return {
|
|
33
|
+
id: row.id,
|
|
34
|
+
userId: row.userId,
|
|
35
|
+
role: row.role,
|
|
36
|
+
revokedAt: row.revokedAt,
|
|
37
|
+
createdAt: row.createdAt,
|
|
38
|
+
updatedAt: row.updatedAt
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=admin-grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/admin-grants.ts"],"sourcesContent":["import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {sql} from 'drizzle-orm';\nimport {index, pgEnum, timestamp, uniqueIndex, uuid} from 'drizzle-orm/pg-core';\nimport type {AdminGrant} from '#core/entities/admin-grant.js';\nimport {pgTable} from './common.js';\nimport {users} from './users.js';\n\nexport const adminRoleEnum = pgEnum('auth_admin_role', [\n 'admin-observer',\n 'admin-operator',\n 'admin-owner',\n]);\n\nexport const adminGrants = pgTable(\n 'admin_grants',\n {\n id: uuidv7PrimaryKey(),\n userId: uuid('user_id')\n .notNull()\n .references(() => users.id, {onDelete: 'cascade'}),\n role: adminRoleEnum('role').notNull(),\n revokedAt: timestamp('revoked_at', {withTimezone: true}),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [\n index('auth_admin_grants_user_id_idx').on(table.userId),\n index('auth_admin_grants_active_owners_idx')\n .on(table.userId)\n .where(sql`${table.role} = 'admin-owner' AND ${table.revokedAt} IS NULL`),\n uniqueIndex('auth_admin_grants_active_user_role_unique')\n .on(table.userId, table.role)\n .where(sql`${table.revokedAt} IS NULL`),\n ],\n);\n\nexport type AdminGrantDb = typeof adminGrants.$inferSelect;\nexport type AdminGrantCreateDb = typeof adminGrants.$inferInsert;\n\nexport function toAdminGrant(row: AdminGrantDb): AdminGrant {\n return {\n id: row.id,\n userId: row.userId,\n role: row.role,\n revokedAt: row.revokedAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n"],"names":["uuidv7PrimaryKey","sql","index","pgEnum","timestamp","uniqueIndex","uuid","pgTable","users","adminRoleEnum","adminGrants","id","userId","notNull","references","onDelete","role","revokedAt","withTimezone","createdAt","defaultNow","updatedAt","table","on","where","toAdminGrant","row"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,GAAG,QAAO,cAAc;AAChC,SAAQC,KAAK,EAAEC,MAAM,EAAEC,SAAS,EAAEC,WAAW,EAAEC,IAAI,QAAO,sBAAsB;AAEhF,SAAQC,OAAO,QAAO,cAAc;AACpC,SAAQC,KAAK,QAAO,aAAa;AAEjC,OAAO,MAAMC,gBAAgBN,OAAO,mBAAmB;IACrD;IACA;IACA;CACD,EAAE;AAEH,OAAO,MAAMO,cAAcH,QACzB,gBACA;IACEI,IAAIX;IACJY,QAAQN,KAAK,WACVO,OAAO,GACPC,UAAU,CAAC,IAAMN,MAAMG,EAAE,EAAE;QAACI,UAAU;IAAS;IAClDC,MAAMP,cAAc,QAAQI,OAAO;IACnCI,WAAWb,UAAU,cAAc;QAACc,cAAc;IAAI;IACtDC,WAAWf,UAAU,cAAc;QAACc,cAAc;IAAI,GAAGL,OAAO,GAAGO,UAAU;IAC7EC,WAAWjB,UAAU,cAAc;QAACc,cAAc;IAAI,GAAGL,OAAO,GAAGO,UAAU;AAC/E,GACA,CAACE,QAAU;QACTpB,MAAM,iCAAiCqB,EAAE,CAACD,MAAMV,MAAM;QACtDV,MAAM,uCACHqB,EAAE,CAACD,MAAMV,MAAM,EACfY,KAAK,CAACvB,GAAG,CAAC,EAAEqB,MAAMN,IAAI,CAAC,qBAAqB,EAAEM,MAAML,SAAS,CAAC,QAAQ,CAAC;QAC1EZ,YAAY,6CACTkB,EAAE,CAACD,MAAMV,MAAM,EAAEU,MAAMN,IAAI,EAC3BQ,KAAK,CAACvB,GAAG,CAAC,EAAEqB,MAAML,SAAS,CAAC,QAAQ,CAAC;KACzC,EACD;AAKF,OAAO,SAASQ,aAAaC,GAAiB;IAC5C,OAAO;QACLf,IAAIe,IAAIf,EAAE;QACVC,QAAQc,IAAId,MAAM;QAClBI,MAAMU,IAAIV,IAAI;QACdC,WAAWS,IAAIT,SAAS;QACxBE,WAAWO,IAAIP,SAAS;QACxBE,WAAWK,IAAIL,SAAS;IAC1B;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import type { ShipfoxModule } from '@shipfox/node-module';
|
|
2
|
-
|
|
2
|
+
import type { SignupPolicy } from '#core/ports.js';
|
|
3
|
+
export type { AdminRole, JobLeaseTokenClaims, RunnerSessionTokenClaims } from '@shipfox/api-auth-dto';
|
|
4
|
+
export { ADMIN_ROLES, getCurrentAdminRole, hasMinimumAdminRole, highestAdminRole, requireAdminRole, revokeAdminGrant, } from '#core/admin-role.js';
|
|
5
|
+
export { bootstrapFirstAdminOwner, grantAdministratorRole, listAdministratorGrants, revokeAdministratorGrant, } from '#core/administration.js';
|
|
3
6
|
export type { CreateSessionForUserError, CreateSessionForUserParams, CreateSessionForUserResult, ProvisionUserParams, } from '#core/auth.js';
|
|
4
7
|
export { createSessionForUser, provisionUser } from '#core/auth.js';
|
|
5
8
|
export type { EmailOwner, FindUserByEmailParams } from '#core/email-owner.js';
|
|
6
9
|
export { findUserByEmail } from '#core/email-owner.js';
|
|
10
|
+
export type { AdminGrant } from '#core/entities/admin-grant.js';
|
|
7
11
|
export type { User, UserStatus } from '#core/entities/user.js';
|
|
8
|
-
export { AuthDependencyUnavailableError, EmailNotVerifiedError, InvalidCredentialsError, UserNotFoundError, } from '#core/errors.js';
|
|
12
|
+
export { AdminBootstrapClosedError, AdminGrantAlreadyExistsError, AdminGrantNotFoundError, AdminIdempotencyKeyReuseError, AdminRoleRequiredError, AuthDependencyUnavailableError, EmailNotVerifiedError, InvalidAdminBootstrapTokenError, InvalidCredentialsError, LastAdminOwnerError, SignupNotAllowedError, UserNotFoundError, } from '#core/errors.js';
|
|
9
13
|
export { issueJobLeaseToken, jobLeaseParamsFrom, verifyJobLeaseToken, } from '#core/job-lease-token.js';
|
|
14
|
+
export type { SignupPolicy } from '#core/ports.js';
|
|
10
15
|
export { issueRunnerSessionToken, verifyRunnerSessionToken, } from '#core/runner-session-token.js';
|
|
16
|
+
export { createEnvironmentSignupPolicy, DEFAULT_SIGNUP_NOT_ALLOWED_MESSAGE, } from '#core/signup-policy.js';
|
|
11
17
|
export { type AuthenticatedSessionContext, createJwtAuthMethod, getAuthenticatedSessionContext, type RefreshSessionId, type UserId, } from '#presentation/auth/jwt-auth.js';
|
|
12
18
|
export { createLeaseTokenAuthMethod } from '#presentation/auth/lease-token-auth.js';
|
|
13
19
|
export { authCookiePlugin, clearRefreshTokenCookie, getRefreshTokenCookie, setRefreshTokenCookie, } from '#presentation/auth/refresh-cookie.js';
|
|
14
20
|
export { createRunnerSessionAuthMethod } from '#presentation/auth/runner-session-auth.js';
|
|
15
|
-
export
|
|
21
|
+
export interface CreateAuthModuleOptions {
|
|
16
22
|
workspaces: import('@shipfox/api-workspaces-dto/inter-module').WorkspacesInterModuleClient;
|
|
17
|
-
|
|
23
|
+
signupPolicy?: SignupPolicy;
|
|
24
|
+
}
|
|
25
|
+
export declare function createAuthModule({ workspaces, signupPolicy, }: CreateAuthModuleOptions): ShipfoxModule;
|
|
18
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAiBjD,YAAY,EAAC,SAAS,EAAE,mBAAmB,EAAE,wBAAwB,EAAC,MAAM,uBAAuB,CAAC;AACpG,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,oBAAoB,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAClE,YAAY,EAAC,UAAU,EAAE,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACrD,YAAY,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAC;AAC9D,YAAY,EAAC,IAAI,EAAE,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,EAC9B,qBAAqB,EACrB,+BAA+B,EAC/B,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,2BAA2B,EAChC,mBAAmB,EACnB,8BAA8B,EAC9B,KAAK,gBAAgB,EACrB,KAAK,MAAM,GACZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAC;AAClF,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAC,6BAA6B,EAAC,MAAM,2CAA2C,CAAC;AAIxF,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,OAAO,0CAA0C,EAAE,2BAA2B,CAAC;IAC3F,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,YAA8C,GAC/C,EAAE,uBAAuB,GAAG,aAAa,CAezC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AUTH_PASSWORD_RESET_SEND_REQUESTED, authEventSchemas } from '@shipfox/api-auth-dto';
|
|
2
|
+
import { administrationActionEventSchemas } from '@shipfox/api-common-dto';
|
|
2
3
|
import { subscriberFactory } from '@shipfox/node-module';
|
|
3
4
|
import { config } from '#config.js';
|
|
5
|
+
import { createEnvironmentSignupPolicy } from '#core/signup-policy.js';
|
|
4
6
|
import { db } from '#db/db.js';
|
|
5
7
|
import { migrationsPath } from '#db/migrations.js';
|
|
6
8
|
import { authOutbox } from '#db/schema/outbox.js';
|
|
@@ -9,20 +11,28 @@ import { createLeaseTokenAuthMethod } from '#presentation/auth/lease-token-auth.
|
|
|
9
11
|
import { createRunnerSessionAuthMethod } from '#presentation/auth/runner-session-auth.js';
|
|
10
12
|
import { createAuthE2eRoutes } from '#presentation/e2eRoutes/index.js';
|
|
11
13
|
import { createAuthInterModulePresentation } from '#presentation/inter-module.js';
|
|
14
|
+
import { administrationRoutes } from '#presentation/routes/administration.js';
|
|
12
15
|
import { buildAuthRoutes } from '#presentation/routes/index.js';
|
|
13
16
|
import { onPasswordResetSendRequested } from '#presentation/subscribers/index.js';
|
|
14
17
|
import { passwordLoginMethods } from './login-methods.js';
|
|
18
|
+
const authPublisherEventSchemas = {
|
|
19
|
+
...authEventSchemas,
|
|
20
|
+
...administrationActionEventSchemas
|
|
21
|
+
};
|
|
22
|
+
export { ADMIN_ROLES, getCurrentAdminRole, hasMinimumAdminRole, highestAdminRole, requireAdminRole, revokeAdminGrant } from '#core/admin-role.js';
|
|
23
|
+
export { bootstrapFirstAdminOwner, grantAdministratorRole, listAdministratorGrants, revokeAdministratorGrant } from '#core/administration.js';
|
|
15
24
|
export { createSessionForUser, provisionUser } from '#core/auth.js';
|
|
16
25
|
export { findUserByEmail } from '#core/email-owner.js';
|
|
17
|
-
export { AuthDependencyUnavailableError, EmailNotVerifiedError, InvalidCredentialsError, UserNotFoundError } from '#core/errors.js';
|
|
26
|
+
export { AdminBootstrapClosedError, AdminGrantAlreadyExistsError, AdminGrantNotFoundError, AdminIdempotencyKeyReuseError, AdminRoleRequiredError, AuthDependencyUnavailableError, EmailNotVerifiedError, InvalidAdminBootstrapTokenError, InvalidCredentialsError, LastAdminOwnerError, SignupNotAllowedError, UserNotFoundError } from '#core/errors.js';
|
|
18
27
|
export { issueJobLeaseToken, jobLeaseParamsFrom, verifyJobLeaseToken } from '#core/job-lease-token.js';
|
|
19
28
|
export { issueRunnerSessionToken, verifyRunnerSessionToken } from '#core/runner-session-token.js';
|
|
29
|
+
export { createEnvironmentSignupPolicy, DEFAULT_SIGNUP_NOT_ALLOWED_MESSAGE } from '#core/signup-policy.js';
|
|
20
30
|
export { createJwtAuthMethod, getAuthenticatedSessionContext } from '#presentation/auth/jwt-auth.js';
|
|
21
31
|
export { createLeaseTokenAuthMethod } from '#presentation/auth/lease-token-auth.js';
|
|
22
32
|
export { authCookiePlugin, clearRefreshTokenCookie, getRefreshTokenCookie, setRefreshTokenCookie } from '#presentation/auth/refresh-cookie.js';
|
|
23
33
|
export { createRunnerSessionAuthMethod } from '#presentation/auth/runner-session-auth.js';
|
|
24
34
|
const subscriber = subscriberFactory();
|
|
25
|
-
export function createAuthModule({ workspaces }) {
|
|
35
|
+
export function createAuthModule({ workspaces, signupPolicy = createEnvironmentSignupPolicy() }) {
|
|
26
36
|
return {
|
|
27
37
|
name: 'auth',
|
|
28
38
|
database: {
|
|
@@ -37,7 +47,8 @@ export function createAuthModule({ workspaces }) {
|
|
|
37
47
|
],
|
|
38
48
|
loginMethods: passwordLoginMethods(config.AUTH_PASSWORD_ENABLED),
|
|
39
49
|
routes: [
|
|
40
|
-
buildAuthRoutes(config.AUTH_PASSWORD_ENABLED, workspaces)
|
|
50
|
+
buildAuthRoutes(config.AUTH_PASSWORD_ENABLED, workspaces, signupPolicy),
|
|
51
|
+
administrationRoutes
|
|
41
52
|
],
|
|
42
53
|
e2eRoutes: [
|
|
43
54
|
createAuthE2eRoutes(workspaces)
|
|
@@ -47,7 +58,7 @@ export function createAuthModule({ workspaces }) {
|
|
|
47
58
|
name: 'auth',
|
|
48
59
|
table: authOutbox,
|
|
49
60
|
db,
|
|
50
|
-
eventSchemas:
|
|
61
|
+
eventSchemas: authPublisherEventSchemas
|
|
51
62
|
}
|
|
52
63
|
],
|
|
53
64
|
subscribers: [
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n AUTH_PASSWORD_RESET_SEND_REQUESTED,\n type AuthEventMap,\n authEventSchemas,\n} from '@shipfox/api-auth-dto';\nimport type {ShipfoxModule} from '@shipfox/node-module';\nimport {subscriberFactory} from '@shipfox/node-module';\nimport {config} from '#config.js';\nimport {db} from '#db/db.js';\nimport {migrationsPath} from '#db/migrations.js';\nimport {authOutbox} from '#db/schema/outbox.js';\nimport {createJwtAuthMethod} from '#presentation/auth/jwt-auth.js';\nimport {createLeaseTokenAuthMethod} from '#presentation/auth/lease-token-auth.js';\nimport {createRunnerSessionAuthMethod} from '#presentation/auth/runner-session-auth.js';\nimport {createAuthE2eRoutes} from '#presentation/e2eRoutes/index.js';\nimport {createAuthInterModulePresentation} from '#presentation/inter-module.js';\nimport {buildAuthRoutes} from '#presentation/routes/index.js';\nimport {onPasswordResetSendRequested} from '#presentation/subscribers/index.js';\nimport {passwordLoginMethods} from './login-methods.js';\n\nexport type {JobLeaseTokenClaims, RunnerSessionTokenClaims} from '@shipfox/api-auth-dto';\nexport type {\n CreateSessionForUserError,\n CreateSessionForUserParams,\n CreateSessionForUserResult,\n ProvisionUserParams,\n} from '#core/auth.js';\nexport {createSessionForUser, provisionUser} from '#core/auth.js';\nexport type {EmailOwner, FindUserByEmailParams} from '#core/email-owner.js';\nexport {findUserByEmail} from '#core/email-owner.js';\nexport type {User, UserStatus} from '#core/entities/user.js';\nexport {\n AuthDependencyUnavailableError,\n EmailNotVerifiedError,\n InvalidCredentialsError,\n UserNotFoundError,\n} from '#core/errors.js';\nexport {\n issueJobLeaseToken,\n jobLeaseParamsFrom,\n verifyJobLeaseToken,\n} from '#core/job-lease-token.js';\nexport {\n issueRunnerSessionToken,\n verifyRunnerSessionToken,\n} from '#core/runner-session-token.js';\nexport {\n type AuthenticatedSessionContext,\n createJwtAuthMethod,\n getAuthenticatedSessionContext,\n type RefreshSessionId,\n type UserId,\n} from '#presentation/auth/jwt-auth.js';\nexport {createLeaseTokenAuthMethod} from '#presentation/auth/lease-token-auth.js';\nexport {\n authCookiePlugin,\n clearRefreshTokenCookie,\n getRefreshTokenCookie,\n setRefreshTokenCookie,\n} from '#presentation/auth/refresh-cookie.js';\nexport {createRunnerSessionAuthMethod} from '#presentation/auth/runner-session-auth.js';\n\nconst subscriber = subscriberFactory<AuthEventMap>();\n\nexport
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n AUTH_PASSWORD_RESET_SEND_REQUESTED,\n type AuthEventMap,\n authEventSchemas,\n} from '@shipfox/api-auth-dto';\nimport {administrationActionEventSchemas} from '@shipfox/api-common-dto';\nimport type {ShipfoxModule} from '@shipfox/node-module';\nimport {subscriberFactory} from '@shipfox/node-module';\nimport {config} from '#config.js';\nimport type {SignupPolicy} from '#core/ports.js';\nimport {createEnvironmentSignupPolicy} from '#core/signup-policy.js';\nimport {db} from '#db/db.js';\nimport {migrationsPath} from '#db/migrations.js';\nimport {authOutbox} from '#db/schema/outbox.js';\nimport {createJwtAuthMethod} from '#presentation/auth/jwt-auth.js';\nimport {createLeaseTokenAuthMethod} from '#presentation/auth/lease-token-auth.js';\nimport {createRunnerSessionAuthMethod} from '#presentation/auth/runner-session-auth.js';\nimport {createAuthE2eRoutes} from '#presentation/e2eRoutes/index.js';\nimport {createAuthInterModulePresentation} from '#presentation/inter-module.js';\nimport {administrationRoutes} from '#presentation/routes/administration.js';\nimport {buildAuthRoutes} from '#presentation/routes/index.js';\nimport {onPasswordResetSendRequested} from '#presentation/subscribers/index.js';\nimport {passwordLoginMethods} from './login-methods.js';\n\nconst authPublisherEventSchemas = {...authEventSchemas, ...administrationActionEventSchemas};\n\nexport type {AdminRole, JobLeaseTokenClaims, RunnerSessionTokenClaims} from '@shipfox/api-auth-dto';\nexport {\n ADMIN_ROLES,\n getCurrentAdminRole,\n hasMinimumAdminRole,\n highestAdminRole,\n requireAdminRole,\n revokeAdminGrant,\n} from '#core/admin-role.js';\nexport {\n bootstrapFirstAdminOwner,\n grantAdministratorRole,\n listAdministratorGrants,\n revokeAdministratorGrant,\n} from '#core/administration.js';\nexport type {\n CreateSessionForUserError,\n CreateSessionForUserParams,\n CreateSessionForUserResult,\n ProvisionUserParams,\n} from '#core/auth.js';\nexport {createSessionForUser, provisionUser} from '#core/auth.js';\nexport type {EmailOwner, FindUserByEmailParams} from '#core/email-owner.js';\nexport {findUserByEmail} from '#core/email-owner.js';\nexport type {AdminGrant} from '#core/entities/admin-grant.js';\nexport type {User, UserStatus} from '#core/entities/user.js';\nexport {\n AdminBootstrapClosedError,\n AdminGrantAlreadyExistsError,\n AdminGrantNotFoundError,\n AdminIdempotencyKeyReuseError,\n AdminRoleRequiredError,\n AuthDependencyUnavailableError,\n EmailNotVerifiedError,\n InvalidAdminBootstrapTokenError,\n InvalidCredentialsError,\n LastAdminOwnerError,\n SignupNotAllowedError,\n UserNotFoundError,\n} from '#core/errors.js';\nexport {\n issueJobLeaseToken,\n jobLeaseParamsFrom,\n verifyJobLeaseToken,\n} from '#core/job-lease-token.js';\nexport type {SignupPolicy} from '#core/ports.js';\nexport {\n issueRunnerSessionToken,\n verifyRunnerSessionToken,\n} from '#core/runner-session-token.js';\nexport {\n createEnvironmentSignupPolicy,\n DEFAULT_SIGNUP_NOT_ALLOWED_MESSAGE,\n} from '#core/signup-policy.js';\nexport {\n type AuthenticatedSessionContext,\n createJwtAuthMethod,\n getAuthenticatedSessionContext,\n type RefreshSessionId,\n type UserId,\n} from '#presentation/auth/jwt-auth.js';\nexport {createLeaseTokenAuthMethod} from '#presentation/auth/lease-token-auth.js';\nexport {\n authCookiePlugin,\n clearRefreshTokenCookie,\n getRefreshTokenCookie,\n setRefreshTokenCookie,\n} from '#presentation/auth/refresh-cookie.js';\nexport {createRunnerSessionAuthMethod} from '#presentation/auth/runner-session-auth.js';\n\nconst subscriber = subscriberFactory<AuthEventMap>();\n\nexport interface CreateAuthModuleOptions {\n workspaces: import('@shipfox/api-workspaces-dto/inter-module').WorkspacesInterModuleClient;\n signupPolicy?: SignupPolicy;\n}\n\nexport function createAuthModule({\n workspaces,\n signupPolicy = createEnvironmentSignupPolicy(),\n}: CreateAuthModuleOptions): ShipfoxModule {\n return {\n name: 'auth',\n database: {db, migrationsPath, databaseNamespace: 'auth'},\n auth: [createJwtAuthMethod(), createLeaseTokenAuthMethod(), createRunnerSessionAuthMethod()],\n loginMethods: passwordLoginMethods(config.AUTH_PASSWORD_ENABLED),\n routes: [\n buildAuthRoutes(config.AUTH_PASSWORD_ENABLED, workspaces, signupPolicy),\n administrationRoutes,\n ],\n e2eRoutes: [createAuthE2eRoutes(workspaces)],\n publishers: [{name: 'auth', table: authOutbox, db, eventSchemas: authPublisherEventSchemas}],\n subscribers: [subscriber(AUTH_PASSWORD_RESET_SEND_REQUESTED, onPasswordResetSendRequested)],\n interModulePresentations: [createAuthInterModulePresentation()],\n };\n}\n"],"names":["AUTH_PASSWORD_RESET_SEND_REQUESTED","authEventSchemas","administrationActionEventSchemas","subscriberFactory","config","createEnvironmentSignupPolicy","db","migrationsPath","authOutbox","createJwtAuthMethod","createLeaseTokenAuthMethod","createRunnerSessionAuthMethod","createAuthE2eRoutes","createAuthInterModulePresentation","administrationRoutes","buildAuthRoutes","onPasswordResetSendRequested","passwordLoginMethods","authPublisherEventSchemas","ADMIN_ROLES","getCurrentAdminRole","hasMinimumAdminRole","highestAdminRole","requireAdminRole","revokeAdminGrant","bootstrapFirstAdminOwner","grantAdministratorRole","listAdministratorGrants","revokeAdministratorGrant","createSessionForUser","provisionUser","findUserByEmail","AdminBootstrapClosedError","AdminGrantAlreadyExistsError","AdminGrantNotFoundError","AdminIdempotencyKeyReuseError","AdminRoleRequiredError","AuthDependencyUnavailableError","EmailNotVerifiedError","InvalidAdminBootstrapTokenError","InvalidCredentialsError","LastAdminOwnerError","SignupNotAllowedError","UserNotFoundError","issueJobLeaseToken","jobLeaseParamsFrom","verifyJobLeaseToken","issueRunnerSessionToken","verifyRunnerSessionToken","DEFAULT_SIGNUP_NOT_ALLOWED_MESSAGE","getAuthenticatedSessionContext","authCookiePlugin","clearRefreshTokenCookie","getRefreshTokenCookie","setRefreshTokenCookie","subscriber","createAuthModule","workspaces","signupPolicy","name","database","databaseNamespace","auth","loginMethods","AUTH_PASSWORD_ENABLED","routes","e2eRoutes","publishers","table","eventSchemas","subscribers","interModulePresentations"],"mappings":"AAAA,SACEA,kCAAkC,EAElCC,gBAAgB,QACX,wBAAwB;AAC/B,SAAQC,gCAAgC,QAAO,0BAA0B;AAEzE,SAAQC,iBAAiB,QAAO,uBAAuB;AACvD,SAAQC,MAAM,QAAO,aAAa;AAElC,SAAQC,6BAA6B,QAAO,yBAAyB;AACrE,SAAQC,EAAE,QAAO,YAAY;AAC7B,SAAQC,cAAc,QAAO,oBAAoB;AACjD,SAAQC,UAAU,QAAO,uBAAuB;AAChD,SAAQC,mBAAmB,QAAO,iCAAiC;AACnE,SAAQC,0BAA0B,QAAO,yCAAyC;AAClF,SAAQC,6BAA6B,QAAO,4CAA4C;AACxF,SAAQC,mBAAmB,QAAO,mCAAmC;AACrE,SAAQC,iCAAiC,QAAO,gCAAgC;AAChF,SAAQC,oBAAoB,QAAO,yCAAyC;AAC5E,SAAQC,eAAe,QAAO,gCAAgC;AAC9D,SAAQC,4BAA4B,QAAO,qCAAqC;AAChF,SAAQC,oBAAoB,QAAO,qBAAqB;AAExD,MAAMC,4BAA4B;IAAC,GAAGjB,gBAAgB;IAAE,GAAGC,gCAAgC;AAAA;AAG3F,SACEiB,WAAW,EACXC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,QACX,sBAAsB;AAC7B,SACEC,wBAAwB,EACxBC,sBAAsB,EACtBC,uBAAuB,EACvBC,wBAAwB,QACnB,0BAA0B;AAOjC,SAAQC,oBAAoB,EAAEC,aAAa,QAAO,gBAAgB;AAElE,SAAQC,eAAe,QAAO,uBAAuB;AAGrD,SACEC,yBAAyB,EACzBC,4BAA4B,EAC5BC,uBAAuB,EACvBC,6BAA6B,EAC7BC,sBAAsB,EACtBC,8BAA8B,EAC9BC,qBAAqB,EACrBC,+BAA+B,EAC/BC,uBAAuB,EACvBC,mBAAmB,EACnBC,qBAAqB,EACrBC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,kBAAkB,EAClBC,kBAAkB,EAClBC,mBAAmB,QACd,2BAA2B;AAElC,SACEC,uBAAuB,EACvBC,wBAAwB,QACnB,gCAAgC;AACvC,SACE3C,6BAA6B,EAC7B4C,kCAAkC,QAC7B,yBAAyB;AAChC,SAEExC,mBAAmB,EACnByC,8BAA8B,QAGzB,iCAAiC;AACxC,SAAQxC,0BAA0B,QAAO,yCAAyC;AAClF,SACEyC,gBAAgB,EAChBC,uBAAuB,EACvBC,qBAAqB,EACrBC,qBAAqB,QAChB,uCAAuC;AAC9C,SAAQ3C,6BAA6B,QAAO,4CAA4C;AAExF,MAAM4C,aAAapD;AAOnB,OAAO,SAASqD,iBAAiB,EAC/BC,UAAU,EACVC,eAAerD,+BAA+B,EACtB;IACxB,OAAO;QACLsD,MAAM;QACNC,UAAU;YAACtD;YAAIC;YAAgBsD,mBAAmB;QAAM;QACxDC,MAAM;YAACrD;YAAuBC;YAA8BC;SAAgC;QAC5FoD,cAAc9C,qBAAqBb,OAAO4D,qBAAqB;QAC/DC,QAAQ;YACNlD,gBAAgBX,OAAO4D,qBAAqB,EAAEP,YAAYC;YAC1D5C;SACD;QACDoD,WAAW;YAACtD,oBAAoB6C;SAAY;QAC5CU,YAAY;YAAC;gBAACR,MAAM;gBAAQS,OAAO5D;gBAAYF;gBAAI+D,cAAcnD;YAAyB;SAAE;QAC5FoD,aAAa;YAACf,WAAWvD,oCAAoCgB;SAA8B;QAC3FuD,0BAA0B;YAAC1D;SAAoC;IACjE;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type AuthTokenType = 'session' | 'job_lease' | 'runner_session';
|
|
2
2
|
export type AuthTokenVerificationOutcome = 'ok' | 'rejected';
|
|
3
3
|
export type AuthTokenRefreshOutcome = 'rotated' | 'grace' | 'rejected';
|
|
4
|
-
export type AuthRateLimitAction = 'login' | 'email-send';
|
|
4
|
+
export type AuthRateLimitAction = 'login' | 'email-send' | 'bootstrap';
|
|
5
5
|
export type AuthRateLimitScope = 'ip' | 'email';
|
|
6
6
|
export type AuthRateLimitOutcome = 'allowed' | 'blocked' | 'unavailable';
|
|
7
7
|
export declare function recordTokenIssued(tokenType: AuthTokenType): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/metrics/instance.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,CAAC;AACvE,MAAM,MAAM,4BAA4B,GAAG,IAAI,GAAG,UAAU,CAAC;AAC7D,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;AACvE,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/metrics/instance.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,CAAC;AACvE,MAAM,MAAM,4BAA4B,GAAG,IAAI,GAAG,UAAU,CAAC;AAC7D,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;AACvE,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,YAAY,GAAG,WAAW,CAAC;AACvE,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,OAAO,CAAC;AAChD,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAC;AAsCzE,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAEhE;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,4BAA4B,GACpC,IAAI,CAEN;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAE3E;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC/C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,OAAO,EAAE,oBAAoB,CAAC;CAC/B,GAAG,IAAI,CAQP;AAED,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/metrics/instance.ts"],"sourcesContent":["import {instanceMetrics} from '@shipfox/node-opentelemetry';\n\nexport type AuthTokenType = 'session' | 'job_lease' | 'runner_session';\nexport type AuthTokenVerificationOutcome = 'ok' | 'rejected';\nexport type AuthTokenRefreshOutcome = 'rotated' | 'grace' | 'rejected';\nexport type AuthRateLimitAction = 'login' | 'email-send';\nexport type AuthRateLimitScope = 'ip' | 'email';\nexport type AuthRateLimitOutcome = 'allowed' | 'blocked' | 'unavailable';\n\nconst meter = instanceMetrics.getMeter('auth');\n\nconst tokenIssuedCount = meter.createCounter<{token_type: AuthTokenType}>('auth_token_issued', {\n description: 'Tokens issued by token type',\n});\n\nconst tokenVerifiedCount = meter.createCounter<{\n token_type: AuthTokenType;\n outcome: AuthTokenVerificationOutcome;\n}>('auth_token_verified', {description: 'Token verification attempts by token type and outcome'});\n\nconst tokenRefreshedCount = meter.createCounter<{outcome: AuthTokenRefreshOutcome}>(\n 'auth_token_refreshed',\n {description: 'Refresh-token exchanges by outcome'},\n);\n\nconst rateLimitCheckCount = meter.createCounter<{\n action: AuthRateLimitAction;\n scope: AuthRateLimitScope;\n outcome: AuthRateLimitOutcome;\n}>('auth_rate_limit_checks', {\n description: 'Authentication rate limit checks by action, scope, and outcome',\n});\n\nconst rateLimitPruneFailureCount = meter.createCounter('auth_rate_limit_prune_failures', {\n description: 'Authentication rate limit prune failures',\n});\n\nfunction recordMetric(record: () => void): void {\n try {\n record();\n } catch {\n // Metrics must not affect authentication outcomes.\n }\n}\n\nexport function recordTokenIssued(tokenType: AuthTokenType): void {\n recordMetric(() => tokenIssuedCount.add(1, {token_type: tokenType}));\n}\n\nexport function recordTokenVerified(\n tokenType: AuthTokenType,\n outcome: AuthTokenVerificationOutcome,\n): void {\n recordMetric(() => tokenVerifiedCount.add(1, {token_type: tokenType, outcome}));\n}\n\nexport function recordTokenRefreshed(outcome: AuthTokenRefreshOutcome): void {\n recordMetric(() => tokenRefreshedCount.add(1, {outcome}));\n}\n\nexport function recordAuthRateLimitCheck(params: {\n action: AuthRateLimitAction;\n scope: AuthRateLimitScope;\n outcome: AuthRateLimitOutcome;\n}): void {\n recordMetric(() =>\n rateLimitCheckCount.add(1, {\n action: params.action,\n scope: params.scope,\n outcome: params.outcome,\n }),\n );\n}\n\nexport function recordAuthRateLimitPruneFailure(): void {\n recordMetric(() => rateLimitPruneFailureCount.add(1));\n}\n"],"names":["instanceMetrics","meter","getMeter","tokenIssuedCount","createCounter","description","tokenVerifiedCount","tokenRefreshedCount","rateLimitCheckCount","rateLimitPruneFailureCount","recordMetric","record","recordTokenIssued","tokenType","add","token_type","recordTokenVerified","outcome","recordTokenRefreshed","recordAuthRateLimitCheck","params","action","scope","recordAuthRateLimitPruneFailure"],"mappings":"AAAA,SAAQA,eAAe,QAAO,8BAA8B;AAS5D,MAAMC,QAAQD,gBAAgBE,QAAQ,CAAC;AAEvC,MAAMC,mBAAmBF,MAAMG,aAAa,CAA8B,qBAAqB;IAC7FC,aAAa;AACf;AAEA,MAAMC,qBAAqBL,MAAMG,aAAa,CAG3C,uBAAuB;IAACC,aAAa;AAAuD;AAE/F,MAAME,sBAAsBN,MAAMG,aAAa,CAC7C,wBACA;IAACC,aAAa;AAAoC;AAGpD,MAAMG,sBAAsBP,MAAMG,aAAa,CAI5C,0BAA0B;IAC3BC,aAAa;AACf;AAEA,MAAMI,6BAA6BR,MAAMG,aAAa,CAAC,kCAAkC;IACvFC,aAAa;AACf;AAEA,SAASK,aAAaC,MAAkB;IACtC,IAAI;QACFA;IACF,EAAE,OAAM;IACN,mDAAmD;IACrD;AACF;AAEA,OAAO,SAASC,kBAAkBC,SAAwB;IACxDH,aAAa,IAAMP,iBAAiBW,GAAG,CAAC,GAAG;YAACC,YAAYF;QAAS;AACnE;AAEA,OAAO,SAASG,oBACdH,SAAwB,EACxBI,OAAqC;IAErCP,aAAa,IAAMJ,mBAAmBQ,GAAG,CAAC,GAAG;YAACC,YAAYF;YAAWI;QAAO;AAC9E;AAEA,OAAO,SAASC,qBAAqBD,OAAgC;IACnEP,aAAa,IAAMH,oBAAoBO,GAAG,CAAC,GAAG;YAACG;QAAO;AACxD;AAEA,OAAO,SAASE,yBAAyBC,MAIxC;IACCV,aAAa,IACXF,oBAAoBM,GAAG,CAAC,GAAG;YACzBO,QAAQD,OAAOC,MAAM;YACrBC,OAAOF,OAAOE,KAAK;YACnBL,SAASG,OAAOH,OAAO;QACzB;AAEJ;AAEA,OAAO,SAASM;IACdb,aAAa,IAAMD,2BAA2BK,GAAG,CAAC;AACpD"}
|
|
1
|
+
{"version":3,"sources":["../../src/metrics/instance.ts"],"sourcesContent":["import {instanceMetrics} from '@shipfox/node-opentelemetry';\n\nexport type AuthTokenType = 'session' | 'job_lease' | 'runner_session';\nexport type AuthTokenVerificationOutcome = 'ok' | 'rejected';\nexport type AuthTokenRefreshOutcome = 'rotated' | 'grace' | 'rejected';\nexport type AuthRateLimitAction = 'login' | 'email-send' | 'bootstrap';\nexport type AuthRateLimitScope = 'ip' | 'email';\nexport type AuthRateLimitOutcome = 'allowed' | 'blocked' | 'unavailable';\n\nconst meter = instanceMetrics.getMeter('auth');\n\nconst tokenIssuedCount = meter.createCounter<{token_type: AuthTokenType}>('auth_token_issued', {\n description: 'Tokens issued by token type',\n});\n\nconst tokenVerifiedCount = meter.createCounter<{\n token_type: AuthTokenType;\n outcome: AuthTokenVerificationOutcome;\n}>('auth_token_verified', {description: 'Token verification attempts by token type and outcome'});\n\nconst tokenRefreshedCount = meter.createCounter<{outcome: AuthTokenRefreshOutcome}>(\n 'auth_token_refreshed',\n {description: 'Refresh-token exchanges by outcome'},\n);\n\nconst rateLimitCheckCount = meter.createCounter<{\n action: AuthRateLimitAction;\n scope: AuthRateLimitScope;\n outcome: AuthRateLimitOutcome;\n}>('auth_rate_limit_checks', {\n description: 'Authentication rate limit checks by action, scope, and outcome',\n});\n\nconst rateLimitPruneFailureCount = meter.createCounter('auth_rate_limit_prune_failures', {\n description: 'Authentication rate limit prune failures',\n});\n\nfunction recordMetric(record: () => void): void {\n try {\n record();\n } catch {\n // Metrics must not affect authentication outcomes.\n }\n}\n\nexport function recordTokenIssued(tokenType: AuthTokenType): void {\n recordMetric(() => tokenIssuedCount.add(1, {token_type: tokenType}));\n}\n\nexport function recordTokenVerified(\n tokenType: AuthTokenType,\n outcome: AuthTokenVerificationOutcome,\n): void {\n recordMetric(() => tokenVerifiedCount.add(1, {token_type: tokenType, outcome}));\n}\n\nexport function recordTokenRefreshed(outcome: AuthTokenRefreshOutcome): void {\n recordMetric(() => tokenRefreshedCount.add(1, {outcome}));\n}\n\nexport function recordAuthRateLimitCheck(params: {\n action: AuthRateLimitAction;\n scope: AuthRateLimitScope;\n outcome: AuthRateLimitOutcome;\n}): void {\n recordMetric(() =>\n rateLimitCheckCount.add(1, {\n action: params.action,\n scope: params.scope,\n outcome: params.outcome,\n }),\n );\n}\n\nexport function recordAuthRateLimitPruneFailure(): void {\n recordMetric(() => rateLimitPruneFailureCount.add(1));\n}\n"],"names":["instanceMetrics","meter","getMeter","tokenIssuedCount","createCounter","description","tokenVerifiedCount","tokenRefreshedCount","rateLimitCheckCount","rateLimitPruneFailureCount","recordMetric","record","recordTokenIssued","tokenType","add","token_type","recordTokenVerified","outcome","recordTokenRefreshed","recordAuthRateLimitCheck","params","action","scope","recordAuthRateLimitPruneFailure"],"mappings":"AAAA,SAAQA,eAAe,QAAO,8BAA8B;AAS5D,MAAMC,QAAQD,gBAAgBE,QAAQ,CAAC;AAEvC,MAAMC,mBAAmBF,MAAMG,aAAa,CAA8B,qBAAqB;IAC7FC,aAAa;AACf;AAEA,MAAMC,qBAAqBL,MAAMG,aAAa,CAG3C,uBAAuB;IAACC,aAAa;AAAuD;AAE/F,MAAME,sBAAsBN,MAAMG,aAAa,CAC7C,wBACA;IAACC,aAAa;AAAoC;AAGpD,MAAMG,sBAAsBP,MAAMG,aAAa,CAI5C,0BAA0B;IAC3BC,aAAa;AACf;AAEA,MAAMI,6BAA6BR,MAAMG,aAAa,CAAC,kCAAkC;IACvFC,aAAa;AACf;AAEA,SAASK,aAAaC,MAAkB;IACtC,IAAI;QACFA;IACF,EAAE,OAAM;IACN,mDAAmD;IACrD;AACF;AAEA,OAAO,SAASC,kBAAkBC,SAAwB;IACxDH,aAAa,IAAMP,iBAAiBW,GAAG,CAAC,GAAG;YAACC,YAAYF;QAAS;AACnE;AAEA,OAAO,SAASG,oBACdH,SAAwB,EACxBI,OAAqC;IAErCP,aAAa,IAAMJ,mBAAmBQ,GAAG,CAAC,GAAG;YAACC,YAAYF;YAAWI;QAAO;AAC9E;AAEA,OAAO,SAASC,qBAAqBD,OAAgC;IACnEP,aAAa,IAAMH,oBAAoBO,GAAG,CAAC,GAAG;YAACG;QAAO;AACxD;AAEA,OAAO,SAASE,yBAAyBC,MAIxC;IACCV,aAAa,IACXF,oBAAoBM,GAAG,CAAC,GAAG;YACzBO,QAAQD,OAAOC,MAAM;YACrBC,OAAOF,OAAOE,KAAK;YACnBL,SAASG,OAAOH,OAAO;QACzB;AAEJ;AAEA,OAAO,SAASM;IACdb,aAAa,IAAMD,2BAA2BK,GAAG,CAAC;AACpD"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { LoginResponseDto, UserDto } from '@shipfox/api-auth-dto';
|
|
1
|
+
import type { AdminRole, LoginResponseDto, UserDto } from '@shipfox/api-auth-dto';
|
|
2
2
|
import type { User } from '#core/entities/user.js';
|
|
3
3
|
export declare function toUserDto(user: User): UserDto;
|
|
4
4
|
export declare function toAuthSessionDto(result: {
|
|
5
5
|
token: string;
|
|
6
6
|
user: User;
|
|
7
|
+
adminRole?: AdminRole | null;
|
|
7
8
|
}): LoginResponseDto;
|
|
8
9
|
//# sourceMappingURL=user.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,OAAO,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAChF,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAEjD,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU7C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAC9B,GAAG,gBAAgB,CAMnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/dto/user.ts"],"sourcesContent":["import type {LoginResponseDto, UserDto} from '@shipfox/api-auth-dto';\nimport type {User} from '#core/entities/user.js';\n\nexport function toUserDto(user: User): UserDto {\n return {\n id: user.id,\n email: user.email,\n name: user.name,\n email_verified_at: user.emailVerifiedAt ? user.emailVerifiedAt.toISOString() : null,\n status: user.status,\n created_at: user.createdAt.toISOString(),\n updated_at: user.updatedAt.toISOString(),\n };\n}\n\nexport function toAuthSessionDto(result: {token: string
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/dto/user.ts"],"sourcesContent":["import type {AdminRole, LoginResponseDto, UserDto} from '@shipfox/api-auth-dto';\nimport type {User} from '#core/entities/user.js';\n\nexport function toUserDto(user: User): UserDto {\n return {\n id: user.id,\n email: user.email,\n name: user.name,\n email_verified_at: user.emailVerifiedAt ? user.emailVerifiedAt.toISOString() : null,\n status: user.status,\n created_at: user.createdAt.toISOString(),\n updated_at: user.updatedAt.toISOString(),\n };\n}\n\nexport function toAuthSessionDto(result: {\n token: string;\n user: User;\n adminRole?: AdminRole | null;\n}): LoginResponseDto {\n return {\n token: result.token,\n user: toUserDto(result.user),\n admin_role: result.adminRole ?? null,\n };\n}\n"],"names":["toUserDto","user","id","email","name","email_verified_at","emailVerifiedAt","toISOString","status","created_at","createdAt","updated_at","updatedAt","toAuthSessionDto","result","token","admin_role","adminRole"],"mappings":"AAGA,OAAO,SAASA,UAAUC,IAAU;IAClC,OAAO;QACLC,IAAID,KAAKC,EAAE;QACXC,OAAOF,KAAKE,KAAK;QACjBC,MAAMH,KAAKG,IAAI;QACfC,mBAAmBJ,KAAKK,eAAe,GAAGL,KAAKK,eAAe,CAACC,WAAW,KAAK;QAC/EC,QAAQP,KAAKO,MAAM;QACnBC,YAAYR,KAAKS,SAAS,CAACH,WAAW;QACtCI,YAAYV,KAAKW,SAAS,CAACL,WAAW;IACxC;AACF;AAEA,OAAO,SAASM,iBAAiBC,MAIhC;IACC,OAAO;QACLC,OAAOD,OAAOC,KAAK;QACnBd,MAAMD,UAAUc,OAAOb,IAAI;QAC3Be,YAAYF,OAAOG,SAAS,IAAI;IAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,oCAAoC,CAAC;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAM/B,wBAAgB,iCAAiC,IAAI,uBAAuB,CAC1E,OAAO,uBAAuB,CAC/B,CAoBA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { authInterModuleContract } from '@shipfox/api-auth-dto/inter-module';
|
|
2
|
-
import { defineInterModulePresentation } from '@shipfox/inter-module';
|
|
2
|
+
import { createInterModuleKnownError, defineInterModulePresentation } from '@shipfox/inter-module';
|
|
3
|
+
import { getCurrentAdminRole, requireAdminRole } from '#core/admin-role.js';
|
|
4
|
+
import { AdminRoleRequiredError } from '#core/errors.js';
|
|
3
5
|
import { issueJobLeaseToken } from '#core/job-lease-token.js';
|
|
4
6
|
import { issueRunnerSessionToken } from '#core/runner-session-token.js';
|
|
5
7
|
export function createAuthInterModulePresentation() {
|
|
@@ -9,7 +11,29 @@ export function createAuthInterModulePresentation() {
|
|
|
9
11
|
}),
|
|
10
12
|
mintJobLeaseToken: async (claims)=>({
|
|
11
13
|
token: await issueJobLeaseToken(claims)
|
|
12
|
-
})
|
|
14
|
+
}),
|
|
15
|
+
getCurrentAdminRole: async ({ userId })=>({
|
|
16
|
+
role: await getCurrentAdminRole({
|
|
17
|
+
userId
|
|
18
|
+
})
|
|
19
|
+
}),
|
|
20
|
+
requireAdminRole: async ({ userId, minimumRole })=>{
|
|
21
|
+
try {
|
|
22
|
+
return {
|
|
23
|
+
role: await requireAdminRole({
|
|
24
|
+
userId,
|
|
25
|
+
minimumRole
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (error instanceof AdminRoleRequiredError) {
|
|
30
|
+
throw createInterModuleKnownError(authInterModuleContract.methods.requireAdminRole, 'admin-role-required', {
|
|
31
|
+
requiredRole: error.minimumRole
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
13
37
|
});
|
|
14
38
|
}
|
|
15
39
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import {authInterModuleContract} from '@shipfox/api-auth-dto/inter-module';\nimport {defineInterModulePresentation
|
|
1
|
+
{"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import {authInterModuleContract} from '@shipfox/api-auth-dto/inter-module';\nimport {\n createInterModuleKnownError,\n defineInterModulePresentation,\n type InterModulePresentation,\n} from '@shipfox/inter-module';\nimport {getCurrentAdminRole, requireAdminRole} from '#core/admin-role.js';\nimport {AdminRoleRequiredError} from '#core/errors.js';\nimport {issueJobLeaseToken} from '#core/job-lease-token.js';\nimport {issueRunnerSessionToken} from '#core/runner-session-token.js';\n\nexport function createAuthInterModulePresentation(): InterModulePresentation<\n typeof authInterModuleContract\n> {\n return defineInterModulePresentation(authInterModuleContract, {\n mintRunnerSessionToken: async (claims) => ({token: await issueRunnerSessionToken(claims)}),\n mintJobLeaseToken: async (claims) => ({token: await issueJobLeaseToken(claims)}),\n getCurrentAdminRole: async ({userId}) => ({role: await getCurrentAdminRole({userId})}),\n requireAdminRole: async ({userId, minimumRole}) => {\n try {\n return {role: await requireAdminRole({userId, minimumRole})};\n } catch (error) {\n if (error instanceof AdminRoleRequiredError) {\n throw createInterModuleKnownError(\n authInterModuleContract.methods.requireAdminRole,\n 'admin-role-required',\n {requiredRole: error.minimumRole},\n );\n }\n throw error;\n }\n },\n });\n}\n"],"names":["authInterModuleContract","createInterModuleKnownError","defineInterModulePresentation","getCurrentAdminRole","requireAdminRole","AdminRoleRequiredError","issueJobLeaseToken","issueRunnerSessionToken","createAuthInterModulePresentation","mintRunnerSessionToken","claims","token","mintJobLeaseToken","userId","role","minimumRole","error","methods","requiredRole"],"mappings":"AAAA,SAAQA,uBAAuB,QAAO,qCAAqC;AAC3E,SACEC,2BAA2B,EAC3BC,6BAA6B,QAExB,wBAAwB;AAC/B,SAAQC,mBAAmB,EAAEC,gBAAgB,QAAO,sBAAsB;AAC1E,SAAQC,sBAAsB,QAAO,kBAAkB;AACvD,SAAQC,kBAAkB,QAAO,2BAA2B;AAC5D,SAAQC,uBAAuB,QAAO,gCAAgC;AAEtE,OAAO,SAASC;IAGd,OAAON,8BAA8BF,yBAAyB;QAC5DS,wBAAwB,OAAOC,SAAY,CAAA;gBAACC,OAAO,MAAMJ,wBAAwBG;YAAO,CAAA;QACxFE,mBAAmB,OAAOF,SAAY,CAAA;gBAACC,OAAO,MAAML,mBAAmBI;YAAO,CAAA;QAC9EP,qBAAqB,OAAO,EAACU,MAAM,EAAC,GAAM,CAAA;gBAACC,MAAM,MAAMX,oBAAoB;oBAACU;gBAAM;YAAE,CAAA;QACpFT,kBAAkB,OAAO,EAACS,MAAM,EAAEE,WAAW,EAAC;YAC5C,IAAI;gBACF,OAAO;oBAACD,MAAM,MAAMV,iBAAiB;wBAACS;wBAAQE;oBAAW;gBAAE;YAC7D,EAAE,OAAOC,OAAO;gBACd,IAAIA,iBAAiBX,wBAAwB;oBAC3C,MAAMJ,4BACJD,wBAAwBiB,OAAO,CAACb,gBAAgB,EAChD,uBACA;wBAACc,cAAcF,MAAMD,WAAW;oBAAA;gBAEpC;gBACA,MAAMC;YACR;QACF;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"administration.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/administration.ts"],"names":[],"mappings":"AAUA,OAAO,EAA2B,KAAK,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAoLhF,eAAO,MAAM,oBAAoB,EAAE,UAIlC,CAAC"}
|