@digipair/skill-web-keycloak 0.90.0 → 0.91.0-0

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/.swcrc ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "jsc": {
3
+ "target": "es2017",
4
+ "parser": {
5
+ "syntax": "typescript",
6
+ "decorators": true,
7
+ "dynamicImport": true
8
+ },
9
+ "transform": {
10
+ "decoratorMetadata": true,
11
+ "legacyDecorator": true
12
+ },
13
+ "keepClassNames": true,
14
+ "externalHelpers": true,
15
+ "loose": true
16
+ },
17
+ "module": {
18
+ "type": "es6"
19
+ },
20
+ "sourceMaps": true,
21
+ "exclude": [
22
+ "jest.config.ts",
23
+ ".*\\.spec.tsx?$",
24
+ ".*\\.test.tsx?$",
25
+ "./src/jest-setup.ts$",
26
+ "./**/jest-setup.ts$"
27
+ ]
28
+ }
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # mylib
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build mylib` to build the library.
@@ -0,0 +1,22 @@
1
+ import baseConfig from '../../eslint.config.mjs';
2
+
3
+ export default [
4
+ ...baseConfig,
5
+ {
6
+ files: ['**/*.json'],
7
+ rules: {
8
+ '@nx/dependency-checks': [
9
+ 'error',
10
+ {
11
+ ignoredFiles: [
12
+ '{projectRoot}/eslint.config.{js,cjs,mjs}',
13
+ '{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
14
+ ],
15
+ },
16
+ ],
17
+ },
18
+ languageOptions: {
19
+ parser: await import('jsonc-eslint-parser'),
20
+ },
21
+ },
22
+ ];
package/package.json CHANGED
@@ -1,12 +1,28 @@
1
1
  {
2
2
  "name": "@digipair/skill-web-keycloak",
3
- "version": "0.90.0",
3
+ "version": "0.91.0-0",
4
+ "type": "module",
5
+ "main": "dist/libs/skill-web-keycloak/index.cjs.js",
6
+ "module": "dist/libs/skill-web-keycloak/index.esm.js",
7
+ "types": "dist/libs/skill-web-keycloak/index.esm.d.ts",
8
+ "exports": {
9
+ "./package.json": "./libs/skill-web-keycloak/package.json",
10
+ ".": {
11
+ "development": "./dist/libs/skill-web-keycloak/src/index.ts",
12
+ "types": "./dist/libs/skill-web-keycloak/index.esm.d.ts",
13
+ "import": "./dist/libs/skill-web-keycloak/index.esm.js",
14
+ "default": "./dist/libs/skill-web-keycloak/index.cjs.js"
15
+ }
16
+ },
4
17
  "keywords": [
5
18
  "digipair",
6
19
  "web",
7
20
  "util"
8
21
  ],
9
- "dependencies": {},
10
- "main": "./index.cjs.js",
11
- "module": "./index.esm.js"
12
- }
22
+ "nx": {
23
+ "name": "skill-web-keycloak"
24
+ },
25
+ "dependencies": {
26
+ "@digipair/engine": "0.91.0-0"
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ const { withNx } = require('@nx/rollup/with-nx');
2
+
3
+ module.exports = withNx(
4
+ {
5
+ main: 'libs/skill-web-keycloak/src/index.ts',
6
+ outputPath: 'dist/libs/skill-web-keycloak',
7
+ tsConfig: 'libs/skill-web-keycloak/tsconfig.lib.json',
8
+ compiler: 'swc',
9
+ format: ['esm', "cjs"],
10
+ assets: [
11
+ {
12
+ input: 'libs/skill-web-keycloak/',
13
+ glob: 'package.json',
14
+ output: '.'
15
+ },
16
+ {
17
+ input: 'libs/skill-web-keycloak/src/',
18
+ glob: '*.json',
19
+ output: '.'
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ // Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
25
+ // e.g.
26
+ // output: { sourcemap: true },
27
+ }
28
+ );
@@ -0,0 +1,7 @@
1
+ import { skillWebKeycloak } from './skill-web-keycloak';
2
+
3
+ describe('skillWebKeycloak', () => {
4
+ it('should work', () => {
5
+ expect(skillWebKeycloak()).toEqual('skill-web-keycloak');
6
+ });
7
+ });
@@ -0,0 +1,93 @@
1
+ import { PinsSettings } from '@digipair/engine';
2
+
3
+ declare const Keycloak: any;
4
+
5
+ class WebKeycloakService {
6
+ set _keycloakPromise(promise: any) {
7
+ (window as any)['__DIGIPAIR_KEYCLOAK'] = promise;
8
+ }
9
+ get _keycloakPromise() {
10
+ return (window as any)['__DIGIPAIR_KEYCLOAK'];
11
+ }
12
+
13
+ set _isLogged(isLogged: boolean) {
14
+ (window as any)['__DIGIPAIR_KEYCLOAK_IS_LOGGED'] = isLogged;
15
+ }
16
+ get _isLogged() {
17
+ return (window as any)['__DIGIPAIR_KEYCLOAK_IS_LOGGED'];
18
+ }
19
+
20
+ private async authentification(): Promise<any> {
21
+ const keycloak = await this._keycloakPromise;
22
+
23
+ if (this._isLogged) {
24
+ await keycloak.updateToken(60000);
25
+ }
26
+
27
+ return keycloak;
28
+ }
29
+
30
+ async isLogged(_params: any, _pinsSettingsList: PinsSettings[], _context: any): Promise<boolean> {
31
+ return this._isLogged;
32
+ }
33
+
34
+ async initialize(params: any, _pinsSettingsList: PinsSettings[], context: any): Promise<void> {
35
+ const {
36
+ url = context.variables.KEYCLOAK_URL,
37
+ realm = context.variables.KEYCLOAK_REALM,
38
+ clientId = context.variables.KEYCLOAK_CLIENTID,
39
+ } = params;
40
+
41
+ this._keycloakPromise = (async () => {
42
+ const keycloak = new Keycloak({
43
+ url,
44
+ realm,
45
+ clientId,
46
+ });
47
+
48
+ this._isLogged = false;
49
+ try {
50
+ this._isLogged = await keycloak.init({
51
+ onLoad: 'check-sso',
52
+ silentCheckSsoRedirectUri: window.location.origin + '/public/silent-check-sso.html',
53
+ });
54
+ } catch (error) {
55
+ console.error('keycloak error', error);
56
+ }
57
+
58
+ return keycloak;
59
+ })();
60
+
61
+ await this.authentification();
62
+ }
63
+
64
+ async token(_params: any, _pinsSettingsList: PinsSettings[], _context: any): Promise<string> {
65
+ const authentification = await this.authentification();
66
+ return authentification.token;
67
+ }
68
+
69
+ async logout(_params: any, _pinsSettingsList: PinsSettings[], _context: any): Promise<void> {
70
+ const authentification = await this.authentification();
71
+ authentification.logout();
72
+ }
73
+
74
+ async login(_params: any, _pinsSettingsList: PinsSettings[], _context: any): Promise<void> {
75
+ const authentification = await this.authentification();
76
+ await authentification.login();
77
+ }
78
+ }
79
+
80
+ export const isLogged = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
81
+ new WebKeycloakService().isLogged(params, pinsSettingsList, context);
82
+
83
+ export const initialize = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
84
+ new WebKeycloakService().initialize(params, pinsSettingsList, context);
85
+
86
+ export const token = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
87
+ new WebKeycloakService().token(params, pinsSettingsList, context);
88
+
89
+ export const logout = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
90
+ new WebKeycloakService().logout(params, pinsSettingsList, context);
91
+
92
+ export const login = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
93
+ new WebKeycloakService().login(params, pinsSettingsList, context);
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "../engine"
8
+ },
9
+ {
10
+ "path": "./tsconfig.lib.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
7
+ "emitDeclarationOnly": true,
8
+ "module": "esnext",
9
+ "moduleResolution": "node",
10
+ "forceConsistentCasingInFileNames": true,
11
+ "types": ["node"]
12
+ },
13
+ "include": ["src/**/*.ts"],
14
+ "references": [
15
+ {
16
+ "path": "../engine/tsconfig.lib.json"
17
+ }
18
+ ]
19
+ }
package/index.cjs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
package/index.cjs.js DELETED
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- let WebKeycloakService = class WebKeycloakService {
6
- set _keycloakPromise(promise) {
7
- window['__DIGIPAIR_KEYCLOAK'] = promise;
8
- }
9
- get _keycloakPromise() {
10
- return window['__DIGIPAIR_KEYCLOAK'];
11
- }
12
- set _isLogged(isLogged) {
13
- window['__DIGIPAIR_KEYCLOAK_IS_LOGGED'] = isLogged;
14
- }
15
- get _isLogged() {
16
- return window['__DIGIPAIR_KEYCLOAK_IS_LOGGED'];
17
- }
18
- async authentification() {
19
- const keycloak = await this._keycloakPromise;
20
- if (this._isLogged) {
21
- await keycloak.updateToken(60000);
22
- }
23
- return keycloak;
24
- }
25
- async isLogged(_params, _pinsSettingsList, _context) {
26
- return this._isLogged;
27
- }
28
- async initialize(params, _pinsSettingsList, context) {
29
- const { url = context.variables.KEYCLOAK_URL, realm = context.variables.KEYCLOAK_REALM, clientId = context.variables.KEYCLOAK_CLIENTID } = params;
30
- this._keycloakPromise = (async ()=>{
31
- const keycloak = new Keycloak({
32
- url,
33
- realm,
34
- clientId
35
- });
36
- this._isLogged = false;
37
- try {
38
- this._isLogged = await keycloak.init({
39
- onLoad: 'check-sso',
40
- silentCheckSsoRedirectUri: window.location.origin + '/public/silent-check-sso.html'
41
- });
42
- } catch (error) {
43
- console.error('keycloak error', error);
44
- }
45
- return keycloak;
46
- })();
47
- await this.authentification();
48
- }
49
- async token(_params, _pinsSettingsList, _context) {
50
- const authentification = await this.authentification();
51
- return authentification.token;
52
- }
53
- async logout(_params, _pinsSettingsList, _context) {
54
- const authentification = await this.authentification();
55
- authentification.logout();
56
- }
57
- async login(_params, _pinsSettingsList, _context) {
58
- const authentification = await this.authentification();
59
- await authentification.login();
60
- }
61
- };
62
- const isLogged = (params, pinsSettingsList, context)=>new WebKeycloakService().isLogged(params, pinsSettingsList, context);
63
- const initialize = (params, pinsSettingsList, context)=>new WebKeycloakService().initialize(params, pinsSettingsList, context);
64
- const token = (params, pinsSettingsList, context)=>new WebKeycloakService().token(params, pinsSettingsList, context);
65
- const logout = (params, pinsSettingsList, context)=>new WebKeycloakService().logout(params, pinsSettingsList, context);
66
- const login = (params, pinsSettingsList, context)=>new WebKeycloakService().login(params, pinsSettingsList, context);
67
-
68
- exports.initialize = initialize;
69
- exports.isLogged = isLogged;
70
- exports.login = login;
71
- exports.logout = logout;
72
- exports.token = token;
package/index.esm.js DELETED
@@ -1,64 +0,0 @@
1
- let WebKeycloakService = class WebKeycloakService {
2
- set _keycloakPromise(promise) {
3
- window['__DIGIPAIR_KEYCLOAK'] = promise;
4
- }
5
- get _keycloakPromise() {
6
- return window['__DIGIPAIR_KEYCLOAK'];
7
- }
8
- set _isLogged(isLogged) {
9
- window['__DIGIPAIR_KEYCLOAK_IS_LOGGED'] = isLogged;
10
- }
11
- get _isLogged() {
12
- return window['__DIGIPAIR_KEYCLOAK_IS_LOGGED'];
13
- }
14
- async authentification() {
15
- const keycloak = await this._keycloakPromise;
16
- if (this._isLogged) {
17
- await keycloak.updateToken(60000);
18
- }
19
- return keycloak;
20
- }
21
- async isLogged(_params, _pinsSettingsList, _context) {
22
- return this._isLogged;
23
- }
24
- async initialize(params, _pinsSettingsList, context) {
25
- const { url = context.variables.KEYCLOAK_URL, realm = context.variables.KEYCLOAK_REALM, clientId = context.variables.KEYCLOAK_CLIENTID } = params;
26
- this._keycloakPromise = (async ()=>{
27
- const keycloak = new Keycloak({
28
- url,
29
- realm,
30
- clientId
31
- });
32
- this._isLogged = false;
33
- try {
34
- this._isLogged = await keycloak.init({
35
- onLoad: 'check-sso',
36
- silentCheckSsoRedirectUri: window.location.origin + '/public/silent-check-sso.html'
37
- });
38
- } catch (error) {
39
- console.error('keycloak error', error);
40
- }
41
- return keycloak;
42
- })();
43
- await this.authentification();
44
- }
45
- async token(_params, _pinsSettingsList, _context) {
46
- const authentification = await this.authentification();
47
- return authentification.token;
48
- }
49
- async logout(_params, _pinsSettingsList, _context) {
50
- const authentification = await this.authentification();
51
- authentification.logout();
52
- }
53
- async login(_params, _pinsSettingsList, _context) {
54
- const authentification = await this.authentification();
55
- await authentification.login();
56
- }
57
- };
58
- const isLogged = (params, pinsSettingsList, context)=>new WebKeycloakService().isLogged(params, pinsSettingsList, context);
59
- const initialize = (params, pinsSettingsList, context)=>new WebKeycloakService().initialize(params, pinsSettingsList, context);
60
- const token = (params, pinsSettingsList, context)=>new WebKeycloakService().token(params, pinsSettingsList, context);
61
- const logout = (params, pinsSettingsList, context)=>new WebKeycloakService().logout(params, pinsSettingsList, context);
62
- const login = (params, pinsSettingsList, context)=>new WebKeycloakService().login(params, pinsSettingsList, context);
63
-
64
- export { initialize, isLogged, login, logout, token };
@@ -1,6 +0,0 @@
1
- import { PinsSettings } from '@digipair/engine';
2
- export declare const isLogged: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<boolean>;
3
- export declare const initialize: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<void>;
4
- export declare const token: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<string>;
5
- export declare const logout: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<void>;
6
- export declare const login: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<void>;
File without changes
File without changes
File without changes