Add signer info to history datatable.
This commit is contained in:
parent
dd7becb0d5
commit
4d32176387
@ -10,3 +10,4 @@ export * from '@app/_helpers/read-csv';
|
|||||||
export * from '@app/_helpers/schema-validation';
|
export * from '@app/_helpers/schema-validation';
|
||||||
export * from '@app/_helpers/sync';
|
export * from '@app/_helpers/sync';
|
||||||
export * from '@app/_helpers/online-status';
|
export * from '@app/_helpers/online-status';
|
||||||
|
export * from './to-hex';
|
||||||
|
9
src/app/_helpers/to-hex.ts
Normal file
9
src/app/_helpers/to-hex.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
function asciiToHex(str: string): string {
|
||||||
|
const arr = [];
|
||||||
|
for (let n = 0, l = str.length; n < l; n++) {
|
||||||
|
arr.push(Number(str.charCodeAt(n)).toString(16));
|
||||||
|
}
|
||||||
|
return arr.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
export { asciiToHex };
|
@ -44,6 +44,23 @@ export class AppComponent implements OnInit {
|
|||||||
await this.tokenService.init();
|
await this.tokenService.init();
|
||||||
await this.userService.init();
|
await this.userService.init();
|
||||||
await this.transactionService.init();
|
await this.transactionService.init();
|
||||||
|
try {
|
||||||
|
const publicKeys = await this.authService.getPublicKeys();
|
||||||
|
await this.authService.mutableKeyStore.importPublicKey(publicKeys);
|
||||||
|
this.authService.getTrustedUsers();
|
||||||
|
} catch (error) {
|
||||||
|
this.errorDialogService.openDialog({
|
||||||
|
message: 'Trusted keys endpoint cannot be reached. Please try again later.',
|
||||||
|
});
|
||||||
|
// TODO do something to halt user progress...show a sad cicada page 🦗?
|
||||||
|
}
|
||||||
|
if (!this.swUpdate.isEnabled) {
|
||||||
|
this.swUpdate.available.subscribe(() => {
|
||||||
|
if (confirm('New Version available. Load New Version?')) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
await this.router.events
|
await this.router.events
|
||||||
.pipe(filter((e) => e instanceof NavigationEnd))
|
.pipe(filter((e) => e instanceof NavigationEnd))
|
||||||
.forEach(async (routeInfo) => {
|
.forEach(async (routeInfo) => {
|
||||||
@ -69,23 +86,6 @@ export class AppComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
|
||||||
const publicKeys = await this.authService.getPublicKeys();
|
|
||||||
await this.authService.mutableKeyStore.importPublicKey(publicKeys);
|
|
||||||
this.authService.getTrustedUsers();
|
|
||||||
} catch (error) {
|
|
||||||
this.errorDialogService.openDialog({
|
|
||||||
message: 'Trusted keys endpoint cannot be reached. Please try again later.',
|
|
||||||
});
|
|
||||||
// TODO do something to halt user progress...show a sad cicada page 🦗?
|
|
||||||
}
|
|
||||||
if (!this.swUpdate.isEnabled) {
|
|
||||||
this.swUpdate.available.subscribe(() => {
|
|
||||||
if (confirm('New Version available. Load New Version?')) {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load resize
|
// Load resize
|
||||||
|
@ -362,6 +362,13 @@
|
|||||||
</mat-cell>
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="signer">
|
||||||
|
<mat-header-cell *matHeaderCellDef mat-sort-header>Staff</mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let history">
|
||||||
|
{{ history?.snapshot.signature?.data | signatureUser | async }}
|
||||||
|
</mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="message">
|
<ng-container matColumnDef="message">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Message</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header>Message</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let history">
|
<mat-cell *matCellDef="let history">
|
||||||
|
@ -25,8 +25,6 @@ import { MatSnackBar } from '@angular/material/snack-bar';
|
|||||||
import { add0x, strip0x } from '@src/assets/js/ethtx/dist/hex';
|
import { add0x, strip0x } from '@src/assets/js/ethtx/dist/hex';
|
||||||
import { environment } from '@src/environments/environment';
|
import { environment } from '@src/environments/environment';
|
||||||
import { AccountDetails, Transaction } from '@app/_models';
|
import { AccountDetails, Transaction } from '@app/_models';
|
||||||
import * as openpgp from 'openpgp';
|
|
||||||
// const openpgp = require('openpgp');
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-account-details',
|
selector: 'app-account-details',
|
||||||
@ -52,6 +50,7 @@ export class AccountDetailsComponent implements OnInit, AfterViewInit {
|
|||||||
historyDataSource: MatTableDataSource<any>;
|
historyDataSource: MatTableDataSource<any>;
|
||||||
historyDisplayedColumns: Array<string> = [
|
historyDisplayedColumns: Array<string> = [
|
||||||
'actor',
|
'actor',
|
||||||
|
'signer',
|
||||||
'message',
|
'message',
|
||||||
'sequence',
|
'sequence',
|
||||||
'dependencies',
|
'dependencies',
|
||||||
@ -193,15 +192,6 @@ export class AccountDetailsComponent implements OnInit, AfterViewInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.userService.historySubject.subscribe(async (histories) => {
|
this.userService.historySubject.subscribe(async (histories) => {
|
||||||
if (histories.length > 3) {
|
|
||||||
console.log(histories[0].snapshot.signature.digest);
|
|
||||||
const armoredSignature = histories[0].snapshot.signature.data;
|
|
||||||
console.log(armoredSignature);
|
|
||||||
// const signature = await openpgp.readSignature({ armoredSignature });
|
|
||||||
// alert('Signature read!');
|
|
||||||
// signature.getSigningKeyIds().map(x => console.log(x.toHex()));
|
|
||||||
// console.log('IDs read!');
|
|
||||||
}
|
|
||||||
this.historyDataSource = new MatTableDataSource<any>(histories);
|
this.historyDataSource = new MatTableDataSource<any>(histories);
|
||||||
this.historyDataSource.paginator = this.historyPaginator;
|
this.historyDataSource.paginator = this.historyPaginator;
|
||||||
this.historyDataSource.sort = this.historyTableSort;
|
this.historyDataSource.sort = this.historyTableSort;
|
||||||
|
8
src/app/shared/_pipes/signature-user.pipe.spec.ts
Normal file
8
src/app/shared/_pipes/signature-user.pipe.spec.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { SignatureUserPipe } from './signature-user.pipe';
|
||||||
|
|
||||||
|
describe('SignatureUserPipe', () => {
|
||||||
|
it('create an instance', () => {
|
||||||
|
const pipe = new SignatureUserPipe();
|
||||||
|
expect(pipe).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
20
src/app/shared/_pipes/signature-user.pipe.ts
Normal file
20
src/app/shared/_pipes/signature-user.pipe.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
|
import * as openpgp from 'openpgp';
|
||||||
|
import { asciiToHex } from '@app/_helpers';
|
||||||
|
import { KeystoreService } from '@app/_services';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'signatureUser',
|
||||||
|
})
|
||||||
|
export class SignatureUserPipe implements PipeTransform {
|
||||||
|
async transform(armoredSignature: string, ...args: unknown[]): Promise<string> {
|
||||||
|
const keystore = await KeystoreService.getKeystore();
|
||||||
|
const signature = await openpgp.signature.readArmored(armoredSignature);
|
||||||
|
const keyId = asciiToHex(signature.packets[0].issuerKeyId.bytes);
|
||||||
|
const pubKey = keystore.getPublicKeyForId(keyId);
|
||||||
|
if (pubKey) {
|
||||||
|
return pubKey.users[0].userId.userid;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ import { MatDialogModule } from '@angular/material/dialog';
|
|||||||
import { SafePipe } from '@app/shared/_pipes/safe.pipe';
|
import { SafePipe } from '@app/shared/_pipes/safe.pipe';
|
||||||
import { NetworkStatusComponent } from './network-status/network-status.component';
|
import { NetworkStatusComponent } from './network-status/network-status.component';
|
||||||
import { UnixDatePipe } from './_pipes/unix-date.pipe';
|
import { UnixDatePipe } from './_pipes/unix-date.pipe';
|
||||||
|
import { SignatureUserPipe } from './_pipes/signature-user.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -26,6 +27,7 @@ import { UnixDatePipe } from './_pipes/unix-date.pipe';
|
|||||||
SafePipe,
|
SafePipe,
|
||||||
NetworkStatusComponent,
|
NetworkStatusComponent,
|
||||||
UnixDatePipe,
|
UnixDatePipe,
|
||||||
|
SignatureUserPipe,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
TopbarComponent,
|
TopbarComponent,
|
||||||
@ -36,6 +38,7 @@ import { UnixDatePipe } from './_pipes/unix-date.pipe';
|
|||||||
SafePipe,
|
SafePipe,
|
||||||
NetworkStatusComponent,
|
NetworkStatusComponent,
|
||||||
UnixDatePipe,
|
UnixDatePipe,
|
||||||
|
SignatureUserPipe,
|
||||||
],
|
],
|
||||||
imports: [CommonModule, RouterModule, MatIconModule, MatDialogModule],
|
imports: [CommonModule, RouterModule, MatIconModule, MatDialogModule],
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user