@xdevplatform/chat-xdk 0.1.0 → 0.2.0
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/LICENSE +21 -0
- package/README.md +27 -23
- package/index.d.ts +365 -77
- package/index.js +178 -47
- package/package.json +6 -2
- package/pkg/chat_xdk_wasm.d.ts +124 -44
- package/pkg/chat_xdk_wasm.js +224 -223
- package/pkg/chat_xdk_wasm_bg.wasm +0 -0
- package/pkg/chat_xdk_wasm_bg.wasm.d.ts +15 -9
- package/pkg/package.json +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 X Corp.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -13,44 +13,34 @@ The Rust WASM layer is a pure crypto engine; Juicebox key-storage lifecycle is o
|
|
|
13
13
|
## Prerequisites
|
|
14
14
|
|
|
15
15
|
- **Node.js 18+**
|
|
16
|
-
- [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)
|
|
17
16
|
|
|
18
|
-
##
|
|
19
|
-
|
|
20
|
-
### 1. Build chat-xdk WASM
|
|
17
|
+
## Install
|
|
21
18
|
|
|
22
19
|
```bash
|
|
23
|
-
|
|
24
|
-
wasm-pack build --target nodejs --out-dir pkg # or --target web for browser bundlers
|
|
20
|
+
npm install @xdevplatform/chat-xdk
|
|
25
21
|
```
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
The compiled WASM engine ships inside the package (`pkg/`) — no build step.
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
Clone [juicebox-sdk](https://github.com/juicebox-systems/juicebox-sdk) as a sibling of `chat-xdk`:
|
|
25
|
+
Juicebox PIN-based key storage is an optional peer dependency:
|
|
31
26
|
|
|
32
27
|
```bash
|
|
33
|
-
|
|
34
|
-
cd ../juicebox-sdk/rust/sdk/bridge/wasm
|
|
35
|
-
wasm-pack build --target nodejs --out-dir pkg --out-name juicebox-sdk
|
|
28
|
+
npm install juicebox-sdk # only needed for setup()/unlock()/changePin()
|
|
36
29
|
```
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
that `index.js` imports (`juicebox-sdk.js`, `juicebox-sdk_bg.js`, `juicebox-sdk_bg.wasm`).
|
|
40
|
-
Use the same `--target` for both builds (`nodejs` for Node, `web` or `bundler` for browsers).
|
|
31
|
+
## Developing in this repo
|
|
41
32
|
|
|
42
|
-
|
|
33
|
+
Working from a chat-xdk checkout (instead of the npm package) requires staging
|
|
34
|
+
the WASM build that `index.js` resolves at `./pkg/`:
|
|
43
35
|
|
|
44
36
|
```bash
|
|
45
|
-
|
|
46
|
-
npm install
|
|
47
|
-
npm install ../../juicebox-sdk/rust/sdk/bridge/wasm/pkg # links juicebox-sdk
|
|
37
|
+
make wasm # from the repo root; builds --target web and stages js/pkg/
|
|
48
38
|
```
|
|
49
39
|
|
|
50
40
|
## Quick Start
|
|
51
41
|
|
|
52
42
|
```typescript
|
|
53
|
-
import { createChat } from "chat-xdk";
|
|
43
|
+
import { createChat } from "@xdevplatform/chat-xdk";
|
|
54
44
|
|
|
55
45
|
const chat = await createChat({
|
|
56
46
|
juiceboxConfig: configJson,
|
|
@@ -58,10 +48,24 @@ const chat = await createChat({
|
|
|
58
48
|
});
|
|
59
49
|
await chat.unlock("2580");
|
|
60
50
|
|
|
61
|
-
// Initial load — batch decrypt with automatic key extraction
|
|
51
|
+
// Initial load — batch decrypt with automatic key extraction.
|
|
52
|
+
// Each signing-key entry carries all five fields from the X API
|
|
53
|
+
// public keys response.
|
|
62
54
|
const result = chat.decryptEvents(rawEvents, [
|
|
63
|
-
{
|
|
64
|
-
|
|
55
|
+
{
|
|
56
|
+
userId: "111",
|
|
57
|
+
publicKeyVersion: "v1",
|
|
58
|
+
publicKey: "BASE64...",
|
|
59
|
+
identityPublicKey: "BASE64...",
|
|
60
|
+
identityPublicKeySignature: "BASE64...",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
userId: "222",
|
|
64
|
+
publicKeyVersion: "v1",
|
|
65
|
+
publicKey: "BASE64...",
|
|
66
|
+
identityPublicKey: "BASE64...",
|
|
67
|
+
identityPublicKeySignature: "BASE64...",
|
|
68
|
+
},
|
|
65
69
|
]);
|
|
66
70
|
|
|
67
71
|
for (const dm of result.messages) {
|