Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const sandbox = (
resource: string,
sources: Sources,
connectors: MainConnectors = {}
) => {
let channels: MessageChannels;
let subscription: FantasySubscription;
let worker: Worker;
let receivePorts: MessagePorts = {};
let rafSubscription: FantasySubscription;
const instanceId = uuid();
return adapt(xs.create({
start(observer) {
const sourceKeys = Object.keys(sources);
channels = createChannels(sourceKeys);
// { DOM: channel}
worker = open(resource);
// make a object of destination ports (rx in thread) wiil be transfered to thread
const transferPorts = portMap(channels, 2);
// make a object of entry ports (tx in main)
const sendPorts = portMap(channels, 1);
if (!tempDirectory) {
let baseLocation: string;
if (IS_WINDOWS) {
// On Windows use the USERPROFILE env variable
baseLocation = process.env["USERPROFILE"] || "C:\\";
} else {
if (process.platform === "darwin") {
baseLocation = "/Users";
} else {
baseLocation = "/home";
}
}
tempDirectory = path.join(baseLocation, "actions", "temp");
}
const dest = path.join(tempDirectory, uuidV4.default());
await io.mkdirP(dest);
return dest;
}
test('returns null when redis item is not found', async () => {
const randomCacheKey = uuid.default()
const response = await sut.get(randomCacheKey)
expect(response).toBeUndefined()
})
})
events: (events: string, options?: WorkerEventFnOptions): Stream => {
const listenerId = uuid();
let subscription: Subscription;
return adapt(xs.create({
start(observer) {
const attachMessage = {
cmd: WorkerDOMMessageCommand.attach,
payload: {
selector: selector,
events: events,
options: options,
listenerId
}
}
tx.postMessage(attachMessage);
subscription = fromEvent(rx, 'message')
.filter(e => (e.data as WorkerDOMEvent).listenerId === listenerId)
.subscribe({
private static generateUuid(): string {
return uuidv4.default()
}
}
export function import_(recognizerContext, model, data, callback) {
const recognitionContext = {
model,
callback: (err, res) => iinkCallback(model, err, res, callback),
importFileId: uuid.default()
};
const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, recognitionContext);
const chunkSize = recognizerContext.editor.configuration.recognitionParams.server.websocket.fileChunkSize;
for (let i = 0; i < data.size; i += chunkSize) {
if (i === 0) {
CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildImportFile, recognitionContext.importFileId, data.type)
.catch(exception => CdkWSRecognizerUtil.retry(import_, recognizerContext, model, data, callback));
}
const blobPart = data.slice(i, chunkSize, data.type);
readBlob(blobPart).then((res) => {
CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildImportChunk, recognitionContext.importFileId, res, i + chunkSize > data.size)
.catch(exception => CdkWSRecognizerUtil.retry(import_, recognizerContext, model, data, callback));
});
}
import { default as bunyan } from 'bunyan';
import { default as bformat } from 'bunyan-format';
import { default as CWLogsWritable } from 'cwlogs-writable';
import { default as UUID } from 'uuid/v4';
import { default as ExpressSSE } from 'express-sse';
import { default as proxy } from 'proxy-agent';
import { default as bunyanTcp } from 'bunyan-logstash-tcp';
let SSE = [];
let AGENT_ID = UUID();
let STREAM = [];
let LOG = process.env.NODE_ENV === 'test' ? console : create(AGENT_ID);
let STREAM_USER_LAST_ACTIVITY = Date.now();
let CWLogFilterEventStream = require('smoketail').CWLogFilterEventStream;
let janitorInterval;
function getLogGroupMap() {
let logGroupMap = {};
logGroupMap['gtmGithubHook'] = '/aws/lambda/gtmGithubHook-dev-gtmGithubHook';
logGroupMap['gtmGithubResults'] = '/aws/lambda/gtmGithubHook-dev-gtmGithubResults';
logGroupMap['gtmAgent'] = process.env.GTM_AGENT_CLOUDWATCH_LOGS_GROUP || 'gtmAgent';
return logGroupMap;
}
function create(agentId) {