@edirect/auth
Advanced tools
Comparing version 9.1.1 to 9.1.2
@@ -12,2 +12,1 @@ export interface EntityUserInterface { | ||
export declare function keycloakAccessTokenToEntityUserInterface(data: any): EntityUserInterface; | ||
export declare function getEntities(data: any): string[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getEntities = exports.keycloakAccessTokenToEntityUserInterface = void 0; | ||
exports.keycloakAccessTokenToEntityUserInterface = void 0; | ||
const user_interface_1 = require("./user.interface"); | ||
@@ -12,12 +12,8 @@ function keycloakAccessTokenToEntityUserInterface(data) { | ||
firstName: (data === null || data === void 0 ? void 0 : data.given_name) || (data === null || data === void 0 ? void 0 : data.clientId), | ||
lastName: data === null || data === void 0 ? void 0 : data.family_name, | ||
lastName: (data === null || data === void 0 ? void 0 : data.family_name) || (data === null || data === void 0 ? void 0 : data.preferred_username), | ||
phone: data === null || data === void 0 ? void 0 : data.phone_number, | ||
entities: getEntities(data), | ||
entities: (0, user_interface_1.getEntityAttributeByClient)(data, data.azp, 'entities') || [], | ||
}; | ||
} | ||
exports.keycloakAccessTokenToEntityUserInterface = keycloakAccessTokenToEntityUserInterface; | ||
function getEntities(data) { | ||
return ((data === null || data === void 0 ? void 0 : data.entities) || []).map((i) => i.entityId); | ||
} | ||
exports.getEntities = getEntities; | ||
//# sourceMappingURL=entity-user.interface.js.map |
@@ -13,2 +13,3 @@ import { EntityUserInterface } from './entity-user.interface'; | ||
export interface UserInterface extends JWTToken { | ||
clientId?: string; | ||
accountId: string; | ||
@@ -15,0 +16,0 @@ permissions: string[]; |
@@ -7,2 +7,3 @@ "use strict"; | ||
function keycloakAccessTokenToUserInterface(data, client) { | ||
const entityId = getEntityAttributeByClient(data, data.azp, 'entityId'); | ||
return { | ||
@@ -14,7 +15,8 @@ aud: client, | ||
jti: data.jti, | ||
clientId: client, | ||
accountId: getEntityAttributeByClient(data, data.azp, 'accountId'), | ||
permissions: getPermissions(data, data.azp), | ||
roles: getRoles(data, data.azp), | ||
permissions: getPermissions(data, client), | ||
roles: getRoles(data, client), | ||
scope: data.scope, | ||
username: data === null || data === void 0 ? void 0 : data.preferred_username, | ||
username: [entityId, data === null || data === void 0 ? void 0 : data.email].filter(Boolean).join('#'), | ||
entityUser: (0, entity_user_interface_1.keycloakAccessTokenToEntityUserInterface)(data), | ||
@@ -25,3 +27,6 @@ }; | ||
function getEntityAttributeByClient(data, client, attribute) { | ||
const entityData = ((data === null || data === void 0 ? void 0 : data.entities) || []).find((i) => i.entityId === client.replace('-client', '')); | ||
let entityData = ((data === null || data === void 0 ? void 0 : data.entities) || []).find((i) => i.entityId === client.replace('-client', '')); | ||
if (!entityData) { | ||
entityData = ((data === null || data === void 0 ? void 0 : data.entities) || []).find((i) => i.entityId === 'edirect'); | ||
} | ||
return (0, lodash_1.get)(entityData, attribute); | ||
@@ -28,0 +33,0 @@ } |
{ | ||
"name": "@edirect/auth", | ||
"version": "9.1.1", | ||
"version": "9.1.2", | ||
"description": "Auth Module", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -22,3 +22,3 @@ { | ||
"dependencies": { | ||
"@edirect/auth": "^9.0.0", | ||
"@edirect/auth": "^9.1.1", | ||
"@edirect/config": "^9.0.0", | ||
@@ -25,0 +25,0 @@ "@edirect/logger": "^9.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1219295
26895