nostr-double-ratchet 0.0.14 → 0.0.16

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/Session.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { VerifiedEvent } from "nostr-tools";
2
- import { SessionState, Unsubscribe, NostrSubscribe, MessageCallback } from "./types";
1
+ import { VerifiedEvent, UnsignedEvent } from "nostr-tools";
2
+ import { SessionState, Unsubscribe, NostrSubscribe, EventCallback } from "./types";
3
3
  /**
4
4
  * Double ratchet secure communication session over Nostr
5
5
  *
@@ -27,18 +27,26 @@ export declare class Session {
27
27
  */
28
28
  static init(nostrSubscribe: NostrSubscribe, theirNextNostrPublicKey: string, ourCurrentPrivateKey: Uint8Array, isInitiator: boolean, sharedSecret: Uint8Array, name?: string): Session;
29
29
  /**
30
- * Sends an encrypted message through the session
31
- * @param data The plaintext message to send
30
+ * Sends a text message through the encrypted session
31
+ * @param text The plaintext message to send
32
32
  * @returns A verified Nostr event containing the encrypted message
33
33
  * @throws Error if we are not the initiator and trying to send the first message
34
34
  */
35
- send(data: string): VerifiedEvent;
35
+ send(text: string): VerifiedEvent;
36
+ /**
37
+ * Send a partial Nostr event through the encrypted session.
38
+ * In addition to chat messages, it could be files, webrtc negotiation or many other types of messages.
39
+ * @param event Partial Nostr event to send. Must be unsigned. Id and will be generated if not provided.
40
+ * @returns A verified Nostr event containing the encrypted message
41
+ * @throws Error if we are not the initiator and trying to send the first message
42
+ */
43
+ sendEvent(event: Partial<UnsignedEvent>): VerifiedEvent;
36
44
  /**
37
45
  * Subscribes to incoming messages on this session
38
46
  * @param callback Function to be called when a message is received
39
47
  * @returns Unsubscribe function to stop receiving messages
40
48
  */
41
- onMessage(callback: MessageCallback): Unsubscribe;
49
+ onEvent(callback: EventCallback): Unsubscribe;
42
50
  /**
43
51
  * Stop listening to incoming messages
44
52
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../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