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.
- package/LICENSE +21 -0
- package/README.md +212 -2
- package/client/dist/assets/geist-mono-cyrillic-400-normal-C51Di1Mf.woff2 +0 -0
- package/client/dist/assets/geist-mono-cyrillic-400-normal-CPJFfJgk.woff +0 -0
- package/client/dist/assets/geist-mono-cyrillic-500-normal-D2cXvDHF.woff2 +0 -0
- package/client/dist/assets/geist-mono-cyrillic-500-normal-DfuvdVgn.woff +0 -0
- package/client/dist/assets/geist-mono-cyrillic-600-normal-Dfv53e6N.woff2 +0 -0
- package/client/dist/assets/geist-mono-cyrillic-600-normal-DzvMIgFZ.woff +0 -0
- package/client/dist/assets/geist-mono-latin-400-normal-B2yvC1Cq.woff +0 -0
- package/client/dist/assets/geist-mono-latin-400-normal-DTRLJnHl.woff2 +0 -0
- package/client/dist/assets/geist-mono-latin-500-normal-D-GG86Jb.woff +0 -0
- package/client/dist/assets/geist-mono-latin-500-normal-YINYabwD.woff2 +0 -0
- package/client/dist/assets/geist-mono-latin-600-normal-V-KvD_pi.woff2 +0 -0
- package/client/dist/assets/geist-mono-latin-600-normal-bZn07FKM.woff +0 -0
- package/client/dist/assets/geist-mono-latin-ext-400-normal-CfzLURNc.woff +0 -0
- package/client/dist/assets/geist-mono-latin-ext-400-normal-DI-rJ0UV.woff2 +0 -0
- package/client/dist/assets/geist-mono-latin-ext-500-normal-Buglb9-a.woff2 +0 -0
- package/client/dist/assets/geist-mono-latin-ext-500-normal-CrWEgvU_.woff +0 -0
- package/client/dist/assets/geist-mono-latin-ext-600-normal-B7ybHiTt.woff +0 -0
- package/client/dist/assets/geist-mono-latin-ext-600-normal-TphwrhF8.woff2 +0 -0
- package/client/dist/assets/geist-mono-symbols2-400-normal-DjbiTEEA.woff +0 -0
- package/client/dist/assets/geist-mono-symbols2-500-normal-CmnCPGa0.woff +0 -0
- package/client/dist/assets/geist-mono-symbols2-600-normal-D7I4D0GJ.woff +0 -0
- package/client/dist/assets/geist-mono-vietnamese-400-normal-CZEPLOgu.woff +0 -0
- package/client/dist/assets/geist-mono-vietnamese-500-normal-Dx9-epDo.woff +0 -0
- package/client/dist/assets/geist-mono-vietnamese-600-normal-BLL01lwa.woff +0 -0
- package/client/dist/assets/index-BWbZAfMJ.js +80 -0
- package/client/dist/assets/index-ZnG2njjK.css +2 -0
- package/client/dist/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/client/dist/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/client/dist/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/client/dist/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/client/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/client/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/client/dist/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/client/dist/favicon.svg +12 -0
- package/client/dist/index.html +16 -0
- package/client/dist/site.webmanifest +16 -0
- package/dist/adapters/email.js +125 -0
- package/dist/adapters/storage.js +106 -0
- package/dist/app.js +2126 -0
- package/dist/config.js +106 -0
- package/dist/db/client.js +294 -0
- package/dist/db/queries.js +898 -0
- package/dist/emails/templates.js +221 -0
- package/dist/index.js +77 -0
- package/dist/jobs/chaser.js +81 -0
- package/dist/jobs/demo.js +329 -0
- package/dist/jobs/purge.js +22 -0
- package/dist/jobs/webhook.js +153 -0
- package/dist/security/auth.js +69 -0
- package/dist/security/crypto.js +91 -0
- package/dist/security/magic-bytes.js +131 -0
- package/dist/security/rate-limit.js +72 -0
- package/dist/security/ssrf.js +181 -0
- package/dist/templates/presets.js +341 -0
- package/dist/validators/index.js +52 -0
- package/dist/validators/packs/au.js +108 -0
- package/dist/validators/packs/eu.js +85 -0
- package/dist/validators/packs/generic.js +57 -0
- package/dist/validators/packs/types.js +1 -0
- package/dist/validators/packs/uk.js +58 -0
- package/dist/validators/packs/us.js +82 -0
- package/package.json +55 -4
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
export const BUILTIN_TEMPLATES = [
|
|
2
|
+
{
|
|
3
|
+
key: "agency-onboarding",
|
|
4
|
+
name: "Agency / Web Project Client Onboarding",
|
|
5
|
+
description: "Collect brand assets, hosting/domain contacts, company details, and scope sign-off without endless email threads.",
|
|
6
|
+
items: [
|
|
7
|
+
{
|
|
8
|
+
section: "Company Details",
|
|
9
|
+
label: "Primary Project Contact Email",
|
|
10
|
+
helpText: "Email address for approvals and handover credentials.",
|
|
11
|
+
kind: "text",
|
|
12
|
+
required: true,
|
|
13
|
+
validator: "email",
|
|
14
|
+
slug: "contact-email",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
section: "Company Details",
|
|
18
|
+
label: "Existing Website URL",
|
|
19
|
+
helpText: "Include https:// (or enter https://example.com if greenfield).",
|
|
20
|
+
kind: "text",
|
|
21
|
+
required: false,
|
|
22
|
+
validator: "url",
|
|
23
|
+
slug: "website-url",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
section: "Brand & Creative Assets",
|
|
27
|
+
label: "High-Resolution Brand Logo & Style Guide",
|
|
28
|
+
helpText: "Upload PNG/JPEG/PDF brand files (max 20 MB each).",
|
|
29
|
+
kind: "file",
|
|
30
|
+
required: true,
|
|
31
|
+
validator: "none",
|
|
32
|
+
allowedGroups: ["pdf", "image"],
|
|
33
|
+
maxFileMb: 20,
|
|
34
|
+
multiple: true,
|
|
35
|
+
slug: "brand-assets",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
section: "Brand & Creative Assets",
|
|
39
|
+
label: "Copywriting & Key Page Notes",
|
|
40
|
+
helpText: "Key messaging points, offers, or links to existing drafts.",
|
|
41
|
+
kind: "textarea",
|
|
42
|
+
required: false,
|
|
43
|
+
validator: "none",
|
|
44
|
+
slug: "copy-notes",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
section: "Sign-Off",
|
|
48
|
+
label: "Authorisation Declaration",
|
|
49
|
+
helpText: "I confirm we hold rights to all uploaded assets and approve kick-off.",
|
|
50
|
+
kind: "checkbox",
|
|
51
|
+
required: true,
|
|
52
|
+
validator: "none",
|
|
53
|
+
slug: "authorisation",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "au-individual-tax-eofy",
|
|
59
|
+
name: "AU Individual Tax Return (EOFY Pack)",
|
|
60
|
+
description: "Australian EOFY personal tax checklist with ATO TFN mod-11 masking, BSB verification, and receipt uploads.",
|
|
61
|
+
items: [
|
|
62
|
+
{
|
|
63
|
+
section: "Identity & ATO Details",
|
|
64
|
+
label: "Tax File Number (TFN)",
|
|
65
|
+
helpText: "Validated deterministically via ATO mod-11 and stored encrypted/masked.",
|
|
66
|
+
kind: "text",
|
|
67
|
+
required: true,
|
|
68
|
+
validator: "au_tfn_mod11",
|
|
69
|
+
slug: "tfn",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
section: "Identity & ATO Details",
|
|
73
|
+
label: "Refund Bank BSB",
|
|
74
|
+
helpText: "6-digit Australian BSB (e.g. 062-000).",
|
|
75
|
+
kind: "text",
|
|
76
|
+
required: true,
|
|
77
|
+
validator: "au_bsb",
|
|
78
|
+
slug: "refund-bsb",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
section: "Identity & ATO Details",
|
|
82
|
+
label: "Mobile Phone Number",
|
|
83
|
+
helpText: "Australian mobile normalised to +61 E.164.",
|
|
84
|
+
kind: "text",
|
|
85
|
+
required: true,
|
|
86
|
+
validator: "au_phone_e164",
|
|
87
|
+
slug: "mobile",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
section: "Income & Deductions",
|
|
91
|
+
label: "Private Health Insurance Tax Statement",
|
|
92
|
+
helpText: "Annual PDF statement from your health fund.",
|
|
93
|
+
kind: "file",
|
|
94
|
+
required: false,
|
|
95
|
+
validator: "none",
|
|
96
|
+
allowedGroups: ["pdf", "image"],
|
|
97
|
+
maxFileMb: 15,
|
|
98
|
+
multiple: false,
|
|
99
|
+
slug: "private-health-statement",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
section: "Income & Deductions",
|
|
103
|
+
label: "Work-Related Expense Receipts & Logbook",
|
|
104
|
+
helpText: "Upload PDFs, images, or CSV/XLSX summary spreadsheets.",
|
|
105
|
+
kind: "file",
|
|
106
|
+
required: true,
|
|
107
|
+
validator: "none",
|
|
108
|
+
allowedGroups: ["pdf", "image", "spreadsheet"],
|
|
109
|
+
maxFileMb: 25,
|
|
110
|
+
multiple: true,
|
|
111
|
+
slug: "deduction-receipts",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
section: "Declaration",
|
|
115
|
+
label: "Taxpayer Accuracy Declaration",
|
|
116
|
+
helpText: "I declare all income and deduction records provided are true and complete.",
|
|
117
|
+
kind: "checkbox",
|
|
118
|
+
required: true,
|
|
119
|
+
validator: "none",
|
|
120
|
+
slug: "tax-declaration",
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
key: "au-bas-bookkeeping",
|
|
126
|
+
name: "AU Company / BAS Bookkeeping Pack",
|
|
127
|
+
description: "Quarterly BAS & supplier invoice intake pack with ATO ABN mod-89 validation and bank/statement uploads.",
|
|
128
|
+
items: [
|
|
129
|
+
{
|
|
130
|
+
section: "Entity Identification",
|
|
131
|
+
label: "Australian Business Number (ABN)",
|
|
132
|
+
helpText: "11-digit ABN verified via ATO modulo-89 maths.",
|
|
133
|
+
kind: "text",
|
|
134
|
+
required: true,
|
|
135
|
+
validator: "au_abn_mod89",
|
|
136
|
+
slug: "abn",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
section: "Entity Identification",
|
|
140
|
+
label: "Operating Bank BSB",
|
|
141
|
+
helpText: "6-digit BSB for reconciliation verification.",
|
|
142
|
+
kind: "text",
|
|
143
|
+
required: true,
|
|
144
|
+
validator: "au_bsb",
|
|
145
|
+
slug: "bank-bsb",
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
section: "Quarter Records",
|
|
149
|
+
label: "Business Bank Statements (Full Quarter)",
|
|
150
|
+
helpText: "Upload official PDF statements or CSV exports.",
|
|
151
|
+
kind: "file",
|
|
152
|
+
required: true,
|
|
153
|
+
validator: "none",
|
|
154
|
+
allowedGroups: ["pdf", "spreadsheet"],
|
|
155
|
+
maxFileMb: 25,
|
|
156
|
+
multiple: true,
|
|
157
|
+
slug: "bank-statements",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
section: "Quarter Records",
|
|
161
|
+
label: "Missing Supplier Tax Invoices & Capital Purchases",
|
|
162
|
+
helpText: "PDF or photo scans of tax invoices over $82.50 incl. GST.",
|
|
163
|
+
kind: "file",
|
|
164
|
+
required: false,
|
|
165
|
+
validator: "none",
|
|
166
|
+
allowedGroups: ["pdf", "image"],
|
|
167
|
+
maxFileMb: 20,
|
|
168
|
+
multiple: true,
|
|
169
|
+
slug: "supplier-invoices",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
section: "Sign-Off",
|
|
173
|
+
label: "Director BAS Lodgement Authority",
|
|
174
|
+
helpText: "I confirm records cover the complete BAS reporting period.",
|
|
175
|
+
kind: "checkbox",
|
|
176
|
+
required: true,
|
|
177
|
+
validator: "none",
|
|
178
|
+
slug: "bas-authority",
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
key: "au-allied-health-intake",
|
|
184
|
+
name: "AU Allied Health Clinic New Patient Intake",
|
|
185
|
+
description: "Passwordless clinical referral & Medicare intake pack with Services Australia mod-10 + IRN verification.",
|
|
186
|
+
items: [
|
|
187
|
+
{
|
|
188
|
+
section: "Patient Details",
|
|
189
|
+
label: "Medicare Card Number + IRN",
|
|
190
|
+
helpText: "11 digits including 1-digit IRN (verified via Services Australia mod-10 and stored masked).",
|
|
191
|
+
kind: "text",
|
|
192
|
+
required: true,
|
|
193
|
+
validator: "au_medicare_mod10",
|
|
194
|
+
slug: "medicare",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
section: "Patient Details",
|
|
198
|
+
label: "Patient Mobile Number",
|
|
199
|
+
helpText: "Used for appointment SMS confirmations (+61).",
|
|
200
|
+
kind: "text",
|
|
201
|
+
required: true,
|
|
202
|
+
validator: "au_phone_e164",
|
|
203
|
+
slug: "patient-mobile",
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
section: "Clinical Documents",
|
|
207
|
+
label: "GP Referral / Care Plan (EPC / MHCP)",
|
|
208
|
+
helpText: "Upload PDF or clear photo of signed GP referral letter.",
|
|
209
|
+
kind: "file",
|
|
210
|
+
required: true,
|
|
211
|
+
validator: "none",
|
|
212
|
+
allowedGroups: ["pdf", "image"],
|
|
213
|
+
maxFileMb: 15,
|
|
214
|
+
multiple: true,
|
|
215
|
+
slug: "gp-referral",
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
section: "Consent",
|
|
219
|
+
label: "Privacy & Clinical Intake Consent",
|
|
220
|
+
helpText: "I consent to the clinic collecting these records for treatment and Medicare claiming.",
|
|
221
|
+
kind: "checkbox",
|
|
222
|
+
required: true,
|
|
223
|
+
validator: "none",
|
|
224
|
+
slug: "clinical-consent",
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
key: "kyc-legal-onboarding",
|
|
230
|
+
name: "Legal / KYC Client Onboarding",
|
|
231
|
+
description: "Know-your-client intake pack with verified E.164 phone, IBAN banking, photo ID upload, and compliance sign-off.",
|
|
232
|
+
items: [
|
|
233
|
+
{
|
|
234
|
+
section: "Contact & Identity",
|
|
235
|
+
label: "Authorised Signatory Email",
|
|
236
|
+
helpText: "Email address for engagement letters and compliance notices.",
|
|
237
|
+
kind: "text",
|
|
238
|
+
required: true,
|
|
239
|
+
validator: "email",
|
|
240
|
+
slug: "signatory-email",
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
section: "Contact & Identity",
|
|
244
|
+
label: "Primary Mobile or Direct Phone",
|
|
245
|
+
helpText: "International format starting with + and country code.",
|
|
246
|
+
kind: "text",
|
|
247
|
+
required: true,
|
|
248
|
+
validator: "phone_e164",
|
|
249
|
+
slug: "primary-phone",
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
section: "Banking & AML",
|
|
253
|
+
label: "Settlement IBAN",
|
|
254
|
+
helpText: "International Bank Account Number verified via mod-97.",
|
|
255
|
+
kind: "text",
|
|
256
|
+
required: true,
|
|
257
|
+
validator: "iban",
|
|
258
|
+
slug: "settlement-iban",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
section: "Verification Documents",
|
|
262
|
+
label: "Certified Photo ID (Passport or Driver Licence)",
|
|
263
|
+
helpText: "Upload clear PDF or image scans of current government-issued ID.",
|
|
264
|
+
kind: "file",
|
|
265
|
+
required: true,
|
|
266
|
+
validator: "none",
|
|
267
|
+
allowedGroups: ["pdf", "image"],
|
|
268
|
+
maxFileMb: 15,
|
|
269
|
+
multiple: true,
|
|
270
|
+
slug: "photo-id",
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
section: "Declaration",
|
|
274
|
+
label: "KYC & AML Confirmation",
|
|
275
|
+
helpText: "I confirm all identity and banking details provided are accurate and belong to the named client.",
|
|
276
|
+
kind: "checkbox",
|
|
277
|
+
required: true,
|
|
278
|
+
validator: "none",
|
|
279
|
+
slug: "kyc-confirmation",
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
key: "mortgage-loan-pack",
|
|
285
|
+
name: "Mortgage & Loan Document Pack",
|
|
286
|
+
description: "Borrowing assessment pack with contact email, optional US ABA routing verification, bank statement and payslip uploads, and borrower declaration.",
|
|
287
|
+
items: [
|
|
288
|
+
{
|
|
289
|
+
section: "Borrower Details",
|
|
290
|
+
label: "Borrower Email Address",
|
|
291
|
+
helpText: "Primary email for lending updates and settlement notices.",
|
|
292
|
+
kind: "text",
|
|
293
|
+
required: true,
|
|
294
|
+
validator: "email",
|
|
295
|
+
slug: "borrower-email",
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
section: "Borrower Details",
|
|
299
|
+
label: "US Servicing Bank ABA Routing Number",
|
|
300
|
+
helpText: "Optional 9-digit US ABA routing number for direct debit verification.",
|
|
301
|
+
kind: "text",
|
|
302
|
+
required: false,
|
|
303
|
+
validator: "us_routing_aba",
|
|
304
|
+
slug: "aba-routing",
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
section: "Financial Records",
|
|
308
|
+
label: "Recent Bank Statements (3 Months)",
|
|
309
|
+
helpText: "Official PDF statements showing income deposits and regular expenses.",
|
|
310
|
+
kind: "file",
|
|
311
|
+
required: true,
|
|
312
|
+
validator: "none",
|
|
313
|
+
allowedGroups: ["pdf"],
|
|
314
|
+
maxFileMb: 25,
|
|
315
|
+
multiple: true,
|
|
316
|
+
slug: "bank-statements",
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
section: "Financial Records",
|
|
320
|
+
label: "Recent Payslips or Income Verification",
|
|
321
|
+
helpText: "Upload your last two payslips or latest tax assessment PDFs.",
|
|
322
|
+
kind: "file",
|
|
323
|
+
required: true,
|
|
324
|
+
validator: "none",
|
|
325
|
+
allowedGroups: ["pdf"],
|
|
326
|
+
maxFileMb: 20,
|
|
327
|
+
multiple: true,
|
|
328
|
+
slug: "payslips",
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
section: "Declaration",
|
|
332
|
+
label: "Borrower Accuracy Declaration",
|
|
333
|
+
helpText: "I declare all financial statements and income documents supplied are true and unaltered.",
|
|
334
|
+
kind: "checkbox",
|
|
335
|
+
required: true,
|
|
336
|
+
validator: "none",
|
|
337
|
+
slug: "loan-declaration",
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
},
|
|
341
|
+
];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { auPack } from "./packs/au.js";
|
|
2
|
+
import { euPack } from "./packs/eu.js";
|
|
3
|
+
import { genericPack } from "./packs/generic.js";
|
|
4
|
+
import { ukPack } from "./packs/uk.js";
|
|
5
|
+
import { usPack } from "./packs/us.js";
|
|
6
|
+
/** Add a country pack: create `packs/<code>.ts` exporting a ValidatorPack, then list it here. */
|
|
7
|
+
export const VALIDATOR_PACKS = [genericPack, auPack, ukPack, usPack, euPack];
|
|
8
|
+
const REGISTRY = new Map();
|
|
9
|
+
for (const pack of VALIDATOR_PACKS) {
|
|
10
|
+
for (const [key, def] of Object.entries(pack.validators)) {
|
|
11
|
+
if (REGISTRY.has(key))
|
|
12
|
+
throw new Error(`Duplicate validator key "${key}" in pack "${pack.id}"`);
|
|
13
|
+
REGISTRY.set(key, { ...def, pack: pack.id });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export const SENSITIVE_VALIDATORS = new Set([...REGISTRY].filter(([, def]) => def.sensitive).map(([key]) => key));
|
|
17
|
+
export function isKnownValidator(key) {
|
|
18
|
+
return REGISTRY.has(key);
|
|
19
|
+
}
|
|
20
|
+
export function getValidatorHint(key) {
|
|
21
|
+
return REGISTRY.get(key)?.hint;
|
|
22
|
+
}
|
|
23
|
+
export function listValidators() {
|
|
24
|
+
return [...REGISTRY].map(([key, def]) => ({
|
|
25
|
+
key,
|
|
26
|
+
pack: def.pack,
|
|
27
|
+
label: def.label,
|
|
28
|
+
short: def.short,
|
|
29
|
+
hint: def.hint ?? null,
|
|
30
|
+
sensitive: Boolean(def.sensitive),
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
export function validateTextValue(validator, raw) {
|
|
34
|
+
const trimmed = raw.trim();
|
|
35
|
+
if (!trimmed)
|
|
36
|
+
return { valid: false, error: "Value is required" };
|
|
37
|
+
const def = REGISTRY.get(validator);
|
|
38
|
+
if (!def)
|
|
39
|
+
return { valid: false, error: "This field has an unknown validator. Contact the sender." };
|
|
40
|
+
return def.validate(trimmed);
|
|
41
|
+
}
|
|
42
|
+
export function maskSensitiveValue(validator, value) {
|
|
43
|
+
if (!SENSITIVE_VALIDATORS.has(validator))
|
|
44
|
+
return value;
|
|
45
|
+
const compact = /[A-Za-z]/.test(value)
|
|
46
|
+
? value.replace(/[\s-]+/g, "").toUpperCase()
|
|
47
|
+
: value.replace(/\D+/g, "");
|
|
48
|
+
if (compact.length <= 3)
|
|
49
|
+
return "***";
|
|
50
|
+
const tail = compact.slice(-3);
|
|
51
|
+
return `${"*".repeat(Math.max(3, compact.length - 3))} ${tail}`;
|
|
52
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export function validateAuAbn(raw) {
|
|
2
|
+
const digits = raw.replace(/[\s-]+/g, "");
|
|
3
|
+
if (!/^[1-9]\d{10}$/.test(digits)) {
|
|
4
|
+
return { valid: false, error: "ABN must be 11 digits and cannot start with 0" };
|
|
5
|
+
}
|
|
6
|
+
const weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19];
|
|
7
|
+
const nums = digits.split("").map((d) => Number(d));
|
|
8
|
+
nums[0] -= 1;
|
|
9
|
+
const sum = nums.reduce((acc, n, i) => acc + n * weights[i], 0);
|
|
10
|
+
if (sum % 89 !== 0) {
|
|
11
|
+
return { valid: false, error: "Invalid ABN checksum (ATO mod-89 failed)" };
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
valid: true,
|
|
15
|
+
normalised: `${digits.slice(0, 2)} ${digits.slice(2, 5)} ${digits.slice(5, 8)} ${digits.slice(8, 11)}`,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function validateAuBsb(raw) {
|
|
19
|
+
const digits = raw.replace(/[\s-]+/g, "");
|
|
20
|
+
if (!/^\d{6}$/.test(digits)) {
|
|
21
|
+
return { valid: false, error: "BSB must be exactly 6 digits (e.g. 062-000)" };
|
|
22
|
+
}
|
|
23
|
+
return { valid: true, normalised: `${digits.slice(0, 3)}-${digits.slice(3, 6)}` };
|
|
24
|
+
}
|
|
25
|
+
export function validateAuTfn(raw) {
|
|
26
|
+
const digits = raw.replace(/[\s-]+/g, "");
|
|
27
|
+
if (!/^\d{8,9}$/.test(digits) || /^0+$/.test(digits)) {
|
|
28
|
+
return { valid: false, error: "TFN must be 8 or 9 digits" };
|
|
29
|
+
}
|
|
30
|
+
const weights = digits.length === 9 ? [1, 4, 3, 7, 5, 8, 6, 9, 10] : [10, 7, 8, 4, 6, 3, 5, 1];
|
|
31
|
+
const sum = digits.split("").reduce((acc, ch, i) => acc + Number(ch) * weights[i], 0);
|
|
32
|
+
if (sum % 11 !== 0) {
|
|
33
|
+
return { valid: false, error: "Invalid TFN checksum (ATO mod-11 failed)" };
|
|
34
|
+
}
|
|
35
|
+
const formatted = digits.length === 9
|
|
36
|
+
? `${digits.slice(0, 3)} ${digits.slice(3, 6)} ${digits.slice(6, 9)}`
|
|
37
|
+
: `${digits.slice(0, 2)} ${digits.slice(2, 5)} ${digits.slice(5, 8)}`;
|
|
38
|
+
return { valid: true, normalised: formatted };
|
|
39
|
+
}
|
|
40
|
+
export function validateAuMedicare(raw) {
|
|
41
|
+
const stripped = raw.trim().replace(/\s*\/\s*(?=\d\s*$)/, "");
|
|
42
|
+
const digits = stripped.replace(/[\s-]+/g, "");
|
|
43
|
+
if (!/^\d{10,11}$/.test(digits)) {
|
|
44
|
+
return { valid: false, error: "Medicare number must be 10 digits (+ optional 1-digit IRN)" };
|
|
45
|
+
}
|
|
46
|
+
if (!/^[2-6]/.test(digits)) {
|
|
47
|
+
return { valid: false, error: "Medicare card number must start with 2, 3, 4, 5, or 6" };
|
|
48
|
+
}
|
|
49
|
+
const weights = [1, 3, 7, 9, 1, 3, 7, 9];
|
|
50
|
+
let sum = 0;
|
|
51
|
+
for (let i = 0; i < 8; i++) {
|
|
52
|
+
sum += Number(digits[i]) * weights[i];
|
|
53
|
+
}
|
|
54
|
+
if (sum % 10 !== Number(digits[8])) {
|
|
55
|
+
return { valid: false, error: "Invalid Medicare checksum (Services Australia mod-10 failed)" };
|
|
56
|
+
}
|
|
57
|
+
if (digits[9] === "0") {
|
|
58
|
+
return { valid: false, error: "Medicare issue number (10th digit) cannot be 0" };
|
|
59
|
+
}
|
|
60
|
+
if (digits.length === 11 && digits[10] === "0") {
|
|
61
|
+
return { valid: false, error: "Medicare IRN (11th digit) must be 1 to 9" };
|
|
62
|
+
}
|
|
63
|
+
const base = `${digits.slice(0, 4)} ${digits.slice(4, 9)} ${digits[9]}`;
|
|
64
|
+
return {
|
|
65
|
+
valid: true,
|
|
66
|
+
normalised: digits.length === 11 ? `${base} / ${digits[10]}` : base,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function validateAuPhone(raw) {
|
|
70
|
+
const cleaned = raw.replace(/[\s()-]+/g, "");
|
|
71
|
+
let e164 = "";
|
|
72
|
+
if (/^\+61[23478]\d{8}$/.test(cleaned)) {
|
|
73
|
+
e164 = cleaned;
|
|
74
|
+
}
|
|
75
|
+
else if (/^61[23478]\d{8}$/.test(cleaned)) {
|
|
76
|
+
e164 = `+${cleaned}`;
|
|
77
|
+
}
|
|
78
|
+
else if (/^0[23478]\d{8}$/.test(cleaned)) {
|
|
79
|
+
e164 = `+61${cleaned.slice(1)}`;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return { valid: false, error: "Enter a valid Australian mobile or landline number (e.g. 0412 345 678)" };
|
|
83
|
+
}
|
|
84
|
+
return { valid: true, normalised: e164 };
|
|
85
|
+
}
|
|
86
|
+
export const auPack = {
|
|
87
|
+
id: "au",
|
|
88
|
+
name: "Australia",
|
|
89
|
+
validators: {
|
|
90
|
+
au_phone_e164: { label: "AU phone (+61 E.164)", short: "+61 Phone", hint: "0412 345 678", validate: validateAuPhone },
|
|
91
|
+
au_abn_mod89: { label: "ATO ABN (11-digit mod-89)", short: "ABN", hint: "51 824 753 556", validate: validateAuAbn },
|
|
92
|
+
au_bsb: { label: "Australian BSB (6-digit)", short: "BSB", hint: "062-000", validate: validateAuBsb },
|
|
93
|
+
au_tfn_mod11: {
|
|
94
|
+
label: "ATO TFN (mod-11, masked)",
|
|
95
|
+
short: "TFN",
|
|
96
|
+
hint: "8 or 9 digits, stored masked",
|
|
97
|
+
sensitive: true,
|
|
98
|
+
validate: validateAuTfn,
|
|
99
|
+
},
|
|
100
|
+
au_medicare_mod10: {
|
|
101
|
+
label: "Medicare + IRN (mod-10, masked)",
|
|
102
|
+
short: "Medicare",
|
|
103
|
+
hint: "10 or 11 digits incl. IRN",
|
|
104
|
+
sensitive: true,
|
|
105
|
+
validate: validateAuMedicare,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const EU_VAT_PATTERNS = {
|
|
2
|
+
AT: /^U\d{8}$/,
|
|
3
|
+
BE: /^[01]\d{9}$/,
|
|
4
|
+
BG: /^\d{9,10}$/,
|
|
5
|
+
CY: /^\d{8}[A-Z]$/,
|
|
6
|
+
CZ: /^\d{8,10}$/,
|
|
7
|
+
DE: /^\d{9}$/,
|
|
8
|
+
DK: /^\d{8}$/,
|
|
9
|
+
EE: /^\d{9}$/,
|
|
10
|
+
EL: /^\d{9}$/,
|
|
11
|
+
ES: /^[A-Z0-9]\d{7}[A-Z0-9]$/,
|
|
12
|
+
FI: /^\d{8}$/,
|
|
13
|
+
FR: /^[A-HJ-NP-Z0-9]{2}\d{9}$/,
|
|
14
|
+
HR: /^\d{11}$/,
|
|
15
|
+
HU: /^\d{8}$/,
|
|
16
|
+
IE: /^(?:\d{7}[A-Z]{1,2}|\d[A-Z+*]\d{5}[A-Z])$/,
|
|
17
|
+
IT: /^\d{11}$/,
|
|
18
|
+
LT: /^(?:\d{9}|\d{12})$/,
|
|
19
|
+
LU: /^\d{8}$/,
|
|
20
|
+
LV: /^\d{11}$/,
|
|
21
|
+
MT: /^\d{8}$/,
|
|
22
|
+
NL: /^\d{9}B\d{2}$/,
|
|
23
|
+
PL: /^\d{10}$/,
|
|
24
|
+
PT: /^\d{9}$/,
|
|
25
|
+
RO: /^\d{2,10}$/,
|
|
26
|
+
SE: /^\d{12}$/,
|
|
27
|
+
SI: /^\d{8}$/,
|
|
28
|
+
SK: /^\d{10}$/,
|
|
29
|
+
};
|
|
30
|
+
function checkDeVat(body) {
|
|
31
|
+
let product = 10;
|
|
32
|
+
for (let i = 0; i < 8; i++) {
|
|
33
|
+
let sum = (Number(body[i]) + product) % 10;
|
|
34
|
+
if (sum === 0)
|
|
35
|
+
sum = 10;
|
|
36
|
+
product = (2 * sum) % 11;
|
|
37
|
+
}
|
|
38
|
+
const checkDigit = (11 - product) % 10;
|
|
39
|
+
return Number(body[8]) === checkDigit;
|
|
40
|
+
}
|
|
41
|
+
export function validateEuVat(raw) {
|
|
42
|
+
const cleaned = raw.replace(/[\s.-]+/g, "").toUpperCase();
|
|
43
|
+
if (cleaned.length < 4) {
|
|
44
|
+
return { valid: false, error: "EU VAT number must start with a 2-letter EU member state code" };
|
|
45
|
+
}
|
|
46
|
+
const country = cleaned.slice(0, 2);
|
|
47
|
+
const body = cleaned.slice(2);
|
|
48
|
+
const pattern = EU_VAT_PATTERNS[country];
|
|
49
|
+
if (!pattern) {
|
|
50
|
+
return { valid: false, error: `Unsupported or non-EU VAT country code "${country}"` };
|
|
51
|
+
}
|
|
52
|
+
if (!pattern.test(body)) {
|
|
53
|
+
return { valid: false, error: `Invalid ${country} VAT format` };
|
|
54
|
+
}
|
|
55
|
+
if (country === "BE") {
|
|
56
|
+
if (97 - (Number(body.slice(0, 8)) % 97) !== Number(body.slice(8, 10))) {
|
|
57
|
+
return { valid: false, error: "Invalid BE VAT checksum (mod-97 failed)" };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (country === "DE") {
|
|
61
|
+
if (!checkDeVat(body)) {
|
|
62
|
+
return { valid: false, error: "Invalid DE VAT checksum (ISO 7064 mod 11,10 failed)" };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (country === "FR") {
|
|
66
|
+
const key = body.slice(0, 2);
|
|
67
|
+
const siren = body.slice(2);
|
|
68
|
+
if (/^\d{2}/.test(key) && Number(key) !== (12 + 3 * (Number(siren) % 97)) % 97) {
|
|
69
|
+
return { valid: false, error: "Invalid FR VAT checksum (mod-97 failed)" };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { valid: true, normalised: `${country}${body}` };
|
|
73
|
+
}
|
|
74
|
+
export const euPack = {
|
|
75
|
+
id: "eu",
|
|
76
|
+
name: "European Union",
|
|
77
|
+
validators: {
|
|
78
|
+
eu_vat: {
|
|
79
|
+
label: "EU VAT Number (country format + checksum)",
|
|
80
|
+
short: "EU VAT",
|
|
81
|
+
hint: "DE123456788 or FR40303265045",
|
|
82
|
+
validate: validateEuVat,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function validateEmail(v) {
|
|
2
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(v)
|
|
3
|
+
? { valid: true, normalised: v.toLowerCase() }
|
|
4
|
+
: { valid: false, error: "Enter a valid email address" };
|
|
5
|
+
}
|
|
6
|
+
function validateUrl(v) {
|
|
7
|
+
try {
|
|
8
|
+
const parsed = new URL(v);
|
|
9
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
10
|
+
return { valid: false, error: "URL must start with https:// or http://" };
|
|
11
|
+
}
|
|
12
|
+
return { valid: true, normalised: parsed.toString() };
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return { valid: false, error: "Enter a valid URL (e.g. https://example.com)" };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function validatePhoneE164(v) {
|
|
19
|
+
const cleaned = v.replace(/[\s().-]+/g, "");
|
|
20
|
+
if (!/^\+[1-9]\d{7,14}$/.test(cleaned)) {
|
|
21
|
+
return { valid: false, error: "Enter an international number starting with + and country code (e.g. +44 20 7946 0958)" };
|
|
22
|
+
}
|
|
23
|
+
return { valid: true, normalised: cleaned };
|
|
24
|
+
}
|
|
25
|
+
// ISO 13616 IBAN: move first 4 chars to end, letters to numbers (A=10), mod 97 must equal 1.
|
|
26
|
+
function validateIban(v) {
|
|
27
|
+
const iban = v.replace(/\s+/g, "").toUpperCase();
|
|
28
|
+
if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(iban)) {
|
|
29
|
+
return { valid: false, error: "IBAN must start with a 2-letter country code and 2 check digits" };
|
|
30
|
+
}
|
|
31
|
+
const rearranged = iban.slice(4) + iban.slice(0, 4);
|
|
32
|
+
let remainder = 0;
|
|
33
|
+
for (const ch of rearranged) {
|
|
34
|
+
const n = ch >= "A" ? String(ch.charCodeAt(0) - 55) : ch;
|
|
35
|
+
for (const d of n)
|
|
36
|
+
remainder = (remainder * 10 + Number(d)) % 97;
|
|
37
|
+
}
|
|
38
|
+
if (remainder !== 1)
|
|
39
|
+
return { valid: false, error: "Invalid IBAN checksum (mod-97 failed)" };
|
|
40
|
+
return { valid: true, normalised: iban.replace(/(.{4})/g, "$1 ").trim() };
|
|
41
|
+
}
|
|
42
|
+
export const genericPack = {
|
|
43
|
+
id: "generic",
|
|
44
|
+
name: "Generic",
|
|
45
|
+
validators: {
|
|
46
|
+
none: { label: "None (any text)", short: "Text", validate: (v) => ({ valid: true, normalised: v }) },
|
|
47
|
+
email: { label: "Email address", short: "Email", hint: "name@company.com", validate: validateEmail },
|
|
48
|
+
url: { label: "Website URL (https://)", short: "URL", hint: "https://example.com", validate: validateUrl },
|
|
49
|
+
phone_e164: {
|
|
50
|
+
label: "International phone (E.164)",
|
|
51
|
+
short: "Phone",
|
|
52
|
+
hint: "+44 20 7946 0958",
|
|
53
|
+
validate: validatePhoneE164,
|
|
54
|
+
},
|
|
55
|
+
iban: { label: "IBAN (mod-97)", short: "IBAN", hint: "GB82 WEST 1234 5698 7654 32", validate: validateIban },
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|