@kano/kbc-utils
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -18,3 +18,3 @@ "use strict"; | ||
this.setKey = (base, userId) => { | ||
return `${base}_${this.env}${userId ? `_${userId}` : ''}`; | ||
return `${this.env}_${userId ? `${userId}_` : ''}${base}`; | ||
}; | ||
@@ -54,2 +54,3 @@ this.read = (baseKey, userId) => { | ||
const env = process.env.NODE_ENV || 'no-env'; | ||
const domain = process.env.NODE_ENV === 'development' ? 'localhost' : 'kano.me'; | ||
return { | ||
@@ -70,3 +71,3 @@ read: function (params) { | ||
params.path = params.path || '/'; | ||
params.domain = params.domain || 'kano.me'; | ||
params.domain = params.domain || domain; | ||
if (typeof name === 'string') { | ||
@@ -221,8 +222,12 @@ const cookie = encode(name) + '=' + encode(params.value) + ';'; | ||
let guest = guest_1.default(process.env.NODE_ENV === 'production' ? 'https://kano-cross-domain-storage.netlify.app' : 'https://staging-kano-cross-domain-storage.netlify.app'); | ||
let connectionError = false; | ||
return { | ||
read: (key) => new Promise((resolve, reject) => { | ||
if (connectionError) | ||
reject(); | ||
guest.get(key, (error, data) => { | ||
if (error) { | ||
console.error('cross-domain-storage:' + error); | ||
return reject(error); | ||
console.log('cross-domain-storage: ' + error); | ||
connectionError = true; | ||
return reject(); | ||
} | ||
@@ -233,6 +238,9 @@ return resolve(data); | ||
write: (key, value) => new Promise((resolve, reject) => { | ||
if (connectionError) | ||
reject(); | ||
guest.set(key, value, (error, data) => { | ||
if (error) { | ||
console.error('cross-domain-storage:' + error); | ||
return reject(error); | ||
console.log('cross-domain-storage: ' + error); | ||
connectionError = true; | ||
return reject(); | ||
} | ||
@@ -243,6 +251,9 @@ return resolve(data || value); | ||
remove: (key) => new Promise((resolve, reject) => { | ||
if (connectionError) | ||
reject(); | ||
guest.remove(key, (error, data) => { | ||
if (error) { | ||
console.error('cross-domain-storage:' + error); | ||
return reject(error); | ||
console.log('cross-domain-storage: ' + error); | ||
connectionError = true; | ||
return reject(); | ||
} | ||
@@ -249,0 +260,0 @@ return resolve(data || key); |
{ | ||
"name": "@kano/kbc-utils", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "Utilities functionality for boilerplate mini apps", | ||
@@ -37,3 +37,3 @@ "author": "Kano Computing", | ||
}, | ||
"gitHead": "75508f227a809f12ba759874ff7a6510bf7d4263" | ||
"gitHead": "fd51a62cc82f5892f9648987e32b16646db0a0aa" | ||
} |
Sorry, the diff of this file is not supported yet
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
46573
609
4