@absolutejs/auth 0.55.5 → 0.55.7

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.
Files changed (219) hide show
  1. package/README.md +6 -1
  2. package/dist/agents/index.js +36 -6
  3. package/dist/agents/index.js.map +6 -5
  4. package/dist/index.d.ts +3400 -8
  5. package/dist/index.js +777 -522
  6. package/dist/index.js.map +17 -13
  7. package/dist/server.d.ts +6 -6
  8. package/dist/server.js +775 -522
  9. package/dist/server.js.map +18 -14
  10. package/package.json +1 -1
  11. package/dist/abuse/captcha.d.ts +0 -11
  12. package/dist/abuse/config.d.ts +0 -29
  13. package/dist/actions.d.ts +0 -27
  14. package/dist/adaptive/config.d.ts +0 -34
  15. package/dist/adaptive/fingerprint.d.ts +0 -2
  16. package/dist/adaptive/inMemoryStores.d.ts +0 -3
  17. package/dist/adaptive/postgresStores.d.ts +0 -245
  18. package/dist/adaptive/types.d.ts +0 -62
  19. package/dist/agents/config.d.ts +0 -44
  20. package/dist/agents/context.d.ts +0 -46
  21. package/dist/agents/idJag.d.ts +0 -49
  22. package/dist/agents/inMemoryStores.d.ts +0 -4
  23. package/dist/agents/oidcAdapter.d.ts +0 -12
  24. package/dist/agents/postgresStores.d.ts +0 -569
  25. package/dist/agents/principal.d.ts +0 -4
  26. package/dist/agents/registration.d.ts +0 -162
  27. package/dist/agents/registrationClient.d.ts +0 -50
  28. package/dist/agents/routes.d.ts +0 -214
  29. package/dist/agents/types.d.ts +0 -129
  30. package/dist/apikeys/config.d.ts +0 -64
  31. package/dist/apikeys/inMemoryStores.d.ts +0 -4
  32. package/dist/apikeys/postgresStores.d.ts +0 -359
  33. package/dist/apikeys/routes.d.ts +0 -83
  34. package/dist/apikeys/types.d.ts +0 -53
  35. package/dist/audit/config.d.ts +0 -9
  36. package/dist/audit/export.d.ts +0 -2
  37. package/dist/audit/inMemoryAuditStore.d.ts +0 -2
  38. package/dist/audit/integrity.d.ts +0 -19
  39. package/dist/audit/postgresAuditStore.d.ts +0 -116
  40. package/dist/audit/siem.d.ts +0 -11
  41. package/dist/audit/types.d.ts +0 -19
  42. package/dist/audit/wrap.d.ts +0 -9
  43. package/dist/authInstance.d.ts +0 -7
  44. package/dist/authorization/config.d.ts +0 -19
  45. package/dist/authorization/protectPermission.d.ts +0 -52
  46. package/dist/compliance/cipher.d.ts +0 -5
  47. package/dist/compliance/config.d.ts +0 -18
  48. package/dist/compliance/redaction.d.ts +0 -8
  49. package/dist/compliance/routes.d.ts +0 -89
  50. package/dist/constants.d.ts +0 -10
  51. package/dist/credentials/backgroundOps.d.ts +0 -45
  52. package/dist/credentials/config.d.ts +0 -68
  53. package/dist/credentials/emailValidation.d.ts +0 -9
  54. package/dist/credentials/emailVerification.d.ts +0 -83
  55. package/dist/credentials/import.d.ts +0 -34
  56. package/dist/credentials/inMemoryCredentialStore.d.ts +0 -2
  57. package/dist/credentials/legacyHashers.d.ts +0 -3
  58. package/dist/credentials/login.d.ts +0 -76
  59. package/dist/credentials/passwordPolicy.d.ts +0 -15
  60. package/dist/credentials/passwordReset.d.ts +0 -87
  61. package/dist/credentials/postgresCredentialStore.d.ts +0 -235
  62. package/dist/credentials/register.d.ts +0 -54
  63. package/dist/credentials/routes.d.ts +0 -201
  64. package/dist/credentials/types.d.ts +0 -26
  65. package/dist/crypto.d.ts +0 -32
  66. package/dist/errors.d.ts +0 -12
  67. package/dist/federation/tokenStore.d.ts +0 -29
  68. package/dist/fga/config.d.ts +0 -53
  69. package/dist/fga/inMemoryStores.d.ts +0 -3
  70. package/dist/fga/postgresStores.d.ts +0 -116
  71. package/dist/fga/redisCheckCache.d.ts +0 -11
  72. package/dist/fga/schema.d.ts +0 -2
  73. package/dist/fga/types.d.ts +0 -28
  74. package/dist/htmx/renderers.d.ts +0 -8
  75. package/dist/htmx/routes.d.ts +0 -514
  76. package/dist/htmx/types.d.ts +0 -129
  77. package/dist/linkedProviders/inMemoryStores.d.ts +0 -9
  78. package/dist/linkedProviders/neonStores.d.ts +0 -484
  79. package/dist/linkedProviders/oauthResolver.d.ts +0 -9
  80. package/dist/linkedProviders/resolver.d.ts +0 -22
  81. package/dist/lockout/config.d.ts +0 -17
  82. package/dist/lockout/inMemoryLockoutStore.d.ts +0 -2
  83. package/dist/lockout/postgresLockoutStore.d.ts +0 -71
  84. package/dist/lockout/redisLockoutStore.d.ts +0 -3
  85. package/dist/lockout/types.d.ts +0 -12
  86. package/dist/mfa/backupCodes.d.ts +0 -5
  87. package/dist/mfa/challenge.d.ts +0 -70
  88. package/dist/mfa/config.d.ts +0 -50
  89. package/dist/mfa/gate.d.ts +0 -2
  90. package/dist/mfa/inMemoryMfaStore.d.ts +0 -2
  91. package/dist/mfa/management.d.ts +0 -106
  92. package/dist/mfa/postgresMfaStore.d.ts +0 -206
  93. package/dist/mfa/rotation.d.ts +0 -17
  94. package/dist/mfa/routes.d.ts +0 -234
  95. package/dist/mfa/secret.d.ts +0 -2
  96. package/dist/mfa/sms.d.ts +0 -105
  97. package/dist/mfa/totp.d.ts +0 -91
  98. package/dist/mfa/types.d.ts +0 -23
  99. package/dist/migrations/generate.d.ts +0 -2
  100. package/dist/migrations/index.d.ts +0 -5
  101. package/dist/migrations/runner.d.ts +0 -13
  102. package/dist/migrations/types.d.ts +0 -14
  103. package/dist/oidc/clientAuth.d.ts +0 -19
  104. package/dist/oidc/clientIdMetadata.d.ts +0 -32
  105. package/dist/oidc/config.d.ts +0 -295
  106. package/dist/oidc/dpop.d.ts +0 -23
  107. package/dist/oidc/inMemoryStores.d.ts +0 -11
  108. package/dist/oidc/inMemoryVciStores.d.ts +0 -3
  109. package/dist/oidc/jar.d.ts +0 -14
  110. package/dist/oidc/keys.d.ts +0 -25
  111. package/dist/oidc/logout.d.ts +0 -38
  112. package/dist/oidc/mtls.d.ts +0 -11
  113. package/dist/oidc/par.d.ts +0 -28
  114. package/dist/oidc/postgresStores.d.ts +0 -1187
  115. package/dist/oidc/registration.d.ts +0 -138
  116. package/dist/oidc/routes.d.ts +0 -568
  117. package/dist/oidc/types.d.ts +0 -143
  118. package/dist/oidc/userinfo.d.ts +0 -21
  119. package/dist/oidc/vci.d.ts +0 -159
  120. package/dist/oidc/vciRoutes.d.ts +0 -92
  121. package/dist/organizations/config.d.ts +0 -46
  122. package/dist/organizations/inMemoryOrganizationStore.d.ts +0 -2
  123. package/dist/organizations/operations.d.ts +0 -39
  124. package/dist/organizations/postgresOrganizationStore.d.ts +0 -340
  125. package/dist/organizations/routes.d.ts +0 -298
  126. package/dist/organizations/types.d.ts +0 -45
  127. package/dist/passwordless/config.d.ts +0 -43
  128. package/dist/passwordless/inMemoryPasswordlessTokenStore.d.ts +0 -2
  129. package/dist/passwordless/postgresPasswordlessTokenStore.d.ts +0 -56
  130. package/dist/passwordless/routes.d.ts +0 -162
  131. package/dist/passwordless/types.d.ts +0 -9
  132. package/dist/portal/config.d.ts +0 -34
  133. package/dist/portal/inMemorySetupSessionStore.d.ts +0 -2
  134. package/dist/portal/operations.d.ts +0 -10
  135. package/dist/portal/postgresSetupSessionStore.d.ts +0 -116
  136. package/dist/portal/routes.d.ts +0 -160
  137. package/dist/portal/types.d.ts +0 -16
  138. package/dist/providers/clients.d.ts +0 -1818
  139. package/dist/providersFromEnv.d.ts +0 -19
  140. package/dist/roles/config.d.ts +0 -27
  141. package/dist/roles/inMemoryRoleStore.d.ts +0 -2
  142. package/dist/roles/operations.d.ts +0 -8
  143. package/dist/roles/postgresRoleStore.d.ts +0 -86
  144. package/dist/roles/resolver.d.ts +0 -17
  145. package/dist/roles/routes.d.ts +0 -105
  146. package/dist/roles/types.d.ts +0 -14
  147. package/dist/routes/authorize.d.ts +0 -102
  148. package/dist/routes/callback.d.ts +0 -64
  149. package/dist/routes/profile.d.ts +0 -70
  150. package/dist/routes/protectRoute.d.ts +0 -51
  151. package/dist/routes/refresh.d.ts +0 -74
  152. package/dist/routes/revoke.d.ts +0 -73
  153. package/dist/routes/sessions.d.ts +0 -103
  154. package/dist/routes/signout.d.ts +0 -70
  155. package/dist/routes/stepUp.d.ts +0 -48
  156. package/dist/routes/userStatus.d.ts +0 -72
  157. package/dist/scim/config.d.ts +0 -57
  158. package/dist/scim/extensions.d.ts +0 -30
  159. package/dist/scim/inMemoryScimTokenStore.d.ts +0 -2
  160. package/dist/scim/postgresScimTokenStore.d.ts +0 -86
  161. package/dist/scim/routes.d.ts +0 -366
  162. package/dist/scim/serialize.d.ts +0 -83
  163. package/dist/scim/types.d.ts +0 -54
  164. package/dist/serverConfig.d.ts +0 -10
  165. package/dist/session/access.d.ts +0 -33
  166. package/dist/session/anonymous.d.ts +0 -12
  167. package/dist/session/cleanup.d.ts +0 -45
  168. package/dist/session/impersonation.d.ts +0 -34
  169. package/dist/session/inMemoryStore.d.ts +0 -7
  170. package/dist/session/internalData.d.ts +0 -34
  171. package/dist/session/multiSession.d.ts +0 -27
  172. package/dist/session/neonStore.d.ts +0 -513
  173. package/dist/session/promote.d.ts +0 -23
  174. package/dist/session/redisStore.d.ts +0 -6
  175. package/dist/session/sessionsConfig.d.ts +0 -9
  176. package/dist/session/state.d.ts +0 -33
  177. package/dist/session/types.d.ts +0 -20
  178. package/dist/session/userSessions.d.ts +0 -19
  179. package/dist/sso/config.d.ts +0 -149
  180. package/dist/sso/discoveryRoute.d.ts +0 -63
  181. package/dist/sso/inMemorySamlServiceProviderStore.d.ts +0 -2
  182. package/dist/sso/inMemorySsoConnectionStore.d.ts +0 -2
  183. package/dist/sso/oidcRoutes.d.ts +0 -98
  184. package/dist/sso/postgresSamlServiceProviderStore.d.ts +0 -101
  185. package/dist/sso/postgresSsoConnectionStore.d.ts +0 -116
  186. package/dist/sso/samlIdpRoutes.d.ts +0 -139
  187. package/dist/sso/samlRoutes.d.ts +0 -178
  188. package/dist/sso/types.d.ts +0 -53
  189. package/dist/stores/postgres.d.ts +0 -5
  190. package/dist/stores/redis.d.ts +0 -5
  191. package/dist/telemetry/tracing.d.ts +0 -15
  192. package/dist/tenancy.d.ts +0 -9
  193. package/dist/typeGuards.d.ts +0 -6
  194. package/dist/typebox.d.ts +0 -4
  195. package/dist/types.d.ts +0 -421
  196. package/dist/utils.d.ts +0 -45
  197. package/dist/vault/config.d.ts +0 -20
  198. package/dist/vault/inMemoryVaultStore.d.ts +0 -2
  199. package/dist/vault/postgresVaultStore.d.ts +0 -86
  200. package/dist/vault/types.d.ts +0 -14
  201. package/dist/vc/inMemoryVpStores.d.ts +0 -2
  202. package/dist/vc/openid4vp.d.ts +0 -82
  203. package/dist/vc/postgresVcStores.d.ts +0 -300
  204. package/dist/vc/sdJwt.d.ts +0 -37
  205. package/dist/vc/statusList.d.ts +0 -29
  206. package/dist/vc/statusListRoutes.d.ts +0 -63
  207. package/dist/vc/vpRoutes.d.ts +0 -120
  208. package/dist/webauthn/adapter.d.ts +0 -59
  209. package/dist/webauthn/config.d.ts +0 -36
  210. package/dist/webauthn/inMemoryWebAuthnCredentialStore.d.ts +0 -2
  211. package/dist/webauthn/postgresWebAuthnCredentialStore.d.ts +0 -146
  212. package/dist/webauthn/routes.d.ts +0 -155
  213. package/dist/webauthn/types.d.ts +0 -17
  214. package/dist/webhooks/config.d.ts +0 -34
  215. package/dist/webhooks/dispatcher.d.ts +0 -3
  216. package/dist/webhooks/inMemoryStore.d.ts +0 -2
  217. package/dist/webhooks/postgresStore.d.ts +0 -116
  218. package/dist/webhooks/sign.d.ts +0 -11
  219. package/dist/webhooks/types.d.ts +0 -25
@@ -1,162 +0,0 @@
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 {};
@@ -1,50 +0,0 @@
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 {};
@@ -1,214 +0,0 @@
1
- import { type AgentAuthConfig } from './config';
2
- import { agentAuthChallenge } from './context';
3
- import { agentRegistrationDiscoveryMetadata } from './registration';
4
- export { agentAuthChallenge, agentRegistrationDiscoveryMetadata };
5
- export declare const agentAuthPlugin: (config?: AgentAuthConfig) => import("elysia").default<"", {
6
- decorator: {};
7
- store: {};
8
- derive: {
9
- readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
10
- code: "Forbidden" | "Unauthorized";
11
- message: "Agent is not authenticated" | "Insufficient agent scopes";
12
- }) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
13
- };
14
- resolve: {};
15
- }, {
16
- typebox: {};
17
- error: {};
18
- }, {
19
- schema: {};
20
- standaloneSchema: {};
21
- macro: {};
22
- macroFn: {};
23
- parser: {};
24
- response: import("elysia").ExtractErrorFromHandle<{
25
- readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
26
- code: "Forbidden" | "Unauthorized";
27
- message: "Agent is not authenticated" | "Insufficient agent scopes";
28
- }) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
29
- }>;
30
- }, {}, {
31
- derive: {};
32
- resolve: {};
33
- schema: {};
34
- standaloneSchema: {};
35
- response: {};
36
- }, {
37
- derive: {};
38
- resolve: {};
39
- schema: {};
40
- standaloneSchema: {};
41
- response: {};
42
- }> | import("elysia").default<"", {
43
- decorator: {};
44
- store: {};
45
- derive: {
46
- readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
47
- code: "Forbidden" | "Unauthorized";
48
- message: "Agent is not authenticated" | "Insufficient agent scopes";
49
- }) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
50
- };
51
- resolve: {};
52
- }, {
53
- typebox: {};
54
- error: {};
55
- }, {
56
- schema: {};
57
- standaloneSchema: {};
58
- macro: {};
59
- macroFn: {};
60
- parser: {};
61
- response: import("elysia").ExtractErrorFromHandle<{
62
- readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
63
- code: "Forbidden" | "Unauthorized";
64
- message: "Agent is not authenticated" | "Insufficient agent scopes";
65
- }) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
66
- }>;
67
- }, {
68
- [x: string]: {
69
- get: {
70
- body: unknown;
71
- params: {};
72
- query: unknown;
73
- headers: unknown;
74
- response: {
75
- 200: {
76
- resource: string;
77
- scopes_supported: string[];
78
- resource_name?: string | undefined;
79
- resource_logo_uri?: string | undefined;
80
- authorization_servers: string[];
81
- bearer_methods_supported: string[];
82
- };
83
- };
84
- };
85
- };
86
- }, {
87
- derive: {};
88
- resolve: {};
89
- schema: {};
90
- standaloneSchema: {};
91
- response: {};
92
- }, {
93
- derive: {};
94
- resolve: {};
95
- schema: {};
96
- standaloneSchema: {};
97
- response: {};
98
- }> | import("elysia").default<"", {
99
- decorator: {};
100
- store: {};
101
- derive: {
102
- readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
103
- code: "Forbidden" | "Unauthorized";
104
- message: "Agent is not authenticated" | "Insufficient agent scopes";
105
- }) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
106
- };
107
- resolve: {};
108
- }, {
109
- typebox: {};
110
- error: {};
111
- }, {
112
- schema: {};
113
- standaloneSchema: {};
114
- macro: {};
115
- macroFn: {};
116
- parser: {};
117
- response: import("elysia").ExtractErrorFromHandle<{
118
- readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
119
- code: "Forbidden" | "Unauthorized";
120
- message: "Agent is not authenticated" | "Insufficient agent scopes";
121
- }) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
122
- }>;
123
- }, {
124
- [x: string]: {
125
- get: {
126
- body: unknown;
127
- params: {};
128
- query: unknown;
129
- headers: unknown;
130
- response: {
131
- 200: {
132
- resource: string;
133
- scopes_supported: string[];
134
- resource_name?: string | undefined;
135
- resource_logo_uri?: string | undefined;
136
- authorization_servers: string[];
137
- bearer_methods_supported: string[];
138
- };
139
- };
140
- };
141
- };
142
- } & {
143
- [x: string]: {
144
- get: {
145
- body: unknown;
146
- params: {};
147
- query: unknown;
148
- headers: unknown;
149
- response: {
150
- 200: Response;
151
- };
152
- };
153
- };
154
- } & {
155
- [x: string]: {
156
- get: {
157
- body: unknown;
158
- params: {};
159
- query: unknown;
160
- headers: unknown;
161
- response: {
162
- 200: Response;
163
- };
164
- };
165
- };
166
- } & {
167
- [x: string]: {
168
- post: {
169
- body: unknown;
170
- params: {};
171
- query: unknown;
172
- headers: unknown;
173
- response: {
174
- 200: Response;
175
- };
176
- };
177
- };
178
- } & {
179
- [x: string]: {
180
- post: {
181
- body: unknown;
182
- params: {};
183
- query: unknown;
184
- headers: unknown;
185
- response: {
186
- 200: Response;
187
- };
188
- };
189
- };
190
- } & {
191
- [x: string]: {
192
- post: {
193
- body: unknown;
194
- params: {};
195
- query: unknown;
196
- headers: unknown;
197
- response: {
198
- 200: Response;
199
- };
200
- };
201
- };
202
- }, {
203
- derive: {};
204
- resolve: {};
205
- schema: {};
206
- standaloneSchema: {};
207
- response: {};
208
- }, {
209
- derive: {};
210
- resolve: {};
211
- schema: {};
212
- standaloneSchema: {};
213
- response: {};
214
- }>;
@@ -1,129 +0,0 @@
1
- export type AgentRegistrationStatus = 'active' | 'revoked';
2
- export type AgentDelegationStatus = 'active' | 'revoked';
3
- /** A durable identity for an agent client. This is deliberately protocol-neutral:
4
- * `clientId` can refer to an OAuth client, while adapters for other protocols can
5
- * use `agentId` without manufacturing OAuth metadata. */
6
- export type AgentRegistration = {
7
- agentId: string;
8
- allowedScopes: string[];
9
- clientId?: string;
10
- createdAt: number;
11
- metadata?: Record<string, unknown>;
12
- name: string;
13
- status: AgentRegistrationStatus;
14
- updatedAt: number;
15
- };
16
- export type AgentRegistrationStore = {
17
- findByAgentId: (agentId: string) => Promise<AgentRegistration | undefined>;
18
- findByClientId: (clientId: string) => Promise<AgentRegistration | undefined>;
19
- listRegistrations: () => Promise<AgentRegistration[]>;
20
- saveRegistration: (registration: AgentRegistration) => Promise<void>;
21
- };
22
- /** A user's explicit grant to an agent. Authorization details use RFC 9396's
23
- * open object shape so applications can express transaction constraints without
24
- * forcing them into coarse OAuth scope strings. */
25
- export type AgentDelegation = {
26
- agentId: string;
27
- authorizationDetails?: Record<string, unknown>[];
28
- createdAt: number;
29
- delegationId: string;
30
- expiresAt?: number;
31
- organizationId?: string;
32
- scopes: string[];
33
- status: AgentDelegationStatus;
34
- updatedAt: number;
35
- userId: string;
36
- };
37
- export type AgentDelegationStore = {
38
- findActiveDelegation: (query: {
39
- agentId: string;
40
- now?: number;
41
- organizationId?: string;
42
- userId: string;
43
- }) => Promise<AgentDelegation | undefined>;
44
- findByDelegationId: (delegationId: string) => Promise<AgentDelegation | undefined>;
45
- listDelegations: (agentId?: string) => Promise<AgentDelegation[]>;
46
- saveDelegation: (delegation: AgentDelegation) => Promise<void>;
47
- };
48
- /** The normalized result produced by a wire-protocol adapter. The core never
49
- * handles raw provider assertions; it authorizes only this verified shape. */
50
- export type VerifiedAgentCredential = {
51
- agentId: string;
52
- claims?: Record<string, unknown>;
53
- expiresAt?: number;
54
- organizationId?: string;
55
- resource?: string;
56
- scopes: string[];
57
- userId?: string;
58
- };
59
- export type AgentCredentialVerifier = (request: Request) => Promise<VerifiedAgentCredential | undefined>;
60
- export type AgentPrincipal = {
61
- agentId: string;
62
- authorizationDetails?: Record<string, unknown>[];
63
- delegationId?: string;
64
- kind: 'agent';
65
- name: string;
66
- organizationId?: string;
67
- scopes: string[];
68
- trust: 'delegated' | 'registered';
69
- userId?: string;
70
- };
71
- export type AgentIdentityRegistrationKind = 'anonymous' | 'identity_assertion' | 'service_auth';
72
- export type AgentIdentityRegistrationStatus = 'claimed' | 'pending' | 'revoked';
73
- export type AgentClaimAttempt = {
74
- attempts: number;
75
- email: string;
76
- expiresAt: number;
77
- tokenHash: string;
78
- userCodeHash: string;
79
- };
80
- /** Durable state for the open auth.md registration profile. Secrets are
81
- * represented only by hashes; plaintext claim and attempt tokens are returned
82
- * once to the agent and never persisted. `version` is used for compare-and-swap
83
- * updates so claim completion is safe across multiple application instances. */
84
- export type AgentIdentityRegistration = {
85
- agentId: string;
86
- claimAttempt?: AgentClaimAttempt;
87
- claimExpiresAt: number;
88
- claimTokenHash: string;
89
- createdAt: number;
90
- expiresAt: number;
91
- kind: AgentIdentityRegistrationKind;
92
- loginHint?: string;
93
- lastPolledAt?: number;
94
- registrationId: string;
95
- status: AgentIdentityRegistrationStatus;
96
- updatedAt: number;
97
- upstream?: {
98
- clientId: string;
99
- issuer: string;
100
- subject: string;
101
- };
102
- userId?: string;
103
- version: number;
104
- };
105
- export type AgentIdentityRegistrationStore = {
106
- create: (registration: AgentIdentityRegistration) => Promise<boolean>;
107
- findByClaimTokenHash: (claimTokenHash: string) => Promise<AgentIdentityRegistration | undefined>;
108
- findByAgentId: (agentId: string) => Promise<AgentIdentityRegistration | undefined>;
109
- findByRegistrationId: (registrationId: string) => Promise<AgentIdentityRegistration | undefined>;
110
- findByUpstreamIdentity: (query: {
111
- clientId: string;
112
- issuer: string;
113
- subject: string;
114
- }) => Promise<AgentIdentityRegistration | undefined>;
115
- findByAttemptTokenHash: (attemptTokenHash: string) => Promise<AgentIdentityRegistration | undefined>;
116
- /** Replaces a record only when its current version equals expectedVersion. */
117
- replace: (registration: AgentIdentityRegistration, expectedVersion: number) => Promise<boolean>;
118
- };
119
- export type VerifiedAgentIdentityAssertion = {
120
- authenticatedAt: number;
121
- clientId: string;
122
- email?: string;
123
- emailVerified?: boolean;
124
- issuer: string;
125
- name?: string;
126
- phoneNumber?: string;
127
- phoneNumberVerified?: boolean;
128
- subject: string;
129
- };
@@ -1,64 +0,0 @@
1
- import type { RouteString } from '../types';
2
- import type { AccessTokenStore, ApiClient, ApiClientStore, ApiKey, ApiKeyStore, ApiPrincipal } from './types';
3
- export declare const DEFAULT_TOKEN_ROUTE: RouteString;
4
- export type ApiKeysConfig = {
5
- /** Where minted access tokens live — required (with `apiClientStore`) for the
6
- * client_credentials grant to be mounted. */
7
- accessTokenStore?: AccessTokenStore;
8
- /** Lifetime of a minted access token (defaults to one hour). */
9
- accessTokenTtlMs?: number;
10
- /** Registered M2M clients — required (with `accessTokenStore`) for the
11
- * client_credentials grant. */
12
- apiClientStore?: ApiClientStore;
13
- /** Static API keys. Used by the exported `verifyApiKey` / `resolveApiPrincipal`
14
- * helpers; the consumer wires its own management + guard routes. */
15
- apiKeyStore?: ApiKeyStore;
16
- /** Path of the client_credentials token endpoint (defaults to `/oauth2/token`). */
17
- tokenRoute?: RouteString;
18
- };
19
- export type ClientCredentialsResult = {
20
- error: 'invalid_client' | 'invalid_scope';
21
- ok: false;
22
- } | {
23
- accessToken: string;
24
- expiresIn: number;
25
- ok: true;
26
- scopes: string[];
27
- };
28
- export declare const createApiClient: (apiClientStore: ApiClientStore, options: {
29
- name: string;
30
- ownerId?: string;
31
- scopes?: string[];
32
- }) => Promise<{
33
- clientId: string;
34
- clientSecret: string;
35
- record: ApiClient;
36
- }>;
37
- export declare const createApiKey: (apiKeyStore: ApiKeyStore, options: {
38
- expiresAt?: number;
39
- name: string;
40
- ownerId?: string;
41
- scopes?: string[];
42
- }) => Promise<{
43
- key: string;
44
- record: ApiKey;
45
- }>;
46
- export declare const exchangeClientCredentials: ({ accessTokenStore, apiClientStore, clientId, clientSecret, now, requestedScopes, ttlMs }: {
47
- accessTokenStore: AccessTokenStore;
48
- apiClientStore: ApiClientStore;
49
- clientId: string;
50
- clientSecret: string;
51
- now?: number;
52
- requestedScopes?: string[];
53
- ttlMs?: number;
54
- }) => Promise<ClientCredentialsResult>;
55
- export declare const hasScopes: (principal: ApiPrincipal | undefined, required: string[]) => boolean;
56
- export declare const resolveApiPrincipal: ({ accessTokenStore, apiKey, apiKeyStore, authorization, now }: {
57
- accessTokenStore?: AccessTokenStore;
58
- apiKey?: string;
59
- apiKeyStore?: ApiKeyStore;
60
- authorization?: string;
61
- now?: number;
62
- }) => Promise<ApiPrincipal | undefined>;
63
- export declare const verifyAccessToken: (accessTokenStore: AccessTokenStore, presented: string, now?: number) => Promise<import("./types").AccessToken | undefined>;
64
- export declare const verifyApiKey: (apiKeyStore: ApiKeyStore, presented: string, now?: number) => Promise<ApiKey | undefined>;
@@ -1,4 +0,0 @@
1
- import type { AccessTokenStore, ApiClientStore, ApiKeyStore } from './types';
2
- export declare const createInMemoryAccessTokenStore: () => AccessTokenStore;
3
- export declare const createInMemoryApiClientStore: () => ApiClientStore;
4
- export declare const createInMemoryApiKeyStore: () => ApiKeyStore;