@vlayer/sdk 0.1.0-nightly-20241008-77ed5a3 → 0.1.0-nightly-20241008-a3822d1
Sign up to get free protection for your applications and to get access to all the features.
- package/node_modules/@vlayer/web-proof-commons/index.ts +1 -0
- package/node_modules/@vlayer/web-proof-commons/lib/index.ts +1 -0
- package/node_modules/@vlayer/web-proof-commons/lib/message.ts +20 -0
- package/node_modules/@vlayer/web-proof-commons/package.json +4 -0
- package/package.json +1 -1
- package/src/api/webProof/providers/extension.ts +10 -21
- package/node_modules/@vlayer/web-proof-commons/constants/message.ts +0 -13
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./lib";
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./message";
|
@@ -0,0 +1,20 @@
|
|
1
|
+
export const enum ExtensionAction {
|
2
|
+
RequestWebProof,
|
3
|
+
}
|
4
|
+
|
5
|
+
export const enum ExtensionMessageType {
|
6
|
+
ProofDone,
|
7
|
+
ProofError,
|
8
|
+
RedirectBack,
|
9
|
+
}
|
10
|
+
|
11
|
+
export type ExtensionMessage =
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
13
|
+
| { type: ExtensionMessageType.ProofDone; proof: any } // Change to WebProof
|
14
|
+
| { type: ExtensionMessageType.ProofError; error: string }
|
15
|
+
| { type: ExtensionMessageType.RedirectBack };
|
16
|
+
|
17
|
+
export type WebProverSessionConfig = {
|
18
|
+
notaryUrl: string;
|
19
|
+
wsProxyUrl: string;
|
20
|
+
};
|
package/package.json
CHANGED
@@ -7,7 +7,8 @@ import {
|
|
7
7
|
import {
|
8
8
|
ExtensionAction,
|
9
9
|
ExtensionMessage,
|
10
|
-
|
10
|
+
ExtensionMessageType,
|
11
|
+
} from "@vlayer/web-proof-commons";
|
11
12
|
|
12
13
|
import { WebProof } from "../../lib/types/webProof";
|
13
14
|
|
@@ -49,26 +50,14 @@ export const createExtensionWebProofProvider = ({
|
|
49
50
|
});
|
50
51
|
const port = chrome.runtime.connect(EXTENSION_ID);
|
51
52
|
// TODO: validate message in runtime
|
52
|
-
port.onMessage.addListener(
|
53
|
-
(
|
54
|
-
message
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
type: ExtensionMessage.ProofError;
|
61
|
-
error: { message: string };
|
62
|
-
},
|
63
|
-
) => {
|
64
|
-
if (message.type === ExtensionMessage.ProofDone) {
|
65
|
-
resolve(message.proof);
|
66
|
-
}
|
67
|
-
if (message.type === ExtensionMessage.ProofError) {
|
68
|
-
reject(message.error);
|
69
|
-
}
|
70
|
-
},
|
71
|
-
);
|
53
|
+
port.onMessage.addListener((message: ExtensionMessage) => {
|
54
|
+
if (message.type === ExtensionMessageType.ProofDone) {
|
55
|
+
resolve(message.proof);
|
56
|
+
}
|
57
|
+
if (message.type === ExtensionMessageType.ProofError) {
|
58
|
+
reject(message.error);
|
59
|
+
}
|
60
|
+
});
|
72
61
|
});
|
73
62
|
},
|
74
63
|
};
|