Skip to content

Commit 1228a16

Browse files
sanjuyadav24Sanju Yadav
andauthored
Update methods removed from Node24 to support Node24 migration (#658)
Co-authored-by: Sanju Yadav <sanjuyadav@microsoft.com>
1 parent 38ea3e0 commit 1228a16

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

api/WebApi.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,25 @@ export class WebApi {
475475
if (lookupKey && lookupKey.indexOf(':') > 0) {
476476
let lookupInfo: string[] = lookupKey.split(':', 2);
477477

478-
// file contains encryption key
479-
let keyFile = new Buffer(lookupInfo[0], 'base64').toString('utf8');
480-
let encryptKey = new Buffer(fs.readFileSync(keyFile, 'utf8'), 'base64');
478+
let keyFile = Buffer.from(lookupInfo[0], 'base64').toString('utf8');
479+
let keyAndIv = fs.readFileSync(keyFile, 'utf8');
480+
481+
let [keyBase64, ivBase64] = keyAndIv.split(':', 2);
482+
483+
if (!keyBase64 || !ivBase64) {
484+
throw new Error(
485+
'Invalid encryption key format. Expected "key:iv" format from azure-pipelines-task-lib 5.2.4+. ' +
486+
'This version of azure-devops-node-api (15.2.0+) is not compatible with task-lib <5.2.4.'
487+
);
488+
}
489+
490+
let encryptKey = Buffer.from(keyBase64, 'base64');
491+
let iv = Buffer.from(ivBase64, 'base64');
481492

482-
let encryptedContent: string = new Buffer(lookupInfo[1], 'base64').toString('utf8');
493+
let encryptedContent: string = Buffer.from(lookupInfo[1], 'base64').toString('utf8');
483494

484-
let decipher = crypto.createDecipher("aes-256-ctr", encryptKey)
485-
let decryptedContent = decipher.update(encryptedContent, 'hex', 'utf8')
495+
let decipher = crypto.createDecipheriv("aes-256-ctr", encryptKey, iv);
496+
let decryptedContent = decipher.update(encryptedContent, 'hex', 'utf8');
486497
decryptedContent += decipher.final('utf8');
487498

488499
return decryptedContent;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "azure-devops-node-api",
33
"description": "Node client for Azure DevOps and TFS REST APIs",
4-
"version": "15.1.2",
4+
"version": "15.1.3",
55
"main": "./WebApi.js",
66
"types": "./WebApi.d.ts",
77
"scripts": {

0 commit comments

Comments
 (0)