The DSP Web SDK enables integration with the Virtru Data Security Platform (DSP). It provides tools for encrypting and decrypting TDF (Trusted Data Format) content, as well as managing Attribute-Based Access Control (ABAC) operations.
npm install @virtru/dsp-sdkThe DSP Web SDK enables integration with the Virtru Data Security Platform (DSP).
It provides tools for encrypting and decrypting TDF (Trusted Data Format) content, as well as managing Attribute-Based Access Control (ABAC) operations.
> Note: The package name is subject to change before public release.
``shUsing npm
npm install @virtru/dsp-sdk
`
The following example demonstrates how to authenticate with DSP, initialize the platform client, and perform common operations such as tagging and fetching configuration.
`typescript
import { AuthProviders, DSP } from '@virtru/dsp-sdk';
const authProvider = await AuthProviders.refreshAuthProvider({
clientId: 'oids-client-id',
exchange: 'refresh',
refreshToken: 'refresh-token',
oidcOrigin: 'oidc-issuer-url',
});
const dsp = new DSP({
authProvider,
platformUrl: '/api',
});
// Tag PDP
const taggingResponse = await dsp.services.v2.taggingPDPService.tag({});
// List policy attributes
const attributesResponse = await dsp.services.v1.attributes.listAttributes({});
// Encrypts string into a NanoTDF
const nano = await dsp.createNanoTDF({
source: {
type: "buffer",
location: new TextEncoder().encode("hello world"),
},
});
await nano.pipeTo(
new WritableStream({
write(chunk) {
console.log(chunk);
},
})
);
`
Refer to the API documentation for a complete list of available methods and configuration options.
This section is intended for repository maintainers and contributors. To verify the integrity of the SDK and ensure all features work as expected, run the test suite using the following command:
`bash`
pnpm test
- ESLint is used for linting. To check for linting errors:
`bash`
pnpm lint
`
- To automatically fix linting errors:
bash`
pnpm lint:fix
This section is for maintainers who need to regenerate TypeScript code from protobuf definitions.
The SDK includes TypeScript code that is generated from protobuf definitions in the data-security-platform repository. This generated code lives in src/gen/ and is checked into version control. The code generation process is manual to ensure CI builds succeed without requiring access to the DSP repository.
- Node.js (version 22 or higher)
- buf CLI installed (https://buf.build/docs/installation)
- Access to the data-security-platform repository
1. Clone the data-security-platform repository as a sibling to this monorepo:
`bash`
cd ../../ # Navigate to parent directory containing js-lib-monorepo
git clone git@github.com:virtru-corp/data-security-platform.git
Your directory structure should look like:
``
virtru-corp/
├── js-lib-monorepo/
│ └── libraries/
│ └── dsp-sdk/
└── data-security-platform/
└── ext/
From the dsp-sdk directory, run:
`bash`
buf generate ../../../data-security-platform/ext \
--path ../../../data-security-platform/ext/virtru/policy/certificates \
--path ../../../data-security-platform/ext/virtru/policy/objects.proto \
--path ../../../data-security-platform/ext/virtru/common
This will regenerate the TypeScript files in src/gen/.
You only need to regenerate the code when:
- Proto definitions in the data-security-platform repository change
- New proto files are added that the SDK needs to consume
- Proto dependencies are updated
After regenerating, commit the updated files in src/gen/` to version control.