gathergate 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +212 -2
  3. package/client/dist/assets/geist-mono-cyrillic-400-normal-C51Di1Mf.woff2 +0 -0
  4. package/client/dist/assets/geist-mono-cyrillic-400-normal-CPJFfJgk.woff +0 -0
  5. package/client/dist/assets/geist-mono-cyrillic-500-normal-D2cXvDHF.woff2 +0 -0
  6. package/client/dist/assets/geist-mono-cyrillic-500-normal-DfuvdVgn.woff +0 -0
  7. package/client/dist/assets/geist-mono-cyrillic-600-normal-Dfv53e6N.woff2 +0 -0
  8. package/client/dist/assets/geist-mono-cyrillic-600-normal-DzvMIgFZ.woff +0 -0
  9. package/client/dist/assets/geist-mono-latin-400-normal-B2yvC1Cq.woff +0 -0
  10. package/client/dist/assets/geist-mono-latin-400-normal-DTRLJnHl.woff2 +0 -0
  11. package/client/dist/assets/geist-mono-latin-500-normal-D-GG86Jb.woff +0 -0
  12. package/client/dist/assets/geist-mono-latin-500-normal-YINYabwD.woff2 +0 -0
  13. package/client/dist/assets/geist-mono-latin-600-normal-V-KvD_pi.woff2 +0 -0
  14. package/client/dist/assets/geist-mono-latin-600-normal-bZn07FKM.woff +0 -0
  15. package/client/dist/assets/geist-mono-latin-ext-400-normal-CfzLURNc.woff +0 -0
  16. package/client/dist/assets/geist-mono-latin-ext-400-normal-DI-rJ0UV.woff2 +0 -0
  17. package/client/dist/assets/geist-mono-latin-ext-500-normal-Buglb9-a.woff2 +0 -0
  18. package/client/dist/assets/geist-mono-latin-ext-500-normal-CrWEgvU_.woff +0 -0
  19. package/client/dist/assets/geist-mono-latin-ext-600-normal-B7ybHiTt.woff +0 -0
  20. package/client/dist/assets/geist-mono-latin-ext-600-normal-TphwrhF8.woff2 +0 -0
  21. package/client/dist/assets/geist-mono-symbols2-400-normal-DjbiTEEA.woff +0 -0
  22. package/client/dist/assets/geist-mono-symbols2-500-normal-CmnCPGa0.woff +0 -0
  23. package/client/dist/assets/geist-mono-symbols2-600-normal-D7I4D0GJ.woff +0 -0
  24. package/client/dist/assets/geist-mono-vietnamese-400-normal-CZEPLOgu.woff +0 -0
  25. package/client/dist/assets/geist-mono-vietnamese-500-normal-Dx9-epDo.woff +0 -0
  26. package/client/dist/assets/geist-mono-vietnamese-600-normal-BLL01lwa.woff +0 -0
  27. package/client/dist/assets/index-BWbZAfMJ.js +80 -0
  28. package/client/dist/assets/index-ZnG2njjK.css +2 -0
  29. package/client/dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  30. package/client/dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  31. package/client/dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  32. package/client/dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  33. package/client/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  34. package/client/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  35. package/client/dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  36. package/client/dist/favicon.svg +12 -0
  37. package/client/dist/index.html +16 -0
  38. package/client/dist/site.webmanifest +16 -0
  39. package/dist/adapters/email.js +125 -0
  40. package/dist/adapters/storage.js +106 -0
  41. package/dist/app.js +2126 -0
  42. package/dist/config.js +106 -0
  43. package/dist/db/client.js +294 -0
  44. package/dist/db/queries.js +898 -0
  45. package/dist/emails/templates.js +221 -0
  46. package/dist/index.js +77 -0
  47. package/dist/jobs/chaser.js +81 -0
  48. package/dist/jobs/demo.js +329 -0
  49. package/dist/jobs/purge.js +22 -0
  50. package/dist/jobs/webhook.js +153 -0
  51. package/dist/security/auth.js +69 -0
  52. package/dist/security/crypto.js +91 -0
  53. package/dist/security/magic-bytes.js +131 -0
  54. package/dist/security/rate-limit.js +72 -0
  55. package/dist/security/ssrf.js +181 -0
  56. package/dist/templates/presets.js +341 -0
  57. package/dist/validators/index.js +52 -0
  58. package/dist/validators/packs/au.js +108 -0
  59. package/dist/validators/packs/eu.js +85 -0
  60. package/dist/validators/packs/generic.js +57 -0
  61. package/dist/validators/packs/types.js +1 -0
  62. package/dist/validators/packs/uk.js +58 -0
  63. package/dist/validators/packs/us.js +82 -0
  64. package/package.json +55 -4
@@ -0,0 +1,58 @@
1
+ export function validateUkUtr(raw) {
2
+ const digits = raw.replace(/[\s-]+/g, "");
3
+ if (!/^\d{10}$/.test(digits)) {
4
+ return { valid: false, error: "UK UTR must be exactly 10 digits" };
5
+ }
6
+ const weights = [6, 7, 8, 9, 10, 5, 4, 3, 2];
7
+ let sum = 0;
8
+ for (let i = 0; i < 9; i++) {
9
+ sum += Number(digits[i + 1]) * weights[i];
10
+ }
11
+ const expected = [2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1][sum % 11];
12
+ if (Number(digits[0]) !== expected) {
13
+ return { valid: false, error: "Invalid UK UTR checksum (HMRC mod-11 failed)" };
14
+ }
15
+ return { valid: true, normalised: `${digits.slice(0, 5)} ${digits.slice(5, 10)}` };
16
+ }
17
+ export function validateUkNino(raw) {
18
+ const cleaned = raw.replace(/[\s-]+/g, "").toUpperCase();
19
+ if (!/^(?!BG|GB|NK|KN|TN|NT|ZZ)[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z]\d{6}[A-D]$/.test(cleaned)) {
20
+ return { valid: false, error: "Enter a valid UK National Insurance number (e.g. AA 12 34 56 C)" };
21
+ }
22
+ return {
23
+ valid: true,
24
+ normalised: `${cleaned.slice(0, 2)} ${cleaned.slice(2, 4)} ${cleaned.slice(4, 6)} ${cleaned.slice(6, 8)} ${cleaned[8]}`,
25
+ };
26
+ }
27
+ export function validateUkSortCode(raw) {
28
+ const digits = raw.replace(/[\s-]+/g, "");
29
+ if (!/^\d{6}$/.test(digits) || digits === "000000") {
30
+ return { valid: false, error: "UK Sort Code must be 6 digits and not 00-00-00" };
31
+ }
32
+ return { valid: true, normalised: `${digits.slice(0, 2)}-${digits.slice(2, 4)}-${digits.slice(4, 6)}` };
33
+ }
34
+ export const ukPack = {
35
+ id: "uk",
36
+ name: "United Kingdom",
37
+ validators: {
38
+ uk_utr_mod11: {
39
+ label: "HMRC UTR (10-digit mod-11)",
40
+ short: "UK UTR",
41
+ hint: "10-digit Unique Taxpayer Reference",
42
+ validate: validateUkUtr,
43
+ },
44
+ uk_nino: {
45
+ label: "UK National Insurance (masked)",
46
+ short: "UK NINO",
47
+ hint: "AA 12 34 56 C, stored masked",
48
+ sensitive: true,
49
+ validate: validateUkNino,
50
+ },
51
+ uk_sort_code: {
52
+ label: "UK Bank Sort Code (6-digit)",
53
+ short: "Sort Code",
54
+ hint: "20-00-00",
55
+ validate: validateUkSortCode,
56
+ },
57
+ },
58
+ };
@@ -0,0 +1,82 @@
1
+ function isValidEinPrefix(prefix) {
2
+ return ((prefix >= 1 && prefix <= 6) ||
3
+ (prefix >= 10 && prefix <= 16) ||
4
+ (prefix >= 20 && prefix <= 27) ||
5
+ (prefix >= 30 && prefix <= 48) ||
6
+ (prefix >= 50 && prefix <= 68) ||
7
+ (prefix >= 71 && prefix <= 77) ||
8
+ (prefix >= 80 && prefix <= 88) ||
9
+ (prefix >= 90 && prefix <= 95) ||
10
+ (prefix >= 98 && prefix <= 99));
11
+ }
12
+ export function validateUsEin(raw) {
13
+ const digits = raw.replace(/[\s-]+/g, "");
14
+ if (!/^\d{9}$/.test(digits)) {
15
+ return { valid: false, error: "IRS EIN must be exactly 9 digits (XX-XXXXXXX)" };
16
+ }
17
+ const prefix = Number(digits.slice(0, 2));
18
+ if (!isValidEinPrefix(prefix)) {
19
+ return { valid: false, error: "Invalid IRS EIN prefix" };
20
+ }
21
+ return { valid: true, normalised: `${digits.slice(0, 2)}-${digits.slice(2, 9)}` };
22
+ }
23
+ function isValidAbaPrefix(prefix) {
24
+ return ((prefix >= 0 && prefix <= 12) ||
25
+ (prefix >= 21 && prefix <= 32) ||
26
+ (prefix >= 61 && prefix <= 72) ||
27
+ prefix === 80);
28
+ }
29
+ export function validateUsRoutingAba(raw) {
30
+ const digits = raw.replace(/[\s-]+/g, "");
31
+ if (!/^\d{9}$/.test(digits)) {
32
+ return { valid: false, error: "ABA routing number must be exactly 9 digits" };
33
+ }
34
+ const prefix = Number(digits.slice(0, 2));
35
+ if (!isValidAbaPrefix(prefix)) {
36
+ return { valid: false, error: "Invalid ABA routing number Federal Reserve prefix" };
37
+ }
38
+ const d = digits.split("").map(Number);
39
+ const checksum = 3 * (d[0] + d[3] + d[6]) + 7 * (d[1] + d[4] + d[7]) + (d[2] + d[5] + d[8]);
40
+ if (checksum % 10 !== 0) {
41
+ return { valid: false, error: "Invalid ABA routing number checksum (mod-10 failed)" };
42
+ }
43
+ return { valid: true, normalised: digits };
44
+ }
45
+ export function validateUsSsn(raw) {
46
+ const digits = raw.replace(/[\s-]+/g, "");
47
+ if (!/^\d{9}$/.test(digits)) {
48
+ return { valid: false, error: "US SSN must be exactly 9 digits" };
49
+ }
50
+ const area = Number(digits.slice(0, 3));
51
+ const group = digits.slice(3, 5);
52
+ const serial = digits.slice(5, 9);
53
+ if (area === 0 || area === 666 || area >= 900 || group === "00" || serial === "0000") {
54
+ return { valid: false, error: "Invalid US SSN (violates SSA area, group, or serial rules)" };
55
+ }
56
+ return { valid: true, normalised: `${digits.slice(0, 3)}-${group}-${serial}` };
57
+ }
58
+ export const usPack = {
59
+ id: "us",
60
+ name: "United States",
61
+ validators: {
62
+ us_ein: {
63
+ label: "IRS EIN (9-digit XX-XXXXXXX)",
64
+ short: "US EIN",
65
+ hint: "12-3456789",
66
+ validate: validateUsEin,
67
+ },
68
+ us_routing_aba: {
69
+ label: "US ABA Routing Number (mod-10)",
70
+ short: "ABA Routing",
71
+ hint: "021000021",
72
+ validate: validateUsRoutingAba,
73
+ },
74
+ us_ssn: {
75
+ label: "US SSN (SSA rules, masked)",
76
+ short: "US SSN",
77
+ hint: "9 digits, stored masked",
78
+ sensitive: true,
79
+ validate: validateUsSsn,
80
+ },
81
+ },
82
+ };
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "gathergate",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Self-hosted magic-link client document checklist, deterministic validator, and auto-chaser.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "gathergate": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "client/dist",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/FAAS19/gathergate.git"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "engines": {
24
+ "node": ">=22.13.0"
25
+ },
26
+ "scripts": {
27
+ "dev": "tsx watch src/index.ts",
28
+ "dev:client": "npm --prefix client run dev",
29
+ "build:client": "npm --prefix client run build",
30
+ "build:demo": "npm --prefix client run build:demo",
31
+ "build:site": "npm --prefix site run build",
32
+ "build:pages": "npm run build:site && npm run build:demo",
33
+ "build:cf": "npm run build:pages && node site/scripts/prepare-cf-output.mjs",
34
+ "build:server": "tsc",
35
+ "build": "npm run build:client && npm run build:server",
36
+ "typecheck": "tsc --noEmit && npm --prefix client run typecheck",
37
+ "start": "node dist/index.js",
38
+ "test": "tsx --test tests/*.test.ts && npm --prefix client test",
39
+ "test:e2e": "npm run build && playwright test",
40
+ "test:pages": "npm run build:pages && playwright test --config playwright.pages.config.ts"
41
+ },
42
+ "dependencies": {
43
+ "@hono/node-server": "^2.1.11",
44
+ "aws4fetch": "^1.0.20",
45
+ "hono": "^4.13.21",
46
+ "nodemailer": "^10.6.1",
47
+ "yazl": "^3.3.1"
48
+ },
49
+ "devDependencies": {
50
+ "@axe-core/playwright": "^4.14.0",
51
+ "@playwright/test": "^1.65.1",
52
+ "@types/node": "^24.19.2",
53
+ "@types/nodemailer": "^8.0.2",
54
+ "tsx": "^4.19.4",
55
+ "typescript": "^7.0.2"
56
+ }
57
+ }