@majikah/majik-message 0.2.8 → 0.2.10
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/dist/core/contacts/majik-contact-directory.js +6 -0
- package/dist/core/crypto/keystore.js +6 -6
- package/dist/core/messages/envelope-cache.d.ts +0 -1
- package/dist/core/messages/envelope-cache.js +2 -2
- package/dist/majik-message.d.ts +0 -5
- package/dist/majik-message.js +33 -21
- package/package.json +4 -4
|
@@ -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
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import { MajikKey } from "@majikah/majik-key";
|
|
9
|
-
import { base64ToArrayBuffer } from "../utils/utilities";
|
|
9
|
+
// import { base64ToArrayBuffer } from "../utils/utilities";
|
|
10
10
|
import { KDF_VERSION } from "./constants";
|
|
11
11
|
// ─── IDB Config ───────────────────────────────────────────────────────────────
|
|
12
12
|
const STORE_NAME = "majik-keys";
|
|
@@ -381,11 +381,11 @@ export class MajikKeyStore {
|
|
|
381
381
|
if (!si.id || !si.publicKey || !si.fingerprint) {
|
|
382
382
|
throw new MajikKeyStoreError("Invalid legacy SerializedIdentity: missing required fields");
|
|
383
383
|
}
|
|
384
|
-
// SerializedIdentity may or may not have encryptedPrivateKey
|
|
385
|
-
// (some records were stored without it — public-key-only contacts)
|
|
386
|
-
const encryptedPrivateKey = si.encryptedPrivateKey
|
|
387
|
-
|
|
388
|
-
|
|
384
|
+
// // SerializedIdentity may or may not have encryptedPrivateKey
|
|
385
|
+
// // (some records were stored without it — public-key-only contacts)
|
|
386
|
+
// const encryptedPrivateKey = si.encryptedPrivateKey
|
|
387
|
+
// ? base64ToArrayBuffer(si.encryptedPrivateKey)
|
|
388
|
+
// : new ArrayBuffer(0);
|
|
389
389
|
// Reconstruct as a minimal MajikKeyJSON (v1 PBKDF2, no ML-KEM)
|
|
390
390
|
const json = {
|
|
391
391
|
id: si.id,
|
|
@@ -15,7 +15,7 @@ export class EnvelopeCacheError extends Error {
|
|
|
15
15
|
* EnvelopeCache
|
|
16
16
|
* ------------------------------- */
|
|
17
17
|
export class EnvelopeCache {
|
|
18
|
-
userProfile = "default";
|
|
18
|
+
// private userProfile: string = "default";
|
|
19
19
|
dbPromise;
|
|
20
20
|
dbName;
|
|
21
21
|
storeName;
|
|
@@ -29,7 +29,7 @@ export class EnvelopeCache {
|
|
|
29
29
|
this.maxEntries = config?.maxEntries;
|
|
30
30
|
this.memoryCacheSize = config?.memoryCacheSize || 100;
|
|
31
31
|
this.memoryCache = new Map();
|
|
32
|
-
this.userProfile = userProfile || "default";
|
|
32
|
+
// this.userProfile = userProfile || "default";
|
|
33
33
|
this.dbPromise = this.initDB();
|
|
34
34
|
}
|
|
35
35
|
/* -------------------------------
|
package/dist/majik-message.d.ts
CHANGED
|
@@ -44,11 +44,6 @@ export declare class MajikMessage {
|
|
|
44
44
|
private readonly autosaveIntervalMs;
|
|
45
45
|
private readonly autosaveDebounceMs;
|
|
46
46
|
constructor(config: MajikMessageConfig, id?: string, userProfile?: string);
|
|
47
|
-
/**
|
|
48
|
-
* Resolve a list of account/contact IDs into MajikRecipient objects.
|
|
49
|
-
* Each recipient needs their ML-KEM public key from MajikKeyStore.
|
|
50
|
-
*/
|
|
51
|
-
private _resolveRecipients;
|
|
52
47
|
/**
|
|
53
48
|
* Resolve a list of account/contact IDs into MajikRecipient objects.
|
|
54
49
|
* Each recipient needs their ML-KEM public key from MajikKeyStore.
|
package/dist/majik-message.js
CHANGED
|
@@ -59,27 +59,30 @@ export class MajikMessage {
|
|
|
59
59
|
this.attachAutosaveHandlers();
|
|
60
60
|
}
|
|
61
61
|
// ── Private: Envelope helpers ────────────────────────────────────────────
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
async _resolveRecipients(ids) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
62
|
+
// /**
|
|
63
|
+
// * Resolve a list of account/contact IDs into MajikRecipient objects.
|
|
64
|
+
// * Each recipient needs their ML-KEM public key from MajikKeyStore.
|
|
65
|
+
// */
|
|
66
|
+
// private async _resolveRecipients(ids: string[]): Promise<MajikRecipient[]> {
|
|
67
|
+
// return Promise.all(
|
|
68
|
+
// ids.map(async (id) => {
|
|
69
|
+
// const contact = this.contactDirectory.getContact(id);
|
|
70
|
+
// if (!contact) throw new Error(`No contact found for id "${id}"`);
|
|
71
|
+
// // const key = await MajikKeyStore.load(id);
|
|
72
|
+
// const mlPubKey = base64ToUint8Array(contact.mlKey);
|
|
73
|
+
// if (!mlPubKey) {
|
|
74
|
+
// throw new Error(
|
|
75
|
+
// `Contact "${id}" has no ML-KEM public key. ` +
|
|
76
|
+
// `They may need to upgrade their account via importFromMnemonicBackup().`,
|
|
77
|
+
// );
|
|
78
|
+
// }
|
|
79
|
+
// return {
|
|
80
|
+
// fingerprint: contact.fingerprint,
|
|
81
|
+
// mlKemPublicKey: mlPubKey,
|
|
82
|
+
// } satisfies MajikRecipient;
|
|
83
|
+
// }),
|
|
84
|
+
// );
|
|
85
|
+
// }
|
|
83
86
|
/**
|
|
84
87
|
* Resolve a list of account/contact IDs into MajikRecipient objects.
|
|
85
88
|
* Each recipient needs their ML-KEM public key from MajikKeyStore.
|
|
@@ -415,6 +418,9 @@ export class MajikMessage {
|
|
|
415
418
|
catch {
|
|
416
419
|
publicKey = { raw: new Uint8Array(rawBuffer) };
|
|
417
420
|
}
|
|
421
|
+
if (!data?.id || !publicKey || !data?.fingerprint || !data?.mlKey) {
|
|
422
|
+
throw new Error("Invalid contact JSON");
|
|
423
|
+
}
|
|
418
424
|
return new MajikContact({
|
|
419
425
|
id: data.id,
|
|
420
426
|
publicKey,
|
|
@@ -424,6 +430,12 @@ export class MajikMessage {
|
|
|
424
430
|
});
|
|
425
431
|
}
|
|
426
432
|
addContact(contact) {
|
|
433
|
+
if (!contact?.id ||
|
|
434
|
+
!contact?.publicKey ||
|
|
435
|
+
!contact?.fingerprint ||
|
|
436
|
+
!contact?.mlKey) {
|
|
437
|
+
throw new Error("Invalid contact JSON");
|
|
438
|
+
}
|
|
427
439
|
this.contactDirectory.addContact(contact);
|
|
428
440
|
this.emit("new-contact", contact);
|
|
429
441
|
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.
|
|
5
|
+
"version": "0.2.10",
|
|
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.
|
|
85
|
-
"@majikah/majik-key": "^0.2.
|
|
86
|
-
"@majikah/majik-signature": "^0.0.
|
|
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",
|