@xapps-platform/backend-kit 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 +196 -0
- package/dist/backend/modes/gateway-managed/payment.d.ts +23 -0
- package/dist/backend/modes/gateway-managed/payment.d.ts.map +1 -0
- package/dist/backend/modes/gateway-managed/payment.js +49 -0
- package/dist/backend/modes/gateway-managed/payment.js.map +7 -0
- package/dist/backend/modes/gateway-managed/paymentSession.d.ts +4 -0
- package/dist/backend/modes/gateway-managed/paymentSession.d.ts.map +1 -0
- package/dist/backend/modes/gateway-managed/paymentSession.js +16 -0
- package/dist/backend/modes/gateway-managed/paymentSession.js.map +7 -0
- package/dist/backend/modes/gateway-managed/policy.d.ts +68 -0
- package/dist/backend/modes/gateway-managed/policy.d.ts.map +1 -0
- package/dist/backend/modes/gateway-managed/policy.js +53 -0
- package/dist/backend/modes/gateway-managed/policy.js.map +7 -0
- package/dist/backend/modes/gateway-managed/policyContext.d.ts +5 -0
- package/dist/backend/modes/gateway-managed/policyContext.d.ts.map +1 -0
- package/dist/backend/modes/gateway-managed/policyContext.js +22 -0
- package/dist/backend/modes/gateway-managed/policyContext.js.map +7 -0
- package/dist/backend/modes/index.d.ts +72 -0
- package/dist/backend/modes/index.d.ts.map +1 -0
- package/dist/backend/modes/index.js +159 -0
- package/dist/backend/modes/index.js.map +7 -0
- package/dist/backend/modes/owner-managed/payment.d.ts +34 -0
- package/dist/backend/modes/owner-managed/payment.d.ts.map +1 -0
- package/dist/backend/modes/owner-managed/payment.js +75 -0
- package/dist/backend/modes/owner-managed/payment.js.map +7 -0
- package/dist/backend/modes/owner-managed/paymentAssets.d.ts +4 -0
- package/dist/backend/modes/owner-managed/paymentAssets.d.ts.map +1 -0
- package/dist/backend/modes/owner-managed/paymentAssets.js +11 -0
- package/dist/backend/modes/owner-managed/paymentAssets.js.map +7 -0
- package/dist/backend/modes/owner-managed/paymentPageApi.d.ts +4 -0
- package/dist/backend/modes/owner-managed/paymentPageApi.d.ts.map +1 -0
- package/dist/backend/modes/owner-managed/paymentPageApi.js +11 -0
- package/dist/backend/modes/owner-managed/paymentPageApi.js.map +7 -0
- package/dist/backend/modes/owner-managed/paymentSession.d.ts +4 -0
- package/dist/backend/modes/owner-managed/paymentSession.d.ts.map +1 -0
- package/dist/backend/modes/owner-managed/paymentSession.js +18 -0
- package/dist/backend/modes/owner-managed/paymentSession.js.map +7 -0
- package/dist/backend/modes/owner-managed/policy.d.ts +68 -0
- package/dist/backend/modes/owner-managed/policy.d.ts.map +1 -0
- package/dist/backend/modes/owner-managed/policy.js +53 -0
- package/dist/backend/modes/owner-managed/policy.js.map +7 -0
- package/dist/backend/modes/owner-managed/policyContext.d.ts +5 -0
- package/dist/backend/modes/owner-managed/policyContext.d.ts.map +1 -0
- package/dist/backend/modes/owner-managed/policyContext.js +26 -0
- package/dist/backend/modes/owner-managed/policyContext.js.map +7 -0
- package/dist/backend/modes/publisher-delegated/payment.d.ts +23 -0
- package/dist/backend/modes/publisher-delegated/payment.d.ts.map +1 -0
- package/dist/backend/modes/publisher-delegated/payment.js +50 -0
- package/dist/backend/modes/publisher-delegated/payment.js.map +7 -0
- package/dist/backend/modes/publisher-delegated/paymentSession.d.ts +4 -0
- package/dist/backend/modes/publisher-delegated/paymentSession.d.ts.map +1 -0
- package/dist/backend/modes/publisher-delegated/paymentSession.js +16 -0
- package/dist/backend/modes/publisher-delegated/paymentSession.js.map +7 -0
- package/dist/backend/modes/publisher-delegated/policy.d.ts +68 -0
- package/dist/backend/modes/publisher-delegated/policy.d.ts.map +1 -0
- package/dist/backend/modes/publisher-delegated/policy.js +53 -0
- package/dist/backend/modes/publisher-delegated/policy.js.map +7 -0
- package/dist/backend/modes/publisher-delegated/policyContext.d.ts +5 -0
- package/dist/backend/modes/publisher-delegated/policyContext.d.ts.map +1 -0
- package/dist/backend/modes/publisher-delegated/policyContext.js +22 -0
- package/dist/backend/modes/publisher-delegated/policyContext.js.map +7 -0
- package/dist/backend/modes/tenant-delegated/payment.d.ts +23 -0
- package/dist/backend/modes/tenant-delegated/payment.d.ts.map +1 -0
- package/dist/backend/modes/tenant-delegated/payment.js +50 -0
- package/dist/backend/modes/tenant-delegated/payment.js.map +7 -0
- package/dist/backend/modes/tenant-delegated/paymentSession.d.ts +4 -0
- package/dist/backend/modes/tenant-delegated/paymentSession.d.ts.map +1 -0
- package/dist/backend/modes/tenant-delegated/paymentSession.js +16 -0
- package/dist/backend/modes/tenant-delegated/paymentSession.js.map +7 -0
- package/dist/backend/modes/tenant-delegated/policy.d.ts +68 -0
- package/dist/backend/modes/tenant-delegated/policy.d.ts.map +1 -0
- package/dist/backend/modes/tenant-delegated/policy.js +53 -0
- package/dist/backend/modes/tenant-delegated/policy.js.map +7 -0
- package/dist/backend/modes/tenant-delegated/policyContext.d.ts +5 -0
- package/dist/backend/modes/tenant-delegated/policyContext.d.ts.map +1 -0
- package/dist/backend/modes/tenant-delegated/policyContext.js +22 -0
- package/dist/backend/modes/tenant-delegated/policyContext.js.map +7 -0
- package/dist/backend/modules.d.ts +33 -0
- package/dist/backend/modules.d.ts.map +1 -0
- package/dist/backend/modules.js +100 -0
- package/dist/backend/modules.js.map +7 -0
- package/dist/backend/options.d.ts +78 -0
- package/dist/backend/options.d.ts.map +1 -0
- package/dist/backend/options.js +153 -0
- package/dist/backend/options.js.map +7 -0
- package/dist/backend/paymentRuntime.d.ts +31 -0
- package/dist/backend/paymentRuntime.d.ts.map +1 -0
- package/dist/backend/paymentRuntime.js +231 -0
- package/dist/backend/paymentRuntime.js.map +7 -0
- package/dist/backend/policies/common.d.ts +102 -0
- package/dist/backend/policies/common.d.ts.map +1 -0
- package/dist/backend/policies/common.js +226 -0
- package/dist/backend/policies/common.js.map +7 -0
- package/dist/backend/routes/gateway/guard.d.ts +7 -0
- package/dist/backend/routes/gateway/guard.d.ts.map +1 -0
- package/dist/backend/routes/gateway/guard.js +89 -0
- package/dist/backend/routes/gateway/guard.js.map +7 -0
- package/dist/backend/routes/gateway/hostApi.d.ts +8 -0
- package/dist/backend/routes/gateway/hostApi.d.ts.map +1 -0
- package/dist/backend/routes/gateway/hostApi.js +45 -0
- package/dist/backend/routes/gateway/hostApi.js.map +7 -0
- package/dist/backend/routes/gateway/hostApiBridge.d.ts +5 -0
- package/dist/backend/routes/gateway/hostApiBridge.d.ts.map +1 -0
- package/dist/backend/routes/gateway/hostApiBridge.js +61 -0
- package/dist/backend/routes/gateway/hostApiBridge.js.map +7 -0
- package/dist/backend/routes/gateway/hostApiCore.d.ts +5 -0
- package/dist/backend/routes/gateway/hostApiCore.d.ts.map +1 -0
- package/dist/backend/routes/gateway/hostApiCore.js +95 -0
- package/dist/backend/routes/gateway/hostApiCore.js.map +7 -0
- package/dist/backend/routes/gateway/hostApiLifecycle.d.ts +5 -0
- package/dist/backend/routes/gateway/hostApiLifecycle.d.ts.map +1 -0
- package/dist/backend/routes/gateway/hostApiLifecycle.js +80 -0
- package/dist/backend/routes/gateway/hostApiLifecycle.js.map +7 -0
- package/dist/backend/routes/gateway/hostContractBoundary.d.ts +25 -0
- package/dist/backend/routes/gateway/hostContractBoundary.d.ts.map +1 -0
- package/dist/backend/routes/gateway/hostContractBoundary.js +43 -0
- package/dist/backend/routes/gateway/hostContractBoundary.js.map +7 -0
- package/dist/backend/routes/gateway/payment.d.ts +4 -0
- package/dist/backend/routes/gateway/payment.d.ts.map +1 -0
- package/dist/backend/routes/gateway/payment.js +10 -0
- package/dist/backend/routes/gateway/payment.js.map +7 -0
- package/dist/backend/routes/gateway/shared.d.ts +36 -0
- package/dist/backend/routes/gateway/shared.d.ts.map +1 -0
- package/dist/backend/routes/gateway/shared.js +208 -0
- package/dist/backend/routes/gateway/shared.js.map +7 -0
- package/dist/backend/routes/gateway/subjectProfiles.d.ts +2 -0
- package/dist/backend/routes/gateway/subjectProfiles.d.ts.map +1 -0
- package/dist/backend/routes/gateway/subjectProfiles.js +150 -0
- package/dist/backend/routes/gateway/subjectProfiles.js.map +7 -0
- package/dist/backend/routes/health.d.ts +2 -0
- package/dist/backend/routes/health.d.ts.map +1 -0
- package/dist/backend/routes/health.js +20 -0
- package/dist/backend/routes/health.js.map +7 -0
- package/dist/backend/routes/reference.d.ts +2 -0
- package/dist/backend/routes/reference.d.ts.map +1 -0
- package/dist/backend/routes/reference.js +414 -0
- package/dist/backend/routes/reference.js.map +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +81 -0
- package/dist/index.js.map +7 -0
- package/package.json +42 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import {
|
|
3
|
+
getBackendModeEndpointGroups,
|
|
4
|
+
getBackendModeReferenceDetails,
|
|
5
|
+
normalizeEnabledBackendModes
|
|
6
|
+
} from "../modes/index.js";
|
|
7
|
+
const BASE_ENDPOINT_GROUPS = [
|
|
8
|
+
{
|
|
9
|
+
key: "core_health",
|
|
10
|
+
label: "Core health",
|
|
11
|
+
when_to_use: "Always present in the reference backend.",
|
|
12
|
+
endpoints: [{ method: "GET", path: "/health", purpose: "Basic backend health." }]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
key: "guard_execution",
|
|
16
|
+
label: "Tenant guard execution reference",
|
|
17
|
+
when_to_use: "Needed when the tenant owns payment-policy or subject-profile policy execution.",
|
|
18
|
+
endpoints: [
|
|
19
|
+
{
|
|
20
|
+
method: "POST",
|
|
21
|
+
path: "/xapps/requests",
|
|
22
|
+
purpose: "Receives tenant-owned guard/policy tool execution."
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: "tenant_subject_profile_reference",
|
|
28
|
+
label: "Tenant subject-profile reference seam",
|
|
29
|
+
when_to_use: "Optional seam when the tenant wants to provide tenant-owned billing profile candidates.",
|
|
30
|
+
endpoints: [
|
|
31
|
+
{
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/guard/subject-profiles/tenant-candidates",
|
|
34
|
+
purpose: "Returns tenant-owned billing/profile candidates for the guard."
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
key: "reference_assets",
|
|
40
|
+
label: "Reference assets",
|
|
41
|
+
when_to_use: "Only for the current local/reference browser flow.",
|
|
42
|
+
endpoints: [
|
|
43
|
+
{ method: "GET", path: "/", purpose: "Entry page for the marketplace host reference." },
|
|
44
|
+
{
|
|
45
|
+
method: "GET",
|
|
46
|
+
path: "/marketplace.html",
|
|
47
|
+
purpose: "Marketplace host shell with single-panel and split-panel embed modes."
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
method: "GET",
|
|
51
|
+
path: "/single-xapp.html",
|
|
52
|
+
purpose: "Focused single-xapp host surface using the same shared host/runtime contract."
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
method: "GET",
|
|
56
|
+
path: "/embed/sdk/xapps-embed-sdk.esm.js",
|
|
57
|
+
purpose: "Serves the embed SDK bundle used by the local reference host surfaces."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
method: "GET",
|
|
61
|
+
path: "/host/marketplace-host.js",
|
|
62
|
+
purpose: "Browser bootstrap for the marketplace host reference."
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
method: "GET",
|
|
66
|
+
path: "/host/single-xapp-host.js",
|
|
67
|
+
purpose: "Browser bootstrap for the single-xapp host reference."
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
method: "GET",
|
|
71
|
+
path: "/host/host-shell.js",
|
|
72
|
+
purpose: "Shared host-shell rendering helpers for marketplace and single-xapp surfaces."
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
method: "GET",
|
|
76
|
+
path: "/host/marketplace-runtime.js",
|
|
77
|
+
purpose: "Shared marketplace runtime wiring over the browser SDK contract."
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
method: "GET",
|
|
81
|
+
path: "/host/reference-runtime.js",
|
|
82
|
+
purpose: "Reference theme/runtime helpers for the standard marketplace host flow."
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
method: "GET",
|
|
86
|
+
path: "/host/host-status.js",
|
|
87
|
+
purpose: "Shared host proof/status renderer used by tenant host surfaces."
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: "reference_marketplace_host_core",
|
|
93
|
+
label: "Reference marketplace host proxy: core contract",
|
|
94
|
+
when_to_use: "Use this first. It is the core tenant browser->backend contract for the marketplace host.",
|
|
95
|
+
endpoints: [
|
|
96
|
+
{
|
|
97
|
+
method: "GET",
|
|
98
|
+
path: "/api/host-config",
|
|
99
|
+
purpose: "Returns current host config such as gateway base URL and supported embed modes."
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
method: "POST",
|
|
103
|
+
path: "/api/resolve-subject",
|
|
104
|
+
purpose: "Resolves a stable subject id from email for the stateless host bootstrap."
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
method: "POST",
|
|
108
|
+
path: "/api/create-catalog-session",
|
|
109
|
+
purpose: "Proxies catalog session creation for the host page."
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
method: "POST",
|
|
113
|
+
path: "/api/create-widget-session",
|
|
114
|
+
purpose: "Proxies widget session creation for the host page."
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
key: "reference_marketplace_host_lifecycle",
|
|
120
|
+
label: "Reference marketplace host proxy: lifecycle",
|
|
121
|
+
when_to_use: "Required for a real tenant marketplace host, while still kept as a separate layer for clarity.",
|
|
122
|
+
endpoints: [
|
|
123
|
+
{
|
|
124
|
+
method: "GET",
|
|
125
|
+
path: "/api/installations",
|
|
126
|
+
purpose: "Lists installations for the current subject in the host page."
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
method: "POST",
|
|
130
|
+
path: "/api/install",
|
|
131
|
+
purpose: "Install mutation proxy used by the host page."
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
method: "POST",
|
|
135
|
+
path: "/api/update",
|
|
136
|
+
purpose: "Update mutation proxy used by the host page."
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
method: "POST",
|
|
140
|
+
path: "/api/uninstall",
|
|
141
|
+
purpose: "Uninstall mutation proxy used by the host page."
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
key: "reference_marketplace_host_bridge",
|
|
147
|
+
label: "Reference marketplace host proxy: advanced bridge",
|
|
148
|
+
when_to_use: "Add these only when the tenant host needs bridge renewal or advanced signing seams.",
|
|
149
|
+
endpoints: [
|
|
150
|
+
{
|
|
151
|
+
method: "POST",
|
|
152
|
+
path: "/api/bridge/token-refresh",
|
|
153
|
+
purpose: "Bridge v2 token-refresh helper for widget session renewal."
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
method: "POST",
|
|
157
|
+
path: "/api/bridge/sign",
|
|
158
|
+
purpose: "Optional bridge signing seam for advanced host integrations."
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
method: "POST",
|
|
162
|
+
path: "/api/bridge/vendor-assertion",
|
|
163
|
+
purpose: "Optional vendor assertion seam for advanced linked integrations."
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
];
|
|
168
|
+
const OPTION_GROUPS = [
|
|
169
|
+
{
|
|
170
|
+
key: "lean_managed_first_lane",
|
|
171
|
+
label: "Lean first version",
|
|
172
|
+
recommended: true,
|
|
173
|
+
platform_managed: ["payments: stripe gateway-managed", "invoicing", "notifications"],
|
|
174
|
+
tenant_must_own: [
|
|
175
|
+
"tenant identity/bootstrap",
|
|
176
|
+
"core marketplace host proxy contract",
|
|
177
|
+
"marketplace lifecycle routes",
|
|
178
|
+
"payment return signing configuration",
|
|
179
|
+
"guard execution endpoint",
|
|
180
|
+
"tenant configuration for the chosen gateway lane"
|
|
181
|
+
],
|
|
182
|
+
reference_endpoint_groups: [
|
|
183
|
+
"core_health",
|
|
184
|
+
"guard_execution",
|
|
185
|
+
"gateway_managed_payment_reference",
|
|
186
|
+
"reference_marketplace_host_core",
|
|
187
|
+
"reference_marketplace_host_lifecycle",
|
|
188
|
+
"tenant_subject_profile_reference"
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
key: "tenant_payment_control",
|
|
193
|
+
label: "Tenant payment method / delegated evolution",
|
|
194
|
+
recommended: false,
|
|
195
|
+
platform_managed: ["invoicing", "notifications"],
|
|
196
|
+
tenant_must_own: [
|
|
197
|
+
"payment lane selection/configuration",
|
|
198
|
+
"core marketplace host proxy contract",
|
|
199
|
+
"marketplace lifecycle routes",
|
|
200
|
+
"payment return signing policy",
|
|
201
|
+
"tenant payment page or equivalent UX if owner-managed mode is selected"
|
|
202
|
+
],
|
|
203
|
+
reference_endpoint_groups: [
|
|
204
|
+
"core_health",
|
|
205
|
+
"guard_execution",
|
|
206
|
+
"tenant_delegated_payment_reference",
|
|
207
|
+
"owner_managed_payment_reference",
|
|
208
|
+
"reference_marketplace_host_core",
|
|
209
|
+
"reference_marketplace_host_lifecycle",
|
|
210
|
+
"reference_marketplace_host_bridge",
|
|
211
|
+
"tenant_subject_profile_reference"
|
|
212
|
+
],
|
|
213
|
+
notes: [
|
|
214
|
+
"Current tenant backend is the reference seam for tenant-controlled payment evolution.",
|
|
215
|
+
"The tenant may keep the same contract in Node or reimplement it in PHP/Laravel via xapps/xapps-php."
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
key: "tenant_own_invoicing",
|
|
220
|
+
label: "Tenant-owned invoicing later",
|
|
221
|
+
recommended: false,
|
|
222
|
+
platform_managed: [],
|
|
223
|
+
tenant_must_own: [
|
|
224
|
+
"tenant invoice provider configuration",
|
|
225
|
+
"invoice execution policy/refs on the gateway lane"
|
|
226
|
+
],
|
|
227
|
+
reference_endpoint_groups: [],
|
|
228
|
+
notes: [
|
|
229
|
+
"No dedicated tenant backend endpoint is required in the current lean lane for managed invoicing.",
|
|
230
|
+
"If tenant-owned invoicing is selected later, follow docs/specifications/expansions/09-invoicing-hook-provider-model.md."
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
key: "tenant_own_notifications",
|
|
235
|
+
label: "Tenant-owned notifications later",
|
|
236
|
+
recommended: false,
|
|
237
|
+
platform_managed: [],
|
|
238
|
+
tenant_must_own: [
|
|
239
|
+
"tenant notification provider configuration",
|
|
240
|
+
"notification execution policy/refs on the gateway lane"
|
|
241
|
+
],
|
|
242
|
+
reference_endpoint_groups: [],
|
|
243
|
+
notes: [
|
|
244
|
+
"No dedicated tenant backend endpoint is required in the current lean lane for managed notifications.",
|
|
245
|
+
"If tenant-owned notifications are selected later, follow docs/specifications/expansions/08-notification-hook-provider-model.md."
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
];
|
|
249
|
+
const PAYMENT_MODE_SUMMARY = [
|
|
250
|
+
{
|
|
251
|
+
key: "gateway_managed",
|
|
252
|
+
label: "Gateway managed",
|
|
253
|
+
default_for_first_lane: true,
|
|
254
|
+
page_owner: "gateway"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
key: "tenant_delegated",
|
|
258
|
+
label: "Gateway delegated by tenant",
|
|
259
|
+
default_for_first_lane: false,
|
|
260
|
+
page_owner: "gateway"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
key: "publisher_delegated",
|
|
264
|
+
label: "Gateway delegated by publisher",
|
|
265
|
+
default_for_first_lane: false,
|
|
266
|
+
page_owner: "gateway"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
key: "owner_managed",
|
|
270
|
+
reference_key: "owner_managed",
|
|
271
|
+
label: "Owner managed",
|
|
272
|
+
default_for_first_lane: false,
|
|
273
|
+
page_owner: "owner"
|
|
274
|
+
}
|
|
275
|
+
];
|
|
276
|
+
function nowIso() {
|
|
277
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
278
|
+
}
|
|
279
|
+
function buildReferenceCapabilityState(options = {}) {
|
|
280
|
+
return {
|
|
281
|
+
enableReference: options.enableReference !== false,
|
|
282
|
+
enableLifecycle: options.enableLifecycle !== false,
|
|
283
|
+
enableBridge: options.enableBridge !== false,
|
|
284
|
+
enabledModes: normalizeEnabledBackendModes(options.enabledModes)
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function filterEndpointGroups(capabilities) {
|
|
288
|
+
const filteredStaticGroups = BASE_ENDPOINT_GROUPS.filter((group) => {
|
|
289
|
+
if (group.key === "reference_marketplace_host_lifecycle") return capabilities.enableLifecycle;
|
|
290
|
+
if (group.key === "reference_marketplace_host_bridge") return capabilities.enableBridge;
|
|
291
|
+
if ([
|
|
292
|
+
"gateway_managed_payment_reference",
|
|
293
|
+
"tenant_delegated_payment_reference",
|
|
294
|
+
"publisher_delegated_payment_reference",
|
|
295
|
+
"owner_managed_payment_reference"
|
|
296
|
+
].includes(group.key)) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
return true;
|
|
300
|
+
});
|
|
301
|
+
const modeGroups = getBackendModeEndpointGroups(capabilities.enabledModes);
|
|
302
|
+
const guardIndex = filteredStaticGroups.findIndex((group) => group.key === "guard_execution");
|
|
303
|
+
if (guardIndex === -1) return [...filteredStaticGroups, ...modeGroups];
|
|
304
|
+
return [
|
|
305
|
+
...filteredStaticGroups.slice(0, guardIndex + 1),
|
|
306
|
+
...modeGroups,
|
|
307
|
+
...filteredStaticGroups.slice(guardIndex + 1)
|
|
308
|
+
];
|
|
309
|
+
}
|
|
310
|
+
function filterIntegrationOptions(capabilities) {
|
|
311
|
+
const allowedGroupKeys = new Set(filterEndpointGroups(capabilities).map((group) => group.key));
|
|
312
|
+
return OPTION_GROUPS.map((option) => ({
|
|
313
|
+
...option,
|
|
314
|
+
reference_endpoint_groups: (option.reference_endpoint_groups || []).filter(
|
|
315
|
+
(key) => allowedGroupKeys.has(key)
|
|
316
|
+
)
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
function readReferenceConfig(options = {}) {
|
|
320
|
+
const reference = options.reference && typeof options.reference === "object" ? options.reference : {};
|
|
321
|
+
const branding = options.branding && typeof options.branding === "object" ? options.branding : {};
|
|
322
|
+
const gateway = options.gateway && typeof options.gateway === "object" ? options.gateway : {};
|
|
323
|
+
const rawAssets = reference.referenceAssets && typeof reference.referenceAssets === "object" ? reference.referenceAssets : {};
|
|
324
|
+
const assets = Array.isArray(rawAssets.endpoints) ? rawAssets.endpoints : BASE_ENDPOINT_GROUPS.find((group) => group.key === "reference_assets")?.endpoints || [];
|
|
325
|
+
return {
|
|
326
|
+
tenant: String(reference.tenant || "").trim() || "tenant",
|
|
327
|
+
workspace: String(reference.workspace || "").trim() || "tenant",
|
|
328
|
+
stack: String(reference.stack || "").trim() || "node",
|
|
329
|
+
mode: String(reference.mode || "").trim() || "reference-marketplace-tenant",
|
|
330
|
+
tenantPolicySlugs: Array.isArray(reference.tenantPolicySlugs) ? reference.tenantPolicySlugs : [],
|
|
331
|
+
proofSources: Array.isArray(reference.proofSources) ? reference.proofSources : ["/api/reference", "/api/host-config", "/api/installations?subjectId=..."],
|
|
332
|
+
sdkPaths: reference.sdkPaths && typeof reference.sdkPaths === "object" ? reference.sdkPaths : {
|
|
333
|
+
node: "@xapps/server-sdk",
|
|
334
|
+
php: "xapps/xapps-php",
|
|
335
|
+
browser: "@xapps/xapps-embed-sdk"
|
|
336
|
+
},
|
|
337
|
+
hostSurfaces: Array.isArray(reference.hostSurfaces) ? reference.hostSurfaces : [
|
|
338
|
+
{ key: "single-panel", label: "Single panel", recommended_for_first_lane: true },
|
|
339
|
+
{ key: "split-panel", label: "Split panel", recommended_for_first_lane: false },
|
|
340
|
+
{ key: "single-xapp", label: "Single xapp", recommended_for_first_lane: false }
|
|
341
|
+
],
|
|
342
|
+
notes: Array.isArray(reference.notes) ? reference.notes : [],
|
|
343
|
+
gatewayUrl: String(gateway.baseUrl || "").trim(),
|
|
344
|
+
displayName: String(branding.tenantName || "").trim(),
|
|
345
|
+
stackLabel: String(branding.stackLabel || "").trim(),
|
|
346
|
+
embedSdkCandidateFiles: Array.isArray(reference.embedSdkCandidateFiles) ? reference.embedSdkCandidateFiles : [],
|
|
347
|
+
referenceAssetEndpoints: assets
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
async function referenceRoutes(fastify, options = {}) {
|
|
351
|
+
const capabilities = buildReferenceCapabilityState(options);
|
|
352
|
+
const enabledModeSet = new Set(capabilities.enabledModes);
|
|
353
|
+
const reference = readReferenceConfig(options);
|
|
354
|
+
fastify.get("/embed/sdk/xapps-embed-sdk.esm.js", async (request, reply) => {
|
|
355
|
+
const localSdkFile = reference.embedSdkCandidateFiles.find(
|
|
356
|
+
(filePath) => fs.existsSync(filePath)
|
|
357
|
+
);
|
|
358
|
+
if (localSdkFile) {
|
|
359
|
+
return reply.code(200).type("application/javascript; charset=utf-8").send(fs.readFileSync(localSdkFile, "utf8"));
|
|
360
|
+
}
|
|
361
|
+
const upstreamUrl = `${String(reference.gatewayUrl || "").trim().replace(/\/+$/, "")}/embed/sdk/xapps-embed-sdk.esm.js`;
|
|
362
|
+
if (!upstreamUrl.startsWith("http://") && !upstreamUrl.startsWith("https://")) {
|
|
363
|
+
request.log.error(
|
|
364
|
+
{ gatewayUrl: reference.gatewayUrl },
|
|
365
|
+
"invalid gateway URL for embed sdk fallback"
|
|
366
|
+
);
|
|
367
|
+
return reply.code(404).send({ ok: false, message: "embed sdk not built" });
|
|
368
|
+
}
|
|
369
|
+
try {
|
|
370
|
+
const upstream = await fetch(upstreamUrl);
|
|
371
|
+
if (!upstream.ok) {
|
|
372
|
+
request.log.error(
|
|
373
|
+
{ status: upstream.status, upstreamUrl },
|
|
374
|
+
"failed to fetch embed sdk from gateway fallback"
|
|
375
|
+
);
|
|
376
|
+
return reply.code(502).send({ ok: false, message: "embed sdk not available" });
|
|
377
|
+
}
|
|
378
|
+
return reply.code(200).type("application/javascript; charset=utf-8").send(await upstream.text());
|
|
379
|
+
} catch (err) {
|
|
380
|
+
request.log.error({ err, upstreamUrl }, "embed sdk fallback fetch failed");
|
|
381
|
+
return reply.code(502).send({ ok: false, message: "embed sdk not available" });
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
if (!capabilities.enableReference) return;
|
|
385
|
+
fastify.get("/api/reference", async () => {
|
|
386
|
+
const endpointGroups = filterEndpointGroups(capabilities).map(
|
|
387
|
+
(group) => group.key === "reference_assets" ? { ...group, endpoints: reference.referenceAssetEndpoints } : group
|
|
388
|
+
);
|
|
389
|
+
return {
|
|
390
|
+
ok: true,
|
|
391
|
+
tenant: reference.tenant,
|
|
392
|
+
workspace: reference.workspace,
|
|
393
|
+
stack: reference.stack,
|
|
394
|
+
mode: reference.mode,
|
|
395
|
+
time: nowIso(),
|
|
396
|
+
gateway_url: reference.gatewayUrl,
|
|
397
|
+
...reference.displayName ? { display_name: reference.displayName } : {},
|
|
398
|
+
...reference.stackLabel ? { stack_label: reference.stackLabel } : {},
|
|
399
|
+
tenant_policy_slugs: reference.tenantPolicySlugs,
|
|
400
|
+
proof_sources: reference.proofSources,
|
|
401
|
+
sdk_paths: reference.sdkPaths,
|
|
402
|
+
host_surfaces: reference.hostSurfaces,
|
|
403
|
+
payment_modes: PAYMENT_MODE_SUMMARY.filter((mode) => enabledModeSet.has(mode.key)),
|
|
404
|
+
payment_mode_reference_details: getBackendModeReferenceDetails(capabilities.enabledModes),
|
|
405
|
+
endpoint_groups: endpointGroups,
|
|
406
|
+
integration_options: filterIntegrationOptions(capabilities),
|
|
407
|
+
...reference.notes.length > 0 ? { notes: reference.notes } : {}
|
|
408
|
+
};
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
export {
|
|
412
|
+
referenceRoutes as default
|
|
413
|
+
};
|
|
414
|
+
//# sourceMappingURL=reference.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/backend/routes/reference.ts"],
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\nimport fs from \"node:fs\";\nimport {\n getBackendModeEndpointGroups,\n getBackendModeReferenceDetails,\n normalizeEnabledBackendModes,\n} from \"../modes/index.js\";\n\nconst BASE_ENDPOINT_GROUPS = [\n {\n key: \"core_health\",\n label: \"Core health\",\n when_to_use: \"Always present in the reference backend.\",\n endpoints: [{ method: \"GET\", path: \"/health\", purpose: \"Basic backend health.\" }],\n },\n {\n key: \"guard_execution\",\n label: \"Tenant guard execution reference\",\n when_to_use: \"Needed when the tenant owns payment-policy or subject-profile policy execution.\",\n endpoints: [\n {\n method: \"POST\",\n path: \"/xapps/requests\",\n purpose: \"Receives tenant-owned guard/policy tool execution.\",\n },\n ],\n },\n {\n key: \"tenant_subject_profile_reference\",\n label: \"Tenant subject-profile reference seam\",\n when_to_use:\n \"Optional seam when the tenant wants to provide tenant-owned billing profile candidates.\",\n endpoints: [\n {\n method: \"POST\",\n path: \"/guard/subject-profiles/tenant-candidates\",\n purpose: \"Returns tenant-owned billing/profile candidates for the guard.\",\n },\n ],\n },\n {\n key: \"reference_assets\",\n label: \"Reference assets\",\n when_to_use: \"Only for the current local/reference browser flow.\",\n endpoints: [\n { method: \"GET\", path: \"/\", purpose: \"Entry page for the marketplace host reference.\" },\n {\n method: \"GET\",\n path: \"/marketplace.html\",\n purpose: \"Marketplace host shell with single-panel and split-panel embed modes.\",\n },\n {\n method: \"GET\",\n path: \"/single-xapp.html\",\n purpose: \"Focused single-xapp host surface using the same shared host/runtime contract.\",\n },\n {\n method: \"GET\",\n path: \"/embed/sdk/xapps-embed-sdk.esm.js\",\n purpose: \"Serves the embed SDK bundle used by the local reference host surfaces.\",\n },\n {\n method: \"GET\",\n path: \"/host/marketplace-host.js\",\n purpose: \"Browser bootstrap for the marketplace host reference.\",\n },\n {\n method: \"GET\",\n path: \"/host/single-xapp-host.js\",\n purpose: \"Browser bootstrap for the single-xapp host reference.\",\n },\n {\n method: \"GET\",\n path: \"/host/host-shell.js\",\n purpose: \"Shared host-shell rendering helpers for marketplace and single-xapp surfaces.\",\n },\n {\n method: \"GET\",\n path: \"/host/marketplace-runtime.js\",\n purpose: \"Shared marketplace runtime wiring over the browser SDK contract.\",\n },\n {\n method: \"GET\",\n path: \"/host/reference-runtime.js\",\n purpose: \"Reference theme/runtime helpers for the standard marketplace host flow.\",\n },\n {\n method: \"GET\",\n path: \"/host/host-status.js\",\n purpose: \"Shared host proof/status renderer used by tenant host surfaces.\",\n },\n ],\n },\n {\n key: \"reference_marketplace_host_core\",\n label: \"Reference marketplace host proxy: core contract\",\n when_to_use:\n \"Use this first. It is the core tenant browser->backend contract for the marketplace host.\",\n endpoints: [\n {\n method: \"GET\",\n path: \"/api/host-config\",\n purpose: \"Returns current host config such as gateway base URL and supported embed modes.\",\n },\n {\n method: \"POST\",\n path: \"/api/resolve-subject\",\n purpose: \"Resolves a stable subject id from email for the stateless host bootstrap.\",\n },\n {\n method: \"POST\",\n path: \"/api/create-catalog-session\",\n purpose: \"Proxies catalog session creation for the host page.\",\n },\n {\n method: \"POST\",\n path: \"/api/create-widget-session\",\n purpose: \"Proxies widget session creation for the host page.\",\n },\n ],\n },\n {\n key: \"reference_marketplace_host_lifecycle\",\n label: \"Reference marketplace host proxy: lifecycle\",\n when_to_use:\n \"Required for a real tenant marketplace host, while still kept as a separate layer for clarity.\",\n endpoints: [\n {\n method: \"GET\",\n path: \"/api/installations\",\n purpose: \"Lists installations for the current subject in the host page.\",\n },\n {\n method: \"POST\",\n path: \"/api/install\",\n purpose: \"Install mutation proxy used by the host page.\",\n },\n {\n method: \"POST\",\n path: \"/api/update\",\n purpose: \"Update mutation proxy used by the host page.\",\n },\n {\n method: \"POST\",\n path: \"/api/uninstall\",\n purpose: \"Uninstall mutation proxy used by the host page.\",\n },\n ],\n },\n {\n key: \"reference_marketplace_host_bridge\",\n label: \"Reference marketplace host proxy: advanced bridge\",\n when_to_use:\n \"Add these only when the tenant host needs bridge renewal or advanced signing seams.\",\n endpoints: [\n {\n method: \"POST\",\n path: \"/api/bridge/token-refresh\",\n purpose: \"Bridge v2 token-refresh helper for widget session renewal.\",\n },\n {\n method: \"POST\",\n path: \"/api/bridge/sign\",\n purpose: \"Optional bridge signing seam for advanced host integrations.\",\n },\n {\n method: \"POST\",\n path: \"/api/bridge/vendor-assertion\",\n purpose: \"Optional vendor assertion seam for advanced linked integrations.\",\n },\n ],\n },\n];\n\nconst OPTION_GROUPS = [\n {\n key: \"lean_managed_first_lane\",\n label: \"Lean first version\",\n recommended: true,\n platform_managed: [\"payments: stripe gateway-managed\", \"invoicing\", \"notifications\"],\n tenant_must_own: [\n \"tenant identity/bootstrap\",\n \"core marketplace host proxy contract\",\n \"marketplace lifecycle routes\",\n \"payment return signing configuration\",\n \"guard execution endpoint\",\n \"tenant configuration for the chosen gateway lane\",\n ],\n reference_endpoint_groups: [\n \"core_health\",\n \"guard_execution\",\n \"gateway_managed_payment_reference\",\n \"reference_marketplace_host_core\",\n \"reference_marketplace_host_lifecycle\",\n \"tenant_subject_profile_reference\",\n ],\n },\n {\n key: \"tenant_payment_control\",\n label: \"Tenant payment method / delegated evolution\",\n recommended: false,\n platform_managed: [\"invoicing\", \"notifications\"],\n tenant_must_own: [\n \"payment lane selection/configuration\",\n \"core marketplace host proxy contract\",\n \"marketplace lifecycle routes\",\n \"payment return signing policy\",\n \"tenant payment page or equivalent UX if owner-managed mode is selected\",\n ],\n reference_endpoint_groups: [\n \"core_health\",\n \"guard_execution\",\n \"tenant_delegated_payment_reference\",\n \"owner_managed_payment_reference\",\n \"reference_marketplace_host_core\",\n \"reference_marketplace_host_lifecycle\",\n \"reference_marketplace_host_bridge\",\n \"tenant_subject_profile_reference\",\n ],\n notes: [\n \"Current tenant backend is the reference seam for tenant-controlled payment evolution.\",\n \"The tenant may keep the same contract in Node or reimplement it in PHP/Laravel via xapps/xapps-php.\",\n ],\n },\n {\n key: \"tenant_own_invoicing\",\n label: \"Tenant-owned invoicing later\",\n recommended: false,\n platform_managed: [],\n tenant_must_own: [\n \"tenant invoice provider configuration\",\n \"invoice execution policy/refs on the gateway lane\",\n ],\n reference_endpoint_groups: [],\n notes: [\n \"No dedicated tenant backend endpoint is required in the current lean lane for managed invoicing.\",\n \"If tenant-owned invoicing is selected later, follow docs/specifications/expansions/09-invoicing-hook-provider-model.md.\",\n ],\n },\n {\n key: \"tenant_own_notifications\",\n label: \"Tenant-owned notifications later\",\n recommended: false,\n platform_managed: [],\n tenant_must_own: [\n \"tenant notification provider configuration\",\n \"notification execution policy/refs on the gateway lane\",\n ],\n reference_endpoint_groups: [],\n notes: [\n \"No dedicated tenant backend endpoint is required in the current lean lane for managed notifications.\",\n \"If tenant-owned notifications are selected later, follow docs/specifications/expansions/08-notification-hook-provider-model.md.\",\n ],\n },\n];\n\nconst PAYMENT_MODE_SUMMARY = [\n {\n key: \"gateway_managed\",\n label: \"Gateway managed\",\n default_for_first_lane: true,\n page_owner: \"gateway\",\n },\n {\n key: \"tenant_delegated\",\n label: \"Gateway delegated by tenant\",\n default_for_first_lane: false,\n page_owner: \"gateway\",\n },\n {\n key: \"publisher_delegated\",\n label: \"Gateway delegated by publisher\",\n default_for_first_lane: false,\n page_owner: \"gateway\",\n },\n {\n key: \"owner_managed\",\n reference_key: \"owner_managed\",\n label: \"Owner managed\",\n default_for_first_lane: false,\n page_owner: \"owner\",\n },\n];\n\nfunction nowIso() {\n return new Date().toISOString();\n}\n\nfunction buildReferenceCapabilityState(options = {}) {\n return {\n enableReference: options.enableReference !== false,\n enableLifecycle: options.enableLifecycle !== false,\n enableBridge: options.enableBridge !== false,\n enabledModes: normalizeEnabledBackendModes(options.enabledModes),\n };\n}\n\nfunction filterEndpointGroups(capabilities) {\n const filteredStaticGroups = BASE_ENDPOINT_GROUPS.filter((group) => {\n if (group.key === \"reference_marketplace_host_lifecycle\") return capabilities.enableLifecycle;\n if (group.key === \"reference_marketplace_host_bridge\") return capabilities.enableBridge;\n if (\n [\n \"gateway_managed_payment_reference\",\n \"tenant_delegated_payment_reference\",\n \"publisher_delegated_payment_reference\",\n \"owner_managed_payment_reference\",\n ].includes(group.key)\n ) {\n return false;\n }\n return true;\n });\n const modeGroups = getBackendModeEndpointGroups(capabilities.enabledModes);\n const guardIndex = filteredStaticGroups.findIndex((group) => group.key === \"guard_execution\");\n if (guardIndex === -1) return [...filteredStaticGroups, ...modeGroups];\n return [\n ...filteredStaticGroups.slice(0, guardIndex + 1),\n ...modeGroups,\n ...filteredStaticGroups.slice(guardIndex + 1),\n ];\n}\n\nfunction filterIntegrationOptions(capabilities) {\n const allowedGroupKeys = new Set(filterEndpointGroups(capabilities).map((group) => group.key));\n return OPTION_GROUPS.map((option) => ({\n ...option,\n reference_endpoint_groups: (option.reference_endpoint_groups || []).filter((key) =>\n allowedGroupKeys.has(key),\n ),\n }));\n}\n\nfunction readReferenceConfig(options = {}) {\n const reference =\n options.reference && typeof options.reference === \"object\" ? options.reference : {};\n const branding = options.branding && typeof options.branding === \"object\" ? options.branding : {};\n const gateway = options.gateway && typeof options.gateway === \"object\" ? options.gateway : {};\n const rawAssets =\n reference.referenceAssets && typeof reference.referenceAssets === \"object\"\n ? reference.referenceAssets\n : {};\n const assets = Array.isArray(rawAssets.endpoints)\n ? rawAssets.endpoints\n : BASE_ENDPOINT_GROUPS.find((group) => group.key === \"reference_assets\")?.endpoints || [];\n return {\n tenant: String(reference.tenant || \"\").trim() || \"tenant\",\n workspace: String(reference.workspace || \"\").trim() || \"tenant\",\n stack: String(reference.stack || \"\").trim() || \"node\",\n mode: String(reference.mode || \"\").trim() || \"reference-marketplace-tenant\",\n tenantPolicySlugs: Array.isArray(reference.tenantPolicySlugs)\n ? reference.tenantPolicySlugs\n : [],\n proofSources: Array.isArray(reference.proofSources)\n ? reference.proofSources\n : [\"/api/reference\", \"/api/host-config\", \"/api/installations?subjectId=...\"],\n sdkPaths:\n reference.sdkPaths && typeof reference.sdkPaths === \"object\"\n ? reference.sdkPaths\n : {\n node: \"@xapps/server-sdk\",\n php: \"xapps/xapps-php\",\n browser: \"@xapps/xapps-embed-sdk\",\n },\n hostSurfaces: Array.isArray(reference.hostSurfaces)\n ? reference.hostSurfaces\n : [\n { key: \"single-panel\", label: \"Single panel\", recommended_for_first_lane: true },\n { key: \"split-panel\", label: \"Split panel\", recommended_for_first_lane: false },\n { key: \"single-xapp\", label: \"Single xapp\", recommended_for_first_lane: false },\n ],\n notes: Array.isArray(reference.notes) ? reference.notes : [],\n gatewayUrl: String(gateway.baseUrl || \"\").trim(),\n displayName: String(branding.tenantName || \"\").trim(),\n stackLabel: String(branding.stackLabel || \"\").trim(),\n embedSdkCandidateFiles: Array.isArray(reference.embedSdkCandidateFiles)\n ? reference.embedSdkCandidateFiles\n : [],\n referenceAssetEndpoints: assets,\n };\n}\n\nexport default async function referenceRoutes(fastify, options = {}) {\n const capabilities = buildReferenceCapabilityState(options);\n const enabledModeSet = new Set(capabilities.enabledModes);\n const reference = readReferenceConfig(options);\n\n fastify.get(\"/embed/sdk/xapps-embed-sdk.esm.js\", async (request, reply) => {\n const localSdkFile = reference.embedSdkCandidateFiles.find((filePath) =>\n fs.existsSync(filePath),\n );\n if (localSdkFile) {\n return reply\n .code(200)\n .type(\"application/javascript; charset=utf-8\")\n .send(fs.readFileSync(localSdkFile, \"utf8\"));\n }\n\n const upstreamUrl = `${String(reference.gatewayUrl || \"\")\n .trim()\n .replace(/\\/+$/, \"\")}/embed/sdk/xapps-embed-sdk.esm.js`;\n if (!upstreamUrl.startsWith(\"http://\") && !upstreamUrl.startsWith(\"https://\")) {\n request.log.error(\n { gatewayUrl: reference.gatewayUrl },\n \"invalid gateway URL for embed sdk fallback\",\n );\n return reply.code(404).send({ ok: false, message: \"embed sdk not built\" });\n }\n\n try {\n const upstream = await fetch(upstreamUrl);\n if (!upstream.ok) {\n request.log.error(\n { status: upstream.status, upstreamUrl },\n \"failed to fetch embed sdk from gateway fallback\",\n );\n return reply.code(502).send({ ok: false, message: \"embed sdk not available\" });\n }\n return reply\n .code(200)\n .type(\"application/javascript; charset=utf-8\")\n .send(await upstream.text());\n } catch (err) {\n request.log.error({ err, upstreamUrl }, \"embed sdk fallback fetch failed\");\n return reply.code(502).send({ ok: false, message: \"embed sdk not available\" });\n }\n });\n\n if (!capabilities.enableReference) return;\n\n fastify.get(\"/api/reference\", async () => {\n const endpointGroups = filterEndpointGroups(capabilities).map((group) =>\n group.key === \"reference_assets\"\n ? { ...group, endpoints: reference.referenceAssetEndpoints }\n : group,\n );\n return {\n ok: true,\n tenant: reference.tenant,\n workspace: reference.workspace,\n stack: reference.stack,\n mode: reference.mode,\n time: nowIso(),\n gateway_url: reference.gatewayUrl,\n ...(reference.displayName ? { display_name: reference.displayName } : {}),\n ...(reference.stackLabel ? { stack_label: reference.stackLabel } : {}),\n tenant_policy_slugs: reference.tenantPolicySlugs,\n proof_sources: reference.proofSources,\n sdk_paths: reference.sdkPaths,\n host_surfaces: reference.hostSurfaces,\n payment_modes: PAYMENT_MODE_SUMMARY.filter((mode) => enabledModeSet.has(mode.key)),\n payment_mode_reference_details: getBackendModeReferenceDetails(capabilities.enabledModes),\n endpoint_groups: endpointGroups,\n integration_options: filterIntegrationOptions(capabilities),\n ...(reference.notes.length > 0 ? { notes: reference.notes } : {}),\n };\n });\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAO,QAAQ;AACf;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,uBAAuB;AAAA,EAC3B;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,WAAW,CAAC,EAAE,QAAQ,OAAO,MAAM,WAAW,SAAS,wBAAwB,CAAC;AAAA,EAClF;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,WAAW;AAAA,MACT;AAAA,QACE,QAAQ;AAAA,QACR,MAAM;AAA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,IAAI,EAAE,OAAO,UAAU,MAAM,IAAI,CAAC;AAAA,IACjE;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createGatewayExecutionModule, createHostReferenceModule, createReferenceSurfaceModule, createHostProxyService } from "./backend/modules.js";
|
|
2
|
+
import { buildHostedGatewayPaymentUrl, buildModeHostedGatewayPaymentUrl, createPaymentEvidenceHandler, createPaymentRuntime, extractHostedPaymentSessionId, registerPaymentPageApiRoutes, registerPaymentPageAssetRoute } from "./backend/paymentRuntime.js";
|
|
3
|
+
import { normalizeBackendKitOptions, resolvePlatformSecretRefFromEnv } from "./backend/options.js";
|
|
4
|
+
export declare function createBackendKit(input?: {}, deps?: {}): Promise<{
|
|
5
|
+
options: any;
|
|
6
|
+
registerRoutes(app: any): Promise<void>;
|
|
7
|
+
applyNotFoundHandler(app: any): void;
|
|
8
|
+
}>;
|
|
9
|
+
export { buildHostedGatewayPaymentUrl as buildHostedGatewayPaymentUrl, buildModeHostedGatewayPaymentUrl as buildModeHostedGatewayPaymentUrl, createGatewayExecutionModule, createHostReferenceModule, createReferenceSurfaceModule, createHostProxyService, createPaymentEvidenceHandler, createPaymentRuntime, extractHostedPaymentSessionId, normalizeBackendKitOptions, registerPaymentPageApiRoutes, registerPaymentPageAssetRoute, resolvePlatformSecretRefFromEnv, };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,4BAA4B,EAC5B,oBAAoB,EACpB,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAEnG,wBAAsB,gBAAgB,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK;;;;GA+D3D;AAED,OAAO,EACL,4BAA4B,IAAI,4BAA4B,EAC5D,gCAAgC,IAAI,gCAAgC,EACpE,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,EACpB,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,+BAA+B,GAChC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createGatewayExecutionModule,
|
|
3
|
+
createHostReferenceModule,
|
|
4
|
+
createReferenceSurfaceModule,
|
|
5
|
+
createHostProxyService
|
|
6
|
+
} from "./backend/modules.js";
|
|
7
|
+
import {
|
|
8
|
+
buildHostedGatewayPaymentUrl,
|
|
9
|
+
buildModeHostedGatewayPaymentUrl,
|
|
10
|
+
createPaymentEvidenceHandler,
|
|
11
|
+
createPaymentRuntime,
|
|
12
|
+
extractHostedPaymentSessionId,
|
|
13
|
+
registerPaymentPageApiRoutes,
|
|
14
|
+
registerPaymentPageAssetRoute
|
|
15
|
+
} from "./backend/paymentRuntime.js";
|
|
16
|
+
import { normalizeBackendKitOptions, resolvePlatformSecretRefFromEnv } from "./backend/options.js";
|
|
17
|
+
async function createBackendKit(input = {}, deps = {}) {
|
|
18
|
+
const normalizeOptions = typeof deps.normalizeOptions === "function" ? deps.normalizeOptions : null;
|
|
19
|
+
const createReferenceSurfaceModule2 = typeof deps.createReferenceSurfaceModule === "function" ? deps.createReferenceSurfaceModule : null;
|
|
20
|
+
const createHostReferenceModule2 = typeof deps.createHostReferenceModule === "function" ? deps.createHostReferenceModule : null;
|
|
21
|
+
const createGatewayExecutionModule2 = typeof deps.createGatewayExecutionModule === "function" ? deps.createGatewayExecutionModule : null;
|
|
22
|
+
if (!normalizeOptions || !createReferenceSurfaceModule2 || !createHostReferenceModule2 || !createGatewayExecutionModule2) {
|
|
23
|
+
throw new TypeError("backend kit dependencies are incomplete");
|
|
24
|
+
}
|
|
25
|
+
const options = normalizeOptions(input);
|
|
26
|
+
const paymentRuntime = await createPaymentRuntime(options, deps);
|
|
27
|
+
const referenceSurfaceModule = createReferenceSurfaceModule2({
|
|
28
|
+
gateway: options.gateway,
|
|
29
|
+
branding: options.branding,
|
|
30
|
+
enableReference: options.host.enableReference,
|
|
31
|
+
enableLifecycle: options.host.enableLifecycle,
|
|
32
|
+
enableBridge: options.host.enableBridge,
|
|
33
|
+
enabledModes: options.payments.enabledModes,
|
|
34
|
+
reference: options.reference
|
|
35
|
+
});
|
|
36
|
+
const hostReferenceModule = createHostReferenceModule2({
|
|
37
|
+
gateway: options.gateway,
|
|
38
|
+
branding: options.branding,
|
|
39
|
+
reference: options.reference,
|
|
40
|
+
enableLifecycle: options.host.enableLifecycle,
|
|
41
|
+
enableBridge: options.host.enableBridge,
|
|
42
|
+
allowedOrigins: options.host.allowedOrigins,
|
|
43
|
+
bootstrap: options.host.bootstrap,
|
|
44
|
+
hostProxyService: options.overrides.hostProxyService
|
|
45
|
+
});
|
|
46
|
+
const gatewayExecutionModule = createGatewayExecutionModule2({
|
|
47
|
+
enabledModes: options.payments.enabledModes,
|
|
48
|
+
subjectProfiles: options.subjectProfiles,
|
|
49
|
+
paymentRuntime
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
options,
|
|
53
|
+
async registerRoutes(app) {
|
|
54
|
+
await referenceSurfaceModule.registerRoutes(app);
|
|
55
|
+
await hostReferenceModule.registerRoutes(app);
|
|
56
|
+
await gatewayExecutionModule.registerRoutes(app);
|
|
57
|
+
},
|
|
58
|
+
applyNotFoundHandler(app) {
|
|
59
|
+
app.setNotFoundHandler(
|
|
60
|
+
async (_request, reply) => reply.code(404).send({ message: "Not found" })
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
buildHostedGatewayPaymentUrl,
|
|
67
|
+
buildModeHostedGatewayPaymentUrl,
|
|
68
|
+
createBackendKit,
|
|
69
|
+
createGatewayExecutionModule,
|
|
70
|
+
createHostProxyService,
|
|
71
|
+
createHostReferenceModule,
|
|
72
|
+
createPaymentEvidenceHandler,
|
|
73
|
+
createPaymentRuntime,
|
|
74
|
+
createReferenceSurfaceModule,
|
|
75
|
+
extractHostedPaymentSessionId,
|
|
76
|
+
normalizeBackendKitOptions,
|
|
77
|
+
registerPaymentPageApiRoutes,
|
|
78
|
+
registerPaymentPageAssetRoute,
|
|
79
|
+
resolvePlatformSecretRefFromEnv
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// @ts-nocheck\nimport {\n createGatewayExecutionModule,\n createHostReferenceModule,\n createReferenceSurfaceModule,\n createHostProxyService,\n} from \"./backend/modules.js\";\nimport {\n buildHostedGatewayPaymentUrl,\n buildModeHostedGatewayPaymentUrl,\n createPaymentEvidenceHandler,\n createPaymentRuntime,\n extractHostedPaymentSessionId,\n registerPaymentPageApiRoutes,\n registerPaymentPageAssetRoute,\n} from \"./backend/paymentRuntime.js\";\nimport { normalizeBackendKitOptions, resolvePlatformSecretRefFromEnv } from \"./backend/options.js\";\n\nexport async function createBackendKit(input = {}, deps = {}) {\n const normalizeOptions =\n typeof deps.normalizeOptions === \"function\" ? deps.normalizeOptions : null;\n const createReferenceSurfaceModule =\n typeof deps.createReferenceSurfaceModule === \"function\"\n ? deps.createReferenceSurfaceModule\n : null;\n const createHostReferenceModule =\n typeof deps.createHostReferenceModule === \"function\" ? deps.createHostReferenceModule : null;\n const createGatewayExecutionModule =\n typeof deps.createGatewayExecutionModule === \"function\"\n ? deps.createGatewayExecutionModule\n : null;\n if (\n !normalizeOptions ||\n !createReferenceSurfaceModule ||\n !createHostReferenceModule ||\n !createGatewayExecutionModule\n ) {\n throw new TypeError(\"backend kit dependencies are incomplete\");\n }\n\n const options = normalizeOptions(input);\n const paymentRuntime = await createPaymentRuntime(options, deps);\n\n const referenceSurfaceModule = createReferenceSurfaceModule({\n gateway: options.gateway,\n branding: options.branding,\n enableReference: options.host.enableReference,\n enableLifecycle: options.host.enableLifecycle,\n enableBridge: options.host.enableBridge,\n enabledModes: options.payments.enabledModes,\n reference: options.reference,\n });\n const hostReferenceModule = createHostReferenceModule({\n gateway: options.gateway,\n branding: options.branding,\n reference: options.reference,\n enableLifecycle: options.host.enableLifecycle,\n enableBridge: options.host.enableBridge,\n allowedOrigins: options.host.allowedOrigins,\n bootstrap: options.host.bootstrap,\n hostProxyService: options.overrides.hostProxyService,\n });\n const gatewayExecutionModule = createGatewayExecutionModule({\n enabledModes: options.payments.enabledModes,\n subjectProfiles: options.subjectProfiles,\n paymentRuntime,\n });\n\n return {\n options,\n async registerRoutes(app) {\n await referenceSurfaceModule.registerRoutes(app);\n await hostReferenceModule.registerRoutes(app);\n await gatewayExecutionModule.registerRoutes(app);\n },\n applyNotFoundHandler(app) {\n app.setNotFoundHandler(async (_request, reply) =>\n reply.code(404).send({ message: \"Not found\" }),\n );\n },\n };\n}\n\nexport {\n buildHostedGatewayPaymentUrl as buildHostedGatewayPaymentUrl,\n buildModeHostedGatewayPaymentUrl as buildModeHostedGatewayPaymentUrl,\n createGatewayExecutionModule,\n createHostReferenceModule,\n createReferenceSurfaceModule,\n createHostProxyService,\n createPaymentEvidenceHandler,\n createPaymentRuntime,\n extractHostedPaymentSessionId,\n normalizeBackendKitOptions,\n registerPaymentPageApiRoutes,\n registerPaymentPageAssetRoute,\n resolvePlatformSecretRefFromEnv,\n};\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACE;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AC1D,cAAc,QAAQ,SAAS;AAAA,IAC/B,iBAAiB,QAAQ;AAAA,IACzB;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA,MAAM,eAAe,KAAK;AACxB,YAAM,uBAAuB,eAAe,GAAG;AAC/C,YAAM,oBAAoB,eAAe,GAAG;AAC5C,YAAM,uBAAuB,eAAe,GAAG;AAAA,IACjD;AAAA,IACA,qBAAqB,KAAK;AACxB,UAAI;AAAA,QAAmB,OAAO,UAAU,UACtC,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,SAAS,YAAY,CAAC;AAAA,MAC/C;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["createReferenceSurfaceModule", "createHostReferenceModule", "createGatewayExecutionModule"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xapps-platform/backend-kit",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Daniel Vladescu <daniel.vladescu@gmail.com>",
|
|
6
|
+
"description": "Modular Node backend kit for the current Xapps backend contract (tenant surface today, shared actor-adapter direction later)",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./backend/modes": "./dist/backend/modes/index.js",
|
|
12
|
+
"./backend/policies/common": "./dist/backend/policies/common.js",
|
|
13
|
+
"./backend/routes/health": "./dist/backend/routes/health.js",
|
|
14
|
+
"./backend/routes/reference": "./dist/backend/routes/reference.js",
|
|
15
|
+
"./backend/routes/gateway/*": "./dist/backend/routes/gateway/*.js",
|
|
16
|
+
"./backend/modes/*/*": "./dist/backend/modes/*/*.js",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/0x730/xapps-sdk-js.git",
|
|
29
|
+
"directory": "packages/backend-kit"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://gateway.0x730.com",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/0x730/xapps-sdk-js/issues"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "node ../../scripts/build-backend-kit.mjs",
|
|
37
|
+
"smoke": "npm run build && node examples/smoke/smoke.mjs"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@xapps-platform/server-sdk": "^0.1.0"
|
|
41
|
+
}
|
|
42
|
+
}
|