|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2022 Google LLC |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +import { TotpSecret } from '../../platform_browser/mfa/assertions/totp'; |
| 18 | +import { |
| 19 | + TotpMultiFactorAssertion, |
| 20 | + MultiFactorSession, |
| 21 | + FactorId |
| 22 | +} from '../../model/public_types'; |
| 23 | +/** |
| 24 | + * Provider for generating a {@link TotpMultiFactorAssertion}. |
| 25 | + * |
| 26 | + * @public |
| 27 | + */ |
| 28 | +export class TotpMultiFactorGenerator { |
| 29 | + /** |
| 30 | + * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of |
| 31 | + * the totp(Time-based One Time Password) second factor. |
| 32 | + * This assertion is used to complete enrollment in TOTP second factor. |
| 33 | + * |
| 34 | + * @param secret {@link TotpSecret}. |
| 35 | + * @param oneTimePassword One-time password from TOTP App. |
| 36 | + * @returns A {@link TotpMultiFactorAssertion} which can be used with |
| 37 | + * {@link MultiFactorUser.enroll}. |
| 38 | + */ |
| 39 | + static assertionForEnrollment( |
| 40 | + _secret: TotpSecret, |
| 41 | + _oneTimePassword: string |
| 42 | + ): TotpMultiFactorAssertion { |
| 43 | + throw new Error('Unimplemented'); |
| 44 | + } |
| 45 | + /** |
| 46 | + * Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the totp second factor. |
| 47 | + * This assertion is used to complete signIn with TOTP as the second factor. |
| 48 | + * |
| 49 | + * @param enrollmentId identifies the enrolled TOTP second factor. |
| 50 | + * @param otp One-time password from TOTP App. |
| 51 | + * @returns A {@link TotpMultiFactorAssertion} which can be used with |
| 52 | + * {@link MultiFactorResolver.resolveSignIn}. |
| 53 | + */ |
| 54 | + static assertionForSignIn( |
| 55 | + _enrollmentId: string, |
| 56 | + _otp: string |
| 57 | + ): TotpMultiFactorAssertion { |
| 58 | + throw new Error('Unimplemented'); |
| 59 | + } |
| 60 | + /** |
| 61 | + * Returns a promise to {@link TOTPSecret} which contains the TOTP shared secret key and other parameters. |
| 62 | + * Creates a TOTP secret as part of enrolling a TOTP second factor. |
| 63 | + * Used for generating a QRCode URL or inputting into a TOTP App. |
| 64 | + * This method uses the auth instance corresponding to the user in the multiFactorSession. |
| 65 | + * |
| 66 | + * @param session A link to {@MultiFactorSession}. |
| 67 | + * @returns A promise to {@link TotpSecret}. |
| 68 | + */ |
| 69 | + static async generateSecret( |
| 70 | + _session: MultiFactorSession |
| 71 | + ): Promise<TotpSecret> { |
| 72 | + throw new Error('Unimplemented'); |
| 73 | + } |
| 74 | + /** |
| 75 | + * The identifier of the TOTP second factor: `totp`. |
| 76 | + */ |
| 77 | + static FACTOR_ID = FactorId.TOTP; |
| 78 | +} |
0 commit comments