@ibm-verify/privacy
v1.0.2
Published
Data Privacy and Consent Management SDK
Downloads
5
Keywords
Readme
IBM Security Verify Privacy SDK for Javascript
Fast, opinionated, simple privacy SDK for Node that leverages the data privacy & consent engine on IBM Security Verify.
const Privacy = require('@ibm-verify/privacy');
// tenant information and other global config
const config = { tenantUrl: "https://abc.verify.ibm.com" };
// access token generated using any OAuth client library
const auth = { accessToken: getToken() };
// optional context
const context = { "ipAddress": "1.2.3.4" };
const privacy = new Privacy(config, auth, context);
// determine items that need assessment
let items = [
{
"purposeId": "marketing",
"attributeId": "mobile_number",
"accessTypeId": "default"
}
];
doAssess = async (req, res) => {
// assess if the item can be used
let decision = await privacy.assess(items);
if (decision.status == "consent") {
// metadata used to render a user consent page
let r = await privacy.getConsentMetadata(items);
res.render('consent', { metadata: r.metadata });
}
// handle other cases
}
storeConsents = async (req, res) => {
// assuming the request.body is a JSON array of
// consent records that need to be stored
let r = await privacy.storeConsents(req.body);
if (r.status == "success") {
// done. Respond accordingly
} else if (r.status == "fail") {
// something didn't save. For example - an attempt was made to store a consent
// for an attribute that isn't linked to a purpose on Verify.
// Render an appropriate error code to the user.
}
}
Prerequisites
- Sign up for your IBM Security Verify Tenant.
- If you are not using an OAuth/OIDC application to get a user/delegated token, obtain a privileged access token by configuring an API client with the following entitlements.
- Check for data usage approval to assess the usage of requested data items
- Retrieve privacy purposes and associated user's consent to present a complete user consent experience
- Create privacy consent records to record consents
- Read privacy consents to get the user's consents
- Identify attributes you intend to use in your application that require assessment
- Identify purpose-of-use for those attributes
Installation
Use npm to install the SDK:
$ npm install @ibm-verify/privacy
Features
- Integrate with the Verify data privacy engine using APIs
- Insert privacy assessment and consent at any point in your application flow. Privacy & compliance regulations are configured centrally on the Verify tenant
- Build pleasing experiences for user consent and preferences using the simplified object returned by the
getConsentMetadata
function
Documentation
Tests
Before running the tests, the Verify tenant must be configured with the following:
- Purpose with ID
marketing
- Purpose
marketing
must be configured with two attributes -mobile_number
andemail
- Purpose
marketing
must be configured with thedefault
access type
The test environment must be setup as below:
- In the directory where this Git repository is cloned, run:
$ npm install
- Copy
./test/dotenv
to./test/.env
- Use any OIDC application configured on the Verify tenant to generate an OAuth token. This would be associated with the user account used to login to the application.
Now you can run the test by executing:
$ npm test
If you want to see debug logs, run:
$ npm run testdebug