@arslankhan/doc-forge 0.0.0-stage → 0.1.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.
Files changed (246) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +13 -0
  3. package/LICENSING.md +80 -0
  4. package/README.md +547 -2
  5. package/RELEASE.md +50 -0
  6. package/dist/binding-path.d.ts +15 -0
  7. package/dist/binding-path.d.ts.map +1 -0
  8. package/dist/binding-path.js +37 -0
  9. package/dist/binding-path.js.map +1 -0
  10. package/dist/binding.d.ts +91 -0
  11. package/dist/binding.d.ts.map +1 -0
  12. package/dist/binding.js +229 -0
  13. package/dist/binding.js.map +1 -0
  14. package/dist/designer/Canvas.d.ts +51 -0
  15. package/dist/designer/Canvas.d.ts.map +1 -0
  16. package/dist/designer/Canvas.js +188 -0
  17. package/dist/designer/Canvas.js.map +1 -0
  18. package/dist/designer/DocumentDesigner.d.ts +14 -0
  19. package/dist/designer/DocumentDesigner.d.ts.map +1 -0
  20. package/dist/designer/DocumentDesigner.js +351 -0
  21. package/dist/designer/DocumentDesigner.js.map +1 -0
  22. package/dist/designer/HtmlPreview.d.ts +9 -0
  23. package/dist/designer/HtmlPreview.d.ts.map +1 -0
  24. package/dist/designer/HtmlPreview.js +20 -0
  25. package/dist/designer/HtmlPreview.js.map +1 -0
  26. package/dist/designer/ImageBindingFields.d.ts +11 -0
  27. package/dist/designer/ImageBindingFields.d.ts.map +1 -0
  28. package/dist/designer/ImageBindingFields.js +106 -0
  29. package/dist/designer/ImageBindingFields.js.map +1 -0
  30. package/dist/designer/InvoiceFields.d.ts +13 -0
  31. package/dist/designer/InvoiceFields.d.ts.map +1 -0
  32. package/dist/designer/InvoiceFields.js +85 -0
  33. package/dist/designer/InvoiceFields.js.map +1 -0
  34. package/dist/designer/PreviewDataDialog.d.ts +13 -0
  35. package/dist/designer/PreviewDataDialog.d.ts.map +1 -0
  36. package/dist/designer/PreviewDataDialog.js +16 -0
  37. package/dist/designer/PreviewDataDialog.js.map +1 -0
  38. package/dist/designer/PropertiesPanel.d.ts +15 -0
  39. package/dist/designer/PropertiesPanel.d.ts.map +1 -0
  40. package/dist/designer/PropertiesPanel.js +63 -0
  41. package/dist/designer/PropertiesPanel.js.map +1 -0
  42. package/dist/designer/ReportFields.d.ts +14 -0
  43. package/dist/designer/ReportFields.d.ts.map +1 -0
  44. package/dist/designer/ReportFields.js +257 -0
  45. package/dist/designer/ReportFields.js.map +1 -0
  46. package/dist/designer/StyleFields.d.ts +16 -0
  47. package/dist/designer/StyleFields.d.ts.map +1 -0
  48. package/dist/designer/StyleFields.js +138 -0
  49. package/dist/designer/StyleFields.js.map +1 -0
  50. package/dist/designer/TextBindingFields.d.ts +11 -0
  51. package/dist/designer/TextBindingFields.d.ts.map +1 -0
  52. package/dist/designer/TextBindingFields.js +105 -0
  53. package/dist/designer/TextBindingFields.js.map +1 -0
  54. package/dist/designer/Toolbar.d.ts +52 -0
  55. package/dist/designer/Toolbar.d.ts.map +1 -0
  56. package/dist/designer/Toolbar.js +62 -0
  57. package/dist/designer/Toolbar.js.map +1 -0
  58. package/dist/designer/Toolbox.d.ts +8 -0
  59. package/dist/designer/Toolbox.d.ts.map +1 -0
  60. package/dist/designer/Toolbox.js +43 -0
  61. package/dist/designer/Toolbox.js.map +1 -0
  62. package/dist/designer/border-preview.d.ts +15 -0
  63. package/dist/designer/border-preview.d.ts.map +1 -0
  64. package/dist/designer/border-preview.js +34 -0
  65. package/dist/designer/border-preview.js.map +1 -0
  66. package/dist/designer/history.d.ts +13 -0
  67. package/dist/designer/history.d.ts.map +1 -0
  68. package/dist/designer/history.js +51 -0
  69. package/dist/designer/history.js.map +1 -0
  70. package/dist/designer/index.d.ts +5 -0
  71. package/dist/designer/index.d.ts.map +1 -0
  72. package/dist/designer/index.js +3 -0
  73. package/dist/designer/index.js.map +1 -0
  74. package/dist/designer/page-geometry.d.ts +35 -0
  75. package/dist/designer/page-geometry.d.ts.map +1 -0
  76. package/dist/designer/page-geometry.js +123 -0
  77. package/dist/designer/page-geometry.js.map +1 -0
  78. package/dist/designer/styles.d.ts +3 -0
  79. package/dist/designer/styles.d.ts.map +1 -0
  80. package/dist/designer/styles.js +594 -0
  81. package/dist/designer/styles.js.map +1 -0
  82. package/dist/designer/template-edits.d.ts +26 -0
  83. package/dist/designer/template-edits.d.ts.map +1 -0
  84. package/dist/designer/template-edits.js +323 -0
  85. package/dist/designer/template-edits.js.map +1 -0
  86. package/dist/designer/theme.d.ts +31 -0
  87. package/dist/designer/theme.d.ts.map +1 -0
  88. package/dist/designer/theme.js +92 -0
  89. package/dist/designer/theme.js.map +1 -0
  90. package/dist/examples/bound-invoice.d.ts +143 -0
  91. package/dist/examples/bound-invoice.d.ts.map +1 -0
  92. package/dist/examples/bound-invoice.js +99 -0
  93. package/dist/examples/bound-invoice.js.map +1 -0
  94. package/dist/examples/full-invoice-data.d.ts +81 -0
  95. package/dist/examples/full-invoice-data.d.ts.map +1 -0
  96. package/dist/examples/full-invoice-data.js +86 -0
  97. package/dist/examples/full-invoice-data.js.map +1 -0
  98. package/dist/examples/full-invoice.d.ts +402 -0
  99. package/dist/examples/full-invoice.d.ts.map +1 -0
  100. package/dist/examples/full-invoice.js +199 -0
  101. package/dist/examples/full-invoice.js.map +1 -0
  102. package/dist/examples/invoice-data.d.ts +51 -0
  103. package/dist/examples/invoice-data.d.ts.map +1 -0
  104. package/dist/examples/invoice-data.js +51 -0
  105. package/dist/examples/invoice-data.js.map +1 -0
  106. package/dist/examples/invoice.d.ts +90 -0
  107. package/dist/examples/invoice.d.ts.map +1 -0
  108. package/dist/examples/invoice.js +62 -0
  109. package/dist/examples/invoice.js.map +1 -0
  110. package/dist/examples/jobs-report-data.d.ts +84 -0
  111. package/dist/examples/jobs-report-data.d.ts.map +1 -0
  112. package/dist/examples/jobs-report-data.js +79 -0
  113. package/dist/examples/jobs-report-data.js.map +1 -0
  114. package/dist/examples/jobs-report.d.ts +182 -0
  115. package/dist/examples/jobs-report.d.ts.map +1 -0
  116. package/dist/examples/jobs-report.js +96 -0
  117. package/dist/examples/jobs-report.js.map +1 -0
  118. package/dist/index.d.ts +31 -0
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +21 -0
  121. package/dist/index.js.map +1 -0
  122. package/dist/invoice/calculate.d.ts +59 -0
  123. package/dist/invoice/calculate.d.ts.map +1 -0
  124. package/dist/invoice/calculate.js +270 -0
  125. package/dist/invoice/calculate.js.map +1 -0
  126. package/dist/invoice/context.d.ts +15 -0
  127. package/dist/invoice/context.d.ts.map +1 -0
  128. package/dist/invoice/context.js +79 -0
  129. package/dist/invoice/context.js.map +1 -0
  130. package/dist/invoice/format.d.ts +10 -0
  131. package/dist/invoice/format.d.ts.map +1 -0
  132. package/dist/invoice/format.js +95 -0
  133. package/dist/invoice/format.js.map +1 -0
  134. package/dist/license/capabilities.d.ts +17 -0
  135. package/dist/license/capabilities.d.ts.map +1 -0
  136. package/dist/license/capabilities.js +46 -0
  137. package/dist/license/capabilities.js.map +1 -0
  138. package/dist/license/client.d.ts +109 -0
  139. package/dist/license/client.d.ts.map +1 -0
  140. package/dist/license/client.js +346 -0
  141. package/dist/license/client.js.map +1 -0
  142. package/dist/license/codec.d.ts +5 -0
  143. package/dist/license/codec.d.ts.map +1 -0
  144. package/dist/license/codec.js +26 -0
  145. package/dist/license/codec.js.map +1 -0
  146. package/dist/license/errors.d.ts +11 -0
  147. package/dist/license/errors.d.ts.map +1 -0
  148. package/dist/license/errors.js +19 -0
  149. package/dist/license/errors.js.map +1 -0
  150. package/dist/license/features.d.ts +20 -0
  151. package/dist/license/features.d.ts.map +1 -0
  152. package/dist/license/features.js +28 -0
  153. package/dist/license/features.js.map +1 -0
  154. package/dist/license/index.d.ts +16 -0
  155. package/dist/license/index.d.ts.map +1 -0
  156. package/dist/license/index.js +9 -0
  157. package/dist/license/index.js.map +1 -0
  158. package/dist/license/provider.d.ts +59 -0
  159. package/dist/license/provider.d.ts.map +1 -0
  160. package/dist/license/provider.js +150 -0
  161. package/dist/license/provider.js.map +1 -0
  162. package/dist/license/redact.d.ts +4 -0
  163. package/dist/license/redact.d.ts.map +1 -0
  164. package/dist/license/redact.js +15 -0
  165. package/dist/license/redact.js.map +1 -0
  166. package/dist/license/store.d.ts +26 -0
  167. package/dist/license/store.d.ts.map +1 -0
  168. package/dist/license/store.js +90 -0
  169. package/dist/license/store.js.map +1 -0
  170. package/dist/license/token.d.ts +45 -0
  171. package/dist/license/token.d.ts.map +1 -0
  172. package/dist/license/token.js +195 -0
  173. package/dist/license/token.js.map +1 -0
  174. package/dist/pdf/browser-blocked.d.ts +12 -0
  175. package/dist/pdf/browser-blocked.d.ts.map +1 -0
  176. package/dist/pdf/browser-blocked.js +25 -0
  177. package/dist/pdf/browser-blocked.js.map +1 -0
  178. package/dist/pdf/browser.d.ts +12 -0
  179. package/dist/pdf/browser.d.ts.map +1 -0
  180. package/dist/pdf/browser.js +69 -0
  181. package/dist/pdf/browser.js.map +1 -0
  182. package/dist/pdf/errors.d.ts +6 -0
  183. package/dist/pdf/errors.d.ts.map +1 -0
  184. package/dist/pdf/errors.js +11 -0
  185. package/dist/pdf/errors.js.map +1 -0
  186. package/dist/pdf/index.d.ts +10 -0
  187. package/dist/pdf/index.d.ts.map +1 -0
  188. package/dist/pdf/index.js +9 -0
  189. package/dist/pdf/index.js.map +1 -0
  190. package/dist/pdf/options.d.ts +143 -0
  191. package/dist/pdf/options.d.ts.map +1 -0
  192. package/dist/pdf/options.js +322 -0
  193. package/dist/pdf/options.js.map +1 -0
  194. package/dist/pdf/render-pdf.d.ts +13 -0
  195. package/dist/pdf/render-pdf.d.ts.map +1 -0
  196. package/dist/pdf/render-pdf.js +195 -0
  197. package/dist/pdf/render-pdf.js.map +1 -0
  198. package/dist/render/appearance.d.ts +25 -0
  199. package/dist/render/appearance.d.ts.map +1 -0
  200. package/dist/render/appearance.js +149 -0
  201. package/dist/render/appearance.js.map +1 -0
  202. package/dist/render/css.d.ts +17 -0
  203. package/dist/render/css.d.ts.map +1 -0
  204. package/dist/render/css.js +170 -0
  205. package/dist/render/css.js.map +1 -0
  206. package/dist/render/errors.d.ts +6 -0
  207. package/dist/render/errors.d.ts.map +1 -0
  208. package/dist/render/errors.js +11 -0
  209. package/dist/render/errors.js.map +1 -0
  210. package/dist/render/escape.d.ts +7 -0
  211. package/dist/render/escape.d.ts.map +1 -0
  212. package/dist/render/escape.js +27 -0
  213. package/dist/render/escape.js.map +1 -0
  214. package/dist/render/image-policy.d.ts +21 -0
  215. package/dist/render/image-policy.d.ts.map +1 -0
  216. package/dist/render/image-policy.js +62 -0
  217. package/dist/render/image-policy.js.map +1 -0
  218. package/dist/render/render-html.d.ts +28 -0
  219. package/dist/render/render-html.d.ts.map +1 -0
  220. package/dist/render/render-html.js +364 -0
  221. package/dist/render/render-html.js.map +1 -0
  222. package/dist/render/render-report.d.ts +23 -0
  223. package/dist/render/render-report.d.ts.map +1 -0
  224. package/dist/render/render-report.js +313 -0
  225. package/dist/render/render-report.js.map +1 -0
  226. package/dist/report/process.d.ts +48 -0
  227. package/dist/report/process.d.ts.map +1 -0
  228. package/dist/report/process.js +347 -0
  229. package/dist/report/process.js.map +1 -0
  230. package/dist/schema.d.ts +30 -0
  231. package/dist/schema.d.ts.map +1 -0
  232. package/dist/schema.js +8 -0
  233. package/dist/schema.js.map +1 -0
  234. package/dist/serialize.d.ts +13 -0
  235. package/dist/serialize.d.ts.map +1 -0
  236. package/dist/serialize.js +42 -0
  237. package/dist/serialize.js.map +1 -0
  238. package/dist/types.d.ts +335 -0
  239. package/dist/types.d.ts.map +1 -0
  240. package/dist/types.js +40 -0
  241. package/dist/types.js.map +1 -0
  242. package/dist/validate.d.ts +15 -0
  243. package/dist/validate.d.ts.map +1 -0
  244. package/dist/validate.js +977 -0
  245. package/dist/validate.js.map +1 -0
  246. package/package.json +105 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ This version has not been published.
6
+
7
+ - Prepare the library as an installable ESM package with typed entry points for the core API, the React designer, license checks, and Node.js PDF export.
8
+ - Add a license client that stays unconfigured until a host supplies a public verification key and a license provider. Existing document features stay available while enforcement is off.
9
+ - Document the commercial licensing boundary. The software license itself is still a placeholder.
10
+
11
+ PDF export through `@arslankhan/doc-forge/pdf` is part of this version. It requires Playwright and Chromium in the host application.
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ The software license for DocForge has not been selected.
2
+
3
+ This file is a placeholder. It is not a grant of rights, and it is not legal advice. No open-source license, commercial license, or support agreement has been reviewed or approved for this package.
4
+
5
+ Until the owner replaces this file:
6
+
7
+ - Do not publish the package to npm.
8
+ - Do not treat the package as open source.
9
+ - Do not assume that a customer entitlement, a subscription, or a support agreement is included.
10
+
11
+ The npm manifest uses the SPDX value `UNLICENSED` for the same reason. Distribution settings, such as the package name and whether the package is public, are separate from both this software license and a customer's purchased feature entitlement.
12
+
13
+ See LICENSING.md for the technical license-client design and the payment boundary.
package/LICENSING.md ADDED
@@ -0,0 +1,80 @@
1
+ # Commercial licensing
2
+
3
+ This note describes how DocForge is meant to be licensed and sold. It is not legal advice, and it is not a statement that any license has been reviewed or approved. The owner must choose the software license, the commercial terms, and the support terms before publication.
4
+
5
+ Three different things are easy to mix together:
6
+
7
+ | Topic | What it controls | Where it lives |
8
+ | --- | --- | --- |
9
+ | Software license | Whether someone may copy, modify, or redistribute the DocForge source and package | `LICENSE`, chosen by the owner |
10
+ | Package distribution | Whether the npm package is public or private, and which name it uses | `package.json` `name` and `npm publish` access |
11
+ | Customer entitlement | Which paid features a customer may use | Signed license token from the license service |
12
+ | Support agreement | Response times, consulting, or other services | A separate contract, not this package |
13
+
14
+ `package.json` currently uses the SPDX value `UNLICENSED`. That means npm should not treat this package as open source. It does not by itself describe the commercial terms. Replace `LICENSE` and the SPDX value only after the owner has selected the terms.
15
+
16
+ ## What the package does
17
+
18
+ The license client can activate a key, store a signed token, verify that token, and report feature entitlements. With the default `enforcement: "off"`, every registered feature still reports as available. Existing rendering, invoices, reports, the designer, and PDF export keep working. Nothing in the renderers consults the license client.
19
+
20
+ Activation stays `unconfigured` until the host supplies all of the following:
21
+
22
+ - `productId`
23
+ - `issuer`
24
+ - `audience`
25
+ - one or more P-256 public keys (`spki`)
26
+ - a `LicenseProvider` that talks to the real license service
27
+
28
+ There is no built-in license server URL, payment provider, or private signing key. `createMockLicenseProvider()` is a test double. It cannot mint a token that this package will trust unless the test also produces a signature with a private key that stays outside the package.
29
+
30
+ ## Token verification
31
+
32
+ Tokens are compact JWS values signed with ES256 (ECDSA P-256 and SHA-256). This package verifies them with Web Crypto and the public key the host configures. The matching private key stays on the license server.
33
+
34
+ A token is accepted only when all of these checks pass:
35
+
36
+ - `alg` is exactly `ES256`
37
+ - the signature matches a configured `kid`
38
+ - `iss`, `aud`, and `product` match the host configuration
39
+ - `exp` has not passed, allowing the configured clock skew
40
+ - `entitlements` is an array of feature names
41
+
42
+ A field such as `isPremium: true` grants nothing. Entitlements that are not in `LICENSE_FEATURES` are reported as unrecognized and are not enabled. The client does not expand a `plan` name through a local table. The license server should put the feature list in the signed `entitlements` claim. `entitlementsForPlan()` is a helper for that server, not an authorization check.
43
+
44
+ Key rotation: publish the new public key with a new `kid`, include both keys in the client configuration until old tokens expire, then remove the old key. An unknown `kid` is an invalid token.
45
+
46
+ Revocation: the license service tells the client during activate or refresh. The host can also pass token ids it received from that service as `revokedTokenIds`. A browser-supplied list is only as trustworthy as the browser. Offline, a signature-valid token remains usable until `exp`, and `revocationUnknown` is true. A network failure sets status `network_unavailable`. It does not set `invalid`.
47
+
48
+ Suggested refresh interval: 24 hours, which is the client default. The token's own `exp` is the hard stop. Choose both when the license server is built.
49
+
50
+ ## Browser and server trust
51
+
52
+ Anyone can read the React designer bundle and skip a check that runs only in the browser. Client-side `hasFeature()` is a product signal, not source-code protection. Do not rely on it to hide premium algorithms.
53
+
54
+ For PDF export, verify the license in the Node.js process that calls `@arslankhan/doc-forge/pdf`, or inside the license service that process calls. That process is the trust boundary. The designer bundle does not import Playwright, and browser builds of `@arslankhan/doc-forge/pdf` resolve to an entry that does not import Playwright either.
55
+
56
+ License records use a host-supplied store. They are not written into template JSON. The browser store uses `localStorage` key `doc-forge-license` only when the host creates it in the browser. Server rendering does not touch `window`.
57
+
58
+ Do not log license keys or signed tokens. `redactSecret()` keeps only the last four characters of a secret.
59
+
60
+ ## Payments
61
+
62
+ This package does not collect or store card data, and it does not contain a checkout.
63
+
64
+ A separate backend should:
65
+
66
+ 1. Receive a payment event from the payment provider.
67
+ 2. Verify the webhook signature with the provider's secret. That secret is not part of this npm package.
68
+ 3. Store the event id and ignore a duplicate delivery.
69
+ 4. Create or update the customer license only after the provider confirms the payment.
70
+ 5. Choose entitlements for the paid plan and sign a license token with the private key.
71
+ 6. On renewal, sign a new token with a later `exp`.
72
+ 7. On cancellation, refund, or chargeback, revoke the token id and stop renewing it. The next online refresh returns `revoked`. Offline copies remain valid until they expire, which is why `exp` and the refresh interval have to be short enough for the product.
73
+
74
+ A browser redirect to a success page is not a payment confirmation. Do not activate a license from that redirect.
75
+
76
+ ## Feature names
77
+
78
+ `report.grouping`, `report.aggregates`, `designer.premium`, `styling.premium`, `pdf.export`, `tables.advanced`, and `support.commercial`.
79
+
80
+ Which plan includes which name is a product decision. Leave enforcement off until that decision is explicit. Turning enforcement on without a valid token makes `hasFeature()` return false. It still does not remove the underlying APIs.