@patchstack/connect 0.5.0 → 0.5.1
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/AGENT-INSTALL.md +4 -1
- package/README.md +17 -1
- package/dist/cli.js +42 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +9 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/protect.cjs +10 -3
- package/dist/protect.cjs.map +1 -1
- package/dist/protect.js +1 -1
- package/dist/{refresh-manifest-LDS35UKV.js → refresh-manifest-2MMPQN2A.js} +10 -3
- package/dist/refresh-manifest-2MMPQN2A.js.map +1 -0
- package/package.json +1 -1
- package/dist/refresh-manifest-LDS35UKV.js.map +0 -1
package/dist/protect.cjs
CHANGED
|
@@ -142,6 +142,9 @@ var init_types = __esm({
|
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
// src/client.ts
|
|
145
|
+
function claimTokenHeader(config) {
|
|
146
|
+
return typeof config.claimToken === "string" && config.claimToken !== "" ? { [CLAIM_TOKEN_HEADER]: config.claimToken } : {};
|
|
147
|
+
}
|
|
145
148
|
function buildEndpointUrl(base, siteUuid) {
|
|
146
149
|
const trimmed = base.replace(/\/$/, "");
|
|
147
150
|
return siteUuid !== void 0 && siteUuid !== null && siteUuid.length > 0 ? `${trimmed}/${encodeURIComponent(siteUuid)}` : trimmed;
|
|
@@ -177,7 +180,8 @@ async function postManifest(config, payload) {
|
|
|
177
180
|
headers: {
|
|
178
181
|
"Content-Type": "application/json",
|
|
179
182
|
Accept: "application/json",
|
|
180
|
-
"User-Agent": "@patchstack/connect"
|
|
183
|
+
"User-Agent": "@patchstack/connect",
|
|
184
|
+
...claimTokenHeader(config)
|
|
181
185
|
},
|
|
182
186
|
body: JSON.stringify(buildManifestBody(config, payload)),
|
|
183
187
|
signal: AbortSignal.timeout(timeoutMs)
|
|
@@ -236,7 +240,7 @@ function isTimeoutError(cause) {
|
|
|
236
240
|
}
|
|
237
241
|
return false;
|
|
238
242
|
}
|
|
239
|
-
var DEFAULT_ENDPOINT, DEFAULT_TIMEOUT_MS;
|
|
243
|
+
var DEFAULT_ENDPOINT, DEFAULT_TIMEOUT_MS, CLAIM_TOKEN_HEADER;
|
|
240
244
|
var init_client = __esm({
|
|
241
245
|
"src/client.ts"() {
|
|
242
246
|
"use strict";
|
|
@@ -244,6 +248,7 @@ var init_client = __esm({
|
|
|
244
248
|
init_pulse_token();
|
|
245
249
|
DEFAULT_ENDPOINT = "https://api.patchstack.com/monitor/pulse/manifest";
|
|
246
250
|
DEFAULT_TIMEOUT_MS = 3e4;
|
|
251
|
+
CLAIM_TOKEN_HEADER = "X-Patchstack-Claim-Token";
|
|
247
252
|
}
|
|
248
253
|
});
|
|
249
254
|
|
|
@@ -478,6 +483,7 @@ async function resolveConfig(options) {
|
|
|
478
483
|
const apiKeyRaw = fromEnv.apiKey ?? fromSecretFile.apiKey ?? fromFile.apiKey ?? null;
|
|
479
484
|
const pulseAuthRaw = fromEnv.pulseAuth ?? fromSecretFile.pulseAuth ?? fromFile.pulseAuth ?? apiKeyRaw;
|
|
480
485
|
const identity = options.detectSiteIdentity === true ? await resolveSiteIdentity(options.cwd, fromEnv, fromFile) : { url: null, name: null };
|
|
486
|
+
const claimToken = stated(options.cliClaimToken) ?? stated(process.env.PATCHSTACK_CLAIM_TOKEN);
|
|
481
487
|
return {
|
|
482
488
|
siteUuid: siteUuid === null || siteUuid.length === 0 ? null : siteUuid,
|
|
483
489
|
apiKey: apiKeyRaw === null || apiKeyRaw.length === 0 ? null : apiKeyRaw,
|
|
@@ -487,7 +493,8 @@ async function resolveConfig(options) {
|
|
|
487
493
|
endpoint,
|
|
488
494
|
timeoutMs,
|
|
489
495
|
environment,
|
|
490
|
-
widget: fromFile.widget !== false
|
|
496
|
+
widget: fromFile.widget !== false,
|
|
497
|
+
claimToken
|
|
491
498
|
};
|
|
492
499
|
}
|
|
493
500
|
async function readSecretFile(cwd) {
|