@ghentcdh/authentication-vue 0.6.0 → 0.6.2

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.
Files changed (2) hide show
  1. package/index.js +1 -0
  2. package/package.json +12 -7
package/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),w=require("keycloak-js"),u="GHENTCDH_AUTHENTICATION";class s extends w{constructor(t){super(t)}async initialize(){try{const t=await this.init({onLoad:"login-required"});console.log(t?"User is authenticated":"User is not authenticated")}catch(t){console.error("Failed to initialize adapter:",t)}}static async init(t){const o=new s(t);return console.log("KeycloakAdapter",t),await o.initialize(),o}get userInfo(){return this.idTokenParsed}updateToken(){return console.log("update the token"),super.updateToken(30)}get isAuthenticated(){return this.authenticated??!1}}const f={skipAuthentication:!1},A=n=>{const t=a.ref(!1);let o;const r={...f,...n},l=async()=>{const e=await s.init(n.keycloak);return o=e,t.value=!0,e},d=()=>o?.token,i=async()=>{if(!o)return l();t.value||await new Promise(e=>{const g=a.watch(t,p=>{p&&(g(),e())})})},h=async()=>(await i())?.userInfo,k=async()=>(await i())?.logout(),y=async()=>(await i())?.updateToken(),c=a.markRaw({install(e){e.runWithContext(()=>{e.config.globalProperties.$auth=r,e.provide(u,c)})},updateToken:y,token:d,user:h,logout:k,options:r});return c},T=()=>{const n=a.inject(u);return n||console.warn("No auth provided, authorized calls may not work"),{isAuthenticated:()=>!!n?.user(),getUser:()=>n?.user(),logout:()=>n?.logout()}};exports.createAuth=A;exports.useAuthenticate=T;
package/package.json CHANGED
@@ -1,20 +1,25 @@
1
1
  {
2
2
  "name": "@ghentcdh/authentication-vue",
3
3
  "license": "MIT",
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "main": "./index.js",
6
+ "module": "./index.mjs",
6
7
  "types": "./index.d.ts",
7
- "dependencies": {
8
- "vue": "^3.5.13",
9
- "keycloak-js": "^26.1.2"
10
- },
11
8
  "exports": {
12
9
  ".": {
10
+ "types": "./index.d.ts",
13
11
  "import": "./index.mjs",
14
- "require": "./index.js",
15
- "types": "./index.d.ts"
12
+ "require": "./index.js"
16
13
  }
17
14
  },
15
+ "peerDependencies": {
16
+ "keycloak-js": "^26.0.0",
17
+ "vue": "^3.5.0"
18
+ },
19
+ "devDependencies": {
20
+ "keycloak-js": "^26.2.2",
21
+ "vue": "3.5.27"
22
+ },
18
23
  "repository": {
19
24
  "type": "git",
20
25
  "url": "https://github.com/GhentCDH/ghentcdh-monorepo.git"