docspring 4.1.0 → 4.3.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.
Files changed (169) hide show
  1. package/AGENTS.md +5 -4
  2. package/README.md +10 -6
  3. package/dist/ApiClient.js +3 -3
  4. package/dist/RequestSchemas.js +94 -15
  5. package/dist/WebhookSignature.js +86 -0
  6. package/dist/api/Client.js +193 -57
  7. package/dist/index.js +42 -0
  8. package/dist/model/AddTemplateFieldsRequest.js +2 -2
  9. package/dist/model/AiFieldNamingLanguage.js +1 -1
  10. package/dist/model/AuthenticationCheck.js +2 -2
  11. package/dist/model/BarcodeSymbology.js +1 -1
  12. package/dist/model/CheckCharacter.js +1 -1
  13. package/dist/model/CombinedFieldType.js +1 -1
  14. package/dist/model/CombinedPdf.js +4 -4
  15. package/dist/model/CombinedPdfFiles.js +2 -2
  16. package/dist/model/CombinedPdfList.js +2 -2
  17. package/dist/model/CombinedPdfSource.js +2 -2
  18. package/dist/model/CombinedPdfSourceInput.js +2 -2
  19. package/dist/model/CombinedPdfSourcePdf.js +2 -2
  20. package/dist/model/CombinedPdfSourceType.js +1 -1
  21. package/dist/model/CombinedPdfState.js +1 -1
  22. package/dist/model/CopyTemplateRequest.js +2 -2
  23. package/dist/model/CreateCombinedPdfRequest.js +3 -3
  24. package/dist/model/CreateCustomFileFromUploadRequest.js +2 -2
  25. package/dist/model/CreateFolderRequest.js +2 -2
  26. package/dist/model/CreateSignatureRequestEventRequest.js +2 -2
  27. package/dist/model/CreateSignatureRequestTokenRequest.js +2 -2
  28. package/dist/model/CreateSubmissionBatchRequest.js +2 -2
  29. package/dist/model/CreateSubmissionRequest.js +7 -7
  30. package/dist/model/CreateTemplatePreviewRequest.js +112 -0
  31. package/dist/model/CreateTemplateRequest.js +32 -13
  32. package/dist/model/CreateWebhookRequest.js +2 -2
  33. package/dist/model/CustomFile.js +2 -2
  34. package/dist/model/CustomFileList.js +2 -2
  35. package/dist/model/CustomFileSourcePdf.js +2 -2
  36. package/dist/model/ErrorCode.js +12 -2
  37. package/dist/model/ErrorDetail.js +3 -3
  38. package/dist/model/ErrorInfo.js +7 -7
  39. package/dist/model/ErrorResponse.js +2 -2
  40. package/dist/model/ExpirationInterval.js +1 -1
  41. package/dist/model/Field.js +3 -3
  42. package/dist/model/FieldComparisonCondition.js +2 -2
  43. package/dist/model/FieldComparisonOperator.js +1 -1
  44. package/dist/model/FieldDependency.js +2 -2
  45. package/dist/model/FieldDependencyInput.js +2 -2
  46. package/dist/model/FieldDisplayType.js +1 -1
  47. package/dist/model/FieldEqualsCondition.js +2 -2
  48. package/dist/model/FieldEqualsOperator.js +1 -1
  49. package/dist/model/FieldGroup.js +6 -6
  50. package/dist/model/FieldGroupInput.js +3 -3
  51. package/dist/model/FieldGroupType.js +1 -1
  52. package/dist/model/FieldInCondition.js +2 -2
  53. package/dist/model/FieldInput.js +3 -3
  54. package/dist/model/FieldOverride.js +2 -2
  55. package/dist/model/FieldPresenceCondition.js +2 -2
  56. package/dist/model/FieldPresenceOperator.js +1 -1
  57. package/dist/model/FieldRangeCondition.js +2 -2
  58. package/dist/model/FieldReimportState.js +1 -1
  59. package/dist/model/FieldSetupLogic.js +1 -1
  60. package/dist/model/FieldSetupNaming.js +1 -1
  61. package/dist/model/FieldSetupSource.js +1 -1
  62. package/dist/model/FieldType.js +1 -1
  63. package/dist/model/Folder.js +2 -2
  64. package/dist/model/FolderList.js +2 -2
  65. package/dist/model/GenerateFilesFormat.js +16 -1
  66. package/dist/model/GenerateSubmissionFilesRequest.js +4 -4
  67. package/dist/model/GeneratedFile.js +7 -7
  68. package/dist/model/GeneratedFileState.js +1 -1
  69. package/dist/model/HtmlEngineOptions.js +2 -2
  70. package/dist/model/HtmlEngineOptionsInput.js +2 -2
  71. package/dist/model/ImageGravity.js +1 -1
  72. package/dist/model/ImageScaleType.js +1 -1
  73. package/dist/model/ModelCodeLanguage.js +7 -2
  74. package/dist/model/MoveFolderRequest.js +2 -2
  75. package/dist/model/MoveTemplateRequest.js +2 -2
  76. package/dist/model/NumberConditionType.js +1 -1
  77. package/dist/model/OutputFormat.js +11 -1
  78. package/dist/model/PageFormat.js +1 -1
  79. package/dist/model/PageImage.js +2 -2
  80. package/dist/model/PageImages.js +2 -2
  81. package/dist/model/PredefinedField.js +2 -2
  82. package/dist/model/PredefinedFieldInput.js +2 -2
  83. package/dist/model/PublishTemplateVersionRequest.js +2 -2
  84. package/dist/model/RemoveTemplateFieldsRequest.js +2 -2
  85. package/dist/model/RenameFolderRequest.js +2 -2
  86. package/dist/model/ReorderTemplateFieldsRequest.js +2 -2
  87. package/dist/model/RestoreTemplateVersionRequest.js +2 -2
  88. package/dist/model/ShapeType.js +1 -1
  89. package/dist/model/SignatureRequest.js +2 -2
  90. package/dist/model/SignatureRequestAuthSecondFactorType.js +1 -1
  91. package/dist/model/SignatureRequestAuthType.js +1 -1
  92. package/dist/model/SignatureRequestEvent.js +2 -2
  93. package/dist/model/SignatureRequestEventType.js +1 -1
  94. package/dist/model/SignatureRequestInput.js +2 -2
  95. package/dist/model/SignatureRequestMessageType.js +1 -1
  96. package/dist/model/SignatureRequestState.js +1 -1
  97. package/dist/model/SignatureRequestToken.js +2 -2
  98. package/dist/model/SignatureRequestTokenType.js +1 -1
  99. package/dist/model/StringConditionType.js +1 -1
  100. package/dist/model/Submission.js +82 -82
  101. package/dist/model/SubmissionAction.js +2 -2
  102. package/dist/model/SubmissionActionState.js +1 -1
  103. package/dist/model/SubmissionActionType.js +1 -1
  104. package/dist/model/SubmissionBatch.js +9 -9
  105. package/dist/model/SubmissionBatchState.js +1 -1
  106. package/dist/model/SubmissionFiles.js +20 -2
  107. package/dist/model/SubmissionInput.js +7 -7
  108. package/dist/model/SubmissionList.js +6 -6
  109. package/dist/model/SubmissionSource.js +1 -1
  110. package/dist/model/SubmissionSourcePdf.js +2 -2
  111. package/dist/model/SubmissionState.js +1 -1
  112. package/dist/model/SubmissionSummary.js +343 -0
  113. package/dist/model/SubmissionValidation.js +2 -2
  114. package/dist/model/Template.js +95 -72
  115. package/dist/model/TemplateActor.js +4 -4
  116. package/dist/model/TemplateActorType.js +1 -1
  117. package/dist/model/TemplateDefaults.js +2 -2
  118. package/dist/model/TemplateDefaultsInput.js +2 -2
  119. package/dist/model/TemplateDiff.js +6 -6
  120. package/dist/model/TemplateDiffSummary.js +2 -2
  121. package/dist/model/TemplateDocument.js +49 -49
  122. package/dist/model/TemplateDocumentState.js +12 -2
  123. package/dist/model/TemplateDocumentSummary.js +152 -0
  124. package/dist/model/TemplateFieldChange.js +2 -2
  125. package/dist/model/TemplateFieldChanges.js +2 -2
  126. package/dist/model/TemplateFieldDependency.js +2 -2
  127. package/dist/model/TemplateFieldDependencyAction.js +1 -1
  128. package/dist/model/TemplateFieldDependencyCondition.js +2 -2
  129. package/dist/model/TemplateFieldDependencyConditionInput.js +2 -2
  130. package/dist/model/TemplateFieldDependencyInput.js +2 -2
  131. package/dist/model/TemplateFieldDependencyMatch.js +1 -1
  132. package/dist/model/TemplateFieldDependencyOperator.js +1 -1
  133. package/dist/model/TemplateFieldLogicStatus.js +1 -1
  134. package/dist/model/TemplateFieldMove.js +2 -2
  135. package/dist/model/TemplateFields.js +2 -2
  136. package/dist/model/TemplateFormMode.js +1 -1
  137. package/dist/model/TemplateModelCode.js +2 -2
  138. package/dist/model/TemplatePageAiError.js +1 -1
  139. package/dist/model/TemplatePageAiNamingStatus.js +1 -1
  140. package/dist/model/TemplatePageFieldsStatus.js +1 -1
  141. package/dist/model/TemplatePageImageStatus.js +1 -1
  142. package/dist/model/TemplatePageImages.js +2 -2
  143. package/dist/model/TemplatePageProcessingStatus.js +2 -2
  144. package/dist/model/TemplatePreview.js +211 -0
  145. package/dist/model/TemplatePreviewState.js +64 -0
  146. package/dist/model/TemplateSourcePdf.js +2 -2
  147. package/dist/model/TemplateSummary.js +29 -291
  148. package/dist/model/TemplateSummaryList.js +2 -2
  149. package/dist/model/TemplateType.js +7 -2
  150. package/dist/model/TemplateVersion.js +2 -2
  151. package/dist/model/TemplateVersionType.js +1 -1
  152. package/dist/model/TextAlignment.js +1 -1
  153. package/dist/model/TextOverflow.js +1 -1
  154. package/dist/model/TextVerticalAlignment.js +1 -1
  155. package/dist/model/Typeface.js +1 -1
  156. package/dist/model/UpdateSignatureRequestRequest.js +2 -2
  157. package/dist/model/UpdateTemplateDocumentRequest.js +8 -8
  158. package/dist/model/UpdateTemplateFieldsRequest.js +2 -2
  159. package/dist/model/UpdateTemplateRequest.js +26 -7
  160. package/dist/model/UpdateWebhookRequest.js +2 -2
  161. package/dist/model/UploadMethod.js +1 -1
  162. package/dist/model/UploadPresign.js +2 -2
  163. package/dist/model/UrlSourcePdf.js +2 -2
  164. package/dist/model/ValidateSubmissionRequest.js +7 -7
  165. package/dist/model/Webhook.js +2 -2
  166. package/dist/model/WebhookEventType.js +1 -1
  167. package/dist/model/WebhookList.js +2 -2
  168. package/dist/model/WebhookMode.js +1 -1
  169. package/package.json +4 -3
package/AGENTS.md CHANGED
@@ -69,8 +69,9 @@ keeps it.
69
69
  (https://docspring.com/docs/webhooks/overview/). A webhook created with API v2 sends events in API v2's format
70
70
  (version 4).
71
71
  - Verify each request's `X-DocSpring-Signature` header before acting on it: an HMAC-SHA256 of `{t}.{raw body}` with the
72
- webhook's signing secret, computed over the raw body exactly as received
73
- (https://docspring.com/docs/webhooks/verifying-signatures/).
72
+ webhook's signing secret, where `t` must be within 5 minutes
73
+ (https://docspring.com/docs/webhooks/verifying-signatures/). Pass the raw body exactly as received, not parsed JSON,
74
+ to `verifyWebhookSignature(payload, signatureHeader, secret)` (exported by the package), which returns true or false.
74
75
  - No webhook is sent when a submission starts waiting for credits.
75
76
 
76
77
  ## Signature requests
@@ -89,5 +90,5 @@ keeps it.
89
90
 
90
91
  - List methods return `data` and `next_cursor`: pass `next_cursor` as `cursor` to get the next page.
91
92
  - Responses can be newer than this SDK, because DocSpring adds fields and enum values to API v2 without a new
92
- version. The model object keeps a response field added to the API after this release as a property. The objects defined inside a model, such as a template's `document`, leave it out. Enum values in responses are strings, so a
93
- value added after this release comes back as it is: handle values you don't recognize.
93
+ version. The model object keeps a response field added to the API after this release as a property. The objects defined inside a model, such as a template's `document`, leave it out. An enum value added after this release comes
94
+ back as the API sent it: handle values you don't recognize.
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # DocSpring JavaScript SDK
2
2
 
3
3
  The official JavaScript client for the [DocSpring API](https://docspring.com/docs/api/). DocSpring fills PDF
4
- templates with your data, generates PDFs from HTML templates, combines PDFs and collects e-signatures.
4
+ forms with your data, generates PDFs and Word documents from HTML and Word templates, combines PDFs and collects
5
+ e-signatures.
5
6
 
6
7
  [Documentation](https://docspring.com/docs/) · [API reference](https://docspring.com/docs/api/) ·
7
8
  [npm](https://www.npmjs.com/package/docspring) · [Changelog](https://github.com/DocSpring/docspring-javascript/blob/main/CHANGELOG.md)
@@ -9,7 +10,7 @@ templates with your data, generates PDFs from HTML templates, combines PDFs and
9
10
  The code in this repository is generated from DocSpring's OpenAPI spec ([About this SDK](#about-this-sdk)). Issues and
10
11
  pull requests are welcome.
11
12
 
12
- Version 4.1.0.
13
+ Version 4.3.0.
13
14
 
14
15
  ## Install and configure
15
16
 
@@ -99,6 +100,7 @@ JavaScript code for every method.
99
100
  | [`createSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsubmission) | Generate a PDF |
100
101
  | [`createSubmissionBatch`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsubmissionbatch) | Generate PDFs in a batch |
101
102
  | [`createTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createtemplate) | Create a template |
103
+ | [`createTemplatePreview`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createtemplatepreview) | Preview a template with data |
102
104
  | [`createWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createwebhook) | Create a webhook |
103
105
  | [`deleteCustomFile`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletecustomfile) | Delete a custom file |
104
106
  | [`deleteFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletefolder) | Delete a folder |
@@ -119,6 +121,7 @@ JavaScript code for every method.
119
121
  | [`getTemplateDiff`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatediff) | Compare a version of a template with the one before it |
120
122
  | [`getTemplateModelCode`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatemodelcode) | Generate typed code for a template's submission data |
121
123
  | [`getTemplatePageImages`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatepageimages) | Get images of a template's pages |
124
+ | [`getTemplatePreview`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatepreview) | Get a template preview |
122
125
  | [`getTemplateSchema`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplateschema) | Get the JSON Schema of a template's submission data |
123
126
  | [`getWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getwebhook) | Get a webhook |
124
127
  | [`listCombinedPdfs`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listcombinedpdfs) | List combined PDFs |
@@ -139,11 +142,11 @@ JavaScript code for every method.
139
142
  | [`testAuthentication`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#testauthentication) | Test authentication |
140
143
  | [`updateSignatureRequest`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatesignaturerequest) | Update a signature request |
141
144
  | [`updateTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplate) | Update a template |
142
- | [`updateTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplatedocument) | Replace a template's PDF |
145
+ | [`updateTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplatedocument) | Replace a template's document |
143
146
  | [`updateTemplateFields`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplatefields) | Update a template's fields |
144
147
  | [`updateWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatewebhook) | Update a webhook |
145
- | [`uploadTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#uploadtemplate) | Create a PDF template from an uploaded PDF |
146
- | [`uploadTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#uploadtemplatedocument) | Replace a template's PDF with an uploaded PDF |
148
+ | [`uploadTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#uploadtemplate) | Create a template from an uploaded PDF or Word document |
149
+ | [`uploadTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#uploadtemplatedocument) | Replace a template's document with an uploaded file |
147
150
  | [`validateSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#validatesubmission) | Check a submission without creating it |
148
151
 
149
152
  ## Errors
@@ -161,7 +164,7 @@ existing code, such as removing or renaming a field, go in a new API version
161
164
  responses that are newer than it is:
162
165
 
163
166
  - The model object keeps a response field added to the API after this release as a property. The objects defined inside a model, such as a template's `document`, leave it out.
164
- - Enum values in responses are strings, so a value added to the API after this release comes back as it is: handle values you don't recognize.
167
+ - An enum value added to the API after this release comes back as the API sent it: handle values you don't recognize.
165
168
 
166
169
  Upgrade the SDK to read new fields and enum values. The [changelog](https://github.com/DocSpring/docspring-javascript/blob/main/CHANGELOG.md) lists
167
170
  what each release adds.
@@ -179,6 +182,7 @@ On top of the generated code, we add:
179
182
  - A client constructor that reads your credentials, region and host from the environment.
180
183
  - A nested object that's null in a response is `null` (stock OpenAPI Generator makes it `undefined`).
181
184
  - A rejected call's `response` is an object with the response's status, headers and body. Stock OpenAPI Generator attaches superagent's response, which holds the request's `Authorization` header, so logging the error printed the API token.
185
+ - `verifyWebhookSignature(payload, signatureHeader, secret)` checks a webhook request's `X-DocSpring-Signature` header, with a `{ tolerance, now }` options object.
182
186
 
183
187
  Each release regenerates every file, so a change made only here would be lost in the next one. Issues and pull
184
188
  requests are welcome all the same: [open an issue](https://github.com/DocSpring/docspring-javascript/issues) or a pull request, or email
package/dist/ApiClient.js CHANGED
@@ -14,7 +14,7 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
14
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
15
  function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); } /**
16
16
  * DocSpring API
17
- * Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures.
17
+ * Use DocSpring's API to fill PDF forms, generate PDFs and Word documents from HTML or Word templates, merge PDFs, and request legally binding e-signatures.
18
18
  *
19
19
  * The version of the OpenAPI document: v2
20
20
  *
@@ -38,7 +38,7 @@ function responseInfo(response) {
38
38
 
39
39
  /**
40
40
  * @module ApiClient
41
- * @version 4.1.0
41
+ * @version 4.3.0
42
42
  */
43
43
 
44
44
  /**
@@ -88,7 +88,7 @@ var ApiClient = /*#__PURE__*/function () {
88
88
  * @default {}
89
89
  */
90
90
  this.defaultHeaders = {
91
- 'User-Agent': 'docspring-javascript-4.1.0'
91
+ 'User-Agent': 'docspring-javascript-4.3.0'
92
92
  };
93
93
 
94
94
  /**
@@ -392,7 +392,7 @@ var _default = exports["default"] = {
392
392
  "name": {
393
393
  "type": "string",
394
394
  "minLength": 1,
395
- "maxLength": 255
395
+ "maxLength": 512
396
396
  },
397
397
  "parent_folder_id": {
398
398
  "type": ["string", "null"],
@@ -597,7 +597,7 @@ var _default = exports["default"] = {
597
597
  "uniqueItems": true,
598
598
  "items": {
599
599
  "type": "string",
600
- "enum": ["pdf", "png"]
600
+ "enum": ["pdf", "docx", "odt", "png"]
601
601
  }
602
602
  },
603
603
  "expires_in": {
@@ -629,7 +629,7 @@ var _default = exports["default"] = {
629
629
  },
630
630
  "email": {
631
631
  "type": ["string", "null"],
632
- "maxLength": 255
632
+ "maxLength": 254
633
633
  },
634
634
  "fields": {
635
635
  "type": "array",
@@ -726,7 +726,7 @@ var _default = exports["default"] = {
726
726
  "uniqueItems": true,
727
727
  "items": {
728
728
  "type": "string",
729
- "enum": ["pdf", "png"]
729
+ "enum": ["pdf", "docx", "odt", "png"]
730
730
  }
731
731
  },
732
732
  "submissions": {
@@ -758,7 +758,7 @@ var _default = exports["default"] = {
758
758
  "uniqueItems": true,
759
759
  "items": {
760
760
  "type": "string",
761
- "enum": ["pdf", "png"]
761
+ "enum": ["pdf", "docx", "odt", "png"]
762
762
  }
763
763
  },
764
764
  "expires_in": {
@@ -814,14 +814,18 @@ var _default = exports["default"] = {
814
814
  "name": {
815
815
  "type": "string",
816
816
  "minLength": 1,
817
- "maxLength": 255
817
+ "maxLength": 512
818
818
  },
819
819
  "description": {
820
820
  "type": ["string", "null"]
821
821
  },
822
822
  "template_type": {
823
823
  "type": "string",
824
- "enum": ["pdf", "html"]
824
+ "enum": ["pdf", "html", "docx"]
825
+ },
826
+ "output_format": {
827
+ "type": "string",
828
+ "enum": ["pdf", "docx", "odt"]
825
829
  },
826
830
  "parent_folder_id": {
827
831
  "type": ["string", "null"],
@@ -1131,6 +1135,9 @@ var _default = exports["default"] = {
1131
1135
  },
1132
1136
  "additionalProperties": false
1133
1137
  },
1138
+ "html_escape_data": {
1139
+ "type": "boolean"
1140
+ },
1134
1141
  "cache_id": {
1135
1142
  "type": "string",
1136
1143
  "minLength": 1,
@@ -1173,6 +1180,32 @@ var _default = exports["default"] = {
1173
1180
  }
1174
1181
  }
1175
1182
  },
1183
+ "createTemplatePreview": {
1184
+ "query": {
1185
+ "version": {
1186
+ "required": false,
1187
+ "schema": {
1188
+ "type": "string",
1189
+ "pattern": "^(\\d+(\\.\\d+(\\.\\d+)?)?|latest|draft)$",
1190
+ "x-pattern-message": "must be a version like 1.2.3 or 1, or latest or draft"
1191
+ }
1192
+ }
1193
+ },
1194
+ "body": {
1195
+ "mediaType": "application/json",
1196
+ "required": true,
1197
+ "schema": {
1198
+ "type": "object",
1199
+ "required": ["data"],
1200
+ "properties": {
1201
+ "data": {
1202
+ "type": "object"
1203
+ }
1204
+ },
1205
+ "additionalProperties": false
1206
+ }
1207
+ }
1208
+ },
1176
1209
  "createWebhook": {
1177
1210
  "body": {
1178
1211
  "mediaType": "application/json",
@@ -1182,7 +1215,7 @@ var _default = exports["default"] = {
1182
1215
  "properties": {
1183
1216
  "name": {
1184
1217
  "type": ["string", "null"],
1185
- "maxLength": 255
1218
+ "maxLength": 512
1186
1219
  },
1187
1220
  "url": {
1188
1221
  "type": "string",
@@ -1285,7 +1318,7 @@ var _default = exports["default"] = {
1285
1318
  "uniqueItems": true,
1286
1319
  "items": {
1287
1320
  "type": "string",
1288
- "enum": ["png"]
1321
+ "enum": ["pdf", "docx", "odt", "png"]
1289
1322
  }
1290
1323
  }
1291
1324
  },
@@ -1348,7 +1381,13 @@ var _default = exports["default"] = {
1348
1381
  "required": true,
1349
1382
  "schema": {
1350
1383
  "type": "string",
1351
- "enum": ["typescript", "javascript", "ruby", "python", "php", "java", "csharp", "elixir", "go"]
1384
+ "enum": ["typescript", "javascript", "ruby", "python", "php", "java", "csharp", "elixir", "go", "rust"]
1385
+ }
1386
+ },
1387
+ "just_types": {
1388
+ "required": false,
1389
+ "schema": {
1390
+ "type": "boolean"
1352
1391
  }
1353
1392
  }
1354
1393
  }
@@ -1365,6 +1404,7 @@ var _default = exports["default"] = {
1365
1404
  }
1366
1405
  }
1367
1406
  },
1407
+ "getTemplatePreview": {},
1368
1408
  "getTemplateSchema": {
1369
1409
  "query": {
1370
1410
  "version": {
@@ -1485,6 +1525,19 @@ var _default = exports["default"] = {
1485
1525
  "schema": {
1486
1526
  "type": "string"
1487
1527
  }
1528
+ },
1529
+ "state": {
1530
+ "required": false,
1531
+ "schema": {
1532
+ "type": "string",
1533
+ "enum": ["pending", "processed", "invalid_data", "error", "image_download_failed", "image_processing_failed", "waiting_for_signature_requests", "syntax_error", "insufficient_credits", "account_suspended", "license_revoked", "accidental", "declined"]
1534
+ }
1535
+ },
1536
+ "include_files": {
1537
+ "required": false,
1538
+ "schema": {
1539
+ "type": "boolean"
1540
+ }
1488
1541
  }
1489
1542
  }
1490
1543
  },
@@ -1541,6 +1594,19 @@ var _default = exports["default"] = {
1541
1594
  "schema": {
1542
1595
  "type": "string"
1543
1596
  }
1597
+ },
1598
+ "state": {
1599
+ "required": false,
1600
+ "schema": {
1601
+ "type": "string",
1602
+ "enum": ["pending", "processed", "invalid_data", "error", "image_download_failed", "image_processing_failed", "waiting_for_signature_requests", "syntax_error", "insufficient_credits", "account_suspended", "license_revoked", "accidental", "declined"]
1603
+ }
1604
+ },
1605
+ "include_files": {
1606
+ "required": false,
1607
+ "schema": {
1608
+ "type": "boolean"
1609
+ }
1544
1610
  }
1545
1611
  }
1546
1612
  },
@@ -1812,11 +1878,15 @@ var _default = exports["default"] = {
1812
1878
  "name": {
1813
1879
  "type": "string",
1814
1880
  "minLength": 1,
1815
- "maxLength": 255
1881
+ "maxLength": 512
1816
1882
  },
1817
1883
  "description": {
1818
1884
  "type": ["string", "null"]
1819
1885
  },
1886
+ "output_format": {
1887
+ "type": "string",
1888
+ "enum": ["pdf", "docx", "odt"]
1889
+ },
1820
1890
  "parent_folder_id": {
1821
1891
  "type": ["string", "null"],
1822
1892
  "minLength": 1
@@ -2158,6 +2228,9 @@ var _default = exports["default"] = {
2158
2228
  }
2159
2229
  },
2160
2230
  "additionalProperties": false
2231
+ },
2232
+ "html_escape_data": {
2233
+ "type": "boolean"
2161
2234
  }
2162
2235
  },
2163
2236
  "additionalProperties": false
@@ -2592,7 +2665,7 @@ var _default = exports["default"] = {
2592
2665
  "properties": {
2593
2666
  "name": {
2594
2667
  "type": ["string", "null"],
2595
- "maxLength": 255
2668
+ "maxLength": 512
2596
2669
  },
2597
2670
  "url": {
2598
2671
  "type": "string",
@@ -2678,7 +2751,7 @@ var _default = exports["default"] = {
2678
2751
  "name": {
2679
2752
  "type": "string",
2680
2753
  "minLength": 1,
2681
- "maxLength": 255
2754
+ "maxLength": 512
2682
2755
  },
2683
2756
  "description": {
2684
2757
  "type": "string"
@@ -2705,6 +2778,10 @@ var _default = exports["default"] = {
2705
2778
  "field_logic": {
2706
2779
  "type": "string",
2707
2780
  "enum": ["ai", "none"]
2781
+ },
2782
+ "output_format": {
2783
+ "type": "string",
2784
+ "enum": ["pdf", "docx", "odt"]
2708
2785
  }
2709
2786
  },
2710
2787
  "additionalProperties": false
@@ -2778,7 +2855,7 @@ var _default = exports["default"] = {
2778
2855
  "uniqueItems": true,
2779
2856
  "items": {
2780
2857
  "type": "string",
2781
- "enum": ["pdf", "png"]
2858
+ "enum": ["pdf", "docx", "odt", "png"]
2782
2859
  }
2783
2860
  },
2784
2861
  "expires_in": {
@@ -2810,7 +2887,7 @@ var _default = exports["default"] = {
2810
2887
  },
2811
2888
  "email": {
2812
2889
  "type": ["string", "null"],
2813
- "maxLength": 255
2890
+ "maxLength": 254
2814
2891
  },
2815
2892
  "fields": {
2816
2893
  "type": "array",
@@ -2897,6 +2974,7 @@ var _default = exports["default"] = {
2897
2974
  "GET /templates/{template_id}/fields": "listTemplateFields",
2898
2975
  "GET /templates/{template_id}/model_code": "getTemplateModelCode",
2899
2976
  "GET /templates/{template_id}/page_images": "getTemplatePageImages",
2977
+ "GET /templates/{template_id}/previews/{preview_id}": "getTemplatePreview",
2900
2978
  "GET /templates/{template_id}/schema": "getTemplateSchema",
2901
2979
  "GET /templates/{template_id}/submissions": "listTemplateSubmissions",
2902
2980
  "GET /uploads/presign": "getPresignUrl",
@@ -2919,6 +2997,7 @@ var _default = exports["default"] = {
2919
2997
  "POST /templates/{template_id}/fields/remove": "removeTemplateFields",
2920
2998
  "POST /templates/{template_id}/fields/reorder": "reorderTemplateFields",
2921
2999
  "POST /templates/{template_id}/move": "moveTemplate",
3000
+ "POST /templates/{template_id}/previews": "createTemplatePreview",
2922
3001
  "POST /templates/{template_id}/publish_version": "publishTemplateVersion",
2923
3002
  "POST /templates/{template_id}/restore_version": "restoreTemplateVersion",
2924
3003
  "POST /templates/{template_id}/submissions": "createSubmission",
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WEBHOOK_SIGNATURE_TOLERANCE = void 0;
7
+ exports.verifyWebhookSignature = verifyWebhookSignature;
8
+ var _crypto = _interopRequireDefault(require("crypto"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
16
+ /**
17
+ * Checks webhook requests' X-DocSpring-Signature header (https://docspring.com/docs/webhooks/verifying-signatures/).
18
+ * @module WebhookSignature
19
+ */
20
+
21
+ /**
22
+ * The number of seconds a webhook request's signature stays valid (verifyWebhookSignature)
23
+ * @type {Number}
24
+ */
25
+ var WEBHOOK_SIGNATURE_TOLERANCE = exports.WEBHOOK_SIGNATURE_TOLERANCE = 300;
26
+
27
+ /**
28
+ * Checks a webhook request's X-DocSpring-Signature header. Returns true when one of its v1 signatures is the
29
+ * HMAC-SHA256 of "{t}.{payload}" with the webhook's secret, and its timestamp t is at most `tolerance` seconds from
30
+ * `now`. Returns false for anything else, including a missing or malformed header.
31
+ * @param {String|Buffer} payload The request body exactly as it was received (Express: express.raw()), not parsed JSON.
32
+ * @param {String} signatureHeader The X-DocSpring-Signature header.
33
+ * @param {String} secret The webhook's signing secret.
34
+ * @param {Object} [options]
35
+ * @param {Number} [options.tolerance=300] How many seconds old (or early) the timestamp can be. 5 minutes by default.
36
+ * @param {Number} [options.now] The current Unix time in seconds, for tests. The system clock by default.
37
+ * @returns {Boolean}
38
+ */
39
+ function verifyWebhookSignature(payload, signatureHeader, secret) {
40
+ var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
41
+ _ref$tolerance = _ref.tolerance,
42
+ tolerance = _ref$tolerance === void 0 ? WEBHOOK_SIGNATURE_TOLERANCE : _ref$tolerance,
43
+ now = _ref.now;
44
+ var body;
45
+ if (typeof payload === 'string') {
46
+ body = Buffer.from(payload, 'utf8');
47
+ } else if (payload instanceof Uint8Array) {
48
+ body = Buffer.from(payload);
49
+ } else {
50
+ return false;
51
+ }
52
+ if (typeof signatureHeader !== 'string' || typeof secret !== 'string' || secret === '') return false;
53
+ var parts = signatureHeader.split(',').map(function (part) {
54
+ var trimmed = part.trim();
55
+ var separator = trimmed.indexOf('=');
56
+ return separator === -1 ? [trimmed, ''] : [trimmed.slice(0, separator), trimmed.slice(separator + 1)];
57
+ });
58
+ var timestampPart = parts.find(function (_ref2) {
59
+ var _ref3 = _slicedToArray(_ref2, 1),
60
+ key = _ref3[0];
61
+ return key === 't';
62
+ });
63
+ var signatures = parts.filter(function (_ref4) {
64
+ var _ref5 = _slicedToArray(_ref4, 2),
65
+ key = _ref5[0],
66
+ value = _ref5[1];
67
+ return key === 'v1' && value !== '';
68
+ }).map(function (_ref6) {
69
+ var _ref7 = _slicedToArray(_ref6, 2),
70
+ value = _ref7[1];
71
+ return value;
72
+ });
73
+ if (!timestampPart || !/^[0-9]+$/.test(timestampPart[1]) || signatures.length === 0) return false;
74
+ var timestamp = timestampPart[1];
75
+ var current = now === undefined || now === null ? Math.floor(Date.now() / 1000) : Number(now);
76
+ if (Math.abs(current - Number(timestamp)) > tolerance) return false;
77
+ var hmac = _crypto["default"].createHmac('sha256', secret);
78
+ hmac.update("".concat(timestamp, "."), 'utf8');
79
+ hmac.update(body);
80
+ var expected = Buffer.from(hmac.digest('hex'), 'utf8');
81
+ // Constant time, so a timing attack can't find a valid signature byte by byte
82
+ return signatures.some(function (signature) {
83
+ var actual = Buffer.from(signature, 'utf8');
84
+ return actual.length === expected.length && _crypto["default"].timingSafeEqual(actual, expected);
85
+ });
86
+ }