Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then((file) => {
console.log("Shared file: " + file);
// console.log("Shared messages: " + JSON.parse(decryptECIES(privateKey, JSON.parse(file))));
console.log("fetched!");
this.setState({ tempMessages: JSON.parse(decryptECIES(privateKey, JSON.parse(file))) });
let temp = this.state.tempMessages;
this.setState({ sharedMessages: temp.messages});
this.setState({ combinedMessages: [...this.state.myMessages, ...this.state.sharedMessages] });
this.setState({ loading: "hide", show: "" });
this.scrollToBottom();
})
.catch((error) => {
.then((fileContents) => {
if(fileContents) {
console.log(JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))));
this.setState({
team: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).team,
integrations: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).team,
editorView: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).editorView,
editorName: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).editorName,
editorRoles: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).editorRoles,
editorPermissions: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).editorPermissions,
editorIntegrations: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).editorIntegrations,
editorPublish: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).editorPublish,
journoView: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).journoView,
journoName: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).journoName,
journoRoles: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).journoRoles,
journoPermissions: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).journoPermissions,
journoIntegrations: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).journoIntegrations,
journoPublish: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).journoPublish,
accountSettings: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).accountSettings,
lastUpdated: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).lastUpdated
})
} else {
this.setState({
team: [],
integrations: [],
editorView: false,
editorRoles: false,
editorPermissions: false,
editorIntegrations: false,
editorPublish: false,
journoView: false,
.then((fileContents) => {
lookupProfile(this.state.user, "https://core.blockstack.org/v1/names")
.then((profile) => {
let image = profile.image;
console.log(profile);
if(profile.image){
this.setState({img: image[0].contentUrl})
} else {
this.setState({ img: avatarFallbackImage })
}
})
.catch((error) => {
console.log('could not resolve profile')
})
this.setState({ shareFile: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))), loading: false })
console.log("loaded");
this.save();
})
.catch(error => {
.then((fileContents) => {
let privateKey = loadUserData().appPrivateKey;
console.log(JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))));
this.setState({ docs: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))) })
console.log("loaded");
this.save();
})
.catch(error => {
client.getFile('updated.txt').then(file => {
if(file.data !=null) {
this.setState({ remoteUpdated: decryptECIES(privateKey, JSON.parse(file.data)) });
}
});
})
.then((fileContents) => {
this.setState({ loading: "hide"})
let privateKey = loadUserData().appPrivateKey;
if(JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))).length > 0) {
this.setState({ totalPosts: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))), loading: "hide" })
} else {
this.setState({ totalPosts: [], loading: "hide" })
}
})
.then(() => {
client.getFile('wordCount.txt').then(file => {
if(file.data != null) {
this.setState({ remoteWords: decryptECIES(privateKey, JSON.parse(file.data)) });
}
});
client.getFile('content.txt').then(file => {
if(file.data !=null) {
this.setState({ remoteContent: decryptECIES(privateKey, JSON.parse(file.data)) });
}
});
client.getFile('wordCount.txt').then(file => {
.then((file) => {
this.setState({ tempMessages: JSON.parse(decryptECIES(privateKey, JSON.parse(file))) });
let temp = this.state.tempMessages;
if(this.state.newCount < 1) {
this.setState({ newCount: temp.messages.length })
this.setState({ sharedMessages: temp.messages});
} else {
if(this.state.newCount < temp.messages.length) {
let newMessageCount = temp.messages.length - this.state.newCount;
this.setState({ sharedMessages: temp.messages});
this.setState({ newCount: this.state.newCount + newMessageCount })
var audio = new Audio('https://notificationsounds.com/soundfiles/0fcbc61acd0479dc77e3cccc0f5ffca7/file-sounds-1078-case-closed.mp3');
audio.play();
if(document.hidden){
this.changeFavicon();
}
} else {
this.setState({ newCount: this.state.newCount});
const decryptObject = (encrypted, privateKey, indexes) => {
const decrypted = Object.assign({}, encrypted)
for (const key in encrypted) {
if (encrypted.hasOwnProperty(key) && indexes.indexOf(key) === -1) {
const value = encrypted[key]
decrypted[key] = stringToValue(decryptECIES(privateKey, value))
}
}
return decrypted
}