npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

exc-security-v2

v2.0.5

Published

##### Content

Downloads

5

Readme

Module Exc-Security-V2

Content
  • ExcSecurityModule
Services
  • ExcSecurityService
Enumerations
  • ExcSecurityEvent
Interfaces
  • IExcCurrentUser
  • IExcCredentials
Classes
  • ExcCredentials
  • ExcStateSecurityProcessor (implements CanActivate of angular router)

Dependencies

  • exc-core-v2
  • exc-rest-v2
  • @angular/router

Install

To install ExcRestModule into your project use

npm i exc-security-v2

ExcSecurityService

Dependencies

  • Register environment into ExcCoreModule.Config() with ExcCoreModule.RegisterConfig('Environment',environment)
  • Add appID, secMode and mainToken into sec section in environment.ts
export const environment = {
  production: false,
  sec: {
    secMode: 'DEFAULT', /* DEFAULT | CODE */
    appID: 17, /* GlobalAccess AppIndex */
    mainToken: 'APPUSE', /* Maintoken to use the application */
  },
  rest: {
    ServiceUrl: 'Base URL of Service with trailing /',
    LoginUrl: 'Base URL of Security Service with trailing /',
    Endpoints: {
      PasswordSettings: 'PasswordSettings'
    }
  }
};

Setup

To use ExcSecurityService you have to do preparations in your project. You have to add Router in your module constructor and register it to ExcCoreModule

  1. app.module.ts
//...
import {environment} from '../environments/environment';
import {ExcCoreModule} from 'exc-core-v2';
import {ExcRestModule, ExcRestService, ExcRestMode, ExcTranslateService} from 'exc-rest-v2';
import {ExcSecurityModule, ExcStateSecurityProcessor} from 'exc-security-v2';
import {AppComponent} from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    AppRoutingModule,
    ExcCoreModule,
    ExcRestModule,
    ExcSecurityModule
    //...
  ],
  providers: [ExcStateSecurityProcessor],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(private excRest: ExcRestService, private excTranslate: ExcTranslateService, private router: Router) {
    ExcCoreModule.RegisterConfig('Environment', environment);
    ExcCoreModule.RegisterService('Router', router); /* Add this line */
    excRest.Mode = ExcRestMode.GROOT;
    excTranslate.activate();
  }
}
  1. app.component.ts
//...
import {ExcCoreModule} from 'exc-core-v2';
import {ExcRestService} from 'exc-rest-v2';
import {ExcSecurityService} from 'exc-security-v2';

//...
export class AppComponent implements OnInit {
//...
  constructor(private excRestService: ExcRestService, public excSecurityService: ExcSecurityService) {
  /* If you want to trigger calls after successful authentication you can subscribe any event */
    excSecurityService.OnReady.subscribe(()=>{
        /* Do anything */
    })
  }
}
  1. app-routing.module.ts
//...
import {ExcSecurityService} from 'exc-security-v2';

const routes: Routes = [
  {
    path: '', redirectTo: '/testroute1', pathMatch: 'full',
    data: {hidden: true}
  },
  {
    path: 'testroute1',
    component: Testroute1Component,
    canActivate: [ExcStateSecurityProcessor],
    data: {class: 'fas fa-home', friendlyName: 'TestRoute1', security: '*'} /*  Use * to allow without security context. Use $$REDIR$$ for manual redirection states */
  },
  {
    path: 'testroute2',
    component: Testroute2Component,
    canActivate: [ExcStateSecurityProcessor],
    data: {class: 'fas fa-brain', friendlyName: 'TestRoute2', security: 'APPUSE'} /* Use Tokens for security check. Multiple tokens are comma separated. Tokens are OR linked */
  }
];
//...

Definitions

Events

| Name | Emitted params | Description | | --- | --- |--- | | OnReady | - | Triggered after initial successful authentication | | OnLoggedOut | - | Triggered after logout | | OnRefresh | includeToken?: boolean | Triggers reload of authentication information. ExcSecurityService has subscribed this Eventhandler To emit this event use excRestService.OnRefresh.emit(includeToken?: boolean)| | OnTokenRefreshed | - | Triggered after reloading of authentication information. | OnIsPwdChangeForced | - | Triggered after reloading of authentication information if password change is forced.

Properties

| Name | Type | Description | | --- | --- | --- | | LoggedIn | boolean | Get flag if user is logged in or not. | | IsInitializing | boolean | Get flag if ExcSecurityService is already initializing | | Credentials | ExcCredentials | Get credential instance for login mask | | UserLogin | string | Get user login of logged in user | | UserName | string | Get name of logged in user |

Methods

Login(credentials?)
Parameters

| Name | Type | Description | | --- | --- | --- | | credentials | IExcCredentials | ExcCredentials | (optional) Credentials for login. If parameter is missing it uses Credentials instance of service instead. |

Returns

void

Examples
const excSecurity = ExcCoreModule.Services().ExcSecurityService;
let credentials: IExcCredentials = {uid: 'username',pwd: 'password'}

excSecurity.Login(credentials);
Logout()
Parameters

| Name | Type | Description | | --- | --- | --- |

Returns

void

Examples
const excSecurity = ExcCoreModule.Services().ExcSecurityService;
excSecurity.Logout();
changePassword(pwdOld, pwdNew, pwdNewRepeat)
Parameters

| Name | Type | Description | | --- | --- | --- | | pwdOld | string | Old password | | pwdNew | string | New password | | pwdNewRepeat | string | Repeated new password |

Returns

Observable<any>

Examples
const excSecurity = ExcCoreModule.Services().ExcSecurityService;
excSecurity.changePassword('old','new','newRepeat').subscribe((success: boolean)=>{
    /* OnTokenRefreshed is triggered automatically on success */
    /* ExcCoreModule.showSuccess is triggered automatically on success */ 
    /* ExcCoreModule.showError is triggered automatically on non-success */ 
    /* ------------------------- */
    /* Do custom implementation here if needed.  */
});
isStateAvailable(routeName, router?)

This method is used by ExcStateSecurityProcessor

Parameters

| Name | Type | Description | | --- | --- | --- | | routeName | string | name of route path | | router? | any undefined | (optional) angular router. If missing, it uses ExcCoreModule.Services().Router instead. |

Returns

boolean

Examples
const excSecurity = ExcCoreModule.Services().ExcSecurityService;

excSecurity.isStateAvailable('testroute1');
excSecurity.isStateAvailable('testroute1', router);
isFeatured(featureToken)
Parameters

| Name | Type | Description | | --- | --- | --- | | featureToken | string | Security token to check against token list of security instance|

Returns

boolean

Examples
const excSecurity = ExcCoreModule.Services().ExcSecurityService;

excSecurity.isFeatured('APPUSE');