AlicomCaptcha4Session.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // AlicomCaptcha4Session.h
  3. // AlicomCaptcha4.h
  4. //
  5. // Created by NikoXu on 2020/9/29.
  6. // Copyright © 2020 GT. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @class AlicomCaptcha4SessionConfiguration, AlicomC4Error;
  11. @protocol AlicomCaptcha4SessionTaskDelegate;
  12. /// 验证会话(Captcha session)
  13. @interface AlicomCaptcha4Session : NSObject
  14. /// 验证会话任务的代理(Captcha session task delegate)
  15. @property (nullable, nonatomic, weak) id<AlicomCaptcha4SessionTaskDelegate> delegate;
  16. /// 当前验证会话的验证ID(The captcha ID of the current captcha session)
  17. @property (nonnull, readonly, nonatomic, strong) NSString *captchaID;
  18. /// 当前验证会话的流水号(The serial number of the current captcha session)
  19. @property (nullable, readonly, nonatomic, strong) NSString *challenge;
  20. /// 当前验证会话的配置(The configuration of the current captcha session)
  21. @property (nonnull, readonly, nonatomic, strong) AlicomCaptcha4SessionConfiguration *configuration;
  22. /// 创建一个新的验证会话实例(Create a new captcha session instance)
  23. /// @param captchaID 验证ID(The captcha ID)
  24. + (instancetype)sessionWithCaptchaID:(NSString *)captchaID;
  25. /// 创建一个新的验证会话实例(Create a new captcha session instance.)
  26. /// @param captchaID 验证ID(The captcha ID)
  27. /// @param configuration 会话配置(The configuration of session)
  28. + (instancetype)sessionWithCaptchaID:(NSString *)captchaID
  29. configuration:(nullable AlicomCaptcha4SessionConfiguration *)configuration;
  30. /// 初始化一个新的验证会话实例(Create a new captcha session instance)
  31. /// @param captchaID 验证ID(The captcha ID)
  32. - (instancetype)initWithCaptchaID:(NSString *)captchaID;
  33. /// 初始化一个新的验证会话实例(Create a new captcha session instance)
  34. /// @param captchaID 验证ID(The captcha ID)
  35. /// @param configuration 会话配置(The configuration of session)
  36. - (instancetype)initWithCaptchaID:(NSString *)captchaID
  37. configuration:(nullable AlicomCaptcha4SessionConfiguration *)configuration;
  38. /// 开始验证(Start verification)
  39. - (void)verify;
  40. /// 取消验证(Cancel verification)
  41. - (void)cancel;
  42. /// SDK 版本号(Obtain the SDK version)
  43. + (NSString *)sdkVersion;
  44. @end
  45. /// 验证会话任务代理协议(Captcha Session Task Delegate)
  46. @protocol AlicomCaptcha4SessionTaskDelegate <NSObject>
  47. @required
  48. /// 回调验证会话的结果参数(Callback result parameters of captcha session)
  49. /// @discussion 拿到验证结果的参数后,需要提交到业务服务端,
  50. /// 完成参数的校验
  51. /// After getting the parameters of verification results,
  52. /// they need to be submitted to the business server to
  53. /// complete the verification of parameters.
  54. /// @param captchaSession 验证会话(Captcha session)
  55. /// @param status 状态码。@"0"/@"1": 未完成/完成。当 status 为 @"1"
  56. /// 时,则为成功,需要对结果进行二次校验。
  57. /// Status code. @ “0”/@ “1”: Not finished/finished.
  58. /// When status is @ “1”, it is successful, and the
  59. /// result needs to be secondary validated.
  60. /// @param result 结果校验参数(Result verification parameters.)。示例(Example):
  61. /// ```
  62. /// {
  63. /// challenge = "19080ae5-fe79-4431-9c78-4ee8e0dec798";
  64. /// captcha_id = "c62d0f270240799b3113b0a5787ead55";
  65. /// }
  66. /// ```
  67. - (void)alicomCaptchaSession:(AlicomCaptcha4Session *)captchaSession
  68. didReceive:(NSString *)status
  69. result:(nullable NSDictionary *)result;
  70. /// 回调验证会话中发生的错误(Callback errors that occurred in the captcha session)
  71. /// @param captchaSession 验证会话(Captcha session)
  72. /// @param error 错误描述对象(Error description object)
  73. - (void)alicomCaptchaSession:(AlicomCaptcha4Session *)captchaSession
  74. didReceiveError:(AlicomC4Error *)error;
  75. @optional
  76. /// 通知验证界面将要展现
  77. /// @param captchaSession 验证会话
  78. - (void)alicomCaptchaSessionWillShow:(AlicomCaptcha4Session *)captchaSession;
  79. @end
  80. NS_ASSUME_NONNULL_END