@absolutejs/auth 0.30.0 → 0.32.0
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/config.d.ts +1 -0
- package/dist/credentials/login.d.ts +1 -1
- package/dist/credentials/register.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +354 -309
- package/dist/index.js.map +22 -22
- package/dist/mfa/challenge.d.ts +1 -1
- package/dist/mfa/config.d.ts +1 -0
- package/dist/passwordless/config.d.ts +1 -0
- package/dist/passwordless/routes.d.ts +1 -1
- package/dist/routes/authorize.d.ts +2 -1
- package/dist/routes/signout.d.ts +1 -1
- package/dist/session/anonymous.d.ts +2 -1
- package/dist/session/impersonation.d.ts +4 -2
- package/dist/session/multiSession.d.ts +5 -3
- package/dist/session/promote.d.ts +2 -1
- package/dist/sso/oidcRoutes.d.ts +2 -1
- package/dist/sso/samlRoutes.d.ts +2 -1
- package/dist/types.d.ts +14 -1
- package/dist/utils.d.ts +4 -2
- package/dist/webauthn/config.d.ts +1 -0
- package/dist/webauthn/routes.d.ts +1 -1
- package/package.json +1 -1
package/dist/mfa/challenge.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
2
|
import { type MfaRouteProps } from './config';
|
|
3
|
-
export declare const mfaChallenge: <UserType>({ authSessionStore, challengeRoute, encryptionKey, getChallengeUser, getUserId, mfaStore, onMfaChallengeError, onMfaChallengeSuccess, sessionDurationMs }: MfaRouteProps<UserType>) => Elysia<"", {
|
|
3
|
+
export declare const mfaChallenge: <UserType>({ authSessionStore, challengeRoute, cookieSecure, encryptionKey, getChallengeUser, getUserId, mfaStore, onMfaChallengeError, onMfaChallengeSuccess, sessionDurationMs }: MfaRouteProps<UserType>) => Elysia<"", {
|
|
4
4
|
decorator: {};
|
|
5
5
|
store: {
|
|
6
6
|
session: import("..").SessionRecord<UserType>;
|
package/dist/mfa/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
2
|
import type { SessionRecord } from '../types';
|
|
3
3
|
import { type PasswordlessRouteProps } from './config';
|
|
4
|
-
export declare const passwordlessRoutes: <UserType>({ authSessionStore, emit, getUserByEmail, getUserId, magicLinkTokenDurationMs, onCreateUser, onPasswordlessLogin, onSendMagicLink, onSendOtp, otpDurationMs, otpLength, passwordlessRoute, passwordlessTokenStore, sessionDurationMs }: PasswordlessRouteProps<UserType>) => Elysia<"", {
|
|
4
|
+
export declare const passwordlessRoutes: <UserType>({ authSessionStore, cookieSecure, emit, getUserByEmail, getUserId, magicLinkTokenDurationMs, onCreateUser, onPasswordlessLogin, onSendMagicLink, onSendOtp, otpDurationMs, otpLength, passwordlessRoute, passwordlessTokenStore, sessionDurationMs }: PasswordlessRouteProps<UserType>) => Elysia<"", {
|
|
5
5
|
decorator: {};
|
|
6
6
|
store: {} | {
|
|
7
7
|
session: SessionRecord<UserType>;
|
|
@@ -3,10 +3,11 @@ import { AuthorizeRoute, ClientProviders, OnAuthorizeError, OnAuthorizeSuccess }
|
|
|
3
3
|
type AuthorizeProps = {
|
|
4
4
|
clientProviders: ClientProviders;
|
|
5
5
|
authorizeRoute?: AuthorizeRoute;
|
|
6
|
+
cookieSecure?: boolean;
|
|
6
7
|
onAuthorizeSuccess: OnAuthorizeSuccess;
|
|
7
8
|
onAuthorizeError: OnAuthorizeError;
|
|
8
9
|
};
|
|
9
|
-
export declare const authorize: ({ clientProviders, authorizeRoute, onAuthorizeSuccess, onAuthorizeError }: AuthorizeProps) => Elysia<"", {
|
|
10
|
+
export declare const authorize: ({ clientProviders, authorizeRoute, cookieSecure, onAuthorizeSuccess, onAuthorizeError }: AuthorizeProps) => Elysia<"", {
|
|
10
11
|
decorator: {};
|
|
11
12
|
store: {};
|
|
12
13
|
derive: {};
|
package/dist/routes/signout.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare const signout: <UserType>({ authSessionStore, signoutRoute, onSig
|
|
|
33
33
|
headers: unknown;
|
|
34
34
|
response: {
|
|
35
35
|
400: "Cookies are missing";
|
|
36
|
-
401: "No
|
|
36
|
+
401: "No user session id found";
|
|
37
37
|
200: Response;
|
|
38
38
|
422: {
|
|
39
39
|
type: "validation";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Cookie } from 'elysia';
|
|
2
2
|
import type { SessionData, SessionRecord, UserSessionId } from '../types';
|
|
3
3
|
import type { AuthSessionStore } from './types';
|
|
4
|
-
export declare const createAnonymousSession: <UserType>({ authSessionStore, cookie, guestUser, inMemorySession, sessionDurationMs }: {
|
|
4
|
+
export declare const createAnonymousSession: <UserType>({ authSessionStore, cookie, cookieSecure, guestUser, inMemorySession, sessionDurationMs }: {
|
|
5
5
|
authSessionStore?: AuthSessionStore<UserType>;
|
|
6
6
|
cookie: Cookie<UserSessionId | undefined>;
|
|
7
|
+
cookieSecure?: boolean;
|
|
7
8
|
guestUser: UserType;
|
|
8
9
|
inMemorySession: SessionRecord<UserType>;
|
|
9
10
|
sessionDurationMs?: number;
|
|
@@ -3,18 +3,20 @@ import type { AuditEvent } from '../audit/types';
|
|
|
3
3
|
import type { SessionData, SessionRecord, UserSessionId } from '../types';
|
|
4
4
|
import type { AuthSessionStore } from './types';
|
|
5
5
|
type Emit = (event: AuditEvent) => Promise<void> | void;
|
|
6
|
-
export declare const endImpersonation: <UserType>({ authSessionStore, cookie, emit, inMemorySession }: {
|
|
6
|
+
export declare const endImpersonation: <UserType>({ authSessionStore, cookie, cookieSecure, emit, inMemorySession }: {
|
|
7
7
|
authSessionStore?: AuthSessionStore<UserType>;
|
|
8
8
|
cookie: Cookie<UserSessionId | undefined>;
|
|
9
|
+
cookieSecure?: boolean;
|
|
9
10
|
emit?: Emit;
|
|
10
11
|
inMemorySession: SessionRecord<UserType>;
|
|
11
12
|
}) => Promise<{
|
|
12
13
|
restored: boolean;
|
|
13
14
|
}>;
|
|
14
15
|
export declare const isImpersonating: <UserType>(session: SessionData<UserType> | undefined) => boolean;
|
|
15
|
-
export declare const startImpersonation: <UserType>({ authSessionStore, cookie, emit, getUserId, impersonator, inMemorySession, sessionDurationMs, user }: {
|
|
16
|
+
export declare const startImpersonation: <UserType>({ authSessionStore, cookie, cookieSecure, emit, getUserId, impersonator, inMemorySession, sessionDurationMs, user }: {
|
|
16
17
|
authSessionStore?: AuthSessionStore<UserType>;
|
|
17
18
|
cookie: Cookie<UserSessionId | undefined>;
|
|
19
|
+
cookieSecure?: boolean;
|
|
18
20
|
emit?: Emit;
|
|
19
21
|
getUserId?: (user: UserType) => string;
|
|
20
22
|
impersonator: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Cookie } from 'elysia';
|
|
2
2
|
import type { SessionRecord, UserSessionId } from '../types';
|
|
3
3
|
import type { AuthSessionStore } from './types';
|
|
4
|
-
export declare const addToSessionRing: (ring: Cookie<string | undefined>, sessionId: UserSessionId) => Cookie<string | undefined>;
|
|
4
|
+
export declare const addToSessionRing: (ring: Cookie<string | undefined>, sessionId: UserSessionId, cookieSecure?: boolean) => Cookie<string | undefined>;
|
|
5
5
|
export declare const listRingSessions: <UserType>({ authSessionStore, inMemorySession, ring }: {
|
|
6
6
|
authSessionStore?: AuthSessionStore<UserType>;
|
|
7
7
|
inMemorySession?: SessionRecord<UserType>;
|
|
@@ -11,15 +11,17 @@ export declare const listRingSessions: <UserType>({ authSessionStore, inMemorySe
|
|
|
11
11
|
user: UserType;
|
|
12
12
|
}[]>;
|
|
13
13
|
export declare const readSessionRing: (ring: Cookie<string | undefined>) => `${string}-${string}-${string}-${string}-${string}`[];
|
|
14
|
-
export declare const removeFromSessionRing: <UserType>({ activeCookie, authSessionStore, inMemorySession, ring, sessionId }: {
|
|
14
|
+
export declare const removeFromSessionRing: <UserType>({ activeCookie, authSessionStore, cookieSecure, inMemorySession, ring, sessionId }: {
|
|
15
15
|
activeCookie?: Cookie<UserSessionId | undefined>;
|
|
16
16
|
authSessionStore?: AuthSessionStore<UserType>;
|
|
17
|
+
cookieSecure?: boolean;
|
|
17
18
|
inMemorySession?: SessionRecord<UserType>;
|
|
18
19
|
ring: Cookie<string | undefined>;
|
|
19
20
|
sessionId: UserSessionId;
|
|
20
21
|
}) => Promise<void>;
|
|
21
|
-
export declare const switchActiveSession: ({ activeCookie, ring, sessionId }: {
|
|
22
|
+
export declare const switchActiveSession: ({ activeCookie, cookieSecure, ring, sessionId }: {
|
|
22
23
|
activeCookie: Cookie<UserSessionId | undefined>;
|
|
24
|
+
cookieSecure?: boolean;
|
|
23
25
|
ring: Cookie<string | undefined>;
|
|
24
26
|
sessionId: UserSessionId;
|
|
25
27
|
}) => boolean;
|
|
@@ -12,11 +12,12 @@ type PromoteToSessionProps<UserType> = {
|
|
|
12
12
|
anonymous?: boolean;
|
|
13
13
|
authSessionStore?: AuthSessionStore<UserType>;
|
|
14
14
|
cookie: Cookie<UserSessionId | undefined>;
|
|
15
|
+
cookieSecure?: boolean;
|
|
15
16
|
impersonator?: SessionData<UserType>['impersonator'];
|
|
16
17
|
inMemorySession: SessionRecord<UserType>;
|
|
17
18
|
samlLogout?: SessionData<UserType>['samlLogout'];
|
|
18
19
|
sessionDurationMs: number;
|
|
19
20
|
user: UserType;
|
|
20
21
|
};
|
|
21
|
-
export declare const promoteToSession: <UserType>({ anonymous, authSessionStore, cookie, impersonator, inMemorySession, samlLogout, sessionDurationMs, user }: PromoteToSessionProps<UserType>) => Promise<`${string}-${string}-${string}-${string}-${string}`>;
|
|
22
|
+
export declare const promoteToSession: <UserType>({ anonymous, authSessionStore, cookie, cookieSecure, impersonator, inMemorySession, samlLogout, sessionDurationMs, user }: PromoteToSessionProps<UserType>) => Promise<`${string}-${string}-${string}-${string}-${string}`>;
|
|
22
23
|
export {};
|
package/dist/sso/oidcRoutes.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import type { AuthSessionStore } from '../session/types';
|
|
|
3
3
|
import { type SSOConfig } from './config';
|
|
4
4
|
type OidcRoutesProps<UserType> = SSOConfig<UserType> & {
|
|
5
5
|
authSessionStore?: AuthSessionStore<UserType>;
|
|
6
|
+
cookieSecure?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const oidcSsoRoutes: <UserType>({ authSessionStore, getSsoUser, onSsoCallbackError, onSsoCallbackSuccess, sessionDurationMs, ssoConnectionStore, ssoRoute }: OidcRoutesProps<UserType>) => Elysia<"", {
|
|
8
|
+
export declare const oidcSsoRoutes: <UserType>({ authSessionStore, cookieSecure, getSsoUser, onSsoCallbackError, onSsoCallbackSuccess, sessionDurationMs, ssoConnectionStore, ssoRoute }: OidcRoutesProps<UserType>) => Elysia<"", {
|
|
8
9
|
decorator: {};
|
|
9
10
|
store: {
|
|
10
11
|
session: import("..").SessionRecord<UserType>;
|
package/dist/sso/samlRoutes.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ import type { SessionRecord } from '../types';
|
|
|
4
4
|
import { type SamlAdapter, type SSOConfig } from './config';
|
|
5
5
|
type SamlRoutesProps<UserType> = SSOConfig<UserType> & {
|
|
6
6
|
authSessionStore?: AuthSessionStore<UserType>;
|
|
7
|
+
cookieSecure?: boolean;
|
|
7
8
|
samlAdapter: SamlAdapter;
|
|
8
9
|
};
|
|
9
|
-
export declare const samlSsoRoutes: <UserType>({ authSessionStore, getSsoUser, onSsoCallbackError, onSsoCallbackSuccess, samlAdapter, sessionDurationMs, ssoConnectionStore, ssoRoute }: SamlRoutesProps<UserType>) => Elysia<"", {
|
|
10
|
+
export declare const samlSsoRoutes: <UserType>({ authSessionStore, cookieSecure, getSsoUser, onSsoCallbackError, onSsoCallbackSuccess, samlAdapter, sessionDurationMs, ssoConnectionStore, ssoRoute }: SamlRoutesProps<UserType>) => Elysia<"", {
|
|
10
11
|
decorator: {};
|
|
11
12
|
store: {
|
|
12
13
|
session: SessionRecord<UserType>;
|
package/dist/types.d.ts
CHANGED
|
@@ -175,7 +175,11 @@ export type OnStatus<UserType> = (({ user }: {
|
|
|
175
175
|
user: UserType | null;
|
|
176
176
|
}) => void | Promise<void>) | undefined;
|
|
177
177
|
export type OnSignOut<UserType> = (({ authProvider, userSessionId, session }: {
|
|
178
|
-
|
|
178
|
+
/** Set only when the session was minted by the OAuth2 `/authorize` flow —
|
|
179
|
+
* credentials, MFA, passwordless, SSO, WebAuthn, and impersonation-minted
|
|
180
|
+
* sessions sign out without one. Use it to revoke the upstream provider
|
|
181
|
+
* token when present; ignore when undefined. */
|
|
182
|
+
authProvider: string | undefined;
|
|
179
183
|
userSessionId: UserSessionId;
|
|
180
184
|
session: SessionRecord<UserType>;
|
|
181
185
|
}) => void | Promise<void>) | undefined;
|
|
@@ -187,6 +191,14 @@ export type RouteString = `/${string}`;
|
|
|
187
191
|
export type AuthorizeRoute = `${string}/:provider${'' | `/${string}`}`;
|
|
188
192
|
export type AuthConfig<UserType> = {
|
|
189
193
|
providersConfiguration: OAuth2ConfigurationOptions;
|
|
194
|
+
/** Override the `Secure` attribute on every cookie the package sets (session, OAuth state,
|
|
195
|
+
* code_verifier, SSO nonce, ring, etc.). When omitted, defaults to
|
|
196
|
+
* `process.env.NODE_ENV === 'production'` — matching the convention used by
|
|
197
|
+
* express-session / iron-session / lucia / better-auth, and the only way non-browser
|
|
198
|
+
* HTTP clients (curl, SSR fetch, test runners) can round-trip cookies on a plain-HTTP
|
|
199
|
+
* dev server. If you run prod without setting `NODE_ENV=production`, set
|
|
200
|
+
* `cookieSecure: true` explicitly. */
|
|
201
|
+
cookieSecure?: boolean;
|
|
190
202
|
authorizeRoute?: AuthorizeRoute;
|
|
191
203
|
profileRoute?: RouteString;
|
|
192
204
|
callbackRoute?: RouteString;
|
|
@@ -332,6 +344,7 @@ export type InsantiateUserSessionProps<UserType> = {
|
|
|
332
344
|
user_session_id: Cookie<UserSessionId | undefined>;
|
|
333
345
|
onNewUser: OnNewUser<UserType>;
|
|
334
346
|
getUser: GetUser<UserType>;
|
|
347
|
+
cookieSecure?: boolean;
|
|
335
348
|
resolvedAuthorization?: ResolvedOAuthAuthorization;
|
|
336
349
|
sessionDurationMs?: number;
|
|
337
350
|
unregisteredSessionDurationMs?: number;
|
package/dist/utils.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export declare const getStatus: <UserType>(session: SessionRecord<UserType>, use
|
|
|
16
16
|
error: null;
|
|
17
17
|
user: NonNullable<UserType> | null;
|
|
18
18
|
}>;
|
|
19
|
-
export declare const instantiateUserSession: <UserType>({ authProvider, session, user_session_id, unregisteredSession, tokenResponse, providerInstance, getUser, onNewUser, resolvedAuthorization, sessionDurationMs, unregisteredSessionDurationMs }: InsantiateUserSessionProps<UserType>) => Promise<Response | import("./types").StatusReturn | undefined>;
|
|
19
|
+
export declare const instantiateUserSession: <UserType>({ authProvider, cookieSecure, session, user_session_id, unregisteredSession, tokenResponse, providerInstance, getUser, onNewUser, resolvedAuthorization, sessionDurationMs, unregisteredSessionDurationMs }: InsantiateUserSessionProps<UserType>) => Promise<Response | import("./types").StatusReturn | undefined>;
|
|
20
|
+
export declare const resolveCookieSecure: (override?: boolean) => boolean;
|
|
20
21
|
export declare const resolveOAuthAuthorization: ({ authProvider, providerInstance, tokenResponse, now }: {
|
|
21
22
|
authProvider: ProviderOption;
|
|
22
23
|
providerInstance: OAuth2Client<ProviderOption>;
|
|
@@ -34,9 +35,10 @@ export declare const validateSession: <SessionType extends Record<string, unknow
|
|
|
34
35
|
expiresAt: number;
|
|
35
36
|
}>({ user_session_id, session }: ValidateSessionProps<SessionType>) => SessionType | undefined;
|
|
36
37
|
type GetUserSessionIdProps<UserType> = {
|
|
38
|
+
cookieSecure?: boolean;
|
|
37
39
|
user_session_id: Cookie<UserSessionId | undefined>;
|
|
38
40
|
session?: SessionRecord<UserType>;
|
|
39
41
|
unregisteredSession?: UnregisteredSessionRecord;
|
|
40
42
|
};
|
|
41
|
-
export declare const getUserSessionId: <UserType>({ user_session_id, session, unregisteredSession }: GetUserSessionIdProps<UserType>) => `${string}-${string}-${string}-${string}-${string}`;
|
|
43
|
+
export declare const getUserSessionId: <UserType>({ cookieSecure, user_session_id, session, unregisteredSession }: GetUserSessionIdProps<UserType>) => `${string}-${string}-${string}-${string}-${string}`;
|
|
42
44
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Elysia } from 'elysia';
|
|
2
2
|
import { type WebAuthnRouteProps } from './config';
|
|
3
|
-
export declare const webauthnRoutes: <UserType>({ authSessionStore, challengeDurationMs, credentialStore, emit, getUserDisplayName, getUserId, getUserName, getWebAuthnUser, onWebAuthnAuthenticated, onWebAuthnRegistered, origin, rpId, rpName, sessionDurationMs, webauthnAdapter, webauthnRoute }: WebAuthnRouteProps<UserType>) => Elysia<"", {
|
|
3
|
+
export declare const webauthnRoutes: <UserType>({ authSessionStore, challengeDurationMs, cookieSecure, credentialStore, emit, getUserDisplayName, getUserId, getUserName, getWebAuthnUser, onWebAuthnAuthenticated, onWebAuthnRegistered, origin, rpId, rpName, sessionDurationMs, webauthnAdapter, webauthnRoute }: WebAuthnRouteProps<UserType>) => Elysia<"", {
|
|
4
4
|
decorator: {};
|
|
5
5
|
store: {
|
|
6
6
|
session: import("..").SessionRecord<UserType>;
|
package/package.json
CHANGED