@oussemasahbeni/keycloakify-login-shadcn 250004.0.3 → 250004.0.7

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.
Files changed (169) hide show
  1. package/keycloak-theme/login/KcContext.ts +23 -23
  2. package/keycloak-theme/login/KcPage.tsx +47 -47
  3. package/keycloak-theme/login/assets/img/auth-logo.svg +100 -100
  4. package/keycloak-theme/login/assets/img/shape.svg +71 -71
  5. package/keycloak-theme/login/components/LogoutOtherSessions.tsx +26 -26
  6. package/keycloak-theme/login/components/PasswordWrapper.tsx +35 -35
  7. package/keycloak-theme/login/components/Template/Template.tsx +227 -227
  8. package/keycloak-theme/login/components/Template/index.ts +1 -1
  9. package/keycloak-theme/login/components/Template/useInitializeTemplate.ts +61 -61
  10. package/keycloak-theme/login/components/UserProfileFormFields/AddRemoveButtonsMultiValuedAttribute.tsx +61 -61
  11. package/keycloak-theme/login/components/UserProfileFormFields/DO_MAKE_USER_CONFIRM_PASSWORD.ts +2 -2
  12. package/keycloak-theme/login/components/UserProfileFormFields/FieldErrors.tsx +28 -28
  13. package/keycloak-theme/login/components/UserProfileFormFields/GroupLabel.tsx +70 -70
  14. package/keycloak-theme/login/components/UserProfileFormFields/InputFieldByType.tsx +58 -58
  15. package/keycloak-theme/login/components/UserProfileFormFields/InputTag.tsx +116 -116
  16. package/keycloak-theme/login/components/UserProfileFormFields/InputTagSelects.tsx +135 -135
  17. package/keycloak-theme/login/components/UserProfileFormFields/SelectTag.tsx +114 -114
  18. package/keycloak-theme/login/components/UserProfileFormFields/TextareaTag.tsx +42 -42
  19. package/keycloak-theme/login/components/UserProfileFormFields/UserProfileFormFields.tsx +127 -127
  20. package/keycloak-theme/login/components/UserProfileFormFields/index.ts +1 -1
  21. package/keycloak-theme/login/i18n.ts +47 -47
  22. package/keycloak-theme/login/mocks/getKcContextMock.ts +22 -22
  23. package/keycloak-theme/login/pages/PageIndex.tsx +134 -134
  24. package/keycloak-theme/login/pages/code/Page.stories.tsx +54 -66
  25. package/keycloak-theme/login/pages/code/Page.tsx +89 -89
  26. package/keycloak-theme/login/pages/code/index.ts +3 -3
  27. package/keycloak-theme/login/pages/delete-account-confirm/Page.stories.tsx +39 -46
  28. package/keycloak-theme/login/pages/delete-account-confirm/Page.tsx +63 -63
  29. package/keycloak-theme/login/pages/delete-account-confirm/index.ts +3 -3
  30. package/keycloak-theme/login/pages/delete-credential/Page.stories.tsx +26 -30
  31. package/keycloak-theme/login/pages/delete-credential/Page.tsx +51 -51
  32. package/keycloak-theme/login/pages/delete-credential/index.ts +3 -3
  33. package/keycloak-theme/login/pages/error/Page.stories.tsx +47 -58
  34. package/keycloak-theme/login/pages/error/Page.tsx +42 -42
  35. package/keycloak-theme/login/pages/error/index.ts +3 -3
  36. package/keycloak-theme/login/pages/frontchannel-logout/Page.stories.tsx +25 -32
  37. package/keycloak-theme/login/pages/frontchannel-logout/Page.tsx +84 -84
  38. package/keycloak-theme/login/pages/frontchannel-logout/index.ts +3 -3
  39. package/keycloak-theme/login/pages/idp-review-user-profile/Page.stories.tsx +46 -58
  40. package/keycloak-theme/login/pages/idp-review-user-profile/Page.tsx +52 -52
  41. package/keycloak-theme/login/pages/idp-review-user-profile/index.ts +3 -3
  42. package/keycloak-theme/login/pages/info/Page.stories.tsx +50 -60
  43. package/keycloak-theme/login/pages/info/Page.tsx +92 -92
  44. package/keycloak-theme/login/pages/link-idp-action/Page.stories.tsx +32 -16
  45. package/keycloak-theme/login/pages/link-idp-action/Page.tsx +43 -43
  46. package/keycloak-theme/login/pages/link-idp-action/index.ts +3 -3
  47. package/keycloak-theme/login/pages/login/Form.tsx +242 -242
  48. package/keycloak-theme/login/pages/login/Info.tsx +29 -29
  49. package/keycloak-theme/login/pages/login/Page.stories.tsx +345 -365
  50. package/keycloak-theme/login/pages/login/Page.tsx +44 -44
  51. package/keycloak-theme/login/pages/login/SocialProviders.tsx +107 -107
  52. package/keycloak-theme/login/pages/login/index.ts +3 -3
  53. package/keycloak-theme/login/pages/login/providers/apple.svg +3 -3
  54. package/keycloak-theme/login/pages/login/providers/bitbucket.svg +11 -11
  55. package/keycloak-theme/login/pages/login/providers/discord.svg +4 -4
  56. package/keycloak-theme/login/pages/login/providers/facebook.svg +5 -5
  57. package/keycloak-theme/login/pages/login/providers/github.svg +3 -3
  58. package/keycloak-theme/login/pages/login/providers/gitlab.svg +7 -7
  59. package/keycloak-theme/login/pages/login/providers/google.svg +7 -7
  60. package/keycloak-theme/login/pages/login/providers/instagram.svg +31 -31
  61. package/keycloak-theme/login/pages/login/providers/linkedin.svg +3 -3
  62. package/keycloak-theme/login/pages/login/providers/microsoft.svg +6 -6
  63. package/keycloak-theme/login/pages/login/providers/oidc.svg +5 -5
  64. package/keycloak-theme/login/pages/login/providers/openshift.svg +7 -7
  65. package/keycloak-theme/login/pages/login/providers/paypal.svg +6 -6
  66. package/keycloak-theme/login/pages/login/providers/slack.svg +11 -11
  67. package/keycloak-theme/login/pages/login/providers/stackoverflow.svg +5 -5
  68. package/keycloak-theme/login/pages/login/providers/x.svg +3 -3
  69. package/keycloak-theme/login/pages/login/useProviderLogos.tsx +39 -39
  70. package/keycloak-theme/login/pages/login/useScript.tsx +62 -62
  71. package/keycloak-theme/login/pages/login-config-totp/Page.stories.tsx +45 -59
  72. package/keycloak-theme/login/pages/login-config-totp/Page.tsx +240 -240
  73. package/keycloak-theme/login/pages/login-config-totp/index.ts +3 -3
  74. package/keycloak-theme/login/pages/login-idp-link-confirm/Page.stories.tsx +30 -34
  75. package/keycloak-theme/login/pages/login-idp-link-confirm/Page.tsx +43 -43
  76. package/keycloak-theme/login/pages/login-idp-link-confirm/index.ts +3 -3
  77. package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.stories.tsx +16 -22
  78. package/keycloak-theme/login/pages/login-idp-link-confirm-override/Page.tsx +47 -47
  79. package/keycloak-theme/login/pages/login-idp-link-confirm-override/index.ts +3 -3
  80. package/keycloak-theme/login/pages/login-idp-link-email/Page.stories.tsx +54 -62
  81. package/keycloak-theme/login/pages/login-idp-link-email/Page.tsx +54 -54
  82. package/keycloak-theme/login/pages/login-idp-link-email/index.ts +3 -3
  83. package/keycloak-theme/login/pages/login-oauth-grant/Page.stories.tsx +39 -45
  84. package/keycloak-theme/login/pages/login-oauth-grant/Page.tsx +126 -126
  85. package/keycloak-theme/login/pages/login-oauth-grant/index.ts +3 -3
  86. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.stories.tsx +38 -48
  87. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/Page.tsx +58 -58
  88. package/keycloak-theme/login/pages/login-oauth2-device-verify-user-code/index.ts +3 -3
  89. package/keycloak-theme/login/pages/login-otp/Page.stories.tsx +82 -96
  90. package/keycloak-theme/login/pages/login-otp/Page.tsx +108 -108
  91. package/keycloak-theme/login/pages/login-otp/index.ts +3 -3
  92. package/keycloak-theme/login/pages/login-page-expired/Page.stories.tsx +28 -36
  93. package/keycloak-theme/login/pages/login-page-expired/Page.tsx +47 -47
  94. package/keycloak-theme/login/pages/login-page-expired/index.ts +3 -3
  95. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.stories.tsx +20 -0
  96. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/Page.tsx +233 -233
  97. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/index.ts +3 -3
  98. package/keycloak-theme/login/pages/login-passkeys-conditional-authenticate/useScript.tsx +63 -63
  99. package/keycloak-theme/login/pages/login-password/Page.stories.tsx +55 -56
  100. package/keycloak-theme/login/pages/login-password/Page.tsx +149 -149
  101. package/keycloak-theme/login/pages/login-password/index.ts +3 -3
  102. package/keycloak-theme/login/pages/login-password/useScript.tsx +63 -63
  103. package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.stories.tsx +28 -36
  104. package/keycloak-theme/login/pages/login-recovery-authn-code-config/Page.tsx +181 -181
  105. package/keycloak-theme/login/pages/login-recovery-authn-code-config/index.ts +3 -3
  106. package/keycloak-theme/login/pages/login-recovery-authn-code-config/useScript.tsx +145 -145
  107. package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.stories.tsx +16 -22
  108. package/keycloak-theme/login/pages/login-recovery-authn-code-input/Page.tsx +70 -70
  109. package/keycloak-theme/login/pages/login-recovery-authn-code-input/index.ts +3 -3
  110. package/keycloak-theme/login/pages/login-reset-otp/Page.stories.tsx +62 -74
  111. package/keycloak-theme/login/pages/login-reset-otp/Page.tsx +86 -86
  112. package/keycloak-theme/login/pages/login-reset-otp/index.ts +3 -3
  113. package/keycloak-theme/login/pages/login-reset-password/Form.tsx +68 -68
  114. package/keycloak-theme/login/pages/login-reset-password/Page.stories.tsx +44 -54
  115. package/keycloak-theme/login/pages/login-reset-password/Page.tsx +27 -27
  116. package/keycloak-theme/login/pages/login-reset-password/index.ts +3 -3
  117. package/keycloak-theme/login/pages/login-update-password/Page.stories.tsx +40 -50
  118. package/keycloak-theme/login/pages/login-update-password/Page.tsx +111 -111
  119. package/keycloak-theme/login/pages/login-update-password/index.ts +3 -3
  120. package/keycloak-theme/login/pages/login-update-profile/Page.stories.tsx +28 -36
  121. package/keycloak-theme/login/pages/login-update-profile/Page.tsx +68 -68
  122. package/keycloak-theme/login/pages/login-update-profile/index.ts +3 -3
  123. package/keycloak-theme/login/pages/login-username/Page.stories.tsx +32 -42
  124. package/keycloak-theme/login/pages/login-username/Page.tsx +246 -246
  125. package/keycloak-theme/login/pages/login-username/index.ts +3 -3
  126. package/keycloak-theme/login/pages/login-username/useScript.tsx +62 -62
  127. package/keycloak-theme/login/pages/login-verify-email/Page.stories.tsx +68 -80
  128. package/keycloak-theme/login/pages/login-verify-email/Page.tsx +38 -38
  129. package/keycloak-theme/login/pages/login-verify-email/index.ts +3 -3
  130. package/keycloak-theme/login/pages/login-x509-info/Page.stories.tsx +29 -37
  131. package/keycloak-theme/login/pages/login-x509-info/Page.tsx +75 -75
  132. package/keycloak-theme/login/pages/login-x509-info/index.ts +3 -3
  133. package/keycloak-theme/login/pages/logout-confirm/Page.stories.tsx +34 -42
  134. package/keycloak-theme/login/pages/logout-confirm/Page.tsx +53 -53
  135. package/keycloak-theme/login/pages/logout-confirm/index.ts +3 -3
  136. package/keycloak-theme/login/pages/register/Form.tsx +106 -106
  137. package/keycloak-theme/login/pages/register/Page.stories.tsx +23 -6
  138. package/keycloak-theme/login/pages/register/Page.tsx +26 -26
  139. package/keycloak-theme/login/pages/register/TermsAcceptance.tsx +56 -56
  140. package/keycloak-theme/login/pages/register/index.ts +3 -3
  141. package/keycloak-theme/login/pages/saml-post-form/Page.stories.tsx +16 -22
  142. package/keycloak-theme/login/pages/saml-post-form/Page.tsx +66 -66
  143. package/keycloak-theme/login/pages/saml-post-form/index.ts +3 -3
  144. package/keycloak-theme/login/pages/select-authenticator/Page.stories.tsx +83 -95
  145. package/keycloak-theme/login/pages/select-authenticator/Page.tsx +100 -100
  146. package/keycloak-theme/login/pages/select-authenticator/index.ts +3 -3
  147. package/keycloak-theme/login/pages/select-organization/Page.stories.tsx +62 -49
  148. package/keycloak-theme/login/pages/select-organization/Page.tsx +126 -126
  149. package/keycloak-theme/login/pages/select-organization/index.ts +3 -3
  150. package/keycloak-theme/login/pages/terms/Page.stories.tsx +15 -0
  151. package/keycloak-theme/login/pages/terms/Page.tsx +51 -51
  152. package/keycloak-theme/login/pages/terms/index.ts +3 -3
  153. package/keycloak-theme/login/pages/update-email/Page.stories.tsx +27 -35
  154. package/keycloak-theme/login/pages/update-email/Page.tsx +62 -62
  155. package/keycloak-theme/login/pages/update-email/index.ts +3 -3
  156. package/keycloak-theme/login/pages/webauthn-authenticate/Page.stories.tsx +112 -126
  157. package/keycloak-theme/login/pages/webauthn-authenticate/Page.tsx +202 -202
  158. package/keycloak-theme/login/pages/webauthn-authenticate/index.ts +3 -3
  159. package/keycloak-theme/login/pages/webauthn-authenticate/useScript.tsx +55 -55
  160. package/keycloak-theme/login/pages/webauthn-error/Page.stories.tsx +54 -66
  161. package/keycloak-theme/login/pages/webauthn-error/Page.tsx +73 -73
  162. package/keycloak-theme/login/pages/webauthn-error/index.ts +3 -3
  163. package/keycloak-theme/login/pages/webauthn-register/Page.stories.tsx +39 -49
  164. package/keycloak-theme/login/pages/webauthn-register/Page.tsx +78 -78
  165. package/keycloak-theme/login/pages/webauthn-register/index.ts +3 -3
  166. package/keycloak-theme/login/pages/webauthn-register/useScript.tsx +62 -62
  167. package/keycloak-theme/login/shared/getColorScheme.ts +45 -45
  168. package/keycloak-theme/login/styleLevelCustomization.tsx +35 -35
  169. package/package.json +5 -1
@@ -11,71 +11,70 @@ export default meta;
11
11
 
12
12
  type Story = StoryObj<typeof meta>;
13
13
 
14
- export const Default: Story = {
15
- render: () => <KcPageStory />
16
- };
14
+ export const Default: Story = {};
17
15
 
18
16
  export const WithPasswordError: Story = {
19
- render: () => (
20
- <KcPageStory
21
- kcContext={{
22
- realm: {
23
- resetPasswordAllowed: true
24
- },
25
- url: {
26
- loginAction: "/mock-login",
27
- loginResetCredentialsUrl: "/mock-reset-password"
28
- },
29
- messagesPerField: {
30
- existsError: (field: string) => field === "password",
31
- get: () => "Invalid password"
32
- }
33
- }}
34
- />
35
- )
17
+ args: {
18
+ kcContext: {
19
+ realm: {
20
+ resetPasswordAllowed: true
21
+ },
22
+ url: {
23
+ loginAction: "/mock-login",
24
+ loginResetCredentialsUrl: "/mock-reset-password"
25
+ },
26
+ messagesPerField: {
27
+ existsError: (field: string) => field === "password",
28
+ get: () => "Invalid password"
29
+ }
30
+ }
31
+ }
36
32
  };
37
33
 
38
34
  export const Arabic: Story = {
39
- render: () => (
40
- <KcPageStory
41
- kcContext={{
42
- locale: {
43
- currentLanguageTag: "ar",
44
- rtl: true
45
- }
46
- }}
47
- />
48
- )
35
+ args: {
36
+ kcContext: {
37
+ locale: {
38
+ currentLanguageTag: "ar",
39
+ rtl: true
40
+ }
41
+ }
42
+ }
43
+ };
44
+ export const French: Story = {
45
+ args: {
46
+ kcContext: {
47
+ locale: {
48
+ currentLanguageTag: "fr"
49
+ }
50
+ }
51
+ }
49
52
  };
50
53
 
51
54
  export const WithWebauthn: Story = {
52
- render: () => (
53
- <KcPageStory
54
- kcContext={{
55
- url: {
56
- loginAction: "/mock-login-action"
57
- },
58
- enableWebAuthnConditionalUI: true
59
- }}
60
- />
61
- )
55
+ args: {
56
+ kcContext: {
57
+ url: {
58
+ loginAction: "/mock-login-action"
59
+ },
60
+ enableWebAuthnConditionalUI: true
61
+ }
62
+ }
62
63
  };
63
64
 
64
65
  export const WithoutResetPasswordOption: Story = {
65
- render: () => (
66
- <KcPageStory
67
- kcContext={{
68
- realm: {
69
- resetPasswordAllowed: false
70
- },
71
- url: {
72
- loginAction: "/mock-login",
73
- loginResetCredentialsUrl: "/mock-reset-password"
74
- },
75
- messagesPerField: {
76
- existsError: () => false
77
- }
78
- }}
79
- />
80
- )
66
+ args: {
67
+ kcContext: {
68
+ realm: {
69
+ resetPasswordAllowed: false
70
+ },
71
+ url: {
72
+ loginAction: "/mock-login",
73
+ loginResetCredentialsUrl: "/mock-reset-password"
74
+ },
75
+ messagesPerField: {
76
+ existsError: () => false
77
+ }
78
+ }
79
+ }
81
80
  };
@@ -1,149 +1,149 @@
1
- import { Button } from "@/components/ui/button";
2
- import { Field, FieldError, FieldLabel } from "@/components/ui/field";
3
- import { Input } from "@/components/ui/input";
4
- import { Label } from '@/components/ui/label';
5
- import { PasswordWrapper } from '@/login/components/PasswordWrapper';
6
- import { useI18n } from '@/login/i18n';
7
- import { useKcContext } from '@/login/KcContext';
8
- import { useKcClsx } from '@keycloakify/login-ui/useKcClsx';
9
- import { kcSanitize } from "keycloakify/lib/kcSanitize";
10
- import { Fingerprint } from "lucide-react";
11
- import { useState } from "react";
12
- import { assert } from "tsafe/assert";
13
- import { Template } from "../../components/Template";
14
- import { useScript } from './useScript';
15
-
16
- export function Page() {
17
- const { kcContext } = useKcContext();
18
- assert(kcContext.pageId === "login-password.ftl");
19
-
20
- const { kcClsx } = useKcClsx();
21
-
22
- const { msg, msgStr } = useI18n();
23
-
24
- const [isLoginButtonDisabled, setIsLoginButtonDisabled] = useState(false);
25
-
26
- const webAuthnButtonId = "authenticateWebAuthnButton";
27
-
28
- useScript({ webAuthnButtonId });
29
-
30
- return (
31
- <Template
32
- headerNode={msg("doLogIn")}
33
- displayMessage={!kcContext.messagesPerField.existsError("password")}
34
- >
35
- <form
36
- id="kc-form-login"
37
- onSubmit={() => {
38
- setIsLoginButtonDisabled(true);
39
- return true;
40
- }}
41
- action={kcContext.url.loginAction}
42
- className="flex flex-col gap-4"
43
- method="post"
44
- >
45
- <Field>
46
- <FieldLabel htmlFor="password">{msg("password")}</FieldLabel>
47
- <PasswordWrapper
48
- passwordInputId="password"
49
- >
50
- <Input
51
- tabIndex={2}
52
- type="password"
53
- id="password"
54
- name="password"
55
- autoComplete="current-password"
56
- aria-invalid={kcContext.messagesPerField.existsError("password")}
57
- />
58
- </PasswordWrapper>
59
- {kcContext.messagesPerField.existsError("password") && (
60
- <FieldError>
61
- <span
62
- id="input-error"
63
- aria-live="polite"
64
- dangerouslySetInnerHTML={{
65
- __html: kcSanitize(
66
- kcContext.messagesPerField.getFirstError("password")
67
- )
68
- }}
69
- />
70
- </FieldError>
71
- )}
72
- </Field>
73
-
74
- <div className="flex justify-end">
75
- {kcContext.realm.resetPasswordAllowed && (
76
- <span className=" underline-offset-4 hover:underline">
77
- <a
78
- tabIndex={5}
79
- href={kcContext.url.loginResetCredentialsUrl}
80
- >
81
- <Label className="text-sm font-medium cursor-pointer">
82
- {msg("doForgotPassword")}
83
- </Label>
84
- </a>
85
- </span>
86
- )}
87
- </div>
88
-
89
- <div className="flex justify-end ">
90
- <Button
91
- disabled={isLoginButtonDisabled}
92
- className="w-full"
93
- name="login"
94
- type="submit"
95
- tabIndex={4}
96
- >
97
- {msgStr("doLogIn")}
98
- </Button>
99
- </div>
100
- </form>
101
- {kcContext.enableWebAuthnConditionalUI && (
102
- <>
103
- <form id="webauth" action={kcContext.url.loginAction} method="post">
104
- <input type="hidden" id="clientDataJSON" name="clientDataJSON" />
105
- <input
106
- type="hidden"
107
- id="authenticatorData"
108
- name="authenticatorData"
109
- />
110
- <input type="hidden" id="signature" name="signature" />
111
- <input type="hidden" id="credentialId" name="credentialId" />
112
- <input type="hidden" id="userHandle" name="userHandle" />
113
- <input type="hidden" id="error" name="error" />
114
- </form>
115
-
116
- {kcContext.authenticators !== undefined &&
117
- kcContext.authenticators.authenticators.length !== 0 && (
118
- <>
119
- <form id="authn_select" className={kcClsx("kcFormClass")}>
120
- {kcContext.authenticators.authenticators.map(
121
- (authenticator, i) => (
122
- <input
123
- key={i}
124
- type="hidden"
125
- name="authn_use_chk"
126
- readOnly
127
- value={authenticator.credentialId}
128
- />
129
- )
130
- )}
131
- </form>
132
- </>
133
- )}
134
- <br />
135
-
136
- <Button
137
- id={webAuthnButtonId}
138
- type="button"
139
- className="w-full"
140
- variant="outline"
141
- >
142
- <Fingerprint className="w-4 h-4" />
143
- {msgStr("passkey-doAuthenticate")}
144
- </Button>
145
- </>
146
- )}
147
- </Template>
148
- );
149
- }
1
+ import { Button } from "@/components/ui/button";
2
+ import { Field, FieldError, FieldLabel } from "@/components/ui/field";
3
+ import { Input } from "@/components/ui/input";
4
+ import { Label } from '@/components/ui/label';
5
+ import { PasswordWrapper } from '@/login/components/PasswordWrapper';
6
+ import { useI18n } from '@/login/i18n';
7
+ import { useKcContext } from '@/login/KcContext';
8
+ import { useKcClsx } from '@keycloakify/login-ui/useKcClsx';
9
+ import { kcSanitize } from "keycloakify/lib/kcSanitize";
10
+ import { Fingerprint } from "lucide-react";
11
+ import { useState } from "react";
12
+ import { assert } from "tsafe/assert";
13
+ import { Template } from "../../components/Template";
14
+ import { useScript } from './useScript';
15
+
16
+ export function Page() {
17
+ const { kcContext } = useKcContext();
18
+ assert(kcContext.pageId === "login-password.ftl");
19
+
20
+ const { kcClsx } = useKcClsx();
21
+
22
+ const { msg, msgStr } = useI18n();
23
+
24
+ const [isLoginButtonDisabled, setIsLoginButtonDisabled] = useState(false);
25
+
26
+ const webAuthnButtonId = "authenticateWebAuthnButton";
27
+
28
+ useScript({ webAuthnButtonId });
29
+
30
+ return (
31
+ <Template
32
+ headerNode={msg("doLogIn")}
33
+ displayMessage={!kcContext.messagesPerField.existsError("password")}
34
+ >
35
+ <form
36
+ id="kc-form-login"
37
+ onSubmit={() => {
38
+ setIsLoginButtonDisabled(true);
39
+ return true;
40
+ }}
41
+ action={kcContext.url.loginAction}
42
+ className="flex flex-col gap-4"
43
+ method="post"
44
+ >
45
+ <Field>
46
+ <FieldLabel htmlFor="password">{msg("password")}</FieldLabel>
47
+ <PasswordWrapper
48
+ passwordInputId="password"
49
+ >
50
+ <Input
51
+ tabIndex={2}
52
+ type="password"
53
+ id="password"
54
+ name="password"
55
+ autoComplete="current-password"
56
+ aria-invalid={kcContext.messagesPerField.existsError("password")}
57
+ />
58
+ </PasswordWrapper>
59
+ {kcContext.messagesPerField.existsError("password") && (
60
+ <FieldError>
61
+ <span
62
+ id="input-error"
63
+ aria-live="polite"
64
+ dangerouslySetInnerHTML={{
65
+ __html: kcSanitize(
66
+ kcContext.messagesPerField.getFirstError("password")
67
+ )
68
+ }}
69
+ />
70
+ </FieldError>
71
+ )}
72
+ </Field>
73
+
74
+ <div className="flex justify-end">
75
+ {kcContext.realm.resetPasswordAllowed && (
76
+ <span className=" underline-offset-4 hover:underline">
77
+ <a
78
+ tabIndex={5}
79
+ href={kcContext.url.loginResetCredentialsUrl}
80
+ >
81
+ <Label className="text-sm font-medium cursor-pointer">
82
+ {msg("doForgotPassword")}
83
+ </Label>
84
+ </a>
85
+ </span>
86
+ )}
87
+ </div>
88
+
89
+ <div className="flex justify-end ">
90
+ <Button
91
+ disabled={isLoginButtonDisabled}
92
+ className="w-full"
93
+ name="login"
94
+ type="submit"
95
+ tabIndex={4}
96
+ >
97
+ {msgStr("doLogIn")}
98
+ </Button>
99
+ </div>
100
+ </form>
101
+ {kcContext.enableWebAuthnConditionalUI && (
102
+ <>
103
+ <form id="webauth" action={kcContext.url.loginAction} method="post">
104
+ <input type="hidden" id="clientDataJSON" name="clientDataJSON" />
105
+ <input
106
+ type="hidden"
107
+ id="authenticatorData"
108
+ name="authenticatorData"
109
+ />
110
+ <input type="hidden" id="signature" name="signature" />
111
+ <input type="hidden" id="credentialId" name="credentialId" />
112
+ <input type="hidden" id="userHandle" name="userHandle" />
113
+ <input type="hidden" id="error" name="error" />
114
+ </form>
115
+
116
+ {kcContext.authenticators !== undefined &&
117
+ kcContext.authenticators.authenticators.length !== 0 && (
118
+ <>
119
+ <form id="authn_select" className={kcClsx("kcFormClass")}>
120
+ {kcContext.authenticators.authenticators.map(
121
+ (authenticator, i) => (
122
+ <input
123
+ key={i}
124
+ type="hidden"
125
+ name="authn_use_chk"
126
+ readOnly
127
+ value={authenticator.credentialId}
128
+ />
129
+ )
130
+ )}
131
+ </form>
132
+ </>
133
+ )}
134
+ <br />
135
+
136
+ <Button
137
+ id={webAuthnButtonId}
138
+ type="button"
139
+ className="w-full"
140
+ variant="outline"
141
+ >
142
+ <Fingerprint className="w-4 h-4" />
143
+ {msgStr("passkey-doAuthenticate")}
144
+ </Button>
145
+ </>
146
+ )}
147
+ </Template>
148
+ );
149
+ }
@@ -1,3 +1,3 @@
1
- import { Page } from "./Page";
2
-
3
- export default Page;
1
+ import { Page } from "./Page";
2
+
3
+ export default Page;
@@ -1,63 +1,63 @@
1
-
2
- import { useInsertScriptTags } from "@keycloakify/login-ui/tools/useInsertScriptTags";
3
- import { waitForElementMountedOnDom } from "@keycloakify/login-ui/tools/waitForElementMountedOnDom";
4
- import { useEffect } from "react";
5
- import { assert } from "tsafe/assert";
6
- import { useI18n } from "../../i18n";
7
- import { useKcContext } from "../../KcContext";
8
-
9
- export function useScript(params: { webAuthnButtonId: string }) {
10
- const { webAuthnButtonId } = params;
11
-
12
- const { kcContext } = useKcContext();
13
- assert(kcContext.pageId === "login-password.ftl");
14
-
15
- const { msgStr, isFetchingTranslations } = useI18n();
16
-
17
- const { insertScriptTags } = useInsertScriptTags({
18
- effectId: "LoginPassword",
19
- scriptTags: [
20
- {
21
- type: "module",
22
- textContent: () => `
23
- import { authenticateByWebAuthn } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/webauthnAuthenticate.js";
24
- import { initAuthenticate } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/passkeysConditionalAuth.js";
25
-
26
- const authButton = document.getElementById("${webAuthnButtonId}");
27
- const input = {
28
- isUserIdentified : ${kcContext.isUserIdentified},
29
- challenge : ${JSON.stringify(kcContext.challenge)},
30
- userVerification : ${JSON.stringify(kcContext.userVerification)},
31
- rpId : ${JSON.stringify(kcContext.rpId)},
32
- createTimeout : ${kcContext.createTimeout}
33
- };
34
- authButton.addEventListener("click", () => {
35
- authenticateByWebAuthn({
36
- ...input,
37
- errmsg : ${JSON.stringify(msgStr("webauthn-unsupported-browser-text"))}
38
- });
39
- });
40
-
41
- initAuthenticate({
42
- ...input,
43
- errmsg : ${JSON.stringify(msgStr("passkey-unsupported-browser-text"))}
44
- });
45
- `
46
- }
47
- ]
48
- });
49
-
50
- useEffect(() => {
51
- if (isFetchingTranslations) {
52
- return;
53
- }
54
-
55
- (async () => {
56
- await waitForElementMountedOnDom({
57
- elementId: webAuthnButtonId
58
- });
59
-
60
- insertScriptTags();
61
- })();
62
- }, [isFetchingTranslations]);
63
- }
1
+
2
+ import { useInsertScriptTags } from "@keycloakify/login-ui/tools/useInsertScriptTags";
3
+ import { waitForElementMountedOnDom } from "@keycloakify/login-ui/tools/waitForElementMountedOnDom";
4
+ import { useEffect } from "react";
5
+ import { assert } from "tsafe/assert";
6
+ import { useI18n } from "../../i18n";
7
+ import { useKcContext } from "../../KcContext";
8
+
9
+ export function useScript(params: { webAuthnButtonId: string }) {
10
+ const { webAuthnButtonId } = params;
11
+
12
+ const { kcContext } = useKcContext();
13
+ assert(kcContext.pageId === "login-password.ftl");
14
+
15
+ const { msgStr, isFetchingTranslations } = useI18n();
16
+
17
+ const { insertScriptTags } = useInsertScriptTags({
18
+ effectId: "LoginPassword",
19
+ scriptTags: [
20
+ {
21
+ type: "module",
22
+ textContent: () => `
23
+ import { authenticateByWebAuthn } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/webauthnAuthenticate.js";
24
+ import { initAuthenticate } from "${import.meta.env.BASE_URL}keycloak-theme/login/js/passkeysConditionalAuth.js";
25
+
26
+ const authButton = document.getElementById("${webAuthnButtonId}");
27
+ const input = {
28
+ isUserIdentified : ${kcContext.isUserIdentified},
29
+ challenge : ${JSON.stringify(kcContext.challenge)},
30
+ userVerification : ${JSON.stringify(kcContext.userVerification)},
31
+ rpId : ${JSON.stringify(kcContext.rpId)},
32
+ createTimeout : ${kcContext.createTimeout}
33
+ };
34
+ authButton.addEventListener("click", () => {
35
+ authenticateByWebAuthn({
36
+ ...input,
37
+ errmsg : ${JSON.stringify(msgStr("webauthn-unsupported-browser-text"))}
38
+ });
39
+ });
40
+
41
+ initAuthenticate({
42
+ ...input,
43
+ errmsg : ${JSON.stringify(msgStr("passkey-unsupported-browser-text"))}
44
+ });
45
+ `
46
+ }
47
+ ]
48
+ });
49
+
50
+ useEffect(() => {
51
+ if (isFetchingTranslations) {
52
+ return;
53
+ }
54
+
55
+ (async () => {
56
+ await waitForElementMountedOnDom({
57
+ elementId: webAuthnButtonId
58
+ });
59
+
60
+ insertScriptTags();
61
+ })();
62
+ }, [isFetchingTranslations]);
63
+ }
@@ -13,32 +13,26 @@ export default meta;
13
13
 
14
14
  type Story = StoryObj<typeof meta>;
15
15
 
16
- export const Default: Story = {
17
- render: () => <KcPageStory />
18
- };
16
+ export const Default: Story = {};
19
17
 
20
18
  export const Arabic: Story = {
21
- render: () => (
22
- <KcPageStory
23
- kcContext={{
24
- locale: {
25
- currentLanguageTag: "ar",
26
- rtl: true
27
- }
28
- }}
29
- />
30
- )
19
+ args: {
20
+ kcContext: {
21
+ locale: {
22
+ currentLanguageTag: "ar",
23
+ rtl: true
24
+ }
25
+ }
26
+ }
31
27
  };
32
28
  export const French: Story = {
33
- render: () => (
34
- <KcPageStory
35
- kcContext={{
36
- locale: {
37
- currentLanguageTag: "fr"
38
- }
39
- }}
40
- />
41
- )
29
+ args: {
30
+ kcContext: {
31
+ locale: {
32
+ currentLanguageTag: "fr"
33
+ }
34
+ }
35
+ }
42
36
  };
43
37
 
44
38
  /**
@@ -48,18 +42,16 @@ export const French: Story = {
48
42
  * - Key Aspect: Ensures that error messages are properly displayed when recovery code generation fails.
49
43
  */
50
44
  export const WithErrorDuringCodeGeneration: Story = {
51
- render: () => (
52
- <KcPageStory
53
- kcContext={{
54
- url: {
55
- loginAction: "/mock-login-action"
56
- },
57
- message: {
58
- summary:
59
- "An error occurred during recovery code generation. Please try again.",
60
- type: "error"
61
- }
62
- }}
63
- />
64
- )
45
+ args: {
46
+ kcContext: {
47
+ url: {
48
+ loginAction: "/mock-login-action"
49
+ },
50
+ message: {
51
+ summary:
52
+ "An error occurred during recovery code generation. Please try again.",
53
+ type: "error"
54
+ }
55
+ }
56
+ }
65
57
  };