@absolutejs/auth 0.75.4 → 0.75.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/context.d.ts +6 -2
- package/dist/agents/index.js +6 -5
- package/dist/agents/index.js.map +3 -3
- package/dist/agents/routes.d.ts +10 -4
- package/dist/authContext.d.ts +178 -66
- package/dist/authorization/protectPermission.d.ts +8 -3
- package/dist/htmx/configuredRoutes.d.ts +126 -37
- package/dist/htmx/routes.d.ts +126 -37
- package/dist/index.d.ts +432 -162
- package/dist/index.js +44 -37
- package/dist/index.js.map +6 -6
- package/dist/routes/protectRoute.d.ts +21 -4
- package/dist/routes/stepUp.d.ts +8 -3
- package/dist/server.js +44 -37
- package/dist/server.js.map +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3370,8 +3370,8 @@ var failureResponse = (config, failure, requiredScopes) => new Response(JSON.str
|
|
|
3370
3370
|
var agentAuthContextPlugin = (config) => new Elysia2({
|
|
3371
3371
|
name: "@absolutejs/auth/agent-context",
|
|
3372
3372
|
seed: pluginDependencySeed(config)
|
|
3373
|
-
}).derive(({ request }) =>
|
|
3374
|
-
protectAgent
|
|
3373
|
+
}).derive(({ request }) => {
|
|
3374
|
+
const protectAgent = async (requiredScopes, handleAuth, handleAuthFail) => {
|
|
3375
3375
|
if (config === undefined) {
|
|
3376
3376
|
const failure = {
|
|
3377
3377
|
code: "Unauthorized",
|
|
@@ -3397,8 +3397,9 @@ var agentAuthContextPlugin = (config) => new Elysia2({
|
|
|
3397
3397
|
return await handleAuthFail?.(failure) ?? failureResponse(config, failure, requiredScopes);
|
|
3398
3398
|
}
|
|
3399
3399
|
return handleAuth(principal);
|
|
3400
|
-
}
|
|
3401
|
-
}
|
|
3400
|
+
};
|
|
3401
|
+
return { protectAgent };
|
|
3402
|
+
}).as("global");
|
|
3402
3403
|
|
|
3403
3404
|
// src/agents/oauthGuide.ts
|
|
3404
3405
|
var DEFAULT_GUIDE_ROUTE = "/auth.md";
|
|
@@ -4609,17 +4610,17 @@ var protectPermissionPlugin = ({
|
|
|
4609
4610
|
}).use(sessionStore()).guard({
|
|
4610
4611
|
cookie: t3.Cookie({ user_session_id: userSessionIdTypebox }),
|
|
4611
4612
|
schema: "merge"
|
|
4612
|
-
}).derive(({ store: { session }, cookie: { user_session_id }, status }) =>
|
|
4613
|
-
protectPermission
|
|
4613
|
+
}).derive(({ store: { session }, cookie: { user_session_id }, status }) => {
|
|
4614
|
+
const protectPermission = (check, handleAuth, handleAuthFail) => getStatusFromSource({
|
|
4614
4615
|
authSessionStore,
|
|
4615
4616
|
session,
|
|
4616
4617
|
user_session_id
|
|
4617
4618
|
}).then(async ({ user, error }) => {
|
|
4618
4619
|
if (error) {
|
|
4619
|
-
return handleAuthFail?.(error) ?? status(error.code, error.message);
|
|
4620
|
+
return await handleAuthFail?.(error) ?? status(error.code, error.message);
|
|
4620
4621
|
}
|
|
4621
4622
|
if (!user) {
|
|
4622
|
-
return handleAuthFail?.({
|
|
4623
|
+
return await handleAuthFail?.({
|
|
4623
4624
|
code: "Unauthorized",
|
|
4624
4625
|
message: "User is not authenticated"
|
|
4625
4626
|
}) ?? status("Unauthorized", "User is not authenticated");
|
|
@@ -4636,14 +4637,15 @@ var protectPermissionPlugin = ({
|
|
|
4636
4637
|
organizationId: check.organizationId,
|
|
4637
4638
|
type: "authorization_denied"
|
|
4638
4639
|
});
|
|
4639
|
-
return handleAuthFail?.({
|
|
4640
|
+
return await handleAuthFail?.({
|
|
4640
4641
|
code: "Forbidden",
|
|
4641
4642
|
message: "Insufficient permissions"
|
|
4642
4643
|
}) ?? status("Forbidden", "Insufficient permissions");
|
|
4643
4644
|
}
|
|
4644
4645
|
return handleAuth(user);
|
|
4645
|
-
})
|
|
4646
|
-
}
|
|
4646
|
+
});
|
|
4647
|
+
return { protectPermission };
|
|
4648
|
+
}).as("global");
|
|
4647
4649
|
|
|
4648
4650
|
// src/routes/protectRoute.ts
|
|
4649
4651
|
import { Elysia as Elysia6, t as t4 } from "elysia";
|
|
@@ -4707,8 +4709,7 @@ var protectRoutePlugin = ({
|
|
|
4707
4709
|
}).derive(async ({
|
|
4708
4710
|
store: { session },
|
|
4709
4711
|
cookie: { user_session_id },
|
|
4710
|
-
headers
|
|
4711
|
-
status
|
|
4712
|
+
headers
|
|
4712
4713
|
}) => {
|
|
4713
4714
|
const sessionStatus = await getStatusFromSource({
|
|
4714
4715
|
authSessionStore,
|
|
@@ -4727,25 +4728,30 @@ var protectRoutePlugin = ({
|
|
|
4727
4728
|
authorization: headers.authorization,
|
|
4728
4729
|
config: accessTokens
|
|
4729
4730
|
});
|
|
4730
|
-
return {
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
return
|
|
4731
|
+
return { absoluteAuthStatus: sessionStatus, authPrincipal };
|
|
4732
|
+
}).derive(({ absoluteAuthStatus, authPrincipal, status }) => {
|
|
4733
|
+
const protectRoute = async (handleAuth, handleAuthFail) => {
|
|
4734
|
+
if (!absoluteAuthStatus)
|
|
4735
|
+
return await handleAuthFail?.({
|
|
4736
|
+
code: "Unauthorized",
|
|
4737
|
+
message: "User is not authenticated"
|
|
4738
|
+
}) ?? status("Unauthorized", "User is not authenticated");
|
|
4739
|
+
const user = authPrincipal?.user;
|
|
4740
|
+
const { error } = absoluteAuthStatus;
|
|
4741
|
+
if (error) {
|
|
4742
|
+
if (user)
|
|
4743
|
+
return handleAuth(user);
|
|
4744
|
+
return await handleAuthFail?.(error) ?? status(error.code, error.message);
|
|
4745
|
+
}
|
|
4746
|
+
if (!user) {
|
|
4747
|
+
return await handleAuthFail?.({
|
|
4748
|
+
code: "Unauthorized",
|
|
4749
|
+
message: "User is not authenticated"
|
|
4750
|
+
}) ?? status("Unauthorized", "User is not authenticated");
|
|
4747
4751
|
}
|
|
4752
|
+
return handleAuth(user);
|
|
4748
4753
|
};
|
|
4754
|
+
return { protectRoute };
|
|
4749
4755
|
}).as("global");
|
|
4750
4756
|
|
|
4751
4757
|
// src/routes/stepUp.ts
|
|
@@ -4758,23 +4764,24 @@ var stepUpPlugin = ({
|
|
|
4758
4764
|
}).use(sessionStore()).guard({
|
|
4759
4765
|
cookie: t5.Cookie({ user_session_id: userSessionIdTypebox }),
|
|
4760
4766
|
schema: "merge"
|
|
4761
|
-
}).derive(({ store: { session }, cookie: { user_session_id }, status }) =>
|
|
4762
|
-
requireRecentAuth
|
|
4767
|
+
}).derive(({ store: { session }, cookie: { user_session_id }, status }) => {
|
|
4768
|
+
const requireRecentAuth = (maxAgeMs, handleAuth, handleAuthFail) => loadSessionFromSource({
|
|
4763
4769
|
authSessionStore,
|
|
4764
4770
|
session,
|
|
4765
4771
|
userSessionId: user_session_id.value
|
|
4766
|
-
}).then((userSession) => {
|
|
4772
|
+
}).then(async (userSession) => {
|
|
4767
4773
|
const authenticatedAt = userSession?.authenticatedAt;
|
|
4768
4774
|
const isRecent = authenticatedAt !== undefined && Date.now() - authenticatedAt <= maxAgeMs;
|
|
4769
4775
|
if (!userSession || !isRecent) {
|
|
4770
|
-
return handleAuthFail?.({
|
|
4776
|
+
return await handleAuthFail?.({
|
|
4771
4777
|
code: "Unauthorized",
|
|
4772
4778
|
message: "Recent authentication required"
|
|
4773
4779
|
}) ?? status("Unauthorized", "Recent authentication required");
|
|
4774
4780
|
}
|
|
4775
4781
|
return handleAuth(userSession.user);
|
|
4776
|
-
})
|
|
4777
|
-
}
|
|
4782
|
+
});
|
|
4783
|
+
return { requireRecentAuth };
|
|
4784
|
+
}).as("global");
|
|
4778
4785
|
|
|
4779
4786
|
// src/oidc/socketTickets.ts
|
|
4780
4787
|
init_crypto();
|
|
@@ -41026,5 +41033,5 @@ export {
|
|
|
41026
41033
|
ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV
|
|
41027
41034
|
};
|
|
41028
41035
|
|
|
41029
|
-
//# debugId=
|
|
41036
|
+
//# debugId=BB86F0203A3F9DD064756E2164756E21
|
|
41030
41037
|
//# sourceMappingURL=index.js.map
|