@nodii/onboarding 0.0.1 → 0.1.0-dev.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/dist/chunk-34BQX2KR.js +164 -0
- package/dist/chunk-34BQX2KR.js.map +1 -0
- package/dist/chunk-4SWOVHZ2.js +434 -0
- package/dist/chunk-4SWOVHZ2.js.map +1 -0
- package/dist/chunk-7NS7ENJV.js +232 -0
- package/dist/chunk-7NS7ENJV.js.map +1 -0
- package/dist/chunk-AFCJLUPK.js +92 -0
- package/dist/chunk-AFCJLUPK.js.map +1 -0
- package/dist/chunk-AW7W3HAC.js +154 -0
- package/dist/chunk-AW7W3HAC.js.map +1 -0
- package/dist/chunk-BIFANV7M.js +22 -0
- package/dist/chunk-BIFANV7M.js.map +1 -0
- package/dist/chunk-BQCTDU5V.js +327 -0
- package/dist/chunk-BQCTDU5V.js.map +1 -0
- package/dist/chunk-JFIONONR.js +3 -0
- package/dist/chunk-JFIONONR.js.map +1 -0
- package/dist/chunk-SWMIIUXR.js +1162 -0
- package/dist/chunk-SWMIIUXR.js.map +1 -0
- package/dist/chunk-VH6FWDWI.js +3 -0
- package/dist/chunk-VH6FWDWI.js.map +1 -0
- package/dist/chunk-Z4PA6C2Z.js +3 -0
- package/dist/chunk-Z4PA6C2Z.js.map +1 -0
- package/dist/chunk-ZDY2I6KY.js +3 -0
- package/dist/chunk-ZDY2I6KY.js.map +1 -0
- package/dist/dynamic/index.d.ts +184 -0
- package/dist/dynamic/index.js +4 -0
- package/dist/dynamic/index.js.map +1 -0
- package/dist/form/index.d.ts +64 -0
- package/dist/form/index.js +5 -0
- package/dist/form/index.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -0
- package/dist/model-IEyDI54w.d.ts +487 -0
- package/dist/recaptcha/index.d.ts +102 -0
- package/dist/recaptcha/index.js +4 -0
- package/dist/recaptcha/index.js.map +1 -0
- package/dist/schema-TfyBU6JW.d.ts +107 -0
- package/dist/signup-client-Bl6eUrxR.d.ts +259 -0
- package/dist/spec/index.d.ts +88 -0
- package/dist/spec/index.js +4 -0
- package/dist/spec/index.js.map +1 -0
- package/dist/submit/index.d.ts +106 -0
- package/dist/submit/index.js +6 -0
- package/dist/submit/index.js.map +1 -0
- package/dist/widget/index.d.ts +219 -0
- package/dist/widget/index.js +10 -0
- package/dist/widget/index.js.map +1 -0
- package/package.json +77 -6
- package/README.md +0 -5
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* D540 §1 onboarding-spec model — mirrors the LOCKED hub REST contract:
|
|
5
|
+
* GET /api/v1/public/onboarding/spec (PublicOnboardingSpecResponse)
|
|
6
|
+
*
|
|
7
|
+
* Response shape (hub JSON Schema, both tiers identical):
|
|
8
|
+
* {
|
|
9
|
+
* specVersion: string (monotonic; echo on submit; stale ⇒ 409),
|
|
10
|
+
* onboarderTier: "platform" | "tenant",
|
|
11
|
+
* botChallenge: { provider: "recaptcha", siteKey: string },
|
|
12
|
+
* forms: {
|
|
13
|
+
* contact: { fields: SpecField[] },
|
|
14
|
+
* signup: { steps: [{ stage: "lead"|"prospect"|"activation",
|
|
15
|
+
* fields: SpecField[] }] }
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* SpecField (required: key, type, label, required):
|
|
20
|
+
* { key, type, label, required, validation?, options?, serviceSelection?,
|
|
21
|
+
* piiClass?: "none"|"context"|"always"|"reference" }
|
|
22
|
+
*
|
|
23
|
+
* The Zod schema below validates a fetched spec BEFORE the SDK renders
|
|
24
|
+
* anything from it — a malformed spec throws OnboardingSpecInvalidError
|
|
25
|
+
* (a half-parsed spec could silently drop required fields).
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
type OnboarderTier = "platform" | "tenant";
|
|
29
|
+
type PiiClass = "none" | "context" | "always" | "reference";
|
|
30
|
+
type SpecStage = "lead" | "prospect" | "activation";
|
|
31
|
+
type TerminalStage = "prospect" | "inactive" | "active";
|
|
32
|
+
/**
|
|
33
|
+
* Field keys are interpolated into DOM element ids and (historically) CSS
|
|
34
|
+
* selectors by the widget layer. Constrain them to a strict identifier
|
|
35
|
+
* alphabet so a MALICIOUS or compromised onboarder spec cannot smuggle CSS
|
|
36
|
+
* metacharacters or selector-breakout payloads (e.g. `evil], [onclick=…`)
|
|
37
|
+
* through the fetched spec. A spec with an out-of-alphabet key is REJECTED
|
|
38
|
+
* at parse time → OnboardingSpecInvalidError (fail-closed; never rendered).
|
|
39
|
+
* This is layer 1; the widget also CSS.escapes ids as defense-in-depth.
|
|
40
|
+
*/
|
|
41
|
+
declare const FIELD_KEY_PATTERN: RegExp;
|
|
42
|
+
declare const specFieldSchema: z.ZodObject<{
|
|
43
|
+
key: z.ZodString;
|
|
44
|
+
type: z.ZodString;
|
|
45
|
+
label: z.ZodString;
|
|
46
|
+
required: z.ZodBoolean;
|
|
47
|
+
validation: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
48
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
49
|
+
serviceSelection: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
piiClass: z.ZodOptional<z.ZodEnum<["none", "context", "always", "reference"]>>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
type: string;
|
|
53
|
+
key: string;
|
|
54
|
+
label: string;
|
|
55
|
+
required: boolean;
|
|
56
|
+
options?: unknown[] | undefined;
|
|
57
|
+
validation?: Record<string, unknown> | undefined;
|
|
58
|
+
serviceSelection?: boolean | undefined;
|
|
59
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
type: string;
|
|
62
|
+
key: string;
|
|
63
|
+
label: string;
|
|
64
|
+
required: boolean;
|
|
65
|
+
options?: unknown[] | undefined;
|
|
66
|
+
validation?: Record<string, unknown> | undefined;
|
|
67
|
+
serviceSelection?: boolean | undefined;
|
|
68
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
type SpecField = z.infer<typeof specFieldSchema>;
|
|
71
|
+
declare const specStepSchema: z.ZodObject<{
|
|
72
|
+
stage: z.ZodEnum<["lead", "prospect", "activation"]>;
|
|
73
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
74
|
+
key: z.ZodString;
|
|
75
|
+
type: z.ZodString;
|
|
76
|
+
label: z.ZodString;
|
|
77
|
+
required: z.ZodBoolean;
|
|
78
|
+
validation: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
79
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
80
|
+
serviceSelection: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
piiClass: z.ZodOptional<z.ZodEnum<["none", "context", "always", "reference"]>>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
type: string;
|
|
84
|
+
key: string;
|
|
85
|
+
label: string;
|
|
86
|
+
required: boolean;
|
|
87
|
+
options?: unknown[] | undefined;
|
|
88
|
+
validation?: Record<string, unknown> | undefined;
|
|
89
|
+
serviceSelection?: boolean | undefined;
|
|
90
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
type: string;
|
|
93
|
+
key: string;
|
|
94
|
+
label: string;
|
|
95
|
+
required: boolean;
|
|
96
|
+
options?: unknown[] | undefined;
|
|
97
|
+
validation?: Record<string, unknown> | undefined;
|
|
98
|
+
serviceSelection?: boolean | undefined;
|
|
99
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
100
|
+
}>, "many">;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
stage: "lead" | "prospect" | "activation";
|
|
103
|
+
fields: {
|
|
104
|
+
type: string;
|
|
105
|
+
key: string;
|
|
106
|
+
label: string;
|
|
107
|
+
required: boolean;
|
|
108
|
+
options?: unknown[] | undefined;
|
|
109
|
+
validation?: Record<string, unknown> | undefined;
|
|
110
|
+
serviceSelection?: boolean | undefined;
|
|
111
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
112
|
+
}[];
|
|
113
|
+
}, {
|
|
114
|
+
stage: "lead" | "prospect" | "activation";
|
|
115
|
+
fields: {
|
|
116
|
+
type: string;
|
|
117
|
+
key: string;
|
|
118
|
+
label: string;
|
|
119
|
+
required: boolean;
|
|
120
|
+
options?: unknown[] | undefined;
|
|
121
|
+
validation?: Record<string, unknown> | undefined;
|
|
122
|
+
serviceSelection?: boolean | undefined;
|
|
123
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
124
|
+
}[];
|
|
125
|
+
}>;
|
|
126
|
+
type SpecStep = z.infer<typeof specStepSchema>;
|
|
127
|
+
declare const onboardingSpecSchema: z.ZodObject<{
|
|
128
|
+
specVersion: z.ZodString;
|
|
129
|
+
onboarderTier: z.ZodEnum<["platform", "tenant"]>;
|
|
130
|
+
botChallenge: z.ZodObject<{
|
|
131
|
+
provider: z.ZodLiteral<"recaptcha">;
|
|
132
|
+
siteKey: z.ZodString;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
provider: "recaptcha";
|
|
135
|
+
siteKey: string;
|
|
136
|
+
}, {
|
|
137
|
+
provider: "recaptcha";
|
|
138
|
+
siteKey: string;
|
|
139
|
+
}>;
|
|
140
|
+
forms: z.ZodObject<{
|
|
141
|
+
contact: z.ZodObject<{
|
|
142
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
143
|
+
key: z.ZodString;
|
|
144
|
+
type: z.ZodString;
|
|
145
|
+
label: z.ZodString;
|
|
146
|
+
required: z.ZodBoolean;
|
|
147
|
+
validation: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
148
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
149
|
+
serviceSelection: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
+
piiClass: z.ZodOptional<z.ZodEnum<["none", "context", "always", "reference"]>>;
|
|
151
|
+
}, "strip", z.ZodTypeAny, {
|
|
152
|
+
type: string;
|
|
153
|
+
key: string;
|
|
154
|
+
label: string;
|
|
155
|
+
required: boolean;
|
|
156
|
+
options?: unknown[] | undefined;
|
|
157
|
+
validation?: Record<string, unknown> | undefined;
|
|
158
|
+
serviceSelection?: boolean | undefined;
|
|
159
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
160
|
+
}, {
|
|
161
|
+
type: string;
|
|
162
|
+
key: string;
|
|
163
|
+
label: string;
|
|
164
|
+
required: boolean;
|
|
165
|
+
options?: unknown[] | undefined;
|
|
166
|
+
validation?: Record<string, unknown> | undefined;
|
|
167
|
+
serviceSelection?: boolean | undefined;
|
|
168
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
169
|
+
}>, "many">;
|
|
170
|
+
}, "strip", z.ZodTypeAny, {
|
|
171
|
+
fields: {
|
|
172
|
+
type: string;
|
|
173
|
+
key: string;
|
|
174
|
+
label: string;
|
|
175
|
+
required: boolean;
|
|
176
|
+
options?: unknown[] | undefined;
|
|
177
|
+
validation?: Record<string, unknown> | undefined;
|
|
178
|
+
serviceSelection?: boolean | undefined;
|
|
179
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
180
|
+
}[];
|
|
181
|
+
}, {
|
|
182
|
+
fields: {
|
|
183
|
+
type: string;
|
|
184
|
+
key: string;
|
|
185
|
+
label: string;
|
|
186
|
+
required: boolean;
|
|
187
|
+
options?: unknown[] | undefined;
|
|
188
|
+
validation?: Record<string, unknown> | undefined;
|
|
189
|
+
serviceSelection?: boolean | undefined;
|
|
190
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
191
|
+
}[];
|
|
192
|
+
}>;
|
|
193
|
+
signup: z.ZodObject<{
|
|
194
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
195
|
+
stage: z.ZodEnum<["lead", "prospect", "activation"]>;
|
|
196
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
197
|
+
key: z.ZodString;
|
|
198
|
+
type: z.ZodString;
|
|
199
|
+
label: z.ZodString;
|
|
200
|
+
required: z.ZodBoolean;
|
|
201
|
+
validation: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
202
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
203
|
+
serviceSelection: z.ZodOptional<z.ZodBoolean>;
|
|
204
|
+
piiClass: z.ZodOptional<z.ZodEnum<["none", "context", "always", "reference"]>>;
|
|
205
|
+
}, "strip", z.ZodTypeAny, {
|
|
206
|
+
type: string;
|
|
207
|
+
key: string;
|
|
208
|
+
label: string;
|
|
209
|
+
required: boolean;
|
|
210
|
+
options?: unknown[] | undefined;
|
|
211
|
+
validation?: Record<string, unknown> | undefined;
|
|
212
|
+
serviceSelection?: boolean | undefined;
|
|
213
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
214
|
+
}, {
|
|
215
|
+
type: string;
|
|
216
|
+
key: string;
|
|
217
|
+
label: string;
|
|
218
|
+
required: boolean;
|
|
219
|
+
options?: unknown[] | undefined;
|
|
220
|
+
validation?: Record<string, unknown> | undefined;
|
|
221
|
+
serviceSelection?: boolean | undefined;
|
|
222
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
223
|
+
}>, "many">;
|
|
224
|
+
}, "strip", z.ZodTypeAny, {
|
|
225
|
+
stage: "lead" | "prospect" | "activation";
|
|
226
|
+
fields: {
|
|
227
|
+
type: string;
|
|
228
|
+
key: string;
|
|
229
|
+
label: string;
|
|
230
|
+
required: boolean;
|
|
231
|
+
options?: unknown[] | undefined;
|
|
232
|
+
validation?: Record<string, unknown> | undefined;
|
|
233
|
+
serviceSelection?: boolean | undefined;
|
|
234
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
235
|
+
}[];
|
|
236
|
+
}, {
|
|
237
|
+
stage: "lead" | "prospect" | "activation";
|
|
238
|
+
fields: {
|
|
239
|
+
type: string;
|
|
240
|
+
key: string;
|
|
241
|
+
label: string;
|
|
242
|
+
required: boolean;
|
|
243
|
+
options?: unknown[] | undefined;
|
|
244
|
+
validation?: Record<string, unknown> | undefined;
|
|
245
|
+
serviceSelection?: boolean | undefined;
|
|
246
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
247
|
+
}[];
|
|
248
|
+
}>, "many">;
|
|
249
|
+
}, "strip", z.ZodTypeAny, {
|
|
250
|
+
steps: {
|
|
251
|
+
stage: "lead" | "prospect" | "activation";
|
|
252
|
+
fields: {
|
|
253
|
+
type: string;
|
|
254
|
+
key: string;
|
|
255
|
+
label: string;
|
|
256
|
+
required: boolean;
|
|
257
|
+
options?: unknown[] | undefined;
|
|
258
|
+
validation?: Record<string, unknown> | undefined;
|
|
259
|
+
serviceSelection?: boolean | undefined;
|
|
260
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
261
|
+
}[];
|
|
262
|
+
}[];
|
|
263
|
+
}, {
|
|
264
|
+
steps: {
|
|
265
|
+
stage: "lead" | "prospect" | "activation";
|
|
266
|
+
fields: {
|
|
267
|
+
type: string;
|
|
268
|
+
key: string;
|
|
269
|
+
label: string;
|
|
270
|
+
required: boolean;
|
|
271
|
+
options?: unknown[] | undefined;
|
|
272
|
+
validation?: Record<string, unknown> | undefined;
|
|
273
|
+
serviceSelection?: boolean | undefined;
|
|
274
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
275
|
+
}[];
|
|
276
|
+
}[];
|
|
277
|
+
}>;
|
|
278
|
+
}, "strip", z.ZodTypeAny, {
|
|
279
|
+
contact: {
|
|
280
|
+
fields: {
|
|
281
|
+
type: string;
|
|
282
|
+
key: string;
|
|
283
|
+
label: string;
|
|
284
|
+
required: boolean;
|
|
285
|
+
options?: unknown[] | undefined;
|
|
286
|
+
validation?: Record<string, unknown> | undefined;
|
|
287
|
+
serviceSelection?: boolean | undefined;
|
|
288
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
289
|
+
}[];
|
|
290
|
+
};
|
|
291
|
+
signup: {
|
|
292
|
+
steps: {
|
|
293
|
+
stage: "lead" | "prospect" | "activation";
|
|
294
|
+
fields: {
|
|
295
|
+
type: string;
|
|
296
|
+
key: string;
|
|
297
|
+
label: string;
|
|
298
|
+
required: boolean;
|
|
299
|
+
options?: unknown[] | undefined;
|
|
300
|
+
validation?: Record<string, unknown> | undefined;
|
|
301
|
+
serviceSelection?: boolean | undefined;
|
|
302
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
303
|
+
}[];
|
|
304
|
+
}[];
|
|
305
|
+
};
|
|
306
|
+
}, {
|
|
307
|
+
contact: {
|
|
308
|
+
fields: {
|
|
309
|
+
type: string;
|
|
310
|
+
key: string;
|
|
311
|
+
label: string;
|
|
312
|
+
required: boolean;
|
|
313
|
+
options?: unknown[] | undefined;
|
|
314
|
+
validation?: Record<string, unknown> | undefined;
|
|
315
|
+
serviceSelection?: boolean | undefined;
|
|
316
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
317
|
+
}[];
|
|
318
|
+
};
|
|
319
|
+
signup: {
|
|
320
|
+
steps: {
|
|
321
|
+
stage: "lead" | "prospect" | "activation";
|
|
322
|
+
fields: {
|
|
323
|
+
type: string;
|
|
324
|
+
key: string;
|
|
325
|
+
label: string;
|
|
326
|
+
required: boolean;
|
|
327
|
+
options?: unknown[] | undefined;
|
|
328
|
+
validation?: Record<string, unknown> | undefined;
|
|
329
|
+
serviceSelection?: boolean | undefined;
|
|
330
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
331
|
+
}[];
|
|
332
|
+
}[];
|
|
333
|
+
};
|
|
334
|
+
}>;
|
|
335
|
+
}, "strip", z.ZodTypeAny, {
|
|
336
|
+
specVersion: string;
|
|
337
|
+
onboarderTier: "platform" | "tenant";
|
|
338
|
+
botChallenge: {
|
|
339
|
+
provider: "recaptcha";
|
|
340
|
+
siteKey: string;
|
|
341
|
+
};
|
|
342
|
+
forms: {
|
|
343
|
+
contact: {
|
|
344
|
+
fields: {
|
|
345
|
+
type: string;
|
|
346
|
+
key: string;
|
|
347
|
+
label: string;
|
|
348
|
+
required: boolean;
|
|
349
|
+
options?: unknown[] | undefined;
|
|
350
|
+
validation?: Record<string, unknown> | undefined;
|
|
351
|
+
serviceSelection?: boolean | undefined;
|
|
352
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
353
|
+
}[];
|
|
354
|
+
};
|
|
355
|
+
signup: {
|
|
356
|
+
steps: {
|
|
357
|
+
stage: "lead" | "prospect" | "activation";
|
|
358
|
+
fields: {
|
|
359
|
+
type: string;
|
|
360
|
+
key: string;
|
|
361
|
+
label: string;
|
|
362
|
+
required: boolean;
|
|
363
|
+
options?: unknown[] | undefined;
|
|
364
|
+
validation?: Record<string, unknown> | undefined;
|
|
365
|
+
serviceSelection?: boolean | undefined;
|
|
366
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
367
|
+
}[];
|
|
368
|
+
}[];
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
}, {
|
|
372
|
+
specVersion: string;
|
|
373
|
+
onboarderTier: "platform" | "tenant";
|
|
374
|
+
botChallenge: {
|
|
375
|
+
provider: "recaptcha";
|
|
376
|
+
siteKey: string;
|
|
377
|
+
};
|
|
378
|
+
forms: {
|
|
379
|
+
contact: {
|
|
380
|
+
fields: {
|
|
381
|
+
type: string;
|
|
382
|
+
key: string;
|
|
383
|
+
label: string;
|
|
384
|
+
required: boolean;
|
|
385
|
+
options?: unknown[] | undefined;
|
|
386
|
+
validation?: Record<string, unknown> | undefined;
|
|
387
|
+
serviceSelection?: boolean | undefined;
|
|
388
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
389
|
+
}[];
|
|
390
|
+
};
|
|
391
|
+
signup: {
|
|
392
|
+
steps: {
|
|
393
|
+
stage: "lead" | "prospect" | "activation";
|
|
394
|
+
fields: {
|
|
395
|
+
type: string;
|
|
396
|
+
key: string;
|
|
397
|
+
label: string;
|
|
398
|
+
required: boolean;
|
|
399
|
+
options?: unknown[] | undefined;
|
|
400
|
+
validation?: Record<string, unknown> | undefined;
|
|
401
|
+
serviceSelection?: boolean | undefined;
|
|
402
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
403
|
+
}[];
|
|
404
|
+
}[];
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
}>;
|
|
408
|
+
type OnboardingSpec = z.infer<typeof onboardingSpecSchema>;
|
|
409
|
+
/**
|
|
410
|
+
* Parse an unknown value as an OnboardingSpec.
|
|
411
|
+
* Returns a SafeParseReturnType (inferred).
|
|
412
|
+
*/
|
|
413
|
+
declare function validateOnboardingSpec(value: unknown): z.SafeParseReturnType<{
|
|
414
|
+
specVersion: string;
|
|
415
|
+
onboarderTier: "platform" | "tenant";
|
|
416
|
+
botChallenge: {
|
|
417
|
+
provider: "recaptcha";
|
|
418
|
+
siteKey: string;
|
|
419
|
+
};
|
|
420
|
+
forms: {
|
|
421
|
+
contact: {
|
|
422
|
+
fields: {
|
|
423
|
+
type: string;
|
|
424
|
+
key: string;
|
|
425
|
+
label: string;
|
|
426
|
+
required: boolean;
|
|
427
|
+
options?: unknown[] | undefined;
|
|
428
|
+
validation?: Record<string, unknown> | undefined;
|
|
429
|
+
serviceSelection?: boolean | undefined;
|
|
430
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
431
|
+
}[];
|
|
432
|
+
};
|
|
433
|
+
signup: {
|
|
434
|
+
steps: {
|
|
435
|
+
stage: "lead" | "prospect" | "activation";
|
|
436
|
+
fields: {
|
|
437
|
+
type: string;
|
|
438
|
+
key: string;
|
|
439
|
+
label: string;
|
|
440
|
+
required: boolean;
|
|
441
|
+
options?: unknown[] | undefined;
|
|
442
|
+
validation?: Record<string, unknown> | undefined;
|
|
443
|
+
serviceSelection?: boolean | undefined;
|
|
444
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
445
|
+
}[];
|
|
446
|
+
}[];
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
}, {
|
|
450
|
+
specVersion: string;
|
|
451
|
+
onboarderTier: "platform" | "tenant";
|
|
452
|
+
botChallenge: {
|
|
453
|
+
provider: "recaptcha";
|
|
454
|
+
siteKey: string;
|
|
455
|
+
};
|
|
456
|
+
forms: {
|
|
457
|
+
contact: {
|
|
458
|
+
fields: {
|
|
459
|
+
type: string;
|
|
460
|
+
key: string;
|
|
461
|
+
label: string;
|
|
462
|
+
required: boolean;
|
|
463
|
+
options?: unknown[] | undefined;
|
|
464
|
+
validation?: Record<string, unknown> | undefined;
|
|
465
|
+
serviceSelection?: boolean | undefined;
|
|
466
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
467
|
+
}[];
|
|
468
|
+
};
|
|
469
|
+
signup: {
|
|
470
|
+
steps: {
|
|
471
|
+
stage: "lead" | "prospect" | "activation";
|
|
472
|
+
fields: {
|
|
473
|
+
type: string;
|
|
474
|
+
key: string;
|
|
475
|
+
label: string;
|
|
476
|
+
required: boolean;
|
|
477
|
+
options?: unknown[] | undefined;
|
|
478
|
+
validation?: Record<string, unknown> | undefined;
|
|
479
|
+
serviceSelection?: boolean | undefined;
|
|
480
|
+
piiClass?: "none" | "context" | "always" | "reference" | undefined;
|
|
481
|
+
}[];
|
|
482
|
+
}[];
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
}>;
|
|
486
|
+
|
|
487
|
+
export { FIELD_KEY_PATTERN as F, type OnboarderTier as O, type PiiClass as P, type SpecField as S, type TerminalStage as T, type OnboardingSpec as a, type SpecStage as b, type SpecStep as c, specStepSchema as d, onboardingSpecSchema as o, specFieldSchema as s, validateOnboardingSpec as v };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* reCAPTCHA v3 loader and token executor.
|
|
3
|
+
*
|
|
4
|
+
* Per D537:
|
|
5
|
+
* - Site key is public (supplied at mount time from the spec response).
|
|
6
|
+
* - Secret key is NEVER in the browser — only the site key is here.
|
|
7
|
+
* - v3 score-based by default; the operator may configure a v2 fallback
|
|
8
|
+
* on the server side for low-score requests.
|
|
9
|
+
* - The loader injects the reCAPTCHA script once and exposes execute()
|
|
10
|
+
* to obtain a fresh token before each submit.
|
|
11
|
+
*
|
|
12
|
+
* Failure semantics (all recoverable, all bounded by opts.timeoutMs / 10s):
|
|
13
|
+
* - A script load failure (adblock / CSP / offline) REJECTS with
|
|
14
|
+
* RecaptchaError(kind:"load_failed"), EVICTS the cached promise, and
|
|
15
|
+
* REMOVES the injected script tag — the next loadRecaptcha call starts
|
|
16
|
+
* fresh. A transient failure never poisons the siteKey.
|
|
17
|
+
* - EVERY wait is bounded, including grecaptcha.ready() AFTER onload and on
|
|
18
|
+
* the adoption/poll paths: if api.js serves but the inner runtime never
|
|
19
|
+
* boots (ready() never fires), the loader rejects RecaptchaError(
|
|
20
|
+
* kind:"timeout") and evicts, rather than hanging the widget on
|
|
21
|
+
* "Sending…" forever.
|
|
22
|
+
* - The "existing script tag but no grecaptcha global" poll is BOUNDED,
|
|
23
|
+
* then the subsequent ready() is bounded by the remaining budget.
|
|
24
|
+
*
|
|
25
|
+
* Multi-siteKey + foreign-global handling (honest):
|
|
26
|
+
* - The v3 script loads with `?render=<siteKey>` and initializes for ONE
|
|
27
|
+
* site key per page. A SECOND different siteKey after our first load is
|
|
28
|
+
* rejected RecaptchaError(kind:"sitekey_mismatch").
|
|
29
|
+
* - If the HOST page pre-loaded grecaptcha with an unknown render key (a
|
|
30
|
+
* FOREIGN global this SDK did not create), we CANNOT introspect its key,
|
|
31
|
+
* so executing our key against it would be the exact silent misfire we
|
|
32
|
+
* promise to prevent. We reject RecaptchaError(kind:"sitekey_mismatch")
|
|
33
|
+
* instead. (Detection: we only adopt a global we brought up ourselves or
|
|
34
|
+
* that our own script tag is loading.)
|
|
35
|
+
*
|
|
36
|
+
* execute() rejections (invalid key at execute time, Google-internal errors,
|
|
37
|
+
* often plain strings) are wrapped in RecaptchaError(kind:"execute_failed").
|
|
38
|
+
*
|
|
39
|
+
* This module is browser-only. It accesses the `window` and `document`
|
|
40
|
+
* globals explicitly.
|
|
41
|
+
*/
|
|
42
|
+
declare global {
|
|
43
|
+
interface Window {
|
|
44
|
+
grecaptcha?: Grecaptcha;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
interface Grecaptcha {
|
|
48
|
+
ready(callback: () => void): void;
|
|
49
|
+
execute(siteKey: string, options: {
|
|
50
|
+
action: string;
|
|
51
|
+
}): Promise<string>;
|
|
52
|
+
}
|
|
53
|
+
type RecaptchaErrorKind = "load_failed" | "timeout" | "sitekey_mismatch" | "execute_failed" | "unavailable";
|
|
54
|
+
/** Typed error for every reCAPTCHA loader failure path. */
|
|
55
|
+
declare class RecaptchaError extends Error {
|
|
56
|
+
readonly kind: RecaptchaErrorKind;
|
|
57
|
+
constructor(kind: RecaptchaErrorKind, message: string);
|
|
58
|
+
}
|
|
59
|
+
interface RecaptchaLoadOptions {
|
|
60
|
+
/**
|
|
61
|
+
* Max time to wait for the script / grecaptcha global to become ready
|
|
62
|
+
* before rejecting with RecaptchaError(kind:"timeout"). Default 10s.
|
|
63
|
+
*/
|
|
64
|
+
timeoutMs?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Inject the reCAPTCHA v3 script for the given siteKey.
|
|
68
|
+
* Idempotent per siteKey: concurrent/repeated calls share one load.
|
|
69
|
+
* A FAILED load is evicted — the next call retries from scratch.
|
|
70
|
+
*
|
|
71
|
+
* @throws {RecaptchaError} kind:"sitekey_mismatch" — a different siteKey
|
|
72
|
+
* is already active (single-render-script limitation, see module doc).
|
|
73
|
+
* @throws {RecaptchaError} kind:"load_failed" — script failed to load.
|
|
74
|
+
* @throws {RecaptchaError} kind:"timeout" — script/global never became ready.
|
|
75
|
+
* @throws {RecaptchaError} kind:"unavailable" — no DOM (not a browser).
|
|
76
|
+
*/
|
|
77
|
+
declare function loadRecaptcha(siteKey: string, opts?: RecaptchaLoadOptions): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Obtain a fresh reCAPTCHA v3 token for the given action.
|
|
80
|
+
* Loads the script if not already loaded. A previous load FAILURE does not
|
|
81
|
+
* block this call — the loader retries from scratch (see loadRecaptcha).
|
|
82
|
+
*
|
|
83
|
+
* @param siteKey - The public reCAPTCHA site key (from the spec endpoint).
|
|
84
|
+
* @param action - The action name (e.g. "contact_submit"). Used for score analytics.
|
|
85
|
+
* @param opts - Optional load options (timeoutMs — also bounds execute()).
|
|
86
|
+
* @returns A fresh reCAPTCHA token. Valid for ~2 minutes.
|
|
87
|
+
*
|
|
88
|
+
* @throws {RecaptchaError} kind:"timeout" if execute() does not settle within
|
|
89
|
+
* the timeout (Google runtime hung) — bounded so the widget re-enables.
|
|
90
|
+
* @throws {RecaptchaError} on any load failure (see loadRecaptcha kinds) or
|
|
91
|
+
* an execute() rejection (kind:"execute_failed").
|
|
92
|
+
*/
|
|
93
|
+
declare function executeRecaptcha(siteKey: string, action: string, opts?: RecaptchaLoadOptions): Promise<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Reset ALL loader state: cached load promise, active siteKey, and the
|
|
96
|
+
* injected script tag (removed from the DOM if present). Primarily for
|
|
97
|
+
* tests and for host pages that intentionally tear down reCAPTCHA.
|
|
98
|
+
* Does NOT unset window.grecaptcha (the script may still own it).
|
|
99
|
+
*/
|
|
100
|
+
declare function _resetRecaptchaState(): void;
|
|
101
|
+
|
|
102
|
+
export { RecaptchaError, type RecaptchaErrorKind, type RecaptchaLoadOptions, _resetRecaptchaState, executeRecaptcha, loadRecaptcha };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|