nostr-double-ratchet 0.0.1 → 0.0.3
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 +7 -4
- package/dist/Channel.d.ts +21 -13
- package/dist/Channel.d.ts.map +1 -1
- package/dist/InviteLink.d.ts.map +1 -1
- package/dist/nostr-double-ratchet.es.js +1126 -1067
- package/dist/nostr-double-ratchet.umd.js +1 -1
- package/dist/types.d.ts +21 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/Channel.ts +187 -99
- package/src/InviteLink.ts +3 -2
- package/src/types.ts +30 -13
- package/src/utils.ts +24 -15
- package/data/profileData.json +0 -1
- package/data/profileIndex.json +0 -1
- package/data/socialGraph.json +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
1
|
+
* Double ratchet on nostr
|
|
2
|
+
- [x] 1-on-1 channel
|
|
3
|
+
- [ ] group channel
|
|
4
|
+
* Invite links for securely exchanging session keys. don't use your long-term key for initiating a session.
|
|
5
|
+
* Breaking changes are likely
|
|
6
|
+
* Stable version on [NPM](https://www.npmjs.com/package/nostr-double-ratchet)
|
|
7
|
+
* check out [tests](./tests/) for usage
|
package/dist/Channel.d.ts
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import { VerifiedEvent } from "nostr-tools";
|
|
2
|
-
import { ChannelState, Unsubscribe, NostrSubscribe, MessageCallback
|
|
2
|
+
import { ChannelState, Unsubscribe, NostrSubscribe, MessageCallback } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Similar to Signal's "Double Ratchet with header encryption"
|
|
5
|
+
* https://signal.org/docs/specifications/doubleratchet/
|
|
6
|
+
*/
|
|
3
7
|
export declare class Channel {
|
|
4
8
|
private nostrSubscribe;
|
|
5
9
|
state: ChannelState;
|
|
6
|
-
nostrUnsubscribe
|
|
7
|
-
nostrNextUnsubscribe
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
private nostrUnsubscribe?;
|
|
11
|
+
private nostrNextUnsubscribe?;
|
|
12
|
+
private internalSubscriptions;
|
|
13
|
+
private currentInternalSubscriptionId;
|
|
10
14
|
name: string;
|
|
11
15
|
constructor(nostrSubscribe: NostrSubscribe, state: ChannelState);
|
|
12
16
|
/**
|
|
13
|
-
*
|
|
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
|
|
14
19
|
*/
|
|
15
|
-
static init(nostrSubscribe: NostrSubscribe,
|
|
16
|
-
updateTheirCurrentNostrPublicKey(theirNewPublicKey: string): void;
|
|
17
|
-
private rotateOurCurrentNostrKey;
|
|
18
|
-
getNostrSenderKeypair(sender: Sender, keyType: KeyType): KeyPair;
|
|
19
|
-
private nostrSubscribeNext;
|
|
20
|
-
private subscribeToNostrEvents;
|
|
21
|
-
onMessage(callback: MessageCallback): Unsubscribe;
|
|
20
|
+
static init(nostrSubscribe: NostrSubscribe, theirNostrPublicKey: string, ourCurrentPrivateKey: Uint8Array, sharedSecret?: Uint8Array, name?: string, isInitiator?: boolean): Channel;
|
|
22
21
|
send(data: string): VerifiedEvent;
|
|
22
|
+
onMessage(callback: MessageCallback): Unsubscribe;
|
|
23
|
+
private ratchetEncrypt;
|
|
24
|
+
private ratchetDecrypt;
|
|
25
|
+
private ratchetStep;
|
|
26
|
+
private skipMessageKeys;
|
|
27
|
+
private trySkippedMessageKeys;
|
|
28
|
+
private decryptHeader;
|
|
29
|
+
private handleNostrEvent;
|
|
30
|
+
private subscribeToNostrEvents;
|
|
23
31
|
}
|
|
24
32
|
//# sourceMappingURL=Channel.d.ts.map
|
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,
|
|
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"}
|
package/dist/InviteLink.d.ts.map
CHANGED
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