Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dbp-toolkit/auth

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbp-toolkit/auth - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

dist/shared/keycloak.zduBIkhr.es.js

8

dist/dbp-auth-demo.js

@@ -1,2 +0,2 @@

import { a as AdapterLitElement, S as ScopedElementsMixin, c as createInstance, A as AuthKeycloak, L as LoginButton, y, d as defineCustomElement } from './shared/login-button.16b45e7e.es.js';
import { a as AdapterLitElement, S as ScopedElementsMixin, c as createInstance, A as AuthKeycloak, L as LoginButton, x, d as defineCustomElement } from './shared/login-button.CVp6LNss.es.js';

@@ -219,6 +219,6 @@ class DBPLitElement extends AdapterLitElement {

return this.noAuth
? y`
? x`
<dbp-login-button subscribe="auth" lang="${this.lang}"></dbp-login-button>
`
: y`
: x`
<div class="container">

@@ -236,3 +236,3 @@ <dbp-auth-keycloak

render() {
return y`
return x`
<style>

@@ -239,0 +239,0 @@ /* from BULMA.CSS */

@@ -1,2 +0,2 @@

import { d as defineCustomElement, A as AuthKeycloak, L as LoginButton } from './shared/login-button.16b45e7e.es.js';
import { d as defineCustomElement, A as AuthKeycloak, L as LoginButton } from './shared/login-button.CVp6LNss.es.js';

@@ -3,0 +3,0 @@ defineCustomElement('dbp-auth-keycloak', AuthKeycloak);

@@ -9,3 +9,3 @@ module.exports = {

sort: true,
i18nextOptions: {compatibilityJSON: 'v3'},
i18nextOptions: {compatibilityJSON: 'v4'},
};
{
"name": "@dbp-toolkit/auth",
"homepage": "https://github.com/digital-blueprint/toolkit/tree/main/packages/auth",
"version": "0.3.2",
"version": "0.3.3",
"main": "src/index.js",

@@ -17,4 +17,3 @@ "license": "LGPL-2.1-or-later",

"devDependencies": {
"@esm-bundle/chai": "^4.2.0",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-commonjs": "^26.0.0",
"@rollup/plugin-json": "^6.0.0",

@@ -25,6 +24,8 @@ "@rollup/plugin-node-resolve": "^15.0.0",

"@rollup/plugin-url": "^8.0.0",
"eslint": "^8.0.0",
"eslint-plugin-jsdoc": "^40.0.0",
"glob": "^8.0.0",
"i18next-parser": "^7.0.0",
"chai": "^5.0.0",
"eslint": "^9.1.0",
"eslint-plugin-jsdoc": "^48.0.0",
"glob": "^10.0.0",
"globals": "^15.3.0",
"i18next-parser": "^9.0.0",
"karma": "^6.0.0",

@@ -36,23 +37,25 @@ "karma-chrome-launcher": "^3.0.0",

"mocha": "^10.0.0",
"playwright": "^1.34.0",
"playwright-core": "^1.20.2",
"prettier": "^2.5.1",
"rollup": "^3.2.5",
"prettier": "^3.0.0",
"rollup": "^4.0.0",
"rollup-plugin-copy": "^3.1.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-emit-ejs": "^3.1.0",
"rollup-plugin-serve": "^2.0.0"
"rollup-plugin-serve": "^2.0.0",
"typescript": "^5.2.2"
},
"dependencies": {
"@dbp-toolkit/common": "^0.3.5",
"@dbp-toolkit/common": "^0.3.6",
"@open-wc/scoped-elements": "^2.1.0",
"event-target-shim": "^6.0.0",
"keycloak-js": "^21.0.0",
"lit": "^2.0.0"
"keycloak-js": "^24.0.0",
"lit": "^2.7.0 || ^3.0.0"
},
"scripts": {
"clean": "rm dist/*",
"format": "yarn run format:eslint && yarn run format:prettier",
"format": "npm run format:eslint && npm run format:prettier",
"format:eslint": "eslint \"**/*.{js,ts}\" --fix",
"format:prettier": "prettier \"**/*.{js,json,ts}\" --write",
"build": "yarn run build-local",
"build": "npm run build-local",
"build-local": "rollup --bundleConfigAsCjs -c",

@@ -64,9 +67,10 @@ "build-dev": "rollup --bundleConfigAsCjs -c --environment BUILD:development",

"i18next": "i18next",
"watch": "yarn run watch-local",
"watch": "npm run watch-local",
"watch-local": "rollup --bundleConfigAsCjs -c --watch",
"watch-dev": "rollup --bundleConfigAsCjs -c --watch --environment BUILD:development",
"test": "yarn run build-test && karma start --singleRun",
"lint": "eslint ."
"test": "npm run build-test && karma start --singleRun",
"lint": "eslint .",
"tsc": "tsc -p jsconfig.json"
},
"gitHead": "d53820b6f4ed7c27eab159a07ed1e63211f81997"
"gitHead": "f2c80a3090825282132fd8f2d6c9661d11e3beb0"
}

@@ -50,2 +50,3 @@ # Auth Web Components

- `idp-hint` (optional): Set a client suggested identity provider
- `no-check-login-iframe` (optional): Set to `true` to disable the login check iframe.

@@ -115,11 +116,11 @@ ### Emitted attributes

# install dependencies
yarn install
npm install
# constantly build dist/bundle.js and run a local web-server on port 8002
yarn run watch-local
npm run watch-local
# build local packages in dist directory
yarn run build
npm run build
```
Jump to <http://localhost:8002> and you should get a Single Sign On login page.

@@ -1,2 +0,2 @@

import glob from 'glob';
import {globSync} from 'glob';
import url from 'url';

@@ -27,3 +27,3 @@ import resolve from '@rollup/plugin-node-resolve';

? ['src/' + appName + '.js', 'src/' + appName + '-demo.js']
: glob.sync('test/**/*.js'),
: globSync('test/**/*.js'),
output: {

@@ -36,9 +36,2 @@ dir: 'dist',

},
onwarn: function (warning, warn) {
// keycloak bundled code uses eval
if (warning.code === 'EVAL' && warning.id.includes('sha256.js')) {
return;
}
warn(warning);
},
plugins: [

@@ -65,3 +58,3 @@ del({

}),
resolve(),
resolve({browser: true}),
commonjs(),

@@ -68,0 +61,0 @@ json(),

import {createInstance} from './i18n.js';
import JSONLD from '@dbp-toolkit/common/jsonld';
import {KeycloakWrapper} from './keycloak.js';
import {LoginStatus} from './util.js';
import {AdapterLitElement} from '@dbp-toolkit/common';
import {AdapterLitElement, combineURLs} from '@dbp-toolkit/common';
import {send} from '@dbp-toolkit/common/notification';

@@ -41,2 +40,3 @@

this.silentCheckSsoRedirectUri = null;
this.noCheckLoginIframe = false;
this.scope = null;

@@ -60,6 +60,2 @@ this.idpHint = '';

break;
case 'entryPointUrl':
// for preloading the instance
JSONLD.getInstance(this.entryPointUrl, this.lang);
break;
case 'requestedLoginStatus':

@@ -93,12 +89,3 @@ console.log('requested-login-status changed', this.requestedLoginStatus);

async _fetchUser(userId) {
let jsonld;
jsonld = await JSONLD.getInstance(this.entryPointUrl, this.lang);
let baseUrl = '';
try {
baseUrl = jsonld.getApiUrlForEntityName('FrontendUser');
} catch (error) {
// backwards compat
baseUrl = jsonld.getApiUrlForEntityName('Person');
}
const apiUrl = baseUrl + '/' + encodeURIComponent(userId);
const apiUrl = combineURLs(this.entryPointUrl, `/frontend/users/${encodeURIComponent(userId)}`);

@@ -216,2 +203,3 @@ let response = await fetch(apiUrl, {

requestedLoginStatus: {type: String, attribute: 'requested-login-status'},
noCheckLoginIframe: {type: Boolean, attribute: 'no-check-login-iframe'},
};

@@ -231,2 +219,3 @@ }

this.silentCheckSsoRedirectUri,
!this.noCheckLoginIframe,
this.idpHint

@@ -233,0 +222,0 @@ );

{
"login": "Anmelden",
"login-failed": "Kommunikation mit dem Anmeldeserver fehlgeschlagen",
"logout": "Abmelden"
"logout": "Abmelden",
"logging-in": "Einloggen"
}
{
"login": "Login",
"login-failed": "Communication with the login server failed",
"logout": "Logout"
"logout": "Logout",
"logging-in": "Logging in"
}

@@ -22,3 +22,3 @@ import {EventTarget} from 'event-target-shim'; // Because EventTarget() doesn't exist on Safari

return new URL(urlOrPath).href;
} catch (e) {
} catch {
return new URL(urlOrPath, window.location.href).href;

@@ -35,3 +35,11 @@ }

export class KeycloakWrapper extends EventTarget {
constructor(baseURL, realm, clientId, silentCheckSsoUri, idpHint) {
/**
* @param {string} baseURL
* @param {string} realm
* @param {string} clientId
* @param {string} silentCheckSsoUri
* @param {boolean} checkLoginIframe
* @param {string} idpHint
*/
constructor(baseURL, realm, clientId, silentCheckSsoUri, checkLoginIframe, idpHint) {
super();

@@ -43,4 +51,5 @@

this._keycloak = null;
this._initDone = false;
this._initPromise = null;
this._silentCheckSsoUri = silentCheckSsoUri;
this._checkLoginIframe = checkLoginIframe;
this._idpHint = idpHint;

@@ -145,5 +154,3 @@ this._checkId = null;

async _ensureInstance() {
if (this._keycloak !== null) return;
async _init() {
const Keycloak = (await import('keycloak-js')).default;

@@ -164,19 +171,3 @@

this._keycloak.onReady = this._onReady.bind(this);
}
async _keycloakInit(options) {
// https://gitlab.tugraz.at/dbp/topics/library/issues/41
// retry the keycloak init in case it fails, maybe it helps :/
try {
return await this._keycloak.init(options);
} catch (e) {
return await this._keycloak.init(options);
}
}
async _ensureInit() {
await this._ensureInstance();
if (this._initDone) return;
this._initDone = true;
const options = {

@@ -191,2 +182,4 @@ promiseType: 'native',

options['checkLoginIframe'] = this._checkLoginIframe;
if (this._silentCheckSsoUri) {

@@ -198,3 +191,3 @@ options['onLoad'] = 'check-sso';

// never return here, so add a timeout and emit a signal so the app can continue
await promiseTimeout(5000, this._keycloakInit(options)).catch(() => {
await promiseTimeout(5000, this._keycloak.init(options)).catch(() => {
console.log('Login timed out');

@@ -204,6 +197,13 @@ this._onChanged();

} else {
await this._keycloakInit(options);
await this._keycloak.init(options);
}
}
async _ensureInit() {
if (this._initPromise === null) {
this._initPromise = this._init();
}
return this._initPromise;
}
/**

@@ -210,0 +210,0 @@ * If this returns true you need to call login() at one point to finish the login process.

@@ -161,7 +161,7 @@ import {createInstance} from './i18n.js';

<a href="#">
<div class="login-box login-button">
<div class="icon">
<div class="login-box login-button" aria-busy="true">
<div class="icon" aria-hidden="false" aria-label="${i18n.t('logging-in')}">
<dbp-mini-spinner class="spinner"></dbp-mini-spinner>
</div>
<div class="label">&#8203;</div>
<div class="label" aria-hidden="true">&#8203;</div>
</div>

@@ -174,3 +174,3 @@ </a>

<div class="login-box login-button">
<div class="icon">${unsafeHTML(logoutSVG)}</div>
<div class="icon" aria-hidden="true">${unsafeHTML(logoutSVG)}</div>
<div class="label">${i18n.t('logout')}</div>

@@ -184,3 +184,3 @@ </div>

<div class="login-box login-button">
<div class="icon">${unsafeHTML(loginSVG)}</div>
<div class="icon" aria-hidden="true">${unsafeHTML(loginSVG)}</div>
<div class="label">${i18n.t('login')}</div>

@@ -187,0 +187,0 @@ </div>

@@ -1,2 +0,2 @@

import {assert} from '@esm-bundle/chai';
import {assert} from 'chai';

@@ -3,0 +3,0 @@ import '../src/dbp-auth';

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc