more dev work
This commit is contained in:
parent
84261c9537
commit
441056cabc
12 changed files with 59 additions and 80 deletions
|
|
@ -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/dist ./dist
|
||||||
COPY --from=prerelease /usr/src/app/package.json ./
|
COPY --from=prerelease /usr/src/app/package.json ./
|
||||||
|
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
|
||||||
USER node
|
USER node
|
||||||
EXPOSE 4321
|
EXPOSE 4321
|
||||||
ENTRYPOINT ["node", "./dist/server/entry.mjs"]
|
ENTRYPOINT ["node", "./dist/server/entry.mjs"]
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,12 @@ export default defineConfig({
|
||||||
site: "https://badblocks.dev",
|
site: "https://badblocks.dev",
|
||||||
trailingSlash: "never",
|
trailingSlash: "never",
|
||||||
// bun adapter is not official, also a little wonky, so use node adapter for now
|
// bun adapter is not official, also a little wonky, so use node adapter for now
|
||||||
adapter: node({
|
|
||||||
mode: "standalone",
|
|
||||||
}),
|
|
||||||
// adapter: bun(),
|
// adapter: bun(),
|
||||||
// output: "static",
|
// output: "static",
|
||||||
|
adapter: node({
|
||||||
|
mode: "standalone",
|
||||||
|
staticHeaders: true,
|
||||||
|
}),
|
||||||
compressHTML: false,
|
compressHTML: false,
|
||||||
devToolbar: { enabled: false },
|
devToolbar: { enabled: false },
|
||||||
prefetch: {
|
prefetch: {
|
||||||
|
|
@ -29,7 +30,6 @@ export default defineConfig({
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
host: true,
|
|
||||||
port: 4321,
|
port: 4321,
|
||||||
},
|
},
|
||||||
env: {
|
env: {
|
||||||
|
|
@ -57,7 +57,4 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
integrations: [alpinejs(), sitemap()],
|
integrations: [alpinejs(), sitemap()],
|
||||||
experimental: {
|
|
||||||
chromeDevtoolsWorkspace: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
12
compose.yaml
12
compose.yaml
|
|
@ -6,12 +6,12 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./db:/db
|
- ./db:/db
|
||||||
environment:
|
environment:
|
||||||
ANDROID_SMS_GATEWAY_IP: ${ANDROID_SMS_GATEWAY_IP:-192.168.0.1}
|
ANDROID_SMS_GATEWAY_IP: ${ANDROID_SMS_GATEWAY_IP:?ANDROID_SMS_GATEWAY_IP is required}
|
||||||
ANDROID_SMS_GATEWAY_URL: ${ANDROID_SMS_GATEWAY_URL:-http://192.168.0.1:8080}
|
ANDROID_SMS_GATEWAY_URL: ${ANDROID_SMS_GATEWAY_URL:? ANDROID_SMS_GATEWAY_URL is required}
|
||||||
ANDROID_SMS_GATEWAY_LOGIN: ${ANDROID_SMS_GATEWAY_LOGIN:-sms}
|
ANDROID_SMS_GATEWAY_LOGIN: ${ANDROID_SMS_GATEWAY_LOGIN:? ANDROID_SMS_GATEWAY_LOGIN is required}
|
||||||
ANDROID_SMS_GATEWAY_PASSWORD: ${ANDROID_SMS_GATEWAY_PASSWORD:-super-secret-password}
|
ANDROID_SMS_GATEWAY_PASSWORD: ${ANDROID_SMS_GATEWAY_PASSWORD:?ANDROID_SMS_GATEWAY_PASSWORD is required}
|
||||||
ANDROID_SMS_GATEWAY_RECIPIENT_PHONE: ${ANDROID_SMS_GATEWAY_RECIPIENT_PHONE:-555-555-1234}
|
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:-super-secret-salt}
|
OTP_SUPER_SECRET_SALT: ${OTP_SUPER_SECRET_SALT:?OTP_SUPER_SECRET_SALT is required}
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
"iconify-icon": "^3.0.2",
|
"iconify-icon": "^3.0.2",
|
||||||
"ofetch": "^1.5.1",
|
"ofetch": "^1.5.1",
|
||||||
"otplib": "12.0.1",
|
"otplib": "12.0.1",
|
||||||
|
"thirty-two": "^1.0.2",
|
||||||
"typescript": "^6.0.3",
|
"typescript": "^6.0.3",
|
||||||
"validator": "^13.15.35"
|
"validator": "^13.15.35"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@ body {
|
||||||
var(--color-accent-transparent),
|
var(--color-accent-transparent),
|
||||||
black 120%
|
black 120%
|
||||||
);
|
);
|
||||||
|
background-attachment: fixed;
|
||||||
color: var(--color-fg);
|
color: var(--color-fg);
|
||||||
column-gap: var(--gutter-large);
|
column-gap: var(--gutter-large);
|
||||||
display: grid;
|
display: grid;
|
||||||
font-size: var(--pt-pica);
|
font-size: var(--pt-pica);
|
||||||
grid-template-rows: auto 1fr auto;
|
grid-template-rows: auto 1fr auto;
|
||||||
height: 100dvb;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
padding-inline: var(--page-padding-inline);
|
padding-inline: var(--page-padding-inline);
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,31 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<!--prettier-ignore-->
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<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="reset.css" as="style" />
|
||||||
<link rel="preload" href="theme.css" as="style" />
|
<link rel="preload" href="theme.css" as="style" />
|
||||||
<link rel="stylesheet" type="text/css" href="/style.css" />
|
<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="generator" content={Astro.generator} />
|
||||||
<meta name="darkreader-lock" />
|
<meta name="darkreader-lock" />
|
||||||
<link rel="sitemap" href="/sitemap-index.xml" />
|
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||||
<script is:inline src="/htmz.js"></script>
|
<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" />
|
<slot name="head" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -34,9 +46,16 @@
|
||||||
<footer>
|
<footer>
|
||||||
<p>
|
<p>
|
||||||
<a href="/license">
|
<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>
|
</a>
|
||||||
<br>
|
<br />
|
||||||
Made from scratch with BAHz: Bun, Astro, and Htmz!
|
Made from scratch with BAHz: Bun, Astro, and Htmz!
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { authenticator } from "otplib";
|
import { authenticator } from "otplib";
|
||||||
import { createHash } from "crypto";
|
import { createHmac } from "crypto";
|
||||||
|
import base32 from "thirty-two";
|
||||||
|
|
||||||
const submissionTimestamps = new Map<string, number[]>();
|
const submissionTimestamps = new Map<string, number[]>();
|
||||||
const otpRequestTimestamps = 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.",
|
"Phone number and salt are required to generate a user secret.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return createHash("sha256")
|
|
||||||
.update(phoneNumber + salt)
|
const digest = createHmac("sha256", salt).update(phoneNumber).digest("hex");
|
||||||
.digest("hex");
|
return base32.encode(digest).toString().replace(/=/g, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function normalizePhone(phone: string) {
|
export function normalizePhone(phone: string) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
---
|
|
||||||
import Layout from "@layouts/BaseLayout.astro";
|
|
||||||
---
|
|
||||||
|
|
||||||
<Layout>
|
|
||||||
<title slot="head">AI Policy</title>
|
|
||||||
<Fragment slot="main"> </Fragment>
|
|
||||||
</Layout>
|
|
||||||
|
|
@ -157,7 +157,12 @@ const msgValue = pickValue("msg") || (await Astro.session?.get("msg"));
|
||||||
{result?.error.message}
|
{result?.error.message}
|
||||||
Please correct any errors and try again.
|
Please correct any errors and try again.
|
||||||
</p>
|
</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>
|
</div>
|
||||||
<fieldset id="send_otp_fields" disabled={nextAction != "send_otp"}>
|
<fieldset id="send_otp_fields" disabled={nextAction != "send_otp"}>
|
||||||
<label for="name">
|
<label for="name">
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import type { APIRoute } from "astro";
|
||||||
export const prerender = false;
|
export const prerender = false;
|
||||||
|
|
||||||
export const GET: APIRoute = async () => {
|
export const GET: APIRoute = async () => {
|
||||||
|
// flesh out later if needed
|
||||||
try {
|
try {
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
|
|
|
||||||
8
src/thirty-two.d.ts
vendored
Normal file
8
src/thirty-two.d.ts
vendored
Normal 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;
|
||||||
|
}
|
||||||
|
|
@ -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."
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue