@cloudpdf/contract 3.0.0-next.11 → 3.0.0-next.13

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/index.js CHANGED
@@ -9,6 +9,13 @@ import {
9
9
  FormSnapshotSchema,
10
10
  MutationMetaSchema,
11
11
  PageTextSnapshotSchema,
12
+ ChangeAnalysisSchema,
13
+ DocumentVersionsSchema,
14
+ SignatureAbortResultSchema,
15
+ SignatureCompleteBodySchema,
16
+ SignatureCompleteResultSchema,
17
+ SignaturePreparedWireSchema,
18
+ SignatureSnapshotSchema,
12
19
  wireTemplates
13
20
  } from "@embedpdf/engine-core/wire";
14
21
  import { z } from "zod";
@@ -867,6 +874,32 @@ var documentPasswordHeader = {
867
874
  var looseJson = z.record(z.string(), z.unknown());
868
875
  var docCredentials = ["api-token", "doc-jwt"];
869
876
  var MutationResponseSchema = z.object({ meta: MutationMetaSchema }).passthrough();
877
+ var DocSigningParamsSchema = DocLayerParamsSchema.extend({
878
+ signingId: z.string().min(1)
879
+ });
880
+ var sha256Pattern = /^[0-9a-f]{64}$/;
881
+ var DocVersionParamsSchema = DocIdParamsSchema.extend({
882
+ sha: z.string().regex(sha256Pattern)
883
+ });
884
+ var DocVersionFieldParamsSchema = DocVersionParamsSchema.extend({
885
+ fieldKey: z.string().min(1)
886
+ });
887
+ var DocVersionDigestParamsSchema = DocVersionFieldParamsSchema.extend({
888
+ algorithm: z.enum(["sha1", "sha256", "sha384", "sha512"])
889
+ });
890
+ var DocVersionRevisionParamsSchema = DocVersionParamsSchema.extend({
891
+ index: z.coerce.number().int().min(0)
892
+ });
893
+ var LayerSignaturesAnalysisQuerySchema = z.object({
894
+ "since.signature": z.coerce.number().int().min(0).optional(),
895
+ "since.revision": z.coerce.number().int().min(0).optional(),
896
+ level: z.enum(["none", "lta", "fill", "annotate"]).optional()
897
+ });
898
+ var VersionAnalysisQuerySchema = LayerSignaturesAnalysisQuerySchema.extend({
899
+ until: z.coerce.number().int().min(0).optional(),
900
+ /** The judging policy version the caller expects — a cache key on this immutable URL, not an input. */
901
+ policy: z.coerce.number().int().min(1).optional()
902
+ });
870
903
  var docOperations = {
871
904
  "doc.head": {
872
905
  operationId: "doc.head",
@@ -916,6 +949,216 @@ var docOperations = {
916
949
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
917
950
  }
918
951
  },
952
+ "doc.signatures.list": {
953
+ operationId: "doc.signatures.list",
954
+ title: "List signatures",
955
+ summary: "The layer view of digital signatures: revisions, every signature field with its signed state, and the protection in force.",
956
+ method: "GET",
957
+ path: wireTemplates.layerSignatures,
958
+ credentials: docCredentials,
959
+ scope: [],
960
+ docCapabilities: ["doc.forms.read"],
961
+ requestHeaders: [documentPasswordHeader],
962
+ params: DocLayerParamsSchema,
963
+ responses: {
964
+ 200: { contentType: "application/json", schema: SignatureSnapshotSchema },
965
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
966
+ },
967
+ notes: "Describes the bytes the layer is over: the base version's signatures plus the layer's own edits as the last revision. Signed bytes (contents, digests, revision prefixes) are served per base version under /versions."
968
+ },
969
+ "doc.signatures.analysis": {
970
+ operationId: "doc.signatures.analysis",
971
+ title: "Analyze layer changes",
972
+ summary: "What the layer changed after a signature (or after any revision), judged against the restrictions in force.",
973
+ method: "GET",
974
+ path: wireTemplates.layerSignaturesAnalysis,
975
+ credentials: docCredentials,
976
+ scope: [],
977
+ docCapabilities: ["doc.forms.read"],
978
+ requestHeaders: [documentPasswordHeader],
979
+ params: DocLayerParamsSchema,
980
+ query: LayerSignaturesAnalysisQuerySchema,
981
+ responses: {
982
+ 200: { contentType: "application/json", schema: ChangeAnalysisSchema },
983
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
984
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
985
+ },
986
+ notes: "Exactly one of `since.signature=<index>` or `since.revision=<index>`; the layer's pending edits are the end. `level=fill|annotate|lta|none` evaluates exploratorily and never becomes a verdict. For history between two base revisions use the version analysis."
987
+ },
988
+ "doc.signatures.prepare": {
989
+ operationId: "doc.signatures.prepare",
990
+ title: "Prepare a signature",
991
+ summary: "Author and seal a signing candidate; returns the digest to sign and the version fences.",
992
+ method: "POST",
993
+ path: wireTemplates.layerSignaturesPrepare,
994
+ credentials: docCredentials,
995
+ scope: [],
996
+ docCapabilities: ["doc.sign"],
997
+ requestHeaders: [documentPasswordHeader],
998
+ params: DocLayerParamsSchema,
999
+ body: { contentType: "multipart/form-data" },
1000
+ responses: {
1001
+ 200: { contentType: "application/json", schema: SignaturePreparedWireSchema },
1002
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1003
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1004
+ 409: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1005
+ },
1006
+ notes: "The multipart envelope: a JSON `body` part (field, subFilter, digest, contentsSize, signer, certify, lock, appearance) and an optional `resource:<key>` PDF part the body's `appearance.resource` names. A certification (`certify.permission`) additionally requires `doc.sign.certify`. The layer is read-only until the signing completes, is aborted, or expires (15 minutes). A layer behind the document head cannot sign (StaleBase)."
1007
+ },
1008
+ "doc.signatures.complete": {
1009
+ operationId: "doc.signatures.complete",
1010
+ title: "Complete a signature",
1011
+ summary: "Install the CMS into the prepared candidate and publish the sealed bytes as the document's next base version.",
1012
+ method: "POST",
1013
+ path: wireTemplates.layerSignatureComplete,
1014
+ credentials: docCredentials,
1015
+ scope: [],
1016
+ docCapabilities: ["doc.sign"],
1017
+ requestHeaders: [documentPasswordHeader],
1018
+ params: DocSigningParamsSchema,
1019
+ body: { contentType: "application/json", schema: SignatureCompleteBodySchema },
1020
+ responses: {
1021
+ 200: { contentType: "application/json", schema: SignatureCompleteResultSchema },
1022
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1023
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1024
+ 409: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1025
+ },
1026
+ notes: "`cms` is the detached CMS over the prepared digest, base64. `expectedVersion` must be what prepare returned. Idempotent by signing id: the same CMS again answers `already-completed`. Every layer of the document then sits over the new version; refetch the manifest after a completion."
1027
+ },
1028
+ "doc.signatures.abort": {
1029
+ operationId: "doc.signatures.abort",
1030
+ title: "Abort a signature",
1031
+ summary: "Discard a pending signing candidate.",
1032
+ method: "DELETE",
1033
+ path: wireTemplates.layerSignatureAbort,
1034
+ credentials: docCredentials,
1035
+ scope: [],
1036
+ docCapabilities: ["doc.sign"],
1037
+ requestHeaders: [documentPasswordHeader],
1038
+ params: DocSigningParamsSchema,
1039
+ responses: {
1040
+ 200: { contentType: "application/json", schema: SignatureAbortResultSchema },
1041
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1042
+ }
1043
+ },
1044
+ "doc.versions.list": {
1045
+ operationId: "doc.versions.list",
1046
+ title: "List versions",
1047
+ summary: "The document's base versions, oldest first, and its head.",
1048
+ method: "GET",
1049
+ path: wireTemplates.docVersions,
1050
+ credentials: docCredentials,
1051
+ scope: [],
1052
+ docCapabilities: ["doc.open"],
1053
+ requestHeaders: [documentPasswordHeader],
1054
+ params: DocIdParamsSchema,
1055
+ responses: {
1056
+ 200: { contentType: "application/json", schema: DocumentVersionsSchema },
1057
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1058
+ },
1059
+ notes: "Every completed signature publishes a new version. Never cached: the list grows."
1060
+ },
1061
+ "doc.versions.signatures": {
1062
+ operationId: "doc.versions.signatures",
1063
+ title: "Version signatures",
1064
+ summary: "The signature snapshot of one base version (immutable).",
1065
+ method: "GET",
1066
+ path: wireTemplates.docVersionSignatures,
1067
+ credentials: docCredentials,
1068
+ scope: [],
1069
+ docCapabilities: ["doc.forms.read"],
1070
+ requestHeaders: [documentPasswordHeader],
1071
+ params: DocVersionParamsSchema,
1072
+ responses: {
1073
+ 200: { contentType: "application/json", schema: SignatureSnapshotSchema },
1074
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1075
+ }
1076
+ },
1077
+ "doc.versions.signatureContents": {
1078
+ operationId: "doc.versions.signatureContents",
1079
+ title: "Signature contents",
1080
+ summary: "The DER /Contents of a signed field in one base version (immutable).",
1081
+ method: "GET",
1082
+ path: wireTemplates.docVersionSignatureContents,
1083
+ credentials: docCredentials,
1084
+ scope: [],
1085
+ docCapabilities: ["doc.forms.read"],
1086
+ requestHeaders: [documentPasswordHeader],
1087
+ params: DocVersionFieldParamsSchema,
1088
+ responses: {
1089
+ 200: { contentType: "application/pkcs7-signature" },
1090
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1091
+ },
1092
+ notes: "`fieldKey` is the field's fully qualified name, token-text encoded (the same encoding attachment keys use)."
1093
+ },
1094
+ "doc.versions.signatureDigest": {
1095
+ operationId: "doc.versions.signatureDigest",
1096
+ title: "Signature digest",
1097
+ summary: "The digest of a signed field's /ByteRange in one base version (immutable).",
1098
+ method: "GET",
1099
+ path: wireTemplates.docVersionSignatureDigest,
1100
+ credentials: docCredentials,
1101
+ scope: [],
1102
+ docCapabilities: ["doc.forms.read"],
1103
+ requestHeaders: [documentPasswordHeader],
1104
+ params: DocVersionDigestParamsSchema,
1105
+ responses: {
1106
+ 200: { contentType: "application/octet-stream" },
1107
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1108
+ },
1109
+ notes: "What a CMS verifier compares its message digest to."
1110
+ },
1111
+ "doc.versions.analysis": {
1112
+ operationId: "doc.versions.analysis",
1113
+ title: "Analyze version history",
1114
+ summary: "What changed between two revisions of one base version (immutable).",
1115
+ method: "GET",
1116
+ path: wireTemplates.docVersionAnalysis,
1117
+ credentials: docCredentials,
1118
+ scope: [],
1119
+ docCapabilities: ["doc.forms.read"],
1120
+ requestHeaders: [documentPasswordHeader],
1121
+ params: DocVersionParamsSchema,
1122
+ query: VersionAnalysisQuerySchema,
1123
+ responses: {
1124
+ 200: { contentType: "application/json", schema: ChangeAnalysisSchema },
1125
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1126
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1127
+ },
1128
+ notes: "Exactly one of `since.signature` / `since.revision`; `until=<revision>` defaults to the last. The same answer for every layer and every caller."
1129
+ },
1130
+ "doc.versions.download": {
1131
+ operationId: "doc.versions.download",
1132
+ title: "Download a version",
1133
+ summary: "The bytes of one base version (immutable).",
1134
+ method: "GET",
1135
+ path: wireTemplates.docVersionDownload,
1136
+ credentials: docCredentials,
1137
+ scope: [],
1138
+ docCapabilities: ["doc.download"],
1139
+ requestHeaders: [documentPasswordHeader],
1140
+ params: DocVersionParamsSchema,
1141
+ responses: {
1142
+ 200: { contentType: "application/pdf" },
1143
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1144
+ }
1145
+ },
1146
+ "doc.versions.revision": {
1147
+ operationId: "doc.versions.revision",
1148
+ title: "Download a revision",
1149
+ summary: "The byte prefix of one revision of a base version: exactly what a signature over it signed (immutable).",
1150
+ method: "GET",
1151
+ path: wireTemplates.docVersionRevision,
1152
+ credentials: docCredentials,
1153
+ scope: [],
1154
+ docCapabilities: ["doc.download"],
1155
+ requestHeaders: [documentPasswordHeader],
1156
+ params: DocVersionRevisionParamsSchema,
1157
+ responses: {
1158
+ 200: { contentType: "application/pdf" },
1159
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1160
+ }
1161
+ },
919
1162
  "doc.render": {
920
1163
  operationId: "doc.render",
921
1164
  title: "Render page",
@@ -1036,6 +1279,42 @@ var docOperations = {
1036
1279
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1037
1280
  }
1038
1281
  },
1282
+ "doc.annotations.flatten": {
1283
+ operationId: "doc.annotations.flatten",
1284
+ title: "Flatten annotations",
1285
+ summary: "Flatten a chosen set of one page's annotations into its content \u2014 pages.flatten for a selection. Painted annotations are removed; ineligible ones report skipped.",
1286
+ method: "POST",
1287
+ path: wireTemplates.layerAnnotationItemsFlatten,
1288
+ credentials: docCredentials,
1289
+ scope: [],
1290
+ docCapabilities: ["doc.pages.modify", "doc.annotate.modify"],
1291
+ requestHeaders: [documentPasswordHeader],
1292
+ params: DocPageParamsSchema,
1293
+ body: { contentType: "application/json", schema: looseJson },
1294
+ responses: {
1295
+ 200: { contentType: "application/json", schema: MutationResponseSchema },
1296
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1297
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1298
+ }
1299
+ },
1300
+ "doc.annotations.exportAppearance": {
1301
+ operationId: "doc.annotations.exportAppearance",
1302
+ title: "Export annotation appearances",
1303
+ summary: "The chosen annotations' appearances as one single-page PDF sized to their union rect \u2014 vector, positions preserved. A read; the source is untouched.",
1304
+ method: "POST",
1305
+ path: wireTemplates.layerAnnotationItemsAppearance,
1306
+ credentials: docCredentials,
1307
+ scope: [],
1308
+ docCapabilities: ["doc.download"],
1309
+ requestHeaders: [documentPasswordHeader],
1310
+ params: DocPageParamsSchema,
1311
+ body: { contentType: "application/json", schema: looseJson },
1312
+ responses: {
1313
+ 200: { contentType: "application/pdf" },
1314
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1315
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1316
+ }
1317
+ },
1039
1318
  "doc.forms.get": {
1040
1319
  operationId: "doc.forms.get",
1041
1320
  title: "Get form snapshot",
@@ -1175,6 +1454,42 @@ var docOperations = {
1175
1454
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1176
1455
  }
1177
1456
  },
1457
+ "doc.pages.setName": {
1458
+ operationId: "doc.pages.setName",
1459
+ title: "Set page name",
1460
+ summary: "Register or rename a /Names /Pages entry (a named page). A page-structure mutation: the layout version advances.",
1461
+ method: "POST",
1462
+ path: wireTemplates.layerPagesNames,
1463
+ credentials: docCredentials,
1464
+ scope: [],
1465
+ docCapabilities: ["doc.pages.assemble"],
1466
+ requestHeaders: [documentPasswordHeader],
1467
+ params: DocLayerParamsSchema,
1468
+ body: { contentType: "application/json", schema: looseJson },
1469
+ responses: {
1470
+ 200: { contentType: "application/json", schema: MutationResponseSchema },
1471
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1472
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1473
+ }
1474
+ },
1475
+ "doc.pages.removeName": {
1476
+ operationId: "doc.pages.removeName",
1477
+ title: "Remove page name",
1478
+ summary: "Remove a /Names /Pages entry; the page itself stays.",
1479
+ method: "POST",
1480
+ path: wireTemplates.layerPagesNamesDelete,
1481
+ credentials: docCredentials,
1482
+ scope: [],
1483
+ docCapabilities: ["doc.pages.assemble"],
1484
+ requestHeaders: [documentPasswordHeader],
1485
+ params: DocLayerParamsSchema,
1486
+ body: { contentType: "application/json", schema: looseJson },
1487
+ responses: {
1488
+ 200: { contentType: "application/json", schema: MutationResponseSchema },
1489
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1490
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1491
+ }
1492
+ },
1178
1493
  "doc.pages.flatten": {
1179
1494
  operationId: "doc.pages.flatten",
1180
1495
  title: "Flatten pages",
@@ -1299,7 +1614,9 @@ var docsGroups = {
1299
1614
  "doc.forms": { title: "Forms" },
1300
1615
  "doc.metadata": { title: "Metadata" },
1301
1616
  "doc.pages": { title: "Pages" },
1302
- "doc.redactions": { title: "Redactions" }
1617
+ "doc.redactions": { title: "Redactions" },
1618
+ "doc.signatures": { title: "Digital signatures" },
1619
+ "doc.versions": { title: "Versions" }
1303
1620
  };
1304
1621
  export {
1305
1622
  ADMIN_DOCUMENT_LIST_DEFAULT_LIMIT,
@@ -1342,7 +1659,13 @@ export {
1342
1659
  DocIdParamsSchema,
1343
1660
  DocLayerParamsSchema,
1344
1661
  DocPageParamsSchema,
1662
+ DocSigningParamsSchema,
1663
+ DocVersionDigestParamsSchema,
1664
+ DocVersionFieldParamsSchema,
1665
+ DocVersionParamsSchema,
1666
+ DocVersionRevisionParamsSchema,
1345
1667
  DocumentStateSchema,
1668
+ LayerSignaturesAnalysisQuerySchema,
1346
1669
  ShareExchangeRequestSchema,
1347
1670
  ShareGrantCreateRequestSchema,
1348
1671
  ShareGrantListQuerySchema,
@@ -1355,6 +1678,7 @@ export {
1355
1678
  TenantUsageQuerySchema,
1356
1679
  TenantUsageResponseSchema,
1357
1680
  UploadPreferenceSchema,
1681
+ VersionAnalysisQuerySchema,
1358
1682
  adminCredentials,
1359
1683
  adminOperations,
1360
1684
  adminTenantScopes,