Avatar

pomdtr

I mainly enjoy building dev tools: - VS Code integration: https://github.com/pomdtr/valtown-vscode - CLI: https://github.com/pomdtr/vt
Joined June 14, 2023
Public vals
317
pomdtr avatar
pomdtr
cdn
HTTP
Val Town CDN If you only want to get the source of a val, you should use https://esm.town/ instead. Usage curl https://pomdtr-cdn.web.val.run/<author>/<name>.<extension>[?v=<version>] To see the code of this val, use https://pomdtr-cdn.web.val.run/pomdtr/cdn.ts Examples Fetching the val code $ curl https://pomdtr-cdn.web.val.run/pomdtr/add.tsx You can also use js , jsx and ts extension (only the content-type change, there is no transpilation). Fetching private val Pass an api token as an username $ curl "https://<token>@pomdtr-cdn.web.val.run/pomdtr/privateVal.ts" Fetching the val README $ curl https://pomdtr-cdn.web.val.run/pomdtr/add.md Getting an image $ curl https://pomdtr-cdn.web.val.run/pomdtr/add.png Fetching a specific version of a val $ curl https://pomdtr-cdn.web.val.run/pomdtr/cdn.ts?v=66 You need to be authenticated to use this method. Fetching the val metadata $ curl https://pomdtr-cdn.web.val.run/pomdtr/add.json
4
pomdtr avatar
pomdtr
valTownToSQLite
Script
Val Town To SQLite Dump all public vals to an sqlite table TODO [x] Upsert instead of insert
1
pomdtr avatar
pomdtr
inbox
Email
This val forward mails to my inbox
0
pomdtr avatar
pomdtr
email_auth_test
HTTP
An interactive, runnable TypeScript val by pomdtr
0
pomdtr avatar
pomdtr
email_auth
Script
Email Auth for Val Town ⚠️ Require a pro account (needed to send email to users) Usage Create an http server, and wrap it in the emailAuth middleware. import { emailAuth } from "https://esm.town/v/pomdtr/email_auth" import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail" export default emailAuth((req) => { return new Response(`your mail is ${req.headers.get("X-User-Email")}`); }, { verifyEmail: verifyUserEmail }); 💡 If you do not want to put your email in clear text, just move it to an env var (ex: Deno.env.get("email") ) If you want to allow anyone to access your val, just use: import { emailAuth } from "https://esm.town/v/pomdtr/email_auth" export default emailAuth((req) => { return new Response(`your mail is ${req.headers.get("X-User-Email")}`); }, { verifyEmail: (_email) => true }); Each time someone tries to access your val but is not allowed, you will get an email with: the email of the user trying to log in the name of the val the he want to access You can then just add the user to your whitelist to allow him in (and the user will not need to confirm his email again) ! TODO [ ] Add expiration for verification codes and session tokens [ ] use links instead of code for verification [ ] improve errors pages
6
pomdtr avatar
pomdtr
password_auth_example
HTTP
0
pomdtr avatar
pomdtr
password_auth
Script
Password Auth Middleware Protect your vals behind a password. Use session cookies to persist authentication. Usage import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=84"; export default passwordAuth(() => { return new Response("OK"); }, { verifyPassword: (password) => password == Deno.env.get("VAL_PASSWORD") }); If you want to use an api token to authenticate: import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=84"; import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken"; export default passwordAuth(() => { return new Response("OK"); }, { verifyPassword: verifyToken }); TODO [x] allow to authenticate using a val town token [ ] add a way to send an email to ask a password from the val owner [ ] automatically extend the session [ ] automatically remove expired sessions FAQ How to sign out ? Navigate to <your-site>/signout .
15
pomdtr avatar
pomdtr
protected_website
HTTP
An interactive, runnable TypeScript val by pomdtr
0
pomdtr avatar
pomdtr
lucia_sqlite
Script
An interactive, runnable TypeScript val by pomdtr
0
pomdtr avatar
pomdtr
basicAuthV2
Script
An interactive, runnable TypeScript val by pomdtr
0
pomdtr avatar
pomdtr
lucia_adapter
Script
Lucia Adapter for val.town Usage import { ValTownAdapter } from "https://esm.town/v/pomdtr/lucia_adapter"; import { Lucia } from "npm:lucia@3.0.1"; const adapter = new ValTownAdapter({ user: "user", session: "session", }); const lucia = new Lucia(adapter)
1
pomdtr avatar
pomdtr
lucia_adapter_base
Script
Copied from https://github.com/lucia-auth/lucia/blob/main/packages/adapter-sqlite/src/base.ts
0
pomdtr avatar
pomdtr
lucia_demo
HTTP
@jsxImportSource npm:hono/jsx
0
pomdtr avatar
pomdtr
log
HTTP
An interactive, runnable TypeScript val by pomdtr
0
pomdtr avatar
pomdtr
blob_editor
HTTP
Preview and edit blobs Usage: import blobEditor from "https://esm.town/v/pomdtr/blob_editor" export default blobEditor("article.md") You can easily protect your val behind @pomdtr/password_auth or @pomdtr/email_auth
0
pomdtr avatar
pomdtr
test
Script
An interactive, runnable TypeScript val by pomdtr
0