Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
token = "";
}
const params = {
content: encryptedData,
filePath: '/documents/index.json',
provider: storageProvider,
token: token,
update: true
}
let postToStorage = await postToStorageProvider(params);
await console.log(postToStorage);
const singleData = await JSON.stringify(getGlobal().singleDoc);
const singleEncrypted = await encryptContent(singleData, {publicKey: publicKey})
const doc = await getGlobal().singleDoc;
const singleParams = await {
content: singleEncrypted,
filePath: `/documents/single/${doc.id}.json`,
provider: storageProvider,
token: token,
update: true
}
let postSingle = await postToStorageProvider(singleParams)
await console.log(postSingle);
setGlobal({ loading: false });
} else {
putFile("documentscollection.json", JSON.stringify(getGlobal().value), {encrypt: true})
.then(() => {
console.log("Saved");
saveSingleDocTags(doc);
token = "";
}
const params = {
content: encryptedData,
filePath: `/vault/${file}`,
provider: storageProvider,
token: token,
update: false
}
let postToStorage = await postToStorageProvider(params);
await console.log(postToStorage);
//Now update vault index file.
const data2 = JSON.stringify(getGlobal().files);
const encryptedData2 = await encryptContent(data2, {publicKey: publicKey})
const params2 = {
content: encryptedData2,
filePath: `/vault/index.json`,
provider: storageProvider,
token: token,
update: true
}
let postVaultIndex = await postToStorageProvider(params2);
await console.log(postVaultIndex);
await setTimeout(loadVault, 1500);
} else {
putFile(file, JSON.stringify(getGlobal().singleFile), {encrypt:true})
.then(() => {
console.log("Saved!");
saveNewVaultFileTwo();
}
} else {
token = "";
}
const params = {
content: encryptedData,
filePath: "/documents/index.json",
provider: storageProvider,
token: token,
update: true
};
let postToStorage = await postToStorageProvider(params);
console.log(postToStorage);
const singleData = JSON.stringify(getGlobal().singleDoc);
const singleEncrypted = await encryptContent(singleData, {
publicKey: publicKey
});
const singleParams = {
content: singleEncrypted,
filePath: `/documents/single/${file}.json`,
provider: storageProvider,
token: token,
update: true
};
let postSingle = await postToStorageProvider(singleParams);
console.log(postSingle);
setGlobal({ autoSave: "Saved" });
loadDocs();
} else if (authProvider === "blockstack") {
putFile(fullFile, JSON.stringify(getGlobal().singleDoc), { encrypt: true })
.then(() => {
const data2 = JSON.stringify(getGlobal().singleFile);
const encryptedData2 = await encryptContent(data2, {publicKey: publicKey})
const params2 = {
content: encryptedData2,
filePath: `/vault/${fullFile}`,
provider: storageProvider,
token: token,
update: true
}
let postToStorage2 = await postToStorageProvider(params2);
await console.log(postToStorage2);
//Now update vault index file.
const data3 = JSON.stringify(getGlobal().files);
const encryptedData3 = await encryptContent(data3, {publicKey: publicKey})
const params3 = {
content: encryptedData3,
filePath: `/vault/index.json`,
provider: storageProvider,
token: token,
update: true
}
let postVaultIndex = await postToStorageProvider(params3);
await console.log(postVaultIndex);
//Finally, share the file for access by recipient.
const fileFull = userShort + fileName;
const data4 = JSON.stringify(getGlobal().sharedCollection);
const encryptedData4 = await encryptContent(data4, { publicKey: getGlobal().pubKey });
const params4 = {
} else {
token = "";
}
const params = {
content: encryptedData,
filePath: '/documents/index.json',
provider: storageProvider,
token: token,
update: getGlobal().value.length > 0 ? true : false
}
let postToStorage = await postToStorageProvider(params);
await console.log(postToStorage);
const singleData = await JSON.stringify(getGlobal().singleDoc);
const singleEncrypted = await encryptContent(singleData, {publicKey: publicKey})
const doc = await getGlobal().singleDoc;
const singleParams = await {
content: singleEncrypted,
filePath: `/documents/single/${doc.id}.json`,
provider: storageProvider,
token: token,
update: false
}
let postSingle = await postToStorageProvider(singleParams)
await console.log(postSingle);
if(window.location.href.includes('vault')) {
window.location.replace('/documents');
} else if(!window.location.href.includes('google') && !window.location.href.includes('documents/doc/') && !window.location.href.includes('file-explorer')) {
setTimeout(() => {
setGlobal({ redirect: true });
}, 1500)
{
scope: "putFilePrefix",
domain: "Administrators"
}
];
const gaiaConfig = await connectToGaiaHub(
gaiaHubUrl,
blockstack.loadUserData().appPrivateKey,
scopes
);
//Need to save the scoped authorization first.
if (pubKey) {
const data = gaiaConfig;
const encryptedData = blockstack.encryptContent(JSON.stringify(data), {
publicKey: pubKey
});
const folderPath = teamName;
const file = `${folderPath}/${pubKey}.json`;
await blockstack.putFile(file, encryptedData, { encrypt: false });
} else {
alert("User has not generated a key yet");
}
//Now, save the appropriate data using the teamKey.
//Fetch the root key first.
let fileName = 'keys/root/teamkey.json';
await blockstack.getFile(fileName, {decrypt: true})
.then((file) => {
if(file) {
//Check if the key has already been created.
setGlobal({ files: files, loading: true }, async () => {
const publicKey = await JSON.parse(localStorage.getItem('graphite_keys')).GraphiteKeyPair.public;
const data = JSON.stringify(getGlobal().files);
const encryptedData = await encryptContent(data, {publicKey: publicKey})
const storageProvider = JSON.parse(localStorage.getItem('storageProvider'));
let token;
if(localStorage.getItem('oauthData')) {
if(typeof JSON.parse(localStorage.getItem('oauthData')) === 'object') {
token = JSON.parse(localStorage.getItem('oauthData')).data.access_token;
} else {
token = JSON.parse(localStorage.getItem('oauthData'))
}
} else {
token = "";
}
const params = {
content: encryptedData,
filePath: '/vault/index.json',
provider: storageProvider,
const encryptLink = (publicKey, loginLink) => {
debug('Encrypting ', loginLink, 'with', publicKey);
return blockstack.encryptContent(loginLink, { publicKey });
};