-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcallback-map.ts
More file actions
157 lines (153 loc) · 5.08 KB
/
callback-map.ts
File metadata and controls
157 lines (153 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import type {
AttributeInputCallback,
BaseCallback,
ChoiceCallback,
ConfirmationCallback,
DeviceProfileCallback,
HiddenValueCallback,
KbaCreateCallback,
MetadataCallback,
NameCallback,
PasswordCallback,
PingOneProtectEvaluationCallback,
PingOneProtectInitializeCallback,
PollingWaitCallback,
ReCaptchaCallback,
ReCaptchaEnterpriseCallback,
RedirectCallback,
SelectIdPCallback,
SuspendedTextOutputCallback,
TermsAndConditionsCallback,
TextInputCallback,
TextOutputCallback,
ValidatedCreatePasswordCallback,
ValidatedCreateUsernameCallback,
} from '@forgerock/journey-client/types';
import {
attributeInputComponent,
choiceComponent,
confirmationComponent,
deviceProfileComponent,
hiddenValueComponent,
kbaCreateComponent,
metadataComponent,
passwordComponent,
pingProtectEvaluationComponent,
pingProtectInitializeComponent,
pollingWaitComponent,
recaptchaComponent,
recaptchaEnterpriseComponent,
redirectComponent,
selectIdpComponent,
suspendedTextOutputComponent,
termsAndConditionsComponent,
textInputComponent,
textOutputComponent,
validatedPasswordComponent,
validatedUsernameComponent,
} from './components/index.js';
/**
* Renders a callback component based on its type
* @param journeyEl - The container element to append the component to
* @param callback - The callback instance
* @param idx - Index for generating unique IDs
*/
export function renderCallback(
journeyEl: HTMLDivElement,
callback: BaseCallback,
idx: number,
): void {
switch (callback.getType()) {
case 'BooleanAttributeInputCallback':
case 'NumberAttributeInputCallback':
case 'StringAttributeInputCallback':
attributeInputComponent(
journeyEl,
callback as AttributeInputCallback<string | number | boolean>,
idx,
);
break;
case 'ChoiceCallback':
choiceComponent(journeyEl, callback as ChoiceCallback, idx);
break;
case 'ConfirmationCallback':
confirmationComponent(journeyEl, callback as ConfirmationCallback, idx);
break;
case 'DeviceProfileCallback':
deviceProfileComponent(journeyEl, callback as DeviceProfileCallback, idx);
break;
case 'HiddenValueCallback':
hiddenValueComponent(journeyEl, callback as HiddenValueCallback, idx);
break;
case 'KbaCreateCallback':
kbaCreateComponent(journeyEl, callback as KbaCreateCallback, idx);
break;
case 'MetadataCallback':
metadataComponent(journeyEl, callback as MetadataCallback, idx);
break;
case 'NameCallback':
textInputComponent(journeyEl, callback as NameCallback, idx);
break;
case 'PasswordCallback':
passwordComponent(journeyEl, callback as PasswordCallback, idx);
break;
case 'PingOneProtectEvaluationCallback':
pingProtectEvaluationComponent(journeyEl, callback as PingOneProtectEvaluationCallback, idx);
break;
case 'PingOneProtectInitializeCallback':
pingProtectInitializeComponent(journeyEl, callback as PingOneProtectInitializeCallback, idx);
break;
case 'PollingWaitCallback':
pollingWaitComponent(journeyEl, callback as PollingWaitCallback, idx);
break;
case 'ReCaptchaCallback':
recaptchaComponent(journeyEl, callback as ReCaptchaCallback, idx);
break;
case 'ReCaptchaEnterpriseCallback':
recaptchaEnterpriseComponent(journeyEl, callback as ReCaptchaEnterpriseCallback, idx);
break;
case 'RedirectCallback':
redirectComponent(journeyEl, callback as RedirectCallback, idx);
break;
case 'SelectIdPCallback':
selectIdpComponent(journeyEl, callback as SelectIdPCallback, idx);
break;
case 'SuspendedTextOutputCallback':
suspendedTextOutputComponent(journeyEl, callback as SuspendedTextOutputCallback, idx);
break;
case 'TermsAndConditionsCallback':
termsAndConditionsComponent(journeyEl, callback as TermsAndConditionsCallback, idx);
break;
case 'TextInputCallback':
textInputComponent(journeyEl, callback as TextInputCallback, idx);
break;
case 'TextOutputCallback':
textOutputComponent(journeyEl, callback as TextOutputCallback, idx);
break;
case 'ValidatedCreatePasswordCallback':
validatedPasswordComponent(journeyEl, callback as ValidatedCreatePasswordCallback, idx);
break;
case 'ValidatedCreateUsernameCallback':
validatedUsernameComponent(journeyEl, callback as ValidatedCreateUsernameCallback, idx);
break;
default:
console.warn(`Unknown callback type: ${callback.getType()}`);
break;
}
}
/**
* Renders all callbacks in a step
* @param journeyEl - The container element to append components to
* @param callbacks - Array of callback instances
*/
export function renderCallbacks(journeyEl: HTMLDivElement, callbacks: BaseCallback[]): void {
callbacks.forEach((callback, idx) => {
renderCallback(journeyEl, callback, idx);
});
}