説明なし

FIRAuthWebUtils.h 3.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright 2018 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. @class FIRAuthRequestConfiguration;
  18. NS_ASSUME_NONNULL_BEGIN
  19. /** @typedef FIRFetchAuthDomainCallback
  20. @brief The callback invoked at the end of the flow to fetch the Auth domain.
  21. @param authDomain The Auth domain.
  22. @param error The error that occurred while fetching the auth domain, if any.
  23. */
  24. typedef void (^FIRFetchAuthDomainCallback)(NSString *_Nullable authDomain,
  25. NSError *_Nullable error);
  26. /** @class FIRAuthURLUtils
  27. @brief A utility class used to facilitate the creation of auth related URLs.
  28. */
  29. @interface FIRAuthWebUtils : NSObject
  30. /** @fn randomStringWithLength:
  31. @brief Generates a random string of a specified length.
  32. */
  33. + (NSString *)randomStringWithLength:(NSUInteger)length;
  34. /** @fn isCallbackSchemeRegisteredForCustomURLScheme:
  35. @brief Checks whether or not the provided custom URL scheme has been registered by the app.
  36. @param URLScheme The custom URL scheme to be checked against all custom URL schemes registered by the app.
  37. @return whether or not the provided custom URL scheme has been registered by the app.
  38. */
  39. + (BOOL)isCallbackSchemeRegisteredForCustomURLScheme:(NSString *)URLScheme;
  40. /** @fn isExpectedCallbackURL:eventID:authType
  41. @brief Parses a URL into all available query items.
  42. @param URL The actual callback URL.
  43. @param eventID The expected event ID.
  44. @param authType The expected auth type.
  45. @param callbackScheme The expected callback custom scheme.
  46. @return Whether or not the actual callback URL matches the expected callback URL.
  47. */
  48. + (BOOL)isExpectedCallbackURL:(nullable NSURL *)URL
  49. eventID:(NSString *)eventID
  50. authType:(NSString *)authType
  51. callbackScheme:(NSString *)callbackScheme;
  52. /** @fn fetchAuthDomainWithCompletion:completion:
  53. @brief Fetches the auth domain associated with the Firebase Project.
  54. @param completion The callback invoked after the auth domain has been constructed or an error
  55. has been encountered.
  56. */
  57. + (void)fetchAuthDomainWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
  58. completion:(FIRFetchAuthDomainCallback)completion;
  59. /** @fn queryItemValue:from:
  60. @brief Utility function to get a value from a NSURLQueryItem array.
  61. @param name The key.
  62. @param queryList The NSURLQueryItem array.
  63. @return The value for the key.
  64. */
  65. + (nullable NSString *)queryItemValue:(NSString *)name from:(NSArray<NSURLQueryItem *> *)queryList;
  66. /** @fn dictionaryWithHttpArgumentsString:
  67. @brief Utility function to get a dictionary from a http argument string.
  68. @param argString The http argument string.
  69. @return The resulting dictionary of query arguments.
  70. */
  71. + (NSDictionary *)dictionaryWithHttpArgumentsString:(NSString *)argString;
  72. /** @fn stringByUnescapingFromURLArgument:from:
  73. @brief Utility function to get a string by unescapting URL arguments.
  74. @param argument The argument string.
  75. @return The resulting string after unescaping URL argument.
  76. */
  77. + (NSString *)stringByUnescapingFromURLArgument:(NSString *)argument;
  78. @end
  79. NS_ASSUME_NONNULL_END