@wildo-ai/platform-config-lib 1.1.11 → 1.1.12

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 (389) hide show
  1. package/dist/esm/_unimplemented/soft-warn.d.ts +24 -49
  2. package/dist/esm/_unimplemented/soft-warn.d.ts.map +1 -1
  3. package/dist/esm/_unimplemented/soft-warn.js +24 -49
  4. package/dist/esm/_unimplemented/soft-warn.js.map +1 -1
  5. package/dist/esm/blueprint/anchored-region.d.ts.map +1 -1
  6. package/dist/esm/blueprint/anchored-region.js.map +1 -1
  7. package/dist/esm/blueprint/blueprint.schemas.d.ts +0 -89
  8. package/dist/esm/blueprint/blueprint.schemas.d.ts.map +1 -1
  9. package/dist/esm/blueprint/blueprint.schemas.js.map +1 -1
  10. package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
  11. package/dist/esm/bootstrap/application-backend-env.contracts.js.map +1 -1
  12. package/dist/esm/bootstrap/application-creation-verification-env.contracts.d.ts.map +1 -1
  13. package/dist/esm/bootstrap/application-creation-verification-env.contracts.js.map +1 -1
  14. package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -1
  15. package/dist/esm/bootstrap/bootstrap-planner.js.map +1 -1
  16. package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
  17. package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
  18. package/dist/esm/bootstrap/bootstrap.schemas.d.ts +8 -1
  19. package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
  20. package/dist/esm/bootstrap/bootstrap.schemas.js +15 -1
  21. package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
  22. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +10 -2
  23. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
  24. package/dist/esm/bootstrap/platform-runtime-env.contracts.js +10 -2
  25. package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
  26. package/dist/esm/bootstrap/platform-store-preconnect.d.ts +21 -0
  27. package/dist/esm/bootstrap/platform-store-preconnect.d.ts.map +1 -1
  28. package/dist/esm/bootstrap/platform-store-preconnect.js +25 -0
  29. package/dist/esm/bootstrap/platform-store-preconnect.js.map +1 -1
  30. package/dist/esm/bootstrap/postgresql-owed-grants.contracts.d.ts +80 -0
  31. package/dist/esm/bootstrap/postgresql-owed-grants.contracts.d.ts.map +1 -0
  32. package/dist/esm/bootstrap/postgresql-owed-grants.contracts.js +81 -0
  33. package/dist/esm/bootstrap/postgresql-owed-grants.contracts.js.map +1 -0
  34. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts +41 -9
  35. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
  36. package/dist/esm/bootstrap/runtime-backing-service-access.js +77 -28
  37. package/dist/esm/bootstrap/runtime-backing-service-access.js.map +1 -1
  38. package/dist/esm/bootstrap/runtime-network-policy.d.ts +117 -12
  39. package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -1
  40. package/dist/esm/bootstrap/runtime-network-policy.js +222 -23
  41. package/dist/esm/bootstrap/runtime-network-policy.js.map +1 -1
  42. package/dist/esm/bootstrap/runtime-network-topology.d.ts +31 -4
  43. package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
  44. package/dist/esm/bootstrap/runtime-network-topology.js +43 -2
  45. package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
  46. package/dist/esm/bootstrap/runtime-platform-access.d.ts.map +1 -1
  47. package/dist/esm/bootstrap/runtime-platform-access.js.map +1 -1
  48. package/dist/esm/bootstrap/runtime-principal.contracts.d.ts +40 -2
  49. package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -1
  50. package/dist/esm/bootstrap/runtime-principal.contracts.js +66 -3
  51. package/dist/esm/bootstrap/runtime-principal.contracts.js.map +1 -1
  52. package/dist/esm/bootstrap/runtime-response-integrity.d.ts.map +1 -1
  53. package/dist/esm/bootstrap/runtime-response-integrity.js +3 -3
  54. package/dist/esm/bootstrap/runtime-response-integrity.js.map +1 -1
  55. package/dist/esm/bootstrap/runtime-secret-env.contracts.d.ts.map +1 -1
  56. package/dist/esm/bootstrap/runtime-secret-env.contracts.js.map +1 -1
  57. package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -1
  58. package/dist/esm/bootstrap/runtime-topology.contracts.js.map +1 -1
  59. package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts.map +1 -1
  60. package/dist/esm/bootstrap/wildo-owner-organization.contracts.js.map +1 -1
  61. package/dist/esm/canonical-json/rfc8785-canonical-json.d.ts.map +1 -1
  62. package/dist/esm/canonical-json/rfc8785-canonical-json.js.map +1 -1
  63. package/dist/esm/config-authoring.entry.d.ts.map +1 -1
  64. package/dist/esm/config-authoring.entry.js.map +1 -1
  65. package/dist/esm/credentials/credential-generator.service.d.ts.map +1 -1
  66. package/dist/esm/credentials/credential-generator.service.js.map +1 -1
  67. package/dist/esm/index.d.ts +5 -1
  68. package/dist/esm/index.d.ts.map +1 -1
  69. package/dist/esm/index.js +5 -1
  70. package/dist/esm/index.js.map +1 -1
  71. package/dist/esm/key-management/application-legacy-envelope-key.contracts.d.ts +119 -0
  72. package/dist/esm/key-management/application-legacy-envelope-key.contracts.d.ts.map +1 -0
  73. package/dist/esm/key-management/application-legacy-envelope-key.contracts.js +109 -0
  74. package/dist/esm/key-management/application-legacy-envelope-key.contracts.js.map +1 -0
  75. package/dist/esm/key-management/application-signing-key-rotation.contracts.d.ts +182 -0
  76. package/dist/esm/key-management/application-signing-key-rotation.contracts.d.ts.map +1 -0
  77. package/dist/esm/key-management/application-signing-key-rotation.contracts.js +145 -0
  78. package/dist/esm/key-management/application-signing-key-rotation.contracts.js.map +1 -0
  79. package/dist/esm/key-management/approval-seal-manifested-copy.d.ts +156 -0
  80. package/dist/esm/key-management/approval-seal-manifested-copy.d.ts.map +1 -0
  81. package/dist/esm/key-management/approval-seal-manifested-copy.js +617 -0
  82. package/dist/esm/key-management/approval-seal-manifested-copy.js.map +1 -0
  83. package/dist/esm/key-management/approval-seal-verifier.d.ts +101 -39
  84. package/dist/esm/key-management/approval-seal-verifier.d.ts.map +1 -1
  85. package/dist/esm/key-management/approval-seal-verifier.js +134 -12
  86. package/dist/esm/key-management/approval-seal-verifier.js.map +1 -1
  87. package/dist/esm/key-management/approval-seal.contracts.d.ts +12 -15
  88. package/dist/esm/key-management/approval-seal.contracts.d.ts.map +1 -1
  89. package/dist/esm/key-management/approval-seal.contracts.js +20 -0
  90. package/dist/esm/key-management/approval-seal.contracts.js.map +1 -1
  91. package/dist/esm/key-management/data-key.contracts.d.ts +0 -2
  92. package/dist/esm/key-management/data-key.contracts.d.ts.map +1 -1
  93. package/dist/esm/key-management/data-key.contracts.js.map +1 -1
  94. package/dist/esm/key-management/es256-jws.d.ts.map +1 -1
  95. package/dist/esm/key-management/es256-jws.js.map +1 -1
  96. package/dist/esm/key-management/key-provider.spi.d.ts +8 -1
  97. package/dist/esm/key-management/key-provider.spi.d.ts.map +1 -1
  98. package/dist/esm/key-management/key-provider.spi.js.map +1 -1
  99. package/dist/esm/key-management/keyring-rotation.contracts.d.ts +2 -12
  100. package/dist/esm/key-management/keyring-rotation.contracts.d.ts.map +1 -1
  101. package/dist/esm/key-management/keyring-rotation.contracts.js +3 -3
  102. package/dist/esm/key-management/keyring-rotation.contracts.js.map +1 -1
  103. package/dist/esm/key-management/keyring-status.contracts.d.ts +0 -7
  104. package/dist/esm/key-management/keyring-status.contracts.d.ts.map +1 -1
  105. package/dist/esm/key-management/keyring-status.contracts.js.map +1 -1
  106. package/dist/esm/key-management/pdf-incremental-update.d.ts +158 -0
  107. package/dist/esm/key-management/pdf-incremental-update.d.ts.map +1 -0
  108. package/dist/esm/key-management/pdf-incremental-update.js +730 -0
  109. package/dist/esm/key-management/pdf-incremental-update.js.map +1 -0
  110. package/dist/esm/key-management/pdf-truetype-font.d.ts +35 -0
  111. package/dist/esm/key-management/pdf-truetype-font.d.ts.map +1 -0
  112. package/dist/esm/key-management/pdf-truetype-font.js +152 -0
  113. package/dist/esm/key-management/pdf-truetype-font.js.map +1 -0
  114. package/dist/esm/key-management/qr-code.d.ts +38 -0
  115. package/dist/esm/key-management/qr-code.d.ts.map +1 -0
  116. package/dist/esm/key-management/qr-code.js +325 -0
  117. package/dist/esm/key-management/qr-code.js.map +1 -0
  118. package/dist/esm/key-management/signature-request.contracts.d.ts +0 -4
  119. package/dist/esm/key-management/signature-request.contracts.d.ts.map +1 -1
  120. package/dist/esm/key-management/signature-request.contracts.js.map +1 -1
  121. package/dist/esm/key-management/signing-log-export.contracts.d.ts +0 -1
  122. package/dist/esm/key-management/signing-log-export.contracts.d.ts.map +1 -1
  123. package/dist/esm/key-management/signing-log-export.contracts.js.map +1 -1
  124. package/dist/esm/key-management/vault-custody.contracts.d.ts +43 -0
  125. package/dist/esm/key-management/vault-custody.contracts.d.ts.map +1 -1
  126. package/dist/esm/key-management/vault-custody.contracts.js +66 -0
  127. package/dist/esm/key-management/vault-custody.contracts.js.map +1 -1
  128. package/dist/esm/lockfile/build-parallelism.d.ts.map +1 -1
  129. package/dist/esm/lockfile/build-parallelism.js.map +1 -1
  130. package/dist/esm/lockfile/canonical-json.d.ts +1 -1
  131. package/dist/esm/lockfile/canonical-json.d.ts.map +1 -1
  132. package/dist/esm/lockfile/canonical-json.js +1 -1
  133. package/dist/esm/lockfile/canonical-json.js.map +1 -1
  134. package/dist/esm/lockfile/file-lock-hold.d.ts.map +1 -1
  135. package/dist/esm/lockfile/file-lock-hold.js +2 -1
  136. package/dist/esm/lockfile/file-lock-hold.js.map +1 -1
  137. package/dist/esm/lockfile/lockfile-io.d.ts +6 -8
  138. package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
  139. package/dist/esm/lockfile/lockfile-io.js +6 -8
  140. package/dist/esm/lockfile/lockfile-io.js.map +1 -1
  141. package/dist/esm/lockfile/materialize-infra-section.d.ts +5 -6
  142. package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
  143. package/dist/esm/lockfile/materialize-infra-section.js +4 -5
  144. package/dist/esm/lockfile/materialize-infra-section.js.map +1 -1
  145. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +1 -247
  146. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
  147. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +1 -1
  148. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
  149. package/dist/esm/pnpm-settings/application-pnpm-settings.d.ts +146 -0
  150. package/dist/esm/pnpm-settings/application-pnpm-settings.d.ts.map +1 -0
  151. package/dist/esm/pnpm-settings/application-pnpm-settings.js +573 -0
  152. package/dist/esm/pnpm-settings/application-pnpm-settings.js.map +1 -0
  153. package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts.map +1 -1
  154. package/dist/esm/project-config/application-public-pricing-catalog.loader.js +15 -3
  155. package/dist/esm/project-config/application-public-pricing-catalog.loader.js.map +1 -1
  156. package/dist/esm/project-config/application-served-public-documents.loader.d.ts.map +1 -1
  157. package/dist/esm/project-config/application-served-public-documents.loader.js +16 -8
  158. package/dist/esm/project-config/application-served-public-documents.loader.js.map +1 -1
  159. package/dist/esm/project-config/backend-compliance-section.reader.d.ts +35 -0
  160. package/dist/esm/project-config/backend-compliance-section.reader.d.ts.map +1 -0
  161. package/dist/esm/project-config/backend-compliance-section.reader.js +123 -0
  162. package/dist/esm/project-config/backend-compliance-section.reader.js.map +1 -0
  163. package/dist/esm/project-config/backend-compliance-section.worker.d.ts +20 -0
  164. package/dist/esm/project-config/backend-compliance-section.worker.d.ts.map +1 -0
  165. package/dist/esm/project-config/backend-compliance-section.worker.js +78 -0
  166. package/dist/esm/project-config/backend-compliance-section.worker.js.map +1 -0
  167. package/dist/esm/project-config/config-module-resolution.d.ts +32 -0
  168. package/dist/esm/project-config/config-module-resolution.d.ts.map +1 -0
  169. package/dist/esm/project-config/config-module-resolution.js +33 -0
  170. package/dist/esm/project-config/config-module-resolution.js.map +1 -0
  171. package/dist/esm/project-config/define-framework-config.d.ts.map +1 -1
  172. package/dist/esm/project-config/define-framework-config.js.map +1 -1
  173. package/dist/esm/project-config/define-infra-env-config.d.ts +109 -55
  174. package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
  175. package/dist/esm/project-config/define-infra-env-config.js +108 -70
  176. package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
  177. package/dist/esm/project-config/define-minion-config.d.ts +26 -36
  178. package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
  179. package/dist/esm/project-config/define-minion-config.js +64 -25
  180. package/dist/esm/project-config/define-minion-config.js.map +1 -1
  181. package/dist/esm/project-config/define-saas-config.d.ts +41 -437
  182. package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
  183. package/dist/esm/project-config/define-saas-config.js +102 -94
  184. package/dist/esm/project-config/define-saas-config.js.map +1 -1
  185. package/dist/esm/project-config/define-worker-config.d.ts +10 -20
  186. package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
  187. package/dist/esm/project-config/define-worker-config.js +10 -12
  188. package/dist/esm/project-config/define-worker-config.js.map +1 -1
  189. package/dist/esm/project-config/hosted-infra-env-config.d.ts.map +1 -1
  190. package/dist/esm/project-config/hosted-infra-env-config.js +1 -1
  191. package/dist/esm/project-config/hosted-infra-env-config.js.map +1 -1
  192. package/dist/esm/project-config/index.d.ts +2 -0
  193. package/dist/esm/project-config/index.d.ts.map +1 -1
  194. package/dist/esm/project-config/index.js +2 -0
  195. package/dist/esm/project-config/index.js.map +1 -1
  196. package/dist/esm/project-config/loader-instances-zod.d.ts +19 -0
  197. package/dist/esm/project-config/loader-instances-zod.d.ts.map +1 -0
  198. package/dist/esm/project-config/loader-instances-zod.js +40 -0
  199. package/dist/esm/project-config/loader-instances-zod.js.map +1 -0
  200. package/dist/esm/project-config/loader.d.ts +131 -14
  201. package/dist/esm/project-config/loader.d.ts.map +1 -1
  202. package/dist/esm/project-config/loader.js +226 -12
  203. package/dist/esm/project-config/loader.js.map +1 -1
  204. package/dist/esm/project-config/minion-liveness.contracts.d.ts +131 -0
  205. package/dist/esm/project-config/minion-liveness.contracts.d.ts.map +1 -0
  206. package/dist/esm/project-config/minion-liveness.contracts.js +167 -0
  207. package/dist/esm/project-config/minion-liveness.contracts.js.map +1 -0
  208. package/dist/esm/project-config/minion-local-provider-registration.d.ts.map +1 -1
  209. package/dist/esm/project-config/minion-local-provider-registration.js.map +1 -1
  210. package/dist/esm/project-config/npm-version-range.d.ts.map +1 -1
  211. package/dist/esm/project-config/npm-version-range.js.map +1 -1
  212. package/dist/esm/project-config/owning-package-tsconfig.d.ts +7 -7
  213. package/dist/esm/project-config/owning-package-tsconfig.d.ts.map +1 -1
  214. package/dist/esm/project-config/owning-package-tsconfig.js +7 -7
  215. package/dist/esm/project-config/owning-package-tsconfig.js.map +1 -1
  216. package/dist/esm/project-config/provider-catalog-types.d.ts.map +1 -1
  217. package/dist/esm/project-config/provider-catalog-types.js.map +1 -1
  218. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
  219. package/dist/esm/project-config/provider-companion-discovery.js +3 -1
  220. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
  221. package/dist/esm/project-config/provider-runtime-artifacts.d.ts +71 -46
  222. package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
  223. package/dist/esm/project-config/provider-runtime-artifacts.js +150 -4
  224. package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
  225. package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts +0 -2
  226. package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts.map +1 -1
  227. package/dist/esm/project-config/shared/application-creation-verification.schemas.js.map +1 -1
  228. package/dist/esm/project-config/shared/application-modules.schemas.d.ts.map +1 -1
  229. package/dist/esm/project-config/shared/application-modules.schemas.js.map +1 -1
  230. package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -1
  231. package/dist/esm/project-config/shared/application-modules.utils.js.map +1 -1
  232. package/dist/esm/project-config/shared/auth.schemas.d.ts +0 -17
  233. package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -1
  234. package/dist/esm/project-config/shared/auth.schemas.js.map +1 -1
  235. package/dist/esm/project-config/shared/backing-service-servability.d.ts.map +1 -1
  236. package/dist/esm/project-config/shared/backing-service-servability.js.map +1 -1
  237. package/dist/esm/project-config/shared/backing-services.schemas.d.ts +9 -10
  238. package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
  239. package/dist/esm/project-config/shared/backing-services.schemas.js +13 -15
  240. package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
  241. package/dist/esm/project-config/shared/cdn.schemas.d.ts +0 -51
  242. package/dist/esm/project-config/shared/cdn.schemas.d.ts.map +1 -1
  243. package/dist/esm/project-config/shared/cdn.schemas.js.map +1 -1
  244. package/dist/esm/project-config/shared/csp-defaults.d.ts +34 -6
  245. package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -1
  246. package/dist/esm/project-config/shared/csp-defaults.js +52 -8
  247. package/dist/esm/project-config/shared/csp-defaults.js.map +1 -1
  248. package/dist/esm/project-config/shared/csp-emit.d.ts +60 -13
  249. package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
  250. package/dist/esm/project-config/shared/csp-emit.js +77 -24
  251. package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
  252. package/dist/esm/project-config/shared/csp.schemas.d.ts +72 -84
  253. package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
  254. package/dist/esm/project-config/shared/csp.schemas.js +40 -12
  255. package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
  256. package/dist/esm/project-config/shared/data-services.schemas.d.ts +0 -8
  257. package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -1
  258. package/dist/esm/project-config/shared/data-services.schemas.js.map +1 -1
  259. package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -1
  260. package/dist/esm/project-config/shared/env-example-defaults.js.map +1 -1
  261. package/dist/esm/project-config/shared/environment.schemas.d.ts +95 -8
  262. package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
  263. package/dist/esm/project-config/shared/environment.schemas.js +122 -10
  264. package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
  265. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +10 -4
  266. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
  267. package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
  268. package/dist/esm/project-config/shared/infra-service.schemas.d.ts.map +1 -1
  269. package/dist/esm/project-config/shared/infra-service.schemas.js.map +1 -1
  270. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts +1 -1
  271. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
  272. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js +1 -1
  273. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
  274. package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
  275. package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
  276. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts.map +1 -1
  277. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
  278. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts +20 -0
  279. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts.map +1 -1
  280. package/dist/esm/project-config/shared/minion-resource-access.validation.js +21 -2
  281. package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -1
  282. package/dist/esm/project-config/shared/object-storage-session-policy.d.ts.map +1 -1
  283. package/dist/esm/project-config/shared/object-storage-session-policy.js.map +1 -1
  284. package/dist/esm/project-config/shared/platform-key-management.schemas.d.ts +62 -36
  285. package/dist/esm/project-config/shared/platform-key-management.schemas.d.ts.map +1 -1
  286. package/dist/esm/project-config/shared/platform-key-management.schemas.js +105 -3
  287. package/dist/esm/project-config/shared/platform-key-management.schemas.js.map +1 -1
  288. package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
  289. package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
  290. package/dist/esm/project-config/shared/platform-storage.schemas.d.ts +2 -2
  291. package/dist/esm/project-config/shared/platform-storage.schemas.d.ts.map +1 -1
  292. package/dist/esm/project-config/shared/platform-storage.schemas.js +16 -2
  293. package/dist/esm/project-config/shared/platform-storage.schemas.js.map +1 -1
  294. package/dist/esm/project-config/shared/service-definitions.schemas.d.ts +21 -23
  295. package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
  296. package/dist/esm/project-config/shared/service-definitions.schemas.js +4 -5
  297. package/dist/esm/project-config/shared/service-definitions.schemas.js.map +1 -1
  298. package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts +0 -18
  299. package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts.map +1 -1
  300. package/dist/esm/project-config/shared/systems-of-record-env.schemas.js.map +1 -1
  301. package/dist/esm/project-config/static-asset-import-noop.d.ts +20 -3
  302. package/dist/esm/project-config/static-asset-import-noop.d.ts.map +1 -1
  303. package/dist/esm/project-config/static-asset-import-noop.js +36 -20
  304. package/dist/esm/project-config/static-asset-import-noop.js.map +1 -1
  305. package/dist/esm/registry/artifact-domain.schemas.d.ts +0 -5
  306. package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -1
  307. package/dist/esm/registry/artifact-domain.schemas.js.map +1 -1
  308. package/dist/esm/registry/digest.schemas.d.ts.map +1 -1
  309. package/dist/esm/registry/digest.schemas.js.map +1 -1
  310. package/dist/esm/registry/index.d.ts +2 -3
  311. package/dist/esm/registry/index.d.ts.map +1 -1
  312. package/dist/esm/registry/index.js +2 -3
  313. package/dist/esm/registry/index.js.map +1 -1
  314. package/dist/esm/registry/local-checkout-source.d.ts.map +1 -1
  315. package/dist/esm/registry/local-checkout-source.js.map +1 -1
  316. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts +1 -98
  317. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
  318. package/dist/esm/registry/lockfile-modules-section.schemas.js +1 -2
  319. package/dist/esm/registry/lockfile-modules-section.schemas.js.map +1 -1
  320. package/dist/esm/registry/module-artifact.schemas.d.ts +17 -17
  321. package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
  322. package/dist/esm/registry/module-artifact.schemas.js.map +1 -1
  323. package/dist/esm/registry/module-manifest.schemas.d.ts +151 -219
  324. package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
  325. package/dist/esm/registry/module-manifest.schemas.js +145 -13
  326. package/dist/esm/registry/module-manifest.schemas.js.map +1 -1
  327. package/dist/esm/registry/module-search.schemas.d.ts.map +1 -1
  328. package/dist/esm/registry/module-search.schemas.js.map +1 -1
  329. package/dist/esm/registry/registry-config.schemas.d.ts +0 -18
  330. package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
  331. package/dist/esm/registry/registry-config.schemas.js.map +1 -1
  332. package/dist/esm/registry/registry-defaults.constants.d.ts.map +1 -1
  333. package/dist/esm/registry/registry-defaults.constants.js.map +1 -1
  334. package/dist/esm/registry/registry-errors.d.ts +81 -3
  335. package/dist/esm/registry/registry-errors.d.ts.map +1 -1
  336. package/dist/esm/registry/registry-errors.js +185 -4
  337. package/dist/esm/registry/registry-errors.js.map +1 -1
  338. package/dist/esm/registry/registry-keys.schemas.d.ts.map +1 -1
  339. package/dist/esm/registry/registry-keys.schemas.js.map +1 -1
  340. package/dist/esm/registry/registry-section-schemas.constants.d.ts.map +1 -1
  341. package/dist/esm/registry/registry-section-schemas.constants.js.map +1 -1
  342. package/dist/esm/registry/registry-url-resolution.d.ts.map +1 -1
  343. package/dist/esm/registry/registry-url-resolution.js.map +1 -1
  344. package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
  345. package/dist/esm/release/framework-release.constants.js.map +1 -1
  346. package/dist/esm/schemas/framework-info.schemas.d.ts.map +1 -1
  347. package/dist/esm/schemas/framework-info.schemas.js.map +1 -1
  348. package/dist/esm/schemas/framework-secrets.schemas.d.ts +0 -7
  349. package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
  350. package/dist/esm/schemas/framework-secrets.schemas.js.map +1 -1
  351. package/dist/esm/schemas/platform-application-config.schemas.d.ts +1 -1
  352. package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -1
  353. package/dist/esm/schemas/platform-application-config.schemas.js.map +1 -1
  354. package/dist/esm/schemas/platform-application-secrets.schemas.d.ts +1 -1
  355. package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -1
  356. package/dist/esm/schemas/platform-application-secrets.schemas.js.map +1 -1
  357. package/dist/esm/schemas/platform-config.schemas.d.ts +2 -2
  358. package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
  359. package/dist/esm/schemas/platform-config.schemas.js.map +1 -1
  360. package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -1
  361. package/dist/esm/workspace-scope/application-subject-manifest.js.map +1 -1
  362. package/dist/esm/workspace-scope/index.d.ts.map +1 -1
  363. package/dist/esm/workspace-scope/index.js.map +1 -1
  364. package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -1
  365. package/dist/esm/workspace-scope/resolve-homes.js.map +1 -1
  366. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
  367. package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
  368. package/dist/esm/workspace-scope/workspace-scope-detector.d.ts.map +1 -1
  369. package/dist/esm/workspace-scope/workspace-scope-detector.js.map +1 -1
  370. package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -1
  371. package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -1
  372. package/dist/tsconfig.build.tsbuildinfo +1 -1
  373. package/package.json +12 -12
  374. package/dist/esm/_unimplemented/index.d.ts +0 -3
  375. package/dist/esm/_unimplemented/index.d.ts.map +0 -1
  376. package/dist/esm/_unimplemented/index.js +0 -3
  377. package/dist/esm/_unimplemented/index.js.map +0 -1
  378. package/dist/esm/_unimplemented/unimplemented-field-warning.d.ts +0 -137
  379. package/dist/esm/_unimplemented/unimplemented-field-warning.d.ts.map +0 -1
  380. package/dist/esm/_unimplemented/unimplemented-field-warning.js +0 -153
  381. package/dist/esm/_unimplemented/unimplemented-field-warning.js.map +0 -1
  382. package/dist/esm/project-config/shared/cdn.example.d.ts +0 -14
  383. package/dist/esm/project-config/shared/cdn.example.d.ts.map +0 -1
  384. package/dist/esm/project-config/shared/cdn.example.js +0 -38
  385. package/dist/esm/project-config/shared/cdn.example.js.map +0 -1
  386. package/dist/esm/project-config/shared/schema-version.schemas.d.ts +0 -15
  387. package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +0 -1
  388. package/dist/esm/project-config/shared/schema-version.schemas.js +0 -40
  389. package/dist/esm/project-config/shared/schema-version.schemas.js.map +0 -1
@@ -0,0 +1,617 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { APPROVAL_SEAL_MANIFESTATION_WORDS, ApprovalSealManifestationWord, interpolateLabelParams } from '@wildo-ai/saas-models';
3
+ import { canonicalizeJson } from '../canonical-json/rfc8785-canonical-json.js';
4
+ import { PdfDocumentReader, PdfIncrementalUpdateRefusal, PdfIncrementalUpdateRefusedError, appendPdfIncrementalUpdate, pdf, } from './pdf-incremental-update.js';
5
+ import { QrCodeTooLongError, QrErrorCorrection, encodeQrCode } from './qr-code.js';
6
+ import { TrueTypeFontUnreadableError, readTrueTypeFont } from './pdf-truetype-font.js';
7
+ /**
8
+ * # The manifested copy of an approved deliverable (#2907)
9
+ *
10
+ * A deliverable a person approved is frozen before anyone approves it (#2904), so it cannot carry its own approval. The
11
+ * manifested copy is a SEPARATE file: the frozen original, byte for byte, followed by one incremental-update section that
12
+ * adds a last page stating who approved it, when, and what the approval meant, and attaches the approval seal's JWS. The
13
+ * pattern is the signature manifestation of 21 CFR §11.50 (printed name, date and time, meaning), borrowed: no Part 11
14
+ * compliance is claimed.
15
+ *
16
+ * spec-cite: 21 CFR §11.50(a) (https://www.ecfr.gov/current/title-21/chapter-I/subchapter-A/part-11/subpart-C/section-11.50) — the three elements, paraphrased.
17
+ *
18
+ * ## Why the copy can be checked from the seal
19
+ *
20
+ * Everything appended is a PURE function of its inputs: the original's bytes, the seal's JWS, the approver's printed
21
+ * name, the page's words, the embedded font and the verification address. The copy carries every input but the
22
+ * original's bytes (its prefix) and the JWS (attached, and given to the verifier): the words, the name and the address in
23
+ * an attached `manifestation.json`, the font as its embedded font program. So a verifier splits the copy at its marker
24
+ * ({@link APPROVAL_SEAL_MANIFESTED_COPY_MARKER}, the LAST occurrence), takes those inputs back, rebuilds the copy and
25
+ * compares byte for byte: one changed byte anywhere in the appended section and the copy is not this seal's.
26
+ *
27
+ * What the rebuild cannot vouch for, and who does: the WORDS are the producing application's, so the host's record of the
28
+ * copy's SHA-256 (in a verification bundle) binds them; the FONT is pinned by its SHA-256
29
+ * ({@link APPROVAL_SEAL_MANIFESTATION_FONT_SHA256S}), so a font drawing other glyphs for the same codes is refused; the
30
+ * NAME is checked against the seal's approver disclosure when it is given; the ORIGINAL against the seal's commitment to
31
+ * the approved file.
32
+ *
33
+ * ## Words, names and the font
34
+ *
35
+ * The words are the application's (`backend_documents.approval_manifestation.*`, and the meaning and outcome vocabularies),
36
+ * in one language. Text is set in Liberation Sans Regular (SIL Open Font License 1.1, which permits embedding it in
37
+ * documents), embedded WHOLE as a CID font with Identity-H encoding and a ToUnicode map, so a reader extracts the text it
38
+ * shows. Embedding the whole font rather than a subset is deliberate: a subset differs with the text, so only the whole
39
+ * font can be pinned by one digest. A name or a word with a character the font has no glyph for refuses the copy; it is
40
+ * never printed approximately. The font covers Latin, Greek and Cyrillic.
41
+ *
42
+ * ## The attachments (ISO 32000-1 §7.11.4, §12.5.6.15; ISO 32000-2 §14.13)
43
+ *
44
+ * The JWS is attached twice over one file specification: by a file attachment annotation on the page, and at document
45
+ * level in the catalog's `EmbeddedFiles` name tree and its `AF` array (PDF 2.0 associated files, `AFRelationship`
46
+ * Supplement), where viewers list a document's attachments. `manifestation.json` is attached at document level only.
47
+ *
48
+ * spec-cite: ISO 32000-1:2008 §7.7.2 (document catalog), §7.7.4 (name dictionary, EmbeddedFiles), §7.9.6 (name trees),
49
+ * §7.11.3–§7.11.4 (file specifications, embedded file streams), §9.7.4 (CIDFontType2), §9.7.5.2 (Identity-H), §9.10.3
50
+ * (ToUnicode CMaps), §12.5.6.15 (file attachment annotations); ISO 32000-2:2020 §14.13 (associated files). Cited by section.
51
+ */
52
+ /** Opens the appended section: the copy is split at its LAST occurrence. Never produced by anything this module writes. */
53
+ export const APPROVAL_SEAL_MANIFESTED_COPY_MARKER = '\n%wildo-manifested-copy:2\n';
54
+ /** The layout version recorded in `manifestation.json`. */
55
+ export const APPROVAL_SEAL_MANIFESTATION_VERSION = 2;
56
+ /** The attached JWS's file name. */
57
+ export const APPROVAL_SEAL_MANIFESTED_COPY_ATTACHMENT_NAME = 'approval-seal.jws';
58
+ /** The attached record of the copy's inputs. */
59
+ export const APPROVAL_SEAL_MANIFESTATION_CONTEXT_NAME = 'manifestation.json';
60
+ /**
61
+ * The fonts a copy may embed, by the SHA-256 of the font program: Liberation Sans Regular 2.x (SIL Open Font License 1.1),
62
+ * the file `pdfjs-dist` ships as `standard_fonts/LiberationSans-Regular.ttf`. A font is added here, never replaced, so a
63
+ * copy made with an earlier font still verifies.
64
+ */
65
+ export const APPROVAL_SEAL_MANIFESTATION_FONT_SHA256S = new Set([
66
+ 'f8ace1f892b2bd9dc1792ba7f097fa7588f84fed48321480e04de5390828221f',
67
+ ]);
68
+ /** Why no manifested copy can be made of a deliverable. */
69
+ export var ApprovalSealManifestedCopyRefusal;
70
+ (function (ApprovalSealManifestedCopyRefusal) {
71
+ /** The deliverable is not a PDF. */
72
+ ApprovalSealManifestedCopyRefusal["NOT_A_PDF"] = "not_a_pdf";
73
+ /** The PDF is encrypted. */
74
+ ApprovalSealManifestedCopyRefusal["ENCRYPTED"] = "encrypted";
75
+ /** The PDF uses a structure the appender does not follow. */
76
+ ApprovalSealManifestedCopyRefusal["UNSUPPORTED_STRUCTURE"] = "unsupported_structure";
77
+ /** The JWS is not an approval seal's: no claims to print. */
78
+ ApprovalSealManifestedCopyRefusal["NOT_A_SEAL"] = "not_a_seal";
79
+ /** The seal records no printed name for its approver. */
80
+ ApprovalSealManifestedCopyRefusal["NO_PRINTED_NAME"] = "no_printed_name";
81
+ /** A character of the name or of a word has no glyph in the font: it is never printed approximately. */
82
+ ApprovalSealManifestedCopyRefusal["TEXT_NOT_PRINTABLE"] = "text_not_printable";
83
+ /** The font is not one of the pinned ones, or not a TrueType font this writer reads. */
84
+ ApprovalSealManifestedCopyRefusal["FONT_NOT_PINNED"] = "font_not_pinned";
85
+ /** A word is missing, empty, or drops a parameter it must print. */
86
+ ApprovalSealManifestedCopyRefusal["WORDING_INCOMPLETE"] = "wording_incomplete";
87
+ /** The verification address with the JWS is too long for a QR code. */
88
+ ApprovalSealManifestedCopyRefusal["VERIFICATION_LINK_TOO_LONG"] = "verification_link_too_long";
89
+ })(ApprovalSealManifestedCopyRefusal || (ApprovalSealManifestedCopyRefusal = {}));
90
+ export class ApprovalSealManifestedCopyRefusedError extends Error {
91
+ refusal;
92
+ constructor(refusal, message) {
93
+ super(message);
94
+ this.refusal = refusal;
95
+ this.name = 'ApprovalSealManifestedCopyRefusedError';
96
+ }
97
+ }
98
+ /**
99
+ * The link a copy's QR code carries: the public verification route with the JWS as its `jws` parameter. A JWS names no
100
+ * person and no row, so the link carries no personal data and no database id; the route verifies from it alone.
101
+ */
102
+ export function approvalSealVerificationLinkOf(verificationUrl, jws) {
103
+ return `${verificationUrl}${verificationUrl.includes('?') ? '&' : '?'}jws=${jws}`;
104
+ }
105
+ const refuse = (refusal, message) => new ApprovalSealManifestedCopyRefusedError(refusal, message);
106
+ function printedClaimsOf(jws) {
107
+ const notASeal = () => refuse(ApprovalSealManifestedCopyRefusal.NOT_A_SEAL, 'the JWS carries no approval seal claims to print');
108
+ const parts = jws.split('.');
109
+ if (parts.length !== 3)
110
+ throw notASeal();
111
+ let payload;
112
+ try {
113
+ payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf8'));
114
+ }
115
+ catch {
116
+ throw notASeal();
117
+ }
118
+ const { jti, iss, iat, decidedAt, meaning, outcome } = payload ?? {};
119
+ if (typeof jti !== 'string' || typeof iss !== 'string' || typeof iat !== 'number' || typeof decidedAt !== 'number'
120
+ || typeof meaning !== 'string' || typeof outcome !== 'string')
121
+ throw notASeal();
122
+ return { jti, iss, iat, decidedAt, meaning, outcome };
123
+ }
124
+ const isoSeconds = (epochSeconds) => new Date(epochSeconds * 1000).toISOString().replace(/\.\d{3}Z$/, 'Z');
125
+ /** A word filled with its parameters; refused when the template is missing, empty, or drops a parameter it must print. */
126
+ function filled(wording, word, params = {}) {
127
+ const template = wording.words[word];
128
+ if (typeof template !== 'string' || template.trim().length === 0) {
129
+ throw refuse(ApprovalSealManifestedCopyRefusal.WORDING_INCOMPLETE, `the word '${word}' is missing`);
130
+ }
131
+ for (const param of APPROVAL_SEAL_MANIFESTATION_WORDS[word].params) {
132
+ if (!template.includes(`{${param}}`))
133
+ throw refuse(ApprovalSealManifestedCopyRefusal.WORDING_INCOMPLETE, `the word '${word}' does not print {${param}}`);
134
+ }
135
+ return interpolateLabelParams(template, params, wording.locale);
136
+ }
137
+ /** Text set in the embedded font: its glyphs, its width, every glyph's character for the ToUnicode map. */
138
+ class TextSetter {
139
+ font;
140
+ used = new Map();
141
+ constructor(font) {
142
+ this.font = font;
143
+ }
144
+ glyphsOf(text) {
145
+ const glyphs = [];
146
+ for (const char of text.normalize('NFC')) {
147
+ const codePoint = char.codePointAt(0);
148
+ const glyph = codePoint >= 0x20 ? this.font.glyphOf(codePoint) : undefined;
149
+ if (glyph === undefined) {
150
+ throw refuse(ApprovalSealManifestedCopyRefusal.TEXT_NOT_PRINTABLE, `U+${codePoint.toString(16).toUpperCase().padStart(4, '0')} has no glyph in the embedded font`);
151
+ }
152
+ if (!this.used.has(glyph))
153
+ this.used.set(glyph, char);
154
+ glyphs.push(glyph);
155
+ }
156
+ return glyphs;
157
+ }
158
+ widthOf(text, size) {
159
+ return this.glyphsOf(text).reduce((sum, glyph) => sum + this.font.advanceOf(glyph), 0) * size / this.font.unitsPerEm;
160
+ }
161
+ /** A line cut at spaces to fit `width` points; a single word wider than the line is cut where it overflows. */
162
+ wrap(text, size, width) {
163
+ const lines = [];
164
+ let line = '';
165
+ for (const word of text.split(' ')) {
166
+ const candidate = line.length === 0 ? word : `${line} ${word}`;
167
+ if (this.widthOf(candidate, size) <= width) {
168
+ line = candidate;
169
+ continue;
170
+ }
171
+ if (line.length > 0)
172
+ lines.push(line);
173
+ line = word;
174
+ while (this.widthOf(line, size) > width && line.length > 1) {
175
+ let cut = line.length - 1;
176
+ while (cut > 1 && this.widthOf(line.slice(0, cut), size) > width)
177
+ cut -= 1;
178
+ lines.push(line.slice(0, cut));
179
+ line = line.slice(cut);
180
+ }
181
+ }
182
+ if (line.length > 0 || lines.length === 0)
183
+ lines.push(line);
184
+ return lines;
185
+ }
186
+ /** A string operand of `Tj`: the glyph ids as two-byte codes (Identity-H). */
187
+ operand(text) {
188
+ return `<${this.glyphsOf(text).map((glyph) => glyph.toString(16).toUpperCase().padStart(4, '0')).join('')}>`;
189
+ }
190
+ }
191
+ /** A4, in points: the page size when the document's first page states none this reader can use. */
192
+ const A4_MEDIA_BOX = [0, 0, 595.28, 841.89];
193
+ const MARGIN = 56;
194
+ const TITLE_SIZE = 16;
195
+ const BODY_SIZE = 10;
196
+ const LEADING = 14;
197
+ const QR_MAX_WIDTH = 170;
198
+ /** The object offsets past the original's `/Size` that the appended section uses, so a verifier finds its own inputs. */
199
+ var AppendedObject;
200
+ (function (AppendedObject) {
201
+ AppendedObject[AppendedObject["PAGE"] = 0] = "PAGE";
202
+ AppendedObject[AppendedObject["TYPE0_FONT"] = 1] = "TYPE0_FONT";
203
+ AppendedObject[AppendedObject["CID_FONT"] = 2] = "CID_FONT";
204
+ AppendedObject[AppendedObject["FONT_DESCRIPTOR"] = 3] = "FONT_DESCRIPTOR";
205
+ AppendedObject[AppendedObject["FONT_PROGRAM"] = 4] = "FONT_PROGRAM";
206
+ AppendedObject[AppendedObject["TO_UNICODE"] = 5] = "TO_UNICODE";
207
+ AppendedObject[AppendedObject["CONTENTS"] = 6] = "CONTENTS";
208
+ AppendedObject[AppendedObject["ANNOTATION"] = 7] = "ANNOTATION";
209
+ AppendedObject[AppendedObject["SEAL_FILESPEC"] = 8] = "SEAL_FILESPEC";
210
+ AppendedObject[AppendedObject["SEAL_FILE"] = 9] = "SEAL_FILE";
211
+ AppendedObject[AppendedObject["CONTEXT_FILESPEC"] = 10] = "CONTEXT_FILESPEC";
212
+ AppendedObject[AppendedObject["CONTEXT_FILE"] = 11] = "CONTEXT_FILE";
213
+ AppendedObject[AppendedObject["NAME_TREE_ROOT"] = 12] = "NAME_TREE_ROOT";
214
+ AppendedObject[AppendedObject["NAME_TREE_LEAF"] = 13] = "NAME_TREE_LEAF";
215
+ })(AppendedObject || (AppendedObject = {}));
216
+ const refusalOf = {
217
+ [PdfIncrementalUpdateRefusal.NOT_A_PDF]: ApprovalSealManifestedCopyRefusal.NOT_A_PDF,
218
+ [PdfIncrementalUpdateRefusal.ENCRYPTED]: ApprovalSealManifestedCopyRefusal.ENCRYPTED,
219
+ [PdfIncrementalUpdateRefusal.UNSUPPORTED_STRUCTURE]: ApprovalSealManifestedCopyRefusal.UNSUPPORTED_STRUCTURE,
220
+ };
221
+ const sha256Hex = (bytes) => createHash('sha256').update(bytes).digest('hex');
222
+ const asBuffer = (bytes) => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
223
+ /**
224
+ * Build the manifested copy. Pure: the same inputs give the same bytes, which is what {@link checkApprovalSealManifestedCopy}
225
+ * relies on. Throws {@link ApprovalSealManifestedCopyRefusedError} when no copy can be made.
226
+ */
227
+ export function buildApprovalSealManifestedCopy(input) {
228
+ const claims = printedClaimsOf(input.jws);
229
+ const approverName = input.approverName.normalize('NFC').trim();
230
+ if (approverName.length === 0)
231
+ throw refuse(ApprovalSealManifestedCopyRefusal.NO_PRINTED_NAME, 'the seal records no printed name for its approver');
232
+ if (!APPROVAL_SEAL_MANIFESTATION_FONT_SHA256S.has(sha256Hex(input.font)))
233
+ throw refuse(ApprovalSealManifestedCopyRefusal.FONT_NOT_PINNED, 'the font is not a pinned one');
234
+ let font;
235
+ try {
236
+ font = readTrueTypeFont(input.font);
237
+ }
238
+ catch (error) {
239
+ if (error instanceof TrueTypeFontUnreadableError)
240
+ throw refuse(ApprovalSealManifestedCopyRefusal.FONT_NOT_PINNED, error.message);
241
+ throw error;
242
+ }
243
+ const { meaningWord, outcomeWord } = input.wording;
244
+ if (!meaningWord?.trim() || !outcomeWord?.trim())
245
+ throw refuse(ApprovalSealManifestedCopyRefusal.WORDING_INCOMPLETE, 'the meaning or the outcome has no word');
246
+ try {
247
+ return appendManifestation(new PdfDocumentReader(asBuffer(input.original)), input, claims, approverName, font);
248
+ }
249
+ catch (error) {
250
+ if (error instanceof PdfIncrementalUpdateRefusedError)
251
+ throw refuse(refusalOf[error.refusal], error.message);
252
+ if (error instanceof QrCodeTooLongError)
253
+ throw refuse(ApprovalSealManifestedCopyRefusal.VERIFICATION_LINK_TOO_LONG, error.message);
254
+ throw error;
255
+ }
256
+ }
257
+ function appendManifestation(reader, input, claims, approverName, font) {
258
+ const unsupported = (message) => new PdfIncrementalUpdateRefusedError(PdfIncrementalUpdateRefusal.UNSUPPORTED_STRUCTURE, message);
259
+ const catalogRef = reader.trailer.entries.get('Root');
260
+ if (catalogRef?.kind !== 'ref')
261
+ throw unsupported('the trailer names its catalog by no reference');
262
+ const catalog = reader.dictOf(catalogRef, 'the document catalog');
263
+ const pagesRef = catalog.entries.get('Pages');
264
+ if (pagesRef?.kind !== 'ref')
265
+ throw unsupported('the catalog names its page tree by no reference');
266
+ const pagesGen = reader.generationOf(pagesRef.num);
267
+ const pages = reader.dictOf(pagesRef, 'the page tree root');
268
+ const kids = pages.entries.get('Kids');
269
+ const count = pages.entries.get('Count');
270
+ if (kids?.kind !== 'array' || count?.kind !== 'number' || !/^\d+$/.test(count.text)) {
271
+ throw unsupported('the page tree root has no direct /Kids array or integer /Count');
272
+ }
273
+ // The first page's size, inherited along the tree (§7.7.3.4), so the appended page matches the document.
274
+ let mediaBox;
275
+ let node = pagesRef;
276
+ for (let depth = 0; depth < 32 && node; depth += 1) {
277
+ const dict = reader.resolve(node);
278
+ if (dict.kind !== 'dict')
279
+ break;
280
+ mediaBox = reader.boxOf(dict.entries.get('MediaBox')) ?? mediaBox;
281
+ const type = dict.entries.get('Type');
282
+ if (type?.kind === 'name' && type.value === 'Page')
283
+ break;
284
+ const children = reader.resolve(dict.entries.get('Kids'));
285
+ node = children.kind === 'array' ? children.items[0] : undefined;
286
+ }
287
+ const firstPage = mediaBox && mediaBox[2] - mediaBox[0] > 300 ? mediaBox : A4_MEDIA_BOX;
288
+ const laidOut = layOutPage(input, claims, approverName, font, firstPage, sha256Hex(reader.bytes));
289
+ // A first page too short for the approval page gives way to A4, which always holds it.
290
+ const final = laidOut ?? layOutPage(input, claims, approverName, font, A4_MEDIA_BOX, sha256Hex(reader.bytes));
291
+ if (!final)
292
+ throw new PdfIncrementalUpdateRefusedError(PdfIncrementalUpdateRefusal.UNSUPPORTED_STRUCTURE, 'the approval page does not fit on an A4 page');
293
+ const { box: pageBox, setter, content, attachmentLine } = final;
294
+ const [llx, lly, urx, ury] = pageBox;
295
+ // Objects, numbered past the original's highest.
296
+ const base = reader.size;
297
+ const at = (offset) => base + offset;
298
+ const jwsBytes = Buffer.from(input.jws, 'ascii');
299
+ const { wording } = input;
300
+ const context = {
301
+ v: APPROVAL_SEAL_MANIFESTATION_VERSION,
302
+ locale: wording.locale,
303
+ words: Object.fromEntries(Object.values(ApprovalSealManifestationWord).map((word) => [word, wording.words[word]])),
304
+ meaningWord: wording.meaningWord,
305
+ outcomeWord: wording.outcomeWord,
306
+ approverName,
307
+ ...(input.verificationUrl !== undefined ? { verificationUrl: input.verificationUrl } : {}),
308
+ };
309
+ const contextBytes = Buffer.from(canonicalizeJson(context), 'utf8');
310
+ const scale = (value) => Math.round((value * 1000) / font.unitsPerEm);
311
+ const fontName = pdf.name(font.postscriptName);
312
+ const box = pdf.array([pdf.real(llx), pdf.real(lly), pdf.real(urx), pdf.real(ury)]);
313
+ const usedGlyphs = [...setter.used.keys()].sort((first, second) => first - second);
314
+ const widths = [];
315
+ for (const glyph of usedGlyphs)
316
+ widths.push(pdf.int(glyph), pdf.array([pdf.int(scale(font.advanceOf(glyph)))]));
317
+ const attachmentKeys = { seal: `approval-seal-${claims.jti}.jws`, context: `approval-manifestation-${claims.jti}.json` };
318
+ const objects = [
319
+ {
320
+ // The page tree root, redefined: the same entries, the new page last among its kids.
321
+ num: pagesRef.num,
322
+ gen: pagesGen,
323
+ value: { kind: 'dict', entries: new Map([...pages.entries, ['Kids', pdf.array([...kids.items, pdf.ref(at(AppendedObject.PAGE))])], ['Count', pdf.int(Number(count.text) + 1)]]) },
324
+ },
325
+ {
326
+ num: at(AppendedObject.PAGE),
327
+ gen: 0,
328
+ // Every inheritable attribute stated, so nothing the tree declares above changes this page (§7.7.3.4).
329
+ value: pdf.dict({
330
+ Type: pdf.name('Page'),
331
+ Parent: pdf.ref(pagesRef.num, pagesGen),
332
+ MediaBox: box,
333
+ CropBox: box,
334
+ Rotate: pdf.int(0),
335
+ Resources: pdf.dict({ Font: pdf.dict({ WildoF: pdf.ref(at(AppendedObject.TYPE0_FONT)) }) }),
336
+ Contents: pdf.ref(at(AppendedObject.CONTENTS)),
337
+ Annots: pdf.array([pdf.ref(at(AppendedObject.ANNOTATION))]),
338
+ }),
339
+ },
340
+ {
341
+ num: at(AppendedObject.TYPE0_FONT),
342
+ gen: 0,
343
+ value: pdf.dict({
344
+ Type: pdf.name('Font'), Subtype: pdf.name('Type0'), BaseFont: fontName, Encoding: pdf.name('Identity-H'),
345
+ DescendantFonts: pdf.array([pdf.ref(at(AppendedObject.CID_FONT))]), ToUnicode: pdf.ref(at(AppendedObject.TO_UNICODE)),
346
+ }),
347
+ },
348
+ {
349
+ num: at(AppendedObject.CID_FONT),
350
+ gen: 0,
351
+ value: pdf.dict({
352
+ Type: pdf.name('Font'), Subtype: pdf.name('CIDFontType2'), BaseFont: fontName,
353
+ CIDSystemInfo: pdf.dict({ Registry: pdf.string('Adobe'), Ordering: pdf.string('Identity'), Supplement: pdf.int(0) }),
354
+ FontDescriptor: pdf.ref(at(AppendedObject.FONT_DESCRIPTOR)), DW: pdf.int(1000), W: pdf.array(widths), CIDToGIDMap: pdf.name('Identity'),
355
+ }),
356
+ },
357
+ {
358
+ num: at(AppendedObject.FONT_DESCRIPTOR),
359
+ gen: 0,
360
+ value: pdf.dict({
361
+ Type: pdf.name('FontDescriptor'), FontName: fontName,
362
+ // Nonsymbolic (bit 6), and fixed-pitch (bit 1) when the font says so (§9.8.2).
363
+ Flags: pdf.int(32 + (font.fixedPitch ? 1 : 0)),
364
+ FontBBox: pdf.array(font.bbox.map((value) => pdf.int(scale(value)))),
365
+ ItalicAngle: pdf.real(font.italicAngle), Ascent: pdf.int(scale(font.ascent)), Descent: pdf.int(scale(font.descent)),
366
+ CapHeight: pdf.int(scale(font.capHeight)), StemV: pdf.int(80), FontFile2: pdf.ref(at(AppendedObject.FONT_PROGRAM)),
367
+ }),
368
+ },
369
+ { num: at(AppendedObject.FONT_PROGRAM), gen: 0, value: pdf.dict({ Length1: pdf.int(input.font.byteLength) }), stream: asBuffer(input.font) },
370
+ { num: at(AppendedObject.TO_UNICODE), gen: 0, value: pdf.dict({}), stream: Buffer.from(toUnicodeCMap(setter.used), 'latin1') },
371
+ { num: at(AppendedObject.CONTENTS), gen: 0, value: pdf.dict({}), stream: Buffer.from(content, 'latin1') },
372
+ {
373
+ num: at(AppendedObject.ANNOTATION),
374
+ gen: 0,
375
+ value: pdf.dict({
376
+ Type: pdf.name('Annot'), Subtype: pdf.name('FileAttachment'),
377
+ Rect: pdf.array([pdf.real(urx - MARGIN - 16), pdf.real(attachmentLine - 4), pdf.real(urx - MARGIN), pdf.real(attachmentLine + 12)]),
378
+ Contents: pdf.string(APPROVAL_SEAL_MANIFESTED_COPY_ATTACHMENT_NAME), Name: pdf.name('Paperclip'),
379
+ // Printable (§12.5.3, bit 3).
380
+ F: pdf.int(4), FS: pdf.ref(at(AppendedObject.SEAL_FILESPEC)),
381
+ }),
382
+ },
383
+ fileSpec(at(AppendedObject.SEAL_FILESPEC), at(AppendedObject.SEAL_FILE), APPROVAL_SEAL_MANIFESTED_COPY_ATTACHMENT_NAME, 'The approval seal of this document, a compact JWS'),
384
+ // `application/jose`: the media type of a compact JWS (RFC 7515 §9.2.1).
385
+ embeddedFile(at(AppendedObject.SEAL_FILE), 'application/jose', jwsBytes),
386
+ fileSpec(at(AppendedObject.CONTEXT_FILESPEC), at(AppendedObject.CONTEXT_FILE), APPROVAL_SEAL_MANIFESTATION_CONTEXT_NAME, 'The inputs this approval page was made from: its words, the printed name, the verification address'),
387
+ embeddedFile(at(AppendedObject.CONTEXT_FILE), 'application/json', contextBytes),
388
+ ...documentLevelAttachments(reader, catalogRef, catalog, at, [
389
+ [attachmentKeys.seal, pdf.ref(at(AppendedObject.SEAL_FILESPEC))],
390
+ [attachmentKeys.context, pdf.ref(at(AppendedObject.CONTEXT_FILESPEC))],
391
+ ]),
392
+ ];
393
+ return appendPdfIncrementalUpdate(reader, APPROVAL_SEAL_MANIFESTED_COPY_MARKER, objects);
394
+ }
395
+ /** The approval page laid out on `box`: its content stream and where its attachment line is; undefined when it does not fit. */
396
+ function layOutPage(input, claims, approverName, font, box, originalSha256) {
397
+ const [llx, lly, urx, ury] = box;
398
+ const { wording } = input;
399
+ const setter = new TextSetter(font);
400
+ const width = urx - llx - 2 * MARGIN;
401
+ const body = [
402
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.INTRO), BODY_SIZE, width),
403
+ '',
404
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.SIGNED_BY, { name: approverName }), BODY_SIZE, width),
405
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.DECIDED_AT, { instant: isoSeconds(claims.decidedAt) }), BODY_SIZE, width),
406
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.MEANING, { meaning: wording.meaningWord, outcome: wording.outcomeWord }), BODY_SIZE, width),
407
+ '',
408
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.SEAL, { seal: claims.jti }), BODY_SIZE, width),
409
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.ISSUER, { issuer: claims.iss }), BODY_SIZE, width),
410
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.SEALED_AT, { instant: isoSeconds(claims.iat) }), BODY_SIZE, width),
411
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.ORIGINAL_DIGEST), BODY_SIZE, width),
412
+ originalSha256,
413
+ '',
414
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.ATTACHMENT, { file: APPROVAL_SEAL_MANIFESTED_COPY_ATTACHMENT_NAME }), BODY_SIZE, width),
415
+ ...setter.wrap(filled(wording, ApprovalSealManifestationWord.VERIFY_OFFLINE), BODY_SIZE, width),
416
+ ];
417
+ const caption = input.verificationUrl !== undefined ? setter.wrap(filled(wording, ApprovalSealManifestationWord.VERIFY_ONLINE), BODY_SIZE, width) : [];
418
+ const title = filled(wording, ApprovalSealManifestationWord.TITLE);
419
+ const point = (value) => pdf.real(value).text;
420
+ const left = llx + MARGIN;
421
+ const top = ury - 72;
422
+ let content = `BT\n/WildoF 16 Tf\n${point(left)} ${point(top)} Td\n${setter.operand(title)} Tj\n/WildoF ${BODY_SIZE} Tf\n${LEADING} TL\n0 -${BODY_SIZE} Td\n`;
423
+ for (const line of [...body, ...caption])
424
+ content += line.length === 0 ? 'T*\n' : `T* ${setter.operand(line)} Tj\n`;
425
+ content += 'ET\n';
426
+ const textBottom = top - BODY_SIZE - LEADING * (body.length + caption.length);
427
+ const attachmentLine = top - BODY_SIZE - LEADING * (body.length - 1);
428
+ let lowest = textBottom;
429
+ if (input.verificationUrl !== undefined) {
430
+ // The QR code, as filled rectangles, one per run of dark modules in a row (ISO/IEC 18004 §6.3.8: four light modules
431
+ // of quiet zone, which the white page gives).
432
+ const code = encodeQrCode(approvalSealVerificationLinkOf(input.verificationUrl, input.jws), QrErrorCorrection.MEDIUM);
433
+ const module = Math.min(2, QR_MAX_WIDTH / code.size);
434
+ const originY = textBottom - LEADING - code.size * module;
435
+ lowest = originY;
436
+ content += 'q\n0 g\n';
437
+ for (let y = 0; y < code.size; y += 1) {
438
+ for (let x = 0; x < code.size;) {
439
+ if (!code.dark(x, y)) {
440
+ x += 1;
441
+ continue;
442
+ }
443
+ let run = 1;
444
+ while (x + run < code.size && code.dark(x + run, y))
445
+ run += 1;
446
+ content += `${point(left + x * module)} ${point(originY + (code.size - 1 - y) * module)} ${point(run * module)} ${point(module)} re\n`;
447
+ x += run;
448
+ }
449
+ }
450
+ content += 'f\nQ\n';
451
+ }
452
+ if (lowest < lly + MARGIN)
453
+ return undefined;
454
+ return { box, setter, content, attachmentLine };
455
+ }
456
+ function fileSpec(num, file, name, description) {
457
+ return {
458
+ num,
459
+ gen: 0,
460
+ value: pdf.dict({
461
+ Type: pdf.name('Filespec'), F: pdf.string(name), UF: pdf.string(name), Desc: pdf.string(description),
462
+ EF: pdf.dict({ F: pdf.ref(file) }),
463
+ // An associated file of the document (ISO 32000-2 §14.13): it supplements the document's content.
464
+ AFRelationship: pdf.name('Supplement'),
465
+ }),
466
+ };
467
+ }
468
+ function embeddedFile(num, mediaType, bytes) {
469
+ return { num, gen: 0, value: pdf.dict({ Type: pdf.name('EmbeddedFile'), Subtype: pdf.name(mediaType), Params: pdf.dict({ Size: pdf.int(bytes.length) }) }), stream: bytes };
470
+ }
471
+ /** A name tree's key, as the bytes it compares by (§7.9.6). */
472
+ const keyBytes = (key) => (key?.kind === 'string' ? key.bytes : undefined);
473
+ /**
474
+ * The catalog redefined with the attachments at document level: in the `EmbeddedFiles` name tree (merged into a tree the
475
+ * document has, §7.9.6) and appended to `AF`. A tree whose keys already hold one of ours, or whose kids' ranges overlap
476
+ * ours, cannot be merged into, and refuses.
477
+ */
478
+ function documentLevelAttachments(reader, catalogRef, catalog, at, attachments) {
479
+ const unsupported = (message) => new PdfIncrementalUpdateRefusedError(PdfIncrementalUpdateRefusal.UNSUPPORTED_STRUCTURE, message);
480
+ const ours = attachments.map(([key, spec]) => [Buffer.from(key, 'latin1'), spec]).sort(([first], [second]) => Buffer.compare(first, second));
481
+ const existingNames = reader.resolve(catalog.entries.get('Names'));
482
+ const names = new Map(existingNames.kind === 'dict' ? existingNames.entries : []);
483
+ const tree = reader.resolve(names.get('EmbeddedFiles'));
484
+ const objects = [];
485
+ const pairs = (entries) => entries.flatMap(([key, value]) => [pdf.string(key), value]);
486
+ if (tree.kind !== 'dict') {
487
+ objects.push({ num: at(AppendedObject.NAME_TREE_ROOT), gen: 0, value: pdf.dict({ Names: pdf.array(pairs(ours)) }) });
488
+ }
489
+ else if (tree.entries.has('Names')) {
490
+ const existing = reader.resolve(tree.entries.get('Names'));
491
+ if (existing.kind !== 'array' || existing.items.length % 2 !== 0)
492
+ throw unsupported('an EmbeddedFiles leaf whose /Names is not key and value pairs');
493
+ const merged = [];
494
+ for (let index = 0; index < existing.items.length; index += 2) {
495
+ const key = keyBytes(reader.resolve(existing.items[index]));
496
+ if (!key)
497
+ throw unsupported('an EmbeddedFiles key that is not a string');
498
+ merged.push([key, existing.items[index + 1]]);
499
+ }
500
+ for (const [key, spec] of ours) {
501
+ if (merged.some(([existingKey]) => existingKey.equals(key)))
502
+ throw unsupported('the document already attaches a file under this seal\'s name');
503
+ merged.push([key, spec]);
504
+ }
505
+ merged.sort(([first], [second]) => Buffer.compare(first, second));
506
+ objects.push({ num: at(AppendedObject.NAME_TREE_ROOT), gen: 0, value: pdf.dict({ Names: pdf.array(pairs(merged)) }) });
507
+ }
508
+ else {
509
+ const kids = reader.resolve(tree.entries.get('Kids'));
510
+ if (kids.kind !== 'array')
511
+ throw unsupported('an EmbeddedFiles root with neither /Names nor /Kids');
512
+ const low = ours[0][0];
513
+ const high = ours[ours.length - 1][0];
514
+ const ranged = kids.items.map((kid) => {
515
+ const limits = reader.resolve(reader.dictOf(kid, 'an EmbeddedFiles kid').entries.get('Limits'));
516
+ const first = limits.kind === 'array' ? keyBytes(reader.resolve(limits.items[0])) : undefined;
517
+ const last = limits.kind === 'array' ? keyBytes(reader.resolve(limits.items[1])) : undefined;
518
+ if (!first || !last)
519
+ throw unsupported('an EmbeddedFiles kid without /Limits');
520
+ if (Buffer.compare(low, last) <= 0 && Buffer.compare(first, high) <= 0)
521
+ throw unsupported('an EmbeddedFiles kid whose range holds this seal\'s names');
522
+ return { kid, first };
523
+ });
524
+ const leaf = pdf.ref(at(AppendedObject.NAME_TREE_LEAF));
525
+ const ordered = [...ranged.map(({ kid, first }) => ({ kid, first })), { kid: leaf, first: low }]
526
+ .sort((first, second) => Buffer.compare(first.first, second.first));
527
+ objects.push({ num: at(AppendedObject.NAME_TREE_ROOT), gen: 0, value: pdf.dict({ Kids: pdf.array(ordered.map(({ kid }) => kid)) }) });
528
+ objects.push({ num: at(AppendedObject.NAME_TREE_LEAF), gen: 0, value: pdf.dict({ Names: pdf.array(pairs(ours)), Limits: pdf.array([pdf.string(low), pdf.string(high)]) }) });
529
+ }
530
+ names.set('EmbeddedFiles', pdf.ref(at(AppendedObject.NAME_TREE_ROOT)));
531
+ const existingAf = reader.resolve(catalog.entries.get('AF'));
532
+ const af = [...(existingAf.kind === 'array' ? existingAf.items : []), ...attachments.map(([, spec]) => spec)];
533
+ objects.push({
534
+ num: catalogRef.num,
535
+ gen: reader.generationOf(catalogRef.num),
536
+ value: { kind: 'dict', entries: new Map([...catalog.entries, ['Names', { kind: 'dict', entries: names }], ['AF', pdf.array(af)]]) },
537
+ });
538
+ return objects;
539
+ }
540
+ /** The ToUnicode CMap of the glyphs used (§9.10.3): each glyph's two-byte code to its character, UTF-16BE. */
541
+ function toUnicodeCMap(used) {
542
+ const hex = (value) => value.toString(16).toUpperCase().padStart(4, '0');
543
+ const entries = [...used.entries()].sort(([first], [second]) => first - second)
544
+ .map(([glyph, char]) => `<${hex(glyph)}> <${Buffer.from(char, 'utf16le').swap16().toString('hex').toUpperCase()}>`);
545
+ let blocks = '';
546
+ for (let index = 0; index < entries.length; index += 100) {
547
+ const block = entries.slice(index, index + 100);
548
+ blocks += `${block.length} beginbfchar\n${block.join('\n')}\nendbfchar\n`;
549
+ }
550
+ return '/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n'
551
+ + '/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n'
552
+ + '1 begincodespacerange\n<0000> <FFFF>\nendcodespacerange\n'
553
+ + blocks
554
+ + 'endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\n';
555
+ }
556
+ /** A copy split at its manifestation marker: the original's bytes. Undefined when the bytes carry no marker. */
557
+ export function originalOfApprovalSealManifestedCopy(copy) {
558
+ const bytes = asBuffer(copy);
559
+ const at = bytes.lastIndexOf(APPROVAL_SEAL_MANIFESTED_COPY_MARKER, undefined, 'latin1');
560
+ return at > 0 ? bytes.subarray(0, at) : undefined;
561
+ }
562
+ const ContextShape = (value) => {
563
+ if (value === null || typeof value !== 'object')
564
+ return false;
565
+ const context = value;
566
+ return context.v === APPROVAL_SEAL_MANIFESTATION_VERSION && typeof context.locale === 'string' && typeof context.meaningWord === 'string'
567
+ && typeof context.outcomeWord === 'string' && typeof context.approverName === 'string'
568
+ && (context.verificationUrl === undefined || typeof context.verificationUrl === 'string')
569
+ && context.words !== null && typeof context.words === 'object'
570
+ && Object.values(ApprovalSealManifestationWord).every((word) => typeof context.words[word] === 'string');
571
+ };
572
+ /**
573
+ * Check a copy against the seal it claims: take its inputs back from it (the words, the name, the address, the font),
574
+ * rebuild it from its own prefix and the JWS, and compare byte for byte. `approverName`, when the seal's approver
575
+ * disclosure is given, must be the name the copy prints. Says nothing about whether the prefix is the approved file:
576
+ * the caller opens it against the seal's commitment.
577
+ */
578
+ export function checkApprovalSealManifestedCopy(copy, seal) {
579
+ const original = originalOfApprovalSealManifestedCopy(copy);
580
+ if (!original)
581
+ return { matches: false };
582
+ try {
583
+ const base = new PdfDocumentReader(original).size;
584
+ const copyReader = new PdfDocumentReader(asBuffer(copy));
585
+ const font = copyReader.streamDataOf(base + AppendedObject.FONT_PROGRAM);
586
+ const contextBytes = copyReader.streamDataOf(base + AppendedObject.CONTEXT_FILE);
587
+ if (!font || !contextBytes)
588
+ return { matches: false };
589
+ const fontSha256 = sha256Hex(font);
590
+ if (!APPROVAL_SEAL_MANIFESTATION_FONT_SHA256S.has(fontSha256))
591
+ return { matches: false };
592
+ const context = JSON.parse(contextBytes.toString('utf8'));
593
+ if (!ContextShape(context))
594
+ return { matches: false };
595
+ if (seal.approverName !== undefined && seal.approverName.normalize('NFC').trim() !== context.approverName)
596
+ return { matches: false };
597
+ const rebuilt = buildApprovalSealManifestedCopy({
598
+ original,
599
+ jws: seal.jws,
600
+ approverName: context.approverName,
601
+ wording: { locale: context.locale, words: context.words, meaningWord: context.meaningWord, outcomeWord: context.outcomeWord },
602
+ font,
603
+ ...(context.verificationUrl !== undefined ? { verificationUrl: context.verificationUrl } : {}),
604
+ });
605
+ if (Buffer.compare(rebuilt, asBuffer(copy)) !== 0)
606
+ return { matches: false };
607
+ return {
608
+ matches: true,
609
+ original,
610
+ statement: { locale: context.locale, approverName: context.approverName, fontSha256, ...(context.verificationUrl !== undefined ? { verificationUrl: context.verificationUrl } : {}) },
611
+ };
612
+ }
613
+ catch {
614
+ return { matches: false };
615
+ }
616
+ }
617
+ //# sourceMappingURL=approval-seal-manifested-copy.js.map