### Contribute to Axis Project Repository Source: https://github.com/funish/axis/blob/main/README.md Instructions for forking, cloning, and setting up the Axis project for contribution. It includes adding the upstream remote, installing dependencies, and starting the development mode. This process ensures contributors can work on the project effectively. ```bash # Clone your fork: git clone https://github.com/YOUR_USERNAME/axis.git cd axis # Add upstream remote: git remote add upstream https://github.com/funish/axis.git # Install dependencies: pnpm install # Development mode: pnpm dev ``` -------------------------------- ### Setting up a DNS over HTTPS (DoH) Server with UnDns Source: https://github.com/funish/axis/blob/main/packages/undns/README.md Provides code examples for creating and running a DNS over HTTPS server using UnDns. It shows how to start a standalone server or integrate the DoH handler into an existing h3 application. ```typescript import { createDohServer, createDohHandler } from "undns/servers/doh"; // Create and start DoH server const dohServer = createDohServer(); dohServer.serve(8080); console.log("DoH Server running on http://localhost:8080/dns-query"); // Use handler with existing h3 app import { createApp } from "h3"; const app = createApp(); const dohHandler = createDohHandler(); app.use("/dns-query", dohHandler); ``` -------------------------------- ### Basic RDAP Server Setup in TypeScript Source: https://github.com/funish/axis/blob/main/packages/rdap/README.md Sets up and starts a basic RDAP server using the rdap library. This snippet shows how to initialize the server and make it listen on a specified port. It also outlines the available default endpoints for various RDAP query types. ```typescript import { createRdapServer, createRdapHandler } from "rdap/server"; // Create and start RDAP server const server = createRdapServer(); server.serve(8080); // RDAP Server running on http://localhost:8080 // Available endpoints: // GET /help - Server help // GET /domain/example.com - Domain info // GET /ip/8.8.8.8 - IP info // GET /autnum/15169 - ASN info // GET /nameserver/ns1.example.com - Nameserver info // GET /entity/ABC123-EXAMPLE - Entity info ``` -------------------------------- ### Install ipdo IP Library Source: https://github.com/funish/axis/blob/main/packages/ipdo/README.md Demonstrates how to install the ipdo library using different package managers like npm, yarn, and pnpm. ```bash # Using npm npm install ipdo # Using yarn yarn add ipdo # Using pnpm pnpm add ipdo ``` -------------------------------- ### Install and Use Axis Network Toolkit Source: https://github.com/funish/axis/blob/main/README.md This snippet demonstrates how to install the Axis project and use its core functionalities for IP address manipulation, DNS management, and RDAP queries. It requires Node.js and pnpm for installation. ```bash git clone https://github.com/funish/axis.git cd axis pnpm install ``` ```typescript // IP address manipulation with ipdo import { isValidIP, parseCIDR, ipInRange } from "ipdo"; console.log(isValidIP("192.168.1.1")); // true const range = parseCIDR("192.168.0.0/24"); console.log(ipInRange("192.168.0.0/24", "192.168.0.1")); // true // DNS management with undns import { createDNSManager } from "undns"; import nodeDriver from "undns/drivers/node"; const dns = createDNSManager({ driver: nodeDriver({ servers: ["8.8.8.8", "1.1.1.1"], }), }); const records = await dns.getRecords("example.com"); console.log(`Found ${records.length} records`); // RDAP queries with rdap import { queryDomain, queryIP, queryASN } from "rdap"; const domainInfo = await queryDomain("example.com"); const ipInfo = await queryIP("8.8.8.8"); const asnInfo = await queryASN("15169"); console.log("Domain:", domainInfo.handle); console.log("IP Network:", ipInfo.handle); console.log("ASN:", asnInfo.handle); ``` -------------------------------- ### Install rdap Client and Server Source: https://github.com/funish/axis/blob/main/packages/rdap/README.md Instructions for installing the rdap library using popular package managers like npm, yarn, and pnpm. This is the primary step to integrate the RDAP client and server functionalities into your project. ```bash # Using npm npm install rdap # Using yarn yarn add rdap # Using pnpm pnpm add rdap ``` -------------------------------- ### Basic UnDns Setup with Node.js Driver Source: https://github.com/funish/axis/blob/main/packages/undns/README.md Demonstrates how to initialize the UnDns manager using the built-in Node.js DNS driver. It configures the manager to use specified DNS servers for queries. ```typescript import { createDNSManager } from "undns"; import nodeDriver from "undns/drivers/node"; // Create DNS manager with Node.js driver const dns = createDNSManager({ driver: nodeDriver({ servers: ["8.8.8.8", "1.1.1.1"], // Use Google and Cloudflare DNS }), }); ``` -------------------------------- ### Install UnDns Package using npm, yarn, or pnpm Source: https://github.com/funish/axis/blob/main/packages/undns/README.md Installs the UnDns library using popular package managers. This is the first step to integrating UnDns into your Node.js project. ```bash # Install with npm $ npm install undns # Install with yarn $ yarn add undns # Install with pnpm $ pnpm add undns ``` -------------------------------- ### Create DNS over HTTPS (DoH) Servers (TypeScript) Source: https://context7.com/funish/axis/llms.txt Explains how to build RFC 8484 compliant DNS over HTTPS servers using the undns library. Shows creating a basic DoH server and one with custom upstream DNS servers. Supports both GET and POST methods for queries. ```typescript import { createDohServer } from "undns/servers/doh"; // Create basic DoH server const dohServer = createDohServer(); dohServer.serve(8080); console.log("DoH Server running on http://localhost:8080/dns-query"); // Query the server using standard DoH clients: // curl 'http://localhost:8080/dns-query?name=example.com&type=A' // Create DoH server with custom upstream DNS const customDohServer = createDohServer({ upstream: { servers: ["1.1.1.1", "8.8.8.8"] } }); customDohServer.serve(8053); // Server supports both GET and POST methods // GET: /dns-query?name=example.com&type=A // POST: /dns-query (with DNS wire format in body) ``` -------------------------------- ### Find Bootstrap Servers and Get Metadata (TypeScript) Source: https://github.com/funish/axis/blob/main/packages/rdap/README.md This section illustrates how to find the appropriate RDAP bootstrap server for a given query type and query, and how to retrieve bootstrap metadata for offline use. It also shows how to force a refresh of this bootstrap data. ```typescript import { findBootstrapServer, getBootstrapMetadata } from "rdap"; // Find appropriate RDAP server for a query const serverUrl = await findBootstrapServer("dns", "example.com"); console.log(serverUrl); // "https://rdap.verisign.com" const serverUrl = await findBootstrapServer("ipv4", "8.8.8.8"); console.log(serverUrl); // "https://rdap.arin.net" // Get bootstrap metadata for offline usage const metadata = await getBootstrapMetadata("ipv4"); console.log(metadata.servers); // Available IPv4 RDAP servers // Force refresh bootstrap data const freshMetadata = await getBootstrapMetadata("dns", true); ``` -------------------------------- ### Handle RDAP Query Errors Gracefully (TypeScript) Source: https://github.com/funish/axis/blob/main/packages/rdap/README.md This code example demonstrates how to implement robust error handling for RDAP queries using a try-catch block. It shows how to log errors and identify common error types such as 'not found', 'rate limit', and authentication failures. ```typescript import { queryRDAP } from "rdap"; try { const data = await queryRDAP("nonexistent-domain.example"); } catch (error) { console.error(`RDAP query failed: ${error.message}`); // Common error types: if (error.message.includes("not found")) { // Handle 404 errors } if (error.message.includes("rate limit")) { // Handle 429 errors } if (error.message.includes("authentication failed")) { // Handle 401/403 errors } } ``` -------------------------------- ### Integrate DoH Handler with h3 (TypeScript) Source: https://context7.com/funish/axis/llms.txt Shows how to integrate a DoH handler into an existing h3 application for custom routing. Includes setting up CORS support and basic health and metrics endpoints. The handler supports GET and POST requests. ```typescript import { createApp } from "h3"; import { createDohHandler } from "undns/servers/doh"; // Create h3 app const app = createApp(); // Create DoH handler const dohHandler = createDohHandler({ upstream: { servers: ["8.8.8.8", "1.1.1.1"] } }); // Mount DoH handler at custom path app.use("/dns-query", dohHandler); // Add CORS support for browser clients app.use("/dns-query", (event) => { event.node.res.setHeader("Access-Control-Allow-Origin", "*"); event.node.res.setHeader("Access-Control-Allow-Methods", "GET, POST"); event.node.res.setHeader("Access-Control-Allow-Headers", "Content-Type"); }); // Add health check endpoint app.use("/health", () => ({ status: "ok", service: "DoH Server" })); // Add metrics endpoint let queryCount = 0; app.use("/metrics", () => ({ queries: queryCount })); // Start server // createServer(toNodeListener(app)).listen(3000); ``` -------------------------------- ### DNS over HTTPS (DoH) Server Source: https://context7.com/funish/axis/llms.txt Create and configure RFC 8484 compliant DNS over HTTPS servers using the undns library. Supports GET and POST requests. ```APIDOC ## DNS over HTTPS Server ### Creating DoH Servers Build RFC 8484 compliant DNS over HTTPS servers. ### Method GET, POST ### Endpoint `/dns-query` ### Parameters #### Query Parameters (for GET requests) - **name** (string) - Required - The domain name to query. - **type** (string) - Required - The DNS record type (e.g., A, AAAA, MX). #### Request Body (for POST requests) - **DNS wire format** (binary) - Required - The DNS query in wire format. ### Request Example (GET) ```bash curl 'http://localhost:8080/dns-query?name=example.com&type=A' ``` ### Request Example (POST) ```bash curl -X POST -d '' http://localhost:8080/dns-query ``` ### Response #### Success Response (200) - **DNS wire format** (binary) - The DNS response in wire format. ### DoH Handler Integration with h3 Integrate DoH handler into existing h3 applications for custom routing. ### Method GET, POST ### Endpoint `/dns-query` (or custom path) ### Parameters (See parameters for 'Creating DoH Servers') ### Request Example (h3 Integration) ```typescript import { createApp } from "h3"; import { createDohHandler } from "undns/servers/doh"; const app = createApp(); const dohHandler = createDohHandler({ upstream: { servers: ["8.8.8.8", "1.1.1.1"] } }); app.use("/dns-query", dohHandler); // Add CORS and other middleware as needed app.use("/dns-query", (event) => { event.node.res.setHeader("Access-Control-Allow-Origin", "*"); event.node.res.setHeader("Access-Control-Allow-Methods", "GET, POST"); event.node.res.setHeader("Access-Control-Allow-Headers", "Content-Type"); }); // Server creation omitted for brevity // createServer(toNodeListener(app)).listen(3000); ``` ``` -------------------------------- ### Integrate RDAP Handler with h3 Source: https://context7.com/funish/axis/llms.txt Integrates the RDAP handler into existing h3 applications. It sets up an h3 server, creates an RDAP handler with authorization and fetch options, and mounts it to a '/rdap' route. An additional '/health' route is included. The server can be started using a Node.js http server. ```typescript import { createApp } from "h3"; import { createRdapHandler } from "rdap/server"; // Create h3 app const app = createApp(); // Create RDAP handler with authorization const rdapHandler = createRdapHandler({ baseUrl: "https://rdap.example.com", authorize: async (event) => { const authHeader = event.headers.get("authorization"); if (!authHeader?.startsWith("Bearer ")) { throw new Error("Unauthorized"); } return true; }, fetchOptions: { headers: { "User-Agent": "MyRDAPProxy/1.0" } } }); // Mount RDAP handler app.use("/rdap", rdapHandler); // Add additional routes app.use("/health", () => ({ status: "ok" })); // Start server (using your preferred runtime) // For Node.js: // import { toNodeListener } from "h3"; // import { createServer } from "http"; // createServer(toNodeListener(app)).listen(3000); ``` -------------------------------- ### Develop and Test Axis Project Source: https://github.com/funish/axis/blob/main/README.md This section provides commands for setting up the development environment, building the project, running linters, and testing the implementation within the Axis monorepo. It utilizes pnpm for package management. ```bash # Development mode pnpm dev # Build the project pnpm build # Run linting pnpm lint # Test the implementation bun playground/drivers/node.ts ``` -------------------------------- ### Parse CIDR Notation and Calculate Range Details (TypeScript) Source: https://context7.com/funish/axis/llms.txt Parses CIDR (Classless Inter-Domain Routing) notation to extract network details like the start and end IP addresses, prefix length, and version. It also provides functions to get the network mask and calculate the total number of IPs within a given CIDR range. ```typescript import { parseCIDR, firstIPInRange, lastIPInRange, maskForCIDR, rangeSize } from "ipdo"; // Parse CIDR notation const range = parseCIDR("192.168.1.0/24"); console.log(range); // { // start: 3232235776, // end: 3232236031, // prefix: 24, // version: 4 // } // Get first and last IPs in range console.log(firstIPInRange("192.168.1.0/24")); // "192.168.1.0" console.log(lastIPInRange("192.168.1.0/24")); // "192.168.1.255" // Get network mask console.log(maskForCIDR("192.168.1.0/24")); // "255.255.255.0" console.log(maskForCIDR("192.168.0.0/16")); // "255.255.0.0" // Calculate range size console.log(rangeSize("192.168.1.0/24")); // 256 console.log(rangeSize("10.0.0.0/8")); // 16777216 // IPv6 ranges console.log(firstIPInRange("2001:db8::/32")); // "2001:0db8:0000:0000:0000:0000:0000:0000" console.log(lastIPInRange("2001:db8::/32")); // "2001:0db8:ffff:ffff:ffff:ffff:ffff:ffff" ``` -------------------------------- ### POST /queryNameserver Source: https://context7.com/funish/axis/llms.txt Query nameserver registration and configuration details. ```APIDOC ## POST /queryNameserver ### Description Query nameserver registration and configuration details. Supports custom RDAP servers. ### Method POST ### Endpoint /queryNameserver ### Parameters #### Request Body - **nameserverName** (string) - Required - The hostname of the nameserver to query. - **options** (object) - Optional - Configuration options for the query. - **baseUrl** (string) - Optional - The base URL for a custom RDAP server. ### Request Example ```json { "nameserverName": "ns1.example.com", "options": { "baseUrl": "https://rdap.arin.net/registry" } } ``` ### Response #### Success Response (200) - **handle** (string) - The handle of the nameserver. - **ldhName** (string) - The LDH name of the nameserver. - **status** (array of strings) - The status of the nameserver registration. - **ipAddresses** (object) - IP addresses associated with the nameserver. - **v4** (array of strings) - IPv4 addresses. - **v6** (array of strings) - IPv6 addresses. #### Response Example ```json { "handle": "NS1_EXAMPLE_COM", "ldhName": "ns1.example.com", "status": ["active"], "ipAddresses": { "v4": ["192.0.2.1"], "v6": ["2001:db8::1"] } } ``` ``` -------------------------------- ### Create RDAP Servers (TypeScript) Source: https://context7.com/funish/axis/llms.txt Implement RDAP servers using the 'rdap/server' module. Supports creating basic proxy servers that forward requests to IANA bootstrap servers, servers that proxy to a specific RDAP registry, or servers with custom data providers for custom responses. Requires the 'rdap/server' library. ```typescript import { createRdapServer, createRdapHandler } from "rdap/server"; // Create basic RDAP server (proxies to IANA bootstrap servers) const server = createRdapServer(); server.serve(8080); console.log("RDAP Server running on http://localhost:8080"); // Available endpoints: // GET /help - Server capabilities // GET /domain/example.com - Domain info // GET /ip/8.8.8.8 - IP network info // GET /autnum/15169 - ASN info // GET /nameserver/ns1.example.com - Nameserver info // GET /entity/GOGL - Entity info // Create server with custom base URL (proxy mode) const proxyServer = createRdapServer({ baseUrl: "https://rdap.arin.net/registry" }); proxyServer.serve(8080); // Create server with custom data provider const customServer = createRdapServer({ dataProvider: async (query, type) => { console.log(`Query: ${query}, Type: ${type}`); // Return custom data from your database if (type === "domain") { return { objectClassName: "domain", handle: query.toUpperCase(), ldhName: query, status: ["active"], events: [ { eventAction: "registration", eventDate: new Date().toISOString() } ] }; } throw new Error(`Query type ${type} not supported`); } }); customServer.serve(8080); ``` -------------------------------- ### Available UnDns Drivers Source: https://github.com/funish/axis/blob/main/packages/undns/README.md Lists the different DNS drivers available for use with UnDns, including Node.js, Cloudflare, DNS over HTTPS, and a null driver for testing purposes. ```typescript // Node.js DNS driver (read-only) import nodeDriver from "undns/drivers/node"; // Cloudflare DNS driver (read-write) import cloudflareDriver from "undns/drivers/cloudflare"; // DNS over HTTPS driver (read-only) import dohDriver from "undns/drivers/doh"; // Null driver (for testing) import nullDriver from "undns/drivers/null"; ``` -------------------------------- ### Get RDAP Bootstrap Metadata Source: https://github.com/funish/axis/blob/main/packages/rdap/README.md Retrieves bootstrap metadata essential for RDAP server discovery. This function supports offline usage by leveraging cached data and can be configured to force a refresh from IANA. It returns a promise resolving to metadata containing server listings. ```typescript getBootstrapMetadata(type: RdapBootstrapType, fetch?: boolean): Promise ``` -------------------------------- ### POST /queryIP Source: https://context7.com/funish/axis/llms.txt Query IP address allocation and registration data for both IPv4 and IPv6. ```APIDOC ## POST /queryIP ### Description Query IP address allocation and registration data for both IPv4 and IPv6 networks. ### Method POST ### Endpoint /queryIP ### Parameters #### Request Body - **ipAddress** (string) - Required - The IP address (IPv4 or IPv6) to query. ### Request Example ```json { "ipAddress": "8.8.8.8" } ``` ### Response #### Success Response (200) - **handle** (string) - The handle of the IP network. - **startAddress** (string) - The starting IP address of the allocation. - **endAddress** (string) - The ending IP address of the allocation. - **ipVersion** (string) - The IP version ('v4' or 'v6'). - **name** (string) - The name associated with the IP network. - **type** (string) - The type of IP allocation. - **country** (string) - The country code associated with the IP network. #### Response Example ```json { "handle": "NET-8-8-8-0-1", "startAddress": "8.8.8.0", "endAddress": "8.8.8.255", "ipVersion": "v4", "name": "LVLT-GOGL-8-8-8", "type": "DIRECT ALLOCATION", "country": "US" } ``` ``` -------------------------------- ### POST /queryDomain Source: https://context7.com/funish/axis/llms.txt Query domain registration data using the RDAP protocol. Supports automatic server discovery and custom server configurations. ```APIDOC ## POST /queryDomain ### Description Query domain registration data using RDAP protocol with automatic server discovery. You can also specify custom RDAP servers and authentication headers. ### Method POST ### Endpoint /queryDomain ### Parameters #### Request Body - **domainName** (string) - Required - The domain name to query. - **options** (object) - Optional - Configuration options for the query. - **baseUrl** (string) - Optional - The base URL for a custom RDAP server. - **fetchOptions** (object) - Optional - Options for the underlying fetch request, such as headers or timeout. - **headers** (object) - Optional - Custom headers to include in the request. - **timeout** (number) - Optional - Request timeout in milliseconds. ### Request Example ```json { "domainName": "example.com", "options": { "baseUrl": "https://rdap.verisign.com/com/v1", "fetchOptions": { "headers": { "Authorization": "Bearer your-token-here", "User-Agent": "MyApp/1.0" }, "timeout": 5000 } } } ``` ### Response #### Success Response (200) - **handle** (string) - The unique identifier for the domain. - **ldhName** (string) - The domain name in LDH format. - **status** (array of strings) - The status of the domain registration. - **nameservers** (array of objects) - A list of nameservers associated with the domain. - **ldhName** (string) - The LDH name of the nameserver. - **events** (array of objects) - A list of events related to the domain. - **eventAction** (string) - The type of event. - **eventDate** (string) - The date and time of the event. - **entities** (array of objects) - Information about entities associated with the domain (e.g., registrant, registrar). - **roles** (array of strings) - The roles of the entity. - **handle** (string) - The handle of the entity. #### Response Example ```json { "handle": "EXAMPLE-COM", "ldhName": "example.com", "status": ["active"], "nameservers": [ { "ldhName": "ns1.example.com" }, { "ldhName": "ns2.example.com" } ], "events": [ { "eventAction": "registration", "eventDate": "1995-08-14T04:00:00Z" }, { "eventAction": "last changed", "eventDate": "2023-08-14T07:01:38Z" } ], "entities": [ { "roles": ["registrant"], "handle": "REGISTRANT-ORG" }, { "roles": ["registrar"], "handle": "GOADDY" } ] } ``` ``` -------------------------------- ### Safe DNS Operations with Error Handling (TypeScript) Source: https://context7.com/funish/axis/llms.txt Illustrates using utility functions `safeCall` and `unwrapResult` from `undns/utils` for robust DNS operations with proper error handling. Demonstrates safe calls with default fallbacks, unwrapping results, and batch queries with error handling. ```typescript import { createDNSManager } from "undns"; import { safeCall, unwrapResult } from "undns/utils"; import nodeDriver from "undns/drivers/node"; const dns = createDNSManager({ driver: nodeDriver({ servers: ["8.8.8.8"] }) }); // Safe call with default fallback value const result = await safeCall( () => dns.getRecords("nonexistent-domain.example"), [] // Default value on error ); if (result.error) { console.error("DNS query failed:", result.error.message); console.log("Using default:", result.value); // [] } else { console.log("Records:", result.value); } // Unwrap result (throws on error) try { const successResult = await safeCall( () => dns.getRecords("example.com"), [] ); const records = unwrapResult(successResult); console.log("Got records:", records); } catch (error) { console.error("Failed to get records:", error); } // Batch queries with error handling const domains = ["example.com", "google.com", "invalid-domain.xyz"]; const results = await Promise.all( domains.map(domain => safeCall(() => dns.getRecords(domain, { type: "A" }), []) ) ); results.forEach((result, i) => { if (result.error) { console.log(`${domains[i]}: Error - ${result.error.message}`); } else { console.log(`${domains[i]}: ${result.value.length} records`); } }); ``` -------------------------------- ### Query IP Network Information using RDAP (TypeScript) Source: https://context7.com/funish/axis/llms.txt Retrieves IP address allocation and registration data for both IPv4 and IPv6 addresses. The function takes an IP address string and returns details such as handle, start and end addresses, IP version, name, type, and country. Dependencies include the 'rdap' library. ```typescript import { queryIP } from "rdap"; // Query IPv4 network information const ipv4Info = await queryIP("8.8.8.8"); console.log({ handle: ipv4Info.handle, startAddress: ipv4Info.startAddress, endAddress: ipv4Info.endAddress, ipVersion: ipv4Info.ipVersion, name: ipv4Info.name, type: ipv4Info.type, country: ipv4Info.country }); // Output: // { // handle: "NET-8-8-8-0-1", // startAddress: "8.8.0", // endAddress: "8.8.255", // ipVersion: "v4", // name: "LVLT-GOGL-8-8-8", // type: "DIRECT ALLOCATION", // country: "US" // } // Query IPv6 network information const ipv6Info = await queryIP("2001:4860:4860::8888"); console.log({ handle: ipv6Info.handle, startAddress: ipv6Info.startAddress, endAddress: ipv6Info.endAddress, ipVersion: ipv6Info.ipVersion }); ``` -------------------------------- ### RDAP Type Detection and Validation Utilities (TypeScript) Source: https://context7.com/funish/axis/llms.txt Automatically detect the type of an RDAP query (domain, IP, ASN, nameserver) and validate input formats. Includes functions to get bootstrap types, check if a string is a valid domain, validate and format Autonomous System Numbers (ASNs), and convert internationalized domain names to ASCII. Dependencies: 'rdap' library. ```typescript import { getQueryType, getBootstrapType, isDomain, isAsn, formatAsn, convertToAscii } from "rdap"; // Automatic type detection console.log(getQueryType("example.com")); // "domain" console.log(getQueryType("8.8.8.8")); // "ip" console.log(getQueryType("2001:db8::1")); // "ip" console.log(getQueryType("AS15169")); // "autnum" console.log(getQueryType("ns1.example.com")); // "nameserver" // Get bootstrap type for server discovery console.log(getBootstrapType("example.com")); // "dns" console.log(getBootstrapType("8.8.8.8")); // "ipv4" console.log(getBootstrapType("2001:db8::1")); // "ipv6" console.log(getBootstrapType("AS15169")); // "asn" // Validate domain names console.log(isDomain("example.com")); // true console.log(isDomain("sub.example.com")); // true console.log(isDomain("not a domain")); // false // Validate and format ASN console.log(isAsn("AS15169")); // true console.log(isAsn("15169")); // true console.log(formatAsn("AS15169")); // "15169" console.log(formatAsn("15169")); // "15169" // Convert internationalized domain names to ASCII console.log(convertToAscii("mΓΌnchen.de")); // "xn--mnchen-3ya.de" console.log(convertToAscii("ζ΅‹θ―•.com")); // "xn--0zwm56d.com" ``` -------------------------------- ### RDAP Bootstrap Utilities Source: https://github.com/funish/axis/blob/main/packages/rdap/README.md Utilities for working with RDAP bootstrap data, including type conversion, server discovery, and metadata retrieval. ```APIDOC ## bootstrapTypeToQueryType(type: RdapBootstrapType, queryType?: RdapQueryType): RdapQueryType ### Description Convert bootstrap type to query type. Optionally accepts explicit query type to override default mapping. ### Method N/A (Utility Function) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (N/A) - **RdapQueryType** (RdapQueryType) - The converted query type. #### Response Example N/A ## findBootstrapServer(type: RdapBootstrapType, query: string): Promise ### Description Find appropriate RDAP server for a given query type and query string. ### Method N/A (Utility Function) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (N/A) - **string** - Promise resolving to the RDAP server URL #### Response Example N/A ## getBootstrapMetadata(type: RdapBootstrapType, fetch?: boolean): Promise ### Description Get bootstrap metadata for RDAP server discovery. Supports offline usage with cached data. ### Method N/A (Utility Function) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters - **type** (RdapBootstrapType) - Required - Bootstrap type ("asn" | "dns" | "ipv4" | "ipv6" | "object-tags") - **fetch** (boolean) - Optional - Force refresh bootstrap data from IANA (default: false) #### Request Body N/A ### Request Example N/A ### Response #### Success Response (N/A) - **RdapBootstrapMetadata** (RdapBootstrapMetadata) - Promise resolving to bootstrap metadata with server listings #### Response Example N/A ``` -------------------------------- ### IP Address to Binary and Numeric Conversions in TypeScript Source: https://github.com/funish/axis/blob/main/packages/ipdo/README.md Demonstrates converting IPv4 and IPv6 addresses to their numeric representations (integer and BigInt) and vice versa, as well as converting to binary strings using the ipdo library. ```typescript import { ipv4ToInt, intToIPv4, ipv6ToBigInt, bigIntToIPv6, toBinary, toNumber, } from "ipdo"; // IPv4 conversions console.log(ipv4ToInt("192.168.0.1")); // 3232235521 console.log(intToIPv4(3232235521)); // '192.168.0.1' // IPv6 conversions console.log(ipv6ToBigInt("2001:db8::")); // 42540766452641154071740215577757643584n console.log(bigIntToIPv6(42540766452641154071740215577757643584n)); // '2001:db8::' // Generic conversions console.log(toBinary("192.168.0.1")); // '11000000101010000000000000000001' console.log(toNumber("192.168.0.1")); // 3232235521 ``` -------------------------------- ### Querying DNS Records with UnDns Source: https://github.com/funish/axis/blob/main/packages/undns/README.md Shows how to retrieve DNS records for a given domain using UnDns. It covers fetching all records, specific record types (A, MX), and checking for record existence. ```typescript // Get all records for a domain const records = await dns.getRecords("example.com"); // Get specific record type const aRecords = await dns.getRecords("example.com", { type: "A" }); const mxRecords = await dns.getRecords("example.com", { type: "MX" }); // Get a single record const firstARecord = await dns.getRecord("example.com", { type: "A" }); // Check if record exists const hasMxRecord = await dns.hasRecord("example.com", { type: "MX" }); ``` -------------------------------- ### DNS Queries with Subdomain Support Source: https://context7.com/funish/axis/llms.txt Queries DNS records for specific subdomains using the 'undns' library with the Node.js driver. It shows how to query subdomains by specifying the 'name' option or by using the full subdomain name in the query. It also demonstrates querying multiple subdomains in a loop. ```typescript import { createDNSManager } from "undns"; import nodeDriver from "undns/drivers/node"; const dns = createDNSManager({ driver: nodeDriver({ servers: ["8.8.8.8"] }) }); // Query subdomain by specifying name option const wwwRecords = await dns.getRecords("example.com", { name: "www", type: "A" }); console.log("www.example.com A records:", wwwRecords); // Or use full subdomain name const apiRecords = await dns.getRecords("api.example.com"); console.log("api.example.com records:", apiRecords); // Query multiple subdomains const subdomains = ["www", "mail", "api", "ftp"]; for (const sub of subdomains) { const records = await dns.getRecords("example.com", { name: sub, type: "A" }); console.log(`${sub}: ${records.length} records`); } ``` -------------------------------- ### Basic RDAP Client Queries in TypeScript Source: https://github.com/funish/axis/blob/main/packages/rdap/README.md Demonstrates how to use the rdap library in TypeScript to perform various RDAP queries, including domain, IP (IPv4 and IPv6), ASN, nameserver, and entity lookups. It also shows how to use the generic queryRDAP function with custom options like baseUrl and fetchOptions for advanced use cases. ```typescript import { queryRDAP, queryDomain, queryIP, queryASN, queryNameserver, queryEntity, queryHelp, createRdapServer, } from "rdap"; // Query domain information const domainInfo = await queryDomain("example.com"); // Returns: RdapDomain with nameservers, status, events, etc. // Query IP information (IPv4) const ipv4Info = await queryIP("8.8.8.8"); // Returns: RdapIpNetwork with network information, entities, etc. // Query IP information (IPv6) const ipv6Info = await queryIP("2001:db8::1"); // Returns: RdapIpNetwork with network information, entities, etc. // Query ASN information const asnInfo = await queryASN("15169"); // Returns: RdapAutnum with ASN details, network range, etc. // Query nameserver information const nsInfo = await queryNameserver("ns1.example.com"); // Returns: RdapNameserver with nameserver details, status, etc. // Query entity information const entityInfo = await queryEntity("GOGL"); // Returns: RdapEntity with entity details, roles, etc. // Query help information const helpInfo = await queryHelp(); // Returns: RdapHelp with RDAP server capabilities and reverse search properties // Generic query with options const data = await queryRDAP("example.com", { baseUrl: "https://custom-rdap-server.com", type: "domain", // Explicitly specify query type fetchOptions: { headers: { Authorization: "Bearer your-token", }, }, }); // All convenience functions also support options const domainWithCustomServer = await queryDomain("example.com", { baseUrl: "https://custom-rdap-server.com", fetchOptions: { headers: { "User-Agent": "MyApp/1.0" }, }, }); const nameserverWithType = await queryNameserver("ns1.example.com", { type: "nameserver", // Explicitly specify nameserver query }); // Create and start RDAP server const server = createRdapServer(); server.serve(8080); console.log("RDAP Server running on http://localhost:8080"); ``` -------------------------------- ### Manage DNS Records with Cloudflare Driver (TypeScript) Source: https://context7.com/funish/axis/llms.txt Demonstrates full read/write support for managing DNS records on Cloudflare using the undns library. Requires Cloudflare API token and Zone ID. It covers creating, reading, and removing DNS records. ```typescript import { createDNSManager } from "undns"; import cloudflareDriver from "undns/drivers/cloudflare"; // Create DNS manager with Cloudflare driver (requires API token) const dns = createDNSManager({ driver: cloudflareDriver({ apiToken: process.env.CLOUDFLARE_API_TOKEN, zoneId: process.env.CLOUDFLARE_ZONE_ID }) }); // Read operations (same as other drivers) const records = await dns.getRecords("example.com"); console.log(`Cloudflare has ${records.length} records`); // Write operations (Cloudflare driver supports these) // Create new A record const newRecord = await dns.setRecord("example.com", { name: "www", type: "A", address: "192.0.2.1", ttl: 3600 }); console.log(`Created record: ${newRecord.id}`); // Create multiple records at once const multipleRecords = await dns.setRecords("example.com", [ { name: "api", type: "A", address: "192.0.2.2" }, { name: "mail", type: "MX", priority: 10, exchange: "mail.example.com" }, { name: "@", type: "TXT", entries: ["v=spf1 include:_spf.example.com ~all"] } ]); console.log(`Created ${multipleRecords.length} records`); // Remove a record const recordToRemove = await dns.getRecord("example.com", { name: "old", type: "A" }); if (recordToRemove) { await dns.removeRecord("example.com", recordToRemove); console.log("Record removed"); } ``` -------------------------------- ### RDAP Types and Standards Source: https://github.com/funish/axis/blob/main/packages/rdap/README.md Details on the types used within the RDAP client and the standards it complies with. ```APIDOC ### πŸ“‹ Types #### `RdapOptions` Configuration options for RDAP queries: ```typescript interface RdapOptions { baseUrl?: string; // Custom RDAP server URL type?: RdapQueryType; // Explicit query type (overrides auto-detection) fetchOptions?: RequestInit; // Fetch API options (headers, auth, etc.) } ``` #### Response Types - `RdapDomain` - Domain information response - `RdapIpNetwork` - IP network information response - `RdapAutnum` - Autonomous system information response - `RdapNameserver` - Nameserver information response - `RdapEntity` - Entity information response - `RdapHelp` - Help and server capabilities response - `RdapErrorResponse` - Error response ## πŸ“– Standards Compliance This implementation strictly follows these RDAP-related standards: - πŸ“˜ [RFC 7480](https://tools.ietf.org/html/rfc7480) - HTTP Usage in RDAP - πŸ”’ [RFC 7481](https://tools.ietf.org/html/rfc7481) - Security Services for RDAP - πŸ” [RFC 7482](https://tools.ietf.org/html/rfc7482) - RDAP Query Format - πŸ“‹ [RFC 7483](https://tools.ietf.org/html/rfc7483) - RDAP JSON Responses - πŸ”„ [RFC 8056](https://tools.ietf.org/html/rfc8056) - EPP and RDAP Status Mapping - βœ… [ICANN RDAP Response Profile](https://www.icann.org/rdap) ### βœ… Specification Compliance Features - **HTTP Method**: Uses GET for all RDAP queries as required by RFC 7482 - **Content Negotiation**: Sends `Accept: application/rdap+json` header - **User-Agent**: Includes proper client identification - **URL Structure**: Follows `{baseUrl}/{queryType}/{query}` pattern - **Error Handling**: Implements comprehensive HTTP status code handling - **Help Support**: Provides `queryHelp()` for server capability discovery - **Bootstrap Service**: Uses IANA official bootstrap data for server discovery - **Language Support**: Includes `Accept-Language` header for internationalization ``` -------------------------------- ### Basic DNS Operations with Node.js Driver Source: https://context7.com/funish/axis/llms.txt Performs basic DNS queries using the built-in Node.js DNS resolver via the 'undns' library. It demonstrates creating a DNS manager with custom DNS servers, retrieving all records, specific record types (A, MX, TXT), a single record, and checking for record existence. ```typescript import { createDNSManager } from "undns"; import nodeDriver from "undns/drivers/node"; // Create DNS manager with Node.js driver const dns = createDNSManager({ driver: nodeDriver({ servers: ["8.8.8.8", "1.1.1.1"] // Custom DNS servers }) }); // Get all records for a domain const allRecords = await dns.getRecords("example.com"); console.log(`Found ${allRecords.length} records`); // Get specific record types const aRecords = await dns.getRecords("example.com", { type: "A" }); console.log("A records:", aRecords.map(r => r.address)); const mxRecords = await dns.getRecords("example.com", { type: "MX" }); mxRecords.forEach(r => { console.log(`MX: ${r.priority} ${r.exchange}`); }); const txtRecords = await dns.getRecords("example.com", { type: "TXT" }); txtRecords.forEach(r => { console.log("TXT:", r.entries.join(" ")); }); // Get single record (first match) const firstA = await dns.getRecord("example.com", { type: "A" }); if (firstA) { console.log(`Primary A record: ${firstA.address}`); } // Check if record exists const hasMX = await dns.hasRecord("example.com", { type: "MX" }); console.log(`Has MX record: ${hasMX}`); ``` -------------------------------- ### Query Domain with Custom RDAP Servers and Authentication (TypeScript) Source: https://context7.com/funish/axis/llms.txt Allows querying domain information using specific RDAP servers and custom authentication headers. You can specify a `baseUrl` for a custom server and provide `fetchOptions` for headers, timeouts, and other request configurations. This enables more control over the query process. ```typescript import { queryDomain } from "rdap"; // Use custom RDAP server const domainInfo = await queryDomain("example.com", { baseUrl: "https://rdap.verisign.com/com/v1" }); console.log(domainInfo.handle); // Add authentication headers const authenticatedQuery = await queryDomain("example.com", { fetchOptions: { headers: { "Authorization": "Bearer your-token-here", "User-Agent": "MyApp/1.0" } } }); // Combine custom server and options const result = await queryDomain("example.net", { baseUrl: "https://rdap.nic.net", fetchOptions: { headers: { "Accept-Language": "en-US,en;q=0.9" }, timeout: 5000 } }); ``` -------------------------------- ### Working with Subdomain DNS Records in UnDns Source: https://github.com/funish/axis/blob/main/packages/undns/README.md Illustrates how to query DNS records for subdomains using the UnDns library. You can specify a subdomain name directly or use the full subdomain address. ```typescript // Query subdomain records const wwwRecords = await dns.getRecords("example.com", { name: "www", type: "A", }); // Or specify full subdomain const subRecords = await dns.getRecords("api.example.com"); ```