@majikah/majik-message 0.2.18 → 0.2.20

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.
@@ -28,6 +28,10 @@ export declare class MajikContactDirectory {
28
28
  blockContact(id: string): MajikContact;
29
29
  unblockContact(id: string): MajikContact;
30
30
  hasContact(id: string): boolean;
31
+ /**
32
+ * Checks if a contact exists by their public key (base64)
33
+ */
34
+ hasContactByPublicKeyBase64(publicKeyBase64: string): Promise<boolean>;
31
35
  clear(): this;
32
36
  setMajikahStatus(id: string, status: boolean): MajikContact;
33
37
  isMajikahIdentityChecked(id: string): boolean;
@@ -131,6 +131,16 @@ export class MajikContactDirectory {
131
131
  hasContact(id) {
132
132
  return this.contacts.has(id);
133
133
  }
134
+ /**
135
+ * Checks if a contact exists by their public key (base64)
136
+ */
137
+ async hasContactByPublicKeyBase64(publicKeyBase64) {
138
+ if (!publicKeyBase64 || typeof publicKeyBase64 !== "string") {
139
+ throw new MajikContactDirectoryError("Public key must be a non-empty base64 string");
140
+ }
141
+ const contact = await this.getContactByPublicKeyBase64(publicKeyBase64);
142
+ return contact !== undefined;
143
+ }
134
144
  clear() {
135
145
  this.contacts.clear();
136
146
  this.fingerprintMap.clear();
@@ -197,10 +197,7 @@ export class MajikMessage {
197
197
  throw new Error("Account with the same ID already exists");
198
198
  }
199
199
  const keyContact = key.toContact();
200
- const contactJSON = await keyContact.toJSON();
201
- const reParsedContact = MajikContact.fromJSON(contactJSON);
202
- console.log("Account: ", key);
203
- this.addOwnAccount(reParsedContact);
200
+ this.addOwnAccount(keyContact);
204
201
  return { id: key.id, fingerprint: key.fingerprint };
205
202
  }
206
203
  /**
@@ -209,9 +206,8 @@ export class MajikMessage {
209
206
  async createAccountFromMnemonic(mnemonic, passphrase, label) {
210
207
  const key = await MajikKey.create(mnemonic, passphrase, label);
211
208
  await MajikKeyStore.addMajikKey(key);
212
- const keyContact = await key.toContact().toJSON();
213
- const reParsedContact = MajikContact.fromJSON(keyContact);
214
- this.addOwnAccount(reParsedContact);
209
+ const keyContact = key.toContact();
210
+ this.addOwnAccount(keyContact);
215
211
  return { id: key.id, fingerprint: key.fingerprint, backup: key.backup };
216
212
  }
217
213
  addOwnAccount(account) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@majikah/majik-message",
3
3
  "type": "module",
4
4
  "description": "Post-quantum end-to-end encryption with ML-KEM-768. Seed phrase–based accounts. Auto-expiring messages. Offline-ready. Exportable encrypted messages. Tamper-proof threads with blockchain-like integrity. Quantum-resistant messaging.",
5
- "version": "0.2.18",
5
+ "version": "0.2.20",
6
6
  "license": "Apache-2.0",
7
7
  "author": "Zelijah",
8
8
  "main": "./dist/index.js",
@@ -82,9 +82,9 @@
82
82
  "@bokuweb/zstd-wasm": "^0.0.27",
83
83
  "@majikah/majik-contact": "^0.0.1",
84
84
  "@majikah/majik-envelope": "^0.0.1",
85
- "@majikah/majik-file": "^0.0.22",
86
- "@majikah/majik-key": "^0.2.3",
87
- "@majikah/majik-signature": "^0.0.15",
85
+ "@majikah/majik-file": "^0.0.23",
86
+ "@majikah/majik-key": "^0.2.4",
87
+ "@majikah/majik-signature": "^0.0.16",
88
88
  "@noble/hashes": "^2.0.1",
89
89
  "@noble/post-quantum": "^0.5.4",
90
90
  "@scure/bip39": "^1.6.0",