nostr-double-ratchet 0.0.3 → 0.0.5

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/Channel.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { VerifiedEvent } from "nostr-tools";
2
2
  import { ChannelState, Unsubscribe, NostrSubscribe, MessageCallback } from "./types";
3
3
  /**
4
- * Similar to Signal's "Double Ratchet with header encryption"
4
+ * Double ratchet secure communication channel over Nostr
5
+ *
6
+ * Very similar to Signal's "Double Ratchet with header encryption"
5
7
  * https://signal.org/docs/specifications/doubleratchet/
6
8
  */
7
9
  export declare class Channel {
@@ -14,11 +16,28 @@ export declare class Channel {
14
16
  name: string;
15
17
  constructor(nostrSubscribe: NostrSubscribe, state: ChannelState);
16
18
  /**
17
- * @param sharedSecret optional, but useful to keep the first chain of messages secure. Unlike the Nostr keys, it can be forgotten after the 1st message in the chain.
18
- * @param isInitiator determines which chain key is used for sending vs receiving
19
+ * Initializes a new secure communication channel
20
+ * @param nostrSubscribe Function to subscribe to Nostr events
21
+ * @param theirNostrPublicKey The public key of the other party
22
+ * @param ourCurrentPrivateKey Our current private key for Nostr
23
+ * @param isInitiator Whether we are initiating the conversation (true) or responding (false)
24
+ * @param sharedSecret Initial shared secret for securing the first message chain
25
+ * @param name Optional name for the channel (for debugging)
26
+ * @returns A new Channel instance
27
+ */
28
+ static init(nostrSubscribe: NostrSubscribe, theirNostrPublicKey: string, ourCurrentPrivateKey: Uint8Array, isInitiator: boolean, sharedSecret: Uint8Array, name?: string): Channel;
29
+ /**
30
+ * Sends an encrypted message through the channel
31
+ * @param data The plaintext message to send
32
+ * @returns A verified Nostr event containing the encrypted message
33
+ * @throws Error if we are not the initiator and trying to send the first message
19
34
  */
20
- static init(nostrSubscribe: NostrSubscribe, theirNostrPublicKey: string, ourCurrentPrivateKey: Uint8Array, sharedSecret?: Uint8Array, name?: string, isInitiator?: boolean): Channel;
21
35
  send(data: string): VerifiedEvent;
36
+ /**
37
+ * Subscribes to incoming messages on this channel
38
+ * @param callback Function to be called when a message is received
39
+ * @returns Unsubscribe function to stop receiving messages
40
+ */
22
41
  onMessage(callback: MessageCallback): Unsubscribe;
23
42
  private ratchetEncrypt;
24
43
  private ratchetDecrypt;
@@ -1 +1 @@
1
- {"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,aAAa,EAAE,MAAM,aAAa,CAAC;AAEnG,OAAO,EACL,YAAY,EAEZ,WAAW,EACX,cAAc,EACd,eAAe,EAEhB,MAAM,SAAS,CAAC;AAKjB;;;GAGG;AACH,qBAAa,OAAO;IAON,OAAO,CAAC,cAAc;IAAyB,KAAK,EAAE,YAAY;IAN9E,OAAO,CAAC,gBAAgB,CAAC,CAAc;IACvC,OAAO,CAAC,oBAAoB,CAAC,CAAc;IAC3C,OAAO,CAAC,qBAAqB,CAAsC;IACnE,OAAO,CAAC,6BAA6B,CAAK;IACnC,IAAI,EAAE,MAAM,CAAC;gBAEA,cAAc,EAAE,cAAc,EAAS,KAAK,EAAE,YAAY;IAI9E;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,oBAAoB,EAAE,UAAU,EAAE,YAAY,aAAmB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,UAAO,GAAG,OAAO;IA6BvL,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa;IAoBjC,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,WAAW;IAOjD,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,WAAW;IAwBnB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,gBAAgB;IAuBxB,OAAO,CAAC,sBAAsB;CAa/B"}
1
+ {"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,aAAa,EAAE,MAAM,aAAa,CAAC;AAEnG,OAAO,EACL,YAAY,EAEZ,WAAW,EACX,cAAc,EACd,eAAe,EAEhB,MAAM,SAAS,CAAC;AAKjB;;;;;GAKG;AACH,qBAAa,OAAO;IAQN,OAAO,CAAC,cAAc;IAAyB,KAAK,EAAE,YAAY;IAP9E,OAAO,CAAC,gBAAgB,CAAC,CAAc;IACvC,OAAO,CAAC,oBAAoB,CAAC,CAAc;IAC3C,OAAO,CAAC,qBAAqB,CAAsC;IACnE,OAAO,CAAC,6BAA6B,CAAK;IACnC,IAAI,EAAE,MAAM,CAAC;gBAGA,cAAc,EAAE,cAAc,EAAS,KAAK,EAAE,YAAY;IAI9E;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO;IA4BlL;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa;IAoBjC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,WAAW;IAQjD,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,WAAW;IAyBnB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,gBAAgB;IAuBxB,OAAO,CAAC,sBAAsB;CAyB/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"InviteLink.d.ts","sourceRoot":"","sources":["../src/InviteLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,aAAa,EAAS,MAAM,aAAa,CAAC;AAE1G,OAAO,EAAE,cAAc,EA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