Persistent profiles
A profile keeps one browser identity between runs: its cookies and site storage, and the same persona, proxy, time zone, locale and screen every time it opens. The SDK, the CLI and the MCP server share profiles, and one file carries a profile to another machine.
What a profile is
A profile is a directory with a manifest.json and the browser's own user-data directory (Chromium's --user-data-dir):
<profiles root>/<id>/ manifest.json identity and settings (schema below) user-data/ cookies, storage, IndexedDB, service workers, preferences lock present while a browser has the profile open
The profiles root is NINJASURFER_PROFILES_DIR if set, otherwise $XDG_DATA_HOME/ninjasurfer/profiles (default ~/.local/share/ninjasurfer/profiles) on Linux, ~/Library/Application Support/ninjasurfer/profiles on macOS and %LOCALAPPDATA%\ninjasurfer\profiles on Windows. Directories and manifests are private to your user (0700/0600).
Each profile has:
| Field | Set | Changes |
|---|---|---|
id |
128 random bits (32 hex digits) at creation | never; local only, a new id on import |
name |
by you, unique in the root | rename |
| persona OS | win (default), mac or android |
never |
| persona seed | 64 random bits from the OS CSPRNG at creation | never (a clone gets a new one unless --keep-seed) |
| timezone, locale, proxy, screen, graphics, gpu mode | at creation | update |
Proxies: http://, https:// and socks5://, each with or without user:pass. socks4:// and socks4a:// are refused with PROXY_UNSUPPORTED ("use a socks5:// proxy"), a new one at create and a stored one at start; the profile keeps its identity, change its proxy to socks5. A socks5 proxy with credentials is authenticated by the engine itself (username/password, RFC 1929; username 1-255 bytes, password at most 255): the SDK writes them to a 0600 file in a private 0700 directory, passes only its path (--ns-proxy-credentials-file), and removes it when the browser closes; wrong credentials fail the connection, nothing goes direct. An http/https proxy with credentials reaches the browser through a local adapter on 127.0.0.1, because Chromium ignores credentials given on its command line; the timezone probe uses the same route as the browser. The adapter serves only its browser: connections from the same user (checked on Linux), proxy requests only (a page fetching the port directly is refused), no loopback, link-local or private targets, and limits on connections and header size; it closes with the browser. It also has deadlines: a request head must arrive whole within 30 s (else 408), and connecting to the upstream proxy and its answer to CONNECT must each complete within 30 s (else 504). A plain-HTTP connection idle both ways for 120 s is closed. An established tunnel (WebSockets, long downloads) has no time limit. Either side closing closes the other and frees the connection. The SDK never passes http_proxy, https_proxy, all_proxy or no_proxy from the environment to the browser: the proxy goes only on the command line.
An https proxy whose certificate is not publicly trusted takes its own CA with it: proxyCa (PEM text; MCP proxy_ca, CLI --proxy-ca-file FILE), stored in the manifest as settings.proxy_ca. Every launch of the profile gives it to the engine like proxy.ca of a launch: the browser trusts it for the TLS hop to the proxy alone (pages never see it), and an engine without private-CA support refuses the launch with PROXY_TLS private-ca-unsupported. It needs an https proxy; a change to a proxy that is not https (or none) drops it unless the change names one, and a new password keeps it. The CA is no secret: export, sync and clone keep it.
The id is an opaque handle for this machine; the seed cannot be derived from it, and neither is sent to sites. A profile always has its own seed, so it never falls back to the browser's seed 0.
Reopening a profile through any entry point gives the same browser: the Playwright wrappers, launchAgent, ninjasurfer start, ninjasurfer mcp and ninjasurfer profile start all take the persona and settings from the manifest. Passing a different value for one of them together with a profile is an error; change the profile with update instead.
Quick start
ninjasurfer profile create alice --scope local --persona-os mac --locale de-DE --proxy-file proxy.url ninjasurfer profile start alice --scope local # a headed browser; it runs until `profile stop` or you close its window ninjasurfer profile list --scope local
The profile commands (and every other MCP tool's: ninjasurfer cookies get, ninjasurfer navigate, …) are the MCP
tools themselves: the same flags as the tool's parameters, the same checks and the same answer (--json prints it). They
run on one NinjaSurfer host: the app while it runs, otherwise a background ninjasurfer mcp --host that the first command
starts and that exits after 10 idle minutes with no browser running. ninjasurfer profile create --help lists a command's
flags. A secret goes in a file only you can read (--proxy-file, chmod 600). A command that needs --confirm says what
it would do and exits 3 without it; a refusal exits 1 with CODE: message.
import { createProfile, NinjaSurfer } from "ninjasurfer";
await createProfile("alice", { personaOs: "mac", locale: "de-DE" });
const context = await NinjaSurfer({ profile: "alice", headless: false }); // BrowserContext
const page = await context.newPage();
await page.goto("https://example.com");
await context.close(); // writes the profile and unlocks it
// reopen later: cookies, storage and the persona are the sameWith profile, the wrappers return a Playwright BrowserContext (launchPersistentContext): all its pages share the profile. Without it they return a Browser with a throwaway profile, as before.
Agents and servers:
import { withAgent } from "ninjasurfer";
await withAgent({ profile: "alice" }, (agent) => agent.runTask("..."));ninjasurfer start alice --port 9222 # CDP endpoint for external agents ninjasurfer mcp # MCP server; browser tools name their profile
Persona identity
A win or mac profile whose fonts fit an entry pins, at creation, one entry of the persona catalog (personas/catalog/<version>.json, shipped in the SDK): the reference configuration chosen for its seed on this host (class, catalog version, entry id and the entry's SHA-256). It also pins its graphics class (swiftshader for graphics software, hardware-gpu for hardware; with auto, the class found at the first launch) and a CPU policy. The manifest keeps them under persona.catalog, environment and identity_revision.
The seed draws from the catalog's typical core: laptops and desktops in landscape, touch only with a battery, and screen sizes and DPRs most machines have. Sites score a configuration by how rare it is (touch on a desktop or a portrait screen stands out), so a new profile stays where most machines are. Rare entries are real machines as well and stay available: by name (catalogEntry), or let the seed draw them with rareEntries: true. Existing profiles keep their entry.
The theme (light or dark, prefers-color-scheme) follows real shares as well. A win profile draws it once from its seed by its entry's Windows version (Windows 10 about 20% dark, Windows 11 about 41%) and passes it on every launch (--persona-color-scheme); a mac or android profile has its entry's own. It stays the same as long as the profile's catalog pin does; personaColorScheme or the switch in args overrides it for a launch.
Fonts of an entry: the win and mac entries name a font slot ({"mode": "slots", "slots": ["win"]}), not packs. A new win/mac profile resolves the slot of its OS through the browser from the font repository (see font slots in the SDK READMEs) and fits the entry because its pins came from that slot (fonts.slots.names). Pins made otherwise (explicit packs, the standard set, host fonts) do not fit: the profile is outside the catalog (uncatalogued). Where the slot cannot be resolved at creation (no installed browser, no repository), the profile gets the standard packs with a warning and is outside the catalog until migrated. An older entry that lists packs is matched by its pins as before.
Every launch checks them again, without choosing again, before the browser opens the profile's data: the entry is still in the shipped catalog unchanged, the executable's engine version (--version) is in the entry's range, the host has the CPUs the entry needs, the graphics class is the pinned one (a profile pinned to hardware-gpu is refused on a host without a usable GPU instead of falling back to SwiftShader), and the fonts are the entry's (pins resolved from its slots, or its packs). A mismatch fails with ProfileCompatibilityError and a reason code: cpu-unavailable, engine-out-of-range, engine-unknown, graphics-class-unsupported, fonts-unavailable, entry-changed, catalog-outdated (the profile pins an older persona catalog than the one this SDK ships: update it with profile migrate), catalog-version-unknown (a newer one: update NinjaSurfer), catalog-not-in-browser, catalog-not-native, catalog-not-applied-natively, catalog-auto-applied.
Catalog mode (environment.catalog_mode) says whether the entry is actually applied:
strict: the browser applies the entry natively. Its--persona-diagnosticsreport names the catalog version and entry, and every launch passes--persona-catalog-versionand--persona-catalog-entry, plus--persona-catalog-entry-sha256when the browser checks the hash itself. Astrictprofile on a browser without the catalog is refused withcatalog-not-native; it never runs silently without its entry. A browser whose report also names the entry it applies (personaCatalog.selected, earlierentry) is asked again with those switches and must name the pinned entry, elsecatalog-not-applied-natively.legacy: the entry is recorded (fonts, CPUs, engine range are still checked) but not applied: the browser derives the persona from the seed as before the catalog. The profile's info and every launch saycatalog-not-applied; when the browser does have the catalog, launches also saycatalog-available (profile migrate applies it). A legacy profile passes no catalog switches, and the browser must then apply no entry: one whose report names another entry it picked by itself is refused withcatalog-auto-applied, since it would change the seed-derived identity without a migration. A browser that picks the pinned entry's id by itself and carries the pin gets the pin by its hash, and the launch sayscatalog-pin-applied (…). Restarts,cloneProfilewithkeepSeedand export/import keeplegacy; onlymigrateProfilechanges it, as a new identity revision (the previous manifest kept asmanifest.rev<N>.json); a refused migrate changes nothing.
Create, clone and migrate ask the browser (chrome, else CHROME_BIN, else the installed build): strict if it applies the entry, otherwise legacy with a warning on stderr. So a profile created with a browser that does not apply catalog entries is legacy; migrateProfile with one that does makes it strict. Manifests from before catalog modes read as legacy: no browser applied an entry then.
CPUs: an entry fixes hardwareConcurrency (Windows T4: 4, Mac M4: 10). By default (cpuPolicy: "strict") a profile is neither created nor launched on a host with fewer available CPUs. cpuPolicy: "capped" (CLI --allow-cpu-cap) is an explicit deviation from the entry: the browser reports the available CPU count, and the profile's info and every launch (instance.degraded) say cpu-capped (host N < entry M).
Changing the identity is explicit: migrateProfile(name, { cpuPolicy, graphics, catalogVersion }) / ninjasurfer profile migrate chooses again on this host as a new identity revision and keeps the previous manifest as manifest.rev<N>.json. It also brings profiles created before identities (revision 0) into the catalog. Export and import keep the pinned identity. Profiles on host fonts, or with fonts that no entry has, and android profiles are outside the catalog; their info says uncatalogued for win/mac.
instance.graphicsState() reports the class the running browser actually has (after repeated GPU process crashes Chromium may disable acceleration): {pinned, observed, degraded}. The profile keeps its class either way.
Native GPU (gpuMode)
A mac persona on a Mac whose GPU is exactly the persona's GPU model can render natively, with no emulation of what pages read: the engine decides this at every browser start. The SDK only allows it or forbids it, and reports the engine's decision.
- Setting:
gpuMode,"auto"(default: the engine decides) or"emulated"(never native; the launch passes--ninjasurfer-gpu-mode=emulated,"auto"passes nothing). Stored assettings.gpu_mode; manifests without it read as"auto". Set withcreateProfile(name, { gpuMode }),updateProfile(ref, { gpuMode })or CLIprofile create|update --gpu-mode auto|emulated; it applies from the next start. Any other value:invalid gpuMode "<v>"; expected "auto" or "emulated". - One launch:
startProfile(ref, { gpuMode })wins over the stored setting for that launch only;NinjaSurfer({ gpuMode })the same for the wrappers. NINJASURFER_GPU_MODE(autooremulated, for test harnesses) is the default when the launch names no mode and the profile's setting is the default"auto"; an invalid value fails the launch with the same error.instance.gpu(also onstartProfile's instance):{mode, native, reason, model, host}, wheremodeis the launch's effective mode,nativeis true only for reason"native",modelis the persona's GPU model andhostthis Mac's GPU{name, cores, family}as the engine saw them. The engine writes them to<user-data>/NinjaSurferGpuState.jsonat start; the SDK removes a stale one before every launch and reads the new one once the browser is up (waiting up to 10 s, only for amacpersona on a Mac with an engine that has the patch). Without it the SDK says why, withnativefalse andmodel/hostnull:host-not-mac,model-not-native(the persona is notmac),requested-emulated,engine-unsupported(the engine does not support native GPU) orunreported. The engine's own reasons arenative,requested-emulated,host-not-mac,model-not-native,host-gpu-mismatchandgpu-info-mismatch. The Playwright wrappers (NinjaSurfer) pass the mode but do not report the state.
Browser updates and snapshots
Chromium records in <user-data>/Last Version which version last opened a profile's data, and migrates its databases forward when a newer build opens it; an older build cannot read them back, and rolling back the executable does not roll back the data. Before any browser opens a profile's data (every launch, and export/import), the SDK compares the executable's own version (--version) with Last Version:
- older: refused with
ProfileCompatibilityErrorreasonbrowser-downgrade; nothing in the profile changes; - newer: the data is first copied to
<profile>/snapshots/<old version>-<time>/(caches left out; the two newest snapshots are kept), then the browser starts; - the same, or data never opened (no
Last Versionand no browser files): nothing to do; - data with browser files but a missing, unreadable or damaged
Last Version: refused withPROFILE_RECOVERY(reasonlast-version-missing,-unreadableor-damaged). The version that wrote the data is unknown, so it is never taken as safe to open. Restore a snapshot, or write the version intoLast Versionif you know it. On import, data without the file gets the version the archive's manifest records (browser.last_version).
profileSnapshots(name) lists them (newest first) and restoreSnapshot(name, snapshot) puts one back while the profile is closed; the data it replaces is kept as a new snapshot first. validateProfile reports a downgrade or data that needs recovery without touching anything.
Interrupted restores
A restore is journaled in <profile>/.restore/ and never leaves the profile without its data:
- the snapshot is copied to
.restore/new; the current data is kept as a snapshot; - the active data is renamed to
.restore/old, and the copy is renamed into place; .restoreis removed.
Every copied file and directory, the journal and the profile directory are fsynced before each rename, so a power loss cannot leave a renamed but empty copy. A snapshot is written aside and renamed in the same way; an unreadable file fails it instead of leaving it partial.
- A failure before step 2 (no space, I/O or permission error) removes
.restore; the data is untouched. - A failed install is rolled back: the original data goes back in place and the error is raised.
- If the rollback fails too,
.restore/oldkeeps the original, the journal recordsrollback-failed, and every launch, export and restore is refused withPROFILE_RECOVERYuntilrecoverProfile(name)puts the original back. - A process killed during a restore is put right on the next use of the profile: the original data if the copy was not yet installed, the restored data if it was.
Lifecycle and error codes
The SDK's verbs:
| Verb | What it does |
|---|---|
getProfile(ref) |
The profile by name or id. |
validateProfile(ref, {chrome}) |
Every check a start would make (manifest, pinned identity against this host and executable, font pins), without starting the browser or taking the lock. Returns {ok, profile, problems}; each problem is {code, reason, message}. |
startProfile(ref, opts) |
A ready browser with its own DevTools endpoint. A profile that is already open fails with PROFILE_LOCKED naming the holder. |
profileStatus(ref) |
stopped, running (holder pid, browser pid, port, kind) or running-elsewhere, from the lock; no browser is contacted. |
health(instance) |
Alive, the browser version, the graphics state against the pinned class, the launch's deviations. |
stopProfile(ref) |
Clean quit and unlock; succeeds when the profile is already stopped. |
exportProfile, importProfile, migrateProfile, capabilities() |
As described above; capabilities() returns the engine-independent capability registry shipped with the SDK. |
errorCode(error) maps any SDK error to one of these codes (treat an unknown code as INTERNAL). reason carries the finer code: the design reason of PROFILE_INCOMPATIBLE (cpu-unavailable, …) or the browser's font-pack code.
| Code | Meaning |
|---|---|
PROFILE_NOT_FOUND |
No profile with this name or id. |
PROFILE_EXISTS |
A profile with this name already exists. |
PROFILE_LOCKED |
The profile is open in another process (or on another host). |
PROFILE_FORMAT |
The profile manifest is damaged, incomplete or newer than this SDK. |
PROFILE_INCOMPATIBLE |
The profile's pinned identity cannot run here; reason carries the design code (cpu-unavailable, engine-out-of-range, graphics-class-unsupported, ...). |
PROFILE_REFUSED |
The operation is refused in the profile's state (open in this process, a pinned value changed directly, client keys in an unencrypted export, ...). |
PROFILE_FONTS |
The profile's pinned font packs are missing, other or damaged. |
FONT_PACK |
A font-pack command failed; reason carries the browser's code. |
ARCHIVE_INVALID |
A profile archive is damaged, truncated or not an archive. |
ARCHIVE_PASSPHRASE |
Wrong or missing passphrase for an encrypted archive. |
PROXY_UNSUPPORTED |
The proxy URL is refused (scheme, credentials, form). |
PERSONA_CPU |
An older build refuses a persona with more CPUs than the host. |
SANDBOX_UNAVAILABLE |
The Chromium sandbox cannot start on this host. |
ENDPOINT_OWNERSHIP |
The DevTools port is taken, or the endpoint is not the browser this SDK started. |
BROWSER_START_FAILED |
The browser exited or did not answer before its DevTools endpoint came up. |
START_CANCELLED |
The caller's signal stopped a profile start; the browser it had started is stopped and its locks and leases released. |
BROWSER_NOT_INSTALLED |
The browser is not installed and downloading was not allowed. |
RELEASE_ACCESS |
The release could not be read (network, access). |
INVALID_ARGUMENT |
An invalid option or setting (rejected before anything starts). |
PROFILE_RECOVERY |
The profile's data needs recovery before use: an interrupted restore (rollback-failed, restore-indeterminate: run recoverProfile) or an unknown data version (last-version-missing, -unreadable, -damaged: restore a snapshot). |
INTERNAL |
Anything else. |
Network stack
A win, mac or android profile that connects directly (no proxy, no VPN) on a computer of another OS, and an iPhone
profile on Linux, go out through the persona OS's network stack: profile open, start, Desktop, MCP and the
library all need the network module, or they stop with NETSTACK_NEEDED before anything launches (see
system components). There is no mode that starts such a profile on this
computer's own network stack: a published SDK, CLI or MCP ignores NINJASURFER_NETSTACK_MODE=off and refuses
netstack: "off". Through a proxy the profile starts without the module (sites see the proxy's stack); through a VPN
too (NinjaSurfer's VPN client carries the persona's stack).
VPN on networks with DPI
Some networks let a VPN handshake through and then cut the flow. A profile's VPN then fails with VPN_BLOCKED: the
tunnel came up, but nothing comes back through it. On a residential line behind such filtering,
WireGuard, OpenVPN (UDP and TCP) and VLESS with a CDN domain as its Reality SNI were cut; AmneziaWG 1.0/2.0/3.0 and
Hysteria2 passed, and so did VLESS Reality once its SNI was the server's own domain. For VLESS Reality, use an SNI
(and dest) that really lives on your server's IP, best your own domain on that server; a big CDN's domain
(www.cloudflare.com, www.microsoft.com, …) on a server that is not that CDN is the mismatch these filters look
for, and the error names it.
Media devices
media (--media in the CLI) says which microphone, speaker and camera the persona shows; the browser side is --persona-media:
media |
Pages see |
|---|---|
system-audio (default) |
the system default microphone and speaker, labelled for the persona OS; no camera |
none |
no media devices |
host |
the same audio plus one host camera (mediaCamera / --media-camera: the browser's id of it; default the first), masked as the persona's |
A profile stores it (settings.media, settings.media_camera; older manifests read as system-audio) and every launcher passes the same switches: NinjaSurfer(...), launchAgent, startProfile, ninjasurfer start and mcp. Without a profile it is an option of each of them and needs a persona (a seed or a persona OS). Setting --persona-media in the extra arguments too is an error. Changing media away from host drops the camera. Export and import keep the setting; the cookie-reading browser of export/import starts with none.
Before starting, a mode other than system-audio is checked against the capability registry for the executable (media.persona-devices, capabilities): absent, planned or failed there refuses with CAPABILITY_UNSUPPORTED (reason media:<mode>). Another build gets status unknown and starts; a build without --persona-media would ignore it and show system-audio. Permission to use a device is still the page's ordinary prompt (or grantPermissions in automation); no mode grants it.
Crash reports
Chromium on Linux keeps its crashpad database (a client id and the crash dumps) in its default data directory, ~/.config/chromium/Crash Reports, whatever --user-data-dir says, which would make profiles share the user's. Each profile's browser gets its own, <profile>/crash (BREAKPAD_DUMP_LOCATION): a crash in one profile leaves nothing in another profile or in the user's directory. Before each launch the SDK keeps at most 128 MB of reports there and none older than 365 days (crashpad's own defaults), the oldest going first. Clones and archives never carry it, and deleting the profile deletes it.
Limitation: a crash of the browser process itself is always written there, but a renderer crash needs the crash handler to attach to the crashed process with ptrace. Where the kernel refuses that (Yama kernel.yama.ptrace_scope 1 or higher, or a container without CAP_SYS_PTRACE), renderer crashes leave no dump; the browser logs ptrace: Operation not permitted. The tab still shows its crash page; only the report is missing.
Browser extensions
Chromium installs an extension placed in a profile through <user-data>/External Extensions/ only while its default-apps and extension providers are on. Two switches turn them off: --disable-default-apps (the External Extensions provider) and --disable-extensions.
launchAgent,ninjasurfer start PROFILE,ninjasurfer profile open,startProfileand the MCP server pass neither: extensions in a profile load.- The Playwright wrappers (
NinjaSurfer(...)) launch through Playwright, which adds both switches by default; the wrappers drop them (with the other switches listed in Playwright default switches), so extensions load there too. An explicitignoreDefaultArgs/ignore_default_argsof yours is passed to Playwright as given. - If you start the browser yourself and connect over CDP (Playwright
connectOverCDP, Puppeteerconnect), do not add those switches.
Several profiles at once
Different profiles run side by side. Each browser has its own process and process group, its own user-data directory, its own DevTools port (port 0 by default; the SDK identifies its browser from the browser's own stderr) and its own proxy, time zone, locale and persona through that process's arguments and environment. Closing or crashing one never touches the others: the SDK stops only its own process group.
ninjasurfer profile start A --scope local ninjasurfer profile start B --scope local ninjasurfer profile status --scope local # the profiles running here ninjasurfer profile stop A --scope local --confirm
The same profile opens only once at a time. A second open fails with ProfileLockedError naming the process that holds it. The lock is an exclusive flock on the profile's lock file (O_EXLOCK on macOS and the util-linux flock command on Linux), so the kernel releases it when the holder exits or dies (crash, kill -9) and the profile then opens with its cookies and storage; there is no stale lock to break. The file is never deleted; while held it names the holder (pid, host, kind, port) for information only. Profiles roots on network filesystems are not supported. On Linux the SDK needs the util-linux flock command for this (present on common distributions; without it, opening a profile or installing the browser fails at once with an error saying so). The same lock serializes browser downloads into the cache.
NINJASURFER_MAX_INSTANCES=N limits how many profiles may be open at once on this profiles root.
One persona per proxy exit. Give each profile its own egress IP and keep it. Anti-fraud services link visits by IP: when several personas leave through the same IP, each one shows up there as a new visitor on an address that has already been seen with other devices. Anti-fraud services may then flag such visits as suspicious even though the browser itself is unchanged, most often on the first visit after a switch. Rotating personas on one IP therefore costs both a new visitor id and a risk of being flagged. A profile created with timezone: "auto" and locale: "auto" takes its zone and language from its exit, which assumes that exit stays the profile's own.
Certificates. Chromium keeps client certificates and the CAs a user adds outside user-data. On Linux they are in an NSS database: $HOME/.pki/nssdb if that directory exists, else $XDG_DATA_HOME/pki/nssdb. A profile's browser therefore runs with HOME=<profile>/home, which holds the profile's own NSS database (.pki/nssdb), so a certificate imported in one profile is not offered by another. Everything else stays the user's: XDG_DATA_HOME, XDG_CONFIG_HOME, XDG_CACHE_HOME and XDG_STATE_HOME are passed explicitly (fontconfig and its cache, GTK, dconf, crash reports), D-Bus and XDG_RUNTIME_DIR are untouched (the Secret Service or KWallet that encrypts cookies), XAUTHORITY points at the user's file, and ~/.fonts, ~/.fonts.conf, ~/.icons and the download directory are links to the user's own. A profile with pinned font packs gets --font-packs-dir explicitly. Temporary browsers (no profile) are unchanged. On macOS and Windows client certificates live in the Keychain and the Windows certificate store, which a profile does not separate: every profile of the same OS user sees them.
The MCP server keeps one browser per profile: every browser tool names its profile (name or id); a call without one is refused with INVALID_ARGUMENT. profile_status and profile_stop manage them.
Closing a profile quits the browser cleanly through DevTools (Browser.close; SIGTERM to the process group only if it does not exit in time), so Chromium writes cookies and storage before it exits. Session cookies (without an expiry) end with the browser, as in Chromium.
Export and import
export writes a closed profile to one .nsprofile file; import turns it into a new profile, on this or another machine:
ninjasurfer profile export alice alice.nsprofile # asks for a passphrase ninjasurfer profile import alice.nsprofile --name alice # on the other machine
The imported profile gets a new id. Its persona OS and seed and its settings are kept, so the browser reports the same persona fields. What a site sees also depends on the host: GPU and rendering, screen, CPU and network are this machine's, and a profile does not carry them. Fonts are this machine's only for a profile in host-font mode; a profile that pins font packs (the default for win and mac) needs the same packs installed here: the original Windows or macOS fonts of its OS version (see Personas). If the archive was last used with a newer browser than this SDK's, import warns: an older browser may not open newer profile data.
What moves. Cookies (httpOnly and partitioned included), localStorage, sessionStorage, IndexedDB, Cache Storage, service workers and preferences. Chromium encrypts its cookie database with a key from the operating system (Secret Service on Linux, Keychain on macOS, DPAPI on Windows), so copying that file to another machine would leave every cookie unreadable. Export therefore starts the profile's browser briefly, headless and off the network (a black-hole proxy and no DNS), reads every cookie through DevTools (Storage.getCookies), and copies the other files without the encrypted databases and without the OS-bound key in Local State. Import writes the cookies back through the new profile's browser (Storage.setCookies), also offline, so they are encrypted with the new machine's key and no cleartext copy stays on disk.
Certificates (Linux). The profile's NSS database (client certificates with their private keys, added CAs) moves inside the encrypted payload. An archive without a passphrase refuses a database that holds private keys ("contains client keys") unless --exclude-certificates (excludeCertificates: true) leaves the certificates out, with a warning. clone --with-data copies them too.
What does not move. Saved passwords and payment cards (encrypted the same way), session cookies (they end with the browser) and caches the browser rebuilds (HTTP cache, GPU and shader caches).
Protect the file. The archive holds live logins. With a passphrase (the default; the CLI asks, or reads --passphrase-file/--passphrase-env), the whole payload is encrypted. Without one you must say so (--insecure-no-passphrase, insecureNoPassphrase: true) and the SDK warns. The proxy password is left out unless --include-proxy-password, which needs a passphrase; without it the import warns, and profile update NAME --proxy ... sets it. Nothing about the profile (name, persona, settings, proxy) is readable from an encrypted archive without the passphrase: the clear header holds only the format and the key-derivation parameters. The MCP tools profile_export/profile_import take only the name of an environment variable of the server (passphrase_env), so the passphrase never passes through a model's context.
A profile must be closed to be exported: export of an open profile fails with "profile … is already open …; close it first".
Archives are checked before anything is created: format, checksum, passphrase (a wrong one is reported as such, not as damage) and, inside, every path. Damaged, truncated or modified archives are refused.
Data on disk and who can read it
A profile directory (0700) holds, per profile:
| Path | What | Protection |
|---|---|---|
manifest.json (0600) |
persona, settings, pins; the proxy URL with its password | none beyond file permissions |
user-data/ |
the browser's data: cookies, storage, history, saved passwords, Local State |
cookies and passwords are encrypted by Chromium with the OS key (Keychain, DPAPI; on Linux the Secret Service, and without a keyring Chromium's basic store, whose key is a fixed value, so the files are as readable as their permissions) |
home/.pki/nssdb (Linux) |
client certificates with their private keys, added CAs | NSS database without a master password: file permissions |
snapshots/ |
full copies of user-data taken before a browser upgrade (the last 2) |
as user-data |
crash/ |
crash dumps, up to 128 MB / 365 days (see Crash reports) | may contain page memory, so tokens: file permissions |
Threat model: every file is readable by any process running as the same OS user, and by root. The SDK adds no encryption of its own to a live profile, on purpose (no home-made cryptography). Where other local users or a stolen disk matter, put the profiles root on an encrypted volume (FileVault, LUKS, BitLocker) and give each tenant its own OS user. Archives from export are the one thing the SDK encrypts (AES-256-GCM with an scrypt key from your passphrase); they leave the proxy password out unless asked.
Deleting a profile (deleteProfile, profile delete) removes the directory, snapshots and crash dumps included. It does not overwrite the blocks: on SSDs and copy-on-write file systems that cannot be guaranteed anyway, so rely on volume encryption for erasure. Copies you make yourself (backups, clone --with-data, archives) are outside the SDK's reach.
Snapshots and restore cover the browser data only (user-data: cookies, storage, preferences). Restoring one does not change the manifest (identity, settings, proxy, font pins) or the certificates in home/.pki/nssdb: a certificate added after the snapshot stays, one removed stays removed. For a full rollback, export the closed profile and import the archive instead. clone --with-data copies sessions and certificates on purpose: the clone has a new id but the same logins, so sites can link it to the original.
Errors and diagnostics never carry the proxy password: refused proxy URLs are described with *** or without the credentials, egress-probe warnings and lifecycle problems name no credentials, and profile info, lists and conflicts show the proxy redacted.
A profile is managed on one host at a time: the lock records the host, and a profile open elsewhere is refused. Sharing one profiles root between hosts (NFS and the like) is not supported: there is no sync, lease or conflict resolution.
Other commands
ninjasurfer profile get alice --scope local [--json] # manifest, proxy password hidden ninjasurfer profile update alice --scope local --name carol ninjasurfer profile update carol --scope local --timezone Europe/Berlin --no-proxy --window-size 1280x800 ninjasurfer profile update dave --scope local --proxy-file proxy.url --proxy-ca-file proxy-ca.pem ninjasurfer profile clone carol carol2 --scope local [--keep-seed] [--with-data] # same settings, new id and seed, no data ninjasurfer profile delete carol2 --scope local --confirm # without --confirm it says what it would do (exit 3)
A clone starts empty with the source's settings and persona OS, a new id and a new seed. --with-data also copies cookies and site storage, which lets sites link the two whatever their seeds (it warns); --keep-seed makes both report the same persona fields (it warns too). Deleting an open profile, or cloning one with its data, is refused.
The SDK's operations: createProfile, listProfiles, getProfile, renameProfile, updateProfile, cloneProfile, deleteProfile, startProfile, stopProfile, runningProfiles, exportProfile, importProfile. startProfile returns an instance with pid, port, wsUrl, endpoint and close().
Manifest
manifest.json, schema version 1:
{
"schema": "ninjasurfer.profile",
"schema_version": 1,
"id": "3f1c9a0d2b7e4c6f8a1d0e5b9c2f7a64",
"name": "alice",
"created": "2026-10-06T12:00:00Z",
"updated": "2026-10-06T12:30:00Z",
"persona": {"os": "mac", "seed": "9d2c4e1f7a3b6c80"},
"settings": {"timezone": "auto", "locale": "de-DE", "proxy": "http://user:pass@proxy:8080",
"window_size": "auto", "graphics": "auto", "gpu_mode": "auto", "media": "system-audio", "media_camera": null},
"browser": {"last_version": "156.0.8078.80-ns.44", "last_opened": "2026-10-06T12:29:00Z",
"executable_sha256": "…", "font_packs": ["noto-cjk@1.2.3"], "font_packs_dir": null},
"origin": null
}timezone is "auto" (the egress IP's zone, through the proxy), an IANA name, or null for the host's. window_size is "auto" or [width, height]. origin records a clone (cloned_from, with_data) or import (imported_from, imported_at). browser describes the last launch for information only: the browser version, the SHA-256 of the executable, and the font packs selected as given (id or id@version) with their store; it does not record the hardware, fonts or fontconfig of the host. The manifest stores the proxy as given, password included, readable only by your user.
An SDK reads manifests up to its own schema version. An older manifest is migrated step by step when it is loaded; the original is kept as manifest.v<N>.json. A manifest from a newer schema is refused without being changed: update the SDK.
Archive format
.nsprofile, format version 2. All integers are big-endian.
offset 0 "NSPROFILE\0" 10-byte magic
u32 header length (1 … 1 MiB)
header UTF-8 JSON
frames u32 length (1 … 1 MiB + 16), then that many bytes
u32 0 end of frames
32 bytes SHA-256 of every byte before the u32 0The header is in the clear, so it holds nothing about the profile:
{"encryption": null, "format": "ninjasurfer.profile-archive", "format_version": 2}The payload is a gzip stream of records, cut into frames of at most 1 MiB:
| Record | Layout |
|---|---|
| directory | "D", u16 path length, path, u32 mode |
| regular file | "F", u16 path length, path, u32 mode, u64 size, size bytes |
| end | "E" (exactly once, last) |
Paths are relative, /-separated UTF-8 (at most 4096 bytes) with no leading /. Every component is a name that is valid on Windows, macOS and Linux: not empty, . or ..; at most 255 bytes; none of <>:"\|?*, control characters or NUL; no trailing dot or space; not a Windows device name (CON, PRN, AUX, NUL, COM1–COM9, LPT1–LPT9, with or without an extension). An export leaves out files whose names break this rule and reports their paths (onSkipped). If such a path is or holds Cookies, Login Data, Preferences or Local State, the export fails. The first record is archive.json: {"created", "sdk", "profile"} with the manifest (proxy password removed unless requested). Then cookies.json ({"cookies": [...]}, DevTools Network.Cookie objects) and the user-data/ tree. Symbolic links, hard links and special files cannot be expressed. A reader refuses unknown record types, duplicate paths, data after the end record and anything else at the top level, each before it creates the record's file or directory.
With a passphrase, encryption is:
{"cipher": "aes-256-gcm",
"kdf": {"name": "scrypt", "n": 131072, "r": 8, "p": 1},
"salt": "<16 random bytes, base64>",
"nonce_prefix": "<8 random bytes, base64>",
"chunk": 1048576,
"key_check": "<base64 of the first 16 bytes of HMAC-SHA256(key, \"ninjasurfer profile archive key check\")>"}The key is scrypt(passphrase as UTF-8, salt, n, r, p, 32 bytes). Frame i (from 0) is AES-256-GCM(key, nonce = nonce_prefix ‖ u32 i, plaintext = payload chunk, associated data = header bytes ‖ (0x01 if it is the last frame else 0x00)), stored as ciphertext followed by the 16-byte tag. The header, the frame order and the end of the stream are therefore authenticated, and key_check distinguishes a wrong passphrase from a damaged file. Readers accept scrypt costs up to n = 2²⁰, r = 16, p = 4.
Without a passphrase, encryption is null and frames hold the gzip stream in the clear; the trailing SHA-256 detects damage and truncation.
A reader rejects a format_version newer than its own. Format 1 (the first release of profiles) kept the manifest in the clear header ("profile", "created", "sdk", "payload") and had no archive.json; the SDK still imports it.