nuxt-atproto 0.0.4 → 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
@@ -237,17 +237,35 @@ Indicates whether the user is currently authenticated.
237
237
  ```ts
238
238
  const atproto = useAtproto()
239
239
 
240
- if (atproto.isLogged()) {
241
- console.log('User is authenticated')
242
- } else {
243
- console.log('User is not logged in')
240
+ if (!atproto.isLogged()) {
241
+ return console.log('User is not logged in')
244
242
  }
243
+
244
+ console.log('User is authenticated')
245
245
  ```
246
246
 
247
247
  **Returns**: Returns a boolean indicating whether the user is authenticated.
248
248
 
249
249
  <br />
250
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
+
267
+ <br />
268
+
251
269
  ## 🧩 useAgent(service?: string, fetch?: any)
252
270
 
253
271
  A composable provided by `nuxt-atproto` that offers methods for user authentication and session management, including authenticating, signing out and session restore.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-atproto",
3
3
  "configKey": "atproto",
4
- "version": "0.0.4",
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
- isLogged: () => any;
7
+ isLogged: () => boolean;
8
+ getSession: () => any;
8
9
  };
@@ -47,6 +47,10 @@ export function useAtproto(service, fetch) {
47
47
  }
48
48
  }
49
49
  function isLogged() {
50
+ const { $atproto } = useNuxtApp();
51
+ return !!$atproto.session.value;
52
+ }
53
+ function getSession() {
50
54
  const { $atproto } = useNuxtApp();
51
55
  return $atproto.session.value;
52
56
  }
@@ -55,6 +59,7 @@ export function useAtproto(service, fetch) {
55
59
  signInWithHandle,
56
60
  signOut,
57
61
  restore,
58
- isLogged
62
+ isLogged,
63
+ getSession
59
64
  };
60
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-atproto",
3
- "version": "0.0.4",
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",