Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static create(http: Http, options: RequestOptions) {
const tokenGetter = () => localStorage.getItem('token');
return new AuthHttp(new AuthConfig({
headerName: 'Authorization',
headerPrefix: 'JWT',
tokenName: 'token',
tokenGetter: tokenGetter,
globalHeaders: [{ 'Content-Type': 'application/json' }],
noJwtError: true,
noTokenScheme: true
}), http, options);
}
}
static create(http: Http, options: RequestOptions) {
const tokenGetter = () => localStorage.getItem('token');
return new AuthHttp(new AuthConfig({
headerName: 'Authorization',
headerPrefix: 'JWT',
tokenName: 'token',
tokenGetter: tokenGetter,
globalHeaders: [{ 'Content-Type': 'application/json' }],
noJwtError: true,
noTokenScheme: true
}), http, options);
}
}
constructor(http: Http, defOpts?: RequestOptions) {
super(new AuthConfig({
noTokenScheme: true,
tokenName: Token.TOKEN_KEY,
globalHeaders: [ {'Content-Type': 'application/json'} ],
noJwtError: true
}), http, defOpts);
}
}
useFactory: (http: Http, tokenService: TokenService) => {
let config: AuthConfig = new AuthConfig({
headerName: 'Authorization',
headerPrefix: 'Bearer',
tokenName: AUTH_TOKEN_NAME,
tokenGetter: () => {
return new Promise((resolve) => {
resolve(tokenService.getToken());
});
},
noJwtError: true,
noTokenScheme: true,
globalHeaders: [{'Content-Type': 'application/json'}]
});
return new AuthHttp(config, http);
},
deps: [Http, TokenService]