@discover-cloud/shared 1.2.7 → 1.2.8
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.
|
@@ -2,10 +2,11 @@ import { ILogger } from "../utils";
|
|
|
2
2
|
export declare class MachineTokenClient {
|
|
3
3
|
private readonly gatewayUrl;
|
|
4
4
|
private readonly serviceId;
|
|
5
|
+
private readonly internalSecret?;
|
|
5
6
|
private readonly logger;
|
|
6
7
|
private cache;
|
|
7
8
|
private fetchPromise;
|
|
8
|
-
constructor(gatewayUrl: string, serviceId: string, logger?: ILogger);
|
|
9
|
+
constructor(gatewayUrl: string, serviceId: string, internalSecret?: string | undefined, logger?: ILogger);
|
|
9
10
|
getToken(requestId?: string): Promise<string>;
|
|
10
11
|
private getValidCachedToken;
|
|
11
12
|
private fetchToken;
|
|
@@ -4,9 +4,10 @@ exports.MachineTokenClient = void 0;
|
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const REFRESH_BUFFER_S = 10;
|
|
6
6
|
class MachineTokenClient {
|
|
7
|
-
constructor(gatewayUrl, serviceId, logger = utils_1.noopLogger) {
|
|
7
|
+
constructor(gatewayUrl, serviceId, internalSecret, logger = utils_1.noopLogger) {
|
|
8
8
|
this.gatewayUrl = gatewayUrl;
|
|
9
9
|
this.serviceId = serviceId;
|
|
10
|
+
this.internalSecret = internalSecret;
|
|
10
11
|
this.logger = logger;
|
|
11
12
|
this.cache = null;
|
|
12
13
|
this.fetchPromise = null;
|
|
@@ -36,11 +37,15 @@ class MachineTokenClient {
|
|
|
36
37
|
async fetchToken(requestId) {
|
|
37
38
|
const url = `${this.gatewayUrl}/internal/machine-token`;
|
|
38
39
|
this.logger.debug({ serviceId: this.serviceId, requestId }, "Fetching machine token");
|
|
40
|
+
const headers = {
|
|
41
|
+
"content-type": "application/json",
|
|
42
|
+
};
|
|
43
|
+
if (this.internalSecret) {
|
|
44
|
+
headers["x-internal-secret"] = this.internalSecret;
|
|
45
|
+
}
|
|
39
46
|
const response = await fetch(url, {
|
|
40
47
|
method: "POST",
|
|
41
|
-
headers
|
|
42
|
-
"content-type": "application/json",
|
|
43
|
-
},
|
|
48
|
+
headers,
|
|
44
49
|
body: JSON.stringify({
|
|
45
50
|
serviceId: this.serviceId,
|
|
46
51
|
requestId,
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@discover-cloud/shared",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"private": false,
|
|
5
|
-
"type": "commonjs",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc -p tsconfig.json",
|
|
13
|
-
"prepublishOnly": "npm run build"
|
|
14
|
-
},
|
|
15
|
-
"publishConfig": {
|
|
16
|
-
"access": "public"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"axios-retry": "^4.5.0",
|
|
20
|
-
"jose": "^6.1.3",
|
|
21
|
-
"redis": "^5.11.0"
|
|
22
|
-
},
|
|
23
|
-
"peerDependencies": {
|
|
24
|
-
"axios": "^1.13.5",
|
|
25
|
-
"express": "^5.2.1",
|
|
26
|
-
"zod": "^4.3.6"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/express": "^5.0.6",
|
|
30
|
-
"@types/node": "^25.3.0",
|
|
31
|
-
"axios": "^1.13.5",
|
|
32
|
-
"express": "^5.2.1",
|
|
33
|
-
"typescript": "^5.9.3",
|
|
34
|
-
"zod": "^4.3.6"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@discover-cloud/shared",
|
|
3
|
+
"version": "1.2.8",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc -p tsconfig.json",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"axios-retry": "^4.5.0",
|
|
20
|
+
"jose": "^6.1.3",
|
|
21
|
+
"redis": "^5.11.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"axios": "^1.13.5",
|
|
25
|
+
"express": "^5.2.1",
|
|
26
|
+
"zod": "^4.3.6"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/express": "^5.0.6",
|
|
30
|
+
"@types/node": "^25.3.0",
|
|
31
|
+
"axios": "^1.13.5",
|
|
32
|
+
"express": "^5.2.1",
|
|
33
|
+
"typescript": "^5.9.3",
|
|
34
|
+
"zod": "^4.3.6"
|
|
35
|
+
}
|
|
36
|
+
}
|