@patchstack/connect 0.5.0 → 0.5.2
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 +95 -2
- package/README.md +105 -1
- package/dist/cli.js +987 -145
- 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/runtime/report-listeners.cjs +360 -0
- package/dist/protect/templates/express-guard.cjs +30 -12
- package/dist/protect/templates/express-guard.js +30 -12
- package/dist/protect/templates/express-guard.ts +35 -12
- package/dist/protect/templates/fastify-plugin.cjs +14 -1
- package/dist/protect/templates/fastify-plugin.js +14 -1
- package/dist/protect/templates/fastify-plugin.ts +14 -1
- package/dist/protect/templates/generic-guard.cjs +36 -12
- package/dist/protect/templates/generic-guard.js +36 -12
- package/dist/protect/templates/generic-guard.ts +41 -12
- package/dist/protect.cjs +43 -5
- package/dist/protect.cjs.map +1 -1
- package/dist/protect.d.cts +14 -0
- package/dist/protect.d.ts +14 -0
- package/dist/protect.edge.js +30 -1
- package/dist/protect.edge.js.map +2 -2
- package/dist/protect.js +31 -2
- package/dist/protect.js.map +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.js
CHANGED
|
@@ -4480,6 +4480,33 @@ function createSupabaseGuard({ protection, supabaseUrl, fetchImpl = fetch }) {
|
|
|
4480
4480
|
};
|
|
4481
4481
|
}
|
|
4482
4482
|
|
|
4483
|
+
// src/protect/verify-sentinel.js
|
|
4484
|
+
var VERIFY_HEADER = "x-patchstack-verify";
|
|
4485
|
+
var CHALLENGE = "PATCHSTACK_VERIFY_CHALLENGE";
|
|
4486
|
+
function configuredChallenge() {
|
|
4487
|
+
const value = typeof process !== "undefined" ? process.env?.[CHALLENGE] : void 0;
|
|
4488
|
+
return typeof value === "string" && value.length >= 32 ? value : null;
|
|
4489
|
+
}
|
|
4490
|
+
function sameValue(a, b) {
|
|
4491
|
+
if (typeof a !== "string" || typeof b !== "string" || a.length !== b.length) return false;
|
|
4492
|
+
let differs = 0;
|
|
4493
|
+
for (let i = 0; i < a.length; i += 1) differs |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
4494
|
+
return differs === 0;
|
|
4495
|
+
}
|
|
4496
|
+
async function sentinelAnswer(offered) {
|
|
4497
|
+
const challenge = configuredChallenge();
|
|
4498
|
+
if (challenge === null || !sameValue(challenge, typeof offered === "string" ? offered : null)) return null;
|
|
4499
|
+
const subtle = globalThis.crypto?.subtle;
|
|
4500
|
+
if (!subtle || typeof subtle.digest !== "function" || typeof TextEncoder === "undefined") return null;
|
|
4501
|
+
try {
|
|
4502
|
+
const bytes = new TextEncoder().encode(`patchstack-verify:${challenge}`);
|
|
4503
|
+
const digest = await subtle.digest("SHA-256", bytes);
|
|
4504
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
4505
|
+
} catch {
|
|
4506
|
+
return null;
|
|
4507
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4483
4510
|
// src/protect/runtime.js
|
|
4484
4511
|
function createServerFnGuard({ protection }) {
|
|
4485
4512
|
const guard = protection.fetchGuard();
|
|
@@ -5290,7 +5317,7 @@ async function createProtection(options = {}) {
|
|
|
5290
5317
|
let reporter = null;
|
|
5291
5318
|
if (refreshable && options.siteUuid && options.reportManifest !== false && cwd) {
|
|
5292
5319
|
try {
|
|
5293
|
-
({ reportManifest: reporter } = await import("./refresh-manifest-
|
|
5320
|
+
({ reportManifest: reporter } = await import("./refresh-manifest-2MMPQN2A.js"));
|
|
5294
5321
|
} catch (err) {
|
|
5295
5322
|
notify(onError, err, "onError");
|
|
5296
5323
|
}
|
|
@@ -5816,8 +5843,10 @@ function nodeRequestMeta(req, client) {
|
|
|
5816
5843
|
export {
|
|
5817
5844
|
GUARD_PATH,
|
|
5818
5845
|
PulseRuleClient,
|
|
5846
|
+
VERIFY_HEADER,
|
|
5819
5847
|
createProtection,
|
|
5820
5848
|
createServerFnGuard,
|
|
5821
|
-
createSupabaseGuard
|
|
5849
|
+
createSupabaseGuard,
|
|
5850
|
+
sentinelAnswer
|
|
5822
5851
|
};
|
|
5823
5852
|
//# sourceMappingURL=protect.js.map
|