@vlayer/sdk 0.1.0-nightly-20250128-0a32cfc → 0.1.0-nightly-20250128-dc31d90

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.
Files changed (60) hide show
  1. package/dist/api/lib/client.d.ts.map +1 -1
  2. package/dist/api/lib/client.js.map +1 -1
  3. package/dist/api/prover.d.ts.map +1 -1
  4. package/dist/api/prover.js.map +1 -1
  5. package/dist/api/v_call.d.ts.map +1 -1
  6. package/dist/api/v_call.js.map +1 -1
  7. package/dist/api/v_getProofReceipt.d.ts.map +1 -1
  8. package/dist/api/v_getProofReceipt.js.map +1 -1
  9. package/dist/api/webProof/createWebProofRequest.d.ts.map +1 -1
  10. package/dist/api/webProof/createWebProofRequest.js.map +1 -1
  11. package/package.json +7 -20
  12. package/src/api/email/dnsResolver.test.ts +0 -19
  13. package/src/api/email/dnsResolver.ts +0 -87
  14. package/src/api/email/parseEmail.test.ts +0 -133
  15. package/src/api/email/parseEmail.ts +0 -55
  16. package/src/api/email/preverify.test.ts +0 -201
  17. package/src/api/email/preverify.ts +0 -70
  18. package/src/api/email/testdata/test_email.txt +0 -21
  19. package/src/api/email/testdata/test_email_multiple_dkims.txt +0 -28
  20. package/src/api/email/testdata/test_email_subdomain.txt +0 -21
  21. package/src/api/email/testdata/test_email_unknown_domain.txt +0 -21
  22. package/src/api/lib/client.test.ts +0 -261
  23. package/src/api/lib/client.ts +0 -191
  24. package/src/api/lib/errors.ts +0 -19
  25. package/src/api/lib/types/ethereum.ts +0 -45
  26. package/src/api/lib/types/index.ts +0 -3
  27. package/src/api/lib/types/viem.ts +0 -26
  28. package/src/api/lib/types/vlayer.ts +0 -156
  29. package/src/api/lib/types/webProofProvider.ts +0 -68
  30. package/src/api/prover.ts +0 -120
  31. package/src/api/utils/prefixAllButNthSubstring.test.ts +0 -24
  32. package/src/api/utils/prefixAllButNthSubstring.ts +0 -13
  33. package/src/api/utils/versions.test.ts +0 -52
  34. package/src/api/utils/versions.ts +0 -31
  35. package/src/api/v_call.ts +0 -58
  36. package/src/api/v_getProofReceipt.ts +0 -48
  37. package/src/api/v_versions.ts +0 -68
  38. package/src/api/webProof/createWebProofRequest.ts +0 -15
  39. package/src/api/webProof/index.ts +0 -3
  40. package/src/api/webProof/providers/extension.test.ts +0 -122
  41. package/src/api/webProof/providers/extension.ts +0 -197
  42. package/src/api/webProof/providers/index.ts +0 -1
  43. package/src/api/webProof/steps/expectUrl.ts +0 -12
  44. package/src/api/webProof/steps/index.ts +0 -11
  45. package/src/api/webProof/steps/notarize.ts +0 -20
  46. package/src/api/webProof/steps/startPage.ts +0 -12
  47. package/src/config/createContext.ts +0 -69
  48. package/src/config/deploy.ts +0 -108
  49. package/src/config/getChainConfirmations.ts +0 -6
  50. package/src/config/getConfig.ts +0 -71
  51. package/src/config/index.ts +0 -5
  52. package/src/config/types.ts +0 -26
  53. package/src/config/writeEnvVariables.ts +0 -28
  54. package/src/index.ts +0 -7
  55. package/src/testHelpers/readFile.ts +0 -3
  56. package/src/web-proof-commons/index.ts +0 -3
  57. package/src/web-proof-commons/types/message.ts +0 -176
  58. package/src/web-proof-commons/types/redaction.test.ts +0 -97
  59. package/src/web-proof-commons/types/redaction.ts +0 -201
  60. package/src/web-proof-commons/utils.ts +0 -11
@@ -1,26 +0,0 @@
1
- import { type Abi, type ContractFunctionName } from "viem";
2
- import {
3
- type AbiParametersToPrimitiveTypes,
4
- type ExtractAbiFunction,
5
- } from "abitype";
6
-
7
- type Without<T extends readonly unknown[], P> = T extends readonly [
8
- infer F,
9
- ...infer R,
10
- ]
11
- ? F extends P
12
- ? Without<R, P>
13
- : readonly [F, ...Without<R, P>]
14
- : [];
15
-
16
- export type ContractFunctionArgsWithout<
17
- abi extends Abi,
18
- functionName extends ContractFunctionName<abi>,
19
- without,
20
- > = AbiParametersToPrimitiveTypes<
21
- Without<
22
- ExtractAbiFunction<abi extends Abi ? abi : Abi, functionName>["inputs"],
23
- without
24
- >,
25
- "inputs"
26
- >;
@@ -1,156 +0,0 @@
1
- import { type Branded } from "../../../web-proof-commons/utils";
2
- import {
3
- type Abi,
4
- type AbiStateMutability,
5
- type Address,
6
- type ContractFunctionArgs,
7
- type ContractFunctionName,
8
- type ContractFunctionReturnType,
9
- type Hex,
10
- } from "viem";
11
- import { type WebProofRequest } from "./webProofProvider";
12
- import { type ContractFunctionArgsWithout } from "./viem";
13
- import { z } from "zod";
14
-
15
- type Calldata = string;
16
-
17
- export type CallParams = {
18
- to: Address;
19
- data: Calldata;
20
- gas_limit: number;
21
- };
22
-
23
- export type CallContext = {
24
- chain_id: number;
25
- };
26
-
27
- export type BrandedHash<T, F> = Branded<{ hash: string }, [T, F]>;
28
-
29
- export type Proof = {
30
- seal: {
31
- verifierSelector: Hex;
32
- seal: readonly [Hex, Hex, Hex, Hex, Hex, Hex, Hex, Hex];
33
- mode: number;
34
- };
35
- callGuestId: Hex;
36
- length: bigint;
37
- callAssumptions: {
38
- proverContractAddress: Address;
39
- functionSelector: Hex;
40
- settleBlockHash: Hex;
41
- settleBlockNumber: bigint;
42
- };
43
- };
44
-
45
- export type VCallResult = Hex;
46
-
47
- export interface VCallResponse {
48
- jsonrpc: string;
49
- result: VCallResult;
50
- id: number;
51
- }
52
-
53
- export type VGetProofReceiptParams = {
54
- hash: Hex;
55
- };
56
-
57
- export enum ProofState {
58
- Queued = "queued",
59
- ChainProof = "chain_proof",
60
- Preflight = "preflight",
61
- Proving = "proving",
62
- Done = "done",
63
- }
64
-
65
- export type ProofData = {
66
- evm_call_result: Hex;
67
- proof: Proof;
68
- };
69
-
70
- export type Metrics = {
71
- gas: number;
72
- cycles: number;
73
- times: {
74
- preflight: number;
75
- proving: number;
76
- };
77
- };
78
-
79
- export type ProofDataWithMetrics = {
80
- data: ProofData;
81
- metrics: Metrics;
82
- };
83
-
84
- export type ProveArgs<T extends Abi, F extends ContractFunctionName<T>> = {
85
- address: Hex;
86
- proverAbi: T;
87
- functionName: F;
88
- chainId?: number;
89
- gasLimit?: number;
90
- token?: string;
91
- args: ContractFunctionArgs<T, AbiStateMutability, F>;
92
- };
93
-
94
- export type VlayerClient = {
95
- prove: <T extends Abi, F extends ContractFunctionName<T>>(
96
- args: ProveArgs<T, F>,
97
- ) => Promise<BrandedHash<T, F>>;
98
-
99
- waitForProvingResult: <
100
- T extends Abi,
101
- F extends ContractFunctionName<T>,
102
- >(args: {
103
- hash: BrandedHash<T, F>;
104
- numberOfRetries?: number;
105
- sleepDuration?: number;
106
- }) => Promise<ContractFunctionReturnType<T, AbiStateMutability, F>>;
107
-
108
- proveWeb: <T extends Abi, F extends ContractFunctionName<T>>(args: {
109
- address: Hex;
110
- proverAbi: T;
111
- functionName: F;
112
- chainId: number;
113
- gasLimit?: number;
114
- token?: string;
115
- args: [
116
- WebProofRequest,
117
- ...ContractFunctionArgsWithout<T, F, { name: "webProof" }>,
118
- ];
119
- }) => Promise<BrandedHash<T, F>>;
120
- };
121
-
122
- export const proofReceiptSchema = z.discriminatedUnion("status", [
123
- z.object({
124
- status: z.literal(0),
125
- error: z.string(),
126
- data: z.undefined(),
127
- metrics: z.custom<Metrics>(),
128
- state: z.enum([
129
- ProofState.ChainProof,
130
- ProofState.Preflight,
131
- ProofState.Proving,
132
- ]),
133
- }),
134
- z.object({
135
- status: z.literal(1),
136
- error: z.undefined(),
137
- state: z.enum([
138
- ProofState.Done,
139
- ProofState.ChainProof,
140
- ProofState.Preflight,
141
- ProofState.Proving,
142
- ProofState.Queued,
143
- ]),
144
- data: z.custom<ProofData>(),
145
- metrics: z.custom<Metrics>(),
146
- }),
147
- ]);
148
-
149
- export const vGetProofReceiptSchema = z.object({
150
- jsonrpc: z.string(),
151
- result: proofReceiptSchema,
152
- id: z.number(),
153
- });
154
-
155
- export type ProofReceipt = z.infer<typeof proofReceiptSchema>;
156
- export type VGetProofReceiptResponse = z.infer<typeof vGetProofReceiptSchema>;
@@ -1,68 +0,0 @@
1
- import { type Hex, type Abi, type ContractFunctionName } from "viem";
2
- import type { ContractFunctionArgsWithout } from "./viem";
3
- import {
4
- type Branded,
5
- type ExtensionMessageType,
6
- type ExtensionMessage,
7
- type PresentationJSON,
8
- type WebProofStep,
9
- type ZkProvingStatus,
10
- } from "../../../web-proof-commons";
11
-
12
- export type WebProofRequestInput = {
13
- logoUrl: string;
14
- steps: WebProofStep[];
15
- };
16
-
17
- export type WebProofRequest = Branded<
18
- WebProofRequestInput & {
19
- isWebProof: true;
20
- },
21
- "webProof"
22
- >;
23
-
24
- export type ProverCallCommitment<
25
- T extends Abi,
26
- F extends ContractFunctionName<T>,
27
- > = {
28
- address: Hex;
29
- proverAbi: T;
30
- functionName: F;
31
- commitmentArgs: ContractFunctionArgsWithout<T, F, { name: "webProof" }>;
32
- chainId: number;
33
- };
34
-
35
- export type GetWebProofArgs<
36
- T extends Abi,
37
- F extends ContractFunctionName<T>,
38
- > = {
39
- proverCallCommitment: ProverCallCommitment<T, F>;
40
- } & WebProofRequestInput;
41
-
42
- export type WebProofProvider = {
43
- getWebProof: <T extends Abi, F extends ContractFunctionName<T>>(
44
- args: GetWebProofArgs<T, F>,
45
- ) => Promise<{
46
- presentationJSON: PresentationJSON;
47
- decodedTranscript: {
48
- sent: string;
49
- recv: string;
50
- };
51
- }>;
52
-
53
- requestWebProof: <T extends Abi, F extends ContractFunctionName<T>>(
54
- args: GetWebProofArgs<T, F>,
55
- ) => void;
56
-
57
- notifyZkProvingStatus: (status: ZkProvingStatus) => void;
58
-
59
- addEventListeners: <T extends ExtensionMessageType>(
60
- messageType: T,
61
- listener: (args: Extract<ExtensionMessage, { type: T }>) => void,
62
- ) => void;
63
- };
64
-
65
- export type WebProofProviderSetup = {
66
- notaryUrl?: string;
67
- wsProxyUrl?: string;
68
- };
package/src/api/prover.ts DELETED
@@ -1,120 +0,0 @@
1
- import {
2
- type Abi,
3
- type AbiStateMutability,
4
- type Address,
5
- type ContractFunctionArgs,
6
- type ContractFunctionName,
7
- encodeFunctionData,
8
- type Hex,
9
- } from "viem";
10
- import {
11
- type CallContext,
12
- type CallParams,
13
- type BrandedHash,
14
- type ProofDataWithMetrics,
15
- type ProofReceipt,
16
- ProofState,
17
- type VGetProofReceiptParams,
18
- type VGetProofReceiptResponse,
19
- } from "./lib/types/vlayer";
20
- import { match } from "ts-pattern";
21
- import { v_call } from "./v_call";
22
- import { v_getProofReceipt } from "./v_getProofReceipt";
23
- import { foundry } from "viem/chains";
24
- import { v_versions } from "./v_versions";
25
- import { checkVersionCompatibility } from "./utils/versions";
26
- import meta from "../../package.json" with { type: "json" };
27
- const sdkVersion = meta.version;
28
-
29
- export interface ProveOptions {
30
- preverifyVersions?: boolean;
31
- }
32
-
33
- async function preverifyVersions(url: string, shouldPreverify: boolean) {
34
- if (shouldPreverify) {
35
- const proverVersions = await v_versions(url);
36
- checkVersionCompatibility(proverVersions.result.api_version, sdkVersion);
37
- }
38
- }
39
-
40
- export async function prove<T extends Abi, F extends ContractFunctionName<T>>(
41
- prover: Address,
42
- abi: T,
43
- functionName: F,
44
- args: ContractFunctionArgs<T, AbiStateMutability, F>,
45
- chainId: number = foundry.id,
46
- url: string = "http://127.0.0.1:3000",
47
- gasLimit: number = 10_000_000,
48
- token?: string,
49
- options: ProveOptions = { preverifyVersions: false },
50
- ): Promise<BrandedHash<T, F>> {
51
- await preverifyVersions(url, !!options.preverifyVersions);
52
- const calldata = encodeFunctionData({
53
- abi: abi as Abi,
54
- functionName: functionName as string,
55
- args: args as readonly unknown[],
56
- });
57
- const call: CallParams = { to: prover, data: calldata, gas_limit: gasLimit };
58
- const context: CallContext = {
59
- chain_id: chainId,
60
- };
61
- const resp = await v_call(call, context, url, token);
62
- return { hash: resp.result } as BrandedHash<T, F>;
63
- }
64
-
65
- export async function getProofReceipt<
66
- T extends Abi,
67
- F extends ContractFunctionName<T>,
68
- >(
69
- hash: BrandedHash<T, F>,
70
- url: string = "http://127.0.0.1:3000",
71
- ): Promise<ProofReceipt> {
72
- const params: VGetProofReceiptParams = {
73
- hash: hash.hash as Hex,
74
- };
75
- const resp = await v_getProofReceipt(params, url);
76
- handleErrors(resp);
77
- return resp.result;
78
- }
79
-
80
- const handleErrors = (resp: VGetProofReceiptResponse) => {
81
- const { status, state, error } = resp.result;
82
- if (status === 0) {
83
- match(state)
84
- .with(ProofState.ChainProof, () => {
85
- throw new Error("Waiting for chain proof failed with error: " + error);
86
- })
87
- .with(ProofState.Preflight, () => {
88
- throw new Error("Preflight failed with error: " + error);
89
- })
90
- .with(ProofState.Proving, () => {
91
- throw new Error("Proving failed with error: " + error);
92
- })
93
- .exhaustive();
94
- }
95
- };
96
-
97
- export async function waitForProof<
98
- T extends Abi,
99
- F extends ContractFunctionName<T>,
100
- >(
101
- hash: BrandedHash<T, F>,
102
- url: string,
103
- numberOfRetries: number = 240,
104
- sleepDuration: number = 1000,
105
- ): Promise<ProofDataWithMetrics> {
106
- for (let retry = 0; retry < numberOfRetries; retry++) {
107
- const { state, data, metrics } = await getProofReceipt(hash, url);
108
- if (state === ProofState.Done) {
109
- return { data, metrics };
110
- }
111
- await sleep(sleepDuration);
112
- }
113
- throw new Error(
114
- `Timed out waiting for ZK proof generation after ${numberOfRetries * sleepDuration}ms. Consider increasing numberOfRetries.`,
115
- );
116
- }
117
-
118
- async function sleep(ms: number): Promise<void> {
119
- return new Promise((resolve) => setTimeout(resolve, ms));
120
- }
@@ -1,24 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { prefixAllButNthSubstring } from "./prefixAllButNthSubstring";
3
-
4
- describe("prefixAllButNthSubstring", () => {
5
- test("adds 'X-' prefix to all matches except n-th (indexed from 0)", () => {
6
- const str = "abc 123 abc 456 abc 789";
7
- expect(prefixAllButNthSubstring(str, /abc/gi, 3, 0)).toBe(
8
- "abc 123 X-abc 456 X-abc 789",
9
- );
10
- expect(prefixAllButNthSubstring(str, /abc/gi, 3, 1)).toBe(
11
- "X-abc 123 abc 456 X-abc 789",
12
- );
13
- expect(prefixAllButNthSubstring(str, /abc/gi, 3, 2)).toBe(
14
- "X-abc 123 X-abc 456 abc 789",
15
- );
16
- });
17
-
18
- test("does not add prefix to substrings past total substring count", () => {
19
- const str = "abc 123 abc 456 abc 789 abc abc";
20
- expect(prefixAllButNthSubstring(str, /abc/gi, 3, 1)).toBe(
21
- "X-abc 123 abc 456 X-abc 789 abc abc",
22
- );
23
- });
24
- });
@@ -1,13 +0,0 @@
1
- export function prefixAllButNthSubstring(
2
- str: string,
3
- pattern: RegExp,
4
- substringsCount: number,
5
- skippedIndex: number,
6
- ) {
7
- let occurrence = 0;
8
- return str.replace(pattern, (match) => {
9
- return occurrence++ === skippedIndex || occurrence > substringsCount
10
- ? match
11
- : `X-${match}`;
12
- });
13
- }
@@ -1,52 +0,0 @@
1
- import { describe, test, expect } from "vitest";
2
- import { checkVersionCompatibility } from "./versions";
3
-
4
- describe("versions compatibility", () => {
5
- test("throws if major version mismatches", () => {
6
- expect(() => {
7
- checkVersionCompatibility("1.2.3", "2.1.3");
8
- }).toThrowError(
9
- "SDK version 2.1.3 is incompatible with prover version 1.2.3",
10
- );
11
- });
12
-
13
- test("throws if major version mismatches with metadata after dash", () => {
14
- expect(() => {
15
- checkVersionCompatibility("1.2.3-dev-123456-deadbeef", "2.1.3");
16
- }).toThrowError(
17
- "SDK version 2.1.3 is incompatible with prover version 1.2.3-dev-123456-deadbeef",
18
- );
19
- });
20
-
21
- test("throws if major version is 0 and minor version mismatches", () => {
22
- expect(() => {
23
- checkVersionCompatibility("0.2.3", "0.1.3");
24
- }).toThrowError(
25
- "SDK version 0.1.3 is incompatible with prover version 0.2.3",
26
- );
27
- });
28
-
29
- test("does not throw if major and minor versions match", () => {
30
- expect(() => {
31
- checkVersionCompatibility("1.2.3", "1.2.13");
32
- }).not.toThrow();
33
- });
34
-
35
- test("does not throw if major version is >0 and minor mismatches", () => {
36
- expect(() => {
37
- checkVersionCompatibility("1.2.3", "1.5.8");
38
- }).not.toThrow();
39
- });
40
-
41
- test("does not throw if major version is 0 and minor matches", () => {
42
- expect(() => {
43
- checkVersionCompatibility("0.2.3", "0.2.7");
44
- }).not.toThrow();
45
- });
46
-
47
- test("works for semvers with metadata after dash", () => {
48
- expect(() => {
49
- checkVersionCompatibility("0.2.3-dev-123456-deadbeef", "0.2.7");
50
- }).not.toThrow();
51
- });
52
- });
@@ -1,31 +0,0 @@
1
- import { parse, type SemVer } from "semver";
2
- import { VersionError } from "../lib/errors";
3
-
4
- function safeParseSemver(semverString: string): SemVer {
5
- const parsed = parse(semverString);
6
- if (parsed === null) {
7
- throw new VersionError(`Invalid semver string: ${semverString}`);
8
- }
9
- return parsed;
10
- }
11
-
12
- export function checkVersionCompatibility(
13
- proverSemver: string,
14
- sdkSemver: string,
15
- ) {
16
- const { major: proverMajor, minor: proverMinor } =
17
- safeParseSemver(proverSemver);
18
- const { major: sdkMajor, minor: sdkMinor } = safeParseSemver(sdkSemver);
19
-
20
- if (proverMajor !== sdkMajor) {
21
- throw new VersionError(
22
- `SDK version ${sdkSemver} is incompatible with prover version ${proverSemver}`,
23
- );
24
- }
25
-
26
- if (proverMajor === 0 && proverMinor !== sdkMinor) {
27
- throw new VersionError(
28
- `SDK version ${sdkSemver} is incompatible with prover version ${proverSemver}`,
29
- );
30
- }
31
- }
package/src/api/v_call.ts DELETED
@@ -1,58 +0,0 @@
1
- import {
2
- type CallContext,
3
- type CallParams,
4
- type VCallResponse,
5
- } from "./lib/types/vlayer";
6
- import { parseVCallResponseError } from "./lib/errors";
7
- import debug from "debug";
8
-
9
- const log = debug("vlayer:v_call");
10
-
11
- function v_callBody(call: CallParams, context: CallContext) {
12
- console.log("call", call);
13
- console.log("context", context);
14
- return {
15
- method: "v_call",
16
- params: [call, context],
17
- id: 1,
18
- jsonrpc: "2.0",
19
- };
20
- }
21
-
22
- export async function v_call(
23
- call: CallParams,
24
- context: CallContext,
25
- url: string = "http://127.0.0.1:3000",
26
- token?: string,
27
- ): Promise<VCallResponse> {
28
- const headers: Record<string, string> = {
29
- "Content-Type": "application/json",
30
- };
31
- if (token !== undefined) {
32
- headers["Authorization"] = "Bearer " + token;
33
- }
34
- const response = await fetch(url, {
35
- method: "POST",
36
- body: JSON.stringify(v_callBody(call, context)),
37
- headers,
38
- });
39
- log("response", response);
40
- if (!response.ok) {
41
- throw new Error(`HTTP error! status: ${response.status}`);
42
- }
43
- const response_json = await response.json();
44
- log("response_json", response_json);
45
- assertObject(response_json);
46
- if ("error" in response_json) {
47
- throw parseVCallResponseError(
48
- response_json.error as { message: string | undefined },
49
- );
50
- }
51
- return response_json as Promise<VCallResponse>;
52
- }
53
-
54
- function assertObject(x: unknown): asserts x is object {
55
- if (typeof x !== "object") {
56
- throw new Error("Expected object");
57
- }
58
- }
@@ -1,48 +0,0 @@
1
- import {
2
- type VGetProofReceiptParams,
3
- type VGetProofReceiptResponse,
4
- } from "./lib/types/vlayer";
5
- import { parseVCallResponseError } from "./lib/errors";
6
- import { vGetProofReceiptSchema } from "./lib/types/vlayer";
7
- import debug from "debug";
8
-
9
- const log = debug("vlayer:v_getProofReceipt");
10
-
11
- function v_getProofReceiptBody(params: VGetProofReceiptParams) {
12
- return {
13
- method: "v_getProofReceipt",
14
- params: params,
15
- id: 1,
16
- jsonrpc: "2.0",
17
- };
18
- }
19
-
20
- export async function v_getProofReceipt(
21
- params: VGetProofReceiptParams,
22
- url: string = "http://127.0.0.1:3000",
23
- ): Promise<VGetProofReceiptResponse> {
24
- const response = await fetch(url, {
25
- method: "POST",
26
- body: JSON.stringify(v_getProofReceiptBody(params)),
27
- headers: { "Content-Type": "application/json" },
28
- });
29
- log("response", response);
30
- if (!response.ok) {
31
- throw new Error(`HTTP error! status: ${response.status}`);
32
- }
33
- const response_json = await response.json();
34
- log("response_json", response_json);
35
- assertObject(response_json);
36
- if ("error" in response_json) {
37
- throw parseVCallResponseError(
38
- response_json.error as { message: string | undefined },
39
- );
40
- }
41
- return vGetProofReceiptSchema.parse(response_json);
42
- }
43
-
44
- function assertObject(x: unknown): asserts x is object {
45
- if (typeof x !== "object") {
46
- throw new Error("Expected object");
47
- }
48
- }
@@ -1,68 +0,0 @@
1
- import debug from "debug";
2
-
3
- const log = debug("vlayer:v_versions");
4
-
5
- const v_versionsBody = {
6
- method: "v_versions",
7
- params: [],
8
- id: 1,
9
- jsonrpc: "2.0",
10
- };
11
-
12
- interface VVersionsResponseResult {
13
- call_guest_id: string;
14
- chain_guest_id: string;
15
- api_version: string;
16
- }
17
-
18
- export interface VVersionsResponse {
19
- jsonrpc: string;
20
- result: VVersionsResponseResult;
21
- id: number;
22
- }
23
-
24
- export async function v_versions(
25
- url: string = "http://127.0.0.1:3000",
26
- ): Promise<VVersionsResponse> {
27
- const response = await fetch(url, {
28
- method: "POST",
29
- body: JSON.stringify(v_versionsBody),
30
- headers: { "Content-Type": "application/json" },
31
- });
32
- log("response", response);
33
- if (!response.ok) {
34
- throw new Error(`HTTP error! status: ${response.status}`);
35
- }
36
- const response_json = await response.json();
37
- assertResponseObject(response_json);
38
- return response_json;
39
- }
40
-
41
- function isFieldAString(
42
- x: object,
43
- field: keyof VVersionsResponseResult,
44
- ): boolean {
45
- return (
46
- field in x && typeof (x as VVersionsResponseResult)[field] === "string"
47
- );
48
- }
49
-
50
- function assertResponseObject(x: unknown): asserts x is VVersionsResponse {
51
- if (!x || typeof x !== "object") {
52
- throw new Error("Expected object");
53
- }
54
- if (!("result" in x) || !x.result || typeof x.result !== "object") {
55
- throw new Error(
56
- `Unexpected \`v_versions\` response: ${JSON.stringify(x, null, 2)}`,
57
- );
58
- }
59
- if (
60
- !isFieldAString(x.result, "call_guest_id") ||
61
- !isFieldAString(x.result, "chain_guest_id") ||
62
- !isFieldAString(x.result, "api_version")
63
- ) {
64
- throw new Error(
65
- `Unexpected \`v_versions\` response: ${JSON.stringify(x, null, 2)}`,
66
- );
67
- }
68
- }
@@ -1,15 +0,0 @@
1
- import {
2
- type WebProofRequest,
3
- type WebProofRequestInput,
4
- } from "../lib/types/webProofProvider";
5
-
6
- export const createWebProofRequest = ({
7
- logoUrl,
8
- steps,
9
- }: WebProofRequestInput) => {
10
- return {
11
- logoUrl,
12
- steps,
13
- isWebProof: true,
14
- } as WebProofRequest;
15
- };
@@ -1,3 +0,0 @@
1
- export * from "./createWebProofRequest";
2
- export * from "./steps";
3
- export * from "./providers";