@aws-amplify/auth 4.6.14 → 4.6.15-unstable.2

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