Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import ua from 'universal-analytics'
import uuid from 'uuid/v4'
const Store = require('electron-store')
const store = new Store({ name: 'SnippetStoreUserInfo' })
const config = new Store({ name: 'SnippetStoreConf' })
// Retrieve the userid value, and if it's not there, assign it a new uuid.
const userId = store.get('userId') || uuid()
// (re)save the userid, so it persists for the next app session.
store.set('userId', userId)
const user = ua('UA-123395923-2', userId)
export function trackEvent (category, action, label, value) {
if (config.get('config').allowAnalytics) {
user
.event({
ec: category,
ea: action,
el: label,
ev: value
})
.send()
}
}
sendMessage ({ commit, rootState }, { text, created, sender, conversationId }) {
const convoRef = rootState.db.collection('conversations').doc(conversationId)
convoRef.update({
messages: [...state.all[conversationId].messages, { id: uuidv4(), created, sender, text }]
})
.then(res => console.log('Message sent.'))
.catch(err => console.log('Error', err))
},
generateInitSession() {
return uuidv4()
}
peerRPCRequest(code, data, peer): Promise> {
const requestId = uuid4();
return new Promise((resolve) => {
if (!(PeerRepository.has(peer))) {
logger.error(`Peer ${peer.ip}:${peer.port} is offline`);
resolve(new ResponseEntity({ errors: [`Peer ${peer.ip}:${peer.port} is offline`] }));
}
if (!peer.socket) {
peer = PeerRepository.getPeerFromPool(peer);
}
const responseListener = (response) => {
response = new SocketResponseRPC(response);
if (response.requestId && response.requestId === requestId) {
componentDidMount() {
this.setState({
dropboxAuthenticationID: uuid(),
googleDriveAuthenticationID: uuid()
});
this.props.onReady();
}
export const addMarkingDefinition = async (user, markingDefinition) => {
const wTx = await takeWriteTx();
const internalId = markingDefinition.internal_id
? escapeString(markingDefinition.internal_id)
: uuid();
const markingDefinitionIterator = await wTx.tx.query(`insert $markingDefinition isa Marking-Definition,
has internal_id "${internalId}",
has entity_type "marking-definition",
has stix_id "${
markingDefinition.stix_id
? escapeString(markingDefinition.stix_id)
: `marking-definition--${uuid()}`
}",
has definition_type "${escapeString(markingDefinition.definition_type)}",
has definition "${escapeString(markingDefinition.definition)}",
has color "${escapeString(markingDefinition.color)}",
has level ${markingDefinition.level},
has created ${
markingDefinition.created ? prepareDate(markingDefinition.created) : now()
},
has modified ${
const track = async (event) => {
if (!cookie('playground_anonymous')) {
cookie('playground_anonymous', uuidv4());
}
trackEvents.push({
...event,
id: uuidv4(),
clientAnonymousId: cookie('playground_anonymous'),
clientTimestamp: new Date().toJSON()
});
const flush = async (toFlush, retries) => {
if (!toFlush) {
toFlush = trackEvents;
trackEvents = [];
}
if (!toFlush.length) {
return null;
}
if (retries == null) {
retries = 10;
}
try {
const sentAt = new Date().toJSON();
const {
from, encKey, data: dataArr, sharingConfirmationId
} = data;
if (sharingConfirmationId) {
sendWS(globalStates.ws, {
type: 'share-confirm',
data: sharingConfirmationId
});
}
if (!from || !encKey || !dataArr) {
return;
}
const notificationId = uuid();
notification.open({
key: notificationId,
duration: 0,
message: 'New Data',
description: 'Decrypting...',
icon:
});
const decKey = textToBytes(decryptAsymmetric(globalStates.privateKey, encKey));
Promise.all(dataArr.map(datum => Promise.all([
datum.type,
decryptObjectSymmetric(
decKey,
{
name: datum.name,
(_input, key = uuid().toString()) => ({key}),
);
export function ModelManifests(params) {
let urlPath = "/registry/models/manifest";
let body = {},
queryParameters = {},
headers = params.headers || {},
form = {};
headers["Accept"] = ["application/json"];
headers["Content-Type"] = ["application/json"];
if (has(params, "requestId")) {
headers["X-Request-ID"] = params.requestId;
} else if (has(params, "X-Request-ID")) {
headers["X-Request-ID"] = params["X-Request-ID"];
} else {
headers["X-Request-ID"] = uuid();
}
return function ModelManifestsRequest({ http, path, resolve }) {
let parameters = params;
if (parameters === undefined) {
parameters = {};
}
if (parameters["frameworkName"] !== undefined) {
queryParameters["framework_name"] = resolve.value(
parameters["frameworkName"]
);
}
if (parameters["frameworkVersion"] !== undefined) {