@verdaccio/types 10.4.1 → 10.5.1
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 +18 -0
- package/README.md +6 -5
- package/build/commons.d.ts +20 -0
- package/build/configuration.d.ts +156 -0
- package/build/manifest.d.ts +112 -0
- package/build/plugins/auth.d.ts +22 -0
- package/build/plugins/commons.d.ts +11 -0
- package/build/plugins/filter.d.ts +5 -0
- package/build/plugins/index.d.ts +34 -0
- package/build/plugins/middleware.d.ts +6 -0
- package/build/plugins/storage.d.ts +105 -0
- package/build/plugins/theme.d.ts +0 -0
- package/build/types.d.ts +4 -0
- package/package.json +11 -6
- package/tsconfig.json +16 -0
- package/index.d.ts +0 -578
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4643709: fix: wrong package configuration
|
|
8
|
+
|
|
9
|
+
## 10.5.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- b5cfaf6: feat: refactor types and typescript 4
|
|
14
|
+
|
|
15
|
+
## 10.4.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 2d428b3: fix: user_agent property as boolean
|
|
20
|
+
|
|
3
21
|
## 10.4.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
# Typescript types
|
|
1
|
+
# Typescript types
|
|
2
2
|
|
|
3
3
|
Typescript definitions for verdaccio plugins and internal code
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
6
7
|
For usage with the library, the `tsconfig.json` should looks like this.
|
|
7
8
|
|
|
8
9
|
```
|
|
@@ -29,9 +30,9 @@ For usage with the library, the `tsconfig.json` should looks like this.
|
|
|
29
30
|
}
|
|
30
31
|
```
|
|
31
32
|
|
|
32
|
-
###
|
|
33
|
+
### Example
|
|
33
34
|
|
|
34
|
-
```
|
|
35
|
+
```typescript
|
|
35
36
|
import type {ILocalData, LocalStorage, Logger, Config} from '@verdaccio/types';
|
|
36
37
|
|
|
37
38
|
class LocalData implements ILocalData {
|
|
@@ -45,4 +46,4 @@ import type {ILocalData, LocalStorage, Logger, Config} from '@verdaccio/types';
|
|
|
45
46
|
}
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
#### Plugins
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare type Callback = Function;
|
|
3
|
+
export declare type CallbackAction = (err: any | null) => void;
|
|
4
|
+
export declare type CallbackError = (err: NodeJS.ErrnoException) => void;
|
|
5
|
+
export interface RemoteUser {
|
|
6
|
+
real_groups: string[];
|
|
7
|
+
groups: string[];
|
|
8
|
+
name: string | void;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare type StringValue = string | void | null;
|
|
12
|
+
export interface HttpError extends Error {
|
|
13
|
+
status: number;
|
|
14
|
+
statusCode: number;
|
|
15
|
+
expose: boolean;
|
|
16
|
+
headers?: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { PackageAccess, PackageList } from './manifest';
|
|
2
|
+
export declare type TypeToken = 'Bearer' | 'Basic';
|
|
3
|
+
export 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
|
+
}
|
|
12
|
+
export declare type LoggerType = 'stdout' | 'stderr' | 'file';
|
|
13
|
+
export declare type LoggerFormat = 'pretty' | 'pretty-timestamped' | 'file';
|
|
14
|
+
export declare type LoggerLevel = 'http' | 'fatal' | 'warn' | 'info' | 'debug' | 'trace';
|
|
15
|
+
export interface ConfigWithHttps extends Config {
|
|
16
|
+
https: HttpsConf;
|
|
17
|
+
}
|
|
18
|
+
export interface LoggerConfItem {
|
|
19
|
+
type: LoggerType;
|
|
20
|
+
format: LoggerFormat;
|
|
21
|
+
level: LoggerLevel;
|
|
22
|
+
}
|
|
23
|
+
export interface Headers {
|
|
24
|
+
[key: string]: string;
|
|
25
|
+
}
|
|
26
|
+
export interface UpLinkTokenConf {
|
|
27
|
+
type: TypeToken;
|
|
28
|
+
token?: string;
|
|
29
|
+
token_env?: boolean | string;
|
|
30
|
+
}
|
|
31
|
+
export 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
|
+
}
|
|
44
|
+
export declare type RateLimit = {
|
|
45
|
+
windowMs?: number;
|
|
46
|
+
max?: number;
|
|
47
|
+
};
|
|
48
|
+
export 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
|
+
}
|
|
57
|
+
export interface UpLinksConfList {
|
|
58
|
+
[key: string]: UpLinkConf;
|
|
59
|
+
}
|
|
60
|
+
export interface AuthHtpasswd {
|
|
61
|
+
file: string;
|
|
62
|
+
max_users: number;
|
|
63
|
+
}
|
|
64
|
+
export declare type AuthConf = any | AuthHtpasswd;
|
|
65
|
+
export interface JWTOptions {
|
|
66
|
+
sign: JWTSignOptions;
|
|
67
|
+
verify: JWTVerifyOptions;
|
|
68
|
+
}
|
|
69
|
+
export interface JWTSignOptions {
|
|
70
|
+
algorithm?: string;
|
|
71
|
+
expiresIn?: string;
|
|
72
|
+
notBefore?: string;
|
|
73
|
+
ignoreExpiration?: boolean;
|
|
74
|
+
maxAge?: string | number;
|
|
75
|
+
clockTimestamp?: number;
|
|
76
|
+
}
|
|
77
|
+
export interface JWTVerifyOptions {
|
|
78
|
+
algorithm?: string;
|
|
79
|
+
expiresIn?: string;
|
|
80
|
+
notBefore?: string | number;
|
|
81
|
+
ignoreExpiration?: boolean;
|
|
82
|
+
maxAge?: string | number;
|
|
83
|
+
clockTimestamp?: number;
|
|
84
|
+
}
|
|
85
|
+
export interface APITokenOptions {
|
|
86
|
+
legacy: boolean;
|
|
87
|
+
jwt?: JWTOptions;
|
|
88
|
+
}
|
|
89
|
+
export interface Security {
|
|
90
|
+
web: JWTOptions;
|
|
91
|
+
api: APITokenOptions;
|
|
92
|
+
}
|
|
93
|
+
export interface PublishOptions {
|
|
94
|
+
allow_offline: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface ListenAddress {
|
|
97
|
+
[key: string]: string;
|
|
98
|
+
}
|
|
99
|
+
export interface HttpsConfKeyCert {
|
|
100
|
+
key: string;
|
|
101
|
+
cert: string;
|
|
102
|
+
ca?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface HttpsConfPfx {
|
|
105
|
+
pfx: string;
|
|
106
|
+
passphrase?: string;
|
|
107
|
+
}
|
|
108
|
+
export declare type HttpsConf = HttpsConfKeyCert | HttpsConfPfx;
|
|
109
|
+
export interface Notifications {
|
|
110
|
+
method: string;
|
|
111
|
+
packagePattern: RegExp;
|
|
112
|
+
packagePatternFlags: string;
|
|
113
|
+
endpoint: string;
|
|
114
|
+
content: string;
|
|
115
|
+
headers: Headers;
|
|
116
|
+
}
|
|
117
|
+
export declare type ServerSettingsConf = {
|
|
118
|
+
rateLimit: RateLimit;
|
|
119
|
+
keepAliveTimeout?: number;
|
|
120
|
+
};
|
|
121
|
+
export interface ConfigYaml {
|
|
122
|
+
_debug?: boolean;
|
|
123
|
+
storage?: string | void;
|
|
124
|
+
packages: PackageList;
|
|
125
|
+
uplinks: UpLinksConfList;
|
|
126
|
+
logs?: LoggerConfItem;
|
|
127
|
+
web?: WebConf;
|
|
128
|
+
auth?: AuthConf;
|
|
129
|
+
security: Security;
|
|
130
|
+
publish?: PublishOptions;
|
|
131
|
+
store?: any;
|
|
132
|
+
listen?: ListenAddress;
|
|
133
|
+
https?: HttpsConf;
|
|
134
|
+
http_proxy?: string;
|
|
135
|
+
plugins?: string | void;
|
|
136
|
+
https_proxy?: string;
|
|
137
|
+
no_proxy?: string;
|
|
138
|
+
max_body_size?: string;
|
|
139
|
+
notifications?: Notifications;
|
|
140
|
+
notify?: Notifications | Notifications[];
|
|
141
|
+
middlewares?: any;
|
|
142
|
+
filters?: any;
|
|
143
|
+
url_prefix?: string;
|
|
144
|
+
server?: ServerSettingsConf;
|
|
145
|
+
}
|
|
146
|
+
export interface ConfigRuntime extends ConfigYaml {
|
|
147
|
+
self_path: string;
|
|
148
|
+
}
|
|
149
|
+
export interface Config extends ConfigYaml, ConfigRuntime {
|
|
150
|
+
user_agent?: string | boolean;
|
|
151
|
+
server_id: string;
|
|
152
|
+
secret: string;
|
|
153
|
+
checkSecretKey(token: string): string;
|
|
154
|
+
getMatchedPackagesSpec(storage: string): PackageAccess | void;
|
|
155
|
+
[key: string]: any;
|
|
156
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export interface PackageAccess {
|
|
2
|
+
storage?: string;
|
|
3
|
+
publish?: string[];
|
|
4
|
+
proxy?: string[];
|
|
5
|
+
access?: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface PackageList {
|
|
8
|
+
[key: string]: PackageAccess;
|
|
9
|
+
}
|
|
10
|
+
export interface MergeTags {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
}
|
|
13
|
+
export interface DistFile {
|
|
14
|
+
url: string;
|
|
15
|
+
sha: string;
|
|
16
|
+
registry?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface DistFiles {
|
|
19
|
+
[key: string]: DistFile;
|
|
20
|
+
}
|
|
21
|
+
export interface Token {
|
|
22
|
+
user: string;
|
|
23
|
+
token: string;
|
|
24
|
+
key: string;
|
|
25
|
+
cidr?: string[];
|
|
26
|
+
readonly: boolean;
|
|
27
|
+
created: number | string;
|
|
28
|
+
updated?: number | string;
|
|
29
|
+
}
|
|
30
|
+
export interface AttachMents {
|
|
31
|
+
[key: string]: AttachMentsItem;
|
|
32
|
+
}
|
|
33
|
+
export interface AttachMentsItem {
|
|
34
|
+
content_type?: string;
|
|
35
|
+
data?: string;
|
|
36
|
+
length?: number;
|
|
37
|
+
shasum?: string;
|
|
38
|
+
version?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface GenericBody {
|
|
41
|
+
[key: string]: string;
|
|
42
|
+
}
|
|
43
|
+
export interface UpLinkMetadata {
|
|
44
|
+
etag: string;
|
|
45
|
+
fetched: number;
|
|
46
|
+
}
|
|
47
|
+
export interface UpLinks {
|
|
48
|
+
[key: string]: UpLinkMetadata;
|
|
49
|
+
}
|
|
50
|
+
export interface Dist {
|
|
51
|
+
integrity?: string;
|
|
52
|
+
shasum: string;
|
|
53
|
+
tarball: string;
|
|
54
|
+
}
|
|
55
|
+
export interface Author {
|
|
56
|
+
name: string;
|
|
57
|
+
email?: string;
|
|
58
|
+
url?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface PackageUsers {
|
|
61
|
+
[key: string]: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface Version {
|
|
64
|
+
name: string;
|
|
65
|
+
version: string;
|
|
66
|
+
devDependencies?: string;
|
|
67
|
+
directories?: any;
|
|
68
|
+
dist: Dist;
|
|
69
|
+
author: string | Author;
|
|
70
|
+
main: string;
|
|
71
|
+
homemage?: string;
|
|
72
|
+
license?: string;
|
|
73
|
+
readme: string;
|
|
74
|
+
readmeFileName?: string;
|
|
75
|
+
readmeFilename?: string;
|
|
76
|
+
description: string;
|
|
77
|
+
bin?: string;
|
|
78
|
+
bugs?: any;
|
|
79
|
+
files?: string[];
|
|
80
|
+
gitHead?: string;
|
|
81
|
+
maintainers?: Author[];
|
|
82
|
+
contributors?: Author[];
|
|
83
|
+
repository?: string | any;
|
|
84
|
+
scripts?: any;
|
|
85
|
+
homepage?: string;
|
|
86
|
+
etag?: string;
|
|
87
|
+
dependencies: any;
|
|
88
|
+
keywords?: string | string[];
|
|
89
|
+
nodeVersion?: string;
|
|
90
|
+
_id: string;
|
|
91
|
+
_npmVersion?: string;
|
|
92
|
+
_npmUser: Author;
|
|
93
|
+
_hasShrinkwrap?: boolean;
|
|
94
|
+
deprecated?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface Versions {
|
|
97
|
+
[key: string]: Version;
|
|
98
|
+
}
|
|
99
|
+
export declare type Package = Manifest;
|
|
100
|
+
export interface Manifest {
|
|
101
|
+
_id?: string;
|
|
102
|
+
name: string;
|
|
103
|
+
versions: Versions;
|
|
104
|
+
'dist-tags': GenericBody;
|
|
105
|
+
time?: GenericBody;
|
|
106
|
+
readme?: string;
|
|
107
|
+
users?: PackageUsers;
|
|
108
|
+
_distfiles: DistFiles;
|
|
109
|
+
_attachments: AttachMents;
|
|
110
|
+
_uplinks: UpLinks;
|
|
111
|
+
_rev: string;
|
|
112
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Callback, HttpError, RemoteUser } from '../commons';
|
|
4
|
+
import { Config } from '../configuration';
|
|
5
|
+
export interface AuthPluginPackage {
|
|
6
|
+
packageName: string;
|
|
7
|
+
packageVersion?: string;
|
|
8
|
+
tag?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare type AuthError = HttpError & {
|
|
11
|
+
code: number;
|
|
12
|
+
};
|
|
13
|
+
export declare type AuthAccessCallback = (error: AuthError | null, access: boolean) => void;
|
|
14
|
+
export declare type AuthCallback = (error: AuthError | null, groups: string[] | false) => void;
|
|
15
|
+
export interface IBasicAuth<T> {
|
|
16
|
+
config: T & Config;
|
|
17
|
+
aesEncrypt(buf: Buffer): Buffer;
|
|
18
|
+
authenticate(user: string, password: string, cb: Callback): void;
|
|
19
|
+
changePassword(user: string, password: string, newPassword: string, cb: Callback): void;
|
|
20
|
+
allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
|
|
21
|
+
add_user(user: string, password: string, cb: Callback): any;
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Config, Logger } from '../configuration';
|
|
2
|
+
export declare class Plugin<T> {
|
|
3
|
+
constructor(config: T, options: PluginOptions<T>);
|
|
4
|
+
}
|
|
5
|
+
export interface IPlugin<T> {
|
|
6
|
+
version?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginOptions<T> {
|
|
9
|
+
config: T & Config;
|
|
10
|
+
logger: Logger;
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RemoteUser } from '../commons';
|
|
2
|
+
import { PackageAccess } from '../manifest';
|
|
3
|
+
import { AuthAccessCallback, AuthCallback } from './auth';
|
|
4
|
+
import { IPlugin } from './commons';
|
|
5
|
+
export interface AllowAccess {
|
|
6
|
+
name: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
tag?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* ```typescript
|
|
12
|
+
* dasdsadsa()
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface IPluginAuth<T> extends IPlugin<T> {
|
|
16
|
+
/**
|
|
17
|
+
* @param props user from Application component
|
|
18
|
+
*/
|
|
19
|
+
authenticate(user: string, password: string, cb: AuthCallback): void;
|
|
20
|
+
adduser?(user: string, password: string, cb: AuthCallback): void;
|
|
21
|
+
changePassword?(user: string, password: string, newPassword: string, cb: AuthCallback): void;
|
|
22
|
+
allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
|
|
23
|
+
allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
|
|
24
|
+
allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
|
|
25
|
+
allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
|
|
26
|
+
allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
|
|
27
|
+
allow_unpublish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
|
|
28
|
+
apiJWTmiddleware?(helpers: any): Function;
|
|
29
|
+
}
|
|
30
|
+
export * from './auth';
|
|
31
|
+
export * from './storage';
|
|
32
|
+
export * from './middleware';
|
|
33
|
+
export * from './commons';
|
|
34
|
+
export * from './filter';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IBasicAuth } from './auth';
|
|
2
|
+
import { IPlugin } from './commons';
|
|
3
|
+
import { IStorageManager } from './storage';
|
|
4
|
+
export interface IPluginMiddleware<T> extends IPlugin<T> {
|
|
5
|
+
register_middlewares(app: any, auth: IBasicAuth<T>, storage: IStorageManager<T>): void;
|
|
6
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PassThrough } from 'stream';
|
|
3
|
+
import { Callback, CallbackAction, StringValue } from '../commons';
|
|
4
|
+
import { Config, Logger } from '../configuration';
|
|
5
|
+
import { MergeTags, Package, Token, Version } from '../manifest';
|
|
6
|
+
import { IPlugin } from './commons';
|
|
7
|
+
export declare class IUploadTarball extends PassThrough {
|
|
8
|
+
abort(): void;
|
|
9
|
+
done(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class IReadTarball extends PassThrough {
|
|
12
|
+
abort(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare type StorageList = string[];
|
|
15
|
+
export interface LocalStorage {
|
|
16
|
+
list: any;
|
|
17
|
+
secret: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ILocalStorage {
|
|
20
|
+
add(name: string): void;
|
|
21
|
+
remove(name: string): void;
|
|
22
|
+
get(): StorageList;
|
|
23
|
+
sync(): void;
|
|
24
|
+
}
|
|
25
|
+
interface TarballActions {
|
|
26
|
+
addTarball(name: string, filename: string): IUploadTarball;
|
|
27
|
+
getTarball(name: string, filename: string): IReadTarball;
|
|
28
|
+
removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
|
|
29
|
+
}
|
|
30
|
+
interface StoragePackageActions extends TarballActions {
|
|
31
|
+
addVersion(name: string, version: string, metadata: Version, tag: StringValue, callback: Callback): void;
|
|
32
|
+
mergeTags(name: string, tags: MergeTags, callback: Callback): void;
|
|
33
|
+
removePackage(name: string, callback: Callback): void;
|
|
34
|
+
changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
|
|
35
|
+
}
|
|
36
|
+
export interface IStorageManager<T> extends StoragePackageActions {
|
|
37
|
+
config: T & Config;
|
|
38
|
+
logger: Logger;
|
|
39
|
+
init(config: T & Config, filters: any): Promise<any>;
|
|
40
|
+
addPackage(name: string, metadata: any, callback: Callback): Promise<any>;
|
|
41
|
+
getPackage(options: any): void;
|
|
42
|
+
search(startkey: string, options: any): IReadTarball;
|
|
43
|
+
getLocalDatabase(callback: Callback): void;
|
|
44
|
+
}
|
|
45
|
+
export interface IBasicStorage<T> extends StoragePackageActions {
|
|
46
|
+
addPackage(name: string, info: Package, callback: Callback): void;
|
|
47
|
+
updateVersions(name: string, packageInfo: Package, callback: Callback): void;
|
|
48
|
+
getPackageMetadata(name: string, callback: Callback): void;
|
|
49
|
+
search(startKey: string, options: any): IReadTarball;
|
|
50
|
+
getSecret(config: T & Config): Promise<any>;
|
|
51
|
+
}
|
|
52
|
+
export interface TokenFilter {
|
|
53
|
+
user: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ITokenActions {
|
|
56
|
+
saveToken(token: Token): Promise<any>;
|
|
57
|
+
deleteToken(user: string, tokenKey: string): Promise<any>;
|
|
58
|
+
readTokens(filter: TokenFilter): Promise<Token[]>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* This method expect return a Package object
|
|
62
|
+
* eg:
|
|
63
|
+
* {
|
|
64
|
+
* name: string;
|
|
65
|
+
* time: number;
|
|
66
|
+
* ... and other props
|
|
67
|
+
* }
|
|
68
|
+
*
|
|
69
|
+
* The `cb` callback object will be executed if:
|
|
70
|
+
* - it might return object (truly)
|
|
71
|
+
* - it might reutrn null
|
|
72
|
+
*/
|
|
73
|
+
export declare type onSearchPackage = (item: Package, cb: CallbackAction) => void;
|
|
74
|
+
export declare type onEndSearchPackage = (error?: any) => void;
|
|
75
|
+
export declare type onValidatePackage = (name: string) => boolean;
|
|
76
|
+
export declare type StorageUpdateCallback = (data: Package, cb: CallbackAction) => void;
|
|
77
|
+
export declare type StorageWriteCallback = (name: string, json: Package, callback: Callback) => void;
|
|
78
|
+
export declare type PackageTransformer = (pkg: Package) => Package;
|
|
79
|
+
export declare type ReadPackageCallback = (err: any | null, data?: Package) => void;
|
|
80
|
+
export interface ILocalPackageManager {
|
|
81
|
+
logger: Logger;
|
|
82
|
+
writeTarball(pkgName: string): IUploadTarball;
|
|
83
|
+
readTarball(pkgName: string): IReadTarball;
|
|
84
|
+
readPackage(fileName: string, callback: ReadPackageCallback): void;
|
|
85
|
+
createPackage(pkgName: string, value: Package, cb: CallbackAction): void;
|
|
86
|
+
deletePackage(fileName: string, callback: CallbackAction): void;
|
|
87
|
+
removePackage(callback: CallbackAction): void;
|
|
88
|
+
updatePackage(pkgFileName: string, updateHandler: StorageUpdateCallback, onWrite: StorageWriteCallback, transformPackage: PackageTransformer, onEnd: CallbackAction): void;
|
|
89
|
+
savePackage(fileName: string, json: Package, callback: CallbackAction): void;
|
|
90
|
+
}
|
|
91
|
+
export declare type IPackageStorage = ILocalPackageManager | void;
|
|
92
|
+
export declare type IPluginStorage<T> = ILocalData<T>;
|
|
93
|
+
export declare type IPackageStorageManager = ILocalPackageManager;
|
|
94
|
+
export interface ILocalData<T> extends IPlugin<T>, ITokenActions {
|
|
95
|
+
logger: Logger;
|
|
96
|
+
config: T & Config;
|
|
97
|
+
add(name: string, callback: Callback): void;
|
|
98
|
+
remove(name: string, callback: Callback): void;
|
|
99
|
+
get(callback: Callback): void;
|
|
100
|
+
getSecret(): Promise<string>;
|
|
101
|
+
setSecret(secret: string): Promise<any>;
|
|
102
|
+
getPackageStorage(packageInfo: string): IPackageStorage;
|
|
103
|
+
search(onPackage: onSearchPackage, onEnd: onEndSearchPackage, validateName: onValidatePackage): void;
|
|
104
|
+
}
|
|
105
|
+
export {};
|
|
File without changes
|
package/build/types.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/types",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.5.1",
|
|
4
4
|
"description": "verdaccio types definitions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"verdaccio",
|
|
@@ -21,18 +21,23 @@
|
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
|
-
"main": "
|
|
25
|
-
"types": "
|
|
24
|
+
"main": "build/types.d.ts",
|
|
25
|
+
"types": "build/types.d.ts",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@types/node": "
|
|
27
|
+
"@types/node": "12.12.6",
|
|
28
|
+
"typedoc": "^0.22.17",
|
|
29
|
+
"typedoc-plugin-missing-exports": "^0.22.6",
|
|
30
|
+
"typedoc-umlclass": "^0.6.1"
|
|
28
31
|
},
|
|
29
32
|
"funding": {
|
|
30
33
|
"type": "opencollective",
|
|
31
34
|
"url": "https://opencollective.com/verdaccio"
|
|
32
35
|
},
|
|
33
36
|
"scripts": {
|
|
37
|
+
"clean": "rimraf ./build",
|
|
34
38
|
"test": "exit 0",
|
|
35
|
-
"build": "
|
|
39
|
+
"build": "tsc --emitDeclarationOnly -p tsconfig.json",
|
|
40
|
+
"docs": "typedoc --options ./typedoc.json --excludeExternals"
|
|
36
41
|
},
|
|
37
|
-
"readme": "# Typescript types
|
|
42
|
+
"readme": "# Typescript types\n\nTypescript definitions for verdaccio plugins and internal code\n\n## Usage\n\nFor usage with the library, the `tsconfig.json` should looks like this.\n\n```\n//tsconfig.json\n{\n \"compilerOptions\": {\n \"target\": \"esnext\",\n \"module\": \"commonjs\",\n \"declaration\": true,\n \"noImplicitAny\": false,\n \"strict\": true,\n \"outDir\": \"lib\",\n \"allowSyntheticDefaultImports\": true,\n \"esModuleInterop\": true,\n \"typeRoots\": [\n \"./node_modules/@verdaccio/types/lib/verdaccio\",\n \"./node_modules/@types\"\n ]\n },\n \"include\": [\n \"src/*.ts\",\n \"types/*.d.ts\"\n ]\n}\n```\n\n### Example\n\n```typescript\nimport type {ILocalData, LocalStorage, Logger, Config} from '@verdaccio/types';\n\n class LocalData implements ILocalData {\n\n path: string;\n logger: Logger;\n data: LocalStorage;\n config: Config;\n locked: boolean;\n ...\n}\n```\n\n#### Plugins\n"
|
|
38
43
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compileOnSave": false,
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "esnext",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"noImplicitAny": false,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"strictNullChecks": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"rootDir": "./src",
|
|
14
|
+
"outDir": "./build"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/index.d.ts
DELETED
|
@@ -1,578 +0,0 @@
|
|
|
1
|
-
// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import { PassThrough } from 'stream';
|
|
4
|
-
|
|
5
|
-
declare module '@verdaccio/types' {
|
|
6
|
-
type StringValue = string | void | null;
|
|
7
|
-
|
|
8
|
-
type StorageList = string[];
|
|
9
|
-
type Callback = Function;
|
|
10
|
-
// FIXME: err should be something flexible enough for any implementation
|
|
11
|
-
type CallbackAction = (err: any | null) => void;
|
|
12
|
-
type CallbackError = (err: NodeJS.ErrnoException) => void;
|
|
13
|
-
interface Author {
|
|
14
|
-
name: string;
|
|
15
|
-
email?: string;
|
|
16
|
-
url?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface Dist {
|
|
20
|
-
integrity?: string;
|
|
21
|
-
shasum: string;
|
|
22
|
-
tarball: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface RemoteUser {
|
|
26
|
-
real_groups: string[];
|
|
27
|
-
groups: string[];
|
|
28
|
-
name: string | void;
|
|
29
|
-
error?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface LocalStorage {
|
|
33
|
-
list: any;
|
|
34
|
-
secret: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface Version {
|
|
38
|
-
name: string;
|
|
39
|
-
version: string;
|
|
40
|
-
devDependencies?: string;
|
|
41
|
-
directories?: any;
|
|
42
|
-
dist: Dist;
|
|
43
|
-
author: string | Author;
|
|
44
|
-
main: string;
|
|
45
|
-
homemage?: string;
|
|
46
|
-
license?: string;
|
|
47
|
-
readme: string;
|
|
48
|
-
readmeFileName?: string;
|
|
49
|
-
readmeFilename?: string;
|
|
50
|
-
description: string;
|
|
51
|
-
bin?: string;
|
|
52
|
-
bugs?: any;
|
|
53
|
-
files?: string[];
|
|
54
|
-
gitHead?: string;
|
|
55
|
-
maintainers?: Author[];
|
|
56
|
-
contributors?: Author[];
|
|
57
|
-
repository?: string | any;
|
|
58
|
-
scripts?: any;
|
|
59
|
-
homepage?: string;
|
|
60
|
-
etag?: string;
|
|
61
|
-
dependencies: any;
|
|
62
|
-
keywords?: string | string[];
|
|
63
|
-
nodeVersion?: string;
|
|
64
|
-
_id: string;
|
|
65
|
-
_npmVersion?: string;
|
|
66
|
-
_npmUser: Author;
|
|
67
|
-
_hasShrinkwrap?: boolean;
|
|
68
|
-
deprecated?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface Logger {
|
|
72
|
-
child: (conf: any) => any;
|
|
73
|
-
debug: (conf: any, template?: string) => void;
|
|
74
|
-
error: (conf: any, template?: string) => void;
|
|
75
|
-
http: (conf: any, template?: string) => void;
|
|
76
|
-
trace: (conf: any, template?: string) => void;
|
|
77
|
-
warn: (conf: any, template?: string) => void;
|
|
78
|
-
info: (conf: any, template?: string) => void;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
interface Versions {
|
|
82
|
-
[key: string]: Version;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
interface DistFile {
|
|
86
|
-
url: string;
|
|
87
|
-
sha: string;
|
|
88
|
-
registry?: string;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
interface MergeTags {
|
|
92
|
-
[key: string]: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
interface DistFiles {
|
|
96
|
-
[key: string]: DistFile;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
interface AttachMents {
|
|
100
|
-
[key: string]: AttachMentsItem;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
interface AttachMentsItem {
|
|
104
|
-
content_type?: string;
|
|
105
|
-
data?: string;
|
|
106
|
-
length?: number;
|
|
107
|
-
shasum?: string;
|
|
108
|
-
version?: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
interface GenericBody {
|
|
112
|
-
[key: string]: string;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
interface UpLinkMetadata {
|
|
116
|
-
etag: string;
|
|
117
|
-
fetched: number;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
interface UpLinks {
|
|
121
|
-
[key: string]: UpLinkMetadata;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
interface Tags {
|
|
125
|
-
[key: string]: Version;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
interface Headers {
|
|
129
|
-
[key: string]: string;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
interface PackageUsers {
|
|
133
|
-
[key: string]: boolean;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
interface Package {
|
|
137
|
-
_id?: string;
|
|
138
|
-
name: string;
|
|
139
|
-
versions: Versions;
|
|
140
|
-
'dist-tags': GenericBody;
|
|
141
|
-
time?: GenericBody;
|
|
142
|
-
readme?: string;
|
|
143
|
-
users?: PackageUsers;
|
|
144
|
-
_distfiles: DistFiles;
|
|
145
|
-
_attachments: AttachMents;
|
|
146
|
-
_uplinks: UpLinks;
|
|
147
|
-
_rev: string;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
class IUploadTarball extends PassThrough {
|
|
151
|
-
abort(): void;
|
|
152
|
-
done(): void;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
class IReadTarball extends PassThrough {
|
|
156
|
-
abort(): void;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
interface UpLinkTokenConf {
|
|
160
|
-
type: 'Bearer' | 'Basic';
|
|
161
|
-
token?: string;
|
|
162
|
-
token_env?: boolean | string;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
interface UpLinkConf {
|
|
166
|
-
url: string;
|
|
167
|
-
ca?: string;
|
|
168
|
-
cache?: boolean;
|
|
169
|
-
timeout?: string | void;
|
|
170
|
-
maxage?: string | void;
|
|
171
|
-
max_fails?: number | void;
|
|
172
|
-
fail_timeout?: string | void;
|
|
173
|
-
headers?: Headers;
|
|
174
|
-
auth?: UpLinkTokenConf;
|
|
175
|
-
strict_ssl?: boolean | void;
|
|
176
|
-
_autogenerated?: boolean;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
interface AuthPluginPackage {
|
|
180
|
-
packageName: string;
|
|
181
|
-
packageVersion?: string;
|
|
182
|
-
tag?: string;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
interface PackageAccess {
|
|
186
|
-
storage?: string;
|
|
187
|
-
publish?: string[];
|
|
188
|
-
proxy?: string[];
|
|
189
|
-
access?: string[];
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
interface PackageList {
|
|
193
|
-
[key: string]: PackageAccess;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
interface UpLinksConfList {
|
|
197
|
-
[key: string]: UpLinkConf;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
type LoggerType = 'stdout' | 'stderr' | 'file';
|
|
201
|
-
type LoggerFormat = 'pretty' | 'pretty-timestamped' | 'file';
|
|
202
|
-
type LoggerLevel = 'http' | 'fatal' | 'warn' | 'info' | 'debug' | 'trace';
|
|
203
|
-
|
|
204
|
-
interface LoggerConfItem {
|
|
205
|
-
type: LoggerType;
|
|
206
|
-
format: LoggerFormat;
|
|
207
|
-
level: LoggerLevel;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
interface PublishOptions {
|
|
211
|
-
allow_offline: boolean;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
type AuthConf = any | AuthHtpasswd;
|
|
215
|
-
|
|
216
|
-
interface AuthHtpasswd {
|
|
217
|
-
file: string;
|
|
218
|
-
max_users: number;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
interface Notifications {
|
|
222
|
-
method: string;
|
|
223
|
-
packagePattern: RegExp;
|
|
224
|
-
packagePatternFlags: string;
|
|
225
|
-
endpoint: string;
|
|
226
|
-
content: string;
|
|
227
|
-
headers: Headers;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
interface ConfigFile {
|
|
231
|
-
storage: string;
|
|
232
|
-
plugins: string;
|
|
233
|
-
self_path: string;
|
|
234
|
-
packages: PackageList;
|
|
235
|
-
uplinks: UpLinksConfList;
|
|
236
|
-
logs: LoggerConf[];
|
|
237
|
-
web: WebConf;
|
|
238
|
-
auth: AuthConf;
|
|
239
|
-
publish?: PublishOptions;
|
|
240
|
-
url_prefix?: string;
|
|
241
|
-
listen?: ListenAddress;
|
|
242
|
-
https?: HttpsConf;
|
|
243
|
-
http_proxy?: string;
|
|
244
|
-
https_proxy?: string;
|
|
245
|
-
no_proxy?: string;
|
|
246
|
-
max_body_size?: string;
|
|
247
|
-
notifications: Notifications;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
interface Token {
|
|
251
|
-
user: string;
|
|
252
|
-
token: string;
|
|
253
|
-
key: string;
|
|
254
|
-
cidr?: string[];
|
|
255
|
-
readonly: boolean;
|
|
256
|
-
created: number | string;
|
|
257
|
-
updated?: number | string;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
interface TokenFilter {
|
|
261
|
-
user: string;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
type SyncReturn = Error | void;
|
|
265
|
-
type IPackageStorage = ILocalPackageManager | void;
|
|
266
|
-
type IPackageStorageManager = ILocalPackageManager;
|
|
267
|
-
type IPluginStorage<T> = ILocalData<T>;
|
|
268
|
-
|
|
269
|
-
interface AuthHtpasswd {
|
|
270
|
-
file: string;
|
|
271
|
-
max_users: number;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
interface ILocalStorage {
|
|
275
|
-
add(name: string): void;
|
|
276
|
-
remove(name: string): void;
|
|
277
|
-
get(): StorageList;
|
|
278
|
-
sync(): void;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
interface LoggerConf {
|
|
282
|
-
[key: string]: LoggerConfItem;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
interface ListenAddress {
|
|
286
|
-
[key: string]: string;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
interface WebConf {
|
|
290
|
-
enable?: boolean;
|
|
291
|
-
title?: string;
|
|
292
|
-
logo?: string;
|
|
293
|
-
favicon?: string;
|
|
294
|
-
gravatar?: boolean;
|
|
295
|
-
sort_packages?: string;
|
|
296
|
-
rateLimit?: RateLimit;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
interface HttpsConfKeyCert {
|
|
300
|
-
key: string;
|
|
301
|
-
cert: string;
|
|
302
|
-
ca?: string;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
interface HttpsConfPfx {
|
|
306
|
-
pfx: string;
|
|
307
|
-
passphrase?: string;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
type HttpsConf = HttpsConfKeyCert | HttpsConfPfx;
|
|
311
|
-
|
|
312
|
-
interface JWTOptions {
|
|
313
|
-
sign: JWTSignOptions;
|
|
314
|
-
verify: JWTVerifyOptions;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
interface JWTVerifyOptions {
|
|
318
|
-
algorithm?: string;
|
|
319
|
-
expiresIn?: string;
|
|
320
|
-
notBefore?: string | number;
|
|
321
|
-
ignoreExpiration?: boolean;
|
|
322
|
-
maxAge?: string | number;
|
|
323
|
-
clockTimestamp?: number;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
interface JWTSignOptions {
|
|
327
|
-
algorithm?: string;
|
|
328
|
-
expiresIn?: string;
|
|
329
|
-
notBefore?: string;
|
|
330
|
-
ignoreExpiration?: boolean;
|
|
331
|
-
maxAge?: string | number;
|
|
332
|
-
clockTimestamp?: number;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
interface APITokenOptions {
|
|
336
|
-
legacy: boolean;
|
|
337
|
-
jwt?: JWTOptions;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
type RateLimit = {
|
|
341
|
-
windowMs?: number;
|
|
342
|
-
max?: number;
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
interface Security {
|
|
346
|
-
web: JWTOptions;
|
|
347
|
-
api: APITokenOptions;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
export type ServerSettingsConf = {
|
|
351
|
-
// express-rate-limit settings
|
|
352
|
-
rateLimit: RateLimit;
|
|
353
|
-
keepAliveTimeout?: number;
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
interface ConfigYaml {
|
|
357
|
-
_debug?: boolean;
|
|
358
|
-
storage?: string | void;
|
|
359
|
-
packages: PackageList;
|
|
360
|
-
uplinks: UpLinksConfList;
|
|
361
|
-
// FUTURE: log should be mandatory
|
|
362
|
-
logs?: LoggerConfItem;
|
|
363
|
-
web?: WebConf;
|
|
364
|
-
auth?: AuthConf;
|
|
365
|
-
security: Security;
|
|
366
|
-
publish?: PublishOptions;
|
|
367
|
-
store?: any;
|
|
368
|
-
listen?: ListenAddress;
|
|
369
|
-
https?: HttpsConf;
|
|
370
|
-
http_proxy?: string;
|
|
371
|
-
plugins?: string | void;
|
|
372
|
-
https_proxy?: string;
|
|
373
|
-
no_proxy?: string;
|
|
374
|
-
max_body_size?: string;
|
|
375
|
-
notifications?: Notifications;
|
|
376
|
-
notify?: Notifications | Notifications[];
|
|
377
|
-
middlewares?: any;
|
|
378
|
-
filters?: any;
|
|
379
|
-
url_prefix?: string;
|
|
380
|
-
server?: ServerSettingsConf;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
interface ConfigRuntime extends ConfigYaml {
|
|
384
|
-
// @deprecated on v6 this is config_path
|
|
385
|
-
self_path: string;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
interface Config extends ConfigYaml, ConfigRuntime {
|
|
389
|
-
user_agent: string;
|
|
390
|
-
server_id: string;
|
|
391
|
-
secret: string;
|
|
392
|
-
// deprecated
|
|
393
|
-
checkSecretKey(token: string): string;
|
|
394
|
-
getMatchedPackagesSpec(storage: string): PackageAccess | void;
|
|
395
|
-
[key: string]: any;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
interface ConfigWithHttps extends Config {
|
|
399
|
-
https: HttpsConf;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
interface ITokenActions {
|
|
403
|
-
saveToken(token: Token): Promise<any>;
|
|
404
|
-
deleteToken(user: string, tokenKey: string): Promise<any>;
|
|
405
|
-
readTokens(filter: TokenFilter): Promise<Token[]>;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* This method expect return a Package object
|
|
410
|
-
* eg:
|
|
411
|
-
* {
|
|
412
|
-
* name: string;
|
|
413
|
-
* time: number;
|
|
414
|
-
* ... and other props
|
|
415
|
-
* }
|
|
416
|
-
*
|
|
417
|
-
* The `cb` callback object will be executed if:
|
|
418
|
-
* - it might return object (truly)
|
|
419
|
-
* - it might reutrn null
|
|
420
|
-
*/
|
|
421
|
-
type onSearchPackage = (item: Package, cb: CallbackAction) => void;
|
|
422
|
-
// FIXME: error should be export type `VerdaccioError = HttpError & { code: number };`
|
|
423
|
-
// but this type is on @verdaccio/commons-api and cannot be used here yet
|
|
424
|
-
type onEndSearchPackage = (error?: any) => void;
|
|
425
|
-
type onValidatePackage = (name: string) => boolean;
|
|
426
|
-
|
|
427
|
-
interface ILocalData<T> extends IPlugin<T>, ITokenActions {
|
|
428
|
-
logger: Logger;
|
|
429
|
-
config: T & Config;
|
|
430
|
-
add(name: string, callback: Callback): void;
|
|
431
|
-
remove(name: string, callback: Callback): void;
|
|
432
|
-
get(callback: Callback): void;
|
|
433
|
-
getSecret(): Promise<string>;
|
|
434
|
-
setSecret(secret: string): Promise<any>;
|
|
435
|
-
getPackageStorage(packageInfo: string): IPackageStorage;
|
|
436
|
-
search(
|
|
437
|
-
onPackage: onSearchPackage,
|
|
438
|
-
onEnd: onEndSearchPackage,
|
|
439
|
-
validateName: onValidatePackage
|
|
440
|
-
): void;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
type StorageUpdateCallback = (data: Package, cb: CallbackAction) => void;
|
|
444
|
-
type StorageUpdateHandler = (name: string, cb: StorageUpdateCallback) => void;
|
|
445
|
-
type StorageWriteCallback = (name: string, json: Package, callback: Callback) => void;
|
|
446
|
-
type PackageTransformer = (pkg: Package) => Package;
|
|
447
|
-
type ReadPackageCallback = (err: any | null, data?: Package) => void;
|
|
448
|
-
|
|
449
|
-
interface ILocalPackageManager {
|
|
450
|
-
logger: Logger;
|
|
451
|
-
writeTarball(pkgName: string): IUploadTarball;
|
|
452
|
-
readTarball(pkgName: string): IReadTarball;
|
|
453
|
-
readPackage(fileName: string, callback: ReadPackageCallback): void;
|
|
454
|
-
createPackage(pkgName: string, value: Package, cb: CallbackAction): void;
|
|
455
|
-
deletePackage(fileName: string, callback: CallbackAction): void;
|
|
456
|
-
removePackage(callback: CallbackAction): void;
|
|
457
|
-
updatePackage(
|
|
458
|
-
pkgFileName: string,
|
|
459
|
-
updateHandler: StorageUpdateCallback,
|
|
460
|
-
onWrite: StorageWriteCallback,
|
|
461
|
-
transformPackage: PackageTransformer,
|
|
462
|
-
onEnd: CallbackAction
|
|
463
|
-
): void;
|
|
464
|
-
savePackage(fileName: string, json: Package, callback: CallbackAction): void;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
interface TarballActions {
|
|
468
|
-
addTarball(name: string, filename: string): IUploadTarball;
|
|
469
|
-
getTarball(name: string, filename: string): IReadTarball;
|
|
470
|
-
removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
interface StoragePackageActions extends TarballActions {
|
|
474
|
-
addVersion(
|
|
475
|
-
name: string,
|
|
476
|
-
version: string,
|
|
477
|
-
metadata: Version,
|
|
478
|
-
tag: StringValue,
|
|
479
|
-
callback: Callback
|
|
480
|
-
): void;
|
|
481
|
-
mergeTags(name: string, tags: MergeTags, callback: Callback): void;
|
|
482
|
-
removePackage(name: string, callback: Callback): void;
|
|
483
|
-
changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
interface IStorageManager<T> extends StoragePackageActions {
|
|
487
|
-
config: T & Config;
|
|
488
|
-
logger: Logger;
|
|
489
|
-
init(config: T & Config, filters: any): Promise<any>;
|
|
490
|
-
addPackage(name: string, metadata: any, callback: Callback): Promise<any>;
|
|
491
|
-
getPackage(options: any): void;
|
|
492
|
-
search(startkey: string, options: any): IReadTarball;
|
|
493
|
-
getLocalDatabase(callback: Callback): void;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
interface IBasicStorage<T> extends StoragePackageActions {
|
|
497
|
-
addPackage(name: string, info: Package, callback: Callback): void;
|
|
498
|
-
updateVersions(name: string, packageInfo: Package, callback: Callback): void;
|
|
499
|
-
getPackageMetadata(name: string, callback: Callback): void;
|
|
500
|
-
search(startKey: string, options: any): IReadTarball;
|
|
501
|
-
getSecret(config: T & Config): Promise<any>;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
interface IBasicAuth<T> {
|
|
505
|
-
config: T & Config;
|
|
506
|
-
aesEncrypt(buf: Buffer): Buffer;
|
|
507
|
-
authenticate(user: string, password: string, cb: Callback): void;
|
|
508
|
-
changePassword(user: string, password: string, newPassword: string, cb: Callback): void;
|
|
509
|
-
allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
|
|
510
|
-
add_user(user: string, password: string, cb: Callback): any;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
class Plugin<T> {
|
|
514
|
-
constructor(config: T, options: PluginOptions<T>);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
interface IPlugin<T> {
|
|
518
|
-
version?: string;
|
|
519
|
-
// In case a plugin needs to be cleaned up/removed
|
|
520
|
-
close?(): void;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
interface PluginOptions<T> {
|
|
524
|
-
config: T & Config;
|
|
525
|
-
logger: Logger;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
interface AllowAccess {
|
|
529
|
-
name: string;
|
|
530
|
-
version?: string;
|
|
531
|
-
tag?: string;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// FIXME: error should be export type `VerdaccioError = HttpError & { code: number };` instead of AuthError
|
|
535
|
-
// but this type is on @verdaccio/commons-api and cannot be used here yet (I don't know why)
|
|
536
|
-
interface HttpError extends Error {
|
|
537
|
-
status: number;
|
|
538
|
-
statusCode: number;
|
|
539
|
-
expose: boolean;
|
|
540
|
-
headers?: {
|
|
541
|
-
[key: string]: string;
|
|
542
|
-
};
|
|
543
|
-
[key: string]: any;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
type AuthError = HttpError & { code: number };
|
|
547
|
-
type AuthAccessCallback = (error: AuthError | null, access: boolean) => void;
|
|
548
|
-
type AuthCallback = (error: AuthError | null, groups: string[] | false) => void;
|
|
549
|
-
|
|
550
|
-
interface IPluginAuth<T> extends IPlugin<T> {
|
|
551
|
-
authenticate(user: string, password: string, cb: AuthCallback): void;
|
|
552
|
-
adduser?(user: string, password: string, cb: AuthCallback): void;
|
|
553
|
-
changePassword?(user: string, password: string, newPassword: string, cb: AuthCallback): void;
|
|
554
|
-
allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
|
|
555
|
-
allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
|
|
556
|
-
allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
|
|
557
|
-
allow_publish?(
|
|
558
|
-
user: RemoteUser,
|
|
559
|
-
pkg: AllowAccess & PackageAccess,
|
|
560
|
-
cb: AuthAccessCallback
|
|
561
|
-
): void;
|
|
562
|
-
allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
|
|
563
|
-
allow_unpublish?(
|
|
564
|
-
user: RemoteUser,
|
|
565
|
-
pkg: AllowAccess & PackageAccess,
|
|
566
|
-
cb: AuthAccessCallback
|
|
567
|
-
): void;
|
|
568
|
-
apiJWTmiddleware?(helpers: any): Function;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
interface IPluginMiddleware<T> extends IPlugin<T> {
|
|
572
|
-
register_middlewares(app: any, auth: IBasicAuth<T>, storage: IStorageManager<T>): void;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
interface IPluginStorageFilter<T> extends IPlugin<T> {
|
|
576
|
-
filter_metadata(packageInfo: Package): Promise<Package>;
|
|
577
|
-
}
|
|
578
|
-
}
|