diff --git a/.env.example b/.env.example index 2494daa..12622fe 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,3 @@ TWITTER_ANALYTICS_VIEWS_SECRET=your-twitter-secret GITHUB_ACCOUNT_VERIFICATION_SECRET=your-github-secret -RECLAIM_GITHUB_TOKEN=your-github-token +RECLAIM_GITHUB_TOKEN=your-github-token \ No newline at end of file diff --git a/CRIP/CRIP-MonkeyType_120s.md b/CRIP/CRIP-MonkeyType_120s.md new file mode 100644 index 0000000..3e1ed35 --- /dev/null +++ b/CRIP/CRIP-MonkeyType_120s.md @@ -0,0 +1,83 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|--------------------|-------------------------------|----------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-2 | Monkeytype Integration | Integration with MonekeyType to get users typing speed in 120 sec | Ashwin KV | | Draft | Integration | CRIP | 2024-07-07 | | + +## Title + +Monkeytype Integration 60s + +## Introduction + +This proposal outlines the integration of monkeytype as a data provider for the Catoff-Reclaim integration project. The integration aims to retrieve and process user top typing speed data of 120 seconds from monkeytype, such as username, WPM,Accuracy and Time of achivement to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. + +## External APIs Needed + +- nill + +## Use Cases + +1. **User Verification**: Validate users' typing speeds and accuracy to ensure they meet specific standards for challenges and competitions. +2. **Challenge Participation**: Allow users to participate in typing challenges that require proof of their fastest typing speed and accuracy. +3. **Skill Assessment**: Assess users' typing skills based on their best performance on Monkeytype, helping to identify areas of improvement and track progress. +3. **Leaderboard Ranking**: Create leaderboards on the Catoff platform based on users' fastest typing speeds and accuracy from Monkeytype +3. **Team Competitions**: Organize team-based typing competitions where each team member's performance on Monkeytype contributes to the team's overall score. + +## Data Provider + +- **Name**: Monkeytype 120 sec data +- **Hash Value**: 0x059fe3942bf736c935700846a1b71ca91b93bdaaa65b37ea0d06834c90ee16b3 + +## Code Snippet + +Below is a code snippet that demonstrates the key parts of the GitHub integration. The full implementation should follow the service file template. + +**`services/monkeyTypeService.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const timeStamp = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username + + const date = new Date(Number(timeStamp)) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } + + // Format the date and time + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + wpm, + acc, + completionTime, + username, + } + const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) + + // Create a ReclaimServiceResponse object with the processed data + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + username, + ProcessedData, + proof[0] + ) +} + + +``` diff --git a/CRIP/CRIP-MonkeyType_15s.md b/CRIP/CRIP-MonkeyType_15s.md new file mode 100644 index 0000000..97035da --- /dev/null +++ b/CRIP/CRIP-MonkeyType_15s.md @@ -0,0 +1,83 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|--------------------|-------------------------------|----------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-2 | Monkeytype Integration | Integration with MonekeyType to get users typing speed in 15 sec | Ashwin KV | | Draft | Integration | CRIP | 2024-07-05 | | + +## Title + +Monkeytype Integration 15s + +## Introduction + +This proposal outlines the integration of monkeytype as a data provider for the Catoff-Reclaim integration project. The integration aims to retrieve and process user top typing speed data of 15 seconds from monkeytype, such as username, WPM,Accuracy and Time of achivement to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. + +## External APIs Needed + +- nill + +## Use Cases + +1. **User Verification**: Validate users' typing speeds and accuracy to ensure they meet specific standards for challenges and competitions. +2. **Challenge Participation**: Allow users to participate in typing challenges that require proof of their fastest typing speed and accuracy. +3. **Skill Assessment**: Assess users' typing skills based on their best performance on Monkeytype, helping to identify areas of improvement and track progress. +3. **Leaderboard Ranking**: Create leaderboards on the Catoff platform based on users' fastest typing speeds and accuracy from Monkeytype +3. **Team Competitions**: Organize team-based typing competitions where each team member's performance on Monkeytype contributes to the team's overall score. + +## Data Provider + +- **Name**: Monkeytype 15 sec data +- **Hash Value**: 0x604f5228860b144b6e63ff47e541c1419b38d119cc3828a917dd9966dc7bb3a1 + +## Code Snippet + +Below is a code snippet that demonstrates the key parts of the GitHub integration. The full implementation should follow the service file template. + +**`services/monkeyTypeService.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const timeStamp = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username + + const date = new Date(Number(timeStamp)) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } + + // Format the date and time + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + wpm, + acc, + completionTime, + username, + } + const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) + + // Create a ReclaimServiceResponse object with the processed data + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + username, + ProcessedData, + proof[0] + ) +} + + +``` diff --git a/CRIP/CRIP-MonkeyType_30s.md b/CRIP/CRIP-MonkeyType_30s.md new file mode 100644 index 0000000..536f501 --- /dev/null +++ b/CRIP/CRIP-MonkeyType_30s.md @@ -0,0 +1,83 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|--------------------|-------------------------------|----------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-2 | Monkeytype Integration | Integration with MonekeyType to get users typing speed in 30 sec | Ashwin KV | | Draft | Integration | CRIP | 2024-07-07 | | + +## Title + +Monkeytype Integration 30s + +## Introduction + +This proposal outlines the integration of monkeytype as a data provider for the Catoff-Reclaim integration project. The integration aims to retrieve and process user top typing speed data of 30 seconds from monkeytype, such as username, WPM,Accuracy and Time of achivement to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. + +## External APIs Needed + +- nill + +## Use Cases + +1. **User Verification**: Validate users' typing speeds and accuracy to ensure they meet specific standards for challenges and competitions. +2. **Challenge Participation**: Allow users to participate in typing challenges that require proof of their fastest typing speed and accuracy. +3. **Skill Assessment**: Assess users' typing skills based on their best performance on Monkeytype, helping to identify areas of improvement and track progress. +3. **Leaderboard Ranking**: Create leaderboards on the Catoff platform based on users' fastest typing speeds and accuracy from Monkeytype +3. **Team Competitions**: Organize team-based typing competitions where each team member's performance on Monkeytype contributes to the team's overall score. + +## Data Provider + +- **Name**: Monkeytype 30 sec data +- **Hash Value**: 0x12bfd8a194c63765e7dc5aa47d74114f812f26652bf8cae1b0677d2ad471815e + +## Code Snippet + +Below is a code snippet that demonstrates the key parts of the GitHub integration. The full implementation should follow the service file template. + +**`services/monkeyTypeService.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const timeStamp = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username + + const date = new Date(Number(timeStamp)) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } + + // Format the date and time + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + wpm, + acc, + completionTime, + username, + } + const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) + + // Create a ReclaimServiceResponse object with the processed data + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + username, + ProcessedData, + proof[0] + ) +} + + +``` diff --git a/CRIP/CRIP-MonkeyType_60s.md b/CRIP/CRIP-MonkeyType_60s.md new file mode 100644 index 0000000..3196c6c --- /dev/null +++ b/CRIP/CRIP-MonkeyType_60s.md @@ -0,0 +1,83 @@ +| proposal | title | description | author | discussions-to | status | type | category | created | requires | +|----------|--------------------|-------------------------------|----------------------------|----------------|--------|-------------|----------|------------|----------| +| CRIP-2 | Monkeytype Integration | Integration with MonekeyType to get users typing speed in 60 sec | Ashwin KV | | Draft | Integration | CRIP | 2024-07-07 | | + +## Title + +Monkeytype Integration 60s + +## Introduction + +This proposal outlines the integration of monkeytype as a data provider for the Catoff-Reclaim integration project. The integration aims to retrieve and process user top typing speed data of 60 seconds from monkeytype, such as username, WPM,Accuracy and Time of achivement to be used within the Catoff platform. This will enable users to validate their typing speed and use them for various challenges and verifications on Catoff. + +## External APIs Needed + +- nill + +## Use Cases + +1. **User Verification**: Validate users' typing speeds and accuracy to ensure they meet specific standards for challenges and competitions. +2. **Challenge Participation**: Allow users to participate in typing challenges that require proof of their fastest typing speed and accuracy. +3. **Skill Assessment**: Assess users' typing skills based on their best performance on Monkeytype, helping to identify areas of improvement and track progress. +3. **Leaderboard Ranking**: Create leaderboards on the Catoff platform based on users' fastest typing speeds and accuracy from Monkeytype +3. **Team Competitions**: Organize team-based typing competitions where each team member's performance on Monkeytype contributes to the team's overall score. + +## Data Provider + +- **Name**: Monkeytype 60 sec data +- **Hash Value**: 0x3904d64f3f1ce330bcd893fbaf9cf6ab94e58e3b22a200099f73a156bad646b7 + +## Code Snippet + +Below is a code snippet that demonstrates the key parts of the GitHub integration. The full implementation should follow the service file template. + +**`services/monkeyTypeService.js`** + +```javascript +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc + const timeStamp = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username + + const date = new Date(Number(timeStamp)) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } + + // Format the date and time + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + wpm, + acc, + completionTime, + username, + } + const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) + + // Create a ReclaimServiceResponse object with the processed data + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + username, + ProcessedData, + proof[0] + ) +} + + +``` diff --git a/package.json b/package.json index ac9ddd6..bade4b3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CRIP is an open source project to receieve community proposals for catoff challenges which are based on reclaim integration", "main": "index.js", "scripts": { - "start": "node index.js", + "start": "node --env-file=.env index.js ", "lint": "eslint '**/*.js'", "lint:fix": "eslint '**/*.js' --fix", "format": "prettier --write '**/*.js'" @@ -32,4 +32,4 @@ "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5" } -} +} \ No newline at end of file diff --git a/src/services/monkeyTypeService.js b/src/services/monkeyTypeService.js new file mode 100644 index 0000000..c99b3e1 --- /dev/null +++ b/src/services/monkeyTypeService.js @@ -0,0 +1,44 @@ +const { ReclaimServiceResponse } = require('../utils/reclaimServiceResponse') + +exports.processMonkeyTypeData = async (proof, providerName) => { + // Extract relevant data from the proof + const wpm = JSON.parse(proof[0].claimData.context).extractedParameters.wpm // word per minutes speed of the test + const acc = JSON.parse(proof[0].claimData.context).extractedParameters.acc // accuracy for the test + const timeStamp = JSON.parse(proof[0].claimData.context) + .extractedParameters.completionTime // completion time of the test + const username = JSON.parse(proof[0].claimData.context).extractedParameters + .username //username of the proof + + const date = new Date(Number(timeStamp)) + // Options for formatting timestamp + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZoneName: 'short', + } + + // Format the date and time + const completionTime = date.toLocaleString('en-US', options) + // The complete processedData from monkeyType + const ProcessedData = { + providerName, + wpm, + acc, + completionTime, + username, + } + const lastUpdateTimeStamp = JSON.parse(proof[0].claimData.timestampS) + + // Create a ReclaimServiceResponse object with the processed data + return new ReclaimServiceResponse( + providerName, + lastUpdateTimeStamp, + username, + ProcessedData, + proof[0] + ) +} diff --git a/src/services/reclaimService.js b/src/services/reclaimService.js index b33006f..c2c061a 100644 --- a/src/services/reclaimService.js +++ b/src/services/reclaimService.js @@ -3,12 +3,12 @@ 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 { processMonkeyTypeData } = require('./monkeyTypeService') exports.signWithProviderID = async (userId, providerId) => { const providerName = RECLAIM_PROVIDER_ID[providerId] const reclaimAppID = RECLAIM_APP_ID[providerName] const reclaimAppSecret = process.env[`${providerName}_SECRET`] - console.log( `Sending signature request to Reclaim for userId: ${userId} with providerName: ${providerName}` ) @@ -34,6 +34,7 @@ exports.signWithProviderID = async (userId, providerId) => { } const handleReclaimSession = async (userId, reclaimClient, providerName) => { + await reclaimClient.startSession({ onSuccessCallback: async proof => { console.log( @@ -49,6 +50,18 @@ const handleReclaimSession = async (userId, reclaimClient, providerName) => { case 'GITHUB_ACCOUNT_VERIFICATION': processedData = await processGitHubData(proof, providerName) break + case 'MONKEY_TYPE_SPEED_15S': + processedData = await processMonkeyTypeData(proof, providerName) + break + case 'MONKEY_TYPE_SPEED_30S': + processedData = await processMonkeyTypeData(proof, providerName) + break + case 'MONKEY_TYPE_SPEED_60S': + processedData = await processMonkeyTypeData(proof, providerName) + break + case 'MONKEY_TYPE_SPEED_120S': + processedData = await processMonkeyTypeData(proof, providerName) + break default: throw new Error(`No handler for provider: ${providerName}`) } diff --git a/src/utils/constants.js b/src/utils/constants.js index 1c58669..6a51368 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -1,9 +1,17 @@ exports.RECLAIM_PROVIDER_ID = { twitter: 'TWITTER_ANALYTICS_VIEWS', github: 'GITHUB_ACCOUNT_VERIFICATION', + '835bdf89-86ad-4272-8126-34200c32f1a8': 'MONKEY_TYPE_SPEED_15S', + 'c87918fb-6b25-4ac3-9843-7c595b9a2baf': 'MONKEY_TYPE_SPEED_30S', + 'c9e3c386-a110-4c9c-b124-cf2f9def116f': 'MONKEY_TYPE_SPEED_60S', + 'a350bcef-58f4-49ca-aecd-d15bd1d8e312': 'MONKEY_TYPE_SPEED_120S', } exports.RECLAIM_APP_ID = { TWITTER_ANALYTICS_VIEWS: 'your-twitter-app-id', GITHUB_ACCOUNT_VERIFICATION: 'your-github-app-id', + MONKEY_TYPE_SPEED_15S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', + MONKEY_TYPE_SPEED_30S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', + MONKEY_TYPE_SPEED_60S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', + MONKEY_TYPE_SPEED_120S: '0xe10Ee0749132eE2Ff8FFaB199E686ecAAD5607F0', }