2018-02-26 15:28:09 -05:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import type {
|
2018-07-15 12:26:58 -05:00
|
|
|
IBasicAuth,
|
|
|
|
IBasicStorage,
|
2018-07-15 16:23:14 -05:00
|
|
|
IStorageManager,
|
2018-04-30 11:34:55 -05:00
|
|
|
UpLinkConf,
|
|
|
|
Callback,
|
|
|
|
Versions,
|
|
|
|
Version,
|
2018-08-21 01:05:34 -05:00
|
|
|
RemoteUser,
|
2018-04-30 11:34:55 -05:00
|
|
|
Config,
|
|
|
|
Logger,
|
2018-08-21 01:05:34 -05:00
|
|
|
JWTSignOptions,
|
2018-07-02 01:24:45 -05:00
|
|
|
PackageAccess,
|
2018-07-15 12:26:58 -05:00
|
|
|
StringValue as verdaccio$StringValue,
|
2018-04-30 11:34:55 -05:00
|
|
|
Package} from '@verdaccio/types';
|
2018-02-26 15:28:09 -05:00
|
|
|
import type {
|
2018-04-30 11:34:55 -05:00
|
|
|
IReadTarball,
|
2018-02-26 15:28:09 -05:00
|
|
|
} from '@verdaccio/streams';
|
|
|
|
import type {ILocalData} from '@verdaccio/local-storage';
|
2018-08-17 05:14:23 -05:00
|
|
|
import lunrMutable from 'lunr-mutable-indexes';
|
2018-03-02 17:19:08 -05:00
|
|
|
import type {NextFunction, $Request, $Response} from 'request';
|
2018-02-26 15:28:09 -05:00
|
|
|
|
2018-07-15 12:26:58 -05:00
|
|
|
export type StringValue = verdaccio$StringValue;
|
2018-03-17 05:54:57 -05:00
|
|
|
|
2018-07-15 16:23:14 -05:00
|
|
|
export type StartUpConfig = {
|
|
|
|
storage: string;
|
2018-07-18 07:53:08 -05:00
|
|
|
plugins?: string;
|
2018-07-15 16:23:14 -05:00
|
|
|
self_path: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type MatchedPackage = PackageAccess | void;
|
|
|
|
|
2018-08-21 01:05:34 -05:00
|
|
|
export type JWTPayload = RemoteUser & {
|
|
|
|
password?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type AESPayload = {
|
2018-07-15 16:23:14 -05:00
|
|
|
user: string;
|
2018-08-21 01:05:34 -05:00
|
|
|
password: string;
|
2018-07-15 16:23:14 -05:00
|
|
|
}
|
|
|
|
|
2018-08-21 01:05:34 -05:00
|
|
|
export type AuthTokenHeader = {
|
|
|
|
scheme: string;
|
|
|
|
token: string;
|
2018-07-15 16:23:14 -05:00
|
|
|
}
|
|
|
|
|
2018-08-21 01:05:34 -05:00
|
|
|
export type BasicPayload = AESPayload | void;
|
|
|
|
export type AuthMiddlewarePayload = RemoteUser | BasicPayload;
|
|
|
|
|
2018-07-15 16:23:14 -05:00
|
|
|
export type ProxyList = {
|
|
|
|
[key: string]: IProxy;
|
|
|
|
}
|
|
|
|
|
2018-08-21 01:05:34 -05:00
|
|
|
export type CookieSessionToken = {
|
|
|
|
expires: Date;
|
|
|
|
}
|
|
|
|
|
2018-07-15 16:23:14 -05:00
|
|
|
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>;
|
|
|
|
}
|
|
|
|
|
2018-10-12 04:07:55 -05:00
|
|
|
export type Profile = {
|
|
|
|
tfa: boolean;
|
|
|
|
name: string;
|
|
|
|
email: string;
|
|
|
|
email_verified: string;
|
|
|
|
created: string;
|
|
|
|
updated: string;
|
|
|
|
cidr_whitelist: any;
|
|
|
|
fullname: string;
|
|
|
|
}
|
|
|
|
|
2018-07-15 16:23:14 -05:00
|
|
|
export type $RequestExtend = $Request & {remote_user?: any}
|
|
|
|
export type $ResponseExtend = $Response & {cookies?: any}
|
|
|
|
export type $NextFunctionVer = NextFunction & mixed;
|
|
|
|
export type $SidebarPackage = Package & {latest: mixed}
|
|
|
|
|
|
|
|
|
2018-08-21 01:05:34 -05:00
|
|
|
export interface IAuthWebUI {
|
|
|
|
jwtEncrypt(user: RemoteUser, signOptions: JWTSignOptions): string;
|
|
|
|
aesEncrypt(buf: Buffer): Buffer;
|
2018-07-15 12:26:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IAuthMiddleware {
|
2018-04-30 11:34:55 -05:00
|
|
|
apiJWTmiddleware(): $NextFunctionVer;
|
2018-04-30 08:13:54 -05:00
|
|
|
webUIJWTmiddleware(): $NextFunctionVer;
|
2018-07-15 12:26:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IAuth extends IBasicAuth, IAuthMiddleware, IAuthWebUI {
|
|
|
|
config: verdaccio$Config;
|
|
|
|
logger: verdaccio$Logger;
|
|
|
|
secret: string;
|
|
|
|
plugins: Array<any>;
|
2018-02-26 15:28:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IWebSearch {
|
2018-08-17 05:14:23 -05:00
|
|
|
index: lunrMutable.index;
|
2018-04-30 11:34:55 -05:00
|
|
|
storage: IStorageHandler;
|
|
|
|
query(query: string): any;
|
|
|
|
add(pkg: Version): void;
|
|
|
|
remove(name: string): void;
|
|
|
|
reindex(): void;
|
|
|
|
configureStorage(storage: IStorageHandler): void;
|
2018-02-26 15:28:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IProxy {
|
2018-04-30 11:34:55 -05: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 15:28:09 -05:00
|
|
|
}
|
|
|
|
|
2018-07-15 12:26:58 -05:00
|
|
|
export interface IStorage extends IBasicStorage {
|
2018-04-30 11:34:55 -05:00
|
|
|
config: Config;
|
|
|
|
localData: ILocalData;
|
|
|
|
logger: Logger;
|
2018-02-26 15:28:09 -05:00
|
|
|
}
|
|
|
|
|
2018-11-22 07:39:39 -05:00
|
|
|
export type IGetPackageOptions = {
|
|
|
|
callback: Callback;
|
|
|
|
name: string;
|
|
|
|
keepUpLinkData: boolean;
|
|
|
|
uplinksLook: boolean;
|
|
|
|
req: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type ISyncUplinks = {
|
|
|
|
uplinksLook?: boolean;
|
|
|
|
etag?: string;
|
|
|
|
}
|
|
|
|
|
2018-07-15 16:23:14 -05:00
|
|
|
export interface IStorageHandler extends IStorageManager {
|
|
|
|
localStorage: IStorage;
|
|
|
|
uplinks: ProxyList;
|
|
|
|
_syncUplinksMetadata(name: string, packageInfo: Package, options: any, callback: Callback): void;
|
|
|
|
_updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void;
|
2018-06-03 01:51:18 -05:00
|
|
|
}
|
2018-12-13 13:05:47 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @property { string | number | Styles } [ruleOrSelector]
|
|
|
|
*/
|
|
|
|
export type Styles = {
|
|
|
|
[ruleOrSelector: string]: string | number | Styles,
|
|
|
|
};
|