Skip to content

Commit 2844d8f

Browse files
committed
Add case insensitivity to Activate and GetKey
1 parent 549b047 commit 2844d8f

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

internal/HelperMethods.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = class HelperMethods {
1111
const key = new NodeRSA();
1212
const pubKey = HelperMethods.GetPublicKeyParams(rsaPubKey);
1313
key.importKey({ n: pubKey.modulus, e: pubKey.exponent }, 'components-public');
14-
return key.verify(Buffer.from(response["licenseKey"], "base64"), Buffer.from(response["signature"], "base64"));
14+
return key.verify(Buffer.from(this.GetValueCaseInsensitive(response,"licenseKey"), "base64"), Buffer.from(this.GetValueCaseInsensitive(response,"signature"), "base64"));
1515
}
1616

1717
/**
@@ -57,4 +57,13 @@ module.exports = class HelperMethods {
5757
})();
5858
});
5959
}
60+
61+
static GetValueCaseInsensitive(obj, key) {
62+
for (var prop in obj) {
63+
if (prop.toLowerCase() === key.toLowerCase()) {
64+
return obj[prop];
65+
}
66+
}
67+
return undefined;
68+
}
6069
}

methods/Key.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = class Key {
2121
const res = await helpers.CallAPI(`${LicenseServerUrl}/api/key/Activate`, formBody)
2222

2323
if (helpers.VerifySignature(res, rsaPubKey)) {
24-
const license = JSON.parse(Buffer.from(res["licenseKey"], "base64").toString("utf-8"));
24+
const license = JSON.parse(Buffer.from(helpers.GetValueCaseInsensitive(res,"licenseKey"), "base64").toString("utf-8"));
2525
license.RawResponse = res;
2626
resolve(license);
2727
} else {
@@ -74,7 +74,7 @@ module.exports = class Key {
7474
reject(new Error(body.message));
7575
} else {
7676
if (helpers.VerifySignature(body, rsaPubKey)) {
77-
const license = JSON.parse(Buffer.from(body["licenseKey"], "base64").toString("utf-8"));
77+
const license = JSON.parse(Buffer.from(helpers.GetValueCaseInsensitive(res,"licenseKey"), "base64").toString("utf-8"));
7878
license.RawResponse = body;
7979
resolve(license);
8080
} else {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cryptolens",
3-
"version": "1.0.12",
3+
"version": "1.0.13",
44
"description": "Client API for NodeJS to access Cryptolens Software Licensing API.",
55
"main": "main.js",
66
"scripts": {

0 commit comments

Comments
 (0)