WIP 2.0.0: v1 removed; Argon2id passwords; node-fetch gone
- /api (v1) answers 410 API_V1_REMOVED, except provider webhooks (/api/webhooks/*, /api/whatsapp/webhook) and links in sent messages (308s, one-click POST). 43 v1 route files and deprecation.ts removed; /docs redirects to /docs/v2; API_DOCUMENTATION.md points there. - Read-only and impersonation lists name v2 paths only. The campus scope route test now runs over v2 routes (v2CampusScope.test.ts). - Passwords hashed with Argon2id (@node-rs/argon2); bcrypt hashes still sign in and are re-hashed at the next sign-in. - e2e on /api/v2 only (v2() helper); Playwright waits on /api/v2. - MIGRATING-TO-2.md with the full v1 -> v2 table. - Two documented response shapes corrected. Backend 690 tests and e2e 102/102 (PayFast sandbox skipped) pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,34 @@ and this project follows [Semantic Versioning](https://semver.org/).
|
||||
editor.
|
||||
- `npm run ai:eval` (backend): the helpers' eval set — fixed examples run through the site's Hub
|
||||
connection, with automatic checks on the facts and every answer printed to read.
|
||||
- **MIGRATING-TO-2.md:** what changes for integrations and for whoever runs the server, with every
|
||||
v1 address and its v2 replacement.
|
||||
|
||||
### Removed
|
||||
|
||||
- **API v1** (`/api/…`). Every screen has used `/api/v2` since 1.51.16. Any v1 address now answers
|
||||
`410 Gone` with `code: "API_V1_REMOVED"`, except what outside senders still use: the provider
|
||||
webhooks (`/api/webhooks/yoco|payfast|whatsapp` and WAWP's oldest `/api/whatsapp/webhook`) and
|
||||
the links in messages already sent (calendar files and one-click unsubscribe answer `308` with
|
||||
their v2 address; a mail app's one-click POST to the old address is still handled) —
|
||||
`legacyV1Router` and `v1Removed` in `src/v2/links.ts`. The 43 v1 route files are gone (the
|
||||
controllers stay: `v1Route` runs them behind v2 routes); so are the `Deprecation` headers
|
||||
(`src/v2/deprecation.ts`), the v1 reference at `/docs` (it redirects to `/docs/v2`) and the
|
||||
hand-written `backend/API_DOCUMENTATION.md` (now a pointer to `/docs/v2`).
|
||||
- `node-fetch` from the backend's dependencies (nothing used it since the move to native `fetch`).
|
||||
|
||||
### Changed
|
||||
|
||||
- **Passwords are hashed with Argon2id** (`@node-rs/argon2`, 19 MiB, 2 passes) instead of bcrypt.
|
||||
bcrypt hashes still sign in, and are re-hashed with Argon2id the first time each person signs in
|
||||
(`needsRehash` in `src/config/auth.js`, used by `logIn`). `bcryptjs` stays only to check those.
|
||||
- The campus-scope route test runs over the v2 routes (`tests/v2CampusScope.test.ts`): each staff
|
||||
or supervisor route needs a campus-scope middleware or must be on the list of routes whose
|
||||
service checks campuses itself. The read-only and impersonation lists name v2 paths only.
|
||||
- e2e tests call `/api/v2` only (`v2()` in `e2e/fixtures.ts` returns the answer's `data`);
|
||||
Playwright waits for `/api/v2/setup/needed`.
|
||||
- Documented shapes corrected: the access log's `actions` (action → label) and a cash-up's
|
||||
`cashDenominations` (notes and coins).
|
||||
|
||||
## [1.52.3] - 2026-11-02
|
||||
|
||||
|
||||
@@ -0,0 +1,408 @@
|
||||
# Moving to Cross Events 2.0
|
||||
|
||||
Cross Events 2.0 removes version 1 of the API (`/api/…`). Everything the app does has been on
|
||||
version 2 (`/api/v2/…`) since 1.51.16, so **a church that only uses the app has nothing to do** —
|
||||
the update looks the same as any other. This guide is for anyone with their own integration (a
|
||||
script, a website plug-in, a spreadsheet import) that calls the API directly, and for whoever runs
|
||||
the server.
|
||||
|
||||
## What still works without changes
|
||||
|
||||
- **Payment and WhatsApp webhooks.** Yoco, PayFast and WAWP keep posting to the addresses they were
|
||||
registered with: `/api/webhooks/yoco`, `/api/webhooks/payfast`, `/api/webhooks/whatsapp` and the
|
||||
oldest WAWP address, `/api/whatsapp/webhook`. New registrations use `/api/v2/webhooks/…`.
|
||||
- **Links in messages already sent.** "Add to calendar" links (`/api/events/{id}/ics`) and one-click
|
||||
unsubscribe links (`/api/privacy/unsubscribe/{token}/one-click`) answer `308` with their v2
|
||||
address; a mail app's one-click `POST` to the old address is still handled.
|
||||
- **Outbound webhooks** (Site settings → Webhooks) send the same events and payloads as before.
|
||||
- **Pages people open** — event pages, consent forms, ticket transfers, waitlist offers — are app
|
||||
pages, not API addresses, so they were never affected.
|
||||
|
||||
Any other `/api/…` address now answers **`410 Gone`**:
|
||||
|
||||
```json
|
||||
{ "code": "API_V1_REMOVED", "message": "API v1 was removed in Cross Events 2.0. Use /api/v2 — it is described at /docs/v2." }
|
||||
```
|
||||
|
||||
`/docs` (the v1 reference) redirects to `/docs/v2`.
|
||||
|
||||
## How v2 differs
|
||||
|
||||
The full reference is at `/docs/v2` on your site (sign in as an admin), generated from the code so
|
||||
it is always current. The OpenAPI 3.1 document is `GET /api/v2/openapi.json`.
|
||||
|
||||
| | v1 | v2 |
|
||||
|---|---|---|
|
||||
| Answers | whatever each endpoint returned | always `{ "data": … }` |
|
||||
| Lists | plain arrays, some paged | `{ "data": [ … ], "meta": { "page", "limit", "total", "pages" } }`, `?page=` and `?limit=` (most lists up to 100) |
|
||||
| Errors | `{ "message", "code"? }`, often `400` | `{ "error": { "code", "message", "reason"?, "fields"? } }` — `code` is one of a fixed set (`VALIDATION_FAILED`, `UNAUTHENTICATED`, `FORBIDDEN`, `NOT_FOUND`, `CONFLICT`, `READ_ONLY`, `RATE_LIMITED`, `UNAVAILABLE`, `INTERNAL`); v1's `code` is now `reason` |
|
||||
| Input | anything | checked against the documented schema; mistakes are `VALIDATION_FAILED` with `fields` |
|
||||
| Changing a record | mostly `PUT` | `PATCH` for partial changes (events, ticket options, variants, series, users, coupons…) |
|
||||
| Dates | mixed | ISO 8601, UTC |
|
||||
|
||||
Things that behave differently, not just live at a new address:
|
||||
|
||||
- **Signing in:** `POST /api/v2/auth/login` takes `{ identifier, password }` (an email or phone
|
||||
number). If two-step sign-in is on, the answer is `status: "code_sent"` with a `challengeId`;
|
||||
finish with `POST /api/v2/auth/login/code`.
|
||||
- **Signing up:** `POST /api/v2/auth/signup` needs `acceptTerms: true`; the phone number is
|
||||
`phone`. The answer's `data` holds `token` and `user`.
|
||||
- **Checking a ticket in:** `POST /api/v2/checkin/{qrCode}` with `{ people? }` (was `qty`). Every
|
||||
normal result is a `200` with an `outcome` — `checked_in`, `already_used`, `consent_required`,
|
||||
`wrong_event`, … — where v1 used `403`s. Look a ticket up first with `GET /api/v2/checkin/{qrCode}`.
|
||||
- **Paying online:** `POST /api/v2/registrations/{id}/checkout` (the registration is in the path,
|
||||
not the body).
|
||||
- **Cancelling a registration:** `POST /api/v2/registrations/{id}/cancel` (was `DELETE`).
|
||||
- **Staff lists of registrations** are paged (up to 200 a page).
|
||||
- **A suspended or unlicensed site** refuses new events, registrations and payments with
|
||||
`READ_ONLY` / reason `LICENCE_READ_ONLY`.
|
||||
|
||||
## For whoever runs the server
|
||||
|
||||
1. Deploy as usual: `bash scripts/deploy.sh v2.0.0` (it backs up, migrates, builds and rolls back
|
||||
on failure). Run `bash scripts/deploy.sh --check` first if anyone may have changed files by hand.
|
||||
2. Two migrations run: `20261030120000_ai_helpers` (the AI call log) and anything newer listed in the
|
||||
CHANGELOG.
|
||||
3. **AI helpers** need the site connected to the Hub (Site settings → Licence) and a monthly AI cap
|
||||
above R0 on the licence. The Hub must run 1.6.0 or later. With no cap the AI buttons don't show
|
||||
and nothing else changes.
|
||||
4. If something outside Cross Events still calls `/api/…`, it will get `410` after the update — look
|
||||
for those in the nginx access log before updating (`grep -v '/api/v2/' access.log | grep ' /api/'`,
|
||||
leaving out the webhook and link addresses above).
|
||||
5. Passwords are re-hashed with a stronger method the next time each person signs in; nothing to do.
|
||||
|
||||
## Every v1 address and its v2 replacement
|
||||
|
||||
`{id}` is the record's id. `{a|b}` means either. Methods that changed are shown in the v2 column.
|
||||
|
||||
| v1 | v2 |
|
||||
|---|---|
|
||||
| `GET /api/events` | `GET /api/v2/events` |
|
||||
| `GET /api/events/{id}` | `GET /api/v2/events/{id}/full` |
|
||||
| `GET /api/events/{id}/ics` | `GET /api/v2/events/{id}/calendar.ics` |
|
||||
| `GET /api/events/by-alias/{id}` | `GET /api/v2/events/by-alias/{id}` |
|
||||
| `POST /api/events/{id}/options` | `POST /api/v2/events/{id}/ticket-options` |
|
||||
| `PUT /api/events/options/{id}` | `PATCH /api/v2/ticket-options/{id}` |
|
||||
| `DELETE /api/events/options/{id}` | `DELETE /api/v2/ticket-options/{id}` |
|
||||
| `POST /api/events/options/{id}/variants` | `POST /api/v2/ticket-options/{id}/variants` |
|
||||
| `PUT /api/events/variants/{id}` | `PATCH /api/v2/variants/{id}` |
|
||||
| `DELETE /api/events/variants/{id}` | `DELETE /api/v2/variants/{id}` |
|
||||
| `GET /api/events/attachments/status` | `GET /api/v2/attachments/status` |
|
||||
| `POST /api/events/attachments/sync` | `POST /api/v2/attachments/sync` |
|
||||
| `GET /api/events/{id}/attachments` | `GET /api/v2/events/{id}/attachments` |
|
||||
| `POST /api/events/{id}/attachments` | `POST /api/v2/events/{id}/attachments` |
|
||||
| `DELETE /api/events/{id}/attachments/{id2}` | `DELETE /api/v2/events/{id}/attachments/{id2}` |
|
||||
| `GET /api/sections` | `GET /api/v2/sections` |
|
||||
| `POST /api/sections` | `POST /api/v2/sections` |
|
||||
| `PUT /api/sections/{id}` | `PATCH /api/v2/sections/{id}` |
|
||||
| `DELETE /api/sections/{id}` | `DELETE /api/v2/sections/{id}` |
|
||||
| `GET /api/events/{id}/costs` | `GET /api/v2/events/{id}/costs` |
|
||||
| `POST /api/events/{id}/costs` | `POST /api/v2/events/{id}/costs` |
|
||||
| `PUT /api/costs/{id}` | `PATCH /api/v2/costs/{id}` |
|
||||
| `DELETE /api/costs/{id}` | `DELETE /api/v2/costs/{id}` |
|
||||
| `POST /api/uploads/{event-image|logo|favicon}` | `POST /api/v2/uploads/{event-image|logo|favicon}` |
|
||||
| `GET /api/events/all` | `GET /api/v2/events/manage` |
|
||||
| `POST /api/events` | `POST /api/v2/events` |
|
||||
| `PUT /api/events/{id}` | `PATCH /api/v2/events/{id}` |
|
||||
| `DELETE /api/events/{id}` | `DELETE /api/v2/events/{id}` |
|
||||
| `POST /api/events/{id}/copy-from` | `POST /api/v2/events/{id}/copy-from` |
|
||||
| `GET /api/events/{id}/notify-recipients` | `GET /api/v2/events/{id}/notify-recipients` |
|
||||
| `PUT /api/events/{id}/notify-recipients` | `PUT /api/v2/events/{id}/notify-recipients` |
|
||||
| `POST /api/webhooks/{yoco|payfast|whatsapp}` | `POST /api/v2/webhooks/{yoco|payfast|whatsapp}` |
|
||||
| `POST /api/whatsapp/webhook` | `POST /api/v2/webhooks/whatsapp` |
|
||||
| `POST /api/privacy/unsubscribe/{id}/one-click` | `POST /api/v2/unsubscribe/{id}/one-click` |
|
||||
| `GET /api/privacy/me` | `GET /api/v2/me/privacy` |
|
||||
| `PUT /api/privacy/me/news` | `PUT /api/v2/me/privacy/news` |
|
||||
| `GET /api/privacy/me/export` | `GET /api/v2/me/privacy/export` |
|
||||
| `POST /api/privacy/me/requests` | `POST /api/v2/me/privacy/requests` |
|
||||
| `POST /api/privacy/me/notice/accept` | `POST /api/v2/me/privacy/notice/accept` |
|
||||
| `GET /api/privacy/notice` | `GET /api/v2/privacy/notice` |
|
||||
| `GET /api/privacy/unsubscribe/{id}` | `GET /api/v2/unsubscribe/{id}` |
|
||||
| `POST /api/privacy/unsubscribe/{id}` | `POST /api/v2/unsubscribe/{id}` |
|
||||
| `GET /api/privacy/requests` | `GET /api/v2/privacy/requests` |
|
||||
| `POST /api/privacy/requests/{id}/{complete|reject}` | `POST /api/v2/privacy/requests/{id}/{complete|reject}` |
|
||||
| `GET /api/privacy/notice/draft` | `GET /api/v2/privacy/notice/draft` |
|
||||
| `PUT /api/privacy/notice/draft` | `PUT /api/v2/privacy/notice/draft` |
|
||||
| `DELETE /api/privacy/notice/draft` | `DELETE /api/v2/privacy/notice/draft` |
|
||||
| `POST /api/privacy/notice/{publish|builtin-reviewed}` | `POST /api/v2/privacy/notice/{publish|builtin-reviewed}` |
|
||||
| `GET /api/privacy/operators` | `GET /api/v2/privacy/operators` |
|
||||
| `POST /api/privacy/operators` | `POST /api/v2/privacy/operators` |
|
||||
| `PUT /api/privacy/operators/{id}` | `PUT /api/v2/privacy/operators/{id}` |
|
||||
| `DELETE /api/privacy/operators/{id}` | `DELETE /api/v2/privacy/operators/{id}` |
|
||||
| `GET /api/privacy/{consent-log|access-log|readiness|retention|breaches}` | `GET /api/v2/privacy/{consent-log|access-log|readiness|retention|breaches}` |
|
||||
| `PUT /api/privacy/retention` | `PUT /api/v2/privacy/retention` |
|
||||
| `POST /api/privacy/retention/run` | `POST /api/v2/privacy/retention/run` |
|
||||
| `POST /api/privacy/breaches` | `POST /api/v2/privacy/breaches` |
|
||||
| `PUT /api/privacy/breaches/{id}` | `PUT /api/v2/privacy/breaches/{id}` |
|
||||
| `GET /api/admin/{audit-log|jobs|impersonation-sessions}` | `GET /api/v2/admin/{audit-log|jobs|impersonation-sessions}` |
|
||||
| `POST /api/admin/jobs/{id}/run` | `POST /api/v2/admin/jobs/{id}/run` |
|
||||
| `POST /api/admin/impersonate/{end|log}` | `POST /api/v2/me/impersonation/{end|log}` |
|
||||
| `GET /api/admin/impersonate/current` | `GET /api/v2/me/impersonation` |
|
||||
| `POST /api/admin/impersonate/{id}` | `POST /api/v2/admin/impersonate/{id}` |
|
||||
| `GET /api/settings/needs-setup` | `GET /api/v2/setup/needed` |
|
||||
| `GET /api/settings/all` | `GET /api/v2/settings/all` |
|
||||
| `GET /api/settings` | `GET /api/v2/settings` |
|
||||
| `PUT /api/settings` | `PUT /api/v2/settings` |
|
||||
| `POST /api/settings/test-smtp` | `POST /api/v2/settings/test-smtp` |
|
||||
| `POST /api/setup/register` | `POST /api/v2/setup/register` |
|
||||
| `POST /api/setup` | `POST /api/v2/setup` |
|
||||
| `GET /api/hub/{status|notices}` | `GET /api/v2/hub/{status|notices}` |
|
||||
| `POST /api/hub/{connect|heartbeat|update-request|update-snooze}` | `POST /api/v2/hub/{connect|heartbeat|update-request|update-snooze}` |
|
||||
| `POST /api/hub/update-request/cancel` | `POST /api/v2/hub/update-request/cancel` |
|
||||
| `GET /api/outbound-webhooks` | `GET /api/v2/outbound-webhooks` |
|
||||
| `POST /api/outbound-webhooks` | `POST /api/v2/outbound-webhooks` |
|
||||
| `POST /api/outbound-webhooks/deliveries/{id}/resend` | `POST /api/v2/outbound-webhook-deliveries/{id}/resend` |
|
||||
| `PUT /api/outbound-webhooks/{id}` | `PATCH /api/v2/outbound-webhooks/{id}` |
|
||||
| `DELETE /api/outbound-webhooks/{id}` | `DELETE /api/v2/outbound-webhooks/{id}` |
|
||||
| `POST /api/outbound-webhooks/{id}/{rotate-secret|test}` | `POST /api/v2/outbound-webhooks/{id}/{rotate-secret|test}` |
|
||||
| `GET /api/outbound-webhooks/{id}/deliveries` | `GET /api/v2/outbound-webhooks/{id}/deliveries` |
|
||||
| `GET /api/backups` | `GET /api/v2/backups` |
|
||||
| `POST /api/backups/run` | `POST /api/v2/backups/run` |
|
||||
| `GET /api/backups/{id}/download` | `GET /api/v2/backups/{id}/download` |
|
||||
| `GET /api/{yoco|payfast}/config` | `GET /api/v2/payments/{yoco|payfast}/config` |
|
||||
| `PUT /api/{yoco|payfast}/config` | `PUT /api/v2/payments/{yoco|payfast}/config` |
|
||||
| `GET /api/yoco/webhooks` | `GET /api/v2/payments/yoco/webhooks` |
|
||||
| `POST /api/yoco/webhooks` | `POST /api/v2/payments/yoco/webhooks` |
|
||||
| `DELETE /api/yoco/webhooks/{id}` | `DELETE /api/v2/payments/yoco/webhooks/{id}` |
|
||||
| `POST /api/payfast/test` | `POST /api/v2/payments/payfast/test` |
|
||||
| `POST /api/users/login/2fa/resend` | `POST /api/v2/auth/login/code/resend` |
|
||||
| `POST /api/users/forgot` | `POST /api/v2/auth/password/forgot` |
|
||||
| `POST /api/users/reset` | `POST /api/v2/auth/password/reset` |
|
||||
| `POST /api/users/activate` | `POST /api/v2/auth/activate` |
|
||||
| `POST /api/users/revoke-sessions` | `POST /api/v2/me/sessions/revoke` |
|
||||
| `POST /api/users/close-account` | `POST /api/v2/me/close` |
|
||||
| `GET /api/users/activity` | `GET /api/v2/me/activity` |
|
||||
| `POST /api/users/verify-password` | `POST /api/v2/me/verify-password` |
|
||||
| `POST /api/users/2fa/{enable|confirm|disable}` | `POST /api/v2/me/two-factor/{enable|confirm|disable}` |
|
||||
| `GET /api/users/check-exists` | `GET /api/v2/users/exists` |
|
||||
| `POST /api/users/{id}/revoke-sessions` | `POST /api/v2/users/{id}/sessions/revoke` |
|
||||
| `POST /api/users/{id}/anonymize` | `POST /api/v2/users/{id}/anonymize` |
|
||||
| `GET /api/users` | `GET /api/v2/users` |
|
||||
| `GET /api/users/{?!profile$}{id}` | `GET /api/v2/users/{?!profile$}` |
|
||||
| `PUT /api/users/{?!profile$}{id}` | `PATCH /api/v2/users/{?!profile$}` |
|
||||
| `DELETE /api/users/{id}` | `DELETE /api/v2/users/{id}` |
|
||||
| `GET /api/events/admin/all` | `GET /api/v2/admin/events` |
|
||||
| `POST /api/events/{id}/{email|whatsapp}-attendees` | `POST /api/v2/events/{id}/{email|whatsapp}-attendees` |
|
||||
| `POST /api/events/{id}/{email|whatsapp}-attendees/schedule` | `POST /api/v2/events/{id}/{email|whatsapp}-attendees/schedule` |
|
||||
| `POST /api/broadcasts/{preview|send|schedule}` | `POST /api/v2/broadcasts/email/{preview|send|schedule}` |
|
||||
| `POST /api/whatsapp-broadcasts/{preview|send|schedule}` | `POST /api/v2/broadcasts/whatsapp/{preview|send|schedule}` |
|
||||
| `GET /api/scheduled-emails` | `GET /api/v2/scheduled-messages` |
|
||||
| `PATCH /api/scheduled-emails/{id}` | `PATCH /api/v2/scheduled-messages/{id}` |
|
||||
| `DELETE /api/scheduled-emails/{id}` | `DELETE /api/v2/scheduled-messages/{id}` |
|
||||
| `POST /api/automations/schedule` | `POST /api/v2/automations/schedule` |
|
||||
| `GET /api/whatsapp/{config|status|qr}` | `GET /api/v2/whatsapp/{config|status|qr}` |
|
||||
| `POST /api/whatsapp/config` | `GET/PUT /api/v2/whatsapp/config` |
|
||||
| `POST /api/whatsapp/create-instance` | `POST /api/v2/whatsapp/instance` |
|
||||
| `POST /api/whatsapp/delete-instance` | `POST /api/v2/whatsapp/instance` |
|
||||
| `POST /api/whatsapp/{request-code|logout|start|restart}` | `POST /api/v2/whatsapp/{request-code|logout|start|restart}` |
|
||||
| `GET /api/banner` | `GET /api/v2/banner` |
|
||||
| `POST /api/banner` | `GET/PUT /api/v2/banner` |
|
||||
| `GET /api/saved-filters` | `GET /api/v2/saved-filters` |
|
||||
| `POST /api/saved-filters` | `POST /api/v2/saved-filters` |
|
||||
| `PUT /api/saved-filters/{id}` | `PUT /api/v2/saved-filters/{id}` |
|
||||
| `DELETE /api/saved-filters/{id}` | `DELETE /api/v2/saved-filters/{id}` |
|
||||
| `GET /api/dashboard/{today|search}` | `GET /api/v2/dashboard/{today|search}` |
|
||||
| `GET /api/stats/{staff|supervisor|admin|overview}` | `GET /api/v2/stats/{staff|supervisor|admin|overview}` |
|
||||
| `POST /api/analytics/track` | `POST /api/v2/analytics/track` |
|
||||
| `GET /api/analytics/funnel` | `GET /api/v2/analytics/funnel` |
|
||||
| `POST /api/reports/{pdf|excel|email|whatsapp}` | `POST /api/v2/reports/{pdf|excel|email|whatsapp}` |
|
||||
| `GET /api/kids/me` | `GET /api/v2/me/family` |
|
||||
| `POST /api/kids/me` | `POST /api/v2/me/family` |
|
||||
| `PUT /api/kids/me` | `PATCH /api/v2/me/family` |
|
||||
| `DELETE /api/kids/me` | `DELETE /api/v2/me/family` |
|
||||
| `POST /api/kids/me/{children|adults}` | `POST /api/v2/me/family/{children|adults}` |
|
||||
| `PUT /api/kids/me/{children|adults}/{id}` | `PUT /api/v2/me/family/{children|adults}/{id}` |
|
||||
| `DELETE /api/kids/me/{children|adults}/{id}` | `DELETE /api/v2/me/family/{children|adults}/{id}` |
|
||||
| `GET /api/kids/setup-events` | `GET /api/v2/kids/setup-events` |
|
||||
| `GET /api/kids/events` | `GET /api/v2/kids/events` |
|
||||
| `GET /api/kids/events/{id}/{settings|board|families|offline}` | `GET /api/v2/events/{id}/kids/{settings|board|families|offline}` |
|
||||
| `PUT /api/kids/events/{id}/settings` | `PUT /api/v2/events/{id}/kids/settings` |
|
||||
| `POST /api/kids/events/{id}/{families|check-in|check-out|duty|sync}` | `POST /api/v2/events/{id}/kids/{families|check-in|check-out|duty|sync}` |
|
||||
| `GET /api/kids/events/{id}/families/qr/{id2}` | `GET /api/v2/events/{id}/kids/families/qr/{id2}` |
|
||||
| `GET /api/kids/events/{id}/families/{id2}` | `GET /api/v2/events/{id}/kids/families/{id2}` |
|
||||
| `POST /api/kids/events/{id}/families/{id2}/{parents|children|adults}` | `POST /api/v2/events/{id}/kids/families/{id2}/{parents|children|adults}` |
|
||||
| `PUT /api/kids/events/{id}/families/{id2}/children/{id3}` | `PUT /api/v2/events/{id}/kids/families/{id2}/children/{id3}` |
|
||||
| `GET /api/kids/events/{id}/code/{id2}` | `GET /api/v2/events/{id}/kids/code/{id2}` |
|
||||
| `POST /api/kids/check-ins/{id}/{override|page}` | `POST /api/v2/kids/check-ins/{id}/{override|page}` |
|
||||
| `PUT /api/kids/check-ins/{id}/room` | `PUT /api/v2/kids/check-ins/{id}/room` |
|
||||
| `POST /api/kids/alerts/{id}/resolve` | `POST /api/v2/kids/alerts/{id}/resolve` |
|
||||
| `GET /api/volunteers/me` | `GET /api/v2/me/volunteering` |
|
||||
| `GET /api/volunteers/events/{id}` | `GET /api/v2/events/{id}/volunteer-roles` |
|
||||
| `POST /api/volunteers/roles/{id}/sign-up` | `POST /api/v2/volunteer-roles/{id}/sign-up` |
|
||||
| `DELETE /api/volunteers/slots/{id}` | `DELETE /api/v2/volunteer-slots/{id}` |
|
||||
| `POST /api/volunteers/slots/{id}/swap` | `POST /api/v2/volunteer-slots/{id}/swap` |
|
||||
| `DELETE /api/volunteers/swaps/{id}` | `DELETE /api/v2/volunteer-swaps/{id}` |
|
||||
| `POST /api/volunteers/swaps/{id}/accept` | `POST /api/v2/volunteer-swaps/{id}/accept` |
|
||||
| `POST /api/volunteers/check-in` | `POST /api/v2/volunteering/check-in` |
|
||||
| `GET /api/volunteers/manage/events` | `GET /api/v2/volunteering/events` |
|
||||
| `GET /api/volunteers/manage/hours` | `GET /api/v2/volunteering/hours` |
|
||||
| `GET /api/volunteers/manage/events/{id}` | `GET /api/v2/events/{id}/volunteers` |
|
||||
| `GET /api/volunteers/manage/events/{id}/{qr|settings}` | `GET /api/v2/events/{id}/volunteers/{qr|settings}` |
|
||||
| `PUT /api/volunteers/manage/events/{id}/settings` | `PUT /api/v2/events/{id}/volunteers/settings` |
|
||||
| `POST /api/volunteers/manage/events/{id}/roles` | `POST /api/v2/events/{id}/volunteer-roles` |
|
||||
| `PUT /api/volunteers/manage/roles/{id}` | `PATCH /api/v2/volunteer-roles/{id}` |
|
||||
| `DELETE /api/volunteers/manage/roles/{id}` | `DELETE /api/v2/volunteer-roles/{id}` |
|
||||
| `POST /api/volunteers/manage/roles/{id}/assign` | `POST /api/v2/volunteer-roles/{id}/assign` |
|
||||
| `POST /api/volunteers/manage/slots/{id}/check-in` | `POST /api/v2/volunteer-slots/{id}/check-in` |
|
||||
| `DELETE /api/volunteers/manage/slots/{id}` | `POST /api/v2/volunteer-slots/{id}/remove` |
|
||||
| `GET /api/tickets/mytickets` | `GET /api/v2/me/tickets` |
|
||||
| `POST /api/tickets/email` | `POST /api/v2/me/tickets/email` |
|
||||
| `GET /api/tickets/scans/recent` | `GET /api/v2/tickets/scans/recent` |
|
||||
| `GET /api/tickets/scans/stats` | `GET /api/v2/tickets/scans/stats` |
|
||||
| `POST /api/tickets/send-to` | `POST /api/v2/tickets/send` |
|
||||
| `POST /api/tickets/generate` | `POST /api/v2/tickets/generate` |
|
||||
| `PUT /api/tickets/email-sent` | `POST /api/v2/tickets/email-sent` |
|
||||
| `GET /api/tickets/qr/{id}` | `GET /api/v2/tickets/qr/{id}` |
|
||||
| `GET /api/tickets/event/{id}` | `GET /api/v2/events/{id}/tickets` |
|
||||
| `GET /api/tickets/transfer-offer/{id}` | `GET /api/v2/ticket-transfers/{id}` |
|
||||
| `POST /api/tickets/transfer-offer/{id}/{accept|decline}` | `POST /api/v2/ticket-transfers/{id}/{accept|decline}` |
|
||||
| `GET /api/tickets` | `GET /api/v2/tickets` |
|
||||
| `GET /api/tickets/{id}/transfers` | `GET /api/v2/tickets/{id}/transfers` |
|
||||
| `POST /api/tickets/{id}/transfer` | `POST /api/v2/tickets/{id}/transfer` |
|
||||
| `DELETE /api/tickets/{id}/transfer` | `DELETE /api/v2/tickets/{id}/transfer` |
|
||||
| `GET /api/tickets/{id}` | `GET /api/v2/tickets/{id}` |
|
||||
| `GET /api/scan-locks` | `GET /api/v2/scan-locks` |
|
||||
| `POST /api/scan-locks` | `POST /api/v2/scan-locks` |
|
||||
| `GET /api/scan-locks/reports` | `GET /api/v2/scan-locks/reports` |
|
||||
| `POST /api/scan-locks/reports/{id}/review` | `POST /api/v2/scan-locks/reports/{id}/review` |
|
||||
| `GET /api/scan-locks/{id}/snapshot` | `GET /api/v2/scan-locks/{id}/snapshot` |
|
||||
| `POST /api/scan-locks/{id}/{sync|force-release}` | `POST /api/v2/scan-locks/{id}/{sync|force-release}` |
|
||||
| `DELETE /api/scan-locks/{id}` | `DELETE /api/v2/scan-locks/{id}` |
|
||||
| `GET /api/attendance/certificates/verify/{id}` | `GET /api/v2/certificates/verify/{id}` |
|
||||
| `GET /api/attendance/certificates/mine` | `GET /api/v2/me/certificates` |
|
||||
| `POST /api/attendance/certificates/preview` | `POST /api/v2/certificates/preview` |
|
||||
| `GET /api/attendance/certificates/{id}/pdf` | `GET /api/v2/certificates/{id}/pdf` |
|
||||
| `POST /api/attendance/certificates/{id}/revoke` | `POST /api/v2/certificates/{id}/revoke` |
|
||||
| `GET /api/attendance/{id}/export` | `GET /api/v2/events/{id}/attendance/export` |
|
||||
| `POST /api/attendance/{id}/mark` | `POST /api/v2/events/{id}/attendance` |
|
||||
| `POST /api/attendance/{id}/certificates` | `POST /api/v2/events/{id}/certificates` |
|
||||
| `POST /api/attendance/{id}/certificates/send` | `POST /api/v2/events/{id}/certificates/send` |
|
||||
| `GET /api/attendance/{id}/certificates.pdf` | `GET /api/v2/events/{id}/certificates.pdf` |
|
||||
| `GET /api/attendance/{id}` | `GET /api/v2/events/{id}/attendance` |
|
||||
| `GET /api/allocations/my-groups` | `GET /api/v2/me/allocation-groups` |
|
||||
| `GET /api/allocations/event/{id}` | `GET /api/v2/events/{id}/allocations` |
|
||||
| `POST /api/allocations/sets` | `POST /api/v2/allocation-sets` |
|
||||
| `PUT /api/allocations/sets/{id}` | `PATCH /api/v2/allocation-sets/{id}` |
|
||||
| `DELETE /api/allocations/sets/{id}` | `DELETE /api/v2/allocation-sets/{id}` |
|
||||
| `GET /api/allocations/sets/{id}/lists` | `GET /api/v2/allocation-sets/{id}/lists` |
|
||||
| `POST /api/allocations/sets/{id}/{groups|auto}` | `POST /api/v2/allocation-sets/{id}/{groups|auto}` |
|
||||
| `PUT /api/allocations/sets/{id}/assignments` | `PUT /api/v2/allocation-sets/{id}/assignments` |
|
||||
| `DELETE /api/allocations/sets/{id}/assignments` | `DELETE /api/v2/allocation-sets/{id}/assignments` |
|
||||
| `PUT /api/allocations/groups/{id}` | `PATCH /api/v2/allocation-groups/{id}` |
|
||||
| `DELETE /api/allocations/groups/{id}` | `DELETE /api/v2/allocation-groups/{id}` |
|
||||
| `GET /api/payments/providers` | `GET /api/v2/payments/providers` |
|
||||
| `GET /api/payments/providers/settings` | `GET /api/v2/payments/providers/settings` |
|
||||
| `PUT /api/payments/providers/settings` | `PUT /api/v2/payments/providers/settings` |
|
||||
| `GET /api/payments/pay/{id}` | `GET /api/v2/payment-links/{id}` |
|
||||
| `POST /api/payments/pay/{id}` | `POST /api/v2/payment-links/{id}` |
|
||||
| `GET /api/payments/checkouts/open` | `GET /api/v2/payments/open-checkouts` |
|
||||
| `POST /api/payments/checkouts/check` | `POST /api/v2/payments/open-checkouts/check` |
|
||||
| `POST /api/payments/[yoco-]checkout/send` | `POST /api/v2/registrations/{id}/payment-link` |
|
||||
| `GET /api/payments/mypayments` | `GET /api/v2/me/payments` |
|
||||
| `GET /api/payments/admin/stats` | `GET /api/v2/payments/stats` |
|
||||
| `GET /api/payments/registration/{id}` | `GET /api/v2/registrations/{id}/payments` |
|
||||
| `GET /api/payments/event/{id}` | `GET /api/v2/events/{id}/payments` |
|
||||
| `PUT /api/payments/assign-donation` | `POST /api/v2/payments/donations/assign` |
|
||||
| `POST /api/payments/unassign-donation` | `POST /api/v2/payments/donations/unassign` |
|
||||
| `POST /api/payments/refund` | `POST /api/v2/payments/refunds` |
|
||||
| `POST /api/payments/{id}/send-receipt` | `POST /api/v2/payments/{id}/receipt` |
|
||||
| `GET /api/payments` | `GET /api/v2/payments` |
|
||||
| `POST /api/payments` | `POST /api/v2/payments` |
|
||||
| `GET /api/payments/{id}` | `GET /api/v2/payments/{id}` |
|
||||
| `GET /api/cashups/audit` | `GET /api/v2/cashups/audit` |
|
||||
| `GET /api/cashups/event/{id}` | `GET /api/v2/events/{id}/cashup` |
|
||||
| `GET /api/cashups/event/{id}/cash-by-user` | `GET /api/v2/events/{id}/cashup/cash-by-user` |
|
||||
| `PUT /api/cashups/event/{id}/person-cash/{id2}` | `PUT /api/v2/events/{id}/cashup/person-cash/{id2}` |
|
||||
| `PUT /api/cashups/event/{id}/draft` | `PUT /api/v2/events/{id}/cashup/draft` |
|
||||
| `POST /api/cashups/event/{id}/close` | `POST /api/v2/events/{id}/cashup/close` |
|
||||
| `POST /api/cashups/event/{id}/reopen` | `POST /api/v2/events/{id}/cashup/reopen` |
|
||||
| `POST /api/cashups/lines/{id}/pending` | `POST /api/v2/cashup-lines/{id}/pending` |
|
||||
| `GET /api/{provider|yoco}-transactions` | `GET /api/v2/provider-transactions` |
|
||||
| `GET /api/{provider|yoco}-transactions/unreconciled` | `GET /api/v2/provider-transactions/unreconciled` |
|
||||
| `POST /api/{?:provider|yoco}-transactions/{id}/reconcile` | `POST /api/v2/provider-transactions/{?:provider|yoco}/reconcile` |
|
||||
| `POST /api/{?:provider|yoco}-transactions/{id}/ignore` | `POST /api/v2/provider-transactions/{?:provider|yoco}/ignore` |
|
||||
| `POST /api/waitlist` | `POST /api/v2/waitlist` |
|
||||
| `GET /api/waitlist/mine` | `GET /api/v2/me/waitlist` |
|
||||
| `GET /api/waitlist/claim/{id}` | `GET /api/v2/waitlist/claims/{id}` |
|
||||
| `GET /api/waitlist/events/{id}` | `GET /api/v2/events/{id}/waitlist` |
|
||||
| `POST /api/waitlist/{id}/{offer|move|remove}` | `POST /api/v2/waitlist/{id}/{offer|move|remove}` |
|
||||
| `DELETE /api/waitlist/{id}` | `DELETE /api/v2/waitlist/{id}` |
|
||||
| `GET /api/sponsorships/event/{id}` | `GET /api/v2/events/{id}/sponsorship` |
|
||||
| `GET /api/sponsorships/event/{id}/pool` | `GET /api/v2/events/{id}/sponsorship/pool` |
|
||||
| `POST /api/sponsorships/checkout` | `POST /api/v2/sponsorships/checkout` |
|
||||
| `GET /api/consent/events/{id}` | `GET /api/v2/events/{id}/consent` |
|
||||
| `GET /api/consent/events/{id}/medical` | `GET /api/v2/events/{id}/consent/medical` |
|
||||
| `POST /api/consent/events/{id}/{resend-pending|rerequest}` | `POST /api/v2/events/{id}/consent/{resend-pending|rerequest}` |
|
||||
| `POST /api/consent/requests/{id}/resend` | `POST /api/v2/consent-requests/{id}/resend` |
|
||||
| `GET /api/consent/{id}` | `GET /api/v2/consent/{id}` |
|
||||
| `POST /api/consent/{id}` | `POST /api/v2/consent/{id}` |
|
||||
| `GET /api/forms/responses` | `GET /api/v2/form-responses` |
|
||||
| `GET /api/feedback/summary` | `GET /api/v2/feedback/summary` |
|
||||
| `GET /api/feedback/public/{id}` | `GET /api/v2/feedback-forms/{id}` |
|
||||
| `POST /api/feedback/public/{id}` | `POST /api/v2/feedback-forms/{id}` |
|
||||
| `GET /api/feedback/event/{id}` | `GET /api/v2/events/{id}/feedback` |
|
||||
| `PUT /api/feedback/event/{id}` | `PUT /api/v2/events/{id}/feedback` |
|
||||
| `DELETE /api/feedback/event/{id}` | `DELETE /api/v2/events/{id}/feedback` |
|
||||
| `POST /api/feedback/event/{id}/send-now` | `POST /api/v2/events/{id}/feedback/send-now` |
|
||||
| `GET /api/registrations` | `GET /api/v2/registrations` |
|
||||
| `GET /api/registrations/myregistrations` | `GET /api/v2/me/registrations/full` |
|
||||
| `GET /api/registrations/event/{id}` | `GET /api/v2/events/{id}/registrations` |
|
||||
| `POST /api/registrations/manual` | `GET /api/v2/registrations/manual` |
|
||||
| `POST /api/registrations/bulk` | `GET /api/v2/registrations/bulk` |
|
||||
| `PUT /api/registrations/{id}/options` | `PUT /api/v2/registrations/{id}/items` |
|
||||
| `POST /api/registrations/{id}/send-invoice` | `POST /api/v2/registrations/{id}/invoice` |
|
||||
| `POST /api/registrations/{id}/coupon` | `POST /api/v2/registrations/{id}/coupon` |
|
||||
| `DELETE /api/registrations/{id}/coupon` | `DELETE /api/v2/registrations/{id}/coupon` |
|
||||
| `PUT /api/registrations/{id}/attendees` | `PUT /api/v2/registrations/{id}/attendees` |
|
||||
| `POST /api/registrations/{id}/attendees/{id2}/send-form-link` | `POST /api/v2/registrations/{id}/attendees/{id2}/form-link` |
|
||||
| `GET /api/registrations/{id}/forms/draft` | `GET /api/v2/registrations/{id}/form-draft` |
|
||||
| `PUT /api/registrations/{id}/forms/draft` | `PUT /api/v2/registrations/{id}/form-draft` |
|
||||
| `POST /api/registrations/{id}/forms/responses` | `POST /api/v2/registrations/{id}/form-responses` |
|
||||
| `PUT /api/registrations/{id}/forms/responses` | `PUT /api/v2/registrations/{id}/form-responses` |
|
||||
| `GET /api/registrations/{id}` | `GET /api/v2/registrations/{id}/full` |
|
||||
| `PUT /api/registrations/{id}` | `PATCH /api/v2/registrations/{id}/status` |
|
||||
| `GET /api/series` | `GET /api/v2/series` |
|
||||
| `POST /api/series` | `POST /api/v2/series` |
|
||||
| `GET /api/series/by-slug/{id}` | `GET /api/v2/series/by-slug/{id}` |
|
||||
| `GET /api/series/{id}/compare` | `GET /api/v2/series/{id}/compare` |
|
||||
| `POST /api/series/{id}/follow` | `PUT/DELETE /api/v2/series/{id}/follow` |
|
||||
| `DELETE /api/series/{id}/follow` | `DELETE /api/v2/series/{id}/follow` |
|
||||
| `PUT /api/series/{id}` | `PATCH /api/v2/series/{id}` |
|
||||
| `DELETE /api/series/{id}` | `DELETE /api/v2/series/{id}` |
|
||||
| `GET /api/season-passes/mine` | `GET /api/v2/me/season-passes` |
|
||||
| `POST /api/season-passes/purchases/{id}/checkout` | `POST /api/v2/season-pass-purchases/{id}/checkout` |
|
||||
| `POST /api/season-passes/{id}/buy` | `POST /api/v2/season-passes/{id}/buy` |
|
||||
| `GET /api/season-passes` | `GET /api/v2/season-passes` |
|
||||
| `POST /api/season-passes` | `POST /api/v2/season-passes` |
|
||||
| `PUT /api/season-passes/{id}` | `PATCH /api/v2/season-passes/{id}` |
|
||||
| `DELETE /api/season-passes/{id}` | `DELETE /api/v2/season-passes/{id}` |
|
||||
| `POST /api/bundles/quote` | `PATCH/DELETE /api/v2/bundles/quote` |
|
||||
| `GET /api/bundles/event/{id}` | `GET /api/v2/events/{id}/bundles` |
|
||||
| `POST /api/bundles/event/{id}` | `POST /api/v2/events/{id}/bundles` |
|
||||
| `PUT /api/bundles/{id}` | `PATCH /api/v2/bundles/{id}` |
|
||||
| `DELETE /api/bundles/{id}` | `DELETE /api/v2/bundles/{id}` |
|
||||
| `POST /api/coupons/validate` | `GET/PATCH /api/v2/coupons/check` |
|
||||
| `GET /api/coupons/redemptions` | `GET /api/v2/coupons/redemptions` |
|
||||
| `GET /api/coupons` | `GET /api/v2/coupons` |
|
||||
| `POST /api/coupons` | `POST /api/v2/coupons` |
|
||||
| `GET /api/coupons/{id}` | `GET /api/v2/coupons/{id}` |
|
||||
| `PUT /api/coupons/{id}` | `PATCH /api/v2/coupons/{id}` |
|
||||
| `GET /api/campuses` | `GET /api/v2/campuses` |
|
||||
| `GET /api/campuses/admin` | `GET /api/v2/campuses/admin` |
|
||||
| `GET /api/campuses/by-slug/{id}` | `GET /api/v2/campuses/by-slug/{id}` |
|
||||
| `PUT /api/campuses/settings` | `PUT /api/v2/campuses/enabled` |
|
||||
| `PUT /api/campuses/order` | `PUT /api/v2/campuses/order` |
|
||||
| `POST /api/campuses` | `POST /api/v2/campuses` |
|
||||
| `GET /api/campuses/{id}/audience` | `GET /api/v2/campuses/{id}/audience` |
|
||||
| `PUT /api/campuses/{id}` | `PATCH /api/v2/campuses/{id}` |
|
||||
| `DELETE /api/campuses/{id}` | `DELETE /api/v2/campuses/{id}` |
|
||||
| `GET /api/users/profile` | `GET /api/v2/me` |
|
||||
| `PUT /api/users/profile` | `PATCH /api/v2/me` |
|
||||
| `POST /api/users` | `POST /api/v2/auth/signup` |
|
||||
| `POST /api/users/login` | `POST /api/v2/auth/login` |
|
||||
| `POST /api/users/login/2fa` | `POST /api/v2/auth/login/code` |
|
||||
| `POST /api/registrations` | `POST /api/v2/registrations` |
|
||||
| `DELETE /api/registrations/{id}` | `POST /api/v2/registrations/{id}/cancel` |
|
||||
| `POST /api/payments/checkout` | `POST /api/v2/registrations/{id}/checkout` |
|
||||
| `GET /api/tickets/scan-preview/{id}` | `GET /api/v2/checkin/{id}` |
|
||||
| `POST /api/tickets/scan/{id}` | `POST /api/v2/checkin/{id}` |
|
||||
File diff suppressed because it is too large
Load Diff
Generated
+233
-43
@@ -10,6 +10,7 @@
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@cj-tech-master/excelts": "^10.2.0",
|
||||
"@node-rs/argon2": "^2.2.2",
|
||||
"@prisma/adapter-pg": "^7.10.1",
|
||||
"@prisma/client": "^7.10.1",
|
||||
"@sentry/node": "^10.71.0",
|
||||
@@ -23,7 +24,6 @@
|
||||
"ics": "^3.12.0",
|
||||
"jsonwebtoken": "^9.0.3",
|
||||
"multer": "^2.5.0",
|
||||
"node-fetch": "^2.7.0",
|
||||
"nodemailer": "^10.3.0",
|
||||
"pdfkit": "^0.17.1",
|
||||
"pg-boss": "^11.1.2",
|
||||
@@ -1729,6 +1729,238 @@
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2/-/argon2-2.2.2.tgz",
|
||||
"integrity": "sha512-NtdlPPWtR5U4BxX5EGJYza+UklNaoWORmkaKCMqf/nyKeXWKVwNt8KfQoRpNT7OB1DcEwmePafO4wZyW+sbfCQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@node-rs/argon2-android-arm-eabi": "2.2.2",
|
||||
"@node-rs/argon2-android-arm64": "2.2.2",
|
||||
"@node-rs/argon2-darwin-arm64": "2.2.2",
|
||||
"@node-rs/argon2-darwin-x64": "2.2.2",
|
||||
"@node-rs/argon2-freebsd-x64": "2.2.2",
|
||||
"@node-rs/argon2-linux-arm-gnueabihf": "2.2.2",
|
||||
"@node-rs/argon2-linux-arm64-gnu": "2.2.2",
|
||||
"@node-rs/argon2-linux-arm64-musl": "2.2.2",
|
||||
"@node-rs/argon2-linux-x64-gnu": "2.2.2",
|
||||
"@node-rs/argon2-linux-x64-musl": "2.2.2",
|
||||
"@node-rs/argon2-win32-arm64-msvc": "2.2.2",
|
||||
"@node-rs/argon2-win32-ia32-msvc": "2.2.2",
|
||||
"@node-rs/argon2-win32-x64-msvc": "2.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-android-arm-eabi": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-android-arm-eabi/-/argon2-android-arm-eabi-2.2.2.tgz",
|
||||
"integrity": "sha512-c11BOrPLBWNC1cDyzGB+Bil+flmxfZbB2hv8EhcobmAsFKMyqkHPNhUY4qhcjv1U+4+Vmw4G8H+l224iO2g/Dw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-android-arm64": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-android-arm64/-/argon2-android-arm64-2.2.2.tgz",
|
||||
"integrity": "sha512-dpMYIoxhN/wY6hFH+3MM5kQErcH3luMekkszbkDF3NKqhB1kFRntkOLDpFY87oItBSHJrsoYkXC3vBRhjYoCjQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-darwin-arm64": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-darwin-arm64/-/argon2-darwin-arm64-2.2.2.tgz",
|
||||
"integrity": "sha512-vxVAXcIG0iiHizkCuImmzVhOFsRnU4Z79xiOxdISLyI+QhOAWbbTaVSXw0PNfThB3zAdkzzDJ/WWu52Hs/qHGg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-darwin-x64": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-darwin-x64/-/argon2-darwin-x64-2.2.2.tgz",
|
||||
"integrity": "sha512-r7GbSFpFZZ9EAV9cvIm9prUjOupK7QQXTyP+FJ6bWSMq0h+qRDBlUOXQXduDIIrLEGoBVelixKUtf4ksZ0ljoQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-freebsd-x64": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-freebsd-x64/-/argon2-freebsd-x64-2.2.2.tgz",
|
||||
"integrity": "sha512-AmWxDSmQgprilD6NX3jmxCgcDvWAW7kGJnnWQo+0qav6nfMXdPZYgSezK/skmw1GBWipr4yZMIUzpeNHnVpMxg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-linux-arm-gnueabihf": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-linux-arm-gnueabihf/-/argon2-linux-arm-gnueabihf-2.2.2.tgz",
|
||||
"integrity": "sha512-M1gnPBTr9GFeEUWkQ53qCJeTsX03C3kcUeHnDbN7dU2xkI58wMP4Z1sEBN7WmKJ/fTHYEgti4truz7r4A82DLg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-linux-arm64-gnu": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-linux-arm64-gnu/-/argon2-linux-arm64-gnu-2.2.2.tgz",
|
||||
"integrity": "sha512-4CYDlIdITlLSVcAXYUtEoGUahRaayPXM+4Rcfg3BZx9WGi6UB8HUycs6GNMTPYXV5kVXCpyE2u1HmYUpgmIzOQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-linux-arm64-musl": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-linux-arm64-musl/-/argon2-linux-arm64-musl-2.2.2.tgz",
|
||||
"integrity": "sha512-FYlfj3XgQ1xrx6HzQbKbUcKiYMG/3iSi/X81KyhHaItTJ7vZlMwrbVLl9yqDmvotKUF6VjrhrlZ8KRbbzchseA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-linux-x64-gnu": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-linux-x64-gnu/-/argon2-linux-x64-gnu-2.2.2.tgz",
|
||||
"integrity": "sha512-ULXLs8UFYZANlwiROM7AeccxZndr2Xk3IstADq3jAUhnwV2W75mxMBTABUZ+7AdKRhPLOrxU77OgnMWlDkYJQg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-linux-x64-musl": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-linux-x64-musl/-/argon2-linux-x64-musl-2.2.2.tgz",
|
||||
"integrity": "sha512-zgjIwc9TyGodn62vGc+36DGwFqVV5e7L8Ptd2FQWuBxe5aFrcFxvtDGn1/qfYwoHLv09utgtR+RBAPCXepWG3Q==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-win32-arm64-msvc": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-win32-arm64-msvc/-/argon2-win32-arm64-msvc-2.2.2.tgz",
|
||||
"integrity": "sha512-3nLhvLie/ec5xfxUBXXqGMb7oGeqF+YXrcGckqaTaGkPtOBozho0Kh2IuP/zi9BcOriirTG2LW3gtIOfpuh+mQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-win32-ia32-msvc": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-win32-ia32-msvc/-/argon2-win32-ia32-msvc-2.2.2.tgz",
|
||||
"integrity": "sha512-6RJKD6cFl7UeiYJLjRsXPywVXSFSaSDdr6xGpztNDV31QHCEecWnsnNmKxzi4gVpln2F9XeWEtIgM4Nqw1hLbA==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@node-rs/argon2-win32-x64-msvc": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@node-rs/argon2-win32-x64-msvc/-/argon2-win32-x64-msvc-2.2.2.tgz",
|
||||
"integrity": "sha512-dQOO9S4QKBaVul0Uyk/2quJc/OBeHNZRJP+GZZTy1A5kYIaAfIJGHUYLY6oFoAlcuLIkdFouLaHX3fCl8tZm/w==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@opentelemetry/api": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.1.tgz",
|
||||
@@ -7492,26 +7724,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/node-int64": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||
@@ -9096,12 +9308,6 @@
|
||||
"integrity": "sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ts-jest": {
|
||||
"version": "29.4.15",
|
||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.4.15.tgz",
|
||||
@@ -9421,22 +9627,6 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@cj-tech-master/excelts": "^10.2.0",
|
||||
"@node-rs/argon2": "^2.2.2",
|
||||
"@prisma/adapter-pg": "^7.10.1",
|
||||
"@prisma/client": "^7.10.1",
|
||||
"@sentry/node": "^10.71.0",
|
||||
@@ -35,7 +36,6 @@
|
||||
"ics": "^3.12.0",
|
||||
"jsonwebtoken": "^9.0.3",
|
||||
"multer": "^2.5.0",
|
||||
"node-fetch": "^2.7.0",
|
||||
"nodemailer": "^10.3.0",
|
||||
"pdfkit": "^0.17.1",
|
||||
"pg-boss": "^11.1.2",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
require('dotenv').config({ path: require('path').resolve(__dirname, '../.env') });
|
||||
const { createPrismaClient } = require('../src/config/db');
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { hashPassword } = require('../src/config/auth');
|
||||
|
||||
const prisma = createPrismaClient();
|
||||
|
||||
@@ -47,7 +47,7 @@ function randomPhone() {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const passwordHash = await bcrypt.hash('Demo@1234', 10);
|
||||
const passwordHash = await hashPassword('Demo@1234');
|
||||
|
||||
// Role distribution: ~55 user, ~15 staff, ~5 supervisor
|
||||
const rolePool = [
|
||||
|
||||
@@ -42,7 +42,7 @@ const readline = require('readline');
|
||||
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
|
||||
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { hashPassword } = require('../src/config/auth');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const { createPrismaClient } = require('../src/config/db');
|
||||
const { applyBundles } = require('../src/utils/bundles');
|
||||
@@ -1859,7 +1859,7 @@ async function main() {
|
||||
return;
|
||||
}
|
||||
|
||||
passwordHash = await bcrypt.hash(DEMO_PASSWORD, 10);
|
||||
passwordHash = await hashPassword(DEMO_PASSWORD);
|
||||
const people = buildPeople();
|
||||
if (profile.campuses) buildCampuses();
|
||||
const events = profile.upcoming.map(key => UPCOMING[key](people));
|
||||
|
||||
+8
-1374
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,6 @@
|
||||
const jwt = require('jsonwebtoken');
|
||||
const argon2 = require('@node-rs/argon2');
|
||||
// Only for checking passwords saved before 2.0 (they're re-hashed with Argon2id at the next sign-in).
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
// `extra` adds claims, e.g. { setup: true } for the first-run setup wizard's token.
|
||||
@@ -10,17 +12,30 @@ const generateToken = (userId, role, tokenVersion = 0, extra = {}) => {
|
||||
);
|
||||
};
|
||||
|
||||
const hashPassword = async (password) => {
|
||||
const salt = await bcrypt.genSalt(10);
|
||||
return await bcrypt.hash(password, salt);
|
||||
// Argon2id with OWASP's recommended minimum (19 MiB, 2 passes, 1 lane): about 20–40 ms a hash.
|
||||
const ARGON2 = { algorithm: 2 /* Argon2id (a const enum in the typings, so not on the module) */, memoryCost: 19456, timeCost: 2, parallelism: 1 };
|
||||
const ARGON2_PREFIX = `$argon2id$v=19$m=${ARGON2.memoryCost},t=${ARGON2.timeCost},p=${ARGON2.parallelism}$`;
|
||||
|
||||
const hashPassword = async (password) => argon2.hash(password, ARGON2);
|
||||
|
||||
/** Whether `entered` is the password behind `stored` (an Argon2 hash, or a bcrypt one from before 2.0). */
|
||||
const comparePassword = async (enteredPassword, storedPassword) => {
|
||||
if (typeof enteredPassword !== 'string' || typeof storedPassword !== 'string') return false;
|
||||
try {
|
||||
if (storedPassword.startsWith('$argon2')) return await argon2.verify(storedPassword, enteredPassword);
|
||||
if (/^\$2[aby]\$/.test(storedPassword)) return await bcrypt.compare(enteredPassword, storedPassword);
|
||||
} catch {
|
||||
// A malformed hash never matches.
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const comparePassword = async (enteredPassword, storedPassword) => {
|
||||
return await bcrypt.compare(enteredPassword, storedPassword);
|
||||
};
|
||||
/** True for a hash that isn't Argon2id with today's settings (bcrypt, or weaker Argon2). */
|
||||
const needsRehash = (storedPassword) => typeof storedPassword === 'string' && !storedPassword.startsWith(ARGON2_PREFIX);
|
||||
|
||||
module.exports = {
|
||||
generateToken,
|
||||
hashPassword,
|
||||
comparePassword,
|
||||
};
|
||||
needsRehash,
|
||||
};
|
||||
|
||||
@@ -10,38 +10,8 @@
|
||||
|
||||
const { licenceStatus } = require('./licence');
|
||||
|
||||
// v1 paths (until 2.0 removes them) and their /api/v2 successors (1.52.3: the screens have used v2
|
||||
// since 1.51.15, so without these a suspended or unlicensed site wasn't read-only any more).
|
||||
// /api/v2 only: 2.0 removed v1 (1.52.3 added these — the screens had used v2 since 1.51.15).
|
||||
const BLOCKED = [
|
||||
['POST', /^\/api\/events\/?$/],
|
||||
['PUT', /^\/api\/events\/[^/]+\/?$/],
|
||||
['POST', /^\/api\/events\/[^/]+\/copy-from\/?$/],
|
||||
['POST', /^\/api\/series\/?$/],
|
||||
['PUT', /^\/api\/series\/[^/]+\/?$/],
|
||||
// Season passes: new or changed passes, and buying one (it makes registrations and payments).
|
||||
['POST', /^\/api\/season-passes\/?$/],
|
||||
['PUT', /^\/api\/season-passes\/[^/]+\/?$/],
|
||||
['POST', /^\/api\/season-passes\/[^/]+\/buy\/?$/],
|
||||
['POST', /^\/api\/season-passes\/purchases\/[^/]+\/checkout\/?$/],
|
||||
['POST', /^\/api\/events\/[^/]+\/options\/?$/],
|
||||
['PUT', /^\/api\/events\/options\/[^/]+\/?$/],
|
||||
['POST', /^\/api\/events\/options\/[^/]+\/variants\/?$/],
|
||||
['PUT', /^\/api\/events\/variants\/[^/]+\/?$/],
|
||||
['POST', /^\/api\/registrations\/?$/],
|
||||
['POST', /^\/api\/registrations\/manual\/?$/],
|
||||
['PUT', /^\/api\/registrations\/[^/]+\/options\/?$/],
|
||||
['POST', /^\/api\/payments\/?$/],
|
||||
['POST', /^\/api\/payments\/(checkout|yoco-checkout)(\/send)?\/?$/],
|
||||
['POST', /^\/api\/payments\/pay\/[^/]+\/?$/],
|
||||
['POST', /^\/api\/waitlist\/?$/],
|
||||
['POST', /^\/api\/coupons\/?$/],
|
||||
['POST', /^\/api\/bundles\/event\/[^/]+\/?$/],
|
||||
// Volunteer rosters: new roles and new people on them (they can carry a free ticket).
|
||||
['POST', /^\/api\/volunteers\/roles\/[^/]+\/sign-up\/?$/],
|
||||
['POST', /^\/api\/volunteers\/manage\/events\/[^/]+\/roles\/?$/],
|
||||
['POST', /^\/api\/volunteers\/manage\/roles\/[^/]+\/assign\/?$/],
|
||||
|
||||
// /api/v2 — the same actions.
|
||||
['POST', /^\/api\/v2\/events\/?$/],
|
||||
['PATCH', /^\/api\/v2\/events\/[^/]+\/?$/],
|
||||
['POST', /^\/api\/v2\/events\/[^/]+\/copy-from\/?$/],
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { listAuditLog } = require('../controllers/adminAuditController');
|
||||
const { startImpersonation, endImpersonation, logPageView, currentImpersonation, listSessions } = require('../controllers/impersonationController');
|
||||
const { listJobs, runJobNow } = require('../controllers/jobsController');
|
||||
const { protect, admin } = require('../middleware/authMiddleware');
|
||||
|
||||
router.get('/audit-log', protect, admin, listAuditLog);
|
||||
router.get('/jobs', protect, admin, listJobs);
|
||||
router.post('/jobs/:name/run', protect, admin, runJobNow);
|
||||
router.get('/impersonation-sessions', protect, admin, listSessions);
|
||||
// Called with the impersonation token itself (which belongs to the viewed user).
|
||||
router.post('/impersonate/end', protect, endImpersonation);
|
||||
router.post('/impersonate/log', protect, logPageView);
|
||||
router.get('/impersonate/current', protect, currentImpersonation);
|
||||
router.post('/impersonate/:userId', protect, admin, startImpersonation);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,23 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
getBoard, createSet, updateSet, deleteSet, createGroup, updateGroup, deleteGroup,
|
||||
assign, autoAssign, clearAssignments, getSetLists, getMyGroups,
|
||||
} = require('../controllers/allocationController');
|
||||
const { protect, staff, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, campusIndependent } = require('../utils/campusScope');
|
||||
|
||||
router.get('/my-groups', protect, staff, campusIndependent('only the groups the signed-in person leads'), getMyGroups);
|
||||
router.get('/event/:eventId', protect, supervisor, scopeEvent(), getBoard);
|
||||
router.post('/sets', protect, supervisor, scopeEvent({ from: req => req.body?.eventId }), createSet);
|
||||
router.put('/sets/:id', protect, supervisor, scopeEvent({ resolve: 'allocationSet' }), updateSet);
|
||||
router.delete('/sets/:id', protect, supervisor, scopeEvent({ resolve: 'allocationSet' }), deleteSet);
|
||||
router.get('/sets/:id/lists', protect, supervisor, scopeEvent({ resolve: 'allocationSet' }), getSetLists);
|
||||
router.post('/sets/:id/groups', protect, supervisor, scopeEvent({ resolve: 'allocationSet' }), createGroup);
|
||||
router.put('/sets/:id/assignments', protect, supervisor, scopeEvent({ resolve: 'allocationSet' }), assign);
|
||||
router.delete('/sets/:id/assignments', protect, supervisor, scopeEvent({ resolve: 'allocationSet' }), clearAssignments);
|
||||
router.post('/sets/:id/auto', protect, supervisor, scopeEvent({ resolve: 'allocationSet' }), autoAssign);
|
||||
router.put('/groups/:id', protect, supervisor, scopeEvent({ resolve: 'allocationGroup' }), updateGroup);
|
||||
router.delete('/groups/:id', protect, supervisor, scopeEvent({ resolve: 'allocationGroup' }), deleteGroup);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,19 +0,0 @@
|
||||
const express = require('express');
|
||||
const rateLimit = require('express-rate-limit');
|
||||
const router = express.Router();
|
||||
const { trackStage, getFunnel } = require('../controllers/analyticsController');
|
||||
const { protect, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeList } = require('../utils/campusScope');
|
||||
|
||||
const trackLimiter = rateLimit({
|
||||
windowMs: 60 * 1000,
|
||||
max: 60,
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
handler: (req, res) => res.status(204).end(), // silently drop floods
|
||||
});
|
||||
|
||||
router.post('/track', trackLimiter, trackStage);
|
||||
router.get('/funnel', protect, supervisor, scopeList, getFunnel);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,26 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
getRegister, markAttendance, exportRegister,
|
||||
issueCertificates, revokeCertificate, sendCertificatesHandler, downloadEventCertificates, previewCertificate,
|
||||
myCertificates, downloadCertificate, verifyCertificate,
|
||||
} = require('../controllers/attendanceController');
|
||||
const { protect, staff, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, campusIndependent } = require('../utils/campusScope');
|
||||
|
||||
// Certificates — fixed paths first so they aren't taken as an :eventId
|
||||
router.get('/certificates/verify/:code', verifyCertificate);
|
||||
router.get('/certificates/mine', protect, myCertificates);
|
||||
router.post('/certificates/preview', protect, supervisor, campusIndependent('previews a certificate template from the request body'), previewCertificate);
|
||||
router.get('/certificates/:id/pdf', protect, downloadCertificate);
|
||||
router.post('/certificates/:id/revoke', protect, supervisor, scopeEvent({ resolve: 'certificate' }), revokeCertificate);
|
||||
|
||||
// Attendance register
|
||||
router.get('/:eventId', protect, staff, scopeEvent(), getRegister);
|
||||
router.get('/:eventId/export', protect, staff, scopeEvent(), exportRegister);
|
||||
router.post('/:eventId/mark', protect, supervisor, scopeEvent(), markAttendance);
|
||||
router.post('/:eventId/certificates', protect, supervisor, scopeEvent(), issueCertificates);
|
||||
router.post('/:eventId/certificates/send', protect, supervisor, scopeEvent(), sendCertificatesHandler);
|
||||
router.get('/:eventId/certificates.pdf', protect, supervisor, scopeEvent(), downloadEventCertificates);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,10 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { scheduleAutomations } = require('../controllers/automationController');
|
||||
const { protect, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent } = require('../utils/campusScope');
|
||||
|
||||
// Schedule multiple automation emails for an event
|
||||
router.post('/schedule', protect, supervisor, scopeEvent({ from: req => req.body?.eventId }), scheduleAutomations);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,10 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getBackups, triggerBackup, downloadBackup } = require('../controllers/backupController');
|
||||
const { protect, admin } = require('../middleware/authMiddleware');
|
||||
|
||||
router.get('/', protect, admin, getBackups);
|
||||
router.post('/run', protect, admin, triggerBackup);
|
||||
router.get('/:filename/download', protect, admin, downloadBackup);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,10 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getBanner, setBanner } = require('../controllers/bannerController');
|
||||
const { protect, supervisor } = require('../middleware/authMiddleware');
|
||||
const { unscopedOnly } = require('../utils/campusScope');
|
||||
|
||||
router.get('/', getBanner);
|
||||
router.post('/', protect, supervisor, unscopedOnly, setBanner);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,12 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { previewBroadcast, sendBroadcast, scheduleBroadcast } = require('../controllers/broadcastController');
|
||||
const { protect, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeBroadcast } = require('../utils/campusScope');
|
||||
|
||||
// All routes require supervisor (or admin via middleware logic) access
|
||||
router.post('/preview', protect, supervisor, scopeBroadcast({ freeformField: 'emails' }), previewBroadcast);
|
||||
router.post('/send', protect, supervisor, scopeBroadcast({ freeformField: 'emails' }), sendBroadcast);
|
||||
router.post('/schedule', protect, supervisor, scopeBroadcast({ freeformField: 'emails' }), scheduleBroadcast);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,15 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { listBundles, createBundle, updateBundle, deleteBundle, quoteBundles } = require('../controllers/bundleController');
|
||||
const { protect, supervisor, optionalAuth } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent } = require('../utils/campusScope');
|
||||
|
||||
// What a basket gets off before registering (guests included)
|
||||
router.post('/quote', optionalAuth, quoteBundles);
|
||||
|
||||
router.get('/event/:eventId', protect, supervisor, scopeEvent(), listBundles);
|
||||
router.post('/event/:eventId', protect, supervisor, scopeEvent({ need: 'manage' }), createBundle);
|
||||
router.put('/:id', protect, supervisor, scopeEvent({ resolve: 'bundle', need: 'manage' }), updateBundle);
|
||||
router.delete('/:id', protect, supervisor, scopeEvent({ resolve: 'bundle', need: 'manage' }), deleteBundle);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,21 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
getCampuses, getCampusBySlug, getCampusesAdmin, updateCampusSettings, createCampus, updateCampus, reorderCampuses, deleteCampus,
|
||||
getCampusAudience,
|
||||
} = require('../controllers/campusController');
|
||||
const { protect, admin, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeList } = require('../utils/campusScope');
|
||||
|
||||
// Multi-campus (utils/campuses.js). The public list is empty while campuses are off.
|
||||
router.get('/', getCampuses);
|
||||
router.get('/by-slug/:slug', getCampusBySlug);
|
||||
router.get('/admin', protect, admin, getCampusesAdmin);
|
||||
router.put('/settings', protect, admin, updateCampusSettings);
|
||||
router.put('/order', protect, admin, reorderCampuses);
|
||||
router.post('/', protect, admin, createCampus);
|
||||
router.put('/:id', protect, admin, updateCampus);
|
||||
router.delete('/:id', protect, admin, deleteCampus);
|
||||
router.get('/:id/audience', protect, supervisor, scopeList, getCampusAudience);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,16 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getEventCashup, getCashByRecordedUser, savePersonCash, saveEventCashupDraft, closeEvent, reopenEvent, resolvePending, getCashupAudit } = require('../controllers/cashupController');
|
||||
const { protect, supervisor, admin } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeList } = require('../utils/campusScope');
|
||||
|
||||
router.get('/audit', protect, supervisor, scopeList, getCashupAudit);
|
||||
router.get('/event/:eventId', protect, supervisor, scopeEvent({ need: 'manage' }), getEventCashup);
|
||||
router.get('/event/:eventId/cash-by-user', protect, supervisor, scopeEvent({ need: 'manage' }), getCashByRecordedUser);
|
||||
router.put('/event/:eventId/person-cash/:userId', protect, supervisor, scopeEvent({ need: 'manage' }), savePersonCash);
|
||||
router.put('/event/:eventId/draft', protect, admin, saveEventCashupDraft);
|
||||
router.post('/event/:eventId/close', protect, admin, closeEvent);
|
||||
router.post('/event/:eventId/reopen', protect, admin, reopenEvent);
|
||||
router.post('/lines/:lineId/pending', protect, admin, resolvePending);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,21 +0,0 @@
|
||||
const express = require('express');
|
||||
const rateLimit = require('express-rate-limit');
|
||||
const router = express.Router();
|
||||
const { getConsent, answerConsent, listEventConsent, resendRequest, resendPending, rerequestConsent, medicalList } = require('../controllers/consentController');
|
||||
const { protect, staff, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent } = require('../utils/campusScope');
|
||||
|
||||
// The token in the link is the parent's only credential, so keep guessing slow.
|
||||
const consentLimiter = rateLimit({ windowMs: 60 * 1000, max: 30, message: { message: 'Too many attempts. Please try again in a minute.' } });
|
||||
|
||||
router.get('/events/:eventId', protect, staff, scopeEvent(), listEventConsent);
|
||||
router.post('/events/:eventId/resend-pending', protect, supervisor, scopeEvent(), resendPending);
|
||||
router.post('/events/:eventId/rerequest', protect, supervisor, scopeEvent(), rerequestConsent);
|
||||
router.get('/events/:eventId/medical', protect, supervisor, scopeEvent(), medicalList);
|
||||
router.post('/requests/:id/resend', protect, scopeEvent({ resolve: 'consentRequest', ownerOk: true }), resendRequest);
|
||||
|
||||
// Public consent page
|
||||
router.get('/:token', consentLimiter, getConsent);
|
||||
router.post('/:token', consentLimiter, answerConsent);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,13 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getEventCosts, createEventCost, updateEventCost, deleteEventCost } = require('../controllers/costController');
|
||||
const { protect, supervisor, admin } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent } = require('../utils/campusScope');
|
||||
|
||||
// Mounted at /api — paths below match the documented /api/events/:eventId/costs and /api/costs/:id shape
|
||||
router.get('/events/:eventId/costs', protect, supervisor, scopeEvent({ need: 'manage' }), getEventCosts);
|
||||
router.post('/events/:eventId/costs', protect, admin, createEventCost);
|
||||
router.put('/costs/:id', protect, admin, updateEventCost);
|
||||
router.delete('/costs/:id', protect, admin, deleteEventCost);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,16 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { listCoupons, getCoupon, createCoupon, updateCoupon, validateCode, listRedemptions } = require('../controllers/couponController');
|
||||
const { protect, supervisor, optionalAuth } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeList } = require('../utils/campusScope');
|
||||
|
||||
// Check a code against a basket before registering (guests included)
|
||||
router.post('/validate', optionalAuth, scopeEvent({ from: req => req.body?.eventId }), validateCode);
|
||||
|
||||
router.get('/', protect, supervisor, scopeList, listCoupons);
|
||||
router.post('/', protect, supervisor, scopeList, createCoupon);
|
||||
router.get('/redemptions', protect, supervisor, scopeList, listRedemptions);
|
||||
router.get('/:id', protect, supervisor, scopeList, getCoupon);
|
||||
router.put('/:id', protect, supervisor, scopeList, updateCoupon);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,93 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
createEvent,
|
||||
copyEventSetupFrom,
|
||||
getEvents,
|
||||
getAllEvents,
|
||||
getEventsAll,
|
||||
getEventById,
|
||||
getEventIcs,
|
||||
updateEvent,
|
||||
getEventNotifyRecipients,
|
||||
updateEventNotifyRecipients,
|
||||
deleteEvent,
|
||||
createEventOption,
|
||||
updateEventOption,
|
||||
deleteEventOption,
|
||||
createOptionVariant,
|
||||
updateOptionVariant,
|
||||
deleteOptionVariant,
|
||||
listEventAttachments,
|
||||
uploadEventAttachment,
|
||||
deleteEventAttachment,
|
||||
attachmentsStatus,
|
||||
attachmentsSync,
|
||||
emailEventAttendees,
|
||||
scheduleEmailEventAttendees,
|
||||
whatsappEventAttendees,
|
||||
scheduleWhatsappEventAttendees,
|
||||
getEventByAlias
|
||||
} = require('../controllers/eventController');
|
||||
const { protect, admin, supervisor, optionalAuth } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeBody, scopeList } = require('../utils/campusScope');
|
||||
|
||||
// Public routes
|
||||
router.get('/', getEvents);
|
||||
|
||||
// Staff/supervisor/admin: all events including hidden, optional past/inactive filters
|
||||
router.get('/all', protect, getEventsAll);
|
||||
|
||||
// Admin routes
|
||||
router.get('/admin/all', protect, admin, getAllEvents);
|
||||
router.get('/attachments/status', protect, admin, attachmentsStatus);
|
||||
router.post('/attachments/sync', protect, admin, attachmentsSync);
|
||||
|
||||
// Public route for single event (keep after specific admin routes).
|
||||
// optionalAuth populates req.user when a valid token is present so staff/supervisor/admin
|
||||
// can still load inactive events (e.g. for cashup or editing) without being 404'd.
|
||||
router.get('/:id', optionalAuth, getEventById);
|
||||
router.get('/:id/ics', optionalAuth, getEventIcs);
|
||||
router.get('/by-alias/:redirectUrl', getEventByAlias);
|
||||
|
||||
// Create/Update/Delete event
|
||||
router.post('/', protect, supervisor, scopeList, createEvent);
|
||||
router.route('/:id')
|
||||
.put(protect, supervisor, scopeEvent({ need: 'manage' }), updateEvent)
|
||||
.delete(protect, admin, deleteEvent);
|
||||
|
||||
// Clone: copy allocation groups (and costs, for admins) from the source event into a new copy.
|
||||
router.post('/:id/copy-from', protect, supervisor, scopeEvent({ need: 'manage' }), scopeBody([['fromEventId', 'event']]), copyEventSetupFrom);
|
||||
|
||||
// Notification recipients: who gets registration/payment/daily-summary emails for this event
|
||||
router.route('/:id/notify-recipients')
|
||||
.get(protect, supervisor, scopeEvent(), getEventNotifyRecipients)
|
||||
.put(protect, supervisor, scopeEvent({ need: 'manage' }), updateEventNotifyRecipients);
|
||||
|
||||
// Attachments routes
|
||||
router.get('/:id/attachments', listEventAttachments); // public read (used by event detail page)
|
||||
router.post('/:id/attachments', protect, supervisor, scopeEvent({ need: 'manage' }), ...uploadEventAttachment);
|
||||
router.delete('/:eventId/attachments/:attachmentId', protect, supervisor, scopeEvent({ need: 'manage' }), deleteEventAttachment);
|
||||
|
||||
// Bulk email attendees
|
||||
router.post('/:id/email-attendees', protect, supervisor, scopeEvent(), emailEventAttendees);
|
||||
// Schedule bulk email to attendees
|
||||
router.post('/:id/email-attendees/schedule', protect, supervisor, scopeEvent(), scheduleEmailEventAttendees);
|
||||
// Bulk WhatsApp message to attendees
|
||||
router.post('/:id/whatsapp-attendees', protect, supervisor, scopeEvent(), whatsappEventAttendees);
|
||||
// Schedule bulk WhatsApp message to attendees
|
||||
router.post('/:id/whatsapp-attendees/schedule', protect, supervisor, scopeEvent(), scheduleWhatsappEventAttendees);
|
||||
|
||||
// Event options routes
|
||||
router.post('/:id/options', protect, supervisor, scopeEvent({ need: 'manage' }), createEventOption);
|
||||
router.route('/options/:id')
|
||||
.put(protect, supervisor, scopeEvent({ resolve: 'eventOption', need: 'manage' }), updateEventOption)
|
||||
.delete(protect, admin, deleteEventOption);
|
||||
|
||||
// Option variant routes
|
||||
router.post('/options/:id/variants', protect, supervisor, scopeEvent({ resolve: 'eventOption', need: 'manage' }), createOptionVariant);
|
||||
router.route('/variants/:id')
|
||||
.put(protect, supervisor, scopeEvent({ resolve: 'optionVariant', need: 'manage' }), updateOptionVariant)
|
||||
.delete(protect, admin, deleteOptionVariant);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,15 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getEventFeedback, saveEventFeedback, deleteEventFeedback, sendNow, getPublicForm, submitPublicForm, getSummary } = require('../controllers/feedbackController');
|
||||
const { protect, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeList } = require('../utils/campusScope');
|
||||
|
||||
router.get('/public/:token', getPublicForm);
|
||||
router.post('/public/:token', submitPublicForm);
|
||||
router.get('/summary', protect, supervisor, scopeList, getSummary);
|
||||
router.get('/event/:eventId', protect, supervisor, scopeEvent(), getEventFeedback);
|
||||
router.put('/event/:eventId', protect, supervisor, scopeEvent({ need: 'manage' }), saveEventFeedback);
|
||||
router.delete('/event/:eventId', protect, supervisor, scopeEvent({ need: 'manage' }), deleteEventFeedback);
|
||||
router.post('/event/:eventId/send-now', protect, supervisor, scopeEvent({ need: 'manage' }), sendNow);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,10 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { listFormResponses } = require('../controllers/formController');
|
||||
const { protect, staff } = require('../middleware/authMiddleware');
|
||||
const { scopeList } = require('../utils/campusScope');
|
||||
|
||||
// Staff or higher can view submitted forms
|
||||
router.get('/responses', protect, staff, scopeList, listFormResponses);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,18 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getStatus, connect, heartbeatNow, requestUpdate, cancelUpdateRequest, snoozeUpdate, getNotices } = require('../controllers/hubController');
|
||||
const { protect, admin, supervisor } = require('../middleware/authMiddleware');
|
||||
const { campusIndependent } = require('../utils/campusScope');
|
||||
|
||||
// Licence and the Cross Events Hub (docs/hub-protocol.md). Admins only; the setup wizard's
|
||||
// admin token counts, so the licence step can run during /setup.
|
||||
router.get('/status', protect, admin, getStatus);
|
||||
router.post('/connect', protect, admin, connect);
|
||||
router.post('/heartbeat', protect, admin, heartbeatNow);
|
||||
router.post('/update-request', protect, admin, requestUpdate);
|
||||
router.post('/update-request/cancel', protect, admin, cancelUpdateRequest);
|
||||
router.post('/update-snooze', protect, admin, snoozeUpdate);
|
||||
// The provider's notices: site admins and supervisors see them as a banner.
|
||||
router.get('/notices', protect, supervisor, campusIndependent('notices from the provider are for the whole site'), getNotices);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,47 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const c = require('../controllers/kidsController');
|
||||
const { protect, staff, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeList } = require('../utils/campusScope');
|
||||
|
||||
// My account → Kids (any signed-in parent; only their own family)
|
||||
router.get('/me', protect, c.getMine);
|
||||
router.post('/me', protect, c.createMine);
|
||||
router.put('/me', protect, c.renameMine);
|
||||
router.delete('/me', protect, c.leaveMine);
|
||||
router.post('/me/children', protect, c.saveMyChild);
|
||||
router.put('/me/children/:id', protect, c.saveMyChild);
|
||||
router.delete('/me/children/:id', protect, c.deleteMyChild);
|
||||
router.post('/me/adults', protect, c.saveMyAdult);
|
||||
router.put('/me/adults/:id', protect, c.saveMyAdult);
|
||||
router.delete('/me/adults/:id', protect, c.deleteMyAdult);
|
||||
|
||||
// Setup (supervisors)
|
||||
router.get('/setup-events', protect, supervisor, scopeList, c.setupEvents);
|
||||
router.get('/events/:eventId/settings', protect, supervisor, scopeEvent(), c.getSettings);
|
||||
router.put('/events/:eventId/settings', protect, supervisor, scopeEvent({ need: 'manage' }), c.saveSettings);
|
||||
|
||||
// The desk and the rooms (staff). Families are church-wide; staff reach them through an event
|
||||
// they can work on.
|
||||
router.get('/events', protect, staff, scopeList, c.listEvents);
|
||||
router.get('/events/:eventId/board', protect, staff, scopeEvent(), c.getBoard);
|
||||
router.get('/events/:eventId/families', protect, staff, scopeEvent(), c.searchFamilies);
|
||||
router.post('/events/:eventId/families', protect, staff, scopeEvent(), c.createFamilyAtDesk);
|
||||
router.get('/events/:eventId/families/qr/:token', protect, staff, scopeEvent(), c.familyByQr);
|
||||
router.get('/events/:eventId/families/:familyId', protect, staff, scopeEvent(), c.getFamily);
|
||||
router.post('/events/:eventId/families/:familyId/parents', protect, staff, scopeEvent(), c.addParentAtDesk);
|
||||
router.post('/events/:eventId/families/:familyId/children', protect, staff, scopeEvent(), c.saveChildAtDesk);
|
||||
router.put('/events/:eventId/families/:familyId/children/:childId', protect, staff, scopeEvent(), c.saveChildAtDesk);
|
||||
router.post('/events/:eventId/families/:familyId/adults', protect, staff, scopeEvent(), c.addAdultAtDesk);
|
||||
router.post('/events/:eventId/check-in', protect, staff, scopeEvent(), c.checkIn);
|
||||
router.post('/events/:eventId/check-out', protect, staff, scopeEvent(), c.checkOut);
|
||||
router.get('/events/:eventId/code/:code', protect, staff, scopeEvent(), c.lookupCode);
|
||||
router.post('/events/:eventId/duty', protect, staff, scopeEvent(), c.setDuty);
|
||||
router.get('/events/:eventId/offline', protect, staff, scopeEvent(), c.offlineSnapshot);
|
||||
router.post('/events/:eventId/sync', protect, staff, scopeEvent(), c.syncOffline);
|
||||
router.post('/check-ins/:id/override', protect, staff, scopeEvent({ resolve: 'kidsCheckIn' }), c.overrideCheckOut);
|
||||
router.post('/check-ins/:id/page', protect, staff, scopeEvent({ resolve: 'kidsCheckIn' }), c.pageParent);
|
||||
router.put('/check-ins/:id/room', protect, staff, scopeEvent({ resolve: 'kidsCheckIn' }), c.moveRoom);
|
||||
router.post('/alerts/:id/resolve', protect, staff, scopeEvent({ resolve: 'kidsAlert' }), c.resolveAlert);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,17 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { list, create, update, remove, rotateSecret, test, deliveries, resend } = require('../controllers/outboundWebhookController');
|
||||
const { protect, admin } = require('../middleware/authMiddleware');
|
||||
|
||||
// Outbound webhooks (1.48.0): admins only. Payment provider webhooks *into* the site are /api/webhooks/<provider>.
|
||||
router.use(protect, admin);
|
||||
router.get('/', list);
|
||||
router.post('/', create);
|
||||
router.post('/deliveries/:id/resend', resend);
|
||||
router.put('/:id', update);
|
||||
router.delete('/:id', remove);
|
||||
router.post('/:id/rotate-secret', rotateSecret);
|
||||
router.post('/:id/test', test);
|
||||
router.get('/:id/deliveries', deliveries);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,10 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getConfig, updateConfig, testConnection } = require('../controllers/payfastController');
|
||||
const { protect, admin } = require('../middleware/authMiddleware');
|
||||
|
||||
router.get('/config', protect, admin, getConfig);
|
||||
router.put('/config', protect, admin, updateConfig);
|
||||
router.post('/test', protect, admin, testConnection);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,54 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
createPayment,
|
||||
getPayments,
|
||||
getUserPayments,
|
||||
getPaymentById,
|
||||
getPaymentsByRegistration,
|
||||
getPaymentsByEvent,
|
||||
assignDonationToRegistration,
|
||||
unassignDonationFromRegistration,
|
||||
createCheckout,
|
||||
sendPaymentLink,
|
||||
createRefund,
|
||||
getPaymentStats,
|
||||
sendReceipt,
|
||||
} = require('../controllers/paymentController');
|
||||
const { listPaymentProviders, getPaymentProviderSettings, updatePaymentProviderSettings, getPayPage, choosePayProvider, listOpenCheckouts, checkCheckoutStatus } = require('../controllers/paymentProvidersController');
|
||||
const { protect, supervisor, staff, admin} = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeBody, scopeList, unscopedOnly } = require('../utils/campusScope');
|
||||
|
||||
// Campus-scoped staff: payments follow their registration's or event's campus. Door payments for
|
||||
// church-wide events are allowed; refunds of them aren't (need 'manage'); a payment or donation
|
||||
// not linked to any event is for admins and unscoped supervisors (orphan 'deny').
|
||||
const paymentTarget = scopeBody([['registrationId', 'registration'], ['eventId', 'event']], { orphan: 'deny' });
|
||||
|
||||
// Protected routes
|
||||
router.post('/', protect, supervisor, paymentTarget, createPayment);
|
||||
router.get('/providers', listPaymentProviders);
|
||||
router.get('/pay/:id', getPayPage);
|
||||
router.post('/pay/:id', choosePayProvider);
|
||||
router.get('/checkouts/open', protect, supervisor, unscopedOnly, listOpenCheckouts);
|
||||
router.post('/checkouts/check', protect, supervisor, unscopedOnly, checkCheckoutStatus);
|
||||
router.get('/providers/settings', protect, admin, getPaymentProviderSettings);
|
||||
router.put('/providers/settings', protect, admin, updatePaymentProviderSettings);
|
||||
router.post('/checkout', protect, createCheckout);
|
||||
router.post('/checkout/send', protect, supervisor, scopeBody([['registrationId', 'registration']]), sendPaymentLink);
|
||||
// Older names, kept for existing clients
|
||||
router.post('/yoco-checkout', protect, createCheckout);
|
||||
router.post('/yoco-checkout/send', protect, supervisor, scopeBody([['registrationId', 'registration']]), sendPaymentLink);
|
||||
router.get('/mypayments', protect, getUserPayments);
|
||||
router.post('/:id/send-receipt', protect, scopeEvent({ resolve: 'payment', ownerOk: true }), sendReceipt);
|
||||
router.get('/:id', protect, scopeEvent({ resolve: 'payment', ownerOk: true }), getPaymentById);
|
||||
router.get('/registration/:registrationId', protect, scopeEvent({ resolve: 'registration', from: req => req.params.registrationId, ownerOk: true }), getPaymentsByRegistration);
|
||||
|
||||
// Admin/Staff routes
|
||||
router.get('/', protect, supervisor, scopeList, getPayments);
|
||||
router.get('/event/:eventId', protect, staff, scopeEvent(), getPaymentsByEvent);
|
||||
router.put('/assign-donation', protect, supervisor, scopeBody([['paymentId', 'payment']], { orphan: 'deny' }), scopeBody([['registrationId', 'registration']]), assignDonationToRegistration);
|
||||
router.post('/unassign-donation', protect, supervisor, scopeBody([['legId', 'payment']], { orphan: 'deny' }), unassignDonationFromRegistration);
|
||||
router.post('/refund', protect, supervisor, scopeBody([['paymentId', 'payment'], ['registrationId', 'registration']], { need: 'manage', orphan: 'deny' }), createRefund);
|
||||
router.get('/admin/stats', protect, admin, getPaymentStats);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,87 +0,0 @@
|
||||
const express = require('express');
|
||||
const rateLimit = require('express-rate-limit');
|
||||
const router = express.Router();
|
||||
const {
|
||||
getMyPrivacy,
|
||||
updateMyNews,
|
||||
exportMyData,
|
||||
createMyRequest,
|
||||
getUnsubscribe,
|
||||
postUnsubscribe,
|
||||
oneClickUnsubscribe,
|
||||
oneClickRedirect,
|
||||
listRequests,
|
||||
completeRequest,
|
||||
rejectRequest,
|
||||
} = require('../controllers/privacyController');
|
||||
const {
|
||||
getNotice,
|
||||
acceptMyNotice,
|
||||
getNoticeDraft,
|
||||
saveNoticeDraft,
|
||||
discardNoticeDraft,
|
||||
publishNotice,
|
||||
markBuiltInReviewed,
|
||||
listOperators,
|
||||
createOperator,
|
||||
updateOperator,
|
||||
deleteOperator,
|
||||
consentLog,
|
||||
accessLog,
|
||||
getReadiness,
|
||||
getRetention,
|
||||
saveRetention,
|
||||
runRetentionNow,
|
||||
listBreaches,
|
||||
createBreach,
|
||||
updateBreach,
|
||||
} = require('../controllers/privacyAdminController');
|
||||
const { protect, admin } = require('../middleware/authMiddleware');
|
||||
|
||||
// Exports are heavy-ish (every record the person has) — a few per 10 minutes is plenty.
|
||||
const exportLimiter = rateLimit({ windowMs: 10 * 60 * 1000, max: 10, standardHeaders: true, legacyHeaders: false });
|
||||
|
||||
// The person themselves
|
||||
router.get('/me', protect, getMyPrivacy);
|
||||
router.put('/me/news', protect, updateMyNews);
|
||||
router.get('/me/export', protect, exportLimiter, exportMyData);
|
||||
router.post('/me/requests', protect, createMyRequest);
|
||||
|
||||
// Unsubscribe links (signed tokens, no login)
|
||||
router.get('/unsubscribe/:token', getUnsubscribe);
|
||||
router.post('/unsubscribe/:token', postUnsubscribe);
|
||||
router.get('/unsubscribe/:token/one-click', oneClickRedirect);
|
||||
router.post('/unsubscribe/:token/one-click', express.urlencoded({ extended: false }), oneClickUnsubscribe);
|
||||
|
||||
// Admin: data requests inbox
|
||||
router.get('/requests', protect, admin, listRequests);
|
||||
router.post('/requests/:id/complete', protect, admin, completeRequest);
|
||||
router.post('/requests/:id/reject', protect, admin, rejectRequest);
|
||||
|
||||
// Privacy notice: public reading, acceptance, and the admin editor
|
||||
router.get('/notice', getNotice);
|
||||
router.post('/me/notice/accept', protect, acceptMyNotice);
|
||||
router.get('/notice/draft', protect, admin, getNoticeDraft);
|
||||
router.put('/notice/draft', protect, admin, saveNoticeDraft);
|
||||
router.delete('/notice/draft', protect, admin, discardNoticeDraft);
|
||||
router.post('/notice/publish', protect, admin, publishNotice);
|
||||
router.post('/notice/builtin-reviewed', protect, admin, markBuiltInReviewed);
|
||||
|
||||
// Admin: operator register, consent log, access log
|
||||
router.get('/operators', protect, admin, listOperators);
|
||||
router.post('/operators', protect, admin, createOperator);
|
||||
router.put('/operators/:id', protect, admin, updateOperator);
|
||||
router.delete('/operators/:id', protect, admin, deleteOperator);
|
||||
router.get('/consent-log', protect, admin, consentLog);
|
||||
router.get('/access-log', protect, admin, accessLog);
|
||||
|
||||
// Admin: readiness, retention, breach register
|
||||
router.get('/readiness', protect, admin, getReadiness);
|
||||
router.get('/retention', protect, admin, getRetention);
|
||||
router.put('/retention', protect, admin, saveRetention);
|
||||
router.post('/retention/run', protect, admin, runRetentionNow);
|
||||
router.get('/breaches', protect, admin, listBreaches);
|
||||
router.post('/breaches', protect, admin, createBreach);
|
||||
router.put('/breaches/:id', protect, admin, updateBreach);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,21 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getAllProviderTransactions, getUnreconciledProviderTransactions, reconcileProviderTransaction, ignoreProviderTransaction } = require('../controllers/providerTransactionsController');
|
||||
const { protect, supervisor} = require('../middleware/authMiddleware');
|
||||
const { unscopedOnly } = require('../utils/campusScope');
|
||||
|
||||
// Mounted at /api/provider-transactions (and /api/yoco-transactions, the older name).
|
||||
|
||||
// GET all payment provider transactions (admin/supervisor)
|
||||
router.get('/', protect, supervisor, unscopedOnly, getAllProviderTransactions);
|
||||
|
||||
// GET all unreconciled transactions (admin/supervisor)
|
||||
router.get('/unreconciled', protect, supervisor, unscopedOnly, getUnreconciledProviderTransactions);
|
||||
|
||||
// POST reconcile a transaction
|
||||
router.post('/:id/reconcile', protect, supervisor, unscopedOnly, reconcileProviderTransaction);
|
||||
|
||||
// POST ignore a transaction
|
||||
router.post('/:id/ignore', protect, supervisor, unscopedOnly, ignoreProviderTransaction);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,54 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
createRegistration,
|
||||
getRegistrations,
|
||||
getUserRegistrations,
|
||||
getRegistrationById,
|
||||
updateRegistrationStatus,
|
||||
cancelRegistration,
|
||||
getRegistrationsByEvent,
|
||||
createManualRegistration,
|
||||
updateRegistrationOptions,
|
||||
submitFormResponses, replaceFormResponses,
|
||||
getFormDraft, saveFormDraft,
|
||||
sendInvoice,
|
||||
applyCoupon, removeCoupon,
|
||||
updateAttendees, sendAttendeeFormLink,
|
||||
} = require('../controllers/registrationController');
|
||||
const { protect, supervisor, staff, optionalAuth } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeList, scopeBody } = require('../utils/campusScope');
|
||||
const { notOnSeasonPass } = require('../utils/seasonPass');
|
||||
|
||||
// Campus-scoped staff (utils/campusScope.js). Routes open to the registration's owner as well
|
||||
// as to staff check staff against the registration's event, and let the owner through (ownerOk).
|
||||
|
||||
// Registration - auth optional when event doesn't require it
|
||||
router.post('/', optionalAuth, createRegistration);
|
||||
router.get('/myregistrations', protect, getUserRegistrations);
|
||||
router.put('/:id/options', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), notOnSeasonPass, updateRegistrationOptions);
|
||||
router.delete('/:id', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), cancelRegistration);
|
||||
router.post('/:id/send-invoice', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), sendInvoice);
|
||||
router.post('/:id/coupon', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), notOnSeasonPass, applyCoupon);
|
||||
router.delete('/:id/coupon', protect, staff, scopeEvent({ resolve: 'registration' }), removeCoupon);
|
||||
router.put('/:id/attendees', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), updateAttendees);
|
||||
router.post('/:id/attendees/:attendeeId/send-form-link', protect, scopeEvent({ resolve: 'registration', ownerOk: true }), sendAttendeeFormLink);
|
||||
|
||||
// Registration detail + forms — optionalAuth so guests can access with just the registrationId
|
||||
router.get('/:id', optionalAuth, scopeEvent({ resolve: 'registration', ownerOk: true }), getRegistrationById);
|
||||
router.get('/:id/forms/draft', optionalAuth, scopeEvent({ resolve: 'registration', ownerOk: true }), getFormDraft);
|
||||
router.put('/:id/forms/draft', optionalAuth, scopeEvent({ resolve: 'registration', ownerOk: true }), saveFormDraft);
|
||||
router.post('/:id/forms/responses', optionalAuth, scopeEvent({ resolve: 'registration', ownerOk: true }), submitFormResponses);
|
||||
router.put('/:id/forms/responses', protect, supervisor, scopeEvent({ resolve: 'registration' }), replaceFormResponses);
|
||||
|
||||
// Admin/Staff routes
|
||||
router.get('/', protect, staff, scopeList, getRegistrations);
|
||||
router.put('/:id', protect, staff, scopeEvent({ resolve: 'registration' }), updateRegistrationStatus);
|
||||
router.get('/event/:eventId', protect, staff, scopeEvent(), getRegistrationsByEvent);
|
||||
router.post('/manual', protect, supervisor, scopeEvent({ from: req => req.body?.eventId }), createManualRegistration);
|
||||
// Bulk actions (1.49.1): every ticked registration must be one this person may manage.
|
||||
router.post('/bulk', protect, supervisor, scopeBody([['registrationIds', 'registration']], { orphan: 'deny' }), async (req, res) => {
|
||||
try { res.json(await require('../utils/bulkRegistrations').runBulk(req, req.body || {})); } catch (e) { res.status(e.statusCode || 400).json({ message: e.message }); }
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,18 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { generatePdf, generateExcel, emailPdf, whatsappPdf } = require('../controllers/reportController');
|
||||
const { protect } = require('../middleware/authMiddleware');
|
||||
|
||||
// Generate and download PDF
|
||||
router.post('/pdf', protect, generatePdf);
|
||||
|
||||
// Generate and download styled Excel (.xlsx)
|
||||
router.post('/excel', protect, generateExcel);
|
||||
|
||||
// Email PDF to current user
|
||||
router.post('/email', protect, emailPdf);
|
||||
|
||||
// Send PDF to current user's own WhatsApp
|
||||
router.post('/whatsapp', protect, whatsappPdf);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,16 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { listLocks, createLock, getSnapshot, syncLock, releaseLock, forceRelease, listReports, reviewReport } = require('../controllers/scanLockController');
|
||||
const { protect, staff, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent } = require('../utils/campusScope');
|
||||
|
||||
router.get('/', protect, staff, scopeEvent({ from: req => req.query.eventId }), listLocks);
|
||||
router.post('/', protect, staff, scopeEvent({ from: req => req.body?.eventId }), createLock);
|
||||
router.get('/reports', protect, supervisor, scopeEvent({ from: req => req.query.eventId }), listReports);
|
||||
router.post('/reports/:id/review', protect, supervisor, scopeEvent({ resolve: 'syncReport' }), reviewReport);
|
||||
router.get('/:id/snapshot', protect, staff, scopeEvent({ resolve: 'scanLock' }), getSnapshot);
|
||||
router.post('/:id/sync', protect, staff, scopeEvent({ resolve: 'scanLock' }), syncLock);
|
||||
router.post('/:id/force-release', protect, supervisor, scopeEvent({ resolve: 'scanLock' }), forceRelease);
|
||||
router.delete('/:id', protect, staff, scopeEvent({ resolve: 'scanLock' }), releaseLock);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,12 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { listScheduledEmails, updateScheduledEmail, deleteScheduledEmail } = require('../controllers/scheduledEmailsController');
|
||||
const { protect, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeList } = require('../utils/campusScope');
|
||||
|
||||
// All routes require supervisor (or admin via middleware logic) access
|
||||
router.get('/', protect, supervisor, scopeList, listScheduledEmails);
|
||||
router.patch('/:id', protect, supervisor, scopeList, updateScheduledEmail);
|
||||
router.delete('/:id', protect, supervisor, scopeList, deleteScheduledEmail);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,18 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { listPasses, createPass, updatePass, deletePass, buy, payPurchase, myPurchases } = require('../controllers/seasonPassController');
|
||||
const { protect, supervisor } = require('../middleware/authMiddleware');
|
||||
const { campusIndependent } = require('../utils/campusScope');
|
||||
|
||||
const SPANS = campusIndependent('a pass can span campuses; each event on it is checked against the person\'s campuses in the controller');
|
||||
|
||||
router.get('/mine', protect, myPurchases);
|
||||
router.post('/:id/buy', protect, buy);
|
||||
router.post('/purchases/:id/checkout', protect, payPurchase);
|
||||
|
||||
router.get('/', protect, supervisor, SPANS, listPasses);
|
||||
router.post('/', protect, supervisor, SPANS, createPass);
|
||||
router.put('/:id', protect, supervisor, SPANS, updatePass);
|
||||
router.delete('/:id', protect, supervisor, SPANS, deletePass);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,17 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
getSections,
|
||||
createSection,
|
||||
deleteSection,
|
||||
updateSection
|
||||
} = require('../controllers/sectionController');
|
||||
const { protect, admin, supervisor, staff } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeList } = require('../utils/campusScope');
|
||||
|
||||
router.get('/', protect, staff, scopeList, getSections);
|
||||
router.post('/', protect, supervisor, scopeEvent({ from: req => req.body?.eventId, need: 'manage' }), createSection);
|
||||
router.delete('/:id', protect, admin, deleteSection);
|
||||
router.put('/:id', protect, supervisor, scopeEvent({ resolve: 'section', need: 'manage' }), updateSection);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,21 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { listSeries, createSeries, updateSeries, deleteSeries, getSeriesBySlug, followSeries, unfollowSeries, compare } = require('../controllers/seriesController');
|
||||
const { protect, admin, supervisor, optionalAuth } = require('../middleware/authMiddleware');
|
||||
const { campusIndependent, scopeList } = require('../utils/campusScope');
|
||||
|
||||
const SPANS = campusIndependent('a series spans campuses; adding an event to one is checked on the event');
|
||||
|
||||
router.get('/by-slug/:slug', optionalAuth, getSeriesBySlug);
|
||||
router.post('/:id/follow', protect, followSeries);
|
||||
router.delete('/:id/follow', protect, unfollowSeries);
|
||||
|
||||
// The list filters each series' events by the person's campuses itself.
|
||||
router.get('/', protect, supervisor, SPANS, listSeries);
|
||||
router.post('/', protect, supervisor, SPANS, createSeries);
|
||||
router.put('/:id', protect, supervisor, SPANS, updateSeries);
|
||||
router.delete('/:id', protect, admin, deleteSeries);
|
||||
// Year-on-year report: only the events the person may see (filtered in the controller).
|
||||
router.get('/:id/compare', protect, supervisor, scopeList, compare);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,12 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getSettings, getAllSettings, updateSettings, needsSetup, testSmtp } = require('../controllers/settingsController');
|
||||
const { protect, admin } = require('../middleware/authMiddleware');
|
||||
|
||||
router.get('/needs-setup', needsSetup);
|
||||
router.get('/all', protect, admin, getAllSettings);
|
||||
router.get('/', getSettings);
|
||||
router.put('/', protect, admin, updateSettings);
|
||||
router.post('/test-smtp', protect, admin, testSmtp);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,12 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { setupRegister, runSetup } = require('../controllers/settingsController');
|
||||
const { protect, admin } = require('../middleware/authMiddleware');
|
||||
|
||||
// Step 1 of setup: create the admin account, returns a JWT token
|
||||
router.post('/register', setupRegister);
|
||||
|
||||
// Step 2 of setup: finalize settings (requires the token from /register)
|
||||
router.post('/', protect, admin, runSetup);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,11 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getEventSponsorship, createSponsorCheckout, getPool } = require('../controllers/sponsorshipController');
|
||||
const { protect, supervisor, optionalAuth } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent } = require('../utils/campusScope');
|
||||
|
||||
router.get('/event/:eventId', getEventSponsorship);
|
||||
router.get('/event/:eventId/pool', protect, supervisor, scopeEvent(), getPool);
|
||||
router.post('/checkout', optionalAuth, createSponsorCheckout);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,18 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getStaffDashboardStats, getSupervisorDashboardStats, getAdminDashboardStats, getOverviewStats } = require('../controllers/statsController');
|
||||
const { protect, staff, supervisor, admin } = require('../middleware/authMiddleware');
|
||||
const { scopeList } = require('../utils/campusScope');
|
||||
|
||||
// One endpoint per dashboard — each returns exactly what that dashboard renders in a
|
||||
// single response instead of the dashboard making several separate calls (and, previously,
|
||||
// pulling full payments/events lists just to reduce them to a couple of numbers).
|
||||
router.get('/staff', protect, staff, scopeList, getStaffDashboardStats);
|
||||
router.get('/supervisor', protect, supervisor, scopeList, getSupervisorDashboardStats);
|
||||
router.get('/admin', protect, admin, getAdminDashboardStats);
|
||||
|
||||
// Month-over-month KPIs + trend + top events, shared by the Admin and Supervisor dashboards.
|
||||
// Staff never sees financial data, so this has no staff-accessible route.
|
||||
router.get('/overview', protect, supervisor, scopeList, getOverviewStats);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,55 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
generateTickets,
|
||||
getTickets,
|
||||
getUserTickets,
|
||||
getTicketById,
|
||||
getTicketByQrCode,
|
||||
getScanPreview,
|
||||
scanTicket,
|
||||
getTicketsByEvent,
|
||||
markTicketsAsEmailSent,
|
||||
emailTickets,
|
||||
sendTicketsTo,
|
||||
getRecentScans,
|
||||
getScanStats,
|
||||
transferTicketHandler,
|
||||
cancelTransferHandler,
|
||||
getTransferOffer,
|
||||
acceptTransferOffer,
|
||||
declineTransferOffer,
|
||||
getTicketTransfers
|
||||
} = require('../controllers/ticketController');
|
||||
const { protect, admin, supervisor, staff } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeBody, scopeList } = require('../utils/campusScope');
|
||||
|
||||
// Campus-scoped staff (utils/campusScope.js). The scanner names the campus of another campus's ticket.
|
||||
|
||||
// Protected routes
|
||||
router.get('/mytickets', protect, getUserTickets);
|
||||
router.get('/:id', protect, scopeEvent({ resolve: 'ticket', ownerOk: true }), getTicketById);
|
||||
router.post('/email', protect, emailTickets);
|
||||
router.post('/:id/transfer', protect, scopeEvent({ resolve: 'ticket', ownerOk: true }), transferTicketHandler);
|
||||
router.delete('/:id/transfer', protect, scopeEvent({ resolve: 'ticket', ownerOk: true }), cancelTransferHandler);
|
||||
// Transfer links (public: the person the ticket is offered to)
|
||||
router.get('/transfer-offer/:token', getTransferOffer);
|
||||
router.post('/transfer-offer/:token/accept', acceptTransferOffer);
|
||||
router.post('/transfer-offer/:token/decline', declineTransferOffer);
|
||||
router.get('/:id/transfers', protect, scopeEvent({ resolve: 'ticket', ownerOk: true }), getTicketTransfers);
|
||||
|
||||
// Staff routes
|
||||
router.post('/send-to', protect, staff, scopeBody([['registrationId', 'registration'], ['ticketIds', 'ticket']]), sendTicketsTo);
|
||||
router.get('/scan-preview/:qrCode', protect, staff, scopeEvent({ resolve: 'ticketQr', from: req => req.params.qrCode, nameCampus: true }), getScanPreview);
|
||||
router.get('/qr/:qrCode', protect, staff, scopeEvent({ resolve: 'ticketQr', from: req => req.params.qrCode, nameCampus: true }), getTicketByQrCode);
|
||||
router.post('/scan/:qrCode', protect, staff, scopeEvent({ resolve: 'ticketQr', from: req => req.params.qrCode, nameCampus: true }), scanTicket);
|
||||
router.get('/event/:eventId', protect, staff, scopeEvent(), getTicketsByEvent);
|
||||
router.get('/scans/recent', protect, staff, scopeList, getRecentScans);
|
||||
router.get('/scans/stats', protect, staff, scopeList, getScanStats);
|
||||
|
||||
// Admin routes
|
||||
router.post('/generate', protect, supervisor, scopeBody([['registrationId', 'registration']]), generateTickets);
|
||||
router.get('/', protect, supervisor, scopeList, getTickets);
|
||||
router.put('/email-sent', protect, admin, markTicketsAsEmailSent);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,53 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const { upload, uploadEventImage, uploadLogo, uploadLogoImage, uploadFavicon, uploadFaviconImage } = require('../controllers/uploadController');
|
||||
const { protect, supervisor, admin } = require('../middleware/authMiddleware');
|
||||
const { campusIndependent } = require('../utils/campusScope');
|
||||
const prisma = require('../config/db');
|
||||
|
||||
// @route POST /api/uploads/event-image
|
||||
// @desc Upload an image for an event
|
||||
// @access Private (Supervisor+ recommended)
|
||||
router.post('/event-image', protect, supervisor, campusIndependent('stores an image file; the event it goes on is checked when the event is saved'), (req, res, next) => {
|
||||
upload.single('image')(req, res, (err) => {
|
||||
if (err) {
|
||||
req.multerError = err;
|
||||
}
|
||||
next();
|
||||
});
|
||||
}, uploadEventImage);
|
||||
|
||||
// Shared access rule for branding assets (logo, favicon): admin, OR allowed
|
||||
// during first-time setup (no users yet).
|
||||
async function brandingAssetAccess(req, res, next) {
|
||||
try {
|
||||
const count = await prisma.user.count();
|
||||
if (count === 0) return next(); // first-time setup
|
||||
return protect(req, res, () => admin(req, res, next));
|
||||
} catch {
|
||||
return protect(req, res, () => admin(req, res, next));
|
||||
}
|
||||
}
|
||||
|
||||
// @route POST /api/uploads/logo
|
||||
// @desc Upload site logo — admin, OR allowed during first-time setup (no users yet)
|
||||
// @access Admin or setup
|
||||
router.post('/logo', brandingAssetAccess, (req, res, next) => {
|
||||
uploadLogo.single('image')(req, res, (err) => {
|
||||
if (err) req.multerError = err;
|
||||
next();
|
||||
});
|
||||
}, uploadLogoImage);
|
||||
|
||||
// @route POST /api/uploads/favicon
|
||||
// @desc Upload site favicon — admin, OR allowed during first-time setup (no users yet)
|
||||
// @access Admin or setup
|
||||
router.post('/favicon', brandingAssetAccess, (req, res, next) => {
|
||||
uploadFavicon.single('image')(req, res, (err) => {
|
||||
if (err) req.multerError = err;
|
||||
next();
|
||||
});
|
||||
}, uploadFaviconImage);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,67 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
registerUser,
|
||||
loginUser,
|
||||
verifyLoginTwoFactor,
|
||||
resendLoginTwoFactor,
|
||||
startEnableTwoFactor,
|
||||
confirmEnableTwoFactor,
|
||||
disableTwoFactor,
|
||||
verifyPassword,
|
||||
getUserProfile,
|
||||
updateUserProfile,
|
||||
getUsers,
|
||||
checkUserExists,
|
||||
getUserById,
|
||||
updateUser,
|
||||
deleteUser,
|
||||
anonymizeUser,
|
||||
requestPasswordReset,
|
||||
resetPassword,
|
||||
activateAccount,
|
||||
revokeMySession,
|
||||
adminRevokeUserSessions,
|
||||
closeAccount,
|
||||
getMyActivity,
|
||||
} = require('../controllers/userController');
|
||||
const { protect, admin, supervisor, loginLimiter} = require('../middleware/authMiddleware');
|
||||
const { campusIndependent } = require('../utils/campusScope');
|
||||
|
||||
// Public routes
|
||||
router.post('/', registerUser);
|
||||
router.post('/login', loginLimiter, loginUser);
|
||||
router.post('/login/2fa', loginLimiter, verifyLoginTwoFactor);
|
||||
router.post('/login/2fa/resend', loginLimiter, resendLoginTwoFactor);
|
||||
router.post('/forgot', loginLimiter, requestPasswordReset);
|
||||
router.post('/reset', resetPassword);
|
||||
router.post('/activate', activateAccount);
|
||||
|
||||
// Protected routes
|
||||
router.route('/profile')
|
||||
.get(protect, getUserProfile)
|
||||
.put(protect, updateUserProfile);
|
||||
|
||||
router.post('/revoke-sessions', protect, revokeMySession);
|
||||
router.post('/close-account', protect, closeAccount);
|
||||
router.get('/activity', protect, getMyActivity);
|
||||
router.post('/verify-password', protect, loginLimiter, verifyPassword);
|
||||
router.post('/2fa/enable', protect, loginLimiter, startEnableTwoFactor);
|
||||
router.post('/2fa/confirm', protect, loginLimiter, confirmEnableTwoFactor);
|
||||
router.post('/2fa/disable', protect, loginLimiter, disableTwoFactor);
|
||||
|
||||
// Admin routes
|
||||
router.route('/')
|
||||
.get(protect, supervisor, campusIndependent('accounts are shared across campuses'), getUsers);
|
||||
|
||||
router.get('/check-exists', protect, supervisor, campusIndependent('accounts are shared across campuses'), checkUserExists);
|
||||
|
||||
router.route('/:id')
|
||||
.get(protect, admin, getUserById)
|
||||
.put(protect, admin, updateUser)
|
||||
.delete(protect, admin, deleteUser);
|
||||
|
||||
router.post('/:id/revoke-sessions', protect, admin, adminRevokeUserSessions);
|
||||
router.post('/:id/anonymize', protect, admin, anonymizeUser);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,33 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const c = require('../controllers/volunteerController');
|
||||
const { protect, staff, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent, scopeList } = require('../utils/campusScope');
|
||||
|
||||
// My account → Serving (anyone with an account can volunteer; only their own slots)
|
||||
router.get('/me', protect, c.getMine);
|
||||
router.get('/events/:eventId', protect, c.getEventRoles);
|
||||
router.post('/roles/:id/sign-up', protect, c.signUp);
|
||||
router.delete('/slots/:id', protect, c.withdraw);
|
||||
router.post('/slots/:id/swap', protect, c.requestSwap);
|
||||
router.delete('/swaps/:id', protect, c.cancelSwap);
|
||||
router.post('/swaps/:id/accept', protect, c.acceptSwap);
|
||||
router.post('/check-in', protect, c.checkIn);
|
||||
|
||||
// The roster on the day (staff)
|
||||
router.get('/manage/events', protect, staff, scopeList, c.listEvents);
|
||||
router.get('/manage/events/:eventId', protect, staff, scopeEvent(), c.getRoster);
|
||||
router.get('/manage/events/:eventId/qr', protect, staff, scopeEvent(), c.getQr);
|
||||
router.post('/manage/slots/:id/check-in', protect, staff, scopeEvent({ resolve: 'volunteerSlot' }), c.checkInManual);
|
||||
|
||||
// Roles, people, settings and reports (supervisors)
|
||||
router.get('/manage/events/:eventId/settings', protect, supervisor, scopeEvent(), c.getSettings);
|
||||
router.put('/manage/events/:eventId/settings', protect, supervisor, scopeEvent({ need: 'manage' }), c.saveSettings);
|
||||
router.post('/manage/events/:eventId/roles', protect, supervisor, scopeEvent({ need: 'manage' }), c.createRole);
|
||||
router.put('/manage/roles/:id', protect, supervisor, scopeEvent({ resolve: 'servingRole', need: 'manage' }), c.updateRole);
|
||||
router.delete('/manage/roles/:id', protect, supervisor, scopeEvent({ resolve: 'servingRole', need: 'manage' }), c.deleteRole);
|
||||
router.post('/manage/roles/:id/assign', protect, supervisor, scopeEvent({ resolve: 'servingRole' }), c.assign);
|
||||
router.delete('/manage/slots/:id', protect, supervisor, scopeEvent({ resolve: 'volunteerSlot' }), c.remove);
|
||||
router.get('/manage/hours', protect, supervisor, scopeList, c.hours);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,20 +0,0 @@
|
||||
const express = require('express');
|
||||
const rateLimit = require('express-rate-limit');
|
||||
const router = express.Router();
|
||||
const { joinWaitlist, myWaitlist, leaveWaitlist, claimInfo, eventWaitlist, offerManually, moveEntry, removeEntry } = require('../controllers/waitlistController');
|
||||
const { protect, staff, supervisor, optionalAuth } = require('../middleware/authMiddleware');
|
||||
const { scopeEvent } = require('../utils/campusScope');
|
||||
|
||||
// Claim links are credentials, so keep guessing slow.
|
||||
const claimLimiter = rateLimit({ windowMs: 60 * 1000, max: 30, message: { message: 'Too many attempts. Please try again in a minute.' } });
|
||||
|
||||
router.post('/', optionalAuth, joinWaitlist);
|
||||
router.get('/mine', protect, myWaitlist);
|
||||
router.get('/claim/:token', claimLimiter, claimInfo);
|
||||
router.get('/events/:eventId', protect, staff, scopeEvent(), eventWaitlist);
|
||||
router.post('/:id/offer', protect, supervisor, scopeEvent({ resolve: 'waitlistEntry' }), offerManually);
|
||||
router.post('/:id/move', protect, supervisor, scopeEvent({ resolve: 'waitlistEntry' }), moveEntry);
|
||||
router.post('/:id/remove', protect, supervisor, scopeEvent({ resolve: 'waitlistEntry' }), removeEntry);
|
||||
router.delete('/:id', protect, leaveWaitlist);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,11 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { previewWhatsAppBroadcast, sendWhatsAppBroadcast, scheduleWhatsAppBroadcast } = require('../controllers/whatsappBroadcastController');
|
||||
const { protect, supervisor } = require('../middleware/authMiddleware');
|
||||
const { scopeBroadcast } = require('../utils/campusScope');
|
||||
|
||||
router.post('/preview', protect, supervisor, scopeBroadcast({ freeformField: 'phones' }), previewWhatsAppBroadcast);
|
||||
router.post('/send', protect, supervisor, scopeBroadcast({ freeformField: 'phones' }), sendWhatsAppBroadcast);
|
||||
router.post('/schedule', protect, supervisor, scopeBroadcast({ freeformField: 'phones' }), scheduleWhatsAppBroadcast);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,37 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const {
|
||||
getConfigHandler,
|
||||
saveConfigHandler,
|
||||
createInstanceHandler,
|
||||
deleteInstanceHandler,
|
||||
getStatusHandler,
|
||||
getQrHandler,
|
||||
requestCodeHandler,
|
||||
logoutHandler,
|
||||
startHandler,
|
||||
restartHandler,
|
||||
handleWebhook,
|
||||
} = require('../controllers/whatsappController');
|
||||
const { protect, admin } = require('../middleware/authMiddleware');
|
||||
|
||||
// Public webhook (called by WAWP servers)
|
||||
router.post('/webhook', handleWebhook);
|
||||
|
||||
// Admin-only: credentials config
|
||||
router.get( '/config', protect, admin, getConfigHandler);
|
||||
router.post('/config', protect, admin, saveConfigHandler);
|
||||
|
||||
// Admin-only: instance lifecycle
|
||||
router.post('/create-instance', protect, admin, createInstanceHandler);
|
||||
router.post('/delete-instance', protect, admin, deleteInstanceHandler);
|
||||
|
||||
// Admin-only: session management
|
||||
router.get( '/status', protect, admin, getStatusHandler);
|
||||
router.get( '/qr', protect, admin, getQrHandler);
|
||||
router.post('/request-code', protect, admin, requestCodeHandler);
|
||||
router.post('/logout', protect, admin, logoutHandler);
|
||||
router.post('/start', protect, admin, startHandler);
|
||||
router.post('/restart', protect, admin, restartHandler);
|
||||
|
||||
module.exports = router;
|
||||
@@ -1,12 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { getConfig, updateConfig, getWebhooks, createWebhook, removeWebhook } = require('../controllers/yocoController');
|
||||
const { protect, admin } = require('../middleware/authMiddleware');
|
||||
|
||||
router.get('/config', protect, admin, getConfig);
|
||||
router.put('/config', protect, admin, updateConfig);
|
||||
router.get('/webhooks', protect, admin, getWebhooks);
|
||||
router.post('/webhooks', protect, admin, createWebhook);
|
||||
router.delete('/webhooks/:id', protect, admin, removeWebhook);
|
||||
|
||||
module.exports = router;
|
||||
@@ -12,6 +12,7 @@ const auth = require('../config/auth') as {
|
||||
generateToken(id: string, role: string, tokenVersion: number): string;
|
||||
hashPassword(pw: string): Promise<string>;
|
||||
comparePassword(pw: string, hash: string): Promise<boolean>;
|
||||
needsRehash(hash: string): boolean;
|
||||
};
|
||||
const twoFactor = require('../utils/twoFactor') as {
|
||||
createChallenge(user: any, purpose: string, method: string): Promise<{ challengeId: string; method: string; destination: string | null }>;
|
||||
@@ -249,7 +250,9 @@ export async function logIn(input: { identifier: string; password: string; devic
|
||||
fail(401, 'Invalid email or password', undefined, { v1Status: 400 });
|
||||
}
|
||||
|
||||
const updated = await prisma.user.update({ where: { id: user.id }, data: { failedAttempts: 0, lockUntil: null }, select: LOGIN_USER_SELECT });
|
||||
// 2.0: a password saved with bcrypt (or weaker Argon2 settings) is re-hashed now we have it.
|
||||
const rehashed = auth.needsRehash(user.password) ? { password: await auth.hashPassword(input.password) } : {};
|
||||
const updated = await prisma.user.update({ where: { id: user.id }, data: { failedAttempts: 0, lockUntil: null, ...rehashed }, select: LOGIN_USER_SELECT });
|
||||
|
||||
// Two-factor: the password alone isn't enough unless this browser was remembered earlier.
|
||||
if (updated.twoFactorEnabled && !(await twoFactor.isTrustedDevice(updated.id, input.deviceToken))) {
|
||||
|
||||
@@ -18,7 +18,7 @@ const prisma = require('../config/db');
|
||||
const MAX_MINUTES = 30;
|
||||
const SAFE_METHODS = ['GET', 'HEAD', 'OPTIONS'];
|
||||
// v1 and v2 paths for ending a viewing-as session and logging what was viewed.
|
||||
const ALLOWED_WRITES = ['/api/admin/impersonate/end', '/api/admin/impersonate/log', '/api/v2/me/impersonation/end', '/api/v2/me/impersonation/log'];
|
||||
const ALLOWED_WRITES = ['/api/v2/me/impersonation/end', '/api/v2/me/impersonation/log'];
|
||||
|
||||
/** The `imp` claim of a bearer token, or null (no token, invalid token, or not impersonating). */
|
||||
function impersonationClaim(req) {
|
||||
|
||||
@@ -1,380 +0,0 @@
|
||||
import type { RequestHandler } from 'express';
|
||||
|
||||
/**
|
||||
* v1 endpoints that have a v2 replacement say so (1.51.3): a `Deprecation` header (RFC 9745,
|
||||
* the date v2 covered them) and `Link: <…>; rel="successor-version"` pointing at the v2
|
||||
* endpoint. v1 keeps working until 2.0; endpoints without a v2 version get no header yet.
|
||||
*/
|
||||
|
||||
// When these v1 endpoints got their v2 replacement (1.51.3's release day).
|
||||
const DEPRECATED_AT = Math.floor(Date.UTC(2026, 9, 29) / 1000);
|
||||
|
||||
type Successor = { method: string; v1: RegExp; v2: (m: RegExpMatchArray) => string };
|
||||
|
||||
const SUCCESSORS: Successor[] = [
|
||||
{ method: 'GET', v1: /^\/api\/events\/?$/, v2: () => '/api/v2/events' },
|
||||
// v1's event detail is the full record (v2's /events/{id} is the public summary).
|
||||
{ method: 'GET', v1: /^\/api\/events\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/full` },
|
||||
// 1.51.8: the rest of the events area
|
||||
{ method: 'GET', v1: /^\/api\/events\/([^/]+)\/ics$/, v2: m => `/api/v2/events/${m[1]}/calendar.ics` },
|
||||
{ method: 'GET', v1: /^\/api\/events\/by-alias\/([^/]+)$/, v2: m => `/api/v2/events/by-alias/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/events\/([^/]+)\/options$/, v2: m => `/api/v2/events/${m[1]}/ticket-options` },
|
||||
{ method: 'PUT', v1: /^\/api\/events\/options\/([^/]+)$/, v2: m => `/api/v2/ticket-options/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/events\/options\/([^/]+)$/, v2: m => `/api/v2/ticket-options/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/events\/options\/([^/]+)\/variants$/, v2: m => `/api/v2/ticket-options/${m[1]}/variants` },
|
||||
{ method: 'PUT', v1: /^\/api\/events\/variants\/([^/]+)$/, v2: m => `/api/v2/variants/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/events\/variants\/([^/]+)$/, v2: m => `/api/v2/variants/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/events\/attachments\/status$/, v2: () => '/api/v2/attachments/status' },
|
||||
{ method: 'POST', v1: /^\/api\/events\/attachments\/sync$/, v2: () => '/api/v2/attachments/sync' },
|
||||
{ method: 'GET', v1: /^\/api\/events\/([^/]+)\/attachments$/, v2: m => `/api/v2/events/${m[1]}/attachments` },
|
||||
{ method: 'POST', v1: /^\/api\/events\/([^/]+)\/attachments$/, v2: m => `/api/v2/events/${m[1]}/attachments` },
|
||||
{ method: 'DELETE', v1: /^\/api\/events\/([^/]+)\/attachments\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/attachments/${m[2]}` },
|
||||
{ method: 'GET', v1: /^\/api\/sections\/?$/, v2: () => '/api/v2/sections' },
|
||||
{ method: 'POST', v1: /^\/api\/sections\/?$/, v2: () => '/api/v2/sections' },
|
||||
{ method: 'PUT', v1: /^\/api\/sections\/([^/]+)$/, v2: m => `/api/v2/sections/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/sections\/([^/]+)$/, v2: m => `/api/v2/sections/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/events\/([^/]+)\/costs$/, v2: m => `/api/v2/events/${m[1]}/costs` },
|
||||
{ method: 'POST', v1: /^\/api\/events\/([^/]+)\/costs$/, v2: m => `/api/v2/events/${m[1]}/costs` },
|
||||
{ method: 'PUT', v1: /^\/api\/costs\/([^/]+)$/, v2: m => `/api/v2/costs/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/costs\/([^/]+)$/, v2: m => `/api/v2/costs/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/uploads\/(event-image|logo|favicon)$/, v2: m => `/api/v2/uploads/${m[1]}` },
|
||||
// 1.51.7: setting events up
|
||||
{ method: 'GET', v1: /^\/api\/events\/all$/, v2: () => '/api/v2/events/manage' },
|
||||
{ method: 'POST', v1: /^\/api\/events\/?$/, v2: () => '/api/v2/events' },
|
||||
{ method: 'PUT', v1: /^\/api\/events\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/events\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/events\/([^/]+)\/copy-from$/, v2: m => `/api/v2/events/${m[1]}/copy-from` },
|
||||
{ method: 'GET', v1: /^\/api\/events\/([^/]+)\/notify-recipients$/, v2: m => `/api/v2/events/${m[1]}/notify-recipients` },
|
||||
{ method: 'PUT', v1: /^\/api\/events\/([^/]+)\/notify-recipients$/, v2: m => `/api/v2/events/${m[1]}/notify-recipients` },
|
||||
// 1.51.16: incoming webhooks and links in sent messages (v1 still answered by the same code)
|
||||
{ method: 'POST', v1: /^\/api\/webhooks\/(yoco|payfast|whatsapp)$/, v2: m => `/api/v2/webhooks/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/whatsapp\/webhook$/, v2: () => '/api/v2/webhooks/whatsapp' },
|
||||
{ method: 'POST', v1: /^\/api\/privacy\/unsubscribe\/([^/]+)\/one-click$/, v2: m => `/api/v2/unsubscribe/${m[1]}/one-click` },
|
||||
// 1.51.15: privacy and admin
|
||||
{ method: 'GET', v1: /^\/api\/privacy\/me$/, v2: () => '/api/v2/me/privacy' },
|
||||
{ method: 'PUT', v1: /^\/api\/privacy\/me\/news$/, v2: () => '/api/v2/me/privacy/news' },
|
||||
{ method: 'GET', v1: /^\/api\/privacy\/me\/export$/, v2: () => '/api/v2/me/privacy/export' },
|
||||
{ method: 'POST', v1: /^\/api\/privacy\/me\/requests$/, v2: () => '/api/v2/me/privacy/requests' },
|
||||
{ method: 'POST', v1: /^\/api\/privacy\/me\/notice\/accept$/, v2: () => '/api/v2/me/privacy/notice/accept' },
|
||||
{ method: 'GET', v1: /^\/api\/privacy\/notice$/, v2: () => '/api/v2/privacy/notice' },
|
||||
{ method: 'GET', v1: /^\/api\/privacy\/unsubscribe\/([^/]+)$/, v2: m => `/api/v2/unsubscribe/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/privacy\/unsubscribe\/([^/]+)$/, v2: m => `/api/v2/unsubscribe/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/privacy\/requests$/, v2: () => '/api/v2/privacy/requests' },
|
||||
{ method: 'POST', v1: /^\/api\/privacy\/requests\/([^/]+)\/(complete|reject)$/, v2: m => `/api/v2/privacy/requests/${m[1]}/${m[2]}` },
|
||||
{ method: 'GET', v1: /^\/api\/privacy\/notice\/draft$/, v2: () => '/api/v2/privacy/notice/draft' },
|
||||
{ method: 'PUT', v1: /^\/api\/privacy\/notice\/draft$/, v2: () => '/api/v2/privacy/notice/draft' },
|
||||
{ method: 'DELETE', v1: /^\/api\/privacy\/notice\/draft$/, v2: () => '/api/v2/privacy/notice/draft' },
|
||||
{ method: 'POST', v1: /^\/api\/privacy\/notice\/(publish|builtin-reviewed)$/, v2: m => `/api/v2/privacy/notice/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/privacy\/operators$/, v2: () => '/api/v2/privacy/operators' },
|
||||
{ method: 'POST', v1: /^\/api\/privacy\/operators$/, v2: () => '/api/v2/privacy/operators' },
|
||||
{ method: 'PUT', v1: /^\/api\/privacy\/operators\/([^/]+)$/, v2: m => `/api/v2/privacy/operators/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/privacy\/operators\/([^/]+)$/, v2: m => `/api/v2/privacy/operators/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/privacy\/(consent-log|access-log|readiness|retention|breaches)$/, v2: m => `/api/v2/privacy/${m[1]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/privacy\/retention$/, v2: () => '/api/v2/privacy/retention' },
|
||||
{ method: 'POST', v1: /^\/api\/privacy\/retention\/run$/, v2: () => '/api/v2/privacy/retention/run' },
|
||||
{ method: 'POST', v1: /^\/api\/privacy\/breaches$/, v2: () => '/api/v2/privacy/breaches' },
|
||||
{ method: 'PUT', v1: /^\/api\/privacy\/breaches\/([^/]+)$/, v2: m => `/api/v2/privacy/breaches/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/admin\/(audit-log|jobs|impersonation-sessions)$/, v2: m => `/api/v2/admin/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/admin\/jobs\/([^/]+)\/run$/, v2: m => `/api/v2/admin/jobs/${m[1]}/run` },
|
||||
{ method: 'POST', v1: /^\/api\/admin\/impersonate\/(end|log)$/, v2: m => `/api/v2/me/impersonation/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/admin\/impersonate\/current$/, v2: () => '/api/v2/me/impersonation' },
|
||||
{ method: 'POST', v1: /^\/api\/admin\/impersonate\/([^/]+)$/, v2: m => `/api/v2/admin/impersonate/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/settings\/needs-setup$/, v2: () => '/api/v2/setup/needed' },
|
||||
{ method: 'GET', v1: /^\/api\/settings\/all$/, v2: () => '/api/v2/settings/all' },
|
||||
{ method: 'GET', v1: /^\/api\/settings\/?$/, v2: () => '/api/v2/settings' },
|
||||
{ method: 'PUT', v1: /^\/api\/settings\/?$/, v2: () => '/api/v2/settings' },
|
||||
{ method: 'POST', v1: /^\/api\/settings\/test-smtp$/, v2: () => '/api/v2/settings/test-smtp' },
|
||||
{ method: 'POST', v1: /^\/api\/setup\/register$/, v2: () => '/api/v2/setup/register' },
|
||||
{ method: 'POST', v1: /^\/api\/setup\/?$/, v2: () => '/api/v2/setup' },
|
||||
{ method: 'GET', v1: /^\/api\/hub\/(status|notices)$/, v2: m => `/api/v2/hub/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/hub\/(connect|heartbeat|update-request|update-snooze)$/, v2: m => `/api/v2/hub/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/hub\/update-request\/cancel$/, v2: () => '/api/v2/hub/update-request/cancel' },
|
||||
{ method: 'GET', v1: /^\/api\/outbound-webhooks\/?$/, v2: () => '/api/v2/outbound-webhooks' },
|
||||
{ method: 'POST', v1: /^\/api\/outbound-webhooks\/?$/, v2: () => '/api/v2/outbound-webhooks' },
|
||||
{ method: 'POST', v1: /^\/api\/outbound-webhooks\/deliveries\/([^/]+)\/resend$/, v2: m => `/api/v2/outbound-webhook-deliveries/${m[1]}/resend` },
|
||||
{ method: 'PUT', v1: /^\/api\/outbound-webhooks\/([^/]+)$/, v2: m => `/api/v2/outbound-webhooks/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/outbound-webhooks\/([^/]+)$/, v2: m => `/api/v2/outbound-webhooks/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/outbound-webhooks\/([^/]+)\/(rotate-secret|test)$/, v2: m => `/api/v2/outbound-webhooks/${m[1]}/${m[2]}` },
|
||||
{ method: 'GET', v1: /^\/api\/outbound-webhooks\/([^/]+)\/deliveries$/, v2: m => `/api/v2/outbound-webhooks/${m[1]}/deliveries` },
|
||||
{ method: 'GET', v1: /^\/api\/backups\/?$/, v2: () => '/api/v2/backups' },
|
||||
{ method: 'POST', v1: /^\/api\/backups\/run$/, v2: () => '/api/v2/backups/run' },
|
||||
{ method: 'GET', v1: /^\/api\/backups\/([^/]+)\/download$/, v2: m => `/api/v2/backups/${m[1]}/download` },
|
||||
{ method: 'GET', v1: /^\/api\/(yoco|payfast)\/config$/, v2: m => `/api/v2/payments/${m[1]}/config` },
|
||||
{ method: 'PUT', v1: /^\/api\/(yoco|payfast)\/config$/, v2: m => `/api/v2/payments/${m[1]}/config` },
|
||||
{ method: 'GET', v1: /^\/api\/yoco\/webhooks$/, v2: () => '/api/v2/payments/yoco/webhooks' },
|
||||
{ method: 'POST', v1: /^\/api\/yoco\/webhooks$/, v2: () => '/api/v2/payments/yoco/webhooks' },
|
||||
{ method: 'DELETE', v1: /^\/api\/yoco\/webhooks\/([^/]+)$/, v2: m => `/api/v2/payments/yoco/webhooks/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/payfast\/test$/, v2: () => '/api/v2/payments/payfast/test' },
|
||||
// 1.51.14: people and messaging
|
||||
{ method: 'POST', v1: /^\/api\/users\/login\/2fa\/resend$/, v2: () => '/api/v2/auth/login/code/resend' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/forgot$/, v2: () => '/api/v2/auth/password/forgot' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/reset$/, v2: () => '/api/v2/auth/password/reset' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/activate$/, v2: () => '/api/v2/auth/activate' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/revoke-sessions$/, v2: () => '/api/v2/me/sessions/revoke' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/close-account$/, v2: () => '/api/v2/me/close' },
|
||||
{ method: 'GET', v1: /^\/api\/users\/activity$/, v2: () => '/api/v2/me/activity' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/verify-password$/, v2: () => '/api/v2/me/verify-password' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/2fa\/(enable|confirm|disable)$/, v2: m => `/api/v2/me/two-factor/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/users\/check-exists$/, v2: () => '/api/v2/users/exists' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/([^/]+)\/revoke-sessions$/, v2: m => `/api/v2/users/${m[1]}/sessions/revoke` },
|
||||
{ method: 'POST', v1: /^\/api\/users\/([^/]+)\/anonymize$/, v2: m => `/api/v2/users/${m[1]}/anonymize` },
|
||||
{ method: 'GET', v1: /^\/api\/users\/?$/, v2: () => '/api/v2/users' },
|
||||
// (/api/users/profile is /api/v2/me — see 1.51.2 below.)
|
||||
{ method: 'GET', v1: /^\/api\/users\/(?!profile$)([^/]+)$/, v2: m => `/api/v2/users/${m[1]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/users\/(?!profile$)([^/]+)$/, v2: m => `/api/v2/users/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/users\/([^/]+)$/, v2: m => `/api/v2/users/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/events\/admin\/all$/, v2: () => '/api/v2/admin/events' },
|
||||
{ method: 'POST', v1: /^\/api\/events\/([^/]+)\/(email|whatsapp)-attendees$/, v2: m => `/api/v2/events/${m[1]}/${m[2]}-attendees` },
|
||||
{ method: 'POST', v1: /^\/api\/events\/([^/]+)\/(email|whatsapp)-attendees\/schedule$/, v2: m => `/api/v2/events/${m[1]}/${m[2]}-attendees/schedule` },
|
||||
{ method: 'POST', v1: /^\/api\/broadcasts\/(preview|send|schedule)$/, v2: m => `/api/v2/broadcasts/email/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/whatsapp-broadcasts\/(preview|send|schedule)$/, v2: m => `/api/v2/broadcasts/whatsapp/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/scheduled-emails\/?$/, v2: () => '/api/v2/scheduled-messages' },
|
||||
{ method: 'PATCH', v1: /^\/api\/scheduled-emails\/([^/]+)$/, v2: m => `/api/v2/scheduled-messages/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/scheduled-emails\/([^/]+)$/, v2: m => `/api/v2/scheduled-messages/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/automations\/schedule$/, v2: () => '/api/v2/automations/schedule' },
|
||||
{ method: 'GET', v1: /^\/api\/whatsapp\/(config|status|qr)$/, v2: m => `/api/v2/whatsapp/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/whatsapp\/config$/, v2: () => '/api/v2/whatsapp/config' },
|
||||
{ method: 'POST', v1: /^\/api\/whatsapp\/create-instance$/, v2: () => '/api/v2/whatsapp/instance' },
|
||||
{ method: 'POST', v1: /^\/api\/whatsapp\/delete-instance$/, v2: () => '/api/v2/whatsapp/instance' },
|
||||
{ method: 'POST', v1: /^\/api\/whatsapp\/(request-code|logout|start|restart)$/, v2: m => `/api/v2/whatsapp/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/banner\/?$/, v2: () => '/api/v2/banner' },
|
||||
{ method: 'POST', v1: /^\/api\/banner\/?$/, v2: () => '/api/v2/banner' },
|
||||
{ method: 'GET', v1: /^\/api\/saved-filters\/?$/, v2: () => '/api/v2/saved-filters' },
|
||||
{ method: 'POST', v1: /^\/api\/saved-filters\/?$/, v2: () => '/api/v2/saved-filters' },
|
||||
{ method: 'PUT', v1: /^\/api\/saved-filters\/([^/]+)$/, v2: m => `/api/v2/saved-filters/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/saved-filters\/([^/]+)$/, v2: m => `/api/v2/saved-filters/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/dashboard\/(today|search)$/, v2: m => `/api/v2/dashboard/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/stats\/(staff|supervisor|admin|overview)$/, v2: m => `/api/v2/stats/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/analytics\/track$/, v2: () => '/api/v2/analytics/track' },
|
||||
{ method: 'GET', v1: /^\/api\/analytics\/funnel$/, v2: () => '/api/v2/analytics/funnel' },
|
||||
{ method: 'POST', v1: /^\/api\/reports\/(pdf|excel|email|whatsapp)$/, v2: m => `/api/v2/reports/${m[1]}` },
|
||||
// 1.51.13: kids check-in and volunteer rosters
|
||||
{ method: 'GET', v1: /^\/api\/kids\/me$/, v2: () => '/api/v2/me/family' },
|
||||
{ method: 'POST', v1: /^\/api\/kids\/me$/, v2: () => '/api/v2/me/family' },
|
||||
{ method: 'PUT', v1: /^\/api\/kids\/me$/, v2: () => '/api/v2/me/family' },
|
||||
{ method: 'DELETE', v1: /^\/api\/kids\/me$/, v2: () => '/api/v2/me/family' },
|
||||
{ method: 'POST', v1: /^\/api\/kids\/me\/(children|adults)$/, v2: m => `/api/v2/me/family/${m[1]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/kids\/me\/(children|adults)\/([^/]+)$/, v2: m => `/api/v2/me/family/${m[1]}/${m[2]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/kids\/me\/(children|adults)\/([^/]+)$/, v2: m => `/api/v2/me/family/${m[1]}/${m[2]}` },
|
||||
{ method: 'GET', v1: /^\/api\/kids\/setup-events$/, v2: () => '/api/v2/kids/setup-events' },
|
||||
{ method: 'GET', v1: /^\/api\/kids\/events$/, v2: () => '/api/v2/kids/events' },
|
||||
{ method: 'GET', v1: /^\/api\/kids\/events\/([^/]+)\/(settings|board|families|offline)$/, v2: m => `/api/v2/events/${m[1]}/kids/${m[2]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/kids\/events\/([^/]+)\/settings$/, v2: m => `/api/v2/events/${m[1]}/kids/settings` },
|
||||
{ method: 'POST', v1: /^\/api\/kids\/events\/([^/]+)\/(families|check-in|check-out|duty|sync)$/, v2: m => `/api/v2/events/${m[1]}/kids/${m[2]}` },
|
||||
{ method: 'GET', v1: /^\/api\/kids\/events\/([^/]+)\/families\/qr\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/kids/families/qr/${m[2]}` },
|
||||
{ method: 'GET', v1: /^\/api\/kids\/events\/([^/]+)\/families\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/kids/families/${m[2]}` },
|
||||
{ method: 'POST', v1: /^\/api\/kids\/events\/([^/]+)\/families\/([^/]+)\/(parents|children|adults)$/, v2: m => `/api/v2/events/${m[1]}/kids/families/${m[2]}/${m[3]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/kids\/events\/([^/]+)\/families\/([^/]+)\/children\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/kids/families/${m[2]}/children/${m[3]}` },
|
||||
{ method: 'GET', v1: /^\/api\/kids\/events\/([^/]+)\/code\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/kids/code/${m[2]}` },
|
||||
{ method: 'POST', v1: /^\/api\/kids\/check-ins\/([^/]+)\/(override|page)$/, v2: m => `/api/v2/kids/check-ins/${m[1]}/${m[2]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/kids\/check-ins\/([^/]+)\/room$/, v2: m => `/api/v2/kids/check-ins/${m[1]}/room` },
|
||||
{ method: 'POST', v1: /^\/api\/kids\/alerts\/([^/]+)\/resolve$/, v2: m => `/api/v2/kids/alerts/${m[1]}/resolve` },
|
||||
{ method: 'GET', v1: /^\/api\/volunteers\/me$/, v2: () => '/api/v2/me/volunteering' },
|
||||
{ method: 'GET', v1: /^\/api\/volunteers\/events\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/volunteer-roles` },
|
||||
{ method: 'POST', v1: /^\/api\/volunteers\/roles\/([^/]+)\/sign-up$/, v2: m => `/api/v2/volunteer-roles/${m[1]}/sign-up` },
|
||||
{ method: 'DELETE', v1: /^\/api\/volunteers\/slots\/([^/]+)$/, v2: m => `/api/v2/volunteer-slots/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/volunteers\/slots\/([^/]+)\/swap$/, v2: m => `/api/v2/volunteer-slots/${m[1]}/swap` },
|
||||
{ method: 'DELETE', v1: /^\/api\/volunteers\/swaps\/([^/]+)$/, v2: m => `/api/v2/volunteer-swaps/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/volunteers\/swaps\/([^/]+)\/accept$/, v2: m => `/api/v2/volunteer-swaps/${m[1]}/accept` },
|
||||
{ method: 'POST', v1: /^\/api\/volunteers\/check-in$/, v2: () => '/api/v2/volunteering/check-in' },
|
||||
{ method: 'GET', v1: /^\/api\/volunteers\/manage\/events$/, v2: () => '/api/v2/volunteering/events' },
|
||||
{ method: 'GET', v1: /^\/api\/volunteers\/manage\/hours$/, v2: () => '/api/v2/volunteering/hours' },
|
||||
{ method: 'GET', v1: /^\/api\/volunteers\/manage\/events\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/volunteers` },
|
||||
{ method: 'GET', v1: /^\/api\/volunteers\/manage\/events\/([^/]+)\/(qr|settings)$/, v2: m => `/api/v2/events/${m[1]}/volunteers/${m[2]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/volunteers\/manage\/events\/([^/]+)\/settings$/, v2: m => `/api/v2/events/${m[1]}/volunteers/settings` },
|
||||
{ method: 'POST', v1: /^\/api\/volunteers\/manage\/events\/([^/]+)\/roles$/, v2: m => `/api/v2/events/${m[1]}/volunteer-roles` },
|
||||
{ method: 'PUT', v1: /^\/api\/volunteers\/manage\/roles\/([^/]+)$/, v2: m => `/api/v2/volunteer-roles/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/volunteers\/manage\/roles\/([^/]+)$/, v2: m => `/api/v2/volunteer-roles/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/volunteers\/manage\/roles\/([^/]+)\/assign$/, v2: m => `/api/v2/volunteer-roles/${m[1]}/assign` },
|
||||
{ method: 'POST', v1: /^\/api\/volunteers\/manage\/slots\/([^/]+)\/check-in$/, v2: m => `/api/v2/volunteer-slots/${m[1]}/check-in` },
|
||||
{ method: 'DELETE', v1: /^\/api\/volunteers\/manage\/slots\/([^/]+)$/, v2: m => `/api/v2/volunteer-slots/${m[1]}/remove` },
|
||||
// 1.51.12: tickets, scan locks, attendance and certificates, allocations
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/mytickets$/, v2: () => '/api/v2/me/tickets' },
|
||||
{ method: 'POST', v1: /^\/api\/tickets\/email$/, v2: () => '/api/v2/me/tickets/email' },
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/scans\/recent$/, v2: () => '/api/v2/tickets/scans/recent' },
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/scans\/stats$/, v2: () => '/api/v2/tickets/scans/stats' },
|
||||
{ method: 'POST', v1: /^\/api\/tickets\/send-to$/, v2: () => '/api/v2/tickets/send' },
|
||||
{ method: 'POST', v1: /^\/api\/tickets\/generate$/, v2: () => '/api/v2/tickets/generate' },
|
||||
{ method: 'PUT', v1: /^\/api\/tickets\/email-sent$/, v2: () => '/api/v2/tickets/email-sent' },
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/qr\/([^/]+)$/, v2: m => `/api/v2/tickets/qr/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/tickets` },
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/transfer-offer\/([^/]+)$/, v2: m => `/api/v2/ticket-transfers/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/tickets\/transfer-offer\/([^/]+)\/(accept|decline)$/, v2: m => `/api/v2/ticket-transfers/${m[1]}/${m[2]}` },
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/?$/, v2: () => '/api/v2/tickets' },
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/([^/]+)\/transfers$/, v2: m => `/api/v2/tickets/${m[1]}/transfers` },
|
||||
{ method: 'POST', v1: /^\/api\/tickets\/([^/]+)\/transfer$/, v2: m => `/api/v2/tickets/${m[1]}/transfer` },
|
||||
{ method: 'DELETE', v1: /^\/api\/tickets\/([^/]+)\/transfer$/, v2: m => `/api/v2/tickets/${m[1]}/transfer` },
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/([^/]+)$/, v2: m => `/api/v2/tickets/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/scan-locks\/?$/, v2: () => '/api/v2/scan-locks' },
|
||||
{ method: 'POST', v1: /^\/api\/scan-locks\/?$/, v2: () => '/api/v2/scan-locks' },
|
||||
{ method: 'GET', v1: /^\/api\/scan-locks\/reports$/, v2: () => '/api/v2/scan-locks/reports' },
|
||||
{ method: 'POST', v1: /^\/api\/scan-locks\/reports\/([^/]+)\/review$/, v2: m => `/api/v2/scan-locks/reports/${m[1]}/review` },
|
||||
{ method: 'GET', v1: /^\/api\/scan-locks\/([^/]+)\/snapshot$/, v2: m => `/api/v2/scan-locks/${m[1]}/snapshot` },
|
||||
{ method: 'POST', v1: /^\/api\/scan-locks\/([^/]+)\/(sync|force-release)$/, v2: m => `/api/v2/scan-locks/${m[1]}/${m[2]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/scan-locks\/([^/]+)$/, v2: m => `/api/v2/scan-locks/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/attendance\/certificates\/verify\/([^/]+)$/, v2: m => `/api/v2/certificates/verify/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/attendance\/certificates\/mine$/, v2: () => '/api/v2/me/certificates' },
|
||||
{ method: 'POST', v1: /^\/api\/attendance\/certificates\/preview$/, v2: () => '/api/v2/certificates/preview' },
|
||||
{ method: 'GET', v1: /^\/api\/attendance\/certificates\/([^/]+)\/pdf$/, v2: m => `/api/v2/certificates/${m[1]}/pdf` },
|
||||
{ method: 'POST', v1: /^\/api\/attendance\/certificates\/([^/]+)\/revoke$/, v2: m => `/api/v2/certificates/${m[1]}/revoke` },
|
||||
{ method: 'GET', v1: /^\/api\/attendance\/([^/]+)\/export$/, v2: m => `/api/v2/events/${m[1]}/attendance/export` },
|
||||
{ method: 'POST', v1: /^\/api\/attendance\/([^/]+)\/mark$/, v2: m => `/api/v2/events/${m[1]}/attendance` },
|
||||
{ method: 'POST', v1: /^\/api\/attendance\/([^/]+)\/certificates$/, v2: m => `/api/v2/events/${m[1]}/certificates` },
|
||||
{ method: 'POST', v1: /^\/api\/attendance\/([^/]+)\/certificates\/send$/, v2: m => `/api/v2/events/${m[1]}/certificates/send` },
|
||||
{ method: 'GET', v1: /^\/api\/attendance\/([^/]+)\/certificates\.pdf$/, v2: m => `/api/v2/events/${m[1]}/certificates.pdf` },
|
||||
{ method: 'GET', v1: /^\/api\/attendance\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/attendance` },
|
||||
{ method: 'GET', v1: /^\/api\/allocations\/my-groups$/, v2: () => '/api/v2/me/allocation-groups' },
|
||||
{ method: 'GET', v1: /^\/api\/allocations\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/allocations` },
|
||||
{ method: 'POST', v1: /^\/api\/allocations\/sets$/, v2: () => '/api/v2/allocation-sets' },
|
||||
{ method: 'PUT', v1: /^\/api\/allocations\/sets\/([^/]+)$/, v2: m => `/api/v2/allocation-sets/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/allocations\/sets\/([^/]+)$/, v2: m => `/api/v2/allocation-sets/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/allocations\/sets\/([^/]+)\/lists$/, v2: m => `/api/v2/allocation-sets/${m[1]}/lists` },
|
||||
{ method: 'POST', v1: /^\/api\/allocations\/sets\/([^/]+)\/(groups|auto)$/, v2: m => `/api/v2/allocation-sets/${m[1]}/${m[2]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/allocations\/sets\/([^/]+)\/assignments$/, v2: m => `/api/v2/allocation-sets/${m[1]}/assignments` },
|
||||
{ method: 'DELETE', v1: /^\/api\/allocations\/sets\/([^/]+)\/assignments$/, v2: m => `/api/v2/allocation-sets/${m[1]}/assignments` },
|
||||
{ method: 'PUT', v1: /^\/api\/allocations\/groups\/([^/]+)$/, v2: m => `/api/v2/allocation-groups/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/allocations\/groups\/([^/]+)$/, v2: m => `/api/v2/allocation-groups/${m[1]}` },
|
||||
// 1.51.11: money (payments, cash-ups, provider transactions, waitlist, sponsorship, consent, forms, feedback)
|
||||
{ method: 'GET', v1: /^\/api\/payments\/providers$/, v2: () => '/api/v2/payments/providers' },
|
||||
{ method: 'GET', v1: /^\/api\/payments\/providers\/settings$/, v2: () => '/api/v2/payments/providers/settings' },
|
||||
{ method: 'PUT', v1: /^\/api\/payments\/providers\/settings$/, v2: () => '/api/v2/payments/providers/settings' },
|
||||
{ method: 'GET', v1: /^\/api\/payments\/pay\/([^/]+)$/, v2: m => `/api/v2/payment-links/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/payments\/pay\/([^/]+)$/, v2: m => `/api/v2/payment-links/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/payments\/checkouts\/open$/, v2: () => '/api/v2/payments/open-checkouts' },
|
||||
{ method: 'POST', v1: /^\/api\/payments\/checkouts\/check$/, v2: () => '/api/v2/payments/open-checkouts/check' },
|
||||
{ method: 'POST', v1: /^\/api\/payments\/(yoco-)?checkout\/send$/, v2: () => '/api/v2/registrations/{id}/payment-link' },
|
||||
{ method: 'GET', v1: /^\/api\/payments\/mypayments$/, v2: () => '/api/v2/me/payments' },
|
||||
{ method: 'GET', v1: /^\/api\/payments\/admin\/stats$/, v2: () => '/api/v2/payments/stats' },
|
||||
{ method: 'GET', v1: /^\/api\/payments\/registration\/([^/]+)$/, v2: m => `/api/v2/registrations/${m[1]}/payments` },
|
||||
{ method: 'GET', v1: /^\/api\/payments\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/payments` },
|
||||
{ method: 'PUT', v1: /^\/api\/payments\/assign-donation$/, v2: () => '/api/v2/payments/donations/assign' },
|
||||
{ method: 'POST', v1: /^\/api\/payments\/unassign-donation$/, v2: () => '/api/v2/payments/donations/unassign' },
|
||||
{ method: 'POST', v1: /^\/api\/payments\/refund$/, v2: () => '/api/v2/payments/refunds' },
|
||||
{ method: 'POST', v1: /^\/api\/payments\/([^/]+)\/send-receipt$/, v2: m => `/api/v2/payments/${m[1]}/receipt` },
|
||||
{ method: 'GET', v1: /^\/api\/payments\/?$/, v2: () => '/api/v2/payments' },
|
||||
{ method: 'POST', v1: /^\/api\/payments\/?$/, v2: () => '/api/v2/payments' },
|
||||
{ method: 'GET', v1: /^\/api\/payments\/([^/]+)$/, v2: m => `/api/v2/payments/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/cashups\/audit$/, v2: () => '/api/v2/cashups/audit' },
|
||||
{ method: 'GET', v1: /^\/api\/cashups\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/cashup` },
|
||||
{ method: 'GET', v1: /^\/api\/cashups\/event\/([^/]+)\/cash-by-user$/, v2: m => `/api/v2/events/${m[1]}/cashup/cash-by-user` },
|
||||
{ method: 'PUT', v1: /^\/api\/cashups\/event\/([^/]+)\/person-cash\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/cashup/person-cash/${m[2]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/cashups\/event\/([^/]+)\/draft$/, v2: m => `/api/v2/events/${m[1]}/cashup/draft` },
|
||||
{ method: 'POST', v1: /^\/api\/cashups\/event\/([^/]+)\/close$/, v2: m => `/api/v2/events/${m[1]}/cashup/close` },
|
||||
{ method: 'POST', v1: /^\/api\/cashups\/event\/([^/]+)\/reopen$/, v2: m => `/api/v2/events/${m[1]}/cashup/reopen` },
|
||||
{ method: 'POST', v1: /^\/api\/cashups\/lines\/([^/]+)\/pending$/, v2: m => `/api/v2/cashup-lines/${m[1]}/pending` },
|
||||
{ method: 'GET', v1: /^\/api\/(provider|yoco)-transactions\/?$/, v2: () => '/api/v2/provider-transactions' },
|
||||
{ method: 'GET', v1: /^\/api\/(provider|yoco)-transactions\/unreconciled$/, v2: () => '/api/v2/provider-transactions/unreconciled' },
|
||||
{ method: 'POST', v1: /^\/api\/(?:provider|yoco)-transactions\/([^/]+)\/reconcile$/, v2: m => `/api/v2/provider-transactions/${m[1]}/reconcile` },
|
||||
{ method: 'POST', v1: /^\/api\/(?:provider|yoco)-transactions\/([^/]+)\/ignore$/, v2: m => `/api/v2/provider-transactions/${m[1]}/ignore` },
|
||||
{ method: 'POST', v1: /^\/api\/waitlist\/?$/, v2: () => '/api/v2/waitlist' },
|
||||
{ method: 'GET', v1: /^\/api\/waitlist\/mine$/, v2: () => '/api/v2/me/waitlist' },
|
||||
{ method: 'GET', v1: /^\/api\/waitlist\/claim\/([^/]+)$/, v2: m => `/api/v2/waitlist/claims/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/waitlist\/events\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/waitlist` },
|
||||
{ method: 'POST', v1: /^\/api\/waitlist\/([^/]+)\/(offer|move|remove)$/, v2: m => `/api/v2/waitlist/${m[1]}/${m[2]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/waitlist\/([^/]+)$/, v2: m => `/api/v2/waitlist/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/sponsorships\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/sponsorship` },
|
||||
{ method: 'GET', v1: /^\/api\/sponsorships\/event\/([^/]+)\/pool$/, v2: m => `/api/v2/events/${m[1]}/sponsorship/pool` },
|
||||
{ method: 'POST', v1: /^\/api\/sponsorships\/checkout$/, v2: () => '/api/v2/sponsorships/checkout' },
|
||||
{ method: 'GET', v1: /^\/api\/consent\/events\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/consent` },
|
||||
{ method: 'GET', v1: /^\/api\/consent\/events\/([^/]+)\/medical$/, v2: m => `/api/v2/events/${m[1]}/consent/medical` },
|
||||
{ method: 'POST', v1: /^\/api\/consent\/events\/([^/]+)\/(resend-pending|rerequest)$/, v2: m => `/api/v2/events/${m[1]}/consent/${m[2]}` },
|
||||
{ method: 'POST', v1: /^\/api\/consent\/requests\/([^/]+)\/resend$/, v2: m => `/api/v2/consent-requests/${m[1]}/resend` },
|
||||
{ method: 'GET', v1: /^\/api\/consent\/([^/]+)$/, v2: m => `/api/v2/consent/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/consent\/([^/]+)$/, v2: m => `/api/v2/consent/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/forms\/responses$/, v2: () => '/api/v2/form-responses' },
|
||||
{ method: 'GET', v1: /^\/api\/feedback\/summary$/, v2: () => '/api/v2/feedback/summary' },
|
||||
{ method: 'GET', v1: /^\/api\/feedback\/public\/([^/]+)$/, v2: m => `/api/v2/feedback-forms/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/feedback\/public\/([^/]+)$/, v2: m => `/api/v2/feedback-forms/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/feedback\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/feedback` },
|
||||
{ method: 'PUT', v1: /^\/api\/feedback\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/feedback` },
|
||||
{ method: 'DELETE', v1: /^\/api\/feedback\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/feedback` },
|
||||
{ method: 'POST', v1: /^\/api\/feedback\/event\/([^/]+)\/send-now$/, v2: m => `/api/v2/events/${m[1]}/feedback/send-now` },
|
||||
// 1.51.10: managing registrations
|
||||
{ method: 'GET', v1: /^\/api\/registrations\/?$/, v2: () => '/api/v2/registrations' },
|
||||
{ method: 'GET', v1: /^\/api\/registrations\/myregistrations$/, v2: () => '/api/v2/me/registrations/full' },
|
||||
{ method: 'GET', v1: /^\/api\/registrations\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/registrations` },
|
||||
{ method: 'POST', v1: /^\/api\/registrations\/manual$/, v2: () => '/api/v2/registrations/manual' },
|
||||
{ method: 'POST', v1: /^\/api\/registrations\/bulk$/, v2: () => '/api/v2/registrations/bulk' },
|
||||
{ method: 'PUT', v1: /^\/api\/registrations\/([^/]+)\/options$/, v2: m => `/api/v2/registrations/${m[1]}/items` },
|
||||
{ method: 'POST', v1: /^\/api\/registrations\/([^/]+)\/send-invoice$/, v2: m => `/api/v2/registrations/${m[1]}/invoice` },
|
||||
{ method: 'POST', v1: /^\/api\/registrations\/([^/]+)\/coupon$/, v2: m => `/api/v2/registrations/${m[1]}/coupon` },
|
||||
{ method: 'DELETE', v1: /^\/api\/registrations\/([^/]+)\/coupon$/, v2: m => `/api/v2/registrations/${m[1]}/coupon` },
|
||||
{ method: 'PUT', v1: /^\/api\/registrations\/([^/]+)\/attendees$/, v2: m => `/api/v2/registrations/${m[1]}/attendees` },
|
||||
{ method: 'POST', v1: /^\/api\/registrations\/([^/]+)\/attendees\/([^/]+)\/send-form-link$/, v2: m => `/api/v2/registrations/${m[1]}/attendees/${m[2]}/form-link` },
|
||||
{ method: 'GET', v1: /^\/api\/registrations\/([^/]+)\/forms\/draft$/, v2: m => `/api/v2/registrations/${m[1]}/form-draft` },
|
||||
{ method: 'PUT', v1: /^\/api\/registrations\/([^/]+)\/forms\/draft$/, v2: m => `/api/v2/registrations/${m[1]}/form-draft` },
|
||||
{ method: 'POST', v1: /^\/api\/registrations\/([^/]+)\/forms\/responses$/, v2: m => `/api/v2/registrations/${m[1]}/form-responses` },
|
||||
{ method: 'PUT', v1: /^\/api\/registrations\/([^/]+)\/forms\/responses$/, v2: m => `/api/v2/registrations/${m[1]}/form-responses` },
|
||||
{ method: 'GET', v1: /^\/api\/registrations\/([^/]+)$/, v2: m => `/api/v2/registrations/${m[1]}/full` },
|
||||
{ method: 'PUT', v1: /^\/api\/registrations\/([^/]+)$/, v2: m => `/api/v2/registrations/${m[1]}/status` },
|
||||
// 1.51.9: series, season passes, bundles, coupons, campuses
|
||||
{ method: 'GET', v1: /^\/api\/series\/?$/, v2: () => '/api/v2/series' },
|
||||
{ method: 'POST', v1: /^\/api\/series\/?$/, v2: () => '/api/v2/series' },
|
||||
{ method: 'GET', v1: /^\/api\/series\/by-slug\/([^/]+)$/, v2: m => `/api/v2/series/by-slug/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/series\/([^/]+)\/compare$/, v2: m => `/api/v2/series/${m[1]}/compare` },
|
||||
{ method: 'POST', v1: /^\/api\/series\/([^/]+)\/follow$/, v2: m => `/api/v2/series/${m[1]}/follow` },
|
||||
{ method: 'DELETE', v1: /^\/api\/series\/([^/]+)\/follow$/, v2: m => `/api/v2/series/${m[1]}/follow` },
|
||||
{ method: 'PUT', v1: /^\/api\/series\/([^/]+)$/, v2: m => `/api/v2/series/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/series\/([^/]+)$/, v2: m => `/api/v2/series/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/season-passes\/mine$/, v2: () => '/api/v2/me/season-passes' },
|
||||
{ method: 'POST', v1: /^\/api\/season-passes\/purchases\/([^/]+)\/checkout$/, v2: m => `/api/v2/season-pass-purchases/${m[1]}/checkout` },
|
||||
{ method: 'POST', v1: /^\/api\/season-passes\/([^/]+)\/buy$/, v2: m => `/api/v2/season-passes/${m[1]}/buy` },
|
||||
{ method: 'GET', v1: /^\/api\/season-passes\/?$/, v2: () => '/api/v2/season-passes' },
|
||||
{ method: 'POST', v1: /^\/api\/season-passes\/?$/, v2: () => '/api/v2/season-passes' },
|
||||
{ method: 'PUT', v1: /^\/api\/season-passes\/([^/]+)$/, v2: m => `/api/v2/season-passes/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/season-passes\/([^/]+)$/, v2: m => `/api/v2/season-passes/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/bundles\/quote$/, v2: () => '/api/v2/bundles/quote' },
|
||||
{ method: 'GET', v1: /^\/api\/bundles\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/bundles` },
|
||||
{ method: 'POST', v1: /^\/api\/bundles\/event\/([^/]+)$/, v2: m => `/api/v2/events/${m[1]}/bundles` },
|
||||
{ method: 'PUT', v1: /^\/api\/bundles\/([^/]+)$/, v2: m => `/api/v2/bundles/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/bundles\/([^/]+)$/, v2: m => `/api/v2/bundles/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/coupons\/validate$/, v2: () => '/api/v2/coupons/check' },
|
||||
{ method: 'GET', v1: /^\/api\/coupons\/redemptions$/, v2: () => '/api/v2/coupons/redemptions' },
|
||||
{ method: 'GET', v1: /^\/api\/coupons\/?$/, v2: () => '/api/v2/coupons' },
|
||||
{ method: 'POST', v1: /^\/api\/coupons\/?$/, v2: () => '/api/v2/coupons' },
|
||||
{ method: 'GET', v1: /^\/api\/coupons\/([^/]+)$/, v2: m => `/api/v2/coupons/${m[1]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/coupons\/([^/]+)$/, v2: m => `/api/v2/coupons/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/campuses\/?$/, v2: () => '/api/v2/campuses' },
|
||||
{ method: 'GET', v1: /^\/api\/campuses\/admin$/, v2: () => '/api/v2/campuses/admin' },
|
||||
{ method: 'GET', v1: /^\/api\/campuses\/by-slug\/([^/]+)$/, v2: m => `/api/v2/campuses/by-slug/${m[1]}` },
|
||||
{ method: 'PUT', v1: /^\/api\/campuses\/settings$/, v2: () => '/api/v2/campuses/enabled' },
|
||||
{ method: 'PUT', v1: /^\/api\/campuses\/order$/, v2: () => '/api/v2/campuses/order' },
|
||||
{ method: 'POST', v1: /^\/api\/campuses\/?$/, v2: () => '/api/v2/campuses' },
|
||||
{ method: 'GET', v1: /^\/api\/campuses\/([^/]+)\/audience$/, v2: m => `/api/v2/campuses/${m[1]}/audience` },
|
||||
{ method: 'PUT', v1: /^\/api\/campuses\/([^/]+)$/, v2: m => `/api/v2/campuses/${m[1]}` },
|
||||
{ method: 'DELETE', v1: /^\/api\/campuses\/([^/]+)$/, v2: m => `/api/v2/campuses/${m[1]}` },
|
||||
{ method: 'GET', v1: /^\/api\/users\/profile$/, v2: () => '/api/v2/me' },
|
||||
{ method: 'PUT', v1: /^\/api\/users\/profile$/, v2: () => '/api/v2/me' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/?$/, v2: () => '/api/v2/auth/signup' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/login$/, v2: () => '/api/v2/auth/login' },
|
||||
{ method: 'POST', v1: /^\/api\/users\/login\/2fa$/, v2: () => '/api/v2/auth/login/code' },
|
||||
{ method: 'POST', v1: /^\/api\/registrations\/?$/, v2: () => '/api/v2/registrations' },
|
||||
{ method: 'DELETE', v1: /^\/api\/registrations\/([^/]+)$/, v2: m => `/api/v2/registrations/${m[1]}/cancel` },
|
||||
{ method: 'POST', v1: /^\/api\/payments\/checkout$/, v2: () => '/api/v2/registrations/{id}/checkout' },
|
||||
{ method: 'GET', v1: /^\/api\/tickets\/scan-preview\/([^/]+)$/, v2: m => `/api/v2/checkin/${m[1]}` },
|
||||
{ method: 'POST', v1: /^\/api\/tickets\/scan\/([^/]+)$/, v2: m => `/api/v2/checkin/${m[1]}` },
|
||||
];
|
||||
|
||||
// GET /api/events/all isn't a single event.
|
||||
const NOT_AN_EVENT_ID = new Set(['all']);
|
||||
|
||||
/** The v2 successor of a v1 request, if it has one. Pure; exported for tests. */
|
||||
export function successorOf(method: string, path: string): string | null {
|
||||
for (const s of SUCCESSORS) {
|
||||
if (s.method !== method) continue;
|
||||
const m = path.match(s.v1);
|
||||
if (!m) continue;
|
||||
if (s.v1.source.startsWith('^\\/api\\/events\\/(') && NOT_AN_EVENT_ID.has(m[1])) continue;
|
||||
return s.v2(m);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const deprecationHeaders: RequestHandler = (req, res, next) => {
|
||||
const successor = successorOf(req.method, req.originalUrl.split('?')[0]);
|
||||
if (successor) {
|
||||
res.setHeader('Deprecation', `@${DEPRECATED_AT}`);
|
||||
res.setHeader('Link', `<${successor}>; rel="successor-version"`);
|
||||
}
|
||||
next();
|
||||
};
|
||||
@@ -42,6 +42,22 @@ const REDIRECTS: { method: string; v1: RegExp; v2: (m: RegExpMatchArray) => stri
|
||||
{ method: 'GET', v1: /^\/api\/privacy\/unsubscribe\/([^/]+)\/one-click$/, v2: m => `/api/v2/unsubscribe/${m[1]}/one-click` },
|
||||
];
|
||||
|
||||
/**
|
||||
* What's left of v1 (removed in 2.0), mounted at /api: WAWP's oldest webhook address (sites set
|
||||
* up before 1.51.16 registered /api/whatsapp/webhook, and providers may not follow a redirect on
|
||||
* POST) and a mail app's one-click unsubscribe POST to the address in an email already sent.
|
||||
* /api/webhooks/… (Yoco, PayFast, WAWP) is mounted by app.js before the JSON parser.
|
||||
*/
|
||||
export const legacyV1Router = Router();
|
||||
legacyV1Router.post('/whatsapp/webhook', handleWhatsappWebhook);
|
||||
legacyV1Router.post('/privacy/unsubscribe/:token/one-click', express.urlencoded({ extended: false }), privacy.oneClickUnsubscribe);
|
||||
|
||||
/** Any other v1 address: gone since 2.0 (410, pointing at v2). /api/v2 misses fall through to 404. */
|
||||
export const v1Removed: RequestHandler = (req, res, next) => {
|
||||
if (req.path === '/v2' || req.path.startsWith('/v2/')) return next();
|
||||
res.status(410).json({ code: 'API_V1_REMOVED', message: 'API v1 was removed in Cross Events 2.0. Use /api/v2 — it is described at /docs/v2.' });
|
||||
};
|
||||
|
||||
export const legacyLinkRedirects: RequestHandler = (req, res, next) => {
|
||||
const [path, query] = req.originalUrl.split('?');
|
||||
for (const r of REDIRECTS) {
|
||||
|
||||
@@ -107,7 +107,7 @@ export function buildOpenApi(opts: { version: string; serverUrl?: string; list?:
|
||||
'- an error is `{ "error": { "code", "message", "fields"? } }` with a stable `code`.',
|
||||
'',
|
||||
'Dates are ISO 8601 in UTC; amounts are in rand. Sign in through the app and send the token as `Authorization: Bearer <token>`.',
|
||||
'Version 1 (`/api/…`) keeps working while the app moves over; it will be removed in 2.0.',
|
||||
'Version 1 (`/api/…`) was removed in 2.0: its addresses answer `410 Gone`. See the migration guide (MIGRATING-TO-2.md).',
|
||||
].join('\n'),
|
||||
},
|
||||
servers: [{ url: opts.serverUrl ?? '/api/v2' }],
|
||||
|
||||
@@ -88,7 +88,7 @@ v1Route({ method: 'post', path: '/privacy/operators', tag: 'Privacy', summary: '
|
||||
v1Route({ method: 'put', path: '/privacy/operators/:id', tag: 'Privacy', summary: 'Change an operator', access: 'admin', params: idParams, body: loose, documented: { body: operatorInput.partial(), response: operator }, v1: privacy.updateOperator });
|
||||
v1Route({ method: 'delete', path: '/privacy/operators/:id', tag: 'Privacy', summary: 'Remove an operator', access: 'admin', params: idParams, documented: { response: D.message }, v1: privacy.deleteOperator });
|
||||
v1Route({ method: 'get', path: '/privacy/consent-log', tag: 'Privacy', summary: 'Consent given and withdrawn', access: 'admin', query: filters('type', 'page', 'q'), documented: { response: logPage(D.obj({ id: D.str, at: D.optDate, name: D.optStr })).describe('`type` news: email, channel, granted, source, ip; notice: email, version, source, ip; parental: child, event, status, signedName') }, v1: privacy.consentLog });
|
||||
v1Route({ method: 'get', path: '/privacy/access-log', tag: 'Privacy', summary: 'Who looked at sensitive information', access: 'admin', query: filters('page', 'action', 'sensitive', 'actorId', 'from', 'to'), documented: { response: logPage(D.obj({ id: D.str, at: D.date, actor: D.str, actorRole: D.optStr, action: D.str, what: D.optStr, records: D.optNum, eventId: D.optStr, ip: D.optStr, sensitive: D.bool })).extend({ actions: z.array(D.str), actors: z.array(D.obj({ id: D.str, name: D.str })) }) }, v1: privacy.accessLog });
|
||||
v1Route({ method: 'get', path: '/privacy/access-log', tag: 'Privacy', summary: 'Who looked at sensitive information', access: 'admin', query: filters('page', 'action', 'sensitive', 'actorId', 'from', 'to'), documented: { response: logPage(D.obj({ id: D.str, at: D.date, actor: D.str, actorRole: D.optStr, action: D.str, what: D.optStr, records: D.optNum, eventId: D.optStr, ip: D.optStr, sensitive: D.bool })).extend({ actions: z.record(z.string(), D.str).describe('Every action, with its label'), actors: z.array(D.obj({ id: D.str, name: D.str })) }) }, v1: privacy.accessLog });
|
||||
v1Route({ method: 'get', path: '/privacy/readiness', tag: 'Privacy', summary: 'POPIA checklist', access: 'admin', documented: { response: D.obj({ score: D.num.describe('%'), passed: D.num, total: D.num, checks: z.array(D.obj({ key: D.str, label: D.str, ok: D.bool, detail: D.optStr, href: D.optStr, applies: D.bool })) }) }, v1: privacy.getReadiness });
|
||||
v1Route({ method: 'get', path: '/privacy/retention', tag: 'Privacy', summary: 'How long information is kept', access: 'admin', documented: { response: retentionState }, v1: privacy.getRetention });
|
||||
v1Route({ method: 'put', path: '/privacy/retention', tag: 'Privacy', summary: 'Change how long information is kept', access: 'admin', body: loose, documented: { body: D.obj({ policies: D.anyObj.describe('Per kind of information: { enabled, months }') }), response: retentionState }, v1: privacy.saveRetention });
|
||||
|
||||
@@ -204,7 +204,7 @@ v1Route({
|
||||
});
|
||||
v1Route({
|
||||
method: 'get', path: `${cashupBase}/cash-by-user`, tag: 'Cash-ups', summary: 'Cash taken by each person',
|
||||
access: 'supervisor', campusScope: 'scopeEvent(manage)', middleware: [cs.scopeEvent({ need: 'manage' })], params: idParams, map: asEvent, documented: { response: D.obj({ rows: z.array(D.anyObj).describe('Per person: who, cash recorded, cash counted'), cashActualTotal: D.optRand, cashDenominations: D.anyObj.nullish() }) }, v1: cashup.getCashByRecordedUser,
|
||||
access: 'supervisor', campusScope: 'scopeEvent(manage)', middleware: [cs.scopeEvent({ need: 'manage' })], params: idParams, map: asEvent, documented: { response: D.obj({ rows: z.array(D.anyObj).describe('Per person: who, cash recorded, cash counted'), cashActualTotal: D.optRand, cashDenominations: z.array(D.obj({ value: D.num.describe('The note or coin, in rand'), count: D.num })).describe('Counted cash by note and coin') }) }, v1: cashup.getCashByRecordedUser,
|
||||
});
|
||||
v1Route({
|
||||
method: 'put', path: `${cashupBase}/person-cash/:userId`, tag: 'Cash-ups', summary: 'Count one person\'s cash',
|
||||
|
||||
@@ -9,7 +9,8 @@ const mockDb = {
|
||||
};
|
||||
jest.mock('../src/config/db', () => mockDb);
|
||||
const mockCompare = jest.fn(async () => false);
|
||||
jest.mock('../src/config/auth', () => ({ comparePassword: (...a: unknown[]) => (mockCompare as jest.Mock)(...a), hashPassword: async () => 'stand-in-hash', generateToken: () => 't' }));
|
||||
const mockNeedsRehash = jest.fn(() => false);
|
||||
jest.mock('../src/config/auth', () => ({ comparePassword: (...a: unknown[]) => (mockCompare as jest.Mock)(...a), hashPassword: async () => 'stand-in-hash', generateToken: () => 't', needsRehash: (...a: unknown[]) => (mockNeedsRehash as jest.Mock)(...a) }));
|
||||
const mockSendMail = jest.fn(async () => undefined);
|
||||
jest.mock('../src/utils/email', () => ({ sendMail: (...a: unknown[]) => (mockSendMail as jest.Mock)(...a), buildPasswordResetEmail: () => ({ html: '', text: 'reset' }) }));
|
||||
jest.mock('../src/utils/notify', () => ({ waText: async () => undefined }));
|
||||
@@ -81,3 +82,27 @@ describe('sign-in', () => {
|
||||
expect(mockCompare).toHaveBeenCalledWith('guess', 'stand-in-hash');
|
||||
});
|
||||
});
|
||||
|
||||
describe('password re-hashing (2.0)', () => {
|
||||
// Stop logIn at its first save, to see what it saves.
|
||||
const firstSave = () => new Promise<Record<string, unknown>>(resolve => {
|
||||
mockDb.user.update.mockImplementationOnce(async (args: { data: Record<string, unknown> }) => { resolve(args.data); throw new Error('stop'); });
|
||||
});
|
||||
|
||||
test('a right password on an old hash saves a new hash', async () => {
|
||||
mockDb.user.findFirst.mockResolvedValueOnce({ ...realUser, password: '$2a$10$old' });
|
||||
mockCompare.mockResolvedValueOnce(true as never);
|
||||
mockNeedsRehash.mockReturnValueOnce(true);
|
||||
const saved = firstSave();
|
||||
await logIn({ identifier: realUser.email, password: 'right' }, { ip: '127.0.0.1', userAgent: 'test' } as never).catch(() => undefined);
|
||||
expect(await saved).toMatchObject({ failedAttempts: 0, password: 'stand-in-hash' });
|
||||
});
|
||||
|
||||
test('a current hash is left as it is', async () => {
|
||||
mockDb.user.findFirst.mockResolvedValueOnce(realUser);
|
||||
mockCompare.mockResolvedValueOnce(true as never);
|
||||
const saved = firstSave();
|
||||
await logIn({ identifier: realUser.email, password: 'right' }, { ip: '127.0.0.1', userAgent: 'test' } as never).catch(() => undefined);
|
||||
expect(await saved).not.toHaveProperty('password');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -73,7 +73,7 @@ test('moving keeps the same lines and tickets, repriced; checks places; not othe
|
||||
test('payments and ticket changes are refused in licence read-only mode; cancelling is not', async () => {
|
||||
mockLicence.mockResolvedValueOnce({ readOnly: true });
|
||||
await expect(bulk.runBulk(req, { action: 'markPaid', registrationIds: ['a'], method: 'cash' })).rejects.toMatchObject({ statusCode: 403 });
|
||||
expect(isBlocked('POST', '/api/registrations/bulk')).toBe(false);
|
||||
expect(isBlocked('POST', '/api/v2/registrations/bulk')).toBe(false);
|
||||
});
|
||||
|
||||
test('allocating places each named person; a registration without names says so', async () => {
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// Every staff/supervisor route must say how it handles campus-scoped staff (utils/campusScope.js):
|
||||
// scopeEvent(...), scopeList, unscopedOnly or campusIndependent('reason'). A route that says
|
||||
// nothing would show a campus-limited supervisor every campus's data, so this fails on it.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { staff, supervisor } = require('../src/middleware/authMiddleware');
|
||||
|
||||
const ROUTES_DIR = path.join(__dirname, '..', 'src', 'routes');
|
||||
|
||||
function staffRoutes() {
|
||||
const out = [];
|
||||
for (const file of fs.readdirSync(ROUTES_DIR).filter(f => f.endsWith('.js'))) {
|
||||
const router = require(path.join(ROUTES_DIR, file));
|
||||
for (const layer of router.stack || []) {
|
||||
if (!layer.route) continue;
|
||||
for (const method of Object.keys(layer.route.methods)) {
|
||||
// router.route('/x').get(...).put(...) puts every method's handlers on one route, so the
|
||||
// role is checked per method (admin-only methods are never campus-scoped).
|
||||
const forMethod = layer.route.stack.filter(s => s.method === method || s.method === undefined).map(s => s.handle);
|
||||
if (!forMethod.includes(staff) && !forMethod.includes(supervisor)) continue;
|
||||
const marker = forMethod.find(h => h && h.campusScope);
|
||||
out.push({ file, method: method.toUpperCase(), path: layer.route.path, marker: marker ? marker.campusScope : null });
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
describe('campus scope on staff and supervisor routes', () => {
|
||||
const routes = staffRoutes();
|
||||
|
||||
test('finds the staff and supervisor routes', () => {
|
||||
expect(routes.length).toBeGreaterThan(100);
|
||||
});
|
||||
|
||||
test('every one says how it handles campus-scoped staff', () => {
|
||||
const missing = routes.filter(r => !r.marker).map(r => `${r.file} ${r.method} ${r.path}`);
|
||||
expect(missing).toEqual([]);
|
||||
});
|
||||
|
||||
test('a campus-independent route gives a reason', () => {
|
||||
for (const r of routes.filter(x => x.marker && x.marker.startsWith('independent'))) {
|
||||
expect(r.marker.length).toBeGreaterThan('independent: '.length + 5);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -26,6 +26,6 @@ describe('event cloning', () => {
|
||||
});
|
||||
|
||||
test('copying setup is blocked in licence read-only mode', () => {
|
||||
expect(isBlocked('POST', '/api/events/abc/copy-from')).toBe(true);
|
||||
expect(isBlocked('POST', '/api/v2/events/abc/copy-from')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,35 +78,7 @@ describe('heartbeat report', () => {
|
||||
});
|
||||
|
||||
describe('read-only mode', () => {
|
||||
test.each([
|
||||
['POST', '/api/events'],
|
||||
['PUT', '/api/events/ev_1'],
|
||||
['PUT', '/api/events/options/opt_1'],
|
||||
['PUT', '/api/events/variants/var_1'],
|
||||
['POST', '/api/registrations'],
|
||||
['POST', '/api/registrations/manual'],
|
||||
['PUT', '/api/registrations/abc/options'],
|
||||
['POST', '/api/payments'],
|
||||
['POST', '/api/payments/checkout'],
|
||||
['POST', '/api/payments/pay/chk_1'],
|
||||
['POST', '/api/waitlist'],
|
||||
])('%s %s is blocked', (m, p) => expect(isBlocked(m, p)).toBe(true));
|
||||
|
||||
test.each([
|
||||
['POST', '/api/tickets/scan/QR123'],
|
||||
['GET', '/api/events'],
|
||||
['PUT', '/api/events/ev_1/notify-recipients'],
|
||||
['PUT', '/api/registrations/abc'],
|
||||
['POST', '/api/payments/refund'],
|
||||
['POST', '/api/privacy/me/requests'],
|
||||
['POST', '/api/hub/connect'],
|
||||
['POST', '/api/hub/update-request/cancel'],
|
||||
['POST', '/api/hub/update-snooze'],
|
||||
['POST', '/api/users/login'],
|
||||
['POST', '/api/reports/pdf'],
|
||||
])('%s %s keeps working', (m, p) => expect(isBlocked(m, p)).toBe(false));
|
||||
|
||||
// 1.52.3: the screens use /api/v2, so its routes must be blocked too.
|
||||
// /api/v2 only (2.0 removed v1).
|
||||
test.each([
|
||||
['POST', '/api/v2/events'],
|
||||
['PATCH', '/api/v2/events/ev_1'],
|
||||
|
||||
@@ -20,10 +20,10 @@ describe('allowedWhileImpersonating', () => {
|
||||
});
|
||||
|
||||
test('except ending the session and logging page views', () => {
|
||||
expect(allowedWhileImpersonating('POST', '/api/admin/impersonate/end')).toBe(true);
|
||||
expect(allowedWhileImpersonating('POST', '/api/admin/impersonate/log?x=1')).toBe(true);
|
||||
expect(allowedWhileImpersonating('DELETE', '/api/admin/impersonate/end')).toBe(false);
|
||||
expect(allowedWhileImpersonating('POST', '/api/admin/impersonate/end/../../users')).toBe(false);
|
||||
expect(allowedWhileImpersonating('POST', '/api/v2/me/impersonation/end')).toBe(true);
|
||||
expect(allowedWhileImpersonating('POST', '/api/v2/me/impersonation/log?x=1')).toBe(true);
|
||||
expect(allowedWhileImpersonating('DELETE', '/api/v2/me/impersonation/end')).toBe(false);
|
||||
expect(allowedWhileImpersonating('POST', '/api/v2/me/impersonation/end/../../users')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../src/controllers/privacyController', () => ({
|
||||
oneClickUnsubscribe: (req: { params: { token: string }; body: unknown }, res: { json(b: unknown): void }) => { mockCalls.push({ name: 'one-click', body: req.body }); res.json({ ok: true }); },
|
||||
}));
|
||||
|
||||
import { webhooksRouter, linksRouter, legacyLinkRedirects } from '../src/v2/links';
|
||||
import { webhooksRouter, linksRouter, legacyLinkRedirects, legacyV1Router, v1Removed } from '../src/v2/links';
|
||||
|
||||
// The same order and raw-body handling as app.js.
|
||||
function app() {
|
||||
@@ -27,7 +27,9 @@ function app() {
|
||||
a.use(express.json());
|
||||
a.use('/api/v2', linksRouter);
|
||||
a.use(legacyLinkRedirects);
|
||||
a.post('/api/privacy/unsubscribe/:token/one-click', (_req, res) => { mockCalls.push({ name: 'v1 one-click' }); res.json({ ok: true }); });
|
||||
a.use('/api', legacyV1Router);
|
||||
a.use('/api', v1Removed);
|
||||
a.use((_req, res) => { res.status(404).json({ notFound: true }); });
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -72,6 +74,24 @@ describe('links in sent messages', () => {
|
||||
expect(mockCalls[0]).toEqual({ name: 'one-click', body: { 'List-Unsubscribe': 'One-Click' } });
|
||||
const old = await request(app()).post('/api/privacy/unsubscribe/tok/one-click').type('form').send('List-Unsubscribe=One-Click');
|
||||
expect(old.status).toBe(200);
|
||||
expect(mockCalls[1].name).toBe('v1 one-click');
|
||||
expect(mockCalls[1]).toEqual({ name: 'one-click', body: { 'List-Unsubscribe': 'One-Click' } });
|
||||
});
|
||||
});
|
||||
|
||||
describe('v1, removed in 2.0', () => {
|
||||
test("WAWP's oldest webhook address still reaches the handler", async () => {
|
||||
await request(app()).post('/api/whatsapp/webhook?secret=s3').send({ event: 'message' });
|
||||
expect(mockCalls[0]).toEqual({ name: 'whatsapp', body: { event: 'message' }, query: { secret: 's3' } });
|
||||
});
|
||||
|
||||
test('any other v1 address answers 410 and points at v2', async () => {
|
||||
const res = await request(app()).get('/api/events');
|
||||
expect(res.status).toBe(410);
|
||||
expect(res.body).toMatchObject({ code: 'API_V1_REMOVED', message: expect.stringContaining('/api/v2') });
|
||||
expect((await request(app()).post('/api/users/login').send({})).status).toBe(410);
|
||||
});
|
||||
|
||||
test('an unknown v2 address is still a 404', async () => {
|
||||
expect((await request(app()).get('/api/v2/nothing-here')).status).toBe(404);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// 2.0: new passwords are hashed with Argon2id; bcrypt hashes from before still work and are
|
||||
// re-hashed the next time the person signs in (services/auth.ts logIn).
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { hashPassword, comparePassword, needsRehash } = require('../src/config/auth');
|
||||
|
||||
describe('password hashing', () => {
|
||||
test('new hashes are Argon2id and check out', async () => {
|
||||
const hash = await hashPassword('Correct-horse-1');
|
||||
expect(hash.startsWith('$argon2id$')).toBe(true);
|
||||
expect(await comparePassword('Correct-horse-1', hash)).toBe(true);
|
||||
expect(await comparePassword('wrong', hash)).toBe(false);
|
||||
expect(needsRehash(hash)).toBe(false);
|
||||
});
|
||||
|
||||
test('two hashes of the same password differ (salted)', async () => {
|
||||
expect(await hashPassword('same')).not.toBe(await hashPassword('same'));
|
||||
});
|
||||
|
||||
test('old bcrypt hashes still sign in, and are marked for re-hashing', async () => {
|
||||
const old = await bcrypt.hash('Legacy-pass-1', 10);
|
||||
expect(await comparePassword('Legacy-pass-1', old)).toBe(true);
|
||||
expect(await comparePassword('nope', old)).toBe(false);
|
||||
expect(needsRehash(old)).toBe(true);
|
||||
});
|
||||
|
||||
test('anything else never matches', async () => {
|
||||
for (const stored of ['', null, undefined, 'plain-text', '$argon2id$broken']) {
|
||||
expect(await comparePassword('plain-text', stored)).toBe(false);
|
||||
}
|
||||
expect(await comparePassword(undefined, await hashPassword('x'))).toBe(false);
|
||||
});
|
||||
|
||||
test('weaker Argon2 settings are re-hashed too', () => {
|
||||
expect(needsRehash('$argon2id$v=19$m=4096,t=3,p=1$c2FsdHNhbHQ$aGFzaGhhc2g')).toBe(true);
|
||||
expect(needsRehash('$argon2i$v=19$m=19456,t=2,p=1$c2FsdHNhbHQ$aGFzaGhhc2g')).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -112,9 +112,9 @@ describe('season passes', () => {
|
||||
});
|
||||
|
||||
test('making, changing and buying passes is blocked in licence read-only mode', () => {
|
||||
expect(isBlocked('POST', '/api/season-passes')).toBe(true);
|
||||
expect(isBlocked('PUT', '/api/season-passes/p1')).toBe(true);
|
||||
expect(isBlocked('POST', '/api/season-passes/p1/buy')).toBe(true);
|
||||
expect(isBlocked('POST', '/api/season-passes/purchases/pp1/checkout')).toBe(true);
|
||||
expect(isBlocked('POST', '/api/v2/season-passes')).toBe(true);
|
||||
expect(isBlocked('PATCH', '/api/v2/season-passes/p1')).toBe(true);
|
||||
expect(isBlocked('POST', '/api/v2/season-passes/p1/buy')).toBe(true);
|
||||
expect(isBlocked('POST', '/api/v2/season-pass-purchases/pp1/checkout')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -41,9 +41,9 @@ describe('event series', () => {
|
||||
});
|
||||
|
||||
test('creating and changing series is blocked in licence read-only mode; following is not', () => {
|
||||
expect(isBlocked('POST', '/api/series')).toBe(true);
|
||||
expect(isBlocked('PUT', '/api/series/abc')).toBe(true);
|
||||
expect(isBlocked('POST', '/api/series/abc/follow')).toBe(false);
|
||||
expect(isBlocked('POST', '/api/v2/series')).toBe(true);
|
||||
expect(isBlocked('PATCH', '/api/v2/series/abc')).toBe(true);
|
||||
expect(isBlocked('PUT', '/api/v2/series/abc/follow')).toBe(false);
|
||||
});
|
||||
|
||||
describe('year-on-year comparison', () => {
|
||||
|
||||
@@ -392,24 +392,6 @@ describe('check-in', () => {
|
||||
expect(res.body.data.ticket).toMatchObject({ attendee: 'Lulu', bookedBy: 'Thandi', ticketOptionId: 'o1', remaining: 2, consentStatus: 'not_required' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('v1 deprecation headers', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { successorOf } = require('../src/v2/deprecation');
|
||||
test('v1 endpoints with a v2 replacement point at it; the rest say nothing', () => {
|
||||
expect(successorOf('GET', '/api/events')).toBe('/api/v2/events');
|
||||
expect(successorOf('GET', '/api/events/e1')).toBe('/api/v2/events/e1/full');
|
||||
expect(successorOf('PUT', '/api/events/options/o1')).toBe('/api/v2/ticket-options/o1');
|
||||
expect(successorOf('DELETE', '/api/events/e1/attachments/a1')).toBe('/api/v2/events/e1/attachments/a1');
|
||||
expect(successorOf('GET', '/api/events/all')).toBe('/api/v2/events/manage');
|
||||
expect(successorOf('PUT', '/api/events/e1')).toBe('/api/v2/events/e1');
|
||||
expect(successorOf('DELETE', '/api/registrations/r1')).toBe('/api/v2/registrations/r1/cancel');
|
||||
expect(successorOf('POST', '/api/tickets/scan/QR1')).toBe('/api/v2/checkin/QR1');
|
||||
expect(successorOf('GET', '/api/reports/summary')).toBeNull();
|
||||
expect(successorOf('GET', '/api/v2/events')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('shared middleware on v2', () => {
|
||||
test("v1-style refusals become v2 errors, keeping the specific code as reason", async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// Every staff/supervisor route on /api/v2 must really check campus-scoped staff (utils/campusScope.js).
|
||||
// A route has to declare `campusScope` (start-up fails otherwise), but the declaration is only text:
|
||||
// the check itself is a marked middleware — scopeEvent(...), scopeBody(...), scopeList,
|
||||
// unscopedOnly, campusIndependent('reason') or scopeBroadcast(...). A route without one would show
|
||||
// a campus-limited supervisor every campus's data, so this fails on it.
|
||||
//
|
||||
// (Until 2.0 the same test ran over the v1 route files, which held the markers.)
|
||||
//
|
||||
// The routes below check campuses inside their TypeScript service or handler instead, as their
|
||||
// `campusScope` text says. Adding a route here means its handler does the check itself.
|
||||
const CHECKED_IN_HANDLER = new Set([
|
||||
'GET /events/manage', 'POST /events', 'GET /sections', 'POST /uploads/event-image',
|
||||
'GET /series', 'POST /series', 'PATCH /series/:id', 'GET /series/:id/compare',
|
||||
'GET /season-passes', 'POST /season-passes', 'PATCH /season-passes/:id', 'DELETE /season-passes/:id',
|
||||
'GET /coupons', 'GET /coupons/redemptions', 'GET /coupons/:id', 'POST /coupons', 'PATCH /coupons/:id',
|
||||
'GET /campuses/:id/audience', 'GET /registrations',
|
||||
'GET /saved-filters', 'POST /saved-filters', 'PUT /saved-filters/:id', 'DELETE /saved-filters/:id',
|
||||
'GET /checkin/:qrCode', 'POST /checkin/:qrCode',
|
||||
]);
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
const { v2Router } = require('../src/v2');
|
||||
const { routes } = require('../src/v2/route');
|
||||
|
||||
type Route = { method: string; path: string; access: string; campusScope?: string; middleware?: { campusScope?: string }[] };
|
||||
|
||||
describe('campus scope on v2 staff and supervisor routes', () => {
|
||||
v2Router();
|
||||
const staffRoutes = (routes as Route[]).filter(r => r.access === 'staff' || r.access === 'supervisor');
|
||||
const key = (r: Route) => `${r.method.toUpperCase()} ${r.path}`;
|
||||
const marker = (r: Route) => (r.middleware || []).find(h => h && h.campusScope)?.campusScope;
|
||||
|
||||
test('finds the staff and supervisor routes', () => {
|
||||
expect(staffRoutes.length).toBeGreaterThan(150);
|
||||
});
|
||||
|
||||
test('each one has a campus-scope middleware, or checks in its handler', () => {
|
||||
const missing = staffRoutes.filter(r => !marker(r) && !CHECKED_IN_HANDLER.has(key(r))).map(key);
|
||||
expect(missing).toEqual([]);
|
||||
});
|
||||
|
||||
test('the handler-checked list holds only real staff routes without a middleware', () => {
|
||||
const real = new Set(staffRoutes.filter(r => !marker(r)).map(key));
|
||||
expect([...CHECKED_IN_HANDLER].filter(k => !real.has(k))).toEqual([]);
|
||||
});
|
||||
|
||||
test('a campus-independent route gives a reason', () => {
|
||||
for (const r of staffRoutes) {
|
||||
const m = marker(r);
|
||||
if (m && m.startsWith('independent')) expect(m.length).toBeGreaterThan('independent: '.length + 5);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -80,13 +80,13 @@ describe('reserved tickets', () => {
|
||||
|
||||
describe('read-only licence', () => {
|
||||
test.each([
|
||||
['POST', '/api/volunteers/roles/r1/sign-up'],
|
||||
['POST', '/api/volunteers/manage/events/e1/roles'],
|
||||
['POST', '/api/volunteers/manage/roles/r1/assign'],
|
||||
['POST', '/api/v2/volunteer-roles/r1/sign-up'],
|
||||
['POST', '/api/v2/events/e1/volunteer-roles'],
|
||||
['POST', '/api/v2/volunteer-roles/r1/assign'],
|
||||
])('%s %s is blocked', (m, p) => expect(isBlocked(m, p)).toBe(true));
|
||||
test.each([
|
||||
['POST', '/api/volunteers/check-in'],
|
||||
['POST', '/api/volunteers/swaps/w1/accept'],
|
||||
['DELETE', '/api/volunteers/slots/s1'],
|
||||
['POST', '/api/v2/volunteering/check-in'],
|
||||
['POST', '/api/v2/volunteer-swaps/w1/accept'],
|
||||
['DELETE', '/api/v2/volunteer-slots/s1'],
|
||||
])('%s %s keeps working', (m, p) => expect(isBlocked(m, p)).toBe(false));
|
||||
});
|
||||
|
||||
@@ -11,18 +11,18 @@ sold — trustworthy (POPIA), flexible (multi-day events, several payment
|
||||
providers), maintainable (tests, CI, typed backend, versioned API), and with
|
||||
**AI helpers** as the headline feature (§15).
|
||||
|
||||
**Status (2026-10-30):** all features in this document are approved, and everything before 2.0.0
|
||||
has shipped (1.32.0 – 1.51.17). **2.0.0 is in progress** on the `release/2.0` branch, tagged only
|
||||
**Status (2026-11-02):** all features in this document are approved, and everything before 2.0.0
|
||||
has shipped (1.32.0 – 1.52.3). **2.0.0 is in progress** on the `release/2.0` branch, tagged only
|
||||
when all of it is in (decided 2026-10-30):
|
||||
|
||||
| # | Part | Where | State |
|
||||
|---|------|-------|-------|
|
||||
| 1 | AI proxy: key, metering in rand, caps, markup, usage views; model list with prices (Sonnet 5.5 default) | Hub 1.6.0 – 1.6.1 (`events-hub`) | ✅ tagged; real Claude calls tested 2026-10-30 |
|
||||
| 2 | AI plumbing: `/api/v2/ai/status`, usage, Site settings → AI, `<AiButton>`, `useAiStatus()`, `AiCall` log, Anthropic operator entry | `release/2.0` | ✅ committed (WIP) |
|
||||
| 3 | The five helpers (§15) with their buttons, an eval set, privacy notice text | `release/2.0` | next |
|
||||
| 4 | v1 removed (webhook paths and old message links keep working) | `release/2.0` | to do |
|
||||
| 5 | Migration guide, docs | `release/2.0` | to do |
|
||||
| 6 | Marketing site: Cross Code with a Cross Events page (§17) | its own repo | to do |
|
||||
| 3 | The five helpers (§15) with their buttons, an eval set, privacy notice text | `release/2.0` | ✅ committed (WIP); eval 19/19 through a local Hub (2026-10-30) |
|
||||
| 4 | v1 removed (webhook paths and old message links keep working); clean-ups: Argon2id passwords with rehash-on-login, `node-fetch` gone, React Compiler lint rules back to errors | `release/2.0` | ✅ v1, passwords, `node-fetch` (2026-11-02); lint rules in progress |
|
||||
| 5 | Migration guide (`MIGRATING-TO-2.md`), docs | `release/2.0` | guide ✅ (2026-11-02); docs in progress |
|
||||
| 6 | Marketing site: Cross Code with a Cross Events page (§17) | its own repo | to do — repo, domain, hosting, prices and contact route still to decide |
|
||||
|
||||
The full version list is in [HANDOVER.md](./HANDOVER.md) and the [build order](#suggested-build-order) below.
|
||||
|
||||
@@ -845,7 +845,7 @@ keep adding to.
|
||||
| Split big controllers | `registrationController` (2.3k lines), `eventController`, `paymentController` → services by domain. Done **as each feature touches them**, not as a big-bang rewrite. Partly done (1.51.1 – 1.51.10); the handlers behind `v1Route` are a 2.x clean-up |
|
||||
| TypeScript backend ✅ | Incremental (`allowJs`), new code in TS first; share zod schemas/types with the frontend (1.51.0) |
|
||||
| API v2 ✅ | `/api/v2` with consistent errors, pagination and an OpenAPI spec (replaces the hand-written API docs). `/api` (v1) kept during the transition; every endpoint on v2 since 1.51.16 |
|
||||
| Dependencies | Express 5 ✅ (1.51.3); native `fetch` ✅ (nothing uses `node-fetch` any more — it's still in `backend/package.json`, to remove); password hashing upgrade with rehash-on-login — **not done** (still `bcryptjs`), decide whether it's in 2.0 |
|
||||
| Dependencies | Express 5 ✅ (1.51.3); native `fetch` ✅ (`node-fetch` removed in 2.0); password hashing ✅ in 2.0 — Argon2id (`@node-rs/argon2`), bcrypt hashes re-hashed at the next sign-in |
|
||||
|
||||
---
|
||||
|
||||
@@ -1103,6 +1103,7 @@ feature.
|
||||
| — | AI buttons and markup | AI buttons show only when the licence's monthly cap is **above R0**. When the cap is reached they stay visible but **disabled** until next month or until the cap is raised. Usage is charged at the real cost **plus a markup %** set in the Hub (a default, plus an override per licence). The markup covers small overruns and is the profit. The cap is counted in charged rand, and each call is checked against its worst-case cost before it's sent (2026-10-29) |
|
||||
| — | Building 2.0 | On a `release/2.0` branch with a WIP commit per part, tagged 2.0.0 only when everything is in; the Hub's AI proxy ships first as its own release (Hub 1.6.0) (2026-10-30) |
|
||||
| — | Marketing site | Part of 2.0: a simple static HTML site — Cross Code as the main site, with a page for Cross Events, the only product on sale for now. Laid out to add a church app and a full church website later. Repo, domain and hosting still to decide (2026-10-30) |
|
||||
| — | 2.0 clean-ups | All in 2.0 (2026-11-02): v1 removed, Argon2id passwords with rehash-on-login, `node-fetch` removed, React Compiler lint rules back to errors |
|
||||
| — | AI later | Ask AI (read-only, tools only), help/navigation assistant, actions with confirmation, more helpers, and long-term **self-hosted** AI behind the same Hub endpoint — not tied to versions (2026-10-24) |
|
||||
| — | POPIA: message kinds | Bulk messages are either **Event updates** (to registrants — still sent after unsubscribing) or **News & announcements** (marketing — opt-in, one-click unsubscribe). Every bulk email links to the preferences (2026-10-23) |
|
||||
| — | POPIA: existing users | Kept opted in to news (logged as "existing account"), asked once at their next login to confirm or opt out. New sign-ups choose with an unticked box (2026-10-23) |
|
||||
@@ -1126,4 +1127,3 @@ feature.
|
||||
|
||||
- **Marketing site (§17):** repository, domain(s), hosting, whether prices are shown, and the
|
||||
contact route.
|
||||
- **Password hashing upgrade** (§14): in 2.0 or later.
|
||||
|
||||
@@ -68,7 +68,7 @@ test.describe("API v2", () => {
|
||||
// A free ticket for the user, then check it in twice through v2.
|
||||
const event = (await (await request.get(`${API}/api/v2/events/${seed().events.free}`)).json()).data;
|
||||
await request.post(`${API}/api/v2/registrations`, { headers, data: { eventId: event.id, options: [{ eventOptionId: event.ticketOptions[0].id, quantity: 1 }] } });
|
||||
const tickets = await (await request.get(`${API}/api/tickets/mytickets`, { headers })).json();
|
||||
const tickets = (await (await request.get(`${API}/api/v2/me/tickets`, { headers })).json()).data;
|
||||
const qr = tickets.find((t: { eventId: string; qrCode: string }) => t.eventId === event.id).qrCode;
|
||||
|
||||
const staff = { Authorization: `Bearer ${seed().users.staff.token}` };
|
||||
@@ -84,17 +84,14 @@ test.describe("API v2", () => {
|
||||
expect((await (await request.post(`${API}/api/v2/checkin/NOT-A-CODE`, { headers: staff, data: {} })).json()).error.code).toBe("NOT_FOUND");
|
||||
});
|
||||
|
||||
test("v1 endpoints with a v2 version say so", async ({ request }) => {
|
||||
test("v1 is gone in 2.0, except webhooks and links in messages already sent", async ({ request }) => {
|
||||
const v1 = await request.get(`${API}/api/events`);
|
||||
expect(v1.headers()["deprecation"]).toMatch(/^@\d+$/);
|
||||
expect(v1.headers()["link"]).toBe(`</api/v2/events>; rel="successor-version"`);
|
||||
const all = await request.get(`${API}/api/events/all`, { headers: { Authorization: `Bearer ${seed().users.staff.token}` } });
|
||||
expect(all.headers()["link"]).toBe(`</api/v2/events/manage>; rel="successor-version"`);
|
||||
expect((await request.get(`${API}/api/settings/needs-setup`)).headers()["link"]).toBe(`</api/v2/setup/needed>; rel="successor-version"`);
|
||||
// Incoming webhooks: the v1 address still works (same handler) and names its v2 one.
|
||||
const hook = await request.post(`${API}/api/webhooks/whatsapp`, { data: {} });
|
||||
expect(hook.status()).toBe(200);
|
||||
expect(hook.headers()["link"]).toBe(`</api/v2/webhooks/whatsapp>; rel="successor-version"`);
|
||||
expect(v1.status()).toBe(410);
|
||||
expect((await v1.json()).code).toBe("API_V1_REMOVED");
|
||||
expect((await request.post(`${API}/api/users/login`, { data: {} })).status()).toBe(410);
|
||||
// Incoming webhooks: the v1 addresses still reach the same handlers.
|
||||
expect((await request.post(`${API}/api/webhooks/whatsapp`, { data: {} })).status()).toBe(200);
|
||||
expect((await request.post(`${API}/api/whatsapp/webhook`, { data: {} })).status()).toBe(200);
|
||||
expect((await request.post(`${API}/api/v2/webhooks/whatsapp`, { data: { event: "noop" } })).status()).toBe(200);
|
||||
// A calendar link in an email already sent goes to its v2 address.
|
||||
const ics = await request.get(`${API}/api/events/${seed().events.conference}/ics`, { maxRedirects: 0 });
|
||||
@@ -102,6 +99,9 @@ test.describe("API v2", () => {
|
||||
expect(ics.headers()["location"]).toBe(`/api/v2/events/${seed().events.conference}/calendar.ics`);
|
||||
const followed = await request.get(`${API}/api/events/${seed().events.conference}/ics`);
|
||||
expect(followed.headers()["content-type"]).toContain("text/calendar");
|
||||
// The old API reference sends people to the v2 one.
|
||||
const docs = await request.get(`${API}/docs`, { maxRedirects: 0 });
|
||||
expect(docs.headers()["location"]).toBe("/docs/v2");
|
||||
});
|
||||
|
||||
test("staff list every event; supervisors create, change and admins deactivate", async ({ request }) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, loginAs, api } from "./fixtures";
|
||||
import { test, expect, loginAs, api, v2 } from "./fixtures";
|
||||
|
||||
// Bulk actions on the registrations list (1.49.1): tick several, mark them paid, move them to
|
||||
// another ticket, cancel — each through the same rules as one at a time.
|
||||
@@ -14,15 +14,15 @@ test.describe.serial("bulk actions on registrations", () => {
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
const page = await browser.newPage();
|
||||
const start = new Date(Date.now() + 20 * 864e5);
|
||||
event = await api<Ev>(page, "admin", "POST", "/api/events", {
|
||||
event = await v2<Ev>(page, "admin", "POST", "/api/v2/events", {
|
||||
title: "E2E Bulk Night", startDate: start.toISOString(), endDate: new Date(start.getTime() + 3 * 3600e3).toISOString(),
|
||||
price: 100, location: "Church hall",
|
||||
});
|
||||
const full = await api<Ev>(page, "admin", "GET", `/api/events/${event.id}`);
|
||||
const full = await v2<Ev>(page, "admin", "GET", `/api/v2/events/${event.id}/full`);
|
||||
main = full.eventOptions!.find(o => o.isMainTicket)!.id;
|
||||
vip = (await api<{ id: string }>(page, "admin", "POST", `/api/events/${event.id}/options`, { name: "VIP", price: 150, isMainTicket: true })).id;
|
||||
vip = (await v2<{ id: string }>(page, "admin", "POST", `/api/v2/events/${event.id}/ticket-options`, { name: "VIP", price: 150, isMainTicket: true })).id;
|
||||
for (const role of ["staff", "supervisor", "user"] as const) {
|
||||
regs.push((await api<{ id: string }>(page, role, "POST", "/api/registrations", { eventId: event.id, options: [{ eventOptionId: main, quantity: 1 }] })).id);
|
||||
regs.push((await v2<{ id: string }>(page, role, "POST", "/api/v2/registrations", { eventId: event.id, options: [{ eventOptionId: main, quantity: 1 }] })).id);
|
||||
}
|
||||
await page.close();
|
||||
});
|
||||
@@ -45,7 +45,7 @@ test.describe.serial("bulk actions on registrations", () => {
|
||||
await expect(page.getByTestId("bulk-result")).toContainText("3 done");
|
||||
|
||||
for (const id of regs) {
|
||||
const r = await api<Reg>(page, "admin", "GET", `/api/registrations/${id}`);
|
||||
const r = await v2<Reg>(page, "admin", "GET", `/api/v2/registrations/${id}/full`);
|
||||
expect(r.status).toBe("paid");
|
||||
expect(r.payments?.map(p => [p.amount, p.method])).toEqual([[100, "cash"]]);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ test.describe.serial("bulk actions on registrations", () => {
|
||||
await bar.getByRole("button", { name: /Move to another ticket/ }).click();
|
||||
await expect(page.getByTestId("bulk-result")).toContainText("2 done");
|
||||
|
||||
const moved = await Promise.all(regs.map(id => api<Reg>(page, "admin", "GET", `/api/registrations/${id}`)));
|
||||
const moved = await Promise.all(regs.map(id => v2<Reg>(page, "admin", "GET", `/api/v2/registrations/${id}/full`)));
|
||||
const onVip = moved.filter(r => r.registrationOptions?.some(o => o.eventOptionId === vip));
|
||||
expect(onVip).toHaveLength(2);
|
||||
// R150 now, R100 paid: they owe the difference.
|
||||
@@ -73,14 +73,14 @@ test.describe.serial("bulk actions on registrations", () => {
|
||||
await bar.getByRole("button", { name: "Clear selection" }).click();
|
||||
const left = moved.find(r => !r.registrationOptions?.some(o => o.eventOptionId === vip))!;
|
||||
await page.getByRole("checkbox", { name: /^Select / }).nth(2).check();
|
||||
const selectedId = (await api<Reg>(page, "admin", "GET", `/api/registrations/${left.id}`)).id;
|
||||
const selectedId = (await v2<Reg>(page, "admin", "GET", `/api/v2/registrations/${left.id}/full`)).id;
|
||||
expect(selectedId).toBe(left.id);
|
||||
const bar2 = page.getByTestId("bulk-bar");
|
||||
await bar2.getByLabel("Bulk action").selectOption("cancel");
|
||||
page.once("dialog", d => d.accept());
|
||||
await bar2.getByRole("button", { name: /Cancel — 1/ }).click();
|
||||
await expect(page.getByTestId("bulk-result")).toContainText("1 done");
|
||||
const cancelled = (await Promise.all(regs.map(id => api<Reg>(page, "admin", "GET", `/api/registrations/${id}`)))).filter(r => r.status === "cancelled");
|
||||
const cancelled = (await Promise.all(regs.map(id => v2<Reg>(page, "admin", "GET", `/api/v2/registrations/${id}/full`)))).filter(r => r.status === "cancelled");
|
||||
expect(cancelled).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { test, expect, seed, api, loginAs, API } from "./fixtures";
|
||||
import { test, expect, seed, api, loginAs, API, v2 } from "./fixtures";
|
||||
|
||||
// Campus-scoped staff (1.44.0): the seeded staff member and supervisor are limited to E2E South
|
||||
// for these tests; afterwards the limits are cleared and campuses turned off again.
|
||||
test.describe("campus-scoped staff", () => {
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
const page = await browser.newPage();
|
||||
await api(page, "admin", "PUT", "/api/campuses/settings", { enabled: true });
|
||||
await v2(page, "admin", "PUT", "/api/v2/campuses/enabled", { enabled: true });
|
||||
for (const role of ["staff", "supervisor"] as const) {
|
||||
await api(page, "admin", "PUT", `/api/users/${seed().users[role].id}`, { scopedCampusIds: [seed().campuses.south.id] });
|
||||
await v2(page, "admin", "PATCH", `/api/v2/users/${seed().users[role].id}`, { scopedCampusIds: [seed().campuses.south.id] });
|
||||
}
|
||||
await page.close();
|
||||
});
|
||||
@@ -15,17 +15,17 @@ test.describe("campus-scoped staff", () => {
|
||||
test.afterAll(async ({ browser }) => {
|
||||
const page = await browser.newPage();
|
||||
for (const role of ["staff", "supervisor"] as const) {
|
||||
await api(page, "admin", "PUT", `/api/users/${seed().users[role].id}`, { scopedCampusIds: [] });
|
||||
await v2(page, "admin", "PATCH", `/api/v2/users/${seed().users[role].id}`, { scopedCampusIds: [] });
|
||||
}
|
||||
await api(page, "admin", "PUT", "/api/campuses/settings", { enabled: false });
|
||||
await v2(page, "admin", "PUT", "/api/v2/campuses/enabled", { enabled: false });
|
||||
await page.close();
|
||||
});
|
||||
|
||||
test("the scanner refuses another campus's ticket and says which campus", async ({ page }) => {
|
||||
const scan = (qr: string) => page.request.get(`${API}/api/tickets/scan-preview/${encodeURIComponent(qr)}`, { headers: { Authorization: `Bearer ${seed().users.staff.token}` } });
|
||||
const scan = (qr: string) => page.request.get(`${API}/api/v2/checkin/${encodeURIComponent(qr)}`, { headers: { Authorization: `Bearer ${seed().users.staff.token}` } });
|
||||
const north = await scan(seed().northTicketQr);
|
||||
expect(north.status()).toBe(403);
|
||||
expect((await north.json()).message).toBe("This ticket is for an event at E2E North.");
|
||||
expect((await north.json()).error.message).toBe("This ticket is for an event at E2E North.");
|
||||
// The course is for all campuses, so it scans.
|
||||
expect((await scan(seed().course.qrCode)).status()).toBe(200);
|
||||
});
|
||||
@@ -46,7 +46,7 @@ test.describe("campus-scoped staff", () => {
|
||||
});
|
||||
|
||||
test("another campus's registrations are not found for a scoped supervisor", async ({ page }) => {
|
||||
const res = await page.request.get(`${API}/api/registrations/event/${seed().events.free}`, { headers: { Authorization: `Bearer ${seed().users.supervisor.token}` } });
|
||||
const res = await page.request.get(`${API}/api/v2/events/${seed().events.free}/registrations`, { headers: { Authorization: `Bearer ${seed().users.supervisor.token}` } });
|
||||
expect(res.status()).toBe(404);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, seed, api, API } from "./fixtures";
|
||||
import { test, expect, seed, api, API, v2 } from "./fixtures";
|
||||
|
||||
// Multi-campus. The campuses and the two events' campuses are seeded (e2e/support/prepare-db.js)
|
||||
// with campuses off; these tests turn them on, and off again afterwards so the other specs see a
|
||||
@@ -6,13 +6,13 @@ import { test, expect, seed, api, API } from "./fixtures";
|
||||
test.describe("campuses", () => {
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
const page = await browser.newPage();
|
||||
await api(page, "admin", "PUT", "/api/campuses/settings", { enabled: true });
|
||||
await v2(page, "admin", "PUT", "/api/v2/campuses/enabled", { enabled: true });
|
||||
await page.close();
|
||||
});
|
||||
|
||||
test.afterAll(async ({ browser }) => {
|
||||
const page = await browser.newPage();
|
||||
await api(page, "admin", "PUT", "/api/campuses/settings", { enabled: false });
|
||||
await v2(page, "admin", "PUT", "/api/v2/campuses/enabled", { enabled: false });
|
||||
await page.close();
|
||||
});
|
||||
|
||||
@@ -38,8 +38,8 @@ test.describe("campuses", () => {
|
||||
});
|
||||
|
||||
test("a campus with events can't be deleted", async ({ page }) => {
|
||||
const res = await page.request.delete(`${API}/api/campuses/${seed().campuses.north.id}`, { headers: { Authorization: `Bearer ${seed().users.admin.token}` } });
|
||||
const res = await page.request.delete(`${API}/api/v2/campuses/${seed().campuses.north.id}`, { headers: { Authorization: `Bearer ${seed().users.admin.token}` } });
|
||||
expect(res.status()).toBe(409);
|
||||
expect((await res.json()).code).toBe("CAMPUS_HAS_EVENTS");
|
||||
expect((await res.json()).error.reason).toBe("CAMPUS_HAS_EVENTS");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import AxeBuilder from "@axe-core/playwright";
|
||||
import { test, expect, loginAs, api } from "./fixtures";
|
||||
import { test, expect, loginAs, api, v2 } from "./fixtures";
|
||||
|
||||
// 1.50.2: event dropdowns are a searchable picker — upcoming events first, past ones a click
|
||||
// away, and typing searches them all.
|
||||
test.describe("event picker", () => {
|
||||
test("opens on upcoming events; past ones are behind a button or found by searching", async ({ page }) => {
|
||||
const start = new Date(Date.now() - 40 * 864e5);
|
||||
await api(page, "supervisor", "POST", "/api/events", {
|
||||
await v2(page, "supervisor", "POST", "/api/v2/events", {
|
||||
title: "E2E Picker Old Gathering", description: "A past event for the picker test.", price: 0, location: "1 Test Street, Pretoria",
|
||||
startDate: start.toISOString(), endDate: new Date(start.getTime() + 2 * 3600e3).toISOString(),
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ async function open(body: Buffer) {
|
||||
|
||||
test.describe("Excel exports", () => {
|
||||
test("a report with stats, a chart and a table", async ({ request }) => {
|
||||
const res = await request.post(`${API}/api/reports/excel`, {
|
||||
const res = await request.post(`${API}/api/v2/reports/excel`, {
|
||||
headers: { Authorization: `Bearer ${seed().users.supervisor.token}` },
|
||||
data: {
|
||||
title: "E2E Payments",
|
||||
@@ -36,7 +36,7 @@ test.describe("Excel exports", () => {
|
||||
});
|
||||
|
||||
test("the attendance register", async ({ request }) => {
|
||||
const res = await request.get(`${API}/api/attendance/${seed().events.course}/export?format=xlsx`, {
|
||||
const res = await request.get(`${API}/api/v2/events/${seed().events.course}/attendance/export?format=xlsx`, {
|
||||
headers: { Authorization: `Bearer ${seed().users.supervisor.token}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
|
||||
@@ -52,6 +52,11 @@ export async function api<T = unknown>(page: Page, role: Role, method: string, u
|
||||
return (text ? JSON.parse(text) : null) as T;
|
||||
}
|
||||
|
||||
/** Calls `/api/v2` as a seeded user and returns the answer's `data` (throws on an error, like `api`). */
|
||||
export async function v2<T = unknown>(page: Page, role: Role, method: string, url: string, body?: unknown): Promise<T> {
|
||||
return (await api<{ data: T }>(page, role, method, url, body)).data;
|
||||
}
|
||||
|
||||
/** Chooses an event in an EventPicker (the first on the page, or the one labelled `label`) by searching its title. */
|
||||
export async function pickEvent(page: Page, title: string, label?: string) {
|
||||
const button = label ? page.getByRole("button", { name: new RegExp(`^${label}:`) }) : page.getByTestId("event-picker").first().getByRole("button").first();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { test, expect, seed, loginAs, api } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, v2 } from "./fixtures";
|
||||
|
||||
// 1.50.1: long lists load a page (or just what's needed) at a time, with search and filters.
|
||||
test.describe("long lists", () => {
|
||||
test("Payments: today, recent and a person's payments for a refund", async ({ page }) => {
|
||||
// A donation recorded today for the seeded user (on an event no other test totals up).
|
||||
await api(page, "supervisor", "POST", "/api/payments", {
|
||||
await v2(page, "supervisor", "POST", "/api/v2/payments", {
|
||||
amount: 77, method: "cash", isDonation: true, eventId: seed().events.conference, userId: seed().users.user.id,
|
||||
});
|
||||
|
||||
@@ -21,11 +21,11 @@ test.describe("long lists", () => {
|
||||
|
||||
test("Payments API: narrowing filters", async ({ page }) => {
|
||||
const userId = seed().users.user.id;
|
||||
const mine = await api<{ data: { userId: string }[] }>(page, "supervisor", "GET", `/api/payments?userId=${userId}&limit=200`);
|
||||
const mine = await v2<{ data: { userId: string }[] }>(page, "supervisor", "GET", `/api/v2/payments?userId=${userId}&limit=200`);
|
||||
expect(mine.data.length).toBeGreaterThan(0);
|
||||
expect(mine.data.every((p) => p.userId === userId)).toBe(true);
|
||||
|
||||
const unpaid = await api<{ status: string }[]>(page, "supervisor", "GET", "/api/registrations?unpaid=1");
|
||||
const unpaid = await v2<{ status: string }[]>(page, "supervisor", "GET", "/api/v2/registrations?unpaid=true");
|
||||
expect(unpaid.every((r) => ["pending", "confirmed", "partial_paid"].includes(r.status))).toBe(true);
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ test.describe("long lists", () => {
|
||||
});
|
||||
|
||||
test("Data requests: search", async ({ page }) => {
|
||||
const res = await api<{ requests: unknown[]; total: number }>(page, "admin", "GET", "/api/privacy/requests?status=closed&search=nobody-matches-this-xyz");
|
||||
const res = await v2<{ requests: unknown[]; total: number }>(page, "admin", "GET", "/api/v2/privacy/requests?status=closed&search=nobody-matches-this-xyz");
|
||||
expect(res.requests).toEqual([]);
|
||||
expect(res.total).toBe(0);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, seed, loginAs, api } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, v2 } from "./fixtures";
|
||||
|
||||
// Pays into a real PayFast sandbox account, so it needs one:
|
||||
// E2E_PAYFAST_MERCHANT_ID, E2E_PAYFAST_MERCHANT_KEY, E2E_PAYFAST_PASSPHRASE
|
||||
@@ -17,17 +17,17 @@ test.describe("PayFast", () => {
|
||||
test.skip(!PF.merchantId, "Set E2E_PAYFAST_* to test against a PayFast sandbox account");
|
||||
|
||||
test("choose PayFast on the pay page and land on PayFast's payment page", async ({ page }) => {
|
||||
await api(page, "admin", "PUT", "/api/payfast/config", { ...PF, mode: "sandbox" });
|
||||
await v2(page, "admin", "PUT", "/api/v2/payments/payfast/config", { ...PF, mode: "sandbox" });
|
||||
try {
|
||||
await api(page, "admin", "PUT", "/api/payments/providers/settings", { providers: [{ id: "yoco", enabled: true }, { id: "payfast", enabled: true }] });
|
||||
await v2(page, "admin", "PUT", "/api/v2/payments/providers/settings", { providers: [{ id: "yoco", enabled: true }, { id: "payfast", enabled: true }] });
|
||||
|
||||
// A booking for the paid conference, then an online checkout for it
|
||||
const event = await api<EventWithOptions>(page, "staff", "GET", `/api/events/${seed().events.paid}`);
|
||||
const event = await v2<EventWithOptions>(page, "staff", "GET", `/api/v2/events/${seed().events.paid}/full`);
|
||||
const option = event.eventOptions.find((o) => o.isMainTicket)!;
|
||||
const reg = await api<Registration>(page, "staff", "POST", "/api/registrations", { eventId: seed().events.paid, options: [{ eventOptionId: option.id, quantity: 1 }] });
|
||||
const reg = await v2<Registration>(page, "staff", "POST", "/api/v2/registrations", { eventId: seed().events.paid, options: [{ eventOptionId: option.id, quantity: 1 }] });
|
||||
const origin = new URL(page.url() === "about:blank" ? "http://localhost:3100" : page.url()).origin;
|
||||
const checkout = await api<Checkout>(page, "staff", "POST", "/api/payments/checkout", {
|
||||
registrationId: reg.id, successUrl: `${origin}/payment/success`, cancelUrl: `${origin}/payment/cancel`, failureUrl: `${origin}/payment/failure`,
|
||||
const checkout = await v2<Checkout>(page, "staff", "POST", `/api/v2/registrations/${reg.id}/checkout`, {
|
||||
successUrl: `${origin}/payment/success`, cancelUrl: `${origin}/payment/cancel`, failureUrl: `${origin}/payment/failure`,
|
||||
});
|
||||
// Yoco and PayFast are both on, so the payer chooses
|
||||
expect(checkout.provider).toBeNull();
|
||||
@@ -53,8 +53,8 @@ test.describe("PayFast", () => {
|
||||
await expect(row.getByText("Not paid (yet)")).toBeVisible({ timeout: 30_000 });
|
||||
await expect(page.getByText("No new payments found.")).toBeVisible();
|
||||
} finally {
|
||||
await api(page, "admin", "PUT", "/api/payments/providers/settings", { providers: [{ id: "yoco", enabled: true }, { id: "payfast", enabled: false }] });
|
||||
await api(page, "admin", "PUT", "/api/payfast/config", { merchantId: "", merchantKey: "", passphrase: "" });
|
||||
await v2(page, "admin", "PUT", "/api/v2/payments/providers/settings", { providers: [{ id: "yoco", enabled: true }, { id: "payfast", enabled: false }] });
|
||||
await v2(page, "admin", "PUT", "/api/v2/payments/payfast/config", { merchantId: "", merchantKey: "", passphrase: "" });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, seed, loginAs, api } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, v2 } from "./fixtures";
|
||||
|
||||
type ProviderSetting = { id: string; label: string; enabled: boolean; configured: boolean };
|
||||
|
||||
@@ -20,28 +20,28 @@ test.describe("payment providers", () => {
|
||||
await expect(page.getByText(/Online payments are off/)).toBeVisible();
|
||||
// A switched-off provider's settings are hidden
|
||||
await expect(page.getByRole("heading", { name: "Yoco payments" })).toBeHidden();
|
||||
const off = await api<{ providers: { id: string }[]; minimumAmount: number }>(page, "user", "GET", "/api/payments/providers");
|
||||
const off = await v2<{ providers: { id: string }[]; minimumAmount: number }>(page, "user", "GET", "/api/v2/payments/providers");
|
||||
expect(off.providers).toEqual([]);
|
||||
expect(off.minimumAmount).toBe(15);
|
||||
|
||||
await yoco.check();
|
||||
await expect(yoco).toBeChecked();
|
||||
await expect(page.getByRole("heading", { name: "Yoco payments" })).toBeVisible();
|
||||
const settings = await api<{ providers: ProviderSetting[] }>(page, "admin", "GET", "/api/payments/providers/settings");
|
||||
const settings = await v2<{ providers: ProviderSetting[] }>(page, "admin", "GET", "/api/v2/payments/providers/settings");
|
||||
expect(settings.providers.find((p) => p.id === "yoco")?.enabled).toBe(true);
|
||||
} finally {
|
||||
// Leave Yoco on for the other tests.
|
||||
await api(page, "admin", "PUT", "/api/payments/providers/settings", { providers: [{ id: "yoco", enabled: true }] });
|
||||
await v2(page, "admin", "PUT", "/api/v2/payments/providers/settings", { providers: [{ id: "yoco", enabled: true }] });
|
||||
}
|
||||
});
|
||||
|
||||
test("with no provider on, nothing offers to pay online", async ({ page }) => {
|
||||
type EventWithOptions = { eventOptions: { id: string; isMainTicket: boolean }[] };
|
||||
const event = await api<EventWithOptions>(page, "admin", "GET", `/api/events/${seed().events.paid}`);
|
||||
const event = await v2<EventWithOptions>(page, "admin", "GET", `/api/v2/events/${seed().events.paid}/full`);
|
||||
const option = event.eventOptions.find((o) => o.isMainTicket)!;
|
||||
const reg = await api<{ id: string }>(page, "admin", "POST", "/api/registrations", { eventId: seed().events.paid, options: [{ eventOptionId: option.id, quantity: 1 }] });
|
||||
const reg = await v2<{ id: string }>(page, "admin", "POST", "/api/v2/registrations", { eventId: seed().events.paid, options: [{ eventOptionId: option.id, quantity: 1 }] });
|
||||
|
||||
await api(page, "admin", "PUT", "/api/payments/providers/settings", { providers: [{ id: "yoco", enabled: false }, { id: "payfast", enabled: false }] });
|
||||
await v2(page, "admin", "PUT", "/api/v2/payments/providers/settings", { providers: [{ id: "yoco", enabled: false }, { id: "payfast", enabled: false }] });
|
||||
try {
|
||||
await loginAs(page, "admin");
|
||||
await page.goto(`/registration/success?registrationId=${reg.id}`);
|
||||
@@ -53,11 +53,11 @@ test.describe("payment providers", () => {
|
||||
await page.goto("/dashboard/user/donate");
|
||||
await expect(page.getByText(/Online donations aren.t available/)).toBeVisible();
|
||||
} finally {
|
||||
await api(page, "admin", "PUT", "/api/payments/providers/settings", { providers: [{ id: "yoco", enabled: true }, { id: "payfast", enabled: false }] });
|
||||
await v2(page, "admin", "PUT", "/api/v2/payments/providers/settings", { providers: [{ id: "yoco", enabled: true }, { id: "payfast", enabled: false }] });
|
||||
}
|
||||
|
||||
// Back on (when Yoco is set up in this environment), the button returns
|
||||
const on = await api<{ providers: unknown[] }>(page, "admin", "GET", "/api/payments/providers");
|
||||
const on = await v2<{ providers: unknown[] }>(page, "admin", "GET", "/api/v2/payments/providers");
|
||||
if (on.providers.length > 0) {
|
||||
await page.goto(`/registration/success?registrationId=${reg.id}`);
|
||||
await expect(page.getByRole("button", { name: "Pay online" })).toBeVisible();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, seed, loginAs, api, pickEvent } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, pickEvent, v2 } from "./fixtures";
|
||||
|
||||
type Registration = { id: string; eventId: string; user?: { name: string }; registrationOptions: { sessionId?: string | null; sessionIds?: string[]; priceSnapshot: number; quantity: number }[] };
|
||||
type WaitlistEntry = { eventId: string; sessionId: string | null; quantity: number };
|
||||
@@ -20,7 +20,7 @@ test.describe("pick sessions", () => {
|
||||
await page.getByRole("button", { name: "Register", exact: true }).click();
|
||||
await page.waitForURL(/\/registration\/success/);
|
||||
|
||||
const regs = await api<Registration[]>(page, "user", "GET", "/api/registrations/myregistrations");
|
||||
const regs = await v2<Registration[]>(page, "user", "GET", "/api/v2/me/registrations/full");
|
||||
const reg = regs.find((r) => r.eventId === seed().events.dropIn);
|
||||
expect(reg?.registrationOptions.filter((o) => o.sessionId)).toHaveLength(2);
|
||||
});
|
||||
@@ -39,7 +39,7 @@ test.describe("pick sessions", () => {
|
||||
await page.getByRole("button", { name: "Register", exact: true }).click();
|
||||
await page.waitForURL(/\/registration\/success/);
|
||||
|
||||
const regs = await api<Registration[]>(page, "user", "GET", "/api/registrations/myregistrations");
|
||||
const regs = await v2<Registration[]>(page, "user", "GET", "/api/v2/me/registrations/full");
|
||||
const line = regs.find((r) => r.eventId === seed().events.conference)?.registrationOptions[0];
|
||||
expect(line?.sessionId ?? null).toBeNull();
|
||||
expect(line?.sessionIds).toHaveLength(2);
|
||||
@@ -58,7 +58,7 @@ test.describe("pick sessions", () => {
|
||||
await page.locator("form").filter({ hasText: "Join the waitlist" }).getByRole("button", { name: "Join waitlist" }).click();
|
||||
await expect(page.getByText(/You're on the waitlist/)).toBeVisible();
|
||||
|
||||
const mine = await api<WaitlistEntry[]>(page, "admin", "GET", "/api/waitlist/mine");
|
||||
const mine = await v2<WaitlistEntry[]>(page, "admin", "GET", "/api/v2/me/waitlist");
|
||||
const entry = mine.find((e) => e.eventId === seed().events.dropIn);
|
||||
expect(entry?.sessionId).toBeTruthy();
|
||||
expect(entry?.quantity).toBe(1);
|
||||
@@ -86,7 +86,7 @@ test.describe("pick sessions", () => {
|
||||
await page.getByRole("button", { name: "Confirm Registration" }).click();
|
||||
await expect(page.getByText("Select Items")).toBeHidden();
|
||||
|
||||
const regs = await api<Registration[]>(page, "supervisor", "GET", `/api/registrations/event/${seed().events.dropIn}`);
|
||||
const regs = await v2<Registration[]>(page, "supervisor", "GET", `/api/v2/events/${seed().events.dropIn}/registrations`);
|
||||
const reg = regs.find((r) => r.user?.name === "Door Walk In");
|
||||
expect(reg?.registrationOptions.filter((o) => o.sessionId)).toHaveLength(1);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, seed, loginAs, api, API, type Role } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, API, type Role, v2 } from "./fixtures";
|
||||
|
||||
type Section = { id: string; title: string; body: string };
|
||||
type Draft = { sections: Section[]; versions: { version: number; acceptances: number }[] };
|
||||
@@ -13,12 +13,12 @@ test.describe("privacy notice, operators and access log (POPIA)", () => {
|
||||
test.afterAll(async ({ request }) => {
|
||||
const tokens = [...(["admin", "supervisor", "staff", "user"] as Role[]).map(r => seed().users[r].token), seed().newsPromptUser.token, seed().noticeFirstUser.token];
|
||||
for (const token of tokens) {
|
||||
await request.post(`${API}/api/privacy/me/notice/accept`, { headers: { Authorization: `Bearer ${token}` } });
|
||||
await request.post(`${API}/api/v2/me/privacy/notice/accept`, { headers: { Authorization: `Bearer ${token}` } });
|
||||
}
|
||||
});
|
||||
|
||||
test("the built-in notice is shown until a version is published, with the operator register filled in", async ({ page }) => {
|
||||
const notice = await (await page.request.get(`${API}/api/privacy/notice`)).json() as Notice;
|
||||
const notice = await (await (await page.request.get(`${API}/api/v2/privacy/notice`)).json()).data as Notice;
|
||||
expect(notice.version).toBe(0);
|
||||
expect(notice.sections.find(s => s.id === "sharing")?.body).toContain("• PayFast (South Africa)");
|
||||
|
||||
@@ -29,7 +29,7 @@ test.describe("privacy notice, operators and access log (POPIA)", () => {
|
||||
|
||||
test("an admin edits and publishes; operators feed the notice", async ({ page }) => {
|
||||
// A new operator appears in the notice's {operators} list.
|
||||
const op = await api<Operator>(page, "admin", "POST", "/api/privacy/operators", { name: "E2E Mailer", purpose: "Sending emails", dataShared: "Email address", location: "Ireland" });
|
||||
const op = await v2<Operator>(page, "admin", "POST", "/api/v2/privacy/operators", { name: "E2E Mailer", purpose: "Sending emails", dataShared: "Email address", location: "Ireland" });
|
||||
|
||||
await loginAs(page, "admin");
|
||||
await page.goto("/dashboard/admin/privacy?tab=notice");
|
||||
@@ -40,7 +40,7 @@ test.describe("privacy notice, operators and access log (POPIA)", () => {
|
||||
await expect(page.getByText("Draft saved.")).toBeVisible();
|
||||
|
||||
// Nothing public changes until it's published.
|
||||
expect(((await (await page.request.get(`${API}/api/privacy/notice`)).json()) as Notice).version).toBe(0);
|
||||
expect(((await (await page.request.get(`${API}/api/v2/privacy/notice`)).json()).data as Notice).version).toBe(0);
|
||||
|
||||
await page.getByRole("button", { name: "Publish…" }).click();
|
||||
await page.getByPlaceholder("e.g. We now use PayFast for online payments.").fill("Clearer introduction.");
|
||||
@@ -52,15 +52,15 @@ test.describe("privacy notice, operators and access log (POPIA)", () => {
|
||||
await expect(page.getByText("• E2E Mailer (Ireland) — Sending emails.", { exact: false })).toBeVisible();
|
||||
await expect(page.getByText(/Version 1/).first()).toBeVisible();
|
||||
|
||||
await api(page, "admin", "DELETE", `/api/privacy/operators/${op.id}`);
|
||||
await v2(page, "admin", "DELETE", `/api/v2/privacy/operators/${op.id}`);
|
||||
});
|
||||
|
||||
test("after publishing its own version, the editor points out new built-in text", async ({ page }) => {
|
||||
// The published version came from the built-in text; put an older wording back in one changed
|
||||
// section so it shows as having new text.
|
||||
const draft = await api<Draft>(page, "admin", "GET", "/api/privacy/notice/draft");
|
||||
const draft = await v2<Draft>(page, "admin", "GET", "/api/v2/privacy/notice/draft");
|
||||
const sections = draft.sections.map(s => (s.id === "changes" ? { ...s, body: "We may update this notice from time to time." } : s));
|
||||
await api(page, "admin", "PUT", "/api/privacy/notice/draft", { sections });
|
||||
await v2(page, "admin", "PUT", "/api/v2/privacy/notice/draft", { sections });
|
||||
|
||||
await loginAs(page, "admin");
|
||||
await page.goto("/dashboard/admin/privacy?tab=notice");
|
||||
@@ -80,7 +80,7 @@ test.describe("privacy notice, operators and access log (POPIA)", () => {
|
||||
await page.reload();
|
||||
await expect(page.getByLabel("1. Introduction text")).toBeVisible();
|
||||
await expect(page.getByTestId("builtin-updates")).toHaveCount(0);
|
||||
await api(page, "admin", "DELETE", "/api/privacy/notice/draft");
|
||||
await v2(page, "admin", "DELETE", "/api/v2/privacy/notice/draft");
|
||||
});
|
||||
|
||||
test("someone who never accepted the notice is asked once, after login", async ({ page }) => {
|
||||
@@ -102,10 +102,10 @@ test.describe("privacy notice, operators and access log (POPIA)", () => {
|
||||
});
|
||||
|
||||
test("a significant change is accepted once, after login", async ({ page }) => {
|
||||
const draft = await api<Draft>(page, "admin", "GET", "/api/privacy/notice/draft");
|
||||
const draft = await v2<Draft>(page, "admin", "GET", "/api/v2/privacy/notice/draft");
|
||||
// Re-acceptance needs a summary of what changed.
|
||||
await expect(api(page, "admin", "POST", "/api/privacy/notice/publish", { sections: draft.sections, requiresAcceptance: true })).rejects.toThrow(/400/);
|
||||
const published = await api<{ version: number }>(page, "admin", "POST", "/api/privacy/notice/publish", { sections: draft.sections, requiresAcceptance: true, changeSummary: "We added WhatsApp news." });
|
||||
await expect(v2(page, "admin", "POST", "/api/v2/privacy/notice/publish", { sections: draft.sections, requiresAcceptance: true })).rejects.toThrow(/400/);
|
||||
const published = await v2<{ version: number }>(page, "admin", "POST", "/api/v2/privacy/notice/publish", { sections: draft.sections, requiresAcceptance: true, changeSummary: "We added WhatsApp news." });
|
||||
|
||||
await loginAs(page, "user");
|
||||
await page.goto("/dashboard/user");
|
||||
@@ -118,19 +118,19 @@ test.describe("privacy notice, operators and access log (POPIA)", () => {
|
||||
await expect(page.getByText("My Events").first()).toBeVisible();
|
||||
await expect(page.getByRole("dialog", { name: "We've updated our privacy notice" })).toHaveCount(0);
|
||||
|
||||
const log = await api<ConsentLog>(page, "admin", "GET", `/api/privacy/consent-log?type=notice&q=${encodeURIComponent(seed().users.user.email)}`);
|
||||
const log = await v2<ConsentLog>(page, "admin", "GET", `/api/v2/privacy/consent-log?type=notice&q=${encodeURIComponent(seed().users.user.email)}`);
|
||||
expect(log.rows[0]).toMatchObject({ version: published.version, source: "prompt" });
|
||||
});
|
||||
|
||||
test("bulk exports are in the access log", async ({ page }) => {
|
||||
const res = await page.request.post(`${API}/api/reports/pdf`, {
|
||||
const res = await page.request.post(`${API}/api/v2/reports/pdf`, {
|
||||
headers: { Authorization: `Bearer ${seed().users.supervisor.token}`, "Content-Type": "application/json" },
|
||||
data: JSON.stringify({ title: "E2E attendee list", kind: "table", table: { columns: ["Name"], rows: [["A"], ["B"], ["C"]] } }),
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
await api(page, "supervisor", "GET", `/api/consent/events/${seed().events.free}`);
|
||||
await v2(page, "supervisor", "GET", `/api/v2/events/${seed().events.free}/consent`);
|
||||
|
||||
const log = await api<AccessLog>(page, "admin", "GET", "/api/privacy/access-log");
|
||||
const log = await v2<AccessLog>(page, "admin", "GET", "/api/v2/privacy/access-log");
|
||||
expect(log.rows.find(r => r.action === "report_pdf")).toMatchObject({ what: "E2E attendee list", records: 3, actor: "Sam Supervisor" });
|
||||
expect(log.rows.some(r => r.action === "consent_list")).toBe(true);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, seed, loginAs, api } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, v2 } from "./fixtures";
|
||||
|
||||
type RunResult = { result: Record<string, Record<string, number>> };
|
||||
type UserRow = { name: string; email: string; isActive: boolean };
|
||||
@@ -7,32 +7,32 @@ type Breach = { id: string; status: string; regulatorNotifiedAt: string | null }
|
||||
|
||||
test.describe("retention, breaches and readiness (POPIA)", () => {
|
||||
test("the retention job warns inactive accounts first, and anonymises them 30 days after the warning", async ({ page }) => {
|
||||
const { result } = await api<RunResult>(page, "admin", "POST", "/api/privacy/retention/run");
|
||||
const { result } = await v2<RunResult>(page, "admin", "POST", "/api/v2/privacy/retention/run");
|
||||
expect(result.inactive_accounts.warned).toBeGreaterThanOrEqual(1);
|
||||
expect(result.inactive_accounts.anonymised).toBeGreaterThanOrEqual(1);
|
||||
expect(result.login_history.deleted).toBeGreaterThanOrEqual(1);
|
||||
|
||||
const warned = await api<UserRow>(page, "admin", "GET", `/api/users/${seed().retention.toWarn}`);
|
||||
const warned = await v2<UserRow>(page, "admin", "GET", `/api/v2/users/${seed().retention.toWarn}`);
|
||||
expect(warned.email).toBe("dormant@e2e.test");
|
||||
const gone = await api<UserRow>(page, "admin", "GET", `/api/users/${seed().retention.toAnonymise}`);
|
||||
const gone = await v2<UserRow>(page, "admin", "GET", `/api/v2/users/${seed().retention.toAnonymise}`);
|
||||
expect(gone.name).toBe("Deleted User");
|
||||
expect(gone.email).toMatch(/@deleted\.invalid$/);
|
||||
|
||||
// Seeded accounts (staff roles, and the recently active user) are untouched.
|
||||
expect((await api<UserRow>(page, "admin", "GET", `/api/users/${seed().users.user.id}`)).email).toBe("user@e2e.test");
|
||||
expect((await v2<UserRow>(page, "admin", "GET", `/api/v2/users/${seed().users.user.id}`)).email).toBe("user@e2e.test");
|
||||
});
|
||||
|
||||
test("retention periods are validated and saved; the notice follows them", async ({ page }) => {
|
||||
const state = await api<{ policies: Record<string, { enabled: boolean; months: number }> }>(page, "admin", "GET", "/api/privacy/retention");
|
||||
await expect(api(page, "admin", "PUT", "/api/privacy/retention", { policies: { ...state.policies, inactive_accounts: { enabled: true, months: 3 } } })).rejects.toThrow(/400/);
|
||||
await api(page, "admin", "PUT", "/api/privacy/retention", { policies: { ...state.policies, form_answers: { enabled: true, months: 18 } } });
|
||||
const state = await v2<{ policies: Record<string, { enabled: boolean; months: number }> }>(page, "admin", "GET", "/api/v2/privacy/retention");
|
||||
await expect(v2(page, "admin", "PUT", "/api/v2/privacy/retention", { policies: { ...state.policies, inactive_accounts: { enabled: true, months: 3 } } })).rejects.toThrow(/400/);
|
||||
await v2(page, "admin", "PUT", "/api/v2/privacy/retention", { policies: { ...state.policies, form_answers: { enabled: true, months: 18 } } });
|
||||
|
||||
await page.goto("/legal/privacy");
|
||||
await expect(page.getByText("Answers to event forms are deleted 18 months after the event.", { exact: false })).toBeVisible();
|
||||
});
|
||||
|
||||
test("a breach is recorded, reported, and drafts are ready to copy", async ({ page }) => {
|
||||
const breach = await api<Breach>(page, "admin", "POST", "/api/privacy/breaches", {
|
||||
const breach = await v2<Breach>(page, "admin", "POST", "/api/v2/privacy/breaches", {
|
||||
title: "Phone with the attendee list lost", discoveredAt: new Date().toISOString(),
|
||||
description: "A leader's phone was stolen at the camp site.", dataAffected: "Names and phone numbers of 40 campers",
|
||||
});
|
||||
@@ -46,12 +46,12 @@ test.describe("retention, breaches and readiness (POPIA)", () => {
|
||||
await page.getByRole("button", { name: "Regulator told today" }).click();
|
||||
await expect(page.getByRole("button", { name: "Regulator told today" })).toHaveCount(0);
|
||||
|
||||
const list = await api<Breach[]>(page, "admin", "GET", "/api/privacy/breaches");
|
||||
const list = await v2<Breach[]>(page, "admin", "GET", "/api/v2/privacy/breaches");
|
||||
expect(list.find(b => b.id === breach.id)?.regulatorNotifiedAt).toBeTruthy();
|
||||
});
|
||||
|
||||
test("the readiness page scores the install", async ({ page }) => {
|
||||
const r = await api<Readiness>(page, "admin", "GET", "/api/privacy/readiness");
|
||||
const r = await v2<Readiness>(page, "admin", "GET", "/api/v2/privacy/readiness");
|
||||
expect(r.score).toBeGreaterThan(0);
|
||||
expect(r.checks.find(c => c.key === "retention_reviewed")?.ok).toBe(true);
|
||||
expect(r.checks.find(c => c.key === "retention_running")?.ok).toBe(false); // jobs are off in e2e
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { test, expect, seed, loginAs, api, API } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, API, v2 } from "./fixtures";
|
||||
|
||||
type Account = { id: string; token: string; email: string };
|
||||
type PrivacyInfo = { news: { email: boolean; whatsapp: boolean }; history: { source: string }[]; requests: { type: string; status: string }[] };
|
||||
@@ -9,12 +9,12 @@ type Requests = { requests: { id: string; type: string; userId: string; blockers
|
||||
/** A brand-new account made through sign-up, so tests can change it freely. */
|
||||
async function signUp(page: Page, newsOptIn: boolean): Promise<Account> {
|
||||
const email = `privacy-${Date.now()}-${Math.floor(Math.random() * 1e6)}@e2e.test`;
|
||||
const res = await page.request.post(`${API}/api/users`, {
|
||||
data: { name: "Pat Privacy", email, password: "E2e-password-123", newsOptIn },
|
||||
const res = await page.request.post(`${API}/api/v2/auth/signup`, {
|
||||
data: { name: "Pat Privacy", email, password: "E2e-password-123", newsOptIn, acceptTerms: true },
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
return { id: body.id, token: body.token, email };
|
||||
const { data } = await res.json();
|
||||
return { id: data.user.id, token: data.token, email };
|
||||
}
|
||||
|
||||
async function asAccount<T>(page: Page, account: Account, method: string, url: string, body?: unknown) {
|
||||
@@ -23,13 +23,15 @@ async function asAccount<T>(page: Page, account: Account, method: string, url: s
|
||||
headers: { Authorization: `Bearer ${account.token}`, "Content-Type": "application/json" },
|
||||
data: body === undefined ? undefined : JSON.stringify(body),
|
||||
});
|
||||
return { status: res.status(), body: (await res.json().catch(() => null)) as T };
|
||||
// v2 answers { data }; a download (my data) is the file itself.
|
||||
const json = await res.json().catch(() => null);
|
||||
return { status: res.status(), body: (json && typeof json === "object" && "data" in json ? json.data : json) as T };
|
||||
}
|
||||
|
||||
test.describe("privacy (POPIA)", () => {
|
||||
test("sign-up records the news choice; the privacy page changes it and downloads my data", async ({ page }) => {
|
||||
const me = await signUp(page, false);
|
||||
const before = await asAccount<PrivacyInfo>(page, me, "GET", "/api/privacy/me");
|
||||
const before = await asAccount<PrivacyInfo>(page, me, "GET", "/api/v2/me/privacy");
|
||||
expect(before.body.news.email).toBe(false);
|
||||
expect(before.body.history.map((h) => h.source)).toContain("signup");
|
||||
|
||||
@@ -41,7 +43,7 @@ test.describe("privacy (POPIA)", () => {
|
||||
await expect(page.getByText("You're subscribed.")).toBeVisible();
|
||||
await expect(byEmail).toBeChecked();
|
||||
|
||||
const exported = await asAccount<{ account: { email: string }; communication: { news: { email: boolean } } }>(page, me, "GET", "/api/privacy/me/export");
|
||||
const exported = await asAccount<{ account: { email: string }; communication: { news: { email: boolean } } }>(page, me, "GET", "/api/v2/me/privacy/export");
|
||||
expect(exported.status).toBe(200);
|
||||
expect(exported.body.account.email).toBe(me.email);
|
||||
expect(exported.body.communication.news.email).toBe(true);
|
||||
@@ -49,10 +51,10 @@ test.describe("privacy (POPIA)", () => {
|
||||
|
||||
test("news broadcasts skip people who aren't opted in; event updates don't", async ({ page }) => {
|
||||
const out = await signUp(page, false);
|
||||
const news = await api<Preview>(page, "supervisor", "POST", "/api/broadcasts/preview", { userIds: [out.id, seed().users.admin.id], emails: "", kind: "news" });
|
||||
const news = await v2<Preview>(page, "supervisor", "POST", "/api/v2/broadcasts/email/preview", { userIds: [out.id, seed().users.admin.id], emails: "", kind: "news" });
|
||||
expect(news.matched).toBe(1);
|
||||
expect(news.skipped).toBe(1);
|
||||
const update = await api<Preview>(page, "supervisor", "POST", "/api/broadcasts/preview", { userIds: [out.id, seed().users.admin.id], emails: "", kind: "update" });
|
||||
const update = await v2<Preview>(page, "supervisor", "POST", "/api/v2/broadcasts/email/preview", { userIds: [out.id, seed().users.admin.id], emails: "", kind: "update" });
|
||||
expect(update.matched).toBe(2);
|
||||
expect(update.skipped).toBe(0);
|
||||
});
|
||||
@@ -61,11 +63,11 @@ test.describe("privacy (POPIA)", () => {
|
||||
await page.goto(`/unsubscribe?t=${encodeURIComponent(seed().unsubscribeToken)}`);
|
||||
await page.getByRole("button", { name: "Unsubscribe from all news" }).click();
|
||||
await expect(page.getByText(/You're unsubscribed from news and announcements/)).toBeVisible();
|
||||
const after = await api<PrivacyInfo>(page, "user", "GET", "/api/privacy/me");
|
||||
const after = await v2<PrivacyInfo>(page, "user", "GET", "/api/v2/me/privacy");
|
||||
expect(after.news).toEqual({ email: false, whatsapp: false });
|
||||
expect(after.history.some((h) => h.source === "unsubscribe_link")).toBe(true);
|
||||
|
||||
const bad = await page.request.get(`${API}/api/privacy/unsubscribe/not-a-real-token`);
|
||||
const bad = await page.request.get(`${API}/api/v2/unsubscribe/not-a-real-token`);
|
||||
expect(bad.status()).toBe(404);
|
||||
});
|
||||
|
||||
@@ -84,17 +86,17 @@ test.describe("privacy (POPIA)", () => {
|
||||
|
||||
test("delete my account: closed at once, anonymised when an admin completes the request", async ({ page }) => {
|
||||
const me = await signUp(page, true);
|
||||
const wrong = await asAccount(page, me, "POST", "/api/privacy/me/requests", { type: "deletion", password: "nope" });
|
||||
const wrong = await asAccount(page, me, "POST", "/api/v2/me/privacy/requests", { type: "deletion", password: "nope" });
|
||||
expect(wrong.status).toBe(400);
|
||||
const made = await asAccount(page, me, "POST", "/api/privacy/me/requests", { type: "deletion", password: "E2e-password-123" });
|
||||
const made = await asAccount(page, me, "POST", "/api/v2/me/privacy/requests", { type: "deletion", password: "E2e-password-123" });
|
||||
expect(made.status).toBe(201);
|
||||
|
||||
// The account is closed: the old session no longer works, and logging in is refused.
|
||||
expect((await asAccount(page, me, "GET", "/api/privacy/me")).status).toBe(401);
|
||||
const login = await page.request.post(`${API}/api/users/login`, { data: { email: me.email, password: "E2e-password-123" } });
|
||||
expect((await asAccount(page, me, "GET", "/api/v2/me/privacy")).status).toBe(401);
|
||||
const login = await page.request.post(`${API}/api/v2/auth/login`, { data: { identifier: me.email, password: "E2e-password-123" } });
|
||||
expect(login.ok()).toBe(false);
|
||||
|
||||
const inbox = await api<Requests>(page, "admin", "GET", "/api/privacy/requests?status=open");
|
||||
const inbox = await v2<Requests>(page, "admin", "GET", "/api/v2/privacy/requests?status=open");
|
||||
const request = inbox.requests.find((r) => r.userId === me.id);
|
||||
expect(request?.type).toBe("deletion");
|
||||
expect(request?.blockers).toEqual([]);
|
||||
@@ -103,8 +105,8 @@ test.describe("privacy (POPIA)", () => {
|
||||
await loginAs(page, "admin");
|
||||
await page.goto("/dashboard/admin/data-requests");
|
||||
await expect(page.getByText(me.email)).toBeVisible();
|
||||
await api(page, "admin", "POST", `/api/privacy/requests/${request!.id}/complete`, {});
|
||||
const user = await api<{ name: string; email: string }>(page, "admin", "GET", `/api/users/${me.id}`);
|
||||
await v2(page, "admin", "POST", `/api/v2/privacy/requests/${request!.id}/complete`, {});
|
||||
const user = await v2<{ name: string; email: string }>(page, "admin", "GET", `/api/v2/users/${me.id}`);
|
||||
expect(user.name).toBe("Deleted User");
|
||||
expect(user.email).toMatch(/@deleted\.invalid$/);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, seed, loginAs, api } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, v2 } from "./fixtures";
|
||||
|
||||
type Registration = { id: string; status: string; eventId: string };
|
||||
type Ticket = { id: string; qrCode: string; eventId: string };
|
||||
@@ -14,7 +14,7 @@ test.describe("registration → payment → ticket → check-in → cashup", ()
|
||||
await page.getByRole("button", { name: "Register", exact: true }).click();
|
||||
await page.waitForURL(/\/registration\/success/);
|
||||
|
||||
const tickets = await api<Ticket[]>(page, "user", "GET", "/api/tickets/mytickets");
|
||||
const tickets = await v2<Ticket[]>(page, "user", "GET", "/api/v2/me/tickets");
|
||||
expect(tickets.some((t) => t.eventId === seed().events.free)).toBe(true);
|
||||
});
|
||||
|
||||
@@ -26,14 +26,14 @@ test.describe("registration → payment → ticket → check-in → cashup", ()
|
||||
await page.getByRole("button", { name: "Register", exact: true }).click();
|
||||
await page.waitForURL(/\/registration\/success/);
|
||||
|
||||
const regs = await api<Registration[]>(page, "user", "GET", "/api/registrations/myregistrations");
|
||||
const regs = await v2<Registration[]>(page, "user", "GET", "/api/v2/me/registrations/full");
|
||||
const reg = regs.find((r) => r.eventId === seed().events.paid);
|
||||
expect(reg?.status).not.toBe("paid");
|
||||
expect((await api<Ticket[]>(page, "user", "GET", "/api/tickets/mytickets")).some((t) => t.eventId === seed().events.paid)).toBe(false);
|
||||
expect((await v2<Ticket[]>(page, "user", "GET", "/api/v2/me/tickets")).some((t) => t.eventId === seed().events.paid)).toBe(false);
|
||||
|
||||
// A supervisor records the cash payment at the desk.
|
||||
await api(page, "supervisor", "POST", "/api/payments", { amount: 150, method: "cash", registrationId: reg!.id, eventId: seed().events.paid, userId: seed().users.user.id });
|
||||
const ticket = (await api<Ticket[]>(page, "user", "GET", "/api/tickets/mytickets")).find((t) => t.eventId === seed().events.paid);
|
||||
await v2(page, "supervisor", "POST", "/api/v2/payments", { amount: 150, method: "cash", registrationId: reg!.id, eventId: seed().events.paid, userId: seed().users.user.id });
|
||||
const ticket = (await v2<Ticket[]>(page, "user", "GET", "/api/v2/me/tickets")).find((t) => t.eventId === seed().events.paid);
|
||||
expect(ticket).toBeTruthy();
|
||||
|
||||
// My Events shows it.
|
||||
@@ -41,11 +41,11 @@ test.describe("registration → payment → ticket → check-in → cashup", ()
|
||||
await expect(page.getByText("E2E Paid Conference").first()).toBeVisible();
|
||||
|
||||
// Staff check it in; a second scan is refused.
|
||||
await api(page, "staff", "POST", `/api/tickets/scan/${ticket!.qrCode}`, { qty: 1 });
|
||||
await expect(api(page, "staff", "POST", `/api/tickets/scan/${ticket!.qrCode}`, { qty: 1 })).rejects.toThrow(/403.*fully used/);
|
||||
expect((await v2<{ outcome: string }>(page, "staff", "POST", `/api/v2/checkin/${ticket!.qrCode}`, { people: 1 })).outcome).toBe("checked_in");
|
||||
expect(await v2(page, "staff", "POST", `/api/v2/checkin/${ticket!.qrCode}`, { people: 1 })).toMatchObject({ outcome: "already_used", message: expect.stringMatching(/fully used/) });
|
||||
|
||||
// Cashup: the R150 cash is on the supervisor who took it.
|
||||
const cash = await api<CashByUser>(page, "supervisor", "GET", `/api/cashups/event/${seed().events.paid}/cash-by-user`);
|
||||
const cash = await v2<CashByUser>(page, "supervisor", "GET", `/api/v2/events/${seed().events.paid}/cashup/cash-by-user`);
|
||||
const mine = cash.rows.find((r) => r.userId === seed().users.supervisor.id);
|
||||
expect(mine?.cash.total).toBe(150);
|
||||
expect(mine?.cash.count).toBe(1);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, loginAs, api, seed, API } from "./fixtures";
|
||||
import { test, expect, loginAs, api, seed, API, v2 } from "./fixtures";
|
||||
|
||||
// Event series (1.47.1): a supervisor makes a series, events join it, the public series page
|
||||
// lists them, an event page links to the next one, a user follows it, and the series job tells
|
||||
@@ -28,12 +28,12 @@ test.describe.serial("event series", () => {
|
||||
await expect(page.getByRole("status")).toContainText("E2E Breakfast");
|
||||
await expect(page.getByTestId("series-row").filter({ hasText: "E2E Breakfast" })).toContainText("/series/e2e-breakfast");
|
||||
|
||||
const all = await api<Series[]>(page, "supervisor", "GET", "/api/series");
|
||||
const all = await v2<Series[]>(page, "supervisor", "GET", "/api/v2/series");
|
||||
series = all.find((s) => s.name === "E2E Breakfast")!;
|
||||
past = await api<Created>(page, "supervisor", "POST", "/api/events", event("E2E Breakfast (last month)", -30, series.id));
|
||||
next = await api<Created>(page, "supervisor", "POST", "/api/events", event("E2E Breakfast (next month)", 30, series.id));
|
||||
past = await v2<Created>(page, "supervisor", "POST", "/api/v2/events", event("E2E Breakfast (last month)", -30, series.id));
|
||||
next = await v2<Created>(page, "supervisor", "POST", "/api/v2/events", event("E2E Breakfast (next month)", 30, series.id));
|
||||
// Both are live already; announce them now so only the event made after following counts below.
|
||||
await api<JobRun>(page, "admin", "POST", "/api/admin/jobs/series/run");
|
||||
await v2<JobRun>(page, "admin", "POST", "/api/v2/admin/jobs/series/run");
|
||||
});
|
||||
|
||||
test("the series page lists what's coming up and what's past", async ({ page }) => {
|
||||
@@ -56,10 +56,10 @@ test.describe.serial("event series", () => {
|
||||
await page.getByRole("button", { name: "Follow this series" }).click();
|
||||
await expect(page.getByRole("button", { name: "Unfollow" })).toBeVisible();
|
||||
|
||||
await api<Created>(page, "supervisor", "POST", "/api/events", event("E2E Breakfast (in two months)", 60, series.id));
|
||||
const first = await api<JobRun>(page, "admin", "POST", "/api/admin/jobs/series/run");
|
||||
await v2<Created>(page, "supervisor", "POST", "/api/v2/events", event("E2E Breakfast (in two months)", 60, series.id));
|
||||
const first = await v2<JobRun>(page, "admin", "POST", "/api/v2/admin/jobs/series/run");
|
||||
expect(first.output.announced).toBe(1);
|
||||
const again = await api<JobRun>(page, "admin", "POST", "/api/admin/jobs/series/run");
|
||||
const again = await v2<JobRun>(page, "admin", "POST", "/api/v2/admin/jobs/series/run");
|
||||
expect(again.output.announced).toBe(0);
|
||||
});
|
||||
|
||||
@@ -86,17 +86,17 @@ test.describe.serial("event series", () => {
|
||||
await expect(page.getByTestId("my-passes").getByRole("button", { name: "Pay now" })).toBeVisible();
|
||||
|
||||
type Mine = { id: string; total: number; registrations: { id: string; event: { title: string } }[] }[];
|
||||
const [purchase] = await api<Mine>(page, "user", "GET", "/api/season-passes/mine");
|
||||
const [purchase] = await v2<Mine>(page, "user", "GET", "/api/v2/me/season-passes");
|
||||
expect(purchase.total).toBe(60);
|
||||
expect(purchase.registrations.map((r) => r.event.title).sort()).toEqual(["E2E Breakfast (in two months)", "E2E Breakfast (next month)"]);
|
||||
// Each event's registration owes its share: 2 × R15.
|
||||
type Reg = { id: string; totalDueComputed?: number; registrationOptions: { quantity: number; priceSnapshot: number }[] };
|
||||
const regs = await api<Reg[]>(page, "supervisor", "GET", `/api/registrations/event/${next.id}`);
|
||||
const regs = await v2<Reg[]>(page, "supervisor", "GET", `/api/v2/events/${next.id}/registrations`);
|
||||
const fromPass = regs.find((r) => r.id === purchase.registrations.find((x) => x.event.title === "E2E Breakfast (next month)")!.id)!;
|
||||
expect(fromPass.registrationOptions[0]).toMatchObject({ quantity: 2, priceSnapshot: 15 });
|
||||
|
||||
// A pass registration keeps its tickets as bought: no codes.
|
||||
const res = await page.request.post(`${API}/api/registrations/${fromPass.id}/coupon`, {
|
||||
const res = await page.request.post(`${API}/api/v2/registrations/${fromPass.id}/coupon`, {
|
||||
headers: { Authorization: `Bearer ${seed().users.user.token}` }, data: { code: "ANY" },
|
||||
});
|
||||
expect(res.status()).toBe(409);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { test, expect, seed, loginAs, api, pickEvent } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, pickEvent, v2 } from "./fixtures";
|
||||
|
||||
test.describe("multi-day events", () => {
|
||||
test("check-in is once per session, and the register and certificates follow", async ({ page }) => {
|
||||
const { course, events } = seed();
|
||||
|
||||
// Scanning today: Week 2.
|
||||
const scan = await api<{ session: { label: string } }>(page, "staff", "POST", `/api/tickets/scan/${course.qrCode}`, { qty: 1 });
|
||||
const scan = await v2<{ session: { label: string } }>(page, "staff", "POST", `/api/v2/checkin/${course.qrCode}`, { people: 1 });
|
||||
expect(scan.session.label).toBe("Week 2");
|
||||
await expect(api(page, "staff", "POST", `/api/tickets/scan/${course.qrCode}`, { qty: 1 })).rejects.toThrow(/Already checked in for Week 2/);
|
||||
expect(await v2(page, "staff", "POST", `/api/v2/checkin/${course.qrCode}`, { people: 1 })).toMatchObject({ outcome: "already_used", message: expect.stringMatching(/Already checked in for Week 2/) });
|
||||
|
||||
// The register shows weeks 1 and 2 ticked.
|
||||
await loginAs(page, "supervisor");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, seed, loginAs, api, pickEvent } from "./fixtures";
|
||||
import { test, expect, seed, loginAs, api, pickEvent, v2 } from "./fixtures";
|
||||
|
||||
type EventRow = { id: string; title: string; scheduleType?: string; sessions?: { cancelled?: boolean }[] };
|
||||
|
||||
@@ -26,7 +26,7 @@ test.describe("supervisor tools", () => {
|
||||
|
||||
const row = page.locator("li", { hasText: "E2E Wizard Course" });
|
||||
await expect(row.getByText(/5 sessions · /)).toBeVisible();
|
||||
const all = await api<EventRow[]>(page, "supervisor", "GET", "/api/events/all");
|
||||
const all = await v2<EventRow[]>(page, "supervisor", "GET", "/api/v2/events/manage");
|
||||
const created = all.find((e) => e.title === "E2E Wizard Course");
|
||||
expect(created?.scheduleType).toBe("sessions");
|
||||
expect(created?.sessions?.filter((s) => !s.cancelled)).toHaveLength(5);
|
||||
@@ -34,7 +34,7 @@ test.describe("supervisor tools", () => {
|
||||
|
||||
test("copy an event: the popup is filled in and every date moves with the new start", async ({ page }) => {
|
||||
type Full = EventRow & { eventOptions: { name: string; price: number }[]; sessions: { startsAt: string; label?: string | null }[] };
|
||||
const source = await api<Full>(page, "supervisor", "GET", `/api/events/${seed().events.course}`);
|
||||
const source = await v2<Full>(page, "supervisor", "GET", `/api/v2/events/${seed().events.course}/full`);
|
||||
|
||||
await loginAs(page, "supervisor");
|
||||
await page.goto("/dashboard/supervisor/events");
|
||||
@@ -57,10 +57,10 @@ test.describe("supervisor tools", () => {
|
||||
await create.click();
|
||||
await expect(page.getByRole("heading", { name: "Copy Event" })).toBeHidden();
|
||||
|
||||
const all = await api<EventRow[]>(page, "supervisor", "GET", "/api/events/all?includePast=true");
|
||||
const all = await v2<EventRow[]>(page, "supervisor", "GET", "/api/v2/events/manage?past=true");
|
||||
const row = all.find((e) => e.title === "E2E Alpha Course (next term)");
|
||||
expect(row).toBeTruthy();
|
||||
const copy = await api<Full>(page, "supervisor", "GET", `/api/events/${row!.id}`);
|
||||
const copy = await v2<Full>(page, "supervisor", "GET", `/api/v2/events/${row!.id}/full`);
|
||||
expect(copy.scheduleType).toBe("sessions");
|
||||
const active = (s: Full) => s.sessions.filter((x) => !(x as { cancelled?: boolean }).cancelled);
|
||||
expect(active(copy)).toHaveLength(active(source).length);
|
||||
|
||||
@@ -20,9 +20,9 @@ test.describe.serial("volunteer rosters", () => {
|
||||
});
|
||||
|
||||
test("the volunteer ticket isn't offered publicly", async ({ request }) => {
|
||||
const res = await request.get(`${API}/api/events/${seed().events.serving}`);
|
||||
const ev = await res.json();
|
||||
expect(ev.eventOptions.map((o: { name: string }) => o.name)).toEqual(["Entry"]);
|
||||
const res = await request.get(`${API}/api/v2/events/${seed().events.serving}`);
|
||||
const ev = (await res.json()).data;
|
||||
expect(ev.ticketOptions.map((o: { name: string }) => o.name)).toEqual(["Entry"]);
|
||||
});
|
||||
|
||||
test("a user signs up, then asks for cover", async ({ page }) => {
|
||||
@@ -48,8 +48,8 @@ test.describe.serial("volunteer rosters", () => {
|
||||
await expect(page.getByTestId("my-shift").filter({ hasText: "Welcome team" })).toBeVisible();
|
||||
|
||||
// The QR code on the wall holds this; a phone camera opens the check-in page.
|
||||
const qr = await request.get(`${API}/api/volunteers/manage/events/${seed().events.serving}/qr`, { headers: { Authorization: `Bearer ${seed().users.supervisor.token}` } });
|
||||
const { qr: code } = await qr.json();
|
||||
const qr = await request.get(`${API}/api/v2/events/${seed().events.serving}/volunteers/qr`, { headers: { Authorization: `Bearer ${seed().users.supervisor.token}` } });
|
||||
const { qr: code } = (await qr.json()).data;
|
||||
await page.goto(`/serve/check-in?code=${encodeURIComponent(code)}`);
|
||||
await expect(page.getByTestId("volunteer-checked-in")).toContainText("Welcome team");
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ test.describe.serial("outbound webhooks", () => {
|
||||
|
||||
test("a new account is sent, signed, and shows in the delivery log", async ({ page, request }) => {
|
||||
const email = `webhook-${Date.now()}@test.local`;
|
||||
const res = await request.post(`${API}/api/users`, { data: { name: "Webhook Person", email, password: "E2e-password-123", phoneNumber: "0820000123" } });
|
||||
const res = await request.post(`${API}/api/v2/auth/signup`, { data: { name: "Webhook Person", email, password: "E2e-password-123", phone: "0820000123", acceptTerms: true } });
|
||||
expect(res.ok()).toBe(true);
|
||||
|
||||
await expect.poll(() => received.filter(r => r.headers["x-crossevents-event"] === "user.created").length, { timeout: 15000 }).toBeGreaterThan(0);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"info": {
|
||||
"title": "Cross Events API",
|
||||
"version": "v2",
|
||||
"description": "Version 2 of the Cross Events API. Every response is JSON:\n- a single item is `{ \"data\": { … } }`;\n- a list is `{ \"data\": [ … ], \"meta\": { \"page\", \"limit\", \"total\", \"pages\" } }`, paged with `?page=` and `?limit=` (at most 100);\n- an error is `{ \"error\": { \"code\", \"message\", \"fields\"? } }` with a stable `code`.\n\nDates are ISO 8601 in UTC; amounts are in rand. Sign in through the app and send the token as `Authorization: Bearer <token>`.\nVersion 1 (`/api/…`) keeps working while the app moves over; it will be removed in 2.0."
|
||||
"description": "Version 2 of the Cross Events API. Every response is JSON:\n- a single item is `{ \"data\": { … } }`;\n- a list is `{ \"data\": [ … ], \"meta\": { \"page\", \"limit\", \"total\", \"pages\" } }`, paged with `?page=` and `?limit=` (at most 100);\n- an error is `{ \"error\": { \"code\", \"message\", \"fields\"? } }` with a stable `code`.\n\nDates are ISO 8601 in UTC; amounts are in rand. Sign in through the app and send the token as `Authorization: Bearer <token>`.\nVersion 1 (`/api/…`) was removed in 2.0: its addresses answer `410 Gone`. See the migration guide (MIGRATING-TO-2.md)."
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
@@ -21285,20 +21285,30 @@
|
||||
]
|
||||
},
|
||||
"cashDenominations": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"additionalProperties": {}
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"value": {
|
||||
"type": "number",
|
||||
"description": "The note or coin, in rand"
|
||||
},
|
||||
"count": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
"required": [
|
||||
"value",
|
||||
"count"
|
||||
],
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"description": "Counted cash by note and coin"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"rows"
|
||||
"rows",
|
||||
"cashDenominations"
|
||||
],
|
||||
"additionalProperties": {}
|
||||
}
|
||||
@@ -59217,10 +59227,14 @@
|
||||
}
|
||||
},
|
||||
"actions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"propertyNames": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Every action, with its label"
|
||||
},
|
||||
"actors": {
|
||||
"type": "array",
|
||||
|
||||
+11
-3
@@ -16134,9 +16134,14 @@ export interface operations {
|
||||
[key: string]: unknown;
|
||||
}[];
|
||||
cashActualTotal?: number | null;
|
||||
cashDenominations?: {
|
||||
/** @description Counted cash by note and coin */
|
||||
cashDenominations: ({
|
||||
/** @description The note or coin, in rand */
|
||||
value: number;
|
||||
count: number;
|
||||
} & {
|
||||
[key: string]: unknown;
|
||||
} | null;
|
||||
})[];
|
||||
} & {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
@@ -33791,7 +33796,10 @@ export interface operations {
|
||||
} & {
|
||||
[key: string]: unknown;
|
||||
})[];
|
||||
actions: string[];
|
||||
/** @description Every action, with its label */
|
||||
actions: {
|
||||
[key: string]: string;
|
||||
};
|
||||
actors: ({
|
||||
id: string;
|
||||
name: string;
|
||||
|
||||
@@ -35,7 +35,7 @@ export default defineConfig({
|
||||
// tsx runs the TypeScript straight from src/ (never a stale dist/ build).
|
||||
command: "node ../e2e/support/prepare-db.js && npx tsx src/index.js",
|
||||
cwd: "backend",
|
||||
url: `http://localhost:${API_PORT}/api/settings/needs-setup`,
|
||||
url: `http://localhost:${API_PORT}/api/v2/setup/needed`,
|
||||
timeout: 180_000,
|
||||
reuseExistingServer: !ci,
|
||||
stdout: "ignore",
|
||||
|
||||
Reference in New Issue
Block a user