Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8b22310

Browse filesBrowse files
panvaRafaelGSS
authored andcommitted
crypto: add CryptoKey Symbol.toStringTag
closes #45987 PR-URL: #46042 Fixes: #45987 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
1 parent e5f53b5 commit 8b22310
Copy full SHA for 8b22310

File tree

Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/crypto/keys.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/keys.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,11 @@ ObjectDefineProperties(CryptoKey.prototype, {
696696
extractable: kEnumerableProperty,
697697
algorithm: kEnumerableProperty,
698698
usages: kEnumerableProperty,
699+
[SymbolToStringTag]: {
700+
__proto__: null,
701+
configurable: true,
702+
value: 'CryptoKey',
703+
},
699704
});
700705

701706
// All internal code must use new InternalCryptoKey to create
Collapse file

‎test/parallel/test-webcrypto-keygen.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-keygen.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ const vectors = {
277277

278278
assert.strictEqual(publicKey.type, 'public');
279279
assert.strictEqual(privateKey.type, 'private');
280+
assert.strictEqual(publicKey.toString(), '[object CryptoKey]');
281+
assert.strictEqual(privateKey.toString(), '[object CryptoKey]');
280282
assert.strictEqual(publicKey.extractable, true);
281283
assert.strictEqual(privateKey.extractable, true);
282284
assert.deepStrictEqual(publicKey.usages, publicUsages);
@@ -439,6 +441,8 @@ const vectors = {
439441

440442
assert.strictEqual(publicKey.type, 'public');
441443
assert.strictEqual(privateKey.type, 'private');
444+
assert.strictEqual(publicKey.toString(), '[object CryptoKey]');
445+
assert.strictEqual(privateKey.toString(), '[object CryptoKey]');
442446
assert.strictEqual(publicKey.extractable, true);
443447
assert.strictEqual(privateKey.extractable, true);
444448
assert.deepStrictEqual(publicKey.usages, publicUsages);
@@ -503,6 +507,7 @@ const vectors = {
503507
assert(isCryptoKey(key));
504508

505509
assert.strictEqual(key.type, 'secret');
510+
assert.strictEqual(key.toString(), '[object CryptoKey]');
506511
assert.strictEqual(key.extractable, true);
507512
assert.deepStrictEqual(key.usages, usages);
508513
assert.strictEqual(key.algorithm.name, name);
@@ -562,6 +567,7 @@ const vectors = {
562567
assert(isCryptoKey(key));
563568

564569
assert.strictEqual(key.type, 'secret');
570+
assert.strictEqual(key.toString(), '[object CryptoKey]');
565571
assert.strictEqual(key.extractable, true);
566572
assert.deepStrictEqual(key.usages, usages);
567573
assert.strictEqual(key.algorithm.name, 'HMAC');
@@ -629,6 +635,8 @@ assert.throws(() => new CryptoKey(), { code: 'ERR_ILLEGAL_CONSTRUCTOR' });
629635

630636
assert.strictEqual(publicKey.type, 'public');
631637
assert.strictEqual(privateKey.type, 'private');
638+
assert.strictEqual(publicKey.toString(), '[object CryptoKey]');
639+
assert.strictEqual(privateKey.toString(), '[object CryptoKey]');
632640
assert.strictEqual(publicKey.extractable, true);
633641
assert.strictEqual(privateKey.extractable, true);
634642
assert.deepStrictEqual(publicKey.usages, publicUsages);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.