@aws-amplify/ui 3.0.6 → 3.0.10

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
@@ -16,6 +16,34 @@ declare type SignInResult = string;
16
16
  declare type Validator = (formData: AuthFormData, touchData?: AuthFormData) => ValidatorResult | Promise<ValidatorResult>;
17
17
  declare type SignInTypes = (user: string, code: string, mfaType: AuthChallengeNames.SMS_MFA | AuthChallengeNames.SOFTWARE_TOKEN_MFA) => SignInResult | Promise<SignInResult>;
18
18
 
19
+ declare const defaultServices: {
20
+ getAmplifyConfig(): Promise<{}>;
21
+ getCurrentUser(): Promise<any>;
22
+ handleSignUp(formData: any): Promise<any>;
23
+ handleSignIn({ username, password, }: {
24
+ username: string;
25
+ password: string;
26
+ }): Promise<any>;
27
+ handleConfirmSignIn({ user, code, mfaType, }: {
28
+ user: any;
29
+ code: string;
30
+ mfaType: AuthChallengeNames.SMS_MFA | AuthChallengeNames.SOFTWARE_TOKEN_MFA;
31
+ }): Promise<any>;
32
+ handleConfirmSignUp({ username, code, }: {
33
+ username: string;
34
+ code: string;
35
+ }): Promise<any>;
36
+ handleForgotPasswordSubmit({ username, code, password, }: {
37
+ username: string;
38
+ code: string;
39
+ password: string;
40
+ }): Promise<SignInResult>;
41
+ handleForgotPassword(formData: any): Promise<any>;
42
+ validateCustomSignUp(formData: any, touchData: any): Promise<ValidatorResult>;
43
+ validateConfirmPassword<Validator>(formData: any, touchData: any): Promise<ValidatorResult>;
44
+ validatePreferredUsername(formData: any, touchData: any): Promise<ValidatorResult>;
45
+ };
46
+
19
47
  declare type AuthFormData = Record<string, string>;
20
48
  interface AuthContext {
21
49
  actorRef?: any;
@@ -23,7 +51,9 @@ interface AuthContext {
23
51
  loginMechanisms?: LoginMechanism[];
24
52
  signUpAttributes?: SignUpAttribute[];
25
53
  socialProviders?: SocialProvider[];
54
+ initialState?: 'signIn' | 'signUp' | 'resetPassword';
26
55
  };
56
+ services?: Partial<typeof defaultServices>;
27
57
  user?: CognitoUserAmplify;
28
58
  username?: string;
29
59
  password?: string;
@@ -40,6 +70,7 @@ interface ServicesContext {
40
70
  interface BaseFormContext {
41
71
  authAttributes?: Record<string, any>;
42
72
  challengeName?: string;
73
+ requiredAttributes?: Array<string>;
43
74
  formValues?: AuthFormData;
44
75
  touched?: AuthFormData;
45
76
  intent?: string;
@@ -87,7 +118,7 @@ interface CognitoUserAmplify extends CognitoUser {
87
118
  username?: string;
88
119
  }
89
120
  declare type InvokeActorEventTypes = 'done.invoke.signInActor' | 'done.invoke.signUpActor' | 'done.invoke.signOutActor' | 'done.invoke.resetPasswordActor';
90
- declare type AuthEventTypes = 'CHANGE' | 'BLUR' | 'FEDERATED_SIGN_IN' | 'RESEND' | 'RESET_PASSWORD' | 'SIGN_IN' | 'SIGN_OUT' | 'SIGN_UP' | 'SKIP' | 'SUBMIT' | InvokeActorEventTypes;
121
+ declare type AuthEventTypes = 'CHANGE' | 'BLUR' | 'FEDERATED_SIGN_IN' | 'RESEND' | 'RESET_PASSWORD' | 'SIGN_IN' | 'SIGN_OUT' | 'SIGN_UP' | 'SKIP' | 'SUBMIT' | 'INIT' | InvokeActorEventTypes;
91
122
  declare enum AuthChallengeNames {
92
123
  SMS_MFA = "SMS_MFA",
93
124
  SOFTWARE_TOKEN_MFA = "SOFTWARE_TOKEN_MFA",
@@ -113,6 +144,7 @@ interface AuthEvent {
113
144
  }
114
145
  declare type AuthMachineState = State<AuthContext, AuthEvent>;
115
146
  declare type AuthInterpreter = Interpreter<AuthContext, any, AuthEvent>;
147
+ declare type AuthMachineSend = AuthInterpreter['send'];
116
148
 
117
149
  declare type NoInfer<T> = [T][T extends any ? 0 : never];
118
150
 
@@ -209,6 +241,15 @@ declare const getServiceFacade: ({ send, state }: {
209
241
  toSignUp: (data?: AuthEventData) => void;
210
242
  skipVerification: (data?: AuthEventData) => void;
211
243
  };
244
+ /**
245
+ * Listens to external auth Hub events and sends corresponding event to
246
+ * the `authService` of interest
247
+ *
248
+ * @param send - `send` function associated with the `authService` of interest
249
+ *
250
+ * @returns function that unsubscribes to the hub evenmt
251
+ */
252
+ declare const listenToAuthHub: (send: AuthMachineSend) => () => void;
212
253
 
213
254
  declare type ContactMethod = 'Email' | 'Phone Number';
214
255
  declare const censorAllButFirstAndLast: (value: string) => string;
@@ -249,6 +290,7 @@ declare const DefaultTexts: {
249
290
  readonly FAMILY_NAME: string;
250
291
  readonly GIVEN_NAME: string;
251
292
  readonly FORGOT_YOUR_PASSWORD: string;
293
+ readonly FORGOT_YOUR_PASSWORD_LEGACY: string;
252
294
  readonly HIDE_PASSWORD: string;
253
295
  readonly LOADING: string;
254
296
  readonly LOGIN_NAME: string;
@@ -302,41 +344,16 @@ declare type Dict = Record<string, string>;
302
344
  * You can also use translate<string> to handle custom strings or dynamic content.
303
345
  */
304
346
  declare function translate<T = Phrase>(phrase: NoInfer<T>): string;
347
+ /**
348
+ * Whether I18n has a translation entry for given phrase
349
+ */
350
+ declare function hasTranslation(phrase: string): boolean;
305
351
  declare const translations: Record<string, Dict>;
306
352
 
307
- declare const defaultServices: {
308
- getAmplifyConfig(): Promise<{}>;
309
- getCurrentUser(): Promise<any>;
310
- handleSignUp(formData: any): Promise<any>;
311
- handleSignIn({ username, password, }: {
312
- username: string;
313
- password: string;
314
- }): Promise<any>;
315
- handleConfirmSignIn({ user, code, mfaType, }: {
316
- user: any;
317
- code: string;
318
- mfaType: AuthChallengeNames.SMS_MFA | AuthChallengeNames.SOFTWARE_TOKEN_MFA;
319
- }): Promise<any>;
320
- handleConfirmSignUp({ username, code, }: {
321
- username: string;
322
- code: string;
323
- }): Promise<any>;
324
- handleForgotPasswordSubmit({ username, code, password, }: {
325
- username: string;
326
- code: string;
327
- password: string;
328
- }): Promise<SignInResult>;
329
- handleForgotPassword(formData: any): Promise<any>;
330
- validateCustomSignUp(formData: any, touchData: any): Promise<ValidatorResult>;
331
- validateConfirmPassword<Validator>(formData: any, touchData: any): Promise<ValidatorResult>;
332
- validatePreferredUsername(formData: any, touchData: any): Promise<ValidatorResult>;
333
- };
334
-
335
353
  declare type AuthenticatorMachineOptions = AuthContext['config'] & {
336
- initialState?: 'signIn' | 'signUp' | 'resetPassword';
337
- services?: Partial<typeof defaultServices>;
354
+ services?: AuthContext['services'];
338
355
  };
339
- declare function createAuthenticatorMachine({ initialState, loginMechanisms, signUpAttributes, socialProviders, services: customServices, }: AuthenticatorMachineOptions): xstate.StateMachine<AuthContext, any, AuthEvent, {
356
+ declare function createAuthenticatorMachine(): xstate.StateMachine<AuthContext, any, AuthEvent, {
340
357
  value: any;
341
358
  context: AuthContext;
342
359
  }, xstate.ActionObject<AuthContext, AuthEvent>>;
@@ -703,7 +720,6 @@ interface Breakpoints {
703
720
  xl: number;
704
721
  xxl: number;
705
722
  };
706
- unit: string;
707
723
  defaultBreakpoint: string;
708
724
  }
709
725
 
@@ -825,4 +841,4 @@ declare function createTheme(theme?: Theme, baseTheme?: BaseTheme): WebTheme;
825
841
 
826
842
  declare const defaultTheme: WebTheme;
827
843
 
828
- export { ActorContextWithForms, AuthActorContext, AuthActorState, AuthChallengeNames, AuthContext, AuthEvent, AuthEventData, AuthEventTypes, AuthFieldsWithDefaults, AuthFormData, AuthInputAttributes, AuthInterpreter, AuthMachineState, AuthenticatorMachineOptions, BaseTheme, BorderWidthValue, CognitoUserAmplify, ColorModeOverride, ColorValue, ContactMethod, DefaultTexts, DesignToken, Dict, FederatedIdentityProviders, FontSizeValue, FontValue, FontWeightValue, InputAttributes, InvokeActorEventTypes, LineHeightValue, LoginMechanism, LoginMechanismArray, MediaQueryOverride, NoInfer, OpacityValue, OutlineOffsetValue, OutlineWidthValue, Override, Phrase, RadiusValue, ResetPasswordContext, ResetPasswordState, SelectorOverride, ServicesContext, 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, getSendEventAliases, getServiceContextFacade, getServiceFacade, isDesignToken, signUpFieldsWithDefault, signUpFieldsWithoutDefault, translate, translations };
844
+ export { ActorContextWithForms, AuthActorContext, AuthActorState, AuthChallengeNames, AuthContext, AuthEvent, AuthEventData, AuthEventTypes, AuthFieldsWithDefaults, AuthFormData, AuthInputAttributes, AuthInterpreter, AuthMachineSend, AuthMachineState, AuthenticatorMachineOptions, BaseTheme, BorderWidthValue, CognitoUserAmplify, ColorModeOverride, ColorValue, ContactMethod, DefaultTexts, DesignToken, Dict, FederatedIdentityProviders, FontSizeValue, FontValue, FontWeightValue, InputAttributes, InvokeActorEventTypes, LineHeightValue, LoginMechanism, LoginMechanismArray, MediaQueryOverride, NoInfer, OpacityValue, OutlineOffsetValue, OutlineWidthValue, Override, Phrase, RadiusValue, ResetPasswordContext, ResetPasswordState, SelectorOverride, ServicesContext, 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, getSendEventAliases, getServiceContextFacade, getServiceFacade, hasTranslation, isDesignToken, listenToAuthHub, signUpFieldsWithDefault, signUpFieldsWithoutDefault, translate, translations };