@aws-amplify/ui 3.1.0 → 3.2.0
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.
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +168 -84
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/styles.css +104 -128
- package/dist/theme.css +31 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,80 @@
|
|
|
1
1
|
import * as amazon_cognito_identity_js from 'amazon-cognito-identity-js';
|
|
2
2
|
import { CognitoUser, CodeDeliveryDetails } from 'amazon-cognito-identity-js';
|
|
3
3
|
import * as xstate from 'xstate';
|
|
4
|
-
import {
|
|
4
|
+
import { Interpreter, State, Sender } from 'xstate';
|
|
5
5
|
import { PartialDeep } from 'type-fest';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Map of each input name to its value
|
|
9
|
+
*/
|
|
10
|
+
declare type AuthFormData = Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* List of routes that support custom formFields
|
|
13
|
+
*/
|
|
14
|
+
declare type formFieldComponents = 'signIn' | 'signUp' | 'forceNewPassword' | 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'resetPassword' | 'setupTOTP';
|
|
15
|
+
/**
|
|
16
|
+
* Used to customize form field attributes for each authenticator screen.
|
|
17
|
+
*/
|
|
18
|
+
declare type FormFields = {
|
|
19
|
+
[key in formFieldComponents]?: formField;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Override option for each screen. Maps each input to override options.
|
|
23
|
+
*/
|
|
24
|
+
interface formField {
|
|
25
|
+
[key: string]: formFieldTypes;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Override options for each field
|
|
29
|
+
*/
|
|
30
|
+
interface formFieldTypes {
|
|
31
|
+
/** Will hide the label above the input if set to true */
|
|
32
|
+
labelHidden?: boolean;
|
|
33
|
+
/** Label text */
|
|
34
|
+
label?: string;
|
|
35
|
+
/** Placeholder text */
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated For internal use only, please use `isRequired` instead.
|
|
39
|
+
*/
|
|
40
|
+
required?: boolean;
|
|
41
|
+
/** Whether this field is required for submission */
|
|
42
|
+
isRequired?: boolean;
|
|
43
|
+
/** Default dial code value */
|
|
44
|
+
dialCode?: string;
|
|
45
|
+
/** TOTP issuer to be used in the QR setup */
|
|
46
|
+
totpIssuer?: string;
|
|
47
|
+
/** TOTP username to be used in the QR */
|
|
48
|
+
totpUsername?: string;
|
|
49
|
+
/** List of dial codes you want to show in phone number field */
|
|
50
|
+
dialCodeList?: Array<string>;
|
|
51
|
+
/** Integer that denotes where this field should be positioned in. */
|
|
52
|
+
order?: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Enum of known challenge names */
|
|
56
|
+
declare enum AuthChallengeNames {
|
|
57
|
+
SMS_MFA = "SMS_MFA",
|
|
58
|
+
SOFTWARE_TOKEN_MFA = "SOFTWARE_TOKEN_MFA",
|
|
59
|
+
NEW_PASSWORD_REQUIRED = "NEW_PASSWORD_REQUIRED",
|
|
60
|
+
RESET_REQUIRED = "RESET_REQUIRED",
|
|
61
|
+
MFA_SETUP = "MFA_SETUP"
|
|
62
|
+
}
|
|
63
|
+
/** Known cognito user attributes */
|
|
64
|
+
interface CognitoAttributes {
|
|
65
|
+
email: string;
|
|
66
|
+
phone_number: string;
|
|
67
|
+
[key: string]: string;
|
|
68
|
+
}
|
|
69
|
+
/** Cognito User Interface */
|
|
70
|
+
interface CognitoUserAmplify extends CognitoUser {
|
|
71
|
+
username?: string;
|
|
72
|
+
attributes?: CognitoAttributes;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Maps each input to its validation error, if any
|
|
77
|
+
*/
|
|
7
78
|
declare type ValidationError = Record<string, string>;
|
|
8
79
|
/**
|
|
9
80
|
* Return type of validator. This is `null` if there are no error, and `ValidationError` otherwise.
|
|
@@ -16,6 +87,36 @@ declare type SignInResult = string;
|
|
|
16
87
|
declare type Validator = (formData: AuthFormData, touchData?: AuthFormData) => ValidatorResult | Promise<ValidatorResult>;
|
|
17
88
|
declare type SignInTypes = (user: string, code: string, mfaType: AuthChallengeNames.SMS_MFA | AuthChallengeNames.SOFTWARE_TOKEN_MFA) => SignInResult | Promise<SignInResult>;
|
|
18
89
|
|
|
90
|
+
/** Array of auth fields that we supply defaults with */
|
|
91
|
+
declare const signUpFieldsWithDefault: readonly ["birthdate", "email", "family_name", "given_name", "middle_name", "name", "nickname", "phone_number", "preferred_username", "profile", "website"];
|
|
92
|
+
/** Auth fields that we supply defaults with */
|
|
93
|
+
declare type SignUpFieldsWithDefaults = typeof signUpFieldsWithDefault[number];
|
|
94
|
+
/** Array of auth fields that we do not supply defaults with */
|
|
95
|
+
declare const signUpFieldsWithoutDefault: readonly ["address", "gender", "locale", "picture", "updated_at", "zoneinfo"];
|
|
96
|
+
/** Auth fields that we do not supply defaults with */
|
|
97
|
+
declare type SignUpFieldsWithoutDefaults = typeof signUpFieldsWithoutDefault[number];
|
|
98
|
+
/** All known auth fields */
|
|
99
|
+
declare type SignUpAttribute = SignUpFieldsWithDefaults | SignUpFieldsWithoutDefaults;
|
|
100
|
+
/** Fields that are common in all routes */
|
|
101
|
+
declare type CommonFields = 'username' | 'password' | 'confirm_password';
|
|
102
|
+
/** Array of known login mechanisms */
|
|
103
|
+
declare const LoginMechanismArray: readonly ["username", "email", "phone_number"];
|
|
104
|
+
/** Login mechanisms that can be used to sign in */
|
|
105
|
+
declare type LoginMechanism = typeof LoginMechanismArray[number];
|
|
106
|
+
/** List of social provider Authenticator supports */
|
|
107
|
+
declare type SocialProvider = 'amazon' | 'apple' | 'facebook' | 'google';
|
|
108
|
+
/** Input fields that we provide default fields with */
|
|
109
|
+
declare type AuthFieldsWithDefaults = LoginMechanism | SignUpFieldsWithDefaults | 'confirmation_code' | 'password';
|
|
110
|
+
/** Maps default attributes values for an input */
|
|
111
|
+
interface InputAttributeDefaults {
|
|
112
|
+
label: string;
|
|
113
|
+
type: string;
|
|
114
|
+
placeholder: string;
|
|
115
|
+
autocomplete?: string;
|
|
116
|
+
}
|
|
117
|
+
/** Maps default attribute values for each Auth Field */
|
|
118
|
+
declare type AuthInputAttributes = Record<AuthFieldsWithDefaults, InputAttributeDefaults>;
|
|
119
|
+
|
|
19
120
|
declare const defaultServices: {
|
|
20
121
|
getAmplifyConfig(): Promise<{}>;
|
|
21
122
|
getCurrentUser(): Promise<any>;
|
|
@@ -44,13 +145,22 @@ declare const defaultServices: {
|
|
|
44
145
|
validatePreferredUsername(formData: any, touchData: any): Promise<ValidatorResult>;
|
|
45
146
|
};
|
|
46
147
|
|
|
47
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Data that actor returns when they are done and reach the final state
|
|
150
|
+
*/
|
|
48
151
|
interface ActorDoneData {
|
|
152
|
+
/** Any auth form values that needs to be persisted between the actors */
|
|
49
153
|
authAttributes?: AuthFormData;
|
|
154
|
+
/** String that indicates where authMachine should next transition to */
|
|
50
155
|
intent?: string;
|
|
156
|
+
/** User returned by the actor it's done */
|
|
51
157
|
user?: CognitoUserAmplify;
|
|
52
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Context interface for the top-level machine
|
|
161
|
+
*/
|
|
53
162
|
interface AuthContext {
|
|
163
|
+
/** Reference to the spawned actor */
|
|
54
164
|
actorRef?: any;
|
|
55
165
|
config?: {
|
|
56
166
|
loginMechanisms?: LoginMechanism[];
|
|
@@ -67,24 +177,31 @@ interface AuthContext {
|
|
|
67
177
|
mfaType?: AuthChallengeNames.SMS_MFA | AuthChallengeNames.SOFTWARE_TOKEN_MFA;
|
|
68
178
|
actorDoneData?: Omit<ActorDoneData, 'user'>;
|
|
69
179
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
user?: string;
|
|
74
|
-
code?: string;
|
|
75
|
-
mfaType: AuthChallengeNames.SMS_MFA | AuthChallengeNames.SOFTWARE_TOKEN_MFA;
|
|
76
|
-
}
|
|
180
|
+
/**
|
|
181
|
+
* Base context for all actors that have auth forms associated
|
|
182
|
+
*/
|
|
77
183
|
interface BaseFormContext {
|
|
184
|
+
/** Any user attributes set that needs to persist between states */
|
|
78
185
|
authAttributes?: Record<string, any>;
|
|
186
|
+
/** Current challengeName issued by Cognnito */
|
|
79
187
|
challengeName?: string;
|
|
188
|
+
/** Required attributes for form submission */
|
|
80
189
|
requiredAttributes?: Array<string>;
|
|
190
|
+
/** Maps each input name to tis value */
|
|
81
191
|
formValues?: AuthFormData;
|
|
192
|
+
/** Input (names) that has been blurred at least ones */
|
|
82
193
|
touched?: AuthFormData;
|
|
194
|
+
/** String that indicates where authMachine should next transition to */
|
|
83
195
|
intent?: string;
|
|
196
|
+
/** Error returned from remote service / API */
|
|
84
197
|
remoteError?: string;
|
|
198
|
+
/** Current user inteface the actor is working with */
|
|
85
199
|
user?: CognitoUserAmplify;
|
|
200
|
+
/** Maps each input to its validation error, if any */
|
|
86
201
|
validationError?: ValidationError;
|
|
202
|
+
/** Denotes where a confirmation code has been sent to */
|
|
87
203
|
codeDeliveryDetails?: CodeDeliveryDetails;
|
|
204
|
+
/** Default country code for all phone number fields. */
|
|
88
205
|
country_code?: string;
|
|
89
206
|
}
|
|
90
207
|
interface SignInContext extends BaseFormContext {
|
|
@@ -95,11 +212,6 @@ interface SignInContext extends BaseFormContext {
|
|
|
95
212
|
redirectIntent?: string;
|
|
96
213
|
unverifiedAttributes?: Record<string, string>;
|
|
97
214
|
}
|
|
98
|
-
declare const signUpFieldsWithDefault: readonly ["birthdate", "email", "family_name", "given_name", "middle_name", "name", "nickname", "phone_number", "preferred_username", "profile", "website"];
|
|
99
|
-
declare const signUpFieldsWithoutDefault: readonly ["address", "gender", "locale", "picture", "updated_at", "zoneinfo"];
|
|
100
|
-
declare type SignUpFieldsWithDefaults = typeof signUpFieldsWithDefault[number];
|
|
101
|
-
declare type SignUpFieldsWithoutDefaults = typeof signUpFieldsWithoutDefault[number];
|
|
102
|
-
declare type SignUpAttribute = SignUpFieldsWithDefaults | SignUpFieldsWithoutDefaults;
|
|
103
215
|
interface SignUpContext extends BaseFormContext {
|
|
104
216
|
loginMechanisms: Required<AuthContext>['config']['loginMechanisms'];
|
|
105
217
|
socialProviders: Required<AuthContext>['config']['socialProviders'];
|
|
@@ -118,74 +230,51 @@ interface SignOutContext {
|
|
|
118
230
|
user?: CognitoUserAmplify;
|
|
119
231
|
formFields?: FormFields;
|
|
120
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Context for actors that have forms
|
|
235
|
+
*/
|
|
121
236
|
declare type ActorContextWithForms = SignInContext | SignUpContext | ResetPasswordContext;
|
|
122
|
-
declare type SignInState = State<SignInContext, AuthEvent>;
|
|
123
|
-
declare type SignUpState = State<SignUpContext, AuthEvent>;
|
|
124
|
-
declare type SignOutState = State<SignOutContext, AuthEvent>;
|
|
125
|
-
declare type ResetPasswordState = State<ResetPasswordContext, AuthEvent>;
|
|
126
237
|
declare type AuthActorContext = ActorContextWithForms | SignOutContext;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
interface CognitoAttributes {
|
|
133
|
-
email: string;
|
|
134
|
-
phone_number: string;
|
|
135
|
-
[key: string]: string;
|
|
136
|
-
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Events that occur when actors are done
|
|
241
|
+
*/
|
|
137
242
|
declare type InvokeActorEventTypes = 'done.invoke.signInActor' | 'done.invoke.signUpActor' | 'done.invoke.signOutActor' | 'done.invoke.resetPasswordActor';
|
|
243
|
+
/**
|
|
244
|
+
* All known explicit events for xstate
|
|
245
|
+
*/
|
|
138
246
|
declare type AuthEventTypes = 'CHANGE' | 'BLUR' | 'FEDERATED_SIGN_IN' | 'RESEND' | 'RESET_PASSWORD' | 'SIGN_IN' | 'SIGN_OUT' | 'SIGN_UP' | 'SKIP' | 'SUBMIT' | 'INIT' | InvokeActorEventTypes;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
NEW_PASSWORD_REQUIRED = "NEW_PASSWORD_REQUIRED",
|
|
143
|
-
RESET_REQUIRED = "RESET_REQUIRED",
|
|
144
|
-
MFA_SETUP = "MFA_SETUP"
|
|
145
|
-
}
|
|
146
|
-
interface InputAttributes {
|
|
147
|
-
label: string;
|
|
148
|
-
type: string;
|
|
149
|
-
placeholder: string;
|
|
150
|
-
autocomplete?: string;
|
|
151
|
-
}
|
|
152
|
-
declare const LoginMechanismArray: readonly ["username", "email", "phone_number"];
|
|
153
|
-
declare type CommonFields = 'username' | 'password' | 'confirm_password';
|
|
154
|
-
declare type LoginMechanism = typeof LoginMechanismArray[number];
|
|
155
|
-
declare type SocialProvider = 'amazon' | 'apple' | 'facebook' | 'google';
|
|
156
|
-
declare type formFieldComponents = 'signIn' | 'signUp' | 'forceNewPassword' | 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'resetPassword' | 'setupTOTP';
|
|
157
|
-
declare type FormFields = {
|
|
158
|
-
[key in formFieldComponents]?: formField;
|
|
159
|
-
};
|
|
160
|
-
interface formField {
|
|
161
|
-
[key: string]: formFieldTypes;
|
|
162
|
-
}
|
|
163
|
-
interface formFieldTypes {
|
|
164
|
-
labelHidden?: boolean;
|
|
165
|
-
label?: string;
|
|
166
|
-
placeholder?: string;
|
|
167
|
-
/**
|
|
168
|
-
* @deprecated Internal use only, please use `isRequired` instead.
|
|
169
|
-
*/
|
|
170
|
-
required?: boolean;
|
|
171
|
-
isRequired?: boolean;
|
|
172
|
-
dialCode?: string;
|
|
173
|
-
totpIssuer?: string;
|
|
174
|
-
totpUsername?: string;
|
|
175
|
-
dialCodeList?: Array<string>;
|
|
176
|
-
order?: number;
|
|
177
|
-
}
|
|
178
|
-
declare type AuthFieldsWithDefaults = LoginMechanism | SignUpFieldsWithDefaults | 'confirmation_code' | 'password';
|
|
179
|
-
declare type AuthInputAttributes = Record<AuthFieldsWithDefaults, InputAttributes>;
|
|
247
|
+
/**
|
|
248
|
+
* Data payload for auth events
|
|
249
|
+
*/
|
|
180
250
|
declare type AuthEventData = Record<PropertyKey, any>;
|
|
251
|
+
/** Top-level auth machine event interface */
|
|
181
252
|
interface AuthEvent {
|
|
182
253
|
type: AuthEventTypes;
|
|
183
254
|
data?: AuthEventData;
|
|
184
255
|
}
|
|
185
|
-
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* This files provides types that describe general shape of
|
|
259
|
+
* authenticator machine and its intepreter.
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Intefrace for `authMachine` machine interpreter
|
|
264
|
+
*/
|
|
186
265
|
declare type AuthInterpreter = Interpreter<AuthContext, any, AuthEvent>;
|
|
266
|
+
/**
|
|
267
|
+
* Function type for `send` in `authMachine`
|
|
268
|
+
*/
|
|
187
269
|
declare type AuthMachineSend = AuthInterpreter['send'];
|
|
188
270
|
|
|
271
|
+
declare type SignInState = State<SignInContext, AuthEvent>;
|
|
272
|
+
declare type SignUpState = State<SignUpContext, AuthEvent>;
|
|
273
|
+
declare type SignOutState = State<SignOutContext, AuthEvent>;
|
|
274
|
+
declare type ResetPasswordState = State<ResetPasswordContext, AuthEvent>;
|
|
275
|
+
declare type AuthActorState = State<AuthActorContext, AuthEvent>;
|
|
276
|
+
declare type AuthMachineState = State<AuthContext, AuthEvent>;
|
|
277
|
+
|
|
189
278
|
declare type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
190
279
|
|
|
191
280
|
declare const authInputAttributes: AuthInputAttributes;
|
|
@@ -210,8 +299,8 @@ declare const getAliasInfoFromContext: (context: AuthContext, alias?: LoginMecha
|
|
|
210
299
|
* secondaryAliases.
|
|
211
300
|
*/
|
|
212
301
|
declare const getConfiguredAliases: (context: AuthContext) => {
|
|
213
|
-
primaryAlias: "
|
|
214
|
-
secondaryAliases: ("
|
|
302
|
+
primaryAlias: "email" | "phone_number" | "username";
|
|
303
|
+
secondaryAliases: ("email" | "phone_number" | "username")[];
|
|
215
304
|
};
|
|
216
305
|
/**
|
|
217
306
|
* Get the state of current actor. This is useful for checking which screen
|
|
@@ -671,7 +760,7 @@ declare type WebShadows = {
|
|
|
671
760
|
[Property in keyof Shadows]: WebDesignToken<ShadowValue>;
|
|
672
761
|
};
|
|
673
762
|
|
|
674
|
-
declare type
|
|
763
|
+
declare type SpaceSizes = {
|
|
675
764
|
xxxs: DesignToken<SpaceValue>;
|
|
676
765
|
xxs: DesignToken<SpaceValue>;
|
|
677
766
|
xs: DesignToken<SpaceValue>;
|
|
@@ -681,16 +770,11 @@ declare type Space = {
|
|
|
681
770
|
xl: DesignToken<SpaceValue>;
|
|
682
771
|
xxl: DesignToken<SpaceValue>;
|
|
683
772
|
xxxl: DesignToken<SpaceValue>;
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
medium: DesignToken<SpaceValue>;
|
|
690
|
-
large: DesignToken<SpaceValue>;
|
|
691
|
-
xl: DesignToken<SpaceValue>;
|
|
692
|
-
xxl: DesignToken<SpaceValue>;
|
|
693
|
-
xxxl: DesignToken<SpaceValue>;
|
|
773
|
+
};
|
|
774
|
+
declare type Space = SpaceSizes & {
|
|
775
|
+
zero: DesignToken<SpaceValue>;
|
|
776
|
+
relative: SpaceSizes & {
|
|
777
|
+
full: DesignToken<SpaceValue>;
|
|
694
778
|
};
|
|
695
779
|
};
|
|
696
780
|
declare type WebSpace = {
|
|
@@ -891,4 +975,4 @@ declare function createTheme(theme?: Theme, baseTheme?: BaseTheme): WebTheme;
|
|
|
891
975
|
|
|
892
976
|
declare const defaultTheme: WebTheme;
|
|
893
977
|
|
|
894
|
-
export { ActorContextWithForms, ActorDoneData, AuthActorContext, AuthActorState, AuthChallengeNames, AuthContext, AuthEvent, AuthEventData, AuthEventTypes, AuthFieldsWithDefaults, AuthFormData, AuthInputAttributes, AuthInterpreter, AuthMachineSend, AuthMachineState, AuthenticatorMachineOptions, BaseTheme, BorderWidthValue, CognitoAttributes, CognitoUserAmplify, ColorModeOverride, ColorValue, CommonFields, ContactMethod, DefaultTexts, DesignToken, Dict, FederatedIdentityProviders, FontSizeValue, FontValue, FontWeightValue, FormFields,
|
|
978
|
+
export { ActorContextWithForms, ActorDoneData, AuthActorContext, AuthActorState, AuthChallengeNames, AuthContext, AuthEvent, AuthEventData, AuthEventTypes, AuthFieldsWithDefaults, AuthFormData, AuthInputAttributes, AuthInterpreter, AuthMachineSend, AuthMachineState, AuthenticatorMachineOptions, BaseTheme, BorderWidthValue, CognitoAttributes, CognitoUserAmplify, ColorModeOverride, ColorValue, CommonFields, ContactMethod, DefaultTexts, DesignToken, Dict, FederatedIdentityProviders, FontSizeValue, FontValue, FontWeightValue, FormFields, InputAttributeDefaults, InvokeActorEventTypes, LineHeightValue, LoginMechanism, LoginMechanismArray, MediaQueryOverride, NoInfer, OpacityValue, OutlineOffsetValue, OutlineWidthValue, Override, Phrase, RadiusValue, ResetPasswordContext, ResetPasswordState, SelectorOverride, ShadowValue, SignInContext, SignInResult, SignInState, SignInTypes, SignOutContext, SignOutState, SignUpAttribute, SignUpContext, SignUpFieldsWithDefaults, SignUpFieldsWithoutDefaults, SignUpState, SocialProvider, SpaceValue, Theme, TimeValue, TransformValue, ValidationError, Validator, ValidatorResult, WebDesignToken, WebTheme, authInputAttributes, censorAllButFirstAndLast, censorPhoneNumber, countryDialCodes, createAuthenticatorMachine, createTheme, defaultTheme, formField, formFieldComponents, formFieldTypes, getActorContext, getActorState, getAliasInfoFromContext, getConfiguredAliases, getFormDataFromEvent, getSendEventAliases, getServiceContextFacade, getServiceFacade, hasTranslation, isDesignToken, listenToAuthHub, setFormOrder, signUpFieldsWithDefault, signUpFieldsWithoutDefault, translate, translations };
|