swdc-tracker
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -46,3 +46,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var hashedValue, hashValueAlreadyExists, response; | ||
var hashedValue, hashValueAlreadyExists; | ||
return __generator(this, function (_a) { | ||
@@ -70,2 +70,27 @@ switch (_a.label) { | ||
case 3: | ||
_a.sent(); | ||
setUserHashedValues(jwt); | ||
_a.label = 4; | ||
case 4: return [2 /*return*/, hashedValue]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.hashValue = hashValue; | ||
function encryptValue(value, hashedValue, dataType, jwt) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var params, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!jwt) { | ||
return [2 /*return*/, ""]; | ||
} | ||
params = { | ||
value: value, | ||
hashed_value: hashedValue, | ||
data_type: dataType | ||
}; | ||
return [4 /*yield*/, http_1.post("/user_encrypted_data", params, jwt)]; | ||
case 1: | ||
response = _a.sent(); | ||
@@ -80,10 +105,4 @@ if (response.status == 201) { | ||
} | ||
// async update the hashedValues to stay up to date with the backend | ||
setUserHashedValues(jwt); | ||
} | ||
else { | ||
console.log("swdc-tracker received an error attempting to encrypt. status code: " + response.status); | ||
} | ||
_a.label = 4; | ||
case 4: return [2 /*return*/, hashedValue]; | ||
return [2 /*return*/]; | ||
} | ||
@@ -93,19 +112,2 @@ }); | ||
} | ||
exports.hashValue = hashValue; | ||
function encryptValue(value, hashedValue, dataType, jwt) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var params; | ||
return __generator(this, function (_a) { | ||
if (!jwt) { | ||
return [2 /*return*/, ""]; | ||
} | ||
params = { | ||
value: value, | ||
hashed_value: hashedValue, | ||
data_type: dataType | ||
}; | ||
return [2 /*return*/, http_1.post("/user_encrypted_data", params, jwt)]; | ||
}); | ||
}); | ||
} | ||
function setUserHashedValues(jwt) { | ||
@@ -112,0 +114,0 @@ return __awaiter(this, void 0, void 0, function () { |
{ | ||
"name": "swdc-tracker", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "swdc event tracker", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
@@ -28,17 +28,4 @@ import { get, post } from "./http"; | ||
if (!hashValueAlreadyExists) { | ||
const response = await encryptValue(value, hashedValue, dataType, jwt); | ||
if(response.status == 201) { | ||
// update the local userHashedValues so that we don't re-encrypt it | ||
if(userHashedValues[dataType]) { | ||
userHashedValues[dataType].push(hashedValue); | ||
} else { | ||
userHashedValues[dataType] = [hashedValue] | ||
} | ||
// async update the hashedValues to stay up to date with the backend | ||
setUserHashedValues(jwt); | ||
} else { | ||
console.log(`swdc-tracker received an error attempting to encrypt. status code: ${response.status}`) | ||
} | ||
await encryptValue(value, hashedValue, dataType, jwt); | ||
setUserHashedValues(jwt); | ||
} | ||
@@ -60,3 +47,11 @@ | ||
return post("/user_encrypted_data", params, jwt); | ||
const response = await post("/user_encrypted_data", params, jwt); | ||
if(response.status == 201) { | ||
// update the local userHashedValues so that we don't re-encrypt it | ||
if(userHashedValues[dataType]) { | ||
userHashedValues[dataType].push(hashedValue); | ||
} else { | ||
userHashedValues[dataType] = [hashedValue] | ||
} | ||
} | ||
} | ||
@@ -63,0 +58,0 @@ |
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
122905
2606