@absolutejs/auth 0.25.1 → 0.26.0-beta.1
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/audit/config.d.ts +8 -0
- package/dist/audit/inMemoryAuditStore.d.ts +2 -0
- package/dist/audit/postgresAuditStore.d.ts +142 -0
- package/dist/audit/types.d.ts +18 -0
- package/dist/audit/wrap.d.ts +9 -0
- package/dist/credentials/config.d.ts +61 -0
- package/dist/credentials/emailVerification.d.ts +83 -0
- package/dist/credentials/inMemoryCredentialStore.d.ts +2 -0
- package/dist/credentials/login.d.ts +75 -0
- package/dist/credentials/passwordPolicy.d.ts +14 -0
- package/dist/credentials/passwordReset.d.ts +87 -0
- package/dist/credentials/postgresCredentialStore.d.ts +279 -0
- package/dist/credentials/register.d.ts +54 -0
- package/dist/credentials/routes.d.ts +200 -0
- package/dist/credentials/types.d.ts +26 -0
- package/dist/crypto.d.ts +32 -0
- package/dist/{ui → htmx}/index.js +2 -2
- package/dist/{ui → htmx}/index.js.map +2 -2
- package/dist/{htmxRoutes.d.ts → htmx/routes.d.ts} +4 -4
- package/dist/index.d.ts +427 -27
- package/dist/index.js +3315 -1932
- package/dist/index.js.map +60 -27
- package/dist/{neonLinkedProviders.d.ts → linkedProviders/neonStores.d.ts} +619 -613
- package/dist/{oauthLinkedProviderResolver.d.ts → linkedProviders/oauthResolver.d.ts} +1 -1
- package/dist/lockout/config.d.ts +17 -0
- package/dist/lockout/inMemoryLockoutStore.d.ts +2 -0
- package/dist/lockout/postgresLockoutStore.d.ts +81 -0
- package/dist/lockout/types.d.ts +12 -0
- package/dist/mfa/backupCodes.d.ts +5 -0
- package/dist/mfa/challenge.d.ts +65 -0
- package/dist/mfa/config.d.ts +32 -0
- package/dist/mfa/gate.d.ts +2 -0
- package/dist/mfa/inMemoryMfaStore.d.ts +2 -0
- package/dist/mfa/postgresMfaStore.d.ts +134 -0
- package/dist/mfa/routes.d.ts +117 -0
- package/dist/mfa/secret.d.ts +2 -0
- package/dist/mfa/totp.d.ts +91 -0
- package/dist/mfa/types.d.ts +16 -0
- package/dist/{providerClients.d.ts → providers/clients.d.ts} +35 -19
- package/dist/{authorize.d.ts → routes/authorize.d.ts} +5 -5
- package/dist/{callback.d.ts → routes/callback.d.ts} +4 -4
- package/dist/{profile.d.ts → routes/profile.d.ts} +5 -5
- package/dist/{protectRoute.d.ts → routes/protectRoute.d.ts} +5 -5
- package/dist/{refresh.d.ts → routes/refresh.d.ts} +5 -5
- package/dist/{revoke.d.ts → routes/revoke.d.ts} +6 -6
- package/dist/routes/sessions.d.ts +103 -0
- package/dist/{signout.d.ts → routes/signout.d.ts} +4 -4
- package/dist/routes/stepUp.d.ts +48 -0
- package/dist/{userStatus.d.ts → routes/userStatus.d.ts} +4 -4
- package/dist/{sessionAccess.d.ts → session/access.d.ts} +12 -12
- package/dist/{sessionCleanup.d.ts → session/cleanup.d.ts} +2 -2
- package/dist/{authSessionStores.d.ts → session/inMemoryStore.d.ts} +2 -2
- package/dist/{neonAuthSessionStore.d.ts → session/neonStore.d.ts} +209 -175
- package/dist/session/promote.d.ts +13 -0
- package/dist/session/sessionsConfig.d.ts +9 -0
- package/dist/{sessionStore.d.ts → session/state.d.ts} +1 -1
- package/dist/{sessionTypes.d.ts → session/types.d.ts} +1 -1
- package/dist/session/userSessions.d.ts +16 -0
- package/dist/stores/postgres.d.ts +5 -0
- package/dist/tenancy.d.ts +9 -0
- package/dist/typeGuards.d.ts +2 -2
- package/dist/typebox.d.ts +3 -3
- package/dist/types.d.ts +33 -3
- package/dist/utils.d.ts +9 -9
- package/package.json +19 -16
- /package/dist/{ui → htmx}/index.d.ts +0 -0
- /package/dist/{ui → htmx}/renderers.d.ts +0 -0
- /package/dist/{ui → htmx}/types.d.ts +0 -0
- /package/dist/{linkedProviderStores.d.ts → linkedProviders/inMemoryStores.d.ts} +0 -0
- /package/dist/{linkedProviderResolver.d.ts → linkedProviders/resolver.d.ts} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AuditEvent, AuditSink } from './types';
|
|
2
|
+
export type AuditConfig<UserType> = {
|
|
3
|
+
auditStore?: AuditSink;
|
|
4
|
+
getUserId?: (user: UserType) => string;
|
|
5
|
+
onAuditEvent?: (event: AuditEvent) => void | Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export type AuditEmitter = (event: AuditEvent) => Promise<void>;
|
|
8
|
+
export declare const createAuditEmitter: <UserType>({ auditStore, onAuditEvent }: AuditConfig<UserType>) => (event: AuditEvent) => Promise<void>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { type AnyPgDatabase } from '../stores/postgres';
|
|
2
|
+
import type { AuditSink } from './types';
|
|
3
|
+
export declare const auditEventsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4
|
+
name: "auth_audit_events";
|
|
5
|
+
schema: undefined;
|
|
6
|
+
columns: {
|
|
7
|
+
at_ms: import("drizzle-orm/pg-core").PgColumn<{
|
|
8
|
+
name: "at_ms";
|
|
9
|
+
tableName: "auth_audit_events";
|
|
10
|
+
dataType: "number";
|
|
11
|
+
columnType: "PgBigInt53";
|
|
12
|
+
data: number;
|
|
13
|
+
driverParam: string | number;
|
|
14
|
+
notNull: true;
|
|
15
|
+
hasDefault: false;
|
|
16
|
+
isPrimaryKey: false;
|
|
17
|
+
isAutoincrement: false;
|
|
18
|
+
hasRuntimeDefault: false;
|
|
19
|
+
enumValues: undefined;
|
|
20
|
+
baseColumn: never;
|
|
21
|
+
identity: undefined;
|
|
22
|
+
generated: undefined;
|
|
23
|
+
}, {}, {}>;
|
|
24
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
25
|
+
name: "id";
|
|
26
|
+
tableName: "auth_audit_events";
|
|
27
|
+
dataType: "string";
|
|
28
|
+
columnType: "PgVarchar";
|
|
29
|
+
data: string;
|
|
30
|
+
driverParam: string;
|
|
31
|
+
notNull: true;
|
|
32
|
+
hasDefault: false;
|
|
33
|
+
isPrimaryKey: true;
|
|
34
|
+
isAutoincrement: false;
|
|
35
|
+
hasRuntimeDefault: false;
|
|
36
|
+
enumValues: [string, ...string[]];
|
|
37
|
+
baseColumn: never;
|
|
38
|
+
identity: undefined;
|
|
39
|
+
generated: undefined;
|
|
40
|
+
}, {}, {
|
|
41
|
+
length: 255;
|
|
42
|
+
}>;
|
|
43
|
+
ip: import("drizzle-orm/pg-core").PgColumn<{
|
|
44
|
+
name: "ip";
|
|
45
|
+
tableName: "auth_audit_events";
|
|
46
|
+
dataType: "string";
|
|
47
|
+
columnType: "PgVarchar";
|
|
48
|
+
data: string;
|
|
49
|
+
driverParam: string;
|
|
50
|
+
notNull: false;
|
|
51
|
+
hasDefault: false;
|
|
52
|
+
isPrimaryKey: false;
|
|
53
|
+
isAutoincrement: false;
|
|
54
|
+
hasRuntimeDefault: false;
|
|
55
|
+
enumValues: [string, ...string[]];
|
|
56
|
+
baseColumn: never;
|
|
57
|
+
identity: undefined;
|
|
58
|
+
generated: undefined;
|
|
59
|
+
}, {}, {
|
|
60
|
+
length: 64;
|
|
61
|
+
}>;
|
|
62
|
+
metadata_json: import("drizzle-orm/pg-core").PgColumn<{
|
|
63
|
+
name: "metadata_json";
|
|
64
|
+
tableName: "auth_audit_events";
|
|
65
|
+
dataType: "json";
|
|
66
|
+
columnType: "PgJsonb";
|
|
67
|
+
data: Record<string, unknown>;
|
|
68
|
+
driverParam: unknown;
|
|
69
|
+
notNull: false;
|
|
70
|
+
hasDefault: false;
|
|
71
|
+
isPrimaryKey: false;
|
|
72
|
+
isAutoincrement: false;
|
|
73
|
+
hasRuntimeDefault: false;
|
|
74
|
+
enumValues: undefined;
|
|
75
|
+
baseColumn: never;
|
|
76
|
+
identity: undefined;
|
|
77
|
+
generated: undefined;
|
|
78
|
+
}, {}, {
|
|
79
|
+
$type: Record<string, unknown>;
|
|
80
|
+
}>;
|
|
81
|
+
organization_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
82
|
+
name: "organization_id";
|
|
83
|
+
tableName: "auth_audit_events";
|
|
84
|
+
dataType: "string";
|
|
85
|
+
columnType: "PgVarchar";
|
|
86
|
+
data: string;
|
|
87
|
+
driverParam: string;
|
|
88
|
+
notNull: false;
|
|
89
|
+
hasDefault: false;
|
|
90
|
+
isPrimaryKey: false;
|
|
91
|
+
isAutoincrement: false;
|
|
92
|
+
hasRuntimeDefault: false;
|
|
93
|
+
enumValues: [string, ...string[]];
|
|
94
|
+
baseColumn: never;
|
|
95
|
+
identity: undefined;
|
|
96
|
+
generated: undefined;
|
|
97
|
+
}, {}, {
|
|
98
|
+
length: 255;
|
|
99
|
+
}>;
|
|
100
|
+
type: import("drizzle-orm/pg-core").PgColumn<{
|
|
101
|
+
name: "type";
|
|
102
|
+
tableName: "auth_audit_events";
|
|
103
|
+
dataType: "string";
|
|
104
|
+
columnType: "PgVarchar";
|
|
105
|
+
data: string;
|
|
106
|
+
driverParam: string;
|
|
107
|
+
notNull: true;
|
|
108
|
+
hasDefault: false;
|
|
109
|
+
isPrimaryKey: false;
|
|
110
|
+
isAutoincrement: false;
|
|
111
|
+
hasRuntimeDefault: false;
|
|
112
|
+
enumValues: [string, ...string[]];
|
|
113
|
+
baseColumn: never;
|
|
114
|
+
identity: undefined;
|
|
115
|
+
generated: undefined;
|
|
116
|
+
}, {}, {
|
|
117
|
+
length: 64;
|
|
118
|
+
}>;
|
|
119
|
+
user_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
120
|
+
name: "user_id";
|
|
121
|
+
tableName: "auth_audit_events";
|
|
122
|
+
dataType: "string";
|
|
123
|
+
columnType: "PgVarchar";
|
|
124
|
+
data: string;
|
|
125
|
+
driverParam: string;
|
|
126
|
+
notNull: false;
|
|
127
|
+
hasDefault: false;
|
|
128
|
+
isPrimaryKey: false;
|
|
129
|
+
isAutoincrement: false;
|
|
130
|
+
hasRuntimeDefault: false;
|
|
131
|
+
enumValues: [string, ...string[]];
|
|
132
|
+
baseColumn: never;
|
|
133
|
+
identity: undefined;
|
|
134
|
+
generated: undefined;
|
|
135
|
+
}, {}, {
|
|
136
|
+
length: 255;
|
|
137
|
+
}>;
|
|
138
|
+
};
|
|
139
|
+
dialect: "pg";
|
|
140
|
+
}>;
|
|
141
|
+
export declare const createNeonAuditSink: (databaseUrl: string) => AuditSink;
|
|
142
|
+
export declare const createPostgresAuditSink: (db: AnyPgDatabase) => AuditSink;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OrganizationId } from '../tenancy';
|
|
2
|
+
export type AuditEventType = 'credentials_login' | 'credentials_login_failed' | 'email_verified' | 'identity_conflict' | 'logout' | 'mfa_challenge' | 'mfa_challenge_failed' | 'mfa_enrolled' | 'oauth_login' | 'password_reset' | 'register' | 'scim_provision' | 'session_revoked' | 'sso_login' | 'token_refreshed' | 'token_revoked';
|
|
3
|
+
export type AuditEvent = {
|
|
4
|
+
at: number;
|
|
5
|
+
ip?: string;
|
|
6
|
+
metadata?: Record<string, unknown>;
|
|
7
|
+
organizationId?: OrganizationId;
|
|
8
|
+
type: AuditEventType;
|
|
9
|
+
userId?: string;
|
|
10
|
+
};
|
|
11
|
+
export type AuditEventFilter = {
|
|
12
|
+
limit?: number;
|
|
13
|
+
userId?: string;
|
|
14
|
+
};
|
|
15
|
+
export type AuditSink = {
|
|
16
|
+
append: (event: AuditEvent) => Promise<void>;
|
|
17
|
+
list?: (filter?: AuditEventFilter) => Promise<AuditEvent[]>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CredentialsConfig } from '../credentials/config';
|
|
2
|
+
import type { MfaConfig } from '../mfa/config';
|
|
3
|
+
import type { OnCallbackSuccess, OnRevocationSuccess, OnSignOut } from '../types';
|
|
4
|
+
import type { AuditEmitter } from './config';
|
|
5
|
+
export declare const composeCallbackAudit: <UserType>(onCallbackSuccess: OnCallbackSuccess<UserType>, emit: AuditEmitter) => (context: Parameters<NonNullable<OnCallbackSuccess<UserType>>>[0]) => Promise<void | Response | import("..").StatusReturn | undefined>;
|
|
6
|
+
export declare const composeCredentialsAudit: <UserType>(credentials: CredentialsConfig<UserType>, emit: AuditEmitter, getUserId?: (user: UserType) => string) => CredentialsConfig<UserType>;
|
|
7
|
+
export declare const composeMfaAudit: <UserType>(mfa: MfaConfig<UserType>, emit: AuditEmitter) => MfaConfig<UserType>;
|
|
8
|
+
export declare const composeRevocationAudit: (onRevocationSuccess: OnRevocationSuccess, emit: AuditEmitter) => (context: Parameters<NonNullable<OnRevocationSuccess>>[0]) => Promise<void | undefined>;
|
|
9
|
+
export declare const composeSignOutAudit: <UserType>(onSignOut: OnSignOut<UserType>, emit: AuditEmitter) => (context: Parameters<NonNullable<OnSignOut<UserType>>>[0]) => Promise<void | undefined>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { LockoutGuard } from '../lockout/config';
|
|
2
|
+
import type { AuthSessionStore } from '../session/types';
|
|
3
|
+
import type { OrganizationId } from '../tenancy';
|
|
4
|
+
import type { RouteString, StatusReturn, UserSessionId } from '../types';
|
|
5
|
+
import type { PasswordPolicy } from './passwordPolicy';
|
|
6
|
+
import type { CredentialStore } from './types';
|
|
7
|
+
export declare const DEFAULT_CREDENTIAL_SESSION_TTL_MS: number;
|
|
8
|
+
export declare const DEFAULT_RESET_TOKEN_TTL_MS: number;
|
|
9
|
+
export declare const DEFAULT_VERIFICATION_TOKEN_TTL_MS: number;
|
|
10
|
+
export type CredentialIdentity = {
|
|
11
|
+
email: string;
|
|
12
|
+
organizationId?: OrganizationId;
|
|
13
|
+
};
|
|
14
|
+
export type CredentialEmailType = 'reset_password' | 'verify_email';
|
|
15
|
+
export type CredentialEmailMessage = {
|
|
16
|
+
email: string;
|
|
17
|
+
expiresAt: number;
|
|
18
|
+
token: string;
|
|
19
|
+
type: CredentialEmailType;
|
|
20
|
+
};
|
|
21
|
+
export type CredentialsConfig<UserType> = {
|
|
22
|
+
credentialStore: CredentialStore;
|
|
23
|
+
getUserByEmail: (email: string) => Promise<UserType | null | undefined> | UserType | null | undefined;
|
|
24
|
+
isMfaRequired?: (user: UserType) => boolean | Promise<boolean>;
|
|
25
|
+
loginRoute?: RouteString;
|
|
26
|
+
onCreateCredentialUser: (identity: CredentialIdentity & Record<string, unknown>) => Promise<Response | StatusReturn | UserType> | Response | StatusReturn | UserType;
|
|
27
|
+
onCredentialsLoginError?: (context: {
|
|
28
|
+
email: string;
|
|
29
|
+
error: unknown;
|
|
30
|
+
}) => void | Promise<void>;
|
|
31
|
+
onCredentialsLoginSuccess?: (context: {
|
|
32
|
+
user: UserType;
|
|
33
|
+
userSessionId: UserSessionId;
|
|
34
|
+
}) => void | Promise<void>;
|
|
35
|
+
onEmailVerified?: (context: {
|
|
36
|
+
email: string;
|
|
37
|
+
}) => void | Promise<void>;
|
|
38
|
+
onPasswordReset?: (context: {
|
|
39
|
+
email: string;
|
|
40
|
+
}) => void | Promise<void>;
|
|
41
|
+
onRegistrationSuccess?: (context: {
|
|
42
|
+
email: string;
|
|
43
|
+
user: UserType;
|
|
44
|
+
}) => void | Promise<void>;
|
|
45
|
+
onSendEmail: (message: CredentialEmailMessage) => void | Promise<void>;
|
|
46
|
+
passwordPolicy?: PasswordPolicy;
|
|
47
|
+
registerRoute?: RouteString;
|
|
48
|
+
/** When true, registration creates the account but NOT a session, and login is
|
|
49
|
+
* rejected until the email is verified. Default false = auto-login on register and
|
|
50
|
+
* verification acts as a soft, later gate. */
|
|
51
|
+
requireEmailVerification?: boolean;
|
|
52
|
+
resetPasswordRoute?: RouteString;
|
|
53
|
+
resetTokenDurationMs?: number;
|
|
54
|
+
sessionDurationMs?: number;
|
|
55
|
+
verificationTokenDurationMs?: number;
|
|
56
|
+
verifyEmailRoute?: RouteString;
|
|
57
|
+
};
|
|
58
|
+
export type CredentialRouteProps<UserType> = CredentialsConfig<UserType> & {
|
|
59
|
+
authSessionStore?: AuthSessionStore<UserType>;
|
|
60
|
+
lockoutGuard?: LockoutGuard;
|
|
61
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type CredentialsConfig } from './config';
|
|
3
|
+
export declare const credentialsEmailVerification: <UserType>({ credentialStore, onEmailVerified, onSendEmail, verificationTokenDurationMs, verifyEmailRoute }: CredentialsConfig<UserType>) => Elysia<"", {
|
|
4
|
+
decorator: {};
|
|
5
|
+
store: {};
|
|
6
|
+
derive: {};
|
|
7
|
+
resolve: {};
|
|
8
|
+
}, {
|
|
9
|
+
typebox: {};
|
|
10
|
+
error: {};
|
|
11
|
+
}, {
|
|
12
|
+
schema: {};
|
|
13
|
+
standaloneSchema: {};
|
|
14
|
+
macro: {};
|
|
15
|
+
macroFn: {};
|
|
16
|
+
parser: {};
|
|
17
|
+
response: {};
|
|
18
|
+
}, {
|
|
19
|
+
[x: string]: {
|
|
20
|
+
post: {
|
|
21
|
+
body: {
|
|
22
|
+
token: string;
|
|
23
|
+
};
|
|
24
|
+
params: {};
|
|
25
|
+
query: unknown;
|
|
26
|
+
headers: unknown;
|
|
27
|
+
response: {
|
|
28
|
+
200: {
|
|
29
|
+
readonly status: "email_verified";
|
|
30
|
+
};
|
|
31
|
+
400: "Invalid or expired verification token";
|
|
32
|
+
422: {
|
|
33
|
+
type: "validation";
|
|
34
|
+
on: string;
|
|
35
|
+
summary?: string;
|
|
36
|
+
message?: string;
|
|
37
|
+
found?: unknown;
|
|
38
|
+
property?: string;
|
|
39
|
+
expected?: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
} & {
|
|
45
|
+
[x: string]: {
|
|
46
|
+
request: {
|
|
47
|
+
post: {
|
|
48
|
+
body: {
|
|
49
|
+
email: string;
|
|
50
|
+
};
|
|
51
|
+
params: {};
|
|
52
|
+
query: unknown;
|
|
53
|
+
headers: unknown;
|
|
54
|
+
response: {
|
|
55
|
+
200: {
|
|
56
|
+
readonly status: "verification_requested";
|
|
57
|
+
};
|
|
58
|
+
422: {
|
|
59
|
+
type: "validation";
|
|
60
|
+
on: string;
|
|
61
|
+
summary?: string;
|
|
62
|
+
message?: string;
|
|
63
|
+
found?: unknown;
|
|
64
|
+
property?: string;
|
|
65
|
+
expected?: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}, {
|
|
72
|
+
derive: {};
|
|
73
|
+
resolve: {};
|
|
74
|
+
schema: {};
|
|
75
|
+
standaloneSchema: {};
|
|
76
|
+
response: {};
|
|
77
|
+
}, {
|
|
78
|
+
derive: {};
|
|
79
|
+
resolve: {};
|
|
80
|
+
schema: {};
|
|
81
|
+
standaloneSchema: {};
|
|
82
|
+
response: {};
|
|
83
|
+
}>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type CredentialRouteProps } from './config';
|
|
3
|
+
export declare const credentialsLogin: <UserType>({ authSessionStore, credentialStore, getUserByEmail, isMfaRequired, lockoutGuard, loginRoute, onCredentialsLoginError, onCredentialsLoginSuccess, requireEmailVerification, sessionDurationMs }: CredentialRouteProps<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: {
|
|
25
|
+
email: string;
|
|
26
|
+
password: string;
|
|
27
|
+
};
|
|
28
|
+
params: {};
|
|
29
|
+
query: unknown;
|
|
30
|
+
headers: unknown;
|
|
31
|
+
response: {
|
|
32
|
+
200: {
|
|
33
|
+
readonly status: "mfa_required";
|
|
34
|
+
} | {
|
|
35
|
+
readonly status: "authenticated";
|
|
36
|
+
};
|
|
37
|
+
401: "Invalid email or password";
|
|
38
|
+
403: {
|
|
39
|
+
readonly status: "email_not_verified";
|
|
40
|
+
};
|
|
41
|
+
422: {
|
|
42
|
+
type: "validation";
|
|
43
|
+
on: string;
|
|
44
|
+
summary?: string;
|
|
45
|
+
message?: string;
|
|
46
|
+
found?: unknown;
|
|
47
|
+
property?: string;
|
|
48
|
+
expected?: string;
|
|
49
|
+
};
|
|
50
|
+
429: {
|
|
51
|
+
readonly retryAfterMs: number | undefined;
|
|
52
|
+
readonly status: "account_locked";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}, {
|
|
58
|
+
derive: {};
|
|
59
|
+
resolve: {};
|
|
60
|
+
schema: {};
|
|
61
|
+
standaloneSchema: {};
|
|
62
|
+
response: {};
|
|
63
|
+
}, {
|
|
64
|
+
derive: {};
|
|
65
|
+
resolve: {};
|
|
66
|
+
schema: {};
|
|
67
|
+
standaloneSchema: {};
|
|
68
|
+
response: {};
|
|
69
|
+
} & {
|
|
70
|
+
derive: {};
|
|
71
|
+
resolve: {};
|
|
72
|
+
schema: {};
|
|
73
|
+
standaloneSchema: {};
|
|
74
|
+
response: {};
|
|
75
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type PasswordPolicy = {
|
|
2
|
+
checkBreaches?: boolean;
|
|
3
|
+
minLength?: number;
|
|
4
|
+
requireDigit?: boolean;
|
|
5
|
+
requireLowercase?: boolean;
|
|
6
|
+
requireSymbol?: boolean;
|
|
7
|
+
requireUppercase?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type PasswordPolicyViolation = 'breached' | 'missing_digit' | 'missing_lowercase' | 'missing_symbol' | 'missing_uppercase' | 'too_short';
|
|
10
|
+
export type PasswordPolicyResult = {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
violations: PasswordPolicyViolation[];
|
|
13
|
+
};
|
|
14
|
+
export declare const evaluatePassword: (password: string, policy?: PasswordPolicy) => Promise<PasswordPolicyResult>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type CredentialsConfig } from './config';
|
|
3
|
+
export declare const credentialsPasswordReset: <UserType>({ credentialStore, onPasswordReset, onSendEmail, passwordPolicy, resetPasswordRoute, resetTokenDurationMs }: CredentialsConfig<UserType>) => Elysia<"", {
|
|
4
|
+
decorator: {};
|
|
5
|
+
store: {};
|
|
6
|
+
derive: {};
|
|
7
|
+
resolve: {};
|
|
8
|
+
}, {
|
|
9
|
+
typebox: {};
|
|
10
|
+
error: {};
|
|
11
|
+
}, {
|
|
12
|
+
schema: {};
|
|
13
|
+
standaloneSchema: {};
|
|
14
|
+
macro: {};
|
|
15
|
+
macroFn: {};
|
|
16
|
+
parser: {};
|
|
17
|
+
response: {};
|
|
18
|
+
}, {
|
|
19
|
+
[x: string]: {
|
|
20
|
+
request: {
|
|
21
|
+
post: {
|
|
22
|
+
body: {
|
|
23
|
+
email: string;
|
|
24
|
+
};
|
|
25
|
+
params: {};
|
|
26
|
+
query: unknown;
|
|
27
|
+
headers: unknown;
|
|
28
|
+
response: {
|
|
29
|
+
200: {
|
|
30
|
+
readonly status: "reset_requested";
|
|
31
|
+
};
|
|
32
|
+
422: {
|
|
33
|
+
type: "validation";
|
|
34
|
+
on: string;
|
|
35
|
+
summary?: string;
|
|
36
|
+
message?: string;
|
|
37
|
+
found?: unknown;
|
|
38
|
+
property?: string;
|
|
39
|
+
expected?: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
} & {
|
|
46
|
+
[x: string]: {
|
|
47
|
+
post: {
|
|
48
|
+
body: {
|
|
49
|
+
token: string;
|
|
50
|
+
password: string;
|
|
51
|
+
};
|
|
52
|
+
params: {};
|
|
53
|
+
query: unknown;
|
|
54
|
+
headers: unknown;
|
|
55
|
+
response: {
|
|
56
|
+
200: {
|
|
57
|
+
readonly status: "password_reset";
|
|
58
|
+
};
|
|
59
|
+
400: "Invalid or expired reset token" | {
|
|
60
|
+
readonly message: "Password does not meet the policy";
|
|
61
|
+
readonly violations: import("./passwordPolicy").PasswordPolicyViolation[];
|
|
62
|
+
};
|
|
63
|
+
422: {
|
|
64
|
+
type: "validation";
|
|
65
|
+
on: string;
|
|
66
|
+
summary?: string;
|
|
67
|
+
message?: string;
|
|
68
|
+
found?: unknown;
|
|
69
|
+
property?: string;
|
|
70
|
+
expected?: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}, {
|
|
76
|
+
derive: {};
|
|
77
|
+
resolve: {};
|
|
78
|
+
schema: {};
|
|
79
|
+
standaloneSchema: {};
|
|
80
|
+
response: {};
|
|
81
|
+
}, {
|
|
82
|
+
derive: {};
|
|
83
|
+
resolve: {};
|
|
84
|
+
schema: {};
|
|
85
|
+
standaloneSchema: {};
|
|
86
|
+
response: {};
|
|
87
|
+
}>;
|