@islom929/react-eimzo 0.3.2 → 0.4.0
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/README.md +3 -7
- package/dist/index.cjs +16 -11
- package/dist/index.js +16 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @islom929/react-eimzo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React hook for E-IMZO digital signatures. Simple API, zero UI dependencies — works with any component library.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -130,15 +130,11 @@ function PfxSign() {
|
|
|
130
130
|
|
|
131
131
|
### Sign with tokens
|
|
132
132
|
|
|
133
|
-
No certificate selection needed. Pass device type directly.
|
|
133
|
+
No certificate selection needed. Pass device type directly. Device status is checked automatically on mount.
|
|
134
134
|
|
|
135
135
|
```tsx
|
|
136
136
|
function TokenSign() {
|
|
137
|
-
const { sign, deviceStatus,
|
|
138
|
-
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
if (isInstalled) loadKeys()
|
|
141
|
-
}, [isInstalled])
|
|
137
|
+
const { sign, deviceStatus, isLoading } = useEimzo()
|
|
142
138
|
|
|
143
139
|
const handleTokenSign = (device: 'idcard' | 'baikey' | 'ckc') => {
|
|
144
140
|
sign({
|
package/dist/index.cjs
CHANGED
|
@@ -814,24 +814,29 @@ function EimzoProvider({ apiKeys, children }) {
|
|
|
814
814
|
baikey: false,
|
|
815
815
|
ckc: false
|
|
816
816
|
});
|
|
817
|
+
const checkDevices = (0, import_react.useCallback)(async () => {
|
|
818
|
+
const [idcard, baikey, ckc] = await Promise.allSettled([
|
|
819
|
+
checkIdCard(),
|
|
820
|
+
checkBaikToken(),
|
|
821
|
+
checkCkc()
|
|
822
|
+
]);
|
|
823
|
+
setDeviceStatus({
|
|
824
|
+
idcard: idcard.status === "fulfilled" && idcard.value,
|
|
825
|
+
baikey: baikey.status === "fulfilled" && baikey.value,
|
|
826
|
+
ckc: ckc.status === "fulfilled" && ckc.value
|
|
827
|
+
});
|
|
828
|
+
}, []);
|
|
817
829
|
(0, import_react.useEffect)(() => {
|
|
818
|
-
install(apiKeys).then(
|
|
830
|
+
install(apiKeys).then(async () => {
|
|
831
|
+
setIsInstalled(true);
|
|
832
|
+
await checkDevices();
|
|
833
|
+
}).catch(() => setIsInstalled(false));
|
|
819
834
|
}, []);
|
|
820
835
|
const loadKeys = (0, import_react.useCallback)(async () => {
|
|
821
836
|
setIsLoading(true);
|
|
822
837
|
try {
|
|
823
838
|
const certs = await listAllUserKeys();
|
|
824
839
|
setKeyList(certs);
|
|
825
|
-
const [idcard, baikey, ckc] = await Promise.allSettled([
|
|
826
|
-
checkIdCard(),
|
|
827
|
-
checkBaikToken(),
|
|
828
|
-
checkCkc()
|
|
829
|
-
]);
|
|
830
|
-
setDeviceStatus({
|
|
831
|
-
idcard: idcard.status === "fulfilled" && idcard.value,
|
|
832
|
-
baikey: baikey.status === "fulfilled" && baikey.value,
|
|
833
|
-
ckc: ckc.status === "fulfilled" && ckc.value
|
|
834
|
-
});
|
|
835
840
|
} catch (err) {
|
|
836
841
|
console.error("E-IMZO: Failed to load keys", err);
|
|
837
842
|
} finally {
|
package/dist/index.js
CHANGED
|
@@ -793,24 +793,29 @@ function EimzoProvider({ apiKeys, children }) {
|
|
|
793
793
|
baikey: false,
|
|
794
794
|
ckc: false
|
|
795
795
|
});
|
|
796
|
+
const checkDevices = useCallback(async () => {
|
|
797
|
+
const [idcard, baikey, ckc] = await Promise.allSettled([
|
|
798
|
+
checkIdCard(),
|
|
799
|
+
checkBaikToken(),
|
|
800
|
+
checkCkc()
|
|
801
|
+
]);
|
|
802
|
+
setDeviceStatus({
|
|
803
|
+
idcard: idcard.status === "fulfilled" && idcard.value,
|
|
804
|
+
baikey: baikey.status === "fulfilled" && baikey.value,
|
|
805
|
+
ckc: ckc.status === "fulfilled" && ckc.value
|
|
806
|
+
});
|
|
807
|
+
}, []);
|
|
796
808
|
useEffect(() => {
|
|
797
|
-
install(apiKeys).then(
|
|
809
|
+
install(apiKeys).then(async () => {
|
|
810
|
+
setIsInstalled(true);
|
|
811
|
+
await checkDevices();
|
|
812
|
+
}).catch(() => setIsInstalled(false));
|
|
798
813
|
}, []);
|
|
799
814
|
const loadKeys = useCallback(async () => {
|
|
800
815
|
setIsLoading(true);
|
|
801
816
|
try {
|
|
802
817
|
const certs = await listAllUserKeys();
|
|
803
818
|
setKeyList(certs);
|
|
804
|
-
const [idcard, baikey, ckc] = await Promise.allSettled([
|
|
805
|
-
checkIdCard(),
|
|
806
|
-
checkBaikToken(),
|
|
807
|
-
checkCkc()
|
|
808
|
-
]);
|
|
809
|
-
setDeviceStatus({
|
|
810
|
-
idcard: idcard.status === "fulfilled" && idcard.value,
|
|
811
|
-
baikey: baikey.status === "fulfilled" && baikey.value,
|
|
812
|
-
ckc: ckc.status === "fulfilled" && ckc.value
|
|
813
|
-
});
|
|
814
819
|
} catch (err) {
|
|
815
820
|
console.error("E-IMZO: Failed to load keys", err);
|
|
816
821
|
} finally {
|