@assinafy/cli 2.5.2 → 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 +124 -29
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +124 -29
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +606 -418
- 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 +24 -11
- 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 +86 -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) {
|
|
@@ -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([
|
|
@@ -22524,32 +22573,46 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
22524
22573
|
() => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code))
|
|
22525
22574
|
);
|
|
22526
22575
|
}
|
|
22576
|
+
/** `GET /signers/{signer_id}/documents?signer-access-code=…` */
|
|
22577
|
+
async list(signerId, signerAccessCode, params = {}) {
|
|
22578
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22579
|
+
return this.listDocuments(signerId, signerAccessConfig(code, { ...params }));
|
|
22580
|
+
}
|
|
22527
22581
|
/**
|
|
22528
|
-
* `GET /signers/{signer_id}/documents`
|
|
22529
|
-
*
|
|
22530
|
-
*
|
|
22582
|
+
* `GET /signers/{signer_id}/documents` with the client's owner credentials
|
|
22583
|
+
* (API key or token) instead of a signer access code. The signer must belong
|
|
22584
|
+
* to that workspace.
|
|
22531
22585
|
*/
|
|
22532
|
-
async
|
|
22586
|
+
async listAsOwner(signerId, params = {}) {
|
|
22587
|
+
return this.listDocuments(signerId, { params: cleanParams({ ...params }) });
|
|
22588
|
+
}
|
|
22589
|
+
/** `GET /signers/{signer_id}/documents/search?search=…&signer-access-code=…` */
|
|
22590
|
+
async search(signerId, search, signerAccessCode) {
|
|
22591
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22592
|
+
return this.searchDocuments(signerId, signerAccessConfig(code, { search }));
|
|
22593
|
+
}
|
|
22594
|
+
/**
|
|
22595
|
+
* `GET /signers/{signer_id}/documents/search?search=…` with the client's owner
|
|
22596
|
+
* credentials instead of a signer access code. The signer must belong to that
|
|
22597
|
+
* workspace.
|
|
22598
|
+
*/
|
|
22599
|
+
async searchAsOwner(signerId, search) {
|
|
22600
|
+
return this.searchDocuments(signerId, { params: cleanParams({ search }) });
|
|
22601
|
+
}
|
|
22602
|
+
listDocuments(signerId, config) {
|
|
22533
22603
|
const sid = this.requireId(signerId, "Signer ID");
|
|
22534
|
-
const config = this.signerOrOwnerConfig(signerAccessCode, { ...params });
|
|
22535
22604
|
return this.callList(
|
|
22536
22605
|
"Failed to list signer documents",
|
|
22537
22606
|
() => this.http.get(`/signers/${sid}/documents`, config)
|
|
22538
22607
|
);
|
|
22539
22608
|
}
|
|
22540
|
-
|
|
22541
|
-
async search(signerId, search, signerAccessCode) {
|
|
22609
|
+
searchDocuments(signerId, config) {
|
|
22542
22610
|
const sid = this.requireId(signerId, "Signer ID");
|
|
22543
|
-
const config = this.signerOrOwnerConfig(signerAccessCode, { search });
|
|
22544
22611
|
return this.callList(
|
|
22545
22612
|
"Failed to search signer documents",
|
|
22546
22613
|
() => this.http.get(`/signers/${sid}/documents/search`, config)
|
|
22547
22614
|
);
|
|
22548
22615
|
}
|
|
22549
|
-
signerOrOwnerConfig(signerAccessCode, params) {
|
|
22550
|
-
if (signerAccessCode === void 0) return { params: cleanParams(params) };
|
|
22551
|
-
return signerAccessConfig(this.requireId(signerAccessCode, "signer-access-code"), params);
|
|
22552
|
-
}
|
|
22553
22616
|
/**
|
|
22554
22617
|
* Public `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`.
|
|
22555
22618
|
* When an access code is supplied, the SDK first verifies that it belongs to
|
|
@@ -22615,6 +22678,25 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
22615
22678
|
() => this.http.get("/signers/self", signerAccessConfig(code))
|
|
22616
22679
|
);
|
|
22617
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
|
+
}
|
|
22618
22700
|
/**
|
|
22619
22701
|
* `PUT /signers/accept-terms?signer-access-code=…` — accept the platform
|
|
22620
22702
|
* terms as the signer.
|
|
@@ -22918,9 +23000,10 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
|
22918
23000
|
email: payload.email,
|
|
22919
23001
|
whatsapp_phone_number: payload.whatsapp_phone_number ?? payload.phone
|
|
22920
23002
|
};
|
|
22921
|
-
|
|
22922
|
-
|
|
22923
|
-
|
|
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, "");
|
|
22924
23007
|
if (digits) normalised[useGovernmentId ? "government_id" : "cpf"] = digits;
|
|
22925
23008
|
}
|
|
22926
23009
|
if ("metadata" in payload && payload.metadata !== void 0) {
|
|
@@ -23159,19 +23242,21 @@ var WebhookResource = class extends BaseResource {
|
|
|
23159
23242
|
() => this.http.put(`/accounts/${id}/webhooks/inactivate`)
|
|
23160
23243
|
);
|
|
23161
23244
|
}
|
|
23162
|
-
/**
|
|
23163
|
-
async listEndpoints(accountId) {
|
|
23245
|
+
/** List webhook endpoints, oldest first; `url` matches the registered value exactly. */
|
|
23246
|
+
async listEndpoints(accountId, params = {}) {
|
|
23164
23247
|
const id = this.accountId(accountId);
|
|
23248
|
+
validateWebhookFields(params);
|
|
23165
23249
|
return this.call(
|
|
23166
23250
|
"Failed to list webhook endpoints",
|
|
23167
|
-
() => this.http.get(`/accounts/${id}/webhooks/endpoints
|
|
23251
|
+
() => this.http.get(`/accounts/${id}/webhooks/endpoints`, { params: cleanParams({ ...params }) })
|
|
23168
23252
|
);
|
|
23169
23253
|
}
|
|
23170
23254
|
/**
|
|
23171
23255
|
* `POST /accounts/{accountId}/webhooks/endpoints` — register another
|
|
23172
23256
|
* endpoint. Accounts allow 1 endpoint, or up to 3 on paid plans (`403` past
|
|
23173
23257
|
* the limit); URLs must be unique per workspace. Omitted `events` uses the
|
|
23174
|
-
* 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.
|
|
23175
23260
|
*/
|
|
23176
23261
|
async createEndpoint(payload, accountId) {
|
|
23177
23262
|
if (!payload.url) throw new ValidationError("Webhook URL is required");
|
|
@@ -23219,6 +23304,16 @@ var WebhookResource = class extends BaseResource {
|
|
|
23219
23304
|
() => this.http.delete(`/accounts/${id}/webhooks/endpoints/${eid}`)
|
|
23220
23305
|
);
|
|
23221
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
|
+
}
|
|
23222
23317
|
/**
|
|
23223
23318
|
* `GET …/endpoints/{endpointId}/secret` — the `whsec_` signing secret.
|
|
23224
23319
|
* Returns `400` when signing is disabled. Not available to OAuth applications.
|
|
@@ -23376,12 +23471,10 @@ function readHeader(headers, name) {
|
|
|
23376
23471
|
if (typeof headers.get === "function") {
|
|
23377
23472
|
return headers.get(name) ?? void 0;
|
|
23378
23473
|
}
|
|
23379
|
-
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
|
|
23383
|
-
}
|
|
23384
|
-
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;
|
|
23385
23478
|
}
|
|
23386
23479
|
var WebhookVerifier = class {
|
|
23387
23480
|
constructor(webhookSecret, options = {}) {
|
|
@@ -23406,7 +23499,8 @@ var WebhookVerifier = class {
|
|
|
23406
23499
|
if (!id || !timestamp || !signatures || !/^\d+$/.test(timestamp)) return false;
|
|
23407
23500
|
const tolerance = options.toleranceSeconds ?? 300;
|
|
23408
23501
|
const now = Math.floor((options.now ?? Date.now()) / 1e3);
|
|
23409
|
-
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;
|
|
23410
23504
|
const secret = this.webhookSecret.startsWith("whsec_") ? this.webhookSecret.slice("whsec_".length) : this.webhookSecret;
|
|
23411
23505
|
const key = Buffer.from(secret, "base64");
|
|
23412
23506
|
if (key.length === 0) return false;
|
|
@@ -23414,8 +23508,8 @@ var WebhookVerifier = class {
|
|
|
23414
23508
|
(0, import_node_crypto2.createHmac)("sha256", key).update(`${id}.${timestamp}.`).update(typeof payload === "string" ? Buffer.from(payload, "utf8") : payload).digest("base64")
|
|
23415
23509
|
);
|
|
23416
23510
|
return signatures.split(" ").some((entry) => {
|
|
23417
|
-
const [version, value] = entry.split(","
|
|
23418
|
-
if (version !== "v1" || !value) return false;
|
|
23511
|
+
const [version, value, extra] = entry.split(",");
|
|
23512
|
+
if (version !== "v1" || !value || extra !== void 0) return false;
|
|
23419
23513
|
const provided = Buffer.from(value);
|
|
23420
23514
|
return provided.length === expected.length && (0, import_node_crypto2.timingSafeEqual)(provided, expected);
|
|
23421
23515
|
});
|
|
@@ -23620,6 +23714,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
23620
23714
|
const phone = signer.whatsapp_phone_number ?? signer.phone;
|
|
23621
23715
|
if (phone !== void 0) payload.whatsapp_phone_number = phone;
|
|
23622
23716
|
if (signer.cpf !== void 0) payload.cpf = signer.cpf;
|
|
23717
|
+
if (signer.government_id !== void 0) payload.government_id = signer.government_id;
|
|
23623
23718
|
if (signer.metadata !== void 0) payload.metadata = signer.metadata;
|
|
23624
23719
|
validateCreateSignerPayload(payload);
|
|
23625
23720
|
return { signer, payload, phone };
|
|
@@ -23766,85 +23861,9 @@ function requireAccountId(config, override) {
|
|
|
23766
23861
|
return id;
|
|
23767
23862
|
}
|
|
23768
23863
|
|
|
23769
|
-
// src/lib/
|
|
23770
|
-
|
|
23771
|
-
|
|
23772
|
-
let parsed;
|
|
23773
|
-
try {
|
|
23774
|
-
parsed = JSON.parse(raw);
|
|
23775
|
-
} catch {
|
|
23776
|
-
throw new CliError(`${flag} must be valid JSON.`);
|
|
23777
|
-
}
|
|
23778
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
23779
|
-
throw new CliError(`${flag} must be a JSON object.`);
|
|
23780
|
-
}
|
|
23781
|
-
return parsed;
|
|
23782
|
-
}
|
|
23783
|
-
function parseJsonArray(raw, flag) {
|
|
23784
|
-
if (raw === void 0) return void 0;
|
|
23785
|
-
let parsed;
|
|
23786
|
-
try {
|
|
23787
|
-
parsed = JSON.parse(raw);
|
|
23788
|
-
} catch {
|
|
23789
|
-
throw new CliError(`${flag} must be valid JSON.`);
|
|
23790
|
-
}
|
|
23791
|
-
if (!Array.isArray(parsed)) {
|
|
23792
|
-
throw new CliError(`${flag} must be a JSON array.`);
|
|
23793
|
-
}
|
|
23794
|
-
return parsed;
|
|
23795
|
-
}
|
|
23796
|
-
function splitList(raw) {
|
|
23797
|
-
if (raw === void 0) return void 0;
|
|
23798
|
-
const items = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
23799
|
-
return items;
|
|
23800
|
-
}
|
|
23801
|
-
function collect(value, previous = []) {
|
|
23802
|
-
return [...previous, value];
|
|
23803
|
-
}
|
|
23804
|
-
function parseInteger(raw, flag, options = {}) {
|
|
23805
|
-
if (raw === void 0) return void 0;
|
|
23806
|
-
const trimmed = raw.trim();
|
|
23807
|
-
if (!/^-?\d+$/.test(trimmed)) {
|
|
23808
|
-
throw new CliError(`${flag} must be an integer.`);
|
|
23809
|
-
}
|
|
23810
|
-
const n2 = Number(trimmed);
|
|
23811
|
-
if (!Number.isSafeInteger(n2)) {
|
|
23812
|
-
throw new CliError(`${flag} must be a safe integer.`);
|
|
23813
|
-
}
|
|
23814
|
-
if (options.min !== void 0 && n2 < options.min) {
|
|
23815
|
-
throw new CliError(`${flag} must be ${options.min} or greater.`);
|
|
23816
|
-
}
|
|
23817
|
-
return n2;
|
|
23818
|
-
}
|
|
23819
|
-
|
|
23820
|
-
// src/lib/options.ts
|
|
23821
|
-
function addPaginationOptions(command) {
|
|
23822
|
-
return command.option("--page <n>", "Page number to fetch").option("--per-page <n>", "Items per page");
|
|
23823
|
-
}
|
|
23824
|
-
function addSearchListOptions(command) {
|
|
23825
|
-
return addPaginationOptions(command).option("--search <query>", "Filter by a search query");
|
|
23826
|
-
}
|
|
23827
|
-
function addSortableListOptions(command, description) {
|
|
23828
|
-
return addPaginationOptions(command).option("--sort <field>", description);
|
|
23829
|
-
}
|
|
23830
|
-
function addListOptions(command, sortDescription = "Sort by field") {
|
|
23831
|
-
return addSearchListOptions(command).option("--sort <field>", sortDescription);
|
|
23832
|
-
}
|
|
23833
|
-
function addDownloadOptions(command) {
|
|
23834
|
-
return command.option("-o, --output <path>", "Output file path").option("--force", "Overwrite the output file if it already exists");
|
|
23835
|
-
}
|
|
23836
|
-
function addSignerRefOptions(command) {
|
|
23837
|
-
return command.addOption(
|
|
23838
|
-
new Option("--signer-ids <csv>", "Comma-separated signer IDs (required)").conflicts(
|
|
23839
|
-
"signers"
|
|
23840
|
-
)
|
|
23841
|
-
).addOption(
|
|
23842
|
-
new Option(
|
|
23843
|
-
"--signers <json>",
|
|
23844
|
-
"JSON array of signer refs, with verification_method, step, \u2026 (required)"
|
|
23845
|
-
).conflicts("signerIds")
|
|
23846
|
-
);
|
|
23847
|
-
}
|
|
23864
|
+
// src/lib/files.ts
|
|
23865
|
+
var import_node_fs4 = require("fs");
|
|
23866
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
23848
23867
|
|
|
23849
23868
|
// src/lib/output.ts
|
|
23850
23869
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
@@ -23931,218 +23950,20 @@ function printError(err, config) {
|
|
|
23931
23950
|
process.exitCode = normalized.exitCode ?? 1;
|
|
23932
23951
|
}
|
|
23933
23952
|
|
|
23934
|
-
//
|
|
23935
|
-
var
|
|
23936
|
-
|
|
23937
|
-
|
|
23938
|
-
|
|
23939
|
-
const perPage = parseInteger(flags.perPage, "--per-page", { min: 1 });
|
|
23940
|
-
if (page !== void 0) params.page = page;
|
|
23941
|
-
if (perPage !== void 0) params["per-page"] = perPage;
|
|
23942
|
-
if (flags.search) params.search = flags.search;
|
|
23943
|
-
if (flags.sort) params.sort = flags.sort;
|
|
23944
|
-
return params;
|
|
23945
|
-
}
|
|
23946
|
-
function paginationFooter(result) {
|
|
23947
|
-
const meta = result.meta;
|
|
23948
|
-
if (!meta) return "";
|
|
23949
|
-
const parts = [];
|
|
23950
|
-
if (meta.current_page !== void 0 && meta.last_page !== void 0) {
|
|
23951
|
-
parts.push(`page ${meta.current_page}/${meta.last_page}`);
|
|
23952
|
-
}
|
|
23953
|
-
if (meta.total !== void 0) {
|
|
23954
|
-
parts.push(`${meta.total} total`);
|
|
23955
|
-
}
|
|
23956
|
-
if (meta.per_page !== void 0) {
|
|
23957
|
-
parts.push(`${meta.per_page}/page`);
|
|
23958
|
-
}
|
|
23959
|
-
return parts.length > 0 ? import_picocolors2.default.dim(parts.join(" \xB7 ")) : "";
|
|
23960
|
-
}
|
|
23961
|
-
function tableWithFooter(table, result) {
|
|
23962
|
-
const footer = paginationFooter(result);
|
|
23963
|
-
return footer ? `${table}
|
|
23964
|
-
${footer}` : table;
|
|
23965
|
-
}
|
|
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);
|
|
23966
23958
|
|
|
23967
|
-
//
|
|
23968
|
-
var
|
|
23969
|
-
|
|
23970
|
-
|
|
23971
|
-
|
|
23972
|
-
|
|
23973
|
-
|
|
23974
|
-
|
|
23975
|
-
function configDir() {
|
|
23976
|
-
if (process.env.ASSINAFY_CONFIG_DIR) {
|
|
23977
|
-
return process.env.ASSINAFY_CONFIG_DIR;
|
|
23978
|
-
}
|
|
23979
|
-
if (process.platform === "win32" && process.env.APPDATA) {
|
|
23980
|
-
return import_node_path3.default.join(process.env.APPDATA, "assinafy");
|
|
23981
|
-
}
|
|
23982
|
-
const xdg = process.env.XDG_CONFIG_HOME;
|
|
23983
|
-
const base = xdg && xdg.length > 0 ? xdg : import_node_path3.default.join(import_node_os.default.homedir(), ".config");
|
|
23984
|
-
return import_node_path3.default.join(base, "assinafy");
|
|
23985
|
-
}
|
|
23986
|
-
function configPath() {
|
|
23987
|
-
return import_node_path3.default.join(configDir(), "config.json");
|
|
23988
|
-
}
|
|
23989
|
-
function readConfigFile(options = {}) {
|
|
23990
|
-
const file = configPath();
|
|
23991
|
-
if (!(0, import_node_fs3.existsSync)(file)) {
|
|
23992
|
-
return {};
|
|
23993
|
-
}
|
|
23994
|
-
try {
|
|
23995
|
-
const parsed = JSON.parse((0, import_node_fs3.readFileSync)(file, "utf8"));
|
|
23996
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
23997
|
-
if (parsed.default_profile !== void 0 && typeof parsed.default_profile !== "string") {
|
|
23998
|
-
throw new Error("Invalid default_profile");
|
|
23999
|
-
}
|
|
24000
|
-
if (parsed.profiles !== void 0) {
|
|
24001
|
-
if (!parsed.profiles || typeof parsed.profiles !== "object" || Array.isArray(parsed.profiles)) {
|
|
24002
|
-
throw new Error("Invalid profiles");
|
|
24003
|
-
}
|
|
24004
|
-
for (const profile of Object.values(parsed.profiles)) {
|
|
24005
|
-
if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
|
|
24006
|
-
throw new Error("Invalid profile");
|
|
24007
|
-
}
|
|
24008
|
-
for (const key of [
|
|
24009
|
-
"api_key",
|
|
24010
|
-
"token",
|
|
24011
|
-
"account_id",
|
|
24012
|
-
"base_url",
|
|
24013
|
-
"webhook_secret"
|
|
24014
|
-
]) {
|
|
24015
|
-
if (profile[key] !== void 0 && typeof profile[key] !== "string") {
|
|
24016
|
-
throw new Error("Invalid profile field");
|
|
24017
|
-
}
|
|
24018
|
-
}
|
|
24019
|
-
}
|
|
24020
|
-
}
|
|
24021
|
-
return parsed;
|
|
24022
|
-
}
|
|
24023
|
-
if (options.strict) {
|
|
24024
|
-
throw new CliError(`Config file at ${file} is not a JSON object; refusing to overwrite it.`);
|
|
24025
|
-
}
|
|
24026
|
-
process.stderr.write(
|
|
24027
|
-
`${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} is not a JSON object; ignoring it.
|
|
24028
|
-
`
|
|
24029
|
-
);
|
|
24030
|
-
return {};
|
|
24031
|
-
} catch (error) {
|
|
24032
|
-
if (error instanceof CliError) throw error;
|
|
24033
|
-
if (options.strict) {
|
|
24034
|
-
throw new CliError(
|
|
24035
|
-
`Config file at ${file} has invalid JSON or field types; refusing to overwrite it.`
|
|
24036
|
-
);
|
|
24037
|
-
}
|
|
24038
|
-
process.stderr.write(
|
|
24039
|
-
`${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} has invalid JSON or field types; ignoring it.
|
|
24040
|
-
`
|
|
24041
|
-
);
|
|
24042
|
-
return {};
|
|
24043
|
-
}
|
|
24044
|
-
}
|
|
24045
|
-
function writeConfigFile(config) {
|
|
24046
|
-
const dir = configDir();
|
|
24047
|
-
if (!(0, import_node_fs3.existsSync)(dir)) {
|
|
24048
|
-
(0, import_node_fs3.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
24049
|
-
}
|
|
24050
|
-
if (process.platform !== "win32") (0, import_node_fs3.chmodSync)(dir, 448);
|
|
24051
|
-
const file = configPath();
|
|
24052
|
-
const tmp = `${file}.${(0, import_node_crypto3.randomUUID)()}.tmp`;
|
|
24053
|
-
try {
|
|
24054
|
-
(0, import_node_fs3.writeFileSync)(tmp, `${JSON.stringify(config, null, 2)}
|
|
24055
|
-
`, {
|
|
24056
|
-
flag: "wx",
|
|
24057
|
-
mode: 384
|
|
24058
|
-
});
|
|
24059
|
-
(0, import_node_fs3.chmodSync)(tmp, 384);
|
|
24060
|
-
(0, import_node_fs3.renameSync)(tmp, file);
|
|
24061
|
-
} catch (err) {
|
|
24062
|
-
(0, import_node_fs3.rmSync)(tmp, { force: true });
|
|
24063
|
-
throw err;
|
|
24064
|
-
}
|
|
24065
|
-
}
|
|
24066
|
-
function activeProfileName(globals, file = readConfigFile()) {
|
|
24067
|
-
return globals.profile || process.env.ASSINAFY_PROFILE || file.default_profile || DEFAULT_PROFILE;
|
|
24068
|
-
}
|
|
24069
|
-
function resolveConfig2(globals) {
|
|
24070
|
-
const file = readConfigFile();
|
|
24071
|
-
const profileName = activeProfileName(globals, file);
|
|
24072
|
-
const profile = file.profiles?.[profileName] ?? {};
|
|
24073
|
-
const pick = (flag, env, stored) => flag || env || stored || void 0;
|
|
24074
|
-
const baseUrl = pick(globals.baseUrl, process.env.ASSINAFY_BASE_URL, profile.base_url) ?? DEFAULT_BASE_URL2;
|
|
24075
|
-
const credentials = [
|
|
24076
|
-
{ apiKey: globals.apiKey, token: globals.token },
|
|
24077
|
-
{ apiKey: process.env.ASSINAFY_API_KEY, token: process.env.ASSINAFY_TOKEN },
|
|
24078
|
-
{ apiKey: profile.api_key, token: profile.token }
|
|
24079
|
-
].find(({ apiKey, token }) => apiKey || token);
|
|
24080
|
-
return {
|
|
24081
|
-
apiKey: credentials?.apiKey,
|
|
24082
|
-
token: credentials?.token,
|
|
24083
|
-
accountId: pick(globals.accountId, process.env.ASSINAFY_ACCOUNT_ID, profile.account_id),
|
|
24084
|
-
baseUrl: normalizeBaseUrl(baseUrl),
|
|
24085
|
-
webhookSecret: pick(void 0, process.env.ASSINAFY_WEBHOOK_SECRET, profile.webhook_secret),
|
|
24086
|
-
profile: profileName,
|
|
24087
|
-
json: Boolean(globals.json),
|
|
24088
|
-
quiet: Boolean(globals.quiet)
|
|
24089
|
-
};
|
|
24090
|
-
}
|
|
24091
|
-
|
|
24092
|
-
// src/lib/run.ts
|
|
24093
|
-
function getGlobals(command) {
|
|
24094
|
-
const opts = command.optsWithGlobals();
|
|
24095
|
-
return {
|
|
24096
|
-
apiKey: opts.apiKey,
|
|
24097
|
-
token: opts.token,
|
|
24098
|
-
accountId: opts.accountId,
|
|
24099
|
-
baseUrl: opts.baseUrl,
|
|
24100
|
-
profile: opts.profile,
|
|
24101
|
-
json: Boolean(opts.json),
|
|
24102
|
-
quiet: Boolean(opts.quiet)
|
|
24103
|
-
};
|
|
24104
|
-
}
|
|
24105
|
-
async function withResolvedConfig(command, handler) {
|
|
24106
|
-
let outputConfig = { json: false, quiet: false };
|
|
24107
|
-
try {
|
|
24108
|
-
const globals = getGlobals(command);
|
|
24109
|
-
outputConfig = { json: Boolean(globals.json), quiet: Boolean(globals.quiet) };
|
|
24110
|
-
const config = resolveConfig2(globals);
|
|
24111
|
-
await handler(config);
|
|
24112
|
-
} catch (err) {
|
|
24113
|
-
printError(err, outputConfig);
|
|
24114
|
-
}
|
|
24115
|
-
}
|
|
24116
|
-
function runWithClient(command, handler) {
|
|
24117
|
-
return withResolvedConfig(command, (config) => handler({ client: createClient(config), config }));
|
|
24118
|
-
}
|
|
24119
|
-
function runWithPublicClient(command, handler) {
|
|
24120
|
-
return withResolvedConfig(
|
|
24121
|
-
command,
|
|
24122
|
-
(config) => handler({
|
|
24123
|
-
client: createClient(config, { allowUnauthenticated: true, omitCredentials: true }),
|
|
24124
|
-
config
|
|
24125
|
-
})
|
|
24126
|
-
);
|
|
24127
|
-
}
|
|
24128
|
-
function runAction(command, handler) {
|
|
24129
|
-
return withResolvedConfig(command, (config) => handler({ config }));
|
|
24130
|
-
}
|
|
24131
|
-
|
|
24132
|
-
// node_modules/@clack/core/dist/index.mjs
|
|
24133
|
-
var import_node_util4 = require("util");
|
|
24134
|
-
var import_node_process2 = require("process");
|
|
24135
|
-
var l = __toESM(require("readline"), 1);
|
|
24136
|
-
var import_node_readline = __toESM(require("readline"), 1);
|
|
24137
|
-
|
|
24138
|
-
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
24139
|
-
var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
24140
|
-
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
24141
|
-
return (input) => {
|
|
24142
|
-
let surrogatePairsNr = 0;
|
|
24143
|
-
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
24144
|
-
while (SURROGATE_PAIR_RE.test(input)) {
|
|
24145
|
-
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;
|
|
24146
23967
|
}
|
|
24147
23968
|
return input.length - surrogatePairsNr;
|
|
24148
23969
|
};
|
|
@@ -24842,8 +24663,8 @@ var n = class extends V {
|
|
|
24842
24663
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
24843
24664
|
var import_node_util5 = require("util");
|
|
24844
24665
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
24845
|
-
var
|
|
24846
|
-
var
|
|
24666
|
+
var import_node_fs3 = require("fs");
|
|
24667
|
+
var import_node_path3 = require("path");
|
|
24847
24668
|
var import_sisteransi2 = __toESM(require_src3(), 1);
|
|
24848
24669
|
function isUnicodeSupported() {
|
|
24849
24670
|
if (import_node_process3.default.platform !== "win32") {
|
|
@@ -25101,33 +24922,376 @@ ${d}${n2}
|
|
|
25101
24922
|
return `${s}${r2}${n2}${l2.trim() ? `
|
|
25102
24923
|
${r2}` : ""}`;
|
|
25103
24924
|
}
|
|
25104
|
-
default: {
|
|
25105
|
-
const n2 = i2 ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", r2 = i2 ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
|
|
25106
|
-
return `${s}${n2}${o}
|
|
25107
|
-
${r2}
|
|
25108
|
-
`;
|
|
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);
|
|
25109
25184
|
}
|
|
25185
|
+
return parsed;
|
|
25110
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 {};
|
|
25111
25207
|
}
|
|
25112
|
-
}
|
|
25113
|
-
|
|
25114
|
-
|
|
25115
|
-
|
|
25116
|
-
|
|
25117
|
-
if (!useSpinner) {
|
|
25118
|
-
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 });
|
|
25119
25213
|
}
|
|
25120
|
-
|
|
25121
|
-
|
|
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`;
|
|
25122
25217
|
try {
|
|
25123
|
-
|
|
25124
|
-
|
|
25125
|
-
|
|
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);
|
|
25126
25225
|
} catch (err) {
|
|
25127
|
-
|
|
25226
|
+
(0, import_node_fs5.rmSync)(tmp, { force: true });
|
|
25128
25227
|
throw err;
|
|
25129
25228
|
}
|
|
25130
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
|
+
}
|
|
25131
25295
|
|
|
25132
25296
|
// src/lib/table.ts
|
|
25133
25297
|
var import_node_util6 = require("util");
|
|
@@ -25350,32 +25514,55 @@ var whatsappCommand = new Command("whatsapp-notifications").description("List Wh
|
|
|
25350
25514
|
);
|
|
25351
25515
|
});
|
|
25352
25516
|
});
|
|
25353
|
-
var
|
|
25354
|
-
|
|
25355
|
-
|
|
25356
|
-
|
|
25357
|
-
|
|
25358
|
-
|
|
25359
|
-
|
|
25360
|
-
|
|
25361
|
-
|
|
25362
|
-
|
|
25363
|
-
|
|
25364
|
-
|
|
25365
|
-
|
|
25366
|
-
|
|
25367
|
-
|
|
25368
|
-
|
|
25369
|
-
|
|
25370
|
-
|
|
25371
|
-
|
|
25372
|
-
|
|
25373
|
-
|
|
25374
|
-
|
|
25375
|
-
|
|
25376
|
-
|
|
25377
|
-
|
|
25378
|
-
}
|
|
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);
|
|
25379
25566
|
|
|
25380
25567
|
// src/commands/auth.ts
|
|
25381
25568
|
function resetPasswordPayload(email, resetToken, newPassword) {
|
|
@@ -25669,7 +25856,7 @@ var setCommand = new Command("set").description(
|
|
|
25669
25856
|
const merged = command.optsWithGlobals();
|
|
25670
25857
|
const file = readConfigFile({ strict: true });
|
|
25671
25858
|
const profileName = activeProfileName(getGlobals(command), file);
|
|
25672
|
-
const profiles = file.profiles ??
|
|
25859
|
+
const profiles = file.profiles ?? /* @__PURE__ */ Object.create(null);
|
|
25673
25860
|
const profile = { ...profiles[profileName] };
|
|
25674
25861
|
let changed = false;
|
|
25675
25862
|
if (merged.apiKey !== void 0) {
|
|
@@ -25963,47 +26150,6 @@ var docsCommand = new Command("docs").description("Print (or open) the Assinafy
|
|
|
25963
26150
|
});
|
|
25964
26151
|
});
|
|
25965
26152
|
|
|
25966
|
-
// src/lib/files.ts
|
|
25967
|
-
var import_node_fs5 = require("fs");
|
|
25968
|
-
var import_node_path5 = __toESM(require("path"), 1);
|
|
25969
|
-
function readBinary(inputPath) {
|
|
25970
|
-
try {
|
|
25971
|
-
return (0, import_node_fs5.readFileSync)(import_node_path5.default.resolve(inputPath));
|
|
25972
|
-
} catch (err) {
|
|
25973
|
-
throw new CliError(
|
|
25974
|
-
`Failed to read file "${inputPath}": ${err instanceof Error ? err.message : String(err)}`
|
|
25975
|
-
);
|
|
25976
|
-
}
|
|
25977
|
-
}
|
|
25978
|
-
function writeBinary(outputPath, data, options = {}) {
|
|
25979
|
-
const resolved = import_node_path5.default.resolve(outputPath);
|
|
25980
|
-
try {
|
|
25981
|
-
(0, import_node_fs5.writeFileSync)(resolved, data, { flag: options.force ? "w" : "wx" });
|
|
25982
|
-
} catch (err) {
|
|
25983
|
-
if (err && typeof err === "object" && "code" in err && err.code === "EEXIST") {
|
|
25984
|
-
throw new CliError(`File "${resolved}" already exists. Pass --force to overwrite it.`);
|
|
25985
|
-
}
|
|
25986
|
-
throw new CliError(
|
|
25987
|
-
`Failed to write file "${resolved}": ${err instanceof Error ? err.message : String(err)}`
|
|
25988
|
-
);
|
|
25989
|
-
}
|
|
25990
|
-
return resolved;
|
|
25991
|
-
}
|
|
25992
|
-
function defaultArtifactFilename(documentId, artifact) {
|
|
25993
|
-
const ext = artifact === "thumbnail" ? "jpg" : artifact === "bundle" ? "zip" : "pdf";
|
|
25994
|
-
return `${documentId}-${artifact}.${ext}`;
|
|
25995
|
-
}
|
|
25996
|
-
async function saveDownload(config, options) {
|
|
25997
|
-
const buffer = await withSpinner(options.message, config, options.download);
|
|
25998
|
-
const out = writeBinary(options.output ?? options.defaultName, buffer, { force: options.force });
|
|
25999
|
-
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
26000
|
-
printData(
|
|
26001
|
-
{ path: out, bytes: buffer.byteLength, ...options.data },
|
|
26002
|
-
config,
|
|
26003
|
-
(d) => sanitizeTerminalText(d.path)
|
|
26004
|
-
);
|
|
26005
|
-
}
|
|
26006
|
-
|
|
26007
26153
|
// src/commands/documents.ts
|
|
26008
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) => {
|
|
26009
26155
|
await runWithClient(command, async ({ client, config }) => {
|
|
@@ -26529,7 +26675,7 @@ var loginCommand2 = new Command("login").description(
|
|
|
26529
26675
|
const apiKey = merged.apiKey ?? await promptSecret("Enter your Assinafy API key");
|
|
26530
26676
|
const accountId = merged.accountId ?? await promptText("Default account/workspace ID (optional)");
|
|
26531
26677
|
const profileName = activeProfileName(getGlobals(command), file);
|
|
26532
|
-
const profiles = file.profiles ??
|
|
26678
|
+
const profiles = file.profiles ?? /* @__PURE__ */ Object.create(null);
|
|
26533
26679
|
const profile = { ...profiles[profileName], api_key: apiKey };
|
|
26534
26680
|
if (accountId) profile.account_id = accountId;
|
|
26535
26681
|
if (merged.baseUrl) profile.base_url = merged.baseUrl;
|
|
@@ -26790,7 +26936,7 @@ var documentsCommand2 = addListOptions(
|
|
|
26790
26936
|
const result = await withSpinner(
|
|
26791
26937
|
"Fetching documents",
|
|
26792
26938
|
config,
|
|
26793
|
-
() => client.signerDocuments.list(signerId, opts.accessCode, listParams(opts))
|
|
26939
|
+
() => opts.accessCode === void 0 ? client.signerDocuments.listAsOwner(signerId, listParams(opts)) : client.signerDocuments.list(signerId, opts.accessCode, listParams(opts))
|
|
26794
26940
|
);
|
|
26795
26941
|
printPaginatedData(
|
|
26796
26942
|
result,
|
|
@@ -26808,7 +26954,7 @@ var searchCommand2 = new Command("search").description("Search the signer's docu
|
|
|
26808
26954
|
const result = await withSpinner(
|
|
26809
26955
|
"Searching documents",
|
|
26810
26956
|
config,
|
|
26811
|
-
() => client.signerDocuments.search(signerId, query, opts.accessCode)
|
|
26957
|
+
() => opts.accessCode === void 0 ? client.signerDocuments.searchAsOwner(signerId, query) : client.signerDocuments.search(signerId, query, opts.accessCode)
|
|
26812
26958
|
);
|
|
26813
26959
|
printPaginatedData(
|
|
26814
26960
|
result,
|
|
@@ -26849,6 +26995,27 @@ var selfCommand = new Command("self").description("Fetch the signer's own profil
|
|
|
26849
26995
|
printData(profile, config);
|
|
26850
26996
|
});
|
|
26851
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
|
+
});
|
|
26852
27019
|
var acceptTermsCommand = new Command("accept-terms").description("Accept the platform terms as the signer").addOption(accessCodeOption()).action(async (opts, command) => {
|
|
26853
27020
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
26854
27021
|
const result = await withSpinner(
|
|
@@ -27007,7 +27174,7 @@ var declineMultipleCommand = new Command("decline-multiple").description("Declin
|
|
|
27007
27174
|
printData(result, config);
|
|
27008
27175
|
});
|
|
27009
27176
|
});
|
|
27010
|
-
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);
|
|
27011
27178
|
|
|
27012
27179
|
// src/commands/signers.ts
|
|
27013
27180
|
var signerColumns = [
|
|
@@ -27019,13 +27186,16 @@ var signerColumns = [
|
|
|
27019
27186
|
value: (r2) => r2.whatsapp_phone_number
|
|
27020
27187
|
}
|
|
27021
27188
|
];
|
|
27022
|
-
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) => {
|
|
27023
27192
|
await runWithClient(command, async ({ client, config }) => {
|
|
27024
27193
|
const accountId = requireAccountId(config);
|
|
27025
27194
|
const payload = { full_name: opts.name };
|
|
27026
27195
|
if (opts.email) payload.email = opts.email;
|
|
27027
27196
|
if (opts.phone) payload.whatsapp_phone_number = opts.phone;
|
|
27028
27197
|
if (opts.cpf) payload.cpf = opts.cpf;
|
|
27198
|
+
if (opts.governmentId !== void 0) payload.government_id = opts.governmentId;
|
|
27029
27199
|
const metadata = parseJsonObject(opts.metadata, "--metadata");
|
|
27030
27200
|
if (metadata) payload.metadata = metadata;
|
|
27031
27201
|
const signer = await withSpinner(
|
|
@@ -27074,7 +27244,9 @@ var getCommand4 = new Command("get").description("Show a signer by ID").argument
|
|
|
27074
27244
|
printData(signer, config, (s) => renderKeyValue(s));
|
|
27075
27245
|
});
|
|
27076
27246
|
});
|
|
27077
|
-
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) => {
|
|
27078
27250
|
await runWithClient(command, async ({ client, config }) => {
|
|
27079
27251
|
const accountId = requireAccountId(config);
|
|
27080
27252
|
const payload = {};
|
|
@@ -27082,6 +27254,7 @@ var updateCommand2 = new Command("update").description("Update a signer").argume
|
|
|
27082
27254
|
if (opts.email) payload.email = opts.email;
|
|
27083
27255
|
if (opts.phone) payload.whatsapp_phone_number = opts.phone;
|
|
27084
27256
|
if (opts.cpf) payload.cpf = opts.cpf;
|
|
27257
|
+
if (opts.governmentId !== void 0) payload.government_id = opts.governmentId;
|
|
27085
27258
|
const signer = await withSpinner(
|
|
27086
27259
|
"Updating signer",
|
|
27087
27260
|
config,
|
|
@@ -27432,7 +27605,8 @@ var renderEndpoint = (e) => renderKeyValue({
|
|
|
27432
27605
|
email: e.email,
|
|
27433
27606
|
is_active: e.is_active,
|
|
27434
27607
|
signing_enabled: e.signing_enabled,
|
|
27435
|
-
events: e.events
|
|
27608
|
+
events: e.events,
|
|
27609
|
+
secret: e.secret
|
|
27436
27610
|
});
|
|
27437
27611
|
function endpointFieldOptions(command) {
|
|
27438
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(
|
|
@@ -27450,13 +27624,13 @@ function endpointPayload(opts) {
|
|
|
27450
27624
|
if (opts.signing !== void 0) payload.signing_enabled = opts.signing;
|
|
27451
27625
|
return payload;
|
|
27452
27626
|
}
|
|
27453
|
-
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) => {
|
|
27454
27628
|
await runWithClient(command, async ({ client, config }) => {
|
|
27455
27629
|
const accountId = requireAccountId(config);
|
|
27456
27630
|
const rows = await withSpinner(
|
|
27457
27631
|
"Fetching endpoints",
|
|
27458
27632
|
config,
|
|
27459
|
-
() => client.webhooks.listEndpoints(accountId)
|
|
27633
|
+
() => client.webhooks.listEndpoints(accountId, { url: opts.url })
|
|
27460
27634
|
);
|
|
27461
27635
|
printData(
|
|
27462
27636
|
rows,
|
|
@@ -27531,6 +27705,20 @@ var endpointsDeleteCommand = new Command("delete").alias("rm").description("Dele
|
|
|
27531
27705
|
printData({ id: endpointId, deleted: true }, config);
|
|
27532
27706
|
});
|
|
27533
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
|
+
});
|
|
27534
27722
|
var endpointsSecretCommand = new Command("secret").description(
|
|
27535
27723
|
"Print the endpoint signing secret (signing must be enabled; not available via OAuth)"
|
|
27536
27724
|
).argument("<endpointId>", "Endpoint ID").action(async (endpointId, _opts, command) => {
|
|
@@ -27586,7 +27774,7 @@ var verifyCommand2 = new Command("verify").description(
|
|
|
27586
27774
|
printData({ valid, id: opts.id }, config, () => "valid");
|
|
27587
27775
|
});
|
|
27588
27776
|
});
|
|
27589
|
-
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);
|
|
27590
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);
|
|
27591
27779
|
|
|
27592
27780
|
// src/commands/whoami.ts
|
|
@@ -27810,7 +27998,7 @@ function handleStreamError(err, fallback, exit = process.exit) {
|
|
|
27810
27998
|
// package.json
|
|
27811
27999
|
var package_default = {
|
|
27812
28000
|
name: "@assinafy/cli",
|
|
27813
|
-
version: "2.
|
|
28001
|
+
version: "2.6.0",
|
|
27814
28002
|
description: "The official command-line interface for the Assinafy digital-signature API",
|
|
27815
28003
|
license: "MIT",
|
|
27816
28004
|
type: "module",
|