opencode-secrets-obfuscation 0.1.2 → 0.1.3

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/plugin.mjs +4 -0
package/README.md CHANGED
@@ -10,7 +10,7 @@ This plugin keeps configured dotenv values private and substitutes opaque secret
10
10
 
11
11
  ## Installation
12
12
 
13
- Install with: opencode plugin add opencode-secrets-obfuscation@0.1.2
13
+ Install with: opencode plugin add opencode-secrets-obfuscation@0.1.3
14
14
 
15
15
  Configure the published package in opencode.jsonc with the options documented at https://github.com/jfomhhover/opencode-secrets-obfuscation/blob/main/INSTALL.md.
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-secrets-obfuscation",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Transparent OpenCode V2 secret substitution plugin",
5
5
  "license": "MIT",
6
6
  "repository": {
package/plugin.mjs CHANGED
@@ -3514,6 +3514,7 @@ async function redactRequest(request, state) {
3514
3514
  request.headers.forEach((value, name) => {
3515
3515
  record[name] = value;
3516
3516
  });
3517
+ const originalHeaders = { ...record };
3517
3518
  if (redactHeaders(record, state, { skipAuth: true, strict: true }) === "withheld") return "withheld";
3518
3519
  delete record["content-length"];
3519
3520
  let body;
@@ -3528,6 +3529,9 @@ async function redactRequest(request, state) {
3528
3529
  if (safe !== read.text) body = safe;
3529
3530
  }
3530
3531
  }
3532
+ const headersChanged = Object.keys(record).length !== Object.keys(originalHeaders).length || Object.keys(record).some((name) => record[name] !== originalHeaders[name]);
3533
+ if (body === void 0 && !headersChanged) return request;
3534
+ if (body !== void 0) record["content-length"] = String(encoder2.encode(body).byteLength);
3531
3535
  try {
3532
3536
  return new Request(request, {
3533
3537
  headers: record,