solana-messenger-sdk 0.7.0 → 0.7.1

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.
Files changed (2) hide show
  1. package/README.md +45 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -92,12 +92,25 @@ await messenger.send(recipient, "hello from a custodial wallet");
92
92
 
93
93
  ### Methods
94
94
 
95
+ #### Messaging
95
96
  | Method | Description |
96
97
  |--------|-------------|
97
98
  | `init()` | Generate encryption key, register on-chain. Call once. Returns `{ encryptionAddress, status }` where status is `"registered"`, `"already_registered"`, or `"updated"`. |
98
- | `send(recipient, message, encryptionPubkey?)` | Send encrypted message. Recipient must be registered. Auto-chunks if needed. Fees auto-deducted. |
99
- | `read({ since?, limit? })` | Read messages sent to you. `since` is a unix timestamp (seconds). Decrypts automatically. |
100
- | `listen(callback)` | Real-time WebSocket listener. Returns unsubscribe function. |
99
+ | `send(recipient, message, encryptionPubkey?)` | Send encrypted DM. Recipient must be registered. Auto-chunks if needed. Fees auto-deducted. |
100
+ | `read({ since?, limit? })` | Read DMs sent to you. `since` is a unix timestamp (seconds). Decrypts automatically. |
101
+ | `listen(callback)` | Real-time WebSocket listener for DMs. Returns unsubscribe function. |
102
+
103
+ #### Groups
104
+ | Method | Description |
105
+ |--------|-------------|
106
+ | `createGroup(members)` | Create a group chat (max 10 members). You're auto-added. Returns `{ groupId, groupPda, signature }`. |
107
+ | `sendGroup(groupPda, message)` | Send E2E encrypted message to a group. Uses symmetric key + per-member key wraps. |
108
+ | `updateGroup(groupPda, members)` | Update group members (creator only). Creator must stay in list. |
109
+ | `closeGroup(groupPda)` | Close group and reclaim rent (creator only). |
110
+
111
+ #### Registry
112
+ | Method | Description |
113
+ |--------|-------------|
101
114
  | `register(encryptionPubkey)` | Register encryption key (called by init). |
102
115
  | `updateEncryptionKey(newPubkey)` | Rotate encryption key. |
103
116
  | `setMinFee(lamports)` | Set minimum fee to receive messages. Senders pay this to you. |
@@ -106,6 +119,26 @@ await messenger.send(recipient, "hello from a custodial wallet");
106
119
  | `getAddress()` | Get your wallet address. |
107
120
  | `getEncryptionPublicKey()` | Get your encryption public key (after init). |
108
121
 
122
+ ### Group Messaging Example
123
+
124
+ ```typescript
125
+ // Create a group
126
+ const { groupPda } = await messenger.createGroup([
127
+ myAddress, "Member1Address...", "Member2Address...",
128
+ ]);
129
+
130
+ // Send to group — encrypted with symmetric key, wrapped per member
131
+ await messenger.sendGroup(groupPda, "Hello team!");
132
+
133
+ // Update members (creator only)
134
+ await messenger.updateGroup(groupPda, [myAddress, "Member1Address...", "NewMember..."]);
135
+
136
+ // Close group (creator only)
137
+ await messenger.closeGroup(groupPda);
138
+ ```
139
+
140
+ Group messages use a **symmetric key wrap** model: the message is encrypted once with a random symmetric key (NaCl secretbox), then the symmetric key is individually wrapped (NaCl box) for each recipient. This keeps the ciphertext size constant regardless of group size.
141
+
109
142
  ### Low-Level Exports
110
143
 
111
144
  For custom transaction composition:
@@ -116,7 +149,13 @@ import {
116
149
  buildRegisterInstruction,
117
150
  buildUpdateEncryptionKeyInstruction,
118
151
  buildDeregisterInstruction,
152
+ buildSetMinFeeInstruction,
153
+ buildCreateGroupInstruction,
154
+ buildUpdateGroupInstruction,
155
+ buildSendGroupMessageInstruction,
156
+ buildCloseGroupInstruction,
119
157
  deriveRegistryPda,
158
+ deriveGroupPda,
120
159
  lookupEncryptionKey,
121
160
  encrypt,
122
161
  decrypt,
@@ -128,11 +167,13 @@ import {
128
167
 
129
168
  ## How It Works
130
169
 
131
- - **Encryption:** NaCl box (XSalsa20-Poly1305) via Diffie-Hellman shared secret
170
+ - **Encryption (DMs):** NaCl box (XSalsa20-Poly1305) via Diffie-Hellman shared secret
171
+ - **Encryption (Groups):** NaCl secretbox (symmetric) + per-recipient key wraps via NaCl box
132
172
  - **Key conversion:** ed25519 → x25519 via ed2curve
133
173
  - **Messages:** Emitted as program events — no on-chain storage
134
174
  - **Chunking:** Messages > 661 bytes are automatically split and reassembled
135
175
  - **Registry:** On-chain PDA at `["messenger", wallet]` maps identity → encryption pubkey
176
+ - **Groups:** On-chain PDA at `["group", group_id]` stores membership (max 10)
136
177
 
137
178
  ## Cost
138
179
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solana-messenger-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "TypeScript SDK for Solana Messenger — encrypted agent-to-agent messaging",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",