@nodii/onboarding 0.0.1 → 0.1.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 +75 -2
- package/dist/chunk-7NS7ENJV.js +232 -0
- package/dist/chunk-7NS7ENJV.js.map +1 -0
- package/dist/chunk-AZE3NPSY.js +186 -0
- package/dist/chunk-AZE3NPSY.js.map +1 -0
- package/dist/chunk-BMQINH6O.js +401 -0
- package/dist/chunk-BMQINH6O.js.map +1 -0
- package/dist/chunk-F75ZJERM.js +199 -0
- package/dist/chunk-F75ZJERM.js.map +1 -0
- package/dist/chunk-FIRSA7EH.js +3 -0
- package/dist/chunk-FIRSA7EH.js.map +1 -0
- package/dist/chunk-IPAKPLIF.js +1660 -0
- package/dist/chunk-IPAKPLIF.js.map +1 -0
- package/dist/chunk-JFDQZ3AC.js +3 -0
- package/dist/chunk-JFDQZ3AC.js.map +1 -0
- package/dist/chunk-JFIONONR.js +3 -0
- package/dist/chunk-JFIONONR.js.map +1 -0
- package/dist/chunk-KQTS47FC.js +546 -0
- package/dist/chunk-KQTS47FC.js.map +1 -0
- package/dist/chunk-LVJM4CTG.js +306 -0
- package/dist/chunk-LVJM4CTG.js.map +1 -0
- package/dist/chunk-SEKNVHD3.js +59 -0
- package/dist/chunk-SEKNVHD3.js.map +1 -0
- package/dist/chunk-SIMLMQPT.js +37 -0
- package/dist/chunk-SIMLMQPT.js.map +1 -0
- package/dist/chunk-U56GQITG.js +79 -0
- package/dist/chunk-U56GQITG.js.map +1 -0
- package/dist/chunk-U6AXKGYQ.js +101 -0
- package/dist/chunk-U6AXKGYQ.js.map +1 -0
- package/dist/chunk-VH6FWDWI.js +3 -0
- package/dist/chunk-VH6FWDWI.js.map +1 -0
- package/dist/chunk-XJTJPBJB.js +191 -0
- package/dist/chunk-XJTJPBJB.js.map +1 -0
- package/dist/chunk-Z4PA6C2Z.js +3 -0
- package/dist/chunk-Z4PA6C2Z.js.map +1 -0
- package/dist/client-CqE2dF9A.d.ts +86 -0
- package/dist/consent/index.d.ts +59 -0
- package/dist/consent/index.js +7 -0
- package/dist/consent/index.js.map +1 -0
- package/dist/controller-BQb62D0N.d.ts +177 -0
- package/dist/dynamic/index.d.ts +235 -0
- package/dist/dynamic/index.js +6 -0
- package/dist/dynamic/index.js.map +1 -0
- package/dist/errors-vJkye4a0.d.ts +110 -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-Dqfa890U.d.ts +83 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -0
- package/dist/model-ESLSEbi0.d.ts +640 -0
- package/dist/model-mnjAEtKe.d.ts +253 -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/render-DC7P2BGQ.js +5 -0
- package/dist/render-DC7P2BGQ.js.map +1 -0
- package/dist/schema-BrXb9gnh.d.ts +267 -0
- package/dist/signup-client-BL5DfarJ.d.ts +392 -0
- package/dist/spec/index.d.ts +17 -0
- package/dist/spec/index.js +5 -0
- package/dist/spec/index.js.map +1 -0
- package/dist/submit/index.d.ts +42 -0
- package/dist/submit/index.js +6 -0
- package/dist/submit/index.js.map +1 -0
- package/dist/viewer/index.d.ts +4 -0
- package/dist/viewer/index.js +5 -0
- package/dist/viewer/index.js.map +1 -0
- package/dist/widget/index.d.ts +262 -0
- package/dist/widget/index.js +12 -0
- package/dist/widget/index.js.map +1 -0
- package/package.json +96 -6
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
import { T as TerminalStage } from './model-ESLSEbi0.js';
|
|
3
|
+
import { e as ConsentSubmitDocument } from './controller-BQb62D0N.js';
|
|
4
|
+
import { C as ContactFormValues } from './schema-BrXb9gnh.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Submit client for POST /api/v1/public/onboarding/leads.
|
|
8
|
+
*
|
|
9
|
+
* Contract per D540 + hub REST interface 8686dd33:
|
|
10
|
+
* - Idempotency-Key header REQUIRED (uuid v4, generated ONCE per logical
|
|
11
|
+
* submission, REUSED on retries — same key = exactly-once delivery).
|
|
12
|
+
* - Outgoing payload validated through leadsWireSchema (STRICT — unknown
|
|
13
|
+
* keys rejected, matching additionalProperties:false) BEFORE any fetch.
|
|
14
|
+
* - botToken in request body (D537).
|
|
15
|
+
* - Response: { accepted: true } on 200/202 (empty/non-JSON 2xx body is
|
|
16
|
+
* treated as acceptance; a JSON body that does not confirm acceptance
|
|
17
|
+
* throws OnboardingServerError — see parseSuccessBody).
|
|
18
|
+
* - 403 bot_challenge_failed → throw OnboardingBotChallengeError (no retry)
|
|
19
|
+
* - 409 spec_stale (D540) → throw OnboardingSpecStaleError (no retry)
|
|
20
|
+
* - 422 → throw OnboardingValidationError (no retry)
|
|
21
|
+
* - 429 → throw OnboardingRateLimitError (no auto-retry)
|
|
22
|
+
* - 5xx → retry with SAME idempotency key, capped backoff
|
|
23
|
+
* - network error → retry with SAME idempotency key, capped backoff
|
|
24
|
+
*
|
|
25
|
+
* Max retries: 3 attempts total (1 initial + 2 retries).
|
|
26
|
+
* Backoff: 1s, 2s (capped at 2 retries).
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A bot token, or a provider that mints a FRESH one per attempt.
|
|
31
|
+
*
|
|
32
|
+
* reCAPTCHA tokens are SINGLE-USE — the server consumes them at siteverify.
|
|
33
|
+
* If a 5xx happens AFTER the token was consumed, resending the same token on
|
|
34
|
+
* retry gets 403. Pass a provider function to mint a fresh token per attempt;
|
|
35
|
+
* a bare string is back-compat but the caller then OWNS that risk.
|
|
36
|
+
*/
|
|
37
|
+
type BotTokenSource = string | (() => string | Promise<string>);
|
|
38
|
+
declare function resolveBotToken(source: BotTokenSource): Promise<string>;
|
|
39
|
+
interface LeadsSubmitOptions {
|
|
40
|
+
baseUrl: string;
|
|
41
|
+
/**
|
|
42
|
+
* reCAPTCHA token (D537), or a provider called ONCE PER ATTEMPT to mint a
|
|
43
|
+
* fresh token (recommended — tokens are single-use; a fixed string on a
|
|
44
|
+
* retried request risks 403 after the first attempt consumed it).
|
|
45
|
+
*/
|
|
46
|
+
botToken?: BotTokenSource;
|
|
47
|
+
/**
|
|
48
|
+
* Stable idempotency key for this submission. Generate ONCE with
|
|
49
|
+
* `generateIdempotencyKey()` and pass the same key for retries.
|
|
50
|
+
* The server chains this key through to D538 for exactly-once delivery.
|
|
51
|
+
*/
|
|
52
|
+
idempotencyKey: string;
|
|
53
|
+
/** Optional custom fetch implementation (defaults to global fetch). */
|
|
54
|
+
fetch?: typeof globalThis.fetch;
|
|
55
|
+
/**
|
|
56
|
+
* Per-attempt request timeout in ms (default 15s). A stalled intake aborts
|
|
57
|
+
* with OnboardingNetworkError so the widget re-enables instead of hanging.
|
|
58
|
+
*/
|
|
59
|
+
timeoutMs?: number;
|
|
60
|
+
/** Optional onAttempt callback for observability (attempt number, 1-based). */
|
|
61
|
+
onAttempt?: (attempt: number) => void;
|
|
62
|
+
}
|
|
63
|
+
interface LeadsSubmitResult {
|
|
64
|
+
accepted: true;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generate a stable idempotency key for one logical submission.
|
|
68
|
+
* Uses the Web Crypto API (available in all modern browsers + Bun/Node >= 19).
|
|
69
|
+
* Call ONCE per user submission, pass the SAME key on retries.
|
|
70
|
+
*/
|
|
71
|
+
declare function generateIdempotencyKey(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Compute a stable fingerprint of the outgoing lead payload, EXCLUDING
|
|
74
|
+
* botToken (which is fresh per attempt by design).
|
|
75
|
+
*
|
|
76
|
+
* The widget uses this to decide whether a resubmission is a RETRY of the
|
|
77
|
+
* same logical submission (same fingerprint → reuse the Idempotency-Key)
|
|
78
|
+
* or a NEW logical submission (fingerprint changed because the user edited
|
|
79
|
+
* fields → mint a NEW key). This mirrors the server's D538 payload-match
|
|
80
|
+
* guard: same key + different payload is INVALID_ARGUMENT server-side.
|
|
81
|
+
*
|
|
82
|
+
* FNV-1a 32-bit over a stable JSON serialization of [name, email, phone,
|
|
83
|
+
* message]. Collision risk is irrelevant here — a collision only means an
|
|
84
|
+
* unnecessary key reuse across two submissions from the same browser tab.
|
|
85
|
+
*/
|
|
86
|
+
declare function computePayloadFingerprint(values: ContactFormValues): string;
|
|
87
|
+
/**
|
|
88
|
+
* Submit a contact-form lead to the onboarding intake.
|
|
89
|
+
*
|
|
90
|
+
* The outgoing payload is validated through leadsWireSchema in STRICT mode
|
|
91
|
+
* before any network I/O — unknown keys are rejected client-side, exactly
|
|
92
|
+
* mirroring the server's additionalProperties:false.
|
|
93
|
+
*
|
|
94
|
+
* Handles retry semantics: 5xx and network errors are retried up to
|
|
95
|
+
* MAX_ATTEMPTS total, always with the SAME idempotencyKey to guarantee
|
|
96
|
+
* exactly-once server-side processing (D538 idempotency chain).
|
|
97
|
+
*
|
|
98
|
+
* 403, 409, 422 and 429 are NOT retried — caller handles them.
|
|
99
|
+
*
|
|
100
|
+
* @throws {OnboardingValidationError} if the payload fails the strict wire
|
|
101
|
+
* schema (unknown keys, constraint violations) — thrown BEFORE any fetch
|
|
102
|
+
* @throws {OnboardingBotChallengeError} on 403, or if the bot-token provider
|
|
103
|
+
* throws (reCAPTCHA unreachable) on any attempt
|
|
104
|
+
* @throws {OnboardingConflictError} on 409 (leads has no spec_stale concept)
|
|
105
|
+
* @throws {OnboardingRateLimitError} on 429
|
|
106
|
+
* @throws {OnboardingServerError} on 5xx after all retries exhausted, or on
|
|
107
|
+
* a 2xx whose JSON body does not confirm acceptance
|
|
108
|
+
* @throws {OnboardingNetworkError} on network failure OR timeout after all
|
|
109
|
+
* retries exhausted
|
|
110
|
+
* @throws {OnboardingValidationError} on 422 (server-side re-validation)
|
|
111
|
+
*/
|
|
112
|
+
declare function submitLead(values: ContactFormValues, options: LeadsSubmitOptions): Promise<LeadsSubmitResult>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Submit client for POST /api/v1/public/onboarding/submit (D540 §2).
|
|
116
|
+
*
|
|
117
|
+
* Contract per the LOCKED hub REST interface (PublicOnboardingSubmitRequest):
|
|
118
|
+
* - Body: { specVersion, answers, selectedServices?, botToken,
|
|
119
|
+
* consent:{tosAccepted:true, privacyAccepted:true},
|
|
120
|
+
* credentials:{email, displayName?}, organisationName?, subdomain }
|
|
121
|
+
* additionalProperties: false — validated STRICTLY client-side before
|
|
122
|
+
* any fetch (unknown keys are rejected, not stripped).
|
|
123
|
+
* - Idempotency-Key header REQUIRED (same D538 discipline as leads:
|
|
124
|
+
* stable across retries of the SAME payload; the widget mints a new
|
|
125
|
+
* key when the payload fingerprint changes).
|
|
126
|
+
* - specVersion policy is reject-stale: 409 → OnboardingSpecStaleError
|
|
127
|
+
* carrying the server's current version. The CALLER refetches the spec
|
|
128
|
+
* and surfaces re-validation to the user — NEVER silent auto-resubmit.
|
|
129
|
+
* - Response: { accepted:true, terminalStage, verificationEmailSent? }.
|
|
130
|
+
*
|
|
131
|
+
* Success-body rule for /submit (DIFFERENT from /leads, deliberately):
|
|
132
|
+
* the response carries REQUIRED routing data (terminalStage decides what
|
|
133
|
+
* the UI shows next), so a 2xx with an empty/unparseable/garbage body is
|
|
134
|
+
* an OnboardingServerError — the SDK will not fabricate a terminal stage.
|
|
135
|
+
* (/leads tolerates body-less 2xx because its only signal IS the status.)
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* STRICT wire schema for ONE element of the D543 §4 consent.documents array.
|
|
140
|
+
* `accepted` is const-true (an unaccepted doc is never sent — the consent
|
|
141
|
+
* controller omits it), and `evidence` carries only the gate-relevant flags.
|
|
142
|
+
*/
|
|
143
|
+
declare const consentSubmitDocumentSchema: z.ZodObject<{
|
|
144
|
+
legalDocumentId: z.ZodString;
|
|
145
|
+
versionNo: z.ZodNumber;
|
|
146
|
+
accepted: z.ZodLiteral<true>;
|
|
147
|
+
evidence: z.ZodObject<{
|
|
148
|
+
scrolled_to_end: z.ZodOptional<z.ZodBoolean>;
|
|
149
|
+
opened: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
+
}, "strict", z.ZodTypeAny, {
|
|
151
|
+
opened?: boolean | undefined;
|
|
152
|
+
scrolled_to_end?: boolean | undefined;
|
|
153
|
+
}, {
|
|
154
|
+
opened?: boolean | undefined;
|
|
155
|
+
scrolled_to_end?: boolean | undefined;
|
|
156
|
+
}>;
|
|
157
|
+
}, "strict", z.ZodTypeAny, {
|
|
158
|
+
legalDocumentId: string;
|
|
159
|
+
versionNo: number;
|
|
160
|
+
accepted: true;
|
|
161
|
+
evidence: {
|
|
162
|
+
opened?: boolean | undefined;
|
|
163
|
+
scrolled_to_end?: boolean | undefined;
|
|
164
|
+
};
|
|
165
|
+
}, {
|
|
166
|
+
legalDocumentId: string;
|
|
167
|
+
versionNo: number;
|
|
168
|
+
accepted: true;
|
|
169
|
+
evidence: {
|
|
170
|
+
opened?: boolean | undefined;
|
|
171
|
+
scrolled_to_end?: boolean | undefined;
|
|
172
|
+
};
|
|
173
|
+
}>;
|
|
174
|
+
/**
|
|
175
|
+
* STRICT wire schema — mirrors PublicOnboardingSubmitRequest exactly
|
|
176
|
+
* (additionalProperties: false; consent booleans are const-true; passwordless
|
|
177
|
+
* per D1010, with the workspace subdomain required by D836).
|
|
178
|
+
*
|
|
179
|
+
* D543 §4: `consent` extends from booleans to a per-document array. The
|
|
180
|
+
* `documents` array is AUTHORITATIVE (the server re-validates it); the
|
|
181
|
+
* `tosAccepted`/`privacyAccepted` booleans are kept as a DERIVED convenience
|
|
182
|
+
* (D543 "kept as a derived convenience only"). `documents` is OPTIONAL on the
|
|
183
|
+
* wire for backward-compat — a pre-ConsentPack onboarder serves no consentPack
|
|
184
|
+
* and submits the booleans alone (D543 "pre-ConsentPack submits still parse").
|
|
185
|
+
*/
|
|
186
|
+
declare const signupWireSchema: z.ZodObject<{
|
|
187
|
+
specVersion: z.ZodString;
|
|
188
|
+
answers: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
189
|
+
selectedServices: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
190
|
+
botToken: z.ZodOptional<z.ZodString>;
|
|
191
|
+
consent: z.ZodObject<{
|
|
192
|
+
tosAccepted: z.ZodLiteral<true>;
|
|
193
|
+
privacyAccepted: z.ZodLiteral<true>;
|
|
194
|
+
documents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
195
|
+
legalDocumentId: z.ZodString;
|
|
196
|
+
versionNo: z.ZodNumber;
|
|
197
|
+
accepted: z.ZodLiteral<true>;
|
|
198
|
+
evidence: z.ZodObject<{
|
|
199
|
+
scrolled_to_end: z.ZodOptional<z.ZodBoolean>;
|
|
200
|
+
opened: z.ZodOptional<z.ZodBoolean>;
|
|
201
|
+
}, "strict", z.ZodTypeAny, {
|
|
202
|
+
opened?: boolean | undefined;
|
|
203
|
+
scrolled_to_end?: boolean | undefined;
|
|
204
|
+
}, {
|
|
205
|
+
opened?: boolean | undefined;
|
|
206
|
+
scrolled_to_end?: boolean | undefined;
|
|
207
|
+
}>;
|
|
208
|
+
}, "strict", z.ZodTypeAny, {
|
|
209
|
+
legalDocumentId: string;
|
|
210
|
+
versionNo: number;
|
|
211
|
+
accepted: true;
|
|
212
|
+
evidence: {
|
|
213
|
+
opened?: boolean | undefined;
|
|
214
|
+
scrolled_to_end?: boolean | undefined;
|
|
215
|
+
};
|
|
216
|
+
}, {
|
|
217
|
+
legalDocumentId: string;
|
|
218
|
+
versionNo: number;
|
|
219
|
+
accepted: true;
|
|
220
|
+
evidence: {
|
|
221
|
+
opened?: boolean | undefined;
|
|
222
|
+
scrolled_to_end?: boolean | undefined;
|
|
223
|
+
};
|
|
224
|
+
}>, "many">>;
|
|
225
|
+
}, "strict", z.ZodTypeAny, {
|
|
226
|
+
tosAccepted: true;
|
|
227
|
+
privacyAccepted: true;
|
|
228
|
+
documents?: {
|
|
229
|
+
legalDocumentId: string;
|
|
230
|
+
versionNo: number;
|
|
231
|
+
accepted: true;
|
|
232
|
+
evidence: {
|
|
233
|
+
opened?: boolean | undefined;
|
|
234
|
+
scrolled_to_end?: boolean | undefined;
|
|
235
|
+
};
|
|
236
|
+
}[] | undefined;
|
|
237
|
+
}, {
|
|
238
|
+
tosAccepted: true;
|
|
239
|
+
privacyAccepted: true;
|
|
240
|
+
documents?: {
|
|
241
|
+
legalDocumentId: string;
|
|
242
|
+
versionNo: number;
|
|
243
|
+
accepted: true;
|
|
244
|
+
evidence: {
|
|
245
|
+
opened?: boolean | undefined;
|
|
246
|
+
scrolled_to_end?: boolean | undefined;
|
|
247
|
+
};
|
|
248
|
+
}[] | undefined;
|
|
249
|
+
}>;
|
|
250
|
+
credentials: z.ZodObject<{
|
|
251
|
+
email: z.ZodString;
|
|
252
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
253
|
+
}, "strict", z.ZodTypeAny, {
|
|
254
|
+
email: string;
|
|
255
|
+
displayName?: string | undefined;
|
|
256
|
+
}, {
|
|
257
|
+
email: string;
|
|
258
|
+
displayName?: string | undefined;
|
|
259
|
+
}>;
|
|
260
|
+
organisationName: z.ZodOptional<z.ZodString>;
|
|
261
|
+
subdomain: z.ZodString;
|
|
262
|
+
}, "strict", z.ZodTypeAny, {
|
|
263
|
+
specVersion: string;
|
|
264
|
+
credentials: {
|
|
265
|
+
email: string;
|
|
266
|
+
displayName?: string | undefined;
|
|
267
|
+
};
|
|
268
|
+
subdomain: string;
|
|
269
|
+
answers: Record<string, unknown>;
|
|
270
|
+
consent: {
|
|
271
|
+
tosAccepted: true;
|
|
272
|
+
privacyAccepted: true;
|
|
273
|
+
documents?: {
|
|
274
|
+
legalDocumentId: string;
|
|
275
|
+
versionNo: number;
|
|
276
|
+
accepted: true;
|
|
277
|
+
evidence: {
|
|
278
|
+
opened?: boolean | undefined;
|
|
279
|
+
scrolled_to_end?: boolean | undefined;
|
|
280
|
+
};
|
|
281
|
+
}[] | undefined;
|
|
282
|
+
};
|
|
283
|
+
botToken?: string | undefined;
|
|
284
|
+
organisationName?: string | undefined;
|
|
285
|
+
selectedServices?: string[] | undefined;
|
|
286
|
+
}, {
|
|
287
|
+
specVersion: string;
|
|
288
|
+
credentials: {
|
|
289
|
+
email: string;
|
|
290
|
+
displayName?: string | undefined;
|
|
291
|
+
};
|
|
292
|
+
subdomain: string;
|
|
293
|
+
answers: Record<string, unknown>;
|
|
294
|
+
consent: {
|
|
295
|
+
tosAccepted: true;
|
|
296
|
+
privacyAccepted: true;
|
|
297
|
+
documents?: {
|
|
298
|
+
legalDocumentId: string;
|
|
299
|
+
versionNo: number;
|
|
300
|
+
accepted: true;
|
|
301
|
+
evidence: {
|
|
302
|
+
opened?: boolean | undefined;
|
|
303
|
+
scrolled_to_end?: boolean | undefined;
|
|
304
|
+
};
|
|
305
|
+
}[] | undefined;
|
|
306
|
+
};
|
|
307
|
+
botToken?: string | undefined;
|
|
308
|
+
organisationName?: string | undefined;
|
|
309
|
+
selectedServices?: string[] | undefined;
|
|
310
|
+
}>;
|
|
311
|
+
type SignupWirePayload = z.infer<typeof signupWireSchema>;
|
|
312
|
+
/** The payload the caller assembles (botToken attached by the transport). */
|
|
313
|
+
interface SignupSubmitBody {
|
|
314
|
+
specVersion: string;
|
|
315
|
+
answers: Record<string, unknown>;
|
|
316
|
+
selectedServices?: string[];
|
|
317
|
+
/**
|
|
318
|
+
* D543 §4 consent. `documents` (the per-doc array) is authoritative when
|
|
319
|
+
* present; the booleans are the derived convenience. `documents` is omitted
|
|
320
|
+
* for a pre-ConsentPack onboarder (backward-compat).
|
|
321
|
+
*/
|
|
322
|
+
consent: {
|
|
323
|
+
tosAccepted: true;
|
|
324
|
+
privacyAccepted: true;
|
|
325
|
+
documents?: ConsentSubmitDocument[];
|
|
326
|
+
};
|
|
327
|
+
credentials: {
|
|
328
|
+
email: string;
|
|
329
|
+
displayName?: string;
|
|
330
|
+
};
|
|
331
|
+
organisationName?: string;
|
|
332
|
+
subdomain: string;
|
|
333
|
+
}
|
|
334
|
+
interface SignupSubmitOptions {
|
|
335
|
+
baseUrl: string;
|
|
336
|
+
/**
|
|
337
|
+
* reCAPTCHA token (D537), or a provider called ONCE PER ATTEMPT to mint a
|
|
338
|
+
* fresh token. Tokens are single-use (consumed at siteverify), so a fixed
|
|
339
|
+
* string on a retried request risks 403 after the first attempt consumed
|
|
340
|
+
* it — pass a provider for retry-safe recovery.
|
|
341
|
+
*/
|
|
342
|
+
botToken?: BotTokenSource;
|
|
343
|
+
/** Stable idempotency key — same discipline as submitLead. */
|
|
344
|
+
idempotencyKey: string;
|
|
345
|
+
fetch?: typeof globalThis.fetch;
|
|
346
|
+
/**
|
|
347
|
+
* Per-attempt request timeout in ms (default 15s). A stalled intake aborts
|
|
348
|
+
* with OnboardingNetworkError so the widget re-enables instead of hanging.
|
|
349
|
+
*/
|
|
350
|
+
timeoutMs?: number;
|
|
351
|
+
onAttempt?: (attempt: number) => void;
|
|
352
|
+
}
|
|
353
|
+
interface SignupSubmitResult {
|
|
354
|
+
accepted: true;
|
|
355
|
+
/** Stage the existing engine landed the applicant at (D540 §2). */
|
|
356
|
+
terminalStage: TerminalStage;
|
|
357
|
+
verificationEmailSent?: boolean;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Stable fingerprint of a signup submission, EXCLUDING botToken (fresh per
|
|
361
|
+
* attempt by design). Same role as computePayloadFingerprint for leads:
|
|
362
|
+
* same fingerprint ⇒ retry (reuse the Idempotency-Key); changed
|
|
363
|
+
* fingerprint ⇒ new logical submission (mint a new key) — mirroring the
|
|
364
|
+
* server's D538 payload-match guard.
|
|
365
|
+
*/
|
|
366
|
+
declare function computeSignupFingerprint(body: SignupSubmitBody): string;
|
|
367
|
+
/**
|
|
368
|
+
* Submit a full signup to the onboarding intake.
|
|
369
|
+
*
|
|
370
|
+
* @throws {OnboardingValidationError} strict wire-schema failure — BEFORE any fetch
|
|
371
|
+
* @throws {OnboardingBotChallengeError} on 403, or if the bot-token provider
|
|
372
|
+
* throws (reCAPTCHA unreachable) on any attempt
|
|
373
|
+
* @throws {OnboardingSpecStaleError} on 409 with code:"spec_stale" (caller
|
|
374
|
+
* refetches spec); carries the server's currentSpecVersion
|
|
375
|
+
* @throws {OnboardingConsentStaleError} on 409 with code:"consent_stale"
|
|
376
|
+
* (D543 §4 — a required legal doc changed; caller refetches spec + requires
|
|
377
|
+
* re-acceptance of the changed docs, NEVER auto-accepts); carries
|
|
378
|
+
* staleDocuments
|
|
379
|
+
* @throws {OnboardingConsentIncompleteError} on 400 with
|
|
380
|
+
* code:"consent_incomplete" (D543 §4 — server found a required doc missing/
|
|
381
|
+
* unaccepted/evidence-insufficient)
|
|
382
|
+
* @throws {OnboardingConflictError} on a 409 that is NOT spec_stale/consent_stale
|
|
383
|
+
* @throws {OnboardingRateLimitError} on 429
|
|
384
|
+
* @throws {OnboardingValidationError} on 422 (server re-validation) or a
|
|
385
|
+
* generic 400 that is NOT consent_incomplete
|
|
386
|
+
* @throws {OnboardingServerError} on 5xx after retries, or a 2xx without
|
|
387
|
+
* the required {accepted:true, terminalStage} body
|
|
388
|
+
* @throws {OnboardingNetworkError} on network failure OR timeout after retries
|
|
389
|
+
*/
|
|
390
|
+
declare function submitSignup(body: SignupSubmitBody, options: SignupSubmitOptions): Promise<SignupSubmitResult>;
|
|
391
|
+
|
|
392
|
+
export { type BotTokenSource as B, type LeadsSubmitOptions as L, type SignupSubmitBody as S, type LeadsSubmitResult as a, type SignupSubmitOptions as b, type SignupSubmitResult as c, type SignupWirePayload as d, computePayloadFingerprint as e, computeSignupFingerprint as f, consentSubmitDocumentSchema as g, generateIdempotencyKey as h, submitLead as i, submitSignup as j, resolveBotToken as r, signupWireSchema as s };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { F as FIELD_KEY_PATTERN, O as OnboarderTier, a as OnboardingSpec, P as PiiClass, S as SpecField, b as SpecStage, c as SpecStep, T as TerminalStage, o as onboardingSpecSchema, s as specFieldSchema, d as specStepSchema, v as validateOnboardingSpec } from '../model-ESLSEbi0.js';
|
|
2
|
+
export { A as ACCEPTANCE_LEVELS, a as AcceptanceLevel, C as ConsentDocType, b as ConsentDocument, c as ConsentPack, D as DOC_TYPES, d as acceptanceLevelSchema, e as consentDocKey, f as consentDocumentSchema, g as consentPackSchema } from '../model-mnjAEtKe.js';
|
|
3
|
+
export { O as OnboardingSpecCache, S as SpecFetchOptions, a as SpecFieldDiff, d as defaultSpecCache, b as diffSpecFields, f as fetchOnboardingSpec } from '../client-CqE2dF9A.js';
|
|
4
|
+
import 'zod/v3';
|
|
5
|
+
|
|
6
|
+
interface PinStateResult {
|
|
7
|
+
pin: string;
|
|
8
|
+
stateIso: string | null;
|
|
9
|
+
}
|
|
10
|
+
declare function fetchPinState(options: {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
pin: string;
|
|
13
|
+
fetch?: typeof globalThis.fetch;
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
}): Promise<PinStateResult>;
|
|
16
|
+
|
|
17
|
+
export { type PinStateResult, fetchPinState };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FIELD_KEY_PATTERN, OnboardingSpecCache, defaultSpecCache, diffSpecFields, fetchOnboardingSpec, fetchPinState, onboardingSpecSchema, specFieldSchema, specStepSchema, validateOnboardingSpec } from '../chunk-F75ZJERM.js';
|
|
2
|
+
export { ACCEPTANCE_LEVELS, DOC_TYPES, acceptanceLevelSchema, consentDocKey, consentDocumentSchema, consentPackSchema } from '../chunk-U56GQITG.js';
|
|
3
|
+
import '../chunk-XJTJPBJB.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export { B as BotTokenSource, L as LeadsSubmitOptions, a as LeadsSubmitResult, S as SignupSubmitBody, b as SignupSubmitOptions, c as SignupSubmitResult, d as SignupWirePayload, e as computePayloadFingerprint, f as computeSignupFingerprint, g as consentSubmitDocumentSchema, h as generateIdempotencyKey, r as resolveBotToken, s as signupWireSchema, i as submitLead, j as submitSignup } from '../signup-client-BL5DfarJ.js';
|
|
2
|
+
export { O as OnboardingBotChallengeError, a as OnboardingConflictError, b as OnboardingConsentIncompleteError, c as OnboardingConsentStaleError, d as OnboardingError, e as OnboardingErrorKind, f as OnboardingNetworkError, g as OnboardingRateLimitError, h as OnboardingServerError, i as OnboardingSpecInvalidError, j as OnboardingSpecStaleError, k as OnboardingSubdomainTakenError, l as OnboardingValidationError, S as StaleConsentDocument } from '../errors-vJkye4a0.js';
|
|
3
|
+
import 'zod/v3';
|
|
4
|
+
import '../model-ESLSEbi0.js';
|
|
5
|
+
import '../controller-BQb62D0N.js';
|
|
6
|
+
import '../model-mnjAEtKe.js';
|
|
7
|
+
import '../schema-BrXb9gnh.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Shared HTTP helper: fetch bounded by a timeout via AbortController.
|
|
11
|
+
*
|
|
12
|
+
* Every SDK wire call (spec fetch, leads submit, signup submit) MUST be
|
|
13
|
+
* bounded — the widgets flip to a disabled/"Sending…"/"Loading…" state
|
|
14
|
+
* BEFORE the await, so an intake that accepts the connection and then stalls
|
|
15
|
+
* would otherwise hang the UI forever. On timeout the fetch is aborted and a
|
|
16
|
+
* typed OnboardingNetworkError is raised by the caller (which maps abort/
|
|
17
|
+
* network failures uniformly).
|
|
18
|
+
*/
|
|
19
|
+
/** Default per-request timeout. Generous enough for a slow-but-alive intake. */
|
|
20
|
+
declare const DEFAULT_REQUEST_TIMEOUT_MS = 15000;
|
|
21
|
+
interface TimeoutFetchOptions extends RequestInit {
|
|
22
|
+
/** Per-request timeout in ms. Default DEFAULT_REQUEST_TIMEOUT_MS. */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
/** The fetch implementation to use (defaults to globalThis.fetch). */
|
|
25
|
+
fetchImpl?: typeof globalThis.fetch;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* fetch() with a hard timeout. Aborts the request when the deadline elapses;
|
|
29
|
+
* the resulting AbortError propagates to the caller (who wraps it as an
|
|
30
|
+
* OnboardingNetworkError). A caller-supplied `signal` is respected too — if
|
|
31
|
+
* either the caller aborts OR the timeout fires, the request is aborted.
|
|
32
|
+
*/
|
|
33
|
+
declare function fetchWithTimeout(url: string, options?: TimeoutFetchOptions): Promise<Response>;
|
|
34
|
+
/**
|
|
35
|
+
* Run a promise with a timeout. On timeout, rejects with `onTimeout()`'s
|
|
36
|
+
* error. Used to bound calls that don't take an AbortSignal (grecaptcha
|
|
37
|
+
* .execute()). The underlying op is NOT cancelled (grecaptcha has no abort),
|
|
38
|
+
* but the caller no longer waits on it — the widget re-enables.
|
|
39
|
+
*/
|
|
40
|
+
declare function withTimeout<T>(op: Promise<T>, timeoutMs: number, onTimeout: () => Error): Promise<T>;
|
|
41
|
+
|
|
42
|
+
export { DEFAULT_REQUEST_TIMEOUT_MS, fetchWithTimeout, withTimeout };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '../chunk-Z4PA6C2Z.js';
|
|
2
|
+
export { computePayloadFingerprint, computeSignupFingerprint, consentSubmitDocumentSchema, generateIdempotencyKey, resolveBotToken, signupWireSchema, submitLead, submitSignup } from '../chunk-BMQINH6O.js';
|
|
3
|
+
import '../chunk-SIMLMQPT.js';
|
|
4
|
+
export { DEFAULT_REQUEST_TIMEOUT_MS, OnboardingBotChallengeError, OnboardingConflictError, OnboardingConsentIncompleteError, OnboardingConsentStaleError, OnboardingError, OnboardingNetworkError, OnboardingRateLimitError, OnboardingServerError, OnboardingSpecInvalidError, OnboardingSpecStaleError, OnboardingSubdomainTakenError, OnboardingValidationError, fetchWithTimeout, withTimeout } from '../chunk-XJTJPBJB.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|