@absolutejs/auth 0.54.8 → 0.55.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/README.md +19 -5
- package/dist/agents/config.d.ts +16 -0
- package/dist/agents/idJag.d.ts +49 -0
- package/dist/agents/inMemoryStores.d.ts +2 -1
- package/dist/agents/index.d.ts +5 -2
- package/dist/agents/index.js +1391 -66
- package/dist/agents/index.js.map +12 -8
- package/dist/agents/postgresStores.d.ts +280 -1
- package/dist/agents/registration.d.ts +162 -0
- package/dist/agents/registrationClient.d.ts +50 -0
- package/dist/agents/routes.d.ts +112 -1
- package/dist/agents/types.d.ts +59 -0
- package/dist/apikeys/routes.d.ts +2 -2
- package/dist/cli/migrate.js +57 -8
- package/dist/cli/migrate.js.map +4 -4
- package/dist/credentials/login.d.ts +4 -4
- package/dist/credentials/routes.d.ts +4 -4
- package/dist/index.d.ts +185 -2
- package/dist/index.js +1388 -102
- package/dist/index.js.map +15 -12
- package/dist/manifest.js +12 -6
- package/dist/manifest.js.map +4 -4
- package/dist/manifest.json +2 -2
- package/dist/mfa/routes.d.ts +2 -2
- package/dist/mfa/sms.d.ts +2 -2
- package/dist/oidc/clientAuth.d.ts +6 -2
- package/dist/oidc/config.d.ts +19 -5
- package/dist/oidc/keys.d.ts +7 -3
- package/dist/oidc/logout.d.ts +2 -2
- package/dist/oidc/routes.d.ts +13 -11
- package/dist/organizations/routes.d.ts +1 -1
- package/dist/portal/routes.d.ts +3 -3
- package/dist/roles/routes.d.ts +1 -1
- package/dist/routes/refresh.d.ts +1 -1
- package/dist/routes/revoke.d.ts +1 -1
- package/dist/routes/sessions.d.ts +3 -3
- package/dist/sso/discoveryRoute.d.ts +1 -1
- package/dist/sso/oidcRoutes.d.ts +2 -2
- package/dist/sso/samlRoutes.d.ts +4 -4
- package/docs/AGENT-AUTH.md +54 -0
- package/docs/MIGRATE-FROM-LUCIA.md +235 -0
- package/docs/OAUTH-PROVIDER-QUIRKS.md +150 -0
- package/docs/UI-COMPONENTS.md +226 -0
- package/package.json +7 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnyPgDatabase } from '../stores/postgres';
|
|
2
|
-
import type { AgentDelegationStatus, AgentDelegationStore, AgentRegistrationStatus, AgentRegistrationStore } from './types';
|
|
2
|
+
import type { AgentDelegationStatus, AgentDelegationStore, AgentIdentityRegistrationKind, AgentIdentityRegistrationStatus, AgentIdentityRegistrationStore, AgentRegistrationStatus, AgentRegistrationStore } from './types';
|
|
3
3
|
export declare const agentDelegationsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4
4
|
name: "auth_agent_delegations";
|
|
5
5
|
schema: undefined;
|
|
@@ -157,6 +157,283 @@ export declare const agentDelegationsTable: import("drizzle-orm/pg-core").PgTabl
|
|
|
157
157
|
};
|
|
158
158
|
dialect: "pg";
|
|
159
159
|
}>;
|
|
160
|
+
export declare const agentIdentityRegistrationsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
161
|
+
name: "auth_agent_identity_registrations";
|
|
162
|
+
schema: undefined;
|
|
163
|
+
columns: {
|
|
164
|
+
agent_id: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
|
|
165
|
+
name: string;
|
|
166
|
+
tableName: "auth_agent_identity_registrations";
|
|
167
|
+
dataType: "string";
|
|
168
|
+
data: string;
|
|
169
|
+
driverParam: string;
|
|
170
|
+
notNull: true;
|
|
171
|
+
hasDefault: false;
|
|
172
|
+
isPrimaryKey: false;
|
|
173
|
+
isAutoincrement: false;
|
|
174
|
+
hasRuntimeDefault: false;
|
|
175
|
+
enumValues: undefined;
|
|
176
|
+
identity: undefined;
|
|
177
|
+
generated: undefined;
|
|
178
|
+
}>;
|
|
179
|
+
claim_attempt: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").Set$Type<import("drizzle-orm/pg-core").PgJsonbBuilder, import("./types").AgentClaimAttempt | undefined>, {
|
|
180
|
+
name: string;
|
|
181
|
+
tableName: "auth_agent_identity_registrations";
|
|
182
|
+
dataType: "object json";
|
|
183
|
+
data: import("./types").AgentClaimAttempt | undefined;
|
|
184
|
+
driverParam: unknown;
|
|
185
|
+
notNull: false;
|
|
186
|
+
hasDefault: false;
|
|
187
|
+
isPrimaryKey: false;
|
|
188
|
+
isAutoincrement: false;
|
|
189
|
+
hasRuntimeDefault: false;
|
|
190
|
+
enumValues: undefined;
|
|
191
|
+
identity: undefined;
|
|
192
|
+
generated: undefined;
|
|
193
|
+
}>;
|
|
194
|
+
claim_attempt_token_hash: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
|
|
195
|
+
name: string;
|
|
196
|
+
tableName: "auth_agent_identity_registrations";
|
|
197
|
+
dataType: "string";
|
|
198
|
+
data: string;
|
|
199
|
+
driverParam: string;
|
|
200
|
+
notNull: false;
|
|
201
|
+
hasDefault: false;
|
|
202
|
+
isPrimaryKey: false;
|
|
203
|
+
isAutoincrement: false;
|
|
204
|
+
hasRuntimeDefault: false;
|
|
205
|
+
enumValues: undefined;
|
|
206
|
+
identity: undefined;
|
|
207
|
+
generated: undefined;
|
|
208
|
+
}>;
|
|
209
|
+
claim_expires_at_ms: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBigInt53Builder>, {
|
|
210
|
+
name: string;
|
|
211
|
+
tableName: "auth_agent_identity_registrations";
|
|
212
|
+
dataType: "number int53";
|
|
213
|
+
data: number;
|
|
214
|
+
driverParam: string | number;
|
|
215
|
+
notNull: true;
|
|
216
|
+
hasDefault: false;
|
|
217
|
+
isPrimaryKey: false;
|
|
218
|
+
isAutoincrement: false;
|
|
219
|
+
hasRuntimeDefault: false;
|
|
220
|
+
enumValues: undefined;
|
|
221
|
+
identity: undefined;
|
|
222
|
+
generated: undefined;
|
|
223
|
+
}>;
|
|
224
|
+
claim_token_hash: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
|
|
225
|
+
name: string;
|
|
226
|
+
tableName: "auth_agent_identity_registrations";
|
|
227
|
+
dataType: "string";
|
|
228
|
+
data: string;
|
|
229
|
+
driverParam: string;
|
|
230
|
+
notNull: true;
|
|
231
|
+
hasDefault: false;
|
|
232
|
+
isPrimaryKey: false;
|
|
233
|
+
isAutoincrement: false;
|
|
234
|
+
hasRuntimeDefault: false;
|
|
235
|
+
enumValues: undefined;
|
|
236
|
+
identity: undefined;
|
|
237
|
+
generated: undefined;
|
|
238
|
+
}>;
|
|
239
|
+
created_at_ms: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBigInt53Builder>, {
|
|
240
|
+
name: string;
|
|
241
|
+
tableName: "auth_agent_identity_registrations";
|
|
242
|
+
dataType: "number int53";
|
|
243
|
+
data: number;
|
|
244
|
+
driverParam: string | number;
|
|
245
|
+
notNull: true;
|
|
246
|
+
hasDefault: false;
|
|
247
|
+
isPrimaryKey: false;
|
|
248
|
+
isAutoincrement: false;
|
|
249
|
+
hasRuntimeDefault: false;
|
|
250
|
+
enumValues: undefined;
|
|
251
|
+
identity: undefined;
|
|
252
|
+
generated: undefined;
|
|
253
|
+
}>;
|
|
254
|
+
expires_at_ms: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBigInt53Builder>, {
|
|
255
|
+
name: string;
|
|
256
|
+
tableName: "auth_agent_identity_registrations";
|
|
257
|
+
dataType: "number int53";
|
|
258
|
+
data: number;
|
|
259
|
+
driverParam: string | number;
|
|
260
|
+
notNull: true;
|
|
261
|
+
hasDefault: false;
|
|
262
|
+
isPrimaryKey: false;
|
|
263
|
+
isAutoincrement: false;
|
|
264
|
+
hasRuntimeDefault: false;
|
|
265
|
+
enumValues: undefined;
|
|
266
|
+
identity: undefined;
|
|
267
|
+
generated: undefined;
|
|
268
|
+
}>;
|
|
269
|
+
kind: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").Set$Type<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, AgentIdentityRegistrationKind>>, {
|
|
270
|
+
name: string;
|
|
271
|
+
tableName: "auth_agent_identity_registrations";
|
|
272
|
+
dataType: "string";
|
|
273
|
+
data: AgentIdentityRegistrationKind;
|
|
274
|
+
driverParam: string;
|
|
275
|
+
notNull: true;
|
|
276
|
+
hasDefault: false;
|
|
277
|
+
isPrimaryKey: false;
|
|
278
|
+
isAutoincrement: false;
|
|
279
|
+
hasRuntimeDefault: false;
|
|
280
|
+
enumValues: undefined;
|
|
281
|
+
identity: undefined;
|
|
282
|
+
generated: undefined;
|
|
283
|
+
}>;
|
|
284
|
+
last_polled_at_ms: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").PgBigInt53Builder, {
|
|
285
|
+
name: string;
|
|
286
|
+
tableName: "auth_agent_identity_registrations";
|
|
287
|
+
dataType: "number int53";
|
|
288
|
+
data: number;
|
|
289
|
+
driverParam: string | number;
|
|
290
|
+
notNull: false;
|
|
291
|
+
hasDefault: false;
|
|
292
|
+
isPrimaryKey: false;
|
|
293
|
+
isAutoincrement: false;
|
|
294
|
+
hasRuntimeDefault: false;
|
|
295
|
+
enumValues: undefined;
|
|
296
|
+
identity: undefined;
|
|
297
|
+
generated: undefined;
|
|
298
|
+
}>;
|
|
299
|
+
login_hint: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
|
|
300
|
+
name: string;
|
|
301
|
+
tableName: "auth_agent_identity_registrations";
|
|
302
|
+
dataType: "string";
|
|
303
|
+
data: string;
|
|
304
|
+
driverParam: string;
|
|
305
|
+
notNull: false;
|
|
306
|
+
hasDefault: false;
|
|
307
|
+
isPrimaryKey: false;
|
|
308
|
+
isAutoincrement: false;
|
|
309
|
+
hasRuntimeDefault: false;
|
|
310
|
+
enumValues: undefined;
|
|
311
|
+
identity: undefined;
|
|
312
|
+
generated: undefined;
|
|
313
|
+
}>;
|
|
314
|
+
registration_id: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetIsPrimaryKey<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
|
|
315
|
+
name: string;
|
|
316
|
+
tableName: "auth_agent_identity_registrations";
|
|
317
|
+
dataType: "string";
|
|
318
|
+
data: string;
|
|
319
|
+
driverParam: string;
|
|
320
|
+
notNull: true;
|
|
321
|
+
hasDefault: false;
|
|
322
|
+
isPrimaryKey: false;
|
|
323
|
+
isAutoincrement: false;
|
|
324
|
+
hasRuntimeDefault: false;
|
|
325
|
+
enumValues: undefined;
|
|
326
|
+
identity: undefined;
|
|
327
|
+
generated: undefined;
|
|
328
|
+
}>;
|
|
329
|
+
status: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").Set$Type<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, AgentIdentityRegistrationStatus>>, {
|
|
330
|
+
name: string;
|
|
331
|
+
tableName: "auth_agent_identity_registrations";
|
|
332
|
+
dataType: "string";
|
|
333
|
+
data: AgentIdentityRegistrationStatus;
|
|
334
|
+
driverParam: string;
|
|
335
|
+
notNull: true;
|
|
336
|
+
hasDefault: false;
|
|
337
|
+
isPrimaryKey: false;
|
|
338
|
+
isAutoincrement: false;
|
|
339
|
+
hasRuntimeDefault: false;
|
|
340
|
+
enumValues: undefined;
|
|
341
|
+
identity: undefined;
|
|
342
|
+
generated: undefined;
|
|
343
|
+
}>;
|
|
344
|
+
updated_at_ms: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBigInt53Builder>, {
|
|
345
|
+
name: string;
|
|
346
|
+
tableName: "auth_agent_identity_registrations";
|
|
347
|
+
dataType: "number int53";
|
|
348
|
+
data: number;
|
|
349
|
+
driverParam: string | number;
|
|
350
|
+
notNull: true;
|
|
351
|
+
hasDefault: false;
|
|
352
|
+
isPrimaryKey: false;
|
|
353
|
+
isAutoincrement: false;
|
|
354
|
+
hasRuntimeDefault: false;
|
|
355
|
+
enumValues: undefined;
|
|
356
|
+
identity: undefined;
|
|
357
|
+
generated: undefined;
|
|
358
|
+
}>;
|
|
359
|
+
upstream_client_id: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
|
|
360
|
+
name: string;
|
|
361
|
+
tableName: "auth_agent_identity_registrations";
|
|
362
|
+
dataType: "string";
|
|
363
|
+
data: string;
|
|
364
|
+
driverParam: string;
|
|
365
|
+
notNull: false;
|
|
366
|
+
hasDefault: false;
|
|
367
|
+
isPrimaryKey: false;
|
|
368
|
+
isAutoincrement: false;
|
|
369
|
+
hasRuntimeDefault: false;
|
|
370
|
+
enumValues: undefined;
|
|
371
|
+
identity: undefined;
|
|
372
|
+
generated: undefined;
|
|
373
|
+
}>;
|
|
374
|
+
upstream_issuer: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
|
|
375
|
+
name: string;
|
|
376
|
+
tableName: "auth_agent_identity_registrations";
|
|
377
|
+
dataType: "string";
|
|
378
|
+
data: string;
|
|
379
|
+
driverParam: string;
|
|
380
|
+
notNull: false;
|
|
381
|
+
hasDefault: false;
|
|
382
|
+
isPrimaryKey: false;
|
|
383
|
+
isAutoincrement: false;
|
|
384
|
+
hasRuntimeDefault: false;
|
|
385
|
+
enumValues: undefined;
|
|
386
|
+
identity: undefined;
|
|
387
|
+
generated: undefined;
|
|
388
|
+
}>;
|
|
389
|
+
upstream_subject: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
|
|
390
|
+
name: string;
|
|
391
|
+
tableName: "auth_agent_identity_registrations";
|
|
392
|
+
dataType: "string";
|
|
393
|
+
data: string;
|
|
394
|
+
driverParam: string;
|
|
395
|
+
notNull: false;
|
|
396
|
+
hasDefault: false;
|
|
397
|
+
isPrimaryKey: false;
|
|
398
|
+
isAutoincrement: false;
|
|
399
|
+
hasRuntimeDefault: false;
|
|
400
|
+
enumValues: undefined;
|
|
401
|
+
identity: undefined;
|
|
402
|
+
generated: undefined;
|
|
403
|
+
}>;
|
|
404
|
+
user_id: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
|
|
405
|
+
name: string;
|
|
406
|
+
tableName: "auth_agent_identity_registrations";
|
|
407
|
+
dataType: "string";
|
|
408
|
+
data: string;
|
|
409
|
+
driverParam: string;
|
|
410
|
+
notNull: false;
|
|
411
|
+
hasDefault: false;
|
|
412
|
+
isPrimaryKey: false;
|
|
413
|
+
isAutoincrement: false;
|
|
414
|
+
hasRuntimeDefault: false;
|
|
415
|
+
enumValues: undefined;
|
|
416
|
+
identity: undefined;
|
|
417
|
+
generated: undefined;
|
|
418
|
+
}>;
|
|
419
|
+
version: import("drizzle-orm/pg-core").PgBuildColumn<"auth_agent_identity_registrations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgIntegerBuilder>, {
|
|
420
|
+
name: string;
|
|
421
|
+
tableName: "auth_agent_identity_registrations";
|
|
422
|
+
dataType: "number int32";
|
|
423
|
+
data: number;
|
|
424
|
+
driverParam: string | number;
|
|
425
|
+
notNull: true;
|
|
426
|
+
hasDefault: false;
|
|
427
|
+
isPrimaryKey: false;
|
|
428
|
+
isAutoincrement: false;
|
|
429
|
+
hasRuntimeDefault: false;
|
|
430
|
+
enumValues: undefined;
|
|
431
|
+
identity: undefined;
|
|
432
|
+
generated: undefined;
|
|
433
|
+
}>;
|
|
434
|
+
};
|
|
435
|
+
dialect: "pg";
|
|
436
|
+
}>;
|
|
160
437
|
export declare const agentRegistrationsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
161
438
|
name: "auth_agent_registrations";
|
|
162
439
|
schema: undefined;
|
|
@@ -285,6 +562,8 @@ export declare const agentRegistrationsTable: import("drizzle-orm/pg-core").PgTa
|
|
|
285
562
|
dialect: "pg";
|
|
286
563
|
}>;
|
|
287
564
|
export declare const createNeonAgentDelegationStore: (databaseUrl: string) => AgentDelegationStore;
|
|
565
|
+
export declare const createNeonAgentIdentityRegistrationStore: (databaseUrl: string) => AgentIdentityRegistrationStore;
|
|
288
566
|
export declare const createNeonAgentRegistrationStore: (databaseUrl: string) => AgentRegistrationStore;
|
|
289
567
|
export declare const createPostgresAgentDelegationStore: <DB extends AnyPgDatabase>(db: DB) => AgentDelegationStore;
|
|
568
|
+
export declare const createPostgresAgentIdentityRegistrationStore: <DB extends AnyPgDatabase>(db: DB) => AgentIdentityRegistrationStore;
|
|
290
569
|
export declare const createPostgresAgentRegistrationStore: <DB extends AnyPgDatabase>(db: DB) => AgentRegistrationStore;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { AccessTokenStore } from '../apikeys/types';
|
|
2
|
+
import { type SigningKey } from '../oidc/keys';
|
|
3
|
+
import type { RouteString } from '../types';
|
|
4
|
+
import type { AgentAuthConfig, AgentRegistrationDiscoveryMetadata } from './config';
|
|
5
|
+
import type { AgentIdentityRegistration, AgentIdentityRegistrationKind, AgentIdentityRegistrationStore, VerifiedAgentIdentityAssertion } from './types';
|
|
6
|
+
export declare const AGENT_CLAIM_GRANT_TYPE: "urn:workos:agent-auth:grant-type:claim";
|
|
7
|
+
export declare const AGENT_IDENTITY_ASSERTION_GRANT_TYPE: "urn:ietf:params:oauth:grant-type:jwt-bearer";
|
|
8
|
+
export declare const AGENT_IDENTITY_ASSERTION_TYPE: "urn:ietf:params:oauth:token-type:id-jag";
|
|
9
|
+
export type AgentRegistrationAuthenticatedUser = {
|
|
10
|
+
email?: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
};
|
|
13
|
+
export type AgentRegistrationProtocolConfig = {
|
|
14
|
+
accessTokenStore: AccessTokenStore;
|
|
15
|
+
allowAnonymous?: boolean;
|
|
16
|
+
allowServiceAuth?: boolean;
|
|
17
|
+
assertionTtlMs?: number;
|
|
18
|
+
attemptTtlMs?: number;
|
|
19
|
+
claimRoute?: RouteString;
|
|
20
|
+
claimTtlMs?: number;
|
|
21
|
+
completeRoute?: RouteString;
|
|
22
|
+
guideRoute?: RouteString;
|
|
23
|
+
identityRoute?: RouteString;
|
|
24
|
+
identityStore: AgentIdentityRegistrationStore;
|
|
25
|
+
maxAuthenticationAgeMs?: number;
|
|
26
|
+
maxCodeAttempts?: number;
|
|
27
|
+
pollIntervalSeconds?: number;
|
|
28
|
+
postClaimScopes: string[];
|
|
29
|
+
preClaimScopes?: string[];
|
|
30
|
+
resolveAuthenticatedUser: (request: Request) => Promise<AgentRegistrationAuthenticatedUser | undefined>;
|
|
31
|
+
/** Match a cryptographically verified upstream identity to local state. A
|
|
32
|
+
* userId permits immediate registration; omitting it requires a user claim. */
|
|
33
|
+
resolveVerifiedIdentity?: (identity: VerifiedAgentIdentityAssertion) => Promise<{
|
|
34
|
+
userId?: string;
|
|
35
|
+
} | undefined>;
|
|
36
|
+
/** Bulk-revokes access tokens for an agent. Required for anonymous
|
|
37
|
+
* registration and recommended for immediate cleanup on any revocation. It
|
|
38
|
+
* must be idempotent because atomic state updates may be retried. */
|
|
39
|
+
revokeAccessTokens?: (agentId: string) => Promise<void>;
|
|
40
|
+
signingKey: SigningKey;
|
|
41
|
+
tokenTtlMs?: number;
|
|
42
|
+
verifyIdentityAssertion?: (assertion: string) => Promise<VerifiedAgentIdentityAssertion | undefined>;
|
|
43
|
+
};
|
|
44
|
+
export type AgentRegistrationEndpoints = {
|
|
45
|
+
claimEndpoint: string;
|
|
46
|
+
completeEndpoint: string;
|
|
47
|
+
guide: string;
|
|
48
|
+
identityEndpoint: string;
|
|
49
|
+
tokenEndpoint: string;
|
|
50
|
+
};
|
|
51
|
+
export declare const agentRegistrationDiscoveryMetadata: (config: AgentAuthConfig) => AgentRegistrationDiscoveryMetadata;
|
|
52
|
+
export declare const agentRegistrationEndpoints: (config: AgentAuthConfig) => AgentRegistrationEndpoints;
|
|
53
|
+
/** Generates the agent-readable companion document. Endpoint URLs and support
|
|
54
|
+
* flags come from the same structured configuration used for discovery, so the
|
|
55
|
+
* prose cannot silently drift from the authorization server metadata. */
|
|
56
|
+
export declare const generateAgentRegistrationGuide: (config: AgentAuthConfig) => string;
|
|
57
|
+
declare const createFlow: ({ agentId, kind, loginHint, now, registration, status, upstream, userId, withAttempt }: {
|
|
58
|
+
agentId: string;
|
|
59
|
+
kind: AgentIdentityRegistrationKind;
|
|
60
|
+
loginHint?: string;
|
|
61
|
+
now: number;
|
|
62
|
+
registration: AgentRegistrationProtocolConfig;
|
|
63
|
+
status: AgentIdentityRegistration["status"];
|
|
64
|
+
upstream?: AgentIdentityRegistration["upstream"];
|
|
65
|
+
userId?: string;
|
|
66
|
+
withAttempt?: string;
|
|
67
|
+
}) => Promise<{
|
|
68
|
+
attempt: {
|
|
69
|
+
attempt: {
|
|
70
|
+
attempts: number;
|
|
71
|
+
email: string;
|
|
72
|
+
expiresAt: number;
|
|
73
|
+
tokenHash: string;
|
|
74
|
+
userCodeHash: string;
|
|
75
|
+
};
|
|
76
|
+
attemptToken: string;
|
|
77
|
+
expiresAt: number;
|
|
78
|
+
userCode: string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
claimToken: string;
|
|
81
|
+
flow: AgentIdentityRegistration;
|
|
82
|
+
}>;
|
|
83
|
+
export declare const issueAgentServiceAssertion: (config: AgentAuthConfig, flow: AgentIdentityRegistration, now?: number) => Promise<{
|
|
84
|
+
assertion: string;
|
|
85
|
+
expiresAt: number;
|
|
86
|
+
}>;
|
|
87
|
+
declare const ceremony: (config: AgentAuthConfig, flow: AgentIdentityRegistration, attempt: NonNullable<Awaited<ReturnType<typeof createFlow>>["attempt"]>) => {
|
|
88
|
+
expires_in: number;
|
|
89
|
+
interval: number;
|
|
90
|
+
user_code: string;
|
|
91
|
+
verification_uri: string;
|
|
92
|
+
};
|
|
93
|
+
export type StartAgentRegistrationInput = {
|
|
94
|
+
type: 'anonymous';
|
|
95
|
+
} | {
|
|
96
|
+
loginHint: string;
|
|
97
|
+
type: 'service_auth';
|
|
98
|
+
} | {
|
|
99
|
+
assertion: string;
|
|
100
|
+
assertionType: typeof AGENT_IDENTITY_ASSERTION_TYPE;
|
|
101
|
+
type: 'identity_assertion';
|
|
102
|
+
};
|
|
103
|
+
export type StartAgentRegistrationResult = {
|
|
104
|
+
error: string;
|
|
105
|
+
message?: string;
|
|
106
|
+
status: 400 | 401 | 403;
|
|
107
|
+
} | {
|
|
108
|
+
assertionExpires: number;
|
|
109
|
+
claim?: ReturnType<typeof ceremony>;
|
|
110
|
+
claimToken?: string;
|
|
111
|
+
claimTokenExpires?: number;
|
|
112
|
+
identityAssertion?: string;
|
|
113
|
+
preClaimScopes?: string[];
|
|
114
|
+
postClaimScopes: string[];
|
|
115
|
+
registrationId: string;
|
|
116
|
+
registrationType: AgentIdentityRegistrationKind;
|
|
117
|
+
status: 200;
|
|
118
|
+
};
|
|
119
|
+
export declare const startAgentRegistration: (config: AgentAuthConfig, input: StartAgentRegistrationInput, now?: number) => Promise<StartAgentRegistrationResult>;
|
|
120
|
+
export type BeginAgentClaimResult = {
|
|
121
|
+
error: 'claim_expired' | 'invalid_claim_token';
|
|
122
|
+
status: 400;
|
|
123
|
+
} | {
|
|
124
|
+
error: 'concurrent_update';
|
|
125
|
+
status: 409;
|
|
126
|
+
} | {
|
|
127
|
+
claimAttempt: ReturnType<typeof ceremony>;
|
|
128
|
+
status: 200;
|
|
129
|
+
};
|
|
130
|
+
export declare const beginAgentClaim: (config: AgentAuthConfig, input: {
|
|
131
|
+
claimToken: string;
|
|
132
|
+
email: string;
|
|
133
|
+
}, now?: number) => Promise<BeginAgentClaimResult>;
|
|
134
|
+
export type CompleteAgentClaimResult = {
|
|
135
|
+
error: 'claim_expired' | 'concurrent_update' | 'invalid_claim_attempt' | 'user_code_invalid' | 'wrong_user';
|
|
136
|
+
status: 400 | 403 | 409 | 429;
|
|
137
|
+
} | {
|
|
138
|
+
status: 204;
|
|
139
|
+
};
|
|
140
|
+
export declare const completeAgentClaim: (config: AgentAuthConfig, input: {
|
|
141
|
+
attemptToken: string;
|
|
142
|
+
request: Request;
|
|
143
|
+
userCode: string;
|
|
144
|
+
}, now?: number) => Promise<CompleteAgentClaimResult>;
|
|
145
|
+
export type AgentTokenGrantResult = {
|
|
146
|
+
body: Record<string, unknown>;
|
|
147
|
+
status: 200;
|
|
148
|
+
} | {
|
|
149
|
+
body: {
|
|
150
|
+
error: string;
|
|
151
|
+
};
|
|
152
|
+
status: 400;
|
|
153
|
+
};
|
|
154
|
+
export declare const createAgentRegistrationCredentialVerifier: (accessTokenStore: AccessTokenStore, identityStore?: AgentIdentityRegistrationStore) => (request: Request) => Promise<{
|
|
155
|
+
agentId: string;
|
|
156
|
+
expiresAt: number;
|
|
157
|
+
scopes: string[];
|
|
158
|
+
userId: string | undefined;
|
|
159
|
+
} | undefined>;
|
|
160
|
+
export declare const handleAgentTokenGrant: (config: AgentAuthConfig, body: Record<string, string | undefined>, now?: number) => Promise<AgentTokenGrantResult | undefined>;
|
|
161
|
+
export declare const revokeAgentIdentityRegistration: (config: AgentAuthConfig, registrationId: string, now?: number) => Promise<boolean>;
|
|
162
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
type JsonObject = Record<string, unknown>;
|
|
2
|
+
export type DiscoveredAgentRegistration = {
|
|
3
|
+
agentAuth: {
|
|
4
|
+
claimEndpoint: string;
|
|
5
|
+
identityAssertionTypes: string[];
|
|
6
|
+
identityEndpoint: string;
|
|
7
|
+
identityTypes: string[];
|
|
8
|
+
skill: string;
|
|
9
|
+
};
|
|
10
|
+
authorizationServer: string;
|
|
11
|
+
resource: string;
|
|
12
|
+
resourceMetadataUrl: string;
|
|
13
|
+
scopes: string[];
|
|
14
|
+
tokenEndpoint: string;
|
|
15
|
+
};
|
|
16
|
+
export type AgentRegistrationClientOptions = {
|
|
17
|
+
allowInsecureLocalhost?: boolean;
|
|
18
|
+
maxResponseBytes?: number;
|
|
19
|
+
request?: typeof fetch;
|
|
20
|
+
};
|
|
21
|
+
/** Discovers agent registration using RFC 9728 followed by RFC 8414. Network
|
|
22
|
+
* policy is injected through `request`; redirects are rejected by default. */
|
|
23
|
+
export declare const createAgentRegistrationClient: (discovery: DiscoveredAgentRegistration, options?: AgentRegistrationClientOptions) => {
|
|
24
|
+
beginAnonymous: () => Promise<{
|
|
25
|
+
body: JsonObject;
|
|
26
|
+
response: Response;
|
|
27
|
+
}>;
|
|
28
|
+
beginServiceAuth: (loginHint: string) => Promise<{
|
|
29
|
+
body: JsonObject;
|
|
30
|
+
response: Response;
|
|
31
|
+
}>;
|
|
32
|
+
beginVerified: (assertion: string) => Promise<{
|
|
33
|
+
body: JsonObject;
|
|
34
|
+
response: Response;
|
|
35
|
+
}>;
|
|
36
|
+
claim: (claimToken: string, email: string) => Promise<{
|
|
37
|
+
body: JsonObject;
|
|
38
|
+
response: Response;
|
|
39
|
+
}>;
|
|
40
|
+
exchangeAssertion: (assertion: string) => Promise<{
|
|
41
|
+
body: JsonObject;
|
|
42
|
+
response: Response;
|
|
43
|
+
}>;
|
|
44
|
+
pollClaim: (claimToken: string) => Promise<{
|
|
45
|
+
body: JsonObject;
|
|
46
|
+
response: Response;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
export declare const discoverAgentRegistration: (resource: string, options?: AgentRegistrationClientOptions) => Promise<DiscoveredAgentRegistration>;
|
|
50
|
+
export {};
|
package/dist/agents/routes.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
2
|
import { type AgentAuthConfig } from './config';
|
|
3
3
|
import type { AgentPrincipal } from './types';
|
|
4
|
+
import { agentRegistrationDiscoveryMetadata } from './registration';
|
|
4
5
|
type AgentAuthFailure = {
|
|
5
6
|
code: 'Forbidden' | 'Unauthorized';
|
|
6
7
|
message: 'Agent is not authenticated' | 'Insufficient agent scopes';
|
|
@@ -11,6 +12,7 @@ export declare const agentAuthChallenge: ({ config, error, requiredScopes }: {
|
|
|
11
12
|
requiredScopes?: string[];
|
|
12
13
|
}) => string;
|
|
13
14
|
export declare const agentResourceMetadataUrl: (config: AgentAuthConfig) => string;
|
|
15
|
+
export { agentRegistrationDiscoveryMetadata };
|
|
14
16
|
export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
15
17
|
decorator: {};
|
|
16
18
|
store: {};
|
|
@@ -92,5 +94,114 @@ export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
|
92
94
|
schema: {};
|
|
93
95
|
standaloneSchema: {};
|
|
94
96
|
response: {};
|
|
97
|
+
}> | Elysia<"", {
|
|
98
|
+
decorator: {};
|
|
99
|
+
store: {};
|
|
100
|
+
derive: {
|
|
101
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
102
|
+
};
|
|
103
|
+
resolve: {};
|
|
104
|
+
}, {
|
|
105
|
+
typebox: {};
|
|
106
|
+
error: {};
|
|
107
|
+
}, {
|
|
108
|
+
schema: {};
|
|
109
|
+
standaloneSchema: {};
|
|
110
|
+
macro: {};
|
|
111
|
+
macroFn: {};
|
|
112
|
+
parser: {};
|
|
113
|
+
response: import("elysia").ExtractErrorFromHandle<{
|
|
114
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
115
|
+
}>;
|
|
116
|
+
}, {
|
|
117
|
+
[x: string]: {
|
|
118
|
+
get: {
|
|
119
|
+
body: unknown;
|
|
120
|
+
params: {};
|
|
121
|
+
query: unknown;
|
|
122
|
+
headers: unknown;
|
|
123
|
+
response: {
|
|
124
|
+
200: {
|
|
125
|
+
resource: string;
|
|
126
|
+
scopes_supported: string[];
|
|
127
|
+
resource_name?: string | undefined;
|
|
128
|
+
resource_logo_uri?: string | undefined;
|
|
129
|
+
authorization_servers: string[];
|
|
130
|
+
bearer_methods_supported: string[];
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
} & {
|
|
136
|
+
[x: string]: {
|
|
137
|
+
get: {
|
|
138
|
+
body: unknown;
|
|
139
|
+
params: {};
|
|
140
|
+
query: unknown;
|
|
141
|
+
headers: unknown;
|
|
142
|
+
response: {
|
|
143
|
+
200: Response;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
} & {
|
|
148
|
+
[x: string]: {
|
|
149
|
+
get: {
|
|
150
|
+
body: unknown;
|
|
151
|
+
params: {};
|
|
152
|
+
query: unknown;
|
|
153
|
+
headers: unknown;
|
|
154
|
+
response: {
|
|
155
|
+
200: Response;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
} & {
|
|
160
|
+
[x: string]: {
|
|
161
|
+
post: {
|
|
162
|
+
body: unknown;
|
|
163
|
+
params: {};
|
|
164
|
+
query: unknown;
|
|
165
|
+
headers: unknown;
|
|
166
|
+
response: {
|
|
167
|
+
200: Response;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
} & {
|
|
172
|
+
[x: string]: {
|
|
173
|
+
post: {
|
|
174
|
+
body: unknown;
|
|
175
|
+
params: {};
|
|
176
|
+
query: unknown;
|
|
177
|
+
headers: unknown;
|
|
178
|
+
response: {
|
|
179
|
+
200: Response;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
} & {
|
|
184
|
+
[x: string]: {
|
|
185
|
+
post: {
|
|
186
|
+
body: unknown;
|
|
187
|
+
params: {};
|
|
188
|
+
query: unknown;
|
|
189
|
+
headers: unknown;
|
|
190
|
+
response: {
|
|
191
|
+
200: Response;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
}, {
|
|
196
|
+
derive: {};
|
|
197
|
+
resolve: {};
|
|
198
|
+
schema: {};
|
|
199
|
+
standaloneSchema: {};
|
|
200
|
+
response: {};
|
|
201
|
+
}, {
|
|
202
|
+
derive: {};
|
|
203
|
+
resolve: {};
|
|
204
|
+
schema: {};
|
|
205
|
+
standaloneSchema: {};
|
|
206
|
+
response: {};
|
|
95
207
|
}>;
|
|
96
|
-
export {};
|