@xyz17711/domain-security 0.1.0 → 0.1.2
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 +8 -5
- package/dist/index.d.ts +11 -2
- package/dist/index.js +10 -2
- package/dist/langchain.d.ts +1 -1
- package/dist/langchain.js +1 -1
- package/package.json +30 -2
- package/src/index.ts +0 -115
- package/src/langchain.ts +0 -28
- package/test/index.test.mjs +0 -24
- package/test/langchain.test.mjs +0 -16
- package/tsconfig.json +0 -16
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@xyz17711/domain-security)
|
|
5
5
|
[](https://github.com/17711-services/clients/blob/main/LICENSE)
|
|
6
6
|
|
|
7
|
-
Typed TypeScript client for
|
|
7
|
+
Typed TypeScript client for **domain-security-service**, part of the
|
|
8
8
|
[17711.xyz](https://api.17711.xyz) microservice fleet -- pay-per-call APIs settled in USDC via
|
|
9
9
|
[x402](https://x402.org), listed on [x402scan](https://www.x402scan.com/server/f1c7b972-3405-4b75-8b4f-d1bfbd6305ff).
|
|
10
10
|
|
|
@@ -25,10 +25,13 @@ npm install @xyz17711/domain-security
|
|
|
25
25
|
```typescript
|
|
26
26
|
import { Client } from "@xyz17711/domain-security";
|
|
27
27
|
|
|
28
|
-
const client = new Client(
|
|
28
|
+
const client = new Client(); // talks to https://api.17711.xyz/registry/domain-security-service by default
|
|
29
29
|
// see the Methods table above for every available call and its request/response type
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
Pass another base URL (self-hosted instance, test server) as the first argument:
|
|
33
|
+
`new Client("https://my-host.example/registry/domain-security-service")`.
|
|
34
|
+
|
|
32
35
|
## Paying past the free quota
|
|
33
36
|
|
|
34
37
|
Every gated tool allows a small number of free calls per day; beyond that it returns a 402
|
|
@@ -38,7 +41,7 @@ network, and payee address attached:
|
|
|
38
41
|
```typescript
|
|
39
42
|
import { Client, PaymentRequiredError } from "@xyz17711/domain-security";
|
|
40
43
|
|
|
41
|
-
const client = new Client(
|
|
44
|
+
const client = new Client();
|
|
42
45
|
try {
|
|
43
46
|
await client.getReport(/* ... */);
|
|
44
47
|
} catch (e) {
|
|
@@ -54,7 +57,7 @@ own environment/secrets manager, never a literal string in source code:
|
|
|
54
57
|
```typescript
|
|
55
58
|
import { Client } from "@xyz17711/domain-security";
|
|
56
59
|
|
|
57
|
-
const client = new Client(
|
|
60
|
+
const client = new Client({
|
|
58
61
|
x402PrivateKey: process.env.X402_PRIVATE_KEY,
|
|
59
62
|
x402ExpectedNetwork: "eip155:8453", // Base mainnet; use eip155:84532 for Base Sepolia testnet
|
|
60
63
|
x402MaxPaymentUsdc: 0.01, // refuse any single call above this
|
|
@@ -73,7 +76,7 @@ with that same key in this process.
|
|
|
73
76
|
import { Client } from "@xyz17711/domain-security";
|
|
74
77
|
import { DomainSecurityToolkit } from "@xyz17711/domain-security/langchain";
|
|
75
78
|
|
|
76
|
-
const client = new Client(
|
|
79
|
+
const client = new Client({ /* ...wallet options... */ });
|
|
77
80
|
const tools = new DomainSecurityToolkit(client).getTools();
|
|
78
81
|
```
|
|
79
82
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed HTTP client and request/response interfaces for
|
|
2
|
+
* Typed HTTP client and request/response interfaces for domain-security-service.
|
|
3
3
|
*/
|
|
4
4
|
import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
|
|
5
5
|
export interface BlocklistHit {
|
|
@@ -94,8 +94,17 @@ export interface GetReportRequest {
|
|
|
94
94
|
/** The oldest report you accept, in seconds. Omit it for the default (reports up to 1 hour old); `0` forces a fresh assessment. The response always says how old it is. */
|
|
95
95
|
max_age_seconds?: number | null;
|
|
96
96
|
}
|
|
97
|
-
/**
|
|
97
|
+
/** Production base URL of this service; pass another to self-host or test. */
|
|
98
|
+
export declare const DEFAULT_BASE_URL = "https://api.17711.xyz/registry/domain-security-service";
|
|
99
|
+
/** Typed client for domain-security-service, e.g. `client.getReport(...)`. */
|
|
98
100
|
export declare class Client extends BaseClient {
|
|
101
|
+
/**
|
|
102
|
+
* `new Client()` talks to the production service. Pass a base URL to target another
|
|
103
|
+
* instance, and/or wallet options (`new Client({ x402PrivateKey, ... })`) to pay past the
|
|
104
|
+
* free quota automatically.
|
|
105
|
+
*/
|
|
106
|
+
constructor(options?: ClientOptions);
|
|
107
|
+
constructor(baseUrl?: string, options?: ClientOptions);
|
|
99
108
|
/** Domain security check: SSL certificate check, DMARC SPF check, DNSSEC, security headers and blocklist status with a score ($0.009, x402) */
|
|
100
109
|
getReport(request: GetReportRequest): Promise<GetReportResponse>;
|
|
101
110
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed HTTP client and request/response interfaces for
|
|
2
|
+
* Typed HTTP client and request/response interfaces for domain-security-service.
|
|
3
3
|
*/
|
|
4
4
|
import { Client as BaseClient } from "@xyz17711/core";
|
|
5
|
-
/**
|
|
5
|
+
/** Production base URL of this service; pass another to self-host or test. */
|
|
6
|
+
export const DEFAULT_BASE_URL = "https://api.17711.xyz/registry/domain-security-service";
|
|
7
|
+
/** Typed client for domain-security-service, e.g. `client.getReport(...)`. */
|
|
6
8
|
export class Client extends BaseClient {
|
|
9
|
+
constructor(baseUrlOrOptions, options = {}) {
|
|
10
|
+
const [url, opts] = typeof baseUrlOrOptions === "object"
|
|
11
|
+
? [DEFAULT_BASE_URL, baseUrlOrOptions]
|
|
12
|
+
: [baseUrlOrOptions ?? DEFAULT_BASE_URL, options];
|
|
13
|
+
super(url, opts);
|
|
14
|
+
}
|
|
7
15
|
/** Domain security check: SSL certificate check, DMARC SPF check, DNSSEC, security headers and blocklist status with a score ($0.009, x402) */
|
|
8
16
|
async getReport(request) {
|
|
9
17
|
return this.post("/v1/domain-security/get_report", request);
|
package/dist/langchain.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LangChain.js tools for
|
|
2
|
+
* LangChain.js tools for domain-security-service, grouped in one Toolkit -- one tool per operation, each just an async function (JS has no separate sync form to generate). Requires the `@langchain/core`+`zod` peer dependencies declared in this package's own package.json -- imported from `domain-security/langchain`, never from the package root, so importing the base client never requires them installed.
|
|
3
3
|
*/
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Client } from "./index.js";
|
package/dist/langchain.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LangChain.js tools for
|
|
2
|
+
* LangChain.js tools for domain-security-service, grouped in one Toolkit -- one tool per operation, each just an async function (JS has no separate sync form to generate). Requires the `@langchain/core`+`zod` peer dependencies declared in this package's own package.json -- imported from `domain-security/langchain`, never from the package root, so importing the base client never requires them installed.
|
|
3
3
|
*/
|
|
4
4
|
import { tool } from "@langchain/core/tools";
|
|
5
5
|
import { z } from "zod";
|
package/package.json
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyz17711/domain-security",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Typed TypeScript client for the 17711.xyz Domain Security API: pay-per-call, settled in USDC via x402.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "17711 Services",
|
|
7
|
+
"homepage": "https://api.17711.xyz",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/17711-services/clients.git",
|
|
11
|
+
"directory": "node/packages/domain-security"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/17711-services/clients/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"x402",
|
|
18
|
+
"usdc",
|
|
19
|
+
"api-client",
|
|
20
|
+
"pay-per-call",
|
|
21
|
+
"ai-agents",
|
|
22
|
+
"mcp",
|
|
23
|
+
"langchain",
|
|
24
|
+
"domain-security"
|
|
25
|
+
],
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
5
33
|
"type": "module",
|
|
6
34
|
"main": "dist/index.js",
|
|
7
35
|
"types": "dist/index.d.ts",
|
package/src/index.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed HTTP client and request/response interfaces for 🛡️ domain-security-service.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
|
|
6
|
-
|
|
7
|
-
export interface BlocklistHit {
|
|
8
|
-
cidr: string;
|
|
9
|
-
ip: string;
|
|
10
|
-
source: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface DnsSecurity {
|
|
14
|
-
/** CAA records: the certificate authorities allowed to issue for the domain. */
|
|
15
|
-
caa: string[];
|
|
16
|
-
/** Whether the answer for the domain is validated by DNSSEC. */
|
|
17
|
-
dnssec: boolean;
|
|
18
|
-
/** Authoritative name servers (at most 8). */
|
|
19
|
-
name_servers: string[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface Finding {
|
|
23
|
-
/** Stable machine-readable code, e.g. `tls.expired`, `mail.dmarc_absent`, `http.hsts_missing`. */
|
|
24
|
-
code: string;
|
|
25
|
-
/** What was observed and why it matters, in one sentence. */
|
|
26
|
-
message: string;
|
|
27
|
-
/** `critical`, `high`, `medium`, `low` or `info`. */
|
|
28
|
-
severity: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface HttpSecurity {
|
|
32
|
-
/** Whether the `Server` / `X-Powered-By` headers disclose a software version. */
|
|
33
|
-
discloses_version: boolean;
|
|
34
|
-
/** The ones that are missing. */
|
|
35
|
-
headers_missing: string[];
|
|
36
|
-
/** Security headers found on the HTTPS response (`strict-transport-security`, `content-security-policy`, `x-content-type-options`, `x-frame-options`, `referrer-policy`, `permissions-policy`). */
|
|
37
|
-
headers_present: string[];
|
|
38
|
-
/** `true` when plain HTTP on port 80 redirects to HTTPS, `false` when it serves content or redirects elsewhere, absent when port 80 does not answer. */
|
|
39
|
-
http_redirects_to_https?: boolean | null;
|
|
40
|
-
/** Status of `GET https://<domain>/`. */
|
|
41
|
-
https_status?: number | null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface MailSecurity {
|
|
45
|
-
/** DMARC policy: `reject`, `quarantine`, `none` or `absent`. */
|
|
46
|
-
dmarc?: string | null;
|
|
47
|
-
/** Whether an MTA-STS policy is published (`_mta-sts` TXT record). */
|
|
48
|
-
mta_sts: boolean;
|
|
49
|
-
/** Mail servers (MX) of the website's domain, highest priority first (at most 5). */
|
|
50
|
-
mx: string[];
|
|
51
|
-
/** Mail platform deduced from the MX records (`google-workspace`, `microsoft-365`, ...). */
|
|
52
|
-
provider?: string | null;
|
|
53
|
-
/** SPF policy: `strict` (-all), `soft` (~all), `neutral` (?all), `open` (+all) or `none`. */
|
|
54
|
-
spf?: string | null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface TlsSecurity {
|
|
58
|
-
/** Days left before expiry (negative once expired). */
|
|
59
|
-
days_remaining?: number | null;
|
|
60
|
-
/** Why the handshake or validation failed, when it did. */
|
|
61
|
-
error?: string | null;
|
|
62
|
-
/** Certificate end of validity (UTC). */
|
|
63
|
-
expires_at?: string | null;
|
|
64
|
-
issuer?: string | null;
|
|
65
|
-
/** `TLS1.3` or `TLS1.2`. */
|
|
66
|
-
protocol?: string | null;
|
|
67
|
-
/** Whether HTTPS answered on port 443. */
|
|
68
|
-
reachable: boolean;
|
|
69
|
-
/** Number of host names the certificate covers. */
|
|
70
|
-
san_count: number;
|
|
71
|
-
/** Whether the certificate chain validates for this host name. */
|
|
72
|
-
valid: boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface GetReportResponse {
|
|
76
|
-
/** How old this report is, in seconds (0 for a fresh assessment). */
|
|
77
|
-
age_seconds: number;
|
|
78
|
-
/** Addresses found on a public IP blocklist (IPv4 only). */
|
|
79
|
-
blocklisted: BlocklistHit[];
|
|
80
|
-
dns: DnsSecurity;
|
|
81
|
-
/** The host that was assessed, lowercased, without scheme or path. */
|
|
82
|
-
domain: string;
|
|
83
|
-
/** Everything worth acting on, most severe first. */
|
|
84
|
-
findings: Finding[];
|
|
85
|
-
/** `true` when this report was served from a stored result. */
|
|
86
|
-
from_cache: boolean;
|
|
87
|
-
/** `A` (90+), `B` (80+), `C` (65+), `D` (50+), `F`. */
|
|
88
|
-
grade: string;
|
|
89
|
-
http: HttpSecurity;
|
|
90
|
-
/** Public IPv4/IPv6 addresses of the host (at most 8). */
|
|
91
|
-
ip_addresses: string[];
|
|
92
|
-
mail: MailSecurity;
|
|
93
|
-
/** When the assessment was made (UTC). */
|
|
94
|
-
retrieved_at: string;
|
|
95
|
-
/** 0 to 100, higher is better; derived from the findings. */
|
|
96
|
-
score: number;
|
|
97
|
-
tls: TlsSecurity;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface GetReportRequest {
|
|
101
|
-
/** The domain to assess: `stripe.com`, `www.stripe.com` or a full URL (only the host is used). */
|
|
102
|
-
domain: string;
|
|
103
|
-
/** The oldest report you accept, in seconds. Omit it for the default (reports up to 1 hour old); `0` forces a fresh assessment. The response always says how old it is. */
|
|
104
|
-
max_age_seconds?: number | null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** Typed client for 🛡️ domain-security-service, e.g. `client.getReport(...)`. */
|
|
108
|
-
export class Client extends BaseClient {
|
|
109
|
-
/** Domain security check: SSL certificate check, DMARC SPF check, DNSSEC, security headers and blocklist status with a score ($0.009, x402) */
|
|
110
|
-
async getReport(request: GetReportRequest): Promise<GetReportResponse> {
|
|
111
|
-
return this.post<GetReportResponse>("/v1/domain-security/get_report", request);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export { ClientOptions };
|
package/src/langchain.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LangChain.js tools for 🛡️ domain-security-service, grouped in one Toolkit -- one tool per operation, each just an async function (JS has no separate sync form to generate). Requires the `@langchain/core`+`zod` peer dependencies declared in this package's own package.json -- imported from `domain-security/langchain`, never from the package root, so importing the base client never requires them installed.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { tool } from "@langchain/core/tools";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { Client } from "./index.js";
|
|
8
|
-
|
|
9
|
-
export class DomainSecurityToolkit {
|
|
10
|
-
private client: Client;
|
|
11
|
-
|
|
12
|
-
constructor(client: Client) {
|
|
13
|
-
this.client = client;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getTools() {
|
|
17
|
-
return [
|
|
18
|
-
tool(
|
|
19
|
-
async (input) => this.client.getReport(input),
|
|
20
|
-
{
|
|
21
|
-
name: "getReport",
|
|
22
|
-
description: "Domain security check: SSL certificate check, DMARC SPF check, DNSSEC, security headers and blocklist status with a score ($0.009, x402)",
|
|
23
|
-
schema: z.object({ domain: z.string(), max_age_seconds: z.number().nullable().optional() }),
|
|
24
|
-
},
|
|
25
|
-
),
|
|
26
|
-
];
|
|
27
|
-
}
|
|
28
|
-
}
|
package/test/index.test.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every domain-security client method sends a request to the expected path/HTTP verb and parses a well-formed response -- one test per operation, real fetch mocked via a plain reassignment of `globalThis.fetch` (no extra test/mocking dependency). Runs against the COMPILED package (`../dist/index.js`) -- build before testing.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { test } from "node:test";
|
|
6
|
-
import assert from "node:assert/strict";
|
|
7
|
-
import { Client } from "../dist/index.js";
|
|
8
|
-
|
|
9
|
-
test("getReport calls the expected path", async () => {
|
|
10
|
-
const originalFetch = globalThis.fetch;
|
|
11
|
-
globalThis.fetch = async (url, init = {}) => {
|
|
12
|
-
const parsed = new URL(url);
|
|
13
|
-
assert.equal((init.method ?? "GET").toUpperCase(), "POST");
|
|
14
|
-
assert.equal(parsed.pathname, "/v1/domain-security/get_report");
|
|
15
|
-
return new Response(JSON.stringify({ age_seconds: 0, blocklisted: [], dns: { caa: [], dnssec: false, name_servers: [] }, domain: "test", findings: [], from_cache: false, grade: "test", http: { discloses_version: false, headers_missing: [], headers_present: [], http_redirects_to_https: null, https_status: null }, ip_addresses: [], mail: { dmarc: null, mta_sts: false, mx: [], provider: null, spf: null }, retrieved_at: "test", score: 0, tls: { days_remaining: null, error: null, expires_at: null, issuer: null, protocol: null, reachable: false, san_count: 0, valid: false } }), { status: 200 });
|
|
16
|
-
};
|
|
17
|
-
try {
|
|
18
|
-
const client = new Client("https://example.test");
|
|
19
|
-
const result = await client.getReport({ domain: "test", max_age_seconds: null });
|
|
20
|
-
assert.ok(result !== undefined);
|
|
21
|
-
} finally {
|
|
22
|
-
globalThis.fetch = originalFetch;
|
|
23
|
-
}
|
|
24
|
-
});
|
package/test/langchain.test.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every domain-security LangChain tool through the real StructuredTool (`.invoke()`), not just the underlying client method -- catches schema-shape bugs a plain client-method test would miss. Requires the `langchain`/`zod` dev dependencies.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { test } from "node:test";
|
|
6
|
-
import assert from "node:assert/strict";
|
|
7
|
-
import { Client } from "../dist/index.js";
|
|
8
|
-
import { DomainSecurityToolkit } from "../dist/langchain.js";
|
|
9
|
-
|
|
10
|
-
test("getReport tool invoke", async () => {
|
|
11
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ age_seconds: 0, blocklisted: [], dns: { caa: [], dnssec: false, name_servers: [] }, domain: "test", findings: [], from_cache: false, grade: "test", http: { discloses_version: false, headers_missing: [], headers_present: [], http_redirects_to_https: null, https_status: null }, ip_addresses: [], mail: { dmarc: null, mta_sts: false, mx: [], provider: null, spf: null }, retrieved_at: "test", score: 0, tls: { days_remaining: null, error: null, expires_at: null, issuer: null, protocol: null, reachable: false, san_count: 0, valid: false } }), { status: 200 });
|
|
12
|
-
const toolkit = new DomainSecurityToolkit(new Client("https://example.test"));
|
|
13
|
-
const t = toolkit.getTools().find((x) => x.name === "getReport");
|
|
14
|
-
const result = await t.invoke({ domain: "test", max_age_seconds: 0 });
|
|
15
|
-
assert.ok(result !== undefined);
|
|
16
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ES2020",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"rootDir": "src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"src"
|
|
15
|
-
]
|
|
16
|
-
}
|