@session.js/blinded-session-id 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/package.json +41 -35
package/README.md
CHANGED
|
@@ -27,13 +27,13 @@ await blindSessionId({
|
|
|
27
27
|
- generateKAs — returns legacy and modern KAs as Uint8Array
|
|
28
28
|
- convertToX25519Key, convertToEd25519Key — self explanatory
|
|
29
29
|
|
|
30
|
-
##
|
|
30
|
+
## Acknowledgements
|
|
31
31
|
|
|
32
32
|
Credit to li0ard, this code was mostly taken from [https://github.com/theinfinityway/session_id/](https://github.com/theinfinityway/session_id/)
|
|
33
33
|
|
|
34
|
-
## Made for
|
|
34
|
+
## Made for Session.js
|
|
35
35
|
|
|
36
|
-
Use Session messenger programmatically with [Session.js](https://
|
|
36
|
+
Use Session messenger programmatically with [Session.js](https://git.hloth.dev/session.js/client): Session bots, custom Session clients, and more.
|
|
37
37
|
|
|
38
38
|
## Donate
|
|
39
39
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const convertToX25519Key: (key: string) => string;
|
|
|
4
4
|
export declare function crypto_core_ed25519_scalar_reduce(scalar: Uint8Array): Uint8Array;
|
|
5
5
|
export declare const generateKA: (sessionId: string, serverPk: string) => Uint8Array;
|
|
6
6
|
export declare const generateBlindedKeys: (sessionId: string, serverPk: string) => Uint8Array[];
|
|
7
|
-
export declare const blindSessionId: ({ sessionId, serverPk }: {
|
|
7
|
+
export declare const blindSessionId: ({ sessionId, serverPk, }: {
|
|
8
8
|
sessionId: string;
|
|
9
9
|
serverPk: string;
|
|
10
10
|
}) => string;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Huge thanks to li0ard for this code
|
|
2
|
-
// CREDIT: https://github.com/theinfinityway/session_id/
|
|
2
|
+
// CREDIT: https://github.com/theinfinityway/session_id/ [MIT]
|
|
3
3
|
/* eslint-disable prefer-const */
|
|
4
4
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
5
5
|
import { bytesToHex, hexToBytes } from "@noble/curves/utils.js";
|
|
@@ -573,17 +573,17 @@ export const generateKA = (sessionId, serverPk) => {
|
|
|
573
573
|
export const generateBlindedKeys = (sessionId, serverPk) => {
|
|
574
574
|
const kA = generateKA(sessionId, serverPk);
|
|
575
575
|
const key1 = kA;
|
|
576
|
-
const modifiedByte = kA[31] &
|
|
576
|
+
const modifiedByte = kA[31] & 0x7f;
|
|
577
577
|
const key2 = new Uint8Array(32);
|
|
578
578
|
key2.set(kA.slice(0, 31), 0);
|
|
579
579
|
key2[31] = modifiedByte;
|
|
580
580
|
return [key1, key2];
|
|
581
581
|
};
|
|
582
|
-
export const blindSessionId = ({ sessionId, serverPk }) => {
|
|
582
|
+
export const blindSessionId = ({ sessionId, serverPk, }) => {
|
|
583
583
|
const [key1, key2] = generateBlindedKeys(sessionId, serverPk);
|
|
584
584
|
const isKey2 = key1[31] & 0x80;
|
|
585
585
|
if (isKey2) {
|
|
586
|
-
return
|
|
586
|
+
return "15" + bytesToHex(key2);
|
|
587
587
|
}
|
|
588
|
-
return
|
|
588
|
+
return "15" + bytesToHex(key1);
|
|
589
589
|
};
|
package/package.json
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
2
|
+
"name": "@session.js/blinded-session-id",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Utility JavaScript library with methods to work with Session's blinded Session ID",
|
|
5
|
+
"homepage": "https://git.hloth.dev/session.js/blinded-session-id#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://git.hloth.dev/session.js/blinded-session-id/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://git.hloth.dev/session.js/blinded-session-id.git"
|
|
12
|
+
},
|
|
13
|
+
"funding": "https://hloth.dev/donate",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Viktor Shchelochkov <hi@hloth.dev> (https://hloth.dev)",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist/index.js",
|
|
21
|
+
"dist/index.d.ts",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "rm -rf dist && tsc --project tsconfig.build.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@noble/curves": "^2.0.1",
|
|
30
|
+
"@noble/hashes": "^2.0.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@eslint/compat": "^2.0.1",
|
|
34
|
+
"@eslint/js": "^9.39.2",
|
|
35
|
+
"@types/bun": "latest",
|
|
36
|
+
"eslint-config-prettier": "^10.1.8",
|
|
37
|
+
"prettier": "^3.8.0",
|
|
38
|
+
"typescript-eslint": "^8.53.1"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"typescript": "^5.0.0"
|
|
42
|
+
}
|
|
37
43
|
}
|