{"id":15175640,"url":"https://github.com/dnslink-std/js","last_synced_at":"2025-10-26T11:31:11.936Z","repository":{"id":57108934,"uuid":"377587904","full_name":"dnslink-std/js","owner":"dnslink-std","description":"The reference implementation for DNSLink resolver in JavaScript. Tested in Node.js and in the Browser.","archived":false,"fork":false,"pushed_at":"2022-06-03T07:42:39.000Z","size":170,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T17:06:29.910Z","etag":null,"topics":["decentralized-web","dnslink","dweb","javascript","p2p"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnslink-std.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-16T18:11:58.000Z","updated_at":"2024-01-10T16:29:24.000Z","dependencies_parsed_at":"2022-08-20T17:40:48.782Z","dependency_job_id":null,"html_url":"https://github.com/dnslink-std/js","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnslink-std%2Fjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnslink-std%2Fjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnslink-std%2Fjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnslink-std%2Fjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnslink-std","download_url":"https://codeload.github.com/dnslink-std/js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238319416,"owners_count":19452336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decentralized-web","dnslink","dweb","javascript","p2p"],"created_at":"2024-09-27T12:39:48.434Z","updated_at":"2025-10-26T11:31:11.633Z","avatar_url":"https://github.com/dnslink-std.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @dnslink/js\n\nThe reference implementation for DNSLink resolver in JavaScript. Tested in Node.js and in the Browser.\n\n## Usage\n\nYou can use `dnslink` both as a [CLI tool](#command-line) or a [library](#javascript-api).\n\n## JavaScript API\n\nGetting started with DNSLink resolution in a jiffy:\n\n```javascript\nimport { resolve, DNSRcodeError } from '@dnslink/js'\n\n// assumes top-level await\nlet result\ntry {\n  result = await resolve('dnslink.dev/abcd?foo=bar', {\n    endpoints: ['dns.google'], // required! see more below.\n    /* (optional) */\n    signal, // AbortSignal that you can use to abort the request\n    timeout: 1000, // timeout for the operation\n    retries: 3 // retries in case of transport error\n  })\n} catch (err) {\n  // Errors provided by DNS server\n  if (err instanceof DNSRcodeError) {\n    err.rcode // Error code number following - https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6\n    err.error // Error code name following (same list)\n    err.code // `RCODE_${err.code}\n    err.domain // Domain lookup that resulted in the error\n    if (err.rcode === 3) {\n      // NXDomain = Domain not found; most relevant error\n    }\n  } else {\n    // A variety other errors may be thrown as well. Possible causes include, but are not limited to:\n    // - Invalid input\n    // - Timeouts / aborts\n    // - Networking errors\n    // - Incompatible dns packets provided by server\n  }\n}\nconst { links, log, txtEntries } = result\n\n// `links` is an object containing given links for the different namespaces\n// Each names contains an identifier and a ttl.\nlinks.ipfs === [{ identifier: 'QmTg....yomU', ttl: 60 }]\n\n// The `log` is always an Array and contains a list of log entries\n// that were should help to trace back how the linked data was resolved.\nArray.isArray(log)\n\n// The `txtEntries` are a reduced form of the links that contains the namespace \n// as part of the value\ntxtEntries === [{ value: '/ipfs/QmTg....yomU', ttl: 60 }]\n```\n\n### Endpoints\n\nYou **need** to specify endpoints to be used with the API. You can specify them the same way\nas you would in [`dns-query`](https://github.com/martinheidegger/dns-query#endpoints).\n\n## Possible log statements\n\nThe log statements follow the [DNSLink specification][log-codes].\n\n[log-codes]: https://github.com/dnslink-std/test/blob/main/LOG_CODES.md\n\n## Command Line\n\nTo use `dnslink` in the command line you will need Node.js installed. \n\nInstall it permanently using `npm i -g @dnslink/js` or run in on-the-fly\nusing `npx @dnslink/js`.\n\nYou can get detailed help for the app by passing a `--help` option at the end:\n\n```\n$ npx @dnslink/js --help\n```\n\n## License\n\nPublished under dual-license: [MIT OR Apache-2.0](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnslink-std%2Fjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnslink-std%2Fjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnslink-std%2Fjs/lists"}