Certenov0.19.0

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 isPlanWhat you holdYou configure it withIf the licence does not verify
A web page (React, Next.js, vanilla JS, Vue)Browser plan, tied to your domainsA site ID (site_…), or a signed domain tokenThe viewer's licensing optionThe PDF still opens, with the free Viewer features only
A desktop app (Electron, Tauri)Desktop plan, tied to machinesA licence key (CERT-…)The app's native side activates the machine and passes the viewer an activation tokenThe same as a web page
A server or script (Node.js, headless)Server plan, tied to machinesA 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:

ValueUse 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:

tsx
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:

  • useLicence runs the check once and returns the licence's state.
  • LicenceFeaturesProvider hands the licence to the viewer. The viewer runs only the plugins and controls the licence includes, useVerification() verifies only with signature_verification, and CertenoProvider ignores options the licence does not include. You do not have to disable anything yourself.
  • It takes the features that useLicence returned. 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:

js
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

SituationResult
No licensing optionOnly the free Viewer features are offered. No notice is shown.
The licence verifiesThe 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 secondsThe 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:

ts
// 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:

ts
// 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:

tsx
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.

js
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:

ts
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:

rust
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:

ts
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 answers NO_DEVICE or FINGERPRINT_MISMATCH. Certeno's openDeviceLicence does 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:

ts
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:

bash
npm install @trexolab-solution/[email protected]

How it behaves:

StartThe 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.
RunningThe 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 runThe 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 runsA known machine is only checked. With no network it starts from its cached activation after a few seconds of retries.
OptionstrustStore, algorithmPolicy and revocation plugins are ignored, with a console note, when the licence does not include custom_trust_store, algorithm_policy or revocation_checking.
ContainersThe 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.

FeatureWhat it unlocksEnforced by
searchFind in documentThe viewer control
printPrintThe viewer control
downloadDownloadThe viewer control
open_fileOpen fileThe viewer control
fullscreenFullscreenThe viewer control
theme_toggleLight/dark toggleThe viewer control
rotationRotateThe viewer control
selectionText selection toolThe viewer control
thumbnailsThumbnails and sidebarThe viewer control
highlightText highlighting. Not available yet: listed on plans, but the viewer has no highlighting tooln/a
propertiesDocument propertiesThe viewer control
shortcuts_helpKeyboard shortcuts helpThe viewer control
context_menuRight-click menuThe viewer control
accessibilityFont size controlThe viewer control
signature_verificationSignature verification and the signature UIThe viewer control and useVerification(); required to start in Node
cert_exportExport 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_storeThe trustStore option; in Node also plugin trust stores and setTrustStoreConfig()An option gate
algorithm_policyThe algorithmPolicy option; in Node also setAlgorithmPolicy()An option gate
theme_overridestheme.overridesAn option gate
custom_translationstranslations. Partial: only a few viewer strings can be replaced todayAn option gate
white_labelThe about optionAn option gate
revocation_checkingOnline revocation checkingRevocation plugins are ignored without it. The vanilla viewer and Node do this; in React use licensedPlugins()
node_runtimeThe headless engineRequired to start in Node
viewer_coreThe baseline viewerA licence without it (a Server plan) gives a viewer the free features only
signature_panelThe signature list panel and its button on the verdict barInside the viewer
custom_pluginsA plugin's own setup and inputResolver hooksThe 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:

OptionFeatureVanilla viewerReact viewerNode
about (a branding object, or false)white_labelIgnored, with a console noteIgnoredn/a
trustStorecustom_trust_storeIgnored, with a console noteIgnored, with a console noteIgnored, with a console note
algorithmPolicyalgorithm_policyIgnored, with a console noteIgnored, with a console noteIgnored, with a console note
theme.overridestheme_overridesIgnored, with a console noteIgnored, with a console noten/a
translationscustom_translationsIgnored, with a console noteIgnored, with a console noten/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

RuntimeWhat is sent, and to whom
Browser, site IDThe 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 tokenNothing. The token is verified in the browser.
Desktop viewerNothing. The activation token is verified in the web view.
Desktop native half and NodeThe 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 licensing option 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

reasonMeaningWhat to do
DOMAIN_NOT_ALLOWEDThe page's domain is not on the licenceAdd the domain to the licence
TOKEN_EXPIREDThe token's life is overSite 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_VALIDThe device clock is behindSet the clock
INVALID_SIGNATURE, ISSUER_MISMATCH, INVALID_TOKEN, WRONG_TOKEN_SCOPEThe 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_REVOKEDThe licence itself is not activeContact your licence provider
NO_TOKENDesktop: the native half has no token. Site ID: no token is stored and the request failedCheck the native licence step, or the network
NO_HOSTThe page has no host name to check a domain licence againstUse a site ID in a browser, or an activation token in a desktop app
CHECK_TIMEOUTThe check took over five secondsThe viewer opened with the free features; it tries again next time
CHECK_FAILED, VERIFY_FAILEDAn unexpected errorLook 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

codeMeaningWhat to do
LICENCE_UNAVAILABLEFirst run, no network, nothing cachedStart once with a network
SDK_MISSINGThe licence SDK is not installednpm install @trexolab-solution/[email protected]
NO_LICENCE_KEYlicence has no licenceKeyPass the key
UNAUTHORIZEDThe licence key is not knownCheck the key
FEATURE_NOT_LICENSEDThe licence lacks node_runtime or signature_verificationUse a Server or Desktop plan
ACTIVATION_LIMIT_REACHEDThe plan's machine limit is used upFree a machine, or raise the limit
LICENSE_EXPIRED, LICENSE_REVOKED, LICENSE_SUSPENDEDThe licence is not activeContact your licence provider
CLOCK_ROLLED_BACKThe clock is earlier than a time the machine already sawSet the clock, or go online once
REVOCATION_LIST_STALE, FIRST_CONNECTION_REQUIREDThe machine has been offline too longConnect it to the network
DEVICE_LICENCE_NEEDS_NODElicence was set in a browserUse the viewer's licensing option

See also Server and Desktop licences for the API.