2018-02-26 21:28:09 +01:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import type {
|
2018-04-30 18:34:55 +02:00
|
|
|
UpLinkConf,
|
|
|
|
Callback,
|
|
|
|
Versions,
|
|
|
|
Version,
|
|
|
|
MergeTags,
|
|
|
|
Config,
|
|
|
|
Logger,
|
2018-07-02 08:24:45 +02:00
|
|
|
PackageAccess,
|
2018-04-30 18:34:55 +02:00
|
|
|
Package} from '@verdaccio/types';
|
2018-02-26 21:28:09 +01:00
|
|
|
import type {
|
2018-04-30 18:34:55 +02:00
|
|
|
IUploadTarball,
|
|
|
|
IReadTarball,
|
2018-02-26 21:28:09 +01:00
|
|
|
} from '@verdaccio/streams';
|
|
|
|
import type {ILocalData} from '@verdaccio/local-storage';
|
2018-03-02 23:19:08 +01:00
|
|
|
import type {NextFunction, $Request, $Response} from 'request';
|
2018-02-26 21:28:09 +01:00
|
|
|
|
2018-03-17 11:54:57 +01:00
|
|
|
export type StringValue = string | void | null;
|
|
|
|
|
2018-02-26 21:28:09 +01:00
|
|
|
export interface IAuth {
|
2018-04-30 18:34:55 +02:00
|
|
|
config: Config;
|
|
|
|
logger: Logger;
|
|
|
|
secret: string;
|
|
|
|
plugins: Array<any>;
|
2018-06-01 22:17:01 +02:00
|
|
|
aesEncrypt(buf: Buffer): Buffer;
|
2018-04-30 18:34:55 +02:00
|
|
|
apiJWTmiddleware(): $NextFunctionVer;
|
2018-04-30 15:13:54 +02:00
|
|
|
webUIJWTmiddleware(): $NextFunctionVer;
|
2018-04-30 18:34:55 +02:00
|
|
|
authenticate(user: string, password: string, cb: Callback): void;
|
|
|
|
allow_access(packageName: string, user: string, callback: Callback): void;
|
2018-04-30 15:13:54 +02:00
|
|
|
issueUIjwt(user: string, time: string): string;
|
2018-04-30 18:34:55 +02:00
|
|
|
add_user(user: string, password: string, cb: Callback): any;
|
2018-02-26 21:28:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IWebSearch {
|
2018-04-30 18:34:55 +02:00
|
|
|
index: any;
|
|
|
|
storage: IStorageHandler;
|
|
|
|
query(query: string): any;
|
|
|
|
add(pkg: Version): void;
|
|
|
|
remove(name: string): void;
|
|
|
|
reindex(): void;
|
|
|
|
configureStorage(storage: IStorageHandler): void;
|
2018-02-26 21:28:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IProxy {
|
2018-04-30 18:34:55 +02:00
|
|
|
config: UpLinkConf;
|
|
|
|
failed_requests: number;
|
|
|
|
userAgent: string;
|
|
|
|
ca?: string | void;
|
|
|
|
logger: Logger;
|
|
|
|
server_id: string;
|
|
|
|
url: any;
|
|
|
|
maxage: number;
|
|
|
|
timeout: number;
|
|
|
|
max_fails: number;
|
|
|
|
fail_timeout: number;
|
|
|
|
upname: string;
|
|
|
|
fetchTarball(url: string): IReadTarball;
|
|
|
|
isUplinkValid(url: string): boolean;
|
|
|
|
getRemoteMetadata(name: string, options: any, callback: Callback): void;
|
2018-02-26 21:28:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export type ProxyList = {
|
2018-04-30 18:34:55 +02:00
|
|
|
[key: string]: IProxy;
|
2018-02-26 21:28:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export type Utils = {
|
2018-04-30 18:34:55 +02:00
|
|
|
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>;
|
2018-02-26 21:28:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IStorageHandler {
|
2018-04-30 18:34:55 +02:00
|
|
|
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;
|
2018-02-26 21:28:09 +01:00
|
|
|
}
|
|
|
|
|
2018-07-02 08:24:45 +02:00
|
|
|
// export interface ConfigHandler {
|
|
|
|
// checkSecretKey(token: string): string;
|
|
|
|
// hasProxyTo(pkg: string, upLink: string): boolean;
|
|
|
|
// getMatchedPackagesSpec(storage: string): verdaccio$PackageAccess | void;
|
|
|
|
// [key: string]: number;
|
|
|
|
// }
|
|
|
|
|
|
|
|
export type StartUpConfig = {
|
|
|
|
storage: string;
|
|
|
|
self_path: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type MatchedPackage = PackageAccess | void;
|
|
|
|
|
2018-02-26 21:28:09 +01:00
|
|
|
export interface IStorage {
|
2018-04-30 18:34:55 +02:00
|
|
|
config: Config;
|
|
|
|
localData: ILocalData;
|
|
|
|
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;
|
2018-04-21 18:36:06 +02:00
|
|
|
getSecret(config: Config): Promise<any>;
|
2018-02-26 21:28:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-03 08:51:18 +02:00
|
|
|
export type JWTPayload = {
|
|
|
|
user: string;
|
|
|
|
group: string | void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type JWTSignOptions = {
|
|
|
|
expiresIn: string;
|
|
|
|
}
|
|
|
|
|
2018-03-02 23:19:08 +01:00
|
|
|
export type $RequestExtend = $Request & {remote_user?: any}
|
|
|
|
export type $ResponseExtend = $Response & {cookies?: any}
|
|
|
|
export type $NextFunctionVer = NextFunction & mixed;
|
2018-03-11 16:27:16 +01:00
|
|
|
export type $SidebarPackage = Package & {latest: mixed}
|