A minimal starter for ATProto logins in Astro

chore: Remove database and iron-session

+2
.env.template
···
+
PORT=4321
+
PUBLIC_URL=
+9
astro.config.mjs
···
import { defineConfig } from "astro/config";
import tailwindcss from "@tailwindcss/vite";
+
import node from "@astrojs/node";
export default defineConfig({
+
output: "server",
+
adapter: node({
+
mode: "standalone",
+
}),
+
server: {
+
host: "127.0.0.1",
+
port: 4321,
+
},
vite: {
plugins: [tailwindcss()],
},
+528 -14
package-lock.json
···
"name": "astro-atproto-starter",
"version": "0.0.1",
"dependencies": {
+
"@astrojs/node": "^9.5.0",
"@astrojs/tailwind": "^6.0.2",
+
"@atproto/api": "^0.17.4",
+
"@atproto/oauth-client-node": "^0.3.10",
"@tailwindcss/vite": "^4.1.16",
"astro": "^5.15.1",
"daisyui": "^5.3.9",
+
"dotenv": "^17.2.3",
"tailwindcss": "^4.1.16"
}
},
···
"vfile": "^6.0.3"
}
},
+
"node_modules/@astrojs/node": {
+
"version": "9.5.0",
+
"resolved": "https://registry.npmjs.org/@astrojs/node/-/node-9.5.0.tgz",
+
"integrity": "sha512-x1whLIatmCefaqJA8FjfI+P6FStF+bqmmrib0OUGM1M3cZhAXKLgPx6UF2AzQ3JgpXgCWYM24MHtraPvZhhyLQ==",
+
"license": "MIT",
+
"dependencies": {
+
"@astrojs/internal-helpers": "0.7.4",
+
"send": "^1.2.0",
+
"server-destroy": "^1.0.1"
+
},
+
"peerDependencies": {
+
"astro": "^5.14.3"
+
}
+
},
"node_modules/@astrojs/prism": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-3.3.0.tgz",
···
},
"engines": {
"node": "18.20.8 || ^20.3.0 || >=22.0.0"
+
}
+
},
+
"node_modules/@atproto-labs/did-resolver": {
+
"version": "0.2.2",
+
"resolved": "https://registry.npmjs.org/@atproto-labs/did-resolver/-/did-resolver-0.2.2.tgz",
+
"integrity": "sha512-ca2B7xR43tVoQ8XxBvha58DXwIH8cIyKQl6lpOKGkPUrJuFoO4iCLlDiSDi2Ueh+yE1rMDPP/qveHdajgDX3WQ==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto-labs/fetch": "0.2.3",
+
"@atproto-labs/pipe": "0.1.1",
+
"@atproto-labs/simple-store": "0.3.0",
+
"@atproto-labs/simple-store-memory": "0.1.4",
+
"@atproto/did": "0.2.1",
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto-labs/fetch": {
+
"version": "0.2.3",
+
"resolved": "https://registry.npmjs.org/@atproto-labs/fetch/-/fetch-0.2.3.tgz",
+
"integrity": "sha512-NZtbJOCbxKUFRFKMpamT38PUQMY0hX0p7TG5AEYOPhZKZEP7dHZ1K2s1aB8MdVH0qxmqX7nQleNrrvLf09Zfdw==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto-labs/pipe": "0.1.1"
+
}
+
},
+
"node_modules/@atproto-labs/fetch-node": {
+
"version": "0.2.0",
+
"resolved": "https://registry.npmjs.org/@atproto-labs/fetch-node/-/fetch-node-0.2.0.tgz",
+
"integrity": "sha512-Krq09nH/aeoiU2s9xdHA0FjTEFWG9B5FFenipv1iRixCcPc7V3DhTNDawxG9gI8Ny0k4dBVS9WTRN/IDzBx86Q==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto-labs/fetch": "0.2.3",
+
"@atproto-labs/pipe": "0.1.1",
+
"ipaddr.js": "^2.1.0",
+
"undici": "^6.14.1"
+
},
+
"engines": {
+
"node": ">=18.7.0"
+
}
+
},
+
"node_modules/@atproto-labs/handle-resolver": {
+
"version": "0.3.2",
+
"resolved": "https://registry.npmjs.org/@atproto-labs/handle-resolver/-/handle-resolver-0.3.2.tgz",
+
"integrity": "sha512-KIerCzh3qb+zZoqWbIvTlvBY0XPq0r56kwViaJY/LTe/3oPO2JaqlYKS/F4dByWBhHK6YoUOJ0sWrh6PMJl40A==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto-labs/simple-store": "0.3.0",
+
"@atproto-labs/simple-store-memory": "0.1.4",
+
"@atproto/did": "0.2.1",
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto-labs/handle-resolver-node": {
+
"version": "0.1.21",
+
"resolved": "https://registry.npmjs.org/@atproto-labs/handle-resolver-node/-/handle-resolver-node-0.1.21.tgz",
+
"integrity": "sha512-fuJy5Px5pGF3lJX/ATdurbT8tbmaFWtf+PPxAQDFy7ot2no3t+iaAgymhyxYymrssOuWs6BwOP8tyF3VrfdwtQ==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto-labs/fetch-node": "0.2.0",
+
"@atproto-labs/handle-resolver": "0.3.2",
+
"@atproto/did": "0.2.1"
+
},
+
"engines": {
+
"node": ">=18.7.0"
+
}
+
},
+
"node_modules/@atproto-labs/identity-resolver": {
+
"version": "0.3.2",
+
"resolved": "https://registry.npmjs.org/@atproto-labs/identity-resolver/-/identity-resolver-0.3.2.tgz",
+
"integrity": "sha512-MYxO9pe0WsFyi5HFdKAwqIqHfiF2kBPoVhAIuH/4PYHzGr799ED47xLhNMxR3ZUYrJm5+TQzWXypGZ0Btw1Ffw==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto-labs/did-resolver": "0.2.2",
+
"@atproto-labs/handle-resolver": "0.3.2"
+
}
+
},
+
"node_modules/@atproto-labs/pipe": {
+
"version": "0.1.1",
+
"resolved": "https://registry.npmjs.org/@atproto-labs/pipe/-/pipe-0.1.1.tgz",
+
"integrity": "sha512-hdNw2oUs2B6BN1lp+32pF7cp8EMKuIN5Qok2Vvv/aOpG/3tNSJ9YkvfI0k6Zd188LeDDYRUpYpxcoFIcGH/FNg==",
+
"license": "MIT"
+
},
+
"node_modules/@atproto-labs/simple-store": {
+
"version": "0.3.0",
+
"resolved": "https://registry.npmjs.org/@atproto-labs/simple-store/-/simple-store-0.3.0.tgz",
+
"integrity": "sha512-nOb6ONKBRJHRlukW1sVawUkBqReLlLx6hT35VS3imaNPwiXDxLnTK7lxw3Lrl9k5yugSBDQAkZAq3MPTEFSUBQ==",
+
"license": "MIT"
+
},
+
"node_modules/@atproto-labs/simple-store-memory": {
+
"version": "0.1.4",
+
"resolved": "https://registry.npmjs.org/@atproto-labs/simple-store-memory/-/simple-store-memory-0.1.4.tgz",
+
"integrity": "sha512-3mKY4dP8I7yKPFj9VKpYyCRzGJOi5CEpOLPlRhoJyLmgs3J4RzDrjn323Oakjz2Aj2JzRU/AIvWRAZVhpYNJHw==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto-labs/simple-store": "0.3.0",
+
"lru-cache": "^10.2.0"
+
}
+
},
+
"node_modules/@atproto/api": {
+
"version": "0.17.4",
+
"resolved": "https://registry.npmjs.org/@atproto/api/-/api-0.17.4.tgz",
+
"integrity": "sha512-MRa0WdxyDiGF7fVKd/2ldvonsHQjsaLUOGw/PHrZ7J01lqlw/jaXLS25FNNYzjPGmGpnIyDCIg4Uucd/OblI9w==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto/common-web": "^0.4.3",
+
"@atproto/lexicon": "^0.5.1",
+
"@atproto/syntax": "^0.4.1",
+
"@atproto/xrpc": "^0.7.5",
+
"await-lock": "^2.2.2",
+
"multiformats": "^9.9.0",
+
"tlds": "^1.234.0",
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto/common-web": {
+
"version": "0.4.3",
+
"resolved": "https://registry.npmjs.org/@atproto/common-web/-/common-web-0.4.3.tgz",
+
"integrity": "sha512-nRDINmSe4VycJzPo6fP/hEltBcULFxt9Kw7fQk6405FyAWZiTluYHlXOnU7GkQfeUK44OENG1qFTBcmCJ7e8pg==",
+
"license": "MIT",
+
"dependencies": {
+
"graphemer": "^1.4.0",
+
"multiformats": "^9.9.0",
+
"uint8arrays": "3.0.0",
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto/did": {
+
"version": "0.2.1",
+
"resolved": "https://registry.npmjs.org/@atproto/did/-/did-0.2.1.tgz",
+
"integrity": "sha512-1i5BTU2GnBaaeYWhxUOnuEKFVq9euT5+dQPFabHpa927BlJ54PmLGyBBaOI7/NbLmN5HWwBa18SBkMpg3jGZRA==",
+
"license": "MIT",
+
"dependencies": {
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto/jwk": {
+
"version": "0.6.0",
+
"resolved": "https://registry.npmjs.org/@atproto/jwk/-/jwk-0.6.0.tgz",
+
"integrity": "sha512-bDoJPvt7TrQVi/rBfBrSSpGykhtIriKxeYCYQTiPRKFfyRhbgpElF0wPXADjIswnbzZdOwbY63az4E/CFVT3Tw==",
+
"license": "MIT",
+
"dependencies": {
+
"multiformats": "^9.9.0",
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto/jwk-jose": {
+
"version": "0.1.11",
+
"resolved": "https://registry.npmjs.org/@atproto/jwk-jose/-/jwk-jose-0.1.11.tgz",
+
"integrity": "sha512-i4Fnr2sTBYmMmHXl7NJh8GrCH+tDQEVWrcDMDnV5DjJfkgT17wIqvojIw9SNbSL4Uf0OtfEv6AgG0A+mgh8b5Q==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto/jwk": "0.6.0",
+
"jose": "^5.2.0"
+
}
+
},
+
"node_modules/@atproto/jwk-webcrypto": {
+
"version": "0.2.0",
+
"resolved": "https://registry.npmjs.org/@atproto/jwk-webcrypto/-/jwk-webcrypto-0.2.0.tgz",
+
"integrity": "sha512-UmgRrrEAkWvxwhlwe30UmDOdTEFidlIzBC7C3cCbeJMcBN1x8B3KH+crXrsTqfWQBG58mXgt8wgSK3Kxs2LhFg==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto/jwk": "0.6.0",
+
"@atproto/jwk-jose": "0.1.11",
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto/lexicon": {
+
"version": "0.5.1",
+
"resolved": "https://registry.npmjs.org/@atproto/lexicon/-/lexicon-0.5.1.tgz",
+
"integrity": "sha512-y8AEtYmfgVl4fqFxqXAeGvhesiGkxiy3CWoJIfsFDDdTlZUC8DFnZrYhcqkIop3OlCkkljvpSJi1hbeC1tbi8A==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto/common-web": "^0.4.3",
+
"@atproto/syntax": "^0.4.1",
+
"iso-datestring-validator": "^2.2.2",
+
"multiformats": "^9.9.0",
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto/oauth-client": {
+
"version": "0.5.8",
+
"resolved": "https://registry.npmjs.org/@atproto/oauth-client/-/oauth-client-0.5.8.tgz",
+
"integrity": "sha512-7YEym6d97+Dd73qGdkQTXi5La8xvCQxwRUDzzlR/NVAARa9a4YP7MCmqBJVeP2anT0By+DSAPyPDLTsxcjIcCg==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto-labs/did-resolver": "0.2.2",
+
"@atproto-labs/fetch": "0.2.3",
+
"@atproto-labs/handle-resolver": "0.3.2",
+
"@atproto-labs/identity-resolver": "0.3.2",
+
"@atproto-labs/simple-store": "0.3.0",
+
"@atproto-labs/simple-store-memory": "0.1.4",
+
"@atproto/did": "0.2.1",
+
"@atproto/jwk": "0.6.0",
+
"@atproto/oauth-types": "0.5.0",
+
"@atproto/xrpc": "0.7.5",
+
"core-js": "^3",
+
"multiformats": "^9.9.0",
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto/oauth-client-node": {
+
"version": "0.3.10",
+
"resolved": "https://registry.npmjs.org/@atproto/oauth-client-node/-/oauth-client-node-0.3.10.tgz",
+
"integrity": "sha512-6khKlJqu1Ed5rt3rzcTD5hymB6JUjKdOHWYXwiphw4inkAIo6GxLCighI4eGOqZorYk2j8ueeTNB6KsgH0kcRw==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto-labs/did-resolver": "0.2.2",
+
"@atproto-labs/handle-resolver-node": "0.1.21",
+
"@atproto-labs/simple-store": "0.3.0",
+
"@atproto/did": "0.2.1",
+
"@atproto/jwk": "0.6.0",
+
"@atproto/jwk-jose": "0.1.11",
+
"@atproto/jwk-webcrypto": "0.2.0",
+
"@atproto/oauth-client": "0.5.8",
+
"@atproto/oauth-types": "0.5.0"
+
},
+
"engines": {
+
"node": ">=18.7.0"
+
}
+
},
+
"node_modules/@atproto/oauth-types": {
+
"version": "0.5.0",
+
"resolved": "https://registry.npmjs.org/@atproto/oauth-types/-/oauth-types-0.5.0.tgz",
+
"integrity": "sha512-33xz7HcXhbl+XRqbIMVu3GE02iK1nKe2oMWENASsfZEYbCz2b9ZOarOFuwi7g4LKqpGowGp0iRKsQHFcq4SDaQ==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto/did": "0.2.1",
+
"@atproto/jwk": "0.6.0",
+
"zod": "^3.23.8"
+
}
+
},
+
"node_modules/@atproto/syntax": {
+
"version": "0.4.1",
+
"resolved": "https://registry.npmjs.org/@atproto/syntax/-/syntax-0.4.1.tgz",
+
"integrity": "sha512-CJdImtLAiFO+0z3BWTtxwk6aY5w4t8orHTMVJgkf++QRJWTxPbIFko/0hrkADB7n2EruDxDSeAgfUGehpH6ngw==",
+
"license": "MIT"
+
},
+
"node_modules/@atproto/xrpc": {
+
"version": "0.7.5",
+
"resolved": "https://registry.npmjs.org/@atproto/xrpc/-/xrpc-0.7.5.tgz",
+
"integrity": "sha512-MUYNn5d2hv8yVegRL0ccHvTHAVj5JSnW07bkbiaz96UH45lvYNRVwt44z+yYVnb0/mvBzyD3/ZQ55TRGt7fHkA==",
+
"license": "MIT",
+
"dependencies": {
+
"@atproto/lexicon": "^0.5.1",
+
"zod": "^3.23.8"
}
},
"node_modules/@babel/helper-string-parser": {
···
"postcss": "^8.1.0"
},
+
"node_modules/await-lock": {
+
"version": "2.2.2",
+
"resolved": "https://registry.npmjs.org/await-lock/-/await-lock-2.2.2.tgz",
+
"integrity": "sha512-aDczADvlvTGajTDjcjpJMqRkOF6Qdz3YbPZm/PyW6tKPkx2hlYBzxMhEywM/tU72HrVZjgl5VCdRuMlA7pZ8Gw==",
+
"license": "MIT"
+
},
"node_modules/axobject-query": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",
···
"integrity": "sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg==",
"license": "MIT"
},
+
"node_modules/core-js": {
+
"version": "3.46.0",
+
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.46.0.tgz",
+
"integrity": "sha512-vDMm9B0xnqqZ8uSBpZ8sNtRtOdmfShrvT6h2TuQGLs0Is+cR0DYbj/KWP6ALVNbWPpqA/qPLoOuppJN07humpA==",
+
"hasInstallScript": true,
+
"license": "MIT",
+
"funding": {
+
"type": "opencollective",
+
"url": "https://opencollective.com/core-js"
+
}
+
},
"node_modules/crossws": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/crossws/-/crossws-0.3.5.tgz",
···
"integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==",
"license": "MIT"
},
+
"node_modules/depd": {
+
"version": "2.0.0",
+
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
+
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
+
"license": "MIT",
+
"engines": {
+
"node": ">= 0.8"
+
}
+
},
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
···
"integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==",
"license": "MIT"
},
+
"node_modules/dotenv": {
+
"version": "17.2.3",
+
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz",
+
"integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==",
+
"license": "BSD-2-Clause",
+
"engines": {
+
"node": ">=12"
+
},
+
"funding": {
+
"url": "https://dotenvx.com"
+
}
+
},
"node_modules/dset": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/dset/-/dset-3.1.4.tgz",
···
"node": ">=4"
},
+
"node_modules/ee-first": {
+
"version": "1.1.1",
+
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
+
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
+
"license": "MIT"
+
},
"node_modules/electron-to-chromium": {
"version": "1.5.240",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.240.tgz",
···
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
"license": "MIT"
+
},
+
"node_modules/encodeurl": {
+
"version": "2.0.0",
+
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
+
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
+
"license": "MIT",
+
"engines": {
+
"node": ">= 0.8"
+
}
},
"node_modules/enhanced-resolve": {
"version": "5.18.3",
···
"node": ">=6"
},
+
"node_modules/escape-html": {
+
"version": "1.0.3",
+
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
+
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
+
"license": "MIT"
+
},
"node_modules/escape-string-regexp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
···
"license": "MIT",
"dependencies": {
"@types/estree": "^1.0.0"
+
}
+
},
+
"node_modules/etag": {
+
"version": "1.8.1",
+
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
+
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
+
"license": "MIT",
+
"engines": {
+
"node": ">= 0.6"
},
"node_modules/eventemitter3": {
···
"url": "https://github.com/sponsors/rawify"
},
+
"node_modules/fresh": {
+
"version": "2.0.0",
+
"resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
+
"integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",
+
"license": "MIT",
+
"engines": {
+
"node": ">= 0.8"
+
}
+
},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
···
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"license": "ISC"
+
},
+
"node_modules/graphemer": {
+
"version": "1.4.0",
+
"resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",
+
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
+
"license": "MIT"
},
"node_modules/h3": {
"version": "1.15.4",
···
"integrity": "sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ==",
"license": "BSD-2-Clause"
},
+
"node_modules/http-errors": {
+
"version": "2.0.0",
+
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
+
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
+
"license": "MIT",
+
"dependencies": {
+
"depd": "2.0.0",
+
"inherits": "2.0.4",
+
"setprototypeof": "1.2.0",
+
"statuses": "2.0.1",
+
"toidentifier": "1.0.1"
+
},
+
"engines": {
+
"node": ">= 0.8"
+
}
+
},
+
"node_modules/http-errors/node_modules/statuses": {
+
"version": "2.0.1",
+
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
+
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
+
"license": "MIT",
+
"engines": {
+
"node": ">= 0.8"
+
}
+
},
"node_modules/import-meta-resolve": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.2.0.tgz",
···
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
+
}
+
},
+
"node_modules/inherits": {
+
"version": "2.0.4",
+
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+
"license": "ISC"
+
},
+
"node_modules/ipaddr.js": {
+
"version": "2.2.0",
+
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz",
+
"integrity": "sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA==",
+
"license": "MIT",
+
"engines": {
+
"node": ">= 10"
},
"node_modules/iron-webcrypto": {
···
"url": "https://github.com/sponsors/sindresorhus"
},
+
"node_modules/iso-datestring-validator": {
+
"version": "2.2.2",
+
"resolved": "https://registry.npmjs.org/iso-datestring-validator/-/iso-datestring-validator-2.2.2.tgz",
+
"integrity": "sha512-yLEMkBbLZTlVQqOnQ4FiMujR6T4DEcCb1xizmvXS+OxuhwcbtynoosRzdMA69zZCShCNAbi+gJ71FxZBBXx1SA==",
+
"license": "MIT"
+
},
"node_modules/jiti": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.1.tgz",
···
"license": "MIT",
"bin": {
"jiti": "lib/jiti-cli.mjs"
+
}
+
},
+
"node_modules/jose": {
+
"version": "5.10.0",
+
"resolved": "https://registry.npmjs.org/jose/-/jose-5.10.0.tgz",
+
"integrity": "sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg==",
+
"license": "MIT",
+
"funding": {
+
"url": "https://github.com/sponsors/panva"
},
"node_modules/js-yaml": {
···
],
"license": "MIT"
},
+
"node_modules/mime-db": {
+
"version": "1.54.0",
+
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
+
"integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",
+
"license": "MIT",
+
"engines": {
+
"node": ">= 0.6"
+
}
+
},
+
"node_modules/mime-types": {
+
"version": "3.0.1",
+
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz",
+
"integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==",
+
"license": "MIT",
+
"dependencies": {
+
"mime-db": "^1.54.0"
+
},
+
"engines": {
+
"node": ">= 0.6"
+
}
+
},
"node_modules/mrmime": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz",
···
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
+
},
+
"node_modules/multiformats": {
+
"version": "9.9.0",
+
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-9.9.0.tgz",
+
"integrity": "sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==",
+
"license": "(Apache-2.0 AND MIT)"
},
"node_modules/nanoid": {
"version": "3.3.11",
···
"resolved": "https://registry.npmjs.org/ohash/-/ohash-2.0.11.tgz",
"integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==",
"license": "MIT"
+
},
+
"node_modules/on-finished": {
+
"version": "2.4.1",
+
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
+
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
+
"license": "MIT",
+
"dependencies": {
+
"ee-first": "1.1.1"
+
},
+
"engines": {
+
"node": ">= 0.8"
+
}
},
"node_modules/oniguruma-parser": {
"version": "0.12.1",
···
"integrity": "sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==",
"license": "MIT"
},
+
"node_modules/range-parser": {
+
"version": "1.2.1",
+
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
+
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
+
"license": "MIT",
+
"engines": {
+
"node": ">= 0.6"
+
}
+
},
"node_modules/readdirp": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
···
"node": ">=10"
},
+
"node_modules/send": {
+
"version": "1.2.0",
+
"resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz",
+
"integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==",
+
"license": "MIT",
+
"dependencies": {
+
"debug": "^4.3.5",
+
"encodeurl": "^2.0.0",
+
"escape-html": "^1.0.3",
+
"etag": "^1.8.1",
+
"fresh": "^2.0.0",
+
"http-errors": "^2.0.0",
+
"mime-types": "^3.0.1",
+
"ms": "^2.1.3",
+
"on-finished": "^2.4.1",
+
"range-parser": "^1.2.1",
+
"statuses": "^2.0.1"
+
},
+
"engines": {
+
"node": ">= 18"
+
}
+
},
+
"node_modules/server-destroy": {
+
"version": "1.0.1",
+
"resolved": "https://registry.npmjs.org/server-destroy/-/server-destroy-1.0.1.tgz",
+
"integrity": "sha512-rb+9B5YBIEzYcD6x2VKidaa+cqYBJQKnU4oe4E3ANwRRN56yk/ua1YCJT1n21NTS8w6CcOclAKNP3PhdCXKYtQ==",
+
"license": "ISC"
+
},
+
"node_modules/setprototypeof": {
+
"version": "1.2.0",
+
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
+
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
+
"license": "ISC"
+
},
"node_modules/sharp": {
"version": "0.34.4",
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.4.tgz",
···
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
+
}
+
},
+
"node_modules/statuses": {
+
"version": "2.0.2",
+
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
+
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
+
"license": "MIT",
+
"engines": {
+
"node": ">= 0.8"
},
"node_modules/string-width": {
···
"url": "https://github.com/sponsors/SuperchupuDev"
},
+
"node_modules/tlds": {
+
"version": "1.261.0",
+
"resolved": "https://registry.npmjs.org/tlds/-/tlds-1.261.0.tgz",
+
"integrity": "sha512-QXqwfEl9ddlGBaRFXIvNKK6OhipSiLXuRuLJX5DErz0o0Q0rYxulWLdFryTkV5PkdZct5iMInwYEGe/eR++1AA==",
+
"license": "MIT",
+
"bin": {
+
"tlds": "bin.js"
+
}
+
},
+
"node_modules/toidentifier": {
+
"version": "1.0.1",
+
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
+
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
+
"license": "MIT",
+
"engines": {
+
"node": ">=0.6"
+
}
+
},
"node_modules/trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",
···
"url": "https://github.com/sponsors/sindresorhus"
},
-
"node_modules/typescript": {
-
"version": "5.9.3",
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
-
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
-
"license": "Apache-2.0",
-
"peer": true,
-
"bin": {
-
"tsc": "bin/tsc",
-
"tsserver": "bin/tsserver"
-
},
-
"engines": {
-
"node": ">=14.17"
-
}
-
},
"node_modules/ufo": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.1.tgz",
"integrity": "sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==",
"license": "MIT"
},
+
"node_modules/uint8arrays": {
+
"version": "3.0.0",
+
"resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.0.0.tgz",
+
"integrity": "sha512-HRCx0q6O9Bfbp+HHSfQQKD7wU70+lydKVt4EghkdOvlK/NlrF90z+eXV34mUd48rNvVJXwkrMSPpCATkct8fJA==",
+
"license": "MIT",
+
"dependencies": {
+
"multiformats": "^9.4.2"
+
}
+
},
"node_modules/ultrahtml": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/ultrahtml/-/ultrahtml-1.6.0.tgz",
···
"resolved": "https://registry.npmjs.org/uncrypto/-/uncrypto-0.1.3.tgz",
"integrity": "sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==",
"license": "MIT"
+
},
+
"node_modules/undici": {
+
"version": "6.22.0",
+
"resolved": "https://registry.npmjs.org/undici/-/undici-6.22.0.tgz",
+
"integrity": "sha512-hU/10obOIu62MGYjdskASR3CUAiYaFTtC9Pa6vHyf//mAipSvSQg6od2CnJswq7fvzNS3zJhxoRkgNVaHurWKw==",
+
"license": "MIT",
+
"engines": {
+
"node": ">=18.17"
+
}
},
"node_modules/undici-types": {
"version": "7.16.0",
+4
package.json
···
"astro": "astro"
},
"dependencies": {
+
"@astrojs/node": "^9.5.0",
"@astrojs/tailwind": "^6.0.2",
+
"@atproto/api": "^0.17.4",
+
"@atproto/oauth-client-node": "^0.3.10",
"@tailwindcss/vite": "^4.1.16",
"astro": "^5.15.1",
"daisyui": "^5.3.9",
+
"dotenv": "^17.2.3",
"tailwindcss": "^4.1.16"
}
}
+17
src/lib/context.ts
···
+
import { NodeOAuthClient } from '@atproto/oauth-client-node'
+
import { createOAuthClient } from './oauth'
+
+
export type AppContext = {
+
oauthClient: NodeOAuthClient
+
}
+
+
let _ctx: AppContext | null = null
+
+
export async function getAppContext(): Promise<AppContext> {
+
if (_ctx) return _ctx
+
+
const oauthClient = await createOAuthClient()
+
+
_ctx = { oauthClient }
+
return _ctx
+
}
+4
src/lib/env.ts
···
+
export const env = {
+
PORT: Number(process.env.PORT) || 4321,
+
PUBLIC_URL: process.env.PUBLIC_URL || undefined,
+
}
+21
src/lib/oauth.ts
···
+
import {
+
atprotoLoopbackClientMetadata,
+
NodeOAuthClient,
+
} from "@atproto/oauth-client-node";
+
import { env } from "./env";
+
import { SessionStore, StateStore } from "./storage";
+
+
export async function createOAuthClient() {
+
const clientMetadata = atprotoLoopbackClientMetadata(
+
`http://localhost?${new URLSearchParams([
+
["redirect_uri", `http://127.0.0.1:${env.PORT}/api/oauth/callback`],
+
["scope", `atproto transition:generic`],
+
])}`,
+
);
+
+
return new NodeOAuthClient({
+
clientMetadata,
+
stateStore: new StateStore(),
+
sessionStore: new SessionStore(),
+
});
+
}
+61
src/lib/session.ts
···
+
import type { AstroCookies } from 'astro'
+
+
export type SessionData = { did?: string }
+
+
const COOKIE_NAME = 'sid'
+
+
// Simple cookie-based session using Web Crypto API
+
export class Session {
+
private data: SessionData = {}
+
private cookies: AstroCookies
+
+
constructor(cookies: AstroCookies, data: SessionData = {}) {
+
this.cookies = cookies
+
this.data = data
+
}
+
+
get did() {
+
return this.data.did
+
}
+
+
set did(value: string | undefined) {
+
this.data.did = value
+
}
+
+
async save() {
+
const jsonData = JSON.stringify(this.data)
+
// For simplicity, we'll just base64 encode the data
+
// In production, you'd want proper encryption
+
const encoded = btoa(jsonData)
+
+
this.cookies.set(COOKIE_NAME, encoded, {
+
httpOnly: true,
+
secure: false,
+
sameSite: 'lax',
+
path: '/',
+
maxAge: 60 * 60 * 24 * 30, // 30 days
+
})
+
}
+
+
destroy() {
+
this.data = {}
+
this.cookies.delete(COOKIE_NAME, { path: '/' })
+
}
+
}
+
+
export function getSession(cookies: AstroCookies): Session {
+
const cookie = cookies.get(COOKIE_NAME)
+
+
if (!cookie?.value) {
+
return new Session(cookies)
+
}
+
+
try {
+
const decoded = atob(cookie.value)
+
const data = JSON.parse(decoded) as SessionData
+
return new Session(cookies, data)
+
} catch (err) {
+
console.warn('Failed to decode session:', err)
+
return new Session(cookies)
+
}
+
}
+41
src/lib/storage.ts
···
+
import type {
+
NodeSavedSession,
+
NodeSavedSessionStore,
+
NodeSavedState,
+
NodeSavedStateStore,
+
} from '@atproto/oauth-client-node'
+
+
// In-memory storage for OAuth state and sessions
+
// For production, you'd want to use a proper database or distributed cache
+
+
export class StateStore implements NodeSavedStateStore {
+
private store = new Map<string, NodeSavedState>()
+
+
async get(key: string): Promise<NodeSavedState | undefined> {
+
return this.store.get(key)
+
}
+
+
async set(key: string, val: NodeSavedState) {
+
this.store.set(key, val)
+
}
+
+
async del(key: string) {
+
this.store.delete(key)
+
}
+
}
+
+
export class SessionStore implements NodeSavedSessionStore {
+
private store = new Map<string, NodeSavedSession>()
+
+
async get(key: string): Promise<NodeSavedSession | undefined> {
+
return this.store.get(key)
+
}
+
+
async set(key: string, val: NodeSavedSession) {
+
this.store.set(key, val)
+
}
+
+
async del(key: string) {
+
this.store.delete(key)
+
}
+
}
+24
src/pages/api/login.ts
···
+
import type { APIRoute } from 'astro'
+
import { getAppContext } from '../../lib/context'
+
+
export const POST: APIRoute = async ({ request, redirect }) => {
+
try {
+
const ctx = await getAppContext()
+
const formData = await request.formData()
+
const handle = formData.get('handle')
+
+
if (!handle || typeof handle !== 'string') {
+
return new Response('Invalid handle', { status: 400 })
+
}
+
+
const url = await ctx.oauthClient.authorize(handle, {
+
scope: 'atproto transition:generic',
+
})
+
+
return redirect(url.toString())
+
} catch (err) {
+
console.error('OAuth authorize failed:', err)
+
const error = err instanceof Error ? err.message : 'unexpected error'
+
return new Response(`Login failed: ${error}`, { status: 500 })
+
}
+
}
+26
src/pages/api/logout.ts
···
+
import type { APIRoute } from 'astro'
+
import { getAppContext } from '../../lib/context'
+
import { getSession } from '../../lib/session'
+
+
export const POST: APIRoute = async (context) => {
+
try {
+
const ctx = await getAppContext()
+
const session = getSession(context.cookies)
+
+
if (session.did) {
+
try {
+
const oauthSession = await ctx.oauthClient.restore(session.did)
+
if (oauthSession) await oauthSession.signOut()
+
} catch (err) {
+
console.warn('Failed to revoke credentials:', err)
+
}
+
}
+
+
session.destroy()
+
+
return context.redirect('/')
+
} catch (err) {
+
console.error('Logout failed:', err)
+
return new Response('Logout failed', { status: 500 })
+
}
+
}
+31
src/pages/api/oauth/callback.ts
···
+
import type { APIRoute } from 'astro'
+
import { getAppContext } from '../../../lib/context'
+
import { getSession } from '../../../lib/session'
+
+
export const GET: APIRoute = async (context) => {
+
try {
+
const ctx = await getAppContext()
+
const url = new URL(context.request.url)
+
const params = new URLSearchParams(url.search)
+
+
const session = getSession(context.cookies)
+
+
if (session.did) {
+
try {
+
const oauthSession = await ctx.oauthClient.restore(session.did)
+
if (oauthSession) await oauthSession.signOut()
+
} catch (err) {
+
console.warn('OAuth restore failed during callback:', err)
+
}
+
}
+
+
const oauth = await ctx.oauthClient.callback(params)
+
session.did = oauth.session.did
+
await session.save()
+
+
return context.redirect('/')
+
} catch (err) {
+
console.error('OAuth callback failed:', err)
+
return context.redirect('/?error=login_failed')
+
}
+
}
+74 -14
src/pages/index.astro
···
---
import "../styles.css";
+
import { getSession } from "../lib/session";
+
import { getAppContext } from "../lib/context";
+
import { Agent } from "@atproto/api";
+
+
const session = getSession(Astro.cookies);
+
const ctx = await getAppContext();
+
+
let agent: Agent | null = null;
+
let profile: any = null;
+
+
if (session.did) {
+
try {
+
const oauthSession = await ctx.oauthClient.restore(session.did);
+
if (oauthSession) {
+
agent = new Agent(oauthSession);
+
+
try {
+
const profileResponse = await agent.com.atproto.repo.getRecord({
+
repo: agent.assertDid,
+
collection: "app.bsky.actor.profile",
+
rkey: "self",
+
});
+
profile = profileResponse.data;
+
} catch (err) {
+
console.warn("Failed to fetch profile:", err);
+
}
+
}
+
} catch (err) {
+
console.warn("OAuth restore failed:", err);
+
session.destroy();
+
}
+
}
+
+
const displayName = profile?.value?.displayName || agent?.assertDid || "User";
+
const handle = agent?.assertDid || "";
---
<html lang="en" data-theme="dracula">
···
<div class="min-h-screen flex items-center justify-center">
<div class="card w-96 bg-base-100 shadow-xl">
<div class="card-body">
-
<h2 class="card-title justify-center mb-6">Login</h2>
-
<form>
-
<div class="join join-vertical w-full">
-
<input
-
type="text"
-
placeholder="Username"
-
class="input input-bordered join-item"
-
name="username"
-
/>
-
<button type="submit" class="btn btn-primary join-item">
-
Login
-
</button>
-
</div>
-
</form>
+
{
+
agent ? (
+
<>
+
<h2 class="card-title justify-center mb-4">Welcome!</h2>
+
<div class="space-y-4">
+
<div class="text-center">
+
<p class="text-lg font-semibold">{displayName}</p>
+
<p class="text-sm opacity-70">{handle}</p>
+
</div>
+
<form method="POST" action="/api/logout" class="w-full">
+
<button type="submit" class="btn btn-error w-full">
+
Logout
+
</button>
+
</form>
+
</div>
+
</>
+
) : (
+
<>
+
<h2 class="card-title justify-center mb-6">ATProto Login</h2>
+
<form method="POST" action="/api/login">
+
<div class="join join-vertical w-full">
+
<input
+
type="text"
+
placeholder="Enter your handle (e.g. alice.bsky.social)"
+
class="input input-bordered join-item"
+
name="handle"
+
required
+
/>
+
<button
+
type="submit"
+
class="btn btn-primary btn-wide join-item"
+
>
+
Login
+
</button>
+
</div>
+
</form>
+
</>
+
)
+
}
</div>
</div>
</div>