Skip to content

Commit

Permalink
Merge pull request #666 from auth0/feature/angular-10-support
Browse files Browse the repository at this point in the history
Feature/angular 10 support
  • Loading branch information
Sambego authored Jul 7, 2020
2 parents 566f4be + 403b68c commit 3c45ffb
Show file tree
Hide file tree
Showing 14 changed files with 6,579 additions and 5,924 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
Expand Down
12,299 changes: 6,462 additions & 5,837 deletions package-lock.json

Large diffs are not rendered by default.

56 changes: 32 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,51 @@
"postbuild": "cp ./README.md ./CHANGELOG.md ./LICENSE ./dist/angular-jwt/",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"release": "np",
"release:preview": "np --preview ",
"release:dry": "np --no-publish"
},
"private": false,
"dependencies": {
"@angular/common": "~9.1.1",
"@angular/compiler": "~9.1.1",
"@angular/core": "~9.1.1",
"url": "^0.11.0",
"@angular/platform-browser": "~9.1.1",
"@angular/platform-browser-dynamic": "~9.1.1",
"@angular/common": "~10.0.1",
"@angular/compiler": "~10.0.1",
"@angular/core": "~10.0.1",
"@angular/platform-browser": "~10.0.1",
"@angular/platform-browser-dynamic": "~10.0.1",
"core-js": "^3.2.1",
"rxjs": "~6.5.3",
"tslib": "^1.10.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.0",
"@angular-devkit/build-ng-packagr": "~0.901.0",
"@angular/cli": "~9.1.0",
"@angular/compiler-cli": "~9.1.1",
"@angular/language-service": "~9.1.1",
"@angular-devkit/build-angular": "~0.1000.0",
"@angular-devkit/build-ng-packagr": "~0.1000.0",
"@angular/cli": "~10.0.0",
"@angular/compiler-cli": "~10.0.1",
"@angular/language-service": "~10.0.1",
"@types/jasmine": "~3.4.1",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"ng-packagr": "^9.0.0",
"protractor": "~5.4.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~3.3.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ng-packagr": "^10.0.0",
"np": "^6.2.5",
"protractor": "~7.0.0",
"ts-node": "~8.4.1",
"tslib": "^1.9.0",
"tslint": "~5.20.0",
"typescript": "~3.7.5"
"tslint": "~6.1.0",
"typescript": "~3.9.5"
},
"np": {
"contents": "dist/angular-jwt"
},
"publishConfig": {
"access": "public"
}
}
}
16 changes: 5 additions & 11 deletions projects/angular-jwt/ng-package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/angular-jwt",
"lib": {
"entryFile": "src/index.ts",
"umdModuleIds": {
"url": "url"
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/angular-jwt",
"lib": {
"entryFile": "src/index.ts"
}
},
"whitelistedNonPeerDependencies": [
"url"
]
}
}
6 changes: 3 additions & 3 deletions projects/angular-jwt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"peerDependencies": {
"@angular/common": ">=7.1.0"
},
"dependencies": {
"url": "^0.11.0"
}
"dependencies": {
"tslib": "^2.0.0"
}
}
31 changes: 17 additions & 14 deletions projects/angular-jwt/src/lib/jwt.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { JwtHelperService } from "./jwthelper.service";
import { JWT_OPTIONS } from "./jwtoptions.token";

import { mergeMap } from "rxjs/operators";
import { parse } from "url";
import { from, Observable } from "rxjs";

@Injectable()
Expand Down Expand Up @@ -42,18 +41,22 @@ export class JwtInterceptor implements HttpInterceptor {
}

isWhitelistedDomain(request: HttpRequest<any>): boolean {
const requestUrl: any = parse(request.url, false, true);
const hostName =
requestUrl.hostname !== null
? `${requestUrl.hostname}${
requestUrl.port && !this.standardPorts.includes(requestUrl.port)
? ":" + requestUrl.port
: ""
}`
: requestUrl.hostname;
const requestUrl: URL = new URL(request.url, window.location.origin);

// If the host equals the current window origin,
// the domain is whitelisted by default
if (requestUrl.host === window.location.host) {
return true;
}

// If not the current domain, check the whitelist
const hostName = `${requestUrl.hostname}${
requestUrl.port && !this.standardPorts.includes(requestUrl.port)
? ":" + requestUrl.port
: ""
}`;

return (
hostName === null ||
this.whitelistedDomains.findIndex((domain) =>
typeof domain === "string"
? domain === hostName
Expand All @@ -65,15 +68,15 @@ export class JwtInterceptor implements HttpInterceptor {
}

isBlacklistedRoute(request: HttpRequest<any>): boolean {
const requestedUrl = parse(request.url, false, true);
const requestedUrl: URL = new URL(request.url, window.location.origin);

return (
this.blacklistedRoutes.findIndex((route: string | RegExp) => {
if (typeof route === "string") {
const parsedRoute = parse(route, false, true);
const parsedRoute: URL = new URL(route, window.location.origin);
return (
parsedRoute.hostname === requestedUrl.hostname &&
parsedRoute.path === requestedUrl.path
parsedRoute.pathname === requestedUrl.pathname
);
}

Expand Down
2 changes: 1 addition & 1 deletion projects/angular-jwt/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
Expand Down
2 changes: 1 addition & 1 deletion projects/angular-jwt/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
Expand Down
2 changes: 1 addition & 1 deletion src/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
Expand Down
2 changes: 1 addition & 1 deletion src/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"types": [
Expand Down
31 changes: 31 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"paths": {
"angular-jwt": [
"projects/angular-jwt/src/index"
],
"angular-jwt/*": [
"projects/angular-jwt/src/*"
]
}
}
}
53 changes: 24 additions & 29 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
/*
This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
It is not intended to be used to perform a compilation.
To learn more about this file see: https://angular.io/config/solution-tsconfig.
*/
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"paths": {
"angular-jwt": [
"projects/angular-jwt/src/index"
],
"angular-jwt/*": [
"projects/angular-jwt/src/*"
]
"files": [],
"references": [
{
"path": "./src/tsconfig.app.json"
},
{
"path": "./src/tsconfig.spec.json"
},
{
"path": "./e2e/tsconfig.e2e.json"
},
{
"path": "./projects/angular-jwt/tsconfig.lib.json"
},
{
"path": "./projects/angular-jwt/tsconfig.spec.json"
}
}
}
]
}
1 change: 0 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
Expand Down

0 comments on commit 3c45ffb

Please sign in to comment.