@atlaskit/privacy-safe v1.0.0
PrivacySafe
This package provides some utility functions to help mark strings as being privacy safe (potentially for consumption in analytics).
Installation
npm install @atlaskit/privacy-safe
Using the component
privateSafeString
Create a wrapper which signifies that the supplied string is privacy safe. Use privateSafeString when you are certain that the string or its source isn't user entered data. If you pass any non-string type (e.g. null, undefined), the string will be marked being unsafe.
import { privacySafeString } from '@atlaskit/privacy-safe';
const safeString = privateSafeString('projects');
safeString.value // 'projects'
isPrivacySafeString
Check to see if the supplied object is a safe string.
import { privacySafeString, isPrivacySafeString } from '@atlaskit/privacy-safe';
const safeString = privateSafeString('projects');
isPrivacySafeString(safeString); // true
dangerouslyCreateSafeString
Create a safe string but acknowledge that it is user entered data. (eg. NPS survey responses). If you pass any non-string type (e.g. null, undefined), the string will be marked being unsafe.
import { dangerouslyCreateSafeString } from '@atlaskit/privacy-safe';
function create(nps) {
const safeString = dangerouslyCreateSafeString(nps.response);
}
markAsSafe
Provide a list of acceptable values and only when an allowed value matches, create a safe string.
import { markAsSafe, isPrivacySafeString } from '@atlaskit/privacy-safe';
isPrivacySafeString(markAsSafe('project', 'issue')('issue')); // true
isPrivacySafeString(markAsSafe('project', 'issue')('corporation')); // false
* Please note that this module could have dependencies that are governed by the Atlassian Design Guidelines license which will be automatically included on install. Each dependency has a license file that indicates whether the Atlassian Design Guidelines license applies.
We're here to help!
Let us know what you think of our components and docs, your feedback is really important for us.
Are you in trouble? Read through our contribution guidelines and raise an issue to us.
8 years ago