chore: add sub type example with flow

This commit is contained in:
Juan Picado @jotadeveloper 2018-07-16 20:50:29 +02:00
parent 2f4dbe8564
commit b2e88d12a1
No known key found for this signature in database
GPG Key ID: 18AC54485952D158
3 changed files with 38 additions and 4 deletions

View File

@ -52,7 +52,7 @@
"devDependencies": {
"@commitlint/cli": "6.1.3",
"@commitlint/config-conventional": "6.1.3",
"@verdaccio/types": "3.4.0",
"@verdaccio/types": "3.4.1",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-eslint": "8.2.2",

View File

@ -40,6 +40,36 @@ class ExampleAuthPlugin implements IPluginAuth {
}
}
type SubTypePackageAccess = PackageAccess & {
sub?: boolean
}
class ExampleAuthCustomPlugin implements IPluginAuth {
config: AppConfig;
logger: Logger;
constructor(config: AppConfig, options: PluginOptions) {
this.config = config;
this.logger = options.logger;
}
adduser(user: string, password: string, cb: verdaccio$Callback): void {
cb();
}
authenticate(user: string, password: string, cb: verdaccio$Callback): void {
cb();
}
allow_access(user: RemoteUser, pkg: SubTypePackageAccess, cb: verdaccio$Callback): void {
cb();
}
allow_publish(user: RemoteUser, pkg: SubTypePackageAccess, cb: verdaccio$Callback): void {
cb();
}
}
const config1: AppConfig = new Config({
storage: './storage',
self_path: '/home/sotrage'
@ -51,6 +81,7 @@ const options: PluginOptions = {
}
const auth = new ExampleAuthPlugin(config1, options);
const authSub = new ExampleAuthCustomPlugin(config1, options);
const remoteUser: RemoteUser = {
groups: [],
real_groups: [],
@ -60,3 +91,6 @@ const remoteUser: RemoteUser = {
auth.authenticate('user', 'pass', () => {});
auth.allow_access(remoteUser, {}, () => {});
auth.allow_publish(remoteUser, {}, () => {});
authSub.authenticate('user', 'pass', () => {});
authSub.allow_access(remoteUser, {sub: true}, () => {});
authSub.allow_publish(remoteUser, {sub: true}, () => {});

View File

@ -234,9 +234,9 @@
version "1.0.0"
resolved "https://registry.npmjs.org/@verdaccio/streams/-/streams-1.0.0.tgz#d5d24c6747208728b9fd16b908e3932c3fb1f864"
"@verdaccio/types@3.4.0":
version "3.4.0"
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-3.4.0.tgz#3915f4b39a8e96e547e4d396bf406d7e32a454d9"
"@verdaccio/types@3.4.1":
version "3.4.1"
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-3.4.1.tgz#be18fb695bcd014c94c89b7805ace36dc9da2636"
"@webassemblyjs/ast@1.5.9":
version "1.5.9"