Fix DeriveECDHKeyMaterial lint: brace-style, indentation, operator-linebreak, constructor JSDoc
This commit is contained in:
parent
718824a42f
commit
b2e3100886
@ -75,7 +75,10 @@ function concatBytes(parts) {
|
|||||||
const total = parts.reduce((sum, p) => sum + p.length, 0);
|
const total = parts.reduce((sum, p) => sum + p.length, 0);
|
||||||
const out = new Uint8Array(total);
|
const out = new Uint8Array(total);
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
for (const p of parts) { out.set(p, offset); offset += p.length; }
|
for (const p of parts) {
|
||||||
|
out.set(p, offset);
|
||||||
|
offset += p.length;
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +118,9 @@ async function concatKdf(rawSecret, sharedInfo, hashAlg, outputLen) {
|
|||||||
*/
|
*/
|
||||||
class DeriveECDHKeyMaterial extends Operation {
|
class DeriveECDHKeyMaterial extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DeriveECDHKeyMaterial constructor.
|
||||||
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -218,9 +224,9 @@ class DeriveECDHKeyMaterial extends Operation {
|
|||||||
if (!globalThis.crypto || !globalThis.crypto.subtle)
|
if (!globalThis.crypto || !globalThis.crypto.subtle)
|
||||||
throw new OperationError("WebCrypto is not available in this runtime.");
|
throw new OperationError("WebCrypto is not available in this runtime.");
|
||||||
|
|
||||||
const privateDer = privateFmt === "PEM"
|
const privateDer = privateFmt === "PEM" ?
|
||||||
? parsePrivateKey(input)
|
parsePrivateKey(input) :
|
||||||
: parsePemOrHex(input, "HEX", "PRIVATE KEY");
|
parsePemOrHex(input, "HEX", "PRIVATE KEY");
|
||||||
|
|
||||||
const publicDer = parsePemOrHex(
|
const publicDer = parsePemOrHex(
|
||||||
peerPublicKey,
|
peerPublicKey,
|
||||||
@ -235,9 +241,9 @@ class DeriveECDHKeyMaterial extends Operation {
|
|||||||
(sharedInfoHexNorm.length > 0 && !/^[0-9a-fA-F]+$/.test(sharedInfoHexNorm)))
|
(sharedInfoHexNorm.length > 0 && !/^[0-9a-fA-F]+$/.test(sharedInfoHexNorm)))
|
||||||
throw new OperationError("Shared info must be hex.");
|
throw new OperationError("Shared info must be hex.");
|
||||||
|
|
||||||
const sharedInfo = sharedInfoHexNorm.length
|
const sharedInfo = sharedInfoHexNorm.length ?
|
||||||
? new Uint8Array(sharedInfoHexNorm.match(/.{2}/g).map(h => parseInt(h, 16)))
|
new Uint8Array(sharedInfoHexNorm.match(/.{2}/g).map(h => parseInt(h, 16))) :
|
||||||
: new Uint8Array();
|
new Uint8Array();
|
||||||
|
|
||||||
const privateKey = await crypto.subtle.importKey(
|
const privateKey = await crypto.subtle.importKey(
|
||||||
"pkcs8", privateDer,
|
"pkcs8", privateDer,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user