esigncomply 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Esign Comply
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,280 @@
1
- # Temporary Holding Version
1
+ # esigncomply
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Server SDK and command-line tool for [Esign Comply](https://esigncomply.com):
4
+ an independent, tamper-evident record of what a person was shown and what they
5
+ agreed to on your own signup, checkout and signing pages.
6
+
7
+ This package runs on your server. It holds your secret API key, creates
8
+ sessions, confirms records and verifies webhooks. The signer's browser never
9
+ sees the key: it gets a short-lived session token and uses `@esigncomply/browser`.
10
+
11
+ ```
12
+ npm install esigncomply
13
+ ```
14
+
15
+ Node 20.19 or later. ES modules. No runtime dependencies beyond the offline
16
+ verifier, `esigncomply-verify`.
17
+
18
+ ## Try it first
19
+
20
+ ```
21
+ export ESIGNCOMPLY_API_KEY=esc_test_us_...
22
+ npx esigncomply@latest demo
23
+ ```
24
+
25
+ `demo` serves a signup page on localhost, runs a real test ceremony when you
26
+ tick the box and click "Create account", and prints the record ID.
27
+
28
+ ## Every method returns `{ data, error }`
29
+
30
+ No method throws. Exactly one of `data` and `error` is null.
31
+
32
+ ```ts
33
+ import { EsignComply } from "esigncomply";
34
+
35
+ const esc = new EsignComply(process.env.ESIGNCOMPLY_API_KEY!);
36
+
37
+ const { data, error } = await esc.records.get("rec_Z4m8");
38
+ if (error) {
39
+ // error.type, error.code, error.message, error.status, error.request_id
40
+ // and, where they apply: error.param, error.missing_steps, error.rule, error.quote, error.retry_after
41
+ return;
42
+ }
43
+ data.status; // "recorded"
44
+ ```
45
+
46
+ Branch on `error.type` first. Codes can be added at any time, so treat a
47
+ `code` you do not know as its `type`. A network failure comes back as
48
+ `{ type: "api_error", code: "network_error" }`.
49
+
50
+ The constructor is the one place that throws: it refuses to run in a browser,
51
+ because the secret key must never reach client code.
52
+
53
+ ## Record an agreement
54
+
55
+ **1. Your server starts a session** for one signer and the documents they will
56
+ see, and hands the page the client token.
57
+
58
+ ```ts
59
+ // POST /api/esigncomply/session on your server
60
+ const { data: session, error } = await esc.sessions.create(
61
+ {
62
+ profile: "prof_signup_us",
63
+ signer: { external_id: user.id, email: user.email, name: user.name, class: "consumer", country: "US", region: "US-CA" },
64
+ documents: [
65
+ { document: "doc_8Hq2", version: "current" }, // Terms of Service
66
+ { document: "doc_Pv71", version: "current" }, // Privacy Notice
67
+ ],
68
+ context: { url: "https://app.example.com/signup", locale: "en-US", purpose: "account_signup" },
69
+ },
70
+ { idempotencyKey: `signup-${user.id}` },
71
+ );
72
+ if (error) return Response.json({ error: error.message }, { status: 502 });
73
+
74
+ // Keep what you asked for, so you can check the record against it later.
75
+ await db.pendingSignups.set(session.id, { userId: user.id, versions: session.documents.map((d) => d.version_id) });
76
+
77
+ // The browser gets the token, the API URL and the steps. Never the API key.
78
+ return Response.json({ clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents });
79
+ ```
80
+
81
+ `session.required_steps` is the authoritative list of steps for this session.
82
+ Read it; do not hard-code steps.
83
+
84
+ **2. The page runs the ceremony** with `@esigncomply/browser` and the client
85
+ token, and gets back a record ID when the signer acts.
86
+
87
+ **3. Your server confirms the record before granting access.** The page's word
88
+ is not enough: anyone can post a made-up record ID to your endpoint. Read the
89
+ record with the secret key and compare it with what your server asked for.
90
+
91
+ ```ts
92
+ // POST /api/esigncomply/confirm on your server, called by your page with { sessionId, recordId }
93
+ const pending = await db.pendingSignups.get(sessionId);
94
+ const { data: record, error } = await esc.records.get(recordId);
95
+
96
+ const confirmed =
97
+ !error &&
98
+ pending !== undefined &&
99
+ ["recorded", "timestamped", "anchored"].includes(record.status) &&
100
+ record.livemode === (process.env.NODE_ENV === "production") &&
101
+ record.signer.external_id === pending.userId &&
102
+ record.documents.map((d) => d.version_id).sort().join() === [...pending.versions].sort().join();
103
+
104
+ if (!confirmed) return Response.json({ error: "No valid record of acceptance." }, { status: 403 });
105
+ await grantAccess(pending.userId, record.id);
106
+ ```
107
+
108
+ A record with status `pending_seal` is committed but not yet signed. Wait for
109
+ the `record.completed` webhook, which fires once the receipt exists.
110
+
111
+ ## Webhooks
112
+
113
+ Deliveries follow the Standard Webhooks convention: headers `webhook-id`,
114
+ `webhook-timestamp` and `webhook-signature`, an HMAC-SHA256 over
115
+ `id.timestamp.body`. Verify against the raw body, exactly as received.
116
+
117
+ ```ts
118
+ // app/api/esigncomply/webhook/route.ts (Next.js)
119
+ import { EsignComply } from "esigncomply";
120
+
121
+ const esc = new EsignComply(process.env.ESIGNCOMPLY_API_KEY!);
122
+
123
+ export async function POST(request: Request) {
124
+ const rawBody = await request.text(); // not request.json(): the signature covers the bytes
125
+ const { data: event, error } = await esc.webhooks.verify(rawBody, request.headers, process.env.ESIGNCOMPLY_WEBHOOK_SECRET!);
126
+ if (error) return new Response(error.message, { status: 400 });
127
+
128
+ // Deliveries are at-least-once: do each event once.
129
+ if (await db.webhookEvents.seen(event.id)) return new Response("ok");
130
+
131
+ switch (event.type) {
132
+ case "record.completed": {
133
+ // Payloads carry IDs and status only. Fetch the record for details.
134
+ const { data: record } = await esc.records.get(String(event.data.record_id));
135
+ if (record && record.status !== "pending_seal") await grantAccess(record.signer.external_id, record.id);
136
+ break;
137
+ }
138
+ case "consent.withdrawn":
139
+ case "record.disputed":
140
+ await flagForReview(String(event.data.record_id));
141
+ break;
142
+ default:
143
+ // New event types can be added at any time. Ignore the ones you do not know.
144
+ }
145
+ await db.webhookEvents.mark(event.id);
146
+ return new Response("ok");
147
+ }
148
+ ```
149
+
150
+ `verify` accepts a fetch `Headers` object or a plain record (`req.headers` in
151
+ Node and Express). It refuses deliveries whose timestamp is more than five
152
+ minutes from now, so a captured request cannot be replayed, and compares
153
+ signatures in constant time.
154
+
155
+ ## Idempotency and retries
156
+
157
+ - Pass `{ idempotencyKey }` on any call that creates something. A repeat with
158
+ the same key and body returns the original response, for 24 hours.
159
+ - The SDK retries up to twice (`maxRetries`): always after a `429`, waiting the
160
+ interval in `Retry-After`; and after a `5xx` or a network error only when the
161
+ call is a `GET` or carries an idempotency key, so nothing is ever done twice.
162
+
163
+ ```ts
164
+ const esc = new EsignComply(process.env.ESIGNCOMPLY_API_KEY!, {
165
+ apiVersion: "2026-11-21", // sent as Esign-Comply-Version; default: the version the key is pinned to
166
+ maxRetries: 2,
167
+ baseUrl: undefined, // default: from the key's region, or ESIGNCOMPLY_API_URL
168
+ });
169
+ ```
170
+
171
+ The host follows the region code in the key: `esc_…_us_…` calls
172
+ `https://esigncomply.com/v1`, `esc_…_eu_…` calls
173
+ `https://api.eu.esigncomply.com/v1`. For local development set
174
+ `ESIGNCOMPLY_API_URL=http://localhost:3000/v1`.
175
+
176
+ ## What is on the client
177
+
178
+ | Resource | Methods |
179
+ |---|---|
180
+ | `esc.documents` | `create`, `list`, `get` |
181
+ | `esc.documents.versions` | `create(documentId, body)`, `list`, `get`, `getContent(documentId, versionId \| "current")` |
182
+ | `esc.profiles` | `create`, `list`, `get`, `guidance(id)`, `adopt(id, { note })`, `rollback(id)` |
183
+ | `esc.jurisdictions` | `list`, `get(code)`, `versions(code)`, `resolve(body)` (dry run) |
184
+ | `esc.sessions` | `create(body, { idempotencyKey })`, `get`, `cancel` |
185
+ | `esc.records` | `list(filters)`, `get(id)`, `report(id)`, `evidence(id, { inline })`, `receipt(id)`, `annotate(id, { type, data, note })`, `certify(id, body)`, `submitDeferred(body)` |
186
+ | `esc.certificates` | `create`, `quote`, `list`, `get`, `pdf(id)`, `share(id, body)`, `revokeShare(id)` |
187
+ | `esc.supplements` | `create(body, { idempotencyKey })`, `list(filters)`, `get`, `content(id)`, `withdraw(id)`, `types()` |
188
+ | `esc.files` | `upload(pathOrBytes, { name, contentType })`, `get(id)` |
189
+ | `esc.guidance` | `notices.list / get / acknowledge`, `releases.list / get`, `updates.get(id)` |
190
+ | `esc.signers` | `records(externalId)`, `status(externalId)`, `withdrawConsent(externalId, { record_id, scope, note })`, `requestErasure(externalId, { scope, basis })` |
191
+ | `esc.webhooks` | `verify(rawBody, headers, secret)`, `create`, `list`, `update`, `delete`, `listDeliveries` |
192
+ | `esc.usage` | `get()` |
193
+ | `esc.conformance` | `run(body)`, `get(id)` |
194
+ | `esc.prompts` | `generate(body)`, `list()`, `get(id)` |
195
+ | `esc.domains` | `create`, `get`, `verify(id)`, `update`, `watchJurisdictions(id, codes)` (resolves to the watched list) |
196
+ | `esc.apiKeys` | `create`, `list`, `delete` |
197
+ | `esc.verify(receiptOrIdOrHash)` | Ask the API whether a record matches its seal. A signed receipt is sent as `receipt`, a `sha256:` hash as `record_hash`, anything else as `record_id`. A hash or an ID is answered only for a record of your key's own domain. |
198
+ | `esc.request(method, path, { body, query, idempotencyKey, token })` | Any endpoint without a method yet. Same `{ data, error }` contract. |
199
+
200
+ Types ship with the package. Enumerations are open strings: the API can add
201
+ values without a new SDK, so a `switch` needs a `default`.
202
+
203
+ **Files.** `records.report(id)` and `certificates.pdf(id)` resolve to
204
+ `{ bytes: Uint8Array, contentType }`. `records.evidence(id)` resolves to a
205
+ signed download link; with `{ inline: true }` it resolves to the ZIP bytes.
206
+
207
+ ```ts
208
+ import { verifyPackage } from "esigncomply-verify";
209
+
210
+ const { data: zip } = await esc.records.evidence("rec_Z4m8", { inline: true });
211
+ const report = await verifyPackage(zip!.bytes); // offline: no API call
212
+ ```
213
+
214
+ **Customer-supplied material.** Send what you have, in the shape you have it.
215
+ `files.upload` registers the file, sends the bytes straight to storage, and
216
+ returns the file once Esign Comply has re-hashed it.
217
+
218
+ ```ts
219
+ const { data: file } = await esc.files.upload("./renewal-notice.eml", { contentType: "message/rfc822" });
220
+ await esc.supplements.create(
221
+ { subject: { record: "rec_Z4m8" }, type: "notice.sent", text: "Renewal reminder emailed.", files: [file!.id] },
222
+ { idempotencyKey: "renewal-notice-usr_1842-2027-01" },
223
+ );
224
+ ```
225
+
226
+ **Server-only sessions.** With `capture_mode: "server_only"` your server
227
+ reports the steps itself. There is no named method for that yet; use
228
+ `esc.request("POST", `/sessions/${id}/events`, { body })` and
229
+ `esc.request("POST", `/sessions/${id}/complete`, { body, idempotencyKey })`.
230
+ Every step of such a record is tagged asserted, not observed.
231
+
232
+ ## Command line
233
+
234
+ ```
235
+ esigncomply <command> [options]
236
+ ```
237
+
238
+ Every command takes `--help`. Output is plain text; colour appears only when
239
+ stdout is a terminal. The commands read `ESIGNCOMPLY_API_KEY` and, for local
240
+ development, `ESIGNCOMPLY_API_URL`.
241
+
242
+ | Command | What it does |
243
+ |---|---|
244
+ | `esigncomply demo [--port 4310] [--auto]` | Creates (or reuses) a demo Terms of Service, Privacy Notice and profile in test mode, serves a signup page on localhost, and prints the record ID, the verify URL and the dashboard link once you sign. `--auto` drives the page with Playwright when it is installed; otherwise it reports the ceremony from the command itself as a `server_only` session and says so. Test keys only. |
245
+ | `esigncomply check --url <page> [--region US-CA …] [--json]` | The conformance checker. Opens the page at 390x844, 768x1024 and 1440x900 with Playwright, runs the ceremony at each size, tries violations that must be refused (untouched checkbox, programmatic click, another origin), and reports the findings of a conformance run for each size. `--region` dry-runs the jurisdiction resolution for a signer in that region. Exit code `1` on a blocking finding, `2` when it cannot run. Test keys only. |
246
+ | `esigncomply documents publish <file> --document <doc_id> --label <label> [--language en] [--material]` | Publishes a Markdown, HTML, text or PDF file as a new immutable version and prints its content hash. Safe to run twice. |
247
+ | `esigncomply webhooks listen --forward <url> [--secret whsec_…]` | Forwards test-mode webhook deliveries to a server on your machine, signed with your test endpoint's secret so your handler's verification runs for real. Test keys only. |
248
+ | `esigncomply verify <package.zip>` | Verifies an evidence package offline. Runs `esigncomply-verify`; needs no key and no network. |
249
+
250
+ `check` needs Playwright, which is an optional dependency:
251
+
252
+ ```
253
+ npm install --save-dev playwright
254
+ npx playwright install chromium
255
+ ```
256
+
257
+ In CI:
258
+
259
+ ```
260
+ npx esigncomply check --url http://localhost:3000/signup || exit 1
261
+ npx esigncomply check --region US-CA --region US-NY
262
+ ```
263
+
264
+ Findings are advisory statements about measurable design facts. The checker
265
+ does not state that a flow is lawful or enforceable.
266
+
267
+ ## Development
268
+
269
+ ```
270
+ pnpm --filter esigncomply-verify build # the CLI's verify command and the live test import it
271
+ pnpm --filter esigncomply test
272
+ pnpm --filter esigncomply build
273
+ ```
274
+
275
+ `test/live.test.ts` runs a whole flow against a real API and is skipped unless
276
+ both variables are set. It needs a test key and creates test-mode objects only.
277
+
278
+ ```
279
+ ESIGNCOMPLY_API_KEY=esc_test_... ESIGNCOMPLY_API_URL=http://localhost:3000/v1 pnpm --filter esigncomply test
280
+ ```
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Argument parsing by hand: no dependency for a handful of flags.
3
+ * Flags may be written `--name value` or `--name=value`. `--` ends the flags.
4
+ */
5
+ export type FlagKind = "boolean" | "string" | "list";
6
+ export declare class UsageError extends Error {
7
+ }
8
+ export interface Parsed {
9
+ positionals: string[];
10
+ flags: Record<string, string | boolean | string[] | undefined>;
11
+ }
12
+ export declare function parseArgs(argv: string[], spec: Record<string, FlagKind>, aliases?: Record<string, string>): Parsed;
13
+ export declare function str(flags: Parsed["flags"], key: string): string | undefined;
14
+ export declare function list(flags: Parsed["flags"], key: string): string[];
15
+ export declare function bool(flags: Parsed["flags"], key: string): boolean;
16
+ export declare function int(flags: Parsed["flags"], key: string, fallback: number, min: number, max: number): number;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Playwright is optional. It is loaded only by `check` and `demo --auto`, and
3
+ * only when one of them runs, so the package installs and works without it.
4
+ */
5
+ import type { Browser } from "playwright";
6
+ export declare const INSTALL_PLAYWRIGHT: string;
7
+ export type Launch = {
8
+ ok: true;
9
+ browser: Browser;
10
+ } | {
11
+ ok: false;
12
+ reason: "not_installed" | "no_browser";
13
+ detail: string;
14
+ };
15
+ /** Launch headless Chromium: Playwright's own build first, then an installed Chrome. */
16
+ export declare function launchBrowser(): Promise<Launch>;
17
+ export declare const INSTALL_BROWSER: string;
@@ -0,0 +1,80 @@
1
+ import type { EsignComply } from "../index";
2
+ import type { ConformanceRun, JurisdictionResolution } from "../types";
3
+ import { launchBrowser } from "./browser";
4
+ import { type Io } from "./io";
5
+ export declare const CHECK_HELP = "esigncomply check --url <page> [--region US-CA \u2026] [--json]\n\nThe active conformance checker (spec 12.6). It opens your page in a headless\nbrowser at 390x844, 768x1024 and 1440x900, runs the ceremony with a test\nsigner at each size, and reports the findings for the test sessions it saw.\nIt also tries things that must be refused: submitting with the checkbox\nuntouched, a programmatic click, and completing from another origin.\n\n --url <page> The page that runs the ceremony, for example http://localhost:3000/signup.\n --region <code> Dry-run the jurisdiction resolution for a signer in this region (JR-12),\n for example --region US-CA --region US-NY. Repeatable. Works without --url.\n --profile <id> Profile for the dry run. Default: the domain's only profile.\n --purpose <purpose> context.purpose for the dry run, for example auto_renewal.\n --signer-class <c> consumer (default), business or employee, for the dry run.\n --checkbox <css> The assent checkbox, when the checker cannot find it.\n --submit <css> The button that performs the signing act.\n --fill <css=value> Fill a field before submitting. Repeatable. Empty text, e-mail and\n password fields are filled with test values on their own.\n --callback <url> Your server's confirmation endpoint. The checker posts a forged\n success to it and expects a refusal (CC-3).\n --timeout <seconds> How long to wait for the ceremony to complete at each size. Default 20.\n --json Print the report as JSON.\n\nEnvironment\n ESIGNCOMPLY_API_KEY A test key (esc_test_\u2026) for the domain the page uses. Live keys are refused.\n ESIGNCOMPLY_API_URL API base URL, for local development.\n\nExit codes\n 0 no blocking finding\n 1 a blocking finding, a violation that was not refused, or a ceremony that did not complete\n 2 the check could not run (bad arguments, Playwright not installed)\n\nFindings are advisory statements about measurable design facts. The checker\ndoes not state that a flow is lawful or enforceable.\n";
6
+ export declare const VIEWPORTS: readonly [{
7
+ readonly width: 390;
8
+ readonly height: 844;
9
+ }, {
10
+ readonly width: 768;
11
+ readonly height: 1024;
12
+ }, {
13
+ readonly width: 1440;
14
+ readonly height: 900;
15
+ }];
16
+ export interface CheckFinding {
17
+ rule: string;
18
+ status: string;
19
+ state?: string;
20
+ message: string;
21
+ measurement?: Record<string, unknown>;
22
+ selector?: string;
23
+ fix?: string;
24
+ prompt_instruction?: string;
25
+ viewport?: string;
26
+ record_id?: string;
27
+ session_id?: string;
28
+ event_type?: string;
29
+ }
30
+ export interface Attempt {
31
+ id: string;
32
+ title: string;
33
+ /** `refused`: the violation was stopped, as it must be. `accepted`: it went through. `skipped`: not run. */
34
+ outcome: "refused" | "accepted" | "skipped";
35
+ detail: string;
36
+ }
37
+ interface ObservedSession {
38
+ id: string;
39
+ viewport: string;
40
+ purpose: "untouched" | "programmatic" | "ceremony";
41
+ apiBase: string;
42
+ token: string | null;
43
+ events: number;
44
+ findings: CheckFinding[];
45
+ recordId: string | null;
46
+ completeStatus: number | null;
47
+ completeError: string | null;
48
+ }
49
+ export interface CheckReport {
50
+ url: string | null;
51
+ viewports: string[];
52
+ dry_runs: Array<{
53
+ region: string;
54
+ resolution: JurisdictionResolution | null;
55
+ error: string | null;
56
+ }>;
57
+ attempts: Attempt[];
58
+ sessions: Array<Omit<ObservedSession, "token" | "findings">>;
59
+ /** False when POST /v1/conformance/runs was not available and findings were read from the records instead. */
60
+ run_endpoint_available: boolean | null;
61
+ /** One conformance run for each window size. */
62
+ runs: Array<{
63
+ viewport: string;
64
+ run: ConformanceRun;
65
+ }>;
66
+ findings: CheckFinding[];
67
+ summary: {
68
+ pass: number;
69
+ warn: number;
70
+ block: number;
71
+ };
72
+ problems: string[];
73
+ note: string;
74
+ }
75
+ export interface CheckDeps {
76
+ client?: EsignComply;
77
+ launch?: typeof launchBrowser;
78
+ }
79
+ export declare function checkCommand(argv: string[], io: Io, deps?: CheckDeps): Promise<number>;
80
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The page `esigncomply demo` serves: a plain signup form that runs a real
3
+ * test-mode ceremony. It loads the browser SDK from the API's host; when the
4
+ * bundle is not available it reports the same steps itself with fetch and the
5
+ * session's client token. The secret API key never reaches this page.
6
+ */
7
+ export interface DemoPageConfig {
8
+ /** `<API origin>/sdk/v1/esigncomply.js` */
9
+ sdkUrl: string;
10
+ noticePrefix: string;
11
+ checkboxLabel: string;
12
+ buttonLabel: string;
13
+ }
14
+ export declare function escapeHtml(text: string): string;
15
+ export declare function demoPage(config: DemoPageConfig, documents: Array<{
16
+ version_id: string;
17
+ title: string;
18
+ }>): string;
19
+ /**
20
+ * A document version rendered on its own page: the target of the links in the
21
+ * notice. `html` is the API's sanitized rendering, injected unmodified inside
22
+ * `<article data-esc-document>` so the text on the page hashes to the version's render hash.
23
+ */
24
+ export declare function documentPage(title: string, html: string, versionId: string): string;
@@ -0,0 +1,36 @@
1
+ import { type Server } from "node:http";
2
+ import type { EsignComply } from "../index";
3
+ import type { EscRecord } from "../types";
4
+ import { type Io } from "./io";
5
+ export declare const DEMO_HELP = "esigncomply demo [--port 4310] [--auto]\n\nRecord a first test signature without writing any code. The command creates a\ndemo Terms of Service, a demo Privacy Notice and a profile in test mode (or\nreuses the ones it made before), serves a signup page on localhost, and waits.\nTick the box and click \"Create account\": the page runs a real ceremony against\nthe API, this process confirms the record with the secret key, and prints the\nrecord ID, the verify URL and the dashboard link.\n\n --port <port> Port for the local page. Default 4310.\n --auto Do not wait for a person. Drive the page with Playwright when it\n is installed; otherwise report the ceremony from this process as\n a server_only session, and say so.\n\nEnvironment\n ESIGNCOMPLY_API_KEY A test key (esc_test_\u2026). Live keys are refused.\n ESIGNCOMPLY_API_URL API base URL, for local development.\n\nThe secret key stays in this process. The page receives only the session's\nclient token.\n";
6
+ interface DemoDocument {
7
+ document_id: string;
8
+ version_id: string;
9
+ title: string;
10
+ }
11
+ interface Setup {
12
+ documents: DemoDocument[];
13
+ profileId: string;
14
+ created: string[];
15
+ }
16
+ /** Find or create the demo documents and profile, so running the demo twice does not pile up copies. */
17
+ export declare function ensureDemoSetup(esc: EsignComply): Promise<Setup>;
18
+ /** Server-side confirmation (CP-3): never trust what the browser says happened; read the record with the secret key. */
19
+ export declare function confirmRecord(esc: EsignComply, recordId: string, expected: {
20
+ externalId: string;
21
+ versionIds: string[];
22
+ }): Promise<EscRecord>;
23
+ /** Report the ceremony from this process. Every step is then asserted by the caller, not observed in a browser. */
24
+ export declare function runServerOnly(esc: EsignComply, setup: Setup): Promise<EscRecord>;
25
+ interface DemoServer {
26
+ server: Server;
27
+ url: string;
28
+ /** Resolves with the first record the page completed and this process confirmed. */
29
+ done: Promise<{
30
+ record: EscRecord;
31
+ channel: string;
32
+ }>;
33
+ }
34
+ export declare function startDemoServer(esc: EsignComply, setup: Setup, port: number, io: Io): Promise<DemoServer>;
35
+ export declare function demoCommand(argv: string[], io: Io): Promise<number>;
36
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type Io } from "./io";
2
+ export declare const DOCUMENTS_HELP = "esigncomply documents publish <file> --document <doc_id> --label <version label> [options]\n\nPublish a file as a new, immutable version of a document. The API returns the\ncontent hash that every record of this version will name.\n\n --document <doc_id> The document to add the version to (required).\n --label <label> Version label, for example 2026-11-21 (required).\n --language <code> Language of this version. Default: en.\n --material Mark the change as material: earlier acceptances become\n outstanding in the signer status (DV-4).\n --summary <text> Summary of changes, shown to signers asked to accept again.\n --effective-at <time> RFC 3339 time from which the version is current. Default: now.\n --format <format> markdown, html, text or pdf. Default: from the file extension.\n --json Print the version object as JSON.\n\nEnvironment\n ESIGNCOMPLY_API_KEY A test or live key with document write access.\n ESIGNCOMPLY_API_URL API base URL, for local development.\n\nRunning the command again with the same file, document, label and language\nreturns the version already published: the call carries an idempotency key\nderived from them.\n";
3
+ export declare function documentsCommand(argv: string[], io: Io): Promise<number>;
@@ -0,0 +1,9 @@
1
+ import { type Io } from "./io";
2
+ /**
3
+ * The `esigncomply` command (spec 13.11): demo, check, documents publish,
4
+ * webhooks listen, verify. Output is plain text; colours appear only when
5
+ * stdout is a terminal.
6
+ */
7
+ export declare const HELP = "esigncomply 1.0.1\n\nUsage\n esigncomply <command> [options]\n\nCommands\n demo Serve a local signup page, run a test ceremony, print the record ID.\n check Conformance check of your page at three window sizes; exit code for CI.\n documents publish Publish a file as a new version of a document.\n webhooks listen Forward test webhook deliveries to a server on your machine.\n verify Verify an evidence package offline.\n\n esigncomply <command> --help Options of one command.\n esigncomply --version\n\nEnvironment\n ESIGNCOMPLY_API_KEY Your secret key. demo, check and webhooks listen take test keys only.\n ESIGNCOMPLY_API_URL API base URL. Default: the host for the region in the key.\n";
8
+ /** Run the command line. Returns the exit code and writes only through `io`. */
9
+ export declare function run(argv: string[], io?: Io): Promise<number>;
@@ -0,0 +1,40 @@
1
+ import { EsignComply } from "../index";
2
+ import type { EscError } from "../errors";
3
+ /** Where a command writes. Tests pass their own; nothing in the CLI writes to the console directly. */
4
+ export interface Io {
5
+ out: (text: string) => void;
6
+ err: (text: string) => void;
7
+ env: Record<string, string | undefined>;
8
+ /** Colours are used only when stdout is a terminal. */
9
+ isTTY: boolean;
10
+ }
11
+ export declare function processIo(): Io;
12
+ declare const CODES: {
13
+ readonly green: 32;
14
+ readonly red: 31;
15
+ readonly yellow: 33;
16
+ readonly dim: 2;
17
+ readonly bold: 1;
18
+ };
19
+ export declare function paint(io: Io, color: keyof typeof CODES, text: string): string;
20
+ export declare function line(io: Io, text?: string): void;
21
+ /** A client from ESIGNCOMPLY_API_KEY and ESIGNCOMPLY_API_URL. Commands that create test data refuse live keys. */
22
+ export declare function clientFromEnv(io: Io, options?: {
23
+ testOnly?: string;
24
+ }): EsignComply;
25
+ export declare function describeError(error: EscError): string;
26
+ /** An API error that ends the command. */
27
+ export declare class CommandError extends Error {
28
+ readonly exitCode: number;
29
+ constructor(message: string, exitCode?: number);
30
+ }
31
+ export declare function must<T>(result: {
32
+ data: T;
33
+ error: null;
34
+ } | {
35
+ data: null;
36
+ error: EscError;
37
+ }, doing: string): T;
38
+ /** The web origin that serves the dashboard and the browser SDK for an API base URL. */
39
+ export declare function appOrigin(baseUrl: string): string;
40
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { Io } from "./io";
2
+ export declare const VERIFY_HELP = "esigncomply verify <package.zip | directory> [--jwks <file or https URL>] [--tsa-roots <pem file>] [--json]\nesigncomply verify <certificate.json> --evidence <package.zip>\n\nVerify an evidence package offline. This runs the open-source verifier,\nesigncomply-verify: no API key, no account and no network are needed, and\nnothing is fetched unless --jwks is an https URL.\n\n --jwks <file | https URL> Check signatures against these sealing keys instead of the bundled ones.\n --tsa-roots <pem file> Trust anchors for the timestamp authority's certificate chain.\n --evidence <zip | dir> With a certificate: the evidence package of a record it covers.\n --json Print the report as JSON.\n\nExit code 0 when verified, 1 when not, 2 when the command could not run.\n\nA passing verification shows that the record matches its seal and bounds when it\nexisted. It does not establish who signed or whether any agreement is valid or\nenforceable.\n";
3
+ /** Delegates to the verifier's own command, so both commands always behave the same. */
4
+ export declare function verifyCommand(argv: string[], io: Io): Promise<number>;
@@ -0,0 +1,20 @@
1
+ import type { EsignComply } from "../index";
2
+ import type { WebhookDelivery } from "../types";
3
+ import { type Io } from "./io";
4
+ export declare const WEBHOOKS_HELP = "esigncomply webhooks listen --forward <local URL> [options]\n\nForward test-mode webhook deliveries to a server on your machine, so you can\nbuild the handler before your endpoint is reachable from the internet. Each\nevent is posted to the URL with the body Esign Comply delivers and the\nwebhook-id, webhook-timestamp and webhook-signature headers.\n\n --forward <url> Where to post deliveries, for example\n http://localhost:3000/api/esigncomply/webhook (required).\n --secret <whsec_\u2026> The signing secret of your test endpoint. The API does not\n return the signature it sent, so the command signs each\n forwarded delivery with this secret, the way Esign Comply\n signs it, and esc.webhooks.verify() accepts it. Without a\n secret, deliveries are forwarded unsigned.\n --endpoint <id> Forward the deliveries of this endpoint only.\n --interval <ms> How often to ask for new deliveries. Default 2000, minimum 1000.\n --since <time> Start from this RFC 3339 time instead of now.\n --once Ask once, forward what is there, and exit.\n\nEnvironment\n ESIGNCOMPLY_API_KEY A full-access test key (esc_test_\u2026). Live deliveries are never forwarded.\n ESIGNCOMPLY_WEBHOOK_SECRET Used when --secret is not given.\n ESIGNCOMPLY_API_URL API base URL, for local development.\n\nDeliveries exist only for registered endpoints: create a test endpoint first\n(esc.webhooks.create({ url }), or the dashboard) and keep the secret it returns.\nStop with Ctrl+C.\n";
5
+ export interface ListenDeps {
6
+ /** Posts one delivery to the local URL. Replaced in tests. */
7
+ fetch?: typeof globalThis.fetch;
8
+ sleep?: (ms: number) => Promise<void>;
9
+ /** Resolves when the command should stop (Ctrl+C). */
10
+ stop?: Promise<void>;
11
+ client?: EsignComply;
12
+ now?: () => Date;
13
+ }
14
+ /** The request the local handler receives for one delivery. */
15
+ export declare function forwardedRequest(d: WebhookDelivery, secret: string | undefined, now: Date): {
16
+ body: string;
17
+ headers: Record<string, string>;
18
+ signed: boolean;
19
+ };
20
+ export declare function webhooksCommand(argv: string[], io: Io, deps?: ListenDeps): Promise<number>;