@majikah/majik-message 0.3.10 → 0.3.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.
@@ -56,7 +56,6 @@ export interface MajikMessageJSON {
56
56
  }
57
57
  type EventCallback = (...args: any[]) => void;
58
58
  export declare class MajikMessage {
59
- private readonly _id;
60
59
  private _db;
61
60
  private _contacts;
62
61
  private _keys;
@@ -158,6 +157,8 @@ export declare class MajikMessage {
158
157
  setContactMajikahStatus(id: string, status: boolean): void;
159
158
  hasOwnIdentity(fingerprint: string): Promise<boolean>;
160
159
  getContactByID(id: string): MajikContact | null;
160
+ hasContact(id: string): boolean;
161
+ hasContactByPublicKeyBase64(publicKey: MajikMessagePublicKey): Promise<boolean>;
161
162
  getContactByPublicKey(publicKeyBase64: string): Promise<MajikContact | null>;
162
163
  getContactsByID(ids: string[], strict?: boolean): MajikContact[];
163
164
  getContactsByPublicKey(publicKeys: string[]): Promise<MajikContact[]>;
@@ -171,7 +172,7 @@ export declare class MajikMessage {
171
172
  importContactCompressed(base64Str: string): Promise<MajikContact>;
172
173
  addContact(contact: MajikContact): Promise<void>;
173
174
  removeContact(id: string): Promise<void>;
174
- listContacts(includeOwnAccounts?: boolean): MajikContact[];
175
+ listContacts(includeOwnAccounts?: boolean, majikahOnly?: boolean): MajikContact[];
175
176
  updateContactMeta(id: string, meta: Partial<MajikContactMeta>): Promise<void>;
176
177
  createGroup(id: string, name: string, meta?: Partial<Omit<MajikContactGroupMeta, "name">>, initialMemberIds?: string[]): Promise<this>;
177
178
  addGroup(group: MajikContactGroup): Promise<this>;
@@ -1,8 +1,7 @@
1
1
  // MajikMessage.ts
2
2
  import { MessageEnvelope } from "./core/messages/message-envelope";
3
3
  import { EnvelopeCache, } from "./core/messages/envelope-cache";
4
- import { arrayToBase64, base64ToUint8Array } from "./core/utils/utilities";
5
- import { randomBytes } from "@stablelib/random";
4
+ import { base64ToUint8Array } from "./core/utils/utilities";
6
5
  import { MajikMessageChat } from "./core/database/chat/majik-message-chat";
7
6
  import { MajikKey } from "@majikah/majik-key";
8
7
  import { MajikEnvelope, } from "@majikah/majik-envelope";
@@ -14,7 +13,6 @@ import { MajikKeyManager } from "./core/crypto/keystore-manager";
14
13
  import { ClientStateManager } from "./core/client-state-manager";
15
14
  // ─── MajikMessage ─────────────────────────────────────────────────────────────
16
15
  export class MajikMessage {
17
- _id;
18
16
  _db;
19
17
  _contacts;
20
18
  _keys;
@@ -31,7 +29,6 @@ export class MajikMessage {
31
29
  _ownAccountsOrder = [];
32
30
  _autosaveOrderTimer = null;
33
31
  constructor(config, id) {
34
- this._id = id || arrayToBase64(randomBytes(32));
35
32
  this._db = config.dbSQL || null;
36
33
  this.envelopeCache = config.envelopeCache || new EnvelopeCache(undefined);
37
34
  this._contacts =
@@ -428,6 +425,16 @@ export class MajikMessage {
428
425
  throw new Error("Invalid contact ID");
429
426
  return this._contacts.getContact(id) ?? null;
430
427
  }
428
+ hasContact(id) {
429
+ if (!id?.trim())
430
+ throw new Error("Invalid contact ID");
431
+ return this._contacts.hasContact(id);
432
+ }
433
+ async hasContactByPublicKeyBase64(publicKey) {
434
+ if (!publicKey?.trim())
435
+ throw new Error("Invalid contact public key");
436
+ return await this._contacts.hasContactByPublicKeyBase64(publicKey);
437
+ }
431
438
  async getContactByPublicKey(publicKeyBase64) {
432
439
  if (!publicKeyBase64?.trim())
433
440
  throw new Error("Invalid public key");
@@ -503,8 +510,8 @@ export class MajikMessage {
503
510
  throw new Error(result.message);
504
511
  this._emit("removed-contact", id);
505
512
  }
506
- listContacts(includeOwnAccounts = false) {
507
- const contacts = this._contacts.listContacts(true);
513
+ listContacts(includeOwnAccounts = false, majikahOnly = false) {
514
+ const contacts = this._contacts.listContacts(true, majikahOnly);
508
515
  if (includeOwnAccounts)
509
516
  return contacts;
510
517
  const ownIds = new Set(this.listOwnAccounts().map((a) => a.id));
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.10",
5
+ "version": "0.3.11",
6
6
  "license": "Apache-2.0",
7
7
  "author": "Zelijah",
8
8
  "main": "./dist/index.js",