From b2e88d12a1572004f1f957e042e330c92a2fb0e0 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Mon, 16 Jul 2018 20:50:29 +0200 Subject: [PATCH] chore: add sub type example with flow --- package.json | 2 +- test/flow/plugins/auth/example.auth.plugin.js | 34 ++++++++++++++++++ yarn.lock | Bin 348500 -> 348500 bytes 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8ea99371f..b68f4f8b0 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/flow/plugins/auth/example.auth.plugin.js b/test/flow/plugins/auth/example.auth.plugin.js index f3e3d4728..9ece36b22 100644 --- a/test/flow/plugins/auth/example.auth.plugin.js +++ b/test/flow/plugins/auth/example.auth.plugin.js @@ -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}, () => {}); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 0eafbcc11b48659386edd4f64927dbcaf2379a5a..9e8e9ba24dd7ca88c256958a0fab4e7672c3acea 100644 GIT binary patch delta 114 zcmcbzNc74g(G3$61q_v}xD*u1Qj3Z+^Yavxj3+0?=uTcQ&pr8uqL7}UUP*eDa#E_H zMOu=XrD;-fih-d?vZYC~g=Lbtg@I{ea;mXeO0s22qLG=g+2lrL;bv{6c5Nj_AZ7w$ OW*}zSuC2tXsSf}~n<19~ delta 100 zcmcbzNc74g(G3$6nGBSs{}W}gp1fY3d-4rMAzcH#lJqKNV@pHRG?OG_%S4M*OS4o{ z6Z2G)6k|)Xq%;!)vlR1GW1~b9Q