@saviours/check 0.1.1 → 0.1.3
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 +59 -18
- package/dist/gateway.d.ts +6 -0
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +37 -11
- package/dist/gateway.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -6
- package/scripts/smoke.mjs +47 -0
package/README.md
CHANGED
|
@@ -1,20 +1,43 @@
|
|
|
1
1
|
# `@saviours/check`
|
|
2
2
|
|
|
3
|
+
<p align="left">
|
|
4
|
+
<img src="https://www.saviours.xyz/brand/saviours-mark-ink.png" alt="saviours" width="40" height="40" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
3
7
|
[](https://www.npmjs.com/package/@saviours/check)
|
|
4
8
|
|
|
5
9
|
Two-line counterparty check for wallets and agents.
|
|
6
10
|
Default path reads Sepolia ENS only — **$0**, no Saviours server.
|
|
7
11
|
|
|
12
|
+
## Install (fresh project)
|
|
13
|
+
|
|
14
|
+
**Do not run `npm i` / `pnpm add` inside the Saviours git monorepo.**
|
|
15
|
+
That tree is pnpm-managed; mixing `npm` there crashes arborist (`Cannot read properties of null (reading 'matches')`).
|
|
16
|
+
|
|
8
17
|
```bash
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
mkdir saviours-demo && cd saviours-demo
|
|
19
|
+
npm init -y
|
|
20
|
+
npm i @saviours/check
|
|
21
|
+
# or: pnpm init && pnpm add @saviours/check
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Package is **ESM-only** (`"type": "module"`). Use `import`, not `require`.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
node --input-type=module -e "
|
|
28
|
+
import { check } from '@saviours/check';
|
|
29
|
+
const r = await check('0x935bfb495e33f74d2e9735df1da66ace442ede48');
|
|
30
|
+
console.log(r.decision, r.status); // named → BLOCK|WARN · TAINTED|WATCH
|
|
31
|
+
"
|
|
11
32
|
```
|
|
12
33
|
|
|
13
34
|
```ts
|
|
14
35
|
import { check, guard } from "@saviours/check";
|
|
15
36
|
|
|
16
37
|
const r = await check("0x935bfb495e33f74d2e9735df1da66ace442ede48");
|
|
17
|
-
if (r.decision === "BLOCK"
|
|
38
|
+
if (r.decision === "BLOCK" || r.decision === "WARN") {
|
|
39
|
+
throw new Error(\`named \${r.status}\`);
|
|
40
|
+
}
|
|
18
41
|
|
|
19
42
|
await guard(addr); // throws SavioursBlockedError on BLOCK
|
|
20
43
|
```
|
|
@@ -22,27 +45,55 @@ await guard(addr); // throws SavioursBlockedError on BLOCK
|
|
|
22
45
|
| Mode | Path | Cost | Our server? |
|
|
23
46
|
|---|---|---|---|
|
|
24
47
|
| `ens` (default) | PermissionedResolver.text | $0 | No |
|
|
25
|
-
| `shield` | `POST
|
|
26
|
-
| `full` | `POST
|
|
48
|
+
| `shield` | `POST …/api/shield/check` | $0 | Bazantic gateway |
|
|
49
|
+
| `full` | `POST …/api/investigate` | ~$0.01 on miss (x402) | Bazantic gateway |
|
|
27
50
|
|
|
28
51
|
```ts
|
|
29
52
|
await check(addr, { mode: "shield" });
|
|
53
|
+
// unpaid miss → throws with HTTP 402 guidance; or pass apiKey / BAZANTIC_API_KEY
|
|
30
54
|
await check(addr, { mode: "full" });
|
|
31
55
|
```
|
|
32
56
|
|
|
57
|
+
Gateway defaults to **`https://saviours.bazgateway.com`** (override with `baseUrl` / `BAZANTIC_GATEWAY_URL`).
|
|
58
|
+
Also exported: `BAZANTIC_GATEWAY`, `BAZANTIC_MCP`, `SAVIOURS_APP_URL`.
|
|
59
|
+
|
|
33
60
|
Also: `castCommand(address)`, React helper `@saviours/check/react`.
|
|
34
61
|
|
|
62
|
+
### Inside this monorepo
|
|
63
|
+
|
|
64
|
+
Workspace already wires the package — no npm install needed:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pnpm --filter @saviours/check build
|
|
68
|
+
pnpm --filter @saviours/check smoke
|
|
69
|
+
```
|
|
70
|
+
|
|
35
71
|
## Product law
|
|
36
72
|
|
|
37
73
|
- Memory hit is always **$0**.
|
|
38
74
|
- **UNKNOWN / no name ≠ SAFE.**
|
|
39
75
|
- Only WATCH / TAINTED are named.
|
|
40
76
|
|
|
77
|
+
## Bazantic (agents)
|
|
78
|
+
|
|
79
|
+
| | |
|
|
80
|
+
|---|---|
|
|
81
|
+
| Gateway | `https://saviours.bazgateway.com` |
|
|
82
|
+
| MCP | `https://saviours.bazgateway.com/mcp` (POST) |
|
|
83
|
+
| Tiers | Free `$0` · Standard `~$0.01` · Complex `~$0.05` |
|
|
84
|
+
| Recipes | `safe-swap-with-memory` · `saviours-check-before-sign` · `investigate-once-explain` · `dossier-deep-dive` · `fleet-triage` |
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
claude mcp add --transport http saviours https://saviours.bazgateway.com/mcp
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Never bind in agent recipes: `dispute` · `revoke` · `eacProbe`.
|
|
91
|
+
|
|
41
92
|
## Links
|
|
42
93
|
|
|
43
|
-
- App: [www.saviours.xyz](https://www.saviours.xyz) · Build · Wallet gate
|
|
44
|
-
- Integrate
|
|
45
|
-
-
|
|
94
|
+
- App: [www.saviours.xyz](https://www.saviours.xyz) · Build · Wallet gate · [/gateway](https://www.saviours.xyz/gateway)
|
|
95
|
+
- Integrate: [docs/INTEGRATE.md](https://github.com/devhb1/Saviour/blob/main/docs/INTEGRATE.md)
|
|
96
|
+
- Recipes: [docs/recipes/PUBLISH_KIT.md](https://github.com/devhb1/Saviour/blob/main/docs/recipes/PUBLISH_KIT.md)
|
|
46
97
|
- OpenAPI: [openapi-saviours.json](https://www.saviours.xyz/openapi-saviours.json)
|
|
47
98
|
|
|
48
99
|
## Support
|
|
@@ -50,13 +101,3 @@ Also: `castCommand(address)`, React helper `@saviours/check/react`.
|
|
|
50
101
|
- Email: [b4harshit01@gmail.com](mailto:b4harshit01@gmail.com)
|
|
51
102
|
- Twitter: [@harshitb01](https://twitter.com/harshitb01)
|
|
52
103
|
- GitHub: [devhb1](https://github.com/devhb1) · [issues](https://github.com/devhb1/Saviour/issues)
|
|
53
|
-
|
|
54
|
-
## Smoke
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
node --input-type=module -e "
|
|
58
|
-
import { check } from '@saviours/check';
|
|
59
|
-
console.log(await check('0x935bfb495e33f74d2e9735df1da66ace442ede48'));
|
|
60
|
-
"
|
|
61
|
-
# → decision BLOCK · status TAINTED
|
|
62
|
-
```
|
package/dist/gateway.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { CheckOptions, CheckResult } from "./types.js";
|
|
2
|
+
/** Canonical Bazantic x402 / MCP gateway (preferred for shield + full). */
|
|
3
|
+
export declare const BAZANTIC_GATEWAY: "https://saviours.bazgateway.com";
|
|
4
|
+
/** Public Vercel upstream (fail-closed writes). */
|
|
5
|
+
export declare const SAVIOURS_APP_URL: "https://www.saviours.xyz";
|
|
6
|
+
/** MCP endpoint (POST only). */
|
|
7
|
+
export declare const BAZANTIC_MCP: "https://saviours.bazgateway.com/mcp";
|
|
2
8
|
export declare function checkShield(address: string, opts?: CheckOptions): Promise<CheckResult>;
|
|
3
9
|
export declare function checkFull(address: string, opts?: CheckOptions): Promise<CheckResult>;
|
|
4
10
|
//# sourceMappingURL=gateway.d.ts.map
|
package/dist/gateway.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAY,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAY,MAAM,YAAY,CAAC;AAEtE,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,EAAG,iCAA0C,CAAC;AAE3E,mDAAmD;AACnD,eAAO,MAAM,gBAAgB,EAAG,0BAAmC,CAAC;AAEpE,gCAAgC;AAChC,eAAO,MAAM,YAAY,uCAAqC,CAAC;AA8B/D,wBAAsB,WAAW,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,YAAiB,GACtB,OAAO,CAAC,WAAW,CAAC,CAkEtB;AAED,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,YAAiB,GACtB,OAAO,CAAC,WAAW,CAAC,CAmEtB"}
|
package/dist/gateway.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/** Canonical Bazantic x402 / MCP gateway (preferred for shield + full). */
|
|
2
|
+
export const BAZANTIC_GATEWAY = "https://saviours.bazgateway.com";
|
|
3
|
+
/** Public Vercel upstream (fail-closed writes). */
|
|
4
|
+
export const SAVIOURS_APP_URL = "https://www.saviours.xyz";
|
|
5
|
+
/** MCP endpoint (POST only). */
|
|
6
|
+
export const BAZANTIC_MCP = `${BAZANTIC_GATEWAY}/mcp`;
|
|
7
|
+
const DEFAULT_BASE = BAZANTIC_GATEWAY;
|
|
2
8
|
function requireAddress(address) {
|
|
3
9
|
const a = address.trim().toLowerCase();
|
|
4
10
|
if (!/^0x[a-f0-9]{40}$/.test(a)) {
|
|
@@ -7,17 +13,28 @@ function requireAddress(address) {
|
|
|
7
13
|
return a;
|
|
8
14
|
}
|
|
9
15
|
function baseUrl(opts) {
|
|
10
|
-
|
|
11
|
-
process.env.
|
|
12
|
-
process.env.
|
|
13
|
-
|
|
16
|
+
const raw = opts.baseUrl?.trim() ||
|
|
17
|
+
process.env.BAZANTIC_GATEWAY_URL?.trim() ||
|
|
18
|
+
process.env.SAVIOURS_BASE_URL?.trim() ||
|
|
19
|
+
process.env.PUBLIC_APP_URL?.trim() ||
|
|
20
|
+
DEFAULT_BASE;
|
|
21
|
+
return raw.replace(/\/$/, "");
|
|
22
|
+
}
|
|
23
|
+
function authHeaders(opts) {
|
|
24
|
+
const key = opts.apiKey?.trim() ||
|
|
25
|
+
process.env.BAZANTIC_API_KEY?.trim() ||
|
|
26
|
+
process.env.BAZENTI_API_KEY?.trim();
|
|
27
|
+
return key ? { Authorization: `Bearer ${key}` } : {};
|
|
14
28
|
}
|
|
15
29
|
export async function checkShield(address, opts = {}) {
|
|
16
30
|
const addr = requireAddress(address);
|
|
17
31
|
const t0 = Date.now();
|
|
18
32
|
const res = await fetch(`${baseUrl(opts)}/api/shield/check`, {
|
|
19
33
|
method: "POST",
|
|
20
|
-
headers: {
|
|
34
|
+
headers: {
|
|
35
|
+
"content-type": "application/json",
|
|
36
|
+
...authHeaders(opts),
|
|
37
|
+
},
|
|
21
38
|
body: JSON.stringify({
|
|
22
39
|
chainId: opts.chainId ?? 1,
|
|
23
40
|
address: addr,
|
|
@@ -43,9 +60,12 @@ export async function checkShield(address, opts = {}) {
|
|
|
43
60
|
: json.check.decision === "ALLOW"
|
|
44
61
|
? "SAFE"
|
|
45
62
|
: "UNKNOWN",
|
|
46
|
-
ensName: json.check.ensName ??
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
ensName: json.check.ensName ?? `${addr}.saviours.eth`,
|
|
64
|
+
source: source === "none" && json.check.decision === "ESCALATE"
|
|
65
|
+
? "none"
|
|
66
|
+
: source === "ens"
|
|
67
|
+
? "ens"
|
|
68
|
+
: "shield",
|
|
49
69
|
reason: json.check.reason,
|
|
50
70
|
latencyMs: typeof json.check.latencyMs === "number"
|
|
51
71
|
? json.check.latencyMs
|
|
@@ -63,7 +83,10 @@ export async function checkFull(address, opts = {}) {
|
|
|
63
83
|
const t0 = Date.now();
|
|
64
84
|
const res = await fetch(`${baseUrl(opts)}/api/investigate`, {
|
|
65
85
|
method: "POST",
|
|
66
|
-
headers: {
|
|
86
|
+
headers: {
|
|
87
|
+
"content-type": "application/json",
|
|
88
|
+
...authHeaders(opts),
|
|
89
|
+
},
|
|
67
90
|
body: JSON.stringify({
|
|
68
91
|
chainId: opts.chainId ?? 1,
|
|
69
92
|
address: addr,
|
|
@@ -72,7 +95,10 @@ export async function checkFull(address, opts = {}) {
|
|
|
72
95
|
registryNetwork: opts.registryNetwork ?? "sepolia",
|
|
73
96
|
}),
|
|
74
97
|
});
|
|
75
|
-
const json = (await res.json());
|
|
98
|
+
const json = (await res.json().catch(() => ({})));
|
|
99
|
+
if (res.status === 402) {
|
|
100
|
+
throw new Error("investigate unpaid (HTTP 402 x402). Settle USDC on Base via Bazantic grant, or pass apiKey / BAZANTIC_API_KEY. Gateway: https://saviours.bazgateway.com");
|
|
101
|
+
}
|
|
76
102
|
if (!res.ok) {
|
|
77
103
|
throw new Error(json.error || `investigate HTTP ${res.status}`);
|
|
78
104
|
}
|
package/dist/gateway.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,iCAA0C,CAAC;AAE3E,mDAAmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAAmC,CAAC;AAEpE,gCAAgC;AAChC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,gBAAgB,MAAe,CAAC;AAE/D,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAEtC,SAAS,cAAc,CAAC,OAAe;IACrC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QA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IAAI,CAAC,IAAI,EAAE,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE;QAClD,IAAI,EAAE;YACJ,KAAK;YACL,EAAE;YACF,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;SACpB;QACD,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,GAAG;YACT,CAAC,CAAC,0BAA0B;YAC5B,CAAC,CAAC,mDAAmD;KACxD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { check } from "./check.js";
|
|
|
2
2
|
export { guard, SavioursBlockedError } from "./guard.js";
|
|
3
3
|
export { castCommand } from "./castCommand.js";
|
|
4
4
|
export { checkEns } from "./ens.js";
|
|
5
|
-
export { checkShield, checkFull } from "./gateway.js";
|
|
5
|
+
export { checkShield, checkFull, BAZANTIC_GATEWAY, BAZANTIC_MCP, SAVIOURS_APP_URL, } from "./gateway.js";
|
|
6
6
|
export type { CheckCost, CheckMode, CheckOptions, CheckResult, Decision, } from "./types.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,GACT,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,5 @@ export { check } from "./check.js";
|
|
|
2
2
|
export { guard, SavioursBlockedError } from "./guard.js";
|
|
3
3
|
export { castCommand } from "./castCommand.js";
|
|
4
4
|
export { checkEns } from "./ens.js";
|
|
5
|
-
export { checkShield, checkFull } from "./gateway.js";
|
|
5
|
+
export { checkShield, checkFull, BAZANTIC_GATEWAY, BAZANTIC_MCP, SAVIOURS_APP_URL, } from "./gateway.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -27,8 +27,10 @@ export type CheckOptions = {
|
|
|
27
27
|
resolver?: `0x${string}`;
|
|
28
28
|
/** Parent name, default saviours.eth */
|
|
29
29
|
parent?: string;
|
|
30
|
-
/** Gateway / app origin for shield + full. */
|
|
30
|
+
/** Gateway / app origin for shield + full. Default: Bazantic `saviours.bazgateway.com`. */
|
|
31
31
|
baseUrl?: string;
|
|
32
|
+
/** Bazantic JWT for paid investigate bypass (or set BAZANTIC_API_KEY). */
|
|
33
|
+
apiKey?: string;
|
|
32
34
|
chainId?: number;
|
|
33
35
|
registryNetwork?: "sepolia" | "anvil";
|
|
34
36
|
/** full mode only — force Graph path */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAE/D,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,CAAC;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,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,EAAE,SAAS,CAAC;IACjB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IACtC,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kEAAkE;IAClE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saviours/check",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Two-line counterparty check — ENS first,
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Two-line counterparty check — ENS first, Bazantic Shield/investigate gateway",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -30,26 +30,32 @@
|
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
|
+
"main": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
33
35
|
"exports": {
|
|
34
36
|
".": {
|
|
35
37
|
"types": "./dist/index.d.ts",
|
|
36
|
-
"import": "./dist/index.js"
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"default": "./dist/index.js"
|
|
37
40
|
},
|
|
38
41
|
"./react": {
|
|
39
42
|
"types": "./dist/react.d.ts",
|
|
40
|
-
"import": "./dist/react.js"
|
|
43
|
+
"import": "./dist/react.js",
|
|
44
|
+
"default": "./dist/react.js"
|
|
41
45
|
}
|
|
42
46
|
},
|
|
43
47
|
"files": [
|
|
44
48
|
"dist",
|
|
45
49
|
"examples",
|
|
46
|
-
"README.md"
|
|
50
|
+
"README.md",
|
|
51
|
+
"scripts"
|
|
47
52
|
],
|
|
48
53
|
"scripts": {
|
|
49
54
|
"build": "tsc -p tsconfig.json",
|
|
50
55
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
51
56
|
"prepare": "tsc -p tsconfig.json",
|
|
52
|
-
"prepublishOnly": "tsc -p tsconfig.json"
|
|
57
|
+
"prepublishOnly": "tsc -p tsconfig.json",
|
|
58
|
+
"smoke": "node ./scripts/smoke.mjs"
|
|
53
59
|
},
|
|
54
60
|
"peerDependencies": {
|
|
55
61
|
"react": ">=18"
|
|
@@ -63,6 +69,7 @@
|
|
|
63
69
|
"viem": "^2.56.3"
|
|
64
70
|
},
|
|
65
71
|
"devDependencies": {
|
|
72
|
+
"@types/node": "^20.19.43",
|
|
66
73
|
"typescript": "^5.7.2"
|
|
67
74
|
},
|
|
68
75
|
"engines": {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Integrator smoke — after `npm i @saviours/check` in a fresh project:
|
|
4
|
+
* node node_modules/@saviours/check/scripts/smoke.mjs
|
|
5
|
+
* From this monorepo:
|
|
6
|
+
* pnpm --filter @saviours/check smoke
|
|
7
|
+
*/
|
|
8
|
+
let check;
|
|
9
|
+
try {
|
|
10
|
+
({ check } = await import("@saviours/check"));
|
|
11
|
+
} catch {
|
|
12
|
+
({ check } = await import("../dist/index.js"));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const ATTACK_1 = "0x935bfb495e33f74d2e9735df1da66ace442ede48";
|
|
16
|
+
|
|
17
|
+
const r = await check(ATTACK_1);
|
|
18
|
+
const named =
|
|
19
|
+
r.decision === "BLOCK" ||
|
|
20
|
+
r.decision === "WARN" ||
|
|
21
|
+
r.status === "TAINTED" ||
|
|
22
|
+
r.status === "WATCH";
|
|
23
|
+
|
|
24
|
+
console.log(
|
|
25
|
+
JSON.stringify(
|
|
26
|
+
{
|
|
27
|
+
address: ATTACK_1,
|
|
28
|
+
decision: r.decision,
|
|
29
|
+
status: r.status,
|
|
30
|
+
source: r.source,
|
|
31
|
+
ensName: r.ensName ?? null,
|
|
32
|
+
},
|
|
33
|
+
null,
|
|
34
|
+
2,
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
if (!named) {
|
|
39
|
+
console.error(
|
|
40
|
+
"Expected ATTACK-1 to be named (BLOCK/WARN · TAINTED/WATCH). Got",
|
|
41
|
+
r.decision,
|
|
42
|
+
r.status,
|
|
43
|
+
);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log("smoke ok · named threat · ENS resolve path");
|