angular2-jwt icon indicating copy to clipboard operation
angular2-jwt copied to clipboard

Breaking changes in version 0.2.1+

Open max-was-here opened this issue 9 years ago • 8 comments

This library does not respect Semver as it introduces breaking changes in its version 0.2.1 :

The default token name as been changed, breaking all applications that were depending on the default token name for their authentication.

I suggest two options :

  • Support both token name, deprecating the first one but still fallback to it if the new token name cannot be found
  • Respect semver and change the MAJOR version when releasing a breaking change

For the first option, I can work to do a pull request when I have time.

max-was-here avatar Apr 11 '17 17:04 max-was-here

+1, just got a bunch of auth errors after doing a fresh npm install and traced it back to the token name change! My version went from 0.2.0 -> 0.2.2

gabrielalack avatar Apr 11 '17 20:04 gabrielalack

From what i have seen, the tokenNotExpired() method is not working correctly after updating 0.2.0 -> 0.2.2

hassanasad avatar Apr 12 '17 08:04 hassanasad

Yes, by default looks like it takes token as name.

If someone wants to keep his token name, just change the service factory:

export function authHttpServiceFactory(http: Http, options: RequestOptions) {
  return new AuthHttp(new AuthConfig({
    tokenName: 'id_token',
    globalHeaders: [{ 'Content-Type': 'application/json' }],
  }), http, options);
}

and the authenticated method, pass as argument the name

tokenNotExpired(`id_token`)

tomtobac avatar Apr 19 '17 08:04 tomtobac

@tomtobac yeah it works that way - i was just wondering why do we have to pass the token name in tokenNotExpired() method if we have already declared it in AuthConfig factory function. Shouldn't it pick from there automatically?

hassanasad avatar Apr 19 '17 08:04 hassanasad

@hassanasad Yes, you are right. I don't know why but I guess it should take it from there... I am wondering why not :thinking:

tomtobac avatar Apr 19 '17 08:04 tomtobac

I think the point of this issue is that you made backwards breaking changes, but only updated the patch number which should definitely not having breaking changes.

treeder avatar Apr 23 '17 22:04 treeder

This library does not respect Semver as it introduces breaking changes in its version 0.2.1

FYI, SemVer treats major version zero a little different:

Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.

sos4nt avatar Apr 25 '17 09:04 sos4nt

It's still convention that the minor version should change for breaking changes with major version 0. I don't know why it changed, or why it was done without any warning. I suspect it was to align better with the jwt spec.

escardin avatar Apr 25 '17 12:04 escardin