PhoneAuthProvider.swift 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import FirebaseCore
  15. import Foundation
  16. /// A concrete implementation of `AuthProvider` for phone auth providers.
  17. ///
  18. /// This class is available on iOS only.
  19. @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
  20. @objc(FIRPhoneAuthProvider) open class PhoneAuthProvider: NSObject {
  21. /// A string constant identifying the phone identity provider.
  22. @objc public static let id = "phone"
  23. #if os(iOS)
  24. /// Returns an instance of `PhoneAuthProvider` for the default `Auth` object.
  25. @objc(provider) open class func provider() -> PhoneAuthProvider {
  26. return PhoneAuthProvider(auth: Auth.auth())
  27. }
  28. /// Returns an instance of `PhoneAuthProvider` for the provided `Auth` object.
  29. /// - Parameter auth: The auth object to associate with the phone auth provider instance.
  30. @objc(providerWithAuth:)
  31. open class func provider(auth: Auth) -> PhoneAuthProvider {
  32. return PhoneAuthProvider(auth: auth)
  33. }
  34. /// Starts the phone number authentication flow by sending a verification code to the
  35. /// specified phone number.
  36. ///
  37. /// Possible error codes:
  38. /// * `AuthErrorCodeCaptchaCheckFailed` - Indicates that the reCAPTCHA token obtained by
  39. /// the Firebase Auth is invalid or has expired.
  40. /// * `AuthErrorCodeQuotaExceeded` - Indicates that the phone verification quota for this
  41. /// project has been exceeded.
  42. /// * `AuthErrorCodeInvalidPhoneNumber` - Indicates that the phone number provided is invalid.
  43. /// * `AuthErrorCodeMissingPhoneNumber` - Indicates that a phone number was not provided.
  44. /// - Parameter phoneNumber: The phone number to be verified.
  45. /// - Parameter uiDelegate: An object used to present the SFSafariViewController. The object is
  46. /// retained by this method until the completion block is executed.
  47. /// - Parameter completion: The callback to be invoked when the verification flow is finished.
  48. @objc(verifyPhoneNumber:UIDelegate:completion:)
  49. open func verifyPhoneNumber(_ phoneNumber: String,
  50. uiDelegate: AuthUIDelegate? = nil,
  51. completion: ((_: String?, _: Error?) -> Void)?) {
  52. verifyPhoneNumber(phoneNumber,
  53. uiDelegate: uiDelegate,
  54. multiFactorSession: nil,
  55. completion: completion)
  56. }
  57. /// Verify ownership of the second factor phone number by the current user.
  58. /// - Parameter phoneNumber: The phone number to be verified.
  59. /// - Parameter uiDelegate: An object used to present the SFSafariViewController. The object is
  60. /// retained by this method until the completion block is executed.
  61. /// - Parameter multiFactorSession: A session to identify the MFA flow. For enrollment, this
  62. /// identifies the user trying to enroll. For sign-in, this identifies that the user already
  63. /// passed the first factor challenge.
  64. /// - Parameter completion: The callback to be invoked when the verification flow is finished.
  65. @objc(verifyPhoneNumber:UIDelegate:multiFactorSession:completion:)
  66. open func verifyPhoneNumber(_ phoneNumber: String,
  67. uiDelegate: AuthUIDelegate? = nil,
  68. multiFactorSession: MultiFactorSession? = nil,
  69. completion: ((_: String?, _: Error?) -> Void)?) {
  70. guard AuthWebUtils.isCallbackSchemeRegistered(forCustomURLScheme: callbackScheme,
  71. urlTypes: auth.mainBundleUrlTypes) else {
  72. fatalError(
  73. "Please register custom URL scheme \(callbackScheme) in the app's Info.plist file."
  74. )
  75. }
  76. kAuthGlobalWorkQueue.async {
  77. Task {
  78. do {
  79. let verificationID = try await self.internalVerify(
  80. phoneNumber: phoneNumber,
  81. uiDelegate: uiDelegate,
  82. multiFactorSession: multiFactorSession
  83. )
  84. Auth.wrapMainAsync(callback: completion, withParam: verificationID, error: nil)
  85. } catch {
  86. Auth.wrapMainAsync(callback: completion, withParam: nil, error: error)
  87. }
  88. }
  89. }
  90. }
  91. /// Verify ownership of the second factor phone number by the current user.
  92. /// - Parameter phoneNumber: The phone number to be verified.
  93. /// - Parameter uiDelegate: An object used to present the SFSafariViewController. The object is
  94. /// retained by this method until the completion block is executed.
  95. /// - Parameter multiFactorSession: A session to identify the MFA flow. For enrollment, this
  96. /// identifies the user trying to enroll. For sign-in, this identifies that the user already
  97. /// passed the first factor challenge.
  98. /// - Returns: The verification ID
  99. @available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
  100. open func verifyPhoneNumber(_ phoneNumber: String,
  101. uiDelegate: AuthUIDelegate? = nil,
  102. multiFactorSession: MultiFactorSession? = nil) async throws
  103. -> String {
  104. return try await withCheckedThrowingContinuation { continuation in
  105. self.verifyPhoneNumber(phoneNumber,
  106. uiDelegate: uiDelegate,
  107. multiFactorSession: multiFactorSession) { result, error in
  108. if let error {
  109. continuation.resume(throwing: error)
  110. } else if let result {
  111. continuation.resume(returning: result)
  112. }
  113. }
  114. }
  115. }
  116. /// Verify ownership of the second factor phone number by the current user.
  117. /// - Parameter multiFactorInfo: The phone multi factor whose number need to be verified.
  118. /// - Parameter uiDelegate: An object used to present the SFSafariViewController. The object is
  119. /// retained by this method until the completion block is executed.
  120. /// - Parameter multiFactorSession: A session to identify the MFA flow. For enrollment, this
  121. /// identifies the user trying to enroll. For sign-in, this identifies that the user already
  122. /// passed the first factor challenge.
  123. /// - Parameter completion: The callback to be invoked when the verification flow is finished.
  124. @objc(verifyPhoneNumberWithMultiFactorInfo:UIDelegate:multiFactorSession:completion:)
  125. open func verifyPhoneNumber(with multiFactorInfo: PhoneMultiFactorInfo,
  126. uiDelegate: AuthUIDelegate? = nil,
  127. multiFactorSession: MultiFactorSession?,
  128. completion: ((_: String?, _: Error?) -> Void)?) {
  129. multiFactorSession?.multiFactorInfo = multiFactorInfo
  130. verifyPhoneNumber(multiFactorInfo.phoneNumber,
  131. uiDelegate: uiDelegate,
  132. multiFactorSession: multiFactorSession,
  133. completion: completion)
  134. }
  135. /// Verify ownership of the second factor phone number by the current user.
  136. /// - Parameter multiFactorInfo: The phone multi factor whose number need to be verified.
  137. /// - Parameter uiDelegate: An object used to present the SFSafariViewController. The object is
  138. /// retained by this method until the completion block is executed.
  139. /// - Parameter multiFactorSession: A session to identify the MFA flow. For enrollment, this
  140. /// identifies the user trying to enroll. For sign-in, this identifies that the user already
  141. /// passed the first factor challenge.
  142. /// - Returns: The verification ID.
  143. @available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
  144. open func verifyPhoneNumber(with multiFactorInfo: PhoneMultiFactorInfo,
  145. uiDelegate: AuthUIDelegate? = nil,
  146. multiFactorSession: MultiFactorSession?) async throws -> String {
  147. return try await withCheckedThrowingContinuation { continuation in
  148. self.verifyPhoneNumber(with: multiFactorInfo,
  149. uiDelegate: uiDelegate,
  150. multiFactorSession: multiFactorSession) { result, error in
  151. if let error {
  152. continuation.resume(throwing: error)
  153. } else if let result {
  154. continuation.resume(returning: result)
  155. }
  156. }
  157. }
  158. }
  159. /// Creates an `AuthCredential` for the phone number provider identified by the
  160. /// verification ID and verification code.
  161. ///
  162. /// - Parameter verificationID: The verification ID obtained from invoking
  163. /// verifyPhoneNumber:completion:
  164. /// - Parameter verificationCode: The verification code obtained from the user.
  165. /// - Returns: The corresponding phone auth credential for the verification ID and verification
  166. /// code provided.
  167. @objc(credentialWithVerificationID:verificationCode:)
  168. open func credential(withVerificationID verificationID: String,
  169. verificationCode: String) -> PhoneAuthCredential {
  170. return PhoneAuthCredential(withProviderID: PhoneAuthProvider.id,
  171. verificationID: verificationID,
  172. verificationCode: verificationCode)
  173. }
  174. private func internalVerify(phoneNumber: String,
  175. uiDelegate: AuthUIDelegate?,
  176. multiFactorSession: MultiFactorSession? = nil) async throws
  177. -> String? {
  178. guard phoneNumber.count > 0 else {
  179. throw AuthErrorUtils.missingPhoneNumberError(message: nil)
  180. }
  181. guard let manager = auth.notificationManager else {
  182. throw AuthErrorUtils.notificationNotForwardedError()
  183. }
  184. guard await manager.checkNotificationForwarding() else {
  185. throw AuthErrorUtils.notificationNotForwardedError()
  186. }
  187. return try await verifyClAndSendVerificationCode(toPhoneNumber: phoneNumber,
  188. retryOnInvalidAppCredential: true,
  189. multiFactorSession: multiFactorSession,
  190. uiDelegate: uiDelegate)
  191. }
  192. /// Starts the flow to verify the client via silent push notification.
  193. /// - Parameter retryOnInvalidAppCredential: Whether or not the flow should be retried if an
  194. /// AuthErrorCodeInvalidAppCredential error is returned from the backend.
  195. /// - Parameter phoneNumber: The phone number to be verified.
  196. /// - Parameter callback: The callback to be invoked on the global work queue when the flow is
  197. /// finished.
  198. private func verifyClAndSendVerificationCode(toPhoneNumber phoneNumber: String,
  199. retryOnInvalidAppCredential: Bool,
  200. uiDelegate: AuthUIDelegate?) async throws
  201. -> String? {
  202. let codeIdentity = try await verifyClient(withUIDelegate: uiDelegate)
  203. let request = SendVerificationCodeRequest(phoneNumber: phoneNumber,
  204. codeIdentity: codeIdentity,
  205. requestConfiguration: auth
  206. .requestConfiguration)
  207. do {
  208. let response = try await AuthBackend.call(with: request)
  209. return response.verificationID
  210. } catch {
  211. return try await handleVerifyErrorWithRetry(error: error,
  212. phoneNumber: phoneNumber,
  213. retryOnInvalidAppCredential: retryOnInvalidAppCredential,
  214. multiFactorSession: nil,
  215. uiDelegate: uiDelegate)
  216. }
  217. }
  218. /// Starts the flow to verify the client via silent push notification.
  219. /// - Parameter retryOnInvalidAppCredential: Whether of not the flow should be retried if an
  220. /// AuthErrorCodeInvalidAppCredential error is returned from the backend.
  221. /// - Parameter phoneNumber: The phone number to be verified.
  222. private func verifyClAndSendVerificationCode(toPhoneNumber phoneNumber: String,
  223. retryOnInvalidAppCredential: Bool,
  224. multiFactorSession session: MultiFactorSession?,
  225. uiDelegate: AuthUIDelegate?) async throws
  226. -> String? {
  227. if let settings = auth.settings,
  228. settings.isAppVerificationDisabledForTesting {
  229. let request = SendVerificationCodeRequest(
  230. phoneNumber: phoneNumber,
  231. codeIdentity: CodeIdentity.empty,
  232. requestConfiguration: auth.requestConfiguration
  233. )
  234. let response = try await AuthBackend.call(with: request)
  235. return response.verificationID
  236. }
  237. guard let session else {
  238. return try await verifyClAndSendVerificationCode(
  239. toPhoneNumber: phoneNumber,
  240. retryOnInvalidAppCredential: retryOnInvalidAppCredential,
  241. uiDelegate: uiDelegate
  242. )
  243. }
  244. let codeIdentity = try await verifyClient(withUIDelegate: uiDelegate)
  245. let startMFARequestInfo = AuthProtoStartMFAPhoneRequestInfo(phoneNumber: phoneNumber,
  246. codeIdentity: codeIdentity)
  247. do {
  248. if let idToken = session.idToken {
  249. let request = StartMFAEnrollmentRequest(idToken: idToken,
  250. enrollmentInfo: startMFARequestInfo,
  251. requestConfiguration: auth.requestConfiguration)
  252. let response = try await AuthBackend.call(with: request)
  253. return response.phoneSessionInfo?.sessionInfo
  254. } else {
  255. let request = StartMFASignInRequest(MFAPendingCredential: session.mfaPendingCredential,
  256. MFAEnrollmentID: session.multiFactorInfo?.uid,
  257. signInInfo: startMFARequestInfo,
  258. requestConfiguration: auth.requestConfiguration)
  259. let response = try await AuthBackend.call(with: request)
  260. return response.responseInfo?.sessionInfo
  261. }
  262. } catch {
  263. return try await handleVerifyErrorWithRetry(
  264. error: error,
  265. phoneNumber: phoneNumber,
  266. retryOnInvalidAppCredential: retryOnInvalidAppCredential,
  267. multiFactorSession: session,
  268. uiDelegate: uiDelegate
  269. )
  270. }
  271. }
  272. private func handleVerifyErrorWithRetry(error: Error,
  273. phoneNumber: String,
  274. retryOnInvalidAppCredential: Bool,
  275. multiFactorSession session: MultiFactorSession?,
  276. uiDelegate: AuthUIDelegate?) async throws -> String? {
  277. if (error as NSError).code == AuthErrorCode.invalidAppCredential.rawValue {
  278. if retryOnInvalidAppCredential {
  279. auth.appCredentialManager.clearCredential()
  280. return try await verifyClAndSendVerificationCode(toPhoneNumber: phoneNumber,
  281. retryOnInvalidAppCredential: false,
  282. multiFactorSession: session,
  283. uiDelegate: uiDelegate)
  284. }
  285. throw AuthErrorUtils.unexpectedResponse(deserializedResponse: nil, underlyingError: error)
  286. }
  287. throw error
  288. }
  289. /// Continues the flow to verify the client via silent push notification.
  290. private func verifyClient(withUIDelegate uiDelegate: AuthUIDelegate?) async throws
  291. -> CodeIdentity {
  292. // Remove the simulator check below after FCM supports APNs in simulators
  293. #if targetEnvironment(simulator)
  294. let environment = ProcessInfo().environment
  295. if environment["XCTestConfigurationFilePath"] == nil {
  296. return try await CodeIdentity
  297. .recaptcha(reCAPTCHAFlowWithUIDelegate(withUIDelegate: uiDelegate))
  298. }
  299. #endif
  300. if let credential = auth.appCredentialManager.credential {
  301. return CodeIdentity.credential(credential)
  302. }
  303. var token: AuthAPNSToken
  304. do {
  305. token = try await auth.tokenManager.getToken()
  306. } catch {
  307. return try await CodeIdentity
  308. .recaptcha(reCAPTCHAFlowWithUIDelegate(withUIDelegate: uiDelegate))
  309. }
  310. let request = VerifyClientRequest(withAppToken: token.string,
  311. isSandbox: token.type == AuthAPNSTokenType.sandbox,
  312. requestConfiguration: auth.requestConfiguration)
  313. do {
  314. let verifyResponse = try await AuthBackend.call(with: request)
  315. guard let receipt = verifyResponse.receipt,
  316. let timeout = verifyResponse.suggestedTimeOutDate?.timeIntervalSinceNow else {
  317. fatalError("Internal Auth Error: invalid VerifyClientResponse")
  318. }
  319. let credential = await
  320. auth.appCredentialManager.didStartVerification(withReceipt: receipt, timeout: timeout)
  321. if credential.secret == nil {
  322. AuthLog.logWarning(code: "I-AUT000014", message: "Failed to receive remote " +
  323. "notification to verify app identity within \(timeout) " +
  324. "second(s), falling back to reCAPTCHA verification.")
  325. return try await CodeIdentity
  326. .recaptcha(reCAPTCHAFlowWithUIDelegate(withUIDelegate: uiDelegate))
  327. }
  328. return CodeIdentity.credential(credential)
  329. } catch {
  330. let nserror = error as NSError
  331. // reCAPTCHA Flow if it's an invalid app credential or a missing app token.
  332. guard nserror.code == AuthErrorCode.invalidAppCredential.rawValue || nserror
  333. .code == AuthErrorCode.missingAppToken.rawValue else {
  334. throw error
  335. }
  336. return try await CodeIdentity
  337. .recaptcha(reCAPTCHAFlowWithUIDelegate(withUIDelegate: uiDelegate))
  338. }
  339. }
  340. /// Continues the flow to verify the client via silent push notification.
  341. private func reCAPTCHAFlowWithUIDelegate(withUIDelegate uiDelegate: AuthUIDelegate?) async throws
  342. -> String {
  343. let eventID = AuthWebUtils.randomString(withLength: 10)
  344. guard let url = try await reCAPTCHAURL(withEventID: eventID) else {
  345. fatalError(
  346. "Internal error: reCAPTCHAURL returned neither a value nor an error. Report issue"
  347. )
  348. }
  349. let callbackMatcher: (URL?) -> Bool = { callbackURL in
  350. AuthWebUtils.isExpectedCallbackURL(
  351. callbackURL,
  352. eventID: eventID,
  353. authType: self.kAuthTypeVerifyApp,
  354. callbackScheme: self.callbackScheme
  355. )
  356. }
  357. return try await withCheckedThrowingContinuation { continuation in
  358. self.auth.authURLPresenter.present(url,
  359. uiDelegate: uiDelegate,
  360. callbackMatcher: callbackMatcher) { callbackURL, error in
  361. if let error {
  362. continuation.resume(throwing: error)
  363. } else {
  364. do {
  365. try continuation.resume(returning: self.reCAPTCHAToken(forURL: callbackURL))
  366. } catch {
  367. continuation.resume(throwing: error)
  368. }
  369. }
  370. }
  371. }
  372. }
  373. /// Parses the reCAPTCHA URL and returns the reCAPTCHA token.
  374. /// - Parameter url: The url to be parsed for a reCAPTCHA token.
  375. /// - Returns: The reCAPTCHA token if successful.
  376. private func reCAPTCHAToken(forURL url: URL?) throws -> String {
  377. guard let url = url else {
  378. let reason = "Internal Auth Error: nil URL trying to access RECAPTCHA token"
  379. throw AuthErrorUtils.appVerificationUserInteractionFailure(reason: reason)
  380. }
  381. let actualURLComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
  382. if let queryItems = actualURLComponents?.queryItems,
  383. let deepLinkURL = AuthWebUtils.queryItemValue(name: "deep_link_id", from: queryItems) {
  384. let deepLinkComponents = URLComponents(string: deepLinkURL)
  385. if let queryItems = deepLinkComponents?.queryItems {
  386. if let token = AuthWebUtils.queryItemValue(name: "recaptchaToken", from: queryItems) {
  387. return token
  388. }
  389. if let firebaseError = AuthWebUtils.queryItemValue(
  390. name: "firebaseError",
  391. from: queryItems
  392. ) {
  393. if let errorData = firebaseError.data(using: .utf8) {
  394. var errorDict: [AnyHashable: Any]?
  395. do {
  396. errorDict = try JSONSerialization.jsonObject(with: errorData) as? [AnyHashable: Any]
  397. } catch {
  398. throw AuthErrorUtils.JSONSerializationError(underlyingError: error)
  399. }
  400. if let errorDict,
  401. let code = errorDict["code"] as? String,
  402. let message = errorDict["message"] as? String {
  403. throw AuthErrorUtils.urlResponseError(code: code, message: message)
  404. }
  405. }
  406. }
  407. }
  408. let reason = "An unknown error occurred with the following response: \(deepLinkURL)"
  409. throw AuthErrorUtils.appVerificationUserInteractionFailure(reason: reason)
  410. }
  411. let reason = "Failed to get url Components for url: \(url)"
  412. throw AuthErrorUtils.appVerificationUserInteractionFailure(reason: reason)
  413. }
  414. /// Constructs a URL used for opening a reCAPTCHA app verification flow using a given event ID.
  415. /// - Parameter eventID: The event ID used for this purpose.
  416. private func reCAPTCHAURL(withEventID eventID: String) async throws -> URL? {
  417. let authDomain = try await AuthWebUtils
  418. .fetchAuthDomain(withRequestConfiguration: auth.requestConfiguration)
  419. let bundleID = Bundle.main.bundleIdentifier
  420. let clientID = auth.app?.options.clientID
  421. let appID = auth.app?.options.googleAppID
  422. let apiKey = auth.requestConfiguration.apiKey
  423. let appCheck = auth.requestConfiguration.appCheck
  424. var queryItems = [URLQueryItem(name: "apiKey", value: apiKey),
  425. URLQueryItem(name: "authType", value: kAuthTypeVerifyApp),
  426. URLQueryItem(name: "ibi", value: bundleID ?? ""),
  427. URLQueryItem(name: "v", value: AuthBackend.authUserAgent()),
  428. URLQueryItem(name: "eventId", value: eventID)]
  429. if usingClientIDScheme {
  430. queryItems.append(URLQueryItem(name: "clientId", value: clientID))
  431. } else {
  432. queryItems.append(URLQueryItem(name: "appId", value: appID))
  433. }
  434. if let languageCode = auth.requestConfiguration.languageCode {
  435. queryItems.append(URLQueryItem(name: "hl", value: languageCode))
  436. }
  437. var components = URLComponents(string: "https://\(authDomain)/__/auth/handler?")
  438. components?.queryItems = queryItems
  439. if let appCheck {
  440. let tokenResult = await appCheck.getToken(forcingRefresh: false)
  441. if let error = tokenResult.error {
  442. AuthLog.logWarning(code: "I-AUT000018",
  443. message: "Error getting App Check token; using placeholder " +
  444. "token instead. Error: \(error)")
  445. }
  446. let appCheckTokenFragment = "fac=\(tokenResult.token)"
  447. components?.fragment = appCheckTokenFragment
  448. }
  449. return components?.url
  450. }
  451. private let auth: Auth
  452. private let callbackScheme: String
  453. private let usingClientIDScheme: Bool
  454. init(auth: Auth) {
  455. self.auth = auth
  456. if let clientID = auth.app?.options.clientID {
  457. let reverseClientIDScheme = clientID.components(separatedBy: ".").reversed()
  458. .joined(separator: ".")
  459. if AuthWebUtils.isCallbackSchemeRegistered(forCustomURLScheme: reverseClientIDScheme,
  460. urlTypes: auth.mainBundleUrlTypes) {
  461. callbackScheme = reverseClientIDScheme
  462. usingClientIDScheme = true
  463. return
  464. }
  465. }
  466. usingClientIDScheme = false
  467. if let appID = auth.app?.options.googleAppID {
  468. let dashedAppID = appID.replacingOccurrences(of: ":", with: "-")
  469. callbackScheme = "app-\(dashedAppID)"
  470. return
  471. }
  472. callbackScheme = ""
  473. }
  474. private let kAuthTypeVerifyApp = "verifyApp"
  475. #endif
  476. }