@majikah/majik-message 0.3.2 → 0.3.4

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.
@@ -61,7 +61,7 @@ export declare class MajikContactGroupManager {
61
61
  * Updates mutable metadata fields on a group.
62
62
  * Name is protected on system groups (delegates to MajikContactGroup.updateName which throws).
63
63
  */
64
- updateGroupMeta(id: string, meta: Partial<Pick<MajikContactGroupMeta, "name" | "description">>): MajikContactGroup;
64
+ updateGroupMeta(id: string, meta: Partial<Pick<MajikContactGroupMeta, "name" | "description" | "color">>): MajikContactGroup;
65
65
  /**
66
66
  * Adds a contact to a group.
67
67
  *
@@ -157,6 +157,7 @@ export class MajikContactGroupManager {
157
157
  group.updateName(meta.name);
158
158
  if (meta.description !== undefined)
159
159
  group.updateDescription(meta.description);
160
+ group.setColor(meta?.color || group.meta?.color);
160
161
  return group;
161
162
  }
162
163
  /* ================================
@@ -120,7 +120,7 @@ export declare class MajikContactManager {
120
120
  * Updates mutable metadata on a group (name, description).
121
121
  * Name is locked on system groups — will throw if attempted.
122
122
  */
123
- updateGroupMeta(id: string, meta: Partial<Pick<MajikContactGroupMeta, "name" | "description">>): MajikContactGroup;
123
+ updateGroupMeta(id: string, meta: Partial<Pick<MajikContactGroupMeta, "name" | "description" | "color">>): MajikContactGroup;
124
124
  /**
125
125
  * Adds a contact to a group.
126
126
  * Validates the contact exists in the directory.
@@ -225,12 +225,8 @@ export declare class MajikContactManager {
225
225
  * between directory and group state across serialization rounds
226
226
  *
227
227
  * @param data The payload produced by toJSON().
228
- * @param KEY_ALGO The WebCrypto algorithm descriptor used to import
229
- * public keys — passed through to the directory's fromJSON.
230
228
  */
231
- static fromJSON(data: MajikContactManagerJSON, KEY_ALGO: KeyAlgorithm | EcKeyImportParams | {
232
- name: string;
233
- }): Promise<MajikContactManager>;
229
+ static fromJSON(data: MajikContactManagerJSON): Promise<MajikContactManager>;
234
230
  /**
235
231
  * Walks every group and removes any member ID not present in the directory.
236
232
  * Operates directly on the group instances — no re-serialization needed.
@@ -382,10 +382,8 @@ export class MajikContactManager {
382
382
  * between directory and group state across serialization rounds
383
383
  *
384
384
  * @param data The payload produced by toJSON().
385
- * @param KEY_ALGO The WebCrypto algorithm descriptor used to import
386
- * public keys — passed through to the directory's fromJSON.
387
385
  */
388
- static async fromJSON(data, KEY_ALGO) {
386
+ static async fromJSON(data) {
389
387
  if (!data || typeof data !== "object") {
390
388
  throw new MajikContactManagerError("fromJSON: invalid payload — expected { contacts, groups }");
391
389
  }
@@ -172,7 +172,7 @@ export declare class MajikMessage {
172
172
  * Updates mutable metadata on a group (name, description).
173
173
  * Name is locked on system groups — will throw if attempted.
174
174
  */
175
- updateGroupMeta(id: string, meta: Partial<Pick<MajikContactGroupMeta, "name" | "description">>): this;
175
+ updateGroupMeta(id: string, meta: Partial<Pick<MajikContactGroupMeta, "name" | "description" | "color">>): this;
176
176
  /**
177
177
  * Adds a contact to a group.
178
178
  * Validates the contact exists in the directory.
@@ -690,7 +690,6 @@ export declare class MajikMessage {
690
690
  on(event: MajikMessageEvents, callback: EventCallback): void;
691
691
  off(event: MajikMessageEvents, callback?: EventCallback): void;
692
692
  private emit;
693
- private handleEnvelope;
694
693
  /**
695
694
  * Sign raw bytes or a string using the active account.
696
695
  *
@@ -1497,54 +1497,6 @@ export class MajikMessage {
1497
1497
  emit(event, ...args) {
1498
1498
  this.listeners.get(event)?.forEach((cb) => cb(...args));
1499
1499
  }
1500
- // ── Private: Envelope Handler (Scanner) ───────────────────────────────────
1501
- async handleEnvelope(envelope) {
1502
- const cached = await this.envelopeCache.get(envelope);
1503
- if (cached)
1504
- return;
1505
- let majikEnvelope;
1506
- try {
1507
- majikEnvelope = MajikEnvelope.fromBinary(envelope.raw);
1508
- }
1509
- catch {
1510
- this.emit("untrusted", envelope);
1511
- return;
1512
- }
1513
- if (majikEnvelope.isGroup) {
1514
- for (const account of this.listOwnAccounts()) {
1515
- try {
1516
- const identity = await this._resolveIdentity(account.id);
1517
- const plaintext = await majikEnvelope.decrypt(identity);
1518
- await this.envelopeCache.set(envelope, this._source);
1519
- this.scheduleAutosave();
1520
- this.emit("message", plaintext, envelope, account);
1521
- return;
1522
- }
1523
- catch {
1524
- continue;
1525
- }
1526
- }
1527
- this.emit("untrusted", envelope);
1528
- }
1529
- else {
1530
- const fingerprint = envelope.extractFingerprint();
1531
- const account = this.listOwnAccounts().find((a) => a.fingerprint === fingerprint);
1532
- if (!account) {
1533
- this.emit("untrusted", envelope);
1534
- return;
1535
- }
1536
- try {
1537
- const identity = await this._resolveIdentity(account.id);
1538
- const plaintext = await majikEnvelope.decrypt(identity);
1539
- await this.envelopeCache.set(envelope, this._source);
1540
- this.scheduleAutosave();
1541
- this.emit("message", plaintext, envelope, account);
1542
- }
1543
- catch (err) {
1544
- this.emit("error", err, { envelope });
1545
- }
1546
- }
1547
- }
1548
1500
  // ── Content & File Signing ────────────────────────────────────────────────
1549
1501
  /**
1550
1502
  * Sign raw bytes or a string using the active account.
@@ -2309,7 +2261,7 @@ export class MajikMessage {
2309
2261
  static async fromJSON(json) {
2310
2262
  // const migratedJSON = migrateMajikMessageJSON(json);
2311
2263
  // ── Step 2: restore MajikContactManager (directory + groups together) ─
2312
- const contactManager = await MajikContactManager.fromJSON(json.contacts, KEY_ALGO);
2264
+ const contactManager = await MajikContactManager.fromJSON(json.contacts);
2313
2265
  const envelopeCache = EnvelopeCache.fromJSON(json.envelopeCache);
2314
2266
  const instance = new this({ contactManager, envelopeCache }, json.id);
2315
2267
  try {
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.3.2",
5
+ "version": "0.3.4",
6
6
  "license": "Apache-2.0",
7
7
  "author": "Zelijah",
8
8
  "main": "./dist/index.js",