@majikah/majik-signature-client 0.6.1 → 0.6.3
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.
|
@@ -136,7 +136,7 @@ export declare class MajikSignatureClient {
|
|
|
136
136
|
autoLockInterval(): Promise<number | undefined>;
|
|
137
137
|
isOnetimeUnlockEnabled(): Promise<boolean>;
|
|
138
138
|
generateMnemonic(strength?: 128 | 256, language?: MnemonicLanguage): Promise<string>;
|
|
139
|
-
createAccount(mnemonic: string, passphrase: string, label?: string): Promise<{
|
|
139
|
+
createAccount(mnemonic: string, passphrase: string, label?: string, mnemonicLanguage?: MnemonicLanguage): Promise<{
|
|
140
140
|
id: string;
|
|
141
141
|
fingerprint: string;
|
|
142
142
|
backup: string;
|
|
@@ -218,16 +218,6 @@ export declare class MajikSignatureClient {
|
|
|
218
218
|
getBlockedContacts(): MajikContact[];
|
|
219
219
|
clearDirectory(): Promise<this>;
|
|
220
220
|
resolveSignerLabel(signerId: string): string;
|
|
221
|
-
/**
|
|
222
|
-
* Sign content with the active account.
|
|
223
|
-
*
|
|
224
|
-
* The active account must be unlocked and have signing keys.
|
|
225
|
-
* Use unlockAccount() first if needed.
|
|
226
|
-
*
|
|
227
|
-
* @param content - Raw bytes or UTF-8 string to sign
|
|
228
|
-
* @param options - Optional content type and timestamp override
|
|
229
|
-
* @param accountId - Override which account signs. Defaults to active account.
|
|
230
|
-
*/
|
|
231
221
|
sign(content: Uint8Array | string, options?: SignOptions, accountId?: string): Promise<SignResult>;
|
|
232
222
|
/**
|
|
233
223
|
* Sign content and immediately serialize to a base64 string.
|
|
@@ -451,12 +441,7 @@ export declare class MajikSignatureClient {
|
|
|
451
441
|
mimeType?: string;
|
|
452
442
|
accountId?: string;
|
|
453
443
|
expectedSigners?: ExpectedSigner[];
|
|
454
|
-
}): Promise<
|
|
455
|
-
blob: Blob;
|
|
456
|
-
signature: MajikSignature;
|
|
457
|
-
handler: string;
|
|
458
|
-
mimeType: string;
|
|
459
|
-
}>;
|
|
444
|
+
}): Promise<ReturnType<typeof MajikSignature.signFile>>;
|
|
460
445
|
/**
|
|
461
446
|
* Sign multiple file blobs with the active (or specified) account in one call.
|
|
462
447
|
*
|
|
@@ -646,12 +631,7 @@ export declare class MajikSignatureClient {
|
|
|
646
631
|
timestamp?: string;
|
|
647
632
|
mimeType?: string;
|
|
648
633
|
accountId?: string;
|
|
649
|
-
}): Promise<
|
|
650
|
-
blob: Blob;
|
|
651
|
-
signature: MajikSignature;
|
|
652
|
-
handler: string;
|
|
653
|
-
mimeType: string;
|
|
654
|
-
}>;
|
|
634
|
+
}): Promise<ReturnType<typeof MajikSignature.signFile>>;
|
|
655
635
|
/**
|
|
656
636
|
* Extract metadata from a file's embedded signature without verifying it.
|
|
657
637
|
*
|
|
@@ -708,10 +688,7 @@ export declare class MajikSignatureClient {
|
|
|
708
688
|
*/
|
|
709
689
|
canSign(file: Blob, key: MajikKey, options?: {
|
|
710
690
|
mimeType?: string;
|
|
711
|
-
}): Promise<
|
|
712
|
-
permitted: boolean;
|
|
713
|
-
reason?: string;
|
|
714
|
-
}>;
|
|
691
|
+
}): Promise<ReturnType<typeof MajikSignature.canSign>>;
|
|
715
692
|
/**
|
|
716
693
|
* Returns true when the file has a restricted multi-sig envelope
|
|
717
694
|
* (allowlist with more than one expected signer).
|
|
@@ -803,12 +780,7 @@ export declare class MajikSignatureClient {
|
|
|
803
780
|
mimeType?: string;
|
|
804
781
|
timestamp?: string;
|
|
805
782
|
accountId?: string;
|
|
806
|
-
}): Promise<
|
|
807
|
-
blob: Blob;
|
|
808
|
-
sealInfo: SealInfo;
|
|
809
|
-
handler: string;
|
|
810
|
-
mimeType: string;
|
|
811
|
-
}>;
|
|
783
|
+
}): Promise<ReturnType<typeof MajikSignature.seal>>;
|
|
812
784
|
/**
|
|
813
785
|
* Verify the seal hash against the current signatories and seal timestamp.
|
|
814
786
|
* Returns invalid if the envelope is not sealed.
|
|
@@ -218,9 +218,11 @@ export class MajikSignatureClient {
|
|
|
218
218
|
async generateMnemonic(strength = 128, language = "en") {
|
|
219
219
|
return await MajikKeyManager.generateMnemonic(strength, language);
|
|
220
220
|
}
|
|
221
|
-
async createAccount(mnemonic, passphrase, label) {
|
|
221
|
+
async createAccount(mnemonic, passphrase, label, mnemonicLanguage = "en") {
|
|
222
222
|
try {
|
|
223
|
-
const key = await MajikKey.create(mnemonic, passphrase, label
|
|
223
|
+
const key = await MajikKey.create(mnemonic, passphrase, label, {
|
|
224
|
+
mnemonicLanguage: mnemonicLanguage,
|
|
225
|
+
});
|
|
224
226
|
await this._keys.save(key);
|
|
225
227
|
const contact = key.toContact();
|
|
226
228
|
this._registerOwnAccount(contact);
|
|
@@ -631,31 +633,22 @@ export class MajikSignatureClient {
|
|
|
631
633
|
return `${signerId.slice(0, 16)}…`;
|
|
632
634
|
}
|
|
633
635
|
// ── Signing ───────────────────────────────────────────────────────────────
|
|
634
|
-
/**
|
|
635
|
-
* Sign content with the active account.
|
|
636
|
-
*
|
|
637
|
-
* The active account must be unlocked and have signing keys.
|
|
638
|
-
* Use unlockAccount() first if needed.
|
|
639
|
-
*
|
|
640
|
-
* @param content - Raw bytes or UTF-8 string to sign
|
|
641
|
-
* @param options - Optional content type and timestamp override
|
|
642
|
-
* @param accountId - Override which account signs. Defaults to active account.
|
|
643
|
-
*/
|
|
644
636
|
async sign(content, options, accountId) {
|
|
637
|
+
const id = accountId ?? this.getActiveAccount()?.id;
|
|
638
|
+
if (!id)
|
|
639
|
+
throw new Error("No active account — call setActiveAccount() first");
|
|
640
|
+
let key;
|
|
641
|
+
let shouldRelock = false;
|
|
645
642
|
try {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
throw new Error("No active account — call setActiveAccount() first");
|
|
649
|
-
const key = this._keys.get(id);
|
|
643
|
+
await this._keys.ensureUnlocked(id);
|
|
644
|
+
key = this._keys.get(id);
|
|
650
645
|
if (!key)
|
|
651
646
|
throw new Error(`Account not found in keystore: "${id}"`);
|
|
652
|
-
if (key.isLocked) {
|
|
653
|
-
throw new Error(`Account "${id}" is locked. Call unlockAccount() before signing.`);
|
|
654
|
-
}
|
|
655
647
|
if (!key.hasSigningKeys) {
|
|
656
648
|
throw new Error(`Account "${id}" has no signing keys. ` +
|
|
657
649
|
`Re-import via importAccountFromMnemonicBackup() to enable signing.`);
|
|
658
650
|
}
|
|
651
|
+
shouldRelock = !(await this.isOnetimeUnlockEnabled());
|
|
659
652
|
const signature = await MajikSignature.sign(content, key, options);
|
|
660
653
|
const result = {
|
|
661
654
|
signature,
|
|
@@ -671,6 +664,10 @@ export class MajikSignatureClient {
|
|
|
671
664
|
this._emit("error", err, { context: "sign" });
|
|
672
665
|
throw err;
|
|
673
666
|
}
|
|
667
|
+
finally {
|
|
668
|
+
if (shouldRelock)
|
|
669
|
+
key?.lock();
|
|
670
|
+
}
|
|
674
671
|
}
|
|
675
672
|
/**
|
|
676
673
|
* Sign content and immediately serialize to a base64 string.
|
|
@@ -1017,16 +1014,19 @@ export class MajikSignatureClient {
|
|
|
1017
1014
|
const id = options?.accountId ?? this.getActiveAccount()?.id;
|
|
1018
1015
|
if (!id)
|
|
1019
1016
|
throw new Error("No active account — call setActiveAccount() first");
|
|
1017
|
+
let key;
|
|
1018
|
+
let shouldRelock = false;
|
|
1020
1019
|
try {
|
|
1021
1020
|
await this._keys.ensureUnlocked(id);
|
|
1022
|
-
|
|
1021
|
+
key = this._keys.get(id);
|
|
1023
1022
|
if (!key)
|
|
1024
1023
|
throw new Error(`Account not found in keystore: "${id}"`);
|
|
1025
1024
|
if (!key.hasSigningKeys) {
|
|
1026
1025
|
throw new Error(`Account "${id}" has no signing keys. ` +
|
|
1027
1026
|
`Re-import via importAccountFromMnemonicBackup() to enable signing.`);
|
|
1028
1027
|
}
|
|
1029
|
-
|
|
1028
|
+
shouldRelock = !(await this.isOnetimeUnlockEnabled());
|
|
1029
|
+
return await MajikSignature.sign(content, key, {
|
|
1030
1030
|
contentType: options?.contentType,
|
|
1031
1031
|
timestamp: options?.timestamp,
|
|
1032
1032
|
});
|
|
@@ -1035,6 +1035,10 @@ export class MajikSignatureClient {
|
|
|
1035
1035
|
this._emit("error", err, { context: "signContent" });
|
|
1036
1036
|
throw err;
|
|
1037
1037
|
}
|
|
1038
|
+
finally {
|
|
1039
|
+
if (shouldRelock)
|
|
1040
|
+
key?.lock();
|
|
1041
|
+
}
|
|
1038
1042
|
}
|
|
1039
1043
|
/**
|
|
1040
1044
|
* Sign a file and embed the signature directly into it using the active account.
|
|
@@ -1054,26 +1058,34 @@ export class MajikSignatureClient {
|
|
|
1054
1058
|
const id = options?.accountId ?? this.getActiveAccount()?.id;
|
|
1055
1059
|
if (!id)
|
|
1056
1060
|
throw new Error("No active account — call setActiveAccount() first");
|
|
1061
|
+
let key;
|
|
1062
|
+
let shouldRelock = false;
|
|
1057
1063
|
try {
|
|
1058
1064
|
await this._keys.ensureUnlocked(id);
|
|
1059
|
-
|
|
1065
|
+
key = this._keys.get(id);
|
|
1060
1066
|
if (!key)
|
|
1061
1067
|
throw new Error(`Account not found in keystore: "${id}"`);
|
|
1062
1068
|
if (!key.hasSigningKeys) {
|
|
1063
1069
|
throw new Error(`Account "${id}" has no signing keys. ` +
|
|
1064
1070
|
`Re-import via importAccountFromMnemonicBackup() to enable signing.`);
|
|
1065
1071
|
}
|
|
1066
|
-
|
|
1072
|
+
shouldRelock = !(await this.isOnetimeUnlockEnabled());
|
|
1073
|
+
const signedResponse = await MajikSignature.signFile(file, key, {
|
|
1067
1074
|
contentType: options?.contentType,
|
|
1068
1075
|
timestamp: options?.timestamp,
|
|
1069
1076
|
mimeType: options?.mimeType,
|
|
1070
1077
|
expectedSigners: options?.expectedSigners,
|
|
1071
1078
|
});
|
|
1079
|
+
return signedResponse;
|
|
1072
1080
|
}
|
|
1073
1081
|
catch (err) {
|
|
1074
1082
|
this._emit("error", err, { context: "signFile" });
|
|
1075
1083
|
throw err;
|
|
1076
1084
|
}
|
|
1085
|
+
finally {
|
|
1086
|
+
if (shouldRelock)
|
|
1087
|
+
key?.lock();
|
|
1088
|
+
}
|
|
1077
1089
|
}
|
|
1078
1090
|
/**
|
|
1079
1091
|
* Sign multiple file blobs with the active (or specified) account in one call.
|
|
@@ -1622,11 +1634,19 @@ export class MajikSignatureClient {
|
|
|
1622
1634
|
const id = options?.accountId ?? this.getActiveAccount()?.id;
|
|
1623
1635
|
if (!id)
|
|
1624
1636
|
throw new Error("No active account — call setActiveAccount() first");
|
|
1637
|
+
let key;
|
|
1638
|
+
let shouldRelock = false;
|
|
1625
1639
|
try {
|
|
1626
|
-
|
|
1640
|
+
await this._keys.ensureUnlocked(id);
|
|
1641
|
+
key = this._keys.get(id);
|
|
1627
1642
|
if (!key)
|
|
1628
1643
|
throw new Error(`Account not found in keystore: "${id}"`);
|
|
1629
|
-
|
|
1644
|
+
if (!key.hasSigningKeys) {
|
|
1645
|
+
throw new Error(`Account "${id}" has no signing keys. ` +
|
|
1646
|
+
`Re-import via importAccountFromMnemonicBackup() to enable signing.`);
|
|
1647
|
+
}
|
|
1648
|
+
shouldRelock = !(await this.isOnetimeUnlockEnabled());
|
|
1649
|
+
return await MajikSignature.seal(file, key, {
|
|
1630
1650
|
mimeType: options?.mimeType,
|
|
1631
1651
|
timestamp: options?.timestamp,
|
|
1632
1652
|
});
|
|
@@ -1635,6 +1655,10 @@ export class MajikSignatureClient {
|
|
|
1635
1655
|
this._emit("error", err, { context: "seal" });
|
|
1636
1656
|
throw err;
|
|
1637
1657
|
}
|
|
1658
|
+
finally {
|
|
1659
|
+
if (shouldRelock)
|
|
1660
|
+
key?.lock();
|
|
1661
|
+
}
|
|
1638
1662
|
}
|
|
1639
1663
|
/**
|
|
1640
1664
|
* Verify the seal hash against the current signatories and seal timestamp.
|
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, 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.3",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Zelijah",
|
|
8
8
|
"main": "./dist/index.js",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"@majikah/majik-cjson": "^0.0.3",
|
|
56
56
|
"@majikah/majik-contact": "^0.0.6",
|
|
57
57
|
"@majikah/majik-file": "^0.1.12",
|
|
58
|
-
"@majikah/majik-key": "^0.3.
|
|
59
|
-
"@majikah/majik-signature": "^0.2.
|
|
58
|
+
"@majikah/majik-key": "^0.3.3",
|
|
59
|
+
"@majikah/majik-signature": "^0.2.1",
|
|
60
60
|
"@stablelib/ed25519": "^2.1.0",
|
|
61
61
|
"ed2curve": "^0.3.0",
|
|
62
62
|
"fflate": "^0.8.3"
|