chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { afterAll, afterEach, beforeAll } from 'vitest';
|
||||
import nock from 'nock';
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
nock.enableNetConnect((host) => host.startsWith('127.0.0.1'));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.enableNetConnect();
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
const nodeCrypto = require('crypto');
|
||||
const { webcrypto } = nodeCrypto;
|
||||
|
||||
if (typeof globalThis.crypto?.getRandomValues !== 'function') {
|
||||
Object.defineProperty(globalThis, 'crypto', {
|
||||
configurable: true,
|
||||
value: webcrypto,
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof nodeCrypto.getRandomValues !== 'function') {
|
||||
nodeCrypto.getRandomValues = webcrypto.getRandomValues.bind(webcrypto);
|
||||
}
|
||||
|
||||
if (typeof globalThis.ReadableStream !== 'function') {
|
||||
const webStreams = require('stream/web');
|
||||
|
||||
for (const name of ['ReadableStream', 'WritableStream', 'TransformStream']) {
|
||||
if (
|
||||
typeof globalThis[name] !== 'function' &&
|
||||
typeof webStreams[name] === 'function'
|
||||
) {
|
||||
Object.defineProperty(globalThis, name, {
|
||||
configurable: true,
|
||||
value: webStreams[name],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user