@proxy-checkout/cli 0.1.0-prx-124.136.1 → 0.1.0
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/README.md +1 -3
- package/dist/cjs/cli.d.cts +1 -1
- package/dist/cjs/cli.d.ts +1 -1
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/webhooks.d.cts +1 -6
- package/dist/cjs/webhooks.d.ts +1 -6
- package/dist/cjs/webhooks.js +18 -20
- package/dist/esm/cli.d.ts +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/webhooks.d.ts +1 -6
- package/dist/esm/webhooks.js +18 -20
- package/package.json +1 -1
- package/dist/cjs/generated/stripe-integration-capabilities-version.d.cts +0 -1
- package/dist/cjs/generated/stripe-integration-capabilities-version.d.ts +0 -1
- package/dist/cjs/generated/stripe-integration-capabilities-version.js +0 -5
- package/dist/cjs/stripe-profile.d.cts +0 -13
- package/dist/cjs/stripe-profile.d.ts +0 -13
- package/dist/cjs/stripe-profile.js +0 -42
- package/dist/esm/generated/stripe-integration-capabilities-version.d.ts +0 -1
- package/dist/esm/generated/stripe-integration-capabilities-version.js +0 -2
- package/dist/esm/stripe-profile.d.ts +0 -13
- package/dist/esm/stripe-profile.js +0 -38
package/README.md
CHANGED
|
@@ -64,9 +64,7 @@ proxy listen \
|
|
|
64
64
|
--forward-to http://127.0.0.1:3000/webhooks
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Structured `stripe.started` output includes the selected configuration, effective capability IDs, exact events, manifest version, non-secret profile hash, ingress ID, and expiry for agent/CI evidence. The Stripe signing secret is captured only in child-process memory, never echoed or placed in argv, and stored only inside Proxy's existing encrypted temporary PSP ingress boundary. The CLI never receives the merchant's Stripe API credential. Both the Stripe ingress and local listener close on exit or expire server-side after a crash.
|
|
67
|
+
The Stripe signing secret is captured only in child-process memory, never echoed or placed in argv, and stored only inside Proxy's existing encrypted temporary PSP ingress boundary. The CLI never receives the merchant's Stripe API credential. Both the Stripe ingress and local listener close on exit or expire server-side after a crash.
|
|
70
68
|
|
|
71
69
|
## Advanced delivery controls
|
|
72
70
|
|
package/dist/cjs/cli.d.cts
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
|
|
3
|
+
export declare const cliVersion = "0.1.0";
|
|
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
|
|
3
|
+
export declare const cliVersion = "0.1.0";
|
|
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
|
|
12
|
+
exports.cliVersion = "0.1.0";
|
|
13
13
|
async function runCli(argv, options = {}) {
|
|
14
14
|
const io = options.io ?? {
|
|
15
15
|
isTTY: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
package/dist/cjs/webhooks.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CliOutput } from "./output.js";
|
|
2
|
-
import { type StripeIngressProfileRecord } from "./stripe-profile.js";
|
|
3
2
|
export interface WebhookEndpointRecord {
|
|
4
3
|
event_schema_version: string;
|
|
5
4
|
event_types: string[] | null;
|
|
@@ -45,16 +44,12 @@ export declare class ProxyWebhooksClient {
|
|
|
45
44
|
errorClass: "network_error" | "timeout" | null;
|
|
46
45
|
responseStatusCode: number | null;
|
|
47
46
|
}): Promise<unknown>;
|
|
48
|
-
createStripeIngress(listenerId: string, webhookSecret: string,
|
|
49
|
-
event_types: string[];
|
|
47
|
+
createStripeIngress(listenerId: string, webhookSecret: string, pspConfigId?: string, signal?: AbortSignal): Promise<{
|
|
50
48
|
expires_at: string;
|
|
51
49
|
id: string;
|
|
52
50
|
inbound_url: string;
|
|
53
|
-
manifest_version: number;
|
|
54
51
|
merchant_psp_config_id: string;
|
|
55
|
-
profile_hash: string;
|
|
56
52
|
}>;
|
|
57
|
-
getStripeIngressProfile(listenerId: string, pspConfigId?: string, signal?: AbortSignal): Promise<StripeIngressProfileRecord>;
|
|
58
53
|
}
|
|
59
54
|
export declare function runListener(input: {
|
|
60
55
|
client: ProxyWebhooksClient;
|
package/dist/cjs/webhooks.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CliOutput } from "./output.js";
|
|
2
|
-
import { type StripeIngressProfileRecord } from "./stripe-profile.js";
|
|
3
2
|
export interface WebhookEndpointRecord {
|
|
4
3
|
event_schema_version: string;
|
|
5
4
|
event_types: string[] | null;
|
|
@@ -45,16 +44,12 @@ export declare class ProxyWebhooksClient {
|
|
|
45
44
|
errorClass: "network_error" | "timeout" | null;
|
|
46
45
|
responseStatusCode: number | null;
|
|
47
46
|
}): Promise<unknown>;
|
|
48
|
-
createStripeIngress(listenerId: string, webhookSecret: string,
|
|
49
|
-
event_types: string[];
|
|
47
|
+
createStripeIngress(listenerId: string, webhookSecret: string, pspConfigId?: string, signal?: AbortSignal): Promise<{
|
|
50
48
|
expires_at: string;
|
|
51
49
|
id: string;
|
|
52
50
|
inbound_url: string;
|
|
53
|
-
manifest_version: number;
|
|
54
51
|
merchant_psp_config_id: string;
|
|
55
|
-
profile_hash: string;
|
|
56
52
|
}>;
|
|
57
|
-
getStripeIngressProfile(listenerId: string, pspConfigId?: string, signal?: AbortSignal): Promise<StripeIngressProfileRecord>;
|
|
58
53
|
}
|
|
59
54
|
export declare function runListener(input: {
|
|
60
55
|
client: ProxyWebhooksClient;
|
package/dist/cjs/webhooks.js
CHANGED
|
@@ -7,10 +7,19 @@ const node_child_process_1 = require("node:child_process");
|
|
|
7
7
|
const errors_js_1 = require("./errors.js");
|
|
8
8
|
const http_client_js_1 = require("./http-client.js");
|
|
9
9
|
const output_js_1 = require("./output.js");
|
|
10
|
-
const stripe_profile_js_1 = require("./stripe-profile.js");
|
|
11
10
|
const claimPollIntervalMs = 1_000;
|
|
12
11
|
const heartbeatIntervalMs = 30_000;
|
|
13
12
|
const localForwardTimeoutMs = 30_000;
|
|
13
|
+
const stripeEvents = [
|
|
14
|
+
"checkout.session.completed",
|
|
15
|
+
"customer.subscription.deleted",
|
|
16
|
+
"customer.subscription.updated",
|
|
17
|
+
"invoice.paid",
|
|
18
|
+
"invoice.payment_failed",
|
|
19
|
+
"payment_intent.canceled",
|
|
20
|
+
"payment_intent.payment_failed",
|
|
21
|
+
"payment_intent.succeeded",
|
|
22
|
+
].join(",");
|
|
14
23
|
class ProxyWebhooksClient {
|
|
15
24
|
api;
|
|
16
25
|
constructor(apiBaseUrl, token, fetchImpl) {
|
|
@@ -64,21 +73,16 @@ class ProxyWebhooksClient {
|
|
|
64
73
|
},
|
|
65
74
|
});
|
|
66
75
|
}
|
|
67
|
-
async createStripeIngress(listenerId, webhookSecret,
|
|
76
|
+
async createStripeIngress(listenerId, webhookSecret, pspConfigId, signal) {
|
|
68
77
|
return (await this.api.request(`/cli/webhook-listeners/${encodeURIComponent(listenerId)}/stripe-ingress`, {
|
|
69
78
|
method: "POST",
|
|
70
79
|
body: {
|
|
71
80
|
...(pspConfigId ? { psp_config_id: pspConfigId } : {}),
|
|
72
|
-
profile_hash: profileHash,
|
|
73
81
|
webhook_secret: webhookSecret,
|
|
74
82
|
},
|
|
75
83
|
signal,
|
|
76
84
|
})).stripe_ingress;
|
|
77
85
|
}
|
|
78
|
-
async getStripeIngressProfile(listenerId, pspConfigId, signal) {
|
|
79
|
-
const query = pspConfigId ? `?${new URLSearchParams({ psp_config_id: pspConfigId })}` : "";
|
|
80
|
-
return (await this.api.request(`/cli/webhook-listeners/${encodeURIComponent(listenerId)}/stripe-ingress-profile${query}`, { signal })).stripe_ingress_profile;
|
|
81
|
-
}
|
|
82
86
|
}
|
|
83
87
|
exports.ProxyWebhooksClient = ProxyWebhooksClient;
|
|
84
88
|
async function runListener(input) {
|
|
@@ -99,21 +103,15 @@ async function runListener(input) {
|
|
|
99
103
|
if (input.signal.aborted)
|
|
100
104
|
throw listenerInterrupted();
|
|
101
105
|
if (input.stripe) {
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
(0, stripe_profile_js_1.assertCreatedStripeIngressProfile)(stripeProfile, ingress);
|
|
106
|
-
stripeProcess = await startStripeListener(ingress.inbound_url, ingress.event_types, input.output, (error) => {
|
|
106
|
+
const webhookSecret = await captureStripeWebhookSecret(input.signal);
|
|
107
|
+
const ingress = await input.client.createStripeIngress(listener.id, webhookSecret, input.pspConfigId, input.signal);
|
|
108
|
+
stripeProcess = await startStripeListener(ingress.inbound_url, input.output, (error) => {
|
|
107
109
|
stripeProcessFailure = stripeListenerStartError(error);
|
|
108
110
|
});
|
|
109
111
|
input.output.event("stripe.started", {
|
|
110
|
-
effective_capability_ids: stripeProfile.effective_capability_ids,
|
|
111
|
-
event_types: ingress.event_types,
|
|
112
112
|
expires_at: ingress.expires_at,
|
|
113
113
|
ingress_id: ingress.id,
|
|
114
|
-
manifest_version: ingress.manifest_version,
|
|
115
114
|
merchant_psp_config_id: ingress.merchant_psp_config_id,
|
|
116
|
-
profile_hash: ingress.profile_hash,
|
|
117
115
|
}, "Stripe CLI test webhook orchestration is active.");
|
|
118
116
|
}
|
|
119
117
|
if (input.signal.aborted)
|
|
@@ -218,8 +216,8 @@ async function forwardClaim(client, claim, destination, signal) {
|
|
|
218
216
|
responseStatusCode,
|
|
219
217
|
});
|
|
220
218
|
}
|
|
221
|
-
async function captureStripeWebhookSecret(
|
|
222
|
-
const result = await captureProcess("stripe", ["listen", "--events",
|
|
219
|
+
async function captureStripeWebhookSecret(signal) {
|
|
220
|
+
const result = await captureProcess("stripe", ["listen", "--events", stripeEvents, "--print-secret"], signal, 30_000);
|
|
223
221
|
if (signal.aborted)
|
|
224
222
|
throw listenerInterrupted();
|
|
225
223
|
const match = `${result.stdout}\n${result.stderr}`.match(/\bwhsec_[A-Za-z0-9_-]{8,512}\b/);
|
|
@@ -231,8 +229,8 @@ async function captureStripeWebhookSecret(eventTypes, signal) {
|
|
|
231
229
|
function listenerInterrupted() {
|
|
232
230
|
return new errors_js_1.CliError("Local webhook listener interrupted", "cli_listener_interrupted", errors_js_1.cliExitCodes.interrupted);
|
|
233
231
|
}
|
|
234
|
-
function startStripeListener(inboundUrl,
|
|
235
|
-
const child = (0, node_child_process_1.spawn)("stripe", ["listen", "--events",
|
|
232
|
+
function startStripeListener(inboundUrl, output, onError) {
|
|
233
|
+
const child = (0, node_child_process_1.spawn)("stripe", ["listen", "--events", stripeEvents, "--forward-to", inboundUrl], {
|
|
236
234
|
shell: false,
|
|
237
235
|
stdio: ["pipe", "pipe", "pipe"],
|
|
238
236
|
});
|
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
|
|
3
|
+
export declare const cliVersion = "0.1.0";
|
|
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
|
|
8
|
+
export const cliVersion = "0.1.0";
|
|
9
9
|
export async function runCli(argv, options = {}) {
|
|
10
10
|
const io = options.io ?? {
|
|
11
11
|
isTTY: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
package/dist/esm/webhooks.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CliOutput } from "./output.js";
|
|
2
|
-
import { type StripeIngressProfileRecord } from "./stripe-profile.js";
|
|
3
2
|
export interface WebhookEndpointRecord {
|
|
4
3
|
event_schema_version: string;
|
|
5
4
|
event_types: string[] | null;
|
|
@@ -45,16 +44,12 @@ export declare class ProxyWebhooksClient {
|
|
|
45
44
|
errorClass: "network_error" | "timeout" | null;
|
|
46
45
|
responseStatusCode: number | null;
|
|
47
46
|
}): Promise<unknown>;
|
|
48
|
-
createStripeIngress(listenerId: string, webhookSecret: string,
|
|
49
|
-
event_types: string[];
|
|
47
|
+
createStripeIngress(listenerId: string, webhookSecret: string, pspConfigId?: string, signal?: AbortSignal): Promise<{
|
|
50
48
|
expires_at: string;
|
|
51
49
|
id: string;
|
|
52
50
|
inbound_url: string;
|
|
53
|
-
manifest_version: number;
|
|
54
51
|
merchant_psp_config_id: string;
|
|
55
|
-
profile_hash: string;
|
|
56
52
|
}>;
|
|
57
|
-
getStripeIngressProfile(listenerId: string, pspConfigId?: string, signal?: AbortSignal): Promise<StripeIngressProfileRecord>;
|
|
58
53
|
}
|
|
59
54
|
export declare function runListener(input: {
|
|
60
55
|
client: ProxyWebhooksClient;
|
package/dist/esm/webhooks.js
CHANGED
|
@@ -2,10 +2,19 @@ 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";
|
|
6
5
|
const claimPollIntervalMs = 1_000;
|
|
7
6
|
const heartbeatIntervalMs = 30_000;
|
|
8
7
|
const localForwardTimeoutMs = 30_000;
|
|
8
|
+
const stripeEvents = [
|
|
9
|
+
"checkout.session.completed",
|
|
10
|
+
"customer.subscription.deleted",
|
|
11
|
+
"customer.subscription.updated",
|
|
12
|
+
"invoice.paid",
|
|
13
|
+
"invoice.payment_failed",
|
|
14
|
+
"payment_intent.canceled",
|
|
15
|
+
"payment_intent.payment_failed",
|
|
16
|
+
"payment_intent.succeeded",
|
|
17
|
+
].join(",");
|
|
9
18
|
export class ProxyWebhooksClient {
|
|
10
19
|
api;
|
|
11
20
|
constructor(apiBaseUrl, token, fetchImpl) {
|
|
@@ -59,21 +68,16 @@ export class ProxyWebhooksClient {
|
|
|
59
68
|
},
|
|
60
69
|
});
|
|
61
70
|
}
|
|
62
|
-
async createStripeIngress(listenerId, webhookSecret,
|
|
71
|
+
async createStripeIngress(listenerId, webhookSecret, pspConfigId, signal) {
|
|
63
72
|
return (await this.api.request(`/cli/webhook-listeners/${encodeURIComponent(listenerId)}/stripe-ingress`, {
|
|
64
73
|
method: "POST",
|
|
65
74
|
body: {
|
|
66
75
|
...(pspConfigId ? { psp_config_id: pspConfigId } : {}),
|
|
67
|
-
profile_hash: profileHash,
|
|
68
76
|
webhook_secret: webhookSecret,
|
|
69
77
|
},
|
|
70
78
|
signal,
|
|
71
79
|
})).stripe_ingress;
|
|
72
80
|
}
|
|
73
|
-
async getStripeIngressProfile(listenerId, pspConfigId, signal) {
|
|
74
|
-
const query = pspConfigId ? `?${new URLSearchParams({ psp_config_id: pspConfigId })}` : "";
|
|
75
|
-
return (await this.api.request(`/cli/webhook-listeners/${encodeURIComponent(listenerId)}/stripe-ingress-profile${query}`, { signal })).stripe_ingress_profile;
|
|
76
|
-
}
|
|
77
81
|
}
|
|
78
82
|
export async function runListener(input) {
|
|
79
83
|
const destination = validateLoopbackDestination(input.forwardTo);
|
|
@@ -93,21 +97,15 @@ export async function runListener(input) {
|
|
|
93
97
|
if (input.signal.aborted)
|
|
94
98
|
throw listenerInterrupted();
|
|
95
99
|
if (input.stripe) {
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
assertCreatedStripeIngressProfile(stripeProfile, ingress);
|
|
100
|
-
stripeProcess = await startStripeListener(ingress.inbound_url, ingress.event_types, input.output, (error) => {
|
|
100
|
+
const webhookSecret = await captureStripeWebhookSecret(input.signal);
|
|
101
|
+
const ingress = await input.client.createStripeIngress(listener.id, webhookSecret, input.pspConfigId, input.signal);
|
|
102
|
+
stripeProcess = await startStripeListener(ingress.inbound_url, input.output, (error) => {
|
|
101
103
|
stripeProcessFailure = stripeListenerStartError(error);
|
|
102
104
|
});
|
|
103
105
|
input.output.event("stripe.started", {
|
|
104
|
-
effective_capability_ids: stripeProfile.effective_capability_ids,
|
|
105
|
-
event_types: ingress.event_types,
|
|
106
106
|
expires_at: ingress.expires_at,
|
|
107
107
|
ingress_id: ingress.id,
|
|
108
|
-
manifest_version: ingress.manifest_version,
|
|
109
108
|
merchant_psp_config_id: ingress.merchant_psp_config_id,
|
|
110
|
-
profile_hash: ingress.profile_hash,
|
|
111
109
|
}, "Stripe CLI test webhook orchestration is active.");
|
|
112
110
|
}
|
|
113
111
|
if (input.signal.aborted)
|
|
@@ -212,8 +210,8 @@ async function forwardClaim(client, claim, destination, signal) {
|
|
|
212
210
|
responseStatusCode,
|
|
213
211
|
});
|
|
214
212
|
}
|
|
215
|
-
async function captureStripeWebhookSecret(
|
|
216
|
-
const result = await captureProcess("stripe", ["listen", "--events",
|
|
213
|
+
async function captureStripeWebhookSecret(signal) {
|
|
214
|
+
const result = await captureProcess("stripe", ["listen", "--events", stripeEvents, "--print-secret"], signal, 30_000);
|
|
217
215
|
if (signal.aborted)
|
|
218
216
|
throw listenerInterrupted();
|
|
219
217
|
const match = `${result.stdout}\n${result.stderr}`.match(/\bwhsec_[A-Za-z0-9_-]{8,512}\b/);
|
|
@@ -225,8 +223,8 @@ async function captureStripeWebhookSecret(eventTypes, signal) {
|
|
|
225
223
|
function listenerInterrupted() {
|
|
226
224
|
return new CliError("Local webhook listener interrupted", "cli_listener_interrupted", cliExitCodes.interrupted);
|
|
227
225
|
}
|
|
228
|
-
function startStripeListener(inboundUrl,
|
|
229
|
-
const child = spawn("stripe", ["listen", "--events",
|
|
226
|
+
function startStripeListener(inboundUrl, output, onError) {
|
|
227
|
+
const child = spawn("stripe", ["listen", "--events", stripeEvents, "--forward-to", inboundUrl], {
|
|
230
228
|
shell: false,
|
|
231
229
|
stdio: ["pipe", "pipe", "pipe"],
|
|
232
230
|
});
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stripeIntegrationCapabilitiesManifestVersion: 2;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stripeIntegrationCapabilitiesManifestVersion: 2;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stripeIntegrationCapabilitiesManifestVersion = void 0;
|
|
4
|
-
// Generated by tools/compliance/sync-stripe-integration-capabilities.mjs.
|
|
5
|
-
exports.stripeIntegrationCapabilitiesManifestVersion = 2;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface StripeIngressProfileRecord {
|
|
2
|
-
effective_capability_ids: string[];
|
|
3
|
-
event_types: string[];
|
|
4
|
-
manifest_version: number;
|
|
5
|
-
merchant_psp_config_id: string;
|
|
6
|
-
profile_hash: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function validateStripeIngressProfile(profile: StripeIngressProfileRecord): StripeIngressProfileRecord;
|
|
9
|
-
export declare function assertCreatedStripeIngressProfile(expected: StripeIngressProfileRecord, actual: {
|
|
10
|
-
event_types: string[];
|
|
11
|
-
manifest_version: number;
|
|
12
|
-
profile_hash: string;
|
|
13
|
-
}): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface StripeIngressProfileRecord {
|
|
2
|
-
effective_capability_ids: string[];
|
|
3
|
-
event_types: string[];
|
|
4
|
-
manifest_version: number;
|
|
5
|
-
merchant_psp_config_id: string;
|
|
6
|
-
profile_hash: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function validateStripeIngressProfile(profile: StripeIngressProfileRecord): StripeIngressProfileRecord;
|
|
9
|
-
export declare function assertCreatedStripeIngressProfile(expected: StripeIngressProfileRecord, actual: {
|
|
10
|
-
event_types: string[];
|
|
11
|
-
manifest_version: number;
|
|
12
|
-
profile_hash: string;
|
|
13
|
-
}): void;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateStripeIngressProfile = validateStripeIngressProfile;
|
|
4
|
-
exports.assertCreatedStripeIngressProfile = assertCreatedStripeIngressProfile;
|
|
5
|
-
const errors_js_1 = require("./errors.js");
|
|
6
|
-
const stripe_integration_capabilities_version_js_1 = require("./generated/stripe-integration-capabilities-version.js");
|
|
7
|
-
const stripeEventPattern = /^[a-z0-9_]+(?:\.[a-z0-9_]+)+$/;
|
|
8
|
-
const capabilityPattern = /^[a-z0-9_]+(?:\.[a-z0-9_]+)+$/;
|
|
9
|
-
const sha256Pattern = /^[0-9a-f]{64}$/;
|
|
10
|
-
const maximumEntries = 100;
|
|
11
|
-
function validateStripeIngressProfile(profile) {
|
|
12
|
-
if (profile.manifest_version !== stripe_integration_capabilities_version_js_1.stripeIntegrationCapabilitiesManifestVersion) {
|
|
13
|
-
throw profileError("Stripe ingress profile uses an incompatible manifest version");
|
|
14
|
-
}
|
|
15
|
-
if (!profile.merchant_psp_config_id.startsWith("pspcfg_") ||
|
|
16
|
-
!sha256Pattern.test(profile.profile_hash)) {
|
|
17
|
-
throw profileError("Stripe ingress profile identity is invalid");
|
|
18
|
-
}
|
|
19
|
-
assertSortedUnique(profile.event_types, stripeEventPattern, false, "event types");
|
|
20
|
-
assertSortedUnique(profile.effective_capability_ids, capabilityPattern, true, "capability ids");
|
|
21
|
-
return profile;
|
|
22
|
-
}
|
|
23
|
-
function assertCreatedStripeIngressProfile(expected, actual) {
|
|
24
|
-
assertSortedUnique(actual.event_types, stripeEventPattern, false, "event types");
|
|
25
|
-
if (actual.manifest_version !== expected.manifest_version ||
|
|
26
|
-
actual.profile_hash !== expected.profile_hash ||
|
|
27
|
-
JSON.stringify(actual.event_types) !== JSON.stringify(expected.event_types)) {
|
|
28
|
-
throw profileError("Stripe ingress profile changed while the listener was starting");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function assertSortedUnique(values, pattern, allowEmpty, label) {
|
|
32
|
-
if (!Array.isArray(values) ||
|
|
33
|
-
(!allowEmpty && values.length === 0) ||
|
|
34
|
-
values.length > maximumEntries ||
|
|
35
|
-
values.some((value) => !pattern.test(value)) ||
|
|
36
|
-
values.some((value, index) => index > 0 && values[index - 1] >= value)) {
|
|
37
|
-
throw profileError(`Stripe ingress profile ${label} are invalid`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function profileError(message) {
|
|
41
|
-
return new errors_js_1.CliError(message, "stripe_ingress_profile_unsupported", errors_js_1.cliExitCodes.dependency);
|
|
42
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stripeIntegrationCapabilitiesManifestVersion: 2;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface StripeIngressProfileRecord {
|
|
2
|
-
effective_capability_ids: string[];
|
|
3
|
-
event_types: string[];
|
|
4
|
-
manifest_version: number;
|
|
5
|
-
merchant_psp_config_id: string;
|
|
6
|
-
profile_hash: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function validateStripeIngressProfile(profile: StripeIngressProfileRecord): StripeIngressProfileRecord;
|
|
9
|
-
export declare function assertCreatedStripeIngressProfile(expected: StripeIngressProfileRecord, actual: {
|
|
10
|
-
event_types: string[];
|
|
11
|
-
manifest_version: number;
|
|
12
|
-
profile_hash: string;
|
|
13
|
-
}): void;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { CliError, cliExitCodes } from "./errors.js";
|
|
2
|
-
import { stripeIntegrationCapabilitiesManifestVersion } from "./generated/stripe-integration-capabilities-version.js";
|
|
3
|
-
const stripeEventPattern = /^[a-z0-9_]+(?:\.[a-z0-9_]+)+$/;
|
|
4
|
-
const capabilityPattern = /^[a-z0-9_]+(?:\.[a-z0-9_]+)+$/;
|
|
5
|
-
const sha256Pattern = /^[0-9a-f]{64}$/;
|
|
6
|
-
const maximumEntries = 100;
|
|
7
|
-
export function validateStripeIngressProfile(profile) {
|
|
8
|
-
if (profile.manifest_version !== stripeIntegrationCapabilitiesManifestVersion) {
|
|
9
|
-
throw profileError("Stripe ingress profile uses an incompatible manifest version");
|
|
10
|
-
}
|
|
11
|
-
if (!profile.merchant_psp_config_id.startsWith("pspcfg_") ||
|
|
12
|
-
!sha256Pattern.test(profile.profile_hash)) {
|
|
13
|
-
throw profileError("Stripe ingress profile identity is invalid");
|
|
14
|
-
}
|
|
15
|
-
assertSortedUnique(profile.event_types, stripeEventPattern, false, "event types");
|
|
16
|
-
assertSortedUnique(profile.effective_capability_ids, capabilityPattern, true, "capability ids");
|
|
17
|
-
return profile;
|
|
18
|
-
}
|
|
19
|
-
export function assertCreatedStripeIngressProfile(expected, actual) {
|
|
20
|
-
assertSortedUnique(actual.event_types, stripeEventPattern, false, "event types");
|
|
21
|
-
if (actual.manifest_version !== expected.manifest_version ||
|
|
22
|
-
actual.profile_hash !== expected.profile_hash ||
|
|
23
|
-
JSON.stringify(actual.event_types) !== JSON.stringify(expected.event_types)) {
|
|
24
|
-
throw profileError("Stripe ingress profile changed while the listener was starting");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function assertSortedUnique(values, pattern, allowEmpty, label) {
|
|
28
|
-
if (!Array.isArray(values) ||
|
|
29
|
-
(!allowEmpty && values.length === 0) ||
|
|
30
|
-
values.length > maximumEntries ||
|
|
31
|
-
values.some((value) => !pattern.test(value)) ||
|
|
32
|
-
values.some((value, index) => index > 0 && values[index - 1] >= value)) {
|
|
33
|
-
throw profileError(`Stripe ingress profile ${label} are invalid`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function profileError(message) {
|
|
37
|
-
return new CliError(message, "stripe_ingress_profile_unsupported", cliExitCodes.dependency);
|
|
38
|
-
}
|