@assinafy/cli 1.0.0 → 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/README.md +2 -2
- package/dist/cli.cjs +59 -53
- package/docs/assignments.md +2 -1
- package/docs/send.md +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,10 +122,10 @@ assinafy send contract.pdf \
|
|
|
122
122
|
--signer "Bruno <+5548999990000>" \
|
|
123
123
|
--message "Please sign" \
|
|
124
124
|
--expires-at 2026-12-31T23:59:59Z \
|
|
125
|
-
--copy-receivers
|
|
125
|
+
--copy-receivers sig_abc123,sig_def456
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
Use `--signers '<json>'` for full control (verification methods, signing order/`step`), and `--no-wait` to skip waiting for processing.
|
|
128
|
+
Use `--signers '<json>'` for full control (verification methods, signing order/`step`), and `--no-wait` to skip waiting for processing. Per the API, `--copy-receivers` takes **signer IDs** (people who only receive a copy of the finished document), not arbitrary email addresses.
|
|
129
129
|
|
|
130
130
|
### `documents`
|
|
131
131
|
|
package/dist/cli.cjs
CHANGED
|
@@ -20770,11 +20770,10 @@ var AssignmentResource = class extends BaseResource {
|
|
|
20770
20770
|
/** Create a signing assignment for a document. */
|
|
20771
20771
|
async create(documentId, payload) {
|
|
20772
20772
|
const docId = this.requireId(documentId, "Document ID");
|
|
20773
|
-
const signers = extractSignerRefs(payload);
|
|
20774
20773
|
const body = buildAssignmentPayload(payload);
|
|
20775
20774
|
this.logger.info("Creating assignment", {
|
|
20776
20775
|
documentId: docId,
|
|
20777
|
-
signers: signers.length
|
|
20776
|
+
signers: body.signers.length
|
|
20778
20777
|
});
|
|
20779
20778
|
return this.call(
|
|
20780
20779
|
"Failed to create assignment",
|
|
@@ -21369,15 +21368,19 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
21369
21368
|
// src/api/support/webhook-verifier.ts
|
|
21370
21369
|
var import_node_crypto = require("crypto");
|
|
21371
21370
|
var WebhookVerifier = class {
|
|
21372
|
-
constructor(webhookSecret) {
|
|
21371
|
+
constructor(webhookSecret, options = {}) {
|
|
21373
21372
|
this.webhookSecret = webhookSecret;
|
|
21373
|
+
this.algorithm = options.algorithm ?? "sha256";
|
|
21374
|
+
this.encoding = options.encoding ?? "hex";
|
|
21374
21375
|
}
|
|
21375
21376
|
webhookSecret;
|
|
21376
|
-
|
|
21377
|
+
algorithm;
|
|
21378
|
+
encoding;
|
|
21379
|
+
/** Returns `true` if `signature` is a valid HMAC of `payload` under the configured scheme. */
|
|
21377
21380
|
verify(payload, signature) {
|
|
21378
21381
|
if (!this.webhookSecret || !signature) return false;
|
|
21379
21382
|
const buf = typeof payload === "string" ? Buffer.from(payload, "utf8") : payload;
|
|
21380
|
-
const expected = (0, import_node_crypto.createHmac)(
|
|
21383
|
+
const expected = (0, import_node_crypto.createHmac)(this.algorithm, this.webhookSecret).update(buf).digest(this.encoding);
|
|
21381
21384
|
const provided = signature.trim();
|
|
21382
21385
|
const a = Buffer.from(expected, "utf8");
|
|
21383
21386
|
const b3 = Buffer.from(provided, "utf8");
|
|
@@ -21567,7 +21570,7 @@ var CliError = class extends Error {
|
|
|
21567
21570
|
};
|
|
21568
21571
|
function normalizeError(err) {
|
|
21569
21572
|
if (err instanceof CliError) {
|
|
21570
|
-
return { message: err.message, code: err.code };
|
|
21573
|
+
return { message: err.message, code: err.code, exitCode: err.exitCode };
|
|
21571
21574
|
}
|
|
21572
21575
|
if (err instanceof ApiError) {
|
|
21573
21576
|
return {
|
|
@@ -21627,12 +21630,16 @@ function splitList(raw) {
|
|
|
21627
21630
|
function collect(value, previous = []) {
|
|
21628
21631
|
return [...previous, value];
|
|
21629
21632
|
}
|
|
21630
|
-
function parseInteger(raw, flag) {
|
|
21633
|
+
function parseInteger(raw, flag, options = {}) {
|
|
21631
21634
|
if (raw === void 0) return void 0;
|
|
21632
|
-
const
|
|
21633
|
-
if (
|
|
21635
|
+
const trimmed = raw.trim();
|
|
21636
|
+
if (!/^-?\d+$/.test(trimmed)) {
|
|
21634
21637
|
throw new CliError(`${flag} must be an integer.`);
|
|
21635
21638
|
}
|
|
21639
|
+
const n = Number(trimmed);
|
|
21640
|
+
if (options.min !== void 0 && n < options.min) {
|
|
21641
|
+
throw new CliError(`${flag} must be ${options.min} or greater.`);
|
|
21642
|
+
}
|
|
21636
21643
|
return n;
|
|
21637
21644
|
}
|
|
21638
21645
|
|
|
@@ -21675,7 +21682,41 @@ function printError(err, config) {
|
|
|
21675
21682
|
writeErr(import_picocolors.default.dim(` (HTTP ${normalized.statusCode})`));
|
|
21676
21683
|
}
|
|
21677
21684
|
}
|
|
21678
|
-
process.exitCode = 1;
|
|
21685
|
+
process.exitCode = normalized.exitCode ?? 1;
|
|
21686
|
+
}
|
|
21687
|
+
|
|
21688
|
+
// src/lib/client.ts
|
|
21689
|
+
function createClient(config, options = {}) {
|
|
21690
|
+
const apiKey = options.preferToken ? void 0 : config.apiKey;
|
|
21691
|
+
const token = config.token;
|
|
21692
|
+
if (options.preferToken && !token && !options.allowUnauthenticated) {
|
|
21693
|
+
throw new CliError(
|
|
21694
|
+
"This command requires a JWT access token. Run `assinafy auth login <email>` and pass the returned token with --token or ASSINAFY_TOKEN."
|
|
21695
|
+
);
|
|
21696
|
+
}
|
|
21697
|
+
if (!apiKey && !token && !options.allowUnauthenticated) {
|
|
21698
|
+
throw new CliError(
|
|
21699
|
+
"No credentials found. Set one with `assinafy config set --api-key <key>`, pass --api-key, or set ASSINAFY_API_KEY."
|
|
21700
|
+
);
|
|
21701
|
+
}
|
|
21702
|
+
const clientOptions = {
|
|
21703
|
+
baseUrl: config.baseUrl,
|
|
21704
|
+
allowUnauthenticated: options.allowUnauthenticated
|
|
21705
|
+
};
|
|
21706
|
+
if (apiKey) clientOptions.apiKey = apiKey;
|
|
21707
|
+
else if (token) clientOptions.token = token;
|
|
21708
|
+
if (config.accountId) clientOptions.accountId = config.accountId;
|
|
21709
|
+
if (config.webhookSecret) clientOptions.webhookSecret = config.webhookSecret;
|
|
21710
|
+
return new AssinafyClient(clientOptions);
|
|
21711
|
+
}
|
|
21712
|
+
function requireAccountId(config, override) {
|
|
21713
|
+
const id = override ?? config.accountId;
|
|
21714
|
+
if (!id) {
|
|
21715
|
+
throw new CliError(
|
|
21716
|
+
"No account ID found. Pass --account-id <id>, set ASSINAFY_ACCOUNT_ID, or run `assinafy config set --account-id <id>`."
|
|
21717
|
+
);
|
|
21718
|
+
}
|
|
21719
|
+
return id;
|
|
21679
21720
|
}
|
|
21680
21721
|
|
|
21681
21722
|
// src/lib/config.ts
|
|
@@ -21742,40 +21783,6 @@ function normalizeBaseUrl(raw) {
|
|
|
21742
21783
|
return raw.endsWith("/") ? raw.slice(0, -1) : raw;
|
|
21743
21784
|
}
|
|
21744
21785
|
|
|
21745
|
-
// src/lib/client.ts
|
|
21746
|
-
function createClient(config, options = {}) {
|
|
21747
|
-
const apiKey = options.preferToken ? void 0 : config.apiKey;
|
|
21748
|
-
const token = config.token;
|
|
21749
|
-
if (options.preferToken && !token && !options.allowUnauthenticated) {
|
|
21750
|
-
throw new CliError(
|
|
21751
|
-
"This command requires a JWT access token. Run `assinafy auth login <email>` and pass the returned token with --token or ASSINAFY_TOKEN."
|
|
21752
|
-
);
|
|
21753
|
-
}
|
|
21754
|
-
if (!apiKey && !token && !options.allowUnauthenticated) {
|
|
21755
|
-
throw new CliError(
|
|
21756
|
-
"No credentials found. Set one with `assinafy config set --api-key <key>`, pass --api-key, or set ASSINAFY_API_KEY."
|
|
21757
|
-
);
|
|
21758
|
-
}
|
|
21759
|
-
const clientOptions = {
|
|
21760
|
-
baseUrl: config.baseUrl,
|
|
21761
|
-
allowUnauthenticated: options.allowUnauthenticated
|
|
21762
|
-
};
|
|
21763
|
-
if (apiKey) clientOptions.apiKey = apiKey;
|
|
21764
|
-
else if (token) clientOptions.token = token;
|
|
21765
|
-
if (config.accountId) clientOptions.accountId = config.accountId;
|
|
21766
|
-
if (config.webhookSecret) clientOptions.webhookSecret = config.webhookSecret;
|
|
21767
|
-
return new AssinafyClient(clientOptions);
|
|
21768
|
-
}
|
|
21769
|
-
function requireAccountId(config, override) {
|
|
21770
|
-
const id = override ?? config.accountId;
|
|
21771
|
-
if (!id) {
|
|
21772
|
-
throw new CliError(
|
|
21773
|
-
"No account ID found. Pass --account-id <id>, set ASSINAFY_ACCOUNT_ID, or run `assinafy config set --account-id <id>`."
|
|
21774
|
-
);
|
|
21775
|
-
}
|
|
21776
|
-
return id;
|
|
21777
|
-
}
|
|
21778
|
-
|
|
21779
21786
|
// src/lib/run.ts
|
|
21780
21787
|
function getGlobals(command) {
|
|
21781
21788
|
const opts = command.optsWithGlobals();
|
|
@@ -22444,7 +22451,7 @@ function resolveSigners(signersJson, signerIdsCsv) {
|
|
|
22444
22451
|
}
|
|
22445
22452
|
return ids;
|
|
22446
22453
|
}
|
|
22447
|
-
var createCommand2 = new Command("create").description("Create a signing assignment for a document").argument("<documentId>", "Document ID").option("--signer-ids <csv>", "Comma-separated signer IDs").option("--signers <json>", "JSON array of signer refs (with verification_method, step, \u2026)").option("--method <method>", "virtual or collect", "virtual").option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated
|
|
22454
|
+
var createCommand2 = new Command("create").description("Create a signing assignment for a document").argument("<documentId>", "Document ID").option("--signer-ids <csv>", "Comma-separated signer IDs").option("--signers <json>", "JSON array of signer refs (with verification_method, step, \u2026)").option("--method <method>", "virtual or collect", "virtual").option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").action(async (documentId, opts, command) => {
|
|
22448
22455
|
await runWithClient(command, async ({ client, config }) => {
|
|
22449
22456
|
const payload = {
|
|
22450
22457
|
method: opts.method,
|
|
@@ -22863,8 +22870,8 @@ function addListOptions(command) {
|
|
|
22863
22870
|
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
22864
22871
|
function listParams(flags) {
|
|
22865
22872
|
const params = {};
|
|
22866
|
-
const page = parseInteger(flags.page, "--page");
|
|
22867
|
-
const perPage = parseInteger(flags.perPage, "--per-page");
|
|
22873
|
+
const page = parseInteger(flags.page, "--page", { min: 1 });
|
|
22874
|
+
const perPage = parseInteger(flags.perPage, "--per-page", { min: 1 });
|
|
22868
22875
|
if (page !== void 0) params.page = page;
|
|
22869
22876
|
if (perPage !== void 0) params["per-page"] = perPage;
|
|
22870
22877
|
if (flags.search) params.search = flags.search;
|
|
@@ -23143,8 +23150,7 @@ var statusesCommand = new Command("statuses").description("List every possible d
|
|
|
23143
23150
|
config,
|
|
23144
23151
|
(rows) => renderTable(rows, [
|
|
23145
23152
|
{ header: "CODE", value: (r2) => r2.code },
|
|
23146
|
-
{ header: "DELETABLE", value: (r2) => r2.deletable }
|
|
23147
|
-
{ header: "DESCRIPTION", value: (r2) => r2.description }
|
|
23153
|
+
{ header: "DELETABLE", value: (r2) => r2.deletable }
|
|
23148
23154
|
])
|
|
23149
23155
|
);
|
|
23150
23156
|
});
|
|
@@ -23191,8 +23197,8 @@ var progressCommand = new Command("progress").description("Show signing progress
|
|
|
23191
23197
|
});
|
|
23192
23198
|
var waitCommand = new Command("wait").description("Poll a document until it is ready (or fails / times out)").argument("<id>", "Document ID").option("--timeout <ms>", "Maximum time to wait in milliseconds", "30000").option("--interval <ms>", "Poll interval in milliseconds", "2000").action(async (id, opts, command) => {
|
|
23193
23199
|
await runWithClient(command, async ({ client, config }) => {
|
|
23194
|
-
const maxWaitMs = parseInteger(opts.timeout, "--timeout");
|
|
23195
|
-
const pollIntervalMs = parseInteger(opts.interval, "--interval");
|
|
23200
|
+
const maxWaitMs = parseInteger(opts.timeout, "--timeout", { min: 1 });
|
|
23201
|
+
const pollIntervalMs = parseInteger(opts.interval, "--interval", { min: 1 });
|
|
23196
23202
|
const doc = await withSpinner(
|
|
23197
23203
|
"Waiting for document",
|
|
23198
23204
|
config,
|
|
@@ -23416,7 +23422,7 @@ function resolveSigners2(signerSpecs, signersJson) {
|
|
|
23416
23422
|
}
|
|
23417
23423
|
return signerSpecs.map(parseSignerSpec);
|
|
23418
23424
|
}
|
|
23419
|
-
var sendCommand = new Command("send").description("Upload a PDF, create signers, and request signatures in one step").argument("<file>", "Path to the PDF file").option("--signer <spec>", 'Signer as "Name <email-or-phone>" (repeatable)', collect, []).option("--signers <json>", "JSON array of signer objects (overrides --signer)").option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated
|
|
23425
|
+
var sendCommand = new Command("send").description("Upload a PDF, create signers, and request signatures in one step").argument("<file>", "Path to the PDF file").option("--signer <spec>", 'Signer as "Name <email-or-phone>" (repeatable)', collect, []).option("--signers <json>", "JSON array of signer objects (overrides --signer)").option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").option("--metadata <json>", "JSON object of metadata to attach to the document").option("--no-wait", "Do not wait for the document to finish processing").action(async (file, opts, command) => {
|
|
23420
23426
|
await runWithClient(command, async ({ client, config }) => {
|
|
23421
23427
|
const accountId = requireAccountId(config);
|
|
23422
23428
|
const signers = resolveSigners2(opts.signer, opts.signers);
|
|
@@ -24116,7 +24122,7 @@ function setupCliExitHandler() {
|
|
|
24116
24122
|
// package.json
|
|
24117
24123
|
var package_default = {
|
|
24118
24124
|
name: "@assinafy/cli",
|
|
24119
|
-
version: "1.0.
|
|
24125
|
+
version: "1.0.1",
|
|
24120
24126
|
description: "The official command-line interface for the Assinafy digital-signature API",
|
|
24121
24127
|
license: "MIT",
|
|
24122
24128
|
type: "module",
|
package/docs/assignments.md
CHANGED
|
@@ -37,7 +37,8 @@ Options:
|
|
|
37
37
|
--method <method> virtual or collect (default: "virtual")
|
|
38
38
|
--message <message> Message shown to signers
|
|
39
39
|
--expires-at <iso8601> Expiration timestamp
|
|
40
|
-
--copy-receivers <csv> Comma-separated
|
|
40
|
+
--copy-receivers <csv> Comma-separated signer IDs to receive a copy of the
|
|
41
|
+
document
|
|
41
42
|
-h, --help display help for command
|
|
42
43
|
```
|
|
43
44
|
|
package/docs/send.md
CHANGED
|
@@ -16,7 +16,8 @@ Options:
|
|
|
16
16
|
--signers <json> JSON array of signer objects (overrides --signer)
|
|
17
17
|
--message <message> Message shown to signers
|
|
18
18
|
--expires-at <iso8601> Expiration timestamp
|
|
19
|
-
--copy-receivers <csv> Comma-separated
|
|
19
|
+
--copy-receivers <csv> Comma-separated signer IDs to receive a copy of the
|
|
20
|
+
document
|
|
20
21
|
--metadata <json> JSON object of metadata to attach to the document
|
|
21
22
|
--no-wait Do not wait for the document to finish processing
|
|
22
23
|
-h, --help display help for command
|