An Angular interceptor implementation. Uses a two token process to keep a user authenticated.
Created for an internal project, it's generic enough to work with your general refresher token implementation.
To install this library, run:
$ npm install request-handler --save
The implementation can be imported via the following method:
$ npm install request-handler
and then from your Angular AppModule
:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { RequestHandlerModule } from 'request-handler';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
RequestHandlerModule.forRoot({
clientAccessTokenName: 'string', // The key for the access token in storage.
clientRefreshTokenName: 'string', // The key for the refresh token in storage.
serverAccessTokenName: 'string', // The header value the access token is stored in
serverRefreshTokenName: 'string', // The header value the refresh token is stored in.
refreshUrl: 'string' // POST Endpoint to be hit to refresh the access token when it expires.
})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
To generate all *.js
, *.d.ts
and *.metadata.json
files:
$ npm run build
To lint all *.ts
files:
$ npm run lint
MIT © george phillips