-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #590 from Telegram-Mini-Apps/feature/3rd-party-ini…
…t-data-validation 3rd party init data validation utilities
- Loading branch information
Showing
30 changed files
with
576 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@telegram-apps/init-data-node": minor | ||
--- | ||
|
||
Add utilities related to 3-rd party validation. Git rid of Node.js `Buffer`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@telegram-apps/types": minor | ||
--- | ||
|
||
Define InitData.signature. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@telegram-apps/transformers": minor | ||
--- | ||
|
||
Add InitData.signature transformer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 0 additions & 85 deletions
85
packages/bridge/src/launch-params/parseLaunchParams.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/init-data-node/src/converters/arrayBufferToHex.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Converts array buffer to hex. | ||
* @param buffer - buffer to convert | ||
*/ | ||
export function arrayBufferToHex(buffer: ArrayBuffer): string { | ||
return new Uint8Array(buffer).reduce((acc, byte) => { | ||
// Convert byte to hex and pad with zero if needed (e.g., "0a" instead of "a") | ||
return acc + byte.toString(16).padStart(2, '0'); | ||
}, ''); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/init-data-node/src/converters/hexToArrayBuffer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Converts a hex string to ArrayBuffer. | ||
* @param hexString - value to convert. | ||
*/ | ||
export function hexToArrayBuffer(hexString: string): ArrayBuffer { | ||
if (hexString.length % 2 !== 0) { | ||
throw new Error('Hex string must have an even number of characters'); | ||
} | ||
|
||
const buffer = new ArrayBuffer(hexString.length / 2); | ||
const uint8Array = new Uint8Array(buffer); | ||
for (let i = 0; i < hexString.length; i += 2) { | ||
uint8Array[i / 2] = parseInt(hexString.substring(i, i + 2), 16); | ||
} | ||
|
||
return buffer; | ||
} |
Oops, something went wrong.