domrobot-client 3.2.1 → 3.3.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/.github/workflows/format-lint.yaml +20 -0
- package/.github/workflows/publish.yaml +22 -0
- package/.prettierrc +5 -5
- package/README.md +7 -10
- package/lib/domrobot.d.ts +6 -2
- package/lib/domrobot.js +12 -7
- package/lib/domrobot.js.map +1 -1
- package/package.json +43 -42
- package/src/domrobot.ts +23 -6
- package/tsconfig.json +12 -15
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: format-lint.yaml
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
format:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: actions/setup-node@v4
|
|
14
|
+
with:
|
|
15
|
+
node-version: '20'
|
|
16
|
+
- run: npm ci
|
|
17
|
+
- name: Prettier check
|
|
18
|
+
run: npm run format:check
|
|
19
|
+
- name: Lint the code
|
|
20
|
+
run: npm run lint
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Publish Package to npmjs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: '20.x'
|
|
18
|
+
registry-url: 'https://registry.npmjs.org'
|
|
19
|
+
- run: npm ci
|
|
20
|
+
- run: npm publish --provenance --access public
|
|
21
|
+
env:
|
|
22
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.prettierrc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
2
|
+
"printWidth": 120,
|
|
3
|
+
"trailingComma": "all",
|
|
4
|
+
"singleQuote": true,
|
|
5
|
+
"tabWidth": 4
|
|
6
|
+
}
|
package/README.md
CHANGED
|
@@ -4,20 +4,19 @@
|
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
INWX Domrobot Node.js Client
|
|
8
|
-
|
|
7
|
+
# INWX Domrobot Node.js Client
|
|
8
|
+
|
|
9
9
|
You can access all functions of our frontend via our API, which is available via the JSON-RPC protocol and thus can be easily consumed with all programming languages.
|
|
10
10
|
|
|
11
11
|
There is also an OT&E test system, which you can access via [ote.inwx.com](https://ote.inwx.com/en/). Here you will find the known web interface which is using a test database. On the OT&E system no actions will be charged. So you can test as much as you like there.
|
|
12
12
|
|
|
13
|
-
Documentation
|
|
14
|
-
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
15
|
You can view a detailed description of the API functions in our documentation. You can find the online documentation [by clicking here](https://www.inwx.de/en/help/apidoc).
|
|
16
16
|
|
|
17
17
|
If you still experience any kind of problems don't hesitate to contact our [support via email](mailto:support@inwx.de).
|
|
18
18
|
|
|
19
|
-
Installation
|
|
20
|
-
-------
|
|
19
|
+
## Installation
|
|
21
20
|
|
|
22
21
|
The recommended way is via npm:
|
|
23
22
|
|
|
@@ -27,8 +26,7 @@ npm install --save domrobot-client
|
|
|
27
26
|
|
|
28
27
|
You can find more information about the package on [npmjs.org](https://www.npmjs.com/package/domrobot-client).
|
|
29
28
|
|
|
30
|
-
Example
|
|
31
|
-
-------
|
|
29
|
+
## Example
|
|
32
30
|
|
|
33
31
|
```typescript
|
|
34
32
|
import { ApiClient, Language } from 'domrobot-client';
|
|
@@ -71,7 +69,6 @@ const asyncFunc = async () => {
|
|
|
71
69
|
asyncFunc();
|
|
72
70
|
```
|
|
73
71
|
|
|
74
|
-
License
|
|
75
|
-
----
|
|
72
|
+
## License
|
|
76
73
|
|
|
77
74
|
MIT
|
package/lib/domrobot.d.ts
CHANGED
|
@@ -7,12 +7,14 @@ export declare class ApiClient {
|
|
|
7
7
|
private language;
|
|
8
8
|
private debugMode;
|
|
9
9
|
private cookie;
|
|
10
|
+
private headers;
|
|
10
11
|
/**
|
|
11
12
|
* @param apiUrl url of the API.
|
|
12
13
|
* @param language default language for future API requests.
|
|
13
14
|
* @param debugMode whether requests and responses should be printed out.
|
|
15
|
+
* @param headers Optional HTTP headers to be included in all API requests.
|
|
14
16
|
*/
|
|
15
|
-
constructor(apiUrl?: string, language?: string, debugMode?: boolean);
|
|
17
|
+
constructor(apiUrl?: string, language?: string, debugMode?: boolean, headers?: Record<string, any>);
|
|
16
18
|
/**
|
|
17
19
|
* Makes an API call.
|
|
18
20
|
*
|
|
@@ -23,7 +25,7 @@ export declare class ApiClient {
|
|
|
23
25
|
* @param cacheOption HTTP cache options
|
|
24
26
|
* @param nextjsOptions Next.js options
|
|
25
27
|
*/
|
|
26
|
-
callApi(apiMethod: string, methodParams?: any, clientTransactionId?: string, language?: string, cacheOption?:
|
|
28
|
+
callApi(apiMethod: string, methodParams?: any, clientTransactionId?: string, language?: string, cacheOption?: 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached' | 'default', nextjsOptions?: object): Promise<any>;
|
|
27
29
|
/**
|
|
28
30
|
* Performs a login at the API and saves the session for following API calls.
|
|
29
31
|
*
|
|
@@ -43,6 +45,8 @@ export declare class ApiClient {
|
|
|
43
45
|
setDebugMode(value: boolean): void;
|
|
44
46
|
getCookie(): string;
|
|
45
47
|
setCookie(cookie: string): void;
|
|
48
|
+
setHeaders(headers: Record<string, any>): void;
|
|
49
|
+
getHeaders(): Record<string, any>;
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* The API response-message language.
|
package/lib/domrobot.js
CHANGED
|
@@ -19,12 +19,14 @@ class ApiClient {
|
|
|
19
19
|
* @param apiUrl url of the API.
|
|
20
20
|
* @param language default language for future API requests.
|
|
21
21
|
* @param debugMode whether requests and responses should be printed out.
|
|
22
|
+
* @param headers Optional HTTP headers to be included in all API requests.
|
|
22
23
|
*/
|
|
23
|
-
constructor(apiUrl = ApiClient.API_URL_OTE, language = Language.EN, debugMode = false) {
|
|
24
|
+
constructor(apiUrl = ApiClient.API_URL_OTE, language = Language.EN, debugMode = false, headers = {}) {
|
|
24
25
|
this.apiUrl = apiUrl;
|
|
25
26
|
this.language = language;
|
|
26
27
|
this.debugMode = debugMode;
|
|
27
28
|
this.cookie = null;
|
|
29
|
+
this.headers = headers;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* Makes an API call.
|
|
@@ -38,6 +40,7 @@ class ApiClient {
|
|
|
38
40
|
*/
|
|
39
41
|
callApi(apiMethod_1) {
|
|
40
42
|
return __awaiter(this, arguments, void 0, function* (apiMethod, methodParams = {}, clientTransactionId = ApiClient.generateClientTransactionId(), language = this.language, cacheOption, nextjsOptions) {
|
|
43
|
+
var _a;
|
|
41
44
|
if ('clTRID' in methodParams && clientTransactionId !== null) {
|
|
42
45
|
methodParams.clTRID = clientTransactionId;
|
|
43
46
|
}
|
|
@@ -50,13 +53,9 @@ class ApiClient {
|
|
|
50
53
|
});
|
|
51
54
|
let fetchOption = {
|
|
52
55
|
method: 'POST',
|
|
53
|
-
headers: new Headers({
|
|
54
|
-
'Content-Type': 'application/json',
|
|
55
|
-
Cookie: this.cookie,
|
|
56
|
-
'User-Agent': `DomRobot/${ApiClient.CLIENT_VERSION} (Node ${process.version})`,
|
|
57
|
-
}),
|
|
56
|
+
headers: new Headers(Object.assign({ 'Content-Type': 'application/json', Cookie: this.cookie, 'User-Agent': `DomRobot/${ApiClient.CLIENT_VERSION} (Node ${process.version})` }, ((_a = this.headers) !== null && _a !== void 0 ? _a : {}))),
|
|
58
57
|
body: requestBody,
|
|
59
|
-
cache: cacheOption !== null && cacheOption !== void 0 ? cacheOption :
|
|
58
|
+
cache: cacheOption !== null && cacheOption !== void 0 ? cacheOption : 'default',
|
|
60
59
|
};
|
|
61
60
|
if (nextjsOptions !== undefined) {
|
|
62
61
|
fetchOption = Object.assign(Object.assign({}, fetchOption), nextjsOptions);
|
|
@@ -125,6 +124,12 @@ class ApiClient {
|
|
|
125
124
|
setCookie(cookie) {
|
|
126
125
|
this.cookie = cookie;
|
|
127
126
|
}
|
|
127
|
+
setHeaders(headers) {
|
|
128
|
+
this.headers = headers;
|
|
129
|
+
}
|
|
130
|
+
getHeaders() {
|
|
131
|
+
return this.headers;
|
|
132
|
+
}
|
|
128
133
|
}
|
|
129
134
|
exports.ApiClient = ApiClient;
|
|
130
135
|
ApiClient.CLIENT_VERSION = '3.0.2';
|
package/lib/domrobot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domrobot.js","sourceRoot":"","sources":["../src/domrobot.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AAEjC,MAAa,SAAS;IAMX,MAAM,CAAC,2BAA2B;QACrC,OAAO,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC;IAChE,CAAC;
|
|
1
|
+
{"version":3,"file":"domrobot.js","sourceRoot":"","sources":["../src/domrobot.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AAEjC,MAAa,SAAS;IAMX,MAAM,CAAC,2BAA2B;QACrC,OAAO,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC;IAChE,CAAC;IASD;;;;;OAKG;IACH,YACI,SAAiB,SAAS,CAAC,WAAW,EACtC,WAAmB,QAAQ,CAAC,EAAE,EAC9B,YAAqB,KAAK,EAC1B,UAA+B,EAAE;QAEjC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45 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
2
|
+
"name": "domrobot-client",
|
|
3
|
+
"version": "3.3.0",
|
|
4
|
+
"description": "INWX Domrobot Node.JS Client",
|
|
5
|
+
"author": "INWX Developer <developer@inwx.de> (https://inwx.com)",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/inwx/nodejs-client.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"INWX",
|
|
14
|
+
"API",
|
|
15
|
+
"INWX-API",
|
|
16
|
+
"Domrobot",
|
|
17
|
+
"Client",
|
|
18
|
+
"Domrobot-Client",
|
|
19
|
+
"Node",
|
|
20
|
+
"NodeJS"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
25
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
26
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
27
|
+
"prepare": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"otplib": "^12.0.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^22.2.0",
|
|
34
|
+
"@types/otplib": "^7.0.0",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^8.1.0",
|
|
36
|
+
"browserify": "^17.0.0",
|
|
37
|
+
"eslint": "^8.44.0",
|
|
38
|
+
"eslint-config-prettier": "^8.8.0",
|
|
39
|
+
"prettier": "^3.3.3",
|
|
40
|
+
"typescript": "^5.5.4"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
}
|
|
44
45
|
}
|
package/src/domrobot.ts
CHANGED
|
@@ -15,17 +15,25 @@ export class ApiClient {
|
|
|
15
15
|
private debugMode: boolean;
|
|
16
16
|
|
|
17
17
|
private cookie: string;
|
|
18
|
+
private headers: Record<string, any>;
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* @param apiUrl url of the API.
|
|
21
22
|
* @param language default language for future API requests.
|
|
22
23
|
* @param debugMode whether requests and responses should be printed out.
|
|
24
|
+
* @param headers Optional HTTP headers to be included in all API requests.
|
|
23
25
|
*/
|
|
24
|
-
constructor(
|
|
26
|
+
constructor(
|
|
27
|
+
apiUrl: string = ApiClient.API_URL_OTE,
|
|
28
|
+
language: string = Language.EN,
|
|
29
|
+
debugMode: boolean = false,
|
|
30
|
+
headers: Record<string, any> = {},
|
|
31
|
+
) {
|
|
25
32
|
this.apiUrl = apiUrl;
|
|
26
33
|
this.language = language;
|
|
27
34
|
this.debugMode = debugMode;
|
|
28
35
|
this.cookie = null;
|
|
36
|
+
this.headers = headers;
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
/**
|
|
@@ -43,8 +51,8 @@ export class ApiClient {
|
|
|
43
51
|
methodParams: any = {},
|
|
44
52
|
clientTransactionId: string = ApiClient.generateClientTransactionId(),
|
|
45
53
|
language: string = this.language,
|
|
46
|
-
cacheOption?:
|
|
47
|
-
nextjsOptions?: object
|
|
54
|
+
cacheOption?: 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached' | 'default',
|
|
55
|
+
nextjsOptions?: object,
|
|
48
56
|
): Promise<any> {
|
|
49
57
|
if ('clTRID'! in methodParams && clientTransactionId !== null) {
|
|
50
58
|
methodParams.clTRID = clientTransactionId;
|
|
@@ -64,13 +72,14 @@ export class ApiClient {
|
|
|
64
72
|
'Content-Type': 'application/json',
|
|
65
73
|
Cookie: this.cookie,
|
|
66
74
|
'User-Agent': `DomRobot/${ApiClient.CLIENT_VERSION} (Node ${process.version})`,
|
|
75
|
+
...(this.headers ?? {}),
|
|
67
76
|
}),
|
|
68
77
|
body: requestBody,
|
|
69
|
-
cache: cacheOption ??
|
|
78
|
+
cache: cacheOption ?? 'default',
|
|
70
79
|
};
|
|
71
80
|
|
|
72
81
|
if (nextjsOptions !== undefined) {
|
|
73
|
-
fetchOption = {...fetchOption, ...nextjsOptions};
|
|
82
|
+
fetchOption = { ...fetchOption, ...nextjsOptions };
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
const response = await fetch(this.apiUrl, fetchOption);
|
|
@@ -79,7 +88,7 @@ export class ApiClient {
|
|
|
79
88
|
this.cookie = response.headers.get('set-cookie');
|
|
80
89
|
}
|
|
81
90
|
|
|
82
|
-
const data = await response.json()
|
|
91
|
+
const data = await response.json();
|
|
83
92
|
if (this.debugMode) {
|
|
84
93
|
console.info(`Request (${apiMethod}): ${requestBody}`);
|
|
85
94
|
console.info(`Response (${apiMethod}): ${JSON.stringify(data)}`);
|
|
@@ -145,6 +154,14 @@ export class ApiClient {
|
|
|
145
154
|
public setCookie(cookie: string) {
|
|
146
155
|
this.cookie = cookie;
|
|
147
156
|
}
|
|
157
|
+
|
|
158
|
+
public setHeaders(headers: Record<string, any>) {
|
|
159
|
+
this.headers = headers;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public getHeaders(): Record<string, any> {
|
|
163
|
+
return this.headers;
|
|
164
|
+
}
|
|
148
165
|
}
|
|
149
166
|
|
|
150
167
|
/**
|
package/tsconfig.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"examples"
|
|
15
|
-
]
|
|
16
|
-
}
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "none",
|
|
4
|
+
"target": "es6",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"outDir": "./lib"
|
|
10
|
+
},
|
|
11
|
+
"include": ["src"],
|
|
12
|
+
"exclude": ["node_modules", "examples"]
|
|
13
|
+
}
|