@absolutejs/auth 0.65.1 → 0.65.3
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/dist/abuse/captcha.d.ts +11 -0
- package/dist/abuse/config.d.ts +29 -0
- package/dist/actions.d.ts +27 -0
- package/dist/adaptive/config.d.ts +34 -0
- package/dist/adaptive/fingerprint.d.ts +2 -0
- package/dist/adaptive/inMemoryStores.d.ts +3 -0
- package/dist/adaptive/postgresStores.d.ts +245 -0
- package/dist/adaptive/types.d.ts +62 -0
- package/dist/agents/config.d.ts +49 -0
- package/dist/agents/context.d.ts +46 -0
- package/dist/agents/idJag.d.ts +49 -0
- package/dist/agents/inMemoryStores.d.ts +4 -0
- package/dist/agents/index.d.ts +13 -0
- package/dist/agents/oauthGuide.d.ts +18 -0
- package/dist/agents/oidcAdapter.d.ts +20 -0
- package/dist/agents/postgresStores.d.ts +1176 -0
- package/dist/agents/principal.d.ts +4 -0
- package/dist/agents/registration.d.ts +162 -0
- package/dist/agents/registrationClient.d.ts +50 -0
- package/dist/agents/routes.d.ts +256 -0
- package/dist/agents/types.d.ts +129 -0
- package/dist/apikeys/config.d.ts +64 -0
- package/dist/apikeys/inMemoryStores.d.ts +4 -0
- package/dist/apikeys/postgresStores.d.ts +359 -0
- package/dist/apikeys/routes.d.ts +83 -0
- package/dist/apikeys/types.d.ts +53 -0
- package/dist/audit/config.d.ts +9 -0
- package/dist/audit/export.d.ts +2 -0
- package/dist/audit/inMemoryAuditStore.d.ts +2 -0
- package/dist/audit/integrity.d.ts +19 -0
- package/dist/audit/postgresAuditStore.d.ts +116 -0
- package/dist/audit/siem.d.ts +11 -0
- package/dist/audit/types.d.ts +21 -0
- package/dist/audit/wrap.d.ts +11 -0
- package/dist/authContext.d.ts +193 -0
- package/dist/authorization/config.d.ts +19 -0
- package/dist/authorization/protectPermission.d.ts +52 -0
- package/dist/cli/import/auth0.d.ts +2 -0
- package/dist/cli/import/clerk.d.ts +2 -0
- package/dist/cli/import/index.d.ts +10 -0
- package/dist/cli/import/lucia.d.ts +2 -0
- package/dist/cli/import/nextauth.d.ts +2 -0
- package/dist/cli/import/supabase.d.ts +2 -0
- package/dist/cli/import/types.d.ts +27 -0
- package/dist/cli/migrate.d.ts +2 -0
- package/dist/cli/migrate.js.map +2 -2
- package/dist/client/components/react/SignIn.d.ts +32 -0
- package/dist/client/components/react/SignUp.d.ts +29 -0
- package/dist/client/components/react/UserButton.d.ts +36 -0
- package/dist/client/createAuthClient.d.ts +285 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/passkeyHelpers.d.ts +19 -0
- package/dist/client/react.d.ts +87 -0
- package/dist/client/sessionExpiry.d.ts +37 -0
- package/dist/client/solid.d.ts +86 -0
- package/dist/client/svelte.d.ts +86 -0
- package/dist/client/vue.d.ts +88 -0
- package/dist/compliance/cipher.d.ts +11 -0
- package/dist/compliance/config.d.ts +18 -0
- package/dist/compliance/redaction.d.ts +8 -0
- package/dist/compliance/routes.d.ts +89 -0
- package/dist/constants.d.ts +10 -0
- package/dist/credentials/backgroundOps.d.ts +45 -0
- package/dist/credentials/config.d.ts +94 -0
- package/dist/credentials/emailValidation.d.ts +9 -0
- package/dist/credentials/emailVerification.d.ts +83 -0
- package/dist/credentials/import.d.ts +49 -0
- package/dist/credentials/inMemoryCredentialStore.d.ts +2 -0
- package/dist/credentials/legacyHashers.d.ts +3 -0
- package/dist/credentials/login.d.ts +76 -0
- package/dist/credentials/passwordPolicy.d.ts +15 -0
- package/dist/credentials/passwordReset.d.ts +87 -0
- package/dist/credentials/postgresCredentialStore.d.ts +235 -0
- package/dist/credentials/register.d.ts +54 -0
- package/dist/credentials/routes.d.ts +201 -0
- package/dist/credentials/types.d.ts +26 -0
- package/dist/crypto.d.ts +32 -0
- package/dist/csrf.d.ts +10 -0
- package/dist/errors.d.ts +12 -0
- package/dist/federation/tokenStore.d.ts +29 -0
- package/dist/fga/config.d.ts +53 -0
- package/dist/fga/inMemoryStores.d.ts +3 -0
- package/dist/fga/postgresStores.d.ts +116 -0
- package/dist/fga/redisCheckCache.d.ts +11 -0
- package/dist/fga/schema.d.ts +2 -0
- package/dist/fga/types.d.ts +28 -0
- package/dist/fingerprint-client/index.d.ts +26 -0
- package/dist/htmx/configuredRoutes.d.ts +542 -0
- package/dist/htmx/index.d.ts +2 -0
- package/dist/htmx/renderers.d.ts +8 -0
- package/dist/htmx/routes.d.ts +514 -0
- package/dist/htmx/types.d.ts +129 -0
- package/dist/index.d.ts +3647 -0
- package/dist/index.js +34 -4
- package/dist/index.js.map +7 -6
- package/dist/linkedProviders/inMemoryStores.d.ts +9 -0
- package/dist/linkedProviders/index.d.ts +3 -0
- package/dist/linkedProviders/neonStores.d.ts +484 -0
- package/dist/linkedProviders/oauthAccountResolver.d.ts +28 -0
- package/dist/linkedProviders/oauthResolver.d.ts +9 -0
- package/dist/linkedProviders/resolver.d.ts +22 -0
- package/dist/lockout/config.d.ts +17 -0
- package/dist/lockout/inMemoryLockoutStore.d.ts +2 -0
- package/dist/lockout/postgresLockoutStore.d.ts +71 -0
- package/dist/lockout/redisLockoutStore.d.ts +3 -0
- package/dist/lockout/types.d.ts +12 -0
- package/dist/manifest.d.ts +18 -0
- package/dist/manifest.json +373 -0
- package/dist/mfa/backupCodes.d.ts +5 -0
- package/dist/mfa/challenge.d.ts +72 -0
- package/dist/mfa/config.d.ts +59 -0
- package/dist/mfa/gate.d.ts +2 -0
- package/dist/mfa/inMemoryMfaStore.d.ts +2 -0
- package/dist/mfa/management.d.ts +106 -0
- package/dist/mfa/postgresMfaStore.d.ts +266 -0
- package/dist/mfa/recentAuth.d.ts +2 -0
- package/dist/mfa/rotation.d.ts +17 -0
- package/dist/mfa/routes.d.ts +239 -0
- package/dist/mfa/secret.d.ts +2 -0
- package/dist/mfa/sms.d.ts +143 -0
- package/dist/mfa/totp.d.ts +91 -0
- package/dist/mfa/types.d.ts +58 -0
- package/dist/migrations/generate.d.ts +2 -0
- package/dist/migrations/index.d.ts +6 -0
- package/dist/migrations/runner.d.ts +22 -0
- package/dist/migrations/types.d.ts +14 -0
- package/dist/oidc/clientAuth.d.ts +19 -0
- package/dist/oidc/clientIdMetadata.d.ts +28 -0
- package/dist/oidc/config.d.ts +307 -0
- package/dist/oidc/dpop.d.ts +23 -0
- package/dist/oidc/inMemoryStores.d.ts +11 -0
- package/dist/oidc/inMemoryVciStores.d.ts +3 -0
- package/dist/oidc/index.d.ts +12 -0
- package/dist/oidc/jar.d.ts +14 -0
- package/dist/oidc/keys.d.ts +50 -0
- package/dist/oidc/logout.d.ts +38 -0
- package/dist/oidc/mtls.d.ts +11 -0
- package/dist/oidc/operator.d.ts +14 -0
- package/dist/oidc/par.d.ts +28 -0
- package/dist/oidc/postgresStores.d.ts +1217 -0
- package/dist/oidc/registration.d.ts +138 -0
- package/dist/oidc/routes.d.ts +569 -0
- package/dist/oidc/types.d.ts +157 -0
- package/dist/oidc/userinfo.d.ts +21 -0
- package/dist/oidc/vci.d.ts +159 -0
- package/dist/oidc/vciRoutes.d.ts +92 -0
- package/dist/organizations/config.d.ts +46 -0
- package/dist/organizations/inMemoryOrganizationStore.d.ts +2 -0
- package/dist/organizations/operations.d.ts +39 -0
- package/dist/organizations/postgresOrganizationStore.d.ts +340 -0
- package/dist/organizations/routes.d.ts +299 -0
- package/dist/organizations/types.d.ts +45 -0
- package/dist/passwordless/config.d.ts +43 -0
- package/dist/passwordless/inMemoryPasswordlessTokenStore.d.ts +2 -0
- package/dist/passwordless/postgresPasswordlessTokenStore.d.ts +56 -0
- package/dist/passwordless/routes.d.ts +163 -0
- package/dist/passwordless/types.d.ts +9 -0
- package/dist/pluginIdentity.d.ts +2 -0
- package/dist/plugins/denyDisposableEmail.d.ts +7 -0
- package/dist/plugins/discordAlert.d.ts +7 -0
- package/dist/plugins/geoBlock.d.ts +8 -0
- package/dist/plugins/index.d.ts +12 -0
- package/dist/plugins/pagerdutyAlert.d.ts +9 -0
- package/dist/plugins/posthogIdentify.d.ts +7 -0
- package/dist/plugins/slackAlert.d.ts +7 -0
- package/dist/portal/config.d.ts +34 -0
- package/dist/portal/inMemorySetupSessionStore.d.ts +2 -0
- package/dist/portal/operations.d.ts +10 -0
- package/dist/portal/postgresSetupSessionStore.d.ts +116 -0
- package/dist/portal/routes.d.ts +160 -0
- package/dist/portal/types.d.ts +16 -0
- package/dist/providers/clients.d.ts +1831 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providersFromEnv.d.ts +19 -0
- package/dist/redirect.d.ts +2 -0
- package/dist/roles/config.d.ts +27 -0
- package/dist/roles/inMemoryRoleStore.d.ts +2 -0
- package/dist/roles/operations.d.ts +8 -0
- package/dist/roles/postgresRoleStore.d.ts +86 -0
- package/dist/roles/resolver.d.ts +17 -0
- package/dist/roles/routes.d.ts +106 -0
- package/dist/roles/types.d.ts +14 -0
- package/dist/routes/authorize.d.ts +102 -0
- package/dist/routes/callback.d.ts +64 -0
- package/dist/routes/profile.d.ts +73 -0
- package/dist/routes/protectRoute.d.ts +51 -0
- package/dist/routes/refresh.d.ts +74 -0
- package/dist/routes/requireAuth.d.ts +43 -0
- package/dist/routes/revoke.d.ts +73 -0
- package/dist/routes/sessions.d.ts +103 -0
- package/dist/routes/signout.d.ts +70 -0
- package/dist/routes/stepUp.d.ts +48 -0
- package/dist/routes/userStatus.d.ts +72 -0
- package/dist/saml.d.ts +1 -0
- package/dist/scim/config.d.ts +57 -0
- package/dist/scim/extensions.d.ts +30 -0
- package/dist/scim/inMemoryScimTokenStore.d.ts +2 -0
- package/dist/scim/postgresScimTokenStore.d.ts +86 -0
- package/dist/scim/routes.d.ts +366 -0
- package/dist/scim/serialize.d.ts +83 -0
- package/dist/scim/types.d.ts +54 -0
- package/dist/server.d.ts +34 -0
- package/dist/server.js +32 -4
- package/dist/server.js.map +7 -6
- package/dist/session/access.d.ts +33 -0
- package/dist/session/anonymous.d.ts +12 -0
- package/dist/session/cleanup.d.ts +45 -0
- package/dist/session/cookieReader.d.ts +10 -0
- package/dist/session/impersonation.d.ts +34 -0
- package/dist/session/inMemoryStore.d.ts +7 -0
- package/dist/session/multiSession.d.ts +27 -0
- package/dist/session/neonStore.d.ts +574 -0
- package/dist/session/promote.d.ts +23 -0
- package/dist/session/redisStore.d.ts +6 -0
- package/dist/session/sessionsConfig.d.ts +9 -0
- package/dist/session/state.d.ts +33 -0
- package/dist/session/types.d.ts +23 -0
- package/dist/session/userSessions.d.ts +19 -0
- package/dist/sso/config.d.ts +149 -0
- package/dist/sso/discoveryRoute.d.ts +63 -0
- package/dist/sso/inMemorySamlServiceProviderStore.d.ts +2 -0
- package/dist/sso/inMemorySsoConnectionStore.d.ts +2 -0
- package/dist/sso/nodeSamlAdapter.d.ts +8 -0
- package/dist/sso/oidcRoutes.d.ts +98 -0
- package/dist/sso/postgresSamlServiceProviderStore.d.ts +101 -0
- package/dist/sso/postgresSsoConnectionStore.d.ts +117 -0
- package/dist/sso/samlIdpRoutes.d.ts +139 -0
- package/dist/sso/samlRoutes.d.ts +179 -0
- package/dist/sso/types.d.ts +53 -0
- package/dist/stores/postgres.d.ts +5 -0
- package/dist/stores/redis.d.ts +5 -0
- package/dist/telemetry/tracing.d.ts +15 -0
- package/dist/tenancy.d.ts +9 -0
- package/dist/typeGuards.d.ts +6 -0
- package/dist/typebox.d.ts +4 -0
- package/dist/types.d.ts +438 -0
- package/dist/utils.d.ts +45 -0
- package/dist/vault/config.d.ts +20 -0
- package/dist/vault/inMemoryVaultStore.d.ts +2 -0
- package/dist/vault/index.d.ts +5 -0
- package/dist/vault/postgresVaultStore.d.ts +86 -0
- package/dist/vault/types.d.ts +14 -0
- package/dist/vc/inMemoryVpStores.d.ts +2 -0
- package/dist/vc/openid4vp.d.ts +82 -0
- package/dist/vc/postgresVcStores.d.ts +300 -0
- package/dist/vc/sdJwt.d.ts +37 -0
- package/dist/vc/statusList.d.ts +29 -0
- package/dist/vc/statusListRoutes.d.ts +63 -0
- package/dist/vc/vpRoutes.d.ts +120 -0
- package/dist/verification/types.d.ts +58 -0
- package/dist/webauthn/adapter.d.ts +59 -0
- package/dist/webauthn/config.d.ts +36 -0
- package/dist/webauthn/inMemoryWebAuthnCredentialStore.d.ts +2 -0
- package/dist/webauthn/postgresWebAuthnCredentialStore.d.ts +146 -0
- package/dist/webauthn/routes.d.ts +155 -0
- package/dist/webauthn/simpleWebAuthnAdapter.d.ts +3 -0
- package/dist/webauthn/types.d.ts +17 -0
- package/dist/webauthn.d.ts +1 -0
- package/dist/webhooks/config.d.ts +34 -0
- package/dist/webhooks/dispatcher.d.ts +3 -0
- package/dist/webhooks/inMemoryStore.d.ts +2 -0
- package/dist/webhooks/postgresStore.d.ts +116 -0
- package/dist/webhooks/sign.d.ts +11 -0
- package/dist/webhooks/types.d.ts +25 -0
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type MfaRouteProps } from './config';
|
|
3
|
+
export declare const mfaTotpRoutes: <UserType>({ authSessionStore, backupCodeCount, encryptionKey, getUserId, issuer, managementAuthMaxAgeMs, mfaStore, onMfaEnrolled, totpSetupRoute, totpVerifyRoute }: MfaRouteProps<UserType>) => Elysia<"", {
|
|
4
|
+
decorator: {};
|
|
5
|
+
store: {
|
|
6
|
+
session: import("..").SessionRecord<UserType>;
|
|
7
|
+
unregisteredSession: import("..").UnregisteredSessionRecord;
|
|
8
|
+
};
|
|
9
|
+
derive: {};
|
|
10
|
+
resolve: {};
|
|
11
|
+
}, {
|
|
12
|
+
typebox: {};
|
|
13
|
+
error: {};
|
|
14
|
+
}, {
|
|
15
|
+
schema: {};
|
|
16
|
+
standaloneSchema: {};
|
|
17
|
+
macro: {};
|
|
18
|
+
macroFn: {};
|
|
19
|
+
parser: {};
|
|
20
|
+
response: {};
|
|
21
|
+
}, {
|
|
22
|
+
[x: string]: {
|
|
23
|
+
post: {
|
|
24
|
+
body: unknown;
|
|
25
|
+
params: {};
|
|
26
|
+
query: unknown;
|
|
27
|
+
headers: unknown;
|
|
28
|
+
response: {
|
|
29
|
+
401: "Recent authentication required" | "Authentication required";
|
|
30
|
+
200: {
|
|
31
|
+
readonly secret: string;
|
|
32
|
+
readonly uri: string;
|
|
33
|
+
};
|
|
34
|
+
422: {
|
|
35
|
+
type: "validation";
|
|
36
|
+
on: string;
|
|
37
|
+
summary?: string;
|
|
38
|
+
message?: string;
|
|
39
|
+
found?: unknown;
|
|
40
|
+
property?: string;
|
|
41
|
+
expected?: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
} & {
|
|
47
|
+
[x: string]: {
|
|
48
|
+
post: {
|
|
49
|
+
body: {
|
|
50
|
+
code: string;
|
|
51
|
+
};
|
|
52
|
+
params: {};
|
|
53
|
+
query: unknown;
|
|
54
|
+
headers: unknown;
|
|
55
|
+
response: {
|
|
56
|
+
400: "No TOTP enrollment in progress" | "Invalid TOTP code";
|
|
57
|
+
401: "Recent authentication required" | "Authentication required";
|
|
58
|
+
200: {
|
|
59
|
+
readonly backupCodes: string[];
|
|
60
|
+
};
|
|
61
|
+
422: {
|
|
62
|
+
type: "validation";
|
|
63
|
+
on: string;
|
|
64
|
+
summary?: string;
|
|
65
|
+
message?: string;
|
|
66
|
+
found?: unknown;
|
|
67
|
+
property?: string;
|
|
68
|
+
expected?: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}, {
|
|
74
|
+
derive: {};
|
|
75
|
+
resolve: {};
|
|
76
|
+
schema: {};
|
|
77
|
+
standaloneSchema: {};
|
|
78
|
+
response: {};
|
|
79
|
+
}, {
|
|
80
|
+
derive: {};
|
|
81
|
+
resolve: {};
|
|
82
|
+
schema: {};
|
|
83
|
+
standaloneSchema: {};
|
|
84
|
+
response: {};
|
|
85
|
+
} & {
|
|
86
|
+
derive: {};
|
|
87
|
+
resolve: {};
|
|
88
|
+
schema: {};
|
|
89
|
+
standaloneSchema: {};
|
|
90
|
+
response: {};
|
|
91
|
+
}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { VerificationPurpose } from '../verification/types';
|
|
2
|
+
export type MfaFactorType = 'backup_codes' | 'sms' | 'totp';
|
|
3
|
+
export type MfaEnrollment = {
|
|
4
|
+
backupCodeHashes: string[];
|
|
5
|
+
createdAt: number;
|
|
6
|
+
lastUsedAt?: number;
|
|
7
|
+
smsFailedAttempts?: number;
|
|
8
|
+
smsPendingCodeHash?: string;
|
|
9
|
+
smsPendingCodeExpiresAt?: number;
|
|
10
|
+
smsPendingPurpose?: VerificationPurpose;
|
|
11
|
+
smsProviderReference?: string;
|
|
12
|
+
smsCodeSentAt?: number;
|
|
13
|
+
/** Opaque generation binding every update to the currently active challenge. */
|
|
14
|
+
smsChallengeId?: string;
|
|
15
|
+
smsPhone?: string;
|
|
16
|
+
smsVerified: boolean;
|
|
17
|
+
totpFailedAttempts?: number;
|
|
18
|
+
totpSecretCiphertext?: string;
|
|
19
|
+
totpVerified: boolean;
|
|
20
|
+
updatedAt: number;
|
|
21
|
+
userId: string;
|
|
22
|
+
};
|
|
23
|
+
export type MFAStore = {
|
|
24
|
+
/** Atomically reserves the SMS slot only when the resend cooldown has elapsed. */
|
|
25
|
+
claimSmsChallenge: (input: {
|
|
26
|
+
challengeId: string;
|
|
27
|
+
cooldownCutoff: number;
|
|
28
|
+
enrollment: MfaEnrollment;
|
|
29
|
+
}) => Promise<boolean>;
|
|
30
|
+
completeSmsChallenge: (input: {
|
|
31
|
+
challengeId: string;
|
|
32
|
+
lastUsedAt?: number;
|
|
33
|
+
smsVerified: boolean;
|
|
34
|
+
userId: string;
|
|
35
|
+
}) => Promise<boolean>;
|
|
36
|
+
finalizeSmsChallenge: (input: {
|
|
37
|
+
challengeId: string;
|
|
38
|
+
expiresAt: number;
|
|
39
|
+
hash?: string;
|
|
40
|
+
providerReference?: string;
|
|
41
|
+
userId: string;
|
|
42
|
+
}) => Promise<boolean>;
|
|
43
|
+
getEnrollment: (userId: string) => Promise<MfaEnrollment | undefined>;
|
|
44
|
+
listEnrollments: () => Promise<MfaEnrollment[]>;
|
|
45
|
+
removeEnrollment: (userId: string) => Promise<void>;
|
|
46
|
+
recordSmsFailure: (input: {
|
|
47
|
+
challengeId: string;
|
|
48
|
+
maxAttempts: number;
|
|
49
|
+
userId: string;
|
|
50
|
+
}) => Promise<number | undefined>;
|
|
51
|
+
rollbackSmsChallenge: (input: {
|
|
52
|
+
challengeId: string;
|
|
53
|
+
previous?: MfaEnrollment;
|
|
54
|
+
userId: string;
|
|
55
|
+
}) => Promise<void>;
|
|
56
|
+
saveEnrollment: (enrollment: MfaEnrollment) => Promise<void>;
|
|
57
|
+
};
|
|
58
|
+
export declare const isMfaEnrolled: (enrollment: MfaEnrollment | undefined) => boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BlockMigrations } from './types';
|
|
2
|
+
export type BlockName = 'adaptive' | 'agents' | 'apikeys' | 'audit' | 'credentials' | 'fga' | 'linkedProviders' | 'lockout' | 'mfa' | 'oidc' | 'organizations' | 'passwordless' | 'portal' | 'roles' | 'scim' | 'sessions' | 'sso' | 'vault' | 'vc' | 'webauthn' | 'webhooks';
|
|
3
|
+
export declare const blockMigrations: Record<BlockName, BlockMigrations>;
|
|
4
|
+
export { runMigrations } from './runner';
|
|
5
|
+
export type { MigrationClient, MigrationQueryResult, MigrationRunResult, RunMigrationsOptions } from './runner';
|
|
6
|
+
export type { Migration, BlockMigrations } from './types';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type BlockName } from './index';
|
|
2
|
+
export type RunMigrationsOptions = {
|
|
3
|
+
/** Existing SQL client. When provided, the runner does not create or close a pool. */
|
|
4
|
+
client?: MigrationClient;
|
|
5
|
+
/** Postgres connection string used by the default Neon-compatible pool. */
|
|
6
|
+
databaseUrl?: string;
|
|
7
|
+
/** Subset of blocks to apply. Omit to apply every block the package ships. */
|
|
8
|
+
blocks?: BlockName[];
|
|
9
|
+
/** Optional logger; defaults to console.log. Pass `() => undefined` for silent mode. */
|
|
10
|
+
log?: (message: string) => void;
|
|
11
|
+
};
|
|
12
|
+
export type MigrationRunResult = {
|
|
13
|
+
applied: string[];
|
|
14
|
+
skipped: string[];
|
|
15
|
+
};
|
|
16
|
+
export type MigrationQueryResult = {
|
|
17
|
+
rows: unknown[];
|
|
18
|
+
};
|
|
19
|
+
export type MigrationClient = {
|
|
20
|
+
query: (text: string, values?: readonly unknown[]) => Promise<MigrationQueryResult>;
|
|
21
|
+
};
|
|
22
|
+
export declare const runMigrations: ({ blocks, client, databaseUrl, log }: RunMigrationsOptions) => Promise<MigrationRunResult>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Migration = {
|
|
2
|
+
/** Stable identifier — stored in `auth_migrations` to track applied state. Must be
|
|
3
|
+
* monotonically ordered within a block (e.g. `0001_init`, `0002_add_foo_column`). */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Idempotent SQL. Use `CREATE TABLE IF NOT EXISTS` so re-running is a no-op even if
|
|
6
|
+
* the consumer wired the tables by hand before adopting the migration runner. */
|
|
7
|
+
sql: string;
|
|
8
|
+
};
|
|
9
|
+
export type BlockMigrations = {
|
|
10
|
+
/** Block name as used in the CLI's `--blocks` flag and in `runMigrations({ blocks })`.
|
|
11
|
+
* Convention: same string as the `src/<block>/` directory. */
|
|
12
|
+
block: string;
|
|
13
|
+
migrations: Migration[];
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClientAssertionJtiStore, OAuthClient } from './types';
|
|
2
|
+
export declare const CLIENT_ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
|
|
3
|
+
export declare const verifyClientAssertion: ({ assertion, expectedAudience, jtiStore, resolveClient }: {
|
|
4
|
+
assertion: string;
|
|
5
|
+
expectedAudience: string;
|
|
6
|
+
jtiStore?: ClientAssertionJtiStore;
|
|
7
|
+
resolveClient: (clientId: string) => Promise<OAuthClient | undefined>;
|
|
8
|
+
}) => Promise<OAuthClient | undefined>;
|
|
9
|
+
export declare const verifyJwtSignedByClient: ({ jwt, client }: {
|
|
10
|
+
client: OAuthClient;
|
|
11
|
+
jwt: string;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
header: {
|
|
14
|
+
[k: string]: any;
|
|
15
|
+
};
|
|
16
|
+
payload: {
|
|
17
|
+
[k: string]: any;
|
|
18
|
+
};
|
|
19
|
+
} | undefined>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OAuthClient } from './types';
|
|
2
|
+
export type ClientIdMetadataDocument = {
|
|
3
|
+
client_id: string;
|
|
4
|
+
client_name?: string;
|
|
5
|
+
redirect_uris: string[];
|
|
6
|
+
grant_types?: string[];
|
|
7
|
+
response_types?: string[];
|
|
8
|
+
token_endpoint_auth_method?: 'none' | 'private_key_jwt' | 'self_signed_tls_client_auth';
|
|
9
|
+
application_type?: 'native' | 'web';
|
|
10
|
+
client_uri?: string;
|
|
11
|
+
logo_uri?: string;
|
|
12
|
+
policy_uri?: string;
|
|
13
|
+
tos_uri?: string;
|
|
14
|
+
jwks_uri?: string;
|
|
15
|
+
jwks?: {
|
|
16
|
+
keys: JsonWebKey[];
|
|
17
|
+
};
|
|
18
|
+
scope?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const clientIdMetadataToOAuthClient: (document: ClientIdMetadataDocument) => OAuthClient;
|
|
21
|
+
export declare const createClientIdMetadataResolver: ({ fetch: fetcher, allow, cacheTtlMs, maxBytes, now }: {
|
|
22
|
+
fetch: (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
23
|
+
allow?: (clientId: string) => boolean | Promise<boolean>;
|
|
24
|
+
cacheTtlMs?: number;
|
|
25
|
+
maxBytes?: number;
|
|
26
|
+
now?: () => number;
|
|
27
|
+
}) => (clientId: string) => Promise<OAuthClient | undefined>;
|
|
28
|
+
export declare const validateClientIdMetadataDocument: (document: ClientIdMetadataDocument, expectedClientId: string) => string[];
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import type { RouteString } from '../types';
|
|
2
|
+
import { type SigningKey, type SigningKeyIdentity } from './keys';
|
|
3
|
+
import type { OnClientRegistered, OnClientRegistration } from './registration';
|
|
4
|
+
import type { VciConfig } from './vci';
|
|
5
|
+
import type { AuthorizationCodeStore, BackchannelAuthStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClient, OAuthClientStore, OidcRefreshTokenStore, PushedAuthorizationRequestStore } from './types';
|
|
6
|
+
export declare const DEFAULT_OIDC_ROUTE: RouteString;
|
|
7
|
+
export type PublicTokenGrantResult = {
|
|
8
|
+
body: Record<string, unknown>;
|
|
9
|
+
status: number;
|
|
10
|
+
};
|
|
11
|
+
export type OidcProviderConfig<UserType> = {
|
|
12
|
+
/** Additional non-conflicting RFC 8414 metadata. Reserved core OAuth keys
|
|
13
|
+
* cannot be replaced. Used by profiles such as open agent registration. */
|
|
14
|
+
additionalDiscoveryMetadata?: Record<string, unknown>;
|
|
15
|
+
/** Public extension grants whose bearer material is carried in their body
|
|
16
|
+
* (for example an agent claim_token). They run before OAuth client auth. */
|
|
17
|
+
publicTokenGrantTypes?: string[];
|
|
18
|
+
handlePublicTokenGrant?: (context: {
|
|
19
|
+
body: Record<string, string | undefined>;
|
|
20
|
+
request: Request;
|
|
21
|
+
}) => Promise<PublicTokenGrantResult | undefined>;
|
|
22
|
+
accessTokenTtlMs?: number | ((context: {
|
|
23
|
+
scopes: string[];
|
|
24
|
+
}) => number);
|
|
25
|
+
acrValuesSupported?: string[];
|
|
26
|
+
authorizationCodeStore: AuthorizationCodeStore;
|
|
27
|
+
clientAssertionJtiStore?: ClientAssertionJtiStore;
|
|
28
|
+
clientRegistrationTokenStore?: ClientRegistrationTokenStore;
|
|
29
|
+
clientStore: OAuthClientStore;
|
|
30
|
+
resolveClientIdMetadata?: (clientId: string) => Promise<OAuthClient | undefined>;
|
|
31
|
+
deviceAuthorizationStore?: DeviceAuthorizationStore;
|
|
32
|
+
deviceCodeTtlMs?: number;
|
|
33
|
+
devicePollIntervalSeconds?: number;
|
|
34
|
+
backchannelAuthStore?: BackchannelAuthStore;
|
|
35
|
+
backchannelAuthTtlMs?: number;
|
|
36
|
+
backchannelPollIntervalSeconds?: number;
|
|
37
|
+
resolveBackchannelUser?: (hint: {
|
|
38
|
+
client: OAuthClient;
|
|
39
|
+
loginHint: string;
|
|
40
|
+
}) => Promise<{
|
|
41
|
+
sub: string;
|
|
42
|
+
} | undefined>;
|
|
43
|
+
onBackchannelAuthRequest?: (context: {
|
|
44
|
+
authReqId: string;
|
|
45
|
+
bindingMessage: string | undefined;
|
|
46
|
+
clientId: string;
|
|
47
|
+
scopes: string[];
|
|
48
|
+
userSub: string;
|
|
49
|
+
}) => Promise<void> | void;
|
|
50
|
+
getAccessTokenClaims?: (context: {
|
|
51
|
+
audience?: string;
|
|
52
|
+
clientId: string;
|
|
53
|
+
scopes: string[];
|
|
54
|
+
sub: string;
|
|
55
|
+
}) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
56
|
+
getClaims?: (user: UserType) => Record<string, unknown>;
|
|
57
|
+
consentUrl?: string;
|
|
58
|
+
needsConsent?: (context: {
|
|
59
|
+
client: {
|
|
60
|
+
clientId: string;
|
|
61
|
+
name: string;
|
|
62
|
+
};
|
|
63
|
+
requestedScopes: string[];
|
|
64
|
+
user: UserType;
|
|
65
|
+
}) => boolean | Promise<boolean>;
|
|
66
|
+
getGrantedScopes?: (context: {
|
|
67
|
+
client: {
|
|
68
|
+
clientId: string;
|
|
69
|
+
name: string;
|
|
70
|
+
};
|
|
71
|
+
requestedScopes: string[];
|
|
72
|
+
user: UserType;
|
|
73
|
+
}) => string[] | undefined | Promise<string[] | undefined>;
|
|
74
|
+
getUserId: (user: UserType) => string;
|
|
75
|
+
getUserInfo?: (sub: string) => Promise<Record<string, unknown> | undefined>;
|
|
76
|
+
idTokenTtlMs?: number;
|
|
77
|
+
issuer: string;
|
|
78
|
+
dpopNonce?: {
|
|
79
|
+
secret: string;
|
|
80
|
+
};
|
|
81
|
+
extractTlsClientCert?: (headers: Headers) => Promise<Uint8Array | undefined> | Uint8Array | undefined;
|
|
82
|
+
getAcr?: (context: {
|
|
83
|
+
scopes: string[];
|
|
84
|
+
user: UserType;
|
|
85
|
+
}) => string | undefined;
|
|
86
|
+
initialAccessTokenStore?: InitialAccessTokenStore;
|
|
87
|
+
loginUrl?: string;
|
|
88
|
+
logoutDeliveryStore?: LogoutDeliveryStore;
|
|
89
|
+
oidcRoute?: RouteString;
|
|
90
|
+
onClientRegistration?: OnClientRegistration;
|
|
91
|
+
/** Fires after RFC 7591 registration has been persisted and has a generated client id. */
|
|
92
|
+
onClientRegistered?: OnClientRegistered;
|
|
93
|
+
/** Fires after an authenticated user authorizes an OAuth authorization-code
|
|
94
|
+
* request and the final granted scopes are known, before the code is issued. */
|
|
95
|
+
onAuthorizationCodeApproved?: (context: {
|
|
96
|
+
clientId: string;
|
|
97
|
+
scopes: string[];
|
|
98
|
+
userSub: string;
|
|
99
|
+
}) => void | Promise<void>;
|
|
100
|
+
/** Fires after the authenticated user approves an RFC 8628 device request. */
|
|
101
|
+
onDeviceAuthorizationApproved?: (context: {
|
|
102
|
+
clientId: string;
|
|
103
|
+
scopes: string[];
|
|
104
|
+
userSub: string;
|
|
105
|
+
}) => void | Promise<void>;
|
|
106
|
+
pushedAuthorizationRequestStore?: PushedAuthorizationRequestStore;
|
|
107
|
+
pushedAuthorizationRequestTtlMs?: number;
|
|
108
|
+
refreshTokenStore: OidcRefreshTokenStore;
|
|
109
|
+
refreshTokenTtlMs?: number;
|
|
110
|
+
/** Previous public signing identities retained only for the bounded token
|
|
111
|
+
* overlap window after rotation. The active `signingKey` always signs new
|
|
112
|
+
* tokens and is published first. Private material does not belong here. */
|
|
113
|
+
previousSigningKeys?: readonly SigningKeyIdentity[];
|
|
114
|
+
signingKey: SigningKey;
|
|
115
|
+
strictFapi?: boolean;
|
|
116
|
+
vciConfig?: VciConfig;
|
|
117
|
+
};
|
|
118
|
+
export type TokenExchangeResult = {
|
|
119
|
+
error: 'invalid_grant' | 'invalid_scope';
|
|
120
|
+
ok: false;
|
|
121
|
+
} | {
|
|
122
|
+
accessToken: string;
|
|
123
|
+
expiresIn: number;
|
|
124
|
+
ok: true;
|
|
125
|
+
scope: string;
|
|
126
|
+
};
|
|
127
|
+
export declare const exchangeToken: <UserType>({ actorClientId, audience, config, dpopJkt, now, requestedScopes, subjectToken }: {
|
|
128
|
+
actorClientId: string;
|
|
129
|
+
audience?: string;
|
|
130
|
+
config: OidcProviderConfig<UserType>;
|
|
131
|
+
dpopJkt?: string;
|
|
132
|
+
now?: number;
|
|
133
|
+
requestedScopes?: string[];
|
|
134
|
+
subjectToken: string;
|
|
135
|
+
}) => Promise<TokenExchangeResult>;
|
|
136
|
+
export declare const issueTokenSet: <UserType>({ acr, audience, claims, clientCertThumbprint, clientId, config, dpopJkt, nonce, now, scopes, sub }: {
|
|
137
|
+
acr?: string;
|
|
138
|
+
audience?: string;
|
|
139
|
+
claims?: Record<string, unknown>;
|
|
140
|
+
clientCertThumbprint?: string;
|
|
141
|
+
clientId: string;
|
|
142
|
+
config: OidcProviderConfig<UserType>;
|
|
143
|
+
dpopJkt?: string;
|
|
144
|
+
nonce?: string;
|
|
145
|
+
now?: number;
|
|
146
|
+
scopes: string[];
|
|
147
|
+
sub: string;
|
|
148
|
+
}) => Promise<{
|
|
149
|
+
access_token: string;
|
|
150
|
+
expires_in: number;
|
|
151
|
+
id_token: string;
|
|
152
|
+
refresh_token: string;
|
|
153
|
+
scope: string;
|
|
154
|
+
token_type: "Bearer" | "DPoP";
|
|
155
|
+
}>;
|
|
156
|
+
export declare const mcpProtectedResourceMetadata: ({ issuer, resource, scopes }: {
|
|
157
|
+
issuer: string;
|
|
158
|
+
resource: string;
|
|
159
|
+
scopes?: string[];
|
|
160
|
+
}) => {
|
|
161
|
+
authorization_servers: string[];
|
|
162
|
+
resource: string;
|
|
163
|
+
scopes_supported: string[];
|
|
164
|
+
};
|
|
165
|
+
export declare const verifyPkce: (codeVerifier: string, codeChallenge: string) => Promise<boolean>;
|
|
166
|
+
export type TokenIntrospection = {
|
|
167
|
+
active: false;
|
|
168
|
+
} | {
|
|
169
|
+
active: true;
|
|
170
|
+
client_id: string;
|
|
171
|
+
exp: number;
|
|
172
|
+
iat: number;
|
|
173
|
+
scope: string;
|
|
174
|
+
sub: string;
|
|
175
|
+
token_type: 'access_token' | 'refresh_token';
|
|
176
|
+
};
|
|
177
|
+
export type TokenTypeHint = 'access_token' | 'refresh_token';
|
|
178
|
+
export declare const introspectToken: <UserType>({ config, hint, now, token }: {
|
|
179
|
+
config: OidcProviderConfig<UserType>;
|
|
180
|
+
hint?: TokenTypeHint;
|
|
181
|
+
now?: number;
|
|
182
|
+
token: string;
|
|
183
|
+
}) => Promise<{
|
|
184
|
+
active: false;
|
|
185
|
+
} | {
|
|
186
|
+
active: true;
|
|
187
|
+
client_id: string;
|
|
188
|
+
exp: number;
|
|
189
|
+
iat: number;
|
|
190
|
+
scope: string;
|
|
191
|
+
sub: string;
|
|
192
|
+
token_type: "access_token";
|
|
193
|
+
} | {
|
|
194
|
+
active: true;
|
|
195
|
+
client_id: string;
|
|
196
|
+
exp: number;
|
|
197
|
+
iat: number;
|
|
198
|
+
scope: string;
|
|
199
|
+
sub: string;
|
|
200
|
+
token_type: "refresh_token";
|
|
201
|
+
}>;
|
|
202
|
+
export declare const revokeRefreshToken: <UserType>(config: OidcProviderConfig<UserType>, token: string) => Promise<boolean>;
|
|
203
|
+
export type DeviceAuthorizationResponse = {
|
|
204
|
+
device_code: string;
|
|
205
|
+
expires_in: number;
|
|
206
|
+
interval: number;
|
|
207
|
+
user_code: string;
|
|
208
|
+
verification_uri: string;
|
|
209
|
+
verification_uri_complete: string;
|
|
210
|
+
};
|
|
211
|
+
export declare const issueDeviceAuthorization: <UserType>({ clientId, config, now, requestedScopes }: {
|
|
212
|
+
clientId: string;
|
|
213
|
+
config: OidcProviderConfig<UserType>;
|
|
214
|
+
now?: number;
|
|
215
|
+
requestedScopes: string[];
|
|
216
|
+
}) => Promise<DeviceAuthorizationResponse>;
|
|
217
|
+
export type DeviceDecisionResult = {
|
|
218
|
+
error: 'already_decided' | 'expired_token' | 'invalid_user_code' | 'not_configured';
|
|
219
|
+
ok: false;
|
|
220
|
+
} | {
|
|
221
|
+
ok: true;
|
|
222
|
+
};
|
|
223
|
+
export declare const approveDeviceAuthorization: <UserType>({ config, userCode, userSub }: {
|
|
224
|
+
config: OidcProviderConfig<UserType>;
|
|
225
|
+
userCode: string;
|
|
226
|
+
userSub: string;
|
|
227
|
+
}) => Promise<DeviceDecisionResult>;
|
|
228
|
+
export declare const denyDeviceAuthorization: <UserType>({ config, userCode }: {
|
|
229
|
+
config: OidcProviderConfig<UserType>;
|
|
230
|
+
userCode: string;
|
|
231
|
+
}) => Promise<DeviceDecisionResult>;
|
|
232
|
+
export type DeviceCodeExchangeError = 'access_denied' | 'authorization_pending' | 'expired_token' | 'invalid_grant' | 'slow_down';
|
|
233
|
+
export type DeviceCodeExchangeResult = {
|
|
234
|
+
access_token: string;
|
|
235
|
+
expires_in: number;
|
|
236
|
+
id_token: string;
|
|
237
|
+
ok: true;
|
|
238
|
+
refresh_token: string;
|
|
239
|
+
scope: string;
|
|
240
|
+
token_type: 'Bearer' | 'DPoP';
|
|
241
|
+
} | {
|
|
242
|
+
error: DeviceCodeExchangeError;
|
|
243
|
+
ok: false;
|
|
244
|
+
};
|
|
245
|
+
export declare const exchangeDeviceCode: <UserType>({ clientId, config, deviceCode, dpopJkt, now }: {
|
|
246
|
+
clientId: string;
|
|
247
|
+
config: OidcProviderConfig<UserType>;
|
|
248
|
+
deviceCode: string;
|
|
249
|
+
dpopJkt?: string;
|
|
250
|
+
now?: number;
|
|
251
|
+
}) => Promise<DeviceCodeExchangeResult>;
|
|
252
|
+
export declare const CIBA_GRANT_TYPE = "urn:openid:params:grant-type:ciba";
|
|
253
|
+
export type BackchannelAuthResponse = {
|
|
254
|
+
auth_req_id: string;
|
|
255
|
+
expires_in: number;
|
|
256
|
+
interval: number;
|
|
257
|
+
};
|
|
258
|
+
export type BackchannelAuthError = 'expired_login_hint_token' | 'invalid_client' | 'invalid_request' | 'unknown_user_id';
|
|
259
|
+
export declare const issueBackchannelAuth: <UserType>({ clientId, config, loginHint, bindingMessage, now, requestedScopes }: {
|
|
260
|
+
clientId: string;
|
|
261
|
+
config: OidcProviderConfig<UserType>;
|
|
262
|
+
loginHint: string;
|
|
263
|
+
bindingMessage?: string;
|
|
264
|
+
now?: number;
|
|
265
|
+
requestedScopes: string[];
|
|
266
|
+
}) => Promise<{
|
|
267
|
+
error: BackchannelAuthError;
|
|
268
|
+
ok: false;
|
|
269
|
+
} | ({
|
|
270
|
+
ok: true;
|
|
271
|
+
} & BackchannelAuthResponse)>;
|
|
272
|
+
export type BackchannelDecisionResult = {
|
|
273
|
+
error: 'already_decided' | 'expired_token' | 'invalid_auth_req_id' | 'not_configured';
|
|
274
|
+
ok: false;
|
|
275
|
+
} | {
|
|
276
|
+
ok: true;
|
|
277
|
+
};
|
|
278
|
+
export declare const approveBackchannelAuth: <UserType>({ authReqId, config, userSub }: {
|
|
279
|
+
authReqId: string;
|
|
280
|
+
config: OidcProviderConfig<UserType>;
|
|
281
|
+
userSub?: string;
|
|
282
|
+
}) => Promise<BackchannelDecisionResult>;
|
|
283
|
+
export declare const denyBackchannelAuth: <UserType>({ authReqId, config }: {
|
|
284
|
+
authReqId: string;
|
|
285
|
+
config: OidcProviderConfig<UserType>;
|
|
286
|
+
}) => Promise<BackchannelDecisionResult>;
|
|
287
|
+
export type BackchannelExchangeError = 'access_denied' | 'authorization_pending' | 'expired_token' | 'invalid_grant' | 'slow_down';
|
|
288
|
+
export type BackchannelExchangeResult = {
|
|
289
|
+
access_token: string;
|
|
290
|
+
expires_in: number;
|
|
291
|
+
id_token: string;
|
|
292
|
+
ok: true;
|
|
293
|
+
refresh_token: string;
|
|
294
|
+
scope: string;
|
|
295
|
+
token_type: 'Bearer' | 'DPoP';
|
|
296
|
+
} | {
|
|
297
|
+
error: BackchannelExchangeError;
|
|
298
|
+
ok: false;
|
|
299
|
+
};
|
|
300
|
+
export declare const exchangeBackchannelAuth: <UserType>({ authReqId, clientCertThumbprint, clientId, config, dpopJkt, now }: {
|
|
301
|
+
authReqId: string;
|
|
302
|
+
clientCertThumbprint?: string;
|
|
303
|
+
clientId: string;
|
|
304
|
+
config: OidcProviderConfig<UserType>;
|
|
305
|
+
dpopJkt?: string;
|
|
306
|
+
now?: number;
|
|
307
|
+
}) => Promise<BackchannelExchangeResult>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const extractDpopNonceClaim: (proof: string) => string | undefined;
|
|
2
|
+
export declare const mintDpopNonce: ({ now, secret }: {
|
|
3
|
+
now?: number;
|
|
4
|
+
secret: string;
|
|
5
|
+
}) => Promise<string>;
|
|
6
|
+
export declare const verifyDpopNonce: ({ now, nonce, secret }: {
|
|
7
|
+
nonce: string;
|
|
8
|
+
now?: number;
|
|
9
|
+
secret: string;
|
|
10
|
+
}) => Promise<boolean>;
|
|
11
|
+
export type DpopResult = {
|
|
12
|
+
jkt: string;
|
|
13
|
+
jti?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const verifyDpopProof: ({ accessToken, htm, htu, isUsedJti, maxAgeMs, now, proof }: {
|
|
16
|
+
accessToken?: string;
|
|
17
|
+
htm: string;
|
|
18
|
+
htu: string;
|
|
19
|
+
isUsedJti?: (jti: string) => boolean | Promise<boolean>;
|
|
20
|
+
maxAgeMs?: number;
|
|
21
|
+
now?: number;
|
|
22
|
+
proof: string | undefined;
|
|
23
|
+
}) => Promise<DpopResult | undefined>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AuthorizationCodeStore, BackchannelAuthStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClient, OAuthClientStore, OidcRefreshTokenStore, PushedAuthorizationRequestStore } from './types';
|
|
2
|
+
export declare const createInMemoryAuthorizationCodeStore: () => AuthorizationCodeStore;
|
|
3
|
+
export declare const createInMemoryBackchannelAuthStore: () => BackchannelAuthStore;
|
|
4
|
+
export declare const createInMemoryClientAssertionJtiStore: () => ClientAssertionJtiStore;
|
|
5
|
+
export declare const createInMemoryClientRegistrationTokenStore: () => ClientRegistrationTokenStore;
|
|
6
|
+
export declare const createInMemoryDeviceAuthorizationStore: () => DeviceAuthorizationStore;
|
|
7
|
+
export declare const createInMemoryInitialAccessTokenStore: (initialHashes?: string[]) => InitialAccessTokenStore;
|
|
8
|
+
export declare const createInMemoryLogoutDeliveryStore: () => LogoutDeliveryStore;
|
|
9
|
+
export declare const createInMemoryOAuthClientStore: (clients: OAuthClient[]) => OAuthClientStore;
|
|
10
|
+
export declare const createInMemoryOidcRefreshTokenStore: () => OidcRefreshTokenStore;
|
|
11
|
+
export declare const createInMemoryPushedAuthorizationRequestStore: () => PushedAuthorizationRequestStore;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declaration-stable OIDC provider entry point.
|
|
3
|
+
*
|
|
4
|
+
* Server applications that only need to issue and verify OAuth/OIDC tokens
|
|
5
|
+
* should import this subpath instead of loading every optional Auth feature
|
|
6
|
+
* through the package root.
|
|
7
|
+
*/
|
|
8
|
+
export type { OidcProviderConfig } from './config';
|
|
9
|
+
export { generateSigningKey, jwkThumbprint, signJwt, signingVerificationKeys, toPublicJwk, verifyJwt, verifyJwtWithKeys, type SigningKey, type SigningKeyIdentity } from './keys';
|
|
10
|
+
export { revokeOAuthClientCredentials } from './operator';
|
|
11
|
+
export { createNeonAuthorizationCodeStore, createNeonClientAssertionJtiStore, createNeonClientRegistrationTokenStore, createNeonDeviceAuthorizationStore, createNeonInitialAccessTokenStore, createNeonOAuthClientStore, createNeonOidcRefreshTokenStore, createPostgresAuthorizationCodeStore, createPostgresClientAssertionJtiStore, createPostgresClientRegistrationTokenStore, createPostgresDeviceAuthorizationStore, createPostgresInitialAccessTokenStore, createPostgresOAuthClientStore, createPostgresOidcRefreshTokenStore } from './postgresStores';
|
|
12
|
+
export type { AuthorizationCodeStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, OAuthClient, OAuthClientStore, OidcRefreshTokenConnection, OidcRefreshTokenStore } from './types';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OAuthClient } from './types';
|
|
2
|
+
export type JarParseResult = {
|
|
3
|
+
error: 'invalid_request_object';
|
|
4
|
+
ok: false;
|
|
5
|
+
} | {
|
|
6
|
+
ok: true;
|
|
7
|
+
params: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
export declare const parseSignedRequestObject: ({ client, expectedIssuer, jwt, now }: {
|
|
10
|
+
client: OAuthClient;
|
|
11
|
+
expectedIssuer: string;
|
|
12
|
+
jwt: string;
|
|
13
|
+
now?: number;
|
|
14
|
+
}) => Promise<JarParseResult>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type SigningKeyIdentity = {
|
|
2
|
+
kid: string;
|
|
3
|
+
publicJwk: JsonWebKey;
|
|
4
|
+
};
|
|
5
|
+
/** ES256 signing material can remain local for development or be delegated to
|
|
6
|
+
* a non-exportable KMS/HSM adapter. External signers return the 64-byte JOSE
|
|
7
|
+
* ECDSA signature (r || s), not an ASN.1 DER envelope. */
|
|
8
|
+
export type SigningKey = SigningKeyIdentity & ({
|
|
9
|
+
privateJwk: JsonWebKey;
|
|
10
|
+
sign?: never;
|
|
11
|
+
} | {
|
|
12
|
+
privateJwk?: never;
|
|
13
|
+
sign: (input: Uint8Array) => Promise<Uint8Array>;
|
|
14
|
+
});
|
|
15
|
+
declare const generateSigningKey: () => Promise<SigningKey>;
|
|
16
|
+
declare const jwkThumbprint: (jwk: JsonWebKey) => Promise<string>;
|
|
17
|
+
declare const signJwt: (payload: Record<string, unknown>, signing: SigningKey, typ?: string) => Promise<string>;
|
|
18
|
+
declare const toPublicJwk: (key: SigningKeyIdentity) => {
|
|
19
|
+
alg: string;
|
|
20
|
+
crv: string | undefined;
|
|
21
|
+
kid: string;
|
|
22
|
+
kty: string | undefined;
|
|
23
|
+
use: string;
|
|
24
|
+
x: string | undefined;
|
|
25
|
+
y: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
declare const verifyJwt: (token: string, publicJwk: JsonWebKey) => Promise<{
|
|
28
|
+
header: {
|
|
29
|
+
[k: string]: any;
|
|
30
|
+
};
|
|
31
|
+
payload: {
|
|
32
|
+
[k: string]: any;
|
|
33
|
+
};
|
|
34
|
+
} | undefined>;
|
|
35
|
+
/** Resolves the active signing identity followed by still-valid previous
|
|
36
|
+
* public identities. Duplicate key IDs fail closed because a JWT `kid` must
|
|
37
|
+
* identify exactly one verification key during an overlap window. */
|
|
38
|
+
declare const signingVerificationKeys: (active: SigningKeyIdentity, previous?: readonly SigningKeyIdentity[]) => SigningKeyIdentity[];
|
|
39
|
+
/** Verifies an Absolute Auth JWT against the exact public identity named by
|
|
40
|
+
* its protected `kid` header. This keeps already-issued tokens valid while a
|
|
41
|
+
* previous public key remains in the configured overlap window. */
|
|
42
|
+
declare const verifyJwtWithKeys: (token: string, keys: readonly SigningKeyIdentity[]) => Promise<{
|
|
43
|
+
header: {
|
|
44
|
+
[k: string]: any;
|
|
45
|
+
};
|
|
46
|
+
payload: {
|
|
47
|
+
[k: string]: any;
|
|
48
|
+
};
|
|
49
|
+
} | undefined>;
|
|
50
|
+
export { generateSigningKey, jwkThumbprint, signingVerificationKeys, signJwt, toPublicJwk, verifyJwt, verifyJwtWithKeys };
|