lightapp-platform-common
Advanced tools
Comparing version 2.0.28 to 2.0.29
@@ -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,20 @@ { | ||
}, | ||
"type": { | ||
"$ref": "file:common/model/schemas/SystemType.schema.json" | ||
"type": {}, | ||
"systems": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "file:common/model/schemas/Enumeration.schema.json" | ||
} | ||
}, | ||
"InMeters": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "file:common/model/schemas/IMeter.schema.json" | ||
} | ||
}, | ||
"OutMeters": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "file:common/model/schemas/IMeter.schema.json" | ||
} | ||
} | ||
@@ -19,0 +35,0 @@ }, |
{ | ||
"name": "lightapp-platform-common", | ||
"version": "2.0.28", | ||
"version": "2.0.29", | ||
"description": "common utilities for lightapp platform", | ||
@@ -11,5 +11,3 @@ "main": "index.js", | ||
"@types/jsonschema": "^1.1.1", | ||
"@types/jsonwebtoken": "^8.3.0", | ||
"amazon-cognito-identity-js": "^3.0.3", | ||
"jsonwebtoken": "^8.4.0", | ||
"pg": "^7.6.1" | ||
@@ -16,0 +14,0 @@ }, |
@@ -9,7 +9,7 @@ "use strict"; | ||
constructor() { | ||
console.debug(`Instantiating Cognito with identify pool: ${JSON.stringify(config.poolData)}...`); | ||
console.log(`instantiating cognito with poolData: ${JSON.stringify(config.poolData)}...`); | ||
this.cognitoUserPoolData = config.poolData; | ||
} | ||
signOut(username) { | ||
console.log(`Singing out username: ${username}...`); | ||
console.log(`sign out username: ${username}...`); | ||
let cognitoUserPool = new amazon_cognito_identity_js_1.CognitoUserPool(this.cognitoUserPoolData); | ||
@@ -31,3 +31,3 @@ const userData = { | ||
}; | ||
console.log(`Signing up user: ${JSON.stringify(userInfo)}`); | ||
console.log(`start Cognito signUp with userInfo: ${JSON.stringify(userInfo)}`); | ||
let userAttributes = []; | ||
@@ -40,3 +40,3 @@ let validationData = []; | ||
userAttributes.push(cognitoUserAttribute); | ||
console.debug(`userAttributes: ${JSON.stringify(userAttributes)}`); | ||
console.log(`userAttributes: ${JSON.stringify(userAttributes)}`); | ||
cognitoUserPool = new amazon_cognito_identity_js_1.CognitoUserPool(this.cognitoUserPoolData); | ||
@@ -50,3 +50,3 @@ } | ||
const { userName, password } = userInfo; | ||
console.debug(`before cognitoUserPool.signUp... username: ${userName}, password: ${password}`); | ||
console.log(`before cognitoUserPool.signUp... username: ${userName}, password: ${password}`); | ||
cognitoUserPool.signUp(userName, password, userAttributes, validationData, (err, res) => { | ||
@@ -65,4 +65,5 @@ if (err) { | ||
signIn(username, password, callBack) { | ||
console.log(`Attempting to login with username: ${username}, password: ${password}`); | ||
console.log(`start Cognito login with username: ${username}, password: ${password}`); | ||
let _result; | ||
console.log(`trying to instantiate new CognitoUserPool using poolData: : ${JSON.stringify(this.cognitoUserPoolData)}`); | ||
let cognitoUserPool = new amazon_cognito_identity_js_1.CognitoUserPool(this.cognitoUserPoolData); | ||
@@ -81,8 +82,14 @@ const userData = { | ||
const idToken = res.getIdToken().getJwtToken(); | ||
_result = Result_2.getResult(Result_1.StatusCode.OK, 'login success', { Authorization: idToken }); | ||
const authData = { | ||
Username: username, | ||
Password: password, | ||
AuthToken: idToken | ||
}; | ||
_result = Result_2.getResult(Result_1.StatusCode.OK, authData); | ||
callBack(null, _result); | ||
console.log('end sign in Cognito user'); | ||
}, | ||
onFailure: (err) => { | ||
_result = Result_2.getResult(Result_1.StatusCode.BAD_REQUEST, err); | ||
callBack(Result_2.getError(err, 'Login in has failed'), _result); | ||
callBack(Result_2.getError(err, 'fail in cognitoUser.authenticateUser'), _result); | ||
} | ||
@@ -94,3 +101,3 @@ }); | ||
let _result; | ||
console.log(`Confirming registration for username: ${userName} with verificationCode: ${verificationCode}`); | ||
console.log(`start confirmRegistration for userName: ${userName}, verificationCode: ${verificationCode}`); | ||
const cognitoUserPool = new amazon_cognito_identity_js_1.CognitoUserPool(this.cognitoUserPoolData); | ||
@@ -104,3 +111,3 @@ const userData = { | ||
if (err) { | ||
_error = Result_2.getError(err, 'User registration failed'); | ||
_error = Result_2.getError(err, 'fail in cognitoUser.confirmRegistration'); | ||
_result = Result_2.getResult(Result_1.StatusCode.BAD_REQUEST, err); | ||
@@ -107,0 +114,0 @@ callBack(_error, _result); |
@@ -12,6 +12,5 @@ "use strict"; | ||
exports.getError = (error, details) => { | ||
let internalError = { error: JSON.stringify(error), details: details }; | ||
let result = JSON.stringify(internalError); | ||
let result = `${details}: ${JSON.stringify(error)}`; | ||
console.error(result); | ||
return result; | ||
}; |
3
21036
39
579
- Removed@types/jsonwebtoken@^8.3.0
- Removedjsonwebtoken@^8.4.0
- Removed@types/jsonwebtoken@8.5.9(transitive)
- Removed@types/node@22.13.1(transitive)
- Removedbuffer-equal-constant-time@1.0.1(transitive)
- Removedecdsa-sig-formatter@1.0.11(transitive)
- Removedjsonwebtoken@8.5.1(transitive)
- Removedjwa@1.4.1(transitive)
- Removedjws@3.2.2(transitive)
- Removedlodash.includes@4.3.0(transitive)
- Removedlodash.isboolean@3.0.3(transitive)
- Removedlodash.isinteger@4.0.4(transitive)
- Removedlodash.isnumber@3.0.3(transitive)
- Removedlodash.isplainobject@4.0.6(transitive)
- Removedlodash.isstring@4.0.1(transitive)
- Removedlodash.once@4.1.1(transitive)
- Removedms@2.1.3(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedundici-types@6.20.0(transitive)