mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-09-14 21:20:10 +00:00
Compare commits
No commits in common. "main" and "v3.0.11" have entirely different histories.
14
.codeclimate.yml
Normal file
14
.codeclimate.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
engines:
|
||||||
|
duplication:
|
||||||
|
enabled: true
|
||||||
|
config:
|
||||||
|
languages:
|
||||||
|
- javascript
|
||||||
|
eslint:
|
||||||
|
enabled: true
|
||||||
|
fixme:
|
||||||
|
enabled: true
|
||||||
|
ratings:
|
||||||
|
paths:
|
||||||
|
- "lib/**/*"
|
@ -1,4 +1 @@
|
|||||||
dist
|
src/compression
|
||||||
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
|
|
||||||
}
|
|
||||||
};
|
|
344
.eslintrc.js
Normal file
344
.eslintrc.js
Normal file
@ -0,0 +1,344 @@
|
|||||||
|
module.exports = {
|
||||||
|
"extends": "airbnb-base",
|
||||||
|
"parserOptions": { "sourceType": "module" },
|
||||||
|
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es6": true,
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"globals": { // TODO are all these necessary?
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
|
||||||
|
"rules": {
|
||||||
|
// Auto generated rules:
|
||||||
|
"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"
|
||||||
|
],
|
||||||
|
"arrow-spacing": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"after": true,
|
||||||
|
"before": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"block-spacing": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"brace-style": "off",
|
||||||
|
"callback-return": "error",
|
||||||
|
"camelcase": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"properties": "never"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"capitalized-comments": "off",
|
||||||
|
"class-methods-use-this": "error",
|
||||||
|
"comma-dangle": [ "error", "never" ],
|
||||||
|
"comma-spacing": "off",
|
||||||
|
"comma-style": [
|
||||||
|
"error",
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"complexity": "off",
|
||||||
|
"computed-property-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"consistent-return": "off",
|
||||||
|
"consistent-this": "error",
|
||||||
|
"curly": "error",
|
||||||
|
"default-case": "off",
|
||||||
|
"dot-location": "error",
|
||||||
|
"dot-notation": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"allowKeywords": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"eol-last": "off",
|
||||||
|
"eqeqeq": "error",
|
||||||
|
"for-direction": "error",
|
||||||
|
"func-call-spacing": "error",
|
||||||
|
"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"
|
||||||
|
],
|
||||||
|
"init-declarations": "off",
|
||||||
|
"jsx-quotes": "error",
|
||||||
|
"key-spacing": "off",
|
||||||
|
"keyword-spacing": "off",
|
||||||
|
"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-await-in-loop": "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
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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",
|
||||||
|
{
|
||||||
|
"ignoreEOLComments": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-multi-str": "error",
|
||||||
|
"no-multiple-empty-lines": "error",
|
||||||
|
"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",
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-unused-expressions": "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": "off",
|
||||||
|
"object-property-newline": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"allowMultiplePropertiesPerLine": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"object-shorthand": "off",
|
||||||
|
"one-var-declaration-per-line": [
|
||||||
|
"error",
|
||||||
|
"initializations"
|
||||||
|
],
|
||||||
|
"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": "off",
|
||||||
|
"require-await": "error",
|
||||||
|
"require-jsdoc": "off",
|
||||||
|
"semi-spacing": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"after": true,
|
||||||
|
"before": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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"
|
||||||
|
],
|
||||||
|
"space-infix-ops": "off",
|
||||||
|
"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"
|
||||||
|
],
|
||||||
|
|
||||||
|
// Custom silencers:
|
||||||
|
"camelcase": 0,
|
||||||
|
"require-await": 0,
|
||||||
|
"no-multi-assign": 0,
|
||||||
|
"no-underscore-dangle": 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-unused-expressions": [ 2, { "allowShortCircuit": true } ],
|
||||||
|
"no-constant-condition": [ 2, { "checkLoops": false } ],
|
||||||
|
|
||||||
|
// Custom warnings:
|
||||||
|
"no-console": 1,
|
||||||
|
"no-unused-vars": 1,
|
||||||
|
|
||||||
|
// TODO Consider fixing these:
|
||||||
|
"indent": [ 0, 2, { "SwitchCase": 1 } ],
|
||||||
|
"valid-jsdoc": 0,
|
||||||
|
"new-cap": [ 0, { "properties": false, "capIsNewExceptionPattern": "^type_.*" }],
|
||||||
|
"no-lonely-if": 0,
|
||||||
|
"import/extensions": 0,
|
||||||
|
"no-buffer-constructor": 0, // deprecated
|
||||||
|
}
|
||||||
|
};
|
10
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
10
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Report an issue with this library
|
|
||||||
---
|
|
||||||
<!-- Please search existing issues and discussions to avoid creating duplicates. -->
|
|
||||||
|
|
||||||
- OpenPGP.js version:
|
|
||||||
- Affected platform (Browser or Node.js version):
|
|
||||||
|
|
||||||
<!-- Describe the bug you have encountered -->
|
|
8
.github/ISSUE_TEMPLATE/config.yml
vendored
8
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1,8 +0,0 @@
|
|||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: Feature request
|
|
||||||
url: https://github.com/openpgpjs/openpgpjs/discussions/categories/ideas
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
- name: Question
|
|
||||||
url: https://github.com/openpgpjs/openpgpjs/discussions/categories/q-a
|
|
||||||
about: Please ask any questions here
|
|
63
.github/dependabot.yml
vendored
63
.github/dependabot.yml
vendored
@ -1,63 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "npm"
|
|
||||||
# The redundant target-branch directive is needed to set two different update schedules for npm,
|
|
||||||
# working around a dependabot limitation:
|
|
||||||
# see https://github.com/dependabot/dependabot-core/issues/1778#issuecomment-1988140219 .
|
|
||||||
target-branch: main
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
allow:
|
|
||||||
- dependency-name: "playwright"
|
|
||||||
- dependency-name: "@noble*"
|
|
||||||
- dependency-name: "fflate"
|
|
||||||
versioning-strategy: increase
|
|
||||||
cooldown: # consider updates only X days after release
|
|
||||||
semver-major-days: 7
|
|
||||||
semver-minor-days: 1
|
|
||||||
semver-patch-days: 1
|
|
||||||
include:
|
|
||||||
- "*"
|
|
||||||
groups:
|
|
||||||
# Any packages matching the pattern @noble* where the highest resolvable
|
|
||||||
# version is minor or patch will be grouped together.
|
|
||||||
# Grouping rules apply to version updates only.
|
|
||||||
noble:
|
|
||||||
applies-to: version-updates
|
|
||||||
patterns:
|
|
||||||
- "@noble*"
|
|
||||||
update-types:
|
|
||||||
- "minor"
|
|
||||||
- "patch"
|
|
||||||
# update other dependencies separately on a monthly basis
|
|
||||||
- package-ecosystem: "npm"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "monthly"
|
|
||||||
ignore: # targeted by other schedule above
|
|
||||||
- dependency-name: "playwright"
|
|
||||||
- dependency-name: "@noble*"
|
|
||||||
- dependency-name: "fflate"
|
|
||||||
versioning-strategy: increase
|
|
||||||
cooldown: # consider updates only X days after release
|
|
||||||
semver-major-days: 30
|
|
||||||
semver-minor-days: 3
|
|
||||||
semver-patch-days: 3
|
|
||||||
include:
|
|
||||||
- "*"
|
|
||||||
groups:
|
|
||||||
dev-dependencies:
|
|
||||||
applies-to: version-updates
|
|
||||||
patterns:
|
|
||||||
- "*"
|
|
||||||
update-types: # major updates will trigger non-grouped MRs
|
|
||||||
- "minor"
|
|
||||||
- "patch"
|
|
||||||
|
|
||||||
- package-ecosystem: "github-actions"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
commit-message:
|
|
||||||
prefix: "CI"
|
|
39
.github/test-suite/config.json.template
vendored
39
.github/test-suite/config.json.template
vendored
@ -1,39 +0,0 @@
|
|||||||
{
|
|
||||||
"drivers": [
|
|
||||||
{
|
|
||||||
"id": "sop-openpgpjs-branch",
|
|
||||||
"path": "__SOP_OPENPGPJS__",
|
|
||||||
"env": {
|
|
||||||
"OPENPGPJS_PATH": "__OPENPGPJS_BRANCH__"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "sop-openpgpjs-main",
|
|
||||||
"path": "__SOP_OPENPGPJS__",
|
|
||||||
"env": {
|
|
||||||
"OPENPGPJS_PATH": "__OPENPGPJS_MAIN__",
|
|
||||||
"DISABLE_PROFILES": "true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "__SQOP__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "__GPGME_SOP__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "gosop-v2",
|
|
||||||
"path": "__GOSOP_V2__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "__RNP_SOP__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "__RSOP__"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"rlimits": {
|
|
||||||
"DATA": 1073741824
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
14
.github/test-suite/prepare_config.sh
vendored
14
.github/test-suite/prepare_config.sh
vendored
@ -1,14 +0,0 @@
|
|||||||
CONFIG_TEMPLATE=$1
|
|
||||||
CONFIG_OUTPUT=$2
|
|
||||||
OPENPGPJS_BRANCH=$3
|
|
||||||
OPENPGPJS_MAIN=$4
|
|
||||||
cat $CONFIG_TEMPLATE \
|
|
||||||
| sed "s@__OPENPGPJS_BRANCH__@${OPENPGPJS_BRANCH}@g" \
|
|
||||||
| sed "s@__OPENPGPJS_MAIN__@${OPENPGPJS_MAIN}@g" \
|
|
||||||
| sed "s@__SQOP__@${SQOP}@g" \
|
|
||||||
| sed "s@__GPGME_SOP__@${GPGME_SOP}@g" \
|
|
||||||
| sed "s@__GOSOP_V2__@${GOSOP_V2}@g" \
|
|
||||||
| sed "s@__SOP_OPENPGPJS__@${SOP_OPENPGPJS_V2}@g" \
|
|
||||||
| sed "s@__RNP_SOP__@${RNP_SOP}@g" \
|
|
||||||
| sed "s@__RSOP__@${RSOP}@g" \
|
|
||||||
> $CONFIG_OUTPUT
|
|
67
.github/workflows/benchmark.yml
vendored
67
.github/workflows/benchmark.yml
vendored
@ -1,67 +0,0 @@
|
|||||||
name: Performance Regression Test
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
benchmark:
|
|
||||||
name: Time and memory usage benchmark
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# check out pull request branch
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
path: pr
|
|
||||||
# check out main branch (to compare performance)
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: main
|
|
||||||
path: main
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '>=20.6.0'
|
|
||||||
|
|
||||||
- name: Run pull request time benchmark
|
|
||||||
run: cd pr && npm install && npm run --silent benchmark-time > benchmarks.txt && cat benchmarks.txt
|
|
||||||
|
|
||||||
- name: Run pull request memory usage benchmark
|
|
||||||
run: cd pr && npm run --silent benchmark-memory-usage > memory_usage.txt && cat memory_usage.txt
|
|
||||||
|
|
||||||
- name: Run time benchmark on main (baseline)
|
|
||||||
run: cd main && npm install && npm run --silent benchmark-time > benchmarks.txt && cat benchmarks.txt
|
|
||||||
|
|
||||||
- name: Run memory usage benchmark on main (baseline)
|
|
||||||
run: cd main && npm run --silent benchmark-memory-usage > memory_usage.txt && cat memory_usage.txt
|
|
||||||
|
|
||||||
- name: Compare time benchmark result
|
|
||||||
uses: openpgpjs/github-action-pull-request-benchmark@v1
|
|
||||||
with:
|
|
||||||
tool: 'benchmarkjs'
|
|
||||||
name: 'Time benchmark'
|
|
||||||
pr-benchmark-file-path: pr/benchmarks.txt
|
|
||||||
base-benchmark-file-path: main/benchmarks.txt
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# trigger alert comment if 1.3 times slower
|
|
||||||
alert-threshold: '130%'
|
|
||||||
comment-on-alert: false
|
|
||||||
# fail workdlow if 1.5 times slower
|
|
||||||
fail-threshold: '150%'
|
|
||||||
fail-on-alert: true
|
|
||||||
file-to-annotate: ${{ github.workspace }}/test/benchmarks/time.js
|
|
||||||
|
|
||||||
- name: Compare memory usage benchmark result
|
|
||||||
uses: openpgpjs/github-action-pull-request-benchmark@v1
|
|
||||||
with:
|
|
||||||
tool: 'raw'
|
|
||||||
name: 'Memory usage benchmark'
|
|
||||||
pr-benchmark-file-path: pr/memory_usage.txt
|
|
||||||
base-benchmark-file-path: main/memory_usage.txt
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
alert-threshold: '102%'
|
|
||||||
comment-on-alert: false
|
|
||||||
fail-threshold: '110%'
|
|
||||||
fail-on-alert: true
|
|
||||||
file-to-annotate: ${{ github.workspace }}/test/benchmarks/memory_usage.js
|
|
||||||
|
|
19
.github/workflows/docs.yml
vendored
19
.github/workflows/docs.yml
vendored
@ -1,19 +0,0 @@
|
|||||||
name: Documentation
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: JSDoc
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
- run: npm ci --ignore-scripts
|
|
||||||
- run: npm run docs
|
|
87
.github/workflows/sop-test-suite.yml
vendored
87
.github/workflows/sop-test-suite.yml
vendored
@ -1,87 +0,0 @@
|
|||||||
name: SOP interoperability test suite
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [ main ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
test-suite:
|
|
||||||
name: Run interoperability test suite
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: ghcr.io/protonmail/openpgp-interop-test-docker:v1.1.12
|
|
||||||
credentials:
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.github_token }}
|
|
||||||
steps:
|
|
||||||
# check out repo for scripts
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
# check out pull request branch
|
|
||||||
- name: Checkout openpgpjs-branch
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
path: openpgpjs-branch
|
|
||||||
- name: Install openpgpjs-branch
|
|
||||||
run: cd openpgpjs-branch && npm install
|
|
||||||
- name: Print openpgpjs-branch version
|
|
||||||
run: $SOP_OPENPGPJS_V2 version --extended
|
|
||||||
env:
|
|
||||||
OPENPGPJS_PATH: ${{ github.workspace }}/openpgpjs-branch
|
|
||||||
# check out main branch
|
|
||||||
- name: Checkout openpgpjs-main
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: main
|
|
||||||
path: openpgpjs-main
|
|
||||||
- name: Install openpgpjs-main
|
|
||||||
run: cd openpgpjs-main && npm install
|
|
||||||
- name: Print openpgpjs-main version
|
|
||||||
run: $SOP_OPENPGPJS_V2 version --extended
|
|
||||||
env:
|
|
||||||
OPENPGPJS_PATH: ${{ github.workspace }}/openpgpjs-main
|
|
||||||
# Run test suite
|
|
||||||
- name: Prepare test configuration
|
|
||||||
run: ./.github/test-suite/prepare_config.sh $CONFIG_TEMPLATE $CONFIG_OUTPUT $GITHUB_WORKSPACE/openpgpjs-branch $GITHUB_WORKSPACE/openpgpjs-main
|
|
||||||
env:
|
|
||||||
CONFIG_TEMPLATE: .github/test-suite/config.json.template
|
|
||||||
CONFIG_OUTPUT: .github/test-suite/config.json
|
|
||||||
- name: Display configuration
|
|
||||||
run: cat .github/test-suite/config.json
|
|
||||||
- name: Run interoperability test suite
|
|
||||||
run: cd $TEST_SUITE_DIR && $TEST_SUITE --config $GITHUB_WORKSPACE/$CONFIG --json-out $GITHUB_WORKSPACE/$RESULTS_JSON --html-out $GITHUB_WORKSPACE/$RESULTS_HTML
|
|
||||||
env:
|
|
||||||
CONFIG: .github/test-suite/config.json
|
|
||||||
RESULTS_JSON: .github/test-suite/test-suite-results.json
|
|
||||||
RESULTS_HTML: .github/test-suite/test-suite-results.html
|
|
||||||
# Upload results
|
|
||||||
- name: Upload test results json artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: test-suite-results.json
|
|
||||||
path: .github/test-suite/test-suite-results.json
|
|
||||||
- name: Upload test results html artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: test-suite-results.html
|
|
||||||
path: .github/test-suite/test-suite-results.html
|
|
||||||
|
|
||||||
compare-with-main:
|
|
||||||
name: Compare with main
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: test-suite
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Download test results json artifact
|
|
||||||
id: download-test-results
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: test-suite-results.json
|
|
||||||
- name: Compare with baseline
|
|
||||||
uses: ProtonMail/openpgp-interop-test-analyzer@v2
|
|
||||||
with:
|
|
||||||
results: ${{ steps.download-test-results.outputs.download-path }}/test-suite-results.json
|
|
||||||
output: baseline-comparison.json
|
|
||||||
baseline: sop-openpgpjs-main
|
|
||||||
target: sop-openpgpjs-branch
|
|
208
.github/workflows/tests.yml
vendored
208
.github/workflows/tests.yml
vendored
@ -1,208 +0,0 @@
|
|||||||
name: Code Tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build: # cache both dist and tests (non-lightweight only), based on commit hash
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
- name: Check for cached folders
|
|
||||||
id: cache-full
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
dist
|
|
||||||
test/lib
|
|
||||||
key: cache-${{ github.sha }}
|
|
||||||
- name: Build dist and tests
|
|
||||||
if: steps.cache-full.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
npm ci
|
|
||||||
npm run build-test
|
|
||||||
|
|
||||||
node:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false # if tests for one version fail, continue with the rest
|
|
||||||
matrix:
|
|
||||||
node-version: [18.x, 20.x, 22.x]
|
|
||||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
||||||
|
|
||||||
name: Node ${{ matrix.node-version }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
- run: npm ci --ignore-scripts # for mocha
|
|
||||||
- name: Retrieve cached folders
|
|
||||||
uses: actions/cache/restore@v4
|
|
||||||
id: cache-full
|
|
||||||
with:
|
|
||||||
# test/lib is not needed, but the path must be specified fully for a cache-hit
|
|
||||||
path: |
|
|
||||||
dist
|
|
||||||
test/lib
|
|
||||||
key: cache-${{ github.sha }}
|
|
||||||
fail-on-cache-miss: true # sanity check for runner issues or misconfigurations
|
|
||||||
- run: npm test
|
|
||||||
|
|
||||||
test-browsers-latest:
|
|
||||||
name: Browsers (latest)
|
|
||||||
needs: build
|
|
||||||
strategy:
|
|
||||||
fail-fast: false # if tests for one version fail, continue with the rest
|
|
||||||
matrix:
|
|
||||||
# run on all main platforms to test platform-specific code, if present
|
|
||||||
# (e.g. webkit's WebCrypto API implementation is different in macOS vs Linux)
|
|
||||||
runner: ['ubuntu-latest', 'macos-latest', 'windows-latest']
|
|
||||||
runs-on: ${{ matrix.runner }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
|
|
||||||
- name: Retrieve cached built folders
|
|
||||||
uses: actions/cache/restore@v4
|
|
||||||
id: cache-full
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
dist
|
|
||||||
test/lib
|
|
||||||
key: cache-${{ github.sha }}
|
|
||||||
enableCrossOsArchive: true
|
|
||||||
fail-on-cache-miss: true # sanity check for runner issues or misconfigurations
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
# cannot use `--ignore-scripts` since playwright seems to use it to set ENV vars
|
|
||||||
run: |
|
|
||||||
npm pkg delete scripts.prepare
|
|
||||||
npm ci
|
|
||||||
|
|
||||||
- name: Get Playwright version and cache location
|
|
||||||
id: playwright-version
|
|
||||||
if: ${{ matrix.runner != 'windows-latest' }} # setting env vars does not work in windows, it'd require custom handling
|
|
||||||
run: |
|
|
||||||
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/^Version //')
|
|
||||||
echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
|
|
||||||
PLAYWRIGHT_CACHE=${{ fromJSON('{"ubuntu-latest": "~/.cache/ms-playwright", "macos-latest": "~/Library/Caches/ms-playwright"}')[matrix.runner] }}
|
|
||||||
echo "playwright_cache=$PLAYWRIGHT_CACHE" >> $GITHUB_OUTPUT
|
|
||||||
- name: Check for cached browsers
|
|
||||||
id: cache-playwright-browsers
|
|
||||||
if: ${{ matrix.runner != 'windows-latest' }}
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ${{ steps.playwright-version.outputs.playwright_cache }}
|
|
||||||
key: playwright-browsers-${{ matrix.runner }}-${{ steps.playwright-version.outputs.version }}
|
|
||||||
- name: Install browsers
|
|
||||||
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
npx playwright install --with-deps chromium
|
|
||||||
npx playwright install --with-deps firefox
|
|
||||||
|
|
||||||
- name: Install WebKit # caching not possible, external shared libraries required
|
|
||||||
run: npx playwright install --with-deps webkit
|
|
||||||
|
|
||||||
- name: Run browser tests
|
|
||||||
run: npm run test-browser:ci -- --static-logging
|
|
||||||
|
|
||||||
- name: Run browser tests (lightweight) # overwrite test/lib
|
|
||||||
run: |
|
|
||||||
npm run build-test -- --config-test-lightweight-build
|
|
||||||
npm run test-browser:ci -- --static-logging
|
|
||||||
|
|
||||||
test-browsers-compatibility:
|
|
||||||
name: Browsers (older, on Browserstack)
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: test-browsers-latest
|
|
||||||
env: # credentials need hardcoding for now since Github secrets aren't accessible on pull requests from forks
|
|
||||||
BROWSERSTACK_USERNAME: openpgpjs_PlY4Uq885CQ
|
|
||||||
BROWSERSTACK_ACCESS_KEY: VjgBVRMxNVBj7SjJFiau
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
|
|
||||||
- name: Generate self-signed HTTPS certificates for web-test-runner server
|
|
||||||
uses: kofemann/action-create-certificate@v0.0.4
|
|
||||||
with:
|
|
||||||
hostcert: '127.0.0.1.pem'
|
|
||||||
hostkey: '127.0.0.1-key.pem'
|
|
||||||
cachain: 'ca-chain.pem'
|
|
||||||
- name: Adjust HTTPS certificates permissions
|
|
||||||
run: sudo chown runner:docker *.pem
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci --ignore-scripts
|
|
||||||
|
|
||||||
- name: Retrieve cached dist folder
|
|
||||||
uses: actions/cache/restore@v4
|
|
||||||
id: cache-full
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
dist
|
|
||||||
test/lib
|
|
||||||
key: cache-${{ github.sha }}
|
|
||||||
|
|
||||||
- name: Wait for other Browserstack tests to finish
|
|
||||||
uses: softprops/turnstyle@v1
|
|
||||||
with:
|
|
||||||
poll-interval-seconds: 30
|
|
||||||
abort-after-seconds: 900
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Run browserstack tests
|
|
||||||
run: npm run test-browserstack -- --static-logging
|
|
||||||
|
|
||||||
- name: Run browserstack tests (lightweight) # overwrite test/lib
|
|
||||||
run: |
|
|
||||||
npm run build-test -- --config-test-lightweight-build
|
|
||||||
npm run test-browserstack -- --static-logging
|
|
||||||
env:
|
|
||||||
LIGHTWEIGHT: true
|
|
||||||
|
|
||||||
types:
|
|
||||||
name: Type definitions
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
- run: npm ci --ignore-scripts # TS
|
|
||||||
- name: Retrieve cached folders
|
|
||||||
uses: actions/cache/restore@v4
|
|
||||||
id: cache-full
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
dist
|
|
||||||
test/lib
|
|
||||||
key: cache-${{ github.sha }}
|
|
||||||
- run: npm run test-type-definitions
|
|
||||||
|
|
||||||
lint:
|
|
||||||
name: ESLint
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
- run: npm ci --ignore-scripts # linter
|
|
||||||
- name: Retrieve cached folders
|
|
||||||
uses: actions/cache/restore@v4
|
|
||||||
id: cache-full
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
dist
|
|
||||||
test/lib
|
|
||||||
key: cache-${{ github.sha }}
|
|
||||||
- run: npm run lint
|
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,8 +1,11 @@
|
|||||||
|
build/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules/
|
node_modules/
|
||||||
npm*
|
npm*
|
||||||
|
src/compression/
|
||||||
test/lib/
|
test/lib/
|
||||||
test/typescript/definitions.js
|
|
||||||
dist/
|
dist/
|
||||||
|
dist/*.tgz
|
||||||
|
dist/*_debug.js
|
||||||
openpgp.store/
|
openpgp.store/
|
||||||
coverage
|
doc/
|
||||||
|
17
.jsdocrc.cjs
17
.jsdocrc.cjs
@ -1,17 +0,0 @@
|
|||||||
const pkg = require('./package.json');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
plugins: ['plugins/markdown'],
|
|
||||||
markdown: {
|
|
||||||
idInHeadings: true
|
|
||||||
},
|
|
||||||
templates: {
|
|
||||||
default: {
|
|
||||||
includeDate: false,
|
|
||||||
outputSourceFiles: false,
|
|
||||||
externalSourceLinks: {
|
|
||||||
urlPrefix: `${pkg.repository.url}/blob/v${pkg.version}/src/`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
3
.jsdocrc.js
Normal file
3
.jsdocrc.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: ['plugins/markdown']
|
||||||
|
};
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"node-option": [
|
|
||||||
"experimental-specifier-resolution=node",
|
|
||||||
"loader=ts-node/esm"
|
|
||||||
]
|
|
||||||
}
|
|
57
.travis.yml
Normal file
57
.travis.yml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
sudo: false
|
||||||
|
language: node_js
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- node_modules
|
||||||
|
addons:
|
||||||
|
code_climate:
|
||||||
|
repo_token: $CODECLIMATE_REPO_TOKEN
|
||||||
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
|
include:
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='unit' OPENPGP_NODE_JS='8'
|
||||||
|
- node_js: "9"
|
||||||
|
env: OPENPGPJSTEST='unit' OPENPGP_NODE_JS='9'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-0' BROWSER='firefox 38'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-1' BROWSER='firefox 54'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-2' BROWSER='chrome 38'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-3' BROWSER='chrome 59'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-6' BROWSER='safari 8'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-7' BROWSER='safari 10'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-5' BROWSER='microsoft edge 15'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-4' BROWSER='internet explorer 11'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-8' BROWSER='android 4.4'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-9' BROWSER='android 6.0'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-10' BROWSER='iphone 7.0'
|
||||||
|
- node_js: "8"
|
||||||
|
env: OPENPGPJSTEST='end2end-11' BROWSER='iphone 11.0'
|
||||||
|
allow_failures:
|
||||||
|
- env: OPENPGPJSTEST='end2end-0' BROWSER='firefox 38'
|
||||||
|
- env: OPENPGPJSTEST='end2end-1' BROWSER='firefox 54'
|
||||||
|
- env: OPENPGPJSTEST='end2end-2' BROWSER='chrome 38'
|
||||||
|
- env: OPENPGPJSTEST='end2end-3' BROWSER='chrome 59'
|
||||||
|
- env: OPENPGPJSTEST='end2end-6' BROWSER='safari 8'
|
||||||
|
- env: OPENPGPJSTEST='end2end-7' BROWSER='safari 10'
|
||||||
|
- env: OPENPGPJSTEST='end2end-5' BROWSER='microsoft edge 15'
|
||||||
|
- env: OPENPGPJSTEST='end2end-4' BROWSER='internet explorer 11'
|
||||||
|
- env: OPENPGPJSTEST='end2end-8' BROWSER='android 4.4'
|
||||||
|
- env: OPENPGPJSTEST='end2end-9' BROWSER='android 6.0'
|
||||||
|
- env: OPENPGPJSTEST='end2end-10' BROWSER='iphone 7.0'
|
||||||
|
- env: OPENPGPJSTEST='end2end-11' BROWSER='iphone 11.0'
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g grunt-cli codeclimate-test-reporter
|
||||||
|
script:
|
||||||
|
- $TRAVIS_BUILD_DIR/travis.sh
|
308
Gruntfile.js
Normal file
308
Gruntfile.js
Normal file
@ -0,0 +1,308 @@
|
|||||||
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
|
var version = grunt.option('release');
|
||||||
|
var fs = require('fs');
|
||||||
|
var browser_capabilities;
|
||||||
|
|
||||||
|
if (process.env.SELENIUM_BROWSER_CAPABILITIES !== undefined) {
|
||||||
|
browser_capabilities = JSON.parse(process.env.SELENIUM_BROWSER_CAPABILITIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
var getSauceKey = function getSaucekey () {
|
||||||
|
return '60ffb656-2346-4b77-81f3-bc435ff4c103';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Project configuration.
|
||||||
|
grunt.initConfig({
|
||||||
|
pkg: grunt.file.readJSON('package.json'),
|
||||||
|
browserify: {
|
||||||
|
openpgp: {
|
||||||
|
files: {
|
||||||
|
'dist/openpgp.js': ['./src/index.js']
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
browserifyOptions: {
|
||||||
|
standalone: 'openpgp'
|
||||||
|
},
|
||||||
|
// Don't bundle these packages with openpgp.js
|
||||||
|
external: ['crypto', 'zlib', 'node-localstorage', 'node-fetch', 'asn1.js'],
|
||||||
|
transform: [
|
||||||
|
["babelify", {
|
||||||
|
global: true,
|
||||||
|
// Only babelify asmcrypto and address-rfc2822 in node_modules
|
||||||
|
only: /^(?:.*\/node_modules\/asmcrypto\.js\/|.*\/node_modules\/address-rfc2822\/|(?!.*\/node_modules\/)).*$/,
|
||||||
|
plugins: ["transform-async-to-generator",
|
||||||
|
"syntax-async-functions",
|
||||||
|
"transform-regenerator",
|
||||||
|
"transform-runtime"],
|
||||||
|
ignore: ['*.min.js'],
|
||||||
|
presets: ["env"]
|
||||||
|
}]
|
||||||
|
],
|
||||||
|
plugin: ['browserify-derequire']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
openpgp_debug: {
|
||||||
|
files: {
|
||||||
|
'dist/openpgp_debug.js': ['./src/index.js']
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
browserifyOptions: {
|
||||||
|
fullPaths: true,
|
||||||
|
debug: true,
|
||||||
|
standalone: 'openpgp'
|
||||||
|
},
|
||||||
|
external: ['crypto', 'zlib', 'node-localstorage', 'node-fetch', 'asn1.js'],
|
||||||
|
transform: [
|
||||||
|
["babelify", {
|
||||||
|
global: true,
|
||||||
|
// Only babelify asmcrypto in node_modules
|
||||||
|
only: /^(?:.*\/node_modules\/asmcrypto\.js\/|(?!.*\/node_modules\/)).*$/,
|
||||||
|
plugins: ["transform-async-to-generator",
|
||||||
|
"syntax-async-functions",
|
||||||
|
"transform-regenerator",
|
||||||
|
"transform-runtime"],
|
||||||
|
ignore: ['*.min.js'],
|
||||||
|
presets: ["env"]
|
||||||
|
}]
|
||||||
|
],
|
||||||
|
plugin: ['browserify-derequire']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
worker: {
|
||||||
|
files: {
|
||||||
|
'dist/openpgp.worker.js': ['./src/worker/worker.js']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unittests: {
|
||||||
|
files: {
|
||||||
|
'test/lib/unittests-bundle.js': ['./test/unittests.js']
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
external: ['buffer', 'openpgp', '../../dist/openpgp', '../../../dist/openpgp'],
|
||||||
|
transform: [
|
||||||
|
["babelify", {
|
||||||
|
global: true,
|
||||||
|
// Only babelify chai-as-promised in node_modules
|
||||||
|
only: /^(?:.*\/node_modules\/chai-as-promised\/|(?!.*\/node_modules\/)).*$/,
|
||||||
|
plugins: ["transform-async-to-generator",
|
||||||
|
"syntax-async-functions",
|
||||||
|
"transform-regenerator",
|
||||||
|
"transform-runtime",
|
||||||
|
"transform-remove-strict-mode"],
|
||||||
|
ignore: ['*.min.js'],
|
||||||
|
presets: ["env"]
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
replace: {
|
||||||
|
openpgp: {
|
||||||
|
src: ['dist/openpgp.js'],
|
||||||
|
dest: ['dist/openpgp.js'],
|
||||||
|
replacements: [{
|
||||||
|
from: /OpenPGP.js VERSION/g,
|
||||||
|
to: 'OpenPGP.js v<%= pkg.version %>'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
openpgp_debug: {
|
||||||
|
src: ['dist/openpgp_debug.js'],
|
||||||
|
dest: ['dist/openpgp_debug.js'],
|
||||||
|
replacements: [{
|
||||||
|
from: /OpenPGP.js VERSION/g,
|
||||||
|
to: 'OpenPGP.js v<%= pkg.version %>'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
openpgp_min: {
|
||||||
|
src: ['dist/openpgp.min.js'],
|
||||||
|
dest: ['dist/openpgp.min.js'],
|
||||||
|
replacements: [{
|
||||||
|
from: "openpgp.worker.js",
|
||||||
|
to: "openpgp.worker.min.js"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
worker_min: {
|
||||||
|
src: ['dist/openpgp.worker.min.js'],
|
||||||
|
dest: ['dist/openpgp.worker.min.js'],
|
||||||
|
replacements: [{
|
||||||
|
from: "openpgp.js",
|
||||||
|
to: "openpgp.min.js"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
uglify: {
|
||||||
|
openpgp: {
|
||||||
|
files: {
|
||||||
|
'dist/openpgp.min.js' : ['dist/openpgp.js'],
|
||||||
|
'dist/openpgp.worker.min.js' : ['dist/openpgp.worker.js']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
banner: '/*! OpenPGP.js v<%= pkg.version %> - ' +
|
||||||
|
'<%= grunt.template.today("yyyy-mm-dd") %> - ' +
|
||||||
|
'this is LGPL licensed code, see LICENSE/our website <%= pkg.homepage %> for more information. */'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
jsbeautifier: {
|
||||||
|
files: ['src/**/*.js'],
|
||||||
|
options: {
|
||||||
|
indent_size: 2,
|
||||||
|
preserve_newlines: true,
|
||||||
|
keep_array_indentation: false,
|
||||||
|
keep_function_indentation: false,
|
||||||
|
wrap_line_length: 120
|
||||||
|
}
|
||||||
|
},
|
||||||
|
eslint: {
|
||||||
|
target: ['src/**/*.js'],
|
||||||
|
options: { configFile: '.eslintrc.js' }
|
||||||
|
},
|
||||||
|
jsdoc: {
|
||||||
|
dist: {
|
||||||
|
src: ['README.md', 'src'],
|
||||||
|
options: {
|
||||||
|
configure: '.jsdocrc.js',
|
||||||
|
destination: 'doc',
|
||||||
|
recurse: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mocha_istanbul: {
|
||||||
|
coverage: {
|
||||||
|
src: 'test',
|
||||||
|
options: {
|
||||||
|
root: '.',
|
||||||
|
timeout: 240000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mochaTest: {
|
||||||
|
unittests: {
|
||||||
|
options: {
|
||||||
|
reporter: 'spec',
|
||||||
|
timeout: 120000
|
||||||
|
},
|
||||||
|
src: ['test/unittests.js']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
copy: {
|
||||||
|
browsertest: {
|
||||||
|
expand: true,
|
||||||
|
flatten: true,
|
||||||
|
cwd: 'node_modules/',
|
||||||
|
src: ['mocha/mocha.css', 'mocha/mocha.js'],
|
||||||
|
dest: 'test/lib/'
|
||||||
|
},
|
||||||
|
bzip2: {
|
||||||
|
expand: true,
|
||||||
|
cwd: 'node_modules/compressjs/bin/',
|
||||||
|
src: ['bzip2.build.js'],
|
||||||
|
dest: 'src/compression/'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clean: ['dist/'],
|
||||||
|
connect: {
|
||||||
|
dev: {
|
||||||
|
options: {
|
||||||
|
port: 3001,
|
||||||
|
base: '.',
|
||||||
|
keepalive: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
options: {
|
||||||
|
port: 3000,
|
||||||
|
base: '.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'saucelabs-mocha': {
|
||||||
|
all: {
|
||||||
|
options: {
|
||||||
|
username: 'openpgpjs',
|
||||||
|
key: getSauceKey,
|
||||||
|
urls: ['http://127.0.0.1:3000/test/unittests.html'],
|
||||||
|
build: process.env.TRAVIS_BUILD_ID,
|
||||||
|
testname: 'Sauce Unit Test for openpgpjs',
|
||||||
|
browsers: [browser_capabilities],
|
||||||
|
public: "public",
|
||||||
|
maxRetries: 3,
|
||||||
|
throttled: 2,
|
||||||
|
pollInterval: 10000,
|
||||||
|
sauceConfig: {maxDuration: 1800, commandTimeout: 600, idleTimeout: 1000},
|
||||||
|
statusCheckAttempts: 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
src: {
|
||||||
|
files: ['src/**/*.js'],
|
||||||
|
tasks: ['browserify:openpgp', 'browserify:worker']
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
files: ['test/*.js', 'test/crypto/**/*.js', 'test/general/**/*.js', 'test/worker/**/*.js'],
|
||||||
|
tasks: ['browserify:unittests']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load the plugin(s)
|
||||||
|
grunt.loadNpmTasks('grunt-browserify');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-uglify-es');
|
||||||
|
grunt.loadNpmTasks('grunt-text-replace');
|
||||||
|
grunt.loadNpmTasks('grunt-jsbeautifier');
|
||||||
|
grunt.loadNpmTasks('grunt-jsdoc');
|
||||||
|
grunt.loadNpmTasks('gruntify-eslint');
|
||||||
|
grunt.loadNpmTasks('grunt-mocha-istanbul');
|
||||||
|
grunt.loadNpmTasks('grunt-mocha-test');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||||
|
grunt.loadNpmTasks('grunt-saucelabs');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||||
|
|
||||||
|
grunt.registerTask('set_version', function() {
|
||||||
|
if (!version) {
|
||||||
|
throw new Error('You must specify the version: "--release=1.0.0"');
|
||||||
|
}
|
||||||
|
|
||||||
|
patchFile({
|
||||||
|
fileName: 'package.json',
|
||||||
|
version: version
|
||||||
|
});
|
||||||
|
|
||||||
|
patchFile({
|
||||||
|
fileName: 'npm-shrinkwrap.json',
|
||||||
|
version: version
|
||||||
|
});
|
||||||
|
|
||||||
|
patchFile({
|
||||||
|
fileName: 'bower.json',
|
||||||
|
version: version
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function patchFile(options) {
|
||||||
|
var path = './' + options.fileName,
|
||||||
|
file = require(path);
|
||||||
|
|
||||||
|
if (options.version) {
|
||||||
|
file.version = options.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(path, JSON.stringify(file, null, 2) + '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build tasks
|
||||||
|
grunt.registerTask('version', ['replace:openpgp', 'replace:openpgp_debug']);
|
||||||
|
grunt.registerTask('replace_min', ['replace:openpgp_min', 'replace:worker_min']);
|
||||||
|
grunt.registerTask('default', ['clean', 'copy:bzip2', 'browserify', 'version', 'uglify', 'replace_min']);
|
||||||
|
grunt.registerTask('documentation', ['jsdoc']);
|
||||||
|
// Test/Dev tasks
|
||||||
|
grunt.registerTask('test', ['eslint', 'mochaTest']);
|
||||||
|
grunt.registerTask('coverage', ['mocha_istanbul:coverage']);
|
||||||
|
grunt.registerTask('saucelabs', ['default', 'copy:browsertest', 'connect:test', 'saucelabs-mocha']);
|
||||||
|
grunt.registerTask('browsertest', ['default', 'copy:browsertest', 'connect:test', 'watch']);
|
||||||
|
|
||||||
|
};
|
771
README.md
771
README.md
@ -1,663 +1,341 @@
|
|||||||
OpenPGP.js [](https://gitter.im/openpgpjs/openpgpjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
OpenPGP.js [](https://travis-ci.org/openpgpjs/openpgpjs)
|
||||||
==========
|
==========
|
||||||
|
|
||||||
[OpenPGP.js](https://openpgpjs.org/) is a JavaScript implementation of the OpenPGP protocol. It implements [RFC 9580](https://datatracker.ietf.org/doc/rfc9580/) (superseding [RFC 4880](https://tools.ietf.org/html/rfc4880) and [RFC 4880bis](https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-10)).
|
[OpenPGP.js](https://openpgpjs.org/) is a JavaScript implementation of the OpenPGP protocol. This is defined in [RFC 4880](https://tools.ietf.org/html/rfc4880).
|
||||||
|
|
||||||
|
|
||||||
|
[](https://saucelabs.com/u/openpgpjs)
|
||||||
|
|
||||||
|
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
|
||||||
**Table of Contents**
|
**Table of Contents**
|
||||||
|
|
||||||
- [OpenPGP.js](#openpgpjs)
|
- [OpenPGP.js](#openpgpjs)
|
||||||
- [Platform Support](#platform-support)
|
- [Platform Support](#platform-support)
|
||||||
- [Performance](#performance)
|
- [Performance](#performance)
|
||||||
- [Getting started](#getting-started)
|
- [Getting started](#getting-started)
|
||||||
- [Node.js](#nodejs)
|
- [Npm](#npm)
|
||||||
- [Deno (experimental)](#deno-experimental)
|
- [Bower](#bower)
|
||||||
- [Browser (webpack)](#browser-webpack)
|
- [Examples](#examples)
|
||||||
- [Browser (plain files)](#browser-plain-files)
|
- [Set up](#set-up)
|
||||||
- [Updating from older versions of the library](#updating-from-older-versions-of-the-library)
|
|
||||||
- [Code examples](#code-examples)
|
|
||||||
- [Encrypt and decrypt *Uint8Array* data with a password](#encrypt-and-decrypt-uint8array-data-with-a-password)
|
- [Encrypt and decrypt *Uint8Array* data with a password](#encrypt-and-decrypt-uint8array-data-with-a-password)
|
||||||
- [Encrypt and decrypt *String* data with PGP keys](#encrypt-and-decrypt-string-data-with-pgp-keys)
|
- [Encrypt and decrypt *String* data with PGP keys](#encrypt-and-decrypt-string-data-with-pgp-keys)
|
||||||
- [Encrypt symmetrically with compression](#encrypt-symmetrically-with-compression)
|
- [Encrypt with compression](#encrypt-with-compression)
|
||||||
- [Streaming encrypt *Uint8Array* data with a password](#streaming-encrypt-uint8array-data-with-a-password)
|
|
||||||
- [Streaming encrypt and decrypt *String* data with PGP keys](#streaming-encrypt-and-decrypt-string-data-with-pgp-keys)
|
|
||||||
- [Generate new key pair](#generate-new-key-pair)
|
- [Generate new key pair](#generate-new-key-pair)
|
||||||
- [Revoke a key](#revoke-a-key)
|
- [Lookup public key on HKP server](#lookup-public-key-on-hkp-server)
|
||||||
|
- [Upload public key to HKP server](#upload-public-key-to-hkp-server)
|
||||||
- [Sign and verify cleartext messages](#sign-and-verify-cleartext-messages)
|
- [Sign and verify cleartext messages](#sign-and-verify-cleartext-messages)
|
||||||
- [Create and verify *detached* signatures](#create-and-verify-detached-signatures)
|
- [Create and verify *detached* signatures](#create-and-verify-detached-signatures)
|
||||||
- [Streaming sign and verify *Uint8Array* data](#streaming-sign-and-verify-uint8array-data)
|
|
||||||
- [Documentation](#documentation)
|
- [Documentation](#documentation)
|
||||||
- [Security Audit](#security-audit)
|
- [Security Audit](#security-audit)
|
||||||
- [Security recommendations](#security-recommendations)
|
- [Security recommendations](#security-recommendations)
|
||||||
- [Development](#development)
|
- [Development](#development)
|
||||||
- [How do I get involved?](#how-do-i-get-involved)
|
- [How do I get involved?](#how-do-i-get-involved)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
|
- [Resources](#resources)
|
||||||
|
|
||||||
|
<!-- markdown-toc end -->
|
||||||
|
|
||||||
### Platform Support
|
### Platform Support
|
||||||
|
|
||||||
* The `dist/openpgp.min.js` (or `.mjs`) bundle works with recent versions of Chrome, Firefox, Edge and Safari 14+.
|
* OpenPGP.js v3.x is written in ES7 but is transpiled to ES5 using [Babel](https://babeljs.io/) to run in most environments. We support Node.js v8+ and browsers that implement [window.crypto.getRandomValues](https://caniuse.com/#feat=getrandomvalues).
|
||||||
|
|
||||||
* The `dist/node/openpgp.min.mjs` (or `.cjs`) bundle works in Node.js v18+: it is used by default when you `import ... from 'openpgp'` (or `require('openpgp')`, respectively).
|
* The API uses the Async/Await syntax introduced in ES7 to return Promise objects. Async functions are available in [most modern browsers](https://caniuse.com/#feat=async-functions). If you need to support older browsers, fear not! We use [core-js](https://github.com/zloirock/core-js) to polyfill new features so that no action is required on your part!
|
||||||
|
|
||||||
* Support for the [Web Cryptography API](https://w3c.github.io/webcrypto/)'s `SubtleCrypto` is required.
|
|
||||||
* In browsers, `SubtleCrypto` is only available in [secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts).
|
|
||||||
* In supported versions of Node.js, `SubtleCrypto` is always available.
|
|
||||||
|
|
||||||
* Support for the [Web Streams API](https://streams.spec.whatwg.org/) is required.
|
|
||||||
* In browsers: the latest versions of Chrome, Firefox, Edge and Safari support Streams, including `TransformStream`s.
|
|
||||||
These are needed if you use the library with stream inputs.
|
|
||||||
In previous versions of OpenPGP.js, Web Streams were automatically polyfilled by the library,
|
|
||||||
but from v6 this task is left up to the library user, due to the more extensive browser support, and the
|
|
||||||
polyfilling side-effects. If you're working with [older browsers versions which do not implement e.g. TransformStreams](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream#browser_compatibility), you can manually
|
|
||||||
load the [Web Streams polyfill](https://github.com/MattiasBuelens/web-streams-polyfills).
|
|
||||||
Please note that when you load the polyfills, the global `ReadableStream` property (if it exists) gets overwritten with the polyfill version.
|
|
||||||
In some edge cases, you might need to use the native
|
|
||||||
`ReadableStream` (for example when using it to create a `Response`
|
|
||||||
object), in which case you should store a reference to it before loading
|
|
||||||
the polyfills. There is also the [web-streams-adapter](https://github.com/MattiasBuelens/web-streams-adapter)
|
|
||||||
library to convert back and forth between them.
|
|
||||||
* In Node.js: OpenPGP.js v6 no longer supports native Node `Readable` streams in inputs, and instead expects (and outputs) [Node's Web Streams](https://nodejs.org/api/webstreams.html#class-readablestream). [Node v17+ includes utilities to convert from and to Web Streams](https://nodejs.org/api/stream.html#streamreadabletowebstreamreadable-options).
|
|
||||||
|
|
||||||
|
* For the OpenPGP HTTP Key Server (HKP) client the new [fetch API](https://caniuse.com/#feat=fetch) is used. The module is polyfilled for [browsers](https://github.com/github/fetch) and is included as a dependency for [Node.js](https://github.com/bitinn/node-fetch) runtimes.
|
||||||
|
|
||||||
### Performance
|
### Performance
|
||||||
|
|
||||||
* Version 3.0.0 of the library introduced support for public-key cryptography using [elliptic curves](https://wiki.gnupg.org/ECC). We use native implementations on browsers and Node.js when available. Compared to RSA, elliptic curve cryptography provides stronger security per bits of key, which allows for much faster operations. Currently the following curves are supported:
|
* Version 3.0.0 of the library introduces support for public-key cryptography using [elliptic curves](https://wiki.gnupg.org/ECC). We use native implementations on browsers and Node.js when available or [Elliptic](https://github.com/indutny/elliptic) otherwise. Elliptic curve cryptography provides stronger security per bits of key, which allows for much faster operations. Currently the following curves are supported (* = when available):
|
||||||
|
|
||||||
| Curve | Encryption | Signature | NodeCrypto | WebCrypto | Constant-Time |
|
|
||||||
|:---------------:|:----------:|:---------:|:----------:|:---------:|:-----------------:|
|
|
||||||
| curve25519 | ECDH | N/A | No | No | Algorithmically |
|
|
||||||
| ed25519 | N/A | EdDSA | No | Yes* | If native** |
|
|
||||||
| nistP256 | ECDH | ECDSA | Yes* | Yes* | If native** |
|
|
||||||
| nistP384 | ECDH | ECDSA | Yes* | Yes* | If native** |
|
|
||||||
| nistP521 | ECDH | ECDSA | Yes* | Yes* | If native** |
|
|
||||||
| brainpoolP256r1 | ECDH | ECDSA | Yes* | No | If native** |
|
|
||||||
| brainpoolP384r1 | ECDH | ECDSA | Yes* | No | If native** |
|
|
||||||
| brainpoolP512r1 | ECDH | ECDSA | Yes* | No | If native** |
|
|
||||||
| secp256k1 | ECDH | ECDSA | Yes* | No | If native** |
|
|
||||||
|
|
||||||
\* when available
|
| Curve | Encryption | Signature | Elliptic | NodeCrypto | WebCrypto |
|
||||||
\** these curves are only constant-time if the underlying native implementation is available and constant-time
|
|:--------------- |:----------:|:---------:|:--------:|:----------:|:---------:|
|
||||||
|
| p256 | ECDH | ECDSA | Yes | Yes* | Yes* |
|
||||||
|
| p384 | ECDH | ECDSA | Yes | Yes* | Yes* |
|
||||||
|
| p521 | ECDH | ECDSA | Yes | Yes* | Yes* |
|
||||||
|
| secp256k1 | ECDH | ECDSA | Yes | Yes* | No |
|
||||||
|
| brainpoolP256r1 | ECDH | ECDSA | Yes | Yes* | No |
|
||||||
|
| brainpoolP384r1 | ECDH | ECDSA | Yes | Yes* | No |
|
||||||
|
| brainpoolP512r1 | ECDH | ECDSA | Yes | Yes* | No |
|
||||||
|
| curve25519 | ECDH | N/A | Yes | No | No |
|
||||||
|
| ed25519 | N/A | EdDSA | Yes | No | No |
|
||||||
|
|
||||||
* The platform's [native Web Crypto API](https://w3c.github.io/webcrypto/) is used for performance. On Node.js the native [crypto module](https://nodejs.org/api/crypto.html#crypto_crypto) is also used, in cases where it offers additional functionality.
|
* Version 2.x of the library has been built from the ground up with Uint8Arrays. This allows for much better performance and memory usage than strings.
|
||||||
|
|
||||||
* The library implements authenticated encryption (AEAD) as per [RFC 9580](https://datatracker.ietf.org/doc/rfc9580/) using AES-GCM, OCB, or EAX. This makes symmetric encryption faster on platforms with native implementations. However, since the specification is very recent and other OpenPGP implementations are in the process of adopting it, the feature is currently behind a flag. **Note: activating this setting can break compatibility with other OpenPGP implementations which have yet to implement the feature.** You can enable it by setting `openpgp.config.aeadProtect = true`.
|
* If the user's browser supports [native WebCrypto](https://caniuse.com/#feat=cryptography) via the `window.crypto.subtle` API, this will be used. Under Node.js the native [crypto module](https://nodejs.org/API/crypto.html#crypto_crypto) is used. This can be deactivated by setting `openpgp.config.use_native = false`.
|
||||||
Note that this setting has a different effect from the one in OpenPGP.js v5, which implemented support for a provisional version of AEAD from [RFC 4880bis](https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-10), which was modified in RFC 9580.
|
|
||||||
|
* The library implements the [IETF proposal](https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04) for authenticated encryption using native AES-EAX, OCB, or GCM. This makes symmetric encryption up to 30x faster on supported platforms. Since the specification has not been finalized and other OpenPGP implementations haven't adopted it yet, the feature is currently behind a flag. **Note: activating this setting can break compatibility with other OpenPGP implementations, and also with future versions of OpenPGP.js. Don't use it with messages you want to store on disk or in a database.** You can enable it by setting `openpgp.config.aead_protect = true`.
|
||||||
|
|
||||||
You can change the AEAD mode by setting one of the following options:
|
You can change the AEAD mode by setting one of the following options:
|
||||||
|
|
||||||
```
|
```
|
||||||
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.gcm; // Default, native in WebCrypto and Node.js
|
openpgp.config.aead_mode = openpgp.enums.aead.eax // Default, native
|
||||||
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.ocb; // Non-native, but supported across RFC 9580 implementations
|
openpgp.config.aead_mode = openpgp.enums.aead.ocb // Non-native
|
||||||
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.eax; // Native in Node.js
|
openpgp.config.aead_mode = openpgp.enums.aead.experimental_gcm // **Non-standard**, fastest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
We previously also implemented an [earlier version](https://tools.ietf.org/html/draft-ford-openpgp-format-00) of the draft (using GCM), which you could enable by setting `openpgp.config.aead_protect = true`. If you need to stay compatible with that version, you need to set `openpgp.config.aead_protect_version = 0`.
|
||||||
|
|
||||||
|
* For environments that don't provide native crypto, the library falls back to [asm.js](https://caniuse.com/#feat=asmjs) implementations of AES, SHA-1, and SHA-256. We use [Rusha](https://github.com/srijs/rusha) and [asmCrypto Lite](https://github.com/openpgpjs/asmcrypto-lite) (a minimal subset of asmCrypto.js built specifically for OpenPGP.js).
|
||||||
|
|
||||||
|
|
||||||
### Getting started
|
### Getting started
|
||||||
|
|
||||||
#### Node.js
|
#### Npm
|
||||||
|
|
||||||
Install OpenPGP.js using npm and save it in your dependencies:
|
npm install --save openpgp
|
||||||
|
|
||||||
```sh
|
#### Bower
|
||||||
npm install --save openpgp
|
|
||||||
```
|
|
||||||
|
|
||||||
And import it as an ES module, from a .mjs file:
|
bower install --save openpgp
|
||||||
```js
|
|
||||||
import * as openpgp from 'openpgp';
|
|
||||||
```
|
|
||||||
|
|
||||||
Or as a CommonJS module:
|
Or just fetch a minified build under [dist](https://github.com/openpgpjs/openpgpjs/tree/master/dist).
|
||||||
|
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
Here are some examples of how to use the v2.x+ API. For more elaborate examples and working code, please check out the [public API unit tests](https://github.com/openpgpjs/openpgpjs/blob/master/test/general/openpgp.js). If you're upgrading from v1.x it might help to check out the [documentation](https://github.com/openpgpjs/openpgpjs#documentation).
|
||||||
|
|
||||||
|
#### Set up
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const openpgp = require('openpgp');
|
var openpgp = require('openpgp'); // use as CommonJS, AMD, ES6 module or via window.openpgp
|
||||||
|
|
||||||
|
openpgp.initWorker({ path:'openpgp.worker.js' }) // set the relative web worker path
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 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:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install --save-dev openpgp
|
|
||||||
```
|
|
||||||
|
|
||||||
And import it as an ES6 module:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import * as openpgp from 'openpgp';
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also only import the functions you need, as follows:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { readMessage, decrypt } from 'openpgp';
|
|
||||||
```
|
|
||||||
|
|
||||||
Or, if you want to use the lightweight build (which is smaller, and lazily loads non-default curves on demand):
|
|
||||||
|
|
||||||
```js
|
|
||||||
import * as openpgp from 'openpgp/lightweight';
|
|
||||||
```
|
|
||||||
|
|
||||||
To test whether the lazy loading works, try to generate a key with a non-standard curve:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { generateKey } from 'openpgp/lightweight';
|
|
||||||
await generateKey({ curve: 'brainpoolP512r1', userIDs: [{ name: 'Test', email: 'test@test.com' }] });
|
|
||||||
```
|
|
||||||
|
|
||||||
For more examples of how to generate a key, see [Generate new key pair](#generate-new-key-pair). It is recommended to use `curve25519` instead of `brainpoolP512r1` by default.
|
|
||||||
|
|
||||||
|
|
||||||
#### Browser (plain files)
|
|
||||||
|
|
||||||
Grab `openpgp.min.js` from [unpkg.com/openpgp/dist](https://unpkg.com/openpgp/dist/), and load it in a script tag:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="openpgp.min.js"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
Or, to load OpenPGP.js as an ES6 module, grab `openpgp.min.mjs` from [unpkg.com/openpgp/dist](https://unpkg.com/openpgp/dist/), and import it as follows:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script type="module">
|
|
||||||
import * as openpgp from './openpgp.min.mjs';
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
To offload cryptographic operations off the main thread, you can implement a Web Worker in your application and load OpenPGP.js from there. For an example Worker implementation, see `test/worker/worker_example.js`.
|
|
||||||
|
|
||||||
#### TypeScript
|
|
||||||
|
|
||||||
Since TS is not fully integrated in the library, TS-only dependencies are currently listed as `devDependencies`, so to compile the project you’ll need to add `@openpgp/web-stream-tools` manually:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install --save-dev @openpgp/web-stream-tools
|
|
||||||
```
|
|
||||||
|
|
||||||
If you notice missing or incorrect type definitions, feel free to open a PR.
|
|
||||||
|
|
||||||
### Updating from older versions of the library
|
|
||||||
|
|
||||||
We recommend updating to the latest major library version as soon as possible to benefit from security and performance improvements.
|
|
||||||
|
|
||||||
When releasing a new major version, we will announce the end of life date of the previous one.
|
|
||||||
|
|
||||||
For information about which library versions are deprecated, and will thus not receive further security patches, you can refer to our [npm release page](https://www.npmjs.com/package/openpgp?activeTab=versions).
|
|
||||||
|
|
||||||
For guidance on how to update to the latest library version, see [this wiki page](https://github.com/openpgpjs/openpgpjs/wiki/Updating-from-previous-versions).
|
|
||||||
|
|
||||||
### Code examples
|
|
||||||
|
|
||||||
Here are some examples of how to use OpenPGP.js v6. For more elaborate examples and working code, please check out the [public API unit tests](https://github.com/openpgpjs/openpgpjs/blob/main/test/general/openpgp.js). If you're upgrading from v4 it might help to check out the [changelog](https://github.com/openpgpjs/openpgpjs/wiki/v6-Changelog) and [documentation](https://github.com/openpgpjs/openpgpjs#documentation).
|
|
||||||
|
|
||||||
#### Encrypt and decrypt *Uint8Array* data with a password
|
#### Encrypt and decrypt *Uint8Array* data with a password
|
||||||
|
|
||||||
Encryption will use the algorithm specified in config.preferredSymmetricAlgorithm (defaults to aes256), and decryption will use the algorithm used for encryption.
|
```js
|
||||||
|
var options, encrypted;
|
||||||
|
|
||||||
|
options = {
|
||||||
|
data: new Uint8Array([0x01, 0x01, 0x01]), // input as Uint8Array (or String)
|
||||||
|
passwords: ['secret stuff'], // multiple passwords possible
|
||||||
|
armor: false // don't ASCII armor (for Uint8Array output)
|
||||||
|
};
|
||||||
|
|
||||||
|
openpgp.encrypt(options).then(function(ciphertext) {
|
||||||
|
encrypted = ciphertext.message.packets.write(); // get raw encrypted packets as Uint8Array
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
options = {
|
||||||
const message = await openpgp.createMessage({ binary: new Uint8Array([0x01, 0x01, 0x01]) });
|
message: openpgp.message.read(encrypted), // parse encrypted bytes
|
||||||
const encrypted = await openpgp.encrypt({
|
passwords: ['secret stuff'], // decrypt with password
|
||||||
message, // input as Message object
|
format: 'binary' // output as Uint8Array
|
||||||
passwords: ['secret stuff'], // multiple passwords possible
|
};
|
||||||
format: 'binary' // don't ASCII armor (for Uint8Array output)
|
|
||||||
});
|
|
||||||
console.log(encrypted); // Uint8Array
|
|
||||||
|
|
||||||
const encryptedMessage = await openpgp.readMessage({
|
openpgp.decrypt(options).then(function(plaintext) {
|
||||||
binaryMessage: encrypted // parse encrypted bytes
|
return plaintext.data // Uint8Array([0x01, 0x01, 0x01])
|
||||||
});
|
});
|
||||||
const { data: decrypted } = await openpgp.decrypt({
|
|
||||||
message: encryptedMessage,
|
|
||||||
passwords: ['secret stuff'], // decrypt with password
|
|
||||||
format: 'binary' // output as Uint8Array
|
|
||||||
});
|
|
||||||
console.log(decrypted); // Uint8Array([0x01, 0x01, 0x01])
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Encrypt and decrypt *String* data with PGP keys
|
#### Encrypt and decrypt *String* data with PGP keys
|
||||||
|
|
||||||
Encryption will use the algorithm preferred by the public (encryption) key (defaults to aes256 for keys generated in OpenPGP.js), and decryption will use the algorithm used for encryption.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const openpgp = require('openpgp'); // use as CommonJS, AMD, ES6 module or via window.openpgp
|
var options, encrypted;
|
||||||
|
|
||||||
(async () => {
|
var pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
||||||
// put keys in backtick (``) to avoid errors caused by spaces or tabs
|
var privkey = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----'; //encrypted private key
|
||||||
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
var passphrase = 'secret passphrase'; //what the privKey is encrypted with
|
||||||
...
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
|
||||||
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
|
|
||||||
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
|
||||||
|
|
||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
var privKeyObj = openpgp.key.readArmored(privkey).keys[0];
|
||||||
|
await privKeyObj.decrypt(passphrase);
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
options = {
|
||||||
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
data: 'Hello, World!', // input as String (or Uint8Array)
|
||||||
passphrase
|
publicKeys: openpgp.key.readArmored(pubkey).keys, // for encryption
|
||||||
});
|
privateKeys: [privKeyObj] // for signing (optional)
|
||||||
|
};
|
||||||
|
|
||||||
const encrypted = await openpgp.encrypt({
|
openpgp.encrypt(options).then(function(ciphertext) {
|
||||||
message: await openpgp.createMessage({ text: 'Hello, World!' }), // input as Message object
|
encrypted = ciphertext.data; // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
||||||
encryptionKeys: publicKey,
|
});
|
||||||
signingKeys: privateKey // optional
|
|
||||||
});
|
|
||||||
console.log(encrypted); // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
|
||||||
|
|
||||||
const message = await openpgp.readMessage({
|
|
||||||
armoredMessage: encrypted // parse armored message
|
|
||||||
});
|
|
||||||
const { data: decrypted, signatures } = await openpgp.decrypt({
|
|
||||||
message,
|
|
||||||
verificationKeys: publicKey, // optional
|
|
||||||
decryptionKeys: privateKey
|
|
||||||
});
|
|
||||||
console.log(decrypted); // 'Hello, World!'
|
|
||||||
// check signature validity (signed messages only)
|
|
||||||
try {
|
|
||||||
await signatures[0].verified; // throws on invalid signature
|
|
||||||
console.log('Signature is valid');
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error('Signature could not be verified: ' + e.message);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Encrypt to multiple public keys:
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
options = {
|
||||||
const publicKeysArmored = [
|
message: openpgp.message.readArmored(encrypted), // parse armored message
|
||||||
`-----BEGIN PGP PUBLIC KEY BLOCK-----
|
publicKeys: openpgp.key.readArmored(pubkey).keys, // for verification (optional)
|
||||||
...
|
privateKeys: [privKeyObj] // for decryption
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`,
|
};
|
||||||
`-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`
|
|
||||||
];
|
|
||||||
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
|
|
||||||
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
|
||||||
const plaintext = 'Hello, World!';
|
|
||||||
|
|
||||||
const publicKeys = await Promise.all(publicKeysArmored.map(armoredKey => openpgp.readKey({ armoredKey })));
|
openpgp.decrypt(options).then(function(plaintext) {
|
||||||
|
return plaintext.data; // 'Hello, World!'
|
||||||
const privateKey = await openpgp.decryptKey({
|
});
|
||||||
privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
|
|
||||||
passphrase
|
|
||||||
});
|
|
||||||
|
|
||||||
const message = await openpgp.createMessage({ text: plaintext });
|
|
||||||
const encrypted = await openpgp.encrypt({
|
|
||||||
message, // input as Message object
|
|
||||||
encryptionKeys: publicKeys,
|
|
||||||
signingKeys: privateKey // optional
|
|
||||||
});
|
|
||||||
console.log(encrypted); // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you expect an encrypted message to be signed with one of the public keys you have, and do not want to trust the decrypted data otherwise, you can pass the decryption option `expectSigned = true`, so that the decryption operation will fail if no valid signature is found:
|
#### Encrypt with compression
|
||||||
|
|
||||||
|
By default, `encrypt` will not use any compression. It's possible to override that behavior in two ways:
|
||||||
|
|
||||||
|
Either set the `compression` parameter in the options object when calling `encrypt`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
var options, encrypted;
|
||||||
// put keys in backtick (``) to avoid errors caused by spaces or tabs
|
|
||||||
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
|
||||||
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
|
|
||||||
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
|
||||||
|
|
||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
options = {
|
||||||
|
data: new Uint8Array([0x01, 0x02, 0x03]), // input as Uint8Array (or String)
|
||||||
|
passwords: ['secret stuff'], // multiple passwords possible
|
||||||
|
compression: openpgp.enums.compression.zip // compress the data with zip
|
||||||
|
};
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
ciphertext = await openpgp.encrypt(options); // use ciphertext
|
||||||
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
|
||||||
passphrase
|
|
||||||
});
|
|
||||||
|
|
||||||
const encryptedAndSignedMessage = `-----BEGIN PGP MESSAGE-----
|
|
||||||
...
|
|
||||||
-----END PGP MESSAGE-----`;
|
|
||||||
|
|
||||||
const message = await openpgp.readMessage({
|
|
||||||
armoredMessage: encryptedAndSignedMessage // parse armored message
|
|
||||||
});
|
|
||||||
// decryption will fail if all signatures are invalid or missing
|
|
||||||
const { data: decrypted, signatures } = await openpgp.decrypt({
|
|
||||||
message,
|
|
||||||
decryptionKeys: privateKey,
|
|
||||||
expectSigned: true,
|
|
||||||
verificationKeys: publicKey, // mandatory with expectSigned=true
|
|
||||||
});
|
|
||||||
console.log(decrypted); // 'Hello, World!'
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Encrypt symmetrically with compression
|
Or, override the config to enable compression:
|
||||||
|
|
||||||
By default, `encrypt` will not use any compression when encrypting symmetrically only (i.e. when no `encryptionKeys` are given).
|
|
||||||
It's possible to change that behaviour by enabling compression through the config, either for the single encryption:
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
openpgp.config.compression = openpgp.enums.compression.zip
|
||||||
const message = await openpgp.createMessage({ binary: new Uint8Array([0x01, 0x02, 0x03]) }); // or createMessage({ text: 'string' })
|
|
||||||
const encrypted = await openpgp.encrypt({
|
|
||||||
message,
|
|
||||||
passwords: ['secret stuff'], // multiple passwords possible
|
|
||||||
config: { preferredCompressionAlgorithm: openpgp.enums.compression.zlib } // compress the data with zlib
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
```
|
|
||||||
|
|
||||||
or by changing the default global configuration:
|
|
||||||
```js
|
|
||||||
openpgp.config.preferredCompressionAlgorithm = openpgp.enums.compression.zlib
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Where the value can be any of:
|
Where the value can be any of:
|
||||||
* `openpgp.enums.compression.zip`
|
* `openpgp.enums.compression.zip`
|
||||||
* `openpgp.enums.compression.zlib`
|
* `openpgp.enums.compression.zlib`
|
||||||
* `openpgp.enums.compression.uncompressed` (default)
|
* `openpgp.enums.compression.bzip2`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Streaming encrypt *Uint8Array* data with a password
|
|
||||||
|
|
||||||
```js
|
|
||||||
(async () => {
|
|
||||||
const readableStream = new ReadableStream({
|
|
||||||
start(controller) {
|
|
||||||
controller.enqueue(new Uint8Array([0x01, 0x02, 0x03]));
|
|
||||||
controller.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const message = await openpgp.createMessage({ binary: readableStream });
|
|
||||||
const encrypted = await openpgp.encrypt({
|
|
||||||
message, // input as Message object
|
|
||||||
passwords: ['secret stuff'], // multiple passwords possible
|
|
||||||
format: 'binary' // don't ASCII armor (for Uint8Array output)
|
|
||||||
});
|
|
||||||
console.log(encrypted); // raw encrypted packets as ReadableStream<Uint8Array>
|
|
||||||
|
|
||||||
// Either pipe the above stream somewhere, pass it to another function,
|
|
||||||
// or read it manually as follows:
|
|
||||||
for await (const chunk of encrypted) {
|
|
||||||
console.log('new chunk:', chunk); // Uint8Array
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
```
|
|
||||||
|
|
||||||
For more information on using ReadableStreams (both in browsers and Node.js), see [the MDN Documentation on the
|
|
||||||
Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) .
|
|
||||||
|
|
||||||
#### Streaming encrypt and decrypt *String* data with PGP keys
|
|
||||||
|
|
||||||
```js
|
|
||||||
(async () => {
|
|
||||||
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`; // Public key
|
|
||||||
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`; // Encrypted private key
|
|
||||||
const passphrase = `yourPassphrase`; // Password that private key is encrypted with
|
|
||||||
|
|
||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
|
||||||
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
|
||||||
passphrase
|
|
||||||
});
|
|
||||||
|
|
||||||
const readableStream = new ReadableStream({
|
|
||||||
start(controller) {
|
|
||||||
controller.enqueue('Hello, world!');
|
|
||||||
controller.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const encrypted = await openpgp.encrypt({
|
|
||||||
message: await openpgp.createMessage({ text: readableStream }), // input as Message object
|
|
||||||
encryptionKeys: publicKey,
|
|
||||||
signingKeys: privateKey // optional
|
|
||||||
});
|
|
||||||
console.log(encrypted); // ReadableStream containing '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
|
||||||
|
|
||||||
const message = await openpgp.readMessage({
|
|
||||||
armoredMessage: encrypted // parse armored message
|
|
||||||
});
|
|
||||||
const decrypted = await openpgp.decrypt({
|
|
||||||
message,
|
|
||||||
verificationKeys: publicKey, // optional
|
|
||||||
decryptionKeys: privateKey
|
|
||||||
});
|
|
||||||
const chunks = [];
|
|
||||||
for await (const chunk of decrypted.data) {
|
|
||||||
chunks.push(chunk);
|
|
||||||
}
|
|
||||||
const plaintext = chunks.join('');
|
|
||||||
console.log(plaintext); // 'Hello, World!'
|
|
||||||
})();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### Generate new key pair
|
#### Generate new key pair
|
||||||
|
|
||||||
ECC keys (smaller and faster to generate):
|
RSA keys:
|
||||||
|
```js
|
||||||
|
var options = {
|
||||||
|
userIds: [{ name:'Jon Smith', email:'jon@example.com' }], // multiple user IDs
|
||||||
|
numBits: 4096, // RSA key size
|
||||||
|
passphrase: 'super long and hard to guess secret' // protects the private key
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
Possible values for `curve` are: `curve25519`, `ed25519`, `nistP256`, `nistP384`, `nistP521`,
|
ECC keys:
|
||||||
`brainpoolP256r1`, `brainpoolP384r1`, `brainpoolP512r1`, and `secp256k1`.
|
|
||||||
Note that both the `curve25519` and `ed25519` options generate a primary key for signing using Ed25519
|
Possible values for curve are: `curve25519`, `ed25519`, `p256`, `p384`, `p521`, `secp256k1`,
|
||||||
|
`brainpoolP256r1`, `brainpoolP384r1`, or `brainpoolP512r1`.
|
||||||
|
Note that options both `curve25519` and `ed25519` generate a primary key for signing using Ed25519
|
||||||
and a subkey for encryption using Curve25519.
|
and a subkey for encryption using Curve25519.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
var options = {
|
||||||
const { privateKey, publicKey, revocationCertificate } = await openpgp.generateKey({
|
userIds: [{ name:'Jon Smith', email:'jon@example.com' }], // multiple user IDs
|
||||||
type: 'ecc', // Type of the key, defaults to ECC
|
curve: "ed25519", // ECC curve name
|
||||||
curve: 'curve25519', // ECC curve name, defaults to curve25519
|
passphrase: 'super long and hard to guess secret' // protects the private key
|
||||||
userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
|
};
|
||||||
passphrase: 'super long and hard to guess secret', // protects the private key
|
|
||||||
format: 'armored' // output key format, defaults to 'armored' (other options: 'binary' or 'object')
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(privateKey); // '-----BEGIN PGP PRIVATE KEY BLOCK ... '
|
|
||||||
console.log(publicKey); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
|
||||||
console.log(revocationCertificate); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
RSA keys (increased compatibility):
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
openpgp.generateKey(options).then(function(key) {
|
||||||
const { privateKey, publicKey } = await openpgp.generateKey({
|
var privkey = key.privateKeyArmored; // '-----BEGIN PGP PRIVATE KEY BLOCK ... '
|
||||||
type: 'rsa', // Type of the key
|
var pubkey = key.publicKeyArmored; // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
||||||
rsaBits: 4096, // RSA key size (defaults to 4096 bits)
|
});
|
||||||
userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
|
|
||||||
passphrase: 'super long and hard to guess secret' // protects the private key
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Revoke a key
|
#### Lookup public key on HKP server
|
||||||
|
|
||||||
Using a revocation certificate:
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
var hkp = new openpgp.HKP('https://pgp.mit.edu');
|
||||||
const { publicKey: revokedKeyArmored } = await openpgp.revokeKey({
|
|
||||||
key: await openpgp.readKey({ armoredKey: publicKeyArmored }),
|
var options = {
|
||||||
revocationCertificate,
|
query: 'alice@example.com'
|
||||||
format: 'armored' // output armored keys
|
};
|
||||||
});
|
|
||||||
console.log(revokedKeyArmored); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
hkp.lookup(options).then(function(key) {
|
||||||
})();
|
var pubkey = openpgp.key.readArmored(key);
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Using the private key:
|
#### Upload public key to HKP server
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
var hkp = new openpgp.HKP('https://pgp.mit.edu');
|
||||||
const { publicKey: revokedKeyArmored } = await openpgp.revokeKey({
|
|
||||||
key: await openpgp.readKey({ armoredKey: privateKeyArmored }),
|
var pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
||||||
format: 'armored' // output armored keys
|
|
||||||
});
|
hkp.upload(pubkey).then(function() { ... });
|
||||||
console.log(revokedKeyArmored); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Sign and verify cleartext messages
|
#### Sign and verify cleartext messages
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
var options, cleartext, validity;
|
||||||
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
|
||||||
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
|
|
||||||
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
|
||||||
|
|
||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
var pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
||||||
|
var privkey = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----'; //encrypted private key
|
||||||
|
var passphrase = 'secret passphrase'; //what the privKey is encrypted with
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
var privKeyObj = openpgp.key.readArmored(privkey).keys[0];
|
||||||
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
await privKeyObj.decrypt(passphrase);
|
||||||
passphrase
|
```
|
||||||
});
|
|
||||||
|
|
||||||
const unsignedMessage = await openpgp.createCleartextMessage({ text: 'Hello, World!' });
|
```js
|
||||||
const cleartextMessage = await openpgp.sign({
|
options = {
|
||||||
message: unsignedMessage, // CleartextMessage or Message object
|
data: 'Hello, World!', // input as String (or Uint8Array)
|
||||||
signingKeys: privateKey
|
privateKeys: [privKeyObj] // for signing
|
||||||
});
|
};
|
||||||
console.log(cleartextMessage); // '-----BEGIN PGP SIGNED MESSAGE ... END PGP SIGNATURE-----'
|
|
||||||
|
|
||||||
const signedMessage = await openpgp.readCleartextMessage({
|
openpgp.sign(options).then(function(signed) {
|
||||||
cleartextMessage // parse armored message
|
cleartext = signed.data; // '-----BEGIN PGP SIGNED MESSAGE ... END PGP SIGNATURE-----'
|
||||||
});
|
});
|
||||||
const verificationResult = await openpgp.verify({
|
```
|
||||||
message: signedMessage,
|
|
||||||
verificationKeys: publicKey
|
```js
|
||||||
});
|
options = {
|
||||||
const { verified, keyID } = verificationResult.signatures[0];
|
message: openpgp.cleartext.readArmored(cleartext), // parse armored message
|
||||||
try {
|
publicKeys: openpgp.key.readArmored(pubkey).keys // for verification
|
||||||
await verified; // throws on invalid signature
|
};
|
||||||
console.log('Signed by key id ' + keyID.toHex());
|
|
||||||
} catch (e) {
|
openpgp.verify(options).then(function(verified) {
|
||||||
throw new Error('Signature could not be verified: ' + e.message);
|
validity = verified.signatures[0].valid; // true
|
||||||
}
|
if (validity) {
|
||||||
})();
|
console.log('signed by key id ' + verified.signatures[0].keyid.toHex());
|
||||||
|
}
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Create and verify *detached* signatures
|
#### Create and verify *detached* signatures
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
var options, detachedSig, validity;
|
||||||
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
|
||||||
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
|
||||||
...
|
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
|
|
||||||
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
|
||||||
|
|
||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
var pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
||||||
|
var privkey = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----'; //encrypted private key
|
||||||
|
var passphrase = 'secret passphrase'; //what the privKey is encrypted with
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
var privKeyObj = openpgp.key.readArmored(privkey).keys[0];
|
||||||
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
await privKeyObj.decrypt(passphrase);
|
||||||
passphrase
|
```
|
||||||
});
|
|
||||||
|
```js
|
||||||
const message = await openpgp.createMessage({ text: 'Hello, World!' });
|
options = {
|
||||||
const detachedSignature = await openpgp.sign({
|
data: 'Hello, World!', // input as String (or Uint8Array)
|
||||||
message, // Message object
|
privateKeys: [privKeyObj], // for signing
|
||||||
signingKeys: privateKey,
|
detached: true
|
||||||
detached: true
|
};
|
||||||
});
|
|
||||||
console.log(detachedSignature);
|
openpgp.sign(options).then(function(signed) {
|
||||||
|
detachedSig = signed.signature;
|
||||||
const signature = await openpgp.readSignature({
|
});
|
||||||
armoredSignature: detachedSignature // parse detached signature
|
|
||||||
});
|
|
||||||
const verificationResult = await openpgp.verify({
|
|
||||||
message, // Message object
|
|
||||||
signature,
|
|
||||||
verificationKeys: publicKey
|
|
||||||
});
|
|
||||||
const { verified, keyID } = verificationResult.signatures[0];
|
|
||||||
try {
|
|
||||||
await verified; // throws on invalid signature
|
|
||||||
console.log('Signed by key id ' + keyID.toHex());
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error('Signature could not be verified: ' + e.message);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Streaming sign and verify *Uint8Array* data
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
options = {
|
||||||
var readableStream = new ReadableStream({
|
message: openpgp.message.fromText('Hello, World!'), // input as Message object
|
||||||
start(controller) {
|
signature: openpgp.signature.readArmored(detachedSig), // parse detached signature
|
||||||
controller.enqueue(new Uint8Array([0x01, 0x02, 0x03]));
|
publicKeys: openpgp.key.readArmored(pubkey).keys // for verification
|
||||||
controller.close();
|
};
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
openpgp.verify(options).then(function(verified) {
|
||||||
...
|
validity = verified.signatures[0].valid; // true
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
if (validity) {
|
||||||
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
console.log('signed by key id ' + verified.signatures[0].keyid.toHex());
|
||||||
...
|
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
|
|
||||||
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
|
||||||
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
|
||||||
passphrase
|
|
||||||
});
|
|
||||||
|
|
||||||
const message = await openpgp.createMessage({ binary: readableStream }); // or createMessage({ text: ReadableStream<String> })
|
|
||||||
const signatureArmored = await openpgp.sign({
|
|
||||||
message,
|
|
||||||
signingKeys: privateKey
|
|
||||||
});
|
|
||||||
console.log(signatureArmored); // ReadableStream containing '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
|
||||||
|
|
||||||
const verificationResult = await openpgp.verify({
|
|
||||||
message: await openpgp.readMessage({ armoredMessage: signatureArmored }), // parse armored signature
|
|
||||||
verificationKeys: await openpgp.readKey({ armoredKey: publicKeyArmored })
|
|
||||||
});
|
|
||||||
|
|
||||||
for await (const chunk of verificationResult.data) {}
|
|
||||||
// Note: you *have* to read `verificationResult.data` in some way or other,
|
|
||||||
// even if you don't need it, as that is what triggers the
|
|
||||||
// verification of the data.
|
|
||||||
|
|
||||||
try {
|
|
||||||
await verificationResult.signatures[0].verified; // throws on invalid signature
|
|
||||||
console.log('Signed by key id ' + verificationResult.signatures[0].keyID.toHex());
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error('Signature could not be verified: ' + e.message);
|
|
||||||
}
|
}
|
||||||
})();
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
The full documentation is available at [openpgpjs.org](https://docs.openpgpjs.org/).
|
A jsdoc build of our code comments is available at [doc/index.html](https://openpgpjs.org/openpgpjs/doc/index.html). Public calls should generally be made through the OpenPGP object [doc/openpgp.html](https://openpgpjs.org/openpgpjs/doc/module-openpgp.html).
|
||||||
|
|
||||||
### Security Audit
|
### Security Audit
|
||||||
|
|
||||||
@ -675,14 +353,27 @@ To create your own build of the library, just run the following command after cl
|
|||||||
|
|
||||||
npm install && npm test
|
npm install && npm test
|
||||||
|
|
||||||
For debugging browser errors, run the following command:
|
For debugging browser errors, you can open `test/unittests.html` in a browser or, after running the following command, open [`http://localhost:3000/test/unittests.html`](http://localhost:3000/test/unittests.html):
|
||||||
|
|
||||||
npm run browsertest
|
grunt browsertest
|
||||||
|
|
||||||
### How do I get involved?
|
### How do I get involved?
|
||||||
|
|
||||||
You want to help, great! It's probably best to send us a message on [Gitter](https://gitter.im/openpgpjs/openpgpjs) before you start your undertaking, to make sure nobody else is working on it, and so we can discuss the best course of action. Other than that, just go ahead and fork our repo, make your changes and send us a pull request! :)
|
You want to help, great! Go ahead and fork our repo, make your changes and send us a pull request.
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
[GNU Lesser General Public License](https://www.gnu.org/licenses/lgpl-3.0.en.html) (3.0 or any later version). Please take a look at the [LICENSE](LICENSE) file for more information.
|
GNU Lesser General Public License (3.0 or any later version). Please take a look at the [LICENSE](LICENSE) file for more information.
|
||||||
|
|
||||||
|
### Resources
|
||||||
|
|
||||||
|
Below is a collection of resources, many of these were projects that were in someway a precursor to the current OpenPGP.js project. If you'd like to add your link here, please do so in a pull request or email to the list.
|
||||||
|
|
||||||
|
* [https://www.hanewin.net/encrypt/](https://www.hanewin.net/encrypt/)
|
||||||
|
* [https://github.com/seancolyer/gmail-crypt](https://github.com/seancolyer/gmail-crypt)
|
||||||
|
* [https://github.com/mete0r/jspg](https://github.com/mete0r/jspg)
|
||||||
|
* [https://fitblip.pub/JSPGP-Stuffs/](https://fitblip.pub/JSPGP-Stuffs/)
|
||||||
|
* [http://qooxdoo.org/contrib/project/crypto](http://qooxdoo.org/contrib/project/crypto)
|
||||||
|
* [https://github.com/GPGTools/Mobile/wiki/Introduction](https://github.com/GPGTools/Mobile/wiki/Introduction)
|
||||||
|
* [http://gpg4browsers.recurity.com/](http://gpg4browsers.recurity.com/)
|
||||||
|
* [https://github.com/gmontalvoriv/mailock](https://github.com/gmontalvoriv/mailock)
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
## Reporting Security Issues
|
|
||||||
|
|
||||||
**Please do not report security vulnerabilities through public GitHub issues.**
|
|
||||||
|
|
||||||
If you believe you have found a security vulnerability in OpenPGP.js, please report it via email to [security@openpgpjs.org](mailto:security@openpgpjs.org). If possible, encrypt your message with our PGP key: it can be downloaded automatically using [WKD](https://wiki.gnupg.org/WKD), or manually on [openpgpjs.org](https://openpgpjs.org/.well-known/openpgpkey/hu/t5s8ztdbon8yzntexy6oz5y48etqsnbb?l=security).
|
|
||||||
|
|
||||||
You should receive a response within 2 working days.
|
|
37
bower.json
Normal file
37
bower.json
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"name": "openpgp",
|
||||||
|
"version": "3.0.11",
|
||||||
|
"license": "LGPL-3.0+",
|
||||||
|
"homepage": "https://openpgpjs.org/",
|
||||||
|
"authors": [
|
||||||
|
"OpenPGP Development Team <list@openpgpjs.org> (https://github.com/openpgpjs/openpgpjs/graphs/contributors)"
|
||||||
|
],
|
||||||
|
"description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
|
||||||
|
"main": [
|
||||||
|
"dist/openpgp.js",
|
||||||
|
"dist/openpgp.worker.js"
|
||||||
|
],
|
||||||
|
"moduleType": [
|
||||||
|
"amd",
|
||||||
|
"es6",
|
||||||
|
"globals",
|
||||||
|
"node"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"crypto",
|
||||||
|
"gpg",
|
||||||
|
"pgp",
|
||||||
|
"openpgp",
|
||||||
|
"encryption"
|
||||||
|
],
|
||||||
|
"ignore": [
|
||||||
|
"**/.*",
|
||||||
|
"dist/*.tgz",
|
||||||
|
"dist/*_debug.js",
|
||||||
|
"node_modules",
|
||||||
|
"bower_components",
|
||||||
|
"test",
|
||||||
|
"tests",
|
||||||
|
"doc"
|
||||||
|
]
|
||||||
|
}
|
51771
dist/openpgp.js
vendored
Normal file
51771
dist/openpgp.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
dist/openpgp.min.js
vendored
Normal file
2
dist/openpgp.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
137
dist/openpgp.worker.js
vendored
Normal file
137
dist/openpgp.worker.js
vendored
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||||
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
||||||
|
// Copyright (C) 2011 Recurity Labs GmbH
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 3.0 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// 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 no-restricted-globals */
|
||||||
|
/* eslint-disable no-var */
|
||||||
|
/* eslint-disable vars-on-top */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fileoverview Provides functions for communicating with workers
|
||||||
|
* @see module:openpgp.initWorker
|
||||||
|
* @see module:openpgp.getWorker
|
||||||
|
* @see module:openpgp.destroyWorker
|
||||||
|
* @see module:worker/async_proxy
|
||||||
|
* @module worker/worker
|
||||||
|
*/
|
||||||
|
|
||||||
|
self.window = self; // to make UMD bundles work
|
||||||
|
|
||||||
|
importScripts('openpgp.js');
|
||||||
|
var openpgp = window.openpgp;
|
||||||
|
|
||||||
|
var randomQueue = [];
|
||||||
|
var MAX_SIZE_RANDOM_BUFFER = 60000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle random buffer exhaustion by requesting more random bytes from the main window
|
||||||
|
* @returns {Promise<Object>} Empty promise whose resolution indicates that the buffer has been refilled
|
||||||
|
*/
|
||||||
|
function randomCallback() {
|
||||||
|
|
||||||
|
if (!randomQueue.length) {
|
||||||
|
self.postMessage({ event: 'request-seed', amount: MAX_SIZE_RANDOM_BUFFER });
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise(function(resolve) {
|
||||||
|
randomQueue.push(resolve);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
openpgp.crypto.random.randomBuffer.init(MAX_SIZE_RANDOM_BUFFER, randomCallback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle messages from the main window.
|
||||||
|
* @param {Object} event Contains event type and data
|
||||||
|
*/
|
||||||
|
self.onmessage = function(event) {
|
||||||
|
var msg = event.data || {};
|
||||||
|
|
||||||
|
switch (msg.event) {
|
||||||
|
case 'configure':
|
||||||
|
configure(msg.config);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'seed-random':
|
||||||
|
seedRandom(msg.buf);
|
||||||
|
|
||||||
|
var queueCopy = randomQueue;
|
||||||
|
randomQueue = [];
|
||||||
|
for (var i = 0; i < queueCopy.length; i++) {
|
||||||
|
queueCopy[i]();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
delegate(msg.id, msg.event, msg.options || {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set config from main context to worker context.
|
||||||
|
* @param {Object} config The openpgp configuration
|
||||||
|
*/
|
||||||
|
function configure(config) {
|
||||||
|
Object.keys(config).forEach(function(key) {
|
||||||
|
openpgp.config[key] = config[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seed the library with entropy gathered window.crypto.getRandomValues
|
||||||
|
* as this api is only avalible in the main window.
|
||||||
|
* @param {ArrayBuffer} buffer Some random bytes
|
||||||
|
*/
|
||||||
|
function seedRandom(buffer) {
|
||||||
|
if (!(buffer instanceof Uint8Array)) {
|
||||||
|
buffer = new Uint8Array(buffer);
|
||||||
|
}
|
||||||
|
openpgp.crypto.random.randomBuffer.set(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic proxy function that handles all commands from the public api.
|
||||||
|
* @param {String} method The public api function to be delegated to the worker thread
|
||||||
|
* @param {Object} options The api function's options
|
||||||
|
*/
|
||||||
|
function delegate(id, method, options) {
|
||||||
|
if (typeof openpgp[method] !== 'function') {
|
||||||
|
response({ id:id, event:'method-return', err:'Unknown Worker Event' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// parse cloned packets
|
||||||
|
options = openpgp.packet.clone.parseClonedPackets(options, method);
|
||||||
|
openpgp[method](options).then(function(data) {
|
||||||
|
// clone packets (for web worker structured cloning algorithm)
|
||||||
|
response({ id:id, event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
|
||||||
|
}).catch(function(e) {
|
||||||
|
response({
|
||||||
|
id:id, event:'method-return', err:e.message, stack:e.stack
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Respond to the main window.
|
||||||
|
* @param {Object} event Contains event type and data
|
||||||
|
*/
|
||||||
|
function response(event) {
|
||||||
|
self.postMessage(event, openpgp.util.getTransferables(event.data));
|
||||||
|
}
|
||||||
|
|
||||||
|
},{}]},{},[1]);
|
2
dist/openpgp.worker.min.js
vendored
Normal file
2
dist/openpgp.worker.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/*! OpenPGP.js v3.0.11 - 2018-05-22 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
|
||||||
|
!function e(n,t,r){function o(a,f){if(!t[a]){if(!n[a]){var c="function"==typeof require&&require;if(!f&&c)return c(a,!0);if(i)return i(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=t[a]={exports:{}};n[a][0].call(u.exports,function(e){var t=n[a][1][e];return o(t||e)},u,u.exports,e,n,t,r)}return t[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,n,t){self.window=self,importScripts("openpgp.min.js");var r=window.openpgp,o=[],i=6e4;function a(e){self.postMessage(e,r.util.getTransferables(e.data))}r.crypto.random.randomBuffer.init(i,function(){return o.length||self.postMessage({event:"request-seed",amount:i}),new Promise(function(e){o.push(e)})}),self.onmessage=function(e){var n,t=e.data||{};switch(t.event){case"configure":n=t.config,Object.keys(n).forEach(function(e){r.config[e]=n[e]});break;case"seed-random":!function(e){e instanceof Uint8Array||(e=new Uint8Array(e));r.crypto.random.randomBuffer.set(e)}(t.buf);var i=o;o=[];for(var f=0;f<i.length;f++)i[f]();break;default:!function(e,n,t){if("function"!=typeof r[n])return void a({id:e,event:"method-return",err:"Unknown Worker Event"});t=r.packet.clone.parseClonedPackets(t,n),r[n](t).then(function(n){a({id:e,event:"method-return",data:r.packet.clone.clonePackets(n)})}).catch(function(n){a({id:e,event:"method-return",err:n.message,stack:n.stack})})}(t.id,t.event,t.options||{})}}},{}]},{},[1]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
docs.openpgpjs.org
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
5397
docs/Key.html
5397
docs/Key.html
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4870
docs/Message.html
4870
docs/Message.html
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1467
docs/PacketList.html
1467
docs/PacketList.html
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1893
docs/PrivateKey.html
1893
docs/PrivateKey.html
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 116 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 118 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 120 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 114 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 120 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 117 KiB |
Binary file not shown.
11739
docs/global.html
11739
docs/global.html
File diff suppressed because one or more lines are too long
729
docs/index.html
729
docs/index.html
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user