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