@cloudpdf/contract 3.0.0-next.12 → 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",
@@ -1371,7 +1614,9 @@ var docsGroups = {
1371
1614
  "doc.forms": { title: "Forms" },
1372
1615
  "doc.metadata": { title: "Metadata" },
1373
1616
  "doc.pages": { title: "Pages" },
1374
- "doc.redactions": { title: "Redactions" }
1617
+ "doc.redactions": { title: "Redactions" },
1618
+ "doc.signatures": { title: "Digital signatures" },
1619
+ "doc.versions": { title: "Versions" }
1375
1620
  };
1376
1621
  export {
1377
1622
  ADMIN_DOCUMENT_LIST_DEFAULT_LIMIT,
@@ -1414,7 +1659,13 @@ export {
1414
1659
  DocIdParamsSchema,
1415
1660
  DocLayerParamsSchema,
1416
1661
  DocPageParamsSchema,
1662
+ DocSigningParamsSchema,
1663
+ DocVersionDigestParamsSchema,
1664
+ DocVersionFieldParamsSchema,
1665
+ DocVersionParamsSchema,
1666
+ DocVersionRevisionParamsSchema,
1417
1667
  DocumentStateSchema,
1668
+ LayerSignaturesAnalysisQuerySchema,
1418
1669
  ShareExchangeRequestSchema,
1419
1670
  ShareGrantCreateRequestSchema,
1420
1671
  ShareGrantListQuerySchema,
@@ -1427,6 +1678,7 @@ export {
1427
1678
  TenantUsageQuerySchema,
1428
1679
  TenantUsageResponseSchema,
1429
1680
  UploadPreferenceSchema,
1681
+ VersionAnalysisQuerySchema,
1430
1682
  adminCredentials,
1431
1683
  adminOperations,
1432
1684
  adminTenantScopes,