Skip to content

Commit 24cf95f

Browse files
noookatinux
andauthored
feat: add bluesky as a provider (#281)
Co-authored-by: Sébastien Chopin <[email protected]> Co-authored-by: Sébastien Chopin <[email protected]>
1 parent f9d8e13 commit 24cf95f

File tree

15 files changed

+3266
-1111
lines changed

15 files changed

+3266
-1111
lines changed

README.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ It can also be set using environment variables:
217217
- Authentik
218218
- AWS Cognito
219219
- Battle.net
220+
- Bluesky (AT Protocol)
220221
- Discord
221222
- Dropbox
222223
- Facebook
@@ -304,6 +305,28 @@ export default defineNuxtConfig({
304305
})
305306
```
306307

308+
### AT Protocol
309+
310+
Social networks that rely on AT Protocol (e.g., Bluesky) slightly differ from a regular OAuth flow.
311+
312+
To enable OAuth with AT Protocol, you need to:
313+
314+
1. Install the peer dependencies:
315+
316+
```bash
317+
npx nypm i @atproto/oauth-client-node @atproto/api
318+
```
319+
320+
2. Enable it in your `nuxt.config.ts`
321+
322+
```ts
323+
export default defineNuxtConfig({
324+
auth: {
325+
atproto: true
326+
}
327+
})
328+
```
329+
307330
### WebAuthn (passkey)
308331

309332
WebAuthn (Web Authentication) is a web standard that enhances security by replacing passwords with passkeys using public key cryptography. Users can authenticate with biometric data (like fingerprints or facial recognition) or physical devices (like USB keys), reducing the risk of phishing and password breaches. This approach offers a more secure and user-friendly authentication method, supported by major browsers and platforms.
@@ -711,26 +734,26 @@ Checkout the [`SessionConfig`](https://github.com/unjs/h3/blob/c04c458810e34eb15
711734

712735
```bash
713736
# Install dependencies
714-
npm install
737+
pnpm install
715738

716739
# Generate type stubs
717-
npm run dev:prepare
740+
pnpm run dev:prepare
718741

719742
# Develop with the playground
720-
npm run dev
743+
pnpm run dev
721744

722745
# Build the playground
723-
npm run dev:build
746+
pnpm run dev:build
724747

725748
# Run ESLint
726-
npm run lint
749+
pnpm run lint
727750

728751
# Run Vitest
729-
npm run test
730-
npm run test:watch
752+
pnpm run test
753+
pnpm run test:watch
731754

732755
# Release new version
733-
npm run release
756+
pnpm run release
734757
```
735758

736759
<!-- Badges -->

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,22 @@
5050
},
5151
"peerDependencies": {
5252
"@simplewebauthn/browser": "^11.0.0",
53-
"@simplewebauthn/server": "^11.0.0"
53+
"@simplewebauthn/server": "^11.0.0",
54+
"@atproto/oauth-client-node": "^0.2.0",
55+
"@atproto/api": "^0.13.15"
5456
},
5557
"peerDependenciesMeta": {
5658
"@simplewebauthn/browser": {
5759
"optional": true
5860
},
5961
"@simplewebauthn/server": {
6062
"optional": true
63+
},
64+
"@atproto/oauth-client-node": {
65+
"optional": true
66+
},
67+
"@atproto/api": {
68+
"optional": true
6169
}
6270
},
6371
"devDependencies": {

playground/app.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ const providers = computed(() =>
2828
disabled: Boolean(user.value?.github),
2929
icon: 'i-simple-icons-github',
3030
},
31+
{
32+
label: user.value?.bluesky || 'Bluesky',
33+
click() {
34+
const handle = prompt('Enter your Bluesky handle')
35+
if (handle) {
36+
navigateTo({
37+
path: '/auth/bluesky',
38+
query: { handle },
39+
}, {
40+
external: true,
41+
})
42+
}
43+
},
44+
disabled: Boolean(user.value?.bluesky),
45+
icon: 'i-simple-icons-bluesky',
46+
},
3147
{
3248
label: user.value?.gitlab || 'GitLab',
3349
to: '/auth/gitlab',

playground/auth.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
declare module '#auth-utils' {
22
interface User {
3+
bluesky?: string
34
webauthn?: string
45
email?: string
56
password?: string

playground/nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ export default defineNuxtConfig({
2525
},
2626
auth: {
2727
webAuthn: true,
28+
atproto: true,
2829
},
2930
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default defineOAuthBlueskyEventHandler({
2+
async onSuccess(event, { user }) {
3+
await setUserSession(event, {
4+
user: {
5+
bluesky: user.did,
6+
},
7+
loggedInAt: Date.now(),
8+
})
9+
10+
return sendRedirect(event, '/')
11+
},
12+
})

0 commit comments

Comments
 (0)