doc: mark Certificate methods as static, add missing KeyObject.from

PR-URL: https://github.com/nodejs/node/pull/37198
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
Filip Skokan committed 2021-02-05 21:01:09 +01:00
1 parent 931c2d161e
commit e8286bbd71
1 file changed
+29 -3
+29 -3
View File
@@ -53,7 +53,7 @@ The `crypto` module provides the `Certificate` class for working with SPKAC
data. The most common usage is handling output generated by the HTML5
`<keygen>` element. Node.js uses [OpenSSL's SPKAC implementation][] internally.
### `Certificate.exportChallenge(spkac[, encoding])`
### Static method: `Certificate.exportChallenge(spkac[, encoding])`
<!-- YAML
added: v9.0.0
changes:
@@ -76,7 +76,7 @@ console.log(challenge.toString('utf8'));
// Prints: the challenge as a UTF8 string
```
### `Certificate.exportPublicKey(spkac[, encoding])`
### Static method: `Certificate.exportPublicKey(spkac[, encoding])`
<!-- YAML
added: v9.0.0
changes:
@@ -99,7 +99,7 @@ console.log(publicKey);
// Prints: the public key as <Buffer ...>
```
### `Certificate.verifySpkac(spkac[, encoding])`
### Static method: `Certificate.verifySpkac(spkac[, encoding])`
<!-- YAML
added: v9.0.0
changes:
@@ -1284,6 +1284,32 @@ passing keys as strings or `Buffer`s due to improved security features.
The receiver obtains a cloned `KeyObject`, and the `KeyObject` does not need to
be listed in the `transferList` argument.
### Static method: `KeyObject.from(key)`
<!-- YAML
added: v15.0.0
-->
* `key` {CryptoKey}
* Returns: {KeyObject}
Example: Converting a `CryptoKey` instance to a `KeyObject`:
```js
const { webcrypto: { subtle }, KeyObject } = require('crypto');
(async function() {
const key = await subtle.generateKey({
name: 'HMAC',
hash: 'SHA-256',
length: 256
}, true, ['sign', 'verify']);
const keyObject = KeyObject.from(key);
console.log(keyObject.symmetricKeySize);
// Prints: 32 (symmetric key size in bytes)
})();
```
### `keyObject.asymmetricKeyDetails`
<!-- YAML
added: v15.7.0