@owdproject/nuxt-module-atproto 0.0.0-stage → 4.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +129 -2
- package/dist/module.d.mts +5 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +40 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +22 -0
- package/dist/runtime/stores/storeAtprotoAccount.d.ts +1 -0
- package/dist/runtime/stores/storeAtprotoAccount.js +51 -0
- package/dist/runtime/utils/utilAtprotoDesktop.d.ts +1 -0
- package/dist/runtime/utils/utilAtprotoDesktop.js +3 -0
- package/dist/runtime/utils/utilRoute.d.ts +3 -0
- package/dist/runtime/utils/utilRoute.js +9 -0
- package/dist/types.d.mts +7 -0
- package/package.json +70 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Open Web Desktop Team ~ github.com/owdproject
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
19
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
20
|
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,130 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="160" height="160" src="https://avatars.githubusercontent.com/u/201536780?s=160&v=4" />
|
|
3
|
+
</p>
|
|
4
|
+
<h1 align="center">ATProto Module</h1>
|
|
5
|
+
<h3 align="center">
|
|
6
|
+
AT Protocol Module for Open Web Desktop.
|
|
7
|
+
</h3>
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
This module for Open Web Desktop enables AT Protocol integration, including OAuth
|
|
12
|
+
session management, account state, and desktop owner profile fetching.
|
|
13
|
+
|
|
14
|
+
It wraps [`nuxt-atproto`](https://nuxt-atproto.pages.dev/) and exposes the
|
|
15
|
+
AT Protocol composables throughout the desktop runtime.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- OAuth session management via `nuxt-atproto`
|
|
20
|
+
- Generates `client-metadata.json` in `/public` for OAuth
|
|
21
|
+
- Fetches the desktop owner's ATProto profile at build time
|
|
22
|
+
- Provides `useAtprotoAccountStore` for reactive account state
|
|
23
|
+
- Handles OAuth login / logout from the Account app
|
|
24
|
+
|
|
25
|
+
## Requirements
|
|
26
|
+
|
|
27
|
+
- `@owdproject/core` ≥ 3.4.0
|
|
28
|
+
- `nuxt-atproto` ≥ 0.1.0 (installed automatically as a dependency)
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm desktop add module-atproto
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
### 1. Configure `nuxt-atproto` in `nuxt.config.ts`
|
|
39
|
+
|
|
40
|
+
The AT Protocol OAuth client is configured via the `atproto` key in your Nuxt
|
|
41
|
+
config. This is separate from the desktop config and is required for OAuth to work:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
// nuxt.config.ts
|
|
45
|
+
export default defineNuxtConfig({
|
|
46
|
+
atproto: {
|
|
47
|
+
serviceEndpoint: {
|
|
48
|
+
private: 'https://bsky.social',
|
|
49
|
+
public: 'https://public.api.bsky.app',
|
|
50
|
+
},
|
|
51
|
+
oauth: {
|
|
52
|
+
// Set `writeClientMetadata: true` to generate /public/client-metadata.json
|
|
53
|
+
writeClientMetadata: true,
|
|
54
|
+
clientMetadata: {
|
|
55
|
+
// Leave `remote` empty to use the generated local client-metadata.json.
|
|
56
|
+
// Set it to a URL if you host the metadata file yourself.
|
|
57
|
+
remote: '',
|
|
58
|
+
local: {
|
|
59
|
+
client_id: 'https://your-desktop.example.com/client-metadata.json',
|
|
60
|
+
client_name: 'My Desktop',
|
|
61
|
+
client_uri: 'https://your-desktop.example.com',
|
|
62
|
+
logo_uri: 'https://your-desktop.example.com/favicon.ico',
|
|
63
|
+
tos_uri: 'https://your-desktop.example.com',
|
|
64
|
+
policy_uri: 'https://your-desktop.example.com',
|
|
65
|
+
redirect_uris: ['https://your-desktop.example.com'],
|
|
66
|
+
scope: 'atproto transition:generic',
|
|
67
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
68
|
+
response_types: ['code'],
|
|
69
|
+
token_endpoint_auth_method: 'none',
|
|
70
|
+
application_type: 'web',
|
|
71
|
+
dpop_bound_access_tokens: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
signInOptions: {
|
|
75
|
+
state: '',
|
|
76
|
+
prompt: 'login',
|
|
77
|
+
scope: 'atproto',
|
|
78
|
+
ui_locales: 'en',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
debug: false,
|
|
82
|
+
},
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. Configure the desktop owner in `desktop.config.ts`
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
// desktop/desktop.config.ts
|
|
90
|
+
export default defineDesktopConfig({
|
|
91
|
+
// ...
|
|
92
|
+
atprotoDesktop: {
|
|
93
|
+
owner: {
|
|
94
|
+
did: 'did:plc:your-did-here',
|
|
95
|
+
},
|
|
96
|
+
name: {
|
|
97
|
+
title: 'my',
|
|
98
|
+
affix: 'Desktop',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The `owner.profile` field is populated automatically at build time by fetching
|
|
105
|
+
the profile from the ATProto public API.
|
|
106
|
+
|
|
107
|
+
## Composables
|
|
108
|
+
|
|
109
|
+
The following composables are auto-imported from `nuxt-atproto`:
|
|
110
|
+
|
|
111
|
+
| Composable | Description |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `useAtprotoSession()` | Reactive OAuth session (`session`, `isLogged`, `status`) |
|
|
114
|
+
| `useAtprotoAuth()` | `signIn()`, `signInWithHandle()`, `signOut()`, `restore()` |
|
|
115
|
+
| `useAtprotoAgent(scope)` | Cached AT Protocol agent (`'authenticated'`, `'public'`, or a PDS URL) |
|
|
116
|
+
|
|
117
|
+
> **Legacy API** (`useAtproto()`, `useAgent()`) still works but is deprecated
|
|
118
|
+
> in `nuxt-atproto` ≥ 0.1.0. Prefer the composables above.
|
|
119
|
+
|
|
120
|
+
## Stores
|
|
121
|
+
|
|
122
|
+
| Store | Pinia id | Description |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| `useAtprotoAccountStore` | `desktop/atproto/account` | Account profile, session state, handle resolver |
|
|
125
|
+
|
|
126
|
+
The store persists `handleResolver` via `module-persistence` (if installed).
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
This module is released under the [MIT License](LICENSE).
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createResolver, installModule, addImportsDir, addPlugin } from '@nuxt/kit';
|
|
2
|
+
import { defineDesktopModule } from '@owdproject/nuxt/kit';
|
|
3
|
+
import { getAtprotoDesktopOwner } from '../dist/runtime/utils/utilAtprotoDesktop.js';
|
|
4
|
+
import { AtpAgent } from '@atproto/api';
|
|
5
|
+
|
|
6
|
+
const { resolve } = createResolver(import.meta.url);
|
|
7
|
+
const module$1 = defineDesktopModule({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "desktop-module-atproto",
|
|
10
|
+
configKey: "atprotoDesktop"
|
|
11
|
+
},
|
|
12
|
+
defaults: {
|
|
13
|
+
owner: {
|
|
14
|
+
did: "did:plc:iaf5ejdchj6nydfxmcrq5rm6"
|
|
15
|
+
},
|
|
16
|
+
name: {
|
|
17
|
+
title: "atproto",
|
|
18
|
+
affix: "OS"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
async setup(options, _nuxt) {
|
|
22
|
+
await installModule("nuxt-atproto", {});
|
|
23
|
+
const atprotoConfig = _nuxt.options.runtimeConfig.public.atproto;
|
|
24
|
+
const publicServiceEndpoint = atprotoConfig && atprotoConfig.serviceEndpoint && atprotoConfig.serviceEndpoint.public;
|
|
25
|
+
options.owner.profile = await getAtprotoDesktopOwner(
|
|
26
|
+
new AtpAgent({
|
|
27
|
+
service: publicServiceEndpoint ?? "https://public.api.bsky.app"
|
|
28
|
+
}),
|
|
29
|
+
options.owner.did
|
|
30
|
+
);
|
|
31
|
+
addImportsDir(resolve("./runtime/composables"));
|
|
32
|
+
addImportsDir(resolve("./runtime/stores"));
|
|
33
|
+
addPlugin({
|
|
34
|
+
src: resolve("./runtime/plugin"),
|
|
35
|
+
mode: "client"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useAtprotoAccountStore } from "./stores/storeAtprotoAccount.js";
|
|
2
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
+
import { useAtprotoSession, useAtprotoAgent } from "#imports";
|
|
4
|
+
export default defineNuxtPlugin({
|
|
5
|
+
name: "desktop-plugin-atproto",
|
|
6
|
+
parallel: true,
|
|
7
|
+
async setup(nuxtApp) {
|
|
8
|
+
const atprotoAccountStore = useAtprotoAccountStore();
|
|
9
|
+
nuxtApp.hook("app:mounted", async () => {
|
|
10
|
+
const { isLogged, session } = useAtprotoSession();
|
|
11
|
+
if (isLogged.value && session.value) {
|
|
12
|
+
const agent = useAtprotoAgent("public");
|
|
13
|
+
atprotoAccountStore.setAccountState("fetching", true);
|
|
14
|
+
await agent.getProfile({
|
|
15
|
+
actor: session.value.sub
|
|
16
|
+
}).then((profile) => {
|
|
17
|
+
atprotoAccountStore.setAccount(profile.data);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAtprotoAccountStore: any;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { ref, reactive, computed } from "@vue/reactivity";
|
|
3
|
+
import { useRuntimeConfig } from "nuxt/app";
|
|
4
|
+
export const useAtprotoAccountStore = defineStore(
|
|
5
|
+
"desktop/atproto/account",
|
|
6
|
+
() => {
|
|
7
|
+
const runtimeConfig = useRuntimeConfig();
|
|
8
|
+
const session = ref();
|
|
9
|
+
const account = ref();
|
|
10
|
+
const handleResolver = ref(
|
|
11
|
+
runtimeConfig.public.atproto?.serviceEndpoint?.private ?? "https://bsky.social"
|
|
12
|
+
);
|
|
13
|
+
const state = reactive({
|
|
14
|
+
fetching: false
|
|
15
|
+
});
|
|
16
|
+
const isAccountLogged = computed(() => {
|
|
17
|
+
return !!account.value;
|
|
18
|
+
});
|
|
19
|
+
const handleResolverHostname = computed(() => {
|
|
20
|
+
return new URL(handleResolver.value).hostname;
|
|
21
|
+
});
|
|
22
|
+
function setAccount(value) {
|
|
23
|
+
account.value = value;
|
|
24
|
+
state.fetching = false;
|
|
25
|
+
}
|
|
26
|
+
function setAccountState(key, value) {
|
|
27
|
+
state[key] = value;
|
|
28
|
+
}
|
|
29
|
+
function reset() {
|
|
30
|
+
session.value = void 0;
|
|
31
|
+
account.value = void 0;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
session,
|
|
35
|
+
account,
|
|
36
|
+
handleResolver,
|
|
37
|
+
handleResolverHostname,
|
|
38
|
+
state,
|
|
39
|
+
isAccountLogged,
|
|
40
|
+
setAccount,
|
|
41
|
+
setAccountState,
|
|
42
|
+
reset
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
persistedState: {
|
|
47
|
+
persist: true,
|
|
48
|
+
includePaths: ["handleResolver"]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getAtprotoDesktopOwner(agent: any, did: string): Promise<any>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function routeAtprotoOS(path) {
|
|
2
|
+
return "https://github.com/atproto-os" + path;
|
|
3
|
+
}
|
|
4
|
+
export function routeBluesky(path) {
|
|
5
|
+
return "https://bsky.app" + path;
|
|
6
|
+
}
|
|
7
|
+
export function routeBlueskyProfile(handle) {
|
|
8
|
+
return routeBluesky(`/profile/${handle}`);
|
|
9
|
+
}
|
package/dist/types.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owdproject/nuxt-module-atproto",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "4.0.0-alpha.4",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"owd-client",
|
|
6
|
+
"owd-modules"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"homepage": "https://github.com/atproto-os/module-atproto",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Open Web Desktop Team",
|
|
12
|
+
"url": "https://github.com/owdproject"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/types.d.mts",
|
|
18
|
+
"development": "./src/module.ts",
|
|
19
|
+
"import": "./dist/module.mjs",
|
|
20
|
+
"default": "./dist/module.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./runtime/*": {
|
|
23
|
+
"types": "./dist/runtime/*",
|
|
24
|
+
"import": "./dist/runtime/*",
|
|
25
|
+
"default": "./dist/runtime/*"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/module.mjs",
|
|
29
|
+
"typesVersions": {
|
|
30
|
+
"*": {
|
|
31
|
+
".": [
|
|
32
|
+
"./dist/types.d.mts"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"nx": {
|
|
40
|
+
"name": "module-atproto"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"prepack": "nuxt-module-build build",
|
|
44
|
+
"dev": "pnpm run dev:prepare && cd playground && pnpm exec nuxt dev",
|
|
45
|
+
"dev:build": "nuxt build playground",
|
|
46
|
+
"dev:generate": "NUXT_APP_BASE_URL=${NUXT_APP_BASE_URL:-/module-atproto/} nuxt generate playground",
|
|
47
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && cd playground && pnpm exec nuxt prepare",
|
|
48
|
+
"validate": "desktop validate ."
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@atproto/api": "^0.20.6",
|
|
52
|
+
"@nuxt/kit": "^4.6.2",
|
|
53
|
+
"nuxt-atproto": "^0.1.1",
|
|
54
|
+
"@owdproject/nuxt": "^4.0.0-alpha.3"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
58
|
+
"@nuxt/schema": "^4.6.2",
|
|
59
|
+
"@owdproject/core": "^4.0.0-alpha.3",
|
|
60
|
+
"nuxt": "^4.6.2",
|
|
61
|
+
"typescript": "~6.0.3"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@owdproject/core": "^4.0.0-alpha.3",
|
|
65
|
+
"@owdproject/nuxt": "^4.0.0-alpha.3"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public",
|
|
69
|
+
"tag": "alpha",
|
|
70
|
+
"registry": "https://registry.npmjs.org/"
|
|
71
|
+
}
|
|
72
|
+
}
|