@assinafy/cli 2.5.3 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +1 -1
- package/README.en.md +24 -3
- package/README.md +22 -2
- package/dist/api.cjs +98 -17
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +98 -17
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +578 -404
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/api/resources/assignments.d.ts +7 -1
- package/dist/types/api/resources/assignments.d.ts.map +1 -1
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/resources/signer-documents.d.ts +8 -4
- package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
- package/dist/types/api/resources/webhooks.d.ts +10 -5
- package/dist/types/api/resources/webhooks.d.ts.map +1 -1
- package/dist/types/api/support/webhook-verifier.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +87 -4
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/api/utils.d.ts.map +1 -1
- package/docs/README.md +1 -1
- package/docs/api-operations.json +49 -1
- package/docs/api-reference.md +464 -45
- package/docs/assignments.md +67 -9
- package/docs/sdk-reference.md +81 -8
- package/docs/signer.md +27 -0
- package/docs/signers.md +14 -12
- package/docs/webhooks.md +18 -2
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -21173,7 +21173,8 @@ var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
|
21173
21173
|
var VERIFICATION_METHODS = [
|
|
21174
21174
|
"Email",
|
|
21175
21175
|
"Whatsapp",
|
|
21176
|
-
"DigitalCertificate"
|
|
21176
|
+
"DigitalCertificate",
|
|
21177
|
+
"IdDocumentFaceMatchBasic"
|
|
21177
21178
|
];
|
|
21178
21179
|
var NOTIFICATION_METHODS = ["Email", "Whatsapp"];
|
|
21179
21180
|
function handleAssinafyResponse(response) {
|
|
@@ -21532,6 +21533,53 @@ function normaliseSignerRef(ref, options) {
|
|
|
21532
21533
|
throw new ValidationError("Invalid signer reference", { ref });
|
|
21533
21534
|
}
|
|
21534
21535
|
var AssignmentResource = class extends BaseResource {
|
|
21536
|
+
/** Fetch an account review and available evidence for a signer's identity verification. */
|
|
21537
|
+
async getIdentityVerification(documentId, assignmentId, signerId) {
|
|
21538
|
+
const docId = this.requireId(documentId, "Document ID");
|
|
21539
|
+
const asgId = this.requireId(assignmentId, "Assignment ID");
|
|
21540
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
21541
|
+
return this.call(
|
|
21542
|
+
"Failed to fetch signer identity review",
|
|
21543
|
+
() => this.http.get(
|
|
21544
|
+
`/documents/${docId}/assignments/${asgId}/signers/${sid}/identity-verification`
|
|
21545
|
+
)
|
|
21546
|
+
);
|
|
21547
|
+
}
|
|
21548
|
+
/** Download JPEG/PNG evidence or the document PDF, available only while the review is open. */
|
|
21549
|
+
async downloadIdentityVerificationImage(documentId, assignmentId, signerId, name) {
|
|
21550
|
+
const docId = this.requireId(documentId, "Document ID");
|
|
21551
|
+
const asgId = this.requireId(assignmentId, "Assignment ID");
|
|
21552
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
21553
|
+
if (!["document_front", "document_back", "document_pdf", "face"].includes(name)) {
|
|
21554
|
+
throw new ValidationError("Unknown identity verification image name");
|
|
21555
|
+
}
|
|
21556
|
+
return this.callBinary(
|
|
21557
|
+
"Failed to download identity review image",
|
|
21558
|
+
() => this.http.get(
|
|
21559
|
+
`/documents/${docId}/assignments/${asgId}/signers/${sid}/identity-verification/images/${name}`,
|
|
21560
|
+
{ responseType: "arraybuffer" }
|
|
21561
|
+
)
|
|
21562
|
+
);
|
|
21563
|
+
}
|
|
21564
|
+
/** Approve certification or reject/cancel the document; the optional note is private to reviewers. */
|
|
21565
|
+
async reviewIdentityVerification(documentId, assignmentId, signerId, payload) {
|
|
21566
|
+
const docId = this.requireId(documentId, "Document ID");
|
|
21567
|
+
const asgId = this.requireId(assignmentId, "Assignment ID");
|
|
21568
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
21569
|
+
if (!payload || !["Approved", "Rejected"].includes(payload.decision)) {
|
|
21570
|
+
throw new ValidationError("decision must be Approved or Rejected");
|
|
21571
|
+
}
|
|
21572
|
+
if (payload.note != null && (typeof payload.note !== "string" || [...payload.note].length > 2e3)) {
|
|
21573
|
+
throw new ValidationError("note must contain at most 2000 characters");
|
|
21574
|
+
}
|
|
21575
|
+
return this.call(
|
|
21576
|
+
"Failed to decide signer identity review",
|
|
21577
|
+
() => this.http.post(
|
|
21578
|
+
`/documents/${docId}/assignments/${asgId}/signers/${sid}/identity-verification/review`,
|
|
21579
|
+
{ decision: payload.decision, note: payload.note }
|
|
21580
|
+
)
|
|
21581
|
+
);
|
|
21582
|
+
}
|
|
21535
21583
|
/**
|
|
21536
21584
|
* List assignments across the account (`GET /assignments`).
|
|
21537
21585
|
*
|
|
@@ -21786,6 +21834,7 @@ var DOCUMENT_SORTS = ["name", "-name", "updated_at", "-updated_at"];
|
|
|
21786
21834
|
var READY_STATUSES = /* @__PURE__ */ new Set([
|
|
21787
21835
|
"metadata_ready",
|
|
21788
21836
|
"pending_signature",
|
|
21837
|
+
"pending_identity_review",
|
|
21789
21838
|
"certificated"
|
|
21790
21839
|
]);
|
|
21791
21840
|
var FAILED_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -22629,6 +22678,25 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
22629
22678
|
() => this.http.get("/signers/self", signerAccessConfig(code))
|
|
22630
22679
|
);
|
|
22631
22680
|
}
|
|
22681
|
+
/** `GET /signers/identity-verification` — session status, capture URL and restart eligibility. */
|
|
22682
|
+
async getIdentityVerification(signerAccessCode) {
|
|
22683
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22684
|
+
return this.call(
|
|
22685
|
+
"Failed to fetch identity verification",
|
|
22686
|
+
() => this.http.get("/signers/identity-verification", signerAccessConfig(code))
|
|
22687
|
+
);
|
|
22688
|
+
}
|
|
22689
|
+
/** `POST /signers/identity-verification` — open a hosted session after the signer's explicit consent. */
|
|
22690
|
+
async startIdentityVerification(signerAccessCode, payload) {
|
|
22691
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22692
|
+
if (payload?.consent !== true) {
|
|
22693
|
+
throw new ValidationError("Explicit biometric-processing consent is required");
|
|
22694
|
+
}
|
|
22695
|
+
return this.call(
|
|
22696
|
+
"Failed to start identity verification",
|
|
22697
|
+
() => this.http.post("/signers/identity-verification", { consent: true }, signerAccessConfig(code))
|
|
22698
|
+
);
|
|
22699
|
+
}
|
|
22632
22700
|
/**
|
|
22633
22701
|
* `PUT /signers/accept-terms?signer-access-code=…` — accept the platform
|
|
22634
22702
|
* terms as the signer.
|
|
@@ -22932,9 +23000,10 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
|
22932
23000
|
email: payload.email,
|
|
22933
23001
|
whatsapp_phone_number: payload.whatsapp_phone_number ?? payload.phone
|
|
22934
23002
|
};
|
|
22935
|
-
|
|
22936
|
-
|
|
22937
|
-
|
|
23003
|
+
if (payload.government_id !== void 0) {
|
|
23004
|
+
normalised.government_id = payload.government_id;
|
|
23005
|
+
} else if (payload.cpf) {
|
|
23006
|
+
const digits = payload.cpf.replace(/\D/g, "");
|
|
22938
23007
|
if (digits) normalised[useGovernmentId ? "government_id" : "cpf"] = digits;
|
|
22939
23008
|
}
|
|
22940
23009
|
if ("metadata" in payload && payload.metadata !== void 0) {
|
|
@@ -23173,19 +23242,21 @@ var WebhookResource = class extends BaseResource {
|
|
|
23173
23242
|
() => this.http.put(`/accounts/${id}/webhooks/inactivate`)
|
|
23174
23243
|
);
|
|
23175
23244
|
}
|
|
23176
|
-
/**
|
|
23177
|
-
async listEndpoints(accountId) {
|
|
23245
|
+
/** List webhook endpoints, oldest first; `url` matches the registered value exactly. */
|
|
23246
|
+
async listEndpoints(accountId, params = {}) {
|
|
23178
23247
|
const id = this.accountId(accountId);
|
|
23248
|
+
validateWebhookFields(params);
|
|
23179
23249
|
return this.call(
|
|
23180
23250
|
"Failed to list webhook endpoints",
|
|
23181
|
-
() => this.http.get(`/accounts/${id}/webhooks/endpoints
|
|
23251
|
+
() => this.http.get(`/accounts/${id}/webhooks/endpoints`, { params: cleanParams({ ...params }) })
|
|
23182
23252
|
);
|
|
23183
23253
|
}
|
|
23184
23254
|
/**
|
|
23185
23255
|
* `POST /accounts/{accountId}/webhooks/endpoints` — register another
|
|
23186
23256
|
* endpoint. Accounts allow 1 endpoint, or up to 3 on paid plans (`403` past
|
|
23187
23257
|
* the limit); URLs must be unique per workspace. Omitted `events` uses the
|
|
23188
|
-
* same default set as {@link register}.
|
|
23258
|
+
* same default set as {@link register}. Signed creation returns `secret`
|
|
23259
|
+
* once, including to OAuth applications; save it securely.
|
|
23189
23260
|
*/
|
|
23190
23261
|
async createEndpoint(payload, accountId) {
|
|
23191
23262
|
if (!payload.url) throw new ValidationError("Webhook URL is required");
|
|
@@ -23233,6 +23304,16 @@ var WebhookResource = class extends BaseResource {
|
|
|
23233
23304
|
() => this.http.delete(`/accounts/${id}/webhooks/endpoints/${eid}`)
|
|
23234
23305
|
);
|
|
23235
23306
|
}
|
|
23307
|
+
/** Delete the endpoint whose URL exactly matches `url`; returns 404 when none matches. */
|
|
23308
|
+
async deleteEndpointByUrl(url2, accountId) {
|
|
23309
|
+
if (!url2) throw new ValidationError("Webhook URL is required");
|
|
23310
|
+
validateWebhookFields({ url: url2 });
|
|
23311
|
+
const id = this.accountId(accountId);
|
|
23312
|
+
return this.call(
|
|
23313
|
+
"Failed to delete webhook endpoint by URL",
|
|
23314
|
+
() => this.http.delete(`/accounts/${id}/webhooks/endpoints`, { params: { url: url2 } })
|
|
23315
|
+
);
|
|
23316
|
+
}
|
|
23236
23317
|
/**
|
|
23237
23318
|
* `GET …/endpoints/{endpointId}/secret` — the `whsec_` signing secret.
|
|
23238
23319
|
* Returns `400` when signing is disabled. Not available to OAuth applications.
|
|
@@ -23390,12 +23471,10 @@ function readHeader(headers, name) {
|
|
|
23390
23471
|
if (typeof headers.get === "function") {
|
|
23391
23472
|
return headers.get(name) ?? void 0;
|
|
23392
23473
|
}
|
|
23393
|
-
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
|
|
23397
|
-
}
|
|
23398
|
-
return void 0;
|
|
23474
|
+
const matches = Object.entries(headers).filter(([key]) => key.toLowerCase() === name);
|
|
23475
|
+
if (matches.length !== 1) return void 0;
|
|
23476
|
+
const value = matches[0]?.[1];
|
|
23477
|
+
return Array.isArray(value) ? value.length === 1 ? value[0] : void 0 : value;
|
|
23399
23478
|
}
|
|
23400
23479
|
var WebhookVerifier = class {
|
|
23401
23480
|
constructor(webhookSecret, options = {}) {
|
|
@@ -23420,7 +23499,8 @@ var WebhookVerifier = class {
|
|
|
23420
23499
|
if (!id || !timestamp || !signatures || !/^\d+$/.test(timestamp)) return false;
|
|
23421
23500
|
const tolerance = options.toleranceSeconds ?? 300;
|
|
23422
23501
|
const now = Math.floor((options.now ?? Date.now()) / 1e3);
|
|
23423
|
-
if (Math.abs(now - Number(timestamp)) > tolerance)
|
|
23502
|
+
if (!Number.isFinite(tolerance) || tolerance < 0 || !Number.isSafeInteger(now) || now < 0 || !Number.isSafeInteger(Number(timestamp)) || Math.abs(now - Number(timestamp)) > tolerance)
|
|
23503
|
+
return false;
|
|
23424
23504
|
const secret = this.webhookSecret.startsWith("whsec_") ? this.webhookSecret.slice("whsec_".length) : this.webhookSecret;
|
|
23425
23505
|
const key = Buffer.from(secret, "base64");
|
|
23426
23506
|
if (key.length === 0) return false;
|
|
@@ -23428,8 +23508,8 @@ var WebhookVerifier = class {
|
|
|
23428
23508
|
(0, import_node_crypto2.createHmac)("sha256", key).update(`${id}.${timestamp}.`).update(typeof payload === "string" ? Buffer.from(payload, "utf8") : payload).digest("base64")
|
|
23429
23509
|
);
|
|
23430
23510
|
return signatures.split(" ").some((entry) => {
|
|
23431
|
-
const [version, value] = entry.split(","
|
|
23432
|
-
if (version !== "v1" || !value) return false;
|
|
23511
|
+
const [version, value, extra] = entry.split(",");
|
|
23512
|
+
if (version !== "v1" || !value || extra !== void 0) return false;
|
|
23433
23513
|
const provided = Buffer.from(value);
|
|
23434
23514
|
return provided.length === expected.length && (0, import_node_crypto2.timingSafeEqual)(provided, expected);
|
|
23435
23515
|
});
|
|
@@ -23634,6 +23714,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
23634
23714
|
const phone = signer.whatsapp_phone_number ?? signer.phone;
|
|
23635
23715
|
if (phone !== void 0) payload.whatsapp_phone_number = phone;
|
|
23636
23716
|
if (signer.cpf !== void 0) payload.cpf = signer.cpf;
|
|
23717
|
+
if (signer.government_id !== void 0) payload.government_id = signer.government_id;
|
|
23637
23718
|
if (signer.metadata !== void 0) payload.metadata = signer.metadata;
|
|
23638
23719
|
validateCreateSignerPayload(payload);
|
|
23639
23720
|
return { signer, payload, phone };
|
|
@@ -23780,85 +23861,9 @@ function requireAccountId(config, override) {
|
|
|
23780
23861
|
return id;
|
|
23781
23862
|
}
|
|
23782
23863
|
|
|
23783
|
-
// src/lib/
|
|
23784
|
-
|
|
23785
|
-
|
|
23786
|
-
let parsed;
|
|
23787
|
-
try {
|
|
23788
|
-
parsed = JSON.parse(raw);
|
|
23789
|
-
} catch {
|
|
23790
|
-
throw new CliError(`${flag} must be valid JSON.`);
|
|
23791
|
-
}
|
|
23792
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
23793
|
-
throw new CliError(`${flag} must be a JSON object.`);
|
|
23794
|
-
}
|
|
23795
|
-
return parsed;
|
|
23796
|
-
}
|
|
23797
|
-
function parseJsonArray(raw, flag) {
|
|
23798
|
-
if (raw === void 0) return void 0;
|
|
23799
|
-
let parsed;
|
|
23800
|
-
try {
|
|
23801
|
-
parsed = JSON.parse(raw);
|
|
23802
|
-
} catch {
|
|
23803
|
-
throw new CliError(`${flag} must be valid JSON.`);
|
|
23804
|
-
}
|
|
23805
|
-
if (!Array.isArray(parsed)) {
|
|
23806
|
-
throw new CliError(`${flag} must be a JSON array.`);
|
|
23807
|
-
}
|
|
23808
|
-
return parsed;
|
|
23809
|
-
}
|
|
23810
|
-
function splitList(raw) {
|
|
23811
|
-
if (raw === void 0) return void 0;
|
|
23812
|
-
const items = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
23813
|
-
return items;
|
|
23814
|
-
}
|
|
23815
|
-
function collect(value, previous = []) {
|
|
23816
|
-
return [...previous, value];
|
|
23817
|
-
}
|
|
23818
|
-
function parseInteger(raw, flag, options = {}) {
|
|
23819
|
-
if (raw === void 0) return void 0;
|
|
23820
|
-
const trimmed = raw.trim();
|
|
23821
|
-
if (!/^-?\d+$/.test(trimmed)) {
|
|
23822
|
-
throw new CliError(`${flag} must be an integer.`);
|
|
23823
|
-
}
|
|
23824
|
-
const n2 = Number(trimmed);
|
|
23825
|
-
if (!Number.isSafeInteger(n2)) {
|
|
23826
|
-
throw new CliError(`${flag} must be a safe integer.`);
|
|
23827
|
-
}
|
|
23828
|
-
if (options.min !== void 0 && n2 < options.min) {
|
|
23829
|
-
throw new CliError(`${flag} must be ${options.min} or greater.`);
|
|
23830
|
-
}
|
|
23831
|
-
return n2;
|
|
23832
|
-
}
|
|
23833
|
-
|
|
23834
|
-
// src/lib/options.ts
|
|
23835
|
-
function addPaginationOptions(command) {
|
|
23836
|
-
return command.option("--page <n>", "Page number to fetch").option("--per-page <n>", "Items per page");
|
|
23837
|
-
}
|
|
23838
|
-
function addSearchListOptions(command) {
|
|
23839
|
-
return addPaginationOptions(command).option("--search <query>", "Filter by a search query");
|
|
23840
|
-
}
|
|
23841
|
-
function addSortableListOptions(command, description) {
|
|
23842
|
-
return addPaginationOptions(command).option("--sort <field>", description);
|
|
23843
|
-
}
|
|
23844
|
-
function addListOptions(command, sortDescription = "Sort by field") {
|
|
23845
|
-
return addSearchListOptions(command).option("--sort <field>", sortDescription);
|
|
23846
|
-
}
|
|
23847
|
-
function addDownloadOptions(command) {
|
|
23848
|
-
return command.option("-o, --output <path>", "Output file path").option("--force", "Overwrite the output file if it already exists");
|
|
23849
|
-
}
|
|
23850
|
-
function addSignerRefOptions(command) {
|
|
23851
|
-
return command.addOption(
|
|
23852
|
-
new Option("--signer-ids <csv>", "Comma-separated signer IDs (required)").conflicts(
|
|
23853
|
-
"signers"
|
|
23854
|
-
)
|
|
23855
|
-
).addOption(
|
|
23856
|
-
new Option(
|
|
23857
|
-
"--signers <json>",
|
|
23858
|
-
"JSON array of signer refs, with verification_method, step, \u2026 (required)"
|
|
23859
|
-
).conflicts("signerIds")
|
|
23860
|
-
);
|
|
23861
|
-
}
|
|
23864
|
+
// src/lib/files.ts
|
|
23865
|
+
var import_node_fs4 = require("fs");
|
|
23866
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
23862
23867
|
|
|
23863
23868
|
// src/lib/output.ts
|
|
23864
23869
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
@@ -23945,218 +23950,20 @@ function printError(err, config) {
|
|
|
23945
23950
|
process.exitCode = normalized.exitCode ?? 1;
|
|
23946
23951
|
}
|
|
23947
23952
|
|
|
23948
|
-
//
|
|
23949
|
-
var
|
|
23950
|
-
|
|
23951
|
-
|
|
23952
|
-
|
|
23953
|
-
const perPage = parseInteger(flags.perPage, "--per-page", { min: 1 });
|
|
23954
|
-
if (page !== void 0) params.page = page;
|
|
23955
|
-
if (perPage !== void 0) params["per-page"] = perPage;
|
|
23956
|
-
if (flags.search) params.search = flags.search;
|
|
23957
|
-
if (flags.sort) params.sort = flags.sort;
|
|
23958
|
-
return params;
|
|
23959
|
-
}
|
|
23960
|
-
function paginationFooter(result) {
|
|
23961
|
-
const meta = result.meta;
|
|
23962
|
-
if (!meta) return "";
|
|
23963
|
-
const parts = [];
|
|
23964
|
-
if (meta.current_page !== void 0 && meta.last_page !== void 0) {
|
|
23965
|
-
parts.push(`page ${meta.current_page}/${meta.last_page}`);
|
|
23966
|
-
}
|
|
23967
|
-
if (meta.total !== void 0) {
|
|
23968
|
-
parts.push(`${meta.total} total`);
|
|
23969
|
-
}
|
|
23970
|
-
if (meta.per_page !== void 0) {
|
|
23971
|
-
parts.push(`${meta.per_page}/page`);
|
|
23972
|
-
}
|
|
23973
|
-
return parts.length > 0 ? import_picocolors2.default.dim(parts.join(" \xB7 ")) : "";
|
|
23974
|
-
}
|
|
23975
|
-
function tableWithFooter(table, result) {
|
|
23976
|
-
const footer = paginationFooter(result);
|
|
23977
|
-
return footer ? `${table}
|
|
23978
|
-
${footer}` : table;
|
|
23979
|
-
}
|
|
23953
|
+
// node_modules/@clack/core/dist/index.mjs
|
|
23954
|
+
var import_node_util4 = require("util");
|
|
23955
|
+
var import_node_process2 = require("process");
|
|
23956
|
+
var l = __toESM(require("readline"), 1);
|
|
23957
|
+
var import_node_readline = __toESM(require("readline"), 1);
|
|
23980
23958
|
|
|
23981
|
-
//
|
|
23982
|
-
var
|
|
23983
|
-
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
23989
|
-
function configDir() {
|
|
23990
|
-
if (process.env.ASSINAFY_CONFIG_DIR) {
|
|
23991
|
-
return process.env.ASSINAFY_CONFIG_DIR;
|
|
23992
|
-
}
|
|
23993
|
-
if (process.platform === "win32" && process.env.APPDATA) {
|
|
23994
|
-
return import_node_path3.default.join(process.env.APPDATA, "assinafy");
|
|
23995
|
-
}
|
|
23996
|
-
const xdg = process.env.XDG_CONFIG_HOME;
|
|
23997
|
-
const base = xdg && xdg.length > 0 ? xdg : import_node_path3.default.join(import_node_os.default.homedir(), ".config");
|
|
23998
|
-
return import_node_path3.default.join(base, "assinafy");
|
|
23999
|
-
}
|
|
24000
|
-
function configPath() {
|
|
24001
|
-
return import_node_path3.default.join(configDir(), "config.json");
|
|
24002
|
-
}
|
|
24003
|
-
function readConfigFile(options = {}) {
|
|
24004
|
-
const file = configPath();
|
|
24005
|
-
if (!(0, import_node_fs3.existsSync)(file)) {
|
|
24006
|
-
return {};
|
|
24007
|
-
}
|
|
24008
|
-
try {
|
|
24009
|
-
const parsed = JSON.parse((0, import_node_fs3.readFileSync)(file, "utf8"));
|
|
24010
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
24011
|
-
if (parsed.default_profile !== void 0 && typeof parsed.default_profile !== "string") {
|
|
24012
|
-
throw new Error("Invalid default_profile");
|
|
24013
|
-
}
|
|
24014
|
-
if (parsed.profiles !== void 0) {
|
|
24015
|
-
if (!parsed.profiles || typeof parsed.profiles !== "object" || Array.isArray(parsed.profiles)) {
|
|
24016
|
-
throw new Error("Invalid profiles");
|
|
24017
|
-
}
|
|
24018
|
-
for (const profile of Object.values(parsed.profiles)) {
|
|
24019
|
-
if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
|
|
24020
|
-
throw new Error("Invalid profile");
|
|
24021
|
-
}
|
|
24022
|
-
for (const key of [
|
|
24023
|
-
"api_key",
|
|
24024
|
-
"token",
|
|
24025
|
-
"account_id",
|
|
24026
|
-
"base_url",
|
|
24027
|
-
"webhook_secret"
|
|
24028
|
-
]) {
|
|
24029
|
-
if (profile[key] !== void 0 && typeof profile[key] !== "string") {
|
|
24030
|
-
throw new Error("Invalid profile field");
|
|
24031
|
-
}
|
|
24032
|
-
}
|
|
24033
|
-
}
|
|
24034
|
-
}
|
|
24035
|
-
return parsed;
|
|
24036
|
-
}
|
|
24037
|
-
if (options.strict) {
|
|
24038
|
-
throw new CliError(`Config file at ${file} is not a JSON object; refusing to overwrite it.`);
|
|
24039
|
-
}
|
|
24040
|
-
process.stderr.write(
|
|
24041
|
-
`${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} is not a JSON object; ignoring it.
|
|
24042
|
-
`
|
|
24043
|
-
);
|
|
24044
|
-
return {};
|
|
24045
|
-
} catch (error) {
|
|
24046
|
-
if (error instanceof CliError) throw error;
|
|
24047
|
-
if (options.strict) {
|
|
24048
|
-
throw new CliError(
|
|
24049
|
-
`Config file at ${file} has invalid JSON or field types; refusing to overwrite it.`
|
|
24050
|
-
);
|
|
24051
|
-
}
|
|
24052
|
-
process.stderr.write(
|
|
24053
|
-
`${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} has invalid JSON or field types; ignoring it.
|
|
24054
|
-
`
|
|
24055
|
-
);
|
|
24056
|
-
return {};
|
|
24057
|
-
}
|
|
24058
|
-
}
|
|
24059
|
-
function writeConfigFile(config) {
|
|
24060
|
-
const dir = configDir();
|
|
24061
|
-
if (!(0, import_node_fs3.existsSync)(dir)) {
|
|
24062
|
-
(0, import_node_fs3.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
24063
|
-
}
|
|
24064
|
-
if (process.platform !== "win32") (0, import_node_fs3.chmodSync)(dir, 448);
|
|
24065
|
-
const file = configPath();
|
|
24066
|
-
const tmp = `${file}.${(0, import_node_crypto3.randomUUID)()}.tmp`;
|
|
24067
|
-
try {
|
|
24068
|
-
(0, import_node_fs3.writeFileSync)(tmp, `${JSON.stringify(config, null, 2)}
|
|
24069
|
-
`, {
|
|
24070
|
-
flag: "wx",
|
|
24071
|
-
mode: 384
|
|
24072
|
-
});
|
|
24073
|
-
(0, import_node_fs3.chmodSync)(tmp, 384);
|
|
24074
|
-
(0, import_node_fs3.renameSync)(tmp, file);
|
|
24075
|
-
} catch (err) {
|
|
24076
|
-
(0, import_node_fs3.rmSync)(tmp, { force: true });
|
|
24077
|
-
throw err;
|
|
24078
|
-
}
|
|
24079
|
-
}
|
|
24080
|
-
function activeProfileName(globals, file = readConfigFile()) {
|
|
24081
|
-
return globals.profile || process.env.ASSINAFY_PROFILE || file.default_profile || DEFAULT_PROFILE;
|
|
24082
|
-
}
|
|
24083
|
-
function resolveConfig2(globals) {
|
|
24084
|
-
const file = readConfigFile();
|
|
24085
|
-
const profileName = activeProfileName(globals, file);
|
|
24086
|
-
const profile = file.profiles?.[profileName] ?? {};
|
|
24087
|
-
const pick = (flag, env, stored) => flag || env || stored || void 0;
|
|
24088
|
-
const baseUrl = pick(globals.baseUrl, process.env.ASSINAFY_BASE_URL, profile.base_url) ?? DEFAULT_BASE_URL2;
|
|
24089
|
-
const credentials = [
|
|
24090
|
-
{ apiKey: globals.apiKey, token: globals.token },
|
|
24091
|
-
{ apiKey: process.env.ASSINAFY_API_KEY, token: process.env.ASSINAFY_TOKEN },
|
|
24092
|
-
{ apiKey: profile.api_key, token: profile.token }
|
|
24093
|
-
].find(({ apiKey, token }) => apiKey || token);
|
|
24094
|
-
return {
|
|
24095
|
-
apiKey: credentials?.apiKey,
|
|
24096
|
-
token: credentials?.token,
|
|
24097
|
-
accountId: pick(globals.accountId, process.env.ASSINAFY_ACCOUNT_ID, profile.account_id),
|
|
24098
|
-
baseUrl: normalizeBaseUrl(baseUrl),
|
|
24099
|
-
webhookSecret: pick(void 0, process.env.ASSINAFY_WEBHOOK_SECRET, profile.webhook_secret),
|
|
24100
|
-
profile: profileName,
|
|
24101
|
-
json: Boolean(globals.json),
|
|
24102
|
-
quiet: Boolean(globals.quiet)
|
|
24103
|
-
};
|
|
24104
|
-
}
|
|
24105
|
-
|
|
24106
|
-
// src/lib/run.ts
|
|
24107
|
-
function getGlobals(command) {
|
|
24108
|
-
const opts = command.optsWithGlobals();
|
|
24109
|
-
return {
|
|
24110
|
-
apiKey: opts.apiKey,
|
|
24111
|
-
token: opts.token,
|
|
24112
|
-
accountId: opts.accountId,
|
|
24113
|
-
baseUrl: opts.baseUrl,
|
|
24114
|
-
profile: opts.profile,
|
|
24115
|
-
json: Boolean(opts.json),
|
|
24116
|
-
quiet: Boolean(opts.quiet)
|
|
24117
|
-
};
|
|
24118
|
-
}
|
|
24119
|
-
async function withResolvedConfig(command, handler) {
|
|
24120
|
-
let outputConfig = { json: false, quiet: false };
|
|
24121
|
-
try {
|
|
24122
|
-
const globals = getGlobals(command);
|
|
24123
|
-
outputConfig = { json: Boolean(globals.json), quiet: Boolean(globals.quiet) };
|
|
24124
|
-
const config = resolveConfig2(globals);
|
|
24125
|
-
await handler(config);
|
|
24126
|
-
} catch (err) {
|
|
24127
|
-
printError(err, outputConfig);
|
|
24128
|
-
}
|
|
24129
|
-
}
|
|
24130
|
-
function runWithClient(command, handler) {
|
|
24131
|
-
return withResolvedConfig(command, (config) => handler({ client: createClient(config), config }));
|
|
24132
|
-
}
|
|
24133
|
-
function runWithPublicClient(command, handler) {
|
|
24134
|
-
return withResolvedConfig(
|
|
24135
|
-
command,
|
|
24136
|
-
(config) => handler({
|
|
24137
|
-
client: createClient(config, { allowUnauthenticated: true, omitCredentials: true }),
|
|
24138
|
-
config
|
|
24139
|
-
})
|
|
24140
|
-
);
|
|
24141
|
-
}
|
|
24142
|
-
function runAction(command, handler) {
|
|
24143
|
-
return withResolvedConfig(command, (config) => handler({ config }));
|
|
24144
|
-
}
|
|
24145
|
-
|
|
24146
|
-
// node_modules/@clack/core/dist/index.mjs
|
|
24147
|
-
var import_node_util4 = require("util");
|
|
24148
|
-
var import_node_process2 = require("process");
|
|
24149
|
-
var l = __toESM(require("readline"), 1);
|
|
24150
|
-
var import_node_readline = __toESM(require("readline"), 1);
|
|
24151
|
-
|
|
24152
|
-
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
24153
|
-
var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
24154
|
-
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
24155
|
-
return (input) => {
|
|
24156
|
-
let surrogatePairsNr = 0;
|
|
24157
|
-
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
24158
|
-
while (SURROGATE_PAIR_RE.test(input)) {
|
|
24159
|
-
surrogatePairsNr += 1;
|
|
23959
|
+
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
23960
|
+
var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
23961
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
23962
|
+
return (input) => {
|
|
23963
|
+
let surrogatePairsNr = 0;
|
|
23964
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
23965
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
23966
|
+
surrogatePairsNr += 1;
|
|
24160
23967
|
}
|
|
24161
23968
|
return input.length - surrogatePairsNr;
|
|
24162
23969
|
};
|
|
@@ -24856,8 +24663,8 @@ var n = class extends V {
|
|
|
24856
24663
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
24857
24664
|
var import_node_util5 = require("util");
|
|
24858
24665
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
24859
|
-
var
|
|
24860
|
-
var
|
|
24666
|
+
var import_node_fs3 = require("fs");
|
|
24667
|
+
var import_node_path3 = require("path");
|
|
24861
24668
|
var import_sisteransi2 = __toESM(require_src3(), 1);
|
|
24862
24669
|
function isUnicodeSupported() {
|
|
24863
24670
|
if (import_node_process3.default.platform !== "win32") {
|
|
@@ -25115,33 +24922,376 @@ ${d}${n2}
|
|
|
25115
24922
|
return `${s}${r2}${n2}${l2.trim() ? `
|
|
25116
24923
|
${r2}` : ""}`;
|
|
25117
24924
|
}
|
|
25118
|
-
default: {
|
|
25119
|
-
const n2 = i2 ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", r2 = i2 ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
|
|
25120
|
-
return `${s}${n2}${o}
|
|
25121
|
-
${r2}
|
|
25122
|
-
`;
|
|
24925
|
+
default: {
|
|
24926
|
+
const n2 = i2 ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", r2 = i2 ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
|
|
24927
|
+
return `${s}${n2}${o}
|
|
24928
|
+
${r2}
|
|
24929
|
+
`;
|
|
24930
|
+
}
|
|
24931
|
+
}
|
|
24932
|
+
}
|
|
24933
|
+
}).prompt();
|
|
24934
|
+
|
|
24935
|
+
// src/lib/spinner.ts
|
|
24936
|
+
async function withSpinner(message, config, task) {
|
|
24937
|
+
const useSpinner = !config.json && !config.quiet && process.stderr.isTTY;
|
|
24938
|
+
if (!useSpinner) {
|
|
24939
|
+
return task();
|
|
24940
|
+
}
|
|
24941
|
+
const s = spinner({ output: process.stderr });
|
|
24942
|
+
s.start(message);
|
|
24943
|
+
try {
|
|
24944
|
+
const result = await task();
|
|
24945
|
+
s.stop(message);
|
|
24946
|
+
return result;
|
|
24947
|
+
} catch (err) {
|
|
24948
|
+
s.error(message);
|
|
24949
|
+
throw err;
|
|
24950
|
+
}
|
|
24951
|
+
}
|
|
24952
|
+
|
|
24953
|
+
// src/lib/files.ts
|
|
24954
|
+
function readBinary(inputPath) {
|
|
24955
|
+
try {
|
|
24956
|
+
return (0, import_node_fs4.readFileSync)(import_node_path4.default.resolve(inputPath));
|
|
24957
|
+
} catch (err) {
|
|
24958
|
+
throw new CliError(
|
|
24959
|
+
`Failed to read file "${inputPath}": ${err instanceof Error ? err.message : String(err)}`
|
|
24960
|
+
);
|
|
24961
|
+
}
|
|
24962
|
+
}
|
|
24963
|
+
function writeBinary(outputPath, data, options = {}) {
|
|
24964
|
+
const resolved = import_node_path4.default.resolve(outputPath);
|
|
24965
|
+
try {
|
|
24966
|
+
(0, import_node_fs4.writeFileSync)(resolved, data, { flag: options.force ? "w" : "wx" });
|
|
24967
|
+
} catch (err) {
|
|
24968
|
+
if (err && typeof err === "object" && "code" in err && err.code === "EEXIST") {
|
|
24969
|
+
throw new CliError(`File "${resolved}" already exists. Pass --force to overwrite it.`);
|
|
24970
|
+
}
|
|
24971
|
+
throw new CliError(
|
|
24972
|
+
`Failed to write file "${resolved}": ${err instanceof Error ? err.message : String(err)}`
|
|
24973
|
+
);
|
|
24974
|
+
}
|
|
24975
|
+
return resolved;
|
|
24976
|
+
}
|
|
24977
|
+
function defaultArtifactFilename(documentId, artifact) {
|
|
24978
|
+
const ext = artifact === "thumbnail" ? "jpg" : artifact === "bundle" ? "zip" : "pdf";
|
|
24979
|
+
return `${documentId}-${artifact}.${ext}`;
|
|
24980
|
+
}
|
|
24981
|
+
async function saveDownload(config, options) {
|
|
24982
|
+
const buffer = await withSpinner(options.message, config, options.download);
|
|
24983
|
+
const out = writeBinary(options.output ?? options.defaultName, buffer, { force: options.force });
|
|
24984
|
+
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
24985
|
+
printData(
|
|
24986
|
+
{ path: out, bytes: buffer.byteLength, ...options.data },
|
|
24987
|
+
config,
|
|
24988
|
+
(d) => sanitizeTerminalText(d.path)
|
|
24989
|
+
);
|
|
24990
|
+
}
|
|
24991
|
+
|
|
24992
|
+
// src/lib/json.ts
|
|
24993
|
+
function parseJsonObject(raw, flag) {
|
|
24994
|
+
if (raw === void 0) return void 0;
|
|
24995
|
+
let parsed;
|
|
24996
|
+
try {
|
|
24997
|
+
parsed = JSON.parse(raw);
|
|
24998
|
+
} catch {
|
|
24999
|
+
throw new CliError(`${flag} must be valid JSON.`);
|
|
25000
|
+
}
|
|
25001
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
25002
|
+
throw new CliError(`${flag} must be a JSON object.`);
|
|
25003
|
+
}
|
|
25004
|
+
return parsed;
|
|
25005
|
+
}
|
|
25006
|
+
function parseJsonArray(raw, flag) {
|
|
25007
|
+
if (raw === void 0) return void 0;
|
|
25008
|
+
let parsed;
|
|
25009
|
+
try {
|
|
25010
|
+
parsed = JSON.parse(raw);
|
|
25011
|
+
} catch {
|
|
25012
|
+
throw new CliError(`${flag} must be valid JSON.`);
|
|
25013
|
+
}
|
|
25014
|
+
if (!Array.isArray(parsed)) {
|
|
25015
|
+
throw new CliError(`${flag} must be a JSON array.`);
|
|
25016
|
+
}
|
|
25017
|
+
return parsed;
|
|
25018
|
+
}
|
|
25019
|
+
function splitList(raw) {
|
|
25020
|
+
if (raw === void 0) return void 0;
|
|
25021
|
+
const items = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
25022
|
+
return items;
|
|
25023
|
+
}
|
|
25024
|
+
function collect(value, previous = []) {
|
|
25025
|
+
return [...previous, value];
|
|
25026
|
+
}
|
|
25027
|
+
function parseInteger(raw, flag, options = {}) {
|
|
25028
|
+
if (raw === void 0) return void 0;
|
|
25029
|
+
const trimmed = raw.trim();
|
|
25030
|
+
if (!/^-?\d+$/.test(trimmed)) {
|
|
25031
|
+
throw new CliError(`${flag} must be an integer.`);
|
|
25032
|
+
}
|
|
25033
|
+
const n2 = Number(trimmed);
|
|
25034
|
+
if (!Number.isSafeInteger(n2)) {
|
|
25035
|
+
throw new CliError(`${flag} must be a safe integer.`);
|
|
25036
|
+
}
|
|
25037
|
+
if (options.min !== void 0 && n2 < options.min) {
|
|
25038
|
+
throw new CliError(`${flag} must be ${options.min} or greater.`);
|
|
25039
|
+
}
|
|
25040
|
+
return n2;
|
|
25041
|
+
}
|
|
25042
|
+
|
|
25043
|
+
// src/lib/options.ts
|
|
25044
|
+
function addPaginationOptions(command) {
|
|
25045
|
+
return command.option("--page <n>", "Page number to fetch").option("--per-page <n>", "Items per page");
|
|
25046
|
+
}
|
|
25047
|
+
function addSearchListOptions(command) {
|
|
25048
|
+
return addPaginationOptions(command).option("--search <query>", "Filter by a search query");
|
|
25049
|
+
}
|
|
25050
|
+
function addSortableListOptions(command, description) {
|
|
25051
|
+
return addPaginationOptions(command).option("--sort <field>", description);
|
|
25052
|
+
}
|
|
25053
|
+
function addListOptions(command, sortDescription = "Sort by field") {
|
|
25054
|
+
return addSearchListOptions(command).option("--sort <field>", sortDescription);
|
|
25055
|
+
}
|
|
25056
|
+
function addDownloadOptions(command) {
|
|
25057
|
+
return command.option("-o, --output <path>", "Output file path").option("--force", "Overwrite the output file if it already exists");
|
|
25058
|
+
}
|
|
25059
|
+
function addSignerRefOptions(command) {
|
|
25060
|
+
return command.addOption(
|
|
25061
|
+
new Option("--signer-ids <csv>", "Comma-separated signer IDs (required)").conflicts(
|
|
25062
|
+
"signers"
|
|
25063
|
+
)
|
|
25064
|
+
).addOption(
|
|
25065
|
+
new Option(
|
|
25066
|
+
"--signers <json>",
|
|
25067
|
+
"JSON array of signer refs, with verification_method, step, \u2026 (required)"
|
|
25068
|
+
).conflicts("signerIds")
|
|
25069
|
+
);
|
|
25070
|
+
}
|
|
25071
|
+
|
|
25072
|
+
// src/lib/pagination.ts
|
|
25073
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
25074
|
+
function listParams(flags) {
|
|
25075
|
+
const params = {};
|
|
25076
|
+
const page = parseInteger(flags.page, "--page", { min: 1 });
|
|
25077
|
+
const perPage = parseInteger(flags.perPage, "--per-page", { min: 1 });
|
|
25078
|
+
if (page !== void 0) params.page = page;
|
|
25079
|
+
if (perPage !== void 0) params["per-page"] = perPage;
|
|
25080
|
+
if (flags.search) params.search = flags.search;
|
|
25081
|
+
if (flags.sort) params.sort = flags.sort;
|
|
25082
|
+
return params;
|
|
25083
|
+
}
|
|
25084
|
+
function paginationFooter(result) {
|
|
25085
|
+
const meta = result.meta;
|
|
25086
|
+
if (!meta) return "";
|
|
25087
|
+
const parts = [];
|
|
25088
|
+
if (meta.current_page !== void 0 && meta.last_page !== void 0) {
|
|
25089
|
+
parts.push(`page ${meta.current_page}/${meta.last_page}`);
|
|
25090
|
+
}
|
|
25091
|
+
if (meta.total !== void 0) {
|
|
25092
|
+
parts.push(`${meta.total} total`);
|
|
25093
|
+
}
|
|
25094
|
+
if (meta.per_page !== void 0) {
|
|
25095
|
+
parts.push(`${meta.per_page}/page`);
|
|
25096
|
+
}
|
|
25097
|
+
return parts.length > 0 ? import_picocolors2.default.dim(parts.join(" \xB7 ")) : "";
|
|
25098
|
+
}
|
|
25099
|
+
function tableWithFooter(table, result) {
|
|
25100
|
+
const footer = paginationFooter(result);
|
|
25101
|
+
return footer ? `${table}
|
|
25102
|
+
${footer}` : table;
|
|
25103
|
+
}
|
|
25104
|
+
|
|
25105
|
+
// src/lib/prompts.ts
|
|
25106
|
+
async function promptText(message, placeholder) {
|
|
25107
|
+
const value = await text({ message, placeholder, output: process.stderr });
|
|
25108
|
+
return unwrap(value);
|
|
25109
|
+
}
|
|
25110
|
+
async function promptSecret(message) {
|
|
25111
|
+
const value = await password({ message, output: process.stderr });
|
|
25112
|
+
return unwrap(value);
|
|
25113
|
+
}
|
|
25114
|
+
async function confirmDestructive(message, force) {
|
|
25115
|
+
if (force) return true;
|
|
25116
|
+
if (!process.stdin.isTTY) {
|
|
25117
|
+
throw new CliError("Refusing to proceed without confirmation. Re-run with --yes to confirm.");
|
|
25118
|
+
}
|
|
25119
|
+
const value = await confirm({ message, output: process.stderr });
|
|
25120
|
+
return unwrap(value);
|
|
25121
|
+
}
|
|
25122
|
+
function unwrap(value) {
|
|
25123
|
+
if (isCancel3(value)) {
|
|
25124
|
+
cancel("Cancelled.", { output: process.stderr });
|
|
25125
|
+
throw new CliError("Cancelled.", { exitCode: 130 });
|
|
25126
|
+
}
|
|
25127
|
+
return value;
|
|
25128
|
+
}
|
|
25129
|
+
|
|
25130
|
+
// src/lib/config.ts
|
|
25131
|
+
var import_node_crypto3 = require("crypto");
|
|
25132
|
+
var import_node_fs5 = require("fs");
|
|
25133
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
25134
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
25135
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
25136
|
+
var DEFAULT_BASE_URL2 = "https://api.assinafy.com.br/v1";
|
|
25137
|
+
var DEFAULT_PROFILE = "default";
|
|
25138
|
+
function configDir() {
|
|
25139
|
+
if (process.env.ASSINAFY_CONFIG_DIR) {
|
|
25140
|
+
return process.env.ASSINAFY_CONFIG_DIR;
|
|
25141
|
+
}
|
|
25142
|
+
if (process.platform === "win32" && process.env.APPDATA) {
|
|
25143
|
+
return import_node_path5.default.join(process.env.APPDATA, "assinafy");
|
|
25144
|
+
}
|
|
25145
|
+
const xdg = process.env.XDG_CONFIG_HOME;
|
|
25146
|
+
const base = xdg && xdg.length > 0 ? xdg : import_node_path5.default.join(import_node_os.default.homedir(), ".config");
|
|
25147
|
+
return import_node_path5.default.join(base, "assinafy");
|
|
25148
|
+
}
|
|
25149
|
+
function configPath() {
|
|
25150
|
+
return import_node_path5.default.join(configDir(), "config.json");
|
|
25151
|
+
}
|
|
25152
|
+
function readConfigFile(options = {}) {
|
|
25153
|
+
const file = configPath();
|
|
25154
|
+
if (!(0, import_node_fs5.existsSync)(file)) {
|
|
25155
|
+
return {};
|
|
25156
|
+
}
|
|
25157
|
+
try {
|
|
25158
|
+
const parsed = JSON.parse((0, import_node_fs5.readFileSync)(file, "utf8"));
|
|
25159
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
25160
|
+
if (parsed.default_profile !== void 0 && typeof parsed.default_profile !== "string") {
|
|
25161
|
+
throw new Error("Invalid default_profile");
|
|
25162
|
+
}
|
|
25163
|
+
if (parsed.profiles !== void 0) {
|
|
25164
|
+
if (!parsed.profiles || typeof parsed.profiles !== "object" || Array.isArray(parsed.profiles)) {
|
|
25165
|
+
throw new Error("Invalid profiles");
|
|
25166
|
+
}
|
|
25167
|
+
for (const profile of Object.values(parsed.profiles)) {
|
|
25168
|
+
if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
|
|
25169
|
+
throw new Error("Invalid profile");
|
|
25170
|
+
}
|
|
25171
|
+
for (const key of [
|
|
25172
|
+
"api_key",
|
|
25173
|
+
"token",
|
|
25174
|
+
"account_id",
|
|
25175
|
+
"base_url",
|
|
25176
|
+
"webhook_secret"
|
|
25177
|
+
]) {
|
|
25178
|
+
if (profile[key] !== void 0 && typeof profile[key] !== "string") {
|
|
25179
|
+
throw new Error("Invalid profile field");
|
|
25180
|
+
}
|
|
25181
|
+
}
|
|
25182
|
+
}
|
|
25183
|
+
Object.setPrototypeOf(parsed.profiles, null);
|
|
25123
25184
|
}
|
|
25185
|
+
return parsed;
|
|
25124
25186
|
}
|
|
25187
|
+
if (options.strict) {
|
|
25188
|
+
throw new CliError(`Config file at ${file} is not a JSON object; refusing to overwrite it.`);
|
|
25189
|
+
}
|
|
25190
|
+
process.stderr.write(
|
|
25191
|
+
`${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} is not a JSON object; ignoring it.
|
|
25192
|
+
`
|
|
25193
|
+
);
|
|
25194
|
+
return {};
|
|
25195
|
+
} catch (error) {
|
|
25196
|
+
if (error instanceof CliError) throw error;
|
|
25197
|
+
if (options.strict) {
|
|
25198
|
+
throw new CliError(
|
|
25199
|
+
`Config file at ${file} has invalid JSON or field types; refusing to overwrite it.`
|
|
25200
|
+
);
|
|
25201
|
+
}
|
|
25202
|
+
process.stderr.write(
|
|
25203
|
+
`${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} has invalid JSON or field types; ignoring it.
|
|
25204
|
+
`
|
|
25205
|
+
);
|
|
25206
|
+
return {};
|
|
25125
25207
|
}
|
|
25126
|
-
}
|
|
25127
|
-
|
|
25128
|
-
|
|
25129
|
-
|
|
25130
|
-
|
|
25131
|
-
if (!useSpinner) {
|
|
25132
|
-
return task();
|
|
25208
|
+
}
|
|
25209
|
+
function writeConfigFile(config) {
|
|
25210
|
+
const dir = configDir();
|
|
25211
|
+
if (!(0, import_node_fs5.existsSync)(dir)) {
|
|
25212
|
+
(0, import_node_fs5.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
25133
25213
|
}
|
|
25134
|
-
|
|
25135
|
-
|
|
25214
|
+
if (process.platform !== "win32") (0, import_node_fs5.chmodSync)(dir, 448);
|
|
25215
|
+
const file = configPath();
|
|
25216
|
+
const tmp = `${file}.${(0, import_node_crypto3.randomUUID)()}.tmp`;
|
|
25136
25217
|
try {
|
|
25137
|
-
|
|
25138
|
-
|
|
25139
|
-
|
|
25218
|
+
(0, import_node_fs5.writeFileSync)(tmp, `${JSON.stringify(config, null, 2)}
|
|
25219
|
+
`, {
|
|
25220
|
+
flag: "wx",
|
|
25221
|
+
mode: 384
|
|
25222
|
+
});
|
|
25223
|
+
(0, import_node_fs5.chmodSync)(tmp, 384);
|
|
25224
|
+
(0, import_node_fs5.renameSync)(tmp, file);
|
|
25140
25225
|
} catch (err) {
|
|
25141
|
-
|
|
25226
|
+
(0, import_node_fs5.rmSync)(tmp, { force: true });
|
|
25142
25227
|
throw err;
|
|
25143
25228
|
}
|
|
25144
25229
|
}
|
|
25230
|
+
function activeProfileName(globals, file = readConfigFile()) {
|
|
25231
|
+
return globals.profile || process.env.ASSINAFY_PROFILE || file.default_profile || DEFAULT_PROFILE;
|
|
25232
|
+
}
|
|
25233
|
+
function resolveConfig2(globals) {
|
|
25234
|
+
const file = readConfigFile();
|
|
25235
|
+
const profileName = activeProfileName(globals, file);
|
|
25236
|
+
const profile = file.profiles?.[profileName] ?? {};
|
|
25237
|
+
const pick = (flag, env, stored) => flag || env || stored || void 0;
|
|
25238
|
+
const baseUrl = pick(globals.baseUrl, process.env.ASSINAFY_BASE_URL, profile.base_url) ?? DEFAULT_BASE_URL2;
|
|
25239
|
+
const credentials = [
|
|
25240
|
+
{ apiKey: globals.apiKey, token: globals.token },
|
|
25241
|
+
{ apiKey: process.env.ASSINAFY_API_KEY, token: process.env.ASSINAFY_TOKEN },
|
|
25242
|
+
{ apiKey: profile.api_key, token: profile.token }
|
|
25243
|
+
].find(({ apiKey, token }) => apiKey || token);
|
|
25244
|
+
return {
|
|
25245
|
+
apiKey: credentials?.apiKey,
|
|
25246
|
+
token: credentials?.token,
|
|
25247
|
+
accountId: pick(globals.accountId, process.env.ASSINAFY_ACCOUNT_ID, profile.account_id),
|
|
25248
|
+
baseUrl: normalizeBaseUrl(baseUrl),
|
|
25249
|
+
webhookSecret: pick(void 0, process.env.ASSINAFY_WEBHOOK_SECRET, profile.webhook_secret),
|
|
25250
|
+
profile: profileName,
|
|
25251
|
+
json: Boolean(globals.json),
|
|
25252
|
+
quiet: Boolean(globals.quiet)
|
|
25253
|
+
};
|
|
25254
|
+
}
|
|
25255
|
+
|
|
25256
|
+
// src/lib/run.ts
|
|
25257
|
+
function getGlobals(command) {
|
|
25258
|
+
const opts = command.optsWithGlobals();
|
|
25259
|
+
return {
|
|
25260
|
+
apiKey: opts.apiKey,
|
|
25261
|
+
token: opts.token,
|
|
25262
|
+
accountId: opts.accountId,
|
|
25263
|
+
baseUrl: opts.baseUrl,
|
|
25264
|
+
profile: opts.profile,
|
|
25265
|
+
json: Boolean(opts.json),
|
|
25266
|
+
quiet: Boolean(opts.quiet)
|
|
25267
|
+
};
|
|
25268
|
+
}
|
|
25269
|
+
async function withResolvedConfig(command, handler) {
|
|
25270
|
+
let outputConfig = { json: false, quiet: false };
|
|
25271
|
+
try {
|
|
25272
|
+
const globals = getGlobals(command);
|
|
25273
|
+
outputConfig = { json: Boolean(globals.json), quiet: Boolean(globals.quiet) };
|
|
25274
|
+
const config = resolveConfig2(globals);
|
|
25275
|
+
await handler(config);
|
|
25276
|
+
} catch (err) {
|
|
25277
|
+
printError(err, outputConfig);
|
|
25278
|
+
}
|
|
25279
|
+
}
|
|
25280
|
+
function runWithClient(command, handler) {
|
|
25281
|
+
return withResolvedConfig(command, (config) => handler({ client: createClient(config), config }));
|
|
25282
|
+
}
|
|
25283
|
+
function runWithPublicClient(command, handler) {
|
|
25284
|
+
return withResolvedConfig(
|
|
25285
|
+
command,
|
|
25286
|
+
(config) => handler({
|
|
25287
|
+
client: createClient(config, { allowUnauthenticated: true, omitCredentials: true }),
|
|
25288
|
+
config
|
|
25289
|
+
})
|
|
25290
|
+
);
|
|
25291
|
+
}
|
|
25292
|
+
function runAction(command, handler) {
|
|
25293
|
+
return withResolvedConfig(command, (config) => handler({ config }));
|
|
25294
|
+
}
|
|
25145
25295
|
|
|
25146
25296
|
// src/lib/table.ts
|
|
25147
25297
|
var import_node_util6 = require("util");
|
|
@@ -25364,32 +25514,55 @@ var whatsappCommand = new Command("whatsapp-notifications").description("List Wh
|
|
|
25364
25514
|
);
|
|
25365
25515
|
});
|
|
25366
25516
|
});
|
|
25367
|
-
var
|
|
25368
|
-
|
|
25369
|
-
|
|
25370
|
-
|
|
25371
|
-
|
|
25372
|
-
|
|
25373
|
-
|
|
25374
|
-
|
|
25375
|
-
|
|
25376
|
-
|
|
25377
|
-
|
|
25378
|
-
|
|
25379
|
-
|
|
25380
|
-
|
|
25381
|
-
|
|
25382
|
-
|
|
25383
|
-
|
|
25384
|
-
|
|
25385
|
-
|
|
25386
|
-
|
|
25387
|
-
|
|
25388
|
-
|
|
25389
|
-
|
|
25390
|
-
|
|
25391
|
-
|
|
25392
|
-
}
|
|
25517
|
+
var identityVerificationCommand = new Command("identity-verification").description("Fetch a signer identity review and its evidence summary").argument("<documentId>", "Document ID").argument("<assignmentId>", "Assignment ID").argument("<signerId>", "Signer ID").action(async (documentId, assignmentId, signerId, _opts, command) => {
|
|
25518
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
25519
|
+
const result = await withSpinner(
|
|
25520
|
+
"Fetching identity review",
|
|
25521
|
+
config,
|
|
25522
|
+
() => client.assignments.getIdentityVerification(documentId, assignmentId, signerId)
|
|
25523
|
+
);
|
|
25524
|
+
printData(result, config);
|
|
25525
|
+
});
|
|
25526
|
+
});
|
|
25527
|
+
var identityImageCommand = new Command("identity-image").description("Download identity review evidence while the review is open").argument("<documentId>", "Document ID").argument("<assignmentId>", "Assignment ID").argument("<signerId>", "Signer ID").addOption(
|
|
25528
|
+
new Option("--name <name>", "Evidence image name").choices(["document_front", "document_back", "document_pdf", "face"]).makeOptionMandatory()
|
|
25529
|
+
).requiredOption("-o, --output <path>", "Output path for JPEG/PNG evidence or the document PDF").option("--force", "Overwrite the output file if it already exists").action(async (documentId, assignmentId, signerId, opts, command) => {
|
|
25530
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
25531
|
+
await saveDownload(config, {
|
|
25532
|
+
message: "Downloading identity evidence",
|
|
25533
|
+
download: () => client.assignments.downloadIdentityVerificationImage(
|
|
25534
|
+
documentId,
|
|
25535
|
+
assignmentId,
|
|
25536
|
+
signerId,
|
|
25537
|
+
opts.name
|
|
25538
|
+
),
|
|
25539
|
+
output: opts.output,
|
|
25540
|
+
defaultName: opts.output,
|
|
25541
|
+
force: opts.force
|
|
25542
|
+
});
|
|
25543
|
+
});
|
|
25544
|
+
});
|
|
25545
|
+
var reviewIdentityCommand = new Command("review-identity").description("Approve certification or reject and cancel the document after identity review").argument("<documentId>", "Document ID").argument("<assignmentId>", "Assignment ID").argument("<signerId>", "Signer ID").addOption(
|
|
25546
|
+
new Option("--decision <decision>", "Review decision").choices(["Approved", "Rejected"]).makeOptionMandatory()
|
|
25547
|
+
).option("--note <note>", "Private review note (at most 2000 characters)").option("-y, --yes", "Skip the confirmation prompt").action(async (documentId, assignmentId, signerId, opts, command) => {
|
|
25548
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
25549
|
+
if (!await confirmDestructive(
|
|
25550
|
+
opts.decision === "Rejected" ? `Reject this identity review, cancel document ${documentId}, and notify its recipients?` : `Approve this identity review and release certification for ${documentId}?`,
|
|
25551
|
+
Boolean(opts.yes)
|
|
25552
|
+
))
|
|
25553
|
+
return;
|
|
25554
|
+
const result = await withSpinner(
|
|
25555
|
+
"Deciding identity review",
|
|
25556
|
+
config,
|
|
25557
|
+
() => client.assignments.reviewIdentityVerification(documentId, assignmentId, signerId, {
|
|
25558
|
+
decision: opts.decision,
|
|
25559
|
+
note: opts.note
|
|
25560
|
+
})
|
|
25561
|
+
);
|
|
25562
|
+
printData(result, config);
|
|
25563
|
+
});
|
|
25564
|
+
});
|
|
25565
|
+
var assignmentsCommand = new Command("assignments").description("Create and manage signing assignments").addCommand(listCommand).addCommand(createCommand).addCommand(estimateCostCommand).addCommand(resetExpirationCommand).addCommand(resendCommand).addCommand(estimateResendCostCommand).addCommand(whatsappCommand).addCommand(identityVerificationCommand).addCommand(identityImageCommand).addCommand(reviewIdentityCommand);
|
|
25393
25566
|
|
|
25394
25567
|
// src/commands/auth.ts
|
|
25395
25568
|
function resetPasswordPayload(email, resetToken, newPassword) {
|
|
@@ -25683,7 +25856,7 @@ var setCommand = new Command("set").description(
|
|
|
25683
25856
|
const merged = command.optsWithGlobals();
|
|
25684
25857
|
const file = readConfigFile({ strict: true });
|
|
25685
25858
|
const profileName = activeProfileName(getGlobals(command), file);
|
|
25686
|
-
const profiles = file.profiles ??
|
|
25859
|
+
const profiles = file.profiles ?? /* @__PURE__ */ Object.create(null);
|
|
25687
25860
|
const profile = { ...profiles[profileName] };
|
|
25688
25861
|
let changed = false;
|
|
25689
25862
|
if (merged.apiKey !== void 0) {
|
|
@@ -25977,47 +26150,6 @@ var docsCommand = new Command("docs").description("Print (or open) the Assinafy
|
|
|
25977
26150
|
});
|
|
25978
26151
|
});
|
|
25979
26152
|
|
|
25980
|
-
// src/lib/files.ts
|
|
25981
|
-
var import_node_fs5 = require("fs");
|
|
25982
|
-
var import_node_path5 = __toESM(require("path"), 1);
|
|
25983
|
-
function readBinary(inputPath) {
|
|
25984
|
-
try {
|
|
25985
|
-
return (0, import_node_fs5.readFileSync)(import_node_path5.default.resolve(inputPath));
|
|
25986
|
-
} catch (err) {
|
|
25987
|
-
throw new CliError(
|
|
25988
|
-
`Failed to read file "${inputPath}": ${err instanceof Error ? err.message : String(err)}`
|
|
25989
|
-
);
|
|
25990
|
-
}
|
|
25991
|
-
}
|
|
25992
|
-
function writeBinary(outputPath, data, options = {}) {
|
|
25993
|
-
const resolved = import_node_path5.default.resolve(outputPath);
|
|
25994
|
-
try {
|
|
25995
|
-
(0, import_node_fs5.writeFileSync)(resolved, data, { flag: options.force ? "w" : "wx" });
|
|
25996
|
-
} catch (err) {
|
|
25997
|
-
if (err && typeof err === "object" && "code" in err && err.code === "EEXIST") {
|
|
25998
|
-
throw new CliError(`File "${resolved}" already exists. Pass --force to overwrite it.`);
|
|
25999
|
-
}
|
|
26000
|
-
throw new CliError(
|
|
26001
|
-
`Failed to write file "${resolved}": ${err instanceof Error ? err.message : String(err)}`
|
|
26002
|
-
);
|
|
26003
|
-
}
|
|
26004
|
-
return resolved;
|
|
26005
|
-
}
|
|
26006
|
-
function defaultArtifactFilename(documentId, artifact) {
|
|
26007
|
-
const ext = artifact === "thumbnail" ? "jpg" : artifact === "bundle" ? "zip" : "pdf";
|
|
26008
|
-
return `${documentId}-${artifact}.${ext}`;
|
|
26009
|
-
}
|
|
26010
|
-
async function saveDownload(config, options) {
|
|
26011
|
-
const buffer = await withSpinner(options.message, config, options.download);
|
|
26012
|
-
const out = writeBinary(options.output ?? options.defaultName, buffer, { force: options.force });
|
|
26013
|
-
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
26014
|
-
printData(
|
|
26015
|
-
{ path: out, bytes: buffer.byteLength, ...options.data },
|
|
26016
|
-
config,
|
|
26017
|
-
(d) => sanitizeTerminalText(d.path)
|
|
26018
|
-
);
|
|
26019
|
-
}
|
|
26020
|
-
|
|
26021
26153
|
// src/commands/documents.ts
|
|
26022
26154
|
var uploadCommand = new Command("upload").description("Upload a PDF to the workspace").argument("<file>", "Path to the PDF file").option("--name <name>", "Override the document name (defaults to the file name)").option("--metadata <json>", "JSON object of metadata to attach").option("--wait", "Wait until the document finishes processing").action(async (file, opts, command) => {
|
|
26023
26155
|
await runWithClient(command, async ({ client, config }) => {
|
|
@@ -26543,7 +26675,7 @@ var loginCommand2 = new Command("login").description(
|
|
|
26543
26675
|
const apiKey = merged.apiKey ?? await promptSecret("Enter your Assinafy API key");
|
|
26544
26676
|
const accountId = merged.accountId ?? await promptText("Default account/workspace ID (optional)");
|
|
26545
26677
|
const profileName = activeProfileName(getGlobals(command), file);
|
|
26546
|
-
const profiles = file.profiles ??
|
|
26678
|
+
const profiles = file.profiles ?? /* @__PURE__ */ Object.create(null);
|
|
26547
26679
|
const profile = { ...profiles[profileName], api_key: apiKey };
|
|
26548
26680
|
if (accountId) profile.account_id = accountId;
|
|
26549
26681
|
if (merged.baseUrl) profile.base_url = merged.baseUrl;
|
|
@@ -26863,6 +26995,27 @@ var selfCommand = new Command("self").description("Fetch the signer's own profil
|
|
|
26863
26995
|
printData(profile, config);
|
|
26864
26996
|
});
|
|
26865
26997
|
});
|
|
26998
|
+
var identityStatusCommand = new Command("identity-status").description("Fetch biometric verification status and the private capture URL").addOption(accessCodeOption()).action(async (opts, command) => {
|
|
26999
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
27000
|
+
const result = await withSpinner(
|
|
27001
|
+
"Fetching identity verification",
|
|
27002
|
+
config,
|
|
27003
|
+
() => client.signerDocuments.getIdentityVerification(opts.accessCode)
|
|
27004
|
+
);
|
|
27005
|
+
printData(result, config);
|
|
27006
|
+
});
|
|
27007
|
+
});
|
|
27008
|
+
var identityStartCommand = new Command("identity-start").description("Open a biometric verification session with the signer\u2019s explicit consent").addOption(accessCodeOption()).option("--consent", "The signer explicitly consents to biometric processing").action(async (opts, command) => {
|
|
27009
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
27010
|
+
if (!opts.consent) throw new CliError("The signer\u2019s explicit --consent is required.");
|
|
27011
|
+
const result = await withSpinner(
|
|
27012
|
+
"Starting identity verification",
|
|
27013
|
+
config,
|
|
27014
|
+
() => client.signerDocuments.startIdentityVerification(opts.accessCode, { consent: true })
|
|
27015
|
+
);
|
|
27016
|
+
printData(result, config);
|
|
27017
|
+
});
|
|
27018
|
+
});
|
|
26866
27019
|
var acceptTermsCommand = new Command("accept-terms").description("Accept the platform terms as the signer").addOption(accessCodeOption()).action(async (opts, command) => {
|
|
26867
27020
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
26868
27021
|
const result = await withSpinner(
|
|
@@ -27021,7 +27174,7 @@ var declineMultipleCommand = new Command("decline-multiple").description("Declin
|
|
|
27021
27174
|
printData(result, config);
|
|
27022
27175
|
});
|
|
27023
27176
|
});
|
|
27024
|
-
var signerCommand = new Command("signer").description("Signer-side flows and public artifact downloads").addCommand(documentCommand).addCommand(documentsCommand2).addCommand(searchCommand2).addCommand(downloadCommand2).addCommand(selfCommand).addCommand(acceptTermsCommand).addCommand(verifyCodeCommand).addCommand(certificateStartCommand).addCommand(certificateCompleteCommand).addCommand(confirmDataCommand).addCommand(uploadSignatureCommand).addCommand(downloadSignatureCommand).addCommand(assignmentCommand).addCommand(signCommand).addCommand(declineCommand).addCommand(signMultipleCommand).addCommand(declineMultipleCommand);
|
|
27177
|
+
var signerCommand = new Command("signer").description("Signer-side flows and public artifact downloads").addCommand(documentCommand).addCommand(documentsCommand2).addCommand(searchCommand2).addCommand(downloadCommand2).addCommand(selfCommand).addCommand(identityStatusCommand).addCommand(identityStartCommand).addCommand(acceptTermsCommand).addCommand(verifyCodeCommand).addCommand(certificateStartCommand).addCommand(certificateCompleteCommand).addCommand(confirmDataCommand).addCommand(uploadSignatureCommand).addCommand(downloadSignatureCommand).addCommand(assignmentCommand).addCommand(signCommand).addCommand(declineCommand).addCommand(signMultipleCommand).addCommand(declineMultipleCommand);
|
|
27025
27178
|
|
|
27026
27179
|
// src/commands/signers.ts
|
|
27027
27180
|
var signerColumns = [
|
|
@@ -27033,13 +27186,16 @@ var signerColumns = [
|
|
|
27033
27186
|
value: (r2) => r2.whatsapp_phone_number
|
|
27034
27187
|
}
|
|
27035
27188
|
];
|
|
27036
|
-
var createCommand3 = new Command("create").description("Create a signer (reuses an existing one with the same email)").requiredOption("--name <name>", "Signer full name").option("--email <email>", "Email address").option("--phone <number>", "WhatsApp phone number (E.164)").option("--cpf <cpf>", "Brazilian tax ID (CPF); non-digits are stripped").
|
|
27189
|
+
var createCommand3 = new Command("create").description("Create a signer (reuses an existing one with the same email)").requiredOption("--name <name>", "Signer full name").option("--email <email>", "Email address").option("--phone <number>", "WhatsApp phone number (E.164)").option("--cpf <cpf>", "Brazilian tax ID (CPF); non-digits are stripped").addOption(
|
|
27190
|
+
new Option("--government-id <id>", "CPF or numeric/alphanumeric CNPJ").conflicts("cpf")
|
|
27191
|
+
).option("--metadata <json>", "JSON object of metadata").action(async (opts, command) => {
|
|
27037
27192
|
await runWithClient(command, async ({ client, config }) => {
|
|
27038
27193
|
const accountId = requireAccountId(config);
|
|
27039
27194
|
const payload = { full_name: opts.name };
|
|
27040
27195
|
if (opts.email) payload.email = opts.email;
|
|
27041
27196
|
if (opts.phone) payload.whatsapp_phone_number = opts.phone;
|
|
27042
27197
|
if (opts.cpf) payload.cpf = opts.cpf;
|
|
27198
|
+
if (opts.governmentId !== void 0) payload.government_id = opts.governmentId;
|
|
27043
27199
|
const metadata = parseJsonObject(opts.metadata, "--metadata");
|
|
27044
27200
|
if (metadata) payload.metadata = metadata;
|
|
27045
27201
|
const signer = await withSpinner(
|
|
@@ -27088,7 +27244,9 @@ var getCommand4 = new Command("get").description("Show a signer by ID").argument
|
|
|
27088
27244
|
printData(signer, config, (s) => renderKeyValue(s));
|
|
27089
27245
|
});
|
|
27090
27246
|
});
|
|
27091
|
-
var updateCommand2 = new Command("update").description("Update a signer").argument("<id>", "Signer ID").option("--name <name>", "Signer full name").option("--email <email>", "Email address").option("--phone <number>", "WhatsApp phone number (E.164)").option("--cpf <cpf>", "Brazilian tax ID (CPF/CNPJ), sent as government_id").
|
|
27247
|
+
var updateCommand2 = new Command("update").description("Update a signer").argument("<id>", "Signer ID").option("--name <name>", "Signer full name").option("--email <email>", "Email address").option("--phone <number>", "WhatsApp phone number (E.164)").option("--cpf <cpf>", "Brazilian tax ID (CPF/CNPJ), sent as government_id").addOption(
|
|
27248
|
+
new Option("--government-id <id>", "CPF or numeric/alphanumeric CNPJ").conflicts("cpf")
|
|
27249
|
+
).action(async (id, opts, command) => {
|
|
27092
27250
|
await runWithClient(command, async ({ client, config }) => {
|
|
27093
27251
|
const accountId = requireAccountId(config);
|
|
27094
27252
|
const payload = {};
|
|
@@ -27096,6 +27254,7 @@ var updateCommand2 = new Command("update").description("Update a signer").argume
|
|
|
27096
27254
|
if (opts.email) payload.email = opts.email;
|
|
27097
27255
|
if (opts.phone) payload.whatsapp_phone_number = opts.phone;
|
|
27098
27256
|
if (opts.cpf) payload.cpf = opts.cpf;
|
|
27257
|
+
if (opts.governmentId !== void 0) payload.government_id = opts.governmentId;
|
|
27099
27258
|
const signer = await withSpinner(
|
|
27100
27259
|
"Updating signer",
|
|
27101
27260
|
config,
|
|
@@ -27446,7 +27605,8 @@ var renderEndpoint = (e) => renderKeyValue({
|
|
|
27446
27605
|
email: e.email,
|
|
27447
27606
|
is_active: e.is_active,
|
|
27448
27607
|
signing_enabled: e.signing_enabled,
|
|
27449
|
-
events: e.events
|
|
27608
|
+
events: e.events,
|
|
27609
|
+
secret: e.secret
|
|
27450
27610
|
});
|
|
27451
27611
|
function endpointFieldOptions(command) {
|
|
27452
27612
|
return command.option("--name <name>", "Label to tell endpoints apart").option("--events <csv>", "Comma-separated event names").addOption(new Option("--active", "Deliver events to this endpoint")).addOption(new Option("--inactive", "Stop delivering events").conflicts("active")).addOption(new Option("--signing", "Sign deliveries (Standard Webhooks)")).addOption(
|
|
@@ -27464,13 +27624,13 @@ function endpointPayload(opts) {
|
|
|
27464
27624
|
if (opts.signing !== void 0) payload.signing_enabled = opts.signing;
|
|
27465
27625
|
return payload;
|
|
27466
27626
|
}
|
|
27467
|
-
var endpointsListCommand = new Command("list").alias("ls").description("List webhook endpoints, oldest first").action(async (
|
|
27627
|
+
var endpointsListCommand = new Command("list").alias("ls").description("List webhook endpoints, oldest first").option("--url <url>", "Only the endpoint registered with exactly this URL").action(async (opts, command) => {
|
|
27468
27628
|
await runWithClient(command, async ({ client, config }) => {
|
|
27469
27629
|
const accountId = requireAccountId(config);
|
|
27470
27630
|
const rows = await withSpinner(
|
|
27471
27631
|
"Fetching endpoints",
|
|
27472
27632
|
config,
|
|
27473
|
-
() => client.webhooks.listEndpoints(accountId)
|
|
27633
|
+
() => client.webhooks.listEndpoints(accountId, { url: opts.url })
|
|
27474
27634
|
);
|
|
27475
27635
|
printData(
|
|
27476
27636
|
rows,
|
|
@@ -27545,6 +27705,20 @@ var endpointsDeleteCommand = new Command("delete").alias("rm").description("Dele
|
|
|
27545
27705
|
printData({ id: endpointId, deleted: true }, config);
|
|
27546
27706
|
});
|
|
27547
27707
|
});
|
|
27708
|
+
var endpointsDeleteByUrlCommand = new Command("delete-by-url").description("Delete the webhook endpoint with exactly this registered URL").requiredOption("--url <url>", "Registered endpoint URL").option("-y, --yes", "Skip the confirmation prompt").action(async (opts, command) => {
|
|
27709
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27710
|
+
const accountId = requireAccountId(config);
|
|
27711
|
+
if (!await confirmDestructive(`Delete webhook endpoint ${opts.url}?`, Boolean(opts.yes)))
|
|
27712
|
+
return;
|
|
27713
|
+
const result = await withSpinner(
|
|
27714
|
+
"Deleting endpoint",
|
|
27715
|
+
config,
|
|
27716
|
+
() => client.webhooks.deleteEndpointByUrl(opts.url, accountId)
|
|
27717
|
+
);
|
|
27718
|
+
printSuccess("Webhook endpoint deleted", config);
|
|
27719
|
+
printData(result, config);
|
|
27720
|
+
});
|
|
27721
|
+
});
|
|
27548
27722
|
var endpointsSecretCommand = new Command("secret").description(
|
|
27549
27723
|
"Print the endpoint signing secret (signing must be enabled; not available via OAuth)"
|
|
27550
27724
|
).argument("<endpointId>", "Endpoint ID").action(async (endpointId, _opts, command) => {
|
|
@@ -27600,7 +27774,7 @@ var verifyCommand2 = new Command("verify").description(
|
|
|
27600
27774
|
printData({ valid, id: opts.id }, config, () => "valid");
|
|
27601
27775
|
});
|
|
27602
27776
|
});
|
|
27603
|
-
var endpointsCommand = new Command("endpoints").description("Manage webhook endpoints and their signing secrets").addCommand(endpointsListCommand).addCommand(endpointsCreateCommand).addCommand(endpointsGetCommand).addCommand(endpointsUpdateCommand).addCommand(endpointsDeleteCommand).addCommand(endpointsSecretCommand).addCommand(endpointsRotateSecretCommand);
|
|
27777
|
+
var endpointsCommand = new Command("endpoints").description("Manage webhook endpoints and their signing secrets").addCommand(endpointsListCommand).addCommand(endpointsCreateCommand).addCommand(endpointsGetCommand).addCommand(endpointsUpdateCommand).addCommand(endpointsDeleteCommand).addCommand(endpointsDeleteByUrlCommand).addCommand(endpointsSecretCommand).addCommand(endpointsRotateSecretCommand);
|
|
27604
27778
|
var webhooksCommand = new Command("webhooks").description("Manage webhook endpoints, the primary subscription, and delivery history").addCommand(endpointsCommand).addCommand(registerCommand).addCommand(getCommand6).addCommand(inactivateCommand).addCommand(eventTypesCommand).addCommand(dispatchesCommand).addCommand(retryCommand).addCommand(verifyCommand2);
|
|
27605
27779
|
|
|
27606
27780
|
// src/commands/whoami.ts
|
|
@@ -27824,7 +27998,7 @@ function handleStreamError(err, fallback, exit = process.exit) {
|
|
|
27824
27998
|
// package.json
|
|
27825
27999
|
var package_default = {
|
|
27826
28000
|
name: "@assinafy/cli",
|
|
27827
|
-
version: "2.
|
|
28001
|
+
version: "2.6.0",
|
|
27828
28002
|
description: "The official command-line interface for the Assinafy digital-signature API",
|
|
27829
28003
|
license: "MIT",
|
|
27830
28004
|
type: "module",
|