@absolutejs/auth 0.27.0-beta.5 → 0.27.0-beta.6
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/credentials/emailValidation.d.ts +9 -0
- package/dist/credentials/passwordPolicy.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +141 -1
- package/dist/index.js.map +9 -6
- package/dist/session/anonymous.d.ts +11 -0
- package/dist/session/multiSession.d.ts +25 -0
- package/dist/session/promote.d.ts +2 -1
- package/dist/types.d.ts +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type EmailValidationResult = {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
reason?: 'disposable' | 'invalid_format' | 'no_mx';
|
|
4
|
+
};
|
|
5
|
+
export declare const isDisposableEmail: (email: string, extraDomains?: Iterable<string>) => boolean;
|
|
6
|
+
export declare const validateEmailDeliverability: (email: string, options?: {
|
|
7
|
+
checkMx?: boolean;
|
|
8
|
+
disposableDomains?: Iterable<string>;
|
|
9
|
+
}) => Promise<EmailValidationResult>;
|
|
@@ -12,3 +12,4 @@ export type PasswordPolicyResult = {
|
|
|
12
12
|
violations: PasswordPolicyViolation[];
|
|
13
13
|
};
|
|
14
14
|
export declare const evaluatePassword: (password: string, policy?: PasswordPolicy) => Promise<PasswordPolicyResult>;
|
|
15
|
+
export declare const isPasswordCompromised: (password: string) => Promise<boolean>;
|
package/dist/index.d.ts
CHANGED
|
@@ -14652,6 +14652,8 @@ export { sessionRoutes } from './routes/sessions';
|
|
|
14652
14652
|
export { stepUpPlugin } from './routes/stepUp';
|
|
14653
14653
|
export * from './session/sessionsConfig';
|
|
14654
14654
|
export { endImpersonation, isImpersonating, startImpersonation } from './session/impersonation';
|
|
14655
|
+
export { createAnonymousSession, isAnonymousSession } from './session/anonymous';
|
|
14656
|
+
export { addToSessionRing, listRingSessions, readSessionRing, removeFromSessionRing, switchActiveSession } from './session/multiSession';
|
|
14655
14657
|
export { listUserSessions, revokeUserSessions } from './session/userSessions';
|
|
14656
14658
|
export type { UserSession } from './session/userSessions';
|
|
14657
14659
|
export { sessionCleanup } from './session/cleanup';
|
|
@@ -14666,6 +14668,7 @@ export * from './crypto';
|
|
|
14666
14668
|
export * from './tenancy';
|
|
14667
14669
|
export * from './credentials/config';
|
|
14668
14670
|
export * from './credentials/passwordPolicy';
|
|
14671
|
+
export * from './credentials/emailValidation';
|
|
14669
14672
|
export * from './credentials/types';
|
|
14670
14673
|
export { credentialRoutes } from './credentials/routes';
|
|
14671
14674
|
export { credentialsEmailVerification } from './credentials/emailVerification';
|
package/dist/index.js
CHANGED
|
@@ -3213,6 +3213,7 @@ var persistWhen = async (shouldPersist, persist) => {
|
|
|
3213
3213
|
await persist();
|
|
3214
3214
|
};
|
|
3215
3215
|
var promoteToSession = async ({
|
|
3216
|
+
anonymous,
|
|
3216
3217
|
authSessionStore,
|
|
3217
3218
|
cookie,
|
|
3218
3219
|
impersonator,
|
|
@@ -3236,6 +3237,8 @@ var promoteToSession = async ({
|
|
|
3236
3237
|
data.samlLogout = samlLogout;
|
|
3237
3238
|
if (impersonator !== undefined)
|
|
3238
3239
|
data.impersonator = impersonator;
|
|
3240
|
+
if (anonymous === true)
|
|
3241
|
+
data.anonymous = true;
|
|
3239
3242
|
targetSession[userSessionId] = data;
|
|
3240
3243
|
cookie.set({
|
|
3241
3244
|
httpOnly: true,
|
|
@@ -3512,6 +3515,7 @@ var evaluatePassword = async (password, policy = {}) => {
|
|
|
3512
3515
|
}
|
|
3513
3516
|
return { ok: violations.length === 0, violations };
|
|
3514
3517
|
};
|
|
3518
|
+
var isPasswordCompromised = (password) => isPasswordBreached(password);
|
|
3515
3519
|
|
|
3516
3520
|
// src/credentials/passwordReset.ts
|
|
3517
3521
|
var credentialsPasswordReset = ({
|
|
@@ -18141,6 +18145,90 @@ var startImpersonation = async ({
|
|
|
18141
18145
|
});
|
|
18142
18146
|
return sessionId;
|
|
18143
18147
|
};
|
|
18148
|
+
// src/session/anonymous.ts
|
|
18149
|
+
var DEFAULT_GUEST_TTL_MS = MILLISECONDS_IN_A_DAY;
|
|
18150
|
+
var createAnonymousSession = async ({
|
|
18151
|
+
authSessionStore,
|
|
18152
|
+
cookie,
|
|
18153
|
+
guestUser,
|
|
18154
|
+
inMemorySession,
|
|
18155
|
+
sessionDurationMs = DEFAULT_GUEST_TTL_MS
|
|
18156
|
+
}) => promoteToSession({
|
|
18157
|
+
anonymous: true,
|
|
18158
|
+
authSessionStore,
|
|
18159
|
+
cookie,
|
|
18160
|
+
inMemorySession,
|
|
18161
|
+
sessionDurationMs,
|
|
18162
|
+
user: guestUser
|
|
18163
|
+
});
|
|
18164
|
+
var isAnonymousSession = (session) => session?.anonymous === true;
|
|
18165
|
+
// src/session/multiSession.ts
|
|
18166
|
+
var SEPARATOR = " ";
|
|
18167
|
+
var writeRing = (ring, ids) => ring.set({
|
|
18168
|
+
httpOnly: true,
|
|
18169
|
+
sameSite: "lax",
|
|
18170
|
+
secure: true,
|
|
18171
|
+
value: ids.join(SEPARATOR)
|
|
18172
|
+
});
|
|
18173
|
+
var readRing = (ring) => (ring.value ?? "").split(SEPARATOR).filter((entry) => isUserSessionId(entry));
|
|
18174
|
+
var addToSessionRing = (ring, sessionId) => writeRing(ring, [...new Set([...readRing(ring), sessionId])]);
|
|
18175
|
+
var listRingSessions = async ({
|
|
18176
|
+
authSessionStore,
|
|
18177
|
+
inMemorySession,
|
|
18178
|
+
ring
|
|
18179
|
+
}) => {
|
|
18180
|
+
const resolved = await Promise.all(readRing(ring).map(async (sessionId) => {
|
|
18181
|
+
const session = await loadSessionFromSource({
|
|
18182
|
+
authSessionStore,
|
|
18183
|
+
session: inMemorySession,
|
|
18184
|
+
userSessionId: sessionId
|
|
18185
|
+
});
|
|
18186
|
+
return session === undefined ? undefined : { sessionId, user: session.user };
|
|
18187
|
+
}));
|
|
18188
|
+
return resolved.filter((entry) => entry !== undefined);
|
|
18189
|
+
};
|
|
18190
|
+
var readSessionRing = (ring) => readRing(ring);
|
|
18191
|
+
var removeFromSessionRing = async ({
|
|
18192
|
+
activeCookie,
|
|
18193
|
+
authSessionStore,
|
|
18194
|
+
inMemorySession,
|
|
18195
|
+
ring,
|
|
18196
|
+
sessionId
|
|
18197
|
+
}) => {
|
|
18198
|
+
const remaining = readRing(ring).filter((id) => id !== sessionId);
|
|
18199
|
+
writeRing(ring, remaining);
|
|
18200
|
+
if (authSessionStore)
|
|
18201
|
+
await authSessionStore.removeSession(sessionId);
|
|
18202
|
+
else if (inMemorySession)
|
|
18203
|
+
delete inMemorySession[sessionId];
|
|
18204
|
+
if (activeCookie?.value !== sessionId)
|
|
18205
|
+
return;
|
|
18206
|
+
const [fallback] = remaining;
|
|
18207
|
+
if (fallback === undefined)
|
|
18208
|
+
activeCookie.remove();
|
|
18209
|
+
else
|
|
18210
|
+
activeCookie.set({
|
|
18211
|
+
httpOnly: true,
|
|
18212
|
+
sameSite: "lax",
|
|
18213
|
+
secure: true,
|
|
18214
|
+
value: fallback
|
|
18215
|
+
});
|
|
18216
|
+
};
|
|
18217
|
+
var switchActiveSession = ({
|
|
18218
|
+
activeCookie,
|
|
18219
|
+
ring,
|
|
18220
|
+
sessionId
|
|
18221
|
+
}) => {
|
|
18222
|
+
if (!readRing(ring).includes(sessionId))
|
|
18223
|
+
return false;
|
|
18224
|
+
activeCookie.set({
|
|
18225
|
+
httpOnly: true,
|
|
18226
|
+
sameSite: "lax",
|
|
18227
|
+
secure: true,
|
|
18228
|
+
value: sessionId
|
|
18229
|
+
});
|
|
18230
|
+
return true;
|
|
18231
|
+
};
|
|
18144
18232
|
// src/utils.ts
|
|
18145
18233
|
var defineAuthConfig = (configuration) => configuration;
|
|
18146
18234
|
var defineAuthHtmxConfig = (htmxConfig) => htmxConfig;
|
|
@@ -18316,6 +18404,48 @@ var getUserSessionId = ({
|
|
|
18316
18404
|
};
|
|
18317
18405
|
// src/tenancy.ts
|
|
18318
18406
|
var hasOrganizationScope = (value) => typeof value.organizationId === "string" && value.organizationId.length > 0;
|
|
18407
|
+
// src/credentials/emailValidation.ts
|
|
18408
|
+
import { resolveMx } from "dns/promises";
|
|
18409
|
+
var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/u;
|
|
18410
|
+
var DISPOSABLE_DOMAINS = new Set([
|
|
18411
|
+
"10minutemail.com",
|
|
18412
|
+
"fakeinbox.com",
|
|
18413
|
+
"getnada.com",
|
|
18414
|
+
"guerrillamail.com",
|
|
18415
|
+
"mailinator.com",
|
|
18416
|
+
"maildrop.cc",
|
|
18417
|
+
"sharklasers.com",
|
|
18418
|
+
"temp-mail.org",
|
|
18419
|
+
"tempmail.com",
|
|
18420
|
+
"throwaway.email",
|
|
18421
|
+
"trashmail.com",
|
|
18422
|
+
"yopmail.com"
|
|
18423
|
+
]);
|
|
18424
|
+
var domainOf = (email) => email.slice(email.lastIndexOf("@") + 1).toLowerCase();
|
|
18425
|
+
var hasMxRecord = async (domain) => {
|
|
18426
|
+
try {
|
|
18427
|
+
return (await resolveMx(domain)).length > 0;
|
|
18428
|
+
} catch {
|
|
18429
|
+
return false;
|
|
18430
|
+
}
|
|
18431
|
+
};
|
|
18432
|
+
var isDisposableEmail = (email, extraDomains) => {
|
|
18433
|
+
const domain = domainOf(email);
|
|
18434
|
+
return DISPOSABLE_DOMAINS.has(domain) || extraDomains !== undefined && new Set(extraDomains).has(domain);
|
|
18435
|
+
};
|
|
18436
|
+
var validateEmailDeliverability = async (email, options) => {
|
|
18437
|
+
const normalized = email.trim().toLowerCase();
|
|
18438
|
+
if (!EMAIL_PATTERN.test(normalized)) {
|
|
18439
|
+
return { ok: false, reason: "invalid_format" };
|
|
18440
|
+
}
|
|
18441
|
+
if (isDisposableEmail(normalized, options?.disposableDomains)) {
|
|
18442
|
+
return { ok: false, reason: "disposable" };
|
|
18443
|
+
}
|
|
18444
|
+
if (options?.checkMx === true && !await hasMxRecord(domainOf(normalized))) {
|
|
18445
|
+
return { ok: false, reason: "no_mx" };
|
|
18446
|
+
}
|
|
18447
|
+
return { ok: true };
|
|
18448
|
+
};
|
|
18319
18449
|
// src/credentials/inMemoryCredentialStore.ts
|
|
18320
18450
|
var cloneCredential = (value) => ({
|
|
18321
18451
|
...value
|
|
@@ -20580,9 +20710,11 @@ export {
|
|
|
20580
20710
|
verifyApiKey,
|
|
20581
20711
|
verifyAccessToken,
|
|
20582
20712
|
validateSession,
|
|
20713
|
+
validateEmailDeliverability,
|
|
20583
20714
|
userSessionIdTypebox,
|
|
20584
20715
|
trustDevice,
|
|
20585
20716
|
toPublicJwk,
|
|
20717
|
+
switchActiveSession,
|
|
20586
20718
|
stepUpPlugin,
|
|
20587
20719
|
startImpersonation,
|
|
20588
20720
|
ssoDiscoveryRoute,
|
|
@@ -20612,8 +20744,10 @@ export {
|
|
|
20612
20744
|
resolveClientProviderEntry,
|
|
20613
20745
|
resolveAuthHtmxRenderers,
|
|
20614
20746
|
resolveApiPrincipal,
|
|
20747
|
+
removeFromSessionRing,
|
|
20615
20748
|
refreshableProviderOptions,
|
|
20616
20749
|
recordLoginAttempt,
|
|
20750
|
+
readSessionRing,
|
|
20617
20751
|
providers,
|
|
20618
20752
|
providerOptions,
|
|
20619
20753
|
protectRoutePlugin,
|
|
@@ -20642,6 +20776,7 @@ export {
|
|
|
20642
20776
|
listUserSessions,
|
|
20643
20777
|
listUserOrganizations,
|
|
20644
20778
|
listSubjects,
|
|
20779
|
+
listRingSessions,
|
|
20645
20780
|
knownDevicesTable,
|
|
20646
20781
|
jwkThumbprint,
|
|
20647
20782
|
issueTokenSet,
|
|
@@ -20652,11 +20787,14 @@ export {
|
|
|
20652
20787
|
isRevocableOAuth2Client,
|
|
20653
20788
|
isRefreshableProviderOption,
|
|
20654
20789
|
isRefreshableOAuth2Client,
|
|
20790
|
+
isPasswordCompromised,
|
|
20655
20791
|
isPKCEProviderOption,
|
|
20656
20792
|
isOIDCProviderOption,
|
|
20657
20793
|
isMfaEnrolled,
|
|
20658
20794
|
isImpersonating,
|
|
20795
|
+
isDisposableEmail,
|
|
20659
20796
|
isAuthIntent,
|
|
20797
|
+
isAnonymousSession,
|
|
20660
20798
|
inviteToOrganization,
|
|
20661
20799
|
instantiateUserSession,
|
|
20662
20800
|
hashToken,
|
|
@@ -20784,6 +20922,7 @@ export {
|
|
|
20784
20922
|
createAuditEmitter,
|
|
20785
20923
|
createApiKey,
|
|
20786
20924
|
createApiClient,
|
|
20925
|
+
createAnonymousSession,
|
|
20787
20926
|
createAbuseGuard,
|
|
20788
20927
|
consumeBackupCode,
|
|
20789
20928
|
constantTimeEqual,
|
|
@@ -20802,6 +20941,7 @@ export {
|
|
|
20802
20941
|
apiKeysTable,
|
|
20803
20942
|
apiKeysRoutes,
|
|
20804
20943
|
apiClientsTable,
|
|
20944
|
+
addToSessionRing,
|
|
20805
20945
|
accessTokensTable,
|
|
20806
20946
|
acceptInvitation,
|
|
20807
20947
|
WEBAUTHN_CHALLENGE_COOKIE,
|
|
@@ -20834,5 +20974,5 @@ export {
|
|
|
20834
20974
|
AuthIdentityConflictError
|
|
20835
20975
|
};
|
|
20836
20976
|
|
|
20837
|
-
//# debugId=
|
|
20977
|
+
//# debugId=D6A51261327D341C64756E2164756E21
|
|
20838
20978
|
//# sourceMappingURL=index.js.map
|