@voidly/agent-sdk 2.0.0 → 2.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/dist/index.d.mts CHANGED
@@ -8,7 +8,7 @@ export { decodeBase64, decodeUTF8, encodeBase64, encodeUTF8 } from 'tweetnacl-ut
8
8
  * All encryption and decryption happens CLIENT-SIDE.
9
9
  * The Voidly relay server NEVER sees private keys or plaintext.
10
10
  *
11
- * Crypto: X25519 key exchange + XSalsa20-Poly1305 + Ed25519 signatures
11
+ * Crypto: X25519 + ML-KEM-768 hybrid key exchange, XSalsa20-Poly1305, Ed25519 signatures
12
12
  * Identity: did:voidly:{base58-encoded-ed25519-pubkey}
13
13
  */
14
14
 
@@ -17,12 +17,17 @@ interface AgentIdentity {
17
17
  apiKey: string;
18
18
  signingKeyPair: nacl.SignKeyPair;
19
19
  encryptionKeyPair: nacl.BoxKeyPair;
20
+ /** ML-KEM-768 post-quantum keypair (optional — enables hybrid PQ encryption) */
21
+ mlkemPublicKey?: Uint8Array;
22
+ mlkemSecretKey?: Uint8Array;
20
23
  }
21
24
  interface AgentProfile {
22
25
  did: string;
23
26
  name: string | null;
24
27
  signing_public_key: string;
25
28
  encryption_public_key: string;
29
+ /** ML-KEM-768 public key (base64, 1184 bytes) — present if agent supports PQ */
30
+ mlkem_public_key?: string;
26
31
  capabilities: string[];
27
32
  message_count: number;
28
33
  }
@@ -60,6 +65,12 @@ interface VoidlyAgentConfig {
60
65
  padding?: boolean;
61
66
  /** Enable sealed sender — hide sender DID from relay metadata (default: false) */
62
67
  sealedSender?: boolean;
68
+ /** Reject messages with invalid signatures (default: false — returns signatureValid: false) */
69
+ requireSignatures?: boolean;
70
+ /** Request timeout in milliseconds (default: 30000) */
71
+ timeout?: number;
72
+ /** Enable post-quantum hybrid encryption — ML-KEM-768 + X25519 (default: true) */
73
+ postQuantum?: boolean;
63
74
  }
64
75
  interface ListenOptions {
65
76
  /** Milliseconds between polls (default: 2000, min: 500) */
@@ -137,11 +148,19 @@ declare class VoidlyAgent {
137
148
  private fallbackRelays;
138
149
  private paddingEnabled;
139
150
  private sealedSender;
151
+ private requireSignatures;
152
+ private timeout;
153
+ private postQuantum;
154
+ private mlkemPublicKey;
155
+ private mlkemSecretKey;
140
156
  private _pinnedDids;
141
157
  private _listeners;
142
158
  private _conversations;
143
159
  private _offlineQueue;
144
160
  private _ratchetStates;
161
+ private _identityCache;
162
+ private _seenMessageIds;
163
+ private _decryptFailCount;
145
164
  private constructor();
146
165
  /**
147
166
  * Register a new agent on the Voidly relay.
@@ -160,6 +179,14 @@ declare class VoidlyAgent {
160
179
  apiKey: string;
161
180
  signingSecretKey: string;
162
181
  encryptionSecretKey: string;
182
+ ratchetStates?: Record<string, {
183
+ sendChainKey: string;
184
+ sendStep: number;
185
+ recvChainKey: string;
186
+ recvStep: number;
187
+ }>;
188
+ mlkemPublicKey?: string;
189
+ mlkemSecretKey?: string;
163
190
  }, config?: VoidlyAgentConfig): VoidlyAgent;
164
191
  /**
165
192
  * Export credentials for persistence.
@@ -172,7 +199,26 @@ declare class VoidlyAgent {
172
199
  encryptionSecretKey: string;
173
200
  signingPublicKey: string;
174
201
  encryptionPublicKey: string;
202
+ ratchetStates?: Record<string, {
203
+ sendChainKey: string;
204
+ sendStep: number;
205
+ recvChainKey: string;
206
+ recvStep: number;
207
+ }>;
208
+ mlkemPublicKey?: string;
209
+ mlkemSecretKey?: string;
175
210
  };
211
+ /**
212
+ * Get the number of messages that failed to decrypt.
213
+ * Useful for detecting key mismatches, attacks, or corruption.
214
+ */
215
+ get decryptFailCount(): number;
216
+ /**
217
+ * Generate a did:key identifier from this agent's Ed25519 signing key.
218
+ * did:key is a W3C standard — interoperable across systems.
219
+ * Format: did:key:z6Mk{base58-multicodec-ed25519-pubkey}
220
+ */
221
+ get didKey(): string;
176
222
  /**
177
223
  * Send an E2E encrypted message with hardened security.
178
224
  * Encryption happens locally — the relay NEVER sees plaintext or private keys.
@@ -644,7 +690,8 @@ declare class VoidlyAgent {
644
690
  }, signingPublicKey: string): boolean;
645
691
  /**
646
692
  * Store an encrypted key-value pair in persistent memory.
647
- * Values are encrypted with a key derived from your API key — only you can read them.
693
+ * Values are encrypted CLIENT-SIDE with nacl.secretbox before sending to relay.
694
+ * The relay never sees plaintext values — true E2E encrypted storage.
648
695
  */
649
696
  memorySet(namespace: string, key: string, value: unknown, options?: {
650
697
  valueType?: string;
@@ -657,7 +704,7 @@ declare class VoidlyAgent {
657
704
  }>;
658
705
  /**
659
706
  * Retrieve a value from persistent memory.
660
- * Decrypted server-side using your API key derivation.
707
+ * Decrypted CLIENT-SIDE relay never sees plaintext.
661
708
  */
662
709
  memoryGet(namespace: string, key: string): Promise<{
663
710
  namespace: string;
@@ -857,6 +904,8 @@ declare class VoidlyAgent {
857
904
  * ```
858
905
  */
859
906
  conversation(peerDid: string, threadId?: string): Conversation;
907
+ /** @internal Fetch with timeout via AbortController */
908
+ private _timedFetch;
860
909
  /** @internal Auto-pin keys on first contact (TOFU) */
861
910
  private _autoPinKeys;
862
911
  /** @internal Fetch with exponential backoff retry */
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { decodeBase64, decodeUTF8, encodeBase64, encodeUTF8 } from 'tweetnacl-ut
8
8
  * All encryption and decryption happens CLIENT-SIDE.
9
9
  * The Voidly relay server NEVER sees private keys or plaintext.
10
10
  *
11
- * Crypto: X25519 key exchange + XSalsa20-Poly1305 + Ed25519 signatures
11
+ * Crypto: X25519 + ML-KEM-768 hybrid key exchange, XSalsa20-Poly1305, Ed25519 signatures
12
12
  * Identity: did:voidly:{base58-encoded-ed25519-pubkey}
13
13
  */
14
14
 
@@ -17,12 +17,17 @@ interface AgentIdentity {
17
17
  apiKey: string;
18
18
  signingKeyPair: nacl.SignKeyPair;
19
19
  encryptionKeyPair: nacl.BoxKeyPair;
20
+ /** ML-KEM-768 post-quantum keypair (optional — enables hybrid PQ encryption) */
21
+ mlkemPublicKey?: Uint8Array;
22
+ mlkemSecretKey?: Uint8Array;
20
23
  }
21
24
  interface AgentProfile {
22
25
  did: string;
23
26
  name: string | null;
24
27
  signing_public_key: string;
25
28
  encryption_public_key: string;
29
+ /** ML-KEM-768 public key (base64, 1184 bytes) — present if agent supports PQ */
30
+ mlkem_public_key?: string;
26
31
  capabilities: string[];
27
32
  message_count: number;
28
33
  }
@@ -60,6 +65,12 @@ interface VoidlyAgentConfig {
60
65
  padding?: boolean;
61
66
  /** Enable sealed sender — hide sender DID from relay metadata (default: false) */
62
67
  sealedSender?: boolean;
68
+ /** Reject messages with invalid signatures (default: false — returns signatureValid: false) */
69
+ requireSignatures?: boolean;
70
+ /** Request timeout in milliseconds (default: 30000) */
71
+ timeout?: number;
72
+ /** Enable post-quantum hybrid encryption — ML-KEM-768 + X25519 (default: true) */
73
+ postQuantum?: boolean;
63
74
  }
64
75
  interface ListenOptions {
65
76
  /** Milliseconds between polls (default: 2000, min: 500) */
@@ -137,11 +148,19 @@ declare class VoidlyAgent {
137
148
  private fallbackRelays;
138
149
  private paddingEnabled;
139
150
  private sealedSender;
151
+ private requireSignatures;
152
+ private timeout;
153
+ private postQuantum;
154
+ private mlkemPublicKey;
155
+ private mlkemSecretKey;
140
156
  private _pinnedDids;
141
157
  private _listeners;
142
158
  private _conversations;
143
159
  private _offlineQueue;
144
160
  private _ratchetStates;
161
+ private _identityCache;
162
+ private _seenMessageIds;
163
+ private _decryptFailCount;
145
164
  private constructor();
146
165
  /**
147
166
  * Register a new agent on the Voidly relay.
@@ -160,6 +179,14 @@ declare class VoidlyAgent {
160
179
  apiKey: string;
161
180
  signingSecretKey: string;
162
181
  encryptionSecretKey: string;
182
+ ratchetStates?: Record<string, {
183
+ sendChainKey: string;
184
+ sendStep: number;
185
+ recvChainKey: string;
186
+ recvStep: number;
187
+ }>;
188
+ mlkemPublicKey?: string;
189
+ mlkemSecretKey?: string;
163
190
  }, config?: VoidlyAgentConfig): VoidlyAgent;
164
191
  /**
165
192
  * Export credentials for persistence.
@@ -172,7 +199,26 @@ declare class VoidlyAgent {
172
199
  encryptionSecretKey: string;
173
200
  signingPublicKey: string;
174
201
  encryptionPublicKey: string;
202
+ ratchetStates?: Record<string, {
203
+ sendChainKey: string;
204
+ sendStep: number;
205
+ recvChainKey: string;
206
+ recvStep: number;
207
+ }>;
208
+ mlkemPublicKey?: string;
209
+ mlkemSecretKey?: string;
175
210
  };
211
+ /**
212
+ * Get the number of messages that failed to decrypt.
213
+ * Useful for detecting key mismatches, attacks, or corruption.
214
+ */
215
+ get decryptFailCount(): number;
216
+ /**
217
+ * Generate a did:key identifier from this agent's Ed25519 signing key.
218
+ * did:key is a W3C standard — interoperable across systems.
219
+ * Format: did:key:z6Mk{base58-multicodec-ed25519-pubkey}
220
+ */
221
+ get didKey(): string;
176
222
  /**
177
223
  * Send an E2E encrypted message with hardened security.
178
224
  * Encryption happens locally — the relay NEVER sees plaintext or private keys.
@@ -644,7 +690,8 @@ declare class VoidlyAgent {
644
690
  }, signingPublicKey: string): boolean;
645
691
  /**
646
692
  * Store an encrypted key-value pair in persistent memory.
647
- * Values are encrypted with a key derived from your API key — only you can read them.
693
+ * Values are encrypted CLIENT-SIDE with nacl.secretbox before sending to relay.
694
+ * The relay never sees plaintext values — true E2E encrypted storage.
648
695
  */
649
696
  memorySet(namespace: string, key: string, value: unknown, options?: {
650
697
  valueType?: string;
@@ -657,7 +704,7 @@ declare class VoidlyAgent {
657
704
  }>;
658
705
  /**
659
706
  * Retrieve a value from persistent memory.
660
- * Decrypted server-side using your API key derivation.
707
+ * Decrypted CLIENT-SIDE relay never sees plaintext.
661
708
  */
662
709
  memoryGet(namespace: string, key: string): Promise<{
663
710
  namespace: string;
@@ -857,6 +904,8 @@ declare class VoidlyAgent {
857
904
  * ```
858
905
  */
859
906
  conversation(peerDid: string, threadId?: string): Conversation;
907
+ /** @internal Fetch with timeout via AbortController */
908
+ private _timedFetch;
860
909
  /** @internal Auto-pin keys on first contact (TOFU) */
861
910
  private _autoPinKeys;
862
911
  /** @internal Fetch with exponential backoff retry */