@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,22 @@
|
|
|
1
|
+
import { Callback, HttpError, RemoteUser } from '../commons';
|
|
2
|
+
import { Config } from '../configuration';
|
|
3
|
+
|
|
4
|
+
export interface AuthPluginPackage {
|
|
5
|
+
packageName: string;
|
|
6
|
+
packageVersion?: string;
|
|
7
|
+
tag?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type AuthError = HttpError & { code: number };
|
|
11
|
+
export type AuthAccessCallback = (error: AuthError | null, access: boolean) => void;
|
|
12
|
+
export type AuthCallback = (error: AuthError | null, groups: string[] | false) => void;
|
|
13
|
+
|
|
14
|
+
// @deprecated use IBasicAuth from @verdaccio/auth
|
|
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,15 @@
|
|
|
1
|
+
import { Config, Logger } from '../configuration';
|
|
2
|
+
|
|
3
|
+
export class Plugin<T> {
|
|
4
|
+
public constructor(config: T, options: PluginOptions<T>) {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface IPlugin<T> {
|
|
8
|
+
// TODO: not used on core yet
|
|
9
|
+
version?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface PluginOptions<T> {
|
|
13
|
+
config: T & Config;
|
|
14
|
+
logger: Logger;
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RemoteUser } from '../commons';
|
|
2
|
+
import { AllowAccess } from '../configuration';
|
|
3
|
+
import { PackageAccess } from '../manifest';
|
|
4
|
+
import { AuthAccessCallback, AuthCallback } from './auth';
|
|
5
|
+
import { IPlugin } from './commons';
|
|
6
|
+
|
|
7
|
+
export interface IPluginAuth<T> extends IPlugin<T> {
|
|
8
|
+
/**
|
|
9
|
+
* @param props user from Application component
|
|
10
|
+
*/
|
|
11
|
+
authenticate(user: string, password: string, cb: AuthCallback): void;
|
|
12
|
+
adduser?(user: string, password: string, cb: AuthCallback): void;
|
|
13
|
+
changePassword?(user: string, password: string, newPassword: string, cb: AuthCallback): void;
|
|
14
|
+
allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
|
|
15
|
+
allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
|
|
16
|
+
allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
|
|
17
|
+
allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
|
|
18
|
+
allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
|
|
19
|
+
allow_unpublish?(
|
|
20
|
+
user: RemoteUser,
|
|
21
|
+
pkg: AllowAccess & PackageAccess,
|
|
22
|
+
cb: AuthAccessCallback
|
|
23
|
+
): void;
|
|
24
|
+
apiJWTmiddleware?(helpers: any): Function;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export * from './auth';
|
|
28
|
+
export * from './storage';
|
|
29
|
+
export * from './middleware';
|
|
30
|
+
export * from './commons';
|
|
31
|
+
export * from './filter';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Config } from '../configuration';
|
|
2
|
+
import { IBasicAuth } from './auth';
|
|
3
|
+
import { IPlugin } from './commons';
|
|
4
|
+
|
|
5
|
+
// TODO: convert to generic storage should come from implementation
|
|
6
|
+
export interface IPluginMiddleware<T, K> extends IPlugin<T> {
|
|
7
|
+
register_middlewares(app: any, auth: IBasicAuth<T>, storage: K): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { PassThrough, PipelinePromise, Readable, Stream, Writable } from 'stream';
|
|
2
|
+
|
|
3
|
+
import { Callback, CallbackAction, StringValue } from '../commons';
|
|
4
|
+
import { Config, Logger } from '../configuration';
|
|
5
|
+
import { Manifest, MergeTags, Token, Version } from '../manifest';
|
|
6
|
+
import { IPlugin } from './commons';
|
|
7
|
+
|
|
8
|
+
export type StorageList = string[];
|
|
9
|
+
|
|
10
|
+
export interface LocalStorage {
|
|
11
|
+
list: any;
|
|
12
|
+
secret: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ILocalStorage {
|
|
16
|
+
add(name: string): void;
|
|
17
|
+
remove(name: string): void;
|
|
18
|
+
get(): StorageList;
|
|
19
|
+
sync(): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface TokenFilter {
|
|
23
|
+
user: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ITokenActions {
|
|
27
|
+
saveToken(token: Token): Promise<any>;
|
|
28
|
+
deleteToken(user: string, tokenKey: string): Promise<any>;
|
|
29
|
+
readTokens(filter: TokenFilter): Promise<Token[]>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* This method expect return a Package object
|
|
34
|
+
* eg:
|
|
35
|
+
* {
|
|
36
|
+
* name: string;
|
|
37
|
+
* time: number;
|
|
38
|
+
* ... and other props
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* The `cb` callback object will be executed if:
|
|
42
|
+
* - it might return object (truly)
|
|
43
|
+
* - it might reutrn null
|
|
44
|
+
*/
|
|
45
|
+
export type onSearchPackage = (item: Manifest, cb: CallbackAction) => void;
|
|
46
|
+
// FIXME: error should be export type `VerdaccioError = HttpError & { code: number };`
|
|
47
|
+
// but this type is on @verdaccio/commons-api and cannot be used here yet
|
|
48
|
+
export type onEndSearchPackage = (error?: any) => void;
|
|
49
|
+
export type onValidatePackage = (name: string) => boolean;
|
|
50
|
+
|
|
51
|
+
export type StorageUpdateCallback = (data: Manifest, cb: CallbackAction) => void;
|
|
52
|
+
|
|
53
|
+
export type StorageWriteCallback = (name: string, json: Manifest, callback: Callback) => void;
|
|
54
|
+
export type PackageTransformer = (pkg: Manifest) => Manifest;
|
|
55
|
+
export type ReadPackageCallback = (err: any | null, data?: Manifest) => void;
|
|
56
|
+
|
|
57
|
+
export interface ILocalPackageManager {
|
|
58
|
+
logger: Logger;
|
|
59
|
+
deletePackage(fileName: string): Promise<void>;
|
|
60
|
+
removePackage(): Promise<void>;
|
|
61
|
+
// next packages migration (this list is meant to replace the callback parent functions)
|
|
62
|
+
updatePackage(
|
|
63
|
+
packageName: string,
|
|
64
|
+
handleUpdate: (manifest: Manifest) => Promise<Manifest>
|
|
65
|
+
): Promise<Manifest>;
|
|
66
|
+
readPackage(name: string): Promise<Manifest>;
|
|
67
|
+
savePackage(pkgName: string, value: Manifest): Promise<void>;
|
|
68
|
+
readTarball(pkgName: string, { signal }): Promise<Readable>;
|
|
69
|
+
createPackage(name: string, manifest: Manifest): Promise<void>;
|
|
70
|
+
writeTarball(tarballName: string, { signal }): Promise<Writable>;
|
|
71
|
+
// verify if tarball exist in the storage
|
|
72
|
+
hasTarball(fileName: string): Promise<boolean>;
|
|
73
|
+
// verify if package exist in the storage
|
|
74
|
+
hasPackage(): Promise<boolean>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type IPackageStorage = ILocalPackageManager | void;
|
|
78
|
+
|
|
79
|
+
export type IPluginStorage<T> = ILocalData<T>;
|
|
80
|
+
export type IPackageStorageManager = ILocalPackageManager;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated use @verdaccio/core pluginUtils instead
|
|
84
|
+
*/
|
|
85
|
+
interface ILocalData<T> extends IPlugin<T>, ITokenActions {
|
|
86
|
+
logger: Logger;
|
|
87
|
+
config: T & Config;
|
|
88
|
+
add(name: string): Promise<void>;
|
|
89
|
+
remove(name: string): Promise<void>;
|
|
90
|
+
get(): Promise<any>;
|
|
91
|
+
init(): Promise<void>;
|
|
92
|
+
getSecret(): Promise<string>;
|
|
93
|
+
setSecret(secret: string): Promise<any>;
|
|
94
|
+
getPackageStorage(packageInfo: string): IPackageStorage;
|
|
95
|
+
}
|
|
File without changes
|
package/src/search.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type PublisherMaintainer = {
|
|
2
|
+
username: string;
|
|
3
|
+
email: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type SearchPackageBody = {
|
|
7
|
+
name: string;
|
|
8
|
+
scope: string;
|
|
9
|
+
description: string;
|
|
10
|
+
author: string | PublisherMaintainer;
|
|
11
|
+
version: string;
|
|
12
|
+
keywords: string | string[] | undefined;
|
|
13
|
+
date: string;
|
|
14
|
+
links?: {
|
|
15
|
+
npm: string; // only include placeholder for URL eg: {url}/{packageName}
|
|
16
|
+
homepage?: string;
|
|
17
|
+
repository?: string;
|
|
18
|
+
bugs?: string;
|
|
19
|
+
};
|
|
20
|
+
publisher?: any;
|
|
21
|
+
maintainers?: PublisherMaintainer[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type SearchResultWeb = {
|
|
25
|
+
name: string;
|
|
26
|
+
version: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
package/src/types.ts
ADDED
package/tsconfig.json
ADDED