Dev.to Security 🔐 Cybersecurity 👁 0 📖 4 min read

A booking calendar still ships availability and cancellation rules in the browser

A booking widget looks simple: a month grid, some greyed-out days, a confirm button. Under the hood it is usually a JavaScript model of your business. Opening hours, buffer times, staff skills, minimum notice, cancellati

A booking widget looks simple: a month grid, some greyed-out days, a confirm button. Under the hood it is usually a JavaScript model of your business. Opening hours, buffer times, staff skills, minimum notice, cancellation windows, and any "Pro" scheduling rules have to run in the tab if the calendar is going to update without a round trip.

That also means those rules travel with the page. This article is about what a client-side booking calendar actually exposes, which decisions must be made again on the server, and how to protect the scheduling engine you still have to run in the browser.

The calendar is a rules engine with a grid on top

A typical availability helper looks like this:

export function getSlots(day, staff, service) {
  const open = HOURS[day.weekday];          // your interesting part
  const buffers = RULES.buffers[service.id];
  const booked = loadLocalBusy(day, staff);
  return buildSlots(open, buffers, booked, {
    minNoticeMin: RULES.minNoticeMin,
    cancelHours: RULES.cancelHours[service.plan],
  });
}

export function canCancel(appointment, now) {
  return hoursUntil(appointment.start, now) >= RULES.cancelHours[appointment.plan];
}

HOURS, RULES, and buildSlots are more valuable than the date-picker UI. A visitor who pretty-prints the bundle can read:

  • Opening hours, blackout dates, and per-staff or per-room constraints.
  • Buffer and duration tables, including ones the UI does not label.
  • Minimum-notice and cancellation windows, sometimes different by plan.
  • How "busy" is computed, and whether that array is only a preview.

Minifying the widget will rename getSlots. It will not hide a distinctive buffer, a holiday table, or the structure of the slot builder.

Grey days are a preview, not a lock

The calendar has to show something immediately, so teams often precompute slots in the browser and then POST the chosen time. That preview is not an authorization check.

If createBooking trusts the slot the widget already calculated, a caller can submit a time the grid would have greyed out: inside the buffer, below the minimum notice, or in a window reserved for another plan. The same is true of canCancel. A hide-the-button check in the tab does not cancel or prevent a cancel; the API does.

Keep the interactive grid. Do not let it be the last word on whether a time is bookable, billable, or cancellable.

// the server must decide, regardless of what the widget displayed
app.post("/bookings", async (req, res) => {
  const slot = await inventory.lockIfAvailable(req.user, req.body);
  if (!slot) return res.status(409).json({ error: "unavailable" });
  return res.json(await bookings.create(slot));
});

Inventory, deposits, no-show fees, and cancellations belong in that path. The widget can fail open in the UI and still be safe if the server refuses.

What to leave on the server

Some pieces should never be trusted from the tab, and some should not be shipped at all:

  • The authoritative yes/no for a booking, reschedule, or cancellation.
  • Payments, deposits, coupons, and plan entitlements.
  • Staff-only calendars, internal notes, and unpublished availability you would not show on a public page.
  • A full unsold inventory dump when a cheaper query for one day would do.

The browser can render the month and offer a slot. The server should re-check the slot against current inventory and the user's entitlement before it locks anything.

What to protect in the client

The live calendar still needs a fast preview. You may also have a proprietary packer: a constraint solver, a staff-matching score, or a dense occupancy heuristic you do not want copied into a rival widget. For that slice:

  1. Keep inventory locks, charges, and cancellations authoritative on the server.
  2. Minify the widget as usual.
  3. Extract buildSlots or the matcher and apply a real protection pass — identifier renaming and string tables as a floor, VM-style protection if wholesale reuse of the engine is the risk you care about.
  4. Keep staff-only calendars and unpublished books out of the public bundle, and keep production source maps off the public CDN.

A JS VM obfuscator compiles that function to a custom bytecode and ships a small interpreter. Pretty-printing the chunk no longer reconstructs the original packer; you get bytecode and a dispatcher. That is slower than a bare getSlots() call, which is why you protect the engine, not the date grid, and why protection is not a substitute for a server-side lock.

VEILVM is a browser-based JSVMP workspace you can point at one extracted function before you wire protection into CI. Protection raises the cost of casual inspection and wholesale reuse. It does not make a visible calendar a secret, and it does not replace a server-side availability check.

Checklist

  • [ ] Creating, rescheduling, and cancelling a booking is decided again on the server, not only by a greyed-out cell.
  • [ ] Payments, deposits, and plan entitlements are enforced on the server.
  • [ ] Staff-only or unpublished calendars are not sitting in the public widget bundle.
  • [ ] A proprietary slot packer or staff matcher is a candidate for protection; the date-picker UI is not.
  • [ ] Production source maps are not downloadable from the CDN.
  • [ ] End-to-end tests book and refuse fixture slots against the minified (and, if applicable, protected) production widget and the real API.

If you want to try VM protection on a single extracted function, VEILVM runs in the browser with no sign-up: 3 free runs a day, up to 5 KB per file (resets at 00:00 UTC). A free account raises the input limit to 30 KB. Pro is $9/month or $79/year and adds an API so the protection step can run in CI. Standard requests are processed in memory and are not written to logs. Start at https://vm.ldvmp.com.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.