@vlayer/sdk 0.1.0-nightly-20241206-b638b72 → 0.1.0-nightly-20241209-b20d3cb

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.
@@ -70,7 +70,6 @@ export const createVlayerClient = ({ url = "http://127.0.0.1:3000", webProofProv
70
70
  {
71
71
  webProofJson: JSON.stringify({
72
72
  tls_proof: webProof,
73
- notary_pub_key: webProofPlaceholder.notaryPubKey,
74
73
  }),
75
74
  },
76
75
  ...commitmentArgs,
@@ -4,7 +4,6 @@ import { Branded, ExtensionMessageType, ExtensionMessage, type PresentationJSON,
4
4
  export type WebProofRequestInput = {
5
5
  logoUrl: string;
6
6
  steps: WebProofStep[];
7
- notaryPubKey?: string;
8
7
  };
9
8
  export type WebProofRequest = Branded<WebProofRequestInput & {
10
9
  isWebProof: true;
@@ -1,2 +1,2 @@
1
1
  import { WebProofRequest, WebProofRequestInput } from "../lib/types/webProofProvider.js";
2
- export declare const createWebProofRequest: ({ logoUrl, steps, notaryPubKey, }: WebProofRequestInput) => WebProofRequest;
2
+ export declare const createWebProofRequest: ({ logoUrl, steps, }: WebProofRequestInput) => WebProofRequest;
@@ -1,9 +1,7 @@
1
- const NOTARY_PUB_KEY = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAExpX/4R4z40gI6C/j9zAM39u58LJu\n3Cx5tXTuqhhu/tirnBi5GniMmspOTEsps4ANnPLpMmMSfhJ+IFHbc3qVOA==\n-----END PUBLIC KEY-----\n";
2
- export const createWebProofRequest = ({ logoUrl, steps, notaryPubKey = NOTARY_PUB_KEY, }) => {
1
+ export const createWebProofRequest = ({ logoUrl, steps, }) => {
3
2
  return {
4
3
  logoUrl,
5
4
  steps,
6
- notaryPubKey,
7
5
  isWebProof: true,
8
6
  };
9
7
  };
@@ -31,6 +31,10 @@ class ExtensionWebProofProvider {
31
31
  connectToExtension() {
32
32
  if (!this.port) {
33
33
  this.port = chrome.runtime.connect(EXTENSION_ID);
34
+ this.port.onDisconnect.addListener(() => {
35
+ this.port = null;
36
+ this.connectToExtension();
37
+ });
34
38
  this.port.onMessage.addListener((message) => {
35
39
  if (message.type === ExtensionMessageType.ProofDone) {
36
40
  this.listeners[ExtensionMessageType.ProofDone]?.forEach((cb) => {
@@ -1,7 +1,29 @@
1
1
  import { createExtensionWebProofProvider } from "./extension.js";
2
- import { describe, it, expect } from "vitest";
2
+ import { describe, it, expect, vi } from "vitest";
3
3
  import { expectUrl, startPage, notarize } from "../steps/index.js";
4
4
  import { StepValidationError } from "../../../web-proof-commons/index.js";
5
+ const chrome = {
6
+ runtime: {
7
+ disconnectCallbacks: [],
8
+ connect: vi.fn().mockImplementation(() => ({
9
+ postMessage: vi.fn().mockImplementation(() => { }),
10
+ onMessage: {
11
+ addListener: vi.fn().mockImplementation(() => { }),
12
+ },
13
+ onDisconnect: {
14
+ addListener: vi.fn().mockImplementation((callback) => {
15
+ chrome.runtime.disconnectCallbacks.push(callback);
16
+ }),
17
+ },
18
+ })),
19
+ disconnect: vi.fn().mockImplementation(() => {
20
+ chrome.runtime.disconnectCallbacks.forEach((callback) => {
21
+ callback();
22
+ });
23
+ }),
24
+ },
25
+ };
26
+ vi.stubGlobal("chrome", chrome);
5
27
  const defaults = {
6
28
  logoUrl: "https://example.com/logo.png",
7
29
  proverCallCommitment: {
@@ -60,6 +82,20 @@ describe("ExtensionWebProofProvider", () => {
60
82
  expectUrl(validUrl, label),
61
83
  notarize(validUrl, "GET", label),
62
84
  ],
63
- })).not.toThrow(StepValidationError);
85
+ })).not.toThrow();
86
+ });
87
+ it("should reconnect extension on disconnect", () => {
88
+ const provider = createExtensionWebProofProvider();
89
+ provider.requestWebProof({
90
+ ...defaults,
91
+ steps: [
92
+ startPage(validUrl, label),
93
+ expectUrl(validUrlPattern, label),
94
+ notarize(validUrlPattern, "GET", label),
95
+ ],
96
+ });
97
+ chrome.runtime.connect.mockClear();
98
+ chrome.runtime.disconnect();
99
+ expect(chrome.runtime.connect).toHaveBeenCalled();
64
100
  });
65
101
  });
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "types": "./dist/config/index.d.ts"
16
16
  }
17
17
  },
18
- "version": "0.1.0-nightly-20241206-b638b72",
18
+ "version": "0.1.0-nightly-20241209-b20d3cb",
19
19
  "scripts": {
20
20
  "build": "bun tsc && bun tsc-alias",
21
21
  "test:unit": "vitest --run",