@majikah/majik-message 0.2.19 → 0.2.21

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();
@@ -104,7 +104,8 @@ export declare class MajikMessage {
104
104
  updatePassphrase(currentPassphrase: string, newPassphrase: string, id?: string): Promise<void>;
105
105
  getContactByID(id: string): MajikContact | null;
106
106
  hasContact(id: string): boolean;
107
- getContactByPublicKey(publicKeyBase64: string): Promise<MajikContact | null>;
107
+ hasContactByPublicKeyBase64(publicKey: MajikMessagePublicKey): Promise<boolean>;
108
+ getContactByPublicKey(publicKeyBase64: MajikMessagePublicKey): Promise<MajikContact | null>;
108
109
  exportContactAsJSON(contactId: string): Promise<string | null>;
109
110
  exportContactAsString(contactId: string): Promise<string | null>;
110
111
  importContactFromJSON(jsonStr: string): Promise<MAJIK_API_RESPONSE>;
@@ -305,6 +305,11 @@ export class MajikMessage {
305
305
  throw new Error("Invalid contact ID");
306
306
  return this.contactDirectory.hasContact(id);
307
307
  }
308
+ async hasContactByPublicKeyBase64(publicKey) {
309
+ if (!publicKey?.trim())
310
+ throw new Error("Invalid contact public key");
311
+ return await this.contactDirectory.hasContactByPublicKeyBase64(publicKey);
312
+ }
308
313
  async getContactByPublicKey(publicKeyBase64) {
309
314
  if (!publicKeyBase64?.trim())
310
315
  throw new Error("Invalid public key");
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.19",
5
+ "version": "0.2.21",
6
6
  "license": "Apache-2.0",
7
7
  "author": "Zelijah",
8
8
  "main": "./dist/index.js",