crypto: allow unbound SubtleCrypto.supports

Static Web IDL operations do not require an interface receiver.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66237
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
This commit is contained in:
Filip Skokan authored and Node.js GitHub Bot committed 2026-09-25 13:23:09 +00:00
1 parent d0cbb41986
commit 3ca28cb44b
3 files changed
+15 -2

No files matched your search

-1
View File
@@ -1759,7 +1759,6 @@ class SubtleCrypto {
// Implements https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-supports
static supports(operation, algorithm, lengthOrAdditionalAlgorithm = null) {
emitExperimentalWarning('The supports Web Crypto API method');
if (this !== SubtleCrypto) throw new ERR_INVALID_THIS('SubtleCrypto constructor');
webidl ??= require('internal/crypto/webidl');
const prefix = "Failed to execute 'supports' on 'SubtleCrypto'";
webidl.requiredArguments(arguments.length, 2, { prefix });
+1 -1
View File
@@ -142,7 +142,7 @@ const notSubtle = Reflect.construct(function() {}, [], SubtleCrypto);
// Test SubtleCrypto.supports
{
assert.throws(() => SubtleCrypto.supports.call(undefined), {
name: 'TypeError', code: 'ERR_INVALID_THIS',
name: 'TypeError', code: 'ERR_MISSING_ARGS',
});
}
@@ -0,0 +1,14 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const { supports } = SubtleCrypto;
assert.strictEqual(supports('digest', 'SHA-256'), true);
for (const receiver of [undefined, null, {}, globalThis.crypto.subtle]) {
assert.strictEqual(supports.call(receiver, 'digest', 'SHA-256'), true);
assert.strictEqual(supports.call(receiver, 'digest', 'unknown'), false);
}