angular-oauth2
angular-oauth2 copied to clipboard
TypeScript definition
Hi,
It would be really nice to have a TypeScript definition for TypeScript users.
more info can be found here. https://github.com/typings/typings/issues/322
@shabith PRs are welcome :)
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;
}
}
this is great @cskiwi. Thanks for sharing this.
2 things to mention,
-
grantPath
andrevokePath
are optional. - I think we need another 2 interfaces call
IOAuthTokenProvider
andIOAuthTokenConfig
interface IOAuthTokenConfig {
name: string;
options: any;
}
interface IOAuthTokenProvider {
configure(params:IOAuthTokenConfig): IOAuthTokenConfig;
}
What do you think?
@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 ^^ )
That's good @cskiwi
@shabith @cskiwi Can we have a PR with this?