@majikah/majik-signature-client 0.6.4 → 0.6.6
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/storage/client-state/_types.d.ts +1 -8
- package/dist/core/storage/client-state/_types.js +2 -1
- package/dist/core/storage/client-state/adapter-idb.d.ts +1 -1
- package/dist/core/storage/client-state/adapter-memory.d.ts +2 -1
- package/dist/core/storage/client-state/adapter-sql.d.ts +2 -1
- package/dist/majik-signature-client.d.ts +7 -1
- package/dist/majik-signature-client.js +19 -10
- package/package.json +1 -1
|
@@ -7,15 +7,8 @@
|
|
|
7
7
|
* ClientStateManager owns all serialisation / deserialisation logic; the
|
|
8
8
|
* adapter only moves bytes.
|
|
9
9
|
*/
|
|
10
|
+
import { ClientStateEntry } from "@majikah/majik-key-client";
|
|
10
11
|
import { MajikStorageAdapter } from "../storage-adapter";
|
|
11
|
-
export interface ClientStateEntry {
|
|
12
|
-
/** Stable string key that identifies this piece of state. */
|
|
13
|
-
id: string;
|
|
14
|
-
/** JSON-serialised value. Always a string on the wire / in storage. */
|
|
15
|
-
value: string;
|
|
16
|
-
/** ISO 8601 datetime — set by the adapter on every write where supported. */
|
|
17
|
-
updatedAt?: string;
|
|
18
|
-
}
|
|
19
12
|
export declare const CLIENT_STATE_KEYS: {
|
|
20
13
|
readonly ACCOUNT_ORDER: "user_account_order";
|
|
21
14
|
readonly USER_APP_PREFERENCES: "user_app_preferences";
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* ClientStateManager owns all serialisation / deserialisation logic; the
|
|
8
8
|
* adapter only moves bytes.
|
|
9
9
|
*/
|
|
10
|
+
import { BASE_CLIENT_STATE_KEYS } from "@majikah/majik-key-client";
|
|
10
11
|
// ---------------------------------------------------------------------------
|
|
11
12
|
// Well-known state keys
|
|
12
13
|
// ---------------------------------------------------------------------------
|
|
13
14
|
export const CLIENT_STATE_KEYS = {
|
|
14
|
-
|
|
15
|
+
...BASE_CLIENT_STATE_KEYS,
|
|
15
16
|
USER_APP_PREFERENCES: "user_app_preferences",
|
|
16
17
|
};
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
* Each entry is stored with `id` as the keyPath — identical to the invoice
|
|
13
13
|
* and contact adapters.
|
|
14
14
|
*/
|
|
15
|
-
import type { ClientStateEntry } from "
|
|
15
|
+
import type { ClientStateEntry } from "@majikah/majik-key-client";
|
|
16
16
|
import { IDBGenericAdapter } from "../idb-adapter";
|
|
17
17
|
export declare const IDB_ADAPTER_CLIENT_STATE: IDBGenericAdapter<ClientStateEntry>;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* Default adapter — zero-config, non-persistent. State is lost on page reload
|
|
6
6
|
* or process restart. Useful for tests, SSR, and headless environments.
|
|
7
7
|
*/
|
|
8
|
-
import type { ClientStateEntry
|
|
8
|
+
import type { ClientStateEntry } from "@majikah/majik-key-client";
|
|
9
|
+
import type { ClientStateStorageAdapter } from "./_types";
|
|
9
10
|
export declare class InMemoryClientStateAdapter implements ClientStateStorageAdapter {
|
|
10
11
|
private _store;
|
|
11
12
|
save(entry: ClientStateEntry): Promise<void>;
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
* needed) and mapped to the `id` field of ClientStateEntry in TypeScript so
|
|
18
18
|
* the adapter contract is identical to the IDB and memory variants.
|
|
19
19
|
*/
|
|
20
|
-
import type {
|
|
20
|
+
import type { ClientStateStorageAdapter } from "./_types";
|
|
21
21
|
import type { SQLiteDatabase } from "../sql-db-manager";
|
|
22
|
+
import type { ClientStateEntry } from "@majikah/majik-key-client";
|
|
22
23
|
/** DDL — pass to your migration runner or call createSchema() directly. */
|
|
23
24
|
export declare const MAJIK_CLIENT_STATE_SCHEMA: string;
|
|
24
25
|
export declare class SQLiteClientStateAdapter implements ClientStateStorageAdapter {
|
|
@@ -23,7 +23,7 @@ import { MajikContactManager, MajikContactManagerAdapters } from "./core/contact
|
|
|
23
23
|
import { MajikContactManagerJSON } from "./core/contacts/types";
|
|
24
24
|
import { MajikContact, MajikContactGroup, MajikContactGroupMeta, MajikContactMeta, SerializedMajikContact } from "@majikah/majik-contact";
|
|
25
25
|
import { ClientStateManager } from "./core/client-state-manager";
|
|
26
|
-
import { MajikSignatureStampStorageAdapter, UserAppPreferences } from "./core/storage";
|
|
26
|
+
import { ClientStateStorageAdapter, MajikSignatureStampStorageAdapter, UserAppPreferences } from "./core/storage";
|
|
27
27
|
import { AppDataSnapshot, ContactManagerSnapshot } from "./core/backup/types";
|
|
28
28
|
import { MajikSignatureStampManager } from "./core/stamp/majik-signature-stamp-manager";
|
|
29
29
|
import { MajikSignatureStamp, MajikSignatureStampJSON, StampAssetKind } from "./core/stamp/majik-signature-stamp";
|
|
@@ -60,6 +60,12 @@ export declare class MajikSignatureClient extends MajikKeyClient<MajikContact, M
|
|
|
60
60
|
private _contacts;
|
|
61
61
|
private _stamps;
|
|
62
62
|
constructor(config: MajikSignatureClientConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Override — without this, MajikKeyClient's constructor falls back to
|
|
65
|
+
* building a plain MajikKeyClientStateManager (ACCOUNT_ORDER only),
|
|
66
|
+
* and every call to getUserAppPreferences() etc. throws at runtime.
|
|
67
|
+
*/
|
|
68
|
+
protected _createDefaultStateManager(adapter?: ClientStateStorageAdapter): ClientStateManager;
|
|
63
69
|
/** Expose the stamp manager for direct access if needed. */
|
|
64
70
|
get stampManager(): MajikSignatureStampManager;
|
|
65
71
|
protected _buildOwnAccountContact(key: MajikKey, meta?: Partial<MajikContactMeta>): MajikContact;
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
import { MajikSignature } from "@majikah/majik-signature";
|
|
18
18
|
import { base64ToUint8Array } from "./core/utils/utilities";
|
|
19
19
|
import { MajikContactManager, } from "./core/contacts/majik-contact-manager";
|
|
20
|
-
import {
|
|
20
|
+
import { ClientStateManager } from "./core/client-state-manager";
|
|
21
|
+
import { InMemoryClientStateAdapter, InMemoryStampstoreAdapter, } from "./core/storage";
|
|
21
22
|
import { MajikCompressedJSON } from "@majikah/majik-cjson";
|
|
22
23
|
import { prependMagic, readBackupBlob } from "./core/backup/utils";
|
|
23
24
|
import { MAJIK_SIGNATURE_BACKUP_MAGIC, MAJIK_MESSAGE_BACKUP_MAGIC_SIZE, } from "./core/backup/constants";
|
|
@@ -50,6 +51,14 @@ export class MajikSignatureClient extends MajikKeyClient {
|
|
|
50
51
|
"contact-group-change",
|
|
51
52
|
]);
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Override — without this, MajikKeyClient's constructor falls back to
|
|
56
|
+
* building a plain MajikKeyClientStateManager (ACCOUNT_ORDER only),
|
|
57
|
+
* and every call to getUserAppPreferences() etc. throws at runtime.
|
|
58
|
+
*/
|
|
59
|
+
_createDefaultStateManager(adapter) {
|
|
60
|
+
return new ClientStateManager(adapter ?? new InMemoryClientStateAdapter());
|
|
61
|
+
}
|
|
53
62
|
/** Expose the stamp manager for direct access if needed. */
|
|
54
63
|
get stampManager() {
|
|
55
64
|
return this._stamps;
|
|
@@ -110,44 +119,44 @@ export class MajikSignatureClient extends MajikKeyClient {
|
|
|
110
119
|
* Retrieve persisted user app prefernces, or `null` if none have been saved.
|
|
111
120
|
*/
|
|
112
121
|
async getUserAppPreferences() {
|
|
113
|
-
return this.
|
|
122
|
+
return this.stateManager.getUserAppPreferences();
|
|
114
123
|
}
|
|
115
124
|
/**
|
|
116
125
|
* Persist user app prefernces.
|
|
117
126
|
*/
|
|
118
127
|
async setUserAppPreferences(preferences) {
|
|
119
|
-
await this.
|
|
128
|
+
await this.stateManager.setUserAppPreferences(preferences);
|
|
120
129
|
}
|
|
121
130
|
/**
|
|
122
131
|
* Remove persisted user app prefernces.
|
|
123
132
|
*/
|
|
124
133
|
async removeUserAppPreferences() {
|
|
125
|
-
await this.
|
|
134
|
+
await this.stateManager.removeUserAppPreferences();
|
|
126
135
|
}
|
|
127
136
|
/**
|
|
128
137
|
* Reset persisted user app prefernces to default settings.
|
|
129
138
|
*/
|
|
130
139
|
async resetUserAppPreferences() {
|
|
131
|
-
await this.
|
|
140
|
+
await this.stateManager.resetUserAppPreferences();
|
|
132
141
|
}
|
|
133
142
|
async isAnalyticsEnabled() {
|
|
134
|
-
const appPreferences = await this.
|
|
143
|
+
const appPreferences = await this.stateManager.getUserAppPreferences();
|
|
135
144
|
return appPreferences.privacy.shareAnalytics ?? false;
|
|
136
145
|
}
|
|
137
146
|
async isAutoSealEnabled() {
|
|
138
|
-
const appPreferences = await this.
|
|
147
|
+
const appPreferences = await this.stateManager.getUserAppPreferences();
|
|
139
148
|
return appPreferences.signing.autoSeal ?? false;
|
|
140
149
|
}
|
|
141
150
|
async isAutoLockOnMinimizeEnabled() {
|
|
142
|
-
const appPreferences = await this.
|
|
151
|
+
const appPreferences = await this.stateManager.getUserAppPreferences();
|
|
143
152
|
return appPreferences.security?.key?.autoLockOnMinimize ?? false;
|
|
144
153
|
}
|
|
145
154
|
async autoLockInterval() {
|
|
146
|
-
const appPreferences = await this.
|
|
155
|
+
const appPreferences = await this.stateManager.getUserAppPreferences();
|
|
147
156
|
return appPreferences.security?.key?.autoLockInterval;
|
|
148
157
|
}
|
|
149
158
|
async isOnetimeUnlockEnabled() {
|
|
150
|
-
const appPreferences = await this.
|
|
159
|
+
const appPreferences = await this.stateManager.getUserAppPreferences();
|
|
151
160
|
return appPreferences.security?.key?.onetimeUnlock ?? true;
|
|
152
161
|
}
|
|
153
162
|
// ==========================================================================
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@majikah/majik-signature-client",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Majik Signature Client is a hybrid post-quantum content signing and verification library for the Majikah ecosystem. Built on top of Majik Key Client, it provides tamper-proof, forgery-resistant digital signatures for any content format — using a dual-algorithm architecture that combines classical Ed25519 with post-quantum ML-DSA-87 (FIPS-204).",
|
|
5
|
-
"version": "0.6.
|
|
5
|
+
"version": "0.6.6",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Zelijah",
|
|
8
8
|
"main": "./dist/index.js",
|