lightapp-platform-common
Advanced tools
Comparing version 2.0.37 to 2.0.38
@@ -10,3 +10,9 @@ { | ||
"type": "string" | ||
}, | ||
"AuthToken": { | ||
"type": "string" | ||
} | ||
}, | ||
@@ -13,0 +19,0 @@ "required": [ |
@@ -13,2 +13,5 @@ { | ||
"type": "string" | ||
}, | ||
"authToken": { | ||
"type": "string" | ||
} | ||
@@ -19,4 +22,5 @@ }, | ||
"firstName", | ||
"lastName" | ||
"lastName", | ||
"authToken" | ||
] | ||
} |
@@ -15,4 +15,17 @@ { | ||
}, | ||
"type": { | ||
"$ref": "file:common/model/schemas/SystemType.schema.json" | ||
"type": {}, | ||
"children": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "file:common/model/schemas/Enumeration.schema.json" | ||
} | ||
}, | ||
"Meters": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "file:common/model/schemas/IMeter.schema.json" | ||
} | ||
}, | ||
"MetaData": { | ||
"type": "string" | ||
} | ||
@@ -19,0 +32,0 @@ }, |
{ | ||
"name": "lightapp-platform-common", | ||
"version": "2.0.37", | ||
"version": "2.0.38", | ||
"description": "common utilities for lightapp platform", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -60,2 +60,26 @@ "use strict"; | ||
} | ||
signInPromised(username, password) { | ||
console.log(`Attempting to promise login with username: ${username}, password: ${password}`); | ||
let _result; | ||
let cognitoUserPool = new amazon_cognito_identity_js_1.CognitoUserPool(this.cognitoUserPoolData); | ||
const userData = { | ||
Username: username, | ||
Pool: cognitoUserPool | ||
}; | ||
const cognitoUser = new amazon_cognito_identity_js_1.CognitoUser(userData); | ||
const authenticationDetails = new amazon_cognito_identity_js_1.AuthenticationDetails({ | ||
Username: username, | ||
Password: password | ||
}); | ||
return new Promise((resolve, reject) => { | ||
cognitoUser.authenticateUser(authenticationDetails, { | ||
onSuccess: function (result) { | ||
resolve(result); | ||
}, | ||
onFailure: function (err) { | ||
reject(err); | ||
}, | ||
}); | ||
}); | ||
} | ||
signIn(username, password, callBack) { | ||
@@ -62,0 +86,0 @@ console.log(`Attempting to login with username: ${username}, password: ${password}`); |
@@ -8,24 +8,12 @@ "use strict"; | ||
exports.getUserName = (event) => { | ||
if (event.headers) { | ||
const _headers = JSON.parse(event.headers.toString()); | ||
const _token = _headers.Authorization; | ||
const authentication = new Authentication_1.default(_token); | ||
const _username = authentication.username; | ||
return _username; | ||
} | ||
else { | ||
console.log(`missing headers in request`); | ||
return null; | ||
} | ||
const _headers = JSON.parse(event.headers.toString()); | ||
const _token = _headers.Authorization; | ||
const authentication = new Authentication_1.default(_token); | ||
const _username = authentication.username; | ||
return _username; | ||
}; | ||
exports.getHeader = (event, header) => { | ||
if (event.headers) { | ||
const _headers = JSON.parse(event.headers.toString()); | ||
const _header = _headers[header]; | ||
return _header; | ||
} | ||
else { | ||
console.log(`missing headers in request`); | ||
return null; | ||
} | ||
const _headers = JSON.parse(event.headers.toString()); | ||
const _header = _headers[header]; | ||
return _header; | ||
}; | ||
@@ -32,0 +20,0 @@ exports.getQueryString = (event, paramName) => { |
30751
54
816