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 +23 -4
- package/dist/Channel.d.ts.map +1 -1
- package/dist/InviteLink.d.ts.map +1 -1
- package/dist/nostr-double-ratchet.es.js +483 -455
- package/dist/nostr-double-ratchet.umd.js +1 -1
- package/dist/types.d.ts +17 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -16
- package/src/Channel.ts +52 -18
- package/src/InviteLink.ts +6 -4
- package/src/types.ts +19 -1
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
|
-
*
|
|
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
|
-
*
|
|
18
|
-
* @param
|
|
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;
|
package/dist/Channel.d.ts.map
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/InviteLink.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InviteLink.d.ts","sourceRoot":"","sources":["../src/InviteLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,aAAa,EAAS,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"InviteLink.d.ts","sourceRoot":"","sources":["../src/InviteLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,aAAa,EAAS,MAAM,aAAa,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA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