@aws-amplify/ui 3.0.7 → 3.0.11

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;
@@ -309,39 +350,10 @@ declare function translate<T = Phrase>(phrase: NoInfer<T>): string;
309
350
  declare function hasTranslation(phrase: string): boolean;
310
351
  declare const translations: Record<string, Dict>;
311
352
 
312
- declare const defaultServices: {
313
- getAmplifyConfig(): Promise<{}>;
314
- getCurrentUser(): Promise<any>;
315
- handleSignUp(formData: any): Promise<any>;
316
- handleSignIn({ username, password, }: {
317
- username: string;
318
- password: string;
319
- }): Promise<any>;
320
- handleConfirmSignIn({ user, code, mfaType, }: {
321
- user: any;
322
- code: string;
323
- mfaType: AuthChallengeNames.SMS_MFA | AuthChallengeNames.SOFTWARE_TOKEN_MFA;
324
- }): Promise<any>;
325
- handleConfirmSignUp({ username, code, }: {
326
- username: string;
327
- code: string;
328
- }): Promise<any>;
329
- handleForgotPasswordSubmit({ username, code, password, }: {
330
- username: string;
331
- code: string;
332
- password: string;
333
- }): Promise<SignInResult>;
334
- handleForgotPassword(formData: any): Promise<any>;
335
- validateCustomSignUp(formData: any, touchData: any): Promise<ValidatorResult>;
336
- validateConfirmPassword<Validator>(formData: any, touchData: any): Promise<ValidatorResult>;
337
- validatePreferredUsername(formData: any, touchData: any): Promise<ValidatorResult>;
338
- };
339
-
340
353
  declare type AuthenticatorMachineOptions = AuthContext['config'] & {
341
- initialState?: 'signIn' | 'signUp' | 'resetPassword';
342
- services?: Partial<typeof defaultServices>;
354
+ services?: AuthContext['services'];
343
355
  };
344
- declare function createAuthenticatorMachine({ initialState, loginMechanisms, signUpAttributes, socialProviders, services: customServices, }: AuthenticatorMachineOptions): xstate.StateMachine<AuthContext, any, AuthEvent, {
356
+ declare function createAuthenticatorMachine(): xstate.StateMachine<AuthContext, any, AuthEvent, {
345
357
  value: any;
346
358
  context: AuthContext;
347
359
  }, xstate.ActionObject<AuthContext, AuthEvent>>;
@@ -829,4 +841,4 @@ declare function createTheme(theme?: Theme, baseTheme?: BaseTheme): WebTheme;
829
841
 
830
842
  declare const defaultTheme: WebTheme;
831
843
 
832
- 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, hasTranslation, 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 };