Commit ff892708 authored by Mark Harding's avatar Mark Harding

(chore): pushing new modules for olivia

parent 83ee1729
No related merge requests found
......@@ -5,6 +5,4 @@
</h1>
</div>
<img [src]="qrImageUri" />
<router-outlet></router-outlet>
import { Component } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { DomSanitizer, SafeUrl } from "@angular/platform-browser";
// import * as Connect from "uport-connect";
declare const Connect: any;
......@@ -12,19 +9,6 @@ declare const Connect: any;
})
export class AppComponent {
title = "t3";
qrImageUri: SafeUrl;
constructor(private http: HttpClient, private sanitizer: DomSanitizer) {}
ngOnInit() {
// const uport = new Connect("Minds Trust (t3)", );
// uport.requestDisclosure();
this.fetchQrImageUri();
}
async fetchQrImageUri() {
this.http.get("http://localhost:8088/qr").subscribe((data: any) => {
this.qrImageUri = this.sanitizer.bypassSecurityTrustUrl(data.qrImageData);
});
}
constructor() {}
}
......@@ -4,10 +4,18 @@ import { HttpClientModule } from "@angular/common/http";
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { uPortModule } from "./modules/uport/uport.module";
import { T3VerificationModule } from "./modules/verification/verification.module";
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, AppRoutingModule, HttpClientModule],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
uPortModule,
T3VerificationModule
],
providers: [],
bootstrap: [AppComponent]
})
......
import { NgModule } from "@angular/core";
import { uPortVerificationService } from "./verification.service";
@NgModule({
providers: [uPortVerificationService]
})
export class uPortModule {}
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { SafeUrl, DomSanitizer } from "@angular/platform-browser";
import { Subject, interval, BehaviorSubject } from "rxjs";
import { first } from "rxjs/operators";
@Injectable()
export class uPortVerificationService {
qrImageUri$: Subject<SafeUrl> = new Subject();
data$: BehaviorSubject<any> = new BehaviorSubject(null);
constructor(private http: HttpClient, private sanitizer: DomSanitizer) {
this.start();
}
/**
* Commence login
*/
async start(): Promise<void> {
await this.fetch();
this.startPolling();
}
async fetch(): Promise<void> {
const data = await this.http.get("http://localhost:8088/qr").toPromise();
this.data$.next(data);
}
/**
* Fetch a qr code
*/
fetchQrImageUri(): void {
this.data$.subscribe((data: any) => {
this.qrImageUri$.next(
this.sanitizer.bypassSecurityTrustUrl(data.qrImageData)
);
});
}
startPolling() {
interval(1000).subscribe(async () => {});
}
}
<img [src]="verificationService.qrImageUri$ | async" />
import { Component } from "@angular/core";
import { uPortVerificationService } from "../uport/verification.service";
@Component({
selector: "t3-verification",
templateUrl: "./verification.component.html"
})
export class T3VerificationComponent {
constructor(public verificationService: uPortVerificationService) {}
ngOnInit() {
this.verificationService.fetchQrImageUri();
this.verificationService.startPolling();
}
}
import { NgModule } from "@angular/core";
import { T3VerificationComponent } from "./verification.component";
import { uPortModule } from "../uport/uport.module";
import { Router, RouterModule } from "@angular/router";
import { CommonModule } from "@angular/common";
@NgModule({
imports: [
CommonModule,
uPortModule,
RouterModule,
RouterModule.forChild([
{
path: "verification",
component: T3VerificationComponent
}
])
],
declarations: [T3VerificationComponent],
entryComponents: [T3VerificationComponent]
})
export class T3VerificationModule {}
......@@ -42,6 +42,7 @@ app.get("/qr", async (req, res) => {
);
const qr = transports.ui.getImageDataURI(uri);
res.send({
uri,
qrImageData: qr
});
} catch (err) {}
......@@ -58,3 +59,6 @@ app.post("/callback", async (req, res) => {
console.log(err);
}
});
// run the app server and tunneling service
const server = app.listen(8088, () => {});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment