Skip to content

Commit f9945c0

Browse files
committed
initial commit
0 parents  commit f9945c0

24 files changed

Lines changed: 1657 additions & 0 deletions

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+\.[0-9]+\.[0-9]+'
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
# install, build, lint, fmt, test
17+
- uses: actions/checkout@v6
18+
- uses: oven-sh/setup-bun@v2
19+
- uses: actions/setup-node@v6
20+
with:
21+
node-version: 24
22+
registry-url: https://registry.npmjs.org/
23+
24+
- run: bun install --frozen-lockfile
25+
- run: bun run fmt:check
26+
- run: bun run lint
27+
- run: bun run build
28+
29+
# publish
30+
- run: npm publish --access public

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
*.tsbuildinfo

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!dist/**
3+
!package.json
4+
!README.md
5+
!LICENSE

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# AT Astro
2+
3+
An integration to build AT Protocol AppViews using Astro. This package implements the OAuth flow with Astro and exposes helpful
4+
utilities to get an authenticated ATProto client and manage sign in and sign out.
5+
6+
## Note on Port
7+
8+
By default, Astro exposes the dev server using port 3000; however, OAuth redirects require a non-localhost URL, so I recommend running Astro with `astro dev --host 127.0.0.1`.
9+
10+
## Installation
11+
12+
```bash
13+
npm i at-astro
14+
# or
15+
yarn add at-astro
16+
# or
17+
pnpm i at-astro
18+
# or
19+
bun i at-astro
20+
```
21+
22+
Then, in your `astro.config.ts`:
23+
24+
```ts
25+
// Add this import
26+
import atproto from "at-astro"
27+
28+
export default defineConfig({
29+
// Ensure site is defined
30+
site: "https://pixl.pics/",
31+
// Ensure you have an adapter set up (this example uses Cloudflare)
32+
adapter: cloudflare(),
33+
34+
integrations: [
35+
// Add this integration to your Astro config
36+
atproto({
37+
// Add the OAuth scopes your app needs to access. Typically this is your app's lexicon namespace.
38+
scopes: ["repo:com.myapp.mylexicon"],
39+
}),
40+
],
41+
})
42+
```
43+
44+
## Usage
45+
46+
### Routes
47+
48+
This package adds the following routes:
49+
- `/oauth-client-metadata.json` - OAuth2 client metadata
50+
- `/oauth/login` - OAuth2 login route
51+
- `/oauth/callback` - OAuth2 callback route
52+
- `/oauth/logout` - Sign out route
53+
54+
To add sign in, create a sign in page and add a standard HTML form that submits to `/oauth/login`:
55+
```html
56+
<form
57+
action="/oauth/login"
58+
method="post"
59+
>
60+
<label>
61+
Handle
62+
<input
63+
name="handle"
64+
placeholder="you.bsky.social"
65+
required
66+
/>
67+
</label>
68+
<button>
69+
Sign in
70+
</button>
71+
</form>
72+
```
73+
74+
Sign out is just as simple:
75+
```html
76+
<form action="/oauth/logout" method="post">
77+
<button>
78+
Sign out
79+
</button>
80+
</form>
81+
```
82+
83+
It supports GET requests as well, so an alternative would be:
84+
```html
85+
<a href="/oauth/logout">Sign out</a>
86+
```
87+
88+
### Client
89+
90+
After OAuth, you will have access to an authenticated ATProto client using the `getClient` function.

bun.lock

Lines changed: 990 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

oxfmt.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from "oxfmt"
2+
3+
export default defineConfig({
4+
semi: false,
5+
ignorePatterns: ["src/lexicons/**/*", "lexicons/**/*"],
6+
})

oxlint.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from "oxlint"
2+
3+
export default defineConfig({
4+
plugins: ["eslint", "typescript", "unicorn", "oxc"],
5+
options: {
6+
typeAware: true,
7+
typeCheck: true,
8+
},
9+
env: {
10+
builtin: true,
11+
},
12+
rules: {
13+
"typescript/switch-exhaustiveness-check": "error",
14+
},
15+
})

package.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"name": "at-astro",
3+
"version": "0.0.1",
4+
"private": false,
5+
"description": "An Astro integration for the AT Protocol. Implements authentication and content loaders for ATProto records.",
6+
"keywords": [
7+
"astro",
8+
"astro-integration",
9+
"astro-loader",
10+
"atproto",
11+
"atprotocol",
12+
"bluesky",
13+
"content-collections",
14+
"withastro"
15+
],
16+
"homepage": "https://github.com/chrisvander/at-astro",
17+
"repository": "git+https://github.com/chrisvander/at-astro.git",
18+
"type": "module",
19+
"module": "dist/index.mjs",
20+
"types": "dist/index.d.ts",
21+
"exports": {
22+
".": {
23+
"types": "./dist/index.d.mts",
24+
"default": "./dist/index.mjs"
25+
},
26+
"./auth": {
27+
"types": "./dist/auth.d.mts",
28+
"default": "./dist/auth.mjs"
29+
},
30+
"./pages/*": {
31+
"types": "./dist/pages/*.d.mts",
32+
"default": "./dist/pages/*.mjs"
33+
},
34+
"./pages/oauth/*": {
35+
"types": "./dist/pages/oauth/*.d.mts",
36+
"default": "./dist/pages/oauth/*.mjs"
37+
}
38+
},
39+
"scripts": {
40+
"build": "tsdown",
41+
"check": "tsc",
42+
"test": "bun test",
43+
"fmt": "oxfmt",
44+
"fmt:check": "oxfmt --check",
45+
"lint": "oxlint",
46+
"lint:fix": "oxlint --fix"
47+
},
48+
"dependencies": {
49+
"@atproto/jwk-webcrypto": "^0.3.4",
50+
"@atproto/oauth-client": "^0.8.3"
51+
},
52+
"devDependencies": {
53+
"@types/bun": "^1.4.0",
54+
"oxfmt": "^0.64.0",
55+
"oxlint": "^1.79.0",
56+
"oxlint-tsgolint": "^7.0.2001",
57+
"tsdown": "^0.22.14",
58+
"typescript": "^7.0.2"
59+
},
60+
"peerDependencies": {
61+
"@atproto/lex": "^0.3.6",
62+
"astro": "^7.2.4"
63+
}
64+
}

src/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./lib/atproto-client"

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import createPlugin from "./integration"
2+
3+
export type { AtAstroOptions, AtAstroConfig } from "./integration"
4+
export type { AtprotoOAuthScope } from "./types/oauth-scope"
5+
6+
export default createPlugin

0 commit comments

Comments
 (0)