@absolutejs/auth 0.30.0 → 0.31.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 +1 -1
- package/dist/index.js +351 -303
- package/dist/index.js.map +21 -21
- 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/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 +9 -0
- 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/index.js
CHANGED
|
@@ -3184,6 +3184,184 @@ var protectPermissionPlugin = ({
|
|
|
3184
3184
|
// src/compliance/routes.ts
|
|
3185
3185
|
import { Elysia as Elysia4, t as t4 } from "elysia";
|
|
3186
3186
|
|
|
3187
|
+
// src/utils.ts
|
|
3188
|
+
var defineAuthConfig = (configuration) => configuration;
|
|
3189
|
+
var defineAuthHtmxConfig = (htmxConfig) => htmxConfig;
|
|
3190
|
+
var defineAuthSettings = (settings) => settings;
|
|
3191
|
+
var defineProvidersConfiguration = (providersConfiguration) => providersConfiguration;
|
|
3192
|
+
var getStatus = async (session, user_session_id) => {
|
|
3193
|
+
if (user_session_id === undefined) {
|
|
3194
|
+
return {
|
|
3195
|
+
error: {
|
|
3196
|
+
code: "Bad Request",
|
|
3197
|
+
message: "Cookies are missing"
|
|
3198
|
+
},
|
|
3199
|
+
user: null
|
|
3200
|
+
};
|
|
3201
|
+
}
|
|
3202
|
+
const userSession = validateSession({ session, user_session_id });
|
|
3203
|
+
const user = userSession?.user ?? null;
|
|
3204
|
+
return {
|
|
3205
|
+
error: null,
|
|
3206
|
+
user
|
|
3207
|
+
};
|
|
3208
|
+
};
|
|
3209
|
+
var instantiateUserSession = async ({
|
|
3210
|
+
authProvider,
|
|
3211
|
+
cookieSecure,
|
|
3212
|
+
session,
|
|
3213
|
+
user_session_id,
|
|
3214
|
+
unregisteredSession,
|
|
3215
|
+
tokenResponse,
|
|
3216
|
+
providerInstance,
|
|
3217
|
+
getUser,
|
|
3218
|
+
onNewUser,
|
|
3219
|
+
resolvedAuthorization,
|
|
3220
|
+
sessionDurationMs = MILLISECONDS_IN_A_DAY,
|
|
3221
|
+
unregisteredSessionDurationMs = MILLISECONDS_IN_AN_HOUR
|
|
3222
|
+
}) => {
|
|
3223
|
+
const authorization = resolvedAuthorization ?? await resolveOAuthAuthorization({
|
|
3224
|
+
authProvider,
|
|
3225
|
+
providerInstance,
|
|
3226
|
+
tokenResponse
|
|
3227
|
+
});
|
|
3228
|
+
const { accessToken, refreshToken, userIdentity } = authorization;
|
|
3229
|
+
const userSession = validateSession({ session, user_session_id });
|
|
3230
|
+
const userSessionId = getUserSessionId({
|
|
3231
|
+
cookieSecure,
|
|
3232
|
+
session,
|
|
3233
|
+
unregisteredSession,
|
|
3234
|
+
user_session_id
|
|
3235
|
+
});
|
|
3236
|
+
let user = userSession?.user ?? await getUser(userIdentity);
|
|
3237
|
+
const response = user ?? await onNewUser(userIdentity);
|
|
3238
|
+
const isRedirectOrStatus = response instanceof Response || isStatusResponse(response);
|
|
3239
|
+
if (!isRedirectOrStatus) {
|
|
3240
|
+
user = response;
|
|
3241
|
+
session[userSessionId] = {
|
|
3242
|
+
accessToken,
|
|
3243
|
+
authenticatedAt: Date.now(),
|
|
3244
|
+
expiresAt: Date.now() + sessionDurationMs,
|
|
3245
|
+
refreshToken,
|
|
3246
|
+
user
|
|
3247
|
+
};
|
|
3248
|
+
return;
|
|
3249
|
+
}
|
|
3250
|
+
const existingUnregistered = unregisteredSession[userSessionId];
|
|
3251
|
+
if (existingUnregistered) {
|
|
3252
|
+
existingUnregistered.accessToken = accessToken;
|
|
3253
|
+
existingUnregistered.expiresAt = Date.now() + unregisteredSessionDurationMs;
|
|
3254
|
+
existingUnregistered.refreshToken = refreshToken;
|
|
3255
|
+
existingUnregistered.userIdentity = userIdentity;
|
|
3256
|
+
return response;
|
|
3257
|
+
}
|
|
3258
|
+
unregisteredSession[userSessionId] = {
|
|
3259
|
+
accessToken,
|
|
3260
|
+
expiresAt: Date.now() + unregisteredSessionDurationMs,
|
|
3261
|
+
refreshToken,
|
|
3262
|
+
userIdentity
|
|
3263
|
+
};
|
|
3264
|
+
return response;
|
|
3265
|
+
};
|
|
3266
|
+
var resolveCookieSecure = (override) => override ?? false;
|
|
3267
|
+
var resolveOAuthAuthorization = async ({
|
|
3268
|
+
authProvider,
|
|
3269
|
+
providerInstance,
|
|
3270
|
+
tokenResponse,
|
|
3271
|
+
now = Date.now()
|
|
3272
|
+
}) => {
|
|
3273
|
+
let userIdentity;
|
|
3274
|
+
let accessToken = tokenResponse.access_token;
|
|
3275
|
+
let refreshToken = tokenResponse.refresh_token;
|
|
3276
|
+
if (tokenResponse.id_token) {
|
|
3277
|
+
userIdentity = normalizeProviderIdentity({
|
|
3278
|
+
identity: decodeJWT(tokenResponse.id_token),
|
|
3279
|
+
providerConfiguration: providers[authProvider],
|
|
3280
|
+
source: "idToken"
|
|
3281
|
+
});
|
|
3282
|
+
} else if (authProvider === "withings") {
|
|
3283
|
+
userIdentity = { userid: tokenResponse.body.userid };
|
|
3284
|
+
accessToken = tokenResponse.body.access_token;
|
|
3285
|
+
refreshToken = tokenResponse.body.refresh_token;
|
|
3286
|
+
} else {
|
|
3287
|
+
userIdentity = normalizeProviderIdentity({
|
|
3288
|
+
identity: await providerInstance.fetchUserProfile(tokenResponse.access_token),
|
|
3289
|
+
providerConfiguration: providers[authProvider],
|
|
3290
|
+
source: "profile"
|
|
3291
|
+
});
|
|
3292
|
+
}
|
|
3293
|
+
const tokenType = Reflect.get(tokenResponse, "token_type");
|
|
3294
|
+
return {
|
|
3295
|
+
accessToken,
|
|
3296
|
+
expiresAt: resolveOAuthTokenExpiresAt(tokenResponse, now),
|
|
3297
|
+
refreshToken,
|
|
3298
|
+
tokenType: typeof tokenType === "string" ? tokenType : undefined,
|
|
3299
|
+
userIdentity
|
|
3300
|
+
};
|
|
3301
|
+
};
|
|
3302
|
+
var parseExpiresInSeconds = (expiresIn) => {
|
|
3303
|
+
if (typeof expiresIn === "number") {
|
|
3304
|
+
return expiresIn;
|
|
3305
|
+
}
|
|
3306
|
+
if (typeof expiresIn === "string" && expiresIn.trim().length > 0) {
|
|
3307
|
+
return Number(expiresIn);
|
|
3308
|
+
}
|
|
3309
|
+
return Number.NaN;
|
|
3310
|
+
};
|
|
3311
|
+
var resolveOAuthTokenExpiresAt = (tokenResponse, now = Date.now()) => {
|
|
3312
|
+
const expiresIn = Reflect.get(tokenResponse, "expires_in");
|
|
3313
|
+
const expiresInSeconds = parseExpiresInSeconds(expiresIn);
|
|
3314
|
+
if (!Number.isFinite(expiresInSeconds) || expiresInSeconds <= 0) {
|
|
3315
|
+
return;
|
|
3316
|
+
}
|
|
3317
|
+
return now + expiresInSeconds * 1000;
|
|
3318
|
+
};
|
|
3319
|
+
var validateSession = ({
|
|
3320
|
+
user_session_id,
|
|
3321
|
+
session
|
|
3322
|
+
}) => {
|
|
3323
|
+
const userSessionId = user_session_id.value;
|
|
3324
|
+
if (!userSessionId) {
|
|
3325
|
+
return;
|
|
3326
|
+
}
|
|
3327
|
+
const userSession = session[userSessionId];
|
|
3328
|
+
if (!userSession) {
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
const isExpired = userSession.expiresAt < Date.now();
|
|
3332
|
+
if (isExpired) {
|
|
3333
|
+
delete session[userSessionId];
|
|
3334
|
+
user_session_id.remove();
|
|
3335
|
+
return;
|
|
3336
|
+
}
|
|
3337
|
+
return userSession;
|
|
3338
|
+
};
|
|
3339
|
+
var clearExistingSession = (existingId, session, unregisteredSession) => {
|
|
3340
|
+
if (session)
|
|
3341
|
+
delete session[existingId];
|
|
3342
|
+
if (unregisteredSession)
|
|
3343
|
+
delete unregisteredSession[existingId];
|
|
3344
|
+
};
|
|
3345
|
+
var getUserSessionId = ({
|
|
3346
|
+
cookieSecure,
|
|
3347
|
+
user_session_id,
|
|
3348
|
+
session,
|
|
3349
|
+
unregisteredSession
|
|
3350
|
+
}) => {
|
|
3351
|
+
const existingId = user_session_id?.value;
|
|
3352
|
+
if (isNonEmptyString(existingId)) {
|
|
3353
|
+
clearExistingSession(existingId, session, unregisteredSession);
|
|
3354
|
+
}
|
|
3355
|
+
const userSessionId = crypto.randomUUID();
|
|
3356
|
+
user_session_id.set({
|
|
3357
|
+
httpOnly: true,
|
|
3358
|
+
sameSite: "lax",
|
|
3359
|
+
secure: resolveCookieSecure(cookieSecure),
|
|
3360
|
+
value: userSessionId
|
|
3361
|
+
});
|
|
3362
|
+
return userSessionId;
|
|
3363
|
+
};
|
|
3364
|
+
|
|
3187
3365
|
// src/session/promote.ts
|
|
3188
3366
|
var clearSession = async ({
|
|
3189
3367
|
authSessionStore,
|
|
@@ -3216,6 +3394,7 @@ var promoteToSession = async ({
|
|
|
3216
3394
|
anonymous,
|
|
3217
3395
|
authSessionStore,
|
|
3218
3396
|
cookie,
|
|
3397
|
+
cookieSecure,
|
|
3219
3398
|
impersonator,
|
|
3220
3399
|
inMemorySession,
|
|
3221
3400
|
samlLogout,
|
|
@@ -3243,7 +3422,7 @@ var promoteToSession = async ({
|
|
|
3243
3422
|
cookie.set({
|
|
3244
3423
|
httpOnly: true,
|
|
3245
3424
|
sameSite: "lax",
|
|
3246
|
-
secure:
|
|
3425
|
+
secure: resolveCookieSecure(cookieSecure),
|
|
3247
3426
|
value: userSessionId
|
|
3248
3427
|
});
|
|
3249
3428
|
if (authSessionStore) {
|
|
@@ -3549,6 +3728,7 @@ var isPasswordCompromised = (password) => isPasswordBreached(password);
|
|
|
3549
3728
|
var credentialsLogin = ({
|
|
3550
3729
|
authSessionStore,
|
|
3551
3730
|
checkBreachesOnLogin,
|
|
3731
|
+
cookieSecure,
|
|
3552
3732
|
credentialStore,
|
|
3553
3733
|
getUserByEmail,
|
|
3554
3734
|
isMfaRequired,
|
|
@@ -3620,7 +3800,7 @@ var credentialsLogin = ({
|
|
|
3620
3800
|
user_session_id.set({
|
|
3621
3801
|
httpOnly: true,
|
|
3622
3802
|
sameSite: "lax",
|
|
3623
|
-
secure:
|
|
3803
|
+
secure: resolveCookieSecure(cookieSecure),
|
|
3624
3804
|
value: pendingSessionId
|
|
3625
3805
|
});
|
|
3626
3806
|
await persistWhen(authSessionStore !== undefined, compatibilityLayer.persist);
|
|
@@ -3630,6 +3810,7 @@ var credentialsLogin = ({
|
|
|
3630
3810
|
const userSessionId = await promoteToSession({
|
|
3631
3811
|
authSessionStore,
|
|
3632
3812
|
cookie: user_session_id,
|
|
3813
|
+
cookieSecure,
|
|
3633
3814
|
inMemorySession: session,
|
|
3634
3815
|
sessionDurationMs,
|
|
3635
3816
|
user
|
|
@@ -3703,6 +3884,7 @@ var credentialsPasswordReset = ({
|
|
|
3703
3884
|
import { Elysia as Elysia8, t as t8 } from "elysia";
|
|
3704
3885
|
var credentialsRegister = ({
|
|
3705
3886
|
authSessionStore,
|
|
3887
|
+
cookieSecure,
|
|
3706
3888
|
credentialStore,
|
|
3707
3889
|
onCreateCredentialUser,
|
|
3708
3890
|
onCredentialsLoginSuccess,
|
|
@@ -3773,6 +3955,7 @@ var credentialsRegister = ({
|
|
|
3773
3955
|
const userSessionId = await promoteToSession({
|
|
3774
3956
|
authSessionStore,
|
|
3775
3957
|
cookie: user_session_id,
|
|
3958
|
+
cookieSecure,
|
|
3776
3959
|
inMemorySession: session,
|
|
3777
3960
|
sessionDurationMs,
|
|
3778
3961
|
user: created
|
|
@@ -4041,6 +4224,7 @@ var encryptTotpSecret = (secret, encryptionKey) => encryptionKey ? encryptSecret
|
|
|
4041
4224
|
var mfaChallenge = ({
|
|
4042
4225
|
authSessionStore,
|
|
4043
4226
|
challengeRoute = "/auth/mfa/challenge",
|
|
4227
|
+
cookieSecure,
|
|
4044
4228
|
encryptionKey,
|
|
4045
4229
|
getChallengeUser,
|
|
4046
4230
|
getUserId,
|
|
@@ -4098,7 +4282,7 @@ var mfaChallenge = ({
|
|
|
4098
4282
|
user_session_id.set({
|
|
4099
4283
|
httpOnly: true,
|
|
4100
4284
|
sameSite: "lax",
|
|
4101
|
-
secure:
|
|
4285
|
+
secure: resolveCookieSecure(cookieSecure),
|
|
4102
4286
|
value: userSessionId
|
|
4103
4287
|
});
|
|
4104
4288
|
await persistWhen(authSessionStore !== undefined, compatibilityLayer.persist);
|
|
@@ -6480,6 +6664,7 @@ var generateOtpCode = (length) => {
|
|
|
6480
6664
|
};
|
|
6481
6665
|
var passwordlessRoutes = ({
|
|
6482
6666
|
authSessionStore,
|
|
6667
|
+
cookieSecure,
|
|
6483
6668
|
emit,
|
|
6484
6669
|
getUserByEmail,
|
|
6485
6670
|
getUserId,
|
|
@@ -6505,6 +6690,7 @@ var passwordlessRoutes = ({
|
|
|
6505
6690
|
const userSessionId = await promoteToSession({
|
|
6506
6691
|
authSessionStore,
|
|
6507
6692
|
cookie: userSessionCookie,
|
|
6693
|
+
cookieSecure,
|
|
6508
6694
|
inMemorySession: session,
|
|
6509
6695
|
sessionDurationMs,
|
|
6510
6696
|
user
|
|
@@ -7072,132 +7258,136 @@ var parseReferer = (headerReferer) => {
|
|
|
7072
7258
|
var authorize = ({
|
|
7073
7259
|
clientProviders,
|
|
7074
7260
|
authorizeRoute = "/oauth2/:provider/authorization",
|
|
7261
|
+
cookieSecure,
|
|
7075
7262
|
onAuthorizeSuccess,
|
|
7076
7263
|
onAuthorizeError
|
|
7077
|
-
}) => new Elysia20().get(authorizeRoute, async ({
|
|
7078
|
-
status,
|
|
7079
|
-
redirect,
|
|
7080
|
-
cookie: {
|
|
7081
|
-
state,
|
|
7082
|
-
code_verifier,
|
|
7083
|
-
auth_provider,
|
|
7084
|
-
auth_client,
|
|
7085
|
-
auth_intent,
|
|
7086
|
-
origin_url
|
|
7087
|
-
},
|
|
7088
|
-
params: { provider },
|
|
7089
|
-
query: { client, intent },
|
|
7090
|
-
headers
|
|
7091
7264
|
}) => {
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
httpOnly: true,
|
|
7125
|
-
maxAge: COOKIE_DURATION,
|
|
7126
|
-
path: "/",
|
|
7127
|
-
sameSite: "lax",
|
|
7128
|
-
secure: true,
|
|
7129
|
-
value: clientName ?? ""
|
|
7130
|
-
});
|
|
7131
|
-
if (authIntent !== undefined) {
|
|
7132
|
-
auth_intent.set({
|
|
7265
|
+
const secure = resolveCookieSecure(cookieSecure);
|
|
7266
|
+
return new Elysia20().get(authorizeRoute, async ({
|
|
7267
|
+
status,
|
|
7268
|
+
redirect,
|
|
7269
|
+
cookie: {
|
|
7270
|
+
state,
|
|
7271
|
+
code_verifier,
|
|
7272
|
+
auth_provider,
|
|
7273
|
+
auth_client,
|
|
7274
|
+
auth_intent,
|
|
7275
|
+
origin_url
|
|
7276
|
+
},
|
|
7277
|
+
params: { provider },
|
|
7278
|
+
query: { client, intent },
|
|
7279
|
+
headers
|
|
7280
|
+
}) => {
|
|
7281
|
+
if (auth_provider === undefined || auth_client === undefined || auth_intent === undefined || origin_url === undefined || state === undefined || code_verifier === undefined)
|
|
7282
|
+
return status("Bad Request", "Cookies are missing");
|
|
7283
|
+
if (provider === undefined)
|
|
7284
|
+
return status("Bad Request", "Provider is required");
|
|
7285
|
+
const resolvedProvider = resolveClientProviderEntry({
|
|
7286
|
+
clientName: client,
|
|
7287
|
+
clientProviders,
|
|
7288
|
+
providerName: provider
|
|
7289
|
+
});
|
|
7290
|
+
if ("error" in resolvedProvider) {
|
|
7291
|
+
return status("Unauthorized", resolvedProvider.error);
|
|
7292
|
+
}
|
|
7293
|
+
const { clientName, providerInstance, scope, searchParams } = resolvedProvider.entry;
|
|
7294
|
+
const referer = parseReferer(headers["referer"]);
|
|
7295
|
+
const authIntent = isAuthIntent(intent) ? intent : undefined;
|
|
7296
|
+
origin_url.set({
|
|
7133
7297
|
httpOnly: true,
|
|
7134
7298
|
maxAge: COOKIE_DURATION,
|
|
7135
7299
|
path: "/",
|
|
7136
7300
|
sameSite: "lax",
|
|
7137
|
-
secure
|
|
7138
|
-
value:
|
|
7301
|
+
secure,
|
|
7302
|
+
value: referer
|
|
7139
7303
|
});
|
|
7140
|
-
|
|
7141
|
-
auth_intent.remove();
|
|
7142
|
-
}
|
|
7143
|
-
const currentState = generateState();
|
|
7144
|
-
state.set({
|
|
7145
|
-
httpOnly: true,
|
|
7146
|
-
maxAge: COOKIE_DURATION,
|
|
7147
|
-
path: "/",
|
|
7148
|
-
sameSite: "lax",
|
|
7149
|
-
secure: true,
|
|
7150
|
-
value: currentState
|
|
7151
|
-
});
|
|
7152
|
-
const codeVerifier = isPKCEProviderOption(provider) ? generateCodeVerifier() : undefined;
|
|
7153
|
-
if (codeVerifier) {
|
|
7154
|
-
code_verifier.set({
|
|
7304
|
+
auth_provider.set({
|
|
7155
7305
|
httpOnly: true,
|
|
7156
7306
|
maxAge: COOKIE_DURATION,
|
|
7157
7307
|
path: "/",
|
|
7158
7308
|
sameSite: "lax",
|
|
7159
|
-
secure
|
|
7160
|
-
value:
|
|
7161
|
-
});
|
|
7162
|
-
}
|
|
7163
|
-
try {
|
|
7164
|
-
const authorizationURL = await providerInstance.createAuthorizationUrl(codeVerifier ? { codeVerifier, scope, state: currentState } : { scope, state: currentState });
|
|
7165
|
-
searchParams?.forEach(([key, value]) => authorizationURL.searchParams.set(key, value));
|
|
7166
|
-
await onAuthorizeSuccess?.({
|
|
7167
|
-
authClient: clientName,
|
|
7168
|
-
authIntent,
|
|
7169
|
-
authorizationUrl: authorizationURL,
|
|
7170
|
-
authProvider: provider
|
|
7309
|
+
secure,
|
|
7310
|
+
value: provider
|
|
7171
7311
|
});
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7312
|
+
auth_client.set({
|
|
7313
|
+
httpOnly: true,
|
|
7314
|
+
maxAge: COOKIE_DURATION,
|
|
7315
|
+
path: "/",
|
|
7316
|
+
sameSite: "lax",
|
|
7317
|
+
secure,
|
|
7318
|
+
value: clientName ?? ""
|
|
7179
7319
|
});
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7320
|
+
if (authIntent !== undefined) {
|
|
7321
|
+
auth_intent.set({
|
|
7322
|
+
httpOnly: true,
|
|
7323
|
+
maxAge: COOKIE_DURATION,
|
|
7324
|
+
path: "/",
|
|
7325
|
+
sameSite: "lax",
|
|
7326
|
+
secure,
|
|
7327
|
+
value: authIntent
|
|
7328
|
+
});
|
|
7329
|
+
} else {
|
|
7330
|
+
auth_intent.remove();
|
|
7331
|
+
}
|
|
7332
|
+
const currentState = generateState();
|
|
7333
|
+
state.set({
|
|
7334
|
+
httpOnly: true,
|
|
7335
|
+
maxAge: COOKIE_DURATION,
|
|
7336
|
+
path: "/",
|
|
7337
|
+
sameSite: "lax",
|
|
7338
|
+
secure,
|
|
7339
|
+
value: currentState
|
|
7184
7340
|
});
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7341
|
+
const codeVerifier = isPKCEProviderOption(provider) ? generateCodeVerifier() : undefined;
|
|
7342
|
+
if (codeVerifier) {
|
|
7343
|
+
code_verifier.set({
|
|
7344
|
+
httpOnly: true,
|
|
7345
|
+
maxAge: COOKIE_DURATION,
|
|
7346
|
+
path: "/",
|
|
7347
|
+
sameSite: "lax",
|
|
7348
|
+
secure,
|
|
7349
|
+
value: codeVerifier
|
|
7350
|
+
});
|
|
7351
|
+
}
|
|
7352
|
+
try {
|
|
7353
|
+
const authorizationURL = await providerInstance.createAuthorizationUrl(codeVerifier ? { codeVerifier, scope, state: currentState } : { scope, state: currentState });
|
|
7354
|
+
searchParams?.forEach(([key, value]) => authorizationURL.searchParams.set(key, value));
|
|
7355
|
+
await onAuthorizeSuccess?.({
|
|
7356
|
+
authClient: clientName,
|
|
7357
|
+
authIntent,
|
|
7358
|
+
authorizationUrl: authorizationURL,
|
|
7359
|
+
authProvider: provider
|
|
7360
|
+
});
|
|
7361
|
+
return redirect(authorizationURL.toString());
|
|
7362
|
+
} catch (err) {
|
|
7363
|
+
console.error("[authorize] Failed to create authorization URL:", {
|
|
7364
|
+
authClient: clientName,
|
|
7365
|
+
error: err instanceof Error ? err.message : err,
|
|
7366
|
+
provider,
|
|
7367
|
+
stack: err instanceof Error ? err.stack : undefined
|
|
7368
|
+
});
|
|
7369
|
+
await onAuthorizeError?.({
|
|
7370
|
+
authClient: clientName,
|
|
7371
|
+
authProvider: provider,
|
|
7372
|
+
error: err
|
|
7373
|
+
});
|
|
7374
|
+
return status("Internal Server Error", "Failed to create authorization URL");
|
|
7375
|
+
}
|
|
7376
|
+
}, {
|
|
7377
|
+
cookie: t17.Cookie({
|
|
7378
|
+
auth_client: authClientOption,
|
|
7379
|
+
auth_intent: authIntentOption,
|
|
7380
|
+
auth_provider: t17.Optional(authProviderOption)
|
|
7381
|
+
}),
|
|
7382
|
+
params: t17.Object({
|
|
7383
|
+
provider: authProviderOption
|
|
7384
|
+
}),
|
|
7385
|
+
query: t17.Object({
|
|
7386
|
+
client: authClientOption,
|
|
7387
|
+
intent: authIntentOption
|
|
7388
|
+
})
|
|
7389
|
+
});
|
|
7390
|
+
};
|
|
7201
7391
|
|
|
7202
7392
|
// src/routes/callback.ts
|
|
7203
7393
|
import { Elysia as Elysia21, t as t18 } from "elysia";
|
|
@@ -8470,13 +8660,13 @@ var ssoDiscoveryRoute = ({
|
|
|
8470
8660
|
|
|
8471
8661
|
// src/sso/oidcRoutes.ts
|
|
8472
8662
|
import { Elysia as Elysia32, t as t28 } from "elysia";
|
|
8473
|
-
var
|
|
8663
|
+
var makeSsoCookieOptions = (secure) => ({
|
|
8474
8664
|
httpOnly: true,
|
|
8475
8665
|
maxAge: COOKIE_DURATION,
|
|
8476
8666
|
path: "/",
|
|
8477
8667
|
sameSite: "lax",
|
|
8478
|
-
secure
|
|
8479
|
-
};
|
|
8668
|
+
secure
|
|
8669
|
+
});
|
|
8480
8670
|
var ssoCookieSchema = t28.Cookie({
|
|
8481
8671
|
sso_nonce: t28.Optional(t28.String()),
|
|
8482
8672
|
sso_organization: t28.Optional(t28.String()),
|
|
@@ -8497,6 +8687,7 @@ var parseReferer2 = (referer) => {
|
|
|
8497
8687
|
};
|
|
8498
8688
|
var oidcSsoRoutes = ({
|
|
8499
8689
|
authSessionStore,
|
|
8690
|
+
cookieSecure,
|
|
8500
8691
|
getSsoUser,
|
|
8501
8692
|
onSsoCallbackError,
|
|
8502
8693
|
onSsoCallbackSuccess,
|
|
@@ -8504,6 +8695,7 @@ var oidcSsoRoutes = ({
|
|
|
8504
8695
|
ssoConnectionStore,
|
|
8505
8696
|
ssoRoute = DEFAULT_SSO_ROUTE
|
|
8506
8697
|
}) => {
|
|
8698
|
+
const ssoCookieOptions = makeSsoCookieOptions(resolveCookieSecure(cookieSecure));
|
|
8507
8699
|
const authorizeRoute = `${ssoRoute}/oidc/:organizationId/authorize`;
|
|
8508
8700
|
const callbackRoute = `${ssoRoute}/oidc/:organizationId/callback`;
|
|
8509
8701
|
return new Elysia32().use(sessionStore()).get(authorizeRoute, async ({
|
|
@@ -8606,6 +8798,7 @@ var oidcSsoRoutes = ({
|
|
|
8606
8798
|
const userSessionId = await promoteToSession({
|
|
8607
8799
|
authSessionStore,
|
|
8608
8800
|
cookie: user_session_id,
|
|
8801
|
+
cookieSecure,
|
|
8609
8802
|
inMemorySession: session,
|
|
8610
8803
|
sessionDurationMs,
|
|
8611
8804
|
user
|
|
@@ -8655,6 +8848,7 @@ var settle = async (work) => {
|
|
|
8655
8848
|
};
|
|
8656
8849
|
var samlSsoRoutes = ({
|
|
8657
8850
|
authSessionStore,
|
|
8851
|
+
cookieSecure,
|
|
8658
8852
|
getSsoUser,
|
|
8659
8853
|
onSsoCallbackError,
|
|
8660
8854
|
onSsoCallbackSuccess,
|
|
@@ -8730,6 +8924,7 @@ var samlSsoRoutes = ({
|
|
|
8730
8924
|
const userSessionId = await promoteToSession({
|
|
8731
8925
|
authSessionStore,
|
|
8732
8926
|
cookie: user_session_id,
|
|
8927
|
+
cookieSecure,
|
|
8733
8928
|
inMemorySession: session,
|
|
8734
8929
|
samlLogout: {
|
|
8735
8930
|
connectionId: connection.connectionId,
|
|
@@ -8897,6 +9092,7 @@ var WEBAUTHN_CHALLENGE_COOKIE = "webauthn_challenge";
|
|
|
8897
9092
|
var webauthnRoutes = ({
|
|
8898
9093
|
authSessionStore,
|
|
8899
9094
|
challengeDurationMs = DEFAULT_WEBAUTHN_CHALLENGE_TTL_MS,
|
|
9095
|
+
cookieSecure,
|
|
8900
9096
|
credentialStore,
|
|
8901
9097
|
emit,
|
|
8902
9098
|
getUserDisplayName,
|
|
@@ -8912,6 +9108,7 @@ var webauthnRoutes = ({
|
|
|
8912
9108
|
webauthnAdapter,
|
|
8913
9109
|
webauthnRoute = DEFAULT_WEBAUTHN_ROUTE
|
|
8914
9110
|
}) => {
|
|
9111
|
+
const secure = resolveCookieSecure(cookieSecure);
|
|
8915
9112
|
const challengeCookie = t30.Cookie({
|
|
8916
9113
|
user_session_id: t30.Optional(userSessionIdTypebox),
|
|
8917
9114
|
webauthn_challenge: t30.Optional(t30.String())
|
|
@@ -8920,7 +9117,7 @@ var webauthnRoutes = ({
|
|
|
8920
9117
|
httpOnly: true,
|
|
8921
9118
|
maxAge: Math.floor(challengeDurationMs / MILLISECONDS_IN_A_SECOND),
|
|
8922
9119
|
sameSite: "lax",
|
|
8923
|
-
secure
|
|
9120
|
+
secure,
|
|
8924
9121
|
value: challenge
|
|
8925
9122
|
});
|
|
8926
9123
|
return new Elysia34().use(sessionStore()).post(`${webauthnRoute}/register/options`, async ({
|
|
@@ -9052,6 +9249,7 @@ var webauthnRoutes = ({
|
|
|
9052
9249
|
const userSessionId = await promoteToSession({
|
|
9053
9250
|
authSessionStore,
|
|
9054
9251
|
cookie: user_session_id,
|
|
9252
|
+
cookieSecure,
|
|
9055
9253
|
inMemorySession: session,
|
|
9056
9254
|
sessionDurationMs,
|
|
9057
9255
|
user
|
|
@@ -19549,7 +19747,7 @@ var getGrantedScopes = (scopeValue, fallbackScopes) => {
|
|
|
19549
19747
|
}
|
|
19550
19748
|
return [...new Set(fallbackScopes.filter(Boolean))];
|
|
19551
19749
|
};
|
|
19552
|
-
var
|
|
19750
|
+
var parseExpiresInSeconds2 = (expiresIn) => {
|
|
19553
19751
|
if (typeof expiresIn === "number") {
|
|
19554
19752
|
return expiresIn;
|
|
19555
19753
|
}
|
|
@@ -19559,7 +19757,7 @@ var parseExpiresInSeconds = (expiresIn) => {
|
|
|
19559
19757
|
return Number.NaN;
|
|
19560
19758
|
};
|
|
19561
19759
|
var getExpiresAt = (tokenResponse2) => {
|
|
19562
|
-
const expiresInSeconds =
|
|
19760
|
+
const expiresInSeconds = parseExpiresInSeconds2(tokenResponse2.expires_in);
|
|
19563
19761
|
if (!Number.isFinite(expiresInSeconds) || expiresInSeconds <= 0) {
|
|
19564
19762
|
return;
|
|
19565
19763
|
}
|
|
@@ -19898,6 +20096,7 @@ var DEFAULT_IMPERSONATION_TTL_MS = MILLISECONDS_IN_AN_HOUR;
|
|
|
19898
20096
|
var endImpersonation = async ({
|
|
19899
20097
|
authSessionStore,
|
|
19900
20098
|
cookie,
|
|
20099
|
+
cookieSecure,
|
|
19901
20100
|
emit,
|
|
19902
20101
|
inMemorySession
|
|
19903
20102
|
}) => {
|
|
@@ -19930,7 +20129,7 @@ var endImpersonation = async ({
|
|
|
19930
20129
|
cookie.set({
|
|
19931
20130
|
httpOnly: true,
|
|
19932
20131
|
sameSite: "lax",
|
|
19933
|
-
secure:
|
|
20132
|
+
secure: resolveCookieSecure(cookieSecure),
|
|
19934
20133
|
value: returnTo
|
|
19935
20134
|
});
|
|
19936
20135
|
return { restored: true };
|
|
@@ -19942,6 +20141,7 @@ var isImpersonating = (session) => session?.impersonator !== undefined;
|
|
|
19942
20141
|
var startImpersonation = async ({
|
|
19943
20142
|
authSessionStore,
|
|
19944
20143
|
cookie,
|
|
20144
|
+
cookieSecure,
|
|
19945
20145
|
emit,
|
|
19946
20146
|
getUserId,
|
|
19947
20147
|
impersonator,
|
|
@@ -19959,6 +20159,7 @@ var startImpersonation = async ({
|
|
|
19959
20159
|
const sessionId = await promoteToSession({
|
|
19960
20160
|
authSessionStore,
|
|
19961
20161
|
cookie,
|
|
20162
|
+
cookieSecure,
|
|
19962
20163
|
impersonator: stamp,
|
|
19963
20164
|
inMemorySession,
|
|
19964
20165
|
sessionDurationMs,
|
|
@@ -19977,6 +20178,7 @@ var DEFAULT_GUEST_TTL_MS = MILLISECONDS_IN_A_DAY;
|
|
|
19977
20178
|
var createAnonymousSession = async ({
|
|
19978
20179
|
authSessionStore,
|
|
19979
20180
|
cookie,
|
|
20181
|
+
cookieSecure,
|
|
19980
20182
|
guestUser,
|
|
19981
20183
|
inMemorySession,
|
|
19982
20184
|
sessionDurationMs = DEFAULT_GUEST_TTL_MS
|
|
@@ -19984,6 +20186,7 @@ var createAnonymousSession = async ({
|
|
|
19984
20186
|
anonymous: true,
|
|
19985
20187
|
authSessionStore,
|
|
19986
20188
|
cookie,
|
|
20189
|
+
cookieSecure,
|
|
19987
20190
|
inMemorySession,
|
|
19988
20191
|
sessionDurationMs,
|
|
19989
20192
|
user: guestUser
|
|
@@ -19991,14 +20194,14 @@ var createAnonymousSession = async ({
|
|
|
19991
20194
|
var isAnonymousSession = (session) => session?.anonymous === true;
|
|
19992
20195
|
// src/session/multiSession.ts
|
|
19993
20196
|
var SEPARATOR = " ";
|
|
19994
|
-
var writeRing = (ring, ids) => ring.set({
|
|
20197
|
+
var writeRing = (ring, ids, cookieSecure) => ring.set({
|
|
19995
20198
|
httpOnly: true,
|
|
19996
20199
|
sameSite: "lax",
|
|
19997
|
-
secure:
|
|
20200
|
+
secure: resolveCookieSecure(cookieSecure),
|
|
19998
20201
|
value: ids.join(SEPARATOR)
|
|
19999
20202
|
});
|
|
20000
20203
|
var readRing = (ring) => (ring.value ?? "").split(SEPARATOR).filter((entry) => isUserSessionId(entry));
|
|
20001
|
-
var addToSessionRing = (ring, sessionId) => writeRing(ring, [...new Set([...readRing(ring), sessionId])]);
|
|
20204
|
+
var addToSessionRing = (ring, sessionId, cookieSecure) => writeRing(ring, [...new Set([...readRing(ring), sessionId])], cookieSecure);
|
|
20002
20205
|
var listRingSessions = async ({
|
|
20003
20206
|
authSessionStore,
|
|
20004
20207
|
inMemorySession,
|
|
@@ -20018,12 +20221,13 @@ var readSessionRing = (ring) => readRing(ring);
|
|
|
20018
20221
|
var removeFromSessionRing = async ({
|
|
20019
20222
|
activeCookie,
|
|
20020
20223
|
authSessionStore,
|
|
20224
|
+
cookieSecure,
|
|
20021
20225
|
inMemorySession,
|
|
20022
20226
|
ring,
|
|
20023
20227
|
sessionId
|
|
20024
20228
|
}) => {
|
|
20025
20229
|
const remaining = readRing(ring).filter((id) => id !== sessionId);
|
|
20026
|
-
writeRing(ring, remaining);
|
|
20230
|
+
writeRing(ring, remaining, cookieSecure);
|
|
20027
20231
|
if (authSessionStore)
|
|
20028
20232
|
await authSessionStore.removeSession(sessionId);
|
|
20029
20233
|
else if (inMemorySession)
|
|
@@ -20037,12 +20241,13 @@ var removeFromSessionRing = async ({
|
|
|
20037
20241
|
activeCookie.set({
|
|
20038
20242
|
httpOnly: true,
|
|
20039
20243
|
sameSite: "lax",
|
|
20040
|
-
secure:
|
|
20244
|
+
secure: resolveCookieSecure(cookieSecure),
|
|
20041
20245
|
value: fallback
|
|
20042
20246
|
});
|
|
20043
20247
|
};
|
|
20044
20248
|
var switchActiveSession = ({
|
|
20045
20249
|
activeCookie,
|
|
20250
|
+
cookieSecure,
|
|
20046
20251
|
ring,
|
|
20047
20252
|
sessionId
|
|
20048
20253
|
}) => {
|
|
@@ -20051,184 +20256,11 @@ var switchActiveSession = ({
|
|
|
20051
20256
|
activeCookie.set({
|
|
20052
20257
|
httpOnly: true,
|
|
20053
20258
|
sameSite: "lax",
|
|
20054
|
-
secure:
|
|
20259
|
+
secure: resolveCookieSecure(cookieSecure),
|
|
20055
20260
|
value: sessionId
|
|
20056
20261
|
});
|
|
20057
20262
|
return true;
|
|
20058
20263
|
};
|
|
20059
|
-
// src/utils.ts
|
|
20060
|
-
var defineAuthConfig = (configuration) => configuration;
|
|
20061
|
-
var defineAuthHtmxConfig = (htmxConfig) => htmxConfig;
|
|
20062
|
-
var defineAuthSettings = (settings) => settings;
|
|
20063
|
-
var defineProvidersConfiguration = (providersConfiguration) => providersConfiguration;
|
|
20064
|
-
var getStatus = async (session, user_session_id) => {
|
|
20065
|
-
if (user_session_id === undefined) {
|
|
20066
|
-
return {
|
|
20067
|
-
error: {
|
|
20068
|
-
code: "Bad Request",
|
|
20069
|
-
message: "Cookies are missing"
|
|
20070
|
-
},
|
|
20071
|
-
user: null
|
|
20072
|
-
};
|
|
20073
|
-
}
|
|
20074
|
-
const userSession = validateSession({ session, user_session_id });
|
|
20075
|
-
const user = userSession?.user ?? null;
|
|
20076
|
-
return {
|
|
20077
|
-
error: null,
|
|
20078
|
-
user
|
|
20079
|
-
};
|
|
20080
|
-
};
|
|
20081
|
-
var instantiateUserSession = async ({
|
|
20082
|
-
authProvider,
|
|
20083
|
-
session,
|
|
20084
|
-
user_session_id,
|
|
20085
|
-
unregisteredSession,
|
|
20086
|
-
tokenResponse: tokenResponse2,
|
|
20087
|
-
providerInstance,
|
|
20088
|
-
getUser,
|
|
20089
|
-
onNewUser,
|
|
20090
|
-
resolvedAuthorization,
|
|
20091
|
-
sessionDurationMs = MILLISECONDS_IN_A_DAY,
|
|
20092
|
-
unregisteredSessionDurationMs = MILLISECONDS_IN_AN_HOUR
|
|
20093
|
-
}) => {
|
|
20094
|
-
const authorization = resolvedAuthorization ?? await resolveOAuthAuthorization({
|
|
20095
|
-
authProvider,
|
|
20096
|
-
providerInstance,
|
|
20097
|
-
tokenResponse: tokenResponse2
|
|
20098
|
-
});
|
|
20099
|
-
const { accessToken, refreshToken, userIdentity } = authorization;
|
|
20100
|
-
const userSession = validateSession({ session, user_session_id });
|
|
20101
|
-
const userSessionId = getUserSessionId({
|
|
20102
|
-
session,
|
|
20103
|
-
unregisteredSession,
|
|
20104
|
-
user_session_id
|
|
20105
|
-
});
|
|
20106
|
-
let user = userSession?.user ?? await getUser(userIdentity);
|
|
20107
|
-
const response = user ?? await onNewUser(userIdentity);
|
|
20108
|
-
const isRedirectOrStatus = response instanceof Response || isStatusResponse(response);
|
|
20109
|
-
if (!isRedirectOrStatus) {
|
|
20110
|
-
user = response;
|
|
20111
|
-
session[userSessionId] = {
|
|
20112
|
-
accessToken,
|
|
20113
|
-
authenticatedAt: Date.now(),
|
|
20114
|
-
expiresAt: Date.now() + sessionDurationMs,
|
|
20115
|
-
refreshToken,
|
|
20116
|
-
user
|
|
20117
|
-
};
|
|
20118
|
-
return;
|
|
20119
|
-
}
|
|
20120
|
-
const existingUnregistered = unregisteredSession[userSessionId];
|
|
20121
|
-
if (existingUnregistered) {
|
|
20122
|
-
existingUnregistered.accessToken = accessToken;
|
|
20123
|
-
existingUnregistered.expiresAt = Date.now() + unregisteredSessionDurationMs;
|
|
20124
|
-
existingUnregistered.refreshToken = refreshToken;
|
|
20125
|
-
existingUnregistered.userIdentity = userIdentity;
|
|
20126
|
-
return response;
|
|
20127
|
-
}
|
|
20128
|
-
unregisteredSession[userSessionId] = {
|
|
20129
|
-
accessToken,
|
|
20130
|
-
expiresAt: Date.now() + unregisteredSessionDurationMs,
|
|
20131
|
-
refreshToken,
|
|
20132
|
-
userIdentity
|
|
20133
|
-
};
|
|
20134
|
-
return response;
|
|
20135
|
-
};
|
|
20136
|
-
var resolveOAuthAuthorization = async ({
|
|
20137
|
-
authProvider,
|
|
20138
|
-
providerInstance,
|
|
20139
|
-
tokenResponse: tokenResponse2,
|
|
20140
|
-
now = Date.now()
|
|
20141
|
-
}) => {
|
|
20142
|
-
let userIdentity;
|
|
20143
|
-
let accessToken = tokenResponse2.access_token;
|
|
20144
|
-
let refreshToken = tokenResponse2.refresh_token;
|
|
20145
|
-
if (tokenResponse2.id_token) {
|
|
20146
|
-
userIdentity = normalizeProviderIdentity({
|
|
20147
|
-
identity: decodeJWT(tokenResponse2.id_token),
|
|
20148
|
-
providerConfiguration: providers[authProvider],
|
|
20149
|
-
source: "idToken"
|
|
20150
|
-
});
|
|
20151
|
-
} else if (authProvider === "withings") {
|
|
20152
|
-
userIdentity = { userid: tokenResponse2.body.userid };
|
|
20153
|
-
accessToken = tokenResponse2.body.access_token;
|
|
20154
|
-
refreshToken = tokenResponse2.body.refresh_token;
|
|
20155
|
-
} else {
|
|
20156
|
-
userIdentity = normalizeProviderIdentity({
|
|
20157
|
-
identity: await providerInstance.fetchUserProfile(tokenResponse2.access_token),
|
|
20158
|
-
providerConfiguration: providers[authProvider],
|
|
20159
|
-
source: "profile"
|
|
20160
|
-
});
|
|
20161
|
-
}
|
|
20162
|
-
const tokenType = Reflect.get(tokenResponse2, "token_type");
|
|
20163
|
-
return {
|
|
20164
|
-
accessToken,
|
|
20165
|
-
expiresAt: resolveOAuthTokenExpiresAt(tokenResponse2, now),
|
|
20166
|
-
refreshToken,
|
|
20167
|
-
tokenType: typeof tokenType === "string" ? tokenType : undefined,
|
|
20168
|
-
userIdentity
|
|
20169
|
-
};
|
|
20170
|
-
};
|
|
20171
|
-
var parseExpiresInSeconds2 = (expiresIn) => {
|
|
20172
|
-
if (typeof expiresIn === "number") {
|
|
20173
|
-
return expiresIn;
|
|
20174
|
-
}
|
|
20175
|
-
if (typeof expiresIn === "string" && expiresIn.trim().length > 0) {
|
|
20176
|
-
return Number(expiresIn);
|
|
20177
|
-
}
|
|
20178
|
-
return Number.NaN;
|
|
20179
|
-
};
|
|
20180
|
-
var resolveOAuthTokenExpiresAt = (tokenResponse2, now = Date.now()) => {
|
|
20181
|
-
const expiresIn = Reflect.get(tokenResponse2, "expires_in");
|
|
20182
|
-
const expiresInSeconds = parseExpiresInSeconds2(expiresIn);
|
|
20183
|
-
if (!Number.isFinite(expiresInSeconds) || expiresInSeconds <= 0) {
|
|
20184
|
-
return;
|
|
20185
|
-
}
|
|
20186
|
-
return now + expiresInSeconds * 1000;
|
|
20187
|
-
};
|
|
20188
|
-
var validateSession = ({
|
|
20189
|
-
user_session_id,
|
|
20190
|
-
session
|
|
20191
|
-
}) => {
|
|
20192
|
-
const userSessionId = user_session_id.value;
|
|
20193
|
-
if (!userSessionId) {
|
|
20194
|
-
return;
|
|
20195
|
-
}
|
|
20196
|
-
const userSession = session[userSessionId];
|
|
20197
|
-
if (!userSession) {
|
|
20198
|
-
return;
|
|
20199
|
-
}
|
|
20200
|
-
const isExpired2 = userSession.expiresAt < Date.now();
|
|
20201
|
-
if (isExpired2) {
|
|
20202
|
-
delete session[userSessionId];
|
|
20203
|
-
user_session_id.remove();
|
|
20204
|
-
return;
|
|
20205
|
-
}
|
|
20206
|
-
return userSession;
|
|
20207
|
-
};
|
|
20208
|
-
var clearExistingSession = (existingId, session, unregisteredSession) => {
|
|
20209
|
-
if (session)
|
|
20210
|
-
delete session[existingId];
|
|
20211
|
-
if (unregisteredSession)
|
|
20212
|
-
delete unregisteredSession[existingId];
|
|
20213
|
-
};
|
|
20214
|
-
var getUserSessionId = ({
|
|
20215
|
-
user_session_id,
|
|
20216
|
-
session,
|
|
20217
|
-
unregisteredSession
|
|
20218
|
-
}) => {
|
|
20219
|
-
const existingId = user_session_id?.value;
|
|
20220
|
-
if (isNonEmptyString(existingId)) {
|
|
20221
|
-
clearExistingSession(existingId, session, unregisteredSession);
|
|
20222
|
-
}
|
|
20223
|
-
const userSessionId = crypto.randomUUID();
|
|
20224
|
-
user_session_id.set({
|
|
20225
|
-
httpOnly: true,
|
|
20226
|
-
sameSite: "lax",
|
|
20227
|
-
secure: true,
|
|
20228
|
-
value: userSessionId
|
|
20229
|
-
});
|
|
20230
|
-
return userSessionId;
|
|
20231
|
-
};
|
|
20232
20264
|
// src/tenancy.ts
|
|
20233
20265
|
var hasOrganizationScope = (value) => typeof value.organizationId === "string" && value.organizationId.length > 0;
|
|
20234
20266
|
// src/credentials/emailValidation.ts
|
|
@@ -23342,6 +23374,7 @@ var createPostgresSetupSessionStore = (db) => ({
|
|
|
23342
23374
|
var auth = async ({
|
|
23343
23375
|
providersConfiguration,
|
|
23344
23376
|
authorizeRoute,
|
|
23377
|
+
cookieSecure,
|
|
23345
23378
|
callbackRoute,
|
|
23346
23379
|
profileRoute,
|
|
23347
23380
|
signoutRoute,
|
|
@@ -23389,6 +23422,7 @@ var auth = async ({
|
|
|
23389
23422
|
onSessionCleanup
|
|
23390
23423
|
}) => {
|
|
23391
23424
|
const clientProviders = await buildClientProviders(providersConfiguration, createOAuth2Client);
|
|
23425
|
+
const resolvedCookieSecure = resolveCookieSecure(cookieSecure);
|
|
23392
23426
|
const webhookDispatch = webhooks ? createWebhookDispatcher(webhooks) : undefined;
|
|
23393
23427
|
const auditEmit = audit || webhookDispatch ? createAuditEmitter({
|
|
23394
23428
|
...audit,
|
|
@@ -23432,6 +23466,7 @@ var auth = async ({
|
|
|
23432
23466
|
})).use(authorize({
|
|
23433
23467
|
authorizeRoute,
|
|
23434
23468
|
clientProviders,
|
|
23469
|
+
cookieSecure: resolvedCookieSecure,
|
|
23435
23470
|
onAuthorizeError,
|
|
23436
23471
|
onAuthorizeSuccess
|
|
23437
23472
|
})).use(callback({
|
|
@@ -23452,14 +23487,25 @@ var auth = async ({
|
|
|
23452
23487
|
})).use(auditedCredentials ? credentialRoutes({
|
|
23453
23488
|
...auditedCredentials,
|
|
23454
23489
|
authSessionStore,
|
|
23490
|
+
cookieSecure: resolvedCookieSecure,
|
|
23455
23491
|
lockoutGuard
|
|
23456
|
-
}) : new Elysia36).use(auditedMfa ? mfaRoutes({
|
|
23492
|
+
}) : new Elysia36).use(auditedMfa ? mfaRoutes({
|
|
23493
|
+
...auditedMfa,
|
|
23494
|
+
authSessionStore,
|
|
23495
|
+
cookieSecure: resolvedCookieSecure
|
|
23496
|
+
}) : new Elysia36).use(passwordless ? passwordlessRoutes({
|
|
23457
23497
|
...passwordless,
|
|
23458
23498
|
authSessionStore,
|
|
23499
|
+
cookieSecure: resolvedCookieSecure,
|
|
23459
23500
|
emit: auditEmit
|
|
23460
|
-
}) : new Elysia36).use(sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia36).use(sso ? oidcSsoRoutes({
|
|
23501
|
+
}) : new Elysia36).use(sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia36).use(sso ? oidcSsoRoutes({
|
|
23502
|
+
...sso,
|
|
23503
|
+
authSessionStore,
|
|
23504
|
+
cookieSecure: resolvedCookieSecure
|
|
23505
|
+
}) : new Elysia36).use(sso && sso.samlAdapter ? samlSsoRoutes({
|
|
23461
23506
|
...sso,
|
|
23462
23507
|
authSessionStore,
|
|
23508
|
+
cookieSecure: resolvedCookieSecure,
|
|
23463
23509
|
samlAdapter: sso.samlAdapter
|
|
23464
23510
|
}) : new Elysia36).use(sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
|
|
23465
23511
|
getOrganizationByEmailDomain: sso.getOrganizationByEmailDomain,
|
|
@@ -23476,6 +23522,7 @@ var auth = async ({
|
|
|
23476
23522
|
}) : new Elysia36).use(portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia36).use(webauthn ? webauthnRoutes({
|
|
23477
23523
|
...webauthn,
|
|
23478
23524
|
authSessionStore,
|
|
23525
|
+
cookieSecure: resolvedCookieSecure,
|
|
23479
23526
|
emit: auditEmit
|
|
23480
23527
|
}) : new Elysia36).use(compliance ? complianceRoutes({
|
|
23481
23528
|
...compliance,
|
|
@@ -23556,6 +23603,7 @@ export {
|
|
|
23556
23603
|
resolvePermissions,
|
|
23557
23604
|
resolveOAuthTokenExpiresAt,
|
|
23558
23605
|
resolveOAuthAuthorization,
|
|
23606
|
+
resolveCookieSecure,
|
|
23559
23607
|
resolveClientProviderEntry,
|
|
23560
23608
|
resolveAuthHtmxRenderers,
|
|
23561
23609
|
resolveApiPrincipal,
|
|
@@ -23856,5 +23904,5 @@ export {
|
|
|
23856
23904
|
AuthIdentityConflictError
|
|
23857
23905
|
};
|
|
23858
23906
|
|
|
23859
|
-
//# debugId=
|
|
23907
|
+
//# debugId=185BEA3393AC9BDA64756E2164756E21
|
|
23860
23908
|
//# sourceMappingURL=index.js.map
|