@@ -38,18 +38,14 @@ const BUILTIN_ACCESS_LEVEL_ANONYMOUS = ['$anonymous', '$all'];
3838// Level to apply on 'allow_access' calls when a package definition does not define one
3939const DEFAULT_ALLOW_ACCESS_LEVEL = [ '$all' ] ;
4040
41- export interface VerdaccioGitLabPlugin extends IPluginAuth < VerdaccioGitlabConfig > {
42- authCache ?: AuthCache ;
43- }
44-
45- export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
46- options : PluginOptions < VerdaccioGitlabConfig > ;
47- config : VerdaccioGitlabConfig ;
48- authCache ?: AuthCache ;
49- logger : Logger ;
50- publishLevel : VerdaccioGitlabAccessLevel ;
51-
52- constructor ( config : VerdaccioGitlabConfig , options : PluginOptions < VerdaccioGitlabConfig > ) {
41+ export default class VerdaccioGitLab implements IPluginAuth < VerdaccioGitlabConfig > {
42+ private options : PluginOptions < VerdaccioGitlabConfig > ;
43+ private config : VerdaccioGitlabConfig ;
44+ private authCache ?: AuthCache ;
45+ private logger : Logger ;
46+ private publishLevel : VerdaccioGitlabAccessLevel ;
47+
48+ public constructor ( config : VerdaccioGitlabConfig , options : PluginOptions < VerdaccioGitlabConfig > ) {
5349 this . logger = options . logger ;
5450 this . config = config ;
5551 this . options = options ;
@@ -75,14 +71,13 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
7571 this . logger . info ( `[gitlab] publish control level: ${ this . publishLevel } ` ) ;
7672 }
7773
78- authenticate ( user : string , password : string , cb : Callback ) {
74+ public authenticate ( user : string , password : string , cb : Callback ) {
7975 this . logger . trace ( `[gitlab] authenticate called for user: ${ user } ` ) ;
8076
8177 // Try to find the user groups in the cache
8278 const cachedUserGroups = this . _getCachedUserGroups ( user , password ) ;
8379 if ( cachedUserGroups ) {
84- // @ts -ignore
85- this . logger . debug ( `[gitlab] user: ${ user } found in cache, authenticated with groups:` , cachedUserGroups ) ;
80+ this . logger . debug ( `[gitlab] user: ${ user } found in cache, authenticated with groups:` , cachedUserGroups . toString ( ) ) ;
8681 return cb ( null , cachedUserGroups . publish ) ;
8782 }
8883
@@ -107,8 +102,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
107102 // - for publish, the logged in user id and all the groups they can reach as configured with access level `$auth.gitlab.publish`
108103 const gitlabPublishQueryParams = { min_access_level : publishLevelId } ;
109104
110- // @ts -ignore
111- this . logger . trace ( '[gitlab] querying gitlab user groups with params:' , gitlabPublishQueryParams ) ;
105+ this . logger . trace ( '[gitlab] querying gitlab user groups with params:' , gitlabPublishQueryParams . toString ( ) ) ;
112106
113107 const groupsPromise = GitlabAPI . Groups . all ( gitlabPublishQueryParams ) . then ( groups => {
114108 return groups . filter ( group => group . path === group . full_path ) . map ( group => group . path ) ;
@@ -124,8 +118,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
124118 this . _setCachedUserGroups ( user , password , { publish : realGroups } ) ;
125119
126120 this . logger . info ( `[gitlab] user: ${ user } successfully authenticated` ) ;
127- // @ts -ignore
128- this . logger . debug ( `[gitlab] user: ${ user } , with groups:` , realGroups ) ;
121+ this . logger . debug ( `[gitlab] user: ${ user } , with groups:` , realGroups . toString ( ) ) ;
129122
130123 return cb ( null , realGroups ) ;
131124 } )
@@ -140,17 +133,17 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
140133 } ) ;
141134 }
142135
143- adduser ( user : string , password : string , cb : Callback ) {
136+ public adduser ( user : string , password : string , cb : Callback ) {
144137 this . logger . trace ( `[gitlab] adduser called for user: ${ user } ` ) ;
145138 return cb ( null , true ) ;
146139 }
147140
148- changePassword ( user : string , password : string , newPassword : string , cb : Callback ) {
141+ public changePassword ( user : string , password : string , newPassword : string , cb : Callback ) {
149142 this . logger . trace ( `[gitlab] changePassword called for user: ${ user } ` ) ;
150143 return cb ( getInternalError ( 'You are using verdaccio-gitlab integration. Please change your password in gitlab' ) ) ;
151144 }
152145
153- allow_access ( user : RemoteUser , _package : VerdaccioGitlabPackageAccess & PackageAccess , cb : Callback ) {
146+ public allow_access ( user : RemoteUser , _package : VerdaccioGitlabPackageAccess & PackageAccess , cb : Callback ) {
154147 if ( ! _package . gitlab ) return cb ( null , false ) ;
155148
156149 const packageAccess = _package . access && _package . access . length > 0 ? _package . access : DEFAULT_ALLOW_ACCESS_LEVEL ;
@@ -171,7 +164,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
171164 }
172165 }
173166
174- allow_publish ( user : RemoteUser , _package : VerdaccioGitlabPackageAccess & PackageAccess , cb : Callback ) {
167+ public allow_publish ( user : RemoteUser , _package : VerdaccioGitlabPackageAccess & PackageAccess , cb : Callback ) {
175168 if ( ! _package . gitlab ) return cb ( null , false ) ;
176169
177170 const packageScopePermit = false ;
@@ -205,7 +198,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
205198 }
206199 }
207200
208- _matchGroupWithPackage ( real_group : string , package_name : string ) : boolean {
201+ private _matchGroupWithPackage ( real_group : string , package_name : string ) : boolean {
209202 if ( real_group === package_name ) {
210203 return true ;
211204 }
@@ -230,15 +223,15 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
230223 return false ;
231224 }
232225
233- _getCachedUserGroups ( username : string , password : string ) : UserDataGroups | null {
226+ private _getCachedUserGroups ( username : string , password : string ) : UserDataGroups | null {
234227 if ( ! this . authCache ) {
235228 return null ;
236229 }
237230 const userData = this . authCache . findUser ( username , password ) ;
238231 return ( userData || { } ) . groups || null ;
239232 }
240233
241- _setCachedUserGroups ( username : string , password : string , groups : UserDataGroups ) : boolean {
234+ private _setCachedUserGroups ( username : string , password : string , groups : UserDataGroups ) : boolean {
242235 if ( ! this . authCache ) {
243236 return false ;
244237 }
0 commit comments