@assinafy/cli 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/dist/api.cjs +53 -25
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +50 -24
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +389 -371
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/resources/assignments.d.ts.map +1 -1
- package/dist/types/api/resources/authentication.d.ts +1 -1
- package/dist/types/api/resources/authentication.d.ts.map +1 -1
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/resources/oauth.d.ts.map +1 -1
- package/dist/types/api/resources/signers.d.ts.map +1 -1
- package/dist/types/api/resources/workspaces.d.ts.map +1 -1
- package/dist/types/api/utils.d.ts +4 -0
- package/dist/types/api/utils.d.ts.map +1 -1
- package/docs/assignments.md +10 -7
- package/docs/auth.md +1 -1
- package/docs/documents.md +5 -3
- package/docs/fields.md +2 -2
- package/docs/sdk-reference.md +4 -4
- package/docs/users.md +2 -1
- package/docs/workspaces.md +6 -3
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -21206,6 +21206,19 @@ function cleanParams(params) {
|
|
|
21206
21206
|
}
|
|
21207
21207
|
return out;
|
|
21208
21208
|
}
|
|
21209
|
+
function stripEmpty(body) {
|
|
21210
|
+
const out = {};
|
|
21211
|
+
for (const [key, value] of Object.entries(body)) {
|
|
21212
|
+
if (value !== void 0 && value !== null) {
|
|
21213
|
+
out[key] = value;
|
|
21214
|
+
}
|
|
21215
|
+
}
|
|
21216
|
+
return out;
|
|
21217
|
+
}
|
|
21218
|
+
function appendFilePart(form, data, contentType, fileName) {
|
|
21219
|
+
const view = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
21220
|
+
form.append("file", new Blob([view], { type: contentType }), fileName);
|
|
21221
|
+
}
|
|
21209
21222
|
function publicRequestConfig(config = {}) {
|
|
21210
21223
|
return {
|
|
21211
21224
|
...config,
|
|
@@ -21446,7 +21459,7 @@ function buildAssignmentPayload(payload, options = {}) {
|
|
|
21446
21459
|
if (!options.skipDigitalCertificateStepValidation) {
|
|
21447
21460
|
validateSigningSteps(normalisedSigners);
|
|
21448
21461
|
}
|
|
21449
|
-
return
|
|
21462
|
+
return stripEmpty({
|
|
21450
21463
|
method: payload.method ?? "virtual",
|
|
21451
21464
|
signers: normalisedSigners,
|
|
21452
21465
|
message: payload.message,
|
|
@@ -21477,7 +21490,7 @@ function normaliseSignerRef(ref, options) {
|
|
|
21477
21490
|
const input = ref;
|
|
21478
21491
|
const id = input.id ?? input.signer_id;
|
|
21479
21492
|
validateSignerOptions(input);
|
|
21480
|
-
const normalised =
|
|
21493
|
+
const normalised = stripEmpty({
|
|
21481
21494
|
id,
|
|
21482
21495
|
verification_method: input.verification_method,
|
|
21483
21496
|
notification_methods: input.notification_methods,
|
|
@@ -21676,6 +21689,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
21676
21689
|
var import_node_fs2 = require("fs");
|
|
21677
21690
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
21678
21691
|
var MAX_UPLOAD_BYTES = 25 * 1024 * 1024;
|
|
21692
|
+
var DOCUMENT_SORTS = ["name", "-name", "updated_at", "-updated_at"];
|
|
21679
21693
|
var READY_STATUSES = /* @__PURE__ */ new Set([
|
|
21680
21694
|
"metadata_ready",
|
|
21681
21695
|
"pending_signature",
|
|
@@ -21723,7 +21737,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
21723
21737
|
*/
|
|
21724
21738
|
async list(params = {}, accountId) {
|
|
21725
21739
|
const id = this.accountId(accountId);
|
|
21726
|
-
requireSort(params.sort,
|
|
21740
|
+
requireSort(params.sort, DOCUMENT_SORTS);
|
|
21727
21741
|
return this.callList(
|
|
21728
21742
|
"Failed to list documents",
|
|
21729
21743
|
() => this.http.get(`/accounts/${id}/documents`, {
|
|
@@ -21741,7 +21755,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
21741
21755
|
*/
|
|
21742
21756
|
async search(params = {}, accountId) {
|
|
21743
21757
|
const id = this.accountId(accountId);
|
|
21744
|
-
requireSort(params.sort,
|
|
21758
|
+
requireSort(params.sort, DOCUMENT_SORTS);
|
|
21745
21759
|
return this.callList(
|
|
21746
21760
|
"Failed to search documents",
|
|
21747
21761
|
() => this.http.get(`/accounts/${id}/documents/search`, {
|
|
@@ -22096,8 +22110,7 @@ function validateUpload(buffer, fileName) {
|
|
|
22096
22110
|
}
|
|
22097
22111
|
function buildUploadForm(buffer, fileName, name, metadata) {
|
|
22098
22112
|
const form = new FormData();
|
|
22099
|
-
|
|
22100
|
-
form.append("file", new Blob([view], { type: "application/pdf" }), fileName);
|
|
22113
|
+
appendFilePart(form, buffer, "application/pdf", fileName);
|
|
22101
22114
|
form.append("name", name);
|
|
22102
22115
|
if (metadata) {
|
|
22103
22116
|
form.append("metadata", JSON.stringify(metadata));
|
|
@@ -22212,21 +22225,26 @@ function validationConfig(signerAccessCode) {
|
|
|
22212
22225
|
|
|
22213
22226
|
// src/api/resources/oauth.ts
|
|
22214
22227
|
var import_node_crypto = require("crypto");
|
|
22215
|
-
|
|
22216
|
-
|
|
22217
|
-
}
|
|
22228
|
+
function formRequestConfig() {
|
|
22229
|
+
return publicRequestConfig({
|
|
22230
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
22231
|
+
});
|
|
22232
|
+
}
|
|
22218
22233
|
var OAuthResource = class extends BaseResource {
|
|
22219
22234
|
/** `GET /.well-known/oauth-protected-resource` at the API origin, outside `/v1`. */
|
|
22220
22235
|
async metadata() {
|
|
22221
|
-
return this.call(
|
|
22222
|
-
|
|
22223
|
-
()
|
|
22236
|
+
return this.call("Failed to discover OAuth resource", () => {
|
|
22237
|
+
const baseURL = this.http.defaults.baseURL;
|
|
22238
|
+
if (!baseURL) {
|
|
22239
|
+
throw new ValidationError("A base URL is required to discover OAuth metadata");
|
|
22240
|
+
}
|
|
22241
|
+
return this.http.get(
|
|
22224
22242
|
"/.well-known/oauth-protected-resource",
|
|
22225
22243
|
publicRequestConfig({
|
|
22226
|
-
baseURL: new URL(
|
|
22244
|
+
baseURL: new URL(baseURL).origin
|
|
22227
22245
|
})
|
|
22228
|
-
)
|
|
22229
|
-
);
|
|
22246
|
+
);
|
|
22247
|
+
});
|
|
22230
22248
|
}
|
|
22231
22249
|
/** Read RFC 8414 metadata from an HTTPS issuer and verify its issuer identity. */
|
|
22232
22250
|
async discovery(issuer) {
|
|
@@ -22350,7 +22368,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
22350
22368
|
}
|
|
22351
22369
|
const tokens = await this.call(
|
|
22352
22370
|
"OAuth token request failed",
|
|
22353
|
-
() => this.http.post("/oauth/token", payload, formRequestConfig)
|
|
22371
|
+
() => this.http.post("/oauth/token", payload, formRequestConfig())
|
|
22354
22372
|
);
|
|
22355
22373
|
const next = tokens?.refresh_token;
|
|
22356
22374
|
if (payload.grant_type === "refresh_token" && (typeof next !== "string" || !next.trim() || next === payload.refresh_token)) {
|
|
@@ -22371,7 +22389,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
22371
22389
|
}
|
|
22372
22390
|
await this.call(
|
|
22373
22391
|
"OAuth revocation failed",
|
|
22374
|
-
() => this.http.post("/oauth/revoke", payload, formRequestConfig)
|
|
22392
|
+
() => this.http.post("/oauth/revoke", payload, formRequestConfig())
|
|
22375
22393
|
);
|
|
22376
22394
|
}
|
|
22377
22395
|
/** `GET /oauth/userinfo` — flat OIDC claims; requires a bearer token with `openid`. */
|
|
@@ -22769,12 +22787,18 @@ var SignerResource = class extends BaseResource {
|
|
|
22769
22787
|
requireEmail(email);
|
|
22770
22788
|
try {
|
|
22771
22789
|
const lower = email.toLowerCase();
|
|
22772
|
-
for (let page = 1; ; page++) {
|
|
22790
|
+
for (let page = 1; page <= MAX_SEARCH_PAGES; page++) {
|
|
22773
22791
|
const { data, meta } = await this.list({ search: email, per_page: 100, page }, accountId);
|
|
22774
22792
|
const match = data.find((s) => (s.email ?? "").toLowerCase() === lower);
|
|
22775
22793
|
if (match) return match;
|
|
22776
|
-
if (!data.length
|
|
22794
|
+
if (!data.length) return null;
|
|
22795
|
+
if (meta?.last_page !== void 0) {
|
|
22796
|
+
if (page >= meta.last_page) return null;
|
|
22797
|
+
} else if (data.length < 100) {
|
|
22798
|
+
return null;
|
|
22799
|
+
}
|
|
22777
22800
|
}
|
|
22801
|
+
throw new ValidationError("Signer email search exceeded the maximum page count");
|
|
22778
22802
|
} catch (err) {
|
|
22779
22803
|
if (err instanceof ApiError && err.statusCode === 404) {
|
|
22780
22804
|
return null;
|
|
@@ -22783,6 +22807,7 @@ var SignerResource = class extends BaseResource {
|
|
|
22783
22807
|
}
|
|
22784
22808
|
}
|
|
22785
22809
|
};
|
|
22810
|
+
var MAX_SEARCH_PAGES = 100;
|
|
22786
22811
|
function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
22787
22812
|
const normalised = {
|
|
22788
22813
|
full_name: payload.full_name,
|
|
@@ -22797,7 +22822,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
|
22797
22822
|
if ("metadata" in payload && payload.metadata !== void 0) {
|
|
22798
22823
|
normalised.metadata = payload.metadata;
|
|
22799
22824
|
}
|
|
22800
|
-
return
|
|
22825
|
+
return stripEmpty(normalised);
|
|
22801
22826
|
}
|
|
22802
22827
|
|
|
22803
22828
|
// src/api/resources/tags.ts
|
|
@@ -22818,7 +22843,7 @@ var TagResource = class extends BaseResource {
|
|
|
22818
22843
|
const id = this.accountId(accountId);
|
|
22819
22844
|
return this.call(
|
|
22820
22845
|
"Failed to create tag",
|
|
22821
|
-
() => this.http.post(`/accounts/${id}/tags`,
|
|
22846
|
+
() => this.http.post(`/accounts/${id}/tags`, stripEmpty({ ...payload }))
|
|
22822
22847
|
);
|
|
22823
22848
|
}
|
|
22824
22849
|
/**
|
|
@@ -23091,9 +23116,8 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
23091
23116
|
throw new ValidationError("Logo buffer is required");
|
|
23092
23117
|
}
|
|
23093
23118
|
const contentType = options.contentType ?? "image/png";
|
|
23094
|
-
const view = new Uint8Array(logo.buffer, logo.byteOffset, logo.byteLength);
|
|
23095
23119
|
const form = new FormData();
|
|
23096
|
-
form
|
|
23120
|
+
appendFilePart(form, logo, contentType, options.fileName ?? "logo.png");
|
|
23097
23121
|
return this.call(
|
|
23098
23122
|
"Failed to upload workspace logo",
|
|
23099
23123
|
() => this.http.post(`/accounts/${id}/logo`, form, {
|
|
@@ -23557,6 +23581,21 @@ function addSortableListOptions(command, description) {
|
|
|
23557
23581
|
function addListOptions(command, sortDescription = "Sort by field") {
|
|
23558
23582
|
return addSearchListOptions(command).option("--sort <field>", sortDescription);
|
|
23559
23583
|
}
|
|
23584
|
+
function addDownloadOptions(command) {
|
|
23585
|
+
return command.option("-o, --output <path>", "Output file path").option("--force", "Overwrite the output file if it already exists");
|
|
23586
|
+
}
|
|
23587
|
+
function addSignerRefOptions(command) {
|
|
23588
|
+
return command.addOption(
|
|
23589
|
+
new Option("--signer-ids <csv>", "Comma-separated signer IDs (required)").conflicts(
|
|
23590
|
+
"signers"
|
|
23591
|
+
)
|
|
23592
|
+
).addOption(
|
|
23593
|
+
new Option(
|
|
23594
|
+
"--signers <json>",
|
|
23595
|
+
"JSON array of signer refs, with verification_method, step, \u2026 (required)"
|
|
23596
|
+
).conflicts("signerIds")
|
|
23597
|
+
);
|
|
23598
|
+
}
|
|
23560
23599
|
|
|
23561
23600
|
// src/lib/output.ts
|
|
23562
23601
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
@@ -23662,6 +23701,11 @@ function paginationFooter(result) {
|
|
|
23662
23701
|
}
|
|
23663
23702
|
return parts.length > 0 ? import_picocolors2.default.dim(parts.join(" \xB7 ")) : "";
|
|
23664
23703
|
}
|
|
23704
|
+
function tableWithFooter(table, result) {
|
|
23705
|
+
const footer = paginationFooter(result);
|
|
23706
|
+
return footer ? `${table}
|
|
23707
|
+
${footer}` : table;
|
|
23708
|
+
}
|
|
23665
23709
|
|
|
23666
23710
|
// src/lib/config.ts
|
|
23667
23711
|
var import_node_crypto3 = require("crypto");
|
|
@@ -24787,7 +24831,7 @@ async function withSpinner(message, config, task) {
|
|
|
24787
24831
|
if (!useSpinner) {
|
|
24788
24832
|
return task();
|
|
24789
24833
|
}
|
|
24790
|
-
const s = spinner();
|
|
24834
|
+
const s = spinner({ output: process.stderr });
|
|
24791
24835
|
s.start(message);
|
|
24792
24836
|
try {
|
|
24793
24837
|
const result = await task();
|
|
@@ -24864,7 +24908,7 @@ function displayWidth(text2) {
|
|
|
24864
24908
|
}
|
|
24865
24909
|
|
|
24866
24910
|
// src/commands/assignments.ts
|
|
24867
|
-
function
|
|
24911
|
+
function resolveAssignmentSignerRefs(signersJson, signerIdsCsv, required2 = true) {
|
|
24868
24912
|
if (signersJson) {
|
|
24869
24913
|
return parseJsonArray(signersJson, "--signers");
|
|
24870
24914
|
}
|
|
@@ -24894,25 +24938,22 @@ var listCommand = addSortableListOptions(
|
|
|
24894
24938
|
{ header: "SIGNERS", value: (r2) => r2.signers?.length },
|
|
24895
24939
|
{ header: "EXPIRES", value: (r2) => r2.expires_at }
|
|
24896
24940
|
]);
|
|
24897
|
-
|
|
24898
|
-
return footer ? `${table}
|
|
24899
|
-
${footer}` : table;
|
|
24941
|
+
return tableWithFooter(table, result);
|
|
24900
24942
|
});
|
|
24901
24943
|
});
|
|
24902
24944
|
});
|
|
24903
|
-
var createCommand =
|
|
24904
|
-
new
|
|
24905
|
-
|
|
24906
|
-
|
|
24907
|
-
|
|
24908
|
-
).option("--method <method>", "virtual or collect", "virtual").option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").option(
|
|
24945
|
+
var createCommand = addSignerRefOptions(
|
|
24946
|
+
new Command("create").description("Create a signing assignment for a document").argument("<documentId>", "Document ID")
|
|
24947
|
+
).addOption(
|
|
24948
|
+
new Option("--method <method>", "virtual or collect").choices(["virtual", "collect"]).default("virtual")
|
|
24949
|
+
).option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").option(
|
|
24909
24950
|
"--entries <json>",
|
|
24910
24951
|
`JSON array of field placement entries, required for --method collect (e.g. '[{"page_id":"p1","fields":[{"signer_id":"s1","field_id":"f1"}]}]')`
|
|
24911
24952
|
).action(async (documentId, opts, command) => {
|
|
24912
24953
|
await runWithClient(command, async ({ client, config }) => {
|
|
24913
24954
|
const payload = {
|
|
24914
24955
|
method: opts.method,
|
|
24915
|
-
signers:
|
|
24956
|
+
signers: resolveAssignmentSignerRefs(opts.signers, opts.signerIds)
|
|
24916
24957
|
};
|
|
24917
24958
|
if (opts.message) payload.message = opts.message;
|
|
24918
24959
|
if (opts.expiresAt) payload.expires_at = opts.expiresAt;
|
|
@@ -24939,7 +24980,11 @@ var createCommand = new Command("create").description("Create a signing assignme
|
|
|
24939
24980
|
);
|
|
24940
24981
|
});
|
|
24941
24982
|
});
|
|
24942
|
-
var estimateCostCommand =
|
|
24983
|
+
var estimateCostCommand = addSignerRefOptions(
|
|
24984
|
+
new Command("estimate-cost").description("Estimate the credit cost of an assignment").argument("<documentId>", "Document ID")
|
|
24985
|
+
).addOption(
|
|
24986
|
+
new Option("--method <method>", "virtual or collect").choices(["virtual", "collect"]).default("virtual")
|
|
24987
|
+
).option(
|
|
24943
24988
|
"--entries <json>",
|
|
24944
24989
|
"JSON array of field placement entries, required for --method collect"
|
|
24945
24990
|
).action(async (documentId, opts, command) => {
|
|
@@ -24947,7 +24992,7 @@ var estimateCostCommand = new Command("estimate-cost").description("Estimate the
|
|
|
24947
24992
|
const method = opts.method;
|
|
24948
24993
|
const payload = {
|
|
24949
24994
|
method,
|
|
24950
|
-
signers:
|
|
24995
|
+
signers: resolveAssignmentSignerRefs(opts.signers, opts.signerIds, true)
|
|
24951
24996
|
};
|
|
24952
24997
|
if (opts.entries) {
|
|
24953
24998
|
payload.entries = parseJsonArray(opts.entries, "--entries");
|
|
@@ -25023,11 +25068,11 @@ var assignmentsCommand = new Command("assignments").description("Create and mana
|
|
|
25023
25068
|
|
|
25024
25069
|
// src/lib/prompts.ts
|
|
25025
25070
|
async function promptText(message, placeholder) {
|
|
25026
|
-
const value = await text({ message, placeholder });
|
|
25071
|
+
const value = await text({ message, placeholder, output: process.stderr });
|
|
25027
25072
|
return unwrap(value);
|
|
25028
25073
|
}
|
|
25029
25074
|
async function promptSecret(message) {
|
|
25030
|
-
const value = await password({ message });
|
|
25075
|
+
const value = await password({ message, output: process.stderr });
|
|
25031
25076
|
return unwrap(value);
|
|
25032
25077
|
}
|
|
25033
25078
|
async function confirmDestructive(message, force) {
|
|
@@ -25035,13 +25080,13 @@ async function confirmDestructive(message, force) {
|
|
|
25035
25080
|
if (!process.stdin.isTTY) {
|
|
25036
25081
|
throw new CliError("Refusing to proceed without confirmation. Re-run with --yes to confirm.");
|
|
25037
25082
|
}
|
|
25038
|
-
const value = await confirm({ message });
|
|
25083
|
+
const value = await confirm({ message, output: process.stderr });
|
|
25039
25084
|
return unwrap(value);
|
|
25040
25085
|
}
|
|
25041
25086
|
function unwrap(value) {
|
|
25042
25087
|
if (isCancel3(value)) {
|
|
25043
|
-
cancel("Cancelled.");
|
|
25044
|
-
|
|
25088
|
+
cancel("Cancelled.", { output: process.stderr });
|
|
25089
|
+
throw new CliError("Cancelled.", { exitCode: 130 });
|
|
25045
25090
|
}
|
|
25046
25091
|
return value;
|
|
25047
25092
|
}
|
|
@@ -25074,7 +25119,9 @@ var loginCommand = new Command("login").description(
|
|
|
25074
25119
|
);
|
|
25075
25120
|
});
|
|
25076
25121
|
});
|
|
25077
|
-
var socialLoginCommand = new Command("social-login").description("Exchange a provider token for an Assinafy JWT (no existing credentials required)").
|
|
25122
|
+
var socialLoginCommand = new Command("social-login").description("Exchange a provider token for an Assinafy JWT (no existing credentials required)").addOption(
|
|
25123
|
+
new Option("--provider <provider>", "OAuth provider").choices(["google"]).makeOptionMandatory()
|
|
25124
|
+
).addOption(
|
|
25078
25125
|
new Option("--provider-token <token>", "Provider token").env("ASSINAFY_PROVIDER_TOKEN").makeOptionMandatory()
|
|
25079
25126
|
).option("--accept-terms", "Accept the platform terms").action(async (opts, command) => {
|
|
25080
25127
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
@@ -25323,24 +25370,181 @@ var pathCommand = new Command("path").description("Print the config file path").
|
|
|
25323
25370
|
});
|
|
25324
25371
|
var configCommand = new Command("config").description("Manage credentials, profiles, and settings").addCommand(setCommand).addCommand(getCommand).addCommand(listCommand2).addCommand(useCommand).addCommand(removeCommand).addCommand(pathCommand);
|
|
25325
25372
|
|
|
25326
|
-
// src/
|
|
25373
|
+
// src/lib/oauth-browser.ts
|
|
25327
25374
|
var import_node_child_process2 = require("child_process");
|
|
25375
|
+
var import_node_crypto4 = require("crypto");
|
|
25376
|
+
var import_node_events2 = require("events");
|
|
25377
|
+
var import_node_http = require("http");
|
|
25378
|
+
var CLI_OAUTH_REDIRECT_URI = "https://integrations.assinafy.com.br/assinafy-cli/oauth-callback";
|
|
25379
|
+
var clearHistory = "history.replaceState(null, '', '/');";
|
|
25380
|
+
var brandOrigin = "https://integrations.assinafy.com.br";
|
|
25381
|
+
var callbackCopy = {
|
|
25382
|
+
received: {
|
|
25383
|
+
heading: "Volte ao terminal.",
|
|
25384
|
+
status: "A resposta de autoriza\xE7\xE3o foi recebida. Confira no terminal se a conex\xE3o foi conclu\xEDda."
|
|
25385
|
+
},
|
|
25386
|
+
denied: {
|
|
25387
|
+
heading: "Conex\xE3o n\xE3o autorizada.",
|
|
25388
|
+
status: "A autoriza\xE7\xE3o n\xE3o foi conclu\xEDda. Confira o erro no terminal e inicie uma nova conex\xE3o."
|
|
25389
|
+
},
|
|
25390
|
+
invalid: {
|
|
25391
|
+
heading: "Retorno inv\xE1lido.",
|
|
25392
|
+
status: "Continue na janela original de autoriza\xE7\xE3o. Se ela expirou, inicie uma nova conex\xE3o no terminal."
|
|
25393
|
+
}
|
|
25394
|
+
};
|
|
25395
|
+
function callbackPage(status) {
|
|
25396
|
+
const copy = callbackCopy[status];
|
|
25397
|
+
return `<!doctype html>
|
|
25398
|
+
<html lang="pt-BR">
|
|
25399
|
+
<head>
|
|
25400
|
+
<meta charset="utf-8">
|
|
25401
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
25402
|
+
<meta name="referrer" content="no-referrer">
|
|
25403
|
+
<meta name="robots" content="noindex, nofollow, noarchive">
|
|
25404
|
+
<title>${copy.heading} | Assinafy CLI</title>
|
|
25405
|
+
<script>${clearHistory}</script>
|
|
25406
|
+
<link rel="icon" href="${brandOrigin}/brand/assinafy-icon.png">
|
|
25407
|
+
<link rel="stylesheet" href="${brandOrigin}/brand/colors.css">
|
|
25408
|
+
<link rel="stylesheet" href="${brandOrigin}/brand/site.css">
|
|
25409
|
+
<link rel="stylesheet" href="${brandOrigin}/oauth-callback.css">
|
|
25410
|
+
</head>
|
|
25411
|
+
<body>
|
|
25412
|
+
<a class="skip-link" href="#conteudo">Pular para o conte\xFAdo</a>
|
|
25413
|
+
<header class="site-header wrap">
|
|
25414
|
+
<a class="brand" href="${brandOrigin}" aria-label="Assinafy Integra\xE7\xF5es, in\xEDcio">
|
|
25415
|
+
<img src="${brandOrigin}/brand/assinafy-logotype.svg" width="148" height="32" alt="Assinafy">
|
|
25416
|
+
<span class="brand-section">integra\xE7\xF5es</span>
|
|
25417
|
+
</a>
|
|
25418
|
+
</header>
|
|
25419
|
+
<main id="conteudo" class="hero wrap">
|
|
25420
|
+
<div>
|
|
25421
|
+
<p class="eyebrow"><img src="${brandOrigin}/assinafy-cli/cli-icon.svg" width="24" height="24" alt="">Conex\xE3o com a Assinafy CLI</p>
|
|
25422
|
+
<h1>${copy.heading}</h1>
|
|
25423
|
+
<p class="hero-description" role="status">${copy.status}</p>
|
|
25424
|
+
<a class="button button-primary" href="${brandOrigin}/assinafy-cli">Ajuda para conectar<svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12h16m-7-7 7 7-7 7"/></svg></a>
|
|
25425
|
+
</div>
|
|
25426
|
+
<figure class="connection-art">
|
|
25427
|
+
<div class="connection-map" role="img" aria-label="Retorno de autoriza\xE7\xE3o: Assinafy para Assinafy CLI.">
|
|
25428
|
+
<svg class="connection-lines" viewBox="0 0 480 240" preserveAspectRatio="none" fill="none" aria-hidden="true">
|
|
25429
|
+
<path class="connection-route" d="M120 106H240"/>
|
|
25430
|
+
<path class="connection-complete" d="M240 106H374m-64-5 5 5-5 5"/>
|
|
25431
|
+
</svg>
|
|
25432
|
+
<div class="connection-node connection-assinafy" aria-hidden="true">
|
|
25433
|
+
<span class="connection-tile"><img src="${brandOrigin}/brand/assinafy-icon.png" width="60" height="60" alt=""></span>
|
|
25434
|
+
<span class="connection-label">Assinafy</span>
|
|
25435
|
+
</div>
|
|
25436
|
+
<div class="connection-node connection-application" aria-hidden="true">
|
|
25437
|
+
<span class="connection-tile"><img src="${brandOrigin}/assinafy-cli/cli-icon.svg" width="36" height="36" alt=""></span>
|
|
25438
|
+
<span class="connection-label">Assinafy CLI</span>
|
|
25439
|
+
</div>
|
|
25440
|
+
</div>
|
|
25441
|
+
<figcaption class="connection-caption">Continue no terminal que iniciou a conex\xE3o.</figcaption>
|
|
25442
|
+
</figure>
|
|
25443
|
+
</main>
|
|
25444
|
+
<footer class="site-footer wrap"><span>Assinafy. Assinaturas que conectam.</span></footer>
|
|
25445
|
+
</body>
|
|
25446
|
+
</html>`;
|
|
25447
|
+
}
|
|
25448
|
+
var callbackHeaders = {
|
|
25449
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
25450
|
+
"Cache-Control": "no-store",
|
|
25451
|
+
"Referrer-Policy": "no-referrer",
|
|
25452
|
+
"X-Content-Type-Options": "nosniff",
|
|
25453
|
+
"X-Robots-Tag": "noindex, nofollow, noarchive",
|
|
25454
|
+
"Content-Security-Policy": `default-src 'none'; script-src 'sha256-${(0, import_node_crypto4.createHash)("sha256").update(clearHistory).digest("base64")}'; style-src ${brandOrigin}; img-src ${brandOrigin}; font-src ${brandOrigin}; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`,
|
|
25455
|
+
Connection: "close"
|
|
25456
|
+
};
|
|
25457
|
+
function openBrowser(url2) {
|
|
25458
|
+
const [executable, args] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["rundll32.exe", ["url.dll,FileProtocolHandler", url2]] : ["xdg-open", [url2]];
|
|
25459
|
+
return new Promise((resolve, reject) => {
|
|
25460
|
+
const child = (0, import_node_child_process2.spawn)(executable, args, {
|
|
25461
|
+
stdio: "ignore",
|
|
25462
|
+
detached: true,
|
|
25463
|
+
windowsHide: true
|
|
25464
|
+
});
|
|
25465
|
+
child.once("error", () => reject(new CliError("Could not open the system browser.")));
|
|
25466
|
+
child.once("spawn", () => {
|
|
25467
|
+
child.unref();
|
|
25468
|
+
resolve();
|
|
25469
|
+
});
|
|
25470
|
+
});
|
|
25471
|
+
}
|
|
25472
|
+
async function connectOAuth(oauth, options, onAuthorize, timeoutMs = 18e4) {
|
|
25473
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 6e5) {
|
|
25474
|
+
throw new CliError("OAuth connection timeout must be between 1 and 600000 milliseconds.");
|
|
25475
|
+
}
|
|
25476
|
+
const request = await oauth.authorize(options);
|
|
25477
|
+
if (new URL(request.redirect_uri).search) {
|
|
25478
|
+
throw new CliError("The browser relay redirect URI must not contain query parameters.");
|
|
25479
|
+
}
|
|
25480
|
+
const server = (0, import_node_http.createServer)({ maxHeaderSize: 8192, requestTimeout: 5e3, headersTimeout: 5e3 });
|
|
25481
|
+
server.maxConnections = 8;
|
|
25482
|
+
server.setTimeout(5e3, (socket) => socket.destroy());
|
|
25483
|
+
let timer;
|
|
25484
|
+
let callbackUrl;
|
|
25485
|
+
try {
|
|
25486
|
+
server.listen(0, "127.0.0.1");
|
|
25487
|
+
await (0, import_node_events2.once)(server, "listening");
|
|
25488
|
+
const address = server.address();
|
|
25489
|
+
if (!address || typeof address === "string") throw new CliError("No OAuth listener address.");
|
|
25490
|
+
const host = `127.0.0.1:${address.port}`;
|
|
25491
|
+
request.state += `.${address.port}`;
|
|
25492
|
+
const expectedState = Buffer.from(request.state);
|
|
25493
|
+
const authorization = new URL(request.authorization_url);
|
|
25494
|
+
authorization.searchParams.set("state", request.state);
|
|
25495
|
+
request.authorization_url = authorization.toString();
|
|
25496
|
+
callbackUrl = await new Promise((resolve, reject) => {
|
|
25497
|
+
let consumed = false;
|
|
25498
|
+
timer = setTimeout(
|
|
25499
|
+
() => reject(new CliError("OAuth connection timed out. Start again.")),
|
|
25500
|
+
timeoutMs
|
|
25501
|
+
);
|
|
25502
|
+
server.once("error", reject);
|
|
25503
|
+
server.on("request", (incoming, response) => {
|
|
25504
|
+
const raw = incoming.url ?? "";
|
|
25505
|
+
const url2 = new URL(raw.startsWith("/callback?") ? raw : "/invalid", `http://${host}`);
|
|
25506
|
+
const query = url2.searchParams;
|
|
25507
|
+
const state = Buffer.from(query.get("state") ?? "");
|
|
25508
|
+
const valid = !consumed && incoming.method === "GET" && incoming.headers.host === host && raw.startsWith("/callback?") && raw.length <= 8192 && url2.origin === `http://${host}` && url2.pathname === "/callback" && !url2.hash && [...query.keys()].every((key) => query.getAll(key).length === 1) && state.length === expectedState.length && (0, import_node_crypto4.timingSafeEqual)(state, expectedState) && query.get("iss") === request.issuer && query.has("code") !== query.has("error") && Boolean((query.get("code") ?? query.get("error"))?.trim());
|
|
25509
|
+
if (!valid) {
|
|
25510
|
+
response.writeHead(400, callbackHeaders);
|
|
25511
|
+
response.end(callbackPage("invalid"));
|
|
25512
|
+
return;
|
|
25513
|
+
}
|
|
25514
|
+
consumed = true;
|
|
25515
|
+
const callback = new URL(request.redirect_uri);
|
|
25516
|
+
for (const key of ["code", "state", "iss", "error"]) {
|
|
25517
|
+
if (query.has(key)) callback.searchParams.set(key, query.get(key));
|
|
25518
|
+
}
|
|
25519
|
+
response.writeHead(200, callbackHeaders);
|
|
25520
|
+
response.end(
|
|
25521
|
+
callbackPage(query.has("error") ? "denied" : "received"),
|
|
25522
|
+
() => resolve(callback.toString())
|
|
25523
|
+
);
|
|
25524
|
+
});
|
|
25525
|
+
void Promise.resolve().then(() => onAuthorize(request.authorization_url)).catch(reject);
|
|
25526
|
+
});
|
|
25527
|
+
} finally {
|
|
25528
|
+
clearTimeout(timer);
|
|
25529
|
+
await new Promise((resolve) => {
|
|
25530
|
+
server.close(() => resolve());
|
|
25531
|
+
server.closeAllConnections();
|
|
25532
|
+
});
|
|
25533
|
+
}
|
|
25534
|
+
return oauth.exchangeCode(callbackUrl, request);
|
|
25535
|
+
}
|
|
25536
|
+
|
|
25537
|
+
// src/commands/docs.ts
|
|
25328
25538
|
var DOCS_URL = "https://api.assinafy.com.br/v1/docs";
|
|
25329
25539
|
var docsCommand = new Command("docs").description("Print (or open) the Assinafy API documentation URL").option("--open", "Open the documentation in your default browser").action(async (opts, command) => {
|
|
25330
25540
|
await runAction(command, async ({ config }) => {
|
|
25331
25541
|
if (opts.open) {
|
|
25332
|
-
|
|
25333
|
-
|
|
25334
|
-
|
|
25335
|
-
|
|
25336
|
-
|
|
25337
|
-
}
|
|
25338
|
-
child.on(
|
|
25339
|
-
"error",
|
|
25340
|
-
() => printWarning(`Could not open a browser. Visit ${DOCS_URL}`, config)
|
|
25341
|
-
);
|
|
25342
|
-
child.unref();
|
|
25343
|
-
printInfo(`Opening ${DOCS_URL}`, config);
|
|
25542
|
+
try {
|
|
25543
|
+
await openBrowser(DOCS_URL);
|
|
25544
|
+
printInfo(`Opening ${DOCS_URL}`, config);
|
|
25545
|
+
} catch {
|
|
25546
|
+
printWarning(`Could not open a browser. Visit ${DOCS_URL}`, config);
|
|
25547
|
+
}
|
|
25344
25548
|
}
|
|
25345
25549
|
printData({ docs: DOCS_URL }, config, (data) => data.docs);
|
|
25346
25550
|
});
|
|
@@ -25376,6 +25580,16 @@ function defaultArtifactFilename(documentId, artifact) {
|
|
|
25376
25580
|
const ext = artifact === "thumbnail" ? "jpg" : artifact === "bundle" ? "zip" : "pdf";
|
|
25377
25581
|
return `${documentId}-${artifact}.${ext}`;
|
|
25378
25582
|
}
|
|
25583
|
+
async function saveDownload(config, options) {
|
|
25584
|
+
const buffer = await withSpinner(options.message, config, options.download);
|
|
25585
|
+
const out = writeBinary(options.output ?? options.defaultName, buffer, { force: options.force });
|
|
25586
|
+
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
25587
|
+
printData(
|
|
25588
|
+
{ path: out, bytes: buffer.byteLength, ...options.data },
|
|
25589
|
+
config,
|
|
25590
|
+
(d) => sanitizeTerminalText(d.path)
|
|
25591
|
+
);
|
|
25592
|
+
}
|
|
25379
25593
|
|
|
25380
25594
|
// src/commands/documents.ts
|
|
25381
25595
|
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) => {
|
|
@@ -25421,12 +25635,15 @@ function renderDocumentListTable(result) {
|
|
|
25421
25635
|
{ header: "STATUS", value: (r2) => r2.status },
|
|
25422
25636
|
{ header: "CREATED", value: (r2) => r2.created_at }
|
|
25423
25637
|
]);
|
|
25424
|
-
|
|
25425
|
-
return footer ? `${table}
|
|
25426
|
-
${footer}` : table;
|
|
25638
|
+
return tableWithFooter(table, result);
|
|
25427
25639
|
}
|
|
25428
25640
|
var listCommand3 = addListOptions(
|
|
25429
|
-
new Command("list").description("List workspace documents").option("--status <status>", "Filter by document status").
|
|
25641
|
+
new Command("list").description("List workspace documents").option("--status <status>", "Filter by document status").addOption(
|
|
25642
|
+
new Option("--method <method>", "Filter by signature method (virtual or collect)").choices([
|
|
25643
|
+
"virtual",
|
|
25644
|
+
"collect"
|
|
25645
|
+
])
|
|
25646
|
+
).option("--tags <ids>", "Comma-separated tag IDs (AND semantics)")
|
|
25430
25647
|
).action(async (opts, command) => {
|
|
25431
25648
|
await runWithClient(command, async ({ client, config }) => {
|
|
25432
25649
|
const accountId = requireAccountId(config);
|
|
@@ -25491,63 +25708,49 @@ var renameCommand = new Command("rename").description("Rename a document (only b
|
|
|
25491
25708
|
printData(doc, config, (d) => renderKeyValue({ id: d.id, name: d.name, status: d.status }));
|
|
25492
25709
|
});
|
|
25493
25710
|
});
|
|
25494
|
-
var downloadCommand =
|
|
25495
|
-
"
|
|
25496
|
-
|
|
25497
|
-
|
|
25498
|
-
|
|
25711
|
+
var downloadCommand = addDownloadOptions(
|
|
25712
|
+
new Command("download").description("Download a document artifact").argument("<id>", "Document ID").option(
|
|
25713
|
+
"--artifact <name>",
|
|
25714
|
+
"original | certificated | certificate-page | pades | bundle",
|
|
25715
|
+
"certificated"
|
|
25716
|
+
)
|
|
25717
|
+
).action(async (id, opts, command) => {
|
|
25499
25718
|
await runWithClient(command, async ({ client, config }) => {
|
|
25500
25719
|
const artifact = requireDocumentArtifactName(opts.artifact);
|
|
25501
|
-
|
|
25502
|
-
"Downloading document",
|
|
25503
|
-
|
|
25504
|
-
|
|
25505
|
-
|
|
25506
|
-
|
|
25507
|
-
|
|
25720
|
+
await saveDownload(config, {
|
|
25721
|
+
message: "Downloading document",
|
|
25722
|
+
download: () => client.documents.download(id, artifact),
|
|
25723
|
+
output: opts.output,
|
|
25724
|
+
defaultName: defaultArtifactFilename(id, artifact),
|
|
25725
|
+
force: opts.force,
|
|
25726
|
+
data: { artifact }
|
|
25508
25727
|
});
|
|
25509
|
-
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
25510
|
-
printData(
|
|
25511
|
-
{ path: out, bytes: buffer.byteLength, artifact },
|
|
25512
|
-
config,
|
|
25513
|
-
(d) => sanitizeTerminalText(d.path)
|
|
25514
|
-
);
|
|
25515
25728
|
});
|
|
25516
25729
|
});
|
|
25517
|
-
var thumbnailCommand =
|
|
25730
|
+
var thumbnailCommand = addDownloadOptions(
|
|
25731
|
+
new Command("thumbnail").description("Download the document thumbnail (JPEG)").argument("<id>", "Document ID")
|
|
25732
|
+
).action(async (id, opts, command) => {
|
|
25518
25733
|
await runWithClient(command, async ({ client, config }) => {
|
|
25519
|
-
|
|
25520
|
-
"Downloading thumbnail",
|
|
25521
|
-
|
|
25522
|
-
|
|
25523
|
-
|
|
25524
|
-
const out = writeBinary(opts.output ?? defaultArtifactFilename(id, "thumbnail"), buffer, {
|
|
25734
|
+
await saveDownload(config, {
|
|
25735
|
+
message: "Downloading thumbnail",
|
|
25736
|
+
download: () => client.documents.thumbnail(id),
|
|
25737
|
+
output: opts.output,
|
|
25738
|
+
defaultName: defaultArtifactFilename(id, "thumbnail"),
|
|
25525
25739
|
force: opts.force
|
|
25526
25740
|
});
|
|
25527
|
-
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
25528
|
-
printData(
|
|
25529
|
-
{ path: out, bytes: buffer.byteLength },
|
|
25530
|
-
config,
|
|
25531
|
-
(d) => sanitizeTerminalText(d.path)
|
|
25532
|
-
);
|
|
25533
25741
|
});
|
|
25534
25742
|
});
|
|
25535
|
-
var downloadPageCommand =
|
|
25743
|
+
var downloadPageCommand = addDownloadOptions(
|
|
25744
|
+
new Command("download-page").description("Download a single document page (JPEG)").argument("<id>", "Document ID").argument("<pageId>", "Page ID")
|
|
25745
|
+
).action(async (id, pageId, opts, command) => {
|
|
25536
25746
|
await runWithClient(command, async ({ client, config }) => {
|
|
25537
|
-
|
|
25538
|
-
"Downloading page",
|
|
25539
|
-
|
|
25540
|
-
|
|
25541
|
-
|
|
25542
|
-
const out = writeBinary(opts.output ?? `${id}-page-${pageId}.jpg`, buffer, {
|
|
25747
|
+
await saveDownload(config, {
|
|
25748
|
+
message: "Downloading page",
|
|
25749
|
+
download: () => client.documents.downloadPage(id, pageId),
|
|
25750
|
+
output: opts.output,
|
|
25751
|
+
defaultName: `${id}-page-${pageId}.jpg`,
|
|
25543
25752
|
force: opts.force
|
|
25544
25753
|
});
|
|
25545
|
-
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
25546
|
-
printData(
|
|
25547
|
-
{ path: out, bytes: buffer.byteLength },
|
|
25548
|
-
config,
|
|
25549
|
-
(d) => sanitizeTerminalText(d.path)
|
|
25550
|
-
);
|
|
25551
25754
|
});
|
|
25552
25755
|
});
|
|
25553
25756
|
var activitiesCommand = new Command("activities").description("Show the activity log for a document").argument("<id>", "Document ID").action(async (id, _opts, command) => {
|
|
@@ -25706,14 +25909,14 @@ var publicCommand = new Command("public").description("Public (unauthenticated)
|
|
|
25706
25909
|
});
|
|
25707
25910
|
});
|
|
25708
25911
|
var sendTokenCommand = new Command("send-token").description("Send a 6-digit verification token to a signer").argument("<id>", "Document ID").addOption(
|
|
25709
|
-
new Option(
|
|
25710
|
-
"
|
|
25711
|
-
"
|
|
25712
|
-
])
|
|
25912
|
+
new Option(
|
|
25913
|
+
"--email <email>",
|
|
25914
|
+
"Email address (compatibility overload for older deployments)"
|
|
25915
|
+
).conflicts(["recipient", "channel"])
|
|
25713
25916
|
).addOption(
|
|
25714
25917
|
new Option(
|
|
25715
25918
|
"--recipient <value>",
|
|
25716
|
-
"Email address or phone number (
|
|
25919
|
+
"Email address or phone number (production payload)"
|
|
25717
25920
|
).conflicts("email")
|
|
25718
25921
|
).addOption(
|
|
25719
25922
|
new Option("--channel <channel>", "email or whatsapp").default("email").conflicts("email")
|
|
@@ -25786,6 +25989,9 @@ var fieldColumns = [
|
|
|
25786
25989
|
{ header: "REQUIRED", value: (r2) => r2.is_required },
|
|
25787
25990
|
{ header: "ACTIVE", value: (r2) => r2.is_active }
|
|
25788
25991
|
];
|
|
25992
|
+
var signerAccessCodeOption = () => new Option("--signer-access-code <code>", "Signer access code (for signer-side validation)").env(
|
|
25993
|
+
"ASSINAFY_SIGNER_ACCESS_CODE"
|
|
25994
|
+
);
|
|
25789
25995
|
var createCommand2 = new Command("create").description("Create a custom field definition").requiredOption("--type <type>", "Field type (see `fields types`)").requiredOption("--name <name>", "Field name").option("--regex <regex>", "Validation regex").option("--required", "Mark the field as required").option("--inactive", "Compatibility: create the field inactive").action(async (opts, command) => {
|
|
25790
25996
|
await runWithClient(command, async ({ client, config }) => {
|
|
25791
25997
|
const accountId = requireAccountId(config);
|
|
@@ -25857,12 +26063,7 @@ var deleteCommand2 = new Command("delete").alias("rm").description("Delete a fie
|
|
|
25857
26063
|
printData({ deleted: id }, config);
|
|
25858
26064
|
});
|
|
25859
26065
|
});
|
|
25860
|
-
var validateCommand = new Command("validate").description("Validate a value against a field definition").argument("<id>", "Field ID").argument("<value>", "Value to validate").addOption(
|
|
25861
|
-
new Option(
|
|
25862
|
-
"--signer-access-code <code>",
|
|
25863
|
-
"Signer access code (for signer-side validation)"
|
|
25864
|
-
).env("ASSINAFY_SIGNER_ACCESS_CODE")
|
|
25865
|
-
).action(async (id, value, opts, command) => {
|
|
26066
|
+
var validateCommand = new Command("validate").description("Validate a value against a field definition").argument("<id>", "Field ID").argument("<value>", "Value to validate").addOption(signerAccessCodeOption()).action(async (id, value, opts, command) => {
|
|
25866
26067
|
const run = opts.signerAccessCode ? runWithPublicClient : runWithClient;
|
|
25867
26068
|
await run(command, async ({ client, config }) => {
|
|
25868
26069
|
const accountId = requireAccountId(config);
|
|
@@ -25878,11 +26079,7 @@ var validateCommand = new Command("validate").description("Validate a value agai
|
|
|
25878
26079
|
);
|
|
25879
26080
|
});
|
|
25880
26081
|
});
|
|
25881
|
-
var validateMultipleCommand = new Command("validate-multiple").description("Validate multiple field values at once").requiredOption("--entries <json>", "JSON array of { field_id, value } entries").addOption(
|
|
25882
|
-
new Option("--signer-access-code <code>", "Signer access code").env(
|
|
25883
|
-
"ASSINAFY_SIGNER_ACCESS_CODE"
|
|
25884
|
-
)
|
|
25885
|
-
).action(async (opts, command) => {
|
|
26082
|
+
var validateMultipleCommand = new Command("validate-multiple").description("Validate multiple field values at once").requiredOption("--entries <json>", "JSON array of { field_id, value } entries").addOption(signerAccessCodeOption()).action(async (opts, command) => {
|
|
25886
26083
|
const run = opts.signerAccessCode ? runWithPublicClient : runWithClient;
|
|
25887
26084
|
await run(command, async ({ client, config }) => {
|
|
25888
26085
|
const accountId = requireAccountId(config);
|
|
@@ -25965,178 +26162,6 @@ var logoutCommand = new Command("logout").description("Remove stored credentials
|
|
|
25965
26162
|
});
|
|
25966
26163
|
});
|
|
25967
26164
|
|
|
25968
|
-
// src/lib/oauth-browser.ts
|
|
25969
|
-
var import_node_child_process3 = require("child_process");
|
|
25970
|
-
var import_node_crypto4 = require("crypto");
|
|
25971
|
-
var import_node_events2 = require("events");
|
|
25972
|
-
var import_node_http = require("http");
|
|
25973
|
-
var CLI_OAUTH_REDIRECT_URI = "https://integrations.assinafy.com.br/assinafy-cli/oauth-callback";
|
|
25974
|
-
var clearHistory = "history.replaceState(null, '', '/');";
|
|
25975
|
-
var brandOrigin = "https://integrations.assinafy.com.br";
|
|
25976
|
-
var callbackCopy = {
|
|
25977
|
-
received: {
|
|
25978
|
-
heading: "Volte ao terminal.",
|
|
25979
|
-
status: "A resposta de autoriza\xE7\xE3o foi recebida. Confira no terminal se a conex\xE3o foi conclu\xEDda."
|
|
25980
|
-
},
|
|
25981
|
-
denied: {
|
|
25982
|
-
heading: "Conex\xE3o n\xE3o autorizada.",
|
|
25983
|
-
status: "A autoriza\xE7\xE3o n\xE3o foi conclu\xEDda. Confira o erro no terminal e inicie uma nova conex\xE3o."
|
|
25984
|
-
},
|
|
25985
|
-
invalid: {
|
|
25986
|
-
heading: "Retorno inv\xE1lido.",
|
|
25987
|
-
status: "Continue na janela original de autoriza\xE7\xE3o. Se ela expirou, inicie uma nova conex\xE3o no terminal."
|
|
25988
|
-
}
|
|
25989
|
-
};
|
|
25990
|
-
function callbackPage(status) {
|
|
25991
|
-
const copy = callbackCopy[status];
|
|
25992
|
-
return `<!doctype html>
|
|
25993
|
-
<html lang="pt-BR">
|
|
25994
|
-
<head>
|
|
25995
|
-
<meta charset="utf-8">
|
|
25996
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
25997
|
-
<meta name="referrer" content="no-referrer">
|
|
25998
|
-
<meta name="robots" content="noindex, nofollow, noarchive">
|
|
25999
|
-
<title>${copy.heading} | Assinafy CLI</title>
|
|
26000
|
-
<script>${clearHistory}</script>
|
|
26001
|
-
<link rel="icon" href="${brandOrigin}/brand/assinafy-icon.png">
|
|
26002
|
-
<link rel="stylesheet" href="${brandOrigin}/brand/colors.css">
|
|
26003
|
-
<link rel="stylesheet" href="${brandOrigin}/brand/site.css">
|
|
26004
|
-
<link rel="stylesheet" href="${brandOrigin}/oauth-callback.css">
|
|
26005
|
-
</head>
|
|
26006
|
-
<body>
|
|
26007
|
-
<a class="skip-link" href="#conteudo">Pular para o conte\xFAdo</a>
|
|
26008
|
-
<header class="site-header wrap">
|
|
26009
|
-
<a class="brand" href="${brandOrigin}" aria-label="Assinafy Integra\xE7\xF5es, in\xEDcio">
|
|
26010
|
-
<img src="${brandOrigin}/brand/assinafy-logotype.svg" width="148" height="32" alt="Assinafy">
|
|
26011
|
-
<span class="brand-section">integra\xE7\xF5es</span>
|
|
26012
|
-
</a>
|
|
26013
|
-
</header>
|
|
26014
|
-
<main id="conteudo" class="hero wrap">
|
|
26015
|
-
<div>
|
|
26016
|
-
<p class="eyebrow"><img src="${brandOrigin}/assinafy-cli/cli-icon.svg" width="24" height="24" alt="">Conex\xE3o com a Assinafy CLI</p>
|
|
26017
|
-
<h1>${copy.heading}</h1>
|
|
26018
|
-
<p class="hero-description" role="status">${copy.status}</p>
|
|
26019
|
-
<a class="button button-primary" href="${brandOrigin}/assinafy-cli">Ajuda para conectar<svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12h16m-7-7 7 7-7 7"/></svg></a>
|
|
26020
|
-
</div>
|
|
26021
|
-
<figure class="connection-art">
|
|
26022
|
-
<div class="connection-map" role="img" aria-label="Retorno de autoriza\xE7\xE3o: Assinafy para Assinafy CLI.">
|
|
26023
|
-
<svg class="connection-lines" viewBox="0 0 480 240" preserveAspectRatio="none" fill="none" aria-hidden="true">
|
|
26024
|
-
<path class="connection-route" d="M120 106H240"/>
|
|
26025
|
-
<path class="connection-complete" d="M240 106H374m-64-5 5 5-5 5"/>
|
|
26026
|
-
</svg>
|
|
26027
|
-
<div class="connection-node connection-assinafy" aria-hidden="true">
|
|
26028
|
-
<span class="connection-tile"><img src="${brandOrigin}/brand/assinafy-icon.png" width="60" height="60" alt=""></span>
|
|
26029
|
-
<span class="connection-label">Assinafy</span>
|
|
26030
|
-
</div>
|
|
26031
|
-
<div class="connection-node connection-application" aria-hidden="true">
|
|
26032
|
-
<span class="connection-tile"><img src="${brandOrigin}/assinafy-cli/cli-icon.svg" width="36" height="36" alt=""></span>
|
|
26033
|
-
<span class="connection-label">Assinafy CLI</span>
|
|
26034
|
-
</div>
|
|
26035
|
-
</div>
|
|
26036
|
-
<figcaption class="connection-caption">Continue no terminal que iniciou a conex\xE3o.</figcaption>
|
|
26037
|
-
</figure>
|
|
26038
|
-
</main>
|
|
26039
|
-
<footer class="site-footer wrap"><span>Assinafy. Assinaturas que conectam.</span></footer>
|
|
26040
|
-
</body>
|
|
26041
|
-
</html>`;
|
|
26042
|
-
}
|
|
26043
|
-
var callbackHeaders = {
|
|
26044
|
-
"Content-Type": "text/html; charset=utf-8",
|
|
26045
|
-
"Cache-Control": "no-store",
|
|
26046
|
-
"Referrer-Policy": "no-referrer",
|
|
26047
|
-
"X-Content-Type-Options": "nosniff",
|
|
26048
|
-
"X-Robots-Tag": "noindex, nofollow, noarchive",
|
|
26049
|
-
"Content-Security-Policy": `default-src 'none'; script-src 'sha256-${(0, import_node_crypto4.createHash)("sha256").update(clearHistory).digest("base64")}'; style-src ${brandOrigin}; img-src ${brandOrigin}; font-src ${brandOrigin}; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`,
|
|
26050
|
-
Connection: "close"
|
|
26051
|
-
};
|
|
26052
|
-
function openBrowser(url2) {
|
|
26053
|
-
const [executable, args] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["rundll32.exe", ["url.dll,FileProtocolHandler", url2]] : ["xdg-open", [url2]];
|
|
26054
|
-
return new Promise((resolve, reject) => {
|
|
26055
|
-
const child = (0, import_node_child_process3.spawn)(executable, args, {
|
|
26056
|
-
stdio: "ignore",
|
|
26057
|
-
detached: true,
|
|
26058
|
-
windowsHide: true
|
|
26059
|
-
});
|
|
26060
|
-
child.once("error", () => reject(new CliError("Could not open the system browser.")));
|
|
26061
|
-
child.once("spawn", () => {
|
|
26062
|
-
child.unref();
|
|
26063
|
-
resolve();
|
|
26064
|
-
});
|
|
26065
|
-
});
|
|
26066
|
-
}
|
|
26067
|
-
async function connectOAuth(oauth, options, onAuthorize, timeoutMs = 18e4) {
|
|
26068
|
-
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 6e5) {
|
|
26069
|
-
throw new CliError("OAuth connection timeout must be between 1 and 600000 milliseconds.");
|
|
26070
|
-
}
|
|
26071
|
-
const request = await oauth.authorize(options);
|
|
26072
|
-
if (new URL(request.redirect_uri).search) {
|
|
26073
|
-
throw new CliError("The browser relay redirect URI must not contain query parameters.");
|
|
26074
|
-
}
|
|
26075
|
-
const server = (0, import_node_http.createServer)({ maxHeaderSize: 8192, requestTimeout: 5e3, headersTimeout: 5e3 });
|
|
26076
|
-
server.maxConnections = 8;
|
|
26077
|
-
server.setTimeout(5e3, (socket) => socket.destroy());
|
|
26078
|
-
let timer;
|
|
26079
|
-
let cancel2;
|
|
26080
|
-
let terminate;
|
|
26081
|
-
let callbackUrl;
|
|
26082
|
-
try {
|
|
26083
|
-
server.listen(0, "127.0.0.1");
|
|
26084
|
-
await (0, import_node_events2.once)(server, "listening");
|
|
26085
|
-
const address = server.address();
|
|
26086
|
-
if (!address || typeof address === "string") throw new CliError("No OAuth listener address.");
|
|
26087
|
-
const host = `127.0.0.1:${address.port}`;
|
|
26088
|
-
request.state += `.${address.port}`;
|
|
26089
|
-
const expectedState = Buffer.from(request.state);
|
|
26090
|
-
const authorization = new URL(request.authorization_url);
|
|
26091
|
-
authorization.searchParams.set("state", request.state);
|
|
26092
|
-
request.authorization_url = authorization.toString();
|
|
26093
|
-
callbackUrl = await new Promise((resolve, reject) => {
|
|
26094
|
-
let consumed = false;
|
|
26095
|
-
timer = setTimeout(
|
|
26096
|
-
() => reject(new CliError("OAuth connection timed out. Start again.")),
|
|
26097
|
-
timeoutMs
|
|
26098
|
-
);
|
|
26099
|
-
cancel2 = () => reject(new CliError("OAuth connection cancelled.", { exitCode: 130 }));
|
|
26100
|
-
terminate = () => reject(new CliError("OAuth connection terminated.", { exitCode: 143 }));
|
|
26101
|
-
process.once("SIGINT", cancel2);
|
|
26102
|
-
process.once("SIGTERM", terminate);
|
|
26103
|
-
server.once("error", reject);
|
|
26104
|
-
server.on("request", (incoming, response) => {
|
|
26105
|
-
const raw = incoming.url ?? "";
|
|
26106
|
-
const url2 = new URL(raw.startsWith("/callback?") ? raw : "/invalid", `http://${host}`);
|
|
26107
|
-
const query = url2.searchParams;
|
|
26108
|
-
const state = Buffer.from(query.get("state") ?? "");
|
|
26109
|
-
const valid = !consumed && incoming.method === "GET" && incoming.headers.host === host && raw.startsWith("/callback?") && raw.length <= 8192 && url2.origin === `http://${host}` && url2.pathname === "/callback" && !url2.hash && [...query.keys()].every((key) => query.getAll(key).length === 1) && state.length === expectedState.length && (0, import_node_crypto4.timingSafeEqual)(state, expectedState) && query.get("iss") === request.issuer && query.has("code") !== query.has("error") && Boolean((query.get("code") ?? query.get("error"))?.trim());
|
|
26110
|
-
if (!valid) {
|
|
26111
|
-
response.writeHead(400, callbackHeaders);
|
|
26112
|
-
response.end(callbackPage("invalid"));
|
|
26113
|
-
return;
|
|
26114
|
-
}
|
|
26115
|
-
consumed = true;
|
|
26116
|
-
const callback = new URL(request.redirect_uri);
|
|
26117
|
-
for (const key of ["code", "state", "iss", "error"]) {
|
|
26118
|
-
if (query.has(key)) callback.searchParams.set(key, query.get(key));
|
|
26119
|
-
}
|
|
26120
|
-
response.writeHead(200, callbackHeaders);
|
|
26121
|
-
response.end(
|
|
26122
|
-
callbackPage(query.has("error") ? "denied" : "received"),
|
|
26123
|
-
() => resolve(callback.toString())
|
|
26124
|
-
);
|
|
26125
|
-
});
|
|
26126
|
-
void Promise.resolve().then(() => onAuthorize(request.authorization_url)).catch(reject);
|
|
26127
|
-
});
|
|
26128
|
-
} finally {
|
|
26129
|
-
clearTimeout(timer);
|
|
26130
|
-
if (cancel2) process.off("SIGINT", cancel2);
|
|
26131
|
-
if (terminate) process.off("SIGTERM", terminate);
|
|
26132
|
-
await new Promise((resolve) => {
|
|
26133
|
-
server.close(() => resolve());
|
|
26134
|
-
server.closeAllConnections();
|
|
26135
|
-
});
|
|
26136
|
-
}
|
|
26137
|
-
return oauth.exchangeCode(callbackUrl, request);
|
|
26138
|
-
}
|
|
26139
|
-
|
|
26140
26165
|
// src/commands/oauth.ts
|
|
26141
26166
|
var clientIdOption = () => new Option("--client-id <id>", "OAuth application client ID").env("ASSINAFY_OAUTH_CLIENT_ID").default("96BZZ0sZTb2NkEXt1GCaIRCTprI2YKHZr8JDHawuXUyCLC88");
|
|
26142
26167
|
var clientSecretOption = () => new Option(
|
|
@@ -26157,7 +26182,7 @@ var connectCommand = new Command("connect").description(
|
|
|
26157
26182
|
{
|
|
26158
26183
|
clientId: opts.clientId,
|
|
26159
26184
|
redirectUri: opts.redirectUri,
|
|
26160
|
-
scopes: opts.scope.trim().split(/\s+/)
|
|
26185
|
+
scopes: opts.scope.trim().split(/\s+/).filter(Boolean)
|
|
26161
26186
|
},
|
|
26162
26187
|
async (url2) => {
|
|
26163
26188
|
process.stderr.write(
|
|
@@ -26207,7 +26232,7 @@ var authorizeCommand = new Command("authorize").description(
|
|
|
26207
26232
|
await client.oauth.authorize({
|
|
26208
26233
|
clientId: opts.clientId,
|
|
26209
26234
|
redirectUri: opts.redirectUri,
|
|
26210
|
-
scopes: opts.scope.trim().split(/\s+/)
|
|
26235
|
+
scopes: opts.scope.trim().split(/\s+/).filter(Boolean)
|
|
26211
26236
|
}),
|
|
26212
26237
|
config
|
|
26213
26238
|
);
|
|
@@ -26274,6 +26299,7 @@ var userinfoCommand = new Command("userinfo").description("Read OIDC claims usin
|
|
|
26274
26299
|
var oauthCommand = new Command("oauth").description("OAuth 2.1 authorization, PKCE, token rotation, and OpenID Connect").addCommand(connectCommand).addCommand(metadataCommand).addCommand(discoveryCommand).addCommand(authorizeCommand).addCommand(exchangeCommand).addCommand(refreshCommand).addCommand(revokeCommand).addCommand(userinfoCommand);
|
|
26275
26300
|
|
|
26276
26301
|
// src/commands/send.ts
|
|
26302
|
+
var phonePattern = /^\+?[\d\s().-]*\d[\d\s().-]*$/;
|
|
26277
26303
|
function parseSignerSpec(spec) {
|
|
26278
26304
|
const match = spec.match(/^\s*(.*?)\s*<\s*([^>]*)\s*>\s*$/);
|
|
26279
26305
|
const name = match?.[1]?.trim();
|
|
@@ -26282,12 +26308,17 @@ function parseSignerSpec(spec) {
|
|
|
26282
26308
|
throw new CliError(`Invalid --signer "${spec}". Use "Name <email-or-phone>".`);
|
|
26283
26309
|
}
|
|
26284
26310
|
const isEmail = contact.includes("@");
|
|
26311
|
+
if (!match && !isEmail && !phonePattern.test(contact)) {
|
|
26312
|
+
throw new CliError(
|
|
26313
|
+
`Invalid --signer "${spec}". A bare contact must be an email or a phone number. Use "Name <email-or-phone>".`
|
|
26314
|
+
);
|
|
26315
|
+
}
|
|
26285
26316
|
const signer = { name: name || contact };
|
|
26286
26317
|
if (isEmail) signer.email = contact;
|
|
26287
26318
|
else signer.whatsapp_phone_number = contact;
|
|
26288
26319
|
return signer;
|
|
26289
26320
|
}
|
|
26290
|
-
function
|
|
26321
|
+
function resolveSigners(signerSpecs, signersJson) {
|
|
26291
26322
|
if (signerSpecs.length > 0 && signersJson) {
|
|
26292
26323
|
throw new CliError("Provide either --signer or --signers, not both.");
|
|
26293
26324
|
}
|
|
@@ -26304,7 +26335,7 @@ var sendCommand = new Command("send").description("Upload a PDF, create signers,
|
|
|
26304
26335
|
).addOption(new Option("--signers <json>", "JSON array of signer objects").conflicts("signer")).option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").option("--metadata <json>", "JSON object of metadata to attach to the document").option("--no-wait", "Do not wait for the document to finish processing").action(async (file, opts, command) => {
|
|
26305
26336
|
await runWithClient(command, async ({ client, config }) => {
|
|
26306
26337
|
const accountId = requireAccountId(config);
|
|
26307
|
-
const signers =
|
|
26338
|
+
const signers = resolveSigners(opts.signer, opts.signers);
|
|
26308
26339
|
const params = {
|
|
26309
26340
|
source: { filePath: file },
|
|
26310
26341
|
signers,
|
|
@@ -26389,29 +26420,22 @@ var searchCommand2 = new Command("search").description("Search the signer's docu
|
|
|
26389
26420
|
);
|
|
26390
26421
|
});
|
|
26391
26422
|
});
|
|
26392
|
-
var downloadCommand2 =
|
|
26393
|
-
new
|
|
26394
|
-
"
|
|
26423
|
+
var downloadCommand2 = addDownloadOptions(
|
|
26424
|
+
new Command("download").description("Download a signer document artifact").argument("<signerId>", "Signer ID").argument("<documentId>", "Document ID").argument("<artifact>", "original | certificated | certificate-page | pades | bundle").addOption(
|
|
26425
|
+
new Option("--access-code <code>", "Optional signer identity preflight code").env(
|
|
26426
|
+
"ASSINAFY_SIGNER_ACCESS_CODE"
|
|
26427
|
+
)
|
|
26395
26428
|
)
|
|
26396
|
-
).
|
|
26429
|
+
).action(async (signerId, documentId, artifact, opts, command) => {
|
|
26397
26430
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
26398
26431
|
const artifactName = requireDocumentArtifactName(artifact);
|
|
26399
|
-
|
|
26400
|
-
"Downloading",
|
|
26401
|
-
|
|
26402
|
-
|
|
26403
|
-
|
|
26404
|
-
|
|
26405
|
-
|
|
26406
|
-
buffer,
|
|
26407
|
-
{ force: opts.force }
|
|
26408
|
-
);
|
|
26409
|
-
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
26410
|
-
printData(
|
|
26411
|
-
{ path: out, bytes: buffer.byteLength },
|
|
26412
|
-
config,
|
|
26413
|
-
(d) => sanitizeTerminalText(d.path)
|
|
26414
|
-
);
|
|
26432
|
+
await saveDownload(config, {
|
|
26433
|
+
message: "Downloading",
|
|
26434
|
+
download: () => client.signerDocuments.download(signerId, documentId, artifactName, opts.accessCode),
|
|
26435
|
+
output: opts.output,
|
|
26436
|
+
defaultName: defaultArtifactFilename(documentId, artifactName),
|
|
26437
|
+
force: opts.force
|
|
26438
|
+
});
|
|
26415
26439
|
});
|
|
26416
26440
|
});
|
|
26417
26441
|
var selfCommand = new Command("self").description("Fetch the signer's own profile").addOption(accessCodeOption()).action(async (opts, command) => {
|
|
@@ -26508,23 +26532,18 @@ var uploadSignatureCommand = new Command("upload-signature").description("Upload
|
|
|
26508
26532
|
printData(result, config);
|
|
26509
26533
|
});
|
|
26510
26534
|
});
|
|
26511
|
-
var downloadSignatureCommand =
|
|
26535
|
+
var downloadSignatureCommand = addDownloadOptions(
|
|
26536
|
+
new Command("download-signature").description("Download the signer's signature or initial image").addOption(accessCodeOption()).option("--type <type>", "signature or initial", "signature")
|
|
26537
|
+
).action(async (opts, command) => {
|
|
26512
26538
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
26513
26539
|
const imageType = requireSignerImageType(opts.type);
|
|
26514
|
-
|
|
26515
|
-
"Downloading signature",
|
|
26516
|
-
|
|
26517
|
-
|
|
26518
|
-
|
|
26519
|
-
const out = writeBinary(opts.output ?? `signer-${imageType}.png`, buffer, {
|
|
26540
|
+
await saveDownload(config, {
|
|
26541
|
+
message: "Downloading signature",
|
|
26542
|
+
download: () => client.signerDocuments.downloadSignature(opts.accessCode, imageType),
|
|
26543
|
+
output: opts.output,
|
|
26544
|
+
defaultName: `signer-${imageType}.png`,
|
|
26520
26545
|
force: opts.force
|
|
26521
26546
|
});
|
|
26522
|
-
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
26523
|
-
printData(
|
|
26524
|
-
{ path: out, bytes: buffer.byteLength },
|
|
26525
|
-
config,
|
|
26526
|
-
(d) => sanitizeTerminalText(d.path)
|
|
26527
|
-
);
|
|
26528
26547
|
});
|
|
26529
26548
|
});
|
|
26530
26549
|
var assignmentCommand = new Command("assignment").description("Fetch the assignment as the signer sees it").addOption(accessCodeOption()).option("--accept-terms", "Pass has_accepted_terms=true").action(async (opts, command) => {
|
|
@@ -26639,9 +26658,7 @@ var listCommand5 = addListOptions(
|
|
|
26639
26658
|
);
|
|
26640
26659
|
printPaginatedData(result, config, (rows) => {
|
|
26641
26660
|
const table = renderTable(rows, signerColumns);
|
|
26642
|
-
|
|
26643
|
-
return footer ? `${table}
|
|
26644
|
-
${footer}` : table;
|
|
26661
|
+
return tableWithFooter(table, result);
|
|
26645
26662
|
});
|
|
26646
26663
|
});
|
|
26647
26664
|
});
|
|
@@ -26787,9 +26804,7 @@ var listCommand7 = addListOptions(
|
|
|
26787
26804
|
{ header: "STATUS", value: (r2) => r2.status },
|
|
26788
26805
|
{ header: "CREATED", value: (r2) => r2.created_at }
|
|
26789
26806
|
]);
|
|
26790
|
-
|
|
26791
|
-
return footer ? `${table}
|
|
26792
|
-
${footer}` : table;
|
|
26807
|
+
return tableWithFooter(table, result);
|
|
26793
26808
|
});
|
|
26794
26809
|
});
|
|
26795
26810
|
});
|
|
@@ -26813,23 +26828,18 @@ var getCommand5 = new Command("get").description("Show a template by ID").argume
|
|
|
26813
26828
|
);
|
|
26814
26829
|
});
|
|
26815
26830
|
});
|
|
26816
|
-
var downloadPageCommand2 =
|
|
26831
|
+
var downloadPageCommand2 = addDownloadOptions(
|
|
26832
|
+
new Command("download-page").description("Download a template page as a JPEG").argument("<templateId>", "Template ID").argument("<pageId>", "Page ID")
|
|
26833
|
+
).action(async (templateId, pageId, opts, command) => {
|
|
26817
26834
|
await runWithClient(command, async ({ client, config }) => {
|
|
26818
26835
|
const accountId = requireAccountId(config);
|
|
26819
|
-
|
|
26820
|
-
"Downloading page",
|
|
26821
|
-
|
|
26822
|
-
|
|
26823
|
-
|
|
26824
|
-
const out = writeBinary(opts.output ?? `${templateId}-page-${pageId}.jpg`, buffer, {
|
|
26836
|
+
await saveDownload(config, {
|
|
26837
|
+
message: "Downloading page",
|
|
26838
|
+
download: () => client.templates.downloadPage(templateId, pageId, accountId),
|
|
26839
|
+
output: opts.output,
|
|
26840
|
+
defaultName: `${templateId}-page-${pageId}.jpg`,
|
|
26825
26841
|
force: opts.force
|
|
26826
26842
|
});
|
|
26827
|
-
printSuccess(`Saved ${buffer.byteLength} bytes to ${out}`, config);
|
|
26828
|
-
printData(
|
|
26829
|
-
{ path: out, bytes: buffer.byteLength },
|
|
26830
|
-
config,
|
|
26831
|
-
(d) => sanitizeTerminalText(d.path)
|
|
26832
|
-
);
|
|
26833
26843
|
});
|
|
26834
26844
|
});
|
|
26835
26845
|
var templatesCommand = new Command("templates").description("List and inspect document templates").addCommand(listCommand7).addCommand(getCommand5).addCommand(downloadPageCommand2);
|
|
@@ -26841,7 +26851,9 @@ var selfCommand2 = new Command("self").description("Show the authenticated user'
|
|
|
26841
26851
|
printData(user, config);
|
|
26842
26852
|
});
|
|
26843
26853
|
});
|
|
26844
|
-
var statsCommand = new Command("stats").description("Show document KPIs across the user's accounts").
|
|
26854
|
+
var statsCommand = new Command("stats").description("Show document KPIs across the user's accounts").addOption(
|
|
26855
|
+
new Option("--granularity <value>", "monthly or daily").choices(["monthly", "daily"]).default("monthly")
|
|
26856
|
+
).option("--month <yyyy-mm>", "Month required for daily granularity").action(async (opts, command) => {
|
|
26845
26857
|
await runWithClient(command, async ({ client, config }) => {
|
|
26846
26858
|
const params = {
|
|
26847
26859
|
granularity: opts.granularity,
|
|
@@ -26991,9 +27003,7 @@ var dispatchesCommand = addSortableListOptions(
|
|
|
26991
27003
|
{ header: "STATUS", value: (r2) => r2.http_status },
|
|
26992
27004
|
{ header: "ENDPOINT", value: (r2) => r2.endpoint }
|
|
26993
27005
|
]);
|
|
26994
|
-
|
|
26995
|
-
return footer ? `${table}
|
|
26996
|
-
${footer}` : table;
|
|
27006
|
+
return tableWithFooter(table, result);
|
|
26997
27007
|
});
|
|
26998
27008
|
});
|
|
26999
27009
|
});
|
|
@@ -27038,7 +27048,12 @@ var whoamiCommand = new Command("whoami").description("Verify credentials and li
|
|
|
27038
27048
|
|
|
27039
27049
|
// src/commands/workspaces.ts
|
|
27040
27050
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
27041
|
-
var createCommand5 = new Command("create").description("Create a workspace (account)").requiredOption("--name <name>", "Workspace name").
|
|
27051
|
+
var createCommand5 = new Command("create").description("Create a workspace (account)").requiredOption("--name <name>", "Workspace name").addOption(
|
|
27052
|
+
new Option("--notification-sender <type>", "Notification sender: User or Account").choices([
|
|
27053
|
+
"User",
|
|
27054
|
+
"Account"
|
|
27055
|
+
])
|
|
27056
|
+
).option("--primary-color <hex>", "Primary brand color").option("--secondary-color <hex>", "Secondary brand color").action(async (opts, command) => {
|
|
27042
27057
|
await runWithClient(command, async ({ client, config }) => {
|
|
27043
27058
|
const workspace = await withSpinner(
|
|
27044
27059
|
"Creating workspace",
|
|
@@ -27083,12 +27098,16 @@ var getCommand7 = new Command("get").description("Show a workspace by ID").argum
|
|
|
27083
27098
|
printData(workspace, config, (w) => renderKeyValue(w));
|
|
27084
27099
|
});
|
|
27085
27100
|
});
|
|
27086
|
-
var updateCommand4 = new Command("update").description("Update a workspace").argument("<id>", "Account/workspace ID").option("--name <name>", "New name").
|
|
27101
|
+
var updateCommand4 = new Command("update").description("Update a workspace").argument("<id>", "Account/workspace ID").option("--name <name>", "New name").addOption(
|
|
27102
|
+
new Option("--notification-sender <type>", "Notification sender: User or Account").choices([
|
|
27103
|
+
"User",
|
|
27104
|
+
"Account"
|
|
27105
|
+
])
|
|
27106
|
+
).option("--primary-color <hex>", "Primary brand color (pass empty to clear)").option("--secondary-color <hex>", "Secondary brand color (pass empty to clear)").action(async (id, opts, command) => {
|
|
27087
27107
|
await runWithClient(command, async ({ client, config }) => {
|
|
27088
27108
|
const payload = {};
|
|
27089
27109
|
if (opts.name) payload.name = opts.name;
|
|
27090
|
-
if (opts.notificationSender)
|
|
27091
|
-
payload.notification_sender_type = opts.notificationSender;
|
|
27110
|
+
if (opts.notificationSender) payload.notification_sender_type = opts.notificationSender;
|
|
27092
27111
|
if (opts.primaryColor !== void 0) payload.primary_color = opts.primaryColor || null;
|
|
27093
27112
|
if (opts.secondaryColor !== void 0) payload.secondary_color = opts.secondaryColor || null;
|
|
27094
27113
|
const workspace = await withSpinner(
|
|
@@ -27114,7 +27133,9 @@ var themeCommand = new Command("theme").description("Show public branding for a
|
|
|
27114
27133
|
);
|
|
27115
27134
|
});
|
|
27116
27135
|
});
|
|
27117
|
-
var statsCommand2 = new Command("stats").description("Show document KPIs for a workspace").argument("<id>", "Account/workspace ID").
|
|
27136
|
+
var statsCommand2 = new Command("stats").description("Show document KPIs for a workspace").argument("<id>", "Account/workspace ID").addOption(
|
|
27137
|
+
new Option("--granularity <value>", "monthly or daily").choices(["monthly", "daily"]).default("monthly")
|
|
27138
|
+
).option("--month <yyyy-mm>", "Month required for daily granularity").action(async (id, opts, command) => {
|
|
27118
27139
|
await runWithClient(command, async ({ client, config }) => {
|
|
27119
27140
|
const params = {
|
|
27120
27141
|
granularity: opts.granularity,
|
|
@@ -27128,20 +27149,17 @@ var statsCommand2 = new Command("stats").description("Show document KPIs for a w
|
|
|
27128
27149
|
printData(rows, config, renderDocumentStats);
|
|
27129
27150
|
});
|
|
27130
27151
|
});
|
|
27131
|
-
var logoDownloadCommand =
|
|
27152
|
+
var logoDownloadCommand = addDownloadOptions(
|
|
27153
|
+
new Command("download").description("Download the workspace logo").argument("<id>", "Account/workspace ID")
|
|
27154
|
+
).action(async (id, opts, command) => {
|
|
27132
27155
|
await runWithClient(command, async ({ client, config }) => {
|
|
27133
|
-
|
|
27134
|
-
"Downloading workspace logo",
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
|
|
27140
|
-
printData(
|
|
27141
|
-
{ path: output, bytes: logo.byteLength },
|
|
27142
|
-
config,
|
|
27143
|
-
(value) => sanitizeTerminalText(value.path)
|
|
27144
|
-
);
|
|
27156
|
+
await saveDownload(config, {
|
|
27157
|
+
message: "Downloading workspace logo",
|
|
27158
|
+
download: () => client.workspaces.downloadLogo(id),
|
|
27159
|
+
output: opts.output,
|
|
27160
|
+
defaultName: `${id}-logo.png`,
|
|
27161
|
+
force: opts.force
|
|
27162
|
+
});
|
|
27145
27163
|
});
|
|
27146
27164
|
});
|
|
27147
27165
|
var logoUploadCommand = new Command("upload").description("Upload or replace the workspace logo").argument("<id>", "Account/workspace ID").argument("<file>", "Logo image path").option("--content-type <mime>", "Image MIME type (inferred from extension)").action(async (id, file, opts, command) => {
|
|
@@ -27228,7 +27246,7 @@ function handleStreamError(err, fallback, exit = process.exit) {
|
|
|
27228
27246
|
// package.json
|
|
27229
27247
|
var package_default = {
|
|
27230
27248
|
name: "@assinafy/cli",
|
|
27231
|
-
version: "2.4.
|
|
27249
|
+
version: "2.4.1",
|
|
27232
27250
|
description: "The official command-line interface for the Assinafy digital-signature API",
|
|
27233
27251
|
license: "MIT",
|
|
27234
27252
|
type: "module",
|