release: WRNexusJS 0.5.0
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { createAuthEngine, MemoryAuthStore } from "@wrnexus/auth";
|
||||
|
||||
export const outbox: unknown[] = [];
|
||||
|
||||
export const auth = createAuthEngine({
|
||||
store: new MemoryAuthStore(),
|
||||
secret: "development-auth-showcase-secret-change-in-production",
|
||||
issuer: "WRNexus Auth Showcase",
|
||||
sendLoginAlerts: true,
|
||||
onSignedIn(ctx, returnTo) {
|
||||
const safe = returnTo?.startsWith("/") && !returnTo.startsWith("//") ? returnTo : "/account";
|
||||
return Response.redirect(new URL(safe, ctx.url), 303);
|
||||
},
|
||||
onSignedOut(ctx) {
|
||||
return Response.redirect(new URL("/sign-in", ctx.url), 303);
|
||||
},
|
||||
onSuccessfulSignUp() {
|
||||
return {
|
||||
autoSignIn: true,
|
||||
redirectTo: "/account",
|
||||
};
|
||||
},
|
||||
delivery: {
|
||||
async send(message) {
|
||||
outbox.push(message);
|
||||
console.info(`[auth-showcase] queued ${message.template} for ${message.destination}`);
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
createCaptchaEngine,
|
||||
createCaptchaHttpHandlers,
|
||||
MemoryCaptchaStore,
|
||||
} from "@wrnexus/captcha/server";
|
||||
|
||||
export const captchaEngine = createCaptchaEngine({
|
||||
secret: process.env.CAPTCHA_SECRET ?? "development-auth-showcase-captcha-secret-change-this",
|
||||
store: new MemoryCaptchaStore(),
|
||||
basePath: "/api/captcha",
|
||||
challengeTtlMs: 2 * 60_000,
|
||||
responseTokenTtlMs: 5 * 60_000,
|
||||
maxAttempts: 3,
|
||||
minCompletionMs: 800,
|
||||
});
|
||||
|
||||
export const captchaHandlers = createCaptchaHttpHandlers(captchaEngine, {
|
||||
createLimit: 60,
|
||||
verifyLimit: 60,
|
||||
windowMs: 60_000,
|
||||
});
|
||||
Reference in New Issue
Block a user