No Description

AWSCognitoIdentityUser.h 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. //
  2. // Copyright 2014-2018 Amazon.com,
  3. // Inc. or its affiliates. All Rights Reserved.
  4. //
  5. // Licensed under the Amazon Software License (the "License").
  6. // You may not use this file except in compliance with the
  7. // License. A copy of the License is located at
  8. //
  9. // http://aws.amazon.com/asl/
  10. //
  11. // or in the "license" file accompanying this file. This file is
  12. // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  13. // CONDITIONS OF ANY KIND, express or implied. See the License
  14. // for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. #import <Foundation/Foundation.h>
  18. #import "AWSCognitoIdentityProviderService.h"
  19. /**
  20. The status of the user.
  21. <ul>
  22. <li>AWSCognitoIdentityUserStatusUnknown - The user status is unknown.</li>
  23. <li>AWSCognitoIdentityUserStatusConfirmed - The user was auto confirmed.</li>
  24. <li>AWSCognitoIdentityUserStatusUnconfirmed - The user was not confirmed.</li>
  25. </ul>
  26. */
  27. typedef NS_ENUM(NSInteger, AWSCognitoIdentityUserStatus) {
  28. AWSCognitoIdentityUserStatusUnknown = 0,
  29. AWSCognitoIdentityUserStatusConfirmed = -1000,
  30. AWSCognitoIdentityUserStatusUnconfirmed = -2000,
  31. };
  32. @class AWSCognitoIdentityUserPool;
  33. @class AWSCognitoIdentityUserSession;
  34. @class AWSCognitoIdentityUserSessionToken;
  35. @class AWSCognitoIdentityUserSettings;
  36. @class AWSCognitoIdentityUserMFAOption;
  37. @class AWSCognitoIdentityUserMfaType;
  38. @class AWSCognitoIdentityUserMfaPreferences;
  39. @class AWSCognitoIdentityUserConfirmSignUpResponse;
  40. @class AWSCognitoIdentityUserGetDetailsResponse;
  41. @class AWSCognitoIdentityUserResendConfirmationCodeResponse;
  42. @class AWSCognitoIdentityUserForgotPasswordResponse;
  43. @class AWSCognitoIdentityUserConfirmForgotPasswordResponse;
  44. @class AWSCognitoIdentityUserChangePasswordResponse;
  45. @class AWSCognitoIdentityUserAttributeType;
  46. @class AWSCognitoIdentityUserUpdateAttributesResponse;
  47. @class AWSCognitoIdentityUserDeleteAttributesResponse;
  48. @class AWSCognitoIdentityUserVerifyAttributeResponse;
  49. @class AWSCognitoIdentityUserGetAttributeVerificationCodeResponse;
  50. @class AWSCognitoIdentityUserSetUserSettingsResponse;
  51. @class AWSCognitoIdentityUserGlobalSignOutResponse;
  52. @class AWSCognitoIdentityUserListDevicesResponse;
  53. @class AWSCognitoIdentityUserUpdateDeviceStatusResponse;
  54. @class AWSCognitoIdentityUserGetDeviceResponse;
  55. @class AWSCognitoIdentityUserSetUserMfaPreferenceResponse;
  56. @class AWSCognitoIdentityUserAssociateSoftwareTokenResponse;
  57. @class AWSCognitoIdentityUserVerifySoftwareTokenResponse;
  58. NS_ASSUME_NONNULL_BEGIN
  59. @interface AWSCognitoIdentityUser : NSObject
  60. /**
  61. The username of this user
  62. */
  63. @property (nonatomic, readonly, nullable) NSString *username;
  64. /**
  65. If this user is a result of a signup, this has the confirmation status
  66. */
  67. @property (nonatomic, readonly) AWSCognitoIdentityUserStatus confirmedStatus;
  68. /**
  69. Determines whether this user has an active session or not. If the refresh token is expired
  70. the user will be prompted to authenticate when you call getSession.
  71. */
  72. @property (nonatomic, readonly, getter=isSignedIn) BOOL signedIn;
  73. /**
  74. Get the device id
  75. */
  76. @property (nonatomic, readonly) NSString * deviceId;
  77. /**
  78. Confirm a users' sign up with the confirmation code
  79. */
  80. - (AWSTask<AWSCognitoIdentityUserConfirmSignUpResponse *> *)confirmSignUp:(NSString *)confirmationCode;
  81. /**
  82. Confirm a users' sign up with the confirmation code. If forceAliasCreation is set, if another user is aliased to the same email/phone this code was sent to, reassign alias to this user.
  83. */
  84. -(AWSTask<AWSCognitoIdentityUserConfirmSignUpResponse *> *) confirmSignUp:(NSString *) confirmationCode forceAliasCreation:(BOOL)forceAliasCreation;
  85. /**
  86. Resend the confirmation code sent during sign up
  87. */
  88. - (AWSTask<AWSCognitoIdentityUserResendConfirmationCodeResponse *> *)resendConfirmationCode;
  89. /**
  90. Get a session with id, access and refresh tokens.
  91. */
  92. - (AWSTask<AWSCognitoIdentityUserSession *> *)getSession;
  93. /**
  94. Get a session with the following username and password
  95. */
  96. - (AWSTask<AWSCognitoIdentityUserSession *> *)getSession:(NSString *)username
  97. password:(NSString *)password
  98. validationData:(nullable NSArray<AWSCognitoIdentityUserAttributeType *> *)validationData;
  99. /**
  100. Get details about this user, including user attributes
  101. */
  102. - (AWSTask<AWSCognitoIdentityUserGetDetailsResponse *> *)getDetails;
  103. /**
  104. Send a code to this user to initiate the forgot password flow
  105. */
  106. - (AWSTask<AWSCognitoIdentityUserForgotPasswordResponse *> *)forgotPassword;
  107. /**
  108. Conclude the forgot password flow by providing the forgot password code and new password.
  109. */
  110. - (AWSTask<AWSCognitoIdentityUserConfirmForgotPasswordResponse *> *)confirmForgotPassword:(NSString *)confirmationCode
  111. password:(NSString *)password;
  112. /**
  113. Change this user's password
  114. */
  115. - (AWSTask<AWSCognitoIdentityUserChangePasswordResponse *> *)changePassword:(NSString *)currentPassword
  116. proposedPassword:(NSString *)proposedPassword;
  117. /**
  118. Update this user's attributes
  119. */
  120. - (AWSTask<AWSCognitoIdentityUserUpdateAttributesResponse *> *)updateAttributes:(NSArray<AWSCognitoIdentityUserAttributeType *> *)attributes;
  121. /**
  122. Delete the attributes specified by attributeNames
  123. */
  124. - (AWSTask<AWSCognitoIdentityUserDeleteAttributesResponse *> *)deleteAttributes:(NSArray<NSString *> *)attributeNames;
  125. /**
  126. Verify a user attribute upon receiving the verification code.
  127. */
  128. - (AWSTask<AWSCognitoIdentityUserVerifyAttributeResponse *> *)verifyAttribute:(NSString *)attributeName
  129. code:(NSString *)code;
  130. /**
  131. Request a verification code to verify an attribute.
  132. */
  133. - (AWSTask<AWSCognitoIdentityUserGetAttributeVerificationCodeResponse *> *)getAttributeVerificationCode:(NSString *)attributeName;
  134. /**
  135. Set the user settings for this user such as MFA
  136. */
  137. - (AWSTask<AWSCognitoIdentityUserSetUserSettingsResponse *> *)setUserSettings:(AWSCognitoIdentityUserSettings *)settings;
  138. /**
  139. Set the user mfa preference supercedes SetUserSettings
  140. */
  141. - (AWSTask<AWSCognitoIdentityUserSetUserMfaPreferenceResponse *> *)setUserMfaPreference:(AWSCognitoIdentityUserMfaPreferences *) preferences;
  142. /**
  143. Start the process of associating a software token
  144. */
  145. - (AWSTask<AWSCognitoIdentityUserAssociateSoftwareTokenResponse *> *) associateSoftwareToken;
  146. /**
  147. Complete the process of associating a software token by verifying the code and setting device friendly name
  148. */
  149. -(AWSTask<AWSCognitoIdentityUserVerifySoftwareTokenResponse *>*) verifySoftwareToken: (NSString*) userCode friendlyDeviceName: (NSString* _Nullable) friendlyDeviceName;
  150. /**
  151. Delete this user
  152. */
  153. - (AWSTask *)deleteUser;
  154. /**
  155. Remove all sessions from the keychain for this user. Last known user remains.
  156. */
  157. - (void)signOut;
  158. /**
  159. Invalidate any active sessions with the service. Last known user remains.
  160. */
  161. - (AWSTask<AWSCognitoIdentityUserGlobalSignOutResponse *> *) globalSignOut;
  162. /**
  163. Remove all sessions from the keychain for this user and clear last known user.
  164. */
  165. - (void) signOutAndClearLastKnownUser;
  166. /**
  167. Remove the id and access token from the keychain, but keep the refresh token.
  168. Use this when you have updated user attributes and want to refresh the id and access tokens.
  169. */
  170. - (void) clearSession;
  171. /**
  172. List devices for this user
  173. */
  174. - (AWSTask<AWSCognitoIdentityUserListDevicesResponse *> *) listDevices: (int) limit paginationToken:(NSString * _Nullable) paginationToken;
  175. /**
  176. Update device remembered status for a specific device id.
  177. */
  178. - (AWSTask<AWSCognitoIdentityUserUpdateDeviceStatusResponse *> *) updateDeviceStatus: (NSString *) deviceId remembered:(BOOL) remembered;
  179. /**
  180. Convenience method to update device remembered status for this device.
  181. */
  182. - (AWSTask<AWSCognitoIdentityUserUpdateDeviceStatusResponse *> *) updateDeviceStatus: (BOOL) remembered;
  183. /**
  184. Get device details for a specific deviceId.
  185. */
  186. - (AWSTask<AWSCognitoIdentityUserGetDeviceResponse *> *) getDevice: (NSString *) deviceId;
  187. /**
  188. Convenience method to get device details for this device.
  189. */
  190. - (AWSTask<AWSCognitoIdentityUserGetDeviceResponse *> *) getDevice;
  191. /**
  192. Forget (stop tracking) a specific deviceId.
  193. */
  194. - (AWSTask *) forgetDevice: (NSString *) deviceId;
  195. /**
  196. Forget (stop tracking) this device.
  197. */
  198. - (AWSTask *) forgetDevice;
  199. @end
  200. /**
  201. A User session. Encapsulates all tokens (id, access and refresh tokens) for a user.
  202. */
  203. @interface AWSCognitoIdentityUserSession : NSObject
  204. @property (nonatomic, readonly) AWSCognitoIdentityUserSessionToken * _Nullable idToken;
  205. @property (nonatomic, readonly) AWSCognitoIdentityUserSessionToken * _Nullable accessToken;
  206. @property (nonatomic, readonly) AWSCognitoIdentityUserSessionToken * _Nullable refreshToken;
  207. @property (nonatomic, readonly) NSDate * _Nullable expirationTime;
  208. @end
  209. /**
  210. A JWT session token.
  211. */
  212. @interface AWSCognitoIdentityUserSessionToken : NSObject
  213. /**
  214. The raw JWT token as a string.
  215. **/
  216. @property (nonatomic, readonly) NSString * tokenString;
  217. /**
  218. A NSDictionary of claims in this token.
  219. @deprecated This property is incorrectly typed as a [String : String], but
  220. claim values may be of several different type.
  221. */
  222. @property (nonatomic, readonly) NSDictionary<NSString *, NSString*> * claims DEPRECATED_MSG_ATTRIBUTE("Use `tokenClaims` instead.");
  223. /**
  224. A Dictionary of claims in this token
  225. */
  226. @property (nonatomic, readonly) NSDictionary<NSString *, id> * tokenClaims;
  227. @end
  228. /**
  229. User settings. Currently only mfa options.
  230. */
  231. @interface AWSCognitoIdentityUserSettings : NSObject
  232. @property (nonatomic, copy) NSArray<AWSCognitoIdentityUserMFAOption *>* _Nullable mfaOptions;
  233. @end
  234. /**
  235. User MFA preferences. Replaces user settings for mfa
  236. */
  237. @interface AWSCognitoIdentityUserMfaPreferences : NSObject
  238. @property (nonatomic, strong) AWSCognitoIdentityUserMfaType* _Nullable smsMfa;
  239. @property (nonatomic, strong) AWSCognitoIdentityUserMfaType* _Nullable softwareTokenMfa;
  240. @end
  241. /**
  242. User settings. Currently only mfa options.
  243. */
  244. @interface AWSCognitoIdentityUserMfaType : NSObject
  245. @property (nonatomic, assign) BOOL enabled;
  246. @property (nonatomic, assign) BOOL preferred;
  247. - (instancetype) initWithEnabled:(BOOL) enabled preferred:(BOOL) preferred;
  248. @end
  249. @interface AWSCognitoIdentityUserMFAOption : NSObject
  250. @property (nonatomic, strong) NSString * attributeName;
  251. @property (nonatomic, assign) AWSCognitoIdentityProviderDeliveryMediumType deliveryMedium;
  252. @end
  253. @interface AWSCognitoIdentityUserAttributeType : AWSCognitoIdentityProviderAttributeType
  254. - (instancetype) initWithName:(NSString *) name value:(NSString *) value;
  255. @end
  256. #pragma Response wrappers
  257. @interface AWSCognitoIdentityUserConfirmSignUpResponse : AWSCognitoIdentityProviderConfirmSignUpResponse
  258. @end
  259. @interface AWSCognitoIdentityUserResendConfirmationCodeResponse :AWSCognitoIdentityProviderResendConfirmationCodeResponse
  260. @end
  261. @interface AWSCognitoIdentityUserGetDetailsResponse : AWSCognitoIdentityProviderGetUserResponse
  262. @end
  263. @interface AWSCognitoIdentityUserForgotPasswordResponse : AWSCognitoIdentityProviderForgotPasswordResponse
  264. @end
  265. @interface AWSCognitoIdentityUserConfirmForgotPasswordResponse : AWSCognitoIdentityProviderConfirmForgotPasswordResponse
  266. @end
  267. @interface AWSCognitoIdentityUserChangePasswordResponse : AWSCognitoIdentityProviderChangePasswordResponse
  268. @end
  269. @interface AWSCognitoIdentityUserUpdateAttributesResponse : AWSCognitoIdentityProviderUpdateUserAttributesResponse
  270. @end
  271. @interface AWSCognitoIdentityUserDeleteAttributesResponse : AWSCognitoIdentityProviderDeleteUserAttributesResponse
  272. @end
  273. @interface AWSCognitoIdentityUserVerifyAttributeResponse : AWSCognitoIdentityProviderVerifyUserAttributeResponse
  274. @end
  275. @interface AWSCognitoIdentityUserGetAttributeVerificationCodeResponse : AWSCognitoIdentityProviderGetUserAttributeVerificationCodeResponse
  276. @end
  277. @interface AWSCognitoIdentityUserSetUserSettingsResponse : AWSCognitoIdentityProviderSetUserSettingsResponse
  278. @end
  279. @interface AWSCognitoIdentityUserGlobalSignOutResponse : AWSCognitoIdentityProviderGlobalSignOutResponse
  280. @end
  281. @interface AWSCognitoIdentityUserListDevicesResponse : AWSCognitoIdentityProviderListDevicesResponse
  282. @end
  283. @interface AWSCognitoIdentityUserUpdateDeviceStatusResponse : AWSCognitoIdentityProviderUpdateDeviceStatusResponse
  284. @end
  285. @interface AWSCognitoIdentityUserGetDeviceResponse : AWSCognitoIdentityProviderGetDeviceResponse
  286. @end
  287. @interface AWSCognitoIdentityUserVerifySoftwareTokenResponse : AWSCognitoIdentityProviderVerifySoftwareTokenResponse
  288. @end
  289. @interface AWSCognitoIdentityUserAssociateSoftwareTokenResponse : AWSCognitoIdentityProviderAssociateSoftwareTokenResponse
  290. @end
  291. @interface AWSCognitoIdentityUserSetUserMfaPreferenceResponse : AWSCognitoIdentityProviderSetUserMFAPreferenceResponse
  292. @end
  293. NS_ASSUME_NONNULL_END