@@ -32,15 +32,12 @@ import { FindDdoHandler } from '../handler/ddoHandler.js'
3232// import { ProviderFeeValidation } from '../../../@types/Fees.js'
3333import { isOrderingAllowedForAsset } from '../handler/downloadHandler.js'
3434import { DDOManager } from '@oceanprotocol/ddo-js'
35- import { getNonceAsNumber , checkNonce , NonceResponse } from '../utils/nonceHandler.js'
35+ import { getNonceAsNumber } from '../utils/nonceHandler.js'
3636import { generateUniqueID } from '../../database/sqliteCompute.js'
3737
3838export class PaidComputeStartHandler extends CommandHandler {
3939 validate ( command : PaidComputeStartCommand ) : ValidateParams {
4040 const commandValidation = validateCommandParameters ( command , [
41- 'consumerAddress' ,
42- 'signature' ,
43- 'nonce' ,
4441 'environment' ,
4542 'algorithm' ,
4643 'datasets' ,
@@ -64,6 +61,19 @@ export class PaidComputeStartHandler extends CommandHandler {
6461 if ( this . shouldDenyTaskHandling ( validationResponse ) ) {
6562 return validationResponse
6663 }
64+
65+ const authValidationResponse = await this . validateTokenOrSignature (
66+ task . authorization ,
67+ task . consumerAddress ,
68+ task . nonce ,
69+ task . signature ,
70+ String ( task . consumerAddress + task . datasets [ 0 ] ?. documentId + task . nonce )
71+ )
72+
73+ if ( authValidationResponse . status . httpStatus !== 200 ) {
74+ return authValidationResponse
75+ }
76+
6777 try {
6878 const node = this . getOceanNode ( )
6979 // split compute env (which is already in hash-envId format) and get the hash
@@ -452,9 +462,6 @@ export class FreeComputeStartHandler extends CommandHandler {
452462 const commandValidation = validateCommandParameters ( command , [
453463 'algorithm' ,
454464 'datasets' ,
455- 'consumerAddress' ,
456- 'signature' ,
457- 'nonce' ,
458465 'environment'
459466 ] )
460467 if ( commandValidation . valid ) {
@@ -468,34 +475,23 @@ export class FreeComputeStartHandler extends CommandHandler {
468475 }
469476
470477 async handle ( task : FreeComputeStartCommand ) : Promise < P2PCommandResponse > {
478+ const thisNode = this . getOceanNode ( )
471479 const validationResponse = await this . verifyParamsAndRateLimits ( task )
472480 if ( this . shouldDenyTaskHandling ( validationResponse ) ) {
473481 return validationResponse
474482 }
475- const thisNode = this . getOceanNode ( )
476- // Validate nonce and signature
477- const nonceCheckResult : NonceResponse = await checkNonce (
478- thisNode . getDatabase ( ) . nonce ,
483+
484+ const authValidationResponse = await this . validateTokenOrSignature (
485+ task . authorization ,
479486 task . consumerAddress ,
480- parseInt ( task . nonce ) ,
487+ task . nonce ,
481488 task . signature ,
482489 String ( task . nonce )
483490 )
484-
485- if ( ! nonceCheckResult . valid ) {
486- CORE_LOGGER . logMessage (
487- 'Invalid nonce or signature, unable to proceed: ' + nonceCheckResult . error ,
488- true
489- )
490- return {
491- stream : null ,
492- status : {
493- httpStatus : 500 ,
494- error :
495- 'Invalid nonce or signature, unable to proceed: ' + nonceCheckResult . error
496- }
497- }
491+ if ( authValidationResponse . status . httpStatus !== 200 ) {
492+ return authValidationResponse
498493 }
494+
499495 let engine = null
500496 try {
501497 // split compute env (which is already in hash-envId format) and get the hash
0 commit comments