@absolutejs/auth 0.56.4 → 0.56.5

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 (211) hide show
  1. package/dist/abuse/captcha.d.ts +11 -0
  2. package/dist/abuse/config.d.ts +29 -0
  3. package/dist/actions.d.ts +27 -0
  4. package/dist/adaptive/config.d.ts +34 -0
  5. package/dist/adaptive/fingerprint.d.ts +2 -0
  6. package/dist/adaptive/inMemoryStores.d.ts +3 -0
  7. package/dist/adaptive/postgresStores.d.ts +245 -0
  8. package/dist/adaptive/types.d.ts +62 -0
  9. package/dist/agents/config.d.ts +44 -0
  10. package/dist/agents/context.d.ts +46 -0
  11. package/dist/agents/idJag.d.ts +49 -0
  12. package/dist/agents/inMemoryStores.d.ts +4 -0
  13. package/dist/agents/oidcAdapter.d.ts +12 -0
  14. package/dist/agents/postgresStores.d.ts +569 -0
  15. package/dist/agents/principal.d.ts +4 -0
  16. package/dist/agents/registration.d.ts +162 -0
  17. package/dist/agents/registrationClient.d.ts +50 -0
  18. package/dist/agents/routes.d.ts +321 -0
  19. package/dist/agents/types.d.ts +129 -0
  20. package/dist/apikeys/config.d.ts +64 -0
  21. package/dist/apikeys/inMemoryStores.d.ts +4 -0
  22. package/dist/apikeys/postgresStores.d.ts +359 -0
  23. package/dist/apikeys/routes.d.ts +83 -0
  24. package/dist/apikeys/types.d.ts +53 -0
  25. package/dist/audit/config.d.ts +9 -0
  26. package/dist/audit/export.d.ts +2 -0
  27. package/dist/audit/inMemoryAuditStore.d.ts +2 -0
  28. package/dist/audit/integrity.d.ts +19 -0
  29. package/dist/audit/postgresAuditStore.d.ts +116 -0
  30. package/dist/audit/siem.d.ts +11 -0
  31. package/dist/audit/types.d.ts +19 -0
  32. package/dist/audit/wrap.d.ts +9 -0
  33. package/dist/authContext.d.ts +193 -0
  34. package/dist/authorization/config.d.ts +19 -0
  35. package/dist/authorization/protectPermission.d.ts +52 -0
  36. package/dist/compliance/cipher.d.ts +11 -0
  37. package/dist/compliance/config.d.ts +18 -0
  38. package/dist/compliance/redaction.d.ts +8 -0
  39. package/dist/compliance/routes.d.ts +89 -0
  40. package/dist/constants.d.ts +10 -0
  41. package/dist/credentials/backgroundOps.d.ts +45 -0
  42. package/dist/credentials/config.d.ts +68 -0
  43. package/dist/credentials/emailValidation.d.ts +9 -0
  44. package/dist/credentials/emailVerification.d.ts +83 -0
  45. package/dist/credentials/import.d.ts +34 -0
  46. package/dist/credentials/inMemoryCredentialStore.d.ts +2 -0
  47. package/dist/credentials/legacyHashers.d.ts +3 -0
  48. package/dist/credentials/login.d.ts +76 -0
  49. package/dist/credentials/passwordPolicy.d.ts +15 -0
  50. package/dist/credentials/passwordReset.d.ts +87 -0
  51. package/dist/credentials/postgresCredentialStore.d.ts +235 -0
  52. package/dist/credentials/register.d.ts +54 -0
  53. package/dist/credentials/routes.d.ts +201 -0
  54. package/dist/credentials/types.d.ts +26 -0
  55. package/dist/crypto.d.ts +32 -0
  56. package/dist/errors.d.ts +12 -0
  57. package/dist/federation/tokenStore.d.ts +29 -0
  58. package/dist/fga/config.d.ts +53 -0
  59. package/dist/fga/inMemoryStores.d.ts +3 -0
  60. package/dist/fga/postgresStores.d.ts +116 -0
  61. package/dist/fga/redisCheckCache.d.ts +11 -0
  62. package/dist/fga/schema.d.ts +2 -0
  63. package/dist/fga/types.d.ts +28 -0
  64. package/dist/htmx/configuredRoutes.d.ts +542 -0
  65. package/dist/htmx/renderers.d.ts +8 -0
  66. package/dist/htmx/routes.d.ts +514 -0
  67. package/dist/htmx/types.d.ts +129 -0
  68. package/dist/linkedProviders/inMemoryStores.d.ts +9 -0
  69. package/dist/linkedProviders/neonStores.d.ts +484 -0
  70. package/dist/linkedProviders/oauthAccountResolver.d.ts +28 -0
  71. package/dist/linkedProviders/oauthResolver.d.ts +9 -0
  72. package/dist/linkedProviders/resolver.d.ts +22 -0
  73. package/dist/lockout/config.d.ts +17 -0
  74. package/dist/lockout/inMemoryLockoutStore.d.ts +2 -0
  75. package/dist/lockout/postgresLockoutStore.d.ts +71 -0
  76. package/dist/lockout/redisLockoutStore.d.ts +3 -0
  77. package/dist/lockout/types.d.ts +12 -0
  78. package/dist/mfa/backupCodes.d.ts +5 -0
  79. package/dist/mfa/challenge.d.ts +70 -0
  80. package/dist/mfa/config.d.ts +50 -0
  81. package/dist/mfa/gate.d.ts +2 -0
  82. package/dist/mfa/inMemoryMfaStore.d.ts +2 -0
  83. package/dist/mfa/management.d.ts +106 -0
  84. package/dist/mfa/postgresMfaStore.d.ts +206 -0
  85. package/dist/mfa/rotation.d.ts +17 -0
  86. package/dist/mfa/routes.d.ts +234 -0
  87. package/dist/mfa/secret.d.ts +2 -0
  88. package/dist/mfa/sms.d.ts +105 -0
  89. package/dist/mfa/totp.d.ts +91 -0
  90. package/dist/mfa/types.d.ts +23 -0
  91. package/dist/migrations/generate.d.ts +2 -0
  92. package/dist/migrations/index.d.ts +5 -0
  93. package/dist/migrations/runner.d.ts +13 -0
  94. package/dist/migrations/types.d.ts +14 -0
  95. package/dist/oidc/clientAuth.d.ts +19 -0
  96. package/dist/oidc/clientIdMetadata.d.ts +32 -0
  97. package/dist/oidc/config.d.ts +296 -0
  98. package/dist/oidc/dpop.d.ts +23 -0
  99. package/dist/oidc/inMemoryStores.d.ts +11 -0
  100. package/dist/oidc/inMemoryVciStores.d.ts +3 -0
  101. package/dist/oidc/jar.d.ts +14 -0
  102. package/dist/oidc/keys.d.ts +35 -0
  103. package/dist/oidc/logout.d.ts +38 -0
  104. package/dist/oidc/mtls.d.ts +11 -0
  105. package/dist/oidc/par.d.ts +28 -0
  106. package/dist/oidc/postgresStores.d.ts +1217 -0
  107. package/dist/oidc/registration.d.ts +138 -0
  108. package/dist/oidc/routes.d.ts +569 -0
  109. package/dist/oidc/types.d.ts +148 -0
  110. package/dist/oidc/userinfo.d.ts +21 -0
  111. package/dist/oidc/vci.d.ts +159 -0
  112. package/dist/oidc/vciRoutes.d.ts +92 -0
  113. package/dist/organizations/config.d.ts +46 -0
  114. package/dist/organizations/inMemoryOrganizationStore.d.ts +2 -0
  115. package/dist/organizations/operations.d.ts +39 -0
  116. package/dist/organizations/postgresOrganizationStore.d.ts +340 -0
  117. package/dist/organizations/routes.d.ts +299 -0
  118. package/dist/organizations/types.d.ts +45 -0
  119. package/dist/passwordless/config.d.ts +43 -0
  120. package/dist/passwordless/inMemoryPasswordlessTokenStore.d.ts +2 -0
  121. package/dist/passwordless/postgresPasswordlessTokenStore.d.ts +56 -0
  122. package/dist/passwordless/routes.d.ts +163 -0
  123. package/dist/passwordless/types.d.ts +9 -0
  124. package/dist/pluginIdentity.d.ts +2 -0
  125. package/dist/portal/config.d.ts +34 -0
  126. package/dist/portal/inMemorySetupSessionStore.d.ts +2 -0
  127. package/dist/portal/operations.d.ts +10 -0
  128. package/dist/portal/postgresSetupSessionStore.d.ts +116 -0
  129. package/dist/portal/routes.d.ts +160 -0
  130. package/dist/portal/types.d.ts +16 -0
  131. package/dist/providers/clients.d.ts +1818 -0
  132. package/dist/providersFromEnv.d.ts +19 -0
  133. package/dist/roles/config.d.ts +27 -0
  134. package/dist/roles/inMemoryRoleStore.d.ts +2 -0
  135. package/dist/roles/operations.d.ts +8 -0
  136. package/dist/roles/postgresRoleStore.d.ts +86 -0
  137. package/dist/roles/resolver.d.ts +17 -0
  138. package/dist/roles/routes.d.ts +106 -0
  139. package/dist/roles/types.d.ts +14 -0
  140. package/dist/routes/authorize.d.ts +102 -0
  141. package/dist/routes/callback.d.ts +64 -0
  142. package/dist/routes/profile.d.ts +70 -0
  143. package/dist/routes/protectRoute.d.ts +51 -0
  144. package/dist/routes/refresh.d.ts +74 -0
  145. package/dist/routes/revoke.d.ts +73 -0
  146. package/dist/routes/sessions.d.ts +103 -0
  147. package/dist/routes/signout.d.ts +70 -0
  148. package/dist/routes/stepUp.d.ts +48 -0
  149. package/dist/routes/userStatus.d.ts +72 -0
  150. package/dist/scim/config.d.ts +57 -0
  151. package/dist/scim/extensions.d.ts +30 -0
  152. package/dist/scim/inMemoryScimTokenStore.d.ts +2 -0
  153. package/dist/scim/postgresScimTokenStore.d.ts +86 -0
  154. package/dist/scim/routes.d.ts +366 -0
  155. package/dist/scim/serialize.d.ts +83 -0
  156. package/dist/scim/types.d.ts +54 -0
  157. package/dist/session/access.d.ts +33 -0
  158. package/dist/session/anonymous.d.ts +12 -0
  159. package/dist/session/cleanup.d.ts +45 -0
  160. package/dist/session/impersonation.d.ts +34 -0
  161. package/dist/session/inMemoryStore.d.ts +7 -0
  162. package/dist/session/multiSession.d.ts +27 -0
  163. package/dist/session/neonStore.d.ts +513 -0
  164. package/dist/session/promote.d.ts +23 -0
  165. package/dist/session/redisStore.d.ts +6 -0
  166. package/dist/session/sessionsConfig.d.ts +9 -0
  167. package/dist/session/state.d.ts +33 -0
  168. package/dist/session/types.d.ts +21 -0
  169. package/dist/session/userSessions.d.ts +19 -0
  170. package/dist/sso/config.d.ts +149 -0
  171. package/dist/sso/discoveryRoute.d.ts +63 -0
  172. package/dist/sso/inMemorySamlServiceProviderStore.d.ts +2 -0
  173. package/dist/sso/inMemorySsoConnectionStore.d.ts +2 -0
  174. package/dist/sso/oidcRoutes.d.ts +98 -0
  175. package/dist/sso/postgresSamlServiceProviderStore.d.ts +101 -0
  176. package/dist/sso/postgresSsoConnectionStore.d.ts +116 -0
  177. package/dist/sso/samlIdpRoutes.d.ts +139 -0
  178. package/dist/sso/samlRoutes.d.ts +179 -0
  179. package/dist/sso/types.d.ts +53 -0
  180. package/dist/stores/postgres.d.ts +5 -0
  181. package/dist/stores/redis.d.ts +5 -0
  182. package/dist/telemetry/tracing.d.ts +15 -0
  183. package/dist/tenancy.d.ts +9 -0
  184. package/dist/typeGuards.d.ts +6 -0
  185. package/dist/typebox.d.ts +4 -0
  186. package/dist/types.d.ts +421 -0
  187. package/dist/utils.d.ts +45 -0
  188. package/dist/vault/config.d.ts +20 -0
  189. package/dist/vault/inMemoryVaultStore.d.ts +2 -0
  190. package/dist/vault/postgresVaultStore.d.ts +86 -0
  191. package/dist/vault/types.d.ts +14 -0
  192. package/dist/vc/inMemoryVpStores.d.ts +2 -0
  193. package/dist/vc/openid4vp.d.ts +82 -0
  194. package/dist/vc/postgresVcStores.d.ts +300 -0
  195. package/dist/vc/sdJwt.d.ts +37 -0
  196. package/dist/vc/statusList.d.ts +29 -0
  197. package/dist/vc/statusListRoutes.d.ts +63 -0
  198. package/dist/vc/vpRoutes.d.ts +120 -0
  199. package/dist/webauthn/adapter.d.ts +59 -0
  200. package/dist/webauthn/config.d.ts +36 -0
  201. package/dist/webauthn/inMemoryWebAuthnCredentialStore.d.ts +2 -0
  202. package/dist/webauthn/postgresWebAuthnCredentialStore.d.ts +146 -0
  203. package/dist/webauthn/routes.d.ts +155 -0
  204. package/dist/webauthn/types.d.ts +17 -0
  205. package/dist/webhooks/config.d.ts +34 -0
  206. package/dist/webhooks/dispatcher.d.ts +3 -0
  207. package/dist/webhooks/inMemoryStore.d.ts +2 -0
  208. package/dist/webhooks/postgresStore.d.ts +116 -0
  209. package/dist/webhooks/sign.d.ts +11 -0
  210. package/dist/webhooks/types.d.ts +25 -0
  211. package/package.json +3 -3
@@ -0,0 +1,11 @@
1
+ import type { AbuseContext } from './config';
2
+ export declare const verifyHcaptcha: ({ secret }: {
3
+ secret: string;
4
+ }) => (token: string | undefined, context: AbuseContext) => Promise<boolean>;
5
+ export declare const verifyRecaptcha: ({ minScore, secret }: {
6
+ minScore?: number;
7
+ secret: string;
8
+ }) => (token: string | undefined, context: AbuseContext) => Promise<boolean>;
9
+ export declare const verifyTurnstile: ({ secret }: {
10
+ secret: string;
11
+ }) => (token: string | undefined, context: AbuseContext) => Promise<boolean>;
@@ -0,0 +1,29 @@
1
+ export type AbuseAction = 'allow' | 'challenge' | 'deny';
2
+ export type AbuseSignal = 'blocked_ip' | 'bot' | 'captcha_failed' | 'not_allowlisted';
3
+ export type BotClass = 'agent' | 'bot' | 'crawler' | 'human';
4
+ export type AbuseContext = {
5
+ captchaToken?: string;
6
+ ip?: string;
7
+ userAgent?: string;
8
+ };
9
+ export type AbuseReason = {
10
+ action: AbuseAction;
11
+ signal: AbuseSignal;
12
+ };
13
+ export type AbuseAssessment = {
14
+ action: AbuseAction;
15
+ reasons: AbuseReason[];
16
+ };
17
+ export type AbuseConfig = {
18
+ botAction?: AbuseAction;
19
+ captchaAction?: AbuseAction;
20
+ classifyBot?: (context: AbuseContext) => BotClass | Promise<BotClass>;
21
+ ipAllow?: string[];
22
+ ipDeny?: string[];
23
+ verifyCaptcha?: (token: string | undefined, context: AbuseContext) => boolean | Promise<boolean>;
24
+ };
25
+ export declare const assessAbuse: (config: AbuseConfig, context: AbuseContext) => Promise<AbuseAssessment>;
26
+ export declare const createAbuseGuard: (config: AbuseConfig) => {
27
+ assess: (context: AbuseContext) => Promise<AbuseAssessment>;
28
+ };
29
+ export declare const defaultBotClassifier: (context: AbuseContext) => "bot" | "crawler" | "human";
@@ -0,0 +1,27 @@
1
+ export type AuthEventName = 'postLogin' | 'postLogout' | 'postMfa' | 'postOauthCallback' | 'postRegister' | 'preLogin' | 'preRegister';
2
+ export type AuthActionContext<UserType> = {
3
+ email?: string;
4
+ event: AuthEventName;
5
+ ip?: string;
6
+ metadata?: Record<string, unknown>;
7
+ user?: UserType;
8
+ userAgent?: string;
9
+ };
10
+ export type AuthActionResult = {
11
+ kind: 'deny';
12
+ reason: string;
13
+ } | {
14
+ kind: 'pass';
15
+ } | {
16
+ kind: 'redirect';
17
+ url: string;
18
+ };
19
+ export type AuthAction<UserType> = {
20
+ event: AuthEventName | AuthEventName[];
21
+ handler: (context: AuthActionContext<UserType>) => AuthActionResult | Promise<AuthActionResult>;
22
+ name: string;
23
+ };
24
+ export type AuthPipeline<UserType> = {
25
+ run: (event: AuthEventName, context: Omit<AuthActionContext<UserType>, 'event'>) => Promise<AuthActionResult>;
26
+ };
27
+ export declare const createActionPipeline: <UserType>(actions: AuthAction<UserType>[]) => AuthPipeline<UserType>;
@@ -0,0 +1,34 @@
1
+ import type { KnownDeviceStore, LoginHistoryStore, RiskAction, RiskAssessment, RiskContext, RiskSignal, RiskThresholds, RiskWeights, WeightedRiskAssessment } from './types';
2
+ export type AdaptiveConfig = {
3
+ historyLimit?: number;
4
+ knownDeviceStore: KnownDeviceStore;
5
+ loginHistoryStore: LoginHistoryStore;
6
+ maxTravelKmh?: number;
7
+ offHours?: {
8
+ end: number;
9
+ start: number;
10
+ };
11
+ rules?: Partial<Record<RiskSignal, RiskAction>>;
12
+ velocityMaxAttempts?: number;
13
+ velocityWindowMs?: number;
14
+ };
15
+ export declare const assessRisk: (config: AdaptiveConfig, context: RiskContext) => Promise<RiskAssessment>;
16
+ export declare const createRiskEngine: (config: AdaptiveConfig) => {
17
+ assessRisk: (context: RiskContext) => Promise<RiskAssessment>;
18
+ recordAttempt: (context: RiskContext & {
19
+ outcome: RiskAction;
20
+ }) => Promise<void>;
21
+ scoreRisk: (context: RiskContext, options?: {
22
+ thresholds?: RiskThresholds;
23
+ weights?: RiskWeights;
24
+ }) => Promise<WeightedRiskAssessment>;
25
+ trustDevice: (userId: string, deviceId: string, label?: string) => Promise<void>;
26
+ };
27
+ export declare const recordLoginAttempt: (config: AdaptiveConfig, context: RiskContext & {
28
+ outcome: RiskAction;
29
+ }) => Promise<void>;
30
+ export declare const scoreRisk: (config: AdaptiveConfig & {
31
+ thresholds?: RiskThresholds;
32
+ weights?: RiskWeights;
33
+ }, context: RiskContext) => Promise<WeightedRiskAssessment>;
34
+ export declare const trustDevice: (config: AdaptiveConfig, userId: string, deviceId: string, label?: string) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ export type DeviceSignals = Record<string, unknown>;
2
+ export declare const fingerprintDevice: (signals: DeviceSignals) => Promise<string>;
@@ -0,0 +1,3 @@
1
+ import type { KnownDeviceStore, LoginHistoryStore } from './types';
2
+ export declare const createInMemoryKnownDeviceStore: () => KnownDeviceStore;
3
+ export declare const createInMemoryLoginHistoryStore: () => LoginHistoryStore;
@@ -0,0 +1,245 @@
1
+ import { type AnyPgDatabase } from '../stores/postgres';
2
+ import type { KnownDeviceStore, LoginHistoryStore } from './types';
3
+ export declare const knownDevicesTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
4
+ name: "auth_known_devices";
5
+ schema: undefined;
6
+ columns: {
7
+ device_id: import("drizzle-orm/pg-core").PgBuildColumn<"auth_known_devices", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
8
+ name: string;
9
+ tableName: "auth_known_devices";
10
+ dataType: "string";
11
+ data: string;
12
+ driverParam: string;
13
+ notNull: true;
14
+ hasDefault: false;
15
+ isPrimaryKey: false;
16
+ isAutoincrement: false;
17
+ hasRuntimeDefault: false;
18
+ enumValues: undefined;
19
+ identity: undefined;
20
+ generated: undefined;
21
+ }>;
22
+ first_seen_at_ms: import("drizzle-orm/pg-core").PgBuildColumn<"auth_known_devices", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBigInt53Builder>, {
23
+ name: string;
24
+ tableName: "auth_known_devices";
25
+ dataType: "number int53";
26
+ data: number;
27
+ driverParam: string | number;
28
+ notNull: true;
29
+ hasDefault: false;
30
+ isPrimaryKey: false;
31
+ isAutoincrement: false;
32
+ hasRuntimeDefault: false;
33
+ enumValues: undefined;
34
+ identity: undefined;
35
+ generated: undefined;
36
+ }>;
37
+ label: import("drizzle-orm/pg-core").PgBuildColumn<"auth_known_devices", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
38
+ name: string;
39
+ tableName: "auth_known_devices";
40
+ dataType: "string";
41
+ data: string;
42
+ driverParam: string;
43
+ notNull: false;
44
+ hasDefault: false;
45
+ isPrimaryKey: false;
46
+ isAutoincrement: false;
47
+ hasRuntimeDefault: false;
48
+ enumValues: undefined;
49
+ identity: undefined;
50
+ generated: undefined;
51
+ }>;
52
+ last_seen_at_ms: import("drizzle-orm/pg-core").PgBuildColumn<"auth_known_devices", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBigInt53Builder>, {
53
+ name: string;
54
+ tableName: "auth_known_devices";
55
+ dataType: "number int53";
56
+ data: number;
57
+ driverParam: string | number;
58
+ notNull: true;
59
+ hasDefault: false;
60
+ isPrimaryKey: false;
61
+ isAutoincrement: false;
62
+ hasRuntimeDefault: false;
63
+ enumValues: undefined;
64
+ identity: undefined;
65
+ generated: undefined;
66
+ }>;
67
+ trusted: import("drizzle-orm/pg-core").PgBuildColumn<"auth_known_devices", import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBooleanBuilder>>, {
68
+ name: string;
69
+ tableName: "auth_known_devices";
70
+ dataType: "boolean";
71
+ data: boolean;
72
+ driverParam: boolean;
73
+ notNull: true;
74
+ hasDefault: true;
75
+ isPrimaryKey: false;
76
+ isAutoincrement: false;
77
+ hasRuntimeDefault: false;
78
+ enumValues: undefined;
79
+ identity: undefined;
80
+ generated: undefined;
81
+ }>;
82
+ user_id: import("drizzle-orm/pg-core").PgBuildColumn<"auth_known_devices", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
83
+ name: string;
84
+ tableName: "auth_known_devices";
85
+ dataType: "string";
86
+ data: string;
87
+ driverParam: string;
88
+ notNull: true;
89
+ hasDefault: false;
90
+ isPrimaryKey: false;
91
+ isAutoincrement: false;
92
+ hasRuntimeDefault: false;
93
+ enumValues: undefined;
94
+ identity: undefined;
95
+ generated: undefined;
96
+ }>;
97
+ };
98
+ dialect: "pg";
99
+ }>;
100
+ export declare const loginHistoryTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
101
+ name: "auth_login_history";
102
+ schema: undefined;
103
+ columns: {
104
+ attempt_id: import("drizzle-orm/pg-core").PgBuildColumn<"auth_login_history", import("drizzle-orm/pg-core").SetIsPrimaryKey<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
105
+ name: string;
106
+ tableName: "auth_login_history";
107
+ dataType: "string";
108
+ data: string;
109
+ driverParam: string;
110
+ notNull: true;
111
+ hasDefault: false;
112
+ isPrimaryKey: false;
113
+ isAutoincrement: false;
114
+ hasRuntimeDefault: false;
115
+ enumValues: undefined;
116
+ identity: undefined;
117
+ generated: undefined;
118
+ }>;
119
+ country: import("drizzle-orm/pg-core").PgBuildColumn<"auth_login_history", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
120
+ name: string;
121
+ tableName: "auth_login_history";
122
+ dataType: "string";
123
+ data: string;
124
+ driverParam: string;
125
+ notNull: false;
126
+ hasDefault: false;
127
+ isPrimaryKey: false;
128
+ isAutoincrement: false;
129
+ hasRuntimeDefault: false;
130
+ enumValues: undefined;
131
+ identity: undefined;
132
+ generated: undefined;
133
+ }>;
134
+ device_id: import("drizzle-orm/pg-core").PgBuildColumn<"auth_login_history", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
135
+ name: string;
136
+ tableName: "auth_login_history";
137
+ dataType: "string";
138
+ data: string;
139
+ driverParam: string;
140
+ notNull: true;
141
+ hasDefault: false;
142
+ isPrimaryKey: false;
143
+ isAutoincrement: false;
144
+ hasRuntimeDefault: false;
145
+ enumValues: undefined;
146
+ identity: undefined;
147
+ generated: undefined;
148
+ }>;
149
+ ip_address: import("drizzle-orm/pg-core").PgBuildColumn<"auth_login_history", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
150
+ name: string;
151
+ tableName: "auth_login_history";
152
+ dataType: "string";
153
+ data: string;
154
+ driverParam: string;
155
+ notNull: false;
156
+ hasDefault: false;
157
+ isPrimaryKey: false;
158
+ isAutoincrement: false;
159
+ hasRuntimeDefault: false;
160
+ enumValues: undefined;
161
+ identity: undefined;
162
+ generated: undefined;
163
+ }>;
164
+ latitude: import("drizzle-orm/pg-core").PgBuildColumn<"auth_login_history", import("drizzle-orm/pg-core").PgDoublePrecisionBuilder, {
165
+ name: string;
166
+ tableName: "auth_login_history";
167
+ dataType: "number double";
168
+ data: number;
169
+ driverParam: string | number;
170
+ notNull: false;
171
+ hasDefault: false;
172
+ isPrimaryKey: false;
173
+ isAutoincrement: false;
174
+ hasRuntimeDefault: false;
175
+ enumValues: undefined;
176
+ identity: undefined;
177
+ generated: undefined;
178
+ }>;
179
+ longitude: import("drizzle-orm/pg-core").PgBuildColumn<"auth_login_history", import("drizzle-orm/pg-core").PgDoublePrecisionBuilder, {
180
+ name: string;
181
+ tableName: "auth_login_history";
182
+ dataType: "number double";
183
+ data: number;
184
+ driverParam: string | number;
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
+ outcome: import("drizzle-orm/pg-core").PgBuildColumn<"auth_login_history", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
195
+ name: string;
196
+ tableName: "auth_login_history";
197
+ dataType: "string";
198
+ data: string;
199
+ driverParam: string;
200
+ notNull: true;
201
+ hasDefault: false;
202
+ isPrimaryKey: false;
203
+ isAutoincrement: false;
204
+ hasRuntimeDefault: false;
205
+ enumValues: undefined;
206
+ identity: undefined;
207
+ generated: undefined;
208
+ }>;
209
+ timestamp_ms: import("drizzle-orm/pg-core").PgBuildColumn<"auth_login_history", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBigInt53Builder>, {
210
+ name: string;
211
+ tableName: "auth_login_history";
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
+ user_id: import("drizzle-orm/pg-core").PgBuildColumn<"auth_login_history", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
225
+ name: string;
226
+ tableName: "auth_login_history";
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
+ };
240
+ dialect: "pg";
241
+ }>;
242
+ export declare const createNeonKnownDeviceStore: (databaseUrl: string) => KnownDeviceStore;
243
+ export declare const createNeonLoginHistoryStore: (databaseUrl: string) => LoginHistoryStore;
244
+ export declare const createPostgresKnownDeviceStore: <DB extends AnyPgDatabase>(db: DB) => KnownDeviceStore;
245
+ export declare const createPostgresLoginHistoryStore: <DB extends AnyPgDatabase>(db: DB) => LoginHistoryStore;
@@ -0,0 +1,62 @@
1
+ export type RiskAction = 'allow' | 'deny' | 'step_up';
2
+ export type RiskSignal = 'impossible_travel' | 'new_country' | 'new_device' | 'off_hours' | 'proxy' | 'velocity';
3
+ export type GeoPoint = {
4
+ country?: string;
5
+ latitude?: number;
6
+ longitude?: number;
7
+ };
8
+ export type RiskContext = {
9
+ deviceId: string;
10
+ geo?: GeoPoint;
11
+ ipAddress?: string;
12
+ isProxy?: boolean;
13
+ localHour?: number;
14
+ now?: number;
15
+ userId: string;
16
+ };
17
+ export type RiskReason = {
18
+ action: RiskAction;
19
+ signal: RiskSignal;
20
+ };
21
+ export type RiskAssessment = {
22
+ action: RiskAction;
23
+ reasons: RiskReason[];
24
+ };
25
+ export type RiskWeights = Partial<Record<RiskSignal, number>>;
26
+ export type RiskThresholds = {
27
+ deny: number;
28
+ stepUp: number;
29
+ };
30
+ export type WeightedRiskAssessment = {
31
+ action: RiskAction;
32
+ reasons: RiskReason[];
33
+ score: number;
34
+ };
35
+ export type KnownDevice = {
36
+ deviceId: string;
37
+ firstSeenAt: number;
38
+ label?: string;
39
+ lastSeenAt: number;
40
+ trusted: boolean;
41
+ userId: string;
42
+ };
43
+ export type KnownDeviceStore = {
44
+ findDevice: (userId: string, deviceId: string) => Promise<KnownDevice | undefined>;
45
+ listDevices: (userId: string) => Promise<KnownDevice[]>;
46
+ saveDevice: (device: KnownDevice) => Promise<void>;
47
+ };
48
+ export type LoginAttempt = {
49
+ attemptId: string;
50
+ country?: string;
51
+ deviceId: string;
52
+ ipAddress?: string;
53
+ latitude?: number;
54
+ longitude?: number;
55
+ outcome: RiskAction;
56
+ timestamp: number;
57
+ userId: string;
58
+ };
59
+ export type LoginHistoryStore = {
60
+ listRecent: (userId: string, limit: number) => Promise<LoginAttempt[]>;
61
+ recordAttempt: (attempt: LoginAttempt) => Promise<void>;
62
+ };
@@ -0,0 +1,44 @@
1
+ import type { RouteString } from '../types';
2
+ import type { AgentCredentialVerifier, AgentDelegationStore, AgentRegistrationStore } from './types';
3
+ import type { AgentRegistrationProtocolConfig } from './registration';
4
+ export declare const DEFAULT_AGENT_RESOURCE_METADATA_ROUTE: RouteString;
5
+ export type AgentRegistrationDiscoveryMetadata = {
6
+ claim_endpoint: string;
7
+ identity_assertion: {
8
+ assertion_types_supported: string[];
9
+ };
10
+ identity_endpoint: string;
11
+ identity_types_supported: string[];
12
+ skill: string;
13
+ };
14
+ export type AgentAuthConfig = {
15
+ /** Permit registered agents to authenticate without a user delegation. Secure
16
+ * default is false; enable for machine-only resources. */
17
+ allowUndelegated?: boolean;
18
+ /** Open auth.md agent-registration support. Implemented natively by Absolute
19
+ * Auth and projected through OAuth discovery; no WorkOS service is required. */
20
+ agentRegistration?: AgentRegistrationProtocolConfig;
21
+ authorizationServer: string;
22
+ delegationStore: AgentDelegationStore;
23
+ logoUri?: string;
24
+ metadataRoute?: RouteString;
25
+ /** Authorization-server route prefix. Defaults to `/oauth2`; used to derive
26
+ * the authoritative token endpoint advertised by the generated guide. */
27
+ oidcRoute?: RouteString;
28
+ registrationStore: AgentRegistrationStore;
29
+ /** Treat clients created through RFC 7591 DCR as agent registrations. Explicitly
30
+ * opt-in because a deployment may also use DCR for ordinary relying parties. */
31
+ registerDynamicClients?: boolean;
32
+ resource: string;
33
+ resourceName?: string;
34
+ scopes: string[];
35
+ verifyCredential: AgentCredentialVerifier;
36
+ };
37
+ export declare const agentProtectedResourceMetadata: (config: Pick<AgentAuthConfig, "authorizationServer" | "logoUri" | "resource" | "resourceName" | "scopes">) => {
38
+ resource: string;
39
+ scopes_supported: string[];
40
+ resource_name?: string | undefined;
41
+ resource_logo_uri?: string | undefined;
42
+ authorization_servers: string[];
43
+ bearer_methods_supported: string[];
44
+ };
@@ -0,0 +1,46 @@
1
+ import { Elysia } from 'elysia';
2
+ import { type AgentAuthConfig } from './config';
3
+ import type { AgentPrincipal } from './types';
4
+ type AgentAuthFailure = {
5
+ code: 'Forbidden' | 'Unauthorized';
6
+ message: 'Agent is not authenticated' | 'Insufficient agent scopes';
7
+ };
8
+ export declare const agentAuthChallenge: ({ config, error, requiredScopes }: {
9
+ config: AgentAuthConfig;
10
+ error?: "invalid_token" | "insufficient_scope";
11
+ requiredScopes?: string[];
12
+ }) => string;
13
+ export declare const agentResourceMetadataUrl: (config: AgentAuthConfig) => string;
14
+ export declare const agentAuthContextPlugin: (config?: AgentAuthConfig) => Elysia<"", {
15
+ decorator: {};
16
+ store: {};
17
+ derive: {
18
+ readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
19
+ };
20
+ resolve: {};
21
+ }, {
22
+ typebox: {};
23
+ error: {};
24
+ }, {
25
+ schema: {};
26
+ standaloneSchema: {};
27
+ macro: {};
28
+ macroFn: {};
29
+ parser: {};
30
+ response: import("elysia").ExtractErrorFromHandle<{
31
+ readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
32
+ }>;
33
+ }, {}, {
34
+ derive: {};
35
+ resolve: {};
36
+ schema: {};
37
+ standaloneSchema: {};
38
+ response: {};
39
+ }, {
40
+ derive: {};
41
+ resolve: {};
42
+ schema: {};
43
+ standaloneSchema: {};
44
+ response: {};
45
+ }>;
46
+ export {};
@@ -0,0 +1,49 @@
1
+ import { type SigningKey } from '../oidc/keys';
2
+ import type { VerifiedAgentIdentityAssertion } from './types';
3
+ export type AgentIdentityAssertionJtiStore = {
4
+ /** Atomically records an issuer+jti pair. Returns false for a replay. */
5
+ recordIfFresh: (issuer: string, jti: string, expiresAt: number) => Promise<boolean>;
6
+ };
7
+ export declare const createInMemoryAgentIdentityAssertionJtiStore: () => AgentIdentityAssertionJtiStore;
8
+ export type AgentIdentityAssertionUser = {
9
+ authenticatedAt: number;
10
+ email?: string;
11
+ emailVerified?: boolean;
12
+ methods?: string[];
13
+ name?: string;
14
+ phoneNumber?: string;
15
+ phoneNumberVerified?: boolean;
16
+ subject: string;
17
+ };
18
+ /** Native provider-side ID-JAG issuance. The caller owns the user consent UI
19
+ * and must authorize the requested audience before invoking this helper. */
20
+ export declare const issueAgentIdentityAssertion: ({ agentContextId, agentPlatform, audience, clientId, issuer, now, resource, signingKey, ttlMs, user }: {
21
+ agentContextId?: string;
22
+ agentPlatform?: string;
23
+ audience: string;
24
+ clientId: string;
25
+ issuer: string;
26
+ now?: number;
27
+ resource?: string;
28
+ signingKey: SigningKey;
29
+ ttlMs?: number;
30
+ user: AgentIdentityAssertionUser;
31
+ }) => Promise<{
32
+ assertion: string;
33
+ assertionType: "urn:ietf:params:oauth:token-type:id-jag";
34
+ expiresAt: number;
35
+ }>;
36
+ /** Builds a fail-closed service-side verifier. Issuer resolution is injected so
37
+ * the application can use pinned configuration, CIMD, or an egress-guarded
38
+ * JWKS resolver without this package performing ambient network access. */
39
+ export declare const createAgentIdentityAssertionVerifier: ({ audience, clockSkewMs, jtiStore, maxAssertionLifetimeMs, maxAuthenticationAgeMs, resolveIssuer }: {
40
+ audience: string;
41
+ clockSkewMs?: number;
42
+ jtiStore: AgentIdentityAssertionJtiStore;
43
+ maxAssertionLifetimeMs?: number;
44
+ maxAuthenticationAgeMs?: number;
45
+ resolveIssuer: (issuer: string) => Promise<{
46
+ allowedClientIds?: string[];
47
+ publicJwk: JsonWebKey;
48
+ } | undefined>;
49
+ }) => (assertion: string, now?: number) => Promise<VerifiedAgentIdentityAssertion | undefined>;
@@ -0,0 +1,4 @@
1
+ import type { AgentDelegationStore, AgentIdentityRegistrationStore, AgentRegistrationStore } from './types';
2
+ export declare const createInMemoryAgentDelegationStore: () => AgentDelegationStore;
3
+ export declare const createInMemoryAgentIdentityRegistrationStore: () => AgentIdentityRegistrationStore;
4
+ export declare const createInMemoryAgentRegistrationStore: () => AgentRegistrationStore;
@@ -0,0 +1,12 @@
1
+ import type { AgentCredentialVerifier } from './types';
2
+ /** Adapter for Absolute Auth's RFC 9068-style JWT access tokens. It validates
3
+ * signature, issuer, audience, expiry, and extracts the OAuth client as the
4
+ * agent identity while retaining `sub` as the authorizing user. */
5
+ export declare const createOidcAgentCredentialVerifier: ({ issuer, isUsedDpopJti, maxDpopAgeMs, publicJwk, requireDpop, resource }: {
6
+ issuer: string;
7
+ isUsedDpopJti?: (jti: string) => boolean | Promise<boolean>;
8
+ maxDpopAgeMs?: number;
9
+ publicJwk: JsonWebKey;
10
+ requireDpop?: boolean;
11
+ resource: string;
12
+ }) => AgentCredentialVerifier;