@moreillon/vue-oidc 0.0.14 → 0.0.15
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 +41 -41
- package/dist/composables/useAuth.d.ts +16 -4
- package/dist/plugins/auth.js +1 -1
- package/package.json +28 -28
package/README.md
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
# Vue OIDC
|
|
2
|
-
|
|
3
|
-
## Usage example
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { createApp } from "vue";
|
|
7
|
-
import { createPinia } from "pinia";
|
|
8
|
-
import { auth } from "@moreillon/vue-oidc";
|
|
9
|
-
import App from "./App.vue";
|
|
10
|
-
import router from "./router";
|
|
11
|
-
|
|
12
|
-
const app = createApp(App);
|
|
13
|
-
|
|
14
|
-
const { VITE_OIDC_AUTHORITY, VITE_OIDC_CLIENT_ID } = import.meta.env;
|
|
15
|
-
|
|
16
|
-
app.use(auth, {
|
|
17
|
-
authority: VITE_OIDC_AUTHORITY,
|
|
18
|
-
client_id: VITE_OIDC_CLIENT_ID,
|
|
19
|
-
});
|
|
20
|
-
app.use(createPinia());
|
|
21
|
-
app.use(router);
|
|
22
|
-
|
|
23
|
-
app.mount("#app");
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Then in your components:
|
|
27
|
-
|
|
28
|
-
```vue
|
|
29
|
-
<script setup lang="ts">
|
|
30
|
-
import { useAuth } from "@moreillon/vue-oidc";
|
|
31
|
-
|
|
32
|
-
const { user } = useAuth();
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<template>
|
|
36
|
-
<h1>User</h1>
|
|
37
|
-
<p>
|
|
38
|
-
{{ user }}
|
|
39
|
-
</p>
|
|
40
|
-
</template>
|
|
41
|
-
```
|
|
1
|
+
# Vue OIDC
|
|
2
|
+
|
|
3
|
+
## Usage example
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createApp } from "vue";
|
|
7
|
+
import { createPinia } from "pinia";
|
|
8
|
+
import { auth } from "@moreillon/vue-oidc";
|
|
9
|
+
import App from "./App.vue";
|
|
10
|
+
import router from "./router";
|
|
11
|
+
|
|
12
|
+
const app = createApp(App);
|
|
13
|
+
|
|
14
|
+
const { VITE_OIDC_AUTHORITY, VITE_OIDC_CLIENT_ID } = import.meta.env;
|
|
15
|
+
|
|
16
|
+
app.use(auth, {
|
|
17
|
+
authority: VITE_OIDC_AUTHORITY,
|
|
18
|
+
client_id: VITE_OIDC_CLIENT_ID,
|
|
19
|
+
});
|
|
20
|
+
app.use(createPinia());
|
|
21
|
+
app.use(router);
|
|
22
|
+
|
|
23
|
+
app.mount("#app");
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then in your components:
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<script setup lang="ts">
|
|
30
|
+
import { useAuth } from "@moreillon/vue-oidc";
|
|
31
|
+
|
|
32
|
+
const { user } = useAuth();
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<h1>User</h1>
|
|
37
|
+
<p>
|
|
38
|
+
{{ user }}
|
|
39
|
+
</p>
|
|
40
|
+
</template>
|
|
41
|
+
```
|
|
@@ -30,10 +30,16 @@ export default function (): {
|
|
|
30
30
|
isExpired: (expires_at: string) => boolean;
|
|
31
31
|
saveAuthDataInCookies: (data: {
|
|
32
32
|
expires_in: number;
|
|
33
|
-
}) =>
|
|
33
|
+
}) => {
|
|
34
|
+
expires_at: string;
|
|
35
|
+
expires_in: number;
|
|
36
|
+
};
|
|
34
37
|
exchangeCodeForToken: (code: string) => Promise<void>;
|
|
35
38
|
getUser: () => Promise<any>;
|
|
36
|
-
refreshAccessToken: (oidcConfig: import("@moreillon/oidc-auth").OidcConfig) => Promise<
|
|
39
|
+
refreshAccessToken: (oidcConfig: import("@moreillon/oidc-auth").OidcConfig) => Promise<{
|
|
40
|
+
expires_at: string;
|
|
41
|
+
expires_in: number;
|
|
42
|
+
}>;
|
|
37
43
|
onTokenRefreshed: (handler: (oidcData: import("@moreillon/oidc-auth").Tokens) => void) => void;
|
|
38
44
|
runRefreshEventHandlers: () => void;
|
|
39
45
|
login: () => void;
|
|
@@ -65,10 +71,16 @@ export default function (): {
|
|
|
65
71
|
isExpired: (expires_at: string) => boolean;
|
|
66
72
|
saveAuthDataInCookies: (data: {
|
|
67
73
|
expires_in: number;
|
|
68
|
-
}) =>
|
|
74
|
+
}) => {
|
|
75
|
+
expires_at: string;
|
|
76
|
+
expires_in: number;
|
|
77
|
+
};
|
|
69
78
|
exchangeCodeForToken: (code: string) => Promise<void>;
|
|
70
79
|
getUser: () => Promise<any>;
|
|
71
|
-
refreshAccessToken: (oidcConfig: import("@moreillon/oidc-auth").OidcConfig) => Promise<
|
|
80
|
+
refreshAccessToken: (oidcConfig: import("@moreillon/oidc-auth").OidcConfig) => Promise<{
|
|
81
|
+
expires_at: string;
|
|
82
|
+
expires_in: number;
|
|
83
|
+
}>;
|
|
72
84
|
onTokenRefreshed: (handler: (oidcData: import("@moreillon/oidc-auth").Tokens) => void) => void;
|
|
73
85
|
runRefreshEventHandlers: () => void;
|
|
74
86
|
login: () => void;
|
package/dist/plugins/auth.js
CHANGED
|
@@ -11,8 +11,8 @@ export default {
|
|
|
11
11
|
if (!oidcData)
|
|
12
12
|
return;
|
|
13
13
|
const { user, tokens: { access_token }, } = oidcData;
|
|
14
|
-
auth.user.value = user;
|
|
15
14
|
auth.access_token.value = access_token;
|
|
15
|
+
auth.user.value = user;
|
|
16
16
|
auth.client.value.onTokenRefreshed(({ access_token }) => {
|
|
17
17
|
auth.access_token.value = access_token;
|
|
18
18
|
});
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@moreillon/vue-oidc",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"files": [
|
|
6
|
-
"dist"
|
|
7
|
-
],
|
|
8
|
-
"main": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsc"
|
|
12
|
-
},
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"@moreillon/oidc-auth": "^3.0.
|
|
15
|
-
"vue": "^3.5.17"
|
|
16
|
-
},
|
|
17
|
-
"devDependencies": {
|
|
18
|
-
"@tsconfig/node22": "^22.0.2",
|
|
19
|
-
"@types/node": "^22.15.32",
|
|
20
|
-
"@vitejs/plugin-vue": "^6.0.0",
|
|
21
|
-
"@vue/tsconfig": "^0.7.0",
|
|
22
|
-
"npm-run-all2": "^8.0.4",
|
|
23
|
-
"typescript": "~5.8.0",
|
|
24
|
-
"vite": "^7.0.0",
|
|
25
|
-
"vite-plugin-vue-devtools": "^7.7.7",
|
|
26
|
-
"vue-tsc": "^2.2.10"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@moreillon/vue-oidc",
|
|
3
|
+
"version": "0.0.15",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@moreillon/oidc-auth": "^3.0.6",
|
|
15
|
+
"vue": "^3.5.17"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@tsconfig/node22": "^22.0.2",
|
|
19
|
+
"@types/node": "^22.15.32",
|
|
20
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
21
|
+
"@vue/tsconfig": "^0.7.0",
|
|
22
|
+
"npm-run-all2": "^8.0.4",
|
|
23
|
+
"typescript": "~5.8.0",
|
|
24
|
+
"vite": "^7.0.0",
|
|
25
|
+
"vite-plugin-vue-devtools": "^7.7.7",
|
|
26
|
+
"vue-tsc": "^2.2.10"
|
|
27
|
+
}
|
|
28
|
+
}
|