mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-23 22:15:52 +00:00
Linter: update to eslint v9
This eslint version brings breaking changes related to the eslint config. eslint-airbnb-config has yet to release a compatible version with the new format, and it generally looks unmaintained, hence we drop the dependency in favor of the built-in recommended configs.
This commit is contained in:
parent
5a69043aad
commit
d4bb70815b
@ -1,4 +0,0 @@
|
|||||||
dist
|
|
||||||
test/lib/
|
|
||||||
test/typescript/
|
|
||||||
docs
|
|
||||||
146
.eslintrc.cjs
146
.eslintrc.cjs
@ -1,146 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
'extends': [
|
|
||||||
'airbnb-base',
|
|
||||||
'airbnb-typescript/base'
|
|
||||||
],
|
|
||||||
|
|
||||||
'parser': '@typescript-eslint/parser',
|
|
||||||
|
|
||||||
'parserOptions': {
|
|
||||||
'ecmaVersion': 11,
|
|
||||||
'sourceType': 'module',
|
|
||||||
'project': 'tsconfig.json'
|
|
||||||
},
|
|
||||||
|
|
||||||
'env': {
|
|
||||||
'browser': true,
|
|
||||||
'es6': true,
|
|
||||||
'node': true
|
|
||||||
},
|
|
||||||
|
|
||||||
'plugins': [
|
|
||||||
'@typescript-eslint',
|
|
||||||
'chai-friendly',
|
|
||||||
'import',
|
|
||||||
'unicorn'
|
|
||||||
],
|
|
||||||
|
|
||||||
'settings': {
|
|
||||||
'import/resolver': {
|
|
||||||
'typescript': {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
'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': {
|
|
||||||
'arrow-body-style': 'off',
|
|
||||||
'arrow-parens': ['error','as-needed'],
|
|
||||||
'class-methods-use-this': 'off',
|
|
||||||
'@typescript-eslint/comma-dangle': ['error', 'never'],
|
|
||||||
'@typescript-eslint/comma-spacing': 'off',
|
|
||||||
'consistent-return': 'off',
|
|
||||||
'default-case': 'off',
|
|
||||||
'@typescript-eslint/default-param-last': 'off',
|
|
||||||
'eol-last': ['error', 'always'],
|
|
||||||
'function-call-argument-newline': 'off',
|
|
||||||
'func-names': ['error', 'never'],
|
|
||||||
'function-paren-newline': 'off',
|
|
||||||
'global-require': 'off',
|
|
||||||
'key-spacing': 'off',
|
|
||||||
'keyword-spacing': 'error',
|
|
||||||
'max-classes-per-file': 'off',
|
|
||||||
'max-len': 'off',
|
|
||||||
'newline-per-chained-call': 'off',
|
|
||||||
'no-bitwise': 'off',
|
|
||||||
'no-continue': 'off',
|
|
||||||
'no-else-return': 'off',
|
|
||||||
'no-empty': ['error', { 'allowEmptyCatch': true }],
|
|
||||||
'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 1, 'maxBOF':0 }],
|
|
||||||
'no-nested-ternary': 'off',
|
|
||||||
'no-param-reassign': 'off', // TODO get rid of this
|
|
||||||
'no-plusplus': 'off',
|
|
||||||
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
|
|
||||||
'object-curly-newline': 'off',
|
|
||||||
'@typescript-eslint/no-shadow': 'off', // TODO get rid of this
|
|
||||||
'object-property-newline': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
'allowMultiplePropertiesPerLine': true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'object-shorthand': 'off',
|
|
||||||
'operator-assignment': 'off',
|
|
||||||
'operator-linebreak': [
|
|
||||||
'error',
|
|
||||||
'after'
|
|
||||||
],
|
|
||||||
'padded-blocks': 'off',
|
|
||||||
'prefer-arrow-callback': 'off',
|
|
||||||
'prefer-destructuring': 'off',
|
|
||||||
'prefer-rest-params': 'off', // TODO get rid of this
|
|
||||||
'prefer-spread': 'off', // TODO get rid of this
|
|
||||||
'prefer-template': 'off',
|
|
||||||
'quote-props': 'off',
|
|
||||||
'quotes': ['error', 'single', { 'avoidEscape': true }],
|
|
||||||
'@typescript-eslint/space-before-function-paren': ['error', { 'anonymous': 'ignore', 'named': 'never', 'asyncArrow': 'always' }],
|
|
||||||
'spaced-comment': 'off',
|
|
||||||
'indent': 'off',
|
|
||||||
'@typescript-eslint/indent': ['error', 2, { 'SwitchCase': 1 }],
|
|
||||||
'no-unused-vars': 'off',
|
|
||||||
"@typescript-eslint/no-unused-vars": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"argsIgnorePattern": "^_",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
// eslint-plugin-import rules:
|
|
||||||
'import/named': 'error',
|
|
||||||
'import/extensions': 'off', // temporary: we use them in tests (ESM compliant), but not in the lib (to limit diff)
|
|
||||||
'import/first': 'off',
|
|
||||||
'import/no-extraneous-dependencies': ['error', { 'devDependencies': true, 'optionalDependencies': false, 'peerDependencies': false }],
|
|
||||||
'import/no-unassigned-import': 'error',
|
|
||||||
'import/no-unresolved': 'error',
|
|
||||||
'import/prefer-default-export': 'off',
|
|
||||||
|
|
||||||
// Custom silencers:
|
|
||||||
'no-multi-assign': 'off',
|
|
||||||
'no-underscore-dangle': 'off',
|
|
||||||
'no-await-in-loop': 'off',
|
|
||||||
'camelcase': 'off', // snake_case used in tests, need to fix separately
|
|
||||||
'@typescript-eslint/naming-convention': 'off', // supersedes 'camelcase' rule
|
|
||||||
'@typescript-eslint/lines-between-class-members': 'off',
|
|
||||||
|
|
||||||
// Custom errors:
|
|
||||||
'@typescript-eslint/no-use-before-define': ['error', { 'functions': false, 'classes': true, 'variables': false, 'allowNamedExports': true }],
|
|
||||||
'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 }],
|
|
||||||
'@typescript-eslint/no-unused-expressions': 0,
|
|
||||||
'chai-friendly/no-unused-expressions': [2, { 'allowShortCircuit': true }],
|
|
||||||
'unicorn/switch-case-braces': ['error', 'avoid'],
|
|
||||||
|
|
||||||
// Custom warnings:
|
|
||||||
'no-console': 1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
155
eslint.config.js
Normal file
155
eslint.config.js
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
// @ts-check
|
||||||
|
import eslint from '@eslint/js';
|
||||||
|
import { defineConfig, globalIgnores } from 'eslint/config';
|
||||||
|
import tseslint from 'typescript-eslint';
|
||||||
|
import globals from 'globals';
|
||||||
|
// @ts-expect-error missing types
|
||||||
|
import pluginChaiFriendly from 'eslint-plugin-chai-friendly';
|
||||||
|
import pluginImport from 'eslint-plugin-import';
|
||||||
|
import pluginStylistic from '@stylistic/eslint-plugin';
|
||||||
|
// @ts-expect-error missing types
|
||||||
|
import pluginUnicorn from 'eslint-plugin-unicorn';
|
||||||
|
|
||||||
|
export default defineConfig(
|
||||||
|
eslint.configs.recommended,
|
||||||
|
tseslint.configs.recommended,
|
||||||
|
globalIgnores(['dist/', 'test/lib/', 'docs/', '.jsdocrc.cjs']),
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: 'module',
|
||||||
|
parserOptions: {
|
||||||
|
projectService: true,
|
||||||
|
tsconfigRootDir: import.meta.dirname
|
||||||
|
},
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.nodeBuiltin,
|
||||||
|
...globals.mocha
|
||||||
|
}
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
'import/resolver': {
|
||||||
|
typescript: { alwaysTryTypes: true }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
'chai-friendly': pluginChaiFriendly,
|
||||||
|
'import': pluginImport,
|
||||||
|
'@stylistic': pluginStylistic,
|
||||||
|
'unicorn': pluginUnicorn
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'arrow-body-style': 'off',
|
||||||
|
'arrow-parens': ['error','as-needed'],
|
||||||
|
'class-methods-use-this': 'off', // TODO warn
|
||||||
|
|
||||||
|
'comma-dangle': ['error', 'never'],
|
||||||
|
'@typescript-eslint/comma-spacing': 'off',
|
||||||
|
'consistent-return': 'off',
|
||||||
|
'default-case': 'off',
|
||||||
|
'@typescript-eslint/default-param-last': 'off',
|
||||||
|
'eol-last': ['error', 'always'],
|
||||||
|
'function-call-argument-newline': 'off',
|
||||||
|
'func-names': ['error', 'never'],
|
||||||
|
'function-paren-newline': 'off',
|
||||||
|
'global-require': 'off',
|
||||||
|
'key-spacing': 'off',
|
||||||
|
'keyword-spacing': 'error',
|
||||||
|
'max-classes-per-file': 'off',
|
||||||
|
'max-len': 'off',
|
||||||
|
'newline-per-chained-call': 'off',
|
||||||
|
'no-bitwise': 'off',
|
||||||
|
'no-continue': 'off',
|
||||||
|
'no-else-return': 'off',
|
||||||
|
'no-empty': ['error', { 'allowEmptyCatch': true }],
|
||||||
|
'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 1, 'maxBOF':0 }],
|
||||||
|
'no-nested-ternary': 'off', // TODO warn
|
||||||
|
'no-param-reassign': 'off', // TODO get rid of this
|
||||||
|
'no-plusplus': 'off',
|
||||||
|
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
|
||||||
|
'object-curly-newline': 'off',
|
||||||
|
'@typescript-eslint/no-shadow': 'off', // TODO get rid of this
|
||||||
|
'object-property-newline': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'allowMultiplePropertiesPerLine': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'object-shorthand': 'off',
|
||||||
|
'operator-assignment': 'off',
|
||||||
|
'operator-linebreak': [
|
||||||
|
'error',
|
||||||
|
'after'
|
||||||
|
],
|
||||||
|
'padded-blocks': 'off',
|
||||||
|
'prefer-arrow-callback': 'off',
|
||||||
|
'prefer-destructuring': 'off',
|
||||||
|
'prefer-rest-params': 'off', // TODO get rid of this
|
||||||
|
'prefer-spread': 'off', // TODO get rid of this
|
||||||
|
'prefer-template': 'off',
|
||||||
|
'quote-props': 'off',
|
||||||
|
'quotes': ['error', 'single', { 'avoidEscape': true }],
|
||||||
|
'spaced-comment': 'off',
|
||||||
|
'indent': 'off',
|
||||||
|
'no-unused-vars': 'off',
|
||||||
|
'@typescript-eslint/no-unused-vars': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'argsIgnorePattern': '^_'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// eslint-plugin-import rules:
|
||||||
|
'import/named': 'error',
|
||||||
|
'import/extensions': 'off', // temporary: we use them in tests (ESM compliant), but not in the lib (to limit diff)
|
||||||
|
'import/first': 'off',
|
||||||
|
'import/no-extraneous-dependencies': ['error', { 'devDependencies': true, 'optionalDependencies': false, 'peerDependencies': false }],
|
||||||
|
'import/no-unassigned-import': 'error',
|
||||||
|
'import/no-unresolved': 'error',
|
||||||
|
'import/prefer-default-export': 'off',
|
||||||
|
'import/newline-after-import': 'error',
|
||||||
|
|
||||||
|
// Custom silencers:
|
||||||
|
'no-multi-assign': 'off',
|
||||||
|
'no-underscore-dangle': 'off',
|
||||||
|
'no-await-in-loop': 'off',
|
||||||
|
'camelcase': 'off', // snake_case used in tests, need to fix separately
|
||||||
|
'@typescript-eslint/naming-convention': 'off', // supersedes 'camelcase' rule
|
||||||
|
'@typescript-eslint/lines-between-class-members': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/no-this-alias': 'off',
|
||||||
|
|
||||||
|
// Custom errors:
|
||||||
|
'@typescript-eslint/no-use-before-define': ['error', { 'functions': false, 'classes': true, 'variables': false, 'allowNamedExports': true }],
|
||||||
|
'no-constant-condition': [2, { 'checkLoops': false }],
|
||||||
|
'new-cap': ['error', {
|
||||||
|
properties: false,
|
||||||
|
newIsCap: true,
|
||||||
|
newIsCapExceptions: [],
|
||||||
|
capIsNew: false
|
||||||
|
}],
|
||||||
|
'max-lines': [2, { 'max': 620, 'skipBlankLines': true, 'skipComments': true }],
|
||||||
|
'@typescript-eslint/no-unused-expressions': 'off',
|
||||||
|
'chai-friendly/no-unused-expressions': ['error', { 'allowShortCircuit': true }],
|
||||||
|
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'with-single-extends' }],
|
||||||
|
|
||||||
|
'@stylistic/indent': ['error', 2, { 'SwitchCase': 1 }],
|
||||||
|
'@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
|
||||||
|
'@stylistic/space-before-function-paren': ['error', { 'anonymous': 'ignore', 'named': 'never', 'asyncArrow': 'always' }],
|
||||||
|
'@stylistic/no-mixed-operators': ['error', {
|
||||||
|
allowSamePrecedence: true,
|
||||||
|
groups: [
|
||||||
|
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
|
||||||
|
['&&', '||']
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
'@stylistic/no-mixed-spaces-and-tabs': 'error',
|
||||||
|
'@stylistic/eol-last': 'error',
|
||||||
|
'@stylistic/no-trailing-spaces': 'error',
|
||||||
|
'@stylistic/no-tabs': 'error',
|
||||||
|
'unicorn/switch-case-braces': ['error', 'avoid'],
|
||||||
|
'no-console': 'warn',
|
||||||
|
'no-process-exit': 'error'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
4
openpgp.d.ts
vendored
4
openpgp.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable max-lines, @typescript-eslint/indent */
|
/* eslint-disable @stylistic/indent */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type definitions for OpenPGP.js http://openpgpjs.org/
|
* Type definitions for OpenPGP.js http://openpgpjs.org/
|
||||||
@ -411,7 +411,7 @@ export class AEADEncryptedDataPacket extends BasePacket {
|
|||||||
static readonly tag: enums.packet.aeadEncryptedData;
|
static readonly tag: enums.packet.aeadEncryptedData;
|
||||||
private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
|
private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
|
||||||
private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
|
private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
|
||||||
private crypt(fn: Function, sessionKey: Uint8Array, data: MaybeStream<Uint8Array>): MaybeStream<Uint8Array>;
|
private crypt(fn: (block: Uint8Array) => Uint8Array, sessionKey: Uint8Array, data: MaybeStream<Uint8Array>): MaybeStream<Uint8Array>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PublicKeyEncryptedSessionKeyPacket extends BasePacket {
|
export class PublicKeyEncryptedSessionKeyPacket extends BasePacket {
|
||||||
|
|||||||
1649
package-lock.json
generated
1649
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@ -63,6 +63,7 @@
|
|||||||
"postversion": "git push --follow-tags && npm publish"
|
"postversion": "git push --follow-tags && npm publish"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.36.0",
|
||||||
"@noble/ciphers": "^1.3.0",
|
"@noble/ciphers": "^1.3.0",
|
||||||
"@noble/curves": "^1.9.6",
|
"@noble/curves": "^1.9.6",
|
||||||
"@noble/hashes": "^1.8.0",
|
"@noble/hashes": "^1.8.0",
|
||||||
@ -77,10 +78,10 @@
|
|||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
"@rollup/plugin-typescript": "^12.1.4",
|
"@rollup/plugin-typescript": "^12.1.4",
|
||||||
"@rollup/plugin-wasm": "^6.2.2",
|
"@rollup/plugin-wasm": "^6.2.2",
|
||||||
|
"@stylistic/eslint-plugin": "^5.4.0",
|
||||||
"@types/chai": "^4.3.20",
|
"@types/chai": "^4.3.20",
|
||||||
"@types/node": "^24.3.1",
|
"@types/node": "^24.3.1",
|
||||||
"@types/sinon": "^17.0.4",
|
"@types/sinon": "^17.0.4",
|
||||||
"@typescript-eslint/parser": "^7.18.0",
|
|
||||||
"@web/test-runner": "^0.19.0",
|
"@web/test-runner": "^0.19.0",
|
||||||
"@web/test-runner-browserstack": "^0.8.0",
|
"@web/test-runner-browserstack": "^0.8.0",
|
||||||
"@web/test-runner-mocha": "^0.9.0",
|
"@web/test-runner-mocha": "^0.9.0",
|
||||||
@ -92,21 +93,20 @@
|
|||||||
"chai": "^4.5.0",
|
"chai": "^4.5.0",
|
||||||
"chai-as-promised": "^8.0.1",
|
"chai-as-promised": "^8.0.1",
|
||||||
"eckey-utils": "^0.7.14",
|
"eckey-utils": "^0.7.14",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^9.36.0",
|
||||||
"eslint-config-airbnb": "^19.0.4",
|
"eslint-import-resolver-typescript": "^4.4.4",
|
||||||
"eslint-config-airbnb-base": "^15.0.0",
|
"eslint-plugin-chai-friendly": "^1.1.0",
|
||||||
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
||||||
"eslint-import-resolver-typescript": "^3.10.1",
|
|
||||||
"eslint-plugin-chai-friendly": "^0.7.4",
|
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-unicorn": "^48.0.1",
|
"eslint-plugin-unicorn": "^48.0.1",
|
||||||
"fflate": "^0.8.2",
|
"fflate": "^0.8.2",
|
||||||
|
"globals": "^16.4.0",
|
||||||
"mocha": "^11.7.1",
|
"mocha": "^11.7.1",
|
||||||
"playwright": "^1.56.0",
|
"playwright": "^1.56.0",
|
||||||
"rollup": "^4.48.1",
|
"rollup": "^4.48.1",
|
||||||
"sinon": "^21.0.0",
|
"sinon": "^21.0.0",
|
||||||
"tsx": "^4.20.5",
|
"tsx": "^4.20.5",
|
||||||
"typescript": "^5.9.2",
|
"typescript": "^5.9.2",
|
||||||
|
"typescript-eslint": "^8.44.1",
|
||||||
"web-streams-polyfill": "^4.2.0"
|
"web-streams-polyfill": "^4.2.0"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable no-process-env */
|
|
||||||
|
|
||||||
import { builtinModules } from 'module';
|
import { builtinModules } from 'module';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
|
|||||||
@ -189,7 +189,7 @@ function verifyHeaders(headers, packetlist) {
|
|||||||
.map(hashName => {
|
.map(hashName => {
|
||||||
try {
|
try {
|
||||||
return enums.write(enums.hash, hashName.toLowerCase());
|
return enums.write(enums.hash, hashName.toLowerCase());
|
||||||
} catch (e) {
|
} catch {
|
||||||
throw new Error('Unknown hash algorithm in armor header: ' + hashName.toLowerCase());
|
throw new Error('Unknown hash algorithm in armor header: ' + hashName.toLowerCase());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -458,7 +458,7 @@ export function generateSessionKey(algo) {
|
|||||||
function checkSupportedCurve(oid) {
|
function checkSupportedCurve(oid) {
|
||||||
try {
|
try {
|
||||||
oid.getName();
|
oid.getName();
|
||||||
} catch (e) {
|
} catch {
|
||||||
throw new UnsupportedError('Unknown curve OID');
|
throw new UnsupportedError('Unknown curve OID');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,7 +88,7 @@ export async function validateParams(algo, A, k) {
|
|||||||
const recomputedSharedSecret = await recomputeSharedSecret(algo, ephemeralPublicKey, A, k);
|
const recomputedSharedSecret = await recomputeSharedSecret(algo, ephemeralPublicKey, A, k);
|
||||||
|
|
||||||
return util.equalsUint8Array(sharedSecret, recomputedSharedSecret);
|
return util.equalsUint8Array(sharedSecret, recomputedSharedSecret);
|
||||||
} catch (_) {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -161,7 +161,7 @@ export async function validateParams(oid, Q, d) {
|
|||||||
const signature = await sign(oid, hashAlgo, message, Q, d, hashed);
|
const signature = await sign(oid, hashAlgo, message, Q, d, hashed);
|
||||||
// eslint-disable-next-line @typescript-eslint/return-await
|
// eslint-disable-next-line @typescript-eslint/return-await
|
||||||
return await verify(oid, hashAlgo, signature, message, Q, hashed);
|
return await verify(oid, hashAlgo, signature, message, Q, hashed);
|
||||||
} catch (err) {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ async function nodeVerify(curve, hashAlgo, { r, s }, message, publicKey) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return verify.verify({ key: derPublicKey, format: 'der', type: 'spki', dsaEncoding: 'ieee-p1363' }, signature);
|
return verify.verify({ key: derPublicKey, format: 'der', type: 'spki', dsaEncoding: 'ieee-p1363' }, signature);
|
||||||
} catch (err) {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -143,7 +143,7 @@ class CurveWithOID {
|
|||||||
this.name = oidOrName instanceof OID ?
|
this.name = oidOrName instanceof OID ?
|
||||||
oidOrName.getName() :
|
oidOrName.getName() :
|
||||||
enums.write(enums.curve,oidOrName);
|
enums.write(enums.curve,oidOrName);
|
||||||
} catch (err) {
|
} catch {
|
||||||
throw new UnsupportedError('Unknown curve');
|
throw new UnsupportedError('Unknown curve');
|
||||||
}
|
}
|
||||||
const params = curves[this.name];
|
const params = curves[this.name];
|
||||||
|
|||||||
@ -333,7 +333,7 @@ async function nodeVerify(hashAlgo, data, s, n, e) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return verify.verify(key, s);
|
return verify.verify(key, s);
|
||||||
} catch (err) {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,7 +361,7 @@ async function nodeDecrypt(data, n, e, d, p, q, u) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return new Uint8Array(nodeCrypto.privateDecrypt(key, data));
|
return new Uint8Array(nodeCrypto.privateDecrypt(key, data));
|
||||||
} catch (err) {
|
} catch {
|
||||||
throw new Error('Decryption error');
|
throw new Error('Decryption error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/enums.d.ts
vendored
1
src/enums.d.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-duplicate-enum-values */
|
||||||
declare namespace enums {
|
declare namespace enums {
|
||||||
export function read(type: typeof armor, e: armor): armorNames;
|
export function read(type: typeof armor, e: armor): armorNames;
|
||||||
export function read(type: typeof compression, e: compression): compressionNames;
|
export function read(type: typeof compression, e: compression): compressionNames;
|
||||||
|
|||||||
@ -357,7 +357,7 @@ export async function isDataRevoked(primaryKey, signatureType, dataToVerify, rev
|
|||||||
// TODO get an identifier of the revoked object instead
|
// TODO get an identifier of the revoked object instead
|
||||||
revocationKeyIDs.push(revocationSignature.issuerKeyID);
|
revocationKeyIDs.push(revocationSignature.issuerKeyID);
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
}));
|
}));
|
||||||
// TODO further verify that this is the signature that should be revoked
|
// TODO further verify that this is the signature that should be revoked
|
||||||
if (signature) {
|
if (signature) {
|
||||||
@ -398,7 +398,7 @@ export function sanitizeKeyOptions(options, subkeyDefaults = {}) {
|
|||||||
case 'ecc': // NB: this case also handles legacy eddsa and x25519 keys, based on `options.curve`
|
case 'ecc': // NB: this case also handles legacy eddsa and x25519 keys, based on `options.curve`
|
||||||
try {
|
try {
|
||||||
options.curve = enums.write(enums.curve, options.curve);
|
options.curve = enums.write(enums.curve, options.curve);
|
||||||
} catch (e) {
|
} catch {
|
||||||
throw new Error('Unknown curve');
|
throw new Error('Unknown curve');
|
||||||
}
|
}
|
||||||
if (options.curve === enums.curve.ed25519Legacy || options.curve === enums.curve.curve25519Legacy ||
|
if (options.curve === enums.curve.ed25519Legacy || options.curve === enums.curve.curve25519Legacy ||
|
||||||
|
|||||||
@ -442,7 +442,7 @@ class Key {
|
|||||||
} else {
|
} else {
|
||||||
primaryKeyExpiry = selfSigKeyExpiry < selfSigExpiry ? selfSigKeyExpiry : selfSigExpiry;
|
primaryKeyExpiry = selfSigKeyExpiry < selfSigExpiry ? selfSigKeyExpiry : selfSigExpiry;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
primaryKeyExpiry = null;
|
primaryKeyExpiry = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ class Key {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!users.length) {
|
if (!users.length) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
||||||
throw exception || new Error('Could not find primary user');
|
throw exception || new Error('Could not find primary user');
|
||||||
}
|
}
|
||||||
await Promise.all(users.map(async function (a) {
|
await Promise.all(users.map(async function (a) {
|
||||||
@ -751,8 +751,7 @@ class Key {
|
|||||||
}
|
}
|
||||||
|
|
||||||
['getKeyID', 'getFingerprint', 'getAlgorithmInfo', 'getCreationTime', 'hasSameFingerprintAs'].forEach(name => {
|
['getKeyID', 'getFingerprint', 'getAlgorithmInfo', 'getCreationTime', 'hasSameFingerprintAs'].forEach(name => {
|
||||||
Key.prototype[name] =
|
Key.prototype[name] = Subkey.prototype[name];
|
||||||
Subkey.prototype[name];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Key;
|
export default Key;
|
||||||
|
|||||||
@ -114,7 +114,7 @@ class PrivateKey extends PublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (keys.length === 0) {
|
if (keys.length === 0) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
||||||
throw exception || new Error('No decryption key packets found');
|
throw exception || new Error('No decryption key packets found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class Subkey {
|
|||||||
let bindingSignature;
|
let bindingSignature;
|
||||||
try {
|
try {
|
||||||
bindingSignature = await helper.getLatestValidSignature(this.bindingSignatures, primaryKey, enums.signature.subkeyBinding, dataToVerify, date, config);
|
bindingSignature = await helper.getLatestValidSignature(this.bindingSignatures, primaryKey, enums.signature.subkeyBinding, dataToVerify, date, config);
|
||||||
} catch (e) {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const keyExpiry = helper.getKeyExpirationTime(this.keyPacket, bindingSignature);
|
const keyExpiry = helper.getKeyExpirationTime(this.keyPacket, bindingSignature);
|
||||||
@ -153,7 +153,7 @@ class Subkey {
|
|||||||
try {
|
try {
|
||||||
await srcBindSig.verify(primaryKey, enums.signature.subkeyBinding, dataToVerify, date, undefined, config);
|
await srcBindSig.verify(primaryKey, enums.signature.subkeyBinding, dataToVerify, date, undefined, config);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -222,7 +222,7 @@ class User {
|
|||||||
try {
|
try {
|
||||||
await srcSelfSig.verify(primaryKey, enums.signature.certGeneric, dataToVerify, date, false, config);
|
await srcSelfSig.verify(primaryKey, enums.signature.certGeneric, dataToVerify, date, false, config);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -220,7 +220,7 @@ export class Message {
|
|||||||
if (selfCertification.preferredSymmetricAlgorithms) {
|
if (selfCertification.preferredSymmetricAlgorithms) {
|
||||||
algos = algos.concat(selfCertification.preferredSymmetricAlgorithms);
|
algos = algos.concat(selfCertification.preferredSymmetricAlgorithms);
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
|
|
||||||
await Promise.all(decryptionKeyPackets.map(async function(decryptionKeyPacket) {
|
await Promise.all(decryptionKeyPackets.map(async function(decryptionKeyPacket) {
|
||||||
if (!decryptionKeyPacket.isDecrypted()) {
|
if (!decryptionKeyPacket.isDecrypted()) {
|
||||||
@ -460,7 +460,7 @@ export class Message {
|
|||||||
try {
|
try {
|
||||||
await keyPacket.decrypt(password);
|
await keyPacket.decrypt(password);
|
||||||
return 1;
|
return 1;
|
||||||
} catch (e) {
|
} catch {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -26,7 +26,7 @@ export function newPacketFromTag(tag, allowedPackets) {
|
|||||||
let packetType;
|
let packetType;
|
||||||
try {
|
try {
|
||||||
packetType = enums.read(enums.packet, tag);
|
packetType = enums.read(enums.packet, tag);
|
||||||
} catch (e) {
|
} catch {
|
||||||
throw new UnknownPacketError(`Unknown packet type with tag: ${tag}`);
|
throw new UnknownPacketError(`Unknown packet type with tag: ${tag}`);
|
||||||
}
|
}
|
||||||
throw new Error(`Packet not allowed in this context: ${packetType}`);
|
throw new Error(`Packet not allowed in this context: ${packetType}`);
|
||||||
@ -174,7 +174,7 @@ class PacketList extends Array {
|
|||||||
// in case there's an MDC error, which should take precedence.
|
// in case there's an MDC error, which should take precedence.
|
||||||
if (unauthenticatedError) {
|
if (unauthenticatedError) {
|
||||||
await reader.readToEnd();
|
await reader.readToEnd();
|
||||||
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
||||||
throw unauthenticatedError;
|
throw unauthenticatedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -481,7 +481,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|||||||
try {
|
try {
|
||||||
const { privateParams } = parsePrivateKeyParams(this.algorithm, cleartext, this.publicParams);
|
const { privateParams } = parsePrivateKeyParams(this.algorithm, cleartext, this.publicParams);
|
||||||
this.privateParams = privateParams;
|
this.privateParams = privateParams;
|
||||||
} catch (err) {
|
} catch {
|
||||||
throw new Error('Error reading MPIs');
|
throw new Error('Error reading MPIs');
|
||||||
}
|
}
|
||||||
this.isEncrypted = false;
|
this.isEncrypted = false;
|
||||||
@ -515,7 +515,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|||||||
try {
|
try {
|
||||||
// this can throw if some parameters are undefined
|
// this can throw if some parameters are undefined
|
||||||
validParams = await validateParams(this.algorithm, this.publicParams, this.privateParams);
|
validParams = await validateParams(this.algorithm, this.publicParams, this.privateParams);
|
||||||
} catch (_) {
|
} catch {
|
||||||
validParams = false;
|
validParams = false;
|
||||||
}
|
}
|
||||||
if (!validParams) {
|
if (!validParams) {
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import defaultConfig from './config';
|
|||||||
const debugMode = (() => {
|
const debugMode = (() => {
|
||||||
try {
|
try {
|
||||||
return process.env.NODE_ENV === 'development'; // eslint-disable-line no-process-env
|
return process.env.NODE_ENV === 'development'; // eslint-disable-line no-process-env
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
return false;
|
return false;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ const util = {
|
|||||||
try {
|
try {
|
||||||
error.message += ': ' + cause.message;
|
error.message += ': ' + cause.message;
|
||||||
error.cause = cause;
|
error.cause = cause;
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
return new Error(error + ': ' + cause.message, { cause });
|
return new Error(error + ': ' + cause.message, { cause });
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
|
/* global require */
|
||||||
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { writeFileSync, unlinkSync } from 'fs';
|
import { writeFileSync, unlinkSync } from 'fs';
|
||||||
|
|||||||
@ -1016,8 +1016,7 @@ export default () => describe('Packet', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Reading signersUserID from armored signature', async function() {
|
it('Reading signersUserID from armored signature', async function() {
|
||||||
const armoredSignature =
|
const armoredSignature = `-----BEGIN PGP SIGNATURE-----
|
||||||
`-----BEGIN PGP SIGNATURE-----
|
|
||||||
|
|
||||||
iQFKBAEBCgA0FiEEdOyNPagqedqiXfEMa6Ve2Dq64bsFAlszXwQWHHRlc3Qtd2tk
|
iQFKBAEBCgA0FiEEdOyNPagqedqiXfEMa6Ve2Dq64bsFAlszXwQWHHRlc3Qtd2tk
|
||||||
QG1ldGFjb2RlLmJpegAKCRBrpV7YOrrhuw1PB/9KhFRR/M3OR6NmIent6ri1ekWn
|
QG1ldGFjb2RlLmJpegAKCRBrpV7YOrrhuw1PB/9KhFRR/M3OR6NmIent6ri1ekWn
|
||||||
@ -1035,8 +1034,7 @@ kePFjAnu9cpynKXu3usf8+FuBw2zLsg1Id1n7ttxoAte416KjBN9lFBt8mcu
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Reading notations from armored key', async function() {
|
it('Reading notations from armored key', async function() {
|
||||||
const pubkey =
|
const pubkey = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
`-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
|
|
||||||
mQENBFzQOToBCADd0Pwh8edZ6gR3x49L1PaBPtiAQUr1QDUDWeNes8co5MTFl5hG
|
mQENBFzQOToBCADd0Pwh8edZ6gR3x49L1PaBPtiAQUr1QDUDWeNes8co5MTFl5hG
|
||||||
lHzptt+VD0JGucuIkvi34f5z2ZbInAV/xYDX3kSYefy6LB8XJD527I/o9bqY1P7T
|
lHzptt+VD0JGucuIkvi34f5z2ZbInAV/xYDX3kSYefy6LB8XJD527I/o9bqY1P7T
|
||||||
|
|||||||
@ -61,7 +61,7 @@ async function makeKeyValid() {
|
|||||||
encryptionKeys: k
|
encryptionKeys: k
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
} catch (e) {
|
} catch {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import {
|
|||||||
encrypt, decrypt, sign, verify, config, enums,
|
encrypt, decrypt, sign, verify, config, enums,
|
||||||
generateSessionKey, encryptSessionKey, decryptSessionKeys,
|
generateSessionKey, encryptSessionKey, decryptSessionKeys,
|
||||||
LiteralDataPacket, PacketList, CompressedDataPacket, PublicKeyPacket, PublicSubkeyPacket, SecretKeyPacket, SecretSubkeyPacket, CleartextMessage,
|
LiteralDataPacket, PacketList, CompressedDataPacket, PublicKeyPacket, PublicSubkeyPacket, SecretKeyPacket, SecretSubkeyPacket, CleartextMessage,
|
||||||
WebStream, NodeWebStream,
|
WebStream, NodeWebStream
|
||||||
} from 'openpgp';
|
} from 'openpgp';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
@ -47,7 +47,7 @@ import {
|
|||||||
const parsedBinaryPrivateKey: PrivateKey = await readPrivateKey({ binaryKey: privateKeyBinary });
|
const parsedBinaryPrivateKey: PrivateKey = await readPrivateKey({ binaryKey: privateKeyBinary });
|
||||||
expect(parsedBinaryPrivateKey.isPrivate()).to.be.true;
|
expect(parsedBinaryPrivateKey.isPrivate()).to.be.true;
|
||||||
// a generic Key can be directly used as PublicKey, since both classes have the same properties
|
// a generic Key can be directly used as PublicKey, since both classes have the same properties
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const unusedPublicKey: PublicKey = parsedKey;
|
const unusedPublicKey: PublicKey = parsedKey;
|
||||||
|
|
||||||
// Check PrivateKey type inference
|
// Check PrivateKey type inference
|
||||||
@ -55,23 +55,23 @@ import {
|
|||||||
expect(parsedKey.isDecrypted()).to.be.true;
|
expect(parsedKey.isDecrypted()).to.be.true;
|
||||||
} else {
|
} else {
|
||||||
// @ts-expect-error isDecrypted is not defined for public keys
|
// @ts-expect-error isDecrypted is not defined for public keys
|
||||||
try { parsedKey.isDecrypted(); } catch (e) {}
|
try { parsedKey.isDecrypted(); } catch {}
|
||||||
}
|
}
|
||||||
(await privateKey.update(privateKey)).isDecrypted();
|
(await privateKey.update(privateKey)).isDecrypted();
|
||||||
(await privateKey.toPublic().update(privateKey)).isDecrypted();
|
(await privateKey.toPublic().update(privateKey)).isDecrypted();
|
||||||
// @ts-expect-error isDecrypted is not defined for public keys
|
// @ts-expect-error isDecrypted is not defined for public keys
|
||||||
try { (await privateKey.toPublic().update(privateKey.toPublic())).isDecrypted(); } catch (e) {}
|
try { (await privateKey.toPublic().update(privateKey.toPublic())).isDecrypted(); } catch {}
|
||||||
|
|
||||||
// Revoke keys
|
// Revoke keys
|
||||||
await revokeKey({ key: privateKey });
|
await revokeKey({ key: privateKey });
|
||||||
// @ts-expect-error for missing revocation certificate
|
// @ts-expect-error for missing revocation certificate
|
||||||
try { await revokeKey({ key: publicKey }); } catch (e) {}
|
try { await revokeKey({ key: publicKey }); } catch {}
|
||||||
const { privateKey: revokedPrivateKey, publicKey: revokedPublicKey } = await revokeKey({ key: privateKey, revocationCertificate, format: 'object' });
|
const { privateKey: revokedPrivateKey, publicKey: revokedPublicKey } = await revokeKey({ key: privateKey, revocationCertificate, format: 'object' });
|
||||||
expect(revokedPrivateKey).to.be.instanceOf(PrivateKey);
|
expect(revokedPrivateKey).to.be.instanceOf(PrivateKey);
|
||||||
expect(revokedPublicKey).to.be.instanceOf(PublicKey);
|
expect(revokedPublicKey).to.be.instanceOf(PublicKey);
|
||||||
const revokedKeyPair = await revokeKey({ key: publicKey, revocationCertificate, format: 'object' });
|
const revokedKeyPair = await revokeKey({ key: publicKey, revocationCertificate, format: 'object' });
|
||||||
// @ts-expect-error for null private key
|
// @ts-expect-error for null private key
|
||||||
try { revokedKeyPair.privateKey.armor(); } catch (e) {}
|
try { revokedKeyPair.privateKey.armor(); } catch {}
|
||||||
expect(revokedKeyPair.privateKey).to.be.null;
|
expect(revokedKeyPair.privateKey).to.be.null;
|
||||||
expect(revokedKeyPair.publicKey).to.be.instanceOf(PublicKey);
|
expect(revokedKeyPair.publicKey).to.be.instanceOf(PublicKey);
|
||||||
|
|
||||||
@ -123,16 +123,16 @@ import {
|
|||||||
const verifiedCleartextData: string = verificationResult.data;
|
const verifiedCleartextData: string = verificationResult.data;
|
||||||
expect(verifiedCleartextData).to.equal(cleartextMessage.getText());
|
expect(verifiedCleartextData).to.equal(cleartextMessage.getText());
|
||||||
// @ts-expect-error Binary output not available for cleartext messages
|
// @ts-expect-error Binary output not available for cleartext messages
|
||||||
try { await verify({ message: cleartextMessage, verificationKeys: publicKey, format: 'binary' }) } catch (e) {}
|
try { await verify({ message: cleartextMessage, verificationKeys: publicKey, format: 'binary' }) } catch {}
|
||||||
|
|
||||||
const clearSignedArmor = await sign({ signingKeys: privateKeys, message: cleartextMessage });
|
const clearSignedArmor = await sign({ signingKeys: privateKeys, message: cleartextMessage });
|
||||||
expect(clearSignedArmor).to.include('-----BEGIN PGP SIGNED MESSAGE-----');
|
expect(clearSignedArmor).to.include('-----BEGIN PGP SIGNED MESSAGE-----');
|
||||||
const clearSignedObject: CleartextMessage = await sign({ signingKeys: privateKeys, message: cleartextMessage, format: 'object' });
|
const clearSignedObject: CleartextMessage = await sign({ signingKeys: privateKeys, message: cleartextMessage, format: 'object' });
|
||||||
expect(clearSignedObject).to.be.instanceOf(CleartextMessage);
|
expect(clearSignedObject).to.be.instanceOf(CleartextMessage);
|
||||||
// @ts-expect-error PublicKey not assignable to PrivateKey
|
// @ts-expect-error PublicKey not assignable to PrivateKey
|
||||||
try { await sign({ signingKeys: publicKeys, message: cleartextMessage }); } catch (e) {}
|
try { await sign({ signingKeys: publicKeys, message: cleartextMessage }); } catch {}
|
||||||
// @ts-expect-error Key not assignable to PrivateKey
|
// @ts-expect-error Key not assignable to PrivateKey
|
||||||
try { await sign({ signingKeys: parsedKey, message: cleartextMessage }); } catch (e) {}
|
try { await sign({ signingKeys: parsedKey, message: cleartextMessage }); } catch {}
|
||||||
|
|
||||||
// Sign text message (armored)
|
// Sign text message (armored)
|
||||||
const textSignedArmor: string = await sign({ signingKeys: privateKeys, message: textMessage });
|
const textSignedArmor: string = await sign({ signingKeys: privateKeys, message: textMessage });
|
||||||
@ -147,7 +147,10 @@ import {
|
|||||||
expect(textSignedObject).to.be.instanceOf(Message);
|
expect(textSignedObject).to.be.instanceOf(Message);
|
||||||
|
|
||||||
// Sign text message (armored)
|
// Sign text message (armored)
|
||||||
const textSignedWithNotations: string = await sign({ signingKeys: privateKeys, message: textMessage, signatureNotations: [{
|
const textSignedWithNotations: string = await sign({
|
||||||
|
signingKeys: privateKeys,
|
||||||
|
message: textMessage,
|
||||||
|
signatureNotations: [{
|
||||||
name: 'test@example.org',
|
name: 'test@example.org',
|
||||||
value: new TextEncoder().encode('test'),
|
value: new TextEncoder().encode('test'),
|
||||||
humanReadable: true,
|
humanReadable: true,
|
||||||
@ -176,7 +179,7 @@ import {
|
|||||||
// @ts-expect-error for unsafe downcasting
|
// @ts-expect-error for unsafe downcasting
|
||||||
packets.map((packet: LiteralDataPacket) => packet.getText());
|
packets.map((packet: LiteralDataPacket) => packet.getText());
|
||||||
// @ts-expect-error for non-packet element
|
// @ts-expect-error for non-packet element
|
||||||
try { new PacketList().push(1); } catch (e) {}
|
try { new PacketList().push(1); } catch {}
|
||||||
|
|
||||||
// Packetlist of specific type
|
// Packetlist of specific type
|
||||||
const literalPackets = new PacketList<LiteralDataPacket>();
|
const literalPackets = new PacketList<LiteralDataPacket>();
|
||||||
@ -216,7 +219,7 @@ import {
|
|||||||
const nodeTextStream = NodeNativeReadableStream.toWeb(createReadStream('non-existent-file', { encoding: 'utf8' }));
|
const nodeTextStream = NodeNativeReadableStream.toWeb(createReadStream('non-existent-file', { encoding: 'utf8' }));
|
||||||
const messageFromNodeTextStream = await createMessage({ text: nodeTextStream });
|
const messageFromNodeTextStream = await createMessage({ text: nodeTextStream });
|
||||||
(await encrypt({ message: messageFromNodeTextStream, passwords: 'password', format: 'armored' })) as NodeWebStream<string>;
|
(await encrypt({ message: messageFromNodeTextStream, passwords: 'password', format: 'armored' })) as NodeWebStream<string>;
|
||||||
} catch (err) {}
|
} catch {}
|
||||||
const webTextStream = new WebReadableStream<string>();
|
const webTextStream = new WebReadableStream<string>();
|
||||||
const messageFromWebTextStream = await createMessage({ text: webTextStream });
|
const messageFromWebTextStream = await createMessage({ text: webTextStream });
|
||||||
(await encrypt({ message: messageFromWebTextStream, passwords: 'password', format: 'armored' })) as WebStream<string>;
|
(await encrypt({ message: messageFromWebTextStream, passwords: 'password', format: 'armored' })) as WebStream<string>;
|
||||||
@ -228,7 +231,7 @@ import {
|
|||||||
const nodeBinaryStream = NodeNativeReadableStream.toWeb(createReadStream('non-existent-file'));
|
const nodeBinaryStream = NodeNativeReadableStream.toWeb(createReadStream('non-existent-file'));
|
||||||
const messageFromNodeBinaryStream = await createMessage({ binary: nodeBinaryStream });
|
const messageFromNodeBinaryStream = await createMessage({ binary: nodeBinaryStream });
|
||||||
(await encrypt({ message: messageFromNodeBinaryStream, passwords: 'password', format: 'binary' })) as NodeWebStream<Uint8Array>;
|
(await encrypt({ message: messageFromNodeBinaryStream, passwords: 'password', format: 'binary' })) as NodeWebStream<Uint8Array>;
|
||||||
} catch (err) {}
|
} catch {}
|
||||||
const webBinaryStream = new WebReadableStream<Uint8Array>();
|
const webBinaryStream = new WebReadableStream<Uint8Array>();
|
||||||
const messageFromWebBinaryStream = await createMessage({ binary: webBinaryStream });
|
const messageFromWebBinaryStream = await createMessage({ binary: webBinaryStream });
|
||||||
(await encrypt({ message: messageFromWebBinaryStream, passwords: 'password', format: 'binary' })) as WebStream<Uint8Array>;
|
(await encrypt({ message: messageFromWebBinaryStream, passwords: 'password', format: 'binary' })) as WebStream<Uint8Array>;
|
||||||
@ -239,5 +242,6 @@ import {
|
|||||||
})().catch(e => {
|
})().catch(e => {
|
||||||
console.error('TypeScript definitions tests failed by throwing the following error');
|
console.error('TypeScript definitions tests failed by throwing the following error');
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
// eslint-disable-next-line no-process-exit
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -54,7 +54,7 @@ describe('Unit Tests', function () {
|
|||||||
openpgp.config[key] = decodeURIComponent(value);
|
openpgp.config[key] = decodeURIComponent(value);
|
||||||
try {
|
try {
|
||||||
openpgp.config[key] = window.eval(openpgp.config[key]); // eslint-disable-line no-eval
|
openpgp.config[key] = window.eval(openpgp.config[key]); // eslint-disable-line no-eval
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* globals openpgp */
|
/* globals openpgp, importScripts */
|
||||||
|
|
||||||
importScripts('../../dist/openpgp.js');
|
importScripts('../../dist/openpgp.js');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user