@laiye_packages/uci 1.0.8 → 1.0.9
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/index.js +6 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9708,7 +9708,7 @@ class LYAppPermission extends LYObject {
|
|
|
9708
9708
|
super(), this._codes = {};
|
|
9709
9709
|
this._app_name = app_name;
|
|
9710
9710
|
this._codes = codes;
|
|
9711
|
-
this._allCodes = allCodes;
|
|
9711
|
+
this._allCodes = allCodes || [];
|
|
9712
9712
|
}
|
|
9713
9713
|
get app_name() {
|
|
9714
9714
|
return this._app_name;
|
|
@@ -9727,7 +9727,7 @@ class LYAppPermission extends LYObject {
|
|
|
9727
9727
|
return this._codes[code];
|
|
9728
9728
|
}
|
|
9729
9729
|
hasPermission(code) {
|
|
9730
|
-
if (
|
|
9730
|
+
if (!this._allCodes.includes(code)) return true;
|
|
9731
9731
|
return code in this._codes;
|
|
9732
9732
|
}
|
|
9733
9733
|
}
|
|
@@ -10624,9 +10624,8 @@ class LYSMCrypto extends LYBaseCrypto {
|
|
|
10624
10624
|
signature(data, privateKey) {
|
|
10625
10625
|
try {
|
|
10626
10626
|
this._validateKey(privateKey, 32, 'SM2 private');
|
|
10627
|
-
const dataHex = this._uint8ArrayToHex(data);
|
|
10628
10627
|
const privateKeyHex = this._uint8ArrayToHex(privateKey);
|
|
10629
|
-
const signature = sm2.doSignature(
|
|
10628
|
+
const signature = sm2.doSignature(Array.from(data), privateKeyHex);
|
|
10630
10629
|
if (!signature) throw new LYCryptoError('SM2 signature failed');
|
|
10631
10630
|
return signature;
|
|
10632
10631
|
} catch (error) {
|
|
@@ -10637,9 +10636,8 @@ class LYSMCrypto extends LYBaseCrypto {
|
|
|
10637
10636
|
verify(data, publicKey, signature) {
|
|
10638
10637
|
try {
|
|
10639
10638
|
this._validatePublicKey(publicKey);
|
|
10640
|
-
const dataHex = this._uint8ArrayToHex(data);
|
|
10641
10639
|
const publicKeyHex = this._uint8ArrayToHex(publicKey);
|
|
10642
|
-
return sm2.doVerifySignature(
|
|
10640
|
+
return sm2.doVerifySignature(Array.from(data), signature, publicKeyHex);
|
|
10643
10641
|
} catch (error) {
|
|
10644
10642
|
if (error instanceof LYCryptoError) throw error;
|
|
10645
10643
|
throw new LYCryptoError(`SM2 verify error: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -10648,9 +10646,8 @@ class LYSMCrypto extends LYBaseCrypto {
|
|
|
10648
10646
|
encryptAsymmetric(data, publicKey) {
|
|
10649
10647
|
try {
|
|
10650
10648
|
this._validatePublicKey(publicKey);
|
|
10651
|
-
const dataHex = this._uint8ArrayToHex(data);
|
|
10652
10649
|
const publicKeyHex = this._uint8ArrayToHex(publicKey);
|
|
10653
|
-
const encrypted = sm2.doEncrypt(
|
|
10650
|
+
const encrypted = sm2.doEncrypt(Array.from(data), publicKeyHex);
|
|
10654
10651
|
if (!encrypted) throw new LYCryptoError('SM2 encryption failed');
|
|
10655
10652
|
return this._hexToUint8Array(encrypted);
|
|
10656
10653
|
} catch (error) {
|
|
@@ -10665,7 +10662,7 @@ class LYSMCrypto extends LYBaseCrypto {
|
|
|
10665
10662
|
const privateKeyHex = this._uint8ArrayToHex(privateKey);
|
|
10666
10663
|
const decrypted = sm2.doDecrypt(dataHex, privateKeyHex);
|
|
10667
10664
|
if (!decrypted) throw new LYCryptoError('SM2 decryption failed');
|
|
10668
|
-
return
|
|
10665
|
+
return new TextEncoder().encode(decrypted);
|
|
10669
10666
|
} catch (error) {
|
|
10670
10667
|
if (error instanceof LYCryptoError) throw error;
|
|
10671
10668
|
throw new LYCryptoError(`SM2 decryption error: ${error instanceof Error ? error.message : String(error)}`);
|