@vlayer/sdk 0.1.0-nightly-20241015-4fe37fa → 0.1.0-nightly-20241015-013f55a

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,175 @@
1
+ # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2
+
3
+ # Logs
4
+
5
+ logs
6
+ _.log
7
+ npm-debug.log_
8
+ yarn-debug.log*
9
+ yarn-error.log*
10
+ lerna-debug.log*
11
+ .pnpm-debug.log*
12
+
13
+ # Caches
14
+
15
+ .cache
16
+
17
+ # Diagnostic reports (https://nodejs.org/api/report.html)
18
+
19
+ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20
+
21
+ # Runtime data
22
+
23
+ pids
24
+ _.pid
25
+ _.seed
26
+ *.pid.lock
27
+
28
+ # Directory for instrumented libs generated by jscoverage/JSCover
29
+
30
+ lib-cov
31
+
32
+ # Coverage directory used by tools like istanbul
33
+
34
+ coverage
35
+ *.lcov
36
+
37
+ # nyc test coverage
38
+
39
+ .nyc_output
40
+
41
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42
+
43
+ .grunt
44
+
45
+ # Bower dependency directory (https://bower.io/)
46
+
47
+ bower_components
48
+
49
+ # node-waf configuration
50
+
51
+ .lock-wscript
52
+
53
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
54
+
55
+ build/Release
56
+
57
+ # Dependency directories
58
+
59
+ node_modules/
60
+ jspm_packages/
61
+
62
+ # Snowpack dependency directory (https://snowpack.dev/)
63
+
64
+ web_modules/
65
+
66
+ # TypeScript cache
67
+
68
+ *.tsbuildinfo
69
+
70
+ # Optional npm cache directory
71
+
72
+ .npm
73
+
74
+ # Optional eslint cache
75
+
76
+ .eslintcache
77
+
78
+ # Optional stylelint cache
79
+
80
+ .stylelintcache
81
+
82
+ # Microbundle cache
83
+
84
+ .rpt2_cache/
85
+ .rts2_cache_cjs/
86
+ .rts2_cache_es/
87
+ .rts2_cache_umd/
88
+
89
+ # Optional REPL history
90
+
91
+ .node_repl_history
92
+
93
+ # Output of 'npm pack'
94
+
95
+ *.tgz
96
+
97
+ # Yarn Integrity file
98
+
99
+ .yarn-integrity
100
+
101
+ # dotenv environment variable files
102
+
103
+ .env
104
+ .env.development.local
105
+ .env.test.local
106
+ .env.production.local
107
+ .env.local
108
+
109
+ # parcel-bundler cache (https://parceljs.org/)
110
+
111
+ .parcel-cache
112
+
113
+ # Next.js build output
114
+
115
+ .next
116
+ out
117
+
118
+ # Nuxt.js build / generate output
119
+
120
+ .nuxt
121
+ dist
122
+
123
+ # Gatsby files
124
+
125
+ # Comment in the public line in if your project uses Gatsby and not Next.js
126
+
127
+ # https://nextjs.org/blog/next-9-1#public-directory-support
128
+
129
+ # public
130
+
131
+ # vuepress build output
132
+
133
+ .vuepress/dist
134
+
135
+ # vuepress v2.x temp and cache directory
136
+
137
+ .temp
138
+
139
+ # Docusaurus cache and generated files
140
+
141
+ .docusaurus
142
+
143
+ # Serverless directories
144
+
145
+ .serverless/
146
+
147
+ # FuseBox cache
148
+
149
+ .fusebox/
150
+
151
+ # DynamoDB Local files
152
+
153
+ .dynamodb/
154
+
155
+ # TernJS port file
156
+
157
+ .tern-port
158
+
159
+ # Stores VSCode versions used for testing VSCode extensions
160
+
161
+ .vscode-test
162
+
163
+ # yarn v2
164
+
165
+ .yarn/cache
166
+ .yarn/unplugged
167
+ .yarn/build-state.yml
168
+ .yarn/install-state.gz
169
+ .pnp.*
170
+
171
+ # IntelliJ based IDEs
172
+ .idea
173
+
174
+ # Finder (MacOS) folder config
175
+ .DS_Store
@@ -0,0 +1,4 @@
1
+ # @vlayer/web-proof-commons
2
+
3
+ `web-proof-commons` is a TypeScript package that provides common type definitions and utilities shared between the
4
+ `browser-extension` and `@vlayer/sdk` projects.
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@vlayer/web-proof-commons",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "exports": "./src/index.ts",
6
+ "type": "module",
7
+ "scripts": {
8
+ "lint": "eslint lib",
9
+ "lint:fix": "eslint --fix lib"
10
+ },
11
+ "devDependencies": {
12
+ "@types/bun": "latest"
13
+ },
14
+ "peerDependencies": {
15
+ "typescript": "^5.0.0"
16
+ }
17
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./types/message.ts";
2
+ export * from "./types/webProof.ts";
3
+ export * from "./utils";
@@ -0,0 +1,71 @@
1
+ import type { Branded } from "../utils.ts";
2
+ import type { WebProof } from "./webProof.ts";
3
+
4
+ export const EXTENSION_STEP = {
5
+ expectUrl: "expectUrl",
6
+ startPage: "startPage",
7
+ notarize: "notarize",
8
+ } as const;
9
+
10
+ export type ExtensionStep =
11
+ (typeof EXTENSION_STEP)[keyof typeof EXTENSION_STEP];
12
+
13
+ export const enum ExtensionAction {
14
+ RequestWebProof,
15
+ }
16
+
17
+ export type MessageToExtension = {
18
+ action: ExtensionAction;
19
+ payload: WebProverSessionConfig;
20
+ };
21
+
22
+ export const enum ExtensionMessageType {
23
+ ProofDone = "ProofDone",
24
+ ProofError = "ProofError",
25
+ RedirectBack = "RedirectBack",
26
+ }
27
+
28
+ export type ExtensionMessage =
29
+ | { type: ExtensionMessageType.ProofDone; proof: WebProof }
30
+ | { type: ExtensionMessageType.ProofError; error: string }
31
+ | { type: ExtensionMessageType.RedirectBack };
32
+
33
+ export type WebProverSessionConfig = {
34
+ notaryUrl: string;
35
+ wsProxyUrl: string;
36
+ logoUrl: string;
37
+ steps: WebProofStep[];
38
+ };
39
+
40
+ export type WebProofStep =
41
+ | WebProofStepNotarize
42
+ | WebProofStepExpectUrl
43
+ | WebProofStepStartPage;
44
+
45
+ export type WebProofStepNotarize = Branded<
46
+ {
47
+ url: string;
48
+ method: string;
49
+ label: string;
50
+ step: typeof EXTENSION_STEP.notarize;
51
+ },
52
+ "notarize"
53
+ >;
54
+
55
+ export type WebProofStepExpectUrl = Branded<
56
+ {
57
+ url: string;
58
+ label: string;
59
+ step: typeof EXTENSION_STEP.expectUrl;
60
+ },
61
+ "expectUrl"
62
+ >;
63
+
64
+ export type WebProofStepStartPage = Branded<
65
+ {
66
+ url: string;
67
+ label: string;
68
+ step: typeof EXTENSION_STEP.startPage;
69
+ },
70
+ "startPage"
71
+ >;
@@ -0,0 +1,111 @@
1
+ // NOTE : this is copied from tlsn-js 5.4
2
+ // for some reason newest versions doesn't export this type (clarification is in progress)
3
+ // probably it should be reexported from tlsn-js
4
+
5
+ export interface WebProof {
6
+ session: Session;
7
+ substrings: Substrings;
8
+ notaryUrl: string;
9
+ }
10
+
11
+ export interface Session {
12
+ header: Header;
13
+ signature: Signature;
14
+ session_info: SessionInfo;
15
+ }
16
+
17
+ export interface SessionInfo {
18
+ server_name: ServerName;
19
+ handshake_decommitment: HandshakeDecommitment;
20
+ }
21
+
22
+ export interface HandshakeDecommitment {
23
+ nonce: number[];
24
+ data: Data;
25
+ }
26
+
27
+ export interface Data {
28
+ server_cert_details: ServerCERTDetails;
29
+ server_kx_details: ServerKxDetails;
30
+ client_random: number[];
31
+ server_random: number[];
32
+ }
33
+
34
+ export interface ServerCERTDetails {
35
+ cert_chain: Array<number[]>;
36
+ ocsp_response: number[];
37
+ scts: null;
38
+ }
39
+
40
+ export interface ServerKxDetails {
41
+ kx_params: number[];
42
+ kx_sig: KxSig;
43
+ }
44
+
45
+ export interface KxSig {
46
+ scheme: string;
47
+ sig: number[];
48
+ }
49
+
50
+ export interface Header {
51
+ encoder_seed: number[];
52
+ merkle_root: number[];
53
+ sent_len: number;
54
+ recv_len: number;
55
+ handshake_summary: HandshakeSummary;
56
+ }
57
+
58
+ export interface HandshakeSummary {
59
+ time: number;
60
+ server_public_key: ServerPublicKey;
61
+ handshake_commitment: number[];
62
+ }
63
+
64
+ export interface ServerPublicKey {
65
+ group: string;
66
+ key: number[];
67
+ }
68
+
69
+ export interface ServerName {
70
+ Dns: string;
71
+ }
72
+
73
+ export interface Signature {
74
+ P256: string;
75
+ }
76
+
77
+ export interface Substrings {
78
+ openings: { [key: string]: Opening[] };
79
+ inclusion_proof: InclusionProof;
80
+ }
81
+
82
+ export interface InclusionProof {
83
+ proof: unknown[];
84
+ total_leaves: number;
85
+ }
86
+
87
+ export interface Opening {
88
+ kind?: string;
89
+ ranges?: Range[];
90
+ direction?: string;
91
+ Blake3?: Blake3;
92
+ }
93
+
94
+ export interface Blake3 {
95
+ data: number[];
96
+ nonce: number[];
97
+ }
98
+
99
+ export interface Range {
100
+ start: number;
101
+ end: number;
102
+ }
103
+ export const assertWebProof = function (candidate: {
104
+ notaryUrl?: string;
105
+ }): asserts candidate is WebProof {
106
+ //for now only thing we check is notary url
107
+ //TODO: implement later once we known the conteact with tlsn-js
108
+ if (!candidate.notaryUrl) {
109
+ throw new Error("Missing required parameter");
110
+ }
111
+ };
@@ -0,0 +1,12 @@
1
+ declare const __brand: unique symbol;
2
+ type Brand<B> = { [__brand]: B };
3
+ export type Branded<T, B> = T & Brand<B>;
4
+
5
+ export function isDefined<T>(
6
+ value: T | undefined,
7
+ message: string = "Value is undefined",
8
+ ): asserts value is T {
9
+ if (value === undefined) {
10
+ throw new Error(message);
11
+ }
12
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+
22
+ // Some stricter flags (disabled by default)
23
+ "noUnusedLocals": false,
24
+ "noUnusedParameters": false,
25
+ "noPropertyAccessFromIndexSignature": false
26
+ }
27
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@vlayer/sdk",
3
3
  "type": "module",
4
- "module": "src/index.ts",
5
- "version": "0.1.0-nightly-20241015-4fe37fa",
4
+ "exports": "./src/index.ts",
5
+ "version": "0.1.0-nightly-20241015-013f55a",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
8
8
  "build": "npm run gen:types",
@@ -22,7 +22,7 @@
22
22
  "dns-over-http-resolver": "^3.0.3",
23
23
  "postal-mime": "^2.3.2",
24
24
  "viem": "^2.21.0",
25
- "@vlayer/web-proof-commons": "file:../../web-proof-commons"
25
+ "@vlayer/web-proof-commons": "file:../web-proof-commons"
26
26
  },
27
27
  "bundleDependencies": [
28
28
  "@vlayer/web-proof-commons"
@@ -13,13 +13,16 @@ import {
13
13
  } from "viem";
14
14
 
15
15
  import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";
16
- import { foundry } from "viem/chains";
16
+ import { foundry, optimismSepolia } from "viem/chains";
17
17
 
18
18
  import type { ContractSpec, ContractArg } from "types/ethereum";
19
19
 
20
- const rpcUrls: Map<number, HttpTransport> = new Map([[foundry.id, http()]]);
20
+ const rpcUrls: Map<number, HttpTransport> = new Map([
21
+ [foundry.id, http()],
22
+ [optimismSepolia.id, http("https://sepolia.optimism.io")],
23
+ ]);
21
24
 
22
- export const chainIds = [foundry.id];
25
+ export const chainIds = [foundry.id, optimismSepolia.id];
23
26
 
24
27
  export function createAnvilClient(
25
28
  chainId: number = foundry.id,
@@ -1,4 +1,3 @@
1
1
  export * from "./ethereum";
2
- export * from "@vlayer/web-proof-commons/lib/types/webProof";
3
2
  export * from "./vlayer";
4
3
  export * from "./webProofProvider";