From 88cb5b5131fc0bc70b53cde8f5193e7b577dcdf5 Mon Sep 17 00:00:00 2001 From: vangorra Date: Tue, 9 Feb 2016 14:31:11 -0800 Subject: [PATCH] Adding support for Meteor package prime8consulting:meteor-oauth2. --- .../meteor-prime8consulting-oauth2-tests.ts | 27 ++++ .../meteor-prime8consulting-oauth2.d.ts | 116 ++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 meteor-prime8consulting-oauth2/meteor-prime8consulting-oauth2-tests.ts create mode 100644 meteor-prime8consulting-oauth2/meteor-prime8consulting-oauth2.d.ts diff --git a/meteor-prime8consulting-oauth2/meteor-prime8consulting-oauth2-tests.ts b/meteor-prime8consulting-oauth2/meteor-prime8consulting-oauth2-tests.ts new file mode 100644 index 000000000..0c4f57aa4 --- /dev/null +++ b/meteor-prime8consulting-oauth2/meteor-prime8consulting-oauth2-tests.ts @@ -0,0 +1,27 @@ +/// + +let str : string; +str = oAuth2Server.pubSubNames.authCodes; +str = oAuth2Server.pubSubNames.refreshTokens; + +str = oAuth2Server.methodNames.authCodeGrant; + +oAuth2Server.collections.refreshToken.find({}); +oAuth2Server.collections.authCode.find({}); +oAuth2Server.collections.accessToken.find({}); +oAuth2Server.collections.client.find({}); + +let obj = oAuth2Server.oauthserver; + +oAuth2Server.subscribeTo.authCode(); + +oAuth2Server.callMethod.authCodeGrant( + 'client_id', + 'redirect_uri', + 'response_type', + ['scope1', 'scope'], + 'state', + (err : Meteor.Error, result : OAuth2Server.AuthCodeGrantResult) => { + + } +); diff --git a/meteor-prime8consulting-oauth2/meteor-prime8consulting-oauth2.d.ts b/meteor-prime8consulting-oauth2/meteor-prime8consulting-oauth2.d.ts new file mode 100644 index 000000000..eb4e84628 --- /dev/null +++ b/meteor-prime8consulting-oauth2/meteor-prime8consulting-oauth2.d.ts @@ -0,0 +1,116 @@ +// Type definitions for prime8consulting:meteor-oauth2 +// Project: https://github.com/prime-8-consulting/meteor-oauth2/ +// Definitions by: Robbie Van Gorkom +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module OAuth2Server { + interface RefreshToken { + refreshToken : string; + clientId : string; + userId : string; + expires : Date; + } + + interface AuthCode { + authCode : string; + clientId : string; + userId : string; + expires : Date; + } + + interface AccessToken { + accessToken : string; + clientId : string; + userId : string; + expires : Date + } + + interface Client { + clientId : string; + active : boolean; + redirectUri : string; + clientSecret : string; + } + + interface PubSubNames { + /** + * Constant string representing the auth codes pub/sub. + */ + authCodes : string; + + /** + * Constant string representing the refresh token pub/sub. + */ + refreshTokens : string; + } + + interface MethodNames { + /** + * Constant string representing th authCodeGran meteor method. + */ + authCodeGrant : string; + } + + interface Collections { + /** + * Collection of the refresh tokens. + */ + refreshToken : Mongo.Collection; + + /** + * Collection of the authorization codes. + */ + authCode : Mongo.Collection; + + /** + * (server only) Collection of the access tokens. + */ + accessToken : Mongo.Collection; + + /** + * (server only) Collection of the clients authorized to use the oauth2 service. + */ + client : Mongo.Collection; + } + + interface SubscribeTo { + /** + * Wrapper function to subscribe to the auth code subscription. Returns a standard subscription handle. + */ + authCode() : Meteor.SubscriptionHandle; + } + + interface AuthCodeGrantResult { + success : boolean; + error : any; + authorizationCode : string; + redirectToUri : string; + } + + interface CallMethod { + /** + * Wrapper for Meteor.method to create an authorization code. This is an async function and a callback must be provided to be of any use. + */ + authCodeGrant( + client_id : string, + redirect_uri : string, + response_type : string, + scope : string[], + state : string, + callback : (err : Meteor.Error, authCodeGrantResult : AuthCodeGrantResult) => void + ) : void; + } + + interface OAuth2Server { + pubSubNames : PubSubNames; + methodNames : MethodNames; + collections : Collections; + oauthserver : any; + subscribeTo : SubscribeTo; + callMethod : CallMethod; + } +} + +declare var oAuth2Server : OAuth2Server.OAuth2Server;