@drmhse/authos-vue 0.2.7 → 0.2.8

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.
@@ -0,0 +1,47 @@
1
+ import { computed, inject } from "vue";
2
+ import { MemoryStorage, SsoClient } from "@drmhse/sso-sdk";
3
+ //#region src/types.ts
4
+ const AUTH_OS_INJECTION_KEY = Symbol("authOS");
5
+ //#endregion
6
+ //#region src/composables/useAuthOS.ts
7
+ /**
8
+ * Access the AuthOS client, state, and configuration.
9
+ *
10
+ * @example
11
+ * ```vue
12
+ * <script setup>
13
+ * import { useAuthOS } from '@drmhse/authos-vue';
14
+ *
15
+ * const { client, isAuthenticated, isLoading, options } = useAuthOS();
16
+ *
17
+ * async function handleLogout() {
18
+ * await client.auth.logout();
19
+ * }
20
+ * <\/script>
21
+ * ```
22
+ */
23
+ function useAuthOS() {
24
+ const context = inject(AUTH_OS_INJECTION_KEY);
25
+ if (!context) {
26
+ const defaultOptions = { baseURL: "http://localhost:3001" };
27
+ return {
28
+ client: new SsoClient({
29
+ baseURL: defaultOptions.baseURL,
30
+ storage: new MemoryStorage()
31
+ }),
32
+ options: defaultOptions,
33
+ isLoading: computed(() => false),
34
+ isAuthenticated: computed(() => false)
35
+ };
36
+ }
37
+ const isLoading = computed(() => context.state.isLoading);
38
+ const isAuthenticated = computed(() => context.state.isAuthenticated);
39
+ return {
40
+ client: context.client,
41
+ options: context.options,
42
+ isLoading,
43
+ isAuthenticated
44
+ };
45
+ }
46
+ //#endregion
47
+ export { AUTH_OS_INJECTION_KEY as n, useAuthOS as t };
@@ -0,0 +1,58 @@
1
+ let vue = require("vue");
2
+ let _drmhse_sso_sdk = require("@drmhse/sso-sdk");
3
+ //#region src/types.ts
4
+ const AUTH_OS_INJECTION_KEY = Symbol("authOS");
5
+ //#endregion
6
+ //#region src/composables/useAuthOS.ts
7
+ /**
8
+ * Access the AuthOS client, state, and configuration.
9
+ *
10
+ * @example
11
+ * ```vue
12
+ * <script setup>
13
+ * import { useAuthOS } from '@drmhse/authos-vue';
14
+ *
15
+ * const { client, isAuthenticated, isLoading, options } = useAuthOS();
16
+ *
17
+ * async function handleLogout() {
18
+ * await client.auth.logout();
19
+ * }
20
+ * <\/script>
21
+ * ```
22
+ */
23
+ function useAuthOS() {
24
+ const context = (0, vue.inject)(AUTH_OS_INJECTION_KEY);
25
+ if (!context) {
26
+ const defaultOptions = { baseURL: "http://localhost:3001" };
27
+ return {
28
+ client: new _drmhse_sso_sdk.SsoClient({
29
+ baseURL: defaultOptions.baseURL,
30
+ storage: new _drmhse_sso_sdk.MemoryStorage()
31
+ }),
32
+ options: defaultOptions,
33
+ isLoading: (0, vue.computed)(() => false),
34
+ isAuthenticated: (0, vue.computed)(() => false)
35
+ };
36
+ }
37
+ const isLoading = (0, vue.computed)(() => context.state.isLoading);
38
+ const isAuthenticated = (0, vue.computed)(() => context.state.isAuthenticated);
39
+ return {
40
+ client: context.client,
41
+ options: context.options,
42
+ isLoading,
43
+ isAuthenticated
44
+ };
45
+ }
46
+ //#endregion
47
+ Object.defineProperty(exports, "AUTH_OS_INJECTION_KEY", {
48
+ enumerable: true,
49
+ get: function() {
50
+ return AUTH_OS_INJECTION_KEY;
51
+ }
52
+ });
53
+ Object.defineProperty(exports, "useAuthOS", {
54
+ enumerable: true,
55
+ get: function() {
56
+ return useAuthOS;
57
+ }
58
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drmhse/authos-vue",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Vue and Nuxt adapter for AuthOS authentication",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -32,8 +32,8 @@
32
32
  "README.md"
33
33
  ],
34
34
  "scripts": {
35
- "build": "tsup",
36
- "dev": "tsup --watch",
35
+ "build": "tsdown",
36
+ "dev": "tsdown --watch",
37
37
  "typecheck": "vue-tsc --noEmit",
38
38
  "lint": "eslint src --ext .ts,.vue",
39
39
  "prepublishOnly": "npm run build"
@@ -53,9 +53,9 @@
53
53
  "vue": ">=3.4.0"
54
54
  },
55
55
  "devDependencies": {
56
+ "@nuxt/kit": "^4.4.8",
56
57
  "@types/node": "^25.0.3",
57
- "nuxt": "^3.14.0",
58
- "tsup": "^8.3.5",
58
+ "tsdown": "^0.22.2",
59
59
  "typescript": "^5.7.2",
60
60
  "vue": "^3.5.13",
61
61
  "vue-tsc": "^2.2.0"
@@ -69,6 +69,6 @@
69
69
  "access": "public"
70
70
  },
71
71
  "dependencies": {
72
- "@drmhse/sso-sdk": "^0.5.3"
72
+ "@drmhse/sso-sdk": "^0.5.4"
73
73
  }
74
74
  }