Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private fixNativeArguments(method: SubtleMethods, args: any[]) {
const res = [...args];
if (method === "importKey") {
if (res[0]?.toLowerCase?.() === "jwk" && !BufferSourceConverter.isBufferSource(res[1])) {
// IE11 uses ArrayBuffer instead of JSON object
res[1] = Convert.FromUtf8String(JSON.stringify(res[1]));
}
}
if (this.browserInfo.name === Browser.IE && args[1] instanceof WrappedNativeCryptoKey) {
// Fix algs for IE11
switch (method) {
case "sign":
case "verify":
case "encrypt":
case "decrypt":
res[0] = { ...this.prepareAlgorithm(res[0]), hash: (res[1]?.algorithm as RsaHashedKeyAlgorithm)?.hash?.name };
break;
case "wrapKey":
case "unwrapKey":