@proxy-checkout/cli 0.1.1-prx-146.161.1 → 0.1.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/README.md +0 -13
- package/dist/cjs/cli.d.cts +1 -1
- package/dist/cjs/cli.d.ts +1 -1
- package/dist/cjs/cli.js +2 -12
- package/dist/cjs/command-schema.js +1 -15
- package/dist/cjs/generated/stripe-integration-capabilities-version.d.cts +0 -564
- package/dist/cjs/generated/stripe-integration-capabilities-version.d.ts +0 -564
- package/dist/cjs/generated/stripe-integration-capabilities-version.js +1 -1148
- package/dist/cjs/index.d.cts +0 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +1 -5
- package/dist/esm/cli.d.ts +1 -1
- package/dist/esm/cli.js +2 -12
- package/dist/esm/command-schema.js +1 -15
- package/dist/esm/generated/stripe-integration-capabilities-version.d.ts +0 -564
- package/dist/esm/generated/stripe-integration-capabilities-version.js +0 -1147
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -1
- package/package.json +1 -1
- package/dist/cjs/stripe-doctor.d.cts +0 -58
- package/dist/cjs/stripe-doctor.d.ts +0 -58
- package/dist/cjs/stripe-doctor.js +0 -164
- package/dist/esm/stripe-doctor.d.ts +0 -58
- package/dist/esm/stripe-doctor.js +0 -159
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,5 +2,4 @@ export { cliVersion, type RunCliOptions, runCli } from "./cli.js";
|
|
|
2
2
|
export { type CommandOptionSchema, type CommandSchema, commandSchemaDocument, commandSchemas, findCommandSchema, llmsFullDocument, } from "./command-schema.js";
|
|
3
3
|
export { CliConfigStore, type CliProfile, type ResolvedCredential } from "./config.js";
|
|
4
4
|
export { CliError, type CliExitCode, cliExitCodes } from "./errors.js";
|
|
5
|
-
export { formatStripeDoctorReport, type StripeDoctorReport, stripeDoctorPathIds, stripeDoctorReport, } from "./stripe-doctor.js";
|
|
6
5
|
export declare const packageName = "@proxy-checkout/cli";
|
package/dist/esm/index.js
CHANGED
|
@@ -2,5 +2,4 @@ export { cliVersion, runCli } from "./cli.js";
|
|
|
2
2
|
export { commandSchemaDocument, commandSchemas, findCommandSchema, llmsFullDocument, } from "./command-schema.js";
|
|
3
3
|
export { CliConfigStore } from "./config.js";
|
|
4
4
|
export { CliError, cliExitCodes } from "./errors.js";
|
|
5
|
-
export { formatStripeDoctorReport, stripeDoctorPathIds, stripeDoctorReport, } from "./stripe-doctor.js";
|
|
6
5
|
export const packageName = "@proxy-checkout/cli";
|
package/package.json
CHANGED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export interface StripeDoctorReport {
|
|
2
|
-
capability_ids: string[];
|
|
3
|
-
capability_manifest_version: 2;
|
|
4
|
-
commercial_mode: string;
|
|
5
|
-
helper: string;
|
|
6
|
-
integration_path: string;
|
|
7
|
-
local_stripe_cli_event_profiles: StripeDoctorEventProfile[];
|
|
8
|
-
money_object_creation: {
|
|
9
|
-
merchant_create_credential: "merchant_backend_only";
|
|
10
|
-
proxy_creates_stripe_money_objects: false;
|
|
11
|
-
proxy_stores_merchant_create_credential: false;
|
|
12
|
-
};
|
|
13
|
-
path_id: string;
|
|
14
|
-
presentation: string | null;
|
|
15
|
-
pricing_modes: string[];
|
|
16
|
-
proxy_merchant_event_types: string[];
|
|
17
|
-
public_documentation_anchor: string;
|
|
18
|
-
readiness: {
|
|
19
|
-
reasons: string[];
|
|
20
|
-
status: "action_required" | "disabled" | "eligible";
|
|
21
|
-
};
|
|
22
|
-
restricted_key: {
|
|
23
|
-
credential_owner: "proxy";
|
|
24
|
-
operations: Array<{
|
|
25
|
-
id: string;
|
|
26
|
-
method: "GET";
|
|
27
|
-
path: string;
|
|
28
|
-
permission: {
|
|
29
|
-
access: "Read";
|
|
30
|
-
resource: string;
|
|
31
|
-
};
|
|
32
|
-
setup_probe: boolean;
|
|
33
|
-
}>;
|
|
34
|
-
permissions: string[];
|
|
35
|
-
purpose: "read_only_reconciliation_and_endpoint_verification";
|
|
36
|
-
};
|
|
37
|
-
unsupported_options: string[];
|
|
38
|
-
validation_command: string;
|
|
39
|
-
versions: {
|
|
40
|
-
browser_sdk: string | null;
|
|
41
|
-
proof_status: string;
|
|
42
|
-
react_sdk: string | null;
|
|
43
|
-
request_api: string;
|
|
44
|
-
server_sdk: string;
|
|
45
|
-
};
|
|
46
|
-
webhook_event_profiles: StripeDoctorEventProfile[];
|
|
47
|
-
}
|
|
48
|
-
interface StripeDoctorEventProfile {
|
|
49
|
-
id: string;
|
|
50
|
-
maximum_api_version: string | null;
|
|
51
|
-
minimum_api_version: string;
|
|
52
|
-
optional_event_types: string[];
|
|
53
|
-
required_event_types: string[];
|
|
54
|
-
}
|
|
55
|
-
export declare function stripeDoctorPathIds(): string[];
|
|
56
|
-
export declare function stripeDoctorReport(pathId: string): StripeDoctorReport | undefined;
|
|
57
|
-
export declare function formatStripeDoctorReport(report: StripeDoctorReport): string;
|
|
58
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export interface StripeDoctorReport {
|
|
2
|
-
capability_ids: string[];
|
|
3
|
-
capability_manifest_version: 2;
|
|
4
|
-
commercial_mode: string;
|
|
5
|
-
helper: string;
|
|
6
|
-
integration_path: string;
|
|
7
|
-
local_stripe_cli_event_profiles: StripeDoctorEventProfile[];
|
|
8
|
-
money_object_creation: {
|
|
9
|
-
merchant_create_credential: "merchant_backend_only";
|
|
10
|
-
proxy_creates_stripe_money_objects: false;
|
|
11
|
-
proxy_stores_merchant_create_credential: false;
|
|
12
|
-
};
|
|
13
|
-
path_id: string;
|
|
14
|
-
presentation: string | null;
|
|
15
|
-
pricing_modes: string[];
|
|
16
|
-
proxy_merchant_event_types: string[];
|
|
17
|
-
public_documentation_anchor: string;
|
|
18
|
-
readiness: {
|
|
19
|
-
reasons: string[];
|
|
20
|
-
status: "action_required" | "disabled" | "eligible";
|
|
21
|
-
};
|
|
22
|
-
restricted_key: {
|
|
23
|
-
credential_owner: "proxy";
|
|
24
|
-
operations: Array<{
|
|
25
|
-
id: string;
|
|
26
|
-
method: "GET";
|
|
27
|
-
path: string;
|
|
28
|
-
permission: {
|
|
29
|
-
access: "Read";
|
|
30
|
-
resource: string;
|
|
31
|
-
};
|
|
32
|
-
setup_probe: boolean;
|
|
33
|
-
}>;
|
|
34
|
-
permissions: string[];
|
|
35
|
-
purpose: "read_only_reconciliation_and_endpoint_verification";
|
|
36
|
-
};
|
|
37
|
-
unsupported_options: string[];
|
|
38
|
-
validation_command: string;
|
|
39
|
-
versions: {
|
|
40
|
-
browser_sdk: string | null;
|
|
41
|
-
proof_status: string;
|
|
42
|
-
react_sdk: string | null;
|
|
43
|
-
request_api: string;
|
|
44
|
-
server_sdk: string;
|
|
45
|
-
};
|
|
46
|
-
webhook_event_profiles: StripeDoctorEventProfile[];
|
|
47
|
-
}
|
|
48
|
-
interface StripeDoctorEventProfile {
|
|
49
|
-
id: string;
|
|
50
|
-
maximum_api_version: string | null;
|
|
51
|
-
minimum_api_version: string;
|
|
52
|
-
optional_event_types: string[];
|
|
53
|
-
required_event_types: string[];
|
|
54
|
-
}
|
|
55
|
-
export declare function stripeDoctorPathIds(): string[];
|
|
56
|
-
export declare function stripeDoctorReport(pathId: string): StripeDoctorReport | undefined;
|
|
57
|
-
export declare function formatStripeDoctorReport(report: StripeDoctorReport): string;
|
|
58
|
-
export {};
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stripeDoctorPathIds = stripeDoctorPathIds;
|
|
4
|
-
exports.stripeDoctorReport = stripeDoctorReport;
|
|
5
|
-
exports.formatStripeDoctorReport = formatStripeDoctorReport;
|
|
6
|
-
const stripe_integration_capabilities_version_js_1 = require("./generated/stripe-integration-capabilities-version.js");
|
|
7
|
-
const manifest = stripe_integration_capabilities_version_js_1.stripeIntegrationCapabilitiesManifest;
|
|
8
|
-
const capabilities = manifest.capabilities;
|
|
9
|
-
const capabilityById = new Map(capabilities.map((capability) => [capability.id, capability]));
|
|
10
|
-
function stripeDoctorPathIds() {
|
|
11
|
-
return capabilities.flatMap((capability) => capability.path_id === null ? [] : [capability.path_id]);
|
|
12
|
-
}
|
|
13
|
-
function stripeDoctorReport(pathId) {
|
|
14
|
-
const capability = capabilities.find(({ path_id }) => path_id === pathId);
|
|
15
|
-
if (!capability || capability.path_id === null)
|
|
16
|
-
return undefined;
|
|
17
|
-
const capabilityIds = resolveCapabilityClosure(capability.id);
|
|
18
|
-
const operationIds = new Set(capabilityIds.flatMap((capabilityId) => {
|
|
19
|
-
const item = requireCapability(capabilityId);
|
|
20
|
-
return [...item.reconciliation_operation_ids, ...item.setup_probe_operation_ids];
|
|
21
|
-
}));
|
|
22
|
-
const operations = manifest.operation_catalog
|
|
23
|
-
.filter(({ id }) => operationIds.has(id))
|
|
24
|
-
.map((operation) => ({
|
|
25
|
-
id: operation.id,
|
|
26
|
-
method: operation.method,
|
|
27
|
-
path: operation.path,
|
|
28
|
-
permission: operation.permission,
|
|
29
|
-
setup_probe: "setup_probe" in operation && operation.setup_probe === true,
|
|
30
|
-
}))
|
|
31
|
-
.sort((left, right) => left.id.localeCompare(right.id));
|
|
32
|
-
const webhookEventGroupIds = new Set(capabilityIds.flatMap((capabilityId) => requireCapability(capabilityId).webhook_event_group_ids));
|
|
33
|
-
const localEventGroupIds = new Set(capabilityIds.flatMap((capabilityId) => requireCapability(capabilityId).local_stripe_cli_event_groups));
|
|
34
|
-
const eventProfilesFor = (eventGroupIds) => manifest.webhook_event_profiles.map((profile) => {
|
|
35
|
-
const groups = profile.event_groups;
|
|
36
|
-
const required = new Set();
|
|
37
|
-
const optional = new Set();
|
|
38
|
-
for (const groupId of eventGroupIds) {
|
|
39
|
-
const group = groups[groupId];
|
|
40
|
-
if (!group)
|
|
41
|
-
throw new Error(`Stripe webhook profile ${profile.id} is missing ${groupId}`);
|
|
42
|
-
for (const eventType of group.required_event_types)
|
|
43
|
-
required.add(eventType);
|
|
44
|
-
for (const eventType of group.optional_event_types ?? [])
|
|
45
|
-
optional.add(eventType);
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
id: profile.id,
|
|
49
|
-
maximum_api_version: profile.maximum_api_version,
|
|
50
|
-
minimum_api_version: profile.minimum_api_version,
|
|
51
|
-
optional_event_types: [...optional].sort(),
|
|
52
|
-
required_event_types: [...required].sort(),
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
const proxyMerchantEventTypes = [
|
|
56
|
-
...new Set(capabilityIds.flatMap((capabilityId) => requireCapability(capabilityId).proxy_merchant_event_types)),
|
|
57
|
-
].sort();
|
|
58
|
-
return {
|
|
59
|
-
capability_ids: capabilityIds,
|
|
60
|
-
capability_manifest_version: manifest.manifest_version,
|
|
61
|
-
commercial_mode: capability.commercial_mode,
|
|
62
|
-
helper: helperFor(capability),
|
|
63
|
-
integration_path: capability.integration_path,
|
|
64
|
-
local_stripe_cli_event_profiles: eventProfilesFor(localEventGroupIds),
|
|
65
|
-
path_id: capability.path_id,
|
|
66
|
-
presentation: capability.checkout_ui_mode,
|
|
67
|
-
pricing_modes: [...capability.pricing_modes],
|
|
68
|
-
proxy_merchant_event_types: proxyMerchantEventTypes,
|
|
69
|
-
public_documentation_anchor: capability.public_documentation_anchor,
|
|
70
|
-
readiness: readinessFor(capability.availability),
|
|
71
|
-
unsupported_options: [...capability.unsupported_options],
|
|
72
|
-
validation_command: `proxy stripe doctor --path ${capability.path_id}`,
|
|
73
|
-
webhook_event_profiles: eventProfilesFor(webhookEventGroupIds),
|
|
74
|
-
money_object_creation: {
|
|
75
|
-
merchant_create_credential: "merchant_backend_only",
|
|
76
|
-
proxy_creates_stripe_money_objects: false,
|
|
77
|
-
proxy_stores_merchant_create_credential: false,
|
|
78
|
-
},
|
|
79
|
-
restricted_key: {
|
|
80
|
-
credential_owner: "proxy",
|
|
81
|
-
operations,
|
|
82
|
-
permissions: [
|
|
83
|
-
...new Set(operations.map(({ permission }) => `${permission.resource}: ${permission.access}`)),
|
|
84
|
-
].sort(),
|
|
85
|
-
purpose: "read_only_reconciliation_and_endpoint_verification",
|
|
86
|
-
},
|
|
87
|
-
versions: {
|
|
88
|
-
browser_sdk: capability.minimum_versions.browser_sdk,
|
|
89
|
-
proof_status: capability.minimum_versions.status,
|
|
90
|
-
react_sdk: capability.minimum_versions.react_sdk,
|
|
91
|
-
request_api: capability.minimum_versions.request_api,
|
|
92
|
-
server_sdk: capability.minimum_versions.server_sdk,
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function formatStripeDoctorReport(report) {
|
|
97
|
-
return [
|
|
98
|
-
`${report.path_id} (${report.capability_ids.at(-1) ?? report.integration_path}) — ${report.readiness.status}`,
|
|
99
|
-
`Helper: ${report.helper}`,
|
|
100
|
-
`Versions: stripe-node ${report.versions.server_sdk}; API ${report.versions.request_api}; stripe-js ${report.versions.browser_sdk ?? "not required"}; react-stripe-js ${report.versions.react_sdk ?? "not required"}`,
|
|
101
|
-
`Proxy restricted key: ${report.restricted_key.permissions.join(", ")}`,
|
|
102
|
-
`Merchant create credential: ${report.money_object_creation.merchant_create_credential}; never sent to Proxy`,
|
|
103
|
-
`Next: ${report.readiness.reasons.join(", ") || "merchant configuration verification"}`,
|
|
104
|
-
].join("\n");
|
|
105
|
-
}
|
|
106
|
-
function resolveCapabilityClosure(capabilityId) {
|
|
107
|
-
const resolved = new Set();
|
|
108
|
-
const active = new Set();
|
|
109
|
-
const visit = (id) => {
|
|
110
|
-
if (resolved.has(id))
|
|
111
|
-
return;
|
|
112
|
-
if (active.has(id))
|
|
113
|
-
throw new Error(`Stripe capability dependency cycle includes ${id}`);
|
|
114
|
-
active.add(id);
|
|
115
|
-
const capability = requireCapability(id);
|
|
116
|
-
for (const dependency of capability.dependencies)
|
|
117
|
-
visit(dependency);
|
|
118
|
-
active.delete(id);
|
|
119
|
-
resolved.add(id);
|
|
120
|
-
};
|
|
121
|
-
visit(capabilityId);
|
|
122
|
-
return [...resolved].sort();
|
|
123
|
-
}
|
|
124
|
-
function requireCapability(capabilityId) {
|
|
125
|
-
const capability = capabilityById.get(capabilityId);
|
|
126
|
-
if (!capability)
|
|
127
|
-
throw new Error(`Stripe capability manifest is missing ${capabilityId}`);
|
|
128
|
-
return capability;
|
|
129
|
-
}
|
|
130
|
-
function helperFor(capability) {
|
|
131
|
-
if (capability.integration_path === "payment_intent")
|
|
132
|
-
return "openPaymentIntent";
|
|
133
|
-
if (capability.integration_path === "checkout_session")
|
|
134
|
-
return "openCheckout";
|
|
135
|
-
if (capability.id === "subscription.direct_setup_intent") {
|
|
136
|
-
return "openSetupIntent + openSubscription";
|
|
137
|
-
}
|
|
138
|
-
if (capability.id === "subscription.direct_saved_payment_method")
|
|
139
|
-
return "openSubscription";
|
|
140
|
-
throw new Error(`Stripe path ${capability.path_id ?? capability.id} has no SDK helper`);
|
|
141
|
-
}
|
|
142
|
-
function readinessFor(availability) {
|
|
143
|
-
if (availability === "disabled") {
|
|
144
|
-
return { reasons: ["capability_manifest_disabled"], status: "disabled" };
|
|
145
|
-
}
|
|
146
|
-
if (availability === "internal") {
|
|
147
|
-
return {
|
|
148
|
-
status: "action_required",
|
|
149
|
-
reasons: [
|
|
150
|
-
"named_internal_cohort_required",
|
|
151
|
-
"production_deployed_test_mode_proof_required",
|
|
152
|
-
"merchant_capability_status_action_required",
|
|
153
|
-
"webhook_endpoint_verification_required",
|
|
154
|
-
],
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
if (availability === "private_beta") {
|
|
158
|
-
return {
|
|
159
|
-
reasons: ["private_beta_enrollment_required", "merchant_configuration_verification_required"],
|
|
160
|
-
status: "action_required",
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
return { reasons: ["merchant_configuration_verification_required"], status: "eligible" };
|
|
164
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export interface StripeDoctorReport {
|
|
2
|
-
capability_ids: string[];
|
|
3
|
-
capability_manifest_version: 2;
|
|
4
|
-
commercial_mode: string;
|
|
5
|
-
helper: string;
|
|
6
|
-
integration_path: string;
|
|
7
|
-
local_stripe_cli_event_profiles: StripeDoctorEventProfile[];
|
|
8
|
-
money_object_creation: {
|
|
9
|
-
merchant_create_credential: "merchant_backend_only";
|
|
10
|
-
proxy_creates_stripe_money_objects: false;
|
|
11
|
-
proxy_stores_merchant_create_credential: false;
|
|
12
|
-
};
|
|
13
|
-
path_id: string;
|
|
14
|
-
presentation: string | null;
|
|
15
|
-
pricing_modes: string[];
|
|
16
|
-
proxy_merchant_event_types: string[];
|
|
17
|
-
public_documentation_anchor: string;
|
|
18
|
-
readiness: {
|
|
19
|
-
reasons: string[];
|
|
20
|
-
status: "action_required" | "disabled" | "eligible";
|
|
21
|
-
};
|
|
22
|
-
restricted_key: {
|
|
23
|
-
credential_owner: "proxy";
|
|
24
|
-
operations: Array<{
|
|
25
|
-
id: string;
|
|
26
|
-
method: "GET";
|
|
27
|
-
path: string;
|
|
28
|
-
permission: {
|
|
29
|
-
access: "Read";
|
|
30
|
-
resource: string;
|
|
31
|
-
};
|
|
32
|
-
setup_probe: boolean;
|
|
33
|
-
}>;
|
|
34
|
-
permissions: string[];
|
|
35
|
-
purpose: "read_only_reconciliation_and_endpoint_verification";
|
|
36
|
-
};
|
|
37
|
-
unsupported_options: string[];
|
|
38
|
-
validation_command: string;
|
|
39
|
-
versions: {
|
|
40
|
-
browser_sdk: string | null;
|
|
41
|
-
proof_status: string;
|
|
42
|
-
react_sdk: string | null;
|
|
43
|
-
request_api: string;
|
|
44
|
-
server_sdk: string;
|
|
45
|
-
};
|
|
46
|
-
webhook_event_profiles: StripeDoctorEventProfile[];
|
|
47
|
-
}
|
|
48
|
-
interface StripeDoctorEventProfile {
|
|
49
|
-
id: string;
|
|
50
|
-
maximum_api_version: string | null;
|
|
51
|
-
minimum_api_version: string;
|
|
52
|
-
optional_event_types: string[];
|
|
53
|
-
required_event_types: string[];
|
|
54
|
-
}
|
|
55
|
-
export declare function stripeDoctorPathIds(): string[];
|
|
56
|
-
export declare function stripeDoctorReport(pathId: string): StripeDoctorReport | undefined;
|
|
57
|
-
export declare function formatStripeDoctorReport(report: StripeDoctorReport): string;
|
|
58
|
-
export {};
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { stripeIntegrationCapabilitiesManifest } from "./generated/stripe-integration-capabilities-version.js";
|
|
2
|
-
const manifest = stripeIntegrationCapabilitiesManifest;
|
|
3
|
-
const capabilities = manifest.capabilities;
|
|
4
|
-
const capabilityById = new Map(capabilities.map((capability) => [capability.id, capability]));
|
|
5
|
-
export function stripeDoctorPathIds() {
|
|
6
|
-
return capabilities.flatMap((capability) => capability.path_id === null ? [] : [capability.path_id]);
|
|
7
|
-
}
|
|
8
|
-
export function stripeDoctorReport(pathId) {
|
|
9
|
-
const capability = capabilities.find(({ path_id }) => path_id === pathId);
|
|
10
|
-
if (!capability || capability.path_id === null)
|
|
11
|
-
return undefined;
|
|
12
|
-
const capabilityIds = resolveCapabilityClosure(capability.id);
|
|
13
|
-
const operationIds = new Set(capabilityIds.flatMap((capabilityId) => {
|
|
14
|
-
const item = requireCapability(capabilityId);
|
|
15
|
-
return [...item.reconciliation_operation_ids, ...item.setup_probe_operation_ids];
|
|
16
|
-
}));
|
|
17
|
-
const operations = manifest.operation_catalog
|
|
18
|
-
.filter(({ id }) => operationIds.has(id))
|
|
19
|
-
.map((operation) => ({
|
|
20
|
-
id: operation.id,
|
|
21
|
-
method: operation.method,
|
|
22
|
-
path: operation.path,
|
|
23
|
-
permission: operation.permission,
|
|
24
|
-
setup_probe: "setup_probe" in operation && operation.setup_probe === true,
|
|
25
|
-
}))
|
|
26
|
-
.sort((left, right) => left.id.localeCompare(right.id));
|
|
27
|
-
const webhookEventGroupIds = new Set(capabilityIds.flatMap((capabilityId) => requireCapability(capabilityId).webhook_event_group_ids));
|
|
28
|
-
const localEventGroupIds = new Set(capabilityIds.flatMap((capabilityId) => requireCapability(capabilityId).local_stripe_cli_event_groups));
|
|
29
|
-
const eventProfilesFor = (eventGroupIds) => manifest.webhook_event_profiles.map((profile) => {
|
|
30
|
-
const groups = profile.event_groups;
|
|
31
|
-
const required = new Set();
|
|
32
|
-
const optional = new Set();
|
|
33
|
-
for (const groupId of eventGroupIds) {
|
|
34
|
-
const group = groups[groupId];
|
|
35
|
-
if (!group)
|
|
36
|
-
throw new Error(`Stripe webhook profile ${profile.id} is missing ${groupId}`);
|
|
37
|
-
for (const eventType of group.required_event_types)
|
|
38
|
-
required.add(eventType);
|
|
39
|
-
for (const eventType of group.optional_event_types ?? [])
|
|
40
|
-
optional.add(eventType);
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
id: profile.id,
|
|
44
|
-
maximum_api_version: profile.maximum_api_version,
|
|
45
|
-
minimum_api_version: profile.minimum_api_version,
|
|
46
|
-
optional_event_types: [...optional].sort(),
|
|
47
|
-
required_event_types: [...required].sort(),
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
const proxyMerchantEventTypes = [
|
|
51
|
-
...new Set(capabilityIds.flatMap((capabilityId) => requireCapability(capabilityId).proxy_merchant_event_types)),
|
|
52
|
-
].sort();
|
|
53
|
-
return {
|
|
54
|
-
capability_ids: capabilityIds,
|
|
55
|
-
capability_manifest_version: manifest.manifest_version,
|
|
56
|
-
commercial_mode: capability.commercial_mode,
|
|
57
|
-
helper: helperFor(capability),
|
|
58
|
-
integration_path: capability.integration_path,
|
|
59
|
-
local_stripe_cli_event_profiles: eventProfilesFor(localEventGroupIds),
|
|
60
|
-
path_id: capability.path_id,
|
|
61
|
-
presentation: capability.checkout_ui_mode,
|
|
62
|
-
pricing_modes: [...capability.pricing_modes],
|
|
63
|
-
proxy_merchant_event_types: proxyMerchantEventTypes,
|
|
64
|
-
public_documentation_anchor: capability.public_documentation_anchor,
|
|
65
|
-
readiness: readinessFor(capability.availability),
|
|
66
|
-
unsupported_options: [...capability.unsupported_options],
|
|
67
|
-
validation_command: `proxy stripe doctor --path ${capability.path_id}`,
|
|
68
|
-
webhook_event_profiles: eventProfilesFor(webhookEventGroupIds),
|
|
69
|
-
money_object_creation: {
|
|
70
|
-
merchant_create_credential: "merchant_backend_only",
|
|
71
|
-
proxy_creates_stripe_money_objects: false,
|
|
72
|
-
proxy_stores_merchant_create_credential: false,
|
|
73
|
-
},
|
|
74
|
-
restricted_key: {
|
|
75
|
-
credential_owner: "proxy",
|
|
76
|
-
operations,
|
|
77
|
-
permissions: [
|
|
78
|
-
...new Set(operations.map(({ permission }) => `${permission.resource}: ${permission.access}`)),
|
|
79
|
-
].sort(),
|
|
80
|
-
purpose: "read_only_reconciliation_and_endpoint_verification",
|
|
81
|
-
},
|
|
82
|
-
versions: {
|
|
83
|
-
browser_sdk: capability.minimum_versions.browser_sdk,
|
|
84
|
-
proof_status: capability.minimum_versions.status,
|
|
85
|
-
react_sdk: capability.minimum_versions.react_sdk,
|
|
86
|
-
request_api: capability.minimum_versions.request_api,
|
|
87
|
-
server_sdk: capability.minimum_versions.server_sdk,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
export function formatStripeDoctorReport(report) {
|
|
92
|
-
return [
|
|
93
|
-
`${report.path_id} (${report.capability_ids.at(-1) ?? report.integration_path}) — ${report.readiness.status}`,
|
|
94
|
-
`Helper: ${report.helper}`,
|
|
95
|
-
`Versions: stripe-node ${report.versions.server_sdk}; API ${report.versions.request_api}; stripe-js ${report.versions.browser_sdk ?? "not required"}; react-stripe-js ${report.versions.react_sdk ?? "not required"}`,
|
|
96
|
-
`Proxy restricted key: ${report.restricted_key.permissions.join(", ")}`,
|
|
97
|
-
`Merchant create credential: ${report.money_object_creation.merchant_create_credential}; never sent to Proxy`,
|
|
98
|
-
`Next: ${report.readiness.reasons.join(", ") || "merchant configuration verification"}`,
|
|
99
|
-
].join("\n");
|
|
100
|
-
}
|
|
101
|
-
function resolveCapabilityClosure(capabilityId) {
|
|
102
|
-
const resolved = new Set();
|
|
103
|
-
const active = new Set();
|
|
104
|
-
const visit = (id) => {
|
|
105
|
-
if (resolved.has(id))
|
|
106
|
-
return;
|
|
107
|
-
if (active.has(id))
|
|
108
|
-
throw new Error(`Stripe capability dependency cycle includes ${id}`);
|
|
109
|
-
active.add(id);
|
|
110
|
-
const capability = requireCapability(id);
|
|
111
|
-
for (const dependency of capability.dependencies)
|
|
112
|
-
visit(dependency);
|
|
113
|
-
active.delete(id);
|
|
114
|
-
resolved.add(id);
|
|
115
|
-
};
|
|
116
|
-
visit(capabilityId);
|
|
117
|
-
return [...resolved].sort();
|
|
118
|
-
}
|
|
119
|
-
function requireCapability(capabilityId) {
|
|
120
|
-
const capability = capabilityById.get(capabilityId);
|
|
121
|
-
if (!capability)
|
|
122
|
-
throw new Error(`Stripe capability manifest is missing ${capabilityId}`);
|
|
123
|
-
return capability;
|
|
124
|
-
}
|
|
125
|
-
function helperFor(capability) {
|
|
126
|
-
if (capability.integration_path === "payment_intent")
|
|
127
|
-
return "openPaymentIntent";
|
|
128
|
-
if (capability.integration_path === "checkout_session")
|
|
129
|
-
return "openCheckout";
|
|
130
|
-
if (capability.id === "subscription.direct_setup_intent") {
|
|
131
|
-
return "openSetupIntent + openSubscription";
|
|
132
|
-
}
|
|
133
|
-
if (capability.id === "subscription.direct_saved_payment_method")
|
|
134
|
-
return "openSubscription";
|
|
135
|
-
throw new Error(`Stripe path ${capability.path_id ?? capability.id} has no SDK helper`);
|
|
136
|
-
}
|
|
137
|
-
function readinessFor(availability) {
|
|
138
|
-
if (availability === "disabled") {
|
|
139
|
-
return { reasons: ["capability_manifest_disabled"], status: "disabled" };
|
|
140
|
-
}
|
|
141
|
-
if (availability === "internal") {
|
|
142
|
-
return {
|
|
143
|
-
status: "action_required",
|
|
144
|
-
reasons: [
|
|
145
|
-
"named_internal_cohort_required",
|
|
146
|
-
"production_deployed_test_mode_proof_required",
|
|
147
|
-
"merchant_capability_status_action_required",
|
|
148
|
-
"webhook_endpoint_verification_required",
|
|
149
|
-
],
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
if (availability === "private_beta") {
|
|
153
|
-
return {
|
|
154
|
-
reasons: ["private_beta_enrollment_required", "merchant_configuration_verification_required"],
|
|
155
|
-
status: "action_required",
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
return { reasons: ["merchant_configuration_verification_required"], status: "eligible" };
|
|
159
|
-
}
|