domeneshop-mcp 1.0.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/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +223 -0
- package/dist/domeneshop/assert.d.ts +9 -0
- package/dist/domeneshop/assert.d.ts.map +1 -0
- package/dist/domeneshop/assert.js +14 -0
- package/dist/domeneshop/assert.js.map +1 -0
- package/dist/domeneshop/client.d.ts +23 -0
- package/dist/domeneshop/client.d.ts.map +1 -0
- package/dist/domeneshop/client.js +27 -0
- package/dist/domeneshop/client.js.map +1 -0
- package/dist/domeneshop/http.d.ts +44 -0
- package/dist/domeneshop/http.d.ts.map +1 -0
- package/dist/domeneshop/http.js +58 -0
- package/dist/domeneshop/http.js.map +1 -0
- package/dist/domeneshop/index.d.ts +14 -0
- package/dist/domeneshop/index.d.ts.map +1 -0
- package/dist/domeneshop/index.js +8 -0
- package/dist/domeneshop/index.js.map +1 -0
- package/dist/domeneshop/resources/dns.d.ts +68 -0
- package/dist/domeneshop/resources/dns.d.ts.map +1 -0
- package/dist/domeneshop/resources/dns.js +60 -0
- package/dist/domeneshop/resources/dns.js.map +1 -0
- package/dist/domeneshop/resources/domains.d.ts +27 -0
- package/dist/domeneshop/resources/domains.d.ts.map +1 -0
- package/dist/domeneshop/resources/domains.js +20 -0
- package/dist/domeneshop/resources/domains.js.map +1 -0
- package/dist/domeneshop/resources/dyndns.d.ts +12 -0
- package/dist/domeneshop/resources/dyndns.d.ts.map +1 -0
- package/dist/domeneshop/resources/dyndns.js +18 -0
- package/dist/domeneshop/resources/dyndns.js.map +1 -0
- package/dist/domeneshop/resources/forwards.d.ts +28 -0
- package/dist/domeneshop/resources/forwards.d.ts.map +1 -0
- package/dist/domeneshop/resources/forwards.js +58 -0
- package/dist/domeneshop/resources/forwards.js.map +1 -0
- package/dist/domeneshop/resources/invoices.d.ts +30 -0
- package/dist/domeneshop/resources/invoices.d.ts.map +1 -0
- package/dist/domeneshop/resources/invoices.js +28 -0
- package/dist/domeneshop/resources/invoices.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/annotations.d.ts +13 -0
- package/dist/mcp/annotations.d.ts.map +1 -0
- package/dist/mcp/annotations.js +18 -0
- package/dist/mcp/annotations.js.map +1 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/result.d.ts +8 -0
- package/dist/mcp/result.d.ts.map +1 -0
- package/dist/mcp/result.js +16 -0
- package/dist/mcp/result.js.map +1 -0
- package/dist/mcp/schema.d.ts +4 -0
- package/dist/mcp/schema.d.ts.map +1 -0
- package/dist/mcp/schema.js +2 -0
- package/dist/mcp/schema.js.map +1 -0
- package/dist/mcp/server.d.ts +5 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +18 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool.d.ts +7 -0
- package/dist/mcp/tool.d.ts.map +1 -0
- package/dist/mcp/tool.js +16 -0
- package/dist/mcp/tool.js.map +1 -0
- package/dist/mcp/tools/dns.d.ts +4 -0
- package/dist/mcp/tools/dns.d.ts.map +1 -0
- package/dist/mcp/tools/dns.js +147 -0
- package/dist/mcp/tools/dns.js.map +1 -0
- package/dist/mcp/tools/domains.d.ts +4 -0
- package/dist/mcp/tools/domains.d.ts.map +1 -0
- package/dist/mcp/tools/domains.js +29 -0
- package/dist/mcp/tools/domains.js.map +1 -0
- package/dist/mcp/tools/dyndns.d.ts +4 -0
- package/dist/mcp/tools/dyndns.d.ts.map +1 -0
- package/dist/mcp/tools/dyndns.js +22 -0
- package/dist/mcp/tools/dyndns.js.map +1 -0
- package/dist/mcp/tools/forwards.d.ts +4 -0
- package/dist/mcp/tools/forwards.d.ts.map +1 -0
- package/dist/mcp/tools/forwards.js +73 -0
- package/dist/mcp/tools/forwards.js.map +1 -0
- package/dist/mcp/tools/invoices.d.ts +4 -0
- package/dist/mcp/tools/invoices.d.ts.map +1 -0
- package/dist/mcp/tools/invoices.js +32 -0
- package/dist/mcp/tools/invoices.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +76 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# domeneshop-mcp
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
Initial public release: an MCP server exposing the Domeneshop API (domains,
|
|
6
|
+
DNS records, HTTP forwards, dynamic DNS and invoices) as 15 tools.
|
|
7
|
+
|
|
8
|
+
Future releases are documented here automatically by
|
|
9
|
+
[Changesets](https://github.com/changesets/changesets) — see
|
|
10
|
+
`.changeset/README.md` for the workflow.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Martin Zachariassen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# domeneshop-mcp
|
|
2
|
+
|
|
3
|
+
[](https://github.com/martinzachariassen/domeneshop-mcp/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
An [MCP](https://modelcontextprotocol.io) server that exposes the
|
|
7
|
+
[Domeneshop API](https://api.domeneshop.no/docs/) as tools, so an AI assistant can
|
|
8
|
+
manage your domains, DNS records, HTTP forwards and invoices.
|
|
9
|
+
|
|
10
|
+
Every operation the Domeneshop API offers is available as a tool — 15 of them,
|
|
11
|
+
covering domains, DNS, HTTP forwarding, dynamic DNS and invoices.
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
1. Get an API token and secret from
|
|
16
|
+
[domeneshop.no/admin?view=api](https://www.domeneshop.no/admin?view=api).
|
|
17
|
+
2. Register the server with Claude Code:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
claude mcp add domeneshop \
|
|
21
|
+
--env DOMENESHOP_API_TOKEN=your-token \
|
|
22
|
+
--env DOMENESHOP_API_SECRET=your-secret \
|
|
23
|
+
-- npx -y domeneshop-mcp
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
That's it — ask Claude to list your domains and it will pick up the new
|
|
27
|
+
tools. This registers the server for the current project only; add `-s user`
|
|
28
|
+
to make it available everywhere. See [Configuration](#configuration) for
|
|
29
|
+
Claude Desktop and other MCP clients, and [Tools](#tools) for everything the
|
|
30
|
+
server can do.
|
|
31
|
+
|
|
32
|
+
## Contents
|
|
33
|
+
|
|
34
|
+
- [Quick start](#quick-start)
|
|
35
|
+
- [Requirements](#requirements)
|
|
36
|
+
- [Installation](#installation)
|
|
37
|
+
- [Configuration](#configuration)
|
|
38
|
+
- [Tools](#tools)
|
|
39
|
+
- [Notes on the Domeneshop API](#notes-on-the-domeneshop-api)
|
|
40
|
+
- [Development](#development)
|
|
41
|
+
- [Contributing](#contributing)
|
|
42
|
+
- [Security](#security)
|
|
43
|
+
- [License](#license)
|
|
44
|
+
|
|
45
|
+
## Requirements
|
|
46
|
+
|
|
47
|
+
- A Domeneshop account with API credentials, created at
|
|
48
|
+
[domeneshop.no/admin?view=api](https://www.domeneshop.no/admin?view=api).
|
|
49
|
+
- Node.js 20 or newer.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm install -g domeneshop-mcp
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or run it directly without installing, via `npx`:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
npx domeneshop-mcp
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Configuration
|
|
64
|
+
|
|
65
|
+
The server reads its credentials from two environment variables and refuses to
|
|
66
|
+
start without them:
|
|
67
|
+
|
|
68
|
+
| Variable | Description |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `DOMENESHOP_API_TOKEN` | API token from the Domeneshop control panel |
|
|
71
|
+
| `DOMENESHOP_API_SECRET` | The matching API secret |
|
|
72
|
+
|
|
73
|
+
It speaks MCP over stdio, so it is launched by your MCP client rather than run
|
|
74
|
+
directly.
|
|
75
|
+
|
|
76
|
+
### Claude Code
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
claude mcp add domeneshop \
|
|
80
|
+
--env DOMENESHOP_API_TOKEN=your-token \
|
|
81
|
+
--env DOMENESHOP_API_SECRET=your-secret \
|
|
82
|
+
-- npx -y domeneshop-mcp
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Claude Desktop and other clients
|
|
86
|
+
|
|
87
|
+
Add the server to your client's MCP configuration — for Claude Desktop that is
|
|
88
|
+
`claude_desktop_config.json`:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"domeneshop": {
|
|
94
|
+
"command": "npx",
|
|
95
|
+
"args": ["-y", "domeneshop-mcp"],
|
|
96
|
+
"env": {
|
|
97
|
+
"DOMENESHOP_API_TOKEN": "your-token",
|
|
98
|
+
"DOMENESHOP_API_SECRET": "your-secret"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Tools
|
|
106
|
+
|
|
107
|
+
Read-only tools are annotated as such, and the tools that overwrite or delete
|
|
108
|
+
state are marked destructive, so clients can decide what to run without asking
|
|
109
|
+
you first.
|
|
110
|
+
|
|
111
|
+
### Domains
|
|
112
|
+
|
|
113
|
+
| Tool | Description |
|
|
114
|
+
| --- | --- |
|
|
115
|
+
| `list_domains` | List all domains on the account, optionally filtered by name |
|
|
116
|
+
| `get_domain` | Get a single domain by its Domeneshop domain ID |
|
|
117
|
+
|
|
118
|
+
### DNS
|
|
119
|
+
|
|
120
|
+
| Tool | Description |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| `list_dns_records` | List a domain's records, optionally filtered by host and type |
|
|
123
|
+
| `get_dns_record` | Get a single record by ID |
|
|
124
|
+
| `create_dns_record` | Create a record |
|
|
125
|
+
| `update_dns_record` | Replace a record (destructive — see the note below) |
|
|
126
|
+
| `delete_dns_record` | Delete a record |
|
|
127
|
+
|
|
128
|
+
All eleven record types Domeneshop accepts are supported, with their
|
|
129
|
+
type-specific fields:
|
|
130
|
+
|
|
131
|
+
| Type | Fields beyond `host`, `data` and `ttl` |
|
|
132
|
+
| --- | --- |
|
|
133
|
+
| `A`, `AAAA`, `ANAME`, `CNAME`, `NS`, `TXT` | — |
|
|
134
|
+
| `MX` | `priority` |
|
|
135
|
+
| `SRV` | `priority`, `weight`, `port` |
|
|
136
|
+
| `TLSA` | `usage`, `selector`, `dtype` |
|
|
137
|
+
| `DS` | `tag`, `alg`, `digest` |
|
|
138
|
+
| `CAA` | `flags`, `tag` |
|
|
139
|
+
|
|
140
|
+
`update_dns_record` replaces the whole record rather than patching it: any field
|
|
141
|
+
left out is dropped, and omitting `ttl` resets it to the default 3600 seconds.
|
|
142
|
+
Read the record first if you are only changing part of it.
|
|
143
|
+
|
|
144
|
+
### HTTP forwarding
|
|
145
|
+
|
|
146
|
+
| Tool | Description |
|
|
147
|
+
| --- | --- |
|
|
148
|
+
| `list_forwards` | List a domain's HTTP forwards |
|
|
149
|
+
| `get_forward` | Get the forward for one host |
|
|
150
|
+
| `create_forward` | Create a forward |
|
|
151
|
+
| `update_forward` | Update a forward |
|
|
152
|
+
| `delete_forward` | Delete a forward |
|
|
153
|
+
|
|
154
|
+
### Dynamic DNS
|
|
155
|
+
|
|
156
|
+
| Tool | Description |
|
|
157
|
+
| --- | --- |
|
|
158
|
+
| `update_dyndns` | Point a hostname at a given IP, or at the caller's apparent IP |
|
|
159
|
+
|
|
160
|
+
### Invoices
|
|
161
|
+
|
|
162
|
+
| Tool | Description |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `list_invoices` | List invoices from the past three years, optionally filtered by status |
|
|
165
|
+
| `get_invoice` | Get a single invoice |
|
|
166
|
+
|
|
167
|
+
## Notes on the Domeneshop API
|
|
168
|
+
|
|
169
|
+
A few things this server relies on are not in Domeneshop's published OpenAPI
|
|
170
|
+
spec, but are supported and used by their own client libraries:
|
|
171
|
+
|
|
172
|
+
- The spec documents seven record types; `ANAME`, `CAA`, `DS` and `NS` work too,
|
|
173
|
+
as the record validation in
|
|
174
|
+
[domeneshop.js](https://github.com/domeneshop/domeneshop.js) and
|
|
175
|
+
[python-domeneshop](https://github.com/domeneshop/python-domeneshop) shows.
|
|
176
|
+
- `GET /invoices` accepts a `status` filter, which domeneshop.js uses.
|
|
177
|
+
- `POST /forwards/` answers `201` with an empty body and names the new forward
|
|
178
|
+
only in the `Location` header.
|
|
179
|
+
- `GET /dyndns/update` answers with a plain-text status line, not JSON.
|
|
180
|
+
|
|
181
|
+
The `tag` field is deliberately untyped: it is a numeric key tag for `DS` and a
|
|
182
|
+
property tag such as `issue` for `CAA`, and Domeneshop documents neither.
|
|
183
|
+
|
|
184
|
+
## Development
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
npm install # install dependencies
|
|
188
|
+
npm run dev # run the server from source with tsx
|
|
189
|
+
npm run build # compile to ./dist
|
|
190
|
+
npm run typecheck # type-check without emitting
|
|
191
|
+
npm run lint # lint with Biome
|
|
192
|
+
npm run format # format with Biome
|
|
193
|
+
npm test # run the test suite (vitest)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The tests stub the Domeneshop API with a local `node:http` server and drive the
|
|
197
|
+
MCP server over an in-memory transport, so they need no credentials and make no
|
|
198
|
+
network calls.
|
|
199
|
+
|
|
200
|
+
### Project layout
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
src/
|
|
204
|
+
domeneshop/ Domeneshop API client (HTTP transport + one resource per endpoint group)
|
|
205
|
+
mcp/ MCP server: tool registration, schemas, result/error helpers
|
|
206
|
+
index.ts CLI entry point
|
|
207
|
+
test/
|
|
208
|
+
domeneshop/ Client tests, against a local HTTP server
|
|
209
|
+
mcp/ End-to-end tool tests, against an in-memory MCP transport
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Contributing
|
|
213
|
+
|
|
214
|
+
Issues and pull requests are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
215
|
+
for the development workflow and changelog conventions.
|
|
216
|
+
|
|
217
|
+
## Security
|
|
218
|
+
|
|
219
|
+
See [SECURITY.md](SECURITY.md) for how to report a vulnerability.
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asserts that a value is defined, narrowing it and throwing otherwise.
|
|
3
|
+
*
|
|
4
|
+
* Used after requests that the Domeneshop API guarantees a body for on
|
|
5
|
+
* success (single-resource GETs, creates and updates), so callers get a
|
|
6
|
+
* concrete type instead of threading `| undefined` through the client.
|
|
7
|
+
*/
|
|
8
|
+
export declare function assertDefined<T>(value: T | undefined, message: string): T;
|
|
9
|
+
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/domeneshop/assert.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAKzE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asserts that a value is defined, narrowing it and throwing otherwise.
|
|
3
|
+
*
|
|
4
|
+
* Used after requests that the Domeneshop API guarantees a body for on
|
|
5
|
+
* success (single-resource GETs, creates and updates), so callers get a
|
|
6
|
+
* concrete type instead of threading `| undefined` through the client.
|
|
7
|
+
*/
|
|
8
|
+
export function assertDefined(value, message) {
|
|
9
|
+
if (value === undefined) {
|
|
10
|
+
throw new Error(message);
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../src/domeneshop/assert.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAI,KAAoB,EAAE,OAAe;IACpE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DnsResource } from "./resources/dns.js";
|
|
2
|
+
import { DomainsResource } from "./resources/domains.js";
|
|
3
|
+
import { DynDnsResource } from "./resources/dyndns.js";
|
|
4
|
+
import { ForwardsResource } from "./resources/forwards.js";
|
|
5
|
+
import { InvoicesResource } from "./resources/invoices.js";
|
|
6
|
+
export interface DomeneshopClientOptions {
|
|
7
|
+
/** Overrides the API base URL. Intended for tests. */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A Domeneshop API client (https://api.domeneshop.no/docs/), authenticated
|
|
12
|
+
* via HTTP Basic Auth using an API token and secret from
|
|
13
|
+
* https://www.domeneshop.no/admin?view=api.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DomeneshopClient {
|
|
16
|
+
readonly domains: DomainsResource;
|
|
17
|
+
readonly dns: DnsResource;
|
|
18
|
+
readonly forwards: ForwardsResource;
|
|
19
|
+
readonly dynDns: DynDnsResource;
|
|
20
|
+
readonly invoices: InvoicesResource;
|
|
21
|
+
constructor(token: string, secret: string, options?: DomeneshopClientOptions);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/domeneshop/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,uBAAuB;IACtC,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;gBAExB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;CAQjF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HttpTransport } from "./http.js";
|
|
2
|
+
import { DnsResource } from "./resources/dns.js";
|
|
3
|
+
import { DomainsResource } from "./resources/domains.js";
|
|
4
|
+
import { DynDnsResource } from "./resources/dyndns.js";
|
|
5
|
+
import { ForwardsResource } from "./resources/forwards.js";
|
|
6
|
+
import { InvoicesResource } from "./resources/invoices.js";
|
|
7
|
+
/**
|
|
8
|
+
* A Domeneshop API client (https://api.domeneshop.no/docs/), authenticated
|
|
9
|
+
* via HTTP Basic Auth using an API token and secret from
|
|
10
|
+
* https://www.domeneshop.no/admin?view=api.
|
|
11
|
+
*/
|
|
12
|
+
export class DomeneshopClient {
|
|
13
|
+
domains;
|
|
14
|
+
dns;
|
|
15
|
+
forwards;
|
|
16
|
+
dynDns;
|
|
17
|
+
invoices;
|
|
18
|
+
constructor(token, secret, options = {}) {
|
|
19
|
+
const transport = new HttpTransport(token, secret, options.baseUrl);
|
|
20
|
+
this.domains = new DomainsResource(transport);
|
|
21
|
+
this.dns = new DnsResource(transport);
|
|
22
|
+
this.forwards = new ForwardsResource(transport);
|
|
23
|
+
this.dynDns = new DynDnsResource(transport);
|
|
24
|
+
this.invoices = new InvoicesResource(transport);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/domeneshop/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAO3D;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAClB,OAAO,CAAkB;IACzB,GAAG,CAAc;IACjB,QAAQ,CAAmB;IAC3B,MAAM,CAAiB;IACvB,QAAQ,CAAmB;IAEpC,YAAY,KAAa,EAAE,MAAc,EAAE,UAAmC,EAAE;QAC9E,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal HTTP transport for the Domeneshop API
|
|
3
|
+
* (https://api.domeneshop.no/docs/), authenticated via HTTP Basic Auth using
|
|
4
|
+
* an API token and secret from https://www.domeneshop.no/admin?view=api.
|
|
5
|
+
*/
|
|
6
|
+
/** Thrown for non-2xx responses from the Domeneshop API. */
|
|
7
|
+
export declare class DomeneshopApiError extends Error {
|
|
8
|
+
readonly statusCode: number;
|
|
9
|
+
readonly body: string;
|
|
10
|
+
constructor(statusCode: number, body: string);
|
|
11
|
+
}
|
|
12
|
+
export interface RequestOptions {
|
|
13
|
+
/** Query parameters. Undefined and empty-string values are omitted. */
|
|
14
|
+
query?: Record<string, string | undefined>;
|
|
15
|
+
/** Request body, marshalled as JSON. */
|
|
16
|
+
body?: unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to parse the response body as JSON. Defaults to true; set to
|
|
19
|
+
* false for endpoints that return a non-JSON (or irrelevant) body, such
|
|
20
|
+
* as the dynamic DNS update protocol's plain-text response.
|
|
21
|
+
*/
|
|
22
|
+
decodeJson?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ApiResponse<T> {
|
|
25
|
+
/** The parsed JSON response body, or undefined if the response was empty. */
|
|
26
|
+
data: T | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The raw response headers. Some endpoints report their result there
|
|
29
|
+
* rather than in the body — see ForwardsResource.create.
|
|
30
|
+
*/
|
|
31
|
+
headers: Headers;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* HttpTransport performs authenticated HTTP requests against the Domeneshop
|
|
35
|
+
* API and decodes JSON responses. It has no knowledge of individual
|
|
36
|
+
* endpoints; that lives in the resource classes built on top of it.
|
|
37
|
+
*/
|
|
38
|
+
export declare class HttpTransport {
|
|
39
|
+
private readonly baseUrl;
|
|
40
|
+
private readonly authorization;
|
|
41
|
+
constructor(token: string, secret: string, baseUrl?: string);
|
|
42
|
+
request<T>(method: string, path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/domeneshop/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,4DAA4D;AAC5D,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAU7C;AAED,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC3C,wCAAwC;IACxC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,6EAA6E;IAC7E,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC;IACpB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAyB;IAKvE,OAAO,CAAC,CAAC,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CA8B3B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal HTTP transport for the Domeneshop API
|
|
3
|
+
* (https://api.domeneshop.no/docs/), authenticated via HTTP Basic Auth using
|
|
4
|
+
* an API token and secret from https://www.domeneshop.no/admin?view=api.
|
|
5
|
+
*/
|
|
6
|
+
const DEFAULT_BASE_URL = "https://api.domeneshop.no/v0";
|
|
7
|
+
/** Thrown for non-2xx responses from the Domeneshop API. */
|
|
8
|
+
export class DomeneshopApiError extends Error {
|
|
9
|
+
statusCode;
|
|
10
|
+
body;
|
|
11
|
+
constructor(statusCode, body) {
|
|
12
|
+
super(body
|
|
13
|
+
? `domeneshop: unexpected status ${String(statusCode)}: ${body}`
|
|
14
|
+
: `domeneshop: unexpected status ${String(statusCode)}`);
|
|
15
|
+
this.name = "DomeneshopApiError";
|
|
16
|
+
this.statusCode = statusCode;
|
|
17
|
+
this.body = body;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* HttpTransport performs authenticated HTTP requests against the Domeneshop
|
|
22
|
+
* API and decodes JSON responses. It has no knowledge of individual
|
|
23
|
+
* endpoints; that lives in the resource classes built on top of it.
|
|
24
|
+
*/
|
|
25
|
+
export class HttpTransport {
|
|
26
|
+
baseUrl;
|
|
27
|
+
authorization;
|
|
28
|
+
constructor(token, secret, baseUrl = DEFAULT_BASE_URL) {
|
|
29
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
30
|
+
this.authorization = `Basic ${Buffer.from(`${token}:${secret}`).toString("base64")}`;
|
|
31
|
+
}
|
|
32
|
+
async request(method, path, options = {}) {
|
|
33
|
+
const url = new URL(this.baseUrl + path);
|
|
34
|
+
for (const [key, value] of Object.entries(options.query ?? {})) {
|
|
35
|
+
if (value !== undefined && value !== "") {
|
|
36
|
+
url.searchParams.set(key, value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const headers = new Headers({
|
|
40
|
+
Accept: "application/json",
|
|
41
|
+
Authorization: this.authorization,
|
|
42
|
+
});
|
|
43
|
+
const init = { method, headers };
|
|
44
|
+
if (options.body !== undefined) {
|
|
45
|
+
init.body = JSON.stringify(options.body);
|
|
46
|
+
headers.set("Content-Type", "application/json");
|
|
47
|
+
}
|
|
48
|
+
const response = await fetch(url, init);
|
|
49
|
+
const text = await response.text();
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new DomeneshopApiError(response.status, text);
|
|
52
|
+
}
|
|
53
|
+
const decodeJson = options.decodeJson ?? true;
|
|
54
|
+
const data = decodeJson && text.length > 0 ? JSON.parse(text) : undefined;
|
|
55
|
+
return { data, headers: response.headers };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/domeneshop/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,gBAAgB,GAAG,8BAA8B,CAAC;AAExD,4DAA4D;AAC5D,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,UAAU,CAAS;IACnB,IAAI,CAAS;IAEtB,YAAY,UAAkB,EAAE,IAAY;QAC1C,KAAK,CACH,IAAI;YACF,CAAC,CAAC,iCAAiC,MAAM,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;YAChE,CAAC,CAAC,iCAAiC,MAAM,CAAC,UAAU,CAAC,EAAE,CAC1D,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAyBD;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACP,OAAO,CAAS;IAChB,aAAa,CAAS;IAEvC,YAAY,KAAa,EAAE,MAAc,EAAE,UAAkB,gBAAgB;QAC3E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IACvF,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAAc,EACd,IAAY,EACZ,UAA0B,EAAE;QAE5B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC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E,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC7C,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type { DomeneshopClientOptions } from "./client.js";
|
|
2
|
+
export { DomeneshopClient } from "./client.js";
|
|
3
|
+
export type { ApiResponse, RequestOptions } from "./http.js";
|
|
4
|
+
export { DomeneshopApiError } from "./http.js";
|
|
5
|
+
export type { DNSRecord, RecordType } from "./resources/dns.js";
|
|
6
|
+
export { DnsResource, RECORD_TYPES } from "./resources/dns.js";
|
|
7
|
+
export type { Domain, DomainServices } from "./resources/domains.js";
|
|
8
|
+
export { DomainsResource } from "./resources/domains.js";
|
|
9
|
+
export { DynDnsResource } from "./resources/dyndns.js";
|
|
10
|
+
export type { Forward } from "./resources/forwards.js";
|
|
11
|
+
export { ForwardsResource } from "./resources/forwards.js";
|
|
12
|
+
export type { Invoice, InvoiceStatus } from "./resources/invoices.js";
|
|
13
|
+
export { INVOICE_STATUSES, InvoicesResource } from "./resources/invoices.js";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domeneshop/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/D,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DomeneshopClient } from "./client.js";
|
|
2
|
+
export { DomeneshopApiError } from "./http.js";
|
|
3
|
+
export { DnsResource, RECORD_TYPES } from "./resources/dns.js";
|
|
4
|
+
export { DomainsResource } from "./resources/domains.js";
|
|
5
|
+
export { DynDnsResource } from "./resources/dyndns.js";
|
|
6
|
+
export { ForwardsResource } from "./resources/forwards.js";
|
|
7
|
+
export { INVOICE_STATUSES, InvoicesResource } from "./resources/invoices.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domeneshop/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { HttpTransport } from "../http.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every DNS record type the Domeneshop API accepts.
|
|
4
|
+
*
|
|
5
|
+
* The published OpenAPI spec only documents A, AAAA, CNAME, MX, SRV, TLSA
|
|
6
|
+
* and TXT, but ANAME, CAA, DS and NS are equally supported — see the record
|
|
7
|
+
* validation in Domeneshop's own client libraries:
|
|
8
|
+
* https://github.com/domeneshop/domeneshop.js (src/lib/interfaces/dnsrecord.ts)
|
|
9
|
+
* and https://github.com/domeneshop/python-domeneshop (domeneshop/client.py).
|
|
10
|
+
*/
|
|
11
|
+
export declare const RECORD_TYPES: readonly ["A", "AAAA", "ANAME", "CAA", "CNAME", "DS", "MX", "NS", "SRV", "TLSA", "TXT"];
|
|
12
|
+
export type RecordType = (typeof RECORD_TYPES)[number];
|
|
13
|
+
/**
|
|
14
|
+
* A DNS record.
|
|
15
|
+
*
|
|
16
|
+
* `host`, `type` and `data` apply to every record type; the remaining
|
|
17
|
+
* fields are type-specific and are omitted when unset. `data` always
|
|
18
|
+
* carries the record's main value — the address, hostname, text or hash —
|
|
19
|
+
* while the numeric parameters below carry the rest.
|
|
20
|
+
*/
|
|
21
|
+
export interface DNSRecord {
|
|
22
|
+
id?: number | undefined;
|
|
23
|
+
host: string;
|
|
24
|
+
ttl?: number | undefined;
|
|
25
|
+
type: string;
|
|
26
|
+
data: string;
|
|
27
|
+
/** MX and SRV: preference, lower is tried first. */
|
|
28
|
+
priority?: number | undefined;
|
|
29
|
+
/** SRV only. */
|
|
30
|
+
weight?: number | undefined;
|
|
31
|
+
port?: number | undefined;
|
|
32
|
+
/** TLSA only. */
|
|
33
|
+
usage?: number | undefined;
|
|
34
|
+
selector?: number | undefined;
|
|
35
|
+
dtype?: number | undefined;
|
|
36
|
+
/** DS only: alg is the signing algorithm, digest the digest type. */
|
|
37
|
+
alg?: number | undefined;
|
|
38
|
+
digest?: number | undefined;
|
|
39
|
+
/** CAA only. */
|
|
40
|
+
flags?: number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* The key tag for DS and the property tag for CAA. Domeneshop documents
|
|
43
|
+
* neither precisely, so this is kept loosely typed rather than forced
|
|
44
|
+
* into one shape.
|
|
45
|
+
*/
|
|
46
|
+
tag?: number | string | undefined;
|
|
47
|
+
}
|
|
48
|
+
export declare class DnsResource {
|
|
49
|
+
private readonly transport;
|
|
50
|
+
constructor(transport: HttpTransport);
|
|
51
|
+
/** Lists DNS records for a domain, optionally filtered by host and/or record type. */
|
|
52
|
+
list(domainId: number, options?: {
|
|
53
|
+
host?: string | undefined;
|
|
54
|
+
type?: string | undefined;
|
|
55
|
+
}): Promise<DNSRecord[]>;
|
|
56
|
+
/** Retrieves a single DNS record. */
|
|
57
|
+
get(domainId: number, recordId: number): Promise<DNSRecord>;
|
|
58
|
+
/** Creates a new DNS record and returns its ID. */
|
|
59
|
+
create(domainId: number, record: DNSRecord): Promise<number>;
|
|
60
|
+
/**
|
|
61
|
+
* Replaces an existing DNS record. Fields left unset on `record` are
|
|
62
|
+
* dropped from the stored record, so callers should send it in full.
|
|
63
|
+
*/
|
|
64
|
+
update(domainId: number, recordId: number, record: DNSRecord): Promise<void>;
|
|
65
|
+
/** Deletes a DNS record. */
|
|
66
|
+
delete(domainId: number, recordId: number): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=dns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dns.d.ts","sourceRoot":"","sources":["../../../src/domeneshop/resources/dns.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,yFAYf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,E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E,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlF,4BAA4B;IACtB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGhE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { assertDefined } from "../assert.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every DNS record type the Domeneshop API accepts.
|
|
4
|
+
*
|
|
5
|
+
* The published OpenAPI spec only documents A, AAAA, CNAME, MX, SRV, TLSA
|
|
6
|
+
* and TXT, but ANAME, CAA, DS and NS are equally supported — see the record
|
|
7
|
+
* validation in Domeneshop's own client libraries:
|
|
8
|
+
* https://github.com/domeneshop/domeneshop.js (src/lib/interfaces/dnsrecord.ts)
|
|
9
|
+
* and https://github.com/domeneshop/python-domeneshop (domeneshop/client.py).
|
|
10
|
+
*/
|
|
11
|
+
export const RECORD_TYPES = [
|
|
12
|
+
"A",
|
|
13
|
+
"AAAA",
|
|
14
|
+
"ANAME",
|
|
15
|
+
"CAA",
|
|
16
|
+
"CNAME",
|
|
17
|
+
"DS",
|
|
18
|
+
"MX",
|
|
19
|
+
"NS",
|
|
20
|
+
"SRV",
|
|
21
|
+
"TLSA",
|
|
22
|
+
"TXT",
|
|
23
|
+
];
|
|
24
|
+
export class DnsResource {
|
|
25
|
+
transport;
|
|
26
|
+
constructor(transport) {
|
|
27
|
+
this.transport = transport;
|
|
28
|
+
}
|
|
29
|
+
/** Lists DNS records for a domain, optionally filtered by host and/or record type. */
|
|
30
|
+
async list(domainId, options = {}) {
|
|
31
|
+
const { data } = await this.transport.request("GET", `/domains/${String(domainId)}/dns`, {
|
|
32
|
+
query: { host: options.host, type: options.type },
|
|
33
|
+
});
|
|
34
|
+
return data ?? [];
|
|
35
|
+
}
|
|
36
|
+
/** Retrieves a single DNS record. */
|
|
37
|
+
async get(domainId, recordId) {
|
|
38
|
+
const { data } = await this.transport.request("GET", `/domains/${String(domainId)}/dns/${String(recordId)}`);
|
|
39
|
+
return assertDefined(data, "domeneshop: empty response for DNS record");
|
|
40
|
+
}
|
|
41
|
+
/** Creates a new DNS record and returns its ID. */
|
|
42
|
+
async create(domainId, record) {
|
|
43
|
+
const { data } = await this.transport.request("POST", `/domains/${String(domainId)}/dns`, { body: record });
|
|
44
|
+
return assertDefined(data, "domeneshop: empty response for created DNS record").id;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Replaces an existing DNS record. Fields left unset on `record` are
|
|
48
|
+
* dropped from the stored record, so callers should send it in full.
|
|
49
|
+
*/
|
|
50
|
+
async update(domainId, recordId, record) {
|
|
51
|
+
await this.transport.request("PUT", `/domains/${String(domainId)}/dns/${String(recordId)}`, {
|
|
52
|
+
body: record,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** Deletes a DNS record. */
|
|
56
|
+
async delete(domainId, recordId) {
|
|
57
|
+
await this.transport.request("DELETE", `/domains/${String(domainId)}/dns/${String(recordId)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=dns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dns.js","sourceRoot":"","sources":["../../../src/domeneshop/resources/dns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG;IACH,MAAM;IACN,OAAO;IACP,KAAK;IACL,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,MAAM;IACN,KAAK;CACG,CAAC;AAyCX,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,SAAwB;QAAxB,cAAS,GAAT,SAAS,CAAe;IAAG,CAAC;IAEzD,sFAAsF;IACtF,KAAK,CAAC,IAAI,CACR,QAAgB,EACh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