auth0 / angular-jwt

Library to help you work with JWTs on AngularJS
MIT License
0 stars 1 forks source link

Angular 6.0.0 not supporting the Angular JWT #171

Closed ghost closed 6 years ago

ghost commented 6 years ago

Packages Json:

    @angular/animations": **"^6.0.0",**
    "@angular/cdk": **"^6.0.0",**
    "@angular/common": **"^6.0.0",**
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/material": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "@auth0/angular-jwt": "^1.1.0",
    "core-js": "^2.5.4",
    "hammerjs": "^2.0.8",
    "jwt-decode": "^2.2.0",
    "ngx-cookie-service": "^1.0.10",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"

Log Error:

ERROR in node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(3,10): error TS2305: Module '"C:/project/lawassito/node_modules/rxjs/Observable"' has no exported member 'Observable'. node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.

timfogarty-row8 commented 6 years ago

the issue is rxjs 6.0. It looks like only three changes need to be made:

In jwt.interceptor.d.ts, and in jtw.interceptor.js, change

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/operator/mergeMap';

to

import { Observable, pipe } from 'rxjs';
import { fromPromise, mergeMap } from 'rxjs/operators';

then in the js file, change

return Observable.fromPromise(token).mergeMap(function (asyncToken) {
      return _this.handleInterception(asyncToken, request, next);
  });

to

return Observable.pipe(fromPromise(token),mergeMap(function (asyncToken) {
      return _this.handleInterception(asyncToken, request, next);
}));

Note that gets it to compile, but I've done no testing on it.

hesampour commented 6 years ago

I get the following error: Package "@auth0/angular-jwt" has an incompatible peer dependency to "@angular/common" (requires "^4.4.6||^5.0.0", would install "6.0.0")

hesampour commented 6 years ago

after adding everything and trying alot get the followng error in browser console ReferenceError: angular is not defined at angular-jwt.js:9 at Object../node_modules/angular-

would you please fix the issue for angular 6

chenkie commented 6 years ago

This lib is actually for Angular 1. You're looking for http://github.com/auth0/angular2-jwt

ShayMe21 commented 6 years ago

The naming of the packages can make you confused actually.

According to here (https://www.npmjs.com/package/@auth0/angular-jwt), you should be using @auth0/angular-jwt that supports Angular6+.

Please try with npm install @auth0/angular-jwt instead. I tested this earlier following the upgrade plan here (https://update.angular.io/) with the Angular2+ QuickStart SDK on Auth0 worked just fine.

hesampour commented 6 years ago

thanks alot.

josuevalrob commented 6 years ago

Is it in the master? should I update?

nhrrsn commented 6 years ago

It works but the package rxjs-compat is still required for backwards compatibility. Any idea when rxjs-compat can be removed?

ERROR in node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(3,10): error TS2305: Module '"/home/user/project/node_modules/rxjs/Observable"' has no exported member 'Observable'. node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.

ghost commented 6 years ago

Oho - I just saw the chenkie comment, I think he is right, SO I am closing this issue. Thanks chenkie.

krushnachandra commented 6 years ago

ERROR TypeError: Observable_1.Observable.defer is not a function at AuthHttp.push../node_modules/angular2-jwt/angular2-jwt.js.AuthHttp.request (angular2-jwt.js:140) at AuthHttp.push../node_modules/angular2-jwt/angular2-jwt.js.AuthHttp.requestHelper (angular2-jwt.js:104) at AuthHttp.push../node_modules/angular2-jwt/angular2-jwt.js.AuthHttp.get (angular2-jwt.js:151)

getting this error after updating to angular 6

hesampour commented 6 years ago

you are using angular2-jwt. change it to @auth0/angular-jwt.

krushnachandra commented 6 years ago

@hesampour thanks bro it worked after moving to @auth0/angular-jwt v2