Skip to content

Commit e3bf175

Browse files
committed
test(auth): manual test for email/password + MFA/TOTP flow
took demo app from PR and ingested it here as local test - added ability to sign up a new email/pass, not just login - added ability to detect unverified email, send verify email, and reload user - added QR code display for TOTP enroll flow
1 parent cf753e0 commit e3bf175

File tree

7 files changed

+625
-30
lines changed

7 files changed

+625
-30
lines changed

packages/auth/lib/TotpMultiFactorGenerator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default class TotpMultiFactorGenerator {
4444
// hashingAlgorithm, codeLength, codeIntervalSeconds, enrollmentCompletionDeadline
4545
} = await auth.native.generateTotpSecret(session);
4646

47-
return new TotpSecret(secretKey);
47+
const totpSecret = new TotpSecret(secretKey, auth);
48+
return totpSecret;
4849
}
4950
}

packages/auth/lib/TotpSecret.js

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
11
export class TotpSecret {
2-
constructor(
3-
secretKey,
4-
hashingAlgorithm,
5-
codeLength,
6-
codeIntervalSeconds,
7-
enrollmentCompletionDeadline,
8-
) {
2+
constructor(secretKey, auth) {
3+
// The native TotpSecret has many more properties, but they are
4+
// internal to the native SDKs, we only maintain the secret in JS layer
95
this.secretKey = secretKey;
10-
this.hashingAlgorithm = hashingAlgorithm;
11-
this.codeLength = codeLength;
12-
this.codeIntervalSeconds = codeIntervalSeconds;
13-
this.enrollmentCompletionDeadline = enrollmentCompletionDeadline;
6+
7+
// we do need a handle to the correct auth instance to generate QR codes etc
8+
this.auth = auth;
149
}
1510

16-
sessionInfo = null;
17-
auth = null;
1811
/**
1912
* Shared secret key/seed used for enrolling in TOTP MFA and generating OTPs.
2013
*/
2114
secretKey = null;
22-
/**
23-
* Hashing algorithm used.
24-
*/
25-
hashingAlgorithm = null;
26-
/**
27-
* Length of the one-time passwords to be generated.
28-
*/
29-
codeLength = null;
30-
/**
31-
* The interval (in seconds) when the OTP codes should change.
32-
*/
33-
codeIntervalSeconds = null;
34-
/**
35-
* The timestamp (UTC string) by which TOTP enrollment should be completed.
36-
*/
37-
enrollmentCompletionDeadline = null;
3815

3916
/**
4017
* Returns a QR code URL as described in

0 commit comments

Comments
 (0)