Commit 120dcf16 authored by David Burke's avatar David Burke

Added jsqr

parent 247c9e1f
Pipeline #32576364 passed with stage
in 8 minutes and 29 seconds
......@@ -9,35 +9,25 @@
</div>
</div>
<p>Next we need your backup code. Passit cannot be recovered without either your original password or recovery code/QR code</p>
<p>Next we need your backup code. Passit cannot be recovered without either your original password or recovery
code/QR code</p>
<app-non-field-messages *ngIf="errorMessage || localErrorMessage" [messages]="[errorMessage, localErrorMessage]"></app-non-field-messages>
<button id="scan-qr-button" (click)="toggleScan()">Scan QR Code</button>
<button id="scan-qr-button" (click)="toggleScan()">Scan QR Code</button>
<div>
<video id="scan-qr-video"></video>
<canvas id="canvas" hidden></canvas>
</div>
<form [ngrxFormState]="form" (submit)="onSubmit()" class="auth-form__form">
<div>
<label [for]="form.controls.code.id">
Or Type Code
</label>
<input
type="email"
[ngrxFormControlState]="form.controls.code"
autofocus
spellcheck="false"
class="form-field__input"
[class.form-field__input--invalid]="form.errors._code && form.isSubmitted"
[class.form-field__input--valid]="!form.errors._code"
/>
<input type="email" [ngrxFormControlState]="form.controls.code" autofocus spellcheck="false" class="form-field__input"
[class.form-field__input--invalid]="form.errors._code && form.isSubmitted" [class.form-field__input--valid]="!form.errors._code" />
</div>
<button
id="loginSubmit"
class="button button--large button--green"
[disabled]="hasStarted"
type="submit">
<button id="loginSubmit" class="button button--large button--green" [disabled]="hasStarted" type="submit">
Next
</button>
</form>
......
import { Component, Input, OnInit, EventEmitter, Output } from "@angular/core";
import { FormGroupState } from "ngrx-forms";
import { IResetPasswordVerifyForm } from "./reset-password-verify.reducer";
import * as Instascan from "instascan";
import jsQR from "jsqr";
@Component({
selector: "app-reset-password-verify",
......@@ -36,18 +36,6 @@ export class ResetPasswordVerifyComponent implements OnInit {
startScan = () => {
this.localErrorMessage = null;
const scanner = this.scanner;
Instascan.Camera.getCameras()
.then(function(cameras: object[]) {
if (cameras.length > 0) {
scanner.start(cameras[0]);
} else {
this.localErrorMessage = "No cameras found.";
}
})
.catch(function(e: any) {
console.error(e);
});
};
stopScan() {
......@@ -65,9 +53,49 @@ export class ResetPasswordVerifyComponent implements OnInit {
}
ngOnInit() {
this.scanner = new Instascan.Scanner({
video: document.getElementById("scan-qr-video")
});
this.scanner.addListener("scan", this.handleQrFound);
const video = document.createElement("video");
const canvasElement = document.getElementById(
"canvas"
) as HTMLCanvasElement;
const canvas = canvasElement.getContext("2d") as CanvasRenderingContext2D;
console.log(video, canvasElement, canvas, jsQR);
setTimeout(() => {
navigator.mediaDevices
.getUserMedia({
video: { facingMode: "environment" }
})
.then(function(stream) {
// video.srcObject = stream;
// video.setAttribute("playsinline", "true"); // required to tell iOS safari we don't want fullscreen
// video.play();
// requestAnimationFrame(tick);
})
.catch(err => console.log(err));
}, 100);
// function tick() {
// if (video.readyState === video.HAVE_ENOUGH_DATA) {
// canvasElement.hidden = false;
// canvasElement.height = video.videoHeight;
// canvasElement.width = video.videoWidth;
// canvas.drawImage(
// video,
// 0,
// 0,
// canvasElement.width,
// canvasElement.height
// );
// const imageData = canvas.getImageData(
// 0,
// 0,
// canvasElement.width,
// canvasElement.height
// );
// const code = jsQR(imageData.data, imageData.width, imageData.height);
// if (code) {
// console.log("code is ", code);
// }
// }
// requestAnimationFrame(tick);
// }
}
}
......@@ -14,9 +14,11 @@ import { ProgressIndicatorModule } from "../app/progress-indicator";
import * as fromForgotPassword from "../app/account/forgot-password/forgot-password.reducer";
import * as fromLogin from "../app/account/login/login.reducer";
import * as fromChangePassword from "../app/account/change-password/change-password.reducer";
import * as fromResetPasswordVerify from "../app/account/forgot-password/reset-password-verify/reset-password-verify.reducer";
import { RouterTestingModule } from "@angular/router/testing";
import { ChangePasswordComponent } from "../app/account/change-password";
import { PasswordInputComponent } from "../app/account/change-password/password-input/password-input.component";
import { ResetPasswordVerifyComponent } from "../app/account/forgot-password/reset-password-verify/reset-password-verify.component";
storiesOf("Account", module)
.addDecorator(withKnobs)
......@@ -47,6 +49,12 @@ storiesOf("Account", module)
form: fromForgotPassword.initialFormState
}
}))
.add("Reset Password Verify", () => ({
component: ResetPasswordVerifyComponent,
props: {
form: fromResetPasswordVerify.initialResetPasswordVerifyFormState
}
}))
.add("Marketing Frame", () => ({
component: MarketingFrameComponent
}))
......
......@@ -2672,7 +2672,7 @@ babel-polyfill@6.16.0:
core-js "^2.4.0"
regenerator-runtime "^0.9.5"
babel-polyfill@6.26.0, babel-polyfill@^6.9.1:
babel-polyfill@6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
integrity sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=
......@@ -4964,7 +4964,7 @@ es6-promise@^2.0.1:
resolved "http://registry.npmjs.org/es6-promise/-/es6-promise-2.3.0.tgz#96edb9f2fdb01995822b263dd8aadab6748181bc"
integrity sha1-lu258v2wGZWCKyY92KratnSBgbw=
es6-promise@^4.0.2, es6-promise@^4.0.3:
es6-promise@^4.0.3:
version "4.2.5"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.5.tgz#da6d0d5692efb461e082c14817fe2427d8f5d054"
integrity sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==
......@@ -6011,15 +6011,6 @@ fsevents@1.2.4, fsevents@^1.0.0, fsevents@^1.2.2:
nan "^2.9.2"
node-pre-gyp "^0.10.0"
fsm-as-promised@^0.13.0:
version "0.13.2"
resolved "https://registry.yarnpkg.com/fsm-as-promised/-/fsm-as-promised-0.13.2.tgz#5f4e11086828b70a1922dc7b4f81c0817d6e8238"
integrity sha1-X04RCGgotwoZItx7T4HAgX1ugjg=
dependencies:
es6-promise "^4.0.2"
lodash "^4.16.2"
stampit "^3.0.1"
fstream@^1.0.0, fstream@^1.0.2:
version "1.0.11"
resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171"
......@@ -7053,16 +7044,6 @@ inside@^1.0.0:
resolved "https://registry.yarnpkg.com/inside/-/inside-1.0.0.tgz#db45e993573cdb3db70b9832e8285bad46424770"
integrity sha1-20Xpk1c82z23C5gy6ChbrUZCR3A=
instascan@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/instascan/-/instascan-1.0.0.tgz#de5949f73f698f8dff68df0a7bcf6942a799ee44"
integrity sha1-3llJ9z9pj43/aN8Ke89pQqeZ7kQ=
dependencies:
babel-polyfill "^6.9.1"
fsm-as-promised "^0.13.0"
visibilityjs "^1.2.3"
webrtc-adapter "^1.4.0"
internal-ip@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-3.0.1.tgz#df5c99876e1d2eb2ea2d74f520e3f669a00ece27"
......@@ -7885,6 +7866,11 @@ jsprim@^1.2.2:
json-schema "0.2.3"
verror "1.10.0"
jsqr@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/jsqr/-/jsqr-1.1.1.tgz#a0d7f95e6c3b0bec913dfef2ca64a877f28ed05f"
integrity sha512-FVoMU2ncTyjaOqN/vwvDnZ7jaAVvFzM3LK3vG3jvQZFWJQlAwJ1XTCOgAEKo+4Rkd6ydMXTTvqGV/4w5VunmTw==
jszip@^2.4.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/jszip/-/jszip-2.6.1.tgz#b88f3a7b2e67a2a048152982c7a3756d9c4828f0"
......@@ -8360,7 +8346,7 @@ lodash@^3.8.0:
resolved "http://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=
lodash@^4.0.0, lodash@^4.0.1, lodash@^4.11.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.16.2, lodash@^4.17.10, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.5.0, lodash@^4.8.0, lodash@~4.17.10, lodash@~4.17.2:
lodash@^4.0.0, lodash@^4.0.1, lodash@^4.11.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.5.0, lodash@^4.8.0, lodash@~4.17.10, lodash@~4.17.2:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
......@@ -11375,11 +11361,6 @@ scss-tokenizer@^0.2.3:
js-base64 "^2.1.8"
source-map "^0.4.2"
sdp@^1.0.0:
version "1.5.4"
resolved "https://registry.yarnpkg.com/sdp/-/sdp-1.5.4.tgz#8e038f6ddb14bd765ae1f4b5216e12094511e0d0"
integrity sha1-jgOPbdsUvXZa4fS1IW4SCUUR4NA=
secure-keys@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/secure-keys/-/secure-keys-1.0.0.tgz#f0c82d98a3b139a8776a8808050b824431087fca"
......@@ -12250,11 +12231,6 @@ stackblur@^1.0.0:
resolved "https://registry.yarnpkg.com/stackblur/-/stackblur-1.0.0.tgz#b407a7e05c93b08d66883bb808d7cba3a503f12f"
integrity sha1-tAen4FyTsI1miDu4CNfLo6UD8S8=
stampit@^3.0.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/stampit/-/stampit-3.2.1.tgz#953a41a49458a0b286ffb1e3c9d6ce7036e589db"
integrity sha1-lTpBpJRYoLKG/7HjydbOcDblids=
static-extend@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6"
......@@ -13458,11 +13434,6 @@ verror@1.10.0:
core-util-is "1.0.2"
extsprintf "^1.2.0"
visibilityjs@^1.2.3:
version "1.2.8"
resolved "https://registry.yarnpkg.com/visibilityjs/-/visibilityjs-1.2.8.tgz#4ccdcebdaef0b34fb89219ab8e10e39c3a7cbfd8"
integrity sha512-Y+aL3OUX88b+/VSmkmC2ApuLbf0grzbNLpCfIDSw3BzTU6PqcPsdgIOaw8b+eZoy+DdQqnVN3y/Evow9vQq9Ig==
viz.js@^1.8.0:
version "1.8.2"
resolved "https://registry.yarnpkg.com/viz.js/-/viz.js-1.8.2.tgz#d9cc04cd99f98ec986bf9054db76a6cbcdc5d97a"
......@@ -13770,13 +13741,6 @@ webpack@^4.15.1, webpack@^4.17.1:
watchpack "^1.5.0"
webpack-sources "^1.2.0"
webrtc-adapter@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/webrtc-adapter/-/webrtc-adapter-1.4.0.tgz#58289a63d054c65b36fb0ef389ea2f6d0c7f5d98"
integrity sha1-WCiaY9BUxls2+w7zieovbQx/XZg=
dependencies:
sdp "^1.0.0"
websocket-driver@>=0.5.1:
version "0.7.0"
resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.0.tgz#0caf9d2d755d93aee049d4bdd0d3fe2cca2a24eb"
......
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