commit
40b736c438
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,12 @@
|
||||
.chkbox-wallet:focus {
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
.blinker {
|
||||
animation: blink-animation 1s steps(5, start) infinite;
|
||||
-webkit-animation: blink-animation 1s steps(5, start) infinite;
|
||||
}
|
||||
|
||||
@keyframes blink-animation { to { visibility: hidden; }}
|
||||
|
||||
@-webkit-keyframes blink-animation { to { visibility: hidden; }}
|
@ -1,41 +1,163 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { takeUntil, take } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { FormBuilder, FormGroup, Validators, ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms';
|
||||
import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper';
|
||||
import { MatStepper } from '@angular/material';
|
||||
|
||||
import { LoggerService } from '../../shared/services/logger.service';
|
||||
|
||||
import { RTLEffects } from '../../shared/store/rtl.effects';
|
||||
import * as RTLActions from '../../shared/store/rtl.actions';
|
||||
import * as fromRTLReducer from '../../shared/store/rtl.reducers';
|
||||
|
||||
export const matchedPasswords: ValidatorFn = (control: FormGroup): ValidationErrors | null => {
|
||||
const initWalletPassword = control.get('initWalletPassword');
|
||||
const initWalletConfirmPassword = control.get('initWalletConfirmPassword');
|
||||
return initWalletPassword && initWalletConfirmPassword && initWalletPassword.value !== initWalletConfirmPassword.value ? { 'unmatchedPasswords': true } : null;
|
||||
};
|
||||
|
||||
export const cipherSeedLength: ValidatorFn = (control: FormGroup): ValidationErrors | null => {
|
||||
const existingCipher = control.get('existingCipher');
|
||||
const cipherSeed = control.get('cipherSeed');
|
||||
const cipherArr = cipherSeed.value.toString().trim().split(',');
|
||||
return existingCipher.value && cipherArr && cipherArr.length !== 24 ? { 'invalidCipher': true } : null;
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'rtl-unlock-lnd',
|
||||
templateUrl: './unlock-lnd.component.html',
|
||||
styleUrls: ['./unlock-lnd.component.scss']
|
||||
styleUrls: ['./unlock-lnd.component.scss'],
|
||||
providers: [{
|
||||
provide: STEPPER_GLOBAL_OPTIONS, useValue: {displayDefaultIndicatorType: false}
|
||||
}]
|
||||
})
|
||||
export class UnlockLNDComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(MatStepper) stepper: MatStepper;
|
||||
public insecureLND = false;
|
||||
public genSeedResponse = [];
|
||||
public initWalletResponse = '';
|
||||
walletOperation = 'init';
|
||||
walletPassword = '';
|
||||
private unsub = new Subject();
|
||||
passwordFormGroup: FormGroup;
|
||||
cipherFormGroup: FormGroup;
|
||||
passphraseFormGroup: FormGroup;
|
||||
private unsubs = [new Subject(), new Subject(), new Subject(), new Subject(), new Subject()];
|
||||
|
||||
constructor(private store: Store<fromRTLReducer.State>) {}
|
||||
constructor(private store: Store<fromRTLReducer.State>, private formBuilder: FormBuilder, private rtlEffects: RTLEffects, private router: Router) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.walletPassword = '';
|
||||
this.passwordFormGroup = this.formBuilder.group({
|
||||
initWalletPassword: ['', [Validators.required, Validators.minLength(8)]],
|
||||
initWalletConfirmPassword: ['', [Validators.required, Validators.minLength(8)]]
|
||||
}, {validators: matchedPasswords});
|
||||
this.cipherFormGroup = this.formBuilder.group({
|
||||
existingCipher: [false],
|
||||
cipherSeed: [{value: '', disabled: true}]
|
||||
}, {validators: cipherSeedLength});
|
||||
this.passphraseFormGroup = this.formBuilder.group({
|
||||
enterPassphrase: [false],
|
||||
passphrase: [{value: '', disabled: true}]
|
||||
});
|
||||
|
||||
this.cipherFormGroup.controls.existingCipher.valueChanges.pipe(takeUntil(this.unsubs[0])).subscribe(checked => {
|
||||
if (checked) {
|
||||
this.cipherFormGroup.controls.cipherSeed.setValue('');
|
||||
this.cipherFormGroup.controls.cipherSeed.enable();
|
||||
} else {
|
||||
this.cipherFormGroup.controls.cipherSeed.setValue('');
|
||||
this.cipherFormGroup.controls.cipherSeed.disable();
|
||||
}
|
||||
});
|
||||
|
||||
this.passphraseFormGroup.controls.enterPassphrase.valueChanges.pipe(takeUntil(this.unsubs[1])).subscribe(checked => {
|
||||
if (checked) {
|
||||
this.passphraseFormGroup.controls.passphrase.setValue('');
|
||||
this.passphraseFormGroup.controls.passphrase.enable();
|
||||
} else {
|
||||
this.passphraseFormGroup.controls.passphrase.setValue('');
|
||||
this.passphraseFormGroup.controls.passphrase.disable();
|
||||
}
|
||||
});
|
||||
|
||||
this.insecureLND = !window.location.protocol.includes('https://');
|
||||
|
||||
this.rtlEffects.initWalletRes
|
||||
.pipe(takeUntil(this.unsubs[2]))
|
||||
.subscribe(initWalletResponse => {
|
||||
this.initWalletResponse = initWalletResponse;
|
||||
});
|
||||
|
||||
this.rtlEffects.genSeedResponse
|
||||
.pipe(takeUntil(this.unsubs[3]))
|
||||
.subscribe(genSeedRes => {
|
||||
this.genSeedResponse = genSeedRes;
|
||||
if (this.passphraseFormGroup.controls.enterPassphrase.value) {
|
||||
this.store.dispatch(new RTLActions.InitWallet({
|
||||
pwd: window.btoa(this.passwordFormGroup.controls.initWalletPassword.value),
|
||||
cipher: this.genSeedResponse,
|
||||
passphrase: window.btoa(this.passphraseFormGroup.controls.passphrase.value)
|
||||
}));
|
||||
} else {
|
||||
this.store.dispatch(new RTLActions.InitWallet({
|
||||
pwd: window.btoa(this.passwordFormGroup.controls.initWalletPassword.value),
|
||||
cipher: this.genSeedResponse
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
onOperateWallet(operation: string) {
|
||||
onOperateWallet() {
|
||||
this.store.dispatch(new RTLActions.OpenSpinner('Unlocking...'));
|
||||
this.store.dispatch(new RTLActions.OperateWallet({operation: operation, pwd: this.walletPassword}));
|
||||
this.store.dispatch(new RTLActions.UnlockWallet({pwd: window.btoa(this.walletPassword)}));
|
||||
}
|
||||
|
||||
onInitWallet() {
|
||||
this.store.dispatch(new RTLActions.OpenSpinner('Initializing...'));
|
||||
if (this.cipherFormGroup.controls.existingCipher.value) {
|
||||
const cipherArr = this.cipherFormGroup.controls.cipherSeed.value.toString().trim().split(',');
|
||||
if (this.passphraseFormGroup.controls.enterPassphrase.value) {
|
||||
this.store.dispatch(new RTLActions.InitWallet({
|
||||
pwd: window.btoa(this.passwordFormGroup.controls.initWalletPassword.value),
|
||||
cipher: cipherArr,
|
||||
passphrase: window.btoa(this.passphraseFormGroup.controls.passphrase.value)
|
||||
}));
|
||||
} else {
|
||||
this.store.dispatch(new RTLActions.InitWallet({
|
||||
pwd: window.btoa(this.passwordFormGroup.controls.initWalletPassword.value),
|
||||
cipher: cipherArr
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
if (this.passphraseFormGroup.controls.enterPassphrase.value) {
|
||||
this.store.dispatch(new RTLActions.GenSeed(window.btoa(this.passphraseFormGroup.controls.passphrase.value)));
|
||||
} else {
|
||||
this.store.dispatch(new RTLActions.GenSeed(''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onGoToHome() {
|
||||
setTimeout(() => {
|
||||
this.store.dispatch(new RTLActions.InitAppData());
|
||||
this.router.navigate(['/']);
|
||||
}, 1000 * 1);
|
||||
}
|
||||
|
||||
resetData() {
|
||||
this.walletOperation = 'init';
|
||||
this.walletPassword = '';
|
||||
this.genSeedResponse = [];
|
||||
this.initWalletResponse = '';
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.unsub.next();
|
||||
this.unsub.complete();
|
||||
this.unsubs.forEach(unsub => {
|
||||
unsub.next();
|
||||
unsub.complete();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
export const VERSION = '0.3.3-beta';
|
||||
export const VERSION = '0.4.0-beta';
|
Loading…
Reference in New Issue