diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml index ff793f9..c23125c 100644 --- a/CHANGELOG.yaml +++ b/CHANGELOG.yaml @@ -5,6 +5,7 @@ unreleased: - >- GH-676 Updated allowed globals list to include: URL, Encoding, Cryptographic, and Stream APIs + - GH-683 Updated allowed globals list to include `Blob` chores: - GH-677 Updated ESLint rules - GH-677 Updated dependencies diff --git a/README.md b/README.md index 95141b1..d4a4bb8 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,13 @@ These are the list of globals available to scripts in the scope ] ``` +### File: +```json +[ + "Blob" +] +``` + ### Cryptography: ```json [ diff --git a/lib/allowed-globals.js b/lib/allowed-globals.js index 7595c6d..2b30380 100644 --- a/lib/allowed-globals.js +++ b/lib/allowed-globals.js @@ -40,6 +40,10 @@ module.exports = [ 'TextDecoder', 'TextDecoderStream', 'TextEncoder', 'TextEncoderStream', + // File + // TODO: Add `File` class once support for node < v20 is dropped + 'Blob', + // Cryptography 'Crypto', 'CryptoKey', 'crypto', 'SubtleCrypto', diff --git a/test/unit/scope-globals.test.js b/test/unit/scope-globals.test.js index 8160bc3..1f4970b 100644 --- a/test/unit/scope-globals.test.js +++ b/test/unit/scope-globals.test.js @@ -16,18 +16,19 @@ describe('scope module globals', function () { scope.exec(` var availableGlobals = Object.getOwnPropertyNames(this).sort(); expect(availableGlobals).eql(['Array', 'ArrayBuffer', 'Atomics', 'atob', 'BigInt', 'BigInt64Array', - 'BigUint64Array', 'Boolean', 'ByteLengthQueuingStrategy', 'CompressionStream', 'CountQueuingStrategy', - 'btoa', 'Crypto', 'CryptoKey', 'crypto', 'DataView', 'Date', 'DecompressionStream', 'decodeURI', - 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'Error', 'escape', 'EvalError', 'Float32Array', - 'Float64Array', 'Function', 'Infinity', 'Int8Array', 'Int16Array', 'Int32Array', 'isFinite', 'isNaN', - 'JSON','Map', 'Math', 'NaN', 'Number', 'Object', 'parseFloat', 'parseInt', 'Proxy', 'Promise', - 'RangeError', 'ReadableByteStreamController', 'ReadableStream', 'ReadableStreamBYOBReader', - 'ReadableStreamBYOBRequest', 'ReadableStreamDefaultController', 'ReadableStreamDefaultReader', - 'ReferenceError', 'Reflect', 'RegExp', 'Set', 'SharedArrayBuffer', 'String', 'SubtleCrypto', 'Symbol', - 'SyntaxError', 'TextDecoder', 'TextDecoderStream', 'TextEncoder', 'TextEncoderStream', - 'TransformStream', 'TransformStreamDefaultController', 'TypeError', 'Uint8Array', 'Uint8ClampedArray', - 'Uint16Array', 'Uint32Array', 'undefined', 'unescape', 'URIError', 'URL', 'URLSearchParams', 'WeakMap', - 'WeakSet', 'WritableStream', 'WritableStreamDefaultController', 'WritableStreamDefaultWriter', + 'BigUint64Array', 'Blob', 'Boolean', 'ByteLengthQueuingStrategy', 'CompressionStream', + 'CountQueuingStrategy', 'btoa', 'Crypto', 'CryptoKey', 'crypto', 'DataView', 'Date', + 'DecompressionStream', 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', + 'Error', 'escape', 'EvalError', 'Float32Array', 'Float64Array', 'Function', 'Infinity', 'Int8Array', + 'Int16Array', 'Int32Array', 'isFinite', 'isNaN', 'JSON','Map', 'Math', 'NaN', 'Number', 'Object', + 'parseFloat', 'parseInt', 'Proxy', 'Promise', 'RangeError', 'ReadableByteStreamController', + 'ReadableStream', 'ReadableStreamBYOBReader', 'ReadableStreamBYOBRequest', + 'ReadableStreamDefaultController', 'ReadableStreamDefaultReader', 'ReferenceError', 'Reflect', 'RegExp', + 'Set', 'SharedArrayBuffer', 'String', 'SubtleCrypto', 'Symbol', 'SyntaxError', 'TextDecoder', + 'TextDecoderStream', 'TextEncoder', 'TextEncoderStream', 'TransformStream', + 'TransformStreamDefaultController', 'TypeError', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', + 'Uint32Array', 'undefined', 'unescape', 'URIError', 'URL', 'URLSearchParams', 'WeakMap', 'WeakSet', + 'WritableStream', 'WritableStreamDefaultController', 'WritableStreamDefaultWriter', 'expect' // special for test ].sort()) `, done);