Skip to content

Commit

Permalink
Refactor SignerService - Organize and clean up code and encrypt seckey
Browse files Browse the repository at this point in the history
  • Loading branch information
miladsoft committed Sep 14, 2024
1 parent 0ad2278 commit d40cd6b
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 246 deletions.
4 changes: 2 additions & 2 deletions src/app/components/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class LoginComponent implements OnInit {
this.showSecAlert = false;

try {
const success = this._signerService.handleLoginWithKey(secretKey); // Updated method to handle both nsec and hex
const success = this._signerService.handleLoginWithKey(secretKey,password); // Updated method to handle both nsec and hex

if (success) {
// Successful login
Expand Down Expand Up @@ -121,7 +121,7 @@ export class LoginComponent implements OnInit {
this.loading = true;
this.showMenemonicAlert = false;

const success = this._signerService.handleLoginWithMenemonic(menemonic, passphrase);
const success = this._signerService.handleLoginWithMenemonic(menemonic, passphrase,password);

if (success) {
this._router.navigateByUrl('/home');
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/auth/register/register.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class RegisterComponent implements OnInit {
const password = this.registerForm.get('password')?.value;

// Generate keys using the security service
const keys = this._signerService.generateAndStoreKeys();
const keys = this._signerService.generateAndStoreKeys(password);

if (!keys) {
// If key generation failed, enable the form and show an error
Expand All @@ -94,7 +94,7 @@ export class RegisterComponent implements OnInit {
return;
}

const { privateKeyHex, publicKey, npub, nsec } = keys;
const { secretKey, pubkey, npub, nsec } = keys;

// Simulate saving user metadata along with keys
const userMetadata = {
Expand All @@ -103,7 +103,7 @@ export class RegisterComponent implements OnInit {
about,
avatarUrl,
password,
publicKey,
pubkey,
npub,
nsec,
};
Expand Down
Loading

0 comments on commit d40cd6b

Please sign in to comment.