esigncomply 0.0.0-stage → 1.0.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.
@@ -0,0 +1,1687 @@
1
+ import type { Open } from "./errors";
2
+ /**
3
+ * Request and response shapes of the Esign Comply API (spec section 13).
4
+ *
5
+ * Enumerations are open strings: the API may add values at any time and
6
+ * clients must tolerate them (BC-3). Responses may carry fields that are not
7
+ * listed here; ignore what you do not know.
8
+ */
9
+ export type { Open };
10
+ /** RFC 3339 timestamp in UTC with millisecond precision. */
11
+ export type Timestamp = string;
12
+ /** `sha256:` followed by 64 lower-case hexadecimal digits. */
13
+ export type Sha256 = string;
14
+ export type Metadata = Record<string, unknown>;
15
+ export interface List<T> {
16
+ object: "list";
17
+ data: T[];
18
+ has_more: boolean;
19
+ }
20
+ /** Cursor pagination (spec 13.1): `limit` defaults to 20, maximum 100. */
21
+ export interface ListParams {
22
+ limit?: number;
23
+ after?: string;
24
+ before?: string;
25
+ }
26
+ export type DocumentType = Open<"terms" | "privacy_notice" | "nda" | "contract" | "consent" | "policy_ack" | "custom">;
27
+ export type DocumentFormat = Open<"markdown" | "html" | "text" | "pdf" | "hash_only">;
28
+ export interface DocumentCreateParams {
29
+ name: string;
30
+ type: DocumentType;
31
+ metadata?: Metadata;
32
+ }
33
+ export interface Document {
34
+ object: "document";
35
+ id: string;
36
+ livemode: boolean;
37
+ name: string;
38
+ type: DocumentType;
39
+ metadata: Metadata;
40
+ archived: boolean;
41
+ created_at: Timestamp;
42
+ /** `GET /documents/{id}` only. */
43
+ current_version?: string | null;
44
+ versions?: number;
45
+ signers_by_version?: Record<string, number> | Array<Record<string, unknown>>;
46
+ warnings?: string[];
47
+ }
48
+ export interface DocumentListParams extends ListParams {
49
+ type?: DocumentType;
50
+ }
51
+ export type DocumentVersionContent = {
52
+ format: "markdown" | "html" | "text";
53
+ text: string;
54
+ }
55
+ /** Uploaded file, 10 MB maximum (DV-1). */
56
+ | {
57
+ format: "pdf";
58
+ data_base64: string;
59
+ }
60
+ /** Hash-only registration (DV-6): Esign Comply seals the hash and never holds the document. */
61
+ | {
62
+ format: "hash_only";
63
+ sha256: string;
64
+ render_sha256?: string;
65
+ };
66
+ export interface DocumentVersionCreateParams {
67
+ version_label: string;
68
+ language?: string;
69
+ effective_at?: Timestamp;
70
+ content: DocumentVersionContent;
71
+ /** Marks earlier acceptances as outstanding in `signers.status()` (DV-4). */
72
+ material_change?: boolean;
73
+ summary_of_changes?: string;
74
+ }
75
+ export interface DocumentVersion {
76
+ object: "document_version";
77
+ id: string;
78
+ document_id: string;
79
+ livemode: boolean;
80
+ version_label: string;
81
+ language: string;
82
+ format: DocumentFormat;
83
+ /** Covers the exact bytes stored (DV-2). */
84
+ content_hash: Sha256;
85
+ /** Covers the normalized visible text; what the browser SDK compares with the page (DV-2). */
86
+ render_hash: Sha256 | null;
87
+ size: number;
88
+ material_change: boolean;
89
+ summary_of_changes: string | null;
90
+ effective_at: Timestamp;
91
+ published_at: Timestamp;
92
+ warnings?: string[];
93
+ }
94
+ export interface DocumentVersionContentResult {
95
+ object: "document_version_content";
96
+ version_id: string;
97
+ document_id: string;
98
+ format: DocumentFormat;
99
+ language: string;
100
+ content_hash: Sha256;
101
+ render_hash: Sha256 | null;
102
+ /** The stored text, for `markdown`, `html` and `text`. Null for hash-only registrations. */
103
+ text?: string | null;
104
+ /** The text rendered to sanitized HTML. */
105
+ html?: string | null;
106
+ /** `pdf` only. */
107
+ data_base64?: string;
108
+ content_type?: string;
109
+ note?: string;
110
+ }
111
+ export type JurisdictionMode = Open<"auto" | "strictest" | "explicit">;
112
+ export type AssuranceLevel = Open<"L1" | "L2" | "L3">;
113
+ export type SignatureMethod = Open<"click" | "checkbox" | "typed" | "drawn" | "passkey">;
114
+ export interface ProfileCreateParams {
115
+ name: string;
116
+ /** Pack codes, e.g. `["US-FED", "US-CA"]`. Read the catalogue with `jurisdictions.list()`. */
117
+ jurisdictions?: string[];
118
+ jurisdiction_mode?: JurisdictionMode;
119
+ on_unknown_region?: Open<"strictest" | "base_only" | "reject">;
120
+ governing_law?: string | null;
121
+ allow_session_packs?: boolean;
122
+ strict_jurisdictions?: boolean;
123
+ pack_versions?: "latest" | Record<string, string>;
124
+ signer_class?: Open<"consumer" | "business" | "employee"> | null;
125
+ document_type?: DocumentType | null;
126
+ purpose?: SessionPurpose | null;
127
+ method?: SignatureMethod;
128
+ assurance_level?: AssuranceLevel;
129
+ failure_mode?: Open<"fail_closed" | "fail_open_deferred">;
130
+ consumer_econsent?: boolean;
131
+ capture_mode?: Open<"standard" | "eu_minimal">;
132
+ receipts_enabled?: boolean;
133
+ signer_certificates_enabled?: boolean;
134
+ change_note?: string | null;
135
+ }
136
+ export interface Profile {
137
+ object: "profile";
138
+ id: string;
139
+ /** Updating a profile creates a new version; sessions and records pin the one they used. */
140
+ version: number;
141
+ livemode: boolean;
142
+ name: string;
143
+ jurisdictions: string[];
144
+ jurisdiction_mode: JurisdictionMode;
145
+ on_unknown_region: Open<"strictest" | "base_only" | "reject">;
146
+ governing_law: string | null;
147
+ allow_session_packs: boolean;
148
+ strict_jurisdictions: boolean;
149
+ pack_versions: "latest" | Record<string, string>;
150
+ signer_class: string | null;
151
+ document_type: string | null;
152
+ purpose: string | null;
153
+ method: SignatureMethod;
154
+ assurance_level: AssuranceLevel;
155
+ failure_mode: Open<"fail_closed" | "fail_open_deferred">;
156
+ consumer_econsent: boolean;
157
+ capture_mode: Open<"standard" | "eu_minimal">;
158
+ receipts_enabled: boolean;
159
+ signer_certificates_enabled: boolean;
160
+ rules_version: string | null;
161
+ baseline: string | null;
162
+ prompt_id: string | null;
163
+ change_note: string | null;
164
+ created_at: Timestamp;
165
+ /** `GET /profiles/{id}` only: record conditions waiting in advise (BC-5). */
166
+ pending_conditions?: Array<{
167
+ rule: string;
168
+ pack: string;
169
+ level: Open<"block" | "warn">;
170
+ reason: string;
171
+ }>;
172
+ versions?: Array<{
173
+ version: number;
174
+ created_at: Timestamp;
175
+ change_note: string | null;
176
+ baseline: string | null;
177
+ }>;
178
+ warnings?: string[];
179
+ }
180
+ export interface LegalSource {
181
+ title: string;
182
+ url?: string;
183
+ [key: string]: unknown;
184
+ }
185
+ export interface GuidanceItem {
186
+ rule: string;
187
+ pack?: string;
188
+ title?: string;
189
+ /** In resolutions. */
190
+ summary?: string;
191
+ /** In `profiles.guidance()`. */
192
+ text?: string;
193
+ duty_holder?: string;
194
+ supplement_types?: string[];
195
+ sources?: LegalSource[];
196
+ review_state?: Open<"draft" | "research_reviewed" | "counsel_reviewed">;
197
+ [key: string]: unknown;
198
+ }
199
+ export interface RecordConditionItem extends GuidanceItem {
200
+ level?: Open<"block" | "warn">;
201
+ state?: Open<"enforce" | "advise">;
202
+ adoption?: Open<"adopted" | "pending" | "not_applicable">;
203
+ checks?: string[];
204
+ adds_steps?: string[];
205
+ }
206
+ /** `GET /profiles/{id}/guidance`: everything that applies to a profile now (13.15). */
207
+ export interface ProfileGuidance {
208
+ object: "profile_guidance";
209
+ profile: {
210
+ id: string;
211
+ version: number;
212
+ jurisdictions: string[];
213
+ };
214
+ guidance_release: string;
215
+ baseline: {
216
+ id: string;
217
+ pack_versions: Record<string, string>;
218
+ adopted_at: Timestamp;
219
+ } | null;
220
+ record_conditions: RecordConditionItem[];
221
+ obligations: GuidanceItem[];
222
+ recommendations: GuidanceItem[];
223
+ reports: GuidanceItem[];
224
+ [key: string]: unknown;
225
+ }
226
+ /** Adoption covers every pending record condition of the profile: the endpoint takes no list of rules. */
227
+ export interface ProfileAdoptParams {
228
+ /** Why the conditions were adopted, kept with the new profile version. 500 characters at most. */
229
+ note?: string;
230
+ [key: string]: unknown;
231
+ }
232
+ export interface JurisdictionRule {
233
+ id: string;
234
+ title?: string;
235
+ summary: string;
236
+ /** How the rule's parts are classed, e.g. `Block; Obligation`. */
237
+ enforcement?: string;
238
+ parts?: Array<{
239
+ class: Open<"record_condition" | "obligation" | "recommendation" | "report">;
240
+ summary?: string;
241
+ level?: string;
242
+ duty_holder?: string;
243
+ adds_steps?: string[];
244
+ supplement_types?: string[];
245
+ [key: string]: unknown;
246
+ }>;
247
+ triggers?: string[];
248
+ scope?: Record<string, unknown>;
249
+ adds_steps?: string[];
250
+ strings?: string[];
251
+ legal_basis?: LegalSource[];
252
+ status?: Open<"active" | "retired">;
253
+ [key: string]: unknown;
254
+ }
255
+ export interface JurisdictionPack {
256
+ object: "jurisdiction_pack";
257
+ code: string;
258
+ name: string;
259
+ parent: string | null;
260
+ version: string;
261
+ status: Open<"active" | "retired">;
262
+ effective_at: Timestamp;
263
+ /** Counsel review date; null until reviewed (JR-11). */
264
+ reviewed_at: Timestamp | null;
265
+ review_state?: Open<"draft" | "research_reviewed" | "counsel_reviewed">;
266
+ description?: string;
267
+ content_hash: Sha256;
268
+ coverage: string[];
269
+ not_covered: string[];
270
+ guidance_release?: string;
271
+ rule_set_version?: string;
272
+ /** In the list. The rules themselves come with `jurisdictions.get(code)`. */
273
+ rule_count?: number;
274
+ /** The `context.facts` keys the pack's rules read (JR-18). */
275
+ fact_keys?: unknown[];
276
+ rules?: JurisdictionRule[];
277
+ exclusions?: unknown[];
278
+ retention_floors?: unknown[];
279
+ evidence_wording?: string;
280
+ prompt_block?: string;
281
+ changelog_url?: string;
282
+ [key: string]: unknown;
283
+ }
284
+ export interface JurisdictionPackVersion {
285
+ code?: string;
286
+ version: string;
287
+ effective_at?: Timestamp;
288
+ reviewed_at?: Timestamp | null;
289
+ content_hash?: Sha256;
290
+ changelog?: string | string[];
291
+ [key: string]: unknown;
292
+ }
293
+ export interface AppliedJurisdiction {
294
+ code: string;
295
+ version: string;
296
+ reason: Open<"base" | "signer_region" | "governing_law" | "organization_region" | "strictest" | "explicit">;
297
+ }
298
+ /** Wording a jurisdiction pack asks the page to carry (SS-7, JR-9). */
299
+ export interface RequiredString {
300
+ slot: string;
301
+ block: string;
302
+ rule: string;
303
+ kind?: Open<"verbatim" | "elements">;
304
+ text?: string;
305
+ translations?: Record<string, string>;
306
+ elements?: string[];
307
+ statutory?: boolean;
308
+ label?: string;
309
+ check?: boolean;
310
+ }
311
+ /** A record condition in the advise state that was evaluated and not met (BC-5). Never an error. */
312
+ export interface Advisory {
313
+ rule: string;
314
+ finding: string;
315
+ notice: string | null;
316
+ }
317
+ export interface RetentionFloor {
318
+ rule: string;
319
+ basis: string;
320
+ floor?: string;
321
+ years?: number;
322
+ months?: number;
323
+ until?: Timestamp;
324
+ }
325
+ export interface SessionSignerParams {
326
+ /** Your own stable identifier for the signer. The only personal datum webhooks carry. */
327
+ external_id: string;
328
+ email?: string | null;
329
+ name?: string | null;
330
+ phone?: string | null;
331
+ class?: Open<"consumer" | "business" | "employee"> | null;
332
+ /** ISO 3166-1 alpha-2. */
333
+ country?: string | null;
334
+ /** ISO 3166-2 (`US-CA`), or a bare subdivision code with `country` (JR-16). */
335
+ region?: string | null;
336
+ locality?: string | null;
337
+ actor_type?: Open<"human" | "electronic_agent"> | null;
338
+ operator?: string | null;
339
+ authority_reference?: string | null;
340
+ }
341
+ export interface SessionDocumentRef {
342
+ document: string;
343
+ /** A version ID, or `"current"` (the default). */
344
+ version?: string;
345
+ }
346
+ export interface SessionJurisdictionParams {
347
+ mode?: JurisdictionMode | null;
348
+ packs?: string[] | null;
349
+ governing_law?: string | null;
350
+ }
351
+ export type SessionPurpose = Open<"account_signup" | "one_time_purchase" | "free_trial" | "auto_renewal" | "contract_signature" | "nda" | "policy_update" | "other">;
352
+ export interface SessionContext {
353
+ /** The page the ceremony runs on. Must fall within the registered domain in live mode (SS-1). */
354
+ url?: string;
355
+ locale?: string;
356
+ purpose?: SessionPurpose;
357
+ /** Facts only you know, read by state-pack rules (JR-18). Unknown keys are kept and never rejected. */
358
+ facts?: Record<string, unknown>;
359
+ /** Free text, 2,000 characters, sealed in the record as asserted (SS-8). */
360
+ notes?: string;
361
+ /** Any JSON up to 16 KB, sealed in the record as asserted (SS-8). */
362
+ extra?: unknown;
363
+ }
364
+ export interface JurisdictionResolveParams {
365
+ profile: string;
366
+ signer?: Partial<SessionSignerParams>;
367
+ jurisdictions?: SessionJurisdictionParams;
368
+ documents?: SessionDocumentRef[];
369
+ context?: SessionContext;
370
+ /** `current`: what the profile's baseline enforces. `latest`: everything the latest release would enforce (BC-7). */
371
+ baseline?: Open<"current" | "latest">;
372
+ }
373
+ /** `POST /jurisdictions/resolve`: a dry run. Creates nothing and is not metered (JR-12). */
374
+ export interface JurisdictionResolution {
375
+ object: "jurisdiction_resolution";
376
+ mode: JurisdictionMode;
377
+ applied_jurisdictions: AppliedJurisdiction[];
378
+ rule_set_version: string;
379
+ rules_fired: string[];
380
+ /** Each fired rule's state for this profile: `enforce`, or `advise` until adopted (BC-5). */
381
+ rule_states?: Array<{
382
+ rule: string;
383
+ state: Open<"enforce" | "advise"> | null;
384
+ level: Open<"block" | "warn"> | null;
385
+ }>;
386
+ required_steps: string[];
387
+ required_strings: RequiredString[];
388
+ retention_floor: RetentionFloor | null;
389
+ exclusions: unknown[];
390
+ baseline?: Open<"current" | "latest">;
391
+ guidance_release: string;
392
+ record_conditions?: RecordConditionItem[];
393
+ obligations: GuidanceItem[];
394
+ recommendations: GuidanceItem[];
395
+ reports?: GuidanceItem[];
396
+ advisories: Advisory[];
397
+ warnings: string[];
398
+ }
399
+ export type SessionStatus = Open<"created" | "in_progress" | "awaiting_verification" | "ready" | "completed" | "expired" | "cancelled">;
400
+ export type CaptureMode = Open<"direct" | "server_only" | "deferred" | "imported">;
401
+ export interface SessionCreateParams {
402
+ profile: string;
403
+ signer: SessionSignerParams;
404
+ jurisdictions?: SessionJurisdictionParams;
405
+ /** 1 to 10 documents. */
406
+ documents: SessionDocumentRef[];
407
+ context?: SessionContext;
408
+ /** Your key-value pairs, 50 keys maximum. Sealed as asserted. */
409
+ metadata?: Metadata;
410
+ /** Seconds, 60 to 86,400. */
411
+ expires_in?: number;
412
+ /**
413
+ * `direct` (default): the signer's browser reports the ceremony with the
414
+ * client token. `server_only`: your server reports it with the secret key;
415
+ * every event is then tagged asserted, and the record says so.
416
+ */
417
+ capture_mode?: "direct" | "server_only";
418
+ }
419
+ export interface SessionDocument {
420
+ document_id: string;
421
+ version_id: string;
422
+ render_hash: Sha256 | null;
423
+ content_hash: Sha256;
424
+ title: string;
425
+ type: DocumentType;
426
+ language: string;
427
+ format: DocumentFormat;
428
+ }
429
+ interface SessionBase {
430
+ object: "session";
431
+ id: string;
432
+ status: SessionStatus;
433
+ livemode: boolean;
434
+ expires_at: Timestamp;
435
+ profile: {
436
+ id: string;
437
+ version: number;
438
+ };
439
+ assurance_level: AssuranceLevel;
440
+ signature_method: SignatureMethod;
441
+ capture_mode: CaptureMode;
442
+ minimal_capture: boolean;
443
+ /** The authoritative list of steps for this session. Never hard-code steps (SS-4). */
444
+ required_steps: string[];
445
+ documents: SessionDocument[];
446
+ applied_jurisdictions: AppliedJurisdiction[];
447
+ jurisdiction_mode: JurisdictionMode;
448
+ rule_set_version: string | null;
449
+ rules_fired: string[];
450
+ required_strings: RequiredString[];
451
+ retention_floor: RetentionFloor | null;
452
+ guidance_release: string | null;
453
+ advisories: Advisory[];
454
+ /** Non-blocking concerns, e.g. `state_pack_unavailable:US-WA` (SS-5). The list is open. */
455
+ warnings: string[];
456
+ }
457
+ /** What `sessions.create` returns. */
458
+ export interface SessionCreated extends SessionBase {
459
+ /** Short-lived token scoped to this session (SS-3). Hand it to the browser SDK; it is the only credential the browser gets. */
460
+ client_token: string;
461
+ /** The regional API base the browser SDK should call. */
462
+ api_url: string;
463
+ }
464
+ /** What `sessions.get` returns to a secret key. */
465
+ export interface Session extends SessionBase {
466
+ completed_steps: string[];
467
+ remaining_steps: string[];
468
+ /** Set once the ceremony completed. Confirm it with `records.get` before granting access (CP-3). */
469
+ record_id: string | null;
470
+ purpose: string | null;
471
+ locale: string | null;
472
+ signer: {
473
+ class: string | null;
474
+ country: string | null;
475
+ region: string | null;
476
+ locality: string | null;
477
+ actor_type: string | null;
478
+ };
479
+ context: {
480
+ url: string | null;
481
+ purpose: string | null;
482
+ facts: Record<string, unknown>;
483
+ };
484
+ metadata: Metadata;
485
+ created_at: Timestamp;
486
+ completed_at: Timestamp | null;
487
+ }
488
+ export interface SessionCancelled {
489
+ object: "session";
490
+ id: string;
491
+ status: Open<"cancelled">;
492
+ livemode: boolean;
493
+ }
494
+ /** One conformance result. Findings are advisory statements about measurable design facts (CC-6). */
495
+ export interface Finding {
496
+ rule: string;
497
+ status: Open<"pass" | "warn" | "block">;
498
+ /** `enforce` can refuse a live record. `advise` is evaluated and stored only (BC-5). */
499
+ state: Open<"enforce" | "advise">;
500
+ message: string;
501
+ fix?: string;
502
+ measurement?: Record<string, unknown>;
503
+ maps_to?: string[];
504
+ event_type?: string;
505
+ version_id?: string;
506
+ [key: string]: unknown;
507
+ }
508
+ export interface CeremonyEventParams {
509
+ /** e.g. `document.presented`, `notice.captured`, `intent.captured`. Read the names from `required_steps`. */
510
+ type: string;
511
+ /** Required for `document.presented`. */
512
+ version_id?: string | null;
513
+ /** The signer's clock, kept apart from the server's receipt time (EV-2). */
514
+ client_time?: string | null;
515
+ data?: Record<string, unknown> | null;
516
+ }
517
+ export interface CeremonyEvent {
518
+ object: "event";
519
+ id: string;
520
+ type: string;
521
+ /** `observed` on the direct browser channel, `asserted` for server-only sessions and for statements by the page. */
522
+ tag: Open<"observed" | "asserted">;
523
+ server_time: Timestamp;
524
+ sequence: number;
525
+ conformance: {
526
+ status: Open<"pass" | "warn" | "block">;
527
+ rules_version?: string;
528
+ findings: Finding[];
529
+ };
530
+ remaining_steps: string[];
531
+ session_status?: SessionStatus;
532
+ }
533
+ export interface SessionCompleteParams {
534
+ signature?: {
535
+ method?: SignatureMethod;
536
+ label_text?: string | null;
537
+ button_text?: string | null;
538
+ typed_name?: string | null;
539
+ };
540
+ client_time?: string | null;
541
+ }
542
+ export type RecordStatus = Open<"pending_seal" | "recorded" | "timestamped" | "anchored" | "disputed" | "voided">;
543
+ export type SignatureLevel = Open<"not_applicable" | "simple" | "advanced" | "qualified">;
544
+ /** What completing a ceremony returns (13.7). Your server must not trust the copy the browser received (CP-3). */
545
+ export interface RecordCompletion {
546
+ object: "record";
547
+ id: string;
548
+ livemode: boolean;
549
+ /** `pending_seal` when the signing key service was unreachable; the receipt follows within 60 seconds (CP-2). */
550
+ status: RecordStatus;
551
+ signed_at: Timestamp;
552
+ signature_level: SignatureLevel;
553
+ assurance_level: AssuranceLevel;
554
+ capture_mode: CaptureMode;
555
+ signer: {
556
+ external_id: string;
557
+ email: string | null;
558
+ name: string | null;
559
+ };
560
+ documents: Array<{
561
+ version_id: string;
562
+ content_hash: Sha256;
563
+ }>;
564
+ record_hash: Sha256;
565
+ receipt: string | null;
566
+ verify_url: string;
567
+ seal: {
568
+ ledger_seq: number | null;
569
+ timestamp: Open<"pending" | "attached">;
570
+ anchor: Open<"pending" | "published">;
571
+ };
572
+ guidance_release: string | null;
573
+ advisories: Advisory[];
574
+ quota_locked: boolean;
575
+ }
576
+ export interface RecordEvent {
577
+ id: string;
578
+ type: string;
579
+ step?: string | null;
580
+ tag: Open<"observed" | "asserted">;
581
+ sequence: number;
582
+ server_time: Timestamp;
583
+ client_time: string | null;
584
+ version_id?: string;
585
+ data: Record<string, unknown>;
586
+ event_hash: Sha256;
587
+ }
588
+ export interface RecordDocument {
589
+ document_id: string;
590
+ version_id: string;
591
+ content_hash: Sha256;
592
+ title?: string;
593
+ type?: DocumentType;
594
+ format?: DocumentFormat;
595
+ language?: string;
596
+ version_label?: string;
597
+ presentation_mode?: string | null;
598
+ render_hash?: Sha256 | null;
599
+ render_match?: boolean | null;
600
+ }
601
+ export interface RecordSeal {
602
+ receipt: string | null;
603
+ kid: string | null;
604
+ ledger_seq: number | null;
605
+ prev_hash: Sha256 | null;
606
+ entry_hash: Sha256 | null;
607
+ timestamp: "pending" | {
608
+ authority: string;
609
+ time: Timestamp;
610
+ kind: string;
611
+ };
612
+ checkpoint: "pending" | {
613
+ id: string;
614
+ time: Timestamp;
615
+ tree_size: number;
616
+ root: string;
617
+ leaf_index: number;
618
+ };
619
+ anchor: "pending" | {
620
+ kind: Open<"ots" | "rekor">;
621
+ time: Timestamp;
622
+ ref: string | null;
623
+ };
624
+ inclusion_proof: string[] | null;
625
+ receipt_signed_at: Timestamp | null;
626
+ committed_at: Timestamp;
627
+ }
628
+ export interface RecordAnnotation {
629
+ object?: "annotation";
630
+ id: string;
631
+ record_id?: string;
632
+ type: AnnotationType;
633
+ actor: string;
634
+ created_at: Timestamp;
635
+ data: Record<string, unknown> | null;
636
+ ledger_seq: number | null;
637
+ }
638
+ /**
639
+ * The record object (13.8) as a `full_access` or `read_only` key reads it. A
640
+ * `recording_access` key gets the status fields only: enough to confirm a
641
+ * signature server-side, nothing more.
642
+ */
643
+ export interface EscRecord {
644
+ object: "record";
645
+ id: string;
646
+ livemode: boolean;
647
+ /** Grant access only on `recorded`, `timestamped` or `anchored` (CP-3). */
648
+ status: RecordStatus;
649
+ signed_at: Timestamp;
650
+ signature_level: SignatureLevel;
651
+ assurance_level: AssuranceLevel;
652
+ capture_mode: CaptureMode;
653
+ signer: {
654
+ external_id: string;
655
+ name?: string | null;
656
+ email?: string | null;
657
+ class?: string | null;
658
+ country?: string | null;
659
+ region?: string | null;
660
+ verified_email?: string;
661
+ verified_phone?: string;
662
+ typed_name?: string;
663
+ [key: string]: unknown;
664
+ };
665
+ documents: RecordDocument[];
666
+ record_hash: Sha256;
667
+ receipt: string | null;
668
+ verify_url: string;
669
+ seal: RecordSeal | {
670
+ timestamp: Open<"pending" | "attached">;
671
+ anchor: Open<"pending" | "published">;
672
+ ledger_seq: number | null;
673
+ };
674
+ metadata: Metadata;
675
+ quota_locked: boolean;
676
+ organization?: {
677
+ legal_name: string | null;
678
+ country: string | null;
679
+ };
680
+ domain?: string | null;
681
+ profile?: {
682
+ id: string;
683
+ version: number;
684
+ };
685
+ jurisdictions?: {
686
+ mode: JurisdictionMode | null;
687
+ applied: AppliedJurisdiction[];
688
+ rule_set_version: string | null;
689
+ rules_fired: Array<{
690
+ id: string;
691
+ state: Open<"enforce" | "advise"> | null;
692
+ }>;
693
+ governing_law: string | null;
694
+ warnings: string[];
695
+ };
696
+ events?: RecordEvent[];
697
+ network?: Record<string, unknown>;
698
+ notice?: Record<string, unknown> | null;
699
+ signature?: Record<string, unknown>;
700
+ context?: SessionContext & Record<string, unknown>;
701
+ retention_floor?: Record<string, unknown> | null;
702
+ guidance_release?: string | null;
703
+ api_version?: string | null;
704
+ /** Advisory. Stored beside the record and excluded from the sealed hash. */
705
+ conformance?: {
706
+ advisory: boolean;
707
+ rules_version: string;
708
+ results: Array<{
709
+ rule: string;
710
+ status: Open<"pass" | "warn" | "block">;
711
+ message: string;
712
+ measurement: Record<string, unknown>;
713
+ }>;
714
+ };
715
+ advisories?: Advisory[];
716
+ copy_delivery?: {
717
+ channel: string;
718
+ status: string | null;
719
+ time: Timestamp | null;
720
+ };
721
+ annotations?: RecordAnnotation[];
722
+ /** Customer-supplied material, outside the sealed hash. The first 20; page the rest through `supplements.list`. */
723
+ supplements?: Array<{
724
+ id: string;
725
+ type: string | null;
726
+ received_at: Timestamp;
727
+ occurred_at: Timestamp | null;
728
+ content_hash: Sha256;
729
+ withdrawn: boolean;
730
+ }>;
731
+ certificates?: Array<{
732
+ id: string;
733
+ type: string;
734
+ status: string;
735
+ issued_at: Timestamp | null;
736
+ requester_class: string;
737
+ charge_class: string | null;
738
+ }>;
739
+ /** Set when the content was erased or purged; the hash, seal and ledger entry remain. */
740
+ content_available?: false;
741
+ content_note?: string;
742
+ }
743
+ /** An item of `records.list`. */
744
+ export interface RecordSummary {
745
+ object: "record";
746
+ id: string;
747
+ livemode: boolean;
748
+ status: RecordStatus;
749
+ signed_at: Timestamp;
750
+ signature_level: SignatureLevel;
751
+ assurance_level: AssuranceLevel;
752
+ capture_mode: CaptureMode;
753
+ signer: {
754
+ external_id: string;
755
+ region: string | null;
756
+ };
757
+ documents: Array<{
758
+ document_id: string | null;
759
+ version_id: string;
760
+ }>;
761
+ jurisdictions: {
762
+ applied: string[];
763
+ };
764
+ purpose: string | null;
765
+ record_hash: Sha256;
766
+ seal: {
767
+ status: string;
768
+ };
769
+ warnings: number;
770
+ advisories: number;
771
+ annotations: string[];
772
+ supplements: number;
773
+ quota_locked: boolean;
774
+ verify_url: string;
775
+ }
776
+ export interface RecordListParams extends ListParams {
777
+ signer_external_id?: string;
778
+ email?: string;
779
+ document_id?: string;
780
+ version_id?: string;
781
+ created_after?: Timestamp;
782
+ created_before?: Timestamp;
783
+ status?: RecordStatus;
784
+ }
785
+ export interface RecordReceipt {
786
+ object: "receipt";
787
+ record_id: string;
788
+ /** Compact JWS (ES256). Verify it offline with `esigncomply-verify`. */
789
+ receipt: string;
790
+ kid: string | null;
791
+ payload: {
792
+ iss: string;
793
+ rid: string;
794
+ dom: string;
795
+ hash: Sha256;
796
+ iat: number;
797
+ lvl: string;
798
+ asr: string;
799
+ seq: number;
800
+ prev: Sha256;
801
+ live: boolean;
802
+ [key: string]: unknown;
803
+ };
804
+ }
805
+ export interface EvidenceOptions {
806
+ /** Return the archive itself instead of a download link. */
807
+ inline?: boolean;
808
+ /** `false` leaves out the customer-supplied folder. */
809
+ supplements?: boolean;
810
+ }
811
+ /** `records.evidence(id)`: a signed download link valid for `expires_in` seconds. */
812
+ export interface EvidencePackageLink {
813
+ object: "evidence_package";
814
+ record_id: string;
815
+ url: string;
816
+ expires_in: number;
817
+ size: number;
818
+ files: Array<{
819
+ path: string;
820
+ sha256: Sha256;
821
+ size: number;
822
+ }>;
823
+ format: string;
824
+ }
825
+ export type AnnotationType = Open<"superseded" | "legal_hold" | "legal_hold_released" | "note" | "paper_copy_requested" | "consent_withdrawn" | "disputed" | "electronic_transactions_refused" | "erased">;
826
+ export interface AnnotationCreateParams {
827
+ type: Open<"superseded" | "legal_hold" | "legal_hold_released" | "note" | "paper_copy_requested">;
828
+ data?: Record<string, unknown>;
829
+ /** Free text, 4,000 characters at most. Stored in the annotation's data as `note`. */
830
+ note?: string;
831
+ }
832
+ /** A signing act your own system captured while Esign Comply was unreachable (`failure_mode: fail_open_deferred`). */
833
+ export interface DeferredRecordParams {
834
+ profile: string;
835
+ signer: Pick<SessionSignerParams, "external_id" | "email" | "name" | "class" | "country" | "region">;
836
+ /** Explicit version IDs: `current` could have changed since the act. */
837
+ documents: Array<{
838
+ document: string;
839
+ version: string;
840
+ }>;
841
+ /** When the acceptance happened, as you assert it. */
842
+ signed_at: Timestamp;
843
+ signature: {
844
+ method: SignatureMethod;
845
+ label_text?: string | null;
846
+ button_text?: string | null;
847
+ };
848
+ context?: Pick<SessionContext, "url" | "locale" | "purpose" | "notes">;
849
+ /** Why the act was deferred. */
850
+ reason?: string;
851
+ metadata?: Metadata;
852
+ [key: string]: unknown;
853
+ }
854
+ export interface SignerStatus {
855
+ object: "signer_status";
856
+ signer: {
857
+ external_id: string;
858
+ known: boolean;
859
+ erased: boolean;
860
+ };
861
+ documents: Array<{
862
+ document_id: string;
863
+ name: string;
864
+ type: DocumentType;
865
+ current_version: {
866
+ id: string;
867
+ version_label: string;
868
+ effective_at: Timestamp;
869
+ material_change: boolean;
870
+ } | null;
871
+ accepted_version: {
872
+ id: string;
873
+ version_label: string;
874
+ record_id: string;
875
+ signed_at: Timestamp;
876
+ } | null;
877
+ /** True when the current version has not been accepted and must be (DV-4). */
878
+ outstanding: boolean;
879
+ reason: string | null;
880
+ summary_of_changes: string | null;
881
+ [key: string]: unknown;
882
+ }>;
883
+ /** The documents that are outstanding. */
884
+ outstanding: unknown[];
885
+ [key: string]: unknown;
886
+ }
887
+ export interface ConsentWithdrawParams {
888
+ /** The record to attach the withdrawal to. Default: the signer's latest record in which consent to electronic records was given. */
889
+ record_id?: string;
890
+ /** What the withdrawn consent covered. Default `electronic_records`. */
891
+ scope?: string;
892
+ /** Free text kept with the annotation, 2,000 characters at most. */
893
+ note?: string;
894
+ [key: string]: unknown;
895
+ }
896
+ /** `signers.withdrawConsent()`: the withdrawal is a `consent_withdrawn` annotation on a record. */
897
+ export interface ConsentWithdrawal {
898
+ object: "consent_withdrawal";
899
+ /** The signer's external ID. */
900
+ signer: string;
901
+ record_id: string;
902
+ annotation_id: string;
903
+ recorded_at: Timestamp;
904
+ [key: string]: unknown;
905
+ }
906
+ export interface ErasureRequestParams {
907
+ /** `erasure` (default) destroys the signer's data key. `restriction` marks the signer restricted and erases nothing. */
908
+ scope?: Open<"erasure" | "restriction">;
909
+ /** The basis or reference for the request, 500 characters at most. */
910
+ basis?: string;
911
+ [key: string]: unknown;
912
+ }
913
+ /** `signers.requestErasure()`. A legal hold or a statutory retention floor blocks an erasure (RT-10). */
914
+ export interface ErasureRequest {
915
+ object: "erasure_request";
916
+ id: string;
917
+ /** The signer's external ID. */
918
+ signer: string;
919
+ scope: Open<"erasure" | "restriction">;
920
+ status: Open<"completed" | "blocked_by_hold" | "rejected">;
921
+ /** True once an erasure completed. */
922
+ erased?: boolean;
923
+ /** True once a restriction was set. */
924
+ restricted?: boolean;
925
+ /** Why the request was blocked or rejected. */
926
+ reason?: string;
927
+ note?: string;
928
+ [key: string]: unknown;
929
+ }
930
+ export type CertificateType = Open<"contemporaneous_record" | "contemporaneous_record_set" | "custodian_certification">;
931
+ export interface CertificateFilter {
932
+ record_ids?: string[];
933
+ signer_external_id?: string;
934
+ document_id?: string;
935
+ version_id?: string;
936
+ created_after?: Timestamp;
937
+ created_before?: Timestamp;
938
+ }
939
+ interface CertificateRequestBase {
940
+ /** `auto`: the packs applied on the record. Or a pack code naming the forum's variant (OC-6). */
941
+ wording?: string;
942
+ reference?: string;
943
+ /** `["supplements"]`, `["network"]` (OC-7). */
944
+ include?: string[];
945
+ share?: {
946
+ expires_in: number;
947
+ };
948
+ /** Required when the certificate would incur a charge (CERT-24). */
949
+ confirm_charge?: boolean;
950
+ reissue_of?: string;
951
+ }
952
+ /** `records.certify(id, body)`: one record. */
953
+ export interface RecordCertificateParams extends CertificateRequestBase {
954
+ type?: CertificateType;
955
+ }
956
+ /** `certificates.create(body)`: a set of records selected by filter. Asynchronous. */
957
+ export interface CertificateCreateParams extends CertificateRequestBase {
958
+ type: CertificateType;
959
+ filter: CertificateFilter;
960
+ }
961
+ export interface CertificateQuote {
962
+ units: number;
963
+ unit_amount: number;
964
+ /** Integer in the smallest currency unit. */
965
+ amount: number;
966
+ currency: string;
967
+ allowance_remaining?: number;
968
+ month_to_date?: number;
969
+ spend_limit?: number | null;
970
+ [key: string]: unknown;
971
+ }
972
+ export interface CertificateBilling {
973
+ charge_class: Open<"included" | "charged" | "enterprise" | "test" | "reissue">;
974
+ units: number;
975
+ unit_amount: number;
976
+ amount: number;
977
+ currency: string;
978
+ allowance?: {
979
+ included: number;
980
+ used: number;
981
+ remaining: number;
982
+ resets_at: Timestamp;
983
+ };
984
+ month_to_date?: number;
985
+ spend_limit?: number | null;
986
+ confirmed_by?: string | null;
987
+ }
988
+ export type IntegrityResult = Open<"pass" | "fail" | "pending" | "not_applicable">;
989
+ /** A ledger entry (`esc-ledger-v1`). `entry_hash` recomputes from the other fields: see FORMAT.md of `esigncomply-verify`. */
990
+ export interface LedgerEntry {
991
+ format: "esc-ledger-v1";
992
+ domain_id: string;
993
+ environment: "live" | "test";
994
+ seq: number;
995
+ entry_type: string;
996
+ subject_id: string;
997
+ subject_hash: Sha256;
998
+ prev_hash: Sha256;
999
+ entry_hash: Sha256;
1000
+ created_at: Timestamp;
1001
+ }
1002
+ /** A share link of a certificate (OC-8). */
1003
+ export interface CertificateShareLink {
1004
+ id: string;
1005
+ expires_at: Timestamp;
1006
+ opens?: number;
1007
+ last_opened_at?: Timestamp | null;
1008
+ /**
1009
+ * The link itself, with the access secret after `#`. Present only in the
1010
+ * response of the request that created the link (`records.certify` with
1011
+ * `share`); it is stored only as a hash and never returned again.
1012
+ */
1013
+ url?: string;
1014
+ }
1015
+ export interface Certificate {
1016
+ object: "certificate";
1017
+ id: string;
1018
+ type: CertificateType;
1019
+ status: Open<"issued" | "processing" | "requested" | "in_review" | "failed">;
1020
+ livemode: boolean;
1021
+ record_ids: string[];
1022
+ issued_at: Timestamp | null;
1023
+ requested_by?: {
1024
+ class: Open<"customer" | "signer">;
1025
+ key_id?: string;
1026
+ };
1027
+ reference?: string | null;
1028
+ wording?: string[];
1029
+ capture_mode?: CaptureMode;
1030
+ chronology?: Record<string, unknown>;
1031
+ intervals_ms?: Record<string, number>;
1032
+ verification?: {
1033
+ checked_at: Timestamp;
1034
+ record_hash: IntegrityResult;
1035
+ receipt_signature: IntegrityResult;
1036
+ timestamp_token: IntegrityResult;
1037
+ inclusion_proof: IntegrityResult;
1038
+ consistency_proof: IntegrityResult;
1039
+ storage_lock: IntegrityResult;
1040
+ [key: string]: unknown;
1041
+ };
1042
+ certificate_hash?: Sha256;
1043
+ /** The statement the certificate hash covers: `sha256(JCS(statement))`. */
1044
+ statement?: Record<string, unknown>;
1045
+ /**
1046
+ * `ledger` is the certificate's full ledger entry, which the offline
1047
+ * verifier recomputes; `ledger_seq` is the same number as `ledger.seq`.
1048
+ * Both are null until the certificate is issued.
1049
+ */
1050
+ seal?: {
1051
+ receipt: string | null;
1052
+ ledger?: LedgerEntry | null;
1053
+ ledger_seq?: number | null;
1054
+ timestamp_token?: "pending" | {
1055
+ authority: string;
1056
+ time: Timestamp | null;
1057
+ };
1058
+ [key: string]: unknown;
1059
+ };
1060
+ pdf_url?: string;
1061
+ json_url?: string;
1062
+ /** The active share link, or null. `share.url` is present only when this request created the link. */
1063
+ share?: CertificateShareLink | null;
1064
+ /** Same value as `share.url`: only in the response that created the link. */
1065
+ share_url?: string | null;
1066
+ /** Same value as `share.expires_at`: only in the response that created the link. */
1067
+ share_expires_at?: Timestamp | null;
1068
+ billing?: CertificateBilling;
1069
+ record_count?: number;
1070
+ include?: string[];
1071
+ reissue_of?: string | null;
1072
+ /** True while the public-anchor line of the certificate reads "pending" (CERT-23). */
1073
+ anchor_pending?: boolean;
1074
+ created_at?: Timestamp;
1075
+ [key: string]: unknown;
1076
+ }
1077
+ export interface CertificateListParams extends ListParams {
1078
+ record_id?: string;
1079
+ type?: CertificateType;
1080
+ status?: string;
1081
+ created_after?: Timestamp;
1082
+ created_before?: Timestamp;
1083
+ }
1084
+ export interface CertificateShareParams {
1085
+ /** Seconds, 90 days maximum (OC-8). */
1086
+ expires_in: number;
1087
+ }
1088
+ export interface CertificateShare {
1089
+ object?: "certificate_share";
1090
+ certificate_id?: string;
1091
+ /** The share link's ID (`shr_…`). */
1092
+ id?: string;
1093
+ share_url: string;
1094
+ share_expires_at: Timestamp;
1095
+ [key: string]: unknown;
1096
+ }
1097
+ /** Exactly one key. Omit the subject to attach the supplement to the domain (SM-4). */
1098
+ export type SupplementSubject = {
1099
+ record: string;
1100
+ } | {
1101
+ session: string;
1102
+ } | {
1103
+ signer: string;
1104
+ } | {
1105
+ document_version: string;
1106
+ } | {
1107
+ domain: string;
1108
+ };
1109
+ export type SupplementType = Open<"notice.sent" | "cancellation.requested" | "cancellation.completed" | "copy.delivered" | "paper_copy.delivered" | "disclosure.delivered" | "translation.delivered" | "consent.delivered" | "wage_notice.delivered" | "withdrawal.acknowledged" | "order.acknowledged" | "payment.disclosure_presented" | "language.presented" | "privacy_notice.presented" | "consent.obtained" | "record.delivered" | "sign.posted" | "erasure.completed" | "incident.reviewed" | "identity.checked" | "counsel.reviewed" | "policy.snapshot" | "screenshot" | "correspondence" | "note">;
1110
+ /** At least one of `text`, `data` or `files`. Nothing else is required (SM-1). */
1111
+ export interface SupplementCreateParams {
1112
+ subject?: SupplementSubject;
1113
+ type?: SupplementType;
1114
+ /** When the thing you are reporting happened, as you assert it. */
1115
+ occurred_at?: Timestamp;
1116
+ rule_ids?: string[];
1117
+ /** UTF-8, 20,000 characters. */
1118
+ text?: string;
1119
+ /** Any JSON value up to 256 KB. Unknown fields are kept as sent. */
1120
+ data?: unknown;
1121
+ /** Up to 10 file IDs from `files.upload`. */
1122
+ files?: string[];
1123
+ labels?: string[];
1124
+ /** Supplements are immutable; correct one by superseding it (SM-9). */
1125
+ supersedes?: string;
1126
+ }
1127
+ export interface FileObject {
1128
+ object: "file";
1129
+ id: string;
1130
+ livemode: boolean;
1131
+ name: string;
1132
+ size: number;
1133
+ content_type: string | null;
1134
+ sha256: Sha256;
1135
+ /** `stored` once Esign Comply has re-hashed the bytes; `rejected` when they do not match `sha256` or the type is refused. */
1136
+ status: Open<"pending" | "stored" | "rejected">;
1137
+ reject_reason?: string;
1138
+ /** The supplement that references the file, once one does. */
1139
+ supplement: string | null;
1140
+ created_at: Timestamp;
1141
+ /** Present on creation only: where to PUT the bytes. Valid for `upload_expires_in` seconds. */
1142
+ upload_url?: string;
1143
+ upload_method?: string;
1144
+ upload_expires_in?: number;
1145
+ /** For files above 6 MB. */
1146
+ resumable_url?: string;
1147
+ resumable_chunk_bytes?: number;
1148
+ [key: string]: unknown;
1149
+ }
1150
+ export interface Supplement {
1151
+ object: "supplement";
1152
+ id: string;
1153
+ livemode: boolean;
1154
+ subject: SupplementSubject | Record<string, string>;
1155
+ type: SupplementType | null;
1156
+ type_recognized: boolean;
1157
+ provenance: Open<"customer_supplied">;
1158
+ occurred_at: Timestamp | null;
1159
+ received_at: Timestamp;
1160
+ content_hash: Sha256;
1161
+ files: Array<Pick<FileObject, "id" | "name" | "size" | "sha256" | "status">>;
1162
+ seal: {
1163
+ receipt: string | null;
1164
+ ledger_seq: number | null;
1165
+ status: Open<"recorded" | "timestamped" | "anchored">;
1166
+ [key: string]: unknown;
1167
+ };
1168
+ /** Seconds between `occurred_at` and `received_at`. */
1169
+ gap_seconds?: number | null;
1170
+ size?: number;
1171
+ has_text?: boolean;
1172
+ has_data?: boolean;
1173
+ rule_ids?: string[];
1174
+ labels?: string[];
1175
+ supersedes?: string | null;
1176
+ withdrawn?: boolean;
1177
+ withdrawn_at?: Timestamp | null;
1178
+ submitted_by?: string;
1179
+ warnings?: string[];
1180
+ }
1181
+ export interface SupplementListParams extends ListParams {
1182
+ /** e.g. `record:rec_…`, or an object with exactly one key. */
1183
+ subject?: string | SupplementSubject;
1184
+ type?: SupplementType;
1185
+ rule_id?: string;
1186
+ label?: string;
1187
+ received_after?: Timestamp;
1188
+ received_before?: Timestamp;
1189
+ }
1190
+ export interface SupplementContent {
1191
+ object: "supplement_content";
1192
+ id: string;
1193
+ provenance: Open<"customer_supplied">;
1194
+ note?: string;
1195
+ content_hash: Sha256;
1196
+ withdrawn: boolean;
1197
+ text: string | null;
1198
+ data: unknown;
1199
+ files: Array<{
1200
+ id: string;
1201
+ name: string;
1202
+ sha256: Sha256;
1203
+ size: number;
1204
+ status: string;
1205
+ content_type?: string | null;
1206
+ download_url?: string;
1207
+ [key: string]: unknown;
1208
+ }>;
1209
+ [key: string]: unknown;
1210
+ }
1211
+ export interface SupplementTypeInfo {
1212
+ type: string;
1213
+ use?: string;
1214
+ suggested_fields?: string[];
1215
+ [key: string]: unknown;
1216
+ }
1217
+ export interface FileUploadOptions {
1218
+ /** File name as you want it shown. Default: the base name of the path. */
1219
+ name?: string;
1220
+ contentType?: string;
1221
+ }
1222
+ export interface GuidanceNotice {
1223
+ object: "guidance_notice";
1224
+ id: string;
1225
+ release: string;
1226
+ published_at: Timestamp;
1227
+ kind: Open<"law_enacted" | "law_effective" | "rule_change" | "case_law" | "regulator_guidance" | "enforcement_action" | "correction" | "product">;
1228
+ class: Open<"record_change" | "obligation" | "recommendation" | "information">;
1229
+ severity: Open<"action_required" | "recommended" | "info">;
1230
+ jurisdictions: string[];
1231
+ topics: string[];
1232
+ title: string;
1233
+ summary: string;
1234
+ effective_at: Timestamp | null;
1235
+ /** Always three separate statements, even when one is "None" (GD-7). */
1236
+ what_changes: {
1237
+ esign_comply_record: string;
1238
+ your_obligations: string;
1239
+ recommendations: string;
1240
+ };
1241
+ affected_rules: string[];
1242
+ affected_profiles?: string[];
1243
+ requires_code_change: Open<"no" | "only_to_follow_the_rule" | "to_adopt_a_record_condition">;
1244
+ update_prompt: string | null;
1245
+ review: {
1246
+ state: Open<"draft" | "research_reviewed" | "counsel_reviewed">;
1247
+ counsel_reviewed_at: Timestamp | null;
1248
+ };
1249
+ sources: LegalSource[];
1250
+ supersedes: string | null;
1251
+ acknowledgment?: {
1252
+ state: Open<"unread" | "read" | "applied" | "not_applicable">;
1253
+ [key: string]: unknown;
1254
+ };
1255
+ }
1256
+ export interface GuidanceNoticeListParams extends ListParams {
1257
+ jurisdiction?: string;
1258
+ class?: GuidanceNotice["class"];
1259
+ severity?: GuidanceNotice["severity"];
1260
+ kind?: GuidanceNotice["kind"];
1261
+ topic?: string;
1262
+ since?: Timestamp;
1263
+ affecting_profile?: string;
1264
+ }
1265
+ export interface GuidanceAcknowledgeParams {
1266
+ state: Open<"read" | "applied" | "not_applicable">;
1267
+ note?: string;
1268
+ }
1269
+ export interface GuidanceRelease {
1270
+ object?: string;
1271
+ id: string;
1272
+ published_at?: Timestamp;
1273
+ content_hash?: Sha256;
1274
+ changelog?: unknown;
1275
+ counts?: {
1276
+ added?: number;
1277
+ changed?: number;
1278
+ retired?: number;
1279
+ };
1280
+ signature?: string;
1281
+ [key: string]: unknown;
1282
+ }
1283
+ /** An update prompt (GD-9): a short reviewed block describing one change, as Markdown. */
1284
+ export interface GuidanceUpdate {
1285
+ object?: string;
1286
+ id: string;
1287
+ /** The prompt ID it updates. */
1288
+ updates?: string | null;
1289
+ markdown: string;
1290
+ [key: string]: unknown;
1291
+ }
1292
+ export type WebhookEventType = Open<"session.expired" | "session.cancelled" | "record.completed" | "record.timestamped" | "record.anchored" | "record.copy_delivered" | "record.copy_bounced" | "record.disputed" | "consent.withdrawn" | "signer.electronic_transactions_refused" | "document.version_published" | "signer.reacceptance_required" | "usage.threshold_reached" | "domain.verified" | "domain.verification_lapsed" | "conformance.run_completed" | "certificate.issued" | "certificate.failed" | "certificate.charged" | "certificate.spend_threshold_reached" | "jurisdiction.pack_updated" | "supplement.received" | "supplement.sealed" | "supplement.withdrawn" | "guidance.notice_published" | "guidance.release_published" | "profile.adoption_available" | "profile.adopted" | "profile.rolled_back">;
1293
+ /**
1294
+ * A delivered event. Payloads carry IDs and status; the only personal datum is
1295
+ * the signer's external ID (WH-5). Ignore types you do not know (WH-6).
1296
+ */
1297
+ export interface WebhookEvent<T = Record<string, unknown>> {
1298
+ object: "event";
1299
+ /** Also the `webhook-id` header. Deliveries are at-least-once: be idempotent on it (WH-4). */
1300
+ id: string;
1301
+ type: WebhookEventType;
1302
+ api_version: string;
1303
+ livemode: boolean;
1304
+ created_at: Timestamp;
1305
+ data: T;
1306
+ }
1307
+ /** `data` of `record.completed`: use it to unlock access. */
1308
+ export interface RecordCompletedData {
1309
+ record_id: string;
1310
+ session_id: string | null;
1311
+ signer_external_id: string;
1312
+ status: RecordStatus;
1313
+ record_hash: Sha256;
1314
+ signed_at: Timestamp;
1315
+ assurance_level: AssuranceLevel;
1316
+ signature_level: SignatureLevel;
1317
+ documents: Array<{
1318
+ version_id: string;
1319
+ content_hash: Sha256;
1320
+ }>;
1321
+ purpose: string | null;
1322
+ }
1323
+ export interface WebhookEndpointCreateParams {
1324
+ /** HTTPS. In test mode `http://localhost` is accepted too. */
1325
+ url: string;
1326
+ /** Event types, or omit for all. An endpoint receives a new type only if it subscribes to it or to all (WH-6). */
1327
+ events?: WebhookEventType[] | ["*"];
1328
+ description?: string | null;
1329
+ }
1330
+ export interface WebhookEndpointUpdateParams {
1331
+ url?: string;
1332
+ events?: WebhookEventType[] | ["*"];
1333
+ description?: string | null;
1334
+ status?: "enabled" | "disabled";
1335
+ }
1336
+ export interface WebhookEndpoint {
1337
+ object: "webhook_endpoint";
1338
+ id: string;
1339
+ livemode: boolean;
1340
+ url: string;
1341
+ description: string | null;
1342
+ events: string[];
1343
+ status: Open<"enabled" | "disabled">;
1344
+ /** Pinned when the endpoint was created (BC-16). */
1345
+ api_version: string;
1346
+ failing_since: Timestamp | null;
1347
+ created_at: Timestamp;
1348
+ /** Shown once, on creation: `whsec_…`. */
1349
+ secret?: string;
1350
+ }
1351
+ /** One delivery to one endpoint, as `webhooks.listDeliveries()` returns it. */
1352
+ export interface WebhookDelivery {
1353
+ object: "webhook_delivery";
1354
+ id: string;
1355
+ endpoint_id: string;
1356
+ /** The event ID: the value of the `webhook-id` header. */
1357
+ webhook_id: string;
1358
+ /** The event type, e.g. `record.completed`. */
1359
+ type: string;
1360
+ status: string;
1361
+ attempts: number;
1362
+ response_status: number | null;
1363
+ response_excerpt: string | null;
1364
+ created_at: Timestamp;
1365
+ delivered_at: Timestamp | null;
1366
+ last_attempt_at: Timestamp | null;
1367
+ /** The event, with `include: "payload"`. */
1368
+ payload?: WebhookEvent;
1369
+ [key: string]: unknown;
1370
+ }
1371
+ /**
1372
+ * `usage.get()`. Live signature events are counted in the plan's allowance period: a UTC calendar
1373
+ * month on Free, the subscription year on paid plans. Test events are counted per calendar month.
1374
+ */
1375
+ export interface Usage {
1376
+ object: "usage";
1377
+ /** `sandbox` is the id of the Free plan. */
1378
+ plan: Open<"sandbox" | "starter" | "unlimited" | "enterprise">;
1379
+ /** The name a person reads, for example `"Free"`. */
1380
+ plan_name?: string;
1381
+ subscription_status: string;
1382
+ period: {
1383
+ start: Timestamp | null;
1384
+ end: Timestamp | null;
1385
+ };
1386
+ events: {
1387
+ /** A true count for the allowance period. It can be higher than `allowance`. */
1388
+ used: number;
1389
+ quota: number | null;
1390
+ /** The period `used` is counted in. */
1391
+ period?: Open<"month" | "year">;
1392
+ period_start?: Timestamp;
1393
+ /** When the count starts again by itself. `null` while the account is locked: a lock does not lift on its own. */
1394
+ resets_at?: Timestamp | null;
1395
+ /** Live sessions that are open and not expired. Not part of `used`. */
1396
+ open_sessions?: number;
1397
+ event_packs: number;
1398
+ allowance: number | null;
1399
+ remaining: number | null;
1400
+ /** The highest of 50%, 80%, 90% and 100% of the allowance that `used` has reached. Always `ok` on plans with no limit. */
1401
+ level: Open<"ok" | "notice_50" | "notice_80" | "notice_90" | "limit_reached">;
1402
+ /** True from the moment the limit is reached until the organization pays. */
1403
+ locked?: boolean;
1404
+ locked_since?: Timestamp | null;
1405
+ event_packs_enabled: boolean;
1406
+ /** Always `null`. Kept so existing clients do not break. */
1407
+ over_quota_since: Timestamp | null;
1408
+ };
1409
+ test_events?: {
1410
+ used_this_month: number;
1411
+ quota_per_month: number | null;
1412
+ };
1413
+ certificates: {
1414
+ included: number | null;
1415
+ used: number;
1416
+ remaining: number | null;
1417
+ charged_units?: number;
1418
+ resets_at: Timestamp | null;
1419
+ charged_month_to_date: number;
1420
+ spend_limit: number | null;
1421
+ unit_amount?: number | null;
1422
+ /** False on Free: certificates exist for test records only. */
1423
+ live_available?: boolean;
1424
+ };
1425
+ verifications?: {
1426
+ sms_used: number;
1427
+ sms_included: number;
1428
+ };
1429
+ supplements: {
1430
+ count?: number;
1431
+ storage_used_bytes: number;
1432
+ storage_allowance_bytes: number | null;
1433
+ };
1434
+ [key: string]: unknown;
1435
+ }
1436
+ export interface ConformanceRunParams {
1437
+ /** Evaluate these sessions. Default: every test session since `since`. */
1438
+ session_ids?: string[];
1439
+ /** Default: the last 24 hours. */
1440
+ since?: Timestamp;
1441
+ /** Only sessions whose page URL is this one. */
1442
+ url?: string;
1443
+ /** Maximum number of sessions, 1 to 500. */
1444
+ limit?: number;
1445
+ }
1446
+ /** One rule's result across the sessions of a run (CC-4). */
1447
+ export interface ConformanceFinding {
1448
+ rule: string;
1449
+ title?: string;
1450
+ /** The worst result the rule had in the run. */
1451
+ status: Open<"pass" | "warn" | "block">;
1452
+ state: Open<"enforce" | "advise">;
1453
+ counts?: {
1454
+ pass: number;
1455
+ warn: number;
1456
+ block: number;
1457
+ };
1458
+ message: string;
1459
+ measurement?: Record<string, unknown>;
1460
+ /** Plain-language repair for the page. */
1461
+ fix?: string | null;
1462
+ maps_to?: string[];
1463
+ /** Page URLs the rule was evaluated on. */
1464
+ pages?: string[];
1465
+ example_session?: string | null;
1466
+ doc_url?: string;
1467
+ /** CSS selector of the element the finding is about, when the API reports one. */
1468
+ selector?: string;
1469
+ /** The prompt instruction it relates to, when the API reports one. */
1470
+ prompt_instruction?: string;
1471
+ [key: string]: unknown;
1472
+ }
1473
+ export interface ConformanceRun {
1474
+ object: "conformance_run";
1475
+ id: string;
1476
+ status: Open<"queued" | "running" | "completed" | "failed">;
1477
+ livemode: boolean;
1478
+ rules_version: string;
1479
+ summary: {
1480
+ sessions: number;
1481
+ rules_evaluated: number;
1482
+ pass: number;
1483
+ warn: number;
1484
+ block: number;
1485
+ status: Open<"pass" | "warn" | "block">;
1486
+ since?: Timestamp;
1487
+ };
1488
+ findings: ConformanceFinding[];
1489
+ /** The findings as Markdown, to paste back into a coding tool (CC-5). */
1490
+ markdown?: string;
1491
+ /** Findings are advisory statements about measurable design facts (CC-6). */
1492
+ note?: string;
1493
+ created_at?: Timestamp;
1494
+ [key: string]: unknown;
1495
+ }
1496
+ export type PromptUseCase = Open<"signup_terms" | "terms_update" | "checkout" | "free_trial" | "auto_renewal" | "nda" | "contract" | "econsent" | "marketing_consent" | "policy_ack" | "custom">;
1497
+ export type PromptFramework = Open<"nextjs_app" | "nextjs_pages" | "remix" | "sveltekit" | "nuxt" | "astro" | "express" | "hono" | "other">;
1498
+ export type PromptTool = Open<"cursor" | "claude_code" | "codex" | "copilot" | "windsurf" | "v0" | "lovable" | "bolt" | "replit" | "other">;
1499
+ /** One use case of a prompt, with what differs from its defaults. */
1500
+ export interface PromptUseCaseParams {
1501
+ use_case: PromptUseCase;
1502
+ assurance_level?: AssuranceLevel;
1503
+ method?: SignatureMethod;
1504
+ /** An existing profile to write into the prompt. Without it a profile is created or reused. */
1505
+ profile?: string;
1506
+ /** Up to 8 documents: an existing document ID, or `{ id?, name?, type? }`. */
1507
+ documents?: Array<string | {
1508
+ id?: string;
1509
+ name?: string;
1510
+ type?: string;
1511
+ }>;
1512
+ }
1513
+ /**
1514
+ * `prompts.generate(body)`: the wizard selections. Every field is optional;
1515
+ * each default that was applied is reported in the prompt's `warnings`.
1516
+ */
1517
+ export interface PromptGenerateParams {
1518
+ company?: string;
1519
+ /** Shorthand for one use case with its defaults. */
1520
+ use_case?: PromptUseCase;
1521
+ /** 1 to 12 use cases, each an ID or an object with its own settings. */
1522
+ use_cases?: Array<PromptUseCase | PromptUseCaseParams>;
1523
+ /** Shorthand: the existing profile of the single use case. */
1524
+ profile?: string;
1525
+ signers?: Open<"consumer" | "business" | "employee" | "mixed">;
1526
+ /** Pack codes. Any state pack adds `US-FED`. */
1527
+ jurisdictions?: string[];
1528
+ jurisdiction_mode?: JurisdictionMode;
1529
+ on_unknown_region?: Open<"strictest" | "base_only" | "reject">;
1530
+ governing_law?: string | null;
1531
+ facts?: Record<string, unknown>;
1532
+ /** Whether consumer notices are delivered electronically. `yes` or `not_sure` adds the consumer e-consent steps. */
1533
+ consumer_econsent?: Open<"yes" | "no" | "not_sure"> | boolean;
1534
+ failure_mode?: Open<"fail_closed" | "fail_open_deferred">;
1535
+ /** A framework ID, or the stack in full. */
1536
+ stack?: PromptFramework | {
1537
+ framework?: PromptFramework;
1538
+ hosting?: Open<"vercel" | "other">;
1539
+ database?: Open<"supabase" | "other">;
1540
+ language?: Open<"typescript" | "javascript">;
1541
+ };
1542
+ tool?: PromptTool;
1543
+ options?: {
1544
+ receipts?: boolean;
1545
+ confirmation?: Open<"webhook" | "lookup">;
1546
+ mobile?: boolean;
1547
+ languages?: string[];
1548
+ certificate_action?: boolean;
1549
+ reports?: string[];
1550
+ guidance_updates?: Open<"off" | "webhook" | "scheduled">;
1551
+ };
1552
+ [key: string]: unknown;
1553
+ }
1554
+ /** Whether a stored prompt is behind the block library or the pack catalogue (PG-10). */
1555
+ export interface PromptVersionStatus {
1556
+ state: Open<"current" | "update_available">;
1557
+ /** Blocks and packs that have a newer version than the one the prompt was built from. */
1558
+ behind: number;
1559
+ blocks: Array<{
1560
+ id: string;
1561
+ from: string;
1562
+ to: string;
1563
+ }>;
1564
+ packs: Array<{
1565
+ code: string;
1566
+ from: string;
1567
+ to: string;
1568
+ }>;
1569
+ guidance_release: {
1570
+ built: string;
1571
+ current: string;
1572
+ };
1573
+ }
1574
+ /** A prompt as `prompts.list()` returns it: everything except the Markdown, the files, the fact keys and the selections. */
1575
+ export interface PromptSummary {
1576
+ object?: "prompt";
1577
+ /** `esc_prompt_…`. Prompt IDs resolve permanently (BC-15). */
1578
+ id: string;
1579
+ livemode?: boolean;
1580
+ title?: string;
1581
+ content_hash?: Sha256;
1582
+ word_count?: number | null;
1583
+ guidance_release?: string;
1584
+ /** Pack codes the prompt was built from, in catalogue order. */
1585
+ jurisdictions?: string[];
1586
+ pack_versions?: Record<string, string>;
1587
+ block_versions?: Record<string, string>;
1588
+ /** The profiles the prompt names. `source`: created by this prompt, reused, or given by the caller. */
1589
+ profiles?: Array<{
1590
+ id: string;
1591
+ name?: string;
1592
+ use_case?: PromptUseCase;
1593
+ source?: Open<"created" | "reused" | "given">;
1594
+ }>;
1595
+ /** Document IDs the prompt names. */
1596
+ documents?: string[];
1597
+ /** Names of the environment variables the prompt uses. A prompt never contains a key. */
1598
+ env?: string[];
1599
+ /** Defaults that were applied and fields that were ignored, as codes. */
1600
+ warnings?: string[];
1601
+ status?: PromptVersionStatus;
1602
+ regenerated_from?: string | null;
1603
+ created_by?: string | null;
1604
+ created_at?: Timestamp;
1605
+ [key: string]: unknown;
1606
+ }
1607
+ /** A prompt with its text: `prompts.generate()` and `prompts.get(id)`. */
1608
+ export interface GeneratedPrompt extends PromptSummary {
1609
+ markdown: string;
1610
+ /** Files the prompt asks the coding tool to create or change. */
1611
+ files?: string[];
1612
+ /** `context.facts` keys the selected packs read. */
1613
+ fact_keys?: string[];
1614
+ /** The selections the prompt was generated from, in the shape `prompts.generate()` accepts. */
1615
+ selections?: PromptGenerateParams;
1616
+ }
1617
+ export interface DomainCreateParams {
1618
+ /** The registrable domain, e.g. `example.com`. */
1619
+ domain: string;
1620
+ /** Cannot be changed later. */
1621
+ region?: Open<"us" | "eu">;
1622
+ [key: string]: unknown;
1623
+ }
1624
+ /** `domains.watchJurisdictions()`: the full watched list after the change (GD-14). */
1625
+ export interface WatchedJurisdictions {
1626
+ object: "watched_jurisdictions";
1627
+ domain_id: string;
1628
+ /** Codes in upper case, without duplicates. */
1629
+ jurisdictions: string[];
1630
+ }
1631
+ export interface Domain {
1632
+ object?: "domain";
1633
+ id: string;
1634
+ domain?: string | null;
1635
+ region?: Open<"us" | "eu">;
1636
+ status?: Open<"not_started" | "pending" | "verified" | "lapsed">;
1637
+ verification?: Record<string, unknown> | null;
1638
+ /** Origins allowed to run test ceremonies besides localhost. */
1639
+ test_origins?: string[];
1640
+ api_url?: string;
1641
+ certificate_spend_limit?: number | null;
1642
+ created_at?: Timestamp;
1643
+ [key: string]: unknown;
1644
+ }
1645
+ export type ApiKeyPermission = Open<"full_access" | "recording_access" | "read_only">;
1646
+ export interface ApiKeyCreateParams {
1647
+ name: string;
1648
+ permission?: ApiKeyPermission;
1649
+ mode?: Open<"test" | "live">;
1650
+ [key: string]: unknown;
1651
+ }
1652
+ export interface ApiKey {
1653
+ object?: "api_key";
1654
+ id: string;
1655
+ name: string;
1656
+ permission: ApiKeyPermission;
1657
+ livemode?: boolean;
1658
+ /** The first characters of the key. The full key is shown once. */
1659
+ prefix?: string;
1660
+ /** Present on creation only. */
1661
+ key?: string;
1662
+ api_version?: string;
1663
+ last_used_at?: Timestamp | null;
1664
+ created_at?: Timestamp;
1665
+ [key: string]: unknown;
1666
+ }
1667
+ /** `esc.verify()`: proof status only. A record ID or hash alone reveals nothing. */
1668
+ export interface VerificationResult {
1669
+ object: "verification_result";
1670
+ valid: boolean;
1671
+ /** Set when `valid` is false, e.g. `receipt_signature_invalid`, `receipt_not_on_file`, `not_verifiable`. */
1672
+ reason?: string;
1673
+ livemode?: boolean;
1674
+ /** `live`, or a statement that a test record carries no attestation. */
1675
+ attestation?: string;
1676
+ status?: RecordStatus;
1677
+ checks?: {
1678
+ receipt_signature: IntegrityResult;
1679
+ record_hash: IntegrityResult;
1680
+ ledger_entry: IntegrityResult;
1681
+ timestamp_token: IntegrityResult;
1682
+ inclusion_proof: IntegrityResult;
1683
+ consistency_proof: IntegrityResult;
1684
+ };
1685
+ checked_at?: Timestamp;
1686
+ note?: string;
1687
+ }