@leancodepl/kratos 9.2.0 → 9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/kratos",
3
- "version": "9.2.0",
3
+ "version": "9.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -10,7 +10,7 @@
10
10
  "node": ">=18.0.0"
11
11
  },
12
12
  "dependencies": {
13
- "@leancodepl/utils": "9.2.0",
13
+ "@leancodepl/utils": "9.3.0",
14
14
  "@radix-ui/react-slot": ">=1.0.0",
15
15
  "@tanstack/react-form": ">=1.0.0",
16
16
  "@tanstack/react-query": ">=5.0.0"
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ type SubmitProps = {
3
+ children: ReactNode;
4
+ };
5
+ export declare function Submit({ children }: SubmitProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./Submit";
@@ -1,46 +1,57 @@
1
1
  import { ComponentType, ReactNode } from "react";
2
2
  import { AuthError } from "../../../utils";
3
3
  import { OnLoginFlowError } from "../types";
4
- type ChooseMethodFormPropsLoading = {
5
- isLoading: true;
6
- };
7
- type ChooseMethodFormPropsLoadedBase = {
8
- isLoading?: false;
9
- Password?: ComponentType<{
10
- children: ReactNode;
11
- }>;
12
- Google?: ComponentType<{
4
+ type ChooseMethodFormPropsComponentsBase = {
5
+ Google: ComponentType<{
13
6
  children: ReactNode;
14
7
  }>;
15
- Passkey?: ComponentType<{
8
+ Passkey: ComponentType<{
16
9
  children: ReactNode;
17
10
  }>;
18
- Apple?: ComponentType<{
11
+ Apple: ComponentType<{
19
12
  children: ReactNode;
20
13
  }>;
21
- Facebook?: ComponentType<{
14
+ Facebook: ComponentType<{
22
15
  children: ReactNode;
23
16
  }>;
17
+ };
18
+ type ChooseMethodFormPropsLoadedBase = {
24
19
  errors: AuthError[];
25
20
  isSubmitting: boolean;
26
21
  isValidating: boolean;
27
22
  };
28
- type ChooseMethodFormPropsLoaded = ChooseMethodFormPropsLoadedBase & {
29
- isRefresh?: false;
30
- Identifier?: ComponentType<{
31
- children: ReactNode;
32
- }>;
33
- };
34
- type ChooseMethodFormPropsLoadedRefresh = ChooseMethodFormPropsLoadedBase & {
23
+ type ChooseMethodFormPropsLoadedRefresh = ChooseMethodFormPropsLoadedBase & Partial<ChooseMethodFormPropsComponentsBase> & {
35
24
  isRefresh: true;
36
25
  identifier?: string;
26
+ passwordFields?: {
27
+ Password: ComponentType<{
28
+ children: ReactNode;
29
+ }>;
30
+ Submit: ComponentType<{
31
+ children: ReactNode;
32
+ }>;
33
+ };
34
+ };
35
+ type ChooseMethodFormPropsLoaded = ChooseMethodFormPropsComponentsBase & ChooseMethodFormPropsLoadedBase & {
36
+ isRefresh?: false;
37
+ passwordFields: {
38
+ Identifier: ComponentType<{
39
+ children: ReactNode;
40
+ }>;
41
+ Password: ComponentType<{
42
+ children: ReactNode;
43
+ }>;
44
+ Submit: ComponentType<{
45
+ children: ReactNode;
46
+ }>;
47
+ };
37
48
  };
38
- export type ChooseMethodFormProps = ChooseMethodFormPropsLoaded | ChooseMethodFormPropsLoadedRefresh | ChooseMethodFormPropsLoading;
49
+ export type ChooseMethodFormProps = ChooseMethodFormPropsLoaded | ChooseMethodFormPropsLoadedRefresh;
39
50
  type ChooseMethodFormWrapperProps = {
40
51
  chooseMethodForm: ComponentType<ChooseMethodFormProps>;
41
52
  isRefresh: boolean | undefined;
42
53
  onError?: OnLoginFlowError;
43
54
  onLoginSuccess?: () => void;
44
55
  };
45
- export declare function ChooseMethodFormWrapper({ chooseMethodForm: ChooseMethodForm, isRefresh, onError, onLoginSuccess, }: ChooseMethodFormWrapperProps): import("react/jsx-runtime").JSX.Element;
56
+ export declare function ChooseMethodFormWrapper({ chooseMethodForm: ChooseMethodForm, isRefresh, onError, onLoginSuccess, }: ChooseMethodFormWrapperProps): import("react/jsx-runtime").JSX.Element | null;
46
57
  export {};
@@ -5,6 +5,7 @@ import { SecondFactorEmailFormProps } from "./secondFactorEmailForm";
5
5
  import { SecondFactorFormProps } from "./secondFactorForm";
6
6
  import { OnLoginFlowError } from "./types";
7
7
  export type LoginFlowProps = {
8
+ loaderComponent?: ComponentType;
8
9
  chooseMethodForm: ComponentType<ChooseMethodFormProps>;
9
10
  secondFactorForm: ComponentType<SecondFactorFormProps>;
10
11
  secondFactorEmailForm: ComponentType<SecondFactorEmailFormProps>;
@@ -25,6 +26,7 @@ export type LoginFlowProps = {
25
26
  * between different authentication steps.
26
27
  *
27
28
  * @param props - Configuration and component props for the login flow
29
+ * @param props.loaderComponent - Optional component to display during loading states
28
30
  * @param props.chooseMethodForm - React component for login method selection
29
31
  * @param props.secondFactorForm - React component for second factor authentication
30
32
  * @param props.secondFactorEmailForm - React component for email-based second factor
@@ -8,6 +8,9 @@ export type SecondFactorEmailFormProps = {
8
8
  Resend: ComponentType<{
9
9
  children: ReactNode;
10
10
  }>;
11
+ Submit: ComponentType<{
12
+ children: ReactNode;
13
+ }>;
11
14
  errors: AuthError[];
12
15
  isSubmitting: boolean;
13
16
  isValidating: boolean;
@@ -4,18 +4,22 @@ import { OnLoginFlowError } from "../types";
4
4
  /**
5
5
  * Props for the SecondFactorForm component.
6
6
  *
7
- * @property {ComponentType<{ children: ReactNode }>} [Totp] - Optional component for rendering the TOTP (Time-based One-Time Password) input.
8
- * @property {ComponentType<{ children: ReactNode }>} [Email] - Optional component for rendering the Email button.
9
- * @property {AuthError[]} errors - Array of authentication errors to display.
10
- * @property {boolean} isRefresh - Indicates if the flow is for refresh credentials.
11
- * @property {boolean} isSubmitting - Indicates if the form is currently submitting.
12
- * @property {boolean} isValidating - Indicates if the form is currently validating.
7
+ * @property {ComponentType<{ children: ReactNode }>} [Email] - Optional component for rendering the Email button for second factor authentication.
8
+ * @property {ComponentType<{ children: ReactNode }>} Totp - Component for rendering the TOTP (Time-based One-Time Password) input field.
9
+ * @property {ComponentType<{ children: ReactNode }>} Submit - Component for rendering the TOTP submit button.
10
+ * @property {AuthError[]} errors - Array of authentication errors to display to the user.
11
+ * @property {boolean | undefined} isRefresh - Indicates if the flow is for refresh credentials.
12
+ * @property {boolean} isSubmitting - Indicates if the form is currently being submitted.
13
+ * @property {boolean} isValidating - Indicates if the form is currently being validated.
13
14
  */
14
15
  export type SecondFactorFormProps = {
15
- Totp?: ComponentType<{
16
+ Email?: ComponentType<{
16
17
  children: ReactNode;
17
18
  }>;
18
- Email?: ComponentType<{
19
+ Totp: ComponentType<{
20
+ children: ReactNode;
21
+ }>;
22
+ Submit: ComponentType<{
19
23
  children: ReactNode;
20
24
  }>;
21
25
  errors: AuthError[];
@@ -2,7 +2,10 @@ import { ComponentType, ReactNode } from "react";
2
2
  import { AuthError } from "../../../utils";
3
3
  import { OnRecoveryFlowError } from "../types";
4
4
  export type CodeFormProps = {
5
- Code?: ComponentType<{
5
+ Code: ComponentType<{
6
+ children: ReactNode;
7
+ }>;
8
+ Submit: ComponentType<{
6
9
  children: ReactNode;
7
10
  }>;
8
11
  errors: Array<AuthError>;
@@ -2,7 +2,10 @@ import { ComponentType, ReactNode } from "react";
2
2
  import { AuthError } from "../../../utils";
3
3
  import { OnRecoveryFlowError } from "../types";
4
4
  export type EmailFormProps = {
5
- Email?: ComponentType<{
5
+ Email: ComponentType<{
6
+ children: ReactNode;
7
+ }>;
8
+ Submit: ComponentType<{
6
9
  children: ReactNode;
7
10
  }>;
8
11
  errors: Array<AuthError>;
@@ -2,18 +2,23 @@ import { ComponentType, ReactNode } from "react";
2
2
  import { AuthError, TraitsConfig } from "../../../utils";
3
3
  import { OnRegistrationFlowError } from "../types";
4
4
  export type ChooseMethodFormProps = {
5
- ReturnToTraitsForm?: ComponentType<{
5
+ ReturnToTraitsForm: ComponentType<{
6
6
  children: ReactNode;
7
7
  }>;
8
- Password?: ComponentType<{
9
- children: ReactNode;
10
- }>;
11
- PasswordConfirmation?: ComponentType<{
12
- children: ReactNode;
13
- }>;
14
- Passkey?: ComponentType<{
8
+ Passkey: ComponentType<{
15
9
  children: ReactNode;
16
10
  }>;
11
+ passwordFields: {
12
+ Password: ComponentType<{
13
+ children: ReactNode;
14
+ }>;
15
+ PasswordConfirmation: ComponentType<{
16
+ children: ReactNode;
17
+ }>;
18
+ Submit: ComponentType<{
19
+ children: ReactNode;
20
+ }>;
21
+ };
17
22
  errors: Array<AuthError>;
18
23
  isSubmitting: boolean;
19
24
  isValidating: boolean;
@@ -9,14 +9,19 @@ type TraitsComponents<TTraitsConfig extends TraitsConfig> = {
9
9
  type: "boolean";
10
10
  } ? ComponentType<Omit<typeof TraitCheckbox, "trait">> : never;
11
11
  };
12
- export type TraitsFormProps<TTraitsConfig extends TraitsConfig> = TraitsComponents<TTraitsConfig> & {
13
- Google?: ComponentType<{
12
+ export type TraitsFormProps<TTraitsConfig extends TraitsConfig> = {
13
+ traitFields: TraitsComponents<TTraitsConfig> & {
14
+ Submit: ComponentType<{
15
+ children: ReactNode;
16
+ }>;
17
+ };
18
+ Google: ComponentType<{
14
19
  children: ReactNode;
15
20
  }>;
16
- Apple?: ComponentType<{
21
+ Apple: ComponentType<{
17
22
  children: ReactNode;
18
23
  }>;
19
- Facebook?: ComponentType<{
24
+ Facebook: ComponentType<{
20
25
  children: ReactNode;
21
26
  }>;
22
27
  errors: Array<AuthError>;
@@ -2,10 +2,13 @@ import { ComponentType, ReactNode } from "react";
2
2
  import { AuthError, TraitsConfig } from "../../../utils";
3
3
  import { OnSettingsFlowError } from "../types";
4
4
  export type NewPasswordFormProps = {
5
- Password?: ComponentType<{
5
+ Password: ComponentType<{
6
6
  children: ReactNode;
7
7
  }>;
8
- PasswordConfirmation?: ComponentType<{
8
+ PasswordConfirmation: ComponentType<{
9
+ children: ReactNode;
10
+ }>;
11
+ Submit: ComponentType<{
9
12
  children: ReactNode;
10
13
  }>;
11
14
  errors: Array<AuthError>;
@@ -18,7 +18,10 @@ type TotpFormPropsLinked = TotpFormPropsLoaded & {
18
18
  };
19
19
  type TotpFormPropsUnlinked = TotpFormPropsLoaded & {
20
20
  isTotpLinked?: false;
21
- Code?: ComponentType<{
21
+ Code: ComponentType<{
22
+ children: ReactNode;
23
+ }>;
24
+ Submit: ComponentType<{
22
25
  children: ReactNode;
23
26
  }>;
24
27
  totpQrImageSrc?: string;
@@ -1,4 +1,4 @@
1
- import { ComponentType } from "react";
1
+ import { ComponentType, ReactNode } from "react";
2
2
  import { AuthError, TraitsConfig } from "../../../utils";
3
3
  import { OnSettingsFlowError } from "../types";
4
4
  import { TraitCheckbox, TraitInput } from "./fields";
@@ -10,6 +10,9 @@ type TraitsComponents<TTraitsConfig extends TraitsConfig> = {
10
10
  } ? ComponentType<Omit<typeof TraitCheckbox, "trait">> : never;
11
11
  };
12
12
  export type TraitsFormProps<TTraitsConfig extends TraitsConfig> = TraitsComponents<TTraitsConfig> & {
13
+ Submit: ComponentType<{
14
+ children: ReactNode;
15
+ }>;
13
16
  errors: Array<AuthError>;
14
17
  isLoading: boolean;
15
18
  isSubmitting: boolean;
@@ -5,6 +5,9 @@ export type EmailVerificationFormProps = {
5
5
  Code: ComponentType<{
6
6
  children: ReactNode;
7
7
  }>;
8
+ Submit: ComponentType<{
9
+ children: ReactNode;
10
+ }>;
8
11
  Resend: ComponentType<{
9
12
  children: ReactNode;
10
13
  }>;
@@ -5,6 +5,7 @@ type UseFlowManagerProps = {
5
5
  onFlowRestart?: () => void;
6
6
  createFlow: () => void;
7
7
  setFlowId: (flowId: string | undefined) => void;
8
+ waitForSession?: boolean;
8
9
  };
9
- export declare const useFlowManager: ({ initialFlowId, currentFlowId, error, onFlowRestart, createFlow, setFlowId, }: UseFlowManagerProps) => void;
10
+ export declare const useFlowManager: ({ initialFlowId, currentFlowId, error, onFlowRestart, createFlow, setFlowId, waitForSession, }: UseFlowManagerProps) => void;
10
11
  export {};
@@ -353,7 +353,7 @@ export declare const mapToAuthError: (error: UiTextError) => {
353
353
  id: "RecoveryFlowError_InvalidRecoveryCodeOrAlreadyUsed";
354
354
  originalError: UiTextError;
355
355
  } | {
356
- id: "VerificationFlowError_InvalidVerifivactionCodeOrAlreadyUsed";
356
+ id: "VerificationFlowError_InvalidVerificationCodeOrAlreadyUsed";
357
357
  originalError: UiTextError;
358
358
  } | {
359
359
  id: "VerificationFlowError_VerificationRequestAlreadyCompletedSuccessfully";
@@ -371,9 +371,6 @@ export declare const mapToAuthError: (error: UiTextError) => {
371
371
  } | {
372
372
  id: "VerificationFlowError_VerificationFlowExpired";
373
373
  originalError: UiTextError;
374
- } | {
375
- id: "VerificationFlowError_InvalidVerificationCodeOrAlreadyUsed";
376
- originalError: UiTextError;
377
374
  } | {
378
375
  id: "Error_Generic_WithContext";
379
376
  context: {