@absolutejs/auth 0.54.4 → 0.54.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/README.md +58 -0
- package/dist/agents/config.d.ts +28 -0
- package/dist/agents/inMemoryStores.d.ts +3 -0
- package/dist/agents/index.d.ts +7 -0
- package/dist/agents/index.js +11299 -0
- package/dist/agents/index.js.map +113 -0
- package/dist/agents/oidcAdapter.d.ts +9 -0
- package/dist/agents/postgresStores.d.ts +290 -0
- package/dist/agents/principal.d.ts +4 -0
- package/dist/agents/routes.d.ts +96 -0
- package/dist/agents/types.d.ts +70 -0
- package/dist/audit/types.d.ts +1 -1
- package/dist/cli/migrate.js +369 -333
- package/dist/cli/migrate.js.map +6 -5
- package/dist/htmx/index.js +13 -1
- package/dist/htmx/index.js.map +3 -3
- package/dist/index.d.ts +152 -2
- package/dist/index.js +675 -206
- package/dist/index.js.map +16 -10
- package/dist/migrations/index.d.ts +1 -1
- package/dist/oidc/config.d.ts +9 -1
- package/dist/oidc/registration.d.ts +8 -1
- package/dist/oidc/routes.d.ts +4 -2
- package/dist/oidc/types.d.ts +3 -0
- package/dist/providers/clients.d.ts +1 -0
- package/dist/providers/index.js +13 -1
- package/dist/providers/index.js.map +3 -3
- package/dist/types.d.ts +5 -0
- package/package.json +11 -3
package/dist/index.js
CHANGED
|
@@ -1946,6 +1946,7 @@ var providers = defineProviders({
|
|
|
1946
1946
|
}
|
|
1947
1947
|
},
|
|
1948
1948
|
withings: {
|
|
1949
|
+
accessTokenPath: ["body", "access_token"],
|
|
1949
1950
|
authorizationUrl: "https://account.withings.com/oauth2_user/authorize2",
|
|
1950
1951
|
isOIDC: false,
|
|
1951
1952
|
isRefreshable: true,
|
|
@@ -2800,10 +2801,21 @@ var buildOAuth2Client = async (meta, config) => {
|
|
|
2800
2801
|
if (!response.ok)
|
|
2801
2802
|
throw await createOAuth2FetchError(response);
|
|
2802
2803
|
const tokenResponse = await response.json();
|
|
2804
|
+
if (!tokenResponse || typeof tokenResponse !== "object") {
|
|
2805
|
+
throw new Error("OAuth token endpoint returned a non-object response");
|
|
2806
|
+
}
|
|
2807
|
+
const oauthError = Reflect.get(tokenResponse, "error");
|
|
2808
|
+
if (typeof oauthError === "string" && oauthError.length > 0) {
|
|
2809
|
+
throw new Error(`OAuth token exchange failed: ${oauthError}`);
|
|
2810
|
+
}
|
|
2803
2811
|
const nestedToken = meta.accessTokenPath ? readPath(tokenResponse, meta.accessTokenPath) : undefined;
|
|
2804
2812
|
if (typeof nestedToken === "string" && nestedToken.length > 0 && tokenResponse && typeof tokenResponse === "object") {
|
|
2805
2813
|
tokenResponse.access_token = nestedToken;
|
|
2806
2814
|
}
|
|
2815
|
+
const accessToken = Reflect.get(tokenResponse, "access_token");
|
|
2816
|
+
if (typeof accessToken !== "string" || accessToken.length === 0) {
|
|
2817
|
+
throw new Error("OAuth token endpoint returned no access_token");
|
|
2818
|
+
}
|
|
2807
2819
|
return tokenResponse;
|
|
2808
2820
|
}
|
|
2809
2821
|
};
|
|
@@ -2812,7 +2824,7 @@ var createCustomOAuth2Client = (providerConfig, credentials) => buildOAuth2Clien
|
|
|
2812
2824
|
var createOAuth2Client = (providerName, config) => buildOAuth2Client(providers[providerName], config);
|
|
2813
2825
|
|
|
2814
2826
|
// src/index.ts
|
|
2815
|
-
import { Elysia as
|
|
2827
|
+
import { Elysia as Elysia42 } from "elysia";
|
|
2816
2828
|
|
|
2817
2829
|
// src/apikeys/routes.ts
|
|
2818
2830
|
import { Elysia, t } from "elysia";
|
|
@@ -3032,6 +3044,146 @@ var apiKeysRoutes = ({
|
|
|
3032
3044
|
});
|
|
3033
3045
|
};
|
|
3034
3046
|
|
|
3047
|
+
// src/agents/routes.ts
|
|
3048
|
+
import { Elysia as Elysia2 } from "elysia";
|
|
3049
|
+
|
|
3050
|
+
// src/agents/config.ts
|
|
3051
|
+
var DEFAULT_AGENT_RESOURCE_METADATA_ROUTE = "/.well-known/oauth-protected-resource";
|
|
3052
|
+
var agentProtectedResourceMetadata = (config) => ({
|
|
3053
|
+
authorization_servers: [config.authorizationServer],
|
|
3054
|
+
bearer_methods_supported: ["header"],
|
|
3055
|
+
...config.logoUri === undefined ? {} : { resource_logo_uri: config.logoUri },
|
|
3056
|
+
...config.resourceName === undefined ? {} : { resource_name: config.resourceName },
|
|
3057
|
+
resource: config.resource,
|
|
3058
|
+
scopes_supported: config.scopes
|
|
3059
|
+
});
|
|
3060
|
+
|
|
3061
|
+
// src/agents/principal.ts
|
|
3062
|
+
var intersectScopes = (...sets) => {
|
|
3063
|
+
if (sets.length === 0)
|
|
3064
|
+
return [];
|
|
3065
|
+
const [first = [], ...rest] = sets;
|
|
3066
|
+
return [...new Set(first)].filter((scope) => rest.every((set) => set.includes(scope)));
|
|
3067
|
+
};
|
|
3068
|
+
var agentHasScopes = (principal, requiredScopes) => principal !== undefined && requiredScopes.every((scope) => principal.scopes.includes(scope));
|
|
3069
|
+
var resolveAgentPrincipal = async (request, config) => {
|
|
3070
|
+
const credential = await config.verifyCredential(request);
|
|
3071
|
+
if (credential === undefined)
|
|
3072
|
+
return;
|
|
3073
|
+
if (credential.resource !== undefined && credential.resource !== config.resource) {
|
|
3074
|
+
return;
|
|
3075
|
+
}
|
|
3076
|
+
if (credential.expiresAt !== undefined && credential.expiresAt <= Date.now()) {
|
|
3077
|
+
return;
|
|
3078
|
+
}
|
|
3079
|
+
const registration = await config.registrationStore.findByAgentId(credential.agentId);
|
|
3080
|
+
if (registration === undefined || registration.status !== "active") {
|
|
3081
|
+
return;
|
|
3082
|
+
}
|
|
3083
|
+
const registeredScopes = intersectScopes(credential.scopes, registration.allowedScopes, config.scopes);
|
|
3084
|
+
if (credential.userId === undefined) {
|
|
3085
|
+
if (config.allowUndelegated !== true)
|
|
3086
|
+
return;
|
|
3087
|
+
return {
|
|
3088
|
+
agentId: registration.agentId,
|
|
3089
|
+
kind: "agent",
|
|
3090
|
+
name: registration.name,
|
|
3091
|
+
scopes: registeredScopes,
|
|
3092
|
+
trust: "registered"
|
|
3093
|
+
};
|
|
3094
|
+
}
|
|
3095
|
+
const delegation = await config.delegationStore.findActiveDelegation({
|
|
3096
|
+
agentId: registration.agentId,
|
|
3097
|
+
organizationId: credential.organizationId,
|
|
3098
|
+
userId: credential.userId
|
|
3099
|
+
});
|
|
3100
|
+
if (delegation === undefined)
|
|
3101
|
+
return;
|
|
3102
|
+
return {
|
|
3103
|
+
agentId: registration.agentId,
|
|
3104
|
+
authorizationDetails: delegation.authorizationDetails,
|
|
3105
|
+
delegationId: delegation.delegationId,
|
|
3106
|
+
kind: "agent",
|
|
3107
|
+
name: registration.name,
|
|
3108
|
+
organizationId: delegation.organizationId,
|
|
3109
|
+
scopes: intersectScopes(registeredScopes, delegation.scopes),
|
|
3110
|
+
trust: "delegated",
|
|
3111
|
+
userId: delegation.userId
|
|
3112
|
+
};
|
|
3113
|
+
};
|
|
3114
|
+
|
|
3115
|
+
// src/agents/routes.ts
|
|
3116
|
+
var quoteHeaderValue = (value) => {
|
|
3117
|
+
const printable = [...value].filter((character) => {
|
|
3118
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
3119
|
+
return codePoint >= 32 && codePoint !== 127;
|
|
3120
|
+
}).join("");
|
|
3121
|
+
return `"${printable.replace(/[\\"]/g, "\\$&")}"`;
|
|
3122
|
+
};
|
|
3123
|
+
var agentAuthChallenge = ({
|
|
3124
|
+
config,
|
|
3125
|
+
error,
|
|
3126
|
+
requiredScopes = []
|
|
3127
|
+
}) => {
|
|
3128
|
+
const parameters = [
|
|
3129
|
+
`resource_metadata=${quoteHeaderValue(agentResourceMetadataUrl(config))}`
|
|
3130
|
+
];
|
|
3131
|
+
if (requiredScopes.length > 0) {
|
|
3132
|
+
parameters.push(`scope=${quoteHeaderValue(requiredScopes.join(" "))}`);
|
|
3133
|
+
}
|
|
3134
|
+
if (error !== undefined) {
|
|
3135
|
+
parameters.push(`error=${quoteHeaderValue(error)}`);
|
|
3136
|
+
}
|
|
3137
|
+
return `Bearer ${parameters.join(", ")}`;
|
|
3138
|
+
};
|
|
3139
|
+
var agentResourceMetadataUrl = (config) => new URL(config.metadataRoute ?? DEFAULT_AGENT_RESOURCE_METADATA_ROUTE, config.resource).toString();
|
|
3140
|
+
var failureResponse = (config, failure, requiredScopes) => new Response(JSON.stringify({
|
|
3141
|
+
error: failure.code === "Forbidden" ? "insufficient_scope" : "invalid_token",
|
|
3142
|
+
error_description: failure.message
|
|
3143
|
+
}), {
|
|
3144
|
+
headers: {
|
|
3145
|
+
"content-type": "application/json",
|
|
3146
|
+
"www-authenticate": agentAuthChallenge({
|
|
3147
|
+
config,
|
|
3148
|
+
error: failure.code === "Forbidden" ? "insufficient_scope" : "invalid_token",
|
|
3149
|
+
requiredScopes
|
|
3150
|
+
})
|
|
3151
|
+
},
|
|
3152
|
+
status: failure.code === "Forbidden" ? 403 : 401
|
|
3153
|
+
});
|
|
3154
|
+
var agentAuthPlugin = (config) => {
|
|
3155
|
+
const plugin = new Elysia2().derive(({ request }) => ({
|
|
3156
|
+
protectAgent: async (requiredScopes, handleAuth, handleAuthFail) => {
|
|
3157
|
+
if (config === undefined) {
|
|
3158
|
+
const failure = {
|
|
3159
|
+
code: "Unauthorized",
|
|
3160
|
+
message: "Agent is not authenticated"
|
|
3161
|
+
};
|
|
3162
|
+
return await handleAuthFail?.(failure) ?? new Response(failure.message, { status: 401 });
|
|
3163
|
+
}
|
|
3164
|
+
const principal = await resolveAgentPrincipal(request, config);
|
|
3165
|
+
if (principal === undefined) {
|
|
3166
|
+
const failure = {
|
|
3167
|
+
code: "Unauthorized",
|
|
3168
|
+
message: "Agent is not authenticated"
|
|
3169
|
+
};
|
|
3170
|
+
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
3171
|
+
}
|
|
3172
|
+
if (!agentHasScopes(principal, requiredScopes)) {
|
|
3173
|
+
const failure = {
|
|
3174
|
+
code: "Forbidden",
|
|
3175
|
+
message: "Insufficient agent scopes"
|
|
3176
|
+
};
|
|
3177
|
+
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
3178
|
+
}
|
|
3179
|
+
return handleAuth(principal);
|
|
3180
|
+
}
|
|
3181
|
+
}));
|
|
3182
|
+
if (config === undefined)
|
|
3183
|
+
return plugin.as("global");
|
|
3184
|
+
return plugin.get(config.metadataRoute ?? DEFAULT_AGENT_RESOURCE_METADATA_ROUTE, () => agentProtectedResourceMetadata(config)).as("global");
|
|
3185
|
+
};
|
|
3186
|
+
|
|
3035
3187
|
// src/audit/config.ts
|
|
3036
3188
|
var createAuditEmitter = ({ auditStore, onAuditEvent, redact }) => async (event) => {
|
|
3037
3189
|
const finalEvent = redact ? await redact(event) : event;
|
|
@@ -3151,7 +3303,7 @@ var composeSignOutAudit = (onSignOut, emit) => async (context) => {
|
|
|
3151
3303
|
};
|
|
3152
3304
|
|
|
3153
3305
|
// src/authorization/protectPermission.ts
|
|
3154
|
-
import { Elysia as
|
|
3306
|
+
import { Elysia as Elysia4, t as t3 } from "elysia";
|
|
3155
3307
|
|
|
3156
3308
|
// src/session/access.ts
|
|
3157
3309
|
var collectSessionEntries = (session) => Object.entries(session).filter((entry) => isUserSessionId(entry[0]));
|
|
@@ -3265,11 +3417,11 @@ var loadSessionFromSource = async ({
|
|
|
3265
3417
|
};
|
|
3266
3418
|
|
|
3267
3419
|
// src/session/state.ts
|
|
3268
|
-
import { Elysia as
|
|
3420
|
+
import { Elysia as Elysia3 } from "elysia";
|
|
3269
3421
|
var sessionStore = () => {
|
|
3270
3422
|
const initialSession = {};
|
|
3271
3423
|
const initialUnregisteredSession = {};
|
|
3272
|
-
return new
|
|
3424
|
+
return new Elysia3({ name: "sessionStore" }).state({
|
|
3273
3425
|
session: initialSession,
|
|
3274
3426
|
unregisteredSession: initialUnregisteredSession
|
|
3275
3427
|
});
|
|
@@ -3291,7 +3443,7 @@ var protectPermissionPlugin = ({
|
|
|
3291
3443
|
authSessionStore,
|
|
3292
3444
|
emit,
|
|
3293
3445
|
hasPermission
|
|
3294
|
-
}) => new
|
|
3446
|
+
}) => new Elysia4().use(sessionStore()).guard({ cookie: t3.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
|
|
3295
3447
|
protectPermission: (check, handleAuth, handleAuthFail) => getStatusFromSource({
|
|
3296
3448
|
authSessionStore,
|
|
3297
3449
|
session,
|
|
@@ -3328,7 +3480,7 @@ var protectPermissionPlugin = ({
|
|
|
3328
3480
|
})).as("global");
|
|
3329
3481
|
|
|
3330
3482
|
// src/compliance/routes.ts
|
|
3331
|
-
import { Elysia as
|
|
3483
|
+
import { Elysia as Elysia5, t as t4 } from "elysia";
|
|
3332
3484
|
|
|
3333
3485
|
// src/utils.ts
|
|
3334
3486
|
init_constants();
|
|
@@ -3427,6 +3579,18 @@ var resolveOAuthAuthorization = async ({
|
|
|
3427
3579
|
let userIdentity;
|
|
3428
3580
|
let accessToken = tokenResponse.access_token;
|
|
3429
3581
|
let refreshToken = tokenResponse.refresh_token;
|
|
3582
|
+
if (authProvider === "withings" && !accessToken) {
|
|
3583
|
+
const body = Reflect.get(tokenResponse, "body");
|
|
3584
|
+
if (body && typeof body === "object") {
|
|
3585
|
+
const nestedAccessToken = Reflect.get(body, "access_token");
|
|
3586
|
+
if (typeof nestedAccessToken === "string") {
|
|
3587
|
+
accessToken = nestedAccessToken;
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
if (typeof accessToken !== "string" || accessToken.length === 0) {
|
|
3592
|
+
throw new Error("OAuth authorization response contains no access_token");
|
|
3593
|
+
}
|
|
3430
3594
|
if (tokenResponse.id_token) {
|
|
3431
3595
|
userIdentity = normalizeProviderIdentity({
|
|
3432
3596
|
identity: decodeJWT(tokenResponse.id_token),
|
|
@@ -3445,7 +3609,7 @@ var resolveOAuthAuthorization = async ({
|
|
|
3445
3609
|
refreshToken = tokenResponse.body.refresh_token;
|
|
3446
3610
|
} else {
|
|
3447
3611
|
userIdentity = normalizeProviderIdentity({
|
|
3448
|
-
identity: await providerInstance.fetchUserProfile(
|
|
3612
|
+
identity: await providerInstance.fetchUserProfile(accessToken),
|
|
3449
3613
|
providerConfiguration: meta,
|
|
3450
3614
|
source: "profile"
|
|
3451
3615
|
});
|
|
@@ -3643,7 +3807,7 @@ var complianceRoutes = ({
|
|
|
3643
3807
|
emit,
|
|
3644
3808
|
exportUserData,
|
|
3645
3809
|
getUserId
|
|
3646
|
-
}) => new
|
|
3810
|
+
}) => new Elysia5().use(sessionStore()).get(`${complianceRoute}/export`, async ({
|
|
3647
3811
|
cookie: { user_session_id },
|
|
3648
3812
|
status,
|
|
3649
3813
|
store: { session }
|
|
@@ -3699,11 +3863,11 @@ var complianceRoutes = ({
|
|
|
3699
3863
|
}, { cookie: t4.Cookie({ user_session_id: userSessionIdTypebox }) });
|
|
3700
3864
|
|
|
3701
3865
|
// src/credentials/routes.ts
|
|
3702
|
-
import { Elysia as
|
|
3866
|
+
import { Elysia as Elysia10 } from "elysia";
|
|
3703
3867
|
|
|
3704
3868
|
// src/credentials/emailVerification.ts
|
|
3705
3869
|
init_crypto();
|
|
3706
|
-
import { Elysia as
|
|
3870
|
+
import { Elysia as Elysia6, t as t5 } from "elysia";
|
|
3707
3871
|
|
|
3708
3872
|
// src/credentials/config.ts
|
|
3709
3873
|
init_constants();
|
|
@@ -3718,7 +3882,7 @@ var credentialsEmailVerification = ({
|
|
|
3718
3882
|
onSendEmail,
|
|
3719
3883
|
verificationTokenDurationMs = DEFAULT_VERIFICATION_TOKEN_TTL_MS,
|
|
3720
3884
|
verifyEmailRoute = "/auth/verify-email"
|
|
3721
|
-
}) => new
|
|
3885
|
+
}) => new Elysia6().post(verifyEmailRoute, async ({ body: { token }, status }) => {
|
|
3722
3886
|
const consumed = await credentialStore.consumeVerificationToken(await hashToken(token));
|
|
3723
3887
|
if (!consumed) {
|
|
3724
3888
|
return status("Bad Request", "Invalid or expired verification token");
|
|
@@ -3750,7 +3914,7 @@ var credentialsEmailVerification = ({
|
|
|
3750
3914
|
// src/credentials/login.ts
|
|
3751
3915
|
init_constants();
|
|
3752
3916
|
init_crypto();
|
|
3753
|
-
import { Elysia as
|
|
3917
|
+
import { Elysia as Elysia7, t as t6 } from "elysia";
|
|
3754
3918
|
|
|
3755
3919
|
// src/credentials/import.ts
|
|
3756
3920
|
init_crypto();
|
|
@@ -3948,7 +4112,7 @@ var credentialsLogin = ({
|
|
|
3948
4112
|
rehashOnLogin = false,
|
|
3949
4113
|
requireEmailVerification = false,
|
|
3950
4114
|
sessionDurationMs = DEFAULT_CREDENTIAL_SESSION_TTL_MS
|
|
3951
|
-
}) => new
|
|
4115
|
+
}) => new Elysia7().use(sessionStore()).post(loginRoute, async ({
|
|
3952
4116
|
body: { email, password },
|
|
3953
4117
|
cookie: { user_session_id },
|
|
3954
4118
|
request,
|
|
@@ -4037,7 +4201,7 @@ var credentialsLogin = ({
|
|
|
4037
4201
|
|
|
4038
4202
|
// src/credentials/passwordReset.ts
|
|
4039
4203
|
init_crypto();
|
|
4040
|
-
import { Elysia as
|
|
4204
|
+
import { Elysia as Elysia8, t as t7 } from "elysia";
|
|
4041
4205
|
var credentialsPasswordReset = ({
|
|
4042
4206
|
credentialStore,
|
|
4043
4207
|
onPasswordReset,
|
|
@@ -4045,7 +4209,7 @@ var credentialsPasswordReset = ({
|
|
|
4045
4209
|
passwordPolicy,
|
|
4046
4210
|
resetPasswordRoute = "/auth/reset-password",
|
|
4047
4211
|
resetTokenDurationMs = DEFAULT_RESET_TOKEN_TTL_MS
|
|
4048
|
-
}) => new
|
|
4212
|
+
}) => new Elysia8().post(`${resetPasswordRoute}/request`, async ({ body: { email }, status }) => {
|
|
4049
4213
|
const normalizedEmail = email.trim().toLowerCase();
|
|
4050
4214
|
const credential = await credentialStore.getCredentialByEmail(normalizedEmail);
|
|
4051
4215
|
if (credential && credential.status === "active") {
|
|
@@ -4096,7 +4260,7 @@ var credentialsPasswordReset = ({
|
|
|
4096
4260
|
|
|
4097
4261
|
// src/credentials/register.ts
|
|
4098
4262
|
init_crypto();
|
|
4099
|
-
import { Elysia as
|
|
4263
|
+
import { Elysia as Elysia9, t as t8 } from "elysia";
|
|
4100
4264
|
var credentialsRegister = ({
|
|
4101
4265
|
authSessionStore,
|
|
4102
4266
|
cookieSecure,
|
|
@@ -4110,7 +4274,7 @@ var credentialsRegister = ({
|
|
|
4110
4274
|
requireEmailVerification = false,
|
|
4111
4275
|
sessionDurationMs = DEFAULT_CREDENTIAL_SESSION_TTL_MS,
|
|
4112
4276
|
verificationTokenDurationMs = DEFAULT_VERIFICATION_TOKEN_TTL_MS
|
|
4113
|
-
}) => new
|
|
4277
|
+
}) => new Elysia9().use(sessionStore()).post(registerRoute, async ({
|
|
4114
4278
|
body: { email, password, ...extraFields },
|
|
4115
4279
|
cookie: { user_session_id },
|
|
4116
4280
|
status,
|
|
@@ -4188,16 +4352,16 @@ var credentialsRegister = ({
|
|
|
4188
4352
|
});
|
|
4189
4353
|
|
|
4190
4354
|
// src/credentials/routes.ts
|
|
4191
|
-
var credentialRoutes = (config) => new
|
|
4355
|
+
var credentialRoutes = (config) => new Elysia10().use(credentialsRegister(config)).use(credentialsEmailVerification(config)).use(credentialsLogin(config)).use(credentialsPasswordReset(config));
|
|
4192
4356
|
|
|
4193
4357
|
// src/htmx/routes.ts
|
|
4194
|
-
import { Elysia as
|
|
4358
|
+
import { Elysia as Elysia12 } from "elysia";
|
|
4195
4359
|
|
|
4196
4360
|
// src/routes/protectRoute.ts
|
|
4197
|
-
import { Elysia as
|
|
4361
|
+
import { Elysia as Elysia11, t as t9 } from "elysia";
|
|
4198
4362
|
var protectRoutePlugin = ({
|
|
4199
4363
|
authSessionStore
|
|
4200
|
-
} = {}) => new
|
|
4364
|
+
} = {}) => new Elysia11().use(sessionStore()).guard({ cookie: t9.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
|
|
4201
4365
|
protectRoute: (handleAuth, handleAuthFail) => getStatusFromSource({
|
|
4202
4366
|
authSessionStore,
|
|
4203
4367
|
session,
|
|
@@ -4306,7 +4470,7 @@ var signInPrompt = `<section class="auth-content"><h1 class="page-heading">Not a
|
|
|
4306
4470
|
var createAuthHtmxRoutes = (config) => {
|
|
4307
4471
|
const renderers = resolveAuthHtmxRenderers(config);
|
|
4308
4472
|
const authorizationHref = config.authorizationHref ?? ((provider) => `/oauth2/${provider}/authorization`);
|
|
4309
|
-
return new
|
|
4473
|
+
return new Elysia12().use(protectRoutePlugin({
|
|
4310
4474
|
authSessionStore: config.authSessionStore
|
|
4311
4475
|
})).get("/htmx/login", () => html(renderers.providerLogin("Sign in with", true))).get("/htmx/link", () => html(renderers.providerLogin("Link", false))).get("/htmx/connector-links", () => html(renderers.connectorLinks())).get("/htmx/auth-menu", ({ protectRoute }) => protectRoute((user) => html(renderers.authMenu(user)), () => html(renderers.authMenu(null)))).get("/htmx/me", ({ protectRoute }) => protectRoute((user) => html(renderers.protected(user)), () => html(signInPrompt))).get("/htmx/account", ({ protectRoute }) => protectRoute((user) => html(renderers.account(user)), () => html(signInPrompt))).get("/htmx/identities", ({ protectRoute, query }) => protectRoute(async (user) => {
|
|
4312
4476
|
const search = typeof query.query === "string" ? query.query : "";
|
|
@@ -4412,11 +4576,11 @@ var isMfaEnrolled = (enrollment) => enrollment !== undefined && (enrollment.totp
|
|
|
4412
4576
|
var createMfaGate = ({ getUserId, mfaStore }) => async (user) => isMfaEnrolled(await mfaStore.getEnrollment(getUserId(user)));
|
|
4413
4577
|
|
|
4414
4578
|
// src/mfa/routes.ts
|
|
4415
|
-
import { Elysia as
|
|
4579
|
+
import { Elysia as Elysia17 } from "elysia";
|
|
4416
4580
|
|
|
4417
4581
|
// src/mfa/challenge.ts
|
|
4418
4582
|
init_crypto();
|
|
4419
|
-
import { Elysia as
|
|
4583
|
+
import { Elysia as Elysia14, t as t11 } from "elysia";
|
|
4420
4584
|
|
|
4421
4585
|
// src/mfa/backupCodes.ts
|
|
4422
4586
|
init_crypto();
|
|
@@ -4452,7 +4616,7 @@ var encryptTotpSecret = (secret, encryptionKey) => encryptionKey ? encryptSecret
|
|
|
4452
4616
|
|
|
4453
4617
|
// src/mfa/sms.ts
|
|
4454
4618
|
init_crypto();
|
|
4455
|
-
import { Elysia as
|
|
4619
|
+
import { Elysia as Elysia13, t as t10 } from "elysia";
|
|
4456
4620
|
var DECIMAL_RADIX2 = 10;
|
|
4457
4621
|
var MASK_VISIBLE_DIGITS = 4;
|
|
4458
4622
|
var E164_PATTERN = /^\+[1-9]\d{7,14}$/u;
|
|
@@ -4505,7 +4669,7 @@ var mfaSmsRoutes = ({
|
|
|
4505
4669
|
smsMaxAttempts = DEFAULT_SMS_MAX_ATTEMPTS,
|
|
4506
4670
|
smsSetupRoute = "/auth/mfa/sms/setup",
|
|
4507
4671
|
smsVerifyRoute = "/auth/mfa/sms/verify"
|
|
4508
|
-
}) => new
|
|
4672
|
+
}) => new Elysia13().use(sessionStore()).post(smsSetupRoute, async ({
|
|
4509
4673
|
body: { phone },
|
|
4510
4674
|
cookie: { user_session_id },
|
|
4511
4675
|
status,
|
|
@@ -4613,7 +4777,7 @@ var mfaChallenge = ({
|
|
|
4613
4777
|
smsCodeTtlMs = DEFAULT_SMS_CODE_TTL_MS,
|
|
4614
4778
|
smsMaxAttempts = DEFAULT_SMS_MAX_ATTEMPTS,
|
|
4615
4779
|
totpMaxAttempts = DEFAULT_TOTP_MAX_ATTEMPTS
|
|
4616
|
-
}) => new
|
|
4780
|
+
}) => new Elysia14().use(sessionStore()).post(challengeRoute, async ({
|
|
4617
4781
|
body: { action, code, factor },
|
|
4618
4782
|
cookie: { user_session_id },
|
|
4619
4783
|
status,
|
|
@@ -4753,7 +4917,7 @@ var mfaChallenge = ({
|
|
|
4753
4917
|
});
|
|
4754
4918
|
|
|
4755
4919
|
// src/mfa/management.ts
|
|
4756
|
-
import { Elysia as
|
|
4920
|
+
import { Elysia as Elysia15, t as t12 } from "elysia";
|
|
4757
4921
|
var maskPhone2 = (phone) => {
|
|
4758
4922
|
if (!phone)
|
|
4759
4923
|
return null;
|
|
@@ -4766,7 +4930,7 @@ var mfaManagementRoutes = ({
|
|
|
4766
4930
|
getUserId,
|
|
4767
4931
|
managementRoute = "/auth/mfa",
|
|
4768
4932
|
mfaStore
|
|
4769
|
-
}) => new
|
|
4933
|
+
}) => new Elysia15().use(sessionStore()).get(managementRoute, async ({
|
|
4770
4934
|
cookie: { user_session_id },
|
|
4771
4935
|
status,
|
|
4772
4936
|
store: { session }
|
|
@@ -4809,7 +4973,7 @@ var mfaManagementRoutes = ({
|
|
|
4809
4973
|
|
|
4810
4974
|
// src/mfa/totp.ts
|
|
4811
4975
|
init_crypto();
|
|
4812
|
-
import { Elysia as
|
|
4976
|
+
import { Elysia as Elysia16, t as t13 } from "elysia";
|
|
4813
4977
|
var mfaTotpRoutes = ({
|
|
4814
4978
|
authSessionStore,
|
|
4815
4979
|
backupCodeCount = DEFAULT_BACKUP_CODE_COUNT,
|
|
@@ -4820,7 +4984,7 @@ var mfaTotpRoutes = ({
|
|
|
4820
4984
|
onMfaEnrolled,
|
|
4821
4985
|
totpSetupRoute = "/auth/mfa/totp/setup",
|
|
4822
4986
|
totpVerifyRoute = "/auth/mfa/totp/verify"
|
|
4823
|
-
}) => new
|
|
4987
|
+
}) => new Elysia16().use(sessionStore()).post(totpSetupRoute, async ({
|
|
4824
4988
|
cookie: { user_session_id },
|
|
4825
4989
|
status,
|
|
4826
4990
|
store: { session }
|
|
@@ -4897,12 +5061,12 @@ var mfaTotpRoutes = ({
|
|
|
4897
5061
|
});
|
|
4898
5062
|
|
|
4899
5063
|
// src/mfa/routes.ts
|
|
4900
|
-
var mfaRoutes = (config) => new
|
|
5064
|
+
var mfaRoutes = (config) => new Elysia17().use(mfaManagementRoutes(config)).use(mfaTotpRoutes(config)).use(mfaSmsRoutes(config)).use(mfaChallenge(config));
|
|
4901
5065
|
|
|
4902
5066
|
// src/oidc/routes.ts
|
|
4903
5067
|
init_constants();
|
|
4904
5068
|
init_crypto();
|
|
4905
|
-
import { Elysia as
|
|
5069
|
+
import { Elysia as Elysia18, t as t14 } from "elysia";
|
|
4906
5070
|
|
|
4907
5071
|
// src/oidc/config.ts
|
|
4908
5072
|
init_constants();
|
|
@@ -5020,13 +5184,11 @@ var buildAccessClaims = ({
|
|
|
5020
5184
|
};
|
|
5021
5185
|
if (act !== undefined)
|
|
5022
5186
|
claims.act = act;
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
cnf["x5t#S256"] = clientCertThumbprint;
|
|
5029
|
-
}
|
|
5187
|
+
const cnf = {
|
|
5188
|
+
...dpopJkt === undefined ? {} : { jkt: dpopJkt },
|
|
5189
|
+
...clientCertThumbprint === undefined ? {} : { "x5t#S256": clientCertThumbprint }
|
|
5190
|
+
};
|
|
5191
|
+
if (Object.keys(cnf).length > 0) {
|
|
5030
5192
|
claims.cnf = cnf;
|
|
5031
5193
|
}
|
|
5032
5194
|
return claims;
|
|
@@ -5253,6 +5415,13 @@ var decideDeviceAuthorization = async (config, userCode, approval) => {
|
|
|
5253
5415
|
return { error: "already_decided", ok: false };
|
|
5254
5416
|
}
|
|
5255
5417
|
await config.deviceAuthorizationStore.updateStatus(record.deviceCodeHash, approval.status, approval.userSub);
|
|
5418
|
+
if (approval.status === "approved" && approval.userSub !== undefined) {
|
|
5419
|
+
await config.onDeviceAuthorizationApproved?.({
|
|
5420
|
+
clientId: record.clientId,
|
|
5421
|
+
scopes: record.scopes,
|
|
5422
|
+
userSub: approval.userSub
|
|
5423
|
+
});
|
|
5424
|
+
}
|
|
5256
5425
|
return { ok: true };
|
|
5257
5426
|
};
|
|
5258
5427
|
var approveDeviceAuthorization = async ({
|
|
@@ -6334,6 +6503,7 @@ var metadataToClient = (clientId, metadata, transform) => {
|
|
|
6334
6503
|
const base = {
|
|
6335
6504
|
backchannelLogoutUri: metadata.backchannel_logout_uri,
|
|
6336
6505
|
clientId,
|
|
6506
|
+
grantTypes: metadata.grant_types,
|
|
6337
6507
|
jwks: metadata.jwks,
|
|
6338
6508
|
jwksUri: metadata.jwks_uri,
|
|
6339
6509
|
name: metadata.client_name ?? clientId,
|
|
@@ -6347,6 +6517,7 @@ var clientToMetadata = (client) => ({
|
|
|
6347
6517
|
backchannel_logout_uri: client.backchannelLogoutUri,
|
|
6348
6518
|
client_id: client.clientId,
|
|
6349
6519
|
client_name: client.name,
|
|
6520
|
+
grant_types: client.grantTypes,
|
|
6350
6521
|
jwks: client.jwks,
|
|
6351
6522
|
jwks_uri: client.jwksUri,
|
|
6352
6523
|
post_logout_redirect_uris: client.postLogoutRedirectUris,
|
|
@@ -6418,6 +6589,7 @@ var registerClient = async ({
|
|
|
6418
6589
|
initialAccessTokenStore,
|
|
6419
6590
|
metadata,
|
|
6420
6591
|
onClientRegistration,
|
|
6592
|
+
onClientRegistered,
|
|
6421
6593
|
presentedInitialAccessToken,
|
|
6422
6594
|
registrationBaseUrl,
|
|
6423
6595
|
registrationTokenStore
|
|
@@ -6438,7 +6610,8 @@ var registerClient = async ({
|
|
|
6438
6610
|
return { body: { error: "invalid_token" }, ok: false, status: 401 };
|
|
6439
6611
|
}
|
|
6440
6612
|
}
|
|
6441
|
-
|
|
6613
|
+
const requiresRedirect = metadata.grant_types === undefined || metadata.grant_types.includes("authorization_code");
|
|
6614
|
+
if (requiresRedirect && (!Array.isArray(metadata.redirect_uris) || metadata.redirect_uris.length === 0)) {
|
|
6442
6615
|
return {
|
|
6443
6616
|
body: { error: "invalid_redirect_uri" },
|
|
6444
6617
|
ok: false,
|
|
@@ -6463,6 +6636,7 @@ var registerClient = async ({
|
|
|
6463
6636
|
await clientStore.saveClient(client);
|
|
6464
6637
|
const regToken = await mintRegistrationToken(clientId);
|
|
6465
6638
|
await registrationTokenStore.saveToken(regToken.record);
|
|
6639
|
+
await onClientRegistered?.({ client, metadata });
|
|
6466
6640
|
return {
|
|
6467
6641
|
body: {
|
|
6468
6642
|
...clientToMetadata(client),
|
|
@@ -6505,7 +6679,8 @@ var updateRegisteredClient = async ({
|
|
|
6505
6679
|
status: 403
|
|
6506
6680
|
};
|
|
6507
6681
|
}
|
|
6508
|
-
|
|
6682
|
+
const requiresRedirect = metadata.grant_types === undefined || metadata.grant_types.includes("authorization_code");
|
|
6683
|
+
if (requiresRedirect && (!Array.isArray(metadata.redirect_uris) || metadata.redirect_uris.length === 0)) {
|
|
6509
6684
|
return {
|
|
6510
6685
|
body: { error: "invalid_redirect_uri" },
|
|
6511
6686
|
status: 400
|
|
@@ -6879,6 +7054,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
6879
7054
|
}
|
|
6880
7055
|
const discovery = {
|
|
6881
7056
|
authorization_endpoint: `${issuer}${authorizeRoute}`,
|
|
7057
|
+
authorization_response_iss_parameter_supported: true,
|
|
6882
7058
|
backchannel_logout_session_supported: false,
|
|
6883
7059
|
backchannel_logout_supported: true,
|
|
6884
7060
|
code_challenge_methods_supported: ["S256"],
|
|
@@ -6892,7 +7068,6 @@ var oidcProviderRoutes = (config) => {
|
|
|
6892
7068
|
request_object_signing_alg_values_supported: ["ES256"],
|
|
6893
7069
|
request_parameter_supported: true,
|
|
6894
7070
|
require_signed_request_object_supported: true,
|
|
6895
|
-
authorization_response_iss_parameter_supported: true,
|
|
6896
7071
|
response_modes_supported: ["query", "form_post"],
|
|
6897
7072
|
response_types_supported: ["code"],
|
|
6898
7073
|
revocation_endpoint: `${issuer}${revokeRoute}`,
|
|
@@ -6971,7 +7146,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
6971
7146
|
url.searchParams.set("state", query.state);
|
|
6972
7147
|
return redirectTo(url.toString());
|
|
6973
7148
|
};
|
|
6974
|
-
return new
|
|
7149
|
+
return new Elysia18().use(sessionStore()).get(authorizeRoute, async ({
|
|
6975
7150
|
cookie: { user_session_id },
|
|
6976
7151
|
query,
|
|
6977
7152
|
request,
|
|
@@ -7466,6 +7641,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
7466
7641
|
clientStore,
|
|
7467
7642
|
initialAccessTokenStore: config.initialAccessTokenStore,
|
|
7468
7643
|
metadata: body,
|
|
7644
|
+
onClientRegistered: config.onClientRegistered,
|
|
7469
7645
|
onClientRegistration: config.onClientRegistration,
|
|
7470
7646
|
presentedInitialAccessToken: presented,
|
|
7471
7647
|
registrationBaseUrl,
|
|
@@ -7476,6 +7652,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
7476
7652
|
body: t14.Object({
|
|
7477
7653
|
backchannel_logout_uri: t14.Optional(t14.String()),
|
|
7478
7654
|
client_name: t14.Optional(t14.String()),
|
|
7655
|
+
grant_types: t14.Optional(t14.Array(t14.String())),
|
|
7479
7656
|
jwks: t14.Optional(t14.Any()),
|
|
7480
7657
|
jwks_uri: t14.Optional(t14.String()),
|
|
7481
7658
|
post_logout_redirect_uris: t14.Optional(t14.Array(t14.String())),
|
|
@@ -7518,6 +7695,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
7518
7695
|
body: t14.Object({
|
|
7519
7696
|
backchannel_logout_uri: t14.Optional(t14.String()),
|
|
7520
7697
|
client_name: t14.Optional(t14.String()),
|
|
7698
|
+
grant_types: t14.Optional(t14.Array(t14.String())),
|
|
7521
7699
|
jwks: t14.Optional(t14.Any()),
|
|
7522
7700
|
jwks_uri: t14.Optional(t14.String()),
|
|
7523
7701
|
post_logout_redirect_uris: t14.Optional(t14.Array(t14.String())),
|
|
@@ -7588,7 +7766,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
7588
7766
|
};
|
|
7589
7767
|
|
|
7590
7768
|
// src/organizations/routes.ts
|
|
7591
|
-
import { Elysia as
|
|
7769
|
+
import { Elysia as Elysia19, t as t15 } from "elysia";
|
|
7592
7770
|
|
|
7593
7771
|
// src/organizations/config.ts
|
|
7594
7772
|
init_constants();
|
|
@@ -7720,7 +7898,7 @@ var organizationRoutes = ({
|
|
|
7720
7898
|
}
|
|
7721
7899
|
return membership?.status === "active";
|
|
7722
7900
|
};
|
|
7723
|
-
return new
|
|
7901
|
+
return new Elysia19().use(sessionStore()).get(organizationsRoute, async ({
|
|
7724
7902
|
cookie: { user_session_id },
|
|
7725
7903
|
status,
|
|
7726
7904
|
store: { session }
|
|
@@ -7952,7 +8130,7 @@ var organizationRoutes = ({
|
|
|
7952
8130
|
|
|
7953
8131
|
// src/passwordless/routes.ts
|
|
7954
8132
|
init_crypto();
|
|
7955
|
-
import { Elysia as
|
|
8133
|
+
import { Elysia as Elysia20, t as t16 } from "elysia";
|
|
7956
8134
|
|
|
7957
8135
|
// src/passwordless/config.ts
|
|
7958
8136
|
init_constants();
|
|
@@ -8013,7 +8191,7 @@ var passwordlessRoutes = ({
|
|
|
8013
8191
|
await onPasswordlessLogin?.({ user, userSessionId });
|
|
8014
8192
|
return userSessionId;
|
|
8015
8193
|
};
|
|
8016
|
-
const magicLink = onSendMagicLink ? new
|
|
8194
|
+
const magicLink = onSendMagicLink ? new Elysia20().use(sessionStore()).post(`${passwordlessRoute}/magic-link`, async ({ body: { email }, status }) => {
|
|
8017
8195
|
const normalizedEmail = email.trim().toLowerCase();
|
|
8018
8196
|
const token = generateSecureToken();
|
|
8019
8197
|
const expiresAt = Date.now() + magicLinkTokenDurationMs;
|
|
@@ -8043,8 +8221,8 @@ var passwordlessRoutes = ({
|
|
|
8043
8221
|
return status("Unauthorized", "No account for this email");
|
|
8044
8222
|
}
|
|
8045
8223
|
return status("OK", { status: "authenticated" });
|
|
8046
|
-
}, { body: t16.Object({ token: t16.String() }), cookie }) : new
|
|
8047
|
-
const otp = onSendOtp ? new
|
|
8224
|
+
}, { body: t16.Object({ token: t16.String() }), cookie }) : new Elysia20;
|
|
8225
|
+
const otp = onSendOtp ? new Elysia20().use(sessionStore()).post(`${passwordlessRoute}/otp`, async ({ body: { email }, status }) => {
|
|
8048
8226
|
const normalizedEmail = email.trim().toLowerCase();
|
|
8049
8227
|
const code = generateOtpCode(otpLength);
|
|
8050
8228
|
const expiresAt = Date.now() + otpDurationMs;
|
|
@@ -8081,12 +8259,12 @@ var passwordlessRoutes = ({
|
|
|
8081
8259
|
email: t16.String()
|
|
8082
8260
|
}),
|
|
8083
8261
|
cookie
|
|
8084
|
-
}) : new
|
|
8085
|
-
return new
|
|
8262
|
+
}) : new Elysia20;
|
|
8263
|
+
return new Elysia20().use(magicLink).use(otp);
|
|
8086
8264
|
};
|
|
8087
8265
|
|
|
8088
8266
|
// src/portal/routes.ts
|
|
8089
|
-
import { Elysia as
|
|
8267
|
+
import { Elysia as Elysia21, t as t17 } from "elysia";
|
|
8090
8268
|
|
|
8091
8269
|
// src/scim/config.ts
|
|
8092
8270
|
init_crypto();
|
|
@@ -8181,7 +8359,7 @@ var portalRoutes = ({
|
|
|
8181
8359
|
}) => {
|
|
8182
8360
|
const loadSession = (authorization) => resolveSetupSession({ authorization, setupSessionStore });
|
|
8183
8361
|
const oidcRedirectUri = (origin, organizationId) => `${origin}${ssoRoute}/oidc/${organizationId}/callback`;
|
|
8184
|
-
return new
|
|
8362
|
+
return new Elysia21().get(`${portalRoute}/session`, async ({ headers, request, status }) => {
|
|
8185
8363
|
const session = await loadSession(headers.authorization);
|
|
8186
8364
|
if (!session) {
|
|
8187
8365
|
return status("Unauthorized", "Invalid or expired setup link");
|
|
@@ -8328,7 +8506,7 @@ var portalRoutes = ({
|
|
|
8328
8506
|
};
|
|
8329
8507
|
|
|
8330
8508
|
// src/roles/routes.ts
|
|
8331
|
-
import { Elysia as
|
|
8509
|
+
import { Elysia as Elysia22, t as t18 } from "elysia";
|
|
8332
8510
|
|
|
8333
8511
|
// src/roles/config.ts
|
|
8334
8512
|
var DEFAULT_ROLES_ROUTE = "/auth/roles";
|
|
@@ -8379,7 +8557,7 @@ var roleRoutes = ({
|
|
|
8379
8557
|
}
|
|
8380
8558
|
return membership?.status === "active";
|
|
8381
8559
|
};
|
|
8382
|
-
return new
|
|
8560
|
+
return new Elysia22().use(sessionStore()).get(`${rolesRoute}/:organizationId`, async ({
|
|
8383
8561
|
cookie: { user_session_id },
|
|
8384
8562
|
params: { organizationId },
|
|
8385
8563
|
status,
|
|
@@ -8602,7 +8780,7 @@ var resolveProviderClientConfiguration = ({
|
|
|
8602
8780
|
|
|
8603
8781
|
// src/routes/authorize.ts
|
|
8604
8782
|
init_constants();
|
|
8605
|
-
import { Elysia as
|
|
8783
|
+
import { Elysia as Elysia23, t as t19 } from "elysia";
|
|
8606
8784
|
var parseReferer = (headerReferer) => {
|
|
8607
8785
|
if (!headerReferer)
|
|
8608
8786
|
return "/";
|
|
@@ -8624,7 +8802,7 @@ var authorize = ({
|
|
|
8624
8802
|
onAuthorizeError
|
|
8625
8803
|
}) => {
|
|
8626
8804
|
const secure = resolveCookieSecure(cookieSecure);
|
|
8627
|
-
return new
|
|
8805
|
+
return new Elysia23().get(authorizeRoute, async ({
|
|
8628
8806
|
status,
|
|
8629
8807
|
redirect,
|
|
8630
8808
|
cookie: {
|
|
@@ -8757,7 +8935,7 @@ var authorize = ({
|
|
|
8757
8935
|
};
|
|
8758
8936
|
|
|
8759
8937
|
// src/routes/callback.ts
|
|
8760
|
-
import { Elysia as
|
|
8938
|
+
import { Elysia as Elysia24, t as t20 } from "elysia";
|
|
8761
8939
|
|
|
8762
8940
|
// src/errors.ts
|
|
8763
8941
|
class AuthIdentityConflictError extends Error {
|
|
@@ -8780,7 +8958,7 @@ var callback = ({
|
|
|
8780
8958
|
onLinkIdentityConflict,
|
|
8781
8959
|
onLinkConnector,
|
|
8782
8960
|
onCallbackError
|
|
8783
|
-
}) => new
|
|
8961
|
+
}) => new Elysia24().use(sessionStore()).get(callbackRoute, async ({
|
|
8784
8962
|
status,
|
|
8785
8963
|
redirect,
|
|
8786
8964
|
store: { session, unregisteredSession },
|
|
@@ -8927,13 +9105,13 @@ var callback = ({
|
|
|
8927
9105
|
});
|
|
8928
9106
|
|
|
8929
9107
|
// src/routes/profile.ts
|
|
8930
|
-
import { Elysia as
|
|
9108
|
+
import { Elysia as Elysia25, t as t21 } from "elysia";
|
|
8931
9109
|
var profile = ({
|
|
8932
9110
|
clientProviders,
|
|
8933
9111
|
profileRoute = "/oauth2/profile",
|
|
8934
9112
|
onProfileSuccess,
|
|
8935
9113
|
onProfileError
|
|
8936
|
-
}) => new
|
|
9114
|
+
}) => new Elysia25().use(sessionStore()).get(profileRoute, async ({
|
|
8937
9115
|
status,
|
|
8938
9116
|
store: { session },
|
|
8939
9117
|
cookie: { user_session_id, auth_provider, auth_client }
|
|
@@ -8992,7 +9170,7 @@ var profile = ({
|
|
|
8992
9170
|
|
|
8993
9171
|
// src/routes/refresh.ts
|
|
8994
9172
|
init_constants();
|
|
8995
|
-
import { Elysia as
|
|
9173
|
+
import { Elysia as Elysia26, t as t22 } from "elysia";
|
|
8996
9174
|
var refresh = ({
|
|
8997
9175
|
authSessionStore,
|
|
8998
9176
|
clientProviders,
|
|
@@ -9000,7 +9178,7 @@ var refresh = ({
|
|
|
9000
9178
|
onRefreshSuccess,
|
|
9001
9179
|
onRefreshError,
|
|
9002
9180
|
sessionDurationMs = MILLISECONDS_IN_A_DAY
|
|
9003
|
-
}) => new
|
|
9181
|
+
}) => new Elysia26().use(sessionStore()).post(refreshRoute, async ({
|
|
9004
9182
|
status,
|
|
9005
9183
|
store: { session },
|
|
9006
9184
|
cookie: { user_session_id, auth_provider, auth_client }
|
|
@@ -9077,14 +9255,14 @@ var refresh = ({
|
|
|
9077
9255
|
});
|
|
9078
9256
|
|
|
9079
9257
|
// src/routes/revoke.ts
|
|
9080
|
-
import { Elysia as
|
|
9258
|
+
import { Elysia as Elysia27, t as t23 } from "elysia";
|
|
9081
9259
|
var revoke = ({
|
|
9082
9260
|
authSessionStore,
|
|
9083
9261
|
clientProviders,
|
|
9084
9262
|
revokeRoute = "/oauth2/revocation",
|
|
9085
9263
|
onRevocationSuccess,
|
|
9086
9264
|
onRevocationError
|
|
9087
|
-
}) => new
|
|
9265
|
+
}) => new Elysia27().use(sessionStore()).post(revokeRoute, async ({
|
|
9088
9266
|
status,
|
|
9089
9267
|
store: { session },
|
|
9090
9268
|
cookie: { user_session_id, auth_provider, auth_client }
|
|
@@ -9157,12 +9335,12 @@ var revoke = ({
|
|
|
9157
9335
|
});
|
|
9158
9336
|
|
|
9159
9337
|
// src/routes/sessions.ts
|
|
9160
|
-
import { Elysia as
|
|
9338
|
+
import { Elysia as Elysia28, t as t24 } from "elysia";
|
|
9161
9339
|
var sessionRoutes = ({
|
|
9162
9340
|
authSessionStore,
|
|
9163
9341
|
getUserId,
|
|
9164
9342
|
sessionsRoute = "/auth/sessions"
|
|
9165
|
-
}) => new
|
|
9343
|
+
}) => new Elysia28().use(sessionStore()).get(sessionsRoute, async ({
|
|
9166
9344
|
cookie: { user_session_id },
|
|
9167
9345
|
status,
|
|
9168
9346
|
store: { session }
|
|
@@ -9222,10 +9400,10 @@ var sessionRoutes = ({
|
|
|
9222
9400
|
});
|
|
9223
9401
|
|
|
9224
9402
|
// src/routes/stepUp.ts
|
|
9225
|
-
import { Elysia as
|
|
9403
|
+
import { Elysia as Elysia29, t as t25 } from "elysia";
|
|
9226
9404
|
var stepUpPlugin = ({
|
|
9227
9405
|
authSessionStore
|
|
9228
|
-
} = {}) => new
|
|
9406
|
+
} = {}) => new Elysia29().use(sessionStore()).guard({ cookie: t25.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
|
|
9229
9407
|
requireRecentAuth: (maxAgeMs, handleAuth, handleAuthFail) => loadSessionFromSource({
|
|
9230
9408
|
authSessionStore,
|
|
9231
9409
|
session,
|
|
@@ -9244,7 +9422,7 @@ var stepUpPlugin = ({
|
|
|
9244
9422
|
})).as("global");
|
|
9245
9423
|
|
|
9246
9424
|
// src/routes/signout.ts
|
|
9247
|
-
import { Elysia as
|
|
9425
|
+
import { Elysia as Elysia30, t as t26 } from "elysia";
|
|
9248
9426
|
var sessionForSignOut = ({
|
|
9249
9427
|
authSessionStore,
|
|
9250
9428
|
currentSession,
|
|
@@ -9274,7 +9452,7 @@ var signout = ({
|
|
|
9274
9452
|
authSessionStore,
|
|
9275
9453
|
signoutRoute = "/oauth2/signout",
|
|
9276
9454
|
onSignOut
|
|
9277
|
-
}) => new
|
|
9455
|
+
}) => new Elysia30().use(sessionStore()).delete(signoutRoute, async ({
|
|
9278
9456
|
status,
|
|
9279
9457
|
store: { session },
|
|
9280
9458
|
cookie: { user_session_id, auth_provider }
|
|
@@ -9321,12 +9499,12 @@ var signout = ({
|
|
|
9321
9499
|
});
|
|
9322
9500
|
|
|
9323
9501
|
// src/routes/userStatus.ts
|
|
9324
|
-
import { Elysia as
|
|
9502
|
+
import { Elysia as Elysia31, t as t27 } from "elysia";
|
|
9325
9503
|
var userStatus = ({
|
|
9326
9504
|
authSessionStore,
|
|
9327
9505
|
statusRoute = "/oauth2/status",
|
|
9328
9506
|
onStatus
|
|
9329
|
-
}) => new
|
|
9507
|
+
}) => new Elysia31().use(sessionStore()).get(statusRoute, async ({ status, cookie: { user_session_id }, store: { session } }) => {
|
|
9330
9508
|
const { user, impersonator, error } = await getStatusFromSource({
|
|
9331
9509
|
authSessionStore,
|
|
9332
9510
|
session,
|
|
@@ -9344,7 +9522,7 @@ var userStatus = ({
|
|
|
9344
9522
|
}, { cookie: t27.Cookie({ user_session_id: userSessionIdTypebox }) });
|
|
9345
9523
|
|
|
9346
9524
|
// src/scim/routes.ts
|
|
9347
|
-
import { Elysia as
|
|
9525
|
+
import { Elysia as Elysia32, t as t28 } from "elysia";
|
|
9348
9526
|
|
|
9349
9527
|
// src/scim/serialize.ts
|
|
9350
9528
|
var USER_SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:User";
|
|
@@ -9817,7 +9995,7 @@ var scimRoutes = ({
|
|
|
9817
9995
|
const resourceTypesLocation = (requestUrl) => `${new URL(requestUrl).origin}${scimRoute}/ResourceTypes`;
|
|
9818
9996
|
const usersEndpoint = `${scimRoute}/Users`;
|
|
9819
9997
|
const groupsEndpoint = `${scimRoute}/Groups`;
|
|
9820
|
-
return new
|
|
9998
|
+
return new Elysia32().onParse(({ request }, contentType) => contentType === SCIM_CONTENT_TYPE2 ? request.json() : undefined).get(spcRoute, async ({ headers, request }) => {
|
|
9821
9999
|
const organizationId = await resolveScimOrganization(scimTokenStore, headers.authorization);
|
|
9822
10000
|
if (organizationId === undefined)
|
|
9823
10001
|
return unauthorized();
|
|
@@ -10009,7 +10187,7 @@ var scimRoutes = ({
|
|
|
10009
10187
|
|
|
10010
10188
|
// src/session/cleanup.ts
|
|
10011
10189
|
init_constants();
|
|
10012
|
-
import { Elysia as
|
|
10190
|
+
import { Elysia as Elysia33 } from "elysia";
|
|
10013
10191
|
var sessionCleanup = ({
|
|
10014
10192
|
authSessionStore,
|
|
10015
10193
|
cleanupIntervalMs = MILLISECONDS_IN_AN_HOUR,
|
|
@@ -10017,7 +10195,7 @@ var sessionCleanup = ({
|
|
|
10017
10195
|
onSessionCleanup
|
|
10018
10196
|
}) => {
|
|
10019
10197
|
let intervalId = null;
|
|
10020
|
-
return new
|
|
10198
|
+
return new Elysia33({ name: "sessionCleanup" }).use(sessionStore()).onStart(({ store: { session, unregisteredSession } }) => {
|
|
10021
10199
|
intervalId = setInterval(async () => {
|
|
10022
10200
|
await performCleanup({
|
|
10023
10201
|
authSessionStore,
|
|
@@ -10245,7 +10423,7 @@ var performCleanup = async ({
|
|
|
10245
10423
|
};
|
|
10246
10424
|
|
|
10247
10425
|
// src/sso/discoveryRoute.ts
|
|
10248
|
-
import { Elysia as
|
|
10426
|
+
import { Elysia as Elysia34, t as t29 } from "elysia";
|
|
10249
10427
|
var emailDomain = (email) => {
|
|
10250
10428
|
const atIndex = email.lastIndexOf("@");
|
|
10251
10429
|
if (atIndex === -1)
|
|
@@ -10258,7 +10436,7 @@ var ssoDiscoveryRoute = ({
|
|
|
10258
10436
|
ssoRoute = DEFAULT_SSO_ROUTE
|
|
10259
10437
|
}) => {
|
|
10260
10438
|
const discoveryRoute = `${ssoRoute}/authorize`;
|
|
10261
|
-
return new
|
|
10439
|
+
return new Elysia34().get(discoveryRoute, async ({ query: { email }, redirect, status }) => {
|
|
10262
10440
|
if (!isNonEmptyString(email)) {
|
|
10263
10441
|
return status("Bad Request", 'An "email" query parameter is required');
|
|
10264
10442
|
}
|
|
@@ -10280,7 +10458,7 @@ var ssoDiscoveryRoute = ({
|
|
|
10280
10458
|
|
|
10281
10459
|
// src/sso/oidcRoutes.ts
|
|
10282
10460
|
init_constants();
|
|
10283
|
-
import { Elysia as
|
|
10461
|
+
import { Elysia as Elysia35, t as t30 } from "elysia";
|
|
10284
10462
|
var makeSsoCookieOptions = (secure) => ({
|
|
10285
10463
|
httpOnly: true,
|
|
10286
10464
|
maxAge: COOKIE_DURATION,
|
|
@@ -10319,7 +10497,7 @@ var oidcSsoRoutes = ({
|
|
|
10319
10497
|
const ssoCookieOptions = makeSsoCookieOptions(resolveCookieSecure(cookieSecure));
|
|
10320
10498
|
const authorizeRoute = `${ssoRoute}/oidc/:organizationId/authorize`;
|
|
10321
10499
|
const callbackRoute = `${ssoRoute}/oidc/:organizationId/callback`;
|
|
10322
|
-
return new
|
|
10500
|
+
return new Elysia35().use(sessionStore()).get(authorizeRoute, async ({
|
|
10323
10501
|
cookie: {
|
|
10324
10502
|
sso_nonce,
|
|
10325
10503
|
sso_organization,
|
|
@@ -10445,7 +10623,7 @@ var oidcSsoRoutes = ({
|
|
|
10445
10623
|
};
|
|
10446
10624
|
|
|
10447
10625
|
// src/sso/samlRoutes.ts
|
|
10448
|
-
import { Elysia as
|
|
10626
|
+
import { Elysia as Elysia36, t as t31 } from "elysia";
|
|
10449
10627
|
var toLocalPath = (value) => {
|
|
10450
10628
|
if (value === undefined || value.length === 0)
|
|
10451
10629
|
return "/";
|
|
@@ -10495,7 +10673,7 @@ var samlSsoRoutes = ({
|
|
|
10495
10673
|
const target = authSessionStore ? compatibilityLayer.session : inMemorySession;
|
|
10496
10674
|
return target[userSessionId]?.samlLogout;
|
|
10497
10675
|
};
|
|
10498
|
-
return new
|
|
10676
|
+
return new Elysia36().use(sessionStore()).get(authorizeRoute, async ({
|
|
10499
10677
|
headers,
|
|
10500
10678
|
params: { organizationId },
|
|
10501
10679
|
redirect,
|
|
@@ -10717,7 +10895,7 @@ var samlSsoRoutes = ({
|
|
|
10717
10895
|
|
|
10718
10896
|
// src/webauthn/routes.ts
|
|
10719
10897
|
init_constants();
|
|
10720
|
-
import { Elysia as
|
|
10898
|
+
import { Elysia as Elysia37, t as t32 } from "elysia";
|
|
10721
10899
|
|
|
10722
10900
|
// src/webauthn/config.ts
|
|
10723
10901
|
init_constants();
|
|
@@ -10759,7 +10937,7 @@ var webauthnRoutes = ({
|
|
|
10759
10937
|
secure,
|
|
10760
10938
|
value: challenge
|
|
10761
10939
|
});
|
|
10762
|
-
return new
|
|
10940
|
+
return new Elysia37().use(sessionStore()).post(`${webauthnRoute}/register/options`, async ({
|
|
10763
10941
|
cookie: { user_session_id, webauthn_challenge },
|
|
10764
10942
|
status,
|
|
10765
10943
|
store: { session }
|
|
@@ -24090,7 +24268,7 @@ var createInMemoryCredentialOfferStore = () => {
|
|
|
24090
24268
|
};
|
|
24091
24269
|
};
|
|
24092
24270
|
// src/oidc/vciRoutes.ts
|
|
24093
|
-
import { Elysia as
|
|
24271
|
+
import { Elysia as Elysia38, t as t33 } from "elysia";
|
|
24094
24272
|
var HTTP_OK3 = 200;
|
|
24095
24273
|
var HTTP_BAD_REQUEST3 = 400;
|
|
24096
24274
|
var HTTP_UNAUTHORIZED3 = 401;
|
|
@@ -24115,7 +24293,7 @@ var vciRoutes = ({
|
|
|
24115
24293
|
const credentialRoute = `${vciRoute}/credential`;
|
|
24116
24294
|
const nonceRoute = `${vciRoute}/nonce`;
|
|
24117
24295
|
const vciSigningKey = vciConfig.signingKey ?? signingKey;
|
|
24118
|
-
return new
|
|
24296
|
+
return new Elysia38().get("/.well-known/openid-credential-issuer", () => Response.json(buildIssuerMetadata({
|
|
24119
24297
|
config: vciConfig,
|
|
24120
24298
|
issuer: issuerUrl,
|
|
24121
24299
|
vciRoute
|
|
@@ -24264,7 +24442,7 @@ var verifyStatusListJwt = async ({
|
|
|
24264
24442
|
};
|
|
24265
24443
|
};
|
|
24266
24444
|
// src/vc/statusListRoutes.ts
|
|
24267
|
-
import { Elysia as
|
|
24445
|
+
import { Elysia as Elysia39, t as t34 } from "elysia";
|
|
24268
24446
|
var HTTP_OK4 = 200;
|
|
24269
24447
|
var HTTP_NOT_FOUND = 404;
|
|
24270
24448
|
var DEFAULT_STATUS_ROUTE = "/vc/status";
|
|
@@ -24276,7 +24454,7 @@ var statusListRoutes = ({
|
|
|
24276
24454
|
ttlSeconds
|
|
24277
24455
|
}) => {
|
|
24278
24456
|
const listRoute = `${statusRoute}/:listId`;
|
|
24279
|
-
return new
|
|
24457
|
+
return new Elysia39().get(listRoute, async ({ params: { listId } }) => {
|
|
24280
24458
|
const bits = await getStatusList(listId);
|
|
24281
24459
|
if (bits === undefined) {
|
|
24282
24460
|
return new Response("Not found", { status: HTTP_NOT_FOUND });
|
|
@@ -24497,7 +24675,7 @@ var createInMemoryPresentationRequestStore = () => {
|
|
|
24497
24675
|
};
|
|
24498
24676
|
};
|
|
24499
24677
|
// src/vc/vpRoutes.ts
|
|
24500
|
-
import { Elysia as
|
|
24678
|
+
import { Elysia as Elysia40, t as t35 } from "elysia";
|
|
24501
24679
|
var HTTP_OK5 = 200;
|
|
24502
24680
|
var HTTP_BAD_REQUEST4 = 400;
|
|
24503
24681
|
var HTTP_NOT_FOUND2 = 404;
|
|
@@ -24516,7 +24694,7 @@ var vpRoutes = ({
|
|
|
24516
24694
|
const authorizeRoute = `${vpRoute}/authorize`;
|
|
24517
24695
|
const requestRoute = `${vpRoute}/request/:id`;
|
|
24518
24696
|
const responseRoute = `${vpRoute}/response`;
|
|
24519
|
-
return new
|
|
24697
|
+
return new Elysia40().post(authorizeRoute, async ({ body }) => {
|
|
24520
24698
|
const input = {
|
|
24521
24699
|
clientId: body.client_id ?? defaultClientId,
|
|
24522
24700
|
requestedClaims: body.requested_claims,
|
|
@@ -24780,6 +24958,220 @@ var createPostgresScimTokenStore = (db) => ({
|
|
|
24780
24958
|
});
|
|
24781
24959
|
}
|
|
24782
24960
|
});
|
|
24961
|
+
// src/agents/oidcAdapter.ts
|
|
24962
|
+
var BEARER_PREFIX6 = "Bearer ";
|
|
24963
|
+
var MS_PER_SECOND7 = 1000;
|
|
24964
|
+
var readAudience = (audience) => {
|
|
24965
|
+
if (typeof audience === "string")
|
|
24966
|
+
return [audience];
|
|
24967
|
+
if (Array.isArray(audience) && audience.every((entry) => typeof entry === "string")) {
|
|
24968
|
+
return audience;
|
|
24969
|
+
}
|
|
24970
|
+
return [];
|
|
24971
|
+
};
|
|
24972
|
+
var createOidcAgentCredentialVerifier = ({
|
|
24973
|
+
issuer,
|
|
24974
|
+
publicJwk,
|
|
24975
|
+
resource
|
|
24976
|
+
}) => {
|
|
24977
|
+
const verifier = async (request) => {
|
|
24978
|
+
const authorization = request.headers.get("authorization");
|
|
24979
|
+
if (authorization === null || !authorization.startsWith(BEARER_PREFIX6)) {
|
|
24980
|
+
return;
|
|
24981
|
+
}
|
|
24982
|
+
const token = authorization.slice(BEARER_PREFIX6.length).trim();
|
|
24983
|
+
if (token.length === 0)
|
|
24984
|
+
return;
|
|
24985
|
+
const verified = await verifyJwt(token, publicJwk);
|
|
24986
|
+
const payload = verified?.payload;
|
|
24987
|
+
if (payload === undefined || payload.iss !== issuer || typeof payload.exp !== "number" || payload.exp <= Math.floor(Date.now() / MS_PER_SECOND7) || !readAudience(payload.aud).includes(resource) || typeof payload.client_id !== "string") {
|
|
24988
|
+
return;
|
|
24989
|
+
}
|
|
24990
|
+
return {
|
|
24991
|
+
agentId: payload.client_id,
|
|
24992
|
+
claims: payload,
|
|
24993
|
+
expiresAt: payload.exp * MS_PER_SECOND7,
|
|
24994
|
+
organizationId: typeof payload.organization_id === "string" ? payload.organization_id : undefined,
|
|
24995
|
+
resource,
|
|
24996
|
+
scopes: typeof payload.scope === "string" ? payload.scope.split(" ").filter(Boolean) : [],
|
|
24997
|
+
userId: typeof payload.sub === "string" ? payload.sub : undefined
|
|
24998
|
+
};
|
|
24999
|
+
};
|
|
25000
|
+
return verifier;
|
|
25001
|
+
};
|
|
25002
|
+
// src/agents/inMemoryStores.ts
|
|
25003
|
+
var cloneRegistration = (value) => ({
|
|
25004
|
+
...value,
|
|
25005
|
+
allowedScopes: [...value.allowedScopes],
|
|
25006
|
+
metadata: value.metadata === undefined ? undefined : { ...value.metadata }
|
|
25007
|
+
});
|
|
25008
|
+
var cloneDelegation = (value) => ({
|
|
25009
|
+
...value,
|
|
25010
|
+
authorizationDetails: value.authorizationDetails?.map((entry) => ({
|
|
25011
|
+
...entry
|
|
25012
|
+
})),
|
|
25013
|
+
scopes: [...value.scopes]
|
|
25014
|
+
});
|
|
25015
|
+
var createInMemoryAgentDelegationStore = () => {
|
|
25016
|
+
const delegations = new Map;
|
|
25017
|
+
return {
|
|
25018
|
+
findActiveDelegation: async ({
|
|
25019
|
+
agentId,
|
|
25020
|
+
now = Date.now(),
|
|
25021
|
+
organizationId,
|
|
25022
|
+
userId
|
|
25023
|
+
}) => {
|
|
25024
|
+
const value = [...delegations.values()].find((delegation) => delegation.agentId === agentId && delegation.userId === userId && delegation.organizationId === organizationId && delegation.status === "active" && (delegation.expiresAt === undefined || delegation.expiresAt > now));
|
|
25025
|
+
return value === undefined ? undefined : cloneDelegation(value);
|
|
25026
|
+
},
|
|
25027
|
+
findByDelegationId: async (delegationId) => {
|
|
25028
|
+
const value = delegations.get(delegationId);
|
|
25029
|
+
return value === undefined ? undefined : cloneDelegation(value);
|
|
25030
|
+
},
|
|
25031
|
+
listDelegations: async (agentId) => [...delegations.values()].filter((delegation) => agentId === undefined || delegation.agentId === agentId).sort((left, right) => right.createdAt - left.createdAt).map(cloneDelegation),
|
|
25032
|
+
saveDelegation: async (delegation) => {
|
|
25033
|
+
delegations.set(delegation.delegationId, cloneDelegation(delegation));
|
|
25034
|
+
}
|
|
25035
|
+
};
|
|
25036
|
+
};
|
|
25037
|
+
var createInMemoryAgentRegistrationStore = () => {
|
|
25038
|
+
const registrations = new Map;
|
|
25039
|
+
return {
|
|
25040
|
+
findByAgentId: async (agentId) => {
|
|
25041
|
+
const value = registrations.get(agentId);
|
|
25042
|
+
return value === undefined ? undefined : cloneRegistration(value);
|
|
25043
|
+
},
|
|
25044
|
+
findByClientId: async (clientId) => {
|
|
25045
|
+
const value = [...registrations.values()].find((registration) => registration.clientId === clientId);
|
|
25046
|
+
return value === undefined ? undefined : cloneRegistration(value);
|
|
25047
|
+
},
|
|
25048
|
+
listRegistrations: async () => [...registrations.values()].sort((left, right) => right.createdAt - left.createdAt).map(cloneRegistration),
|
|
25049
|
+
saveRegistration: async (registration) => {
|
|
25050
|
+
registrations.set(registration.agentId, cloneRegistration(registration));
|
|
25051
|
+
}
|
|
25052
|
+
};
|
|
25053
|
+
};
|
|
25054
|
+
// src/agents/postgresStores.ts
|
|
25055
|
+
var ID_LENGTH7 = 255;
|
|
25056
|
+
var NAME_LENGTH = 255;
|
|
25057
|
+
var STATUS_LENGTH2 = 16;
|
|
25058
|
+
var agentDelegationsTable = pgTable("auth_agent_delegations", {
|
|
25059
|
+
agent_id: varchar("agent_id", { length: ID_LENGTH7 }).notNull(),
|
|
25060
|
+
authorization_details: jsonb("authorization_details").$type(),
|
|
25061
|
+
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
25062
|
+
delegation_id: varchar("delegation_id", {
|
|
25063
|
+
length: ID_LENGTH7
|
|
25064
|
+
}).primaryKey(),
|
|
25065
|
+
expires_at_ms: bigint("expires_at_ms", { mode: "number" }),
|
|
25066
|
+
organization_id: varchar("organization_id", { length: ID_LENGTH7 }),
|
|
25067
|
+
scopes: jsonb("scopes").$type().notNull().default([]),
|
|
25068
|
+
status: varchar("status", { length: STATUS_LENGTH2 }).$type().notNull(),
|
|
25069
|
+
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull(),
|
|
25070
|
+
user_id: varchar("user_id", { length: ID_LENGTH7 }).notNull()
|
|
25071
|
+
});
|
|
25072
|
+
var agentRegistrationsTable = pgTable("auth_agent_registrations", {
|
|
25073
|
+
agent_id: varchar("agent_id", { length: ID_LENGTH7 }).primaryKey(),
|
|
25074
|
+
allowed_scopes: jsonb("allowed_scopes").$type().notNull().default([]),
|
|
25075
|
+
client_id: varchar("client_id", { length: ID_LENGTH7 }).unique(),
|
|
25076
|
+
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
25077
|
+
metadata: jsonb("metadata").$type(),
|
|
25078
|
+
name: varchar("name", { length: NAME_LENGTH }).notNull(),
|
|
25079
|
+
status: varchar("status", { length: STATUS_LENGTH2 }).$type().notNull(),
|
|
25080
|
+
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
25081
|
+
});
|
|
25082
|
+
var toRegistration = (row) => ({
|
|
25083
|
+
agentId: row.agent_id,
|
|
25084
|
+
allowedScopes: row.allowed_scopes,
|
|
25085
|
+
clientId: row.client_id ?? undefined,
|
|
25086
|
+
createdAt: row.created_at_ms,
|
|
25087
|
+
metadata: row.metadata ?? undefined,
|
|
25088
|
+
name: row.name,
|
|
25089
|
+
status: row.status,
|
|
25090
|
+
updatedAt: row.updated_at_ms
|
|
25091
|
+
});
|
|
25092
|
+
var toDelegation = (row) => ({
|
|
25093
|
+
agentId: row.agent_id,
|
|
25094
|
+
authorizationDetails: row.authorization_details ?? undefined,
|
|
25095
|
+
createdAt: row.created_at_ms,
|
|
25096
|
+
delegationId: row.delegation_id,
|
|
25097
|
+
expiresAt: row.expires_at_ms ?? undefined,
|
|
25098
|
+
organizationId: row.organization_id ?? undefined,
|
|
25099
|
+
scopes: row.scopes,
|
|
25100
|
+
status: row.status,
|
|
25101
|
+
updatedAt: row.updated_at_ms,
|
|
25102
|
+
userId: row.user_id
|
|
25103
|
+
});
|
|
25104
|
+
var createNeonAgentDelegationStore = (databaseUrl) => createPostgresAgentDelegationStore(createNeonDatabase(databaseUrl));
|
|
25105
|
+
var createNeonAgentRegistrationStore = (databaseUrl) => createPostgresAgentRegistrationStore(createNeonDatabase(databaseUrl));
|
|
25106
|
+
var createPostgresAgentDelegationStore = (db) => ({
|
|
25107
|
+
findActiveDelegation: async ({
|
|
25108
|
+
agentId,
|
|
25109
|
+
now = Date.now(),
|
|
25110
|
+
organizationId,
|
|
25111
|
+
userId
|
|
25112
|
+
}) => {
|
|
25113
|
+
const organizationCondition = organizationId === undefined ? isNull(agentDelegationsTable.organization_id) : eq(agentDelegationsTable.organization_id, organizationId);
|
|
25114
|
+
const [row] = await db.select().from(agentDelegationsTable).where(and(eq(agentDelegationsTable.agent_id, agentId), eq(agentDelegationsTable.user_id, userId), organizationCondition, eq(agentDelegationsTable.status, "active"), or(isNull(agentDelegationsTable.expires_at_ms), gt(agentDelegationsTable.expires_at_ms, now)))).orderBy(desc(agentDelegationsTable.updated_at_ms)).limit(1);
|
|
25115
|
+
return row === undefined ? undefined : toDelegation(row);
|
|
25116
|
+
},
|
|
25117
|
+
findByDelegationId: async (delegationId) => {
|
|
25118
|
+
const [row] = await db.select().from(agentDelegationsTable).where(eq(agentDelegationsTable.delegation_id, delegationId)).limit(1);
|
|
25119
|
+
return row === undefined ? undefined : toDelegation(row);
|
|
25120
|
+
},
|
|
25121
|
+
listDelegations: async (agentId) => {
|
|
25122
|
+
const base = db.select().from(agentDelegationsTable);
|
|
25123
|
+
const rows = await (agentId === undefined ? base.orderBy(desc(agentDelegationsTable.created_at_ms)) : base.where(eq(agentDelegationsTable.agent_id, agentId)).orderBy(desc(agentDelegationsTable.created_at_ms)));
|
|
25124
|
+
return rows.map(toDelegation);
|
|
25125
|
+
},
|
|
25126
|
+
saveDelegation: async (delegation) => {
|
|
25127
|
+
const values = {
|
|
25128
|
+
agent_id: delegation.agentId,
|
|
25129
|
+
authorization_details: delegation.authorizationDetails ?? null,
|
|
25130
|
+
created_at_ms: delegation.createdAt,
|
|
25131
|
+
delegation_id: delegation.delegationId,
|
|
25132
|
+
expires_at_ms: delegation.expiresAt ?? null,
|
|
25133
|
+
organization_id: delegation.organizationId ?? null,
|
|
25134
|
+
scopes: delegation.scopes,
|
|
25135
|
+
status: delegation.status,
|
|
25136
|
+
updated_at_ms: delegation.updatedAt,
|
|
25137
|
+
user_id: delegation.userId
|
|
25138
|
+
};
|
|
25139
|
+
await db.insert(agentDelegationsTable).values(values).onConflictDoUpdate({
|
|
25140
|
+
set: values,
|
|
25141
|
+
target: agentDelegationsTable.delegation_id
|
|
25142
|
+
});
|
|
25143
|
+
}
|
|
25144
|
+
});
|
|
25145
|
+
var createPostgresAgentRegistrationStore = (db) => ({
|
|
25146
|
+
findByAgentId: async (agentId) => {
|
|
25147
|
+
const [row] = await db.select().from(agentRegistrationsTable).where(eq(agentRegistrationsTable.agent_id, agentId)).limit(1);
|
|
25148
|
+
return row === undefined ? undefined : toRegistration(row);
|
|
25149
|
+
},
|
|
25150
|
+
findByClientId: async (clientId) => {
|
|
25151
|
+
const [row] = await db.select().from(agentRegistrationsTable).where(eq(agentRegistrationsTable.client_id, clientId)).limit(1);
|
|
25152
|
+
return row === undefined ? undefined : toRegistration(row);
|
|
25153
|
+
},
|
|
25154
|
+
listRegistrations: async () => {
|
|
25155
|
+
const rows = await db.select().from(agentRegistrationsTable).orderBy(desc(agentRegistrationsTable.created_at_ms));
|
|
25156
|
+
return rows.map(toRegistration);
|
|
25157
|
+
},
|
|
25158
|
+
saveRegistration: async (registration) => {
|
|
25159
|
+
const values = {
|
|
25160
|
+
agent_id: registration.agentId,
|
|
25161
|
+
allowed_scopes: registration.allowedScopes,
|
|
25162
|
+
client_id: registration.clientId ?? null,
|
|
25163
|
+
created_at_ms: registration.createdAt,
|
|
25164
|
+
metadata: registration.metadata ?? null,
|
|
25165
|
+
name: registration.name,
|
|
25166
|
+
status: registration.status,
|
|
25167
|
+
updated_at_ms: registration.updatedAt
|
|
25168
|
+
};
|
|
25169
|
+
await db.insert(agentRegistrationsTable).values(values).onConflictDoUpdate({
|
|
25170
|
+
set: values,
|
|
25171
|
+
target: agentRegistrationsTable.agent_id
|
|
25172
|
+
});
|
|
25173
|
+
}
|
|
25174
|
+
});
|
|
24783
25175
|
// src/apikeys/inMemoryStores.ts
|
|
24784
25176
|
var createInMemoryAccessTokenStore = () => {
|
|
24785
25177
|
const tokens = new Map;
|
|
@@ -24832,33 +25224,33 @@ var createInMemoryApiKeyStore = () => {
|
|
|
24832
25224
|
};
|
|
24833
25225
|
};
|
|
24834
25226
|
// src/apikeys/postgresStores.ts
|
|
24835
|
-
var
|
|
25227
|
+
var ID_LENGTH8 = 255;
|
|
24836
25228
|
var accessTokensTable = pgTable("auth_access_tokens", {
|
|
24837
|
-
client_id: varchar("client_id", { length:
|
|
25229
|
+
client_id: varchar("client_id", { length: ID_LENGTH8 }).notNull(),
|
|
24838
25230
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
24839
25231
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
24840
|
-
hashed_token: varchar("hashed_token", { length:
|
|
24841
|
-
owner_id: varchar("owner_id", { length:
|
|
25232
|
+
hashed_token: varchar("hashed_token", { length: ID_LENGTH8 }).notNull(),
|
|
25233
|
+
owner_id: varchar("owner_id", { length: ID_LENGTH8 }),
|
|
24842
25234
|
scopes: text("scopes").array().notNull(),
|
|
24843
|
-
token_id: varchar("token_id", { length:
|
|
25235
|
+
token_id: varchar("token_id", { length: ID_LENGTH8 }).primaryKey()
|
|
24844
25236
|
});
|
|
24845
25237
|
var apiClientsTable = pgTable("auth_api_clients", {
|
|
24846
|
-
client_id: varchar("client_id", { length:
|
|
25238
|
+
client_id: varchar("client_id", { length: ID_LENGTH8 }).primaryKey(),
|
|
24847
25239
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
24848
|
-
hashed_secret: varchar("hashed_secret", { length:
|
|
24849
|
-
name: varchar("name", { length:
|
|
24850
|
-
owner_id: varchar("owner_id", { length:
|
|
25240
|
+
hashed_secret: varchar("hashed_secret", { length: ID_LENGTH8 }).notNull(),
|
|
25241
|
+
name: varchar("name", { length: ID_LENGTH8 }).notNull(),
|
|
25242
|
+
owner_id: varchar("owner_id", { length: ID_LENGTH8 }),
|
|
24851
25243
|
scopes: text("scopes").array().notNull()
|
|
24852
25244
|
});
|
|
24853
25245
|
var apiKeysTable = pgTable("auth_api_keys", {
|
|
24854
25246
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
24855
25247
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }),
|
|
24856
|
-
hashed_key: varchar("hashed_key", { length:
|
|
24857
|
-
key_id: varchar("key_id", { length:
|
|
25248
|
+
hashed_key: varchar("hashed_key", { length: ID_LENGTH8 }).notNull(),
|
|
25249
|
+
key_id: varchar("key_id", { length: ID_LENGTH8 }).primaryKey(),
|
|
24858
25250
|
last_used_at_ms: bigint("last_used_at_ms", { mode: "number" }),
|
|
24859
|
-
name: varchar("name", { length:
|
|
24860
|
-
owner_id: varchar("owner_id", { length:
|
|
24861
|
-
prefix: varchar("prefix", { length:
|
|
25251
|
+
name: varchar("name", { length: ID_LENGTH8 }).notNull(),
|
|
25252
|
+
owner_id: varchar("owner_id", { length: ID_LENGTH8 }),
|
|
25253
|
+
prefix: varchar("prefix", { length: ID_LENGTH8 }).notNull(),
|
|
24862
25254
|
scopes: text("scopes").array().notNull()
|
|
24863
25255
|
});
|
|
24864
25256
|
var toKey = (row) => ({
|
|
@@ -25171,11 +25563,11 @@ var createInMemoryPushedAuthorizationRequestStore = () => {
|
|
|
25171
25563
|
// src/oidc/postgresStores.ts
|
|
25172
25564
|
var URL_LENGTH = 2048;
|
|
25173
25565
|
var DEFAULT_LIST_LIMIT2 = 100;
|
|
25174
|
-
var
|
|
25566
|
+
var ID_LENGTH9 = 255;
|
|
25175
25567
|
var oauthBackchannelAuthRequestsTable = pgTable("auth_oauth_backchannel_auth_requests", {
|
|
25176
|
-
auth_req_id: varchar("auth_req_id", { length:
|
|
25568
|
+
auth_req_id: varchar("auth_req_id", { length: ID_LENGTH9 }).primaryKey(),
|
|
25177
25569
|
binding_message: text("binding_message"),
|
|
25178
|
-
client_id: varchar("client_id", { length:
|
|
25570
|
+
client_id: varchar("client_id", { length: ID_LENGTH9 }).notNull(),
|
|
25179
25571
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
25180
25572
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
25181
25573
|
interval_seconds: bigint("interval_seconds", {
|
|
@@ -25184,30 +25576,30 @@ var oauthBackchannelAuthRequestsTable = pgTable("auth_oauth_backchannel_auth_req
|
|
|
25184
25576
|
last_polled_at_ms: bigint("last_polled_at_ms", { mode: "number" }),
|
|
25185
25577
|
scopes: text("scopes").array().notNull(),
|
|
25186
25578
|
status: varchar("status", { length: 16 }).notNull(),
|
|
25187
|
-
user_sub: varchar("user_sub", { length:
|
|
25579
|
+
user_sub: varchar("user_sub", { length: ID_LENGTH9 })
|
|
25188
25580
|
});
|
|
25189
25581
|
var oauthClientAssertionJtisTable = pgTable("auth_oauth_client_assertion_jtis", {
|
|
25190
|
-
client_id: varchar("client_id", { length:
|
|
25582
|
+
client_id: varchar("client_id", { length: ID_LENGTH9 }).notNull(),
|
|
25191
25583
|
composite_key: varchar("composite_key", {
|
|
25192
|
-
length:
|
|
25584
|
+
length: ID_LENGTH9
|
|
25193
25585
|
}).primaryKey(),
|
|
25194
25586
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
25195
|
-
jti: varchar("jti", { length:
|
|
25587
|
+
jti: varchar("jti", { length: ID_LENGTH9 }).notNull()
|
|
25196
25588
|
});
|
|
25197
25589
|
var oauthClientRegistrationTokensTable = pgTable("auth_oauth_client_registration_tokens", {
|
|
25198
|
-
client_id: varchar("client_id", { length:
|
|
25590
|
+
client_id: varchar("client_id", { length: ID_LENGTH9 }).notNull(),
|
|
25199
25591
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
25200
|
-
token_hash: varchar("token_hash", { length:
|
|
25592
|
+
token_hash: varchar("token_hash", { length: ID_LENGTH9 }).primaryKey()
|
|
25201
25593
|
});
|
|
25202
25594
|
var oauthClientsTable = pgTable("auth_oauth_clients", {
|
|
25203
25595
|
backchannel_logout_uri: varchar("backchannel_logout_uri", {
|
|
25204
25596
|
length: URL_LENGTH
|
|
25205
25597
|
}),
|
|
25206
|
-
client_id: varchar("client_id", { length:
|
|
25207
|
-
hashed_secret: varchar("hashed_secret", { length:
|
|
25598
|
+
client_id: varchar("client_id", { length: ID_LENGTH9 }).primaryKey(),
|
|
25599
|
+
hashed_secret: varchar("hashed_secret", { length: ID_LENGTH9 }),
|
|
25208
25600
|
jwks_json: jsonb("jwks_json").$type(),
|
|
25209
25601
|
jwks_uri: varchar("jwks_uri", { length: URL_LENGTH }),
|
|
25210
|
-
name: varchar("name", { length:
|
|
25602
|
+
name: varchar("name", { length: ID_LENGTH9 }).notNull(),
|
|
25211
25603
|
post_logout_redirect_uris: text("post_logout_redirect_uris").array(),
|
|
25212
25604
|
redirect_uris: text("redirect_uris").array().notNull(),
|
|
25213
25605
|
require_pushed_authorization_requests: boolean("require_pushed_authorization_requests"),
|
|
@@ -25215,24 +25607,24 @@ var oauthClientsTable = pgTable("auth_oauth_clients", {
|
|
|
25215
25607
|
scopes: text("scopes").array().notNull()
|
|
25216
25608
|
});
|
|
25217
25609
|
var oauthCodesTable = pgTable("auth_oauth_codes", {
|
|
25218
|
-
acr: varchar("acr", { length:
|
|
25610
|
+
acr: varchar("acr", { length: ID_LENGTH9 }),
|
|
25219
25611
|
claims_json: jsonb("claims_json").$type(),
|
|
25220
|
-
client_id: varchar("client_id", { length:
|
|
25221
|
-
code_challenge: varchar("code_challenge", { length:
|
|
25222
|
-
code_hash: varchar("code_hash", { length:
|
|
25612
|
+
client_id: varchar("client_id", { length: ID_LENGTH9 }).notNull(),
|
|
25613
|
+
code_challenge: varchar("code_challenge", { length: ID_LENGTH9 }).notNull(),
|
|
25614
|
+
code_hash: varchar("code_hash", { length: ID_LENGTH9 }).primaryKey(),
|
|
25223
25615
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
25224
|
-
dpop_jkt: varchar("dpop_jkt", { length:
|
|
25616
|
+
dpop_jkt: varchar("dpop_jkt", { length: ID_LENGTH9 }),
|
|
25225
25617
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
25226
|
-
nonce: varchar("nonce", { length:
|
|
25227
|
-
redirect_uri: varchar("redirect_uri", { length:
|
|
25618
|
+
nonce: varchar("nonce", { length: ID_LENGTH9 }),
|
|
25619
|
+
redirect_uri: varchar("redirect_uri", { length: ID_LENGTH9 }).notNull(),
|
|
25228
25620
|
scopes: text("scopes").array().notNull(),
|
|
25229
|
-
user_id: varchar("user_id", { length:
|
|
25621
|
+
user_id: varchar("user_id", { length: ID_LENGTH9 }).notNull()
|
|
25230
25622
|
});
|
|
25231
25623
|
var oauthDeviceAuthorizationsTable = pgTable("auth_oauth_device_authorizations", {
|
|
25232
|
-
client_id: varchar("client_id", { length:
|
|
25624
|
+
client_id: varchar("client_id", { length: ID_LENGTH9 }).notNull(),
|
|
25233
25625
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
25234
25626
|
device_code_hash: varchar("device_code_hash", {
|
|
25235
|
-
length:
|
|
25627
|
+
length: ID_LENGTH9
|
|
25236
25628
|
}).primaryKey(),
|
|
25237
25629
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
25238
25630
|
interval_seconds: bigint("interval_seconds", {
|
|
@@ -25241,41 +25633,41 @@ var oauthDeviceAuthorizationsTable = pgTable("auth_oauth_device_authorizations",
|
|
|
25241
25633
|
scopes: text("scopes").array().notNull(),
|
|
25242
25634
|
status: varchar("status", { length: 16 }).notNull(),
|
|
25243
25635
|
user_code: varchar("user_code", { length: 16 }).notNull().unique(),
|
|
25244
|
-
user_sub: varchar("user_sub", { length:
|
|
25636
|
+
user_sub: varchar("user_sub", { length: ID_LENGTH9 })
|
|
25245
25637
|
});
|
|
25246
25638
|
var oauthInitialAccessTokensTable = pgTable("auth_oauth_initial_access_tokens", {
|
|
25247
|
-
token_hash: varchar("token_hash", { length:
|
|
25639
|
+
token_hash: varchar("token_hash", { length: ID_LENGTH9 }).primaryKey()
|
|
25248
25640
|
});
|
|
25249
25641
|
var oauthLogoutDeliveriesTable = pgTable("auth_oauth_logout_deliveries", {
|
|
25250
25642
|
attempts: bigint("attempts", { mode: "number" }).notNull(),
|
|
25251
|
-
client_id: varchar("client_id", { length:
|
|
25643
|
+
client_id: varchar("client_id", { length: ID_LENGTH9 }).notNull(),
|
|
25252
25644
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
25253
25645
|
endpoint_url: varchar("endpoint_url", { length: URL_LENGTH }).notNull(),
|
|
25254
|
-
id: varchar("id", { length:
|
|
25646
|
+
id: varchar("id", { length: ID_LENGTH9 }).primaryKey(),
|
|
25255
25647
|
last_error: text("last_error"),
|
|
25256
25648
|
last_status: bigint("last_status", { mode: "number" }),
|
|
25257
25649
|
logout_token: text("logout_token").notNull(),
|
|
25258
|
-
user_id: varchar("user_id", { length:
|
|
25650
|
+
user_id: varchar("user_id", { length: ID_LENGTH9 }).notNull()
|
|
25259
25651
|
});
|
|
25260
25652
|
var oauthPushedAuthorizationRequestsTable = pgTable("auth_oauth_pushed_authorization_requests", {
|
|
25261
|
-
client_id: varchar("client_id", { length:
|
|
25653
|
+
client_id: varchar("client_id", { length: ID_LENGTH9 }).notNull(),
|
|
25262
25654
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
25263
25655
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
25264
25656
|
params_json: jsonb("params_json").$type().notNull(),
|
|
25265
25657
|
request_uri_hash: varchar("request_uri_hash", {
|
|
25266
|
-
length:
|
|
25658
|
+
length: ID_LENGTH9
|
|
25267
25659
|
}).primaryKey()
|
|
25268
25660
|
});
|
|
25269
25661
|
var oauthRefreshTokensTable = pgTable("auth_oauth_refresh_tokens", {
|
|
25270
|
-
acr: varchar("acr", { length:
|
|
25662
|
+
acr: varchar("acr", { length: ID_LENGTH9 }),
|
|
25271
25663
|
claims_json: jsonb("claims_json").$type(),
|
|
25272
|
-
client_id: varchar("client_id", { length:
|
|
25664
|
+
client_id: varchar("client_id", { length: ID_LENGTH9 }).notNull(),
|
|
25273
25665
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
25274
|
-
dpop_jkt: varchar("dpop_jkt", { length:
|
|
25666
|
+
dpop_jkt: varchar("dpop_jkt", { length: ID_LENGTH9 }),
|
|
25275
25667
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
25276
25668
|
scopes: text("scopes").array().notNull(),
|
|
25277
|
-
token_hash: varchar("token_hash", { length:
|
|
25278
|
-
user_id: varchar("user_id", { length:
|
|
25669
|
+
token_hash: varchar("token_hash", { length: ID_LENGTH9 }).primaryKey(),
|
|
25670
|
+
user_id: varchar("user_id", { length: ID_LENGTH9 }).notNull()
|
|
25279
25671
|
});
|
|
25280
25672
|
var toClient2 = (row) => ({
|
|
25281
25673
|
backchannelLogoutUri: row.backchannel_logout_uri ?? undefined,
|
|
@@ -25800,29 +26192,29 @@ var createInMemoryLoginHistoryStore = () => {
|
|
|
25800
26192
|
};
|
|
25801
26193
|
};
|
|
25802
26194
|
// src/adaptive/postgresStores.ts
|
|
25803
|
-
var
|
|
26195
|
+
var ID_LENGTH10 = 255;
|
|
25804
26196
|
var knownDevicesTable = pgTable("auth_known_devices", {
|
|
25805
|
-
device_id: varchar("device_id", { length:
|
|
26197
|
+
device_id: varchar("device_id", { length: ID_LENGTH10 }).notNull(),
|
|
25806
26198
|
first_seen_at_ms: bigint("first_seen_at_ms", {
|
|
25807
26199
|
mode: "number"
|
|
25808
26200
|
}).notNull(),
|
|
25809
|
-
label: varchar("label", { length:
|
|
26201
|
+
label: varchar("label", { length: ID_LENGTH10 }),
|
|
25810
26202
|
last_seen_at_ms: bigint("last_seen_at_ms", {
|
|
25811
26203
|
mode: "number"
|
|
25812
26204
|
}).notNull(),
|
|
25813
26205
|
trusted: boolean("trusted").notNull().default(false),
|
|
25814
|
-
user_id: varchar("user_id", { length:
|
|
26206
|
+
user_id: varchar("user_id", { length: ID_LENGTH10 }).notNull()
|
|
25815
26207
|
}, (table) => [primaryKey({ columns: [table.user_id, table.device_id] })]);
|
|
25816
26208
|
var loginHistoryTable = pgTable("auth_login_history", {
|
|
25817
|
-
attempt_id: varchar("attempt_id", { length:
|
|
25818
|
-
country: varchar("country", { length:
|
|
25819
|
-
device_id: varchar("device_id", { length:
|
|
25820
|
-
ip_address: varchar("ip_address", { length:
|
|
26209
|
+
attempt_id: varchar("attempt_id", { length: ID_LENGTH10 }).primaryKey(),
|
|
26210
|
+
country: varchar("country", { length: ID_LENGTH10 }),
|
|
26211
|
+
device_id: varchar("device_id", { length: ID_LENGTH10 }).notNull(),
|
|
26212
|
+
ip_address: varchar("ip_address", { length: ID_LENGTH10 }),
|
|
25821
26213
|
latitude: doublePrecision("latitude"),
|
|
25822
26214
|
longitude: doublePrecision("longitude"),
|
|
25823
|
-
outcome: varchar("outcome", { length:
|
|
26215
|
+
outcome: varchar("outcome", { length: ID_LENGTH10 }).notNull(),
|
|
25824
26216
|
timestamp_ms: bigint("timestamp_ms", { mode: "number" }).notNull(),
|
|
25825
|
-
user_id: varchar("user_id", { length:
|
|
26217
|
+
user_id: varchar("user_id", { length: ID_LENGTH10 }).notNull()
|
|
25826
26218
|
});
|
|
25827
26219
|
var toRiskAction = (value) => {
|
|
25828
26220
|
if (value === "deny")
|
|
@@ -26149,15 +26541,15 @@ var createRedisFgaCache = (redis, {
|
|
|
26149
26541
|
}
|
|
26150
26542
|
});
|
|
26151
26543
|
// src/fga/postgresStores.ts
|
|
26152
|
-
var
|
|
26544
|
+
var ID_LENGTH11 = 255;
|
|
26153
26545
|
var warrantsTable = pgTable("auth_fga_warrants", {
|
|
26154
|
-
id: varchar("id", { length:
|
|
26155
|
-
relation: varchar("relation", { length:
|
|
26156
|
-
resource_id: varchar("resource_id", { length:
|
|
26157
|
-
resource_type: varchar("resource_type", { length:
|
|
26158
|
-
subject_id: varchar("subject_id", { length:
|
|
26159
|
-
subject_relation: varchar("subject_relation", { length:
|
|
26160
|
-
subject_type: varchar("subject_type", { length:
|
|
26546
|
+
id: varchar("id", { length: ID_LENGTH11 }).primaryKey(),
|
|
26547
|
+
relation: varchar("relation", { length: ID_LENGTH11 }).notNull(),
|
|
26548
|
+
resource_id: varchar("resource_id", { length: ID_LENGTH11 }).notNull(),
|
|
26549
|
+
resource_type: varchar("resource_type", { length: ID_LENGTH11 }).notNull(),
|
|
26550
|
+
subject_id: varchar("subject_id", { length: ID_LENGTH11 }).notNull(),
|
|
26551
|
+
subject_relation: varchar("subject_relation", { length: ID_LENGTH11 }),
|
|
26552
|
+
subject_type: varchar("subject_type", { length: ID_LENGTH11 }).notNull()
|
|
26161
26553
|
});
|
|
26162
26554
|
var toWarrant = (row) => ({
|
|
26163
26555
|
relation: row.relation,
|
|
@@ -26194,41 +26586,41 @@ var createPostgresWarrantStore = (db) => ({
|
|
|
26194
26586
|
});
|
|
26195
26587
|
|
|
26196
26588
|
// src/organizations/postgresOrganizationStore.ts
|
|
26197
|
-
var
|
|
26198
|
-
var
|
|
26589
|
+
var ID_LENGTH12 = 255;
|
|
26590
|
+
var NAME_LENGTH2 = 255;
|
|
26199
26591
|
var STATE_LENGTH = 16;
|
|
26200
26592
|
var organizationInvitationsTable = pgTable("auth_organization_invitations", {
|
|
26201
26593
|
accepted_at_ms: bigint("accepted_at_ms", { mode: "number" }),
|
|
26202
26594
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
26203
|
-
email: varchar("email", { length:
|
|
26595
|
+
email: varchar("email", { length: ID_LENGTH12 }).notNull(),
|
|
26204
26596
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
26205
26597
|
invitation_id: varchar("invitation_id", {
|
|
26206
|
-
length:
|
|
26598
|
+
length: ID_LENGTH12
|
|
26207
26599
|
}).primaryKey(),
|
|
26208
|
-
inviter_user_id: varchar("inviter_user_id", { length:
|
|
26600
|
+
inviter_user_id: varchar("inviter_user_id", { length: ID_LENGTH12 }),
|
|
26209
26601
|
organization_id: varchar("organization_id", {
|
|
26210
|
-
length:
|
|
26602
|
+
length: ID_LENGTH12
|
|
26211
26603
|
}).notNull(),
|
|
26212
26604
|
roles: jsonb("roles").$type().notNull().default([]),
|
|
26213
26605
|
state: varchar("state", { length: STATE_LENGTH }).$type().notNull().default("pending"),
|
|
26214
|
-
token_hash: varchar("token_hash", { length:
|
|
26606
|
+
token_hash: varchar("token_hash", { length: ID_LENGTH12 }).notNull().unique()
|
|
26215
26607
|
});
|
|
26216
26608
|
var organizationMembershipsTable = pgTable("auth_organization_memberships", {
|
|
26217
26609
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
26218
26610
|
organization_id: varchar("organization_id", {
|
|
26219
|
-
length:
|
|
26611
|
+
length: ID_LENGTH12
|
|
26220
26612
|
}).notNull(),
|
|
26221
26613
|
roles: jsonb("roles").$type().notNull().default([]),
|
|
26222
26614
|
status: varchar("status", { length: STATE_LENGTH }).$type().notNull().default("active"),
|
|
26223
26615
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull(),
|
|
26224
|
-
user_id: varchar("user_id", { length:
|
|
26616
|
+
user_id: varchar("user_id", { length: ID_LENGTH12 }).notNull()
|
|
26225
26617
|
}, (table) => [primaryKey({ columns: [table.organization_id, table.user_id] })]);
|
|
26226
26618
|
var organizationsTable = pgTable("auth_organizations", {
|
|
26227
26619
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
26228
26620
|
metadata: jsonb("metadata").$type(),
|
|
26229
|
-
name: varchar("name", { length:
|
|
26621
|
+
name: varchar("name", { length: NAME_LENGTH2 }).notNull(),
|
|
26230
26622
|
organization_id: varchar("organization_id", {
|
|
26231
|
-
length:
|
|
26623
|
+
length: ID_LENGTH12
|
|
26232
26624
|
}).primaryKey(),
|
|
26233
26625
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
26234
26626
|
});
|
|
@@ -26350,11 +26742,11 @@ var createPostgresOrganizationStore = (db) => ({
|
|
|
26350
26742
|
});
|
|
26351
26743
|
|
|
26352
26744
|
// src/passwordless/postgresPasswordlessTokenStore.ts
|
|
26353
|
-
var
|
|
26745
|
+
var ID_LENGTH13 = 255;
|
|
26354
26746
|
var passwordlessTokensTable = pgTable("auth_passwordless_tokens", {
|
|
26355
|
-
email: varchar("email", { length:
|
|
26747
|
+
email: varchar("email", { length: ID_LENGTH13 }).notNull(),
|
|
26356
26748
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
26357
|
-
token_hash: varchar("token_hash", { length:
|
|
26749
|
+
token_hash: varchar("token_hash", { length: ID_LENGTH13 }).primaryKey()
|
|
26358
26750
|
});
|
|
26359
26751
|
var toToken3 = (row) => ({
|
|
26360
26752
|
email: row.email,
|
|
@@ -26381,19 +26773,19 @@ var createPostgresPasswordlessTokenStore = (db) => ({
|
|
|
26381
26773
|
});
|
|
26382
26774
|
|
|
26383
26775
|
// src/portal/postgresSetupSessionStore.ts
|
|
26384
|
-
var
|
|
26776
|
+
var ID_LENGTH14 = 255;
|
|
26385
26777
|
var setupSessionsTable = pgTable("auth_setup_sessions", {
|
|
26386
26778
|
capabilities: jsonb("capabilities").$type().notNull().default([]),
|
|
26387
26779
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
26388
|
-
created_by: varchar("created_by", { length:
|
|
26780
|
+
created_by: varchar("created_by", { length: ID_LENGTH14 }),
|
|
26389
26781
|
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
26390
26782
|
organization_id: varchar("organization_id", {
|
|
26391
|
-
length:
|
|
26783
|
+
length: ID_LENGTH14
|
|
26392
26784
|
}).notNull(),
|
|
26393
26785
|
setup_session_id: varchar("setup_session_id", {
|
|
26394
|
-
length:
|
|
26786
|
+
length: ID_LENGTH14
|
|
26395
26787
|
}).primaryKey(),
|
|
26396
|
-
token_hash: varchar("token_hash", { length:
|
|
26788
|
+
token_hash: varchar("token_hash", { length: ID_LENGTH14 }).notNull().unique()
|
|
26397
26789
|
});
|
|
26398
26790
|
var toSession = (row) => ({
|
|
26399
26791
|
capabilities: row.capabilities,
|
|
@@ -26431,12 +26823,12 @@ var createPostgresSetupSessionStore = (db) => ({
|
|
|
26431
26823
|
});
|
|
26432
26824
|
|
|
26433
26825
|
// src/roles/postgresRoleStore.ts
|
|
26434
|
-
var
|
|
26826
|
+
var ID_LENGTH15 = 255;
|
|
26435
26827
|
var SLUG_LENGTH = 128;
|
|
26436
26828
|
var GLOBAL_SCOPE = "";
|
|
26437
26829
|
var rolesTable = pgTable("auth_roles", {
|
|
26438
26830
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
26439
|
-
organization_id: varchar("organization_id", { length:
|
|
26831
|
+
organization_id: varchar("organization_id", { length: ID_LENGTH15 }).notNull().default(GLOBAL_SCOPE),
|
|
26440
26832
|
permissions: jsonb("permissions").$type().notNull().default([]),
|
|
26441
26833
|
slug: varchar("slug", { length: SLUG_LENGTH }).notNull(),
|
|
26442
26834
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
@@ -26477,13 +26869,13 @@ var createPostgresRoleStore = (db) => ({
|
|
|
26477
26869
|
});
|
|
26478
26870
|
|
|
26479
26871
|
// src/sso/postgresSamlServiceProviderStore.ts
|
|
26480
|
-
var
|
|
26872
|
+
var ID_LENGTH16 = 255;
|
|
26481
26873
|
var URL_LENGTH2 = 2048;
|
|
26482
26874
|
var samlServiceProvidersTable = pgTable("auth_saml_service_providers", {
|
|
26483
26875
|
acs_url: varchar("acs_url", { length: URL_LENGTH2 }).notNull(),
|
|
26484
26876
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
26485
26877
|
entity_id: varchar("entity_id", { length: URL_LENGTH2 }).primaryKey(),
|
|
26486
|
-
name_id_format: varchar("name_id_format", { length:
|
|
26878
|
+
name_id_format: varchar("name_id_format", { length: ID_LENGTH16 }),
|
|
26487
26879
|
signing_cert: text("signing_cert"),
|
|
26488
26880
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
26489
26881
|
});
|
|
@@ -26525,15 +26917,15 @@ var createPostgresSamlServiceProviderStore = (db) => ({
|
|
|
26525
26917
|
});
|
|
26526
26918
|
|
|
26527
26919
|
// src/sso/postgresSsoConnectionStore.ts
|
|
26528
|
-
var
|
|
26920
|
+
var ID_LENGTH17 = 255;
|
|
26529
26921
|
var TYPE_LENGTH2 = 16;
|
|
26530
26922
|
var ssoConnectionsTable = pgTable("auth_sso_connections", {
|
|
26531
26923
|
config: jsonb("config").$type().notNull(),
|
|
26532
|
-
connection_id: varchar("connection_id", { length:
|
|
26924
|
+
connection_id: varchar("connection_id", { length: ID_LENGTH17 }).primaryKey(),
|
|
26533
26925
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
26534
26926
|
enabled: boolean("enabled").notNull().default(true),
|
|
26535
26927
|
organization_id: varchar("organization_id", {
|
|
26536
|
-
length:
|
|
26928
|
+
length: ID_LENGTH17
|
|
26537
26929
|
}).notNull(),
|
|
26538
26930
|
type: varchar("type", { length: TYPE_LENGTH2 }).$type().notNull(),
|
|
26539
26931
|
updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
|
|
@@ -26639,18 +27031,18 @@ var createPostgresSsoConnectionStore = (db) => ({
|
|
|
26639
27031
|
});
|
|
26640
27032
|
|
|
26641
27033
|
// src/webauthn/postgresWebAuthnCredentialStore.ts
|
|
26642
|
-
var
|
|
27034
|
+
var ID_LENGTH18 = 255;
|
|
26643
27035
|
var DEVICE_TYPE_LENGTH = 32;
|
|
26644
27036
|
var webauthnCredentialsTable = pgTable("auth_webauthn_credentials", {
|
|
26645
27037
|
backed_up: boolean("backed_up"),
|
|
26646
27038
|
counter: bigint("counter", { mode: "number" }).notNull().default(0),
|
|
26647
27039
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
26648
|
-
credential_id: varchar("credential_id", { length:
|
|
27040
|
+
credential_id: varchar("credential_id", { length: ID_LENGTH18 }).primaryKey(),
|
|
26649
27041
|
device_type: varchar("device_type", { length: DEVICE_TYPE_LENGTH }),
|
|
26650
27042
|
last_used_at_ms: bigint("last_used_at_ms", { mode: "number" }),
|
|
26651
27043
|
public_key: text("public_key").notNull(),
|
|
26652
27044
|
transports: jsonb("transports").$type(),
|
|
26653
|
-
user_id: varchar("user_id", { length:
|
|
27045
|
+
user_id: varchar("user_id", { length: ID_LENGTH18 }).notNull()
|
|
26654
27046
|
});
|
|
26655
27047
|
var toCredential = (row) => ({
|
|
26656
27048
|
backedUp: row.backed_up ?? undefined,
|
|
@@ -26697,14 +27089,14 @@ var createPostgresWebAuthnCredentialStore = (db) => ({
|
|
|
26697
27089
|
});
|
|
26698
27090
|
|
|
26699
27091
|
// src/webhooks/postgresStore.ts
|
|
26700
|
-
var
|
|
27092
|
+
var ID_LENGTH19 = 255;
|
|
26701
27093
|
var URL_LENGTH3 = 2048;
|
|
26702
27094
|
var DEFAULT_LIST_LIMIT3 = 100;
|
|
26703
27095
|
var webhookDeliveriesTable = pgTable("auth_webhook_deliveries", {
|
|
26704
27096
|
attempts: bigint("attempts", { mode: "number" }).notNull(),
|
|
26705
27097
|
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
26706
27098
|
endpoint_url: varchar("endpoint_url", { length: URL_LENGTH3 }).notNull(),
|
|
26707
|
-
envelope_id: varchar("envelope_id", { length:
|
|
27099
|
+
envelope_id: varchar("envelope_id", { length: ID_LENGTH19 }).primaryKey(),
|
|
26708
27100
|
envelope_json: jsonb("envelope_json").$type().notNull(),
|
|
26709
27101
|
last_error: text("last_error"),
|
|
26710
27102
|
last_status: bigint("last_status", { mode: "number" })
|
|
@@ -26864,6 +27256,10 @@ var mfaTotpLockoutMigration = {
|
|
|
26864
27256
|
};
|
|
26865
27257
|
var blockMigrations = {
|
|
26866
27258
|
adaptive: initMigration("adaptive", [knownDevicesTable, loginHistoryTable]),
|
|
27259
|
+
agents: initMigration("agents", [
|
|
27260
|
+
agentRegistrationsTable,
|
|
27261
|
+
agentDelegationsTable
|
|
27262
|
+
]),
|
|
26867
27263
|
apikeys: initMigration("apikeys", [
|
|
26868
27264
|
accessTokensTable,
|
|
26869
27265
|
apiClientsTable,
|
|
@@ -26925,7 +27321,7 @@ var blockMigrations = {
|
|
|
26925
27321
|
webhooks: initMigration("webhooks", [webhookDeliveriesTable])
|
|
26926
27322
|
};
|
|
26927
27323
|
// src/sso/samlIdpRoutes.ts
|
|
26928
|
-
import { Elysia as
|
|
27324
|
+
import { Elysia as Elysia41, t as t36 } from "elysia";
|
|
26929
27325
|
var HTTP_BAD_REQUEST5 = 400;
|
|
26930
27326
|
var HTTP_UNAUTHORIZED4 = 401;
|
|
26931
27327
|
var HTTP_FOUND2 = 302;
|
|
@@ -27035,7 +27431,7 @@ var samlIdpRoutes = ({
|
|
|
27035
27431
|
user: userSession.user
|
|
27036
27432
|
});
|
|
27037
27433
|
};
|
|
27038
|
-
return new
|
|
27434
|
+
return new Elysia41().use(sessionStore()).post(ssoIdpRoute, async ({ body, cookie: { user_session_id }, request, store }) => handleSpInitiated({
|
|
27039
27435
|
binding: "POST",
|
|
27040
27436
|
body,
|
|
27041
27437
|
inMemorySession: store.session,
|
|
@@ -27356,6 +27752,7 @@ var auth = async ({
|
|
|
27356
27752
|
sso,
|
|
27357
27753
|
scim,
|
|
27358
27754
|
apikeys,
|
|
27755
|
+
agentAuth,
|
|
27359
27756
|
oidc,
|
|
27360
27757
|
organizations,
|
|
27361
27758
|
roles,
|
|
@@ -27397,6 +27794,59 @@ var auth = async ({
|
|
|
27397
27794
|
}
|
|
27398
27795
|
}) : undefined;
|
|
27399
27796
|
const lockoutGuard = lockout ? createLockoutGuard(lockout) : undefined;
|
|
27797
|
+
const oidcConfig = oidc ? {
|
|
27798
|
+
...oidc,
|
|
27799
|
+
onClientRegistered: async (context) => {
|
|
27800
|
+
await oidc.onClientRegistered?.(context);
|
|
27801
|
+
if (agentAuth?.registerDynamicClients !== true)
|
|
27802
|
+
return;
|
|
27803
|
+
const now = Date.now();
|
|
27804
|
+
await agentAuth.registrationStore.saveRegistration({
|
|
27805
|
+
agentId: context.client.clientId,
|
|
27806
|
+
allowedScopes: context.client.scopes.filter((scope) => agentAuth.scopes.includes(scope)),
|
|
27807
|
+
clientId: context.client.clientId,
|
|
27808
|
+
createdAt: now,
|
|
27809
|
+
name: context.client.name,
|
|
27810
|
+
status: "active",
|
|
27811
|
+
updatedAt: now
|
|
27812
|
+
});
|
|
27813
|
+
await auditEmit?.({
|
|
27814
|
+
at: now,
|
|
27815
|
+
metadata: { agentId: context.client.clientId },
|
|
27816
|
+
type: "agent_registered"
|
|
27817
|
+
});
|
|
27818
|
+
},
|
|
27819
|
+
onDeviceAuthorizationApproved: async (context) => {
|
|
27820
|
+
await oidc.onDeviceAuthorizationApproved?.(context);
|
|
27821
|
+
if (agentAuth === undefined)
|
|
27822
|
+
return;
|
|
27823
|
+
const registration = await agentAuth.registrationStore.findByClientId(context.clientId);
|
|
27824
|
+
if (registration === undefined || registration.status !== "active") {
|
|
27825
|
+
return;
|
|
27826
|
+
}
|
|
27827
|
+
const now = Date.now();
|
|
27828
|
+
const existing = await agentAuth.delegationStore.findActiveDelegation({
|
|
27829
|
+
agentId: registration.agentId,
|
|
27830
|
+
now,
|
|
27831
|
+
userId: context.userSub
|
|
27832
|
+
});
|
|
27833
|
+
await agentAuth.delegationStore.saveDelegation({
|
|
27834
|
+
agentId: registration.agentId,
|
|
27835
|
+
createdAt: existing?.createdAt ?? now,
|
|
27836
|
+
delegationId: existing?.delegationId ?? `agd_${crypto.randomUUID()}`,
|
|
27837
|
+
scopes: context.scopes.filter((scope) => registration.allowedScopes.includes(scope) && agentAuth.scopes.includes(scope)),
|
|
27838
|
+
status: "active",
|
|
27839
|
+
updatedAt: now,
|
|
27840
|
+
userId: context.userSub
|
|
27841
|
+
});
|
|
27842
|
+
await auditEmit?.({
|
|
27843
|
+
at: now,
|
|
27844
|
+
metadata: { agentId: registration.agentId },
|
|
27845
|
+
type: "agent_delegated",
|
|
27846
|
+
userId: context.userSub
|
|
27847
|
+
});
|
|
27848
|
+
}
|
|
27849
|
+
} : undefined;
|
|
27400
27850
|
const credentialsConfig = credentials ? {
|
|
27401
27851
|
...credentials,
|
|
27402
27852
|
isMfaRequired: credentials.isMfaRequired ?? (mfa ? createMfaGate(mfa) : undefined)
|
|
@@ -27406,7 +27856,7 @@ var auth = async ({
|
|
|
27406
27856
|
const auditedOnCallbackSuccess = auditEmit ? composeCallbackAudit(onCallbackSuccess, auditEmit) : onCallbackSuccess;
|
|
27407
27857
|
const auditedOnRevocationSuccess = auditEmit ? composeRevocationAudit(onRevocationSuccess, auditEmit) : onRevocationSuccess;
|
|
27408
27858
|
const auditedOnSignOut = auditEmit ? composeSignOutAudit(onSignOut, auditEmit) : onSignOut;
|
|
27409
|
-
const composedAuth = new
|
|
27859
|
+
const composedAuth = new Elysia42().use(sessionCleanup({
|
|
27410
27860
|
authSessionStore,
|
|
27411
27861
|
cleanupIntervalMs,
|
|
27412
27862
|
maxSessions,
|
|
@@ -27454,54 +27904,58 @@ var auth = async ({
|
|
|
27454
27904
|
authSessionStore,
|
|
27455
27905
|
cookieSecure: resolvedCookieSecure,
|
|
27456
27906
|
lockoutGuard
|
|
27457
|
-
}) : new
|
|
27907
|
+
}) : new Elysia42).use(auditedMfa ? mfaRoutes({
|
|
27458
27908
|
...auditedMfa,
|
|
27459
27909
|
authSessionStore,
|
|
27460
27910
|
cookieSecure: resolvedCookieSecure
|
|
27461
|
-
}) : new
|
|
27911
|
+
}) : new Elysia42).use(passwordless ? passwordlessRoutes({
|
|
27462
27912
|
...passwordless,
|
|
27463
27913
|
authSessionStore,
|
|
27464
27914
|
cookieSecure: resolvedCookieSecure,
|
|
27465
27915
|
emit: auditEmit
|
|
27466
|
-
}) : new
|
|
27916
|
+
}) : new Elysia42).use(sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia42).use(sso ? oidcSsoRoutes({
|
|
27467
27917
|
...sso,
|
|
27468
27918
|
authSessionStore,
|
|
27469
27919
|
cookieSecure: resolvedCookieSecure
|
|
27470
|
-
}) : new
|
|
27920
|
+
}) : new Elysia42).use(sso && sso.samlAdapter ? samlSsoRoutes({
|
|
27471
27921
|
...sso,
|
|
27472
27922
|
authSessionStore,
|
|
27473
27923
|
cookieSecure: resolvedCookieSecure,
|
|
27474
27924
|
samlAdapter: sso.samlAdapter
|
|
27475
|
-
}) : new
|
|
27925
|
+
}) : new Elysia42).use(sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
|
|
27476
27926
|
getOrganizationByEmailDomain: sso.getOrganizationByEmailDomain,
|
|
27477
27927
|
ssoConnectionStore: sso.ssoConnectionStore,
|
|
27478
27928
|
ssoRoute: sso.ssoRoute
|
|
27479
|
-
}) : new
|
|
27929
|
+
}) : new Elysia42).use(scim ? scimRoutes(scim) : new Elysia42).use(apikeys ? apiKeysRoutes(apikeys) : new Elysia42).use(oidcConfig ? oidcProviderRoutes({
|
|
27930
|
+
...oidcConfig,
|
|
27931
|
+
authSessionStore
|
|
27932
|
+
}) : new Elysia42).use(organizations ? organizationRoutes({
|
|
27480
27933
|
...organizations,
|
|
27481
27934
|
authSessionStore,
|
|
27482
27935
|
emit: auditEmit
|
|
27483
|
-
}) : new
|
|
27936
|
+
}) : new Elysia42).use(roles ? roleRoutes({
|
|
27484
27937
|
...roles,
|
|
27485
27938
|
authSessionStore,
|
|
27486
27939
|
emit: auditEmit
|
|
27487
|
-
}) : new
|
|
27940
|
+
}) : new Elysia42).use(portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia42).use(webauthn ? webauthnRoutes({
|
|
27488
27941
|
...webauthn,
|
|
27489
27942
|
authSessionStore,
|
|
27490
27943
|
cookieSecure: resolvedCookieSecure,
|
|
27491
27944
|
emit: auditEmit
|
|
27492
|
-
}) : new
|
|
27945
|
+
}) : new Elysia42).use(compliance ? complianceRoutes({
|
|
27493
27946
|
...compliance,
|
|
27494
27947
|
authSessionStore,
|
|
27495
27948
|
emit: auditEmit
|
|
27496
|
-
}) : new
|
|
27949
|
+
}) : new Elysia42).use(protectRoutePlugin({ authSessionStore })).use(stepUpPlugin({ authSessionStore })).use(authorization ? protectPermissionPlugin({
|
|
27497
27950
|
...authorization,
|
|
27498
27951
|
authSessionStore,
|
|
27499
27952
|
emit: auditEmit
|
|
27500
|
-
}) : new
|
|
27953
|
+
}) : new Elysia42).use(htmx ? createAuthHtmxRoutes({
|
|
27501
27954
|
...htmx,
|
|
27502
27955
|
authSessionStore
|
|
27503
|
-
}) : new
|
|
27504
|
-
|
|
27956
|
+
}) : new Elysia42);
|
|
27957
|
+
const authWithAgent = composedAuth.use(agentAuthPlugin(agentAuth));
|
|
27958
|
+
return authWithAgent;
|
|
27505
27959
|
};
|
|
27506
27960
|
export {
|
|
27507
27961
|
writeWarrant,
|
|
@@ -27590,6 +28044,7 @@ export {
|
|
|
27590
28044
|
resolveClientCert,
|
|
27591
28045
|
resolveAuthHtmxRenderers,
|
|
27592
28046
|
resolveApiPrincipal,
|
|
28047
|
+
resolveAgentPrincipal,
|
|
27593
28048
|
removeFromSessionRing,
|
|
27594
28049
|
rehashCredentialPassword,
|
|
27595
28050
|
registerClient,
|
|
@@ -27780,8 +28235,11 @@ export {
|
|
|
27780
28235
|
createPostgresAuditSink,
|
|
27781
28236
|
createPostgresApiKeyStore,
|
|
27782
28237
|
createPostgresApiClientStore,
|
|
28238
|
+
createPostgresAgentRegistrationStore,
|
|
28239
|
+
createPostgresAgentDelegationStore,
|
|
27783
28240
|
createPostgresAccessTokenStore,
|
|
27784
28241
|
createOrganization,
|
|
28242
|
+
createOidcAgentCredentialVerifier,
|
|
27785
28243
|
createOAuthLinkedProviderCredentialResolver,
|
|
27786
28244
|
createNeonWebhookDeliveryStore,
|
|
27787
28245
|
createNeonWebAuthnCredentialStore,
|
|
@@ -27819,6 +28277,8 @@ export {
|
|
|
27819
28277
|
createNeonAuditSink,
|
|
27820
28278
|
createNeonApiKeyStore,
|
|
27821
28279
|
createNeonApiClientStore,
|
|
28280
|
+
createNeonAgentRegistrationStore,
|
|
28281
|
+
createNeonAgentDelegationStore,
|
|
27822
28282
|
createNeonAccessTokenStore,
|
|
27823
28283
|
createMfaGate,
|
|
27824
28284
|
createMembershipPermissionResolver,
|
|
@@ -27859,6 +28319,8 @@ export {
|
|
|
27859
28319
|
createInMemoryAuditSink,
|
|
27860
28320
|
createInMemoryApiKeyStore,
|
|
27861
28321
|
createInMemoryApiClientStore,
|
|
28322
|
+
createInMemoryAgentRegistrationStore,
|
|
28323
|
+
createInMemoryAgentDelegationStore,
|
|
27862
28324
|
createInMemoryAccessTokenStore,
|
|
27863
28325
|
createFgaEngine,
|
|
27864
28326
|
createFederatedTokenStore,
|
|
@@ -27897,6 +28359,12 @@ export {
|
|
|
27897
28359
|
apiKeysTable,
|
|
27898
28360
|
apiKeysRoutes,
|
|
27899
28361
|
apiClientsTable,
|
|
28362
|
+
agentRegistrationsTable,
|
|
28363
|
+
agentProtectedResourceMetadata,
|
|
28364
|
+
agentHasScopes,
|
|
28365
|
+
agentDelegationsTable,
|
|
28366
|
+
agentAuthPlugin,
|
|
28367
|
+
agentAuthChallenge,
|
|
27900
28368
|
addToSessionRing,
|
|
27901
28369
|
accessTokensTable,
|
|
27902
28370
|
acceptInvitation,
|
|
@@ -27940,10 +28408,11 @@ export {
|
|
|
27940
28408
|
DEFAULT_INVITATION_TTL_MS,
|
|
27941
28409
|
DEFAULT_CREDENTIAL_SESSION_TTL_MS,
|
|
27942
28410
|
DEFAULT_BACKUP_CODE_COUNT,
|
|
28411
|
+
DEFAULT_AGENT_RESOURCE_METADATA_ROUTE,
|
|
27943
28412
|
CLIENT_ASSERTION_TYPE,
|
|
27944
28413
|
CIBA_GRANT_TYPE,
|
|
27945
28414
|
AuthIdentityConflictError
|
|
27946
28415
|
};
|
|
27947
28416
|
|
|
27948
|
-
//# debugId=
|
|
28417
|
+
//# debugId=5F5850B4C390793864756E2164756E21
|
|
27949
28418
|
//# sourceMappingURL=index.js.map
|