Collect and reveal data with Skyflow Elements
Skyflow Elements provides a secure way to collect and reveal sensitive data, such as personally identifiable information (PII) and credit card information (PCI). It offers several benefits, including complete programmatic isolation from your frontend applications, end-to-end encryption, tokenization, and the ability to customize the look and feel of the data collection form.
You can integrate Skyflow Elements into existing applications and workflows by installing server-side and client-side Skyflow SDKs, initializing the SDKs with your Skyflow credentials, and using the client-side SDK to create and customize the data collection form.
How it works
When your users interact with Skyflow Elements, various components work together to collect and reveal sensitive data. Here’s how it works:
- When your user enters sensitive data into collect elements, the client-side SDK sends the data to your vault and receives tokens that represent the data.
- When you need to reveal the data to a user, the client-side SDK sends the tokens to your vault, receives the data, and displays the data in reveal elements.
Prerequisites
-
Sign in to your Skyflow account. If you don’t have an account, sign up for a free trial.
-
Basic knowledge of JavaScript and Node.js
-
Basic knowledge of HTML and CSS
-
A device with the following tools installed:
-
A vault and its details: 1. In Studio, click the vault menu icon > View vault details. 2. Note your Vault URL, and Vault ID values.
The following content uses the Quickstart vault template. Adapt your commands accordingly.
Identify data to collect
You may want to collect many kinds of sensitive data from your users. Here are some common examples:
- Personally identifiable information (PII): full name, Social Security Number (SSN), date of birth (DOB), address, phone number, and email address.
- Payment Card Industry (PCI) data: bank account numbers, credit card numbers, and financial transactions.
- Personal health information (PHI): medical history, prescriptions, diagnoses, and health insurance information.
Make sure your vault has the appropriate tables and columns to store the data you want to collect.
This tutorial uses the Quickstart vault template and focuses on securely collecting the columns in the persons
table:
name
email_address
ssn
date_of_birth
state
Create roles and service accounts
To use Skyflow Elements, you need to define a role to control what the SDKs can access and a service account to let the SDKs authenticate and access Skyflow according to their role.
Create a role
-
In Studio, click Settings in the upper navigation.
-
In the side navigation, click Vault, then choose your vault from the dropdown menu.
-
Under IAM, click Roles, then Add New Role.
-
For Name, enter “Collect PII”.
-
For Description, enter a value. For example, “Restrictive vault access”.
-
Click Create.
-
Click Attach Policies, and replace the placeholder content with the following policies:
These policies let you gather data from your client, insert it into your vault, and return tokens to your client.
If you have a requirement to display data, add the following policies:
Caution: Revealing data in your interfaces exposes that data to your users. Only use reveal elements when necessary, and make sure you have adequate access policies in place when you do.
-
Click Create, enter “Collect PII” for the policy name, then click Save.
-
Click Enable, then close the dialog.
Create a service account
- Under IAM, click Service Accounts, then click New Service Account.
- For Name, enter “Client-side SDK”.
- For Roles, select Collect PII.
- Click Create.
Your browser downloads a credentials.json
file. Store this file in a secure location. You’ll need it to generate bearer tokens.
Integrate with a server-side SDK (Node.js)
Now that you’ve created your vault and defined your role and service account, it’s time to integrate with the server-side SDK.
-
In a terminal, run the following commands:
-
Move your
credentials.json
file to the root directory of your project. -
Create
server.js
in the root directory of the project with the following code: -
Run the server:
-
In a new terminal, check to make sure you can fetch a bearer token from your server:
You should see a bearer token in the response. If you don’t, check your first terminal for errors.
Integrate with client-side SDK (JavaScript)
Now that you’ve integrated with the server-side SDK, it’s time to integrate with the client-side SDK.
-
Create
elements.html
in the root directory of the project with the following code. UpdateVAULT_ID
andVAULT_URL
with your vault’s values.This code does the following:
- Defines HTML elements to mount elements onto.
- Initializes the SDK with your vault’s values, including fetching a bearer token from the server-side SDK.
- Defines a collect container and the elements it contains.
- Mounts the collect container onto the HTML element.
- Defines the reveal elements.
- Mounts the reveal elements onto the HTML element.
- Configures the Submit button to collect data from the collect container and update the reveal element with the token.
- Configures the Reveal button to reveal the data in the reveal element.
-
In a browser, open http://localhost:3000.
You should see a form with input fields. When you enter a value and click Submit, the SDK sends the value to your vault and returns a token for the value. Store tokens in your data store instead of the actual values.
When you click the Reveal button, if you added the
DETOKENIZATION
policy, the SDK uses the token to retrieve the value from your vault and display it on the page. If you didn’t add theDETOKENIZATION
policy, the SDK returns an error.
Next steps
You now have a functional, if minimal, integration with Skyflow Elements. There are a few ways you can improve the current integration:
- Customize the types of elements you use.
- Configure upsert to update existing records and insert new records.
- Style the elements to match your application’s look and feel.
- Set labels for the elements.
- Set placeholder text for the elements.
- Set alt text for the elements.
- Add input validation to display errors when users enter invalid data.
- Add input formatting to format the data users enter.
For information on these topics, see the Skyflow JavaScript SDK.