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

Method supports

lib/internal/crypto/webcrypto.js:1607–1767  ·  view source on GitHub ↗
(operation, algorithm, lengthOrAdditionalAlgorithm = null)

Source from the content-addressed store, hash-verified

1605
1606 // Implements https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-supports
1607 static supports(operation, algorithm, lengthOrAdditionalAlgorithm = null) {
1608 emitExperimentalWarning('The supports Web Crypto API method');
1609 if (this !== SubtleCrypto) throw new ERR_INVALID_THIS('SubtleCrypto constructor');
1610 webidl ??= require('internal/crypto/webidl');
1611 const prefix = "Failed to execute 'supports' on 'SubtleCrypto'";
1612 webidl.requiredArguments(arguments.length, 2, { prefix });
1613
1614 operation = webidl.converters.DOMString(operation, {
1615 prefix,
1616 context: '1st argument',
1617 });
1618 algorithm = webidl.converters.AlgorithmIdentifier(algorithm, {
1619 prefix,
1620 context: '2nd argument',
1621 });
1622
1623 switch (operation) {
1624 case 'decapsulateBits':
1625 case 'decapsulateKey':
1626 case 'decrypt':
1627 case 'deriveBits':
1628 case 'deriveKey':
1629 case 'digest':
1630 case 'encapsulateBits':
1631 case 'encapsulateKey':
1632 case 'encrypt':
1633 case 'exportKey':
1634 case 'generateKey':
1635 case 'getPublicKey':
1636 case 'importKey':
1637 case 'sign':
1638 case 'unwrapKey':
1639 case 'verify':
1640 case 'wrapKey':
1641 break;
1642 default:
1643 return false;
1644 }
1645
1646 let length;
1647 let additionalAlgorithm;
1648 if (operation === 'deriveKey') {
1649 additionalAlgorithm = webidl.converters.AlgorithmIdentifier(
1650 lengthOrAdditionalAlgorithm,
1651 {
1652 prefix,
1653 context: '3rd argument',
1654 },
1655 );
1656
1657 if (!check('importKey', additionalAlgorithm)) {
1658 return false;
1659 }
1660
1661 try {
1662 length = getKeyLength(normalizeAlgorithm(additionalAlgorithm, 'get key length'));
1663 } catch {
1664 return false;

Calls 7

emitExperimentalWarningFunction · 0.85
getKeyLengthFunction · 0.85
numBitsToBytesFunction · 0.85
DOMStringMethod · 0.80
checkFunction · 0.70
normalizeAlgorithmFunction · 0.70
requireFunction · 0.50

Tested by

no test coverage detected