@majikah/majik-message 0.3.8 → 0.3.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.
|
@@ -2,7 +2,7 @@ import { MajikMessageChatJSON } from "../../database/chat/types";
|
|
|
2
2
|
import { SQLiteDatabase } from "../sql-db-manager";
|
|
3
3
|
import { StorageSource } from "../storage-adapter";
|
|
4
4
|
import { MajikMessageChatStorageAdapter } from "./_types";
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class SQLiteMessageChatsAdapter implements MajikMessageChatStorageAdapter {
|
|
6
6
|
private db;
|
|
7
7
|
constructor(db: SQLiteDatabase);
|
|
8
8
|
save(message: MajikMessageChatJSON, source?: StorageSource): Promise<void>;
|
package/dist/majik-message.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ import { MajikFile, MajikFileJSON } from "@majikah/majik-file";
|
|
|
10
10
|
import { EnvelopeInfo, ExpectedSigner, MajikSignature, SealInfo, SealVerificationResult, SignatoriesFilter, SignatoriesResult, SignatoryInfo, type MajikSignatureJSON, type MajikSignerPublicKeys, type VerificationResult } from "@majikah/majik-signature";
|
|
11
11
|
import { MajikContactManager, MajikContactManagerAdapters } from "./core/contacts/majik-contact-manager";
|
|
12
12
|
import { MajikContactManagerJSON } from "./core/contacts/types";
|
|
13
|
-
import { ClientStateStorageAdapter, MajikKeyStorageAdapter, SQLiteDatabase } from "./core/storage";
|
|
13
|
+
import { ClientStateStorageAdapter, MajikKeyStorageAdapter, MajikMessageChatStorageAdapter, SQLiteDatabase } from "./core/storage";
|
|
14
14
|
import { MajikKeyManager } from "./core/crypto/keystore-manager";
|
|
15
15
|
import { ClientStateManager } from "./core/client-state-manager";
|
|
16
|
-
type MajikMessageEvents = "
|
|
16
|
+
type MajikMessageEvents = "new-account" | "removed-account" | "active-account-change" | "unlock" | "lock" | "new-contact" | "removed-contact" | "new-contact-group" | "removed-contact-group" | "contact-group-change" | "message" | "envelope" | "untrusted" | "error";
|
|
17
17
|
export interface MajikMessageConfig {
|
|
18
18
|
dbSQL?: SQLiteDatabase;
|
|
19
19
|
/**
|
|
@@ -36,6 +36,7 @@ export interface MajikMessageConfig {
|
|
|
36
36
|
adapters?: {
|
|
37
37
|
contacts?: MajikContactManagerAdapters;
|
|
38
38
|
keys?: MajikKeyStorageAdapter;
|
|
39
|
+
chats?: MajikMessageChatStorageAdapter;
|
|
39
40
|
/**
|
|
40
41
|
* Adapter for client-level state (account order, invoice defaults, etc.).
|
|
41
42
|
* Defaults to IDB_ADAPTER_CLIENT_STATE in browser environments.
|
|
@@ -147,6 +148,10 @@ export declare class MajikMessage {
|
|
|
147
148
|
getActiveAccountKey(): MajikKey | null;
|
|
148
149
|
isAccountActive(id: string): boolean;
|
|
149
150
|
setActiveAccount(id: string, bypassIdentity?: boolean): Promise<boolean>;
|
|
151
|
+
unlockAccount(id: string, passphrase: string): Promise<void>;
|
|
152
|
+
lockAccount(id: string): void;
|
|
153
|
+
lockAllAccounts(): void;
|
|
154
|
+
verifyPassphrase(id: string, passphrase: string): Promise<boolean>;
|
|
150
155
|
listOwnAccounts(majikahOnly?: boolean): MajikContact[];
|
|
151
156
|
isContactMajikahRegistered(id: string): boolean;
|
|
152
157
|
isContactMajikahIdentityChecked(id: string): boolean;
|
package/dist/majik-message.js
CHANGED
|
@@ -40,22 +40,26 @@ export class MajikMessage {
|
|
|
40
40
|
this._keys =
|
|
41
41
|
config.keyManager ??
|
|
42
42
|
new MajikKeyManager(config.adapters?.keys ?? new InMemoryKeystoreAdapter());
|
|
43
|
+
// this._chats =
|
|
44
|
+
// config.
|
|
43
45
|
this._state =
|
|
44
46
|
config.clientStateManager ??
|
|
45
47
|
new ClientStateManager(config.adapters?.clientState ?? new InMemoryClientStateAdapter());
|
|
46
48
|
const events = [
|
|
47
|
-
"message",
|
|
48
|
-
"envelope",
|
|
49
|
-
"untrusted",
|
|
50
|
-
"error",
|
|
51
49
|
"new-account",
|
|
52
|
-
"new-contact",
|
|
53
|
-
"new-contact-group",
|
|
54
50
|
"removed-account",
|
|
51
|
+
"active-account-change",
|
|
52
|
+
"unlock",
|
|
53
|
+
"lock",
|
|
54
|
+
"new-contact",
|
|
55
55
|
"removed-contact",
|
|
56
|
+
"new-contact-group",
|
|
56
57
|
"removed-contact-group",
|
|
57
58
|
"contact-group-change",
|
|
58
|
-
"
|
|
59
|
+
"message",
|
|
60
|
+
"envelope",
|
|
61
|
+
"untrusted",
|
|
62
|
+
"error",
|
|
59
63
|
];
|
|
60
64
|
events.forEach((e) => this._listeners.set(e, []));
|
|
61
65
|
}
|
|
@@ -373,6 +377,28 @@ export class MajikMessage {
|
|
|
373
377
|
}
|
|
374
378
|
return true;
|
|
375
379
|
}
|
|
380
|
+
async unlockAccount(id, passphrase) {
|
|
381
|
+
try {
|
|
382
|
+
await this._keys.unlock(id, passphrase);
|
|
383
|
+
this._emit("unlock", id);
|
|
384
|
+
}
|
|
385
|
+
catch (err) {
|
|
386
|
+
this._emit("error", err, { context: "unlockAccount", id });
|
|
387
|
+
throw err;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
lockAccount(id) {
|
|
391
|
+
this._keys.lock(id);
|
|
392
|
+
this._emit("lock", id);
|
|
393
|
+
}
|
|
394
|
+
lockAllAccounts() {
|
|
395
|
+
this._keys.lockAll();
|
|
396
|
+
for (const id of this._ownAccountsOrder)
|
|
397
|
+
this._emit("lock", id);
|
|
398
|
+
}
|
|
399
|
+
async verifyPassphrase(id, passphrase) {
|
|
400
|
+
return this._keys.isPassphraseValid(id, passphrase);
|
|
401
|
+
}
|
|
376
402
|
listOwnAccounts(majikahOnly = false) {
|
|
377
403
|
let accounts = this._ownAccountsOrder
|
|
378
404
|
.map((id) => this._ownAccounts.get(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.
|
|
5
|
+
"version": "0.3.10",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Zelijah",
|
|
8
8
|
"main": "./dist/index.js",
|