idea-toolbox
Advanced tools
Comparing version 6.5.0 to 6.5.1
@@ -1,6 +0,5 @@ | ||
import { Resource } from './resource.model'; | ||
/** | ||
* A user stored in a Cognito User Pool. | ||
*/ | ||
export declare class CognitoUser extends Resource { | ||
export declare class CognitoUser { | ||
/** | ||
@@ -11,2 +10,6 @@ * The id of the user. | ||
/** | ||
* The email address of the user. | ||
*/ | ||
email: string; | ||
/** | ||
* The fullname of the user. | ||
@@ -16,6 +19,2 @@ */ | ||
/** | ||
* The email address of the user. | ||
*/ | ||
email: string; | ||
/** | ||
* The list of groups containing the user. | ||
@@ -25,7 +24,8 @@ */ | ||
/** | ||
* Load the attributes from an already existing resource. | ||
* Note: the method also reads from the user's token (claims) format. | ||
* The user's custom attributes. | ||
*/ | ||
load(x: any): void; | ||
validate(): string[]; | ||
custom: { | ||
[attribute: string]: string | number; | ||
}; | ||
constructor(x?: any); | ||
/** | ||
@@ -32,0 +32,0 @@ * Whether the user is part of the administrators group. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CognitoUser = void 0; | ||
const resource_model_1 = require("./resource.model"); | ||
/** | ||
* A user stored in a Cognito User Pool. | ||
*/ | ||
class CognitoUser extends resource_model_1.Resource { | ||
/** | ||
* Load the attributes from an already existing resource. | ||
* Note: the method also reads from the user's token (claims) format. | ||
*/ | ||
load(x) { | ||
super.load(x); | ||
this.userId = this.clean(x.userId || x.sub, String); | ||
this.name = this.clean(x.name, String); | ||
this.email = this.clean(x.email, String); | ||
this.groups = this.cleanArray(x.groups || x['cognito:groups']?.split(','), String); | ||
class CognitoUser { | ||
constructor(x = {}) { | ||
this.userId = x.userId || x.sub; | ||
this.email = x.email; | ||
this.name = x.name; | ||
this.groups = x.groups || x['cognito:groups']?.split(','); | ||
if (x.custom) | ||
this.custom = x.custom; | ||
else { | ||
this.custom = {}; | ||
Object.keys(x) | ||
.filter(a => a.startsWith('custom:')) | ||
.forEach(a => (this.custom[a.slice('custom:'.length + 1)] = x[a])); | ||
} | ||
} | ||
validate() { | ||
const e = super.validate(); | ||
if (this.iE(this.name)) | ||
e.push('name'); | ||
if (this.iE(this.email)) | ||
e.push('email'); | ||
return e; | ||
} | ||
/** | ||
@@ -29,0 +23,0 @@ * Whether the user is part of the administrators group. |
{ | ||
"name": "idea-toolbox", | ||
"version": "6.5.0", | ||
"version": "6.5.1", | ||
"description": "IDEA's utility functions", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
467094
13845