Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript definition #91

Open
shabith opened this issue Jun 12, 2016 · 6 comments
Open

TypeScript definition #91

shabith opened this issue Jun 12, 2016 · 6 comments

Comments

@shabith
Copy link

shabith commented Jun 12, 2016

Hi,

It would be really nice to have a TypeScript definition for TypeScript users.

more info can be found here.
typings/typings#322

@ruipenso
Copy link
Member

@shabith PRs are welcome :)

@cskiwi
Copy link

cskiwi commented Jul 1, 2016

Here is a basic d.ts. I created,
still waiting for the Oauth server to test the plugin out, untill then this seems like the right typing

I'm not sure if the grantPath and revokePath are required so I made the required

declare namespace angular.oauth2 {
    /*
     * IOAuth 
     */

     interface IOAuthConfig {
        baseUrl: string;
        clientId: string;
        clientSecret?: string;
        grantPath?: string;
        revokePath?: string;
    }
    interface IOAuthProvider {
        configure(params: IOAuthConfig): IOAuthConfig;
    }

    interface IData {
        username: string;
        password: string;
    }

    interface IOAuth {
        isAuthenticated(): boolean;
        getAccessToken(data: IData, options?: any): angular.IPromise<string>;
        getRefreshToken(data?: IData, options?: any): angular.IPromise<string>;
        revokeToken(data?: IData, options?: any): angular.IPromise<string>;
    }

    /*
     * IOAuthToken 
     */
    interface IOAuthTokenConfig {
        name: string;
        options: IOAuthTokenOptions;
    }

    interface IOAuthTokenOptions {
        secure: boolean;
    }

    interface IOAuthTokenProvider {
        configure(params: IOAuthTokenConfig): IOAuthTokenConfig;
    }
}

@shabith
Copy link
Author

shabith commented Jul 1, 2016

this is great @cskiwi. Thanks for sharing this.

2 things to mention,

  1. grantPath and revokePath are optional.
  2. I think we need another 2 interfaces call IOAuthTokenProvider and IOAuthTokenConfig
interface IOAuthTokenConfig {
        name: string;
        options: any;
    }

interface IOAuthTokenProvider {
        configure(params:IOAuthTokenConfig): IOAuthTokenConfig;
    }

What do you think?

@cskiwi
Copy link

cskiwi commented Jul 1, 2016

@shabith , yep good idea I also added a options interface, so we don't need the any param (I really hate seeing a any in typescript/typings ^^ )

@shabith
Copy link
Author

shabith commented Jul 1, 2016

That's good @cskiwi

@ruipenso
Copy link
Member

ruipenso commented Feb 3, 2017

@shabith @cskiwi Can we have a PR with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants