Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const Consortium = require('coinstac-common').models.Consortium;
const dbRegistryService = require('./db-registry');
const logger = require('./logger.js');
/**
* @module service/seed-consortia
*/
/**
* conditionally seeds consortia db
* @param {object} config server config
* @returns {Promise} resolves to boolean indicating whether seeding happened or not
*/
/* istanbul ignore next */
module.exports = function seedConsortia(config) {
let seedDocs;
if (config.seed && typeof config.seed === 'string') {
'use strict';
const Pouchy = require('pouchy');
const dbConf = require('./.pouchdb-server-config');
const url = require('url');
const common = require('coinstac-common');
const Consortium = common.models.Consortium;
/**
* @private
* @module seed-central-db
* @description stubs a dummy consortium and a dummy computation into the
* infrastructure DBs, which will be consumed by the server and client processes
* @returns {Promise}
*/
module.exports = {
seed(declPath) {
const decl = require(declPath); // eslint-disable-line global-require
return Promise.all([
this._seedConsortia(decl),
this._seedComputations(decl),
])
'use strict';
/**
* @module consortia-service
*/
const common = require('coinstac-common');
const uuid = require('uuid');
const toArray = require('lodash/toArray');
const Consortium = common.models.Consortium;
const ModelService = require('../model-service');
class ConsortiaService extends ModelService {
constructor(opts) {
super(opts);
this.auth = opts.client.auth;
/* istanbul ignore next */
if (!this.auth) {
throw new ReferenceError('auth instance');
}
}
modelServiceHooks() { // eslint-disable-line class-methods-use-this
return {
dbName: 'consortia',
'use strict';
/**
* @module service/remote-pipeline-runner-pool
*/
const coinstacCommon = require('coinstac-common');
const computationRegistryService = require('./computation-registry');
const dbRegistryService = require('./db-registry');
const logger = require('./logger');
const RemotePipelineRunnerPool =
coinstacCommon.models.pipeline.runner.pool.RemotePipelineRunnerPool;
/**
* @property pool RemotePipelineRunnerPool
* {@link http://mrn-code.github.io/coinstac-common/PipelineRunnerPool.html RemotePipelineRunnerPool}
*/
module.exports = {
pool: null,
/**
* initializes the server pipeline runner pool.
* @returns {Promise}
*/
init() {
const dbRegistry = dbRegistryService.get();
const computationRegistry = computationRegistryService.get();
'use strict';
/**
* @private
* @module remote
*/
require('./utils/handle-errors');
const Consortium = require('coinstac-common').models.Consortium;
const CoinstacServer = require('coinstac-server-core/src/coinstac-server.js');
const config = require('./utils/config.js');
const getComputationRegistryStub =
require('./utils/get-computation-registry-stub.js');
const { getChildProcessLogger } = require('./utils/logging');
const logger = getChildProcessLogger();
/**
* Boot remote process.
*
* @todo Figure out how to use `params.data` in this scenario.
*
* @params {Object} params
* @params {Array[]} params.activeComputationInputs Computation inputs to
* set on the consortium's `activeComputationInputs` property
'use strict';
/**
* @module project-service
*/
const ModelService = require('../model-service');
const Project = require('coinstac-common').models.Project;
const bluebird = require('bluebird');
const coinstacCommon = require('coinstac-common');
const fileStats = require('../utils/file-stats');
const fs = require('fs');
const path = require('path');
const camelCase = require('lodash/camelCase');
const difference = require('lodash/difference');
const find = require('lodash/find');
const includes = require('lodash/includes');
const findKey = require('lodash/findKey');
/**
* @class
* @extends ModelService
* @property {Map} projects Collection of project IDs to remote database names
* @property {Map} listeners Collection of remote database names to `DBListener`
'use strict';
const DecentralizedComputation =
require('coinstac-common').models.DecentralizedComputation;
const helpers = require('./helpers.js');
const path = require('path');
const values = require('lodash/values');
const DELIMITER = '--';
/**
* Get a registry filter function.
*
* @private
* @param {string} name
* @param {string} version
* @returns {function}
*/
function registryFilter(name, version) {
return function registryFilterer(registryItem) {
'use strict';
const url = require('url');
const joi = require('joi');
const utils = require('./utils');
const boom = require('boom');
const AuthorizationError = require('./authorization-error.js');
const Consortium = require('coinstac-common').models.Consortium;
const bouncerConfigSchema = joi.object().keys({
allowEverybody: joi.boolean(),
consortiumOwnersOnly: joi.boolean(),
consortiumMembersOnly: joi.boolean(),
exceptionRegExp: joi.alternatives().try(
joi.object().type(RegExp),
joi.array().items(joi.object().type(RegExp))
),
pathRegExp: joi.object().type(RegExp),
rejectEverybody: joi.boolean(),
targetBaseUrl: joi.string().uri({ scheme: /https?/ }).required(),
});
class Bouncer {
/**
maybeSeedConsortia() {
const Consortium = coinstacCommon.models.Consortium;
const seed = this.config.seed;
let seedDocs;
if (!this.dbRegistry) {
return Promise.reject(new Error('Seeding consortia requires DBRegistry'));
}
if (seed && typeof seed === 'string') {
try {
seedDocs = JSON.parse(seed);
} catch (error) {
return Promise.reject(error);
}
} else {
seedDocs = seed;
}
'use strict';
const atob = require('atob');
const axios = require('axios');
const btoa = require('btoa');
const coinsDepositBox = require('coins-deposit-box');
const conf = require('./../../config.js');
const DomStorage = require('dom-storage');
const Halfpenny = require('halfpenny');
const User = require('coinstac-common').models.User;
/**
* Authentication Service
* @class
* @extends Halfpenny
*/
class AuthenticationService extends Halfpenny {
constructor(config) {
super(config);
/**
* @todo: Don't clear to persist user and database credentials between
* sessions.
*/
this.clearDatabaseCredentials();
this.clearUser();