@xyz17711/domain-security 0.0.0-stage → 0.1.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 CHANGED
@@ -1,3 +1,87 @@
1
- # Temporary Holding Version
1
+ # @xyz17711/domain-security
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![Publish](https://github.com/17711-services/clients/actions/workflows/publish-node.yml/badge.svg)](https://github.com/17711-services/clients/actions/workflows/publish-node.yml)
4
+ [![npm](https://img.shields.io/npm/v/@xyz17711/domain-security)](https://www.npmjs.com/package/@xyz17711/domain-security)
5
+ [![License](https://img.shields.io/npm/l/@xyz17711/domain-security)](https://github.com/17711-services/clients/blob/main/LICENSE)
6
+
7
+ Typed TypeScript client for **🛡️ domain-security-service**, part of the
8
+ [17711.xyz](https://api.17711.xyz) microservice fleet -- pay-per-call APIs settled in USDC via
9
+ [x402](https://x402.org), listed on [x402scan](https://www.x402scan.com/server/f1c7b972-3405-4b75-8b4f-d1bfbd6305ff).
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @xyz17711/domain-security
15
+ ```
16
+
17
+ ## Methods
18
+
19
+ | Method | Description |
20
+ | --- | --- |
21
+ | `getReport` | Domain security check: SSL certificate check, DMARC SPF check, DNSSEC, security headers and blocklist status with a score ($0.009, x402) |
22
+
23
+ ## Quickstart
24
+
25
+ ```typescript
26
+ import { Client } from "@xyz17711/domain-security";
27
+
28
+ const client = new Client("https://api.17711.xyz/registry/🛡️ domain-security-service");
29
+ // see the Methods table above for every available call and its request/response type
30
+ ```
31
+
32
+ ## Paying past the free quota
33
+
34
+ Every gated tool allows a small number of free calls per day; beyond that it returns a 402
35
+ challenge. Without a wallet configured, this client throws `PaymentRequiredError` with the price,
36
+ network, and payee address attached:
37
+
38
+ ```typescript
39
+ import { Client, PaymentRequiredError } from "@xyz17711/domain-security";
40
+
41
+ const client = new Client("https://api.17711.xyz/registry/🛡️ domain-security-service");
42
+ try {
43
+ await client.getReport(/* ... */);
44
+ } catch (e) {
45
+ if (e instanceof PaymentRequiredError) {
46
+ console.log(`needs ${e.priceUsdc} USDC on ${e.network}, payable to ${e.payTo}`);
47
+ }
48
+ }
49
+ ```
50
+
51
+ To pay automatically, configure a wallet on the client -- the private key should come from your
52
+ own environment/secrets manager, never a literal string in source code:
53
+
54
+ ```typescript
55
+ import { Client } from "@xyz17711/domain-security";
56
+
57
+ const client = new Client("https://api.17711.xyz/registry/🛡️ domain-security-service", {
58
+ x402PrivateKey: process.env.X402_PRIVATE_KEY,
59
+ x402ExpectedNetwork: "eip155:8453", // Base mainnet; use eip155:84532 for Base Sepolia testnet
60
+ x402MaxPaymentUsdc: 0.01, // refuse any single call above this
61
+ x402MaxTotalSpendUsdc: 1.0, // refuse once this WALLET's lifetime spend would exceed it
62
+ });
63
+ ```
64
+
65
+ **Never commit a private key.** Both spend caps are required together with the key -- a wallet
66
+ with real funds and no explicit caps refuses to construct at all (`WalletConfigError`), on
67
+ purpose. The cumulative cap is tracked per wallet address, shared by every `Client` you construct
68
+ with that same key in this process.
69
+
70
+ ## LangChain.js
71
+
72
+ ```typescript
73
+ import { Client } from "@xyz17711/domain-security";
74
+ import { DomainSecurityToolkit } from "@xyz17711/domain-security/langchain";
75
+
76
+ const client = new Client("https://api.17711.xyz/registry/🛡️ domain-security-service", { /* ...wallet options... */ });
77
+ const tools = new DomainSecurityToolkit(client).getTools();
78
+ ```
79
+
80
+ Requires the optional `@langchain/core`+`zod` peer dependencies (`npm install @langchain/core
81
+ zod`) -- importing the base package above never requires them; only `@xyz17711/domain-security/langchain`
82
+ does.
83
+
84
+ ## License
85
+
86
+ MIT -- see [`LICENSE`](../../LICENSE), shared by every language's client library in the
87
+ `clients` repo this package lives in.
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Typed HTTP client and request/response interfaces for 🛡️ domain-security-service.
3
+ */
4
+ import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
5
+ export interface BlocklistHit {
6
+ cidr: string;
7
+ ip: string;
8
+ source: string;
9
+ }
10
+ export interface DnsSecurity {
11
+ /** CAA records: the certificate authorities allowed to issue for the domain. */
12
+ caa: string[];
13
+ /** Whether the answer for the domain is validated by DNSSEC. */
14
+ dnssec: boolean;
15
+ /** Authoritative name servers (at most 8). */
16
+ name_servers: string[];
17
+ }
18
+ export interface Finding {
19
+ /** Stable machine-readable code, e.g. `tls.expired`, `mail.dmarc_absent`, `http.hsts_missing`. */
20
+ code: string;
21
+ /** What was observed and why it matters, in one sentence. */
22
+ message: string;
23
+ /** `critical`, `high`, `medium`, `low` or `info`. */
24
+ severity: string;
25
+ }
26
+ export interface HttpSecurity {
27
+ /** Whether the `Server` / `X-Powered-By` headers disclose a software version. */
28
+ discloses_version: boolean;
29
+ /** The ones that are missing. */
30
+ headers_missing: string[];
31
+ /** Security headers found on the HTTPS response (`strict-transport-security`, `content-security-policy`, `x-content-type-options`, `x-frame-options`, `referrer-policy`, `permissions-policy`). */
32
+ headers_present: string[];
33
+ /** `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. */
34
+ http_redirects_to_https?: boolean | null;
35
+ /** Status of `GET https://<domain>/`. */
36
+ https_status?: number | null;
37
+ }
38
+ export interface MailSecurity {
39
+ /** DMARC policy: `reject`, `quarantine`, `none` or `absent`. */
40
+ dmarc?: string | null;
41
+ /** Whether an MTA-STS policy is published (`_mta-sts` TXT record). */
42
+ mta_sts: boolean;
43
+ /** Mail servers (MX) of the website's domain, highest priority first (at most 5). */
44
+ mx: string[];
45
+ /** Mail platform deduced from the MX records (`google-workspace`, `microsoft-365`, ...). */
46
+ provider?: string | null;
47
+ /** SPF policy: `strict` (-all), `soft` (~all), `neutral` (?all), `open` (+all) or `none`. */
48
+ spf?: string | null;
49
+ }
50
+ export interface TlsSecurity {
51
+ /** Days left before expiry (negative once expired). */
52
+ days_remaining?: number | null;
53
+ /** Why the handshake or validation failed, when it did. */
54
+ error?: string | null;
55
+ /** Certificate end of validity (UTC). */
56
+ expires_at?: string | null;
57
+ issuer?: string | null;
58
+ /** `TLS1.3` or `TLS1.2`. */
59
+ protocol?: string | null;
60
+ /** Whether HTTPS answered on port 443. */
61
+ reachable: boolean;
62
+ /** Number of host names the certificate covers. */
63
+ san_count: number;
64
+ /** Whether the certificate chain validates for this host name. */
65
+ valid: boolean;
66
+ }
67
+ export interface GetReportResponse {
68
+ /** How old this report is, in seconds (0 for a fresh assessment). */
69
+ age_seconds: number;
70
+ /** Addresses found on a public IP blocklist (IPv4 only). */
71
+ blocklisted: BlocklistHit[];
72
+ dns: DnsSecurity;
73
+ /** The host that was assessed, lowercased, without scheme or path. */
74
+ domain: string;
75
+ /** Everything worth acting on, most severe first. */
76
+ findings: Finding[];
77
+ /** `true` when this report was served from a stored result. */
78
+ from_cache: boolean;
79
+ /** `A` (90+), `B` (80+), `C` (65+), `D` (50+), `F`. */
80
+ grade: string;
81
+ http: HttpSecurity;
82
+ /** Public IPv4/IPv6 addresses of the host (at most 8). */
83
+ ip_addresses: string[];
84
+ mail: MailSecurity;
85
+ /** When the assessment was made (UTC). */
86
+ retrieved_at: string;
87
+ /** 0 to 100, higher is better; derived from the findings. */
88
+ score: number;
89
+ tls: TlsSecurity;
90
+ }
91
+ export interface GetReportRequest {
92
+ /** The domain to assess: `stripe.com`, `www.stripe.com` or a full URL (only the host is used). */
93
+ domain: string;
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
+ max_age_seconds?: number | null;
96
+ }
97
+ /** Typed client for 🛡️ domain-security-service, e.g. `client.getReport(...)`. */
98
+ export declare class Client extends BaseClient {
99
+ /** Domain security check: SSL certificate check, DMARC SPF check, DNSSEC, security headers and blocklist status with a score ($0.009, x402) */
100
+ getReport(request: GetReportRequest): Promise<GetReportResponse>;
101
+ }
102
+ export { ClientOptions };
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Typed HTTP client and request/response interfaces for 🛡️ domain-security-service.
3
+ */
4
+ import { Client as BaseClient } from "@xyz17711/core";
5
+ /** Typed client for 🛡️ domain-security-service, e.g. `client.getReport(...)`. */
6
+ export class Client extends BaseClient {
7
+ /** Domain security check: SSL certificate check, DMARC SPF check, DNSSEC, security headers and blocklist status with a score ($0.009, x402) */
8
+ async getReport(request) {
9
+ return this.post("/v1/domain-security/get_report", request);
10
+ }
11
+ }
@@ -0,0 +1,19 @@
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
+ import { z } from "zod";
5
+ import { Client } from "./index.js";
6
+ export declare class DomainSecurityToolkit {
7
+ private client;
8
+ constructor(client: Client);
9
+ getTools(): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
10
+ domain: z.ZodString;
11
+ max_age_seconds: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
12
+ }, z.core.$strip>, {
13
+ domain: string;
14
+ max_age_seconds?: number | null | undefined;
15
+ }, {
16
+ domain: string;
17
+ max_age_seconds?: number | null | undefined;
18
+ }, import("./index.js").GetReportResponse, unknown, "getReport">[];
19
+ }
@@ -0,0 +1,19 @@
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
+ import { tool } from "@langchain/core/tools";
5
+ import { z } from "zod";
6
+ export class DomainSecurityToolkit {
7
+ constructor(client) {
8
+ this.client = client;
9
+ }
10
+ getTools() {
11
+ return [
12
+ tool(async (input) => this.client.getReport(input), {
13
+ name: "getReport",
14
+ description: "Domain security check: SSL certificate check, DMARC SPF check, DNSSEC, security headers and blocklist status with a score ($0.009, x402)",
15
+ schema: z.object({ domain: z.string(), max_age_seconds: z.number().nullable().optional() }),
16
+ }),
17
+ ];
18
+ }
19
+ }
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@xyz17711/domain-security",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Generated typed client for the 🛡️ domain-security-service 17711.xyz microservice.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./langchain": {
14
+ "types": "./dist/langchain.d.ts",
15
+ "default": "./dist/langchain.js"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "build": "tsc -p .",
20
+ "test": "npm run build && node --test test/*.test.mjs"
21
+ },
22
+ "dependencies": {
23
+ "@xyz17711/core": "^0.1.0"
24
+ },
25
+ "peerDependencies": {
26
+ "@langchain/core": ">=0.3",
27
+ "zod": "^3 || ^4"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "@langchain/core": {
31
+ "optional": true
32
+ },
33
+ "zod": {
34
+ "optional": true
35
+ }
36
+ },
37
+ "devDependencies": {
38
+ "typescript": "^5",
39
+ "@langchain/core": "^1.2",
40
+ "zod": "^4"
41
+ }
42
+ }
package/src/index.ts ADDED
@@ -0,0 +1,115 @@
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 };
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,24 @@
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
+ });
@@ -0,0 +1,16 @@
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 ADDED
@@ -0,0 +1,16 @@
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
+ }