Skip to content

Commit da108ac

Browse files
authored
Axios migration (#91)
1 parent 2a960fb commit da108ac

27 files changed

+412
-6996
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- ./node_modules
1717
- run:
1818
name: Audit Dependencies
19-
command: npm run audit
19+
command: npm audit --production
2020
- run:
2121
name: Running Mocha Tests
2222
command: npm test

.nsprc

Lines changed: 0 additions & 6 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 4.0.0 (August 05, 2025)
2+
* BREAKING CHANGE – All clients named `*RestClient` have been removed except for `PlatformApiRestClient`. Any removed client logic should now be implemented within components.
3+
* `PlatformApiRestClient` has been migrated from the `request` library to `axios`.
4+
* The following libraries have been removed from the main dependencies:
5+
* @elastic.io/ntlm-client
6+
* async
7+
* bunyan-serializers
8+
* elasticio-node
9+
* better-npm-audit
10+
* remove-leading-slash
11+
* remove-trailing-slash
12+
* request
13+
* The `axiosReqWithRetryOnServerError` function can now operate without requiring a context.
14+
115
## 3.2.2 (March 21, 2025)
216
* Updated maester-client to 6.0.0
317

README.md

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
## Table of Contents
55
- [Description](#description)
66
- [Available Functions](#Available-Functions)
7-
- [REST Clients](#REST-Clients)
8-
- [NoAuthRestClient](#NoAuthRestClient)
9-
- [BasicAuthRestClient](#BasicAuthRestClient)
10-
- [ApiKeyRestClient](#ApiKeyRestClient)
11-
- [CookieRestClient](#CookieRestClient)
12-
- [OAuth2AuthorizationCodeRestClient](#OAuth2AuthorizationCodeRestClient)
13-
- [FacelessRestClient](#FacelessRestClient)
147
- [Platform API Clients](#Platform-API-Clients)
158
- [PlatformApiRestClient](#PlatformApiRestClient)
169
- [PlatformApiLogicClient](#PlatformApiLogicClient)
@@ -32,127 +25,6 @@ npm install @elastic.io/component-commons-library
3225

3326
# Available Functions
3427

35-
## REST Clients
36-
A number of REST Client classes are available to use and extend to create Clients for a given API.
37-
38-
Each of the REST Clients extends from the `NoAuthRestClient`, overriding the relevant methods. Exception is PlatformApiRestClient and PlatformApiLogicClient.
39-
40-
### NoAuthRestClient
41-
[NoAuthRestClient](https://github.com/elasticio/component-commons-library/blob/master/src/authentication/NoAuthRestClient.ts) class to make rest requests no no auth APIs by provided options.
42-
43-
#### constructor(emitter, cfg)
44-
- emitter - EIO emitting context.
45-
- cfg - configuration of EIO component object.
46-
47-
```
48-
const Client = new NoAuthRestClient(emitter, cfg);
49-
```
50-
51-
#### async makeRequest(options)
52-
Makes requests:
53-
options expects the following sub-variables:
54-
- url: Url to call
55-
- method: HTTP verb to use
56-
- body: Body of the request, if applicable. Defaults to undefined.
57-
- headers: Any HTTP headers to add to the request. Defaults to {}
58-
- urlIsSegment: Whether to append to the base server url or if the provided URL is an absolute path. Defaults to true
59-
- isJson: If the request is in JSON format. Defaults to true
60-
61-
62-
Class can be extended to have custom authentication
63-
64-
Example:
65-
66-
```javascript
67-
const { NoAuthRestClient } = require('@elastic.io/component-commons-library');
68-
69-
class MyClient extends NoAuthRestClient {
70-
constructor(emitter, cfg) {
71-
super(emitter, cfg);
72-
// Other variables go here
73-
}
74-
75-
// Some methods can be overridden
76-
addAuthenticationToRequestOptions(requestOptions) {
77-
requestOptions.specialField = true;
78-
}
79-
80-
81-
}
82-
```
83-
84-
### BasicAuthRestClient
85-
[BasicAuthRestClient](https://github.com/elasticio/component-commons-library/blob/master/src/authentication/BasicAuthRestClient.ts)
86-
class extends [NoAuthRestClient](#NoAuthRestClient) class.
87-
Makes requests to resource with basic auth.
88-
89-
#### constructor(emitter, cfg)
90-
- cfg.username - mandatory cfg parameter contains username for authorization.
91-
- cfg.password - mandatory cfg parameter contains password for authorization.
92-
93-
```
94-
const Client = new BasicAuthRestClient(emitter, cfg, user, pass);
95-
```
96-
97-
98-
### ApiKeyRestClient
99-
[ApiKeyRestClient](https://github.com/elasticio/component-commons-library/blob/master/src/authentication/ApiKeyRestClient.ts)
100-
class extends [NoAuthRestClient](#NoAuthRestClient) class.
101-
Makes requests to resource with api key (custom header) auth.
102-
103-
#### constructor(emitter, cfg)
104-
- cfg.apiKeyHeaderName - mandatory cfg parameter contains authorization header name.
105-
- cfg.apiKeyHeaderValue - mandatory cfg parameter contains authorization header value.
106-
107-
```
108-
const Client = new BasicAuthRestClient(emitter, cfg, user, pass);
109-
```
110-
111-
### CookieRestClient
112-
[CookieRestClient](https://github.com/elasticio/component-commons-library/blob/master/src/authentication/CookieRestClient.ts)
113-
class extends [NoAuthRestClient](#NoAuthRestClient) class.
114-
115-
TBD
116-
117-
### OAuth2AuthorizationCodeRestClient
118-
[OAuth2RestClient](https://github.com/elasticio/component-commons-library/blob/master/src/authentication/OAuth2AuthorizationCodeRestClient.ts)
119-
class extends [NoAuthRestClient](#NoAuthRestClient) class.
120-
Makes requests to resource with oauth2 access token auth.
121-
122-
#### constructor(emitter, cfg)
123-
- cfg.oauth2 - mandatory cfg parameter contains oauth2 ids, config and tokens.
124-
```
125-
const Client = new OAuth2AuthorizationCodeRestClient(emitter, cfg);
126-
```
127-
This class can handle, refresh and emit oauth2 EIO configuration.
128-
129-
### FacelessRestClient
130-
[FacelessRestClient](https://github.com/elasticio/component-commons-library/blob/master/src/authentication/FacelessRestClient.ts)
131-
Makes requests to resource with oauth2 access token auth using ElasticIO [Faceless Service](https://docs.elastic.io/guides/secrets.html).
132-
133-
#### constructor(emitter, cfg, userAgent, msgId)
134-
135-
- cfg - should contain `secretId` parameter or `oauth` object with oauth2 config and tokens.
136-
- userAgent - optional parameter, used for `User-Agent` header when client retrieve secret from platform
137-
- msgId - optional parameter, used for `x-request-id` header when client retrieve secret from platform
138-
```
139-
const Client = new FacelessRestClient(emitter, cfg, userAgent, msgId);
140-
```
141-
142-
### NtlmRestClient
143-
[NtlmRestClient](https://github.com/elasticio/component-commons-library/blob/master/src/authentication/NtlmRestClient.ts)
144-
class extends [NoAuthRestClient](#NoAuthRestClient) class.
145-
Makes requests to resource with [NTLM authentication](https://en.wikipedia.org/wiki/NT_LAN_Manager).
146-
Falls back to basic authentication if NTLM authentication fails.
147-
Handles both V1 and V2 of the NTLM Protocol.
148-
149-
#### constructor(emitter, cfg)
150-
- cfg.username - mandatory cfg parameter contains username for authorization. Domain information should be combined with this field. (e.g. `SOMEDOMAIN\SomeUser`)
151-
- cfg.password - mandatory cfg parameter contains password for authorization.
152-
153-
```
154-
const Client = new NtlmRestClient(emitter, cfg);
155-
```
15628

15729
## Platform API Clients
15830
A number of Platform API Client classes are available to use and extend them to create Clients for Platform API.

0 commit comments

Comments
 (0)