| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bdbb676 commit c37a119
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1930,8 +1930,8 @@ added: v15.0.0 | |||
| 1930 | 1930 | Example: Converting a `CryptoKey` instance to a `KeyObject`: | |
| 1931 | 1931 | ||
| 1932 | 1932 | ```mjs | |
| 1933 | - const { webcrypto, KeyObject } = await import('node:crypto'); | ||
| 1934 | - const { subtle } = webcrypto; | ||
| 1933 | + const { KeyObject } = await import('node:crypto'); | ||
| 1934 | + const { subtle } = globalThis.crypto; | ||
| 1935 | 1935 | ||
| 1936 | 1936 | const key = await subtle.generateKey({ | |
| 1937 | 1937 | name: 'HMAC', | |
@@ -1945,12 +1945,8 @@ console.log(keyObject.symmetricKeySize); | |||
| 1945 | 1945 | ``` | |
| 1946 | 1946 | ||
| 1947 | 1947 | ```cjs | |
| 1948 | - const { | ||
| 1949 | - webcrypto: { | ||
| 1950 | - subtle, | ||
| 1951 | - }, | ||
| 1952 | - KeyObject, | ||
| 1953 | - } = require('node:crypto'); | ||
| 1948 | + const { KeyObject } = require('node:crypto'); | ||
| 1949 | + const { subtle } = globalThis.crypto; | ||
| 1954 | 1950 | ||
| 1955 | 1951 | (async function() { | |
| 1956 | 1952 | const key = await subtle.generateKey({ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -310,12 +310,12 @@ crypto.randomFill(buf, (err, buf) => { | |||
| 310 | 310 | For the legacy Node.js crypto API, asynchronous single-call | |
| 311 | 311 | operations use the traditional Node.js callback pattern, as | |
| 312 | 312 | illustrated in the previous `randomFill()` example. In the | |
| 313 | - Web Crypto API (accessible via `require('node:crypto').webcrypto`), | ||
| 313 | + Web Crypto API (accessible via `globalThis.crypto`), | ||
| 314 | 314 | all asynchronous single-call operations are Promise-based. | |
| 315 | 315 | ||
| 316 | 316 | ```js | |
| 317 | 317 | // Example Web Crypto API asynchronous single-call operation | |
| 318 | - const { subtle } = require('node:crypto').webcrypto; | ||
| 318 | + const { subtle } = globalThis.crypto; | ||
| 319 | 319 | ||
| 320 | 320 | subtle.generateKeys({ name: 'HMAC', length: 256 }, true, ['sign']) | |
| 321 | 321 | .then((key) => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments