@preventive/triage 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (312) hide show
  1. package/LICENSE-APACHE +202 -0
  2. package/README.md +16 -0
  3. package/api/reap.ts +17 -0
  4. package/cli.js +6 -0
  5. package/client/dependency-paths.d.ts +2 -0
  6. package/client/dependency-paths.js +24 -0
  7. package/client/finding-link.js +305 -0
  8. package/client/linked-findings.d.ts +1 -0
  9. package/client/linked-findings.js +112 -0
  10. package/common/bundle-commit.d.ts +1 -0
  11. package/common/bundle-commit.js +4 -0
  12. package/common/bundle-compare-diff.d.ts +3 -0
  13. package/common/bundle-compare-diff.js +522 -0
  14. package/common/bundle-compare-inputs.d.ts +2 -0
  15. package/common/bundle-compare-inputs.js +65 -0
  16. package/common/bundle-metadata.d.ts +14 -0
  17. package/common/bundle-metadata.js +226 -0
  18. package/common/bundle-pkg-of.d.ts +1 -0
  19. package/common/bundle-pkg-of.js +90 -0
  20. package/common/bundle-reasons.d.ts +2 -0
  21. package/common/bundle-reasons.js +21 -0
  22. package/common/bundle-source-links.d.ts +6 -0
  23. package/common/bundle-source-links.js +216 -0
  24. package/common/bundle-sourcemap.d.ts +10 -0
  25. package/common/bundle-sourcemap.js +100 -0
  26. package/common/bundle-sources.d.ts +7 -0
  27. package/common/bundle-sources.js +310 -0
  28. package/common/bundle-stats.js +41 -0
  29. package/common/bundle-tabs.js +1 -0
  30. package/common/code-language.js +65 -0
  31. package/common/default-scan-models.ts +31 -0
  32. package/common/dependency-reviews.d.ts +23 -0
  33. package/common/dependency-reviews.js +81 -0
  34. package/common/finding-duplicates.js +58 -0
  35. package/common/finding-filters.js +274 -0
  36. package/common/finding-id.js +47 -0
  37. package/common/github-issue-labels.d.ts +1 -0
  38. package/common/github-issue-labels.js +11 -0
  39. package/common/github-pr.ts +56 -0
  40. package/common/gzip.js +59 -0
  41. package/common/line-diff.d.ts +8 -0
  42. package/common/line-diff.js +56 -0
  43. package/common/linked-workspace-groups.js +63 -0
  44. package/common/managed/comments.ts +34 -0
  45. package/common/managed/npm-packages.d.ts +5 -0
  46. package/common/managed/npm-packages.js +34 -0
  47. package/common/managed/permissions.ts +31 -0
  48. package/common/managed/report-content.ts +72 -0
  49. package/common/managed/report-filter.ts +108 -0
  50. package/common/managed/repository-alias.ts +65 -0
  51. package/common/managed/roles.ts +28 -0
  52. package/common/managed/routes.d.ts +2 -0
  53. package/common/managed/routes.js +254 -0
  54. package/common/managed/scan-models.ts +6 -0
  55. package/common/managed/team-app.d.ts +2 -0
  56. package/common/managed/team-app.js +31 -0
  57. package/common/managed/triage.ts +83 -0
  58. package/common/managed/upload-seal.ts +126 -0
  59. package/common/pretty-print.d.ts +5 -0
  60. package/common/pretty-print.js +24 -0
  61. package/common/revalidation-conflicts.js +48 -0
  62. package/common/revalidation-input-groups.js +56 -0
  63. package/common/save-error-reason.ts +20 -7
  64. package/common/scan-server.ts +13 -0
  65. package/common/server-info.ts +35 -0
  66. package/common/utf8.d.ts +3 -0
  67. package/common/utf8.js +45 -0
  68. package/common/workspace-app.js +23 -0
  69. package/common/workspace-groups.js +176 -0
  70. package/out/brotli-fallback.js +3 -3
  71. package/out/chunk-2AFQKRAM.js +51 -0
  72. package/out/chunk-2KBF5TZ7.js +2 -0
  73. package/out/chunk-2XUEZHIP.js +28 -0
  74. package/out/chunk-35VE6CDH.js +2 -0
  75. package/out/chunk-3BZ7JERB.js +1 -0
  76. package/out/chunk-4F6JSF57.js +3 -0
  77. package/out/chunk-4XCDFGDP.js +10 -0
  78. package/out/chunk-C4Z6ZBXV.js +10 -0
  79. package/out/chunk-CMQA4DM6.js +1 -0
  80. package/out/chunk-CVVJAXVY.js +2 -0
  81. package/out/chunk-DIJJNTRH.js +10 -0
  82. package/out/chunk-GJ4IUCNS.js +1 -0
  83. package/out/chunk-GNXOKIGP.js +80 -0
  84. package/out/chunk-GZ4MS3TE.js +13 -0
  85. package/out/chunk-IU3CCINR.js +3 -0
  86. package/out/chunk-K3X5EJBQ.js +2 -0
  87. package/out/chunk-KEX2ATEW.js +2 -0
  88. package/out/chunk-KVEUXIEU.js +1 -0
  89. package/out/chunk-KYCNJVB7.js +1 -0
  90. package/out/chunk-NRPC74AM.js +1 -0
  91. package/out/chunk-OOJM4CTU.js +1 -0
  92. package/out/chunk-PNHBZGDD.js +1 -0
  93. package/out/chunk-QZ3A376W.js +1 -0
  94. package/out/chunk-R5O6FAW4.js +2 -0
  95. package/out/chunk-RFZQQXSG.js +17 -0
  96. package/out/chunk-RSHMVYNS.js +1 -0
  97. package/out/chunk-TUII34K2.js +1 -0
  98. package/out/chunk-TY4RZD3Z.js +226 -0
  99. package/out/chunk-TZ5KB2Y5.js +10 -0
  100. package/out/chunk-U6OPEXIA.js +1 -0
  101. package/out/chunk-UNTRGE26.js +2 -0
  102. package/out/chunk-UXNUAIIC.js +33 -0
  103. package/out/chunk-UYAXVRVL.js +1 -0
  104. package/out/chunk-UZAZM2SX.js +2 -0
  105. package/out/chunk-V3ME6FI5.js +2 -0
  106. package/out/chunk-V5O7M2YT.js +1 -0
  107. package/out/chunk-VIHGO77Y.js +1 -0
  108. package/out/chunk-VQJCXGIY.js +7 -0
  109. package/out/chunk-W4J3MGLB.js +1 -0
  110. package/out/chunk-WGG7KQUH.js +1 -0
  111. package/out/chunk-WZDTZE64.js +1 -0
  112. package/out/chunk-XL35ZV6R.js +1 -0
  113. package/out/chunk-XYFXXB2G.js +10 -0
  114. package/out/chunk-YVZH5SHP.js +1 -0
  115. package/out/chunk-ZBBOBQ43.js +1 -0
  116. package/out/chunk-ZMQQCGF6.js +2 -0
  117. package/out/client-managed-import.js +4 -0
  118. package/out/client-managed.js +37 -0
  119. package/out/client-sync.js +10 -13
  120. package/out/github-issue-authorized.html +3 -0
  121. package/out/github-issue-authorized.js +1 -0
  122. package/out/graph.js +17 -4
  123. package/out/index.html +90 -8
  124. package/out/prism.js +6 -2
  125. package/out/stasis.svg +20 -0
  126. package/out/terminal.js +365 -39
  127. package/out/view.css +1 -1
  128. package/out/view.js +83 -117
  129. package/package.json +298 -59
  130. package/risk/files/characters.js +196 -0
  131. package/risk/files/hosts.js +205 -0
  132. package/risk/files/readability.js +171 -0
  133. package/risk/files/runs-code.js +595 -0
  134. package/risk/files/script.js +114 -0
  135. package/risk/files/stamps.js +46 -0
  136. package/risk/index.d.ts +156 -0
  137. package/risk/index.js +7 -0
  138. package/risk/npm/assess.js +223 -0
  139. package/risk/npm/combined.js +65 -0
  140. package/risk/npm/compare.js +228 -0
  141. package/risk/npm/dependencies.js +153 -0
  142. package/risk/npm/diff.js +43 -0
  143. package/risk/npm/downloads.js +84 -0
  144. package/risk/npm/files.js +34 -0
  145. package/risk/npm/held.js +60 -0
  146. package/risk/npm/install-scripts.js +34 -0
  147. package/risk/npm/malware.js +36 -0
  148. package/risk/npm/manifest.js +65 -0
  149. package/risk/npm/new-dependency.js +30 -0
  150. package/risk/npm/old-version.js +108 -0
  151. package/risk/npm/registry.js +282 -0
  152. package/risk/npm/release.js +85 -0
  153. package/risk/npm/score.js +59 -0
  154. package/risk/npm/specs.js +124 -0
  155. package/risk/npm/tarball.js +113 -0
  156. package/server-common/database-config.ts +16 -0
  157. package/server-common/initialize.ts +18 -0
  158. package/server-common/npm-advisories.ts +101 -0
  159. package/{server → server-common}/origin.ts +5 -5
  160. package/server-common/reap.ts +48 -0
  161. package/server-common/scan-config.ts +19 -0
  162. package/server-common/standalone.ts +29 -0
  163. package/server-common/storage-crypto.ts +182 -0
  164. package/server-common/storage-log.ts +38 -0
  165. package/server-common/vercel-blob.ts +103 -0
  166. package/server-e2e/app.ts +486 -0
  167. package/{server → server-e2e}/auth.ts +5 -1
  168. package/{server → server-e2e}/bus-receiver.ts +2 -1
  169. package/{server → server-e2e}/cli.js +9 -4
  170. package/{server → server-e2e}/config.ts +56 -35
  171. package/{server → server-e2e}/db-neon.ts +2 -2
  172. package/{server → server-e2e}/db-revision-sql.ts +1 -1
  173. package/{server → server-e2e}/db-stmt.ts +2 -2
  174. package/{server → server-e2e}/db.ts +7 -7
  175. package/{server → server-e2e}/http.ts +116 -18
  176. package/{server → server-e2e}/hub.ts +40 -9
  177. package/server-e2e/index.ts +17 -0
  178. package/server-e2e/lifecycle.ts +95 -0
  179. package/{server → server-e2e}/neon-driver.ts +2 -2
  180. package/{server → server-e2e}/npm-proxy.ts +12 -145
  181. package/{server → server-e2e}/objstore/blob-vercel.ts +10 -114
  182. package/{server → server-e2e}/objstore/blob.ts +1 -1
  183. package/server-e2e/objstore/fetch-mint-guard.ts +74 -0
  184. package/{server → server-e2e}/objstore/handlers.ts +9 -8
  185. package/{server → server-e2e}/objstore/init.ts +35 -18
  186. package/{server → server-e2e}/objstore/reaper.ts +1 -1
  187. package/server-e2e/objstore/rest-deny.ts +28 -0
  188. package/server-e2e/objstore/rest-mint.ts +224 -0
  189. package/{server → server-e2e}/objstore/rest.ts +27 -26
  190. package/{server → server-e2e}/objstore/sign.ts +105 -0
  191. package/{server → server-e2e}/objstore/store-neon.ts +6 -10
  192. package/{server → server-e2e}/objstore/store.ts +7 -7
  193. package/{server → server-e2e}/objstore/tokens.ts +2 -2
  194. package/{server → server-e2e}/pubsub.ts +12 -9
  195. package/{server → server-e2e}/sign.ts +4 -4
  196. package/{server → server-e2e}/sse-server.ts +102 -68
  197. package/{server → server-e2e}/sse-session.ts +28 -8
  198. package/{server → server-e2e}/static.ts +31 -21
  199. package/server-e2e/sync-handlers.ts +408 -0
  200. package/{server → server-e2e}/ws-server.ts +20 -9
  201. package/server-managed/activity.ts +245 -0
  202. package/server-managed/avatar-store.ts +12 -0
  203. package/server-managed/blob-store.ts +17 -0
  204. package/server-managed/brotli.ts +10 -0
  205. package/server-managed/bundle-advisories.ts +120 -0
  206. package/server-managed/bundle-advisory-inventory.ts +77 -0
  207. package/server-managed/bundle-build-diagnostics.d.ts +10 -0
  208. package/server-managed/bundle-build-diagnostics.js +23 -0
  209. package/server-managed/bundle-build-leases.ts +41 -0
  210. package/server-managed/bundle-build-worker.js +111 -0
  211. package/server-managed/bundle-build.ts +198 -0
  212. package/server-managed/bundle-cache.ts +199 -0
  213. package/server-managed/bundle-catalog.ts +29 -0
  214. package/server-managed/bundle-commits.ts +140 -0
  215. package/server-managed/bundle-store.ts +24 -0
  216. package/server-managed/bundle-summary-cache.ts +130 -0
  217. package/server-managed/bundle.ts +120 -0
  218. package/server-managed/cache-storage.ts +19 -0
  219. package/server-managed/cli.js +21 -0
  220. package/server-managed/combined.ts +46 -0
  221. package/server-managed/comments.ts +151 -0
  222. package/server-managed/config.ts +158 -0
  223. package/server-managed/content-access.ts +15 -0
  224. package/server-managed/crypto.ts +25 -0
  225. package/server-managed/db-methods.ts +1725 -0
  226. package/server-managed/db-neon.ts +367 -0
  227. package/server-managed/db-schema.ts +227 -0
  228. package/server-managed/db-table-names.ts +22 -0
  229. package/server-managed/db.ts +132 -0
  230. package/server-managed/dependency-reviews.ts +248 -0
  231. package/server-managed/github-app.ts +391 -0
  232. package/server-managed/github-errors.ts +68 -0
  233. package/server-managed/github-issue-links.ts +127 -0
  234. package/server-managed/github-issue-oauth.ts +47 -0
  235. package/server-managed/github-issues.ts +152 -0
  236. package/server-managed/github-metadata.ts +213 -0
  237. package/server-managed/github-oauth.ts +235 -0
  238. package/server-managed/github-pulls.ts +227 -0
  239. package/server-managed/http-response.ts +50 -0
  240. package/server-managed/http.ts +3472 -0
  241. package/server-managed/import-triage.ts +51 -0
  242. package/server-managed/index.ts +187 -0
  243. package/server-managed/kept.ts +28 -0
  244. package/server-managed/link-reports.ts +158 -0
  245. package/server-managed/locked-packages.ts +85 -0
  246. package/server-managed/lru.ts +30 -0
  247. package/server-managed/managed-issues.ts +75 -0
  248. package/server-managed/management-catalog.ts +45 -0
  249. package/server-managed/management.ts +99 -0
  250. package/server-managed/npm-insights.ts +440 -0
  251. package/server-managed/npm-kept.ts +65 -0
  252. package/server-managed/npm-loads.ts +167 -0
  253. package/server-managed/npm-manifest.ts +115 -0
  254. package/server-managed/npm-packages.ts +378 -0
  255. package/server-managed/npm-provenance.ts +123 -0
  256. package/server-managed/npm-risk.ts +177 -0
  257. package/server-managed/object-storage-disk.ts +148 -0
  258. package/server-managed/object-storage-vercel.ts +67 -0
  259. package/server-managed/object-storage.ts +74 -0
  260. package/server-managed/package-entry-points.ts +51 -0
  261. package/server-managed/pretty-print.ts +352 -0
  262. package/server-managed/public-workspace.ts +220 -0
  263. package/server-managed/rename-diff-worker.js +26 -0
  264. package/server-managed/rename-diff.ts +270 -0
  265. package/server-managed/repo-path.ts +21 -0
  266. package/server-managed/report-migration.ts +35 -0
  267. package/server-managed/report-query.ts +10 -0
  268. package/server-managed/report-response.ts +16 -0
  269. package/server-managed/report-sources.ts +178 -0
  270. package/server-managed/report-store.ts +47 -0
  271. package/server-managed/repository-aliases.ts +91 -0
  272. package/server-managed/repository-browser.ts +153 -0
  273. package/server-managed/repository-discovery.ts +82 -0
  274. package/server-managed/repository-policy.ts +27 -0
  275. package/server-managed/repository-risk.ts +420 -0
  276. package/server-managed/revisions.ts +35 -0
  277. package/server-managed/session.ts +92 -0
  278. package/server-managed/slugs.ts +38 -0
  279. package/server-managed/solidity-entry-points.ts +69 -0
  280. package/server-managed/sql-postgres.ts +31 -0
  281. package/server-managed/sql.ts +76 -0
  282. package/server-managed/static.ts +28 -0
  283. package/server-managed/storage-command.ts +16 -0
  284. package/server-managed/storage-db.ts +175 -0
  285. package/server-managed/storage-encryption.ts +279 -0
  286. package/server-managed/storage-maintenance.ts +256 -0
  287. package/server-managed/storage-payload.ts +103 -0
  288. package/server-managed/storage-stores.ts +85 -0
  289. package/server-managed/storage.ts +78 -0
  290. package/server-managed/team-app.ts +94 -0
  291. package/server-managed/team-catalog.ts +7 -0
  292. package/server-managed/team-feed.ts +173 -0
  293. package/server-managed/team-npm-scopes.ts +77 -0
  294. package/server-managed/team-reports.ts +228 -0
  295. package/server-managed/triage-response.ts +16 -0
  296. package/server-managed/type-only-worker.js +19 -0
  297. package/server-managed/type-only.ts +103 -0
  298. package/server-managed/uploads.ts +86 -0
  299. package/server-managed/upstream-cache.ts +215 -0
  300. package/server-managed/view-as.ts +58 -0
  301. package/server-managed/workspace-shares.ts +166 -0
  302. package/server.ts +50 -0
  303. package/server/index.ts +0 -477
  304. package/server/lifecycle.ts +0 -204
  305. package/server/sync-handlers.ts +0 -320
  306. /package/{LICENSE → LICENSE-MIT} +0 -0
  307. /package/{server → server-e2e}/config.example.json +0 -0
  308. /package/{server → server-e2e}/objstore/blob-fs.ts +0 -0
  309. /package/{server → server-e2e}/objstore/fs.ts +0 -0
  310. /package/{server → server-e2e}/peer.ts +0 -0
  311. /package/{server → server-e2e}/util.ts +0 -0
  312. /package/{server → server-e2e}/validation.ts +0 -0
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@preventive/triage",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.41",
4
4
  "description": "Client & relay server for triaging of automated reports",
5
- "license": "MIT",
5
+ "license": "MIT OR Apache-2.0",
6
6
  "author": {
7
7
  "name": "Nikita Skovoroda",
8
8
  "email": "chalkerx@gmail.com",
@@ -29,63 +29,281 @@
29
29
  "#client/sync-host.js": "./client/sync-host.js"
30
30
  },
31
31
  "exports": {
32
- "./server": "./server/index.ts",
32
+ "./reap": "./api/reap.ts",
33
+ "./server": "./server.ts",
34
+ "./server-e2e": "./server-e2e/index.ts",
35
+ "./bundle-build-worker": "./server-managed/bundle-build-worker.js",
33
36
  "./strip-types-loader": "./strip-types-loader.js",
34
37
  "./package.json": "./package.json"
35
38
  },
36
39
  "bin": {
37
- "triage-server": "server/cli.js"
40
+ "triage-server": "cli.js",
41
+ "triage-e2e-server": "server-e2e/cli.js",
42
+ "triage-managed-server": "server-managed/cli.js"
38
43
  },
39
44
  "files": [
40
- "server/auth.ts",
41
- "server/bus-receiver.ts",
42
- "server/cli.js",
43
- "server/config.ts",
44
- "server/db-neon.ts",
45
- "server/db-revision-sql.ts",
46
- "server/db-stmt.ts",
47
- "server/db.ts",
48
- "server/http.ts",
49
- "server/hub.ts",
50
- "server/index.ts",
51
- "server/lifecycle.ts",
52
- "server/neon-driver.ts",
53
- "server/npm-proxy.ts",
54
- "server/objstore/blob-fs.ts",
55
- "server/objstore/blob-vercel.ts",
56
- "server/objstore/blob.ts",
57
- "server/objstore/fs.ts",
58
- "server/objstore/handlers.ts",
59
- "server/objstore/init.ts",
60
- "server/objstore/reaper.ts",
61
- "server/objstore/rest.ts",
62
- "server/objstore/sign.ts",
63
- "server/objstore/store-neon.ts",
64
- "server/objstore/store.ts",
65
- "server/objstore/tokens.ts",
66
- "server/origin.ts",
67
- "server/peer.ts",
68
- "server/pubsub.ts",
69
- "server/sign.ts",
70
- "server/sse-server.ts",
71
- "server/sse-session.ts",
72
- "server/static.ts",
73
- "server/sync-handlers.ts",
74
- "server/util.ts",
75
- "server/validation.ts",
76
- "server/ws-server.ts",
77
- "server/config.example.json",
45
+ "LICENSE-APACHE",
46
+ "LICENSE-MIT",
47
+ "api/reap.ts",
48
+ "cli.js",
49
+ "server.ts",
50
+ "server-e2e/app.ts",
51
+ "server-e2e/auth.ts",
52
+ "server-e2e/bus-receiver.ts",
53
+ "server-e2e/cli.js",
54
+ "server-e2e/config.ts",
55
+ "server-e2e/db-neon.ts",
56
+ "server-e2e/db-revision-sql.ts",
57
+ "server-e2e/db-stmt.ts",
58
+ "server-e2e/db.ts",
59
+ "server-e2e/http.ts",
60
+ "server-e2e/hub.ts",
61
+ "server-e2e/index.ts",
62
+ "server-e2e/lifecycle.ts",
63
+ "server-e2e/neon-driver.ts",
64
+ "server-e2e/npm-proxy.ts",
65
+ "server-e2e/objstore/blob-fs.ts",
66
+ "server-e2e/objstore/blob-vercel.ts",
67
+ "server-e2e/objstore/blob.ts",
68
+ "server-e2e/objstore/fetch-mint-guard.ts",
69
+ "server-e2e/objstore/fs.ts",
70
+ "server-e2e/objstore/handlers.ts",
71
+ "server-e2e/objstore/init.ts",
72
+ "server-e2e/objstore/reaper.ts",
73
+ "server-e2e/objstore/rest-deny.ts",
74
+ "server-e2e/objstore/rest-mint.ts",
75
+ "server-e2e/objstore/rest.ts",
76
+ "server-e2e/objstore/sign.ts",
77
+ "server-e2e/objstore/store-neon.ts",
78
+ "server-e2e/objstore/store.ts",
79
+ "server-e2e/objstore/tokens.ts",
80
+ "server-e2e/peer.ts",
81
+ "server-e2e/pubsub.ts",
82
+ "server-e2e/sign.ts",
83
+ "server-e2e/sse-server.ts",
84
+ "server-e2e/sse-session.ts",
85
+ "server-e2e/static.ts",
86
+ "server-e2e/sync-handlers.ts",
87
+ "server-e2e/util.ts",
88
+ "server-e2e/validation.ts",
89
+ "server-e2e/ws-server.ts",
90
+ "server-e2e/config.example.json",
91
+ "server-managed/activity.ts",
92
+ "server-managed/avatar-store.ts",
93
+ "server-managed/blob-store.ts",
94
+ "server-managed/brotli.ts",
95
+ "server-managed/bundle-advisories.ts",
96
+ "server-managed/bundle-advisory-inventory.ts",
97
+ "server-managed/bundle-cache.ts",
98
+ "server-managed/bundle-build.ts",
99
+ "server-managed/bundle-build-leases.ts",
100
+ "server-managed/bundle-build-worker.js",
101
+ "server-managed/bundle-build-diagnostics.js",
102
+ "server-managed/bundle-build-diagnostics.d.ts",
103
+ "server-managed/bundle-catalog.ts",
104
+ "server-managed/bundle-commits.ts",
105
+ "server-managed/bundle-store.ts",
106
+ "server-managed/bundle-summary-cache.ts",
107
+ "server-managed/bundle.ts",
108
+ "server-managed/cache-storage.ts",
109
+ "server-managed/cli.js",
110
+ "server-managed/combined.ts",
111
+ "server-managed/comments.ts",
112
+ "server-managed/config.ts",
113
+ "server-managed/content-access.ts",
114
+ "server-managed/crypto.ts",
115
+ "server-managed/db-methods.ts",
116
+ "server-managed/db-neon.ts",
117
+ "server-managed/db-schema.ts",
118
+ "server-managed/db-table-names.ts",
119
+ "server-managed/db.ts",
120
+ "server-managed/dependency-reviews.ts",
121
+ "server-managed/github-app.ts",
122
+ "server-managed/github-errors.ts",
123
+ "server-managed/github-metadata.ts",
124
+ "server-managed/github-issue-oauth.ts",
125
+ "server-managed/github-issues.ts",
126
+ "server-managed/github-issue-links.ts",
127
+ "server-managed/github-oauth.ts",
128
+ "server-managed/github-pulls.ts",
129
+ "server-managed/http-response.ts",
130
+ "server-managed/http.ts",
131
+ "server-managed/link-reports.ts",
132
+ "server-managed/locked-packages.ts",
133
+ "server-managed/lru.ts",
134
+ "server-managed/import-triage.ts",
135
+ "server-managed/managed-issues.ts",
136
+ "server-managed/management.ts",
137
+ "server-managed/management-catalog.ts",
138
+ "server-managed/object-storage.ts",
139
+ "server-managed/object-storage-disk.ts",
140
+ "server-managed/object-storage-vercel.ts",
141
+ "server-managed/index.ts",
142
+ "server-managed/npm-insights.ts",
143
+ "server-managed/npm-risk.ts",
144
+ "server-managed/npm-provenance.ts",
145
+ "server-managed/kept.ts",
146
+ "server-managed/npm-kept.ts",
147
+ "server-managed/npm-loads.ts",
148
+ "server-managed/npm-manifest.ts",
149
+ "server-managed/npm-packages.ts",
150
+ "server-managed/package-entry-points.ts",
151
+ "server-managed/pretty-print.ts",
152
+ "server-managed/rename-diff.ts",
153
+ "server-managed/rename-diff-worker.js",
154
+ "server-managed/public-workspace.ts",
155
+ "server-managed/repo-path.ts",
156
+ "server-managed/report-migration.ts",
157
+ "server-managed/report-query.ts",
158
+ "server-managed/report-response.ts",
159
+ "server-managed/report-store.ts",
160
+ "server-managed/report-sources.ts",
161
+ "server-managed/revisions.ts",
162
+ "server-managed/repository-browser.ts",
163
+ "server-managed/repository-aliases.ts",
164
+ "server-managed/repository-discovery.ts",
165
+ "server-managed/repository-policy.ts",
166
+ "server-managed/repository-risk.ts",
167
+ "server-managed/session.ts",
168
+ "server-managed/slugs.ts",
169
+ "server-managed/solidity-entry-points.ts",
170
+ "server-managed/sql-postgres.ts",
171
+ "server-managed/sql.ts",
172
+ "server-managed/static.ts",
173
+ "server-managed/storage.ts",
174
+ "server-managed/storage-command.ts",
175
+ "server-managed/storage-db.ts",
176
+ "server-managed/storage-encryption.ts",
177
+ "server-managed/storage-maintenance.ts",
178
+ "server-managed/storage-payload.ts",
179
+ "server-managed/storage-stores.ts",
180
+ "server-managed/team-catalog.ts",
181
+ "server-managed/team-feed.ts",
182
+ "server-managed/team-npm-scopes.ts",
183
+ "server-managed/team-app.ts",
184
+ "server-managed/team-reports.ts",
185
+ "server-managed/triage-response.ts",
186
+ "server-managed/type-only.ts",
187
+ "server-managed/type-only-worker.js",
188
+ "server-managed/uploads.ts",
189
+ "server-managed/view-as.ts",
190
+ "server-managed/upstream-cache.ts",
191
+ "server-managed/workspace-shares.ts",
192
+ "server-common/database-config.ts",
193
+ "server-common/initialize.ts",
194
+ "server-common/reap.ts",
195
+ "server-common/npm-advisories.ts",
196
+ "server-common/origin.ts",
197
+ "server-common/standalone.ts",
198
+ "server-common/storage-log.ts",
199
+ "server-common/storage-crypto.ts",
200
+ "server-common/vercel-blob.ts",
201
+ "server-common/scan-config.ts",
202
+ "common/bundle-commit.d.ts",
203
+ "common/bundle-commit.js",
204
+ "common/bundle-compare-diff.js",
205
+ "common/bundle-compare-diff.d.ts",
206
+ "common/bundle-compare-inputs.d.ts",
207
+ "common/bundle-compare-inputs.js",
208
+ "common/bundle-metadata.d.ts",
209
+ "common/bundle-pkg-of.d.ts",
210
+ "common/bundle-pkg-of.js",
211
+ "common/bundle-metadata.js",
212
+ "common/bundle-reasons.d.ts",
213
+ "common/bundle-reasons.js",
214
+ "common/bundle-sources.d.ts",
215
+ "common/bundle-sources.js",
216
+ "common/bundle-source-links.d.ts",
217
+ "common/bundle-source-links.js",
218
+ "common/bundle-sourcemap.d.ts",
219
+ "common/bundle-sourcemap.js",
220
+ "common/bundle-stats.js",
221
+ "common/bundle-tabs.js",
222
+ "common/code-language.js",
223
+ "common/default-scan-models.ts",
224
+ "common/dependency-reviews.js",
225
+ "common/dependency-reviews.d.ts",
226
+ "common/finding-id.js",
227
+ "common/finding-duplicates.js",
228
+ "common/finding-filters.js",
229
+ "common/github-pr.ts",
230
+ "common/github-issue-labels.js",
231
+ "common/github-issue-labels.d.ts",
232
+ "common/gzip.js",
233
+ "common/pretty-print.d.ts",
234
+ "common/pretty-print.js",
235
+ "common/line-diff.d.ts",
236
+ "common/line-diff.js",
237
+ "common/linked-workspace-groups.js",
238
+ "common/managed/comments.ts",
239
+ "common/managed/npm-packages.d.ts",
240
+ "common/managed/npm-packages.js",
241
+ "common/managed/permissions.ts",
242
+ "common/managed/report-content.ts",
243
+ "common/managed/repository-alias.ts",
244
+ "common/managed/report-filter.ts",
245
+ "common/managed/roles.ts",
246
+ "common/managed/routes.d.ts",
247
+ "common/managed/routes.js",
248
+ "common/managed/scan-models.ts",
249
+ "common/managed/team-app.js",
250
+ "common/managed/team-app.d.ts",
251
+ "common/managed/triage.ts",
252
+ "common/managed/upload-seal.ts",
78
253
  "common/save-error-reason.ts",
254
+ "common/revalidation-conflicts.js",
255
+ "common/revalidation-input-groups.js",
256
+ "common/server-info.ts",
257
+ "common/scan-server.ts",
79
258
  "common/utf8.d.ts",
80
259
  "common/utf8.js",
260
+ "common/workspace-app.js",
261
+ "common/workspace-groups.js",
262
+ "risk/index.js",
263
+ "risk/index.d.ts",
264
+ "risk/files/characters.js",
265
+ "risk/files/hosts.js",
266
+ "risk/files/readability.js",
267
+ "risk/files/runs-code.js",
268
+ "risk/files/script.js",
269
+ "risk/files/stamps.js",
270
+ "risk/npm/assess.js",
271
+ "risk/npm/combined.js",
272
+ "risk/npm/compare.js",
273
+ "risk/npm/dependencies.js",
274
+ "risk/npm/diff.js",
275
+ "risk/npm/held.js",
276
+ "risk/npm/files.js",
277
+ "risk/npm/downloads.js",
278
+ "risk/npm/install-scripts.js",
279
+ "risk/npm/malware.js",
280
+ "risk/npm/manifest.js",
281
+ "risk/npm/new-dependency.js",
282
+ "risk/npm/old-version.js",
283
+ "risk/npm/registry.js",
284
+ "risk/npm/release.js",
285
+ "risk/npm/score.js",
286
+ "risk/npm/specs.js",
287
+ "risk/npm/tarball.js",
288
+ "client/dependency-paths.d.ts",
289
+ "client/dependency-paths.js",
290
+ "client/finding-link.js",
291
+ "client/linked-findings.d.ts",
292
+ "client/linked-findings.js",
81
293
  "out/brotli-fallback.js",
294
+ "out/chunk-*.js",
295
+ "out/client-managed.js",
296
+ "out/client-managed-import.js",
82
297
  "out/client-sync.js",
83
298
  "out/graph.js",
299
+ "out/github-issue-authorized.html",
300
+ "out/github-issue-authorized.js",
84
301
  "out/icon-maskable.svg",
85
302
  "out/icon.svg",
86
303
  "out/index.html",
87
304
  "out/manifest.webmanifest",
88
305
  "out/prism.js",
306
+ "out/stasis.svg",
89
307
  "out/terminal.js",
90
308
  "out/view.css",
91
309
  "out/view.html",
@@ -94,40 +312,58 @@
94
312
  ],
95
313
  "scripts": {
96
314
  "lint": "node --run lint:js && node --run lint:css && node --run lint:ts",
97
- "lint:js": "oxlint -c .oxlintrc.json --ignore-pattern=ui/logs.js ./tests/ ./common/ ./server/ ./client/ ./ui/",
315
+ "lint:js": "oxlint -c .oxlintrc.json --ignore-pattern=ui/logs.js ./cli.js ./server.ts ./tests/ ./common/ ./server-common/ ./server-e2e/ ./server-managed/ ./client/ ./ui/ ./risk/ ./api/",
98
316
  "lint:css": "stylelint 'ui/**/*.css'",
99
317
  "lint:ts": "tsc --noEmit",
100
318
  "prepack": "node --run build",
101
319
  "build": "node build.js build",
102
320
  "serve": "node build.js serve",
103
- "server": "node server/index.ts",
104
- "test": "node --js-base-64 --experimental-test-module-mocks --test ./tests/*.test.js"
321
+ "server": "node --run server-e2e --",
322
+ "server-e2e": "node server-e2e/index.ts",
323
+ "server-managed": "node server-managed/index.ts",
324
+ "server-managed-test": "node server-managed/test-server.ts",
325
+ "test": "node --js-base-64 --require=./tests/_resource-loader.js --experimental-test-module-mocks --test-timeout=120000 --test-concurrency=$(node -p 'Math.ceil(os.availableParallelism() * 1.5)') --test ./tests/*.test.js"
105
326
  },
106
327
  "devDependencies": {
107
- "@electric-sql/pglite": "^0.4.5",
108
- "@exodus/stasis": "^1.0.0-alpha.1",
109
- "@noble/ciphers": "^2.2.0",
110
- "@preventive/terminal": "^1.3.0",
328
+ "@electric-sql/pglite": "^0.5.8",
329
+ "@noble/ciphers": "^2.4.0",
330
+ "@preventive/terminal": "2.0.0-beta.3",
111
331
  "@rray/frontend": "^1.0.0",
112
- "@stylistic/stylelint-plugin": "^5.1.0",
113
- "@types/node": "^25.6.2",
114
- "@types/ws": "^8.18.1",
332
+ "@stylistic/stylelint-plugin": "^5.3.1",
333
+ "@types/node": "^26.6.4",
334
+ "@types/ws": "^8.18.2",
335
+ "@vercel/functions": "^3.9.11",
115
336
  "brotli": "^1.3.3",
116
- "esbuild": "^0.27.4",
117
- "lit": "^3.3.2",
337
+ "esbuild": "^0.28.2",
338
+ "lit": "^3.3.3",
118
339
  "minify-html-literals": "^1.3.5",
119
- "oxlint": "^1.63.0",
340
+ "oxlint": "^1.87.0",
120
341
  "prismjs": "^1.30.0",
121
- "stylelint": "^17.11.0",
342
+ "stylelint": "^17.16.0",
122
343
  "stylelint-config-recommended": "^18.0.0",
123
- "typescript": "^6.0.3"
344
+ "typescript": "^7.0.2"
124
345
  },
125
346
  "dependencies": {
126
- "ws": "^8.20.1"
347
+ "@exodus/stasis": "1.0.0-beta.9",
348
+ "@exodus/stasis-core": "1.0.0-beta.9",
349
+ "@preventive/compare": "^1.2.0",
350
+ "@preventive/diff": "^1.0.2",
351
+ "@preventive/lockfile": "1.0.0",
352
+ "@preventive/publishers": "^1.1.0",
353
+ "@preventive/report": "1.0.0-alpha.9",
354
+ "@preventive/sourcemap": "1.0.0-alpha.1",
355
+ "@preventive/upstream": "1.1.0",
356
+ "css-tree": "^3.2.1",
357
+ "oxc-minify": "^0.152.0",
358
+ "oxc-parser": "^0.152.0",
359
+ "oxfmt": "^0.72.0",
360
+ "semver": "^7.8.5",
361
+ "ws": "^8.22.0"
127
362
  },
128
363
  "peerDependencies": {
129
364
  "@neondatabase/serverless": "^1.0.2",
130
- "@vercel/blob": "^2.3.3"
365
+ "@vercel/blob": "^2.3.3",
366
+ "@vercel/functions": "^3.9.11"
131
367
  },
132
368
  "peerDependenciesMeta": {
133
369
  "@neondatabase/serverless": {
@@ -135,6 +371,9 @@
135
371
  },
136
372
  "@vercel/blob": {
137
373
  "optional": true
374
+ },
375
+ "@vercel/functions": {
376
+ "optional": true
138
377
  }
139
378
  },
140
379
  "packageManager": "pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800"
@@ -0,0 +1,196 @@
1
+ // The characters a text holds that can make it read other than it runs, or
2
+ // hide text in it: control and bidirectional characters, and the invisible
3
+ // characters a payload or a name no one sees can be spelled in (variation
4
+ // selectors, Hangul fillers, tags). Shared with a code viewer that shows each
5
+ // as a labelled box (ui/view/control-chars.js), which leaves what spells an
6
+ // emoji, a recommended flag or a line's end as it is (passed).
7
+
8
+ // What a text holds beyond printing characters and its line breaks: the C0
9
+ // controls other than tab, line feed and carriage return, DEL, the C1
10
+ // controls, and the bidirectional controls that can make code read other than
11
+ // it runs ("Trojan Source"); and the invisible characters that can hide text
12
+ // in it (invisibleCharacters), as a payload hidden in
13
+ // variation selectors or a variable named by a Hangul filler.
14
+ export const CONTROLS = /(?![\t\n\r])\p{Cc}|[\u202A-\u202E\u2066-\u2069]/gu
15
+ const NON_ASCII = /\P{ASCII}/u
16
+
17
+ // A file's text: `kind` 'ascii' or 'utf8', by whether it holds anything past
18
+ // ASCII, else 'binary' (which the server tells by its bytes, sending no
19
+ // text); `controls` the control and invisible characters a text holds, how
20
+ // often by code point, or null for none.
21
+ export function npmTextEncoding(text) {
22
+ if (typeof text !== 'string') return { kind: 'binary', controls: null }
23
+ const controls = new Map()
24
+ for (const [char] of text.matchAll(CONTROLS)) controls.set(char.codePointAt(0), (controls.get(char.codePointAt(0)) ?? 0) + 1)
25
+ // The invisible characters are all past ASCII: looked for in a text that
26
+ // has any, from its first.
27
+ const past = text.search(NON_ASCII)
28
+ if (past !== -1) for (const [code, times] of invisibleCharacters(text, past) ?? []) controls.set(code, times)
29
+ return { kind: past === -1 ? 'ascii' : 'utf8', controls: controls.size > 0 ? controls : null }
30
+ }
31
+
32
+ // A pictograph is an assigned one (Emoji): Extended_Pictographic also takes
33
+ // in code points reserved for emoji to come, unassigned, each boxed itself,
34
+ // and a joiner or selector beside one would go unseen.
35
+ const EMOJI_BEFORE = /(?=\p{Emoji})\p{Extended_Pictographic}(?:\u{FE0F}|[\u{1F3FB}-\u{1F3FF}])?$/u
36
+ const EMOJI_AFTER = /^(?=\p{Emoji})\p{Extended_Pictographic}/u
37
+ const PICTOGRAPH_BEFORE = /(?=\p{Emoji})\p{Extended_Pictographic}$/u
38
+ const KEYCAP_BASE = /^[\d#*]$/u
39
+ const isTag = code => code >= 0xe0020 && code <= 0xe007f
40
+ // The subdivision flags Unicode recommends (RGI), their tags spelling the
41
+ // subdivision after a black flag: England's, Scotland's and Wales's. Others
42
+ // show as a black flag and their tags as nothing, as a payload in them would.
43
+ const FLAGS = new Set(['gbeng', 'gbsct', 'gbwls'])
44
+ const tagged = (text, from, to) => to - from === 10 ? String.fromCodePoint(...Array.from({ length: 5 }, (_, i) => text.codePointAt(from + 2 * i) - 0xe0000)) : ''
45
+
46
+ // Where to go on from where `code` at `at` in `text` stays text, else -1 for
47
+ // one to show. A CR before a newline is part of the line end, as is one that
48
+ // ends `text` where `lineEnd` says a newline follows it. A joiner between two
49
+ // emoji joins them into one, a recommended subdivision flag's tags, up to the
50
+ // cancel tag, name its region (FLAGS), and the text or emoji presentation
51
+ // selector after a pictograph, or the emoji one between a keycap's digit, #
52
+ // or * and its mark, draws it; after a letter or a digit alone it is another
53
+ // name.
54
+ export function passed(text, at, code, lineEnd) {
55
+ if (code === 0x0d && (text[at + 1] === '\n' || lineEnd && at + 1 === text.length)) return at + 1
56
+ if (code === 0x200d && EMOJI_BEFORE.test(text.slice(Math.max(0, at - 4), at)) && EMOJI_AFTER.test(text.slice(at + 1, at + 3))) return at + 1
57
+ if ((code === 0xfe0e || code === 0xfe0f) && PICTOGRAPH_BEFORE.test(text.slice(Math.max(0, at - 2), at))) return at + 1
58
+ if (code === 0xfe0f && KEYCAP_BASE.test(text[at - 1] ?? '') && text[at + 1] === '\u20E3') return at + 1
59
+ if (isTag(code) && !isTag(text.codePointAt(at - 2))) {
60
+ let end = at
61
+ while (isTag(text.codePointAt(end))) end += 2
62
+ if (text.codePointAt(at - 2) === 0x1f3f4 && text.codePointAt(end - 2) === 0xe007f && FLAGS.has(tagged(text, at, end - 2))) return end
63
+ }
64
+ return -1
65
+ }
66
+
67
+ // Those text is hidden in, as a file's Invisible chars label counts them
68
+ // (readability.js), where they show: variation selectors (a payload, a
69
+ // byte a selector), Hangul fillers (a name no one sees) and tags (ASCII no one
70
+ // sees). Not the format characters, a BOM or a zero-width space, which text
71
+ // has its uses for, nor the other marks that show as nothing (the combining
72
+ // grapheme joiner, the Khmer inherent vowels and the Mongolian free variation
73
+ // selectors), which tables of the characters a name may hold, as JavaScript
74
+ // parsers have, hold too; nor what of these hides nothing (benign).
75
+ const INVISIBLE = /[\u115F\u1160\u3164\uFFA0\u{E0001}\u{E0020}-\u{E007F}]|[\uFE00-\uFE0F]|[\u{E0100}-\u{E01EF}]/u
76
+ // The code units they are in, to look for them by, faster than by code point:
77
+ // the high surrogate starting those past the Basic Multilingual Plane (tags,
78
+ // the selectors' supplement) too, told apart from its others once found. No
79
+ // `u`, which would read a pair as the one code point it spells.
80
+ // eslint-disable-next-line require-unicode-regexp
81
+ const INVISIBLE_UNITS = /[\uFE00-\uFE0F\u115F\u1160\u3164\uFFA0\uDB40]/g
82
+ // A table's code points, from its ranges in hex (`30 2018-2019`).
83
+ const codePoints = ranges => new Set(ranges.split(' ').flatMap(range => {
84
+ const [from, to = from] = range.split('-').map(digits => Number.parseInt(digits, 16))
85
+ return Array.from({ length: to - from + 1 }, (_, i) => from + i)
86
+ }))
87
+ // The variation sequences Unicode registers, which hide nothing, though Code
88
+ // shows their selectors after a letter or a digit, another name there: VS1 to
89
+ // VS14's on other than an ideograph (StandardizedVariants.txt, Unicode
90
+ // 18.0.0), each selector's bases, as an HTML entity table's math symbols, and
91
+ // the emoji with a text and an emoji presentation, VS15 and VS16 after each
92
+ // (emoji-variation-sequences.txt), as a heading's anchor keeps one (`#`).
93
+ const STANDARDIZED = new Map([
94
+ [0xfe00, '30 1000 1002 1004 1010-1011 1015 1019-101a 101c-101d 1022 1031 1075'
95
+ + ' 1078 107a 1080 2018-2019 201c-201d 210b 2110 2112 211b 212c 2130-2131'
96
+ + ' 2133 2205 2229-222a 223d 2242-2243 2248 2268-2269 2272-2273 228a-228b'
97
+ + ' 2293-2295 2297 229c 22cd 22da-22dd 29b7 2a3c-2a3d 2a6c 2a9d-2a9e'
98
+ + ' 2aac-2aad 2acb-2acc 3001-3002 31c0 31c6 31c9 31cf-31d2 31d4-31d5 31d7'
99
+ + ' 31db-31dd 31e5 a856 a85c a85e-a860 a868 aa60-aa66 aa6b-aa6c aa6f aa7a'
100
+ + ' ff01 ff0c ff0e ff10 ff1a-ff1b ff1f 10ac5-10ac6 10ad6-10ad7 10ae1 13091'
101
+ + ' 1310f 1311c 13121 13127 13139 131a0 131b1 131b8-131b9 131cb 131e0'
102
+ + ' 131f9-131fa 1327b 1327f 13285 1328c 132aa 132cb 132dc 132e7 13307'
103
+ + ' 1331b 13322 1333c 13377-13378 13399-1339a 133d3 133e4-133e5 133e7'
104
+ + ' 133ee 133f2 133f5-133f6 13416 13419-1341a 13423 13443-13446'
105
+ + ' 13be8-13bea 13f72 1d49c 1d49e-1d49f 1d4a2 1d4a5-1d4a6 1d4a9-1d4ac'
106
+ + ' 1d4ae-1d4b5 1db10'],
107
+ [0xfe01, '2018-2019 201c-201d 210b 2110 2112 211b 212c 2130-2131 2133 3001-3002'
108
+ + ' 31c6 31cf 31dd ff01 ff0c ff0e ff1a-ff1b ff1f 13093 13132 13139 13187'
109
+ + ' 131b1 131ee 131f8-131fa 13257 1327f 1328b 132a4 13308 13312-13314'
110
+ + ' 1331b 13321-13322 13331 133e8 13419 13f1f 14274 1d49c 1d49e-1d49f'
111
+ + ' 1d4a2 1d4a5-1d4a6 1d4a9-1d4ac 1d4ae-1d4b5'],
112
+ [0xfe02, '2018-2019 201c-201d 13117 13139 13183 131a0 131ba 131ee 13216 1327b'
113
+ + ' 132a4 132e7 132e9 132f8 132fd 13302-13303 13310-13314 1331c 13321'
114
+ + ' 13331 1334a 13361 13373 1337d 13385 133af-133b0 133bf 133db 133dd'
115
+ + ' 13419 1342c 1342e 14274 1d4cf'],
116
+ [0xfe03, '13012 130b8 130ba 1310f 1312f 13139 13184 1319c-1319d 1319f 131b1'
117
+ + ' 131db 13205 13296 13338 13419'],
118
+ [0xfe04, '13139 1340d'],
119
+ [0xfe05, '13139 14274'],
120
+ [0xfe06, '1312f 13139 13184 131db 131ee 13205 132a4 132e9 1332b 13338'
121
+ + ' 13370-13371 13419 14274'],
122
+ ].map(([selector, bases]) => [selector, codePoints(bases)]))
123
+ const EMOJI = codePoints('23 2a 30-39 a9 ae 203c 2049 2122 2139 2194-2199 21a9-21aa 231a-231b 2328'
124
+ + ' 23cf 23e9-23f3 23f8-23fa 24c2 25aa-25ab 25b6 25c0 25fb-25fe 2600-2604 260e'
125
+ + ' 2611 2614-2615 2618 261d 2620 2622-2623 2626 262a 262e-262f 2638-263a 2640'
126
+ + ' 2642 2648-2653 265f-2660 2663 2665-2666 2668 267b 267e-267f 2692-2697 2699'
127
+ + ' 269b-269c 26a0-26a1 26a7 26aa-26ab 26b0-26b1 26bd-26be 26c4-26c5 26c8'
128
+ + ' 26ce-26cf 26d1 26d3-26d4 26e9-26ea 26f0-26f5 26f7-26fa 26fd 2702 2705'
129
+ + ' 2708-270d 270f 2712 2714 2716 271d 2721 2728 2733-2734 2744 2747 274c 274e'
130
+ + ' 2753-2755 2757 2763-2764 2795-2797 27a1 27b0 27bf 2934-2935 2b05-2b07'
131
+ + ' 2b1b-2b1c 2b50 2b55 3030 303d 3297 3299 1f004 1f170-1f171 1f17e-1f17f'
132
+ + ' 1f202 1f21a 1f22f 1f237 1f30d-1f30f 1f315 1f31c 1f321 1f324-1f32c 1f336'
133
+ + ' 1f378 1f37d 1f393 1f396-1f397 1f399-1f39b 1f39e-1f39f 1f3a7 1f3ac-1f3ae'
134
+ + ' 1f3c2 1f3c4 1f3c6 1f3ca-1f3ce 1f3d4-1f3e0 1f3ed 1f3f3 1f3f5 1f3f7 1f408'
135
+ + ' 1f415 1f41f 1f426 1f43f 1f441-1f442 1f446-1f449 1f44d-1f44e 1f453 1f46a'
136
+ + ' 1f47d 1f4a3 1f4b0 1f4b3 1f4bb 1f4bf 1f4cb 1f4da 1f4df 1f4e4-1f4e6'
137
+ + ' 1f4ea-1f4ed 1f4f7 1f4f9-1f4fb 1f4fd 1f508 1f50d 1f512-1f513 1f549-1f54a'
138
+ + ' 1f550-1f567 1f56f-1f570 1f573-1f579 1f587 1f58a-1f58d 1f590 1f5a5 1f5a8'
139
+ + ' 1f5b1-1f5b2 1f5bc 1f5c2-1f5c4 1f5d1-1f5d3 1f5dc-1f5de 1f5e1 1f5e3 1f5e8'
140
+ + ' 1f5ef 1f5f3 1f5fa 1f610 1f687 1f68d 1f691 1f694 1f698 1f6ad 1f6b2'
141
+ + ' 1f6b9-1f6ba 1f6bc 1f6cb 1f6cd-1f6cf 1f6e0-1f6e5 1f6e9 1f6f0 1f6f3')
142
+ // The blocks of variation selectors, as those tables write them out as ranges.
143
+ const BLOCKS = [[0xfe00, 0xfe0f], [0xe0100, 0xe01ef]]
144
+ // The compatibility jamo but their filler.
145
+ const JAMO = [[0x3131, 0x3163], [0x3165, 0x318e]]
146
+
147
+ // The code point before `at` in `text`, a pair of surrogates read as one.
148
+ function codePointBefore(text, at) {
149
+ if (at === 0) return undefined
150
+ const pair = at >= 2 ? text.codePointAt(at - 2) : 0
151
+ return pair > 0xffff ? pair : text.codePointAt(at - 1)
152
+ }
153
+ const within = (code, ...ranges) => code !== undefined && ranges.some(([from, to]) => code >= from && code <= to)
154
+
155
+ // Whether the one shown as `code` at `at` hides nothing: a Hangul filler
156
+ // composing Hangul (the initial consonant's before a vowel, a syllable with
157
+ // none, or the vowel's after an initial consonant, one with none), or a
158
+ // compatibility or halfwidth jamo's among those jamo, as a codepage's table
159
+ // lists them, though not one after a syllable, a name that reads as it; a
160
+ // variation sequence Unicode registers; a block of selectors written out as a
161
+ // range in a table (`VS1-VS16`); or an emoji's presentation selector doubled,
162
+ // as copying text leaves it.
163
+ function benign(text, at, code) {
164
+ const end = at + (code > 0xffff ? 2 : 1)
165
+ const after = text.codePointAt(end), before = codePointBefore(text, at)
166
+ switch (code) {
167
+ case 0x115f: return within(after, [0x1161, 0x11a7], [0xd7b0, 0xd7c6])
168
+ case 0x1160: return within(before, [0x1100, 0x115e], [0xa960, 0xa97c])
169
+ case 0x3164: return within(before, ...JAMO) || within(after, ...JAMO)
170
+ case 0xffa0: return within(before, [0xffa1, 0xffdc]) || within(after, [0xffa1, 0xffdc])
171
+ default: return (code === 0xfe0e || code === 0xfe0f ? EMOJI.has(before) : STANDARDIZED.get(code)?.has(before))
172
+ || BLOCKS.some(([from, to]) => code === from && text[end] === '-' && text.codePointAt(end + 1) === to
173
+ || code === to && text[at - 1] === '-' && codePointBefore(text, at - 1) === from)
174
+ || (code === 0xfe0e || code === 0xfe0f) && before === code && PICTOGRAPH_BEFORE.test(text.slice(Math.max(0, at - 3), at - 1))
175
+ }
176
+ }
177
+
178
+ // How many of each a text holds, by code point, or null for none: each one
179
+ // a code viewer shows (passed), visited alone, not each character it shows. `from`:
180
+ // where to look from, as the first character past ASCII, since all of them are.
181
+ export function invisibleCharacters(text, from = 0) {
182
+ let found = null
183
+ INVISIBLE_UNITS.lastIndex = from
184
+ for (let match = INVISIBLE_UNITS.exec(text); match; match = INVISIBLE_UNITS.exec(text)) {
185
+ const at = match.index, code = text.codePointAt(at)
186
+ if (!INVISIBLE.test(String.fromCodePoint(code))) continue
187
+ const next = passed(text, at, code, false)
188
+ if (next !== -1) INVISIBLE_UNITS.lastIndex = next
189
+ else if (!benign(text, at, code)) {
190
+ found ??= new Map()
191
+ found.set(code, (found.get(code) ?? 0) + 1)
192
+ }
193
+ }
194
+ return found
195
+ }
196
+