cloudflare-htmx
Advanced tools
Comparing version 1.2.0 to 1.2.1
import RootLayout from '@layouts/RootLayout'; | ||
import { applyLayout } from '@lib/html'; | ||
export const onRequestGet = [applyLayout(RootLayout)]; | ||
export const onRequest = [applyLayout(RootLayout, true)]; |
import DashLayout from '@layouts/DashLayout'; | ||
import { authConfig } from '@lib/constants'; | ||
import { applyLayout } from '@lib/html'; | ||
import { middlewareGuard } from 'cloudflare-auth'; | ||
export const onRequestGet = [ | ||
middlewareGuard(authConfig), | ||
applyLayout(DashLayout), | ||
]; | ||
export const onRequest = [middlewareGuard, applyLayout(DashLayout, false)]; |
import SubLayout from '@layouts/SubLayout'; | ||
import { applyLayout } from '@lib/html'; | ||
export const onRequestGet = [applyLayout(SubLayout)]; | ||
export const onRequest = [applyLayout(SubLayout, false)]; |
import Toast from '@components/Toast'; | ||
import { Env, isAuthorised, login } from 'cloudflare-auth'; | ||
import { Env, isAuthorised, loginWithToken } from 'cloudflare-auth'; | ||
import { html, view } from '@lib/html'; | ||
import { authConfig } from '@lib/constants'; | ||
@@ -14,4 +13,3 @@ export const onRequestPost: PagesFunction<Env> = async ({ request, env }) => { | ||
} | ||
const token = await login(email, env); | ||
const magicLink = `${url.origin}/verify?token=${token}`; | ||
const magicLink = await loginWithToken(email, env, url.origin, true); | ||
try { | ||
@@ -29,4 +27,4 @@ return view( | ||
export const onRequestGet: PagesFunction = async ({ request }) => { | ||
const loggedIn = await isAuthorised(authConfig, request); | ||
export const onRequestGet: PagesFunction<Env> = async ({ env, request }) => { | ||
const loggedIn = await isAuthorised(request, env); | ||
if (loggedIn) { | ||
@@ -33,0 +31,0 @@ console.log('redirect to dashboard'); |
@@ -1,6 +0,5 @@ | ||
import { authConfig } from '@lib/constants'; | ||
import { logout } from 'cloudflare-auth'; | ||
import { Env, logout } from 'cloudflare-auth'; | ||
export const onRequestPost: PagesFunction = async ({ request }) => { | ||
return logout(authConfig, new URL(request.url)); | ||
export const onRequestPost: PagesFunction<Env> = async ({ env }) => { | ||
return logout(env, '/'); | ||
}; |
import Spinner from '@components/Spinner'; | ||
import { html, view } from '@lib/html'; | ||
import { authConfig } from '@lib/constants'; | ||
import { verify, Env } from 'cloudflare-auth'; | ||
@@ -11,5 +10,6 @@ | ||
try { | ||
return await verify(token!, env, authConfig, url); | ||
} catch { | ||
return Response.redirect(url.origin, 301); | ||
return await verify(token!, env, '/dashboard'); | ||
} catch (e) { | ||
console.log(e); | ||
return Response.redirect(url.origin, 303); | ||
} | ||
@@ -16,0 +16,0 @@ }; |
@@ -13,13 +13,13 @@ { | ||
"devDependencies": { | ||
"@cloudflare/workers-types": "^4.20230404.0", | ||
"@types/cookie": "^0.5.1", | ||
"tailwindcss": "^3.3.1", | ||
"wrangler": "^3.0.1" | ||
"@cloudflare/workers-types": "^4.20231016.0", | ||
"@types/cookie": "^0.5.3", | ||
"tailwindcss": "^3.3.3", | ||
"wrangler": "^3.14.0" | ||
}, | ||
"private": true, | ||
"dependencies": { | ||
"cloudflare-auth": "^1.0.0", | ||
"cloudflare-auth": "^1.5.0", | ||
"cookie": "^0.5.0", | ||
"daisyui": "^2.51.6" | ||
"daisyui": "^2.52.0" | ||
} | ||
} |
@@ -6,2 +6,4 @@ const HEADERS = { headers: { 'content-type': 'text/html;charset=UTF-8' } }; | ||
new Response(domArgs.join('\n'), HEADERS); | ||
export const redirect = (url: string, status = 303) => | ||
new Response(null, { status, headers: { 'HX-Redirect': url } }); | ||
@@ -8,0 +10,0 @@ export type LayoutFunction<Env = any, Params extends string = any> = ({ |
{ | ||
"name": "cloudflare-htmx", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "HTMX library for Cloudflare Pages", | ||
@@ -5,0 +5,0 @@ "main": "index.ts", |
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
6
1230017
49
22824