@m2msentinel/sdk 1.2.2 → 1.2.5
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/LICENSE +21 -0
- package/README.md +106 -100
- package/agent_adapter.js +1 -1
- package/base_account_paymaster_guard.js +869 -0
- package/index.d.ts +237 -1
- package/index.js +6 -1
- package/mcp_server.js +2 -2
- package/package.json +15 -4
- package/typescript/base_account_paymaster_guard.ts +264 -0
- package/typescript/index.ts +12 -0
- package/typescript/package-lock.json +50 -0
- package/typescript/package.json +6 -2
- package/typescript/tsconfig.json +13 -0
- package/typescript/x402.ts +1 -1
- package/x402_signer.js +1 -1
package/index.d.ts
CHANGED
|
@@ -14,6 +14,190 @@ export interface RecoveryChallengeOptions {
|
|
|
14
14
|
txHash?: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export interface TransactionPreflightRequest {
|
|
18
|
+
chainId: number | string;
|
|
19
|
+
to: string;
|
|
20
|
+
data: string;
|
|
21
|
+
from?: string;
|
|
22
|
+
value?: number | string;
|
|
23
|
+
blockNumber?: number | string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A top-level call in the documented EIP-5792 wallet_sendCalls envelope. */
|
|
27
|
+
export interface WalletSendCallsCall {
|
|
28
|
+
to: string;
|
|
29
|
+
data: string;
|
|
30
|
+
/** Base Account uses canonical 0x quantities for call value. */
|
|
31
|
+
value?: string;
|
|
32
|
+
capabilities?: Record<string, Record<string, unknown>>;
|
|
33
|
+
flowControl?: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface WalletSendCallsParams {
|
|
37
|
+
version: '1.0';
|
|
38
|
+
id?: string;
|
|
39
|
+
from: string;
|
|
40
|
+
/** Deliberately restricted to Base's canonical wallet_sendCalls value. */
|
|
41
|
+
chainId: '0x2105';
|
|
42
|
+
atomicRequired?: boolean;
|
|
43
|
+
calls: WalletSendCallsCall[];
|
|
44
|
+
capabilities?: Record<string, Record<string, unknown>>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface WalletSendCallsRequest {
|
|
48
|
+
method: 'wallet_sendCalls';
|
|
49
|
+
params: [WalletSendCallsParams];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface Eip1193Provider {
|
|
53
|
+
request(request: WalletSendCallsRequest): Promise<unknown>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type BaseTrustLevel = 'HIGH_TRUST_PRIMARY' | 'QUORUM_PUBLIC';
|
|
57
|
+
|
|
58
|
+
export interface BaseObservationBlock {
|
|
59
|
+
status: 'PINNED';
|
|
60
|
+
chainId: number | string;
|
|
61
|
+
network: 'eip155:8453';
|
|
62
|
+
blockNumber: number | string;
|
|
63
|
+
blockHash: string;
|
|
64
|
+
blockTag: string;
|
|
65
|
+
trustLevel: BaseTrustLevel;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface BaseSimulationObservation {
|
|
70
|
+
attempted: true;
|
|
71
|
+
trusted: true;
|
|
72
|
+
outcome: 'NOT_ATTEMPTED' | 'SUCCEEDED' | 'REVERTED' | 'UNAVAILABLE' | 'MALFORMED';
|
|
73
|
+
blockTag: string;
|
|
74
|
+
evidenceOnly: true;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface BaseRpcObservation {
|
|
79
|
+
pinnedBlockTag: string;
|
|
80
|
+
stateBearingCallCount: number;
|
|
81
|
+
failedReadCount: 0;
|
|
82
|
+
failures: unknown[];
|
|
83
|
+
calls: BaseRpcObservationCall[];
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface BaseRpcObservationCall {
|
|
88
|
+
method?: string;
|
|
89
|
+
params?: unknown[];
|
|
90
|
+
blockTag?: string | null;
|
|
91
|
+
status?: 'OK' | 'UNSUPPORTED_OPTIONAL_METHOD' | 'EXECUTION_ERROR' | string;
|
|
92
|
+
trustLevel?: BaseTrustLevel | 'DEGRADED_LOW_TRUST';
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface BaseCapabilityEvidence {
|
|
97
|
+
sourceAddress: string;
|
|
98
|
+
executionRole: 'RESOLVED_EXECUTING_CODE' | 'SELECTED_DIAMOND_FACET';
|
|
99
|
+
transactionSelector: string | null;
|
|
100
|
+
dissection: BaseDissection;
|
|
101
|
+
notASafetyGuarantee: true;
|
|
102
|
+
reachability: 'NOT_ESTABLISHED';
|
|
103
|
+
[key: string]: unknown;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface BaseDissectionCapability {
|
|
107
|
+
type: string;
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface BaseDissection {
|
|
112
|
+
isValidContract: true;
|
|
113
|
+
bytecodeSizeBytes: number;
|
|
114
|
+
targetBytecodeHash: string;
|
|
115
|
+
capabilities: BaseDissectionCapability[];
|
|
116
|
+
detectedCapabilities: string[];
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface BaseBytecodeHashes {
|
|
121
|
+
runtimeBytecodeHash: string | null;
|
|
122
|
+
finalTargetBytecodeHash: string;
|
|
123
|
+
facetBytecodeHash: string | null;
|
|
124
|
+
facetBytecodeHashes: unknown[];
|
|
125
|
+
[key: string]: unknown;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface BaseAccountPreflightObservation {
|
|
129
|
+
status: 'SUCCESS';
|
|
130
|
+
operation: 'TRANSACTION_PREFLIGHT_OBSERVATION';
|
|
131
|
+
request: TransactionPreflightRequest;
|
|
132
|
+
selectorHex: string | null;
|
|
133
|
+
surfaceTarget: string;
|
|
134
|
+
resolvedExecutionTarget: string;
|
|
135
|
+
resolution: Record<string, unknown> & { status: 'COMPLETE'; resolutionComplete: true };
|
|
136
|
+
evidenceGrade: true;
|
|
137
|
+
evidenceStatus: 'VERIFIED';
|
|
138
|
+
effectiveTrust: BaseTrustLevel;
|
|
139
|
+
observationBlock: BaseObservationBlock;
|
|
140
|
+
simulationObservation: BaseSimulationObservation;
|
|
141
|
+
rpcObservation: BaseRpcObservation;
|
|
142
|
+
capabilityEvidence: BaseCapabilityEvidence;
|
|
143
|
+
bytecodeHashes: BaseBytecodeHashes;
|
|
144
|
+
notASafetyGuarantee: true;
|
|
145
|
+
reachability: 'NOT_ESTABLISHED';
|
|
146
|
+
limitations: string[];
|
|
147
|
+
conclusion: null;
|
|
148
|
+
[key: string]: unknown;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface BaseAccountObservationIdentity {
|
|
152
|
+
blockNumber: bigint;
|
|
153
|
+
blockTag: string;
|
|
154
|
+
blockHash: string;
|
|
155
|
+
effectiveTrust: BaseTrustLevel;
|
|
156
|
+
blockTrustLevel: BaseTrustLevel;
|
|
157
|
+
finalTargetBytecodeHash: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface BaseAccountGuardContext {
|
|
161
|
+
callIndex: number;
|
|
162
|
+
index: number;
|
|
163
|
+
call: WalletSendCallsCall;
|
|
164
|
+
transaction: TransactionPreflightRequest;
|
|
165
|
+
request: WalletSendCallsRequest;
|
|
166
|
+
params: WalletSendCallsParams;
|
|
167
|
+
[key: string]: unknown;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type BaseAccountCallerPolicyResult =
|
|
171
|
+
| true
|
|
172
|
+
| false
|
|
173
|
+
| null
|
|
174
|
+
| undefined
|
|
175
|
+
| { allow: true; reason?: string }
|
|
176
|
+
| { allow: false; reason?: string };
|
|
177
|
+
|
|
178
|
+
export type BaseAccountCallerPolicy = (
|
|
179
|
+
observation: BaseAccountPreflightObservation,
|
|
180
|
+
context: BaseAccountGuardContext
|
|
181
|
+
) => BaseAccountCallerPolicyResult | Promise<BaseAccountCallerPolicyResult>;
|
|
182
|
+
|
|
183
|
+
export interface GuardWalletSendCallsOptions {
|
|
184
|
+
client: Pick<M2MSentinelClient, 'preflightTransaction'>;
|
|
185
|
+
provider: Eip1193Provider;
|
|
186
|
+
request: WalletSendCallsRequest;
|
|
187
|
+
policy: BaseAccountCallerPolicy;
|
|
188
|
+
context?: Record<string, unknown>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface BaseAccountPaymasterGuardOptions {
|
|
192
|
+
client: Pick<M2MSentinelClient, 'preflightTransaction'>;
|
|
193
|
+
policy: BaseAccountCallerPolicy;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface BaseAccountGuardCallOptions {
|
|
197
|
+
policy?: BaseAccountCallerPolicy;
|
|
198
|
+
context?: Record<string, unknown>;
|
|
199
|
+
}
|
|
200
|
+
|
|
17
201
|
export interface M2MSentinelErrorOptions {
|
|
18
202
|
status?: number;
|
|
19
203
|
body?: unknown;
|
|
@@ -56,6 +240,7 @@ export class M2MSentinelClient {
|
|
|
56
240
|
getCapabilityScore(address: string, options?: M2MSentinelClientOptions): Promise<any>;
|
|
57
241
|
/** Legacy alias. The response is a capability coverage index, not a safety score. */
|
|
58
242
|
getSecurityScore(address: string, options?: M2MSentinelClientOptions): Promise<any>;
|
|
243
|
+
preflightTransaction(transaction: TransactionPreflightRequest, options?: M2MSentinelClientOptions): Promise<any>;
|
|
59
244
|
getGasFees(options?: M2MSentinelClientOptions): Promise<any>;
|
|
60
245
|
getDexMetrics(options?: M2MSentinelClientOptions): Promise<any>;
|
|
61
246
|
getTokenPrice(symbol: string, options?: M2MSentinelClientOptions): Promise<any>;
|
|
@@ -64,6 +249,58 @@ export class M2MSentinelClient {
|
|
|
64
249
|
revokeKey(confirm?: boolean): Promise<any>;
|
|
65
250
|
}
|
|
66
251
|
|
|
252
|
+
export class WalletSendCallsInputError extends TypeError {
|
|
253
|
+
readonly code: 'INVALID_WALLET_SEND_CALLS_INPUT';
|
|
254
|
+
readonly field: string;
|
|
255
|
+
constructor(field: string, message: string);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export class ExecutionIdentityBlockedError extends Error {
|
|
259
|
+
readonly code: string;
|
|
260
|
+
constructor(code: string, message: string);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export const PreflightInputError: typeof WalletSendCallsInputError;
|
|
264
|
+
export const PreflightBlockedError: typeof ExecutionIdentityBlockedError;
|
|
265
|
+
|
|
266
|
+
export const BASE_CHAIN_ID: 8453;
|
|
267
|
+
export const BASE_CHAIN_HEX: '0x2105';
|
|
268
|
+
export const BASE_NETWORK: 'eip155:8453';
|
|
269
|
+
export const MAX_CALLS: number;
|
|
270
|
+
export const MAX_PREFLIGHT_CONCURRENCY: number;
|
|
271
|
+
export const MAX_RPC_OBSERVATION_CALLS: number;
|
|
272
|
+
export const MAX_DATA_BYTES: number;
|
|
273
|
+
|
|
274
|
+
export function isAffirmativePolicyResult(value: unknown): value is true | { allow: true; reason?: string };
|
|
275
|
+
export function validateWalletSendCallsRequest(request: unknown): WalletSendCallsRequest;
|
|
276
|
+
export const normalizeWalletSendCallsRequest: typeof validateWalletSendCallsRequest;
|
|
277
|
+
export function transactionFromCall(params: WalletSendCallsParams, call: WalletSendCallsCall, index?: number): TransactionPreflightRequest;
|
|
278
|
+
export function toPreflightTransaction(params: WalletSendCallsParams, call: WalletSendCallsCall, index?: number): TransactionPreflightRequest;
|
|
279
|
+
export function assertObservationReady(
|
|
280
|
+
observation: unknown,
|
|
281
|
+
transaction: TransactionPreflightRequest
|
|
282
|
+
): BaseAccountObservationIdentity;
|
|
283
|
+
export function guardWalletSendCalls(options: GuardWalletSendCallsOptions): Promise<unknown>;
|
|
284
|
+
export const preflightWalletSendCalls: typeof guardWalletSendCalls;
|
|
285
|
+
export const sendCallsWithPreflight: typeof guardWalletSendCalls;
|
|
286
|
+
export const executeWalletSendCalls: typeof guardWalletSendCalls;
|
|
287
|
+
|
|
288
|
+
export class BaseAccountPaymasterGuard {
|
|
289
|
+
constructor(options: BaseAccountPaymasterGuardOptions);
|
|
290
|
+
request(provider: Eip1193Provider, request: WalletSendCallsRequest, options?: BaseAccountGuardCallOptions): Promise<unknown>;
|
|
291
|
+
sendCalls(provider: Eip1193Provider, request: WalletSendCallsRequest, options?: BaseAccountGuardCallOptions): Promise<unknown>;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export const BaseAccountExecutionGuard: typeof BaseAccountPaymasterGuard;
|
|
295
|
+
export function createBaseAccountPaymasterGuard(options: BaseAccountPaymasterGuardOptions): BaseAccountPaymasterGuard;
|
|
296
|
+
export function createExecutionIdentityGuard(options: BaseAccountPaymasterGuardOptions): BaseAccountPaymasterGuard;
|
|
297
|
+
export function createPublicClient(options: {
|
|
298
|
+
apiKey: string;
|
|
299
|
+
baseUrl?: string;
|
|
300
|
+
timeoutMs?: number;
|
|
301
|
+
sdk?: { M2MSentinelClient: typeof M2MSentinelClient };
|
|
302
|
+
}): M2MSentinelClient;
|
|
303
|
+
|
|
67
304
|
export type SentinelPolicy = (
|
|
68
305
|
analysis: any,
|
|
69
306
|
context: { targetAddress: string; integration: string }
|
|
@@ -110,4 +347,3 @@ export class X402SignerClient {
|
|
|
110
347
|
export function x402SignerClient(options?: X402SignerClientOptions): X402SignerClient;
|
|
111
348
|
export function parsePaymentHeader(value: string | object | null): any;
|
|
112
349
|
export function parsePriceToUnits(priceStr: string | number, decimals?: number): bigint;
|
|
113
|
-
|
package/index.js
CHANGED
|
@@ -128,6 +128,9 @@ class M2MSentinelClient {
|
|
|
128
128
|
getCapabilityScore(address, options) { return this.request('GET', '/v1/security/score/' + encodeURIComponent(address), undefined, options); }
|
|
129
129
|
// Legacy method name; the response is a capability coverage index, not a safety score.
|
|
130
130
|
getSecurityScore(address, options) { return this.request('GET', '/v1/security/score/' + encodeURIComponent(address), undefined, options); }
|
|
131
|
+
preflightTransaction(transaction, options) {
|
|
132
|
+
return this.request('POST', '/v1/transaction/preflight', transaction, options);
|
|
133
|
+
}
|
|
131
134
|
getGasFees(options) { return this.request('GET', '/v1/gas/fees', undefined, options); }
|
|
132
135
|
getDexMetrics(options) { return this.request('GET', '/v1/dex/metrics', undefined, options); }
|
|
133
136
|
getTokenPrice(symbol, options) { return this.request('GET', '/v1/token/price/' + encodeURIComponent(symbol), undefined, options); }
|
|
@@ -173,6 +176,7 @@ function createViemSentinelInterceptor(apiKey, baseUrl, policy) {
|
|
|
173
176
|
|
|
174
177
|
const { M2MSentinelActionProvider, m2mSentinelActionProvider } = require('./agent_adapter.js');
|
|
175
178
|
const { X402SignerClient, x402SignerClient, parsePaymentHeader, parsePriceToUnits } = require('./x402_signer.js');
|
|
179
|
+
const baseAccountPaymasterGuard = require('./base_account_paymaster_guard.js');
|
|
176
180
|
|
|
177
181
|
module.exports = {
|
|
178
182
|
M2MSentinelClient,
|
|
@@ -188,5 +192,6 @@ module.exports = {
|
|
|
188
192
|
X402SignerClient,
|
|
189
193
|
x402SignerClient,
|
|
190
194
|
parsePaymentHeader,
|
|
191
|
-
parsePriceToUnits
|
|
195
|
+
parsePriceToUnits,
|
|
196
|
+
...baseAccountPaymasterGuard
|
|
192
197
|
};
|
package/mcp_server.js
CHANGED
|
@@ -8,7 +8,7 @@ const readline = require('readline');
|
|
|
8
8
|
let BASE_URL = process.env.M2M_SENTINEL_BASE_URL || 'https://api.m2msentinel.com';
|
|
9
9
|
let API_KEY = process.env.M2M_SENTINEL_API_KEY || '';
|
|
10
10
|
const TIMEOUT_MS = Number(process.env.M2M_SENTINEL_TIMEOUT_MS || 30000);
|
|
11
|
-
const VERSION = '1.2.
|
|
11
|
+
const VERSION = '1.2.5';
|
|
12
12
|
|
|
13
13
|
const TOOLS = [
|
|
14
14
|
{
|
|
@@ -387,7 +387,7 @@ async function runCli(args) {
|
|
|
387
387
|
console.log(`Network: Base Mainnet (8453)`);
|
|
388
388
|
console.log(`Latency: ${res.latencyMs}ms`);
|
|
389
389
|
console.log('================================================================');
|
|
390
|
-
|
|
390
|
+
|
|
391
391
|
const proxy = auditObj.proxyResolution || auditObj.proxy || {};
|
|
392
392
|
const isProxy = !!proxy.isProxy;
|
|
393
393
|
if (isProxy) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m2msentinel/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"mcpName": "io.github.M2M-Sentinel/m2m-sentinel-sdk",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"description": "JavaScript client for M2M Sentinel Base bytecode capability, proxy and market observations",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"types": "index.d.ts",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18"
|
|
13
|
+
},
|
|
11
14
|
"bin": {
|
|
12
15
|
"m2m-sentinel-mcp": "./mcp_server.js",
|
|
13
16
|
"m2m-sentinel": "./mcp_server.js",
|
|
@@ -37,12 +40,16 @@
|
|
|
37
40
|
"glama",
|
|
38
41
|
"agentkit",
|
|
39
42
|
"coinbase",
|
|
40
|
-
"smart-contract-audit"
|
|
43
|
+
"smart-contract-audit",
|
|
44
|
+
"paymaster",
|
|
45
|
+
"wallet-send-calls",
|
|
46
|
+
"sponsored-transaction"
|
|
41
47
|
],
|
|
42
48
|
"author": "M2M Sentinel",
|
|
43
49
|
"files": [
|
|
44
50
|
"index.js",
|
|
45
51
|
"index.d.ts",
|
|
52
|
+
"base_account_paymaster_guard.js",
|
|
46
53
|
"m2m_sentinel_sdk.js",
|
|
47
54
|
"agent_adapter.js",
|
|
48
55
|
"x402_signer.js",
|
|
@@ -50,7 +57,11 @@
|
|
|
50
57
|
"mcp_server.js",
|
|
51
58
|
"smithery.yaml",
|
|
52
59
|
"README.md",
|
|
53
|
-
"typescript/"
|
|
60
|
+
"typescript/index.ts",
|
|
61
|
+
"typescript/x402.ts",
|
|
62
|
+
"typescript/base_account_paymaster_guard.ts",
|
|
63
|
+
"typescript/package.json",
|
|
64
|
+
"typescript/package-lock.json",
|
|
65
|
+
"typescript/tsconfig.json"
|
|
54
66
|
]
|
|
55
67
|
}
|
|
56
|
-
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import type { M2MSentinelClient, TransactionPreflightRequest } from './index';
|
|
2
|
+
|
|
3
|
+
export interface WalletSendCallsCall {
|
|
4
|
+
to: string;
|
|
5
|
+
data: string;
|
|
6
|
+
/** Base Account uses canonical 0x quantities for call value. */
|
|
7
|
+
value?: string;
|
|
8
|
+
capabilities?: Record<string, Record<string, unknown>>;
|
|
9
|
+
flowControl?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface WalletSendCallsParams {
|
|
13
|
+
version: '1.0';
|
|
14
|
+
id?: string;
|
|
15
|
+
from: string;
|
|
16
|
+
/** Deliberately restricted to Base's canonical wallet_sendCalls value. */
|
|
17
|
+
chainId: '0x2105';
|
|
18
|
+
atomicRequired?: boolean;
|
|
19
|
+
calls: WalletSendCallsCall[];
|
|
20
|
+
capabilities?: Record<string, Record<string, unknown>>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface WalletSendCallsRequest {
|
|
24
|
+
method: 'wallet_sendCalls';
|
|
25
|
+
params: [WalletSendCallsParams];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Eip1193Provider {
|
|
29
|
+
request(request: WalletSendCallsRequest): Promise<unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type BaseTrustLevel = 'HIGH_TRUST_PRIMARY' | 'QUORUM_PUBLIC';
|
|
33
|
+
|
|
34
|
+
export interface BaseObservationBlock {
|
|
35
|
+
status: 'PINNED';
|
|
36
|
+
chainId: number | string;
|
|
37
|
+
network: 'eip155:8453';
|
|
38
|
+
blockNumber: number | string;
|
|
39
|
+
blockHash: string;
|
|
40
|
+
blockTag: string;
|
|
41
|
+
trustLevel: BaseTrustLevel;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface BaseSimulationObservation {
|
|
46
|
+
attempted: true;
|
|
47
|
+
trusted: true;
|
|
48
|
+
outcome: 'NOT_ATTEMPTED' | 'SUCCEEDED' | 'REVERTED' | 'UNAVAILABLE' | 'MALFORMED';
|
|
49
|
+
blockTag: string;
|
|
50
|
+
evidenceOnly: true;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface BaseRpcObservation {
|
|
55
|
+
pinnedBlockTag: string;
|
|
56
|
+
stateBearingCallCount: number;
|
|
57
|
+
failedReadCount: 0;
|
|
58
|
+
failures: unknown[];
|
|
59
|
+
calls: BaseRpcObservationCall[];
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface BaseRpcObservationCall {
|
|
64
|
+
method?: string;
|
|
65
|
+
params?: unknown[];
|
|
66
|
+
blockTag?: string | null;
|
|
67
|
+
status?: 'OK' | 'UNSUPPORTED_OPTIONAL_METHOD' | 'EXECUTION_ERROR' | string;
|
|
68
|
+
trustLevel?: BaseTrustLevel | 'DEGRADED_LOW_TRUST';
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface BaseCapabilityEvidence {
|
|
73
|
+
sourceAddress: string;
|
|
74
|
+
executionRole: 'RESOLVED_EXECUTING_CODE' | 'SELECTED_DIAMOND_FACET';
|
|
75
|
+
transactionSelector: string | null;
|
|
76
|
+
dissection: BaseDissection;
|
|
77
|
+
notASafetyGuarantee: true;
|
|
78
|
+
reachability: 'NOT_ESTABLISHED';
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface BaseDissectionCapability {
|
|
83
|
+
type: string;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface BaseDissection {
|
|
88
|
+
isValidContract: true;
|
|
89
|
+
bytecodeSizeBytes: number;
|
|
90
|
+
targetBytecodeHash: string;
|
|
91
|
+
capabilities: BaseDissectionCapability[];
|
|
92
|
+
detectedCapabilities: string[];
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface BaseBytecodeHashes {
|
|
97
|
+
runtimeBytecodeHash: string | null;
|
|
98
|
+
finalTargetBytecodeHash: string;
|
|
99
|
+
facetBytecodeHash: string | null;
|
|
100
|
+
facetBytecodeHashes: unknown[];
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface BaseAccountPreflightObservation {
|
|
105
|
+
status: 'SUCCESS';
|
|
106
|
+
operation: 'TRANSACTION_PREFLIGHT_OBSERVATION';
|
|
107
|
+
request: TransactionPreflightRequest;
|
|
108
|
+
selectorHex: string | null;
|
|
109
|
+
surfaceTarget: string;
|
|
110
|
+
resolvedExecutionTarget: string;
|
|
111
|
+
resolution: Record<string, unknown> & { status: 'COMPLETE'; resolutionComplete: true };
|
|
112
|
+
evidenceGrade: true;
|
|
113
|
+
evidenceStatus: 'VERIFIED';
|
|
114
|
+
effectiveTrust: BaseTrustLevel;
|
|
115
|
+
observationBlock: BaseObservationBlock;
|
|
116
|
+
simulationObservation: BaseSimulationObservation;
|
|
117
|
+
rpcObservation: BaseRpcObservation;
|
|
118
|
+
capabilityEvidence: BaseCapabilityEvidence;
|
|
119
|
+
bytecodeHashes: BaseBytecodeHashes;
|
|
120
|
+
notASafetyGuarantee: true;
|
|
121
|
+
reachability: 'NOT_ESTABLISHED';
|
|
122
|
+
limitations: string[];
|
|
123
|
+
conclusion: null;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface BaseAccountGuardContext {
|
|
128
|
+
callIndex: number;
|
|
129
|
+
index: number;
|
|
130
|
+
call: WalletSendCallsCall;
|
|
131
|
+
transaction: TransactionPreflightRequest;
|
|
132
|
+
request: WalletSendCallsRequest;
|
|
133
|
+
params: WalletSendCallsParams;
|
|
134
|
+
[key: string]: unknown;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type BaseAccountCallerPolicyResult =
|
|
138
|
+
| true
|
|
139
|
+
| false
|
|
140
|
+
| null
|
|
141
|
+
| undefined
|
|
142
|
+
| { allow: true; reason?: string }
|
|
143
|
+
| { allow: false; reason?: string };
|
|
144
|
+
|
|
145
|
+
export type BaseAccountCallerPolicy = (
|
|
146
|
+
observation: BaseAccountPreflightObservation,
|
|
147
|
+
context: BaseAccountGuardContext
|
|
148
|
+
) => BaseAccountCallerPolicyResult | Promise<BaseAccountCallerPolicyResult>;
|
|
149
|
+
|
|
150
|
+
export interface GuardWalletSendCallsOptions {
|
|
151
|
+
client: Pick<M2MSentinelClient, 'preflightTransaction'>;
|
|
152
|
+
provider: Eip1193Provider;
|
|
153
|
+
request: WalletSendCallsRequest;
|
|
154
|
+
policy: BaseAccountCallerPolicy;
|
|
155
|
+
context?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface BaseAccountPaymasterGuardOptions {
|
|
159
|
+
client: Pick<M2MSentinelClient, 'preflightTransaction'>;
|
|
160
|
+
policy: BaseAccountCallerPolicy;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface BaseAccountGuardCallOptions {
|
|
164
|
+
policy?: BaseAccountCallerPolicy;
|
|
165
|
+
context?: Record<string, unknown>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface BaseAccountObservationIdentity {
|
|
169
|
+
blockNumber: bigint;
|
|
170
|
+
blockTag: string;
|
|
171
|
+
blockHash: string;
|
|
172
|
+
effectiveTrust: BaseTrustLevel;
|
|
173
|
+
blockTrustLevel: BaseTrustLevel;
|
|
174
|
+
finalTargetBytecodeHash: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
interface WalletSendCallsInputErrorInstance extends TypeError {
|
|
178
|
+
readonly code: 'INVALID_WALLET_SEND_CALLS_INPUT';
|
|
179
|
+
readonly field: string;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface ExecutionIdentityBlockedErrorInstance extends Error {
|
|
183
|
+
readonly code: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
interface BaseAccountPaymasterGuardInstance {
|
|
187
|
+
request(provider: Eip1193Provider, request: WalletSendCallsRequest, options?: BaseAccountGuardCallOptions): Promise<unknown>;
|
|
188
|
+
sendCalls(provider: Eip1193Provider, request: WalletSendCallsRequest, options?: BaseAccountGuardCallOptions): Promise<unknown>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// This source-distributed TypeScript entrypoint targets Node.js/CommonJS
|
|
192
|
+
// (Node >=18). It intentionally loads the public runtime adapter through
|
|
193
|
+
// Node's require and is not a browser-targeted bundle.
|
|
194
|
+
function runtime(): any {
|
|
195
|
+
return require('../base_account_paymaster_guard.js');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export const BASE_CHAIN_ID: 8453 = runtime().BASE_CHAIN_ID;
|
|
199
|
+
export const BASE_CHAIN_HEX: '0x2105' = runtime().BASE_CHAIN_HEX;
|
|
200
|
+
export const BASE_NETWORK: 'eip155:8453' = runtime().BASE_NETWORK;
|
|
201
|
+
export const MAX_CALLS: number = runtime().MAX_CALLS;
|
|
202
|
+
export const MAX_PREFLIGHT_CONCURRENCY: number = runtime().MAX_PREFLIGHT_CONCURRENCY;
|
|
203
|
+
export const MAX_RPC_OBSERVATION_CALLS: number = runtime().MAX_RPC_OBSERVATION_CALLS;
|
|
204
|
+
export const MAX_DATA_BYTES: number = runtime().MAX_DATA_BYTES;
|
|
205
|
+
|
|
206
|
+
export const WalletSendCallsInputError: {
|
|
207
|
+
new (field: string, message: string): WalletSendCallsInputErrorInstance;
|
|
208
|
+
} = runtime().WalletSendCallsInputError;
|
|
209
|
+
export const ExecutionIdentityBlockedError: {
|
|
210
|
+
new (code: string, message: string): ExecutionIdentityBlockedErrorInstance;
|
|
211
|
+
} = runtime().ExecutionIdentityBlockedError;
|
|
212
|
+
export const PreflightInputError = WalletSendCallsInputError;
|
|
213
|
+
export const PreflightBlockedError = ExecutionIdentityBlockedError;
|
|
214
|
+
|
|
215
|
+
export function isAffirmativePolicyResult(value: unknown): value is true | { allow: true; reason?: string } {
|
|
216
|
+
return runtime().isAffirmativePolicyResult(value);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function validateWalletSendCallsRequest(request: unknown): WalletSendCallsRequest {
|
|
220
|
+
return runtime().validateWalletSendCallsRequest(request);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export const normalizeWalletSendCallsRequest = validateWalletSendCallsRequest;
|
|
224
|
+
|
|
225
|
+
export function transactionFromCall(params: WalletSendCallsParams, call: WalletSendCallsCall, index = 0): TransactionPreflightRequest {
|
|
226
|
+
return runtime().transactionFromCall(params, call, index);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export const toPreflightTransaction = transactionFromCall;
|
|
230
|
+
|
|
231
|
+
export function assertObservationReady(
|
|
232
|
+
observation: unknown,
|
|
233
|
+
transaction: TransactionPreflightRequest
|
|
234
|
+
): BaseAccountObservationIdentity {
|
|
235
|
+
return runtime().assertObservationReady(observation, transaction);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export function guardWalletSendCalls(options: GuardWalletSendCallsOptions): Promise<unknown> {
|
|
239
|
+
return runtime().guardWalletSendCalls(options);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export const preflightWalletSendCalls = guardWalletSendCalls;
|
|
243
|
+
export const sendCallsWithPreflight = guardWalletSendCalls;
|
|
244
|
+
export const executeWalletSendCalls = guardWalletSendCalls;
|
|
245
|
+
|
|
246
|
+
export const BaseAccountPaymasterGuard: {
|
|
247
|
+
new (options: BaseAccountPaymasterGuardOptions): BaseAccountPaymasterGuardInstance;
|
|
248
|
+
} = runtime().BaseAccountPaymasterGuard;
|
|
249
|
+
export const BaseAccountExecutionGuard = BaseAccountPaymasterGuard;
|
|
250
|
+
|
|
251
|
+
export function createBaseAccountPaymasterGuard(options: BaseAccountPaymasterGuardOptions): BaseAccountPaymasterGuardInstance {
|
|
252
|
+
return new BaseAccountPaymasterGuard(options);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export const createExecutionIdentityGuard = createBaseAccountPaymasterGuard;
|
|
256
|
+
|
|
257
|
+
export function createPublicClient(options: {
|
|
258
|
+
apiKey: string;
|
|
259
|
+
baseUrl?: string;
|
|
260
|
+
timeoutMs?: number;
|
|
261
|
+
sdk?: { M2MSentinelClient: typeof M2MSentinelClient };
|
|
262
|
+
}): M2MSentinelClient {
|
|
263
|
+
return runtime().createPublicClient(options);
|
|
264
|
+
}
|
package/typescript/index.ts
CHANGED
|
@@ -18,6 +18,15 @@ export interface RecoveryChallengeOptions {
|
|
|
18
18
|
txHash?: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
export interface TransactionPreflightRequest {
|
|
22
|
+
chainId: number | string;
|
|
23
|
+
to: string;
|
|
24
|
+
data: string;
|
|
25
|
+
from?: string;
|
|
26
|
+
value?: number | string;
|
|
27
|
+
blockNumber?: number | string;
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
export interface M2MSentinelErrorOptions {
|
|
22
31
|
status?: number;
|
|
23
32
|
body?: any;
|
|
@@ -155,6 +164,7 @@ export class M2MSentinelClient {
|
|
|
155
164
|
public getCapabilityScore(address: string, options?: M2MSentinelClientOptions) { return this.request<any>('GET', `/v1/security/score/${encodeURIComponent(address)}`, undefined, options); }
|
|
156
165
|
/** Legacy name. The response is a capability coverage index, not a safety score. */
|
|
157
166
|
public getSecurityScore(address: string, options?: M2MSentinelClientOptions) { return this.request<any>('GET', `/v1/security/score/${encodeURIComponent(address)}`, undefined, options); }
|
|
167
|
+
public preflightTransaction(transaction: TransactionPreflightRequest, options?: M2MSentinelClientOptions) { return this.request<any>('POST', '/v1/transaction/preflight', transaction, options); }
|
|
158
168
|
public getGasFees(options?: M2MSentinelClientOptions) { return this.request<any>('GET', '/v1/gas/fees', undefined, options); }
|
|
159
169
|
public getDexMetrics(options?: M2MSentinelClientOptions) { return this.request<any>('GET', '/v1/dex/metrics', undefined, options); }
|
|
160
170
|
public getTokenPrice(symbol: string, options?: M2MSentinelClientOptions) { return this.request<any>('GET', `/v1/token/price/${encodeURIComponent(symbol)}`, undefined, options); }
|
|
@@ -216,3 +226,5 @@ export {
|
|
|
216
226
|
X402SignerClient,
|
|
217
227
|
x402SignerClient
|
|
218
228
|
} from './x402';
|
|
229
|
+
|
|
230
|
+
export * from './base_account_paymaster_guard';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "m2m-sentinel-sdk",
|
|
3
|
+
"version": "1.2.5",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "m2m-sentinel-sdk",
|
|
9
|
+
"version": "1.2.5",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/node": "^22.7.5",
|
|
12
|
+
"typescript": "^5.0.0"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"node_modules/@types/node": {
|
|
19
|
+
"version": "22.20.1",
|
|
20
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz",
|
|
21
|
+
"integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==",
|
|
22
|
+
"dev": true,
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"undici-types": "~6.21.0"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"node_modules/typescript": {
|
|
29
|
+
"version": "5.9.3",
|
|
30
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
|
31
|
+
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
|
32
|
+
"dev": true,
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"bin": {
|
|
35
|
+
"tsc": "bin/tsc",
|
|
36
|
+
"tsserver": "bin/tsserver"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=14.17"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"node_modules/undici-types": {
|
|
43
|
+
"version": "6.21.0",
|
|
44
|
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
|
45
|
+
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
|
46
|
+
"dev": true,
|
|
47
|
+
"license": "MIT"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|