This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TemplateResult } from "lit-html"; | |
type Render = (tpl: TemplateResult) => void; | |
type Step<In, Out> = { | |
template: (args: { | |
next: (arg: Out) => void; | |
state: In; | |
back?: () => void; | |
}) => TemplateResult; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// On first access looks up a search param: `?token=...` | |
// If the token is valid, saves it in cookies so that | |
// subsequent requests don't need the search param. | |
import type { Config, Context } from "@netlify/edge-functions"; | |
// Ideally look up from the environment | |
const EXPECTED_TOKEN = "very-secret"; | |
const TOKEN_COOKIE_NAME = "my-token"; | |
const TOKEN_HEADER_NAME = "x-my-token"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Config, Context } from "@netlify/edge-functions"; | |
// https://datatracker.ietf.org/doc/html/rfc7617 | |
// base64 encoded "user:pass" | |
const USER_PASS_ENCODED = "dXNlcjpwYXNz"; | |
export default async (request: Request, context: Context) => { | |
const requestAuthentication = () => { | |
const response = new Response(null, { | |
status: 401, |
OlderNewer