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

Feat/add argon2 and kyber #1291

Open
wants to merge 9 commits into
base: PB-2666-implement-pqc-on-drive
Choose a base branch
from
Open
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
19 changes: 9 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.format": true
},
"svg.preview.background": "editor"
}

"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.format": "explicit"
},
"svg.preview.background": "editor"
Comment on lines +2 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be added to the gitignore, as it is part of the vs code configuration.

}
5 changes: 0 additions & 5 deletions jest.config.js

This file was deleted.

15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"version": "v1.0.320",
"private": true,
"dependencies": {
"@dashlane/pqc-kem-kyber512-browser": "^1.0.0",
"@headlessui/react": "1.7.5",
"@iconscout/react-unicons": "^1.1.6",
"@internxt/inxt-js": "=1.2.21",
"@internxt/lib": "^1.2.0",
"@internxt/sdk": "^1.5.15",
"@internxt/sdk": "1.5.17",
"@phosphor-icons/react": "^2.1.7",
"@popperjs/core": "^2.11.6",
"@reduxjs/toolkit": "^1.6.0",
Expand All @@ -17,6 +18,7 @@
"@stripe/stripe-js": "^3.5.0",
"@typeform/embed-react": "^1.19.0",
"@types/uuid": "^8.3.4",
"argon2": "^0.41.1",
"asmcrypto.js": "git+https://github.com/asmcrypto/asmcrypto.js.git",
"assert": "^2.1.0",
"axios": "^0.21.1",
Expand All @@ -43,6 +45,7 @@
"lodash": "^4.17.21",
"openpgp": "^5.9.0",
"os-browserify": "^0.3.0",
"patch-package": "^8.0.0",
"path-browserify": "^1.0.1",
"prettysize": "^2.0.0",
"query-string": "^6.13.8",
Expand Down Expand Up @@ -80,25 +83,27 @@
"url": "^0.11.3",
"util": "^0.12.5",
"uuid": "^8.3.2",
"vitest": "^2.1.1",
"web-vitals": "^0.2.4",
"xlsx-preview": "^1.0.4"
},
"scripts": {
"postinstall": "patch-package",
"preinstall": "node scripts/use-yarn.js",
"prepare": "husky install",
"dev": "craco start",
"start": "craco start",
"build": "craco build",
"vercel:install": "yarn run add:npmrc && yarn install",
"test:unit": "jest src/ && jest test/unit",
"test:unit": "vitest run test/unit && vitest run src/ ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting change, with Vitest the problems with global meta variable has gone?

"test:e2e": "node ./cypress-transform-dotenv.js && cypress run --project test/e2e",
"cypress:open": "node ./cypress-transform-dotenv.js && cypress open --project test/e2e",
"test:playwright": "yarn playwright test",
"test:chromium": "yarn playwright test --project=chromium",
"test:firefox": "yarn playwright test --project=firefox",
"test:safari": "yarn playwright test --project=webkit",
"test:edge": "yarn playwright test --project=edge",
"test": "npm run test:unit && npm run test:e2e",
"test": "vitest run",
"eject": "react-scripts eject",
"format": "prettier \"{src,test}/**/*.{ts,tsx}\" --write",
"lint:ts": "eslint \"./{src,test}/**/*.{ts,tsx}\"",
Expand Down Expand Up @@ -129,14 +134,12 @@
"@internxt/prettier-config": "^1.0.1",
"@playwright/test": "^1.44.1",
"@testing-library/dom": "^7.26.0",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/analytics-node": "^3.1.3",
"@types/async": "^3.2.7",
"@types/file-saver": "^2.0.3",
"@types/filesystem": "^0.0.32",
"@types/jest": "^29.5.5",
"@types/lodash": "^4.14.172",
"@types/node": "^12.0.0",
"@types/openpgp": "^4.4.18",
Expand All @@ -148,6 +151,7 @@
"@types/segment-analytics": "^0.0.34",
"@types/streamsaver": "^2.0.1",
"@types/wicg-file-system-access": "^2020.9.4",
"@vitest/browser": "^2.1.1",
"autoprefixer": "^10.4.16",
"buffer": "^6.0.3",
"cross-env": "^7.0.3",
Expand All @@ -171,7 +175,6 @@
"stylelint-config-standard": "^20.0.0",
"stylelint-scss": "^3.17.2",
"tailwindcss": "^3.3.4",
"ts-jest": "27.1.5",
"typescript": "^4.4.2",
"webpack-bundle-analyzer": "^4.9.1"
},
Expand Down
108 changes: 108 additions & 0 deletions patches/@internxt+sdk+1.5.17.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
diff --git a/node_modules/@internxt/sdk/.DS_Store b/node_modules/@internxt/sdk/.DS_Store
new file mode 100644
index 0000000..945abaa
Binary files /dev/null and b/node_modules/@internxt/sdk/.DS_Store differ
diff --git a/node_modules/@internxt/sdk/dist/auth/index.js b/node_modules/@internxt/sdk/dist/auth/index.js
index 0389bcd..aa76d63 100644
--- a/node_modules/@internxt/sdk/dist/auth/index.js
+++ b/node_modules/@internxt/sdk/dist/auth/index.js
@@ -75,6 +75,8 @@ var Auth = /** @class */ (function () {
salt: registerDetails.salt,
privateKey: registerDetails.keys.privateKeyEncrypted,
publicKey: registerDetails.keys.publicKey,
+ privateKyberKey: registerDetails.keys.privateKyberKeyEncrypted,
+ publicKyberKey: registerDetails.keys.publicKyberKey,
revocationKey: registerDetails.keys.revocationCertificate,
referral: registerDetails.referral,
referrer: registerDetails.referrer,
@@ -96,6 +98,8 @@ var Auth = /** @class */ (function () {
salt: registerDetails.salt,
privateKey: registerDetails.keys.privateKeyEncrypted,
publicKey: registerDetails.keys.publicKey,
+ privateKyberKey: registerDetails.keys.privateKyberKeyEncrypted,
+ publicKyberKey: registerDetails.keys.publicKyberKey,
revocationKey: registerDetails.keys.revocationCertificate,
referral: registerDetails.referral,
referrer: registerDetails.referrer,
@@ -136,9 +140,11 @@ var Auth = /** @class */ (function () {
case 1:
securityDetails = _a.sent();
encryptedSalt = securityDetails.encryptedSalt;
- encryptedPasswordHash = cryptoProvider.encryptPasswordHash(details.password, encryptedSalt);
- return [4 /*yield*/, cryptoProvider.generateKeys(details.password)];
+ return [4 /*yield*/, cryptoProvider.encryptPasswordHash(details.password, encryptedSalt)];
case 2:
+ encryptedPasswordHash = _a.sent();
+ return [4 /*yield*/, cryptoProvider.generateKeys(details.password)];
+ case 3:
keys = _a.sent();
return [2 /*return*/, this.client
.post('/access', {
@@ -148,6 +154,8 @@ var Auth = /** @class */ (function () {
privateKey: keys.privateKeyEncrypted,
publicKey: keys.publicKey,
revocateKey: keys.revocationCertificate,
+ publicKyberKey: keys.publicKyberKey,
+ privateKyberKey: keys.privateKyberKeyEncrypted,
}, this.basicHeaders())
.then(function (data) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -169,6 +177,8 @@ var Auth = /** @class */ (function () {
publicKey: keys.publicKey,
privateKey: keys.privateKeyEncrypted,
revocationKey: keys.revocationCertificate,
+ publicKyberKey: keys.publicKyberKey,
+ privateKyberKey: keys.privateKyberKeyEncrypted,
}, this.headersWithToken(token));
};
/**
diff --git a/node_modules/@internxt/sdk/dist/auth/types.d.ts b/node_modules/@internxt/sdk/dist/auth/types.d.ts
index c104ac5..d9ec1b8 100644
--- a/node_modules/@internxt/sdk/dist/auth/types.d.ts
+++ b/node_modules/@internxt/sdk/dist/auth/types.d.ts
@@ -33,9 +33,11 @@ export interface Keys {
privateKeyEncrypted: string;
publicKey: string;
revocationCertificate: string;
+ publicKyberKey: string;
+ privateKyberKeyEncrypted: string;
}
export interface CryptoProvider {
- encryptPasswordHash: (password: Password, encryptedSalt: string) => string;
+ encryptPasswordHash: (password: Password, encryptedSalt: string) => Promise<string>;
generateKeys: (password: Password) => Promise<Keys>;
}
export declare class UserAccessError extends Error {
diff --git a/node_modules/@internxt/sdk/dist/drive/users/types.d.ts b/node_modules/@internxt/sdk/dist/drive/users/types.d.ts
index 60143e8..f6038c6 100644
--- a/node_modules/@internxt/sdk/dist/drive/users/types.d.ts
+++ b/node_modules/@internxt/sdk/dist/drive/users/types.d.ts
@@ -15,6 +15,7 @@ export interface ChangePasswordPayload {
export declare type UpdateProfilePayload = Partial<Pick<UserSettings, 'name' | 'lastname'>>;
export declare type PreCreateUserResponse = {
publicKey: string;
+ publicKyberKey: string;
user: {
uuid: UUID;
email: string;
@@ -28,6 +29,7 @@ export declare type FriendInvite = {
};
export declare type UserPublicKeyResponse = {
publicKey: string;
+ publicKyberKey: string;
};
export declare type VerifyEmailChangeResponse = {
oldEmail: string;
diff --git a/node_modules/@internxt/sdk/dist/shared/types/userSettings.d.ts b/node_modules/@internxt/sdk/dist/shared/types/userSettings.d.ts
index 1a78d69..b855661 100644
--- a/node_modules/@internxt/sdk/dist/shared/types/userSettings.d.ts
+++ b/node_modules/@internxt/sdk/dist/shared/types/userSettings.d.ts
@@ -18,6 +18,8 @@ export interface UserSettings {
mnemonic: string;
privateKey: string;
publicKey: string;
+ privateKyberKey: string;
+ publicKyberKey: string;
revocationKey: string;
teams?: boolean;
appSumoDetails: AppSumoDetails | null;
18 changes: 13 additions & 5 deletions src/app/auth/components/SignUp/useSignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function useSignUp(
} {
const updateInfo: UpdateInfoFunction = async (email: string, password: string) => {
// Setup hash and salt
const hashObj = passToHash({ password });
const hashObj = await passToHash({ password });
const encPass = encryptText(hashObj.hash);
const encSalt = encryptText(hashObj.salt);

Expand Down Expand Up @@ -93,21 +93,25 @@ export function useSignUp(
};

const doRegister = async (email: string, password: string, captcha: string) => {
const hashObj = passToHash({ password });
const hashObj = await passToHash({ password });
const encPass = encryptText(hashObj.hash);
const encSalt = encryptText(hashObj.salt);
const mnemonic = bip39.generateMnemonic(256);
const encMnemonic = encryptTextWithKey(mnemonic, password);

const { privateKeyArmored, publicKeyArmored, revocationCertificate } = await generateNewKeys();
const { privateKeyArmored, publicKeyArmored, revocationCertificate, publicKyberKeyBase64, privateKyberKeyBase64 } =
await generateNewKeys();
const encPrivateKey = aes.encrypt(privateKeyArmored, password, getAesInitFromEnv());
const encPrivateKyberKey = aes.encrypt(privateKyberKeyBase64, password, getAesInitFromEnv());

const authClient = SdkFactory.getNewApiInstance().createAuthClient();

const keys: Keys = {
privateKeyEncrypted: encPrivateKey,
publicKey: publicKeyArmored,
revocationCertificate: revocationCertificate,
publicKyberKey: publicKyberKeyBase64,
privateKyberKeyEncrypted: encPrivateKyberKey,
};
const registerDetails: RegisterDetails = {
name: 'My',
Expand Down Expand Up @@ -158,19 +162,23 @@ export function useSignUp(
password: string,
captcha: string,
): Promise<RegisterDetails> => {
const hashObj = passToHash({ password });
const hashObj = await passToHash({ password });
const encPass = encryptText(hashObj.hash);
const encSalt = encryptText(hashObj.salt);
const mnemonic = bip39.generateMnemonic(256);
const encMnemonic = encryptTextWithKey(mnemonic, password);

const { privateKeyArmored, publicKeyArmored, revocationCertificate } = await generateNewKeys();
const { privateKeyArmored, publicKeyArmored, revocationCertificate, publicKyberKeyBase64, privateKyberKeyBase64 } =
await generateNewKeys();
const encPrivateKey = aes.encrypt(privateKeyArmored, password, getAesInitFromEnv());
const encPrivateKyberKey = aes.encrypt(privateKyberKeyBase64, password, getAesInitFromEnv());

const keys: Keys = {
privateKeyEncrypted: encPrivateKey,
publicKey: publicKeyArmored,
revocationCertificate: revocationCertificate,
publicKyberKey: publicKyberKeyBase64,
privateKyberKeyEncrypted: encPrivateKyberKey,
};
const registerDetails: RegisterDetails = {
name: 'My',
Expand Down
Loading
Loading