@freesignal/protocol 0.2.8 → 0.2.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/api.d.ts +3 -5
- package/api.js +4 -5
- package/package.json +1 -1
package/api.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* You should have received a copy of the GNU General Public License
|
|
17
17
|
* along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
18
18
|
*/
|
|
19
|
-
import { Crypto, KeyExchangeData, KeyExchangeDataBundle, KeyExchangeSynMessage, LocalStorage } from "@freesignal/interfaces";
|
|
19
|
+
import { Crypto, Database, KeyExchangeData, KeyExchangeDataBundle, KeyExchangeSynMessage, LocalStorage } from "@freesignal/interfaces";
|
|
20
20
|
import { ExportedKeySession } from "./double-ratchet";
|
|
21
21
|
import { KeyExchange } from "./x3dh";
|
|
22
22
|
import { Datagram, IdentityKeys, EncryptedData, UserId } from "./types";
|
|
@@ -28,13 +28,11 @@ export declare class FreeSignalAPI {
|
|
|
28
28
|
protected readonly keyExchange: KeyExchange;
|
|
29
29
|
protected readonly users: LocalStorage<UserId, IdentityKeys>;
|
|
30
30
|
readonly userId: UserId;
|
|
31
|
-
constructor(
|
|
32
|
-
secretSignKey: Uint8Array;
|
|
33
|
-
secretBoxKey: Uint8Array;
|
|
31
|
+
constructor(secretSignKey: Uint8Array, secretBoxKey: Uint8Array, storage: Database<{
|
|
34
32
|
sessions: LocalStorage<UserId, ExportedKeySession>;
|
|
35
33
|
keyExchange: LocalStorage<string, Crypto.KeyPair>;
|
|
36
34
|
users: LocalStorage<UserId, IdentityKeys>;
|
|
37
|
-
});
|
|
35
|
+
}>);
|
|
38
36
|
get identityKeys(): IdentityKeys;
|
|
39
37
|
encryptData(data: Uint8Array, userId: string): Promise<EncryptedData>;
|
|
40
38
|
decryptData(data: Uint8Array, userId: string): Promise<Uint8Array>;
|
package/api.js
CHANGED
|
@@ -37,13 +37,12 @@ const x3dh_1 = require("./x3dh");
|
|
|
37
37
|
const utils_1 = require("@freesignal/utils");
|
|
38
38
|
const types_1 = require("./types");
|
|
39
39
|
class FreeSignalAPI {
|
|
40
|
-
constructor(
|
|
41
|
-
const { secretSignKey, secretBoxKey, sessions, keyExchange, users } = opts;
|
|
40
|
+
constructor(secretSignKey, secretBoxKey, storage) {
|
|
42
41
|
this.signKey = crypto_1.default.EdDSA.keyPair(secretSignKey);
|
|
43
42
|
this.boxKey = crypto_1.default.ECDH.keyPair(secretBoxKey);
|
|
44
|
-
this.sessions = sessions;
|
|
45
|
-
this.keyExchange = new x3dh_1.KeyExchange(secretSignKey, secretBoxKey, keyExchange);
|
|
46
|
-
this.users = users;
|
|
43
|
+
this.sessions = storage.sessions;
|
|
44
|
+
this.keyExchange = new x3dh_1.KeyExchange(secretSignKey, secretBoxKey, storage.keyExchange);
|
|
45
|
+
this.users = storage.users;
|
|
47
46
|
this.userId = types_1.UserId.getUserId(this.signKey.publicKey).toString();
|
|
48
47
|
}
|
|
49
48
|
get identityKeys() {
|