@samhammer/authentication-vue 2.0.4 → 2.0.6

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.
@@ -1,4 +1,6 @@
1
+ import type { KeycloakInitOptions } from "keycloak-js";
1
2
  export interface AuthOptions {
3
+ keycloakInitOptions?: KeycloakInitOptions;
2
4
  apiClientId?: string;
3
5
  appClientId?: string;
4
6
  guestClientId?: string;
package/lib/AuthPlugin.js CHANGED
@@ -24,17 +24,14 @@ export class AuthPlugin {
24
24
  return this.guest.authenticated ? this.guest.getGuestId() : this.keycloak.getToken();
25
25
  }
26
26
  initOnce = once(async (authOptions) => {
27
- console.log("initOnce coming");
28
27
  this.authOptions = authOptions;
29
28
  const guestAuthenticated = this.guest.init(this.authOptions);
30
29
  if (guestAuthenticated) {
31
- console.log("initOnce emit guest authenticated");
32
30
  AuthEvents.emit(AuthEventNames.isGuestAuthenticated);
33
31
  return;
34
32
  }
35
33
  const keyCloakAuthenticated = await this.keycloak.init(this.authOptions);
36
34
  if (keyCloakAuthenticated) {
37
- console.log("initOnce emit keycloak authenticated");
38
35
  AuthEvents.emit(AuthEventNames.isAlreadyAuthenticated);
39
36
  }
40
37
  });
@@ -55,7 +52,6 @@ export class AuthPlugin {
55
52
  return this.keycloak.createLogoutUrl(redirectUri);
56
53
  }
57
54
  async update() {
58
- console.log("Run into update");
59
55
  const authenticated = await this.keycloak.initKeycloak();
60
56
  if (authenticated) {
61
57
  AuthEvents.emit(AuthEventNames.isAlreadyAuthenticated);
@@ -105,6 +101,7 @@ class KeycloakPlugin {
105
101
  });
106
102
  this.pluginState = {
107
103
  keycloak: keycloak,
104
+ authOptios: authOptions,
108
105
  accessTokenKey: `${authOptions.appClientId}-accessToken`,
109
106
  refreshTokenKey: `${authOptions.appClientId}-refreshToken`,
110
107
  idTokenKey: `${authOptions.appClientId}-idToken`
@@ -129,7 +126,8 @@ class KeycloakPlugin {
129
126
  enableLogging: false,
130
127
  refreshToken: LocalStorageUtils.getItem(this.pluginState.refreshTokenKey),
131
128
  token: LocalStorageUtils.getItem(this.pluginState.accessTokenKey),
132
- idToken: LocalStorageUtils.getItem(this.pluginState.idTokenKey)
129
+ idToken: LocalStorageUtils.getItem(this.pluginState.idTokenKey),
130
+ ...this.pluginState.authOptios.keycloakInitOptions
133
131
  });
134
132
  if (authenticated) {
135
133
  console.debug("authenticated keycloak");
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "@samhammer/authentication-vue",
3
- "version": "2.0.4",
4
- "description": "Keycloak authentication for VueJS projects",
5
- "main": "lib/index.js",
6
- "typings": "lib/index.d.ts",
7
- "files": [
8
- "lib/**/*"
9
- ],
10
- "repository": "https://github.com/SamhammerAG/Samhammer.Authentication.Vue",
11
- "author": "SamhammerAG (https://www.samhammer.de/)",
12
- "bugs": {
13
- "url": "https://github.com/SamhammerAG/Samhammer.Authentication.Vue/issues"
14
- },
15
- "homepage": "https://github.com/SamhammerAG/Samhammer.Authentication.Vue#readme",
16
- "license": "MIT",
17
- "scripts": {
18
- "build": "tsc",
19
- "format": "prettier --write --parser typescript ./src",
20
- "lint": "eslint . --fix",
21
- "prepare": "yarn run build",
22
- "prepublishOnly": "yarn run lint",
23
- "version": "git add .",
24
- "postversion": "git push && git push --tags"
25
- },
26
- "devDependencies": {
27
- "@rushstack/eslint-patch": "^1.2.0",
28
- "@types/lodash": "^4.14.191",
29
- "@types/node": "^18.15.1",
30
- "@types/uuid": "^9.0.1",
31
- "@typescript-eslint/eslint-plugin": "^5.54.1",
32
- "@typescript-eslint/parser": "^5.54.1",
33
- "eslint": "^8.36.0",
34
- "eslint-config-prettier": "^8.7.0",
35
- "eslint-plugin-import": "^2.27.5",
36
- "eslint-plugin-prettier": "^4.2.1",
37
- "prettier": "^2.7.1",
38
- "typescript": "^4.7.4"
39
- },
40
- "dependencies": {
41
- "axios": "^1.3.4",
42
- "emittery": "^1.0.1",
43
- "keycloak-js": "^20.0.3",
44
- "lodash": "^4.17.21",
45
- "uuid": "^9.0.0"
46
- }
47
- }
1
+ {
2
+ "name": "@samhammer/authentication-vue",
3
+ "version": "2.0.6",
4
+ "description": "Keycloak authentication for VueJS projects",
5
+ "main": "lib/index.js",
6
+ "typings": "lib/index.d.ts",
7
+ "files": [
8
+ "lib/**/*"
9
+ ],
10
+ "repository": "https://github.com/SamhammerAG/Samhammer.Authentication.Vue",
11
+ "author": "SamhammerAG (https://www.samhammer.de/)",
12
+ "bugs": {
13
+ "url": "https://github.com/SamhammerAG/Samhammer.Authentication.Vue/issues"
14
+ },
15
+ "homepage": "https://github.com/SamhammerAG/Samhammer.Authentication.Vue#readme",
16
+ "license": "MIT",
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "format": "prettier --write --parser typescript ./src",
20
+ "lint": "eslint . --fix",
21
+ "prepare": "yarn run build",
22
+ "prepublishOnly": "yarn run lint",
23
+ "version": "git add .",
24
+ "postversion": "git push && git push --tags"
25
+ },
26
+ "devDependencies": {
27
+ "@rushstack/eslint-patch": "^1.2.0",
28
+ "@types/lodash": "^4.14.191",
29
+ "@types/node": "^18.15.1",
30
+ "@types/uuid": "^9.0.1",
31
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
32
+ "@typescript-eslint/parser": "^5.54.1",
33
+ "eslint": "^8.36.0",
34
+ "eslint-config-prettier": "^8.7.0",
35
+ "eslint-plugin-import": "^2.27.5",
36
+ "eslint-plugin-prettier": "^4.2.1",
37
+ "prettier": "^2.7.1",
38
+ "typescript": "^4.7.4"
39
+ },
40
+ "dependencies": {
41
+ "axios": "^1.3.4",
42
+ "emittery": "^1.0.1",
43
+ "keycloak-js": "^20.0.3",
44
+ "lodash": "^4.17.21",
45
+ "uuid": "^9.0.0"
46
+ }
47
+ }