mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-03 23:09:17 -05:00
Merge pull request #815 from verdaccio/refactor-flow
refactor: flow 0.7x.0
This commit is contained in:
commit
a14a737241
20 changed files with 450 additions and 148 deletions
1
.babelrc
1
.babelrc
|
@ -38,7 +38,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"testOldEnv": {
|
"testOldEnv": {
|
||||||
/** FIXME: for an issue on jest env we need to use es2015-node4 **/
|
|
||||||
"presets": [ "es2015-node4", "flow"],
|
"presets": [ "es2015-node4", "flow"],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"transform-class-properties",
|
"transform-class-properties",
|
||||||
|
|
33
flow-typed/npm/express_v4.16.x.js
vendored
33
flow-typed/npm/express_v4.16.x.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
// flow-typed signature: 41a220e96fcef89a09244ac3797039e8
|
// flow-typed signature: cc24a4e737d9dfb8e1381c3bd4ebaa65
|
||||||
// flow-typed version: 9f7cf2ab0c/express_v4.16.x/flow_>=v0.32.x
|
// flow-typed version: d11eab7bb5/express_v4.16.x/flow_>=v0.32.x
|
||||||
|
|
||||||
import type { Server } from "http";
|
import type { Server } from "http";
|
||||||
import type { Socket } from "net";
|
import type { Socket } from "net";
|
||||||
|
@ -195,13 +195,11 @@ declare class express$Router extends express$Route {
|
||||||
id: string
|
id: string
|
||||||
) => mixed
|
) => mixed
|
||||||
): void;
|
): void;
|
||||||
|
(
|
||||||
// Can't use regular callable signature syntax due to https://github.com/facebook/flow/issues/3084
|
|
||||||
$call: (
|
|
||||||
req: http$IncomingMessage,
|
req: http$IncomingMessage,
|
||||||
res: http$ServerResponse,
|
res: http$ServerResponse,
|
||||||
next?: ?express$NextFunction
|
next?: ?express$NextFunction
|
||||||
) => void;
|
): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -250,6 +248,12 @@ declare class express$Application extends express$Router mixins events$EventEmit
|
||||||
res: http$ServerResponse,
|
res: http$ServerResponse,
|
||||||
next?: ?express$NextFunction
|
next?: ?express$NextFunction
|
||||||
): void;
|
): void;
|
||||||
|
// callable signature is not inherited
|
||||||
|
(
|
||||||
|
req: http$IncomingMessage,
|
||||||
|
res: http$ServerResponse,
|
||||||
|
next?: ?express$NextFunction
|
||||||
|
): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare type JsonOptions = {
|
declare type JsonOptions = {
|
||||||
|
@ -266,6 +270,20 @@ declare type JsonOptions = {
|
||||||
) => mixed
|
) => mixed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare type express$UrlEncodedOptions = {
|
||||||
|
extended?: boolean,
|
||||||
|
inflate?: boolean,
|
||||||
|
limit?: string | number,
|
||||||
|
parameterLimit?: number,
|
||||||
|
type?: string | Array<string> | ((req: express$Request) => boolean),
|
||||||
|
verify?: (
|
||||||
|
req: express$Request,
|
||||||
|
res: express$Response,
|
||||||
|
buf: Buffer,
|
||||||
|
encoding: string
|
||||||
|
) => mixed,
|
||||||
|
}
|
||||||
|
|
||||||
declare module "express" {
|
declare module "express" {
|
||||||
declare export type RouterOptions = express$RouterOptions;
|
declare export type RouterOptions = express$RouterOptions;
|
||||||
declare export type CookieOptions = express$CookieOptions;
|
declare export type CookieOptions = express$CookieOptions;
|
||||||
|
@ -280,6 +298,7 @@ declare module "express" {
|
||||||
(): express$Application, // If you try to call like a function, it will use this signature
|
(): express$Application, // If you try to call like a function, it will use this signature
|
||||||
json: (opts: ?JsonOptions) => express$Middleware,
|
json: (opts: ?JsonOptions) => express$Middleware,
|
||||||
static: (root: string, options?: Object) => express$Middleware, // `static` property on the function
|
static: (root: string, options?: Object) => express$Middleware, // `static` property on the function
|
||||||
Router: typeof express$Router // `Router` property on the function
|
Router: typeof express$Router, // `Router` property on the function
|
||||||
|
urlencoded: (opts: ?express$UrlEncodedOptions) => express$Middleware,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@verdaccio/file-locking": "0.0.7",
|
"@verdaccio/file-locking": "0.0.7",
|
||||||
"@verdaccio/local-storage": "1.1.2",
|
"@verdaccio/local-storage": "1.1.3",
|
||||||
"@verdaccio/streams": "1.0.0",
|
"@verdaccio/streams": "1.0.0",
|
||||||
"JSONStream": "1.3.2",
|
"JSONStream": "1.3.2",
|
||||||
"asciidoctor.js": "1.5.6",
|
"asciidoctor.js": "1.5.6",
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "6.1.3",
|
"@commitlint/cli": "6.1.3",
|
||||||
"@commitlint/config-conventional": "6.1.3",
|
"@commitlint/config-conventional": "6.1.3",
|
||||||
"@verdaccio/types": "3.0.1",
|
"@verdaccio/types": "3.4.1",
|
||||||
"babel-cli": "6.26.0",
|
"babel-cli": "6.26.0",
|
||||||
"babel-core": "6.26.0",
|
"babel-core": "6.26.0",
|
||||||
"babel-eslint": "8.2.2",
|
"babel-eslint": "8.2.2",
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
"eslint-plugin-jest": "21.17.0",
|
"eslint-plugin-jest": "21.17.0",
|
||||||
"eslint-plugin-react": "7.10.0",
|
"eslint-plugin-react": "7.10.0",
|
||||||
"file-loader": "1.1.11",
|
"file-loader": "1.1.11",
|
||||||
"flow-bin": "0.69.0",
|
"flow-bin": "0.76.0",
|
||||||
"flow-runtime": "0.17.0",
|
"flow-runtime": "0.17.0",
|
||||||
"friendly-errors-webpack-plugin": "1.7.0",
|
"friendly-errors-webpack-plugin": "1.7.0",
|
||||||
"github-markdown-css": "2.10.0",
|
"github-markdown-css": "2.10.0",
|
||||||
|
|
|
@ -5,18 +5,26 @@ import express from 'express';
|
||||||
import compression from 'compression';
|
import compression from 'compression';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import Storage from '../lib/storage';
|
import Storage from '../lib/storage';
|
||||||
import {loadPlugin} from '../lib/plugin-loader';
|
import loadPlugin from '../lib/plugin-loader';
|
||||||
import hookDebug from './debug';
|
import hookDebug from './debug';
|
||||||
import Auth from '../lib/auth';
|
import Auth from '../lib/auth';
|
||||||
import apiEndpoint from './endpoint';
|
import apiEndpoint from './endpoint';
|
||||||
|
|
||||||
import type {$Application} from 'express';
|
|
||||||
import type {$ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, IAuth} from '../../types';
|
|
||||||
import type {Config as IConfig} from '@verdaccio/types';
|
|
||||||
import {ErrorCode} from '../lib/utils';
|
import {ErrorCode} from '../lib/utils';
|
||||||
import {API_ERROR, HTTP_STATUS} from '../lib/constants';
|
import {API_ERROR, HTTP_STATUS} from '../lib/constants';
|
||||||
import AppConfig from '../lib/config';
|
import AppConfig from '../lib/config';
|
||||||
|
|
||||||
|
import type {$Application} from 'express';
|
||||||
|
import type {
|
||||||
|
$ResponseExtend,
|
||||||
|
$RequestExtend,
|
||||||
|
$NextFunctionVer,
|
||||||
|
IStorageHandler,
|
||||||
|
IAuth} from '../../types';
|
||||||
|
import type {
|
||||||
|
Config as IConfig,
|
||||||
|
IPluginMiddleware,
|
||||||
|
} from '@verdaccio/types';
|
||||||
|
|
||||||
const LoggerApp = require('../lib/logger');
|
const LoggerApp = require('../lib/logger');
|
||||||
const Middleware = require('./middleware');
|
const Middleware = require('./middleware');
|
||||||
const Cats = require('../lib/status-cats');
|
const Cats = require('../lib/status-cats');
|
||||||
|
@ -54,10 +62,10 @@ const defineAPI = function(config: IConfig, storage: IStorageHandler) {
|
||||||
config: config,
|
config: config,
|
||||||
logger: LoggerApp.logger,
|
logger: LoggerApp.logger,
|
||||||
};
|
};
|
||||||
const plugins = loadPlugin(config, config.middlewares, plugin_params, function(plugin) {
|
const plugins = loadPlugin(config, config.middlewares, plugin_params, function(plugin: IPluginMiddleware) {
|
||||||
return plugin.register_middlewares;
|
return plugin.register_middlewares;
|
||||||
});
|
});
|
||||||
plugins.forEach(function(plugin) {
|
plugins.forEach((plugin) => {
|
||||||
plugin.register_middlewares(app, auth, storage);
|
plugin.register_middlewares(app, auth, storage);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
import {ErrorCode} from './utils';
|
import {ErrorCode} from './utils';
|
||||||
import {API_ERROR} from './constants';
|
import {API_ERROR} from './constants';
|
||||||
|
|
||||||
export function allow_action(action) {
|
import type {RemoteUser, Package, Callback} from '@verdaccio/types';
|
||||||
return function(user, pkg, callback) {
|
|
||||||
|
export function allow_action(action: string) {
|
||||||
|
return function(user: RemoteUser, pkg: Package, callback: Callback) {
|
||||||
const {name, groups} = user;
|
const {name, groups} = user;
|
||||||
const hasPermission = pkg[action].some((group) => name === group || groups.includes(group));
|
const hasPermission = pkg[action].some((group) => name === group || groups.includes(group));
|
||||||
|
|
||||||
|
@ -20,11 +24,11 @@ export function allow_action(action) {
|
||||||
|
|
||||||
export function getDefaultPlugins() {
|
export function getDefaultPlugins() {
|
||||||
return {
|
return {
|
||||||
authenticate(user, password, cb) {
|
authenticate(user: string, password: string, cb: Callback) {
|
||||||
cb(ErrorCode.getForbidden(API_ERROR.BAD_USERNAME_PASSWORD));
|
cb(ErrorCode.getForbidden(API_ERROR.BAD_USERNAME_PASSWORD));
|
||||||
},
|
},
|
||||||
|
|
||||||
add_user(user, password, cb) {
|
add_user(user: string, password: string, cb: Callback) {
|
||||||
return cb(ErrorCode.getConflict(API_ERROR.BAD_USERNAME_PASSWORD));
|
return cb(ErrorCode.getConflict(API_ERROR.BAD_USERNAME_PASSWORD));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import {loadPlugin} from '../lib/plugin-loader';
|
|
||||||
|
import {API_ERROR, HTTP_STATUS, ROLES, TOKEN_BASIC, TOKEN_BEARER} from './constants';
|
||||||
|
import loadPlugin from '../lib/plugin-loader';
|
||||||
import {buildBase64Buffer, ErrorCode} from './utils';
|
import {buildBase64Buffer, ErrorCode} from './utils';
|
||||||
import {aesDecrypt, aesEncrypt, signPayload, verifyPayload} from './crypto-utils';
|
import {aesDecrypt, aesEncrypt, signPayload, verifyPayload} from './crypto-utils';
|
||||||
|
import {getDefaultPlugins} from './auth-utils';
|
||||||
|
|
||||||
import type {Config, Logger, Callback} from '@verdaccio/types';
|
import {getMatchedPackagesSpec} from './config-utils';
|
||||||
|
|
||||||
|
import type {Config, Logger, Callback, IPluginAuth, RemoteUser} from '@verdaccio/types';
|
||||||
import type {$Response, NextFunction} from 'express';
|
import type {$Response, NextFunction} from 'express';
|
||||||
import type {$RequestExtend, JWTPayload} from '../../types';
|
import type {$RequestExtend, JWTPayload} from '../../types';
|
||||||
import {API_ERROR, HTTP_STATUS, ROLES, TOKEN_BASIC, TOKEN_BEARER} from './constants';
|
|
||||||
import {getMatchedPackagesSpec} from './config-utils';
|
|
||||||
import type {IAuth} from '../../types';
|
import type {IAuth} from '../../types';
|
||||||
import {getDefaultPlugins} from './auth-utils';
|
|
||||||
|
|
||||||
const LoggerApi = require('./logger');
|
const LoggerApi = require('./logger');
|
||||||
|
|
||||||
|
@ -36,7 +39,7 @@ class Auth implements IAuth {
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
};
|
};
|
||||||
|
|
||||||
return loadPlugin(config, config.auth, pluginOptions, (plugin) => {
|
return loadPlugin(config, config.auth, pluginOptions, (plugin: IPluginAuth) => {
|
||||||
const {authenticate, allow_access, allow_publish} = plugin;
|
const {authenticate, allow_access, allow_publish} = plugin;
|
||||||
|
|
||||||
return authenticate || allow_access || allow_publish;
|
return authenticate || allow_access || allow_publish;
|
||||||
|
@ -115,7 +118,7 @@ class Auth implements IAuth {
|
||||||
/**
|
/**
|
||||||
* Allow user to access a package.
|
* Allow user to access a package.
|
||||||
*/
|
*/
|
||||||
allow_access(packageName: string, user: string, callback: Callback) {
|
allow_access(packageName: string, user: RemoteUser, callback: Callback) {
|
||||||
let plugins = this.plugins.slice(0);
|
let plugins = this.plugins.slice(0);
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
let pkg = Object.assign({name: packageName}, getMatchedPackagesSpec(packageName, this.config.packages));
|
let pkg = Object.assign({name: packageName}, getMatchedPackagesSpec(packageName, this.config.packages));
|
||||||
|
@ -123,11 +126,11 @@ class Auth implements IAuth {
|
||||||
(function next() {
|
(function next() {
|
||||||
const plugin = plugins.shift();
|
const plugin = plugins.shift();
|
||||||
|
|
||||||
if (typeof(plugin.allow_access) !== 'function') {
|
if (_.isFunction(plugin.allow_access) === false) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.allow_access(user, pkg, function(err, ok) {
|
plugin.allow_access(user, pkg, function(err, ok: boolean) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
@ -152,11 +155,11 @@ class Auth implements IAuth {
|
||||||
(function next() {
|
(function next() {
|
||||||
const plugin = plugins.shift();
|
const plugin = plugins.shift();
|
||||||
|
|
||||||
if (typeof(plugin.allow_publish) !== 'function') {
|
if (_.isFunction(plugin.allow_publish) === false) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.allow_publish(user, pkg, (err, ok) => {
|
plugin.allow_publish(user, pkg, (err, ok: boolean) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
@ -185,7 +188,8 @@ class Auth implements IAuth {
|
||||||
return _next();
|
return _next();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (req.remote_user != null && req.remote_user.name !== undefined) {
|
if (_.isUndefined(req.remote_user) === false
|
||||||
|
&& _.isUndefined(req.remote_user.name) === false) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
req.remote_user = buildAnonymousUser();
|
req.remote_user = buildAnonymousUser();
|
||||||
|
@ -201,7 +205,6 @@ class Auth implements IAuth {
|
||||||
}
|
}
|
||||||
|
|
||||||
const credentials = this._parseCredentials(parts);
|
const credentials = this._parseCredentials(parts);
|
||||||
|
|
||||||
if (!credentials) {
|
if (!credentials) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ export const API_MESSAGE = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const API_ERROR = {
|
export const API_ERROR = {
|
||||||
BAD_USERNAME_PASSWORD: 'bad username/password, access denied {APP}',
|
BAD_USERNAME_PASSWORD: 'bad username/password, access denied',
|
||||||
NO_PACKAGE: 'no such package available',
|
NO_PACKAGE: 'no such package available',
|
||||||
NOT_ALLOWED: 'not allowed to access package',
|
NOT_ALLOWED: 'not allowed to access package',
|
||||||
INTERNAL_SERVER_ERROR: 'internal server error',
|
INTERNAL_SERVER_ERROR: 'internal server error',
|
||||||
|
@ -93,7 +93,7 @@ export const APP_ERROR = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_NO_README = 'ERROR: No README data found!';
|
export const DEFAULT_NO_README = 'ERROR: No README data found!';
|
||||||
|
export const MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';
|
||||||
|
|
||||||
export const WEB_TITLE = 'Verdaccio';
|
export const WEB_TITLE = 'Verdaccio';
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ fileExist, noSuchFile, DEFAULT_REVISION, pkgFileName,
|
||||||
} from './storage-utils';
|
} from './storage-utils';
|
||||||
import {createTarballHash} from './crypto-utils';
|
import {createTarballHash} from './crypto-utils';
|
||||||
import {prepareSearchPackage} from './storage-utils';
|
import {prepareSearchPackage} from './storage-utils';
|
||||||
import {loadPlugin} from '../lib/plugin-loader';
|
import loadPlugin from '../lib/plugin-loader';
|
||||||
import LocalDatabase from '@verdaccio/local-storage';
|
import LocalDatabase from '@verdaccio/local-storage';
|
||||||
import {UploadTarball, ReadTarball} from '@verdaccio/streams';
|
import {UploadTarball, ReadTarball} from '@verdaccio/streams';
|
||||||
import type {
|
import type {
|
||||||
|
@ -396,8 +396,8 @@ class LocalStorage implements IStorage {
|
||||||
const _transform = uploadStream._transform;
|
const _transform = uploadStream._transform;
|
||||||
const storage = this._getLocalStorage(name);
|
const storage = this._getLocalStorage(name);
|
||||||
|
|
||||||
uploadStream.abort = function() {};
|
(uploadStream: any).abort = function() {};
|
||||||
uploadStream.done = function() {};
|
(uploadStream: any).done = function() {};
|
||||||
|
|
||||||
uploadStream._transform = function(data) {
|
uploadStream._transform = function(data) {
|
||||||
shaOneHash.update(data);
|
shaOneHash.update(data);
|
||||||
|
@ -459,11 +459,11 @@ class LocalStorage implements IStorage {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadStream.abort = function() {
|
(uploadStream: any).abort = function() {
|
||||||
writeStream.abort();
|
writeStream.abort();
|
||||||
};
|
};
|
||||||
|
|
||||||
uploadStream.done = function() {
|
(uploadStream: any).done = function() {
|
||||||
if (!length) {
|
if (!length) {
|
||||||
uploadStream.emit('error', ErrorCode.getBadData('refusing to accept zero-length file'));
|
uploadStream.emit('error', ErrorCode.getBadData('refusing to accept zero-length file'));
|
||||||
writeStream.abort();
|
writeStream.abort();
|
||||||
|
@ -521,7 +521,7 @@ class LocalStorage implements IStorage {
|
||||||
const readTarballStream = storage.readTarball(filename);
|
const readTarballStream = storage.readTarball(filename);
|
||||||
const e404 = ErrorCode.getNotFound;
|
const e404 = ErrorCode.getNotFound;
|
||||||
|
|
||||||
stream.abort = function() {
|
(stream: any).abort = function() {
|
||||||
if (_.isNil(readTarballStream) === false) {
|
if (_.isNil(readTarballStream) === false) {
|
||||||
readTarballStream.abort();
|
readTarballStream.abort();
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ class LocalStorage implements IStorage {
|
||||||
* @return {Function}
|
* @return {Function}
|
||||||
*/
|
*/
|
||||||
search(startKey: string, options: any) {
|
search(startKey: string, options: any) {
|
||||||
const stream = new UploadTarball({objectMode: true});
|
const stream = new ReadTarball({objectMode: true});
|
||||||
|
|
||||||
this._searchEachPackage((item, cb) => {
|
this._searchEachPackage((item, cb) => {
|
||||||
if (item.time > parseInt(startKey, 10)) {
|
if (item.time > parseInt(startKey, 10)) {
|
||||||
|
@ -800,7 +800,7 @@ class LocalStorage implements IStorage {
|
||||||
return this.localData.setSecret(config.checkSecretKey(secretKey));
|
return this.localData.setSecret(config.checkSecretKey(secretKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadStorage(config: Config, logger: Logger) {
|
_loadStorage(config: Config, logger: Logger): ILocalData {
|
||||||
const Storage = this._loadStorePlugin();
|
const Storage = this._loadStorePlugin();
|
||||||
|
|
||||||
if (_.isNil(Storage)) {
|
if (_.isNil(Storage)) {
|
||||||
|
@ -811,13 +811,13 @@ class LocalStorage implements IStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadStorePlugin() {
|
_loadStorePlugin(): ILocalData {
|
||||||
const plugin_params = {
|
const plugin_params = {
|
||||||
config: this.config,
|
config: this.config,
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
};
|
};
|
||||||
|
|
||||||
return _.head(loadPlugin(this.config, this.config.store, plugin_params, function(plugin) {
|
return _.head(loadPlugin(this.config, this.config.store, plugin_params, (plugin) => {
|
||||||
return plugin.getPackageStorage;
|
return plugin.getPackageStorage;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Path from 'path';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
import type {Config} from '@verdaccio/types';
|
import type {Config} from '@verdaccio/types';
|
||||||
|
import {MODULE_NOT_FOUND} from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires a module.
|
* Requires a module.
|
||||||
|
@ -14,7 +15,7 @@ function tryLoad(path: string) {
|
||||||
try {
|
try {
|
||||||
return require(path);
|
return require(path);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === 'MODULE_NOT_FOUND') {
|
if (err.code === MODULE_NOT_FOUND) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -44,8 +45,12 @@ function isES6(plugin) {
|
||||||
* @param {*} sanityCheck callback that check the shape that should fulfill the plugin
|
* @param {*} sanityCheck callback that check the shape that should fulfill the plugin
|
||||||
* @return {Array} list of plugins
|
* @return {Array} list of plugins
|
||||||
*/
|
*/
|
||||||
function loadPlugin(config: Config, pluginConfigs: any, params: any, sanityCheck: Function) {
|
export default function loadPlugin<T>(
|
||||||
return Object.keys(pluginConfigs || {}).map(function(pluginId) {
|
config: Config,
|
||||||
|
pluginConfigs: any = {},
|
||||||
|
params: any,
|
||||||
|
sanityCheck: Function): T[] {
|
||||||
|
return Object.keys(pluginConfigs).map((pluginId: string) => {
|
||||||
let plugin;
|
let plugin;
|
||||||
|
|
||||||
// try local plugins first
|
// try local plugins first
|
||||||
|
@ -79,7 +84,9 @@ function loadPlugin(config: Config, pluginConfigs: any, params: any, sanityCheck
|
||||||
throw Error('"' + pluginId + '" doesn\'t look like a valid plugin');
|
throw Error('"' + pluginId + '" doesn\'t look like a valid plugin');
|
||||||
}
|
}
|
||||||
/* eslint new-cap:off */
|
/* eslint new-cap:off */
|
||||||
plugin = isES6(plugin) ? new plugin.default(mergeConfig(config, pluginConfigs[pluginId]), params) : plugin(pluginConfigs[pluginId], params);
|
plugin = isES6(plugin)
|
||||||
|
? new plugin.default(mergeConfig(config, pluginConfigs[pluginId]), params)
|
||||||
|
: plugin(pluginConfigs[pluginId], params);
|
||||||
/* eslint new-cap:off */
|
/* eslint new-cap:off */
|
||||||
|
|
||||||
if (plugin === null || !sanityCheck(plugin)) {
|
if (plugin === null || !sanityCheck(plugin)) {
|
||||||
|
@ -90,5 +97,3 @@ function loadPlugin(config: Config, pluginConfigs: any, params: any, sanityCheck
|
||||||
return plugin;
|
return plugin;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export {loadPlugin};
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ class Storage implements IStorageHandler {
|
||||||
*/
|
*/
|
||||||
getTarball(name: string, filename: string) {
|
getTarball(name: string, filename: string) {
|
||||||
let readStream = new ReadTarball();
|
let readStream = new ReadTarball();
|
||||||
readStream.abort = function() {};
|
(readStream: any).abort = function() {};
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
|
|
|
@ -430,7 +430,7 @@ class ProxyStorage implements IProxy {
|
||||||
let current_length = 0;
|
let current_length = 0;
|
||||||
let expected_length;
|
let expected_length;
|
||||||
|
|
||||||
stream.abort = () => {};
|
(stream: any).abort = () => {};
|
||||||
const readStream = this.request({
|
const readStream = this.request({
|
||||||
uri_full: url,
|
uri_full: url,
|
||||||
encoding: null,
|
encoding: null,
|
||||||
|
|
|
@ -253,7 +253,7 @@ function parse_address(urlAddress: any) {
|
||||||
* Function filters out bad semver versions and sorts the array.
|
* Function filters out bad semver versions and sorts the array.
|
||||||
* @return {Array} sorted Array
|
* @return {Array} sorted Array
|
||||||
*/
|
*/
|
||||||
function semverSort(listVersions: Array<string>) {
|
function semverSort(listVersions: Array<string>): string[] {
|
||||||
return listVersions.filter(function(x) {
|
return listVersions.filter(function(x) {
|
||||||
if (!semver.parse(x, true)) {
|
if (!semver.parse(x, true)) {
|
||||||
Logger.logger.warn( {ver: x}, 'ignoring bad version @{ver}' );
|
Logger.logger.warn( {ver: x}, 'ignoring bad version @{ver}' );
|
||||||
|
@ -409,7 +409,7 @@ function fileExists(path: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortByName(packages: Array<any>) {
|
function sortByName(packages: Array<any>): string[] {
|
||||||
return packages.sort(function(a, b) {
|
return packages.sort(function(a, b) {
|
||||||
if (a.name < b.name) {
|
if (a.name < b.name) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
96
test/flow/plugins/auth/example.auth.plugin.js
Normal file
96
test/flow/plugins/auth/example.auth.plugin.js
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
// this file is not aim to be tested, just to check flow definitions
|
||||||
|
|
||||||
|
import Config from '../../../../src/lib/config';
|
||||||
|
import LoggerApi from '../../../../src/lib/logger';
|
||||||
|
|
||||||
|
import type {
|
||||||
|
Config as AppConfig,
|
||||||
|
PackageAccess,
|
||||||
|
IPluginAuth,
|
||||||
|
RemoteUser,
|
||||||
|
Logger,
|
||||||
|
PluginOptions
|
||||||
|
} from '@verdaccio/types';
|
||||||
|
|
||||||
|
class ExampleAuthPlugin implements IPluginAuth {
|
||||||
|
config: AppConfig;
|
||||||
|
logger: Logger;
|
||||||
|
|
||||||
|
constructor(config: AppConfig, options: PluginOptions) {
|
||||||
|
this.config = config;
|
||||||
|
this.logger = options.logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
adduser(user: string, password: string, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
authenticate(user: string, password: string, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
allow_access(user: RemoteUser, pkg: PackageAccess, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
allow_publish(user: RemoteUser, pkg: PackageAccess, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type SubTypePackageAccess = PackageAccess & {
|
||||||
|
sub?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExampleAuthCustomPlugin implements IPluginAuth {
|
||||||
|
config: AppConfig;
|
||||||
|
logger: Logger;
|
||||||
|
|
||||||
|
constructor(config: AppConfig, options: PluginOptions) {
|
||||||
|
this.config = config;
|
||||||
|
this.logger = options.logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
adduser(user: string, password: string, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
authenticate(user: string, password: string, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
allow_access(user: RemoteUser, pkg: SubTypePackageAccess, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
allow_publish(user: RemoteUser, pkg: SubTypePackageAccess, cb: verdaccio$Callback): void {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const config1: AppConfig = new Config({
|
||||||
|
storage: './storage',
|
||||||
|
self_path: '/home/sotrage'
|
||||||
|
});
|
||||||
|
|
||||||
|
const options: PluginOptions = {
|
||||||
|
config: config1,
|
||||||
|
logger: LoggerApi.logger.child()
|
||||||
|
}
|
||||||
|
|
||||||
|
const auth = new ExampleAuthPlugin(config1, options);
|
||||||
|
const authSub = new ExampleAuthCustomPlugin(config1, options);
|
||||||
|
const remoteUser: RemoteUser = {
|
||||||
|
groups: [],
|
||||||
|
real_groups: [],
|
||||||
|
name: 'test'
|
||||||
|
};
|
||||||
|
|
||||||
|
auth.authenticate('user', 'pass', () => {});
|
||||||
|
auth.allow_access(remoteUser, {}, () => {});
|
||||||
|
auth.allow_publish(remoteUser, {}, () => {});
|
||||||
|
authSub.authenticate('user', 'pass', () => {});
|
||||||
|
authSub.allow_access(remoteUser, {sub: true}, () => {});
|
||||||
|
authSub.allow_publish(remoteUser, {sub: true}, () => {});
|
50
test/flow/plugins/middleware/example.middleware.plugin.js
Normal file
50
test/flow/plugins/middleware/example.middleware.plugin.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
// this file is not aim to be tested, just to check flow definitions
|
||||||
|
import Config from '../../../../src/lib/config';
|
||||||
|
import {generatePackageTemplate} from '../../../../src/lib/storage-utils';
|
||||||
|
import {readFile} from '../../../functional/lib/test.utils';
|
||||||
|
|
||||||
|
const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`);
|
||||||
|
|
||||||
|
import type {
|
||||||
|
Config as AppConfig,
|
||||||
|
IPluginMiddleware,
|
||||||
|
IStorageManager,
|
||||||
|
RemoteUser,
|
||||||
|
IBasicAuth,
|
||||||
|
} from '@verdaccio/types';
|
||||||
|
import type { IUploadTarball, IReadTarball } from '@verdaccio/streams';
|
||||||
|
|
||||||
|
export default class ExampleMiddlewarePlugin implements IPluginMiddleware {
|
||||||
|
register_middlewares(app: any, auth: IBasicAuth, storage: IStorageManager): void {
|
||||||
|
const remoteUser: RemoteUser = {
|
||||||
|
groups: [],
|
||||||
|
real_groups: [],
|
||||||
|
name: 'test'
|
||||||
|
};
|
||||||
|
auth.authenticate('user', 'password', () => {});
|
||||||
|
auth.allow_access('packageName', remoteUser, () => {});
|
||||||
|
auth.add_user('user', 'password', () => {});
|
||||||
|
auth.aesEncrypt(new Buffer('pass'));
|
||||||
|
// storage
|
||||||
|
storage.addPackage('name', generatePackageTemplate('test'), () => {});
|
||||||
|
storage.addVersion('name', 'version', readMetadata(), 'tag', () => {});
|
||||||
|
storage.mergeTags('name', {'latest': '1.0.0'}, () => {});
|
||||||
|
storage.changePackage('name', readMetadata(), 'revision', () => {});
|
||||||
|
storage.removePackage('name', () => {});
|
||||||
|
storage.mergeTags('name', {'latest': '1.0.0'}, () => {});
|
||||||
|
storage.removeTarball('name', 'filename', 'revision', () => {});
|
||||||
|
/* eslint no-unused-vars: 0 */
|
||||||
|
const config1: AppConfig = new Config({
|
||||||
|
storage: './storage',
|
||||||
|
self_path: '/home/sotrage'
|
||||||
|
});
|
||||||
|
const add: IUploadTarball = storage.addTarball('name', 'filename');
|
||||||
|
storage.getTarball('name', 'filename');
|
||||||
|
const read: IReadTarball = storage.getTarball('name', 'filename');
|
||||||
|
const search: IReadTarball = storage.search('test');
|
||||||
|
/* eslint no-unused-vars: 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
0
test/flow/plugins/partials/config.example.js
Normal file
0
test/flow/plugins/partials/config.example.js
Normal file
139
test/flow/plugins/storage/example.storage.plugin.js
Normal file
139
test/flow/plugins/storage/example.storage.plugin.js
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
// this file is not aim to be tested, just to check flow definitions
|
||||||
|
|
||||||
|
import Config from '../../../../src/lib/config';
|
||||||
|
import LoggerApi from '../../../../src/lib/logger';
|
||||||
|
import {generatePackageTemplate} from '../../../../src/lib/storage-utils';
|
||||||
|
import { UploadTarball, ReadTarball } from '@verdaccio/streams';
|
||||||
|
|
||||||
|
import type {
|
||||||
|
Callback,
|
||||||
|
Config as AppConfig,
|
||||||
|
Logger,
|
||||||
|
Package,
|
||||||
|
// PluginOptions
|
||||||
|
} from '@verdaccio/types';
|
||||||
|
|
||||||
|
import type {
|
||||||
|
IPluginStorage,
|
||||||
|
IPackageStorageManager,
|
||||||
|
IPackageStorage
|
||||||
|
} from '@verdaccio/local-storage';
|
||||||
|
import type { IUploadTarball, IReadTarball } from '@verdaccio/streams';
|
||||||
|
|
||||||
|
class PackageStorage implements IPackageStorageManager {
|
||||||
|
path: string;
|
||||||
|
logger: Logger;
|
||||||
|
|
||||||
|
constructor(path: string, logger: Logger) {
|
||||||
|
this.path = path;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePackage(name: string, updateHandler: Callback,
|
||||||
|
onWrite: Callback,
|
||||||
|
transformPackage: Function,
|
||||||
|
onEnd: Callback) {
|
||||||
|
onEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
deletePackage(fileName: string, callback: Callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
removePackage(callback: Callback): void {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
createPackage(name: string, value: Package, cb: Callback) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
savePackage(name: string, value: Package, cb: Callback) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
readPackage(name: string, cb: Callback) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
writeTarball(name: string): IUploadTarball {
|
||||||
|
const uploadStream = new UploadTarball();
|
||||||
|
|
||||||
|
return uploadStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
readTarball(name: string): IReadTarball {
|
||||||
|
const readTarballStream: IReadTarball = new ReadTarball();
|
||||||
|
|
||||||
|
return readTarballStream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExampleStoragePlugin implements IPluginStorage {
|
||||||
|
logger: Logger;
|
||||||
|
config: AppConfig;
|
||||||
|
|
||||||
|
constructor(config: AppConfig, logger: Logger) {
|
||||||
|
this.config = config;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSecret(): Promise<any> {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
setSecret(secret: string): Promise<any> {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
add(name: string, cb: Callback) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
remove(name: string, cb: Callback) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
get(cb: Callback) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
getPackageStorage(packageInfo: string): IPackageStorage {
|
||||||
|
return new PackageStorage(packageInfo, this.logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
search(onPackage: Callback, onEnd: Callback, validateName: any): void {
|
||||||
|
onPackage(onEnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ExampleStoragePlugin;
|
||||||
|
|
||||||
|
const config1: AppConfig = new Config({
|
||||||
|
storage: './storage',
|
||||||
|
self_path: '/home/sotrage'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const storage = new ExampleStoragePlugin(config1, LoggerApi.logger.child());
|
||||||
|
|
||||||
|
storage.add('test', () => {});
|
||||||
|
storage.remove('test', () => {});
|
||||||
|
storage.getSecret().then(() => {});
|
||||||
|
storage.setSecret('newSecret').then(() => {});
|
||||||
|
storage.search(() => {}, () => {}, 'validateName');
|
||||||
|
storage.get(() => {});
|
||||||
|
|
||||||
|
const storageManager: IPackageStorage = storage.getPackageStorage('test');
|
||||||
|
|
||||||
|
if (storageManager) {
|
||||||
|
storageManager.createPackage('test', generatePackageTemplate('test'), () => {});
|
||||||
|
storageManager.savePackage('fileName', generatePackageTemplate('test'), () => {});
|
||||||
|
storageManager.updatePackage('pkgFileName', () =>{}, () => {}, () => {}, () => {});
|
||||||
|
storageManager.deletePackage('test', () => {});
|
||||||
|
storageManager.removePackage(() => {});
|
||||||
|
storageManager.readPackage('test', () => {});
|
||||||
|
storageManager.writeTarball('test');
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {loadPlugin} from '../../../src/lib/plugin-loader';
|
import loadPlugin from '../../../src/lib/plugin-loader';
|
||||||
import logger from '../../../src/lib/logger';
|
import logger from '../../../src/lib/logger';
|
||||||
|
|
||||||
logger.setup([]);
|
logger.setup([]);
|
||||||
|
|
139
types/index.js
139
types/index.js
|
@ -1,36 +1,76 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
|
IBasicAuth,
|
||||||
|
IBasicStorage,
|
||||||
|
IStorageManager,
|
||||||
UpLinkConf,
|
UpLinkConf,
|
||||||
Callback,
|
Callback,
|
||||||
Versions,
|
Versions,
|
||||||
Version,
|
Version,
|
||||||
MergeTags,
|
|
||||||
Config,
|
Config,
|
||||||
Logger,
|
Logger,
|
||||||
PackageAccess,
|
PackageAccess,
|
||||||
|
StringValue as verdaccio$StringValue,
|
||||||
Package} from '@verdaccio/types';
|
Package} from '@verdaccio/types';
|
||||||
import type {
|
import type {
|
||||||
IUploadTarball,
|
|
||||||
IReadTarball,
|
IReadTarball,
|
||||||
} from '@verdaccio/streams';
|
} from '@verdaccio/streams';
|
||||||
import type {ILocalData} from '@verdaccio/local-storage';
|
import type {ILocalData} from '@verdaccio/local-storage';
|
||||||
import type {NextFunction, $Request, $Response} from 'request';
|
import type {NextFunction, $Request, $Response} from 'request';
|
||||||
|
|
||||||
export type StringValue = string | void | null;
|
export type StringValue = verdaccio$StringValue;
|
||||||
|
|
||||||
export interface IAuth {
|
export type StartUpConfig = {
|
||||||
config: Config;
|
storage: string;
|
||||||
logger: Logger;
|
self_path: string;
|
||||||
secret: string;
|
}
|
||||||
plugins: Array<any>;
|
|
||||||
aesEncrypt(buf: Buffer): Buffer;
|
export type MatchedPackage = PackageAccess | void;
|
||||||
|
|
||||||
|
export type JWTPayload = {
|
||||||
|
user: string;
|
||||||
|
group: string | void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type JWTSignOptions = {
|
||||||
|
expiresIn: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ProxyList = {
|
||||||
|
[key: string]: IProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Utils = {
|
||||||
|
ErrorCode: any;
|
||||||
|
getLatestVersion: Callback;
|
||||||
|
isObject: (value: any) => boolean;
|
||||||
|
validate_name: (value: any) => boolean;
|
||||||
|
tag_version: (value: any, version: string, tag: string) => void;
|
||||||
|
normalizeDistTags: (pkg: Package) => void;
|
||||||
|
semverSort: (keys: Array<string>) => Array<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type $RequestExtend = $Request & {remote_user?: any}
|
||||||
|
export type $ResponseExtend = $Response & {cookies?: any}
|
||||||
|
export type $NextFunctionVer = NextFunction & mixed;
|
||||||
|
export type $SidebarPackage = Package & {latest: mixed}
|
||||||
|
|
||||||
|
|
||||||
|
interface IAuthWebUI {
|
||||||
|
issueUIjwt(user: string, time: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IAuthMiddleware {
|
||||||
apiJWTmiddleware(): $NextFunctionVer;
|
apiJWTmiddleware(): $NextFunctionVer;
|
||||||
webUIJWTmiddleware(): $NextFunctionVer;
|
webUIJWTmiddleware(): $NextFunctionVer;
|
||||||
authenticate(user: string, password: string, cb: Callback): void;
|
}
|
||||||
allow_access(packageName: string, user: string, callback: Callback): void;
|
|
||||||
issueUIjwt(user: string, time: string): string;
|
export interface IAuth extends IBasicAuth, IAuthMiddleware, IAuthWebUI {
|
||||||
add_user(user: string, password: string, cb: Callback): any;
|
config: verdaccio$Config;
|
||||||
|
logger: verdaccio$Logger;
|
||||||
|
secret: string;
|
||||||
|
plugins: Array<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IWebSearch {
|
export interface IWebSearch {
|
||||||
|
@ -61,76 +101,15 @@ export interface IProxy {
|
||||||
getRemoteMetadata(name: string, options: any, callback: Callback): void;
|
getRemoteMetadata(name: string, options: any, callback: Callback): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ProxyList = {
|
export interface IStorage extends IBasicStorage {
|
||||||
[key: string]: IProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Utils = {
|
|
||||||
ErrorCode: any;
|
|
||||||
getLatestVersion: Callback;
|
|
||||||
isObject: (value: any) => boolean;
|
|
||||||
validate_name: (value: any) => boolean;
|
|
||||||
tag_version: (value: any, version: string, tag: string) => void;
|
|
||||||
normalizeDistTags: (pkg: Package) => void;
|
|
||||||
semverSort: (keys: Array<string>) => Array<string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IStorageHandler {
|
|
||||||
config: Config;
|
|
||||||
localStorage: IStorage;
|
|
||||||
logger: Logger;
|
|
||||||
uplinks: ProxyList;
|
|
||||||
addPackage(name: string, metadata: any, callback: Function): Promise<any>;
|
|
||||||
init(config: Config): Promise<any>;
|
|
||||||
addVersion(name: string, version: string, metadata: Version, tag: StringValue, callback: Callback): void;
|
|
||||||
mergeTags(name: string, tagHash: MergeTags, callback: Callback): void;
|
|
||||||
changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
|
|
||||||
removePackage(name: string, callback: Callback): void;
|
|
||||||
removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
|
|
||||||
addTarball(name: string, filename: string): IUploadTarball;
|
|
||||||
getTarball(name: string, filename: string): IReadTarball;
|
|
||||||
getPackage(options: any): void;
|
|
||||||
search(startkey: string, options: any): void;
|
|
||||||
getLocalDatabase(callback: Callback): void;
|
|
||||||
_syncUplinksMetadata(name: string, packageInfo: Package, options: any, callback: Callback): void;
|
|
||||||
_updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type StartUpConfig = {
|
|
||||||
storage: string;
|
|
||||||
self_path: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type MatchedPackage = PackageAccess | void;
|
|
||||||
|
|
||||||
export interface IStorage {
|
|
||||||
config: Config;
|
config: Config;
|
||||||
localData: ILocalData;
|
localData: ILocalData;
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
addPackage(name: string, info: Package, callback: Callback): void;
|
|
||||||
removePackage(name: string, callback: Callback): void;
|
|
||||||
updateVersions(name: string, packageInfo: Package, callback: Callback): void;
|
|
||||||
addVersion(name: string, version: string, metadata: Version, tag: StringValue, callback: Callback): void;
|
|
||||||
mergeTags(name: string, tags: MergeTags, callback: Callback): void;
|
|
||||||
changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
|
|
||||||
removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
|
|
||||||
addTarball(name: string, filename: string): IUploadTarball;
|
|
||||||
getTarball(name: string, filename: string): IReadTarball;
|
|
||||||
getPackageMetadata(name: string, callback: Callback): void;
|
|
||||||
search(startKey: string, options: any): IUploadTarball;
|
|
||||||
getSecret(config: Config): Promise<any>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type JWTPayload = {
|
export interface IStorageHandler extends IStorageManager {
|
||||||
user: string;
|
localStorage: IStorage;
|
||||||
group: string | void;
|
uplinks: ProxyList;
|
||||||
|
_syncUplinksMetadata(name: string, packageInfo: Package, options: any, callback: Callback): void;
|
||||||
|
_updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type JWTSignOptions = {
|
|
||||||
expiresIn: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type $RequestExtend = $Request & {remote_user?: any}
|
|
||||||
export type $ResponseExtend = $Response & {cookies?: any}
|
|
||||||
export type $NextFunctionVer = NextFunction & mixed;
|
|
||||||
export type $SidebarPackage = Package & {latest: mixed}
|
|
||||||
|
|
18
yarn.lock
18
yarn.lock
|
@ -219,9 +219,9 @@
|
||||||
lockfile "1.0.3"
|
lockfile "1.0.3"
|
||||||
lodash "4.17.10"
|
lodash "4.17.10"
|
||||||
|
|
||||||
"@verdaccio/local-storage@1.1.2":
|
"@verdaccio/local-storage@1.1.3":
|
||||||
version "1.1.2"
|
version "1.1.3"
|
||||||
resolved "https://registry.npmjs.org/@verdaccio/local-storage/-/local-storage-1.1.2.tgz#938f1da741d148db020bbe68bfb21e86d38e3177"
|
resolved "https://registry.npmjs.org/@verdaccio/local-storage/-/local-storage-1.1.3.tgz#2c1e5b830f69a6ade5a855aea581f3ba96a37cfd"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@verdaccio/file-locking" "0.0.7"
|
"@verdaccio/file-locking" "0.0.7"
|
||||||
"@verdaccio/streams" "1.0.0"
|
"@verdaccio/streams" "1.0.0"
|
||||||
|
@ -234,9 +234,9 @@
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.npmjs.org/@verdaccio/streams/-/streams-1.0.0.tgz#d5d24c6747208728b9fd16b908e3932c3fb1f864"
|
resolved "https://registry.npmjs.org/@verdaccio/streams/-/streams-1.0.0.tgz#d5d24c6747208728b9fd16b908e3932c3fb1f864"
|
||||||
|
|
||||||
"@verdaccio/types@3.0.1":
|
"@verdaccio/types@3.4.1":
|
||||||
version "3.0.1"
|
version "3.4.1"
|
||||||
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-3.0.1.tgz#8cdfd74a8a070ad797a056652f257f9ead3717f9"
|
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-3.4.1.tgz#be18fb695bcd014c94c89b7805ace36dc9da2636"
|
||||||
|
|
||||||
"@webassemblyjs/ast@1.5.9":
|
"@webassemblyjs/ast@1.5.9":
|
||||||
version "1.5.9"
|
version "1.5.9"
|
||||||
|
@ -3833,9 +3833,9 @@ flatten@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.npmjs.org/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
|
resolved "https://registry.npmjs.org/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
|
||||||
|
|
||||||
flow-bin@0.69.0:
|
flow-bin@0.76.0:
|
||||||
version "0.69.0"
|
version "0.76.0"
|
||||||
resolved "https://registry.npmjs.org/flow-bin/-/flow-bin-0.69.0.tgz#053159a684a6051fcbf0b71a2eb19a9679082da6"
|
resolved "https://registry.npmjs.org/flow-bin/-/flow-bin-0.76.0.tgz#eb00036991c3abc106743fcbc7ee321f02aa4faa"
|
||||||
|
|
||||||
flow-config-parser@^0.3.0:
|
flow-config-parser@^0.3.0:
|
||||||
version "0.3.0"
|
version "0.3.0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue