@leancodepl/kratos 9.2.1 → 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/README.md +46 -47
- package/index.cjs.js +140 -88
- package/index.esm.js +140 -88
- package/package.json +2 -2
- package/src/lib/flows/fields/Submit.d.ts +6 -0
- package/src/lib/flows/fields/index.d.ts +1 -0
- package/src/lib/flows/login/chooseMethodForm/ChooseMethodFormWrapper.d.ts +32 -21
- package/src/lib/flows/login/loginFlow.d.ts +2 -0
- package/src/lib/flows/login/secondFactorEmailForm/SecondFactorEmailFormWrapper.d.ts +3 -0
- package/src/lib/flows/login/secondFactorForm/SecondFactorFormWrapper.d.ts +12 -8
- package/src/lib/flows/recovery/codeForm/CodeFormWrapper.d.ts +4 -1
- package/src/lib/flows/recovery/emailForm/EmailFormWrapper.d.ts +4 -1
- package/src/lib/flows/registration/chooseMethodForm/ChooseMethodFormWrapper.d.ts +13 -8
- package/src/lib/flows/registration/traitsForm/TraitsFormWrapper.d.ts +9 -4
- package/src/lib/flows/settings/newPasswordForm/NewPasswordFormWrapper.d.ts +5 -2
- package/src/lib/flows/settings/totpForm/TotpFormFormWrapper.d.ts +4 -1
- package/src/lib/flows/settings/traitsForm/TraitsFormWrapper.d.ts +4 -1
- package/src/lib/flows/verification/emailVerificationForm/EmailVerificationFormWrapper.d.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/kratos",
|
|
3
|
-
"version": "9.
|
|
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.
|
|
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 @@
|
|
|
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
|
|
5
|
-
|
|
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
|
|
8
|
+
Passkey: ComponentType<{
|
|
16
9
|
children: ReactNode;
|
|
17
10
|
}>;
|
|
18
|
-
Apple
|
|
11
|
+
Apple: ComponentType<{
|
|
19
12
|
children: ReactNode;
|
|
20
13
|
}>;
|
|
21
|
-
Facebook
|
|
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
|
|
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
|
|
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
|
|
@@ -4,18 +4,22 @@ import { OnLoginFlowError } from "../types";
|
|
|
4
4
|
/**
|
|
5
5
|
* Props for the SecondFactorForm component.
|
|
6
6
|
*
|
|
7
|
-
* @property {ComponentType<{ children: ReactNode }>} [
|
|
8
|
-
* @property {ComponentType<{ children: ReactNode }>}
|
|
9
|
-
* @property {
|
|
10
|
-
* @property {
|
|
11
|
-
* @property {boolean}
|
|
12
|
-
* @property {boolean}
|
|
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
|
-
|
|
16
|
+
Email?: ComponentType<{
|
|
16
17
|
children: ReactNode;
|
|
17
18
|
}>;
|
|
18
|
-
|
|
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
|
|
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
|
|
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
|
|
5
|
+
ReturnToTraitsForm: ComponentType<{
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
}>;
|
|
8
|
-
|
|
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> =
|
|
13
|
-
|
|
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
|
|
21
|
+
Apple: ComponentType<{
|
|
17
22
|
children: ReactNode;
|
|
18
23
|
}>;
|
|
19
|
-
Facebook
|
|
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
|
|
5
|
+
Password: ComponentType<{
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
}>;
|
|
8
|
-
PasswordConfirmation
|
|
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
|
|
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;
|