@moreillon/vue-oidc 0.0.8 → 0.0.10

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
@@ -1,33 +1,41 @@
1
- # vue-oidc
1
+ # Vue OIDC
2
2
 
3
- This template should help get you started developing with Vue 3 in Vite.
3
+ ## Usage example
4
4
 
5
- ## Recommended IDE Setup
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";
6
11
 
7
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
12
+ const app = createApp(App);
8
13
 
9
- ## Type Support for `.vue` Imports in TS
14
+ const { VITE_OIDC_AUTHORITY, VITE_OIDC_CLIENT_ID } = import.meta.env;
10
15
 
11
- TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
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);
12
22
 
13
- ## Customize configuration
14
-
15
- See [Vite Configuration Reference](https://vite.dev/config/).
16
-
17
- ## Project Setup
18
-
19
- ```sh
20
- npm install
23
+ app.mount("#app");
21
24
  ```
22
25
 
23
- ### Compile and Hot-Reload for Development
26
+ Then in your components:
24
27
 
25
- ```sh
26
- npm run dev
27
- ```
28
+ ```vue
29
+ <script setup lang="ts">
30
+ import { useAuth } from "@moreillon/vue-oidc";
28
31
 
29
- ### Type-Check, Compile and Minify for Production
32
+ const { user } = useAuth();
33
+ </script>
30
34
 
31
- ```sh
32
- npm run build
35
+ <template>
36
+ <h1>User</h1>
37
+ <p>
38
+ {{ user }}
39
+ </p>
40
+ </template>
33
41
  ```
@@ -1,6 +1,6 @@
1
1
  import type OidcClient from "@moreillon/oidc-auth";
2
- declare function login(): () => void;
3
- declare function logout(): () => void;
2
+ declare function login(): void;
3
+ declare function logout(): void;
4
4
  export default function (): {
5
5
  client: import("vue").Ref<{
6
6
  cookieName: string;
@@ -5,12 +5,12 @@ const access_token = ref(null);
5
5
  function login() {
6
6
  if (!client.value)
7
7
  throw new Error("OIDC Client not instanciated");
8
- return client.value.login;
8
+ client.value.login();
9
9
  }
10
10
  function logout() {
11
11
  if (!client.value)
12
12
  throw new Error("OIDC Client not instanciated");
13
- return client.value.logout;
13
+ client.value.logout();
14
14
  }
15
15
  export default function () {
16
16
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moreillon/vue-oidc",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"