File tree Expand file tree Collapse file tree 3 files changed +35
-11
lines changed
android/src/main/java/io/invertase/firebase/auth Expand file tree Collapse file tree 3 files changed +35
-11
lines changed Original file line number Diff line number Diff line change @@ -1305,6 +1305,23 @@ public void finalizeMultiFactorEnrollment(
13051305 });
13061306 }
13071307
1308+ @ ReactMethod
1309+ public void generateQrCodeUrl (
1310+ final String appName ,
1311+ final String secretKey ,
1312+ final String account ,
1313+ final String issuer ,
1314+ final Promise promise ) {
1315+
1316+ TotpSecret secret = mTotpSecrets .get (secretKey );
1317+ if (secret == null ) {
1318+ rejectPromiseWithCodeAndMessage (
1319+ promise , "invalid-multi-factor-secret" , "can't find secret for provided key" );
1320+ return ;
1321+ }
1322+ promise .resolve (secret .generateQrCodeUrl (account , issuer ));
1323+ }
1324+
13081325 @ ReactMethod
13091326 public void finalizeTotpEnrollment (
13101327 final String appName ,
Original file line number Diff line number Diff line change @@ -1026,6 +1026,21 @@ - (void)invalidate {
10261026 }];
10271027}
10281028
1029+ RCT_EXPORT_METHOD (generateQrCodeUrl
1030+ : (FIRApp *)firebaseApp
1031+ : (NSString *)secretKey
1032+ : (NSString *)accountName
1033+ : (NSString *)issuer
1034+ : (RCTPromiseResolveBlock)resolve
1035+ : (RCTPromiseRejectBlock)reject) {
1036+ DLog (@" generateQrCodeUrl using instance resolve generateQrCodeUrl: %@ " , firebaseApp.name );
1037+ DLog (@" generateQrCodeUrl using secretKey: %@ " , secretKey);
1038+ FIRTOTPSecret *totpSecret = cachedTotpSecrets[secretKey];
1039+ NSString *url = [totpSecret generateQRCodeURLWithAccountName: accountName issuer: issuer];
1040+ DLog (@" generateQrCodeUrl got QR Code URL %@ " , url);
1041+ resolve (url);
1042+ }
1043+
10291044RCT_EXPORT_METHOD (getSession
10301045 : (FIRApp *)firebaseApp
10311046 : (RCTPromiseResolveBlock)resolve
Original file line number Diff line number Diff line change @@ -44,17 +44,9 @@ export class TotpSecret {
4444 *
4545 * @param accountName the name of the account/app along with a user identifier.
4646 * @param issuer issuer of the TOTP (likely the app name).
47- * @returns A QR code URL string.
47+ * @returns A Promise that resolves to a QR code URL string.
4848 */
49- generateQrCodeUrl ( _accountName , _issuer ) {
50- throw new Error ( '`generateQrCodeUrl` is not supported on the native Firebase SDKs.' ) ;
51- // if (!this.hashingAlgorithm || !this.codeLength) {
52- // return "";
53- // }
54-
55- // return (
56- // `otpauth://totp/${issuer}:${accountName}?secret=${this.secretKey}&issuer=${issuer}` +
57- // `&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`
58- // );
49+ async generateQrCodeUrl ( accountName , issuer ) {
50+ return this . auth . native . generateQrCodeUrl ( this . secretKey , accountName , issuer ) ;
5951 }
6052}
You can’t perform that action at this time.
0 commit comments