Skip to content

Commit

Permalink
Fix hex pad
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed May 20, 2024
1 parent fef67a3 commit 8601eae
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
3 changes: 2 additions & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"electron:start-live": "node ./live-runner.js",
"electron:start": "yarn build && electron --inspect=5858 ./",
"electron:pack": "yarn build && electron-builder build --dir -c ./electron-builder.config.json",
"electron:make": "yarn build && electron-builder build -c ./electron-builder.config.json -p always"
"electron:make": "yarn build && electron-builder build -c ./electron-builder.config.json -p always",
"pack:all": "yarn electron:pack --mac dmg; yarn electron:pack --win portable"
},
"dependencies": {
"@capacitor-community/electron": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion electron/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class ElectronCapacitorApp {
// Set a CSP up for our application based on the custom scheme
export function setupContentSecurityPolicy(customScheme: string): void {
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
const host = 'https://authman.io http://localhost';
const host = 'https://app.authman.io http://localhost';

callback({
responseHeaders: {
Expand Down
4 changes: 2 additions & 2 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = FZH47FZR8S;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Authman;
Expand All @@ -369,7 +369,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = FZH47FZR8S;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Authman;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test:unit": "vitest",
"lint": "eslint .",
"electron": "bin/electron-script.sh",
"electron:prod": "bin/electron-script.sh build production",
"resources": "capacitor-resources -p android,ios --transform-splash cover"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/service/encryption-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default new class EncryptionService {
*/
async deriveKek(password: Uint8Array | string, salt: Uint8Array | string) {
password = wrapUint8(password);

salt = wrapUint8(salt);

return sodium.crypto_pwhash(
Expand Down
1 change: 1 addition & 0 deletions src/service/local-auth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import encryptionService from '@/service/encryption-service';
import userService from '@/service/user-service';
import { isElectron, saltStorage } from '@/store/main-store';
import { enableBiometricsOption } from '@/store/options-store';
import { wrapUint8 } from '@/utilities/convert';
import secretToolkit, { Encoder } from '@/utilities/secret-toolkit';
import {
AndroidBiometryStrength,
Expand Down
2 changes: 1 addition & 1 deletion src/service/password-reset-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default new class {

const saltHex = bigintToHex(salt);
const saltUint8 = hexToUint8(saltHex);
console.log(saltHex, saltUint8);

const kek = await encryptionService.deriveKek(password, saltUint8);

const keyS = S.toString();
Expand Down
14 changes: 8 additions & 6 deletions src/service/user-delete-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { bigintToHex } from 'bigint-toolkit';

export default new class {
async deleteMeAndLogout() {
await this.deleteMe();
const v = await this.deleteMe();

await userService.logoutAndRedirect();
if (v) {
await userService.logoutAndRedirect();
}
}

async deleteMe() {
Expand All @@ -28,7 +30,7 @@ export default new class {
);

if (!v) {
return;
return false;
}

const password = await userService.askPassword(
Expand All @@ -37,19 +39,19 @@ export default new class {
);

if (!password) {
return;
return false;
}

const kek = await localAuthService.validatePasswordAndGetKek(password);

if (!kek) {
simpleAlert('Invalid password.');
return;
return false;
}

const { loading, run } = await useLoadingOverlay('Deleting account...');

await run(async () => {
return await run(async () => {
const user = userStorage.value!;
const { salt, B, sess } = await authService.challenge(user.email);

Expand Down
4 changes: 2 additions & 2 deletions src/utilities/secret-toolkit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { uint82text, wrapUint8, } from '@/utilities/convert';
import { hexToUint8, uint8ToHex } from 'bigint-toolkit';
import { hexPadZero, hexToUint8, uint8ToHex } from 'bigint-toolkit';
import sodium, { base64_variants, from_base64, to_base64 } from 'libsodium-wrappers-sumo';

export enum Encoder {
Expand Down Expand Up @@ -43,7 +43,7 @@ export default new class {
const [encoder, encoded] = this.extract(str);

if (encoder === Encoder.HEX) {
return hexToUint8(encoded);
return hexToUint8(hexPadZero(encoded));
}

if (encoder === Encoder.BASE64URL) {
Expand Down

0 comments on commit 8601eae

Please sign in to comment.