solana-messenger-sdk 0.8.0 → 1.1.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/README.md CHANGED
@@ -3,9 +3,10 @@
3
3
  [![npm](https://img.shields.io/npm/v/solana-messenger-sdk)](https://www.npmjs.com/package/solana-messenger-sdk)
4
4
  [![license](https://img.shields.io/npm/l/solana-messenger-sdk)](https://github.com/sabersally/solana-messenger/blob/main/LICENSE)
5
5
 
6
- TypeScript SDK for **solana-messenger** — encrypted agent-to-agent messaging on Solana.
6
+ TypeScript SDK for **solana-messenger** — encrypted on-chain messaging with servers, channels, and DMs.
7
7
 
8
- **Program:** `msg1jhfewu1hGDnQKGhXDmqas6JZTq7Lg7PbSX5jY9y` ([mainnet](https://solscan.io/account/msg1jhfewu1hGDnQKGhXDmqas6JZTq7Lg7PbSX5jY9y))
8
+ **Program (mainnet):** `msg1jhfewu1hGDnQKGhXDmqas6JZTq7Lg7PbSX5jY9y`
9
+ **Program (devnet):** `E6p87FCXNZFii8GJs5NY5xUmH8wKRPvGXn3Z2VhNqSv`
9
10
 
10
11
  ## Install
11
12
 
@@ -15,195 +16,108 @@ npm install solana-messenger-sdk
15
16
 
16
17
  ## Quick Start
17
18
 
18
- ### Self-Custody (you have a keypair)
19
-
20
19
  ```typescript
21
20
  import { SolanaMessenger } from "solana-messenger-sdk";
22
- import { readFileSync } from "fs";
23
-
24
- const keypair = new Uint8Array(JSON.parse(readFileSync("~/.config/solana/id.json", "utf-8")));
25
21
 
26
22
  const messenger = new SolanaMessenger({
27
23
  apiKey: "YOUR_HELIUS_API_KEY",
28
- network: "mainnet", // or "devnet"
29
- keypair,
24
+ keypair: keypairBytes, // 64-byte ed25519
30
25
  });
31
26
 
32
- // Initialize: generates local encryption key, registers on-chain
33
27
  await messenger.init();
34
28
 
35
- // Send an encrypted message
36
- await messenger.send("RecipientWalletAddress111111111111111111111", "hey, you up?");
29
+ // DM
30
+ await messenger.send(recipient, "hey!");
37
31
 
38
- // Read messages sent to you
39
- const messages = await messenger.read({ limit: 10 });
40
- for (const msg of messages) {
41
- console.log(`${msg.sender}: ${msg.text}`);
42
- }
43
-
44
- // Listen for new messages in real-time (~400ms)
45
- const unsub = await messenger.listen((msg) => {
46
- console.log(`New message from ${msg.sender}: ${msg.text}`);
47
- });
32
+ // Server + channel
33
+ const { serverId } = await messenger.createServer("My Server");
34
+ await messenger.inviteToServer(serverId, member, [serverKey]);
48
35
  ```
49
36
 
50
- ### External Signer (Privy, Turnkey, etc.)
51
-
52
- For agents using custodial wallets where you don't have the raw keypair:
37
+ ### External Signer (Privy, Turnkey)
53
38
 
54
39
  ```typescript
55
40
  const messenger = new SolanaMessenger({
56
41
  apiKey: "YOUR_HELIUS_API_KEY",
57
- network: "mainnet",
58
- walletAddress: "YourCustodialWalletAddress1111111111111111",
59
- signer: async (unsignedTx, recentBlockhash, feePayer) => {
60
- return await privySignTransaction(unsignedTx);
61
- },
42
+ walletAddress: "YourCustodialWallet",
43
+ signer: async (unsignedTx) => await privySign(unsignedTx),
62
44
  });
63
-
64
- await messenger.init();
65
- await messenger.send(recipient, "hello from a custodial wallet");
66
45
  ```
67
46
 
68
- **Why two modes?** Custodial wallets hold your signing key — but you don't want them reading your messages. `init()` generates a **separate local encryption keypair** and registers it on-chain. Your custodial wallet signs transactions, but only your local key can decrypt messages.
69
-
70
47
  ## API
71
48
 
72
- ### Constructor
73
-
74
- **Self-custody:**
75
- | Field | Type | Required | Description |
76
- |-------|------|----------|-------------|
77
- | `apiKey` | string | ✅ | Helius API key |
78
- | `network` | "mainnet" \| "devnet" | | Network (default: "mainnet") |
79
- | `keypair` | Uint8Array | ✅ | 64-byte ed25519 keypair |
80
- | `programId` | string | | Custom program ID (default: mainnet) |
81
- | `keysDir` | string | | Encryption key storage path |
82
-
83
- **External signer:**
84
- | Field | Type | Required | Description |
85
- |-------|------|----------|-------------|
86
- | `apiKey` | string | ✅ | Helius API key |
87
- | `network` | "mainnet" \| "devnet" | | Network (default: "mainnet") |
88
- | `walletAddress` | string | ✅ | Your wallet's public key |
89
- | `signer` | ExternalSignerFn | ✅ | Signs serialized transactions |
90
- | `programId` | string | | Custom program ID |
91
- | `keysDir` | string | | Encryption key storage path |
92
-
93
- ### Methods
94
-
95
- #### Messaging
96
- | Method | Description |
97
- |--------|-------------|
98
- | `init()` | Generate encryption key, register on-chain. Call once. Returns `{ encryptionAddress, status }` where status is `"registered"`, `"already_registered"`, or `"updated"`. |
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. |
49
+ ### Direct Messages
102
50
 
103
- #### Groups
104
51
  | Method | Description |
105
52
  |--------|-------------|
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). |
53
+ | `send(recipient, message)` | Send encrypted DM. Auto-chunks if needed. |
54
+ | `read({ since?, limit? })` | Read DMs sent to you. |
55
+ | `listen(callback)` | Real-time WebSocket listener. Returns unsubscribe fn. |
56
+
57
+ ### Servers
110
58
 
111
- #### Registry
112
59
  | Method | Description |
113
60
  |--------|-------------|
114
- | `register(encryptionPubkey)` | Register encryption key (called by init). |
115
- | `updateEncryptionKey(newPubkey)` | Rotate encryption key. |
116
- | `setMinFee(lamports)` | Set minimum fee to receive messages. Senders pay this to you. |
117
- | `deregister()` | Remove registry entry, reclaim rent. |
118
- | `lookupEncryptionKey(address)` | Look up anyone's encryption key. |
119
- | `getAddress()` | Get your wallet address. |
120
- | `getEncryptionPublicKey()` | Get your encryption public key (after init). |
61
+ | `createServer(name)` | Create server. You become owner. |
62
+ | `inviteToServer(serverId, member, serverKeys)` | Invite member (admin/owner). Wraps all key versions. |
63
+ | `leaveServer(serverId, remainingMembers)` | Leave + rotate key for remaining members. |
121
64
 
122
- ### Group Messaging Example
65
+ ### Channels
123
66
 
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..."]);
67
+ | Method | Description |
68
+ |--------|-------------|
69
+ | `createChannel({ serverId?, channelType?, members })` | Create channel (standalone or server). |
70
+ | `sendChannelMessage({ channelPda, message, channelKey, keyVersion, senderServerMemberPda? })` | Send to channel. `senderServerMemberPda` required for public channels. |
71
+ | `addChannelMembers(channelPda, channelId, members, allKeyVersions)` | Add members with all historical keys. |
72
+ | `removeChannelMembers(channelId, version, removeList, remaining)` | Remove + rotate key. Returns new channel PDA. |
73
+ | `closeChannel(channelPda, channelId, members)` | Close channel, reclaim rent. |
135
74
 
136
- // Close group (creator only)
137
- await messenger.closeGroup(groupPda);
138
- ```
75
+ ### Identity
139
76
 
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.
77
+ | Method | Description |
78
+ |--------|-------------|
79
+ | `init()` | Register encryption key on-chain. |
80
+ | `setMinFee(lamports)` | Set spam fee for DMs. |
81
+ | `lookupEncryptionKey(address)` | Look up anyone's encryption key. |
82
+ | `getAddress()` | Get wallet address. |
141
83
 
142
- ### Low-Level Exports
84
+ ### Low-Level Builders
143
85
 
144
- For custom transaction composition:
86
+ All instruction builders exported for custom tx composition:
145
87
 
146
88
  ```typescript
147
89
  import {
148
90
  buildSendMessageInstruction,
149
- buildRegisterInstruction,
150
- buildUpdateEncryptionKeyInstruction,
151
- buildDeregisterInstruction,
152
- buildSetMinFeeInstruction,
153
- buildCreateGroupInstruction,
154
- buildUpdateGroupInstruction,
155
- buildSendGroupMessageInstruction,
156
- buildCloseGroupInstruction,
91
+ buildCreateServerInstruction,
92
+ buildInviteToServerInstruction,
93
+ buildLeaveServerInstruction,
94
+ buildRemoveServerMemberInstruction,
95
+ buildCreateChannelInstruction,
96
+ buildSendChannelMessageInstruction,
97
+ buildAddChannelMembersInstruction,
98
+ buildRemoveChannelMembersInstruction,
99
+ // PDA derivation
100
+ deriveServerPda,
101
+ deriveServerMemberPda,
102
+ deriveChannelPda,
103
+ deriveChannelMemberPda,
157
104
  deriveRegistryPda,
158
- deriveGroupPda,
159
- lookupEncryptionKey,
160
- encrypt,
161
- decrypt,
162
- encodeMessage,
163
- decodeMessage,
164
- parseMessageSentEvents,
105
+ deriveConfigPda,
165
106
  } from "solana-messenger-sdk";
166
107
  ```
167
108
 
168
- ## How It Works
169
-
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
172
- - **Key conversion:** ed25519 → x25519 via ed2curve
173
- - **Messages:** Emitted as program events — no on-chain storage
174
- - **Chunking:** Messages > 661 bytes are automatically split and reassembled
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)
177
-
178
- ## Cost
179
-
180
- | Action | Cost |
181
- |--------|------|
182
- | Send message | ~5000 lamports tx fee + protocol fee (default 0) + recipient min_fee (default 0) |
183
- | Register encryption key | ~0.001 SOL (rent, reclaimable) |
184
- | Set min_fee | tx fee only |
185
- | Lookup encryption key | Free (read-only) |
186
- | Deregister | Reclaims rent |
187
-
188
- ## Funding Your Agent
189
-
190
- Your agent needs SOL to send messages. Get your agent's address and transfer SOL from any wallet:
191
-
192
- ```typescript
193
- const address = await messenger.getAddress();
194
- console.log(`Send SOL to: ${address}`);
195
- ```
196
-
197
- ## Dependencies
198
-
199
- - `@solana/kit` — Solana web3 v2
200
- - `tweetnacl` — NaCl box encryption
201
- - `ed2curve` — ed25519 → x25519 conversion
109
+ ## Protocol
202
110
 
203
- ## Links
111
+ Full spec: [SPEC.md](https://github.com/sabersally/solana-messenger/blob/main/SPEC.md)
204
112
 
205
- - [GitHub](https://github.com/sabersally/solana-messenger)
206
- - [Program on Solscan](https://solscan.io/account/msg1jhfewu1hGDnQKGhXDmqas6JZTq7Lg7PbSX5jY9y)
113
+ | Feature | Details |
114
+ |---------|---------|
115
+ | Encryption | NaCl box (DMs), NaCl secretbox (channels) |
116
+ | Member cap | 256 per channel/server |
117
+ | Key rotation | On removal + voluntary leave |
118
+ | History | New members get all historical keys |
119
+ | Discovery | Zero backend — GPA + getSignaturesForAddress |
120
+ | Payer separation | Relay/gasless support |
207
121
 
208
122
  ## License
209
123
 
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- export { buildSendMessageInstruction, buildRegisterInstruction, buildUpdateEncryptionKeyInstruction, buildDeregisterInstruction, buildSetMinFeeInstruction, buildInitializeConfigInstruction, buildUpdateConfigInstruction, buildMigrateRegistryInstruction, buildCreateGroupInstruction, buildUpdateGroupInstruction, buildSendGroupMessageInstruction, buildCloseGroupInstruction, } from "./instructions";
2
- export { deriveRegistryPda, deriveConfigPda, deriveGroupPda } from "./pda";
1
+ export { buildInitializeConfigInstruction, buildUpdateConfigInstruction, buildRegisterInstruction, buildUpdateEncryptionKeyInstruction, buildDeregisterInstruction, buildSetMinFeeInstruction, buildSendMessageInstruction, buildCreateServerInstruction, buildInviteToServerInstruction, buildRemoveServerMemberInstruction, buildLeaveServerInstruction, buildUpdateServerInstruction, buildCloseServerInstruction, buildCreateChannelInstruction, buildSendChannelMessageInstruction, buildAddChannelMembersInstruction, buildRemoveChannelMembersInstruction, buildCloseChannelInstruction, } from "./instructions";
2
+ export { deriveConfigPda, deriveRegistryPda, deriveServerPda, deriveServerMemberPda, deriveChannelPda, deriveChannelMemberPda, } from "./pda";
3
3
  export { lookupEncryptionKey } from "./registry";
4
4
  export { loadOrGenerateEncryptionKeypair } from "./keys";
5
5
  export { convertEd25519ToX25519, encrypt, decrypt, decryptRaw, encodeMessage, decodeMessage, } from "./crypto";
6
6
  export { parseMessageSentEvents } from "./events";
7
- export type { EncryptedPayload, DecodedMessage, MessageSentEvent, Message, } from "./types";
7
+ export type { EncryptedPayload, DecodedMessage, MessageSentEvent, ChannelMessageSentEvent, Message, ChannelMessage, KeyWrap, ServerInfo, ChannelInfo, } from "./types";
8
+ export { ChannelType, Role } from "./types";
8
9
  export { SolanaMessenger } from "./messenger";
9
10
  export type { SolanaMessengerConfig, SelfCustodyConfig, ExternalSignerConfig, ExternalSignerFn, } from "./messenger";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,mCAAmC,EACnC,0BAA0B,EAC1B,yBAAyB,EACzB,gCAAgC,EAChC,4BAA4B,EAC5B,+BAA+B,EAC/B,2BAA2B,EAC3B,2BAA2B,EAC3B,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,+BAA+B,EAAE,MAAM,QAAQ,CAAC;AAGzD,OAAO,EACL,sBAAsB,EACtB,OAAO,EACP,OAAO,EACP,UAAU,EACV,aAAa,EACb,aAAa,GACd,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGl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;AAC9C,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,25 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolanaMessenger = exports.parseMessageSentEvents = exports.decodeMessage = exports.encodeMessage = exports.decryptRaw = exports.decrypt = exports.encrypt = exports.convertEd25519ToX25519 = exports.loadOrGenerateEncryptionKeypair = exports.lookupEncryptionKey = exports.deriveGroupPda = exports.deriveConfigPda = exports.deriveRegistryPda = exports.buildCloseGroupInstruction = exports.buildSendGroupMessageInstruction = exports.buildUpdateGroupInstruction = exports.buildCreateGroupInstruction = exports.buildMigrateRegistryInstruction = exports.buildUpdateConfigInstruction = exports.buildInitializeConfigInstruction = exports.buildSetMinFeeInstruction = exports.buildDeregisterInstruction = exports.buildUpdateEncryptionKeyInstruction = exports.buildRegisterInstruction = exports.buildSendMessageInstruction = void 0;
4
- // Instruction builders (core — use these for custom signing)
3
+ exports.SolanaMessenger = exports.Role = exports.ChannelType = exports.parseMessageSentEvents = exports.decodeMessage = exports.encodeMessage = exports.decryptRaw = exports.decrypt = exports.encrypt = exports.convertEd25519ToX25519 = exports.loadOrGenerateEncryptionKeypair = exports.lookupEncryptionKey = exports.deriveChannelMemberPda = exports.deriveChannelPda = exports.deriveServerMemberPda = exports.deriveServerPda = exports.deriveRegistryPda = exports.deriveConfigPda = exports.buildCloseChannelInstruction = exports.buildRemoveChannelMembersInstruction = exports.buildAddChannelMembersInstruction = exports.buildSendChannelMessageInstruction = exports.buildCreateChannelInstruction = exports.buildCloseServerInstruction = exports.buildUpdateServerInstruction = exports.buildLeaveServerInstruction = exports.buildRemoveServerMemberInstruction = exports.buildInviteToServerInstruction = exports.buildCreateServerInstruction = exports.buildSendMessageInstruction = exports.buildSetMinFeeInstruction = exports.buildDeregisterInstruction = exports.buildUpdateEncryptionKeyInstruction = exports.buildRegisterInstruction = exports.buildUpdateConfigInstruction = exports.buildInitializeConfigInstruction = void 0;
4
+ // Instruction builders
5
5
  var instructions_1 = require("./instructions");
6
- Object.defineProperty(exports, "buildSendMessageInstruction", { enumerable: true, get: function () { return instructions_1.buildSendMessageInstruction; } });
6
+ // Platform
7
+ Object.defineProperty(exports, "buildInitializeConfigInstruction", { enumerable: true, get: function () { return instructions_1.buildInitializeConfigInstruction; } });
8
+ Object.defineProperty(exports, "buildUpdateConfigInstruction", { enumerable: true, get: function () { return instructions_1.buildUpdateConfigInstruction; } });
9
+ // Identity
7
10
  Object.defineProperty(exports, "buildRegisterInstruction", { enumerable: true, get: function () { return instructions_1.buildRegisterInstruction; } });
8
11
  Object.defineProperty(exports, "buildUpdateEncryptionKeyInstruction", { enumerable: true, get: function () { return instructions_1.buildUpdateEncryptionKeyInstruction; } });
9
12
  Object.defineProperty(exports, "buildDeregisterInstruction", { enumerable: true, get: function () { return instructions_1.buildDeregisterInstruction; } });
10
13
  Object.defineProperty(exports, "buildSetMinFeeInstruction", { enumerable: true, get: function () { return instructions_1.buildSetMinFeeInstruction; } });
11
- Object.defineProperty(exports, "buildInitializeConfigInstruction", { enumerable: true, get: function () { return instructions_1.buildInitializeConfigInstruction; } });
12
- Object.defineProperty(exports, "buildUpdateConfigInstruction", { enumerable: true, get: function () { return instructions_1.buildUpdateConfigInstruction; } });
13
- Object.defineProperty(exports, "buildMigrateRegistryInstruction", { enumerable: true, get: function () { return instructions_1.buildMigrateRegistryInstruction; } });
14
- Object.defineProperty(exports, "buildCreateGroupInstruction", { enumerable: true, get: function () { return instructions_1.buildCreateGroupInstruction; } });
15
- Object.defineProperty(exports, "buildUpdateGroupInstruction", { enumerable: true, get: function () { return instructions_1.buildUpdateGroupInstruction; } });
16
- Object.defineProperty(exports, "buildSendGroupMessageInstruction", { enumerable: true, get: function () { return instructions_1.buildSendGroupMessageInstruction; } });
17
- Object.defineProperty(exports, "buildCloseGroupInstruction", { enumerable: true, get: function () { return instructions_1.buildCloseGroupInstruction; } });
18
- // PDA
14
+ // DMs
15
+ Object.defineProperty(exports, "buildSendMessageInstruction", { enumerable: true, get: function () { return instructions_1.buildSendMessageInstruction; } });
16
+ // Servers
17
+ Object.defineProperty(exports, "buildCreateServerInstruction", { enumerable: true, get: function () { return instructions_1.buildCreateServerInstruction; } });
18
+ Object.defineProperty(exports, "buildInviteToServerInstruction", { enumerable: true, get: function () { return instructions_1.buildInviteToServerInstruction; } });
19
+ Object.defineProperty(exports, "buildRemoveServerMemberInstruction", { enumerable: true, get: function () { return instructions_1.buildRemoveServerMemberInstruction; } });
20
+ Object.defineProperty(exports, "buildLeaveServerInstruction", { enumerable: true, get: function () { return instructions_1.buildLeaveServerInstruction; } });
21
+ Object.defineProperty(exports, "buildUpdateServerInstruction", { enumerable: true, get: function () { return instructions_1.buildUpdateServerInstruction; } });
22
+ Object.defineProperty(exports, "buildCloseServerInstruction", { enumerable: true, get: function () { return instructions_1.buildCloseServerInstruction; } });
23
+ // Channels
24
+ Object.defineProperty(exports, "buildCreateChannelInstruction", { enumerable: true, get: function () { return instructions_1.buildCreateChannelInstruction; } });
25
+ Object.defineProperty(exports, "buildSendChannelMessageInstruction", { enumerable: true, get: function () { return instructions_1.buildSendChannelMessageInstruction; } });
26
+ Object.defineProperty(exports, "buildAddChannelMembersInstruction", { enumerable: true, get: function () { return instructions_1.buildAddChannelMembersInstruction; } });
27
+ Object.defineProperty(exports, "buildRemoveChannelMembersInstruction", { enumerable: true, get: function () { return instructions_1.buildRemoveChannelMembersInstruction; } });
28
+ Object.defineProperty(exports, "buildCloseChannelInstruction", { enumerable: true, get: function () { return instructions_1.buildCloseChannelInstruction; } });
29
+ // PDA derivation
19
30
  var pda_1 = require("./pda");
20
- Object.defineProperty(exports, "deriveRegistryPda", { enumerable: true, get: function () { return pda_1.deriveRegistryPda; } });
21
31
  Object.defineProperty(exports, "deriveConfigPda", { enumerable: true, get: function () { return pda_1.deriveConfigPda; } });
22
- Object.defineProperty(exports, "deriveGroupPda", { enumerable: true, get: function () { return pda_1.deriveGroupPda; } });
32
+ Object.defineProperty(exports, "deriveRegistryPda", { enumerable: true, get: function () { return pda_1.deriveRegistryPda; } });
33
+ Object.defineProperty(exports, "deriveServerPda", { enumerable: true, get: function () { return pda_1.deriveServerPda; } });
34
+ Object.defineProperty(exports, "deriveServerMemberPda", { enumerable: true, get: function () { return pda_1.deriveServerMemberPda; } });
35
+ Object.defineProperty(exports, "deriveChannelPda", { enumerable: true, get: function () { return pda_1.deriveChannelPda; } });
36
+ Object.defineProperty(exports, "deriveChannelMemberPda", { enumerable: true, get: function () { return pda_1.deriveChannelMemberPda; } });
23
37
  // Registry lookup
24
38
  var registry_1 = require("./registry");
25
39
  Object.defineProperty(exports, "lookupEncryptionKey", { enumerable: true, get: function () { return registry_1.lookupEncryptionKey; } });
@@ -37,6 +51,9 @@ Object.defineProperty(exports, "decodeMessage", { enumerable: true, get: functio
37
51
  // Events
38
52
  var events_1 = require("./events");
39
53
  Object.defineProperty(exports, "parseMessageSentEvents", { enumerable: true, get: function () { return events_1.parseMessageSentEvents; } });
54
+ var types_1 = require("./types");
55
+ Object.defineProperty(exports, "ChannelType", { enumerable: true, get: function () { return types_1.ChannelType; } });
56
+ Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return types_1.Role; } });
40
57
  // Convenience class
41
58
  var messenger_1 = require("./messenger");
42
59
  Object.defineProperty(exports, "SolanaMessenger", { enumerable: true, get: function () { return messenger_1.SolanaMessenger; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA6D;AAC7D,+CAawB;AAZtB,2HAAA,2BAA2B,OAAA;AAC3B,wHAAA,wBAAwB,OAAA;AACxB,mIAAA,mCAAmC,OAAA;AACnC,0HAAA,0BAA0B,OAAA;AAC1B,yHAAA,yBAAyB,OAAA;AACzB,gIAAA,gCAAgC,OAAA;AAChC,4HAAA,4BA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C,OAAA;AAClC,iIAAA,iCAAiC,OAAA;AACjC,oIAAA,oCAAoC,OAAA;AACpC,4HAAA,4BAA4B,OAAA;AAG9B,iBAAiB;AACjB,6BAOe;AANb,sGAAA,eAAe,OAAA;AACf,wGAAA,iBAAiB,OAAA;AACjB,sGAAA,eAAe,OAAA;AACf,4GAAA,qBAAqB,OAAA;AACrB,uGAAA,gBAAgB,OAAA;AAChB,6GAAA,sBAAsB,OAAA;AAGxB,kBAAkB;AAClB,uCAAiD;AAAxC,+GAAA,mBAAmB,OAAA;AAE5B,iBAAiB;AACjB,+BAAyD;AAAhD,uHAAA,+BAA+B,OAAA;AAExC,SAAS;AACT,mCAOkB;AANhB,gHAAA,sBAAsB,OAAA;AACtB,iGAAA,OAAO,OAAA;AACP,iGAAA,OAAO,OAAA;AACP,oGAAA,UAAU,OAAA;AACV,uGAAA,aAAa,OAAA;AACb,uGAAA,aAAa,OAAA;AAGf,SAAS;AACT,mCAAkD;AAAzC,gHAAA,sBAAsB,OAAA;AAc/B,iCAA4C;AAAnC,oGAAA,WAAW,OAAA;AAAE,6FAAA,IAAI,OAAA;AAE1B,oBAAoB;AACpB,yCAA8C;AAArC,4GAAA,eAAe,OAAA"}
@@ -1,137 +1,171 @@
1
1
  import { address } from "@solana/kit";
2
- export declare function buildSendMessageInstruction(params: {
3
- sender: string;
4
- recipient: string;
5
- ciphertext: Uint8Array;
6
- nonce: Uint8Array;
7
- configPda: string;
8
- feeVault: string;
9
- recipientRegistryPda: string;
10
- payer?: string;
11
- programId?: string;
12
- }): {
2
+ type Instruction = {
13
3
  programAddress: ReturnType<typeof address>;
14
4
  accounts: any[];
15
5
  data: Uint8Array;
16
6
  };
7
+ export declare function buildInitializeConfigInstruction(params: {
8
+ authority: string;
9
+ configPda: string;
10
+ feeVault: string;
11
+ protocolFee: bigint;
12
+ payer?: string;
13
+ programId?: string;
14
+ }): Instruction;
15
+ export declare function buildUpdateConfigInstruction(params: {
16
+ authority: string;
17
+ configPda: string;
18
+ feeVault?: string;
19
+ protocolFee?: bigint;
20
+ programId?: string;
21
+ }): Instruction;
17
22
  export declare function buildRegisterInstruction(params: {
18
23
  owner: string;
19
24
  encryptionPubkey: Uint8Array;
20
25
  registryPda: string;
21
26
  payer?: string;
22
27
  programId?: string;
23
- }): {
24
- programAddress: ReturnType<typeof address>;
25
- accounts: any[];
26
- data: Uint8Array;
27
- };
28
+ }): Instruction;
28
29
  export declare function buildUpdateEncryptionKeyInstruction(params: {
29
30
  owner: string;
30
31
  newEncryptionPubkey: Uint8Array;
31
32
  registryPda: string;
32
33
  programId?: string;
33
- }): {
34
- programAddress: ReturnType<typeof address>;
35
- accounts: any[];
36
- data: Uint8Array;
37
- };
34
+ }): Instruction;
38
35
  export declare function buildSetMinFeeInstruction(params: {
39
36
  owner: string;
40
37
  registryPda: string;
41
38
  minFee: bigint;
42
39
  programId?: string;
43
- }): {
44
- programAddress: ReturnType<typeof address>;
45
- accounts: any[];
46
- data: Uint8Array;
47
- };
48
- export declare function buildInitializeConfigInstruction(params: {
49
- authority: string;
40
+ }): Instruction;
41
+ export declare function buildDeregisterInstruction(params: {
42
+ owner: string;
43
+ registryPda: string;
44
+ programId?: string;
45
+ }): Instruction;
46
+ export declare function buildSendMessageInstruction(params: {
47
+ sender: string;
48
+ recipient: string;
49
+ ciphertext: Uint8Array;
50
+ nonce: Uint8Array;
50
51
  configPda: string;
51
52
  feeVault: string;
52
- protocolFee: bigint;
53
+ recipientRegistryPda: string;
53
54
  payer?: string;
54
55
  programId?: string;
55
- }): {
56
- programAddress: ReturnType<typeof address>;
57
- accounts: any[];
58
- data: Uint8Array;
59
- };
60
- export declare function buildUpdateConfigInstruction(params: {
61
- authority: string;
62
- configPda: string;
63
- feeVault?: string;
64
- protocolFee?: bigint;
56
+ }): Instruction;
57
+ export declare function buildCreateServerInstruction(params: {
58
+ creator: string;
59
+ serverPda: string;
60
+ serverId: string;
61
+ name: Uint8Array;
62
+ ownerKeyWrap: Uint8Array;
63
+ ownerKeyNonce: Uint8Array;
64
+ ownerServerMemberPda: string;
65
+ payer?: string;
65
66
  programId?: string;
66
- }): {
67
- programAddress: ReturnType<typeof address>;
68
- accounts: any[];
69
- data: Uint8Array;
70
- };
71
- export declare function buildMigrateRegistryInstruction(params: {
72
- owner: string;
73
- registryPda: string;
67
+ }): Instruction;
68
+ export declare function buildInviteToServerInstruction(params: {
69
+ serverId: string;
70
+ serverPda: string;
71
+ inviter: string;
72
+ inviterMemberPda: string;
73
+ newMember: string;
74
+ newMemberPda: string;
75
+ keyWraps: Uint8Array[];
76
+ keyNonces: Uint8Array[];
74
77
  payer?: string;
75
78
  programId?: string;
76
- }): {
77
- programAddress: ReturnType<typeof address>;
78
- accounts: any[];
79
- data: Uint8Array;
80
- };
81
- export declare function buildCreateGroupInstruction(params: {
82
- creator: string;
83
- groupPda: string;
84
- groupId: Uint8Array;
85
- members: string[];
79
+ }): Instruction;
80
+ export declare function buildRemoveServerMemberInstruction(params: {
81
+ serverId: string;
82
+ serverPda: string;
83
+ admin: string;
84
+ adminMemberPda: string;
85
+ removedMember: string;
86
+ removedMemberPda: string;
87
+ remainingMemberPdas: string[];
88
+ newKeyWraps: Uint8Array[];
89
+ newKeyNonces: Uint8Array[];
86
90
  payer?: string;
87
91
  programId?: string;
88
- }): {
89
- programAddress: ReturnType<typeof address>;
90
- accounts: any[];
91
- data: Uint8Array;
92
- };
93
- export declare function buildUpdateGroupInstruction(params: {
92
+ }): Instruction;
93
+ export declare function buildLeaveServerInstruction(params: {
94
+ serverId: string;
95
+ serverPda: string;
96
+ member: string;
97
+ serverMemberPda: string;
98
+ remainingMemberPdas: string[];
99
+ newKeyWraps: Uint8Array[];
100
+ newKeyNonces: Uint8Array[];
101
+ programId?: string;
102
+ }): Instruction;
103
+ export declare function buildUpdateServerInstruction(params: {
104
+ serverPda: string;
105
+ owner: string;
106
+ name: Uint8Array;
107
+ programId?: string;
108
+ }): Instruction;
109
+ export declare function buildCloseServerInstruction(params: {
110
+ serverPda: string;
111
+ owner: string;
112
+ memberPubkeys: string[];
113
+ memberPdas: string[];
114
+ programId?: string;
115
+ }): Instruction;
116
+ export declare function buildCreateChannelInstruction(params: {
94
117
  creator: string;
95
- groupPda: string;
118
+ channelPda: string;
119
+ channelId: string;
120
+ serverId?: string;
121
+ channelType: number;
96
122
  members: string[];
123
+ keyWraps: Uint8Array[];
124
+ keyNonces: Uint8Array[];
125
+ creatorServerMemberPda?: string;
126
+ channelMemberPdas: string[];
127
+ payer?: string;
97
128
  programId?: string;
98
- }): {
99
- programAddress: ReturnType<typeof address>;
100
- accounts: any[];
101
- data: Uint8Array;
102
- };
103
- export declare function buildSendGroupMessageInstruction(params: {
129
+ }): Instruction;
130
+ export declare function buildSendChannelMessageInstruction(params: {
104
131
  sender: string;
105
- groupPda: string;
132
+ channelPda: string;
106
133
  configPda: string;
107
134
  feeVault: string;
108
135
  ciphertext: Uint8Array;
109
136
  nonce: Uint8Array;
110
- keyWraps: Uint8Array[];
111
- keyNonces: Uint8Array[];
137
+ keyVersion: number;
138
+ senderServerMemberPda?: string;
112
139
  payer?: string;
113
140
  programId?: string;
114
- }): {
115
- programAddress: ReturnType<typeof address>;
116
- accounts: any[];
117
- data: Uint8Array;
118
- };
119
- export declare function buildCloseGroupInstruction(params: {
141
+ }): Instruction;
142
+ export declare function buildAddChannelMembersInstruction(params: {
120
143
  creator: string;
121
- groupPda: string;
144
+ channelPda: string;
145
+ newMembers: string[];
146
+ keyWraps: Uint8Array[][];
147
+ keyNonces: Uint8Array[][];
148
+ channelMemberPdas: string[];
149
+ payer?: string;
122
150
  programId?: string;
123
- }): {
124
- programAddress: ReturnType<typeof address>;
125
- accounts: any[];
126
- data: Uint8Array;
127
- };
128
- export declare function buildDeregisterInstruction(params: {
129
- owner: string;
130
- registryPda: string;
151
+ }): Instruction;
152
+ export declare function buildRemoveChannelMembersInstruction(params: {
153
+ creator: string;
154
+ oldChannelPda: string;
155
+ newChannelPda: string;
156
+ removeList: string[];
157
+ newKeyWraps: Uint8Array[];
158
+ newKeyNonces: Uint8Array[];
159
+ removedMemberPdas: string[];
160
+ remainingMemberPdas: string[];
161
+ payer?: string;
131
162
  programId?: string;
132
- }): {
133
- programAddress: ReturnType<typeof address>;
134
- accounts: any[];
135
- data: Uint8Array;
136
- };
163
+ }): Instruction;
164
+ export declare function buildCloseChannelInstruction(params: {
165
+ creator: string;
166
+ channelPda: string;
167
+ channelMemberPdas: string[];
168
+ programId?: string;
169
+ }): Instruction;
170
+ export {};
137
171
  //# sourceMappingURL=instructions.d.ts.map