New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@chapeaux/cpx-user

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chapeaux/cpx-user - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

58

cpx-user.d.ts
/// <amd-module name="file:///home/ldary/rh/chapeaux/cpx-components/components/cpx-user/src/cpx-user.ts" />
export declare class CPXUser extends HTMLElement {
_authenticated: boolean;
_userId: string;
get userId(): string;
set userId(val: string);
_name: string;
get name(): string;
set name(val: string);
_cookies: Map<any, any>;
_email: string;
get email(): string;
set email(val: string);
_ready: boolean;
get ready(): boolean;
set ready(val: boolean);
_user: any;
get user(): any;
set user(val: any);
constructor();
connectedCallback(): void;
static get observedAttributes(): string[];
attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
validateKCConfig(): any;
camelCase(str: String, to?: boolean): string;
kcInit(config?: any): Promise<void>;
login(): any;
logout(): any;
register(): any;
account(): any;
get token(): any;
_authenticated: boolean;
_userId: string;
get userId(): string;
set userId(val: string);
_name: string;
get name(): string;
set name(val: string);
_cookies: Map<any, any>;
_email: string;
get email(): string;
set email(val: string);
_ready: boolean;
get ready(): boolean;
set ready(val: boolean);
_user: any;
get user(): any;
set user(val: any);
constructor();
connectedCallback(): void;
static get observedAttributes(): string[];
attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
validateKCConfig(): any;
camelCase(str: String, to?: boolean): string;
kcInit(config?: any): Promise<void>;
login(): any;
logout(): any;
register(): any;
account(): any;
get token(): any;
}

@@ -1,184 +0,220 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
var __awaiter = (this && this.__awaiter) ||
function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done
? resolve(result.value)
: adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
};
export class CPXUser extends HTMLElement {
constructor() {
super();
Object.defineProperty(this, "_authenticated", {
enumerable: true,
configurable: true,
writable: true,
value: false
});
Object.defineProperty(this, "_userId", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
Object.defineProperty(this, "_name", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
Object.defineProperty(this, "_cookies", {
enumerable: true,
configurable: true,
writable: true,
value: new Map()
});
Object.defineProperty(this, "_email", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
Object.defineProperty(this, "_ready", {
enumerable: true,
configurable: true,
writable: true,
value: false
});
Object.defineProperty(this, "_user", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
constructor() {
super();
Object.defineProperty(this, "_authenticated", {
enumerable: true,
configurable: true,
writable: true,
value: false,
});
Object.defineProperty(this, "_userId", {
enumerable: true,
configurable: true,
writable: true,
value: "",
});
Object.defineProperty(this, "_name", {
enumerable: true,
configurable: true,
writable: true,
value: "",
});
Object.defineProperty(this, "_cookies", {
enumerable: true,
configurable: true,
writable: true,
value: new Map(),
});
Object.defineProperty(this, "_email", {
enumerable: true,
configurable: true,
writable: true,
value: "",
});
Object.defineProperty(this, "_ready", {
enumerable: true,
configurable: true,
writable: true,
value: false,
});
Object.defineProperty(this, "_user", {
enumerable: true,
configurable: true,
writable: true,
value: void 0,
});
}
get userId() {
return this._userId;
}
set userId(val) {
if (this._userId === val) {
return;
}
get userId() {
return this._userId;
this._userId = val;
this.setAttribute("user-id", this._userId);
}
get name() {
return this._name;
}
set name(val) {
if (this._name === val) {
return;
}
set userId(val) {
if (this._userId === val)
return;
this._userId = val;
this.setAttribute("user-id", this._userId);
this._name = val;
this.setAttribute("name", this._name);
}
get email() {
return this._email;
}
set email(val) {
if (this._email === val) {
return;
}
get name() {
return this._name;
this._email = val;
this.setAttribute("email", this._email);
}
get ready() {
return this._ready;
}
set ready(val) {
if (this._ready === val) {
return;
}
set name(val) {
if (this._name === val)
return;
this._name = val;
this.setAttribute("name", this._name);
this._ready = val;
this.setAttribute("ready", this._ready.toString());
}
get user() {
return this._user;
}
set user(val) {
if (this._user === val) {
return;
}
get email() {
return this._email;
this._user = val;
if (typeof this._user.email !== "undefined") {
this.email = this._user.email;
}
set email(val) {
if (this._email === val)
return;
this._email = val;
this.setAttribute("email", this._email);
if (typeof this._user.name !== "undefined") {
this.name = this._user.name;
}
get ready() {
return this._ready;
this.dispatchEvent(
new CustomEvent(this.ready ? "user-update" : "user-ready", {
detail: this,
composed: true,
bubbles: true,
}),
);
this.ready = true;
}
connectedCallback() {
let data = this.querySelector("script");
if (data && data.innerText) {
this.user = JSON.parse(data.innerText);
}
set ready(val) {
if (this._ready === val)
return;
this._ready = val;
this.setAttribute("ready", this._ready.toString());
}
static get observedAttributes() {
return [
"name",
"email",
"username",
"user-id",
];
}
attributeChangedCallback(name, oldVal, newVal) {
this[this.camelCase(name)] = newVal;
if (this.kc && !this._authenticated) {
this.kcInit(this.kcConfig);
}
get user() {
return this._user;
}
set user(val) {
if (this._user === val)
return;
this._user = val;
if (typeof this._user.email !== "undefined")
this.email = this._user.email;
if (typeof this._user.name !== "undefined")
this.name = this._user.name;
this.dispatchEvent(new CustomEvent(this.ready ? "user-update" : "user-ready", {
detail: this,
composed: true,
bubbles: true,
}));
this.ready = true;
}
connectedCallback() {
let data = this.querySelector("script");
if (data && data.innerText) {
this.user = JSON.parse(data.innerText);
}
}
static get observedAttributes() {
return [
"name",
"email",
"username",
"user-id",
];
}
attributeChangedCallback(name, oldVal, newVal) {
this[this.camelCase(name)] = newVal;
if (this.kc && !this._authenticated) {
this.kcInit(this.kcConfig);
}
}
validateKCConfig() {
return (!this.ready && typeof this.kcUrl !== "undefined" &&
typeof this.kcRealm !== "undefined" &&
typeof this.kcClientId !== "undefined") || this.kcConfig;
}
camelCase(str, to = true) {
return to
? str.replace(/-([a-z])/g, (m, g) => g.toUpperCase())
: str.replace(/([a-z][A-Z])/g, (m, g) => `${g[0]}-${g[1].toLowerCase()}`);
}
kcInit(config) {
return __awaiter(this, void 0, void 0, function* () {
if (typeof Keycloak !== "undefined" &&
((this.kcUrl !== "" && this.kcRealm !== "" && this.kcClientId !== "") ||
this.kcConfig)) {
console.log("Config:", config);
this.keycloak = Keycloak(config && config !== ""
? JSON.parse(config.replaceAll("'", '"'))
: { url: this.kcUrl, realm: this.kcRealm, clientId: this.kcClientId });
yield this.keycloak.init(this.kcOptions ? JSON.parse(this.kcOptions.replaceAll("'", '"')) : {}).then((authenticated) => {
this._authenticated = authenticated;
if (authenticated) {
this.user = this.keycloak.tokenParsed;
document.cookie = `${this.jwtCookie}=${this.keycloak.token}`;
document.cookie =
`${this.jwtCookie}_refresh=${this.keycloak.refreshToken}`;
}
else {
if (this.kcAuto && !this.ready) {
this.login();
}
}
});
}
validateKCConfig() {
return (!this.ready && typeof this.kcUrl !== "undefined" &&
typeof this.kcRealm !== "undefined" &&
typeof this.kcClientId !== "undefined") || this.kcConfig;
}
camelCase(str, to = true) {
return to
? str.replace(/-([a-z])/g, (m, g) => g.toUpperCase())
: str.replace(/([a-z][A-Z])/g, (m, g) => `${g[0]}-${g[1].toLowerCase()}`);
}
kcInit(config) {
return __awaiter(this, void 0, void 0, function* () {
if (
typeof Keycloak !== "undefined" &&
((this.kcUrl !== "" && this.kcRealm !== "" && this.kcClientId !== "") ||
this.kcConfig)
) {
console.log("Config:", config);
this.keycloak = Keycloak(
config && config !== "" ? JSON.parse(config.replaceAll("'", '"')) : {
url: this.kcUrl,
realm: this.kcRealm,
clientId: this.kcClientId,
},
);
yield this.keycloak.init(
this.kcOptions ? JSON.parse(this.kcOptions.replaceAll("'", '"')) : {},
).then((authenticated) => {
this._authenticated = authenticated;
if (authenticated) {
this.user = this.keycloak.tokenParsed;
document.cookie = `${this.jwtCookie}=${this.keycloak.token}`;
document.cookie =
`${this.jwtCookie}_refresh=${this.keycloak.refreshToken}`;
} else {
if (this.kcAuto && !this.ready) {
this.login();
}
else {
}
}
});
}
login() {
return this.keycloak.login();
}
logout() {
return this.keycloak.logout();
}
register() {
return this.keycloak.register();
}
account() {
return this.keycloak.accountManagement();
}
get token() {
return this.keycloak.tokenParsed;
}
} else {
}
});
}
login() {
return this.keycloak.login();
}
logout() {
return this.keycloak.logout();
}
register() {
return this.keycloak.register();
}
account() {
return this.keycloak.accountManagement();
}
get token() {
return this.keycloak.tokenParsed;
}
}
window.customElements.define("cpx-user", CPXUser);
{
"name": "@chapeaux/cpx-user",
"version": "0.3.0",
"version": "0.4.0",
"description": "Chapeaux User Component",

@@ -32,3 +32,3 @@ "type": "module",

"homepage": "https://github.com/chapeaux/cpx-components/components/cpx-user",
"gitHead": "53af1643f11de85045f1d22e55b033571be302c5",
"gitHead": "03c113e6ec47be4ca201930c6d3963edbd2b3bd5",
"dependencies": {

@@ -35,0 +35,0 @@ "jwt-decode": "^3.0.0"

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