@aws-amplify/auth 4.6.2-next.32 → 4.6.2-next.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/lib/Auth.d.ts +303 -0
  2. package/lib/Auth.js +150 -155
  3. package/lib/Auth.js.map +1 -1
  4. package/lib/Errors.d.ts +9 -0
  5. package/lib/Errors.js +2 -12
  6. package/lib/Errors.js.map +1 -1
  7. package/lib/OAuth/OAuth.d.ts +29 -0
  8. package/lib/OAuth/OAuth.js +2 -12
  9. package/lib/OAuth/OAuth.js.map +1 -1
  10. package/lib/OAuth/oauthStorage.d.ts +5 -0
  11. package/lib/OAuth/oauthStorage.js +2 -12
  12. package/lib/OAuth/oauthStorage.js.map +1 -1
  13. package/lib/OAuth/oauthStorage.native.d.ts +5 -0
  14. package/lib/OAuth/oauthStorage.native.js +2 -12
  15. package/lib/OAuth/oauthStorage.native.js.map +1 -1
  16. package/lib/OAuth/urlOpener.d.ts +1 -0
  17. package/lib/OAuth/urlOpener.js +2 -12
  18. package/lib/OAuth/urlOpener.js.map +1 -1
  19. package/lib/OAuth/urlOpener.native.d.ts +1 -0
  20. package/lib/OAuth/urlOpener.native.js +2 -12
  21. package/lib/OAuth/urlOpener.native.js.map +1 -1
  22. package/lib/common/AuthErrorStrings.d.ts +17 -0
  23. package/lib/index.d.ts +9 -0
  24. package/lib/index.js +2 -12
  25. package/lib/index.js.map +1 -1
  26. package/lib/types/Auth.d.ts +170 -0
  27. package/lib/types/Auth.js +2 -12
  28. package/lib/types/Auth.js.map +1 -1
  29. package/lib/types/index.d.ts +1 -0
  30. package/lib/types/index.js +2 -12
  31. package/lib/types/index.js.map +1 -1
  32. package/lib/urlListener.d.ts +2 -0
  33. package/lib/urlListener.js +2 -12
  34. package/lib/urlListener.js.map +1 -1
  35. package/lib/urlListener.native.d.ts +2 -0
  36. package/lib/urlListener.native.js +2 -12
  37. package/lib/urlListener.native.js.map +1 -1
  38. package/lib-esm/Auth.d.ts +2 -0
  39. package/lib-esm/Auth.js +150 -155
  40. package/lib-esm/Auth.js.map +1 -1
  41. package/lib-esm/Errors.js +2 -12
  42. package/lib-esm/Errors.js.map +1 -1
  43. package/lib-esm/OAuth/OAuth.js +2 -12
  44. package/lib-esm/OAuth/OAuth.js.map +1 -1
  45. package/lib-esm/OAuth/oauthStorage.js +2 -12
  46. package/lib-esm/OAuth/oauthStorage.js.map +1 -1
  47. package/lib-esm/OAuth/oauthStorage.native.js +2 -12
  48. package/lib-esm/OAuth/oauthStorage.native.js.map +1 -1
  49. package/lib-esm/OAuth/urlOpener.js +2 -12
  50. package/lib-esm/OAuth/urlOpener.js.map +1 -1
  51. package/lib-esm/OAuth/urlOpener.native.js +2 -12
  52. package/lib-esm/OAuth/urlOpener.native.js.map +1 -1
  53. package/lib-esm/index.js +2 -12
  54. package/lib-esm/index.js.map +1 -1
  55. package/lib-esm/types/Auth.js +2 -12
  56. package/lib-esm/types/Auth.js.map +1 -1
  57. package/lib-esm/types/index.js +2 -12
  58. package/lib-esm/types/index.js.map +1 -1
  59. package/lib-esm/urlListener.js +2 -12
  60. package/lib-esm/urlListener.js.map +1 -1
  61. package/lib-esm/urlListener.native.js +2 -12
  62. package/lib-esm/urlListener.native.js.map +1 -1
  63. package/package.json +6 -6
  64. package/src/Auth.ts +109 -124
  65. package/src/Errors.ts +2 -12
  66. package/src/OAuth/OAuth.ts +2 -12
  67. package/src/OAuth/oauthStorage.native.ts +2 -12
  68. package/src/OAuth/oauthStorage.ts +2 -12
  69. package/src/OAuth/urlOpener.native.ts +2 -12
  70. package/src/OAuth/urlOpener.ts +2 -12
  71. package/src/index.ts +2 -12
  72. package/src/types/Auth.ts +2 -12
  73. package/src/types/index.ts +2 -12
  74. package/src/urlListener.native.ts +2 -12
  75. package/src/urlListener.ts +2 -12
package/lib/Auth.d.ts ADDED
@@ -0,0 +1,303 @@
1
+ import { AuthOptions, FederatedResponse, SignUpParams, FederatedUser, ConfirmSignUpOptions, SignOutOpts, CurrentUserOpts, GetPreferredMFAOpts, SignInOpts, FederatedSignInOptionsCustom, LegacyProvider, FederatedSignInOptions, ClientMetaData } from './types';
2
+ import { ICredentials } from '@aws-amplify/core';
3
+ import { ISignUpResult, CognitoUser, MFAOption, CognitoUserSession, CognitoUserAttribute, NodeCallback } from 'amazon-cognito-identity-js';
4
+ import { AuthError } from './Errors';
5
+ import { IAuthDevice } from './types/Auth';
6
+ /**
7
+ * Provide authentication steps
8
+ */
9
+ export declare class AuthClass {
10
+ private _config;
11
+ private userPool;
12
+ private user;
13
+ private _oAuthHandler;
14
+ private _storage;
15
+ private _storageSync;
16
+ private oAuthFlowInProgress;
17
+ private pendingSignIn;
18
+ private autoSignInInitiated;
19
+ private inflightSessionPromise;
20
+ Credentials: import("@aws-amplify/core").CredentialsClass;
21
+ /**
22
+ * Initialize Auth with AWS configurations
23
+ * @param {Object} config - Configuration of the Auth
24
+ */
25
+ constructor(config: AuthOptions);
26
+ getModuleName(): string;
27
+ configure(config?: any): AuthOptions;
28
+ wrapRefreshSessionCallback: (callback: NodeCallback<Error, any>) => NodeCallback<Error, any>;
29
+ /**
30
+ * Sign up with username, password and other attributes like phone, email
31
+ * @param {String | object} params - The user attributes used for signin
32
+ * @param {String[]} restOfAttrs - for the backward compatability
33
+ * @return - A promise resolves callback data if success
34
+ */
35
+ signUp(params: string | SignUpParams, ...restOfAttrs: string[]): Promise<ISignUpResult>;
36
+ private handleAutoSignIn;
37
+ private handleCodeAutoSignIn;
38
+ private handleLinkAutoSignIn;
39
+ private signInAfterUserConfirmed;
40
+ /**
41
+ * Send the verification code to confirm sign up
42
+ * @param {String} username - The username to be confirmed
43
+ * @param {String} code - The verification code
44
+ * @param {ConfirmSignUpOptions} options - other options for confirm signup
45
+ * @return - A promise resolves callback data if success
46
+ */
47
+ confirmSignUp(username: string, code: string, options?: ConfirmSignUpOptions): Promise<any>;
48
+ private isTrueStorageValue;
49
+ /**
50
+ * Resend the verification code
51
+ * @param {String} username - The username to be confirmed
52
+ * @param {ClientMetadata} clientMetadata - Metadata to be passed to Cognito Lambda triggers
53
+ * @return - A promise resolves code delivery details if successful
54
+ */
55
+ resendSignUp(username: string, clientMetadata?: ClientMetaData): Promise<any>;
56
+ /**
57
+ * Sign in
58
+ * @param {String | SignInOpts} usernameOrSignInOpts - The username to be signed in or the sign in options
59
+ * @param {String} pw - The password of the username
60
+ * @param {ClientMetaData} clientMetadata - Client metadata for custom workflows
61
+ * @return - A promise resolves the CognitoUser
62
+ */
63
+ signIn(usernameOrSignInOpts: string | SignInOpts, pw?: string, clientMetadata?: ClientMetaData): Promise<CognitoUser | any>;
64
+ /**
65
+ * Return an object with the authentication callbacks
66
+ * @param {CognitoUser} user - the cognito user object
67
+ * @param {} resolve - function called when resolving the current step
68
+ * @param {} reject - function called when rejecting the current step
69
+ * @return - an object with the callback methods for user authentication
70
+ */
71
+ private authCallbacks;
72
+ /**
73
+ * Sign in with a password
74
+ * @private
75
+ * @param {AuthenticationDetails} authDetails - the user sign in data
76
+ * @return - A promise resolves the CognitoUser object if success or mfa required
77
+ */
78
+ private signInWithPassword;
79
+ /**
80
+ * Sign in without a password
81
+ * @private
82
+ * @param {AuthenticationDetails} authDetails - the user sign in data
83
+ * @return - A promise resolves the CognitoUser object if success or mfa required
84
+ */
85
+ private signInWithoutPassword;
86
+ /**
87
+ * This was previously used by an authenticated user to get MFAOptions,
88
+ * but no longer returns a meaningful response. Refer to the documentation for
89
+ * how to setup and use MFA: https://docs.amplify.aws/lib/auth/mfa/q/platform/js
90
+ * @deprecated
91
+ * @param {CognitoUser} user - the current user
92
+ * @return - A promise resolves the current preferred mfa option if success
93
+ */
94
+ getMFAOptions(user: CognitoUser | any): Promise<MFAOption[]>;
95
+ /**
96
+ * get preferred mfa method
97
+ * @param {CognitoUser} user - the current cognito user
98
+ * @param {GetPreferredMFAOpts} params - options for getting the current user preferred MFA
99
+ */
100
+ getPreferredMFA(user: CognitoUser | any, params?: GetPreferredMFAOpts): Promise<string>;
101
+ private _getMfaTypeFromUserData;
102
+ private _getUserData;
103
+ /**
104
+ * set preferred MFA method
105
+ * @param {CognitoUser} user - the current Cognito user
106
+ * @param {string} mfaMethod - preferred mfa method
107
+ * @return - A promise resolve if success
108
+ */
109
+ setPreferredMFA(user: CognitoUser | any, mfaMethod: 'TOTP' | 'SMS' | 'NOMFA' | 'SMS_MFA' | 'SOFTWARE_TOKEN_MFA'): Promise<string>;
110
+ /**
111
+ * disable SMS
112
+ * @deprecated
113
+ * @param {CognitoUser} user - the current user
114
+ * @return - A promise resolves is success
115
+ */
116
+ disableSMS(user: CognitoUser): Promise<string>;
117
+ /**
118
+ * enable SMS
119
+ * @deprecated
120
+ * @param {CognitoUser} user - the current user
121
+ * @return - A promise resolves is success
122
+ */
123
+ enableSMS(user: CognitoUser): Promise<string>;
124
+ /**
125
+ * Setup TOTP
126
+ * @param {CognitoUser} user - the current user
127
+ * @return - A promise resolves with the secret code if success
128
+ */
129
+ setupTOTP(user: CognitoUser | any): Promise<string>;
130
+ /**
131
+ * verify TOTP setup
132
+ * @param {CognitoUser} user - the current user
133
+ * @param {string} challengeAnswer - challenge answer
134
+ * @return - A promise resolves is success
135
+ */
136
+ verifyTotpToken(user: CognitoUser | any, challengeAnswer: string): Promise<CognitoUserSession>;
137
+ /**
138
+ * Send MFA code to confirm sign in
139
+ * @param {Object} user - The CognitoUser object
140
+ * @param {String} code - The confirmation code
141
+ */
142
+ confirmSignIn(user: CognitoUser | any, code: string, mfaType?: 'SMS_MFA' | 'SOFTWARE_TOKEN_MFA' | null, clientMetadata?: ClientMetaData): Promise<CognitoUser | any>;
143
+ completeNewPassword(user: CognitoUser | any, password: string, requiredAttributes?: any, clientMetadata?: ClientMetaData): Promise<CognitoUser | any>;
144
+ /**
145
+ * Send the answer to a custom challenge
146
+ * @param {CognitoUser} user - The CognitoUser object
147
+ * @param {String} challengeResponses - The confirmation code
148
+ */
149
+ sendCustomChallengeAnswer(user: CognitoUser | any, challengeResponses: string, clientMetadata?: ClientMetaData): Promise<CognitoUser | any>;
150
+ /**
151
+ * Delete an authenticated users' attributes
152
+ * @param {CognitoUser} - The currently logged in user object
153
+ * @return {Promise}
154
+ **/
155
+ deleteUserAttributes(user: CognitoUser | any, attributeNames: string[]): Promise<unknown>;
156
+ /**
157
+ * Delete the current authenticated user
158
+ * @return {Promise}
159
+ **/
160
+ deleteUser(): Promise<string | void>;
161
+ /**
162
+ * Update an authenticated users' attributes
163
+ * @param {CognitoUser} - The currently logged in user object
164
+ * @return {Promise}
165
+ **/
166
+ updateUserAttributes(user: CognitoUser | any, attributes: object, clientMetadata?: ClientMetaData): Promise<string>;
167
+ /**
168
+ * Return user attributes
169
+ * @param {Object} user - The CognitoUser object
170
+ * @return - A promise resolves to user attributes if success
171
+ */
172
+ userAttributes(user: CognitoUser | any): Promise<CognitoUserAttribute[]>;
173
+ verifiedContact(user: CognitoUser | any): Promise<{
174
+ verified: {};
175
+ unverified: {};
176
+ }>;
177
+ private isErrorWithMessage;
178
+ private isTokenRevokedError;
179
+ private isRefreshTokenRevokedError;
180
+ private isUserDisabledError;
181
+ private isUserDoesNotExistError;
182
+ private isRefreshTokenExpiredError;
183
+ private isSignedInHostedUI;
184
+ private isSessionInvalid;
185
+ private cleanUpInvalidSession;
186
+ /**
187
+ * Get current authenticated user
188
+ * @return - A promise resolves to current authenticated CognitoUser if success
189
+ */
190
+ currentUserPoolUser(params?: CurrentUserOpts): Promise<CognitoUser | any>;
191
+ private isOAuthInProgress;
192
+ /**
193
+ * Get current authenticated user
194
+ * @param {CurrentUserOpts} - options for getting the current user
195
+ * @return - A promise resolves to current authenticated CognitoUser if success
196
+ */
197
+ currentAuthenticatedUser(params?: CurrentUserOpts): Promise<CognitoUser | any>;
198
+ /**
199
+ * Get current user's session
200
+ * @return - A promise resolves to session object if success
201
+ */
202
+ currentSession(): Promise<CognitoUserSession>;
203
+ private _userSession;
204
+ /**
205
+ * Get the corresponding user session
206
+ * @param {Object} user - The CognitoUser object
207
+ * @return - A promise resolves to the session
208
+ */
209
+ userSession(user: any): Promise<CognitoUserSession>;
210
+ /**
211
+ * Get authenticated credentials of current user.
212
+ * @return - A promise resolves to be current user's credentials
213
+ */
214
+ currentUserCredentials(): Promise<ICredentials>;
215
+ currentCredentials(): Promise<ICredentials>;
216
+ /**
217
+ * Initiate an attribute confirmation request
218
+ * @param {Object} user - The CognitoUser
219
+ * @param {Object} attr - The attributes to be verified
220
+ * @return - A promise resolves to callback data if success
221
+ */
222
+ verifyUserAttribute(user: CognitoUser | any, attr: string, clientMetadata?: ClientMetaData): Promise<void>;
223
+ /**
224
+ * Confirm an attribute using a confirmation code
225
+ * @param {Object} user - The CognitoUser
226
+ * @param {Object} attr - The attribute to be verified
227
+ * @param {String} code - The confirmation code
228
+ * @return - A promise resolves to callback data if success
229
+ */
230
+ verifyUserAttributeSubmit(user: CognitoUser | any, attr: string, code: string): Promise<string>;
231
+ verifyCurrentUserAttribute(attr: string): Promise<void>;
232
+ /**
233
+ * Confirm current user's attribute using a confirmation code
234
+ * @param {Object} attr - The attribute to be verified
235
+ * @param {String} code - The confirmation code
236
+ * @return - A promise resolves to callback data if success
237
+ */
238
+ verifyCurrentUserAttributeSubmit(attr: string, code: string): Promise<string>;
239
+ private cognitoIdentitySignOut;
240
+ private oAuthSignOutRedirect;
241
+ private oAuthSignOutAndResolve;
242
+ private oAuthSignOutRedirectOrReject;
243
+ /**
244
+ * Sign out method
245
+ * @
246
+ * @return - A promise resolved if success
247
+ */
248
+ signOut(opts?: SignOutOpts): Promise<any>;
249
+ private cleanCachedItems;
250
+ /**
251
+ * Change a password for an authenticated user
252
+ * @param {Object} user - The CognitoUser object
253
+ * @param {String} oldPassword - the current password
254
+ * @param {String} newPassword - the requested new password
255
+ * @return - A promise resolves if success
256
+ */
257
+ changePassword(user: CognitoUser | any, oldPassword: string, newPassword: string, clientMetadata?: ClientMetaData): Promise<'SUCCESS'>;
258
+ /**
259
+ * Initiate a forgot password request
260
+ * @param {String} username - the username to change password
261
+ * @return - A promise resolves if success
262
+ */
263
+ forgotPassword(username: string, clientMetadata?: ClientMetaData): Promise<any>;
264
+ /**
265
+ * Confirm a new password using a confirmation Code
266
+ * @param {String} username - The username
267
+ * @param {String} code - The confirmation code
268
+ * @param {String} password - The new password
269
+ * @return - A promise that resolves if success
270
+ */
271
+ forgotPasswordSubmit(username: string, code: string, password: string, clientMetadata?: ClientMetaData): Promise<string>;
272
+ /**
273
+ * Get user information
274
+ * @async
275
+ * @return {Object }- current User's information
276
+ */
277
+ currentUserInfo(): Promise<any>;
278
+ federatedSignIn(options?: FederatedSignInOptions): Promise<ICredentials>;
279
+ federatedSignIn(provider: LegacyProvider, response: FederatedResponse, user: FederatedUser): Promise<ICredentials>;
280
+ federatedSignIn(options?: FederatedSignInOptionsCustom): Promise<ICredentials>;
281
+ /**
282
+ * Used to complete the OAuth flow with or without the Cognito Hosted UI
283
+ * @param {String} URL - optional parameter for customers to pass in the response URL
284
+ */
285
+ private _handleAuthResponse;
286
+ /**
287
+ * Compact version of credentials
288
+ * @param {Object} credentials
289
+ * @return {Object} - Credentials
290
+ */
291
+ essentialCredentials(credentials: any): ICredentials;
292
+ private attributesToObject;
293
+ private isTruthyString;
294
+ private createCognitoUser;
295
+ private _isValidAuthStorage;
296
+ private noUserPoolErrorHandler;
297
+ private rejectAuthError;
298
+ private rejectNoUserPool;
299
+ rememberDevice(): Promise<string | AuthError>;
300
+ forgetDevice(): Promise<void>;
301
+ fetchDevices(): Promise<IAuthDevice[]>;
302
+ }
303
+ export declare const Auth: AuthClass;