@assinafy/cli 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.cjs +23 -3
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +23 -3
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +24 -4
- package/dist/types/api/resources/assignments.d.ts.map +1 -1
- package/dist/types/api/resources/documents.d.ts +1 -0
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/utils.d.ts +5 -1
- package/dist/types/api/utils.d.ts.map +1 -1
- package/docs/api-operations.json +1 -1
- package/docs/api-reference.md +10 -2
- package/docs/sdk-reference.md +3 -3
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -225,6 +225,13 @@ function validateSignerOptions(input) {
|
|
|
225
225
|
throw new ValidationError("step must be an integer");
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
+
function validateDigitalCertificateMethod(method, signers) {
|
|
229
|
+
if (method !== "virtual" && signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
|
|
230
|
+
throw new ValidationError("DigitalCertificate signers require method: virtual", {
|
|
231
|
+
code: "digital_certificate_requires_virtual"
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
228
235
|
function validateSigningSteps(signers) {
|
|
229
236
|
const withSteps = signers.filter((signer) => signer.step !== void 0);
|
|
230
237
|
if (withSteps.length > 0) {
|
|
@@ -401,15 +408,17 @@ function buildAssignmentPayload(payload, options = {}) {
|
|
|
401
408
|
signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
|
|
402
409
|
});
|
|
403
410
|
}
|
|
404
|
-
|
|
411
|
+
const method = payload.method ?? "virtual";
|
|
412
|
+
const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref, options));
|
|
413
|
+
validateDigitalCertificateMethod(method, normalisedSigners);
|
|
414
|
+
if (method === "collect" && !Array.isArray(payload.entries)) {
|
|
405
415
|
throw new ValidationError("entries are required for collect assignments");
|
|
406
416
|
}
|
|
407
|
-
const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref, options));
|
|
408
417
|
if (!options.skipDigitalCertificateStepValidation) {
|
|
409
418
|
validateSigningSteps(normalisedSigners);
|
|
410
419
|
}
|
|
411
420
|
return stripEmpty({
|
|
412
|
-
method
|
|
421
|
+
method,
|
|
413
422
|
signers: normalisedSigners,
|
|
414
423
|
message: payload.message,
|
|
415
424
|
expires_at: payload.expires_at === void 0 ? void 0 : requireIso8601(payload.expires_at, "expires_at"),
|
|
@@ -1013,6 +1022,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
1013
1022
|
if (options.tags !== void 0 && (!Array.isArray(options.tags) || options.tags.some((tag) => typeof tag !== "string" || !tag))) {
|
|
1014
1023
|
throw new ValidationError("tags must contain non-empty tag names");
|
|
1015
1024
|
}
|
|
1025
|
+
await this.validateCertificateTemplateMethod(tmplId, accId, signers);
|
|
1016
1026
|
const body = { ...options, signers };
|
|
1017
1027
|
this.logger.info("Creating document from template", { templateId: tmplId, accountId: accId });
|
|
1018
1028
|
return this.call(
|
|
@@ -1025,6 +1035,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
1025
1035
|
const tmplId = this.requireId(templateId, "Template ID");
|
|
1026
1036
|
const accId = this.accountId(accountId);
|
|
1027
1037
|
validateTemplateSigners(signers, { requireId: false });
|
|
1038
|
+
await this.validateCertificateTemplateMethod(tmplId, accId, signers);
|
|
1028
1039
|
return this.call(
|
|
1029
1040
|
"Failed to estimate cost from template",
|
|
1030
1041
|
() => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents/estimate-cost`, { signers })
|
|
@@ -1103,6 +1114,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
1103
1114
|
const percentage = total > 0 ? Math.round(signed / total * 1e4) / 100 : 0;
|
|
1104
1115
|
return { signed, total, pending, percentage };
|
|
1105
1116
|
}
|
|
1117
|
+
async validateCertificateTemplateMethod(templateId, accountId, signers) {
|
|
1118
|
+
if (!signers.some((signer) => signer.verification_method === "DigitalCertificate")) return;
|
|
1119
|
+
const template = await this.call(
|
|
1120
|
+
"Failed to fetch template",
|
|
1121
|
+
() => this.http.get(`/accounts/${accountId}/templates/${templateId}`)
|
|
1122
|
+
);
|
|
1123
|
+
const method = template.pages?.some((page) => page.fields.length > 0) ? "collect" : "virtual";
|
|
1124
|
+
validateDigitalCertificateMethod(method, signers);
|
|
1125
|
+
}
|
|
1106
1126
|
};
|
|
1107
1127
|
function validateTemplateSigners(signers, options) {
|
|
1108
1128
|
if (!Array.isArray(signers)) throw new ValidationError("signers must be an array");
|