@react-native-firebase/auth 24.1.1 → 25.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java +16 -4
  3. package/dist/module/ActionCodeURL.js +140 -0
  4. package/dist/module/ActionCodeURL.js.map +1 -0
  5. package/{lib → dist/module}/ConfirmationResult.js +4 -5
  6. package/dist/module/ConfirmationResult.js.map +1 -0
  7. package/{lib → dist/module}/MultiFactorResolver.js +14 -5
  8. package/dist/module/MultiFactorResolver.js.map +1 -0
  9. package/{lib → dist/module}/PhoneAuthListener.js +52 -75
  10. package/dist/module/PhoneAuthListener.js.map +1 -0
  11. package/dist/module/PhoneAuthState.js +25 -0
  12. package/dist/module/PhoneAuthState.js.map +1 -0
  13. package/dist/module/PhoneMultiFactorGenerator.js +39 -0
  14. package/dist/module/PhoneMultiFactorGenerator.js.map +1 -0
  15. package/{lib → dist/module}/Settings.js +3 -7
  16. package/dist/module/Settings.js.map +1 -0
  17. package/{lib → dist/module}/TotpMultiFactorGenerator.js +20 -15
  18. package/dist/module/TotpMultiFactorGenerator.js.map +1 -0
  19. package/{lib → dist/module}/TotpSecret.js +7 -5
  20. package/dist/module/TotpSecret.js.map +1 -0
  21. package/dist/module/User.js +245 -0
  22. package/dist/module/User.js.map +1 -0
  23. package/dist/module/constants.js +54 -0
  24. package/dist/module/constants.js.map +1 -0
  25. package/dist/module/credentials/AuthCredential.js +51 -0
  26. package/dist/module/credentials/AuthCredential.js.map +1 -0
  27. package/dist/module/credentials/EmailAuthCredential.js +51 -0
  28. package/dist/module/credentials/EmailAuthCredential.js.map +1 -0
  29. package/dist/module/credentials/OAuthCredential.js +84 -0
  30. package/dist/module/credentials/OAuthCredential.js.map +1 -0
  31. package/dist/module/credentials/PhoneAuthCredential.js +50 -0
  32. package/dist/module/credentials/PhoneAuthCredential.js.map +1 -0
  33. package/{lib/providers/GoogleAuthProvider.js → dist/module/credentials/index.js} +7 -19
  34. package/dist/module/credentials/index.js.map +1 -0
  35. package/{lib → dist/module}/getMultiFactorResolver.js +5 -8
  36. package/dist/module/getMultiFactorResolver.js.map +1 -0
  37. package/{lib/providers/FacebookAuthProvider.js → dist/module/index.js} +11 -18
  38. package/dist/module/index.js.map +1 -0
  39. package/dist/module/modular.js +793 -0
  40. package/dist/module/modular.js.map +1 -0
  41. package/{lib → dist/module}/multiFactor.js +16 -14
  42. package/dist/module/multiFactor.js.map +1 -0
  43. package/dist/module/namespaced.js +522 -0
  44. package/dist/module/namespaced.js.map +1 -0
  45. package/dist/module/package.json +1 -0
  46. package/dist/module/password-policy/PasswordPolicyImpl.js +103 -0
  47. package/dist/module/password-policy/PasswordPolicyImpl.js.map +1 -0
  48. package/{lib → dist/module}/password-policy/PasswordPolicyMixin.js +14 -16
  49. package/dist/module/password-policy/PasswordPolicyMixin.js.map +1 -0
  50. package/{lib → dist/module}/password-policy/passwordPolicyApi.js +18 -12
  51. package/dist/module/password-policy/passwordPolicyApi.js.map +1 -0
  52. package/{lib → dist/module}/providers/AppleAuthProvider.js +14 -7
  53. package/dist/module/providers/AppleAuthProvider.js.map +1 -0
  54. package/{lib → dist/module}/providers/EmailAuthProvider.js +10 -25
  55. package/dist/module/providers/EmailAuthProvider.js.map +1 -0
  56. package/dist/module/providers/FacebookAuthProvider.js +56 -0
  57. package/dist/module/providers/FacebookAuthProvider.js.map +1 -0
  58. package/dist/module/providers/GithubAuthProvider.js +49 -0
  59. package/dist/module/providers/GithubAuthProvider.js.map +1 -0
  60. package/dist/module/providers/GoogleAuthProvider.js +57 -0
  61. package/dist/module/providers/GoogleAuthProvider.js.map +1 -0
  62. package/dist/module/providers/OAuthProvider.js +116 -0
  63. package/dist/module/providers/OAuthProvider.js.map +1 -0
  64. package/{lib → dist/module}/providers/OIDCAuthProvider.js +15 -7
  65. package/dist/module/providers/OIDCAuthProvider.js.map +1 -0
  66. package/dist/module/providers/PhoneAuthProvider.js +87 -0
  67. package/dist/module/providers/PhoneAuthProvider.js.map +1 -0
  68. package/dist/module/providers/TwitterAuthProvider.js +50 -0
  69. package/dist/module/providers/TwitterAuthProvider.js.map +1 -0
  70. package/dist/module/types/auth.js +43 -0
  71. package/dist/module/types/auth.js.map +1 -0
  72. package/dist/module/types/internal.js +4 -0
  73. package/dist/module/types/internal.js.map +1 -0
  74. package/dist/module/types/namespaced.js +62 -0
  75. package/dist/module/types/namespaced.js.map +1 -0
  76. package/dist/module/version.js +5 -0
  77. package/dist/module/version.js.map +1 -0
  78. package/dist/module/web/RNFBAuthModule.android.js +5 -0
  79. package/dist/module/web/RNFBAuthModule.android.js.map +1 -0
  80. package/dist/module/web/RNFBAuthModule.ios.js +5 -0
  81. package/dist/module/web/RNFBAuthModule.ios.js.map +1 -0
  82. package/{lib → dist/module}/web/RNFBAuthModule.js +104 -321
  83. package/dist/module/web/RNFBAuthModule.js.map +1 -0
  84. package/dist/typescript/lib/ActionCodeURL.d.ts +41 -0
  85. package/dist/typescript/lib/ActionCodeURL.d.ts.map +1 -0
  86. package/dist/typescript/lib/ConfirmationResult.d.ts +10 -0
  87. package/dist/typescript/lib/ConfirmationResult.d.ts.map +1 -0
  88. package/dist/typescript/lib/MultiFactorResolver.d.ts +24 -0
  89. package/dist/typescript/lib/MultiFactorResolver.d.ts.map +1 -0
  90. package/dist/typescript/lib/PhoneAuthListener.d.ts +34 -0
  91. package/dist/typescript/lib/PhoneAuthListener.d.ts.map +1 -0
  92. package/dist/typescript/lib/PhoneAuthState.d.ts +7 -0
  93. package/dist/typescript/lib/PhoneAuthState.d.ts.map +1 -0
  94. package/dist/typescript/lib/PhoneMultiFactorGenerator.d.ts +7 -0
  95. package/dist/typescript/lib/PhoneMultiFactorGenerator.d.ts.map +1 -0
  96. package/dist/typescript/lib/Settings.d.ts +13 -0
  97. package/dist/typescript/lib/Settings.d.ts.map +1 -0
  98. package/dist/typescript/lib/TotpMultiFactorGenerator.d.ts +11 -0
  99. package/dist/typescript/lib/TotpMultiFactorGenerator.d.ts.map +1 -0
  100. package/dist/typescript/lib/TotpSecret.d.ts +33 -0
  101. package/dist/typescript/lib/TotpSecret.d.ts.map +1 -0
  102. package/dist/typescript/lib/User.d.ts +51 -0
  103. package/dist/typescript/lib/User.d.ts.map +1 -0
  104. package/dist/typescript/lib/constants.d.ts +35 -0
  105. package/dist/typescript/lib/constants.d.ts.map +1 -0
  106. package/dist/typescript/lib/credentials/AuthCredential.d.ts +12 -0
  107. package/dist/typescript/lib/credentials/AuthCredential.d.ts.map +1 -0
  108. package/dist/typescript/lib/credentials/EmailAuthCredential.d.ts +8 -0
  109. package/dist/typescript/lib/credentials/EmailAuthCredential.d.ts.map +1 -0
  110. package/dist/typescript/lib/credentials/OAuthCredential.d.ts +22 -0
  111. package/dist/typescript/lib/credentials/OAuthCredential.d.ts.map +1 -0
  112. package/dist/typescript/lib/credentials/PhoneAuthCredential.d.ts +8 -0
  113. package/dist/typescript/lib/credentials/PhoneAuthCredential.d.ts.map +1 -0
  114. package/dist/typescript/lib/credentials/index.d.ts +5 -0
  115. package/dist/typescript/lib/credentials/index.d.ts.map +1 -0
  116. package/dist/typescript/lib/getMultiFactorResolver.d.ts +19 -0
  117. package/dist/typescript/lib/getMultiFactorResolver.d.ts.map +1 -0
  118. package/dist/typescript/lib/index.d.ts +8 -0
  119. package/dist/typescript/lib/index.d.ts.map +1 -0
  120. package/dist/typescript/lib/modular.d.ts +370 -0
  121. package/dist/typescript/lib/modular.d.ts.map +1 -0
  122. package/dist/typescript/lib/multiFactor.d.ts +26 -0
  123. package/dist/typescript/lib/multiFactor.d.ts.map +1 -0
  124. package/dist/typescript/lib/namespaced.d.ts +12 -0
  125. package/dist/typescript/lib/namespaced.d.ts.map +1 -0
  126. package/dist/typescript/lib/password-policy/PasswordPolicyImpl.d.ts +19 -0
  127. package/dist/typescript/lib/password-policy/PasswordPolicyImpl.d.ts.map +1 -0
  128. package/dist/typescript/lib/password-policy/PasswordPolicyMixin.d.ts +11 -0
  129. package/dist/typescript/lib/password-policy/PasswordPolicyMixin.d.ts.map +1 -0
  130. package/dist/typescript/lib/password-policy/passwordPolicyApi.d.ts +10 -0
  131. package/dist/typescript/lib/password-policy/passwordPolicyApi.d.ts.map +1 -0
  132. package/dist/typescript/lib/providers/AppleAuthProvider.d.ts +16 -0
  133. package/dist/typescript/lib/providers/AppleAuthProvider.d.ts.map +1 -0
  134. package/dist/typescript/lib/providers/EmailAuthProvider.d.ts +11 -0
  135. package/dist/typescript/lib/providers/EmailAuthProvider.d.ts.map +1 -0
  136. package/dist/typescript/lib/providers/FacebookAuthProvider.d.ts +19 -0
  137. package/dist/typescript/lib/providers/FacebookAuthProvider.d.ts.map +1 -0
  138. package/dist/typescript/lib/providers/GithubAuthProvider.d.ts +15 -0
  139. package/dist/typescript/lib/providers/GithubAuthProvider.d.ts.map +1 -0
  140. package/dist/typescript/lib/providers/GoogleAuthProvider.d.ts +21 -0
  141. package/dist/typescript/lib/providers/GoogleAuthProvider.d.ts.map +1 -0
  142. package/dist/typescript/lib/providers/OAuthProvider.d.ts +33 -0
  143. package/dist/typescript/lib/providers/OAuthProvider.d.ts.map +1 -0
  144. package/dist/typescript/lib/providers/OIDCAuthProvider.d.ts +16 -0
  145. package/dist/typescript/lib/providers/OIDCAuthProvider.d.ts.map +1 -0
  146. package/dist/typescript/lib/providers/PhoneAuthProvider.d.ts +16 -0
  147. package/dist/typescript/lib/providers/PhoneAuthProvider.d.ts.map +1 -0
  148. package/dist/typescript/lib/providers/TwitterAuthProvider.d.ts +15 -0
  149. package/dist/typescript/lib/providers/TwitterAuthProvider.d.ts.map +1 -0
  150. package/dist/typescript/lib/types/auth.d.ts +305 -0
  151. package/dist/typescript/lib/types/auth.d.ts.map +1 -0
  152. package/dist/typescript/lib/types/internal.d.ts +293 -0
  153. package/dist/typescript/lib/types/internal.d.ts.map +1 -0
  154. package/dist/typescript/lib/types/namespaced.d.ts +2185 -0
  155. package/dist/typescript/lib/types/namespaced.d.ts.map +1 -0
  156. package/dist/typescript/lib/version.d.ts +2 -0
  157. package/dist/typescript/lib/version.d.ts.map +1 -0
  158. package/dist/typescript/lib/web/RNFBAuthModule.android.d.ts +3 -0
  159. package/dist/typescript/lib/web/RNFBAuthModule.android.d.ts.map +1 -0
  160. package/dist/typescript/lib/web/RNFBAuthModule.d.ts +406 -0
  161. package/dist/typescript/lib/web/RNFBAuthModule.d.ts.map +1 -0
  162. package/dist/typescript/lib/web/RNFBAuthModule.ios.d.ts +3 -0
  163. package/dist/typescript/lib/web/RNFBAuthModule.ios.d.ts.map +1 -0
  164. package/dist/typescript/package.json +1 -0
  165. package/ios/RNFBAuth/RNFBAuthModule.m +4 -2
  166. package/lib/ActionCodeURL.ts +174 -0
  167. package/lib/ConfirmationResult.ts +42 -0
  168. package/lib/MultiFactorResolver.ts +51 -0
  169. package/lib/PhoneAuthListener.ts +312 -0
  170. package/lib/PhoneAuthState.ts +22 -0
  171. package/lib/{PhoneMultiFactorGenerator.js → PhoneMultiFactorGenerator.ts} +8 -2
  172. package/lib/Settings.ts +59 -0
  173. package/lib/TotpMultiFactorGenerator.ts +78 -0
  174. package/lib/TotpSecret.ts +71 -0
  175. package/lib/{User.js → User.ts} +127 -83
  176. package/lib/constants.ts +55 -0
  177. package/lib/credentials/AuthCredential.ts +55 -0
  178. package/lib/credentials/EmailAuthCredential.ts +70 -0
  179. package/lib/credentials/OAuthCredential.ts +113 -0
  180. package/lib/credentials/PhoneAuthCredential.ts +66 -0
  181. package/lib/{providers/GithubAuthProvider.js → credentials/index.ts} +4 -19
  182. package/lib/getMultiFactorResolver.ts +40 -0
  183. package/lib/{providers/TwitterAuthProvider.js → index.ts} +14 -19
  184. package/lib/modular.ts +1172 -0
  185. package/lib/multiFactor.ts +83 -0
  186. package/lib/namespaced.ts +846 -0
  187. package/lib/password-policy/{PasswordPolicyImpl.js → PasswordPolicyImpl.ts} +37 -19
  188. package/lib/password-policy/PasswordPolicyMixin.ts +83 -0
  189. package/lib/password-policy/passwordPolicyApi.ts +60 -0
  190. package/lib/providers/AppleAuthProvider.ts +44 -0
  191. package/lib/providers/EmailAuthProvider.ts +42 -0
  192. package/lib/providers/FacebookAuthProvider.ts +58 -0
  193. package/lib/providers/GithubAuthProvider.ts +51 -0
  194. package/lib/providers/GoogleAuthProvider.ts +60 -0
  195. package/lib/providers/OAuthProvider.ts +150 -0
  196. package/lib/providers/OIDCAuthProvider.ts +49 -0
  197. package/lib/providers/PhoneAuthProvider.ts +161 -0
  198. package/lib/providers/TwitterAuthProvider.ts +52 -0
  199. package/lib/types/auth.ts +393 -0
  200. package/lib/types/internal.ts +475 -0
  201. package/lib/{index.d.ts → types/namespaced.ts} +52 -41
  202. package/lib/version.ts +2 -0
  203. package/lib/web/RNFBAuthModule.ts +1359 -0
  204. package/package.json +41 -9
  205. package/plugin/tsconfig.tsbuildinfo +1 -1
  206. package/tsconfig.json +26 -0
  207. package/tsdoc.json +22 -0
  208. package/typedoc.json +9 -2
  209. package/lib/index.js +0 -572
  210. package/lib/modular/index.d.ts +0 -801
  211. package/lib/modular/index.js +0 -651
  212. package/lib/providers/OAuthProvider.js +0 -70
  213. package/lib/providers/PhoneAuthProvider.js +0 -52
  214. package/lib/version.js +0 -2
  215. /package/lib/web/{RNFBAuthModule.android.js → RNFBAuthModule.android.ts} +0 -0
  216. /package/lib/web/{RNFBAuthModule.ios.js → RNFBAuthModule.ios.ts} +0 -0
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import { AuthCredential } from '../credentials';
19
+ import type { AuthCredential as AuthCredentialType } from '../types/auth';
20
+
21
+ const providerId = 'oidc.' as const;
22
+
23
+ /**
24
+ * @deprecated Use {@link OAuthProvider} with provider ID `oidc.<your-provider-id>` instead.
25
+ *
26
+ * @example
27
+ * ```js
28
+ * const provider = new OAuthProvider('oidc.sample-provider');
29
+ * const credential = provider.credential({ idToken, accessToken });
30
+ * ```
31
+ */
32
+ export default class OIDCAuthProvider {
33
+ constructor() {
34
+ throw new Error('`new OIDCAuthProvider()` is not supported on the native Firebase SDKs.');
35
+ }
36
+
37
+ static get PROVIDER_ID() {
38
+ return providerId;
39
+ }
40
+
41
+ static credential(
42
+ oidcSuffix: string,
43
+ idToken: string,
44
+ accessToken?: string,
45
+ ): AuthCredentialType {
46
+ const resolvedProviderId = providerId + oidcSuffix;
47
+ return new AuthCredential(resolvedProviderId, resolvedProviderId, idToken, accessToken ?? '');
48
+ }
49
+ }
@@ -0,0 +1,161 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import { createPhoneAuthCredential } from '../credentials';
19
+ import type {
20
+ ApplicationVerifier,
21
+ Auth,
22
+ AuthError,
23
+ MultiFactorInfo,
24
+ PhoneAuthCredential,
25
+ PhoneAuthListener,
26
+ PhoneInfoOptions,
27
+ PhoneMultiFactorEnrollInfoOptions,
28
+ PhoneMultiFactorSignInInfoOptions,
29
+ PhoneSingleFactorInfoOptions,
30
+ UserCredential,
31
+ } from '../types/auth';
32
+
33
+ // Keep the SDK helper signature name while mapping to RNFB's native auth error type.
34
+ type FirebaseError = AuthError;
35
+
36
+ const providerId = 'phone' as const;
37
+
38
+ type PhoneAuthProviderAuth = {
39
+ app: {
40
+ auth(): {
41
+ verifyPhoneNumber(phoneNumber: string): PhoneAuthListener;
42
+ verifyPhoneNumberWithMultiFactorInfo(
43
+ hint: Pick<MultiFactorInfo, 'uid'>,
44
+ session: PhoneMultiFactorSignInInfoOptions['session'],
45
+ ): Promise<string>;
46
+ verifyPhoneNumberForMultiFactor(
47
+ phoneInfoOptions: PhoneMultiFactorEnrollInfoOptions,
48
+ ): Promise<string>;
49
+ };
50
+ };
51
+ };
52
+
53
+ function isPhoneMultiFactorSignInOptions(
54
+ phoneInfoOptions: PhoneInfoOptions,
55
+ ): phoneInfoOptions is PhoneMultiFactorSignInInfoOptions {
56
+ return (
57
+ 'session' in phoneInfoOptions &&
58
+ (('multiFactorHint' in phoneInfoOptions && phoneInfoOptions.multiFactorHint !== undefined) ||
59
+ ('multiFactorUid' in phoneInfoOptions && phoneInfoOptions.multiFactorUid !== undefined))
60
+ );
61
+ }
62
+
63
+ function isPhoneMultiFactorEnrollOptions(
64
+ phoneInfoOptions: PhoneInfoOptions,
65
+ ): phoneInfoOptions is PhoneMultiFactorEnrollInfoOptions {
66
+ return 'phoneNumber' in phoneInfoOptions && 'session' in phoneInfoOptions;
67
+ }
68
+
69
+ function isPhoneSingleFactorOptions(
70
+ phoneInfoOptions: PhoneInfoOptions,
71
+ ): phoneInfoOptions is PhoneSingleFactorInfoOptions {
72
+ return 'phoneNumber' in phoneInfoOptions;
73
+ }
74
+
75
+ function verificationIdFromListener(listener: PhoneAuthListener): Promise<string> {
76
+ return new Promise((resolve, reject) => {
77
+ listener.on(
78
+ 'state_changed',
79
+ snapshot => {
80
+ if (snapshot.error) {
81
+ reject(snapshot.error);
82
+ return;
83
+ }
84
+
85
+ if (snapshot.verificationId) {
86
+ resolve(snapshot.verificationId);
87
+ }
88
+ },
89
+ error => reject(error),
90
+ );
91
+ });
92
+ }
93
+
94
+ export default class PhoneAuthProvider {
95
+ static readonly PHONE_SIGN_IN_METHOD: 'phone' = providerId;
96
+ static readonly PROVIDER_ID: 'phone' = providerId;
97
+
98
+ readonly providerId = providerId;
99
+
100
+ private readonly _auth: PhoneAuthProviderAuth;
101
+
102
+ constructor(auth: Auth) {
103
+ if (auth === undefined) {
104
+ throw new Error('`new PhoneAuthProvider()` is not supported on the native Firebase SDKs.');
105
+ }
106
+ this._auth = auth as unknown as PhoneAuthProviderAuth;
107
+ }
108
+
109
+ static credential(verificationId: string, code: string): PhoneAuthCredential {
110
+ return createPhoneAuthCredential(verificationId, code);
111
+ }
112
+
113
+ static credentialFromResult(_userCredential: UserCredential): PhoneAuthCredential | null {
114
+ return null;
115
+ }
116
+
117
+ static credentialFromError(_error: FirebaseError): PhoneAuthCredential | null {
118
+ return null;
119
+ }
120
+
121
+ verifyPhoneNumber(
122
+ phoneInfoOptions: PhoneInfoOptions | string,
123
+ appVerifier: ApplicationVerifier,
124
+ ): Promise<string>;
125
+ verifyPhoneNumber(
126
+ phoneInfoOptions: PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions,
127
+ ): Promise<string>;
128
+ verifyPhoneNumber(
129
+ phoneInfoOptions: PhoneInfoOptions | string,
130
+ // Native SDKs own app verification, so the JS SDK verifier is accepted for type parity only.
131
+ _appVerifier?: ApplicationVerifier,
132
+ ): Promise<string> {
133
+ if (typeof phoneInfoOptions === 'string') {
134
+ return verificationIdFromListener(this._auth.app.auth().verifyPhoneNumber(phoneInfoOptions));
135
+ }
136
+
137
+ if (isPhoneMultiFactorSignInOptions(phoneInfoOptions)) {
138
+ const multiFactorHint = phoneInfoOptions.multiFactorHint ?? {
139
+ uid: phoneInfoOptions.multiFactorUid!,
140
+ };
141
+
142
+ return this._auth.app
143
+ .auth()
144
+ .verifyPhoneNumberWithMultiFactorInfo(multiFactorHint, phoneInfoOptions.session);
145
+ }
146
+
147
+ if (isPhoneMultiFactorEnrollOptions(phoneInfoOptions)) {
148
+ return this._auth.app.auth().verifyPhoneNumberForMultiFactor(phoneInfoOptions);
149
+ }
150
+
151
+ if (isPhoneSingleFactorOptions(phoneInfoOptions)) {
152
+ return verificationIdFromListener(
153
+ this._auth.app.auth().verifyPhoneNumber(phoneInfoOptions.phoneNumber),
154
+ );
155
+ }
156
+
157
+ throw new Error(
158
+ '`PhoneAuthProvider.verifyPhoneNumber()` requires a phone number, phone info options, or multi-factor phone info.',
159
+ );
160
+ }
161
+ }
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import { OAuthCredential } from '../credentials';
19
+ import type { AuthError, UserCredential } from '../types/auth';
20
+
21
+ // Keep the SDK helper signature name while mapping to RNFB's native auth error type.
22
+ type FirebaseError = AuthError;
23
+
24
+ const providerId = 'twitter.com' as const;
25
+
26
+ export default class TwitterAuthProvider {
27
+ static readonly TWITTER_SIGN_IN_METHOD: 'twitter.com' = providerId;
28
+ static readonly PROVIDER_ID: 'twitter.com' = providerId;
29
+
30
+ constructor() {
31
+ throw new Error('`new TwitterAuthProvider()` is not supported on the native Firebase SDKs.');
32
+ }
33
+
34
+ static credential(token: string, secret: string): OAuthCredential {
35
+ return new OAuthCredential(providerId, {
36
+ accessToken: token,
37
+ secret,
38
+ bridgeToken: token,
39
+ bridgeSecret: secret,
40
+ });
41
+ }
42
+
43
+ /** @remarks Always returns `null` on React Native Firebase. */
44
+ static credentialFromResult(_userCredential: UserCredential): OAuthCredential | null {
45
+ return null;
46
+ }
47
+
48
+ /** @remarks Always returns `null` on React Native Firebase. */
49
+ static credentialFromError(_error: FirebaseError): OAuthCredential | null {
50
+ return null;
51
+ }
52
+ }
@@ -0,0 +1,393 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import type { FirebaseApp, ReactNativeFirebase } from '@react-native-firebase/app';
19
+ import type { ActionCodeOperation, FactorId, OperationType } from '../constants';
20
+ import type {
21
+ AuthCredential,
22
+ EmailAuthCredential,
23
+ OAuthCredential,
24
+ PhoneAuthCredential,
25
+ } from '../credentials';
26
+
27
+ export type { AuthCredential, EmailAuthCredential, OAuthCredential, PhoneAuthCredential };
28
+
29
+ export type CompleteFn = () => void;
30
+ export type ErrorFn = (error: Error) => void;
31
+ export type NextFn<T> = (value: T) => void;
32
+ export type Unsubscribe = () => void;
33
+
34
+ interface Observer<T> {
35
+ next?: NextFn<T> | null;
36
+ error?: ErrorFn | null;
37
+ complete?: CompleteFn | null;
38
+ }
39
+
40
+ export interface Auth {
41
+ readonly app: FirebaseApp;
42
+ readonly name: string;
43
+ /** @remarks Always returns `{}` at runtime. Native iOS/Android Firebase Auth SDKs do not expose the web config object. */
44
+ readonly config: Config;
45
+ /**
46
+ * @remarks
47
+ * **Not supported on React Native Firebase.** The modular {@link setPersistence} helper always throws
48
+ * synchronously because auth state is managed by the native SDKs.
49
+ */
50
+ setPersistence(persistence: Persistence): Promise<void>;
51
+ languageCode: string | null;
52
+ /** Writable tenant ID. Assigning a value delegates to `setTenantId`. */
53
+ tenantId: string | null;
54
+ readonly settings: AuthSettings;
55
+ onAuthStateChanged(
56
+ nextOrObserver: NextOrObserver<User | null>,
57
+ error?: ErrorFn,
58
+ completed?: CompleteFn,
59
+ ): Unsubscribe;
60
+ beforeAuthStateChanged(
61
+ callback: (user: User | null) => void | Promise<void>,
62
+ onAbort?: () => void,
63
+ ): Unsubscribe;
64
+ onIdTokenChanged(
65
+ nextOrObserver: NextOrObserver<User | null>,
66
+ error?: ErrorFn,
67
+ completed?: CompleteFn,
68
+ ): Unsubscribe;
69
+ /** Resolves when the initial auth state has been determined. */
70
+ authStateReady(): Promise<void>;
71
+ readonly currentUser: User | null;
72
+ /** Populated after {@link connectAuthEmulator} is called; otherwise `null`. */
73
+ readonly emulatorConfig: EmulatorConfig | null;
74
+ updateCurrentUser(user: User | null): Promise<void>;
75
+ /**
76
+ * @remarks
77
+ * **Not supported on React Native Firebase.** Always throws synchronously. Set `languageCode`
78
+ * directly or use {@link setLanguageCode}.
79
+ */
80
+ useDeviceLanguage(): void;
81
+ signOut(): Promise<void>;
82
+ }
83
+
84
+ export interface AuthError extends ReactNativeFirebase.NativeFirebaseError {
85
+ readonly customData: {
86
+ readonly appName: string;
87
+ readonly email?: string;
88
+ readonly phoneNumber?: string;
89
+ readonly tenantId?: string;
90
+ };
91
+ }
92
+
93
+ export interface NativeFirebaseAuthError extends ReactNativeFirebase.NativeFirebaseError {
94
+ readonly userInfo: {
95
+ readonly authCredential: AuthCredential | null;
96
+ readonly resolver: MultiFactorResolver | null;
97
+ };
98
+ }
99
+
100
+ /**
101
+ * @deprecated Use {@link OAuthProvider} with provider ID `oidc.<suffix>` instead.
102
+ */
103
+ export interface OIDCProvider {
104
+ readonly PROVIDER_ID: string;
105
+ credential(oidcSuffix: string, idToken: string): AuthCredential;
106
+ }
107
+ export interface MultiFactorError extends AuthError {
108
+ readonly customData: AuthError['customData'] & {
109
+ readonly operationType: (typeof OperationType)[keyof typeof OperationType];
110
+ };
111
+ }
112
+ export interface PhoneAuthSnapshot {
113
+ readonly state: 'sent' | 'timeout' | 'verified' | 'error';
114
+ readonly verificationId: string;
115
+ readonly code: string | null;
116
+ readonly error: ReactNativeFirebase.NativeFirebaseError | null;
117
+ }
118
+
119
+ export interface PhoneAuthError {
120
+ readonly code: string | null;
121
+ readonly verificationId: string;
122
+ readonly message: string | null;
123
+ readonly stack: string | null;
124
+ }
125
+
126
+ export interface PhoneAuthListener {
127
+ on(
128
+ event: string,
129
+ observer: (snapshot: PhoneAuthSnapshot) => void,
130
+ errorCb?: (error: PhoneAuthError) => void,
131
+ successCb?: (snapshot: PhoneAuthSnapshot) => void,
132
+ ): PhoneAuthListener;
133
+ then(
134
+ onFulfilled?: ((value: PhoneAuthSnapshot) => any) | null,
135
+ onRejected?: ((error: ReactNativeFirebase.NativeFirebaseError) => any) | null,
136
+ ): Promise<any>;
137
+ catch(onRejected: (error: ReactNativeFirebase.NativeFirebaseError) => any): Promise<any>;
138
+ }
139
+
140
+ export { ActionCodeURL } from '../ActionCodeURL';
141
+
142
+ /**
143
+ * Firebase JS SDK auth configuration. Native iOS/Android Firebase Auth SDKs do not expose
144
+ * this object, so {@link Auth.config} always returns an empty object on React Native.
145
+ */
146
+ export interface Config {
147
+ apiKey: string;
148
+ apiHost: string;
149
+ apiScheme: string;
150
+ tokenApiHost: string;
151
+ sdkClientVersion: string;
152
+ authDomain?: string;
153
+ }
154
+
155
+ export interface AuthErrorMap {}
156
+
157
+ export interface PopupRedirectResolver {}
158
+
159
+ export interface Dependencies {
160
+ persistence?: Persistence | Persistence[];
161
+ popupRedirectResolver?: PopupRedirectResolver;
162
+ errorMap?: AuthErrorMap;
163
+ }
164
+
165
+ export interface ApplicationVerifier {
166
+ readonly type: string;
167
+ verify(): Promise<string>;
168
+ }
169
+
170
+ export type CustomParameters = Record<string, string>;
171
+
172
+ export interface OAuthCredentialOptions {
173
+ idToken?: string;
174
+ accessToken?: string;
175
+ rawNonce?: string;
176
+ }
177
+
178
+ export interface AuthProvider {
179
+ readonly providerId: string;
180
+ }
181
+
182
+ export interface AuthSettings {
183
+ appVerificationDisabledForTesting: boolean;
184
+ }
185
+
186
+ export interface EmulatorConfig {
187
+ readonly protocol: string;
188
+ readonly host: string;
189
+ readonly port: number | null;
190
+ readonly options: {
191
+ readonly disableWarnings: boolean;
192
+ };
193
+ }
194
+
195
+ export interface PasswordPolicy {
196
+ readonly customStrengthOptions: {
197
+ readonly minPasswordLength?: number;
198
+ readonly maxPasswordLength?: number;
199
+ readonly containsLowercaseLetter?: boolean;
200
+ readonly containsUppercaseLetter?: boolean;
201
+ readonly containsNumericCharacter?: boolean;
202
+ readonly containsNonAlphanumericCharacter?: boolean;
203
+ };
204
+ readonly allowedNonAlphanumericCharacters: string;
205
+ readonly enforcementState: string;
206
+ readonly forceUpgradeOnSignin: boolean;
207
+ }
208
+
209
+ export interface PasswordValidationStatus {
210
+ readonly isValid: boolean;
211
+ readonly meetsMinPasswordLength?: boolean;
212
+ readonly meetsMaxPasswordLength?: boolean;
213
+ readonly containsLowercaseLetter?: boolean;
214
+ readonly containsUppercaseLetter?: boolean;
215
+ readonly containsNumericCharacter?: boolean;
216
+ readonly containsNonAlphanumericCharacter?: boolean;
217
+ readonly passwordPolicy: PasswordPolicy;
218
+ }
219
+
220
+ export interface Persistence {
221
+ readonly type: 'SESSION' | 'LOCAL' | 'NONE' | 'COOKIE';
222
+ }
223
+
224
+ export type NextOrObserver<T> = NextFn<T | null> | Observer<T | null>;
225
+
226
+ // Keep these quoted to match the firebase-js-sdk declaration text used by compare-types.
227
+ // prettier-ignore
228
+ export interface ParsedToken {
229
+ 'exp'?: string;
230
+ 'sub'?: string;
231
+ 'auth_time'?: string;
232
+ 'iat'?: string;
233
+ 'firebase'?: {
234
+ 'sign_in_provider'?: string;
235
+ 'sign_in_second_factor'?: string;
236
+ 'identities'?: Record<string, string>;
237
+ };
238
+ [key: string]: unknown;
239
+ }
240
+
241
+ export type UserProfile = Record<string, unknown>;
242
+
243
+ export interface AdditionalUserInfo {
244
+ readonly isNewUser: boolean;
245
+ readonly profile: Record<string, unknown> | null;
246
+ readonly providerId: string | null;
247
+ readonly username?: string | null;
248
+ }
249
+
250
+ /**
251
+ * firebase-js-sdk `AdditionalUserInfo` fields plus any extra keys returned by the native bridge.
252
+ * Extra keys are preserved for backwards compatibility when native adds provider-specific fields.
253
+ */
254
+ export type AdditionalUserInfoNative = AdditionalUserInfo & Record<string, unknown>;
255
+
256
+ export interface UserInfo {
257
+ readonly displayName: string | null;
258
+ readonly email: string | null;
259
+ readonly phoneNumber: string | null;
260
+ readonly photoURL: string | null;
261
+ readonly providerId: string;
262
+ readonly uid: string;
263
+ }
264
+
265
+ export interface UserMetadata {
266
+ readonly creationTime?: string;
267
+ readonly lastSignInTime?: string;
268
+ }
269
+
270
+ export interface IdTokenResult {
271
+ authTime: string;
272
+ expirationTime: string;
273
+ issuedAtTime: string;
274
+ signInProvider: string | null;
275
+ signInSecondFactor: string | null;
276
+ token: string;
277
+ claims: ParsedToken;
278
+ }
279
+
280
+ export interface User extends UserInfo {
281
+ readonly emailVerified: boolean;
282
+ readonly isAnonymous: boolean;
283
+ readonly metadata: UserMetadata;
284
+ readonly providerData: UserInfo[];
285
+ readonly refreshToken: string;
286
+ readonly tenantId: string | null;
287
+ delete(): Promise<void>;
288
+ getIdToken(forceRefresh?: boolean): Promise<string>;
289
+ getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
290
+ reload(): Promise<void>;
291
+ toJSON(): object;
292
+ }
293
+
294
+ /**
295
+ * @remarks Modular helpers populate top-level `providerId` and `operationType`. When present,
296
+ * `additionalUserInfo` is enumerable and includes firebase-js-sdk fields plus any extra native keys.
297
+ */
298
+ export interface UserCredential {
299
+ user: User;
300
+ providerId: string | null;
301
+ operationType: (typeof OperationType)[keyof typeof OperationType];
302
+ /**
303
+ * Present on modular sign-in results when the native bridge returns federated metadata.
304
+ * Includes firebase-js-sdk core fields; extra native keys are preserved at runtime — see
305
+ * {@link AdditionalUserInfoNative} and {@link getAdditionalUserInfo}.
306
+ */
307
+ additionalUserInfo?: AdditionalUserInfo;
308
+ }
309
+
310
+ export interface ConfirmationResult {
311
+ readonly verificationId: string;
312
+ confirm(verificationCode: string): Promise<UserCredential>;
313
+ }
314
+
315
+ export interface ActionCodeSettings {
316
+ android?: {
317
+ installApp?: boolean;
318
+ minimumVersion?: string;
319
+ packageName: string;
320
+ };
321
+ handleCodeInApp?: boolean;
322
+ iOS?: {
323
+ bundleId: string;
324
+ };
325
+ url: string;
326
+ dynamicLinkDomain?: string;
327
+ linkDomain?: string;
328
+ }
329
+
330
+ export interface ActionCodeInfo {
331
+ data: {
332
+ email?: string | null;
333
+ multiFactorInfo?: MultiFactorInfo | null;
334
+ previousEmail?: string | null;
335
+ };
336
+ operation: (typeof ActionCodeOperation)[keyof typeof ActionCodeOperation];
337
+ }
338
+
339
+ export interface MultiFactorAssertion {
340
+ readonly factorId: (typeof FactorId)[keyof typeof FactorId];
341
+ }
342
+
343
+ export interface MultiFactorInfo {
344
+ readonly uid: string;
345
+ readonly displayName?: string | null;
346
+ readonly enrollmentTime: string;
347
+ readonly factorId: (typeof FactorId)[keyof typeof FactorId];
348
+ }
349
+
350
+ export interface MultiFactorSession {}
351
+
352
+ export interface MultiFactorResolver {
353
+ readonly hints: MultiFactorInfo[];
354
+ readonly session: MultiFactorSession;
355
+ resolveSignIn(assertion: MultiFactorAssertion): Promise<UserCredential>;
356
+ }
357
+
358
+ export interface MultiFactorUser {
359
+ readonly enrolledFactors: MultiFactorInfo[];
360
+ getSession(): Promise<MultiFactorSession>;
361
+ enroll(assertion: MultiFactorAssertion, displayName?: string | null): Promise<void>;
362
+ unenroll(option: MultiFactorInfo | string): Promise<void>;
363
+ }
364
+
365
+ export interface PhoneMultiFactorAssertion extends MultiFactorAssertion {}
366
+
367
+ export interface PhoneMultiFactorEnrollInfoOptions {
368
+ phoneNumber: string;
369
+ session: MultiFactorSession;
370
+ }
371
+
372
+ export interface PhoneMultiFactorInfo extends MultiFactorInfo {
373
+ readonly phoneNumber: string;
374
+ }
375
+
376
+ export interface PhoneMultiFactorSignInInfoOptions {
377
+ multiFactorHint?: MultiFactorInfo;
378
+ multiFactorUid?: string;
379
+ session: MultiFactorSession;
380
+ }
381
+
382
+ export interface PhoneSingleFactorInfoOptions {
383
+ phoneNumber: string;
384
+ }
385
+
386
+ export type PhoneInfoOptions =
387
+ | PhoneSingleFactorInfoOptions
388
+ | PhoneMultiFactorEnrollInfoOptions
389
+ | PhoneMultiFactorSignInInfoOptions;
390
+
391
+ export interface TotpMultiFactorAssertion extends MultiFactorAssertion {}
392
+
393
+ export interface TotpMultiFactorInfo extends MultiFactorInfo {}