diff --git a/package.json b/package.json index ac9ddd6..36d611c 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "homepage": "https://github.com/CatoffGaming/catoff-reclaim-integration-proposal#readme", "dependencies": { "@reclaimprotocol/js-sdk": "^1.3.6", + "@reclaimprotocol/zk-fetch": "^0.1.2", "axios": "^1.7.2", "body-parser": "^1.20.2", "dotenv": "^16.4.5", diff --git a/readme1.md b/readme1.md new file mode 100644 index 0000000..e69de29 diff --git a/src/controllers/reclaimController.js b/src/controllers/reclaimController.js index 6329e3d..5a77e4b 100644 --- a/src/controllers/reclaimController.js +++ b/src/controllers/reclaimController.js @@ -2,6 +2,7 @@ const { signWithProviderID } = require('../services/reclaimService') exports.signHandler = async (req, res) => { const { userId, providerId } = req.body + console.log(req.body); try { const signedUrl = await signWithProviderID(userId, providerId) diff --git a/src/services/githubService.js b/src/services/githubService.js index 043897d..b60ec04 100644 --- a/src/services/githubService.js +++ b/src/services/githubService.js @@ -2,6 +2,7 @@ const axios = require('axios') const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') exports.processGitHubData = async (proof, providerName) => { + console.log("go for it : ",providerName) const githubUsername = JSON.parse(proof[0].claimData.context) .extractedParameters.userName const lastUpdateTimeStamp = proof[0].claimData.timestampS @@ -22,6 +23,7 @@ const getUserCommits = async username => { const dateSince = new Date(new Date().setDate(new Date().getDate() - daysAgo)) .toISOString() .split('T')[0] + console.log("user name : ",username) const url = `https://api.github.com/search/commits?q=author:${username}+committer-date:>${dateSince}` const githubToken = process.env.RECLAIM_GITHUB_TOKEN @@ -37,3 +39,27 @@ const getUserCommits = async username => { ) return response.data.total_count } + + + + + +// // Package import +// import { Reclaim } from '@reclaimprotocol/js-sdk'; + +// const getVerificationReq = async () => { +// const reclaimClient = new Reclaim.ProofRequest("0x449c4A598810232e36e56579eBB8e28DFb98C47B" ); +// const providerIds = [ +// 'bc3ebc42-0726-4ac8-9d6b-c4cde5cfa145', // Tyretp +// ]; +// const APP_SECRET ="0x80758e792730a0993e3271ccc81b17c1d40a309079165e86ec5713f71e9a2dea" // your app secret key. + +// await reclaimClient.buildProofRequest(providerIds[0]) +// reclaimClient.setSignature( +// await reclaimClient.generateSignature( +// APP_SECRET +// ) +// ) +// const {reclaimUrl, statusUrl} = await reclaimClient.createVerificationRequest() +// return {reclaimUrl, statusUrl} +// } diff --git a/src/services/new1.js b/src/services/new1.js new file mode 100644 index 0000000..e69de29 diff --git a/src/services/reclaimService.js b/src/services/reclaimService.js index b33006f..65b618b 100644 --- a/src/services/reclaimService.js +++ b/src/services/reclaimService.js @@ -3,11 +3,18 @@ const { Reclaim } = require('@reclaimprotocol/js-sdk') const { RECLAIM_PROVIDER_ID, RECLAIM_APP_ID } = require('../utils/constants') const { processTwitterData } = require('./twitterService') const { processGitHubData } = require('./githubService') +require('dotenv').config(); exports.signWithProviderID = async (userId, providerId) => { + console.log("boo : ",userId,providerId); + console.log("RECLAIM_PROVIDER_ID edfe : ",RECLAIM_PROVIDER_ID[providerId]) const providerName = RECLAIM_PROVIDER_ID[providerId] + console.log("Provider name : " ,providerName) const reclaimAppID = RECLAIM_APP_ID[providerName] + console.log("reclaimAppID : " ,reclaimAppID) + //const hj=`${providerName}_SECRET`; const reclaimAppSecret = process.env[`${providerName}_SECRET`] + console.log("reclaimAppSecret : " ,reclaimAppSecret) console.log( `Sending signature request to Reclaim for userId: ${userId} with providerName: ${providerName}` @@ -15,15 +22,22 @@ exports.signWithProviderID = async (userId, providerId) => { try { const reclaimClient = new Reclaim.ProofRequest(reclaimAppID) + console.log(reclaimClient) await reclaimClient.buildProofRequest(providerId) reclaimClient.setSignature( await reclaimClient.generateSignature(reclaimAppSecret) ) + const { requestUrl: signedUrl } = await reclaimClient.createVerificationRequest() + console.log("hhhbb :",{ requestUrl: signedUrl }) await handleReclaimSession(userId, reclaimClient, providerName) + + + console.log("ended"); return signedUrl + } catch (error) { console.error( `Failed to process Reclaim request for userId: ${userId}`, @@ -34,20 +48,27 @@ exports.signWithProviderID = async (userId, providerId) => { } const handleReclaimSession = async (userId, reclaimClient, providerName) => { + await reclaimClient.startSession({ + onSuccessCallback: async proof => { + console.log("two") console.log( `Successful reclaim callback with proof: ${JSON.stringify(proof)}` ) + console.log("aa : ",proof); try { let processedData + console.log("two"); switch (providerName) { case 'TWITTER_ANALYTICS_VIEWS': processedData = await processTwitterData(proof, providerName) break - case 'GITHUB_ACCOUNT_VERIFICATION': + case 'GITHUB_ACCOUNT': + console.log("fourth") processedData = await processGitHubData(proof, providerName) + break default: throw new Error(`No handler for provider: ${providerName}`) @@ -65,4 +86,29 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => { console.error(`Verification failed for userId: ${userId}`, error) }, }) + //console.log("hgvnbm : ",t ) } + + + console.log("ended"); + + +// // Package import +// import { Reclaim } from '@reclaimprotocol/js-sdk'; + +// const getVerificationReq = async () => { +// const reclaimClient = new Reclaim.ProofRequest("0x695FC75718ed80E17c4A72660314483Decf393B2" ); +// const providerIds = [ +// '7369ce2a-5e2f-436d-9df7-918197d26b81', // github name1 +// ]; +// const APP_SECRET ="0x29f88462113efb62bd5e1079bea7ea0eb2684e38bcda505cb1e4438adf606b09" // your app secret key. + +// await reclaimClient.buildProofRequest(providerIds[0]) +// reclaimClient.setSignature( +// await reclaimClient.generateSignature( +// APP_SECRET +// ) +// ) +// const {reclaimUrl, statusUrl} = await reclaimClient.createVerificationRequest() +// return {reclaimUrl, statusUrl} +// } diff --git a/src/utils/constants.js b/src/utils/constants.js index 1c58669..577fb98 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -1,9 +1,12 @@ exports.RECLAIM_PROVIDER_ID = { twitter: 'TWITTER_ANALYTICS_VIEWS', - github: 'GITHUB_ACCOUNT_VERIFICATION', + 'github-provider-id':'GITHUB_ACCOUNT',// add the provider id inside 'Apostrophe' } - exports.RECLAIM_APP_ID = { TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id', - GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id', + GITHUB_ACCOUNT: 'github-app-id',/// inside the Apostrophe } + +//user id : 4a1c50a83cf6cc4b55b6b9c53e553e3f847c876b87fb333f71f5d05db8f1a7db + +// app secret 0x29f88462113efb62bd5e1079bea7ea0eb2684e38bcda505cb1e4438adf606b09 \ No newline at end of file