2021-06-23 08:16:51 +02:00
|
|
|
import type { PageId } from "../../bin/build-keycloak-theme/generateFtl";
|
|
|
|
import type { KcLanguageTag } from "../i18n/KcLanguageTag";
|
2021-10-11 20:56:43 +02:00
|
|
|
import { assert } from "tsafe/assert";
|
|
|
|
import type { Equals } from "tsafe";
|
2021-06-23 08:16:51 +02:00
|
|
|
import type { MessageKey } from "../i18n/useKcMessage";
|
|
|
|
import type { LanguageLabel } from "../i18n/KcLanguageTag";
|
2021-02-23 15:32:37 +01:00
|
|
|
|
2021-10-12 00:26:29 +02:00
|
|
|
type ExtractAfterStartingWith<Prefix extends string, StrEnum> = StrEnum extends `${Prefix}${infer U}` ? U : never;
|
2021-02-23 15:32:37 +01:00
|
|
|
|
2021-10-11 21:35:40 +02:00
|
|
|
/** Take theses type definition with a grain of salt.
|
2021-04-01 16:51:28 +02:00
|
|
|
* Some values might be undefined on some pages.
|
|
|
|
* (ex: url.loginAction is undefined on error.ftl)
|
|
|
|
*/
|
2021-06-23 08:16:51 +02:00
|
|
|
export type KcContextBase =
|
2021-10-11 21:35:40 +02:00
|
|
|
| KcContextBase.Login
|
|
|
|
| KcContextBase.Register
|
|
|
|
| KcContextBase.RegisterUserProfile
|
|
|
|
| KcContextBase.Info
|
|
|
|
| KcContextBase.Error
|
|
|
|
| KcContextBase.LoginResetPassword
|
|
|
|
| KcContextBase.LoginVerifyEmail
|
|
|
|
| KcContextBase.Terms
|
|
|
|
| KcContextBase.LoginOtp
|
2021-12-28 00:08:25 +03:00
|
|
|
| KcContextBase.LoginUpdatePassword
|
2021-10-11 21:35:40 +02:00
|
|
|
| KcContextBase.LoginUpdateProfile
|
2022-01-01 18:44:05 +02:00
|
|
|
| KcContextBase.LoginIdpLinkConfirm
|
2022-04-22 17:54:47 +03:00
|
|
|
| KcContextBase.LoginIdpLinkEmail
|
2022-01-01 18:44:05 +02:00
|
|
|
| KcContextBase.LoginPageExpired;
|
2021-04-01 16:51:28 +02:00
|
|
|
|
2021-06-23 08:16:51 +02:00
|
|
|
export declare namespace KcContextBase {
|
2021-04-01 16:51:28 +02:00
|
|
|
export type Common = {
|
2021-03-04 21:14:54 +01:00
|
|
|
url: {
|
|
|
|
loginAction: string;
|
|
|
|
resourcesPath: string;
|
|
|
|
resourcesCommonPath: string;
|
|
|
|
loginRestartFlowUrl: string;
|
2021-03-02 22:48:36 +01:00
|
|
|
loginUrl: string;
|
2021-03-04 21:14:54 +01:00
|
|
|
};
|
|
|
|
realm: {
|
2021-12-21 09:45:23 -03:00
|
|
|
name: string;
|
2021-03-04 18:15:48 +01:00
|
|
|
displayName?: string;
|
2021-03-04 21:14:54 +01:00
|
|
|
displayNameHtml?: string;
|
|
|
|
internationalizationEnabled: boolean;
|
2021-04-01 16:51:28 +02:00
|
|
|
registrationEmailAsUsername: boolean;
|
2021-03-04 21:14:54 +01:00
|
|
|
};
|
|
|
|
/** Undefined if !realm.internationalizationEnabled */
|
|
|
|
locale?: {
|
|
|
|
supported: {
|
2021-03-05 19:50:08 +01:00
|
|
|
url: string;
|
2021-03-04 21:14:54 +01:00
|
|
|
languageTag: KcLanguageTag;
|
|
|
|
/** Is determined by languageTag. Ex: languageTag === "en" => label === "English"
|
|
|
|
* or getLanguageLabel(languageTag) === label
|
|
|
|
*/
|
|
|
|
//label: LanguageLabel;
|
|
|
|
}[];
|
2021-03-06 15:16:21 +01:00
|
|
|
current: LanguageLabel;
|
2021-10-11 21:35:40 +02:00
|
|
|
};
|
2021-03-04 21:14:54 +01:00
|
|
|
auth?: {
|
|
|
|
showUsername: boolean;
|
|
|
|
showResetCredentials: boolean;
|
|
|
|
showTryAnotherWayLink: boolean;
|
2021-03-07 14:57:53 +01:00
|
|
|
attemptedUsername?: string;
|
2021-03-04 21:14:54 +01:00
|
|
|
};
|
|
|
|
scripts: string[];
|
|
|
|
message?: {
|
|
|
|
type: "success" | "warning" | "error" | "info";
|
|
|
|
summary: string;
|
|
|
|
};
|
2021-07-12 15:19:31 +02:00
|
|
|
client: {
|
|
|
|
clientId: string;
|
|
|
|
name?: string;
|
2021-10-17 19:17:58 +02:00
|
|
|
description?: string;
|
2021-10-11 21:35:40 +02:00
|
|
|
};
|
2021-03-04 21:14:54 +01:00
|
|
|
isAppInitiatedAction: boolean;
|
2021-10-11 03:25:02 +02:00
|
|
|
messagesPerField: {
|
|
|
|
printIfExists: <T>(fieldName: string, x: T) => T | undefined;
|
|
|
|
existsError: (fieldName: string) => boolean;
|
|
|
|
get: (fieldName: string) => string;
|
|
|
|
exists: (fieldName: string) => boolean;
|
|
|
|
};
|
2021-03-04 21:14:54 +01:00
|
|
|
};
|
|
|
|
|
2021-04-01 16:51:28 +02:00
|
|
|
export type Login = Common & {
|
2021-03-06 22:41:36 +01:00
|
|
|
pageId: "login.ftl";
|
2021-03-04 21:14:54 +01:00
|
|
|
url: {
|
|
|
|
loginResetCredentialsUrl: string;
|
|
|
|
registrationUrl: string;
|
|
|
|
};
|
|
|
|
realm: {
|
|
|
|
loginWithEmailAllowed: boolean;
|
|
|
|
rememberMe: boolean;
|
2021-03-06 23:03:03 +01:00
|
|
|
password: boolean;
|
2021-03-04 21:14:54 +01:00
|
|
|
resetPasswordAllowed: boolean;
|
2021-03-04 23:24:43 +01:00
|
|
|
registrationAllowed: boolean;
|
2021-03-04 21:14:54 +01:00
|
|
|
};
|
|
|
|
auth: {
|
|
|
|
selectedCredential?: string;
|
|
|
|
};
|
|
|
|
registrationDisabled: boolean;
|
|
|
|
login: {
|
2021-03-04 18:15:48 +01:00
|
|
|
username?: string;
|
2021-09-17 22:57:38 +02:00
|
|
|
rememberMe?: boolean;
|
2021-03-04 21:14:54 +01:00
|
|
|
};
|
|
|
|
usernameEditDisabled: boolean;
|
|
|
|
social: {
|
|
|
|
displayInfo: boolean;
|
|
|
|
providers?: {
|
|
|
|
loginUrl: string;
|
|
|
|
alias: string;
|
|
|
|
providerId: string;
|
|
|
|
displayName: string;
|
2021-10-11 21:35:40 +02:00
|
|
|
}[];
|
2021-03-04 21:14:54 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-10-11 03:25:02 +02:00
|
|
|
export type RegisterCommon = Common & {
|
2021-03-04 21:14:54 +01:00
|
|
|
url: {
|
|
|
|
registrationAction: string;
|
|
|
|
};
|
|
|
|
passwordRequired: boolean;
|
|
|
|
recaptchaRequired: boolean;
|
2021-03-05 14:50:46 +01:00
|
|
|
recaptchaSiteKey?: string;
|
2021-06-15 17:32:03 +02:00
|
|
|
social: {
|
|
|
|
displayInfo: boolean;
|
|
|
|
providers?: {
|
|
|
|
loginUrl: string;
|
|
|
|
alias: string;
|
|
|
|
providerId: string;
|
|
|
|
displayName: string;
|
2021-10-11 21:35:40 +02:00
|
|
|
}[];
|
2021-06-15 17:32:03 +02:00
|
|
|
};
|
2021-03-04 18:15:48 +01:00
|
|
|
};
|
2021-03-04 21:14:54 +01:00
|
|
|
|
2021-10-11 03:25:02 +02:00
|
|
|
export type Register = RegisterCommon & {
|
|
|
|
pageId: "register.ftl";
|
|
|
|
register: {
|
|
|
|
formData: {
|
|
|
|
firstName?: string;
|
|
|
|
displayName?: string;
|
|
|
|
lastName?: string;
|
|
|
|
email?: string;
|
|
|
|
username?: string;
|
2021-10-11 21:35:40 +02:00
|
|
|
};
|
2021-10-11 03:25:02 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export type RegisterUserProfile = RegisterCommon & {
|
|
|
|
pageId: "register-user-profile.ftl";
|
|
|
|
profile: {
|
2021-10-11 20:56:43 +02:00
|
|
|
context: "REGISTRATION_PROFILE";
|
|
|
|
attributes: Attribute[];
|
|
|
|
attributesByName: Record<string, Attribute>;
|
2021-10-11 21:35:40 +02:00
|
|
|
};
|
2021-10-11 03:25:02 +02:00
|
|
|
};
|
|
|
|
|
2021-04-01 16:51:28 +02:00
|
|
|
export type Info = Common & {
|
2021-03-06 22:41:36 +01:00
|
|
|
pageId: "info.ftl";
|
2021-03-06 14:42:56 +01:00
|
|
|
messageHeader?: string;
|
2021-10-12 00:26:29 +02:00
|
|
|
requiredActions?: ExtractAfterStartingWith<"requiredAction.", MessageKey>[];
|
2021-03-06 14:42:56 +01:00
|
|
|
skipLink: boolean;
|
|
|
|
pageRedirectUri?: string;
|
|
|
|
actionUri?: string;
|
|
|
|
client: {
|
|
|
|
baseUrl?: string;
|
2021-10-11 21:35:40 +02:00
|
|
|
};
|
2021-03-06 14:42:56 +01:00
|
|
|
};
|
|
|
|
|
2021-04-01 16:51:28 +02:00
|
|
|
export type Error = Common & {
|
2021-03-06 23:03:03 +01:00
|
|
|
pageId: "error.ftl";
|
|
|
|
client?: {
|
|
|
|
baseUrl?: string;
|
2021-10-11 21:35:40 +02:00
|
|
|
};
|
2021-06-28 04:04:48 +02:00
|
|
|
message: NonNullable<Common["message"]>;
|
2021-03-06 22:41:36 +01:00
|
|
|
};
|
2021-03-04 21:14:54 +01:00
|
|
|
|
2021-04-01 16:51:28 +02:00
|
|
|
export type LoginResetPassword = Common & {
|
2021-03-07 14:57:53 +01:00
|
|
|
pageId: "login-reset-password.ftl";
|
|
|
|
realm: {
|
|
|
|
loginWithEmailAllowed: boolean;
|
2021-10-11 21:35:40 +02:00
|
|
|
};
|
2021-03-07 14:57:53 +01:00
|
|
|
};
|
|
|
|
|
2021-04-01 16:51:28 +02:00
|
|
|
export type LoginVerifyEmail = Common & {
|
2021-03-07 15:37:37 +01:00
|
|
|
pageId: "login-verify-email.ftl";
|
|
|
|
};
|
|
|
|
|
2021-04-08 15:41:40 +02:00
|
|
|
export type Terms = Common & {
|
|
|
|
pageId: "terms.ftl";
|
|
|
|
};
|
|
|
|
|
2021-05-01 14:55:58 +02:00
|
|
|
export type LoginOtp = Common & {
|
|
|
|
pageId: "login-otp.ftl";
|
|
|
|
otpLogin: {
|
2021-10-11 21:35:40 +02:00
|
|
|
userOtpCredentials: { id: string; userLabel: string }[];
|
|
|
|
};
|
2021-05-01 14:55:58 +02:00
|
|
|
};
|
|
|
|
|
2021-12-28 00:08:25 +03:00
|
|
|
export type LoginUpdatePassword = Common & {
|
|
|
|
pageId: "login-update-password.ftl";
|
|
|
|
username: string;
|
|
|
|
};
|
|
|
|
|
2021-06-14 19:06:31 +02:00
|
|
|
export type LoginUpdateProfile = Common & {
|
|
|
|
pageId: "login-update-profile.ftl";
|
|
|
|
user: {
|
|
|
|
editUsernameAllowed: boolean;
|
|
|
|
username?: string;
|
|
|
|
email?: string;
|
|
|
|
firstName?: string;
|
|
|
|
lastName?: string;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-06-14 21:19:46 +02:00
|
|
|
export type LoginIdpLinkConfirm = Common & {
|
|
|
|
pageId: "login-idp-link-confirm.ftl";
|
|
|
|
idpAlias: string;
|
|
|
|
};
|
2022-01-01 18:44:05 +02:00
|
|
|
|
2022-04-22 17:54:47 +03:00
|
|
|
export type LoginIdpLinkEmail = Common & {
|
|
|
|
pageId: "login-idp-link-email.ftl";
|
|
|
|
idpAlias: string;
|
|
|
|
};
|
|
|
|
|
2022-01-01 18:44:05 +02:00
|
|
|
export type LoginPageExpired = Common & {
|
|
|
|
pageId: "login-page-expired.ftl";
|
|
|
|
};
|
2021-03-04 21:14:54 +01:00
|
|
|
}
|
2021-02-23 15:32:37 +01:00
|
|
|
|
2021-10-11 20:56:43 +02:00
|
|
|
export type Attribute = {
|
|
|
|
name: string;
|
|
|
|
displayName?: string;
|
|
|
|
required: boolean;
|
|
|
|
value?: string;
|
|
|
|
group?: string;
|
|
|
|
groupDisplayHeader?: string;
|
|
|
|
groupDisplayDescription?: string;
|
|
|
|
readOnly: boolean;
|
|
|
|
validators: Validators;
|
|
|
|
annotations: Record<string, string>;
|
2021-10-11 21:35:40 +02:00
|
|
|
groupAnnotations: Record<string, string>;
|
2021-11-01 22:28:53 +01:00
|
|
|
autocomplete?:
|
|
|
|
| "on"
|
|
|
|
| "off"
|
|
|
|
| "name"
|
|
|
|
| "honorific-prefix"
|
|
|
|
| "given-name"
|
|
|
|
| "additional-name"
|
|
|
|
| "family-name"
|
|
|
|
| "honorific-suffix"
|
|
|
|
| "nickname"
|
|
|
|
| "email"
|
|
|
|
| "username"
|
|
|
|
| "new-password"
|
|
|
|
| "current-password"
|
|
|
|
| "one-time-code"
|
|
|
|
| "organization-title"
|
|
|
|
| "organization"
|
|
|
|
| "street-address"
|
|
|
|
| "address-line1"
|
|
|
|
| "address-line2"
|
|
|
|
| "address-line3"
|
|
|
|
| "address-level4"
|
|
|
|
| "address-level3"
|
|
|
|
| "address-level2"
|
|
|
|
| "address-level1"
|
|
|
|
| "country"
|
|
|
|
| "country-name"
|
|
|
|
| "postal-code"
|
|
|
|
| "cc-name"
|
|
|
|
| "cc-given-name"
|
|
|
|
| "cc-additional-name"
|
|
|
|
| "cc-family-name"
|
|
|
|
| "cc-number"
|
|
|
|
| "cc-exp"
|
|
|
|
| "cc-exp-month"
|
|
|
|
| "cc-exp-year"
|
|
|
|
| "cc-csc"
|
|
|
|
| "cc-type"
|
|
|
|
| "transaction-currency"
|
|
|
|
| "transaction-amount"
|
|
|
|
| "language"
|
|
|
|
| "bday"
|
|
|
|
| "bday-day"
|
|
|
|
| "bday-month"
|
|
|
|
| "bday-year"
|
|
|
|
| "sex"
|
|
|
|
| "tel"
|
|
|
|
| "tel-country-code"
|
|
|
|
| "tel-national"
|
|
|
|
| "tel-area-code"
|
|
|
|
| "tel-local"
|
|
|
|
| "tel-extension"
|
|
|
|
| "impp"
|
|
|
|
| "url"
|
|
|
|
| "photo";
|
2021-10-11 20:56:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export type Validators = Partial<{
|
|
|
|
length: Validators.DoIgnoreEmpty & Validators.Range;
|
|
|
|
double: Validators.DoIgnoreEmpty & Validators.Range;
|
|
|
|
integer: Validators.DoIgnoreEmpty & Validators.Range;
|
|
|
|
email: Validators.DoIgnoreEmpty;
|
2021-10-11 21:35:40 +02:00
|
|
|
"up-immutable-attribute": {};
|
|
|
|
"up-attribute-required-by-metadata-value": {};
|
|
|
|
"up-username-has-value": {};
|
|
|
|
"up-duplicate-username": {};
|
|
|
|
"up-username-mutation": {};
|
|
|
|
"up-email-exists-as-username": {};
|
|
|
|
"up-blank-attribute-value": Validators.ErrorMessage & {
|
|
|
|
"fail-on-null": boolean;
|
2021-10-11 20:56:43 +02:00
|
|
|
};
|
2021-10-11 21:35:40 +02:00
|
|
|
"up-duplicate-email": {};
|
|
|
|
"local-date": Validators.DoIgnoreEmpty;
|
2021-10-12 00:26:29 +02:00
|
|
|
pattern: Validators.DoIgnoreEmpty & Validators.ErrorMessage & { pattern: string };
|
|
|
|
"person-name-prohibited-characters": Validators.DoIgnoreEmpty & Validators.ErrorMessage;
|
2021-10-11 20:56:43 +02:00
|
|
|
uri: Validators.DoIgnoreEmpty;
|
2021-10-12 00:26:29 +02:00
|
|
|
"username-prohibited-characters": Validators.DoIgnoreEmpty & Validators.ErrorMessage;
|
2021-10-25 21:26:08 +02:00
|
|
|
/** Made up validator that only exists in Keycloakify */
|
|
|
|
_compareToOther: Validators.DoIgnoreEmpty &
|
|
|
|
Validators.ErrorMessage & {
|
|
|
|
name: string;
|
|
|
|
shouldBe: "equal" | "different";
|
|
|
|
};
|
2022-03-18 00:46:12 +01:00
|
|
|
options: Validators.Options;
|
2021-10-11 20:56:43 +02:00
|
|
|
}>;
|
|
|
|
|
|
|
|
export declare namespace Validators {
|
|
|
|
export type DoIgnoreEmpty = {
|
2021-10-11 21:35:40 +02:00
|
|
|
"ignore.empty.value"?: boolean;
|
2021-10-11 20:56:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export type ErrorMessage = {
|
2021-10-11 21:35:40 +02:00
|
|
|
"error-message"?: string;
|
|
|
|
};
|
2021-10-11 20:56:43 +02:00
|
|
|
|
|
|
|
export type Range = {
|
|
|
|
/** "0", "1", "2"... yeah I know, don't tell me */
|
2021-10-25 21:26:08 +02:00
|
|
|
min?: `${number}`;
|
|
|
|
max?: `${number}`;
|
2021-10-11 20:56:43 +02:00
|
|
|
};
|
2022-03-18 00:46:12 +01:00
|
|
|
export type Options = {
|
|
|
|
options: string[];
|
|
|
|
};
|
2021-10-11 20:56:43 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 03:41:05 +02:00
|
|
|
assert<Equals<KcContextBase["pageId"], PageId>>();
|