Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/crypto/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ class CryptoKey {
get type() {
if (!(this instanceof CryptoKey))
throw new ERR_INVALID_THIS('CryptoKey');
return this[kKeyObject].type;
return this[kKeyObject]?.type;
}

get extractable() {
Expand Down
27 changes: 27 additions & 0 deletions test/parallel/test-crypto-inspect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
}

const { subtle } = require('crypto');
const { strictEqual } = require('assert');
const { inspect } = require('util');

const promise = subtle.importKey('raw', Buffer.from([1, 2, 3]), {
name: 'HMAC', hash: 'SHA-256'
}, true, ['sign', 'verify']);

promise.then(common.mustCall((key) => {
const inspected = inspect(Object.getPrototypeOf(key));
strictEqual(
inspected,
'CryptoKey {\n' +
' type: undefined,\n' +
' extractable: undefined,\n' +
' algorithm: undefined,\n' +
' usages: undefined\n' +
'}'
);
}));
Loading