@assinafy/cli 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +21 -6
- package/README.md +20 -3
- package/dist/api.cjs +29 -9
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +29 -9
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +122 -30
- package/dist/types/api/resources/documents.d.ts +3 -3
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/resources/oauth.d.ts.map +1 -1
- package/dist/types/api/resources/signer-documents.d.ts +10 -6
- package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +14 -2
- package/dist/types/api/types.d.ts.map +1 -1
- package/docs/documents.md +8 -8
- package/docs/oauth-guide.md +6 -0
- package/docs/sdk-reference.md +36 -8
- package/docs/signer.md +2 -1
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -803,24 +803,24 @@ var DocumentResource = class extends BaseResource {
|
|
|
803
803
|
);
|
|
804
804
|
}
|
|
805
805
|
/**
|
|
806
|
-
* Replace the document's tag set
|
|
807
|
-
*
|
|
806
|
+
* Replace the document's tag set. Production accepts tag names and creates missing tags.
|
|
807
|
+
* An empty array detaches all tags. Values are forwarded unchanged.
|
|
808
808
|
*/
|
|
809
809
|
async replaceTags(documentId, tags, accountId) {
|
|
810
810
|
const accId = this.accountId(accountId);
|
|
811
811
|
const docId = this.requireId(documentId, "Document ID");
|
|
812
|
-
if (!Array.isArray(tags)) throw new ValidationError("tags must be an array
|
|
812
|
+
if (!Array.isArray(tags)) throw new ValidationError("tags must be an array");
|
|
813
813
|
return this.call(
|
|
814
814
|
"Failed to replace document tags",
|
|
815
815
|
() => this.http.put(`/accounts/${accId}/documents/${docId}/tags`, { tags })
|
|
816
816
|
);
|
|
817
817
|
}
|
|
818
|
-
/** Attach additional tag
|
|
818
|
+
/** Attach additional tag names without removing existing ones. Production creates missing tags. */
|
|
819
819
|
async addTags(documentId, tags, accountId) {
|
|
820
820
|
const accId = this.accountId(accountId);
|
|
821
821
|
const docId = this.requireId(documentId, "Document ID");
|
|
822
822
|
if (!Array.isArray(tags) || tags.length === 0) {
|
|
823
|
-
throw new ValidationError("tags must be a non-empty array
|
|
823
|
+
throw new ValidationError("tags must be a non-empty array");
|
|
824
824
|
}
|
|
825
825
|
return this.call(
|
|
826
826
|
"Failed to add document tags",
|
|
@@ -1234,7 +1234,11 @@ var OAuthResource = class extends BaseResource {
|
|
|
1234
1234
|
throw new ValidationError("OAuth issuer mismatch");
|
|
1235
1235
|
}
|
|
1236
1236
|
if (callback.searchParams.has("error")) {
|
|
1237
|
-
|
|
1237
|
+
const error = callback.searchParams.get("error");
|
|
1238
|
+
const oauthError = error.length > 0 && error.length <= 64 && !/[^a-z_]/.test(error) ? error : "unknown_error";
|
|
1239
|
+
throw new ValidationError(`OAuth authorization was declined or failed: ${oauthError}`, {
|
|
1240
|
+
oauthError
|
|
1241
|
+
});
|
|
1238
1242
|
}
|
|
1239
1243
|
return this.token({
|
|
1240
1244
|
grant_type: "authorization_code",
|
|
@@ -1439,6 +1443,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1439
1443
|
for (const [key, value] of Object.entries(payload)) {
|
|
1440
1444
|
if (value !== void 0) body[key] = value;
|
|
1441
1445
|
}
|
|
1446
|
+
await this.requireDocumentAccess(did, code);
|
|
1442
1447
|
return this.call(
|
|
1443
1448
|
"Failed to confirm signer data",
|
|
1444
1449
|
() => this.http.put(`/documents/${did}/signers/confirm-data`, body, signerAccessConfig(code))
|
|
@@ -1491,13 +1496,20 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1491
1496
|
() => this.http.get("/sign", signerAccessConfig(code, { has_accepted_terms: hasAcceptedTerms }))
|
|
1492
1497
|
);
|
|
1493
1498
|
}
|
|
1494
|
-
/**
|
|
1499
|
+
/**
|
|
1500
|
+
* `POST /documents/{documentId}/assignments/{assignmentId}?signer-access-code=…` — sign.
|
|
1501
|
+
* Virtual assignments accept `[]` after the signer confirms their data.
|
|
1502
|
+
*/
|
|
1495
1503
|
async sign(documentId, assignmentId, signerAccessCode, entries) {
|
|
1496
1504
|
const did = this.requireId(documentId, "Document ID");
|
|
1497
1505
|
const aid = this.requireId(assignmentId, "Assignment ID");
|
|
1498
1506
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1499
|
-
if (!Array.isArray(entries)
|
|
1500
|
-
throw new ValidationError("entries must be
|
|
1507
|
+
if (!Array.isArray(entries)) {
|
|
1508
|
+
throw new ValidationError("entries must be an array");
|
|
1509
|
+
}
|
|
1510
|
+
const document = await this.requireDocumentAccess(did, code, aid);
|
|
1511
|
+
if (document.assignment?.method === "collect" && entries.length === 0) {
|
|
1512
|
+
throw new ValidationError("entries must be non-empty for collect assignments");
|
|
1501
1513
|
}
|
|
1502
1514
|
return this.call(
|
|
1503
1515
|
"Failed to sign document",
|
|
@@ -1513,6 +1525,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1513
1525
|
const aid = this.requireId(assignmentId, "Assignment ID");
|
|
1514
1526
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1515
1527
|
validateDeclineReason(declineReason);
|
|
1528
|
+
await this.requireDocumentAccess(did, code, aid);
|
|
1516
1529
|
return this.call(
|
|
1517
1530
|
"Failed to decline assignment",
|
|
1518
1531
|
() => this.http.put(
|
|
@@ -1522,6 +1535,13 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1522
1535
|
)
|
|
1523
1536
|
);
|
|
1524
1537
|
}
|
|
1538
|
+
async requireDocumentAccess(documentId, signerAccessCode, assignmentId) {
|
|
1539
|
+
const document = await this.getAssignment(signerAccessCode);
|
|
1540
|
+
if (document.id !== documentId || assignmentId !== void 0 && document.assignment?.id !== assignmentId) {
|
|
1541
|
+
throw new ValidationError("Signer access code does not match the document or assignment");
|
|
1542
|
+
}
|
|
1543
|
+
return document;
|
|
1544
|
+
}
|
|
1525
1545
|
};
|
|
1526
1546
|
function validateDeclineReason(value) {
|
|
1527
1547
|
if (typeof value !== "string" || !value.trim()) {
|