ac-signature
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -0,1 +1,16 @@ | ||
<a name="3.1.0"></a> | ||
# [3.1.0](https://github.com/mmpro/ac-signature/compare/v3.0.0..v3.1.0) (2024-07-13 07:36:14) | ||
### Feature | ||
* **App:** Add option to use identifier as part of hash | MP | [bd20f511ac73e19c5d66c6471c948278eead009a](https://github.com/mmpro/ac-signature/commit/bd20f511ac73e19c5d66c6471c948278eead009a) | ||
Some requests are made on behalf of users. To secure them, this information is added as part of the signed hash. Use signature version 5 | ||
Related issues: [undefined/undefined#master](undefined/browse/master) | ||
### Chores | ||
* **App:** Updated packages | MP | [a40f24dd8125d7d3d6c44e693f0b037dae42f82e](https://github.com/mmpro/ac-signature/commit/a40f24dd8125d7d3d6c44e693f0b037dae42f82e) | ||
Updated packages | ||
Related issues: [undefined/undefined#master](undefined/browse/master) | ||
<a name="3.0.0"></a> | ||
@@ -2,0 +17,0 @@ |
10
index.js
@@ -13,2 +13,6 @@ /** | ||
const sign5 = (params) => { | ||
return sign(params, { version: 5 }) | ||
} | ||
const sign2 = (params) => { | ||
@@ -25,2 +29,3 @@ return sign(params, { version: 2 }) | ||
const path = _.get(params, 'path') | ||
const identifier = _.get(params, 'identifier') // identifier header for requests "on behalf" | ||
@@ -70,2 +75,4 @@ // for debugging you can use your own timestamp | ||
} | ||
if (version >= 5 && identifier) valueToHash += '\n' + identifier | ||
@@ -107,2 +114,3 @@ valueToHash += '\n' + ts + (_.isEmpty(payload) ? '' : '\n'+JSON.stringify(payload)) | ||
const ts = parseInt( _.get(options, 'rts', _.get(headers, 'x-admiralcloud-rts'))) | ||
const identifier = _.get(options, 'identifier', _.get(headers, 'x-admiralcloud-identifier')) | ||
const version = parseInt(_.get(options, 'version', _.get(headers, 'x-admiralcloud-version', (_.isString(path) ? 2 : 1)))) | ||
@@ -156,2 +164,3 @@ | ||
} | ||
if (version >= 5 && identifier) valueToHash += '\n' + identifier | ||
@@ -195,2 +204,3 @@ // Check payload against hash ] Hash is calculated | ||
sign2, | ||
sign5, | ||
checkSignedPayload | ||
@@ -197,0 +207,0 @@ } |
{ | ||
"name": "ac-signature", | ||
"description": "Sign payload for AdmiralCloud API", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"author": "Mark Poepping (https://www.admiralcloud.com)", | ||
@@ -26,8 +26,8 @@ "contributors": [ | ||
"devDependencies": { | ||
"ac-semantic-release": "^0.3.5", | ||
"chai": "^4.3.7", | ||
"eslint": "^8.33.0", | ||
"mocha": "^10.2.0", | ||
"mocha-junit-reporter": "^2.2.0", | ||
"superagent": "^8.0.9" | ||
"ac-semantic-release": "^0.4.2", | ||
"chai": "^4.4.1", | ||
"eslint": "^9.7.0", | ||
"mocha": "^10.6.0", | ||
"mocha-junit-reporter": "^2.2.1", | ||
"superagent": "^9.0.2" | ||
}, | ||
@@ -41,3 +41,6 @@ "scripts": { | ||
"node": ">=16.0.0" | ||
}, | ||
"resolutions": { | ||
"braces": "^3.0.3" | ||
} | ||
} |
47675
14
614