@majikah/majik-message 0.2.9 → 0.2.11

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.
@@ -27,6 +27,12 @@ export class MajikContactDirectory {
27
27
  * Contact Management
28
28
  * ================================ */
29
29
  addContact(contact) {
30
+ if (!contact?.id ||
31
+ !contact?.publicKey ||
32
+ !contact?.fingerprint ||
33
+ !contact?.mlKey) {
34
+ throw new MajikContactDirectoryError("Invalid contact");
35
+ }
30
36
  if (!(contact instanceof MajikContact)) {
31
37
  throw new MajikContactDirectoryError("Invalid contact instance");
32
38
  }
@@ -328,6 +328,8 @@ export class MajikMessage {
328
328
  publicKey: publicKeyBase64,
329
329
  fingerprint: contact.fingerprint,
330
330
  mlKey: contact.mlKey,
331
+ edPublicKeyBase64: contact.edPublicKeyBase64,
332
+ mlDsaPublicKeyBase64: contact.mlDsaPublicKeyBase64,
331
333
  }, null, 2);
332
334
  }
333
335
  async exportContactAsString(contactId) {
@@ -357,6 +359,8 @@ export class MajikMessage {
357
359
  fingerprint: data.fingerprint,
358
360
  meta: { label: data.label },
359
361
  mlKey: data.mlKey,
362
+ edPublicKeyBase64: data.edPublicKeyBase64,
363
+ mlDsaPublicKeyBase64: data.mlDsaPublicKeyBase64,
360
364
  }));
361
365
  return { success: true, message: "Contact imported successfully" };
362
366
  }
@@ -397,6 +401,8 @@ export class MajikMessage {
397
401
  publicKey: publicKeyBase64,
398
402
  fingerprint: contact.fingerprint,
399
403
  mlKey: contact.mlKey,
404
+ edPublicKeyBase64: contact.edPublicKeyBase64,
405
+ mlDsaPublicKeyBase64: contact.mlDsaPublicKeyBase64,
400
406
  };
401
407
  const jsonStr = JSON.stringify(jsonObj);
402
408
  const utf8 = new TextEncoder().encode(jsonStr);
@@ -418,15 +424,26 @@ export class MajikMessage {
418
424
  catch {
419
425
  publicKey = { raw: new Uint8Array(rawBuffer) };
420
426
  }
427
+ if (!data?.id || !publicKey || !data?.fingerprint || !data?.mlKey) {
428
+ throw new Error("Invalid contact JSON");
429
+ }
421
430
  return new MajikContact({
422
431
  id: data.id,
423
432
  publicKey,
424
433
  fingerprint: data.fingerprint,
425
434
  meta: { label: data.label },
426
435
  mlKey: data.mlKey,
436
+ edPublicKeyBase64: data.edPublicKeyBase64,
437
+ mlDsaPublicKeyBase64: data.mlDsaPublicKeyBase64,
427
438
  });
428
439
  }
429
440
  addContact(contact) {
441
+ if (!contact?.id ||
442
+ !contact?.publicKey ||
443
+ !contact?.fingerprint ||
444
+ !contact?.mlKey) {
445
+ throw new Error("Invalid contact JSON");
446
+ }
430
447
  this.contactDirectory.addContact(contact);
431
448
  this.emit("new-contact", contact);
432
449
  this.scheduleAutosave();
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.9",
5
+ "version": "0.2.11",
6
6
  "license": "Apache-2.0",
7
7
  "author": "Zelijah",
8
8
  "main": "./dist/index.js",
@@ -81,9 +81,9 @@
81
81
  "dependencies": {
82
82
  "@bokuweb/zstd-wasm": "^0.0.27",
83
83
  "@majikah/majik-envelope": "^0.0.1",
84
- "@majikah/majik-file": "^0.0.19",
85
- "@majikah/majik-key": "^0.2.2",
86
- "@majikah/majik-signature": "^0.0.6",
84
+ "@majikah/majik-file": "^0.0.20",
85
+ "@majikah/majik-key": "^0.2.3",
86
+ "@majikah/majik-signature": "^0.0.10",
87
87
  "@noble/hashes": "^2.0.1",
88
88
  "@noble/post-quantum": "^0.5.4",
89
89
  "@scure/bip39": "^1.6.0",