Oidc-client-js: Rewrite in TS/ES6, and otherwise update

Created on 31 May 2015  Â·  33Comments  Â·  Source: IdentityModel/oidc-client-js

  • Allows for some unit testing
  • Allows for easier modules
  • Possibly allows for both npm/server and require/client modules (we'll see if I can make this happen)
enhancement

Most helpful comment

Does anyone have the actual typescript file or the generated definition file?

All 33 comments

Howdy! We're just attempting to introduce SSO across our company using IdentityServer and in the process of doing so we stumbled across this. Assuming we go forward, that should mean I should have offical resources to assist with the two OIDC libraries and I'd love to help convert to TS (as it's standard at our company) as well as help knock out other issues. Has there been an progress/plan for this?

No progress on the TS front and I'd love the help, as I'm spread thin across many of our OSS projects. Just today I was able to get to some of the more pressing backlog issues from the past many months.

If you're interesting in helping out, perhaps you can email me and we can setup a meeting to coordinate/collaborate.

I understand. I have a lot of OSS I can't contribute to much time to these days unless its work essential.

Happily! I didn't see your comment until after I'd already powered forward somewhat; see PR >_>

@brockallen I might be able to help. My company is also just starting to use IdentityServer and we are invested in TypeScript (we are pushing to move to Angular2 when it comes out of beta). I probably need to understand the OidcClient a little better but I am working with it today. If you are interested, I can get back to you this week.

@RichiCoder1 started already -- in fast I guess it's done. I'm still debating if I like TS enough. I'm convinced that it does need to get cleaned up (it's been on my TODO for a long time), but not sure if plain ES2015 or TS is better.

Please give me some input to help make this decision, as I am all ears.

A counter point I'd say is that TypeScript is basically ES6+ with typings and a more conservative feature on-ramp then something like babel :). I am bias though.

@brockallen @RichiCoder1 I've already done this for the oidc-token-manager repo, and here is a link for the same changes for this oidc-client repo. I used Typescript (just personal preference), but the largest benefits come from using SystemJS. I went over them here IdentityModel/oidc-token-manager#44

BTW @RichiCoder1, I wanted to invite/include you in this: https://github.com/IdentityModel/oidc-token-manager/issues/44#issuecomment-196018085

Question for you all (@RichiCoder1, @ryanwischkaemper, etc) -- any suggestions on how to approach testing module dependencies? is it best to design around them and inject everything into constructors, or is it easier to do some module hooking with webpack (or somewhere else -- mocha?) and then replace dependent modules with stubs/fakes/mocks?

First stab at new structure. Very much baby steps: https://github.com/IdentityModel/oidc-client/tree/es6_rewrite

That looks like a very good start to me!

@brockallen New structure is nice and clean! Are you talking about unit testing module dependencies? If so, then injecting them into constructors and mocking them in your unit tests is a great way to go.

Yes, that's basically what I was asking. I started that way, but in the past few hours I decided to do something like this:

import JsonService from './JsonService';

export default class MetadataService {
    constructor(jsonService) {
        this._jsonService = jsonService || new JsonService();
    }
}

So in the unit test can inject it, but then at runtime it'll pick up the default/real implementation. This also avoids what I started doing here: https://github.com/IdentityModel/oidc-client/blob/es6_rewrite/src/_index.js

@brockallen Looks good

Ok, now everything from oidc-client is now redone in es6/babel, now with:

  • ~218 tests
  • more JWT signature algorithm support
  • logging
  • pluggable async storage
  • support to round trip arbitrary state

I still have packaging to solve, and all the oidc-token-manager stuff to deal with as well.

@brockallen Very nice work! Just pulled it down, built, and ran all tests with no issues. If you'd like any help with the other stuff, I'd be glad to be of service

Well, what's the phantomjs test runner du-jour? is it still karma? i want to do some browser-based integration tests.

or.... maybe mocha-phantomjs since my unit tests are already using mocha...

@brockallen Yes, karma I think. There's also mocha-phantomjs, but I've never used it.

Ok, I just merged my es6 branch to dev, so I'll call this one closed. I'm done with the core OidcClient and now am moving on to the token manager logic, which I will try to merge into this library.

Packaging is basically sorted out and so the dist folder has a single self-contained JS for people that want just a single JS. I guess if you want a more module approach, then you'd get the repo and require/import the individual modules from src as needed -- is that the consumption model you both had in mind and will it work for you?

@brockallen Looking great. This is a huge step forward for this project. As for the distribution, I think it needs to be published to npm - that covers a large majority of developers including Browserify, RequireJS, and webpack users. As it stands right now, the only way to consume this library in a modular fashion with a package manager is via jspm, because it supports installing packages directly from Github.

If you'd like assistance with that or anything else, make some issues and maybe give them an es6 label or something?

What is the status of this now? I'm developing an ng2 app and would love to use this.

Very close.

-Brock

On Apr 21, 2016, at 3:55 AM, Henning Anderssen [email protected] wrote:

What is the status of this now? I'm developing an ng2 app and would love to use this.

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Do you have an approximate time frame work when it is ready? Or at least ready for test.

Nothing definitive. I'll be working on this next week.

-Brock

On Apr 21, 2016, at 7:30 AM, Henning Anderssen [email protected] wrote:

Do you have an approximate time frame work when it is ready?

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Ok, I think I'm now done with this port and have reproduced over all of the prior features (more or less). The API surface is certainly different, but should be still somewhat familiar. The code is certainly much cleaner now (I think). Code is all on the dev branch.

The sample folder shows two main uses -- one is the lower level OidcClient, and the other is the UserManager (which is the logical replacement for the prior token manager).

This is the last chance to provide feedback before I do a release in the next couple of days (to NPM).

Thanks.

Update: I have tested across Chrome, FF, Edge, and IE11. Also, i tested in IE10 and IE9 in emulator mode. All seem to be working (after some tweaking needed for IE-brands).

I released a beta on NPM this week, FWIW.

I'll close this now, as I think we can consider it complete.

Does anyone have the actual typescript file or the generated definition file?

I don't see any master branch, the following should work https://github.com/IdentityModel/oidc-client-js/blob/dev/oidc-client.d.ts

@kristofdegrave yes, thank you
@boban984 please look at the @kristofdegrave 's message.

Was this page helpful?
0 / 5 - 0 ratings