| 459 | // Also builds a parallel Map<UPPERCASED_NAME, canonicalName> per operation |
| 460 | // for O(1) case-insensitive algorithm name lookup in normalizeAlgorithm. |
| 461 | function createSupportedAlgorithms(algorithmDefs) { |
| 462 | const result = {}; |
| 463 | const nameMap = {}; |
| 464 | |
| 465 | for (const { 0: algorithmName, 1: operations } of ObjectEntries(algorithmDefs)) { |
| 466 | // Skip algorithms that are conditionally not supported |
| 467 | if (ObjectPrototypeHasOwnProperty(conditionalAlgorithms, algorithmName) && |
| 468 | !conditionalAlgorithms[algorithmName]) { |
| 469 | continue; |
| 470 | } |
| 471 | |
| 472 | for (const { 0: operation, 1: dict } of ObjectEntries(operations)) { |
| 473 | result[operation] ||= {}; |
| 474 | nameMap[operation] ||= new SafeMap(); |
| 475 | nameMap[operation].set(StringPrototypeToUpperCase(algorithmName), algorithmName); |
| 476 | |
| 477 | // Add experimental warnings for experimental algorithms |
| 478 | if (ArrayPrototypeIncludes(experimentalAlgorithms, algorithmName)) { |
| 479 | ObjectDefineProperty(result[operation], algorithmName, { |
| 480 | get() { |
| 481 | emitExperimentalWarning(`The ${algorithmName} Web Crypto API algorithm`); |
| 482 | return dict; |
| 483 | }, |
| 484 | __proto__: null, |
| 485 | enumerable: true, |
| 486 | }); |
| 487 | } else { |
| 488 | result[operation][algorithmName] = dict; |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | return { algorithms: result, nameMap }; |
| 494 | } |
| 495 | |
| 496 | const { algorithms: kSupportedAlgorithms, nameMap: kAlgorithmNameMap } = |
| 497 | createSupportedAlgorithms(kAlgorithmDefinitions); |