pi-codex-auto-review 0.1.2 → 0.1.3

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 (1013) hide show
  1. package/README.md +19 -10
  2. package/dist/approval-commands.d.ts +4 -0
  3. package/dist/approval-commands.js +103 -0
  4. package/dist/approval-commands.js.map +1 -0
  5. package/dist/approval-settings.d.ts +9 -0
  6. package/dist/approval-settings.js +40 -0
  7. package/dist/approval-settings.js.map +1 -0
  8. package/dist/contracts.d.ts +2 -0
  9. package/dist/contracts.js.map +1 -1
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +15 -34
  12. package/dist/index.js.map +1 -1
  13. package/dist/policy/index.d.ts +0 -1
  14. package/dist/policy/index.js +6 -32
  15. package/dist/policy/index.js.map +1 -1
  16. package/dist/review/investigation.d.ts +3 -3
  17. package/dist/review/investigation.js +1 -1
  18. package/dist/review/investigation.js.map +1 -1
  19. package/dist/review/policy.js +1 -1
  20. package/dist/tools/controller.d.ts +7 -4
  21. package/dist/tools/controller.js +51 -35
  22. package/dist/tools/controller.js.map +1 -1
  23. package/dist/tools/environment.d.ts +1 -0
  24. package/dist/tools/environment.js +6 -0
  25. package/dist/tools/environment.js.map +1 -0
  26. package/dist/tools/executor.d.ts +14 -0
  27. package/dist/tools/executor.js +75 -0
  28. package/dist/tools/executor.js.map +1 -0
  29. package/dist/tools/mutation-queue.d.ts +1 -0
  30. package/dist/tools/mutation-queue.js +16 -0
  31. package/dist/tools/mutation-queue.js.map +1 -0
  32. package/docs/publishing.md +7 -7
  33. package/docs/security/dependencies.md +13 -3
  34. package/docs/testing/auto-review-protection.md +28 -8
  35. package/docs/usage.md +19 -16
  36. package/package.json +11 -14
  37. package/dist/sandbox/broker.d.ts +0 -1
  38. package/dist/sandbox/broker.js +0 -139
  39. package/dist/sandbox/broker.js.map +0 -1
  40. package/dist/sandbox/config.d.ts +0 -5
  41. package/dist/sandbox/config.js +0 -97
  42. package/dist/sandbox/config.js.map +0 -1
  43. package/dist/sandbox/directory-scan.d.ts +0 -1
  44. package/dist/sandbox/directory-scan.js +0 -32
  45. package/dist/sandbox/directory-scan.js.map +0 -1
  46. package/dist/sandbox/executor.d.ts +0 -20
  47. package/dist/sandbox/executor.js +0 -146
  48. package/dist/sandbox/executor.js.map +0 -1
  49. package/dist/sandbox/hard-links.d.ts +0 -4
  50. package/dist/sandbox/hard-links.js +0 -155
  51. package/dist/sandbox/hard-links.js.map +0 -1
  52. package/dist/sandbox/linux-read-paths.d.ts +0 -7
  53. package/dist/sandbox/linux-read-paths.js +0 -47
  54. package/dist/sandbox/linux-read-paths.js.map +0 -1
  55. package/dist/sandbox/paths.d.ts +0 -3
  56. package/dist/sandbox/paths.js +0 -10
  57. package/dist/sandbox/paths.js.map +0 -1
  58. package/dist/sandbox/runtime-write-paths.d.ts +0 -2
  59. package/dist/sandbox/runtime-write-paths.js +0 -8
  60. package/dist/sandbox/runtime-write-paths.js.map +0 -1
  61. package/dist/sandbox/seccomp.d.ts +0 -5
  62. package/dist/sandbox/seccomp.js +0 -16
  63. package/dist/sandbox/seccomp.js.map +0 -1
  64. package/dist/sandbox/worker.d.ts +0 -1
  65. package/dist/sandbox/worker.js +0 -78
  66. package/dist/sandbox/worker.js.map +0 -1
  67. package/node_modules/@anthropic-ai/sandbox-runtime/LICENSE +0 -201
  68. package/node_modules/@anthropic-ai/sandbox-runtime/README.md +0 -901
  69. package/node_modules/@anthropic-ai/sandbox-runtime/dist/cli.d.ts +0 -3
  70. package/node_modules/@anthropic-ai/sandbox-runtime/dist/cli.d.ts.map +0 -1
  71. package/node_modules/@anthropic-ai/sandbox-runtime/dist/cli.js +0 -472
  72. package/node_modules/@anthropic-ai/sandbox-runtime/dist/cli.js.map +0 -1
  73. package/node_modules/@anthropic-ai/sandbox-runtime/dist/index.d.ts +0 -19
  74. package/node_modules/@anthropic-ai/sandbox-runtime/dist/index.d.ts.map +0 -1
  75. package/node_modules/@anthropic-ai/sandbox-runtime/dist/index.js +0 -17
  76. package/node_modules/@anthropic-ai/sandbox-runtime/dist/index.js.map +0 -1
  77. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/address.d.ts +0 -52
  78. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/address.d.ts.map +0 -1
  79. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/address.js +0 -153
  80. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/address.js.map +0 -1
  81. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/aws-sigv4.d.ts +0 -164
  82. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/aws-sigv4.d.ts.map +0 -1
  83. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/aws-sigv4.js +0 -246
  84. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/aws-sigv4.js.map +0 -1
  85. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/body-substitution.d.ts +0 -58
  86. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/body-substitution.d.ts.map +0 -1
  87. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/body-substitution.js +0 -128
  88. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/body-substitution.js.map +0 -1
  89. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-aws-pairs.d.ts +0 -124
  90. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-aws-pairs.d.ts.map +0 -1
  91. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-aws-pairs.js +0 -258
  92. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-aws-pairs.js.map +0 -1
  93. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-decode.d.ts +0 -87
  94. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-decode.d.ts.map +0 -1
  95. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-decode.js +0 -138
  96. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-decode.js.map +0 -1
  97. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-extract.d.ts +0 -67
  98. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-extract.d.ts.map +0 -1
  99. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-extract.js +0 -113
  100. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-extract.js.map +0 -1
  101. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-mask-env.d.ts +0 -70
  102. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-mask-env.d.ts.map +0 -1
  103. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-mask-env.js +0 -171
  104. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-mask-env.js.map +0 -1
  105. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-mask-files.d.ts +0 -120
  106. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-mask-files.d.ts.map +0 -1
  107. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-mask-files.js +0 -281
  108. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-mask-files.js.map +0 -1
  109. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-sentinel.d.ts +0 -108
  110. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-sentinel.d.ts.map +0 -1
  111. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-sentinel.js +0 -208
  112. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/credential-sentinel.js.map +0 -1
  113. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/domain-pattern.d.ts +0 -82
  114. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/domain-pattern.d.ts.map +0 -1
  115. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/domain-pattern.js +0 -155
  116. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/domain-pattern.js.map +0 -1
  117. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/generate-seccomp-filter.d.ts +0 -44
  118. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/generate-seccomp-filter.d.ts.map +0 -1
  119. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/generate-seccomp-filter.js +0 -220
  120. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/generate-seccomp-filter.js.map +0 -1
  121. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/http-proxy.d.ts +0 -150
  122. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/http-proxy.d.ts.map +0 -1
  123. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/http-proxy.js +0 -678
  124. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/http-proxy.js.map +0 -1
  125. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/java-proxy-agent.d.ts +0 -32
  126. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/java-proxy-agent.d.ts.map +0 -1
  127. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/java-proxy-agent.js +0 -111
  128. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/java-proxy-agent.js.map +0 -1
  129. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/linux-sandbox-utils.d.ts +0 -305
  130. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/linux-sandbox-utils.d.ts.map +0 -1
  131. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/linux-sandbox-utils.js +0 -2605
  132. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/linux-sandbox-utils.js.map +0 -1
  133. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/linux-violation-monitor.d.ts +0 -55
  134. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/linux-violation-monitor.d.ts.map +0 -1
  135. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/linux-violation-monitor.js +0 -152
  136. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/linux-violation-monitor.js.map +0 -1
  137. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/listen-in-range.d.ts +0 -12
  138. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/listen-in-range.d.ts.map +0 -1
  139. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/listen-in-range.js +0 -43
  140. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/listen-in-range.js.map +0 -1
  141. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/macos-sandbox-utils.d.ts +0 -116
  142. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/macos-sandbox-utils.d.ts.map +0 -1
  143. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/macos-sandbox-utils.js +0 -1195
  144. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/macos-sandbox-utils.js.map +0 -1
  145. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mitm-ca.d.ts +0 -200
  146. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mitm-ca.d.ts.map +0 -1
  147. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mitm-ca.js +0 -443
  148. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mitm-ca.js.map +0 -1
  149. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mitm-leaf.d.ts +0 -28
  150. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mitm-leaf.d.ts.map +0 -1
  151. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mitm-leaf.js +0 -114
  152. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mitm-leaf.js.map +0 -1
  153. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mux-proxy.d.ts +0 -59
  154. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mux-proxy.d.ts.map +0 -1
  155. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mux-proxy.js +0 -159
  156. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/mux-proxy.js.map +0 -1
  157. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/parent-proxy.d.ts +0 -147
  158. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/parent-proxy.d.ts.map +0 -1
  159. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/parent-proxy.js +0 -445
  160. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/parent-proxy.js.map +0 -1
  161. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/read-deny-glob.d.ts +0 -17
  162. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/read-deny-glob.d.ts.map +0 -1
  163. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/read-deny-glob.js +0 -163
  164. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/read-deny-glob.js.map +0 -1
  165. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/request-filter.d.ts +0 -83
  166. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/request-filter.d.ts.map +0 -1
  167. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/request-filter.js +0 -212
  168. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/request-filter.js.map +0 -1
  169. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/resolved-address-guard.d.ts +0 -76
  170. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/resolved-address-guard.d.ts.map +0 -1
  171. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/resolved-address-guard.js +0 -221
  172. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/resolved-address-guard.js.map +0 -1
  173. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-config.d.ts +0 -1691
  174. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-config.d.ts.map +0 -1
  175. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-config.js +0 -1233
  176. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-config.js.map +0 -1
  177. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-manager.d.ts +0 -97
  178. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-manager.d.ts.map +0 -1
  179. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-manager.js +0 -1937
  180. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-manager.js.map +0 -1
  181. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-schemas.d.ts +0 -113
  182. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-schemas.d.ts.map +0 -1
  183. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-schemas.js +0 -3
  184. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-schemas.js.map +0 -1
  185. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-utils.d.ts +0 -411
  186. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-utils.d.ts.map +0 -1
  187. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-utils.js +0 -1408
  188. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-utils.js.map +0 -1
  189. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-violation-store.d.ts +0 -37
  190. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-violation-store.d.ts.map +0 -1
  191. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-violation-store.js +0 -125
  192. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-violation-store.js.map +0 -1
  193. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/socks-proxy.d.ts +0 -57
  194. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/socks-proxy.d.ts.map +0 -1
  195. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/socks-proxy.js +0 -332
  196. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/socks-proxy.js.map +0 -1
  197. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/tls-terminate-proxy.d.ts +0 -100
  198. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/tls-terminate-proxy.d.ts.map +0 -1
  199. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/tls-terminate-proxy.js +0 -546
  200. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/tls-terminate-proxy.js.map +0 -1
  201. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/windows-sandbox-utils.d.ts +0 -923
  202. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/windows-sandbox-utils.d.ts.map +0 -1
  203. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/windows-sandbox-utils.js +0 -1419
  204. package/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/windows-sandbox-utils.js.map +0 -1
  205. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/config-loader.d.ts +0 -31
  206. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/config-loader.d.ts.map +0 -1
  207. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/config-loader.js +0 -69
  208. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/config-loader.js.map +0 -1
  209. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/debug.d.ts +0 -7
  210. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/debug.d.ts.map +0 -1
  211. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/debug.js +0 -25
  212. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/debug.js.map +0 -1
  213. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/platform.d.ts +0 -15
  214. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/platform.d.ts.map +0 -1
  215. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/platform.js +0 -49
  216. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/platform.js.map +0 -1
  217. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/ripgrep.d.ts +0 -17
  218. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/ripgrep.d.ts.map +0 -1
  219. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/ripgrep.js +0 -37
  220. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/ripgrep.js.map +0 -1
  221. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/shell-quote.d.ts +0 -27
  222. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/shell-quote.d.ts.map +0 -1
  223. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/shell-quote.js +0 -47
  224. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/shell-quote.js.map +0 -1
  225. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/which.d.ts +0 -9
  226. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/which.d.ts.map +0 -1
  227. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/which.js +0 -25
  228. package/node_modules/@anthropic-ai/sandbox-runtime/dist/utils/which.js.map +0 -1
  229. package/node_modules/@anthropic-ai/sandbox-runtime/package.json +0 -88
  230. package/node_modules/@anthropic-ai/sandbox-runtime/vendor/java-proxy-agent/build.ts +0 -95
  231. package/node_modules/@anthropic-ai/sandbox-runtime/vendor/java-proxy-agent/srt-proxy-agent.jar +0 -0
  232. package/node_modules/@anthropic-ai/sandbox-runtime/vendor/seccomp/arm64/apply-seccomp +0 -0
  233. package/node_modules/@anthropic-ai/sandbox-runtime/vendor/seccomp/build.ts +0 -69
  234. package/node_modules/@anthropic-ai/sandbox-runtime/vendor/seccomp/x64/apply-seccomp +0 -0
  235. package/node_modules/@anthropic-ai/sandbox-runtime/vendor/srt-win/arm64/srt-win.exe +0 -0
  236. package/node_modules/@anthropic-ai/sandbox-runtime/vendor/srt-win/build.ts +0 -28
  237. package/node_modules/@anthropic-ai/sandbox-runtime/vendor/srt-win/x64/srt-win.exe +0 -0
  238. package/node_modules/@pondwader/socks5-server/.github/workflows/ci.yml +0 -27
  239. package/node_modules/@pondwader/socks5-server/LICENSE +0 -20
  240. package/node_modules/@pondwader/socks5-server/README.md +0 -151
  241. package/node_modules/@pondwader/socks5-server/dist/index.d.mts +0 -87
  242. package/node_modules/@pondwader/socks5-server/dist/index.d.ts +0 -87
  243. package/node_modules/@pondwader/socks5-server/dist/index.js +0 -346
  244. package/node_modules/@pondwader/socks5-server/dist/index.mjs +0 -307
  245. package/node_modules/@pondwader/socks5-server/package.json +0 -31
  246. package/node_modules/commander/LICENSE +0 -22
  247. package/node_modules/commander/Readme.md +0 -1157
  248. package/node_modules/commander/esm.mjs +0 -16
  249. package/node_modules/commander/index.js +0 -24
  250. package/node_modules/commander/lib/argument.js +0 -149
  251. package/node_modules/commander/lib/command.js +0 -2509
  252. package/node_modules/commander/lib/error.js +0 -39
  253. package/node_modules/commander/lib/help.js +0 -520
  254. package/node_modules/commander/lib/option.js +0 -330
  255. package/node_modules/commander/lib/suggestSimilar.js +0 -101
  256. package/node_modules/commander/package-support.json +0 -16
  257. package/node_modules/commander/package.json +0 -84
  258. package/node_modules/commander/typings/esm.d.mts +0 -3
  259. package/node_modules/commander/typings/index.d.ts +0 -969
  260. package/node_modules/node-forge/.editorconfig +0 -17
  261. package/node_modules/node-forge/.eslintrc.js +0 -24
  262. package/node_modules/node-forge/.github/workflows/main.yaml +0 -96
  263. package/node_modules/node-forge/.istanbul.yml +0 -2
  264. package/node_modules/node-forge/.npmignore +0 -15
  265. package/node_modules/node-forge/CHANGELOG.md +0 -555
  266. package/node_modules/node-forge/CONTRIBUTING.md +0 -18
  267. package/node_modules/node-forge/LICENSE +0 -331
  268. package/node_modules/node-forge/README.md +0 -2071
  269. package/node_modules/node-forge/RELEASE.md +0 -19
  270. package/node_modules/node-forge/SECURITY.md +0 -5
  271. package/node_modules/node-forge/examples/create-cert.js +0 -110
  272. package/node_modules/node-forge/examples/create-csr.js +0 -66
  273. package/node_modules/node-forge/examples/create-pkcs12.js +0 -160
  274. package/node_modules/node-forge/examples/imap.js +0 -46
  275. package/node_modules/node-forge/examples/sign-p7.js +0 -115
  276. package/node_modules/node-forge/examples/tls.js +0 -189
  277. package/node_modules/node-forge/flash/PooledSocket.as +0 -18
  278. package/node_modules/node-forge/flash/README.md +0 -48
  279. package/node_modules/node-forge/flash/SocketEvent.as +0 -36
  280. package/node_modules/node-forge/flash/SocketPool.as +0 -754
  281. package/node_modules/node-forge/flash/mod_fsp/README +0 -135
  282. package/node_modules/node-forge/flash/mod_fsp/mod_fsp.c +0 -415
  283. package/node_modules/node-forge/flash/package.json +0 -28
  284. package/node_modules/node-forge/flash/policyserver.js +0 -65
  285. package/node_modules/node-forge/flash/policyserver.py +0 -112
  286. package/node_modules/node-forge/flash/swf/SocketPool.swf +0 -0
  287. package/node_modules/node-forge/karma-sauce.conf.js +0 -79
  288. package/node_modules/node-forge/karma.conf.js +0 -133
  289. package/node_modules/node-forge/lib/aes.js +0 -1091
  290. package/node_modules/node-forge/lib/aesCipherSuites.js +0 -282
  291. package/node_modules/node-forge/lib/asn1-validator.js +0 -91
  292. package/node_modules/node-forge/lib/asn1.js +0 -1503
  293. package/node_modules/node-forge/lib/baseN.js +0 -186
  294. package/node_modules/node-forge/lib/cipher.js +0 -230
  295. package/node_modules/node-forge/lib/cipherModes.js +0 -999
  296. package/node_modules/node-forge/lib/des.js +0 -496
  297. package/node_modules/node-forge/lib/ed25519.js +0 -1091
  298. package/node_modules/node-forge/lib/forge.js +0 -13
  299. package/node_modules/node-forge/lib/form.js +0 -149
  300. package/node_modules/node-forge/lib/hmac.js +0 -146
  301. package/node_modules/node-forge/lib/http.js +0 -1346
  302. package/node_modules/node-forge/lib/index.all.js +0 -16
  303. package/node_modules/node-forge/lib/index.js +0 -33
  304. package/node_modules/node-forge/lib/jsbn.js +0 -1294
  305. package/node_modules/node-forge/lib/kem.js +0 -168
  306. package/node_modules/node-forge/lib/log.js +0 -319
  307. package/node_modules/node-forge/lib/md.all.js +0 -13
  308. package/node_modules/node-forge/lib/md.js +0 -11
  309. package/node_modules/node-forge/lib/md5.js +0 -289
  310. package/node_modules/node-forge/lib/mgf.js +0 -12
  311. package/node_modules/node-forge/lib/mgf1.js +0 -57
  312. package/node_modules/node-forge/lib/oids.js +0 -180
  313. package/node_modules/node-forge/lib/pbe.js +0 -1023
  314. package/node_modules/node-forge/lib/pbkdf2.js +0 -211
  315. package/node_modules/node-forge/lib/pem.js +0 -237
  316. package/node_modules/node-forge/lib/pkcs1.js +0 -276
  317. package/node_modules/node-forge/lib/pkcs12.js +0 -1078
  318. package/node_modules/node-forge/lib/pkcs7.js +0 -1260
  319. package/node_modules/node-forge/lib/pkcs7asn1.js +0 -410
  320. package/node_modules/node-forge/lib/pki.js +0 -102
  321. package/node_modules/node-forge/lib/prime.js +0 -297
  322. package/node_modules/node-forge/lib/prime.worker.js +0 -168
  323. package/node_modules/node-forge/lib/prng.js +0 -419
  324. package/node_modules/node-forge/lib/pss.js +0 -241
  325. package/node_modules/node-forge/lib/random.js +0 -191
  326. package/node_modules/node-forge/lib/rc2.js +0 -410
  327. package/node_modules/node-forge/lib/rsa.js +0 -1973
  328. package/node_modules/node-forge/lib/sha1.js +0 -319
  329. package/node_modules/node-forge/lib/sha256.js +0 -327
  330. package/node_modules/node-forge/lib/sha512.js +0 -561
  331. package/node_modules/node-forge/lib/socket.js +0 -287
  332. package/node_modules/node-forge/lib/ssh.js +0 -236
  333. package/node_modules/node-forge/lib/tls.js +0 -4282
  334. package/node_modules/node-forge/lib/tlssocket.js +0 -249
  335. package/node_modules/node-forge/lib/util.js +0 -2652
  336. package/node_modules/node-forge/lib/x509.js +0 -3251
  337. package/node_modules/node-forge/lib/xhr.js +0 -738
  338. package/node_modules/node-forge/package.json +0 -123
  339. package/node_modules/node-forge/tests/.eslintrc.js +0 -5
  340. package/node_modules/node-forge/tests/README.md +0 -4
  341. package/node_modules/node-forge/tests/benchmarks/aes-speed.js +0 -62
  342. package/node_modules/node-forge/tests/benchmarks/so-44303784.js +0 -246
  343. package/node_modules/node-forge/tests/flash/README.md +0 -7
  344. package/node_modules/node-forge/tests/flash/Test.as +0 -96
  345. package/node_modules/node-forge/tests/flash/build-flash.xml +0 -7
  346. package/node_modules/node-forge/tests/flash/index.html +0 -28
  347. package/node_modules/node-forge/tests/index.html +0 -33
  348. package/node_modules/node-forge/tests/issues/heartbleed.js +0 -55
  349. package/node_modules/node-forge/tests/issues/issue-428.html +0 -95
  350. package/node_modules/node-forge/tests/issues/issue-428.js +0 -375
  351. package/node_modules/node-forge/tests/karma/index.js +0 -8
  352. package/node_modules/node-forge/tests/karma/testWorker.js +0 -65
  353. package/node_modules/node-forge/tests/karma/web-worker-rsa.js +0 -55
  354. package/node_modules/node-forge/tests/legacy/common.html +0 -65
  355. package/node_modules/node-forge/tests/legacy/common.js +0 -2199
  356. package/node_modules/node-forge/tests/legacy/form.html +0 -148
  357. package/node_modules/node-forge/tests/legacy/form.js +0 -40
  358. package/node_modules/node-forge/tests/legacy/http.html +0 -235
  359. package/node_modules/node-forge/tests/legacy/index.html +0 -70
  360. package/node_modules/node-forge/tests/legacy/keygen.html +0 -113
  361. package/node_modules/node-forge/tests/legacy/login.css +0 -26
  362. package/node_modules/node-forge/tests/legacy/loginDemo.html +0 -32
  363. package/node_modules/node-forge/tests/legacy/loginDemo.js +0 -149
  364. package/node_modules/node-forge/tests/legacy/performance.html +0 -533
  365. package/node_modules/node-forge/tests/legacy/result.txt +0 -1
  366. package/node_modules/node-forge/tests/legacy/socketPool.html +0 -302
  367. package/node_modules/node-forge/tests/legacy/tasks.html +0 -54
  368. package/node_modules/node-forge/tests/legacy/tasks.js +0 -378
  369. package/node_modules/node-forge/tests/legacy/tls.html +0 -389
  370. package/node_modules/node-forge/tests/legacy/webid.html +0 -89
  371. package/node_modules/node-forge/tests/legacy/webid.js +0 -313
  372. package/node_modules/node-forge/tests/legacy/ws-webid.js +0 -120
  373. package/node_modules/node-forge/tests/legacy/xhr.html +0 -67
  374. package/node_modules/node-forge/tests/legacy/xhr.js +0 -590
  375. package/node_modules/node-forge/tests/pocs/ghsa-2328-f5f3-gj25.js +0 -85
  376. package/node_modules/node-forge/tests/pocs/ghsa-ppp5-5v6c-4jwp.js +0 -166
  377. package/node_modules/node-forge/tests/pocs/ghsa-q67f-28xg-22rw.js +0 -103
  378. package/node_modules/node-forge/tests/security/cve-2025-12816.js +0 -75
  379. package/node_modules/node-forge/tests/security/ghsa-554w-wpv2-vw27.js +0 -81
  380. package/node_modules/node-forge/tests/security/index.js +0 -3
  381. package/node_modules/node-forge/tests/server.crt +0 -26
  382. package/node_modules/node-forge/tests/server.js +0 -87
  383. package/node_modules/node-forge/tests/server.key +0 -27
  384. package/node_modules/node-forge/tests/support/task.js +0 -718
  385. package/node_modules/node-forge/tests/tests.css +0 -61
  386. package/node_modules/node-forge/tests/unit/aes.js +0 -1498
  387. package/node_modules/node-forge/tests/unit/asn1.js +0 -1337
  388. package/node_modules/node-forge/tests/unit/csr.js +0 -129
  389. package/node_modules/node-forge/tests/unit/des.js +0 -231
  390. package/node_modules/node-forge/tests/unit/ed25519.js +0 -395
  391. package/node_modules/node-forge/tests/unit/forge.js +0 -2
  392. package/node_modules/node-forge/tests/unit/hmac.js +0 -64
  393. package/node_modules/node-forge/tests/unit/index.html +0 -20
  394. package/node_modules/node-forge/tests/unit/index.js +0 -27
  395. package/node_modules/node-forge/tests/unit/jsbn.js +0 -40
  396. package/node_modules/node-forge/tests/unit/kem.js +0 -167
  397. package/node_modules/node-forge/tests/unit/md5.js +0 -114
  398. package/node_modules/node-forge/tests/unit/mgf1.js +0 -16
  399. package/node_modules/node-forge/tests/unit/pbkdf2.js +0 -182
  400. package/node_modules/node-forge/tests/unit/pem.js +0 -159
  401. package/node_modules/node-forge/tests/unit/pkcs1.js +0 -1077
  402. package/node_modules/node-forge/tests/unit/pkcs12.js +0 -739
  403. package/node_modules/node-forge/tests/unit/pkcs7.js +0 -792
  404. package/node_modules/node-forge/tests/unit/random.js +0 -48
  405. package/node_modules/node-forge/tests/unit/rc2.js +0 -88
  406. package/node_modules/node-forge/tests/unit/rsa.js +0 -1278
  407. package/node_modules/node-forge/tests/unit/sha1.js +0 -72
  408. package/node_modules/node-forge/tests/unit/sha256.js +0 -79
  409. package/node_modules/node-forge/tests/unit/sha512.js +0 -200
  410. package/node_modules/node-forge/tests/unit/ssh.js +0 -175
  411. package/node_modules/node-forge/tests/unit/tls.js +0 -175
  412. package/node_modules/node-forge/tests/unit/util.js +0 -595
  413. package/node_modules/node-forge/tests/unit/x509.js +0 -1986
  414. package/node_modules/node-forge/tests/websockets/server-webid.js +0 -495
  415. package/node_modules/node-forge/tests/websockets/server-ws.js +0 -158
  416. package/node_modules/node-forge/webpack-tests.config.js +0 -26
  417. package/node_modules/node-forge/webpack.config.js +0 -130
  418. package/node_modules/zod/LICENSE +0 -21
  419. package/node_modules/zod/README.md +0 -208
  420. package/node_modules/zod/index.cjs +0 -33
  421. package/node_modules/zod/index.d.cts +0 -4
  422. package/node_modules/zod/index.d.ts +0 -4
  423. package/node_modules/zod/index.js +0 -4
  424. package/node_modules/zod/package.json +0 -118
  425. package/node_modules/zod/src/index.ts +0 -4
  426. package/node_modules/zod/src/v3/ZodError.ts +0 -330
  427. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  428. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  429. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  430. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  431. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  432. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  433. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  434. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  435. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  436. package/node_modules/zod/src/v3/errors.ts +0 -13
  437. package/node_modules/zod/src/v3/external.ts +0 -6
  438. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  439. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  440. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  441. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  442. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  443. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  444. package/node_modules/zod/src/v3/index.ts +0 -4
  445. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  446. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  447. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  448. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  449. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  450. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  451. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  452. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  453. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  454. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  455. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  456. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  457. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  458. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -56
  459. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  460. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  461. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  462. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  463. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  464. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  465. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  466. package/node_modules/zod/src/v3/tests/error.test.ts +0 -551
  467. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  468. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  469. package/node_modules/zod/src/v3/tests/function.test.ts +0 -257
  470. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  471. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  472. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -110
  473. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  474. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -207
  475. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  476. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  477. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  478. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  479. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -21
  480. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  481. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  482. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  483. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  484. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  485. package/node_modules/zod/src/v3/tests/object.test.ts +0 -434
  486. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  487. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  488. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  489. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  490. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  491. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  492. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  493. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  494. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  495. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -194
  496. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  497. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  498. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  499. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  500. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  501. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  502. package/node_modules/zod/src/v3/tests/string.test.ts +0 -916
  503. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  504. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  505. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  506. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  507. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  508. package/node_modules/zod/src/v3/types.ts +0 -5136
  509. package/node_modules/zod/src/v4/classic/checks.ts +0 -30
  510. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  511. package/node_modules/zod/src/v4/classic/compat.ts +0 -66
  512. package/node_modules/zod/src/v4/classic/errors.ts +0 -75
  513. package/node_modules/zod/src/v4/classic/external.ts +0 -50
  514. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  515. package/node_modules/zod/src/v4/classic/iso.ts +0 -90
  516. package/node_modules/zod/src/v4/classic/parse.ts +0 -33
  517. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2054
  518. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  519. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -264
  520. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -210
  521. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  522. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  523. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  524. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -54
  525. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -63
  526. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -252
  527. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  528. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  529. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -352
  530. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  531. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -31
  532. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -296
  533. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -313
  534. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  535. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -619
  536. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -285
  537. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -527
  538. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -711
  539. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -91
  540. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -175
  541. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -268
  542. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  543. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -829
  544. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -34
  545. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -171
  546. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -108
  547. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -227
  548. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -92
  549. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -196
  550. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  551. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  552. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -86
  553. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  554. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -247
  555. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -563
  556. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -123
  557. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -147
  558. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -127
  559. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -81
  560. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -37
  561. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -298
  562. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  563. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  564. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  565. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -252
  566. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -342
  567. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -356
  568. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -532
  569. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -204
  570. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -179
  571. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -57
  572. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -109
  573. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -881
  574. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -66
  575. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -758
  576. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -2314
  577. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -250
  578. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -163
  579. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -94
  580. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  581. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  582. package/node_modules/zod/src/v4/core/api.ts +0 -1594
  583. package/node_modules/zod/src/v4/core/checks.ts +0 -1283
  584. package/node_modules/zod/src/v4/core/config.ts +0 -15
  585. package/node_modules/zod/src/v4/core/core.ts +0 -134
  586. package/node_modules/zod/src/v4/core/doc.ts +0 -44
  587. package/node_modules/zod/src/v4/core/errors.ts +0 -424
  588. package/node_modules/zod/src/v4/core/function.ts +0 -176
  589. package/node_modules/zod/src/v4/core/index.ts +0 -15
  590. package/node_modules/zod/src/v4/core/json-schema.ts +0 -143
  591. package/node_modules/zod/src/v4/core/parse.ts +0 -94
  592. package/node_modules/zod/src/v4/core/regexes.ts +0 -135
  593. package/node_modules/zod/src/v4/core/registries.ts +0 -96
  594. package/node_modules/zod/src/v4/core/schemas.ts +0 -3842
  595. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -64
  596. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  597. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  598. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  599. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  600. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  601. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -977
  602. package/node_modules/zod/src/v4/core/util.ts +0 -775
  603. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  604. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  605. package/node_modules/zod/src/v4/index.ts +0 -4
  606. package/node_modules/zod/src/v4/locales/ar.ts +0 -125
  607. package/node_modules/zod/src/v4/locales/az.ts +0 -121
  608. package/node_modules/zod/src/v4/locales/be.ts +0 -184
  609. package/node_modules/zod/src/v4/locales/ca.ts +0 -127
  610. package/node_modules/zod/src/v4/locales/cs.ts +0 -142
  611. package/node_modules/zod/src/v4/locales/de.ts +0 -124
  612. package/node_modules/zod/src/v4/locales/en.ts +0 -127
  613. package/node_modules/zod/src/v4/locales/eo.ts +0 -125
  614. package/node_modules/zod/src/v4/locales/es.ts +0 -125
  615. package/node_modules/zod/src/v4/locales/fa.ts +0 -134
  616. package/node_modules/zod/src/v4/locales/fi.ts +0 -131
  617. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -126
  618. package/node_modules/zod/src/v4/locales/fr.ts +0 -124
  619. package/node_modules/zod/src/v4/locales/he.ts +0 -125
  620. package/node_modules/zod/src/v4/locales/hu.ts +0 -126
  621. package/node_modules/zod/src/v4/locales/id.ts +0 -125
  622. package/node_modules/zod/src/v4/locales/index.ts +0 -39
  623. package/node_modules/zod/src/v4/locales/it.ts +0 -125
  624. package/node_modules/zod/src/v4/locales/ja.ts +0 -122
  625. package/node_modules/zod/src/v4/locales/kh.ts +0 -126
  626. package/node_modules/zod/src/v4/locales/ko.ts +0 -131
  627. package/node_modules/zod/src/v4/locales/mk.ts +0 -127
  628. package/node_modules/zod/src/v4/locales/ms.ts +0 -124
  629. package/node_modules/zod/src/v4/locales/nl.ts +0 -126
  630. package/node_modules/zod/src/v4/locales/no.ts +0 -124
  631. package/node_modules/zod/src/v4/locales/ota.ts +0 -125
  632. package/node_modules/zod/src/v4/locales/pl.ts +0 -126
  633. package/node_modules/zod/src/v4/locales/ps.ts +0 -133
  634. package/node_modules/zod/src/v4/locales/pt.ts +0 -123
  635. package/node_modules/zod/src/v4/locales/ru.ts +0 -184
  636. package/node_modules/zod/src/v4/locales/sl.ts +0 -126
  637. package/node_modules/zod/src/v4/locales/sv.ts +0 -127
  638. package/node_modules/zod/src/v4/locales/ta.ts +0 -125
  639. package/node_modules/zod/src/v4/locales/th.ts +0 -126
  640. package/node_modules/zod/src/v4/locales/tr.ts +0 -121
  641. package/node_modules/zod/src/v4/locales/ua.ts +0 -126
  642. package/node_modules/zod/src/v4/locales/ur.ts +0 -126
  643. package/node_modules/zod/src/v4/locales/vi.ts +0 -125
  644. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -123
  645. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -125
  646. package/node_modules/zod/src/v4/mini/checks.ts +0 -32
  647. package/node_modules/zod/src/v4/mini/coerce.ts +0 -22
  648. package/node_modules/zod/src/v4/mini/external.ts +0 -40
  649. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  650. package/node_modules/zod/src/v4/mini/iso.ts +0 -62
  651. package/node_modules/zod/src/v4/mini/parse.ts +0 -1
  652. package/node_modules/zod/src/v4/mini/schemas.ts +0 -1579
  653. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -129
  654. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -51
  655. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -144
  656. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -36
  657. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -22
  658. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -43
  659. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -871
  660. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -95
  661. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -185
  662. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  663. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -275
  664. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -299
  665. package/node_modules/zod/src/v4-mini/index.ts +0 -1
  666. package/node_modules/zod/v3/ZodError.cjs +0 -138
  667. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  668. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  669. package/node_modules/zod/v3/ZodError.js +0 -133
  670. package/node_modules/zod/v3/errors.cjs +0 -17
  671. package/node_modules/zod/v3/errors.d.cts +0 -5
  672. package/node_modules/zod/v3/errors.d.ts +0 -5
  673. package/node_modules/zod/v3/errors.js +0 -9
  674. package/node_modules/zod/v3/external.cjs +0 -22
  675. package/node_modules/zod/v3/external.d.cts +0 -6
  676. package/node_modules/zod/v3/external.d.ts +0 -6
  677. package/node_modules/zod/v3/external.js +0 -6
  678. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -2
  679. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  680. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  681. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  682. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -9
  683. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  684. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  685. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  686. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -124
  687. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  688. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  689. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  690. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -2
  691. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  692. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  693. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  694. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -2
  695. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  696. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  697. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  698. package/node_modules/zod/v3/helpers/util.cjs +0 -137
  699. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  700. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  701. package/node_modules/zod/v3/helpers/util.js +0 -133
  702. package/node_modules/zod/v3/index.cjs +0 -33
  703. package/node_modules/zod/v3/index.d.cts +0 -4
  704. package/node_modules/zod/v3/index.d.ts +0 -4
  705. package/node_modules/zod/v3/index.js +0 -4
  706. package/node_modules/zod/v3/locales/en.cjs +0 -111
  707. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  708. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  709. package/node_modules/zod/v3/locales/en.js +0 -109
  710. package/node_modules/zod/v3/standard-schema.cjs +0 -2
  711. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  712. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  713. package/node_modules/zod/v3/standard-schema.js +0 -1
  714. package/node_modules/zod/v3/types.cjs +0 -3775
  715. package/node_modules/zod/v3/types.d.cts +0 -1031
  716. package/node_modules/zod/v3/types.d.ts +0 -1031
  717. package/node_modules/zod/v3/types.js +0 -3693
  718. package/node_modules/zod/v4/classic/checks.cjs +0 -32
  719. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  720. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  721. package/node_modules/zod/v4/classic/checks.js +0 -1
  722. package/node_modules/zod/v4/classic/coerce.cjs +0 -47
  723. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  724. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  725. package/node_modules/zod/v4/classic/coerce.js +0 -17
  726. package/node_modules/zod/v4/classic/compat.cjs +0 -57
  727. package/node_modules/zod/v4/classic/compat.d.cts +0 -46
  728. package/node_modules/zod/v4/classic/compat.d.ts +0 -46
  729. package/node_modules/zod/v4/classic/compat.js +0 -27
  730. package/node_modules/zod/v4/classic/errors.cjs +0 -67
  731. package/node_modules/zod/v4/classic/errors.d.cts +0 -30
  732. package/node_modules/zod/v4/classic/errors.d.ts +0 -30
  733. package/node_modules/zod/v4/classic/errors.js +0 -41
  734. package/node_modules/zod/v4/classic/external.cjs +0 -70
  735. package/node_modules/zod/v4/classic/external.d.cts +0 -13
  736. package/node_modules/zod/v4/classic/external.d.ts +0 -13
  737. package/node_modules/zod/v4/classic/external.js +0 -18
  738. package/node_modules/zod/v4/classic/index.cjs +0 -33
  739. package/node_modules/zod/v4/classic/index.d.cts +0 -4
  740. package/node_modules/zod/v4/classic/index.d.ts +0 -4
  741. package/node_modules/zod/v4/classic/index.js +0 -4
  742. package/node_modules/zod/v4/classic/iso.cjs +0 -60
  743. package/node_modules/zod/v4/classic/iso.d.cts +0 -22
  744. package/node_modules/zod/v4/classic/iso.d.ts +0 -22
  745. package/node_modules/zod/v4/classic/iso.js +0 -30
  746. package/node_modules/zod/v4/classic/parse.cjs +0 -32
  747. package/node_modules/zod/v4/classic/parse.d.cts +0 -23
  748. package/node_modules/zod/v4/classic/parse.d.ts +0 -23
  749. package/node_modules/zod/v4/classic/parse.js +0 -6
  750. package/node_modules/zod/v4/classic/schemas.cjs +0 -1109
  751. package/node_modules/zod/v4/classic/schemas.d.cts +0 -630
  752. package/node_modules/zod/v4/classic/schemas.d.ts +0 -630
  753. package/node_modules/zod/v4/classic/schemas.js +0 -1006
  754. package/node_modules/zod/v4/core/api.cjs +0 -1039
  755. package/node_modules/zod/v4/core/api.d.cts +0 -284
  756. package/node_modules/zod/v4/core/api.d.ts +0 -284
  757. package/node_modules/zod/v4/core/api.js +0 -906
  758. package/node_modules/zod/v4/core/checks.cjs +0 -591
  759. package/node_modules/zod/v4/core/checks.d.cts +0 -278
  760. package/node_modules/zod/v4/core/checks.d.ts +0 -278
  761. package/node_modules/zod/v4/core/checks.js +0 -565
  762. package/node_modules/zod/v4/core/core.cjs +0 -67
  763. package/node_modules/zod/v4/core/core.d.cts +0 -49
  764. package/node_modules/zod/v4/core/core.d.ts +0 -49
  765. package/node_modules/zod/v4/core/core.js +0 -61
  766. package/node_modules/zod/v4/core/doc.cjs +0 -39
  767. package/node_modules/zod/v4/core/doc.d.cts +0 -14
  768. package/node_modules/zod/v4/core/doc.d.ts +0 -14
  769. package/node_modules/zod/v4/core/doc.js +0 -35
  770. package/node_modules/zod/v4/core/errors.cjs +0 -226
  771. package/node_modules/zod/v4/core/errors.d.cts +0 -208
  772. package/node_modules/zod/v4/core/errors.d.ts +0 -208
  773. package/node_modules/zod/v4/core/errors.js +0 -195
  774. package/node_modules/zod/v4/core/function.cjs +0 -102
  775. package/node_modules/zod/v4/core/function.d.cts +0 -52
  776. package/node_modules/zod/v4/core/function.d.ts +0 -52
  777. package/node_modules/zod/v4/core/function.js +0 -75
  778. package/node_modules/zod/v4/core/index.cjs +0 -44
  779. package/node_modules/zod/v4/core/index.d.cts +0 -15
  780. package/node_modules/zod/v4/core/index.d.ts +0 -15
  781. package/node_modules/zod/v4/core/index.js +0 -15
  782. package/node_modules/zod/v4/core/json-schema.cjs +0 -2
  783. package/node_modules/zod/v4/core/json-schema.d.cts +0 -87
  784. package/node_modules/zod/v4/core/json-schema.d.ts +0 -87
  785. package/node_modules/zod/v4/core/json-schema.js +0 -1
  786. package/node_modules/zod/v4/core/parse.cjs +0 -87
  787. package/node_modules/zod/v4/core/parse.d.cts +0 -25
  788. package/node_modules/zod/v4/core/parse.d.ts +0 -25
  789. package/node_modules/zod/v4/core/parse.js +0 -57
  790. package/node_modules/zod/v4/core/regexes.cjs +0 -103
  791. package/node_modules/zod/v4/core/regexes.d.cts +0 -62
  792. package/node_modules/zod/v4/core/regexes.d.ts +0 -62
  793. package/node_modules/zod/v4/core/regexes.js +0 -95
  794. package/node_modules/zod/v4/core/registries.cjs +0 -56
  795. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  796. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  797. package/node_modules/zod/v4/core/registries.js +0 -51
  798. package/node_modules/zod/v4/core/schemas.cjs +0 -1748
  799. package/node_modules/zod/v4/core/schemas.d.cts +0 -1041
  800. package/node_modules/zod/v4/core/schemas.d.ts +0 -1041
  801. package/node_modules/zod/v4/core/schemas.js +0 -1717
  802. package/node_modules/zod/v4/core/standard-schema.cjs +0 -2
  803. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -55
  804. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -55
  805. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  806. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -854
  807. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -88
  808. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -88
  809. package/node_modules/zod/v4/core/to-json-schema.js +0 -849
  810. package/node_modules/zod/v4/core/util.cjs +0 -539
  811. package/node_modules/zod/v4/core/util.d.cts +0 -183
  812. package/node_modules/zod/v4/core/util.d.ts +0 -183
  813. package/node_modules/zod/v4/core/util.js +0 -493
  814. package/node_modules/zod/v4/core/versions.cjs +0 -8
  815. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  816. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  817. package/node_modules/zod/v4/core/versions.js +0 -5
  818. package/node_modules/zod/v4/index.cjs +0 -22
  819. package/node_modules/zod/v4/index.d.cts +0 -3
  820. package/node_modules/zod/v4/index.d.ts +0 -3
  821. package/node_modules/zod/v4/index.js +0 -3
  822. package/node_modules/zod/v4/locales/ar.cjs +0 -142
  823. package/node_modules/zod/v4/locales/ar.d.cts +0 -4
  824. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  825. package/node_modules/zod/v4/locales/ar.js +0 -116
  826. package/node_modules/zod/v4/locales/az.cjs +0 -141
  827. package/node_modules/zod/v4/locales/az.d.cts +0 -4
  828. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  829. package/node_modules/zod/v4/locales/az.js +0 -115
  830. package/node_modules/zod/v4/locales/be.cjs +0 -190
  831. package/node_modules/zod/v4/locales/be.d.cts +0 -4
  832. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  833. package/node_modules/zod/v4/locales/be.js +0 -164
  834. package/node_modules/zod/v4/locales/ca.cjs +0 -144
  835. package/node_modules/zod/v4/locales/ca.d.cts +0 -4
  836. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  837. package/node_modules/zod/v4/locales/ca.js +0 -118
  838. package/node_modules/zod/v4/locales/cs.cjs +0 -161
  839. package/node_modules/zod/v4/locales/cs.d.cts +0 -4
  840. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  841. package/node_modules/zod/v4/locales/cs.js +0 -135
  842. package/node_modules/zod/v4/locales/de.cjs +0 -142
  843. package/node_modules/zod/v4/locales/de.d.cts +0 -4
  844. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  845. package/node_modules/zod/v4/locales/de.js +0 -116
  846. package/node_modules/zod/v4/locales/en.cjs +0 -145
  847. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  848. package/node_modules/zod/v4/locales/en.d.ts +0 -5
  849. package/node_modules/zod/v4/locales/en.js +0 -117
  850. package/node_modules/zod/v4/locales/eo.cjs +0 -144
  851. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  852. package/node_modules/zod/v4/locales/eo.d.ts +0 -5
  853. package/node_modules/zod/v4/locales/eo.js +0 -116
  854. package/node_modules/zod/v4/locales/es.cjs +0 -143
  855. package/node_modules/zod/v4/locales/es.d.cts +0 -4
  856. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  857. package/node_modules/zod/v4/locales/es.js +0 -117
  858. package/node_modules/zod/v4/locales/fa.cjs +0 -148
  859. package/node_modules/zod/v4/locales/fa.d.cts +0 -4
  860. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  861. package/node_modules/zod/v4/locales/fa.js +0 -122
  862. package/node_modules/zod/v4/locales/fi.cjs +0 -148
  863. package/node_modules/zod/v4/locales/fi.d.cts +0 -4
  864. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  865. package/node_modules/zod/v4/locales/fi.js +0 -122
  866. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -143
  867. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -4
  868. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  869. package/node_modules/zod/v4/locales/fr-CA.js +0 -117
  870. package/node_modules/zod/v4/locales/fr.cjs +0 -142
  871. package/node_modules/zod/v4/locales/fr.d.cts +0 -4
  872. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  873. package/node_modules/zod/v4/locales/fr.js +0 -116
  874. package/node_modules/zod/v4/locales/he.cjs +0 -143
  875. package/node_modules/zod/v4/locales/he.d.cts +0 -4
  876. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  877. package/node_modules/zod/v4/locales/he.js +0 -117
  878. package/node_modules/zod/v4/locales/hu.cjs +0 -143
  879. package/node_modules/zod/v4/locales/hu.d.cts +0 -4
  880. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  881. package/node_modules/zod/v4/locales/hu.js +0 -117
  882. package/node_modules/zod/v4/locales/id.cjs +0 -142
  883. package/node_modules/zod/v4/locales/id.d.cts +0 -4
  884. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  885. package/node_modules/zod/v4/locales/id.js +0 -116
  886. package/node_modules/zod/v4/locales/index.cjs +0 -84
  887. package/node_modules/zod/v4/locales/index.d.cts +0 -39
  888. package/node_modules/zod/v4/locales/index.d.ts +0 -39
  889. package/node_modules/zod/v4/locales/index.js +0 -39
  890. package/node_modules/zod/v4/locales/it.cjs +0 -143
  891. package/node_modules/zod/v4/locales/it.d.cts +0 -4
  892. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  893. package/node_modules/zod/v4/locales/it.js +0 -117
  894. package/node_modules/zod/v4/locales/ja.cjs +0 -141
  895. package/node_modules/zod/v4/locales/ja.d.cts +0 -4
  896. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  897. package/node_modules/zod/v4/locales/ja.js +0 -115
  898. package/node_modules/zod/v4/locales/kh.cjs +0 -143
  899. package/node_modules/zod/v4/locales/kh.d.cts +0 -4
  900. package/node_modules/zod/v4/locales/kh.d.ts +0 -4
  901. package/node_modules/zod/v4/locales/kh.js +0 -117
  902. package/node_modules/zod/v4/locales/ko.cjs +0 -147
  903. package/node_modules/zod/v4/locales/ko.d.cts +0 -4
  904. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  905. package/node_modules/zod/v4/locales/ko.js +0 -121
  906. package/node_modules/zod/v4/locales/mk.cjs +0 -144
  907. package/node_modules/zod/v4/locales/mk.d.cts +0 -4
  908. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  909. package/node_modules/zod/v4/locales/mk.js +0 -118
  910. package/node_modules/zod/v4/locales/ms.cjs +0 -142
  911. package/node_modules/zod/v4/locales/ms.d.cts +0 -4
  912. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  913. package/node_modules/zod/v4/locales/ms.js +0 -116
  914. package/node_modules/zod/v4/locales/nl.cjs +0 -143
  915. package/node_modules/zod/v4/locales/nl.d.cts +0 -4
  916. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  917. package/node_modules/zod/v4/locales/nl.js +0 -117
  918. package/node_modules/zod/v4/locales/no.cjs +0 -142
  919. package/node_modules/zod/v4/locales/no.d.cts +0 -4
  920. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  921. package/node_modules/zod/v4/locales/no.js +0 -116
  922. package/node_modules/zod/v4/locales/ota.cjs +0 -143
  923. package/node_modules/zod/v4/locales/ota.d.cts +0 -4
  924. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  925. package/node_modules/zod/v4/locales/ota.js +0 -117
  926. package/node_modules/zod/v4/locales/pl.cjs +0 -143
  927. package/node_modules/zod/v4/locales/pl.d.cts +0 -4
  928. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  929. package/node_modules/zod/v4/locales/pl.js +0 -117
  930. package/node_modules/zod/v4/locales/ps.cjs +0 -148
  931. package/node_modules/zod/v4/locales/ps.d.cts +0 -4
  932. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  933. package/node_modules/zod/v4/locales/ps.js +0 -122
  934. package/node_modules/zod/v4/locales/pt.cjs +0 -142
  935. package/node_modules/zod/v4/locales/pt.d.cts +0 -4
  936. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  937. package/node_modules/zod/v4/locales/pt.js +0 -116
  938. package/node_modules/zod/v4/locales/ru.cjs +0 -190
  939. package/node_modules/zod/v4/locales/ru.d.cts +0 -4
  940. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  941. package/node_modules/zod/v4/locales/ru.js +0 -164
  942. package/node_modules/zod/v4/locales/sl.cjs +0 -143
  943. package/node_modules/zod/v4/locales/sl.d.cts +0 -4
  944. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  945. package/node_modules/zod/v4/locales/sl.js +0 -117
  946. package/node_modules/zod/v4/locales/sv.cjs +0 -144
  947. package/node_modules/zod/v4/locales/sv.d.cts +0 -4
  948. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  949. package/node_modules/zod/v4/locales/sv.js +0 -118
  950. package/node_modules/zod/v4/locales/ta.cjs +0 -143
  951. package/node_modules/zod/v4/locales/ta.d.cts +0 -4
  952. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  953. package/node_modules/zod/v4/locales/ta.js +0 -117
  954. package/node_modules/zod/v4/locales/th.cjs +0 -143
  955. package/node_modules/zod/v4/locales/th.d.cts +0 -4
  956. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  957. package/node_modules/zod/v4/locales/th.js +0 -117
  958. package/node_modules/zod/v4/locales/tr.cjs +0 -143
  959. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  960. package/node_modules/zod/v4/locales/tr.d.ts +0 -5
  961. package/node_modules/zod/v4/locales/tr.js +0 -115
  962. package/node_modules/zod/v4/locales/ua.cjs +0 -143
  963. package/node_modules/zod/v4/locales/ua.d.cts +0 -4
  964. package/node_modules/zod/v4/locales/ua.d.ts +0 -4
  965. package/node_modules/zod/v4/locales/ua.js +0 -117
  966. package/node_modules/zod/v4/locales/ur.cjs +0 -143
  967. package/node_modules/zod/v4/locales/ur.d.cts +0 -4
  968. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  969. package/node_modules/zod/v4/locales/ur.js +0 -117
  970. package/node_modules/zod/v4/locales/vi.cjs +0 -142
  971. package/node_modules/zod/v4/locales/vi.d.cts +0 -4
  972. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  973. package/node_modules/zod/v4/locales/vi.js +0 -116
  974. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -142
  975. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -4
  976. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  977. package/node_modules/zod/v4/locales/zh-CN.js +0 -116
  978. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -143
  979. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -4
  980. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  981. package/node_modules/zod/v4/locales/zh-TW.js +0 -117
  982. package/node_modules/zod/v4/mini/checks.cjs +0 -34
  983. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  984. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  985. package/node_modules/zod/v4/mini/checks.js +0 -1
  986. package/node_modules/zod/v4/mini/coerce.cjs +0 -47
  987. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  988. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  989. package/node_modules/zod/v4/mini/coerce.js +0 -17
  990. package/node_modules/zod/v4/mini/external.cjs +0 -62
  991. package/node_modules/zod/v4/mini/external.d.cts +0 -11
  992. package/node_modules/zod/v4/mini/external.d.ts +0 -11
  993. package/node_modules/zod/v4/mini/external.js +0 -13
  994. package/node_modules/zod/v4/mini/index.cjs +0 -32
  995. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  996. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  997. package/node_modules/zod/v4/mini/index.js +0 -3
  998. package/node_modules/zod/v4/mini/iso.cjs +0 -60
  999. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  1000. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  1001. package/node_modules/zod/v4/mini/iso.js +0 -30
  1002. package/node_modules/zod/v4/mini/parse.cjs +0 -8
  1003. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  1004. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  1005. package/node_modules/zod/v4/mini/parse.js +0 -1
  1006. package/node_modules/zod/v4/mini/schemas.cjs +0 -839
  1007. package/node_modules/zod/v4/mini/schemas.d.cts +0 -356
  1008. package/node_modules/zod/v4/mini/schemas.d.ts +0 -356
  1009. package/node_modules/zod/v4/mini/schemas.js +0 -732
  1010. package/node_modules/zod/v4-mini/index.cjs +0 -17
  1011. package/node_modules/zod/v4-mini/index.d.cts +0 -1
  1012. package/node_modules/zod/v4-mini/index.d.ts +0 -1
  1013. package/node_modules/zod/v4-mini/index.js +0 -1
@@ -1,1973 +0,0 @@
1
- /**
2
- * Javascript implementation of basic RSA algorithms.
3
- *
4
- * @author Dave Longley
5
- *
6
- * Copyright (c) 2010-2014 Digital Bazaar, Inc.
7
- *
8
- * The only algorithm currently supported for PKI is RSA.
9
- *
10
- * An RSA key is often stored in ASN.1 DER format. The SubjectPublicKeyInfo
11
- * ASN.1 structure is composed of an algorithm of type AlgorithmIdentifier
12
- * and a subjectPublicKey of type bit string.
13
- *
14
- * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters
15
- * for the algorithm, if any. In the case of RSA, there aren't any.
16
- *
17
- * SubjectPublicKeyInfo ::= SEQUENCE {
18
- * algorithm AlgorithmIdentifier,
19
- * subjectPublicKey BIT STRING
20
- * }
21
- *
22
- * AlgorithmIdentifer ::= SEQUENCE {
23
- * algorithm OBJECT IDENTIFIER,
24
- * parameters ANY DEFINED BY algorithm OPTIONAL
25
- * }
26
- *
27
- * For an RSA public key, the subjectPublicKey is:
28
- *
29
- * RSAPublicKey ::= SEQUENCE {
30
- * modulus INTEGER, -- n
31
- * publicExponent INTEGER -- e
32
- * }
33
- *
34
- * PrivateKeyInfo ::= SEQUENCE {
35
- * version Version,
36
- * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
37
- * privateKey PrivateKey,
38
- * attributes [0] IMPLICIT Attributes OPTIONAL
39
- * }
40
- *
41
- * Version ::= INTEGER
42
- * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
43
- * PrivateKey ::= OCTET STRING
44
- * Attributes ::= SET OF Attribute
45
- *
46
- * An RSA private key as the following structure:
47
- *
48
- * RSAPrivateKey ::= SEQUENCE {
49
- * version Version,
50
- * modulus INTEGER, -- n
51
- * publicExponent INTEGER, -- e
52
- * privateExponent INTEGER, -- d
53
- * prime1 INTEGER, -- p
54
- * prime2 INTEGER, -- q
55
- * exponent1 INTEGER, -- d mod (p-1)
56
- * exponent2 INTEGER, -- d mod (q-1)
57
- * coefficient INTEGER -- (inverse of q) mod p
58
- * }
59
- *
60
- * Version ::= INTEGER
61
- *
62
- * The OID for the RSA key algorithm is: 1.2.840.113549.1.1.1
63
- */
64
- var forge = require('./forge');
65
- require('./asn1');
66
- require('./jsbn');
67
- require('./oids');
68
- require('./pkcs1');
69
- require('./prime');
70
- require('./random');
71
- require('./util');
72
-
73
- if(typeof BigInteger === 'undefined') {
74
- var BigInteger = forge.jsbn.BigInteger;
75
- }
76
-
77
- var _crypto = forge.util.isNodejs ? require('crypto') : null;
78
-
79
- // shortcut for asn.1 API
80
- var asn1 = forge.asn1;
81
-
82
- // shortcut for util API
83
- var util = forge.util;
84
-
85
- /*
86
- * RSA encryption and decryption, see RFC 2313.
87
- */
88
- forge.pki = forge.pki || {};
89
- module.exports = forge.pki.rsa = forge.rsa = forge.rsa || {};
90
- var pki = forge.pki;
91
-
92
- // for finding primes, which are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29
93
- var GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];
94
-
95
- // validator for a PrivateKeyInfo structure
96
- var privateKeyValidator = {
97
- // PrivateKeyInfo
98
- name: 'PrivateKeyInfo',
99
- tagClass: asn1.Class.UNIVERSAL,
100
- type: asn1.Type.SEQUENCE,
101
- constructed: true,
102
- value: [{
103
- // Version (INTEGER)
104
- name: 'PrivateKeyInfo.version',
105
- tagClass: asn1.Class.UNIVERSAL,
106
- type: asn1.Type.INTEGER,
107
- constructed: false,
108
- capture: 'privateKeyVersion'
109
- }, {
110
- // privateKeyAlgorithm
111
- name: 'PrivateKeyInfo.privateKeyAlgorithm',
112
- tagClass: asn1.Class.UNIVERSAL,
113
- type: asn1.Type.SEQUENCE,
114
- constructed: true,
115
- value: [{
116
- name: 'AlgorithmIdentifier.algorithm',
117
- tagClass: asn1.Class.UNIVERSAL,
118
- type: asn1.Type.OID,
119
- constructed: false,
120
- capture: 'privateKeyOid'
121
- }]
122
- }, {
123
- // PrivateKey
124
- name: 'PrivateKeyInfo',
125
- tagClass: asn1.Class.UNIVERSAL,
126
- type: asn1.Type.OCTETSTRING,
127
- constructed: false,
128
- capture: 'privateKey'
129
- }]
130
- };
131
-
132
- // validator for an RSA private key
133
- var rsaPrivateKeyValidator = {
134
- // RSAPrivateKey
135
- name: 'RSAPrivateKey',
136
- tagClass: asn1.Class.UNIVERSAL,
137
- type: asn1.Type.SEQUENCE,
138
- constructed: true,
139
- value: [{
140
- // Version (INTEGER)
141
- name: 'RSAPrivateKey.version',
142
- tagClass: asn1.Class.UNIVERSAL,
143
- type: asn1.Type.INTEGER,
144
- constructed: false,
145
- capture: 'privateKeyVersion'
146
- }, {
147
- // modulus (n)
148
- name: 'RSAPrivateKey.modulus',
149
- tagClass: asn1.Class.UNIVERSAL,
150
- type: asn1.Type.INTEGER,
151
- constructed: false,
152
- capture: 'privateKeyModulus'
153
- }, {
154
- // publicExponent (e)
155
- name: 'RSAPrivateKey.publicExponent',
156
- tagClass: asn1.Class.UNIVERSAL,
157
- type: asn1.Type.INTEGER,
158
- constructed: false,
159
- capture: 'privateKeyPublicExponent'
160
- }, {
161
- // privateExponent (d)
162
- name: 'RSAPrivateKey.privateExponent',
163
- tagClass: asn1.Class.UNIVERSAL,
164
- type: asn1.Type.INTEGER,
165
- constructed: false,
166
- capture: 'privateKeyPrivateExponent'
167
- }, {
168
- // prime1 (p)
169
- name: 'RSAPrivateKey.prime1',
170
- tagClass: asn1.Class.UNIVERSAL,
171
- type: asn1.Type.INTEGER,
172
- constructed: false,
173
- capture: 'privateKeyPrime1'
174
- }, {
175
- // prime2 (q)
176
- name: 'RSAPrivateKey.prime2',
177
- tagClass: asn1.Class.UNIVERSAL,
178
- type: asn1.Type.INTEGER,
179
- constructed: false,
180
- capture: 'privateKeyPrime2'
181
- }, {
182
- // exponent1 (d mod (p-1))
183
- name: 'RSAPrivateKey.exponent1',
184
- tagClass: asn1.Class.UNIVERSAL,
185
- type: asn1.Type.INTEGER,
186
- constructed: false,
187
- capture: 'privateKeyExponent1'
188
- }, {
189
- // exponent2 (d mod (q-1))
190
- name: 'RSAPrivateKey.exponent2',
191
- tagClass: asn1.Class.UNIVERSAL,
192
- type: asn1.Type.INTEGER,
193
- constructed: false,
194
- capture: 'privateKeyExponent2'
195
- }, {
196
- // coefficient ((inverse of q) mod p)
197
- name: 'RSAPrivateKey.coefficient',
198
- tagClass: asn1.Class.UNIVERSAL,
199
- type: asn1.Type.INTEGER,
200
- constructed: false,
201
- capture: 'privateKeyCoefficient'
202
- }]
203
- };
204
-
205
- // validator for an RSA public key
206
- var rsaPublicKeyValidator = {
207
- // RSAPublicKey
208
- name: 'RSAPublicKey',
209
- tagClass: asn1.Class.UNIVERSAL,
210
- type: asn1.Type.SEQUENCE,
211
- constructed: true,
212
- value: [{
213
- // modulus (n)
214
- name: 'RSAPublicKey.modulus',
215
- tagClass: asn1.Class.UNIVERSAL,
216
- type: asn1.Type.INTEGER,
217
- constructed: false,
218
- capture: 'publicKeyModulus'
219
- }, {
220
- // publicExponent (e)
221
- name: 'RSAPublicKey.exponent',
222
- tagClass: asn1.Class.UNIVERSAL,
223
- type: asn1.Type.INTEGER,
224
- constructed: false,
225
- capture: 'publicKeyExponent'
226
- }]
227
- };
228
-
229
- // validator for an SubjectPublicKeyInfo structure
230
- // Note: Currently only works with an RSA public key
231
- var publicKeyValidator = forge.pki.rsa.publicKeyValidator = {
232
- name: 'SubjectPublicKeyInfo',
233
- tagClass: asn1.Class.UNIVERSAL,
234
- type: asn1.Type.SEQUENCE,
235
- constructed: true,
236
- captureAsn1: 'subjectPublicKeyInfo',
237
- value: [{
238
- name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',
239
- tagClass: asn1.Class.UNIVERSAL,
240
- type: asn1.Type.SEQUENCE,
241
- constructed: true,
242
- value: [{
243
- name: 'AlgorithmIdentifier.algorithm',
244
- tagClass: asn1.Class.UNIVERSAL,
245
- type: asn1.Type.OID,
246
- constructed: false,
247
- capture: 'publicKeyOid'
248
- }]
249
- }, {
250
- // subjectPublicKey
251
- name: 'SubjectPublicKeyInfo.subjectPublicKey',
252
- tagClass: asn1.Class.UNIVERSAL,
253
- type: asn1.Type.BITSTRING,
254
- constructed: false,
255
- value: [{
256
- // RSAPublicKey
257
- name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',
258
- tagClass: asn1.Class.UNIVERSAL,
259
- type: asn1.Type.SEQUENCE,
260
- constructed: true,
261
- optional: true,
262
- captureAsn1: 'rsaPublicKey'
263
- }]
264
- }]
265
- };
266
-
267
- // validator for a DigestInfo structure
268
- var digestInfoValidator = {
269
- name: 'DigestInfo',
270
- tagClass: asn1.Class.UNIVERSAL,
271
- type: asn1.Type.SEQUENCE,
272
- constructed: true,
273
- value: [{
274
- name: 'DigestInfo.DigestAlgorithm',
275
- tagClass: asn1.Class.UNIVERSAL,
276
- type: asn1.Type.SEQUENCE,
277
- constructed: true,
278
- value: [{
279
- name: 'DigestInfo.DigestAlgorithm.algorithmIdentifier',
280
- tagClass: asn1.Class.UNIVERSAL,
281
- type: asn1.Type.OID,
282
- constructed: false,
283
- capture: 'algorithmIdentifier'
284
- }, {
285
- // NULL parameters
286
- name: 'DigestInfo.DigestAlgorithm.parameters',
287
- tagClass: asn1.Class.UNIVERSAL,
288
- type: asn1.Type.NULL,
289
- // captured only to check existence for md2 and md5
290
- capture: 'parameters',
291
- optional: true,
292
- constructed: false
293
- }]
294
- }, {
295
- // digest
296
- name: 'DigestInfo.digest',
297
- tagClass: asn1.Class.UNIVERSAL,
298
- type: asn1.Type.OCTETSTRING,
299
- constructed: false,
300
- capture: 'digest'
301
- }]
302
- };
303
-
304
- /**
305
- * Wrap digest in DigestInfo object.
306
- *
307
- * This function implements EMSA-PKCS1-v1_5-ENCODE as per RFC 3447.
308
- *
309
- * DigestInfo ::= SEQUENCE {
310
- * digestAlgorithm DigestAlgorithmIdentifier,
311
- * digest Digest
312
- * }
313
- *
314
- * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
315
- * Digest ::= OCTET STRING
316
- *
317
- * @param md the message digest object with the hash to sign.
318
- *
319
- * @return the encoded message (ready for RSA encryption)
320
- */
321
- var emsaPkcs1v15encode = function(md) {
322
- // get the oid for the algorithm
323
- var oid;
324
- if(md.algorithm in pki.oids) {
325
- oid = pki.oids[md.algorithm];
326
- } else {
327
- var error = new Error('Unknown message digest algorithm.');
328
- error.algorithm = md.algorithm;
329
- throw error;
330
- }
331
- var oidBytes = asn1.oidToDer(oid).getBytes();
332
-
333
- // create the digest info
334
- var digestInfo = asn1.create(
335
- asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
336
- var digestAlgorithm = asn1.create(
337
- asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
338
- digestAlgorithm.value.push(asn1.create(
339
- asn1.Class.UNIVERSAL, asn1.Type.OID, false, oidBytes));
340
- digestAlgorithm.value.push(asn1.create(
341
- asn1.Class.UNIVERSAL, asn1.Type.NULL, false, ''));
342
- var digest = asn1.create(
343
- asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,
344
- false, md.digest().getBytes());
345
- digestInfo.value.push(digestAlgorithm);
346
- digestInfo.value.push(digest);
347
-
348
- // encode digest info
349
- return asn1.toDer(digestInfo).getBytes();
350
- };
351
-
352
- /**
353
- * Performs x^c mod n (RSA encryption or decryption operation).
354
- *
355
- * @param x the number to raise and mod.
356
- * @param key the key to use.
357
- * @param pub true if the key is public, false if private.
358
- *
359
- * @return the result of x^c mod n.
360
- */
361
- var _modPow = function(x, key, pub) {
362
- if(pub) {
363
- return x.modPow(key.e, key.n);
364
- }
365
-
366
- if(!key.p || !key.q) {
367
- // allow calculation without CRT params (slow)
368
- return x.modPow(key.d, key.n);
369
- }
370
-
371
- // pre-compute dP, dQ, and qInv if necessary
372
- if(!key.dP) {
373
- key.dP = key.d.mod(key.p.subtract(BigInteger.ONE));
374
- }
375
- if(!key.dQ) {
376
- key.dQ = key.d.mod(key.q.subtract(BigInteger.ONE));
377
- }
378
- if(!key.qInv) {
379
- key.qInv = key.q.modInverse(key.p);
380
- }
381
-
382
- /* Chinese remainder theorem (CRT) states:
383
-
384
- Suppose n1, n2, ..., nk are positive integers which are pairwise
385
- coprime (n1 and n2 have no common factors other than 1). For any
386
- integers x1, x2, ..., xk there exists an integer x solving the
387
- system of simultaneous congruences (where ~= means modularly
388
- congruent so a ~= b mod n means a mod n = b mod n):
389
-
390
- x ~= x1 mod n1
391
- x ~= x2 mod n2
392
- ...
393
- x ~= xk mod nk
394
-
395
- This system of congruences has a single simultaneous solution x
396
- between 0 and n - 1. Furthermore, each xk solution and x itself
397
- is congruent modulo the product n = n1*n2*...*nk.
398
- So x1 mod n = x2 mod n = xk mod n = x mod n.
399
-
400
- The single simultaneous solution x can be solved with the following
401
- equation:
402
-
403
- x = sum(xi*ri*si) mod n where ri = n/ni and si = ri^-1 mod ni.
404
-
405
- Where x is less than n, xi = x mod ni.
406
-
407
- For RSA we are only concerned with k = 2. The modulus n = pq, where
408
- p and q are coprime. The RSA decryption algorithm is:
409
-
410
- y = x^d mod n
411
-
412
- Given the above:
413
-
414
- x1 = x^d mod p
415
- r1 = n/p = q
416
- s1 = q^-1 mod p
417
- x2 = x^d mod q
418
- r2 = n/q = p
419
- s2 = p^-1 mod q
420
-
421
- So y = (x1r1s1 + x2r2s2) mod n
422
- = ((x^d mod p)q(q^-1 mod p) + (x^d mod q)p(p^-1 mod q)) mod n
423
-
424
- According to Fermat's Little Theorem, if the modulus P is prime,
425
- for any integer A not evenly divisible by P, A^(P-1) ~= 1 mod P.
426
- Since A is not divisible by P it follows that if:
427
- N ~= M mod (P - 1), then A^N mod P = A^M mod P. Therefore:
428
-
429
- A^N mod P = A^(M mod (P - 1)) mod P. (The latter takes less effort
430
- to calculate). In order to calculate x^d mod p more quickly the
431
- exponent d mod (p - 1) is stored in the RSA private key (the same
432
- is done for x^d mod q). These values are referred to as dP and dQ
433
- respectively. Therefore we now have:
434
-
435
- y = ((x^dP mod p)q(q^-1 mod p) + (x^dQ mod q)p(p^-1 mod q)) mod n
436
-
437
- Since we'll be reducing x^dP by modulo p (same for q) we can also
438
- reduce x by p (and q respectively) before hand. Therefore, let
439
-
440
- xp = ((x mod p)^dP mod p), and
441
- xq = ((x mod q)^dQ mod q), yielding:
442
-
443
- y = (xp*q*(q^-1 mod p) + xq*p*(p^-1 mod q)) mod n
444
-
445
- This can be further reduced to a simple algorithm that only
446
- requires 1 inverse (the q inverse is used) to be used and stored.
447
- The algorithm is called Garner's algorithm. If qInv is the
448
- inverse of q, we simply calculate:
449
-
450
- y = (qInv*(xp - xq) mod p) * q + xq
451
-
452
- However, there are two further complications. First, we need to
453
- ensure that xp > xq to prevent signed BigIntegers from being used
454
- so we add p until this is true (since we will be mod'ing with
455
- p anyway). Then, there is a known timing attack on algorithms
456
- using the CRT. To mitigate this risk, "cryptographic blinding"
457
- should be used. This requires simply generating a random number r
458
- between 0 and n-1 and its inverse and multiplying x by r^e before
459
- calculating y and then multiplying y by r^-1 afterwards. Note that
460
- r must be coprime with n (gcd(r, n) === 1) in order to have an
461
- inverse.
462
- */
463
-
464
- // cryptographic blinding
465
- var r;
466
- do {
467
- r = new BigInteger(
468
- forge.util.bytesToHex(forge.random.getBytes(key.n.bitLength() / 8)),
469
- 16);
470
- } while(r.compareTo(key.n) >= 0 || !r.gcd(key.n).equals(BigInteger.ONE));
471
- x = x.multiply(r.modPow(key.e, key.n)).mod(key.n);
472
-
473
- // calculate xp and xq
474
- var xp = x.mod(key.p).modPow(key.dP, key.p);
475
- var xq = x.mod(key.q).modPow(key.dQ, key.q);
476
-
477
- // xp must be larger than xq to avoid signed bit usage
478
- while(xp.compareTo(xq) < 0) {
479
- xp = xp.add(key.p);
480
- }
481
-
482
- // do last step
483
- var y = xp.subtract(xq)
484
- .multiply(key.qInv).mod(key.p)
485
- .multiply(key.q).add(xq);
486
-
487
- // remove effect of random for cryptographic blinding
488
- y = y.multiply(r.modInverse(key.n)).mod(key.n);
489
-
490
- return y;
491
- };
492
-
493
- /**
494
- * NOTE: THIS METHOD IS DEPRECATED, use 'sign' on a private key object or
495
- * 'encrypt' on a public key object instead.
496
- *
497
- * Performs RSA encryption.
498
- *
499
- * The parameter bt controls whether to put padding bytes before the
500
- * message passed in. Set bt to either true or false to disable padding
501
- * completely (in order to handle e.g. EMSA-PSS encoding separately before),
502
- * signaling whether the encryption operation is a public key operation
503
- * (i.e. encrypting data) or not, i.e. private key operation (data signing).
504
- *
505
- * For PKCS#1 v1.5 padding pass in the block type to use, i.e. either 0x01
506
- * (for signing) or 0x02 (for encryption). The key operation mode (private
507
- * or public) is derived from this flag in that case).
508
- *
509
- * @param m the message to encrypt as a byte string.
510
- * @param key the RSA key to use.
511
- * @param bt for PKCS#1 v1.5 padding, the block type to use
512
- * (0x01 for private key, 0x02 for public),
513
- * to disable padding: true = public key, false = private key.
514
- *
515
- * @return the encrypted bytes as a string.
516
- */
517
- pki.rsa.encrypt = function(m, key, bt) {
518
- var pub = bt;
519
- var eb;
520
-
521
- // get the length of the modulus in bytes
522
- var k = Math.ceil(key.n.bitLength() / 8);
523
-
524
- if(bt !== false && bt !== true) {
525
- // legacy, default to PKCS#1 v1.5 padding
526
- pub = (bt === 0x02);
527
- eb = _encodePkcs1_v1_5(m, key, bt);
528
- } else {
529
- eb = forge.util.createBuffer();
530
- eb.putBytes(m);
531
- }
532
-
533
- // load encryption block as big integer 'x'
534
- // FIXME: hex conversion inefficient, get BigInteger w/byte strings
535
- var x = new BigInteger(eb.toHex(), 16);
536
-
537
- // do RSA encryption
538
- var y = _modPow(x, key, pub);
539
-
540
- // convert y into the encrypted data byte string, if y is shorter in
541
- // bytes than k, then prepend zero bytes to fill up ed
542
- // FIXME: hex conversion inefficient, get BigInteger w/byte strings
543
- var yhex = y.toString(16);
544
- var ed = forge.util.createBuffer();
545
- var zeros = k - Math.ceil(yhex.length / 2);
546
- while(zeros > 0) {
547
- ed.putByte(0x00);
548
- --zeros;
549
- }
550
- ed.putBytes(forge.util.hexToBytes(yhex));
551
- return ed.getBytes();
552
- };
553
-
554
- /**
555
- * NOTE: THIS METHOD IS DEPRECATED, use 'decrypt' on a private key object or
556
- * 'verify' on a public key object instead.
557
- *
558
- * Performs RSA decryption.
559
- *
560
- * The parameter ml controls whether to apply PKCS#1 v1.5 padding
561
- * or not. Set ml = false to disable padding removal completely
562
- * (in order to handle e.g. EMSA-PSS later on) and simply pass back
563
- * the RSA encryption block.
564
- *
565
- * @param ed the encrypted data to decrypt in as a byte string.
566
- * @param key the RSA key to use.
567
- * @param pub true for a public key operation, false for private.
568
- * @param ml the message length, if known, false to disable padding.
569
- *
570
- * @return the decrypted message as a byte string.
571
- */
572
- pki.rsa.decrypt = function(ed, key, pub, ml) {
573
- // get the length of the modulus in bytes
574
- var k = Math.ceil(key.n.bitLength() / 8);
575
-
576
- // error if the length of the encrypted data ED is not k
577
- if(ed.length !== k) {
578
- var error = new Error('Encrypted message length is invalid.');
579
- error.length = ed.length;
580
- error.expected = k;
581
- throw error;
582
- }
583
-
584
- // convert encrypted data into a big integer
585
- // FIXME: hex conversion inefficient, get BigInteger w/byte strings
586
- var y = new BigInteger(forge.util.createBuffer(ed).toHex(), 16);
587
-
588
- // y must be less than the modulus or it wasn't the result of
589
- // a previous mod operation (encryption) using that modulus
590
- if(y.compareTo(key.n) >= 0) {
591
- throw new Error('Encrypted message is invalid.');
592
- }
593
-
594
- // do RSA decryption
595
- var x = _modPow(y, key, pub);
596
-
597
- // create the encryption block, if x is shorter in bytes than k, then
598
- // prepend zero bytes to fill up eb
599
- // FIXME: hex conversion inefficient, get BigInteger w/byte strings
600
- var xhex = x.toString(16);
601
- var eb = forge.util.createBuffer();
602
- var zeros = k - Math.ceil(xhex.length / 2);
603
- while(zeros > 0) {
604
- eb.putByte(0x00);
605
- --zeros;
606
- }
607
- eb.putBytes(forge.util.hexToBytes(xhex));
608
-
609
- if(ml !== false) {
610
- // legacy, default to PKCS#1 v1.5 padding
611
- return _decodePkcs1_v1_5(eb.getBytes(), key, pub);
612
- }
613
-
614
- // return message
615
- return eb.getBytes();
616
- };
617
-
618
- /**
619
- * Creates an RSA key-pair generation state object. It is used to allow
620
- * key-generation to be performed in steps. It also allows for a UI to
621
- * display progress updates.
622
- *
623
- * @param bits the size for the private key in bits, defaults to 2048.
624
- * @param e the public exponent to use, defaults to 65537 (0x10001).
625
- * @param [options] the options to use.
626
- * prng a custom crypto-secure pseudo-random number generator to use,
627
- * that must define "getBytesSync".
628
- * algorithm the algorithm to use (default: 'PRIMEINC').
629
- *
630
- * @return the state object to use to generate the key-pair.
631
- */
632
- pki.rsa.createKeyPairGenerationState = function(bits, e, options) {
633
- // TODO: migrate step-based prime generation code to forge.prime
634
-
635
- // set default bits
636
- if(typeof(bits) === 'string') {
637
- bits = parseInt(bits, 10);
638
- }
639
- bits = bits || 2048;
640
-
641
- // create prng with api that matches BigInteger secure random
642
- options = options || {};
643
- var prng = options.prng || forge.random;
644
- var rng = {
645
- // x is an array to fill with bytes
646
- nextBytes: function(x) {
647
- var b = prng.getBytesSync(x.length);
648
- for(var i = 0; i < x.length; ++i) {
649
- x[i] = b.charCodeAt(i);
650
- }
651
- }
652
- };
653
-
654
- var algorithm = options.algorithm || 'PRIMEINC';
655
-
656
- // create PRIMEINC algorithm state
657
- var rval;
658
- if(algorithm === 'PRIMEINC') {
659
- rval = {
660
- algorithm: algorithm,
661
- state: 0,
662
- bits: bits,
663
- rng: rng,
664
- eInt: e || 65537,
665
- e: new BigInteger(null),
666
- p: null,
667
- q: null,
668
- qBits: bits >> 1,
669
- pBits: bits - (bits >> 1),
670
- pqState: 0,
671
- num: null,
672
- keys: null
673
- };
674
- rval.e.fromInt(rval.eInt);
675
- } else {
676
- throw new Error('Invalid key generation algorithm: ' + algorithm);
677
- }
678
-
679
- return rval;
680
- };
681
-
682
- /**
683
- * Attempts to runs the key-generation algorithm for at most n seconds
684
- * (approximately) using the given state. When key-generation has completed,
685
- * the keys will be stored in state.keys.
686
- *
687
- * To use this function to update a UI while generating a key or to prevent
688
- * causing browser lockups/warnings, set "n" to a value other than 0. A
689
- * simple pattern for generating a key and showing a progress indicator is:
690
- *
691
- * var state = pki.rsa.createKeyPairGenerationState(2048);
692
- * var step = function() {
693
- * // step key-generation, run algorithm for 100 ms, repeat
694
- * if(!forge.pki.rsa.stepKeyPairGenerationState(state, 100)) {
695
- * setTimeout(step, 1);
696
- * } else {
697
- * // key-generation complete
698
- * // TODO: turn off progress indicator here
699
- * // TODO: use the generated key-pair in "state.keys"
700
- * }
701
- * };
702
- * // TODO: turn on progress indicator here
703
- * setTimeout(step, 0);
704
- *
705
- * @param state the state to use.
706
- * @param n the maximum number of milliseconds to run the algorithm for, 0
707
- * to run the algorithm to completion.
708
- *
709
- * @return true if the key-generation completed, false if not.
710
- */
711
- pki.rsa.stepKeyPairGenerationState = function(state, n) {
712
- // set default algorithm if not set
713
- if(!('algorithm' in state)) {
714
- state.algorithm = 'PRIMEINC';
715
- }
716
-
717
- // TODO: migrate step-based prime generation code to forge.prime
718
- // TODO: abstract as PRIMEINC algorithm
719
-
720
- // do key generation (based on Tom Wu's rsa.js, see jsbn.js license)
721
- // with some minor optimizations and designed to run in steps
722
-
723
- // local state vars
724
- var THIRTY = new BigInteger(null);
725
- THIRTY.fromInt(30);
726
- var deltaIdx = 0;
727
- var op_or = function(x, y) {return x | y;};
728
-
729
- // keep stepping until time limit is reached or done
730
- var t1 = +new Date();
731
- var t2;
732
- var total = 0;
733
- while(state.keys === null && (n <= 0 || total < n)) {
734
- // generate p or q
735
- if(state.state === 0) {
736
- /* Note: All primes are of the form:
737
-
738
- 30k+i, for i < 30 and gcd(30, i)=1, where there are 8 values for i
739
-
740
- When we generate a random number, we always align it at 30k + 1. Each
741
- time the number is determined not to be prime we add to get to the
742
- next 'i', eg: if the number was at 30k + 1 we add 6. */
743
- var bits = (state.p === null) ? state.pBits : state.qBits;
744
- var bits1 = bits - 1;
745
-
746
- // get a random number
747
- if(state.pqState === 0) {
748
- state.num = new BigInteger(bits, state.rng);
749
- // force MSB set
750
- if(!state.num.testBit(bits1)) {
751
- state.num.bitwiseTo(
752
- BigInteger.ONE.shiftLeft(bits1), op_or, state.num);
753
- }
754
- // align number on 30k+1 boundary
755
- state.num.dAddOffset(31 - state.num.mod(THIRTY).byteValue(), 0);
756
- deltaIdx = 0;
757
-
758
- ++state.pqState;
759
- } else if(state.pqState === 1) {
760
- // try to make the number a prime
761
- if(state.num.bitLength() > bits) {
762
- // overflow, try again
763
- state.pqState = 0;
764
- // do primality test
765
- } else if(state.num.isProbablePrime(
766
- _getMillerRabinTests(state.num.bitLength()))) {
767
- ++state.pqState;
768
- } else {
769
- // get next potential prime
770
- state.num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);
771
- }
772
- } else if(state.pqState === 2) {
773
- // ensure number is coprime with e
774
- state.pqState =
775
- (state.num.subtract(BigInteger.ONE).gcd(state.e)
776
- .compareTo(BigInteger.ONE) === 0) ? 3 : 0;
777
- } else if(state.pqState === 3) {
778
- // store p or q
779
- state.pqState = 0;
780
- if(state.p === null) {
781
- state.p = state.num;
782
- } else {
783
- state.q = state.num;
784
- }
785
-
786
- // advance state if both p and q are ready
787
- if(state.p !== null && state.q !== null) {
788
- ++state.state;
789
- }
790
- state.num = null;
791
- }
792
- } else if(state.state === 1) {
793
- // ensure p is larger than q (swap them if not)
794
- if(state.p.compareTo(state.q) < 0) {
795
- state.num = state.p;
796
- state.p = state.q;
797
- state.q = state.num;
798
- }
799
- ++state.state;
800
- } else if(state.state === 2) {
801
- // compute phi: (p - 1)(q - 1) (Euler's totient function)
802
- state.p1 = state.p.subtract(BigInteger.ONE);
803
- state.q1 = state.q.subtract(BigInteger.ONE);
804
- state.phi = state.p1.multiply(state.q1);
805
- ++state.state;
806
- } else if(state.state === 3) {
807
- // ensure e and phi are coprime
808
- if(state.phi.gcd(state.e).compareTo(BigInteger.ONE) === 0) {
809
- // phi and e are coprime, advance
810
- ++state.state;
811
- } else {
812
- // phi and e aren't coprime, so generate a new p and q
813
- state.p = null;
814
- state.q = null;
815
- state.state = 0;
816
- }
817
- } else if(state.state === 4) {
818
- // create n, ensure n is has the right number of bits
819
- state.n = state.p.multiply(state.q);
820
-
821
- // ensure n is right number of bits
822
- if(state.n.bitLength() === state.bits) {
823
- // success, advance
824
- ++state.state;
825
- } else {
826
- // failed, get new q
827
- state.q = null;
828
- state.state = 0;
829
- }
830
- } else if(state.state === 5) {
831
- // set keys
832
- var d = state.e.modInverse(state.phi);
833
- state.keys = {
834
- privateKey: pki.rsa.setPrivateKey(
835
- state.n, state.e, d, state.p, state.q,
836
- d.mod(state.p1), d.mod(state.q1),
837
- state.q.modInverse(state.p)),
838
- publicKey: pki.rsa.setPublicKey(state.n, state.e)
839
- };
840
- }
841
-
842
- // update timing
843
- t2 = +new Date();
844
- total += t2 - t1;
845
- t1 = t2;
846
- }
847
-
848
- return state.keys !== null;
849
- };
850
-
851
- /**
852
- * Generates an RSA public-private key pair in a single call.
853
- *
854
- * To generate a key-pair in steps (to allow for progress updates and to
855
- * prevent blocking or warnings in slow browsers) then use the key-pair
856
- * generation state functions.
857
- *
858
- * To generate a key-pair asynchronously (either through web-workers, if
859
- * available, or by breaking up the work on the main thread), pass a
860
- * callback function.
861
- *
862
- * @param [bits] the size for the private key in bits, defaults to 2048.
863
- * @param [e] the public exponent to use, defaults to 65537.
864
- * @param [options] options for key-pair generation, if given then 'bits'
865
- * and 'e' must *not* be given:
866
- * bits the size for the private key in bits, (default: 2048).
867
- * e the public exponent to use, (default: 65537 (0x10001)).
868
- * workerScript the worker script URL.
869
- * workers the number of web workers (if supported) to use,
870
- * (default: 2).
871
- * workLoad the size of the work load, ie: number of possible prime
872
- * numbers for each web worker to check per work assignment,
873
- * (default: 100).
874
- * prng a custom crypto-secure pseudo-random number generator to use,
875
- * that must define "getBytesSync". Disables use of native APIs.
876
- * algorithm the algorithm to use (default: 'PRIMEINC').
877
- * @param [callback(err, keypair)] called once the operation completes.
878
- *
879
- * @return an object with privateKey and publicKey properties.
880
- */
881
- pki.rsa.generateKeyPair = function(bits, e, options, callback) {
882
- // (bits), (options), (callback)
883
- if(arguments.length === 1) {
884
- if(typeof bits === 'object') {
885
- options = bits;
886
- bits = undefined;
887
- } else if(typeof bits === 'function') {
888
- callback = bits;
889
- bits = undefined;
890
- }
891
- } else if(arguments.length === 2) {
892
- // (bits, e), (bits, options), (bits, callback), (options, callback)
893
- if(typeof bits === 'number') {
894
- if(typeof e === 'function') {
895
- callback = e;
896
- e = undefined;
897
- } else if(typeof e !== 'number') {
898
- options = e;
899
- e = undefined;
900
- }
901
- } else {
902
- options = bits;
903
- callback = e;
904
- bits = undefined;
905
- e = undefined;
906
- }
907
- } else if(arguments.length === 3) {
908
- // (bits, e, options), (bits, e, callback), (bits, options, callback)
909
- if(typeof e === 'number') {
910
- if(typeof options === 'function') {
911
- callback = options;
912
- options = undefined;
913
- }
914
- } else {
915
- callback = options;
916
- options = e;
917
- e = undefined;
918
- }
919
- }
920
- options = options || {};
921
- if(bits === undefined) {
922
- bits = options.bits || 2048;
923
- }
924
- if(e === undefined) {
925
- e = options.e || 0x10001;
926
- }
927
-
928
- // use native code if permitted, available, and parameters are acceptable
929
- if(!forge.options.usePureJavaScript && !options.prng &&
930
- bits >= 256 && bits <= 16384 && (e === 0x10001 || e === 3)) {
931
- if(callback) {
932
- // try native async
933
- if(_detectNodeCrypto('generateKeyPair')) {
934
- return _crypto.generateKeyPair('rsa', {
935
- modulusLength: bits,
936
- publicExponent: e,
937
- publicKeyEncoding: {
938
- type: 'spki',
939
- format: 'pem'
940
- },
941
- privateKeyEncoding: {
942
- type: 'pkcs8',
943
- format: 'pem'
944
- }
945
- }, function(err, pub, priv) {
946
- if(err) {
947
- return callback(err);
948
- }
949
- callback(null, {
950
- privateKey: pki.privateKeyFromPem(priv),
951
- publicKey: pki.publicKeyFromPem(pub)
952
- });
953
- });
954
- }
955
- if(_detectSubtleCrypto('generateKey') &&
956
- _detectSubtleCrypto('exportKey')) {
957
- // use standard native generateKey
958
- return util.globalScope.crypto.subtle.generateKey({
959
- name: 'RSASSA-PKCS1-v1_5',
960
- modulusLength: bits,
961
- publicExponent: _intToUint8Array(e),
962
- hash: {name: 'SHA-256'}
963
- }, true /* key can be exported*/, ['sign', 'verify'])
964
- .then(function(pair) {
965
- return util.globalScope.crypto.subtle.exportKey(
966
- 'pkcs8', pair.privateKey);
967
- // avoiding catch(function(err) {...}) to support IE <= 8
968
- }).then(undefined, function(err) {
969
- callback(err);
970
- }).then(function(pkcs8) {
971
- if(pkcs8) {
972
- var privateKey = pki.privateKeyFromAsn1(
973
- asn1.fromDer(forge.util.createBuffer(pkcs8)));
974
- callback(null, {
975
- privateKey: privateKey,
976
- publicKey: pki.setRsaPublicKey(privateKey.n, privateKey.e)
977
- });
978
- }
979
- });
980
- }
981
- if(_detectSubtleMsCrypto('generateKey') &&
982
- _detectSubtleMsCrypto('exportKey')) {
983
- var genOp = util.globalScope.msCrypto.subtle.generateKey({
984
- name: 'RSASSA-PKCS1-v1_5',
985
- modulusLength: bits,
986
- publicExponent: _intToUint8Array(e),
987
- hash: {name: 'SHA-256'}
988
- }, true /* key can be exported*/, ['sign', 'verify']);
989
- genOp.oncomplete = function(e) {
990
- var pair = e.target.result;
991
- var exportOp = util.globalScope.msCrypto.subtle.exportKey(
992
- 'pkcs8', pair.privateKey);
993
- exportOp.oncomplete = function(e) {
994
- var pkcs8 = e.target.result;
995
- var privateKey = pki.privateKeyFromAsn1(
996
- asn1.fromDer(forge.util.createBuffer(pkcs8)));
997
- callback(null, {
998
- privateKey: privateKey,
999
- publicKey: pki.setRsaPublicKey(privateKey.n, privateKey.e)
1000
- });
1001
- };
1002
- exportOp.onerror = function(err) {
1003
- callback(err);
1004
- };
1005
- };
1006
- genOp.onerror = function(err) {
1007
- callback(err);
1008
- };
1009
- return;
1010
- }
1011
- } else {
1012
- // try native sync
1013
- if(_detectNodeCrypto('generateKeyPairSync')) {
1014
- var keypair = _crypto.generateKeyPairSync('rsa', {
1015
- modulusLength: bits,
1016
- publicExponent: e,
1017
- publicKeyEncoding: {
1018
- type: 'spki',
1019
- format: 'pem'
1020
- },
1021
- privateKeyEncoding: {
1022
- type: 'pkcs8',
1023
- format: 'pem'
1024
- }
1025
- });
1026
- return {
1027
- privateKey: pki.privateKeyFromPem(keypair.privateKey),
1028
- publicKey: pki.publicKeyFromPem(keypair.publicKey)
1029
- };
1030
- }
1031
- }
1032
- }
1033
-
1034
- // use JavaScript implementation
1035
- var state = pki.rsa.createKeyPairGenerationState(bits, e, options);
1036
- if(!callback) {
1037
- pki.rsa.stepKeyPairGenerationState(state, 0);
1038
- return state.keys;
1039
- }
1040
- _generateKeyPair(state, options, callback);
1041
- };
1042
-
1043
- /**
1044
- * Sets an RSA public key from BigIntegers modulus and exponent.
1045
- *
1046
- * @param n the modulus.
1047
- * @param e the exponent.
1048
- *
1049
- * @return the public key.
1050
- */
1051
- pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
1052
- var key = {
1053
- n: n,
1054
- e: e
1055
- };
1056
-
1057
- /**
1058
- * Encrypts the given data with this public key. Newer applications
1059
- * should use the 'RSA-OAEP' decryption scheme, 'RSAES-PKCS1-V1_5' is for
1060
- * legacy applications.
1061
- *
1062
- * @param data the byte string to encrypt.
1063
- * @param scheme the encryption scheme to use:
1064
- * 'RSAES-PKCS1-V1_5' (default),
1065
- * 'RSA-OAEP',
1066
- * 'RAW', 'NONE', or null to perform raw RSA encryption,
1067
- * an object with an 'encode' property set to a function
1068
- * with the signature 'function(data, key)' that returns
1069
- * a binary-encoded string representing the encoded data.
1070
- * @param schemeOptions any scheme-specific options.
1071
- *
1072
- * @return the encrypted byte string.
1073
- */
1074
- key.encrypt = function(data, scheme, schemeOptions) {
1075
- if(typeof scheme === 'string') {
1076
- scheme = scheme.toUpperCase();
1077
- } else if(scheme === undefined) {
1078
- scheme = 'RSAES-PKCS1-V1_5';
1079
- }
1080
-
1081
- if(scheme === 'RSAES-PKCS1-V1_5') {
1082
- scheme = {
1083
- encode: function(m, key, pub) {
1084
- return _encodePkcs1_v1_5(m, key, 0x02).getBytes();
1085
- }
1086
- };
1087
- } else if(scheme === 'RSA-OAEP' || scheme === 'RSAES-OAEP') {
1088
- scheme = {
1089
- encode: function(m, key) {
1090
- return forge.pkcs1.encode_rsa_oaep(key, m, schemeOptions);
1091
- }
1092
- };
1093
- } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {
1094
- scheme = {encode: function(e) {return e;}};
1095
- } else if(typeof scheme === 'string') {
1096
- throw new Error('Unsupported encryption scheme: "' + scheme + '".');
1097
- }
1098
-
1099
- // do scheme-based encoding then rsa encryption
1100
- var e = scheme.encode(data, key, true);
1101
- return pki.rsa.encrypt(e, key, true);
1102
- };
1103
-
1104
- /**
1105
- * Verifies the given signature against the given digest.
1106
- *
1107
- * PKCS#1 supports multiple (currently two) signature schemes:
1108
- * RSASSA-PKCS1-V1_5 and RSASSA-PSS.
1109
- *
1110
- * By default this implementation uses the "old scheme", i.e.
1111
- * RSASSA-PKCS1-V1_5, in which case once RSA-decrypted, the
1112
- * signature is an OCTET STRING that holds a DigestInfo.
1113
- *
1114
- * DigestInfo ::= SEQUENCE {
1115
- * digestAlgorithm DigestAlgorithmIdentifier,
1116
- * digest Digest
1117
- * }
1118
- * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
1119
- * Digest ::= OCTET STRING
1120
- *
1121
- * To perform PSS signature verification, provide an instance
1122
- * of Forge PSS object as the scheme parameter.
1123
- *
1124
- * @param digest the message digest hash to compare against the signature,
1125
- * as a binary-encoded string.
1126
- * @param signature the signature to verify, as a binary-encoded string.
1127
- * @param scheme signature verification scheme to use:
1128
- * 'RSASSA-PKCS1-V1_5' or undefined for RSASSA PKCS#1 v1.5,
1129
- * a Forge PSS object for RSASSA-PSS,
1130
- * 'NONE' or null for none, DigestInfo will not be expected, but
1131
- * PKCS#1 v1.5 padding will still be used.
1132
- * @param options optional verify options
1133
- * _parseAllDigestBytes testing flag to control parsing of all
1134
- * digest bytes. Unsupported and not for general usage.
1135
- * (default: true)
1136
- * _skipPaddingChecks testing flag to skip some padding checks to
1137
- * test other checks. Unsupported and not for general usage.
1138
- * (default: false)
1139
- *
1140
- * @return true if the signature was verified, false if not.
1141
- */
1142
- key.verify = function(digest, signature, scheme, options) {
1143
- if(typeof scheme === 'string') {
1144
- scheme = scheme.toUpperCase();
1145
- } else if(scheme === undefined) {
1146
- scheme = 'RSASSA-PKCS1-V1_5';
1147
- }
1148
- if(options === undefined) {
1149
- options = {
1150
- _parseAllDigestBytes: true,
1151
- _skipPaddingChecks: false
1152
- };
1153
- }
1154
- if(!('_parseAllDigestBytes' in options)) {
1155
- options._parseAllDigestBytes = true;
1156
- }
1157
- if(!('_skipPaddingChecks' in options)) {
1158
- options._skipPaddingChecks = false;
1159
- }
1160
-
1161
- if(scheme === 'RSASSA-PKCS1-V1_5') {
1162
- scheme = {
1163
- verify: function(digest, d) {
1164
- // remove padding
1165
- d = _decodePkcs1_v1_5(d, key, true, undefined, options);
1166
- // d is ASN.1 BER-encoded DigestInfo
1167
- var obj = asn1.fromDer(d, {
1168
- parseAllBytes: options._parseAllDigestBytes
1169
- });
1170
-
1171
- // validate DigestInfo structure and element counts (outer DigestInfo
1172
- // and nested DigestAlgorithm). asn1.validate ignores extra children,
1173
- // so length must be checked explicitly at each nesting level to
1174
- // prevent low-exponent PKCS#1 v1.5 signature forgery (CVE-2026-85393).
1175
- var capture = {};
1176
- var errors = [];
1177
- if(!asn1.validate(obj, digestInfoValidator, capture, errors) ||
1178
- obj.value.length !== 2 ||
1179
- obj.value[0].value.length !==
1180
- (('parameters' in capture) ? 2 : 1)) {
1181
- var error = new Error(
1182
- 'ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 ' +
1183
- 'DigestInfo value.');
1184
- error.errors = errors;
1185
- throw error;
1186
- }
1187
- // check hash algorithm identifier
1188
- // see PKCS1-v1-5DigestAlgorithms in RFC 8017
1189
- // FIXME: add support to validator for strict value choices
1190
- var oid = asn1.derToOid(capture.algorithmIdentifier);
1191
- if(!(oid === forge.oids.md2 ||
1192
- oid === forge.oids.md5 ||
1193
- oid === forge.oids.sha1 ||
1194
- oid === forge.oids.sha224 ||
1195
- oid === forge.oids.sha256 ||
1196
- oid === forge.oids.sha384 ||
1197
- oid === forge.oids.sha512 ||
1198
- oid === forge.oids['sha512-224'] ||
1199
- oid === forge.oids['sha512-256'])) {
1200
- var error = new Error(
1201
- 'Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.');
1202
- error.oid = oid;
1203
- throw error;
1204
- }
1205
-
1206
- // special check for md2 and md5 that NULL parameters exist
1207
- if(oid === forge.oids.md2 || oid === forge.oids.md5) {
1208
- if(!('parameters' in capture)) {
1209
- throw new Error(
1210
- 'ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 ' +
1211
- 'DigestInfo value. ' +
1212
- 'Missing algorithm identifier NULL parameters.');
1213
- }
1214
- }
1215
-
1216
- // compare the given digest to the decrypted one
1217
- return digest === capture.digest;
1218
- }
1219
- };
1220
- } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {
1221
- scheme = {
1222
- verify: function(digest, d) {
1223
- // remove padding
1224
- d = _decodePkcs1_v1_5(d, key, true, undefined, options);
1225
- return digest === d;
1226
- }
1227
- };
1228
- }
1229
-
1230
- // do rsa decryption w/o any decoding, then verify -- which does decoding
1231
- var d = pki.rsa.decrypt(signature, key, true, false);
1232
- return scheme.verify(digest, d, key.n.bitLength());
1233
- };
1234
-
1235
- return key;
1236
- };
1237
-
1238
- /**
1239
- * Sets an RSA private key from BigIntegers modulus, exponent, primes,
1240
- * prime exponents, and modular multiplicative inverse.
1241
- *
1242
- * @param n the modulus.
1243
- * @param e the public exponent.
1244
- * @param d the private exponent ((inverse of e) mod n).
1245
- * @param p the first prime.
1246
- * @param q the second prime.
1247
- * @param dP exponent1 (d mod (p-1)).
1248
- * @param dQ exponent2 (d mod (q-1)).
1249
- * @param qInv ((inverse of q) mod p)
1250
- *
1251
- * @return the private key.
1252
- */
1253
- pki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(
1254
- n, e, d, p, q, dP, dQ, qInv) {
1255
- var key = {
1256
- n: n,
1257
- e: e,
1258
- d: d,
1259
- p: p,
1260
- q: q,
1261
- dP: dP,
1262
- dQ: dQ,
1263
- qInv: qInv
1264
- };
1265
-
1266
- /**
1267
- * Decrypts the given data with this private key. The decryption scheme
1268
- * must match the one used to encrypt the data.
1269
- *
1270
- * @param data the byte string to decrypt.
1271
- * @param scheme the decryption scheme to use:
1272
- * 'RSAES-PKCS1-V1_5' (default),
1273
- * 'RSA-OAEP',
1274
- * 'RAW', 'NONE', or null to perform raw RSA decryption.
1275
- * @param schemeOptions any scheme-specific options.
1276
- *
1277
- * @return the decrypted byte string.
1278
- */
1279
- key.decrypt = function(data, scheme, schemeOptions) {
1280
- if(typeof scheme === 'string') {
1281
- scheme = scheme.toUpperCase();
1282
- } else if(scheme === undefined) {
1283
- scheme = 'RSAES-PKCS1-V1_5';
1284
- }
1285
-
1286
- // do rsa decryption w/o any decoding
1287
- var d = pki.rsa.decrypt(data, key, false, false);
1288
-
1289
- if(scheme === 'RSAES-PKCS1-V1_5') {
1290
- scheme = {decode: _decodePkcs1_v1_5};
1291
- } else if(scheme === 'RSA-OAEP' || scheme === 'RSAES-OAEP') {
1292
- scheme = {
1293
- decode: function(d, key) {
1294
- return forge.pkcs1.decode_rsa_oaep(key, d, schemeOptions);
1295
- }
1296
- };
1297
- } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {
1298
- scheme = {decode: function(d) {return d;}};
1299
- } else {
1300
- throw new Error('Unsupported encryption scheme: "' + scheme + '".');
1301
- }
1302
-
1303
- // decode according to scheme
1304
- return scheme.decode(d, key, false);
1305
- };
1306
-
1307
- /**
1308
- * Signs the given digest, producing a signature.
1309
- *
1310
- * PKCS#1 supports multiple (currently two) signature schemes:
1311
- * RSASSA-PKCS1-V1_5 and RSASSA-PSS.
1312
- *
1313
- * By default this implementation uses the "old scheme", i.e.
1314
- * RSASSA-PKCS1-V1_5. In order to generate a PSS signature, provide
1315
- * an instance of Forge PSS object as the scheme parameter.
1316
- *
1317
- * @param md the message digest object with the hash to sign.
1318
- * @param scheme the signature scheme to use:
1319
- * 'RSASSA-PKCS1-V1_5' or undefined for RSASSA PKCS#1 v1.5,
1320
- * a Forge PSS object for RSASSA-PSS,
1321
- * 'NONE' or null for none, DigestInfo will not be used but
1322
- * PKCS#1 v1.5 padding will still be used.
1323
- *
1324
- * @return the signature as a byte string.
1325
- */
1326
- key.sign = function(md, scheme) {
1327
- /* Note: The internal implementation of RSA operations is being
1328
- transitioned away from a PKCS#1 v1.5 hard-coded scheme. Some legacy
1329
- code like the use of an encoding block identifier 'bt' will eventually
1330
- be removed. */
1331
-
1332
- // private key operation
1333
- var bt = false;
1334
-
1335
- if(typeof scheme === 'string') {
1336
- scheme = scheme.toUpperCase();
1337
- }
1338
-
1339
- if(scheme === undefined || scheme === 'RSASSA-PKCS1-V1_5') {
1340
- scheme = {encode: emsaPkcs1v15encode};
1341
- bt = 0x01;
1342
- } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {
1343
- scheme = {encode: function() {return md;}};
1344
- bt = 0x01;
1345
- }
1346
-
1347
- // encode and then encrypt
1348
- var d = scheme.encode(md, key.n.bitLength());
1349
- return pki.rsa.encrypt(d, key, bt);
1350
- };
1351
-
1352
- return key;
1353
- };
1354
-
1355
- /**
1356
- * Wraps an RSAPrivateKey ASN.1 object in an ASN.1 PrivateKeyInfo object.
1357
- *
1358
- * @param rsaKey the ASN.1 RSAPrivateKey.
1359
- *
1360
- * @return the ASN.1 PrivateKeyInfo.
1361
- */
1362
- pki.wrapRsaPrivateKey = function(rsaKey) {
1363
- // PrivateKeyInfo
1364
- return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
1365
- // version (0)
1366
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1367
- asn1.integerToDer(0).getBytes()),
1368
- // privateKeyAlgorithm
1369
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
1370
- asn1.create(
1371
- asn1.Class.UNIVERSAL, asn1.Type.OID, false,
1372
- asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),
1373
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
1374
- ]),
1375
- // PrivateKey
1376
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
1377
- asn1.toDer(rsaKey).getBytes())
1378
- ]);
1379
- };
1380
-
1381
- /**
1382
- * Converts a private key from an ASN.1 object.
1383
- *
1384
- * @param obj the ASN.1 representation of a PrivateKeyInfo containing an
1385
- * RSAPrivateKey or an RSAPrivateKey.
1386
- *
1387
- * @return the private key.
1388
- */
1389
- pki.privateKeyFromAsn1 = function(obj) {
1390
- // get PrivateKeyInfo
1391
- var capture = {};
1392
- var errors = [];
1393
- if(asn1.validate(obj, privateKeyValidator, capture, errors)) {
1394
- obj = asn1.fromDer(forge.util.createBuffer(capture.privateKey));
1395
- }
1396
-
1397
- // get RSAPrivateKey
1398
- capture = {};
1399
- errors = [];
1400
- if(!asn1.validate(obj, rsaPrivateKeyValidator, capture, errors)) {
1401
- var error = new Error('Cannot read private key. ' +
1402
- 'ASN.1 object does not contain an RSAPrivateKey.');
1403
- error.errors = errors;
1404
- throw error;
1405
- }
1406
-
1407
- // Note: Version is currently ignored.
1408
- // capture.privateKeyVersion
1409
- // FIXME: inefficient, get a BigInteger that uses byte strings
1410
- var n, e, d, p, q, dP, dQ, qInv;
1411
- n = forge.util.createBuffer(capture.privateKeyModulus).toHex();
1412
- e = forge.util.createBuffer(capture.privateKeyPublicExponent).toHex();
1413
- d = forge.util.createBuffer(capture.privateKeyPrivateExponent).toHex();
1414
- p = forge.util.createBuffer(capture.privateKeyPrime1).toHex();
1415
- q = forge.util.createBuffer(capture.privateKeyPrime2).toHex();
1416
- dP = forge.util.createBuffer(capture.privateKeyExponent1).toHex();
1417
- dQ = forge.util.createBuffer(capture.privateKeyExponent2).toHex();
1418
- qInv = forge.util.createBuffer(capture.privateKeyCoefficient).toHex();
1419
-
1420
- // set private key
1421
- return pki.setRsaPrivateKey(
1422
- new BigInteger(n, 16),
1423
- new BigInteger(e, 16),
1424
- new BigInteger(d, 16),
1425
- new BigInteger(p, 16),
1426
- new BigInteger(q, 16),
1427
- new BigInteger(dP, 16),
1428
- new BigInteger(dQ, 16),
1429
- new BigInteger(qInv, 16));
1430
- };
1431
-
1432
- /**
1433
- * Converts a private key to an ASN.1 RSAPrivateKey.
1434
- *
1435
- * @param key the private key.
1436
- *
1437
- * @return the ASN.1 representation of an RSAPrivateKey.
1438
- */
1439
- pki.privateKeyToAsn1 = pki.privateKeyToRSAPrivateKey = function(key) {
1440
- // RSAPrivateKey
1441
- return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
1442
- // version (0 = only 2 primes, 1 multiple primes)
1443
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1444
- asn1.integerToDer(0).getBytes()),
1445
- // modulus (n)
1446
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1447
- _bnToBytes(key.n)),
1448
- // publicExponent (e)
1449
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1450
- _bnToBytes(key.e)),
1451
- // privateExponent (d)
1452
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1453
- _bnToBytes(key.d)),
1454
- // privateKeyPrime1 (p)
1455
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1456
- _bnToBytes(key.p)),
1457
- // privateKeyPrime2 (q)
1458
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1459
- _bnToBytes(key.q)),
1460
- // privateKeyExponent1 (dP)
1461
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1462
- _bnToBytes(key.dP)),
1463
- // privateKeyExponent2 (dQ)
1464
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1465
- _bnToBytes(key.dQ)),
1466
- // coefficient (qInv)
1467
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1468
- _bnToBytes(key.qInv))
1469
- ]);
1470
- };
1471
-
1472
- /**
1473
- * Converts a public key from an ASN.1 SubjectPublicKeyInfo or RSAPublicKey.
1474
- *
1475
- * @param obj the asn1 representation of a SubjectPublicKeyInfo or RSAPublicKey.
1476
- *
1477
- * @return the public key.
1478
- */
1479
- pki.publicKeyFromAsn1 = function(obj) {
1480
- // get SubjectPublicKeyInfo
1481
- var capture = {};
1482
- var errors = [];
1483
- if(asn1.validate(obj, publicKeyValidator, capture, errors)) {
1484
- // get oid
1485
- var oid = asn1.derToOid(capture.publicKeyOid);
1486
- if(oid !== pki.oids.rsaEncryption) {
1487
- var error = new Error('Cannot read public key. Unknown OID.');
1488
- error.oid = oid;
1489
- throw error;
1490
- }
1491
- obj = capture.rsaPublicKey;
1492
- }
1493
-
1494
- // get RSA params
1495
- errors = [];
1496
- if(!asn1.validate(obj, rsaPublicKeyValidator, capture, errors)) {
1497
- var error = new Error('Cannot read public key. ' +
1498
- 'ASN.1 object does not contain an RSAPublicKey.');
1499
- error.errors = errors;
1500
- throw error;
1501
- }
1502
-
1503
- // FIXME: inefficient, get a BigInteger that uses byte strings
1504
- var n = forge.util.createBuffer(capture.publicKeyModulus).toHex();
1505
- var e = forge.util.createBuffer(capture.publicKeyExponent).toHex();
1506
-
1507
- // set public key
1508
- return pki.setRsaPublicKey(
1509
- new BigInteger(n, 16),
1510
- new BigInteger(e, 16));
1511
- };
1512
-
1513
- /**
1514
- * Converts a public key to an ASN.1 SubjectPublicKeyInfo.
1515
- *
1516
- * @param key the public key.
1517
- *
1518
- * @return the asn1 representation of a SubjectPublicKeyInfo.
1519
- */
1520
- pki.publicKeyToAsn1 = pki.publicKeyToSubjectPublicKeyInfo = function(key) {
1521
- // SubjectPublicKeyInfo
1522
- return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
1523
- // AlgorithmIdentifier
1524
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
1525
- // algorithm
1526
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
1527
- asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),
1528
- // parameters (null)
1529
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
1530
- ]),
1531
- // subjectPublicKey
1532
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, [
1533
- pki.publicKeyToRSAPublicKey(key)
1534
- ])
1535
- ]);
1536
- };
1537
-
1538
- /**
1539
- * Converts a public key to an ASN.1 RSAPublicKey.
1540
- *
1541
- * @param key the public key.
1542
- *
1543
- * @return the asn1 representation of a RSAPublicKey.
1544
- */
1545
- pki.publicKeyToRSAPublicKey = function(key) {
1546
- // RSAPublicKey
1547
- return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
1548
- // modulus (n)
1549
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1550
- _bnToBytes(key.n)),
1551
- // publicExponent (e)
1552
- asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
1553
- _bnToBytes(key.e))
1554
- ]);
1555
- };
1556
-
1557
- /**
1558
- * Encodes a message using PKCS#1 v1.5 padding.
1559
- *
1560
- * @param m the message to encode.
1561
- * @param key the RSA key to use.
1562
- * @param bt the block type to use, i.e. either 0x01 (for signing) or 0x02
1563
- * (for encryption).
1564
- *
1565
- * @return the padded byte buffer.
1566
- */
1567
- function _encodePkcs1_v1_5(m, key, bt) {
1568
- var eb = forge.util.createBuffer();
1569
-
1570
- // get the length of the modulus in bytes
1571
- var k = Math.ceil(key.n.bitLength() / 8);
1572
-
1573
- /* use PKCS#1 v1.5 padding */
1574
- if(m.length > (k - 11)) {
1575
- var error = new Error('Message is too long for PKCS#1 v1.5 padding.');
1576
- error.length = m.length;
1577
- error.max = k - 11;
1578
- throw error;
1579
- }
1580
-
1581
- /* A block type BT, a padding string PS, and the data D shall be
1582
- formatted into an octet string EB, the encryption block:
1583
-
1584
- EB = 00 || BT || PS || 00 || D
1585
-
1586
- The block type BT shall be a single octet indicating the structure of
1587
- the encryption block. For this version of the document it shall have
1588
- value 00, 01, or 02. For a private-key operation, the block type
1589
- shall be 00 or 01. For a public-key operation, it shall be 02.
1590
-
1591
- The padding string PS shall consist of k-3-||D|| octets. For block
1592
- type 00, the octets shall have value 00; for block type 01, they
1593
- shall have value FF; and for block type 02, they shall be
1594
- pseudorandomly generated and nonzero. This makes the length of the
1595
- encryption block EB equal to k. */
1596
-
1597
- // build the encryption block
1598
- eb.putByte(0x00);
1599
- eb.putByte(bt);
1600
-
1601
- // create the padding
1602
- var padNum = k - 3 - m.length;
1603
- var padByte;
1604
- // private key op
1605
- if(bt === 0x00 || bt === 0x01) {
1606
- padByte = (bt === 0x00) ? 0x00 : 0xFF;
1607
- for(var i = 0; i < padNum; ++i) {
1608
- eb.putByte(padByte);
1609
- }
1610
- } else {
1611
- // public key op
1612
- // pad with random non-zero values
1613
- while(padNum > 0) {
1614
- var numZeros = 0;
1615
- var padBytes = forge.random.getBytes(padNum);
1616
- for(var i = 0; i < padNum; ++i) {
1617
- padByte = padBytes.charCodeAt(i);
1618
- if(padByte === 0) {
1619
- ++numZeros;
1620
- } else {
1621
- eb.putByte(padByte);
1622
- }
1623
- }
1624
- padNum = numZeros;
1625
- }
1626
- }
1627
-
1628
- // zero followed by message
1629
- eb.putByte(0x00);
1630
- eb.putBytes(m);
1631
-
1632
- return eb;
1633
- }
1634
-
1635
- /**
1636
- * Decodes a message using PKCS#1 v1.5 padding.
1637
- *
1638
- * @param em the message to decode.
1639
- * @param key the RSA key to use.
1640
- * @param pub true if the key is a public key, false if it is private.
1641
- * @param ml the message length, if specified.
1642
- * @param options testing options.
1643
- *
1644
- * @return the decoded bytes.
1645
- */
1646
- function _decodePkcs1_v1_5(em, key, pub, ml, options) {
1647
- // get the length of the modulus in bytes
1648
- var k = Math.ceil(key.n.bitLength() / 8);
1649
-
1650
- /* It is an error if any of the following conditions occurs:
1651
-
1652
- 1. The encryption block EB cannot be parsed unambiguously.
1653
- 2. The padding string PS consists of fewer than eight octets
1654
- or is inconsistent with the block type BT.
1655
- 3. The decryption process is a public-key operation and the block
1656
- type BT is not 00 or 01, or the decryption process is a
1657
- private-key operation and the block type is not 02.
1658
- */
1659
-
1660
- // parse the encryption block
1661
- var eb = forge.util.createBuffer(em);
1662
- var first = eb.getByte();
1663
- var bt = eb.getByte();
1664
- if(first !== 0x00 ||
1665
- (pub && bt !== 0x00 && bt !== 0x01) ||
1666
- (!pub && bt !== 0x02) ||
1667
- (pub && bt === 0x00 && typeof(ml) === 'undefined')) {
1668
- throw new Error('Encryption block is invalid.');
1669
- }
1670
-
1671
- var padNum = 0;
1672
- if(bt === 0x00) {
1673
- // check all padding bytes for 0x00
1674
- padNum = k - 3 - ml;
1675
- for(var i = 0; i < padNum; ++i) {
1676
- if(eb.getByte() !== 0x00) {
1677
- throw new Error('Encryption block is invalid.');
1678
- }
1679
- }
1680
- } else if(bt === 0x01) {
1681
- // find the first byte that isn't 0xFF, should be after all padding
1682
- padNum = 0;
1683
- while(eb.length() > 1) {
1684
- if(eb.getByte() !== 0xFF) {
1685
- --eb.read;
1686
- break;
1687
- }
1688
- ++padNum;
1689
- }
1690
-
1691
- // RFC 2313 8.1 note 6
1692
- if(padNum < 8 && !(options ? options._skipPaddingChecks : false)) {
1693
- throw new Error('Encryption block is invalid.');
1694
- }
1695
- } else if(bt === 0x02) {
1696
- // look for 0x00 byte
1697
- padNum = 0;
1698
- while(eb.length() > 1) {
1699
- if(eb.getByte() === 0x00) {
1700
- --eb.read;
1701
- break;
1702
- }
1703
- ++padNum;
1704
- }
1705
-
1706
- // RFC 2313 8.1 note 6
1707
- if(padNum < 8 && !(options ? options._skipPaddingChecks : false)) {
1708
- throw new Error('Encryption block is invalid.');
1709
- }
1710
- }
1711
-
1712
- // zero must be 0x00 and padNum must be (k - 3 - message length)
1713
- var zero = eb.getByte();
1714
- if(zero !== 0x00 || padNum !== (k - 3 - eb.length())) {
1715
- throw new Error('Encryption block is invalid.');
1716
- }
1717
-
1718
- return eb.getBytes();
1719
- }
1720
-
1721
- /**
1722
- * Runs the key-generation algorithm asynchronously, either in the background
1723
- * via Web Workers, or using the main thread and setImmediate.
1724
- *
1725
- * @param state the key-pair generation state.
1726
- * @param [options] options for key-pair generation:
1727
- * workerScript the worker script URL.
1728
- * workers the number of web workers (if supported) to use,
1729
- * (default: 2, -1 to use estimated cores minus one).
1730
- * workLoad the size of the work load, ie: number of possible prime
1731
- * numbers for each web worker to check per work assignment,
1732
- * (default: 100).
1733
- * @param callback(err, keypair) called once the operation completes.
1734
- */
1735
- function _generateKeyPair(state, options, callback) {
1736
- if(typeof options === 'function') {
1737
- callback = options;
1738
- options = {};
1739
- }
1740
- options = options || {};
1741
-
1742
- var opts = {
1743
- algorithm: {
1744
- name: options.algorithm || 'PRIMEINC',
1745
- options: {
1746
- workers: options.workers || 2,
1747
- workLoad: options.workLoad || 100,
1748
- workerScript: options.workerScript
1749
- }
1750
- }
1751
- };
1752
- if('prng' in options) {
1753
- opts.prng = options.prng;
1754
- }
1755
-
1756
- generate();
1757
-
1758
- function generate() {
1759
- // find p and then q (done in series to simplify)
1760
- getPrime(state.pBits, function(err, num) {
1761
- if(err) {
1762
- return callback(err);
1763
- }
1764
- state.p = num;
1765
- if(state.q !== null) {
1766
- return finish(err, state.q);
1767
- }
1768
- getPrime(state.qBits, finish);
1769
- });
1770
- }
1771
-
1772
- function getPrime(bits, callback) {
1773
- forge.prime.generateProbablePrime(bits, opts, callback);
1774
- }
1775
-
1776
- function finish(err, num) {
1777
- if(err) {
1778
- return callback(err);
1779
- }
1780
-
1781
- // set q
1782
- state.q = num;
1783
-
1784
- // ensure p is larger than q (swap them if not)
1785
- if(state.p.compareTo(state.q) < 0) {
1786
- var tmp = state.p;
1787
- state.p = state.q;
1788
- state.q = tmp;
1789
- }
1790
-
1791
- // ensure p is coprime with e
1792
- if(state.p.subtract(BigInteger.ONE).gcd(state.e)
1793
- .compareTo(BigInteger.ONE) !== 0) {
1794
- state.p = null;
1795
- generate();
1796
- return;
1797
- }
1798
-
1799
- // ensure q is coprime with e
1800
- if(state.q.subtract(BigInteger.ONE).gcd(state.e)
1801
- .compareTo(BigInteger.ONE) !== 0) {
1802
- state.q = null;
1803
- getPrime(state.qBits, finish);
1804
- return;
1805
- }
1806
-
1807
- // compute phi: (p - 1)(q - 1) (Euler's totient function)
1808
- state.p1 = state.p.subtract(BigInteger.ONE);
1809
- state.q1 = state.q.subtract(BigInteger.ONE);
1810
- state.phi = state.p1.multiply(state.q1);
1811
-
1812
- // ensure e and phi are coprime
1813
- if(state.phi.gcd(state.e).compareTo(BigInteger.ONE) !== 0) {
1814
- // phi and e aren't coprime, so generate a new p and q
1815
- state.p = state.q = null;
1816
- generate();
1817
- return;
1818
- }
1819
-
1820
- // create n, ensure n is has the right number of bits
1821
- state.n = state.p.multiply(state.q);
1822
- if(state.n.bitLength() !== state.bits) {
1823
- // failed, get new q
1824
- state.q = null;
1825
- getPrime(state.qBits, finish);
1826
- return;
1827
- }
1828
-
1829
- // set keys
1830
- var d = state.e.modInverse(state.phi);
1831
- state.keys = {
1832
- privateKey: pki.rsa.setPrivateKey(
1833
- state.n, state.e, d, state.p, state.q,
1834
- d.mod(state.p1), d.mod(state.q1),
1835
- state.q.modInverse(state.p)),
1836
- publicKey: pki.rsa.setPublicKey(state.n, state.e)
1837
- };
1838
-
1839
- callback(null, state.keys);
1840
- }
1841
- }
1842
-
1843
- /**
1844
- * Converts a positive BigInteger into 2's-complement big-endian bytes.
1845
- *
1846
- * @param b the big integer to convert.
1847
- *
1848
- * @return the bytes.
1849
- */
1850
- function _bnToBytes(b) {
1851
- // prepend 0x00 if first byte >= 0x80
1852
- var hex = b.toString(16);
1853
- if(hex[0] >= '8') {
1854
- hex = '00' + hex;
1855
- }
1856
- var bytes = forge.util.hexToBytes(hex);
1857
-
1858
- // ensure integer is minimally-encoded
1859
- if(bytes.length > 1 &&
1860
- // leading 0x00 for positive integer
1861
- ((bytes.charCodeAt(0) === 0 &&
1862
- (bytes.charCodeAt(1) & 0x80) === 0) ||
1863
- // leading 0xFF for negative integer
1864
- (bytes.charCodeAt(0) === 0xFF &&
1865
- (bytes.charCodeAt(1) & 0x80) === 0x80))) {
1866
- return bytes.substr(1);
1867
- }
1868
- return bytes;
1869
- }
1870
-
1871
- /**
1872
- * Returns the required number of Miller-Rabin tests to generate a
1873
- * prime with an error probability of (1/2)^80.
1874
- *
1875
- * See Handbook of Applied Cryptography Chapter 4, Table 4.4.
1876
- *
1877
- * @param bits the bit size.
1878
- *
1879
- * @return the required number of iterations.
1880
- */
1881
- function _getMillerRabinTests(bits) {
1882
- if(bits <= 100) return 27;
1883
- if(bits <= 150) return 18;
1884
- if(bits <= 200) return 15;
1885
- if(bits <= 250) return 12;
1886
- if(bits <= 300) return 9;
1887
- if(bits <= 350) return 8;
1888
- if(bits <= 400) return 7;
1889
- if(bits <= 500) return 6;
1890
- if(bits <= 600) return 5;
1891
- if(bits <= 800) return 4;
1892
- if(bits <= 1250) return 3;
1893
- return 2;
1894
- }
1895
-
1896
- /**
1897
- * Performs feature detection on the Node crypto interface.
1898
- *
1899
- * @param fn the feature (function) to detect.
1900
- *
1901
- * @return true if detected, false if not.
1902
- */
1903
- function _detectNodeCrypto(fn) {
1904
- return forge.util.isNodejs && typeof _crypto[fn] === 'function';
1905
- }
1906
-
1907
- /**
1908
- * Performs feature detection on the SubtleCrypto interface.
1909
- *
1910
- * @param fn the feature (function) to detect.
1911
- *
1912
- * @return true if detected, false if not.
1913
- */
1914
- function _detectSubtleCrypto(fn) {
1915
- return (typeof util.globalScope !== 'undefined' &&
1916
- typeof util.globalScope.crypto === 'object' &&
1917
- typeof util.globalScope.crypto.subtle === 'object' &&
1918
- typeof util.globalScope.crypto.subtle[fn] === 'function');
1919
- }
1920
-
1921
- /**
1922
- * Performs feature detection on the deprecated Microsoft Internet Explorer
1923
- * outdated SubtleCrypto interface. This function should only be used after
1924
- * checking for the modern, standard SubtleCrypto interface.
1925
- *
1926
- * @param fn the feature (function) to detect.
1927
- *
1928
- * @return true if detected, false if not.
1929
- */
1930
- function _detectSubtleMsCrypto(fn) {
1931
- return (typeof util.globalScope !== 'undefined' &&
1932
- typeof util.globalScope.msCrypto === 'object' &&
1933
- typeof util.globalScope.msCrypto.subtle === 'object' &&
1934
- typeof util.globalScope.msCrypto.subtle[fn] === 'function');
1935
- }
1936
-
1937
- function _intToUint8Array(x) {
1938
- var bytes = forge.util.hexToBytes(x.toString(16));
1939
- var buffer = new Uint8Array(bytes.length);
1940
- for(var i = 0; i < bytes.length; ++i) {
1941
- buffer[i] = bytes.charCodeAt(i);
1942
- }
1943
- return buffer;
1944
- }
1945
-
1946
- function _privateKeyFromJwk(jwk) {
1947
- if(jwk.kty !== 'RSA') {
1948
- throw new Error(
1949
- 'Unsupported key algorithm "' + jwk.kty + '"; algorithm must be "RSA".');
1950
- }
1951
- return pki.setRsaPrivateKey(
1952
- _base64ToBigInt(jwk.n),
1953
- _base64ToBigInt(jwk.e),
1954
- _base64ToBigInt(jwk.d),
1955
- _base64ToBigInt(jwk.p),
1956
- _base64ToBigInt(jwk.q),
1957
- _base64ToBigInt(jwk.dp),
1958
- _base64ToBigInt(jwk.dq),
1959
- _base64ToBigInt(jwk.qi));
1960
- }
1961
-
1962
- function _publicKeyFromJwk(jwk) {
1963
- if(jwk.kty !== 'RSA') {
1964
- throw new Error('Key algorithm must be "RSA".');
1965
- }
1966
- return pki.setRsaPublicKey(
1967
- _base64ToBigInt(jwk.n),
1968
- _base64ToBigInt(jwk.e));
1969
- }
1970
-
1971
- function _base64ToBigInt(b64) {
1972
- return new BigInteger(forge.util.bytesToHex(forge.util.decode64(b64)), 16);
1973
- }