Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .env.example

This file was deleted.

2 changes: 1 addition & 1 deletion src/controllers/reclaimController.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ exports.signHandler = async (req, res) => {
message: `Failed to process request: ${error.message}`,
})
}
}
}
2 changes: 1 addition & 1 deletion src/services/githubService.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ const getUserCommits = async username => {
`Total commits by ${username} in the last 10 years: ${response.data.total_count}`
)
return response.data.total_count
}
}
12 changes: 4 additions & 8 deletions src/services/newIntegrationService.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse')

exports.processNewIntegrationData = async (proof, providerName) => {
// TODO: Extract relevant data from the proof
// Replace 'newParameter' with the actual parameter you need to extract
// Extract relevant data from the proof
const newData = JSON.parse(proof[0].claimData.context).extractedParameters.newParameter

// TODO: Process the extracted data
// Adjust the extraction logic based on the actual format of the data
// For example, if the data is a string with numeric value
// Process the extracted data
const newValue = newData.match(/value=\\"([\d,]+)/)[1].replace(/,/g, '')

// TODO: Extract additional relevant data from the proof
// Extract additional relevant data from the proof
const url = JSON.parse(proof[0].claimData.parameters).url
const matchurl = url.match(/user\/([^\/]+)/)
const username = matchurl ? matchurl[1] : null
const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS)

// TODO: Create a ReclaimServiceResponse object with the processed data
// Adjust the parameters and processing logic based on the actual data structure
// Create a ReclaimServiceResponse object with the processed data
return new ReclaimServiceResponse(providerName, lastUpdateTimeStamp, username, parseInt(newValue, 10), proof[0])
}
6 changes: 5 additions & 1 deletion src/services/reclaimService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { Reclaim } = require('@reclaimprotocol/js-sdk')
const { RECLAIM_PROVIDER_ID, RECLAIM_APP_ID } = require('../utils/constants')
const { processTwitterData } = require('./twitterService')
const { processGitHubData } = require('./githubService')
const { processNewIntegrationData } = require('./newIntegrationService') // Add this line

exports.signWithProviderID = async (userId, providerId) => {
const providerName = RECLAIM_PROVIDER_ID[providerId]
Expand Down Expand Up @@ -49,6 +50,9 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => {
case 'GITHUB_ACCOUNT_VERIFICATION':
processedData = await processGitHubData(proof, providerName)
break
case 'NEW_INTEGRATION_SERVICE': // Add this case
processedData = await processNewIntegrationData(proof, providerName)
break
default:
throw new Error(`No handler for provider: ${providerName}`)
}
Expand All @@ -65,4 +69,4 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => {
console.error(`Verification failed for userId: ${userId}`, error)
},
})
}
}
2 changes: 1 addition & 1 deletion src/services/twitterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ exports.processTwitterData = async (proof, providerName) => {
parseInt(tweetViewsValue, 10),
proof[0]
)
}
}
4 changes: 3 additions & 1 deletion src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
exports.RECLAIM_PROVIDER_ID = {
twitter: 'TWITTER_ANALYTICS_VIEWS',
github: 'GITHUB_ACCOUNT_VERIFICATION',
newIntegration: 'NEW_INTEGRATION_SERVICE'
}

exports.RECLAIM_APP_ID = {
TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id',
GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id',
}
NEW_INTEGRATION_SERVICE: 'your-new-integration-app-id'
}
2 changes: 1 addition & 1 deletion src/utils/reclaimServiceResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class ReclaimServiceResponse {
}
}

module.exports = { ReclaimServiceResponse }
module.exports = { ReclaimServiceResponse }