@aws-amplify/ui 3.2.1 → 3.3.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/index.d.ts CHANGED
@@ -51,6 +51,11 @@ interface FormFieldOptions {
51
51
  /** Integer that denotes where this field should be positioned in. */
52
52
  order?: number;
53
53
  }
54
+ declare type PasswordPolicyRules = 'REQUIRES_LOWERCASE' | 'REQUIRES_NUMBERS' | 'REQUIRES_SYMBOLS' | 'REQUIRES_UPPERCASE';
55
+ interface PasswordSettings {
56
+ passwordPolicyMinLength: number;
57
+ passwordPolicyCharacters: Array<PasswordPolicyRules>;
58
+ }
54
59
 
55
60
  /** Enum of known challenge names */
56
61
  declare enum AuthChallengeNames {
@@ -84,7 +89,7 @@ interface CognitoUserAmplify extends CognitoUser {
84
89
  /**
85
90
  * Maps each input to its validation error, if any
86
91
  */
87
- declare type ValidationError = Record<string, string>;
92
+ declare type ValidationError = Record<string, string | string[]>;
88
93
  /**
89
94
  * Return type of validator. This is `null` if there are no error, and `ValidationError` otherwise.
90
95
  */
@@ -93,7 +98,7 @@ declare type SignInResult = string;
93
98
  /**
94
99
  * Validates the given formData. This can be synchronous or asynchronous.
95
100
  */
96
- declare type Validator = (formData: AuthFormData, touchData?: AuthFormData) => ValidatorResult | Promise<ValidatorResult>;
101
+ declare type Validator = (formData: AuthFormData, touchData?: AuthFormData, passwordSettings?: PasswordSettings) => ValidatorResult | Promise<ValidatorResult>;
97
102
  declare type SignInTypes = (user: string, code: string, mfaType: AuthChallengeNames.SMS_MFA | AuthChallengeNames.SOFTWARE_TOKEN_MFA) => SignInResult | Promise<SignInResult>;
98
103
 
99
104
  /** Array of auth fields that we supply defaults with */
@@ -150,7 +155,8 @@ declare const defaultServices: {
150
155
  }): Promise<SignInResult>;
151
156
  handleForgotPassword(formData: any): Promise<any>;
152
157
  validateCustomSignUp(formData: any, touchData: any): Promise<ValidatorResult>;
153
- validateConfirmPassword<Validator>(formData: any, touchData: any): Promise<ValidatorResult>;
158
+ validateFormPassword<Validator>(formData: any, touchData: any, passwordSettings: PasswordSettings): Promise<ValidatorResult>;
159
+ validateConfirmPassword<Validator_1>(formData: any, touchData: any): Promise<ValidatorResult>;
154
160
  validatePreferredUsername(formData: any, touchData: any): Promise<ValidatorResult>;
155
161
  };
156
162
 
@@ -177,6 +183,7 @@ interface AuthContext {
177
183
  socialProviders?: SocialProvider[];
178
184
  formFields?: FormFields;
179
185
  initialState?: 'signIn' | 'signUp' | 'resetPassword';
186
+ passwordSettings?: PasswordSettings;
180
187
  };
181
188
  services?: Partial<typeof defaultServices>;
182
189
  user?: CognitoUserAmplify;
@@ -208,6 +215,8 @@ interface BaseFormContext {
208
215
  user?: CognitoUserAmplify;
209
216
  /** Maps each input to its validation error, if any */
210
217
  validationError?: ValidationError;
218
+ /** Maps each password validation rule */
219
+ passwordSettings?: PasswordSettings;
211
220
  /** Denotes where a confirmation code has been sent to */
212
221
  codeDeliveryDetails?: CodeDeliveryDetails;
213
222
  /** Default country code for all phone number fields. */
@@ -351,7 +360,7 @@ declare const getServiceContextFacade: (state: AuthMachineState) => {
351
360
  route: string;
352
361
  user: CognitoUserAmplify;
353
362
  validationErrors: {
354
- [x: string]: string;
363
+ [x: string]: string | string[];
355
364
  };
356
365
  codeDeliveryDetails: amazon_cognito_identity_js.CodeDeliveryDetails;
357
366
  };
@@ -365,7 +374,7 @@ declare const getServiceFacade: ({ send, state }: {
365
374
  route: string;
366
375
  user: CognitoUserAmplify;
367
376
  validationErrors: {
368
- [x: string]: string;
377
+ [x: string]: string | string[];
369
378
  };
370
379
  codeDeliveryDetails: amazon_cognito_identity_js.CodeDeliveryDetails;
371
380
  resendCode: (data?: AuthEventData) => void;
@@ -994,4 +1003,4 @@ declare function createTheme(theme?: Theme, baseTheme?: BaseTheme): WebTheme;
994
1003
 
995
1004
  declare const defaultTheme: WebTheme;
996
1005
 
997
- 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, FormField, FormFieldComponents, FormFieldOptions, 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, getActorContext, getActorState, getAliasInfoFromContext, getConfiguredAliases, getFormDataFromEvent, getSendEventAliases, getServiceContextFacade, getServiceFacade, hasTranslation, isDesignToken, listenToAuthHub, setFormOrder, signUpFieldsWithDefault, signUpFieldsWithoutDefault, translate, translations };
1006
+ 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, FormField, FormFieldComponents, FormFieldOptions, FormFields, InputAttributeDefaults, InvokeActorEventTypes, LineHeightValue, LoginMechanism, LoginMechanismArray, MediaQueryOverride, NoInfer, OpacityValue, OutlineOffsetValue, OutlineWidthValue, Override, PasswordPolicyRules, PasswordSettings, 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, getActorContext, getActorState, getAliasInfoFromContext, getConfiguredAliases, getFormDataFromEvent, getSendEventAliases, getServiceContextFacade, getServiceFacade, hasTranslation, isDesignToken, listenToAuthHub, setFormOrder, signUpFieldsWithDefault, signUpFieldsWithoutDefault, translate, translations };