Skip to content

Commit 616eccd

Browse files
committed
check invalid secret
1 parent a61d179 commit 616eccd

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/models/otp.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class OTPEntry implements OTP {
6262
this.code = KeyUtilities.generate(this.type, this.secret, this.counter);
6363
} catch (error) {
6464
this.code = 'Invalid';
65+
if (parent) {
66+
parent.postMessage(`Invalid secret: [${this.secret}]`, '*');
67+
}
6568
}
6669
}
6770
}

src/test/test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,7 @@ const startBtn = document.getElementById('start');
297297
if (startBtn) {
298298
startBtn.onclick = testStart;
299299
}
300+
301+
window.addEventListener('message', (event) => {
302+
testRes[testCaseIndex] = {pass: false, error: event.data};
303+
}, false);

0 commit comments

Comments
 (0)