@xapps-platform/backend-kit 0.1.1 → 0.1.3

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.
Files changed (33) hide show
  1. package/README.md +35 -0
  2. package/dist/backend/modes/gateway-managed/policy.d.ts +2 -2
  3. package/dist/backend/modes/owner-managed/policy.d.ts +2 -2
  4. package/dist/backend/modes/publisher-delegated/policy.d.ts +2 -2
  5. package/dist/backend/modes/tenant-delegated/policy.d.ts +2 -2
  6. package/dist/backend/modules.d.ts +75 -24
  7. package/dist/backend/modules.d.ts.map +1 -1
  8. package/dist/backend/modules.js +6 -2
  9. package/dist/backend/modules.js.map +2 -2
  10. package/dist/backend/options.d.ts +40 -28
  11. package/dist/backend/options.d.ts.map +1 -1
  12. package/dist/backend/options.js +14 -12
  13. package/dist/backend/options.js.map +2 -2
  14. package/dist/backend/paymentRuntime.d.ts +3 -3
  15. package/dist/backend/paymentRuntime.d.ts.map +1 -1
  16. package/dist/backend/paymentRuntime.js +1 -1
  17. package/dist/backend/paymentRuntime.js.map +1 -1
  18. package/dist/backend/policies/common.d.ts +2 -2
  19. package/dist/backend/policies/common.d.ts.map +1 -1
  20. package/dist/backend/policies/common.js +1 -1
  21. package/dist/backend/policies/common.js.map +1 -1
  22. package/dist/backend/routes/gateway/shared.js +1 -1
  23. package/dist/backend/routes/gateway/shared.js.map +1 -1
  24. package/dist/backend/routes/health.d.ts +23 -1
  25. package/dist/backend/routes/health.d.ts.map +1 -1
  26. package/dist/backend/routes/health.js.map +2 -2
  27. package/dist/backend/routes/reference.js +4 -4
  28. package/dist/backend/routes/reference.js.map +1 -1
  29. package/dist/index.d.ts +45 -6
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +11 -8
  32. package/dist/index.js.map +3 -3
  33. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/backend/paymentRuntime.ts"],
4
- "sourcesContent": ["// @ts-nocheck\nimport fs from \"node:fs\";\nimport {\n buildHostedGatewayPaymentUrlFromGuardContext,\n createPaymentHandlerAsync,\n extractHostedPaymentSessionId,\n} from \"@xapps/server-sdk\";\nimport { normalizeOwnerIssuer, readRecord, readString } from \"./options.js\";\n\nfunction mapHostedSessionResult(input = {}) {\n return {\n ...(input?.redirectUrl ? { redirect_url: input.redirectUrl } : {}),\n ...(input?.flow ? { flow: input.flow } : {}),\n ...(input?.paymentSessionId ? { payment_session_id: input.paymentSessionId } : {}),\n ...(input?.clientSettleUrl ? { client_settle_url: input.clientSettleUrl } : {}),\n ...(input?.providerReference !== undefined\n ? { provider_reference: input.providerReference }\n : {}),\n ...(input?.scheme ? { scheme: input.scheme } : {}),\n ...(input?.metadata ? { metadata: input.metadata } : {}),\n };\n}\n\nfunction readPaymentRequestParams(source = {}) {\n const input = readRecord(source);\n return {\n paymentSessionId: readString(input.payment_session_id, input.paymentSessionId).trim(),\n returnUrl: readString(input.return_url, input.returnUrl).trim(),\n cancelUrl: readString(input.cancel_url, input.cancelUrl).trim(),\n xappsResume: readString(input.xapps_resume, input.xappsResume).trim(),\n };\n}\n\nfunction readClientSettleInput(source = {}) {\n const input = readRecord(source);\n const status = readString(input.status).trim();\n return {\n ...readPaymentRequestParams(input),\n status: status === \"failed\" || status === \"cancelled\" ? status : \"paid\",\n clientToken: readString(input.client_token, input.clientToken).trim() || undefined,\n metadata:\n input.metadata && typeof input.metadata === \"object\" && !Array.isArray(input.metadata)\n ? input.metadata\n : undefined,\n };\n}\n\nfunction sendGatewayUnavailable(reply, message, statusCode = 500) {\n return reply.code(statusCode).send({ message });\n}\n\nexport async function createPaymentRuntime(options = {}, deps = {}) {\n const createPaymentHandler =\n typeof deps.createPaymentHandler === \"function\"\n ? deps.createPaymentHandler\n : createPaymentEvidenceHandler;\n const createGatewayClient =\n typeof deps.createGatewayClient === \"function\" ? deps.createGatewayClient : null;\n\n const resolvedGatewayClient =\n options?.overrides?.gatewayClient ||\n (createGatewayClient\n ? createGatewayClient({\n baseUrl: options?.gateway?.baseUrl,\n apiKey: options?.gateway?.apiKey,\n })\n : null);\n const resolvedPaymentHandler =\n options?.overrides?.paymentHandler ||\n (await createPaymentHandler({\n payments: options?.payments || {},\n gatewayClient: resolvedGatewayClient,\n }));\n\n return {\n gatewayClient: resolvedGatewayClient,\n paymentHandler: resolvedPaymentHandler,\n paymentSettings: {\n ownerIssuer: normalizeOwnerIssuer(options?.payments?.ownerIssuer),\n paymentUrl: options?.payments?.paymentUrl,\n returnSecret: options?.payments?.returnSecret,\n returnSecretRef: options?.payments?.returnSecretRef,\n returnUrlAllowlist: options?.payments?.returnUrlAllowlist,\n },\n paymentPageFile: options?.assets?.paymentPage?.filePath || \"\",\n resolvePolicyRequest: options?.overrides?.resolvePolicyRequest || null,\n };\n}\n\nexport async function createPaymentEvidenceHandler({\n payments = {},\n gatewayClient = null,\n issuer = \"\",\n resolvePlatformSecretRef,\n} = {}) {\n const paymentSettings = readRecord(payments);\n return createPaymentHandlerAsync({\n secret: readString(paymentSettings.returnSecret).trim() || undefined,\n secretRef: readString(paymentSettings.returnSecretRef).trim() || undefined,\n secretRefResolverOptions: {\n resolvePlatformSecretRef: async (input) => resolvePlatformSecretRef(input),\n },\n issuer:\n normalizeOwnerIssuer(readString(issuer).trim() || readString(paymentSettings.ownerIssuer)) ||\n \"tenant\",\n returnUrlAllowlist: readString(paymentSettings.returnUrlAllowlist),\n gatewayClient: gatewayClient || undefined,\n requirePersistentStoreInProduction: false,\n });\n}\n\nexport async function buildHostedGatewayPaymentUrl(input = {}, runtime = {}) {\n const payloadInput = readRecord(input);\n const paymentRuntime = readRecord(runtime);\n const paymentSettings = readRecord(paymentRuntime.paymentSettings);\n const ownerIssuer = normalizeOwnerIssuer(paymentSettings.ownerIssuer);\n const gatewayClient = paymentRuntime.gatewayClient || null;\n const paymentHandler = paymentRuntime.paymentHandler || null;\n if (!gatewayClient) {\n throw new Error(\"gateway payment session client not configured\");\n }\n if (!paymentHandler || typeof paymentHandler.upsertSession !== \"function\") {\n throw new Error(\"payment evidence handler not configured\");\n }\n\n const result = await buildHostedGatewayPaymentUrlFromGuardContext({\n deps: {\n createPaymentSession: (payload) => gatewayClient.createPaymentSession(payload),\n upsertSession: (payload) => paymentHandler.upsertSession(payload),\n },\n payload: payloadInput.payload,\n context: payloadInput.context,\n guard: payloadInput.guard,\n guardConfig: payloadInput.guardConfig,\n amount: payloadInput.amount,\n currency: payloadInput.currency,\n defaultPaymentUrl: readString(paymentSettings.paymentUrl),\n fallbackIssuer: readString(payloadInput.fallbackIssuer, ownerIssuer) || ownerIssuer,\n storedIssuer:\n readString(payloadInput.storedIssuer, readString(payloadInput.fallbackIssuer, ownerIssuer)) ||\n ownerIssuer,\n defaultSecret: readString(paymentSettings.returnSecret),\n defaultSecretRef: readString(paymentSettings.returnSecretRef),\n allowDefaultSecretFallback: Boolean(payloadInput.allowDefaultSecretFallback),\n });\n return result.paymentUrl;\n}\n\nexport async function buildModeHostedGatewayPaymentUrl(input = {}, defaults = {}, runtime = {}) {\n const payloadInput = readRecord(input);\n const modeDefaults = readRecord(defaults);\n const paymentRuntime = readRecord(runtime);\n const paymentSettings = readRecord(paymentRuntime.paymentSettings);\n const ownerIssuer = normalizeOwnerIssuer(paymentSettings.ownerIssuer);\n return buildHostedGatewayPaymentUrl(\n {\n ...payloadInput,\n fallbackIssuer:\n readString(\n modeDefaults.fallbackIssuer,\n readString(payloadInput.fallbackIssuer, ownerIssuer),\n ) || ownerIssuer,\n storedIssuer:\n readString(\n modeDefaults.storedIssuer,\n readString(\n payloadInput.storedIssuer,\n readString(\n modeDefaults.fallbackIssuer,\n readString(payloadInput.fallbackIssuer, ownerIssuer),\n ),\n ),\n ) || ownerIssuer,\n allowDefaultSecretFallback: Boolean(\n modeDefaults.allowDefaultSecretFallback ?? payloadInput.allowDefaultSecretFallback,\n ),\n },\n runtime,\n );\n}\n\nexport async function registerPaymentPageAssetRoute(\n fastify,\n { pagePath = \"/tenant-payment.html\", pageFile = \"\" } = {},\n) {\n fastify.get(pagePath, async (_request, reply) => {\n const html = fs.readFileSync(pageFile, \"utf8\");\n return reply.code(200).type(\"text/html; charset=utf-8\").send(html);\n });\n}\n\nexport async function registerPaymentPageApiRoutes(\n fastify,\n { gatewayClient = null, pathPrefix = \"/api/tenant-payment\" } = {},\n) {\n fastify.get(`${pathPrefix}/session`, async (request, reply) => {\n const { paymentSessionId, returnUrl, cancelUrl, xappsResume } = readPaymentRequestParams(\n request.query,\n );\n if (!gatewayClient || typeof gatewayClient.getGatewayPaymentSession !== \"function\") {\n return sendGatewayUnavailable(reply, \"gateway payment client is not configured\");\n }\n if (!paymentSessionId) {\n return reply.code(400).send({ message: \"payment_session_id is required\" });\n }\n const hosted = await gatewayClient.getGatewayPaymentSession({\n paymentSessionId,\n ...(returnUrl ? { returnUrl } : {}),\n ...(cancelUrl ? { cancelUrl } : {}),\n ...(xappsResume ? { xappsResume } : {}),\n });\n return reply.code(200).send({ status: \"success\", result: hosted.session });\n });\n\n fastify.post(`${pathPrefix}/complete`, async (request, reply) => {\n const { paymentSessionId, returnUrl, cancelUrl, xappsResume } = readPaymentRequestParams(\n request.body,\n );\n if (!gatewayClient || typeof gatewayClient.completeGatewayPayment !== \"function\") {\n return sendGatewayUnavailable(reply, \"gateway payment client is not configured\");\n }\n if (!paymentSessionId) {\n return reply.code(400).send({ message: \"payment_session_id is required\" });\n }\n const hosted = await gatewayClient.completeGatewayPayment({\n paymentSessionId,\n ...(returnUrl ? { returnUrl } : {}),\n ...(cancelUrl ? { cancelUrl } : {}),\n ...(xappsResume ? { xappsResume } : {}),\n });\n return reply.code(200).send({ status: \"success\", result: mapHostedSessionResult(hosted) });\n });\n\n fastify.post(`${pathPrefix}/client-settle`, async (request, reply) => {\n const { paymentSessionId, returnUrl, xappsResume, status, clientToken, metadata } =\n readClientSettleInput(request.body);\n if (!paymentSessionId) {\n return reply.code(400).send({ message: \"payment_session_id is required\" });\n }\n if (!gatewayClient || typeof gatewayClient.clientSettleGatewayPayment !== \"function\") {\n return sendGatewayUnavailable(\n reply,\n \"client-settle is not available for this payment mode\",\n 409,\n );\n }\n try {\n const settled = await gatewayClient.clientSettleGatewayPayment({\n paymentSessionId,\n returnUrl: returnUrl || undefined,\n xappsResume: xappsResume || undefined,\n status,\n clientToken,\n metadata,\n });\n return reply.code(200).send({ status: \"success\", result: mapHostedSessionResult(settled) });\n } catch (err) {\n request.log.error(\n { err: err instanceof Error ? err.message : String(err) },\n \"client-settle failed\",\n );\n return reply.code(502).send({ message: \"client_settle_failed\" });\n }\n });\n}\n\nexport { extractHostedPaymentSessionId };\n"],
4
+ "sourcesContent": ["// @ts-nocheck\nimport fs from \"node:fs\";\nimport {\n buildHostedGatewayPaymentUrlFromGuardContext,\n createPaymentHandlerAsync,\n extractHostedPaymentSessionId,\n} from \"@xapps-platform/server-sdk\";\nimport { normalizeOwnerIssuer, readRecord, readString } from \"./options.js\";\n\nfunction mapHostedSessionResult(input = {}) {\n return {\n ...(input?.redirectUrl ? { redirect_url: input.redirectUrl } : {}),\n ...(input?.flow ? { flow: input.flow } : {}),\n ...(input?.paymentSessionId ? { payment_session_id: input.paymentSessionId } : {}),\n ...(input?.clientSettleUrl ? { client_settle_url: input.clientSettleUrl } : {}),\n ...(input?.providerReference !== undefined\n ? { provider_reference: input.providerReference }\n : {}),\n ...(input?.scheme ? { scheme: input.scheme } : {}),\n ...(input?.metadata ? { metadata: input.metadata } : {}),\n };\n}\n\nfunction readPaymentRequestParams(source = {}) {\n const input = readRecord(source);\n return {\n paymentSessionId: readString(input.payment_session_id, input.paymentSessionId).trim(),\n returnUrl: readString(input.return_url, input.returnUrl).trim(),\n cancelUrl: readString(input.cancel_url, input.cancelUrl).trim(),\n xappsResume: readString(input.xapps_resume, input.xappsResume).trim(),\n };\n}\n\nfunction readClientSettleInput(source = {}) {\n const input = readRecord(source);\n const status = readString(input.status).trim();\n return {\n ...readPaymentRequestParams(input),\n status: status === \"failed\" || status === \"cancelled\" ? status : \"paid\",\n clientToken: readString(input.client_token, input.clientToken).trim() || undefined,\n metadata:\n input.metadata && typeof input.metadata === \"object\" && !Array.isArray(input.metadata)\n ? input.metadata\n : undefined,\n };\n}\n\nfunction sendGatewayUnavailable(reply, message, statusCode = 500) {\n return reply.code(statusCode).send({ message });\n}\n\nexport async function createPaymentRuntime(options = {}, deps = {}) {\n const createPaymentHandler =\n typeof deps.createPaymentHandler === \"function\"\n ? deps.createPaymentHandler\n : createPaymentEvidenceHandler;\n const createGatewayClient =\n typeof deps.createGatewayClient === \"function\" ? deps.createGatewayClient : null;\n\n const resolvedGatewayClient =\n options?.overrides?.gatewayClient ||\n (createGatewayClient\n ? createGatewayClient({\n baseUrl: options?.gateway?.baseUrl,\n apiKey: options?.gateway?.apiKey,\n })\n : null);\n const resolvedPaymentHandler =\n options?.overrides?.paymentHandler ||\n (await createPaymentHandler({\n payments: options?.payments || {},\n gatewayClient: resolvedGatewayClient,\n }));\n\n return {\n gatewayClient: resolvedGatewayClient,\n paymentHandler: resolvedPaymentHandler,\n paymentSettings: {\n ownerIssuer: normalizeOwnerIssuer(options?.payments?.ownerIssuer),\n paymentUrl: options?.payments?.paymentUrl,\n returnSecret: options?.payments?.returnSecret,\n returnSecretRef: options?.payments?.returnSecretRef,\n returnUrlAllowlist: options?.payments?.returnUrlAllowlist,\n },\n paymentPageFile: options?.assets?.paymentPage?.filePath || \"\",\n resolvePolicyRequest: options?.overrides?.resolvePolicyRequest || null,\n };\n}\n\nexport async function createPaymentEvidenceHandler({\n payments = {},\n gatewayClient = null,\n issuer = \"\",\n resolvePlatformSecretRef,\n} = {}) {\n const paymentSettings = readRecord(payments);\n return createPaymentHandlerAsync({\n secret: readString(paymentSettings.returnSecret).trim() || undefined,\n secretRef: readString(paymentSettings.returnSecretRef).trim() || undefined,\n secretRefResolverOptions: {\n resolvePlatformSecretRef: async (input) => resolvePlatformSecretRef(input),\n },\n issuer:\n normalizeOwnerIssuer(readString(issuer).trim() || readString(paymentSettings.ownerIssuer)) ||\n \"tenant\",\n returnUrlAllowlist: readString(paymentSettings.returnUrlAllowlist),\n gatewayClient: gatewayClient || undefined,\n requirePersistentStoreInProduction: false,\n });\n}\n\nexport async function buildHostedGatewayPaymentUrl(input = {}, runtime = {}) {\n const payloadInput = readRecord(input);\n const paymentRuntime = readRecord(runtime);\n const paymentSettings = readRecord(paymentRuntime.paymentSettings);\n const ownerIssuer = normalizeOwnerIssuer(paymentSettings.ownerIssuer);\n const gatewayClient = paymentRuntime.gatewayClient || null;\n const paymentHandler = paymentRuntime.paymentHandler || null;\n if (!gatewayClient) {\n throw new Error(\"gateway payment session client not configured\");\n }\n if (!paymentHandler || typeof paymentHandler.upsertSession !== \"function\") {\n throw new Error(\"payment evidence handler not configured\");\n }\n\n const result = await buildHostedGatewayPaymentUrlFromGuardContext({\n deps: {\n createPaymentSession: (payload) => gatewayClient.createPaymentSession(payload),\n upsertSession: (payload) => paymentHandler.upsertSession(payload),\n },\n payload: payloadInput.payload,\n context: payloadInput.context,\n guard: payloadInput.guard,\n guardConfig: payloadInput.guardConfig,\n amount: payloadInput.amount,\n currency: payloadInput.currency,\n defaultPaymentUrl: readString(paymentSettings.paymentUrl),\n fallbackIssuer: readString(payloadInput.fallbackIssuer, ownerIssuer) || ownerIssuer,\n storedIssuer:\n readString(payloadInput.storedIssuer, readString(payloadInput.fallbackIssuer, ownerIssuer)) ||\n ownerIssuer,\n defaultSecret: readString(paymentSettings.returnSecret),\n defaultSecretRef: readString(paymentSettings.returnSecretRef),\n allowDefaultSecretFallback: Boolean(payloadInput.allowDefaultSecretFallback),\n });\n return result.paymentUrl;\n}\n\nexport async function buildModeHostedGatewayPaymentUrl(input = {}, defaults = {}, runtime = {}) {\n const payloadInput = readRecord(input);\n const modeDefaults = readRecord(defaults);\n const paymentRuntime = readRecord(runtime);\n const paymentSettings = readRecord(paymentRuntime.paymentSettings);\n const ownerIssuer = normalizeOwnerIssuer(paymentSettings.ownerIssuer);\n return buildHostedGatewayPaymentUrl(\n {\n ...payloadInput,\n fallbackIssuer:\n readString(\n modeDefaults.fallbackIssuer,\n readString(payloadInput.fallbackIssuer, ownerIssuer),\n ) || ownerIssuer,\n storedIssuer:\n readString(\n modeDefaults.storedIssuer,\n readString(\n payloadInput.storedIssuer,\n readString(\n modeDefaults.fallbackIssuer,\n readString(payloadInput.fallbackIssuer, ownerIssuer),\n ),\n ),\n ) || ownerIssuer,\n allowDefaultSecretFallback: Boolean(\n modeDefaults.allowDefaultSecretFallback ?? payloadInput.allowDefaultSecretFallback,\n ),\n },\n runtime,\n );\n}\n\nexport async function registerPaymentPageAssetRoute(\n fastify,\n { pagePath = \"/tenant-payment.html\", pageFile = \"\" } = {},\n) {\n fastify.get(pagePath, async (_request, reply) => {\n const html = fs.readFileSync(pageFile, \"utf8\");\n return reply.code(200).type(\"text/html; charset=utf-8\").send(html);\n });\n}\n\nexport async function registerPaymentPageApiRoutes(\n fastify,\n { gatewayClient = null, pathPrefix = \"/api/tenant-payment\" } = {},\n) {\n fastify.get(`${pathPrefix}/session`, async (request, reply) => {\n const { paymentSessionId, returnUrl, cancelUrl, xappsResume } = readPaymentRequestParams(\n request.query,\n );\n if (!gatewayClient || typeof gatewayClient.getGatewayPaymentSession !== \"function\") {\n return sendGatewayUnavailable(reply, \"gateway payment client is not configured\");\n }\n if (!paymentSessionId) {\n return reply.code(400).send({ message: \"payment_session_id is required\" });\n }\n const hosted = await gatewayClient.getGatewayPaymentSession({\n paymentSessionId,\n ...(returnUrl ? { returnUrl } : {}),\n ...(cancelUrl ? { cancelUrl } : {}),\n ...(xappsResume ? { xappsResume } : {}),\n });\n return reply.code(200).send({ status: \"success\", result: hosted.session });\n });\n\n fastify.post(`${pathPrefix}/complete`, async (request, reply) => {\n const { paymentSessionId, returnUrl, cancelUrl, xappsResume } = readPaymentRequestParams(\n request.body,\n );\n if (!gatewayClient || typeof gatewayClient.completeGatewayPayment !== \"function\") {\n return sendGatewayUnavailable(reply, \"gateway payment client is not configured\");\n }\n if (!paymentSessionId) {\n return reply.code(400).send({ message: \"payment_session_id is required\" });\n }\n const hosted = await gatewayClient.completeGatewayPayment({\n paymentSessionId,\n ...(returnUrl ? { returnUrl } : {}),\n ...(cancelUrl ? { cancelUrl } : {}),\n ...(xappsResume ? { xappsResume } : {}),\n });\n return reply.code(200).send({ status: \"success\", result: mapHostedSessionResult(hosted) });\n });\n\n fastify.post(`${pathPrefix}/client-settle`, async (request, reply) => {\n const { paymentSessionId, returnUrl, xappsResume, status, clientToken, metadata } =\n readClientSettleInput(request.body);\n if (!paymentSessionId) {\n return reply.code(400).send({ message: \"payment_session_id is required\" });\n }\n if (!gatewayClient || typeof gatewayClient.clientSettleGatewayPayment !== \"function\") {\n return sendGatewayUnavailable(\n reply,\n \"client-settle is not available for this payment mode\",\n 409,\n );\n }\n try {\n const settled = await gatewayClient.clientSettleGatewayPayment({\n paymentSessionId,\n returnUrl: returnUrl || undefined,\n xappsResume: xappsResume || undefined,\n status,\n clientToken,\n metadata,\n });\n return reply.code(200).send({ status: \"success\", result: mapHostedSessionResult(settled) });\n } catch (err) {\n request.log.error(\n { err: err instanceof Error ? err.message : String(err) },\n \"client-settle failed\",\n );\n return reply.code(502).send({ message: \"client_settle_failed\" });\n }\n });\n}\n\nexport { extractHostedPaymentSessionId };\n"],
5
5
  "mappings": "AACA,OAAO,QAAQ;AACf;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB,YAAY,kBAAkB;AAE7D,SAAS,uBAAuB,QAAQ,CAAC,GAAG;AAC1C,SAAO;AAAA,IACL,GAAI,OAAO,cAAc,EAAE,cAAc,MAAM,YAAY,IAAI,CAAC;AAAA,IAChE,GAAI,OAAO,OAAO,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;AAAA,IAC1C,GAAI,OAAO,mBAAmB,EAAE,oBAAoB,MAAM,iBAAiB,IAAI,CAAC;AAAA,IAChF,GAAI,OAAO,kBAAkB,EAAE,mBAAmB,MAAM,gBAAgB,IAAI,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AO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,QAAI;AACF,YAAM,UAAU,MAAM,cAAc,2BAA2B;AAAA,QAC7D;AAAA,QACA,WAAW,aAAa;AAAA,QACxB,aAAa,eAAe;AAAA,QAC5B;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AACD,aAAO,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,QAAQ,WAAW,QAAQ,uBAAuB,OAAO,EAAE,CAAC;AAAA,IAC5F,SAAS,KAAK;AACZ,cAAQ,IAAI;AAAA,QACV,EAAE,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,EAAE;AAAA,QACxD;AAAA,MACF;AACA,aAAO,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,SAAS,uBAAuB,CAAC;AAAA,IACjE;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  export declare function hasUpstreamPaymentVerified(value: any): boolean;
2
2
  export declare function resolveMergedContext(payloadInput: any): Record<string, unknown>;
3
3
  export declare function resolvePriceAmount(guardConfig: any, context: any): unknown;
4
- export declare function buildPaymentAction(action: any): import("@xapps/server-sdk").PaymentGuardAction;
4
+ export declare function buildPaymentAction(action: any): import("@xapps-platform/server-sdk").PaymentGuardAction;
5
5
  export declare function normalizeAllowedIssuers(guardConfig: any, fallbackIssuer: any): string[];
6
6
  export declare function buildPaymentPolicyAllowedResult(input: any, modeMeta?: {}): {
7
7
  allowed: boolean;
@@ -46,7 +46,7 @@ export declare function buildPaymentPolicyBlockedResult(input: any, { buildPayme
46
46
  allowed: boolean;
47
47
  reason: any;
48
48
  message: any;
49
- action: import("@xapps/server-sdk").PaymentGuardAction;
49
+ action: import("@xapps-platform/server-sdk").PaymentGuardAction;
50
50
  details: {
51
51
  verification_failure?: any;
52
52
  uiRequired: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/backend/policies/common.ts"],"names":[],"mappings":"AAqBA,wBAAgB,0BAA0B,CAAC,KAAK,KAAA,WAE/C;AAED,wBAAgB,oBAAoB,CAAC,YAAY,KAAA,2BAEhD;AAED,wBAAgB,kBAAkB,CAAC,WAAW,KAAA,EAAE,OAAO,KAAA,WAEtD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,KAAA,kDAExC;AAED,wBAAgB,uBAAuB,CAAC,WAAW,KAAA,EAAE,cAAc,KAAA,YAElE;AAED,wBAAgB,+BAA+B,CAAC,KAAK,KAAA,EAAE,QAAQ,KAAK;;;;;;;;;;;;;;;EAiBnE;AAED,wBAAgB,iCAAiC,CAAC,cAAc,KAAA;;;;;;;;;;;;;;;;;;EAoB/D;AAED,wBAAsB,+BAA+B,CACnD,KAAK,KAAA,EACL,EAAE,eAAe,EAAE,6BAA6B,EAAE,QAAa,EAAE;;;;CAAA;;;;;;;;;;;;;;;;;;;;GAgClE;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,YAAY,EACZ,GAAG,EACH,qBAAqB,EACrB,4BAA4B,EAC5B,cAAc,EACd,cAAmB,EACnB,eAAoB,EACpB,gBAA0C,GAC3C;;;;;;;;;CAAA;;;;;;;;;;;;;;;;;GAsHA;AAED,wBAAsB,0BAA0B,CAAC,EAC/C,YAAY,EACZ,GAAG,EACH,qBAAqB,EACrB,4BAA4B,EAC5B,iBAAiB,EACjB,cAAmB,EACnB,gBAAgB,GACjB;;;;;;;;CAAA,gBAYA"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/backend/policies/common.ts"],"names":[],"mappings":"AAqBA,wBAAgB,0BAA0B,CAAC,KAAK,KAAA,WAE/C;AAED,wBAAgB,oBAAoB,CAAC,YAAY,KAAA,2BAEhD;AAED,wBAAgB,kBAAkB,CAAC,WAAW,KAAA,EAAE,OAAO,KAAA,WAEtD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,KAAA,2DAExC;AAED,wBAAgB,uBAAuB,CAAC,WAAW,KAAA,EAAE,cAAc,KAAA,YAElE;AAED,wBAAgB,+BAA+B,CAAC,KAAK,KAAA,EAAE,QAAQ,KAAK;;;;;;;;;;;;;;;EAiBnE;AAED,wBAAgB,iCAAiC,CAAC,cAAc,KAAA;;;;;;;;;;;;;;;;;;EAoB/D;AAED,wBAAsB,+BAA+B,CACnD,KAAK,KAAA,EACL,EAAE,eAAe,EAAE,6BAA6B,EAAE,QAAa,EAAE;;;;CAAA;;;;;;;;;;;;;;;;;;;;GAgClE;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,YAAY,EACZ,GAAG,EACH,qBAAqB,EACrB,4BAA4B,EAC5B,cAAc,EACd,cAAmB,EACnB,eAAoB,EACpB,gBAA0C,GAC3C;;;;;;;;;CAAA;;;;;;;;;;;;;;;;;GAsHA;AAED,wBAAsB,0BAA0B,CAAC,EAC/C,YAAY,EACZ,GAAG,EACH,qBAAqB,EACrB,4BAA4B,EAC5B,iBAAiB,EACjB,cAAmB,EACnB,gBAAgB,GACjB;;;;;;;;CAAA,gBAYA"}
@@ -4,7 +4,7 @@ import {
4
4
  normalizePaymentAllowedIssuers as normalizePaymentAllowedIssuersFromSdk,
5
5
  resolveMergedPaymentGuardContext,
6
6
  resolvePaymentGuardPriceAmount
7
- } from "@xapps/server-sdk";
7
+ } from "@xapps-platform/server-sdk";
8
8
  function asObject(value) {
9
9
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
10
10
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/backend/policies/common.ts"],
4
- "sourcesContent": ["// @ts-nocheck\nimport {\n buildPaymentGuardAction,\n hasUpstreamPaymentVerified as hasUpstreamPaymentVerifiedFromSdk,\n normalizePaymentAllowedIssuers as normalizePaymentAllowedIssuersFromSdk,\n resolveMergedPaymentGuardContext,\n resolvePaymentGuardPriceAmount,\n} from \"@xapps/server-sdk\";\n\nfunction asObject(value) {\n return value && typeof value === \"object\" && !Array.isArray(value) ? value : {};\n}\n\nfunction toNumericAmount(amount) {\n if (typeof amount === \"number\") return amount;\n if (typeof amount === \"string\" && amount.trim() && Number.isFinite(Number(amount))) {\n return Number(amount);\n }\n return amount;\n}\n\nexport function hasUpstreamPaymentVerified(value) {\n return hasUpstreamPaymentVerifiedFromSdk(value);\n}\n\nexport function resolveMergedContext(payloadInput) {\n return resolveMergedPaymentGuardContext(asObject(payloadInput));\n}\n\nexport function resolvePriceAmount(guardConfig, context) {\n return resolvePaymentGuardPriceAmount(asObject(guardConfig), asObject(context));\n}\n\nexport function buildPaymentAction(action) {\n return buildPaymentGuardAction(asObject(action));\n}\n\nexport function normalizeAllowedIssuers(guardConfig, fallbackIssuer) {\n return normalizePaymentAllowedIssuersFromSdk(asObject(guardConfig), String(fallbackIssuer || \"\"));\n}\n\nexport function buildPaymentPolicyAllowedResult(input, modeMeta = {}) {\n return {\n allowed: true,\n reason: String(input.policy?.reason || \"tenant_payment_passed\"),\n message: \"Tenant payment policy satisfied\",\n details: {\n payment_status: input.verifiedPayment?.status || input.plainStatus || \"paid\",\n orchestrationApproved: input.orchestrationApproved,\n gatewayPaymentVerified: input.gatewayPaymentVerified,\n paidByGatewayHint: false,\n paidByPlainStatusFallback: false,\n paidByVerifiedEvidence: input.paidByVerifiedEvidence,\n verified_contract: input.verifiedPayment?.contract || null,\n payment_mode: modeMeta.paymentMode || null,\n ...(modeMeta.referenceMode ? { reference_mode: modeMeta.referenceMode } : {}),\n },\n };\n}\n\nexport function buildPaymentGuardFailClosedResult(upstreamStatus) {\n return {\n allowed: false,\n reason: \"payment_session_create_failed\",\n message: \"Payment session could not be created at this time\",\n action: {\n kind: \"complete_payment\",\n label: \"Open Payment\",\n title: \"Complete Payment\",\n },\n details: {\n uiRequired: true,\n orchestration: {\n mode: \"blocking\",\n surface: \"redirect\",\n status: \"failed_dependency\",\n },\n upstream_status: Number(upstreamStatus || 500) || 500,\n },\n };\n}\n\nexport async function buildPaymentPolicyBlockedResult(\n input,\n { buildPaymentUrl, extractHostedPaymentSessionId, modeMeta = {} },\n) {\n const paymentUrl = await buildPaymentUrl(input);\n return {\n allowed: false,\n reason: input.failReason,\n message:\n input.verificationFailure?.ok === false ? \"Payment verification failed\" : input.baseMessage,\n action: buildPaymentAction({\n url: paymentUrl,\n label: input.actionCfg?.label,\n title: input.actionCfg?.title,\n target: input.actionCfg?.target,\n }),\n details: {\n uiRequired: true,\n orchestration: {\n mode: \"blocking\",\n surface: String(input.guardConfig?.ui_mode || \"redirect\"),\n status: \"pending_user_action\",\n payment_session_id: extractHostedPaymentSessionId(paymentUrl),\n payment_mode: modeMeta.paymentMode || null,\n ...(modeMeta.referenceMode ? { reference_mode: modeMeta.referenceMode } : {}),\n },\n payment_status: input.plainStatus || null,\n expected_amount: toNumericAmount(input.amount),\n expected_currency: input.currency,\n ...(input.verificationFailure?.ok === false\n ? { verification_failure: input.verificationFailure }\n : {}),\n },\n };\n}\n\nexport async function buildPaymentPolicyInput({\n payloadInput,\n log,\n resolveAllowedIssuers,\n resolveExpectedPaymentIssuer,\n paymentHandler,\n paymentRuntime = {},\n paymentSettings = {},\n guardSlugDefault = \"tenant-payment-policy\",\n}) {\n const payload = payloadInput && typeof payloadInput === \"object\" ? payloadInput : {};\n const context = resolveMergedContext(payload);\n const policyContext = asObject(payload.policyContext);\n const payloadWithContext = { ...payload, context };\n const guard = payload.guard && typeof payload.guard === \"object\" ? payload.guard : {};\n const guardConfig = guard.config && typeof guard.config === \"object\" ? guard.config : {};\n const policy =\n guardConfig.policy && typeof guardConfig.policy === \"object\" ? guardConfig.policy : {};\n const actionCfg =\n guardConfig.action && typeof guardConfig.action === \"object\" ? guardConfig.action : {};\n const guardSlug = String(guard.slug || guardSlugDefault).trim();\n const orchestration =\n context.orchestration && typeof context.orchestration === \"object\" ? context.orchestration : {};\n const orchestrationEntry =\n orchestration[guardSlug] && typeof orchestration[guardSlug] === \"object\"\n ? orchestration[guardSlug]\n : {};\n const orchestrationPayment =\n orchestrationEntry.payment && typeof orchestrationEntry.payment === \"object\"\n ? orchestrationEntry.payment\n : null;\n\n const allowOrchestrationBypassConfigured = Boolean(\n guardConfig.allow_orchestration_bypass ?? guardConfig.allowOrchestrationBypass,\n );\n if (allowOrchestrationBypassConfigured) {\n log.warn(\"Ignoring allow_orchestration_bypass in canonical payment verification mode.\");\n }\n const orchestrationApproved = false;\n\n const amount = resolvePriceAmount(guardConfig, context);\n const currency = String(guardConfig?.pricing?.currency || guardConfig.currency || \"USD\")\n .trim()\n .toUpperCase();\n const settings = asObject(paymentSettings);\n const allowedIssuers = resolveAllowedIssuers(guardConfig, settings, paymentRuntime);\n const expectedIssuer =\n allowedIssuers[0] || resolveExpectedPaymentIssuer(guardConfig, settings, paymentRuntime);\n const plainStatus = String(payload.payment_status || payload?.payment?.status || \"\")\n .trim()\n .toLowerCase();\n const gatewayPaymentVerified =\n hasUpstreamPaymentVerified(payload.payment_verified) ||\n hasUpstreamPaymentVerified(payload.paymentVerified) ||\n hasUpstreamPaymentVerified(policyContext.payment_verified) ||\n hasUpstreamPaymentVerified(policyContext.paymentVerified);\n let verifiedPayment = null;\n let verificationFailure = null;\n\n const hasVerificationSecret =\n String(settings.returnSecret || \"\").trim().length > 0 ||\n String(settings.returnSecretRef || \"\").trim().length > 0 ||\n Boolean(paymentHandler && typeof paymentHandler.handleVerifyEvidence === \"function\");\n\n if (\n gatewayPaymentVerified &&\n orchestrationPayment &&\n String(orchestrationPayment.status || \"\")\n .trim()\n .toLowerCase() === \"paid\"\n ) {\n verifiedPayment = orchestrationPayment;\n } else if (hasVerificationSecret && paymentHandler?.handleVerifyEvidence) {\n const verificationPayload = orchestrationPayment\n ? { ...payloadWithContext, ...(orchestrationPayment || {}) }\n : payloadWithContext;\n const verifyResult = await paymentHandler.handleVerifyEvidence({\n payload: verificationPayload,\n maxAgeSeconds: Number(guardConfig.payment_return_max_age_s || 900) || 900,\n expected: {\n issuer: expectedIssuer,\n issuers: allowedIssuers,\n amount,\n currency,\n xapp_id: String(context.xappId || context.xapp_id || \"\") || undefined,\n tool_name: String(context.toolName || context.tool_name || \"\") || undefined,\n subject_id: String(context.subjectId || context.subject_id || \"\") || undefined,\n installation_id:\n String(context.installationId || context.installation_id || \"\") || undefined,\n client_id: String(context.clientId || context.client_id || \"\") || undefined,\n },\n });\n if (verifyResult.ok) {\n verifiedPayment = verifyResult.evidence;\n } else if (verifyResult.reason !== \"payment_evidence_not_found\") {\n verificationFailure = verifyResult;\n }\n }\n\n const paidByVerifiedEvidence = Boolean(verifiedPayment);\n if (!hasVerificationSecret) {\n log.warn(\n \"Payment guard verification secret/secret_ref is not configured; canonical mode is fail-closed.\",\n );\n }\n\n const baseReason = String(policy.reason || \"payment_required\").trim() || \"payment_required\";\n const baseMessage = String(policy.message || \"Payment is required before continuing.\").trim();\n const failReason = verificationFailure?.ok === false ? verificationFailure.reason : baseReason;\n return {\n payload: payloadWithContext,\n context,\n guard,\n guardConfig,\n policy,\n amount,\n currency,\n plainStatus,\n orchestrationApproved,\n gatewayPaymentVerified,\n verifiedPayment,\n paidByVerifiedEvidence,\n verificationFailure,\n failReason,\n baseMessage,\n actionCfg,\n };\n}\n\nexport async function resolvePolicyRequestCommon({\n payloadInput,\n log,\n resolveAllowedIssuers,\n resolveExpectedPaymentIssuer,\n resolveModeResult,\n paymentRuntime = {},\n guardSlugDefault,\n}) {\n const input = await buildPaymentPolicyInput({\n payloadInput,\n log,\n resolveAllowedIssuers,\n resolveExpectedPaymentIssuer,\n paymentHandler: paymentRuntime.paymentHandler,\n paymentRuntime,\n paymentSettings: paymentRuntime.paymentSettings,\n guardSlugDefault,\n });\n return resolveModeResult(input, paymentRuntime);\n}\n"],
4
+ "sourcesContent": ["// @ts-nocheck\nimport {\n buildPaymentGuardAction,\n hasUpstreamPaymentVerified as hasUpstreamPaymentVerifiedFromSdk,\n normalizePaymentAllowedIssuers as normalizePaymentAllowedIssuersFromSdk,\n resolveMergedPaymentGuardContext,\n resolvePaymentGuardPriceAmount,\n} from \"@xapps-platform/server-sdk\";\n\nfunction asObject(value) {\n return value && typeof value === \"object\" && !Array.isArray(value) ? value : {};\n}\n\nfunction toNumericAmount(amount) {\n if (typeof amount === \"number\") return amount;\n if (typeof amount === \"string\" && amount.trim() && Number.isFinite(Number(amount))) {\n return Number(amount);\n }\n return amount;\n}\n\nexport function hasUpstreamPaymentVerified(value) {\n return hasUpstreamPaymentVerifiedFromSdk(value);\n}\n\nexport function resolveMergedContext(payloadInput) {\n return resolveMergedPaymentGuardContext(asObject(payloadInput));\n}\n\nexport function resolvePriceAmount(guardConfig, context) {\n return resolvePaymentGuardPriceAmount(asObject(guardConfig), asObject(context));\n}\n\nexport function buildPaymentAction(action) {\n return buildPaymentGuardAction(asObject(action));\n}\n\nexport function normalizeAllowedIssuers(guardConfig, fallbackIssuer) {\n return normalizePaymentAllowedIssuersFromSdk(asObject(guardConfig), String(fallbackIssuer || \"\"));\n}\n\nexport function buildPaymentPolicyAllowedResult(input, modeMeta = {}) {\n return {\n allowed: true,\n reason: String(input.policy?.reason || \"tenant_payment_passed\"),\n message: \"Tenant payment policy satisfied\",\n details: {\n payment_status: input.verifiedPayment?.status || input.plainStatus || \"paid\",\n orchestrationApproved: input.orchestrationApproved,\n gatewayPaymentVerified: input.gatewayPaymentVerified,\n paidByGatewayHint: false,\n paidByPlainStatusFallback: false,\n paidByVerifiedEvidence: input.paidByVerifiedEvidence,\n verified_contract: input.verifiedPayment?.contract || null,\n payment_mode: modeMeta.paymentMode || null,\n ...(modeMeta.referenceMode ? { reference_mode: modeMeta.referenceMode } : {}),\n },\n };\n}\n\nexport function buildPaymentGuardFailClosedResult(upstreamStatus) {\n return {\n allowed: false,\n reason: \"payment_session_create_failed\",\n message: \"Payment session could not be created at this time\",\n action: {\n kind: \"complete_payment\",\n label: \"Open Payment\",\n title: \"Complete Payment\",\n },\n details: {\n uiRequired: true,\n orchestration: {\n mode: \"blocking\",\n surface: \"redirect\",\n status: \"failed_dependency\",\n },\n upstream_status: Number(upstreamStatus || 500) || 500,\n },\n };\n}\n\nexport async function buildPaymentPolicyBlockedResult(\n input,\n { buildPaymentUrl, extractHostedPaymentSessionId, modeMeta = {} },\n) {\n const paymentUrl = await buildPaymentUrl(input);\n return {\n allowed: false,\n reason: input.failReason,\n message:\n input.verificationFailure?.ok === false ? \"Payment verification failed\" : input.baseMessage,\n action: buildPaymentAction({\n url: paymentUrl,\n label: input.actionCfg?.label,\n title: input.actionCfg?.title,\n target: input.actionCfg?.target,\n }),\n details: {\n uiRequired: true,\n orchestration: {\n mode: \"blocking\",\n surface: String(input.guardConfig?.ui_mode || \"redirect\"),\n status: \"pending_user_action\",\n payment_session_id: extractHostedPaymentSessionId(paymentUrl),\n payment_mode: modeMeta.paymentMode || null,\n ...(modeMeta.referenceMode ? { reference_mode: modeMeta.referenceMode } : {}),\n },\n payment_status: input.plainStatus || null,\n expected_amount: toNumericAmount(input.amount),\n expected_currency: input.currency,\n ...(input.verificationFailure?.ok === false\n ? { verification_failure: input.verificationFailure }\n : {}),\n },\n };\n}\n\nexport async function buildPaymentPolicyInput({\n payloadInput,\n log,\n resolveAllowedIssuers,\n resolveExpectedPaymentIssuer,\n paymentHandler,\n paymentRuntime = {},\n paymentSettings = {},\n guardSlugDefault = \"tenant-payment-policy\",\n}) {\n const payload = payloadInput && typeof payloadInput === \"object\" ? payloadInput : {};\n const context = resolveMergedContext(payload);\n const policyContext = asObject(payload.policyContext);\n const payloadWithContext = { ...payload, context };\n const guard = payload.guard && typeof payload.guard === \"object\" ? payload.guard : {};\n const guardConfig = guard.config && typeof guard.config === \"object\" ? guard.config : {};\n const policy =\n guardConfig.policy && typeof guardConfig.policy === \"object\" ? guardConfig.policy : {};\n const actionCfg =\n guardConfig.action && typeof guardConfig.action === \"object\" ? guardConfig.action : {};\n const guardSlug = String(guard.slug || guardSlugDefault).trim();\n const orchestration =\n context.orchestration && typeof context.orchestration === \"object\" ? context.orchestration : {};\n const orchestrationEntry =\n orchestration[guardSlug] && typeof orchestration[guardSlug] === \"object\"\n ? orchestration[guardSlug]\n : {};\n const orchestrationPayment =\n orchestrationEntry.payment && typeof orchestrationEntry.payment === \"object\"\n ? orchestrationEntry.payment\n : null;\n\n const allowOrchestrationBypassConfigured = Boolean(\n guardConfig.allow_orchestration_bypass ?? guardConfig.allowOrchestrationBypass,\n );\n if (allowOrchestrationBypassConfigured) {\n log.warn(\"Ignoring allow_orchestration_bypass in canonical payment verification mode.\");\n }\n const orchestrationApproved = false;\n\n const amount = resolvePriceAmount(guardConfig, context);\n const currency = String(guardConfig?.pricing?.currency || guardConfig.currency || \"USD\")\n .trim()\n .toUpperCase();\n const settings = asObject(paymentSettings);\n const allowedIssuers = resolveAllowedIssuers(guardConfig, settings, paymentRuntime);\n const expectedIssuer =\n allowedIssuers[0] || resolveExpectedPaymentIssuer(guardConfig, settings, paymentRuntime);\n const plainStatus = String(payload.payment_status || payload?.payment?.status || \"\")\n .trim()\n .toLowerCase();\n const gatewayPaymentVerified =\n hasUpstreamPaymentVerified(payload.payment_verified) ||\n hasUpstreamPaymentVerified(payload.paymentVerified) ||\n hasUpstreamPaymentVerified(policyContext.payment_verified) ||\n hasUpstreamPaymentVerified(policyContext.paymentVerified);\n let verifiedPayment = null;\n let verificationFailure = null;\n\n const hasVerificationSecret =\n String(settings.returnSecret || \"\").trim().length > 0 ||\n String(settings.returnSecretRef || \"\").trim().length > 0 ||\n Boolean(paymentHandler && typeof paymentHandler.handleVerifyEvidence === \"function\");\n\n if (\n gatewayPaymentVerified &&\n orchestrationPayment &&\n String(orchestrationPayment.status || \"\")\n .trim()\n .toLowerCase() === \"paid\"\n ) {\n verifiedPayment = orchestrationPayment;\n } else if (hasVerificationSecret && paymentHandler?.handleVerifyEvidence) {\n const verificationPayload = orchestrationPayment\n ? { ...payloadWithContext, ...(orchestrationPayment || {}) }\n : payloadWithContext;\n const verifyResult = await paymentHandler.handleVerifyEvidence({\n payload: verificationPayload,\n maxAgeSeconds: Number(guardConfig.payment_return_max_age_s || 900) || 900,\n expected: {\n issuer: expectedIssuer,\n issuers: allowedIssuers,\n amount,\n currency,\n xapp_id: String(context.xappId || context.xapp_id || \"\") || undefined,\n tool_name: String(context.toolName || context.tool_name || \"\") || undefined,\n subject_id: String(context.subjectId || context.subject_id || \"\") || undefined,\n installation_id:\n String(context.installationId || context.installation_id || \"\") || undefined,\n client_id: String(context.clientId || context.client_id || \"\") || undefined,\n },\n });\n if (verifyResult.ok) {\n verifiedPayment = verifyResult.evidence;\n } else if (verifyResult.reason !== \"payment_evidence_not_found\") {\n verificationFailure = verifyResult;\n }\n }\n\n const paidByVerifiedEvidence = Boolean(verifiedPayment);\n if (!hasVerificationSecret) {\n log.warn(\n \"Payment guard verification secret/secret_ref is not configured; canonical mode is fail-closed.\",\n );\n }\n\n const baseReason = String(policy.reason || \"payment_required\").trim() || \"payment_required\";\n const baseMessage = String(policy.message || \"Payment is required before continuing.\").trim();\n const failReason = verificationFailure?.ok === false ? verificationFailure.reason : baseReason;\n return {\n payload: payloadWithContext,\n context,\n guard,\n guardConfig,\n policy,\n amount,\n currency,\n plainStatus,\n orchestrationApproved,\n gatewayPaymentVerified,\n verifiedPayment,\n paidByVerifiedEvidence,\n verificationFailure,\n failReason,\n baseMessage,\n actionCfg,\n };\n}\n\nexport async function resolvePolicyRequestCommon({\n payloadInput,\n log,\n resolveAllowedIssuers,\n resolveExpectedPaymentIssuer,\n resolveModeResult,\n paymentRuntime = {},\n guardSlugDefault,\n}) {\n const input = await buildPaymentPolicyInput({\n payloadInput,\n log,\n resolveAllowedIssuers,\n resolveExpectedPaymentIssuer,\n paymentHandler: paymentRuntime.paymentHandler,\n paymentRuntime,\n paymentSettings: paymentRuntime.paymentSettings,\n guardSlugDefault,\n });\n return resolveModeResult(input, paymentRuntime);\n}\n"],
5
5
  "mappings": "AACA;AAAA,EACE;AAAA,EACA,8BAA8B;AAAA,EAC9B,kCAAkC;AAAA,EAClC;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS,OAAO;AACvB,SAAO,SAAS,OAAO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,CAAC;AACD,QAAI,aAAa,IAAI;AACnB,wBAAkB,aAAa;AAAA,IACjC,WAAW,aAAa,WAAW,8BAA8B;AAC/D,4BAAsB;AAAA,IACxB;AAAA,EACF;AAEA,QAAM,yBAAyB,QAAQ,eAAe;AACtD,MAAI,CAAC,uBAAuB;AAC1B,QAAI;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa,OAAO,OAAO,UAAU,kBAAkB,EAAE,KAAK,KAAK;AACzE,QAAM,cAAc,OAAO,OAAO,WAAW,wCAAwC,EAAE,KAAK;AAC5F,QAAM,aAAa,qBAAqB,OAAO,QAAQ,oBAAoB,SAAS;AACpF,SAAO;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,eAAsB,2BAA2B;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB,CAAC;AAAA,EAClB;AACF,GAAG;AACD,QAAM,QAAQ,MAAM,wBAAwB;AAAA,IAC1C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB,eAAe;AAAA,IAC/B;AAAA,IACA,iBAAiB,eAAe;AAAA,IAChC;AAAA,EACF,CAAC;AACD,SAAO,kBAAkB,OAAO,cAAc;AAChD;",
6
6
  "names": []
7
7
  }
@@ -2,7 +2,7 @@ import {
2
2
  EmbedHostProxyInputError,
3
3
  EmbedHostProxyNotConfiguredError,
4
4
  GatewayApiClientError
5
- } from "@xapps/server-sdk";
5
+ } from "@xapps-platform/server-sdk";
6
6
  import crypto from "node:crypto";
7
7
  const HOST_BOOTSTRAP_HEADER = "x-xapps-host-bootstrap";
8
8
  function toBase64Url(input) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/backend/routes/gateway/shared.ts"],
4
- "sourcesContent": ["// @ts-nocheck\nimport {\n EmbedHostProxyInputError,\n EmbedHostProxyNotConfiguredError,\n GatewayApiClientError,\n} from \"@xapps/server-sdk\";\nimport crypto from \"node:crypto\";\n\nconst HOST_BOOTSTRAP_HEADER = \"x-xapps-host-bootstrap\";\n\nfunction toBase64Url(input) {\n return Buffer.from(String(input), \"utf8\").toString(\"base64url\");\n}\n\nfunction fromBase64UrlJson(input) {\n const raw = Buffer.from(String(input || \"\"), \"base64url\").toString(\"utf8\");\n return JSON.parse(raw);\n}\n\nfunction normalizeOrigin(value) {\n const raw = String(value || \"\").trim();\n return raw ? raw.replace(/\\/+$/, \"\") : \"\";\n}\n\nfunction normalizeAllowedOrigins(allowedOrigins = []) {\n return Array.isArray(allowedOrigins)\n ? allowedOrigins.map((entry) => normalizeOrigin(entry)).filter(Boolean)\n : [];\n}\n\nexport function readBodyRecord(value) {\n return value && typeof value === \"object\" && !Array.isArray(value) ? value : {};\n}\n\nexport function requireHostProxyService(hostProxyService) {\n if (!hostProxyService || typeof hostProxyService.getHostConfig !== \"function\") {\n throw new EmbedHostProxyNotConfiguredError(\"Host proxy service is not configured\");\n }\n return hostProxyService;\n}\n\nexport function readRequestOrigin(request) {\n return normalizeOrigin(request?.headers?.origin);\n}\n\nfunction readHostBootstrapToken(request) {\n return String(request?.headers?.[HOST_BOOTSTRAP_HEADER] || \"\").trim();\n}\n\nfunction issueHostBootstrapToken(payload, signingSecret) {\n const encodedPayload = toBase64Url(JSON.stringify(payload));\n const signature = crypto\n .createHmac(\"sha256\", String(signingSecret))\n .update(encodedPayload)\n .digest(\"base64url\");\n return `${encodedPayload}.${signature}`;\n}\n\nfunction verifyHostBootstrapToken(token, signingSecret) {\n const parts = String(token || \"\")\n .trim()\n .split(\".\");\n if (parts.length !== 2) {\n throw new EmbedHostProxyInputError(\"host bootstrap token is malformed\", 401);\n }\n const [encodedPayload, receivedSignature] = parts;\n const expectedSignature = crypto\n .createHmac(\"sha256\", String(signingSecret))\n .update(encodedPayload)\n .digest(\"base64url\");\n const received = Buffer.from(receivedSignature, \"utf8\");\n const expected = Buffer.from(expectedSignature, \"utf8\");\n if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {\n throw new EmbedHostProxyInputError(\"host bootstrap token is invalid\", 401);\n }\n const payload = fromBase64UrlJson(encodedPayload);\n if (!payload || typeof payload !== \"object\") {\n throw new EmbedHostProxyInputError(\"host bootstrap token payload is invalid\", 401);\n }\n const now = Math.floor(Date.now() / 1000);\n if (Number(payload.exp || 0) <= now) {\n throw new EmbedHostProxyInputError(\"host bootstrap token expired\", 401);\n }\n return payload;\n}\n\nexport function readHostBootstrapContext(request, bootstrap = {}) {\n const signingSecret = String(bootstrap?.signingSecret || \"\").trim();\n const token = readHostBootstrapToken(request);\n if (!token || !signingSecret) return null;\n const payload = verifyHostBootstrapToken(token, signingSecret);\n const requestOrigin = readRequestOrigin(request);\n const tokenOrigin = normalizeOrigin(payload.origin);\n if (tokenOrigin && requestOrigin && tokenOrigin !== requestOrigin) {\n throw new EmbedHostProxyInputError(\"host bootstrap token origin mismatch\", 401);\n }\n return {\n subjectId: String(payload.subjectId || \"\").trim() || null,\n email: String(payload.email || \"\").trim() || null,\n name: String(payload.name || \"\").trim() || null,\n origin: tokenOrigin || null,\n token,\n };\n}\n\nexport function requireHostBootstrapRequest(request, bootstrap = {}) {\n const allowedApiKeys = Array.isArray(bootstrap?.apiKeys)\n ? bootstrap.apiKeys.map((entry) => String(entry || \"\").trim()).filter(Boolean)\n : [];\n const signingSecret = String(bootstrap?.signingSecret || \"\").trim();\n if (allowedApiKeys.length === 0 || !signingSecret) {\n throw new EmbedHostProxyNotConfiguredError(\"Host bootstrap is not configured\");\n }\n const apiKey = String(request?.headers?.[\"x-api-key\"] || \"\").trim();\n if (!apiKey || !allowedApiKeys.includes(apiKey)) {\n throw new EmbedHostProxyInputError(\"Invalid host bootstrap api key\", 401);\n }\n return {\n apiKey,\n signingSecret,\n ttlSeconds:\n Number.isFinite(Number(bootstrap?.ttlSeconds)) && Number(bootstrap?.ttlSeconds) > 0\n ? Math.floor(Number(bootstrap.ttlSeconds))\n : 300,\n };\n}\n\nexport function buildHostBootstrapResult({\n subjectId,\n email,\n name,\n origin,\n signingSecret,\n ttlSeconds,\n}) {\n const now = Math.floor(Date.now() / 1000);\n const expiresIn = Number(ttlSeconds) > 0 ? Math.floor(Number(ttlSeconds)) : 300;\n const bootstrapToken = issueHostBootstrapToken(\n {\n v: 1,\n type: \"host_bootstrap\",\n subjectId: String(subjectId || \"\").trim(),\n email: String(email || \"\").trim(),\n name: String(name || \"\").trim(),\n origin: normalizeOrigin(origin),\n iat: now,\n exp: now + expiresIn,\n },\n signingSecret,\n );\n return {\n subjectId: String(subjectId || \"\").trim(),\n email: String(email || \"\").trim(),\n name: String(name || \"\").trim() || null,\n bootstrapToken,\n expiresIn,\n };\n}\n\nexport function isOriginAllowed(origin, allowedOrigins = []) {\n const normalizedOrigin = normalizeOrigin(origin);\n if (!normalizedOrigin) return true;\n const normalizedAllowedOrigins = normalizeAllowedOrigins(allowedOrigins);\n if (normalizedAllowedOrigins.length === 0) {\n return true;\n }\n return normalizedAllowedOrigins.includes(normalizedOrigin);\n}\n\nexport function applyHostApiCorsHeaders(reply, request, allowedOrigins = []) {\n const origin = readRequestOrigin(request);\n if (!origin) return;\n const normalizedAllowedOrigins = normalizeAllowedOrigins(allowedOrigins);\n if (normalizedAllowedOrigins.length === 0) return;\n if (!normalizedAllowedOrigins.includes(origin)) return;\n reply.header(\"Access-Control-Allow-Origin\", origin);\n reply.header(\"Vary\", \"Origin\");\n}\n\nexport function ensureHostApiOriginAllowed(request, reply, allowedOrigins = []) {\n const origin = readRequestOrigin(request);\n if (!origin) return true;\n if (!isOriginAllowed(origin, allowedOrigins)) {\n reply.code(403).send({ message: \"Origin is not allowed\" });\n return false;\n }\n applyHostApiCorsHeaders(reply, request, allowedOrigins);\n return true;\n}\n\nexport function sendHostApiPreflight(request, reply, allowedOrigins = []) {\n const origin = readRequestOrigin(request);\n if (origin && !isOriginAllowed(origin, allowedOrigins)) {\n return reply.code(403).send({ message: \"Origin is not allowed\" });\n }\n applyHostApiCorsHeaders(reply, request, allowedOrigins);\n const requestedHeaders = String(\n request?.headers?.[\"access-control-request-headers\"] || \"\",\n ).trim();\n reply.header(\"Access-Control-Allow-Methods\", \"GET, POST, OPTIONS\");\n reply.header(\n \"Access-Control-Allow-Headers\",\n requestedHeaders || \"Content-Type, Authorization, X-Xapps-Host-Bootstrap\",\n );\n reply.header(\"Access-Control-Max-Age\", \"600\");\n return reply.code(204).send();\n}\n\nexport function applyNoStoreHeaders(reply, hostProxyService) {\n const service = requireHostProxyService(hostProxyService);\n const headers = service.getNoStoreHeaders();\n reply.header(\"Cache-Control\", headers[\"Cache-Control\"]);\n reply.header(\"Pragma\", headers.Pragma);\n reply.header(\"Expires\", headers.Expires);\n return reply;\n}\n\nexport function sendServiceError(request, reply, err, fallbackMessage) {\n if (err instanceof EmbedHostProxyInputError || err instanceof EmbedHostProxyNotConfiguredError) {\n return reply.code(err.status).send({ message: err.message });\n }\n if (err instanceof GatewayApiClientError) {\n return reply\n .code(err.status || 502)\n .send(\n err.details && typeof err.details === \"object\" ? err.details : { message: err.message },\n );\n }\n request.log.error({ err }, fallbackMessage);\n return reply.code(500).send({ message: fallbackMessage });\n}\n"],
4
+ "sourcesContent": ["// @ts-nocheck\nimport {\n EmbedHostProxyInputError,\n EmbedHostProxyNotConfiguredError,\n GatewayApiClientError,\n} from \"@xapps-platform/server-sdk\";\nimport crypto from \"node:crypto\";\n\nconst HOST_BOOTSTRAP_HEADER = \"x-xapps-host-bootstrap\";\n\nfunction toBase64Url(input) {\n return Buffer.from(String(input), \"utf8\").toString(\"base64url\");\n}\n\nfunction fromBase64UrlJson(input) {\n const raw = Buffer.from(String(input || \"\"), \"base64url\").toString(\"utf8\");\n return JSON.parse(raw);\n}\n\nfunction normalizeOrigin(value) {\n const raw = String(value || \"\").trim();\n return raw ? raw.replace(/\\/+$/, \"\") : \"\";\n}\n\nfunction normalizeAllowedOrigins(allowedOrigins = []) {\n return Array.isArray(allowedOrigins)\n ? allowedOrigins.map((entry) => normalizeOrigin(entry)).filter(Boolean)\n : [];\n}\n\nexport function readBodyRecord(value) {\n return value && typeof value === \"object\" && !Array.isArray(value) ? value : {};\n}\n\nexport function requireHostProxyService(hostProxyService) {\n if (!hostProxyService || typeof hostProxyService.getHostConfig !== \"function\") {\n throw new EmbedHostProxyNotConfiguredError(\"Host proxy service is not configured\");\n }\n return hostProxyService;\n}\n\nexport function readRequestOrigin(request) {\n return normalizeOrigin(request?.headers?.origin);\n}\n\nfunction readHostBootstrapToken(request) {\n return String(request?.headers?.[HOST_BOOTSTRAP_HEADER] || \"\").trim();\n}\n\nfunction issueHostBootstrapToken(payload, signingSecret) {\n const encodedPayload = toBase64Url(JSON.stringify(payload));\n const signature = crypto\n .createHmac(\"sha256\", String(signingSecret))\n .update(encodedPayload)\n .digest(\"base64url\");\n return `${encodedPayload}.${signature}`;\n}\n\nfunction verifyHostBootstrapToken(token, signingSecret) {\n const parts = String(token || \"\")\n .trim()\n .split(\".\");\n if (parts.length !== 2) {\n throw new EmbedHostProxyInputError(\"host bootstrap token is malformed\", 401);\n }\n const [encodedPayload, receivedSignature] = parts;\n const expectedSignature = crypto\n .createHmac(\"sha256\", String(signingSecret))\n .update(encodedPayload)\n .digest(\"base64url\");\n const received = Buffer.from(receivedSignature, \"utf8\");\n const expected = Buffer.from(expectedSignature, \"utf8\");\n if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {\n throw new EmbedHostProxyInputError(\"host bootstrap token is invalid\", 401);\n }\n const payload = fromBase64UrlJson(encodedPayload);\n if (!payload || typeof payload !== \"object\") {\n throw new EmbedHostProxyInputError(\"host bootstrap token payload is invalid\", 401);\n }\n const now = Math.floor(Date.now() / 1000);\n if (Number(payload.exp || 0) <= now) {\n throw new EmbedHostProxyInputError(\"host bootstrap token expired\", 401);\n }\n return payload;\n}\n\nexport function readHostBootstrapContext(request, bootstrap = {}) {\n const signingSecret = String(bootstrap?.signingSecret || \"\").trim();\n const token = readHostBootstrapToken(request);\n if (!token || !signingSecret) return null;\n const payload = verifyHostBootstrapToken(token, signingSecret);\n const requestOrigin = readRequestOrigin(request);\n const tokenOrigin = normalizeOrigin(payload.origin);\n if (tokenOrigin && requestOrigin && tokenOrigin !== requestOrigin) {\n throw new EmbedHostProxyInputError(\"host bootstrap token origin mismatch\", 401);\n }\n return {\n subjectId: String(payload.subjectId || \"\").trim() || null,\n email: String(payload.email || \"\").trim() || null,\n name: String(payload.name || \"\").trim() || null,\n origin: tokenOrigin || null,\n token,\n };\n}\n\nexport function requireHostBootstrapRequest(request, bootstrap = {}) {\n const allowedApiKeys = Array.isArray(bootstrap?.apiKeys)\n ? bootstrap.apiKeys.map((entry) => String(entry || \"\").trim()).filter(Boolean)\n : [];\n const signingSecret = String(bootstrap?.signingSecret || \"\").trim();\n if (allowedApiKeys.length === 0 || !signingSecret) {\n throw new EmbedHostProxyNotConfiguredError(\"Host bootstrap is not configured\");\n }\n const apiKey = String(request?.headers?.[\"x-api-key\"] || \"\").trim();\n if (!apiKey || !allowedApiKeys.includes(apiKey)) {\n throw new EmbedHostProxyInputError(\"Invalid host bootstrap api key\", 401);\n }\n return {\n apiKey,\n signingSecret,\n ttlSeconds:\n Number.isFinite(Number(bootstrap?.ttlSeconds)) && Number(bootstrap?.ttlSeconds) > 0\n ? Math.floor(Number(bootstrap.ttlSeconds))\n : 300,\n };\n}\n\nexport function buildHostBootstrapResult({\n subjectId,\n email,\n name,\n origin,\n signingSecret,\n ttlSeconds,\n}) {\n const now = Math.floor(Date.now() / 1000);\n const expiresIn = Number(ttlSeconds) > 0 ? Math.floor(Number(ttlSeconds)) : 300;\n const bootstrapToken = issueHostBootstrapToken(\n {\n v: 1,\n type: \"host_bootstrap\",\n subjectId: String(subjectId || \"\").trim(),\n email: String(email || \"\").trim(),\n name: String(name || \"\").trim(),\n origin: normalizeOrigin(origin),\n iat: now,\n exp: now + expiresIn,\n },\n signingSecret,\n );\n return {\n subjectId: String(subjectId || \"\").trim(),\n email: String(email || \"\").trim(),\n name: String(name || \"\").trim() || null,\n bootstrapToken,\n expiresIn,\n };\n}\n\nexport function isOriginAllowed(origin, allowedOrigins = []) {\n const normalizedOrigin = normalizeOrigin(origin);\n if (!normalizedOrigin) return true;\n const normalizedAllowedOrigins = normalizeAllowedOrigins(allowedOrigins);\n if (normalizedAllowedOrigins.length === 0) {\n return true;\n }\n return normalizedAllowedOrigins.includes(normalizedOrigin);\n}\n\nexport function applyHostApiCorsHeaders(reply, request, allowedOrigins = []) {\n const origin = readRequestOrigin(request);\n if (!origin) return;\n const normalizedAllowedOrigins = normalizeAllowedOrigins(allowedOrigins);\n if (normalizedAllowedOrigins.length === 0) return;\n if (!normalizedAllowedOrigins.includes(origin)) return;\n reply.header(\"Access-Control-Allow-Origin\", origin);\n reply.header(\"Vary\", \"Origin\");\n}\n\nexport function ensureHostApiOriginAllowed(request, reply, allowedOrigins = []) {\n const origin = readRequestOrigin(request);\n if (!origin) return true;\n if (!isOriginAllowed(origin, allowedOrigins)) {\n reply.code(403).send({ message: \"Origin is not allowed\" });\n return false;\n }\n applyHostApiCorsHeaders(reply, request, allowedOrigins);\n return true;\n}\n\nexport function sendHostApiPreflight(request, reply, allowedOrigins = []) {\n const origin = readRequestOrigin(request);\n if (origin && !isOriginAllowed(origin, allowedOrigins)) {\n return reply.code(403).send({ message: \"Origin is not allowed\" });\n }\n applyHostApiCorsHeaders(reply, request, allowedOrigins);\n const requestedHeaders = String(\n request?.headers?.[\"access-control-request-headers\"] || \"\",\n ).trim();\n reply.header(\"Access-Control-Allow-Methods\", \"GET, POST, OPTIONS\");\n reply.header(\n \"Access-Control-Allow-Headers\",\n requestedHeaders || \"Content-Type, Authorization, X-Xapps-Host-Bootstrap\",\n );\n reply.header(\"Access-Control-Max-Age\", \"600\");\n return reply.code(204).send();\n}\n\nexport function applyNoStoreHeaders(reply, hostProxyService) {\n const service = requireHostProxyService(hostProxyService);\n const headers = service.getNoStoreHeaders();\n reply.header(\"Cache-Control\", headers[\"Cache-Control\"]);\n reply.header(\"Pragma\", headers.Pragma);\n reply.header(\"Expires\", headers.Expires);\n return reply;\n}\n\nexport function sendServiceError(request, reply, err, fallbackMessage) {\n if (err instanceof EmbedHostProxyInputError || err instanceof EmbedHostProxyNotConfiguredError) {\n return reply.code(err.status).send({ message: err.message });\n }\n if (err instanceof GatewayApiClientError) {\n return reply\n .code(err.status || 502)\n .send(\n err.details && typeof err.details === \"object\" ? err.details : { message: err.message },\n );\n }\n request.log.error({ err }, fallbackMessage);\n return reply.code(500).send({ message: fallbackMessage });\n}\n"],
5
5
  "mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,YAAY;AAEnB,MAAM,wBAAwB;AAE9B,SAAS,YAAY,OAAO;AAC1B,SAAO,OAAO,KAAK,OAAO,KAAK,GAAG,MAAM,EAAE,SAAS,WAAW;AAChE;AAEA,SAAS,kBAAkB,OAAO;AAChC,QAAM,MAAM,OAAO,KAAK,OAAO,SAAS,EAAE,GAAG,WAAW,EAAE,SAAS,MAAM;AACzE,SAAO,KAAK,MAAM,GAAG;AACvB;AAEA,SAAS,gBAAgB,OAAO;AAC9B,QAAM,MAAM,OAAO,SAAS,EAAE,EAAE,KAAK;AACrC,SAAO,MAAM,IAAI,QAAQ,QAAQ,EAAE,IAAI;AACzC;AAEA,SAAS,wBAAwB,iBAAiB,CAAC,GAAG;AACpD,SAAO,MAAM,QAAQ,cAAc,IAC/B,eAAe,IAAI,CAAC,UAAU,gBAAgB,KAAK,CAAC,EAAE,OAAO,OAAO,IACpE,CAAC;AACP;AAEO,SAAS,eAAe,OAAO;AACpC,SAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC;AAChF;AAE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B,QAAQ,eAAe,CAAC;AACtD,QAAM,OAAO,UAAU,QAAQ,MAAM;AACrC,QAAM,OAAO,WAAW,QAAQ,OAAO;AACvC,SAAO;AACT;AAEO,SAAS,iBAAiB,SAAS,OAAO,KAAK,iBAAiB;AACrE,MAAI,eAAe,4BAA4B,eAAe,kCAAkC;AAC9F,WAAO,MAAM,KAAK,IAAI,MAAM,EAAE,KAAK,EAAE,SAAS,IAAI,QAAQ,CAAC;AAAA,EAC7D;AACA,MAAI,eAAe,uBAAuB;AACxC,WAAO,MACJ,KAAK,IAAI,UAAU,GAAG,EACtB;AAAA,MACC,IAAI,WAAW,OAAO,IAAI,YAAY,WAAW,IAAI,UAAU,EAAE,SAAS,IAAI,QAAQ;AAAA,IACxF;AAAA,EACJ;AACA,UAAQ,IAAI,MAAM,EAAE,IAAI,GAAG,eAAe;AAC1C,SAAO,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,SAAS,gBAAgB,CAAC;AAC1D;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,24 @@
1
- export default function healthRoutes(fastify: any, options?: {}): Promise<void>;
1
+ type HealthRouteOptions = {
2
+ branding?: {
3
+ serviceName?: string | null;
4
+ stackLabel?: string | null;
5
+ } | null;
6
+ reference?: {
7
+ mode?: string | null;
8
+ } | null;
9
+ tools?: unknown[] | null;
10
+ };
11
+ type HealthRouteResponse = {
12
+ ok: true;
13
+ service: string;
14
+ mode: string;
15
+ stack?: string;
16
+ tools?: unknown[];
17
+ time: string;
18
+ };
19
+ type FastifyLike = {
20
+ get: (path: string, handler: () => Promise<HealthRouteResponse> | HealthRouteResponse) => void;
21
+ };
22
+ export default function healthRoutes(fastify: FastifyLike, options?: HealthRouteOptions): Promise<void>;
23
+ export {};
2
24
  //# sourceMappingURL=health.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/backend/routes/health.ts"],"names":[],"mappings":"AAKA,wBAA8B,YAAY,CAAC,OAAO,KAAA,EAAE,OAAO,KAAK,iBAe/D"}
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/backend/routes/health.ts"],"names":[],"mappings":"AAAA,KAAK,kBAAkB,GAAG;IACxB,QAAQ,CAAC,EAAE;QACT,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B,GAAG,IAAI,CAAC;IACT,SAAS,CAAC,EAAE;QACV,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,GAAG,IAAI,CAAC;IACT,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,EAAE,EAAE,IAAI,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,KAAK,IAAI,CAAC;CAChG,CAAC;AAMF,wBAA8B,YAAY,CACxC,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAef"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/backend/routes/health.ts"],
4
- "sourcesContent": ["// @ts-nocheck\nfunction nowIso() {\n return new Date().toISOString();\n}\n\nexport default async function healthRoutes(fastify, options = {}) {\n const branding = options.branding && typeof options.branding === \"object\" ? options.branding : {};\n const reference =\n options.reference && typeof options.reference === \"object\" ? options.reference : {};\n const tools = Array.isArray(options.tools) ? options.tools.filter(Boolean) : [];\n fastify.get(\"/health\", async () => ({\n ok: true,\n service: String(branding.serviceName || \"\").trim() || \"tenant-backend\",\n mode: String(reference.mode || \"\").trim() || \"reference-minimum\",\n ...(String(branding.stackLabel || \"\").trim()\n ? { stack: String(branding.stackLabel).trim() }\n : {}),\n ...(tools.length > 0 ? { tools } : {}),\n time: nowIso(),\n }));\n}\n"],
5
- "mappings": "AACA,SAAS,SAAS;AAChB,UAAO,oBAAI,KAAK,GAAE,YAAY;AAChC;AAEA,eAAO,aAAoC,SAAS,UAAU,CAAC,GAAG;AAChE,QAAM,WAAW,QAAQ,YAAY,OAAO,QAAQ,aAAa,WAAW,QAAQ,WAAW,CAAC;AAChG,QAAM,YACJ,QAAQ,aAAa,OAAO,QAAQ,cAAc,WAAW,QAAQ,YAAY,CAAC;AACpF,QAAM,QAAQ,MAAM,QAAQ,QAAQ,KAAK,IAAI,QAAQ,MAAM,OAAO,OAAO,IAAI,CAAC;AAC9E,UAAQ,IAAI,WAAW,aAAa;AAAA,IAClC,IAAI;AAAA,IACJ,SAAS,OAAO,SAAS,eAAe,EAAE,EAAE,KAAK,KAAK;AAAA,IACtD,MAAM,OAAO,UAAU,QAAQ,EAAE,EAAE,KAAK,KAAK;AAAA,IAC7C,GAAI,OAAO,SAAS,cAAc,EAAE,EAAE,KAAK,IACvC,EAAE,OAAO,OAAO,SAAS,UAAU,EAAE,KAAK,EAAE,IAC5C,CAAC;AAAA,IACL,GAAI,MAAM,SAAS,IAAI,EAAE,MAAM,IAAI,CAAC;AAAA,IACpC,MAAM,OAAO;AAAA,EACf,EAAE;AACJ;",
4
+ "sourcesContent": ["type HealthRouteOptions = {\n branding?: {\n serviceName?: string | null;\n stackLabel?: string | null;\n } | null;\n reference?: {\n mode?: string | null;\n } | null;\n tools?: unknown[] | null;\n};\n\ntype HealthRouteResponse = {\n ok: true;\n service: string;\n mode: string;\n stack?: string;\n tools?: unknown[];\n time: string;\n};\n\ntype FastifyLike = {\n get: (path: string, handler: () => Promise<HealthRouteResponse> | HealthRouteResponse) => void;\n};\n\nfunction nowIso(): string {\n return new Date().toISOString();\n}\n\nexport default async function healthRoutes(\n fastify: FastifyLike,\n options: HealthRouteOptions = {},\n): Promise<void> {\n const branding = options.branding && typeof options.branding === \"object\" ? options.branding : {};\n const reference =\n options.reference && typeof options.reference === \"object\" ? options.reference : {};\n const tools = Array.isArray(options.tools) ? options.tools.filter(Boolean) : [];\n fastify.get(\"/health\", async () => ({\n ok: true,\n service: String(branding.serviceName || \"\").trim() || \"tenant-backend\",\n mode: String(reference.mode || \"\").trim() || \"reference-minimum\",\n ...(String(branding.stackLabel || \"\").trim()\n ? { stack: String(branding.stackLabel).trim() }\n : {}),\n ...(tools.length > 0 ? { tools } : {}),\n time: nowIso(),\n }));\n}\n"],
5
+ "mappings": "AAwBA,SAAS,SAAiB;AACxB,UAAO,oBAAI,KAAK,GAAE,YAAY;AAChC;AAEA,eAAO,aACL,SACA,UAA8B,CAAC,GAChB;AACf,QAAM,WAAW,QAAQ,YAAY,OAAO,QAAQ,aAAa,WAAW,QAAQ,WAAW,CAAC;AAChG,QAAM,YACJ,QAAQ,aAAa,OAAO,QAAQ,cAAc,WAAW,QAAQ,YAAY,CAAC;AACpF,QAAM,QAAQ,MAAM,QAAQ,QAAQ,KAAK,IAAI,QAAQ,MAAM,OAAO,OAAO,IAAI,CAAC;AAC9E,UAAQ,IAAI,WAAW,aAAa;AAAA,IAClC,IAAI;AAAA,IACJ,SAAS,OAAO,SAAS,eAAe,EAAE,EAAE,KAAK,KAAK;AAAA,IACtD,MAAM,OAAO,UAAU,QAAQ,EAAE,EAAE,KAAK,KAAK;AAAA,IAC7C,GAAI,OAAO,SAAS,cAAc,EAAE,EAAE,KAAK,IACvC,EAAE,OAAO,OAAO,SAAS,UAAU,EAAE,KAAK,EAAE,IAC5C,CAAC;AAAA,IACL,GAAI,MAAM,SAAS,IAAI,EAAE,MAAM,IAAI,CAAC;AAAA,IACpC,MAAM,OAAO;AAAA,EACf,EAAE;AACJ;",
6
6
  "names": []
7
7
  }
@@ -212,7 +212,7 @@ const OPTION_GROUPS = [
212
212
  ],
213
213
  notes: [
214
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."
215
+ "The tenant may keep the same contract in Node or reimplement it in PHP/Laravel via xapps-platform/xapps-php."
216
216
  ]
217
217
  },
218
218
  {
@@ -330,9 +330,9 @@ function readReferenceConfig(options = {}) {
330
330
  tenantPolicySlugs: Array.isArray(reference.tenantPolicySlugs) ? reference.tenantPolicySlugs : [],
331
331
  proofSources: Array.isArray(reference.proofSources) ? reference.proofSources : ["/api/reference", "/api/host-config", "/api/installations?subjectId=..."],
332
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"
333
+ node: "@xapps-platform/server-sdk",
334
+ php: "xapps-platform/xapps-php",
335
+ browser: "@xapps-platform/embed-sdk"
336
336
  },
337
337
  hostSurfaces: Array.isArray(reference.hostSurfaces) ? reference.hostSurfaces : [
338
338
  { key: "single-panel", label: "Single panel", recommended_for_first_lane: true },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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"],
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-platform/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-platform/server-sdk\",\n php: \"xapps-platform/xapps-php\",\n browser: \"@xapps-platform/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
5
  "mappings": "AACA,OAAO,QAAQ;AACf;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,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AAqB,UAAU;AAAA,MAC/B,eAAe,UAAU;AAAA,MACzB,WAAW,UAAU;AAAA,MACrB,eAAe,UAAU;AAAA,MACzB,eAAe,qBAAqB,OAAO,CAAC,SAAS,eAAe,IAAI,KAAK,GAAG,CAAC;AAAA,MACjF,gCAAgC,+BAA+B,aAAa,YAAY;AAAA,MACxF,iBAAiB;AAAA,MACjB,qBAAqB,yBAAyB,YAAY;AAAA,MAC1D,GAAI,UAAU,MAAM,SAAS,IAAI,EAAE,OAAO,UAAU,MAAM,IAAI,CAAC;AAAA,IACjE;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
package/dist/index.d.ts CHANGED
@@ -1,10 +1,49 @@
1
1
  import { createGatewayExecutionModule, createHostReferenceModule, createReferenceSurfaceModule, createHostProxyService } from "./backend/modules.js";
2
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
- }>;
3
+ import { normalizeBackendKitOptions, resolvePlatformSecretRefFromEnv, type BackendKitNormalizedOptions, type StringRecord } from "./backend/options.js";
4
+ type ReplyLike = {
5
+ code: (statusCode: number) => {
6
+ send: (payload: unknown) => unknown;
7
+ };
8
+ };
9
+ type RegisterableApp = {
10
+ setNotFoundHandler: (handler: (request: unknown, reply: ReplyLike) => Promise<unknown> | unknown) => void;
11
+ };
12
+ type RouteModule = {
13
+ registerRoutes: (app: RegisterableApp) => Promise<void> | void;
14
+ };
15
+ type BackendKitDeps = {
16
+ normalizeOptions?: (input: StringRecord) => BackendKitNormalizedOptions;
17
+ createReferenceSurfaceModule?: (input: {
18
+ gateway: BackendKitNormalizedOptions["gateway"];
19
+ branding: BackendKitNormalizedOptions["branding"];
20
+ enableReference: boolean;
21
+ enableLifecycle: boolean;
22
+ enableBridge: boolean;
23
+ enabledModes: string[];
24
+ reference: BackendKitNormalizedOptions["reference"];
25
+ }) => RouteModule;
26
+ createHostReferenceModule?: (input: {
27
+ gateway: BackendKitNormalizedOptions["gateway"];
28
+ branding: BackendKitNormalizedOptions["branding"];
29
+ reference: BackendKitNormalizedOptions["reference"];
30
+ enableLifecycle: boolean;
31
+ enableBridge: boolean;
32
+ allowedOrigins: string[];
33
+ bootstrap: BackendKitNormalizedOptions["host"]["bootstrap"];
34
+ hostProxyService: unknown;
35
+ }) => RouteModule;
36
+ createGatewayExecutionModule?: (input: {
37
+ enabledModes: string[];
38
+ subjectProfiles: BackendKitNormalizedOptions["subjectProfiles"];
39
+ paymentRuntime: unknown;
40
+ }) => RouteModule;
41
+ };
42
+ export type BackendKit = {
43
+ options: BackendKitNormalizedOptions;
44
+ registerRoutes: (app: RegisterableApp) => Promise<void>;
45
+ applyNotFoundHandler: (app: RegisterableApp) => void;
46
+ };
47
+ export declare function createBackendKit(input?: StringRecord, deps?: BackendKitDeps): Promise<BackendKit>;
9
48
  export { buildHostedGatewayPaymentUrl as buildHostedGatewayPaymentUrl, buildModeHostedGatewayPaymentUrl as buildModeHostedGatewayPaymentUrl, createGatewayExecutionModule, createHostReferenceModule, createReferenceSurfaceModule, createHostProxyService, createPaymentEvidenceHandler, createPaymentRuntime, extractHostedPaymentSessionId, normalizeBackendKitOptions, registerPaymentPageApiRoutes, registerPaymentPageAssetRoute, resolvePlatformSecretRefFromEnv, };
10
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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;AAC9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nB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,2BAA2B,CAAC;IACrC,cAAc,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,oBAAoB,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,KAAK,GAAE,YAAiB,EACxB,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,UAAU,CAAC,CA+DrB;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 CHANGED
@@ -13,18 +13,21 @@ import {
13
13
  registerPaymentPageApiRoutes,
14
14
  registerPaymentPageAssetRoute
15
15
  } from "./backend/paymentRuntime.js";
16
- import { normalizeBackendKitOptions, resolvePlatformSecretRefFromEnv } from "./backend/options.js";
16
+ import {
17
+ normalizeBackendKitOptions,
18
+ resolvePlatformSecretRefFromEnv
19
+ } from "./backend/options.js";
17
20
  async function createBackendKit(input = {}, deps = {}) {
18
21
  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) {
22
+ const createReferenceSurfaceModuleDep = typeof deps.createReferenceSurfaceModule === "function" ? deps.createReferenceSurfaceModule : null;
23
+ const createHostReferenceModuleDep = typeof deps.createHostReferenceModule === "function" ? deps.createHostReferenceModule : null;
24
+ const createGatewayExecutionModuleDep = typeof deps.createGatewayExecutionModule === "function" ? deps.createGatewayExecutionModule : null;
25
+ if (!normalizeOptions || !createReferenceSurfaceModuleDep || !createHostReferenceModuleDep || !createGatewayExecutionModuleDep) {
23
26
  throw new TypeError("backend kit dependencies are incomplete");
24
27
  }
25
28
  const options = normalizeOptions(input);
26
29
  const paymentRuntime = await createPaymentRuntime(options, deps);
27
- const referenceSurfaceModule = createReferenceSurfaceModule2({
30
+ const referenceSurfaceModule = createReferenceSurfaceModuleDep({
28
31
  gateway: options.gateway,
29
32
  branding: options.branding,
30
33
  enableReference: options.host.enableReference,
@@ -33,7 +36,7 @@ async function createBackendKit(input = {}, deps = {}) {
33
36
  enabledModes: options.payments.enabledModes,
34
37
  reference: options.reference
35
38
  });
36
- const hostReferenceModule = createHostReferenceModule2({
39
+ const hostReferenceModule = createHostReferenceModuleDep({
37
40
  gateway: options.gateway,
38
41
  branding: options.branding,
39
42
  reference: options.reference,
@@ -43,7 +46,7 @@ async function createBackendKit(input = {}, deps = {}) {
43
46
  bootstrap: options.host.bootstrap,
44
47
  hostProxyService: options.overrides.hostProxyService
45
48
  });
46
- const gatewayExecutionModule = createGatewayExecutionModule2({
49
+ const gatewayExecutionModule = createGatewayExecutionModuleDep({
47
50
  enabledModes: options.payments.enabledModes,
48
51
  subjectProfiles: options.subjectProfiles,
49
52
  paymentRuntime
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B,uCAAuC;AAE5E,eAAsB,iBAAiB,QAAQ,CAAC,GAAG,OAAO,CAAC,GAAG;AAC5D,QAAM,mBACJ,OAAO,KAAK,qBAAqB,aAAa,KAAK,mBAAmB;AACxE,QAAMA,gCACJ,OAAO,KAAK,iCAAiC,aACzC,KAAK,+BACL;AACN,QAAMC,6BACJ,OAAO,KAAK,8BAA8B,aAAa,KAAK,4BAA4B;AAC1F,QAAMC,gCACJ,OAAO,KAAK,iCAAiC,aACzC,KAAK,+BACL;AACN,MACE,CAAC,oBACD,CAACF,iCACD,CAACC,8BACD,CAACC,+BACD;AACA,UAAM,IAAI,UAAU,yCAAyC;AAAA,EAC/D;AAEA,QAAM,UAAU,iBAAiB,KAAK;AACtC,QAAM,iBAAiB,MAAM,qBAAqB,SAAS,IAAI;AAE/D,QAAM,yBAAyBF,8BAA6B;AAAA,IAC1D,SAAS,QAAQ;AAAA,IACjB,UAAU,QAAQ;AAAA,IAClB,iBAAiB,QAAQ,KAAK;AAAA,IAC9B,iBAAiB,QAAQ,KAAK;AAAA,IAC9B,cAAc,QAAQ,KAAK;AAAA,IAC3B,cAAc,QAAQ,SAAS;AAAA,IAC/B,WAAW,QAAQ;AAAA,EACrB,CAAC;AACD,QAAM,sBAAsBC,2BAA0B;AAAA,IACpD,SAAS,QAAQ;AAAA,IACjB,UAAU,QAAQ;AAAA,IAClB,WAAW,QAAQ;AAAA,IACnB,iBAAiB,QAAQ,KAAK;AAAA,IAC9B,cAAc,QAAQ,KAAK;AAAA,IAC3B,gBAAgB,QAAQ,KAAK;AAAA,IAC7B,WAAW,QAAQ,KAAK;AAAA,IACxB,kBAAkB,QAAQ,UAAU;AAAA,EACtC,CAAC;AACD,QAAM,yBAAyBC,8BAA6B;AAAA,IAC1D,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"]
4
+ "sourcesContent": ["import {\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 {\n normalizeBackendKitOptions,\n resolvePlatformSecretRefFromEnv,\n type BackendKitNormalizedOptions,\n type StringRecord,\n} from \"./backend/options.js\";\n\ntype ReplyLike = {\n code: (statusCode: number) => {\n send: (payload: unknown) => unknown;\n };\n};\n\ntype RegisterableApp = {\n setNotFoundHandler: (\n handler: (request: unknown, reply: ReplyLike) => Promise<unknown> | unknown,\n ) => void;\n};\n\ntype RouteModule = {\n registerRoutes: (app: RegisterableApp) => Promise<void> | void;\n};\n\ntype BackendKitDeps = {\n normalizeOptions?: (input: StringRecord) => BackendKitNormalizedOptions;\n createReferenceSurfaceModule?: (input: {\n gateway: BackendKitNormalizedOptions[\"gateway\"];\n branding: BackendKitNormalizedOptions[\"branding\"];\n enableReference: boolean;\n enableLifecycle: boolean;\n enableBridge: boolean;\n enabledModes: string[];\n reference: BackendKitNormalizedOptions[\"reference\"];\n }) => RouteModule;\n createHostReferenceModule?: (input: {\n gateway: BackendKitNormalizedOptions[\"gateway\"];\n branding: BackendKitNormalizedOptions[\"branding\"];\n reference: BackendKitNormalizedOptions[\"reference\"];\n enableLifecycle: boolean;\n enableBridge: boolean;\n allowedOrigins: string[];\n bootstrap: BackendKitNormalizedOptions[\"host\"][\"bootstrap\"];\n hostProxyService: unknown;\n }) => RouteModule;\n createGatewayExecutionModule?: (input: {\n enabledModes: string[];\n subjectProfiles: BackendKitNormalizedOptions[\"subjectProfiles\"];\n paymentRuntime: unknown;\n }) => RouteModule;\n};\n\nexport type BackendKit = {\n options: BackendKitNormalizedOptions;\n registerRoutes: (app: RegisterableApp) => Promise<void>;\n applyNotFoundHandler: (app: RegisterableApp) => void;\n};\n\nexport async function createBackendKit(\n input: StringRecord = {},\n deps: BackendKitDeps = {},\n): Promise<BackendKit> {\n const normalizeOptions =\n typeof deps.normalizeOptions === \"function\" ? deps.normalizeOptions : null;\n const createReferenceSurfaceModuleDep =\n typeof deps.createReferenceSurfaceModule === \"function\"\n ? deps.createReferenceSurfaceModule\n : null;\n const createHostReferenceModuleDep =\n typeof deps.createHostReferenceModule === \"function\" ? deps.createHostReferenceModule : null;\n const createGatewayExecutionModuleDep =\n typeof deps.createGatewayExecutionModule === \"function\"\n ? deps.createGatewayExecutionModule\n : null;\n if (\n !normalizeOptions ||\n !createReferenceSurfaceModuleDep ||\n !createHostReferenceModuleDep ||\n !createGatewayExecutionModuleDep\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 = createReferenceSurfaceModuleDep({\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 = createHostReferenceModuleDep({\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 = createGatewayExecutionModuleDep({\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": "AAAA;AAAA,EACE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