angular2-jwt
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -30,3 +30,3 @@ "use strict"; | ||
}()); | ||
AuthConfigConsts.DEFAULT_TOKEN_NAME = 'id_token'; | ||
AuthConfigConsts.DEFAULT_TOKEN_NAME = 'access_token'; | ||
AuthConfigConsts.DEFAULT_HEADER_NAME = 'Authorization'; | ||
@@ -33,0 +33,0 @@ AuthConfigConsts.HEADER_PREFIX_BEARER = 'Bearer '; |
{ | ||
"name": "angular2-jwt", | ||
"version": "0.2.0", | ||
"description": "Helper library for handling JWTs in Angular 2", | ||
"version": "0.2.1", | ||
"description": "Helper library for handling JWTs in Angular 2+", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -70,3 +70,3 @@ # angular2-jwt | ||
function authHttpServiceFactory(http: Http, options: RequestOptions) { | ||
export function authHttpServiceFactory(http: Http, options: RequestOptions) { | ||
return new AuthHttp(new AuthConfig(), http, options); | ||
@@ -121,3 +121,3 @@ } | ||
* Header Prefix: `Bearer` | ||
* Token Name: `id_token` | ||
* Token Name: `access_token` | ||
* Token Getter Function: `(() => localStorage.getItem(tokenName))` | ||
@@ -150,3 +150,3 @@ * Supress error and continue with regular HTTP request if no JWT is saved: `false` | ||
function authHttpServiceFactory(http: Http, options: RequestOptions) { | ||
export function authHttpServiceFactory(http: Http, options: RequestOptions) { | ||
return new AuthHttp(new AuthConfig({ | ||
@@ -187,3 +187,3 @@ tokenName: 'token', | ||
globalHeaders: [{'Accept': 'application/json'}], | ||
tokenGetter: (() => storage.get('id_token')), | ||
tokenGetter: (() => storage.get('access_token')), | ||
}), http); | ||
@@ -208,16 +208,2 @@ } | ||
To use `tokenNotExpired` with Ionic 2, use the `Storage` class directly in the function. | ||
```ts | ||
import { Storage } from '@ionic/storage'; | ||
import { tokenNotExpired } from 'angular2-jwt'; | ||
let storage = new Storage(); | ||
this.storage.get('id_token').then(token => { | ||
console.log(tokenNotExpired(null, token)); // Returns true/false | ||
}); | ||
``` | ||
### Sending Per-Request Headers | ||
@@ -280,3 +266,3 @@ | ||
useJwtHelper() { | ||
var token = localStorage.getItem('id_token'); | ||
var token = localStorage.getItem('access_token'); | ||
@@ -296,3 +282,3 @@ console.log( | ||
> **Note:** `tokenNotExpired` will by default assume the token name is `id_token` unless a token name is passed to it, ex: `tokenNotExpired('token_name')`. This will be changed in a future release to automatically use the token name that is set in `AuthConfig`. | ||
> **Note:** `tokenNotExpired` will by default assume the token name is `access_token` unless a token name is passed to it, ex: `tokenNotExpired('token_name')`. This will be changed in a future release to automatically use the token name that is set in `AuthConfig`. | ||
@@ -299,0 +285,0 @@ ```ts |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44749
374