Skip to main content
UniFit
OAuth 2.0 + PKCE • HMAC-SHA256 Webhooks

Authentication, Key Boundaries & Webhook Security

UniFit enforces strict privilege separation between browser storefront tags, merchant backend APIs, and shopper body-measurement profiles. Follow this specification when deploying live integrations.

1. Publishable Keys vs Server API Keys

Key PrefixAllowed EnvironmentCapabilities & Controls
pk_live_* / pk_sbx_*Browser Widget, Storefront Themes, Public OAuth Client IDHydrates Widget Studio theme configuration and initiates OAuth 2.0 + PKCE prompts strictly from allowlisted CORS origins.
uf_live_* / uf_sbx_*Server-to-Server Backend Only (Node, Python, Go, PHP, Java)Authenticates catalog sync, OAuth token exchange, and size recommendation calls via Authorization: Bearer or X-API-Key. Stored server-side as SHA-256 digests; never ship in browser or mobile bundles.

2. Shopper Consent via OAuth 2.0 + PKCE (S256)

Merchants never store raw customer chest, waist, hip, or scan images. Instead, your frontend opens /auth/authorize with a S256 PKCE code challenge, shopper clicks Approve Size Check, and your backend exchanges the one-time authorization code at POST /api/v1/consents/token for a 15-minute scoped size:recommend grant.

3. Public Webhook Verification Guide (HMAC-SHA256)

Outbound webhook events (recommendation attributions, fit feedback updates, and quota alerts) are delivered strictly to public HTTPS endpoints protected against private-IP SSRF redirects and signed using your workspace webhook secret in the X-UniFit-Signature header. Always compare digests using constant-time comparison before processing payloads.

import crypto from "node:crypto";

export function verifyUniFitWebhook(rawBody, signatureHeader, webhookSecret) {
  if (!signatureHeader) return false;
  const expected = crypto
    .createHmac("sha256", webhookSecret)
    .update(rawBody, "utf8")
    .digest("hex");

  const provided = signatureHeader.replace(/^sha256=/, "");
  const a = Buffer.from(expected, "utf8");
  const b = Buffer.from(provided, "utf8");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

Authenticated engineering teams can configure live webhook endpoints, trigger test deliveries, and rotate signing secrets inside the private Developer Portal once signed in.