@owdproject/nuxt-module-atproto 0.0.0-stage → 4.0.0-alpha.3

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 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
- # Temporary Holding Version
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
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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).
@@ -0,0 +1,5 @@
1
+ import { NuxtModule } from '@nuxt/schema';
2
+
3
+ declare const module$1: NuxtModule<any>;
4
+
5
+ export { module$1 as default };
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "desktop-module-atproto",
3
+ "configKey": "atprotoDesktop",
4
+ "version": "4.0.0-alpha.3",
5
+ "builder": {
6
+ "@nuxt/module-builder": "1.0.3",
7
+ "unbuild": "3.6.1"
8
+ }
9
+ }
@@ -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,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _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,13 @@
1
+ export declare const useAtprotoAccountStore: import("pinia").SetupStoreDefinition<"desktop/atproto/account", {
2
+ session: import("vue").Ref<any, any>;
3
+ account: import("vue").Ref<any, any>;
4
+ handleResolver: import("vue").Ref<string, string>;
5
+ handleResolverHostname: import("vue").ComputedRef<string>;
6
+ state: {
7
+ fetching: boolean;
8
+ };
9
+ isAccountLogged: import("vue").ComputedRef<boolean>;
10
+ setAccount: (value: any | undefined) => void;
11
+ setAccountState: (key: "fetching", value: boolean) => void;
12
+ reset: () => void;
13
+ }>;
@@ -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,3 @@
1
+ export async function getAtprotoDesktopOwner(agent, did) {
2
+ return agent.getProfile({ actor: did }).then((result) => result.data);
3
+ }
@@ -0,0 +1,3 @@
1
+ export declare function routeAtprotoOS(path?: string): string;
2
+ export declare function routeBluesky(path?: string): string;
3
+ export declare function routeBlueskyProfile(handle: string): string;
@@ -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
+ }
@@ -0,0 +1,7 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module.mjs'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { default } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@owdproject/nuxt-module-atproto",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "4.0.0-alpha.3",
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": "./src/runtime/*",
24
+ "import": "./src/runtime/*"
25
+ }
26
+ },
27
+ "main": "./dist/module.mjs",
28
+ "typesVersions": {
29
+ "*": {
30
+ ".": [
31
+ "./dist/types.d.mts"
32
+ ]
33
+ }
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "nx": {
39
+ "name": "module-atproto"
40
+ },
41
+ "scripts": {
42
+ "prepack": "nuxt-module-build build",
43
+ "dev": "pnpm run dev:prepare && cd playground && pnpm exec nuxt dev",
44
+ "dev:build": "nuxt build playground",
45
+ "dev:generate": "NUXT_APP_BASE_URL=${NUXT_APP_BASE_URL:-/module-atproto/} nuxt generate playground",
46
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && cd playground && pnpm exec nuxt prepare",
47
+ "validate": "desktop validate ."
48
+ },
49
+ "dependencies": {
50
+ "@atproto/api": "^0.20.6",
51
+ "@nuxt/kit": "^4.6.2",
52
+ "nuxt-atproto": "^0.1.1",
53
+ "@owdproject/nuxt": "^4.0.0-alpha.3"
54
+ },
55
+ "devDependencies": {
56
+ "@nuxt/module-builder": "^1.0.2",
57
+ "@nuxt/schema": "^4.6.2",
58
+ "@owdproject/core": "^4.0.0-alpha.3",
59
+ "nuxt": "^4.6.2",
60
+ "typescript": "~6.0.3"
61
+ },
62
+ "peerDependencies": {
63
+ "@owdproject/core": "^4.0.0-alpha.3",
64
+ "@owdproject/nuxt": "^4.0.0-alpha.3"
65
+ },
66
+ "publishConfig": {
67
+ "access": "public",
68
+ "tag": "alpha",
69
+ "registry": "https://registry.npmjs.org/"
70
+ }
71
+ }