@proxy-checkout/cli 0.1.1-prx-124.137.1 → 0.1.1-prx-124.139.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.1-prx-124.137.1";
3
+ export declare const cliVersion = "0.1.1-prx-124.139.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.1-prx-124.137.1";
3
+ export declare const cliVersion = "0.1.1-prx-124.139.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.1-prx-124.137.1";
12
+ exports.cliVersion = "0.1.1-prx-124.139.1";
13
13
  async function runCli(argv, options = {}) {
14
14
  const io = options.io ?? {
15
15
  isTTY: Boolean(process.stdin.isTTY && process.stdout.isTTY),
@@ -1 +1,2 @@
1
1
  export declare const stripeIntegrationCapabilitiesManifestVersion: 2;
2
+ export declare const stripeLegacyCliEventTypes: readonly ["checkout.session.completed", "customer.subscription.deleted", "customer.subscription.updated", "invoice.paid", "invoice.payment_failed", "payment_intent.canceled", "payment_intent.payment_failed", "payment_intent.succeeded"];
@@ -1 +1,2 @@
1
1
  export declare const stripeIntegrationCapabilitiesManifestVersion: 2;
2
+ export declare const stripeLegacyCliEventTypes: readonly ["checkout.session.completed", "customer.subscription.deleted", "customer.subscription.updated", "invoice.paid", "invoice.payment_failed", "payment_intent.canceled", "payment_intent.payment_failed", "payment_intent.succeeded"];
@@ -1,5 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stripeIntegrationCapabilitiesManifestVersion = void 0;
3
+ exports.stripeLegacyCliEventTypes = exports.stripeIntegrationCapabilitiesManifestVersion = void 0;
4
4
  // Generated by tools/compliance/sync-stripe-integration-capabilities.mjs.
5
5
  exports.stripeIntegrationCapabilitiesManifestVersion = 2;
6
+ exports.stripeLegacyCliEventTypes = [
7
+ "checkout.session.completed",
8
+ "customer.subscription.deleted",
9
+ "customer.subscription.updated",
10
+ "invoice.paid",
11
+ "invoice.payment_failed",
12
+ "payment_intent.canceled",
13
+ "payment_intent.payment_failed",
14
+ "payment_intent.succeeded",
15
+ ];
@@ -5,6 +5,7 @@ export interface StripeIngressProfileRecord {
5
5
  merchant_psp_config_id: string;
6
6
  profile_hash: string;
7
7
  }
8
+ export declare function canonicalLegacyStripeIngressEventTypes(): string[];
8
9
  export declare function validateStripeIngressProfile(profile: StripeIngressProfileRecord): StripeIngressProfileRecord;
9
10
  export declare function assertCreatedStripeIngressProfile(expected: StripeIngressProfileRecord, actual: {
10
11
  event_types: string[];
@@ -5,6 +5,7 @@ export interface StripeIngressProfileRecord {
5
5
  merchant_psp_config_id: string;
6
6
  profile_hash: string;
7
7
  }
8
+ export declare function canonicalLegacyStripeIngressEventTypes(): string[];
8
9
  export declare function validateStripeIngressProfile(profile: StripeIngressProfileRecord): StripeIngressProfileRecord;
9
10
  export declare function assertCreatedStripeIngressProfile(expected: StripeIngressProfileRecord, actual: {
10
11
  event_types: string[];
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canonicalLegacyStripeIngressEventTypes = canonicalLegacyStripeIngressEventTypes;
3
4
  exports.validateStripeIngressProfile = validateStripeIngressProfile;
4
5
  exports.assertCreatedStripeIngressProfile = assertCreatedStripeIngressProfile;
5
6
  const errors_js_1 = require("./errors.js");
@@ -8,6 +9,9 @@ const stripeEventPattern = /^[a-z0-9_]+(?:\.[a-z0-9_]+)+$/;
8
9
  const capabilityPattern = /^[a-z0-9_]+(?:\.[a-z0-9_]+)+$/;
9
10
  const sha256Pattern = /^[0-9a-f]{64}$/;
10
11
  const maximumEntries = 100;
12
+ function canonicalLegacyStripeIngressEventTypes() {
13
+ return [...stripe_integration_capabilities_version_js_1.stripeLegacyCliEventTypes];
14
+ }
11
15
  function validateStripeIngressProfile(profile) {
12
16
  if (profile.manifest_version !== stripe_integration_capabilities_version_js_1.stripeIntegrationCapabilitiesManifestVersion) {
13
17
  throw profileError("Stripe ingress profile uses an incompatible manifest version");
@@ -33,7 +37,10 @@ function assertSortedUnique(values, pattern, allowEmpty, label) {
33
37
  (!allowEmpty && values.length === 0) ||
34
38
  values.length > maximumEntries ||
35
39
  values.some((value) => !pattern.test(value)) ||
36
- values.some((value, index) => index > 0 && values[index - 1] >= value)) {
40
+ values.some((value, index) => {
41
+ const previous = values[index - 1];
42
+ return previous !== undefined && previous >= value;
43
+ })) {
37
44
  throw profileError(`Stripe ingress profile ${label} are invalid`);
38
45
  }
39
46
  }
@@ -54,6 +54,12 @@ export declare class ProxyWebhooksClient {
54
54
  merchant_psp_config_id: string;
55
55
  profile_hash: string;
56
56
  }>;
57
+ createLegacyStripeIngress(listenerId: string, webhookSecret: string, pspConfigId?: string, signal?: AbortSignal): Promise<{
58
+ expires_at: string;
59
+ id: string;
60
+ inbound_url: string;
61
+ merchant_psp_config_id: string;
62
+ }>;
57
63
  getStripeIngressProfile(listenerId: string, pspConfigId?: string, signal?: AbortSignal): Promise<StripeIngressProfileRecord>;
58
64
  }
59
65
  export declare function runListener(input: {
@@ -54,6 +54,12 @@ export declare class ProxyWebhooksClient {
54
54
  merchant_psp_config_id: string;
55
55
  profile_hash: string;
56
56
  }>;
57
+ createLegacyStripeIngress(listenerId: string, webhookSecret: string, pspConfigId?: string, signal?: AbortSignal): Promise<{
58
+ expires_at: string;
59
+ id: string;
60
+ inbound_url: string;
61
+ merchant_psp_config_id: string;
62
+ }>;
57
63
  getStripeIngressProfile(listenerId: string, pspConfigId?: string, signal?: AbortSignal): Promise<StripeIngressProfileRecord>;
58
64
  }
59
65
  export declare function runListener(input: {
@@ -75,6 +75,16 @@ class ProxyWebhooksClient {
75
75
  signal,
76
76
  })).stripe_ingress;
77
77
  }
78
+ async createLegacyStripeIngress(listenerId, webhookSecret, pspConfigId, signal) {
79
+ return (await this.api.request(`/cli/webhook-listeners/${encodeURIComponent(listenerId)}/stripe-ingress`, {
80
+ method: "POST",
81
+ body: {
82
+ ...(pspConfigId ? { psp_config_id: pspConfigId } : {}),
83
+ webhook_secret: webhookSecret,
84
+ },
85
+ signal,
86
+ })).stripe_ingress;
87
+ }
78
88
  async getStripeIngressProfile(listenerId, pspConfigId, signal) {
79
89
  const query = pspConfigId ? `?${new URLSearchParams({ psp_config_id: pspConfigId })}` : "";
80
90
  return (await this.api.request(`/cli/webhook-listeners/${encodeURIComponent(listenerId)}/stripe-ingress-profile${query}`, { signal })).stripe_ingress_profile;
@@ -99,22 +109,47 @@ async function runListener(input) {
99
109
  if (input.signal.aborted)
100
110
  throw listenerInterrupted();
101
111
  if (input.stripe) {
102
- const stripeProfile = (0, stripe_profile_js_1.validateStripeIngressProfile)(await input.client.getStripeIngressProfile(listener.id, input.pspConfigId, input.signal));
103
- const webhookSecret = await captureStripeWebhookSecret(stripeProfile.event_types, input.signal);
104
- const ingress = await input.client.createStripeIngress(listener.id, webhookSecret, stripeProfile.profile_hash, input.pspConfigId, input.signal);
105
- (0, stripe_profile_js_1.assertCreatedStripeIngressProfile)(stripeProfile, ingress);
106
- stripeProcess = await startStripeListener(ingress.inbound_url, ingress.event_types, input.output, (error) => {
112
+ let stripeProfile;
113
+ try {
114
+ stripeProfile = (0, stripe_profile_js_1.validateStripeIngressProfile)(await input.client.getStripeIngressProfile(listener.id, input.pspConfigId, input.signal));
115
+ }
116
+ catch (error) {
117
+ if (!isMissingStripeIngressProfileRoute(error))
118
+ throw error;
119
+ }
120
+ const eventTypes = stripeProfile
121
+ ? stripeProfile.event_types
122
+ : (0, stripe_profile_js_1.canonicalLegacyStripeIngressEventTypes)();
123
+ const webhookSecret = await captureStripeWebhookSecret(eventTypes, input.signal);
124
+ let ingress;
125
+ if (stripeProfile) {
126
+ const profiledIngress = await input.client.createStripeIngress(listener.id, webhookSecret, stripeProfile.profile_hash, input.pspConfigId, input.signal);
127
+ (0, stripe_profile_js_1.assertCreatedStripeIngressProfile)(stripeProfile, profiledIngress);
128
+ ingress = profiledIngress;
129
+ }
130
+ else {
131
+ ingress = await input.client.createLegacyStripeIngress(listener.id, webhookSecret, input.pspConfigId, input.signal);
132
+ }
133
+ stripeProcess = await startStripeListener(ingress.inbound_url, eventTypes, input.output, (error) => {
107
134
  stripeProcessFailure = stripeListenerStartError(error);
108
135
  });
109
- input.output.event("stripe.started", {
110
- effective_capability_ids: stripeProfile.effective_capability_ids,
111
- event_types: ingress.event_types,
112
- expires_at: ingress.expires_at,
113
- ingress_id: ingress.id,
114
- manifest_version: ingress.manifest_version,
115
- merchant_psp_config_id: ingress.merchant_psp_config_id,
116
- profile_hash: ingress.profile_hash,
117
- }, "Stripe CLI test webhook orchestration is active.");
136
+ input.output.event("stripe.started", stripeProfile
137
+ ? {
138
+ effective_capability_ids: stripeProfile.effective_capability_ids,
139
+ event_types: eventTypes,
140
+ expires_at: ingress.expires_at,
141
+ ingress_id: ingress.id,
142
+ manifest_version: stripeProfile.manifest_version,
143
+ merchant_psp_config_id: ingress.merchant_psp_config_id,
144
+ profile_hash: stripeProfile.profile_hash,
145
+ }
146
+ : {
147
+ compatibility_mode: "legacy_api",
148
+ event_types: eventTypes,
149
+ expires_at: ingress.expires_at,
150
+ ingress_id: ingress.id,
151
+ merchant_psp_config_id: ingress.merchant_psp_config_id,
152
+ }, "Stripe CLI test webhook orchestration is active.");
118
153
  }
119
154
  if (input.signal.aborted)
120
155
  throw listenerInterrupted();
@@ -170,6 +205,9 @@ async function runListener(input) {
170
205
  }
171
206
  }
172
207
  }
208
+ function isMissingStripeIngressProfileRoute(error) {
209
+ return error instanceof errors_js_1.CliError && error.code === "http_404" && error.details?.status === 404;
210
+ }
173
211
  async function forwardSelectedDelivery(input) {
174
212
  const destination = validateLoopbackDestination(input.forwardTo);
175
213
  const claim = await input.client.claim(input.listenerId, {
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.1-prx-124.137.1";
3
+ export declare const cliVersion = "0.1.1-prx-124.139.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.1-prx-124.137.1";
8
+ export const cliVersion = "0.1.1-prx-124.139.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),
@@ -1 +1,2 @@
1
1
  export declare const stripeIntegrationCapabilitiesManifestVersion: 2;
2
+ export declare const stripeLegacyCliEventTypes: readonly ["checkout.session.completed", "customer.subscription.deleted", "customer.subscription.updated", "invoice.paid", "invoice.payment_failed", "payment_intent.canceled", "payment_intent.payment_failed", "payment_intent.succeeded"];
@@ -1,2 +1,12 @@
1
1
  // Generated by tools/compliance/sync-stripe-integration-capabilities.mjs.
2
2
  export const stripeIntegrationCapabilitiesManifestVersion = 2;
3
+ export const stripeLegacyCliEventTypes = [
4
+ "checkout.session.completed",
5
+ "customer.subscription.deleted",
6
+ "customer.subscription.updated",
7
+ "invoice.paid",
8
+ "invoice.payment_failed",
9
+ "payment_intent.canceled",
10
+ "payment_intent.payment_failed",
11
+ "payment_intent.succeeded",
12
+ ];
@@ -5,6 +5,7 @@ export interface StripeIngressProfileRecord {
5
5
  merchant_psp_config_id: string;
6
6
  profile_hash: string;
7
7
  }
8
+ export declare function canonicalLegacyStripeIngressEventTypes(): string[];
8
9
  export declare function validateStripeIngressProfile(profile: StripeIngressProfileRecord): StripeIngressProfileRecord;
9
10
  export declare function assertCreatedStripeIngressProfile(expected: StripeIngressProfileRecord, actual: {
10
11
  event_types: string[];
@@ -1,9 +1,12 @@
1
1
  import { CliError, cliExitCodes } from "./errors.js";
2
- import { stripeIntegrationCapabilitiesManifestVersion } from "./generated/stripe-integration-capabilities-version.js";
2
+ import { stripeIntegrationCapabilitiesManifestVersion, stripeLegacyCliEventTypes, } from "./generated/stripe-integration-capabilities-version.js";
3
3
  const stripeEventPattern = /^[a-z0-9_]+(?:\.[a-z0-9_]+)+$/;
4
4
  const capabilityPattern = /^[a-z0-9_]+(?:\.[a-z0-9_]+)+$/;
5
5
  const sha256Pattern = /^[0-9a-f]{64}$/;
6
6
  const maximumEntries = 100;
7
+ export function canonicalLegacyStripeIngressEventTypes() {
8
+ return [...stripeLegacyCliEventTypes];
9
+ }
7
10
  export function validateStripeIngressProfile(profile) {
8
11
  if (profile.manifest_version !== stripeIntegrationCapabilitiesManifestVersion) {
9
12
  throw profileError("Stripe ingress profile uses an incompatible manifest version");
@@ -29,7 +32,10 @@ function assertSortedUnique(values, pattern, allowEmpty, label) {
29
32
  (!allowEmpty && values.length === 0) ||
30
33
  values.length > maximumEntries ||
31
34
  values.some((value) => !pattern.test(value)) ||
32
- values.some((value, index) => index > 0 && values[index - 1] >= value)) {
35
+ values.some((value, index) => {
36
+ const previous = values[index - 1];
37
+ return previous !== undefined && previous >= value;
38
+ })) {
33
39
  throw profileError(`Stripe ingress profile ${label} are invalid`);
34
40
  }
35
41
  }
@@ -54,6 +54,12 @@ export declare class ProxyWebhooksClient {
54
54
  merchant_psp_config_id: string;
55
55
  profile_hash: string;
56
56
  }>;
57
+ createLegacyStripeIngress(listenerId: string, webhookSecret: string, pspConfigId?: string, signal?: AbortSignal): Promise<{
58
+ expires_at: string;
59
+ id: string;
60
+ inbound_url: string;
61
+ merchant_psp_config_id: string;
62
+ }>;
57
63
  getStripeIngressProfile(listenerId: string, pspConfigId?: string, signal?: AbortSignal): Promise<StripeIngressProfileRecord>;
58
64
  }
59
65
  export declare function runListener(input: {
@@ -2,7 +2,7 @@ import { spawn } from "node:child_process";
2
2
  import { CliError, cliExitCodes } from "./errors.js";
3
3
  import { ProxyApiClient } from "./http-client.js";
4
4
  import { redactText } from "./output.js";
5
- import { assertCreatedStripeIngressProfile, validateStripeIngressProfile, } from "./stripe-profile.js";
5
+ import { assertCreatedStripeIngressProfile, canonicalLegacyStripeIngressEventTypes, validateStripeIngressProfile, } from "./stripe-profile.js";
6
6
  const claimPollIntervalMs = 1_000;
7
7
  const heartbeatIntervalMs = 30_000;
8
8
  const localForwardTimeoutMs = 30_000;
@@ -70,6 +70,16 @@ export class ProxyWebhooksClient {
70
70
  signal,
71
71
  })).stripe_ingress;
72
72
  }
73
+ async createLegacyStripeIngress(listenerId, webhookSecret, pspConfigId, signal) {
74
+ return (await this.api.request(`/cli/webhook-listeners/${encodeURIComponent(listenerId)}/stripe-ingress`, {
75
+ method: "POST",
76
+ body: {
77
+ ...(pspConfigId ? { psp_config_id: pspConfigId } : {}),
78
+ webhook_secret: webhookSecret,
79
+ },
80
+ signal,
81
+ })).stripe_ingress;
82
+ }
73
83
  async getStripeIngressProfile(listenerId, pspConfigId, signal) {
74
84
  const query = pspConfigId ? `?${new URLSearchParams({ psp_config_id: pspConfigId })}` : "";
75
85
  return (await this.api.request(`/cli/webhook-listeners/${encodeURIComponent(listenerId)}/stripe-ingress-profile${query}`, { signal })).stripe_ingress_profile;
@@ -93,22 +103,47 @@ export async function runListener(input) {
93
103
  if (input.signal.aborted)
94
104
  throw listenerInterrupted();
95
105
  if (input.stripe) {
96
- const stripeProfile = validateStripeIngressProfile(await input.client.getStripeIngressProfile(listener.id, input.pspConfigId, input.signal));
97
- const webhookSecret = await captureStripeWebhookSecret(stripeProfile.event_types, input.signal);
98
- const ingress = await input.client.createStripeIngress(listener.id, webhookSecret, stripeProfile.profile_hash, input.pspConfigId, input.signal);
99
- assertCreatedStripeIngressProfile(stripeProfile, ingress);
100
- stripeProcess = await startStripeListener(ingress.inbound_url, ingress.event_types, input.output, (error) => {
106
+ let stripeProfile;
107
+ try {
108
+ stripeProfile = validateStripeIngressProfile(await input.client.getStripeIngressProfile(listener.id, input.pspConfigId, input.signal));
109
+ }
110
+ catch (error) {
111
+ if (!isMissingStripeIngressProfileRoute(error))
112
+ throw error;
113
+ }
114
+ const eventTypes = stripeProfile
115
+ ? stripeProfile.event_types
116
+ : canonicalLegacyStripeIngressEventTypes();
117
+ const webhookSecret = await captureStripeWebhookSecret(eventTypes, input.signal);
118
+ let ingress;
119
+ if (stripeProfile) {
120
+ const profiledIngress = await input.client.createStripeIngress(listener.id, webhookSecret, stripeProfile.profile_hash, input.pspConfigId, input.signal);
121
+ assertCreatedStripeIngressProfile(stripeProfile, profiledIngress);
122
+ ingress = profiledIngress;
123
+ }
124
+ else {
125
+ ingress = await input.client.createLegacyStripeIngress(listener.id, webhookSecret, input.pspConfigId, input.signal);
126
+ }
127
+ stripeProcess = await startStripeListener(ingress.inbound_url, eventTypes, input.output, (error) => {
101
128
  stripeProcessFailure = stripeListenerStartError(error);
102
129
  });
103
- input.output.event("stripe.started", {
104
- effective_capability_ids: stripeProfile.effective_capability_ids,
105
- event_types: ingress.event_types,
106
- expires_at: ingress.expires_at,
107
- ingress_id: ingress.id,
108
- manifest_version: ingress.manifest_version,
109
- merchant_psp_config_id: ingress.merchant_psp_config_id,
110
- profile_hash: ingress.profile_hash,
111
- }, "Stripe CLI test webhook orchestration is active.");
130
+ input.output.event("stripe.started", stripeProfile
131
+ ? {
132
+ effective_capability_ids: stripeProfile.effective_capability_ids,
133
+ event_types: eventTypes,
134
+ expires_at: ingress.expires_at,
135
+ ingress_id: ingress.id,
136
+ manifest_version: stripeProfile.manifest_version,
137
+ merchant_psp_config_id: ingress.merchant_psp_config_id,
138
+ profile_hash: stripeProfile.profile_hash,
139
+ }
140
+ : {
141
+ compatibility_mode: "legacy_api",
142
+ event_types: eventTypes,
143
+ expires_at: ingress.expires_at,
144
+ ingress_id: ingress.id,
145
+ merchant_psp_config_id: ingress.merchant_psp_config_id,
146
+ }, "Stripe CLI test webhook orchestration is active.");
112
147
  }
113
148
  if (input.signal.aborted)
114
149
  throw listenerInterrupted();
@@ -164,6 +199,9 @@ export async function runListener(input) {
164
199
  }
165
200
  }
166
201
  }
202
+ function isMissingStripeIngressProfileRoute(error) {
203
+ return error instanceof CliError && error.code === "http_404" && error.details?.status === 404;
204
+ }
167
205
  export async function forwardSelectedDelivery(input) {
168
206
  const destination = validateLoopbackDestination(input.forwardTo);
169
207
  const claim = await input.client.claim(input.listenerId, {
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.1-prx-124.137.1",
10
+ "version": "0.1.1-prx-124.139.1",
11
11
  "bin": {
12
12
  "proxy": "./dist/esm/bin.js"
13
13
  },