diff options
Diffstat (limited to 'js/globals.ts')
-rw-r--r-- | js/globals.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/js/globals.ts b/js/globals.ts index 765215661..c8289d305 100644 --- a/js/globals.ts +++ b/js/globals.ts @@ -10,6 +10,7 @@ import { window } from "./window"; import * as blob from "./blob"; import * as consoleTypes from "./console"; +import * as csprng from "./get_random_values"; import * as customEvent from "./custom_event"; import * as deno from "./deno"; import * as domTypes from "./dom_types"; @@ -69,6 +70,10 @@ window.console = console; window.setTimeout = timers.setTimeout; window.setInterval = timers.setInterval; window.location = (undefined as unknown) as domTypes.Location; +// The following Crypto interface implementation is not up to par with the +// standard https://www.w3.org/TR/WebCryptoAPI/#crypto-interface as it does not +// yet incorporate the SubtleCrypto interface as its "subtle" property. +window.crypto = (csprng as unknown) as Crypto; // When creating the runtime type library, we use modifications to `window` to // determine what is in the global namespace. When we put a class in the @@ -135,3 +140,19 @@ export interface ImportMeta { url: string; main: boolean; } + +export interface Crypto { + readonly subtle: null; + getRandomValues: < + T extends + | Int8Array + | Uint8Array + | Uint8ClampedArray + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + >( + typedArray: T + ) => T; +} |