@absolutejs/auth 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/htmxRoutes.d.ts +514 -0
- package/dist/index.d.ts +455 -3
- package/dist/index.js +207 -40
- package/dist/index.js.map +7 -5
- package/dist/types.d.ts +6 -0
- package/dist/ui/index.js.map +2 -2
- package/dist/ui/types.d.ts +44 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2124,7 +2124,7 @@ var createOAuth2Client = async (providerName, config) => {
|
|
|
2124
2124
|
};
|
|
2125
2125
|
|
|
2126
2126
|
// src/index.ts
|
|
2127
|
-
import { Elysia as
|
|
2127
|
+
import { Elysia as Elysia12 } from "elysia";
|
|
2128
2128
|
|
|
2129
2129
|
// src/authorize.ts
|
|
2130
2130
|
import { Elysia, t as t2 } from "elysia";
|
|
@@ -2698,14 +2698,201 @@ var callback = ({
|
|
|
2698
2698
|
})
|
|
2699
2699
|
});
|
|
2700
2700
|
|
|
2701
|
-
// src/
|
|
2701
|
+
// src/htmxRoutes.ts
|
|
2702
|
+
import { Elysia as Elysia5 } from "elysia";
|
|
2703
|
+
|
|
2704
|
+
// src/protectRoute.ts
|
|
2702
2705
|
import { Elysia as Elysia4, t as t4 } from "elysia";
|
|
2706
|
+
var protectRoutePlugin = ({
|
|
2707
|
+
authSessionStore
|
|
2708
|
+
} = {}) => new Elysia4().use(sessionStore()).guard({ cookie: t4.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
|
|
2709
|
+
protectRoute: (handleAuth, handleAuthFail) => getStatusFromSource({
|
|
2710
|
+
authSessionStore,
|
|
2711
|
+
session,
|
|
2712
|
+
user_session_id
|
|
2713
|
+
}).then(async ({ user, error }) => {
|
|
2714
|
+
if (error) {
|
|
2715
|
+
return handleAuthFail?.(error) ?? status(error.code, error.message);
|
|
2716
|
+
}
|
|
2717
|
+
if (!user) {
|
|
2718
|
+
return handleAuthFail?.({
|
|
2719
|
+
code: "Unauthorized",
|
|
2720
|
+
message: "User is not authenticated"
|
|
2721
|
+
}) ?? status("Unauthorized", "User is not authenticated");
|
|
2722
|
+
}
|
|
2723
|
+
return await handleAuth(user);
|
|
2724
|
+
})
|
|
2725
|
+
})).as("global");
|
|
2726
|
+
|
|
2727
|
+
// src/ui/renderers.ts
|
|
2728
|
+
var escapeHtml = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
2729
|
+
var defaultAuthorizationHref = (provider, client) => client ? `/oauth2/${provider}/authorization?client=${client}` : `/oauth2/${provider}/authorization`;
|
|
2730
|
+
var resolveAuthHtmxRenderers = (config) => {
|
|
2731
|
+
const { connectorTargets, featuredLoginProviders, providerData } = config;
|
|
2732
|
+
const authorizationHref = config.authorizationHref ?? defaultAuthorizationHref;
|
|
2733
|
+
const overrides = config.render ?? {};
|
|
2734
|
+
const providerLabel = (key) => isValidProviderOption(key) ? providerData[key]?.name ?? key : key;
|
|
2735
|
+
const providerLogo = (key) => isValidProviderOption(key) ? providerData[key]?.logoUrl ?? "" : "";
|
|
2736
|
+
const account = (user) => {
|
|
2737
|
+
const fullName = [user.first_name, user.last_name].filter((part) => typeof part === "string" && part.length > 0).join(" ");
|
|
2738
|
+
return `<div class="grid-2">
|
|
2739
|
+
<div class="card"><h2 class="card__title">Canonical account</h2><p class="muted">Absolute Auth keeps one canonical user and links every OAuth identity to it. Conflicting identities raise a merge request.</p></div>
|
|
2740
|
+
<div class="card text-left"><h2 class="card__title">Profile fields</h2>
|
|
2741
|
+
<div class="spread"><span class="muted">Subject</span><span>${escapeHtml(user.sub)}</span></div>
|
|
2742
|
+
<div class="spread"><span class="muted">Name</span><span>${escapeHtml(fullName || "\u2014")}</span></div>
|
|
2743
|
+
<div class="spread"><span class="muted">Email</span><span>${escapeHtml(user.email ?? "\u2014")}</span></div>
|
|
2744
|
+
<div class="spread"><span class="muted">Primary identity</span><span>${escapeHtml(user.primary_auth_identity_id ?? "\u2014")}</span></div>
|
|
2745
|
+
</div>
|
|
2746
|
+
</div>`;
|
|
2747
|
+
};
|
|
2748
|
+
const authMenu = (user) => {
|
|
2749
|
+
if (!user) {
|
|
2750
|
+
return `<a class="btn btn--primary btn--sm" href="/htmx">Sign in</a>`;
|
|
2751
|
+
}
|
|
2752
|
+
const label = user.email ?? user.first_name ?? "Account";
|
|
2753
|
+
return `<span class="muted">${escapeHtml(label)}</span><a class="btn btn--ghost btn--sm" href="/htmx/signout">Sign out</a>`;
|
|
2754
|
+
};
|
|
2755
|
+
const connectorLinks = () => connectorTargets.map((target) => `<div class="card text-left"><h2 class="card__title row"><img class="entity__logo" alt="" src="${providerLogo(target.provider)}" />${escapeHtml(target.label)}</h2><p class="muted">${escapeHtml(target.description)}</p><a class="btn btn--primary" href="${authorizationHref(target.provider, "connector")}">Link ${escapeHtml(target.label)}</a></div>`).join("");
|
|
2756
|
+
const connectors = (payload) => {
|
|
2757
|
+
const scopeList = (scopes) => scopes.map((scope) => `<span class="scope">${escapeHtml(scope)}</span>`).join("");
|
|
2758
|
+
const bindings = payload.bindings.length === 0 ? `<div class="empty-state">No external accounts linked.</div>` : `<div class="entity-list">${payload.bindings.map((binding) => `<div class="entity"><div class="entity__meta"><span class="entity__title">${escapeHtml(binding.label ?? binding.externalAccountId)}<span class="pill">${escapeHtml(binding.connectorProvider)}</span></span><span class="entity__sub">${escapeHtml(binding.externalAccountType)} \xB7 ${escapeHtml(binding.status)}</span><div class="scope-list">${scopeList(binding.availableScopes)}</div></div><div class="entity__actions"><form hx-delete="/htmx/connectors/bindings/${binding.id}" hx-target="#connector-list" hx-swap="innerHTML"><button class="btn btn--danger btn--sm" type="submit">Remove</button></form></div></div>`).join("")}</div>`;
|
|
2759
|
+
const grants = payload.grants.length === 0 ? `<div class="empty-state">No connector grants yet.</div>` : `<div class="entity-list">${payload.grants.map((grant) => `<div class="entity"><div class="entity__meta"><span class="entity__title">${escapeHtml(grant.authProviderKey)}<span class="pill pill--indigo">${escapeHtml(grant.status)}</span></span><span class="entity__sub">Subject ${escapeHtml(grant.providerSubject)}</span><div class="scope-list">${scopeList(grant.grantedScopes)}</div></div><div class="entity__actions"><form hx-delete="/htmx/connectors/grants/${grant.id}" hx-target="#connector-list" hx-swap="innerHTML"><button class="btn btn--danger btn--sm" type="submit">Remove</button></form></div></div>`).join("")}</div>`;
|
|
2760
|
+
return `<h3 class="provider-heading">External accounts</h3>${bindings}<h3 class="provider-heading">Grants</h3>${grants}`;
|
|
2761
|
+
};
|
|
2762
|
+
const identities = (payload, query) => {
|
|
2763
|
+
const pending = payload.mergeRequests.filter((req) => req.status === "pending");
|
|
2764
|
+
const mergesHtml = pending.length === 0 ? "" : `<div class="stack"><h3 class="provider-heading">Merge requests</h3><div class="entity-list">${pending.map((req) => `<div class="entity card--danger"><div class="entity__meta"><span class="entity__title">${escapeHtml(providerLabel(req.conflicting_auth_provider))} conflict</span><span class="entity__sub">Subject ${escapeHtml(req.conflicting_provider_subject)}</span></div><div class="entity__actions">
|
|
2765
|
+
<form hx-post="/htmx/merge/${req.id}" hx-target="#identities-list" hx-swap="innerHTML" hx-include="#identity-query"><button class="btn btn--primary btn--sm" type="submit">Merge</button></form>
|
|
2766
|
+
<form hx-delete="/htmx/merge/${req.id}" hx-target="#identities-list" hx-swap="innerHTML" hx-include="#identity-query"><button class="btn btn--ghost btn--sm" type="submit">Dismiss</button></form>
|
|
2767
|
+
</div></div>`).join("")}</div></div>`;
|
|
2768
|
+
const term = query.trim().toLowerCase();
|
|
2769
|
+
const groups = Object.entries(payload.identities).map(([provider, list]) => ({
|
|
2770
|
+
identities: list.filter((identity) => term === "" || providerLabel(provider).toLowerCase().includes(term) || identity.id.toLowerCase().includes(term) || identity.provider_subject.toLowerCase().includes(term)),
|
|
2771
|
+
provider
|
|
2772
|
+
})).filter((group) => group.identities.length > 0);
|
|
2773
|
+
const groupsHtml = groups.length === 0 ? `<div class="empty-state">No identities match your search.</div>` : groups.map((group) => `<div class="provider-group"><h3 class="provider-heading">${providerLogo(group.provider) ? `<img class="entity__logo" alt="" src="${providerLogo(group.provider)}" />` : ""}${escapeHtml(providerLabel(group.provider))}</h3><div class="entity-list">${group.identities.map((identity) => `<div class="entity"><div class="entity__main"><div class="entity__meta"><span class="entity__title">${escapeHtml(identity.provider_subject)}${identity.isPrimary ? `<span class="pill pill--primary">Primary</span>` : ""}</span><span class="entity__sub">${escapeHtml(identity.id)}</span></div></div><div class="entity__actions">
|
|
2774
|
+
${identity.isPrimary ? "" : `<form hx-post="/htmx/identities/${identity.id}/primary" hx-target="#identities-list" hx-swap="innerHTML" hx-include="#identity-query"><button class="btn btn--neutral btn--sm" type="submit">Set primary</button></form>`}
|
|
2775
|
+
<form hx-delete="/htmx/identities/${identity.id}" hx-target="#identities-list" hx-swap="innerHTML" hx-include="#identity-query"><button class="btn btn--danger btn--sm" type="submit">Remove</button></form>
|
|
2776
|
+
</div></div>`).join("")}</div></div>`).join("");
|
|
2777
|
+
return `${mergesHtml}${groupsHtml}`;
|
|
2778
|
+
};
|
|
2779
|
+
const protectedView = (user) => `<section class="auth-section stack"><div><h1 class="page-heading">Protected page</h1><p class="muted">Your authenticated session resolves to this user record.</p></div><pre class="json">${escapeHtml(JSON.stringify(user, null, 2))}</pre></section>`;
|
|
2780
|
+
const providerLogin = (verb, includeDropdown) => {
|
|
2781
|
+
const featured = featuredLoginProviders.map((provider) => `<a class="oauth-button" href="${authorizationHref(provider)}"><img class="oauth-button__icon" alt="" src="${providerLogo(provider)}" /><span class="oauth-button__text">${escapeHtml(verb)} ${escapeHtml(providerLabel(provider))}</span></a>`).join("");
|
|
2782
|
+
if (!includeDropdown) {
|
|
2783
|
+
return `<div class="oauth-grid">${featured}</div>`;
|
|
2784
|
+
}
|
|
2785
|
+
const options = providerOptions.map((provider) => `<option value="${provider}">${escapeHtml(providerLabel(provider))}</option>`).join("");
|
|
2786
|
+
return `<div class="oauth-grid">${featured}
|
|
2787
|
+
<div class="separator"><span class="separator__line"></span><span class="separator__text">or any provider</span><span class="separator__line"></span></div>
|
|
2788
|
+
<form class="oauth-grid" action="/htmx/login-redirect" method="get">
|
|
2789
|
+
<select class="provider-select" name="provider" required>
|
|
2790
|
+
<option value="">Select a provider\u2026</option>${options}
|
|
2791
|
+
</select>
|
|
2792
|
+
<button class="btn btn--primary" type="submit">Continue</button>
|
|
2793
|
+
</form>
|
|
2794
|
+
</div>`;
|
|
2795
|
+
};
|
|
2796
|
+
return {
|
|
2797
|
+
account: overrides.account ?? account,
|
|
2798
|
+
authMenu: overrides.authMenu ?? authMenu,
|
|
2799
|
+
connectorLinks: overrides.connectorLinks ?? connectorLinks,
|
|
2800
|
+
connectors: overrides.connectors ?? connectors,
|
|
2801
|
+
escapeHtml,
|
|
2802
|
+
identities: overrides.identities ?? identities,
|
|
2803
|
+
protected: overrides.protected ?? protectedView,
|
|
2804
|
+
providerLogin: overrides.providerLogin ?? providerLogin
|
|
2805
|
+
};
|
|
2806
|
+
};
|
|
2807
|
+
|
|
2808
|
+
// src/htmxRoutes.ts
|
|
2809
|
+
var SEE_OTHER = 303;
|
|
2810
|
+
var html = (markup) => new Response(markup, {
|
|
2811
|
+
headers: { "content-type": "text/html; charset=utf-8" }
|
|
2812
|
+
});
|
|
2813
|
+
var signInPrompt = `<section class="auth-content"><h1 class="page-heading">Not authorized</h1><p class="muted">You need to sign in to view this page.</p><a class="btn btn--primary" href="/htmx">Go to sign in</a></section>`;
|
|
2814
|
+
var createAuthHtmxRoutes = (config) => {
|
|
2815
|
+
const renderers = resolveAuthHtmxRenderers(config);
|
|
2816
|
+
const authorizationHref = config.authorizationHref ?? ((provider) => `/oauth2/${provider}/authorization`);
|
|
2817
|
+
return new Elysia5().use(protectRoutePlugin({
|
|
2818
|
+
authSessionStore: config.authSessionStore
|
|
2819
|
+
})).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) => {
|
|
2820
|
+
const search = typeof query.query === "string" ? query.query : "";
|
|
2821
|
+
return html(renderers.identities(await config.loadAuthIdentities(user.sub), search));
|
|
2822
|
+
})).post("/htmx/identities/:id/primary", ({ params, protectRoute }) => protectRoute(async (user) => {
|
|
2823
|
+
try {
|
|
2824
|
+
await config.setPrimaryIdentity({
|
|
2825
|
+
identityId: params.id,
|
|
2826
|
+
userSub: user.sub
|
|
2827
|
+
});
|
|
2828
|
+
} catch {}
|
|
2829
|
+
return html(renderers.identities(await config.loadAuthIdentities(user.sub), ""));
|
|
2830
|
+
})).delete("/htmx/identities/:id", ({ params, protectRoute }) => protectRoute(async (user) => {
|
|
2831
|
+
const payload = await config.loadAuthIdentities(user.sub);
|
|
2832
|
+
const identities = Object.values(payload.identities).flat();
|
|
2833
|
+
const identity = identities.find((candidate) => candidate.id === params.id);
|
|
2834
|
+
if (identity && identities.length > 1 && identity.isPrimary !== true) {
|
|
2835
|
+
await config.removeIdentity({
|
|
2836
|
+
identityId: identity.id,
|
|
2837
|
+
userSub: user.sub
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2840
|
+
return html(renderers.identities(await config.loadAuthIdentities(user.sub), ""));
|
|
2841
|
+
})).post("/htmx/merge/:id", ({ params, protectRoute }) => protectRoute(async (user) => {
|
|
2842
|
+
try {
|
|
2843
|
+
await config.mergeIdentity({
|
|
2844
|
+
mergeRequestId: params.id,
|
|
2845
|
+
userSub: user.sub
|
|
2846
|
+
});
|
|
2847
|
+
} catch {}
|
|
2848
|
+
return html(renderers.identities(await config.loadAuthIdentities(user.sub), ""));
|
|
2849
|
+
})).delete("/htmx/merge/:id", ({ params, protectRoute }) => protectRoute(async (user) => {
|
|
2850
|
+
await config.dismissMergeRequest({
|
|
2851
|
+
mergeRequestId: params.id,
|
|
2852
|
+
userSub: user.sub
|
|
2853
|
+
});
|
|
2854
|
+
return html(renderers.identities(await config.loadAuthIdentities(user.sub), ""));
|
|
2855
|
+
})).get("/htmx/connector-list", ({ protectRoute }) => protectRoute(async (user) => html(renderers.connectors(await config.loadLinkedProviders(user.sub))), () => html(signInPrompt))).delete("/htmx/connectors/grants/:id", ({ params, protectRoute }) => protectRoute(async (user) => {
|
|
2856
|
+
await config.removeGrant({
|
|
2857
|
+
grantId: params.id,
|
|
2858
|
+
userSub: user.sub
|
|
2859
|
+
});
|
|
2860
|
+
return html(renderers.connectors(await config.loadLinkedProviders(user.sub)));
|
|
2861
|
+
})).delete("/htmx/connectors/bindings/:id", ({ params, protectRoute }) => protectRoute(async (user) => {
|
|
2862
|
+
await config.removeBinding({
|
|
2863
|
+
bindingId: params.id,
|
|
2864
|
+
userSub: user.sub
|
|
2865
|
+
});
|
|
2866
|
+
return html(renderers.connectors(await config.loadLinkedProviders(user.sub)));
|
|
2867
|
+
})).get("/htmx/login-redirect", ({ query, redirect }) => {
|
|
2868
|
+
const provider = typeof query.provider === "string" ? query.provider : "";
|
|
2869
|
+
return redirect(isValidProviderOption(provider) ? authorizationHref(provider) : "/htmx");
|
|
2870
|
+
}).post("/htmx/delete-account", (context) => context.protectRoute(async (user) => {
|
|
2871
|
+
const confirm = typeof context.body === "object" && context.body !== null && "confirm" in context.body ? String(context.body.confirm) : "";
|
|
2872
|
+
if (confirm !== "DELETE") {
|
|
2873
|
+
return html(`<div class="error-banner">Type DELETE to confirm.</div>`);
|
|
2874
|
+
}
|
|
2875
|
+
await config.deleteAccount({ userSub: user.sub });
|
|
2876
|
+
context.set.headers["HX-Redirect"] = "/htmx";
|
|
2877
|
+
return html("");
|
|
2878
|
+
})).get("/htmx/signout", async ({ cookie: { user_session_id }, redirect }) => {
|
|
2879
|
+
const sessionId = user_session_id.value;
|
|
2880
|
+
if (sessionId !== undefined && isUserSessionId(sessionId)) {
|
|
2881
|
+
await config.authSessionStore?.removeSession(sessionId);
|
|
2882
|
+
}
|
|
2883
|
+
user_session_id.remove();
|
|
2884
|
+
return redirect("/htmx", SEE_OTHER);
|
|
2885
|
+
});
|
|
2886
|
+
};
|
|
2887
|
+
|
|
2888
|
+
// src/profile.ts
|
|
2889
|
+
import { Elysia as Elysia6, t as t5 } from "elysia";
|
|
2703
2890
|
var profile = ({
|
|
2704
2891
|
clientProviders,
|
|
2705
2892
|
profileRoute = "/oauth2/profile",
|
|
2706
2893
|
onProfileSuccess,
|
|
2707
2894
|
onProfileError
|
|
2708
|
-
}) => new
|
|
2895
|
+
}) => new Elysia6().use(sessionStore()).get(profileRoute, async ({
|
|
2709
2896
|
status,
|
|
2710
2897
|
store: { session },
|
|
2711
2898
|
cookie: { user_session_id, auth_provider, auth_client }
|
|
@@ -2752,38 +2939,15 @@ var profile = ({
|
|
|
2752
2939
|
return err instanceof Error ? status("Internal Server Error", `${err.message} - ${err.stack ?? ""}`) : status("Internal Server Error", `Failed to validate authorization code: Unknown status: ${err}`);
|
|
2753
2940
|
}
|
|
2754
2941
|
}, {
|
|
2755
|
-
cookie:
|
|
2942
|
+
cookie: t5.Cookie({
|
|
2756
2943
|
auth_client: authClientOption,
|
|
2757
2944
|
auth_provider: authProviderOption,
|
|
2758
2945
|
user_session_id: userSessionIdTypebox
|
|
2759
2946
|
})
|
|
2760
2947
|
});
|
|
2761
2948
|
|
|
2762
|
-
// src/protectRoute.ts
|
|
2763
|
-
import { Elysia as Elysia5, t as t5 } from "elysia";
|
|
2764
|
-
var protectRoutePlugin = ({
|
|
2765
|
-
authSessionStore
|
|
2766
|
-
} = {}) => new Elysia5().use(sessionStore()).guard({ cookie: t5.Cookie({ user_session_id: userSessionIdTypebox }) }).derive(({ store: { session }, cookie: { user_session_id }, status }) => ({
|
|
2767
|
-
protectRoute: (handleAuth, handleAuthFail) => getStatusFromSource({
|
|
2768
|
-
authSessionStore,
|
|
2769
|
-
session,
|
|
2770
|
-
user_session_id
|
|
2771
|
-
}).then(async ({ user, error }) => {
|
|
2772
|
-
if (error) {
|
|
2773
|
-
return handleAuthFail?.(error) ?? status(error.code, error.message);
|
|
2774
|
-
}
|
|
2775
|
-
if (!user) {
|
|
2776
|
-
return handleAuthFail?.({
|
|
2777
|
-
code: "Unauthorized",
|
|
2778
|
-
message: "User is not authenticated"
|
|
2779
|
-
}) ?? status("Unauthorized", "User is not authenticated");
|
|
2780
|
-
}
|
|
2781
|
-
return await handleAuth(user);
|
|
2782
|
-
})
|
|
2783
|
-
})).as("global");
|
|
2784
|
-
|
|
2785
2949
|
// src/refresh.ts
|
|
2786
|
-
import { Elysia as
|
|
2950
|
+
import { Elysia as Elysia7, t as t6 } from "elysia";
|
|
2787
2951
|
var refresh = ({
|
|
2788
2952
|
authSessionStore,
|
|
2789
2953
|
clientProviders,
|
|
@@ -2791,7 +2955,7 @@ var refresh = ({
|
|
|
2791
2955
|
onRefreshSuccess,
|
|
2792
2956
|
onRefreshError,
|
|
2793
2957
|
sessionDurationMs = MILLISECONDS_IN_A_DAY
|
|
2794
|
-
}) => new
|
|
2958
|
+
}) => new Elysia7().use(sessionStore()).post(refreshRoute, async ({
|
|
2795
2959
|
status,
|
|
2796
2960
|
store: { session },
|
|
2797
2961
|
cookie: { user_session_id, auth_provider, auth_client }
|
|
@@ -2870,14 +3034,14 @@ var refresh = ({
|
|
|
2870
3034
|
});
|
|
2871
3035
|
|
|
2872
3036
|
// src/revoke.ts
|
|
2873
|
-
import { Elysia as
|
|
3037
|
+
import { Elysia as Elysia8, t as t7 } from "elysia";
|
|
2874
3038
|
var revoke = ({
|
|
2875
3039
|
authSessionStore,
|
|
2876
3040
|
clientProviders,
|
|
2877
3041
|
revokeRoute = "/oauth2/revocation",
|
|
2878
3042
|
onRevocationSuccess,
|
|
2879
3043
|
onRevocationError
|
|
2880
|
-
}) => new
|
|
3044
|
+
}) => new Elysia8().use(sessionStore()).post(revokeRoute, async ({
|
|
2881
3045
|
status,
|
|
2882
3046
|
store: { session },
|
|
2883
3047
|
cookie: { user_session_id, auth_provider, auth_client }
|
|
@@ -2947,7 +3111,7 @@ var revoke = ({
|
|
|
2947
3111
|
});
|
|
2948
3112
|
|
|
2949
3113
|
// src/sessionCleanup.ts
|
|
2950
|
-
import { Elysia as
|
|
3114
|
+
import { Elysia as Elysia9 } from "elysia";
|
|
2951
3115
|
var sessionCleanup = ({
|
|
2952
3116
|
authSessionStore,
|
|
2953
3117
|
cleanupIntervalMs = MILLISECONDS_IN_AN_HOUR,
|
|
@@ -2955,7 +3119,7 @@ var sessionCleanup = ({
|
|
|
2955
3119
|
onSessionCleanup
|
|
2956
3120
|
}) => {
|
|
2957
3121
|
let intervalId = null;
|
|
2958
|
-
return new
|
|
3122
|
+
return new Elysia9({ name: "sessionCleanup" }).use(sessionStore()).onStart(({ store: { session, unregisteredSession } }) => {
|
|
2959
3123
|
intervalId = setInterval(async () => {
|
|
2960
3124
|
await performCleanup({
|
|
2961
3125
|
authSessionStore,
|
|
@@ -3168,12 +3332,12 @@ var performCleanup = async ({
|
|
|
3168
3332
|
};
|
|
3169
3333
|
|
|
3170
3334
|
// src/signout.ts
|
|
3171
|
-
import { Elysia as
|
|
3335
|
+
import { Elysia as Elysia10, t as t8 } from "elysia";
|
|
3172
3336
|
var signout = ({
|
|
3173
3337
|
authSessionStore,
|
|
3174
3338
|
signoutRoute = "/oauth2/signout",
|
|
3175
3339
|
onSignOut
|
|
3176
|
-
}) => new
|
|
3340
|
+
}) => new Elysia10().use(sessionStore()).delete(signoutRoute, async ({
|
|
3177
3341
|
status,
|
|
3178
3342
|
store: { session },
|
|
3179
3343
|
cookie: { user_session_id, auth_provider }
|
|
@@ -3228,12 +3392,12 @@ var signout = ({
|
|
|
3228
3392
|
});
|
|
3229
3393
|
|
|
3230
3394
|
// src/userStatus.ts
|
|
3231
|
-
import { Elysia as
|
|
3395
|
+
import { Elysia as Elysia11, t as t9 } from "elysia";
|
|
3232
3396
|
var userStatus = ({
|
|
3233
3397
|
authSessionStore,
|
|
3234
3398
|
statusRoute = "/oauth2/status",
|
|
3235
3399
|
onStatus
|
|
3236
|
-
}) => new
|
|
3400
|
+
}) => new Elysia11().use(sessionStore()).get(statusRoute, async ({ status, cookie: { user_session_id }, store: { session } }) => {
|
|
3237
3401
|
const { user, error } = await getStatusFromSource({
|
|
3238
3402
|
authSessionStore,
|
|
3239
3403
|
session,
|
|
@@ -13774,6 +13938,7 @@ var absoluteAuth = async ({
|
|
|
13774
13938
|
maxSessions,
|
|
13775
13939
|
sessionDurationMs,
|
|
13776
13940
|
authSessionStore,
|
|
13941
|
+
htmx,
|
|
13777
13942
|
resolveAuthIntent,
|
|
13778
13943
|
onAuthorizeSuccess,
|
|
13779
13944
|
onAuthorizeError,
|
|
@@ -13793,7 +13958,7 @@ var absoluteAuth = async ({
|
|
|
13793
13958
|
onSessionCleanup
|
|
13794
13959
|
}) => {
|
|
13795
13960
|
const clientProviders = await buildClientProviders(providersConfiguration, createOAuth2Client);
|
|
13796
|
-
return new
|
|
13961
|
+
return new Elysia12().use(sessionCleanup({
|
|
13797
13962
|
authSessionStore,
|
|
13798
13963
|
cleanupIntervalMs,
|
|
13799
13964
|
maxSessions,
|
|
@@ -13831,7 +13996,7 @@ var absoluteAuth = async ({
|
|
|
13831
13996
|
onProfileError,
|
|
13832
13997
|
onProfileSuccess,
|
|
13833
13998
|
profileRoute
|
|
13834
|
-
})).use(protectRoutePlugin({ authSessionStore }));
|
|
13999
|
+
})).use(protectRoutePlugin({ authSessionStore })).use(htmx ? createAuthHtmxRoutes({ ...htmx, authSessionStore }) : new Elysia12);
|
|
13835
14000
|
};
|
|
13836
14001
|
export {
|
|
13837
14002
|
validateSession,
|
|
@@ -13844,6 +14009,7 @@ export {
|
|
|
13844
14009
|
resolveOAuthTokenExpiresAt,
|
|
13845
14010
|
resolveOAuthAuthorization,
|
|
13846
14011
|
resolveClientProviderEntry,
|
|
14012
|
+
resolveAuthHtmxRenderers,
|
|
13847
14013
|
refreshableProviderOptions,
|
|
13848
14014
|
providers,
|
|
13849
14015
|
providerOptions,
|
|
@@ -13873,6 +14039,7 @@ export {
|
|
|
13873
14039
|
createLinkedProviderCredentialResolver,
|
|
13874
14040
|
createInMemoryLinkedProviderStores,
|
|
13875
14041
|
createInMemoryAuthSessionStore,
|
|
14042
|
+
createAuthHtmxRoutes,
|
|
13876
14043
|
createAuthConfiguration,
|
|
13877
14044
|
buildClientProviders,
|
|
13878
14045
|
authProviderOption,
|
|
@@ -13882,5 +14049,5 @@ export {
|
|
|
13882
14049
|
AbsoluteAuthIdentityConflictError
|
|
13883
14050
|
};
|
|
13884
14051
|
|
|
13885
|
-
//# debugId=
|
|
14052
|
+
//# debugId=D6887201B1B4B2A864756E2164756E21
|
|
13886
14053
|
//# sourceMappingURL=index.js.map
|