@semics-tech/emdash-events 1.0.0-rc.0 → 1.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/index.mjs +25 -1
- package/dist/manifest.json +25 -1
- package/dist/plugin.mjs +6 -6
- package/dist/ts/astro/lib/page.d.ts +44 -0
- package/dist/ts/astro/lib/page.js +122 -0
- package/dist/ts/integration/index.d.ts +4 -0
- package/dist/ts/integration/index.js +2 -0
- package/emdash-plugin.jsonc +16 -0
- package/package.json +7 -2
- package/src/astro/AttendeeList.astro +154 -0
- package/src/astro/BookingPage.astro +82 -9
- package/src/astro/BookingStatus.astro +147 -51
- package/src/astro/BookingWidget.astro +307 -35
- package/src/astro/CancelBooking.astro +80 -0
- package/src/astro/PageBrand.astro +18 -0
- package/src/astro/PageOrganiser.astro +22 -0
- package/src/astro/TicketPass.astro +131 -33
- package/src/astro/lib/attendees.ts +218 -0
- package/src/astro/lib/list.ts +22 -0
- package/src/astro/lib/page.ts +142 -0
- package/src/astro/lib/pass.ts +9 -0
- package/src/astro/lib/payment.ts +6 -10
- package/src/astro/lib/picker.ts +245 -0
- package/src/astro/lib/widget.ts +75 -2
- package/src/astro/virtual.d.ts +2 -0
- package/src/client/booking.ts +3 -1
- package/src/client/forget-form.ts +16 -0
- package/src/client/picker.ts +154 -0
- package/src/client/print.ts +12 -0
- package/src/i18n/ar.ts +63 -1
- package/src/i18n/en.ts +61 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
// <TicketPass>: one attendee's ticket with the check-in code
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
2
|
+
// <TicketPass>: one attendee's ticket with the check-in code (EU-FR-07). With Events Pro the core also sends the
|
|
3
|
+
// code's QR matrix (`qr`, T082), drawn here as an SVG for the door's camera. The code is the core's 43-character
|
|
4
|
+
// value, which door check-in matches exactly, so it is never shortened, only shown smaller (T158): with a QR the face
|
|
5
|
+
// of the pass shows none (the QR carries it) and "Show the code to type in" reveals it on screen, and a printed pass
|
|
6
|
+
// carries it on one small line under the QR; without a QR (Free) it is the way in and shows in full. The code is
|
|
7
|
+
// grouped in fours by spacing (the text stays the exact value); screen readers get it character by character.
|
|
6
8
|
import { pickLocale, translator } from "../i18n/index";
|
|
7
|
-
import { qrPath } from "./lib/pass";
|
|
9
|
+
import { codeGroups, qrPath } from "./lib/pass";
|
|
8
10
|
|
|
9
11
|
interface Props {
|
|
10
12
|
name: string;
|
|
@@ -22,38 +24,63 @@ const { t, lang, dir } = translator(pickLocale(Astro.props.locale, Astro.current
|
|
|
22
24
|
const statusText =
|
|
23
25
|
status === "pending" ? t("pass.status.pending") : status === "cancelled" ? t("pass.status.cancelled") : status;
|
|
24
26
|
const spoken = code.replace(/[^A-Za-z0-9]/g, "").split("").join(" ");
|
|
27
|
+
const groups = codeGroups(code);
|
|
25
28
|
const matrix = qrPath(qr);
|
|
26
29
|
const box = matrix ? matrix.size + 8 : 0;
|
|
27
30
|
---
|
|
28
|
-
<article class="semics-events semics-ticket-pass" lang={lang} dir={dir} data-testid="ticket-pass" data-status={status}>
|
|
29
|
-
{event && <p class="semics-pass-event">{event}</p>}
|
|
30
|
-
<h3 class="semics-pass-name">{name}</h3>
|
|
31
|
-
{ticket && <p class="semics-pass-ticket">{ticket}</p>}
|
|
31
|
+
<article class="semics-events semics-ticket-pass" lang={lang} dir={dir} data-testid="ticket-pass" data-status={status} data-qr={matrix ? "" : undefined}>
|
|
32
32
|
{matrix && (
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
<div class="semics-pass-qr-box">
|
|
34
|
+
<svg
|
|
35
|
+
class="semics-pass-qr"
|
|
36
|
+
data-testid="ticket-qr"
|
|
37
|
+
role="img"
|
|
38
|
+
aria-label={t("pass.qr")}
|
|
39
|
+
viewBox={`-4 -4 ${box} ${box}`}
|
|
40
|
+
shape-rendering="crispEdges"
|
|
41
|
+
>
|
|
42
|
+
<rect x="-4" y="-4" width={box} height={box} fill="#ffffff" />
|
|
43
|
+
<path d={matrix.d} fill="#000000" />
|
|
44
|
+
</svg>
|
|
45
|
+
<p class="semics-pass-code-print" aria-hidden="true" data-testid="ticket-code-print">{groups.map((g) => <span>{g}</span>)}</p>
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
<div class="semics-pass-text">
|
|
49
|
+
{event && <p class="semics-pass-event">{event}</p>}
|
|
50
|
+
<h3 class="semics-pass-name">{name}</h3>
|
|
51
|
+
{ticket && <p class="semics-pass-ticket">{ticket}</p>}
|
|
52
|
+
{!matrix && (
|
|
53
|
+
<>
|
|
54
|
+
<p class="semics-pass-code-label">{t("pass.code")}</p>
|
|
55
|
+
<p class="semics-pass-code">
|
|
56
|
+
<span aria-hidden="true" data-testid="ticket-code">{groups.map((g) => <span>{g}</span>)}</span>
|
|
57
|
+
<span class="semics-visually-hidden">{spoken}</span>
|
|
58
|
+
</p>
|
|
59
|
+
</>
|
|
60
|
+
)}
|
|
61
|
+
{status && status !== "valid" && <p class="semics-pass-status">{statusText}</p>}
|
|
62
|
+
</div>
|
|
63
|
+
{matrix && (
|
|
64
|
+
<details class="semics-pass-more">
|
|
65
|
+
<summary>{t("pass.codeShow")}</summary>
|
|
66
|
+
<p class="semics-pass-code">
|
|
67
|
+
<span aria-hidden="true" data-testid="ticket-code">{groups.map((g) => <span>{g}</span>)}</span>
|
|
68
|
+
<span class="semics-visually-hidden">{spoken}</span>
|
|
69
|
+
</p>
|
|
70
|
+
</details>
|
|
44
71
|
)}
|
|
45
|
-
<p class="semics-pass-code-label">{t("pass.code")}</p>
|
|
46
|
-
<p class="semics-pass-code">
|
|
47
|
-
<span aria-hidden="true" data-testid="ticket-code">{code}</span>
|
|
48
|
-
<span class="semics-visually-hidden">{spoken}</span>
|
|
49
|
-
</p>
|
|
50
|
-
{status && status !== "valid" && <p class="semics-pass-status">{statusText}</p>}
|
|
51
72
|
</article>
|
|
52
73
|
|
|
53
74
|
<style>
|
|
75
|
+
/* The QR beside the attendee and the code (T157); stacked on a narrow screen. */
|
|
54
76
|
.semics-ticket-pass {
|
|
55
77
|
box-sizing: border-box;
|
|
56
|
-
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-wrap: wrap;
|
|
80
|
+
align-items: center;
|
|
81
|
+
gap: 0.75rem 1.25rem;
|
|
82
|
+
max-inline-size: 32rem;
|
|
83
|
+
margin-block: 0 0.75rem;
|
|
57
84
|
padding: 1rem;
|
|
58
85
|
border: 2px dashed var(--events-border, #6b6b6b);
|
|
59
86
|
border-radius: var(--events-radius, 6px);
|
|
@@ -61,6 +88,10 @@ const box = matrix ? matrix.size + 8 : 0;
|
|
|
61
88
|
color: var(--events-fg, #1a1a1a);
|
|
62
89
|
overflow-wrap: anywhere;
|
|
63
90
|
}
|
|
91
|
+
.semics-pass-text {
|
|
92
|
+
flex: 1 1 12rem;
|
|
93
|
+
min-inline-size: 0;
|
|
94
|
+
}
|
|
64
95
|
.semics-ticket-pass p,
|
|
65
96
|
.semics-ticket-pass h3 {
|
|
66
97
|
margin: 0 0 0.25rem;
|
|
@@ -70,19 +101,58 @@ const box = matrix ? matrix.size + 8 : 0;
|
|
|
70
101
|
.semics-pass-code-label {
|
|
71
102
|
color: var(--events-muted, #4a4a4a);
|
|
72
103
|
}
|
|
104
|
+
.semics-pass-code-label {
|
|
105
|
+
font-size: 0.875rem;
|
|
106
|
+
}
|
|
107
|
+
.semics-pass-qr-box {
|
|
108
|
+
flex: none;
|
|
109
|
+
inline-size: min(100%, 10rem);
|
|
110
|
+
}
|
|
73
111
|
/* Black on white in every theme: phone cameras read dark modules on a light ground. */
|
|
74
112
|
.semics-pass-qr {
|
|
75
113
|
display: block;
|
|
76
|
-
inline-size:
|
|
114
|
+
inline-size: 100%;
|
|
77
115
|
block-size: auto;
|
|
78
116
|
aspect-ratio: 1;
|
|
79
|
-
margin: 0.5rem 0;
|
|
80
117
|
}
|
|
81
|
-
|
|
118
|
+
/* Groups of four, spaced rather than separated, so the text is the exact code; a line breaks only between groups. */
|
|
119
|
+
.semics-pass-code,
|
|
120
|
+
.semics-pass-code-print {
|
|
82
121
|
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
122
|
+
overflow-wrap: normal;
|
|
123
|
+
}
|
|
124
|
+
.semics-pass-code {
|
|
125
|
+
font-size: 0.875rem;
|
|
126
|
+
line-height: 1.5;
|
|
127
|
+
letter-spacing: 0.02em;
|
|
128
|
+
font-weight: 600;
|
|
129
|
+
}
|
|
130
|
+
.semics-pass-code > [data-testid] {
|
|
131
|
+
display: block;
|
|
132
|
+
}
|
|
133
|
+
.semics-pass-code > [data-testid] > span,
|
|
134
|
+
.semics-pass-code-print > span {
|
|
135
|
+
display: inline-block;
|
|
136
|
+
margin-inline-end: 0.35em;
|
|
137
|
+
}
|
|
138
|
+
/* Without a QR the code is what the door types in: a little larger. */
|
|
139
|
+
.semics-ticket-pass:not([data-qr]) .semics-pass-code {
|
|
140
|
+
font-size: 0.9375rem;
|
|
141
|
+
}
|
|
142
|
+
/* The pass's full width, under the QR and the name, so the code fits one line on a desktop. */
|
|
143
|
+
.semics-pass-more {
|
|
144
|
+
flex: 1 1 100%;
|
|
145
|
+
}
|
|
146
|
+
.semics-pass-more summary {
|
|
147
|
+
color: var(--events-accent, #0b57d0);
|
|
148
|
+
font-size: 0.875rem;
|
|
149
|
+
cursor: pointer;
|
|
150
|
+
}
|
|
151
|
+
.semics-pass-more .semics-pass-code {
|
|
152
|
+
margin-block: 0.375rem 0;
|
|
153
|
+
}
|
|
154
|
+
.semics-pass-code-print {
|
|
155
|
+
display: none;
|
|
86
156
|
}
|
|
87
157
|
.semics-visually-hidden {
|
|
88
158
|
position: absolute;
|
|
@@ -92,4 +162,32 @@ const box = matrix ? matrix.size + 8 : 0;
|
|
|
92
162
|
clip-path: inset(50%);
|
|
93
163
|
white-space: nowrap;
|
|
94
164
|
}
|
|
165
|
+
@media print {
|
|
166
|
+
.semics-ticket-pass {
|
|
167
|
+
break-inside: avoid;
|
|
168
|
+
border-color: #000000;
|
|
169
|
+
color: #000000;
|
|
170
|
+
}
|
|
171
|
+
.semics-pass-qr-box {
|
|
172
|
+
inline-size: auto;
|
|
173
|
+
}
|
|
174
|
+
.semics-pass-qr {
|
|
175
|
+
inline-size: 35mm;
|
|
176
|
+
}
|
|
177
|
+
/* The QR's fallback for the door: the full code, one small line under it. */
|
|
178
|
+
.semics-pass-code-print {
|
|
179
|
+
display: block;
|
|
180
|
+
margin: 1.5mm 0 0;
|
|
181
|
+
font-size: 6.5pt;
|
|
182
|
+
line-height: 1.3;
|
|
183
|
+
white-space: nowrap;
|
|
184
|
+
}
|
|
185
|
+
.semics-pass-code-print > span {
|
|
186
|
+
margin-inline-end: 0.25em;
|
|
187
|
+
}
|
|
188
|
+
.semics-ticket-pass:not([data-qr]) .semics-pass-code {
|
|
189
|
+
font-size: 9pt;
|
|
190
|
+
white-space: nowrap;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
95
193
|
</style>
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The booking page's attendee signing list (T133, R95; Suite Pro). Events Pro's `public/booking`
|
|
3
|
+
* describes each seat of a waiver booking (`seat`, `signing`, `signs`, `email`, `minor`) and whether
|
|
4
|
+
* names may still be changed (`signingList.editable`, until `attendeeEditCutoffHours` before the
|
|
5
|
+
* start); Free sends none of it, so `signingRows` is null and the page shows nothing new.
|
|
6
|
+
*
|
|
7
|
+
* The list's forms post back to `/booking` (no JavaScript needed). `handleAttendeeAction` calls the
|
|
8
|
+
* Pro routes with the cookie's access token, never a form field, and redeems what they mint with
|
|
9
|
+
* e-sign in-process:
|
|
10
|
+
*
|
|
11
|
+
* - Sign now (`intent=sign-now`): `public/booking/attendees/sign` mints one inline intent for the
|
|
12
|
+
* seat (the attendee signs for themselves on this device; a minor's guardian signs for them), which
|
|
13
|
+
* `startDoorSigning` redeems before sending the browser to e-sign's signing page.
|
|
14
|
+
* - Resend (`intent=resend`, emailed adults): `public/booking/attendees/resend` mints a `resend`
|
|
15
|
+
* intent; e-sign emails the open envelope's invitation again (rate limited by Events Pro).
|
|
16
|
+
* - Save (`intent=attendees`): `public/booking/attendees` stores the corrected names and emails and
|
|
17
|
+
* mints, per changed seat, a `replace` intent (e-sign voids the old envelope) and, for an emailed
|
|
18
|
+
* adult, the new invitation's intent, redeemed in that order.
|
|
19
|
+
*
|
|
20
|
+
* Every outcome is a redirect to `/booking?ref=` with a code, never a typed value. Web APIs only (R35).
|
|
21
|
+
*/
|
|
22
|
+
import { callPublicRoute, type PublicRouteContext } from "./call";
|
|
23
|
+
import { BOOKING_PATH } from "./checkout-form";
|
|
24
|
+
import { type ReceiptOptions, startDoorSigning } from "./receipt";
|
|
25
|
+
import type { BookingView } from "./widget";
|
|
26
|
+
|
|
27
|
+
/** What Events Pro adds to each attendee of a waiver booking's `public/booking` answer. */
|
|
28
|
+
export interface SigningAttendee {
|
|
29
|
+
name: string;
|
|
30
|
+
seat?: string;
|
|
31
|
+
email?: string;
|
|
32
|
+
minor?: boolean;
|
|
33
|
+
signing?: "signed" | "waiting";
|
|
34
|
+
/** `email`: an adult e-sign invites by email; `inline`: signed on the buyer's device. */
|
|
35
|
+
signs?: "inline" | "email";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SigningRow {
|
|
39
|
+
seat: string;
|
|
40
|
+
name: string;
|
|
41
|
+
email: string;
|
|
42
|
+
minor: boolean;
|
|
43
|
+
signed: boolean;
|
|
44
|
+
canSign: boolean;
|
|
45
|
+
canResend: boolean;
|
|
46
|
+
canEdit: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface AttendeeEdit {
|
|
50
|
+
seat: string;
|
|
51
|
+
name: string;
|
|
52
|
+
email?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Statuses in which a waiver can still be signed: the holds', and a confirmed booking's pending seats. */
|
|
56
|
+
const OPEN = ["awaiting_signature", "awaiting_payment", "awaiting_approval", "confirmed"];
|
|
57
|
+
const SEAT = /^[0-9]{1,3}$/;
|
|
58
|
+
const CODE = /^[A-Z_]{1,40}$/;
|
|
59
|
+
const MAX_TEXT = 254;
|
|
60
|
+
/** Issue codes of a refused save the page explains itself; any other issue is an invalid entry. */
|
|
61
|
+
const ISSUE_CODES = ["ATTENDEE_SIGNED", "WAIVER_EMAIL_REQUIRED", "WAIVER_TOO_MANY_EMAILS", "RATE_LIMITED"];
|
|
62
|
+
|
|
63
|
+
/** Where the after-payment waiver step shows (T160): a paid booking confirmed, or waiting for the organiser. */
|
|
64
|
+
const AFTER_PAYMENT = ["confirmed", "awaiting_approval"];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The booking page's signing step for a waiver that comes after payment (Events Pro's `waiverAfter`, T160): `sign`
|
|
68
|
+
* when a seat signed on this device (the buyer, or a minor with the buyer as guardian) still waits, `invite` when an
|
|
69
|
+
* emailed adult does. Null for any other booking, so nothing changes for a waiver signed before payment.
|
|
70
|
+
*/
|
|
71
|
+
export function waiverStep(booking: BookingView): { sign: boolean; invite: boolean } | null {
|
|
72
|
+
if (booking.waiverAfter !== true || !AFTER_PAYMENT.includes(booking.status)) return null;
|
|
73
|
+
const rows = signingRows(booking);
|
|
74
|
+
const waiting = (booking.attendees as SigningAttendee[]).filter(
|
|
75
|
+
(a) => a.signing === "waiting" && rows?.some((r) => r.seat === a.seat),
|
|
76
|
+
);
|
|
77
|
+
if (waiting.length === 0) return null;
|
|
78
|
+
return { sign: waiting.some((a) => a.signs !== "email"), invite: waiting.some((a) => a.signs === "email") };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The list's rows, or null when the answer has no signing list (Free, or not a waiver booking). */
|
|
82
|
+
export function signingRows(booking: BookingView): SigningRow[] | null {
|
|
83
|
+
const list = booking.signingList;
|
|
84
|
+
if (!list) return null;
|
|
85
|
+
const open = OPEN.includes(booking.status);
|
|
86
|
+
const rows: SigningRow[] = [];
|
|
87
|
+
for (const a of booking.attendees as SigningAttendee[]) {
|
|
88
|
+
if (typeof a.seat !== "string" || !SEAT.test(a.seat) || !a.signing) continue;
|
|
89
|
+
const signed = a.signing === "signed";
|
|
90
|
+
const waiting = open && !signed;
|
|
91
|
+
rows.push({
|
|
92
|
+
seat: a.seat,
|
|
93
|
+
name: a.name,
|
|
94
|
+
email: a.email ?? "",
|
|
95
|
+
minor: a.minor === true,
|
|
96
|
+
signed,
|
|
97
|
+
canSign: waiting,
|
|
98
|
+
canResend: waiting && a.signs === "email",
|
|
99
|
+
canEdit: waiting && list.editable === true,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return rows.length > 0 ? rows : null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const text = (form: FormData, key: string): string | undefined => {
|
|
106
|
+
const value = form.get(key);
|
|
107
|
+
return typeof value === "string" ? value.trim().slice(0, MAX_TEXT) : undefined;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/** The edit form's values for the editable seats (`name:<seat>`, `email:<seat>`); a minor has no email. */
|
|
111
|
+
export function readAttendeeEdits(form: FormData, rows: readonly SigningRow[]): AttendeeEdit[] {
|
|
112
|
+
return rows
|
|
113
|
+
.filter((r) => r.canEdit)
|
|
114
|
+
.map((r) => {
|
|
115
|
+
const name = text(form, `name:${r.seat}`) ?? r.name;
|
|
116
|
+
if (r.minor) return { seat: r.seat, name };
|
|
117
|
+
return { seat: r.seat, name, email: text(form, `email:${r.seat}`) ?? r.email };
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const post = <T>(ctx: PublicRouteContext, pluginId: string | undefined, path: string, body: unknown) =>
|
|
122
|
+
callPublicRoute<T>(ctx, { method: "POST", path, body, ...(pluginId ? { pluginId } : {}) });
|
|
123
|
+
|
|
124
|
+
function back(ref: string, key: "error" | "attendees", value: string): { location: string } {
|
|
125
|
+
const query = new URLSearchParams({ ref });
|
|
126
|
+
query.set(key, key === "error" && !CODE.test(value) ? "INTERNAL" : value);
|
|
127
|
+
return { location: `${BOOKING_PATH}?${query}` };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface Minted {
|
|
131
|
+
intent?: unknown;
|
|
132
|
+
lookup?: unknown;
|
|
133
|
+
intents?: Array<{ token?: unknown; delivery?: unknown }>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Handles the list's posts (`intent` = `sign-now`, `resend` or `attendees`); null for any other
|
|
138
|
+
* form. `booking` is the page's fresh `public/booking` answer, so only offered actions are sent.
|
|
139
|
+
*/
|
|
140
|
+
export async function handleAttendeeAction(
|
|
141
|
+
ctx: PublicRouteContext,
|
|
142
|
+
form: FormData,
|
|
143
|
+
access: { ref: string; token: string },
|
|
144
|
+
options: ReceiptOptions,
|
|
145
|
+
booking: BookingView,
|
|
146
|
+
): Promise<{ location: string } | null> {
|
|
147
|
+
const intent = form.get("intent");
|
|
148
|
+
if (intent !== "sign-now" && intent !== "resend" && intent !== "attendees" && intent !== "sign-waiver") return null;
|
|
149
|
+
const { ref } = access;
|
|
150
|
+
if (!options.esignPluginId) return back(ref, "error", "ESIGN_NOT_CONFIGURED");
|
|
151
|
+
const rows = signingRows(booking) ?? [];
|
|
152
|
+
const auth = { bookingRef: ref, accessToken: access.token };
|
|
153
|
+
|
|
154
|
+
if (intent === "sign-waiver") return signWaiver(ctx, auth, options, booking);
|
|
155
|
+
|
|
156
|
+
if (intent === "attendees") {
|
|
157
|
+
const attendees = readAttendeeEdits(form, rows);
|
|
158
|
+
if (attendees.length === 0) return back(ref, "error", "ATTENDEES_LOCKED");
|
|
159
|
+
const saved = await post<Minted>(ctx, options.pluginId, "public/booking/attendees", { ...auth, attendees });
|
|
160
|
+
if (!saved.ok) {
|
|
161
|
+
const issue = saved.error.issues?.find((i) => ISSUE_CODES.includes(String(i.code)));
|
|
162
|
+
if (issue) return back(ref, "error", String(issue.code));
|
|
163
|
+
return back(ref, "error", saved.error.code === "BAD_REQUEST" ? "ATTENDEE_INVALID" : saved.error.code);
|
|
164
|
+
}
|
|
165
|
+
// In order: each changed seat's `replace` (void the old envelope) before its new invitation.
|
|
166
|
+
for (const minted of saved.data.intents ?? []) {
|
|
167
|
+
const redeemed = await post(ctx, options.esignPluginId, "public/envelopes/from-intent", {
|
|
168
|
+
intent: minted.token,
|
|
169
|
+
});
|
|
170
|
+
if (!redeemed.ok) return back(ref, "error", "ATTENDEES_UNSENT");
|
|
171
|
+
}
|
|
172
|
+
return back(ref, "attendees", "saved");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const seat = form.get("seat");
|
|
176
|
+
const row = rows.find((r) => r.seat === seat);
|
|
177
|
+
if (!row || !(intent === "resend" ? row.canResend : row.canSign)) return back(ref, "error", "BAD_REQUEST");
|
|
178
|
+
if (intent === "resend") {
|
|
179
|
+
const minted = await post<Minted>(ctx, options.pluginId, "public/booking/attendees/resend", { ...auth, seat });
|
|
180
|
+
if (!minted.ok) return back(ref, "error", minted.error.code);
|
|
181
|
+
const sent = await post(ctx, options.esignPluginId, "public/envelopes/from-intent", { intent: minted.data.intent });
|
|
182
|
+
return sent.ok ? back(ref, "attendees", "resent") : back(ref, "error", "SIGNING_UNAVAILABLE");
|
|
183
|
+
}
|
|
184
|
+
const minted = await post<Minted>(ctx, options.pluginId, "public/booking/attendees/sign", { ...auth, seat });
|
|
185
|
+
if (!minted.ok) return back(ref, "error", minted.error.code);
|
|
186
|
+
const started = await startDoorSigning(ctx, minted.data.intent, options, minted.data.lookup);
|
|
187
|
+
if ("location" in started) return started;
|
|
188
|
+
if ("signed" in started) return { location: `${BOOKING_PATH}?ref=${ref}&waiver=signed` };
|
|
189
|
+
return back(ref, "error", started.error);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* "Sign the waiver" after payment (T160): Events Pro's `public/booking/attendees/sign` with no seat mints an intent for every seat not
|
|
194
|
+
* signed. The emailed adults' are redeemed first (e-sign invites each once: a second press finds the envelope and
|
|
195
|
+
* sends nothing), then the first seat signed on this device opens e-sign's signing page; the next press signs the next.
|
|
196
|
+
*/
|
|
197
|
+
async function signWaiver(
|
|
198
|
+
ctx: PublicRouteContext,
|
|
199
|
+
auth: { bookingRef: string; accessToken: string },
|
|
200
|
+
options: ReceiptOptions,
|
|
201
|
+
booking: BookingView,
|
|
202
|
+
): Promise<{ location: string }> {
|
|
203
|
+
const ref = auth.bookingRef;
|
|
204
|
+
if (!waiverStep(booking) || !options.esignPluginId) return back(ref, "error", "BAD_REQUEST");
|
|
205
|
+
const minted = await post<Minted>(ctx, options.pluginId, "public/booking/attendees/sign", auth);
|
|
206
|
+
if (!minted.ok) return back(ref, "error", minted.error.code);
|
|
207
|
+
const intents = minted.data.intents ?? [];
|
|
208
|
+
for (const email of intents.filter((i) => i.delivery === "email")) {
|
|
209
|
+
const sent = await post(ctx, options.esignPluginId, "public/envelopes/from-intent", { intent: email.token });
|
|
210
|
+
if (!sent.ok) return back(ref, "error", "ATTENDEES_UNSENT");
|
|
211
|
+
}
|
|
212
|
+
const inline = intents.find((i) => i.delivery !== "email");
|
|
213
|
+
if (!inline) return back(ref, "attendees", "invited");
|
|
214
|
+
const started = await startDoorSigning(ctx, inline.token, options);
|
|
215
|
+
if ("location" in started) return started;
|
|
216
|
+
if ("signed" in started) return { location: `${BOOKING_PATH}?ref=${ref}&waiver=signed` };
|
|
217
|
+
return back(ref, "error", started.error);
|
|
218
|
+
}
|
package/src/astro/lib/list.ts
CHANGED
|
@@ -62,6 +62,28 @@ const WHEN: Intl.DateTimeFormatOptions = {
|
|
|
62
62
|
timeZoneName: "short",
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
/** The booking widget's and the waiver page's date format: full date, short time. */
|
|
66
|
+
const AT: Intl.DateTimeFormatOptions = { dateStyle: "full", timeStyle: "short" };
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A time on a customer page (a deadline, a hold, the booked session): local time in the event's own zone, as the
|
|
70
|
+
* session's time line reads ("Monday 9 November 2026 at 15:09", T157), without the zone's name. A missing or
|
|
71
|
+
* unknown zone shows UTC and says so; a value that is not a date is shown as it is.
|
|
72
|
+
*/
|
|
73
|
+
export function zonedAt(iso: string, timezone: string | null | undefined, locale: string): string {
|
|
74
|
+
const ms = Date.parse(iso);
|
|
75
|
+
if (!Number.isFinite(ms)) return iso;
|
|
76
|
+
const known = Boolean(timezone && isValidTimeZone(timezone));
|
|
77
|
+
const zone = known ? (timezone as string) : "UTC";
|
|
78
|
+
let time: string;
|
|
79
|
+
try {
|
|
80
|
+
time = formatInZone(ms, zone, locale, AT);
|
|
81
|
+
} catch {
|
|
82
|
+
time = formatInZone(ms, zone, "en-GB", AT); // A locale `Intl` refuses, such as `en_GB`.
|
|
83
|
+
}
|
|
84
|
+
return known ? time : `${time} (${zone})`;
|
|
85
|
+
}
|
|
86
|
+
|
|
65
87
|
const BADGES = { cancelled: "list.badge.cancelled", closed: "list.badge.closed", paused: "list.badge.paused" } as const;
|
|
66
88
|
|
|
67
89
|
/** The start in the event's own zone; a missing or unknown zone shows UTC rather than failing. */
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// i18n-ignore-file: a stylesheet and its option names, no text for people.
|
|
2
|
+
/**
|
|
3
|
+
* The look of the plugins' own full pages (`/booking`, the suite's `/_events/waiver`), which run outside the
|
|
4
|
+
* site's layout: a default stylesheet built only on the `--events-*` properties, and what a site sets through
|
|
5
|
+
* `eventsIntegration({ page })` / `eventsSuite({ page })`. It is one exact string so the signing page can allow
|
|
6
|
+
* it by hash (its CSP allows nothing else inline, `ceremonyCsp`). Web APIs only (R35).
|
|
7
|
+
*
|
|
8
|
+
* The site's own layout is deliberately not wrapped around these pages: an emailed link's one-time code is in the
|
|
9
|
+
* URL here, and a signing page's CSP would block the layout's scripts and styles anyway.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** A theme value by property: `accent` sets `--events-accent` (the signing form follows, see `PAGE_CSS`). */
|
|
13
|
+
export const THEME_PROPERTIES = [
|
|
14
|
+
"fg",
|
|
15
|
+
"muted",
|
|
16
|
+
"bg",
|
|
17
|
+
"border",
|
|
18
|
+
"accent",
|
|
19
|
+
"accent-fg",
|
|
20
|
+
"error",
|
|
21
|
+
"success",
|
|
22
|
+
"radius",
|
|
23
|
+
"font",
|
|
24
|
+
"page-bg",
|
|
25
|
+
"heading-font",
|
|
26
|
+
"heading-fg",
|
|
27
|
+
] as const;
|
|
28
|
+
export type ThemeProperty = (typeof THEME_PROPERTIES)[number];
|
|
29
|
+
export interface PageBrand {
|
|
30
|
+
/** The site's name: the link's text, or the logo's alternative text. Also the organiser at the page's foot. */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Where it links, a path on this site (default `/`). */
|
|
33
|
+
href?: string;
|
|
34
|
+
/** A logo, a path on this site. */
|
|
35
|
+
logo?: string;
|
|
36
|
+
/** The organiser's postal address, one line, at the page's foot and on a printed booking (T157). */
|
|
37
|
+
address?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** One line of text for people: 1 to 300 characters, no control characters (line breaks included). */
|
|
41
|
+
function oneLine(value: unknown): boolean {
|
|
42
|
+
if (typeof value !== "string" || !value.trim() || value.length > 300) return false;
|
|
43
|
+
for (let i = 0; i < value.length; i++) {
|
|
44
|
+
const unit = value.charCodeAt(i);
|
|
45
|
+
if (unit <= 0x1f || unit === 0x7f) return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface PageOptions {
|
|
51
|
+
/** Values for the pages' custom properties, for example `{ accent: "#1f3a2e", "page-bg": "#f6f1ea" }`. */
|
|
52
|
+
theme?: Partial<Record<ThemeProperty, string>>;
|
|
53
|
+
/** A stylesheet on this site, loaded after the defaults: for `@font-face`, or any further rules. */
|
|
54
|
+
stylesheet?: string;
|
|
55
|
+
/** The site's name or logo at the top of each page. */
|
|
56
|
+
brand?: PageBrand;
|
|
57
|
+
/** The event's page, where "Book again" goes: a path with `{slug}` (default `/events/{slug}`). */
|
|
58
|
+
eventPath?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** One line of CSS, nothing that could end the declaration, the rule or the `<style>` element. */
|
|
62
|
+
const THEME_VALUE = /^[^;{}<>\\@]{1,200}$/;
|
|
63
|
+
/** A path on this site; `;` and `,` would end a source in the signing page's CSP header. */
|
|
64
|
+
const SITE_PATH = /^\/(?!\/)[^\s"'<>\\;,]*$/;
|
|
65
|
+
|
|
66
|
+
/** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
|
|
67
|
+
export function checkPageOptions(page: PageOptions = {}): PageOptions {
|
|
68
|
+
const refuse = (what: string) => {
|
|
69
|
+
throw new Error(`page.${what} is not valid`); // i18n-ignore
|
|
70
|
+
};
|
|
71
|
+
for (const [name, value] of Object.entries(page.theme ?? {})) {
|
|
72
|
+
const known = (THEME_PROPERTIES as readonly string[]).includes(name);
|
|
73
|
+
if (!known || typeof value !== "string" || !THEME_VALUE.test(value) || /url\(/i.test(value))
|
|
74
|
+
refuse(`theme.${name}`);
|
|
75
|
+
}
|
|
76
|
+
const { brand, stylesheet, eventPath } = page;
|
|
77
|
+
if (stylesheet !== undefined && !SITE_PATH.test(stylesheet)) refuse("stylesheet");
|
|
78
|
+
if (eventPath !== undefined && !(SITE_PATH.test(eventPath) && eventPath.includes("{slug}"))) refuse("eventPath");
|
|
79
|
+
if (brand) {
|
|
80
|
+
if (typeof brand.name !== "string" || !brand.name.trim()) refuse("brand.name");
|
|
81
|
+
if (brand.href !== undefined && !SITE_PATH.test(brand.href)) refuse("brand.href");
|
|
82
|
+
if (brand.logo !== undefined && !SITE_PATH.test(brand.logo)) refuse("brand.logo");
|
|
83
|
+
if (brand.address !== undefined && !oneLine(brand.address)) refuse("brand.address");
|
|
84
|
+
}
|
|
85
|
+
return page;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The event's page for "Book again"; undefined when the booking does not know its slug. */
|
|
89
|
+
export function eventPageHref(slug: string | null | undefined, eventPath?: string): string | undefined {
|
|
90
|
+
return slug ? (eventPath ?? "/events/{slug}").replace("{slug}", encodeURIComponent(slug)) : undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Works with no site theme at all. Zero specificity on elements, so the components' own rules win; except the card
|
|
95
|
+
* rule for `main`'s sections, which outranks a component's own box (`.semics-payment`, `.semics-attendee-list`) so
|
|
96
|
+
* every card has the same edges, width and look (T158).
|
|
97
|
+
*/
|
|
98
|
+
export const PAGE_CSS = `*,*::before,*::after{box-sizing:border-box}
|
|
99
|
+
html{color-scheme:light;-webkit-text-size-adjust:100%}
|
|
100
|
+
body.semics-page{margin:0;min-block-size:100vh;background:var(--events-page-bg, #f5f4f0);color:var(--events-fg, #1a1a1a);font-family:var(--events-font, system-ui, sans-serif);font-size:1.0625rem;line-height:1.55;overflow-wrap:anywhere;
|
|
101
|
+
--esign-fg:var(--events-fg, #1a1a1a);--esign-muted:var(--events-muted, #4a4a4a);--esign-bg:var(--events-bg, #ffffff);--esign-border:var(--events-border, #6b6b6b);--esign-accent:var(--events-accent, #0b57d0);--esign-accent-fg:var(--events-accent-fg, #ffffff);--esign-error:var(--events-error, #b3261e);--esign-radius:var(--events-radius, 6px);--esign-font:var(--events-font, system-ui, sans-serif)}
|
|
102
|
+
.semics-page-brand{max-inline-size:40rem;margin-inline:auto;padding:1.25rem 1rem 0;font-family:var(--events-heading-font, inherit);font-weight:600}
|
|
103
|
+
.semics-page-brand a{color:var(--events-heading-fg, inherit);text-decoration:none}
|
|
104
|
+
.semics-page-brand img{display:block;block-size:2.5rem;inline-size:auto;max-inline-size:100%}
|
|
105
|
+
.semics-page-main{max-inline-size:40rem;margin-inline:auto;padding:1.5rem 1rem 2rem}
|
|
106
|
+
:where(.semics-page) :is(h1,h2,h3){margin:0 0 .75rem;font-family:var(--events-heading-font, inherit);color:var(--events-heading-fg, inherit);line-height:1.2}
|
|
107
|
+
:where(.semics-page) h1{margin-block-end:1.25rem;font-size:clamp(1.75rem,1.5rem + 1.5vw,2.25rem)}
|
|
108
|
+
:where(.semics-page) h2{font-size:1.25rem}
|
|
109
|
+
:where(.semics-page) h3{font-size:1.0625rem}
|
|
110
|
+
:where(.semics-page) p{margin:0 0 .75rem}
|
|
111
|
+
:where(.semics-page) a{color:var(--events-accent, #0b57d0);text-underline-offset:.2em}
|
|
112
|
+
:where(.semics-page) :focus-visible{outline:3px solid var(--events-accent, #0b57d0);outline-offset:2px}
|
|
113
|
+
.semics-page-main > :is(section,form:not([hidden]),.semics-ceremony){margin-block:0 1.25rem;padding:clamp(1.25rem,.9rem + 1.8vw,1.75rem);background:var(--events-bg, #ffffff);border:1px solid color-mix(in srgb,var(--events-border, #6b6b6b) 30%,transparent);border-radius:calc(var(--events-radius, 6px) + 6px);box-shadow:0 1px 2px rgb(0 0 0 / .04),0 6px 24px rgb(0 0 0 / .05);max-inline-size:none}
|
|
114
|
+
:where(.semics-page-main > section,.semics-page-main > form,.semics-page-main > .semics-ceremony) > :last-child{margin-block-end:0}
|
|
115
|
+
:where(.semics-page) [role="alert"]{padding:.75rem 1rem;border:1px solid var(--events-error, #b3261e);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-error, #b3261e)}
|
|
116
|
+
:where(.semics-page) :is(input:not([type="checkbox"],[type="radio"],[type="hidden"]),select,textarea){font:inherit;inline-size:100%;min-block-size:2.75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-fg, #1a1a1a)}
|
|
117
|
+
:where(.semics-page) label{display:block}
|
|
118
|
+
:where(.semics-page) fieldset{min-inline-size:0;margin:0 0 1rem;padding:0;border:0}
|
|
119
|
+
:where(.semics-page) legend{padding:0;margin-block-end:.5rem;font-weight:600}
|
|
120
|
+
:where(.semics-page) button{font:inherit;font-weight:600;min-block-size:2.75rem;padding:.625rem 1.25rem;border:1px solid var(--events-accent, #0b57d0);border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}
|
|
121
|
+
.semics-page-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem 1.25rem;margin-block:0 1.25rem}
|
|
122
|
+
.semics-page-actions .semics-print{background:transparent;color:var(--events-accent, #0b57d0)}
|
|
123
|
+
.semics-page-organiser{max-inline-size:40rem;margin-inline:auto;padding:0 1rem 3rem;color:var(--events-muted, #4a4a4a);font-size:.9375rem}
|
|
124
|
+
.semics-page-organiser p{margin:0}
|
|
125
|
+
.semics-page-organiser address{font-style:normal}
|
|
126
|
+
@media print{
|
|
127
|
+
@page{margin:15mm}
|
|
128
|
+
body.semics-page{min-block-size:0;background:#ffffff;color:#000000;font-size:11pt}
|
|
129
|
+
.semics-page-brand,.semics-page-actions,.semics-page-main form,.semics-page-main button,.semics-page-main details,.semics-add-to-calendar,[data-semics-payment-live]{display:none !important}
|
|
130
|
+
.semics-page-main{max-inline-size:none;padding:0}
|
|
131
|
+
.semics-page-main > :is(section,form:not([hidden]),.semics-ceremony){box-shadow:none;border-color:#999999;break-inside:avoid}
|
|
132
|
+
.semics-ticket-pass{break-inside:avoid}
|
|
133
|
+
.semics-page-organiser{max-inline-size:none;padding:1rem 0 0;color:#000000}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
|
|
137
|
+
/** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
|
|
138
|
+
export function pageCss(page: PageOptions = {}): string {
|
|
139
|
+
const set = Object.entries(page.theme ?? {}) as Array<[ThemeProperty, string]>;
|
|
140
|
+
if (set.length === 0) return PAGE_CSS;
|
|
141
|
+
return `${PAGE_CSS}:root{${set.map(([name, value]) => `--events-${name}:${value}`).join(";")}}\n`;
|
|
142
|
+
}
|
package/src/astro/lib/pass.ts
CHANGED
|
@@ -33,3 +33,12 @@ export function qrPath(qr: unknown): QrPath | null {
|
|
|
33
33
|
}
|
|
34
34
|
return { size, d };
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A check-in code in groups of four for reading (T158): the pass draws each group as its own span, spaced by CSS, so
|
|
39
|
+
* the text (and a copy of it) stays the exact value door check-in takes. A short code (12 or fewer) stays whole.
|
|
40
|
+
*/
|
|
41
|
+
export function codeGroups(code: string): string[] {
|
|
42
|
+
if (code.length <= 12) return code ? [code] : [];
|
|
43
|
+
return code.match(/.{1,4}/gsu) ?? [];
|
|
44
|
+
}
|
package/src/astro/lib/payment.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* way" are told apart by asking the core, never by a query parameter.
|
|
6
6
|
*/
|
|
7
7
|
import { type MessageKey, t } from "../../i18n/index";
|
|
8
|
+
import { zonedAt } from "./list";
|
|
8
9
|
import type { BookingView } from "./widget";
|
|
9
10
|
|
|
10
11
|
export type PaymentState = "confirmed" | "pending" | "expired" | "cancelled" | "refunded" | "refunded_unavailable";
|
|
@@ -19,15 +20,6 @@ export interface PaymentView {
|
|
|
19
20
|
resume: boolean;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
const utc = (iso: string, locale: string) => {
|
|
23
|
-
try {
|
|
24
|
-
const at = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" });
|
|
25
|
-
return t(locale, "time.utc", { time: at.format(new Date(iso)) });
|
|
26
|
-
} catch {
|
|
27
|
-
return iso;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
23
|
/** The provider's payment page is followed only when it is an `https:` URL (never `javascript:` or `//host`). */
|
|
32
24
|
export function isPayUrl(value: unknown): value is string {
|
|
33
25
|
if (typeof value !== "string" || !value.startsWith("https://")) return false;
|
|
@@ -49,13 +41,17 @@ const final = (state: PaymentState, locale: string): PaymentView => ({
|
|
|
49
41
|
/** The payment section for a booking, or `null` when there is nothing to say about money. */
|
|
50
42
|
export function paymentView(booking: BookingView, locale = "en-GB"): PaymentView | null {
|
|
51
43
|
const paid = booking.totals.totalMinor > 0;
|
|
44
|
+
// Ran out waiting for the organiser: not about a payment (`endedNotes` says what happened).
|
|
45
|
+
if (booking.status === "expired" && booking.undecided) return null;
|
|
52
46
|
switch (booking.status) {
|
|
53
47
|
case "awaiting_payment":
|
|
54
48
|
return {
|
|
55
49
|
state: "pending",
|
|
56
50
|
heading: t(locale, "payment.pending.heading"),
|
|
57
51
|
body: booking.holdExpiresAt
|
|
58
|
-
? t(locale, "payment.pending.bodyUntil", {
|
|
52
|
+
? t(locale, "payment.pending.bodyUntil", {
|
|
53
|
+
time: zonedAt(booking.holdExpiresAt, booking.event?.timezone, locale),
|
|
54
|
+
})
|
|
59
55
|
: t(locale, "payment.pending.body"),
|
|
60
56
|
poll: true,
|
|
61
57
|
resume: true,
|