Skip to main content

Apps

An app is an application of yours that opens from your Webround dashboard with one click. It does not run on Webround: it is independent, built by you or by a developer you trust, and anything with an HTTPS address can be one: a web application on your domain, a Cloudflare Worker, a container on Cloud Run, a VPS.

For now Webround supports private apps: created by the merchant, visible only in their own store, and in no public marketplace.

How an app knows who opens it​

When you open an app that needs authentication (needsSecret), Webround redirects you to its address with a signed URL:

ParameterDescription
wr_storeThe ID of your store.
wr_appThe ID of the app.
wr_tsWhen the URL was generated, in milliseconds.
wr_sigThe HMAC-SHA256 signature.

The signature is HMAC-SHA256(secret, "{wr_store}:{wr_app}:{wr_ts}"). Webround generates the secret when you install the app and shows it once: you give it to the developer, who sets it as an environment variable of the app.

The app must refuse a wr_ts older than 30 seconds: that stops anyone who finds a URL from using it later. The signed parameters arrive only when the app opens. After that the app keeps its own session (a cookie, a token, whatever it prefers):

  1. You open the app from the dashboard.
  2. The app receives the signed parameters.
  3. It checks the signature and the time.
  4. If they are valid, it creates a session and removes the parameters from the address.
  5. Next requests use the session: no new redirect is needed.
// Verification on the app's side
async function handleAuth(request, env) {
const { wr_store, wr_app, wr_ts, wr_sig } = await request.json();
if (!wr_store || !wr_app || !wr_ts || !wr_sig) return Response.json({ ok: false }, { status: 401 });

const age = Date.now() - parseInt(wr_ts);
if (age > 30_000 || age < 0) return Response.json({ ok: false, reason: 'Timestamp expired' }, { status: 401 });

const key = await crypto.subtle.importKey('raw', new TextEncoder().encode(env.APP_SECRET), { name: 'HMAC', hash: 'SHA-256' }, false, ['verify']);
const signature = Uint8Array.from(wr_sig.match(/.{2}/g).map((byte) => parseInt(byte, 16)));
const payload = new TextEncoder().encode(`${wr_store}:${wr_app}:${wr_ts}`);
if (!(await crypto.subtle.verify('HMAC', key, signature, payload))) return Response.json({ ok: false }, { status: 401 });

return new Response(JSON.stringify({ ok: true }), {
headers: { 'Content-Type': 'application/json', 'Set-Cookie': await createSessionCookie(env.APP_SECRET) },
});
}

The signature only tells the app that the launch came from your dashboard. If you prefer, the app can ignore it and use its own login.

Example: a shipping system​

You have an external system for shipments: a web application that shows your orders and creates shipments with your courier. It is not part of Webround, but it needs your orders.

Create an API key with only the permissions it needs, read and update orders, and set it as a secret of the app. The app uses it to call the Webround APIs. Add the app to your dashboard: you open it with a click, Webround authenticates it with the signed redirect, and from there it reads orders, creates shipments and updates statuses on its own.

One app, one key, with only the permissions it needs. If a key leaks, you revoke it and the damage is limited to what it could do.

Checkout hooks and apps​

A checkout hook can belong to an app with appId, and when you remove the app from the store, its hooks are deleted.