Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2651 Update to openpgp v6 #2653

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 20 additions & 70 deletions Core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "0.0.1",
"description": "TypeScript core for FlowCrypt iOS internal use",
"dependencies": {
"@openpgp/web-stream-tools": "0.0.11",
"@openpgp/web-stream-tools": "^0.1.3",
"encoding-japanese": "^2.2.0",
"openpgp": "5.11.2",
"openpgp": "^6.0.1",
"sanitize-html": "^2.8.0",
"zxcvbn": "4.4.2"
},
Expand Down
6 changes: 3 additions & 3 deletions Core/source/core/pgp-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
UserID,
} from 'openpgp';
import { isFullyDecrypted, isFullyEncrypted } from './pgp';
import { MaybeStream, requireStreamReadToEnd } from '../platform/require';
import { requireStreamReadToEnd } from '../platform/require';
import { Str } from './common';

export interface PrvKeyInfo {
Expand Down Expand Up @@ -95,7 +95,7 @@ export class PgpKey {
userIDs: userIds,
passphrase,
format: 'armored',
curve: variant === 'curve25519' ? 'curve25519' : undefined,
curve: variant === 'curve25519' ? 'curve25519Legacy' : undefined,
rsaBits: variant === 'curve25519' ? undefined : variant === 'rsa2048' ? 2048 : 4096,
});
return { public: k.publicKey, private: k.privateKey, revCert: k.revocationCertificate };
Expand Down Expand Up @@ -442,7 +442,7 @@ export class PgpKey {
const readToEnd = await requireStreamReadToEnd();
return {
key,
revocationCertificate: await readToEnd(certificate as MaybeStream<string>),
revocationCertificate: await readToEnd(certificate as unknown as string),
};
}
};
Expand Down
3 changes: 2 additions & 1 deletion Core/source/platform/require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ type ReadToEndFn = <T extends Uint8Array | string>(input: MaybeStream<T>, concat
/* eslint-disable */
export const requireStreamReadToEnd = async (): Promise<ReadToEndFn> => {
const runtime = globalThis.process?.release?.name || 'not node';
const path = '../lib/streams/streams.js';
return runtime === 'not node'
? (await import('@openpgp/web-stream-tools')).readToEnd
? (await import(path)).readToEnd
: require('../../bundles/raw/web-stream-tools').readToEnd;
};

Expand Down
8 changes: 6 additions & 2 deletions Core/source/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ test('generateKey', async t => {
expect(isFullyEncrypted(key)).to.be.true;
expect(isFullyDecrypted(key)).to.be.false;
/* eslint-enable @typescript-eslint/no-unused-expressions */
expect((json.key as { algo: string }).algo).to.deep.equal({ algorithm: 'eddsa', curve: 'ed25519', algorithmId: 22 });
expect((json.key as { algo: string }).algo).to.deep.equal({
algorithm: 'eddsaLegacy',
curve: 'ed25519Legacy',
algorithmId: 22,
});
expectNoData(data);
t.pass();
});
Expand Down Expand Up @@ -662,7 +666,7 @@ test.serial('parseKeys - revoked', async t => {
keywords: 'GALLERY PROTECT TIME CANDY BLEAK ACCESS',
},
],
algo: { algorithm: 'eddsa', curve: 'ed25519', algorithmId: 22 },
algo: { algorithm: 'eddsaLegacy', curve: 'ed25519Legacy', algorithmId: 22 },
created: 1634664782,
lastModified: 1634664811,
revoked: true,
Expand Down
3 changes: 3 additions & 0 deletions Core/tooling/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ mkdir -p ./build/final
# build our source with typescript
./node_modules/.bin/tsc --project tsconfig.json

mkdir -p ./build/ts/lib/streams
cp node_modules/@openpgp/web-stream-tools/lib/*.js ./build/ts/lib/streams

# build raw/ with webpack
./node_modules/.bin/webpack --config webpack.bare.config.js

Expand Down
21 changes: 21 additions & 0 deletions FlowCrypt.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@
958A45A32B10E77F00FFBA56 /* SwiftSoup in Frameworks */ = {isa = PBXBuildFile; productRef = 958A45A22B10E77F00FFBA56 /* SwiftSoup */; };
95E014CF2A8BF27C00D4B4F5 /* AvatarCheckboxNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E014CE2A8BF27C00D4B4F5 /* AvatarCheckboxNode.swift */; };
95F55F9F2A7B8A720000E50F /* ProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = 95F55F9E2A7B8A720000E50F /* ProgressHUD */; };
97C4F3AC2D5354230022AEE6 /* Telegraph in Frameworks */ = {isa = PBXBuildFile; productRef = 97C4F3AB2D5354230022AEE6 /* Telegraph */; };
97C4F3AE2D5354350022AEE6 /* WebServerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97C4F3AD2D5354340022AEE6 /* WebServerManager.swift */; };
9F003D6125E1B4ED00EB38C0 /* TrashFolderProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F003D6025E1B4ED00EB38C0 /* TrashFolderProvider.swift */; };
9F003D6D25EA8F3200EB38C0 /* SessionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F003D6C25EA8F3200EB38C0 /* SessionManager.swift */; };
9F0C3C102316DD5B00299985 /* GoogleAuthManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F0C3C0F2316DD5B00299985 /* GoogleAuthManager.swift */; };
Expand Down Expand Up @@ -666,6 +668,7 @@
9582BC592A782DA700439728 /* pass_phrase_hint.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = pass_phrase_hint.html; sourceTree = "<group>"; };
958566B82A612822001C84D3 /* ASButtonNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ASButtonNode.swift; sourceTree = "<group>"; };
95E014CE2A8BF27C00D4B4F5 /* AvatarCheckboxNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarCheckboxNode.swift; sourceTree = "<group>"; };
97C4F3AD2D5354340022AEE6 /* WebServerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebServerManager.swift; sourceTree = "<group>"; };
9F003D6025E1B4ED00EB38C0 /* TrashFolderProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrashFolderProvider.swift; sourceTree = "<group>"; };
9F003D6C25EA8F3200EB38C0 /* SessionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionManager.swift; sourceTree = "<group>"; };
9F003D9D25EA910B00EB38C0 /* LocalStorageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalStorageTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -926,6 +929,7 @@
51E1675F270F36A400D27C52 /* RealmSwift in Frameworks */,
512C1414271077F8002DE13F /* GoogleAPIClientForREST_PeopleService in Frameworks */,
51E16749270F303100D27C52 /* GoogleSignIn in Frameworks */,
97C4F3AC2D5354230022AEE6 /* Telegraph in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1137,6 +1141,7 @@
32DCA376D595968F13A3347A /* Core */ = {
isa = PBXGroup;
children = (
97C4F3AD2D5354340022AEE6 /* WebServerManager.swift */,
D212D36224C1AC1900035991 /* Models */,
32DCAC732B988D9704658812 /* CoreTypes.swift */,
32DCA0C3D34A69851A238E87 /* Core.swift */,
Expand Down Expand Up @@ -2412,6 +2417,7 @@
51C0C1EE271982A1000C9738 /* MailCore */,
040FDF0D27EDA70700CB936A /* GoogleAPIClientForREST_Oauth2 */,
51A1A12729070CDF007F1188 /* AsyncDisplayKit */,
97C4F3AB2D5354230022AEE6 /* Telegraph */,
);
productName = FlowCrypt;
productReference = C132B9B01EC2DBD800763715 /* FlowCrypt.app */;
Expand Down Expand Up @@ -2532,6 +2538,7 @@
952687412A8A21060005694B /* XCRemoteSwiftPackageReference "LetterAvatarKit" */,
958A45A12B10E76E00FFBA56 /* XCRemoteSwiftPackageReference "SwiftSoup" */,
513E8BC22BF20FCA00340F1B /* XCRemoteSwiftPackageReference "GTMAppAuth" */,
97C4F3AA2D5354170022AEE6 /* XCRemoteSwiftPackageReference "Telegraph" */,
);
productRefGroup = C132B9B11EC2DBD800763715 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -2813,6 +2820,7 @@
9F41FA28253B75F4003B970D /* BackupSelectKeyViewController.swift in Sources */,
2133D51826A1E45400CC686F /* DecryptedPrivateKey.swift in Sources */,
D2F6D1402435008500DB4065 /* SessionCredentialsProvider.swift in Sources */,
97C4F3AE2D5354350022AEE6 /* WebServerManager.swift in Sources */,
9F9ABC8723AC1EAA00D560E3 /* MessageContext.swift in Sources */,
9F883916272709E200669B56 /* MessagesThreadApiClient.swift in Sources */,
9F0C3C102316DD5B00299985 /* GoogleAuthManager.swift in Sources */,
Expand Down Expand Up @@ -3990,6 +3998,14 @@
minimumVersion = 14.1.1;
};
};
97C4F3AA2D5354170022AEE6 /* XCRemoteSwiftPackageReference "Telegraph" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Building42/Telegraph.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.40.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -4053,6 +4069,11 @@
package = 95F55F982A7B89260000E50F /* XCRemoteSwiftPackageReference "ProgressHUD" */;
productName = ProgressHUD;
};
97C4F3AB2D5354230022AEE6 /* Telegraph */ = {
isa = XCSwiftPackageProductDependency;
package = 97C4F3AA2D5354170022AEE6 /* XCRemoteSwiftPackageReference "Telegraph" */;
productName = Telegraph;
};
9FBD69F9277B1E6C002FC602 /* Toast */ = {
isa = XCSwiftPackageProductDependency;
package = 51C0C1F0271987DB000C9738 /* XCRemoteSwiftPackageReference "Toast-Swift" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "05430bf1fc71f707204c86e319466dfc225d7e8224d4328e53f7059acda7dbd3",
"originHash" : "c75a4799d1bfbbb39b1f636aa6616ddb5a8ada3db3974414b893cdd655dd5204",
"pins" : [
{
"identity" : "app-check",
Expand All @@ -19,6 +19,15 @@
"version" : "1.7.5"
}
},
{
"identity" : "cocoaasyncsocket",
"kind" : "remoteSourceControl",
"location" : "https://github.com/robbiehanson/CocoaAsyncSocket.git",
"state" : {
"revision" : "dbdc00669c1ced63b27c3c5f052ee4d28f10150c",
"version" : "7.6.5"
}
},
{
"identity" : "collectionconcurrencykit",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -82,6 +91,15 @@
"version" : "4.1.1"
}
},
{
"identity" : "httpparserc",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Building42/HTTPParserC.git",
"state" : {
"revision" : "a32b391977a17c30fceec0f38933a359dfdaf112",
"version" : "9.2.0"
}
},
{
"identity" : "letteravatarkit",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -199,6 +217,15 @@
"version" : "7.0.2"
}
},
{
"identity" : "telegraph",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Building42/Telegraph.git",
"state" : {
"revision" : "f56b6726195e271fea397b7dd11c4adc36d5a32d",
"version" : "0.40.0"
}
},
{
"identity" : "texture",
"kind" : "remoteSourceControl",
Expand Down
Loading