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
|
-
###
|
|
233
|
+
### ➡️ isLogged()
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
Indicates whether the user is currently authenticated.
|
|
236
236
|
|
|
237
237
|
```ts
|
|
238
238
|
const atproto = useAtproto()
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
console.log(
|
|
240
|
+
if (!atproto.isLogged()) {
|
|
241
|
+
return console.log('User is not logged in')
|
|
242
|
+
}
|
|
242
243
|
|
|
243
|
-
|
|
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
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
62
|
+
isLogged,
|
|
63
|
+
getSession
|
|
57
64
|
};
|
|
58
65
|
}
|