Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
orgInfo.teams[index].users[userId] = userObj;
const updatedUserObj = userObj;
delete updatedUserObj.invitePending;
orgInfo.users.push(updatedUserObj);
await setGlobal({ proOrgInfo: orgInfo });
const accountParams = {
fileName: "account.json",
encrypt: true,
body: JSON.stringify(getGlobal().proOrgInfo)
}
const updatedAccount = await postData(accountParams);
console.log(updatedAccount);
const privateKey = userSession.loadUserData().appPrivateKey;
userObj["selectedTeam"] = data.selectedTeam;
userObj["pubKey"] = getPublicKeyFromPrivate(privateKey);
userObj["orgId"] = proOrgInfo.orgId;
const jwtData = {
profile: userSession.loadUserData().profile,
username: userSession.loadUserData().username,
pubKey: getPublicKeyFromPrivate(privateKey)
}
const bearer = blockstack.signProfileToken(jwtData, userSession.loadUserData().appPrivateKey);
const headerObj = {
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Authorization': bearer
},
}
axios.post(`/account/user?updateTeam=${true}`, JSON.stringify(userObj), headerObj)
.then(async (res) => {
const privateKey = userSession.loadUserData().appPrivateKey;
const jwtData = {
profile: userSession.loadUserData().profile,
username: userSession.loadUserData().username,
pubKey: getPublicKeyFromPrivate(privateKey)
}
const bearer = blockstack.signProfileToken(jwtData, userSession.loadUserData().appPrivateKey);
const headerObj = {
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Authorization': bearer
},
}
const inviteUrlBase = window.location.href.includes('local') ? "http://localhost:3000" : "https://app.graphitedocs.com";
userData["pubKey"] = getPublicKeyFromPrivate(privateKey);
const data = {
inviteUrl: `${inviteUrlBase}/invite/${token}`,
userData
}
axios.post(`/emails/invite`, JSON.stringify(data), headerObj)
.then(async (res) => {
console.log(res.data)
if(userData.resend) {
ToastsStore.success("Invite email re-sent!");
}
}).catch((error) => {
ToastsStore.error("Trouble re-sending invite email.");
console.log(error)
})
}
teamPubKey: publicKey
}
let trialParams = {
fileName: "account.json",
encrypt: true,
body: JSON.stringify(trialObject)
}
let postTrial = await postData(trialParams);
console.log(postTrial);
const data = {
profile: userSession.loadUserData().profile,
username: userSession.loadUserData().username,
pubKey: getPublicKeyFromPrivate(privateKey)
}
const bearer = blockstack.signProfileToken(data, userSession.loadUserData().appPrivateKey);
const headerObj = {
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Authorization': bearer
},
}
axios.post(`/account/org`, JSON.stringify(trialObject), headerObj)
.then(async (res) => {
console.log(res.data)
if(res.data.success === false) {
ToastsStore.error(res.data.message);
} else {
export function deleteTeamFile(data) {
const { userSession, proOrgInfo } = getGlobal();
const privateKey = userSession.loadUserData().appPrivateKey;
const pubKey = getPublicKeyFromPrivate(privateKey);
const tokenData = {
profile: userSession.loadUserData().profile,
username: userSession.loadUserData().username,
pubKey
}
const bearer = blockstack.signProfileToken(tokenData, userSession.loadUserData().appPrivateKey);
const headerObj = {
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Authorization': bearer
},
}
axios.delete(`/account/organization/${proOrgInfo.orgId}/teams/${data.teamId}/files/${data.docId}?pubKey=${pubKey}`, headerObj)
.then(async (res) => {
console.log(res.data)
static currentUser() {
if (typeof window === 'undefined') {
return null;
}
const userData = loadUserData();
if (!userData) {
return null;
}
const { username, profile, appPrivateKey } = userData;
const publicKey = getPublicKeyFromPrivate(appPrivateKey);
const Clazz = this;
const user = new Clazz({
_id: username,
username,
publicKey,
profile,
});
return user;
}
static async create(attrs = {}) {
const privateKey = makeECPrivateKey();
const publicKey = getPublicKeyFromPrivate(privateKey);
const signingKey = new this({
...attrs,
publicKey,
privateKey,
});
await signingKey.save();
return signingKey;
}
singleFile["teamFile"] = true;
await setGlobal({ singleFile });
await saveFile();
const privateKey = userSession.loadUserData().appPrivateKey;
const syncedFile = {
id: fileId,
name: userSession.encryptContent(getGlobal().name, {publicKey: JSON.parse(fetchedKeys).public}),
teamName: userSession.encryptContent(data.teamName, {publicKey: JSON.parse(fetchedKeys).public}),
orgId: proOrgInfo.orgId,
teamId: data.teamId,
lastUpdated: getMonthDayYear(),
timestamp: Date.now(),
currentHostBucket: userSession.encryptContent(userSession.loadUserData().username, {publicKey: JSON.parse(fetchedKeys).public}),
pubKey: getPublicKeyFromPrivate(privateKey)
}
const tokenData = {
profile: userSession.loadUserData().profile,
username: userSession.loadUserData().username,
pubKey: getPublicKeyFromPrivate(privateKey)
}
const bearer = blockstack.signProfileToken(tokenData, userSession.loadUserData().appPrivateKey);
const headerObj = {
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Authorization': bearer
},
}
export async function sendInviteEmail(userData, token) {
const { userSession } = getGlobal();
const privateKey = userSession.loadUserData().appPrivateKey;
const jwtData = {
profile: userSession.loadUserData().profile,
username: userSession.loadUserData().username,
pubKey: getPublicKeyFromPrivate(privateKey)
}
const bearer = blockstack.signProfileToken(jwtData, userSession.loadUserData().appPrivateKey);
const headerObj = {
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Authorization': bearer
},
}
const inviteUrlBase = window.location.href.includes('local') ? "http://localhost:3000" : "https://app.graphitedocs.com";
userData["pubKey"] = getPublicKeyFromPrivate(privateKey);
const data = {
inviteUrl: `${inviteUrlBase}/invite/${token}`,
userData
}
axios.post(`/emails/invite`, JSON.stringify(data), headerObj)
export async function saveNewTeam() {
const { userSession, proOrgInfo } = getGlobal();
const userInfo = proOrgInfo.users.filter(user => user.username === userSession.loadUserData().username)[0];
const checkRole = userInfo.isAdmin;
const teamId = uuid();
const privateKey = makeECPrivateKey();
const publicKey = getPublicKeyFromPrivate(privateKey);
const teamObj = {
orgId: getGlobal().proOrgInfo.orgId,
pubKey: getPublicKeyFromPrivate(userSession.loadUserData().appPrivateKey),
team: {
name: getGlobal().newTeamName,
id: teamId,
pubKey: publicKey,
users: [
{
id: userInfo.id,
username: userSession.loadUserData().username,
role: checkRole === true ? "Admin" : "Manager",
email: userInfo.email,
name: userInfo.name
}
]
publicKey() {
return getPublicKeyFromPrivate(this.privateKey);
}