@assinafy/cli 2.7.1 → 2.8.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 +2 -0
- package/README.en.md +14 -8
- package/README.md +11 -3
- package/dist/api.cjs +517 -61
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +514 -61
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +1009 -169
- package/dist/types/api/client.d.ts +5 -0
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/api/envelope-types.d.ts +73 -0
- package/dist/types/api/envelope-types.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +3 -0
- 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/contracts.d.ts +3 -1
- package/dist/types/api/resources/contracts.d.ts.map +1 -1
- package/dist/types/api/resources/documents.d.ts +21 -6
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/resources/embed.d.ts +14 -0
- package/dist/types/api/resources/embed.d.ts.map +1 -0
- package/dist/types/api/resources/envelopes.d.ts +31 -0
- package/dist/types/api/resources/envelopes.d.ts.map +1 -0
- package/dist/types/api/resources/signer-documents.d.ts +23 -11
- package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
- package/dist/types/api/resources/signers.d.ts +1 -1
- package/dist/types/api/resources/signers.d.ts.map +1 -1
- package/dist/types/api/resources/users.d.ts +3 -1
- package/dist/types/api/resources/users.d.ts.map +1 -1
- package/dist/types/api/resources/webhooks.d.ts +6 -2
- package/dist/types/api/resources/webhooks.d.ts.map +1 -1
- package/dist/types/api/resources/workspaces.d.ts +9 -2
- package/dist/types/api/resources/workspaces.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +103 -7
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/api/utils.d.ts +6 -0
- package/dist/types/api/utils.d.ts.map +1 -1
- package/docs/README.md +3 -1
- package/docs/api-operations.json +234 -2
- package/docs/api-reference.md +11533 -3716
- package/docs/assignments.md +16 -14
- package/docs/contracts.md +4 -3
- package/docs/documents.md +44 -27
- package/docs/embed.md +119 -0
- package/docs/envelopes.md +210 -0
- package/docs/sdk-reference.md +215 -29
- package/docs/send.md +15 -11
- package/docs/signer.md +84 -3
- package/docs/users.md +41 -0
- package/docs/webhooks.md +22 -6
- package/docs/workspaces.md +66 -3
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -17784,7 +17784,7 @@ var Http2Sessions = class {
|
|
|
17784
17784
|
}
|
|
17785
17785
|
}
|
|
17786
17786
|
}
|
|
17787
|
-
const
|
|
17787
|
+
const session2 = import_http2.default.connect(authority, options);
|
|
17788
17788
|
let removed;
|
|
17789
17789
|
let timer;
|
|
17790
17790
|
const removeSession = () => {
|
|
@@ -17798,24 +17798,24 @@ var Http2Sessions = class {
|
|
|
17798
17798
|
}
|
|
17799
17799
|
let entries = authoritySessions, len = entries.length, i2 = len;
|
|
17800
17800
|
while (i2--) {
|
|
17801
|
-
if (entries[i2][0] ===
|
|
17801
|
+
if (entries[i2][0] === session2) {
|
|
17802
17802
|
if (len === 1) {
|
|
17803
17803
|
delete this.sessions[authority];
|
|
17804
17804
|
} else {
|
|
17805
17805
|
entries.splice(i2, 1);
|
|
17806
17806
|
}
|
|
17807
|
-
if (!
|
|
17808
|
-
|
|
17807
|
+
if (!session2.closed) {
|
|
17808
|
+
session2.close();
|
|
17809
17809
|
}
|
|
17810
17810
|
return;
|
|
17811
17811
|
}
|
|
17812
17812
|
}
|
|
17813
17813
|
};
|
|
17814
|
-
const originalRequestFn =
|
|
17814
|
+
const originalRequestFn = session2.request;
|
|
17815
17815
|
const { sessionTimeout } = options;
|
|
17816
17816
|
if (sessionTimeout != null) {
|
|
17817
17817
|
let streamsCount = 0;
|
|
17818
|
-
|
|
17818
|
+
session2.request = function() {
|
|
17819
17819
|
const stream4 = originalRequestFn.apply(this, arguments);
|
|
17820
17820
|
streamsCount++;
|
|
17821
17821
|
if (timer) {
|
|
@@ -17833,11 +17833,11 @@ var Http2Sessions = class {
|
|
|
17833
17833
|
return stream4;
|
|
17834
17834
|
};
|
|
17835
17835
|
}
|
|
17836
|
-
|
|
17837
|
-
|
|
17838
|
-
let entry = [
|
|
17836
|
+
session2.once("close", removeSession);
|
|
17837
|
+
session2.once("error", removeSession);
|
|
17838
|
+
let entry = [session2, options];
|
|
17839
17839
|
authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
|
|
17840
|
-
return
|
|
17840
|
+
return session2;
|
|
17841
17841
|
}
|
|
17842
17842
|
};
|
|
17843
17843
|
var Http2Sessions_default = Http2Sessions;
|
|
@@ -18694,7 +18694,7 @@ var http2Transport = {
|
|
|
18694
18694
|
request(options, cb) {
|
|
18695
18695
|
const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
|
|
18696
18696
|
const { http2Options, headers } = options;
|
|
18697
|
-
const
|
|
18697
|
+
const session2 = http2Sessions.getSession(authority, http2Options);
|
|
18698
18698
|
const { HTTP2_HEADER_SCHEME, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_STATUS } = import_http22.default.constants;
|
|
18699
18699
|
const http2Headers = {
|
|
18700
18700
|
[HTTP2_HEADER_SCHEME]: options.protocol.replace(":", ""),
|
|
@@ -18704,7 +18704,7 @@ var http2Transport = {
|
|
|
18704
18704
|
utils_default.forEach(headers, (header, name) => {
|
|
18705
18705
|
name.charAt(0) !== ":" && (http2Headers[name] = header);
|
|
18706
18706
|
});
|
|
18707
|
-
const req =
|
|
18707
|
+
const req = session2.request(http2Headers);
|
|
18708
18708
|
req.once("response", (responseHeaders) => {
|
|
18709
18709
|
const response = req;
|
|
18710
18710
|
responseHeaders = Object.assign({}, responseHeaders);
|
|
@@ -21165,6 +21165,7 @@ var PartialWorkflowError = class extends AssinafyError {
|
|
|
21165
21165
|
};
|
|
21166
21166
|
|
|
21167
21167
|
// src/api/utils.ts
|
|
21168
|
+
var import_node_http = require("http");
|
|
21168
21169
|
var DOCUMENT_ARTIFACT_NAMES = [
|
|
21169
21170
|
"original",
|
|
21170
21171
|
"certificated",
|
|
@@ -21282,6 +21283,12 @@ function requireEmail(value) {
|
|
|
21282
21283
|
return value;
|
|
21283
21284
|
}
|
|
21284
21285
|
function validateSignerOptions(input) {
|
|
21286
|
+
if (input.embedded !== void 0 && typeof input.embedded !== "boolean") {
|
|
21287
|
+
throw new ValidationError("embedded must be a boolean");
|
|
21288
|
+
}
|
|
21289
|
+
if (input.embedded === true && input.verification_method !== void 0 && !["Email", "Whatsapp"].includes(input.verification_method)) {
|
|
21290
|
+
throw new ValidationError("Embedded signing requires Email or Whatsapp verification");
|
|
21291
|
+
}
|
|
21285
21292
|
if (input.verification_method !== void 0 && !VERIFICATION_METHODS.includes(input.verification_method)) {
|
|
21286
21293
|
throw new ValidationError(
|
|
21287
21294
|
`verification_method must be one of: ${VERIFICATION_METHODS.join(", ")}`
|
|
@@ -21308,6 +21315,33 @@ function validateSignerOptions(input) {
|
|
|
21308
21315
|
throw new ValidationError("step must be an integer");
|
|
21309
21316
|
}
|
|
21310
21317
|
}
|
|
21318
|
+
function validateCreditCeiling(value) {
|
|
21319
|
+
if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value) || value < 0)) {
|
|
21320
|
+
throw new ValidationError("max_total_credits must be a finite non-negative number");
|
|
21321
|
+
}
|
|
21322
|
+
}
|
|
21323
|
+
function idempotencyHeaders(key) {
|
|
21324
|
+
if (key === void 0) return void 0;
|
|
21325
|
+
if (typeof key !== "string" || !key.trim()) {
|
|
21326
|
+
throw new ValidationError("idempotencyKey must be nonblank text");
|
|
21327
|
+
}
|
|
21328
|
+
try {
|
|
21329
|
+
(0, import_node_http.validateHeaderValue)("Idempotency-Key", key);
|
|
21330
|
+
} catch {
|
|
21331
|
+
throw new ValidationError("idempotencyKey must be a valid HTTP header value");
|
|
21332
|
+
}
|
|
21333
|
+
return { "Idempotency-Key": key };
|
|
21334
|
+
}
|
|
21335
|
+
function validateBooleanMap(payload, allowed) {
|
|
21336
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload) || !Object.keys(payload).length) {
|
|
21337
|
+
throw new ValidationError("At least one notification preference is required");
|
|
21338
|
+
}
|
|
21339
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
21340
|
+
if (!allowed.includes(key))
|
|
21341
|
+
throw new ValidationError(`Unknown notification preference: ${key}`);
|
|
21342
|
+
if (typeof value !== "boolean") throw new ValidationError(`${key} must be a boolean`);
|
|
21343
|
+
}
|
|
21344
|
+
}
|
|
21311
21345
|
function validateDigitalCertificateMethod(method, signers) {
|
|
21312
21346
|
if (method !== "virtual" && signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
|
|
21313
21347
|
throw new ValidationError("DigitalCertificate signers require method: virtual", {
|
|
@@ -21486,6 +21520,7 @@ function buildAssignmentPayload(payload, options = {}) {
|
|
|
21486
21520
|
throw new ValidationError("method must be virtual or collect");
|
|
21487
21521
|
}
|
|
21488
21522
|
const signers = extractSignerRefs(payload);
|
|
21523
|
+
validateCreditCeiling(payload.max_total_credits);
|
|
21489
21524
|
if (signers.length === 0) {
|
|
21490
21525
|
throw new ValidationError("At least one signer is required", {
|
|
21491
21526
|
signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
|
|
@@ -21506,7 +21541,8 @@ function buildAssignmentPayload(payload, options = {}) {
|
|
|
21506
21541
|
message: payload.message,
|
|
21507
21542
|
expires_at: payload.expires_at === void 0 ? void 0 : requireExpiration(payload.expires_at),
|
|
21508
21543
|
copy_receivers: payload.copy_receivers,
|
|
21509
|
-
entries: payload.entries
|
|
21544
|
+
entries: payload.entries,
|
|
21545
|
+
max_total_credits: payload.max_total_credits
|
|
21510
21546
|
});
|
|
21511
21547
|
}
|
|
21512
21548
|
function extractSignerRefs(payload) {
|
|
@@ -21535,7 +21571,8 @@ function normaliseSignerRef(ref, options) {
|
|
|
21535
21571
|
id,
|
|
21536
21572
|
verification_method: input.verification_method,
|
|
21537
21573
|
notification_methods: input.notification_methods,
|
|
21538
|
-
step: input.step
|
|
21574
|
+
step: input.step,
|
|
21575
|
+
embedded: input.embedded
|
|
21539
21576
|
});
|
|
21540
21577
|
if (typeof id === "string" && id.length > 0) {
|
|
21541
21578
|
return normalised;
|
|
@@ -21887,12 +21924,14 @@ var ContractResource = class extends BaseResource {
|
|
|
21887
21924
|
);
|
|
21888
21925
|
}
|
|
21889
21926
|
/** Read the root contract and its amendments from any document in that family. */
|
|
21890
|
-
async related(documentId, accountId) {
|
|
21927
|
+
async related(documentId, accountId, params = {}) {
|
|
21891
21928
|
const id = this.accountId(accountId);
|
|
21892
21929
|
const did = this.requireId(documentId, "Document ID");
|
|
21893
21930
|
return this.call(
|
|
21894
21931
|
"Failed to get related contracts",
|
|
21895
|
-
() => this.http.get(`/accounts/${id}/documents/${did}/contract/related
|
|
21932
|
+
() => this.http.get(`/accounts/${id}/documents/${did}/contract/related`, {
|
|
21933
|
+
params: cleanParams(params)
|
|
21934
|
+
})
|
|
21896
21935
|
);
|
|
21897
21936
|
}
|
|
21898
21937
|
/** Advance from the supplied current term or to a later end date. No automatic retry. */
|
|
@@ -22073,9 +22112,9 @@ var DocumentResource = class extends BaseResource {
|
|
|
22073
22112
|
);
|
|
22074
22113
|
}
|
|
22075
22114
|
/** Get document details. */
|
|
22076
|
-
async details(documentId) {
|
|
22115
|
+
async details(documentId, params = {}) {
|
|
22077
22116
|
const id = this.requireId(documentId, "Document ID");
|
|
22078
|
-
return this.fetchDetails(id);
|
|
22117
|
+
return this.fetchDetails(id, void 0, params);
|
|
22079
22118
|
}
|
|
22080
22119
|
/**
|
|
22081
22120
|
* Rename a document (`PATCH /documents/{id}`).
|
|
@@ -22092,8 +22131,17 @@ var DocumentResource = class extends BaseResource {
|
|
|
22092
22131
|
);
|
|
22093
22132
|
}
|
|
22094
22133
|
/** Alias for {@link details}. */
|
|
22095
|
-
async get(documentId) {
|
|
22096
|
-
return this.details(documentId);
|
|
22134
|
+
async get(documentId, params = {}) {
|
|
22135
|
+
return this.details(documentId, params);
|
|
22136
|
+
}
|
|
22137
|
+
/** Read only the assignment items visible to this signer. */
|
|
22138
|
+
async getAsSigner(documentId, signerAccessCode) {
|
|
22139
|
+
const id = this.requireId(documentId, "Document ID");
|
|
22140
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22141
|
+
return this.call(
|
|
22142
|
+
"Failed to fetch signer document",
|
|
22143
|
+
() => this.http.get(`/documents/${id}`, signerAccessConfig(code))
|
|
22144
|
+
);
|
|
22097
22145
|
}
|
|
22098
22146
|
/** Poll document status until ready (or a terminal status / timeout). */
|
|
22099
22147
|
async waitUntilReady(documentId, options = {}) {
|
|
@@ -22140,42 +22188,57 @@ var DocumentResource = class extends BaseResource {
|
|
|
22140
22188
|
attempts
|
|
22141
22189
|
});
|
|
22142
22190
|
}
|
|
22143
|
-
fetchDetails(documentId, timeout) {
|
|
22191
|
+
fetchDetails(documentId, timeout, params) {
|
|
22144
22192
|
return this.call(
|
|
22145
22193
|
"Failed to fetch document details",
|
|
22146
|
-
() => this.http.get(`/documents/${documentId}`, timeout
|
|
22194
|
+
() => this.http.get(`/documents/${documentId}`, { timeout, ...params?.expand ? { params } : {} })
|
|
22147
22195
|
);
|
|
22148
22196
|
}
|
|
22149
22197
|
/** Download a document artifact. Defaults to the certificated (signed) PDF. */
|
|
22150
|
-
async download(documentId, artifactName = "certificated") {
|
|
22198
|
+
async download(documentId, artifactName = "certificated", options = {}) {
|
|
22151
22199
|
const id = this.requireId(documentId, "Document ID");
|
|
22152
22200
|
const artifact = requireDocumentArtifactName(artifactName);
|
|
22201
|
+
const config = this.artifactConfig(options);
|
|
22153
22202
|
return this.callBinary(
|
|
22154
22203
|
"Failed to download document",
|
|
22155
22204
|
() => this.http.get(`/documents/${id}/download/${artifact}`, {
|
|
22205
|
+
...config,
|
|
22156
22206
|
responseType: "arraybuffer"
|
|
22157
22207
|
})
|
|
22158
22208
|
);
|
|
22159
22209
|
}
|
|
22160
22210
|
/** Download the document thumbnail. */
|
|
22161
|
-
async thumbnail(documentId) {
|
|
22211
|
+
async thumbnail(documentId, options = {}) {
|
|
22212
|
+
const config = this.artifactConfig(options);
|
|
22162
22213
|
const id = this.requireId(documentId, "Document ID");
|
|
22163
22214
|
return this.callBinary(
|
|
22164
22215
|
"Failed to download document thumbnail",
|
|
22165
|
-
() => this.http.get(`/documents/${id}/thumbnail`, {
|
|
22216
|
+
() => this.http.get(`/documents/${id}/thumbnail`, {
|
|
22217
|
+
...config,
|
|
22218
|
+
responseType: "arraybuffer"
|
|
22219
|
+
})
|
|
22166
22220
|
);
|
|
22167
22221
|
}
|
|
22168
22222
|
/** Download a single page as a JPEG. */
|
|
22169
|
-
async downloadPage(documentId, pageId) {
|
|
22223
|
+
async downloadPage(documentId, pageId, options = {}) {
|
|
22224
|
+
const config = this.artifactConfig(options);
|
|
22170
22225
|
const docId = this.requireId(documentId, "Document ID");
|
|
22171
22226
|
const pid = this.requireId(pageId, "Page ID");
|
|
22172
22227
|
return this.callBinary(
|
|
22173
22228
|
"Failed to download page",
|
|
22174
22229
|
() => this.http.get(`/documents/${docId}/pages/${pid}/download`, {
|
|
22230
|
+
...config,
|
|
22175
22231
|
responseType: "arraybuffer"
|
|
22176
22232
|
})
|
|
22177
22233
|
);
|
|
22178
22234
|
}
|
|
22235
|
+
artifactConfig(options) {
|
|
22236
|
+
if (options.artifact !== void 0 && options.artifact !== "certificated") {
|
|
22237
|
+
throw new ValidationError("artifact must be certificated");
|
|
22238
|
+
}
|
|
22239
|
+
const params = options.artifact === void 0 ? {} : { artifact: options.artifact };
|
|
22240
|
+
return options.signerAccessCode === void 0 ? { params } : signerAccessConfig(this.requireId(options.signerAccessCode, "signer-access-code"), params);
|
|
22241
|
+
}
|
|
22179
22242
|
/** Fetch one page of the document activity log (20 entries by default). */
|
|
22180
22243
|
async activities(documentId, params = {}) {
|
|
22181
22244
|
const id = this.requireId(documentId, "Document ID");
|
|
@@ -22249,6 +22312,9 @@ var DocumentResource = class extends BaseResource {
|
|
|
22249
22312
|
const tmplId = this.requireId(templateId, "Template ID");
|
|
22250
22313
|
const accId = this.accountId(accountId);
|
|
22251
22314
|
validateTemplateSigners(signers, { requireIdentity: true });
|
|
22315
|
+
validateCreditCeiling(options.max_total_credits);
|
|
22316
|
+
const { idempotencyKey, ...bodyOptions } = options;
|
|
22317
|
+
const headers = idempotencyHeaders(idempotencyKey);
|
|
22252
22318
|
if (options.expires_at !== void 0) requireExpiration(options.expires_at);
|
|
22253
22319
|
if (options.editor_fields !== void 0 && (!Array.isArray(options.editor_fields) || options.editor_fields.some((field) => !field?.field_id || typeof field.value !== "string"))) {
|
|
22254
22320
|
throw new ValidationError("editor_fields must contain field_id and value");
|
|
@@ -22257,11 +22323,11 @@ var DocumentResource = class extends BaseResource {
|
|
|
22257
22323
|
throw new ValidationError("tags must contain non-empty tag names");
|
|
22258
22324
|
}
|
|
22259
22325
|
await this.validateCertificateTemplateMethod(tmplId, accId, signers);
|
|
22260
|
-
const body = { ...
|
|
22326
|
+
const body = { ...bodyOptions, signers };
|
|
22261
22327
|
this.logger.info("Creating document from template", { templateId: tmplId, accountId: accId });
|
|
22262
22328
|
return this.call(
|
|
22263
22329
|
"Failed to create document from template",
|
|
22264
|
-
() => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents`, body)
|
|
22330
|
+
() => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents`, body, { headers })
|
|
22265
22331
|
);
|
|
22266
22332
|
}
|
|
22267
22333
|
/** Estimate the credit cost of creating a document from a template. */
|
|
@@ -22440,6 +22506,265 @@ function sleep(ms) {
|
|
|
22440
22506
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
22441
22507
|
}
|
|
22442
22508
|
|
|
22509
|
+
// src/api/resources/embed.ts
|
|
22510
|
+
var EmbedResource = class extends BaseResource {
|
|
22511
|
+
async listOrigins(accountId) {
|
|
22512
|
+
const id = this.accountId(accountId);
|
|
22513
|
+
return this.call(
|
|
22514
|
+
"Failed to list embed origins",
|
|
22515
|
+
() => this.http.get(`/accounts/${id}/embed-origins`)
|
|
22516
|
+
);
|
|
22517
|
+
}
|
|
22518
|
+
async createOrigin(origin2, accountId) {
|
|
22519
|
+
const id = this.accountId(accountId);
|
|
22520
|
+
validateOrigin(origin2);
|
|
22521
|
+
return this.call(
|
|
22522
|
+
"Failed to add embed origin",
|
|
22523
|
+
() => this.http.post(`/accounts/${id}/embed-origins`, { origin: origin2 })
|
|
22524
|
+
);
|
|
22525
|
+
}
|
|
22526
|
+
async updateOrigin(originId, origin2, accountId) {
|
|
22527
|
+
const id = this.accountId(accountId);
|
|
22528
|
+
const oid = this.requireId(originId, "Origin ID");
|
|
22529
|
+
validateOrigin(origin2);
|
|
22530
|
+
return this.call(
|
|
22531
|
+
"Failed to update embed origin",
|
|
22532
|
+
() => this.http.put(`/accounts/${id}/embed-origins/${oid}`, { origin: origin2 })
|
|
22533
|
+
);
|
|
22534
|
+
}
|
|
22535
|
+
async deleteOrigin(originId, accountId) {
|
|
22536
|
+
const id = this.accountId(accountId);
|
|
22537
|
+
const oid = this.requireId(originId, "Origin ID");
|
|
22538
|
+
return this.call(
|
|
22539
|
+
"Failed to delete embed origin",
|
|
22540
|
+
() => this.http.delete(`/accounts/${id}/embed-origins/${oid}`)
|
|
22541
|
+
);
|
|
22542
|
+
}
|
|
22543
|
+
/** Load the returned private URL in the iframe within five minutes. */
|
|
22544
|
+
async createSession(documentId, assignmentId, signerId) {
|
|
22545
|
+
const did = this.requireId(documentId, "Document ID");
|
|
22546
|
+
const aid = this.requireId(assignmentId, "Assignment ID");
|
|
22547
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
22548
|
+
return this.call(
|
|
22549
|
+
"Failed to create embed session",
|
|
22550
|
+
() => this.http.post(`/documents/${did}/assignments/${aid}/signers/${sid}/embed-sessions`)
|
|
22551
|
+
);
|
|
22552
|
+
}
|
|
22553
|
+
/** Used by Assinafy's embed page; consumes the token even on a 409. Never retry automatically. */
|
|
22554
|
+
async exchangeSession(token, parentOrigin) {
|
|
22555
|
+
const value = this.requireId(token, "Embed session token");
|
|
22556
|
+
if (parentOrigin !== void 0) validateOrigin(parentOrigin);
|
|
22557
|
+
return this.call(
|
|
22558
|
+
"Failed to exchange embed session",
|
|
22559
|
+
() => this.http.post(
|
|
22560
|
+
`/embed/sessions/${value}/exchange`,
|
|
22561
|
+
parentOrigin === void 0 ? void 0 : { parent_origin: parentOrigin },
|
|
22562
|
+
publicRequestConfig()
|
|
22563
|
+
)
|
|
22564
|
+
);
|
|
22565
|
+
}
|
|
22566
|
+
};
|
|
22567
|
+
function validateOrigin(value) {
|
|
22568
|
+
let url2;
|
|
22569
|
+
try {
|
|
22570
|
+
url2 = new URL(value);
|
|
22571
|
+
} catch {
|
|
22572
|
+
throw new ValidationError("origin must be an absolute origin");
|
|
22573
|
+
}
|
|
22574
|
+
if (typeof value !== "string" || /[\s\\?#*]/.test(value) || !/^[a-z][a-z\d+.-]*:\/\/[^/]+\/?$/i.test(value) || url2.username || url2.password || url2.pathname !== "/" || url2.protocol !== "https:" && !(url2.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url2.hostname))) {
|
|
22575
|
+
throw new ValidationError(
|
|
22576
|
+
"origin must use HTTPS (HTTP only for localhost or 127.0.0.1) without path, credentials, query, fragment or wildcard"
|
|
22577
|
+
);
|
|
22578
|
+
}
|
|
22579
|
+
}
|
|
22580
|
+
|
|
22581
|
+
// src/api/resources/envelopes.ts
|
|
22582
|
+
var EnvelopeResource = class extends BaseResource {
|
|
22583
|
+
async list(params = {}, accountId) {
|
|
22584
|
+
const id = this.accountId(accountId);
|
|
22585
|
+
if (params.status !== void 0 && !["open", "closed"].includes(params.status))
|
|
22586
|
+
throw new ValidationError("status must be open or closed");
|
|
22587
|
+
return this.callList(
|
|
22588
|
+
"Failed to list envelopes",
|
|
22589
|
+
() => this.http.get(`/accounts/${id}/envelopes`, { params: cleanParams({ ...params }) })
|
|
22590
|
+
);
|
|
22591
|
+
}
|
|
22592
|
+
/** Creates assignments and sends invitations; persist the result before checking delivery. */
|
|
22593
|
+
async create(payload, options = {}) {
|
|
22594
|
+
const id = this.accountId(options.accountId);
|
|
22595
|
+
validateCreate(payload);
|
|
22596
|
+
const headers = idempotencyHeaders(options.idempotencyKey);
|
|
22597
|
+
return this.call(
|
|
22598
|
+
"Failed to create envelope",
|
|
22599
|
+
() => this.http.post(`/accounts/${id}/envelopes`, payload, { headers })
|
|
22600
|
+
);
|
|
22601
|
+
}
|
|
22602
|
+
async estimateCost(payload, accountId) {
|
|
22603
|
+
const id = this.accountId(accountId);
|
|
22604
|
+
validateCreate(payload);
|
|
22605
|
+
return this.call(
|
|
22606
|
+
"Failed to estimate envelope cost",
|
|
22607
|
+
() => this.http.post(`/accounts/${id}/envelopes/estimate-cost`, payload)
|
|
22608
|
+
);
|
|
22609
|
+
}
|
|
22610
|
+
async get(envelopeId, accountId) {
|
|
22611
|
+
const id = this.accountId(accountId);
|
|
22612
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
22613
|
+
return this.call(
|
|
22614
|
+
"Failed to fetch envelope",
|
|
22615
|
+
() => this.http.get(`/accounts/${id}/envelopes/${eid}`)
|
|
22616
|
+
);
|
|
22617
|
+
}
|
|
22618
|
+
/** Renames, changes the message (null clears), or reorders every current document. */
|
|
22619
|
+
async update(envelopeId, payload, accountId) {
|
|
22620
|
+
const id = this.accountId(accountId);
|
|
22621
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
22622
|
+
if (!payload || !["name", "message", "document_ids"].some(
|
|
22623
|
+
(key) => payload[key] !== void 0
|
|
22624
|
+
))
|
|
22625
|
+
throw new ValidationError("At least one envelope field is required");
|
|
22626
|
+
if (payload.name !== void 0) validateName(payload.name);
|
|
22627
|
+
validateMessage(payload.message);
|
|
22628
|
+
if (payload.document_ids !== void 0) validateIds(payload.document_ids, "document_ids");
|
|
22629
|
+
return this.call(
|
|
22630
|
+
"Failed to update envelope",
|
|
22631
|
+
() => this.http.patch(`/accounts/${id}/envelopes/${eid}`, payload)
|
|
22632
|
+
);
|
|
22633
|
+
}
|
|
22634
|
+
/** Requires a closed envelope; its documents are retained by the server. */
|
|
22635
|
+
async delete(envelopeId, accountId) {
|
|
22636
|
+
const id = this.accountId(accountId);
|
|
22637
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
22638
|
+
return this.call(
|
|
22639
|
+
"Failed to delete envelope",
|
|
22640
|
+
() => this.http.delete(`/accounts/${id}/envelopes/${eid}`)
|
|
22641
|
+
);
|
|
22642
|
+
}
|
|
22643
|
+
async activities(envelopeId, params = {}, accountId) {
|
|
22644
|
+
const id = this.accountId(accountId);
|
|
22645
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
22646
|
+
requireSort(params.sort, ["id", "-id"]);
|
|
22647
|
+
return this.callList(
|
|
22648
|
+
"Failed to fetch envelope activities",
|
|
22649
|
+
() => this.http.get(`/accounts/${id}/envelopes/${eid}/activities`, {
|
|
22650
|
+
params: cleanParams({ ...params })
|
|
22651
|
+
})
|
|
22652
|
+
);
|
|
22653
|
+
}
|
|
22654
|
+
/** ZIP containing the requested artifact of each eligible document. */
|
|
22655
|
+
async download(envelopeId, artifactName = "certificated", accountId) {
|
|
22656
|
+
const id = this.accountId(accountId);
|
|
22657
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
22658
|
+
const artifact = requireDocumentArtifactName(artifactName);
|
|
22659
|
+
return this.callBinary(
|
|
22660
|
+
"Failed to download envelope",
|
|
22661
|
+
() => this.http.get(`/accounts/${id}/envelopes/${eid}/download/${artifact}`, {
|
|
22662
|
+
responseType: "arraybuffer"
|
|
22663
|
+
})
|
|
22664
|
+
);
|
|
22665
|
+
}
|
|
22666
|
+
/** Cancels only cancellable documents and notifies their recipients. */
|
|
22667
|
+
async cancel(envelopeId, accountId) {
|
|
22668
|
+
const id = this.accountId(accountId);
|
|
22669
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
22670
|
+
return this.call(
|
|
22671
|
+
"Failed to cancel envelope",
|
|
22672
|
+
() => this.http.put(`/accounts/${id}/envelopes/${eid}/cancel`)
|
|
22673
|
+
);
|
|
22674
|
+
}
|
|
22675
|
+
async resendNotification(envelopeId, signerId, accountId) {
|
|
22676
|
+
const id = this.accountId(accountId);
|
|
22677
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
22678
|
+
const sid = this.requireId(signerId, "Signer ID");
|
|
22679
|
+
return this.call(
|
|
22680
|
+
"Failed to resend envelope notification",
|
|
22681
|
+
() => this.http.put(`/accounts/${id}/envelopes/${eid}/signers/${sid}/resend`)
|
|
22682
|
+
);
|
|
22683
|
+
}
|
|
22684
|
+
/** Adds a processed document for existing envelope signers and sends updated invitations. */
|
|
22685
|
+
async addDocument(envelopeId, payload, accountId) {
|
|
22686
|
+
const id = this.accountId(accountId);
|
|
22687
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
22688
|
+
validateDocument(payload);
|
|
22689
|
+
validateCreditCeiling(payload.max_total_credits);
|
|
22690
|
+
return this.call(
|
|
22691
|
+
"Failed to add envelope document",
|
|
22692
|
+
() => this.http.post(`/accounts/${id}/envelopes/${eid}/documents`, payload)
|
|
22693
|
+
);
|
|
22694
|
+
}
|
|
22695
|
+
/** Cancels an open document, notifies its recipients, and removes it from the envelope. */
|
|
22696
|
+
async removeDocument(envelopeId, documentId, accountId) {
|
|
22697
|
+
const id = this.accountId(accountId);
|
|
22698
|
+
const eid = this.requireId(envelopeId, "Envelope ID");
|
|
22699
|
+
const did = this.requireId(documentId, "Document ID");
|
|
22700
|
+
return this.call(
|
|
22701
|
+
"Failed to remove envelope document",
|
|
22702
|
+
() => this.http.delete(`/accounts/${id}/envelopes/${eid}/documents/${did}`)
|
|
22703
|
+
);
|
|
22704
|
+
}
|
|
22705
|
+
};
|
|
22706
|
+
function validateName(value) {
|
|
22707
|
+
if (typeof value !== "string" || !value.trim() || [...value].length > 255 || value.includes("<"))
|
|
22708
|
+
throw new ValidationError("name must contain 1\u2013255 characters without <");
|
|
22709
|
+
}
|
|
22710
|
+
function validateMessage(value) {
|
|
22711
|
+
if (value != null && typeof value !== "string")
|
|
22712
|
+
throw new ValidationError("message must be text or null");
|
|
22713
|
+
}
|
|
22714
|
+
function validateIds(values, name) {
|
|
22715
|
+
if (!Array.isArray(values) || !values.length || values.some((id) => typeof id !== "string" || !id.trim()) || new Set(values).size !== values.length)
|
|
22716
|
+
throw new ValidationError(`${name} must contain distinct nonblank IDs`);
|
|
22717
|
+
}
|
|
22718
|
+
function validateDocument(payload) {
|
|
22719
|
+
if (!payload || typeof payload.id !== "string" || !payload.id.trim())
|
|
22720
|
+
throw new ValidationError("Document ID is required");
|
|
22721
|
+
validateIds(payload.signer_ids, "signer_ids");
|
|
22722
|
+
if (payload.method !== void 0 && !["virtual", "collect"].includes(payload.method))
|
|
22723
|
+
throw new ValidationError("method must be virtual or collect");
|
|
22724
|
+
if (payload.method === "collect" && (!Array.isArray(payload.entries) || !payload.entries.length))
|
|
22725
|
+
throw new ValidationError("entries are required for collect documents");
|
|
22726
|
+
if (payload.expires_at != null && typeof payload.expires_at !== "string" && (typeof payload.expires_at !== "number" || !Number.isFinite(payload.expires_at)))
|
|
22727
|
+
throw new ValidationError("expires_at must be a date string, Unix time or null");
|
|
22728
|
+
if (payload.copy_receiver_ids !== void 0 && (!Array.isArray(payload.copy_receiver_ids) || payload.copy_receiver_ids.some((id) => typeof id !== "string" || !id.trim())))
|
|
22729
|
+
throw new ValidationError("copy_receiver_ids must contain nonblank IDs");
|
|
22730
|
+
}
|
|
22731
|
+
function validateCreate(payload) {
|
|
22732
|
+
if (!payload) throw new ValidationError("Envelope payload is required");
|
|
22733
|
+
validateName(payload.name);
|
|
22734
|
+
validateMessage(payload.message);
|
|
22735
|
+
validateCreditCeiling(payload.max_total_credits);
|
|
22736
|
+
if (!Array.isArray(payload.signers) || !payload.signers.length || payload.signers.length > 20 || payload.signers.some((s) => !s || typeof s !== "object"))
|
|
22737
|
+
throw new ValidationError("signers must contain 1\u201320 signers");
|
|
22738
|
+
validateIds(
|
|
22739
|
+
payload.signers.map((s) => s.id),
|
|
22740
|
+
"signers"
|
|
22741
|
+
);
|
|
22742
|
+
for (const signer of payload.signers) {
|
|
22743
|
+
if ("step" in signer) throw new ValidationError("Envelope signers do not accept step");
|
|
22744
|
+
validateSignerOptions(signer);
|
|
22745
|
+
}
|
|
22746
|
+
if (!Array.isArray(payload.documents) || !payload.documents.length || payload.documents.length > 20)
|
|
22747
|
+
throw new ValidationError("documents must contain 1\u201320 documents");
|
|
22748
|
+
for (const document2 of payload.documents) {
|
|
22749
|
+
validateDocument(document2);
|
|
22750
|
+
const signers = document2.signer_ids.map((id) => payload.signers.find((s) => s.id === id));
|
|
22751
|
+
if (signers.some((s) => !s))
|
|
22752
|
+
throw new ValidationError("Every document signer must be listed in signers");
|
|
22753
|
+
const assigned = signers.filter((s) => s !== void 0);
|
|
22754
|
+
validateDigitalCertificateMethod(document2.method ?? "virtual", assigned);
|
|
22755
|
+
if (assigned.length > 1 && assigned.some((s) => s.verification_method === "DigitalCertificate"))
|
|
22756
|
+
throw new ValidationError(
|
|
22757
|
+
"A DigitalCertificate signer must be alone on each envelope document"
|
|
22758
|
+
);
|
|
22759
|
+
}
|
|
22760
|
+
validateIds(
|
|
22761
|
+
payload.documents.map((d) => d.id),
|
|
22762
|
+
"documents"
|
|
22763
|
+
);
|
|
22764
|
+
if (payload.signers.some((s) => !payload.documents.some((d) => d.signer_ids.includes(s.id))))
|
|
22765
|
+
throw new ValidationError("Every signer must belong to at least one document");
|
|
22766
|
+
}
|
|
22767
|
+
|
|
22443
22768
|
// src/api/resources/fields.ts
|
|
22444
22769
|
var FieldsResource = class extends BaseResource {
|
|
22445
22770
|
/** Create a field definition. */
|
|
@@ -22757,12 +23082,12 @@ function httpsUrl(value, name) {
|
|
|
22757
23082
|
// src/api/resources/signer-documents.ts
|
|
22758
23083
|
var SignerDocumentsResource = class extends BaseResource {
|
|
22759
23084
|
/** `GET /signers/{signer_id}/document?signer-access-code=…` */
|
|
22760
|
-
async getCurrent(signerId, signerAccessCode) {
|
|
23085
|
+
async getCurrent(signerId, signerAccessCode, params = {}) {
|
|
22761
23086
|
const sid = this.requireId(signerId, "Signer ID");
|
|
22762
23087
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22763
23088
|
return this.call(
|
|
22764
23089
|
"Failed to fetch current signer document",
|
|
22765
|
-
() => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code))
|
|
23090
|
+
() => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code, params))
|
|
22766
23091
|
);
|
|
22767
23092
|
}
|
|
22768
23093
|
/** `GET /signers/{signer_id}/documents?signer-access-code=…` */
|
|
@@ -22779,17 +23104,17 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
22779
23104
|
return this.listDocuments(signerId, { params: cleanParams({ ...params }) });
|
|
22780
23105
|
}
|
|
22781
23106
|
/** `GET /signers/{signer_id}/documents/search?search=…&signer-access-code=…` */
|
|
22782
|
-
async search(signerId, search, signerAccessCode) {
|
|
23107
|
+
async search(signerId, search, signerAccessCode, params = {}) {
|
|
22783
23108
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22784
|
-
return this.searchDocuments(signerId, signerAccessConfig(code, { search }));
|
|
23109
|
+
return this.searchDocuments(signerId, signerAccessConfig(code, { ...params, search }));
|
|
22785
23110
|
}
|
|
22786
23111
|
/**
|
|
22787
23112
|
* `GET /signers/{signer_id}/documents/search?search=…` with the client's owner
|
|
22788
23113
|
* credentials instead of a signer access code. The signer must belong to that
|
|
22789
23114
|
* workspace.
|
|
22790
23115
|
*/
|
|
22791
|
-
async searchAsOwner(signerId, search) {
|
|
22792
|
-
return this.searchDocuments(signerId, { params: cleanParams({ search }) });
|
|
23116
|
+
async searchAsOwner(signerId, search, params = {}) {
|
|
23117
|
+
return this.searchDocuments(signerId, { params: cleanParams({ ...params, search }) });
|
|
22793
23118
|
}
|
|
22794
23119
|
listDocuments(signerId, config) {
|
|
22795
23120
|
const sid = this.requireId(signerId, "Signer ID");
|
|
@@ -22806,9 +23131,9 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
22806
23131
|
);
|
|
22807
23132
|
}
|
|
22808
23133
|
/**
|
|
22809
|
-
*
|
|
22810
|
-
*
|
|
22811
|
-
*
|
|
23134
|
+
* `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`.
|
|
23135
|
+
* The current API permits only originals with a signer code. Other forms are
|
|
23136
|
+
* retained for compatibility; use downloadCertifiedCopy for completed PDFs.
|
|
22812
23137
|
*/
|
|
22813
23138
|
async download(signerId, documentId, artifactName, signerAccessCode) {
|
|
22814
23139
|
const sid = this.requireId(signerId, "Signer ID");
|
|
@@ -22922,13 +23247,16 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
22922
23247
|
* Returns `{ token }` for the signer's Web PKI client. This production route
|
|
22923
23248
|
* is used by Assinafy's signing frontend but is absent from OpenAPI paths.
|
|
22924
23249
|
*/
|
|
22925
|
-
async startCertificate(signerAccessCode) {
|
|
23250
|
+
async startCertificate(signerAccessCode, documentId) {
|
|
22926
23251
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22927
23252
|
return this.call(
|
|
22928
23253
|
"Failed to start certificate signature",
|
|
22929
23254
|
() => this.http.post(
|
|
22930
23255
|
"/signers/certificate/start",
|
|
22931
|
-
{
|
|
23256
|
+
{
|
|
23257
|
+
"signer-access-code": code,
|
|
23258
|
+
...documentId === void 0 ? {} : { document_id: this.requireId(documentId, "Document ID") }
|
|
23259
|
+
},
|
|
22932
23260
|
signerAccessConfig(code)
|
|
22933
23261
|
)
|
|
22934
23262
|
);
|
|
@@ -22939,7 +23267,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
22939
23267
|
* successfully signs it. Returns `{ signerName }`; private keys stay local.
|
|
22940
23268
|
* This production route is absent from OpenAPI paths.
|
|
22941
23269
|
*/
|
|
22942
|
-
async completeCertificate(signerAccessCode, token) {
|
|
23270
|
+
async completeCertificate(signerAccessCode, token, documentId) {
|
|
22943
23271
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
22944
23272
|
if (typeof token !== "string" || !token.trim()) {
|
|
22945
23273
|
throw new ValidationError("Certificate token is required");
|
|
@@ -22948,7 +23276,11 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
22948
23276
|
"Failed to complete certificate signature",
|
|
22949
23277
|
() => this.http.post(
|
|
22950
23278
|
"/signers/certificate/complete",
|
|
22951
|
-
{
|
|
23279
|
+
{
|
|
23280
|
+
"signer-access-code": code,
|
|
23281
|
+
token,
|
|
23282
|
+
...documentId === void 0 ? {} : { document_id: this.requireId(documentId, "Document ID") }
|
|
23283
|
+
},
|
|
22952
23284
|
signerAccessConfig(code)
|
|
22953
23285
|
)
|
|
22954
23286
|
);
|
|
@@ -23013,11 +23345,15 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
23013
23345
|
);
|
|
23014
23346
|
}
|
|
23015
23347
|
/** `GET /sign?signer-access-code=…` — fetch the assignment as the signer sees it. */
|
|
23016
|
-
async getAssignment(signerAccessCode, hasAcceptedTerms) {
|
|
23348
|
+
async getAssignment(signerAccessCode, hasAcceptedTerms, params = {}) {
|
|
23017
23349
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
23350
|
+
if (params.document_id !== void 0) this.requireId(params.document_id, "Document ID");
|
|
23018
23351
|
return this.call(
|
|
23019
23352
|
"Failed to fetch signer assignment",
|
|
23020
|
-
() => this.http.get(
|
|
23353
|
+
() => this.http.get(
|
|
23354
|
+
"/sign",
|
|
23355
|
+
signerAccessConfig(code, { ...params, has_accepted_terms: hasAcceptedTerms })
|
|
23356
|
+
)
|
|
23021
23357
|
);
|
|
23022
23358
|
}
|
|
23023
23359
|
/**
|
|
@@ -23060,12 +23396,59 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
23060
23396
|
);
|
|
23061
23397
|
}
|
|
23062
23398
|
async requireDocumentAccess(documentId, signerAccessCode, assignmentId) {
|
|
23063
|
-
const document2 = await this.
|
|
23399
|
+
const document2 = assignmentId === void 0 ? await this.call(
|
|
23400
|
+
"Failed to fetch signer document",
|
|
23401
|
+
() => this.http.get(`/documents/${documentId}`, signerAccessConfig(signerAccessCode))
|
|
23402
|
+
) : await this.getAssignment(signerAccessCode, void 0, { document_id: documentId });
|
|
23064
23403
|
if (document2.id !== documentId || assignmentId !== void 0 && document2.assignment?.id !== assignmentId) {
|
|
23065
23404
|
throw new ValidationError("Signer access code does not match the document or assignment");
|
|
23066
23405
|
}
|
|
23067
23406
|
return document2;
|
|
23068
23407
|
}
|
|
23408
|
+
async getTheme(signerAccessCode) {
|
|
23409
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
23410
|
+
return this.call(
|
|
23411
|
+
"Failed to fetch signing theme",
|
|
23412
|
+
() => this.http.get("/sign/theme", signerAccessConfig(code))
|
|
23413
|
+
);
|
|
23414
|
+
}
|
|
23415
|
+
async downloadLogo(signerAccessCode) {
|
|
23416
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
23417
|
+
return this.callBinary(
|
|
23418
|
+
"Failed to download signing logo",
|
|
23419
|
+
() => this.http.get("/sign/logo", {
|
|
23420
|
+
...signerAccessConfig(code),
|
|
23421
|
+
responseType: "arraybuffer"
|
|
23422
|
+
})
|
|
23423
|
+
);
|
|
23424
|
+
}
|
|
23425
|
+
/** Sends a time-limited download link to the original signing contact. */
|
|
23426
|
+
async resendCertifiedCopy(signerAccessCode, documentId) {
|
|
23427
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
23428
|
+
const body = documentId === void 0 ? void 0 : { document_id: this.requireId(documentId, "Document ID") };
|
|
23429
|
+
return this.call(
|
|
23430
|
+
"Failed to send certified copy",
|
|
23431
|
+
() => this.http.post("/sign/certified-copy", body, signerAccessConfig(code))
|
|
23432
|
+
);
|
|
23433
|
+
}
|
|
23434
|
+
/** Expired tokens return an ApiError (302); redirects remain disabled. */
|
|
23435
|
+
async downloadCertifiedCopy(token, artifact = "certificated") {
|
|
23436
|
+
const value = this.requireId(token, "Download token");
|
|
23437
|
+
if (!["certificated", "pades"].includes(artifact))
|
|
23438
|
+
throw new ValidationError("artifact must be certificated or pades");
|
|
23439
|
+
const config = { ...publicRequestConfig(), responseType: "arraybuffer" };
|
|
23440
|
+
return this.callBinary(
|
|
23441
|
+
"Failed to download certified copy",
|
|
23442
|
+
() => artifact === "pades" ? this.http.get(`/signers/downloads/${value}/pades`, config) : this.http.get(`/signers/downloads/${value}`, config)
|
|
23443
|
+
);
|
|
23444
|
+
}
|
|
23445
|
+
async resendDownloadLink(token) {
|
|
23446
|
+
const value = this.requireId(token, "Download token");
|
|
23447
|
+
return this.call(
|
|
23448
|
+
"Failed to resend download link",
|
|
23449
|
+
() => this.http.post(`/signers/downloads/${value}/resend`, void 0, publicRequestConfig())
|
|
23450
|
+
);
|
|
23451
|
+
}
|
|
23069
23452
|
};
|
|
23070
23453
|
function validateDeclineReason(value) {
|
|
23071
23454
|
if (typeof value !== "string" || !value.trim()) {
|
|
@@ -23138,14 +23521,14 @@ var SignerResource = class extends BaseResource {
|
|
|
23138
23521
|
})
|
|
23139
23522
|
);
|
|
23140
23523
|
}
|
|
23141
|
-
/** Update
|
|
23524
|
+
/** Update supplied fields; verified channels on in-flight documents cannot change. */
|
|
23142
23525
|
async update(signerId, payload, accountId) {
|
|
23143
23526
|
const id = this.accountId(accountId);
|
|
23144
23527
|
const sid = this.requireId(signerId, "Signer ID");
|
|
23145
23528
|
if (payload.full_name !== void 0 && !payload.full_name.trim()) {
|
|
23146
23529
|
throw new ValidationError("Signer full name cannot be blank");
|
|
23147
23530
|
}
|
|
23148
|
-
if (payload.email !==
|
|
23531
|
+
if (payload.email != null && payload.email !== "") requireEmail(payload.email);
|
|
23149
23532
|
return this.call(
|
|
23150
23533
|
"Failed to update signer",
|
|
23151
23534
|
() => this.http.put(`/accounts/${id}/signers/${sid}`, normaliseSignerPayload(payload, true))
|
|
@@ -23166,13 +23549,13 @@ var SignerResource = class extends BaseResource {
|
|
|
23166
23549
|
try {
|
|
23167
23550
|
const lower = email.toLowerCase();
|
|
23168
23551
|
for (let page = 1; page <= MAX_SEARCH_PAGES; page++) {
|
|
23169
|
-
const { data, meta } = await this.list({ search: email, per_page:
|
|
23552
|
+
const { data, meta } = await this.list({ search: email, per_page: 50, page }, accountId);
|
|
23170
23553
|
const match = data.find((s) => (s.email ?? "").toLowerCase() === lower);
|
|
23171
23554
|
if (match) return match;
|
|
23172
23555
|
if (!data.length) return null;
|
|
23173
23556
|
if (meta?.last_page !== void 0) {
|
|
23174
23557
|
if (page >= meta.last_page) return null;
|
|
23175
|
-
} else if (data.length <
|
|
23558
|
+
} else if (data.length < 50) {
|
|
23176
23559
|
return null;
|
|
23177
23560
|
}
|
|
23178
23561
|
}
|
|
@@ -23190,7 +23573,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
|
23190
23573
|
const normalised = {
|
|
23191
23574
|
full_name: payload.full_name,
|
|
23192
23575
|
email: payload.email,
|
|
23193
|
-
whatsapp_phone_number: payload.whatsapp_phone_number
|
|
23576
|
+
whatsapp_phone_number: payload.whatsapp_phone_number !== void 0 ? payload.whatsapp_phone_number : payload.phone
|
|
23194
23577
|
};
|
|
23195
23578
|
if (payload.government_id !== void 0) {
|
|
23196
23579
|
normalised.government_id = payload.government_id;
|
|
@@ -23201,7 +23584,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
|
23201
23584
|
if ("metadata" in payload && payload.metadata !== void 0) {
|
|
23202
23585
|
normalised.metadata = payload.metadata;
|
|
23203
23586
|
}
|
|
23204
|
-
return stripEmpty(normalised);
|
|
23587
|
+
return useGovernmentId ? Object.fromEntries(Object.entries(normalised).filter(([, value]) => value !== void 0)) : stripEmpty(normalised);
|
|
23205
23588
|
}
|
|
23206
23589
|
|
|
23207
23590
|
// src/api/resources/tags.ts
|
|
@@ -23303,6 +23686,16 @@ var TemplateResource = class extends BaseResource {
|
|
|
23303
23686
|
};
|
|
23304
23687
|
|
|
23305
23688
|
// src/api/types.ts
|
|
23689
|
+
var PUSH_PREFERENCE_CODES = [
|
|
23690
|
+
"SignerViewed",
|
|
23691
|
+
"SignerSigned",
|
|
23692
|
+
"DocumentCompleted",
|
|
23693
|
+
"SignerDeclined",
|
|
23694
|
+
"DocumentAboutToExpire",
|
|
23695
|
+
"DocumentExpired",
|
|
23696
|
+
"SignerIdentityReviewRequired",
|
|
23697
|
+
"SignerWhatsappFailed"
|
|
23698
|
+
];
|
|
23306
23699
|
var NOTIFICATION_PREFERENCE_CODES = [
|
|
23307
23700
|
"DocumentCompleted",
|
|
23308
23701
|
"SignerDeclined",
|
|
@@ -23320,7 +23713,6 @@ var NOTIFICATION_PREFERENCE_CODES = [
|
|
|
23320
23713
|
];
|
|
23321
23714
|
|
|
23322
23715
|
// src/api/resources/users.ts
|
|
23323
|
-
var NOTIFICATION_PREFERENCES = new Set(NOTIFICATION_PREFERENCE_CODES);
|
|
23324
23716
|
var UsersResource = class extends BaseResource {
|
|
23325
23717
|
/** Fetch the authenticated user's profile. */
|
|
23326
23718
|
async self() {
|
|
@@ -23342,26 +23734,25 @@ var UsersResource = class extends BaseResource {
|
|
|
23342
23734
|
}
|
|
23343
23735
|
/** Merge one or more owner-facing email notification preferences. */
|
|
23344
23736
|
async updateNotificationPreferences(payload) {
|
|
23345
|
-
|
|
23346
|
-
throw new ValidationError("Notification preferences must be an object");
|
|
23347
|
-
}
|
|
23348
|
-
const entries = Object.entries(payload);
|
|
23349
|
-
if (entries.length === 0) {
|
|
23350
|
-
throw new ValidationError("At least one notification preference is required");
|
|
23351
|
-
}
|
|
23352
|
-
for (const [key, value] of entries) {
|
|
23353
|
-
if (!NOTIFICATION_PREFERENCES.has(key)) {
|
|
23354
|
-
throw new ValidationError(`Unknown notification preference: ${key}`);
|
|
23355
|
-
}
|
|
23356
|
-
if (typeof value !== "boolean") {
|
|
23357
|
-
throw new ValidationError(`${key} must be a boolean`);
|
|
23358
|
-
}
|
|
23359
|
-
}
|
|
23737
|
+
validateBooleanMap(payload, NOTIFICATION_PREFERENCE_CODES);
|
|
23360
23738
|
return this.call(
|
|
23361
23739
|
"Failed to update notification preferences",
|
|
23362
23740
|
() => this.http.put("/users/self/notification-preferences", payload)
|
|
23363
23741
|
);
|
|
23364
23742
|
}
|
|
23743
|
+
async getPushPreferences() {
|
|
23744
|
+
return this.call(
|
|
23745
|
+
"Failed to fetch push preferences",
|
|
23746
|
+
() => this.http.get("/users/self/push-preferences")
|
|
23747
|
+
);
|
|
23748
|
+
}
|
|
23749
|
+
async updatePushPreferences(payload) {
|
|
23750
|
+
validateBooleanMap(payload, PUSH_PREFERENCE_CODES);
|
|
23751
|
+
return this.call(
|
|
23752
|
+
"Failed to update push preferences",
|
|
23753
|
+
() => this.http.put("/users/self/push-preferences", payload)
|
|
23754
|
+
);
|
|
23755
|
+
}
|
|
23365
23756
|
};
|
|
23366
23757
|
|
|
23367
23758
|
// src/api/resources/webhooks.ts
|
|
@@ -23401,6 +23792,15 @@ function validateWebhookFields(payload, requireHttps = false) {
|
|
|
23401
23792
|
}
|
|
23402
23793
|
}
|
|
23403
23794
|
var WebhookResource = class extends BaseResource {
|
|
23795
|
+
/** Sends a webhook_test even to an inactive/held endpoint; does not change its state. */
|
|
23796
|
+
async testEndpoint(endpointId, accountId) {
|
|
23797
|
+
const id = this.accountId(accountId);
|
|
23798
|
+
const eid = this.requireId(endpointId, "Endpoint ID");
|
|
23799
|
+
return this.call(
|
|
23800
|
+
"Failed to send webhook test",
|
|
23801
|
+
() => this.http.post(`/accounts/${id}/webhooks/endpoints/${eid}/test`)
|
|
23802
|
+
);
|
|
23803
|
+
}
|
|
23404
23804
|
/**
|
|
23405
23805
|
* `PUT /accounts/{accountId}/webhooks/subscriptions` — create or replace the
|
|
23406
23806
|
* account's oldest webhook endpoint. Use the endpoint methods for accounts
|
|
@@ -23528,15 +23928,21 @@ var WebhookResource = class extends BaseResource {
|
|
|
23528
23928
|
}
|
|
23529
23929
|
/**
|
|
23530
23930
|
* `POST …/endpoints/{endpointId}/secret/rotate` — replace the signing secret.
|
|
23531
|
-
*
|
|
23931
|
+
* Set keep_previous to retain the replaced secret for 24 hours. Requires webhooks:write.
|
|
23532
23932
|
*/
|
|
23533
|
-
async rotateEndpointSecret(endpointId, accountId) {
|
|
23933
|
+
async rotateEndpointSecret(endpointId, accountId, options = {}) {
|
|
23534
23934
|
const id = this.accountId(accountId);
|
|
23535
23935
|
const eid = this.requireId(endpointId, "Endpoint ID");
|
|
23936
|
+
if (options.keep_previous !== void 0 && typeof options.keep_previous !== "boolean") {
|
|
23937
|
+
throw new ValidationError("keep_previous must be a boolean");
|
|
23938
|
+
}
|
|
23536
23939
|
this.logger.info("Rotating webhook endpoint secret");
|
|
23537
23940
|
return this.call(
|
|
23538
23941
|
"Failed to rotate webhook endpoint secret",
|
|
23539
|
-
() => this.http.post(
|
|
23942
|
+
() => this.http.post(
|
|
23943
|
+
`/accounts/${id}/webhooks/endpoints/${eid}/secret/rotate`,
|
|
23944
|
+
options.keep_previous === void 0 ? void 0 : { keep_previous: options.keep_previous }
|
|
23945
|
+
)
|
|
23540
23946
|
);
|
|
23541
23947
|
}
|
|
23542
23948
|
/** List currently supported webhook event types. */
|
|
@@ -23587,9 +23993,46 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
23587
23993
|
);
|
|
23588
23994
|
}
|
|
23589
23995
|
/** Fetch a single workspace. */
|
|
23590
|
-
async get(accountId) {
|
|
23996
|
+
async get(accountId, params = {}) {
|
|
23997
|
+
const id = this.requireId(accountId, "Account ID");
|
|
23998
|
+
return this.call(
|
|
23999
|
+
"Failed to fetch workspace",
|
|
24000
|
+
() => this.http.get(`/accounts/${id}`, { params })
|
|
24001
|
+
);
|
|
24002
|
+
}
|
|
24003
|
+
/** Plan allowance and balances; unavailable to third-party OAuth applications. */
|
|
24004
|
+
async usage(accountId) {
|
|
24005
|
+
const id = this.requireId(accountId, "Account ID");
|
|
24006
|
+
return this.call(
|
|
24007
|
+
"Failed to fetch workspace usage",
|
|
24008
|
+
() => this.http.get(`/accounts/${id}/usage`)
|
|
24009
|
+
);
|
|
24010
|
+
}
|
|
24011
|
+
async getNotificationPolicy(accountId) {
|
|
23591
24012
|
const id = this.requireId(accountId, "Account ID");
|
|
23592
|
-
return this.call(
|
|
24013
|
+
return this.call(
|
|
24014
|
+
"Failed to fetch notification policy",
|
|
24015
|
+
() => this.http.get(`/accounts/${id}/notification-policy`)
|
|
24016
|
+
);
|
|
24017
|
+
}
|
|
24018
|
+
/** Owner-only partial merge; false disables the alert workspace-wide. */
|
|
24019
|
+
async updateNotificationPolicy(accountId, payload) {
|
|
24020
|
+
const id = this.requireId(accountId, "Account ID");
|
|
24021
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload) || !Object.keys(payload).length || Object.keys(payload).some((key) => !["events", "owners_receive_all"].includes(key)))
|
|
24022
|
+
throw new ValidationError("Provide events and/or owners_receive_all");
|
|
24023
|
+
if (payload.owners_receive_all !== void 0 && typeof payload.owners_receive_all !== "boolean")
|
|
24024
|
+
throw new ValidationError("owners_receive_all must be a boolean");
|
|
24025
|
+
if (payload.events !== void 0)
|
|
24026
|
+
validateBooleanMap(payload.events, [
|
|
24027
|
+
...NOTIFICATION_PREFERENCE_CODES,
|
|
24028
|
+
...PUSH_PREFERENCE_CODES
|
|
24029
|
+
]);
|
|
24030
|
+
if (payload.events === void 0 && payload.owners_receive_all === void 0)
|
|
24031
|
+
throw new ValidationError("At least one notification policy field is required");
|
|
24032
|
+
return this.call(
|
|
24033
|
+
"Failed to update notification policy",
|
|
24034
|
+
() => this.http.put(`/accounts/${id}/notification-policy`, payload)
|
|
24035
|
+
);
|
|
23593
24036
|
}
|
|
23594
24037
|
/** Fetch the workspace's public branding theme. */
|
|
23595
24038
|
async getTheme(accountId) {
|
|
@@ -23790,6 +24233,8 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
23790
24233
|
auth;
|
|
23791
24234
|
oauth;
|
|
23792
24235
|
fields;
|
|
24236
|
+
envelopes;
|
|
24237
|
+
embed;
|
|
23793
24238
|
users;
|
|
23794
24239
|
signerDocuments;
|
|
23795
24240
|
webhookVerifier;
|
|
@@ -23861,6 +24306,8 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
23861
24306
|
this.auth = new AuthenticationResource(this.axiosInstance, void 0, this.logger);
|
|
23862
24307
|
this.oauth = new OAuthResource(this.axiosInstance, void 0, this.logger);
|
|
23863
24308
|
this.fields = new FieldsResource(this.axiosInstance, this.defaultAccountId, this.logger);
|
|
24309
|
+
this.envelopes = new EnvelopeResource(this.axiosInstance, this.defaultAccountId, this.logger);
|
|
24310
|
+
this.embed = new EmbedResource(this.axiosInstance, this.defaultAccountId, this.logger);
|
|
23864
24311
|
this.users = new UsersResource(this.axiosInstance, void 0, this.logger);
|
|
23865
24312
|
this.signerDocuments = new SignerDocumentsResource(
|
|
23866
24313
|
this.axiosInstance,
|
|
@@ -23906,6 +24353,7 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
23906
24353
|
throw new ValidationError("At least one signer is required");
|
|
23907
24354
|
}
|
|
23908
24355
|
if (options.expiresAt !== void 0) requireExpiration(options.expiresAt, "expiresAt");
|
|
24356
|
+
validateCreditCeiling(options.maxTotalCredits);
|
|
23909
24357
|
const preparedSigners = options.signers.map((signer) => {
|
|
23910
24358
|
if (!signer || typeof signer !== "object") {
|
|
23911
24359
|
throw new ValidationError("Each signer must be an object");
|
|
@@ -23922,7 +24370,8 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
23922
24370
|
const reference = {
|
|
23923
24371
|
verification_method: signer.verification_method ?? (useWhatsapp ? "Whatsapp" : void 0),
|
|
23924
24372
|
notification_methods: signer.notification_methods ?? (useWhatsapp ? ["Whatsapp"] : void 0),
|
|
23925
|
-
step: signer.step
|
|
24373
|
+
step: signer.step,
|
|
24374
|
+
embedded: signer.embedded
|
|
23926
24375
|
};
|
|
23927
24376
|
validateSignerOptions(reference);
|
|
23928
24377
|
return { reference, payload };
|
|
@@ -23951,7 +24400,8 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
23951
24400
|
}
|
|
23952
24401
|
const assignmentPayload = {
|
|
23953
24402
|
method: "virtual",
|
|
23954
|
-
signers: assignmentSigners
|
|
24403
|
+
signers: assignmentSigners,
|
|
24404
|
+
max_total_credits: options.maxTotalCredits
|
|
23955
24405
|
};
|
|
23956
24406
|
if (options.message !== void 0) assignmentPayload.message = options.message;
|
|
23957
24407
|
if (options.expiresAt !== void 0) assignmentPayload.expires_at = options.expiresAt;
|
|
@@ -25203,6 +25653,13 @@ async function saveDownload(config, options) {
|
|
|
25203
25653
|
}
|
|
25204
25654
|
|
|
25205
25655
|
// src/lib/json.ts
|
|
25656
|
+
function parseCreditCeiling(raw) {
|
|
25657
|
+
if (raw === void 0) return void 0;
|
|
25658
|
+
if (!raw.trim()) throw new CliError("--max-total-credits must be a non-negative number.");
|
|
25659
|
+
const value = Number(raw);
|
|
25660
|
+
validateCreditCeiling(value);
|
|
25661
|
+
return value;
|
|
25662
|
+
}
|
|
25206
25663
|
function parseJsonObject(raw, flag) {
|
|
25207
25664
|
if (raw === void 0) return void 0;
|
|
25208
25665
|
let parsed;
|
|
@@ -25609,14 +26066,15 @@ var createCommand = addSignerRefOptions(
|
|
|
25609
26066
|
new Command("create").description("Create a signing assignment for a document").argument("<documentId>", "Document ID")
|
|
25610
26067
|
).addOption(
|
|
25611
26068
|
new Option("--method <method>", "virtual or collect").choices(["virtual", "collect"]).default("virtual")
|
|
25612
|
-
).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(
|
|
26069
|
+
).option("--message <message>", "Message shown to signers").option("--max-total-credits <amount>", "Reject the send if its credit cost exceeds this amount").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").option(
|
|
25613
26070
|
"--entries <json>",
|
|
25614
26071
|
`JSON array of field placement entries, required for --method collect (e.g. '[{"page_id":"p1","fields":[{"signer_id":"s1","field_id":"f1"}]}]')`
|
|
25615
26072
|
).action(async (documentId, opts, command) => {
|
|
25616
26073
|
await runWithClient(command, async ({ client, config }) => {
|
|
25617
26074
|
const payload = {
|
|
25618
26075
|
method: opts.method,
|
|
25619
|
-
signers: resolveAssignmentSignerRefs(opts.signers, opts.signerIds)
|
|
26076
|
+
signers: resolveAssignmentSignerRefs(opts.signers, opts.signerIds),
|
|
26077
|
+
max_total_credits: parseCreditCeiling(opts.maxTotalCredits)
|
|
25620
26078
|
};
|
|
25621
26079
|
if (opts.message) payload.message = opts.message;
|
|
25622
26080
|
if (opts.expiresAt) payload.expires_at = opts.expiresAt;
|
|
@@ -26236,9 +26694,16 @@ var setCommand2 = new Command("set").description("Set terms or link an amendment
|
|
|
26236
26694
|
printData(await client.contracts.set(documentId, payload, requireAccountId(config)), config);
|
|
26237
26695
|
});
|
|
26238
26696
|
});
|
|
26239
|
-
var relatedCommand = new Command("related").description("Read the root contract and every linked instrument").argument("<documentId>", "Contract or amendment document ID").
|
|
26697
|
+
var relatedCommand = new Command("related").description("Read the root contract and every linked instrument").argument("<documentId>", "Contract or amendment document ID").addOption(
|
|
26698
|
+
new Option("--expand <relation>", "Include document details").choices(["document"])
|
|
26699
|
+
).action(async (documentId, opts, command) => {
|
|
26240
26700
|
await runWithClient(command, async ({ client, config }) => {
|
|
26241
|
-
printData(
|
|
26701
|
+
printData(
|
|
26702
|
+
await client.contracts.related(documentId, requireAccountId(config), {
|
|
26703
|
+
expand: opts.expand
|
|
26704
|
+
}),
|
|
26705
|
+
config
|
|
26706
|
+
);
|
|
26242
26707
|
});
|
|
26243
26708
|
});
|
|
26244
26709
|
var renewCommand = new Command("renew").description("Start the next term using the current term or a later end_date").argument("<documentId>", "Document ID").requiredOption("--data <json>", "JSON with term or end_date, optional value and updated_at").option("-y, --yes", "Skip confirmation").action(async (documentId, opts, command) => {
|
|
@@ -26268,7 +26733,7 @@ var contractsCommand = new Command("contracts").description("Track contract term
|
|
|
26268
26733
|
var import_node_child_process2 = require("child_process");
|
|
26269
26734
|
var import_node_crypto4 = require("crypto");
|
|
26270
26735
|
var import_node_events2 = require("events");
|
|
26271
|
-
var
|
|
26736
|
+
var import_node_http2 = require("http");
|
|
26272
26737
|
var CLI_OAUTH_REDIRECT_URI = "https://integrations.assinafy.com.br/assinafy-cli/oauth-callback";
|
|
26273
26738
|
var clearHistory = "history.replaceState(null, '', '/');";
|
|
26274
26739
|
var brandOrigin = "https://integrations.assinafy.com.br";
|
|
@@ -26371,7 +26836,7 @@ async function connectOAuth(oauth, options, onAuthorize, timeoutMs = 18e4) {
|
|
|
26371
26836
|
if (new URL(request.redirect_uri).search) {
|
|
26372
26837
|
throw new CliError("The browser relay redirect URI must not contain query parameters.");
|
|
26373
26838
|
}
|
|
26374
|
-
const server = (0,
|
|
26839
|
+
const server = (0, import_node_http2.createServer)({ maxHeaderSize: 8192, requestTimeout: 5e3, headersTimeout: 5e3 });
|
|
26375
26840
|
server.maxConnections = 8;
|
|
26376
26841
|
server.setTimeout(5e3, (socket) => socket.destroy());
|
|
26377
26842
|
let timer;
|
|
@@ -26496,11 +26961,11 @@ var listCommand4 = addListOptions(
|
|
|
26496
26961
|
"virtual",
|
|
26497
26962
|
"collect"
|
|
26498
26963
|
])
|
|
26499
|
-
).option("--tags <ids>", "Comma-separated tag IDs (AND semantics)")
|
|
26964
|
+
).option("--tags <ids>", "Comma-separated tag IDs (AND semantics)").option("--envelope <id>", "Filter by envelope ID")
|
|
26500
26965
|
).action(async (opts, command) => {
|
|
26501
26966
|
await runWithClient(command, async ({ client, config }) => {
|
|
26502
26967
|
const accountId = requireAccountId(config);
|
|
26503
|
-
const params = { ...listParams(opts) };
|
|
26968
|
+
const params = { ...listParams(opts), envelope_id: opts.envelope };
|
|
26504
26969
|
if (opts.status) params.status = opts.status;
|
|
26505
26970
|
if (opts.method) params.method = opts.method;
|
|
26506
26971
|
if (opts.tags) params.tags = opts.tags;
|
|
@@ -26513,11 +26978,11 @@ var listCommand4 = addListOptions(
|
|
|
26513
26978
|
});
|
|
26514
26979
|
});
|
|
26515
26980
|
var searchCommand = addListOptions(
|
|
26516
|
-
new Command("search").description("Lightweight document search (type-ahead)").argument("[query]", "Search text (alias for --search)").option("--status <status>", "Filter by document status")
|
|
26981
|
+
new Command("search").description("Lightweight document search (type-ahead)").argument("[query]", "Search text (alias for --search)").option("--status <status>", "Filter by document status").option("--envelope <id>", "Filter by envelope ID")
|
|
26517
26982
|
).action(async (query, opts, command) => {
|
|
26518
26983
|
await runWithClient(command, async ({ client, config }) => {
|
|
26519
26984
|
const accountId = requireAccountId(config);
|
|
26520
|
-
const params = { ...listParams(opts) };
|
|
26985
|
+
const params = { ...listParams(opts), envelope_id: opts.envelope };
|
|
26521
26986
|
if (query) params.search = query;
|
|
26522
26987
|
if (opts.status) params.status = opts.status;
|
|
26523
26988
|
const result = await withSpinner(
|
|
@@ -26528,27 +26993,40 @@ var searchCommand = addListOptions(
|
|
|
26528
26993
|
printPaginatedData(result, config, () => renderDocumentListTable(result));
|
|
26529
26994
|
});
|
|
26530
26995
|
});
|
|
26531
|
-
var getCommand3 = new Command("get").description("Show details for a document").argument("<id>", "Document ID").
|
|
26532
|
-
|
|
26533
|
-
|
|
26534
|
-
|
|
26535
|
-
|
|
26536
|
-
|
|
26537
|
-
|
|
26538
|
-
|
|
26539
|
-
|
|
26540
|
-
|
|
26541
|
-
|
|
26542
|
-
|
|
26543
|
-
|
|
26544
|
-
|
|
26545
|
-
|
|
26546
|
-
|
|
26547
|
-
|
|
26548
|
-
|
|
26549
|
-
|
|
26550
|
-
|
|
26551
|
-
|
|
26996
|
+
var getCommand3 = new Command("get").description("Show details for a document").argument("<id>", "Document ID").addOption(
|
|
26997
|
+
new Option("--access-code <code>", "Read as a signer instead of the owner").env(
|
|
26998
|
+
"ASSINAFY_SIGNER_ACCESS_CODE"
|
|
26999
|
+
)
|
|
27000
|
+
).addOption(
|
|
27001
|
+
new Option("--expand <relation>", "Include envelope details").choices([
|
|
27002
|
+
"envelope",
|
|
27003
|
+
"envelope_id",
|
|
27004
|
+
"envelope,envelope_id"
|
|
27005
|
+
])
|
|
27006
|
+
).action(async (id, opts, command) => {
|
|
27007
|
+
await (opts.accessCode === void 0 ? runWithClient : runWithPublicClient)(
|
|
27008
|
+
command,
|
|
27009
|
+
async ({ client, config }) => {
|
|
27010
|
+
const doc = await withSpinner(
|
|
27011
|
+
"Fetching document",
|
|
27012
|
+
config,
|
|
27013
|
+
() => opts.accessCode === void 0 ? client.documents.details(id, { expand: opts.expand }) : client.documents.getAsSigner(id, opts.accessCode)
|
|
27014
|
+
);
|
|
27015
|
+
printData(
|
|
27016
|
+
doc,
|
|
27017
|
+
config,
|
|
27018
|
+
(d) => renderKeyValue({
|
|
27019
|
+
id: d.id,
|
|
27020
|
+
name: d.name,
|
|
27021
|
+
status: d.status,
|
|
27022
|
+
account_id: d.account_id,
|
|
27023
|
+
created_at: d.created_at,
|
|
27024
|
+
updated_at: d.updated_at,
|
|
27025
|
+
is_closed: d.is_closed
|
|
27026
|
+
})
|
|
27027
|
+
);
|
|
27028
|
+
}
|
|
27029
|
+
);
|
|
26552
27030
|
});
|
|
26553
27031
|
var renameCommand = new Command("rename").description("Rename a document (only before the signature process starts)").argument("<id>", "Document ID").argument("<name>", "New document name").action(async (id, name, _opts, command) => {
|
|
26554
27032
|
await runWithClient(command, async ({ client, config }) => {
|
|
@@ -26562,49 +27040,80 @@ var renameCommand = new Command("rename").description("Rename a document (only b
|
|
|
26562
27040
|
});
|
|
26563
27041
|
});
|
|
26564
27042
|
var downloadCommand = addDownloadOptions(
|
|
26565
|
-
new Command("download").description("Download a document artifact").argument("<id>", "Document ID").
|
|
27043
|
+
new Command("download").description("Download a document artifact").argument("<id>", "Document ID").addOption(
|
|
27044
|
+
new Option("--access-code <code>", "Read as a signer instead of the owner").env(
|
|
27045
|
+
"ASSINAFY_SIGNER_ACCESS_CODE"
|
|
27046
|
+
)
|
|
27047
|
+
).option(
|
|
26566
27048
|
"--artifact <name>",
|
|
26567
27049
|
"original | certificated | certificate-page | pades | bundle",
|
|
26568
27050
|
"certificated"
|
|
26569
27051
|
)
|
|
26570
27052
|
).action(async (id, opts, command) => {
|
|
26571
|
-
await
|
|
26572
|
-
|
|
26573
|
-
|
|
26574
|
-
|
|
26575
|
-
|
|
26576
|
-
|
|
26577
|
-
|
|
26578
|
-
|
|
26579
|
-
|
|
26580
|
-
|
|
26581
|
-
|
|
27053
|
+
await (opts.accessCode === void 0 ? runWithClient : runWithPublicClient)(
|
|
27054
|
+
command,
|
|
27055
|
+
async ({ client, config }) => {
|
|
27056
|
+
const artifact = requireDocumentArtifactName(opts.artifact);
|
|
27057
|
+
await saveDownload(config, {
|
|
27058
|
+
message: "Downloading document",
|
|
27059
|
+
download: () => client.documents.download(id, artifact, { signerAccessCode: opts.accessCode }),
|
|
27060
|
+
output: opts.output,
|
|
27061
|
+
defaultName: defaultArtifactFilename(id, artifact),
|
|
27062
|
+
force: opts.force,
|
|
27063
|
+
data: { artifact }
|
|
27064
|
+
});
|
|
27065
|
+
}
|
|
27066
|
+
);
|
|
26582
27067
|
});
|
|
26583
27068
|
var thumbnailCommand = addDownloadOptions(
|
|
26584
|
-
new Command("thumbnail").description("Download the document thumbnail (JPEG)").
|
|
27069
|
+
new Command("thumbnail").description("Download the document thumbnail (JPEG)").addOption(
|
|
27070
|
+
new Option("--artifact <name>", "Use the signed PDF").choices(["certificated"])
|
|
27071
|
+
).argument("<id>", "Document ID").addOption(
|
|
27072
|
+
new Option("--access-code <code>", "Read as a signer instead of the owner").env(
|
|
27073
|
+
"ASSINAFY_SIGNER_ACCESS_CODE"
|
|
27074
|
+
)
|
|
27075
|
+
)
|
|
26585
27076
|
).action(async (id, opts, command) => {
|
|
26586
|
-
await
|
|
26587
|
-
|
|
26588
|
-
|
|
26589
|
-
|
|
26590
|
-
|
|
26591
|
-
|
|
26592
|
-
|
|
26593
|
-
|
|
26594
|
-
|
|
27077
|
+
await (opts.accessCode === void 0 ? runWithClient : runWithPublicClient)(
|
|
27078
|
+
command,
|
|
27079
|
+
async ({ client, config }) => {
|
|
27080
|
+
await saveDownload(config, {
|
|
27081
|
+
message: "Downloading thumbnail",
|
|
27082
|
+
download: () => client.documents.thumbnail(id, {
|
|
27083
|
+
artifact: opts.artifact,
|
|
27084
|
+
signerAccessCode: opts.accessCode
|
|
27085
|
+
}),
|
|
27086
|
+
output: opts.output,
|
|
27087
|
+
defaultName: defaultArtifactFilename(id, "thumbnail"),
|
|
27088
|
+
force: opts.force
|
|
27089
|
+
});
|
|
27090
|
+
}
|
|
27091
|
+
);
|
|
26595
27092
|
});
|
|
26596
27093
|
var downloadPageCommand = addDownloadOptions(
|
|
26597
|
-
new Command("download-page").description("Download a single document page (JPEG)").
|
|
27094
|
+
new Command("download-page").description("Download a single document page (JPEG)").addOption(
|
|
27095
|
+
new Option("--artifact <name>", "Use the signed PDF").choices(["certificated"])
|
|
27096
|
+
).argument("<id>", "Document ID").addOption(
|
|
27097
|
+
new Option("--access-code <code>", "Read as a signer instead of the owner").env(
|
|
27098
|
+
"ASSINAFY_SIGNER_ACCESS_CODE"
|
|
27099
|
+
)
|
|
27100
|
+
).argument("<pageId>", "Page ID")
|
|
26598
27101
|
).action(async (id, pageId, opts, command) => {
|
|
26599
|
-
await
|
|
26600
|
-
|
|
26601
|
-
|
|
26602
|
-
|
|
26603
|
-
|
|
26604
|
-
|
|
26605
|
-
|
|
26606
|
-
|
|
26607
|
-
|
|
27102
|
+
await (opts.accessCode === void 0 ? runWithClient : runWithPublicClient)(
|
|
27103
|
+
command,
|
|
27104
|
+
async ({ client, config }) => {
|
|
27105
|
+
await saveDownload(config, {
|
|
27106
|
+
message: "Downloading page",
|
|
27107
|
+
download: () => client.documents.downloadPage(id, pageId, {
|
|
27108
|
+
artifact: opts.artifact,
|
|
27109
|
+
signerAccessCode: opts.accessCode
|
|
27110
|
+
}),
|
|
27111
|
+
output: opts.output,
|
|
27112
|
+
defaultName: `${id}-page-${pageId}.jpg`,
|
|
27113
|
+
force: opts.force
|
|
27114
|
+
});
|
|
27115
|
+
}
|
|
27116
|
+
);
|
|
26608
27117
|
});
|
|
26609
27118
|
var activitiesCommand = addSortableListOptions(
|
|
26610
27119
|
new Command("activities").description("Show one page of the activity log for a document").argument("<id>", "Document ID"),
|
|
@@ -26691,7 +27200,7 @@ var tagsRemoveCommand = new Command("tags-remove").description("Detach a single
|
|
|
26691
27200
|
printData(result, config);
|
|
26692
27201
|
});
|
|
26693
27202
|
});
|
|
26694
|
-
var createFromTemplateCommand = new Command("create-from-template").description("Create a document from a template").argument("<templateId>", "Template ID").requiredOption(
|
|
27203
|
+
var createFromTemplateCommand = new Command("create-from-template").option("--idempotency-key <key>", "Creation key for recovering a lost response").option("--max-total-credits <amount>", "Reject creation if its credit cost exceeds this amount").description("Create a document from a template").argument("<templateId>", "Template ID").requiredOption(
|
|
26695
27204
|
"--signers <json>",
|
|
26696
27205
|
`JSON array of signers, e.g. '[{"role_id":"r","id":"s","verification_method":"Email","notification_methods":["Email"]}]'`
|
|
26697
27206
|
).option("--name <name>", "Document name").option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--tags <names>", "Comma-separated tag names to attach").option("--editor-fields <json>", "JSON array of editor field placements").action(async (templateId, opts, command) => {
|
|
@@ -26700,6 +27209,8 @@ var createFromTemplateCommand = new Command("create-from-template").description(
|
|
|
26700
27209
|
const signers = parseJsonArray(opts.signers, "--signers");
|
|
26701
27210
|
const editorFields = parseJsonArray(opts.editorFields, "--editor-fields");
|
|
26702
27211
|
const options = stripEmpty({
|
|
27212
|
+
idempotencyKey: opts.idempotencyKey,
|
|
27213
|
+
max_total_credits: parseCreditCeiling(opts.maxTotalCredits),
|
|
26703
27214
|
name: opts.name,
|
|
26704
27215
|
message: opts.message,
|
|
26705
27216
|
expires_at: opts.expiresAt,
|
|
@@ -26821,6 +27332,208 @@ var waitCommand = new Command("wait").description("Poll a document until it is r
|
|
|
26821
27332
|
});
|
|
26822
27333
|
var documentsCommand = new Command("documents").description("Upload, list, download, and manage documents").addCommand(uploadCommand).addCommand(listCommand4).addCommand(searchCommand).addCommand(getCommand3).addCommand(renameCommand).addCommand(downloadCommand).addCommand(thumbnailCommand).addCommand(downloadPageCommand).addCommand(activitiesCommand).addCommand(deleteCommand).addCommand(tagsCommand).addCommand(tagsSetCommand).addCommand(tagsAddCommand).addCommand(tagsRemoveCommand).addCommand(createFromTemplateCommand).addCommand(estimateTemplateCostCommand).addCommand(verifyCommand).addCommand(statusesCommand).addCommand(publicCommand).addCommand(sendTokenCommand).addCommand(progressCommand).addCommand(waitCommand);
|
|
26823
27334
|
|
|
27335
|
+
// src/commands/embed.ts
|
|
27336
|
+
var origins = new Command("origins").description("Manage origins allowed to embed signing pages");
|
|
27337
|
+
origins.addCommand(
|
|
27338
|
+
new Command("list").description("List allowed origins").action(async (_opts, command) => {
|
|
27339
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27340
|
+
printData(await client.embed.listOrigins(requireAccountId(config)), config);
|
|
27341
|
+
});
|
|
27342
|
+
})
|
|
27343
|
+
);
|
|
27344
|
+
origins.addCommand(
|
|
27345
|
+
new Command("create").description("Allow an exact origin").requiredOption("--origin <url>", "HTTPS origin (HTTP allowed for localhost/127.0.0.1)").action(async (opts, command) => {
|
|
27346
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27347
|
+
printData(await client.embed.createOrigin(opts.origin, requireAccountId(config)), config);
|
|
27348
|
+
});
|
|
27349
|
+
})
|
|
27350
|
+
);
|
|
27351
|
+
origins.addCommand(
|
|
27352
|
+
new Command("update").description("Replace an allowed origin").argument("<originId>", "Origin ID").requiredOption("--origin <url>", "New exact origin").action(async (id, opts, command) => {
|
|
27353
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27354
|
+
printData(
|
|
27355
|
+
await client.embed.updateOrigin(id, opts.origin, requireAccountId(config)),
|
|
27356
|
+
config
|
|
27357
|
+
);
|
|
27358
|
+
});
|
|
27359
|
+
})
|
|
27360
|
+
);
|
|
27361
|
+
origins.addCommand(
|
|
27362
|
+
new Command("delete").description("Remove an allowed origin").argument("<originId>", "Origin ID").option("-y, --yes", "Skip confirmation").action(async (id, opts, command) => {
|
|
27363
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27364
|
+
if (!await confirmDestructive(`Remove embed origin ${id}?`, Boolean(opts.yes))) return;
|
|
27365
|
+
printData(await client.embed.deleteOrigin(id, requireAccountId(config)), config);
|
|
27366
|
+
});
|
|
27367
|
+
})
|
|
27368
|
+
);
|
|
27369
|
+
var session = new Command("session").description("Mint a private iframe URL valid for five minutes").argument("<documentId>", "Document ID").argument("<assignmentId>", "Assignment ID").argument("<signerId>", "Signer ID").action(async (did, aid, sid, _opts, command) => {
|
|
27370
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27371
|
+
printData(await client.embed.createSession(did, aid, sid), config);
|
|
27372
|
+
});
|
|
27373
|
+
});
|
|
27374
|
+
var exchange = new Command("exchange").description("Consume a session token (Assinafy embed page operation)").addOption(
|
|
27375
|
+
new Option("--session-token <token>", "Private session token").env("ASSINAFY_EMBED_SESSION_TOKEN").makeOptionMandatory()
|
|
27376
|
+
).option("--parent-origin <url>", "Origin hosting the iframe").action(async (opts, command) => {
|
|
27377
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
27378
|
+
printData(await client.embed.exchangeSession(opts.sessionToken, opts.parentOrigin), config);
|
|
27379
|
+
});
|
|
27380
|
+
});
|
|
27381
|
+
var embedCommand = new Command("embed").description("Embedded signing origins and sessions").addCommand(origins).addCommand(session).addCommand(exchange);
|
|
27382
|
+
|
|
27383
|
+
// src/commands/envelopes.ts
|
|
27384
|
+
var envelopesCommand = new Command("envelopes").description(
|
|
27385
|
+
"Send and manage groups of documents"
|
|
27386
|
+
);
|
|
27387
|
+
envelopesCommand.addCommand(
|
|
27388
|
+
addPaginationOptions(new Command("list").description("List workspace envelopes")).option("--search <text>", "Part of the envelope name").addOption(
|
|
27389
|
+
new Option("--status <status>", "Document lifecycle group").choices([
|
|
27390
|
+
"open",
|
|
27391
|
+
"closed"
|
|
27392
|
+
])
|
|
27393
|
+
).action(async (opts, command) => {
|
|
27394
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27395
|
+
printData(
|
|
27396
|
+
await client.envelopes.list(
|
|
27397
|
+
{ ...listParams(opts), status: opts.status },
|
|
27398
|
+
requireAccountId(config)
|
|
27399
|
+
),
|
|
27400
|
+
config
|
|
27401
|
+
);
|
|
27402
|
+
});
|
|
27403
|
+
})
|
|
27404
|
+
);
|
|
27405
|
+
for (const action of ["create", "estimate-cost"]) {
|
|
27406
|
+
const cmd = new Command(action).description(
|
|
27407
|
+
action === "create" ? "Create an envelope and send invitations" : "Estimate without sending or charging"
|
|
27408
|
+
).requiredOption(
|
|
27409
|
+
"--data <json>",
|
|
27410
|
+
"Envelope JSON: name, signers, documents, optional max_total_credits"
|
|
27411
|
+
);
|
|
27412
|
+
if (action === "create")
|
|
27413
|
+
cmd.option("--idempotency-key <key>", "Creation key for recovering a lost response");
|
|
27414
|
+
envelopesCommand.addCommand(
|
|
27415
|
+
cmd.action(async (opts, command) => {
|
|
27416
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27417
|
+
const payload = parseJsonObject(opts.data, "--data");
|
|
27418
|
+
const accountId = requireAccountId(config);
|
|
27419
|
+
const result = action === "create" ? await client.envelopes.create(payload, {
|
|
27420
|
+
accountId,
|
|
27421
|
+
idempotencyKey: opts.idempotencyKey
|
|
27422
|
+
}) : await client.envelopes.estimateCost(payload, accountId);
|
|
27423
|
+
printData(result, config);
|
|
27424
|
+
});
|
|
27425
|
+
})
|
|
27426
|
+
);
|
|
27427
|
+
}
|
|
27428
|
+
envelopesCommand.addCommand(
|
|
27429
|
+
new Command("get").description("Read an envelope and its documents").argument("<envelopeId>", "Envelope ID").action(async (id, _opts, command) => {
|
|
27430
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27431
|
+
printData(await client.envelopes.get(id, requireAccountId(config)), config);
|
|
27432
|
+
});
|
|
27433
|
+
})
|
|
27434
|
+
);
|
|
27435
|
+
envelopesCommand.addCommand(
|
|
27436
|
+
new Command("update").description("Rename, change message, or reorder documents").argument("<envelopeId>", "Envelope ID").requiredOption("--data <json>", "Partial JSON: name, message (null clears), document_ids").action(async (id, opts, command) => {
|
|
27437
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27438
|
+
printData(
|
|
27439
|
+
await client.envelopes.update(
|
|
27440
|
+
id,
|
|
27441
|
+
parseJsonObject(opts.data, "--data"),
|
|
27442
|
+
requireAccountId(config)
|
|
27443
|
+
),
|
|
27444
|
+
config
|
|
27445
|
+
);
|
|
27446
|
+
});
|
|
27447
|
+
})
|
|
27448
|
+
);
|
|
27449
|
+
for (const action of ["cancel", "delete"]) {
|
|
27450
|
+
envelopesCommand.addCommand(
|
|
27451
|
+
new Command(action).description(
|
|
27452
|
+
action === "cancel" ? "Cancel open documents and notify recipients" : "Delete a closed envelope, keeping its documents"
|
|
27453
|
+
).argument("<envelopeId>", "Envelope ID").option("-y, --yes", "Skip confirmation").action(async (id, opts, command) => {
|
|
27454
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27455
|
+
if (!await confirmDestructive(`${action} envelope ${id}?`, Boolean(opts.yes))) return;
|
|
27456
|
+
printData(await client.envelopes[action](id, requireAccountId(config)), config);
|
|
27457
|
+
});
|
|
27458
|
+
})
|
|
27459
|
+
);
|
|
27460
|
+
}
|
|
27461
|
+
envelopesCommand.addCommand(
|
|
27462
|
+
addSortableListOptions(
|
|
27463
|
+
new Command("activities").description("Read a page of document activities").argument("<envelopeId>", "Envelope ID"),
|
|
27464
|
+
"id or -id"
|
|
27465
|
+
).action(async (id, opts, command) => {
|
|
27466
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27467
|
+
printData(
|
|
27468
|
+
await client.envelopes.activities(id, listParams(opts), requireAccountId(config)),
|
|
27469
|
+
config
|
|
27470
|
+
);
|
|
27471
|
+
});
|
|
27472
|
+
})
|
|
27473
|
+
);
|
|
27474
|
+
envelopesCommand.addCommand(
|
|
27475
|
+
addDownloadOptions(
|
|
27476
|
+
new Command("download").description("Download a ZIP of document artifacts").argument("<envelopeId>", "Envelope ID")
|
|
27477
|
+
).option(
|
|
27478
|
+
"--artifact <name>",
|
|
27479
|
+
"original, certificated, certificate-page, pades, bundle",
|
|
27480
|
+
"certificated"
|
|
27481
|
+
).action(async (id, opts, command) => {
|
|
27482
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27483
|
+
const artifact = requireDocumentArtifactName(opts.artifact);
|
|
27484
|
+
await saveDownload(config, {
|
|
27485
|
+
message: "Downloading envelope",
|
|
27486
|
+
download: () => client.envelopes.download(id, artifact, requireAccountId(config)),
|
|
27487
|
+
output: opts.output,
|
|
27488
|
+
defaultName: `envelope-${id}-${artifact}.zip`,
|
|
27489
|
+
force: opts.force
|
|
27490
|
+
});
|
|
27491
|
+
});
|
|
27492
|
+
})
|
|
27493
|
+
);
|
|
27494
|
+
envelopesCommand.addCommand(
|
|
27495
|
+
new Command("resend").description("Resend one signer\u2019s envelope invitation; paid channels cost credits").argument("<envelopeId>", "Envelope ID").argument("<signerId>", "Signer ID").action(async (id, signerId, _opts, command) => {
|
|
27496
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27497
|
+
printData(
|
|
27498
|
+
await client.envelopes.resendNotification(id, signerId, requireAccountId(config)),
|
|
27499
|
+
config
|
|
27500
|
+
);
|
|
27501
|
+
});
|
|
27502
|
+
})
|
|
27503
|
+
);
|
|
27504
|
+
envelopesCommand.addCommand(
|
|
27505
|
+
new Command("add-document").description("Add a processed document and notify its envelope signers").argument("<envelopeId>", "Envelope ID").requiredOption(
|
|
27506
|
+
"--data <json>",
|
|
27507
|
+
"JSON: id, signer_ids, optional method, entries, expires_at, copy_receiver_ids, max_total_credits"
|
|
27508
|
+
).action(async (id, opts, command) => {
|
|
27509
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27510
|
+
printData(
|
|
27511
|
+
await client.envelopes.addDocument(
|
|
27512
|
+
id,
|
|
27513
|
+
parseJsonObject(opts.data, "--data"),
|
|
27514
|
+
requireAccountId(config)
|
|
27515
|
+
),
|
|
27516
|
+
config
|
|
27517
|
+
);
|
|
27518
|
+
});
|
|
27519
|
+
})
|
|
27520
|
+
);
|
|
27521
|
+
envelopesCommand.addCommand(
|
|
27522
|
+
new Command("remove-document").description("Cancel and remove an open document, notifying its recipients").argument("<envelopeId>", "Envelope ID").argument("<documentId>", "Document ID").option("-y, --yes", "Skip confirmation").action(async (id, documentId, opts, command) => {
|
|
27523
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
27524
|
+
if (!await confirmDestructive(
|
|
27525
|
+
`Cancel and remove document ${documentId} from envelope ${id}?`,
|
|
27526
|
+
Boolean(opts.yes)
|
|
27527
|
+
))
|
|
27528
|
+
return;
|
|
27529
|
+
printData(
|
|
27530
|
+
await client.envelopes.removeDocument(id, documentId, requireAccountId(config)),
|
|
27531
|
+
config
|
|
27532
|
+
);
|
|
27533
|
+
});
|
|
27534
|
+
})
|
|
27535
|
+
);
|
|
27536
|
+
|
|
26824
27537
|
// src/commands/fields.ts
|
|
26825
27538
|
var fieldColumns = [
|
|
26826
27539
|
{ header: "ID", value: (r2) => r2.id },
|
|
@@ -27172,7 +27885,10 @@ function resolveSigners(signerSpecs, signersJson) {
|
|
|
27172
27885
|
}
|
|
27173
27886
|
var sendCommand = new Command("send").description("Upload a PDF, create signers, and request signatures in one step").argument("<file>", "Path to the PDF file").addOption(
|
|
27174
27887
|
new Option("--signer <spec>", 'Signer as "Name <email-or-phone>" (repeatable)').argParser(collect).default([]).conflicts("signers")
|
|
27175
|
-
).addOption(new Option("--signers <json>", "JSON array of signer objects").conflicts("signer")).option(
|
|
27888
|
+
).addOption(new Option("--signers <json>", "JSON array of signer objects").conflicts("signer")).option(
|
|
27889
|
+
"--max-total-credits <amount>",
|
|
27890
|
+
"Reject the assignment if its credit cost exceeds this amount"
|
|
27891
|
+
).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) => {
|
|
27176
27892
|
await runWithClient(command, async ({ client, config }) => {
|
|
27177
27893
|
const accountId = requireAccountId(config);
|
|
27178
27894
|
const signers = resolveSigners(opts.signer, opts.signers);
|
|
@@ -27183,6 +27899,7 @@ var sendCommand = new Command("send").description("Upload a PDF, create signers,
|
|
|
27183
27899
|
waitForReady: opts.wait
|
|
27184
27900
|
};
|
|
27185
27901
|
if (opts.message) params.message = opts.message;
|
|
27902
|
+
params.maxTotalCredits = parseCreditCeiling(opts.maxTotalCredits);
|
|
27186
27903
|
if (opts.expiresAt) params.expiresAt = opts.expiresAt;
|
|
27187
27904
|
const cc = splitList(opts.copyReceivers);
|
|
27188
27905
|
if (cc) params.copyReceivers = cc;
|
|
@@ -27216,24 +27933,32 @@ var optionalAccessCodeOption = () => new Option("--access-code <code>", "Signer
|
|
|
27216
27933
|
"ASSINAFY_SIGNER_ACCESS_CODE"
|
|
27217
27934
|
);
|
|
27218
27935
|
var runSignerOrOwner = (accessCode) => accessCode === void 0 ? runWithClient : runWithPublicClient;
|
|
27219
|
-
var documentCommand = new Command("document").description("Fetch the signer's current document").argument("<signerId>", "Signer ID").addOption(accessCodeOption()).
|
|
27936
|
+
var documentCommand = new Command("document").description("Fetch the signer's current document").argument("<signerId>", "Signer ID").addOption(accessCodeOption()).addOption(
|
|
27937
|
+
new Option("--expand <relation>", "Include the envelope").choices(["envelope"])
|
|
27938
|
+
).action(async (signerId, opts, command) => {
|
|
27220
27939
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
27221
27940
|
const doc = await withSpinner(
|
|
27222
27941
|
"Fetching document",
|
|
27223
27942
|
config,
|
|
27224
|
-
() => client.signerDocuments.getCurrent(signerId, opts.accessCode)
|
|
27943
|
+
() => client.signerDocuments.getCurrent(signerId, opts.accessCode, { expand: opts.expand })
|
|
27225
27944
|
);
|
|
27226
27945
|
printData(doc, config, (d) => renderKeyValue({ id: d.id, name: d.name, status: d.status }));
|
|
27227
27946
|
});
|
|
27228
27947
|
});
|
|
27229
27948
|
var documentsCommand2 = addListOptions(
|
|
27230
|
-
new Command("documents").description("List the signer's documents").argument("<signerId>", "Signer ID").addOption(optionalAccessCodeOption())
|
|
27949
|
+
new Command("documents").description("List the signer's documents").option("--envelope <id>", "Filter by envelope ID").argument("<signerId>", "Signer ID").addOption(optionalAccessCodeOption())
|
|
27231
27950
|
).action(async (signerId, opts, command) => {
|
|
27232
27951
|
await runSignerOrOwner(opts.accessCode)(command, async ({ client, config }) => {
|
|
27233
27952
|
const result = await withSpinner(
|
|
27234
27953
|
"Fetching documents",
|
|
27235
27954
|
config,
|
|
27236
|
-
() => opts.accessCode === void 0 ? client.signerDocuments.listAsOwner(signerId,
|
|
27955
|
+
() => opts.accessCode === void 0 ? client.signerDocuments.listAsOwner(signerId, {
|
|
27956
|
+
...listParams(opts),
|
|
27957
|
+
envelope_id: opts.envelope
|
|
27958
|
+
}) : client.signerDocuments.list(signerId, opts.accessCode, {
|
|
27959
|
+
...listParams(opts),
|
|
27960
|
+
envelope_id: opts.envelope
|
|
27961
|
+
})
|
|
27237
27962
|
);
|
|
27238
27963
|
printPaginatedData(
|
|
27239
27964
|
result,
|
|
@@ -27246,12 +27971,14 @@ var documentsCommand2 = addListOptions(
|
|
|
27246
27971
|
);
|
|
27247
27972
|
});
|
|
27248
27973
|
});
|
|
27249
|
-
var searchCommand2 = new Command("search").description("Search the signer's documents").argument("<signerId>", "Signer ID").argument("<query>", "Search text").addOption(optionalAccessCodeOption()).action(async (signerId, query, opts, command) => {
|
|
27974
|
+
var searchCommand2 = new Command("search").description("Search the signer's documents").option("--envelope <id>", "Filter by envelope ID").argument("<signerId>", "Signer ID").argument("<query>", "Search text").addOption(optionalAccessCodeOption()).action(async (signerId, query, opts, command) => {
|
|
27250
27975
|
await runSignerOrOwner(opts.accessCode)(command, async ({ client, config }) => {
|
|
27251
27976
|
const result = await withSpinner(
|
|
27252
27977
|
"Searching documents",
|
|
27253
27978
|
config,
|
|
27254
|
-
() => opts.accessCode === void 0 ? client.signerDocuments.searchAsOwner(signerId, query) : client.signerDocuments.search(signerId, query, opts.accessCode
|
|
27979
|
+
() => opts.accessCode === void 0 ? client.signerDocuments.searchAsOwner(signerId, query, { envelope_id: opts.envelope }) : client.signerDocuments.search(signerId, query, opts.accessCode, {
|
|
27980
|
+
envelope_id: opts.envelope
|
|
27981
|
+
})
|
|
27255
27982
|
);
|
|
27256
27983
|
printPaginatedData(
|
|
27257
27984
|
result,
|
|
@@ -27265,8 +27992,8 @@ var searchCommand2 = new Command("search").description("Search the signer's docu
|
|
|
27265
27992
|
});
|
|
27266
27993
|
});
|
|
27267
27994
|
var downloadCommand2 = addDownloadOptions(
|
|
27268
|
-
new Command("download").description("Download a signer
|
|
27269
|
-
new Option("--access-code <code>", "
|
|
27995
|
+
new Command("download").description("Download the original with a signer code; use download-copy for certified files").argument("<signerId>", "Signer ID").argument("<documentId>", "Document ID").argument("<artifact>", "original | certificated | certificate-page | pades | bundle").addOption(
|
|
27996
|
+
new Option("--access-code <code>", "Signer access code (required by the current API)").env(
|
|
27270
27997
|
"ASSINAFY_SIGNER_ACCESS_CODE"
|
|
27271
27998
|
)
|
|
27272
27999
|
)
|
|
@@ -27340,24 +28067,28 @@ var verifyCodeCommand = new Command("verify-code").alias("verify-email").descrip
|
|
|
27340
28067
|
printData(result, config);
|
|
27341
28068
|
});
|
|
27342
28069
|
});
|
|
27343
|
-
var certificateStartCommand = new Command("certificate-start").description("Start an ICP-Brasil A1/A3 signature and return the Web PKI token").addOption(accessCodeOption()).action(async (opts, command) => {
|
|
28070
|
+
var certificateStartCommand = new Command("certificate-start").option("--document-id <id>", "Select a document of the same envelope").description("Start an ICP-Brasil A1/A3 signature and return the Web PKI token").addOption(accessCodeOption()).action(async (opts, command) => {
|
|
27344
28071
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
27345
28072
|
const result = await withSpinner(
|
|
27346
28073
|
"Starting certificate signature",
|
|
27347
28074
|
config,
|
|
27348
|
-
() => client.signerDocuments.startCertificate(opts.accessCode)
|
|
28075
|
+
() => client.signerDocuments.startCertificate(opts.accessCode, opts.documentId)
|
|
27349
28076
|
);
|
|
27350
28077
|
printData(result, config);
|
|
27351
28078
|
});
|
|
27352
28079
|
});
|
|
27353
|
-
var certificateCompleteCommand = new Command("certificate-complete").description("Complete an ICP-Brasil A1/A3 signature after Web PKI has signed the token").addOption(accessCodeOption()).addOption(
|
|
28080
|
+
var certificateCompleteCommand = new Command("certificate-complete").option("--document-id <id>", "Select a document of the same envelope").description("Complete an ICP-Brasil A1/A3 signature after Web PKI has signed the token").addOption(accessCodeOption()).addOption(
|
|
27354
28081
|
new Option("--certificate-token <token>", "Operation token returned by certificate-start").env("ASSINAFY_CERTIFICATE_TOKEN").makeOptionMandatory()
|
|
27355
28082
|
).action(async (opts, command) => {
|
|
27356
28083
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
27357
28084
|
const result = await withSpinner(
|
|
27358
28085
|
"Completing certificate signature",
|
|
27359
28086
|
config,
|
|
27360
|
-
() => client.signerDocuments.completeCertificate(
|
|
28087
|
+
() => client.signerDocuments.completeCertificate(
|
|
28088
|
+
opts.accessCode,
|
|
28089
|
+
opts.certificateToken,
|
|
28090
|
+
opts.documentId
|
|
28091
|
+
)
|
|
27361
28092
|
);
|
|
27362
28093
|
printSuccess("Certificate signature completed", config);
|
|
27363
28094
|
printData(result, config);
|
|
@@ -27411,12 +28142,17 @@ var downloadSignatureCommand = addDownloadOptions(
|
|
|
27411
28142
|
});
|
|
27412
28143
|
});
|
|
27413
28144
|
});
|
|
27414
|
-
var assignmentCommand = new Command("assignment").description("Fetch the assignment as the signer sees it").addOption(accessCodeOption()).option("--accept-terms", "Pass has_accepted_terms=true").
|
|
28145
|
+
var assignmentCommand = new Command("assignment").description("Fetch the assignment as the signer sees it").option("--document-id <id>", "Select another document of the same envelope").addOption(accessCodeOption()).option("--accept-terms", "Pass has_accepted_terms=true").addOption(
|
|
28146
|
+
new Option("--expand <relation>", "Include the envelope").choices(["envelope"])
|
|
28147
|
+
).action(async (opts, command) => {
|
|
27415
28148
|
await runWithPublicClient(command, async ({ client, config }) => {
|
|
27416
28149
|
const result = await withSpinner(
|
|
27417
28150
|
"Fetching assignment",
|
|
27418
28151
|
config,
|
|
27419
|
-
() => client.signerDocuments.getAssignment(opts.accessCode, opts.acceptTerms ? true : void 0
|
|
28152
|
+
() => client.signerDocuments.getAssignment(opts.accessCode, opts.acceptTerms ? true : void 0, {
|
|
28153
|
+
expand: opts.expand,
|
|
28154
|
+
document_id: opts.documentId
|
|
28155
|
+
})
|
|
27420
28156
|
);
|
|
27421
28157
|
printData(result, config);
|
|
27422
28158
|
});
|
|
@@ -27471,7 +28207,54 @@ var declineMultipleCommand = new Command("decline-multiple").description("Declin
|
|
|
27471
28207
|
printData(result, config);
|
|
27472
28208
|
});
|
|
27473
28209
|
});
|
|
27474
|
-
var
|
|
28210
|
+
var themeCommand = new Command("theme").description("Read the signing workspace brand").addOption(accessCodeOption()).action(async (opts, command) => {
|
|
28211
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
28212
|
+
printData(await client.signerDocuments.getTheme(opts.accessCode), config);
|
|
28213
|
+
});
|
|
28214
|
+
});
|
|
28215
|
+
var logoCommand = addDownloadOptions(
|
|
28216
|
+
new Command("logo").description("Download the signing workspace logo").addOption(accessCodeOption())
|
|
28217
|
+
).action(async (opts, command) => {
|
|
28218
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
28219
|
+
await saveDownload(config, {
|
|
28220
|
+
message: "Downloading logo",
|
|
28221
|
+
download: () => client.signerDocuments.downloadLogo(opts.accessCode),
|
|
28222
|
+
output: opts.output,
|
|
28223
|
+
defaultName: "signing-logo",
|
|
28224
|
+
force: opts.force
|
|
28225
|
+
});
|
|
28226
|
+
});
|
|
28227
|
+
});
|
|
28228
|
+
var certifiedCopyCommand = new Command("certified-copy").description("Send a new certified-copy link to the original signing contact").addOption(accessCodeOption()).option("--document-id <id>", "Another document in the same envelope").action(async (opts, command) => {
|
|
28229
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
28230
|
+
printData(
|
|
28231
|
+
await client.signerDocuments.resendCertifiedCopy(opts.accessCode, opts.documentId),
|
|
28232
|
+
config
|
|
28233
|
+
);
|
|
28234
|
+
});
|
|
28235
|
+
});
|
|
28236
|
+
var downloadTokenOption = () => new Option("--download-token <token>", "Private certified-copy link token").env("ASSINAFY_DOWNLOAD_TOKEN").makeOptionMandatory();
|
|
28237
|
+
var downloadCopyCommand = addDownloadOptions(
|
|
28238
|
+
new Command("download-copy").description("Download a PDF using a certified-copy link token").addOption(downloadTokenOption())
|
|
28239
|
+
).addOption(
|
|
28240
|
+
new Option("--artifact <name>", "PDF artifact").choices(["certificated", "pades"]).default("certificated")
|
|
28241
|
+
).action(async (opts, command) => {
|
|
28242
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
28243
|
+
await saveDownload(config, {
|
|
28244
|
+
message: "Downloading certified copy",
|
|
28245
|
+
download: () => client.signerDocuments.downloadCertifiedCopy(opts.downloadToken, opts.artifact),
|
|
28246
|
+
output: opts.output,
|
|
28247
|
+
defaultName: `${opts.artifact}.pdf`,
|
|
28248
|
+
force: opts.force
|
|
28249
|
+
});
|
|
28250
|
+
});
|
|
28251
|
+
});
|
|
28252
|
+
var resendCopyCommand = new Command("resend-download-link").description("Send a new link using an expired download token").addOption(downloadTokenOption()).action(async (opts, command) => {
|
|
28253
|
+
await runWithPublicClient(command, async ({ client, config }) => {
|
|
28254
|
+
printData(await client.signerDocuments.resendDownloadLink(opts.downloadToken), config);
|
|
28255
|
+
});
|
|
28256
|
+
});
|
|
28257
|
+
var signerCommand = new Command("signer").addCommand(themeCommand).addCommand(logoCommand).addCommand(certifiedCopyCommand).addCommand(downloadCopyCommand).addCommand(resendCopyCommand).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);
|
|
27475
28258
|
|
|
27476
28259
|
// src/commands/signers.ts
|
|
27477
28260
|
var signerColumns = [
|
|
@@ -27547,9 +28330,9 @@ var updateCommand2 = new Command("update").description("Update a signer").argume
|
|
|
27547
28330
|
await runWithClient(command, async ({ client, config }) => {
|
|
27548
28331
|
const accountId = requireAccountId(config);
|
|
27549
28332
|
const payload = {};
|
|
27550
|
-
if (opts.name) payload.full_name = opts.name;
|
|
27551
|
-
if (opts.email) payload.email = opts.email;
|
|
27552
|
-
if (opts.phone) payload.whatsapp_phone_number = opts.phone;
|
|
28333
|
+
if (opts.name !== void 0) payload.full_name = opts.name;
|
|
28334
|
+
if (opts.email !== void 0) payload.email = opts.email;
|
|
28335
|
+
if (opts.phone !== void 0) payload.whatsapp_phone_number = opts.phone;
|
|
27553
28336
|
if (opts.cpf) payload.cpf = opts.cpf;
|
|
27554
28337
|
if (opts.governmentId !== void 0) payload.government_id = opts.governmentId;
|
|
27555
28338
|
const signer = await withSpinner(
|
|
@@ -27771,7 +28554,25 @@ var preferencesUpdateCommand = new Command("update").description("Merge one or m
|
|
|
27771
28554
|
});
|
|
27772
28555
|
});
|
|
27773
28556
|
var preferencesCommand = new Command("notification-preferences").alias("preferences").description("Manage owner-facing email notification preferences").addCommand(preferencesGetCommand).addCommand(preferencesUpdateCommand);
|
|
27774
|
-
var
|
|
28557
|
+
var pushPreferences = new Command("push-preferences").description("Manage mobile push notification preferences").addCommand(
|
|
28558
|
+
new Command("get").description("Read push preferences").action(async (_opts, command) => {
|
|
28559
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
28560
|
+
printData(await client.users.getPushPreferences(), config);
|
|
28561
|
+
});
|
|
28562
|
+
})
|
|
28563
|
+
).addCommand(
|
|
28564
|
+
new Command("update").description("Merge push preference booleans").requiredOption("--set <json>", "Partial map of notification codes to booleans").action(async (opts, command) => {
|
|
28565
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
28566
|
+
printData(
|
|
28567
|
+
await client.users.updatePushPreferences(
|
|
28568
|
+
parseJsonObject(opts.set, "--set")
|
|
28569
|
+
),
|
|
28570
|
+
config
|
|
28571
|
+
);
|
|
28572
|
+
});
|
|
28573
|
+
})
|
|
28574
|
+
);
|
|
28575
|
+
var usersCommand = new Command("users").description("Show the authenticated user and personal preferences").addCommand(selfCommand2).addCommand(statsCommand).addCommand(preferencesCommand).addCommand(pushPreferences);
|
|
27775
28576
|
|
|
27776
28577
|
// src/commands/webhooks.ts
|
|
27777
28578
|
var registerCommand = new Command("register").description("Register (or replace) the account's oldest webhook endpoint").requiredOption("--url <url>", "Endpoint URL to receive events").requiredOption("--email <email>", "Contact email for delivery problems").option("--events <csv>", "Comma-separated event names (defaults to a sensible set)").option("--inactive", "Register the subscription as inactive").action(async (opts, command) => {
|
|
@@ -28029,21 +28830,23 @@ var endpointsSecretCommand = new Command("secret").description(
|
|
|
28029
28830
|
printData(result, config, (r2) => r2.secret);
|
|
28030
28831
|
});
|
|
28031
28832
|
});
|
|
28032
|
-
var endpointsRotateSecretCommand = new Command("rotate-secret").description("Replace the endpoint signing secret
|
|
28833
|
+
var endpointsRotateSecretCommand = new Command("rotate-secret").description("Replace the endpoint signing secret").option("--keep-previous", "Keep the replaced secret signing for 24 hours").argument("<endpointId>", "Endpoint ID").option("-y, --yes", "Skip the confirmation prompt").action(async (endpointId, opts, command) => {
|
|
28033
28834
|
await runWithClient(command, async ({ client, config }) => {
|
|
28034
28835
|
const accountId = requireAccountId(config);
|
|
28035
28836
|
if (!await confirmDestructive(
|
|
28036
|
-
`Rotate the signing secret of ${endpointId}? The current secret stops working immediately
|
|
28837
|
+
`Rotate the signing secret of ${endpointId}? ${opts.keepPrevious ? "The current secret stays valid for 24 hours." : "The current secret stops working immediately."}`,
|
|
28037
28838
|
Boolean(opts.yes)
|
|
28038
28839
|
))
|
|
28039
28840
|
return;
|
|
28040
28841
|
const result = await withSpinner(
|
|
28041
28842
|
"Rotating secret",
|
|
28042
28843
|
config,
|
|
28043
|
-
() => client.webhooks.rotateEndpointSecret(endpointId, accountId
|
|
28844
|
+
() => client.webhooks.rotateEndpointSecret(endpointId, accountId, {
|
|
28845
|
+
keep_previous: opts.keepPrevious
|
|
28846
|
+
})
|
|
28044
28847
|
);
|
|
28045
28848
|
printSuccess("Signing secret rotated", config);
|
|
28046
|
-
printData(result, config
|
|
28849
|
+
printData(result, config);
|
|
28047
28850
|
});
|
|
28048
28851
|
});
|
|
28049
28852
|
var verifyCommand2 = new Command("verify").description(
|
|
@@ -28071,7 +28874,13 @@ var verifyCommand2 = new Command("verify").description(
|
|
|
28071
28874
|
printData({ valid, id: opts.id }, config, () => "valid");
|
|
28072
28875
|
});
|
|
28073
28876
|
});
|
|
28074
|
-
var endpointsCommand = new Command("endpoints").
|
|
28877
|
+
var endpointsCommand = new Command("endpoints").addCommand(
|
|
28878
|
+
new Command("test").description("Send one webhook_test, even if inactive or paused").argument("<endpointId>", "Webhook endpoint ID").action(async (id, _opts, command) => {
|
|
28879
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
28880
|
+
printData(await client.webhooks.testEndpoint(id, requireAccountId(config)), config);
|
|
28881
|
+
});
|
|
28882
|
+
})
|
|
28883
|
+
).description("Manage webhook endpoints and their signing secrets").addCommand(endpointsListCommand).addCommand(endpointsCreateCommand).addCommand(endpointsGetCommand).addCommand(endpointsUpdateCommand).addCommand(endpointsDeleteCommand).addCommand(endpointsDeleteByUrlCommand).addCommand(endpointsSecretCommand).addCommand(endpointsRotateSecretCommand);
|
|
28075
28884
|
var webhooksCommand = new Command("webhooks").description("Manage webhook endpoints, the primary subscription, and delivery history").addCommand(endpointsCommand).addCommand(registerCommand).addCommand(getCommand7).addCommand(inactivateCommand).addCommand(eventTypesCommand).addCommand(dispatchesCommand).addCommand(retryCommand).addCommand(verifyCommand2);
|
|
28076
28885
|
|
|
28077
28886
|
// src/commands/whoami.ts
|
|
@@ -28137,12 +28946,16 @@ var listCommand9 = new Command("list").description("List workspaces you can acce
|
|
|
28137
28946
|
);
|
|
28138
28947
|
});
|
|
28139
28948
|
});
|
|
28140
|
-
var getCommand8 = new Command("get").description("Show a workspace by ID").argument("<id>", "Account/workspace ID").
|
|
28949
|
+
var getCommand8 = new Command("get").description("Show a workspace by ID").argument("<id>", "Account/workspace ID").addOption(
|
|
28950
|
+
new Option("--expand <relation>", "Include signing feature flags").choices([
|
|
28951
|
+
"signing_features"
|
|
28952
|
+
])
|
|
28953
|
+
).action(async (id, opts, command) => {
|
|
28141
28954
|
await runWithClient(command, async ({ client, config }) => {
|
|
28142
28955
|
const workspace = await withSpinner(
|
|
28143
28956
|
"Fetching workspace",
|
|
28144
28957
|
config,
|
|
28145
|
-
() => client.workspaces.get(id)
|
|
28958
|
+
() => client.workspaces.get(id, { expand: opts.expand })
|
|
28146
28959
|
);
|
|
28147
28960
|
printData(workspace, config, (w) => renderKeyValue(w));
|
|
28148
28961
|
});
|
|
@@ -28168,7 +28981,7 @@ var updateCommand4 = new Command("update").description("Update a workspace").arg
|
|
|
28168
28981
|
printData(workspace, config, (w) => renderKeyValue({ id: w.id, name: w.name }));
|
|
28169
28982
|
});
|
|
28170
28983
|
});
|
|
28171
|
-
var
|
|
28984
|
+
var themeCommand2 = new Command("theme").description("Show public branding for a workspace").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
|
|
28172
28985
|
await runWithClient(command, async ({ client, config }) => {
|
|
28173
28986
|
const theme = await withSpinner(
|
|
28174
28987
|
"Fetching workspace theme",
|
|
@@ -28235,7 +29048,7 @@ var logoDeleteCommand = new Command("delete").alias("rm").description("Delete th
|
|
|
28235
29048
|
printData({ deleted: true, account_id: id }, config);
|
|
28236
29049
|
});
|
|
28237
29050
|
});
|
|
28238
|
-
var
|
|
29051
|
+
var logoCommand2 = new Command("logo").description("Manage a workspace logo").addCommand(logoDownloadCommand).addCommand(logoUploadCommand).addCommand(logoDeleteCommand);
|
|
28239
29052
|
var deleteCommand5 = new Command("delete").alias("rm").description("Delete a workspace").argument("<id>", "Account/workspace ID").option("--force", "Cancel an active paid subscription automatically and delete anyway").option("-y, --yes", "Skip the confirmation prompt").action(async (id, opts, command) => {
|
|
28240
29053
|
await runWithClient(command, async ({ client, config }) => {
|
|
28241
29054
|
if (!await confirmDestructive(`Delete workspace ${id}?`, Boolean(opts.yes))) return;
|
|
@@ -28248,7 +29061,34 @@ var deleteCommand5 = new Command("delete").alias("rm").description("Delete a wor
|
|
|
28248
29061
|
printData({ deleted: id }, config);
|
|
28249
29062
|
});
|
|
28250
29063
|
});
|
|
28251
|
-
var
|
|
29064
|
+
var usageCommand = new Command("usage").description("Read plan allowances and balances").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
|
|
29065
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
29066
|
+
printData(await client.workspaces.usage(id), config);
|
|
29067
|
+
});
|
|
29068
|
+
});
|
|
29069
|
+
var policyCommand = new Command("notification-policy").description("Workspace-wide notification rules").addCommand(
|
|
29070
|
+
new Command("get").description("Read the policy").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
|
|
29071
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
29072
|
+
printData(await client.workspaces.getNotificationPolicy(id), config);
|
|
29073
|
+
});
|
|
29074
|
+
})
|
|
29075
|
+
).addCommand(
|
|
29076
|
+
new Command("update").description("Merge policy fields (workspace owners only)").argument("<id>", "Account/workspace ID").requiredOption("--data <json>", "Partial JSON: events and/or owners_receive_all").action(async (id, opts, command) => {
|
|
29077
|
+
await runWithClient(command, async ({ client, config }) => {
|
|
29078
|
+
printData(
|
|
29079
|
+
await client.workspaces.updateNotificationPolicy(
|
|
29080
|
+
id,
|
|
29081
|
+
parseJsonObject(
|
|
29082
|
+
opts.data,
|
|
29083
|
+
"--data"
|
|
29084
|
+
)
|
|
29085
|
+
),
|
|
29086
|
+
config
|
|
29087
|
+
);
|
|
29088
|
+
});
|
|
29089
|
+
})
|
|
29090
|
+
);
|
|
29091
|
+
var workspacesCommand = new Command("workspaces").addCommand(usageCommand).addCommand(policyCommand).alias("accounts").description("Manage workspaces (accounts)").addCommand(createCommand5).addCommand(listCommand9).addCommand(getCommand8).addCommand(themeCommand2).addCommand(statsCommand2).addCommand(logoCommand2).addCommand(updateCommand4).addCommand(deleteCommand5);
|
|
28252
29092
|
function logoContentType(file) {
|
|
28253
29093
|
return {
|
|
28254
29094
|
".gif": "image/gif",
|
|
@@ -28295,7 +29135,7 @@ function handleStreamError(err, fallback, exit = process.exit) {
|
|
|
28295
29135
|
// package.json
|
|
28296
29136
|
var package_default = {
|
|
28297
29137
|
name: "@assinafy/cli",
|
|
28298
|
-
version: "2.
|
|
29138
|
+
version: "2.8.0",
|
|
28299
29139
|
description: "The official command-line interface for the Assinafy digital-signature API",
|
|
28300
29140
|
license: "MIT",
|
|
28301
29141
|
type: "module",
|
|
@@ -28411,7 +29251,7 @@ ${import_picocolors7.default.gray("Examples:")}
|
|
|
28411
29251
|
|
|
28412
29252
|
${import_picocolors7.default.gray("Sandbox:")} target it with ${import_picocolors7.default.blue("--base-url https://sandbox.assinafy.com.br/v1")}
|
|
28413
29253
|
`
|
|
28414
|
-
).addCommand(sendCommand).addCommand(documentsCommand).addCommand(contractsCommand).addCommand(signersCommand).addCommand(assignmentsCommand).addCommand(templatesCommand).addCommand(tagsCommand2).addCommand(fieldsCommand).addCommand(webhooksCommand).addCommand(workspacesCommand).addCommand(usersCommand).addCommand(signerCommand).addCommand(authCommand).addCommand(oauthCommand).addCommand(loginCommand2).addCommand(logoutCommand).addCommand(whoamiCommand).addCommand(configCommand).addCommand(docsCommand);
|
|
29254
|
+
).addCommand(sendCommand).addCommand(documentsCommand).addCommand(envelopesCommand).addCommand(embedCommand).addCommand(contractsCommand).addCommand(signersCommand).addCommand(assignmentsCommand).addCommand(templatesCommand).addCommand(tagsCommand2).addCommand(fieldsCommand).addCommand(webhooksCommand).addCommand(workspacesCommand).addCommand(usersCommand).addCommand(signerCommand).addCommand(authCommand).addCommand(oauthCommand).addCommand(loginCommand2).addCommand(logoutCommand).addCommand(whoamiCommand).addCommand(configCommand).addCommand(docsCommand);
|
|
28415
29255
|
program2.parseAsync().catch((err) => {
|
|
28416
29256
|
process.stderr.write(
|
|
28417
29257
|
`${import_picocolors7.default.red("error:")} ${sanitizeTerminalText(err instanceof Error ? err.message : String(err))}
|