idea-toolbox
Advanced tools
Comparing version 0.7.1 to 0.8.0
18
index.js
@@ -21,3 +21,3 @@ 'use strict'; | ||
// COGNITO | ||
cognitoGetUserByClaims, cognitoGetUserByEmail, | ||
cognitoGetUserByClaims, cognitoGetUserByEmail, cognitoGetUserBySub, | ||
// SES | ||
@@ -222,2 +222,18 @@ sesSendEmail, | ||
/** | ||
* Helper function to identify a user by its sub, returning then its attributes. | ||
*/ | ||
function cognitoGetUserBySub(AWS, accessKeyId, secretAccessKey, cognitoUserPoolId, sub, cb) { | ||
new AWS.CognitoIdentityServiceProvider({ | ||
apiVersion: '2016-04-18', accessKeyId: accessKeyId, secretAccessKey: secretAccessKey | ||
}) | ||
.listUsers({ UserPoolId: cognitoUserPoolId, Filter: `sub = "${sub}"`, Limit: 1}, | ||
(err, data) => { | ||
if(err || !data || !data.Users || !data.Users[0]) return cb(); | ||
let userAttributes = []; | ||
data.Users[0].Attributes.forEach(a => userAttributes[a.Name] = a.Value); | ||
cb(userAttributes); | ||
}); | ||
} | ||
/// | ||
@@ -224,0 +240,0 @@ /// SES |
{ | ||
"name": "idea-toolbox", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"description": "IDEA's utility functions", | ||
@@ -5,0 +5,0 @@ "engines": { |
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
16913
360
5