Skip to content

Commit e067344

Browse files
committed
Export TOTP symbols to be picked up by demo app.
1 parent 70cbc31 commit e067344

File tree

3 files changed

+63
-13
lines changed

3 files changed

+63
-13
lines changed

common/api-review/auth.api.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,36 @@ export function signOut(auth: Auth): Promise<void>;
750750
export interface TotpMultiFactorAssertion extends MultiFactorAssertion {
751751
}
752752

753+
// @public
754+
export class TotpMultiFactorGenerator {
755+
static assertionForEnrollment(secret: TotpSecret, oneTimePassword: string): TotpMultiFactorAssertion;
756+
static assertionForSignIn(enrollmentId: string, oneTimePassword: string): TotpMultiFactorAssertion;
757+
// Warning: (ae-forgotten-export) The symbol "FactorId" needs to be exported by the entry point index.d.ts
758+
static FACTOR_ID: FactorId_2;
759+
static generateSecret(session: MultiFactorSession): Promise<TotpSecret>;
760+
}
761+
753762
// @public
754763
export interface TotpMultiFactorInfo extends MultiFactorInfo {
755764
}
756765

766+
// @public
767+
export class TotpSecret {
768+
readonly codeIntervalSeconds: number;
769+
readonly codeLength: number;
770+
// Warning: (ae-forgotten-export) The symbol "StartTotpMfaEnrollmentResponse" needs to be exported by the entry point index.d.ts
771+
//
772+
// @internal (undocumented)
773+
static _fromStartTotpMfaEnrollmentResponse(response: StartTotpMfaEnrollmentResponse, auth: AuthInternal): TotpSecret;
774+
generateQrCodeUrl(accountName?: string, issuer?: string): string;
775+
readonly hashingAlgorithm: string;
776+
// Warning: (ae-forgotten-export) The symbol "TotpVerificationInfo" needs to be exported by the entry point index.d.ts
777+
//
778+
// @internal (undocumented)
779+
_makeTotpVerificationInfo(otp: string): TotpVerificationInfo;
780+
readonly secretKey: string;
781+
}
782+
757783
// @public
758784
export class TwitterAuthProvider extends BaseOAuthProvider {
759785
constructor();

packages/auth/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ import { browserPopupRedirectResolver } from './src/platform_browser/popup_redir
7373

7474
// MFA
7575
import { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';
76+
import {
77+
TotpMultiFactorGenerator,
78+
TotpSecret
79+
} from './src/mfa/assertions/totp';
7680

7781
// Initialization and registration of Auth
7882
import { getAuth } from './src/platform_browser';
@@ -96,5 +100,7 @@ export {
96100
RecaptchaVerifier,
97101
browserPopupRedirectResolver,
98102
PhoneMultiFactorGenerator,
103+
TotpMultiFactorGenerator,
104+
TotpSecret,
99105
getAuth
100106
};

packages/auth/src/mfa/assertions/totp.ts

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,23 +171,41 @@ export class TotpMultiFactorAssertionImpl
171171
*/
172172
export class TotpSecret {
173173
/**
174-
* Constructor for TotpSecret.
175-
* @param secretKey - Shared secret key/seed used for enrolling in TOTP MFA and generating otps.
176-
* @param hashingAlgorithm - Hashing algorithm used.
177-
* @param codeLength - Length of the one-time passwords to be generated.
178-
* @param codeIntervalSeconds - The interval (in seconds) when the OTP codes should change.
174+
* Shared secret key/seed used for enrolling in TOTP MFA and generating otps.
179175
*/
176+
readonly secretKey: string;
177+
/**
178+
* Hashing algorithm used.
179+
*/
180+
readonly hashingAlgorithm: string;
181+
/**
182+
* Length of the one-time passwords to be generated.
183+
*/
184+
readonly codeLength: number;
185+
/**
186+
* The interval (in seconds) when the OTP codes should change.
187+
*/
188+
readonly codeIntervalSeconds: number;
189+
// TODO(prameshj) - make this public after API review.
190+
// This can be used by callers to show a countdown of when to enter OTP code by.
191+
private readonly finalizeEnrollmentBy: string;
192+
193+
// The public members are declared outside the constructor so the docs can be generated.
180194
private constructor(
181-
readonly secretKey: string,
182-
readonly hashingAlgorithm: string,
183-
readonly codeLength: number,
184-
readonly codeIntervalSeconds: number,
185-
// TODO(prameshj) - make this public after API review.
186-
// This can be used by callers to show a countdown of when to enter OTP code by.
187-
private readonly finalizeEnrollmentBy: string,
195+
secretKey: string,
196+
hashingAlgorithm: string,
197+
codeLength: number,
198+
codeIntervalSeconds: number,
199+
finalizeEnrollmentBy: string,
188200
private readonly sessionInfo: string,
189201
private readonly auth: AuthInternal
190-
) {}
202+
) {
203+
this.secretKey = secretKey;
204+
this.hashingAlgorithm = hashingAlgorithm;
205+
this.codeLength = codeLength;
206+
this.codeIntervalSeconds = codeIntervalSeconds;
207+
this.finalizeEnrollmentBy = finalizeEnrollmentBy;
208+
}
191209

192210
/** @internal */
193211
static _fromStartTotpMfaEnrollmentResponse(

0 commit comments

Comments
 (0)