(
id: string,
name: string,
issuer: string,
accountName: string,
)
| 158 | } |
| 159 | |
| 160 | static async createMethod( |
| 161 | id: string, |
| 162 | name: string, |
| 163 | issuer: string, |
| 164 | accountName: string, |
| 165 | ): Promise<MultiFactorAuthSetup> { |
| 166 | const secret = this.generateTOTPSecret(); |
| 167 | const backupCodes = this.generateBackupCodes(); |
| 168 | const qrCodeUrl = await this.generateQRCodeDataURL(secret, issuer, accountName); |
| 169 | |
| 170 | const encryptedSecret = await this.encryptTOTPSecret(secret); |
| 171 | const hashedBackupCodes = await this.hashBackupCodes(backupCodes); |
| 172 | |
| 173 | const method: MultiFactorAuthMethod = { |
| 174 | type: 'totp', |
| 175 | id, |
| 176 | name, |
| 177 | enabled: false, |
| 178 | created_at: new Date(), |
| 179 | metadata: { |
| 180 | totp: { |
| 181 | hashed_secret: encryptedSecret, |
| 182 | hashed_backup_codes: hashedBackupCodes, |
| 183 | }, |
| 184 | }, |
| 185 | }; |
| 186 | |
| 187 | return { |
| 188 | method, |
| 189 | qrCodeUrl, |
| 190 | plainTextSecret: secret, |
| 191 | plainTextBackupCodes: backupCodes, |
| 192 | }; |
| 193 | } |
| 194 | |
| 195 | static async verifyMethodToken( |
| 196 | metadata: MultiFactorAuthMethod['metadata'], |
no test coverage detected