mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-03-30 15:08:32 +00:00
Compare commits
431 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
88310fe69d | ||
![]() |
c2526c8a88 | ||
![]() |
1848f51a4c | ||
![]() |
4762d2c762 | ||
![]() |
d5689894f6 | ||
![]() |
6d4a86295e | ||
![]() |
8a2062d342 | ||
![]() |
e9fe979649 | ||
![]() |
1ab6f27fc9 | ||
![]() |
a7660cc43b | ||
![]() |
b583bcad23 | ||
![]() |
a3a9e06802 | ||
![]() |
965e63b672 | ||
![]() |
96b13a468b | ||
![]() |
432856ff0e | ||
![]() |
b2bd8a0fdd | ||
![]() |
6db98f1e47 | ||
![]() |
8e5da78971 | ||
![]() |
a5d894f514 | ||
![]() |
a16160fc66 | ||
![]() |
abe750cf7c | ||
![]() |
2a8969b437 | ||
![]() |
bf85deedb8 | ||
![]() |
6c3b02872d | ||
![]() |
4d2d8740dc | ||
![]() |
bbdaad0cba | ||
![]() |
daeaf6b1da | ||
![]() |
67faffafff | ||
![]() |
f75447afaa | ||
![]() |
121b478312 | ||
![]() |
088d5f3638 | ||
![]() |
ac1bfc0d60 | ||
![]() |
287104aafb | ||
![]() |
2d65d1d553 | ||
![]() |
3f060660c2 | ||
![]() |
01b62399af | ||
![]() |
dd01ee00cb | ||
![]() |
a5645e1d6c | ||
![]() |
09800741f0 | ||
![]() |
31a7e2616b | ||
![]() |
42d504a69a | ||
![]() |
fb72ea449a | ||
![]() |
f9a3e54364 | ||
![]() |
d3e75de23d | ||
![]() |
12274a1543 | ||
![]() |
0138b69356 | ||
![]() |
821f260ba9 | ||
![]() |
09095ced4f | ||
![]() |
d7f5736d67 | ||
![]() |
693adb417e | ||
![]() |
013dffce70 | ||
![]() |
59c809c943 | ||
![]() |
4ddadd4f53 | ||
![]() |
ae5698c621 | ||
![]() |
4b017f6c67 | ||
![]() |
e924a50c31 | ||
![]() |
88f20974dd | ||
![]() |
05fbc63732 | ||
![]() |
3cdaab7894 | ||
![]() |
e58c02d5ee | ||
![]() |
a57bffc84a | ||
![]() |
5ee854140a | ||
![]() |
ada794cab6 | ||
![]() |
e80d71bdfc | ||
![]() |
e454faab0c | ||
![]() |
6ac17dc71c | ||
![]() |
148fff91e8 | ||
![]() |
ccb040ae96 | ||
![]() |
2b9a07e840 | ||
![]() |
0255fcba86 | ||
![]() |
f2818429db | ||
![]() |
8d8033383b | ||
![]() |
a3839f6db5 | ||
![]() |
1bcce67c68 | ||
![]() |
e7b7f6c6b1 | ||
![]() |
ab8445116c | ||
![]() |
f36be640cc | ||
![]() |
2f185481a7 | ||
![]() |
5fd7ef370f | ||
![]() |
79014f00f0 | ||
![]() |
5c583341d7 | ||
![]() |
db82968b48 | ||
![]() |
7698790d1c | ||
![]() |
bcaaa7e2d2 | ||
![]() |
fca699373a | ||
![]() |
efb0324330 | ||
![]() |
c0b35306cb | ||
![]() |
35a1e1f23b | ||
![]() |
b9c5c8df59 | ||
![]() |
857b794e13 | ||
![]() |
00e147f5c1 | ||
![]() |
42938c871a | ||
![]() |
40b6427658 | ||
![]() |
f729d2bfa7 | ||
![]() |
5268c484e9 | ||
![]() |
9efdaf14b1 | ||
![]() |
8d11c5fd0f | ||
![]() |
7af16be62b | ||
![]() |
4026e24585 | ||
![]() |
a0337780b7 | ||
![]() |
3eba29dba8 | ||
![]() |
12fb916360 | ||
![]() |
cf94380e26 | ||
![]() |
52611e7f26 | ||
![]() |
f8d0e6052f | ||
![]() |
08b71487c5 | ||
![]() |
75f10955e6 | ||
![]() |
1ce2df1119 | ||
![]() |
6ace4a00f5 | ||
![]() |
9f5ff66c3d | ||
![]() |
b1e27a1430 | ||
![]() |
a315c46583 | ||
![]() |
d138b5290b | ||
![]() |
1d732c34ff | ||
![]() |
6a306a1797 | ||
![]() |
676c31b748 | ||
![]() |
727c7cad37 | ||
![]() |
ad7165dfd0 | ||
![]() |
cf0285add5 | ||
![]() |
90495522f7 | ||
![]() |
2985b0f470 | ||
![]() |
5bfff907b4 | ||
![]() |
ec52bdea83 | ||
![]() |
d1a24d1758 | ||
![]() |
7e2ea3f871 | ||
![]() |
f3f1ab931b | ||
![]() |
2bf7c92469 | ||
![]() |
5464caa6f7 | ||
![]() |
231fbbe8ca | ||
![]() |
9a53ac15df | ||
![]() |
a05c23b507 | ||
![]() |
90c8fbbf00 | ||
![]() |
e9e843280b | ||
![]() |
c68bd960ce | ||
![]() |
aa222fecb2 | ||
![]() |
6ebd179ed5 | ||
![]() |
2574795d37 | ||
![]() |
b41298a3f6 | ||
![]() |
cb97c8fcb9 | ||
![]() |
aba61efa70 | ||
![]() |
147d043a32 | ||
![]() |
df59dec319 | ||
![]() |
f5cebfe6fd | ||
![]() |
15adf84a7d | ||
![]() |
d4fd9c8d43 | ||
![]() |
151f15e282 | ||
![]() |
a6283e64cc | ||
![]() |
9c75845944 | ||
![]() |
db15f6d6a1 | ||
![]() |
026b348cf8 | ||
![]() |
711c41826a | ||
![]() |
a4e2c56c49 | ||
![]() |
7a6b41fbd4 | ||
![]() |
17bbab44c9 | ||
![]() |
b413a113f9 | ||
![]() |
280828dae6 | ||
![]() |
3320eaccb2 | ||
![]() |
22c2682574 | ||
![]() |
f64dc3f35f | ||
![]() |
6370e0b2d3 | ||
![]() |
6bfb557ca6 | ||
![]() |
959956cfc9 | ||
![]() |
99899d1d5c | ||
![]() |
591b9399a8 | ||
![]() |
f77da9cdb0 | ||
![]() |
19cb6ee521 | ||
![]() |
e92b44bc84 | ||
![]() |
c754fac10f | ||
![]() |
90a2af9fe2 | ||
![]() |
ff4181ad5a | ||
![]() |
e93702bb8d | ||
![]() |
54fc2c8fbd | ||
![]() |
7881b850ec | ||
![]() |
0da131cd9a | ||
![]() |
30635c72e8 | ||
![]() |
917faa56f5 | ||
![]() |
690346a854 | ||
![]() |
9a547b4553 | ||
![]() |
86f5a8b71b | ||
![]() |
4ee9deae62 | ||
![]() |
9e1962f006 | ||
![]() |
5456211266 | ||
![]() |
a56a4a16e8 | ||
![]() |
7295a2e7b3 | ||
![]() |
909d44f436 | ||
![]() |
a9fae5ff12 | ||
![]() |
01df8ca889 | ||
![]() |
d6d8576700 | ||
![]() |
c7efef60ac | ||
![]() |
7c2248151d | ||
![]() |
360a44f57b | ||
![]() |
0b7a5f69fa | ||
![]() |
24c644207d | ||
![]() |
1509364a49 | ||
![]() |
2afa19db01 | ||
![]() |
d291ce6d0f | ||
![]() |
089a14f9e0 | ||
![]() |
56cd448a32 | ||
![]() |
1ebf7034f5 | ||
![]() |
105b3cdde4 | ||
![]() |
97ebd14829 | ||
![]() |
53e1ec023f | ||
![]() |
8fe04c99c6 | ||
![]() |
278a61adab | ||
![]() |
1423bdd564 | ||
![]() |
79b3687424 | ||
![]() |
1ddf4e151c | ||
![]() |
af96628855 | ||
![]() |
0b8501427b | ||
![]() |
95fd04db8e | ||
![]() |
21343f2bb8 | ||
![]() |
33af3debc4 | ||
![]() |
0e08abb3e2 | ||
![]() |
7e382e6e43 | ||
![]() |
f77ed0c0ed | ||
![]() |
e5fe84dc2e | ||
![]() |
6ae87b9208 | ||
![]() |
9d85938ed7 | ||
![]() |
939622e827 | ||
![]() |
6f1eb06119 | ||
![]() |
5391bcc1bc | ||
![]() |
f21e327e69 | ||
![]() |
2419e6b4c5 | ||
![]() |
762775bc03 | ||
![]() |
b077504b3c | ||
![]() |
5008f07808 | ||
![]() |
b6dc112eb3 | ||
![]() |
5078b8a66d | ||
![]() |
bafdab20cf | ||
![]() |
3ea21f6c6a | ||
![]() |
091be036f4 | ||
![]() |
71ac6aff2f | ||
![]() |
a5f1ab8a1c | ||
![]() |
8816bd7541 | ||
![]() |
31c2a2575d | ||
![]() |
4521de2bea | ||
![]() |
538b5b6304 | ||
![]() |
97b73489d1 | ||
![]() |
6ef4392fb1 | ||
![]() |
e07a0c432a | ||
![]() |
7c9549ce88 | ||
![]() |
b3ef95e60e | ||
![]() |
b3574d6b3e | ||
![]() |
6d477ea509 | ||
![]() |
2377b2958d | ||
![]() |
21a6d83ec8 | ||
![]() |
0b2767fe4c | ||
![]() |
1aefed9602 | ||
![]() |
b094274d98 | ||
![]() |
ae4ed1fbf3 | ||
![]() |
d49d92e5cb | ||
![]() |
3520a357f5 | ||
![]() |
ebf22f2ee7 | ||
![]() |
204f32791d | ||
![]() |
e1ba0b2373 | ||
![]() |
95c73738fa | ||
![]() |
de5549ff69 | ||
![]() |
cec4e029f0 | ||
![]() |
7003d19c71 | ||
![]() |
111132238d | ||
![]() |
fe420d0bf9 | ||
![]() |
410dbcf1d5 | ||
![]() |
96d6e76c05 | ||
![]() |
ed482a17c5 | ||
![]() |
99ba76c695 | ||
![]() |
a12ca976a0 | ||
![]() |
c0f57dffb2 | ||
![]() |
b6fbab0443 | ||
![]() |
1fd9d2f0c5 | ||
![]() |
01b02d6092 | ||
![]() |
5b283550b7 | ||
![]() |
d6145ac73e | ||
![]() |
f90c53ae65 | ||
![]() |
2ba8229d23 | ||
![]() |
5d02e3a03e | ||
![]() |
6b43e02a25 | ||
![]() |
11b59994cf | ||
![]() |
4df86e53a7 | ||
![]() |
8d4dd349ae | ||
![]() |
5ae2846d97 | ||
![]() |
b164190f6a | ||
![]() |
ef953ce81e | ||
![]() |
ee4ad89451 | ||
![]() |
1c07d268b8 | ||
![]() |
3f44082457 | ||
![]() |
b6170aa40d | ||
![]() |
32caf41929 | ||
![]() |
f5b5b73f07 | ||
![]() |
9ed1135d74 | ||
![]() |
de2ffaf8e5 | ||
![]() |
d72cece54a | ||
![]() |
400b163f84 | ||
![]() |
33c19542af | ||
![]() |
1eb0b42387 | ||
![]() |
29d2b701c9 | ||
![]() |
785d24d0d2 | ||
![]() |
726ee55de4 | ||
![]() |
ac223bb8a6 | ||
![]() |
e63ab3db4f | ||
![]() |
0d025d8c3d | ||
![]() |
f72e34fefa | ||
![]() |
c60f2e3490 | ||
![]() |
bb0c1f8a08 | ||
![]() |
8ffd7aa1d4 | ||
![]() |
94868e606a | ||
![]() |
705f238e1e | ||
![]() |
1b17132631 | ||
![]() |
080b49a4ce | ||
![]() |
0ffcc4970f | ||
![]() |
66844826c6 | ||
![]() |
dcd28fadc6 | ||
![]() |
18333999a2 | ||
![]() |
b083e1d067 | ||
![]() |
5b92b80f79 | ||
![]() |
3e6e8d03a4 | ||
![]() |
71fef439ed | ||
![]() |
0307111993 | ||
![]() |
64ca5af879 | ||
![]() |
70778bc4c4 | ||
![]() |
911e0f5330 | ||
![]() |
fbd71f8dfe | ||
![]() |
809deee3a6 | ||
![]() |
375b03dcd4 | ||
![]() |
3a6e2d1661 | ||
![]() |
2e4e05369c | ||
![]() |
126ab53840 | ||
![]() |
9175b76887 | ||
![]() |
50ea1ac889 | ||
![]() |
4dbfcc5043 | ||
![]() |
7a1a67c718 | ||
![]() |
2bc07996fa | ||
![]() |
4379bfb7ec | ||
![]() |
2f8a8c1c9a | ||
![]() |
04488af790 | ||
![]() |
9a935ed559 | ||
![]() |
5957bab2e2 | ||
![]() |
d0be98feb9 | ||
![]() |
9f3985d398 | ||
![]() |
000e1335a2 | ||
![]() |
5e6dd8b1ed | ||
![]() |
4d2cf85a51 | ||
![]() |
93644b7c58 | ||
![]() |
ca60884c05 | ||
![]() |
50fa974dcc | ||
![]() |
08eef424a0 | ||
![]() |
dc85a5088f | ||
![]() |
e862d5f20b | ||
![]() |
bd1a7db46f | ||
![]() |
dd2aa7c5ec | ||
![]() |
5c02953b1c | ||
![]() |
04e806e0b4 | ||
![]() |
e69d8b24fc | ||
![]() |
449ec3a367 | ||
![]() |
b677ab5949 | ||
![]() |
6c32b62ef3 | ||
![]() |
ef066183dd | ||
![]() |
a822dd817b | ||
![]() |
775dade80f | ||
![]() |
cb8901c16d | ||
![]() |
4713282bb1 | ||
![]() |
d677c30359 | ||
![]() |
36985c92dc | ||
![]() |
2e867956eb | ||
![]() |
d89cc48bf3 | ||
![]() |
a1ef5f509f | ||
![]() |
7aaa34ddfc | ||
![]() |
e5c7c77362 | ||
![]() |
f93f59e2e5 | ||
![]() |
f54b133085 | ||
![]() |
255926ab19 | ||
![]() |
717f6bffe4 | ||
![]() |
917b5e51c2 | ||
![]() |
d5d8de36f5 | ||
![]() |
bd13edfc88 | ||
![]() |
22a68878e4 | ||
![]() |
a6c849166d | ||
![]() |
ce5174dd21 | ||
![]() |
d6139daa79 | ||
![]() |
6fc005f19c | ||
![]() |
2894b35d66 | ||
![]() |
9e547bf6e4 | ||
![]() |
6da1c53de7 | ||
![]() |
03fa68dbb6 | ||
![]() |
05e435aae7 | ||
![]() |
1d2093ab0a | ||
![]() |
a17a7200b8 | ||
![]() |
cfeef41d61 | ||
![]() |
88b1380a54 | ||
![]() |
b7527f7966 | ||
![]() |
421733e21b | ||
![]() |
df7e690469 | ||
![]() |
fc42c38706 | ||
![]() |
acafb28661 | ||
![]() |
4f1c474433 | ||
![]() |
a599638ce2 | ||
![]() |
3fa778abe2 | ||
![]() |
f57d3527d3 | ||
![]() |
f59b0dec60 | ||
![]() |
da60fa0047 | ||
![]() |
d9829fce06 | ||
![]() |
4b6189b91b | ||
![]() |
3cd61ff1b4 | ||
![]() |
7ebdd6a2a6 | ||
![]() |
1837077012 | ||
![]() |
5e997605b3 | ||
![]() |
85d129af77 | ||
![]() |
1ac71a94a5 | ||
![]() |
b604458ba8 | ||
![]() |
ce70484738 | ||
![]() |
53f54e1e19 | ||
![]() |
e450582888 | ||
![]() |
3886358592 | ||
![]() |
ed8db3d31e | ||
![]() |
ab22fe86da | ||
![]() |
d238a023c1 | ||
![]() |
f50abd81a1 | ||
![]() |
40542fd08a | ||
![]() |
b862e139fc | ||
![]() |
b76236755a | ||
![]() |
a9252c6649 | ||
![]() |
619d02d78c | ||
![]() |
bccdabbc45 | ||
![]() |
1166de205c | ||
![]() |
e785df4c8f | ||
![]() |
b4e53b3ff7 | ||
![]() |
df2240ba08 | ||
![]() |
1484df9b8f | ||
![]() |
ead266507e | ||
![]() |
0e088aec28 | ||
![]() |
ab7dedf0a5 | ||
![]() |
12e5c96607 |
@ -1,4 +1,4 @@
|
|||||||
dist
|
dist
|
||||||
test/lib/
|
test/lib/
|
||||||
test/typescript/definitions.js
|
test/typescript/
|
||||||
docs
|
docs
|
||||||
|
142
.eslintrc.cjs
Normal file
142
.eslintrc.cjs
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
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',
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
};
|
354
.eslintrc.js
354
.eslintrc.js
@ -1,354 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
"extends": "airbnb-base",
|
|
||||||
"parser": "babel-eslint",
|
|
||||||
"parserOptions": { "sourceType": "module" },
|
|
||||||
|
|
||||||
"env": {
|
|
||||||
"browser": true,
|
|
||||||
"es6": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
|
|
||||||
"plugins": [
|
|
||||||
"chai-friendly"
|
|
||||||
],
|
|
||||||
|
|
||||||
"globals": { // TODO are all these necessary?
|
|
||||||
"globalThis": true,
|
|
||||||
"console": true,
|
|
||||||
"Promise": true,
|
|
||||||
"importScripts": true,
|
|
||||||
"process": true,
|
|
||||||
"Event": true,
|
|
||||||
"describe": true,
|
|
||||||
"it": true,
|
|
||||||
"sinon": true,
|
|
||||||
"mocha": true,
|
|
||||||
"before": true,
|
|
||||||
"beforeEach": true,
|
|
||||||
"after": true,
|
|
||||||
"afterEach": true,
|
|
||||||
"escape": true,
|
|
||||||
"unescape": true,
|
|
||||||
"postMessage": true,
|
|
||||||
"resolves": true,
|
|
||||||
"rejects": true,
|
|
||||||
"TransformStream": true,
|
|
||||||
"BigInt": true
|
|
||||||
},
|
|
||||||
|
|
||||||
"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": ["error", "always"],
|
|
||||||
"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": "error",
|
|
||||||
"line-comment-position": "off",
|
|
||||||
"linebreak-style": [
|
|
||||||
"error",
|
|
||||||
"unix"
|
|
||||||
],
|
|
||||||
"lines-around-comment": "off",
|
|
||||||
"lines-around-directive": "error",
|
|
||||||
"lines-between-class-members": "error",
|
|
||||||
"max-depth": "off",
|
|
||||||
"max-len": "off",
|
|
||||||
"max-lines": "off",
|
|
||||||
"max-nested-callbacks": "error",
|
|
||||||
"max-params": "off",
|
|
||||||
"max-statements": "off",
|
|
||||||
"max-statements-per-line": "off",
|
|
||||||
"multiline-comment-style": "off",
|
|
||||||
"multiline-ternary": "off",
|
|
||||||
"new-parens": "error",
|
|
||||||
"newline-after-var": "off",
|
|
||||||
"newline-before-return": "off",
|
|
||||||
"newline-per-chained-call": "off",
|
|
||||||
"no-alert": "error",
|
|
||||||
"no-array-constructor": "error",
|
|
||||||
"no-bitwise": "off",
|
|
||||||
"no-buffer-constructor": "error",
|
|
||||||
"no-caller": "error",
|
|
||||||
"no-catch-shadow": "error",
|
|
||||||
"no-confusing-arrow": "error",
|
|
||||||
"no-continue": "off",
|
|
||||||
"no-div-regex": "error",
|
|
||||||
"no-duplicate-imports": "error",
|
|
||||||
"no-else-return": "off",
|
|
||||||
"no-empty": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"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", { "max": 2, "maxEOF": 1, "maxBOF":0 }],
|
|
||||||
"no-native-reassign": "error",
|
|
||||||
"no-negated-condition": "off",
|
|
||||||
"no-negated-in-lhs": "error",
|
|
||||||
"no-nested-ternary": "off",
|
|
||||||
"no-new": "error",
|
|
||||||
"no-new-func": "error",
|
|
||||||
"no-new-object": "error",
|
|
||||||
"no-new-require": "error",
|
|
||||||
"no-new-wrappers": "error",
|
|
||||||
"no-octal-escape": "error",
|
|
||||||
"no-param-reassign": "off",
|
|
||||||
"no-path-concat": "error",
|
|
||||||
"no-plusplus": "off",
|
|
||||||
"no-process-env": "error",
|
|
||||||
"no-process-exit": "error",
|
|
||||||
"no-proto": "error",
|
|
||||||
"no-prototype-builtins": "off",
|
|
||||||
"no-restricted-globals": "error",
|
|
||||||
"no-restricted-imports": "error",
|
|
||||||
"no-restricted-modules": "error",
|
|
||||||
"no-restricted-properties": "error",
|
|
||||||
"no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"],
|
|
||||||
"no-return-assign": "error",
|
|
||||||
"no-return-await": "error",
|
|
||||||
"no-script-url": "error",
|
|
||||||
"no-self-compare": "error",
|
|
||||||
"no-shadow": "off",
|
|
||||||
"no-shadow-restricted-names": "error",
|
|
||||||
"no-spaced-func": "error",
|
|
||||||
"no-sync": "error",
|
|
||||||
"no-tabs": "error",
|
|
||||||
"no-template-curly-in-string": "error",
|
|
||||||
"no-ternary": "off",
|
|
||||||
"no-throw-literal": "error",
|
|
||||||
"no-undef-init": "error",
|
|
||||||
"no-undefined": "off",
|
|
||||||
"no-unmodified-loop-condition": "error",
|
|
||||||
"no-unneeded-ternary": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"defaultAssignment": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-use-before-define": "off",
|
|
||||||
"no-useless-call": "error",
|
|
||||||
"no-useless-computed-key": "error",
|
|
||||||
"no-useless-concat": "error",
|
|
||||||
"no-useless-constructor": "error",
|
|
||||||
"no-useless-rename": "error",
|
|
||||||
"no-useless-return": "error",
|
|
||||||
"no-void": "error",
|
|
||||||
"no-warning-comments": "off",
|
|
||||||
"no-whitespace-before-property": "error",
|
|
||||||
"no-with": "error",
|
|
||||||
"nonblock-statement-body-position": "error",
|
|
||||||
"object-curly-newline": "off",
|
|
||||||
"object-curly-spacing": "error",
|
|
||||||
"object-property-newline": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"allowMultiplePropertiesPerLine": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"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": "error",
|
|
||||||
"space-unary-ops": "error",
|
|
||||||
"spaced-comment": "off",
|
|
||||||
"strict": "off",
|
|
||||||
"switch-colon-spacing": "error",
|
|
||||||
"symbol-description": "error",
|
|
||||||
"template-curly-spacing": "error",
|
|
||||||
"template-tag-spacing": "error",
|
|
||||||
"unicode-bom": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
],
|
|
||||||
"wrap-iife": "error",
|
|
||||||
"wrap-regex": "off",
|
|
||||||
"yield-star-spacing": "error",
|
|
||||||
"yoda": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
],
|
|
||||||
"indent": [ "error", 2, { "SwitchCase": 1 } ],
|
|
||||||
"no-buffer-constructor": "error",
|
|
||||||
"no-lonely-if": "error",
|
|
||||||
"no-unused-vars": "error",
|
|
||||||
|
|
||||||
// eslint-plugin-import rules:
|
|
||||||
"import/extensions": "never",
|
|
||||||
"import/no-extraneous-dependencies": ["error", {"devDependencies": true, "optionalDependencies": false, "peerDependencies": false}],
|
|
||||||
"import/no-unassigned-import": "error",
|
|
||||||
|
|
||||||
// Custom silencers:
|
|
||||||
"camelcase": 0,
|
|
||||||
"require-await": 0,
|
|
||||||
"no-multi-assign": 0,
|
|
||||||
"no-underscore-dangle": 0,
|
|
||||||
"no-await-in-loop": 0,
|
|
||||||
|
|
||||||
// Custom errors:
|
|
||||||
"no-undef": 2,
|
|
||||||
"no-trailing-spaces": 2,
|
|
||||||
"no-mixed-operators": [ 2, {"groups": [["&", "|", "^", "~", "<<", ">>", ">>>"], ["&&", "||"]]}],
|
|
||||||
"no-use-before-define": [ 2, { "functions": false, "classes": true, "variables": false }],
|
|
||||||
"no-constant-condition": [ 2, { "checkLoops": false } ],
|
|
||||||
"new-cap": [ 2, { "properties": false, "capIsNewExceptionPattern": "EAX|OCB|GCM|CMAC|CBC|OMAC|CTR", "newIsCapExceptionPattern": "type|hash*"}],
|
|
||||||
"max-lines": [ 2, { "max": 620, "skipBlankLines": true, "skipComments": true } ],
|
|
||||||
"no-unused-expressions": 0,
|
|
||||||
"chai-friendly/no-unused-expressions": [ 2, { "allowShortCircuit": true } ],
|
|
||||||
|
|
||||||
// Custom warnings:
|
|
||||||
"no-console": 1,
|
|
||||||
}
|
|
||||||
};
|
|
10
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
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
Normal file
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
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
|
33
.github/dependabot.yml
vendored
Normal file
33
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
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"
|
||||||
|
versioning-strategy: increase
|
||||||
|
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
allow:
|
||||||
|
- dependency-name: "@noble*"
|
||||||
|
- dependency-name: "fflate"
|
||||||
|
versioning-strategy: increase
|
||||||
|
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"
|
39
.github/test-suite/config.json.template
vendored
Normal file
39
.github/test-suite/config.json.template
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"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
Executable file
14
.github/test-suite/prepare_config.sh
vendored
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
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
Normal file
67
.github/workflows/benchmark.yml
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
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
|
||||||
|
|
52
.github/workflows/browserstack.yml
vendored
52
.github/workflows/browserstack.yml
vendored
@ -1,52 +0,0 @@
|
|||||||
name: Test on Browserstack
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
pull_request:
|
|
||||||
branches: [master]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
full:
|
|
||||||
name: Full Build
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: softprops/turnstyle@v1
|
|
||||||
with:
|
|
||||||
poll-interval-seconds: 30
|
|
||||||
abort-after-seconds: 900
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- uses: actions/setup-node@v1
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run build-test
|
|
||||||
- run: npm run browserstack
|
|
||||||
|
|
||||||
lightweight:
|
|
||||||
name: Lightweight Build
|
|
||||||
|
|
||||||
needs: full
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: softprops/turnstyle@v1
|
|
||||||
with:
|
|
||||||
poll-interval-seconds: 30
|
|
||||||
abort-after-seconds: 900
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- uses: actions/setup-node@v1
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run build-test --lightweight
|
|
||||||
- run: npm run browserstack
|
|
||||||
env:
|
|
||||||
LIGHTWEIGHT: true
|
|
||||||
|
|
||||||
env:
|
|
||||||
BROWSERSTACK_USERNAME: danielhuigens2
|
|
||||||
BROWSERSTACK_KEY: aW2q1ms393QRorwBnfmW
|
|
19
.github/workflows/docs.yml
vendored
Normal file
19
.github/workflows/docs.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
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
|
19
.github/workflows/lint.yml
vendored
19
.github/workflows/lint.yml
vendored
@ -1,19 +0,0 @@
|
|||||||
name: Lint
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
pull_request:
|
|
||||||
branches: [master]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: ESLint
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v1
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run lint
|
|
29
.github/workflows/node.js.yml
vendored
29
.github/workflows/node.js.yml
vendored
@ -1,29 +0,0 @@
|
|||||||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
||||||
|
|
||||||
name: Test on Node.js
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
pull_request:
|
|
||||||
branches: [master]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: ${{ matrix.node-version }}
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [12.x, 14.x, 15.x]
|
|
||||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm test
|
|
87
.github/workflows/sop-test-suite.yml
vendored
Normal file
87
.github/workflows/sop-test-suite.yml
vendored
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
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
|
21
.github/workflows/test-type-definitions.yml
vendored
21
.github/workflows/test-type-definitions.yml
vendored
@ -1,21 +0,0 @@
|
|||||||
name: Types
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
pull_request:
|
|
||||||
branches: [master]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: Test type definitions
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: '15'
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run test-type-definitions
|
|
206
.github/workflows/tests.yml
vendored
Normal file
206
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
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 }}
|
||||||
|
# ignore cache miss, since it was taken care of the `build` step and it should never occur here
|
||||||
|
- 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)
|
||||||
|
# TODO: windows-latest fails to fetch resources from the wtr server; investigate if the problem is with path declaration or permissions
|
||||||
|
runner: ['ubuntu-latest', 'macos-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 }}
|
||||||
|
|
||||||
|
- 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
|
||||||
|
run: |
|
||||||
|
PLAYWRIGHT_VERSION=$(npm ls playwright --depth=0 | grep playwright | sed 's/.*@//')
|
||||||
|
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
|
||||||
|
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
|
||||||
|
if: ${{ matrix.runner == 'macos-latest' }} # do not install on ubuntu, since the X25519 WebCrypto implementation has issues
|
||||||
|
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 --lightweight
|
||||||
|
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 --lightweight
|
||||||
|
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
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,4 +5,4 @@ test/lib/
|
|||||||
test/typescript/definitions.js
|
test/typescript/definitions.js
|
||||||
dist/
|
dist/
|
||||||
openpgp.store/
|
openpgp.store/
|
||||||
.nyc_output/
|
coverage
|
||||||
|
6
.mocharc.json
Normal file
6
.mocharc.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"node-option": [
|
||||||
|
"experimental-specifier-resolution=node",
|
||||||
|
"loader=ts-node/esm"
|
||||||
|
]
|
||||||
|
}
|
263
README.md
263
README.md
@ -1,7 +1,7 @@
|
|||||||
OpenPGP.js [](https://automate.browserstack.com/public-build/eEkxVVM1TytwOGJNWEdnTjk4Y0VNUUNyR3pXcEtJUGRXOVFBRjVNT1JpUT0tLTZYUlZaMWdtQWs4Z0ROS3grRXc2bFE9PQ==--4a9cac0d6ea009d81aff66de0dbb239edd1aef3c) [](https://gitter.im/openpgpjs/openpgpjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
OpenPGP.js [](https://gitter.im/openpgpjs/openpgpjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
==========
|
==========
|
||||||
|
|
||||||
[OpenPGP.js](https://openpgpjs.org/) is a JavaScript implementation of the OpenPGP protocol. It implements [RFC4880](https://tools.ietf.org/html/rfc4880) and parts of [RFC4880bis](https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-10).
|
[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)).
|
||||||
|
|
||||||
**Table of Contents**
|
**Table of Contents**
|
||||||
|
|
||||||
@ -10,6 +10,7 @@ OpenPGP.js [
|
- [Performance](#performance)
|
||||||
- [Getting started](#getting-started)
|
- [Getting started](#getting-started)
|
||||||
- [Node.js](#nodejs)
|
- [Node.js](#nodejs)
|
||||||
|
- [Deno (experimental)](#deno-experimental)
|
||||||
- [Browser (webpack)](#browser-webpack)
|
- [Browser (webpack)](#browser-webpack)
|
||||||
- [Browser (plain files)](#browser-plain-files)
|
- [Browser (plain files)](#browser-plain-files)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
@ -32,61 +33,62 @@ OpenPGP.js [ bundle works with recent versions of Chrome, Firefox, Edge and Safari 14+.
|
||||||
|
|
||||||
* The `dist/node/openpgp.min.js` bundle works well in Node.js. It is used by default when you `require('openpgp')` in Node.js.
|
* 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).
|
||||||
|
|
||||||
|
* 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).
|
||||||
|
|
||||||
* Currently, Chrome, Safari and Edge have partial implementations of the
|
|
||||||
[Streams specification](https://streams.spec.whatwg.org/), and Firefox
|
|
||||||
has a partial implementation behind feature flags. Chrome is the only
|
|
||||||
browser that implements `TransformStream`s, which we need, so we include
|
|
||||||
a [polyfill](https://github.com/MattiasBuelens/web-streams-polyfill) for
|
|
||||||
all other browsers. Please note that in those browsers, the global
|
|
||||||
`ReadableStream` property gets overwritten with the polyfill version if
|
|
||||||
it exists. 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
|
|
||||||
OpenPGP.js. There is also the
|
|
||||||
[web-streams-adapter](https://github.com/MattiasBuelens/web-streams-adapter)
|
|
||||||
library to convert back and forth between them.
|
|
||||||
|
|
||||||
### Performance
|
### Performance
|
||||||
|
|
||||||
* 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. 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 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:
|
||||||
|
|
||||||
| Curve | Encryption | Signature | NodeCrypto | WebCrypto | Constant-Time |
|
| Curve | Encryption | Signature | NodeCrypto | WebCrypto | Constant-Time |
|
||||||
|:---------------:|:----------:|:---------:|:----------:|:---------:|:-----------------:|
|
|:---------------:|:----------:|:---------:|:----------:|:---------:|:-----------------:|
|
||||||
| curve25519 | ECDH | N/A | No | No | Algorithmically** |
|
| curve25519 | ECDH | N/A | No | No | Algorithmically |
|
||||||
| ed25519 | N/A | EdDSA | No | No | Algorithmically** |
|
| ed25519 | N/A | EdDSA | No | Yes* | If native** |
|
||||||
| p256 | ECDH | ECDSA | Yes* | Yes* | If native*** |
|
| nistP256 | ECDH | ECDSA | Yes* | Yes* | If native** |
|
||||||
| p384 | ECDH | ECDSA | Yes* | Yes* | If native*** |
|
| nistP384 | ECDH | ECDSA | Yes* | Yes* | If native** |
|
||||||
| p521 | ECDH | ECDSA | Yes* | Yes* | If native*** |
|
| nistP521 | ECDH | ECDSA | Yes* | Yes* | If native** |
|
||||||
| brainpoolP256r1 | ECDH | ECDSA | Yes* | No | If native*** |
|
| brainpoolP256r1 | ECDH | ECDSA | Yes* | No | If native** |
|
||||||
| brainpoolP384r1 | ECDH | ECDSA | Yes* | No | If native*** |
|
| brainpoolP384r1 | ECDH | ECDSA | Yes* | No | If native** |
|
||||||
| brainpoolP512r1 | ECDH | ECDSA | Yes* | No | If native*** |
|
| brainpoolP512r1 | ECDH | ECDSA | Yes* | No | If native** |
|
||||||
| secp256k1 | ECDH | ECDSA | Yes* | No | If native*** |
|
| secp256k1 | ECDH | ECDSA | Yes* | No | If native** |
|
||||||
|
|
||||||
\* when available
|
\* when available
|
||||||
\** the curve25519 and ed25519 implementations are algorithmically constant-time, but may not be constant-time after optimizations of the JavaScript compiler
|
\** these curves are only constant-time if the underlying native implementation is available and constant-time
|
||||||
\*** these curves are only constant-time if the underlying native implementation is available and constant-time
|
|
||||||
|
|
||||||
* 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 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.
|
||||||
|
|
||||||
* 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.
|
* 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`.
|
||||||
|
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-10) 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.aeadProtect = 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.eax // Default, native
|
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.gcm; // Default, native in WebCrypto and Node.js
|
||||||
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.ocb // Non-native
|
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.ocb; // Non-native, but supported across RFC 9580 implementations
|
||||||
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.experimentalGCM // **Non-standard**, fastest
|
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.eax; // Native in Node.js
|
||||||
```
|
```
|
||||||
|
|
||||||
* 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.
|
|
||||||
|
|
||||||
|
|
||||||
### Getting started
|
### Getting started
|
||||||
|
|
||||||
#### Node.js
|
#### Node.js
|
||||||
@ -97,16 +99,23 @@ Install OpenPGP.js using npm and save it in your dependencies:
|
|||||||
npm install --save openpgp
|
npm install --save openpgp
|
||||||
```
|
```
|
||||||
|
|
||||||
And import it as a CommonJS module:
|
And import it as an ES module, from a .mjs file:
|
||||||
|
```js
|
||||||
|
import * as openpgp from 'openpgp';
|
||||||
|
```
|
||||||
|
|
||||||
|
Or as a CommonJS module:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const openpgp = require('openpgp');
|
const openpgp = require('openpgp');
|
||||||
```
|
```
|
||||||
|
|
||||||
Or as an ES6 module, from an .mjs file:
|
#### Deno (experimental)
|
||||||
|
|
||||||
|
Import as an ES6 module, using /dist/openpgp.mjs.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import * as openpgp from 'openpgp';
|
import * as openpgp from './openpgpjs/dist/openpgp.mjs';
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Browser (webpack)
|
#### Browser (webpack)
|
||||||
@ -163,9 +172,19 @@ import * as openpgp from './openpgp.min.mjs';
|
|||||||
|
|
||||||
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`.
|
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.
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
Here are some examples of how to use OpenPGP.js v5. 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 v4 it might help to check out the [changelog](https://github.com/openpgpjs/openpgpjs/wiki/V5-Changelog) and [documentation](https://github.com/openpgpjs/openpgpjs#documentation).
|
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
|
||||||
|
|
||||||
@ -177,7 +196,7 @@ Encryption will use the algorithm specified in config.preferredSymmetricAlgorith
|
|||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message, // input as Message object
|
message, // input as Message object
|
||||||
passwords: ['secret stuff'], // multiple passwords possible
|
passwords: ['secret stuff'], // multiple passwords possible
|
||||||
armor: false // don't ASCII armor (for Uint8Array output)
|
format: 'binary' // don't ASCII armor (for Uint8Array output)
|
||||||
});
|
});
|
||||||
console.log(encrypted); // Uint8Array
|
console.log(encrypted); // Uint8Array
|
||||||
|
|
||||||
@ -195,7 +214,7 @@ Encryption will use the algorithm specified in config.preferredSymmetricAlgorith
|
|||||||
|
|
||||||
#### 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 key (defaults to aes256 for keys generated in OpenPGP.js), and decryption will use the algorithm used for encryption.
|
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
|
const openpgp = require('openpgp'); // use as CommonJS, AMD, ES6 module or via window.openpgp
|
||||||
@ -213,14 +232,14 @@ const openpgp = require('openpgp'); // use as CommonJS, AMD, ES6 module or via w
|
|||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
const privateKey = await openpgp.decryptKey({
|
||||||
privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
|
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
||||||
passphrase
|
passphrase
|
||||||
});
|
});
|
||||||
|
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message: await openpgp.createMessage({ text: 'Hello, World!' }), // input as Message object
|
message: await openpgp.createMessage({ text: 'Hello, World!' }), // input as Message object
|
||||||
publicKeys: publicKey, // for encryption
|
encryptionKeys: publicKey,
|
||||||
privateKeys: privateKey // for signing (optional)
|
signingKeys: privateKey // optional
|
||||||
});
|
});
|
||||||
console.log(encrypted); // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
console.log(encrypted); // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
||||||
|
|
||||||
@ -229,11 +248,17 @@ const openpgp = require('openpgp'); // use as CommonJS, AMD, ES6 module or via w
|
|||||||
});
|
});
|
||||||
const { data: decrypted, signatures } = await openpgp.decrypt({
|
const { data: decrypted, signatures } = await openpgp.decrypt({
|
||||||
message,
|
message,
|
||||||
publicKeys: publicKey, // for verification (optional)
|
verificationKeys: publicKey, // optional
|
||||||
privateKeys: privateKey // for decryption
|
decryptionKeys: privateKey
|
||||||
});
|
});
|
||||||
console.log(decrypted); // 'Hello, World!'
|
console.log(decrypted); // 'Hello, World!'
|
||||||
console.log(signatures[0].valid) // signature validity (signed messages only)
|
// 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);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -253,7 +278,7 @@ Encrypt to multiple public keys:
|
|||||||
...
|
...
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
|
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
|
||||||
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
||||||
const message = 'Hello, World!';
|
const plaintext = 'Hello, World!';
|
||||||
|
|
||||||
const publicKeys = await Promise.all(publicKeysArmored.map(armoredKey => openpgp.readKey({ armoredKey })));
|
const publicKeys = await Promise.all(publicKeysArmored.map(armoredKey => openpgp.readKey({ armoredKey })));
|
||||||
|
|
||||||
@ -262,11 +287,11 @@ Encrypt to multiple public keys:
|
|||||||
passphrase
|
passphrase
|
||||||
});
|
});
|
||||||
|
|
||||||
const message = await openpgp.createMessage({ text: message });
|
const message = await openpgp.createMessage({ text: plaintext });
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message:, // input as Message object
|
message, // input as Message object
|
||||||
publicKeys, // for encryption
|
encryptionKeys: publicKeys,
|
||||||
privateKeys: privateKey // for signing (optional)
|
signingKeys: privateKey // optional
|
||||||
});
|
});
|
||||||
console.log(encrypted); // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
console.log(encrypted); // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
||||||
})();
|
})();
|
||||||
@ -287,7 +312,7 @@ If you expect an encrypted message to be signed with one of the public keys you
|
|||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
const privateKey = await openpgp.decryptKey({
|
||||||
privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
|
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
||||||
passphrase
|
passphrase
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -301,9 +326,9 @@ If you expect an encrypted message to be signed with one of the public keys you
|
|||||||
// decryption will fail if all signatures are invalid or missing
|
// decryption will fail if all signatures are invalid or missing
|
||||||
const { data: decrypted, signatures } = await openpgp.decrypt({
|
const { data: decrypted, signatures } = await openpgp.decrypt({
|
||||||
message,
|
message,
|
||||||
privateKeys: privateKey // for decryption
|
decryptionKeys: privateKey,
|
||||||
expectSigned: true,
|
expectSigned: true,
|
||||||
publicKeys: publicKey, // for verification (mandatory with expectSigned=true)
|
verificationKeys: publicKey, // mandatory with expectSigned=true
|
||||||
});
|
});
|
||||||
console.log(decrypted); // 'Hello, World!'
|
console.log(decrypted); // 'Hello, World!'
|
||||||
})();
|
})();
|
||||||
@ -311,7 +336,7 @@ If you expect an encrypted message to be signed with one of the public keys you
|
|||||||
|
|
||||||
#### Encrypt symmetrically with compression
|
#### Encrypt symmetrically with compression
|
||||||
|
|
||||||
By default, `encrypt` will not use any compression when encrypting symmetrically only (i.e. when no `publicKeys` are given).
|
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:
|
It's possible to change that behaviour by enabling compression through the config, either for the single encryption:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -352,7 +377,7 @@ Where the value can be any of:
|
|||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message, // input as Message object
|
message, // input as Message object
|
||||||
passwords: ['secret stuff'], // multiple passwords possible
|
passwords: ['secret stuff'], // multiple passwords possible
|
||||||
armor: false // don't ASCII armor (for Uint8Array output)
|
format: 'binary' // don't ASCII armor (for Uint8Array output)
|
||||||
});
|
});
|
||||||
console.log(encrypted); // raw encrypted packets as ReadableStream<Uint8Array>
|
console.log(encrypted); // raw encrypted packets as ReadableStream<Uint8Array>
|
||||||
|
|
||||||
@ -364,14 +389,8 @@ Where the value can be any of:
|
|||||||
})();
|
})();
|
||||||
```
|
```
|
||||||
|
|
||||||
For more information on using ReadableStreams, see [the MDN Documentation on the
|
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).
|
Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) .
|
||||||
|
|
||||||
You can also pass a [Node.js `Readable`
|
|
||||||
stream](https://nodejs.org/api/stream.html#stream_class_stream_readable), in
|
|
||||||
which case OpenPGP.js will return a Node.js `Readable` stream as well, which you
|
|
||||||
can `.pipe()` to a `Writable` stream, for example.
|
|
||||||
|
|
||||||
|
|
||||||
#### Streaming encrypt and decrypt *String* data with PGP keys
|
#### Streaming encrypt and decrypt *String* data with PGP keys
|
||||||
|
|
||||||
@ -380,7 +399,7 @@ can `.pipe()` to a `Writable` stream, for example.
|
|||||||
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
...
|
...
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`; // Public key
|
-----END PGP PUBLIC KEY BLOCK-----`; // Public key
|
||||||
const [privateKeyArmored] = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
||||||
...
|
...
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`; // Encrypted private key
|
-----END PGP PRIVATE KEY BLOCK-----`; // Encrypted private key
|
||||||
const passphrase = `yourPassphrase`; // Password that private key is encrypted with
|
const passphrase = `yourPassphrase`; // Password that private key is encrypted with
|
||||||
@ -388,7 +407,7 @@ can `.pipe()` to a `Writable` stream, for example.
|
|||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
const privateKey = await openpgp.decryptKey({
|
||||||
privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
|
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
||||||
passphrase
|
passphrase
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -401,8 +420,8 @@ can `.pipe()` to a `Writable` stream, for example.
|
|||||||
|
|
||||||
const encrypted = await openpgp.encrypt({
|
const encrypted = await openpgp.encrypt({
|
||||||
message: await openpgp.createMessage({ text: readableStream }), // input as Message object
|
message: await openpgp.createMessage({ text: readableStream }), // input as Message object
|
||||||
publicKeys: publicKey, // for encryption
|
encryptionKeys: publicKey,
|
||||||
privateKeys: privateKey // for signing (optional)
|
signingKeys: privateKey // optional
|
||||||
});
|
});
|
||||||
console.log(encrypted); // ReadableStream containing '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
console.log(encrypted); // ReadableStream containing '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
||||||
|
|
||||||
@ -411,8 +430,8 @@ can `.pipe()` to a `Writable` stream, for example.
|
|||||||
});
|
});
|
||||||
const decrypted = await openpgp.decrypt({
|
const decrypted = await openpgp.decrypt({
|
||||||
message,
|
message,
|
||||||
publicKeys: publicKey, // for verification (optional)
|
verificationKeys: publicKey, // optional
|
||||||
privateKeys: privateKey // for decryption
|
decryptionKeys: privateKey
|
||||||
});
|
});
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
for await (const chunk of decrypted.data) {
|
for await (const chunk of decrypted.data) {
|
||||||
@ -428,22 +447,23 @@ can `.pipe()` to a `Writable` stream, for example.
|
|||||||
|
|
||||||
ECC keys (smaller and faster to generate):
|
ECC keys (smaller and faster to generate):
|
||||||
|
|
||||||
Possible values for `curve` are: `curve25519`, `ed25519`, `p256`, `p384`, `p521`,
|
Possible values for `curve` are: `curve25519`, `ed25519`, `nistP256`, `nistP384`, `nistP521`,
|
||||||
`brainpoolP256r1`, `brainpoolP384r1`, `brainpoolP512r1`, and `secp256k1`.
|
`brainpoolP256r1`, `brainpoolP384r1`, `brainpoolP512r1`, and `secp256k1`.
|
||||||
Note that both the `curve25519` and `ed25519` options generate a primary key for signing using Ed25519
|
Note that both the `curve25519` and `ed25519` options 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 () => {
|
(async () => {
|
||||||
const { privateKeyArmored, publicKeyArmored, revocationCertificate } = await openpgp.generateKey({
|
const { privateKey, publicKey, revocationCertificate } = await openpgp.generateKey({
|
||||||
type: 'ecc', // Type of the key, defaults to ECC
|
type: 'ecc', // Type of the key, defaults to ECC
|
||||||
curve: 'curve25519', // ECC curve name, defaults to curve25519
|
curve: 'curve25519', // ECC curve name, defaults to curve25519
|
||||||
userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
|
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
|
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(privateKeyArmored); // '-----BEGIN PGP PRIVATE KEY BLOCK ... '
|
console.log(privateKey); // '-----BEGIN PGP PRIVATE KEY BLOCK ... '
|
||||||
console.log(publicKeyArmored); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
console.log(publicKey); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
||||||
console.log(revocationCertificate); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
console.log(revocationCertificate); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
||||||
})();
|
})();
|
||||||
```
|
```
|
||||||
@ -452,7 +472,7 @@ RSA keys (increased compatibility):
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
(async () => {
|
(async () => {
|
||||||
const key = await openpgp.generateKey({
|
const { privateKey, publicKey } = await openpgp.generateKey({
|
||||||
type: 'rsa', // Type of the key
|
type: 'rsa', // Type of the key
|
||||||
rsaBits: 4096, // RSA key size (defaults to 4096 bits)
|
rsaBits: 4096, // RSA key size (defaults to 4096 bits)
|
||||||
userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
|
userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
|
||||||
@ -466,9 +486,10 @@ RSA keys (increased compatibility):
|
|||||||
Using a revocation certificate:
|
Using a revocation certificate:
|
||||||
```js
|
```js
|
||||||
(async () => {
|
(async () => {
|
||||||
const { publicKeyArmored: revokedKeyArmored } = await openpgp.revokeKey({
|
const { publicKey: revokedKeyArmored } = await openpgp.revokeKey({
|
||||||
key: await openpgp.readKey({ armoredKey: publicKeyArmored }),
|
key: await openpgp.readKey({ armoredKey: publicKeyArmored }),
|
||||||
revocationCertificate
|
revocationCertificate,
|
||||||
|
format: 'armored' // output armored keys
|
||||||
});
|
});
|
||||||
console.log(revokedKeyArmored); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
console.log(revokedKeyArmored); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
||||||
})();
|
})();
|
||||||
@ -477,9 +498,11 @@ Using a revocation certificate:
|
|||||||
Using the private key:
|
Using the private key:
|
||||||
```js
|
```js
|
||||||
(async () => {
|
(async () => {
|
||||||
const { publicKeyArmored, publicKey } = await openpgp.revokeKey({
|
const { publicKey: revokedKeyArmored } = await openpgp.revokeKey({
|
||||||
key: await openpgp.readKey({ armoredKey: privateKeyArmored })
|
key: await openpgp.readKey({ armoredKey: privateKeyArmored }),
|
||||||
|
format: 'armored' // output armored keys
|
||||||
});
|
});
|
||||||
|
console.log(revokedKeyArmored); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
|
||||||
})();
|
})();
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -498,29 +521,30 @@ Using the private key:
|
|||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
const privateKey = await openpgp.decryptKey({
|
||||||
privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
|
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
||||||
passphrase
|
passphrase
|
||||||
});
|
});
|
||||||
|
|
||||||
const unsignedMessage = await openpgp.createCleartextMessage({ text: 'Hello, World!' });
|
const unsignedMessage = await openpgp.createCleartextMessage({ text: 'Hello, World!' });
|
||||||
const cleartextMessage = await openpgp.sign({
|
const cleartextMessage = await openpgp.sign({
|
||||||
message: unsignedMessage, // CleartextMessage or Message object
|
message: unsignedMessage, // CleartextMessage or Message object
|
||||||
privateKeys: privateKey // for signing
|
signingKeys: privateKey
|
||||||
});
|
});
|
||||||
console.log(cleartextMessage); // '-----BEGIN PGP SIGNED MESSAGE ... END PGP SIGNATURE-----'
|
console.log(cleartextMessage); // '-----BEGIN PGP SIGNED MESSAGE ... END PGP SIGNATURE-----'
|
||||||
|
|
||||||
const signedMessage = await openpgp.readCleartextMessage({
|
const signedMessage = await openpgp.readCleartextMessage({
|
||||||
cleartextMessage // parse armored message
|
cleartextMessage // parse armored message
|
||||||
});
|
});
|
||||||
const verified = await openpgp.verify({
|
const verificationResult = await openpgp.verify({
|
||||||
message: signedMessage,
|
message: signedMessage,
|
||||||
publicKeys: publicKey // for verification
|
verificationKeys: publicKey
|
||||||
});
|
});
|
||||||
const { valid } = verified.signatures[0];
|
const { verified, keyID } = verificationResult.signatures[0];
|
||||||
if (valid) {
|
try {
|
||||||
console.log('signed by key id ' + verified.signatures[0].keyID.toHex());
|
await verified; // throws on invalid signature
|
||||||
} else {
|
console.log('Signed by key id ' + keyID.toHex());
|
||||||
throw new Error('signature could not be verified');
|
} catch (e) {
|
||||||
|
throw new Error('Signature could not be verified: ' + e.message);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
```
|
```
|
||||||
@ -540,14 +564,14 @@ Using the private key:
|
|||||||
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
const privateKey = await openpgp.decryptKey({
|
||||||
privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
|
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
||||||
passphrase
|
passphrase
|
||||||
});
|
});
|
||||||
|
|
||||||
const cleartextMessage = await openpgp.createCleartextMessage({ text: 'Hello, World!' });
|
const message = await openpgp.createMessage({ text: 'Hello, World!' });
|
||||||
const detachedSignature = await openpgp.sign({
|
const detachedSignature = await openpgp.sign({
|
||||||
message: cleartextMessage, // CleartextMessage or Message object
|
message, // Message object
|
||||||
privateKeys: privateKey, // for signing
|
signingKeys: privateKey,
|
||||||
detached: true
|
detached: true
|
||||||
});
|
});
|
||||||
console.log(detachedSignature);
|
console.log(detachedSignature);
|
||||||
@ -555,16 +579,17 @@ Using the private key:
|
|||||||
const signature = await openpgp.readSignature({
|
const signature = await openpgp.readSignature({
|
||||||
armoredSignature: detachedSignature // parse detached signature
|
armoredSignature: detachedSignature // parse detached signature
|
||||||
});
|
});
|
||||||
const verified = await openpgp.verify({
|
const verificationResult = await openpgp.verify({
|
||||||
message: cleartextMessage, // CleartextMessage or Message object
|
message, // Message object
|
||||||
signature,
|
signature,
|
||||||
publicKeys: publicKey // for verification
|
verificationKeys: publicKey
|
||||||
});
|
});
|
||||||
const { valid } = verified.signatures[0];
|
const { verified, keyID } = verificationResult.signatures[0];
|
||||||
if (valid) {
|
try {
|
||||||
console.log('signed by key id ' + verified.signatures[0].keyID.toHex());
|
await verified; // throws on invalid signature
|
||||||
} else {
|
console.log('Signed by key id ' + keyID.toHex());
|
||||||
throw new Error('signature could not be verified');
|
} catch (e) {
|
||||||
|
throw new Error('Signature could not be verified: ' + e.message);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
```
|
```
|
||||||
@ -589,39 +614,39 @@ Using the private key:
|
|||||||
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
const passphrase = `yourPassphrase`; // what the private key is encrypted with
|
||||||
|
|
||||||
const privateKey = await openpgp.decryptKey({
|
const privateKey = await openpgp.decryptKey({
|
||||||
privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
|
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
|
||||||
passphrase
|
passphrase
|
||||||
});
|
});
|
||||||
|
|
||||||
const message = await openpgp.createMessage({ binary: readableStream }); // or createMessage({ text: ReadableStream<String> })
|
const message = await openpgp.createMessage({ binary: readableStream }); // or createMessage({ text: ReadableStream<String> })
|
||||||
const signatureArmored = await openpgp.sign({
|
const signatureArmored = await openpgp.sign({
|
||||||
message,
|
message,
|
||||||
privateKeys: privateKey // for signing
|
signingKeys: privateKey
|
||||||
});
|
});
|
||||||
console.log(signatureArmored); // ReadableStream containing '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
console.log(signatureArmored); // ReadableStream containing '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
|
||||||
|
|
||||||
const verified = await openpgp.verify({
|
const verificationResult = await openpgp.verify({
|
||||||
message: await openpgp.readMessage({ armoredMessage: signatureArmored }), // parse armored signature
|
message: await openpgp.readMessage({ armoredMessage: signatureArmored }), // parse armored signature
|
||||||
publicKeys: await openpgp.readKey({ armoredKey: publicKeyArmored }) // for verification
|
verificationKeys: await openpgp.readKey({ armoredKey: publicKeyArmored })
|
||||||
});
|
});
|
||||||
|
|
||||||
for await (const chunk of verified.data) {}
|
for await (const chunk of verificationResult.data) {}
|
||||||
// Note: you *have* to read `verified.data` in some way or other,
|
// 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
|
// even if you don't need it, as that is what triggers the
|
||||||
// verification of the data.
|
// verification of the data.
|
||||||
|
|
||||||
const valid = await verified.signatures[0].verified;
|
try {
|
||||||
if (valid) {
|
await verificationResult.signatures[0].verified; // throws on invalid signature
|
||||||
console.log('signed by key id ' + verified.signatures[0].keyID.toHex());
|
console.log('Signed by key id ' + verificationResult.signatures[0].keyID.toHex());
|
||||||
} else {
|
} catch (e) {
|
||||||
throw new Error('signature could not be verified');
|
throw new Error('Signature could not be verified: ' + e.message);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
The full documentation is available at [openpgpjs.org](https://openpgpjs.org/openpgpjs/).
|
The full documentation is available at [openpgpjs.org](https://docs.openpgpjs.org/).
|
||||||
|
|
||||||
### Security Audit
|
### Security Audit
|
||||||
|
|
||||||
@ -639,7 +664,7 @@ 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, you can run `npm start` and open [`http://localhost:8080/test/unittests.html`](http://localhost:8080/test/unittests.html) in a browser, or run the following command:
|
For debugging browser errors, run the following command:
|
||||||
|
|
||||||
npm run browsertest
|
npm run browsertest
|
||||||
|
|
||||||
|
7
SECURITY.md
Normal file
7
SECURITY.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
## 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.
|
File diff suppressed because one or more lines are too long
986
docs/Argon2S2K.html
Normal file
986
docs/Argon2S2K.html
Normal file
File diff suppressed because one or more lines are too long
1
docs/CNAME
Normal file
1
docs/CNAME
Normal file
@ -0,0 +1 @@
|
|||||||
|
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
632
docs/Key.html
632
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
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
600
docs/PaddingPacket.html
Normal file
600
docs/PaddingPacket.html
Normal file
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
2831
docs/global.html
2831
docs/global.html
File diff suppressed because one or more lines are too long
266
docs/index.html
266
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
184
docs/module-crypto.html
Normal file
184
docs/module-crypto.html
Normal file
File diff suppressed because one or more lines are too long
604
docs/module-crypto_aes_kw.html
Normal file
604
docs/module-crypto_aes_kw.html
Normal file
File diff suppressed because one or more lines are too long
400
docs/module-crypto_cipherMode.html
Normal file
400
docs/module-crypto_cipherMode.html
Normal file
File diff suppressed because one or more lines are too long
413
docs/module-crypto_cmac.html
Normal file
413
docs/module-crypto_cmac.html
Normal file
File diff suppressed because one or more lines are too long
2655
docs/module-crypto_crypto.html
Normal file
2655
docs/module-crypto_crypto.html
Normal file
File diff suppressed because one or more lines are too long
525
docs/module-crypto_hash.html
Normal file
525
docs/module-crypto_hash.html
Normal file
File diff suppressed because one or more lines are too long
167
docs/module-crypto_hkdf.html
Normal file
167
docs/module-crypto_hkdf.html
Normal file
File diff suppressed because one or more lines are too long
710
docs/module-crypto_mode_cfb.html
Normal file
710
docs/module-crypto_mode_cfb.html
Normal file
File diff suppressed because one or more lines are too long
748
docs/module-crypto_mode_eax.html
Normal file
748
docs/module-crypto_mode_eax.html
Normal file
File diff suppressed because one or more lines are too long
334
docs/module-crypto_mode_gcm.html
Normal file
334
docs/module-crypto_mode_gcm.html
Normal file
File diff suppressed because one or more lines are too long
747
docs/module-crypto_mode_ocb.html
Normal file
747
docs/module-crypto_mode_ocb.html
Normal file
File diff suppressed because one or more lines are too long
882
docs/module-crypto_pkcs1.html
Normal file
882
docs/module-crypto_pkcs1.html
Normal file
File diff suppressed because one or more lines are too long
167
docs/module-crypto_public_key.html
Normal file
167
docs/module-crypto_public_key.html
Normal file
File diff suppressed because one or more lines are too long
1084
docs/module-crypto_public_key_dsa.html
Normal file
1084
docs/module-crypto_public_key_dsa.html
Normal file
File diff suppressed because one or more lines are too long
981
docs/module-crypto_public_key_elgamal.html
Normal file
981
docs/module-crypto_public_key_elgamal.html
Normal file
File diff suppressed because one or more lines are too long
180
docs/module-crypto_public_key_elliptic.html
Normal file
180
docs/module-crypto_public_key_elliptic.html
Normal file
File diff suppressed because one or more lines are too long
1240
docs/module-crypto_public_key_elliptic_curve.html
Normal file
1240
docs/module-crypto_public_key_elliptic_curve.html
Normal file
File diff suppressed because one or more lines are too long
6517
docs/module-crypto_public_key_elliptic_ecdh.html
Normal file
6517
docs/module-crypto_public_key_elliptic_ecdh.html
Normal file
File diff suppressed because one or more lines are too long
1017
docs/module-crypto_public_key_elliptic_ecdsa.html
Normal file
1017
docs/module-crypto_public_key_elliptic_ecdsa.html
Normal file
File diff suppressed because one or more lines are too long
1106
docs/module-crypto_public_key_elliptic_eddsa.html
Normal file
1106
docs/module-crypto_public_key_elliptic_eddsa.html
Normal file
File diff suppressed because one or more lines are too long
927
docs/module-crypto_public_key_elliptic_eddsa_legacy.html
Normal file
927
docs/module-crypto_public_key_elliptic_eddsa_legacy.html
Normal file
File diff suppressed because one or more lines are too long
2369
docs/module-crypto_public_key_rsa.html
Normal file
2369
docs/module-crypto_public_key_rsa.html
Normal file
File diff suppressed because one or more lines are too long
@ -1,593 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>JSDoc: Class: RandomBuffer</title>
|
|
||||||
|
|
||||||
<script src="scripts/prettify/prettify.js"> </script>
|
|
||||||
<script src="scripts/prettify/lang-css.js"> </script>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
||||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1 class="page-title">Class: RandomBuffer</h1>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section>
|
|
||||||
|
|
||||||
<header>
|
|
||||||
|
|
||||||
<h2><span class="attribs"><span class="type-signature"></span></span>RandomBuffer<span class="signature">()</span><span class="type-signature"></span></h2>
|
|
||||||
|
|
||||||
<div class="class-description"><p>Buffer for secure random numbers</p></div>
|
|
||||||
|
|
||||||
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
<div class="container-overview">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2>Constructor</h2>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="RandomBuffer"><span class="type-signature"></span>new RandomBuffer<span class="signature">()</span><span class="type-signature"></span></h4>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dl class="details">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
|
||||||
<a href="https://github.com/openpgpjs/openpgpjs/blob/v5.0.0-3/src/crypto/random.js">crypto/random.js</a>, <a href="https://github.com/openpgpjs/openpgpjs/blob/v5.0.0-3/src/crypto/random.js#L33">line 33</a>
|
|
||||||
</li></ul></dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3 class="subsection-title">Methods</h3>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="get"><span class="type-signature">(async) </span>get<span class="signature">(buf)</span><span class="type-signature"></span></h4>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="description">
|
|
||||||
<p>Take numbers out of buffer and copy to array</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Parameters:</h5>
|
|
||||||
|
|
||||||
|
|
||||||
<table class="params">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<th>Name</th>
|
|
||||||
|
|
||||||
|
|
||||||
<th>Type</th>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<th class="last">Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<td class="name"><code>buf</code></td>
|
|
||||||
|
|
||||||
|
|
||||||
<td class="type">
|
|
||||||
|
|
||||||
|
|
||||||
<span class="param-type">Uint8Array</span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<td class="description last"><p>The destination array</p></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dl class="details">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
|
||||||
<a href="https://github.com/openpgpjs/openpgpjs/blob/v5.0.0-3/src/crypto/random.js">crypto/random.js</a>, <a href="https://github.com/openpgpjs/openpgpjs/blob/v5.0.0-3/src/crypto/random.js#L73">line 73</a>
|
|
||||||
</li></ul></dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="init"><span class="type-signature"></span>init<span class="signature">(size)</span><span class="type-signature"></span></h4>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="description">
|
|
||||||
<p>Initialize buffer</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Parameters:</h5>
|
|
||||||
|
|
||||||
|
|
||||||
<table class="params">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<th>Name</th>
|
|
||||||
|
|
||||||
|
|
||||||
<th>Type</th>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<th class="last">Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<td class="name"><code>size</code></td>
|
|
||||||
|
|
||||||
|
|
||||||
<td class="type">
|
|
||||||
|
|
||||||
|
|
||||||
<span class="param-type">Integer</span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<td class="description last"><p>size of buffer</p></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dl class="details">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
|
||||||
<a href="https://github.com/openpgpjs/openpgpjs/blob/v5.0.0-3/src/crypto/random.js">crypto/random.js</a>, <a href="https://github.com/openpgpjs/openpgpjs/blob/v5.0.0-3/src/crypto/random.js#L43">line 43</a>
|
|
||||||
</li></ul></dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="set"><span class="type-signature"></span>set<span class="signature">(buf)</span><span class="type-signature"></span></h4>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="description">
|
|
||||||
<p>Concat array of secure random numbers to buffer</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h5>Parameters:</h5>
|
|
||||||
|
|
||||||
|
|
||||||
<table class="params">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<th>Name</th>
|
|
||||||
|
|
||||||
|
|
||||||
<th>Type</th>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<th class="last">Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<td class="name"><code>buf</code></td>
|
|
||||||
|
|
||||||
|
|
||||||
<td class="type">
|
|
||||||
|
|
||||||
|
|
||||||
<span class="param-type">Uint8Array</span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</td>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<td class="description last"></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dl class="details">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dt class="tag-source">Source:</dt>
|
|
||||||
<dd class="tag-source"><ul class="dummy"><li>
|
|
||||||
<a href="https://github.com/openpgpjs/openpgpjs/blob/v5.0.0-3/src/crypto/random.js">crypto/random.js</a>, <a href="https://github.com/openpgpjs/openpgpjs/blob/v5.0.0-3/src/crypto/random.js#L53">line 53</a>
|
|
||||||
</li></ul></dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</article>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<nav>
|
|
||||||
<h2><a href="index.html">Home</a></h2><h3>Functions</h3><ul><li><a href="global.html#armor">armor</a></li><li><a href="global.html#createCleartextMessage">createCleartextMessage</a></li><li><a href="global.html#createKey">createKey</a></li><li><a href="global.html#createMessage">createMessage</a></li><li><a href="global.html#decrypt">decrypt</a></li><li><a href="global.html#decryptKey">decryptKey</a></li><li><a href="global.html#decryptSessionKeys">decryptSessionKeys</a></li><li><a href="global.html#encrypt">encrypt</a></li><li><a href="global.html#encryptKey">encryptKey</a></li><li><a href="global.html#encryptSessionKey">encryptSessionKey</a></li><li><a href="global.html#generateKey">generateKey</a></li><li><a href="global.html#generateSessionKey">generateSessionKey</a></li><li><a href="global.html#newPacketFromTag">newPacketFromTag</a></li><li><a href="global.html#readCleartextMessage">readCleartextMessage</a></li><li><a href="global.html#readKey">readKey</a></li><li><a href="global.html#readKeys">readKeys</a></li><li><a href="global.html#readMessage">readMessage</a></li><li><a href="global.html#readPrivateKey">readPrivateKey</a></li><li><a href="global.html#readPrivateKeys">readPrivateKeys</a></li><li><a href="global.html#readSignature">readSignature</a></li><li><a href="global.html#reformatKey">reformatKey</a></li><li><a href="global.html#revokeKey">revokeKey</a></li><li><a href="global.html#sign">sign</a></li><li><a href="global.html#unarmor">unarmor</a></li><li><a href="global.html#verify">verify</a></li></ul><h3>Modules</h3><ul><li><a href="module-config.html">config</a></li><li><a href="module-enums.html">enums</a></li></ul><h3>Classes</h3><ul><li><a href="AEADEncryptedDataPacket.html">AEADEncryptedDataPacket</a></li><li><a href="CleartextMessage.html">CleartextMessage</a></li><li><a href="CompressedDataPacket.html">CompressedDataPacket</a></li><li><a href="Key.html">Key</a></li><li><a href="LiteralDataPacket.html">LiteralDataPacket</a></li><li><a href="MarkerPacket.html">MarkerPacket</a></li><li><a href="Message.html">Message</a></li><li><a href="module-crypto_random-RandomBuffer.html">RandomBuffer</a></li><li><a href="module-key_SubKey-SubKey.html">SubKey</a></li><li><a href="module-key_User-User.html">User</a></li><li><a href="module-type_kdf_params-KDFParams.html">KDFParams</a></li><li><a href="module-type_keyid-KeyID.html">KeyID</a></li><li><a href="module-type_s2k-S2K.html">S2K</a></li><li><a href="OnePassSignaturePacket.html">OnePassSignaturePacket</a></li><li><a href="PacketList.html">PacketList</a></li><li><a href="PrivateKey.html">PrivateKey</a></li><li><a href="PublicKey.html">PublicKey</a></li><li><a href="PublicKeyEncryptedSessionKeyPacket.html">PublicKeyEncryptedSessionKeyPacket</a></li><li><a href="PublicKeyPacket.html">PublicKeyPacket</a></li><li><a href="PublicSubkeyPacket.html">PublicSubkeyPacket</a></li><li><a href="SecretKeyPacket.html">SecretKeyPacket</a></li><li><a href="SecretSubkeyPacket.html">SecretSubkeyPacket</a></li><li><a href="Signature.html">Signature</a></li><li><a href="SignaturePacket.html">SignaturePacket</a></li><li><a href="SymEncryptedIntegrityProtectedDataPacket.html">SymEncryptedIntegrityProtectedDataPacket</a></li><li><a href="SymEncryptedSessionKeyPacket.html">SymEncryptedSessionKeyPacket</a></li><li><a href="SymmetricallyEncryptedDataPacket.html">SymmetricallyEncryptedDataPacket</a></li><li><a href="TrustPacket.html">TrustPacket</a></li><li><a href="UserAttributePacket.html">UserAttributePacket</a></li><li><a href="UserIDPacket.html">UserIDPacket</a></li></ul>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<br class="clear">
|
|
||||||
|
|
||||||
<footer>
|
|
||||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
<script> prettyPrint(); </script>
|
|
||||||
<script src="scripts/linenumber.js"> </script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
516
docs/module-crypto_random.html
Normal file
516
docs/module-crypto_random.html
Normal file
File diff suppressed because one or more lines are too long
917
docs/module-crypto_signature.html
Normal file
917
docs/module-crypto_signature.html
Normal file
File diff suppressed because one or more lines are too long
769
docs/module-encoding_base64.html
Normal file
769
docs/module-encoding_base64.html
Normal file
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
92
docs/module-key_Subkey.html
Normal file
92
docs/module-key_Subkey.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
92
docs/module-key_User.html
Normal file
92
docs/module-key_User.html
Normal file
File diff suppressed because one or more lines are too long
2891
docs/module-key_helper.html
Normal file
2891
docs/module-key_helper.html
Normal file
File diff suppressed because one or more lines are too long
866
docs/module-packet_packet.html
Normal file
866
docs/module-packet_packet.html
Normal file
File diff suppressed because one or more lines are too long
167
docs/module-type_ecdh_symkey.html
Normal file
167
docs/module-type_ecdh_symkey.html
Normal file
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
92
docs/module-type_keyid.html
Normal file
92
docs/module-type_keyid.html
Normal file
File diff suppressed because one or more lines are too long
178
docs/module-type_oid.html
Normal file
178
docs/module-type_oid.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
180
docs/module-type_s2k.html
Normal file
180
docs/module-type_s2k.html
Normal file
File diff suppressed because one or more lines are too long
169
docs/module-type_x25519x448_symkey.html
Normal file
169
docs/module-type_x25519x448_symkey.html
Normal file
File diff suppressed because one or more lines are too long
167
docs/module-util.html
Normal file
167
docs/module-util.html
Normal file
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "openpgp-lightweight",
|
"name": "openpgp-lightweight",
|
||||||
"main": "../dist/lightweight/openpgp.min.mjs",
|
"browser": "../dist/lightweight/openpgp.min.mjs",
|
||||||
"types": "../openpgp.d.ts"
|
"types": "../openpgp.d.ts"
|
||||||
}
|
}
|
||||||
|
548
openpgp.d.ts
vendored
548
openpgp.d.ts
vendored
@ -1,55 +1,82 @@
|
|||||||
|
/* eslint-disable max-lines, @typescript-eslint/indent */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type definitions for OpenPGP.js http://openpgpjs.org/
|
* Type definitions for OpenPGP.js http://openpgpjs.org/
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* - FlowCrypt a. s. <https://flowcrypt.com>
|
* - FlowCrypt a. s. <https://flowcrypt.com>
|
||||||
* - Guillaume Lacasa <https://blog.lacasa.fr>
|
* - Guillaume Lacasa <https://blog.lacasa.fr>
|
||||||
* - Errietta Kostala <https://github.com/errietta>
|
* - Errietta Kostala <https://github.com/errietta>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ############## v5 KEY #################### */
|
import type { WebStream as GenericWebStream, NodeWebStream as GenericNodeWebStream } from '@openpgp/web-stream-tools';
|
||||||
|
|
||||||
export function readKey(options: { armoredKey: string, config?: PartialConfig }): Promise<PublicKey>;
|
/* ############## STREAM #################### */
|
||||||
export function readKey(options: { binaryKey: Uint8Array, config?: PartialConfig }): Promise<PublicKey>;
|
type Data = Uint8Array | string;
|
||||||
export function readKeys(options: { armoredKeys: string, config?: PartialConfig }): Promise<PublicKey[]>;
|
// web-stream-tools might end up supporting additional data types, so we re-declare the types
|
||||||
export function readKeys(options: { binaryKeys: Uint8Array, config?: PartialConfig }): Promise<PublicKey[]>;
|
// to enforce the type contraint that we need.
|
||||||
|
export type WebStream<T extends Data> = GenericWebStream<T>;
|
||||||
|
export type NodeWebStream<T extends Data> = GenericNodeWebStream<T>;
|
||||||
|
export type Stream<T extends Data> = WebStream<T> | NodeWebStream<T>;
|
||||||
|
export type MaybeStream<T extends Data> = T | Stream<T>;
|
||||||
|
type MaybeArray<T> = T | Array<T>;
|
||||||
|
|
||||||
|
/* ############## KEY #################### */
|
||||||
|
// The Key and PublicKey types can be used interchangably since TS cannot detect the difference, as they have the same class properties.
|
||||||
|
// The declared readKey(s) return type is Key instead of a PublicKey since it seems more obvious that a Key can be cast to a PrivateKey.
|
||||||
|
export function readKey(options: { armoredKey: string, config?: PartialConfig }): Promise<Key>;
|
||||||
|
export function readKey(options: { binaryKey: Uint8Array, config?: PartialConfig }): Promise<Key>;
|
||||||
|
export function readKeys(options: { armoredKeys: string, config?: PartialConfig }): Promise<Key[]>;
|
||||||
|
export function readKeys(options: { binaryKeys: Uint8Array, config?: PartialConfig }): Promise<Key[]>;
|
||||||
export function readPrivateKey(options: { armoredKey: string, config?: PartialConfig }): Promise<PrivateKey>;
|
export function readPrivateKey(options: { armoredKey: string, config?: PartialConfig }): Promise<PrivateKey>;
|
||||||
export function readPrivateKey(options: { binaryKey: Uint8Array, config?: PartialConfig }): Promise<PrivateKey>;
|
export function readPrivateKey(options: { binaryKey: Uint8Array, config?: PartialConfig }): Promise<PrivateKey>;
|
||||||
export function readPrivateKeys(options: { armoredKeys: string, config?: PartialConfig }): Promise<PrivateKey[]>;
|
export function readPrivateKeys(options: { armoredKeys: string, config?: PartialConfig }): Promise<PrivateKey[]>;
|
||||||
export function readPrivateKeys(options: { binaryKeys: Uint8Array, config?: PartialConfig }): Promise<PrivateKey[]>;
|
export function readPrivateKeys(options: { binaryKeys: Uint8Array, config?: PartialConfig }): Promise<PrivateKey[]>;
|
||||||
export function generateKey(options: KeyOptions): Promise<KeyPair>;
|
export function generateKey(options: GenerateKeyOptions & { format?: 'armored' }): Promise<SerializedKeyPair<string> & { revocationCertificate: string }>;
|
||||||
export function generateSessionKey(options: { encryptionKeys: PublicKey[], date?: Date, encryptionUserIDs?: UserID[], config?: PartialConfig }): Promise<SessionKey>;
|
export function generateKey(options: GenerateKeyOptions & { format: 'binary' }): Promise<SerializedKeyPair<Uint8Array> & { revocationCertificate: string }>;
|
||||||
export function decryptKey(options: { privateKey: PrivateKey; passphrase?: string | string[]; config?: PartialConfig }): Promise<PrivateKey>;
|
export function generateKey(options: GenerateKeyOptions & { format: 'object' }): Promise<KeyPair & { revocationCertificate: string }>;
|
||||||
export function encryptKey(options: { privateKey: PrivateKey; passphrase?: string | string[]; config?: PartialConfig }): Promise<PrivateKey>;
|
export function decryptKey(options: { privateKey: PrivateKey; passphrase?: MaybeArray<string>; config?: PartialConfig }): Promise<PrivateKey>;
|
||||||
export function reformatKey(options: { privateKey: PrivateKey; userIDs?: UserID|UserID[]; passphrase?: string; keyExpirationTime?: number; config?: PartialConfig }): Promise<KeyPair>;
|
export function encryptKey(options: { privateKey: PrivateKey; passphrase?: MaybeArray<string>; config?: PartialConfig }): Promise<PrivateKey>;
|
||||||
|
export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format?: 'armored', config?: PartialConfig }): Promise<SerializedKeyPair<string> & { revocationCertificate: string }>;
|
||||||
|
export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array> & { revocationCertificate: string }>;
|
||||||
|
export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format: 'object', config?: PartialConfig }): Promise<KeyPair & { revocationCertificate: string }>;
|
||||||
|
export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format?: 'armored', config?: PartialConfig }): Promise<SerializedKeyPair<string>>;
|
||||||
|
export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array>>;
|
||||||
|
export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format: 'object', config?: PartialConfig }): Promise<KeyPair>;
|
||||||
|
export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format?: 'armored', config?: PartialConfig }): Promise<SerializedKeyPair<string>>;
|
||||||
|
export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array>>;
|
||||||
|
export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format: 'object', config?: PartialConfig }): Promise<KeyPair>;
|
||||||
|
export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format?: 'armored', config?: PartialConfig }): Promise<{ publicKey: string, privateKey: null }>;
|
||||||
|
export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format: 'binary', config?: PartialConfig }): Promise<{ publicKey: Uint8Array, privateKey: null }>;
|
||||||
|
export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format: 'object', config?: PartialConfig }): Promise<{ publicKey: PublicKey, privateKey: null }>;
|
||||||
|
|
||||||
export abstract class Key {
|
export abstract class Key {
|
||||||
private primaryKey: PublicKeyPacket | SecretKeyPacket;
|
public readonly keyPacket: PublicKeyPacket | SecretKeyPacket;
|
||||||
private keyPacket: PublicKeyPacket | SecretKeyPacket;
|
public subkeys: Subkey[]; // do not add/replace users directly
|
||||||
public subKeys: SubKey[];
|
public users: User[]; // do not add/replace subkeys directly
|
||||||
public users: User[];
|
|
||||||
public revocationSignatures: SignaturePacket[];
|
public revocationSignatures: SignaturePacket[];
|
||||||
public write(): Uint8Array;
|
public write(): Uint8Array;
|
||||||
public armor(config?: Config): string;
|
public armor(config?: Config): string;
|
||||||
public getExpirationTime(capability?: 'encrypt' | 'encrypt_sign' | 'sign', keyID?: KeyID, userID?: UserID, config?: Config): Promise<Date | typeof Infinity | null>; // Returns null if `capabilities` is passed and the key does not have the specified capabilities or is revoked or invalid.
|
public getExpirationTime(userID?: UserID, config?: Config): Promise<Date | typeof Infinity | null>;
|
||||||
public getKeyIDs(): KeyID[];
|
public getKeyIDs(): KeyID[];
|
||||||
public getPrimaryUser(date?: Date, userID?: UserID, config?: Config): Promise<PrimaryUser>; // throws on error
|
public getPrimaryUser(date?: Date, userID?: UserID, config?: Config): Promise<PrimaryUser>; // throws on error
|
||||||
public getUserIDs(): string[];
|
public getUserIDs(): string[];
|
||||||
public isPrivate(): boolean;
|
public isPrivate(): this is PrivateKey;
|
||||||
public isPublic(): boolean;
|
|
||||||
public toPublic(): PublicKey;
|
public toPublic(): PublicKey;
|
||||||
public update(sourceKey: PublicKey, config?: Config): Promise<PublicKey>;
|
// NB: the order of the `update` declarations matters, since PublicKey includes PrivateKey
|
||||||
public signPrimaryUser(privateKeys: PrivateKey[], date?: Date, userID?: UserID, config?: Config): Promise<PublicKey>
|
public update(sourceKey: PrivateKey, date?: Date, config?: Config): Promise<PrivateKey>;
|
||||||
public signAllUsers(privateKeys: PrivateKey[], config?: Config): Promise<PublicKey>
|
public update(sourceKey: PublicKey, date?: Date, config?: Config): Promise<PublicKey>;
|
||||||
|
public signPrimaryUser(privateKeys: PrivateKey[], date?: Date, userID?: UserID, config?: Config): Promise<this>;
|
||||||
|
public signAllUsers(privateKeys: PrivateKey[], date?: Date, config?: Config): Promise<this>;
|
||||||
public verifyPrimaryKey(date?: Date, userID?: UserID, config?: Config): Promise<void>; // throws on error
|
public verifyPrimaryKey(date?: Date, userID?: UserID, config?: Config): Promise<void>; // throws on error
|
||||||
public verifyPrimaryUser(publicKeys: PublicKey[], date?: Date, userIDs?: UserID, config?: Config): Promise<{ keyID: KeyID, valid: boolean | null }[]>;
|
public verifyPrimaryUser(publicKeys: PublicKey[], date?: Date, userIDs?: UserID, config?: Config): Promise<{ keyID: KeyID, valid: boolean | null }[]>;
|
||||||
public verifyAllUsers(publicKeys: PublicKey[], config?: Config): Promise<{ userID: string, keyID: KeyID, valid: boolean | null }[]>;
|
public verifyAllUsers(publicKeys?: PublicKey[], date?: Date, config?: Config): Promise<{ userID: string, keyID: KeyID, valid: boolean | null }[]>;
|
||||||
public isRevoked(signature: SignaturePacket, key?: AnyKeyPacket, date?: Date, config?: Config): Promise<boolean>;
|
public isRevoked(signature?: SignaturePacket, key?: AnyKeyPacket, date?: Date, config?: Config): Promise<boolean>;
|
||||||
public getRevocationCertificate(date?: Date, config?: Config): Promise<Stream<string> | string | undefined>;
|
public getRevocationCertificate(date?: Date, config?: Config): Promise<MaybeStream<string> | undefined>;
|
||||||
public getEncryptionKey(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<PublicKey | SubKey>;
|
public getEncryptionKey(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<this | Subkey>;
|
||||||
public getSigningKey(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<PublicKey | SubKey>;
|
public getSigningKey(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<this | Subkey>;
|
||||||
public getKeys(keyID?: KeyID): (PublicKey | SubKey)[];
|
public getKeys(keyID?: KeyID): (this | Subkey)[];
|
||||||
public getSubkeys(keyID?: KeyID): SubKey[];
|
public getSubkeys(keyID?: KeyID): Subkey[];
|
||||||
public getFingerprint(): string;
|
public getFingerprint(): string;
|
||||||
public getCreationTime(): Date;
|
public getCreationTime(): Date;
|
||||||
public getAlgorithmInfo(): AlgorithmInfo;
|
public getAlgorithmInfo(): AlgorithmInfo;
|
||||||
@ -59,30 +86,34 @@ export abstract class Key {
|
|||||||
|
|
||||||
type AllowedKeyPackets = PublicKeyPacket | PublicSubkeyPacket | SecretKeyPacket | SecretSubkeyPacket | UserIDPacket | UserAttributePacket | SignaturePacket;
|
type AllowedKeyPackets = PublicKeyPacket | PublicSubkeyPacket | SecretKeyPacket | SecretSubkeyPacket | UserIDPacket | UserAttributePacket | SignaturePacket;
|
||||||
export class PublicKey extends Key {
|
export class PublicKey extends Key {
|
||||||
constructor(packetlist: PacketList<AnyKeyPacket>);
|
constructor(packetlist: PacketList<AnyPacket>);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PrivateKey extends PublicKey {
|
export class PrivateKey extends PublicKey {
|
||||||
constructor(packetlist: PacketList<AnyKeyPacket>);
|
constructor(packetlist: PacketList<AnyPacket>);
|
||||||
public revoke(reason: { flag?: enums.reasonForRevocation; string?: string; }, date?: Date, config?: Config): Promise<PrivateKey>;
|
public revoke(reason?: ReasonForRevocation, date?: Date, config?: Config): Promise<PrivateKey>;
|
||||||
public isDecrypted(): boolean;
|
public isDecrypted(): boolean;
|
||||||
public addSubkey(options: SubKeyOptions): Promise<PrivateKey>;
|
public addSubkey(options: SubkeyOptions): Promise<PrivateKey>;
|
||||||
public getDecryptionKeys(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<PrivateKey | SubKey>
|
public getDecryptionKeys(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<(PrivateKey | Subkey)[]>;
|
||||||
public update(sourceKey: PublicKey, config?: Config): Promise<PrivateKey>;
|
public update(sourceKey: PublicKey, date?: Date, config?: Config): Promise<PrivateKey>;
|
||||||
public getKeys(keyID?: KeyID): (PrivateKey | SubKey)[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SubKey {
|
export class Subkey {
|
||||||
constructor(subKeyPacket: SecretSubkeyPacket | PublicSubkeyPacket);
|
constructor(subkeyPacket: SecretSubkeyPacket | PublicSubkeyPacket, mainKey: PublicKey);
|
||||||
private keyPacket: SecretSubkeyPacket | PublicSubkeyPacket;
|
public readonly keyPacket: SecretSubkeyPacket | PublicSubkeyPacket;
|
||||||
|
public readonly mainKey: PublicKey;
|
||||||
public bindingSignatures: SignaturePacket[];
|
public bindingSignatures: SignaturePacket[];
|
||||||
public revocationSignatures: SignaturePacket[];
|
public revocationSignatures: SignaturePacket[];
|
||||||
public verify(primaryKey: PublicKeyPacket | SecretKeyPacket, date?: Date, config?: Config): Promise<SignaturePacket>;
|
public verify(date?: Date, config?: Config): Promise<SignaturePacket>;
|
||||||
public isDecrypted(): boolean;
|
public isDecrypted(): boolean;
|
||||||
public getFingerprint(): string;
|
public getFingerprint(): string;
|
||||||
public getCreationTime(): Date;
|
public getCreationTime(): Date;
|
||||||
public getAlgorithmInfo(): AlgorithmInfo;
|
public getAlgorithmInfo(): AlgorithmInfo;
|
||||||
public getKeyID(): KeyID;
|
public getKeyID(): KeyID;
|
||||||
|
public getExpirationTime(date?: Date, config?: Config): Promise<Date | typeof Infinity | null>;
|
||||||
|
public isRevoked(signature: SignaturePacket, key: AnyKeyPacket, date?: Date, config?: Config): Promise<boolean>;
|
||||||
|
public update(subKey: Subkey, date?: Date, config?: Config): Promise<void>;
|
||||||
|
public revoke(primaryKey: SecretKeyPacket, reasonForRevocation?: ReasonForRevocation, date?: Date, config?: Config): Promise<Subkey>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
@ -96,33 +127,35 @@ export interface User {
|
|||||||
export interface PrimaryUser {
|
export interface PrimaryUser {
|
||||||
index: number;
|
index: number;
|
||||||
user: User;
|
user: User;
|
||||||
|
selfCertification: SignaturePacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
type AlgorithmInfo = {
|
export type AlgorithmInfo = {
|
||||||
algorithm: enums.publicKeyNames;
|
algorithm: enums.publicKeyNames;
|
||||||
bits?: number;
|
bits?: number;
|
||||||
curve?: EllipticCurveName;
|
curve?: EllipticCurveName;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ############## v5 SIG #################### */
|
/* ############## SIG #################### */
|
||||||
|
|
||||||
export function readSignature(options: { armoredSignature: string, config?: PartialConfig }): Promise<Signature>;
|
export function readSignature(options: { armoredSignature: string, config?: PartialConfig }): Promise<Signature>;
|
||||||
export function readSignature(options: { binarySignature: Uint8Array, config?: PartialConfig }): Promise<Signature>;
|
export function readSignature(options: { binarySignature: Uint8Array, config?: PartialConfig }): Promise<Signature>;
|
||||||
|
|
||||||
export class Signature {
|
export class Signature {
|
||||||
private packets: PacketList<SignaturePacket>;
|
public readonly packets: PacketList<SignaturePacket>;
|
||||||
constructor(packetlist: PacketList<SignaturePacket>);
|
constructor(packetlist: PacketList<SignaturePacket>);
|
||||||
public write(): MaybeStream<Uint8Array>;
|
public write(): MaybeStream<Uint8Array>;
|
||||||
public armor(config?: Config): string;
|
public armor(config?: Config): string;
|
||||||
|
public getSigningKeyIDs(): Array<KeyID>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VerificationResult {
|
interface VerificationResult {
|
||||||
keyID: KeyID;
|
keyID: KeyID;
|
||||||
verified: Promise<null | boolean>;
|
verified: Promise<true>; // throws on invalid signature
|
||||||
signature: Promise<Signature>;
|
signature: Promise<Signature>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ############## v5 CLEARTEXT #################### */
|
/* ############## CLEARTEXT #################### */
|
||||||
|
|
||||||
export function readCleartextMessage(options: { cleartextMessage: string, config?: PartialConfig }): Promise<CleartextMessage>;
|
export function readCleartextMessage(options: { cleartextMessage: string, config?: PartialConfig }): Promise<CleartextMessage>;
|
||||||
|
|
||||||
@ -147,7 +180,7 @@ export class CleartextMessage {
|
|||||||
*
|
*
|
||||||
* @param privateKeys private keys with decrypted secret key data for signing
|
* @param privateKeys private keys with decrypted secret key data for signing
|
||||||
*/
|
*/
|
||||||
sign(privateKeys: PrivateKey[], signature?: Signature, signingKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], config?: Config): void;
|
sign(privateKeys: PrivateKey[], signature?: Signature, signingKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], notations?: RawNotation[], config?: Config): void;
|
||||||
|
|
||||||
/** Verify signatures of cleartext signed message
|
/** Verify signatures of cleartext signed message
|
||||||
* @param keys array of keys to verify signatures
|
* @param keys array of keys to verify signatures
|
||||||
@ -155,68 +188,75 @@ export class CleartextMessage {
|
|||||||
verify(keys: PublicKey[], date?: Date, config?: Config): Promise<VerificationResult[]>;
|
verify(keys: PublicKey[], date?: Date, config?: Config): Promise<VerificationResult[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ############## v5 MSG #################### */
|
/* ############## MSG #################### */
|
||||||
|
export function generateSessionKey(options: { encryptionKeys: MaybeArray<PublicKey>, date?: Date, encryptionUserIDs?: MaybeArray<UserID>, config?: PartialConfig }): Promise<SessionKey>;
|
||||||
|
export function encryptSessionKey(options: EncryptSessionKeyOptions & { format?: 'armored' }): Promise<string>;
|
||||||
|
export function encryptSessionKey(options: EncryptSessionKeyOptions & { format: 'binary' }): Promise<Uint8Array>;
|
||||||
|
export function encryptSessionKey(options: EncryptSessionKeyOptions & { format: 'object' }): Promise<Message<Data>>;
|
||||||
|
export function decryptSessionKeys<T extends MaybeStream<Data>>(options: { message: Message<T>, decryptionKeys?: MaybeArray<PrivateKey>, passwords?: MaybeArray<string>, date?: Date, config?: PartialConfig }): Promise<DecryptedSessionKey[]>;
|
||||||
|
|
||||||
export function readMessage<T extends MaybeStream<string>>(options: { armoredMessage: T, config?: PartialConfig }): Promise<Message<T>>;
|
export function readMessage<T extends MaybeStream<string>>(options: { armoredMessage: T, config?: PartialConfig }): Promise<Message<T>>;
|
||||||
export function readMessage<T extends MaybeStream<Uint8Array>>(options: { binaryMessage: T, config?: PartialConfig }): Promise<Message<T>>;
|
export function readMessage<T extends MaybeStream<Uint8Array>>(options: { binaryMessage: T, config?: PartialConfig }): Promise<Message<T>>;
|
||||||
|
|
||||||
export function createMessage<T extends MaybeStream<string>>(options: { text: T, filename?: string, date?: Date, type?: DataPacketType }): Promise<Message<T>>;
|
export function createMessage<T extends MaybeStream<string>>(options: { text: T, filename?: string, date?: Date, format?: enums.literalFormatNames }): Promise<Message<T>>;
|
||||||
export function createMessage<T extends MaybeStream<Uint8Array>>(options: { binary: T, filename?: string, date?: Date, type?: DataPacketType }): Promise<Message<T>>;
|
export function createMessage<T extends MaybeStream<Uint8Array>>(options: { binary: T, filename?: string, date?: Date, format?: enums.literalFormatNames }): Promise<Message<T>>;
|
||||||
|
|
||||||
export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, armor: false }): Promise<
|
export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format?: 'armored' }): Promise<
|
||||||
T extends WebStream<infer X> ? WebStream<Uint8Array> :
|
T extends WebStream<Data> ? WebStream<string> :
|
||||||
T extends NodeStream<infer X> ? NodeStream<Uint8Array> :
|
T extends NodeWebStream<Data> ? NodeWebStream<string> :
|
||||||
Uint8Array
|
|
||||||
>;
|
|
||||||
export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T> }): Promise<
|
|
||||||
T extends WebStream<infer X> ? WebStream<string> :
|
|
||||||
T extends NodeStream<infer X> ? NodeStream<string> :
|
|
||||||
string
|
string
|
||||||
>;
|
>;
|
||||||
|
export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'binary' }): Promise<
|
||||||
export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, armor: false }): Promise<
|
T extends WebStream<Data> ? WebStream<Uint8Array> :
|
||||||
T extends WebStream<infer X> ? WebStream<Uint8Array> :
|
T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
|
||||||
T extends NodeStream<infer X> ? NodeStream<Uint8Array> :
|
|
||||||
Uint8Array
|
Uint8Array
|
||||||
>;
|
>;
|
||||||
export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T> }): Promise<
|
export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'object' }): Promise<Message<T>>;
|
||||||
T extends WebStream<infer X> ? WebStream<string> :
|
|
||||||
T extends NodeStream<infer X> ? NodeStream<string> :
|
export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format?: 'armored' }): Promise<
|
||||||
|
T extends WebStream<Data> ? WebStream<string> :
|
||||||
|
T extends NodeWebStream<Data> ? NodeWebStream<string> :
|
||||||
string
|
string
|
||||||
>;
|
>;
|
||||||
export function sign(options: SignOptions & { message: CleartextMessage }): Promise<string>;
|
export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format: 'binary' }): Promise<
|
||||||
|
T extends WebStream<Data> ? WebStream<Uint8Array> :
|
||||||
|
T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
|
||||||
|
Uint8Array
|
||||||
|
>;
|
||||||
|
export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format: 'object' }): Promise<Message<T>>;
|
||||||
|
export function sign(options: SignOptions & { message: CleartextMessage, format?: 'armored' }): Promise<string>;
|
||||||
|
export function sign(options: SignOptions & { message: CleartextMessage, format: 'object' }): Promise<CleartextMessage>;
|
||||||
|
|
||||||
export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T>, format: 'binary' }): Promise<DecryptMessageResult & {
|
export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T>, format: 'binary' }): Promise<DecryptMessageResult & {
|
||||||
data:
|
data:
|
||||||
T extends WebStream<infer X> ? WebStream<Uint8Array> :
|
T extends WebStream<Data> ? WebStream<Uint8Array> :
|
||||||
T extends NodeStream<infer X> ? NodeStream<Uint8Array> :
|
T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
|
||||||
Uint8Array
|
Uint8Array
|
||||||
}>;
|
}>;
|
||||||
export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T> }): Promise<DecryptMessageResult & {
|
export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T> }): Promise<DecryptMessageResult & {
|
||||||
data:
|
data:
|
||||||
T extends WebStream<infer X> ? WebStream<string> :
|
T extends WebStream<Data> ? WebStream<string> :
|
||||||
T extends NodeStream<infer X> ? NodeStream<string> :
|
T extends NodeWebStream<Data> ? NodeWebStream<string> :
|
||||||
string
|
string
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T>, format: 'binary' }): Promise<VerifyMessageResult & {
|
export function verify(options: VerifyOptions & { message: CleartextMessage, format?: 'utf8' }): Promise<VerifyMessageResult<string>>;
|
||||||
data:
|
export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T>, format: 'binary' }): Promise<VerifyMessageResult<
|
||||||
T extends WebStream<infer X> ? WebStream<Uint8Array> :
|
T extends WebStream<Data> ? WebStream<Uint8Array> :
|
||||||
T extends NodeStream<infer X> ? NodeStream<Uint8Array> :
|
T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
|
||||||
Uint8Array
|
Uint8Array
|
||||||
}>;
|
>>;
|
||||||
export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T> }): Promise<VerifyMessageResult & {
|
export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T> }): Promise<VerifyMessageResult<
|
||||||
data:
|
T extends WebStream<Data> ? WebStream<string> :
|
||||||
T extends WebStream<infer X> ? WebStream<string> :
|
T extends NodeWebStream<Data> ? NodeWebStream<string> :
|
||||||
T extends NodeStream<infer X> ? NodeStream<string> :
|
|
||||||
string
|
string
|
||||||
}>;
|
>>;
|
||||||
|
|
||||||
/** Class that represents an OpenPGP message. Can be an encrypted message, signed message, compressed message or literal message
|
/** Class that represents an OpenPGP message. Can be an encrypted message, signed message, compressed message or literal message
|
||||||
*/
|
*/
|
||||||
export class Message<T extends MaybeStream<Data>> {
|
export class Message<T extends MaybeStream<Data>> {
|
||||||
|
|
||||||
private packets: PacketList<AnyPacket>;
|
public readonly packets: PacketList<AnyPacket>;
|
||||||
constructor(packetlist: PacketList<AnyPacket>);
|
constructor(packetlist: PacketList<AnyPacket>);
|
||||||
|
|
||||||
/** Returns binary representation of message
|
/** Returns binary representation of message
|
||||||
@ -230,12 +270,12 @@ export class Message<T extends MaybeStream<Data>> {
|
|||||||
/** Decrypt the message
|
/** Decrypt the message
|
||||||
@param decryptionKeys array of private keys with decrypted secret data
|
@param decryptionKeys array of private keys with decrypted secret data
|
||||||
*/
|
*/
|
||||||
public decrypt(decryptionKeys?: PrivateKey[], passwords?: string[], sessionKeys?: SessionKey[], config?: Config): Promise<Message<MaybeStream<Data>>>;
|
public decrypt(decryptionKeys?: PrivateKey[], passwords?: string[], sessionKeys?: SessionKey[], date?: Date, config?: Config): Promise<Message<MaybeStream<Data>>>;
|
||||||
|
|
||||||
/** Encrypt the message
|
/** Encrypt the message
|
||||||
@param encryptionKeys array of public keys, used to encrypt the message
|
@param encryptionKeys array of public keys, used to encrypt the message
|
||||||
*/
|
*/
|
||||||
public encrypt(encryptionKeys?: PublicKey[], passwords?: string[], sessionKeys?: SessionKey[], wildcard?: boolean, encryptionKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], config?: Config): Promise<Message<MaybeStream<Data>>>;
|
public encrypt(encryptionKeys?: PublicKey[], passwords?: string[], sessionKeys?: SessionKey[], wildcard?: boolean, encryptionKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], config?: Config): Promise<Message<MaybeStream<Data>>>;
|
||||||
|
|
||||||
/** Returns the key IDs of the keys to which the session key is encrypted
|
/** Returns the key IDs of the keys to which the session key is encrypted
|
||||||
*/
|
*/
|
||||||
@ -243,7 +283,7 @@ export class Message<T extends MaybeStream<Data>> {
|
|||||||
|
|
||||||
/** Get literal data that is the body of the message
|
/** Get literal data that is the body of the message
|
||||||
*/
|
*/
|
||||||
public getLiteralData(): Uint8Array | Stream<Uint8Array> | null;
|
public getLiteralData(): (T extends Stream<Data> ? WebStream<Uint8Array> : Uint8Array) | null;
|
||||||
|
|
||||||
/** Returns the key IDs of the keys that signed the message
|
/** Returns the key IDs of the keys that signed the message
|
||||||
*/
|
*/
|
||||||
@ -251,14 +291,14 @@ export class Message<T extends MaybeStream<Data>> {
|
|||||||
|
|
||||||
/** Get literal data as text
|
/** Get literal data as text
|
||||||
*/
|
*/
|
||||||
public getText(): string | Stream<string> | null;
|
public getText(): (T extends Stream<Data> ? WebStream<string> : string) | null;
|
||||||
|
|
||||||
public getFilename(): string | null;
|
public getFilename(): string | null;
|
||||||
|
|
||||||
/** Sign the message (the literal data packet of the message)
|
/** Sign the message (the literal data packet of the message)
|
||||||
@param signingKeys private keys with decrypted secret key data for signing
|
@param signingKeys private keys with decrypted secret key data for signing
|
||||||
*/
|
*/
|
||||||
public sign(signingKeys: PrivateKey[], signature?: Signature, signingKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], config?: Config): Promise<Message<T>>;
|
public sign(signingKeys: PrivateKey[], signature?: Signature, signingKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], notations?: RawNotation[], config?: Config): Promise<Message<T>>;
|
||||||
|
|
||||||
/** Unwrap compressed message
|
/** Unwrap compressed message
|
||||||
*/
|
*/
|
||||||
@ -277,7 +317,7 @@ export class Message<T extends MaybeStream<Data>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ############## v5 CONFIG #################### */
|
/* ############## CONFIG #################### */
|
||||||
|
|
||||||
interface Config {
|
interface Config {
|
||||||
preferredHashAlgorithm: enums.hash;
|
preferredHashAlgorithm: enums.hash;
|
||||||
@ -285,29 +325,44 @@ interface Config {
|
|||||||
preferredCompressionAlgorithm: enums.compression;
|
preferredCompressionAlgorithm: enums.compression;
|
||||||
showVersion: boolean;
|
showVersion: boolean;
|
||||||
showComment: boolean;
|
showComment: boolean;
|
||||||
deflateLevel: number;
|
|
||||||
aeadProtect: boolean;
|
aeadProtect: boolean;
|
||||||
allowUnauthenticatedMessages: boolean;
|
allowUnauthenticatedMessages: boolean;
|
||||||
allowUnauthenticatedStream: boolean;
|
allowUnauthenticatedStream: boolean;
|
||||||
checksumRequired: boolean;
|
|
||||||
minRSABits: number;
|
minRSABits: number;
|
||||||
passwordCollisionCheck: boolean;
|
passwordCollisionCheck: boolean;
|
||||||
revocationsExpire: boolean;
|
ignoreUnsupportedPackets: boolean;
|
||||||
tolerant: boolean;
|
ignoreMalformedPackets: boolean;
|
||||||
versionString: string;
|
versionString: string;
|
||||||
commentString: string;
|
commentString: string;
|
||||||
allowInsecureDecryptionWithSigningKeys: boolean;
|
allowInsecureDecryptionWithSigningKeys: boolean;
|
||||||
v5Keys: boolean;
|
allowInsecureVerificationWithReformattedKeys: boolean;
|
||||||
|
allowMissingKeyFlags: boolean;
|
||||||
|
constantTimePKCS1Decryption: boolean;
|
||||||
|
constantTimePKCS1DecryptionSupportedSymmetricAlgorithms: Set<enums.symmetric>;
|
||||||
|
v6Keys: boolean;
|
||||||
|
enableParsingV5Entities: boolean;
|
||||||
|
preferredAEADAlgorithm: enums.aead;
|
||||||
|
aeadChunkSizeByte: number;
|
||||||
|
s2kType: enums.s2k.iterated | enums.s2k.argon2;
|
||||||
|
s2kIterationCountByte: number;
|
||||||
|
s2kArgon2Params: { passes: number, parallelism: number; memoryExponent: number; };
|
||||||
|
maxUserIDLength: number;
|
||||||
|
knownNotations: string[];
|
||||||
|
useEllipticFallback: boolean;
|
||||||
|
rejectHashAlgorithms: Set<enums.hash>;
|
||||||
|
rejectMessageHashAlgorithms: Set<enums.hash>;
|
||||||
|
rejectPublicKeyAlgorithms: Set<enums.publicKey>;
|
||||||
|
rejectCurves: Set<enums.curve>;
|
||||||
}
|
}
|
||||||
export var config: Config;
|
export const config: Config;
|
||||||
|
|
||||||
// PartialConfig has the same properties as Config, but declared as optional.
|
// PartialConfig has the same properties as Config, but declared as optional.
|
||||||
// This interface is relevant for top-level functions, which accept a subset of configuration options
|
// This interface is relevant for top-level functions, which accept a subset of configuration options
|
||||||
interface PartialConfig extends Partial<Config> {}
|
export interface PartialConfig extends Partial<Config> {}
|
||||||
|
|
||||||
/* ############## v5 PACKET #################### */
|
/* ############## PACKET #################### */
|
||||||
|
|
||||||
declare abstract class BasePacket {
|
export declare abstract class BasePacket {
|
||||||
static readonly tag: enums.packet;
|
static readonly tag: enums.packet;
|
||||||
public read(bytes: Uint8Array): void;
|
public read(bytes: Uint8Array): void;
|
||||||
public write(): Uint8Array;
|
public write(): Uint8Array;
|
||||||
@ -319,7 +374,7 @@ declare abstract class BasePacket {
|
|||||||
* - A Subkey Packet cannot always be used when a Primary Key Packet is expected (and vice versa).
|
* - A Subkey Packet cannot always be used when a Primary Key Packet is expected (and vice versa).
|
||||||
*/
|
*/
|
||||||
declare abstract class BasePublicKeyPacket extends BasePacket {
|
declare abstract class BasePublicKeyPacket extends BasePacket {
|
||||||
public algorithm: enums.publicKeyNames;
|
public algorithm: enums.publicKey;
|
||||||
public created: Date;
|
public created: Date;
|
||||||
public version: number;
|
public version: number;
|
||||||
public getAlgorithmInfo(): AlgorithmInfo;
|
public getAlgorithmInfo(): AlgorithmInfo;
|
||||||
@ -352,6 +407,7 @@ declare abstract class BaseSecretKeyPacket extends BasePublicKeyPacket {
|
|||||||
public decrypt(passphrase: string): Promise<void>; // throws on error
|
public decrypt(passphrase: string): Promise<void>; // throws on error
|
||||||
public validate(): Promise<void>; // throws on error
|
public validate(): Promise<void>; // throws on error
|
||||||
public isDummy(): boolean;
|
public isDummy(): boolean;
|
||||||
|
public isMissingSecretKeyMaterial(): boolean;
|
||||||
public makeDummy(config?: Config): void;
|
public makeDummy(config?: Config): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,9 +433,9 @@ export class SymEncryptedIntegrityProtectedDataPacket extends BasePacket {
|
|||||||
|
|
||||||
export class AEADEncryptedDataPacket extends BasePacket {
|
export class AEADEncryptedDataPacket extends BasePacket {
|
||||||
static readonly tag: enums.packet.aeadEncryptedData;
|
static readonly tag: enums.packet.aeadEncryptedData;
|
||||||
private decrypt(sessionKeyAlgorithm: string, sessionKey: Uint8Array, config?: Config): void;
|
private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
|
||||||
private encrypt(sessionKeyAlgorithm: string, sessionKey: Uint8Array, config?: Config): void;
|
private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
|
||||||
private crypt(fn: Function, sessionKey: Uint8Array, data: MaybeStream<Uint8Array>): MaybeStream<Uint8Array>
|
private crypt(fn: Function, sessionKey: Uint8Array, data: MaybeStream<Uint8Array>): MaybeStream<Uint8Array>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PublicKeyEncryptedSessionKeyPacket extends BasePacket {
|
export class PublicKeyEncryptedSessionKeyPacket extends BasePacket {
|
||||||
@ -388,7 +444,7 @@ export class PublicKeyEncryptedSessionKeyPacket extends BasePacket {
|
|||||||
private encrypt(keyPacket: PublicKeyPacket): void; // throws on error
|
private encrypt(keyPacket: PublicKeyPacket): void; // throws on error
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SymEncryptedSessionKey extends BasePacket {
|
export class SymEncryptedSessionKeyPacket extends BasePacket {
|
||||||
static readonly tag: enums.packet.symEncryptedSessionKey;
|
static readonly tag: enums.packet.symEncryptedSessionKey;
|
||||||
private decrypt(passphrase: string): Promise<void>;
|
private decrypt(passphrase: string): Promise<void>;
|
||||||
private encrypt(passphrase: string, config?: Config): Promise<void>;
|
private encrypt(passphrase: string, config?: Config): Promise<void>;
|
||||||
@ -398,8 +454,8 @@ export class LiteralDataPacket extends BasePacket {
|
|||||||
static readonly tag: enums.packet.literalData;
|
static readonly tag: enums.packet.literalData;
|
||||||
private getText(clone?: boolean): MaybeStream<string>;
|
private getText(clone?: boolean): MaybeStream<string>;
|
||||||
private getBytes(clone?: boolean): MaybeStream<Uint8Array>;
|
private getBytes(clone?: boolean): MaybeStream<Uint8Array>;
|
||||||
private setText(text: MaybeStream<string>, format?: DataPacketType);
|
private setText(text: MaybeStream<string>, format?: enums.literal);
|
||||||
private setBytes(bytes: MaybeStream<Uint8Array>, format?: DataPacketType);
|
private setBytes(bytes: MaybeStream<Uint8Array>, format: enums.literal);
|
||||||
private setFilename(filename: string);
|
private setFilename(filename: string);
|
||||||
private getFilename(): string;
|
private getFilename(): string;
|
||||||
private writeHeader(): Uint8Array;
|
private writeHeader(): Uint8Array;
|
||||||
@ -442,9 +498,10 @@ export class SignaturePacket extends BasePacket {
|
|||||||
public hashAlgorithm: enums.hash | null;
|
public hashAlgorithm: enums.hash | null;
|
||||||
public publicKeyAlgorithm: enums.publicKey | null;
|
public publicKeyAlgorithm: enums.publicKey | null;
|
||||||
public signatureData: null | Uint8Array;
|
public signatureData: null | Uint8Array;
|
||||||
public unhashedSubpackets: null | Uint8Array;
|
public unhashedSubpackets: RawSubpacket[];
|
||||||
|
public unknownSubpackets: RawSubpacket[];
|
||||||
public signedHashValue: null | Uint8Array;
|
public signedHashValue: null | Uint8Array;
|
||||||
public created: Date;
|
public created: Date | null;
|
||||||
public signatureExpirationTime: null | number;
|
public signatureExpirationTime: null | number;
|
||||||
public signatureNeverExpires: boolean;
|
public signatureNeverExpires: boolean;
|
||||||
public exportable: null | boolean;
|
public exportable: null | boolean;
|
||||||
@ -478,24 +535,40 @@ export class SignaturePacket extends BasePacket {
|
|||||||
public issuerKeyVersion: null | number;
|
public issuerKeyVersion: null | number;
|
||||||
public issuerFingerprint: null | Uint8Array;
|
public issuerFingerprint: null | Uint8Array;
|
||||||
public preferredAEADAlgorithms: enums.aead[] | null;
|
public preferredAEADAlgorithms: enums.aead[] | null;
|
||||||
public verified: null | boolean;
|
|
||||||
public revoked: null | boolean;
|
public revoked: null | boolean;
|
||||||
public sign(key: AnySecretKeyPacket, data: Uint8Array, detached?: boolean): Promise<void>;
|
public rawNotations: RawNotation[];
|
||||||
public verify(key: AnyKeyPacket, signatureType: enums.signature, data: Uint8Array, detached?: boolean, config?: Config): Promise<void>; // throws on error
|
public sign(key: AnySecretKeyPacket, data: Uint8Array, date?: Date, detached?: boolean): Promise<void>;
|
||||||
|
public verify(key: AnyKeyPacket, signatureType: enums.signature, data: Uint8Array | object, date?: Date, detached?: boolean, config?: Config): Promise<void>; // throws on error
|
||||||
public isExpired(date?: Date): boolean;
|
public isExpired(date?: Date): boolean;
|
||||||
public getExpirationTime(): Date | typeof Infinity;
|
public getExpirationTime(): Date | typeof Infinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RawSubpacket {
|
||||||
|
type: number;
|
||||||
|
critical: boolean;
|
||||||
|
body: Uint8Array;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RawNotation {
|
||||||
|
name: string;
|
||||||
|
value: Uint8Array;
|
||||||
|
humanReadable: boolean;
|
||||||
|
critical: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export class TrustPacket extends BasePacket {
|
export class TrustPacket extends BasePacket {
|
||||||
static readonly tag: enums.packet.trust;
|
static readonly tag: enums.packet.trust;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AnyPacket = BasePacket;
|
export class UnparseablePacket {
|
||||||
|
tag: enums.packet;
|
||||||
|
write: () => Uint8Array;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AnyPacket = BasePacket | UnparseablePacket;
|
||||||
export type AnySecretKeyPacket = SecretKeyPacket | SecretSubkeyPacket;
|
export type AnySecretKeyPacket = SecretKeyPacket | SecretSubkeyPacket;
|
||||||
export type AnyKeyPacket = BasePublicKeyPacket;
|
export type AnyKeyPacket = BasePublicKeyPacket;
|
||||||
|
|
||||||
type DataPacketType = 'utf8' | 'binary' | 'text' | 'mime';
|
|
||||||
|
|
||||||
type AllowedPackets = Map<enums.packet, object>; // mapping to Packet classes (i.e. typeof LiteralDataPacket etc.)
|
type AllowedPackets = Map<enums.packet, object>; // mapping to Packet classes (i.e. typeof LiteralDataPacket etc.)
|
||||||
export class PacketList<T extends AnyPacket> extends Array<T> {
|
export class PacketList<T extends AnyPacket> extends Array<T> {
|
||||||
static fromBinary(bytes: MaybeStream<Uint8Array>, allowedPackets: AllowedPackets, config?: Config): PacketList<AnyPacket>; // the packet types depend on`allowedPackets`
|
static fromBinary(bytes: MaybeStream<Uint8Array>, allowedPackets: AllowedPackets, config?: Config): PacketList<AnyPacket>; // the packet types depend on`allowedPackets`
|
||||||
@ -506,50 +579,35 @@ export class PacketList<T extends AnyPacket> extends Array<T> {
|
|||||||
public findPacket(tag: enums.packet): T | undefined;
|
public findPacket(tag: enums.packet): T | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ############## v5 STREAM #################### */
|
/* ############## GENERAL #################### */
|
||||||
|
|
||||||
type Data = Uint8Array | string;
|
|
||||||
interface BaseStream<T extends Data> { }
|
|
||||||
interface WebStream<T extends Data> extends BaseStream<T> { // copied+simplified version of ReadableStream from lib.dom.d.ts
|
|
||||||
readonly locked: boolean; getReader: Function; pipeThrough: Function; pipeTo: Function; tee: Function;
|
|
||||||
cancel(reason?: any): Promise<void>;
|
|
||||||
}
|
|
||||||
interface NodeStream<T extends Data> extends BaseStream<T> { // copied+simplified version of ReadableStream from @types/node/index.d.ts
|
|
||||||
readable: boolean; pipe: Function; unpipe: Function; wrap: Function;
|
|
||||||
read(size?: number): string | Uint8Array; setEncoding(encoding: string): this; pause(): this; resume(): this;
|
|
||||||
isPaused(): boolean; unshift(chunk: string | Uint8Array): void;
|
|
||||||
}
|
|
||||||
type Stream<T extends Data> = WebStream<T> | NodeStream<T>;
|
|
||||||
type MaybeStream<T extends Data> = T | Stream<T>;
|
|
||||||
|
|
||||||
export namespace stream {
|
|
||||||
function readToEnd<T extends Data>(input: MaybeStream<T>, concat?: (list: T[]) => T): Promise<T>;
|
|
||||||
// concat
|
|
||||||
// slice
|
|
||||||
// clone
|
|
||||||
// webToNode
|
|
||||||
// nodeToWeb
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ############## v5 GENERAL #################### */
|
|
||||||
|
|
||||||
export interface UserID { name?: string; email?: string; comment?: string; }
|
export interface UserID { name?: string; email?: string; comment?: string; }
|
||||||
export interface SessionKey { data: Uint8Array; algorithm: string; }
|
export interface SessionKey {
|
||||||
|
data: Uint8Array;
|
||||||
|
algorithm: enums.symmetricNames;
|
||||||
|
aeadAlgorithm?: enums.aeadNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DecryptedSessionKey {
|
||||||
|
data: Uint8Array;
|
||||||
|
algorithm: enums.symmetricNames | null; // `null` if the session key is associated with a SEIPDv2 packet
|
||||||
|
}
|
||||||
|
|
||||||
interface EncryptOptions {
|
export interface ReasonForRevocation { flag?: enums.reasonForRevocation, string?: string }
|
||||||
|
|
||||||
|
export interface EncryptOptions {
|
||||||
/** message to be encrypted as created by createMessage */
|
/** message to be encrypted as created by createMessage */
|
||||||
message: Message<MaybeStream<Data>>;
|
message: Message<MaybeStream<Data>>;
|
||||||
/** (optional) array of keys or single key, used to encrypt the message */
|
/** (optional) array of keys or single key, used to encrypt the message */
|
||||||
encryptionKeys?: PublicKey | PublicKey[];
|
encryptionKeys?: MaybeArray<PublicKey>;
|
||||||
/** (optional) private keys for signing. If omitted message will not be signed */
|
/** (optional) private keys for signing. If omitted message will not be signed */
|
||||||
signingKeys?: PrivateKey | PrivateKey[];
|
signingKeys?: MaybeArray<PrivateKey>;
|
||||||
/** (optional) array of passwords or a single password to encrypt the message */
|
/** (optional) array of passwords or a single password to encrypt the message */
|
||||||
passwords?: string | string[];
|
passwords?: MaybeArray<string>;
|
||||||
/** (optional) session key in the form: { data:Uint8Array, algorithm:String } */
|
/** (optional) session key */
|
||||||
sessionKey?: SessionKey;
|
sessionKey?: SessionKey;
|
||||||
/** if the return values should be ascii armored or the message/signature objects */
|
/** if the return values should be ascii armored or the message/signature objects */
|
||||||
armor?: boolean;
|
format?: 'armored' | 'binary' | 'object';
|
||||||
/** (optional) if the signature should be detached (if true, signature will be added to returned object) */
|
/** (optional) if the signature should be detached (if true, signature will be added to returned object) */
|
||||||
signature?: Signature;
|
signature?: Signature;
|
||||||
/** (optional) encrypt as of a certain date */
|
/** (optional) encrypt as of a certain date */
|
||||||
@ -557,27 +615,29 @@ interface EncryptOptions {
|
|||||||
/** (optional) use a key ID of 0 instead of the public key IDs */
|
/** (optional) use a key ID of 0 instead of the public key IDs */
|
||||||
wildcard?: boolean;
|
wildcard?: boolean;
|
||||||
/** (optional) Array of key IDs to use for signing. Each `signingKeyIDs[i]` corresponds to `signingKeys[i]` */
|
/** (optional) Array of key IDs to use for signing. Each `signingKeyIDs[i]` corresponds to `signingKeys[i]` */
|
||||||
signingKeyIDs?: KeyID[];
|
signingKeyIDs?: MaybeArray<KeyID>;
|
||||||
/** (optional) Array of key IDs to use for encryption. Each `encryptionKeyIDs[i]` corresponds to `encryptionKeys[i]`*/
|
/** (optional) Array of key IDs to use for encryption. Each `encryptionKeyIDs[i]` corresponds to `encryptionKeys[i]`*/
|
||||||
encryptionKeyIDs?: KeyID[];
|
encryptionKeyIDs?: MaybeArray<KeyID>;
|
||||||
/** (optional) Array of user IDs to sign with, e.g. { name:'Steve Sender', email:'steve@openpgp.org' } */
|
/** (optional) Array of user IDs to sign with, e.g. { name:'Steve Sender', email:'steve@openpgp.org' } */
|
||||||
signingUserIDs?: UserID[];
|
signingUserIDs?: MaybeArray<UserID>;
|
||||||
/** (optional) array of user IDs to encrypt for, e.g. { name:'Robert Receiver', email:'robert@openpgp.org' } */
|
/** (optional) array of user IDs to encrypt for, e.g. { name:'Robert Receiver', email:'robert@openpgp.org' } */
|
||||||
encryptionUserIDs?: UserID[];
|
encryptionUserIDs?: MaybeArray<UserID>;
|
||||||
|
/** (optional) array of notations to add to the signatures, e.g. { name: 'test@example.org', value: new TextEncoder().encode('test'), humanReadable: true, critical: false } */
|
||||||
|
signatureNotations?: MaybeArray<RawNotation>;
|
||||||
config?: PartialConfig;
|
config?: PartialConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DecryptOptions {
|
export interface DecryptOptions {
|
||||||
/** the message object with the encrypted data */
|
/** the message object with the encrypted data */
|
||||||
message: Message<MaybeStream<Data>>;
|
message: Message<MaybeStream<Data>>;
|
||||||
/** (optional) private keys with decrypted secret key data or session key */
|
/** (optional) private keys with decrypted secret key data or session key */
|
||||||
decryptionKeys?: PrivateKey | PrivateKey[];
|
decryptionKeys?: MaybeArray<PrivateKey>;
|
||||||
/** (optional) passwords to decrypt the message */
|
/** (optional) passwords to decrypt the message */
|
||||||
passwords?: string | string[];
|
passwords?: MaybeArray<string>;
|
||||||
/** (optional) session keys in the form: { data:Uint8Array, algorithm:String } */
|
/** (optional) session keys in the form: { data:Uint8Array, algorithm:String } */
|
||||||
sessionKeys?: SessionKey | SessionKey[];
|
sessionKeys?: MaybeArray<SessionKey>;
|
||||||
/** (optional) array of public keys or single key, to verify signatures */
|
/** (optional) array of public keys or single key, to verify signatures */
|
||||||
verificationKeys?: PublicKey | PublicKey[];
|
verificationKeys?: MaybeArray<PublicKey>;
|
||||||
/** (optional) whether data decryption should fail if the message is not signed with the provided publicKeys */
|
/** (optional) whether data decryption should fail if the message is not signed with the provided publicKeys */
|
||||||
expectSigned?: boolean;
|
expectSigned?: boolean;
|
||||||
/** (optional) whether to return data as a string(Stream) or Uint8Array(Stream). If 'utf8' (the default), also normalize newlines. */
|
/** (optional) whether to return data as a string(Stream) or Uint8Array(Stream). If 'utf8' (the default), also normalize newlines. */
|
||||||
@ -589,23 +649,23 @@ interface DecryptOptions {
|
|||||||
config?: PartialConfig;
|
config?: PartialConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SignOptions {
|
export interface SignOptions {
|
||||||
message: CleartextMessage | Message<MaybeStream<Data>>;
|
message: CleartextMessage | Message<MaybeStream<Data>>;
|
||||||
signingKeys?: PrivateKey | PrivateKey[];
|
signingKeys: MaybeArray<PrivateKey>;
|
||||||
armor?: boolean;
|
format?: 'armored' | 'binary' | 'object';
|
||||||
dataType?: DataPacketType;
|
|
||||||
detached?: boolean;
|
detached?: boolean;
|
||||||
signingKeyIDs?: KeyID[];
|
signingKeyIDs?: MaybeArray<KeyID>;
|
||||||
date?: Date;
|
date?: Date;
|
||||||
signingUserIDs?: UserID[];
|
signingUserIDs?: MaybeArray<UserID>;
|
||||||
|
signatureNotations?: MaybeArray<RawNotation>;
|
||||||
config?: PartialConfig;
|
config?: PartialConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VerifyOptions {
|
export interface VerifyOptions {
|
||||||
/** (cleartext) message object with signatures */
|
/** (cleartext) message object with signatures */
|
||||||
message: CleartextMessage | Message<MaybeStream<Data>>;
|
message: CleartextMessage | Message<MaybeStream<Data>>;
|
||||||
/** array of publicKeys or single key, to verify signatures */
|
/** array of publicKeys or single key, to verify signatures */
|
||||||
verificationKeys: PublicKey | PublicKey[];
|
verificationKeys: MaybeArray<PublicKey>;
|
||||||
/** (optional) whether verification should throw if the message is not signed with the provided publicKeys */
|
/** (optional) whether verification should throw if the message is not signed with the provided publicKeys */
|
||||||
expectSigned?: boolean;
|
expectSigned?: boolean;
|
||||||
/** (optional) whether to return data as a string(Stream) or Uint8Array(Stream). If 'utf8' (the default), also normalize newlines. */
|
/** (optional) whether to return data as a string(Stream) or Uint8Array(Stream). If 'utf8' (the default), also normalize newlines. */
|
||||||
@ -613,56 +673,65 @@ interface VerifyOptions {
|
|||||||
/** (optional) detached signature for verification */
|
/** (optional) detached signature for verification */
|
||||||
signature?: Signature;
|
signature?: Signature;
|
||||||
/** (optional) use the given date for verification instead of the current time */
|
/** (optional) use the given date for verification instead of the current time */
|
||||||
date?: Date;
|
date?: Date | null;
|
||||||
config?: PartialConfig;
|
config?: PartialConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface EncryptSessionKeyOptions extends SessionKey {
|
||||||
|
encryptionKeys?: MaybeArray<PublicKey>,
|
||||||
|
passwords?: MaybeArray<string>,
|
||||||
|
format?: 'armored' | 'binary' | 'object',
|
||||||
|
date?: Date,
|
||||||
|
wildcard?: boolean,
|
||||||
|
encryptionKeyIDs?: MaybeArray<KeyID>,
|
||||||
|
encryptionUserIDs?: MaybeArray<UserID>,
|
||||||
|
config?: PartialConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SerializedKeyPair<T extends string | Uint8Array> {
|
||||||
|
privateKey: T;
|
||||||
|
publicKey: T;
|
||||||
|
}
|
||||||
interface KeyPair {
|
interface KeyPair {
|
||||||
key: PrivateKey;
|
privateKey: PrivateKey;
|
||||||
privateKeyArmored: string;
|
publicKey: PublicKey;
|
||||||
publicKeyArmored: string;
|
|
||||||
revocationCertificate: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EllipticCurveName = 'ed25519' | 'curve25519' | 'p256' | 'p384' | 'p521' | 'secp256k1' | 'brainpoolP256r1' | 'brainpoolP384r1' | 'brainpoolP512r1';
|
export type EllipticCurveName = 'ed25519Legacy' | 'curve25519Legacy' | 'nistP256' | 'nistP384' | 'nistP521' | 'secp256k1' | 'brainpoolP256r1' | 'brainpoolP384r1' | 'brainpoolP512r1';
|
||||||
|
|
||||||
interface KeyOptions {
|
interface GenerateKeyOptions {
|
||||||
userIDs: UserID|UserID[];
|
userIDs: MaybeArray<UserID>;
|
||||||
passphrase?: string;
|
passphrase?: string;
|
||||||
type?: 'ecc' | 'rsa';
|
type?: 'ecc' | 'rsa' | 'curve25519' | 'curve448';
|
||||||
curve?: EllipticCurveName;
|
curve?: EllipticCurveName;
|
||||||
rsaBits?: number;
|
rsaBits?: number;
|
||||||
keyExpirationTime?: number;
|
keyExpirationTime?: number;
|
||||||
date?: Date;
|
date?: Date;
|
||||||
subkeys?: SubKeyOptions[];
|
subkeys?: SubkeyOptions[];
|
||||||
|
format?: 'armored' | 'object' | 'binary';
|
||||||
config?: PartialConfig;
|
config?: PartialConfig;
|
||||||
}
|
}
|
||||||
|
export type KeyOptions = GenerateKeyOptions;
|
||||||
|
|
||||||
interface SubKeyOptions {
|
export interface SubkeyOptions extends Pick<GenerateKeyOptions, 'type' | 'curve' | 'rsaBits' | 'keyExpirationTime' | 'date' | 'config'> {
|
||||||
type?: 'ecc' | 'rsa';
|
|
||||||
curve?: EllipticCurveName;
|
|
||||||
rsaBits?: number;
|
|
||||||
keyExpirationTime?: number;
|
|
||||||
date?: Date;
|
|
||||||
sign?: boolean;
|
sign?: boolean;
|
||||||
config?: PartialConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare class KeyID {
|
export declare class KeyID {
|
||||||
bytes: string;
|
bytes: string;
|
||||||
equals(keyID: KeyID, matchWildcard?: boolean): boolean;
|
equals(keyID: KeyID, matchWildcard?: boolean): boolean;
|
||||||
toHex(): string;
|
toHex(): string;
|
||||||
static fromID(hex: string): KeyID;
|
static fromID(hex: string): KeyID;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DecryptMessageResult {
|
export interface DecryptMessageResult {
|
||||||
data: MaybeStream<Data>;
|
data: MaybeStream<Data>;
|
||||||
signatures: VerificationResult[];
|
signatures: VerificationResult[];
|
||||||
filename: string;
|
filename: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VerifyMessageResult {
|
export interface VerifyMessageResult<T extends MaybeStream<Data> = MaybeStream<Data>> {
|
||||||
data: MaybeStream<Data>;
|
data: T;
|
||||||
signatures: VerificationResult[];
|
signatures: VerificationResult[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,7 +739,7 @@ interface VerifyMessageResult {
|
|||||||
/**
|
/**
|
||||||
* Armor an OpenPGP binary packet block
|
* Armor an OpenPGP binary packet block
|
||||||
*/
|
*/
|
||||||
export function armor(messagetype: enums.armor, body: object, partindex: number, parttotal: number, config?: Config): string;
|
export function armor(messagetype: enums.armor, body: object, partindex?: number, parttotal?: number, customComment?: string, emitChecksum?: boolean, config?: Config): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeArmor an OpenPGP armored message; verify the checksum and return the encoded bytes
|
* DeArmor an OpenPGP armored message; verify the checksum and return the encoded bytes
|
||||||
@ -680,44 +749,44 @@ export function unarmor(input: string, config?: Config): Promise<{ text: string,
|
|||||||
/* ############## v5 ENUMS #################### */
|
/* ############## v5 ENUMS #################### */
|
||||||
|
|
||||||
export namespace enums {
|
export namespace enums {
|
||||||
function read(type: typeof armor, e: armor): armorNames;
|
export function read(type: typeof armor, e: armor): armorNames;
|
||||||
function read(type: typeof compression, e: compression): compressionNames;
|
export function read(type: typeof compression, e: compression): compressionNames;
|
||||||
function read(type: typeof hash, e: hash): hashNames;
|
export function read(type: typeof hash, e: hash): hashNames;
|
||||||
function read(type: typeof packet, e: packet): packetNames;
|
export function read(type: typeof packet, e: packet): packetNames;
|
||||||
function read(type: typeof publicKey, e: publicKey): publicKeyNames;
|
export function read(type: typeof publicKey, e: publicKey): publicKeyNames;
|
||||||
function read(type: typeof symmetric, e: symmetric): symmetricNames;
|
export function read(type: typeof symmetric, e: symmetric): symmetricNames;
|
||||||
function read(type: typeof keyStatus, e: keyStatus): keyStatusNames;
|
export function read(type: typeof keyStatus, e: keyStatus): keyStatusNames;
|
||||||
function read(type: typeof keyFlags, e: keyFlags): keyFlagsNames;
|
export function read(type: typeof keyFlags, e: keyFlags): keyFlagsNames;
|
||||||
|
|
||||||
export type armorNames = 'multipartSection' | 'multipartLast' | 'signed' | 'message' | 'publicKey' | 'privateKey';
|
export type armorNames = 'multipartSection' | 'multipartLast' | 'signed' | 'message' | 'publicKey' | 'privateKey';
|
||||||
enum armor {
|
export enum armor {
|
||||||
multipartSection = 0,
|
multipartSection = 0,
|
||||||
multipartLast = 1,
|
multipartLast = 1,
|
||||||
signed = 2,
|
signed = 2,
|
||||||
message = 3,
|
message = 3,
|
||||||
publicKey = 4,
|
publicKey = 4,
|
||||||
privateKey = 5,
|
privateKey = 5,
|
||||||
signature = 6,
|
signature = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
enum reasonForRevocation {
|
export enum reasonForRevocation {
|
||||||
noReason = 0, // No reason specified (key revocations or cert revocations)
|
noReason = 0, // No reason specified (key revocations or cert revocations)
|
||||||
keySuperseded = 1, // Key is superseded (key revocations)
|
keySuperseded = 1, // Key is superseded (key revocations)
|
||||||
keyCompromised = 2, // Key material has been compromised (key revocations)
|
keyCompromised = 2, // Key material has been compromised (key revocations)
|
||||||
keyRetired = 3, // Key is retired and no longer used (key revocations)
|
keyRetired = 3, // Key is retired and no longer used (key revocations)
|
||||||
userIDInvalid = 32, // User ID information is no longer valid (cert revocations)
|
userIDInvalid = 32 // User ID information is no longer valid (cert revocations)
|
||||||
}
|
}
|
||||||
|
|
||||||
export type compressionNames = 'uncompressed' | 'zip' | 'zlib' | 'bzip2';
|
export type compressionNames = 'uncompressed' | 'zip' | 'zlib' | 'bzip2';
|
||||||
enum compression {
|
export enum compression {
|
||||||
uncompressed = 0,
|
uncompressed = 0,
|
||||||
zip = 1,
|
zip = 1,
|
||||||
zlib = 2,
|
zlib = 2,
|
||||||
bzip2 = 3,
|
bzip2 = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export type hashNames = 'md5' | 'sha1' | 'ripemd' | 'sha256' | 'sha384' | 'sha512' | 'sha224';
|
export type hashNames = 'md5' | 'sha1' | 'ripemd' | 'sha256' | 'sha384' | 'sha512' | 'sha224' | 'sha3_256' | 'sha3_512';
|
||||||
enum hash {
|
export enum hash {
|
||||||
md5 = 1,
|
md5 = 1,
|
||||||
sha1 = 2,
|
sha1 = 2,
|
||||||
ripemd = 3,
|
ripemd = 3,
|
||||||
@ -725,12 +794,14 @@ export namespace enums {
|
|||||||
sha384 = 9,
|
sha384 = 9,
|
||||||
sha512 = 10,
|
sha512 = 10,
|
||||||
sha224 = 11,
|
sha224 = 11,
|
||||||
|
sha3_256 = 12,
|
||||||
|
sha3_512 = 14
|
||||||
}
|
}
|
||||||
|
|
||||||
export type packetNames = 'publicKeyEncryptedSessionKey' | 'signature' | 'symEncryptedSessionKey' | 'onePassSignature' | 'secretKey' | 'publicKey'
|
export type packetNames = 'publicKeyEncryptedSessionKey' | 'signature' | 'symEncryptedSessionKey' | 'onePassSignature' | 'secretKey' | 'publicKey' |
|
||||||
| 'secretSubkey' | 'compressed' | 'symmetricallyEncrypted' | 'marker' | 'literal' | 'trust' | 'userID' | 'publicSubkey' | 'userAttribute'
|
'secretSubkey' | 'compressed' | 'symmetricallyEncrypted' | 'marker' | 'literal' | 'trust' | 'userID' | 'publicSubkey' | 'userAttribute' |
|
||||||
| 'symEncryptedIntegrityProtected' | 'modificationDetectionCode' | 'AEADEncryptedDataPacket';
|
'symEncryptedIntegrityProtected' | 'modificationDetectionCode' | 'AEADEncryptedDataPacket';
|
||||||
enum packet {
|
export enum packet {
|
||||||
publicKeyEncryptedSessionKey = 1,
|
publicKeyEncryptedSessionKey = 1,
|
||||||
signature = 2,
|
signature = 2,
|
||||||
symEncryptedSessionKey = 3,
|
symEncryptedSessionKey = 3,
|
||||||
@ -748,11 +819,11 @@ export namespace enums {
|
|||||||
userAttribute = 17,
|
userAttribute = 17,
|
||||||
symEncryptedIntegrityProtectedData = 18,
|
symEncryptedIntegrityProtectedData = 18,
|
||||||
modificationDetectionCode = 19,
|
modificationDetectionCode = 19,
|
||||||
aeadEncryptedData = 20,
|
aeadEncryptedData = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
export type publicKeyNames = 'rsaEncryptSign' | 'rsaEncrypt' | 'rsaSign' | 'elgamal' | 'dsa' | 'ecdh' | 'ecdsa' | 'eddsa' | 'aedh' | 'aedsa';
|
export type publicKeyNames = 'rsaEncryptSign' | 'rsaEncrypt' | 'rsaSign' | 'elgamal' | 'dsa' | 'ecdh' | 'ecdsa' | 'eddsaLegacy' | 'aedh' | 'aedsa' | 'ed25519' | 'x25519' | 'ed448' | 'x448';
|
||||||
enum publicKey {
|
export enum publicKey {
|
||||||
rsaEncryptSign = 1,
|
rsaEncryptSign = 1,
|
||||||
rsaEncrypt = 2,
|
rsaEncrypt = 2,
|
||||||
rsaSign = 3,
|
rsaSign = 3,
|
||||||
@ -760,14 +831,39 @@ export namespace enums {
|
|||||||
dsa = 17,
|
dsa = 17,
|
||||||
ecdh = 18,
|
ecdh = 18,
|
||||||
ecdsa = 19,
|
ecdsa = 19,
|
||||||
eddsa = 22,
|
eddsaLegacy = 22,
|
||||||
aedh = 23,
|
aedh = 23,
|
||||||
aedsa = 24,
|
aedsa = 24,
|
||||||
|
x25519 = 25,
|
||||||
|
x448 = 26,
|
||||||
|
ed25519 = 27,
|
||||||
|
ed448 = 28
|
||||||
}
|
}
|
||||||
|
|
||||||
export type symmetricNames = 'plaintext' | 'idea' | 'tripledes' | 'cast5' | 'blowfish' | 'aes128' | 'aes192' | 'aes256' | 'twofish';
|
export enum curve {
|
||||||
enum symmetric {
|
/** @deprecated use `nistP256` instead */
|
||||||
plaintext = 0,
|
p256 = 'nistP256',
|
||||||
|
nistP256 = 'nistP256',
|
||||||
|
/** @deprecated use `nistP384` instead */
|
||||||
|
p384 = 'nistP384',
|
||||||
|
nistP384 = 'nistP384',
|
||||||
|
/** @deprecated use `nistP521` instead */
|
||||||
|
p521 = 'nistP521',
|
||||||
|
nistP521 = 'nistP521',
|
||||||
|
/** @deprecated use `ed25519Legacy` instead */
|
||||||
|
ed25519 = 'ed25519Legacy',
|
||||||
|
ed25519Legacy = 'ed25519Legacy',
|
||||||
|
/** @deprecated use `curve25519Legacy` instead */
|
||||||
|
curve25519 = 'curve25519Legacy',
|
||||||
|
curve25519Legacy = 'curve25519Legacy',
|
||||||
|
secp256k1 = 'secp256k1',
|
||||||
|
brainpoolP256r1 = 'brainpoolP256r1',
|
||||||
|
brainpoolP384r1 = 'brainpoolP384r1',
|
||||||
|
brainpoolP512r1 = 'brainpoolP512r1'
|
||||||
|
}
|
||||||
|
|
||||||
|
export type symmetricNames = 'idea' | 'tripledes' | 'cast5' | 'blowfish' | 'aes128' | 'aes192' | 'aes256' | 'twofish';
|
||||||
|
export enum symmetric {
|
||||||
idea = 1,
|
idea = 1,
|
||||||
tripledes = 2,
|
tripledes = 2,
|
||||||
cast5 = 3,
|
cast5 = 3,
|
||||||
@ -775,31 +871,30 @@ export namespace enums {
|
|||||||
aes128 = 7,
|
aes128 = 7,
|
||||||
aes192 = 8,
|
aes192 = 8,
|
||||||
aes256 = 9,
|
aes256 = 9,
|
||||||
twofish = 10,
|
twofish = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
export type keyStatusNames = 'invalid' | 'expired' | 'revoked' | 'valid' | 'noSelfCert';
|
export type keyStatusNames = 'invalid' | 'expired' | 'revoked' | 'valid' | 'noSelfCert';
|
||||||
enum keyStatus {
|
export enum keyStatus {
|
||||||
invalid = 0,
|
invalid = 0,
|
||||||
expired = 1,
|
expired = 1,
|
||||||
revoked = 2,
|
revoked = 2,
|
||||||
valid = 3,
|
valid = 3,
|
||||||
noSelfCert = 4,
|
noSelfCert = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
export type keyFlagsNames = 'certifyKeys' | 'signData' | 'encryptCommunication' | 'encryptStorage' | 'splitPrivateKey' | 'authentication'
|
export type keyFlagsNames = 'certifyKeys' | 'signData' | 'encryptCommunication' | 'encryptStorage' | 'splitPrivateKey' | 'authentication' | 'sharedPrivateKey';
|
||||||
| 'sharedPrivateKey';
|
export enum keyFlags {
|
||||||
enum keyFlags {
|
|
||||||
certifyKeys = 1,
|
certifyKeys = 1,
|
||||||
signData = 2,
|
signData = 2,
|
||||||
encryptCommunication = 4,
|
encryptCommunication = 4,
|
||||||
encryptStorage = 8,
|
encryptStorage = 8,
|
||||||
splitPrivateKey = 16,
|
splitPrivateKey = 16,
|
||||||
authentication = 32,
|
authentication = 32,
|
||||||
sharedPrivateKey = 128,
|
sharedPrivateKey = 128
|
||||||
}
|
}
|
||||||
|
|
||||||
enum signature {
|
export enum signature {
|
||||||
binary = 0,
|
binary = 0,
|
||||||
text = 1,
|
text = 1,
|
||||||
standalone = 2,
|
standalone = 2,
|
||||||
@ -817,9 +912,28 @@ export namespace enums {
|
|||||||
thirdParty = 80
|
thirdParty = 80
|
||||||
}
|
}
|
||||||
|
|
||||||
enum aead {
|
export type aeadNames = 'eax' | 'ocb' | 'gcm';
|
||||||
|
export enum aead {
|
||||||
eax = 1,
|
eax = 1,
|
||||||
ocb = 2,
|
ocb = 2,
|
||||||
|
gcm = 3,
|
||||||
|
/** @deprecated use `gcm` instead */
|
||||||
experimentalGCM = 100 // Private algorithm
|
experimentalGCM = 100 // Private algorithm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type literalFormatNames = 'utf8' | 'binary' | 'text' | 'mime';
|
||||||
|
export enum literal {
|
||||||
|
binary = 98,
|
||||||
|
text = 116,
|
||||||
|
utf8 = 117,
|
||||||
|
mime = 109
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum s2k {
|
||||||
|
simple = 0,
|
||||||
|
salted = 1,
|
||||||
|
iterated = 3,
|
||||||
|
argon2 = 4,
|
||||||
|
gnu = 101
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
16384
package-lock.json
generated
16384
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
130
package.json
130
package.json
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "openpgp",
|
"name": "openpgp",
|
||||||
"description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
|
"description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
|
||||||
"version": "5.0.0-3",
|
"version": "6.1.0",
|
||||||
"license": "LGPL-3.0+",
|
"license": "LGPL-3.0+",
|
||||||
"homepage": "https://openpgpjs.org/",
|
"homepage": "https://openpgpjs.org/",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 8.0.0"
|
"node": ">= 18.0.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"crypto",
|
"crypto",
|
||||||
@ -13,13 +13,26 @@
|
|||||||
"gpg",
|
"gpg",
|
||||||
"openpgp"
|
"openpgp"
|
||||||
],
|
],
|
||||||
"main": "dist/node/openpgp.min.js",
|
"main": "dist/node/openpgp.min.cjs",
|
||||||
"module": "dist/node/openpgp.min.mjs",
|
"module": "dist/node/openpgp.min.mjs",
|
||||||
"browser": {
|
"browser": {
|
||||||
"./dist/node/openpgp.min.js": "./dist/openpgp.min.js",
|
"./dist/node/openpgp.min.cjs": "./dist/openpgp.min.js",
|
||||||
"./dist/node/openpgp.min.mjs": "./dist/openpgp.min.mjs"
|
"./dist/node/openpgp.min.mjs": "./dist/openpgp.min.mjs"
|
||||||
},
|
},
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./openpgp.d.ts",
|
||||||
|
"browser": "./dist/openpgp.min.mjs",
|
||||||
|
"import": "./dist/node/openpgp.mjs",
|
||||||
|
"require": "./dist/node/openpgp.min.cjs"
|
||||||
|
},
|
||||||
|
"./lightweight": {
|
||||||
|
"types": "./openpgp.d.ts",
|
||||||
|
"browser": "./dist/lightweight/openpgp.min.mjs"
|
||||||
|
}
|
||||||
|
},
|
||||||
"types": "openpgp.d.ts",
|
"types": "openpgp.d.ts",
|
||||||
|
"type": "module",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "src"
|
"lib": "src"
|
||||||
},
|
},
|
||||||
@ -28,66 +41,77 @@
|
|||||||
"lightweight/",
|
"lightweight/",
|
||||||
"openpgp.d.ts"
|
"openpgp.d.ts"
|
||||||
],
|
],
|
||||||
"esm": {
|
|
||||||
"cjs": {
|
|
||||||
"dedefault": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup --config",
|
"build": "rollup --config",
|
||||||
"build-test": "npm run build --build-only=test",
|
"build-test": "npm run build --build-only=test",
|
||||||
"prepare": "npm run build",
|
"prepare": "npm run build",
|
||||||
"test": "mocha --require esm --timeout 120000 test/unittests.js",
|
"test": "mocha --timeout 120000 test/unittests.js",
|
||||||
"test-type-definitions": "tsc test/typescript/definitions.ts && node test/typescript/definitions.js",
|
"test-type-definitions": "tsx test/typescript/definitions.ts",
|
||||||
"start": "http-server",
|
"benchmark-time": "node test/benchmarks/time.js",
|
||||||
|
"benchmark-memory-usage": "node test/benchmarks/memory_usage.js",
|
||||||
"prebrowsertest": "npm run build-test",
|
"prebrowsertest": "npm run build-test",
|
||||||
"browsertest": "npm start -- -o test/unittests.html",
|
"browsertest": "web-test-runner --config test/web-test-runner.config.js --group local --manual --open",
|
||||||
"browserstack": "karma start test/karma.conf.js",
|
"test-browser": "web-test-runner --config test/web-test-runner.config.js --group local --playwright --browsers chromium firefox webkit",
|
||||||
"coverage": "nyc npm test",
|
"test-browser:ci": "web-test-runner --config test/web-test-runner.config.js --group headless:ci",
|
||||||
|
"test-browserstack": "web-test-runner --config test/web-test-runner.browserstack.config.js",
|
||||||
|
"coverage": "c8 npm test",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"docs": "jsdoc --configure .jsdocrc.js --destination docs --recurse README.md src",
|
"docs": "jsdoc --configure .jsdocrc.cjs --destination docs --recurse README.md src && printf '%s' 'docs.openpgpjs.org' > docs/CNAME",
|
||||||
"preversion": "rm -rf dist docs node_modules && npm install && npm test",
|
"preversion": "rm -rf dist docs node_modules && npm ci && npm test",
|
||||||
"version": "npm run docs && git add -A docs",
|
"version": "npm run docs && git add -A docs",
|
||||||
"postversion": "git push && git push --tags && npm publish"
|
"postversion": "git push --follow-tags && npm publish"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@openpgp/asmcrypto.js": "^2.3.2",
|
"@noble/ciphers": "^1.2.1",
|
||||||
"@openpgp/elliptic": "^6.5.1",
|
"@noble/curves": "^1.8.1",
|
||||||
"@openpgp/jsdoc": "^3.6.4",
|
"@noble/hashes": "^1.5.0",
|
||||||
"@openpgp/pako": "^1.0.12",
|
"@openpgp/jsdoc": "^3.6.11",
|
||||||
"@openpgp/seek-bzip": "^1.0.5-git",
|
"@openpgp/seek-bzip": "^1.0.5-git",
|
||||||
"@openpgp/tweetnacl": "^1.0.3",
|
"@openpgp/tweetnacl": "^1.0.4-1",
|
||||||
"@openpgp/web-stream-tools": "0.0.5",
|
"@openpgp/web-stream-tools": "~0.1.3",
|
||||||
"@rollup/plugin-commonjs": "^11.1.0",
|
"@rollup/plugin-alias": "^5.1.1",
|
||||||
"@rollup/plugin-node-resolve": "^7.1.3",
|
"@rollup/plugin-commonjs": "^25.0.8",
|
||||||
"@rollup/plugin-replace": "^2.3.2",
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||||
"@types/chai": "^4.2.14",
|
"@rollup/plugin-replace": "^5.0.7",
|
||||||
"babel-eslint": "^10.1.0",
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
"bn.js": "^4.11.8",
|
"@rollup/plugin-typescript": "^11.1.6",
|
||||||
"chai": "^4.1.2",
|
"@rollup/plugin-wasm": "^6.2.2",
|
||||||
"chai-as-promised": "^7.1.1",
|
"@types/chai": "^4.3.19",
|
||||||
"email-addresses": "3.1.0",
|
"@types/sinon": "^17.0.3",
|
||||||
"eslint": "^4.17.0",
|
"@typescript-eslint/parser": "^7.18.0",
|
||||||
"eslint-config-airbnb": "^16.1.0",
|
"@web/test-runner": "^0.19.0",
|
||||||
"eslint-config-airbnb-base": "^12.1.0",
|
"@web/test-runner-browserstack": "^0.7.2",
|
||||||
"eslint-plugin-chai-friendly": "^0.5.0",
|
"@web/test-runner-mocha": "^0.9.0",
|
||||||
"eslint-plugin-import": "^2.8.0",
|
"@web/test-runner-playwright": "^0.11.0",
|
||||||
"esm": "^3.2.25",
|
"argon2id": "^1.0.1",
|
||||||
"hash.js": "^1.1.3",
|
"benchmark": "^2.1.4",
|
||||||
"http-server": "^0.12.3",
|
"bn.js": "^5.2.1",
|
||||||
"karma": "^6.1.0",
|
"c8": "^8.0.1",
|
||||||
"karma-browserstack-launcher": "^1.6.0",
|
"chai": "^4.4.1",
|
||||||
"karma-mocha": "^2.0.1",
|
"chai-as-promised": "^7.1.2",
|
||||||
"karma-mocha-reporter": "^2.2.5",
|
"eckey-utils": "^0.7.14",
|
||||||
"mocha": "^5.0.0",
|
"eslint": "^8.57.1",
|
||||||
"nyc": "^14.1.1",
|
"eslint-config-airbnb": "^19.0.4",
|
||||||
"rollup": "^2.38.5",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"rollup-plugin-terser": "^5.3.0",
|
"eslint-config-airbnb-typescript": "^18.0.0",
|
||||||
"sinon": "^4.3.0",
|
"eslint-import-resolver-typescript": "^3.6.3",
|
||||||
"typescript": "^4.1.2"
|
"eslint-plugin-chai-friendly": "^0.7.4",
|
||||||
|
"eslint-plugin-import": "^2.31.0",
|
||||||
|
"eslint-plugin-unicorn": "^48.0.1",
|
||||||
|
"fflate": "^0.8.2",
|
||||||
|
"mocha": "^10.7.3",
|
||||||
|
"playwright": "^1.51.1",
|
||||||
|
"rollup": "^4.24.2",
|
||||||
|
"sinon": "^18.0.1",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"tslib": "^2.8.0",
|
||||||
|
"tsx": "^4.19.2",
|
||||||
|
"typescript": "^5.6.3",
|
||||||
|
"web-streams-polyfill": "^4.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"overrides": {
|
||||||
"asn1.js": "^5.0.0"
|
"@web/dev-server-core": "npm:@openpgp/wtr-dev-server-core@0.7.3-patch.1",
|
||||||
|
"@web/test-runner-core": "npm:@openpgp/wtr-test-runner-core@0.13.4-patch.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
232
rollup.config.js
232
rollup.config.js
@ -1,22 +1,50 @@
|
|||||||
/* eslint-disable no-process-env */
|
/* eslint-disable no-process-env */
|
||||||
|
|
||||||
import { builtinModules } from 'module';
|
import { builtinModules } from 'module';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
|
import alias from '@rollup/plugin-alias';
|
||||||
import resolve from '@rollup/plugin-node-resolve';
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
import replace from '@rollup/plugin-replace';
|
import replace from '@rollup/plugin-replace';
|
||||||
import { terser } from "rollup-plugin-terser";
|
import terser from '@rollup/plugin-terser';
|
||||||
|
import { wasm } from '@rollup/plugin-wasm';
|
||||||
|
import typescript from '@rollup/plugin-typescript';
|
||||||
|
|
||||||
import pkg from './package.json';
|
// ESlint does not support JSON module imports yet, see https://github.com/eslint/eslint/discussions/15305
|
||||||
|
// import pkg from './package.json' assert { type: 'json' };
|
||||||
|
const pkg = JSON.parse(readFileSync('./package.json'));
|
||||||
|
|
||||||
const nodeDependencies = Object.keys(pkg.dependencies);
|
const nodeDependencies = Object.keys(pkg.dependencies || {});
|
||||||
|
const nodeBuiltinModules = builtinModules.concat(['module']);
|
||||||
|
|
||||||
|
const wasmOptions = {
|
||||||
|
node: { targetEnv: 'node' },
|
||||||
|
browser: { targetEnv: 'browser', maxFileSize: undefined } // always inlline (our wasm files are small)
|
||||||
|
};
|
||||||
|
|
||||||
|
const getChunkFileName = (chunkInfo, extension) => `[name].${extension}`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically imported modules which expose an index file as entrypoint end up with a chunk named `index`
|
||||||
|
* by default. We want to preserve the module name instead.
|
||||||
|
*/
|
||||||
|
const setManualChunkName = chunkId => {
|
||||||
|
if (chunkId.includes('seek-bzip')) {
|
||||||
|
return 'seek-bzip';
|
||||||
|
} else if (chunkId.includes('argon2id')) {
|
||||||
|
return 'argon2id';
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const banner =
|
const banner =
|
||||||
`/*! OpenPGP.js v${pkg.version} - ` +
|
`/*! OpenPGP.js v${pkg.version} - ` +
|
||||||
`${new Date().toISOString().split('T')[0]} - ` +
|
`${new Date().toISOString().split('T')[0]} - ` +
|
||||||
`this is LGPL licensed code, see LICENSE/our website ${pkg.homepage} for more information. */`;
|
`this is LGPL licensed code, see LICENSE/our website ${pkg.homepage} for more information. */`;
|
||||||
|
|
||||||
const intro = `const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};`;
|
const intro = "const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};";
|
||||||
|
|
||||||
const terserOptions = {
|
const terserOptions = {
|
||||||
ecma: 2017,
|
ecma: 2017,
|
||||||
@ -29,90 +57,120 @@ const terserOptions = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const nodeBuild = {
|
||||||
|
input: 'src/index.js',
|
||||||
|
external: nodeBuiltinModules.concat(nodeDependencies),
|
||||||
|
output: [
|
||||||
|
{ file: 'dist/node/openpgp.cjs', format: 'cjs', name: pkg.name, banner, intro },
|
||||||
|
{ file: 'dist/node/openpgp.min.cjs', format: 'cjs', name: pkg.name, banner, intro, plugins: [terser(terserOptions)], sourcemap: true },
|
||||||
|
{ file: 'dist/node/openpgp.mjs', format: 'es', banner, intro },
|
||||||
|
{ file: 'dist/node/openpgp.min.mjs', format: 'es', banner, intro, plugins: [terser(terserOptions)], sourcemap: true }
|
||||||
|
].map(options => ({ ...options, inlineDynamicImports: true })),
|
||||||
|
plugins: [
|
||||||
|
resolve({
|
||||||
|
exportConditions: ['node'] // needed for resolution of noble-curves import of '@noble/crypto' in Node 18
|
||||||
|
}),
|
||||||
|
typescript({
|
||||||
|
compilerOptions: { outDir: './dist/tmp-ts' }
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
replace({
|
||||||
|
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`
|
||||||
|
}),
|
||||||
|
wasm(wasmOptions.node)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const fullBrowserBuild = {
|
||||||
|
input: 'src/index.js',
|
||||||
|
external: nodeBuiltinModules.concat(nodeDependencies),
|
||||||
|
output: [
|
||||||
|
{ file: 'dist/openpgp.js', format: 'iife', name: pkg.name, banner, intro },
|
||||||
|
{ file: 'dist/openpgp.min.js', format: 'iife', name: pkg.name, banner, intro, plugins: [terser(terserOptions)], sourcemap: true },
|
||||||
|
{ file: 'dist/openpgp.mjs', format: 'es', banner, intro },
|
||||||
|
{ file: 'dist/openpgp.min.mjs', format: 'es', banner, intro, plugins: [terser(terserOptions)], sourcemap: true }
|
||||||
|
].map(options => ({ ...options, inlineDynamicImports: true })),
|
||||||
|
plugins: [
|
||||||
|
resolve({
|
||||||
|
browser: true
|
||||||
|
}),
|
||||||
|
typescript({
|
||||||
|
compilerOptions: { outDir: './dist/tmp-ts' } // to avoid js files being overwritten
|
||||||
|
}),
|
||||||
|
commonjs({
|
||||||
|
ignore: nodeBuiltinModules.concat(nodeDependencies)
|
||||||
|
}),
|
||||||
|
replace({
|
||||||
|
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
|
||||||
|
"import { createRequire } from 'module';": 'const createRequire = () => () => {}',
|
||||||
|
delimiters: ['', '']
|
||||||
|
}),
|
||||||
|
wasm(wasmOptions.browser)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const lightweightBrowserBuild = {
|
||||||
|
input: 'src/index.js',
|
||||||
|
external: nodeBuiltinModules.concat(nodeDependencies),
|
||||||
|
output: [
|
||||||
|
{ entryFileNames: 'openpgp.mjs', chunkFileNames: chunkInfo => getChunkFileName(chunkInfo, 'mjs') },
|
||||||
|
{ entryFileNames: 'openpgp.min.mjs', chunkFileNames: chunkInfo => getChunkFileName(chunkInfo, 'min.mjs'), plugins: [terser(terserOptions)], sourcemap: true }
|
||||||
|
].map(options => ({ ...options, dir: 'dist/lightweight', manualChunks: setManualChunkName, format: 'es', banner, intro })),
|
||||||
|
preserveEntrySignatures: 'exports-only',
|
||||||
|
plugins: [
|
||||||
|
resolve({
|
||||||
|
browser: true
|
||||||
|
}),
|
||||||
|
typescript({
|
||||||
|
compilerOptions: { outDir: './dist/lightweight/tmp-ts' }
|
||||||
|
}),
|
||||||
|
commonjs({
|
||||||
|
ignore: nodeBuiltinModules.concat(nodeDependencies)
|
||||||
|
}),
|
||||||
|
replace({
|
||||||
|
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
|
||||||
|
"import { createRequire } from 'module';": 'const createRequire = () => () => {}',
|
||||||
|
delimiters: ['', '']
|
||||||
|
}),
|
||||||
|
wasm(wasmOptions.browser)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const testBuild = {
|
||||||
|
input: 'test/unittests.js',
|
||||||
|
output: [
|
||||||
|
{ file: 'test/lib/unittests-bundle.js', format: 'es', intro, sourcemap: true, inlineDynamicImports: true }
|
||||||
|
],
|
||||||
|
external: nodeBuiltinModules.concat(nodeDependencies),
|
||||||
|
plugins: [
|
||||||
|
alias({
|
||||||
|
entries: {
|
||||||
|
openpgp: `./dist/${process.env.npm_config_lightweight ? 'lightweight/' : ''}openpgp.mjs`
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
resolve({
|
||||||
|
browser: true
|
||||||
|
}),
|
||||||
|
typescript({
|
||||||
|
compilerOptions: { outDir: './test/lib/tmp-ts' }
|
||||||
|
}),
|
||||||
|
commonjs({
|
||||||
|
ignore: nodeBuiltinModules.concat(nodeDependencies),
|
||||||
|
requireReturnsDefault: 'preferred'
|
||||||
|
}),
|
||||||
|
replace({
|
||||||
|
"import { createRequire } from 'module';": 'const createRequire = () => () => {}',
|
||||||
|
delimiters: ['', '']
|
||||||
|
}),
|
||||||
|
wasm(wasmOptions.browser)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
export default Object.assign([
|
export default Object.assign([
|
||||||
{
|
nodeBuild,
|
||||||
input: 'src/index.js',
|
fullBrowserBuild,
|
||||||
output: [
|
lightweightBrowserBuild,
|
||||||
{ file: 'dist/openpgp.js', format: 'iife', name: pkg.name, banner, intro },
|
testBuild
|
||||||
{ file: 'dist/openpgp.min.js', format: 'iife', name: pkg.name, banner, intro, plugins: [terser(terserOptions)], sourcemap: true },
|
|
||||||
{ file: 'dist/openpgp.mjs', format: 'es', banner, intro },
|
|
||||||
{ file: 'dist/openpgp.min.mjs', format: 'es', banner, intro, plugins: [terser(terserOptions)], sourcemap: true }
|
|
||||||
],
|
|
||||||
inlineDynamicImports: true,
|
|
||||||
plugins: [
|
|
||||||
resolve({
|
|
||||||
browser: true
|
|
||||||
}),
|
|
||||||
commonjs({
|
|
||||||
ignore: builtinModules.concat(nodeDependencies)
|
|
||||||
}),
|
|
||||||
replace({
|
|
||||||
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
|
|
||||||
'require(': 'void(',
|
|
||||||
delimiters: ['', '']
|
|
||||||
})
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: 'src/index.js',
|
|
||||||
inlineDynamicImports: true,
|
|
||||||
external: builtinModules.concat(nodeDependencies),
|
|
||||||
output: [
|
|
||||||
{ file: 'dist/node/openpgp.js', format: 'cjs', name: pkg.name, banner, intro },
|
|
||||||
{ file: 'dist/node/openpgp.min.js', format: 'cjs', name: pkg.name, banner, intro, plugins: [terser(terserOptions)], sourcemap: true },
|
|
||||||
{ file: 'dist/node/openpgp.mjs', format: 'es', banner, intro },
|
|
||||||
{ file: 'dist/node/openpgp.min.mjs', format: 'es', banner, intro, plugins: [terser(terserOptions)], sourcemap: true }
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
resolve(),
|
|
||||||
commonjs(),
|
|
||||||
replace({
|
|
||||||
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`
|
|
||||||
})
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: 'src/index.js',
|
|
||||||
output: [
|
|
||||||
{ dir: 'dist/lightweight', entryFileNames: 'openpgp.mjs', chunkFileNames: '[name].mjs', format: 'es', banner, intro },
|
|
||||||
{ dir: 'dist/lightweight', entryFileNames: 'openpgp.min.mjs', chunkFileNames: '[name].min.mjs', format: 'es', banner, intro, plugins: [terser(terserOptions)], sourcemap: true }
|
|
||||||
],
|
|
||||||
preserveEntrySignatures: 'allow-extension',
|
|
||||||
plugins: [
|
|
||||||
resolve({
|
|
||||||
browser: true
|
|
||||||
}),
|
|
||||||
commonjs({
|
|
||||||
ignore: builtinModules.concat(nodeDependencies)
|
|
||||||
}),
|
|
||||||
replace({
|
|
||||||
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
|
|
||||||
'require(': 'void(',
|
|
||||||
delimiters: ['', '']
|
|
||||||
})
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: 'test/unittests.js',
|
|
||||||
output: [
|
|
||||||
{ file: 'test/lib/unittests-bundle.js', format: 'es', intro, sourcemap: true }
|
|
||||||
],
|
|
||||||
inlineDynamicImports: true,
|
|
||||||
external: ['../..', '../../..'],
|
|
||||||
plugins: [
|
|
||||||
resolve({
|
|
||||||
browser: true
|
|
||||||
}),
|
|
||||||
commonjs({
|
|
||||||
ignore: builtinModules.concat(nodeDependencies)
|
|
||||||
}),
|
|
||||||
replace({
|
|
||||||
"import openpgpjs from '../../..';": `import * as openpgpjs from '/dist/${process.env.npm_config_lightweight ? 'lightweight/' : ''}openpgp.mjs'; window.openpgp = openpgpjs;`,
|
|
||||||
'require(': 'void(',
|
|
||||||
delimiters: ['', '']
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}
|
|
||||||
].filter(config => {
|
].filter(config => {
|
||||||
config.output = config.output.filter(output => {
|
config.output = config.output.filter(output => {
|
||||||
return (output.file || output.dir + '/' + output.entryFileNames).includes(
|
return (output.file || output.dir + '/' + output.entryFileNames).includes(
|
||||||
|
@ -1,334 +0,0 @@
|
|||||||
import BN from 'bn.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview
|
|
||||||
* BigInteger implementation of basic operations
|
|
||||||
* Wrapper of bn.js library (wwww.github.com/indutny/bn.js)
|
|
||||||
* @module biginteger/bn
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
export default class BigInteger {
|
|
||||||
/**
|
|
||||||
* Get a BigInteger (input must be big endian for strings and arrays)
|
|
||||||
* @param {Number|String|Uint8Array} n - Value to convert
|
|
||||||
* @throws {Error} on undefined input
|
|
||||||
*/
|
|
||||||
constructor(n) {
|
|
||||||
if (n === undefined) {
|
|
||||||
throw new Error('Invalid BigInteger input');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.value = new BN(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
clone() {
|
|
||||||
const clone = new BigInteger(null);
|
|
||||||
this.value.copy(clone.value);
|
|
||||||
return clone;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger increment in place
|
|
||||||
*/
|
|
||||||
iinc() {
|
|
||||||
this.value.iadd(new BN(1));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger increment
|
|
||||||
* @returns {BigInteger} this + 1.
|
|
||||||
*/
|
|
||||||
inc() {
|
|
||||||
return this.clone().iinc();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger decrement in place
|
|
||||||
*/
|
|
||||||
idec() {
|
|
||||||
this.value.isub(new BN(1));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger decrement
|
|
||||||
* @returns {BigInteger} this - 1.
|
|
||||||
*/
|
|
||||||
dec() {
|
|
||||||
return this.clone().idec();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger addition in place
|
|
||||||
* @param {BigInteger} x - Value to add
|
|
||||||
*/
|
|
||||||
iadd(x) {
|
|
||||||
this.value.iadd(x.value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger addition
|
|
||||||
* @param {BigInteger} x - Value to add
|
|
||||||
* @returns {BigInteger} this + x.
|
|
||||||
*/
|
|
||||||
add(x) {
|
|
||||||
return this.clone().iadd(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger subtraction in place
|
|
||||||
* @param {BigInteger} x - Value to subtract
|
|
||||||
*/
|
|
||||||
isub(x) {
|
|
||||||
this.value.isub(x.value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger subtraction
|
|
||||||
* @param {BigInteger} x - Value to subtract
|
|
||||||
* @returns {BigInteger} this - x.
|
|
||||||
*/
|
|
||||||
sub(x) {
|
|
||||||
return this.clone().isub(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger multiplication in place
|
|
||||||
* @param {BigInteger} x - Value to multiply
|
|
||||||
*/
|
|
||||||
imul(x) {
|
|
||||||
this.value.imul(x.value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigInteger multiplication
|
|
||||||
* @param {BigInteger} x - Value to multiply
|
|
||||||
* @returns {BigInteger} this * x.
|
|
||||||
*/
|
|
||||||
mul(x) {
|
|
||||||
return this.clone().imul(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute value modulo m, in place
|
|
||||||
* @param {BigInteger} m - Modulo
|
|
||||||
*/
|
|
||||||
imod(m) {
|
|
||||||
this.value = this.value.umod(m.value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute value modulo m
|
|
||||||
* @param {BigInteger} m - Modulo
|
|
||||||
* @returns {BigInteger} this mod m.
|
|
||||||
*/
|
|
||||||
mod(m) {
|
|
||||||
return this.clone().imod(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute modular exponentiation
|
|
||||||
* Much faster than this.exp(e).mod(n)
|
|
||||||
* @param {BigInteger} e - Exponent
|
|
||||||
* @param {BigInteger} n - Modulo
|
|
||||||
* @returns {BigInteger} this ** e mod n.
|
|
||||||
*/
|
|
||||||
modExp(e, n) {
|
|
||||||
// We use either Montgomery or normal reduction context
|
|
||||||
// Montgomery requires coprime n and R (montogmery multiplier)
|
|
||||||
// bn.js picks R as power of 2, so n must be odd
|
|
||||||
const nred = n.isEven() ? BN.red(n.value) : BN.mont(n.value);
|
|
||||||
const x = this.clone();
|
|
||||||
x.value = x.value.toRed(nred).redPow(e.value).fromRed();
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the inverse of this value modulo n
|
|
||||||
* Note: this and and n must be relatively prime
|
|
||||||
* @param {BigInteger} n - Modulo
|
|
||||||
* @returns {BigInteger} x such that this*x = 1 mod n
|
|
||||||
* @throws {Error} if the inverse does not exist
|
|
||||||
*/
|
|
||||||
modInv(n) {
|
|
||||||
// invm returns a wrong result if the inverse does not exist
|
|
||||||
if (!this.gcd(n).isOne()) {
|
|
||||||
throw new Error('Inverse does not exist');
|
|
||||||
}
|
|
||||||
return new BigInteger(this.value.invm(n.value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute greatest common divisor between this and n
|
|
||||||
* @param {BigInteger} n - Operand
|
|
||||||
* @returns {BigInteger} gcd
|
|
||||||
*/
|
|
||||||
gcd(n) {
|
|
||||||
return new BigInteger(this.value.gcd(n.value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shift this to the left by x, in place
|
|
||||||
* @param {BigInteger} x - Shift value
|
|
||||||
*/
|
|
||||||
ileftShift(x) {
|
|
||||||
this.value.ishln(x.value.toNumber());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shift this to the left by x
|
|
||||||
* @param {BigInteger} x - Shift value
|
|
||||||
* @returns {BigInteger} this << x.
|
|
||||||
*/
|
|
||||||
leftShift(x) {
|
|
||||||
return this.clone().ileftShift(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shift this to the right by x, in place
|
|
||||||
* @param {BigInteger} x - Shift value
|
|
||||||
*/
|
|
||||||
irightShift(x) {
|
|
||||||
this.value.ishrn(x.value.toNumber());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shift this to the right by x
|
|
||||||
* @param {BigInteger} x - Shift value
|
|
||||||
* @returns {BigInteger} this >> x.
|
|
||||||
*/
|
|
||||||
rightShift(x) {
|
|
||||||
return this.clone().irightShift(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this value is equal to x
|
|
||||||
* @param {BigInteger} x
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
equal(x) {
|
|
||||||
return this.value.eq(x.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this value is less than x
|
|
||||||
* @param {BigInteger} x
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
lt(x) {
|
|
||||||
return this.value.lt(x.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this value is less than or equal to x
|
|
||||||
* @param {BigInteger} x
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
lte(x) {
|
|
||||||
return this.value.lte(x.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this value is greater than x
|
|
||||||
* @param {BigInteger} x
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
gt(x) {
|
|
||||||
return this.value.gt(x.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this value is greater than or equal to x
|
|
||||||
* @param {BigInteger} x
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
gte(x) {
|
|
||||||
return this.value.gte(x.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
isZero() {
|
|
||||||
return this.value.isZero();
|
|
||||||
}
|
|
||||||
|
|
||||||
isOne() {
|
|
||||||
return this.value.eq(new BN(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
isNegative() {
|
|
||||||
return this.value.isNeg();
|
|
||||||
}
|
|
||||||
|
|
||||||
isEven() {
|
|
||||||
return this.value.isEven();
|
|
||||||
}
|
|
||||||
|
|
||||||
abs() {
|
|
||||||
const res = this.clone();
|
|
||||||
res.value = res.value.abs();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get this value as a string
|
|
||||||
* @returns {String} this value.
|
|
||||||
*/
|
|
||||||
toString() {
|
|
||||||
return this.value.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get this value as an exact Number (max 53 bits)
|
|
||||||
* Fails if this value is too large
|
|
||||||
* @returns {Number}
|
|
||||||
*/
|
|
||||||
toNumber() {
|
|
||||||
return this.value.toNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get value of i-th bit
|
|
||||||
* @param {Number} i - Bit index
|
|
||||||
* @returns {Number} Bit value.
|
|
||||||
*/
|
|
||||||
getBit(i) {
|
|
||||||
return this.value.testn(i) ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute bit length
|
|
||||||
* @returns {Number} Bit length.
|
|
||||||
*/
|
|
||||||
bitLength() {
|
|
||||||
return this.value.bitLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute byte length
|
|
||||||
* @returns {Number} Byte length.
|
|
||||||
*/
|
|
||||||
byteLength() {
|
|
||||||
return this.value.byteLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Uint8Array representation of this number
|
|
||||||
* @param {String} endian - Endianess of output array (defaults to 'be')
|
|
||||||
* @param {Number} length - Of output array
|
|
||||||
* @returns {Uint8Array}
|
|
||||||
*/
|
|
||||||
toUint8Array(endian = 'be', length) {
|
|
||||||
return this.value.toArrayLike(Uint8Array, endian, length);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
import util from '../util';
|
|
||||||
import BigInteger from './native.interface';
|
|
||||||
|
|
||||||
async function getBigInteger() {
|
|
||||||
if (util.detectBigInt()) {
|
|
||||||
return BigInteger;
|
|
||||||
} else {
|
|
||||||
const { default: BigInteger } = await import('./bn.interface');
|
|
||||||
return BigInteger;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/prefer-default-export
|
|
||||||
export { getBigInteger };
|
|
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