@shipfox/api-auth 18.0.0 → 20.0.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 +17 -2
- package/CHANGELOG.md +47 -0
- package/README.md +24 -9
- package/dist/core/administration.d.ts +15 -0
- package/dist/core/administration.d.ts.map +1 -1
- package/dist/core/administration.js +44 -2
- package/dist/core/administration.js.map +1 -1
- package/dist/core/auth.d.ts.map +1 -1
- package/dist/core/auth.js +5 -3
- package/dist/core/auth.js.map +1 -1
- package/dist/core/cimd.d.ts +39 -0
- package/dist/core/cimd.d.ts.map +1 -0
- package/dist/core/cimd.js +392 -0
- package/dist/core/cimd.js.map +1 -0
- package/dist/core/entities/agent-access.d.ts +75 -0
- package/dist/core/entities/agent-access.d.ts.map +1 -0
- package/dist/core/entities/agent-access.js +3 -0
- package/dist/core/entities/agent-access.js.map +1 -0
- package/dist/core/errors.d.ts +17 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +32 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/oauth-client-resolver.d.ts +54 -0
- package/dist/core/oauth-client-resolver.d.ts.map +1 -0
- package/dist/core/oauth-client-resolver.js +154 -0
- package/dist/core/oauth-client-resolver.js.map +1 -0
- package/dist/core/oauth-client.d.ts +39 -0
- package/dist/core/oauth-client.d.ts.map +1 -0
- package/dist/core/oauth-client.js +236 -0
- package/dist/core/oauth-client.js.map +1 -0
- package/dist/db/admin-user-moderation.d.ts.map +1 -1
- package/dist/db/admin-user-moderation.js +30 -26
- package/dist/db/admin-user-moderation.js.map +1 -1
- package/dist/db/admin-user-summary.d.ts +22 -0
- package/dist/db/admin-user-summary.d.ts.map +1 -1
- package/dist/db/admin-user-summary.js +75 -1
- package/dist/db/admin-user-summary.js.map +1 -1
- package/dist/db/admin-users.d.ts +11 -0
- package/dist/db/admin-users.d.ts.map +1 -1
- package/dist/db/admin-users.js +4 -1
- package/dist/db/admin-users.js.map +1 -1
- package/dist/db/agent-access-retention.d.ts +10 -0
- package/dist/db/agent-access-retention.d.ts.map +1 -0
- package/dist/db/agent-access-retention.js +11 -0
- package/dist/db/agent-access-retention.js.map +1 -0
- package/dist/db/agent-access.d.ts +255 -0
- package/dist/db/agent-access.d.ts.map +1 -0
- package/dist/db/agent-access.js +705 -0
- package/dist/db/agent-access.js.map +1 -0
- package/dist/db/db.d.ts +2604 -238
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +7 -0
- package/dist/db/db.js.map +1 -1
- package/dist/db/schema/agent-access.d.ts +1204 -0
- package/dist/db/schema/agent-access.d.ts.map +1 -0
- package/dist/db/schema/agent-access.js +267 -0
- package/dist/db/schema/agent-access.js.map +1 -0
- package/dist/db/schema/users.d.ts.map +1 -1
- package/dist/db/schema/users.js +8 -3
- package/dist/db/schema/users.js.map +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -2
- 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/routes/administration.d.ts.map +1 -1
- package/dist/presentation/routes/administration.js +123 -20
- package/dist/presentation/routes/administration.js.map +1 -1
- package/dist/presentation/routes/email-verification/verify-email-resend.d.ts.map +1 -1
- package/dist/presentation/routes/email-verification/verify-email-resend.js +6 -1
- package/dist/presentation/routes/email-verification/verify-email-resend.js.map +1 -1
- package/dist/presentation/routes/oauth.d.ts +9 -0
- package/dist/presentation/routes/oauth.d.ts.map +1 -0
- package/dist/presentation/routes/oauth.js +150 -0
- package/dist/presentation/routes/oauth.js.map +1 -0
- package/dist/presentation/routes/rate-limit.d.ts.map +1 -1
- package/dist/presentation/routes/rate-limit.js +34 -0
- package/dist/presentation/routes/rate-limit.js.map +1 -1
- package/dist/presentation/routes/registration/signup.d.ts.map +1 -1
- package/dist/presentation/routes/registration/signup.js +59 -50
- package/dist/presentation/routes/registration/signup.js.map +1 -1
- package/dist/temporal/activities/agent-access-retention.d.ts +13 -0
- package/dist/temporal/activities/agent-access-retention.d.ts.map +1 -0
- package/dist/temporal/activities/agent-access-retention.js +58 -0
- package/dist/temporal/activities/agent-access-retention.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +5 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +8 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/constants.d.ts +2 -0
- package/dist/temporal/constants.d.ts.map +1 -0
- package/dist/temporal/constants.js +3 -0
- package/dist/temporal/constants.js.map +1 -0
- package/dist/temporal/workflows/agent-access-retention-cron.d.ts +2 -0
- package/dist/temporal/workflows/agent-access-retention-cron.d.ts.map +1 -0
- package/dist/temporal/workflows/agent-access-retention-cron.js +22 -0
- package/dist/temporal/workflows/agent-access-retention-cron.js.map +1 -0
- package/dist/temporal/workflows/index.bundle.js +25227 -0
- package/dist/temporal/workflows/index.bundle.meta.json +1 -0
- package/dist/temporal/workflows/index.d.ts +2 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +3 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/drizzle/0003_brainy_luckman.sql +6 -0
- package/drizzle/0004_yummy_runaways.sql +110 -0
- package/drizzle/meta/0003_snapshot.json +844 -0
- package/drizzle/meta/0004_snapshot.json +1751 -0
- package/drizzle/meta/_journal.json +14 -0
- package/package.json +11 -8
- package/src/core/admin-role.test.ts +70 -0
- package/src/core/administration.ts +78 -1
- package/src/core/auth.ts +3 -5
- package/src/core/cimd.test.ts +213 -0
- package/src/core/cimd.ts +532 -0
- package/src/core/entities/agent-access.ts +80 -0
- package/src/core/errors.ts +48 -0
- package/src/core/oauth-client-resolver.test.ts +198 -0
- package/src/core/oauth-client-resolver.ts +253 -0
- package/src/core/oauth-client.test.ts +157 -0
- package/src/core/oauth-client.ts +331 -0
- package/src/db/admin-user-moderation.ts +53 -45
- package/src/db/admin-user-summary.test.ts +228 -0
- package/src/db/admin-user-summary.ts +143 -1
- package/src/db/admin-users.ts +21 -1
- package/src/db/agent-access-retention.ts +10 -0
- package/src/db/agent-access.test.ts +1064 -0
- package/src/db/agent-access.ts +1491 -0
- package/src/db/db.ts +14 -0
- package/src/db/schema/agent-access.ts +273 -0
- package/src/db/schema/users.ts +9 -3
- package/src/index.test.ts +27 -0
- package/src/index.ts +82 -0
- package/src/metrics/instance.ts +6 -1
- package/src/presentation/routes/administration.test.ts +359 -2
- package/src/presentation/routes/administration.ts +142 -20
- package/src/presentation/routes/email-verification/verify-email-resend.ts +7 -1
- package/src/presentation/routes/oauth.test.ts +133 -0
- package/src/presentation/routes/oauth.ts +144 -0
- package/src/presentation/routes/rate-limit.ts +16 -0
- package/src/presentation/routes/registration/signup.ts +52 -41
- package/src/temporal/activities/agent-access-retention.ts +76 -0
- package/src/temporal/activities/index.ts +5 -0
- package/src/temporal/constants.ts +1 -0
- package/src/temporal/workflows/agent-access-retention-cron.ts +23 -0
- package/src/temporal/workflows/index.ts +1 -0
- package/test/globalSetup.ts +1 -1
- package/test/routes.ts +3 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-access.d.ts","sourceRoot":"","sources":["../../../src/db/schema/agent-access.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EACzB,WAAW,EAEX,UAAU,EACV,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,gCAAgC,CAAC;AAIxC,eAAO,MAAM,mBAAmB,8DAA2D,CAAC;AAE5F,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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wB,CAAC,GAAG,EAAE,wBAAwB,GAAG,sBAAsB,CAa9F;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,mBAAmB,GAAG,iBAAiB,CAY/E;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,0BAA0B,GAC9B,wBAAwB,CAe1B"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { uuidv7PrimaryKey } from '@shipfox/node-drizzle';
|
|
2
|
+
import { sql } from 'drizzle-orm';
|
|
3
|
+
import { index, pgEnum, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
|
|
4
|
+
import { pgTable } from './common.js';
|
|
5
|
+
import { users } from './users.js';
|
|
6
|
+
export const agentClientKindEnum = pgEnum('auth_agent_client_kind', [
|
|
7
|
+
'registered',
|
|
8
|
+
'cimd'
|
|
9
|
+
]);
|
|
10
|
+
export const agentClients = pgTable('agent_clients', {
|
|
11
|
+
id: uuidv7PrimaryKey(),
|
|
12
|
+
clientId: text('client_id').notNull(),
|
|
13
|
+
name: text('name').notNull(),
|
|
14
|
+
redirectUris: text('redirect_uris').array().notNull(),
|
|
15
|
+
kind: agentClientKindEnum('kind').notNull(),
|
|
16
|
+
lastSeenAt: timestamp('last_seen_at', {
|
|
17
|
+
withTimezone: true
|
|
18
|
+
}),
|
|
19
|
+
unreferencedAt: timestamp('unreferenced_at', {
|
|
20
|
+
withTimezone: true
|
|
21
|
+
}),
|
|
22
|
+
createdAt: timestamp('created_at', {
|
|
23
|
+
withTimezone: true
|
|
24
|
+
}).notNull().defaultNow(),
|
|
25
|
+
updatedAt: timestamp('updated_at', {
|
|
26
|
+
withTimezone: true
|
|
27
|
+
}).notNull().defaultNow()
|
|
28
|
+
}, (table)=>[
|
|
29
|
+
uniqueIndex('auth_agent_clients_client_id_unique').on(table.clientId),
|
|
30
|
+
index('auth_agent_clients_unreferenced_at_idx').on(table.unreferencedAt),
|
|
31
|
+
index('auth_agent_clients_created_at_idx').on(table.createdAt)
|
|
32
|
+
]);
|
|
33
|
+
export const agentAuthorizationRequests = pgTable('agent_authorization_requests', {
|
|
34
|
+
id: uuidv7PrimaryKey(),
|
|
35
|
+
clientId: uuid('client_id').notNull().references(()=>agentClients.id, {
|
|
36
|
+
onDelete: 'cascade'
|
|
37
|
+
}),
|
|
38
|
+
redirectUri: text('redirect_uri').notNull(),
|
|
39
|
+
resource: text('resource').notNull(),
|
|
40
|
+
scopes: text('scopes').array().notNull(),
|
|
41
|
+
codeChallenge: text('code_challenge').notNull(),
|
|
42
|
+
state: text('state'),
|
|
43
|
+
expiresAt: timestamp('expires_at', {
|
|
44
|
+
withTimezone: true
|
|
45
|
+
}).notNull(),
|
|
46
|
+
consumedAt: timestamp('consumed_at', {
|
|
47
|
+
withTimezone: true
|
|
48
|
+
}),
|
|
49
|
+
createdAt: timestamp('created_at', {
|
|
50
|
+
withTimezone: true
|
|
51
|
+
}).notNull().defaultNow(),
|
|
52
|
+
updatedAt: timestamp('updated_at', {
|
|
53
|
+
withTimezone: true
|
|
54
|
+
}).notNull().defaultNow()
|
|
55
|
+
}, (table)=>[
|
|
56
|
+
index('auth_agent_authorization_requests_client_id_idx').on(table.clientId),
|
|
57
|
+
index('auth_agent_authorization_requests_expires_at_idx').on(table.expiresAt)
|
|
58
|
+
]);
|
|
59
|
+
export const agentGrants = pgTable('agent_grants', {
|
|
60
|
+
id: uuidv7PrimaryKey(),
|
|
61
|
+
userId: uuid('user_id').notNull().references(()=>users.id, {
|
|
62
|
+
onDelete: 'cascade'
|
|
63
|
+
}),
|
|
64
|
+
workspaceId: uuid('workspace_id').notNull(),
|
|
65
|
+
clientId: uuid('client_id').notNull().references(()=>agentClients.id, {
|
|
66
|
+
onDelete: 'cascade'
|
|
67
|
+
}),
|
|
68
|
+
scopes: text('scopes').array().notNull(),
|
|
69
|
+
lastUsedAt: timestamp('last_used_at', {
|
|
70
|
+
withTimezone: true
|
|
71
|
+
}),
|
|
72
|
+
revokedAt: timestamp('revoked_at', {
|
|
73
|
+
withTimezone: true
|
|
74
|
+
}),
|
|
75
|
+
terminalAt: timestamp('terminal_at', {
|
|
76
|
+
withTimezone: true
|
|
77
|
+
}),
|
|
78
|
+
createdAt: timestamp('created_at', {
|
|
79
|
+
withTimezone: true
|
|
80
|
+
}).notNull().defaultNow(),
|
|
81
|
+
updatedAt: timestamp('updated_at', {
|
|
82
|
+
withTimezone: true
|
|
83
|
+
}).notNull().defaultNow()
|
|
84
|
+
}, (table)=>[
|
|
85
|
+
index('auth_agent_grants_user_id_idx').on(table.userId),
|
|
86
|
+
index('auth_agent_grants_workspace_id_idx').on(table.workspaceId),
|
|
87
|
+
index('auth_agent_grants_client_id_idx').on(table.clientId),
|
|
88
|
+
index('auth_agent_grants_terminal_at_idx').on(table.terminalAt),
|
|
89
|
+
uniqueIndex('auth_agent_grants_active_user_workspace_client_unique').on(table.userId, table.workspaceId, table.clientId).where(sql`${table.revokedAt} IS NULL AND ${table.terminalAt} IS NULL`)
|
|
90
|
+
]);
|
|
91
|
+
export const agentAuthorizationCodes = pgTable('agent_authorization_codes', {
|
|
92
|
+
id: uuidv7PrimaryKey(),
|
|
93
|
+
grantId: uuid('grant_id').notNull().references(()=>agentGrants.id, {
|
|
94
|
+
onDelete: 'cascade'
|
|
95
|
+
}),
|
|
96
|
+
hashedCode: text('hashed_code').notNull(),
|
|
97
|
+
codeChallenge: text('code_challenge').notNull(),
|
|
98
|
+
redirectUri: text('redirect_uri').notNull(),
|
|
99
|
+
resource: text('resource').notNull(),
|
|
100
|
+
expiresAt: timestamp('expires_at', {
|
|
101
|
+
withTimezone: true
|
|
102
|
+
}).notNull(),
|
|
103
|
+
consumedAt: timestamp('consumed_at', {
|
|
104
|
+
withTimezone: true
|
|
105
|
+
}),
|
|
106
|
+
createdAt: timestamp('created_at', {
|
|
107
|
+
withTimezone: true
|
|
108
|
+
}).notNull().defaultNow(),
|
|
109
|
+
updatedAt: timestamp('updated_at', {
|
|
110
|
+
withTimezone: true
|
|
111
|
+
}).notNull().defaultNow()
|
|
112
|
+
}, (table)=>[
|
|
113
|
+
uniqueIndex('auth_agent_authorization_codes_hashed_code_unique').on(table.hashedCode),
|
|
114
|
+
index('auth_agent_authorization_codes_grant_id_idx').on(table.grantId),
|
|
115
|
+
index('auth_agent_authorization_codes_expires_at_idx').on(table.expiresAt)
|
|
116
|
+
]);
|
|
117
|
+
export const agentRefreshTokens = pgTable('agent_refresh_tokens', {
|
|
118
|
+
id: uuidv7PrimaryKey(),
|
|
119
|
+
grantId: uuid('grant_id').notNull().references(()=>agentGrants.id, {
|
|
120
|
+
onDelete: 'cascade'
|
|
121
|
+
}),
|
|
122
|
+
hashedToken: text('hashed_token').notNull(),
|
|
123
|
+
expiresAt: timestamp('expires_at', {
|
|
124
|
+
withTimezone: true
|
|
125
|
+
}).notNull(),
|
|
126
|
+
rotatedAt: timestamp('rotated_at', {
|
|
127
|
+
withTimezone: true
|
|
128
|
+
}),
|
|
129
|
+
revokedAt: timestamp('revoked_at', {
|
|
130
|
+
withTimezone: true
|
|
131
|
+
}),
|
|
132
|
+
lastUsedAt: timestamp('last_used_at', {
|
|
133
|
+
withTimezone: true
|
|
134
|
+
}),
|
|
135
|
+
createdAt: timestamp('created_at', {
|
|
136
|
+
withTimezone: true
|
|
137
|
+
}).notNull().defaultNow(),
|
|
138
|
+
updatedAt: timestamp('updated_at', {
|
|
139
|
+
withTimezone: true
|
|
140
|
+
}).notNull().defaultNow()
|
|
141
|
+
}, (table)=>[
|
|
142
|
+
uniqueIndex('auth_agent_refresh_tokens_hashed_token_unique').on(table.hashedToken),
|
|
143
|
+
uniqueIndex('auth_agent_refresh_tokens_live_grant_unique').on(table.grantId).where(sql`${table.rotatedAt} IS NULL AND ${table.revokedAt} IS NULL`),
|
|
144
|
+
index('auth_agent_refresh_tokens_grant_id_idx').on(table.grantId),
|
|
145
|
+
index('auth_agent_refresh_tokens_expires_at_idx').on(table.expiresAt),
|
|
146
|
+
index('auth_agent_refresh_tokens_rotated_at_idx').on(table.rotatedAt),
|
|
147
|
+
index('auth_agent_refresh_tokens_revoked_at_idx').on(table.revokedAt)
|
|
148
|
+
]);
|
|
149
|
+
export const agentPersonalAccessTokens = pgTable('agent_pats', {
|
|
150
|
+
id: uuidv7PrimaryKey(),
|
|
151
|
+
userId: uuid('user_id').notNull().references(()=>users.id, {
|
|
152
|
+
onDelete: 'cascade'
|
|
153
|
+
}),
|
|
154
|
+
workspaceId: uuid('workspace_id').notNull(),
|
|
155
|
+
hashedToken: text('hashed_token').notNull(),
|
|
156
|
+
prefix: text('prefix').notNull(),
|
|
157
|
+
name: text('name').notNull(),
|
|
158
|
+
scopes: text('scopes').array().notNull(),
|
|
159
|
+
expiresAt: timestamp('expires_at', {
|
|
160
|
+
withTimezone: true
|
|
161
|
+
}).notNull(),
|
|
162
|
+
lastUsedAt: timestamp('last_used_at', {
|
|
163
|
+
withTimezone: true
|
|
164
|
+
}),
|
|
165
|
+
revokedAt: timestamp('revoked_at', {
|
|
166
|
+
withTimezone: true
|
|
167
|
+
}),
|
|
168
|
+
createdAt: timestamp('created_at', {
|
|
169
|
+
withTimezone: true
|
|
170
|
+
}).notNull().defaultNow(),
|
|
171
|
+
updatedAt: timestamp('updated_at', {
|
|
172
|
+
withTimezone: true
|
|
173
|
+
}).notNull().defaultNow()
|
|
174
|
+
}, (table)=>[
|
|
175
|
+
uniqueIndex('auth_agent_pats_hashed_token_unique').on(table.hashedToken),
|
|
176
|
+
index('auth_agent_pats_user_id_idx').on(table.userId),
|
|
177
|
+
index('auth_agent_pats_workspace_id_idx').on(table.workspaceId),
|
|
178
|
+
index('auth_agent_pats_expires_at_idx').on(table.expiresAt),
|
|
179
|
+
index('auth_agent_pats_revoked_at_idx').on(table.revokedAt)
|
|
180
|
+
]);
|
|
181
|
+
export function toAgentClient(row) {
|
|
182
|
+
return {
|
|
183
|
+
id: row.id,
|
|
184
|
+
clientId: row.clientId,
|
|
185
|
+
name: row.name,
|
|
186
|
+
redirectUris: row.redirectUris,
|
|
187
|
+
kind: row.kind,
|
|
188
|
+
lastSeenAt: row.lastSeenAt,
|
|
189
|
+
unreferencedAt: row.unreferencedAt,
|
|
190
|
+
createdAt: row.createdAt,
|
|
191
|
+
updatedAt: row.updatedAt
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
export function toAgentAuthorizationRequest(row) {
|
|
195
|
+
return {
|
|
196
|
+
id: row.id,
|
|
197
|
+
clientId: row.clientId,
|
|
198
|
+
redirectUri: row.redirectUri,
|
|
199
|
+
resource: row.resource,
|
|
200
|
+
scopes: row.scopes,
|
|
201
|
+
codeChallenge: row.codeChallenge,
|
|
202
|
+
state: row.state,
|
|
203
|
+
expiresAt: row.expiresAt,
|
|
204
|
+
consumedAt: row.consumedAt,
|
|
205
|
+
createdAt: row.createdAt,
|
|
206
|
+
updatedAt: row.updatedAt
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
export function toAgentGrant(row) {
|
|
210
|
+
return {
|
|
211
|
+
id: row.id,
|
|
212
|
+
userId: row.userId,
|
|
213
|
+
workspaceId: row.workspaceId,
|
|
214
|
+
clientId: row.clientId,
|
|
215
|
+
scopes: row.scopes,
|
|
216
|
+
lastUsedAt: row.lastUsedAt,
|
|
217
|
+
revokedAt: row.revokedAt,
|
|
218
|
+
terminalAt: row.terminalAt,
|
|
219
|
+
createdAt: row.createdAt,
|
|
220
|
+
updatedAt: row.updatedAt
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export function toAgentAuthorizationCode(row) {
|
|
224
|
+
return {
|
|
225
|
+
id: row.id,
|
|
226
|
+
grantId: row.grantId,
|
|
227
|
+
hashedCode: row.hashedCode,
|
|
228
|
+
codeChallenge: row.codeChallenge,
|
|
229
|
+
redirectUri: row.redirectUri,
|
|
230
|
+
resource: row.resource,
|
|
231
|
+
expiresAt: row.expiresAt,
|
|
232
|
+
consumedAt: row.consumedAt,
|
|
233
|
+
createdAt: row.createdAt,
|
|
234
|
+
updatedAt: row.updatedAt
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
export function toAgentRefreshToken(row) {
|
|
238
|
+
return {
|
|
239
|
+
id: row.id,
|
|
240
|
+
grantId: row.grantId,
|
|
241
|
+
hashedToken: row.hashedToken,
|
|
242
|
+
expiresAt: row.expiresAt,
|
|
243
|
+
rotatedAt: row.rotatedAt,
|
|
244
|
+
revokedAt: row.revokedAt,
|
|
245
|
+
lastUsedAt: row.lastUsedAt,
|
|
246
|
+
createdAt: row.createdAt,
|
|
247
|
+
updatedAt: row.updatedAt
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
export function toAgentPersonalAccessToken(row) {
|
|
251
|
+
return {
|
|
252
|
+
id: row.id,
|
|
253
|
+
userId: row.userId,
|
|
254
|
+
workspaceId: row.workspaceId,
|
|
255
|
+
hashedToken: row.hashedToken,
|
|
256
|
+
prefix: row.prefix,
|
|
257
|
+
name: row.name,
|
|
258
|
+
scopes: row.scopes,
|
|
259
|
+
expiresAt: row.expiresAt,
|
|
260
|
+
lastUsedAt: row.lastUsedAt,
|
|
261
|
+
revokedAt: row.revokedAt,
|
|
262
|
+
createdAt: row.createdAt,
|
|
263
|
+
updatedAt: row.updatedAt
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
//# sourceMappingURL=agent-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/agent-access.ts"],"sourcesContent":["import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {sql} from 'drizzle-orm';\nimport {index, pgEnum, text, timestamp, uniqueIndex, uuid} from 'drizzle-orm/pg-core';\nimport type {\n AgentAuthorizationCode,\n AgentAuthorizationRequest,\n AgentClient,\n AgentClientKind,\n AgentGrant,\n AgentPersonalAccessToken,\n AgentRefreshToken,\n} from '#core/entities/agent-access.js';\nimport {pgTable} from './common.js';\nimport {users} from './users.js';\n\nexport const agentClientKindEnum = pgEnum('auth_agent_client_kind', ['registered', 'cimd']);\n\nexport const agentClients = pgTable(\n 'agent_clients',\n {\n id: uuidv7PrimaryKey(),\n clientId: text('client_id').notNull(),\n name: text('name').notNull(),\n redirectUris: text('redirect_uris').array().notNull(),\n kind: agentClientKindEnum('kind').notNull(),\n lastSeenAt: timestamp('last_seen_at', {withTimezone: true}),\n unreferencedAt: timestamp('unreferenced_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 uniqueIndex('auth_agent_clients_client_id_unique').on(table.clientId),\n index('auth_agent_clients_unreferenced_at_idx').on(table.unreferencedAt),\n index('auth_agent_clients_created_at_idx').on(table.createdAt),\n ],\n);\n\nexport const agentAuthorizationRequests = pgTable(\n 'agent_authorization_requests',\n {\n id: uuidv7PrimaryKey(),\n clientId: uuid('client_id')\n .notNull()\n .references(() => agentClients.id, {onDelete: 'cascade'}),\n redirectUri: text('redirect_uri').notNull(),\n resource: text('resource').notNull(),\n scopes: text('scopes').array().notNull(),\n codeChallenge: text('code_challenge').notNull(),\n state: text('state'),\n expiresAt: timestamp('expires_at', {withTimezone: true}).notNull(),\n consumedAt: timestamp('consumed_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_agent_authorization_requests_client_id_idx').on(table.clientId),\n index('auth_agent_authorization_requests_expires_at_idx').on(table.expiresAt),\n ],\n);\n\nexport const agentGrants = pgTable(\n 'agent_grants',\n {\n id: uuidv7PrimaryKey(),\n userId: uuid('user_id')\n .notNull()\n .references(() => users.id, {onDelete: 'cascade'}),\n workspaceId: uuid('workspace_id').notNull(),\n clientId: uuid('client_id')\n .notNull()\n .references(() => agentClients.id, {onDelete: 'cascade'}),\n scopes: text('scopes').array().notNull(),\n lastUsedAt: timestamp('last_used_at', {withTimezone: true}),\n revokedAt: timestamp('revoked_at', {withTimezone: true}),\n terminalAt: timestamp('terminal_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_agent_grants_user_id_idx').on(table.userId),\n index('auth_agent_grants_workspace_id_idx').on(table.workspaceId),\n index('auth_agent_grants_client_id_idx').on(table.clientId),\n index('auth_agent_grants_terminal_at_idx').on(table.terminalAt),\n uniqueIndex('auth_agent_grants_active_user_workspace_client_unique')\n .on(table.userId, table.workspaceId, table.clientId)\n .where(sql`${table.revokedAt} IS NULL AND ${table.terminalAt} IS NULL`),\n ],\n);\n\nexport const agentAuthorizationCodes = pgTable(\n 'agent_authorization_codes',\n {\n id: uuidv7PrimaryKey(),\n grantId: uuid('grant_id')\n .notNull()\n .references(() => agentGrants.id, {onDelete: 'cascade'}),\n hashedCode: text('hashed_code').notNull(),\n codeChallenge: text('code_challenge').notNull(),\n redirectUri: text('redirect_uri').notNull(),\n resource: text('resource').notNull(),\n expiresAt: timestamp('expires_at', {withTimezone: true}).notNull(),\n consumedAt: timestamp('consumed_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 uniqueIndex('auth_agent_authorization_codes_hashed_code_unique').on(table.hashedCode),\n index('auth_agent_authorization_codes_grant_id_idx').on(table.grantId),\n index('auth_agent_authorization_codes_expires_at_idx').on(table.expiresAt),\n ],\n);\n\nexport const agentRefreshTokens = pgTable(\n 'agent_refresh_tokens',\n {\n id: uuidv7PrimaryKey(),\n grantId: uuid('grant_id')\n .notNull()\n .references(() => agentGrants.id, {onDelete: 'cascade'}),\n hashedToken: text('hashed_token').notNull(),\n expiresAt: timestamp('expires_at', {withTimezone: true}).notNull(),\n rotatedAt: timestamp('rotated_at', {withTimezone: true}),\n revokedAt: timestamp('revoked_at', {withTimezone: true}),\n lastUsedAt: timestamp('last_used_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 uniqueIndex('auth_agent_refresh_tokens_hashed_token_unique').on(table.hashedToken),\n uniqueIndex('auth_agent_refresh_tokens_live_grant_unique')\n .on(table.grantId)\n .where(sql`${table.rotatedAt} IS NULL AND ${table.revokedAt} IS NULL`),\n index('auth_agent_refresh_tokens_grant_id_idx').on(table.grantId),\n index('auth_agent_refresh_tokens_expires_at_idx').on(table.expiresAt),\n index('auth_agent_refresh_tokens_rotated_at_idx').on(table.rotatedAt),\n index('auth_agent_refresh_tokens_revoked_at_idx').on(table.revokedAt),\n ],\n);\n\nexport const agentPersonalAccessTokens = pgTable(\n 'agent_pats',\n {\n id: uuidv7PrimaryKey(),\n userId: uuid('user_id')\n .notNull()\n .references(() => users.id, {onDelete: 'cascade'}),\n workspaceId: uuid('workspace_id').notNull(),\n hashedToken: text('hashed_token').notNull(),\n prefix: text('prefix').notNull(),\n name: text('name').notNull(),\n scopes: text('scopes').array().notNull(),\n expiresAt: timestamp('expires_at', {withTimezone: true}).notNull(),\n lastUsedAt: timestamp('last_used_at', {withTimezone: true}),\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 uniqueIndex('auth_agent_pats_hashed_token_unique').on(table.hashedToken),\n index('auth_agent_pats_user_id_idx').on(table.userId),\n index('auth_agent_pats_workspace_id_idx').on(table.workspaceId),\n index('auth_agent_pats_expires_at_idx').on(table.expiresAt),\n index('auth_agent_pats_revoked_at_idx').on(table.revokedAt),\n ],\n);\n\nexport type AgentClientDb = typeof agentClients.$inferSelect;\nexport type AgentClientCreateDb = typeof agentClients.$inferInsert;\nexport type AgentAuthorizationRequestDb = typeof agentAuthorizationRequests.$inferSelect;\nexport type AgentAuthorizationRequestCreateDb = typeof agentAuthorizationRequests.$inferInsert;\nexport type AgentGrantDb = typeof agentGrants.$inferSelect;\nexport type AgentGrantCreateDb = typeof agentGrants.$inferInsert;\nexport type AgentAuthorizationCodeDb = typeof agentAuthorizationCodes.$inferSelect;\nexport type AgentAuthorizationCodeCreateDb = typeof agentAuthorizationCodes.$inferInsert;\nexport type AgentRefreshTokenDb = typeof agentRefreshTokens.$inferSelect;\nexport type AgentRefreshTokenCreateDb = typeof agentRefreshTokens.$inferInsert;\nexport type AgentPersonalAccessTokenDb = typeof agentPersonalAccessTokens.$inferSelect;\nexport type AgentPersonalAccessTokenCreateDb = typeof agentPersonalAccessTokens.$inferInsert;\n\nexport function toAgentClient(row: AgentClientDb): AgentClient {\n return {\n id: row.id,\n clientId: row.clientId,\n name: row.name,\n redirectUris: row.redirectUris,\n kind: row.kind as AgentClientKind,\n lastSeenAt: row.lastSeenAt,\n unreferencedAt: row.unreferencedAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nexport function toAgentAuthorizationRequest(\n row: AgentAuthorizationRequestDb,\n): AgentAuthorizationRequest {\n return {\n id: row.id,\n clientId: row.clientId,\n redirectUri: row.redirectUri,\n resource: row.resource,\n scopes: row.scopes,\n codeChallenge: row.codeChallenge,\n state: row.state,\n expiresAt: row.expiresAt,\n consumedAt: row.consumedAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nexport function toAgentGrant(row: AgentGrantDb): AgentGrant {\n return {\n id: row.id,\n userId: row.userId,\n workspaceId: row.workspaceId,\n clientId: row.clientId,\n scopes: row.scopes,\n lastUsedAt: row.lastUsedAt,\n revokedAt: row.revokedAt,\n terminalAt: row.terminalAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nexport function toAgentAuthorizationCode(row: AgentAuthorizationCodeDb): AgentAuthorizationCode {\n return {\n id: row.id,\n grantId: row.grantId,\n hashedCode: row.hashedCode,\n codeChallenge: row.codeChallenge,\n redirectUri: row.redirectUri,\n resource: row.resource,\n expiresAt: row.expiresAt,\n consumedAt: row.consumedAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nexport function toAgentRefreshToken(row: AgentRefreshTokenDb): AgentRefreshToken {\n return {\n id: row.id,\n grantId: row.grantId,\n hashedToken: row.hashedToken,\n expiresAt: row.expiresAt,\n rotatedAt: row.rotatedAt,\n revokedAt: row.revokedAt,\n lastUsedAt: row.lastUsedAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n\nexport function toAgentPersonalAccessToken(\n row: AgentPersonalAccessTokenDb,\n): AgentPersonalAccessToken {\n return {\n id: row.id,\n userId: row.userId,\n workspaceId: row.workspaceId,\n hashedToken: row.hashedToken,\n prefix: row.prefix,\n name: row.name,\n scopes: row.scopes,\n expiresAt: row.expiresAt,\n lastUsedAt: row.lastUsedAt,\n revokedAt: row.revokedAt,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n"],"names":["uuidv7PrimaryKey","sql","index","pgEnum","text","timestamp","uniqueIndex","uuid","pgTable","users","agentClientKindEnum","agentClients","id","clientId","notNull","name","redirectUris","array","kind","lastSeenAt","withTimezone","unreferencedAt","createdAt","defaultNow","updatedAt","table","on","agentAuthorizationRequests","references","onDelete","redirectUri","resource","scopes","codeChallenge","state","expiresAt","consumedAt","agentGrants","userId","workspaceId","lastUsedAt","revokedAt","terminalAt","where","agentAuthorizationCodes","grantId","hashedCode","agentRefreshTokens","hashedToken","rotatedAt","agentPersonalAccessTokens","prefix","toAgentClient","row","toAgentAuthorizationRequest","toAgentGrant","toAgentAuthorizationCode","toAgentRefreshToken","toAgentPersonalAccessToken"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,GAAG,QAAO,cAAc;AAChC,SAAQC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,W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ACxBnB,WAAW+B,IAAI/B,SAAS;QACxBE,WAAW6B,IAAI7B,SAAS;IAC1B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/db/schema/users.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/db/schema/users.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,IAAI,EAAa,MAAM,wBAAwB,CAAC;AAG7D,eAAO,MAAM,cAAc,0EAAiE,CAAC;AAE7F,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,OAAO,KAAK,CAAC,YAAY,CAAC;AAC/C,MAAM,MAAM,YAAY,GAAG,OAAO,KAAK,CAAC,YAAY,CAAC;AAErD,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAWxC"}
|
package/dist/db/schema/users.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { uuidv7PrimaryKey } from '@shipfox/node-drizzle';
|
|
2
|
-
import {
|
|
2
|
+
import { desc } from 'drizzle-orm';
|
|
3
|
+
import { index, pgEnum, text, timestamp, uniqueIndex } from 'drizzle-orm/pg-core';
|
|
3
4
|
import { pgTable } from './common.js';
|
|
4
5
|
export const userStatusEnum = pgEnum('auth_user_status', [
|
|
5
6
|
'active',
|
|
@@ -16,13 +17,17 @@ export const users = pgTable('users', {
|
|
|
16
17
|
}),
|
|
17
18
|
status: userStatusEnum('status').notNull().default('active'),
|
|
18
19
|
createdAt: timestamp('created_at', {
|
|
19
|
-
withTimezone: true
|
|
20
|
+
withTimezone: true,
|
|
21
|
+
precision: 3
|
|
20
22
|
}).notNull().defaultNow(),
|
|
21
23
|
updatedAt: timestamp('updated_at', {
|
|
22
24
|
withTimezone: true
|
|
23
25
|
}).notNull().defaultNow()
|
|
24
26
|
}, (table)=>[
|
|
25
|
-
uniqueIndex('auth_users_email_unique').on(table.email)
|
|
27
|
+
uniqueIndex('auth_users_email_unique').on(table.email),
|
|
28
|
+
index('auth_users_created_at_id_index').on(desc(table.createdAt), desc(table.id)),
|
|
29
|
+
index('auth_users_name_trgm_index').using('gin', table.name.op('gin_trgm_ops')),
|
|
30
|
+
index('auth_users_email_trgm_index').using('gin', table.email.op('gin_trgm_ops'))
|
|
26
31
|
]);
|
|
27
32
|
export function toUser(row) {
|
|
28
33
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/db/schema/users.ts"],"sourcesContent":["import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {pgEnum, text, timestamp, uniqueIndex} from 'drizzle-orm/pg-core';\nimport type {User, UserStatus} from '#core/entities/user.js';\nimport {pgTable} from './common.js';\n\nexport const userStatusEnum = pgEnum('auth_user_status', ['active', 'suspended', 'deleted']);\n\nexport const users = pgTable(\n 'users',\n {\n id: uuidv7PrimaryKey(),\n email: text('email').notNull(),\n hashedPassword: text('hashed_password'),\n name: text('name'),\n emailVerifiedAt: timestamp('email_verified_at', {withTimezone: true}),\n status: userStatusEnum('status').notNull().default('active'),\n createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [uniqueIndex('auth_users_email_unique').on(table.email)],\n);\n\nexport type UserDb = typeof users.$inferSelect;\nexport type UserCreateDb = typeof users.$inferInsert;\n\nexport function toUser(row: UserDb): User {\n return {\n id: row.id,\n email: row.email,\n hashedPassword: row.hashedPassword,\n name: row.name,\n emailVerifiedAt: row.emailVerifiedAt,\n status: row.status as UserStatus,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n"],"names":["uuidv7PrimaryKey","pgEnum","text","timestamp","uniqueIndex","pgTable","userStatusEnum","users","id","email","notNull","hashedPassword","name","emailVerifiedAt","withTimezone","status","default","createdAt","defaultNow","updatedAt","table","on","toUser","row"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,QAAO,sBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../../src/db/schema/users.ts"],"sourcesContent":["import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';\nimport {desc} from 'drizzle-orm';\nimport {index, pgEnum, text, timestamp, uniqueIndex} from 'drizzle-orm/pg-core';\nimport type {User, UserStatus} from '#core/entities/user.js';\nimport {pgTable} from './common.js';\n\nexport const userStatusEnum = pgEnum('auth_user_status', ['active', 'suspended', 'deleted']);\n\nexport const users = pgTable(\n 'users',\n {\n id: uuidv7PrimaryKey(),\n email: text('email').notNull(),\n hashedPassword: text('hashed_password'),\n name: text('name'),\n emailVerifiedAt: timestamp('email_verified_at', {withTimezone: true}),\n status: userStatusEnum('status').notNull().default('active'),\n createdAt: timestamp('created_at', {withTimezone: true, precision: 3}).notNull().defaultNow(),\n updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),\n },\n (table) => [\n uniqueIndex('auth_users_email_unique').on(table.email),\n index('auth_users_created_at_id_index').on(desc(table.createdAt), desc(table.id)),\n index('auth_users_name_trgm_index').using('gin', table.name.op('gin_trgm_ops')),\n index('auth_users_email_trgm_index').using('gin', table.email.op('gin_trgm_ops')),\n ],\n);\n\nexport type UserDb = typeof users.$inferSelect;\nexport type UserCreateDb = typeof users.$inferInsert;\n\nexport function toUser(row: UserDb): User {\n return {\n id: row.id,\n email: row.email,\n hashedPassword: row.hashedPassword,\n name: row.name,\n emailVerifiedAt: row.emailVerifiedAt,\n status: row.status as UserStatus,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n };\n}\n"],"names":["uuidv7PrimaryKey","desc","index","pgEnum","text","timestamp","uniqueIndex","pgTable","userStatusEnum","users","id","email","notNull","hashedPassword","name","emailVerifiedAt","withTimezone","status","default","createdAt","precision","defaultNow","updatedAt","table","on","using","op","toUser","row"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,wBAAwB;AACvD,SAAQC,IAAI,QAAO,cAAc;AACjC,SAAQC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,QAAO,sBAAsB;AAEhF,SAAQC,OAAO,QAAO,cAAc;AAEpC,OAAO,MAAMC,iBAAiBL,OAAO,oBAAoB;IAAC;IAAU;IAAa;CAAU,EAAE;AAE7F,OAAO,MAAMM,QAAQF,QACnB,SACA;IACEG,IAAIV;IACJW,OAAOP,KAAK,SAASQ,OAAO;IAC5BC,gBAAgBT,KAAK;IACrBU,MAAMV,KAAK;IACXW,iBAAiBV,UAAU,qBAAqB;QAACW,cAAc;IAAI;IACnEC,QAAQT,eAAe,UAAUI,OAAO,GAAGM,OAAO,CAAC;IACnDC,WAAWd,UAAU,cAAc;QAACW,cAAc;QAAMI,WAAW;IAAC,GAAGR,OAAO,GAAGS,UAAU;IAC3FC,WAAWjB,UAAU,cAAc;QAACW,cAAc;IAAI,GAAGJ,OAAO,GAAGS,UAAU;AAC/E,GACA,CAACE,QAAU;QACTjB,YAAY,2BAA2BkB,EAAE,CAACD,MAAMZ,KAAK;QACrDT,MAAM,kCAAkCsB,EAAE,CAACvB,KAAKsB,MAAMJ,SAAS,GAAGlB,KAAKsB,MAAMb,EAAE;QAC/ER,MAAM,8BAA8BuB,KAAK,CAAC,OAAOF,MAAMT,IAAI,CAACY,EAAE,CAAC;QAC/DxB,MAAM,+BAA+BuB,KAAK,CAAC,OAAOF,MAAMZ,KAAK,CAACe,EAAE,CAAC;KAClE,EACD;AAKF,OAAO,SAASC,OAAOC,GAAW;IAChC,OAAO;QACLlB,IAAIkB,IAAIlB,EAAE;QACVC,OAAOiB,IAAIjB,KAAK;QAChBE,gBAAgBe,IAAIf,cAAc;QAClCC,MAAMc,IAAId,IAAI;QACdC,iBAAiBa,IAAIb,eAAe;QACpCE,QAAQW,IAAIX,MAAM;QAClBE,WAAWS,IAAIT,SAAS;QACxBG,WAAWM,IAAIN,SAAS;IAC1B;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,15 +2,22 @@ import type { ShipfoxModule } from '@shipfox/node-module';
|
|
|
2
2
|
import type { SignupPolicy } from '#core/ports.js';
|
|
3
3
|
export type { AdminRole, JobLeaseTokenClaims, RunnerSessionTokenClaims } from '@shipfox/api-auth-dto';
|
|
4
4
|
export { ADMIN_ROLES, getCurrentAdminRole, hasMinimumAdminRole, highestAdminRole, requireAdminRole, revokeAdminGrant, } from '#core/admin-role.js';
|
|
5
|
-
export {
|
|
5
|
+
export type { ListAdministratorUsersParams, ListAdministratorUsersResult, } from '#core/administration.js';
|
|
6
|
+
export { bootstrapFirstAdminOwner, grantAdministratorRole, impersonateUser, listAdministratorUsers, reactivateAdministratorUser, revokeAdministratorGrant, revokeAdministratorUserSessions, suspendAdministratorUser, } from '#core/administration.js';
|
|
6
7
|
export type { CreateImpersonatedSessionTokenParams, CreateImpersonatedSessionTokenResult, CreateSessionForUserError, CreateSessionForUserParams, CreateSessionForUserResult, ProvisionUserParams, } from '#core/auth.js';
|
|
7
8
|
export { createImpersonatedSessionToken, createSessionForUser, provisionUser } from '#core/auth.js';
|
|
9
|
+
export type { CimdAddress, CimdAddressResolver, CimdHttpRequester, CimdHttpResponse, FetchCimdMetadataOptions, FetchedCimdMetadata, } from '#core/cimd.js';
|
|
10
|
+
export { fetchClientIdMetadata, isPublicUnicastAddress, OAUTH_CIMD_FETCH_TIMEOUT_MS, OAUTH_CIMD_MAX_BODY_BYTES, } from '#core/cimd.js';
|
|
8
11
|
export type { EmailOwner, FindUserByEmailParams } from '#core/email-owner.js';
|
|
9
12
|
export { findUserByEmail } from '#core/email-owner.js';
|
|
10
13
|
export type { AdminGrant } from '#core/entities/admin-grant.js';
|
|
11
14
|
export type { User, UserStatus } from '#core/entities/user.js';
|
|
12
|
-
export { AdminBootstrapClosedError, AdminGrantAlreadyExistsError, AdminGrantNotFoundError, AdminIdempotencyKeyReuseError, AdminRoleRequiredError, AuthDependencyUnavailableError, CannotImpersonateAdministratorError, CannotImpersonateSelfError, EmailNotVerifiedError, ImpersonationDisabledError, ImpersonationExpiredError, ImpersonationTargetNotActiveError, InvalidAdminBootstrapTokenError, InvalidCredentialsError, LastAdminOwnerError, SignupNotAllowedError, UserNotFoundError, } from '#core/errors.js';
|
|
15
|
+
export { AdminBootstrapClosedError, AdminGrantAlreadyExistsError, AdminGrantNotFoundError, AdminIdempotencyKeyReuseError, AdminRoleRequiredError, AuthDependencyUnavailableError, CannotImpersonateAdministratorError, CannotImpersonateSelfError, EmailNotVerifiedError, ImpersonationDisabledError, ImpersonationExpiredError, ImpersonationTargetNotActiveError, InvalidAdminBootstrapTokenError, InvalidAdministratorUserDirectoryFilterError, InvalidCredentialsError, InvalidOAuthClientMetadataError, InvalidOAuthConfigurationError, LastAdminOwnerError, OAuthMetadataFetchError, OAuthRedirectUriNotRegisteredError, SignupNotAllowedError, UserNotFoundError, } from '#core/errors.js';
|
|
13
16
|
export { issueJobLeaseToken, jobLeaseParamsFrom, verifyJobLeaseToken, } from '#core/job-lease-token.js';
|
|
17
|
+
export type { OAuthGrantType, ValidatedOAuthClientMetadata } from '#core/oauth-client.js';
|
|
18
|
+
export { assertOAuthClientMetadataMatchesRequest, assertOAuthRedirectUriRegistered, isOAuthLoopbackRedirectUri, metadataForAgentClient, OAUTH_CIMD_CACHE_MAX_AGE_SECONDS, OAUTH_CLIENT_ID_MAX_BYTES, OAUTH_CLIENT_NAME_MAX_BYTES, OAUTH_REDIRECT_URI_MAX_BYTES, OAUTH_REDIRECT_URI_MAX_COUNT, oauthRedirectUriMatches, validateOAuthClientId, validateOAuthClientMetadataDocument, validateOAuthDynamicClientRegistration, validateOAuthPublicOrigin, validateOAuthRedirectUri, } from '#core/oauth-client.js';
|
|
19
|
+
export type { OAuthClientResolver, OAuthClientResolverOptions, RegisteredOAuthClient, RegisterOAuthClientParams, ResolvedOAuthClient, ResolveOAuthClientParams, } from '#core/oauth-client-resolver.js';
|
|
20
|
+
export { createOAuthClientResolver, OAUTH_CIMD_CACHE_MAX_ENTRIES, registerOAuthClient, resolveOAuthClient, } from '#core/oauth-client-resolver.js';
|
|
14
21
|
export type { SignupDenialMessageFormat, SignupPolicy } from '#core/ports.js';
|
|
15
22
|
export { issueRunnerSessionToken, verifyRunnerSessionToken, } from '#core/runner-session-token.js';
|
|
16
23
|
export { createEnvironmentSignupPolicy, DEFAULT_SIGNUP_NOT_ALLOWED_MESSAGE, } from '#core/signup-policy.js';
|
|
@@ -19,6 +26,8 @@ export { type AuthenticatedSessionContext, createJwtAuthMethod, getAuthenticated
|
|
|
19
26
|
export { createLeaseTokenAuthMethod } from '#presentation/auth/lease-token-auth.js';
|
|
20
27
|
export { authCookiePlugin, clearRefreshTokenCookie, getRefreshTokenCookie, setRefreshTokenCookie, } from '#presentation/auth/refresh-cookie.js';
|
|
21
28
|
export { createRunnerSessionAuthMethod } from '#presentation/auth/runner-session-auth.js';
|
|
29
|
+
export type { CreateOAuthRoutesOptions } from '#presentation/routes/oauth.js';
|
|
30
|
+
export { createOAuthClientIdentificationRoutes, createOAuthMetadataRoutes, createOAuthRoutes, } from '#presentation/routes/oauth.js';
|
|
22
31
|
export interface CreateAuthModuleOptions {
|
|
23
32
|
workspaces: import('@shipfox/api-workspaces-dto/inter-module').WorkspacesInterModuleClient;
|
|
24
33
|
signupPolicy?: SignupPolicy;
|
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":"A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C,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;AACxF,YAAY,EAAC,wBAAwB,EAAC,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EACL,qCAAqC,EACrC,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC;AAIvC,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,CA+BzC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
1
3
|
import { AUTH_PASSWORD_RESET_SEND_REQUESTED, authEventSchemas } from '@shipfox/api-auth-dto';
|
|
2
4
|
import { administrationActionEventSchemas } from '@shipfox/api-common-dto';
|
|
3
5
|
import { subscriberFactory } from '@shipfox/node-module';
|
|
@@ -14,23 +16,31 @@ import { createAuthInterModulePresentation } from '#presentation/inter-module.js
|
|
|
14
16
|
import { administrationBootstrapRoutes, administrationRoutes, createAdministrationUserRoutes } from '#presentation/routes/administration.js';
|
|
15
17
|
import { buildAuthRoutes } from '#presentation/routes/index.js';
|
|
16
18
|
import { onPasswordResetSendRequested } from '#presentation/subscribers/index.js';
|
|
19
|
+
import { createAuthMaintenanceActivities } from '#temporal/activities/index.js';
|
|
20
|
+
import { AUTH_AGENT_ACCESS_MAINTENANCE_TASK_QUEUE } from '#temporal/constants.js';
|
|
17
21
|
import { passwordLoginMethods } from './login-methods.js';
|
|
18
22
|
const authPublisherEventSchemas = {
|
|
19
23
|
...authEventSchemas,
|
|
20
24
|
...administrationActionEventSchemas
|
|
21
25
|
};
|
|
26
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
27
|
+
const workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');
|
|
22
28
|
export { ADMIN_ROLES, getCurrentAdminRole, hasMinimumAdminRole, highestAdminRole, requireAdminRole, revokeAdminGrant } from '#core/admin-role.js';
|
|
23
|
-
export { bootstrapFirstAdminOwner, grantAdministratorRole, impersonateUser, reactivateAdministratorUser, revokeAdministratorGrant, revokeAdministratorUserSessions, suspendAdministratorUser } from '#core/administration.js';
|
|
29
|
+
export { bootstrapFirstAdminOwner, grantAdministratorRole, impersonateUser, listAdministratorUsers, reactivateAdministratorUser, revokeAdministratorGrant, revokeAdministratorUserSessions, suspendAdministratorUser } from '#core/administration.js';
|
|
24
30
|
export { createImpersonatedSessionToken, createSessionForUser, provisionUser } from '#core/auth.js';
|
|
31
|
+
export { fetchClientIdMetadata, isPublicUnicastAddress, OAUTH_CIMD_FETCH_TIMEOUT_MS, OAUTH_CIMD_MAX_BODY_BYTES } from '#core/cimd.js';
|
|
25
32
|
export { findUserByEmail } from '#core/email-owner.js';
|
|
26
|
-
export { AdminBootstrapClosedError, AdminGrantAlreadyExistsError, AdminGrantNotFoundError, AdminIdempotencyKeyReuseError, AdminRoleRequiredError, AuthDependencyUnavailableError, CannotImpersonateAdministratorError, CannotImpersonateSelfError, EmailNotVerifiedError, ImpersonationDisabledError, ImpersonationExpiredError, ImpersonationTargetNotActiveError, InvalidAdminBootstrapTokenError, InvalidCredentialsError, LastAdminOwnerError, SignupNotAllowedError, UserNotFoundError } from '#core/errors.js';
|
|
33
|
+
export { AdminBootstrapClosedError, AdminGrantAlreadyExistsError, AdminGrantNotFoundError, AdminIdempotencyKeyReuseError, AdminRoleRequiredError, AuthDependencyUnavailableError, CannotImpersonateAdministratorError, CannotImpersonateSelfError, EmailNotVerifiedError, ImpersonationDisabledError, ImpersonationExpiredError, ImpersonationTargetNotActiveError, InvalidAdminBootstrapTokenError, InvalidAdministratorUserDirectoryFilterError, InvalidCredentialsError, InvalidOAuthClientMetadataError, InvalidOAuthConfigurationError, LastAdminOwnerError, OAuthMetadataFetchError, OAuthRedirectUriNotRegisteredError, SignupNotAllowedError, UserNotFoundError } from '#core/errors.js';
|
|
27
34
|
export { issueJobLeaseToken, jobLeaseParamsFrom, verifyJobLeaseToken } from '#core/job-lease-token.js';
|
|
35
|
+
export { assertOAuthClientMetadataMatchesRequest, assertOAuthRedirectUriRegistered, isOAuthLoopbackRedirectUri, metadataForAgentClient, OAUTH_CIMD_CACHE_MAX_AGE_SECONDS, OAUTH_CLIENT_ID_MAX_BYTES, OAUTH_CLIENT_NAME_MAX_BYTES, OAUTH_REDIRECT_URI_MAX_BYTES, OAUTH_REDIRECT_URI_MAX_COUNT, oauthRedirectUriMatches, validateOAuthClientId, validateOAuthClientMetadataDocument, validateOAuthDynamicClientRegistration, validateOAuthPublicOrigin, validateOAuthRedirectUri } from '#core/oauth-client.js';
|
|
36
|
+
export { createOAuthClientResolver, OAUTH_CIMD_CACHE_MAX_ENTRIES, registerOAuthClient, resolveOAuthClient } from '#core/oauth-client-resolver.js';
|
|
28
37
|
export { issueRunnerSessionToken, verifyRunnerSessionToken } from '#core/runner-session-token.js';
|
|
29
38
|
export { createEnvironmentSignupPolicy, DEFAULT_SIGNUP_NOT_ALLOWED_MESSAGE } from '#core/signup-policy.js';
|
|
30
39
|
export { createJwtAuthMethod, getAuthenticatedSessionContext } from '#presentation/auth/jwt-auth.js';
|
|
31
40
|
export { createLeaseTokenAuthMethod } from '#presentation/auth/lease-token-auth.js';
|
|
32
41
|
export { authCookiePlugin, clearRefreshTokenCookie, getRefreshTokenCookie, setRefreshTokenCookie } from '#presentation/auth/refresh-cookie.js';
|
|
33
42
|
export { createRunnerSessionAuthMethod } from '#presentation/auth/runner-session-auth.js';
|
|
43
|
+
export { createOAuthClientIdentificationRoutes, createOAuthMetadataRoutes, createOAuthRoutes } from '#presentation/routes/oauth.js';
|
|
34
44
|
const subscriber = subscriberFactory();
|
|
35
45
|
export function createAuthModule({ workspaces, signupPolicy = createEnvironmentSignupPolicy() }) {
|
|
36
46
|
return {
|
|
@@ -66,6 +76,20 @@ export function createAuthModule({ workspaces, signupPolicy = createEnvironmentS
|
|
|
66
76
|
subscribers: [
|
|
67
77
|
subscriber(AUTH_PASSWORD_RESET_SEND_REQUESTED, onPasswordResetSendRequested)
|
|
68
78
|
],
|
|
79
|
+
workers: [
|
|
80
|
+
{
|
|
81
|
+
taskQueue: AUTH_AGENT_ACCESS_MAINTENANCE_TASK_QUEUE,
|
|
82
|
+
workflowsPath,
|
|
83
|
+
activities: createAuthMaintenanceActivities,
|
|
84
|
+
workflows: [
|
|
85
|
+
{
|
|
86
|
+
name: 'agentAccessRetentionCron',
|
|
87
|
+
id: 'auth-agent-access-retention',
|
|
88
|
+
cronSchedule: '10 * * * *'
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
],
|
|
69
93
|
interModulePresentations: [
|
|
70
94
|
createAuthInterModulePresentation()
|
|
71
95
|
]
|
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 {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 {\n administrationBootstrapRoutes,\n administrationRoutes,\n createAdministrationUserRoutes,\n} 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 impersonateUser,\n reactivateAdministratorUser,\n revokeAdministratorGrant,\n revokeAdministratorUserSessions,\n suspendAdministratorUser,\n} from '#core/administration.js';\nexport type {\n CreateImpersonatedSessionTokenParams,\n CreateImpersonatedSessionTokenResult,\n CreateSessionForUserError,\n CreateSessionForUserParams,\n CreateSessionForUserResult,\n ProvisionUserParams,\n} from '#core/auth.js';\nexport {createImpersonatedSessionToken, 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 CannotImpersonateAdministratorError,\n CannotImpersonateSelfError,\n EmailNotVerifiedError,\n ImpersonationDisabledError,\n ImpersonationExpiredError,\n ImpersonationTargetNotActiveError,\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 {SignupDenialMessageFormat, 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 type {ImpersonationResult} from '#db/impersonation.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 administrationBootstrapRoutes,\n administrationRoutes,\n ...createAdministrationUserRoutes(workspaces),\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","administrationBootstrapRoutes","administrationRoutes","createAdministrationUserRoutes","buildAuthRoutes","onPasswordResetSendRequested","passwordLoginMethods","authPublisherEventSchemas","ADMIN_ROLES","getCurrentAdminRole","hasMinimumAdminRole","highestAdminRole","requireAdminRole","revokeAdminGrant","bootstrapFirstAdminOwner","grantAdministratorRole","impersonateUser","reactivateAdministratorUser","revokeAdministratorGrant","revokeAdministratorUserSessions","suspendAdministratorUser","createImpersonatedSessionToken","createSessionForUser","provisionUser","findUserByEmail","AdminBootstrapClosedError","AdminGrantAlreadyExistsError","AdminGrantNotFoundError","AdminIdempotencyKeyReuseError","AdminRoleRequiredError","AuthDependencyUnavailableError","CannotImpersonateAdministratorError","CannotImpersonateSelfError","EmailNotVerifiedError","ImpersonationDisabledError","ImpersonationExpiredError","ImpersonationTargetNotActiveError","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,SACEC,6BAA6B,EAC7BC,oBAAoB,EACpBC,8BAA8B,QACzB,yCAAyC;AAChD,SAAQC,eAAe,QAAO,gCAAgC;AAC9D,SAAQC,4BAA4B,QAAO,qCAAqC;AAChF,SAAQC,oBAAoB,QAAO,qBAAqB;AAExD,MAAMC,4BAA4B;IAAC,GAAGnB,gBAAgB;IAAE,GAAGC,gCAAgC;AAAA;AAG3F,SACEmB,WAAW,EACXC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,QACX,sBAAsB;AAC7B,SACEC,wBAAwB,EACxBC,sBAAsB,EACtBC,eAAe,EACfC,2BAA2B,EAC3BC,wBAAwB,EACxBC,+BAA+B,EAC/BC,wBAAwB,QACnB,0BAA0B;AASjC,SAAQC,8BAA8B,EAAEC,oBAAoB,EAAEC,aAAa,QAAO,gBAAgB;AAElG,SAAQC,eAAe,QAAO,uBAAuB;AAGrD,SACEC,yBAAy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E;AACF"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {\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 {\n administrationBootstrapRoutes,\n administrationRoutes,\n createAdministrationUserRoutes,\n} from '#presentation/routes/administration.js';\nimport {buildAuthRoutes} from '#presentation/routes/index.js';\nimport {onPasswordResetSendRequested} from '#presentation/subscribers/index.js';\nimport {createAuthMaintenanceActivities} from '#temporal/activities/index.js';\nimport {AUTH_AGENT_ACCESS_MAINTENANCE_TASK_QUEUE} from '#temporal/constants.js';\nimport {passwordLoginMethods} from './login-methods.js';\n\nconst authPublisherEventSchemas = {...authEventSchemas, ...administrationActionEventSchemas};\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\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 type {\n ListAdministratorUsersParams,\n ListAdministratorUsersResult,\n} from '#core/administration.js';\nexport {\n bootstrapFirstAdminOwner,\n grantAdministratorRole,\n impersonateUser,\n listAdministratorUsers,\n reactivateAdministratorUser,\n revokeAdministratorGrant,\n revokeAdministratorUserSessions,\n suspendAdministratorUser,\n} from '#core/administration.js';\nexport type {\n CreateImpersonatedSessionTokenParams,\n CreateImpersonatedSessionTokenResult,\n CreateSessionForUserError,\n CreateSessionForUserParams,\n CreateSessionForUserResult,\n ProvisionUserParams,\n} from '#core/auth.js';\nexport {createImpersonatedSessionToken, createSessionForUser, provisionUser} from '#core/auth.js';\nexport type {\n CimdAddress,\n CimdAddressResolver,\n CimdHttpRequester,\n CimdHttpResponse,\n FetchCimdMetadataOptions,\n FetchedCimdMetadata,\n} from '#core/cimd.js';\nexport {\n fetchClientIdMetadata,\n isPublicUnicastAddress,\n OAUTH_CIMD_FETCH_TIMEOUT_MS,\n OAUTH_CIMD_MAX_BODY_BYTES,\n} from '#core/cimd.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 CannotImpersonateAdministratorError,\n CannotImpersonateSelfError,\n EmailNotVerifiedError,\n ImpersonationDisabledError,\n ImpersonationExpiredError,\n ImpersonationTargetNotActiveError,\n InvalidAdminBootstrapTokenError,\n InvalidAdministratorUserDirectoryFilterError,\n InvalidCredentialsError,\n InvalidOAuthClientMetadataError,\n InvalidOAuthConfigurationError,\n LastAdminOwnerError,\n OAuthMetadataFetchError,\n OAuthRedirectUriNotRegisteredError,\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 {OAuthGrantType, ValidatedOAuthClientMetadata} from '#core/oauth-client.js';\nexport {\n assertOAuthClientMetadataMatchesRequest,\n assertOAuthRedirectUriRegistered,\n isOAuthLoopbackRedirectUri,\n metadataForAgentClient,\n OAUTH_CIMD_CACHE_MAX_AGE_SECONDS,\n OAUTH_CLIENT_ID_MAX_BYTES,\n OAUTH_CLIENT_NAME_MAX_BYTES,\n OAUTH_REDIRECT_URI_MAX_BYTES,\n OAUTH_REDIRECT_URI_MAX_COUNT,\n oauthRedirectUriMatches,\n validateOAuthClientId,\n validateOAuthClientMetadataDocument,\n validateOAuthDynamicClientRegistration,\n validateOAuthPublicOrigin,\n validateOAuthRedirectUri,\n} from '#core/oauth-client.js';\nexport type {\n OAuthClientResolver,\n OAuthClientResolverOptions,\n RegisteredOAuthClient,\n RegisterOAuthClientParams,\n ResolvedOAuthClient,\n ResolveOAuthClientParams,\n} from '#core/oauth-client-resolver.js';\nexport {\n createOAuthClientResolver,\n OAUTH_CIMD_CACHE_MAX_ENTRIES,\n registerOAuthClient,\n resolveOAuthClient,\n} from '#core/oauth-client-resolver.js';\nexport type {SignupDenialMessageFormat, 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 type {ImpersonationResult} from '#db/impersonation.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';\nexport type {CreateOAuthRoutesOptions} from '#presentation/routes/oauth.js';\nexport {\n createOAuthClientIdentificationRoutes,\n createOAuthMetadataRoutes,\n createOAuthRoutes,\n} from '#presentation/routes/oauth.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 administrationBootstrapRoutes,\n administrationRoutes,\n ...createAdministrationUserRoutes(workspaces),\n ],\n e2eRoutes: [createAuthE2eRoutes(workspaces)],\n publishers: [{name: 'auth', table: authOutbox, db, eventSchemas: authPublisherEventSchemas}],\n subscribers: [subscriber(AUTH_PASSWORD_RESET_SEND_REQUESTED, onPasswordResetSendRequested)],\n workers: [\n {\n taskQueue: AUTH_AGENT_ACCESS_MAINTENANCE_TASK_QUEUE,\n workflowsPath,\n activities: createAuthMaintenanceActivities,\n workflows: [\n {\n name: 'agentAccessRetentionCron',\n id: 'auth-agent-access-retention',\n cronSchedule: '10 * * * *',\n },\n ],\n },\n ],\n interModulePresentations: [createAuthInterModulePresentation()],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","AUTH_PASSWORD_RESET_SEND_REQUESTED","authEventSchemas","administrationActionEventSchemas","subscriberFactory","config","createEnvironmentSignupPolicy","db","migrationsPath","authOutbox","createJwtAuthMethod","createLeaseTokenAuthMethod","createRunnerSessionAuthMethod","createAuthE2eRoutes","createAuthInterModulePresentation","administrationBootstrapRoutes","administrationRoutes","createAdministrationUserRoutes","buildAuthRoutes","onPasswordResetSendRequested","createAuthMaintenanceActivities","AUTH_AGENT_ACCESS_MAINTENANCE_TASK_QUEUE","passwordLoginMethods","authPublisherEventSchemas","packageRoot","url","workflowsPath","ADMIN_ROLES","getCurrentAdminRole","hasMinimumAdminRole","highestAdminRole","requireAdminRole","revokeAdminGrant","bootstrapFirstAdminOwner","grantAdministratorRole","impersonateUser","listAdministratorUsers","reactivateAdministratorUser","revokeAdministratorGrant","revokeAdministratorUserSessions","suspendAdministratorUser","createImpersonatedSessionToken","createSessionForUser","provisionUser","fetchClientIdMetadata","isPublicUnicastAddress","OAUTH_CIMD_FETCH_TIMEOUT_MS","OAUTH_CIMD_MAX_BODY_BYTES","findUserByEmail","AdminBootstrapClosedError","AdminGrantAlreadyExistsError","AdminGrantNotFoundError","AdminIdempotencyKeyReuseError","AdminRoleRequiredError","AuthDependencyUnavailableError","CannotImpersonateAdministratorError","CannotImpersonateSelfError","EmailNotVerifiedError","ImpersonationDisabledError","ImpersonationExpiredError","ImpersonationTargetNotActiveError","InvalidAdminBootstrapTokenError","InvalidAdministratorUserDirectoryFilterError","InvalidCredentialsError","InvalidOAuthClientMetadataError","InvalidOAuthConfigurationError","LastAdminOwnerError","OAuthMetadataFetchError","OAuthRedirectUriNotRegisteredError","SignupNotAllowedError","UserNotFoundError","issueJobLeaseToken","jobLeaseParamsFrom","verifyJobLeaseToken","assertOAuthClientMetadataMatchesRequest","assertOAuthRedirectUriRegistered","isOAuthLoopbackRedirectUri","metadataForAgentClient","OAUTH_CIMD_CACHE_MAX_AGE_SECONDS","OAUTH_CLIENT_ID_MAX_BYTES","OAUTH_CLIENT_NAME_MAX_BYTES","OAUTH_REDIRECT_URI_MAX_BYTES","OAUTH_REDIRECT_URI_MAX_COUNT","oauthRedirectUriMatches","validateOAuthClientId","validateOAuthClientMetadataDocument","validateOAuthDynamicClientRegistration","validateOAuthPublicOrigin","validateOAuthRedirectUri","createOAuthClientResolver","OAUTH_CIMD_CACHE_MAX_ENTRIES","registerOAuthClient","resolveOAuthClient","issueRunnerSessionToken","verifyRunnerSessionToken","DEFAULT_SIGNUP_NOT_ALLOWED_MESSAGE","getAuthenticatedSessionContext","authCookiePlugin","clearRefreshTokenCookie","getRefreshTokenCookie","setRefreshTokenCookie","createOAuthClientIdentificationRoutes","createOAuthMetadataRoutes","createOAuthRoutes","subscriber","createAuthModule","workspaces","signupPolicy","name","database","databaseNamespace","auth","loginMethods","AUTH_PASSWORD_ENABLED","routes","e2eRoutes","publishers","table","eventSchemas","subscribers","workers","taskQueue","activities","workflows","id","cronSchedule","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AACvC,SACEC,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,SACEC,6BAA6B,EAC7BC,oBAAoB,EACpBC,8BAA8B,QACzB,yCAAyC;AAChD,SAAQC,eAAe,QAAO,gCAAgC;AAC9D,SAAQC,4BAA4B,QAAO,qCAAqC;AAChF,SAAQC,+BAA+B,QAAO,gCAAgC;AAC9E,SA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f,MAAM;wBACNgB,IAAI;wBACJC,cAAc;oBAChB;iBACD;YACH;SACD;QACDC,0BAA0B;YAAChH;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' | 'bootstrap' | 'bootstrap-state' | 'lookup' | 'impersonate';
|
|
4
|
+
export type AuthRateLimitAction = 'login' | 'email-send' | 'bootstrap' | 'bootstrap-state' | 'lookup' | 'directory' | 'impersonate' | 'oauth-register' | 'oauth-cimd' | 'oauth-authorize' | 'oauth-token';
|
|
5
5
|
export type AuthRateLimitScope = 'ip' | 'email' | 'actor';
|
|
6
6
|
export type AuthRateLimitOutcome = 'allowed' | 'blocked' | 'unavailable';
|
|
7
7
|
export type AuthImpersonationOutcome = 'succeeded' | 'failed';
|
|
@@ -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,GAC3B,OAAO,GACP,YAAY,GACZ,WAAW,GACX,iBAAiB,GACjB,QAAQ,GACR,aAAa,CAAC;AAClB,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC;AAC1D,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAC;AACzE,MAAM,MAAM,wBAAwB,GAAG,W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E;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;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI,CAElF"}
|
|
@@ -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 =\n | 'login'\n | 'email-send'\n | 'bootstrap'\n | 'bootstrap-state'\n | 'lookup'\n | 'impersonate';\nexport type AuthRateLimitScope = 'ip' | 'email' | 'actor';\nexport type AuthRateLimitOutcome = 'allowed' | 'blocked' | 'unavailable';\nexport type AuthImpersonationOutcome = 'succeeded' | 'failed';\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\nconst impersonationCommandCount = meter.createCounter<{outcome: AuthImpersonationOutcome}>(\n 'auth_impersonation_commands',\n {description: 'Impersonation mint command attempts by outcome'},\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\nexport function recordImpersonationOutcome(outcome: AuthImpersonationOutcome): void {\n recordMetric(() => impersonationCommandCount.add(1, {outcome}));\n}\n"],"names":["instanceMetrics","meter","getMeter","tokenIssuedCount","createCounter","description","tokenVerifiedCount","tokenRefreshedCount","rateLimitCheckCount","rateLimitPruneFailureCount","impersonationCommandCount","recordMetric","record","recordTokenIssued","tokenType","add","token_type","recordTokenVerified","outcome","recordTokenRefreshed","recordAuthRateLimitCheck","params","action","scope","recordAuthRateLimitPruneFailure","recordImpersonationOutcome"],"mappings":"AAAA,SAAQA,eAAe,QAAO,8BAA8B;
|
|
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 =\n | 'login'\n | 'email-send'\n | 'bootstrap'\n | 'bootstrap-state'\n | 'lookup'\n | 'directory'\n | 'impersonate'\n | 'oauth-register'\n | 'oauth-cimd'\n | 'oauth-authorize'\n | 'oauth-token';\nexport type AuthRateLimitScope = 'ip' | 'email' | 'actor';\nexport type AuthRateLimitOutcome = 'allowed' | 'blocked' | 'unavailable';\nexport type AuthImpersonationOutcome = 'succeeded' | 'failed';\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\nconst impersonationCommandCount = meter.createCounter<{outcome: AuthImpersonationOutcome}>(\n 'auth_impersonation_commands',\n {description: 'Impersonation mint command attempts by outcome'},\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\nexport function recordImpersonationOutcome(outcome: AuthImpersonationOutcome): void {\n recordMetric(() => impersonationCommandCount.add(1, {outcome}));\n}\n"],"names":["instanceMetrics","meter","getMeter","tokenIssuedCount","createCounter","description","tokenVerifiedCount","tokenRefreshedCount","rateLimitCheckCount","rateLimitPruneFailureCount","impersonationCommandCount","recordMetric","record","recordTokenIssued","tokenType","add","token_type","recordTokenVerified","outcome","recordTokenRefreshed","recordAuthRateLimitCheck","params","action","scope","recordAuthRateLimitPruneFailure","recordImpersonationOutcome"],"mappings":"AAAA,SAAQA,eAAe,QAAO,8BAA8B;AAqB5D,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,MAAMK,4BAA4BT,MAAMG,aAAa,CACnD,+BACA;IAACC,aAAa;AAAgD;AAGhE,SAASM,aAAaC,MAAkB;IACtC,IAAI;QACFA;IACF,EAAE,OAAM;IACN,mDAAmD;IACrD;AACF;AAEA,OAAO,SAASC,kBAAkBC,SAAwB;IACxDH,aAAa,IAAMR,iBAAiBY,GAAG,CAAC,GAAG;YAACC,YAAYF;QAAS;AACnE;AAEA,OAAO,SAASG,oBACdH,SAAwB,EACxBI,OAAqC;IAErCP,aAAa,IAAML,mBAAmBS,GAAG,CAAC,GAAG;YAACC,YAAYF;YAAWI;QAAO;AAC9E;AAEA,OAAO,SAASC,qBAAqBD,OAAgC;IACnEP,aAAa,IAAMJ,oBAAoBQ,GAAG,CAAC,GAAG;YAACG;QAAO;AACxD;AAEA,OAAO,SAASE,yBAAyBC,MAIxC;IACCV,aAAa,IACXH,oBAAoBO,GAAG,CAAC,GAAG;YACzBO,QAAQD,OAAOC,MAAM;YACrBC,OAAOF,OAAOE,KAAK;YACnBL,SAASG,OAAOH,OAAO;QACzB;AAEJ;AAEA,OAAO,SAASM;IACdb,aAAa,IAAMF,2BAA2BM,GAAG,CAAC;AACpD;AAEA,OAAO,SAASU,2BAA2BP,OAAiC;IAC1EP,aAAa,IAAMD,0BAA0BK,GAAG,CAAC,GAAG;YAACG;QAAO;AAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"administration.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/administration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"administration.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/administration.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,0CAA0C,CAAC;AAE1F,OAAO,EAA2B,KAAK,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAqfhF,eAAO,MAAM,oBAAoB,EAAE,UAIjC,CAAC;AAEH,eAAO,MAAM,6BAA6B,EAAE,UAI1C,CAAC;AAuDH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,2BAA2B,GACtC,UAAU,EAAE,CAuBd"}
|