mppx 0.22.0 → 0.22.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # mppx
2
2
 
3
+ ## 0.22.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d4a8c29: Added `headers` declarations to every identity extension's verifier, payment check and prover, so a proxy and the client's redirect stripping find each protocol's headers from the extension itself.
8
+ - d20d140: Fixed macOS account storage passing the private key in `security` process arguments. The CLI now sends the keychain command on stdin through `security -i`.
9
+ - e3a3dad: Stripped `Forwarded`, `X-Real-IP`, `True-Client-IP`, `CF-Connecting-IP` and `Via` from proxied requests, as `X-Forwarded-*` already is.
10
+ - 364fe92: Added `headers` to identity verifiers and payment checks: a proxy strips the headers declared by the identity protocols its routes use.
11
+
3
12
  ## 0.22.0
4
13
 
5
14
  ### Minor Changes
@@ -1,4 +1,5 @@
1
- export declare function execCommand(command: string, args: string[]): Promise<{
1
+ /** Runs a command without a shell, optionally writing `input` to its stdin. */
2
+ export declare function execCommand(command: string, args: string[], input?: string): Promise<{
2
3
  stdout: string;
3
4
  stderr: string;
4
5
  error: Error | null;
@@ -26,11 +26,27 @@ function assertSecretToolAvailable(error) {
26
26
  if (error && isMissingCommand(error, 'secret-tool'))
27
27
  throw keyringUnavailableError(error);
28
28
  }
29
- export function execCommand(command, args) {
29
+ /**
30
+ * Formats one command line for `security -i`, which splits stdin lines into arguments with
31
+ * quote and backslash escaping. Rejects newlines, which would end the command line early.
32
+ */
33
+ function securityCommandLine(args) {
34
+ return args
35
+ .map((arg) => {
36
+ if (/[\r\n]/.test(arg))
37
+ throw new Error('Keychain values cannot contain line breaks.');
38
+ return `"${arg.replace(/["\\]/g, '\\$&')}"`;
39
+ })
40
+ .join(' ');
41
+ }
42
+ /** Runs a command without a shell, optionally writing `input` to its stdin. */
43
+ export function execCommand(command, args, input) {
30
44
  return new Promise((resolve) => {
31
- child.execFile(command, args, { timeout: commandTimeoutMs() }, (error, stdout, stderr) => {
45
+ const proc = child.execFile(command, args, { timeout: commandTimeoutMs() }, (error, stdout, stderr) => {
32
46
  resolve({ stdout: stdout.trim(), stderr: stderr.trim(), error });
33
47
  });
48
+ if (input !== undefined)
49
+ proc.stdin?.end(input);
34
50
  });
35
51
  }
36
52
  export function createDefaultStore() {
@@ -133,16 +149,11 @@ export function createKeychain(account = 'main') {
133
149
  async set(value) {
134
150
  const platform = os.platform();
135
151
  if (platform === 'darwin') {
152
+ // Send the command on stdin (`security -i`) so the secret never appears in process arguments.
153
+ // Build it before deleting so a rejected value leaves the existing item in place.
154
+ const input = `${securityCommandLine(['add-generic-password', '-s', service, '-a', account, '-w', value])}\n`;
136
155
  await execCommand('security', ['delete-generic-password', '-s', service, '-a', account]);
137
- const { error } = await execCommand('security', [
138
- 'add-generic-password',
139
- '-s',
140
- service,
141
- '-a',
142
- account,
143
- '-w',
144
- value,
145
- ]);
156
+ const { error } = await execCommand('security', ['-i'], input);
146
157
  if (error)
147
158
  throw error;
148
159
  return;