UNPKG

4.2 kBTypeScriptView Raw
1import { PackageAccess, PackageList } from './manifest';
2export declare type TypeToken = 'Bearer' | 'Basic';
3export interface Logger {
4 child: (conf: any) => any;
5 debug: (conf: any, template?: string) => void;
6 error: (conf: any, template?: string) => void;
7 http: (conf: any, template?: string) => void;
8 trace: (conf: any, template?: string) => void;
9 warn: (conf: any, template?: string) => void;
10 info: (conf: any, template?: string) => void;
11}
12export declare type LoggerType = 'stdout' | 'stderr' | 'file';
13export declare type LoggerFormat = 'pretty' | 'pretty-timestamped' | 'file';
14export declare type LoggerLevel = 'http' | 'fatal' | 'warn' | 'info' | 'debug' | 'trace';
15export interface ConfigWithHttps extends Config {
16 https: HttpsConf;
17}
18export interface LoggerConfItem {
19 type: LoggerType;
20 format: LoggerFormat;
21 level: LoggerLevel;
22}
23export interface Headers {
24 [key: string]: string;
25}
26export interface UpLinkTokenConf {
27 type: TypeToken;
28 token?: string;
29 token_env?: boolean | string;
30}
31export interface UpLinkConf {
32 url: string;
33 ca?: string;
34 cache?: boolean;
35 timeout?: string | void;
36 maxage?: string | void;
37 max_fails?: number | void;
38 fail_timeout?: string | void;
39 headers?: Headers;
40 auth?: UpLinkTokenConf;
41 strict_ssl?: boolean | void;
42 _autogenerated?: boolean;
43}
44export declare type RateLimit = {
45 windowMs?: number;
46 max?: number;
47};
48export interface WebConf {
49 enable?: boolean;
50 title?: string;
51 logo?: string;
52 favicon?: string;
53 gravatar?: boolean;
54 sort_packages?: string;
55 rateLimit?: RateLimit;
56}
57export interface UpLinksConfList {
58 [key: string]: UpLinkConf;
59}
60export interface AuthHtpasswd {
61 file: string;
62 max_users: number;
63}
64export declare type AuthConf = any | AuthHtpasswd;
65export interface JWTOptions {
66 sign: JWTSignOptions;
67 verify: JWTVerifyOptions;
68}
69export interface JWTSignOptions {
70 algorithm?: string;
71 expiresIn?: string;
72 notBefore?: string;
73 ignoreExpiration?: boolean;
74 maxAge?: string | number;
75 clockTimestamp?: number;
76}
77export interface JWTVerifyOptions {
78 algorithm?: string;
79 expiresIn?: string;
80 notBefore?: string | number;
81 ignoreExpiration?: boolean;
82 maxAge?: string | number;
83 clockTimestamp?: number;
84}
85export interface APITokenOptions {
86 legacy: boolean;
87 jwt?: JWTOptions;
88}
89export interface Security {
90 enhancedLegacySignature?: boolean;
91 web: JWTOptions;
92 api: APITokenOptions;
93}
94export interface PublishOptions {
95 allow_offline: boolean;
96}
97export interface ListenAddress {
98 [key: string]: string;
99}
100export interface HttpsConfKeyCert {
101 key: string;
102 cert: string;
103 ca?: string;
104}
105export interface HttpsConfPfx {
106 pfx: string;
107 passphrase?: string;
108}
109export declare type HttpsConf = HttpsConfKeyCert | HttpsConfPfx;
110export interface Notifications {
111 method: string;
112 packagePattern: RegExp;
113 packagePatternFlags: string;
114 endpoint: string;
115 content: string;
116 headers: Headers;
117}
118export declare type ServerSettingsConf = {
119 trustProxy?: string;
120 rateLimit: RateLimit;
121 keepAliveTimeout?: number;
122};
123export interface ConfigYaml {
124 _debug?: boolean;
125 storage?: string | void;
126 packages: PackageList;
127 uplinks: UpLinksConfList;
128 logs?: LoggerConfItem;
129 web?: WebConf;
130 auth?: AuthConf;
131 security: Security;
132 publish?: PublishOptions;
133 store?: any;
134 listen?: ListenAddress;
135 https?: HttpsConf;
136 http_proxy?: string;
137 plugins?: string | void | null;
138 https_proxy?: string;
139 no_proxy?: string;
140 max_body_size?: string;
141 notifications?: Notifications;
142 notify?: Notifications | Notifications[];
143 middlewares?: any;
144 filters?: any;
145 url_prefix?: string;
146 server?: ServerSettingsConf;
147}
148export interface ConfigRuntime extends ConfigYaml {
149 self_path: string;
150}
151export interface Config extends ConfigYaml, ConfigRuntime {
152 user_agent?: string | boolean;
153 server_id: string;
154 secret: string;
155 checkSecretKey(token: string): string;
156 getMatchedPackagesSpec(storage: string): PackageAccess | void;
157 [key: string]: any;
158}