mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
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:
1 parent
d0cbb41986
commit
3ca28cb44b
3 files changed
+15
-2
No files matched your search
@@ -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 });
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user