0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/types/index.ts

198 lines
4.6 KiB
TypeScript
Raw Normal View History

/* eslint-disable @typescript-eslint/interface-name-prefix */
import {
IBasicAuth,
IBasicStorage,
IStorageManager,
UpLinkConf,
Callback,
Versions,
Version,
RemoteUser,
Config,
Logger,
JWTSignOptions,
2018-07-02 01:24:45 -05:00
PackageAccess,
ILocalData,
StringValue as verdaccio$StringValue,
IReadTarball,
Package,
IPluginStorageFilter,
Author,
AuthPluginPackage
} from '@verdaccio/types';
import lunrMutable from 'lunr-mutable-indexes';
import {NextFunction, Request, Response} from 'express';
export type StringValue = verdaccio$StringValue;
export interface StartUpConfig {
storage: string;
plugins?: string;
self_path: string;
}
// legacy should be removed in long term
export interface LegacyPackageList {
[key: string]: LegacyPackageAccess;
}
export type LegacyPackageAccess = PackageAccess & {
allow_publish?: string[];
allow_proxy?: string[];
allow_access?: string[];
proxy_access?: string[];
// FIXME: should be published on @verdaccio/types
unpublish?: string[];
}
export type MatchedPackage = PackageAccess | void;
export type JWTPayload = RemoteUser & {
password?: string;
}
export interface AESPayload {
user: string;
password: string;
}
export interface AuthTokenHeader {
scheme: string;
token: string;
}
export type BasicPayload = AESPayload | void;
export type AuthMiddlewarePayload = RemoteUser | BasicPayload;
export interface ProxyList {
[key: string]: IProxy;
}
export interface CookieSessionToken {
expires: Date;
}
export interface 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: string[]) => string[];
}
export interface Profile {
tfa: boolean;
name: string;
email: string;
email_verified: string;
created: string;
updated: string;
cidr_whitelist: any;
fullname: string;
}
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}
export interface IAuthWebUI {
jwtEncrypt(user: RemoteUser, signOptions: JWTSignOptions): Promise<string>;
aesEncrypt(buf: Buffer): Buffer;
}
interface IAuthMiddleware {
apiJWTmiddleware(): $NextFunctionVer;
2018-04-30 08:13:54 -05:00
webUIJWTmiddleware(): $NextFunctionVer;
}
export interface IAuth extends IBasicAuth<Config>, IAuthMiddleware, IAuthWebUI {
config: Config;
logger: Logger;
secret: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
plugins: any[];
allow_unpublish(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
}
export interface IWebSearch {
index: lunrMutable.index;
storage: IStorageHandler;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
query(query: string): any;
add(pkg: Version): void;
remove(name: string): void;
reindex(): void;
configureStorage(storage: IStorageHandler): void;
}
// FIXME: This prop should be on @verdaccio/types
export type UpLinkConfLocal = UpLinkConf & {
no_proxy?: string;
};
export interface IProxy {
config: UpLinkConfLocal;
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;
search(options: any);
getRemoteMetadata(name: string, options: any, callback: Callback): void;
}
export interface IStorage extends IBasicStorage<Config> {
config: Config;
localData: ILocalData<Config>;
logger: Logger;
}
export interface IGetPackageOptions {
callback: Callback;
name: string;
keepUpLinkData: boolean;
uplinksLook: boolean;
req: any;
}
export interface ISyncUplinks {
uplinksLook?: boolean;
etag?: string;
req?: Request;
}
export type IPluginFilters = IPluginStorageFilter<Config>[];
export interface IStorageHandler extends IStorageManager<Config> {
config: Config;
localStorage: IStorage | null;
filters: IPluginFilters;
uplinks: ProxyList;
init(config: Config, filters: IPluginFilters): Promise<string>;
_syncUplinksMetadata(name: string, packageInfo: Package, options: any, callback: Callback): void;
_updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void;
2018-06-03 01:51:18 -05:00
}
Package Refactor (#1145) * chore: fix unit test, forgotten line on merge chore: add node 11 to circleci (#1153) chore: fix the use of Node 11 in CircleCI (#1154) refactor: added css in js, new design, added types feat: added Tag component refactor: added modifiers refactor: replaced by polished ellipsis refactor: added types, new design and css in js refactor: removed ul. it needs refactor refactor: changed media queries refactor: changed icon height refactor: changed Header media queries refactor: removed margin top refactor: updated snapshots refactor: removed unnecessary format author refactor: added license icon & changed size refactor: changed media queries refactor: added icon size refactor: changed media queries refactor: updated snap refactor: replaced Description by Details refactor: updated tests refactor: fixed modifiers type feat: created missed types fix: fixed types fix: fixed prop type fix: fixed undefined prop refactor: replaced label by name refactor: updated snap refactor: moved polished to dev refactor: changed formatAuthor and pkg author type fix: removed incorrect meta's type refactor: removed polished refactor: added spacing & ellipsis mixin refactor: added modifier type refactor: changed datetime format refactor: updated snapshots refactor: rreplaced polished by mixins func * refactor: updated styled * fix: added missed semicolon * refactor: updated media * refactor: updated tests * refactor: organized modifiers * refactor: removed unused imports * refactor: design adjusts * refactor: updated snapshot * refactor: changed minor things * refactor: updated snapshots * refactor: commented tests. fix later
2018-12-13 13:05:47 -05:00
/**
* @property { string | number | Styles } [ruleOrSelector]
*/
export interface Styles {
[ruleOrSelector: string]: string | number | Styles;
Package Refactor (#1145) * chore: fix unit test, forgotten line on merge chore: add node 11 to circleci (#1153) chore: fix the use of Node 11 in CircleCI (#1154) refactor: added css in js, new design, added types feat: added Tag component refactor: added modifiers refactor: replaced by polished ellipsis refactor: added types, new design and css in js refactor: removed ul. it needs refactor refactor: changed media queries refactor: changed icon height refactor: changed Header media queries refactor: removed margin top refactor: updated snapshots refactor: removed unnecessary format author refactor: added license icon & changed size refactor: changed media queries refactor: added icon size refactor: changed media queries refactor: updated snap refactor: replaced Description by Details refactor: updated tests refactor: fixed modifiers type feat: created missed types fix: fixed types fix: fixed prop type fix: fixed undefined prop refactor: replaced label by name refactor: updated snap refactor: moved polished to dev refactor: changed formatAuthor and pkg author type fix: removed incorrect meta's type refactor: removed polished refactor: added spacing & ellipsis mixin refactor: added modifier type refactor: changed datetime format refactor: updated snapshots refactor: rreplaced polished by mixins func * refactor: updated styled * fix: added missed semicolon * refactor: updated media * refactor: updated tests * refactor: organized modifiers * refactor: removed unused imports * refactor: design adjusts * refactor: updated snapshot * refactor: changed minor things * refactor: updated snapshots * refactor: commented tests. fix later
2018-12-13 13:05:47 -05:00
};
export type AuthorAvatar = Author & { avatar?: string };