GeezerVison is showing github.com — crypto: allow unbound SubtleCrypto.supports · nodejs/node@0346e4e
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/crypto/webcrypto.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1761,7 +1761,6 @@ class SubtleCrypto { | 1761 | 1761 | // TODO(panva): Make supports() account for the active FIPS state. | 1762 | 1762 | static supports(operation, algorithm, lengthOrAdditionalAlgorithm = null) { | 1763 | 1763 | emitExperimentalWarning('The supports Web Crypto API method'); | 1764 | | - if (this !== SubtleCrypto) throw new ERR_INVALID_THIS('SubtleCrypto constructor'); | 1765 | 1764 | webidl ??= require('internal/crypto/webidl'); | 1766 | 1765 | const prefix = "Failed to execute 'supports' on 'SubtleCrypto'"; | 1767 | 1766 | webidl.requiredArguments(arguments.length, 2, { prefix }); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-constructors.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -142,7 +142,7 @@ const notSubtle = Reflect.construct(function() {}, [], SubtleCrypto); | 142 | 142 | // Test SubtleCrypto.supports | 143 | 143 | { | 144 | 144 | assert.throws(() => SubtleCrypto.supports.call(undefined), { | 145 | | - name: 'TypeError', code: 'ERR_INVALID_THIS', | | 145 | + name: 'TypeError', code: 'ERR_MISSING_ARGS', | 146 | 146 | }); | 147 | 147 | } | 148 | 148 |
| |
Collapse file Copy file name to clipboard +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +'use strict'; | | 2 | + | | 3 | +const common = require('../common'); | | 4 | +if (!common.hasCrypto) | | 5 | + common.skip('missing crypto'); | | 6 | + | | 7 | +const assert = require('assert'); | | 8 | +const { supports } = SubtleCrypto; | | 9 | + | | 10 | +assert.strictEqual(supports('digest', 'SHA-256'), true); | | 11 | +for (const receiver of [undefined, null, {}, globalThis.crypto.subtle]) { | | 12 | + assert.strictEqual(supports.call(receiver, 'digest', 'SHA-256'), true); | | 13 | + assert.strictEqual(supports.call(receiver, 'digest', 'unknown'), false); | | 14 | +} |
|