diff --git a/README.md b/README.md index 6b8660bdf..ce3cc1de4 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ OpenPGP.js [![BrowserStack Status](https://automate.browserstack.com/badge.svg?b - [Performance](#performance) - [Getting started](#getting-started) - [Node.js](#nodejs) + - [Deno (experimental)](#deno-experimental) - [Browser (webpack)](#browser-webpack) - [Browser (plain files)](#browser-plain-files) - [Examples](#examples) @@ -109,6 +110,14 @@ Or as an ES6 module, from an .mjs file: import * as openpgp from 'openpgp'; ``` +#### Deno (experimental) + +Import as an ES6 module, using /dist/openpgp.mjs. + +```js +import * as openpgp from './openpgpjs/dist/openpgp.mjs'; +``` + #### Browser (webpack) Install OpenPGP.js using npm and save it in your devDependencies: diff --git a/src/crypto/hash/index.js b/src/crypto/hash/index.js index cfec8d381..33cd4c089 100644 --- a/src/crypto/hash/index.js +++ b/src/crypto/hash/index.js @@ -77,7 +77,7 @@ if (nodeCrypto) { // Use Node native crypto for all hash functions } else { // Use JS fallbacks hashFunctions = { md5: md5, - sha1: asmcryptoHash(Sha1, navigator.userAgent.indexOf('Edge') === -1 && 'SHA-1'), + sha1: asmcryptoHash(Sha1, (!navigator.userAgent || navigator.userAgent.indexOf('Edge') === -1) && 'SHA-1'), sha224: hashjsHash(sha224), sha256: asmcryptoHash(Sha256, 'SHA-256'), sha384: hashjsHash(sha384, 'SHA-384'), diff --git a/src/crypto/mode/eax.js b/src/crypto/mode/eax.js index cf68c4600..024ea6f76 100644 --- a/src/crypto/mode/eax.js +++ b/src/crypto/mode/eax.js @@ -51,7 +51,7 @@ async function CTR(key) { if ( util.getWebCrypto() && key.length !== 24 && // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support - navigator.userAgent.indexOf('Edge') === -1 + (!navigator.userAgent || navigator.userAgent.indexOf('Edge') === -1) ) { key = await webCrypto.importKey('raw', key, { name: 'AES-CTR', length: key.length * 8 }, false, ['encrypt']); return async function(pt, iv) { diff --git a/src/crypto/mode/gcm.js b/src/crypto/mode/gcm.js index 424b7e1af..1155cfe19 100644 --- a/src/crypto/mode/gcm.js +++ b/src/crypto/mode/gcm.js @@ -56,7 +56,7 @@ async function GCM(cipher, key) { !pt.length || // iOS does not support GCM-en/decrypting empty messages // Also, synchronous en/decryption might be faster in this case. - (!adata.length && navigator.userAgent.indexOf('Edge') !== -1) + (!adata.length && navigator.userAgent && navigator.userAgent.indexOf('Edge') !== -1) // Edge does not support GCM-en/decrypting without ADATA ) { return AES_GCM.encrypt(pt, key, iv, adata); @@ -70,7 +70,7 @@ async function GCM(cipher, key) { ct.length === tagLength || // iOS does not support GCM-en/decrypting empty messages // Also, synchronous en/decryption might be faster in this case. - (!adata.length && navigator.userAgent.indexOf('Edge') !== -1) + (!adata.length && navigator.userAgent && navigator.userAgent.indexOf('Edge') !== -1) // Edge does not support GCM-en/decrypting without ADATA ) { return AES_GCM.decrypt(ct, key, iv, adata); diff --git a/test/worker/application_worker.js b/test/worker/application_worker.js index f40dd9f55..e34188b25 100644 --- a/test/worker/application_worker.js +++ b/test/worker/application_worker.js @@ -12,7 +12,7 @@ module.exports = () => tryTests('Application Worker', tests, { function tests() { it('Should support loading OpenPGP.js from inside a Web Worker', async function() { - if (/Edge/.test(navigator.userAgent)) { + if (navigator.userAgent && /Edge/.test(navigator.userAgent)) { this.skip(); // Old Edge doesn't support crypto.getRandomValues inside a Worker. } try {