Skip to content

Instantly share code, notes, and snippets.

@aonrobot
Created May 10, 2022 09:48
Show Gist options
  • Save aonrobot/7d7ca6fb19ed598f7a2881ec35d75975 to your computer and use it in GitHub Desktop.
Save aonrobot/7d7ca6fb19ed598f7a2881ec35d75975 to your computer and use it in GitHub Desktop.
const request = require('request');
const crypto = require("crypto");
const NEW_POKER_AGENT_URL = 'https://beta-agent.iampoker.com';
const NEW_POKER_AGENT_KEY = 'YOUR AGENT KEY [Secret Key]'; // ex. xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
const NEW_POKER_AGENT_NAME = 'YOUR AGENT NAME' // ex. agentpentest
const PLAYER_USERNAME = 'YOUR PLAYER USERNAME' // ex. showpentestrekop1
function encryptData(text, secretKey) {
const byte = Buffer.from(JSON.stringify(text))
const sha256 = crypto.createHmac('sha256', secretKey)
.update(byte)
.digest('hex')
const signature = Buffer.from(sha256).toString('base64')
return signature
}
const body = {
memberUsername: PLAYER_USERNAME.toLowerCase(),
agentUsername: NEW_POKER_AGENT_NAME,
active_game: {
"allinorfold": [
"1/2",
"2/4",
"5/10",
]
}
};
let headers = {
'Content-Type': 'application/json',
'x-poker-signature': encryptData(body, NEW_POKER_AGENT_KEY)
};
let options = {
url: `${NEW_POKER_AGENT_URL}/api/v1/game/getURL`,
method: "POST",
headers: headers,
json: body,
pool: { maxSockets: 2500 }
};
request(options, (error, response, body) => {
if (error) {
console.error('Something error.')
} else {
if(response.statusCode === 200) {
console.error('Launch game URL : ', body.data.loginUrl)
} else {
console.error('Something error.')
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment