nuxt-atproto 0.0.3 → 0.0.5

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/README.md CHANGED
@@ -230,20 +230,40 @@ Logs out the currently authenticated user and clears the stored session data.
230
230
 
231
231
  <br />
232
232
 
233
- ### 🔢 agent
233
+ ### ➡️ isLogged()
234
234
 
235
- Provides an object containing both a public `AtpAgent` for general access and an authenticated `Agent` to perform actions that require a logged-in user, such as posting, following, and liking.
235
+ Indicates whether the user is currently authenticated.
236
236
 
237
237
  ```ts
238
238
  const atproto = useAtproto()
239
239
 
240
- const profile = await atproto.agent.public.getProfile({actor: 'owdproject.org'})
241
- console.log(profile.data)
240
+ if (!atproto.isLogged()) {
241
+ return console.log('User is not logged in')
242
+ }
242
243
 
243
- const likedPost = await atproto.agent.account.likePost({cid, uri})
244
- console.log(likedPost.data)
244
+ console.log('User is authenticated')
245
245
  ```
246
246
 
247
+ **Returns**: Returns a boolean indicating whether the user is authenticated.
248
+
249
+ <br />
250
+
251
+ ### ➡️ getSession()
252
+
253
+ Retrieves the current session from the Nuxt application context.
254
+
255
+ ```ts
256
+ const atproto = useAtproto()
257
+
258
+ if (atproto.isLogged()) {
259
+ const session = atproto.getSession()
260
+
261
+ console.log('User is logged in', session.sub)
262
+ }
263
+ ```
264
+
265
+ **Returns**: Returns the current AT Protocol OAuth Browser session.
266
+
247
267
  <br />
248
268
 
249
269
  ## 🧩 useAgent(service?: string, fetch?: any)
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-atproto",
3
3
  "configKey": "atproto",
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "3.5.0"
@@ -4,5 +4,6 @@ export declare function useAtproto(service?: string, fetch?: any): {
4
4
  signInWithHandle: (handle?: string, options?: any) => Promise<void>;
5
5
  signOut: () => Promise<void>;
6
6
  restore: (did: string) => Promise<OAuthSession>;
7
- agent: import("@atproto/api").Agent;
7
+ isLogged: () => boolean;
8
+ getSession: () => any;
8
9
  };
@@ -1,5 +1,4 @@
1
1
  import { useRuntimeConfig, useNuxtApp } from "nuxt/app";
2
- import { useAgent } from "./useAgent.js";
3
2
  export function useAtproto(service, fetch) {
4
3
  const runtimeConfig = useRuntimeConfig();
5
4
  async function signIn(serviceEndpoint = runtimeConfig.public.atproto.serviceEndpoint.private, options = runtimeConfig.public.atproto.oauth.signInOptions) {
@@ -47,12 +46,20 @@ export function useAtproto(service, fetch) {
47
46
  console.log("User signed out");
48
47
  }
49
48
  }
50
- const agent = useAgent(service, fetch);
49
+ function isLogged() {
50
+ const { $atproto } = useNuxtApp();
51
+ return !!$atproto.session.value;
52
+ }
53
+ function getSession() {
54
+ const { $atproto } = useNuxtApp();
55
+ return $atproto.session.value;
56
+ }
51
57
  return {
52
58
  signIn,
53
59
  signInWithHandle,
54
60
  signOut,
55
61
  restore,
56
- agent
62
+ isLogged,
63
+ getSession
57
64
  };
58
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-atproto",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Interact with AT Protocol and Bluesky in your Nuxt.js application",
5
5
  "keywords": [
6
6
  "nuxt",