@proxy-checkout/cli 0.1.0-prx-128.110.1 → 0.1.0-prx-128.112.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.
@@ -1,6 +1,6 @@
1
1
  import { CliConfigStore } from "./config.js";
2
2
  import { type CliIo } from "./output.js";
3
- export declare const cliVersion = "0.1.0-prx-128.110.1";
3
+ export declare const cliVersion = "0.1.0-prx-128.112.1";
4
4
  export interface RunCliOptions {
5
5
  configStore?: CliConfigStore;
6
6
  environment?: NodeJS.ProcessEnv;
package/dist/cjs/cli.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CliConfigStore } from "./config.js";
2
2
  import { type CliIo } from "./output.js";
3
- export declare const cliVersion = "0.1.0-prx-128.110.1";
3
+ export declare const cliVersion = "0.1.0-prx-128.112.1";
4
4
  export interface RunCliOptions {
5
5
  configStore?: CliConfigStore;
6
6
  environment?: NodeJS.ProcessEnv;
package/dist/cjs/cli.js CHANGED
@@ -9,7 +9,7 @@ const config_js_1 = require("./config.js");
9
9
  const errors_js_1 = require("./errors.js");
10
10
  const output_js_1 = require("./output.js");
11
11
  const webhooks_js_1 = require("./webhooks.js");
12
- exports.cliVersion = "0.1.0-prx-128.110.1";
12
+ exports.cliVersion = "0.1.0-prx-128.112.1";
13
13
  async function runCli(argv, options = {}) {
14
14
  const io = options.io ?? {
15
15
  isTTY: Boolean(process.stdin.isTTY && process.stdout.isTTY),
@@ -89,6 +89,7 @@ async function runListener(input) {
89
89
  const destination = validateLoopbackDestination(input.forwardTo);
90
90
  const listener = await input.client.createListener(input.sourceEndpointId, input.signal);
91
91
  let stripeProcess;
92
+ let stripeProcessFailure;
92
93
  let forwarded = 0;
93
94
  let heartbeatFailure;
94
95
  const heartbeatTimer = setInterval(() => {
@@ -104,7 +105,9 @@ async function runListener(input) {
104
105
  if (input.stripe) {
105
106
  const webhookSecret = await captureStripeWebhookSecret(input.signal);
106
107
  const ingress = await input.client.createStripeIngress(listener.id, webhookSecret, input.pspConfigId, input.signal);
107
- stripeProcess = startStripeListener(ingress.inbound_url, input.output);
108
+ stripeProcess = await startStripeListener(ingress.inbound_url, input.output, (error) => {
109
+ stripeProcessFailure = stripeListenerStartError(error);
110
+ });
108
111
  input.output.event("stripe.started", {
109
112
  expires_at: ingress.expires_at,
110
113
  ingress_id: ingress.id,
@@ -117,6 +120,9 @@ async function runListener(input) {
117
120
  if (heartbeatFailure) {
118
121
  throw heartbeatFailure;
119
122
  }
123
+ if (stripeProcessFailure) {
124
+ throw stripeProcessFailure;
125
+ }
120
126
  if (stripeProcess && (stripeProcess.exitCode !== null || stripeProcess.signalCode)) {
121
127
  throw new errors_js_1.CliError("Stripe CLI listener exited unexpectedly", "stripe_cli_exited", errors_js_1.cliExitCodes.dependency, { exit_code: stripeProcess.exitCode, signal: stripeProcess.signalCode });
122
128
  }
@@ -135,6 +141,8 @@ async function runListener(input) {
135
141
  webhook_delivery_id: claim.webhook_delivery_id,
136
142
  }, `Forwarded ${claim.kind} ${claim.webhook_delivery_id} (${formatCompletion(completion)}).`);
137
143
  }
144
+ if (stripeProcessFailure)
145
+ throw stripeProcessFailure;
138
146
  if (input.signal.aborted)
139
147
  throw listenerInterrupted();
140
148
  return { forwarded, listener };
@@ -220,7 +228,7 @@ async function captureStripeWebhookSecret(signal) {
220
228
  function listenerInterrupted() {
221
229
  return new errors_js_1.CliError("Local webhook listener interrupted", "cli_listener_interrupted", errors_js_1.cliExitCodes.interrupted);
222
230
  }
223
- function startStripeListener(inboundUrl, output) {
231
+ function startStripeListener(inboundUrl, output, onError) {
224
232
  const child = (0, node_child_process_1.spawn)("stripe", ["listen", "--events", stripeEvents, "--forward-to", inboundUrl], {
225
233
  shell: false,
226
234
  stdio: ["pipe", "pipe", "pipe"],
@@ -228,8 +236,28 @@ function startStripeListener(inboundUrl, output) {
228
236
  child.stdin.end();
229
237
  pipeSanitized(child.stdout, (line) => output.notice(`[stripe] ${line}`));
230
238
  pipeSanitized(child.stderr, (line) => output.notice(`[stripe] ${line}`));
231
- child.once("error", () => undefined);
232
- return child;
239
+ return new Promise((resolve, reject) => {
240
+ const handleInitialError = (error) => {
241
+ child.removeListener("spawn", handleSpawn);
242
+ reject(stripeListenerStartError(error));
243
+ };
244
+ const handleSpawn = () => {
245
+ child.removeListener("spawn", handleSpawn);
246
+ child.removeListener("error", handleInitialError);
247
+ child.once("error", onError);
248
+ resolve(child);
249
+ };
250
+ child.once("error", handleInitialError);
251
+ child.once("spawn", handleSpawn);
252
+ if (child.exitCode !== null || child.signalCode)
253
+ handleSpawn();
254
+ });
255
+ }
256
+ function stripeListenerStartError(error) {
257
+ if (error?.code === "ENOENT") {
258
+ return new errors_js_1.CliError("Stripe CLI is not installed or not on PATH", "stripe_cli_not_found", errors_js_1.cliExitCodes.dependency);
259
+ }
260
+ return new errors_js_1.CliError("Stripe CLI listener could not start", "stripe_cli_start_failed", errors_js_1.cliExitCodes.dependency);
233
261
  }
234
262
  function pipeSanitized(stream, writeLine) {
235
263
  let pending = "";
package/dist/esm/cli.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CliConfigStore } from "./config.js";
2
2
  import { type CliIo } from "./output.js";
3
- export declare const cliVersion = "0.1.0-prx-128.110.1";
3
+ export declare const cliVersion = "0.1.0-prx-128.112.1";
4
4
  export interface RunCliOptions {
5
5
  configStore?: CliConfigStore;
6
6
  environment?: NodeJS.ProcessEnv;
package/dist/esm/cli.js CHANGED
@@ -5,7 +5,7 @@ import { CliConfigStore } from "./config.js";
5
5
  import { asCliError, CliError, cliExitCodes, usageError } from "./errors.js";
6
6
  import { CliOutput } from "./output.js";
7
7
  import { forwardSelectedDelivery, ProxyWebhooksClient, runListener, } from "./webhooks.js";
8
- export const cliVersion = "0.1.0-prx-128.110.1";
8
+ export const cliVersion = "0.1.0-prx-128.112.1";
9
9
  export async function runCli(argv, options = {}) {
10
10
  const io = options.io ?? {
11
11
  isTTY: Boolean(process.stdin.isTTY && process.stdout.isTTY),
@@ -83,6 +83,7 @@ export async function runListener(input) {
83
83
  const destination = validateLoopbackDestination(input.forwardTo);
84
84
  const listener = await input.client.createListener(input.sourceEndpointId, input.signal);
85
85
  let stripeProcess;
86
+ let stripeProcessFailure;
86
87
  let forwarded = 0;
87
88
  let heartbeatFailure;
88
89
  const heartbeatTimer = setInterval(() => {
@@ -98,7 +99,9 @@ export async function runListener(input) {
98
99
  if (input.stripe) {
99
100
  const webhookSecret = await captureStripeWebhookSecret(input.signal);
100
101
  const ingress = await input.client.createStripeIngress(listener.id, webhookSecret, input.pspConfigId, input.signal);
101
- stripeProcess = startStripeListener(ingress.inbound_url, input.output);
102
+ stripeProcess = await startStripeListener(ingress.inbound_url, input.output, (error) => {
103
+ stripeProcessFailure = stripeListenerStartError(error);
104
+ });
102
105
  input.output.event("stripe.started", {
103
106
  expires_at: ingress.expires_at,
104
107
  ingress_id: ingress.id,
@@ -111,6 +114,9 @@ export async function runListener(input) {
111
114
  if (heartbeatFailure) {
112
115
  throw heartbeatFailure;
113
116
  }
117
+ if (stripeProcessFailure) {
118
+ throw stripeProcessFailure;
119
+ }
114
120
  if (stripeProcess && (stripeProcess.exitCode !== null || stripeProcess.signalCode)) {
115
121
  throw new CliError("Stripe CLI listener exited unexpectedly", "stripe_cli_exited", cliExitCodes.dependency, { exit_code: stripeProcess.exitCode, signal: stripeProcess.signalCode });
116
122
  }
@@ -129,6 +135,8 @@ export async function runListener(input) {
129
135
  webhook_delivery_id: claim.webhook_delivery_id,
130
136
  }, `Forwarded ${claim.kind} ${claim.webhook_delivery_id} (${formatCompletion(completion)}).`);
131
137
  }
138
+ if (stripeProcessFailure)
139
+ throw stripeProcessFailure;
132
140
  if (input.signal.aborted)
133
141
  throw listenerInterrupted();
134
142
  return { forwarded, listener };
@@ -214,7 +222,7 @@ async function captureStripeWebhookSecret(signal) {
214
222
  function listenerInterrupted() {
215
223
  return new CliError("Local webhook listener interrupted", "cli_listener_interrupted", cliExitCodes.interrupted);
216
224
  }
217
- function startStripeListener(inboundUrl, output) {
225
+ function startStripeListener(inboundUrl, output, onError) {
218
226
  const child = spawn("stripe", ["listen", "--events", stripeEvents, "--forward-to", inboundUrl], {
219
227
  shell: false,
220
228
  stdio: ["pipe", "pipe", "pipe"],
@@ -222,8 +230,28 @@ function startStripeListener(inboundUrl, output) {
222
230
  child.stdin.end();
223
231
  pipeSanitized(child.stdout, (line) => output.notice(`[stripe] ${line}`));
224
232
  pipeSanitized(child.stderr, (line) => output.notice(`[stripe] ${line}`));
225
- child.once("error", () => undefined);
226
- return child;
233
+ return new Promise((resolve, reject) => {
234
+ const handleInitialError = (error) => {
235
+ child.removeListener("spawn", handleSpawn);
236
+ reject(stripeListenerStartError(error));
237
+ };
238
+ const handleSpawn = () => {
239
+ child.removeListener("spawn", handleSpawn);
240
+ child.removeListener("error", handleInitialError);
241
+ child.once("error", onError);
242
+ resolve(child);
243
+ };
244
+ child.once("error", handleInitialError);
245
+ child.once("spawn", handleSpawn);
246
+ if (child.exitCode !== null || child.signalCode)
247
+ handleSpawn();
248
+ });
249
+ }
250
+ function stripeListenerStartError(error) {
251
+ if (error?.code === "ENOENT") {
252
+ return new CliError("Stripe CLI is not installed or not on PATH", "stripe_cli_not_found", cliExitCodes.dependency);
253
+ }
254
+ return new CliError("Stripe CLI listener could not start", "stripe_cli_start_failed", cliExitCodes.dependency);
227
255
  }
228
256
  function pipeSanitized(stream, writeLine) {
229
257
  let pending = "";
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "sideEffects": false,
8
8
  "type": "module",
9
9
  "types": "./dist/esm/index.d.ts",
10
- "version": "0.1.0-prx-128.110.1",
10
+ "version": "0.1.0-prx-128.112.1",
11
11
  "bin": {
12
12
  "proxy": "./dist/esm/bin.js"
13
13
  },