xytara 2.3.0 → 2.5.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/OPERATIONS_RUNBOOK.md +1 -0
- package/README.md +16 -0
- package/RELEASE_NOTES.md +18 -14
- package/SERVICE_CONTRACT.md +75 -0
- package/START_HERE.md +40 -0
- package/bin/xytara.js +55 -0
- package/index.js +1 -1
- package/lib/a2a_lane_contract.js +104 -0
- package/lib/a2c_lane_contract.js +111 -0
- package/lib/account_auth.js +347 -1
- package/lib/artifact_distribution_lane_contract.js +54 -0
- package/lib/asyncapi_contract.js +150 -0
- package/lib/auth_interop_contract.js +80 -0
- package/lib/capability_registry.js +572 -0
- package/lib/cloudevents_contract.js +80 -0
- package/lib/command_flow.js +20 -1
- package/lib/commerce_authority.js +449 -0
- package/lib/commerce_client.js +32 -0
- package/lib/commerce_economics.js +2168 -2
- package/lib/commerce_identity.js +578 -0
- package/lib/commerce_runtime.js +4 -0
- package/lib/erc8004_lane_contract.js +65 -0
- package/lib/event_system_lane_contract.js +75 -0
- package/lib/feature_control_lane_contract.js +54 -0
- package/lib/framework_lane_contract.js +89 -0
- package/lib/identity_auth.js +175 -0
- package/lib/identity_interop_contract.js +82 -0
- package/lib/integration_matrix_contract.js +93 -0
- package/lib/major_rails_lane_contract.js +90 -0
- package/lib/mcp_lane_contract.js +110 -0
- package/lib/openapi_contract.js +296 -0
- package/lib/protocol_lane_contract.js +114 -0
- package/lib/provenance_lane_contract.js +54 -0
- package/lib/provider_lane_contract.js +72 -0
- package/lib/release_history.js +16 -0
- package/lib/settlement_lane_contract.js +111 -0
- package/lib/shared_signals_lane_contract.js +54 -0
- package/lib/stablecoin_lane_contract.js +76 -0
- package/lib/stripe_mpp_lane_contract.js +93 -0
- package/lib/telemetry_lane_contract.js +54 -0
- package/lib/treasury_lane_contract.js +84 -0
- package/lib/x402_lane_contract.js +118 -0
- package/package.json +5 -3
- package/server.js +1544 -0
package/server.js
CHANGED
|
@@ -65,7 +65,12 @@ const {
|
|
|
65
65
|
applyRailCredits,
|
|
66
66
|
buildCreditBalanceSummary,
|
|
67
67
|
buildWalletSummary,
|
|
68
|
+
buildWalletLifecycleSummary,
|
|
69
|
+
buildWalletReserveSummary,
|
|
70
|
+
buildWalletCommitSummary,
|
|
71
|
+
buildWalletLedgerBundle,
|
|
68
72
|
buildWalletLedgerSummary,
|
|
73
|
+
applyWalletLifecycleEvent,
|
|
69
74
|
buildEconomicsIntelligenceSummary,
|
|
70
75
|
buildTreasuryIntelligenceSummary,
|
|
71
76
|
buildTreasurySummary,
|
|
@@ -78,6 +83,56 @@ const {
|
|
|
78
83
|
buildPolicySummary,
|
|
79
84
|
buildAccountCreditSpendPolicyPack,
|
|
80
85
|
buildAgentCreditSpendPolicyView,
|
|
86
|
+
buildPricingPolicySummary,
|
|
87
|
+
buildPricingPolicyOperatorBundle,
|
|
88
|
+
buildPricingPolicyPack,
|
|
89
|
+
buildPricingPolicyApplicationSummary,
|
|
90
|
+
buildPricingPolicyPackage,
|
|
91
|
+
buildQuotePolicyDecisionSummary,
|
|
92
|
+
buildPricingBandDecisionSummary,
|
|
93
|
+
buildQuotePolicyOperatorBundle,
|
|
94
|
+
summarizeQuotePolicyOperatorBundle,
|
|
95
|
+
buildQuotePolicyPack,
|
|
96
|
+
summarizeQuotePolicyPack,
|
|
97
|
+
buildQuotePolicyApplicationSummary,
|
|
98
|
+
buildQuotePolicyPackage,
|
|
99
|
+
summarizeQuotePolicyPackage,
|
|
100
|
+
buildTrustInputSummary,
|
|
101
|
+
buildTrustLayerSummary,
|
|
102
|
+
buildTrustLayerOperatorBundle,
|
|
103
|
+
summarizeTrustLayerOperatorBundle,
|
|
104
|
+
buildTrustLayerPolicyPack,
|
|
105
|
+
summarizeTrustLayerPolicyPack,
|
|
106
|
+
buildTrustLayerApplicationSummary,
|
|
107
|
+
buildTrustLayerPackage,
|
|
108
|
+
summarizeTrustLayerPackage,
|
|
109
|
+
listNetworkParticipants,
|
|
110
|
+
getNetworkParticipant,
|
|
111
|
+
buildNetworkParticipationAdmissionPreview,
|
|
112
|
+
createNetworkParticipant,
|
|
113
|
+
buildNetworkParticipationReviewBundle,
|
|
114
|
+
buildNetworkParticipationAttentionSummary,
|
|
115
|
+
buildNetworkParticipationSummary,
|
|
116
|
+
buildNetworkParticipationOperatorBundle,
|
|
117
|
+
buildNetworkParticipationPackage,
|
|
118
|
+
listMultiOperatorParticipants,
|
|
119
|
+
getMultiOperatorParticipant,
|
|
120
|
+
buildMultiOperatorAdmissionPreview,
|
|
121
|
+
createMultiOperatorParticipant,
|
|
122
|
+
renewMultiOperatorParticipant,
|
|
123
|
+
revokeMultiOperatorParticipant,
|
|
124
|
+
rotateMultiOperatorParticipant,
|
|
125
|
+
buildMultiOperatorParticipantRotationSummary,
|
|
126
|
+
buildMultiOperatorReviewBundle,
|
|
127
|
+
buildMultiOperatorAttentionSummary,
|
|
128
|
+
buildMultiOperatorParticipationSummary,
|
|
129
|
+
buildMultiOperatorParticipationOperatorBundle,
|
|
130
|
+
summarizeMultiOperatorParticipationOperatorBundle,
|
|
131
|
+
buildMultiOperatorParticipationPolicyPack,
|
|
132
|
+
summarizeMultiOperatorParticipationPolicyPack,
|
|
133
|
+
buildMultiOperatorParticipationApplicationSummary,
|
|
134
|
+
buildMultiOperatorParticipationPackage,
|
|
135
|
+
summarizeMultiOperatorParticipationPackage,
|
|
81
136
|
buildRailSummary,
|
|
82
137
|
buildEntitlementSummary,
|
|
83
138
|
buildEntitlementReplenishmentSummary,
|
|
@@ -112,17 +167,162 @@ const {
|
|
|
112
167
|
buildOperatorExportPack,
|
|
113
168
|
buildReconciliationReport
|
|
114
169
|
} = require("./lib/commerce_reports");
|
|
170
|
+
const {
|
|
171
|
+
buildOpenApiDocument,
|
|
172
|
+
summarizeOpenApiDocument
|
|
173
|
+
} = require("./lib/openapi_contract");
|
|
174
|
+
const {
|
|
175
|
+
buildAsyncApiDocument,
|
|
176
|
+
summarizeAsyncApiDocument
|
|
177
|
+
} = require("./lib/asyncapi_contract");
|
|
178
|
+
const {
|
|
179
|
+
buildCloudEventsContract,
|
|
180
|
+
summarizeCloudEventsContract
|
|
181
|
+
} = require("./lib/cloudevents_contract");
|
|
182
|
+
const {
|
|
183
|
+
buildAuthInteropContract,
|
|
184
|
+
summarizeAuthInteropContract
|
|
185
|
+
} = require("./lib/auth_interop_contract");
|
|
186
|
+
const {
|
|
187
|
+
buildIdentityInteropContract,
|
|
188
|
+
summarizeIdentityInteropContract
|
|
189
|
+
} = require("./lib/identity_interop_contract");
|
|
190
|
+
const {
|
|
191
|
+
buildProviderLanePack,
|
|
192
|
+
summarizeProviderLanePack
|
|
193
|
+
} = require("./lib/provider_lane_contract");
|
|
194
|
+
const {
|
|
195
|
+
buildFrameworkLanePack,
|
|
196
|
+
summarizeFrameworkLanePack
|
|
197
|
+
} = require("./lib/framework_lane_contract");
|
|
198
|
+
const {
|
|
199
|
+
buildProtocolLanePack,
|
|
200
|
+
summarizeProtocolLanePack
|
|
201
|
+
} = require("./lib/protocol_lane_contract");
|
|
202
|
+
const {
|
|
203
|
+
buildIntegrationMatrixPack,
|
|
204
|
+
summarizeIntegrationMatrixPack
|
|
205
|
+
} = require("./lib/integration_matrix_contract");
|
|
206
|
+
const {
|
|
207
|
+
buildMcpLanePack,
|
|
208
|
+
summarizeMcpLanePack,
|
|
209
|
+
listMcpTools,
|
|
210
|
+
getMcpToolDetail
|
|
211
|
+
} = require("./lib/mcp_lane_contract");
|
|
212
|
+
const {
|
|
213
|
+
buildA2ALanePack,
|
|
214
|
+
summarizeA2ALanePack
|
|
215
|
+
} = require("./lib/a2a_lane_contract");
|
|
216
|
+
const {
|
|
217
|
+
buildA2CLanePack,
|
|
218
|
+
summarizeA2CLanePack
|
|
219
|
+
} = require("./lib/a2c_lane_contract");
|
|
220
|
+
const {
|
|
221
|
+
buildX402LanePack,
|
|
222
|
+
summarizeX402LanePack
|
|
223
|
+
} = require("./lib/x402_lane_contract");
|
|
224
|
+
const {
|
|
225
|
+
buildSettlementLanePack,
|
|
226
|
+
summarizeSettlementLanePack
|
|
227
|
+
} = require("./lib/settlement_lane_contract");
|
|
228
|
+
const {
|
|
229
|
+
buildStripeMppLanePack,
|
|
230
|
+
summarizeStripeMppLanePack
|
|
231
|
+
} = require("./lib/stripe_mpp_lane_contract");
|
|
232
|
+
const {
|
|
233
|
+
buildStablecoinLanePack,
|
|
234
|
+
summarizeStablecoinLanePack
|
|
235
|
+
} = require("./lib/stablecoin_lane_contract");
|
|
236
|
+
const {
|
|
237
|
+
buildMajorRailsLanePack,
|
|
238
|
+
summarizeMajorRailsLanePack
|
|
239
|
+
} = require("./lib/major_rails_lane_contract");
|
|
240
|
+
const {
|
|
241
|
+
buildTreasuryLanePack,
|
|
242
|
+
summarizeTreasuryLanePack
|
|
243
|
+
} = require("./lib/treasury_lane_contract");
|
|
244
|
+
const {
|
|
245
|
+
buildErc8004LanePack,
|
|
246
|
+
summarizeErc8004LanePack
|
|
247
|
+
} = require("./lib/erc8004_lane_contract");
|
|
248
|
+
const {
|
|
249
|
+
buildEventSystemLanePack,
|
|
250
|
+
summarizeEventSystemLanePack
|
|
251
|
+
} = require("./lib/event_system_lane_contract");
|
|
252
|
+
const {
|
|
253
|
+
buildTelemetryLanePack,
|
|
254
|
+
summarizeTelemetryLanePack
|
|
255
|
+
} = require("./lib/telemetry_lane_contract");
|
|
256
|
+
const {
|
|
257
|
+
buildProvenanceLanePack,
|
|
258
|
+
summarizeProvenanceLanePack
|
|
259
|
+
} = require("./lib/provenance_lane_contract");
|
|
260
|
+
const {
|
|
261
|
+
buildArtifactDistributionLanePack,
|
|
262
|
+
summarizeArtifactDistributionLanePack
|
|
263
|
+
} = require("./lib/artifact_distribution_lane_contract");
|
|
264
|
+
const {
|
|
265
|
+
buildSharedSignalsLanePack,
|
|
266
|
+
summarizeSharedSignalsLanePack
|
|
267
|
+
} = require("./lib/shared_signals_lane_contract");
|
|
268
|
+
const {
|
|
269
|
+
buildFeatureControlLanePack,
|
|
270
|
+
summarizeFeatureControlLanePack
|
|
271
|
+
} = require("./lib/feature_control_lane_contract");
|
|
272
|
+
const {
|
|
273
|
+
buildAuthoritySummary,
|
|
274
|
+
buildAuthorityBundle,
|
|
275
|
+
buildAuthorityUsageSummary,
|
|
276
|
+
buildAuthorityReviewBundle,
|
|
277
|
+
buildAuthorityAttentionSummary,
|
|
278
|
+
buildAuthorityLineageSummary,
|
|
279
|
+
buildAuthorityPolicyPack,
|
|
280
|
+
buildAuthorityPolicyPackSummary
|
|
281
|
+
} = require("./lib/commerce_authority");
|
|
282
|
+
const {
|
|
283
|
+
buildMachineIdentitySummary,
|
|
284
|
+
buildMachineIdentityBundle,
|
|
285
|
+
buildMachineIdentityAttachmentSummary,
|
|
286
|
+
buildMachineIdentityLineageSummary,
|
|
287
|
+
buildMachineIdentityBindingLineageSummary,
|
|
288
|
+
buildMachineIdentityProfile,
|
|
289
|
+
buildMachineIdentityPolicyPack,
|
|
290
|
+
buildMachineIdentityPolicyPackSummary,
|
|
291
|
+
buildMachineIdentityPolicyApplicationSummary,
|
|
292
|
+
buildMachineIdentityReviewBundle,
|
|
293
|
+
buildMachineIdentityAttentionSummary,
|
|
294
|
+
buildMachineIdentityOperatorBundle
|
|
295
|
+
} = require("./lib/commerce_identity");
|
|
115
296
|
const {
|
|
116
297
|
createExternalCreditGrant,
|
|
117
298
|
getExternalCreditGrant,
|
|
118
299
|
listExternalCreditGrants
|
|
119
300
|
} = require("./lib/external_credit_bridge");
|
|
120
301
|
const {
|
|
302
|
+
createAuthorityBinding,
|
|
121
303
|
createSpendCredential,
|
|
304
|
+
evaluateAuthorityBindingAction,
|
|
305
|
+
getAuthorityBinding,
|
|
306
|
+
getAuthorityBindingContractSummary,
|
|
307
|
+
getAuthorityBindingRotationSummary,
|
|
122
308
|
getSpendCredential,
|
|
309
|
+
listAuthorityBindings,
|
|
123
310
|
listSpendCredentials,
|
|
311
|
+
renewAuthorityBinding,
|
|
312
|
+
resolveSpendCredential,
|
|
313
|
+
rotateAuthorityBinding,
|
|
314
|
+
revokeAuthorityBinding,
|
|
124
315
|
revokeSpendCredential
|
|
125
316
|
} = require("./lib/account_auth");
|
|
317
|
+
const {
|
|
318
|
+
createIdentityBinding,
|
|
319
|
+
listIdentityBindings,
|
|
320
|
+
getIdentityBinding,
|
|
321
|
+
getIdentityBindingRotationSummary,
|
|
322
|
+
renewIdentityBinding,
|
|
323
|
+
revokeIdentityBinding,
|
|
324
|
+
rotateIdentityBinding
|
|
325
|
+
} = require("./lib/identity_auth");
|
|
126
326
|
const {
|
|
127
327
|
getBsvSettlementRecord,
|
|
128
328
|
listBsvSettlementRecords,
|
|
@@ -246,6 +446,19 @@ const {
|
|
|
246
446
|
buildAdapterPartnerPack,
|
|
247
447
|
summarizeAdapterPartnerPack
|
|
248
448
|
} = require("./lib/adapter_partner_pack");
|
|
449
|
+
const {
|
|
450
|
+
buildCapabilityRegistrySummary,
|
|
451
|
+
buildCapabilityRegistryBundle,
|
|
452
|
+
buildCapabilityRegistryClassificationSummary,
|
|
453
|
+
buildCapabilityRegistryLineageSummary,
|
|
454
|
+
buildCapabilityRegistryOperatorBundle,
|
|
455
|
+
buildCapabilityRegistryPolicyPack,
|
|
456
|
+
summarizeCapabilityRegistryPolicyPack,
|
|
457
|
+
buildCapabilityRegistryPolicyApplicationSummary,
|
|
458
|
+
buildCapabilityRegistryPackage,
|
|
459
|
+
summarizeCapabilityRegistryPackage,
|
|
460
|
+
summarizeCapabilityRegistryOperatorBundle
|
|
461
|
+
} = require("./lib/capability_registry");
|
|
249
462
|
const {
|
|
250
463
|
buildPartnerIntelligencePack,
|
|
251
464
|
summarizePartnerIntelligencePack
|
|
@@ -875,6 +1088,19 @@ function parseBearerToken(headers) {
|
|
|
875
1088
|
return match ? match[1].trim() : null;
|
|
876
1089
|
}
|
|
877
1090
|
|
|
1091
|
+
function resolveDelegatedAuthorityForHeaders(state, headers) {
|
|
1092
|
+
const bearerToken = parseBearerToken(headers);
|
|
1093
|
+
const delegatedSpendRequested = typeof bearerToken === "string" && bearerToken.startsWith("xytara_spend_");
|
|
1094
|
+
if (!delegatedSpendRequested) {
|
|
1095
|
+
return { requested: false, ok: false, reason: "spend_credential_not_requested" };
|
|
1096
|
+
}
|
|
1097
|
+
const delegatedSpend = resolveSpendCredential(state, bearerToken);
|
|
1098
|
+
return {
|
|
1099
|
+
requested: true,
|
|
1100
|
+
...delegatedSpend
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
|
|
878
1104
|
function verifyAccountAuthWriteAccess(headers) {
|
|
879
1105
|
const expectedToken = getAccountAuthBearerToken();
|
|
880
1106
|
if (!expectedToken) {
|
|
@@ -900,6 +1126,18 @@ function verifyAccountAuthWriteAccess(headers) {
|
|
|
900
1126
|
};
|
|
901
1127
|
}
|
|
902
1128
|
|
|
1129
|
+
function mergeIdentityBindingPolicyPayload(policySummary, body, accountId) {
|
|
1130
|
+
const payload = body && typeof body === "object" && !Array.isArray(body) ? body : {};
|
|
1131
|
+
const suggested = policySummary && policySummary.suggested_binding_payload && typeof policySummary.suggested_binding_payload === "object"
|
|
1132
|
+
? policySummary.suggested_binding_payload
|
|
1133
|
+
: {};
|
|
1134
|
+
return {
|
|
1135
|
+
...suggested,
|
|
1136
|
+
...payload,
|
|
1137
|
+
account_id: accountId
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
|
|
903
1141
|
function verifyCreditBridgeWriteAccess(headers) {
|
|
904
1142
|
const expectedToken = getCreditBridgeBearerToken();
|
|
905
1143
|
if (!expectedToken) {
|
|
@@ -3143,6 +3381,271 @@ async function routeRequest(req, res) {
|
|
|
3143
3381
|
return;
|
|
3144
3382
|
}
|
|
3145
3383
|
|
|
3384
|
+
if (req.method === "GET" && (url.pathname === "/openapi.json" || url.pathname === "/v1/openapi")) {
|
|
3385
|
+
sendJson(res, 200, buildOpenApiDocument());
|
|
3386
|
+
return;
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
if (req.method === "GET" && url.pathname === "/v1/openapi/summary") {
|
|
3390
|
+
sendJson(res, 200, summarizeOpenApiDocument());
|
|
3391
|
+
return;
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3394
|
+
if (req.method === "GET" && (url.pathname === "/asyncapi.json" || url.pathname === "/v1/asyncapi")) {
|
|
3395
|
+
sendJson(res, 200, buildAsyncApiDocument());
|
|
3396
|
+
return;
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
if (req.method === "GET" && url.pathname === "/v1/asyncapi/summary") {
|
|
3400
|
+
sendJson(res, 200, summarizeAsyncApiDocument());
|
|
3401
|
+
return;
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3404
|
+
if (req.method === "GET" && (url.pathname === "/cloudevents.json" || url.pathname === "/v1/cloudevents")) {
|
|
3405
|
+
sendJson(res, 200, buildCloudEventsContract());
|
|
3406
|
+
return;
|
|
3407
|
+
}
|
|
3408
|
+
|
|
3409
|
+
if (req.method === "GET" && url.pathname === "/v1/cloudevents/summary") {
|
|
3410
|
+
sendJson(res, 200, summarizeCloudEventsContract());
|
|
3411
|
+
return;
|
|
3412
|
+
}
|
|
3413
|
+
|
|
3414
|
+
if (req.method === "GET" && (url.pathname === "/v1/auth-profiles" || url.pathname === "/v1/auth-interop")) {
|
|
3415
|
+
sendJson(res, 200, buildAuthInteropContract());
|
|
3416
|
+
return;
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3419
|
+
if (req.method === "GET" && (url.pathname === "/v1/auth-profiles/summary" || url.pathname === "/v1/auth-interop/summary")) {
|
|
3420
|
+
sendJson(res, 200, summarizeAuthInteropContract());
|
|
3421
|
+
return;
|
|
3422
|
+
}
|
|
3423
|
+
|
|
3424
|
+
if (req.method === "GET" && (url.pathname === "/v1/identity-interop" || url.pathname === "/v1/credential-interop")) {
|
|
3425
|
+
sendJson(res, 200, buildIdentityInteropContract());
|
|
3426
|
+
return;
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3429
|
+
if (req.method === "GET" && (url.pathname === "/v1/identity-interop/summary" || url.pathname === "/v1/credential-interop/summary")) {
|
|
3430
|
+
sendJson(res, 200, summarizeIdentityInteropContract());
|
|
3431
|
+
return;
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
if (req.method === "GET" && url.pathname === "/v1/providers") {
|
|
3435
|
+
sendJson(res, 200, buildProviderLanePack());
|
|
3436
|
+
return;
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3439
|
+
if (req.method === "GET" && url.pathname === "/v1/providers/summary") {
|
|
3440
|
+
sendJson(res, 200, summarizeProviderLanePack());
|
|
3441
|
+
return;
|
|
3442
|
+
}
|
|
3443
|
+
|
|
3444
|
+
if (req.method === "GET" && url.pathname === "/v1/frameworks") {
|
|
3445
|
+
sendJson(res, 200, buildFrameworkLanePack());
|
|
3446
|
+
return;
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3449
|
+
if (req.method === "GET" && url.pathname === "/v1/frameworks/summary") {
|
|
3450
|
+
sendJson(res, 200, summarizeFrameworkLanePack());
|
|
3451
|
+
return;
|
|
3452
|
+
}
|
|
3453
|
+
|
|
3454
|
+
if (req.method === "GET" && url.pathname === "/v1/protocols") {
|
|
3455
|
+
sendJson(res, 200, buildProtocolLanePack());
|
|
3456
|
+
return;
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3459
|
+
if (req.method === "GET" && url.pathname === "/v1/protocols/summary") {
|
|
3460
|
+
sendJson(res, 200, summarizeProtocolLanePack());
|
|
3461
|
+
return;
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
if (req.method === "GET" && url.pathname === "/v1/integration-matrix") {
|
|
3465
|
+
sendJson(res, 200, buildIntegrationMatrixPack(listIntegrations()));
|
|
3466
|
+
return;
|
|
3467
|
+
}
|
|
3468
|
+
|
|
3469
|
+
if (req.method === "GET" && url.pathname === "/v1/integration-matrix/summary") {
|
|
3470
|
+
sendJson(res, 200, summarizeIntegrationMatrixPack(listIntegrations()));
|
|
3471
|
+
return;
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3474
|
+
if (req.method === "GET" && url.pathname === "/v1/mcp") {
|
|
3475
|
+
sendJson(res, 200, buildMcpLanePack());
|
|
3476
|
+
return;
|
|
3477
|
+
}
|
|
3478
|
+
|
|
3479
|
+
if (req.method === "GET" && url.pathname === "/v1/mcp/summary") {
|
|
3480
|
+
sendJson(res, 200, summarizeMcpLanePack());
|
|
3481
|
+
return;
|
|
3482
|
+
}
|
|
3483
|
+
|
|
3484
|
+
if (req.method === "GET" && url.pathname === "/v1/mcp/tools") {
|
|
3485
|
+
const toolName = String(url.searchParams.get("tool_name") || "").trim();
|
|
3486
|
+
if (!toolName) {
|
|
3487
|
+
sendJson(res, 200, listMcpTools());
|
|
3488
|
+
return;
|
|
3489
|
+
}
|
|
3490
|
+
const tool = getMcpToolDetail(toolName);
|
|
3491
|
+
if (!tool) {
|
|
3492
|
+
sendJson(res, 404, { ok: false, reason: "mcp_tool_not_found", tool_name: toolName });
|
|
3493
|
+
return;
|
|
3494
|
+
}
|
|
3495
|
+
sendJson(res, 200, { ok: true, tool });
|
|
3496
|
+
return;
|
|
3497
|
+
}
|
|
3498
|
+
|
|
3499
|
+
if (req.method === "GET" && url.pathname === "/v1/a2a") {
|
|
3500
|
+
sendJson(res, 200, buildA2ALanePack());
|
|
3501
|
+
return;
|
|
3502
|
+
}
|
|
3503
|
+
|
|
3504
|
+
if (req.method === "GET" && url.pathname === "/v1/a2a/summary") {
|
|
3505
|
+
sendJson(res, 200, summarizeA2ALanePack());
|
|
3506
|
+
return;
|
|
3507
|
+
}
|
|
3508
|
+
|
|
3509
|
+
if (req.method === "GET" && url.pathname === "/v1/a2c") {
|
|
3510
|
+
sendJson(res, 200, buildA2CLanePack());
|
|
3511
|
+
return;
|
|
3512
|
+
}
|
|
3513
|
+
|
|
3514
|
+
if (req.method === "GET" && url.pathname === "/v1/a2c/summary") {
|
|
3515
|
+
sendJson(res, 200, summarizeA2CLanePack());
|
|
3516
|
+
return;
|
|
3517
|
+
}
|
|
3518
|
+
|
|
3519
|
+
if (req.method === "GET" && url.pathname === "/v1/x402") {
|
|
3520
|
+
sendJson(res, 200, buildX402LanePack());
|
|
3521
|
+
return;
|
|
3522
|
+
}
|
|
3523
|
+
|
|
3524
|
+
if (req.method === "GET" && url.pathname === "/v1/x402/summary") {
|
|
3525
|
+
sendJson(res, 200, summarizeX402LanePack());
|
|
3526
|
+
return;
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3529
|
+
if (req.method === "GET" && url.pathname === "/v1/settlement") {
|
|
3530
|
+
sendJson(res, 200, buildSettlementLanePack());
|
|
3531
|
+
return;
|
|
3532
|
+
}
|
|
3533
|
+
|
|
3534
|
+
if (req.method === "GET" && url.pathname === "/v1/settlement/summary") {
|
|
3535
|
+
sendJson(res, 200, summarizeSettlementLanePack());
|
|
3536
|
+
return;
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
if (req.method === "GET" && url.pathname === "/v1/stripe-mpp") {
|
|
3540
|
+
sendJson(res, 200, buildStripeMppLanePack());
|
|
3541
|
+
return;
|
|
3542
|
+
}
|
|
3543
|
+
|
|
3544
|
+
if (req.method === "GET" && url.pathname === "/v1/stripe-mpp/summary") {
|
|
3545
|
+
sendJson(res, 200, summarizeStripeMppLanePack());
|
|
3546
|
+
return;
|
|
3547
|
+
}
|
|
3548
|
+
|
|
3549
|
+
if (req.method === "GET" && url.pathname === "/v1/stablecoins") {
|
|
3550
|
+
sendJson(res, 200, buildStablecoinLanePack());
|
|
3551
|
+
return;
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
if (req.method === "GET" && url.pathname === "/v1/stablecoins/summary") {
|
|
3555
|
+
sendJson(res, 200, summarizeStablecoinLanePack());
|
|
3556
|
+
return;
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
if (req.method === "GET" && url.pathname === "/v1/major-rails") {
|
|
3560
|
+
sendJson(res, 200, buildMajorRailsLanePack());
|
|
3561
|
+
return;
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
if (req.method === "GET" && url.pathname === "/v1/major-rails/summary") {
|
|
3565
|
+
sendJson(res, 200, summarizeMajorRailsLanePack());
|
|
3566
|
+
return;
|
|
3567
|
+
}
|
|
3568
|
+
|
|
3569
|
+
if (req.method === "GET" && url.pathname === "/v1/treasury") {
|
|
3570
|
+
sendJson(res, 200, buildTreasuryLanePack());
|
|
3571
|
+
return;
|
|
3572
|
+
}
|
|
3573
|
+
|
|
3574
|
+
if (req.method === "GET" && url.pathname === "/v1/treasury/summary") {
|
|
3575
|
+
sendJson(res, 200, summarizeTreasuryLanePack());
|
|
3576
|
+
return;
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
if (req.method === "GET" && url.pathname === "/v1/erc8004") {
|
|
3580
|
+
sendJson(res, 200, buildErc8004LanePack());
|
|
3581
|
+
return;
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
if (req.method === "GET" && url.pathname === "/v1/erc8004/summary") {
|
|
3585
|
+
sendJson(res, 200, summarizeErc8004LanePack());
|
|
3586
|
+
return;
|
|
3587
|
+
}
|
|
3588
|
+
|
|
3589
|
+
if (req.method === "GET" && url.pathname === "/v1/event-systems") {
|
|
3590
|
+
sendJson(res, 200, buildEventSystemLanePack());
|
|
3591
|
+
return;
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3594
|
+
if (req.method === "GET" && url.pathname === "/v1/event-systems/summary") {
|
|
3595
|
+
sendJson(res, 200, summarizeEventSystemLanePack());
|
|
3596
|
+
return;
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
if (req.method === "GET" && url.pathname === "/v1/telemetry") {
|
|
3600
|
+
sendJson(res, 200, buildTelemetryLanePack());
|
|
3601
|
+
return;
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
if (req.method === "GET" && url.pathname === "/v1/telemetry/summary") {
|
|
3605
|
+
sendJson(res, 200, summarizeTelemetryLanePack());
|
|
3606
|
+
return;
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
if (req.method === "GET" && url.pathname === "/v1/provenance") {
|
|
3610
|
+
sendJson(res, 200, buildProvenanceLanePack());
|
|
3611
|
+
return;
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3614
|
+
if (req.method === "GET" && url.pathname === "/v1/provenance/summary") {
|
|
3615
|
+
sendJson(res, 200, summarizeProvenanceLanePack());
|
|
3616
|
+
return;
|
|
3617
|
+
}
|
|
3618
|
+
|
|
3619
|
+
if (req.method === "GET" && url.pathname === "/v1/artifact-distribution") {
|
|
3620
|
+
sendJson(res, 200, buildArtifactDistributionLanePack());
|
|
3621
|
+
return;
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
if (req.method === "GET" && url.pathname === "/v1/artifact-distribution/summary") {
|
|
3625
|
+
sendJson(res, 200, summarizeArtifactDistributionLanePack());
|
|
3626
|
+
return;
|
|
3627
|
+
}
|
|
3628
|
+
|
|
3629
|
+
if (req.method === "GET" && url.pathname === "/v1/shared-signals") {
|
|
3630
|
+
sendJson(res, 200, buildSharedSignalsLanePack());
|
|
3631
|
+
return;
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3634
|
+
if (req.method === "GET" && url.pathname === "/v1/shared-signals/summary") {
|
|
3635
|
+
sendJson(res, 200, summarizeSharedSignalsLanePack());
|
|
3636
|
+
return;
|
|
3637
|
+
}
|
|
3638
|
+
|
|
3639
|
+
if (req.method === "GET" && url.pathname === "/v1/feature-control") {
|
|
3640
|
+
sendJson(res, 200, buildFeatureControlLanePack());
|
|
3641
|
+
return;
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3644
|
+
if (req.method === "GET" && url.pathname === "/v1/feature-control/summary") {
|
|
3645
|
+
sendJson(res, 200, summarizeFeatureControlLanePack());
|
|
3646
|
+
return;
|
|
3647
|
+
}
|
|
3648
|
+
|
|
3146
3649
|
if (req.method === "GET" && url.pathname === "/v1/release-pack") {
|
|
3147
3650
|
sendJson(res, 200, buildReleasePack());
|
|
3148
3651
|
return;
|
|
@@ -3271,6 +3774,76 @@ async function routeRequest(req, res) {
|
|
|
3271
3774
|
return;
|
|
3272
3775
|
}
|
|
3273
3776
|
|
|
3777
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry") {
|
|
3778
|
+
sendJson(res, 200, buildCapabilityRegistryBundle());
|
|
3779
|
+
return;
|
|
3780
|
+
}
|
|
3781
|
+
|
|
3782
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/summary") {
|
|
3783
|
+
sendJson(res, 200, buildCapabilityRegistrySummary());
|
|
3784
|
+
return;
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/classification-summary") {
|
|
3788
|
+
sendJson(res, 200, buildCapabilityRegistryClassificationSummary());
|
|
3789
|
+
return;
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/lineage-summary") {
|
|
3793
|
+
sendJson(res, 200, buildCapabilityRegistryLineageSummary());
|
|
3794
|
+
return;
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/operator-bundle") {
|
|
3798
|
+
sendJson(res, 200, buildCapabilityRegistryOperatorBundle(state, {
|
|
3799
|
+
account_id: url.searchParams.get("account_id") || "acct_demo"
|
|
3800
|
+
}));
|
|
3801
|
+
return;
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3804
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/operator-bundle/summary") {
|
|
3805
|
+
sendJson(res, 200, summarizeCapabilityRegistryOperatorBundle(state, {
|
|
3806
|
+
account_id: url.searchParams.get("account_id") || "acct_demo"
|
|
3807
|
+
}));
|
|
3808
|
+
return;
|
|
3809
|
+
}
|
|
3810
|
+
|
|
3811
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/policy-pack") {
|
|
3812
|
+
sendJson(res, 200, buildCapabilityRegistryPolicyPack(state, {
|
|
3813
|
+
account_id: url.searchParams.get("account_id") || "acct_demo"
|
|
3814
|
+
}));
|
|
3815
|
+
return;
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/policy-pack/summary") {
|
|
3819
|
+
sendJson(res, 200, summarizeCapabilityRegistryPolicyPack(state, {
|
|
3820
|
+
account_id: url.searchParams.get("account_id") || "acct_demo"
|
|
3821
|
+
}));
|
|
3822
|
+
return;
|
|
3823
|
+
}
|
|
3824
|
+
|
|
3825
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/policy-application-summary") {
|
|
3826
|
+
sendJson(res, 200, buildCapabilityRegistryPolicyApplicationSummary(state, {
|
|
3827
|
+
account_id: url.searchParams.get("account_id") || "acct_demo",
|
|
3828
|
+
template_id: url.searchParams.get("template_id") || ""
|
|
3829
|
+
}));
|
|
3830
|
+
return;
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/package") {
|
|
3834
|
+
sendJson(res, 200, buildCapabilityRegistryPackage(state, {
|
|
3835
|
+
account_id: url.searchParams.get("account_id") || "acct_demo"
|
|
3836
|
+
}));
|
|
3837
|
+
return;
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3840
|
+
if (req.method === "GET" && url.pathname === "/v1/capability-registry/package/summary") {
|
|
3841
|
+
sendJson(res, 200, summarizeCapabilityRegistryPackage(state, {
|
|
3842
|
+
account_id: url.searchParams.get("account_id") || "acct_demo"
|
|
3843
|
+
}));
|
|
3844
|
+
return;
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3274
3847
|
if (req.method === "GET" && url.pathname === "/v1/partner-intelligence") {
|
|
3275
3848
|
sendJson(res, 200, buildPartnerIntelligencePack());
|
|
3276
3849
|
return;
|
|
@@ -5318,6 +5891,78 @@ async function routeRequest(req, res) {
|
|
|
5318
5891
|
return;
|
|
5319
5892
|
}
|
|
5320
5893
|
|
|
5894
|
+
if (req.method === "POST" && url.pathname === "/v1/economics/rails/credits/reserve") {
|
|
5895
|
+
const body = await readJsonBody(req);
|
|
5896
|
+
const delegatedAuthority = resolveDelegatedAuthorityForHeaders(state, req.headers || {});
|
|
5897
|
+
if (delegatedAuthority.requested && !delegatedAuthority.ok) {
|
|
5898
|
+
sendJson(res, 403, { ok: false, reason: delegatedAuthority.reason });
|
|
5899
|
+
return;
|
|
5900
|
+
}
|
|
5901
|
+
if (delegatedAuthority.ok && delegatedAuthority.binding) {
|
|
5902
|
+
const units = typeof body.units === "number" ? body.units : 0;
|
|
5903
|
+
const authorityDecision = evaluateAuthorityBindingAction(delegatedAuthority.binding, "reserve", units);
|
|
5904
|
+
if (!authorityDecision.ok) {
|
|
5905
|
+
sendJson(res, 403, authorityDecision);
|
|
5906
|
+
return;
|
|
5907
|
+
}
|
|
5908
|
+
}
|
|
5909
|
+
const result = applyWalletLifecycleEvent(state, body, "reserve");
|
|
5910
|
+
if (!result.ok) {
|
|
5911
|
+
sendJson(res, 409, result);
|
|
5912
|
+
return;
|
|
5913
|
+
}
|
|
5914
|
+
sendJson(res, 200, result);
|
|
5915
|
+
return;
|
|
5916
|
+
}
|
|
5917
|
+
|
|
5918
|
+
if (req.method === "POST" && url.pathname === "/v1/economics/rails/credits/release") {
|
|
5919
|
+
const body = await readJsonBody(req);
|
|
5920
|
+
const delegatedAuthority = resolveDelegatedAuthorityForHeaders(state, req.headers || {});
|
|
5921
|
+
if (delegatedAuthority.requested && !delegatedAuthority.ok) {
|
|
5922
|
+
sendJson(res, 403, { ok: false, reason: delegatedAuthority.reason });
|
|
5923
|
+
return;
|
|
5924
|
+
}
|
|
5925
|
+
if (delegatedAuthority.ok && delegatedAuthority.binding) {
|
|
5926
|
+
const units = typeof body.units === "number" ? body.units : 0;
|
|
5927
|
+
const authorityDecision = evaluateAuthorityBindingAction(delegatedAuthority.binding, "release", units);
|
|
5928
|
+
if (!authorityDecision.ok) {
|
|
5929
|
+
sendJson(res, 403, authorityDecision);
|
|
5930
|
+
return;
|
|
5931
|
+
}
|
|
5932
|
+
}
|
|
5933
|
+
const result = applyWalletLifecycleEvent(state, body, "release");
|
|
5934
|
+
if (!result.ok) {
|
|
5935
|
+
sendJson(res, 409, result);
|
|
5936
|
+
return;
|
|
5937
|
+
}
|
|
5938
|
+
sendJson(res, 200, result);
|
|
5939
|
+
return;
|
|
5940
|
+
}
|
|
5941
|
+
|
|
5942
|
+
if (req.method === "POST" && url.pathname === "/v1/economics/rails/credits/reverse") {
|
|
5943
|
+
const body = await readJsonBody(req);
|
|
5944
|
+
const delegatedAuthority = resolveDelegatedAuthorityForHeaders(state, req.headers || {});
|
|
5945
|
+
if (delegatedAuthority.requested && !delegatedAuthority.ok) {
|
|
5946
|
+
sendJson(res, 403, { ok: false, reason: delegatedAuthority.reason });
|
|
5947
|
+
return;
|
|
5948
|
+
}
|
|
5949
|
+
if (delegatedAuthority.ok && delegatedAuthority.binding) {
|
|
5950
|
+
const units = typeof body.units === "number" ? body.units : 0;
|
|
5951
|
+
const authorityDecision = evaluateAuthorityBindingAction(delegatedAuthority.binding, "reverse", units);
|
|
5952
|
+
if (!authorityDecision.ok) {
|
|
5953
|
+
sendJson(res, 403, authorityDecision);
|
|
5954
|
+
return;
|
|
5955
|
+
}
|
|
5956
|
+
}
|
|
5957
|
+
const result = applyWalletLifecycleEvent(state, body, "reverse");
|
|
5958
|
+
if (!result.ok) {
|
|
5959
|
+
sendJson(res, 409, result);
|
|
5960
|
+
return;
|
|
5961
|
+
}
|
|
5962
|
+
sendJson(res, 200, result);
|
|
5963
|
+
return;
|
|
5964
|
+
}
|
|
5965
|
+
|
|
5321
5966
|
if (req.method === "POST" && url.pathname === "/v1/economics/rails/credits/consume") {
|
|
5322
5967
|
const body = await readJsonBody(req);
|
|
5323
5968
|
const result = consumeAccountCredits(state, body);
|
|
@@ -5439,6 +6084,311 @@ async function routeRequest(req, res) {
|
|
|
5439
6084
|
return;
|
|
5440
6085
|
}
|
|
5441
6086
|
|
|
6087
|
+
if (req.method === "GET" && url.pathname === "/v1/account-auth/authority-bindings") {
|
|
6088
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6089
|
+
if (!authorization.ok) {
|
|
6090
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6091
|
+
return;
|
|
6092
|
+
}
|
|
6093
|
+
const bindings = listAuthorityBindings(state, Object.fromEntries(url.searchParams.entries()));
|
|
6094
|
+
sendJson(res, 200, {
|
|
6095
|
+
ok: true,
|
|
6096
|
+
auth_mode: authorization.auth_mode,
|
|
6097
|
+
authority_bindings: bindings
|
|
6098
|
+
});
|
|
6099
|
+
return;
|
|
6100
|
+
}
|
|
6101
|
+
|
|
6102
|
+
if (req.method === "GET" && url.pathname === "/v1/identity/bindings") {
|
|
6103
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6104
|
+
if (!authorization.ok) {
|
|
6105
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6106
|
+
return;
|
|
6107
|
+
}
|
|
6108
|
+
const bindings = listIdentityBindings(state, Object.fromEntries(url.searchParams.entries()));
|
|
6109
|
+
sendJson(res, 200, {
|
|
6110
|
+
ok: true,
|
|
6111
|
+
auth_mode: authorization.auth_mode,
|
|
6112
|
+
identity_bindings: bindings
|
|
6113
|
+
});
|
|
6114
|
+
return;
|
|
6115
|
+
}
|
|
6116
|
+
|
|
6117
|
+
if (req.method === "POST" && url.pathname === "/v1/identity/bindings") {
|
|
6118
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6119
|
+
if (!authorization.ok) {
|
|
6120
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6121
|
+
return;
|
|
6122
|
+
}
|
|
6123
|
+
const body = await readJsonBody(req);
|
|
6124
|
+
sendJson(res, 200, {
|
|
6125
|
+
ok: true,
|
|
6126
|
+
auth_mode: authorization.auth_mode,
|
|
6127
|
+
identity_binding: createIdentityBinding(state, body)
|
|
6128
|
+
});
|
|
6129
|
+
return;
|
|
6130
|
+
}
|
|
6131
|
+
|
|
6132
|
+
if (req.method === "POST" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-policy-bindings")) {
|
|
6133
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6134
|
+
if (!authorization.ok) {
|
|
6135
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6136
|
+
return;
|
|
6137
|
+
}
|
|
6138
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-policy-bindings$/, "");
|
|
6139
|
+
const body = await readJsonBody(req);
|
|
6140
|
+
const policySummary = buildMachineIdentityPolicyApplicationSummary(state, accountId, body && body.template_id ? body.template_id : null);
|
|
6141
|
+
const identityBinding = createIdentityBinding(state, mergeIdentityBindingPolicyPayload(policySummary, body, accountId));
|
|
6142
|
+
sendJson(res, 200, {
|
|
6143
|
+
ok: true,
|
|
6144
|
+
auth_mode: authorization.auth_mode,
|
|
6145
|
+
machine_identity_policy_application_summary: policySummary,
|
|
6146
|
+
identity_binding: identityBinding
|
|
6147
|
+
});
|
|
6148
|
+
return;
|
|
6149
|
+
}
|
|
6150
|
+
|
|
6151
|
+
if (req.method === "POST" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.includes("/machine-identity-policy-rotations/")) {
|
|
6152
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6153
|
+
if (!authorization.ok) {
|
|
6154
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6155
|
+
return;
|
|
6156
|
+
}
|
|
6157
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-policy-rotations\/.*$/, "");
|
|
6158
|
+
const bindingId = getDecodedSuffixId(url.pathname, `/v1/economics/accounts/${encodeURIComponent(accountId)}/machine-identity-policy-rotations/`);
|
|
6159
|
+
const body = await readJsonBody(req);
|
|
6160
|
+
const policySummary = buildMachineIdentityPolicyApplicationSummary(state, accountId, body && body.template_id ? body.template_id : null);
|
|
6161
|
+
const rotation = rotateIdentityBinding(state, bindingId, mergeIdentityBindingPolicyPayload(policySummary, body, accountId));
|
|
6162
|
+
if (!rotation) {
|
|
6163
|
+
sendJson(res, 404, { ok: false, reason: "identity_binding_not_found" });
|
|
6164
|
+
return;
|
|
6165
|
+
}
|
|
6166
|
+
sendJson(res, 200, {
|
|
6167
|
+
ok: true,
|
|
6168
|
+
auth_mode: authorization.auth_mode,
|
|
6169
|
+
machine_identity_policy_application_summary: policySummary,
|
|
6170
|
+
rotation
|
|
6171
|
+
});
|
|
6172
|
+
return;
|
|
6173
|
+
}
|
|
6174
|
+
|
|
6175
|
+
if (req.method === "POST" && url.pathname.endsWith("/revoke") && url.pathname.startsWith("/v1/identity/bindings/")) {
|
|
6176
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6177
|
+
if (!authorization.ok) {
|
|
6178
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6179
|
+
return;
|
|
6180
|
+
}
|
|
6181
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/identity/bindings/").replace(/\/revoke$/, "");
|
|
6182
|
+
const binding = revokeIdentityBinding(state, bindingId, await readJsonBody(req));
|
|
6183
|
+
if (!binding) {
|
|
6184
|
+
sendJson(res, 404, { ok: false, reason: "identity_binding_not_found" });
|
|
6185
|
+
return;
|
|
6186
|
+
}
|
|
6187
|
+
sendJson(res, 200, {
|
|
6188
|
+
ok: true,
|
|
6189
|
+
auth_mode: authorization.auth_mode,
|
|
6190
|
+
identity_binding: binding
|
|
6191
|
+
});
|
|
6192
|
+
return;
|
|
6193
|
+
}
|
|
6194
|
+
|
|
6195
|
+
if (req.method === "POST" && url.pathname.endsWith("/renew") && url.pathname.startsWith("/v1/identity/bindings/")) {
|
|
6196
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6197
|
+
if (!authorization.ok) {
|
|
6198
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6199
|
+
return;
|
|
6200
|
+
}
|
|
6201
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/identity/bindings/").replace(/\/renew$/, "");
|
|
6202
|
+
const binding = renewIdentityBinding(state, bindingId, await readJsonBody(req));
|
|
6203
|
+
if (!binding) {
|
|
6204
|
+
sendJson(res, 404, { ok: false, reason: "identity_binding_not_found" });
|
|
6205
|
+
return;
|
|
6206
|
+
}
|
|
6207
|
+
sendJson(res, 200, {
|
|
6208
|
+
ok: true,
|
|
6209
|
+
auth_mode: authorization.auth_mode,
|
|
6210
|
+
identity_binding: binding
|
|
6211
|
+
});
|
|
6212
|
+
return;
|
|
6213
|
+
}
|
|
6214
|
+
|
|
6215
|
+
if (req.method === "POST" && url.pathname.endsWith("/rotate") && url.pathname.startsWith("/v1/identity/bindings/")) {
|
|
6216
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6217
|
+
if (!authorization.ok) {
|
|
6218
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6219
|
+
return;
|
|
6220
|
+
}
|
|
6221
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/identity/bindings/").replace(/\/rotate$/, "");
|
|
6222
|
+
const rotation = rotateIdentityBinding(state, bindingId, await readJsonBody(req));
|
|
6223
|
+
if (!rotation) {
|
|
6224
|
+
sendJson(res, 404, { ok: false, reason: "identity_binding_not_found" });
|
|
6225
|
+
return;
|
|
6226
|
+
}
|
|
6227
|
+
sendJson(res, 200, {
|
|
6228
|
+
ok: true,
|
|
6229
|
+
auth_mode: authorization.auth_mode,
|
|
6230
|
+
rotation
|
|
6231
|
+
});
|
|
6232
|
+
return;
|
|
6233
|
+
}
|
|
6234
|
+
|
|
6235
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/identity/bindings/")) {
|
|
6236
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6237
|
+
if (!authorization.ok) {
|
|
6238
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6239
|
+
return;
|
|
6240
|
+
}
|
|
6241
|
+
if (url.pathname.endsWith("/rotation-summary")) {
|
|
6242
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/identity/bindings/").replace(/\/rotation-summary$/, "");
|
|
6243
|
+
const bindingSummary = getIdentityBindingRotationSummary(state, bindingId);
|
|
6244
|
+
if (!bindingSummary) {
|
|
6245
|
+
sendJson(res, 404, { ok: false, reason: "identity_binding_not_found" });
|
|
6246
|
+
return;
|
|
6247
|
+
}
|
|
6248
|
+
sendJson(res, 200, {
|
|
6249
|
+
ok: true,
|
|
6250
|
+
auth_mode: authorization.auth_mode,
|
|
6251
|
+
identity_binding_rotation_summary: bindingSummary
|
|
6252
|
+
});
|
|
6253
|
+
return;
|
|
6254
|
+
}
|
|
6255
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/identity/bindings/");
|
|
6256
|
+
const binding = getIdentityBinding(state, bindingId);
|
|
6257
|
+
if (!binding) {
|
|
6258
|
+
sendJson(res, 404, { ok: false, reason: "identity_binding_not_found" });
|
|
6259
|
+
return;
|
|
6260
|
+
}
|
|
6261
|
+
sendJson(res, 200, {
|
|
6262
|
+
ok: true,
|
|
6263
|
+
auth_mode: authorization.auth_mode,
|
|
6264
|
+
identity_binding: binding
|
|
6265
|
+
});
|
|
6266
|
+
return;
|
|
6267
|
+
}
|
|
6268
|
+
|
|
6269
|
+
if (req.method === "POST" && url.pathname === "/v1/account-auth/authority-bindings") {
|
|
6270
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6271
|
+
if (!authorization.ok) {
|
|
6272
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6273
|
+
return;
|
|
6274
|
+
}
|
|
6275
|
+
const body = await readJsonBody(req);
|
|
6276
|
+
sendJson(res, 200, {
|
|
6277
|
+
ok: true,
|
|
6278
|
+
auth_mode: authorization.auth_mode,
|
|
6279
|
+
authority_binding: createAuthorityBinding(state, body)
|
|
6280
|
+
});
|
|
6281
|
+
return;
|
|
6282
|
+
}
|
|
6283
|
+
|
|
6284
|
+
if (req.method === "POST" && url.pathname.endsWith("/revoke") && url.pathname.startsWith("/v1/account-auth/authority-bindings/")) {
|
|
6285
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6286
|
+
if (!authorization.ok) {
|
|
6287
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6288
|
+
return;
|
|
6289
|
+
}
|
|
6290
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/account-auth/authority-bindings/").replace(/\/revoke$/, "");
|
|
6291
|
+
const binding = revokeAuthorityBinding(state, bindingId, await readJsonBody(req));
|
|
6292
|
+
if (!binding) {
|
|
6293
|
+
sendJson(res, 404, { ok: false, reason: "authority_binding_not_found" });
|
|
6294
|
+
return;
|
|
6295
|
+
}
|
|
6296
|
+
sendJson(res, 200, {
|
|
6297
|
+
ok: true,
|
|
6298
|
+
auth_mode: authorization.auth_mode,
|
|
6299
|
+
authority_binding: binding
|
|
6300
|
+
});
|
|
6301
|
+
return;
|
|
6302
|
+
}
|
|
6303
|
+
|
|
6304
|
+
if (req.method === "POST" && url.pathname.endsWith("/renew") && url.pathname.startsWith("/v1/account-auth/authority-bindings/")) {
|
|
6305
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6306
|
+
if (!authorization.ok) {
|
|
6307
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6308
|
+
return;
|
|
6309
|
+
}
|
|
6310
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/account-auth/authority-bindings/").replace(/\/renew$/, "");
|
|
6311
|
+
const binding = renewAuthorityBinding(state, bindingId, await readJsonBody(req));
|
|
6312
|
+
if (!binding) {
|
|
6313
|
+
sendJson(res, 404, { ok: false, reason: "authority_binding_not_found" });
|
|
6314
|
+
return;
|
|
6315
|
+
}
|
|
6316
|
+
sendJson(res, 200, {
|
|
6317
|
+
ok: true,
|
|
6318
|
+
auth_mode: authorization.auth_mode,
|
|
6319
|
+
authority_binding: binding
|
|
6320
|
+
});
|
|
6321
|
+
return;
|
|
6322
|
+
}
|
|
6323
|
+
|
|
6324
|
+
if (req.method === "POST" && url.pathname.endsWith("/rotate") && url.pathname.startsWith("/v1/account-auth/authority-bindings/")) {
|
|
6325
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6326
|
+
if (!authorization.ok) {
|
|
6327
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6328
|
+
return;
|
|
6329
|
+
}
|
|
6330
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/account-auth/authority-bindings/").replace(/\/rotate$/, "");
|
|
6331
|
+
const rotation = rotateAuthorityBinding(state, bindingId, await readJsonBody(req));
|
|
6332
|
+
if (!rotation) {
|
|
6333
|
+
sendJson(res, 404, { ok: false, reason: "authority_binding_not_found" });
|
|
6334
|
+
return;
|
|
6335
|
+
}
|
|
6336
|
+
sendJson(res, 200, {
|
|
6337
|
+
ok: true,
|
|
6338
|
+
auth_mode: authorization.auth_mode,
|
|
6339
|
+
rotation
|
|
6340
|
+
});
|
|
6341
|
+
return;
|
|
6342
|
+
}
|
|
6343
|
+
|
|
6344
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/account-auth/authority-bindings/")) {
|
|
6345
|
+
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
6346
|
+
if (!authorization.ok) {
|
|
6347
|
+
sendJson(res, authorization.status, authorization.payload);
|
|
6348
|
+
return;
|
|
6349
|
+
}
|
|
6350
|
+
if (url.pathname.endsWith("/contract-summary")) {
|
|
6351
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/account-auth/authority-bindings/").replace(/\/contract-summary$/, "");
|
|
6352
|
+
const bindingSummary = getAuthorityBindingContractSummary(state, bindingId);
|
|
6353
|
+
if (!bindingSummary) {
|
|
6354
|
+
sendJson(res, 404, { ok: false, reason: "authority_binding_not_found" });
|
|
6355
|
+
return;
|
|
6356
|
+
}
|
|
6357
|
+
sendJson(res, 200, {
|
|
6358
|
+
ok: true,
|
|
6359
|
+
auth_mode: authorization.auth_mode,
|
|
6360
|
+
authority_binding_contract_summary: bindingSummary
|
|
6361
|
+
});
|
|
6362
|
+
return;
|
|
6363
|
+
}
|
|
6364
|
+
if (url.pathname.endsWith("/rotation-summary")) {
|
|
6365
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/account-auth/authority-bindings/").replace(/\/rotation-summary$/, "");
|
|
6366
|
+
const bindingSummary = getAuthorityBindingRotationSummary(state, bindingId);
|
|
6367
|
+
if (!bindingSummary) {
|
|
6368
|
+
sendJson(res, 404, { ok: false, reason: "authority_binding_not_found" });
|
|
6369
|
+
return;
|
|
6370
|
+
}
|
|
6371
|
+
sendJson(res, 200, {
|
|
6372
|
+
ok: true,
|
|
6373
|
+
auth_mode: authorization.auth_mode,
|
|
6374
|
+
authority_binding_rotation_summary: bindingSummary
|
|
6375
|
+
});
|
|
6376
|
+
return;
|
|
6377
|
+
}
|
|
6378
|
+
const bindingId = getDecodedSuffixId(url.pathname, "/v1/account-auth/authority-bindings/");
|
|
6379
|
+
const binding = getAuthorityBinding(state, bindingId);
|
|
6380
|
+
if (!binding) {
|
|
6381
|
+
sendJson(res, 404, { ok: false, reason: "authority_binding_not_found" });
|
|
6382
|
+
return;
|
|
6383
|
+
}
|
|
6384
|
+
sendJson(res, 200, {
|
|
6385
|
+
ok: true,
|
|
6386
|
+
auth_mode: authorization.auth_mode,
|
|
6387
|
+
authority_binding: binding
|
|
6388
|
+
});
|
|
6389
|
+
return;
|
|
6390
|
+
}
|
|
6391
|
+
|
|
5442
6392
|
if (req.method === "POST" && url.pathname.endsWith("/revoke") && url.pathname.startsWith("/v1/account-auth/spend-credentials/")) {
|
|
5443
6393
|
const authorization = verifyAccountAuthWriteAccess(req.headers || {});
|
|
5444
6394
|
if (!authorization.ok) {
|
|
@@ -5811,6 +6761,150 @@ async function routeRequest(req, res) {
|
|
|
5811
6761
|
return;
|
|
5812
6762
|
}
|
|
5813
6763
|
|
|
6764
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/wallet-lifecycle-summary")) {
|
|
6765
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/wallet-lifecycle-summary$/, "");
|
|
6766
|
+
sendJson(res, 200, buildWalletLifecycleSummary(state, accountId));
|
|
6767
|
+
return;
|
|
6768
|
+
}
|
|
6769
|
+
|
|
6770
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/wallet-reserve-summary")) {
|
|
6771
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/wallet-reserve-summary$/, "");
|
|
6772
|
+
sendJson(res, 200, buildWalletReserveSummary(state, accountId));
|
|
6773
|
+
return;
|
|
6774
|
+
}
|
|
6775
|
+
|
|
6776
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/wallet-commit-summary")) {
|
|
6777
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/wallet-commit-summary$/, "");
|
|
6778
|
+
sendJson(res, 200, buildWalletCommitSummary(state, accountId));
|
|
6779
|
+
return;
|
|
6780
|
+
}
|
|
6781
|
+
|
|
6782
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/wallet-ledger-bundle")) {
|
|
6783
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/wallet-ledger-bundle$/, "");
|
|
6784
|
+
sendJson(res, 200, buildWalletLedgerBundle(state, accountId));
|
|
6785
|
+
return;
|
|
6786
|
+
}
|
|
6787
|
+
|
|
6788
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/authority-summary")) {
|
|
6789
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/authority-summary$/, "");
|
|
6790
|
+
sendJson(res, 200, buildAuthoritySummary(state, accountId));
|
|
6791
|
+
return;
|
|
6792
|
+
}
|
|
6793
|
+
|
|
6794
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/authority-bundle")) {
|
|
6795
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/authority-bundle$/, "");
|
|
6796
|
+
sendJson(res, 200, buildAuthorityBundle(state, accountId));
|
|
6797
|
+
return;
|
|
6798
|
+
}
|
|
6799
|
+
|
|
6800
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/authority-usage-summary")) {
|
|
6801
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/authority-usage-summary$/, "");
|
|
6802
|
+
sendJson(res, 200, buildAuthorityUsageSummary(state, accountId));
|
|
6803
|
+
return;
|
|
6804
|
+
}
|
|
6805
|
+
|
|
6806
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/authority-review-bundle")) {
|
|
6807
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/authority-review-bundle$/, "");
|
|
6808
|
+
sendJson(res, 200, buildAuthorityReviewBundle(state, accountId));
|
|
6809
|
+
return;
|
|
6810
|
+
}
|
|
6811
|
+
|
|
6812
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/authority-attention-summary")) {
|
|
6813
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/authority-attention-summary$/, "");
|
|
6814
|
+
sendJson(res, 200, buildAuthorityAttentionSummary(state, accountId));
|
|
6815
|
+
return;
|
|
6816
|
+
}
|
|
6817
|
+
|
|
6818
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/authority-lineage-summary")) {
|
|
6819
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/authority-lineage-summary$/, "");
|
|
6820
|
+
sendJson(res, 200, buildAuthorityLineageSummary(state, accountId));
|
|
6821
|
+
return;
|
|
6822
|
+
}
|
|
6823
|
+
|
|
6824
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/authority-policy-pack/summary")) {
|
|
6825
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/authority-policy-pack\/summary$/, "");
|
|
6826
|
+
sendJson(res, 200, buildAuthorityPolicyPackSummary(state, accountId));
|
|
6827
|
+
return;
|
|
6828
|
+
}
|
|
6829
|
+
|
|
6830
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/authority-policy-pack")) {
|
|
6831
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/authority-policy-pack$/, "");
|
|
6832
|
+
sendJson(res, 200, buildAuthorityPolicyPack(state, accountId));
|
|
6833
|
+
return;
|
|
6834
|
+
}
|
|
6835
|
+
|
|
6836
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-summary")) {
|
|
6837
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-summary$/, "");
|
|
6838
|
+
sendJson(res, 200, buildMachineIdentitySummary(state, accountId));
|
|
6839
|
+
return;
|
|
6840
|
+
}
|
|
6841
|
+
|
|
6842
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-bundle")) {
|
|
6843
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-bundle$/, "");
|
|
6844
|
+
sendJson(res, 200, buildMachineIdentityBundle(state, accountId));
|
|
6845
|
+
return;
|
|
6846
|
+
}
|
|
6847
|
+
|
|
6848
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-attachment-summary")) {
|
|
6849
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-attachment-summary$/, "");
|
|
6850
|
+
sendJson(res, 200, buildMachineIdentityAttachmentSummary(state, accountId));
|
|
6851
|
+
return;
|
|
6852
|
+
}
|
|
6853
|
+
|
|
6854
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-lineage-summary")) {
|
|
6855
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-lineage-summary$/, "");
|
|
6856
|
+
sendJson(res, 200, buildMachineIdentityLineageSummary(state, accountId));
|
|
6857
|
+
return;
|
|
6858
|
+
}
|
|
6859
|
+
|
|
6860
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-binding-lineage-summary")) {
|
|
6861
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-binding-lineage-summary$/, "");
|
|
6862
|
+
sendJson(res, 200, buildMachineIdentityBindingLineageSummary(state, accountId));
|
|
6863
|
+
return;
|
|
6864
|
+
}
|
|
6865
|
+
|
|
6866
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-profile")) {
|
|
6867
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-profile$/, "");
|
|
6868
|
+
sendJson(res, 200, buildMachineIdentityProfile(state, accountId));
|
|
6869
|
+
return;
|
|
6870
|
+
}
|
|
6871
|
+
|
|
6872
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-policy-pack/summary")) {
|
|
6873
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-policy-pack\/summary$/, "");
|
|
6874
|
+
sendJson(res, 200, buildMachineIdentityPolicyPackSummary(state, accountId));
|
|
6875
|
+
return;
|
|
6876
|
+
}
|
|
6877
|
+
|
|
6878
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-policy-application-summary")) {
|
|
6879
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-policy-application-summary$/, "");
|
|
6880
|
+
sendJson(res, 200, buildMachineIdentityPolicyApplicationSummary(state, accountId, url.searchParams.get("template_id")));
|
|
6881
|
+
return;
|
|
6882
|
+
}
|
|
6883
|
+
|
|
6884
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-policy-pack")) {
|
|
6885
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-policy-pack$/, "");
|
|
6886
|
+
sendJson(res, 200, buildMachineIdentityPolicyPack(state, accountId));
|
|
6887
|
+
return;
|
|
6888
|
+
}
|
|
6889
|
+
|
|
6890
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-review-bundle")) {
|
|
6891
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-review-bundle$/, "");
|
|
6892
|
+
sendJson(res, 200, buildMachineIdentityReviewBundle(state, accountId));
|
|
6893
|
+
return;
|
|
6894
|
+
}
|
|
6895
|
+
|
|
6896
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-attention-summary")) {
|
|
6897
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-attention-summary$/, "");
|
|
6898
|
+
sendJson(res, 200, buildMachineIdentityAttentionSummary(state, accountId));
|
|
6899
|
+
return;
|
|
6900
|
+
}
|
|
6901
|
+
|
|
6902
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/machine-identity-operator-bundle")) {
|
|
6903
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/machine-identity-operator-bundle$/, "");
|
|
6904
|
+
sendJson(res, 200, buildMachineIdentityOperatorBundle(state, accountId));
|
|
6905
|
+
return;
|
|
6906
|
+
}
|
|
6907
|
+
|
|
5814
6908
|
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/wallet-ledger-summary")) {
|
|
5815
6909
|
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/wallet-ledger-summary$/, "");
|
|
5816
6910
|
sendJson(res, 200, buildWalletLedgerSummary(state, accountId));
|
|
@@ -5980,6 +7074,456 @@ async function routeRequest(req, res) {
|
|
|
5980
7074
|
return;
|
|
5981
7075
|
}
|
|
5982
7076
|
|
|
7077
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/pricing-policy-summary")) {
|
|
7078
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/pricing-policy-summary$/, "");
|
|
7079
|
+
sendJson(res, 200, buildPricingPolicySummary(state, accountId));
|
|
7080
|
+
return;
|
|
7081
|
+
}
|
|
7082
|
+
|
|
7083
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/pricing-policy-operator-bundle")) {
|
|
7084
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/pricing-policy-operator-bundle$/, "");
|
|
7085
|
+
sendJson(res, 200, buildPricingPolicyOperatorBundle(state, accountId));
|
|
7086
|
+
return;
|
|
7087
|
+
}
|
|
7088
|
+
|
|
7089
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/pricing-policy-pack")) {
|
|
7090
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/pricing-policy-pack$/, "");
|
|
7091
|
+
sendJson(res, 200, buildPricingPolicyPack(state, accountId));
|
|
7092
|
+
return;
|
|
7093
|
+
}
|
|
7094
|
+
|
|
7095
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/pricing-policy-application-summary")) {
|
|
7096
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/pricing-policy-application-summary$/, "");
|
|
7097
|
+
sendJson(res, 200, buildPricingPolicyApplicationSummary(state, accountId, url.searchParams.get("template_id") || null));
|
|
7098
|
+
return;
|
|
7099
|
+
}
|
|
7100
|
+
|
|
7101
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/pricing-policy-package")) {
|
|
7102
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/pricing-policy-package$/, "");
|
|
7103
|
+
sendJson(res, 200, buildPricingPolicyPackage(state, accountId));
|
|
7104
|
+
return;
|
|
7105
|
+
}
|
|
7106
|
+
|
|
7107
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/quote-policy-decision-summary")) {
|
|
7108
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/quote-policy-decision-summary$/, "");
|
|
7109
|
+
sendJson(res, 200, buildQuotePolicyDecisionSummary(state, {
|
|
7110
|
+
account_id: accountId,
|
|
7111
|
+
task_ref: url.searchParams.get("task_ref") || null,
|
|
7112
|
+
workflow_ref: url.searchParams.get("workflow_ref") || null,
|
|
7113
|
+
quoted_units: Number.isFinite(Number(url.searchParams.get("quoted_units"))) ? Number(url.searchParams.get("quoted_units")) : null,
|
|
7114
|
+
agent_id: url.searchParams.get("agent_id") || null,
|
|
7115
|
+
budget_id: url.searchParams.get("budget_id") || null
|
|
7116
|
+
}));
|
|
7117
|
+
return;
|
|
7118
|
+
}
|
|
7119
|
+
|
|
7120
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/pricing-band-decision-summary")) {
|
|
7121
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/pricing-band-decision-summary$/, "");
|
|
7122
|
+
sendJson(res, 200, buildPricingBandDecisionSummary(state, {
|
|
7123
|
+
account_id: accountId,
|
|
7124
|
+
task_ref: url.searchParams.get("task_ref") || null,
|
|
7125
|
+
workflow_ref: url.searchParams.get("workflow_ref") || null,
|
|
7126
|
+
quoted_units: Number.isFinite(Number(url.searchParams.get("quoted_units"))) ? Number(url.searchParams.get("quoted_units")) : null
|
|
7127
|
+
}));
|
|
7128
|
+
return;
|
|
7129
|
+
}
|
|
7130
|
+
|
|
7131
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/quote-policy-operator-bundle")) {
|
|
7132
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/quote-policy-operator-bundle$/, "");
|
|
7133
|
+
sendJson(res, 200, buildQuotePolicyOperatorBundle(state, {
|
|
7134
|
+
account_id: accountId,
|
|
7135
|
+
task_ref: url.searchParams.get("task_ref") || null,
|
|
7136
|
+
workflow_ref: url.searchParams.get("workflow_ref") || null,
|
|
7137
|
+
quoted_units: Number.isFinite(Number(url.searchParams.get("quoted_units"))) ? Number(url.searchParams.get("quoted_units")) : null,
|
|
7138
|
+
agent_id: url.searchParams.get("agent_id") || null,
|
|
7139
|
+
budget_id: url.searchParams.get("budget_id") || null
|
|
7140
|
+
}));
|
|
7141
|
+
return;
|
|
7142
|
+
}
|
|
7143
|
+
|
|
7144
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/quote-policy-operator-bundle/summary")) {
|
|
7145
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/quote-policy-operator-bundle\/summary$/, "");
|
|
7146
|
+
sendJson(res, 200, summarizeQuotePolicyOperatorBundle(state, {
|
|
7147
|
+
account_id: accountId,
|
|
7148
|
+
task_ref: url.searchParams.get("task_ref") || null,
|
|
7149
|
+
workflow_ref: url.searchParams.get("workflow_ref") || null,
|
|
7150
|
+
quoted_units: Number.isFinite(Number(url.searchParams.get("quoted_units"))) ? Number(url.searchParams.get("quoted_units")) : null,
|
|
7151
|
+
agent_id: url.searchParams.get("agent_id") || null,
|
|
7152
|
+
budget_id: url.searchParams.get("budget_id") || null
|
|
7153
|
+
}));
|
|
7154
|
+
return;
|
|
7155
|
+
}
|
|
7156
|
+
|
|
7157
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/quote-policy-pack")) {
|
|
7158
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/quote-policy-pack$/, "");
|
|
7159
|
+
sendJson(res, 200, buildQuotePolicyPack(state, {
|
|
7160
|
+
account_id: accountId,
|
|
7161
|
+
task_ref: url.searchParams.get("task_ref") || null,
|
|
7162
|
+
workflow_ref: url.searchParams.get("workflow_ref") || null,
|
|
7163
|
+
quoted_units: Number.isFinite(Number(url.searchParams.get("quoted_units"))) ? Number(url.searchParams.get("quoted_units")) : null,
|
|
7164
|
+
agent_id: url.searchParams.get("agent_id") || null,
|
|
7165
|
+
budget_id: url.searchParams.get("budget_id") || null
|
|
7166
|
+
}));
|
|
7167
|
+
return;
|
|
7168
|
+
}
|
|
7169
|
+
|
|
7170
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/quote-policy-pack/summary")) {
|
|
7171
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/quote-policy-pack\/summary$/, "");
|
|
7172
|
+
sendJson(res, 200, summarizeQuotePolicyPack(state, {
|
|
7173
|
+
account_id: accountId,
|
|
7174
|
+
task_ref: url.searchParams.get("task_ref") || null,
|
|
7175
|
+
workflow_ref: url.searchParams.get("workflow_ref") || null,
|
|
7176
|
+
quoted_units: Number.isFinite(Number(url.searchParams.get("quoted_units"))) ? Number(url.searchParams.get("quoted_units")) : null,
|
|
7177
|
+
agent_id: url.searchParams.get("agent_id") || null,
|
|
7178
|
+
budget_id: url.searchParams.get("budget_id") || null
|
|
7179
|
+
}));
|
|
7180
|
+
return;
|
|
7181
|
+
}
|
|
7182
|
+
|
|
7183
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/quote-policy-application-summary")) {
|
|
7184
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/quote-policy-application-summary$/, "");
|
|
7185
|
+
sendJson(res, 200, buildQuotePolicyApplicationSummary(state, {
|
|
7186
|
+
account_id: accountId,
|
|
7187
|
+
task_ref: url.searchParams.get("task_ref") || null,
|
|
7188
|
+
workflow_ref: url.searchParams.get("workflow_ref") || null,
|
|
7189
|
+
quoted_units: Number.isFinite(Number(url.searchParams.get("quoted_units"))) ? Number(url.searchParams.get("quoted_units")) : null,
|
|
7190
|
+
agent_id: url.searchParams.get("agent_id") || null,
|
|
7191
|
+
budget_id: url.searchParams.get("budget_id") || null,
|
|
7192
|
+
template_id: url.searchParams.get("template_id") || null
|
|
7193
|
+
}));
|
|
7194
|
+
return;
|
|
7195
|
+
}
|
|
7196
|
+
|
|
7197
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/quote-policy-package")) {
|
|
7198
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/quote-policy-package$/, "");
|
|
7199
|
+
sendJson(res, 200, buildQuotePolicyPackage(state, {
|
|
7200
|
+
account_id: accountId,
|
|
7201
|
+
task_ref: url.searchParams.get("task_ref") || null,
|
|
7202
|
+
workflow_ref: url.searchParams.get("workflow_ref") || null,
|
|
7203
|
+
quoted_units: Number.isFinite(Number(url.searchParams.get("quoted_units"))) ? Number(url.searchParams.get("quoted_units")) : null,
|
|
7204
|
+
agent_id: url.searchParams.get("agent_id") || null,
|
|
7205
|
+
budget_id: url.searchParams.get("budget_id") || null
|
|
7206
|
+
}));
|
|
7207
|
+
return;
|
|
7208
|
+
}
|
|
7209
|
+
|
|
7210
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/quote-policy-package/summary")) {
|
|
7211
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/quote-policy-package\/summary$/, "");
|
|
7212
|
+
sendJson(res, 200, summarizeQuotePolicyPackage(state, {
|
|
7213
|
+
account_id: accountId,
|
|
7214
|
+
task_ref: url.searchParams.get("task_ref") || null,
|
|
7215
|
+
workflow_ref: url.searchParams.get("workflow_ref") || null,
|
|
7216
|
+
quoted_units: Number.isFinite(Number(url.searchParams.get("quoted_units"))) ? Number(url.searchParams.get("quoted_units")) : null,
|
|
7217
|
+
agent_id: url.searchParams.get("agent_id") || null,
|
|
7218
|
+
budget_id: url.searchParams.get("budget_id") || null
|
|
7219
|
+
}));
|
|
7220
|
+
return;
|
|
7221
|
+
}
|
|
7222
|
+
|
|
7223
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/trust-layer-summary")) {
|
|
7224
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/trust-layer-summary$/, "");
|
|
7225
|
+
sendJson(res, 200, buildTrustLayerSummary(state, accountId));
|
|
7226
|
+
return;
|
|
7227
|
+
}
|
|
7228
|
+
|
|
7229
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/trust-input-summary")) {
|
|
7230
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/trust-input-summary$/, "");
|
|
7231
|
+
sendJson(res, 200, buildTrustInputSummary(state, accountId));
|
|
7232
|
+
return;
|
|
7233
|
+
}
|
|
7234
|
+
|
|
7235
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/trust-layer-operator-bundle")) {
|
|
7236
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/trust-layer-operator-bundle$/, "");
|
|
7237
|
+
sendJson(res, 200, buildTrustLayerOperatorBundle(state, accountId));
|
|
7238
|
+
return;
|
|
7239
|
+
}
|
|
7240
|
+
|
|
7241
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/trust-layer-operator-bundle/summary")) {
|
|
7242
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/trust-layer-operator-bundle\/summary$/, "");
|
|
7243
|
+
sendJson(res, 200, summarizeTrustLayerOperatorBundle(state, accountId));
|
|
7244
|
+
return;
|
|
7245
|
+
}
|
|
7246
|
+
|
|
7247
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/trust-layer-policy-pack")) {
|
|
7248
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/trust-layer-policy-pack$/, "");
|
|
7249
|
+
sendJson(res, 200, buildTrustLayerPolicyPack(state, accountId));
|
|
7250
|
+
return;
|
|
7251
|
+
}
|
|
7252
|
+
|
|
7253
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/trust-layer-policy-pack/summary")) {
|
|
7254
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/trust-layer-policy-pack\/summary$/, "");
|
|
7255
|
+
sendJson(res, 200, summarizeTrustLayerPolicyPack(state, accountId));
|
|
7256
|
+
return;
|
|
7257
|
+
}
|
|
7258
|
+
|
|
7259
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/trust-layer-application-summary")) {
|
|
7260
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/trust-layer-application-summary$/, "");
|
|
7261
|
+
sendJson(res, 200, buildTrustLayerApplicationSummary(state, accountId, url.searchParams.get("template_id") || null));
|
|
7262
|
+
return;
|
|
7263
|
+
}
|
|
7264
|
+
|
|
7265
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/trust-layer-package")) {
|
|
7266
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/trust-layer-package$/, "");
|
|
7267
|
+
sendJson(res, 200, buildTrustLayerPackage(state, accountId));
|
|
7268
|
+
return;
|
|
7269
|
+
}
|
|
7270
|
+
|
|
7271
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/trust-layer-package/summary")) {
|
|
7272
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/trust-layer-package\/summary$/, "");
|
|
7273
|
+
sendJson(res, 200, summarizeTrustLayerPackage(state, accountId));
|
|
7274
|
+
return;
|
|
7275
|
+
}
|
|
7276
|
+
|
|
7277
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participation-summary")) {
|
|
7278
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participation-summary$/, "");
|
|
7279
|
+
sendJson(res, 200, buildMultiOperatorParticipationSummary(state, accountId));
|
|
7280
|
+
return;
|
|
7281
|
+
}
|
|
7282
|
+
|
|
7283
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participation-operator-bundle")) {
|
|
7284
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participation-operator-bundle$/, "");
|
|
7285
|
+
sendJson(res, 200, buildMultiOperatorParticipationOperatorBundle(state, accountId));
|
|
7286
|
+
return;
|
|
7287
|
+
}
|
|
7288
|
+
|
|
7289
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participation-operator-bundle/summary")) {
|
|
7290
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participation-operator-bundle\/summary$/, "");
|
|
7291
|
+
sendJson(res, 200, summarizeMultiOperatorParticipationOperatorBundle(state, accountId));
|
|
7292
|
+
return;
|
|
7293
|
+
}
|
|
7294
|
+
|
|
7295
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participation-policy-pack")) {
|
|
7296
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participation-policy-pack$/, "");
|
|
7297
|
+
sendJson(res, 200, buildMultiOperatorParticipationPolicyPack(state, accountId));
|
|
7298
|
+
return;
|
|
7299
|
+
}
|
|
7300
|
+
|
|
7301
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participation-policy-pack/summary")) {
|
|
7302
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participation-policy-pack\/summary$/, "");
|
|
7303
|
+
sendJson(res, 200, summarizeMultiOperatorParticipationPolicyPack(state, accountId));
|
|
7304
|
+
return;
|
|
7305
|
+
}
|
|
7306
|
+
|
|
7307
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participation-application-summary")) {
|
|
7308
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participation-application-summary$/, "");
|
|
7309
|
+
sendJson(res, 200, buildMultiOperatorParticipationApplicationSummary(state, accountId, url.searchParams.get("template_id") || null));
|
|
7310
|
+
return;
|
|
7311
|
+
}
|
|
7312
|
+
|
|
7313
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participation-package")) {
|
|
7314
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participation-package$/, "");
|
|
7315
|
+
sendJson(res, 200, buildMultiOperatorParticipationPackage(state, accountId));
|
|
7316
|
+
return;
|
|
7317
|
+
}
|
|
7318
|
+
|
|
7319
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participation-package/summary")) {
|
|
7320
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participation-package\/summary$/, "");
|
|
7321
|
+
sendJson(res, 200, summarizeMultiOperatorParticipationPackage(state, accountId));
|
|
7322
|
+
return;
|
|
7323
|
+
}
|
|
7324
|
+
|
|
7325
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/network-participation-summary")) {
|
|
7326
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/network-participation-summary$/, "");
|
|
7327
|
+
sendJson(res, 200, buildNetworkParticipationSummary(state, accountId));
|
|
7328
|
+
return;
|
|
7329
|
+
}
|
|
7330
|
+
|
|
7331
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/network-participation-operator-bundle")) {
|
|
7332
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/network-participation-operator-bundle$/, "");
|
|
7333
|
+
sendJson(res, 200, buildNetworkParticipationOperatorBundle(state, accountId));
|
|
7334
|
+
return;
|
|
7335
|
+
}
|
|
7336
|
+
|
|
7337
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/network-participation-package")) {
|
|
7338
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/network-participation-package$/, "");
|
|
7339
|
+
sendJson(res, 200, buildNetworkParticipationPackage(state, accountId));
|
|
7340
|
+
return;
|
|
7341
|
+
}
|
|
7342
|
+
|
|
7343
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/network-participation-review-bundle")) {
|
|
7344
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/network-participation-review-bundle$/, "");
|
|
7345
|
+
sendJson(res, 200, buildNetworkParticipationReviewBundle(state, accountId));
|
|
7346
|
+
return;
|
|
7347
|
+
}
|
|
7348
|
+
|
|
7349
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/network-participation-attention-summary")) {
|
|
7350
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/network-participation-attention-summary$/, "");
|
|
7351
|
+
sendJson(res, 200, buildNetworkParticipationAttentionSummary(state, accountId));
|
|
7352
|
+
return;
|
|
7353
|
+
}
|
|
7354
|
+
|
|
7355
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/network-participants")) {
|
|
7356
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/network-participants$/, "");
|
|
7357
|
+
sendJson(res, 200, {
|
|
7358
|
+
ok: true,
|
|
7359
|
+
account_id: accountId,
|
|
7360
|
+
count: listNetworkParticipants(state, accountId).length,
|
|
7361
|
+
participants: listNetworkParticipants(state, accountId)
|
|
7362
|
+
});
|
|
7363
|
+
return;
|
|
7364
|
+
}
|
|
7365
|
+
|
|
7366
|
+
if (
|
|
7367
|
+
req.method === "GET"
|
|
7368
|
+
&& url.pathname.startsWith("/v1/economics/accounts/")
|
|
7369
|
+
&& url.pathname.includes("/network-participants/")
|
|
7370
|
+
) {
|
|
7371
|
+
const remainder = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/");
|
|
7372
|
+
const [accountId, participantPath] = remainder.split("/network-participants/");
|
|
7373
|
+
const participantId = participantPath;
|
|
7374
|
+
const participant = getNetworkParticipant(state, accountId, participantId);
|
|
7375
|
+
if (!participant) {
|
|
7376
|
+
sendJson(res, 404, { ok: false, reason: "network_participant_not_found" });
|
|
7377
|
+
return;
|
|
7378
|
+
}
|
|
7379
|
+
sendJson(res, 200, { ok: true, participant });
|
|
7380
|
+
return;
|
|
7381
|
+
}
|
|
7382
|
+
|
|
7383
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participants")) {
|
|
7384
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participants$/, "");
|
|
7385
|
+
sendJson(res, 200, {
|
|
7386
|
+
ok: true,
|
|
7387
|
+
account_id: accountId,
|
|
7388
|
+
count: listMultiOperatorParticipants(state, accountId).length,
|
|
7389
|
+
participants: listMultiOperatorParticipants(state, accountId)
|
|
7390
|
+
});
|
|
7391
|
+
return;
|
|
7392
|
+
}
|
|
7393
|
+
|
|
7394
|
+
if (req.method === "POST" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participants")) {
|
|
7395
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participants$/, "");
|
|
7396
|
+
const body = await readJsonBody(req);
|
|
7397
|
+
sendJson(res, 200, { ok: true, admission: createMultiOperatorParticipant(state, accountId, body) });
|
|
7398
|
+
return;
|
|
7399
|
+
}
|
|
7400
|
+
|
|
7401
|
+
if (
|
|
7402
|
+
req.method === "GET"
|
|
7403
|
+
&& url.pathname.startsWith("/v1/economics/accounts/")
|
|
7404
|
+
&& url.pathname.includes("/multi-operator-participants/")
|
|
7405
|
+
&& !url.pathname.endsWith("/rotation-summary")
|
|
7406
|
+
) {
|
|
7407
|
+
const remainder = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/");
|
|
7408
|
+
const [accountId, participantPath] = remainder.split("/multi-operator-participants/");
|
|
7409
|
+
const participantId = participantPath;
|
|
7410
|
+
const participant = getMultiOperatorParticipant(state, accountId, participantId);
|
|
7411
|
+
if (!participant) {
|
|
7412
|
+
sendJson(res, 404, { ok: false, reason: "multi_operator_participant_not_found" });
|
|
7413
|
+
return;
|
|
7414
|
+
}
|
|
7415
|
+
sendJson(res, 200, { ok: true, participant });
|
|
7416
|
+
return;
|
|
7417
|
+
}
|
|
7418
|
+
|
|
7419
|
+
if (
|
|
7420
|
+
req.method === "GET"
|
|
7421
|
+
&& url.pathname.startsWith("/v1/economics/accounts/")
|
|
7422
|
+
&& url.pathname.includes("/multi-operator-participants/")
|
|
7423
|
+
&& url.pathname.endsWith("/rotation-summary")
|
|
7424
|
+
) {
|
|
7425
|
+
const remainder = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/");
|
|
7426
|
+
const [accountId, participantPath] = remainder.split("/multi-operator-participants/");
|
|
7427
|
+
const participantId = participantPath.replace(/\/rotation-summary$/, "");
|
|
7428
|
+
const summary = buildMultiOperatorParticipantRotationSummary(state, accountId, participantId);
|
|
7429
|
+
if (!summary) {
|
|
7430
|
+
sendJson(res, 404, { ok: false, reason: "multi_operator_participant_not_found" });
|
|
7431
|
+
return;
|
|
7432
|
+
}
|
|
7433
|
+
sendJson(res, 200, summary);
|
|
7434
|
+
return;
|
|
7435
|
+
}
|
|
7436
|
+
|
|
7437
|
+
if (
|
|
7438
|
+
req.method === "POST"
|
|
7439
|
+
&& url.pathname.startsWith("/v1/economics/accounts/")
|
|
7440
|
+
&& url.pathname.includes("/multi-operator-participants/")
|
|
7441
|
+
&& url.pathname.endsWith("/renew")
|
|
7442
|
+
) {
|
|
7443
|
+
const remainder = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/");
|
|
7444
|
+
const [accountId, participantPath] = remainder.split("/multi-operator-participants/");
|
|
7445
|
+
const participantId = participantPath.replace(/\/renew$/, "");
|
|
7446
|
+
const body = await readJsonBody(req);
|
|
7447
|
+
const renewed = renewMultiOperatorParticipant(state, accountId, participantId, body);
|
|
7448
|
+
if (!renewed) {
|
|
7449
|
+
sendJson(res, 404, { ok: false, reason: "multi_operator_participant_not_found" });
|
|
7450
|
+
return;
|
|
7451
|
+
}
|
|
7452
|
+
sendJson(res, 200, { ok: true, renewal: renewed });
|
|
7453
|
+
return;
|
|
7454
|
+
}
|
|
7455
|
+
|
|
7456
|
+
if (
|
|
7457
|
+
req.method === "POST"
|
|
7458
|
+
&& url.pathname.startsWith("/v1/economics/accounts/")
|
|
7459
|
+
&& url.pathname.includes("/multi-operator-participants/")
|
|
7460
|
+
&& url.pathname.endsWith("/rotate")
|
|
7461
|
+
) {
|
|
7462
|
+
const remainder = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/");
|
|
7463
|
+
const [accountId, participantPath] = remainder.split("/multi-operator-participants/");
|
|
7464
|
+
const participantId = participantPath.replace(/\/rotate$/, "");
|
|
7465
|
+
const body = await readJsonBody(req);
|
|
7466
|
+
const rotation = rotateMultiOperatorParticipant(state, accountId, participantId, body);
|
|
7467
|
+
if (!rotation) {
|
|
7468
|
+
sendJson(res, 404, { ok: false, reason: "multi_operator_participant_not_found" });
|
|
7469
|
+
return;
|
|
7470
|
+
}
|
|
7471
|
+
sendJson(res, 200, { ok: true, rotation });
|
|
7472
|
+
return;
|
|
7473
|
+
}
|
|
7474
|
+
|
|
7475
|
+
if (
|
|
7476
|
+
req.method === "POST"
|
|
7477
|
+
&& url.pathname.startsWith("/v1/economics/accounts/")
|
|
7478
|
+
&& url.pathname.includes("/multi-operator-participants/")
|
|
7479
|
+
&& url.pathname.endsWith("/revoke")
|
|
7480
|
+
) {
|
|
7481
|
+
const remainder = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/");
|
|
7482
|
+
const [accountId, participantPath] = remainder.split("/multi-operator-participants/");
|
|
7483
|
+
const participantId = participantPath.replace(/\/revoke$/, "");
|
|
7484
|
+
const body = await readJsonBody(req);
|
|
7485
|
+
const revoked = revokeMultiOperatorParticipant(state, accountId, participantId, body);
|
|
7486
|
+
if (!revoked) {
|
|
7487
|
+
sendJson(res, 404, { ok: false, reason: "multi_operator_participant_not_found" });
|
|
7488
|
+
return;
|
|
7489
|
+
}
|
|
7490
|
+
sendJson(res, 200, { ok: true, revocation: revoked });
|
|
7491
|
+
return;
|
|
7492
|
+
}
|
|
7493
|
+
|
|
7494
|
+
if (req.method === "POST" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-participation/admission-preview")) {
|
|
7495
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-participation\/admission-preview$/, "");
|
|
7496
|
+
const body = await readJsonBody(req);
|
|
7497
|
+
sendJson(res, 200, { ok: true, admission_preview: buildMultiOperatorAdmissionPreview(state, accountId, body) });
|
|
7498
|
+
return;
|
|
7499
|
+
}
|
|
7500
|
+
|
|
7501
|
+
if (req.method === "POST" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/network-participation/admission-preview")) {
|
|
7502
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/network-participation\/admission-preview$/, "");
|
|
7503
|
+
const body = await readJsonBody(req);
|
|
7504
|
+
sendJson(res, 200, { ok: true, admission_preview: buildNetworkParticipationAdmissionPreview(state, accountId, body) });
|
|
7505
|
+
return;
|
|
7506
|
+
}
|
|
7507
|
+
|
|
7508
|
+
if (req.method === "POST" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/network-participants")) {
|
|
7509
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/network-participants$/, "");
|
|
7510
|
+
const body = await readJsonBody(req);
|
|
7511
|
+
sendJson(res, 200, { ok: true, admission: createNetworkParticipant(state, accountId, body) });
|
|
7512
|
+
return;
|
|
7513
|
+
}
|
|
7514
|
+
|
|
7515
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-review-bundle")) {
|
|
7516
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-review-bundle$/, "");
|
|
7517
|
+
sendJson(res, 200, buildMultiOperatorReviewBundle(state, accountId));
|
|
7518
|
+
return;
|
|
7519
|
+
}
|
|
7520
|
+
|
|
7521
|
+
if (req.method === "GET" && url.pathname.startsWith("/v1/economics/accounts/") && url.pathname.endsWith("/multi-operator-attention-summary")) {
|
|
7522
|
+
const accountId = getDecodedSuffixId(url.pathname, "/v1/economics/accounts/").replace(/\/multi-operator-attention-summary$/, "");
|
|
7523
|
+
sendJson(res, 200, buildMultiOperatorAttentionSummary(state, accountId));
|
|
7524
|
+
return;
|
|
7525
|
+
}
|
|
7526
|
+
|
|
5983
7527
|
if (
|
|
5984
7528
|
req.method === "GET"
|
|
5985
7529
|
&& url.pathname.startsWith("/v1/economics/accounts/")
|