@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.d.cts
CHANGED
|
@@ -117,6 +117,20 @@ export interface Protection {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* The header a runtime wiring check sends, and the value a scaffolded guard answers it with.
|
|
122
|
+
*
|
|
123
|
+
* `protect --check --runtime` starts the app with a fresh challenge carried for that verification run,
|
|
124
|
+
* then asks for a response derived from it. The whole app process can read the challenge; the response
|
|
125
|
+
* rules out an accidental match, but does not prove which module answered.
|
|
126
|
+
*
|
|
127
|
+
* The seam reads the header itself and passes the value here; this decides whether it is the challenge
|
|
128
|
+
* and, if so, what to answer with. In a process not launched for runtime verification there is no
|
|
129
|
+
* challenge to match, so the answer is null and the request is screened exactly as it would have been.
|
|
130
|
+
*/
|
|
131
|
+
export declare const VERIFY_HEADER: "x-patchstack-verify";
|
|
132
|
+
export declare function sentinelAnswer(offered: unknown): Promise<string | null>;
|
|
133
|
+
|
|
120
134
|
export interface CreateProtectionOptions {
|
|
121
135
|
/**
|
|
122
136
|
* Fallback when the Pulse rules API does not send `enforcement`.
|
package/dist/protect.d.ts
CHANGED
|
@@ -117,6 +117,20 @@ export interface Protection {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* The header a runtime wiring check sends, and the value a scaffolded guard answers it with.
|
|
122
|
+
*
|
|
123
|
+
* `protect --check --runtime` starts the app with a fresh challenge carried for that verification run,
|
|
124
|
+
* then asks for a response derived from it. The whole app process can read the challenge; the response
|
|
125
|
+
* rules out an accidental match, but does not prove which module answered.
|
|
126
|
+
*
|
|
127
|
+
* The seam reads the header itself and passes the value here; this decides whether it is the challenge
|
|
128
|
+
* and, if so, what to answer with. In a process not launched for runtime verification there is no
|
|
129
|
+
* challenge to match, so the answer is null and the request is screened exactly as it would have been.
|
|
130
|
+
*/
|
|
131
|
+
export declare const VERIFY_HEADER: "x-patchstack-verify";
|
|
132
|
+
export declare function sentinelAnswer(offered: unknown): Promise<string | null>;
|
|
133
|
+
|
|
120
134
|
export interface CreateProtectionOptions {
|
|
121
135
|
/**
|
|
122
136
|
* Fallback when the Pulse rules API does not send `enforcement`.
|
package/dist/protect.edge.js
CHANGED
|
@@ -4594,6 +4594,33 @@ function createSupabaseGuard({ protection, supabaseUrl, fetchImpl = fetch }) {
|
|
|
4594
4594
|
};
|
|
4595
4595
|
}
|
|
4596
4596
|
|
|
4597
|
+
// src/protect/verify-sentinel.js
|
|
4598
|
+
var VERIFY_HEADER = "x-patchstack-verify";
|
|
4599
|
+
var CHALLENGE = "PATCHSTACK_VERIFY_CHALLENGE";
|
|
4600
|
+
function configuredChallenge() {
|
|
4601
|
+
const value = typeof process !== "undefined" ? process.env?.[CHALLENGE] : void 0;
|
|
4602
|
+
return typeof value === "string" && value.length >= 32 ? value : null;
|
|
4603
|
+
}
|
|
4604
|
+
function sameValue(a, b) {
|
|
4605
|
+
if (typeof a !== "string" || typeof b !== "string" || a.length !== b.length) return false;
|
|
4606
|
+
let differs = 0;
|
|
4607
|
+
for (let i = 0; i < a.length; i += 1) differs |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
4608
|
+
return differs === 0;
|
|
4609
|
+
}
|
|
4610
|
+
async function sentinelAnswer(offered) {
|
|
4611
|
+
const challenge = configuredChallenge();
|
|
4612
|
+
if (challenge === null || !sameValue(challenge, typeof offered === "string" ? offered : null)) return null;
|
|
4613
|
+
const subtle = globalThis.crypto?.subtle;
|
|
4614
|
+
if (!subtle || typeof subtle.digest !== "function" || typeof TextEncoder === "undefined") return null;
|
|
4615
|
+
try {
|
|
4616
|
+
const bytes = new TextEncoder().encode(`patchstack-verify:${challenge}`);
|
|
4617
|
+
const digest = await subtle.digest("SHA-256", bytes);
|
|
4618
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
4619
|
+
} catch {
|
|
4620
|
+
return null;
|
|
4621
|
+
}
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4597
4624
|
// src/protect/runtime.js
|
|
4598
4625
|
function createServerFnGuard({ protection }) {
|
|
4599
4626
|
const guard = protection.fetchGuard();
|
|
@@ -5930,8 +5957,10 @@ function nodeRequestMeta(req, client) {
|
|
|
5930
5957
|
export {
|
|
5931
5958
|
GUARD_PATH,
|
|
5932
5959
|
PulseRuleClient,
|
|
5960
|
+
VERIFY_HEADER,
|
|
5933
5961
|
createProtection,
|
|
5934
5962
|
createServerFnGuard,
|
|
5935
|
-
createSupabaseGuard
|
|
5963
|
+
createSupabaseGuard,
|
|
5964
|
+
sentinelAnswer
|
|
5936
5965
|
};
|
|
5937
5966
|
//# sourceMappingURL=protect.edge.js.map
|