@@ -38,19 +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- // @ts -ignore
49- authCache : AuthCache ;
50- logger : Logger ;
51- publishLevel : VerdaccioGitlabAccessLevel ;
52-
53- 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 > ) {
5449 this . logger = options . logger ;
5550 this . config = config ;
5651 this . options = options ;
@@ -76,14 +71,13 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
7671 this . logger . info ( `[gitlab] publish control level: ${ this . publishLevel } ` ) ;
7772 }
7873
79- authenticate ( user : string , password : string , cb : Callback ) {
74+ public authenticate ( user : string , password : string , cb : Callback ) {
8075 this . logger . trace ( `[gitlab] authenticate called for user: ${ user } ` ) ;
8176
8277 // Try to find the user groups in the cache
8378 const cachedUserGroups = this . _getCachedUserGroups ( user , password ) ;
8479 if ( cachedUserGroups ) {
85- // @ts -ignore
86- 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 ( ) ) ;
8781 return cb ( null , cachedUserGroups . publish ) ;
8882 }
8983
@@ -108,8 +102,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
108102 // - for publish, the logged in user id and all the groups they can reach as configured with access level `$auth.gitlab.publish`
109103 const gitlabPublishQueryParams = { min_access_level : publishLevelId } ;
110104
111- // @ts -ignore
112- this . logger . trace ( '[gitlab] querying gitlab user groups with params:' , gitlabPublishQueryParams ) ;
105+ this . logger . trace ( '[gitlab] querying gitlab user groups with params:' , gitlabPublishQueryParams . toString ( ) ) ;
113106
114107 const groupsPromise = GitlabAPI . Groups . all ( gitlabPublishQueryParams ) . then ( groups => {
115108 return groups . filter ( group => group . path === group . full_path ) . map ( group => group . path ) ;
@@ -125,8 +118,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
125118 this . _setCachedUserGroups ( user , password , { publish : realGroups } ) ;
126119
127120 this . logger . info ( `[gitlab] user: ${ user } successfully authenticated` ) ;
128- // @ts -ignore
129- this . logger . debug ( `[gitlab] user: ${ user } , with groups:` , realGroups ) ;
121+ this . logger . debug ( `[gitlab] user: ${ user } , with groups:` , realGroups . toString ( ) ) ;
130122
131123 return cb ( null , realGroups ) ;
132124 } )
@@ -141,17 +133,17 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
141133 } ) ;
142134 }
143135
144- adduser ( user : string , password : string , cb : Callback ) {
136+ public adduser ( user : string , password : string , cb : Callback ) {
145137 this . logger . trace ( `[gitlab] adduser called for user: ${ user } ` ) ;
146138 return cb ( null , true ) ;
147139 }
148140
149- changePassword ( user : string , password : string , newPassword : string , cb : Callback ) {
141+ public changePassword ( user : string , password : string , newPassword : string , cb : Callback ) {
150142 this . logger . trace ( `[gitlab] changePassword called for user: ${ user } ` ) ;
151143 return cb ( getInternalError ( 'You are using verdaccio-gitlab integration. Please change your password in gitlab' ) ) ;
152144 }
153145
154- allow_access ( user : RemoteUser , _package : VerdaccioGitlabPackageAccess & PackageAccess , cb : Callback ) {
146+ public allow_access ( user : RemoteUser , _package : VerdaccioGitlabPackageAccess & PackageAccess , cb : Callback ) {
155147 if ( ! _package . gitlab ) return cb ( null , false ) ;
156148
157149 const packageAccess = _package . access && _package . access . length > 0 ? _package . access : DEFAULT_ALLOW_ACCESS_LEVEL ;
@@ -172,7 +164,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
172164 }
173165 }
174166
175- allow_publish ( user : RemoteUser , _package : VerdaccioGitlabPackageAccess & PackageAccess , cb : Callback ) {
167+ public allow_publish ( user : RemoteUser , _package : VerdaccioGitlabPackageAccess & PackageAccess , cb : Callback ) {
176168 if ( ! _package . gitlab ) return cb ( null , false ) ;
177169
178170 const packageScopePermit = false ;
@@ -206,7 +198,7 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
206198 }
207199 }
208200
209- _matchGroupWithPackage ( real_group : string , package_name : string ) : boolean {
201+ private _matchGroupWithPackage ( real_group : string , package_name : string ) : boolean {
210202 if ( real_group === package_name ) {
211203 return true ;
212204 }
@@ -231,15 +223,15 @@ export default class VerdaccioGitLab implements VerdaccioGitLabPlugin {
231223 return false ;
232224 }
233225
234- _getCachedUserGroups ( username : string , password : string ) : UserDataGroups | null {
226+ private _getCachedUserGroups ( username : string , password : string ) : UserDataGroups | null {
235227 if ( ! this . authCache ) {
236228 return null ;
237229 }
238230 const userData = this . authCache . findUser ( username , password ) ;
239231 return ( userData || { } ) . groups || null ;
240232 }
241233
242- _setCachedUserGroups ( username : string , password : string , groups : UserDataGroups ) : boolean {
234+ private _setCachedUserGroups ( username : string , password : string , groups : UserDataGroups ) : boolean {
243235 if ( ! this . authCache ) {
244236 return false ;
245237 }
0 commit comments