Licensing
Certeno is a licensed SDK. A licence decides which features your app can use. This page explains which licence you need for each kind of app, how to configure it in a React or vanilla viewer, in a desktop app and on a server, and what happens when it does not verify.
Which licence do I need
A licence belongs to a plan, and a plan is made for one place to run Certeno. The three places work differently:
| Your app is | Plan | What you hold | You configure it with | If the licence does not verify |
|---|---|---|---|---|
| A web page (React, Next.js, vanilla JS, Vue) | Browser plan, tied to your domains | A site ID (site_…), or a signed domain token | The viewer's licensing option | The PDF still opens, with the free Viewer features only |
| A desktop app (Electron, Tauri) | Desktop plan, tied to machines | A licence key (CERT-…) | The app's native side activates the machine and passes the viewer an activation token | The same as a web page |
| A server or script (Node.js, headless) | Server plan, tied to machines | A licence key (CERT-…) | createVerifier({ licence }) | The verifier does not start |
The viewer is something people use, so a licence problem there degrades it and never blocks a document. The headless engine is the product a Server plan sells, so without a valid licence it refuses to run.
In all three the licence is checked locally. The licence server signs a token, and Certeno's own engine verifies the signature against a public key and an issuer that are built into the SDK. A token from any other server fails.
Note: A licence key is a credential. Keep it out of web page code. A site ID is different: it is public, like a publishable key, and is meant to be in page code. Never use a licence-server API key in an app you ship.
To get a licence, request an evaluation or a production licence on the contact page. Plans are on the pricing page.
Web pages: React and vanilla JS
Pass licensing with one of three values:
| Value | Use it when |
|---|---|
{ siteId: 'site_…' } | You have a public site ID. The viewer fetches short-lived tokens from the licence server and renews them itself. |
{ domainToken: '…' } | You were issued a signed domain token. It is verified in the browser, with no request to the licence server. |
{ activationToken: '…' } | A desktop app passes the token its native side holds. See Desktop apps. |
If you give more than one, activationToken wins, then domainToken. Without licensing the viewer offers only the free features, the same ones as the Free Viewer plan. No signature is verified, and there is no print, download or open file.
React
The React viewer is composed by you: check the licence with a hook, and put LicenceFeaturesProvider above CertenoProvider:
import { useState } from 'react'
import {
CertenoProvider, Viewer, WelcomeScreen, useVerification, defaultLayoutPlugin,
useLicence, licenceNoticePlugin, LicenceFeaturesProvider, type LicenceState,
} from '@trexolab/certeno-react'
const config = { workerUrl: '/pdf.worker.min.mjs' }
export function App() {
const licence = useLicence({ siteId: 'site_…' })
if (!licence.ready) return null // the check takes a moment, at most five seconds
return (
<LicenceFeaturesProvider features={licence.features}>
<CertenoProvider config={config}>
<PdfViewer licence={licence} />
</CertenoProvider>
</LicenceFeaturesProvider>
)
}
function PdfViewer({ licence }: { licence: LicenceState }) {
const verification = useVerification()
const [layout] = useState(() => defaultLayoutPlugin())
if (!verification.fileBuffer) {
return <WelcomeScreen onOpenFile={(file) => verification.load(file)} />
}
// A licence that did not verify keeps the free features, and says so.
const plugins = !licence.licensed && licence.reason !== 'NO_LICENCE'
? [layout.plugin, licenceNoticePlugin()]
: [layout.plugin]
return (
<Viewer
fileBuffer={verification.fileBuffer}
fileName={verification.fileName}
plugins={plugins}
onOpenFile={(file) => verification.load(file)}
signatures={verification.signatures}
unsignedFields={verification.unsignedFields}
verificationStatus={verification.status ?? undefined}
/>
)
}Each part has a job:
useLicenceruns the check once and returns the licence's state.LicenceFeaturesProviderhands the licence to the viewer. The viewer runs only the plugins and controls the licence includes,useVerification()verifies only withsignature_verification, andCertenoProviderignores options the licence does not include. You do not have to disable anything yourself.- It takes the
featuresthatuseLicencereturned. A list you write yourself is ignored. - Without the provider only the free features are available.
licenceNoticePlugin()adds a slim bar that says some features are unavailable when the licence did not verify.licence.has('print')says whether a feature is included, for your own buttons.
When signatures are not verified
Under a licence without signature_verification (the Free Viewer plan, or a licence that could not be verified), the PDF opens and nothing is verified. The signature on the page looks as the file draws it, with no verdict from Certeno.
load() resolves with verificationSkipped: 'not_licensed' and an empty signatures list. Check it before reading the list: empty does not mean the file is unsigned. result and status stay null, revalidate() resolves to null, and the vanilla viewer does not call onVerified or emit verified.
Vanilla JS
The vanilla viewer does all of that for you:
import { Certeno } from '@trexolab/certeno-vanilla'
const viewer = await Certeno.create(document.getElementById('viewer'), {
workerUrl: '/pdf.worker.min.mjs',
licensing: { siteId: 'site_…' },
onLicence: ({ licensed, reason }) => {
if (!licensed) console.warn('Licence not verified:', reason)
},
})onLicence runs once, after the check, whenever licensing is set.
What the viewer does
| Situation | Result |
|---|---|
No licensing option | Only the free Viewer features are offered. No notice is shown. |
| The licence verifies | The viewer offers the features the licence includes. |
| The licence does not verify (wrong domain, expired, revoked, bad token) | The PDF still opens. Only the free Viewer features are offered, and a slim notice says some features are unavailable. |
| The check cannot finish (no network, server down) | A token already stored in the browser keeps working until it expires. With none, the viewer opens with the free Viewer features. |
| The check takes longer than five seconds | The viewer opens with the free Viewer features. |
A licence problem never stops a PDF from opening. The viewer is held back while the licence is checked, so a control never appears and then disappears.
A token's life, and so how long a page works without reaching the licence server, is set by the plan.
Desktop apps: Electron and Tauri
A desktop app has two halves, and the licence needs both:
- The native half (Electron's main process, or Tauri's Rust backend) talks to the licence server. It activates the machine and keeps a signed activation token fresh.
- The viewer runs in a web view and needs to know which features are allowed. The native half gives it the activation token, and the viewer verifies the token itself, in Certeno's engine. It does not have to trust what the native half says.
licence server ──signs──> native half ──passes the token──> viewer (verifies it itself)
A machine is activated once. The plan limits how many machines one licence can activate, and the licence server refuses another with ACTIVATION_LIMIT_REACHED.
Note: The SDK the native half uses depends on the runtime. Electron (Node) uses @trexolab-solution/authvon-sdk, through Certeno's openDeviceLicence. Tauri (Rust) uses the authvon crate directly.
Electron
Main process. Open the licence, and hand the token to the renderer over IPC:
// electron/main.ts
import { app, ipcMain } from 'electron'
import { openDeviceLicence, type DeviceLicenceHandle } from '@trexolab/certeno-core'
const LICENCE_KEY = 'CERT-XXXX-XXXX-XXXX-XXXX' // your Desktop licence key
let licence: DeviceLicenceHandle | null = null
async function startLicence() {
try {
licence = await openDeviceLicence({ licenceKey: LICENCE_KEY })
} catch (error) {
// The app still opens. With no token the viewer offers the free features.
console.warn('Licence not verified:', (error as { code?: string }).code)
}
}
ipcMain.handle('ct:activation-token', async () => (await licence?.activationToken()) ?? null)
app.whenReady().then(async () => {
await startLicence()
// createWindow()
})
app.on('before-quit', () => void licence?.close())Note: Leave storage at its default. With storage: 'memory' nothing is kept, and activationToken() returns null.
Preload. Expose the token, and nothing else:
// electron/preload.ts
import { contextBridge, ipcRenderer } from 'electron'
contextBridge.exposeInMainWorld('ctLicence', {
activationToken: (): Promise<string | null> => ipcRenderer.invoke('ct:activation-token'),
})Renderer, React. Ask for the token, then give it to useLicence in a child component:
import { useEffect, useState } from 'react'
import { useLicence } from '@trexolab/certeno-react'
declare global {
interface Window { ctLicence: { activationToken(): Promise<string | null> } }
}
export function App() {
const [token, setToken] = useState<string | null | undefined>(undefined)
useEffect(() => { window.ctLicence.activationToken().then(setToken) }, [])
if (token === undefined) return null // waiting for the native half
return <Licensed token={token} />
}
function Licensed({ token }: { token: string | null }) {
const licence = useLicence({ activationToken: token })
if (!licence.ready) return null
return <LicensedViewer licence={licence} /> // as in the React example above
}Renderer, vanilla.
const activationToken = await window.ctLicence.activationToken() // string | null
const viewer = await Certeno.create(el, { workerUrl, licensing: { activationToken } })Important: Pass the token even when it is null. activationToken: null (or an empty string) means "a licence is required and none was found", and the viewer offers the free features. Leaving licensing out means "no licensing", and changes nothing.
Keep the licence fresh. The token has a life set by the plan (7 days unless the plan says otherwise), and it is renewed when the licence is checked online. In a long-running app, re-check from time to time and give the viewer the new token:
setInterval(async () => {
try {
await licence?.ensureFresh() // asks the licence server again if the last check is over 6 hours old
} catch {
/* no longer valid: the viewer falls back when the token it holds expires */
}
}, 60 * 60 * 1000)With React, a new token prop re-checks on its own. With vanilla, the token is read when the viewer is created, so build the viewer again with the new one.
Tauri
Rust backend. Add the crate (authvon 0.7.2 or later) and write a command that returns the token. Check first, and activate only a machine the server does not know yet:
use authvon::{ActivateInput, AuthvonClient, AuthvonError, ClientConfig, ValidationCode};
const SERVER: &str = "https://license.trexolab.com";
// Certeno's public signing key: safe to ship.
const KEYS: &str = r#"{"keys":[{"kty":"OKP","crv":"Ed25519","alg":"EdDSA","use":"sig","kid":"authvon-license-signer-1","x":"fro7Vj8XRh_mhHAyjMtpOqTqgmm0F64eBrcEyDqppFA"}]}"#;
const LICENCE_KEY: &str = "CERT-XXXX-XXXX-XXXX-XXXX"; // your Desktop licence key
async fn activation_token() -> Result<Option<String>, AuthvonError> {
let client = AuthvonClient::new(
ClientConfig::new(SERVER, LICENCE_KEY)
.with_public_key(KEYS)
.with_expected_issuer(SERVER)
.with_max_retries(1),
)?;
let mut result = client.validate().await?;
if !result.valid
&& matches!(result.code, ValidationCode::NoDevice | ValidationCode::FingerprintMismatch)
{
client.activate(ActivateInput::default()).await?;
result = client.validate().await?;
}
if !result.valid {
return Ok(None);
}
Ok(client.activation_token().await)
}
#[tauri::command]
async fn licence_token() -> Option<String> {
activation_token().await.ok().flatten()
}Web view. Ask for the token, and pass it to the viewer as in the Electron renderer examples:
import { invoke } from '@tauri-apps/api/core'
const activationToken = await invoke<string | null>('licence_token')Two things to know about activation
- Check first, activate once. Activating a machine that is already activated drops the signed token the SDK cached, and the licence server issues a machine a new one at most once a day. Always call
validate()first and activate only when it answersNO_DEVICEorFINGERPRINT_MISMATCH. Certeno'sopenDeviceLicencedoes this for you. - The first run needs a network. A machine is activated once. With no network and nothing cached, there is no token, and the viewer shows the free features.
Servers and scripts: Node.js
Pass the licence key to createVerifier. It works in Node only:
import { createVerifier, CertenoLicenceError } from '@trexolab/certeno-core'
try {
const verifier = await createVerifier({
licence: { licenceKey: process.env.CERTENO_LICENCE_KEY! },
})
console.log(verifier.licence?.features)
// ... verifier.verify(pdf, 'file.pdf')
} catch (error) {
if (error instanceof CertenoLicenceError) {
console.error(`Licence problem: ${error.code}`)
}
throw error
}It needs the licence server's SDK, an optional peer dependency that Certeno loads only when you set licence. Install it, and pin the version, because the latest tag on npm points at an older beta:
npm install @trexolab-solution/[email protected]How it behaves:
| Start | The verifier does not start unless the licence is valid and includes node_runtime and signature_verification. It throws a CertenoLicenceError, and its code says why. |
| Running | The licence is asked about again every 6 hours, on the next verify. A licence revoked or expired since stops verify with the same error. If the licence server cannot be reached, the verifier keeps working on the activation it holds. |
| First run | The machine is activated once, so the first run needs a network. With no network and nothing cached the error is LICENCE_UNAVAILABLE: unknown, not refused. |
| Later runs | A known machine is only checked. With no network it starts from its cached activation after a few seconds of retries. |
| Options | trustStore, algorithmPolicy and revocation plugins are ignored, with a console note, when the licence does not include custom_trust_store, algorithm_policy or revocation_checking. |
| Containers | The activation is kept in a folder in the home directory. Mount it, or every start looks like a new machine and uses one of the plan's activations. |
Set storage to 'file' or 'memory' to choose where the activation is kept; the default is 'auto'. In a browser, licence throws DEVICE_LICENCE_NEEDS_NODE.
Note: Deno is not tested. Without cert_export, Node results carry no certificate bytes; buildCertChainPkcs7 still packs bytes your own code already holds.
Features and what they unlock
A licence lists feature names, and each is enforced in one place.
| Feature | What it unlocks | Enforced by |
|---|---|---|
search | Find in document | The viewer control |
print | The viewer control | |
download | Download | The viewer control |
open_file | Open file | The viewer control |
fullscreen | Fullscreen | The viewer control |
theme_toggle | Light/dark toggle | The viewer control |
rotation | Rotate | The viewer control |
selection | Text selection tool | The viewer control |
thumbnails | Thumbnails and sidebar | The viewer control |
highlight | Text highlighting. Not available yet: listed on plans, but the viewer has no highlighting tool | n/a |
properties | Document properties | The viewer control |
shortcuts_help | Keyboard shortcuts help | The viewer control |
context_menu | Right-click menu | The viewer control |
accessibility | Font size control | The viewer control |
signature_verification | Signature verification and the signature UI | The viewer control and useVerification(); required to start in Node |
cert_export | Export a certificate or the whole chain (PEM, DER, PKCS#7, ZIP) | The viewer's export controls; in Node, results carry no certificate bytes (rawDer) |
custom_trust_store | The trustStore option; in Node also plugin trust stores and setTrustStoreConfig() | An option gate |
algorithm_policy | The algorithmPolicy option; in Node also setAlgorithmPolicy() | An option gate |
theme_overrides | theme.overrides | An option gate |
custom_translations | translations. Partial: only a few viewer strings can be replaced today | An option gate |
white_label | The about option | An option gate |
revocation_checking | Online revocation checking | Revocation plugins are ignored without it. The vanilla viewer and Node do this; in React use licensedPlugins() |
node_runtime | The headless engine | Required to start in Node |
viewer_core | The baseline viewer | A licence without it (a Server plan) gives a viewer the free features only |
signature_panel | The signature list panel and its button on the verdict bar | Inside the viewer |
custom_plugins | A plugin's own setup and inputResolver hooks | The vanilla viewer and Node; licensedPlugins() in React |
"The viewer control" means a control is shown only when its feature is listed. "An option gate" is explained in the next section.
Download and Open file
Download and Open file are off unless you turn them on. Without licensing that is unchanged: set features: { download: true, openFile: true }.
With licensing, a licence that includes the feature turns it on for you. Set features: { download: false } to keep it off; that always wins. A licence that lacks the feature keeps it off whatever you set. A licence can switch controls off, never on beyond what you allowed.
Options that need a feature
Some options need a feature. Who ignores an option the licence does not include depends on where you run Certeno:
| Option | Feature | Vanilla viewer | React viewer | Node |
|---|---|---|---|---|
about (a branding object, or false) | white_label | Ignored, with a console note | Ignored | n/a |
trustStore | custom_trust_store | Ignored, with a console note | Ignored, with a console note | Ignored, with a console note |
algorithmPolicy | algorithm_policy | Ignored, with a console note | Ignored, with a console note | Ignored, with a console note |
theme.overrides | theme_overrides | Ignored, with a console note | Ignored, with a console note | n/a |
translations | custom_translations | Ignored, with a console note | Ignored, with a console note | n/a |
plugins are cut down the same way: each part of a plugin runs only with its feature. setTrustStoreConfig() and setAlgorithmPolicy() follow the licence in Node, while a licensed verifier is running.
Network and privacy
| Runtime | What is sent, and to whom |
|---|---|
| Browser, site ID | The viewer asks the licence server for a token, sending the site ID and the page's origin. It keeps the token in localStorage and renews it after half of its life. |
| Browser, domain token | Nothing. The token is verified in the browser. |
| Desktop viewer | Nothing. The activation token is verified in the web view. |
| Desktop native half and Node | The licence key, a fingerprint of the machine, its host name and basic device details, to activate and to check the licence. |
The PDF, and anything about it, is never sent.
- With a Content Security Policy, a site ID needs
connect-src https://license.trexolab.com; see Security. - The signing key and issuer of the licence server are built into the SDK, so a token from another server fails to verify.
- Verification runs in Certeno's own WebAssembly engine, so no second licensing library is downloaded. A page that sets no
licensingoption runs none of this code.
Limits
- Browser code can be read and changed. The browser check deters casual reuse. It is not tamper-proofing. See Security.
- Revocation is not instant. A revoked or suspended licence stops working when the token a browser or a desktop viewer holds expires, not at once. On a server it stops at the next 6-hour check.
- A desktop viewer trusts the native half to pass the right token. It verifies the token's signature, issuer and dates, but a web view cannot compute the machine fingerprint inside it, so tying the token to a machine is the native side's job.
When it does not work
The viewer: reason and onLicence
reason | Meaning | What to do |
|---|---|---|
DOMAIN_NOT_ALLOWED | The page's domain is not on the licence | Add the domain to the licence |
TOKEN_EXPIRED | The token's life is over | Site ID: check the network, the viewer renews on its own. Domain token: get a new one. Desktop: re-check the licence in the native half and pass the new token |
TOKEN_NOT_YET_VALID | The device clock is behind | Set the clock |
INVALID_SIGNATURE, ISSUER_MISMATCH, INVALID_TOKEN, WRONG_TOKEN_SCOPE | The token was not issued by Certeno's licence server, was changed, or is the wrong kind (for example a domain token passed as activationToken) | Use the token the licence server gave you |
LICENSE_SUSPENDED, LICENSE_EXPIRED, LICENSE_REVOKED | The licence itself is not active | Contact your licence provider |
NO_TOKEN | Desktop: the native half has no token. Site ID: no token is stored and the request failed | Check the native licence step, or the network |
NO_HOST | The page has no host name to check a domain licence against | Use a site ID in a browser, or an activation token in a desktop app |
CHECK_TIMEOUT | The check took over five seconds | The viewer opened with the free features; it tries again next time |
CHECK_FAILED, VERIFY_FAILED | An unexpected error | Look at the browser console |
A licence-server code can also appear, for example when the server refuses a site ID.
Node and the native half: CertenoLicenceError.code
code | Meaning | What to do |
|---|---|---|
LICENCE_UNAVAILABLE | First run, no network, nothing cached | Start once with a network |
SDK_MISSING | The licence SDK is not installed | npm install @trexolab-solution/[email protected] |
NO_LICENCE_KEY | licence has no licenceKey | Pass the key |
UNAUTHORIZED | The licence key is not known | Check the key |
FEATURE_NOT_LICENSED | The licence lacks node_runtime or signature_verification | Use a Server or Desktop plan |
ACTIVATION_LIMIT_REACHED | The plan's machine limit is used up | Free a machine, or raise the limit |
LICENSE_EXPIRED, LICENSE_REVOKED, LICENSE_SUSPENDED | The licence is not active | Contact your licence provider |
CLOCK_ROLLED_BACK | The clock is earlier than a time the machine already saw | Set the clock, or go online once |
REVOCATION_LIST_STALE, FIRST_CONNECTION_REQUIRED | The machine has been offline too long | Connect it to the network |
DEVICE_LICENCE_NEEDS_NODE | licence was set in a browser | Use the viewer's licensing option |
See also Server and Desktop licences for the API.