Skip to content

Commit

Permalink
Fix some small code smells (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottokruse authored Jan 11, 2023
1 parent 7816990 commit ad67178
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/asn1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function decodeLengthValue(blockOfLengthValues: Buffer) {
}
const nrLengthOctets = blockOfLengthValues[0] & 0b01111111;
const length = Buffer.from(
blockOfLengthValues.slice(1, 1 + 1 + nrLengthOctets)
blockOfLengthValues.subarray(1, 1 + 1 + nrLengthOctets)
).readUIntBE(0, nrLengthOctets);
return {
length,
Expand Down Expand Up @@ -287,9 +287,9 @@ function decodeSequence(sequence: Buffer) {
);
}
const { firstByteOffset, lastByteOffset } = decodeLengthValue(
sequence.slice(1)
sequence.subarray(1)
);
const sequenceValue = sequence.slice(
const sequenceValue = sequence.subarray(
1 + firstByteOffset,
1 + 1 + lastByteOffset
);
Expand All @@ -300,8 +300,8 @@ function decodeSequence(sequence: Buffer) {
// is to be done with index operator: [index]
// eslint-disable-next-line security/detect-object-injection
const identifier = decodeIdentifier(sequenceValue[offset]);
const next = decodeLengthValue(sequenceValue.slice(offset + 1));
const value = sequenceValue.slice(
const next = decodeLengthValue(sequenceValue.subarray(offset + 1));
const value = sequenceValue.subarray(
offset + 1 + next.firstByteOffset,
offset + 1 + next.lastByteOffset
);
Expand All @@ -320,7 +320,7 @@ function decodeSequence(sequence: Buffer) {
* @returns Array of identifier-length-value triplets
*/
function decodeBitStringWrappedSequenceValue(bitStringValue: Buffer) {
const wrappedSequence = bitStringValue.slice(1);
const wrappedSequence = bitStringValue.subarray(1);
return decodeSequence(wrappedSequence);
}

Expand Down
5 changes: 2 additions & 3 deletions src/node-web-compat-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ export const nodeWebCompat: NodeWebCompat = {
jwk,
{
name: "RSASSA-PKCS1-v1_5",
hash: JwtSignatureAlgorithmsWebCrypto[
alg as keyof typeof JwtSignatureAlgorithmsWebCrypto
],
// eslint-disable-next-line security/detect-object-injection
hash: JwtSignatureAlgorithmsWebCrypto[alg],
},
false,
["verify"]
Expand Down

0 comments on commit ad67178

Please sign in to comment.