Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@auth0/angular-jwt

Package Overview
Dependencies
Maintainers
46
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@auth0/angular-jwt - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

73

bundles/auth0-angular-jwt.umd.js

@@ -89,3 +89,11 @@ (function (global, factory) {

JwtHelperService.prototype.decodeToken = function (token) {
if (token === void 0) { token = this.tokenGetter(); }
var _this = this;
if (token === void 0) { token = null; }
var _token = token || this.tokenGetter();
if (_token instanceof Promise) {
return _token.then(function (t) { return _this._decodeToken(t); });
}
return this._decodeToken(_token);
};
JwtHelperService.prototype._decodeToken = function (token) {
if (!token || token === '') {

@@ -105,3 +113,11 @@ return null;

JwtHelperService.prototype.getTokenExpirationDate = function (token) {
if (token === void 0) { token = this.tokenGetter(); }
var _this = this;
if (token === void 0) { token = null; }
var _token = token || this.tokenGetter();
if (_token instanceof Promise) {
return _token.then(function (t) { return _this._getTokenExpirationDate(t); });
}
return this._getTokenExpirationDate(_token);
};
JwtHelperService.prototype._getTokenExpirationDate = function (token) {
var decoded;

@@ -117,3 +133,11 @@ decoded = this.decodeToken(token);

JwtHelperService.prototype.isTokenExpired = function (token, offsetSeconds) {
if (token === void 0) { token = this.tokenGetter(); }
var _this = this;
if (token === void 0) { token = null; }
var _token = token || this.tokenGetter();
if (_token instanceof Promise) {
return _token.then(function (t) { return _this._isTokenExpired(t, offsetSeconds); });
}
return this._isTokenExpired(_token, offsetSeconds);
};
JwtHelperService.prototype._isTokenExpired = function (token, offsetSeconds) {
if (!token || token === '') {

@@ -148,2 +172,8 @@ return true;

var fromPromiseOrValue = function (input) {
if (input instanceof Promise) {
return rxjs.defer(function () { return input; });
}
return rxjs.of(input);
};
var JwtInterceptor = /** @class */ (function () {

@@ -198,21 +228,23 @@ function JwtInterceptor(config, jwtHelper, document) {

JwtInterceptor.prototype.handleInterception = function (token, request, next) {
var _a;
var _this = this;
var authScheme = this.jwtHelper.getAuthScheme(this.authScheme, request);
var tokenIsExpired = false;
if (!token && this.throwNoTokenError) {
throw new Error('Could not get token from tokenGetter function.');
}
var tokenIsExpired = rxjs.of(false);
if (this.skipWhenExpired) {
tokenIsExpired = token ? this.jwtHelper.isTokenExpired(token) : true;
tokenIsExpired = token ? fromPromiseOrValue(this.jwtHelper.isTokenExpired(token)) : rxjs.of(true);
}
if (token && tokenIsExpired && this.skipWhenExpired) {
request = request.clone();
if (token) {
return tokenIsExpired.pipe(operators.map(function (isExpired) {
var _a;
return isExpired && _this.skipWhenExpired
? request.clone()
: request.clone({
setHeaders: (_a = {},
_a[_this.headerName] = "" + authScheme + token,
_a),
});
}), operators.mergeMap(function (innerRequest) { return next.handle(innerRequest); }));
}
else if (token) {
request = request.clone({
setHeaders: (_a = {},
_a[this.headerName] = "" + authScheme + token,
_a),
});
}
return next.handle(request);

@@ -226,10 +258,5 @@ };

var token = this.tokenGetter(request);
if (token instanceof Promise) {
return rxjs.from(token).pipe(operators.mergeMap(function (asyncToken) {
return _this.handleInterception(asyncToken, request, next);
}));
}
else {
return this.handleInterception(token, request, next);
}
return fromPromiseOrValue(token).pipe(operators.mergeMap(function (asyncToken) {
return _this.handleInterception(asyncToken, request, next);
}));
};

@@ -236,0 +263,0 @@ return JwtInterceptor;

@@ -1,3 +0,9 @@

# Change log
# Change Log
## [v5.1.1](https://github.com/auth0/angular2-jwt/tree/v5.1.1) (2022-12-15)
[Full Changelog](https://github.com/auth0/angular2-jwt/compare/v5.1.0...v5.1.1)
**Fixed**
- Support promise based tokenGetter in JwtHelperService [\#748](https://github.com/auth0/angular2-jwt/pull/748) ([frederikprijck](https://github.com/frederikprijck))
## Version [5.1.0](https://github.com/auth0/angular2-jwt/tags/v5.1.0)

@@ -4,0 +10,0 @@

import { Injectable, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { JWT_OPTIONS } from './jwtoptions.token';
import { mergeMap } from 'rxjs/operators';
import { from } from 'rxjs';
import { map, mergeMap } from 'rxjs/operators';
import { defer, of } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "./jwthelper.service";
const fromPromiseOrValue = (input) => {
if (input instanceof Promise) {
return defer(() => input);
}
return of(input);
};
export class JwtInterceptor {

@@ -57,19 +63,18 @@ constructor(config, jwtHelper, document) {

const authScheme = this.jwtHelper.getAuthScheme(this.authScheme, request);
let tokenIsExpired = false;
if (!token && this.throwNoTokenError) {
throw new Error('Could not get token from tokenGetter function.');
}
let tokenIsExpired = of(false);
if (this.skipWhenExpired) {
tokenIsExpired = token ? this.jwtHelper.isTokenExpired(token) : true;
tokenIsExpired = token ? fromPromiseOrValue(this.jwtHelper.isTokenExpired(token)) : of(true);
}
if (token && tokenIsExpired && this.skipWhenExpired) {
request = request.clone();
if (token) {
return tokenIsExpired.pipe(map((isExpired) => isExpired && this.skipWhenExpired
? request.clone()
: request.clone({
setHeaders: {
[this.headerName]: `${authScheme}${token}`,
},
})), mergeMap((innerRequest) => next.handle(innerRequest)));
}
else if (token) {
request = request.clone({
setHeaders: {
[this.headerName]: `${authScheme}${token}`,
},
});
}
return next.handle(request);

@@ -82,10 +87,5 @@ }

const token = this.tokenGetter(request);
if (token instanceof Promise) {
return from(token).pipe(mergeMap((asyncToken) => {
return this.handleInterception(asyncToken, request, next);
}));
}
else {
return this.handleInterception(token, request, next);
}
return fromPromiseOrValue(token).pipe(mergeMap((asyncToken) => {
return this.handleInterception(asyncToken, request, next);
}));
}

@@ -104,2 +104,2 @@ }

}] }]; } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiand0LmludGVyY2VwdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvYW5ndWxhci1qd3Qvc3JjL2xpYi9qd3QuaW50ZXJjZXB0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkF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WVzdFVybC5wb3J0XG4gICAgICAgIDogJydcbiAgICB9YDtcblxuICAgIHJldHVybiAoXG4gICAgICB0aGlzLmFsbG93ZWREb21haW5zLmZpbmRJbmRleCgoZG9tYWluKSA9PlxuICAgICAgICB0eXBlb2YgZG9tYWluID09PSAnc3RyaW5nJ1xuICAgICAgICAgID8gZG9tYWluID09PSBob3N0TmFtZVxuICAgICAgICAgIDogZG9tYWluIGluc3RhbmNlb2YgUmVnRXhwXG4gICAgICAgICAgPyBkb21haW4udGVzdChob3N0TmFtZSlcbiAgICAgICAgICA6IGZhbHNlXG4gICAgICApID4gLTFcbiAgICApO1xuICB9XG5cbiAgaXNEaXNhbGxvd2VkUm91dGUocmVxdWVzdDogSHR0cFJlcXVlc3Q8YW55Pik6IGJvb2xlYW4ge1xuICAgIGNvbnN0IHJlcXVlc3RlZFVybDogVVJMID0gbmV3IFVSTChcbiAgICAgIHJlcXVlc3QudXJsLFxuICAgICAgdGhpcy5kb2N1bWVudC5sb2NhdGlvbi5vcmlnaW5cbiAgICApO1xuXG4gICAgcmV0dXJuIChcbiAgICAgIHRoaXMuZGlzYWxsb3dlZFJvdXRlcy5maW5kSW5kZXgoKHJvdXRlOiBzdHJpbmcgfCBSZWdFeHApID0+IHtcbiAgICAgICAgaWYgKHR5cGVvZiByb3V0ZSA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgICBjb25zdCBwYXJzZWRSb3V0ZTogVVJMID0gbmV3IFVSTChcbiAgICAgICAgICAgIHJvdXRlLFxuICAgICAgICAgICAgdGhpcy5kb2N1bWVudC5sb2NhdGlvbi5vcmlnaW5cbiAgICAgICAgICApO1xuICAgICAgICAgIHJldHVybiAoXG4gICAgICAgICAgICBwYXJzZWRSb3V0ZS5ob3N0bmFtZSA9PT0gcmVxdWVzdGVkVXJsLmhvc3RuYW1lICYmXG4gICAgICAgICAgICBwYXJzZWRSb3V0ZS5wYXRobmFtZSA9PT0gcmVxdWVzdGVkVXJsLnBhdGhuYW1lXG4gICA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oXG4gICAgcmVxdWVzdDogSHR0cFJlcXVlc3Q8YW55PixcbiAgICBuZXh0OiBIdHRwSGFuZGxlclxuICApOiBPYnNlcnZhYmxlPEh0dHBFdmVudDxhbnk+PiB7XG4gICAgaWYgKCF0aGlzLmlzQWxsb3dlZERvbWFpbihyZXF1ZXN0KSB8fCB0aGlzLmlzRGlzYWxsb3dlZFJvdXRlKHJlcXVlc3QpKSB7XG4gICAgICByZXR1cm4gbmV4dC5oYW5kbGUocmVxdWVzdCk7XG4gICAgfVxuICAgIGNvbnN0IHRva2VuID0gdGhpcy50b2tlbkdldHRlcihyZXF1ZXN0KTtcblxuICAgIHJldHVybiBmcm9tUHJvbWlzZU9yVmFsdWUodG9rZW4pLnBpcGUoXG4gICAgICBtZXJnZU1hcCgoYXN5bmNUb2tlbjogc3RyaW5nIHwgbnVsbCkgPT4ge1xuICAgICAgICByZXR1cm4gdGhpcy5oYW5kbGVJbnRlcmNlcHRpb24oYXN5bmNUb2tlbiwgcmVxdWVzdCwgbmV4dCk7XG4gICAgICB9KVxuICAgICk7XG4gIH1cbn1cbiJdfQ==

@@ -62,3 +62,10 @@ // tslint:disable:no-bitwise

}
decodeToken(token = this.tokenGetter()) {
decodeToken(token = null) {
const _token = token || this.tokenGetter();
if (_token instanceof Promise) {
return _token.then(t => this._decodeToken(t));
}
return this._decodeToken(_token);
}
_decodeToken(token) {
if (!token || token === '') {

@@ -77,3 +84,10 @@ return null;

}
getTokenExpirationDate(token = this.tokenGetter()) {
getTokenExpirationDate(token = null) {
const _token = token || this.tokenGetter();
if (_token instanceof Promise) {
return _token.then(t => this._getTokenExpirationDate(t));
}
return this._getTokenExpirationDate(_token);
}
_getTokenExpirationDate(token) {
let decoded;

@@ -88,3 +102,10 @@ decoded = this.decodeToken(token);

}
isTokenExpired(token = this.tokenGetter(), offsetSeconds) {
isTokenExpired(token = null, offsetSeconds) {
const _token = token || this.tokenGetter();
if (_token instanceof Promise) {
return _token.then(t => this._isTokenExpired(t, offsetSeconds));
}
return this._isTokenExpired(_token, offsetSeconds);
}
_isTokenExpired(token, offsetSeconds) {
if (!token || token === '') {

@@ -115,2 +136,2 @@ return true;

}] }]; } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiand0aGVscGVyLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9hbmd1bGFyLWp3dC9zcmMvbGliL2p3dGhlbHBlci5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLDRCQUE0QjtBQUU1QixPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUNuRCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7O0FBR2pELE1BQU0sT0FBTyxnQkFBZ0I7SUFHM0IsWUFBaUMsTUFBTSxHQUFHLElBQUk7UUFDNUMsSUFBSSxDQUFDLFdBQVcsR0FBRyxDQUFDLE1BQU0sSUFBSSxNQUFNLENBQUMsV0FBVyxDQUFDLElBQUksY0FBYSxDQUFDLENBQUM7SUFDdEUsQ0FBQztJQUVNLGVBQWUsQ0FBQyxHQUFXO1FBQ2hDLElBQUksTUFBTSxHQUFHLEdBQUcsQ0FBQyxPQUFPLENBQUMsSUFBSSxFQUFFLEdBQUcsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxJQUFJLEVBQUUsR0FBRyxDQUFDLENBQUM7UUFDdkQsUUFBUSxNQUFNLENBQUMsTUFBTSxHQUFHLENBQUMsRUFBRTtZQUN6QixLQUFLLENBQUMsQ0FBQyxDQUFDO2dCQUNOLE1BQU07YUFDUDtZQUNELEtBQUssQ0FBQyxDQUFDLENBQUM7Z0JBQ04sTUFBTSxJQUFJLElBQUksQ0FBQztnQkFDZixNQUFNO2FBQ1A7WUFDRCxLQUFLLENBQUMsQ0FBQyxDQUFD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ZigpID4gbmV3IERhdGUoKS52YWx1ZU9mKCkgKyBvZmZzZXRTZWNvbmRzICogMTAwMCk7XG4gIH1cblxuICBwdWJsaWMgZ2V0QXV0aFNjaGVtZShcbiAgICBhdXRoU2NoZW1lOiBGdW5jdGlvbiB8IHN0cmluZyB8IHVuZGVmaW5lZCxcbiAgICByZXF1ZXN0OiBIdHRwUmVxdWVzdDxhbnk+XG4gICk6IHN0cmluZyB7XG4gICAgaWYgKHR5cGVvZiBhdXRoU2NoZW1lID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICByZXR1cm4gYXV0aFNjaGVtZShyZXF1ZXN0KTtcbiAgICB9XG5cbiAgICByZXR1cm4gYXV0aFNjaGVtZTtcbiAgfVxufVxuIl19
import * as i0 from '@angular/core';
import { InjectionToken, Injectable, Inject, NgModule, Optional, SkipSelf } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { mergeMap } from 'rxjs/operators';
import { from } from 'rxjs';
import { map, mergeMap } from 'rxjs/operators';
import { defer, of } from 'rxjs';
import { HTTP_INTERCEPTORS } from '@angular/common/http';

@@ -68,3 +68,10 @@

}
decodeToken(token = this.tokenGetter()) {
decodeToken(token = null) {
const _token = token || this.tokenGetter();
if (_token instanceof Promise) {
return _token.then(t => this._decodeToken(t));
}
return this._decodeToken(_token);
}
_decodeToken(token) {
if (!token || token === '') {

@@ -83,3 +90,10 @@ return null;

}
getTokenExpirationDate(token = this.tokenGetter()) {
getTokenExpirationDate(token = null) {
const _token = token || this.tokenGetter();
if (_token instanceof Promise) {
return _token.then(t => this._getTokenExpirationDate(t));
}
return this._getTokenExpirationDate(_token);
}
_getTokenExpirationDate(token) {
let decoded;

@@ -94,3 +108,10 @@ decoded = this.decodeToken(token);

}
isTokenExpired(token = this.tokenGetter(), offsetSeconds) {
isTokenExpired(token = null, offsetSeconds) {
const _token = token || this.tokenGetter();
if (_token instanceof Promise) {
return _token.then(t => this._isTokenExpired(t, offsetSeconds));
}
return this._isTokenExpired(_token, offsetSeconds);
}
_isTokenExpired(token, offsetSeconds) {
if (!token || token === '') {

@@ -122,2 +143,8 @@ return true;

const fromPromiseOrValue = (input) => {
if (input instanceof Promise) {
return defer(() => input);
}
return of(input);
};
class JwtInterceptor {

@@ -172,19 +199,18 @@ constructor(config, jwtHelper, document) {

const authScheme = this.jwtHelper.getAuthScheme(this.authScheme, request);
let tokenIsExpired = false;
if (!token && this.throwNoTokenError) {
throw new Error('Could not get token from tokenGetter function.');
}
let tokenIsExpired = of(false);
if (this.skipWhenExpired) {
tokenIsExpired = token ? this.jwtHelper.isTokenExpired(token) : true;
tokenIsExpired = token ? fromPromiseOrValue(this.jwtHelper.isTokenExpired(token)) : of(true);
}
if (token && tokenIsExpired && this.skipWhenExpired) {
request = request.clone();
if (token) {
return tokenIsExpired.pipe(map((isExpired) => isExpired && this.skipWhenExpired
? request.clone()
: request.clone({
setHeaders: {
[this.headerName]: `${authScheme}${token}`,
},
})), mergeMap((innerRequest) => next.handle(innerRequest)));
}
else if (token) {
request = request.clone({
setHeaders: {
[this.headerName]: `${authScheme}${token}`,
},
});
}
return next.handle(request);

@@ -197,10 +223,5 @@ }

const token = this.tokenGetter(request);
if (token instanceof Promise) {
return from(token).pipe(mergeMap((asyncToken) => {
return this.handleInterception(asyncToken, request, next);
}));
}
else {
return this.handleInterception(token, request, next);
}
return fromPromiseOrValue(token).pipe(mergeMap((asyncToken) => {
return this.handleInterception(asyncToken, request, next);
}));
}

@@ -207,0 +228,0 @@ }

import { HttpRequest } from '@angular/common/http';
import * as i0 from "@angular/core";
export declare class JwtHelperService {
tokenGetter: () => string;
tokenGetter: () => string | Promise<string>;
constructor(config?: any);

@@ -9,5 +9,8 @@ urlBase64Decode(str: string): string;

private b64DecodeUnicode;
decodeToken<T = any>(token?: string): T;
getTokenExpirationDate(token?: string): Date | null;
isTokenExpired(token?: string, offsetSeconds?: number): boolean;
decodeToken<T = any>(token?: string): T | Promise<T>;
private _decodeToken;
getTokenExpirationDate(token?: string): Date | null | Promise<Date>;
private _getTokenExpirationDate;
isTokenExpired(token?: string, offsetSeconds?: number): boolean | Promise<boolean>;
_isTokenExpired(token: string, offsetSeconds?: number): boolean;
getAuthScheme(authScheme: Function | string | undefined, request: HttpRequest<any>): string;

@@ -14,0 +17,0 @@ static ɵfac: i0.ɵɵFactoryDeclaration<JwtHelperService, never>;

{
"name": "@auth0/angular-jwt",
"version": "5.1.0",
"version": "5.1.1",
"description": "JSON Web Token helper library for Angular",

@@ -5,0 +5,0 @@ "private": false,

@@ -1,5 +0,16 @@

# @auth0/angular-jwt
![Helper library for handling JWTs in Angular applications](https://cdn.auth0.com/website/sdks/banners/angular-jwt-banner.png)
[![npm version](https://badge.fury.io/js/%40auth0%2Fangular-jwt.svg)](https://badge.fury.io/js/%40auth0%2Fangular-jwt)
![Release](https://img.shields.io/github/v/release/auth0/angular2-jwt)
[![codecov](https://codecov.io/gh/auth0/angular2-jwt/branch/main/graph/badge.svg?token=wnauXldcdE)](https://codecov.io/gh/auth0/angular2-jwt)
![Downloads](https://img.shields.io/npm/dw/@auth0/angular-jwt)
[![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
[![CircleCI](https://img.shields.io/circleci/build/github/auth0/angular2-jwt)](https://circleci.com/gh/auth0/angular2-jwt)
:books: [Documentation](#documentation) - :rocket: [Getting Started](#getting-started) - :computer: [API Reference](#api-reference) - :speech_balloon: [Feedback](#feedback)
## Documentation
- [Examples](https://github.com/auth0/angular2-jwt/blob/main/EXAMPLES.md) - code samples for common angular-jwt authentication scenario's.
- [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0.
This library provides an `HttpInterceptor` which automatically attaches a [JSON Web Token](https://jwt.io) to `HttpClient` requests.

@@ -9,13 +20,8 @@

## Supported Angular versions
## Getting started
### Requirements
This project only supports the [actively supported versions of Angular as stated in the Angular documentation](https://angular.io/guide/releases#actively-supported-versions). Whilst other versions might be compatible they are not actively supported
## Sponsor
### Installation
|||
|-|-|
|![auth0 logo](https://user-images.githubusercontent.com/83319/31722733-de95bbde-b3ea-11e7-96bf-4f4e8f915588.png)|If you want to quickly add secure token-based authentication to your Angular projects, feel free to check [Auth0's Angular SDK](https://github.com/auth0/auth0-angular) and free plan at [auth0.com/developers](https://auth0.com/developers?utm_source=GHsponsor&utm_medium=GHsponsor&utm_campaign=angular2-jwt&utm_content=auth)|
## Installation
```bash

@@ -29,26 +35,4 @@ # installation with npm

**This library relies on the URL interface which is not supported in IE11.**
To solve the IE11 compatibility, you can add a polyfill.
## Configure the SDK
- run `npm i --save url-polyfill`
- add `import 'url-polyfill';` to `polyfills.ts` in your project
## Usage: Standalone
If you are only interested in the JWT Decoder, and are not interested in extended
injectable features, you can simply create an instance of the utility and use it
directly:
```ts
import { JwtHelperService } from "@auth0/angular-jwt";
const helper = new JwtHelperService();
const decodedToken = helper.decodeToken(myRawToken);
const expirationDate = helper.getTokenExpirationDate(myRawToken);
const isExpired = helper.isTokenExpired(myRawToken);
```
## Usage: Injection
Import the `JwtModule` module and add it to your imports list. Call the `forRoot` method and provide a `tokenGetter` function. You must also add any domains to the `allowedDomains`, that you want to make requests to by specifying an `allowedDomains` array.

@@ -100,312 +84,33 @@

## Configuration Options
## API reference
Read [our API reference](https://github.com/auth0/angular2-jwt/blob/main/API.md) to get a better understanding on how to use this SDK.
### `tokenGetter: function(HttpRequest): string`
## Feedback
The `tokenGetter` is a function which returns the user's token. This function simply needs to make a retrieval call to wherever the token is stored. In many cases, the token will be stored in local storage or session storage.
### Contributing
```ts
// ...
JwtModule.forRoot({
config: {
// ...
tokenGetter: () => {
return localStorage.getItem("access_token");
},
},
});
```
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
If you have multiple tokens for multiple domains, you can use the `HttpRequest` passed to the `tokenGetter` function to get the correct token for each intercepted request.
- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
- [This repo's contribution guide](https://github.com/auth0/angular2-jwt/blob/main/CONTRIBUTING.md)
### Raise an issue
```ts
// ...
JwtModule.forRoot({
config: {
// ...
tokenGetter: (request) => {
if (request.url.includes("foo")) {
return localStorage.getItem("access_token_foo");
}
To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/angular2-jwt/issues).
return localStorage.getItem("access_token");
},
},
});
```
### Vulnerability Reporting
### `allowedDomains: array`
Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues.
Authenticated requests should only be sent to domains you know and trust. Many applications make requests to APIs from multiple domains, some of which are not controlled by the developer. Since there is no way to know what the API being called will do with the information contained in the request, it is best to not send the user's token to all APIs in a blind fashion.
---
List any domains you wish to allow authenticated requests to be sent to by specifying them in the `allowedDomains` array. **Note that standard http port 80 and https port 443 requests don't require a port to be specified. A port is only required in the allowed domains host name if you are authenticating against a non-standard port e.g. localhost:3001**
```ts
// ...
JwtModule.forRoot({
config: {
// ...
allowedDomains: ["localhost:3001", "foo.com", "bar.com"],
},
});
```
### `disallowedRoutes: array`
If you do not want to replace the authorization headers for specific routes, list them here. This can be useful if your
initial auth route(s) are on an allowed domain and take basic auth headers. These routes need to be prefixed with the correct protocol (`http://`, `https://`). If you want to add a route to the list of disallowed routes regardless of the protocol, you can prefix it with `//`.
```ts
// ...
JwtModule.forRoot({
config: {
// ...
disallowedRoutes: [
"http://localhost:3001/auth/",
"https://foo.com/bar/",
"//foo.com/bar/baz",
/localhost:3001\/foo\/far.*/,
], // strings and regular expressions
},
});
```
**Note:** If requests are sent to the same domain that is serving your Angular application, you do not need to add that domain to the `allowedDomains` array. However, this is only the case if you don't specify the domain in the `Http` request.
For example, the following request assumes that the domain is the same as the one serving your app. It doesn't need to be allowed in this case.
```ts
this.http.get('/api/things')
.subscribe(...)
```
However, if you are serving your API at the same domain as that which is serving your Angular app **and** you are specifying that domain in `Http` requests, then it **does** need to be explicitely allowed.
```ts
// Both the Angular app and the API are served at
// localhost:4200 but because that domain is specified
// in the request, it must be allowed
this.http.get('http://localhost:4200/api/things')
.subscribe(...)
```
### `headerName: string`
The default header name is `Authorization`. This can be changed by specifying a custom `headerName` which is to be a string value.
```ts
// ...
JwtModule.forRoot({
config: {
// ...
headerName: "Your Header Name",
},
});
```
### `authScheme: string | function(HttpRequest): string`
The default authorization scheme is `Bearer` followed by a single space. This can be changed by specifying a custom `authScheme`. You can pass a string which will prefix the token for each request.
```ts
// ...
JwtModule.forRoot({
config: {
// ...
authScheme: "Basic ",
},
});
```
If you want to change the auth scheme dynamically, or based on the request, you can configure a getter function which returns a string.
```ts
// ...
JwtModule.forRoot({
config: {
// ...
authScheme: (request) => {
if (request.url.includes("foo")) {
return "Basic ";
}
return "Bearer ";
},
},
});
```
### `throwNoTokenError: boolean`
Setting `throwNoTokenError` to `true` will result in an error being thrown if a token cannot be retrieved with the `tokenGetter` function. Defaults to `false`.
```ts
// ...
JwtModule.forRoot({
config: {
// ...
throwNoTokenError: true,
},
});
```
### `skipWhenExpired: boolean`
By default, the user's JWT will be sent in `HttpClient` requests even if it is expired. You may choose to not allow the token to be sent if it is expired by setting `skipWhenExpired` to true.
```ts
// ...
JwtModule.forRoot({
config: {
// ...
skipWhenExpired: true,
},
});
```
## Using a Custom Options Factory Function
In some cases, you may need to provide a custom factory function to properly handle your configuration options. This is the case if your `tokenGetter` function relies on a service or if you are using an asynchronous storage mechanism (like Ionic's `Storage`).
Import the `JWT_OPTIONS` `InjectionToken` so that you can instruct it to use your custom factory function.
Create a factory function and specify the options as you normally would if you were using `JwtModule.forRoot` directly. If you need to use a service in the function, list it as a parameter in the function and pass it in the `deps` array when you provide the function.
```ts
import { JwtModule, JWT_OPTIONS } from '@auth0/angular-jwt';
import { TokenService } from './app.tokenservice';
// ...
export function jwtOptionsFactory(tokenService) {
return {
tokenGetter: () => {
return tokenService.getAsyncToken();
},
allowedDomains: ["example.com"]
}
}
// ...
@NgModule({
// ...
imports: [
JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [TokenService]
}
})
],
providers: [TokenService]
})
```
**Note:**: If a `jwtOptionsFactory` is defined, then `config` is ignored. _Both configuration alternatives can't be defined at the same time_.
## Configuration for Ionic 2+
The custom factory function approach described above can be used to get a token asynchronously with Ionic's `Storage`.
```ts
import { JwtModule, JWT_OPTIONS } from '@auth0/angular-jwt';
import { Storage } from '@ionic/storage';
export function jwtOptionsFactory(storage) {
return {
tokenGetter: () => {
return storage.get('access_token');
},
allowedDomains: ["example.com"]
}
}
// ...
@NgModule({
// ...
imports: [
JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [Storage]
}
})
]
})
```
**Note:**: If a `jwtOptionsFactory` is defined, then `config` is ignored. _Both configuration alternatives can't be defined at the same time_.
## Configuration Options
### `JwtHelperService: service`
This service contains helper functions:
## isTokenExpired (old tokenNotExpired function)
```
import { JwtHelperService } from '@auth0/angular-jwt';
// ...
constructor(public jwtHelper: JwtHelperService) {}
ngOnInit() {
console.log(this.jwtHelper.isTokenExpired()); // true or false
}
```
## getTokenExpirationDate
```
import { JwtHelperService } from '@auth0/angular-jwt';
// ...
constructor(public jwtHelper: JwtHelperService) {}
ngOnInit() {
console.log(this.jwtHelper.getTokenExpirationDate()); // date
}
```
## decodeToken
```
import { JwtHelperService } from '@auth0/angular-jwt';
// ...
constructor(public jwtHelper: JwtHelperService) {}
ngOnInit() {
console.log(this.jwtHelper.decodeToken(token)); // token
}
```
## What is Auth0?
Auth0 helps you to:
- Add authentication with [multiple authentication sources](https://auth0.com/docs/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, among others**, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**.
- Add authentication through more traditional **[username/password databases](https://auth0.com/docs/connections/database/custom-db)**.
- Add support for **[linking different user accounts](https://auth0.com/docs/link-accounts)** with the same user.
- Support for generating signed [Json Web Tokens](https://auth0.com/docs/jwt) to call your APIs and **flow the user identity** securely.
- Analytics of how, when and where users are logging in.
- Pull data from other sources and add it to the user profile, through [JavaScript rules](https://auth0.com/docs/rules/current).
## Create a free Auth0 account
1. Go to [Auth0](https://auth0.com/signup) and click Sign Up.
2. Use Google, GitHub or Microsoft Account to login.
## Issue Reporting
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.
## Author
[Auth0](auth0.com)
## License
This project is licensed under the MIT license. See the [LICENSE](LICENSE.txt) file for more info.
<p align="center">
<picture>
<source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
<img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
</picture>
</p>
<p align="center">Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a></p>
<p align="center">
This project is licensed under the MIT license. See the <a href="https://github.com/auth0/angular2-jwt/blob/main/LICENSE"> LICENSE</a> file for more info.</p>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc