Skip to content

Commit d25852f

Browse files
committed
fix: address Copilot code review comments
- Fix verifyResponse stub to use correct api module pattern - Fix parameter validation test to properly test missing parameters - Apply ES6 shorthand property syntax for signingKey - Revert V4 HMAC logic as token usage is out of scope for this PR Ticket: CAAS-783
1 parent 5b04240 commit d25852f

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

modules/sdk-api/src/bitgoAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ export class BitGoAPI implements BitGoBase {
11541154

11551155
return {
11561156
tokenId: params.tokenId,
1157-
signingKey: signingKey,
1157+
signingKey,
11581158
};
11591159
}
11601160

modules/sdk-api/test/unit/bitgoAPI.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,12 +622,8 @@ describe('processV4TokenIssuance', function () {
622622

623623
it('should throw error when missing required parameters', function () {
624624
(() => {
625-
bitgo.processV4TokenIssuance({
626-
tokenId: '',
627-
encryptedToken: '',
628-
derivationPath: '',
629-
ecdhXprv: '',
630-
});
625+
// @ts-expect-error - Testing parameter validation with missing required fields
626+
bitgo.processV4TokenIssuance({});
631627
}).should.throw(/tokenId/);
632628
});
633629

@@ -767,7 +763,8 @@ describe('V4 Token Issuance', function () {
767763
} as any);
768764

769765
// Stub verifyResponse to pass
770-
const verifyStub = sinon.stub(bitgo as any, 'verifyResponse').returns(undefined);
766+
const verifyResponseStub = sinon.stub().returns(undefined);
767+
const verifyStub = sinon.stub(require('../../src/api'), 'verifyResponse').callsFake(verifyResponseStub);
771768

772769
try {
773770
await bitgo.addAccessToken({

modules/sdk-hmac/src/hmac.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ export function calculateHMACSubject<T extends string | Buffer = string>(
4949
let prefixedText: string;
5050
if (statusCode !== undefined && isFinite(statusCode) && Number.isInteger(statusCode)) {
5151
prefixedText =
52-
authVersion === 3 || authVersion === 4
52+
authVersion === 3
5353
? [method.toUpperCase(), timestamp, queryPath, statusCode].join('|')
5454
: [timestamp, queryPath, statusCode].join('|');
5555
} else {
5656
prefixedText =
57-
authVersion === 3 || authVersion === 4
57+
authVersion === 3
5858
? [method.toUpperCase(), timestamp, '3.0', queryPath].join('|')
5959
: [timestamp, queryPath].join('|');
6060
}

0 commit comments

Comments
 (0)