Secured

Installation

How to add @secured-ai/core to your project.

Install

Install @secured-ai/core with your package manager of choice:

npm install @secured-ai/core

Required: SDK access token

Before browser code can initialize the SDK, a Pro user must create an SDK access token in the Secured platform:

  1. Go to Settings > SDK Access Tokens.
  2. Create a token for the environment you are integrating.
  3. Add each allowed browser origin, such as https://app.example.com or http://localhost:5173.
  4. Copy the raw token when it is shown.

Then pass both baseUrl and sdkAccessToken to PrivacyClient:

import { PrivacyClient } from '@secured-ai/core'

export const client = new PrivacyClient({
  baseUrl: 'https://dev-api.securedai.com',
  sdkAccessToken: import.meta.env.VITE_SECURED_SDK_ACCESS_TOKEN,
})

See SDK Access Tokens for wildcard origin rules, rotation, and revoke behavior.

Bundler requirements

@secured-ai/core ships as an ES Module and requires a modern bundler (Vite, Webpack 5, Rollup, esbuild). It targets ES2020 — ensure your build target is set accordingly.

If you use Vite, exclude the Secured packages from dependency optimization so Vite does not move the SDK bundle away from its worker file during local development:

vite.config.ts (example)
import { defineConfig } from 'vite'

export default defineConfig({
  optimizeDeps: {
    exclude: ['@secured-ai/core', '@secured-ai/react'],
  },
  build: {
    target: 'es2020',
  },
})

Optional: ML engine dependencies

The ML engine (engines: { ml: true }) uses @huggingface/transformers under the hood, which downloads WASM binaries and BERT model weights at runtime. No additional install is needed — the package bundles this dependency — but be aware of the size implications before enabling it.

See the ML Engine guide for details.

TypeScript

@secured-ai/core is written in TypeScript and ships its own declaration files. No @types/ package is required.

Ensure your tsconfig.json targets ES2020 or higher:

tsconfig.json
{
  "compilerOptions": {
    "target": "ES2020",
    "moduleResolution": "bundler",
    "strict": true
  }
}

Using within this monorepo (local setup)

If you are working inside the secured-ai-monorepo and want to consume @secured-ai/core from another package or app, add it as a workspace dependency:

package.json
src/index.ts
package.json
apps/your-app/package.json
{
  "dependencies": {
    "@secured-ai/core": "workspace:*"
  }
}

Then run:

pnpm install

The workspace protocol resolves the package directly from packages/core — no build step required during development.

On this page