@@ -47,7 +47,7 @@ function validateParameters(parameters, requiredParameters) {
47
47
48
48
exports . OAuthServices = function ( provider , legs ) {
49
49
this . provider = provider ;
50
- var requiredMethods = [ 'applicationByConsumerKey' , 'validateNotReplay' ] ;
50
+ var requiredMethods = [ 'applicationByConsumerKey' ] ;
51
51
if ( legs ) {
52
52
this . legs = legs ;
53
53
}
@@ -74,8 +74,14 @@ exports.OAuthServices= function(provider, legs) {
74
74
75
75
}
76
76
}
77
-
78
77
78
+ this . providerProvidesValidateNotReplay = ( Object . prototype . toString . call ( provider . validateNotReplay ) === "[object Function]" ) ;
79
+ this . providerProvidesValidateNotReplayClient = ( Object . prototype . toString . call ( provider . validateNotReplayClient ) === "[object Function]" ) ;
80
+ if ( ! this . providerProvidesValidateNotReplay && ! this . providerProvidesValidateNotReplayClient ) {
81
+ throw new Error ( "Data provider must provide either validateNotReplay() or validateNotReplayClient()" ) ;
82
+ } else {
83
+
84
+ }
79
85
} ;
80
86
81
87
exports . OAuthServices . prototype . tokenByTokenAndConsumer = function ( token , consumerKey , callback ) {
@@ -214,13 +220,23 @@ exports.OAuthServices.prototype.authorize= function(request, protocol, callback)
214
220
215
221
// Given all the requestParameters and the next step function, error out if the a replay is detected
216
222
var validateNotReplay = function ( requestParameters , next ) {
217
- self . provider . validateNotReplay ( requestParameters . oauth_token , requestParameters . oauth_timestamp , requestParameters . oauth_nonce , function ( err , result ) {
218
- if ( err ) {
219
- callback ( new errors . OAuthUnauthorizedError ( 'Invalid / used nonce' ) , null ) ;
220
- } else {
221
- next ( ) ;
222
- }
223
- } ) ;
223
+ if ( self . providerProvidesValidateNotReplayClient ) {
224
+ self . provider . validateNotReplayClient ( requestParameters . oauth_consumer_key , requestParameters . oauth_token , requestParameters . oauth_timestamp , requestParameters . oauth_nonce , function ( err , result ) {
225
+ if ( err ) {
226
+ callback ( new errors . OAuthUnauthorizedError ( 'Invalid / used nonce' ) , null ) ;
227
+ } else {
228
+ next ( ) ;
229
+ }
230
+ } ) ;
231
+ } else {
232
+ self . provider . validateNotReplay ( requestParameters . oauth_token , requestParameters . oauth_timestamp , requestParameters . oauth_nonce , function ( err , result ) {
233
+ if ( err ) {
234
+ callback ( new errors . OAuthUnauthorizedError ( 'Invalid / used nonce' ) , null ) ;
235
+ } else {
236
+ next ( ) ;
237
+ }
238
+ } ) ;
239
+ }
224
240
} ;
225
241
226
242
var getApplicationByConsumerKey = function ( consumer_key , next ) {
0 commit comments