@localisprimary/esi 1.2.0 → 1.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/README.md +11 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,17 @@ const alliance = await esi.getAlliance({ alliance_id: 123 })
|
|
|
23
23
|
console.log(alliance.data)
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
## Options
|
|
27
|
+
|
|
28
|
+
The `EsiClient` constructor accepts an options object with the following properties:
|
|
29
|
+
| Parameter | Description | Type | Default | Required |
|
|
30
|
+
|-----------|-------------|------|---------|----------|
|
|
31
|
+
| `token` | Optional auth token for authenticated requests | `string` | `undefined` | No |
|
|
32
|
+
| `userAgent` | User agent string for requests. Resolves to `"localisprimary/esi <userAgent>"` | `string` | `undefined` | No* |
|
|
33
|
+
| `useRequestHeaders` | When false, fall back to query parameters for user agent and token | `boolean` | `true` | No |
|
|
34
|
+
|
|
35
|
+
<small>* Will be required in a future version.</small>
|
|
36
|
+
|
|
26
37
|
## Methods
|
|
27
38
|
|
|
28
39
|
This client provides methods for all EVE ESI endpoints. Methods return a `Promise` that resolves to an `EsiResponse<T>` or throws an `EsiError`.
|
package/dist/client.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ export declare class EsiClient {
|
|
|
3
3
|
private readonly baseUrl;
|
|
4
4
|
private readonly userAgent;
|
|
5
5
|
private readonly token?;
|
|
6
|
+
private readonly useRequestHeaders;
|
|
6
7
|
constructor(options?: {
|
|
7
8
|
token?: string;
|
|
8
9
|
userAgent?: string;
|
|
10
|
+
useRequestHeaders?: boolean;
|
|
9
11
|
});
|
|
10
12
|
private request;
|
|
11
13
|
/**
|
package/dist/client.js
CHANGED
|
@@ -2,8 +2,10 @@ const COMPATIBILITY_DATE = '2025-07-29';
|
|
|
2
2
|
export class EsiClient {
|
|
3
3
|
constructor(options = {}) {
|
|
4
4
|
this.baseUrl = 'https://esi.evetech.net';
|
|
5
|
-
this.userAgent = '
|
|
5
|
+
this.userAgent = 'localisprimary/esi';
|
|
6
|
+
this.useRequestHeaders = true;
|
|
6
7
|
this.token = options.token;
|
|
8
|
+
this.useRequestHeaders = options.useRequestHeaders ?? true;
|
|
7
9
|
if (options.userAgent?.length) {
|
|
8
10
|
this.userAgent += ` ${options.userAgent}`;
|
|
9
11
|
}
|
|
@@ -20,6 +22,13 @@ export class EsiClient {
|
|
|
20
22
|
}
|
|
21
23
|
});
|
|
22
24
|
}
|
|
25
|
+
if (!this.useRequestHeaders) {
|
|
26
|
+
url.searchParams.append('user_agent', this.userAgent);
|
|
27
|
+
url.searchParams.append('compatibility_date', COMPATIBILITY_DATE);
|
|
28
|
+
if (this.token) {
|
|
29
|
+
url.searchParams.append('token', this.token);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
23
32
|
const headers = {
|
|
24
33
|
'Content-Type': 'application/json',
|
|
25
34
|
'X-Compatibility-Date': COMPATIBILITY_DATE,
|
|
@@ -30,7 +39,7 @@ export class EsiClient {
|
|
|
30
39
|
}
|
|
31
40
|
const response = await fetch(url.toString(), {
|
|
32
41
|
method,
|
|
33
|
-
headers,
|
|
42
|
+
headers: this.useRequestHeaders ? headers : undefined,
|
|
34
43
|
body: body ? JSON.stringify(body) : undefined,
|
|
35
44
|
});
|
|
36
45
|
const data = await response.json();
|