Show the desktop · NoMac
Docs · Show the desktop+
Show the desktop
Your user watches their Mac, or uses it, right in your page with no NoMac sign-in, and their agent gets a token for that Mac only.
A link
TypeScriptPython
const { url } = await mac.viewLink({ control: true }); // or watch only: viewLink()
// https://nomac.app/mac/view/...: open it, or put it in an iframe with ?embed=1
- Watch shows the screen live. Control adds the keyboard and mouse.
- One controller at a time: a newer control link takes over, and the one before watches and can take control back.
- Two viewers per Mac at once. Watching never keeps the Mac running, so it still stops at its idle timeout.
- A link lasts 2 hours by default, a day at most, and ends with its Mac. It works for your user's Mac only.
In your page
HTML
<iframe src="https://nomac.app/mac/view/...?embed=1"
style="width: 100%; aspect-ratio: 16 / 10; border: 0"></iframe>
?embed=1shows only the screen, at any size, without the page's own bar. The desktop streams as video, so it needs a current Chrome, Edge, Safari or Firefox.
Only on your site
TypeScriptPython
const { url } = await mac.viewLink({ control: true, allowedOrigins: ["https://app.example.com"] });
- The link then opens only in a frame on one of those sites. It does not open on its own page or on another site.
- Give each as
https://, a host and an optional port.https://*.example.comcovers the subdomains.http://localhost:3000works for testing. - Up to 10 sites per link. Browsers keep to them; to stop a copied link anywhere, sign your user too.
Only for your user
TypeScriptPython
import { signVisitor } from "@nomac/sdk";
// Once. Keep the secret on your server (here NOMAC_EMBED_SECRET), never in a browser.
const { secret } = await nomac.embed.newSecret();
// On your server, for each page load: the link names your user, and you sign them.
const { url } = await mac.viewLink({ control: true, allowedOrigins: ["https://app.example.com"], visitor: user.id });
const visitor = await signVisitor({ secret: process.env.NOMAC_EMBED_SECRET, sessionId: mac.id, visitor: user.id });
const src = `${url}?embed=1#visitor=${visitor}`;
// In your page: <iframe src={src}>
- The link opens only with your server's signature for that user. A copied link opens nothing.
- The signature is a JWT signed with HS256 and the secret:
subis your user's id,sidthe Mac's id andexpat most 15 minutes ahead. Any JWT library can make it. - It goes after
#visitor=, so it never reaches a server log, and the page takes it out of its address. The page then keeps working until the link expires, and reconnects by itself. - A new secret replaces the old one at once. Views already open keep working.
For every link
TypeScriptPython
await nomac.embed.set({ allowedOrigins: ["https://app.example.com"], requireVisitor: true });
Both then apply to every link made over the API from then on, a Mac token's links too. A link can name fewer sites, never others. Links made before keep what they had.
A token for their agent
TypeScriptPython
const { token } = await mac.token({ minutes: 120 });
// Your user's agent, with that token only:
const theirs = new NoMac({ token }).mac(mac.id);
const { stdout } = await theirs.run("xcodebuild -list");
An nmm_…token reaches that Mac's commands and jobs, files and file links, screenshot, input, recording, password and view links. It never reaches another Mac, a start, a stop, an extension, your account's list or its price. It lasts 2 hours by default, a day at most.
Take it back
TypeScript
await mac.revokeTokens(); // every token and link of this Mac made so far; the Mac runs on
Open views close within 20 seconds, and new tokens and links work at once. Revoking the API key that made them ends them too. Over REST: DELETE /api/v1/mac/sessions/{id}/token.
Over REST, a link is POST /api/v1/mac/sessions/{id}/viewwith { "control": true, "minutes": 120 }, and allowed_originsand visitorif you need them. A token is POST .../tokenwith{ "minutes": 120 }. The defaults are GETand PUT /api/v1/embedwith{ "allowed_origins": [...], "require_visitor": true }, and the secret POST /api/v1/embed/secret. See Mac API.