@assinafy/cli 2.5.3 → 2.6.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/.env.example +1 -1
- package/README.en.md +24 -3
- package/README.md +22 -2
- package/dist/api.cjs +121 -20
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +121 -20
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +601 -407
- 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 +1 -0
- 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 +5 -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 +473 -46
- package/docs/assignments.md +67 -9
- package/docs/sdk-reference.md +84 -11
- 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) {
|
|
@@ -21299,6 +21300,13 @@ function validateSignerOptions(input) {
|
|
|
21299
21300
|
throw new ValidationError("step must be an integer");
|
|
21300
21301
|
}
|
|
21301
21302
|
}
|
|
21303
|
+
function validateDigitalCertificateMethod(method, signers) {
|
|
21304
|
+
if (method !== "virtual" && signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
|
|
21305
|
+
throw new ValidationError("DigitalCertificate signers require method: virtual", {
|
|
21306
|
+
code: "digital_certificate_requires_virtual"
|
|
21307
|
+
});
|
|
21308
|
+
}
|
|
21309
|
+
}
|
|
21302
21310
|
function validateSigningSteps(signers) {
|
|
21303
21311
|
const withSteps = signers.filter((signer) => signer.step !== void 0);
|
|
21304
21312
|
if (withSteps.length > 0) {
|
|
@@ -21475,15 +21483,17 @@ function buildAssignmentPayload(payload, options = {}) {
|
|
|
21475
21483
|
signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
|
|
21476
21484
|
});
|
|
21477
21485
|
}
|
|
21478
|
-
|
|
21486
|
+
const method = payload.method ?? "virtual";
|
|
21487
|
+
const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref, options));
|
|
21488
|
+
validateDigitalCertificateMethod(method, normalisedSigners);
|
|
21489
|
+
if (method === "collect" && !Array.isArray(payload.entries)) {
|
|
21479
21490
|
throw new ValidationError("entries are required for collect assignments");
|
|
21480
21491
|
}
|
|
21481
|
-
const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref, options));
|
|
21482
21492
|
if (!options.skipDigitalCertificateStepValidation) {
|
|
21483
21493
|
validateSigningSteps(normalisedSigners);
|
|
21484
21494
|
}
|
|
21485
21495
|
return stripEmpty({
|
|
21486
|
-
method
|
|
21496
|
+
method,
|
|
21487
21497
|
signers: normalisedSigners,
|
|
21488
21498
|
message: payload.message,
|
|
21489
21499
|
expires_at: payload.expires_at === void 0 ? void 0 : requireIso8601(payload.expires_at, "expires_at"),
|
|
@@ -21532,6 +21542,53 @@ function normaliseSignerRef(ref, options) {
|
|
|
21532
21542
|
throw new ValidationError("Invalid signer reference", { ref });
|
|
21533
21543
|
}
|
|
21534
21544
|
var AssignmentResource = class extends BaseResource {
|
|
21545
|
+
/** Fetch an account review and available evidence for a signer's identity verification. */
|
|
21546
|
+
async getIdentityVerification(documentId, assignmentId, signerId) {
|
|
21547
|
+
const docId = this.requireId(documentId, "Document ID");
|
|
21548
|
+
const asgId = this.requireId(assignmentId, "Assignment ID");
|
|
21549
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
21550
|
+
return this.call(
|
|
21551
|
+
"Failed to fetch signer identity review",
|
|
21552
|
+
() => this.http.get(
|
|
21553
|
+
`/documents/${docId}/assignments/${asgId}/signers/${sid}/identity-verification`
|
|
21554
|
+
)
|
|
21555
|
+
);
|
|
21556
|
+
}
|
|
21557
|
+
/** Download JPEG/PNG evidence or the document PDF, available only while the review is open. */
|
|
21558
|
+
async downloadIdentityVerificationImage(documentId, assignmentId, signerId, name) {
|
|
21559
|
+
const docId = this.requireId(documentId, "Document ID");
|
|
21560
|
+
const asgId = this.requireId(assignmentId, "Assignment ID");
|
|
21561
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
21562
|
+
if (!["document_front", "document_back", "document_pdf", "face"].includes(name)) {
|
|
21563
|
+
throw new ValidationError("Unknown identity verification image name");
|
|
21564
|
+
}
|
|
21565
|
+
return this.callBinary(
|
|
21566
|
+
"Failed to download identity review image",
|
|
21567
|
+
() => this.http.get(
|
|
21568
|
+
`/documents/${docId}/assignments/${asgId}/signers/${sid}/identity-verification/images/${name}`,
|
|
21569
|
+
{ responseType: "arraybuffer" }
|
|
21570
|
+
)
|
|
21571
|
+
);
|
|
21572
|
+
}
|
|
21573
|
+
/** Approve certification or reject/cancel the document; the optional note is private to reviewers. */
|
|
21574
|
+
async reviewIdentityVerification(documentId, assignmentId, signerId, payload) {
|
|
21575
|
+
const docId = this.requireId(documentId, "Document ID");
|
|
21576
|
+
const asgId = this.requireId(assignmentId, "Assignment ID");
|
|
21577
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
21578
|
+
if (!payload || !["Approved", "Rejected"].includes(payload.decision)) {
|
|
21579
|
+
throw new ValidationError("decision must be Approved or Rejected");
|
|
21580
|
+
}
|
|
21581
|
+
if (payload.note != null && (typeof payload.note !== "string" || [...payload.note].length > 2e3)) {
|
|
21582
|
+
throw new ValidationError("note must contain at most 2000 characters");
|
|
21583
|
+
}
|
|
21584
|
+
return this.call(
|
|
21585
|
+
"Failed to decide signer identity review",
|
|
21586
|
+
() => this.http.post(
|
|
21587
|
+
`/documents/${docId}/assignments/${asgId}/signers/${sid}/identity-verification/review`,
|
|
21588
|
+
{ decision: payload.decision, note: payload.note }
|
|
21589
|
+
)
|
|
21590
|
+
);
|
|
21591
|
+
}
|
|
21535
21592
|
/**
|
|
21536
21593
|
* List assignments across the account (`GET /assignments`).
|
|
21537
21594
|
*
|
|
@@ -21786,6 +21843,7 @@ var DOCUMENT_SORTS = ["name", "-name", "updated_at", "-updated_at"];
|
|
|
21786
21843
|
var READY_STATUSES = /* @__PURE__ */ new Set([
|
|
21787
21844
|
"metadata_ready",
|
|
21788
21845
|
"pending_signature",
|
|
21846
|
+
"pending_identity_review",
|
|
21789
21847
|
"certificated"
|
|
21790
21848
|
]);
|
|
21791
21849
|
var FAILED_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -22039,6 +22097,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
22039
22097
|
if (options.tags !== void 0 && (!Array.isArray(options.tags) || options.tags.some((tag) => typeof tag !== "string" || !tag))) {
|
|
22040
22098
|
throw new ValidationError("tags must contain non-empty tag names");
|
|
22041
22099
|
}
|
|
22100
|
+
await this.validateCertificateTemplateMethod(tmplId, accId, signers);
|
|
22042
22101
|
const body = { ...options, signers };
|
|
22043
22102
|
this.logger.info("Creating document from template", { templateId: tmplId, accountId: accId });
|
|
22044
22103
|
return this.call(
|
|
@@ -22051,6 +22110,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
22051
22110
|
const tmplId = this.requireId(templateId, "Template ID");
|
|
22052
22111
|
const accId = this.accountId(accountId);
|
|
22053
22112
|
validateTemplateSigners(signers, { requireId: false });
|
|
22113
|
+
await this.validateCertificateTemplateMethod(tmplId, accId, signers);
|
|
22054
22114
|
return this.call(
|
|
22055
22115
|
"Failed to estimate cost from template",
|
|
22056
22116
|
() => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents/estimate-cost`, { signers })
|
|
@@ -22129,6 +22189,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
22129
22189
|
const percentage = total > 0 ? Math.round(signed / total * 1e4) / 100 : 0;
|
|
22130
22190
|
return { signed, total, pending, percentage };
|
|
22131
22191
|
}
|
|
22192
|
+
async validateCertificateTemplateMethod(templateId, accountId, signers) {
|
|
22193
|
+
if (!signers.some((signer) => signer.verification_method === "DigitalCertificate")) return;
|
|
22194
|
+
const template = await this.call(
|
|
22195
|
+
"Failed to fetch template",
|
|
22196
|
+
() => this.http.get(`/accounts/${accountId}/templates/${templateId}`)
|
|
22197
|
+
);
|
|
22198
|
+
const method = template.pages?.some((page) => page.fields.length > 0) ? "collect" : "virtual";
|
|
22199
|
+
validateDigitalCertificateMethod(method, signers);
|
|
22200
|
+
}
|
|
22132
22201
|
};
|
|
22133
22202
|
function validateTemplateSigners(signers, options) {
|
|
22134
22203
|
if (!Array.isArray(signers)) throw new ValidationError("signers must be an array");
|
|
@@ -22629,6 +22698,25 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
22629
22698
|
() => this.http.get("/signers/self", signerAccessConfig(code))
|
|
22630
22699
|
);
|
|
22631
22700
|
}
|
|
22701
|
+
/** `GET /signers/identity-verification` — session status, capture URL and restart eligibility. */
|
|
22702
|
+
async getIdentityVerification(signerAccessCode) {
|
|
22703
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22704
|
+
return this.call(
|
|
22705
|
+
"Failed to fetch identity verification",
|
|
22706
|
+
() => this.http.get("/signers/identity-verification", signerAccessConfig(code))
|
|
22707
|
+
);
|
|
22708
|
+
}
|
|
22709
|
+
/** `POST /signers/identity-verification` — open a hosted session after the signer's explicit consent. */
|
|
22710
|
+
async startIdentityVerification(signerAccessCode, payload) {
|
|
22711
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22712
|
+
if (payload?.consent !== true) {
|
|
22713
|
+
throw new ValidationError("Explicit biometric-processing consent is required");
|
|
22714
|
+
}
|
|
22715
|
+
return this.call(
|
|
22716
|
+
"Failed to start identity verification",
|
|
22717
|
+
() => this.http.post("/signers/identity-verification", { consent: true }, signerAccessConfig(code))
|
|
22718
|
+
);
|
|
22719
|
+
}
|
|
22632
22720
|
/**
|
|
22633
22721
|
* `PUT /signers/accept-terms?signer-access-code=…` — accept the platform
|
|
22634
22722
|
* terms as the signer.
|
|
@@ -22932,9 +23020,10 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
|
22932
23020
|
email: payload.email,
|
|
22933
23021
|
whatsapp_phone_number: payload.whatsapp_phone_number ?? payload.phone
|
|
22934
23022
|
};
|
|
22935
|
-
|
|
22936
|
-
|
|
22937
|
-
|
|
23023
|
+
if (payload.government_id !== void 0) {
|
|
23024
|
+
normalised.government_id = payload.government_id;
|
|
23025
|
+
} else if (payload.cpf) {
|
|
23026
|
+
const digits = payload.cpf.replace(/\D/g, "");
|
|
22938
23027
|
if (digits) normalised[useGovernmentId ? "government_id" : "cpf"] = digits;
|
|
22939
23028
|
}
|
|
22940
23029
|
if ("metadata" in payload && payload.metadata !== void 0) {
|
|
@@ -23173,19 +23262,21 @@ var WebhookResource = class extends BaseResource {
|
|
|
23173
23262
|
() => this.http.put(`/accounts/${id}/webhooks/inactivate`)
|
|
23174
23263
|
);
|
|
23175
23264
|
}
|
|
23176
|
-
/**
|
|
23177
|
-
async listEndpoints(accountId) {
|
|
23265
|
+
/** List webhook endpoints, oldest first; `url` matches the registered value exactly. */
|
|
23266
|
+
async listEndpoints(accountId, params = {}) {
|
|
23178
23267
|
const id = this.accountId(accountId);
|
|
23268
|
+
validateWebhookFields(params);
|
|
23179
23269
|
return this.call(
|
|
23180
23270
|
"Failed to list webhook endpoints",
|
|
23181
|
-
() => this.http.get(`/accounts/${id}/webhooks/endpoints
|
|
23271
|
+
() => this.http.get(`/accounts/${id}/webhooks/endpoints`, { params: cleanParams({ ...params }) })
|
|
23182
23272
|
);
|
|
23183
23273
|
}
|
|
23184
23274
|
/**
|
|
23185
23275
|
* `POST /accounts/{accountId}/webhooks/endpoints` — register another
|
|
23186
23276
|
* endpoint. Accounts allow 1 endpoint, or up to 3 on paid plans (`403` past
|
|
23187
23277
|
* the limit); URLs must be unique per workspace. Omitted `events` uses the
|
|
23188
|
-
* same default set as {@link register}.
|
|
23278
|
+
* same default set as {@link register}. Signed creation returns `secret`
|
|
23279
|
+
* once, including to OAuth applications; save it securely.
|
|
23189
23280
|
*/
|
|
23190
23281
|
async createEndpoint(payload, accountId) {
|
|
23191
23282
|
if (!payload.url) throw new ValidationError("Webhook URL is required");
|
|
@@ -23233,6 +23324,16 @@ var WebhookResource = class extends BaseResource {
|
|
|
23233
23324
|
() => this.http.delete(`/accounts/${id}/webhooks/endpoints/${eid}`)
|
|
23234
23325
|
);
|
|
23235
23326
|
}
|
|
23327
|
+
/** Delete the endpoint whose URL exactly matches `url`; returns 404 when none matches. */
|
|
23328
|
+
async deleteEndpointByUrl(url2, accountId) {
|
|
23329
|
+
if (!url2) throw new ValidationError("Webhook URL is required");
|
|
23330
|
+
validateWebhookFields({ url: url2 });
|
|
23331
|
+
const id = this.accountId(accountId);
|
|
23332
|
+
return this.call(
|
|
23333
|
+
"Failed to delete webhook endpoint by URL",
|
|
23334
|
+
() => this.http.delete(`/accounts/${id}/webhooks/endpoints`, { params: { url: url2 } })
|
|
23335
|
+
);
|
|
23336
|
+
}
|
|
23236
23337
|
/**
|
|
23237
23338
|
* `GET …/endpoints/{endpointId}/secret` — the `whsec_` signing secret.
|
|
23238
23339
|
* Returns `400` when signing is disabled. Not available to OAuth applications.
|
|
@@ -23390,12 +23491,10 @@ function readHeader(headers, name) {
|
|
|
23390
23491
|
if (typeof headers.get === "function") {
|
|
23391
23492
|
return headers.get(name) ?? void 0;
|
|
23392
23493
|
}
|
|
23393
|
-
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
|
|
23397
|
-
}
|
|
23398
|
-
return void 0;
|
|
23494
|
+
const matches = Object.entries(headers).filter(([key]) => key.toLowerCase() === name);
|
|
23495
|
+
if (matches.length !== 1) return void 0;
|
|
23496
|
+
const value = matches[0]?.[1];
|
|
23497
|
+
return Array.isArray(value) ? value.length === 1 ? value[0] : void 0 : value;
|
|
23399
23498
|
}
|
|
23400
23499
|
var WebhookVerifier = class {
|
|
23401
23500
|
constructor(webhookSecret, options = {}) {
|
|
@@ -23420,7 +23519,8 @@ var WebhookVerifier = class {
|
|
|
23420
23519
|
if (!id || !timestamp || !signatures || !/^\d+$/.test(timestamp)) return false;
|
|
23421
23520
|
const tolerance = options.toleranceSeconds ?? 300;
|
|
23422
23521
|
const now = Math.floor((options.now ?? Date.now()) / 1e3);
|
|
23423
|
-
if (Math.abs(now - Number(timestamp)) > tolerance)
|
|
23522
|
+
if (!Number.isFinite(tolerance) || tolerance < 0 || !Number.isSafeInteger(now) || now < 0 || !Number.isSafeInteger(Number(timestamp)) || Math.abs(now - Number(timestamp)) > tolerance)
|
|
23523
|
+
return false;
|
|
23424
23524
|
const secret = this.webhookSecret.startsWith("whsec_") ? this.webhookSecret.slice("whsec_".length) : this.webhookSecret;
|
|
23425
23525
|
const key = Buffer.from(secret, "base64");
|
|
23426
23526
|
if (key.length === 0) return false;
|
|
@@ -23428,8 +23528,8 @@ var WebhookVerifier = class {
|
|
|
23428
23528
|
(0, import_node_crypto2.createHmac)("sha256", key).update(`${id}.${timestamp}.`).update(typeof payload === "string" ? Buffer.from(payload, "utf8") : payload).digest("base64")
|
|
23429
23529
|
);
|
|
23430
23530
|
return signatures.split(" ").some((entry) => {
|
|
23431
|
-
const [version, value] = entry.split(","
|
|
23432
|
-
if (version !== "v1" || !value) return false;
|
|
23531
|
+
const [version, value, extra] = entry.split(",");
|
|
23532
|
+
if (version !== "v1" || !value || extra !== void 0) return false;
|
|
23433
23533
|
const provided = Buffer.from(value);
|
|
23434
23534
|
return provided.length === expected.length && (0, import_node_crypto2.timingSafeEqual)(provided, expected);
|
|
23435
23535
|
});
|
|
@@ -23634,6 +23734,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
23634
23734
|
const phone = signer.whatsapp_phone_number ?? signer.phone;
|
|
23635
23735
|
if (phone !== void 0) payload.whatsapp_phone_number = phone;
|
|
23636
23736
|
if (signer.cpf !== void 0) payload.cpf = signer.cpf;
|
|
23737
|
+
if (signer.government_id !== void 0) payload.government_id = signer.government_id;
|
|
23637
23738
|
if (signer.metadata !== void 0) payload.metadata = signer.metadata;
|
|
23638
23739
|
validateCreateSignerPayload(payload);
|
|
23639
23740
|
return { signer, payload, phone };
|
|
@@ -23780,85 +23881,9 @@ function requireAccountId(config, override) {
|
|
|
23780
23881
|
return id;
|
|
23781
23882
|
}
|
|
23782
23883
|
|
|
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
|
-
}
|
|
23884
|
+
// src/lib/files.ts
|
|
23885
|
+
var import_node_fs4 = require("fs");
|
|
23886
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
23862
23887
|
|
|
23863
23888
|
// src/lib/output.ts
|
|
23864
23889
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
@@ -23945,218 +23970,20 @@ function printError(err, config) {
|
|
|
23945
23970
|
process.exitCode = normalized.exitCode ?? 1;
|
|
23946
23971
|
}
|
|
23947
23972
|
|
|
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
|
-
}
|
|
23973
|
+
// node_modules/@clack/core/dist/index.mjs
|
|
23974
|
+
var import_node_util4 = require("util");
|
|
23975
|
+
var import_node_process2 = require("process");
|
|
23976
|
+
var l = __toESM(require("readline"), 1);
|
|
23977
|
+
var import_node_readline = __toESM(require("readline"), 1);
|
|
23980
23978
|
|
|
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;
|
|
23979
|
+
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
23980
|
+
var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
23981
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
23982
|
+
return (input) => {
|
|
23983
|
+
let surrogatePairsNr = 0;
|
|
23984
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
23985
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
23986
|
+
surrogatePairsNr += 1;
|
|
24160
23987
|
}
|
|
24161
23988
|
return input.length - surrogatePairsNr;
|
|
24162
23989
|
};
|
|
@@ -24856,8 +24683,8 @@ var n = class extends V {
|
|
|
24856
24683
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
24857
24684
|
var import_node_util5 = require("util");
|
|
24858
24685
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
24859
|
-
var
|
|
24860
|
-
var
|
|
24686
|
+
var import_node_fs3 = require("fs");
|
|
24687
|
+
var import_node_path3 = require("path");
|
|
24861
24688
|
var import_sisteransi2 = __toESM(require_src3(), 1);
|
|
24862
24689
|
function isUnicodeSupported() {
|
|
24863
24690
|
if (import_node_process3.default.platform !== "win32") {
|
|
@@ -25115,33 +24942,376 @@ ${d}${n2}
|
|
|
25115
24942
|
return `${s}${r2}${n2}${l2.trim() ? `
|
|
25116
24943
|
${r2}` : ""}`;
|
|
25117
24944
|
}
|
|
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
|
-
`;
|
|
24945
|
+
default: {
|
|
24946
|
+
const n2 = i2 ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", r2 = i2 ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
|
|
24947
|
+
return `${s}${n2}${o}
|
|
24948
|
+
${r2}
|
|
24949
|
+
`;
|
|
24950
|
+
}
|
|
24951
|
+
}
|
|
24952
|
+
}
|
|
24953
|
+
}).prompt();
|
|
24954
|
+
|
|
24955
|
+
// src/lib/spinner.ts
|
|
24956
|
+
async function withSpinner(message, config, task) {
|
|
24957
|
+
const useSpinner = !config.json && !config.quiet && process.stderr.isTTY;
|
|
24958
|
+
if (!useSpinner) {
|
|
24959
|
+
return task();
|
|
24960
|
+
}
|
|
24961
|
+
const s = spinner({ output: process.stderr });
|
|
24962
|
+
s.start(message);
|
|
24963
|
+
try {
|
|
24964
|
+
const result = await task();
|
|
24965
|
+
s.stop(message);
|
|
24966
|
+
return result;
|
|
24967
|
+
} catch (err) {
|
|
24968
|
+
s.error(message);
|
|
24969
|
+
throw err;
|
|
24970
|
+
}
|
|
24971
|
+
}
|
|
24972
|
+
|
|
24973
|
+
// src/lib/files.ts
|
|
24974
|
+
function readBinary(inputPath) {
|
|
24975
|
+
try {
|
|
24976
|
+
return (0, import_node_fs4.readFileSync)(import_node_path4.default.resolve(inputPath));
|
|
24977
|
+
} catch (err) {
|
|
24978
|
+
throw new CliError(
|
|
24979
|
+
`Failed to read file "${inputPath}": ${err instanceof Error ? err.message : String(err)}`
|
|
24980
|
+
);
|
|
24981
|
+
}
|
|
24982
|
+
}
|
|
24983
|
+
function writeBinary(outputPath, data, options = {}) {
|
|
24984
|
+
const resolved = import_node_path4.default.resolve(outputPath);
|
|
24985
|
+
try {
|
|
24986
|
+
(0, import_node_fs4.writeFileSync)(resolved, data, { flag: options.force ? "w" : "wx" });
|
|
24987
|
+
} catch (err) {
|
|
24988
|
+
if (err && typeof err === "object" && "code" in err && err.code === "EEXIST") {
|
|
24989
|
+
throw new CliError(`File "${resolved}" already exists. Pass --force to overwrite it.`);
|
|
24990
|
+
}
|
|
24991
|
+
throw new CliError(
|
|
24992
|
+
`Failed to write file "${resolved}": ${err instanceof Error ? err.message : String(err)}`
|
|
24993
|
+
);
|
|
24994
|
+
}
|
|
24995
|
+
return resolved;
|
|
24996
|
+
}
|
|
24997
|
+
function defaultArtifactFilename(documentId, artifact) {
|
|
24998
|
+
const ext = artifact === "thumbnail" ? "jpg" : artifact === "bundle" ? "zip" : "pdf";
|
|
24999
|
+
return `${documentId}-${artifact}.${ext}`;
|
|
25000
|
+
}
|
|
25001
|
+
async function saveDownload(config, options) {
|
|
25002
|
+
const buffer = await withSpinner(options.message, config, options.download);
|
|
25003
|
+
const out = writeBinary(options.output ?? options.defaultName, buffer, { force: options.force });
|
|
25004
|
+
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
25005
|
+
printData(
|
|
25006
|
+
{ path: out, bytes: buffer.byteLength, ...options.data },
|
|
25007
|
+
config,
|
|
25008
|
+
(d) => sanitizeTerminalText(d.path)
|
|
25009
|
+
);
|
|
25010
|
+
}
|
|
25011
|
+
|
|
25012
|
+
// src/lib/json.ts
|
|
25013
|
+
function parseJsonObject(raw, flag) {
|
|
25014
|
+
if (raw === void 0) return void 0;
|
|
25015
|
+
let parsed;
|
|
25016
|
+
try {
|
|
25017
|
+
parsed = JSON.parse(raw);
|
|
25018
|
+
} catch {
|
|
25019
|
+
throw new CliError(`${flag} must be valid JSON.`);
|
|
25020
|
+
}
|
|
25021
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
25022
|
+
throw new CliError(`${flag} must be a JSON object.`);
|
|
25023
|
+
}
|
|
25024
|
+
return parsed;
|
|
25025
|
+
}
|
|
25026
|
+
function parseJsonArray(raw, flag) {
|
|
25027
|
+
if (raw === void 0) return void 0;
|
|
25028
|
+
let parsed;
|
|
25029
|
+
try {
|
|
25030
|
+
parsed = JSON.parse(raw);
|
|
25031
|
+
} catch {
|
|
25032
|
+
throw new CliError(`${flag} must be valid JSON.`);
|
|
25033
|
+
}
|
|
25034
|
+
if (!Array.isArray(parsed)) {
|
|
25035
|
+
throw new CliError(`${flag} must be a JSON array.`);
|
|
25036
|
+
}
|
|
25037
|
+
return parsed;
|
|
25038
|
+
}
|
|
25039
|
+
function splitList(raw) {
|
|
25040
|
+
if (raw === void 0) return void 0;
|
|
25041
|
+
const items = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
25042
|
+
return items;
|
|
25043
|
+
}
|
|
25044
|
+
function collect(value, previous = []) {
|
|
25045
|
+
return [...previous, value];
|
|
25046
|
+
}
|
|
25047
|
+
function parseInteger(raw, flag, options = {}) {
|
|
25048
|
+
if (raw === void 0) return void 0;
|
|
25049
|
+
const trimmed = raw.trim();
|
|
25050
|
+
if (!/^-?\d+$/.test(trimmed)) {
|
|
25051
|
+
throw new CliError(`${flag} must be an integer.`);
|
|
25052
|
+
}
|
|
25053
|
+
const n2 = Number(trimmed);
|
|
25054
|
+
if (!Number.isSafeInteger(n2)) {
|
|
25055
|
+
throw new CliError(`${flag} must be a safe integer.`);
|
|
25056
|
+
}
|
|
25057
|
+
if (options.min !== void 0 && n2 < options.min) {
|
|
25058
|
+
throw new CliError(`${flag} must be ${options.min} or greater.`);
|
|
25059
|
+
}
|
|
25060
|
+
return n2;
|
|
25061
|
+
}
|
|
25062
|
+
|
|
25063
|
+
// src/lib/options.ts
|
|
25064
|
+
function addPaginationOptions(command) {
|
|
25065
|
+
return command.option("--page <n>", "Page number to fetch").option("--per-page <n>", "Items per page");
|
|
25066
|
+
}
|
|
25067
|
+
function addSearchListOptions(command) {
|
|
25068
|
+
return addPaginationOptions(command).option("--search <query>", "Filter by a search query");
|
|
25069
|
+
}
|
|
25070
|
+
function addSortableListOptions(command, description) {
|
|
25071
|
+
return addPaginationOptions(command).option("--sort <field>", description);
|
|
25072
|
+
}
|
|
25073
|
+
function addListOptions(command, sortDescription = "Sort by field") {
|
|
25074
|
+
return addSearchListOptions(command).option("--sort <field>", sortDescription);
|
|
25075
|
+
}
|
|
25076
|
+
function addDownloadOptions(command) {
|
|
25077
|
+
return command.option("-o, --output <path>", "Output file path").option("--force", "Overwrite the output file if it already exists");
|
|
25078
|
+
}
|
|
25079
|
+
function addSignerRefOptions(command) {
|
|
25080
|
+
return command.addOption(
|
|
25081
|
+
new Option("--signer-ids <csv>", "Comma-separated signer IDs (required)").conflicts(
|
|
25082
|
+
"signers"
|
|
25083
|
+
)
|
|
25084
|
+
).addOption(
|
|
25085
|
+
new Option(
|
|
25086
|
+
"--signers <json>",
|
|
25087
|
+
"JSON array of signer refs, with verification_method, step, \u2026 (required)"
|
|
25088
|
+
).conflicts("signerIds")
|
|
25089
|
+
);
|
|
25090
|
+
}
|
|
25091
|
+
|
|
25092
|
+
// src/lib/pagination.ts
|
|
25093
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
25094
|
+
function listParams(flags) {
|
|
25095
|
+
const params = {};
|
|
25096
|
+
const page = parseInteger(flags.page, "--page", { min: 1 });
|
|
25097
|
+
const perPage = parseInteger(flags.perPage, "--per-page", { min: 1 });
|
|
25098
|
+
if (page !== void 0) params.page = page;
|
|
25099
|
+
if (perPage !== void 0) params["per-page"] = perPage;
|
|
25100
|
+
if (flags.search) params.search = flags.search;
|
|
25101
|
+
if (flags.sort) params.sort = flags.sort;
|
|
25102
|
+
return params;
|
|
25103
|
+
}
|
|
25104
|
+
function paginationFooter(result) {
|
|
25105
|
+
const meta = result.meta;
|
|
25106
|
+
if (!meta) return "";
|
|
25107
|
+
const parts = [];
|
|
25108
|
+
if (meta.current_page !== void 0 && meta.last_page !== void 0) {
|
|
25109
|
+
parts.push(`page ${meta.current_page}/${meta.last_page}`);
|
|
25110
|
+
}
|
|
25111
|
+
if (meta.total !== void 0) {
|
|
25112
|
+
parts.push(`${meta.total} total`);
|
|
25113
|
+
}
|
|
25114
|
+
if (meta.per_page !== void 0) {
|
|
25115
|
+
parts.push(`${meta.per_page}/page`);
|
|
25116
|
+
}
|
|
25117
|
+
return parts.length > 0 ? import_picocolors2.default.dim(parts.join(" \xB7 ")) : "";
|
|
25118
|
+
}
|
|
25119
|
+
function tableWithFooter(table, result) {
|
|
25120
|
+
const footer = paginationFooter(result);
|
|
25121
|
+
return footer ? `${table}
|
|
25122
|
+
${footer}` : table;
|
|
25123
|
+
}
|
|
25124
|
+
|
|
25125
|
+
// src/lib/prompts.ts
|
|
25126
|
+
async function promptText(message, placeholder) {
|
|
25127
|
+
const value = await text({ message, placeholder, output: process.stderr });
|
|
25128
|
+
return unwrap(value);
|
|
25129
|
+
}
|
|
25130
|
+
async function promptSecret(message) {
|
|
25131
|
+
const value = await password({ message, output: process.stderr });
|
|
25132
|
+
return unwrap(value);
|
|
25133
|
+
}
|
|
25134
|
+
async function confirmDestructive(message, force) {
|
|
25135
|
+
if (force) return true;
|
|
25136
|
+
if (!process.stdin.isTTY) {
|
|
25137
|
+
throw new CliError("Refusing to proceed without confirmation. Re-run with --yes to confirm.");
|
|
25138
|
+
}
|
|
25139
|
+
const value = await confirm({ message, output: process.stderr });
|
|
25140
|
+
return unwrap(value);
|
|
25141
|
+
}
|
|
25142
|
+
function unwrap(value) {
|
|
25143
|
+
if (isCancel3(value)) {
|
|
25144
|
+
cancel("Cancelled.", { output: process.stderr });
|
|
25145
|
+
throw new CliError("Cancelled.", { exitCode: 130 });
|
|
25146
|
+
}
|
|
25147
|
+
return value;
|
|
25148
|
+
}
|
|
25149
|
+
|
|
25150
|
+
// src/lib/config.ts
|
|
25151
|
+
var import_node_crypto3 = require("crypto");
|
|
25152
|
+
var import_node_fs5 = require("fs");
|
|
25153
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
25154
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
25155
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
25156
|
+
var DEFAULT_BASE_URL2 = "https://api.assinafy.com.br/v1";
|
|
25157
|
+
var DEFAULT_PROFILE = "default";
|
|
25158
|
+
function configDir() {
|
|
25159
|
+
if (process.env.ASSINAFY_CONFIG_DIR) {
|
|
25160
|
+
return process.env.ASSINAFY_CONFIG_DIR;
|
|
25161
|
+
}
|
|
25162
|
+
if (process.platform === "win32" && process.env.APPDATA) {
|
|
25163
|
+
return import_node_path5.default.join(process.env.APPDATA, "assinafy");
|
|
25164
|
+
}
|
|
25165
|
+
const xdg = process.env.XDG_CONFIG_HOME;
|
|
25166
|
+
const base = xdg && xdg.length > 0 ? xdg : import_node_path5.default.join(import_node_os.default.homedir(), ".config");
|
|
25167
|
+
return import_node_path5.default.join(base, "assinafy");
|
|
25168
|
+
}
|
|
25169
|
+
function configPath() {
|
|
25170
|
+
return import_node_path5.default.join(configDir(), "config.json");
|
|
25171
|
+
}
|
|
25172
|
+
function readConfigFile(options = {}) {
|
|
25173
|
+
const file = configPath();
|
|
25174
|
+
if (!(0, import_node_fs5.existsSync)(file)) {
|
|
25175
|
+
return {};
|
|
25176
|
+
}
|
|
25177
|
+
try {
|
|
25178
|
+
const parsed = JSON.parse((0, import_node_fs5.readFileSync)(file, "utf8"));
|
|
25179
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
25180
|
+
if (parsed.default_profile !== void 0 && typeof parsed.default_profile !== "string") {
|
|
25181
|
+
throw new Error("Invalid default_profile");
|
|
25182
|
+
}
|
|
25183
|
+
if (parsed.profiles !== void 0) {
|
|
25184
|
+
if (!parsed.profiles || typeof parsed.profiles !== "object" || Array.isArray(parsed.profiles)) {
|
|
25185
|
+
throw new Error("Invalid profiles");
|
|
25186
|
+
}
|
|
25187
|
+
for (const profile of Object.values(parsed.profiles)) {
|
|
25188
|
+
if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
|
|
25189
|
+
throw new Error("Invalid profile");
|
|
25190
|
+
}
|
|
25191
|
+
for (const key of [
|
|
25192
|
+
"api_key",
|
|
25193
|
+
"token",
|
|
25194
|
+
"account_id",
|
|
25195
|
+
"base_url",
|
|
25196
|
+
"webhook_secret"
|
|
25197
|
+
]) {
|
|
25198
|
+
if (profile[key] !== void 0 && typeof profile[key] !== "string") {
|
|
25199
|
+
throw new Error("Invalid profile field");
|
|
25200
|
+
}
|
|
25201
|
+
}
|
|
25202
|
+
}
|
|
25203
|
+
Object.setPrototypeOf(parsed.profiles, null);
|
|
25123
25204
|
}
|
|
25205
|
+
return parsed;
|
|
25124
25206
|
}
|
|
25207
|
+
if (options.strict) {
|
|
25208
|
+
throw new CliError(`Config file at ${file} is not a JSON object; refusing to overwrite it.`);
|
|
25209
|
+
}
|
|
25210
|
+
process.stderr.write(
|
|
25211
|
+
`${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} is not a JSON object; ignoring it.
|
|
25212
|
+
`
|
|
25213
|
+
);
|
|
25214
|
+
return {};
|
|
25215
|
+
} catch (error) {
|
|
25216
|
+
if (error instanceof CliError) throw error;
|
|
25217
|
+
if (options.strict) {
|
|
25218
|
+
throw new CliError(
|
|
25219
|
+
`Config file at ${file} has invalid JSON or field types; refusing to overwrite it.`
|
|
25220
|
+
);
|
|
25221
|
+
}
|
|
25222
|
+
process.stderr.write(
|
|
25223
|
+
`${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} has invalid JSON or field types; ignoring it.
|
|
25224
|
+
`
|
|
25225
|
+
);
|
|
25226
|
+
return {};
|
|
25125
25227
|
}
|
|
25126
|
-
}
|
|
25127
|
-
|
|
25128
|
-
|
|
25129
|
-
|
|
25130
|
-
|
|
25131
|
-
if (!useSpinner) {
|
|
25132
|
-
return task();
|
|
25228
|
+
}
|
|
25229
|
+
function writeConfigFile(config) {
|
|
25230
|
+
const dir = configDir();
|
|
25231
|
+
if (!(0, import_node_fs5.existsSync)(dir)) {
|
|
25232
|
+
(0, import_node_fs5.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
25133
25233
|
}
|
|
25134
|
-
|
|
25135
|
-
|
|
25234
|
+
if (process.platform !== "win32") (0, import_node_fs5.chmodSync)(dir, 448);
|
|
25235
|
+
const file = configPath();
|
|
25236
|
+
const tmp = `${file}.${(0, import_node_crypto3.randomUUID)()}.tmp`;
|
|
25136
25237
|
try {
|
|
25137
|
-
|
|
25138
|
-
|
|
25139
|
-
|
|
25238
|
+
(0, import_node_fs5.writeFileSync)(tmp, `${JSON.stringify(config, null, 2)}
|
|
25239
|
+
`, {
|
|
25240
|
+
flag: "wx",
|
|
25241
|
+
mode: 384
|
|
25242
|
+
});
|
|
25243
|
+
(0, import_node_fs5.chmodSync)(tmp, 384);
|
|
25244
|
+
(0, import_node_fs5.renameSync)(tmp, file);
|
|
25140
25245
|
} catch (err) {
|
|
25141
|
-
|
|
25246
|
+
(0, import_node_fs5.rmSync)(tmp, { force: true });
|
|
25142
25247
|
throw err;
|
|
25143
25248
|
}
|
|
25144
25249
|
}
|
|
25250
|
+
function activeProfileName(globals, file = readConfigFile()) {
|
|
25251
|
+
return globals.profile || process.env.ASSINAFY_PROFILE || file.default_profile || DEFAULT_PROFILE;
|
|
25252
|
+
}
|
|
25253
|
+
function resolveConfig2(globals) {
|
|
25254
|
+
const file = readConfigFile();
|
|
25255
|
+
const profileName = activeProfileName(globals, file);
|
|
25256
|
+
const profile = file.profiles?.[profileName] ?? {};
|
|
25257
|
+
const pick = (flag, env, stored) => flag || env || stored || void 0;
|
|
25258
|
+
const baseUrl = pick(globals.baseUrl, process.env.ASSINAFY_BASE_URL, profile.base_url) ?? DEFAULT_BASE_URL2;
|
|
25259
|
+
const credentials = [
|
|
25260
|
+
{ apiKey: globals.apiKey, token: globals.token },
|
|
25261
|
+
{ apiKey: process.env.ASSINAFY_API_KEY, token: process.env.ASSINAFY_TOKEN },
|
|
25262
|
+
{ apiKey: profile.api_key, token: profile.token }
|
|
25263
|
+
].find(({ apiKey, token }) => apiKey || token);
|
|
25264
|
+
return {
|
|
25265
|
+
apiKey: credentials?.apiKey,
|
|
25266
|
+
token: credentials?.token,
|
|
25267
|
+
accountId: pick(globals.accountId, process.env.ASSINAFY_ACCOUNT_ID, profile.account_id),
|
|
25268
|
+
baseUrl: normalizeBaseUrl(baseUrl),
|
|
25269
|
+
webhookSecret: pick(void 0, process.env.ASSINAFY_WEBHOOK_SECRET, profile.webhook_secret),
|
|
25270
|
+
profile: profileName,
|
|
25271
|
+
json: Boolean(globals.json),
|
|
25272
|
+
quiet: Boolean(globals.quiet)
|
|
25273
|
+
};
|
|
25274
|
+
}
|
|
25275
|
+
|
|
25276
|
+
// src/lib/run.ts
|
|
25277
|
+
function getGlobals(command) {
|
|
25278
|
+
const opts = command.optsWithGlobals();
|
|
25279
|
+
return {
|
|
25280
|
+
apiKey: opts.apiKey,
|
|
25281
|
+
token: opts.token,
|
|
25282
|
+
accountId: opts.accountId,
|
|
25283
|
+
baseUrl: opts.baseUrl,
|
|
25284
|
+
profile: opts.profile,
|
|
25285
|
+
json: Boolean(opts.json),
|
|
25286
|
+
quiet: Boolean(opts.quiet)
|
|
25287
|
+
};
|
|
25288
|
+
}
|
|
25289
|
+
async function withResolvedConfig(command, handler) {
|
|
25290
|
+
let outputConfig = { json: false, quiet: false };
|
|
25291
|
+
try {
|
|
25292
|
+
const globals = getGlobals(command);
|
|
25293
|
+
outputConfig = { json: Boolean(globals.json), quiet: Boolean(globals.quiet) };
|
|
25294
|
+
const config = resolveConfig2(globals);
|
|
25295
|
+
await handler(config);
|
|
25296
|
+
} catch (err) {
|
|
25297
|
+
printError(err, outputConfig);
|
|
25298
|
+
}
|
|
25299
|
+
}
|
|
25300
|
+
function runWithClient(command, handler) {
|
|
25301
|
+
return withResolvedConfig(command, (config) => handler({ client: createClient(config), config }));
|
|
25302
|
+
}
|
|
25303
|
+
function runWithPublicClient(command, handler) {
|
|
25304
|
+
return withResolvedConfig(
|
|
25305
|
+
command,
|
|
25306
|
+
(config) => handler({
|
|
25307
|
+
client: createClient(config, { allowUnauthenticated: true, omitCredentials: true }),
|
|
25308
|
+
config
|
|
25309
|
+
})
|
|
25310
|
+
);
|
|
25311
|
+
}
|
|
25312
|
+
function runAction(command, handler) {
|
|
25313
|
+
return withResolvedConfig(command, (config) => handler({ config }));
|
|
25314
|
+
}
|
|
25145
25315
|
|
|
25146
25316
|
// src/lib/table.ts
|
|
25147
25317
|
var import_node_util6 = require("util");
|
|
@@ -25364,32 +25534,55 @@ var whatsappCommand = new Command("whatsapp-notifications").description("List Wh
|
|
|
25364
25534
|
);
|
|
25365
25535
|
});
|
|
25366
25536
|
});
|
|
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
|
-
}
|
|
25537
|
+
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) => {
|
|
25538
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
25539
|
+
const result = await withSpinner(
|
|
25540
|
+
"Fetching identity review",
|
|
25541
|
+
config,
|
|
25542
|
+
() => client.assignments.getIdentityVerification(documentId, assignmentId, signerId)
|
|
25543
|
+
);
|
|
25544
|
+
printData(result, config);
|
|
25545
|
+
});
|
|
25546
|
+
});
|
|
25547
|
+
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(
|
|
25548
|
+
new Option("--name <name>", "Evidence image name").choices(["document_front", "document_back", "document_pdf", "face"]).makeOptionMandatory()
|
|
25549
|
+
).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) => {
|
|
25550
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
25551
|
+
await saveDownload(config, {
|
|
25552
|
+
message: "Downloading identity evidence",
|
|
25553
|
+
download: () => client.assignments.downloadIdentityVerificationImage(
|
|
25554
|
+
documentId,
|
|
25555
|
+
assignmentId,
|
|
25556
|
+
signerId,
|
|
25557
|
+
opts.name
|
|
25558
|
+
),
|
|
25559
|
+
output: opts.output,
|
|
25560
|
+
defaultName: opts.output,
|
|
25561
|
+
force: opts.force
|
|
25562
|
+
});
|
|
25563
|
+
});
|
|
25564
|
+
});
|
|
25565
|
+
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(
|
|
25566
|
+
new Option("--decision <decision>", "Review decision").choices(["Approved", "Rejected"]).makeOptionMandatory()
|
|
25567
|
+
).option("--note <note>", "Private review note (at most 2000 characters)").option("-y, --yes", "Skip the confirmation prompt").action(async (documentId, assignmentId, signerId, opts, command) => {
|
|
25568
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
25569
|
+
if (!await confirmDestructive(
|
|
25570
|
+
opts.decision === "Rejected" ? `Reject this identity review, cancel document ${documentId}, and notify its recipients?` : `Approve this identity review and release certification for ${documentId}?`,
|
|
25571
|
+
Boolean(opts.yes)
|
|
25572
|
+
))
|
|
25573
|
+
return;
|
|
25574
|
+
const result = await withSpinner(
|
|
25575
|
+
"Deciding identity review",
|
|
25576
|
+
config,
|
|
25577
|
+
() => client.assignments.reviewIdentityVerification(documentId, assignmentId, signerId, {
|
|
25578
|
+
decision: opts.decision,
|
|
25579
|
+
note: opts.note
|
|
25580
|
+
})
|
|
25581
|
+
);
|
|
25582
|
+
printData(result, config);
|
|
25583
|
+
});
|
|
25584
|
+
});
|
|
25585
|
+
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
25586
|
|
|
25394
25587
|
// src/commands/auth.ts
|
|
25395
25588
|
function resetPasswordPayload(email, resetToken, newPassword) {
|
|
@@ -25683,7 +25876,7 @@ var setCommand = new Command("set").description(
|
|
|
25683
25876
|
const merged = command.optsWithGlobals();
|
|
25684
25877
|
const file = readConfigFile({ strict: true });
|
|
25685
25878
|
const profileName = activeProfileName(getGlobals(command), file);
|
|
25686
|
-
const profiles = file.profiles ??
|
|
25879
|
+
const profiles = file.profiles ?? /* @__PURE__ */ Object.create(null);
|
|
25687
25880
|
const profile = { ...profiles[profileName] };
|
|
25688
25881
|
let changed = false;
|
|
25689
25882
|
if (merged.apiKey !== void 0) {
|
|
@@ -25977,47 +26170,6 @@ var docsCommand = new Command("docs").description("Print (or open) the Assinafy
|
|
|
25977
26170
|
});
|
|
25978
26171
|
});
|
|
25979
26172
|
|
|
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
26173
|
// src/commands/documents.ts
|
|
26022
26174
|
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
26175
|
await runWithClient(command, async ({ client, config }) => {
|
|
@@ -26543,7 +26695,7 @@ var loginCommand2 = new Command("login").description(
|
|
|
26543
26695
|
const apiKey = merged.apiKey ?? await promptSecret("Enter your Assinafy API key");
|
|
26544
26696
|
const accountId = merged.accountId ?? await promptText("Default account/workspace ID (optional)");
|
|
26545
26697
|
const profileName = activeProfileName(getGlobals(command), file);
|
|
26546
|
-
const profiles = file.profiles ??
|
|
26698
|
+
const profiles = file.profiles ?? /* @__PURE__ */ Object.create(null);
|
|
26547
26699
|
const profile = { ...profiles[profileName], api_key: apiKey };
|
|
26548
26700
|
if (accountId) profile.account_id = accountId;
|
|
26549
26701
|
if (merged.baseUrl) profile.base_url = merged.baseUrl;
|
|
@@ -26863,6 +27015,27 @@ var selfCommand = new Command("self").description("Fetch the signer's own profil
|
|
|
26863
27015
|
printData(profile, config);
|
|
26864
27016
|
});
|
|
26865
27017
|
});
|
|
27018
|
+
var identityStatusCommand = new Command("identity-status").description("Fetch biometric verification status and the private capture URL").addOption(accessCodeOption()).action(async (opts, command) => {
|
|
27019
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
27020
|
+
const result = await withSpinner(
|
|
27021
|
+
"Fetching identity verification",
|
|
27022
|
+
config,
|
|
27023
|
+
() => client.signerDocuments.getIdentityVerification(opts.accessCode)
|
|
27024
|
+
);
|
|
27025
|
+
printData(result, config);
|
|
27026
|
+
});
|
|
27027
|
+
});
|
|
27028
|
+
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) => {
|
|
27029
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
27030
|
+
if (!opts.consent) throw new CliError("The signer\u2019s explicit --consent is required.");
|
|
27031
|
+
const result = await withSpinner(
|
|
27032
|
+
"Starting identity verification",
|
|
27033
|
+
config,
|
|
27034
|
+
() => client.signerDocuments.startIdentityVerification(opts.accessCode, { consent: true })
|
|
27035
|
+
);
|
|
27036
|
+
printData(result, config);
|
|
27037
|
+
});
|
|
27038
|
+
});
|
|
26866
27039
|
var acceptTermsCommand = new Command("accept-terms").description("Accept the platform terms as the signer").addOption(accessCodeOption()).action(async (opts, command) => {
|
|
26867
27040
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
26868
27041
|
const result = await withSpinner(
|
|
@@ -27021,7 +27194,7 @@ var declineMultipleCommand = new Command("decline-multiple").description("Declin
|
|
|
27021
27194
|
printData(result, config);
|
|
27022
27195
|
});
|
|
27023
27196
|
});
|
|
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);
|
|
27197
|
+
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
27198
|
|
|
27026
27199
|
// src/commands/signers.ts
|
|
27027
27200
|
var signerColumns = [
|
|
@@ -27033,13 +27206,16 @@ var signerColumns = [
|
|
|
27033
27206
|
value: (r2) => r2.whatsapp_phone_number
|
|
27034
27207
|
}
|
|
27035
27208
|
];
|
|
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").
|
|
27209
|
+
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(
|
|
27210
|
+
new Option("--government-id <id>", "CPF or numeric/alphanumeric CNPJ").conflicts("cpf")
|
|
27211
|
+
).option("--metadata <json>", "JSON object of metadata").action(async (opts, command) => {
|
|
27037
27212
|
await runWithClient(command, async ({ client, config }) => {
|
|
27038
27213
|
const accountId = requireAccountId(config);
|
|
27039
27214
|
const payload = { full_name: opts.name };
|
|
27040
27215
|
if (opts.email) payload.email = opts.email;
|
|
27041
27216
|
if (opts.phone) payload.whatsapp_phone_number = opts.phone;
|
|
27042
27217
|
if (opts.cpf) payload.cpf = opts.cpf;
|
|
27218
|
+
if (opts.governmentId !== void 0) payload.government_id = opts.governmentId;
|
|
27043
27219
|
const metadata = parseJsonObject(opts.metadata, "--metadata");
|
|
27044
27220
|
if (metadata) payload.metadata = metadata;
|
|
27045
27221
|
const signer = await withSpinner(
|
|
@@ -27088,7 +27264,9 @@ var getCommand4 = new Command("get").description("Show a signer by ID").argument
|
|
|
27088
27264
|
printData(signer, config, (s) => renderKeyValue(s));
|
|
27089
27265
|
});
|
|
27090
27266
|
});
|
|
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").
|
|
27267
|
+
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(
|
|
27268
|
+
new Option("--government-id <id>", "CPF or numeric/alphanumeric CNPJ").conflicts("cpf")
|
|
27269
|
+
).action(async (id, opts, command) => {
|
|
27092
27270
|
await runWithClient(command, async ({ client, config }) => {
|
|
27093
27271
|
const accountId = requireAccountId(config);
|
|
27094
27272
|
const payload = {};
|
|
@@ -27096,6 +27274,7 @@ var updateCommand2 = new Command("update").description("Update a signer").argume
|
|
|
27096
27274
|
if (opts.email) payload.email = opts.email;
|
|
27097
27275
|
if (opts.phone) payload.whatsapp_phone_number = opts.phone;
|
|
27098
27276
|
if (opts.cpf) payload.cpf = opts.cpf;
|
|
27277
|
+
if (opts.governmentId !== void 0) payload.government_id = opts.governmentId;
|
|
27099
27278
|
const signer = await withSpinner(
|
|
27100
27279
|
"Updating signer",
|
|
27101
27280
|
config,
|
|
@@ -27446,7 +27625,8 @@ var renderEndpoint = (e) => renderKeyValue({
|
|
|
27446
27625
|
email: e.email,
|
|
27447
27626
|
is_active: e.is_active,
|
|
27448
27627
|
signing_enabled: e.signing_enabled,
|
|
27449
|
-
events: e.events
|
|
27628
|
+
events: e.events,
|
|
27629
|
+
secret: e.secret
|
|
27450
27630
|
});
|
|
27451
27631
|
function endpointFieldOptions(command) {
|
|
27452
27632
|
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 +27644,13 @@ function endpointPayload(opts) {
|
|
|
27464
27644
|
if (opts.signing !== void 0) payload.signing_enabled = opts.signing;
|
|
27465
27645
|
return payload;
|
|
27466
27646
|
}
|
|
27467
|
-
var endpointsListCommand = new Command("list").alias("ls").description("List webhook endpoints, oldest first").action(async (
|
|
27647
|
+
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
27648
|
await runWithClient(command, async ({ client, config }) => {
|
|
27469
27649
|
const accountId = requireAccountId(config);
|
|
27470
27650
|
const rows = await withSpinner(
|
|
27471
27651
|
"Fetching endpoints",
|
|
27472
27652
|
config,
|
|
27473
|
-
() => client.webhooks.listEndpoints(accountId)
|
|
27653
|
+
() => client.webhooks.listEndpoints(accountId, { url: opts.url })
|
|
27474
27654
|
);
|
|
27475
27655
|
printData(
|
|
27476
27656
|
rows,
|
|
@@ -27545,6 +27725,20 @@ var endpointsDeleteCommand = new Command("delete").alias("rm").description("Dele
|
|
|
27545
27725
|
printData({ id: endpointId, deleted: true }, config);
|
|
27546
27726
|
});
|
|
27547
27727
|
});
|
|
27728
|
+
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) => {
|
|
27729
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27730
|
+
const accountId = requireAccountId(config);
|
|
27731
|
+
if (!await confirmDestructive(`Delete webhook endpoint ${opts.url}?`, Boolean(opts.yes)))
|
|
27732
|
+
return;
|
|
27733
|
+
const result = await withSpinner(
|
|
27734
|
+
"Deleting endpoint",
|
|
27735
|
+
config,
|
|
27736
|
+
() => client.webhooks.deleteEndpointByUrl(opts.url, accountId)
|
|
27737
|
+
);
|
|
27738
|
+
printSuccess("Webhook endpoint deleted", config);
|
|
27739
|
+
printData(result, config);
|
|
27740
|
+
});
|
|
27741
|
+
});
|
|
27548
27742
|
var endpointsSecretCommand = new Command("secret").description(
|
|
27549
27743
|
"Print the endpoint signing secret (signing must be enabled; not available via OAuth)"
|
|
27550
27744
|
).argument("<endpointId>", "Endpoint ID").action(async (endpointId, _opts, command) => {
|
|
@@ -27600,7 +27794,7 @@ var verifyCommand2 = new Command("verify").description(
|
|
|
27600
27794
|
printData({ valid, id: opts.id }, config, () => "valid");
|
|
27601
27795
|
});
|
|
27602
27796
|
});
|
|
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);
|
|
27797
|
+
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
27798
|
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
27799
|
|
|
27606
27800
|
// src/commands/whoami.ts
|
|
@@ -27824,7 +28018,7 @@ function handleStreamError(err, fallback, exit = process.exit) {
|
|
|
27824
28018
|
// package.json
|
|
27825
28019
|
var package_default = {
|
|
27826
28020
|
name: "@assinafy/cli",
|
|
27827
|
-
version: "2.
|
|
28021
|
+
version: "2.6.1",
|
|
27828
28022
|
description: "The official command-line interface for the Assinafy digital-signature API",
|
|
27829
28023
|
license: "MIT",
|
|
27830
28024
|
type: "module",
|