{"version":3,"file":"MsrBrowserCrypto.js","sources":["../../src/crypto/MsrBrowserCrypto.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { KEY_FORMAT_JWK } from \"../utils/BrowserConstants\";\nimport { ISubtleCrypto } from \"./ISubtleCrypto\";\n\ndeclare global {\n interface Window {\n msrCrypto: Crypto & {\n initPrng: (entropy: Uint8Array | number[]) => void\n }\n }\n}\n\nexport class MsrBrowserCrypto implements ISubtleCrypto {\n initPrng(entropy : Uint8Array): void {\n // Turn into array, as initPrng seems to not always like Uint8Array (even though it should support both)\n return window.msrCrypto.initPrng([...entropy]);\n }\n\n getRandomValues(dataBuffer: Uint8Array): Uint8Array {\n return window.msrCrypto.getRandomValues(dataBuffer);\n }\n\n async generateKey(algorithm: RsaHashedKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {\n return window.msrCrypto.subtle.generateKey(algorithm, extractable, keyUsages) as Promise;\n }\n\n async exportKey(key: CryptoKey): Promise {\n return window.msrCrypto.subtle.exportKey(KEY_FORMAT_JWK, key) as Promise as Promise;\n }\n\n async importKey(keyData: JsonWebKey, algorithm: RsaHashedImportParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {\n return window.msrCrypto.subtle.importKey(KEY_FORMAT_JWK, keyData, algorithm, extractable, keyUsages) as Promise;\n }\n\n async sign(algorithm: AlgorithmIdentifier, key: CryptoKey, data: ArrayBuffer): Promise {\n return window.msrCrypto.subtle.sign(algorithm, key, data) as Promise;\n }\n\n async digest(algorithm: AlgorithmIdentifier, data: Uint8Array): Promise {\n return window.msrCrypto.subtle.digest(algorithm, data) as Promise; \n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;IAgBA;KA6BC;IA5BG,mCAAQ,GAAR,UAAS,OAAoB;;QAEzB,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,UAAK,OAAO,EAAE,CAAC;KAClD;IAED,0CAAe,GAAf,UAAgB,UAA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