@pmate/chat-sdk 0.2.2 → 0.2.3
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/lib/runtime/thread.js +3 -6
- package/package.json +2 -1
package/lib/runtime/thread.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { blake3 } from "@noble/hashes/blake3.js";
|
|
2
|
+
import { bytesToHex } from "@noble/hashes/utils.js";
|
|
1
3
|
export function pairId(appId, userA, userB) {
|
|
2
4
|
const [left, right] = userA <= userB ? [userA, userB] : [userB, userA];
|
|
3
5
|
return stableHash(`social:v1:pair:${appId}:${left}:${right}`);
|
|
@@ -9,10 +11,5 @@ export function groupThreadId(appId, groupId) {
|
|
|
9
11
|
return stableHash(`social:v1:group:${appId}:${groupId}`);
|
|
10
12
|
}
|
|
11
13
|
function stableHash(value) {
|
|
12
|
-
|
|
13
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
14
|
-
hash ^= value.charCodeAt(index);
|
|
15
|
-
hash = Math.imul(hash, 0x01000193);
|
|
16
|
-
}
|
|
17
|
-
return `h${(hash >>> 0).toString(16).padStart(8, "0")}`;
|
|
14
|
+
return bytesToHex(blake3(new TextEncoder().encode(value)));
|
|
18
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmate/chat-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Cross-platform PMate chat input components, voice input primitives, and ASR helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"build-storybook": "storybook build --output-dir dist"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"@noble/hashes": "^2.4.0",
|
|
42
43
|
"@emoji-mart/data": "^1.2.1",
|
|
43
44
|
"@emoji-mart/react": "^1.1.1",
|
|
44
45
|
"@msgpack/msgpack": "^3.1.2",
|