Skip to main content

Trusted embed sign-in

Your server mints a JSON Web Token. The browser posts it into the booking iframe. HoldATime creates a customer for that organization only. An email that already has a HoldATime account must open a confirmation link once.

Embed snippet

<div id="holdatime-booking" data-org="your-club" data-amenity="amenity-id"></div>
<script src="https://holdatime.com/embed/booking.js" async></script>
<script>
  HoldATimeEmbed.signIn(tokenFromYourServer);
</script>

Do not put the token in the iframe address. The signing secret never goes to the browser.

Token

HS256 is the default. The issuer is the client id from Embed settings. The audience is holdatime. exp is at most five minutes after iat. Include sub, email, name, and a unique jti.

import { createHmac } from "node:crypto";

const header = Buffer.from(JSON.stringify({ alg: "HS256", typ: "JWT", kid: "YOUR_KID" })).toString("base64url");
const now = Math.floor(Date.now() / 1000);
const body = Buffer.from(JSON.stringify({
  iss: "YOUR_CLIENT_ID",
  aud: "holdatime",
  sub: "member-42",
  email: "ada@club.example",
  name: "Ada",
  iat: now,
  exp: now + 120,
  jti: crypto.randomUUID(),
})).toString("base64url");
const signature = createHmac("sha256", "YOUR_SECRET").update(header + "." + body).digest("base64url");
const token = header + "." + body + "." + signature;
<?php
$header = rtrim(strtr(base64_encode(json_encode(["alg" => "HS256", "typ" => "JWT", "kid" => "YOUR_KID"])), "+/", "-_"), "=");
$now = time();
$body = rtrim(strtr(base64_encode(json_encode([
  "iss" => "YOUR_CLIENT_ID",
  "aud" => "holdatime",
  "sub" => "member-42",
  "email" => "ada@club.example",
  "name" => "Ada",
  "iat" => $now,
  "exp" => $now + 120,
  "jti" => bin2hex(random_bytes(16)),
])), "+/", "-_"), "=");
$signature = rtrim(strtr(base64_encode(hash_hmac("sha256", $header . "." . $body, "YOUR_SECRET", true)), "+/", "-_"), "=");
$token = $header . "." . $body . "." . $signature;