@overturo/js 0.0.0-stage → 1.5.2

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.
@@ -0,0 +1,1366 @@
1
+ interface ApiClientOptions {
2
+ baseUrl: string;
3
+ publishableKey: string;
4
+ apiKey?: string;
5
+ /** Request timeout in milliseconds. 0 disables timeout. */
6
+ timeout?: number;
7
+ }
8
+ /**
9
+ * Fetch-based HTTP client with automatic case conversion, timeout, and error handling.
10
+ */
11
+ declare class ApiClient {
12
+ private baseUrl;
13
+ private publishableKey;
14
+ private apiKey?;
15
+ private timeout;
16
+ constructor(options: ApiClientOptions);
17
+ get<T>(path: string): Promise<T>;
18
+ post<T>(path: string, body?: Record<string, unknown>): Promise<T>;
19
+ /**
20
+ * GET that returns the raw Response object without JSON parsing, case
21
+ * conversion or error throwing. Used where part of the body must stay
22
+ * verbatim (keys that are data, such as purpose names).
23
+ */
24
+ rawGet(path: string): Promise<Response>;
25
+ /**
26
+ * POST that returns the raw Response object without JSON parsing or error throwing.
27
+ * Used by exchange() to handle HTTP 202 (fulfillment pending) with retry logic.
28
+ */
29
+ rawPost(path: string, body: Record<string, unknown>): Promise<Response>;
30
+ private rawRequest;
31
+ private request;
32
+ }
33
+
34
+ /** Configuration options for the Overturo client. */
35
+ interface OverturoOptions {
36
+ /** Publishable key for client-side authentication (pk_live_... or pk_test_...). */
37
+ publishableKey: string;
38
+ /** API key for server-side operations (sk_live_... or sk_test_...). */
39
+ apiKey?: string;
40
+ /** Base URL of the Overturo API. Defaults to https://overturo.com. */
41
+ baseUrl?: string;
42
+ /**
43
+ * Base URL of the host that serves consent flows + iframes (the
44
+ * "trust" host). Defaults to `baseUrl` — production runs API and
45
+ * flow on the same origin (`overturo.com`), so most integrations
46
+ * leave this unset. Set it when the flow is served from a separate
47
+ * host (e.g. `https://trust.overturo.com`, or `http://trust.lvh.me:5100`
48
+ * in dev).
49
+ *
50
+ * Affects: `embed()`, `popup()`, `redirect()`, and the `accordSetup*`
51
+ * variants. Does NOT affect API calls — those always go through
52
+ * `baseUrl`.
53
+ */
54
+ flowBaseUrl?: string;
55
+ /** Request timeout in milliseconds. Defaults to 30000 (30s). Set to 0 to disable. */
56
+ timeout?: number;
57
+ /**
58
+ * opt-in structured `console.debug` output prefixed with
59
+ * `[overturo:sdk]`. Never logs session tokens, publishable keys, or raw
60
+ * envelope payloads. Default false.
61
+ */
62
+ debug?: boolean;
63
+ }
64
+ /** Parameters for creating a new consent session. */
65
+ interface CreateSessionParams {
66
+ /** The flow ID to initiate (flw_...). */
67
+ flowId: string;
68
+ /** Delivery mode for the consent flow. */
69
+ deliveryMode?: "embed" | "popup" | "redirect";
70
+ /** Origin of the embedding page (auto-detected in browser). */
71
+ embedOrigin?: string;
72
+ /** URI to redirect after consent (for redirect mode). */
73
+ redirectUri?: string;
74
+ /** CSRF protection token. */
75
+ state?: string;
76
+ /** ID token replay protection nonce. */
77
+ nonce?: string;
78
+ /** Requested OAuth scopes (space-separated). */
79
+ scope?: string;
80
+ /** Steps to skip in the flow. */
81
+ skipSteps?: string[];
82
+ }
83
+ /** A created consent session. */
84
+ interface Session {
85
+ /** Session token for subsequent operations. */
86
+ sessionToken: string;
87
+ /** Delivery mode of the session. */
88
+ deliveryMode: string;
89
+ /** When the session expires. */
90
+ expiresAt: string;
91
+ /** URL for embedding the consent flow in an iframe. */
92
+ embedUrl: string;
93
+ }
94
+ /** Status of a consent session. */
95
+ interface SessionStatus {
96
+ /** Session token. */
97
+ sessionToken: string;
98
+ /** Current status of the session. */
99
+ status: string;
100
+ /** Delivery mode. */
101
+ deliveryMode: string;
102
+ /** Current step key. */
103
+ currentStep: string | null;
104
+ /** All steps in the flow. */
105
+ steps: StepInfo[];
106
+ /** When the session expires. */
107
+ expiresAt: string;
108
+ /** When the session was completed, if applicable. */
109
+ completedAt: string | null;
110
+ }
111
+ /** Information about a single step in a flow. */
112
+ interface StepInfo {
113
+ /** Step number (1-based). */
114
+ number: number;
115
+ /** Step key identifier. */
116
+ key: string;
117
+ /** Human-readable step title. */
118
+ title: string;
119
+ }
120
+ /**
121
+ * v2 callback signatures.
122
+ *
123
+ * The host's lifecycle callbacks now receive the kind discriminator and the
124
+ * full payload object so a single SDK can route consent-shaped vs.
125
+ * approval-shaped completions correctly.
126
+ */
127
+ type DecisionKind = "consent" | "approval" | "signature_request";
128
+ /** Payload object carried in v2 envelopes. Per-kind-per-type schemas live in `lib/sdk/overturo-js/schemas/postmessage-v2/`. */
129
+ type DecisionPayload = Record<string, unknown>;
130
+ /** Options for the high-level consent() method. */
131
+ interface ConsentOptions {
132
+ /** The flow ID to initiate (flw_...). */
133
+ flowId: string;
134
+ /** Container element or CSS selector for the iframe. */
135
+ container: string | HTMLElement;
136
+ /** Requested OAuth scopes (space-separated). */
137
+ scope?: string;
138
+ /** CSRF protection token. */
139
+ state?: string;
140
+ /** ID token replay protection nonce. */
141
+ nonce?: string;
142
+ /** Steps to skip in the flow. */
143
+ skipSteps?: string[];
144
+ /** Style overrides for the iframe. */
145
+ style?: EmbedStyle;
146
+ /** Loading placeholder (HTML string or DOM element). */
147
+ loading?: string | HTMLElement;
148
+ /** Called when the flow completes. Receives kind and outcome payload. */
149
+ onComplete?: (kind: DecisionKind, payload: DecisionPayload) => void;
150
+ /** Called when the flow is cancelled. */
151
+ onCancel?: (payload: DecisionPayload) => void;
152
+ /** Called on error. Payload conforms to the per-kind error schema. */
153
+ onError?: (payload: DecisionPayload) => void;
154
+ /** Called when the flow's state transitions (replaces v1 `onStep`). */
155
+ onState?: (kind: DecisionKind, payload: DecisionPayload) => void;
156
+ /** Called on a DEADLINE tick (T-30s/T-15s/T-5s/T-0). */
157
+ onDeadline?: (payload: DecisionPayload) => void;
158
+ /** Called when the iframe content resizes. */
159
+ onResize?: (height: number) => void;
160
+ /** Called when the iframe is ready (carries branding + kind in payload). */
161
+ onReady?: (payload: DecisionPayload) => void;
162
+ }
163
+ /**
164
+ * @deprecated Use the v2 `onComplete(kind, payload)` callback signature.
165
+ * Retained as a type-only export for downstream type checkers.
166
+ */
167
+ interface ConsentResult {
168
+ consentToken: string;
169
+ }
170
+ /** Options for embedding a consent or approval flow in an iframe. */
171
+ interface EmbedOptions {
172
+ /** Session token from createSession(). */
173
+ sessionToken: string;
174
+ /** Container element or CSS selector for the iframe. */
175
+ container: string | HTMLElement;
176
+ /** Style overrides for the iframe. */
177
+ style?: EmbedStyle;
178
+ /** Loading placeholder (HTML string or DOM element). */
179
+ loading?: string | HTMLElement;
180
+ /** Called when the flow completes. Receives kind and outcome payload. */
181
+ onComplete?: (kind: DecisionKind, payload: DecisionPayload) => void;
182
+ /** Called when the flow is cancelled. */
183
+ onCancel?: (payload: DecisionPayload) => void;
184
+ /** Called on error. */
185
+ onError?: (payload: DecisionPayload) => void;
186
+ /** Called on each STATE transition. */
187
+ onState?: (kind: DecisionKind, payload: DecisionPayload) => void;
188
+ /** Called on a DEADLINE tick. */
189
+ onDeadline?: (payload: DecisionPayload) => void;
190
+ /** Called when the iframe content resizes. */
191
+ onResize?: (height: number) => void;
192
+ /** Called when the iframe is ready (READY payload carries branding + kind). */
193
+ onReady?: (payload: DecisionPayload) => void;
194
+ }
195
+ /** Style overrides for the embed iframe. Only whitelisted properties are applied. */
196
+ interface EmbedStyle {
197
+ /** CSS width. Default: "100%". */
198
+ width?: string;
199
+ /** CSS min-height. Default: "400px". */
200
+ minHeight?: string;
201
+ /** CSS max-height. Default: "none". */
202
+ maxHeight?: string;
203
+ /** CSS border. Default: "none". */
204
+ border?: string;
205
+ /** CSS border-radius. Default: "0". */
206
+ borderRadius?: string;
207
+ /** CSS background. Default: "transparent". */
208
+ background?: string;
209
+ }
210
+ /** Handle returned from embed(), used to control or destroy the iframe. */
211
+ interface EmbedHandle {
212
+ /** The iframe element. */
213
+ iframe: HTMLIFrameElement;
214
+ /** Removes the iframe and cleans up event listeners. */
215
+ destroy: () => void;
216
+ }
217
+ /** Options for opening a consent or approval flow in a popup window. */
218
+ interface PopupOptions {
219
+ /** Session token from createSession(). */
220
+ sessionToken: string;
221
+ /** Called when the flow completes. Receives kind and outcome payload. */
222
+ onComplete?: (kind: DecisionKind, payload: DecisionPayload) => void;
223
+ /** Called when the flow is cancelled. */
224
+ onCancel?: (payload: DecisionPayload) => void;
225
+ /** Called on error. */
226
+ onError?: (payload: DecisionPayload) => void;
227
+ /** Popup window width in pixels. Default: 500. */
228
+ width?: number;
229
+ /** Popup window height in pixels. Default: 700. */
230
+ height?: number;
231
+ }
232
+ /** Handle returned from popup(), used to close the popup. */
233
+ interface PopupHandle {
234
+ /** Closes the popup window and cleans up event listeners. */
235
+ close: () => void;
236
+ }
237
+ /** Options for redirect mode (full-page navigation). */
238
+ interface RedirectOptions {
239
+ /** The flow ID to redirect to (flw_...). */
240
+ flowId: string;
241
+ /** URI to redirect back to after consent. */
242
+ redirectUri: string;
243
+ /** CSRF protection token. */
244
+ state?: string;
245
+ /** ID token replay protection nonce. */
246
+ nonce?: string;
247
+ /** Requested OAuth scopes (space-separated). */
248
+ scope?: string;
249
+ }
250
+ /** Parameters for exchanging a consent token. */
251
+ interface ExchangeParams {
252
+ /** Session token from the consent session. */
253
+ sessionToken: string;
254
+ /** Single-use consent token received on completion. */
255
+ consentToken: string;
256
+ }
257
+ /** Result of a consent token exchange. */
258
+ interface ExchangeResult {
259
+ /** Resolved claims from the consent flow. */
260
+ claims: Record<string, unknown>;
261
+ /** Attestation results from third-party connectors. */
262
+ attestations: Attestation[];
263
+ /** Issued verifiable credentials. */
264
+ credentials: Credential[];
265
+ /** Provenance metadata for claims. */
266
+ provenance: Record<string, unknown>;
267
+ /** OAuth access token (if OAuth application configured). */
268
+ accessToken?: string;
269
+ /** Token type (e.g., "Bearer"). */
270
+ tokenType?: string;
271
+ /** Token expiry in seconds. */
272
+ expiresIn?: number;
273
+ /** OIDC ID token. */
274
+ idToken?: string;
275
+ /** OAuth refresh token. */
276
+ refreshToken?: string;
277
+ }
278
+ /** An attestation from a third-party connector. */
279
+ interface Attestation {
280
+ /** The claim type that was attested. */
281
+ claimType: string;
282
+ /** Name of the connector that provided the attestation. */
283
+ connector: string;
284
+ /** Attestation status. */
285
+ status: string;
286
+ /** Provider-specific identifier. */
287
+ providerId: string;
288
+ }
289
+ /** An issued verifiable credential. */
290
+ interface Credential {
291
+ /** Credential ID. */
292
+ id: string;
293
+ /** Type of credential. */
294
+ credentialType: string;
295
+ /** Credential format (e.g., "jwt_vc", "sd_jwt"). */
296
+ format: string;
297
+ /** When the credential was issued. */
298
+ issuedAt: string;
299
+ }
300
+ /** Parameters for creating an accord setup session. */
301
+ interface CreateSetupSessionParams {
302
+ /** Solution key (e.g., "meetings", "venues"). */
303
+ solution?: string;
304
+ /** Vertical key (e.g., "healthcare", "education"). */
305
+ vertical?: string;
306
+ /** Pre-selected archetype. */
307
+ archetype?: string;
308
+ /** Pre-selected template key. */
309
+ templateKey?: string;
310
+ /** Delivery mode. */
311
+ deliveryMode?: "embed" | "popup" | "redirect";
312
+ /** Origin of the embedding page (auto-detected in browser). */
313
+ embedOrigin?: string;
314
+ /** URI to redirect after setup (for redirect mode). */
315
+ redirectUri?: string;
316
+ /** CSRF protection token. */
317
+ state?: string;
318
+ /** Locale for the setup wizard (auto-detected from navigator.language if omitted). */
319
+ locale?: string;
320
+ /** Enterprise constraints. */
321
+ constraints?: SetupConstraints;
322
+ /** Load constraints from a saved preset (overrides inline constraints). */
323
+ presetId?: string;
324
+ }
325
+ /** Enterprise constraints for the setup wizard. */
326
+ interface SetupConstraints {
327
+ /** Allowed archetype values. */
328
+ allowedArchetypes?: string[];
329
+ /** Allowed template keys. */
330
+ allowedTemplates?: string[];
331
+ /** Fields that are locked (user cannot change). */
332
+ locked?: Record<string, unknown>;
333
+ /** Default values for fields (user can override). */
334
+ defaults?: Record<string, unknown>;
335
+ /** Steps to hide from the wizard. */
336
+ hiddenSteps?: string[];
337
+ }
338
+ /** A created setup session. */
339
+ interface SetupSession {
340
+ /** Session token for subsequent operations. */
341
+ sessionToken: string;
342
+ /** Delivery mode of the session. */
343
+ deliveryMode: string;
344
+ /** URL for embedding the setup wizard in an iframe. */
345
+ embedUrl: string;
346
+ /** When the session expires. */
347
+ expiresAt: string;
348
+ }
349
+ /** Options for the accordSetup() embed method. */
350
+ interface AccordSetupOptions {
351
+ /** Solution key (e.g., "meetings", "venues"). */
352
+ solution?: string;
353
+ /** Vertical key (e.g., "healthcare", "education"). */
354
+ vertical?: string;
355
+ /** Surface key (e.g., "consent", "agree", "protect"). */
356
+ surface?: string;
357
+ /** Pre-selected archetype. */
358
+ archetype?: string;
359
+ /** Pre-selected template key. */
360
+ templateKey?: string;
361
+ /** Container element or CSS selector for the iframe. */
362
+ container: string | HTMLElement;
363
+ /** Enterprise constraints. */
364
+ constraints?: SetupConstraints;
365
+ /** Load constraints from a saved preset (overrides inline constraints). */
366
+ presetId?: string;
367
+ /** Style overrides for the iframe. */
368
+ style?: EmbedStyle;
369
+ /** Loading placeholder (HTML string or DOM element). */
370
+ loading?: string | HTMLElement;
371
+ /** Locale for the wizard. */
372
+ locale?: string;
373
+ /** Called when the iframe is ready. */
374
+ onReady?: () => void;
375
+ /** Called when the flow navigates to a new step. */
376
+ onStep?: (step: SetupStep) => void;
377
+ /** Called when the accord is created. */
378
+ onCreated?: (result: AccordSetupResult) => void;
379
+ /** Called when the user cancels. */
380
+ onCancel?: () => void;
381
+ /** Called on error. */
382
+ onError?: (error: string) => void;
383
+ /** Called when the iframe content resizes. */
384
+ onResize?: (height: number) => void;
385
+ }
386
+ /** Step progress information. */
387
+ interface SetupStep {
388
+ /** Step key (e.g., "purposes_and_scopes"). */
389
+ key: string;
390
+ /** 0-based step index. */
391
+ index: number;
392
+ /** Total number of steps. */
393
+ total: number;
394
+ }
395
+ /** Result returned when accord setup completes. */
396
+ interface AccordSetupResult {
397
+ /** The created accord ID. Always present. */
398
+ accordId: string;
399
+ /** Consent flow ID (for consent/protect archetypes). */
400
+ flowId?: string;
401
+ }
402
+ /** Options for opening setup in a popup window. */
403
+ interface AccordSetupPopupOptions {
404
+ /** Solution key. */
405
+ solution?: string;
406
+ /** Pre-selected archetype. */
407
+ archetype?: string;
408
+ /** Pre-selected template key. */
409
+ templateKey?: string;
410
+ /** Enterprise constraints. */
411
+ constraints?: SetupConstraints;
412
+ /** Load constraints from a saved preset. */
413
+ presetId?: string;
414
+ /** Called when the accord is created. */
415
+ onCreated?: (result: AccordSetupResult) => void;
416
+ /** Called when the user cancels. */
417
+ onCancel?: () => void;
418
+ /** Called on error. */
419
+ onError?: (error: string) => void;
420
+ /** Popup window width in pixels. Default: 600. */
421
+ width?: number;
422
+ /** Popup window height in pixels. Default: 800. */
423
+ height?: number;
424
+ }
425
+ /** Options for redirect mode setup. */
426
+ interface AccordSetupRedirectOptions {
427
+ /** Solution key. */
428
+ solution?: string;
429
+ /** Pre-selected archetype. */
430
+ archetype?: string;
431
+ /** Pre-selected template key. */
432
+ templateKey?: string;
433
+ /** URI to redirect back to after setup. */
434
+ redirectUri: string;
435
+ /** CSRF protection token. */
436
+ state?: string;
437
+ /** Enterprise constraints. */
438
+ constraints?: SetupConstraints;
439
+ /** Load constraints from a saved preset. */
440
+ presetId?: string;
441
+ }
442
+ /** Handle returned from accordSetup(), used to control or destroy the iframe. */
443
+ interface SetupHandle {
444
+ /** The iframe element. */
445
+ iframe: HTMLIFrameElement;
446
+ /** Removes the iframe and cleans up event listeners. */
447
+ destroy: () => void;
448
+ }
449
+ /** Handle returned from accordSetupPopup(). */
450
+ interface SetupPopupHandle {
451
+ /** Closes the popup window and cleans up event listeners. */
452
+ close: () => void;
453
+ }
454
+ /** Options for rendering a preview. */
455
+ interface PreviewOptions {
456
+ /** Container element or CSS selector for the preview iframe. */
457
+ container: string | HTMLElement;
458
+ /** Device simulation. Default: "desktop". */
459
+ device?: "mobile" | "tablet" | "desktop";
460
+ /** Theme override. */
461
+ theme?: string;
462
+ /** Locale override. */
463
+ locale?: string;
464
+ /** Style overrides for the iframe. */
465
+ style?: EmbedStyle;
466
+ /** Loading placeholder. */
467
+ loading?: string | HTMLElement;
468
+ }
469
+ /** Options for previewing a template. */
470
+ interface PreviewTemplateOptions extends PreviewOptions {
471
+ /** Template ID to preview. */
472
+ templateId: string;
473
+ }
474
+ /** Options for previewing a setup session. */
475
+ interface PreviewSetupOptions extends PreviewOptions {
476
+ /** Setup session token. */
477
+ sessionToken: string;
478
+ }
479
+ /** Handle returned from preview methods, used to control or destroy the preview. */
480
+ interface PreviewHandle {
481
+ /** The iframe element. */
482
+ iframe: HTMLIFrameElement;
483
+ /** Switch device viewport. */
484
+ setDevice: (device: "mobile" | "tablet" | "desktop") => void;
485
+ /** Switch theme. */
486
+ setTheme: (theme: string) => void;
487
+ /** Destroy the preview and remove the iframe. */
488
+ destroy: () => void;
489
+ }
490
+ /** Delivery mode for a decision. */
491
+ /** `capture` (201) types a session the one-call form capture minted; it is never passed to createSession. */
492
+ type DecisionMode = "embed" | "popup" | "redirect" | "capture";
493
+ interface FormCaptureOptions {
494
+ /** The flow whose purposes the form answers. */
495
+ flowId: string;
496
+ /** The form element or a selector resolving to it. */
497
+ form: HTMLFormElement | string;
498
+ /** purpose key → CSS selector of the consent control (a checkbox or radio). Required unless `field` is given. */
499
+ map?: Record<string, string>;
500
+ /**
501
+ * 202 — the `<overturo-consent-field>` element (or a selector resolving to it) inside the form.
502
+ * The control is Overturo-rendered: presentation is observed by the platform and the receipt
503
+ * says so. Needs the field entry (`@overturo/js/field` / `overturo-field.js`) loaded first.
504
+ */
505
+ field?: HTMLElement | string;
506
+ /** CSS selector of the input that holds the person's email address. */
507
+ subjectField: string;
508
+ /** CSS selector of an input holding your own identifier for the person. */
509
+ externalIdField?: string;
510
+ /** purpose key → selector whose text is replaced by the published wording (the discovery read). */
511
+ wording?: Record<string, string>;
512
+ /**
513
+ * purpose key → selector of the label the person read. Its text is digested
514
+ * (the published algorithm, over the trimmed text) and attested with the capture, so the record
515
+ * says whether your wording matched the published wording. Defaults to `wording`.
516
+ */
517
+ labels?: Record<string, string>;
518
+ /** Browser commit — honoured only when the application enabled it and lists allowed origins. */
519
+ commit?: boolean;
520
+ /** Locale for the published wording. */
521
+ locale?: string;
522
+ /** Name of the hidden input that carries the capture token to your server (default overturo_capture_token). */
523
+ tokenFieldName?: string;
524
+ /** Set false to stop the form from submitting after the capture (you call requestSubmit yourself). */
525
+ submitAfterCapture?: boolean;
526
+ onCaptured?: (result: FormCaptureResult) => void;
527
+ onError?: (error: Error) => void;
528
+ }
529
+ interface FormCaptureResult {
530
+ /** The capture token — hand it to your server with the submission and commit it. */
531
+ token: DecisionToken;
532
+ attestationId: string;
533
+ /** True only for a browser commit. */
534
+ committed: boolean;
535
+ wordingVerdict: string | null;
536
+ recordId: string | null;
537
+ }
538
+ /**
539
+ * Nominal-typed decision token. Server-issued, opaque. The brand
540
+ * prevents bare strings from being passed where a token is expected.
541
+ */
542
+ type DecisionToken = string & {
543
+ readonly __brand: "DecisionToken";
544
+ };
545
+ /** Per-kind outcome envelope returned by the COMPLETE postMessage. */
546
+ type DecisionOutcome = {
547
+ kind: "consent";
548
+ result: "granted" | "declined";
549
+ consentToken?: string;
550
+ purposesGranted?: string[];
551
+ purposesDeclined?: string[];
552
+ } | {
553
+ kind: "approval";
554
+ result: "approved" | "denied" | "countered";
555
+ escalationToken?: string;
556
+ counterProposal?: Record<string, unknown>;
557
+ } | {
558
+ kind: "signature_request";
559
+ result: "signed" | "declined" | "countered";
560
+ assuranceLevel?: "integrity_proof" | "advanced" | "qualified" | null;
561
+ completedAt?: string;
562
+ };
563
+ /** Per-kind input to `decisions.createSession`. */
564
+ type DecisionsCreateSessionInput = {
565
+ kind: "consent";
566
+ subjectRef: string;
567
+ mode?: DecisionMode;
568
+ embedOrigin?: string;
569
+ scope?: string;
570
+ state?: string;
571
+ nonce?: string;
572
+ redirectUri?: string;
573
+ } | {
574
+ kind: "approval";
575
+ subjectRef: string;
576
+ mode?: DecisionMode;
577
+ embedOrigin?: string;
578
+ state?: string;
579
+ redirectUri?: string;
580
+ } | {
581
+ kind: "signature_request";
582
+ subjectRef: string;
583
+ mode?: DecisionMode;
584
+ embedOrigin?: string;
585
+ state?: string;
586
+ redirectUri?: string;
587
+ };
588
+ /**
589
+ * typed view of a signing-kind STATE payload (`signature/state.json`).
590
+ * The base `DecisionPayload` stays an untyped Record; consumers that know the
591
+ * kind is `signature_request` can read state through this shape. Carries
592
+ * assurance + signing progress only — there is no home-country/region field.
593
+ */
594
+ interface SignatureStatePayload {
595
+ from: string | null;
596
+ to: "pending" | "opened" | "in_progress" | "signed" | "declined" | "expired";
597
+ kind_payload: {
598
+ required_assurance_level: "integrity_proof" | "advanced" | "qualified";
599
+ participant_role?: string | null;
600
+ };
601
+ }
602
+ /** Per-kind output from `decisions.createSession`. */
603
+ interface DecisionsSession {
604
+ token: DecisionToken;
605
+ kind: DecisionKind;
606
+ mode: DecisionMode;
607
+ expiresAt: string;
608
+ embedUrl: string;
609
+ }
610
+ /** Input to `decisions.exchange`. */
611
+ interface DecisionsExchangeInput {
612
+ token: DecisionToken;
613
+ exchangeToken: string;
614
+ }
615
+ /** Per-kind exchange result. */
616
+ type DecisionExchange = {
617
+ kind: "consent";
618
+ consentToken: string;
619
+ attestations?: Attestation[];
620
+ credentials?: Credential[];
621
+ } | {
622
+ kind: "approval";
623
+ escalationToken: string;
624
+ receiptJti?: string;
625
+ };
626
+ /** Options for `decisions.embed` / `consent.open` / `approvals.open`. */
627
+ interface DecisionsEmbedOptions {
628
+ token: DecisionToken;
629
+ container: string | HTMLElement;
630
+ style?: EmbedStyle;
631
+ loading?: string | HTMLElement;
632
+ embedOrigin?: string;
633
+ onReady?: (payload: DecisionPayload) => void;
634
+ onState?: (kind: DecisionKind, payload: DecisionPayload) => void;
635
+ onComplete?: (outcome: DecisionOutcome) => void;
636
+ onCancel?: (payload: DecisionPayload) => void;
637
+ onError?: (payload: DecisionPayload) => void;
638
+ onDeadline?: (payload: DecisionPayload) => void;
639
+ onResize?: (height: number) => void;
640
+ /** Counter-proposal from approval flows (three-outcome). */
641
+ onCounter?: (payload: DecisionPayload) => void;
642
+ }
643
+ /** Options for `decisions.popup`. */
644
+ interface DecisionsPopupOptions {
645
+ token: DecisionToken;
646
+ width?: number;
647
+ height?: number;
648
+ onComplete?: (outcome: DecisionOutcome) => void;
649
+ onCancel?: (payload: DecisionPayload) => void;
650
+ onError?: (payload: DecisionPayload) => void;
651
+ }
652
+ /** Handle returned by `decisions.embed` / `decisions.popup`. */
653
+ interface DecisionsHandle {
654
+ readonly token: DecisionToken;
655
+ readonly mode: DecisionMode;
656
+ destroy(): Promise<void>;
657
+ }
658
+ /** Public surface of the decisions primitive. */
659
+ interface DecisionsNamespace {
660
+ embed(opts: DecisionsEmbedOptions): DecisionsHandle;
661
+ popup(opts: DecisionsPopupOptions): DecisionsHandle;
662
+ url(opts: {
663
+ token: DecisionToken;
664
+ mode?: DecisionMode;
665
+ }): string;
666
+ createSession(input: DecisionsCreateSessionInput): Promise<DecisionsSession>;
667
+ discover(opts: {
668
+ flowId: string;
669
+ locale?: string;
670
+ }): Promise<FlowDisclosures>;
671
+ exchange(input: DecisionsExchangeInput): Promise<DecisionExchange>;
672
+ cancel(token: DecisionToken): Promise<void>;
673
+ }
674
+ type FlowDisclosureMechanism = "explicit" | "informed" | "opt_out" | "documented" | "delegated";
675
+ type FlowDisclosureLegalBasis = "consent" | "contract" | "legitimate_interest" | "legal_obligation" | "vital_interest" | "public_task";
676
+ type FlowDisclosureButtonMode = "accept" | "acknowledge" | "authorize" | "connect" | "continue" | "share" | "sign_in" | "verify";
677
+ interface FlowDisclosurePurpose {
678
+ name: string;
679
+ label: string;
680
+ description: string | null;
681
+ mechanism: FlowDisclosureMechanism;
682
+ legalBasis: FlowDisclosureLegalBasis;
683
+ required: boolean;
684
+ dataLabels: string[];
685
+ }
686
+ interface FlowDisclosureField {
687
+ name: string;
688
+ label: string;
689
+ fieldType: string;
690
+ required: boolean;
691
+ section: "input" | "obligation" | "proof";
692
+ completedBy: "principal" | "application" | "both";
693
+ }
694
+ interface FlowDisclosureStep {
695
+ key: string;
696
+ title: string;
697
+ }
698
+ interface FlowDisclosures {
699
+ schema: string;
700
+ flow: {
701
+ id: string;
702
+ name: string;
703
+ version: number;
704
+ kind: "consent";
705
+ };
706
+ application: {
707
+ name: string;
708
+ primaryColor: string | null;
709
+ logoUrl: string | null;
710
+ };
711
+ purposes: FlowDisclosurePurpose[];
712
+ fields: FlowDisclosureField[];
713
+ steps: FlowDisclosureStep[];
714
+ presentation: {
715
+ buttonMode: FlowDisclosureButtonMode;
716
+ displayLabel: string;
717
+ };
718
+ outcomes: Array<"granted" | "denied">;
719
+ expiry: {
720
+ consentDurationDays: number | null;
721
+ };
722
+ locale: {
723
+ requested: "params" | "header" | "default";
724
+ resolved: string;
725
+ fallback: "en";
726
+ };
727
+ revision: string;
728
+ }
729
+ /**
730
+ * A participant's own view of one meeting (camelCase after the ApiClient's
731
+ * toCamelCase pass). `purposes` maps purpose name → the recorded decision
732
+ * value; `meeting` names the meeting the decision is pinned to.
733
+ */
734
+ interface MeetingParticipantStatus {
735
+ meetingConsentId: string;
736
+ status: "pending" | "fulfilled" | "expired" | "revoked" | string;
737
+ consentedAt: string | null;
738
+ revokedAt: string | null;
739
+ purposes: Record<string, string>;
740
+ meeting: {
741
+ id: string;
742
+ title: string | null;
743
+ scheduledAt: string | null;
744
+ endsAt: string | null;
745
+ platform: string | null;
746
+ cancelledAt: string | null;
747
+ } | null;
748
+ }
749
+ /** Options for `consent.open` (preserves v0 callback names). */
750
+ interface ConsentOpenOptions {
751
+ flowId: string;
752
+ container: string | HTMLElement;
753
+ mode?: DecisionMode;
754
+ embedOrigin?: string;
755
+ scope?: string;
756
+ state?: string;
757
+ nonce?: string;
758
+ redirectUri?: string;
759
+ style?: EmbedStyle;
760
+ loading?: string | HTMLElement;
761
+ onComplete?: (outcome: DecisionOutcome & {
762
+ kind: "consent";
763
+ }) => void;
764
+ onCancel?: (payload: DecisionPayload) => void;
765
+ onError?: (payload: DecisionPayload) => void;
766
+ onStep?: (payload: DecisionPayload) => void;
767
+ onReady?: (payload: DecisionPayload) => void;
768
+ }
769
+ /** Options for `approvals.open` (three-outcome flow). */
770
+ interface ApprovalsOpenOptions {
771
+ escalationId: string;
772
+ container: string | HTMLElement;
773
+ mode?: DecisionMode;
774
+ embedOrigin?: string;
775
+ state?: string;
776
+ redirectUri?: string;
777
+ style?: EmbedStyle;
778
+ loading?: string | HTMLElement;
779
+ onComplete?: (outcome: DecisionOutcome & {
780
+ kind: "approval";
781
+ }) => void;
782
+ onCancel?: (payload: DecisionPayload) => void;
783
+ onError?: (payload: DecisionPayload) => void;
784
+ onState?: (payload: DecisionPayload) => void;
785
+ onDeadline?: (payload: DecisionPayload) => void;
786
+ onCounter?: (payload: DecisionPayload) => void;
787
+ onReady?: (payload: DecisionPayload) => void;
788
+ }
789
+ /** Public surface of the consent facade. */
790
+ interface ConsentNamespace {
791
+ open(opts: ConsentOpenOptions): Promise<DecisionsHandle>;
792
+ url(opts: {
793
+ flowId: string;
794
+ mode?: DecisionMode;
795
+ }): string;
796
+ /** 189 — pre-flight disclosure discovery for a consent flow (delegates to `decisions.discover`). */
797
+ discover(opts: {
798
+ flowId: string;
799
+ locale?: string;
800
+ }): Promise<FlowDisclosures>;
801
+ }
802
+ /** Public surface of the approvals facade. */
803
+ interface ApprovalsNamespace {
804
+ open(opts: ApprovalsOpenOptions): Promise<DecisionsHandle>;
805
+ url(opts: {
806
+ escalationId: string;
807
+ mode?: DecisionMode;
808
+ }): string;
809
+ /** Returns remaining deadline for an approval session. */
810
+ deadline(token: DecisionToken): Promise<{
811
+ remainingMs: number;
812
+ deadlineAt: string;
813
+ }>;
814
+ }
815
+ /**
816
+ * Options for `signing.open` (cross-border signing, kind
817
+ * `signature_request`). Mirrors `ApprovalsOpenOptions`; `signatureRef` is the
818
+ * per-party signing slot the host resolves to a signing token. `onComplete`
819
+ * narrows to the signing outcome (`signed | declined | countered`). `onState`
820
+ * receives the signing STATE payload (assurance + progress; see
821
+ * {@link SignatureStatePayload}).
822
+ */
823
+ interface SigningOpenOptions {
824
+ signatureRef: string;
825
+ container: string | HTMLElement;
826
+ mode?: DecisionMode;
827
+ embedOrigin?: string;
828
+ state?: string;
829
+ redirectUri?: string;
830
+ style?: EmbedStyle;
831
+ loading?: string | HTMLElement;
832
+ onComplete?: (outcome: DecisionOutcome & {
833
+ kind: "signature_request";
834
+ }) => void;
835
+ onCancel?: (payload: DecisionPayload) => void;
836
+ onError?: (payload: DecisionPayload) => void;
837
+ /** Signing STATE — typed assurance + progress (`signature/state.json`). */
838
+ onState?: (payload: SignatureStatePayload) => void;
839
+ onDeadline?: (payload: DecisionPayload) => void;
840
+ /** Fires on a `countered` outcome. Signing carries no proposal payload. */
841
+ onCounter?: (payload: DecisionPayload) => void;
842
+ onReady?: (payload: DecisionPayload) => void;
843
+ }
844
+ /** Public surface of the signing facade. */
845
+ interface SigningNamespace {
846
+ open(opts: SigningOpenOptions): Promise<DecisionsHandle>;
847
+ url(opts: {
848
+ signatureRef: string;
849
+ mode?: DecisionMode;
850
+ }): string;
851
+ /** Returns remaining deadline for a signing session. */
852
+ deadline(token: DecisionToken): Promise<{
853
+ remainingMs: number;
854
+ deadlineAt: string;
855
+ }>;
856
+ }
857
+
858
+ interface DecisionsConfig {
859
+ api: ApiClient;
860
+ flowBaseUrl: string;
861
+ debug: boolean;
862
+ }
863
+ /**
864
+ * Implementation of the kind-agnostic decisions namespace. Exposed
865
+ * to consumers as `Overturo#decisions`.
866
+ *
867
+ * The class tracks every live `DecisionsHandle` it creates so
868
+ * `Overturo#destroy()` can tear them all down at once.
869
+ */
870
+ declare class Decisions implements DecisionsNamespace {
871
+ #private;
872
+ constructor(config: DecisionsConfig);
873
+ /**
874
+ * Returns the canonical decisions URL for a token. `mode="embed"`
875
+ * gets the `/embed` suffix; `popup` and `redirect` use the bare
876
+ * path (the server-rendered page handles both).
877
+ */
878
+ url(opts: {
879
+ token: DecisionToken;
880
+ mode?: DecisionMode;
881
+ }): string;
882
+ /**
883
+ * Creates a new decisions session via `POST /api/v1/decisions`.
884
+ * Wraps the legacy v0 API client's snake-case helpers so existing
885
+ * tests around case conversion keep working.
886
+ */
887
+ createSession(input: DecisionsCreateSessionInput): Promise<DecisionsSession>;
888
+ /**
889
+ * pre-flight disclosure discovery. Fetches what the decision screen
890
+ * will present for a flow, BEFORE any session exists: purposes, fields,
891
+ * steps, the action label, expiry, and application branding, in public
892
+ * vocabulary and the requested locale. The recommended first call in the
893
+ * embed flow: discover -> createSession -> (SDK reads config).
894
+ *
895
+ * Publishable-key authenticated — the ApiClient already sends
896
+ * `X-Publishable-Key` (api.ts); the server ignores any bearer header on this
897
+ * endpoint. An unknown / foreign / non-consent flow answers a uniform 404
898
+ * (OverturoApiError, status 404).
899
+ */
900
+ discover(opts: {
901
+ flowId: string;
902
+ locale?: string;
903
+ }): Promise<FlowDisclosures>;
904
+ /**
905
+ * Mounts the decisions flow inside an iframe under `opts.container`.
906
+ * Validates inbound v2 envelopes; drops on origin mismatch /
907
+ * schema-invalid. Returns a handle whose `.destroy()` tears down
908
+ * the iframe + listener.
909
+ */
910
+ embed(opts: DecisionsEmbedOptions): DecisionsHandle;
911
+ /**
912
+ * Opens the decisions flow in a popup window. Caller MUST invoke this
913
+ * synchronously from a user-action handler or browsers will block.
914
+ */
915
+ popup(opts: DecisionsPopupOptions): DecisionsHandle;
916
+ /**
917
+ * Exchanges a completed decision's token for the per-kind receipt.
918
+ * Server returns a discriminated union; the SDK preserves the
919
+ * discriminator so consumers using strict TypeScript get narrowing.
920
+ */
921
+ exchange(input: DecisionsExchangeInput): Promise<DecisionExchange>;
922
+ /**
923
+ * Asks the server to mark a session as cancelled. Idempotent on
924
+ * already-terminal sessions.
925
+ */
926
+ cancel(token: DecisionToken): Promise<void>;
927
+ /**
928
+ * Tears down every live handle (embed or popup) this client created.
929
+ * Called by `Overturo#destroy()`. Errors during destroy are swallowed
930
+ * — we want best-effort cleanup, not a half-destroyed state.
931
+ */
932
+ destroyAll(): Promise<void>;
933
+ }
934
+
935
+ declare class ApprovalsFacade implements ApprovalsNamespace {
936
+ #private;
937
+ constructor(decisions: Decisions, api: ApiClient);
938
+ open(opts: ApprovalsOpenOptions): Promise<DecisionsHandle>;
939
+ url(opts: {
940
+ escalationId: string;
941
+ mode?: DecisionMode;
942
+ }): string;
943
+ /**
944
+ * Polls `${decisions_api}/:token` for deadline metadata. Returns the
945
+ * computed remainingMs alongside the absolute deadlineAt for clock-
946
+ * skew tolerance in consumers.
947
+ */
948
+ deadline(token: DecisionToken): Promise<{
949
+ remainingMs: number;
950
+ deadlineAt: string;
951
+ }>;
952
+ }
953
+
954
+ declare class ConsentFacade implements ConsentNamespace {
955
+ #private;
956
+ constructor(decisions: Decisions);
957
+ /**
958
+ * Creates a consent session and mounts the iframe in one call.
959
+ * Bridges v0's `onStep(payload)` to v1's `onState(kind, payload)`
960
+ * so existing call sites keep working with a single rename.
961
+ */
962
+ open(opts: ConsentOpenOptions): Promise<DecisionsHandle>;
963
+ url(opts: {
964
+ flowId: string;
965
+ mode?: DecisionMode;
966
+ }): string;
967
+ /**
968
+ * pre-flight disclosure discovery. Thin delegate to
969
+ * `decisions.discover` so the kind facades stay symmetric.
970
+ */
971
+ discover(opts: {
972
+ flowId: string;
973
+ locale?: string;
974
+ }): Promise<FlowDisclosures>;
975
+ }
976
+
977
+ /**
978
+ * 201 D4 Level B — Form Capture: the organisation keeps its form; Overturo
979
+ * keeps the record. `attach` intercepts the form's submit, reads the mapped
980
+ * consent controls (decision + presentation as shown), posts one capture
981
+ * with the publishable key, writes the capture token into a hidden input and
982
+ * lets the submission proceed. If Overturo is unreachable the form still
983
+ * submits and `onError` fires. Writes nothing to client storage.
984
+ *
985
+ * @example
986
+ * ```ts
987
+ * overturo.forms.attach({
988
+ * flowId: "flw_...",
989
+ * form: "#signup",
990
+ * map: { marketing: "#marketing_opt_in", analytics: "#analytics" },
991
+ * subjectField: "#email",
992
+ * })
993
+ * ```
994
+ */
995
+ declare class FormsFacade {
996
+ private readonly api;
997
+ private readonly decisions;
998
+ private readonly flowBaseUrl;
999
+ private readonly publishableKey;
1000
+ constructor(api: ApiClient, decisions: Decisions, flowBaseUrl: string, publishableKey: string);
1001
+ /** Wires the capture onto the form; returns a detach function. */
1002
+ attach(opts: FormCaptureOptions): () => void;
1003
+ /**
1004
+ * 202 D9 — the embedded consent field: the control is Overturo-rendered
1005
+ * inside the form, so the element does the capture from its own frame. The
1006
+ * field entry (`@overturo/js/field` / `overturo-field.js`) must be loaded;
1007
+ * one field per flow per form.
1008
+ */
1009
+ private attachField;
1010
+ /** Builds the capture body the way `attach` does — exposed for integrators who post themselves. */
1011
+ buildCaptureBody(form: HTMLFormElement, opts: FormCaptureOptions, initiallyChecked?: Record<string, boolean>): Record<string, unknown>;
1012
+ /**
1013
+ * 201 D11 — the digest of each mapped label's text as the person saw it
1014
+ * (a 256-bit digest of the trimmed text — the algorithm the forms
1015
+ * documentation publishes), so the record can
1016
+ * say whether the form's wording matched the wording published for the flow.
1017
+ * Needs `labels` (purpose → label selector) and WebCrypto; otherwise nothing is attested.
1018
+ */
1019
+ labelDigests(form: HTMLFormElement, opts: FormCaptureOptions): Promise<Record<string, string> | undefined>;
1020
+ /** 201 D11 — writes the published wording into the labels the integrator names. */
1021
+ writeWording(form: HTMLFormElement, opts: FormCaptureOptions): Promise<void>;
1022
+ }
1023
+
1024
+ declare class SigningFacade implements SigningNamespace {
1025
+ #private;
1026
+ constructor(decisions: Decisions, api: ApiClient);
1027
+ open(opts: SigningOpenOptions): Promise<DecisionsHandle>;
1028
+ url(opts: {
1029
+ signatureRef: string;
1030
+ mode?: DecisionMode;
1031
+ }): string;
1032
+ /**
1033
+ * Polls `${decisions_api}/:token` for deadline metadata. Returns the
1034
+ * computed remainingMs alongside the absolute deadlineAt for clock-
1035
+ * skew tolerance in consumers.
1036
+ */
1037
+ deadline(token: DecisionToken): Promise<{
1038
+ remainingMs: number;
1039
+ deadlineAt: string;
1040
+ }>;
1041
+ }
1042
+
1043
+ /**
1044
+ * The main Overturo client for initiating consent flows and exchanging tokens.
1045
+ *
1046
+ * @example
1047
+ * ```ts
1048
+ * const overturo = new Overturo({ publishableKey: "pk_live_..." });
1049
+ *
1050
+ * // High-level: create session + embed in one call
1051
+ * const flow = await overturo.consent({
1052
+ * flowId: "flw_...",
1053
+ * container: "#consent",
1054
+ * onComplete: (result) => console.log(result.consentToken),
1055
+ * });
1056
+ *
1057
+ * // Low-level: manual session + embed
1058
+ * const session = await overturo.createSession({ flowId: "flw_..." });
1059
+ * const widget = overturo.embed({ sessionToken: session.sessionToken, container: "#el" });
1060
+ * ```
1061
+ */
1062
+ declare class Overturo {
1063
+ private api;
1064
+ private baseUrl;
1065
+ private flowBaseUrl;
1066
+ private debugFlag;
1067
+ readonly decisions: Decisions;
1068
+ readonly consent: ConsentFacade;
1069
+ readonly approvals: ApprovalsFacade;
1070
+ readonly signing: SigningFacade;
1071
+ /** 201 — Form Capture: the organisation keeps its form; Overturo keeps the record. */
1072
+ readonly forms: FormsFacade;
1073
+ constructor(options: OverturoOptions);
1074
+ /**
1075
+ * Tears down every live decisions handle (embed iframes + popups).
1076
+ * Best-effort: errors during teardown are swallowed.
1077
+ *
1078
+ * @since 1.0.0
1079
+ */
1080
+ destroy(): Promise<void>;
1081
+ /**
1082
+ * Creates a new consent session.
1083
+ * The flowId is sent as accord_id to the server (automatic parameter aliasing).
1084
+ */
1085
+ createSession(params: CreateSessionParams): Promise<Session>;
1086
+ /**
1087
+ * Retrieves the status of an existing consent session.
1088
+ */
1089
+ getSession(sessionToken: string): Promise<SessionStatus>;
1090
+ /**
1091
+ * This participant's consent status for ONE meeting (the meeting's own
1092
+ * window and platform ride along). Identified by the participant's own
1093
+ * session token — never lists other participants.
1094
+ */
1095
+ getMeetingParticipantStatus(meetingId: string, sessionToken: string): Promise<MeetingParticipantStatus>;
1096
+ /**
1097
+ * Withdraws this participant's consent for ONE meeting. The host is told;
1098
+ * the record keeps the withdrawal.
1099
+ */
1100
+ withdrawMeetingConsent(meetingId: string, sessionToken: string): Promise<MeetingParticipantStatus>;
1101
+ private decodeParticipantStatus;
1102
+ /**
1103
+ * Embeds a consent flow in an iframe.
1104
+ * Requires a sessionToken from createSession().
1105
+ */
1106
+ embed(options: EmbedOptions): EmbedHandle;
1107
+ /**
1108
+ * Opens a consent flow in a popup window.
1109
+ * Requires a sessionToken from createSession().
1110
+ *
1111
+ * @throws {OverturoError} If the browser blocks the popup.
1112
+ */
1113
+ popup(options: PopupOptions): PopupHandle;
1114
+ /**
1115
+ * Redirects to a consent flow (full-page navigation).
1116
+ * No session token needed — the server creates one on arrival.
1117
+ */
1118
+ redirect(options: RedirectOptions): void;
1119
+ /**
1120
+ * Exchanges a consent token for claims, attestations, credentials, and tokens.
1121
+ * Best used server-side with apiKey set.
1122
+ *
1123
+ * Handles HTTP 202 (fulfillment pending) transparently by retrying with
1124
+ * the Retry-After interval until the server returns the full result.
1125
+ */
1126
+ exchange(params: ExchangeParams): Promise<ExchangeResult>;
1127
+ /**
1128
+ * Creates a new AccordSetup session via the API.
1129
+ * Lower-level than accordSetup() — use when you need manual control.
1130
+ */
1131
+ createSetupSession(params: CreateSetupSessionParams): Promise<SetupSession>;
1132
+ /**
1133
+ * High-level: creates a setup session and embeds the wizard in an iframe.
1134
+ *
1135
+ * @example
1136
+ * ```ts
1137
+ * const handle = await overturo.accordSetup({
1138
+ * solution: "meetings",
1139
+ * container: "#setup",
1140
+ * onCreated: ({ flowId }) => console.log("Created:", flowId),
1141
+ * });
1142
+ * ```
1143
+ */
1144
+ accordSetup(options: AccordSetupOptions): Promise<SetupHandle>;
1145
+ /**
1146
+ * Creates a setup session and opens the wizard in a popup window.
1147
+ */
1148
+ accordSetupPopup(options: AccordSetupPopupOptions): Promise<SetupPopupHandle>;
1149
+ /**
1150
+ * Creates a setup session and redirects to the wizard (full-page navigation).
1151
+ * On completion, the user is redirected back to `redirectUri` with query params.
1152
+ */
1153
+ accordSetupRedirect(options: AccordSetupRedirectOptions): Promise<void>;
1154
+ /**
1155
+ * Preview a template in an iframe.
1156
+ *
1157
+ * Creates a preview token via the API, then renders the preview in the
1158
+ * specified container. Returns a handle for controlling the preview.
1159
+ *
1160
+ * @example
1161
+ * ```ts
1162
+ * const preview = await overturo.previewTemplate({
1163
+ * templateId: "tpl_abc123",
1164
+ * container: "#preview",
1165
+ * device: "mobile",
1166
+ * theme: "corporate",
1167
+ * });
1168
+ * preview.setDevice("desktop");
1169
+ * preview.destroy();
1170
+ * ```
1171
+ */
1172
+ previewTemplate(options: PreviewTemplateOptions): Promise<PreviewHandle>;
1173
+ /**
1174
+ * Preview a setup session in an iframe.
1175
+ *
1176
+ * Creates a preview token via the API for the specified setup session,
1177
+ * then renders the preview in the specified container.
1178
+ *
1179
+ * @example
1180
+ * ```ts
1181
+ * const preview = await overturo.previewSetup({
1182
+ * sessionToken: "acs_abc123",
1183
+ * container: "#preview",
1184
+ * });
1185
+ * preview.setTheme("dark");
1186
+ * preview.destroy();
1187
+ * ```
1188
+ */
1189
+ previewSetup(options: PreviewSetupOptions): Promise<PreviewHandle>;
1190
+ /**
1191
+ * Builds common CreateSetupSessionParams from any setup options variant.
1192
+ */
1193
+ private buildSetupParams;
1194
+ }
1195
+
1196
+ /**
1197
+ * 201 D12 — the decision and the presentation of one mapped form control, as
1198
+ * observed in the DOM at submit: ticked → granted, unticked → declined (never
1199
+ * silence), with the default-ticked and required flags the server's matrix
1200
+ * refuses for a consent purpose. Only checkable controls are read; anything
1201
+ * else is declined (a text field is never a consent).
1202
+ */
1203
+ interface AttestedDecision {
1204
+ decision: "granted" | "declined";
1205
+ default_checked: boolean;
1206
+ mandatory: boolean;
1207
+ }
1208
+
1209
+ /**
1210
+ * Creates an AccordSetup wizard embedded in an iframe.
1211
+ *
1212
+ * @param baseUrl - The Overturo base URL
1213
+ * @param options - Setup options including session token, container, and callbacks
1214
+ * @returns Handle with iframe reference and destroy method
1215
+ */
1216
+ declare function createSetupEmbed(baseUrl: string, options: AccordSetupOptions & {
1217
+ sessionToken: string;
1218
+ }): SetupHandle;
1219
+ /**
1220
+ * Opens the AccordSetup wizard in a popup window.
1221
+ *
1222
+ * @param baseUrl - The Overturo base URL
1223
+ * @param options - Popup options including session token and callbacks
1224
+ * @returns Handle with close method
1225
+ */
1226
+ declare function createSetupPopup(baseUrl: string, options: AccordSetupPopupOptions & {
1227
+ sessionToken: string;
1228
+ }): SetupPopupHandle;
1229
+ /**
1230
+ * Redirects to the AccordSetup wizard (full-page navigation).
1231
+ *
1232
+ * @param baseUrl - The Overturo base URL
1233
+ * @param options - Redirect options including session token
1234
+ */
1235
+ declare function setupRedirect(baseUrl: string, options: AccordSetupRedirectOptions & {
1236
+ sessionToken: string;
1237
+ }): void;
1238
+
1239
+ /** Base error class for all Overturo SDK errors. */
1240
+ declare class OverturoError extends Error {
1241
+ constructor(message: string);
1242
+ }
1243
+ /** Thrown when required parameters are missing or invalid. */
1244
+ declare class OverturoValidationError extends OverturoError {
1245
+ constructor(message: string);
1246
+ }
1247
+ /** Thrown when the API returns a 4xx or 5xx response. */
1248
+ declare class OverturoApiError extends OverturoError {
1249
+ /** HTTP status code. */
1250
+ status: number;
1251
+ /** Parsed response body, if available. */
1252
+ body: unknown;
1253
+ constructor(message: string, status: number, body: unknown);
1254
+ }
1255
+ /** Thrown when a network error prevents the request from completing. */
1256
+ declare class OverturoNetworkError extends OverturoError {
1257
+ /** The original error that caused the failure. */
1258
+ cause: unknown;
1259
+ constructor(message: string, cause: unknown);
1260
+ }
1261
+ /** Thrown when an operation times out. */
1262
+ declare class OverturoTimeoutError extends OverturoError {
1263
+ constructor(message?: string);
1264
+ }
1265
+ /**
1266
+ * OAP denial category vocabulary.
1267
+ *
1268
+ * Cascade-relevant errors returned by OAP endpoints carry one of these
1269
+ * values. Non-cascade errors (validation, conflict, internal) omit the
1270
+ * field.
1271
+ */
1272
+ type OapDenialCategory = "authorization_denied" | "intent_denied" | "trajectory_denied";
1273
+ /**
1274
+ * Shape of a single OAP error envelope as rendered by the server.
1275
+ * Surfaced through {@link OapDenied} so callers can introspect the
1276
+ * full envelope without re-parsing the response body.
1277
+ */
1278
+ interface OapErrorEnvelope {
1279
+ reason_code: string;
1280
+ message: string;
1281
+ detail?: Record<string, unknown>;
1282
+ failed_bound?: string;
1283
+ denial_category?: OapDenialCategory;
1284
+ cascade_step?: number;
1285
+ request_id?: string;
1286
+ negotiable?: boolean;
1287
+ negotiate_url?: string;
1288
+ documentation_url?: string;
1289
+ }
1290
+ /**
1291
+ * Thrown when an OAP-protocol endpoint returns a denial.
1292
+ *
1293
+ * Carries the structured fields from the OAP error envelope. The
1294
+ * three subclasses below map 1:1 to {@link OapDenialCategory} so
1295
+ * callers can `catch (e: OapIntentDenied)` directly.
1296
+ */
1297
+ declare class OapDenied extends OverturoApiError {
1298
+ reason_code: string;
1299
+ failed_bound: string | undefined;
1300
+ denial_category: OapDenialCategory | undefined;
1301
+ cascade_step: number | undefined;
1302
+ detail: Record<string, unknown> | undefined;
1303
+ constructor(envelope: OapErrorEnvelope, status: number, body: unknown);
1304
+ /**
1305
+ * Build the most-specific subclass for the envelope. Reason-code
1306
+ * dispatch takes precedence over category dispatch so the most
1307
+ * specific subclass wins (sequence denials are
1308
+ * trajectory_denied but get their own subclass).
1309
+ */
1310
+ static fromEnvelope(envelope: OapErrorEnvelope, status: number, body: unknown): OapDenied;
1311
+ }
1312
+ /** denial_category == "authorization_denied" — OAuth/DPoP layer rejected. */
1313
+ declare class OapAuthorizationDenied extends OapDenied {
1314
+ constructor(envelope: OapErrorEnvelope, status: number, body: unknown);
1315
+ }
1316
+ /** denial_category == "intent_denied" — request fell outside grant bounds. */
1317
+ declare class OapIntentDenied extends OapDenied {
1318
+ constructor(envelope: OapErrorEnvelope, status: number, body: unknown);
1319
+ }
1320
+ /** denial_category == "trajectory_denied" — execution history blocked. */
1321
+ declare class OapTrajectoryDenied extends OapDenied {
1322
+ constructor(envelope: OapErrorEnvelope, status: number, body: unknown);
1323
+ }
1324
+ /**
1325
+ * 2 — sequence_bounds violation
1326
+ * (`sequence_prohibited` / `sequence_missing_predecessor`). A
1327
+ * trajectory denial with a structural-ordering flavour.
1328
+ */
1329
+ declare class OapSequenceDenied extends OapTrajectoryDenied {
1330
+ constructor(envelope: OapErrorEnvelope, status: number, body: unknown);
1331
+ }
1332
+
1333
+ declare const ElementBase: typeof HTMLElement;
1334
+
1335
+ declare const ELEMENT_NAME = "overturo-decision";
1336
+ declare const ALREADY_DEFINED_CODE = "OVERTURO_ELEMENT_ALREADY_DEFINED";
1337
+ /**
1338
+ * Reads `token` + `mode` + `theme` attributes; mounts the trust-host
1339
+ * iframe under a Shadow DOM root; emits CustomEvents for every
1340
+ * lifecycle transition. Consumers can subscribe with bare DOM APIs
1341
+ * (no SDK initialisation required for the simple case).
1342
+ *
1343
+ * Events fired (all CustomEvent):
1344
+ * `decision:ready` — `detail` is the READY payload
1345
+ * `decision:state` — `detail = {kind, payload}`
1346
+ * `decision:complete` — `detail = {kind, payload}`
1347
+ * `decision:cancel` — `detail` is the CANCEL payload
1348
+ * `decision:error` — `detail` is the ERROR payload
1349
+ * `decision:deadline` — `detail` is the DEADLINE payload
1350
+ */
1351
+ declare class DecisionElement extends ElementBase {
1352
+ #private;
1353
+ static observedAttributes: string[];
1354
+ constructor();
1355
+ connectedCallback(): void;
1356
+ disconnectedCallback(): void;
1357
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
1358
+ }
1359
+ /**
1360
+ * Default registration. Side-effect import from `src/elements/index.ts`
1361
+ * triggers this on bundle load. Skipped (with a console warning) if
1362
+ * the element is already registered.
1363
+ */
1364
+ declare function registerDecisionElement(): void;
1365
+
1366
+ export { ALREADY_DEFINED_CODE, type AccordSetupOptions, type AccordSetupPopupOptions, type AccordSetupRedirectOptions, type AccordSetupResult, type ApprovalsNamespace, type ApprovalsOpenOptions, type Attestation, type AttestedDecision, type ConsentNamespace, type ConsentOpenOptions, type ConsentOptions, type ConsentResult, type CreateSessionParams, type CreateSetupSessionParams, type Credential, DecisionElement, type DecisionExchange, type DecisionKind, type DecisionMode, type DecisionOutcome, type DecisionPayload, type DecisionToken, type DecisionsCreateSessionInput, type DecisionsEmbedOptions, type DecisionsExchangeInput, type DecisionsHandle, type DecisionsNamespace, type DecisionsPopupOptions, type DecisionsSession, ELEMENT_NAME, type EmbedHandle, type EmbedOptions, type EmbedStyle, type ExchangeParams, type ExchangeResult, type FlowDisclosureButtonMode, type FlowDisclosureField, type FlowDisclosureLegalBasis, type FlowDisclosureMechanism, type FlowDisclosurePurpose, type FlowDisclosureStep, type FlowDisclosures, type FormCaptureOptions, type FormCaptureResult, type MeetingParticipantStatus, OapAuthorizationDenied, type OapDenialCategory, OapDenied, type OapErrorEnvelope, OapIntentDenied, OapSequenceDenied, OapTrajectoryDenied, Overturo, OverturoApiError, OverturoError, OverturoNetworkError, type OverturoOptions, OverturoTimeoutError, OverturoValidationError, type PopupHandle, type PopupOptions, type RedirectOptions, type Session, type SessionStatus, type SetupConstraints, type SetupHandle, type SetupPopupHandle, type SetupSession, type SetupStep, type SignatureStatePayload, type SigningNamespace, type SigningOpenOptions, type StepInfo, createSetupEmbed, createSetupPopup, Overturo as default, registerDecisionElement, setupRedirect };