nostr-double-ratchet 0.0.7 → 0.0.9

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 CHANGED
@@ -1,7 +1,8 @@
1
1
  * Double ratchet on nostr
2
2
  - [x] 1-on-1 channel
3
3
  - [ ] group channel
4
- * Invite links for securely exchanging session keys. don't use your long-term key for initiating a session.
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/)
@@ -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;IA6BlL;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa;IAoB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AAC,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,19 +1,18 @@
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";
5
5
  /**
6
- * Invite link is a safe way to exchange session keys and initiate secret channels.
6
+ * Invite is a safe way to exchange session keys and initiate secret channels.
7
+ *
8
+ * It can be shared privately as an URL (e.g. QR code) or published as a Nostr event.
7
9
  *
8
10
  * Even if inviter's or invitee's long-term private key (identity key) and the shared secret (link) is compromised,
9
11
  * forward secrecy is preserved as long as the session keys are not compromised.
10
12
  *
11
- * Shared secret Nostr channel: inviter listens to it and invitees can write to it. Outside observers don't know who are communicating over it.
12
- * It is vulnerable to spam, so the link should only be given to trusted invitees or used with a reasonable maxUses limit.
13
- *
14
13
  * Also make sure to keep the session key safe.
15
14
  */
16
- export declare class InviteLink {
15
+ export declare class Invite {
17
16
  inviterSessionPublicKey: string;
18
17
  linkSecret: string;
19
18
  inviter: string;
@@ -22,13 +21,22 @@ export declare class InviteLink {
22
21
  maxUses?: number | undefined;
23
22
  usedBy: string[];
24
23
  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): InviteLink;
26
- static fromUrl(url: string): InviteLink;
27
- static deserialize(json: string): InviteLink;
24
+ static createNew(inviter: string, label?: string, maxUses?: number): Invite;
25
+ static fromUrl(url: string): Invite;
26
+ static deserialize(json: string): Invite;
27
+ static fromEvent(event: VerifiedEvent): Invite;
28
+ static fromUser(user: string, subscribe: NostrSubscribe): Promise<Invite | undefined>;
29
+ /**
30
+ * Save Invite as JSON. Includes the inviter's session private key, so don't share this.
31
+ */
28
32
  serialize(): string;
33
+ /**
34
+ * Invite parameters are in the URL's hash so they are not sent to the server.
35
+ */
29
36
  getUrl(root?: string): string;
37
+ getEvent(): UnsignedEvent;
30
38
  /**
31
- * Accepts the invite and creates a new channel with the inviter.
39
+ * Called by the invitee. Accepts the invite and creates a new channel with the inviter.
32
40
  *
33
41
  * @param inviteeSecretKey - The invitee's secret key or a signing function
34
42
  * @param nostrSubscribe - A function to subscribe to Nostr events
@@ -42,10 +50,10 @@ export declare class InviteLink {
42
50
  * Note: You need to publish the returned event on Nostr using NDK or another Nostr system of your choice,
43
51
  * so the inviter can create the channel on their side.
44
52
  */
45
- acceptInvite(nostrSubscribe: NostrSubscribe, inviteePublicKey: string, inviteeSecretKey: Uint8Array | EncryptFunction): Promise<{
53
+ accept(nostrSubscribe: NostrSubscribe, inviteePublicKey: string, inviteeSecretKey: Uint8Array | EncryptFunction): Promise<{
46
54
  channel: Channel;
47
55
  event: VerifiedEvent;
48
56
  }>;
49
57
  listen(inviterSecretKey: Uint8Array | DecryptFunction, nostrSubscribe: NostrSubscribe, onChannel: (channel: Channel, identity?: string) => void): Unsubscribe;
50
58
  }
51
- //# sourceMappingURL=InviteLink.d.ts.map
59
+ //# 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,EAAuB,MAAM,aAAa,CAAC;AAC9I,OAAO,EAAqB,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG3D;;;;;;;;;GAS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G,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,WAAW;CA4ChK"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "./Channel";
2
- export * from "./InviteLink";
2
+ export * from "./Invite";
3
3
  export * from "./types";
4
4
  export * from "./utils";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
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"}