@corpus-core/colibri-stateless 0.5.1 → 0.6.0
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/README.md +19 -10
- package/c4w.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +19 -10
- package/package.json +1 -1
- package/transactionVerifier.d.ts +2 -2
- package/transactionVerifier.js +2 -2
- package/types.d.ts +2 -1
package/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export default class C4Client {
|
|
|
35
35
|
private subscriptionManager;
|
|
36
36
|
private static readonly CRITICAL_METHODS;
|
|
37
37
|
constructor(config?: Partial<C4Config>);
|
|
38
|
-
private
|
|
38
|
+
private getProverConfig;
|
|
39
39
|
private get flags();
|
|
40
40
|
/**
|
|
41
41
|
* checks, whether the rpc-method is supported or proofable.
|
package/index.js
CHANGED
|
@@ -66,7 +66,11 @@ function log(msg) {
|
|
|
66
66
|
}
|
|
67
67
|
export async function handle_request(req, conf) {
|
|
68
68
|
const free_buffers = [];
|
|
69
|
-
const servers = req.type == "
|
|
69
|
+
const servers = req.type == "checkpointz"
|
|
70
|
+
? (conf.checkpointz || [])
|
|
71
|
+
: (req.type == "beacon_api"
|
|
72
|
+
? ((conf.prover && conf.prover.length) ? conf.prover : conf.beacon_apis)
|
|
73
|
+
: conf.rpcs);
|
|
70
74
|
const c4w = await getC4w();
|
|
71
75
|
let path = (req.type == 'eth_rpc' && req.payload)
|
|
72
76
|
? `rpc: ${req.payload?.method}(${req.payload?.params.join(',')})`
|
|
@@ -136,28 +140,32 @@ const default_config = {
|
|
|
136
140
|
alias: ["mainnet", "eth", "0x1"],
|
|
137
141
|
beacon_apis: ["https://lodestar-mainnet.chainsafe.io"],
|
|
138
142
|
rpcs: ["https://rpc.ankr.com/eth"],
|
|
139
|
-
|
|
143
|
+
prover: ["https://mainnet1.colibri-proof.tech"],
|
|
144
|
+
checkpointz: ["https://sync-mainnet.beaconcha.in", "https://beaconstate.info", "https://sync.invis.tools", "https://beaconstate.ethstaker.cc"],
|
|
140
145
|
pollingInterval: 12000,
|
|
141
146
|
},
|
|
142
147
|
'11155111': {
|
|
143
148
|
alias: ["sepolia", "0xaa36a7"],
|
|
144
149
|
beacon_apis: ["https://ethereum-sepolia-beacon-api.publicnode.com"],
|
|
145
150
|
rpcs: ["https://ethereum-sepolia-rpc.publicnode.com"],
|
|
146
|
-
|
|
151
|
+
prover: ["https://sepolia.colibri-proof.tech"],
|
|
152
|
+
checkpointz: [], // No public checkpointz for Sepolia yet
|
|
147
153
|
pollingInterval: 12000,
|
|
148
154
|
},
|
|
149
155
|
'100': {
|
|
150
156
|
alias: ["gnosis", "xdai", "0x64"],
|
|
151
157
|
beacon_apis: ["https://gnosis.colibri-proof.tech"],
|
|
152
158
|
rpcs: ["https://rpc.ankr.com/gnosis"],
|
|
153
|
-
|
|
159
|
+
prover: ["https://gnosis.colibri-proof.tech"],
|
|
160
|
+
checkpointz: [], // TODO: Add Gnosis checkpointz servers
|
|
154
161
|
pollingInterval: 5000,
|
|
155
162
|
},
|
|
156
163
|
'10200': {
|
|
157
164
|
alias: ["chiado", "0x27d8"],
|
|
158
165
|
beacon_apis: ["https://gnosis-chiado-beacon-api.publicnode.com"],
|
|
159
166
|
rpcs: ["https://gnosis-chiado-rpc.publicnode.com"],
|
|
160
|
-
|
|
167
|
+
prover: ["https://chiado.colibri-proof.tech"],
|
|
168
|
+
checkpointz: [], // No public checkpointz for Chiado yet
|
|
161
169
|
pollingInterval: 5000,
|
|
162
170
|
},
|
|
163
171
|
};
|
|
@@ -208,12 +216,13 @@ export default class C4Client {
|
|
|
208
216
|
trusted_block_hashes: [],
|
|
209
217
|
rpcs: chain_config.rpcs || [],
|
|
210
218
|
beacon_apis: chain_config.beacon_apis || [],
|
|
211
|
-
|
|
219
|
+
prover: chain_config.prover || [],
|
|
220
|
+
checkpointz: chain_config.checkpointz || [],
|
|
212
221
|
...config, // User config overrides defaults
|
|
213
222
|
chainId,
|
|
214
223
|
};
|
|
215
224
|
// Schutz vor Config-Manipulation anwenden
|
|
216
|
-
PrototypeProtection.protectConfig(baseConfig, ['rpcs', 'beacon_apis', '
|
|
225
|
+
PrototypeProtection.protectConfig(baseConfig, ['rpcs', 'beacon_apis', 'prover', 'checkpointz']);
|
|
217
226
|
this.config = baseConfig;
|
|
218
227
|
if (!this.config.warningHandler)
|
|
219
228
|
this.config.warningHandler = async (req, message) => console.warn(message);
|
|
@@ -227,7 +236,7 @@ export default class C4Client {
|
|
|
227
236
|
pollingInterval: this.config.pollingInterval || chain_conf(this.config, this.config.chainId)?.pollingInterval || 12000
|
|
228
237
|
});
|
|
229
238
|
}
|
|
230
|
-
async
|
|
239
|
+
async getProverConfig() {
|
|
231
240
|
const c4w = await getC4w();
|
|
232
241
|
if (!c4w.storage)
|
|
233
242
|
return '0x';
|
|
@@ -341,8 +350,8 @@ export default class C4Client {
|
|
|
341
350
|
if (this.config.verify && !this.config.verify(method, args)) {
|
|
342
351
|
return await fetch_rpc(this.config.rpcs, { method, params: args }, false);
|
|
343
352
|
}
|
|
344
|
-
const proof = this.config.
|
|
345
|
-
? await fetch_rpc(this.config.
|
|
353
|
+
const proof = this.config.prover && this.config.prover.length
|
|
354
|
+
? await fetch_rpc(this.config.prover, { method, params: cleanup_args(method, args), c4: await this.getProverConfig() }, true)
|
|
346
355
|
: await this.createProof(method, args);
|
|
347
356
|
return this.verifyProof(method, args, proof);
|
|
348
357
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corpus-core/colibri-stateless",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Colibri is a stateless and trustless ethereum client, which is optimized for the mobile apps or embedded devices, because it does not hols the state, but verifies on demand.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
package/transactionVerifier.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { MethodType as C4MethodType } from './types.js';
|
|
|
26
26
|
*
|
|
27
27
|
* Implementiert eine Sicherheitsschicht gegen NPM Supply-Chain-Attacks:
|
|
28
28
|
* 1. Transaction über fallbackProvider signieren lassen
|
|
29
|
-
* 2. Signierte Transaction mit
|
|
29
|
+
* 2. Signierte Transaction mit colibri_decodeTransaction dekodieren
|
|
30
30
|
* 3. Dekodierte Parameter mit Original vergleichen
|
|
31
31
|
* 4. Bei Übereinstimmung: eth_sendRawTransaction ausführen
|
|
32
32
|
*/
|
|
@@ -40,7 +40,7 @@ export declare class TransactionVerifier {
|
|
|
40
40
|
/**
|
|
41
41
|
* Verifizierte Ausführung von eth_sendTransaction
|
|
42
42
|
* 1. Transaction über fallbackProvider signieren lassen
|
|
43
|
-
* 2. Signierte Transaction mit
|
|
43
|
+
* 2. Signierte Transaction mit colibri_decodeTransaction dekodieren
|
|
44
44
|
* 3. Dekodierte Parameter mit Original vergleichen
|
|
45
45
|
* 4. eth_sendRawTransaction ausführen
|
|
46
46
|
*/
|
package/transactionVerifier.js
CHANGED
|
@@ -25,7 +25,7 @@ export class TransactionVerifier {
|
|
|
25
25
|
/**
|
|
26
26
|
* Verifizierte Ausführung von eth_sendTransaction
|
|
27
27
|
* 1. Transaction über fallbackProvider signieren lassen
|
|
28
|
-
* 2. Signierte Transaction mit
|
|
28
|
+
* 2. Signierte Transaction mit colibri_decodeTransaction dekodieren
|
|
29
29
|
* 3. Dekodierte Parameter mit Original vergleichen
|
|
30
30
|
* 4. eth_sendRawTransaction ausführen
|
|
31
31
|
*/
|
|
@@ -42,7 +42,7 @@ export class TransactionVerifier {
|
|
|
42
42
|
params: [txObject]
|
|
43
43
|
});
|
|
44
44
|
// 2. Signierte Transaction dekodieren
|
|
45
|
-
const decodedTx = await rpcMethod('
|
|
45
|
+
const decodedTx = await rpcMethod('colibri_decodeTransaction', [signedRawTx], C4MethodType.LOCAL);
|
|
46
46
|
// 3. Dekodierte Parameter mit Original vergleichen
|
|
47
47
|
const isValid = this.compareTransactionParameters(txObject, decodedTx, config);
|
|
48
48
|
if (!isValid) {
|
package/types.d.ts
CHANGED
|
@@ -52,7 +52,8 @@ export interface Cache {
|
|
|
52
52
|
export interface ChainConfig {
|
|
53
53
|
beacon_apis: string[];
|
|
54
54
|
rpcs: string[];
|
|
55
|
-
|
|
55
|
+
prover?: string[];
|
|
56
|
+
checkpointz?: string[];
|
|
56
57
|
trusted_block_hashes: string[];
|
|
57
58
|
verify?: (method: string, args: any[]) => boolean;
|
|
58
59
|
pollingInterval?: number;
|