@canister-software/consensus-cli 0.1.0-beta.3 → 0.1.0-beta.4

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/index.d.ts ADDED
@@ -0,0 +1,134 @@
1
+ export interface ProxyClientOptions {
2
+ mode?: "inclusive" | "exclusive";
3
+ routes?: string[];
4
+ matchSubroutes?: boolean;
5
+ strategy?: "auto" | "manual";
6
+ cache_ttl?: number;
7
+ verbose?: boolean;
8
+ node_region?: string;
9
+ node_domain?: string;
10
+ node_exclude?: string;
11
+ }
12
+
13
+ export interface ProxyClientRequestContext {
14
+ consensus?: {
15
+ strategy?: "auto" | "manual";
16
+ shouldProxy?: boolean;
17
+ fetch?: (
18
+ input: RequestInfo | URL,
19
+ init?: RequestInit,
20
+ perRequestOptions?: Partial<ProxyClientOptions>
21
+ ) => Promise<Response>;
22
+ request?: (
23
+ payload: {
24
+ target_url?: string;
25
+ method?: string;
26
+ headers?: Record<string, string>;
27
+ body?: unknown;
28
+ },
29
+ perRequestOptions?: Partial<ProxyClientOptions>
30
+ ) => Promise<{
31
+ status: number;
32
+ statusText: string;
33
+ headers: Record<string, string>;
34
+ data: unknown;
35
+ meta: unknown;
36
+ }>;
37
+ passthroughFetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | null;
38
+ };
39
+ [key: string]: unknown;
40
+ }
41
+
42
+ export type ProxyClientMiddleware = (
43
+ req: ProxyClientRequestContext,
44
+ res: unknown,
45
+ next: (err?: unknown) => void
46
+ ) => void;
47
+
48
+ export declare function ProxyClient(
49
+ fetchWithPayment: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>,
50
+ options?: ProxyClientOptions
51
+ ): ProxyClientMiddleware;
52
+
53
+ export type ConsensusSocketModel = "hybrid" | "time" | "data";
54
+
55
+ export interface ConsensusSocketTokenParams {
56
+ model?: ConsensusSocketModel;
57
+ minutes?: number;
58
+ megabytes?: number;
59
+ nodeRegion?: string;
60
+ nodeDomain?: string;
61
+ nodeExclude?: string;
62
+ }
63
+
64
+ export interface ConsensusSocketTokenAuth {
65
+ token: string;
66
+ connect_url: string;
67
+ expires_in: number;
68
+ }
69
+
70
+ export interface ConsensusSocketConnectTarget {
71
+ connect_url: string;
72
+ token?: string;
73
+ expires_in?: number;
74
+ }
75
+
76
+ export interface ConsensusSocketCallbacks {
77
+ onOpen?: () => void;
78
+ onMessage?: (data: unknown) => void;
79
+ onClose?: (event?: unknown) => void;
80
+ onError?: (error: unknown) => void;
81
+ }
82
+
83
+ export interface ConsensusSocketSafeResult<T> {
84
+ ok: boolean;
85
+ data?: T;
86
+ error?: unknown;
87
+ }
88
+
89
+ export interface ConsensusSocketSessionState {
90
+ connected: boolean;
91
+ reconnecting: boolean;
92
+ closedByCaller: boolean;
93
+ }
94
+
95
+ export interface ConsensusSocketSession {
96
+ send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
97
+ close(code?: number, reason?: string): void;
98
+ on(event: "open" | "message" | "close" | "error", handler: (...args: unknown[]) => void): void;
99
+ off(event: "open" | "message" | "close" | "error", handler: (...args: unknown[]) => void): void;
100
+ getState(): ConsensusSocketSessionState;
101
+ }
102
+
103
+ export interface ConsensusSocketClientOptions {
104
+ webSocketFactory?: new (...args: unknown[]) => unknown;
105
+ openTimeoutMs?: number;
106
+ reconnectIntervalMs?: number;
107
+ defaults?: ConsensusSocketTokenParams;
108
+ }
109
+
110
+ export interface ConsensusSocketClient {
111
+ requestToken(
112
+ params?: ConsensusSocketTokenParams,
113
+ options?: { safe?: false }
114
+ ): Promise<ConsensusSocketTokenAuth>;
115
+ requestToken(
116
+ params: ConsensusSocketTokenParams | undefined,
117
+ options: { safe: true }
118
+ ): Promise<ConsensusSocketSafeResult<ConsensusSocketTokenAuth>>;
119
+ connect(
120
+ connectUrlOrAuth: string | ConsensusSocketConnectTarget,
121
+ callbacks?: ConsensusSocketCallbacks,
122
+ options?: { safe?: false }
123
+ ): Promise<ConsensusSocketSession>;
124
+ connect(
125
+ connectUrlOrAuth: string | ConsensusSocketConnectTarget,
126
+ callbacks: ConsensusSocketCallbacks | undefined,
127
+ options: { safe: true }
128
+ ): Promise<ConsensusSocketSafeResult<ConsensusSocketSession>>;
129
+ }
130
+
131
+ export declare function SocketClient(
132
+ fetchWithPayment: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>,
133
+ options?: ConsensusSocketClientOptions
134
+ ): ConsensusSocketClient;
package/package.json CHANGED
@@ -1,18 +1,32 @@
1
1
  {
2
2
  "name": "@canister-software/consensus-cli",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.1.0-beta.4",
4
4
  "description": "Consensus SDK for interacting with the Consensus protocol",
5
5
  "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./cli": "./bin/consensus.js"
14
+ },
6
15
  "bin": {
7
16
  "consensus": "./bin/consensus.js"
8
17
  },
9
18
  "scripts": {
10
19
  "consensus": "node bin/consensus.js",
11
20
  "setup": "node bin/consensus.js setup",
12
- "reset": "node bin/consensus.js setup --force"
21
+ "reset": "node bin/consensus.js setup --force",
22
+ "build": "tsc -p tsconfig.json",
23
+ "prepack": "npm run build"
13
24
  },
14
25
  "dependencies": {
15
26
  "@coinbase/cdp-sdk": "^1.25.0",
27
+ "@scure/base": "^2.0.0",
28
+ "@solana/kit": "^5.1.0",
29
+ "@x402/core": "^2.3.1",
16
30
  "chalk": "^5.4.1",
17
31
  "chalk-animation": "^2.0.3",
18
32
  "dotenv": "^16.4.5",
@@ -22,6 +36,10 @@
22
36
  "ora": "^8.2.0",
23
37
  "viem": "^2.31.7"
24
38
  },
39
+ "devDependencies": {
40
+ "@types/node": "^22.15.30",
41
+ "typescript": "^5.8.3"
42
+ },
25
43
  "keywords": [
26
44
  "consensus",
27
45
  "api",
@@ -37,9 +55,11 @@
37
55
  "node": ">=18.0.0"
38
56
  },
39
57
  "files": [
58
+ "dist/",
59
+ "index.d.ts",
40
60
  "bin/",
41
61
  "README.md",
42
62
  "LICENSE",
43
- "assets/setup.gif"
63
+ "assets/"
44
64
  ]
45
65
  }
package/assets/setup.gif DELETED
Binary file