@chapeaux/cpx-user
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -21,2 +21,3 @@ export declare class CPXUser extends HTMLElement { | ||
set user(val: any); | ||
_worker: any; | ||
constructor(); | ||
@@ -28,3 +29,4 @@ connectedCallback(): void; | ||
camelCase(str: String, to?: boolean): string; | ||
onMessage(e: any): void; | ||
dispatchEDDL(): Promise<void>; | ||
} |
@@ -19,2 +19,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this._ready = false; | ||
console.log(new URL(import.meta.url).pathname.replace('cpx-user.js', 'user.js')); | ||
this._worker = new Worker(new URL(import.meta.url).pathname.replace('cpx-user.js', 'user.js')); | ||
this.onMessage = this.onMessage.bind(this); | ||
} | ||
@@ -97,2 +100,11 @@ get userId() { | ||
if (this.eddl) { | ||
this._worker.postMessage({ | ||
action: 'getCookies', | ||
values: new Map([ | ||
['rh_common_id', 'custKey'], | ||
['rh_user_id', 'userID'], | ||
['rh_sso_session', 'loggedIn'] | ||
]), | ||
payload: document.cookie | ||
}); | ||
this.dispatchEDDL(); | ||
@@ -110,2 +122,3 @@ } | ||
}); | ||
this._worker.onmessage = this.onMessage; | ||
} | ||
@@ -139,2 +152,14 @@ static get observedAttributes() { | ||
} | ||
onMessage(e) { | ||
const data = e.data; | ||
if (data.action) { | ||
switch (data.action) { | ||
case 'getCookies': | ||
if (data.results) { | ||
Object.assign(this.user, data.results); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
dispatchEDDL() { | ||
@@ -145,5 +170,7 @@ return __awaiter(this, void 0, void 0, function* () { | ||
detail: { | ||
custKey: this.user['custKey'], | ||
accountID: this.user['account_number'] || '', | ||
userID: this.user['preferred_username'], | ||
userID: this.user['userID'], | ||
lastLoginDate: this.user['auth_time'], | ||
loggedIn: this.user['loggedIn'] ? "true" : "false", | ||
hashedEmail: hashedEmail | ||
@@ -150,0 +177,0 @@ }, |
{ | ||
"name": "@chapeaux/cpx-user", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Chapeaux User Component", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1,2 +0,3 @@ | ||
export declare class User { | ||
declare function getCookies(cookies: any, values: Map<string, string>): {}; | ||
declare class User { | ||
constructor(obj?: any); | ||
@@ -3,0 +4,0 @@ givenname: string; |
27
user.js
@@ -1,2 +0,27 @@ | ||
export class User { | ||
"use strict"; | ||
function getCookies(cookies, values) { | ||
let obj = {}; | ||
let cookieMap = new Map(); | ||
cookies.split(';').map(v => { | ||
const rec = v.trim().split('='); | ||
cookieMap.set(rec[0], rec[1]); | ||
}); | ||
for (const [key, value] of values) { | ||
obj[value] = cookieMap.get(key); | ||
} | ||
return obj; | ||
} | ||
onmessage = function (e) { | ||
if (e.data && e.data.action) { | ||
switch (e.data.action) { | ||
case 'getCookies': | ||
postMessage({ action: e.data.action, results: getCookies(e.data.payload, e.data.values) }); | ||
break; | ||
default: | ||
postMessage({}); | ||
break; | ||
} | ||
} | ||
}; | ||
class User { | ||
constructor(obj) { | ||
@@ -3,0 +28,0 @@ this.givenname = ""; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
268
0
48414
8