@drmhse/authos-vue 0.2.6 → 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.
- package/dist/index.d.mts +565 -524
- package/dist/index.d.ts +565 -524
- package/dist/index.js +1285 -1198
- package/dist/index.mjs +1262 -1155
- package/dist/nuxt.d.mts +29 -29
- package/dist/nuxt.d.ts +29 -29
- package/dist/nuxt.js +57 -11354
- package/dist/nuxt.mjs +55 -10080
- package/dist/useAuthOS-DEOIm_-6.mjs +47 -0
- package/dist/useAuthOS-PBWjiXpo.js +58 -0
- package/package.json +6 -6
- package/dist/chokidar-B7NTEAA6.mjs +0 -1730
- package/dist/chunk-5OCDR7QV.mjs +0 -68
- package/dist/chunk-6DZX6EAA.mjs +0 -33
- package/dist/chunk-CD2MZG7D.mjs +0 -103
- package/dist/chunk-I3MWU7CX.mjs +0 -405
- package/dist/chunk-IUIUWQYL.mjs +0 -700
- package/dist/chunk-IYGVWWRW.mjs +0 -448
- package/dist/chunk-JN6U6SKP.mjs +0 -973
- package/dist/chunk-T7GBCGRZ.mjs +0 -734
- package/dist/chunk-VVJVQ4JO.mjs +0 -15
- package/dist/chunk-YED35B36.mjs +0 -33
- package/dist/chunk-ZHH4WLMR.mjs +0 -18
- package/dist/dist-N5W7B4HY.mjs +0 -3
- package/dist/dist-XLLRDJPJ.mjs +0 -505
- package/dist/json5-XBNSJCDA.mjs +0 -3
- package/dist/jsonc-H6LEPRFY.mjs +0 -3
- package/dist/nypm-5BYDGLH7.mjs +0 -3
- package/dist/prompt-WWTBWNTY.mjs +0 -751
- package/dist/tar-A5SPYDDD.mjs +0 -3289
- package/dist/toml-QZCHCWUM.mjs +0 -3
- package/dist/utils-YSWQHENC.mjs +0 -94
- package/dist/yaml-6OXYI3W7.mjs +0 -3
|
@@ -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.
|
|
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": "
|
|
36
|
-
"dev": "
|
|
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
|
-
"
|
|
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": "
|
|
72
|
+
"@drmhse/sso-sdk": "^0.5.4"
|
|
73
73
|
}
|
|
74
74
|
}
|