FIRAuthBackend.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file 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. #import <Foundation/Foundation.h>
  17. #import "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
  18. #import "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
  19. @class FIRAuthRequestConfiguration;
  20. @class FIRCreateAuthURIRequest;
  21. @class FIRCreateAuthURIResponse;
  22. @class FIRDeleteAccountRequest;
  23. @class FIRDeleteAccountResponse;
  24. @class FIREmailLinkSignInRequest;
  25. @class FIREmailLinkSignInResponse;
  26. @class FIRGetAccountInfoRequest;
  27. @class FIRGetAccountInfoResponse;
  28. @class FIRGetProjectConfigRequest;
  29. @class FIRGetProjectConfigResponse;
  30. @class FIRGetOOBConfirmationCodeRequest;
  31. @class FIRGetOOBConfirmationCodeResponse;
  32. @class FIRResetPasswordRequest;
  33. @class FIRResetPasswordResponse;
  34. @class FIRSecureTokenRequest;
  35. @class FIRSecureTokenResponse;
  36. @class FIRSetAccountInfoRequest;
  37. @class FIRSetAccountInfoResponse;
  38. @class FIRVerifyAssertionRequest;
  39. @class FIRVerifyAssertionResponse;
  40. @class FIRVerifyClientRequest;
  41. @class FIRVerifyClientResponse;
  42. @class FIRVerifyCustomTokenRequest;
  43. @class FIRVerifyCustomTokenResponse;
  44. @class FIRVerifyPasswordRequest;
  45. @class FIRVerifyPasswordResponse;
  46. @class FIRVerifyPhoneNumberRequest;
  47. @class FIRVerifyPhoneNumberResponse;
  48. @class FIRSendVerificationCodeRequest;
  49. @class FIRSendVerificationCodeResponse;
  50. @class FIRSignInWithGameCenterRequest;
  51. @class FIRSignInWithGameCenterResponse;
  52. @class FIRSignUpNewUserRequest;
  53. @class FIRSignUpNewUserResponse;
  54. @class FIRRevokeTokenRequest;
  55. @class FIRRevokeTokenResponse;
  56. @class FIRGetRecaptchaConfigRequest;
  57. @class FIRGetRecaptchaConfigResponse;
  58. @class FIRStartPasskeyEnrollmentRequest;
  59. @class FIRStartPasskeyEnrollmentResponse;
  60. @class FIRFinalizePasskeyEnrollmentRequest;
  61. @class FIRFinalizePasskeyEnrollmentResponse;
  62. @class FIRStartPasskeySignInRequest;
  63. @class FIRStartPasskeySignInResponse;
  64. @class FIRFinalizePasskeySignInRequest;
  65. @class FIRFinalizePasskeySignInResponse;
  66. @protocol FIRAuthBackendImplementation;
  67. @protocol FIRAuthBackendRPCIssuer;
  68. NS_ASSUME_NONNULL_BEGIN
  69. /** @typedef FIRAuthBackendRPCIssuerCompletionHandler
  70. @brief The type of block used to return the result of a call to an endpoint.
  71. @param data The HTTP response body.
  72. @param error The error which occurred, if any.
  73. @remarks One of response or error will be non-nil.
  74. */
  75. typedef void (^FIRAuthBackendRPCIssuerCompletionHandler)(NSData *_Nullable data,
  76. NSError *_Nullable error);
  77. /** @typedef FIRCreateAuthURIResponseCallback
  78. @brief The type of block used to return the result of a call to the createAuthURI
  79. endpoint.
  80. @param response The received response, if any.
  81. @param error The error which occurred, if any.
  82. @remarks One of response or error will be non-nil.
  83. */
  84. typedef void (^FIRCreateAuthURIResponseCallback)(FIRCreateAuthURIResponse *_Nullable response,
  85. NSError *_Nullable error);
  86. /** @typedef FIRGetAccountInfoResponseCallback
  87. @brief The type of block used to return the result of a call to the getAccountInfo
  88. endpoint.
  89. @param response The received response, if any.
  90. @param error The error which occurred, if any.
  91. @remarks One of response or error will be non-nil.
  92. */
  93. typedef void (^FIRGetAccountInfoResponseCallback)(FIRGetAccountInfoResponse *_Nullable response,
  94. NSError *_Nullable error);
  95. /** @typedef FIRGetProjectConfigResponseCallback
  96. @brief The type of block used to return the result of a call to the getProjectInfo
  97. endpoint.
  98. @param response The received response, if any.
  99. @param error The error which occurred, if any.
  100. @remarks One of response or error will be non-nil.
  101. */
  102. typedef void (^FIRGetProjectConfigResponseCallback)(FIRGetProjectConfigResponse *_Nullable response,
  103. NSError *_Nullable error);
  104. /** @typedef FIRSetAccountInfoResponseCallback
  105. @brief The type of block used to return the result of a call to the setAccountInfo
  106. endpoint.
  107. @param response The received response, if any.
  108. @param error The error which occurred, if any.
  109. @remarks One of response or error will be non-nil.
  110. */
  111. typedef void (^FIRSetAccountInfoResponseCallback)(FIRSetAccountInfoResponse *_Nullable response,
  112. NSError *_Nullable error);
  113. /** @typedef FIRSecureTokenResponseCallback
  114. @brief The type of block used to return the result of a call to the token endpoint.
  115. @param response The received response, if any.
  116. @param error The error which occurred, if any.
  117. @remarks One of response or error will be non-nil.
  118. */
  119. typedef void (^FIRSecureTokenResponseCallback)(FIRSecureTokenResponse *_Nullable response,
  120. NSError *_Nullable error);
  121. /** @typedef FIRVerifyAssertionResponseCallback
  122. @brief The type of block used to return the result of a call to the verifyAssertion
  123. endpoint.
  124. @param response The received response, if any.
  125. @param error The error which occurred, if any.
  126. @remarks One of response or error will be non-nil.
  127. */
  128. typedef void (^FIRVerifyAssertionResponseCallback)(FIRVerifyAssertionResponse *_Nullable response,
  129. NSError *_Nullable error);
  130. /** @typedef FIRVerifyPasswordResponseCallback
  131. @brief The type of block used to return the result of a call to the verifyPassword
  132. endpoint.
  133. @param response The received response, if any.
  134. @param error The error which occurred, if any.
  135. @remarks One of response or error will be non-nil.
  136. */
  137. typedef void (^FIRVerifyPasswordResponseCallback)(FIRVerifyPasswordResponse *_Nullable response,
  138. NSError *_Nullable error);
  139. /** @typedef FIREmailLinkSigninResponseCallback
  140. @brief The type of block used to return the result of a call to the emailLinkSignin
  141. endpoint.
  142. @param response The received response, if any.
  143. @param error The error which occurred, if any.
  144. @remarks One of response or error will be non-nil.
  145. */
  146. typedef void (^FIREmailLinkSigninResponseCallback)(FIREmailLinkSignInResponse *_Nullable response,
  147. NSError *_Nullable error);
  148. /** @typedef FIRVerifyCustomTokenResponseCallback
  149. @brief The type of block used to return the result of a call to the verifyCustomToken
  150. endpoint.
  151. @param response The received response, if any.
  152. @param error The error which occurred, if any.
  153. @remarks One of response or error will be non-nil.
  154. */
  155. typedef void (^FIRVerifyCustomTokenResponseCallback)(
  156. FIRVerifyCustomTokenResponse *_Nullable response, NSError *_Nullable error);
  157. /** @typedef FIRDeleteCallBack
  158. @brief The type of block called when a request delete account has finished.
  159. @param error The error which occurred, or nil if the request was successful.
  160. */
  161. typedef void (^FIRDeleteCallBack)(NSError *_Nullable error);
  162. /** @typedef FIRGetOOBConfirmationCodeResponseCallback
  163. @brief The type of block used to return the result of a call to the getOOBConfirmationCode
  164. endpoint.
  165. @param response The received response, if any.
  166. @param error The error which occurred, if any.
  167. @remarks One of response or error will be non-nil.
  168. */
  169. typedef void (^FIRGetOOBConfirmationCodeResponseCallback)(
  170. FIRGetOOBConfirmationCodeResponse *_Nullable response, NSError *_Nullable error);
  171. /** @typedef FIRSignupNewUserCallback
  172. @brief The type of block used to return the result of a call to the signupNewUser endpoint.
  173. @param response The received response, if any.
  174. @param error The error which occurred, if any.
  175. @remarks One of response or error will be non-nil.
  176. */
  177. typedef void (^FIRSignupNewUserCallback)(FIRSignUpNewUserResponse *_Nullable response,
  178. NSError *_Nullable error);
  179. /** @typedef FIRResetPasswordCallback
  180. @brief The type of block used to return the result of a call to the resetPassword endpoint.
  181. @param response The received response, if any.
  182. @param error The error which occurred, if any.
  183. @remarks One of response or error will be non-nil.
  184. */
  185. typedef void (^FIRResetPasswordCallback)(FIRResetPasswordResponse *_Nullable response,
  186. NSError *_Nullable error);
  187. /** @typedef FIRSendVerificationCodeResponseCallback
  188. @brief The type of block used to return the result of a call to the sendVerificationCode
  189. endpoint.
  190. @param response The received response, if any.
  191. @param error The error which occurred, if any.
  192. @remarks One of response or error will be non-nil.
  193. */
  194. typedef void (^FIRSendVerificationCodeResponseCallback)(
  195. FIRSendVerificationCodeResponse *_Nullable response, NSError *_Nullable error);
  196. /** @typedef FIRVerifyPhoneNumberResponseCallback
  197. @brief The type of block used to return the result of a call to the verifyPhoneNumber endpoint.
  198. @param response The received response, if any.
  199. @param error The error which occurred, if any.
  200. @remarks One of response or error will be non-nil.
  201. */
  202. typedef void (^FIRVerifyPhoneNumberResponseCallback)(
  203. FIRVerifyPhoneNumberResponse *_Nullable response, NSError *_Nullable error);
  204. /** @typedef FIRVerifyClientResponseCallback
  205. @brief The type of block used to return the result of a call to the verifyClient endpoint.
  206. @param response The received response, if any.
  207. @param error The error which occurred, if any.
  208. @remarks One of response or error will be non-nil.
  209. */
  210. typedef void (^FIRVerifyClientResponseCallback)(FIRVerifyClientResponse *_Nullable response,
  211. NSError *_Nullable error);
  212. /** @typedef FIRRevokeTokenResponseCallback
  213. @brief The type of block used to return the result of a call to the revokeToken endpoint.
  214. @param response The received response, if any.
  215. @param error The error which occurred, if any.
  216. @remarks One of response or error will be non-nil.
  217. */
  218. typedef void (^FIRRevokeTokenResponseCallback)(FIRRevokeTokenResponse *_Nullable response,
  219. NSError *_Nullable error);
  220. /** @typedef FIRSignInWithGameCenterResponseCallback
  221. @brief The type of block used to return the result of a call to the SignInWithGameCenter
  222. endpoint.
  223. @param response The received response, if any.
  224. @param error The error which occurred, if any.
  225. @remarks One of response or error will be non-nil.
  226. */
  227. typedef void (^FIRSignInWithGameCenterResponseCallback)(
  228. FIRSignInWithGameCenterResponse *_Nullable response, NSError *_Nullable error);
  229. /**
  230. @typedef FIRGetRecaptchaConfigResponseCallback
  231. @brief The type of block used to return the result of a call to the getRecaptchaConfig endpoint.
  232. @param response The received response, if any.
  233. @param error The error which occurred, if any.
  234. @remarks One of response or error will be non-nil.
  235. */
  236. typedef void (^FIRGetRecaptchaConfigResponseCallback)(
  237. FIRGetRecaptchaConfigResponse *_Nullable response, NSError *_Nullable error);
  238. /**
  239. @typedef FIRStartPasskeyEnrollmentResponseCallback
  240. @brief The type of block used to return the result of a call to the StartPasskeyEnrollment
  241. endpoint.
  242. @param response The received response, if any.
  243. @param error The error which occurred, if any.
  244. @remarks One of response or error will be non-nil.
  245. */
  246. typedef void (^FIRStartPasskeyEnrollmentResponseCallback)(
  247. FIRStartPasskeyEnrollmentResponse *_Nullable response, NSError *_Nullable error);
  248. /**
  249. @typedef FIRFinalizePasskeyEnrollmentResponseCallback
  250. @brief The type of block used to return the result of a call to the finalizePasskeyEnrollment
  251. endpoint.
  252. @param response The received response, if any.
  253. @param error The error which occurred, if any.
  254. @remarks One of response or error will be non-nil.
  255. */
  256. typedef void (^FIRFinalizePasskeyEnrollmentResponseCallback)(
  257. FIRFinalizePasskeyEnrollmentResponse *_Nullable response, NSError *_Nullable error);
  258. /**
  259. @typedef FIRStartPasskeySignInResponseCallback
  260. @brief The type of block used to return the result of a call to the StartPasskeySignIn
  261. endpoint.
  262. @param response The received response, if any.
  263. @param error The error which occurred, if any.
  264. @remarks One of response or error will be non-nil.
  265. */
  266. typedef void (^FIRStartPasskeySignInResponseCallback)(
  267. FIRStartPasskeySignInResponse *_Nullable response, NSError *_Nullable error);
  268. /**
  269. @typedef FIRFinalizePasskeySignInResponseCallback
  270. @brief The type of block used to return the result of a call to the finalizePasskeySignIn
  271. endpoint.
  272. @param response The received response, if any.
  273. @param error The error which occurred, if any.
  274. @remarks One of response or error will be non-nil.
  275. */
  276. typedef void (^FIRFinalizePasskeySignInResponseCallback)(
  277. FIRFinalizePasskeySignInResponse *_Nullable response, NSError *_Nullable error);
  278. /** @class FIRAuthBackend
  279. @brief Simple static class with methods representing the backend RPCs.
  280. @remarks All callback blocks passed as method parameters are invoked asynchronously on the
  281. global work queue in the future. See
  282. https://github.com/firebase/firebase-ios-sdk/tree/master/FirebaseAuth/Docs/threading.md
  283. */
  284. @interface FIRAuthBackend : NSObject
  285. /** @fn authUserAgent
  286. @brief Retrieves the Firebase Auth user agent.
  287. @return The Firebase Auth user agent.
  288. */
  289. + (NSString *)authUserAgent;
  290. + (id<FIRAuthBackendImplementation>)implementation;
  291. /** @fn setBackendImplementation:
  292. @brief Changes the default backend implementation to something else.
  293. @param backendImplementation The backend implementation to use.
  294. @remarks This is not, generally, safe to call in a scenario where other backend requests may
  295. be occuring. This is specifically to help mock the backend for testing purposes.
  296. */
  297. + (void)setBackendImplementation:(id<FIRAuthBackendImplementation>)backendImplementation;
  298. /** @fn setDefaultBackendImplementationWithRPCIssuer:
  299. @brief Uses the default backend implementation, but with a custom RPC issuer.
  300. @param RPCIssuer The RPC issuer to use. If @c nil, will use the default implementation.
  301. @remarks This is not, generally, safe to call in a scenario where other backend requests may
  302. be occuring. This is specifically to help test the backend interfaces (requests, responses,
  303. and shared FIRAuthBackend logic.)
  304. */
  305. + (void)setDefaultBackendImplementationWithRPCIssuer:
  306. (nullable id<FIRAuthBackendRPCIssuer>)RPCIssuer;
  307. /** @fn createAuthURI:callback:
  308. @brief Calls the createAuthURI endpoint, which is responsible for creating the URI used by the
  309. IdP to authenticate the user.
  310. @param request The request parameters.
  311. @param callback The callback.
  312. */
  313. + (void)createAuthURI:(FIRCreateAuthURIRequest *)request
  314. callback:(FIRCreateAuthURIResponseCallback)callback;
  315. /** @fn getAccountInfo:callback:
  316. @brief Calls the getAccountInfo endpoint, which returns account info for a given account.
  317. @param request The request parameters.
  318. @param callback The callback.
  319. */
  320. + (void)getAccountInfo:(FIRGetAccountInfoRequest *)request
  321. callback:(FIRGetAccountInfoResponseCallback)callback;
  322. /** @fn getProjectConfig:callback:
  323. @brief Calls the getProjectConfig endpoint, which returns configuration information for a given
  324. project.
  325. @param request An object wrapping the backend get request.
  326. @param callback The callback.
  327. */
  328. + (void)getProjectConfig:(FIRGetProjectConfigRequest *)request
  329. callback:(FIRGetProjectConfigResponseCallback)callback;
  330. /** @fn setAccountInfo:callback:
  331. @brief Calls the setAccountInfo endpoint, which is responsible for setting account info for a
  332. user, for example, to sign up a new user with email and password.
  333. @param request The request parameters.
  334. @param callback The callback.
  335. */
  336. + (void)setAccountInfo:(FIRSetAccountInfoRequest *)request
  337. callback:(FIRSetAccountInfoResponseCallback)callback;
  338. /** @fn verifyAssertion:callback:
  339. @brief Calls the verifyAssertion endpoint, which is responsible for authenticating a
  340. user who has IDP-related credentials (an ID Token, an Access Token, etc.)
  341. @param request The request parameters.
  342. @param callback The callback.
  343. */
  344. + (void)verifyAssertion:(FIRVerifyAssertionRequest *)request
  345. callback:(FIRVerifyAssertionResponseCallback)callback;
  346. /** @fn verifyCustomToken:callback:
  347. @brief Calls the verifyCustomToken endpoint, which is responsible for authenticating a
  348. user who has BYOAuth credentials (a self-signed token using their BYOAuth private key.)
  349. @param request The request parameters.
  350. @param callback The callback.
  351. */
  352. + (void)verifyCustomToken:(FIRVerifyCustomTokenRequest *)request
  353. callback:(FIRVerifyCustomTokenResponseCallback)callback;
  354. /** @fn verifyPassword:callback:
  355. @brief Calls the verifyPassword endpoint, which is responsible for authenticating a
  356. user who has email and password credentials.
  357. @param request The request parameters.
  358. @param callback The callback.
  359. */
  360. + (void)verifyPassword:(FIRVerifyPasswordRequest *)request
  361. callback:(FIRVerifyPasswordResponseCallback)callback;
  362. /** @fn emailLinkSignin:callback:
  363. @brief Calls the emailLinkSignin endpoint, which is responsible for authenticating a
  364. user through passwordless sign-in.
  365. @param request The request parameters.
  366. @param callback The callback.
  367. */
  368. + (void)emailLinkSignin:(FIREmailLinkSignInRequest *)request
  369. callback:(FIREmailLinkSigninResponseCallback)callback;
  370. /** @fn secureToken:callback:
  371. @brief Calls the token endpoint, which is responsible for performing STS token exchanges and
  372. token refreshes.
  373. @param request The request parameters.
  374. @param callback The callback.
  375. */
  376. + (void)secureToken:(FIRSecureTokenRequest *)request
  377. callback:(FIRSecureTokenResponseCallback)callback;
  378. /** @fn getOOBConfirmationCode:callback:
  379. @brief Calls the getOOBConfirmationCode endpoint, which is responsible for sending email change
  380. request emails, and password reset emails.
  381. @param request The request parameters.
  382. @param callback The callback.
  383. */
  384. + (void)getOOBConfirmationCode:(FIRGetOOBConfirmationCodeRequest *)request
  385. callback:(FIRGetOOBConfirmationCodeResponseCallback)callback;
  386. /** @fn signUpNewUser:
  387. @brief Calls the signUpNewUser endpoint, which is responsible anonymously signing up a user
  388. or signing in a user anonymously.
  389. @param request The request parameters.
  390. @param callback The callback.
  391. */
  392. + (void)signUpNewUser:(FIRSignUpNewUserRequest *)request
  393. callback:(FIRSignupNewUserCallback)callback;
  394. /** @fn resetPassword:callback
  395. @brief Calls the resetPassword endpoint, which is responsible for resetting a user's password
  396. given an OOB code and new password.
  397. @param request The request parameters.
  398. @param callback The callback.
  399. */
  400. + (void)resetPassword:(FIRResetPasswordRequest *)request
  401. callback:(FIRResetPasswordCallback)callback;
  402. /** @fn deleteAccount:
  403. @brief Calls the DeleteAccount endpoint, which is responsible for deleting a user.
  404. @param request The request parameters.
  405. @param callback The callback.
  406. */
  407. + (void)deleteAccount:(FIRDeleteAccountRequest *)request callback:(FIRDeleteCallBack)callback;
  408. /** @fn SignInWithGameCenter:callback:
  409. @brief Calls the SignInWithGameCenter endpoint, which is responsible for authenticating a user
  410. who has Game Center credentials.
  411. @param request The request parameters.
  412. @param callback The callback.
  413. */
  414. + (void)signInWithGameCenter:(FIRSignInWithGameCenterRequest *)request
  415. callback:(FIRSignInWithGameCenterResponseCallback)callback;
  416. /** @fn getRecaptchaConfig:callback:
  417. @brief Calls the getRecaptchaConfig endpoint, which is responsible for retrieving the recaptcha
  418. configs including site key, provider enablement status.
  419. @param request The request parameters.
  420. @param callback The callback.
  421. */
  422. + (void)getRecaptchaConfig:(FIRGetRecaptchaConfigRequest *)request
  423. callback:(FIRGetRecaptchaConfigResponseCallback)callback;
  424. #if TARGET_OS_IOS
  425. /** @fn sendVerificationCode:callback:
  426. @brief Calls the sendVerificationCode endpoint, which is responsible for sending the
  427. verification code to a phone number specified in the request parameters.
  428. @param request The request parameters.
  429. @param callback The callback.
  430. */
  431. + (void)sendVerificationCode:(FIRSendVerificationCodeRequest *)request
  432. callback:(FIRSendVerificationCodeResponseCallback)callback;
  433. /** @fn verifyPhoneNumber:callback:
  434. @brief Calls the verifyPhoneNumber endpoint, which is responsible for sending the verification
  435. code to a phone number specified in the request parameters.
  436. @param request The request parameters.
  437. @param callback The callback.
  438. */
  439. + (void)verifyPhoneNumber:(FIRVerifyPhoneNumberRequest *)request
  440. callback:(FIRVerifyPhoneNumberResponseCallback)callback;
  441. /** @fn verifyClient:callback:
  442. @brief Calls the verifyClient endpoint, which is responsible for sending the silent push
  443. notification used for app validation to the device provided in the request parameters.
  444. @param request The request parameters.
  445. @param callback The callback.
  446. */
  447. + (void)verifyClient:(FIRVerifyClientRequest *)request
  448. callback:(FIRVerifyClientResponseCallback)callback;
  449. #endif
  450. #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST
  451. /** @fn startPasskeyEnrollment:callback:
  452. @brief Calls the startPasskeyEnrollment endpoint, which is responsible for receving the
  453. challenge that will later be consumed for platform key creation.
  454. @param request The request parameters.
  455. @param callback The callback.
  456. */
  457. + (void)startPasskeyEnrollment:(FIRStartPasskeyEnrollmentRequest *)request
  458. callback:(FIRStartPasskeyEnrollmentResponseCallback)callback;
  459. /** @fn finalizePasskeyEnrollment:callback:
  460. @brief Sends the platform created public info to the finalizePasskeyEnrollment endpoint.
  461. @param request The request parameters.
  462. @param callback The callback.
  463. */
  464. + (void)finalizePasskeyEnrollment:(FIRFinalizePasskeyEnrollmentRequest *)request
  465. callback:(FIRFinalizePasskeyEnrollmentResponseCallback)callback;
  466. /** @fn startPasskeySignIn:callback:
  467. @brief Calls the startPasskeySignIn endpoint, which is responsible for receving the
  468. challenge that will later be consumed for platform key attestation.
  469. @param request The request parameters.
  470. @param callback The callback.
  471. */
  472. + (void)startPasskeySignIn:(FIRStartPasskeySignInRequest *)request
  473. callback:(FIRStartPasskeySignInResponseCallback)callback;
  474. /** @fn finalizePasskeySignIn:callback:
  475. @brief Sends the platform created public info to the finalizePasskeySignIn endpoint.
  476. @param request The request parameters.
  477. @param callback The callback.
  478. */
  479. + (void)finalizePasskeySignIn:(FIRFinalizePasskeySignInRequest *)request
  480. callback:(FIRFinalizePasskeySignInResponseCallback)callback;
  481. #endif
  482. /** @fn revokeToken:callback:
  483. @brief Calls the revokeToken endpoint, which is responsible for revoking the given token
  484. provided in the request parameters.
  485. @param request The request parameters.
  486. @param callback The callback.
  487. */
  488. + (void)revokeToken:(FIRRevokeTokenRequest *)request
  489. callback:(FIRRevokeTokenResponseCallback)callback;
  490. @end
  491. /** @protocol FIRAuthBackendRPCIssuer
  492. @brief Used to make FIRAuthBackend
  493. */
  494. @protocol FIRAuthBackendRPCIssuer <NSObject>
  495. /** @fn asyncCallToURLWithRequestConfiguration:URL:body:contentType:completionHandler:
  496. @brief Asynchronously sends a HTTP request.
  497. @param requestConfiguration The request to be made.
  498. @param URL The request URL.
  499. @param body Request body.
  500. @param contentType Content type of the body.
  501. @param handler provided that handles HTTP response. Invoked asynchronously on the auth global
  502. work queue in the future.
  503. */
  504. - (void)asyncCallToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
  505. URL:(NSURL *)URL
  506. body:(nullable NSData *)body
  507. contentType:(NSString *)contentType
  508. completionHandler:(FIRAuthBackendRPCIssuerCompletionHandler)handler;
  509. @end
  510. /** @protocol FIRAuthBackendImplementation
  511. @brief Used to make FIRAuthBackend provide a layer of indirection to an actual RPC-based backend
  512. or a mock backend.
  513. */
  514. @protocol FIRAuthBackendImplementation <NSObject>
  515. /** @fn createAuthURI:callback:
  516. @brief Calls the createAuthURI endpoint, which is responsible for creating the URI used by the
  517. IdP to authenticate the user.
  518. @param request The request parameters.
  519. @param callback The callback.
  520. */
  521. - (void)createAuthURI:(FIRCreateAuthURIRequest *)request
  522. callback:(FIRCreateAuthURIResponseCallback)callback;
  523. /** @fn getAccountInfo:callback:
  524. @brief Calls the getAccountInfo endpoint, which returns account info for a given account.
  525. @param request The request parameters.
  526. @param callback The callback.
  527. */
  528. - (void)getAccountInfo:(FIRGetAccountInfoRequest *)request
  529. callback:(FIRGetAccountInfoResponseCallback)callback;
  530. /** @fn getProjectConfig:callback:
  531. @brief Calls the getProjectInfo endpoint, which returns configuration information for a given
  532. project.
  533. @param request The request parameters.
  534. @param callback The callback.
  535. */
  536. - (void)getProjectConfig:(FIRGetProjectConfigRequest *)request
  537. callback:(FIRGetProjectConfigResponseCallback)callback;
  538. /** @fn setAccountInfo:callback:
  539. @brief Calls the setAccountInfo endpoint, which is responsible for setting account info for a
  540. user, for example, to sign up a new user with email and password.
  541. @param request The request parameters.
  542. @param callback The callback.
  543. */
  544. - (void)setAccountInfo:(FIRSetAccountInfoRequest *)request
  545. callback:(FIRSetAccountInfoResponseCallback)callback;
  546. /** @fn verifyAssertion:callback:
  547. @brief Calls the verifyAssertion endpoint, which is responsible for authenticating a
  548. user who has IDP-related credentials (an ID Token, an Access Token, etc.)
  549. @param request The request parameters.
  550. @param callback The callback.
  551. */
  552. - (void)verifyAssertion:(FIRVerifyAssertionRequest *)request
  553. callback:(FIRVerifyAssertionResponseCallback)callback;
  554. /** @fn verifyCustomToken:callback:
  555. @brief Calls the verifyCustomToken endpoint, which is responsible for authenticating a
  556. user who has BYOAuth credentials (a self-signed token using their BYOAuth private key.)
  557. @param request The request parameters.
  558. @param callback The callback.
  559. */
  560. - (void)verifyCustomToken:(FIRVerifyCustomTokenRequest *)request
  561. callback:(FIRVerifyCustomTokenResponseCallback)callback;
  562. /** @fn verifyPassword:callback:
  563. @brief Calls the verifyPassword endpoint, which is responsible for authenticating a
  564. user who has email and password credentials.
  565. @param request The request parameters.
  566. @param callback The callback.
  567. */
  568. - (void)verifyPassword:(FIRVerifyPasswordRequest *)request
  569. callback:(FIRVerifyPasswordResponseCallback)callback;
  570. /** @fn emailLinkSignin:callback:
  571. @brief Calls the emailLinkSignin endpoint, which is responsible for authenticating a
  572. user through passwordless sign-in.
  573. @param request The request parameters.
  574. @param callback The callback.
  575. */
  576. - (void)emailLinkSignin:(FIREmailLinkSignInRequest *)request
  577. callback:(FIREmailLinkSigninResponseCallback)callback;
  578. /** @fn secureToken:callback:
  579. @brief Calls the token endpoint, which is responsible for performing STS token exchanges and
  580. token refreshes.
  581. @param request The request parameters.
  582. @param callback The callback.
  583. */
  584. - (void)secureToken:(FIRSecureTokenRequest *)request
  585. callback:(FIRSecureTokenResponseCallback)callback;
  586. /** @fn getOOBConfirmationCode:callback:
  587. @brief Calls the getOOBConfirmationCode endpoint, which is responsible for sending email change
  588. request emails, email sign-in link emails, and password reset emails.
  589. @param request The request parameters.
  590. @param callback The callback.
  591. */
  592. - (void)getOOBConfirmationCode:(FIRGetOOBConfirmationCodeRequest *)request
  593. callback:(FIRGetOOBConfirmationCodeResponseCallback)callback;
  594. /** @fn signUpNewUser:
  595. @brief Calls the signUpNewUser endpoint, which is responsible anonymously signing up a user
  596. or signing in a user anonymously.
  597. @param request The request parameters.
  598. @param callback The callback.
  599. */
  600. - (void)signUpNewUser:(FIRSignUpNewUserRequest *)request
  601. callback:(FIRSignupNewUserCallback)callback;
  602. /** @fn deleteAccount:
  603. @brief Calls the DeleteAccount endpoint, which is responsible for deleting a user.
  604. @param request The request parameters.
  605. @param callback The callback.
  606. */
  607. - (void)deleteAccount:(FIRDeleteAccountRequest *)request callback:(FIRDeleteCallBack)callback;
  608. #if TARGET_OS_IOS
  609. /** @fn sendVerificationCode:callback:
  610. @brief Calls the sendVerificationCode endpoint, which is responsible for sending the
  611. verification code to a phone number specified in the request parameters.
  612. @param request The request parameters.
  613. @param callback The callback.
  614. */
  615. - (void)sendVerificationCode:(FIRSendVerificationCodeRequest *)request
  616. callback:(FIRSendVerificationCodeResponseCallback)callback;
  617. /** @fn verifyPhoneNumber:callback:
  618. @brief Calls the verifyPhoneNumber endpoint, which is responsible for sending the verification
  619. code to a phone number specified in the request parameters.
  620. @param request The request parameters.
  621. @param callback The callback.
  622. */
  623. - (void)verifyPhoneNumber:(FIRVerifyPhoneNumberRequest *)request
  624. callback:(FIRVerifyPhoneNumberResponseCallback)callback;
  625. /** @fn verifyClient:callback:
  626. @brief Calls the verifyClient endpoint, which is responsible for sending the silent push
  627. notification used for app validation to the device provided in the request parameters.
  628. @param request The request parameters.
  629. @param callback The callback.
  630. */
  631. - (void)verifyClient:(FIRVerifyClientRequest *)request
  632. callback:(FIRVerifyClientResponseCallback)callback;
  633. #endif
  634. #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_OSX || TARGET_OS_MACCATALYST
  635. /** @fn startPasskeyEnrollment:callback:
  636. @brief Calls the startPasskeyEnrollment endpoint, which is responsible for receving the
  637. challenge that will later be consumed for platform key creation.
  638. @param request The request parameters.
  639. @param callback The callback.
  640. */
  641. - (void)startPasskeyEnrollment:(FIRStartPasskeyEnrollmentRequest *)request
  642. callback:(FIRStartPasskeyEnrollmentResponseCallback)callback;
  643. /** @fn finalizePasskeyEnrollment:callback:
  644. @brief Calls the finalizePasskeyEnrollment endpoint, which is responsible for sending the
  645. platform credential details to GCIP backend to exchange the access token and refresh token.
  646. @param request The request parameters.
  647. @param callback The callback.
  648. */
  649. - (void)finalizePasskeyEnrollment:(FIRFinalizePasskeyEnrollmentRequest *)request
  650. callback:(FIRFinalizePasskeyEnrollmentResponseCallback)callback;
  651. /** @fn startPasskeySignIn:callback:
  652. @brief Calls the startPasskeySignIn endpoint, which is responsible for receving the challange.
  653. @param request The request parameters.
  654. @param callback The callback.
  655. */
  656. - (void)startPasskeySignIn:(FIRStartPasskeySignInRequest *)request
  657. callback:(FIRStartPasskeySignInResponseCallback)callback;
  658. /** @fn finalizePasskeySignIn:callback:
  659. @brief Sends the platform created public info to the finalizePasskeySignIn endpoint.
  660. @param request The request parameters.
  661. @param callback The callback.
  662. */
  663. - (void)finalizePasskeySignIn:(FIRFinalizePasskeySignInRequest *)request
  664. callback:(FIRFinalizePasskeySignInResponseCallback)callback;
  665. #endif
  666. /** @fn revokeToken:callback:
  667. @brief Calls the revokeToken endpoint, which is responsible for revoking the given token
  668. provided in the request parameters.
  669. @param request The request parameters.
  670. @param callback The callback.
  671. */
  672. - (void)revokeToken:(FIRRevokeTokenRequest *)request
  673. callback:(FIRRevokeTokenResponseCallback)callback;
  674. /** @fn SignInWithGameCenter:callback:
  675. @brief Calls the SignInWithGameCenter endpoint, which is responsible for authenticating a user
  676. who has Game Center credentials.
  677. @param request The request parameters.
  678. @param callback The callback.
  679. */
  680. - (void)signInWithGameCenter:(FIRSignInWithGameCenterRequest *)request
  681. callback:(FIRSignInWithGameCenterResponseCallback)callback;
  682. /** @fn getRecaptchaConfig:callback:
  683. @brief Calls the getRecaptchaConfig endpoint, which is responsible for retrieving the recaptcha
  684. configs including site key, provider enablement status.
  685. @param request The request parameters.
  686. @param callback The callback.
  687. */
  688. - (void)getRecaptchaConfig:(FIRGetRecaptchaConfigRequest *)request
  689. callback:(FIRGetRecaptchaConfigResponseCallback)callback;
  690. /** @fn resetPassword:callback
  691. @brief Calls the resetPassword endpoint, which is responsible for resetting a user's password
  692. given an OOB code and new password.
  693. @param request The request parameters.
  694. @param callback The callback.
  695. */
  696. - (void)resetPassword:(FIRResetPasswordRequest *)request
  697. callback:(FIRResetPasswordCallback)callback;
  698. /** @fn callWithRequest:response:callback:
  699. @brief Calls the RPC using HTTP request.
  700. @remarks Possible error responses:
  701. @see FIRAuthInternalErrorCodeRPCRequestEncodingError
  702. @see FIRAuthInternalErrorCodeJSONSerializationError
  703. @see FIRAuthInternalErrorCodeNetworkError
  704. @see FIRAuthInternalErrorCodeUnexpectedErrorResponse
  705. @see FIRAuthInternalErrorCodeUnexpectedResponse
  706. @see FIRAuthInternalErrorCodeRPCResponseDecodingError
  707. @param request The request.
  708. @param response The empty response to be filled.
  709. @param callback The callback for both success and failure.
  710. */
  711. - (void)callWithRequest:(id<FIRAuthRPCRequest>)request
  712. response:(id<FIRAuthRPCResponse>)response
  713. callback:(void (^)(NSError *_Nullable error))callback;
  714. @end
  715. NS_ASSUME_NONNULL_END