mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 16:42:21 -05:00
fix(ext/crypto): handle idlValue not being present (#11685)
This commit is contained in:
parent
74d523e924
commit
c6e3f93ebb
1 changed files with 7 additions and 2 deletions
|
@ -88,6 +88,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
// See https://www.w3.org/TR/WebCryptoAPI/#dfn-normalize-an-algorithm
|
// See https://www.w3.org/TR/WebCryptoAPI/#dfn-normalize-an-algorithm
|
||||||
|
// 18.4.4
|
||||||
function normalizeAlgorithm(algorithm, op) {
|
function normalizeAlgorithm(algorithm, op) {
|
||||||
if (typeof algorithm == "string") {
|
if (typeof algorithm == "string") {
|
||||||
return normalizeAlgorithm({ name: algorithm }, op);
|
return normalizeAlgorithm({ name: algorithm }, op);
|
||||||
|
@ -125,18 +126,22 @@
|
||||||
return { name: algName };
|
return { name: algName };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 6.
|
||||||
const normalizedAlgorithm = webidl.converters[desiredType](algorithm, {
|
const normalizedAlgorithm = webidl.converters[desiredType](algorithm, {
|
||||||
prefix: "Failed to normalize algorithm",
|
prefix: "Failed to normalize algorithm",
|
||||||
context: "passed algorithm",
|
context: "passed algorithm",
|
||||||
});
|
});
|
||||||
|
// 7.
|
||||||
normalizedAlgorithm.name = algName;
|
normalizedAlgorithm.name = algName;
|
||||||
|
|
||||||
|
// 9.
|
||||||
const dict = simpleAlgorithmDictionaries[desiredType];
|
const dict = simpleAlgorithmDictionaries[desiredType];
|
||||||
|
// 10.
|
||||||
for (const member in dict) {
|
for (const member in dict) {
|
||||||
const idlType = dict[member];
|
const idlType = dict[member];
|
||||||
const idlValue = normalizedAlgorithm[member];
|
const idlValue = normalizedAlgorithm[member];
|
||||||
|
// 3.
|
||||||
if (idlType === "BufferSource") {
|
if (idlType === "BufferSource" && idlValue) {
|
||||||
normalizedAlgorithm[member] = new Uint8Array(
|
normalizedAlgorithm[member] = new Uint8Array(
|
||||||
TypedArrayPrototypeSlice(
|
TypedArrayPrototypeSlice(
|
||||||
(ArrayBufferIsView(idlValue) ? idlValue.buffer : idlValue),
|
(ArrayBufferIsView(idlValue) ? idlValue.buffer : idlValue),
|
||||||
|
|
Loading…
Reference in a new issue