Installation | Encryption Example | Initialization | Documentation | Support
Virgil Security provides a set of APIs for adding security to any application. In a few simple steps you can encrypt communication, securely store data, provide passwordless login, and ensure data integrity.
For a full overview head over to our Javascript Get Started guides.
This client can be used both server-side in a Node application, and client-side in a web browser.
This module requires Node 4.0+ and can be installed via NPM.
npm install virgil-sdk --save
Next: Get Started with the JS SDK.
The client-side SDK targets ECMAScript5+ compatible browsers.
<script
src="https://cdn.virgilsecurity.com/packages/javascript/sdk/4.1.0/virgil-sdk.min.js"
crossorigin="anonymous"></script>
Alternatively download the source code into your application.
Warning: Please note that in the browser environment we use Web Workers to invoke some cryptographic operations. As a result, Chrome and Opera will raise an error unless the code is executed on an actual proper domain:
"Uncaught SecurityError: Script at '[blob url here]' cannot be accessed from origin 'null'."
Next: Get Started with the JS SDK.
Virgil Security makes it super easy to add encryption to any application. With our SDK you create a public [Virgil Card][glossary_virgil_card] for every one of your users and devices. With these in place you can easily encrypt any data in the client.
// find Alice's card(s)
client.cards.find(["alice"])
.then(function (cards) {
// encrypt the message using Alice's cards
var message = "Hello Alice!";
var encryptedMessage = client.encryptFor(message, cards);
// transmit the message with your preferred technology
transmitMessage(encryptedMessage.toString("base64"));
});
The receiving user then uses their stored private key to decrypt the message.
// load Alice's Key from storage.
client.keys.load("alices_key_1", "mypassword")
.then(function (key) {
// decrypt the message using the key
var message = key.decrypt(transferData).toString();
});
Next: To [get you properly started][js_guides_virgil_cards] you'll need to know how to create and publish Virgil Cards. Our [Get Started guide][js_guides_virgil_cards] will get you there all the way.
Also: Encrypted communication is just one of the few things our SDK can do. Have a look at our guides on Encrypted Storage, Data Integrity and Passwordless Login for more information.
To use this SDK you need to sign up for an account and create your first application. Make sure to save the app id, private key and it's password. After this, create an application token for your application to make authenticated requests from your clients.
To initialize the SDK in a web browser you will only need the access token you created.
var client = virgil.API("[ACCESS_TOKEN]");
Note: this client will have limited capabilities. For example, it will be able to generate new Cards but it will need a server-side client to transmit these to Virgil.
To initialize the SDK on the server side we will need the access token, app id and the App Key you created on the Developer Dashboard.
var virgil = require("virgil-sdk");
var appKey = require("fs").readFileSync("/path/to/app/key");
var client = virgil.API({
accessToken: "[ACCESS_TOKEN]",
appCredentials: {
appId: "[APP_ID]",
appKeyData: appKey,
appKeyPassword: "[APP_KEY_PASSWORD]"
}
});
Next: Learn more about our the different ways of initializing the Javascript SDK in our documentation.
Virgil Security has a powerful set of APIs, and the documentation is there to get you started today.
- Get Started documentation
- Guides
Alternatively, head over to our Reference documentaton for in-depth information about every SDK method, it's arguments and return types.
This library is released under the 3-clause BSD License.
Our developer support team is here to help you. You can find us on Twitter and email.