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

@adastradev/user-management-sdk

Package Overview
Dependencies
Maintainers
27
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adastradev/user-management-sdk - npm Package Compare versions

Comparing version 2.4.1-beta.1602699133299 to 2.4.1-beta.1602852851544

2

dist/AuthManager.d.ts

@@ -16,3 +16,3 @@ import { ICognitoUserPoolLocator } from './ICognitoUserPoolLocator';

constructor(locator: ICognitoUserPoolLocator, region: string);
signIn: (email: string, password: string, newPassword?: string) => Promise<CognitoUserSession>;
signIn(email: string, password: string, newPassword?: string): Promise<CognitoUserSession>;
getAndSetEnvironmentCredentials(): Promise<any>;

@@ -19,0 +19,0 @@ getCognitoCredentials(): Promise<any>;

@@ -61,92 +61,2 @@ "use strict";

function AuthManager(locator, region) {
var _this = this;
this.signIn = function (email, password, newPassword) {
if (newPassword === void 0) { newPassword = ''; }
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var _a, error_1, userPool, authenticationData, userData, authenticationDetails, that;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
// get the pool data from the response
console.log("Signing into AWS Cognito");
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
_a = this;
return [4 /*yield*/, this.locator.getPoolForUsername(email)];
case 2:
_a.poolData = _b.sent();
this.authenticatorURI = "cognito-idp." + this.region + ".amazonaws.com/" + this.poolData.UserPoolId;
return [3 /*break*/, 4];
case 3:
error_1 = _b.sent();
return [2 /*return*/, reject(error_1)];
case 4:
userPool = new amazon_cognito_identity_js_1.CognitoUserPool(this.poolData);
authenticationData = {
Password: password,
Username: email.toLowerCase()
};
userData = {
Pool: userPool,
Username: email.toLowerCase()
};
authenticationDetails = new amazon_cognito_identity_js_1.AuthenticationDetails(authenticationData);
// authenticate user to in Cognito user pool
this.cognitoUser = new amazon_cognito_identity_js_1.CognitoUser(userData);
that = this;
this.cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
that.cognitoUserSession = result;
return resolve(result);
},
onFailure: function (err) {
return reject(err);
},
mfaRequired: function (codeDeliveryDetails) {
return reject(Error('Multi-factor auth is not currently supported'));
},
newPasswordRequired: function (userAttributes, requiredAttributes) {
if (newPassword) {
// User was signed up by an admin and must provide new
// password and required attributes
// These attributes are not mutable and should be removed from map.
delete userAttributes.email_verified;
delete userAttributes['custom:tenant_id'];
that.cognitoUser.completeNewPasswordChallenge(newPassword, userAttributes, {
onFailure: function (err) {
return reject(err);
},
onSuccess: function (result) {
that.cognitoUserSession = result;
return resolve(result);
}
});
}
else {
return reject(Error('New password is required for the user'));
}
}
});
return [2 /*return*/];
}
});
}); });
};
this.buildCognitoIdentityCredentials = function (tokens) {
var _a;
return new global_1.CognitoIdentityCredentials({
IdentityPoolId: _this.poolData.IdentityPoolId,
Logins: (_a = {},
_a[_this.authenticatorURI] = tokens.idToken.getJwtToken(),
_a)
});
};
this.getTokens = function (session) {
return {
accessToken: session.getAccessToken(),
idToken: session.getIdToken(),
refreshToken: session.getRefreshToken()
};
};
this.locator = locator;

@@ -159,2 +69,76 @@ this.region = region;

}
AuthManager.prototype.signIn = function (email, password, newPassword) {
var _this = this;
if (newPassword === void 0) { newPassword = ''; }
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var _a, error_1, userPool, authenticationData, userData, authenticationDetails, that;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
// get the pool data from the response
console.log("Signing into AWS Cognito");
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
_a = this;
return [4 /*yield*/, this.locator.getPoolForUsername(email)];
case 2:
_a.poolData = _b.sent();
this.authenticatorURI = "cognito-idp." + this.region + ".amazonaws.com/" + this.poolData.UserPoolId;
return [3 /*break*/, 4];
case 3:
error_1 = _b.sent();
return [2 /*return*/, reject(error_1)];
case 4:
userPool = new amazon_cognito_identity_js_1.CognitoUserPool(this.poolData);
authenticationData = {
Password: password,
Username: email.toLowerCase()
};
userData = {
Pool: userPool,
Username: email.toLowerCase()
};
authenticationDetails = new amazon_cognito_identity_js_1.AuthenticationDetails(authenticationData);
// authenticate user to in Cognito user pool
this.cognitoUser = new amazon_cognito_identity_js_1.CognitoUser(userData);
that = this;
this.cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
that.cognitoUserSession = result;
return resolve(result);
},
onFailure: function (err) {
return reject(err);
},
mfaRequired: function (codeDeliveryDetails) {
return reject(Error('Multi-factor auth is not currently supported'));
},
newPasswordRequired: function (userAttributes, requiredAttributes) {
if (newPassword) {
// User was signed up by an admin and must provide new
// password and required attributes
// These attributes are not mutable and should be removed from map.
delete userAttributes.email_verified;
delete userAttributes['custom:tenant_id'];
that.cognitoUser.completeNewPasswordChallenge(newPassword, userAttributes, {
onFailure: function (err) {
return reject(err);
},
onSuccess: function (result) {
that.cognitoUserSession = result;
return resolve(result);
}
});
}
else {
return reject(Error('New password is required for the user'));
}
}
});
return [2 /*return*/];
}
});
}); });
};
AuthManager.prototype.getAndSetEnvironmentCredentials = function () {

@@ -205,2 +189,18 @@ return __awaiter(this, void 0, void 0, function () {

};
AuthManager.prototype.buildCognitoIdentityCredentials = function (tokens) {
var _a;
return new global_1.CognitoIdentityCredentials({
IdentityPoolId: this.poolData.IdentityPoolId,
Logins: (_a = {},
_a[this.authenticatorURI] = tokens.idToken.getJwtToken(),
_a)
});
};
AuthManager.prototype.getTokens = function (session) {
return {
accessToken: session.getAccessToken(),
idToken: session.getIdToken(),
refreshToken: session.getRefreshToken()
};
};
return AuthManager;

@@ -207,0 +207,0 @@ }());

@@ -11,3 +11,3 @@ "use strict";

for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -14,0 +14,0 @@ __exportStar(require("./AuthManager"), exports);

{
"name": "@adastradev/user-management-sdk",
"version": "2.4.1-beta.1602699133299",
"version": "2.4.1-beta.1602852851544",
"description": "Astra user management SDK for JavaScript in the browser and Node.js",

@@ -35,3 +35,3 @@ "main": "dist/index.js",

"amazon-cognito-identity-js": "^3.3.3",
"aws-sdk": "^2.752.0",
"aws-sdk": "^2.771.0",
"axios": "^0.19.2",

@@ -43,23 +43,23 @@ "node-fetch": "^2.6.1",

"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/chai": "^4.2.12",
"@types/chai": "^4.2.13",
"@types/chai-as-promised": "^7.1.3",
"@types/mocha": "^7.0.2",
"@types/node": "^12.12.31",
"@types/node": "^12.12.67",
"@types/sinon": "^7.5.2",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"codecov": "^3.7.2",
"codecov": "^3.8.0",
"gulp": "^4.0.2",
"gulp-snyk": "^0.1.1",
"mocha": "^7.1.1",
"mocha": "^7.2.0",
"nyc": "^15.1.0",
"sinon": "^9.0.3",
"snyk": "^1.396.0",
"sinon": "^9.2.0",
"snyk": "^1.413.3",
"source-map-support": "^0.5.16",
"ts-node": "^8.8.1",
"ts-node": "^8.10.2",
"tslint": "^6.1.3",
"tslint-config-airbnb": "^5.11.2",
"tslint-config-security": "^1.16.0",
"typescript": "^3.8.3"
"typescript": "^3.9.7"
}
}

Sorry, the diff of this file is not supported yet

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