MCPcopy Index your code
hub / github.com/nodejs/node / createSupportedAlgorithms

Function createSupportedAlgorithms

lib/internal/crypto/util.js:461–494  ·  view source on GitHub ↗
(algorithmDefs)

Source from the content-addressed store, hash-verified

459// Also builds a parallel Map<UPPERCASED_NAME, canonicalName> per operation
460// for O(1) case-insensitive algorithm name lookup in normalizeAlgorithm.
461function 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
496const { algorithms: kSupportedAlgorithms, nameMap: kAlgorithmNameMap } =
497 createSupportedAlgorithms(kAlgorithmDefinitions);

Callers 1

util.jsFile · 0.85

Calls 1

setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…