@hapiboo/module-auth 1.2.2 → 1.3.0

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.
@@ -202,8 +202,8 @@ class Password {
202
202
  return this.hash === this.getHash(base64password);
203
203
  }
204
204
  setPassword(base64Password) {
205
- this.length = settings_1.authSettings.passwordHashLength;
206
- this.iterations = settings_1.authSettings.passwordHashIterations;
205
+ this.length = settings_1.authSettings.passwordHashLength();
206
+ this.iterations = settings_1.authSettings.passwordHashIterations();
207
207
  this.salt = crypto_1.cryptoProvider.generateSalt(this.length);
208
208
  this.hash = this.getHash(base64Password);
209
209
  this.lastChangedAt = date_1.DateObject.now().toUtc();
@@ -217,8 +217,9 @@ var authenticationService;
217
217
  core_1.promise.checkVoid(authorization_1.authorizationService.general.initializeSecurityModel(), reject)
218
218
  .then(() => {
219
219
  //create first admin
220
- console.info('creating first admin user: ' + settings_1.authSettings.firstAdmin.email);
221
- core_1.promise.resolve(admin.invite(settings_1.authSettings.firstAdmin.email, settings_1.authSettings.firstAdmin.email, settings_1.authSettings.firstAdmin.name, baseURL), resolve, reject);
220
+ const to_create = settings_1.authSettings.firstAdmin();
221
+ console.info('... creating first admin user: ' + to_create.email);
222
+ core_1.promise.resolve(admin.invite(to_create.email, to_create.email, to_create.name, baseURL), resolve, reject);
222
223
  });
223
224
  }
224
225
  else {
@@ -17,8 +17,9 @@ var authorizationValidator;
17
17
  function checkUserPermission(user_id, permission_id) {
18
18
  if (userPermissionCache.has(user_id)) {
19
19
  const permissions = userPermissionCache.get(user_id);
20
- if (settings_1.authSettings.overrulingPermission !== undefined) {
21
- return permissions.includes(permission_id) || permissions.includes(settings_1.authSettings.overrulingPermission);
20
+ const overrulingPermission = settings_1.authSettings.overrulingPermission();
21
+ if (overrulingPermission !== undefined) {
22
+ return permissions.includes(permission_id) || permissions.includes(overrulingPermission);
22
23
  }
23
24
  else {
24
25
  return permissions.includes(permission_id);
@@ -28,15 +28,15 @@ export interface IAuthSettings {
28
28
  }
29
29
  export declare namespace authSettings {
30
30
  function init(settings: IAuthSettings, performers: IAuthPerformers): void;
31
- const allowSelfRegistration: boolean;
32
- const allowMultiLogin: boolean;
33
- const passwordHashLength: number;
34
- const passwordHashIterations: number;
35
- const firstAdmin: {
31
+ function allowSelfRegistration(): boolean;
32
+ function allowMultiLogin(): boolean;
33
+ function passwordHashLength(): number;
34
+ function passwordHashIterations(): number;
35
+ function firstAdmin(): {
36
36
  name: string;
37
37
  email: string;
38
38
  };
39
- const overrulingPermission: string | undefined;
39
+ function overrulingPermission(): string | undefined;
40
40
  function getPermissions(): Permission[];
41
41
  function getRoles(): Role[];
42
42
  function sendConfirmation(emailAddress: string, displayName: string, isInvited: boolean, confirmationLink: IAuthEmailLink): IResponsePromiseVoid;
@@ -17,33 +17,38 @@ var authSettings;
17
17
  };
18
18
  let _performers = undefined;
19
19
  function init(settings, performers) {
20
- console.log('authSettings.init()');
20
+ console.info('Authentication Settings Initialization');
21
21
  _settings = settings;
22
22
  _performers = performers;
23
23
  }
24
24
  authSettings.init = init;
25
- authSettings.allowSelfRegistration = (() => {
25
+ function allowSelfRegistration() {
26
26
  return _settings.allowSelfRegistration;
27
- })();
28
- authSettings.allowMultiLogin = (() => {
27
+ }
28
+ authSettings.allowSelfRegistration = allowSelfRegistration;
29
+ function allowMultiLogin() {
29
30
  return _settings.allowMultiLogin;
30
- })();
31
- authSettings.passwordHashLength = (() => {
31
+ }
32
+ authSettings.allowMultiLogin = allowMultiLogin;
33
+ function passwordHashLength() {
32
34
  return _settings.passwordHashLength;
33
- })();
34
- authSettings.passwordHashIterations = (() => {
35
+ }
36
+ authSettings.passwordHashLength = passwordHashLength;
37
+ function passwordHashIterations() {
35
38
  return _settings.passwordHashIterations;
36
- })();
37
- authSettings.firstAdmin = (() => {
38
- console.info('authSettings.firstAdmin: ' + _settings.firstAdmin.name + ' <' + _settings.firstAdmin.email + '>');
39
+ }
40
+ authSettings.passwordHashIterations = passwordHashIterations;
41
+ function firstAdmin() {
39
42
  return {
40
43
  name: _settings.firstAdmin.name,
41
44
  email: _settings.firstAdmin.email
42
45
  };
43
- })();
44
- authSettings.overrulingPermission = (() => {
46
+ }
47
+ authSettings.firstAdmin = firstAdmin;
48
+ function overrulingPermission() {
45
49
  return _settings.overrulingPermission;
46
- })();
50
+ }
51
+ authSettings.overrulingPermission = overrulingPermission;
47
52
  function getPermissions() {
48
53
  if (_settings.getPermissions) {
49
54
  return _settings.getPermissions();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hapiboo/module-auth",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "MK13 Studio Hapiboo - Auth Module",
5
5
  "author": "MK13 Studio",
6
6
  "license": "ISC",