From 899f6cc8df94cf450de8d1e3702d6bde6d4d1fa5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Sep 2021 08:23:15 +0000 Subject: [PATCH 1/3] build(deps): bump openpgp from 4.10.10 to 5.0.0 in /website Bumps [openpgp](https://github.com/openpgpjs/openpgpjs) from 4.10.10 to 5.0.0. - [Release notes](https://github.com/openpgpjs/openpgpjs/releases) - [Commits](https://github.com/openpgpjs/openpgpjs/compare/v4.10.10...v5.0.0) --- updated-dependencies: - dependency-name: openpgp dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- website/package.json | 2 +- website/yarn.lock | 33 +++++---------------------------- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/website/package.json b/website/package.json index 3dedc50d5..71c81cb25 100644 --- a/website/package.json +++ b/website/package.json @@ -13,7 +13,7 @@ "i18next": "^20.6.1", "i18next-browser-languagedetector": "^6.1.2", "i18next-http-backend": "^1.3.1", - "openpgp": "^4.10.10", + "openpgp": "^5.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-dropzone": "^11.3.4", diff --git a/website/yarn.lock b/website/yarn.lock index 940403fb9..c8ceda125 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -9172,7 +9172,7 @@ no-case@^3.0.3: lower-case "^2.0.1" tslib "^1.10.0" -node-fetch@2.6.1, node-fetch@^2.1.2: +node-fetch@2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== @@ -9216,13 +9216,6 @@ node-libs-browser@^2.2.1: util "^0.11.0" vm-browserify "^1.0.1" -node-localstorage@~1.3.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/node-localstorage/-/node-localstorage-1.3.1.tgz#3177ef42837f398aee5dd75e319b281e40704243" - integrity sha512-NMWCSWWc6JbHT5PyWlNT2i8r7PgGYXVntmKawY83k/M0UJScZ5jirb61TLnqKwd815DfBQu+lR3sRw08SPzIaQ== - dependencies: - write-file-atomic "^1.1.4" - node-modules-regexp@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40" @@ -9479,14 +9472,12 @@ open@^7.0.2: is-docker "^2.0.0" is-wsl "^2.1.1" -openpgp@^4.10.10: - version "4.10.10" - resolved "https://registry.yarnpkg.com/openpgp/-/openpgp-4.10.10.tgz#65b58d24466c278120c7f2d1ebc88ef9b15d6361" - integrity sha512-Ub48OogGPjNsr0G/wnJ/SyAQzt/tfcXZTWVZdjKFpXCQV1Ca+upFdSPPkBlGG3lb9EQGOKZJ2tzYNH6ZyKMkDQ== +openpgp@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/openpgp/-/openpgp-5.0.0.tgz#2da0ee406c8834223ae928a9a214f4811f83f923" + integrity sha512-H4Jsj9Bp1KFQ/w520M1d2x45iz9V39Lf+IwIXmUaBmJAMagAt0zanqmWeFzIMJUYmrHTcm6fO/rpc6aftFUHbA== dependencies: asn1.js "^5.0.0" - node-fetch "^2.1.2" - node-localstorage "~1.3.0" opn@^5.5.0: version "5.5.0" @@ -11913,11 +11904,6 @@ slice-ansi@^4.0.0: astral-regex "^2.0.0" is-fullwidth-code-point "^3.0.0" -slide@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" - integrity sha1-VusCfWW00tzmyy4tMsTUr8nh1wc= - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -13609,15 +13595,6 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -write-file-atomic@^1.1.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f" - integrity sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8= - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - slide "^1.1.5" - write-file-atomic@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.3.tgz#56bd5c5a5c70481cd19c571bd39ab965a5de56e8" From ba8764694b7100ee59077ad008cb1678e6991e81 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 16 Sep 2021 11:24:50 +0200 Subject: [PATCH 2/3] Upgrade to openpgp 5 Signed-off-by: Johan Haals --- website/src/createSecret/Upload.tsx | 14 +++++++------- website/src/displaySecret/DisplaySecret.tsx | 2 +- website/src/utils/utils.tsx | 20 ++++++++++++-------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/website/src/createSecret/Upload.tsx b/website/src/createSecret/Upload.tsx index c9531f564..3f9257e18 100644 --- a/website/src/createSecret/Upload.tsx +++ b/website/src/createSecret/Upload.tsx @@ -1,6 +1,6 @@ import { faFileUpload } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { encrypt, message } from 'openpgp'; +import { encrypt, createMessage } from 'openpgp'; import { useCallback, useState } from 'react'; import { useDropzone } from 'react-dropzone'; import { @@ -46,16 +46,16 @@ const Upload = () => { handleSubmit(onSubmit)(); const pw = form.password ? form.password : randomString(); const file = await encrypt({ - armor: true, - message: message.fromBinary( - new Uint8Array(reader.result as ArrayBuffer), - acceptedFiles[0].name, - ), + format: 'armored', + message: await createMessage({ + binary: new Uint8Array(reader.result as ArrayBuffer), + filename: acceptedFiles[0].name, + }), passwords: pw, }); const { data, status } = await uploadFile({ expiration: parseInt(form.expiration), - message: file.data, + message: file, one_time: form.onetime, }); diff --git a/website/src/displaySecret/DisplaySecret.tsx b/website/src/displaySecret/DisplaySecret.tsx index f8ad75615..c447b0cb0 100644 --- a/website/src/displaySecret/DisplaySecret.tsx +++ b/website/src/displaySecret/DisplaySecret.tsx @@ -67,7 +67,7 @@ const DisplaySecret = () => { if (isFile) { setFileName(r.filename); } - setSecret(r.data); + setSecret(r.data.toString()); } catch (e) { setInvalidPassword(true); return false; diff --git a/website/src/utils/utils.tsx b/website/src/utils/utils.tsx index d660df23c..aa86b959a 100644 --- a/website/src/utils/utils.tsx +++ b/website/src/utils/utils.tsx @@ -1,4 +1,10 @@ -import { message, encrypt, decrypt, DecryptResult } from 'openpgp'; +import { + encrypt, + decrypt, + readMessage, + createMessage, + DecryptMessageResult, +} from 'openpgp'; type Response = { // TODO: this shouldn't be any @@ -52,24 +58,22 @@ export const decryptMessage = async ( data: string, passwords: string, format: 'utf8' | 'binary', -): Promise => { - const r = await decrypt({ - message: await message.readArmored(data), +): Promise => { + return decrypt({ + message: await readMessage({ armoredMessage: data }), passwords, format, }); - return r; }; export const encryptMessage = async ( data: string, passwords: string, ): Promise => { - const r = await encrypt({ - message: message.fromText(data), + return encrypt({ + message: await createMessage({ text: data }), passwords, }); - return r.data as string; }; export default randomString; From daebda11fa4f970e7e54d09c16c34974d4b9ae9b Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Thu, 16 Sep 2021 14:20:37 +0200 Subject: [PATCH 3/3] Fix binary decryption Signed-off-by: Johan Haals --- website/src/createSecret/Upload.tsx | 4 ++-- website/src/displaySecret/DisplaySecret.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/website/src/createSecret/Upload.tsx b/website/src/createSecret/Upload.tsx index 3f9257e18..956f178d5 100644 --- a/website/src/createSecret/Upload.tsx +++ b/website/src/createSecret/Upload.tsx @@ -45,7 +45,7 @@ const Upload = () => { reader.onload = async () => { handleSubmit(onSubmit)(); const pw = form.password ? form.password : randomString(); - const file = await encrypt({ + const message = await encrypt({ format: 'armored', message: await createMessage({ binary: new Uint8Array(reader.result as ArrayBuffer), @@ -55,7 +55,7 @@ const Upload = () => { }); const { data, status } = await uploadFile({ expiration: parseInt(form.expiration), - message: file, + message, one_time: form.onetime, }); diff --git a/website/src/displaySecret/DisplaySecret.tsx b/website/src/displaySecret/DisplaySecret.tsx index c447b0cb0..9e7c1e1da 100644 --- a/website/src/displaySecret/DisplaySecret.tsx +++ b/website/src/displaySecret/DisplaySecret.tsx @@ -67,7 +67,7 @@ const DisplaySecret = () => { if (isFile) { setFileName(r.filename); } - setSecret(r.data.toString()); + setSecret(r.data as string); } catch (e) { setInvalidPassword(true); return false;