tmcw avatar

wide

Forked from maxm/wide
Public
pomdtr avatar
pomdtr
extractValInfo
Script
Extract vals infos (author, name, version) from a val url (either from esm.town or val.town ). Example usage: const {author, name} = extractValInfo(import.meta.url) Also returns a unique slug for the val: <author>/<name>
15
maxm avatar
maxm
valSession
HTTP
Val Session import { ValSession } from "https://esm.town/v/maxm/valSession"; // Generate a token from your valtown api key. const token = await ValSession.newSession(Deno.env.get("valtown")); // Other services can use it to authenticate const user = await ValSession.validate(token); Fork it, provide your own VT_SESSION_PRIVATE_KEY, and update the hardcoded public key. You can generate your own keys like so: import { crypto } from "https://deno.land/std@0.198.0/crypto/mod.ts"; // Generate a key pair for JWT signing and verification const { privateKey, publicKey } = await crypto.subtle.generateKey( { name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256", }, true, ["sign", "verify"], ); function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string { const lines = b64.match(/.{1,64}/g) || []; return `-----BEGIN ${type}-----\n${lines.join("\n")}\n-----END ${type}-----`; } const privateKeyPem = formatPEM( btoa(String.fromCharCode(...new Uint8Array(exportPrivateKey))), "PRIVATE KEY", ); const publicKeyPem = formatPEM( btoa(String.fromCharCode(...new Uint8Array(exportPublicKey))), "PUBLIC KEY", ); console.log(privateKeyPem, publicKeyPem);
3
1
Next
tmcw-wide.web.val.run
Updated: January 10, 2025