more dev work

This commit is contained in:
badblocks 2026-07-11 11:06:10 -07:00
parent 84261c9537
commit 441056cabc
Signed by: badblocks
SSH key fingerprint: SHA256:hEcM6BP4hKm9F7WsomNuXSBpPn2BSDnFzPSl3y1NerQ
12 changed files with 59 additions and 80 deletions

View file

@ -33,6 +33,8 @@ COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/dist ./dist
COPY --from=prerelease /usr/src/app/package.json ./
ENV HOST=0.0.0.0
USER node
EXPOSE 4321
ENTRYPOINT ["node", "./dist/server/entry.mjs"]

View file

@ -10,11 +10,12 @@ export default defineConfig({
site: "https://badblocks.dev",
trailingSlash: "never",
// bun adapter is not official, also a little wonky, so use node adapter for now
adapter: node({
mode: "standalone",
}),
// adapter: bun(),
// output: "static",
adapter: node({
mode: "standalone",
staticHeaders: true,
}),
compressHTML: false,
devToolbar: { enabled: false },
prefetch: {
@ -29,7 +30,6 @@ export default defineConfig({
}),
},
server: {
host: true,
port: 4321,
},
env: {
@ -57,7 +57,4 @@ export default defineConfig({
},
},
integrations: [alpinejs(), sitemap()],
experimental: {
chromeDevtoolsWorkspace: true,
},
});

View file

@ -6,12 +6,12 @@ services:
volumes:
- ./db:/db
environment:
ANDROID_SMS_GATEWAY_IP: ${ANDROID_SMS_GATEWAY_IP:-192.168.0.1}
ANDROID_SMS_GATEWAY_URL: ${ANDROID_SMS_GATEWAY_URL:-http://192.168.0.1:8080}
ANDROID_SMS_GATEWAY_LOGIN: ${ANDROID_SMS_GATEWAY_LOGIN:-sms}
ANDROID_SMS_GATEWAY_PASSWORD: ${ANDROID_SMS_GATEWAY_PASSWORD:-super-secret-password}
ANDROID_SMS_GATEWAY_RECIPIENT_PHONE: ${ANDROID_SMS_GATEWAY_RECIPIENT_PHONE:-555-555-1234}
OTP_SUPER_SECRET_SALT: ${OTP_SUPER_SECRET_SALT:-super-secret-salt}
ANDROID_SMS_GATEWAY_IP: ${ANDROID_SMS_GATEWAY_IP:?ANDROID_SMS_GATEWAY_IP is required}
ANDROID_SMS_GATEWAY_URL: ${ANDROID_SMS_GATEWAY_URL:? ANDROID_SMS_GATEWAY_URL is required}
ANDROID_SMS_GATEWAY_LOGIN: ${ANDROID_SMS_GATEWAY_LOGIN:? ANDROID_SMS_GATEWAY_LOGIN is required}
ANDROID_SMS_GATEWAY_PASSWORD: ${ANDROID_SMS_GATEWAY_PASSWORD:?ANDROID_SMS_GATEWAY_PASSWORD is required}
ANDROID_SMS_GATEWAY_RECIPIENT_PHONE: ${ANDROID_SMS_GATEWAY_RECIPIENT_PHONE:? ANDROID_SMS_GATEWAY_RECIPIENT_PHONE is required}
OTP_SUPER_SECRET_SALT: ${OTP_SUPER_SECRET_SALT:?OTP_SUPER_SECRET_SALT is required}
healthcheck:
test:
[

View file

@ -29,6 +29,7 @@
"iconify-icon": "^3.0.2",
"ofetch": "^1.5.1",
"otplib": "12.0.1",
"thirty-two": "^1.0.2",
"typescript": "^6.0.3",
"validator": "^13.15.35"
},

View file

@ -42,12 +42,12 @@ body {
var(--color-accent-transparent),
black 120%
);
background-attachment: fixed;
color: var(--color-fg);
column-gap: var(--gutter-large);
display: grid;
font-size: var(--pt-pica);
grid-template-rows: auto 1fr auto;
height: 100dvb;
left: 0;
overflow-x: hidden;
padding-inline: var(--page-padding-inline);

View file

@ -1,19 +1,31 @@
<!doctype html>
<!--prettier-ignore-->
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preload" href="/unscii-16.woff" as="font" crossorigin="anonymous" />
<link
rel="preload"
href="/unscii-16.woff"
as="font"
crossorigin="anonymous"
/>
<link rel="preload" href="reset.css" as="style" />
<link rel="preload" href="theme.css" as="style" />
<link rel="stylesheet" type="text/css" href="/style.css" />
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' width='100px' height='100px'><rect x='0' y='0' width='100' height='100' rx='15' ry='15' style='fill: rgb(0,0,0);'/><foreignObject width='100' height='100'><div xmlns='http://www.w3.org/1999/xhtml' style='width:100px;height:100px;line-height:100px;text-align:center;vertical-align:middle;color:transparent;text-shadow: 0 0 rgb(0 255 0);font-size:80px;'>👾</div></foreignObject></svg>"/>
<link
rel="icon"
type="image/svg+xml"
href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' width='100px' height='100px'><rect x='0' y='0' width='100' height='100' rx='15' ry='15' style='fill: rgb(0,0,0);'/><foreignObject width='100' height='100'><div xmlns='http://www.w3.org/1999/xhtml' style='width:100px;height:100px;line-height:100px;text-align:center;vertical-align:middle;color:transparent;text-shadow: 0 0 rgb(0 255 0);font-size:80px;'>👾</div></foreignObject></svg>"
/>
<meta name="generator" content={Astro.generator} />
<meta name="darkreader-lock" />
<link rel="sitemap" href="/sitemap-index.xml" />
<script is:inline src="/htmz.js"></script>
<script is:inline async src="/goat.js" data-goatcounter="https://badblocks.goatcounter.com/count"></script>
<script
is:inline
async
src="/goat.js"
data-goatcounter="https://badblocks.goatcounter.com/count"></script>
<slot name="head" />
</head>
<body>
@ -34,9 +46,16 @@
<footer>
<p>
<a href="/license">
<img src="/mit.svg" title="MIT Licensed" alt="MIT License Logo" width="24" height="24" role="img">
<img
src="/mit.svg"
title="MIT Licensed"
alt="MIT License Logo"
width="24"
height="24"
role="img"
/>
</a>
<br>
<br />
Made from scratch with BAHz: Bun, Astro, and Htmz!
</p>
</footer>

View file

@ -1,5 +1,6 @@
import { authenticator } from "otplib";
import { createHash } from "crypto";
import { createHmac } from "crypto";
import base32 from "thirty-two";
const submissionTimestamps = new Map<string, number[]>();
const otpRequestTimestamps = new Map<string, number[]>();
@ -52,9 +53,9 @@ function getUserSecret(phoneNumber: string, salt: string): string {
"Phone number and salt are required to generate a user secret.",
);
}
return createHash("sha256")
.update(phoneNumber + salt)
.digest("hex");
const digest = createHmac("sha256", salt).update(phoneNumber).digest("hex");
return base32.encode(digest).toString().replace(/=/g, "");
}
export function normalizePhone(phone: string) {

View file

@ -1,8 +0,0 @@
---
import Layout from "@layouts/BaseLayout.astro";
---
<Layout>
<title slot="head">AI Policy</title>
<Fragment slot="main"> </Fragment>
</Layout>

View file

@ -157,7 +157,12 @@ const msgValue = pickValue("msg") || (await Astro.session?.get("msg"));
{result?.error.message}
Please correct any errors and try again.
</p>
)) || <p>Use this form to shoot me a quick text!</p>}
)) || (
<p>
Inquiries, opportunities, or comments? Shoot me a quick text
here!
</p>
)}
</div>
<fieldset id="send_otp_fields" disabled={nextAction != "send_otp"}>
<label for="name">

View file

@ -2,6 +2,7 @@ import type { APIRoute } from "astro";
export const prerender = false;
export const GET: APIRoute = async () => {
// flesh out later if needed
try {
return new Response(
JSON.stringify({

8
src/thirty-two.d.ts vendored Normal file
View file

@ -0,0 +1,8 @@
declare module "thirty-two" {
interface Base32 {
encode(input: string | Buffer): Buffer;
decode(input: string | Buffer): Buffer;
}
const base32: Base32;
export = base32;
}

View file

@ -1,47 +0,0 @@
#!/bin/bash
cd $(dirname $(dirname $(realpath $0)))
# Path to the original .env file
ENV_FILE=".env"
# Path to the new .env.example file
EXAMPLE_FILE=".env.example"
# Check if the .env file exists
if [ ! -f "$ENV_FILE" ]; then
echo "The file $ENV_FILE does not exist."
exit 1
fi
# Create or empty the .env.example file
> "$EXAMPLE_FILE"
SKIP_NEXT=false
# Read each line in .env
while IFS= read -r line; do
# Skip the current line if the previous line is part of a multiline/quoted string
if [[ $SKIP_NEXT == true ]]; then
if [[ $line == *'"'* ]]; then
SKIP_NEXT=false
fi
continue
# Copy comments and empty lines verbatim
elif [[ $line == \#* ]] || [[ -z $line ]]; then
echo "$line" >> "$EXAMPLE_FILE"
continue
# Check if the line is a multiline/quoted string
elif [[ $line == *'="'* ]]; then
if [[ $line != *'"' ]]; then
SKIP_NEXT=true
fi
LINE=${line%%=*}
echo "$LINE=\"\${$LINE}\"" >> "$EXAMPLE_FILE"
# For all other lines, copy only the key (everything before the '=') if present
elif [[ $line == *'='* ]]; then
LINE=${line%%=*}
echo "$LINE=\${$LINE}" >> "$EXAMPLE_FILE"
fi
done < "$ENV_FILE"
echo ".env.example file created successfully."