Chapi Dev Talks
8.54K subscribers
950 photos
108 videos
12 files
596 links
My name is Chapi and I am a Developer.

I post my thoughts about tech here.

Message to our assistant to give U Feedback: @sophiservebot

Join https://t.me/chapidevtalks_group

Urgent? Contact Me: @chapimenge (Don't say hi or ask Meta Questions )
Download Telegram
I just wanna post something that takes me whole day to figure out.

async function auth(apiToken: string, telegramInitData: string) {
const initData = new URLSearchParams(telegramInitData);

// URLSearchParams.sort() might not be available in all environments
// so a manual sort implementation could be necessary. For simplicity, we'll skip sorting here.

const hash = initData.get("hash");
initData.delete("hash");

const dataToCheck = Array.from(initData).map(([key, value]) => `${key}=${value}`).join("\n");

// Key preparation: First, derive the secretKey from 'WebAppData' and apiToken
const encoder = new TextEncoder();
const secretKeyMaterial = await crypto.subtle.importKey(
"raw",
encoder.encode("WebAppData"),
{ name: "HMAC", hash: { name: "SHA-256" } },
false,
["sign"]
);
const secretKey = await crypto.subtle.sign(
"HMAC",
secretKeyMaterial,
encoder.encode(apiToken)
);

// Use the derived secretKey to HMAC the dataToCheck
const hmacKey = await crypto.subtle.importKey(
"raw",
secretKey,
{ name: "HMAC", hash: { name: "SHA-256" } },
false,
["sign"]
);

const signatureBuffer = await crypto.subtle.sign(
"HMAC",
hmacKey,
encoder.encode(dataToCheck)
);

const _hash = bufferToHex(signatureBuffer);

console.log(hash, _hash)

return hash === _hash;
}

function bufferToHex(buffer: ArrayBuffer): string {
const byteArray = new Uint8Array(buffer);
return byteArray.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
}


This is for validating user data in telegram mini app and incase anyone runs into the same problem use this.

https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app

Specially in cloudflare worker and vercel
🔥14
Forwarded from Beka (Beka)
Morning good people

I got a dm from lee rob (vercel).

Do any of you know how I can actaually send a valid address and receive the swag here? I've no idea if it's even possible or not. Any help would be highly apperciated 🙏😁
🔥5👏1
"Our IQ might be Room Temperature"
- Primeagen



I am thinking of Celsius 😂😂😂
😁6
Forwarded from Sickipedia
Dating in your 40's is like looking for a parking spot....
The good ones are all taken. The rest are either handicapped or too far away.

#wordplay
@Sickipedia
😁13
I wonder what if our country have a way to have a ministry that only governs tech people and only tech focused economy that only interact with foreign working environment like freelancing and remote jobs.

This makes the opportunity as a country and the means as a citizen much easier.

I mean because there might be a loot of money(specially dollars) moving in this imaginary ministry the correction is also gonna be to the roof since many people can't even resist from taking it to Thier home 😁😁😁


But am just living in imagination let me wake up wegen. 😂😂
😁6🤯3👍2
Question for our Senior Developers.

Is it worth working on Mail Server and Mail Client project as a side project? Reason is I just want to challenge myself to the edge. If you can comment please vote. BE REAL SENIOR DEVS ONLY 😁😁
Anonymous Poll
16%
Yes
9%
No
1%
I will Comment my idea
74%
Just wanna see the results 😂
👏1
Where is your language/tool?

Too bad for fraol rust is not included but at least Lua is there 😂😂
4😁2
Chapi Dev Talks
Where is your language/tool? Too bad for fraol rust is not included but at least Lua is there 😂😂
Now it is packed but I will replace one by one whenever I got a sticker from conference. [Soon there is one from AWS]
🔥5🥰1🆒1
Forwarded from Chapi M.
Setup completed.


Credit goes to Beka. Spend on this around >600 USD 😭


I have to put work on the stream now and also do some YouTube
🔥162😁2🤩2
Forwarded from Beka
forget mkbhd
Joe Rogan😭
TMRW IS DAY OFF. I AM GONNA CODE ALL NIGHT

👩‍💻
Please open Telegram to view this post
VIEW IN TELEGRAM
🎉85
Am gonna code all night with TechNerd join us.


Tmrw is labour day so it is day off most places 😁😁
🔥23😁4👍2🎉2
No premium
😁18🍾71
❗️ IMPORTANT CONCEPT

If you are working on a system that deals with money please watch this video. it is very useful.

https://www.youtube.com/watch?v=lxVzLAHnPOE

People usually tend to skip this idea.

I also want to tell you that if somebody sees me using int to represent money, they definitely laugh at me because i am not saving decimal points right ? right ? right?

But not, when people use int to represent money 1 doesn't mean 1 dollar or 1 ETB it usually means 1 cent or 0.1 depending on the currency decimal point.

Let me explain about currency decimal point. For example USD, EUR, ETB have 2 decimal point which means you can have 50.25 ETB or USD, but that is not the case for every currency.

For example in JPY(Japanese Yen) there dont have minor units it is either 50 JYP or 51 JYP there is no 50.25 JYP.

Or BHD(Bahraini dinar) there is 3 decimal places which means, to get 1 Bahraini dinnar you have 1000 cent(i know surprise), means .1 is not 10 cent we call it 100 fills 😄 so for that reason you have to write the three decimal digit, so pricing are writing like 49.999 BHD not 49.99 .

Anyways knowing this concepts really help you on saving yourself from a big mess.

I know it is Good Start for today 😜

Good day My people
Please open Telegram to view this post
VIEW IN TELEGRAM
12👍4😁3
Human > Hey Siri
Siri > Your mic is turned off

😂
😁22🤯2🕊1
NOT PROGRAMMING/TECH Related.

Ever heard of Did OJ did it ?

»»» [IF] I DID IT.
»»» MORE CONTEXT
👍3