nostr-double-ratchet 0.0.6 → 0.0.8
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 +2 -1
- package/dist/Channel.d.ts +4 -0
- package/dist/Channel.d.ts.map +1 -1
- package/dist/{InviteLink.d.ts → Invite.d.ts} +10 -7
- package/dist/Invite.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/nostr-double-ratchet.es.js +1227 -1145
- package/dist/nostr-double-ratchet.umd.js +1 -1
- package/dist/types.d.ts +7 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/Channel.ts +73 -33
- package/src/{InviteLink.ts → Invite.ts} +73 -13
- package/src/index.ts +1 -1
- package/src/types.ts +9 -9
- package/src/utils.ts +12 -0
- package/dist/InviteLink.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
* Double ratchet on nostr
|
|
2
2
|
- [x] 1-on-1 channel
|
|
3
3
|
- [ ] group channel
|
|
4
|
-
*
|
|
4
|
+
* Invites for securely exchanging session keys. Don't use your long-term key for initiating a session.
|
|
5
5
|
* Breaking changes are likely
|
|
6
6
|
* Stable version on [NPM](https://www.npmjs.com/package/nostr-double-ratchet)
|
|
7
7
|
* check out [tests](./tests/) for usage
|
|
8
|
+
* [Documentation](https://nostr-double-ratchet.iris.to/)
|
package/dist/Channel.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ export declare class Channel {
|
|
|
39
39
|
* @returns Unsubscribe function to stop receiving messages
|
|
40
40
|
*/
|
|
41
41
|
onMessage(callback: MessageCallback): Unsubscribe;
|
|
42
|
+
/**
|
|
43
|
+
* Stop listening to incoming messages
|
|
44
|
+
*/
|
|
45
|
+
close(): void;
|
|
42
46
|
private ratchetEncrypt;
|
|
43
47
|
private ratchetDecrypt;
|
|
44
48
|
private ratchetStep;
|
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;;;;;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;
|
|
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;IA6BlL;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa;IAoBjC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,WAAW;IAOjD;;OAEG;IACH,KAAK;IAML,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,WAAW;IAyBnB,OAAO,CAAC,eAAe;IAyBvB,OAAO,CAAC,qBAAqB;IAqB7B,OAAO,CAAC,aAAa;IAmCrB,OAAO,CAAC,gBAAgB;IA8BxB,OAAO,CAAC,sBAAsB;CAiB/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VerifiedEvent } from "nostr-tools";
|
|
1
|
+
import { VerifiedEvent, UnsignedEvent } from "nostr-tools";
|
|
2
2
|
import { NostrSubscribe, Unsubscribe } from "./types";
|
|
3
3
|
import { Channel } from "./Channel";
|
|
4
4
|
import { EncryptFunction, DecryptFunction } from "./types";
|
|
@@ -13,7 +13,7 @@ import { EncryptFunction, DecryptFunction } from "./types";
|
|
|
13
13
|
*
|
|
14
14
|
* Also make sure to keep the session key safe.
|
|
15
15
|
*/
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class Invite {
|
|
17
17
|
inviterSessionPublicKey: string;
|
|
18
18
|
linkSecret: string;
|
|
19
19
|
inviter: string;
|
|
@@ -22,11 +22,14 @@ export declare class InviteLink {
|
|
|
22
22
|
maxUses?: number | undefined;
|
|
23
23
|
usedBy: string[];
|
|
24
24
|
constructor(inviterSessionPublicKey: string, linkSecret: string, inviter: string, inviterSessionPrivateKey?: Uint8Array | undefined, label?: string | undefined, maxUses?: number | undefined, usedBy?: string[]);
|
|
25
|
-
static createNew(inviter: string, label?: string, maxUses?: number):
|
|
26
|
-
static fromUrl(url: string):
|
|
27
|
-
static deserialize(json: string):
|
|
25
|
+
static createNew(inviter: string, label?: string, maxUses?: number): Invite;
|
|
26
|
+
static fromUrl(url: string): Invite;
|
|
27
|
+
static deserialize(json: string): Invite;
|
|
28
|
+
static fromEvent(event: VerifiedEvent): Invite;
|
|
29
|
+
static fromUser(user: string, subscribe: NostrSubscribe): Promise<Invite | undefined>;
|
|
28
30
|
serialize(): string;
|
|
29
31
|
getUrl(root?: string): string;
|
|
32
|
+
getEvent(): UnsignedEvent;
|
|
30
33
|
/**
|
|
31
34
|
* Accepts the invite and creates a new channel with the inviter.
|
|
32
35
|
*
|
|
@@ -42,10 +45,10 @@ export declare class InviteLink {
|
|
|
42
45
|
* Note: You need to publish the returned event on Nostr using NDK or another Nostr system of your choice,
|
|
43
46
|
* so the inviter can create the channel on their side.
|
|
44
47
|
*/
|
|
45
|
-
|
|
48
|
+
accept(nostrSubscribe: NostrSubscribe, inviteePublicKey: string, inviteeSecretKey: Uint8Array | EncryptFunction): Promise<{
|
|
46
49
|
channel: Channel;
|
|
47
50
|
event: VerifiedEvent;
|
|
48
51
|
}>;
|
|
49
52
|
listen(inviterSecretKey: Uint8Array | DecryptFunction, nostrSubscribe: NostrSubscribe, onChannel: (channel: Channel, identity?: string) => void): Unsubscribe;
|
|
50
53
|
}
|
|
51
|
-
//# sourceMappingURL=
|
|
54
|
+
//# sourceMappingURL=Invite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Invite.d.ts","sourceRoot":"","sources":["../src/Invite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,aAAa,EAAS,aAAa,EAAe,MAAM,aAAa,CAAC;AACtI,OAAO,EAAqB,cAAc,EAAE,WAAW,EA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,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,aAAa,CAAA;KAAE,CAAC;IAkCtD,MAAM,CAAC,gBAAgB,EAAE,UAAU,GAAG,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,WAAW;CAoChK"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|