2019-07-16 01:40:01 -05:00
|
|
|
import {
|
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,
|
2019-09-07 17:46:50 -05:00
|
|
|
IPluginStorage,
|
2019-08-10 06:38:06 -05:00
|
|
|
StringValue as verdaccio$StringValue,
|
|
|
|
IReadTarball,
|
|
|
|
Package,
|
|
|
|
IPluginStorageFilter,
|
|
|
|
Author,
|
2019-09-07 17:46:50 -05:00
|
|
|
AuthPluginPackage,
|
|
|
|
Token,
|
|
|
|
ITokenActions,
|
|
|
|
TokenFilter
|
2019-08-10 06:38:06 -05:00
|
|
|
} from '@verdaccio/types';
|
2018-08-17 05:14:23 -05:00
|
|
|
import lunrMutable from 'lunr-mutable-indexes';
|
2019-07-16 01:40:01 -05:00
|
|
|
import {NextFunction, Request, Response} from 'express';
|
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
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface StartUpConfig {
|
2018-07-15 16:23:14 -05:00
|
|
|
storage: string;
|
2018-07-18 07:53:08 -05:00
|
|
|
plugins?: string;
|
2018-07-15 16:23:14 -05:00
|
|
|
self_path: string;
|
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
// legacy should be removed in long term
|
|
|
|
|
|
|
|
export interface LegacyPackageList {
|
2020-03-08 16:30:14 -05:00
|
|
|
[key: string]: PackageAccessAddOn;
|
2019-07-16 01:40:01 -05:00
|
|
|
}
|
|
|
|
|
2020-03-08 16:30:14 -05:00
|
|
|
export type PackageAccessAddOn = PackageAccess & {
|
2019-07-16 01:40:01 -05:00
|
|
|
// FIXME: should be published on @verdaccio/types
|
|
|
|
unpublish?: string[];
|
|
|
|
}
|
|
|
|
|
2018-07-15 16:23:14 -05:00
|
|
|
export type MatchedPackage = PackageAccess | void;
|
|
|
|
|
2018-08-21 01:05:34 -05:00
|
|
|
export type JWTPayload = RemoteUser & {
|
|
|
|
password?: string;
|
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface 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
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface AuthTokenHeader {
|
2018-08-21 01:05:34 -05:00
|
|
|
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;
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface ProxyList {
|
2018-07-15 16:23:14 -05:00
|
|
|
[key: string]: IProxy;
|
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface CookieSessionToken {
|
2018-08-21 01:05:34 -05:00
|
|
|
expires: Date;
|
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface Utils {
|
2018-07-15 16:23:14 -05: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;
|
2019-07-16 01:40:01 -05:00
|
|
|
semverSort: (keys: string[]) => string[];
|
2018-07-15 16:23:14 -05:00
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface Profile {
|
2018-10-12 04:07:55 -05:00
|
|
|
tfa: boolean;
|
|
|
|
name: string;
|
|
|
|
email: string;
|
|
|
|
email_verified: string;
|
|
|
|
created: string;
|
|
|
|
updated: string;
|
|
|
|
cidr_whitelist: any;
|
|
|
|
fullname: string;
|
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export type $RequestExtend = Request & {remote_user?: any; log: Logger}
|
|
|
|
export type $ResponseExtend = Response & {cookies?: any}
|
|
|
|
export type $NextFunctionVer = NextFunction & any;
|
|
|
|
export type $SidebarPackage = Package & {latest: any}
|
2018-07-15 16:23:14 -05:00
|
|
|
|
2018-08-21 01:05:34 -05:00
|
|
|
export interface IAuthWebUI {
|
2019-07-16 01:40:01 -05:00
|
|
|
jwtEncrypt(user: RemoteUser, signOptions: JWTSignOptions): Promise<string>;
|
2018-08-21 01:05:34 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface IAuth extends IBasicAuth<Config>, IAuthMiddleware, IAuthWebUI {
|
|
|
|
config: Config;
|
|
|
|
logger: Logger;
|
2018-07-15 12:26:58 -05:00
|
|
|
secret: string;
|
2019-07-16 01:40:01 -05:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
plugins: any[];
|
2019-08-10 06:38:06 -05:00
|
|
|
allow_unpublish(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
|
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;
|
2019-07-16 01:40:01 -05:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2018-04-30 11:34:55 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
// FIXME: This prop should be on @verdaccio/types
|
|
|
|
export type UpLinkConfLocal = UpLinkConf & {
|
|
|
|
no_proxy?: string;
|
|
|
|
};
|
|
|
|
|
2018-02-26 15:28:09 -05:00
|
|
|
export interface IProxy {
|
2019-07-16 01:40:01 -05:00
|
|
|
config: UpLinkConfLocal;
|
2018-04-30 11:34:55 -05:00
|
|
|
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;
|
2019-07-16 01:40:01 -05:00
|
|
|
search(options: any);
|
2018-04-30 11:34:55 -05:00
|
|
|
getRemoteMetadata(name: string, options: any, callback: Callback): void;
|
2018-02-26 15:28:09 -05:00
|
|
|
}
|
|
|
|
|
2019-09-07 17:46:50 -05:00
|
|
|
export interface IStorage extends IBasicStorage<Config>, ITokenActions {
|
2018-04-30 11:34:55 -05:00
|
|
|
config: Config;
|
2019-09-07 17:46:50 -05:00
|
|
|
storagePlugin: IPluginStorage<Config>;
|
2018-04-30 11:34:55 -05:00
|
|
|
logger: Logger;
|
2018-02-26 15:28:09 -05:00
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface IGetPackageOptions {
|
2018-11-22 07:39:39 -05:00
|
|
|
callback: Callback;
|
|
|
|
name: string;
|
|
|
|
keepUpLinkData: boolean;
|
|
|
|
uplinksLook: boolean;
|
|
|
|
req: any;
|
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface ISyncUplinks {
|
2018-11-22 07:39:39 -05:00
|
|
|
uplinksLook?: boolean;
|
|
|
|
etag?: string;
|
2019-07-16 01:40:01 -05:00
|
|
|
req?: Request;
|
2018-11-22 07:39:39 -05:00
|
|
|
}
|
|
|
|
|
2019-07-16 01:40:01 -05:00
|
|
|
export type IPluginFilters = IPluginStorageFilter<Config>[];
|
|
|
|
|
2019-09-07 17:46:50 -05:00
|
|
|
export interface IStorageHandler extends IStorageManager<Config>, ITokenActions {
|
2019-07-16 01:40:01 -05:00
|
|
|
config: Config;
|
|
|
|
localStorage: IStorage | null;
|
|
|
|
filters: IPluginFilters;
|
2018-07-15 16:23:14 -05:00
|
|
|
uplinks: ProxyList;
|
2019-07-16 01:40:01 -05:00
|
|
|
init(config: Config, filters: IPluginFilters): Promise<string>;
|
2019-09-07 17:46:50 -05:00
|
|
|
saveToken(token: Token): Promise<any>;
|
|
|
|
deleteToken(user: string, tokenKey: string): Promise<any>;
|
2019-09-26 11:22:14 -05:00
|
|
|
readTokens(filter: TokenFilter): Promise<Token[]>;
|
2018-07-15 16:23:14 -05:00
|
|
|
_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]
|
|
|
|
*/
|
2019-07-16 01:40:01 -05:00
|
|
|
export interface Styles {
|
|
|
|
[ruleOrSelector: string]: string | number | Styles;
|
2021-03-14 02:42:46 -05:00
|
|
|
}
|
2019-07-16 01:40:01 -05:00
|
|
|
|
|
|
|
export type AuthorAvatar = Author & { avatar?: string };
|
|
|
|
|