@islom929/react-eimzo 0.2.0 → 0.3.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/dist/index.cjs +5 -2
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -839,7 +839,7 @@ function EimzoProvider({ apiKeys, children }) {
|
|
|
839
839
|
}
|
|
840
840
|
}, []);
|
|
841
841
|
const sign = (0, import_react.useCallback)(
|
|
842
|
-
async ({ keyId, data }) => {
|
|
842
|
+
async ({ keyId, data, onSuccess, onError }) => {
|
|
843
843
|
setIsLoading(true);
|
|
844
844
|
try {
|
|
845
845
|
let id;
|
|
@@ -849,7 +849,10 @@ function EimzoProvider({ apiKeys, children }) {
|
|
|
849
849
|
id = keyId;
|
|
850
850
|
}
|
|
851
851
|
const pkcs7 = await createPkcs7(id, data);
|
|
852
|
-
|
|
852
|
+
onSuccess(pkcs7);
|
|
853
|
+
} catch (err) {
|
|
854
|
+
const message = typeof err === "string" ? err : "E-IMZO signing failed";
|
|
855
|
+
onError?.(message);
|
|
853
856
|
} finally {
|
|
854
857
|
setIsLoading(false);
|
|
855
858
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -26,6 +26,8 @@ interface ICertificate {
|
|
|
26
26
|
interface ISignParams {
|
|
27
27
|
keyId: ICertificate | string;
|
|
28
28
|
data: string;
|
|
29
|
+
onSuccess: (pkcs7: string) => void;
|
|
30
|
+
onError?: (error: string) => void;
|
|
29
31
|
}
|
|
30
32
|
interface IDeviceStatus {
|
|
31
33
|
idcard: boolean;
|
|
@@ -42,7 +44,7 @@ interface IEimzoContext {
|
|
|
42
44
|
keyList: ICertificate[];
|
|
43
45
|
deviceStatus: IDeviceStatus;
|
|
44
46
|
loadKeys: () => Promise<void>;
|
|
45
|
-
sign: (params: ISignParams) =>
|
|
47
|
+
sign: (params: ISignParams) => void;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
interface IEimzoProviderProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ interface ICertificate {
|
|
|
26
26
|
interface ISignParams {
|
|
27
27
|
keyId: ICertificate | string;
|
|
28
28
|
data: string;
|
|
29
|
+
onSuccess: (pkcs7: string) => void;
|
|
30
|
+
onError?: (error: string) => void;
|
|
29
31
|
}
|
|
30
32
|
interface IDeviceStatus {
|
|
31
33
|
idcard: boolean;
|
|
@@ -42,7 +44,7 @@ interface IEimzoContext {
|
|
|
42
44
|
keyList: ICertificate[];
|
|
43
45
|
deviceStatus: IDeviceStatus;
|
|
44
46
|
loadKeys: () => Promise<void>;
|
|
45
|
-
sign: (params: ISignParams) =>
|
|
47
|
+
sign: (params: ISignParams) => void;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
interface IEimzoProviderProps {
|
package/dist/index.js
CHANGED
|
@@ -818,7 +818,7 @@ function EimzoProvider({ apiKeys, children }) {
|
|
|
818
818
|
}
|
|
819
819
|
}, []);
|
|
820
820
|
const sign = useCallback(
|
|
821
|
-
async ({ keyId, data }) => {
|
|
821
|
+
async ({ keyId, data, onSuccess, onError }) => {
|
|
822
822
|
setIsLoading(true);
|
|
823
823
|
try {
|
|
824
824
|
let id;
|
|
@@ -828,7 +828,10 @@ function EimzoProvider({ apiKeys, children }) {
|
|
|
828
828
|
id = keyId;
|
|
829
829
|
}
|
|
830
830
|
const pkcs7 = await createPkcs7(id, data);
|
|
831
|
-
|
|
831
|
+
onSuccess(pkcs7);
|
|
832
|
+
} catch (err) {
|
|
833
|
+
const message = typeof err === "string" ? err : "E-IMZO signing failed";
|
|
834
|
+
onError?.(message);
|
|
832
835
|
} finally {
|
|
833
836
|
setIsLoading(false);
|
|
834
837
|
}
|