Update ESlint

This commit is contained in:
larabr 2023-02-21 14:54:46 +01:00
parent 1b17132631
commit 705f238e1e
53 changed files with 2258 additions and 3673 deletions

View File

@ -1,4 +1,4 @@
dist
test/lib/
test/typescript/definitions.js
test/typescript/
docs

View File

@ -1,356 +1,358 @@
module.exports = {
"extends": "airbnb-base",
"parser": "babel-eslint",
"parserOptions": { "sourceType": "module" },
"env": {
"browser": true,
"es6": true,
"node": true
'extends': 'airbnb-base',
'parserOptions': {
'ecmaVersion': 11,
'sourceType': 'module'
},
"plugins": [
"chai-friendly",
"import"
'env': {
'browser': true,
'es6': true,
'node': true
},
'plugins': [
'chai-friendly',
'import'
],
"globals": { // TODO are all these necessary?
"globalThis": true,
"console": true,
"Promise": true,
"importScripts": true,
"process": true,
"Event": true,
"describe": true,
"it": true,
"sinon": true,
"mocha": true,
"before": true,
"beforeEach": true,
"after": true,
"afterEach": true,
"escape": true,
"unescape": true,
"postMessage": true,
"resolves": true,
"rejects": true,
"TransformStream": true,
"BigInt": true
'globals': { // TODO are all these necessary?
'globalThis': true,
'console': true,
'Promise': true,
'importScripts': true,
'process': true,
'Event': true,
'describe': true,
'it': true,
'mocha': true,
'before': true,
'beforeEach': true,
'after': true,
'afterEach': true,
'escape': true,
'unescape': true,
'resolves': true,
'rejects': true,
'TransformStream': true,
'BigInt': true
},
"rules": {
'rules': {
// Auto generated rules:
"accessor-pairs": "error",
"array-bracket-newline": "error",
"array-bracket-spacing": [
"error",
"never"
'accessor-pairs': 'error',
'array-bracket-newline': 'error',
'array-bracket-spacing': [
'error',
'never'
],
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": "off",
"arrow-parens": [
"error",
"as-needed"
'array-callback-return': 'error',
'array-element-newline': 'off',
'arrow-body-style': 'off',
'arrow-parens': [
'error',
'as-needed'
],
"arrow-spacing": [
"error",
'arrow-spacing': [
'error',
{
"after": true,
"before": true
'after': true,
'before': true
}
],
"block-spacing": [
"error",
"always"
'block-spacing': [
'error',
'always'
],
"brace-style": "off",
"callback-return": "error",
"camelcase": [
"error",
'brace-style': 'off',
'callback-return': 'error',
'camelcase': [
'error',
{
"properties": "never"
'properties': 'never'
}
],
"capitalized-comments": "off",
"class-methods-use-this": "off",
"comma-dangle": [ "error", "never" ],
"comma-spacing": "off",
"comma-style": [
"error",
"last"
'capitalized-comments': 'off',
'class-methods-use-this': 'off',
'comma-dangle': [ 'error', 'never' ],
'comma-spacing': 'off',
'comma-style': [
'error',
'last'
],
"complexity": "off",
"computed-property-spacing": [
"error",
"never"
'complexity': 'off',
'computed-property-spacing': [
'error',
'never'
],
"consistent-return": "off",
"consistent-this": "error",
"curly": "error",
"default-case": "off",
"dot-location": "error",
"dot-notation": [
"error",
'consistent-return': 'off',
'consistent-this': 'error',
'curly': 'error',
'default-case': 'off',
'default-param-last': 'off',
'dot-location': 'error',
'dot-notation': [
'error',
{
"allowKeywords": true
'allowKeywords': true
}
],
"eol-last": ["error", "always"],
"eqeqeq": "error",
"for-direction": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": [
"error",
"never"
'eol-last': ['error', 'always'],
'eqeqeq': 'error',
'for-direction': 'error',
'func-call-spacing': 'error',
'function-call-argument-newline': 'off',
'func-name-matching': 'error',
'func-names': [
'error',
'never'
],
"func-style": "off",
"function-paren-newline": "off",
"generator-star-spacing": "error",
"getter-return": "error",
"global-require": "off",
"guard-for-in": "off",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": [
"error",
"beside"
'func-style': 'off',
'function-paren-newline': 'off',
'generator-star-spacing': 'error',
'getter-return': 'error',
'global-require': 'off',
'guard-for-in': 'off',
'handle-callback-err': 'error',
'id-blacklist': 'error',
'id-length': 'off',
'id-match': 'error',
'implicit-arrow-linebreak': [
'error',
'beside'
],
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": "error",
"line-comment-position": "off",
"linebreak-style": [
"error",
"unix"
'init-declarations': 'off',
'jsx-quotes': 'error',
'key-spacing': 'off',
'keyword-spacing': 'error',
'line-comment-position': 'off',
'linebreak-style': [
'error',
'unix'
],
"lines-around-comment": "off",
"lines-around-directive": "error",
"lines-between-class-members": "error",
"max-depth": "off",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "error",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": "off",
"multiline-ternary": "off",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"no-alert": "error",
"no-array-constructor": "error",
"no-bitwise": "off",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-continue": "off",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty": [
"error",
'lines-around-comment': 'off',
'lines-around-directive': 'error',
'lines-between-class-members': 'error',
'max-classes-per-file': 'off',
'max-depth': 'off',
'max-len': 'off',
'max-lines': 'off',
'max-nested-callbacks': 'error',
'max-params': 'off',
'max-statements': 'off',
'max-statements-per-line': 'off',
'multiline-comment-style': 'off',
'multiline-ternary': 'off',
'new-parens': 'error',
'newline-after-var': 'off',
'newline-before-return': 'off',
'newline-per-chained-call': 'off',
'no-alert': 'error',
'no-array-constructor': 'error',
'no-bitwise': 'off',
'no-buffer-constructor': 'error',
'no-caller': 'error',
'no-catch-shadow': 'error',
'no-confusing-arrow': 'error',
'no-continue': 'off',
'no-div-regex': 'error',
'no-duplicate-imports': 'error',
'no-else-return': 'off',
'no-empty': [
'error',
{
"allowEmptyCatch": true
'allowEmptyCatch': true
}
],
"no-empty-function": "off",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": [
"error",
"functions"
'no-empty-function': 'off',
'no-eq-null': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-label': 'error',
'no-extra-parens': 'off',
'no-floating-decimal': 'error',
'no-implicit-globals': 'error',
'no-implied-eval': 'error',
'no-inline-comments': 'off',
'no-inner-declarations': [
'error',
'functions'
],
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "off",
"no-mixed-requires": "error",
"no-multi-assign": "error",
"no-multi-spaces": [
"error",
'no-invalid-this': 'error',
'no-iterator': 'error',
'no-label-var': 'error',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-lonely-if': 'error',
'no-loop-func': 'error',
'no-magic-numbers': 'off',
'no-mixed-operators': 'off',
'no-mixed-requires': 'error',
'no-multi-assign': 'error',
'no-multi-spaces': [
'error',
{
"ignoreEOLComments": true
'ignoreEOLComments': true
}
],
"no-multi-str": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF":0 }],
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "off",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "off",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"],
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-undef-init": "error",
"no-undefined": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": [
"error",
'no-multi-str': 'error',
'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 1, 'maxBOF':0 }],
'no-native-reassign': 'error',
'no-negated-condition': 'off',
'no-negated-in-lhs': 'error',
'no-nested-ternary': 'off',
'no-new': 'error',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-require': 'error',
'no-new-wrappers': 'error',
'no-octal-escape': 'error',
'no-param-reassign': 'off',
'no-path-concat': 'error',
'no-plusplus': 'off',
'no-process-env': 'error',
'no-process-exit': 'error',
'no-proto': 'error',
'no-prototype-builtins': 'off',
'no-restricted-globals': 'error',
'no-restricted-imports': 'error',
'no-restricted-modules': 'error',
'no-restricted-properties': 'error',
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
'no-return-assign': 'error',
'no-return-await': 'error',
'no-script-url': 'error',
'no-self-compare': 'error',
'no-shadow': 'off',
'no-shadow-restricted-names': 'error',
'no-spaced-func': 'error',
'no-sync': 'error',
'no-tabs': 'error',
'no-template-curly-in-string': 'error',
'no-ternary': 'off',
'no-throw-literal': 'error',
'no-undef-init': 'error',
'no-undefined': 'off',
'no-unmodified-loop-condition': 'error',
'no-unneeded-ternary': [
'error',
{
"defaultAssignment": true
'defaultAssignment': true
}
],
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": "off",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "off",
"object-curly-spacing": "error",
"object-property-newline": [
"error",
'no-use-before-define': 'off',
'no-useless-call': 'error',
'no-useless-computed-key': 'error',
'no-useless-concat': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-void': 'error',
'no-warning-comments': 'off',
'no-whitespace-before-property': 'error',
'no-with': 'error',
'nonblock-statement-body-position': 'error',
'object-curly-newline': 'off',
'object-curly-spacing': 'error',
'object-property-newline': [
'error',
{
"allowMultiplePropertiesPerLine": true
'allowMultiplePropertiesPerLine': true
}
],
"object-shorthand": "off",
"one-var-declaration-per-line": [
"error",
"initializations"
'object-shorthand': 'off',
'one-var-declaration-per-line': [
'error',
'initializations'
],
"operator-assignment": "off",
"operator-linebreak": [
"error",
"after"
'operator-assignment': 'off',
'operator-linebreak': [
'error',
'after'
],
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "off",
"prefer-destructuring": "off",
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"prefer-template": "off",
"quote-props": "off",
"quotes": ["error", "single", { "avoidEscape": true }],
"require-await": "error",
"require-jsdoc": "off",
"semi-spacing": [
"error",
'padded-blocks': 'off',
'padding-line-between-statements': 'error',
'prefer-arrow-callback': 'off',
'prefer-destructuring': 'off',
'prefer-numeric-literals': 'error',
'prefer-promise-reject-errors': 'error',
'prefer-reflect': 'off',
'prefer-rest-params': 'off',
'prefer-spread': 'off',
'prefer-template': 'off',
'quote-props': 'off',
'quotes': ['error', 'single', { 'avoidEscape': true }],
'require-await': 'error',
'require-jsdoc': 'off',
'semi-spacing': [
'error',
{
"after": true,
"before": false
'after': true,
'before': false
}
],
"semi-style": [
"error",
"last"
'semi-style': [
'error',
'last'
],
"sort-imports": "off",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": [
"error",
"never"
'sort-imports': 'off',
'sort-keys': 'off',
'sort-vars': 'off',
'space-before-blocks': 'off',
'space-before-function-paren': 'off',
'space-in-parens': [
'error',
'never'
],
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "off",
"strict": "off",
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'spaced-comment': 'off',
'strict': 'off',
'switch-colon-spacing': 'error',
'symbol-description': 'error',
'template-curly-spacing': 'error',
'template-tag-spacing': 'error',
'unicode-bom': [
'error',
'never'
],
"wrap-iife": "error",
"wrap-regex": "off",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
'wrap-iife': 'error',
'wrap-regex': 'off',
'yield-star-spacing': 'error',
'yoda': [
'error',
'never'
],
"indent": [ "error", 2, { "SwitchCase": 1 } ],
"no-buffer-constructor": "error",
"no-lonely-if": "error",
"no-unused-vars": "error",
'indent': ['error', 2, { 'SwitchCase': 1 }],
'no-unused-vars': 'error',
// eslint-plugin-import rules:
"import/named": "error",
"import/extensions": "error",
"import/no-extraneous-dependencies": ["error", {"devDependencies": true, "optionalDependencies": false, "peerDependencies": false}],
"import/no-unassigned-import": "error",
'import/named': 'error',
'import/extensions': 'error',
'import/no-extraneous-dependencies': ['error', {'devDependencies': true, 'optionalDependencies': false, 'peerDependencies': false}],
'import/no-unassigned-import': 'error',
'import/prefer-default-export': 'off',
// Custom silencers:
"camelcase": 0,
"require-await": 0,
"no-multi-assign": 0,
"no-underscore-dangle": 0,
"no-await-in-loop": 0,
'camelcase': 0,
'require-await': 0,
'no-multi-assign': 0,
'no-underscore-dangle': 0,
'no-await-in-loop': 0,
// Custom errors:
"no-undef": 2,
"no-trailing-spaces": 2,
"no-mixed-operators": [ 2, {"groups": [["&", "|", "^", "~", "<<", ">>", ">>>"], ["&&", "||"]]}],
"no-use-before-define": [ 2, { "functions": false, "classes": true, "variables": false }],
"no-constant-condition": [ 2, { "checkLoops": false } ],
"new-cap": [ 2, { "properties": false, "capIsNewExceptionPattern": "EAX|OCB|GCM|CMAC|CBC|OMAC|CTR", "newIsCapExceptionPattern": "type|hash*"}],
"max-lines": [ 2, { "max": 620, "skipBlankLines": true, "skipComments": true } ],
"no-unused-expressions": 0,
"chai-friendly/no-unused-expressions": [ 2, { "allowShortCircuit": true } ],
'no-undef': 2,
'no-trailing-spaces': 2,
'no-mixed-operators': [2, { 'groups': [['&', '|', '^', '~', '<<', '>>', '>>>'], ['&&', '||']] }],
'no-use-before-define': [2, { 'functions': false, 'classes': true, 'variables': false }],
'no-constant-condition': [2, { 'checkLoops': false }],
'new-cap': [2, { 'properties': false, 'capIsNewExceptionPattern': 'EAX|OCB|GCM|CMAC|CBC|OMAC|CTR', 'newIsCapExceptionPattern': 'type|hash*' }],
'max-lines': [2, { 'max': 620, 'skipBlankLines': true, 'skipComments': true }],
'no-unused-expressions': 0,
'chai-friendly/no-unused-expressions': [2, { 'allowShortCircuit': true }],
// Custom warnings:
"no-console": 1,
'no-console': 1,
}
};

4898
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -65,17 +65,16 @@
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-replace": "^2.3.2",
"@types/chai": "^4.2.14",
"babel-eslint": "^10.1.0",
"benchmark": "^2.1.4",
"bn.js": "^4.11.8",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"email-addresses": "3.1.0",
"eslint": "^4.17.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-chai-friendly": "^0.5.0",
"eslint-plugin-import": "^2.8.0",
"eslint": "^8.34.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-import": "^2.27.5",
"esm": "^3.2.25",
"hash.js": "^1.1.3",
"http-server": "^14.1.1",

View File

@ -1,8 +1,9 @@
import util from '../util';
import BigInteger from './native.interface';
const detectBigInt = () => typeof BigInt !== 'undefined';
async function getBigInteger() {
if (util.detectBigInt()) {
if (detectBigInt()) {
return BigInteger;
} else {
const { default: BigInteger } = await import('./bn.interface');
@ -10,5 +11,4 @@ async function getBigInteger() {
}
}
// eslint-disable-next-line import/prefer-default-export
export { getBigInteger };

View File

@ -4,4 +4,6 @@
* @module config
*/
export { default } from './config.js';
import config from './config';
export default config;

View File

@ -50,7 +50,7 @@ const RSAPrivateKey = nodeCrypto ? asn1.define('RSAPrivateKey', function () {
const RSAPublicKey = nodeCrypto ? asn1.define('RSAPubliceKey', function () {
this.seq().obj( // used for native NodeJS crypto
this.key('modulus').int(), // n
this.key('publicExponent').int(), // e
this.key('publicExponent').int() // e
);
}) : undefined;
/* eslint-enable no-invalid-this */
@ -197,13 +197,15 @@ export async function generate(bits, e) {
publicKeyEncoding: { type: 'pkcs1', format: 'der' },
privateKeyEncoding: { type: 'pkcs1', format: 'der' }
};
const prv = await new Promise((resolve, reject) => nodeCrypto.generateKeyPair('rsa', opts, (err, _, der) => {
if (err) {
reject(err);
} else {
resolve(RSAPrivateKey.decode(der, 'der'));
}
}));
const prv = await new Promise((resolve, reject) => {
nodeCrypto.generateKeyPair('rsa', opts, (err, _, der) => {
if (err) {
reject(err);
} else {
resolve(RSAPrivateKey.decode(der, 'der'));
}
});
});
/**
* OpenPGP spec differs from DER spec, DER: `u = (inverse of q) mod p`, OpenPGP: `u = (inverse of p) mod q`.
* @link https://tools.ietf.org/html/rfc3447#section-3.2

View File

@ -231,6 +231,7 @@ function splitChecksum(text) {
* @static
*/
export function unarmor(input, config = defaultConfig) {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => {
try {
const reSplit = /^-----[^-]+-----$/m;

View File

@ -15,8 +15,6 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
/* eslint-disable callback-return */
/**
* @fileoverview Functions for reading and writing packets
* @module packet/packet
@ -159,6 +157,7 @@ export async function readPackets(input, callback) {
writer = stream.getWriter(transform.writable);
packet = transform.readable;
}
// eslint-disable-next-line callback-return
callbackReturned = callback({ tag, packet });
} else {
packet = [];
@ -279,6 +278,7 @@ export async function readPackets(input, callback) {
await writer.close();
} else {
packet = util.concatUint8Array(packet);
// eslint-disable-next-line callback-return
await callback({ tag, packet });
}
return !nextPacket || !nextPacket.length;

View File

@ -381,11 +381,6 @@ const util = {
return typeof globalThis !== 'undefined' && globalThis.crypto && globalThis.crypto.subtle;
},
/**
* Detect native BigInt support
*/
detectBigInt: () => typeof BigInt !== 'undefined',
/**
* Get BigInteger class
* It wraps the native BigInt type if it's available
@ -569,6 +564,7 @@ const util = {
* or rejected with the Error of the last resolved Promise (if all promises are rejected)
*/
anyPromise: function(promises) {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => {
let exception;
await Promise.all(promises.map(async promise => {

View File

@ -1,5 +1,5 @@
const Benchmark = require('benchmark');
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../');
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const wrapAsync = func => ({
fn: async deferred => {

View File

@ -1,8 +1,8 @@
const { expect } = require('chai');
const aesKW = require('../../src/crypto/aes_kw');
const util = require('../../src/util');
const expect = require('chai').expect;
module.exports = () => describe('AES Key Wrap and Unwrap', function () {
const test_vectors = [
[

View File

@ -1,9 +1,7 @@
const { expect } = require('chai');
const { aes128: AES128 } = require('../../../src/crypto/cipher');
const chai = require('chai');
const { expect } = chai;
module.exports = () => describe('AES Rijndael cipher test with test vectors from ecb_tbl.txt', function() {
function test_aes(input, key, output) {
const aes = new AES128(new Uint8Array(key));

View File

@ -1,10 +1,8 @@
const { expect } = require('chai');
const BF = require('../../../src/crypto/cipher/blowfish');
const util = require('../../../src/util');
const chai = require('chai');
const { expect } = chai;
module.exports = () => it('Blowfish cipher test with test vectors from https://www.schneier.com/code/vectors.txt', function(done) {
function test_bf(input, key, output) {
const blowfish = new BF(util.uint8ArrayToString(key));

View File

@ -1,10 +1,8 @@
const { expect } = require('chai');
const CAST5 = require('../../../src/crypto/cipher/cast5');
const util = require('../../../src/util');
const chai = require('chai');
const { expect } = chai;
module.exports = () => it('CAST-128 cipher test with test vectors from RFC2144', function (done) {
function test_cast(input, key, output) {
const cast5 = new CAST5(key);

View File

@ -1,10 +1,8 @@
const { expect } = require('chai');
const { DES, TripleDES } = require('../../../src/crypto/cipher/des');
const util = require('../../../src/util');
const chai = require('chai');
const { expect } = chai;
module.exports = () => describe('TripleDES (EDE) cipher test with test vectors from NIST SP 800-20', function() {
// see https://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf
const key = new Uint8Array([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]);

View File

@ -1,7 +1,7 @@
module.exports = () => describe('Cipher', function () {
require('./aes.js')();
require('./blowfish.js')();
require('./cast5.js')();
require('./des.js')();
require('./twofish.js')();
require('./aes')();
require('./blowfish')();
require('./cast5')();
require('./des')();
require('./twofish')();
});

View File

@ -1,10 +1,8 @@
const { expect } = require('chai');
const TF = require('../../../src/crypto/cipher/twofish');
const util = require('../../../src/util');
const chai = require('chai');
const { expect } = chai;
module.exports = () => it('Twofish with test vectors from https://www.schneier.com/code/ecb_ival.txt', function(done) {
function tfencrypt(block, key) {
const tf = new TF(util.stringToUint8Array(key));

View File

@ -1,13 +1,11 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const sandbox = require('sinon/lib/sinon/sandbox');
const crypto = require('../../src/crypto');
const util = require('../../src/util');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
module.exports = () => describe('API functional testing', function() {
const RSAPublicKeyMaterial = util.concatUint8Array([
new Uint8Array([0x08,0x00,0xac,0x15,0xb3,0xd6,0xd2,0x0f,0xf0,0x7a,0xdd,0x21,0xb7,

View File

@ -1,16 +1,14 @@
// Modified by ProtonTech AG
// Adapted from https://github.com/artjomb/cryptojs-extension/blob/8c61d159/test/eax.js
const sandbox = require('sinon/lib/sinon/sandbox');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const EAX = require('../../src/crypto/mode/eax');
const util = require('../../src/util');
const sandbox = require('sinon/lib/sinon/sandbox');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
function testAESEAX() {
it('Passes all test vectors', async function() {
const vectors = [

View File

@ -1,16 +1,14 @@
const sandbox = require('sinon/lib/sinon/sandbox');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const OID = require('../../src/type/oid');
const KDFParams = require('../../src/type/kdf_params');
const elliptic_curves = require('../../src/crypto/public_key/elliptic');
const util = require('../../src/util');
const sandbox = require('sinon/lib/sinon/sandbox');
const chai = require('chai');
const elliptic_data = require('./elliptic_data');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
const key_data = elliptic_data.key_data;
/* eslint-disable no-invalid-this */
module.exports = () => describe('ECDH key exchange @lightweight', function () {

View File

@ -1,17 +1,15 @@
const sandbox = require('sinon/lib/sinon/sandbox');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const elliptic_curves = require('../../src/crypto/public_key/elliptic');
const hashMod = require('../../src/crypto/hash');
const config = require('../../src/config');
const util = require('../../src/util');
const sandbox = require('sinon/lib/sinon/sandbox');
const chai = require('chai');
const elliptic_data = require('./elliptic_data');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
const key_data = elliptic_data.key_data;
/* eslint-disable no-invalid-this */
module.exports = () => describe('Elliptic Curve Cryptography @lightweight', function () {

View File

@ -1,12 +1,11 @@
const sandbox = require('sinon/lib/sinon/sandbox');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const crypto = require('../../src/crypto');
const util = require('../../src/util');
const sandbox = require('sinon/lib/sinon/sandbox');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
module.exports = () => describe('Symmetric AES-GCM (experimental)', function() {
let sinonSandbox;

View File

@ -1,5 +1,5 @@
module.exports = () => describe('Hash', function () {
require('./md5.js')();
require('./ripemd.js')();
require('./sha.js')();
require('./md5')();
require('./ripemd')();
require('./sha')();
});

View File

@ -1,10 +1,8 @@
const { expect } = require('chai');
const md5 = require('../../../src/crypto/hash/md5');
const util = require('../../../src/util');
const chai = require('chai');
const { expect } = chai;
module.exports = () => it('MD5 with test vectors from RFC 1321', async function() {
expect(util.uint8ArrayToHex(await md5(util.stringToUint8Array('')), 'MD5("") = d41d8cd98f00b204e9800998ecf8427e')).to.equal('d41d8cd98f00b204e9800998ecf8427e');
expect(util.uint8ArrayToHex(await md5(util.stringToUint8Array('abc')), 'MD5("a") = 0cc175b9c0f1b6a831c399e269772661')).to.equal('900150983cd24fb0d6963f7d28e17f72');

View File

@ -1,10 +1,8 @@
const { expect } = require('chai');
const { ripemd: rmdString } = require('../../../src/crypto/hash');
const util = require('../../../src/util');
const chai = require('chai');
const { expect } = chai;
module.exports = () => it('RIPE-MD 160 bits with test vectors from https://homes.esat.kuleuven.be/~bosselae/ripemd160.html', async function() {
expect(util.uint8ArrayToHex(await rmdString(util.stringToUint8Array('')), 'RMDstring("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31')).to.equal('9c1185a5c5e9fc54612808977ee8f548b2258d31');
expect(util.uint8ArrayToHex(await rmdString(util.stringToUint8Array('a')), 'RMDstring("a") = 0bdc9d2d256b3ee9daae347be6f4dc835a467ffe')).to.equal('0bdc9d2d256b3ee9daae347be6f4dc835a467ffe');

View File

@ -1,10 +1,8 @@
const { expect } = require('chai');
const hash = require('../../../src/crypto/hash');
const util = require('../../../src/util');
const chai = require('chai');
const { expect } = chai;
module.exports = () => it('SHA* with test vectors from NIST FIPS 180-2', async function() {
expect(util.uint8ArrayToHex(await hash.sha1(util.stringToUint8Array('abc')), 'hash.sha1("abc") = a9993e364706816aba3e25717850c26c9cd0d89d')).to.equal('a9993e364706816aba3e25717850c26c9cd0d89d');
expect(util.uint8ArrayToHex(await hash.sha1(util.stringToUint8Array('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq')), 'hash.sha1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") = 84983e441c3bd26ebaae4aa1f95129e5e54670f1')).to.equal('84983e441c3bd26ebaae4aa1f95129e5e54670f1');

View File

@ -1,14 +1,14 @@
module.exports = () => describe('Crypto', function () {
require('./cipher')();
require('./hash')();
require('./crypto.js')();
require('./elliptic.js')();
require('./ecdh.js')();
require('./pkcs5.js')();
require('./aes_kw.js')();
require('./gcm.js')();
require('./eax.js')();
require('./ocb.js')();
require('./rsa.js')();
require('./validate.js')();
require('./crypto')();
require('./elliptic')();
require('./ecdh')();
require('./pkcs5')();
require('./aes_kw')();
require('./gcm')();
require('./eax')();
require('./ocb')();
require('./rsa')();
require('./validate')();
});

View File

@ -1,15 +1,13 @@
// Modified by ProtonTech AG
// Adapted from https://github.com/artjomb/cryptojs-extension/blob/8c61d159/test/eax.js
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const OCB = require('../../src/crypto/mode/ocb');
const util = require('../../src/util');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
module.exports = () => describe('Symmetric AES-OCB', function() {
it('Passes all test vectors', async function() {
const K = '000102030405060708090A0B0C0D0E0F';

View File

@ -1,6 +1,6 @@
const pkcs5 = require('../../src/crypto/pkcs5');
const { expect } = require('chai');
const expect = require('chai').expect;
const pkcs5 = require('../../src/crypto/pkcs5');
module.exports = () => describe('PKCS5 padding', function() {
it('Add and remove padding', function () {

View File

@ -1,15 +1,12 @@
const sandbox = require('sinon/lib/sinon/sandbox');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const crypto = require('../../src/crypto');
const random = require('../../src/crypto/random');
const util = require('../../src/util');
const sandbox = require('sinon/lib/sinon/sandbox');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
/* eslint-disable no-invalid-this */
module.exports = () => describe('basic RSA cryptography', function () {
let sinonSandbox;

View File

@ -1,10 +1,9 @@
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const chai = require('chai');
const BN = require('bn.js');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
chai.use(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const expect = chai.expect;
const armoredDSAKey = `-----BEGIN PGP PRIVATE KEY BLOCK-----
lQNTBF69PO8RCACHP4KLQcYOPGsGV9owTZvxnvHvvrY8W0v8xDUL3y6CLc05srF1

View File

@ -1,8 +1,7 @@
const { expect } = require('chai');
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const chai = require('chai');
const { expect } = chai;
module.exports = () => describe('ASCII armor', function() {

View File

@ -1,11 +1,10 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const BN = require('bn.js');
const random = require('../../src/crypto/random');
const util = require('../../src/util');
const BN = require('bn.js');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
let BigInteger;
async function getRandomBN(min, max) {

View File

@ -1,13 +1,12 @@
/* globals tryTests: true */
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const util = require('../../src/util');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const input = require('./testInputs.js');
const input = require('./testInputs');
const expect = chai.expect;
module.exports = () => (openpgp.config.ci ? describe.skip : describe)('Brainpool Cryptography @lightweight', function () {
let rejectCurvesVal;

View File

@ -1,10 +1,8 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
const password = 'I am a password';
const tests = {

View File

@ -1,11 +1,11 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const input = require('./testInputs.js');
const util = require('../../src/util');
const expect = chai.expect;
const input = require('./testInputs');
module.exports = () => describe('Elliptic Curve Cryptography for NIST P-256,P-384,P-521 curves @lightweight', function () {
function omnibus() {

View File

@ -1,11 +1,9 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const util = require('../../src/util');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
module.exports = () => describe('Elliptic Curve Cryptography for secp256k1 curve @lightweight', function () {
if (!openpgp.config.useIndutnyElliptic && !util.getNodeCrypto()) {
before(function() {

View File

@ -1,18 +1,18 @@
module.exports = () => describe('General', function () {
require('./util.js')();
require('./biginteger.js')();
require('./armor.js')();
require('./packet.js')();
require('./signature.js')();
require('./key.js')();
require('./openpgp.js')();
require('./config.js')();
require('./oid.js')();
require('./ecc_nist.js')();
require('./ecc_secp256k1.js')();
require('./x25519.js')();
require('./brainpool.js')();
require('./decompression.js')();
require('./streaming.js')();
require('./util')();
require('./biginteger')();
require('./armor')();
require('./packet')();
require('./signature')();
require('./key')();
require('./openpgp')();
require('./config')();
require('./oid')();
require('./ecc_nist')();
require('./ecc_secp256k1')();
require('./x25519')();
require('./brainpool')();
require('./decompression')();
require('./streaming')();
});

View File

@ -1,15 +1,13 @@
/* eslint-disable max-lines */
/* globals tryTests: true */
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const util = require('../../src/util');
const { isAEADSupported, getPreferredAlgo } = require('../../src/key');
const KeyID = require('../../src/type/keyid');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const { expect } = chai;
const priv_key_arm2 =
['-----BEGIN PGP PRIVATE KEY BLOCK-----',

View File

@ -1,8 +1,8 @@
const { expect } = require('chai');
const OID = require('../../src/type/oid');
const util = require('../../src/util');
const expect = require('chai').expect;
module.exports = () => describe('Oid tests', function() {
const p256_oid = new Uint8Array([0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07]);
const p384_oid = new Uint8Array([0x2B, 0x81, 0x04, 0x00, 0x22]);

View File

@ -1,5 +1,9 @@
/* eslint-disable max-lines */
/* globals tryTests: true */
const spy = require('sinon/lib/sinon/spy');
const stream = require('@openpgp/web-stream-tools');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const crypto = require('../../src/crypto');
@ -8,14 +12,7 @@ const util = require('../../src/util');
const keyIDType = require('../../src/type/keyid');
const { isAEADSupported } = require('../../src/key');
const stream = require('@openpgp/web-stream-tools');
const spy = require('sinon/lib/sinon/spy');
const input = require('./testInputs.js');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
const input = require('./testInputs');
const detectNode = () => typeof globalThis.process === 'object' && typeof globalThis.process.versions === 'object';
@ -2891,7 +2888,7 @@ aOU=
},
async pull(controller) {
if (this.remaining.length) {
await new Promise(res => setTimeout(res));
await new Promise(res => { setTimeout(res); });
controller.enqueue(this.remaining.shift() + '\n');
} else {
controller.close();

View File

@ -1,17 +1,14 @@
/* eslint-disable max-lines */
const stream = require('@openpgp/web-stream-tools');
const stub = require('sinon/lib/sinon/stub');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const crypto = require('../../src/crypto');
const util = require('../../src/util');
const stream = require('@openpgp/web-stream-tools');
const stub = require('sinon/lib/sinon/stub');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const { expect } = chai;
const input = require('./testInputs.js');
const input = require('./testInputs');
function stringify(array) {
if (stream.isStream(array)) {

View File

@ -1,16 +1,13 @@
/* eslint-disable max-lines */
/* globals tryTests: true */
const stream = require('@openpgp/web-stream-tools');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const util = require('../../src/util');
const stream = require('@openpgp/web-stream-tools');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
module.exports = () => describe('Signature', function() {
const priv_key_arm1 =
['-----BEGIN PGP PRIVATE KEY BLOCK-----',

View File

@ -1,17 +1,14 @@
/* eslint-disable max-lines */
const stream = require('@openpgp/web-stream-tools');
const stub = require('sinon/lib/sinon/stub');
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const random = require('../../src/crypto/random');
const util = require('../../src/util');
const stub = require('sinon/lib/sinon/stub');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const input = require('./testInputs.js');
const { expect } = chai;
const stream = require('@openpgp/web-stream-tools');
const input = require('./testInputs');
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })(); // eslint-disable-line no-new
const NodeReadableStream = useNativeStream ? undefined : require('stream').Readable;
@ -574,9 +571,9 @@ function tests() {
await writer.abort(e);
}
});
await new Promise(resolve => setTimeout(resolve));
await new Promise(resolve => { setTimeout(resolve); });
await stream.cancel(transformed);
await new Promise(resolve => setTimeout(resolve));
await new Promise(resolve => { setTimeout(resolve); });
expect(canceled).to.be.true;
});
@ -616,7 +613,7 @@ function tests() {
const reader = stream.getReader(encrypted);
expect(await reader.readBytes(1024)).to.match(/^-----BEGIN PGP MESSAGE-----\n/);
dataArrived();
await new Promise(resolve => setTimeout(resolve, 3000));
await new Promise(resolve => { setTimeout(resolve, 3000); });
expect(i).to.be.lessThan(expectedType === 'web' ? 50 : 100);
});
@ -631,7 +628,7 @@ function tests() {
const reader = stream.getReader(signed);
expect(await reader.readBytes(1024)).to.match(/^-----BEGIN PGP MESSAGE-----\n/);
dataArrived();
await new Promise(resolve => setTimeout(resolve, 3000));
await new Promise(resolve => { setTimeout(resolve, 3000); });
expect(i).to.be.lessThan(expectedType === 'web' ? 50 : 100);
});
@ -652,7 +649,7 @@ function tests() {
const reader = stream.getReader(verified.data);
expect(await reader.readBytes(1024)).to.deep.equal(plaintext[0]);
dataArrived();
await new Promise(resolve => setTimeout(resolve, 3000));
await new Promise(resolve => { setTimeout(resolve, 3000); });
expect(i).to.be.lessThan(expectedType === 'web' ? 50 : 250);
});
@ -783,7 +780,7 @@ function tests() {
const reader = stream.getReader(signed);
expect((await reader.readBytes(30)).toString('utf8')).to.equal('-----BEGIN PGP SIGNATURE-----\n');
dataArrived();
await new Promise(resolve => setTimeout(resolve, 3000));
await new Promise(resolve => { setTimeout(resolve, 3000); });
expect(i).to.equal(expectedType === 'web' ? 100 : 500);
});
@ -846,7 +843,7 @@ function tests() {
let i = 0;
const data = global.ReadableStream ? new global.ReadableStream({
async pull(controller) {
await new Promise(resolve => setTimeout(resolve, 10));
await new Promise(resolve => { setTimeout(resolve, 10); });
if (i++ < 10) {
const randomData = input.createSomeMessage();
controller.enqueue(randomData);
@ -859,7 +856,7 @@ function tests() {
encoding: 'utf8',
async read() {
while (true) {
await new Promise(resolve => setTimeout(resolve, 10));
await new Promise(resolve => { setTimeout(resolve, 10); });
if (i++ < 10) {
const randomData = input.createSomeMessage();
plaintext.push(randomData);
@ -914,7 +911,7 @@ function tests() {
const reader = stream.getReader(decrypted.data);
expect(await reader.readBytes(1024)).to.deep.equal(plaintext[0]);
dataArrived();
await new Promise(resolve => setTimeout(resolve, 3000));
await new Promise(resolve => { setTimeout(resolve, 3000); });
expect(i).to.be.lessThan(expectedType === 'web' ? 50 : 300);
} finally {
if (detectNode()) {

View File

@ -1,8 +1,6 @@
const { expect } = require('chai');
const util = require('../../src/util');
const chai = require('chai');
const { expect } = chai;
module.exports = () => describe('Util unit tests', function() {

View File

@ -1,15 +1,14 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const nacl = require('@openpgp/tweetnacl');
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const elliptic = require('../../src/crypto/public_key/elliptic');
const signature = require('../../src/crypto/signature');
const OID = require('../../src/type/oid');
const util = require('../../src/util');
const nacl = require('@openpgp/tweetnacl');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const { expect } = chai;
const input = require('./testInputs');
module.exports = () => (openpgp.config.ci ? describe.skip : describe)('X25519 Cryptography', function () {

View File

@ -1,13 +1,11 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const util = require('../../src/util');
const { readKey, readCleartextMessage, SignaturePacket } = openpgp;
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
/**
* public key of another user.
*/

View File

@ -1,10 +1,8 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
const armoredMessage = `-----BEGIN PGP MESSAGE-----
Version: OpenPGP.js VERSION
Comment: https://openpgpjs.org

View File

@ -1,12 +1,10 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const { readKey, PublicKey, readCleartextMessage, createCleartextMessage, enums, PacketList, SignaturePacket } = openpgp;
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
async function generateTestData() {
const { privateKey: victimPrivKey } = await openpgp.generateKey({
userIDs: [{ name: 'Victim', email: 'victim@example.com' }],

View File

@ -1,12 +1,10 @@
const { use: chaiUse, expect } = require('chai');
chaiUse(require('chai-as-promised'));
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const { readKey, PrivateKey, createMessage, enums, PacketList, SignaturePacket } = openpgp;
const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
/*
* This key is long expired and cannot be used for encryption.
*/

View File

@ -1,8 +1,6 @@
/* globals tryTests: true */
const chai = require('chai');
const { expect } = chai;
const { expect } = require('chai');
/* eslint-disable no-invalid-this */
module.exports = () => tryTests('Application Worker', tests, {
@ -12,12 +10,6 @@ module.exports = () => tryTests('Application Worker', tests, {
function tests() {
it('Should support loading OpenPGP.js from inside a Web Worker', async function() {
try {
globalThis.eval('(async function() {})');
} catch (e) {
console.error(e); // eslint-disable-line no-console
this.skip();
}
const worker = new Worker('./worker/worker_example.js');
async function delegate(action, message) {
return new Promise((resolve, reject) => {

View File

@ -1,4 +1,4 @@
module.exports = () => describe('Web Worker', function () {
require('./application_worker.js')();
require('./application_worker')();
});