@verdaccio/types 11.0.0-6-next.12 → 11.0.0-6-next.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +13 -34
- package/build/commons.d.ts +24 -0
- package/build/configuration.d.ts +237 -0
- package/build/manifest.d.ts +201 -0
- package/build/plugins/auth.d.ts +21 -0
- package/build/plugins/commons.d.ts +11 -0
- package/build/plugins/filter.d.ts +5 -0
- package/build/plugins/index.d.ts +25 -0
- package/build/plugins/middleware.d.ts +5 -0
- package/build/plugins/storage.d.ts +80 -0
- package/build/plugins/theme.d.ts +0 -0
- package/build/search.d.ts +26 -0
- package/build/types.d.ts +5 -0
- package/package.json +21 -11
- package/src/commons.ts +37 -0
- package/src/configuration.ts +296 -0
- package/src/manifest.ts +217 -0
- package/src/plugins/auth.ts +22 -0
- package/src/plugins/commons.ts +15 -0
- package/src/plugins/filter.ts +6 -0
- package/src/plugins/index.ts +31 -0
- package/src/plugins/middleware.ts +8 -0
- package/src/plugins/storage.ts +95 -0
- package/src/plugins/theme.ts +0 -0
- package/src/search.ts +28 -0
- package/src/types.ts +5 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +9 -0
- package/typedoc.json +5 -0
- package/index.d.ts +0 -639
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable, Writable } from 'stream';
|
|
3
|
+
import { Callback, CallbackAction } from '../commons';
|
|
4
|
+
import { Config, Logger } from '../configuration';
|
|
5
|
+
import { Manifest, Token } from '../manifest';
|
|
6
|
+
import { IPlugin } from './commons';
|
|
7
|
+
export declare type StorageList = string[];
|
|
8
|
+
export interface LocalStorage {
|
|
9
|
+
list: any;
|
|
10
|
+
secret: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ILocalStorage {
|
|
13
|
+
add(name: string): void;
|
|
14
|
+
remove(name: string): void;
|
|
15
|
+
get(): StorageList;
|
|
16
|
+
sync(): void;
|
|
17
|
+
}
|
|
18
|
+
export interface TokenFilter {
|
|
19
|
+
user: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ITokenActions {
|
|
22
|
+
saveToken(token: Token): Promise<any>;
|
|
23
|
+
deleteToken(user: string, tokenKey: string): Promise<any>;
|
|
24
|
+
readTokens(filter: TokenFilter): Promise<Token[]>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* This method expect return a Package object
|
|
28
|
+
* eg:
|
|
29
|
+
* {
|
|
30
|
+
* name: string;
|
|
31
|
+
* time: number;
|
|
32
|
+
* ... and other props
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* The `cb` callback object will be executed if:
|
|
36
|
+
* - it might return object (truly)
|
|
37
|
+
* - it might reutrn null
|
|
38
|
+
*/
|
|
39
|
+
export declare type onSearchPackage = (item: Manifest, cb: CallbackAction) => void;
|
|
40
|
+
export declare type onEndSearchPackage = (error?: any) => void;
|
|
41
|
+
export declare type onValidatePackage = (name: string) => boolean;
|
|
42
|
+
export declare type StorageUpdateCallback = (data: Manifest, cb: CallbackAction) => void;
|
|
43
|
+
export declare type StorageWriteCallback = (name: string, json: Manifest, callback: Callback) => void;
|
|
44
|
+
export declare type PackageTransformer = (pkg: Manifest) => Manifest;
|
|
45
|
+
export declare type ReadPackageCallback = (err: any | null, data?: Manifest) => void;
|
|
46
|
+
export interface ILocalPackageManager {
|
|
47
|
+
logger: Logger;
|
|
48
|
+
deletePackage(fileName: string): Promise<void>;
|
|
49
|
+
removePackage(): Promise<void>;
|
|
50
|
+
updatePackage(packageName: string, handleUpdate: (manifest: Manifest) => Promise<Manifest>): Promise<Manifest>;
|
|
51
|
+
readPackage(name: string): Promise<Manifest>;
|
|
52
|
+
savePackage(pkgName: string, value: Manifest): Promise<void>;
|
|
53
|
+
readTarball(pkgName: string, { signal }: {
|
|
54
|
+
signal: any;
|
|
55
|
+
}): Promise<Readable>;
|
|
56
|
+
createPackage(name: string, manifest: Manifest): Promise<void>;
|
|
57
|
+
writeTarball(tarballName: string, { signal }: {
|
|
58
|
+
signal: any;
|
|
59
|
+
}): Promise<Writable>;
|
|
60
|
+
hasTarball(fileName: string): Promise<boolean>;
|
|
61
|
+
hasPackage(): Promise<boolean>;
|
|
62
|
+
}
|
|
63
|
+
export declare type IPackageStorage = ILocalPackageManager | void;
|
|
64
|
+
export declare type IPluginStorage<T> = ILocalData<T>;
|
|
65
|
+
export declare type IPackageStorageManager = ILocalPackageManager;
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated use @verdaccio/core pluginUtils instead
|
|
68
|
+
*/
|
|
69
|
+
interface ILocalData<T> extends IPlugin<T>, ITokenActions {
|
|
70
|
+
logger: Logger;
|
|
71
|
+
config: T & Config;
|
|
72
|
+
add(name: string): Promise<void>;
|
|
73
|
+
remove(name: string): Promise<void>;
|
|
74
|
+
get(): Promise<any>;
|
|
75
|
+
init(): Promise<void>;
|
|
76
|
+
getSecret(): Promise<string>;
|
|
77
|
+
setSecret(secret: string): Promise<any>;
|
|
78
|
+
getPackageStorage(packageInfo: string): IPackageStorage;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare type PublisherMaintainer = {
|
|
2
|
+
username: string;
|
|
3
|
+
email: string;
|
|
4
|
+
};
|
|
5
|
+
export declare type SearchPackageBody = {
|
|
6
|
+
name: string;
|
|
7
|
+
scope: string;
|
|
8
|
+
description: string;
|
|
9
|
+
author: string | PublisherMaintainer;
|
|
10
|
+
version: string;
|
|
11
|
+
keywords: string | string[] | undefined;
|
|
12
|
+
date: string;
|
|
13
|
+
links?: {
|
|
14
|
+
npm: string;
|
|
15
|
+
homepage?: string;
|
|
16
|
+
repository?: string;
|
|
17
|
+
bugs?: string;
|
|
18
|
+
};
|
|
19
|
+
publisher?: any;
|
|
20
|
+
maintainers?: PublisherMaintainer[];
|
|
21
|
+
};
|
|
22
|
+
export declare type SearchResultWeb = {
|
|
23
|
+
name: string;
|
|
24
|
+
version: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
package/build/types.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/types",
|
|
3
|
-
"version": "11.0.0-6-next.
|
|
3
|
+
"version": "11.0.0-6-next.13",
|
|
4
4
|
"description": "verdaccio types definitions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"private",
|
|
@@ -31,18 +31,28 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"main": "
|
|
35
|
-
"types": "
|
|
36
|
-
"scripts": {
|
|
37
|
-
"test": "exit 0",
|
|
38
|
-
"build": "exit 0"
|
|
39
|
-
},
|
|
34
|
+
"main": "build/types.d.ts",
|
|
35
|
+
"types": "build/types.d.ts",
|
|
40
36
|
"devDependencies": {
|
|
41
|
-
"@types/node": "16.11.
|
|
42
|
-
"
|
|
37
|
+
"@types/node": "16.11.47",
|
|
38
|
+
"typedoc": "beta",
|
|
39
|
+
"typedoc-plugin-missing-exports": "1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"typedoc": {
|
|
42
|
+
"entryPoint": "./src/types.ts",
|
|
43
|
+
"readmeFile": "./README.md",
|
|
44
|
+
"displayName": "@verdaccio/types"
|
|
43
45
|
},
|
|
44
46
|
"funding": {
|
|
45
47
|
"type": "opencollective",
|
|
46
48
|
"url": "https://opencollective.com/verdaccio"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"clean": "rimraf ./build",
|
|
52
|
+
"test": "pnpm type-check",
|
|
53
|
+
"build:docs": "typedoc --options ./typedoc.json --excludeExternals --tsconfig tsconfig.build.json",
|
|
54
|
+
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
|
55
|
+
"build": "tsc --emitDeclarationOnly -p tsconfig.build.json"
|
|
56
|
+
},
|
|
57
|
+
"readme": "# @verdaccio/types\n\nTypeScript definitions for Verdaccio plugins and internal code.\n\n### Usage\n\n```ts\nimport type {ILocalData, LocalStorage, Logger, Config} from '@verdaccio/types';\n\nclass LocalData implements ILocalData {\n path: string;\n logger: Logger;\n data: LocalStorage;\n config: Config;\n locked: boolean;\n ...\n}\n```\n\n### Run docs\n\nGenerate the package types documentation at `./docs` folder.\n\n```bash\n pnpm build:docs\n```\n"
|
|
58
|
+
}
|
package/src/commons.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @deprecated add proper type fot the callback
|
|
2
|
+
export type Callback = Function;
|
|
3
|
+
// FIXME: err should be something flexible enough for any implementation
|
|
4
|
+
export type CallbackAction = (err: any | null) => void;
|
|
5
|
+
// eslint-disable-next-line no-undef
|
|
6
|
+
export type CallbackError = (err: NodeJS.ErrnoException) => void;
|
|
7
|
+
|
|
8
|
+
export interface RemoteUser {
|
|
9
|
+
real_groups: string[];
|
|
10
|
+
groups: string[];
|
|
11
|
+
name: string | void;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type StringValue = string | void | null;
|
|
16
|
+
|
|
17
|
+
// FIXME: error should be export type `VerdaccioError = HttpError & { code: number };`
|
|
18
|
+
// instead of AuthError
|
|
19
|
+
// but this type is on @verdaccio/core and cannot be used here yet (I don't know why)
|
|
20
|
+
export interface HttpError extends Error {
|
|
21
|
+
status: number;
|
|
22
|
+
statusCode: number;
|
|
23
|
+
expose: boolean;
|
|
24
|
+
headers?: {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
};
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type URLPrefix = {
|
|
31
|
+
// if is false, it would be relative by default
|
|
32
|
+
absolute: boolean;
|
|
33
|
+
// base path
|
|
34
|
+
// eg: absolute: true, https://somedomain.com/xxx/
|
|
35
|
+
// eg: absolute: false, /xxx/ (default) if url_prefix is an string instead an object
|
|
36
|
+
basePath: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { PackageAccess, PackageList } from './manifest';
|
|
2
|
+
|
|
3
|
+
export type TypeToken = 'Bearer' | 'Basic';
|
|
4
|
+
|
|
5
|
+
export interface Logger {
|
|
6
|
+
child: (conf: any) => any;
|
|
7
|
+
debug: (conf: any, template?: string) => void;
|
|
8
|
+
error: (conf: any, template?: string) => void;
|
|
9
|
+
http: (conf: any, template?: string) => void;
|
|
10
|
+
trace: (conf: any, template?: string) => void;
|
|
11
|
+
warn: (conf: any, template?: string) => void;
|
|
12
|
+
info: (conf: any, template?: string) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type LoggerType = 'stdout' | 'file';
|
|
16
|
+
export type LoggerFormat = 'pretty' | 'pretty-timestamped' | 'json';
|
|
17
|
+
export type LoggerLevel = 'http' | 'fatal' | 'warn' | 'info' | 'debug' | 'trace';
|
|
18
|
+
|
|
19
|
+
export type LoggerConfigItem = {
|
|
20
|
+
type?: LoggerType;
|
|
21
|
+
/**
|
|
22
|
+
* The format
|
|
23
|
+
*/
|
|
24
|
+
format?: LoggerFormat;
|
|
25
|
+
path?: string;
|
|
26
|
+
level?: string;
|
|
27
|
+
colors?: boolean;
|
|
28
|
+
async?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export interface ConfigWithHttps extends Config {
|
|
32
|
+
https: HttpsConf;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface PackageAccessYaml {
|
|
36
|
+
storage?: string;
|
|
37
|
+
publish?: string;
|
|
38
|
+
proxy?: string;
|
|
39
|
+
access?: string;
|
|
40
|
+
unpublish?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface LoggerConfItem {
|
|
44
|
+
type: LoggerType;
|
|
45
|
+
format: LoggerFormat;
|
|
46
|
+
level: LoggerLevel;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface Headers {
|
|
50
|
+
[key: string]: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface UpLinkTokenConf {
|
|
54
|
+
type: TypeToken;
|
|
55
|
+
token?: string;
|
|
56
|
+
token_env?: boolean | string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface UpLinkConf {
|
|
60
|
+
url: string;
|
|
61
|
+
ca?: string;
|
|
62
|
+
cache?: boolean;
|
|
63
|
+
timeout?: string | void;
|
|
64
|
+
maxage?: string | void;
|
|
65
|
+
max_fails?: number | void;
|
|
66
|
+
fail_timeout?: string | void;
|
|
67
|
+
headers?: Headers;
|
|
68
|
+
auth?: UpLinkTokenConf;
|
|
69
|
+
strict_ssl?: boolean | void;
|
|
70
|
+
_autogenerated?: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type RateLimit = {
|
|
74
|
+
windowMs?: number;
|
|
75
|
+
max?: number;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// export interface WebConf {
|
|
79
|
+
// enable?: boolean;
|
|
80
|
+
// title?: string;
|
|
81
|
+
// logo?: string;
|
|
82
|
+
// favicon?: string;
|
|
83
|
+
// gravatar?: boolean;
|
|
84
|
+
// sort_packages?: string;
|
|
85
|
+
// rateLimit?: RateLimit;
|
|
86
|
+
// }
|
|
87
|
+
|
|
88
|
+
export type FlagsConfig = {
|
|
89
|
+
searchRemote?: boolean;
|
|
90
|
+
changePassword?: boolean;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type PackageManagers = 'pnpm' | 'yarn' | 'npm';
|
|
94
|
+
|
|
95
|
+
// FUTURE: WebConf and TemplateUIOptions should be merged .
|
|
96
|
+
export type CommonWebConf = {
|
|
97
|
+
title?: string;
|
|
98
|
+
logo?: string;
|
|
99
|
+
favicon?: string;
|
|
100
|
+
gravatar?: boolean;
|
|
101
|
+
sort_packages?: string;
|
|
102
|
+
darkMode?: boolean;
|
|
103
|
+
url_prefix?: string;
|
|
104
|
+
language?: string;
|
|
105
|
+
login?: boolean;
|
|
106
|
+
scope?: string;
|
|
107
|
+
pkgManagers?: PackageManagers[];
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Options are passed to the index.html
|
|
112
|
+
*/
|
|
113
|
+
export type TemplateUIOptions = {
|
|
114
|
+
uri?: string;
|
|
115
|
+
darkMode?: boolean;
|
|
116
|
+
protocol?: string;
|
|
117
|
+
host?: string;
|
|
118
|
+
// deprecated
|
|
119
|
+
basename?: string;
|
|
120
|
+
scope?: string;
|
|
121
|
+
showInfo?: boolean;
|
|
122
|
+
showSettings?: boolean;
|
|
123
|
+
showSearch?: boolean;
|
|
124
|
+
showFooter?: boolean;
|
|
125
|
+
showThemeSwitch?: boolean;
|
|
126
|
+
showDownloadTarball?: boolean;
|
|
127
|
+
showRaw?: boolean;
|
|
128
|
+
base: string;
|
|
129
|
+
primaryColor?: string;
|
|
130
|
+
version?: string;
|
|
131
|
+
logoURI?: string;
|
|
132
|
+
flags: FlagsConfig;
|
|
133
|
+
} & CommonWebConf;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Options on config.yaml for web
|
|
137
|
+
*/
|
|
138
|
+
export type WebConf = {
|
|
139
|
+
// FIXME: rename to primaryColor and move it to CommonWebConf
|
|
140
|
+
primary_color?: string;
|
|
141
|
+
enable?: boolean;
|
|
142
|
+
scriptsHead?: string[];
|
|
143
|
+
scriptsBodyAfter?: string[];
|
|
144
|
+
metaScripts?: string[];
|
|
145
|
+
bodyBefore?: string[];
|
|
146
|
+
bodyAfter?: string[];
|
|
147
|
+
} & CommonWebConf;
|
|
148
|
+
|
|
149
|
+
export interface UpLinksConfList {
|
|
150
|
+
[key: string]: UpLinkConf;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface AuthHtpasswd {
|
|
154
|
+
file: string;
|
|
155
|
+
max_users: number;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type AuthConf = any | AuthHtpasswd;
|
|
159
|
+
|
|
160
|
+
export interface JWTOptions {
|
|
161
|
+
sign: JWTSignOptions;
|
|
162
|
+
verify: JWTVerifyOptions;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface JWTSignOptions {
|
|
166
|
+
algorithm?: string;
|
|
167
|
+
expiresIn?: string;
|
|
168
|
+
notBefore?: string;
|
|
169
|
+
ignoreExpiration?: boolean;
|
|
170
|
+
maxAge?: string | number;
|
|
171
|
+
clockTimestamp?: number;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface JWTVerifyOptions {
|
|
175
|
+
algorithm?: string;
|
|
176
|
+
expiresIn?: string;
|
|
177
|
+
notBefore?: string | number;
|
|
178
|
+
ignoreExpiration?: boolean;
|
|
179
|
+
maxAge?: string | number;
|
|
180
|
+
clockTimestamp?: number;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface APITokenOptions {
|
|
184
|
+
legacy: boolean;
|
|
185
|
+
jwt?: JWTOptions;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface Security {
|
|
189
|
+
web: JWTOptions;
|
|
190
|
+
api: APITokenOptions;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface PublishOptions {
|
|
194
|
+
allow_offline: boolean;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface ListenAddress {
|
|
198
|
+
[key: string]: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface HttpsConfKeyCert {
|
|
202
|
+
key: string;
|
|
203
|
+
cert: string;
|
|
204
|
+
ca?: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface HttpsConfPfx {
|
|
208
|
+
pfx: string;
|
|
209
|
+
passphrase?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export type HttpsConf = HttpsConfKeyCert | HttpsConfPfx;
|
|
213
|
+
|
|
214
|
+
export interface Notifications {
|
|
215
|
+
method: string;
|
|
216
|
+
packagePattern: RegExp;
|
|
217
|
+
packagePatternFlags: string;
|
|
218
|
+
endpoint: string;
|
|
219
|
+
content: string;
|
|
220
|
+
headers: Headers;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export type Notification = Notifications;
|
|
224
|
+
|
|
225
|
+
export type ServerSettingsConf = {
|
|
226
|
+
// express-rate-limit settings
|
|
227
|
+
rateLimit: RateLimit;
|
|
228
|
+
keepAliveTimeout?: number;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* YAML configuration file available options.
|
|
233
|
+
*/
|
|
234
|
+
export interface ConfigYaml {
|
|
235
|
+
_debug?: boolean;
|
|
236
|
+
storage?: string | void;
|
|
237
|
+
packages: PackageList;
|
|
238
|
+
uplinks: UpLinksConfList;
|
|
239
|
+
log?: LoggerConfItem;
|
|
240
|
+
web?: WebConf;
|
|
241
|
+
auth?: AuthConf;
|
|
242
|
+
security: Security;
|
|
243
|
+
publish?: PublishOptions;
|
|
244
|
+
store?: any;
|
|
245
|
+
listen?: ListenAddress;
|
|
246
|
+
https?: HttpsConf;
|
|
247
|
+
http_proxy?: string;
|
|
248
|
+
plugins?: string | void;
|
|
249
|
+
https_proxy?: string;
|
|
250
|
+
no_proxy?: string;
|
|
251
|
+
max_body_size?: string;
|
|
252
|
+
notifications?: Notifications;
|
|
253
|
+
notify?: Notifications | Notifications[];
|
|
254
|
+
middlewares?: any;
|
|
255
|
+
filters?: any;
|
|
256
|
+
url_prefix?: string;
|
|
257
|
+
server?: ServerSettingsConf;
|
|
258
|
+
flags?: FlagsConfig;
|
|
259
|
+
// internal objects, added by internal yaml to JS config parser
|
|
260
|
+
// @deprecated use configPath instead
|
|
261
|
+
config_path?: string;
|
|
262
|
+
// save the configuration file path
|
|
263
|
+
configPath?: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Configuration object with additonal methods for configuration, includes yaml and internal medatada.
|
|
268
|
+
* @interface Config
|
|
269
|
+
* @extends {ConfigYaml}
|
|
270
|
+
*/
|
|
271
|
+
export interface Config extends Omit<ConfigYaml, 'packages' | 'security' | 'configPath'> {
|
|
272
|
+
user_agent: string;
|
|
273
|
+
server_id: string;
|
|
274
|
+
secret: string;
|
|
275
|
+
// save the configuration file path, it's fails without thi configPath
|
|
276
|
+
configPath: string;
|
|
277
|
+
// packages from yaml file looks different from packages inside the config file
|
|
278
|
+
packages: PackageList;
|
|
279
|
+
// security object defaults is added by the config file but optional in the yaml file
|
|
280
|
+
security: Security;
|
|
281
|
+
// @deprecated (pending adding the replacement)
|
|
282
|
+
checkSecretKey(token: string): string;
|
|
283
|
+
getMatchedPackagesSpec(storage: string): PackageAccess | void;
|
|
284
|
+
// TODO: verify how to handle this in the future
|
|
285
|
+
[key: string]: any;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface AllowAccess {
|
|
289
|
+
name: string;
|
|
290
|
+
version?: string;
|
|
291
|
+
tag?: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// info passed to the auth plugin when a package is package is being published
|
|
295
|
+
|
|
296
|
+
export interface AuthPackageAllow extends PackageAccess, AllowAccess {}
|
package/src/manifest.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export interface PackageAccess {
|
|
2
|
+
storage?: string;
|
|
3
|
+
publish?: string[];
|
|
4
|
+
proxy?: string[];
|
|
5
|
+
access?: string[];
|
|
6
|
+
unpublish: string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PackageList {
|
|
10
|
+
[key: string]: PackageAccess;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface MergeTags {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface DistFile {
|
|
18
|
+
url: string;
|
|
19
|
+
sha: string;
|
|
20
|
+
registry?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface DistFiles {
|
|
24
|
+
[key: string]: DistFile;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Token {
|
|
28
|
+
user: string;
|
|
29
|
+
token: string;
|
|
30
|
+
key: string;
|
|
31
|
+
cidr?: string[];
|
|
32
|
+
readonly: boolean;
|
|
33
|
+
created: number | string;
|
|
34
|
+
updated?: number | string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface AttachMents {
|
|
38
|
+
[key: string]: AttachMentsItem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface AttachMentsItem {
|
|
42
|
+
content_type?: string;
|
|
43
|
+
data?: string;
|
|
44
|
+
length?: number;
|
|
45
|
+
shasum?: string;
|
|
46
|
+
version?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface GenericBody {
|
|
50
|
+
[key: string]: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface UpLinkMetadata {
|
|
54
|
+
etag: string;
|
|
55
|
+
fetched: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface UpLinks {
|
|
59
|
+
[key: string]: UpLinkMetadata;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface Signatures {
|
|
63
|
+
keyid: string;
|
|
64
|
+
sig: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface Dist {
|
|
68
|
+
'npm-signature'?: string;
|
|
69
|
+
signatures?: Signatures[];
|
|
70
|
+
fileCount?: number;
|
|
71
|
+
integrity?: string;
|
|
72
|
+
shasum: string;
|
|
73
|
+
unpackedSize?: number;
|
|
74
|
+
tarball: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface Author {
|
|
78
|
+
username?: string;
|
|
79
|
+
name: string;
|
|
80
|
+
email?: string;
|
|
81
|
+
url?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface PackageUsers {
|
|
85
|
+
[key: string]: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface Tags {
|
|
89
|
+
[key: string]: Version;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface Version {
|
|
93
|
+
name: string;
|
|
94
|
+
version: string;
|
|
95
|
+
devDependencies?: string;
|
|
96
|
+
directories?: any;
|
|
97
|
+
dist: Dist;
|
|
98
|
+
author: string | Author;
|
|
99
|
+
main: string;
|
|
100
|
+
homemage?: string;
|
|
101
|
+
license?: string;
|
|
102
|
+
readme: string;
|
|
103
|
+
readmeFileName?: string;
|
|
104
|
+
readmeFilename?: string;
|
|
105
|
+
description: string;
|
|
106
|
+
bin?: string;
|
|
107
|
+
bugs?: any;
|
|
108
|
+
files?: string[];
|
|
109
|
+
gitHead?: string;
|
|
110
|
+
maintainers?: Author[];
|
|
111
|
+
contributors?: Author[];
|
|
112
|
+
repository?: string | any;
|
|
113
|
+
scripts?: any;
|
|
114
|
+
homepage?: string;
|
|
115
|
+
etag?: string;
|
|
116
|
+
dependencies: any;
|
|
117
|
+
keywords?: string | string[];
|
|
118
|
+
nodeVersion?: string;
|
|
119
|
+
_id: string;
|
|
120
|
+
_npmVersion?: string;
|
|
121
|
+
_npmUser: Author;
|
|
122
|
+
_hasShrinkwrap?: boolean;
|
|
123
|
+
deprecated?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface Versions {
|
|
127
|
+
[key: string]: Version;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated use Manifest instead
|
|
132
|
+
*/
|
|
133
|
+
export interface Package {
|
|
134
|
+
_id?: string;
|
|
135
|
+
name: string;
|
|
136
|
+
versions: Versions;
|
|
137
|
+
'dist-tags': GenericBody;
|
|
138
|
+
time: GenericBody;
|
|
139
|
+
readme?: string;
|
|
140
|
+
users?: PackageUsers;
|
|
141
|
+
_distfiles: DistFiles;
|
|
142
|
+
_attachments: AttachMents;
|
|
143
|
+
_uplinks: UpLinks;
|
|
144
|
+
_rev: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Represents upstream manifest from another registry
|
|
149
|
+
*/
|
|
150
|
+
export interface FullRemoteManifest {
|
|
151
|
+
_id?: string;
|
|
152
|
+
_rev?: string;
|
|
153
|
+
name: string;
|
|
154
|
+
description?: string;
|
|
155
|
+
'dist-tags': GenericBody;
|
|
156
|
+
time: GenericBody;
|
|
157
|
+
versions: Versions;
|
|
158
|
+
maintainers?: Author[];
|
|
159
|
+
/** store the latest readme **/
|
|
160
|
+
readme?: string;
|
|
161
|
+
/** store star assigned to this packages by users */
|
|
162
|
+
users?: PackageUsers;
|
|
163
|
+
// TODO: not clear what access exactly means
|
|
164
|
+
access?: any;
|
|
165
|
+
bugs?: { url: string };
|
|
166
|
+
license?: string;
|
|
167
|
+
homepage?: string;
|
|
168
|
+
repository?: string | { type?: string; url: string; directory?: string };
|
|
169
|
+
keywords?: string[];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface Manifest extends FullRemoteManifest, PublishManifest {
|
|
173
|
+
// private fields only used by verdaccio
|
|
174
|
+
/**
|
|
175
|
+
* store fast access to the dist url of an specific tarball, instead search version
|
|
176
|
+
* by id, just the tarball id is faster.
|
|
177
|
+
*
|
|
178
|
+
* The _distfiles is created only when a package is being sync from an upstream.
|
|
179
|
+
* also used to fetch tarballs from upstream, the private publish tarballs are not stored in
|
|
180
|
+
* this object because they are not published in the upstream registry.
|
|
181
|
+
*/
|
|
182
|
+
_distfiles: DistFiles;
|
|
183
|
+
/**
|
|
184
|
+
* Store access cache metadata, to avoid to fetch the same metadata multiple times.
|
|
185
|
+
*
|
|
186
|
+
* The key represents the uplink id which is composed of a etag and a fetched timestamp.
|
|
187
|
+
*
|
|
188
|
+
* The fetched timestamp is the time when the metadata was fetched, used to avoid to fetch the
|
|
189
|
+
* same metadata until the metadata is older than the last fetch.
|
|
190
|
+
*/
|
|
191
|
+
_uplinks: UpLinks;
|
|
192
|
+
/**
|
|
193
|
+
* store the revision of the manifest
|
|
194
|
+
*/
|
|
195
|
+
_rev: string;
|
|
196
|
+
}
|
|
197
|
+
export interface PublishManifest {
|
|
198
|
+
/**
|
|
199
|
+
* The `_attachments` object has different usages:
|
|
200
|
+
*
|
|
201
|
+
* - When a package is published, it contains the tarball as an string, this string is used to be
|
|
202
|
+
* converted as a tarball, usually attached to the package but not stored in the database.
|
|
203
|
+
* - If user runs `npm star` the _attachments will be at the manifest body but empty.
|
|
204
|
+
*
|
|
205
|
+
* It has also an internal usage:
|
|
206
|
+
*
|
|
207
|
+
* - Used as a cache for the tarball, quick access to the tarball shasum, etc. Instead
|
|
208
|
+
* iterate versions and find the right one, just using the tarball as a key which is what
|
|
209
|
+
* the package manager sends to the registry.
|
|
210
|
+
*
|
|
211
|
+
* - A `_attachments` object is added every time a private tarball is published, upstream cached tarballs are
|
|
212
|
+
* not being part of this object, only for published private packages.
|
|
213
|
+
*
|
|
214
|
+
* Note: This field is removed when the package is accesed through the web user interface.
|
|
215
|
+
* */
|
|
216
|
+
_attachments: AttachMents;
|
|
217
|
+
}
|