Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return fluid.remove_if(fluid.copy(solutions), function (solution) {
// Match on device solutions.
var matchesSolutions = fluid.find(device.solutions, function (devSolution) {
if (devSolution.id === solution.id &&
(!solution.version ||
!devSolution.version ||
semver.satisfies(devSolution.version, solution.version)
)) {
return true;
}
});
if (!matchesSolutions) {
return solutions;
}
});
};
gpii.pspChannel.modelChangeListener = function (handler, pspChannel, value, oldValue, path, transaction) {
fluid.log("PSPChannel's PSP-facing modelChangeListener, sources are ", fluid.keys(transaction.sources));
if (!transaction.sources.PSP && !transaction.sources.SessionCleanup) {
fluid.log("Model change source is not PSP - candidate for update message");
if (pspChannel.outputBlocked) {
// Ensure that we queue just a single outgoing message for when the channel unblocks
if (!pspChannel.outputBlocked.queued) {
pspChannel.outputBlocked.queued = true;
pspChannel.outputBlocked.then(function () {
fluid.log("PSPChannel sending unblocked full update message", JSON.stringify(pspChannel.model, null, 2));
handler.sendTypedMessage("modelChanged", {path: [], type: "ADD", value: pspChannel.model});
});
}
} else {
var changes = fluid.modelPairToChanges(value, oldValue);
var hasDeletion = fluid.find(changes, function (change) {
return change.type === "DELETE";
});
if (hasDeletion) {
changes.forEach(function (change) {
handler.sendTypedMessage("modelChanged", change);
});
} else {
handler.sendTypedMessage("modelChanged", {path: [], type: "ADD", value: value});
}
}
}
};
fluid.each(solutions, function (solution, solutionId) {
// Match on device solutions.
var matchesSolutions = fluid.find(device.solutions, function (devSolution) {
if (devSolution.id === solutionId &&
(!solution.version ||
!devSolution.version ||
semver.satisfies(devSolution.version, solution.version)
)) {
return true;
}
});
if (matchesSolutions) {
filteredSolutions[solutionId] = solution;
}
});
gpii.pspChannel.modelChangeListener = function (handler, pspChannel, value, oldValue, path, transaction) {
fluid.log("PSPChannel's PSP-facing modelChangeListener, sources are ", fluid.keys(transaction.sources));
if (!transaction.sources.PSP && !transaction.sources.SessionCleanup) {
fluid.log("Model change source is not PSP - candidate for update message");
if (pspChannel.outputBlocked) {
// Ensure that we queue just a single outgoing message for when the channel unblocks
if (!pspChannel.outputBlocked.queued) {
pspChannel.outputBlocked.queued = true;
pspChannel.outputBlocked.then(function () {
fluid.log("PSPChannel sending unblocked full update message", JSON.stringify(pspChannel.model, null, 2));
handler.sendTypedMessage("modelChanged", {path: [], type: "ADD", value: pspChannel.model});
});
}
} else {
var changes = fluid.modelPairToChanges(value, oldValue);
var hasDeletion = fluid.find(changes, function (change) {
return change.type === "DELETE";
});
if (hasDeletion) {
changes.forEach(function (change) {
handler.sendTypedMessage("modelChanged", change);
});
} else {
handler.sendTypedMessage("modelChanged", {path: [], type: "ADD", value: value});
}
}
}
};
gpii.tests.productionConfigTesting.getKeyOrPrefsFromFile = function (filePath, id) {
var dataArray = JSON.parse(fs.readFileSync(filePath, "utf-8"));
return fluid.find(dataArray, function (anEntry) {
if (anEntry._id === id) {
return anEntry;
}
}, null);
};
fluid.remove_if(solutions, function (solution) {
var solutionOSVersion = fluid.find(fluid.get(solution, "contexts.OS"), function (OSEntry) {
return OSEntry.id === os ? OSEntry.version : undefined;
});
if (!semver.satisfies(version, solutionOSVersion)) {
return true;
}
});
};
gpii.dataLoader.loadStaticDataFromDisk = function (options) {
var data = gpii.dataLoader.getDataFromDirectory(options.staticDataDir);
var views = fluid.find(data, function (anElement) {
if (anElement._id && anElement._id === "_design/views") {
return anElement;
} else {
return undefined;
}
});
options.staticData = data;
options.newViews = views;
fluid.log("Retrieved static data from: '" + options.staticDataDir + "'");
fluid.log("\tViews data " + ( views ? "read." : "missing." ));
};
gpii.userListeners.pcsc.detectCard = function (atr) {
if (!atr instanceof Buffer) {
fluid.fail("atr needs to be a Buffer.");
}
var knownCards = gpii.userListeners.pcsc.knownCards;
var card = fluid.find(knownCards, function (card) {
return fluid.find(card.atrs, function (atrTest) {
return atrTest.equals(atr) ? card : undefined;
});
});
return card || null;
};
fluid.each(gpiiKeyRecords.rows, function (gpiiKeyRecord) {
var gpiiKey = fluid.find(snapSets, function (aSnapSet) {
if (gpiiKeyRecord.value.prefsSafeId === aSnapSet._id) {
return gpiiKeyRecord.value;
}
}, null);
if (gpiiKey !== null) {
gpiiKey._deleted = true;
gpiiKeysToDelete.push(gpiiKey);
}
});
return gpiiKeysToDelete;
fluid.each(entries, function (entry, entryId) {
if (!installedSolutions.some(function (s) { return s.id === entryId; })) {
var foundEntryId = fluid.find(entry.isInstalled, function (installedSolutionsReporter) {
var resolvedName = deviceReporter.nameResolver.resolveName(installedSolutionsReporter.type, "deviceReporter");
if (fluid.invokeGradedFunction(resolvedName, installedSolutionsReporter)) {
return entryId;
}
}, null);
if (foundEntryId !== null) {
installedSolutions.push({ "id": foundEntryId });
}
}
});
return installedSolutions;