@evervault/sdk
Advanced tools
Comparing version 0.2.0 to 0.2.1
40
index.js
@@ -64,3 +64,16 @@ /** @format */ | ||
keyStore: new EvervaultKeyStore(), | ||
urls: { | ||
auth: 'https://auth.evervault.com', | ||
api: 'https://api.evervault.com', | ||
}, | ||
init: function(newUrls) { | ||
Object.assign(this.urls, newUrls); | ||
}, | ||
/** | ||
* Encrypt your user's data with their evervault secret key | ||
* @param {any} data - data to encrypt | ||
* @param {Object} options - see readme for possible values | ||
*/ | ||
encrypt: function(data, options = {}) { | ||
@@ -106,2 +119,7 @@ const _encryptObject = (data, fields) => { | ||
/** | ||
* | ||
* @param {any} data - the data to be decrypted | ||
* @param {String} privateKey - a string representation of the private key | ||
*/ | ||
decrypt: function(data, privateKey) { | ||
@@ -160,3 +178,7 @@ const _decryptArray = (data) => { | ||
logout: () => { | ||
/** | ||
* delete a user's credentials and redirect them to evervault auth | ||
* @param {string} appId - the unique identifier for the application given by the evervault dashboard | ||
*/ | ||
logout: function(appId) { | ||
localStorage.removeItem('evervault-privateKey'); | ||
@@ -166,6 +188,11 @@ localStorage.removeItem('evervault-accessToken'); | ||
localStorage.removeItem('evervault-haiku'); | ||
Utils.handleRedirect(`${authRedirectUrl}/${MACHINE_NAME}`); | ||
Utils.handleRedirect(`${this.urls.auth}/${appId}`); | ||
}, | ||
refreshAccessToken: (accessToken, refreshToken) => { | ||
/** | ||
* Attempt to refresh the user's accesstoken using their refreshtoken | ||
* @param {String} accessToken - the user's access token given by evervault auth | ||
* @param {String} refreshToken - users's refresh token given by evervault auth | ||
*/ | ||
refreshAccessToken: function(accessToken, refreshToken) { | ||
const requestBody = { | ||
@@ -176,3 +203,3 @@ accessToken: accessToken || localStorage.getItem('evervault-accessToken'), | ||
}; | ||
return fetch('https://api.evervault.dev/v1/token/refresh', { | ||
return fetch(`${this.urls.api}/v1/token/refresh`, { | ||
method: 'POST', | ||
@@ -196,3 +223,3 @@ headers: { | ||
*/ | ||
checkAuth: (appId) => { | ||
checkAuth: function(appId) { | ||
const urlKey = window.location.hash.substring(2); | ||
@@ -203,3 +230,2 @@ window.location.hash = '/'; | ||
const refreshToken = localStorage.getItem('evervault-refreshToken'); | ||
const authRedirectUrl = process.ENV.AUTH_REDIRECT_URL; | ||
@@ -210,3 +236,3 @@ const hasStorageCredentials = | ||
if (!hasStorageCredentials && !urlKey) { | ||
Utils.handleRedirect(`${authRedirectUrl}/${appId}`); | ||
Utils.handleRedirect(`${this.urls.auth}/${appId}`); | ||
} else if (urlKey) { | ||
@@ -213,0 +239,0 @@ //user has key in url but not stored in memory |
{ | ||
"name": "@evervault/sdk", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "evervault Browser SDK", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -12,2 +12,2 @@ /** @format */ | ||
devtool: 'source-map', | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
590
41168
11