@facto-to/connect 0.0.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ "use strict";var P=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var i in t)P(e,i,{get:t[i],enumerable:!0})},V=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of $(t))!Z.call(e,c)&&c!==i&&P(e,c,{get:()=>t[c],enumerable:!(s=G(t,c))||s.enumerable});return e};var B=e=>V(P({},"__esModule",{value:!0}),e);var ae={};H(ae,{MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS:()=>O,MerchantPartnerWorkspaceMockError:()=>d,createFactoConnectFixtureTransport:()=>N,createFactoTestTransport:()=>ne,createMerchantPartnerWorkspaceMock:()=>D,devFixtures:()=>y,devScenarios:()=>re,merchantDevAppFixture:()=>F,merchantFutureTemplateProjectionFixture:()=>L,merchantProductionAppNegativeFixture:()=>q});module.exports=B(ae);var O=["listMerchantWorkspaceApps","createMerchantDevApp","rotateMerchantWorkspaceCredential"],J=new Set(["merchant_connect_dev","merchant_webhook_dev"]),d=class extends Error{status;constructor(t,i){super(t),this.name="MerchantPartnerWorkspaceMockError",this.status=i}};function D(e={}){let t=[],i=(e.initialApps??[]).map(v),s=new Set(e.authenticatedSession?.scopes??[]),c=e.now??(()=>new Date),o=new Map,r=new Map,n=i.length+1;return{client:{async listMerchantWorkspaceApps({environment:p}){if(t.push({operationId:"listMerchantWorkspaceApps",method:"GET",path:"/api/partner-workspace/merchant/apps",query:{environment:p}}),p!=="dev")throw new d("Environment filter is outside the mock server-derived context.",403);return{items:i.filter(h=>h.environment===p).map(v)}},async createMerchantDevApp({idempotencyKey:p,body:h}){let g=I(p),m=C(h,["display_name","capability_template","allowed_origins"]),k=E(m.display_name,"Display name",1,160);if(!Y(m.capability_template))throw new d("Capability template is not approved for Merchant dev app creation.",400);let l={display_name:k,capability_template:m.capability_template,allowed_origins:Q(m.allowed_origins)};t.push({operationId:"createMerchantDevApp",method:"POST",path:"/api/partner-workspace/merchant/apps",headers:{"Idempotency-Key":g},body:l});let u=ee(l),w=o.get(g);if(w){if(w.fingerprint!==u)throw W("createMerchantDevApp");return v(w.response)}let x={app_id:`dev_mcid_mock_${String(n).padStart(2,"0")}`,display_name:l.display_name,environment:"dev",capability_template:l.capability_template,status:"draft",allowed_origins:[...l.allowed_origins]};return n+=1,i.push(x),o.set(g,{fingerprint:u,response:v(x)}),v(x)},async rotateMerchantWorkspaceCredential(p){let h=I(p.idempotencyKey),g=C(p.body,["reason"]),m=E(g.reason,"Rotation reason",3,500);t.push({operationId:"rotateMerchantWorkspaceCredential",method:"POST",path:`/api/partner-workspace/merchant/apps/${encodeURIComponent(p.appId)}/credential-rotations`,headers:{"Idempotency-Key":h},authorization:"partnerSession:step_up",body:{reason:m}});let k=te(p.appId,m),l=r.get(h);if(l){if(l.fingerprint!==k)throw W("rotateMerchantWorkspaceCredential");return{...l.response}}if(!s.has("step_up"))throw new d("Recent step-up authentication is required.",403);let u=i.find(K=>K.app_id===p.appId);if(!u)throw new d("Merchant app is not visible in the active server-derived context.",409);if(u.environment!=="dev")throw new d("Merchant app is outside the mock server-derived context.",403);let w=u.credential_version??0;u.credential_version=w+1;let x=new Date(c().getTime()+300*1e3).toISOString(),S={credential_id:`credential:${u.app_id}`,new_version:u.credential_version,old_version_expires_at:x,retrieval_mode:"protected_retrieval_handle",retrieval_handle:`mock-retrieval:${u.app_id}:${u.credential_version}`};return r.set(h,{fingerprint:k,response:{...S}}),S}},requests:t}}function v(e){return{...e,allowed_origins:[...e.allowed_origins]}}function Y(e){return J.has(e)}function I(e){if(typeof e!="string")throw _("Idempotency-Key must contain between 16 and 128 characters.");let t=e.trim();if(t.length<16||t.length>128)throw _("Idempotency-Key must contain between 16 and 128 characters.");return t}function C(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw _("Request body must be an object.");let i=new Set(t);if(Reflect.ownKeys(e).some(s=>typeof s!="string"||!i.has(s)))throw _("Request body contains an unsupported property.");return e}function E(e,t,i,s){if(typeof e!="string")throw _(`${t} must be a string.`);let c=e.trim(),o=Array.from(c).length;if(o<i||o>s)throw _(`${t} must contain between ${i} and ${s} characters.`);return c}function Q(e){if(!Array.isArray(e)||e.length>20)throw f("Allowed origins must be an array with at most 20 entries.");let t=[],i=new Set;for(let s of e){if(typeof s!="string"||s.length===0||/\s/.test(s))throw f("Each allowed origin must be a non-empty exact URL origin.");let c=/^(https?):\/\/([^/?#\\]+)\/?$/i.exec(s);if(!c)throw f("Allowed origins cannot include a path, query, or fragment.");let o;try{o=new URL(s)}catch{throw f("Allowed origin URL parsing failed.")}if(o.protocol!=="https:"&&o.protocol!=="http:"||o.username!==""||o.password!==""||o.pathname!=="/"||o.search!==""||o.hash!=="")throw f("Allowed origins must be credential-free exact HTTP(S) origins.");if(o.protocol==="http:"){let r=X(c[2]??"").toLowerCase();if(!(r==="localhost"||r==="127.0.0.1"||r==="[::1]"))throw f("Plain HTTP is allowed only for exact loopback origins.")}if(i.has(o.origin))throw f("Allowed origins must be unique after canonicalization.");i.add(o.origin),t.push(o.origin)}return t}function X(e){if(e.startsWith("[")){let i=e.indexOf("]");return i===-1?e:e.slice(0,i+1)}let t=e.lastIndexOf(":");return t===-1?e:e.slice(0,t)}function f(e){return new d(e,400)}function _(e){return new d(e,400)}function ee(e){return JSON.stringify({display_name:e.display_name,capability_template:e.capability_template,allowed_origins:[...e.allowed_origins].sort()})}function te(e,t){return JSON.stringify({app_id:e,reason:t})}function W(e){return new d(`Idempotency key was already used for a different ${e} request.`,409)}var F={app_id:"dev_mcid_fixture_01",display_name:"Fixture storefront",environment:"dev",capability_template:"merchant_connect_dev",status:"draft",allowed_origins:["https://merchant.example"]},q={app_id:"production_mcid_fixture_01",display_name:"Production boundary fixture",environment:"production",capability_template:"merchant_connect_dev",status:"active",allowed_origins:["https://merchant.example"],credential_version:3},L={app_id:"app_fixture_future",display_name:"Future template fixture",environment:"dev",capability_template:"merchant_connect_dev_with_diagnostics",status:"active",allowed_origins:["https://merchant.example"],credential_version:1};var re=Object.freeze(["approved","declined_setup","declined_limit","payment_failed"]),y=Object.freeze({capabilities:{environment:"dev",contractVersion:"2026-07-09",checkedAt:"2026-07-10T00:00:00.000Z",capabilities:[{name:"fixtures",status:"ready",evidenceLevel:"verified",reasonCode:null,verifiedAt:"2026-07-10T00:00:00.000Z",limits:{networkCalls:0}},...["synthetic_identity","faucet","simulation","money_loop","webhook_test_delivery"].map(e=>({name:e,status:"unavailable",evidenceLevel:"contract",reasonCode:"DEV_NOT_DEPLOYED",verifiedAt:null,limits:{}}))]},faucetTransfer:{faucetTransferId:"sft_fixture_1001",userLinkRef:"ul_fixture_buyer_01",amount:{amount:"10.00",currency:"USDC"},status:"accepted",createdAt:"2026-07-10T00:00:00.000Z"},simulation:{simulationId:"sim_fixture_1001",scenario:"approved",executionMode:"pre_admission",status:"accepted",reasonCode:null,authorizationRef:null,chargeRef:null,createdAt:"2026-07-10T00:00:00.000Z",updatedAt:"2026-07-10T00:00:00.000Z"},webhookTestDelivery:{eventId:"evt_fixturetestping1001",deliveryId:"wd_fixturetestping1001",status:"queued",createdAt:"2026-07-10T00:00:00.000Z"}}),b="2026-07-10T00:00:00.000Z",j="0x1111111111111111111111111111111111111111";function N(e={}){let t=e.scenario??"happy_path",i=0;return async(s,c)=>{let o=new URL(s),r=(c?.method??"GET").toUpperCase(),n=o.pathname;if(r==="POST"&&n==="/api/merchant/user-links/exchange")return a({appId:"app_fixture",userLinkRef:"ul_fixture_buyer_01",factoUserId:"user_fixture",factoServerWalletAddress:j,grantStatus:"active",pipelineReady:t!=="setup_required",scopes:["wallet.read","payments.write"]});if(r==="POST"&&n==="/api/merchant/payment-readiness")return a({appId:"app_fixture",userLinkRef:"ul_fixture_buyer_01",factoUserId:"user_fixture",factoServerWalletAddress:j,selectedPipelineId:"pipeline_fixture",chainId:84532,protocolId:"aave-v3",assetSymbol:"USDC",spendMode:"direct",pipelineReady:t!=="setup_required",...t==="setup_required"?{notReadyReason:"payment_route_not_provisioned"}:{}});if(r==="POST"&&n==="/api/merchant/checkout-sessions")return a({sessionId:"checkout_fixture",checkoutUrl:"https://dev.facto.to/checkout/checkout_fixture",status:"pending",amount:"9.99",assetSymbol:"USDC",orderRef:"order_fixture"});if(r==="GET"&&n.startsWith("/api/merchant/checkout-sessions/"))return a({sessionId:"checkout_fixture",status:"charged",amount:"9.99",assetSymbol:"USDC",orderRef:"order_fixture",chargeId:"charge_fixture",confirmedAt:b});if(r==="POST"&&n==="/api/merchant/authorization-sessions")return a(z("created"));if(r==="GET"&&n.startsWith("/api/merchant/authorization-sessions/"))return a(z("authorized"));if(r==="GET"&&n.startsWith("/api/merchant/payment-authorizations/"))return a(U());if(r==="POST"&&n==="/api/merchant/payment-options")return a({paymentOptions:[{paymentOptionId:"fpo_fixture",label:"Fixture Direct",ready:t!=="setup_required",isDefault:!0,chainId:84532,chainLabel:"Base Sepolia",protocolLabel:"Aave V3",assetSymbol:"USDC",spendMode:"direct",settlementPath:"direct",...t==="setup_required"?{blockingReason:"setup_required"}:{}}],defaultPaymentOptionId:"fpo_fixture"});if(r==="POST"&&n==="/api/merchant/payments")return t==="idempotency_conflict"?a({code:"idempotency_conflict",message:"fixture idempotency conflict"},409):a(A(t==="declined_before_money"?"declined":"charging"));if(r==="GET"&&n.startsWith("/api/merchant/payments/")){let M=t==="status_progression"?["charging","finalizing","succeeded"]:["succeeded"],p=M[Math.min(i,M.length-1)]??"succeeded";return i+=1,a(A(p))}return r==="DELETE"&&n.startsWith("/api/merchant/user-links/")?new Response(null,{status:204}):r==="GET"&&n==="/api/merchant/payments"?a({data:[A("succeeded")],hasMore:!1}):r==="GET"&&n==="/api/merchant/payment-authorizations"?a({data:[U()],hasMore:!1}):r==="POST"&&n==="/api/merchant/refunds"?a(R()):r==="GET"&&n==="/api/merchant/refunds"?a({data:[R()],hasMore:!1}):r==="GET"&&n.startsWith("/api/merchant/refunds/")?a(R()):r==="POST"&&n==="/api/merchant/webhook-endpoints"?a({...T(),secret:"whsec_fixture_only"}):r==="GET"&&n==="/api/dev/capabilities"?a(y.capabilities):r==="POST"&&n==="/api/dev/faucet/usdc"?a(y.faucetTransfer,202):r==="POST"&&n==="/api/dev/simulate/charge"?a(y.simulation,202):r==="GET"&&n.startsWith("/api/dev/simulations/")?a(y.simulation):r==="POST"&&n.endsWith("/test-delivery")&&n.startsWith("/api/merchant/webhook-endpoints/")?a(y.webhookTestDelivery,202):r==="GET"&&n==="/api/merchant/webhook-endpoints"?a({data:[T()]}):r==="POST"&&n.endsWith("/rotate-secret")&&n.startsWith("/api/merchant/webhook-endpoints/")?a({...T(),secret:"whsec_fixture_rotated"}):r==="GET"&&n.startsWith("/api/merchant/webhook-endpoints/")?a(T()):r==="DELETE"&&n.startsWith("/api/merchant/webhook-endpoints/")?new Response(null,{status:204}):a({code:"fixture_route_not_found",method:r,path:n},404)}}var ne=N;function z(e){return{sessionId:"mauth_fixture",authorizationUrl:"https://dev.facto.to/merchant-mandates/authorize?session=mauth_fixture",status:e,...e==="authorized"?{mandateId:"mandate_fixture"}:{},expiresAt:"2026-07-10T00:15:00.000Z",state:"state_fixture"}}function U(){return{mandateId:"mandate_fixture",appId:"app_fixture",status:"active",allowedUseCases:["immediate","recurring","metered"],limits:{perTxAmount:"100.00",periodAmount:"500.00",period:"monthly"},paymentPath:{ready:!0,summary:"Fixture payment path ready"},createdAt:b}}function A(e){return{paymentId:"mpay_fixture",mandateId:"mandate_fixture",merchantPaymentRef:"payment_fixture",status:e,amount:e==="declined"?"75.00":"9.99",currency:"USDC",useCase:e==="declined"?"metered":"recurring",...e==="declined"?{declineReason:"mandate_limit_exceeded"}:{},...e==="succeeded"?{chargeId:"charge_fixture",txHash:`0x${"1".repeat(64)}`,terminalAt:"2026-07-10T00:00:03.000Z"}:{},createdAt:b,updatedAt:"2026-07-10T00:00:03.000Z"}}function R(){return{refundId:"refund_fixture",paymentId:"mpay_fixture",status:"succeeded",amount:"9.99",currency:"USDC",reason:"requested_by_customer",merchantRefundRef:"merchant_refund_fixture",createdAt:b}}function T(){return{webhookEndpointId:"webhook_fixture",url:"https://merchant.example/facto-webhooks",enabledEvents:["payment.succeeded","payment.failed"],status:"enabled",createdAt:b}}function a(e,t=200){return new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json"}})}
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/testing/index.ts","../../src/testing/partner-workspace/index.ts","../../src/testing/partner-workspace/fixtures.ts"],"sourcesContent":["import type {\n FactoConnectTransport,\n MandatePaymentStatus,\n DevCapabilities,\n DevFaucetTransfer,\n DevSimulation,\n WebhookTestDeliveryAccepted,\n} from '../server/index'\n\nexport {\n createMerchantPartnerWorkspaceMock,\n MerchantPartnerWorkspaceMockError,\n MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS,\n} from './partner-workspace/index'\nexport type {\n CreateMerchantDevAppRequest,\n CredentialRotationResult,\n MerchantAppProjection,\n MerchantCapabilityTemplate,\n MerchantPartnerWorkspaceClient,\n MerchantPartnerWorkspaceOperationId,\n MerchantPartnerWorkspaceRequest,\n PartnerSessionScope,\n PartnerWorkspaceEnvironment,\n} from './partner-workspace/index'\nexport {\n merchantFutureTemplateProjectionFixture,\n merchantProductionAppNegativeFixture,\n merchantDevAppFixture,\n} from './partner-workspace/fixtures'\n\nexport type FactoConnectFixtureScenario =\n | 'happy_path'\n | 'setup_required'\n | 'idempotency_conflict'\n | 'declined_before_money'\n | 'status_progression'\n\nexport interface FactoConnectFixtureTransportOptions {\n scenario?: FactoConnectFixtureScenario\n}\n\n/** Contract-aligned Dev scenarios for zero-network consumer tests. */\nexport const devScenarios = Object.freeze([\n 'approved',\n 'declined_setup',\n 'declined_limit',\n 'payment_failed',\n] as const)\n\n/** Deterministic public Dev projections. They model contract data, not deployment availability. */\nexport const devFixtures: Readonly<{\n capabilities: DevCapabilities\n faucetTransfer: DevFaucetTransfer\n simulation: DevSimulation\n webhookTestDelivery: WebhookTestDeliveryAccepted\n}> = Object.freeze({\n capabilities: {\n environment: 'dev',\n contractVersion: '2026-07-09',\n checkedAt: '2026-07-10T00:00:00.000Z',\n capabilities: [\n {\n name: 'fixtures',\n status: 'ready',\n evidenceLevel: 'verified',\n reasonCode: null,\n verifiedAt: '2026-07-10T00:00:00.000Z',\n limits: { networkCalls: 0 },\n },\n ...(['synthetic_identity', 'faucet', 'simulation', 'money_loop', 'webhook_test_delivery'] as const).map(\n (name) => ({\n name,\n status: 'unavailable' as const,\n evidenceLevel: 'contract' as const,\n reasonCode: 'DEV_NOT_DEPLOYED',\n verifiedAt: null,\n limits: {},\n }),\n ),\n ],\n },\n faucetTransfer: {\n faucetTransferId: 'sft_fixture_1001',\n userLinkRef: 'ul_fixture_buyer_01',\n amount: { amount: '10.00', currency: 'USDC' },\n status: 'accepted',\n createdAt: '2026-07-10T00:00:00.000Z',\n },\n simulation: {\n simulationId: 'sim_fixture_1001',\n scenario: 'approved',\n executionMode: 'pre_admission',\n status: 'accepted',\n reasonCode: null,\n authorizationRef: null,\n chargeRef: null,\n createdAt: '2026-07-10T00:00:00.000Z',\n updatedAt: '2026-07-10T00:00:00.000Z',\n },\n webhookTestDelivery: {\n eventId: 'evt_fixturetestping1001',\n deliveryId: 'wd_fixturetestping1001',\n status: 'queued',\n createdAt: '2026-07-10T00:00:00.000Z',\n },\n})\n\nconst CREATED_AT = '2026-07-10T00:00:00.000Z'\nconst WALLET = '0x1111111111111111111111111111111111111111'\n\n/**\n * Create a deterministic, in-memory transport for server SDK tests and demos.\n * It never performs DNS resolution or network I/O and returns payloads through\n * the same strict parsers used by the real client.\n */\nexport function createFactoConnectFixtureTransport(\n options: FactoConnectFixtureTransportOptions = {},\n): FactoConnectTransport {\n const scenario = options.scenario ?? 'happy_path'\n let statusIndex = 0\n\n return async (input, init) => {\n const url = new URL(input)\n const method = (init?.method ?? 'GET').toUpperCase()\n const path = url.pathname\n\n if (method === 'POST' && path === '/api/merchant/user-links/exchange') {\n return json({\n appId: 'app_fixture',\n userLinkRef: 'ul_fixture_buyer_01',\n factoUserId: 'user_fixture',\n factoServerWalletAddress: WALLET,\n grantStatus: 'active',\n pipelineReady: scenario !== 'setup_required',\n scopes: ['wallet.read', 'payments.write'],\n })\n }\n\n if (method === 'POST' && path === '/api/merchant/payment-readiness') {\n return json({\n appId: 'app_fixture',\n userLinkRef: 'ul_fixture_buyer_01',\n factoUserId: 'user_fixture',\n factoServerWalletAddress: WALLET,\n selectedPipelineId: 'pipeline_fixture',\n chainId: 84532,\n protocolId: 'aave-v3',\n assetSymbol: 'USDC',\n spendMode: 'direct',\n pipelineReady: scenario !== 'setup_required',\n ...(scenario === 'setup_required'\n ? { notReadyReason: 'payment_route_not_provisioned' }\n : {}),\n })\n }\n\n if (method === 'POST' && path === '/api/merchant/checkout-sessions') {\n return json({\n sessionId: 'checkout_fixture',\n checkoutUrl: 'https://dev.facto.to/checkout/checkout_fixture',\n status: 'pending',\n amount: '9.99',\n assetSymbol: 'USDC',\n orderRef: 'order_fixture',\n })\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/checkout-sessions/')) {\n return json({\n sessionId: 'checkout_fixture',\n status: 'charged',\n amount: '9.99',\n assetSymbol: 'USDC',\n orderRef: 'order_fixture',\n chargeId: 'charge_fixture',\n confirmedAt: CREATED_AT,\n })\n }\n\n if (method === 'POST' && path === '/api/merchant/authorization-sessions') {\n return json(mandateAuthorizationFixture('created'))\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/authorization-sessions/')) {\n return json(mandateAuthorizationFixture('authorized'))\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/payment-authorizations/')) {\n return json(mandateFixture())\n }\n\n if (method === 'POST' && path === '/api/merchant/payment-options') {\n return json({\n paymentOptions: [\n {\n paymentOptionId: 'fpo_fixture',\n label: 'Fixture Direct',\n ready: scenario !== 'setup_required',\n isDefault: true,\n chainId: 84532,\n chainLabel: 'Base Sepolia',\n protocolLabel: 'Aave V3',\n assetSymbol: 'USDC',\n spendMode: 'direct',\n settlementPath: 'direct',\n ...(scenario === 'setup_required' ? { blockingReason: 'setup_required' } : {}),\n },\n ],\n // A mock earns its keep only by emitting what the engine emits. The\n // engine's key here is `defaultPaymentOptionId`; this mock said\n // `selectedPaymentOptionId` (the checkout-state DTO's key) and so\n // agreed with the SDK's broken parser instead of with the engine —\n // the two-way fake green of Facto-to/facto#472 B.\n defaultPaymentOptionId: 'fpo_fixture',\n })\n }\n\n if (method === 'POST' && path === '/api/merchant/payments') {\n if (scenario === 'idempotency_conflict') {\n return json(\n { code: 'idempotency_conflict', message: 'fixture idempotency conflict' },\n 409,\n )\n }\n if (scenario === 'declined_before_money') {\n return json(paymentFixture('declined'))\n }\n return json(paymentFixture('charging'))\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/payments/')) {\n const statuses: readonly MandatePaymentStatus[] =\n scenario === 'status_progression'\n ? ['charging', 'finalizing', 'succeeded']\n : ['succeeded']\n const status = statuses[Math.min(statusIndex, statuses.length - 1)] ?? 'succeeded'\n statusIndex += 1\n return json(paymentFixture(status))\n }\n\n if (method === 'DELETE' && path.startsWith('/api/merchant/user-links/')) {\n return new Response(null, { status: 204 })\n }\n\n if (method === 'GET' && path === '/api/merchant/payments') {\n return json({ data: [paymentFixture('succeeded')], hasMore: false })\n }\n\n if (method === 'GET' && path === '/api/merchant/payment-authorizations') {\n return json({ data: [mandateFixture()], hasMore: false })\n }\n\n if (method === 'POST' && path === '/api/merchant/refunds') {\n return json(refundFixture())\n }\n\n if (method === 'GET' && path === '/api/merchant/refunds') {\n return json({ data: [refundFixture()], hasMore: false })\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/refunds/')) {\n return json(refundFixture())\n }\n\n if (method === 'POST' && path === '/api/merchant/webhook-endpoints') {\n return json({ ...webhookEndpointFixture(), secret: 'whsec_fixture_only' })\n }\n\n if (method === 'GET' && path === '/api/dev/capabilities') {\n return json(devFixtures.capabilities)\n }\n\n if (method === 'POST' && path === '/api/dev/faucet/usdc') {\n return json(devFixtures.faucetTransfer, 202)\n }\n\n if (method === 'POST' && path === '/api/dev/simulate/charge') {\n return json(devFixtures.simulation, 202)\n }\n\n if (method === 'GET' && path.startsWith('/api/dev/simulations/')) {\n return json(devFixtures.simulation)\n }\n\n if (\n method === 'POST' &&\n path.endsWith('/test-delivery') &&\n path.startsWith('/api/merchant/webhook-endpoints/')\n ) {\n return json(devFixtures.webhookTestDelivery, 202)\n }\n\n if (method === 'GET' && path === '/api/merchant/webhook-endpoints') {\n return json({ data: [webhookEndpointFixture()] })\n }\n\n if (\n method === 'POST' &&\n path.endsWith('/rotate-secret') &&\n path.startsWith('/api/merchant/webhook-endpoints/')\n ) {\n return json({ ...webhookEndpointFixture(), secret: 'whsec_fixture_rotated' })\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/webhook-endpoints/')) {\n return json(webhookEndpointFixture())\n }\n\n if (method === 'DELETE' && path.startsWith('/api/merchant/webhook-endpoints/')) {\n return new Response(null, { status: 204 })\n }\n\n return json({ code: 'fixture_route_not_found', method, path }, 404)\n }\n}\n\n/** Alias named by `dev-sdk-surface-v1`; remains fully in-memory. */\nexport const createFactoTestTransport = createFactoConnectFixtureTransport\n\nfunction mandateAuthorizationFixture(status: 'created' | 'authorized'): Record<string, unknown> {\n return {\n sessionId: 'mauth_fixture',\n authorizationUrl: 'https://dev.facto.to/merchant-mandates/authorize?session=mauth_fixture',\n status,\n ...(status === 'authorized' ? { mandateId: 'mandate_fixture' } : {}),\n expiresAt: '2026-07-10T00:15:00.000Z',\n state: 'state_fixture',\n }\n}\n\nfunction mandateFixture(): Record<string, unknown> {\n return {\n mandateId: 'mandate_fixture',\n appId: 'app_fixture',\n status: 'active',\n allowedUseCases: ['immediate', 'recurring', 'metered'],\n limits: { perTxAmount: '100.00', periodAmount: '500.00', period: 'monthly' },\n paymentPath: { ready: true, summary: 'Fixture payment path ready' },\n createdAt: CREATED_AT,\n }\n}\n\nfunction paymentFixture(status: MandatePaymentStatus): Record<string, unknown> {\n return {\n paymentId: 'mpay_fixture',\n mandateId: 'mandate_fixture',\n merchantPaymentRef: 'payment_fixture',\n status,\n amount: status === 'declined' ? '75.00' : '9.99',\n currency: 'USDC',\n useCase: status === 'declined' ? 'metered' : 'recurring',\n ...(status === 'declined' ? { declineReason: 'mandate_limit_exceeded' } : {}),\n ...(status === 'succeeded'\n ? {\n chargeId: 'charge_fixture',\n txHash: `0x${'1'.repeat(64)}`,\n terminalAt: '2026-07-10T00:00:03.000Z',\n }\n : {}),\n createdAt: CREATED_AT,\n updatedAt: '2026-07-10T00:00:03.000Z',\n }\n}\n\nfunction refundFixture(): Record<string, unknown> {\n return {\n refundId: 'refund_fixture',\n paymentId: 'mpay_fixture',\n status: 'succeeded',\n amount: '9.99',\n currency: 'USDC',\n reason: 'requested_by_customer',\n merchantRefundRef: 'merchant_refund_fixture',\n createdAt: CREATED_AT,\n }\n}\n\nfunction webhookEndpointFixture(): Record<string, unknown> {\n return {\n webhookEndpointId: 'webhook_fixture',\n url: 'https://merchant.example/facto-webhooks',\n enabledEvents: ['payment.succeeded', 'payment.failed'],\n status: 'enabled',\n createdAt: CREATED_AT,\n }\n}\n\nfunction json(body: unknown, status = 200): Response {\n return new Response(JSON.stringify(body), {\n status,\n headers: { 'content-type': 'application/json' },\n })\n}\n","export const MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS = [\n 'listMerchantWorkspaceApps',\n 'createMerchantDevApp',\n 'rotateMerchantWorkspaceCredential',\n] as const\n\nexport type MerchantPartnerWorkspaceOperationId =\n (typeof MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS)[number]\n\nexport type PartnerWorkspaceEnvironment = 'dev' | 'mainnet_staging' | 'production'\n\nexport type MerchantCapabilityTemplate =\n | 'merchant_connect_dev'\n | 'merchant_webhook_dev'\n\nconst MERCHANT_CAPABILITY_TEMPLATE_ALLOWLIST = new Set<MerchantCapabilityTemplate>([\n 'merchant_connect_dev',\n 'merchant_webhook_dev',\n])\n\nexport interface MerchantAppProjection {\n app_id: string\n display_name: string\n environment: PartnerWorkspaceEnvironment\n capability_template: string\n status: 'draft' | 'ready' | 'active' | 'disabled'\n allowed_origins: string[]\n credential_version?: number\n}\n\nexport interface CreateMerchantDevAppRequest {\n display_name: string\n capability_template: MerchantCapabilityTemplate\n allowed_origins: string[]\n}\n\nexport interface CredentialRotationResult {\n credential_id: string\n new_version: number\n old_version_expires_at: string\n retrieval_mode: 'show_once' | 'protected_retrieval_handle'\n one_time_secret?: string\n retrieval_handle?: string\n}\n\nexport interface MerchantPartnerWorkspaceClient {\n listMerchantWorkspaceApps(input: {\n environment: PartnerWorkspaceEnvironment\n }): Promise<{ items: MerchantAppProjection[] }>\n createMerchantDevApp(input: {\n idempotencyKey: string\n body: CreateMerchantDevAppRequest\n }): Promise<MerchantAppProjection>\n rotateMerchantWorkspaceCredential(input: {\n appId: string\n idempotencyKey: string\n body: { reason: string }\n }): Promise<CredentialRotationResult>\n}\n\nexport type PartnerSessionScope = 'step_up'\n\nexport type MerchantPartnerWorkspaceRequest =\n | {\n operationId: 'listMerchantWorkspaceApps'\n method: 'GET'\n path: '/api/partner-workspace/merchant/apps'\n query: { environment: PartnerWorkspaceEnvironment }\n }\n | {\n operationId: 'createMerchantDevApp'\n method: 'POST'\n path: '/api/partner-workspace/merchant/apps'\n headers: { 'Idempotency-Key': string }\n body: CreateMerchantDevAppRequest\n }\n | {\n operationId: 'rotateMerchantWorkspaceCredential'\n method: 'POST'\n path: string\n headers: { 'Idempotency-Key': string }\n authorization: 'partnerSession:step_up'\n body: { reason: string }\n }\n\nexport class MerchantPartnerWorkspaceMockError extends Error {\n readonly status: number\n\n constructor(message: string, status: number) {\n super(message)\n this.name = 'MerchantPartnerWorkspaceMockError'\n this.status = status\n }\n}\n\nexport function createMerchantPartnerWorkspaceMock(options: {\n initialApps?: readonly MerchantAppProjection[]\n authenticatedSession?: { scopes: readonly PartnerSessionScope[] }\n now?: () => Date\n} = {}): {\n client: MerchantPartnerWorkspaceClient\n requests: MerchantPartnerWorkspaceRequest[]\n} {\n const requests: MerchantPartnerWorkspaceRequest[] = []\n const apps = (options.initialApps ?? []).map(cloneApp)\n const sessionScopes = new Set(options.authenticatedSession?.scopes ?? [])\n const now = options.now ?? (() => new Date())\n const createIdempotency = new Map<\n string,\n { fingerprint: string; response: MerchantAppProjection }\n >()\n const rotationIdempotency = new Map<\n string,\n { fingerprint: string; response: CredentialRotationResult }\n >()\n let nextApp = apps.length + 1\n\n const client: MerchantPartnerWorkspaceClient = {\n async listMerchantWorkspaceApps({ environment }) {\n requests.push({\n operationId: 'listMerchantWorkspaceApps',\n method: 'GET',\n path: '/api/partner-workspace/merchant/apps',\n query: { environment },\n })\n\n if (environment !== 'dev') {\n throw new MerchantPartnerWorkspaceMockError(\n 'Environment filter is outside the mock server-derived context.',\n 403,\n )\n }\n\n return {\n items: apps.filter((app) => app.environment === environment).map(cloneApp),\n }\n },\n\n async createMerchantDevApp({ idempotencyKey, body }) {\n const normalizedIdempotencyKey = validateIdempotencyKey(idempotencyKey)\n const bodyRecord = validateRequestObject(body, [\n 'display_name',\n 'capability_template',\n 'allowed_origins',\n ])\n const displayName = validateTrimmedString(bodyRecord.display_name, 'Display name', 1, 160)\n if (!isMerchantCapabilityTemplate(bodyRecord.capability_template)) {\n throw new MerchantPartnerWorkspaceMockError(\n 'Capability template is not approved for Merchant dev app creation.',\n 400,\n )\n }\n const requestBody: CreateMerchantDevAppRequest = {\n display_name: displayName,\n capability_template: bodyRecord.capability_template,\n allowed_origins: canonicalizeAllowedOrigins(bodyRecord.allowed_origins),\n }\n requests.push({\n operationId: 'createMerchantDevApp',\n method: 'POST',\n path: '/api/partner-workspace/merchant/apps',\n headers: { 'Idempotency-Key': normalizedIdempotencyKey },\n body: requestBody,\n })\n\n const fingerprint = createRequestFingerprint(requestBody)\n const replay = createIdempotency.get(normalizedIdempotencyKey)\n if (replay) {\n if (replay.fingerprint !== fingerprint) {\n throw idempotencyConflict('createMerchantDevApp')\n }\n return cloneApp(replay.response)\n }\n\n const app: MerchantAppProjection = {\n app_id: `dev_mcid_mock_${String(nextApp).padStart(2, '0')}`,\n display_name: requestBody.display_name,\n environment: 'dev',\n capability_template: requestBody.capability_template,\n status: 'draft',\n allowed_origins: [...requestBody.allowed_origins],\n }\n nextApp += 1\n apps.push(app)\n createIdempotency.set(normalizedIdempotencyKey, {\n fingerprint,\n response: cloneApp(app),\n })\n return cloneApp(app)\n },\n\n async rotateMerchantWorkspaceCredential(input) {\n const normalizedIdempotencyKey = validateIdempotencyKey(input.idempotencyKey)\n const bodyRecord = validateRequestObject(input.body, ['reason'])\n const reason = validateTrimmedString(bodyRecord.reason, 'Rotation reason', 3, 500)\n requests.push({\n operationId: 'rotateMerchantWorkspaceCredential',\n method: 'POST',\n path: `/api/partner-workspace/merchant/apps/${encodeURIComponent(input.appId)}/credential-rotations`,\n headers: { 'Idempotency-Key': normalizedIdempotencyKey },\n authorization: 'partnerSession:step_up',\n body: { reason },\n })\n\n const fingerprint = rotationRequestFingerprint(input.appId, reason)\n const replay = rotationIdempotency.get(normalizedIdempotencyKey)\n if (replay) {\n if (replay.fingerprint !== fingerprint) {\n throw idempotencyConflict('rotateMerchantWorkspaceCredential')\n }\n return { ...replay.response }\n }\n\n if (!sessionScopes.has('step_up')) {\n throw new MerchantPartnerWorkspaceMockError(\n 'Recent step-up authentication is required.',\n 403,\n )\n }\n\n const app = apps.find((candidate) => candidate.app_id === input.appId)\n if (!app) {\n throw new MerchantPartnerWorkspaceMockError(\n 'Merchant app is not visible in the active server-derived context.',\n 409,\n )\n }\n if (app.environment !== 'dev') {\n throw new MerchantPartnerWorkspaceMockError(\n 'Merchant app is outside the mock server-derived context.',\n 403,\n )\n }\n\n const oldVersion = app.credential_version ?? 0\n app.credential_version = oldVersion + 1\n const oldVersionExpiresAt = new Date(now().getTime() + 5 * 60 * 1000).toISOString()\n\n const response: CredentialRotationResult = {\n credential_id: `credential:${app.app_id}`,\n new_version: app.credential_version,\n old_version_expires_at: oldVersionExpiresAt,\n retrieval_mode: 'protected_retrieval_handle',\n retrieval_handle: `mock-retrieval:${app.app_id}:${app.credential_version}`,\n }\n rotationIdempotency.set(normalizedIdempotencyKey, {\n fingerprint,\n response: { ...response },\n })\n return response\n },\n }\n\n return { client, requests }\n}\n\nfunction cloneApp(app: MerchantAppProjection): MerchantAppProjection {\n return { ...app, allowed_origins: [...app.allowed_origins] }\n}\n\nfunction isMerchantCapabilityTemplate(value: unknown): value is MerchantCapabilityTemplate {\n return MERCHANT_CAPABILITY_TEMPLATE_ALLOWLIST.has(value as MerchantCapabilityTemplate)\n}\n\nfunction validateIdempotencyKey(value: unknown): string {\n if (typeof value !== 'string') {\n throw invalidRequest('Idempotency-Key must contain between 16 and 128 characters.')\n }\n const normalized = value.trim()\n if (normalized.length < 16 || normalized.length > 128) {\n throw invalidRequest('Idempotency-Key must contain between 16 and 128 characters.')\n }\n return normalized\n}\n\nfunction validateRequestObject(\n value: unknown,\n allowedProperties: readonly string[],\n): Record<string, unknown> {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n throw invalidRequest('Request body must be an object.')\n }\n const allowed = new Set(allowedProperties)\n if (\n Reflect.ownKeys(value).some(\n (property) => typeof property !== 'string' || !allowed.has(property),\n )\n ) {\n throw invalidRequest('Request body contains an unsupported property.')\n }\n return value as Record<string, unknown>\n}\n\nfunction validateTrimmedString(\n value: unknown,\n field: string,\n minimum: number,\n maximum: number,\n): string {\n if (typeof value !== 'string') {\n throw invalidRequest(`${field} must be a string.`)\n }\n const normalized = value.trim()\n const length = Array.from(normalized).length\n if (length < minimum || length > maximum) {\n throw invalidRequest(`${field} must contain between ${minimum} and ${maximum} characters.`)\n }\n return normalized\n}\n\nfunction canonicalizeAllowedOrigins(value: unknown): string[] {\n if (!Array.isArray(value) || value.length > 20) {\n throw invalidAllowedOrigins('Allowed origins must be an array with at most 20 entries.')\n }\n\n const canonicalOrigins: string[] = []\n const seen = new Set<string>()\n\n for (const candidate of value) {\n if (typeof candidate !== 'string' || candidate.length === 0 || /\\s/.test(candidate)) {\n throw invalidAllowedOrigins('Each allowed origin must be a non-empty exact URL origin.')\n }\n\n const exactOrigin = /^(https?):\\/\\/([^/?#\\\\]+)\\/?$/i.exec(candidate)\n if (!exactOrigin) {\n throw invalidAllowedOrigins('Allowed origins cannot include a path, query, or fragment.')\n }\n\n let parsed: URL\n try {\n parsed = new URL(candidate)\n } catch {\n throw invalidAllowedOrigins('Allowed origin URL parsing failed.')\n }\n\n if (\n (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') ||\n parsed.username !== '' ||\n parsed.password !== '' ||\n parsed.pathname !== '/' ||\n parsed.search !== '' ||\n parsed.hash !== ''\n ) {\n throw invalidAllowedOrigins('Allowed origins must be credential-free exact HTTP(S) origins.')\n }\n\n if (parsed.protocol === 'http:') {\n const rawHostname = rawAuthorityHostname(exactOrigin[2] ?? '').toLowerCase()\n const isExactLoopback =\n rawHostname === 'localhost' ||\n rawHostname === '127.0.0.1' ||\n rawHostname === '[::1]'\n if (!isExactLoopback) {\n throw invalidAllowedOrigins('Plain HTTP is allowed only for exact loopback origins.')\n }\n }\n\n if (seen.has(parsed.origin)) {\n throw invalidAllowedOrigins('Allowed origins must be unique after canonicalization.')\n }\n seen.add(parsed.origin)\n canonicalOrigins.push(parsed.origin)\n }\n\n return canonicalOrigins\n}\n\nfunction rawAuthorityHostname(authority: string): string {\n if (authority.startsWith('[')) {\n const closingBracket = authority.indexOf(']')\n return closingBracket === -1 ? authority : authority.slice(0, closingBracket + 1)\n }\n const portSeparator = authority.lastIndexOf(':')\n return portSeparator === -1 ? authority : authority.slice(0, portSeparator)\n}\n\nfunction invalidAllowedOrigins(message: string): MerchantPartnerWorkspaceMockError {\n return new MerchantPartnerWorkspaceMockError(message, 400)\n}\n\nfunction invalidRequest(message: string): MerchantPartnerWorkspaceMockError {\n return new MerchantPartnerWorkspaceMockError(message, 400)\n}\n\nfunction createRequestFingerprint(body: CreateMerchantDevAppRequest): string {\n return JSON.stringify({\n display_name: body.display_name,\n capability_template: body.capability_template,\n allowed_origins: [...body.allowed_origins].sort(),\n })\n}\n\nfunction rotationRequestFingerprint(appId: string, reason: string): string {\n return JSON.stringify({ app_id: appId, reason })\n}\n\nfunction idempotencyConflict(operationId: MerchantPartnerWorkspaceOperationId): Error {\n return new MerchantPartnerWorkspaceMockError(\n `Idempotency key was already used for a different ${operationId} request.`,\n 409,\n )\n}\n","import type { MerchantAppProjection } from './index'\n\n/** Safe dev projection for Merchant Partner Workspace testing. */\nexport const merchantDevAppFixture = {\n app_id: 'dev_mcid_fixture_01',\n display_name: 'Fixture storefront',\n environment: 'dev',\n capability_template: 'merchant_connect_dev',\n status: 'draft',\n allowed_origins: ['https://merchant.example'],\n} satisfies MerchantAppProjection\n\n/** Negative fixture proving that the testing helper cannot rotate Production apps. */\nexport const merchantProductionAppNegativeFixture = {\n app_id: 'production_mcid_fixture_01',\n display_name: 'Production boundary fixture',\n environment: 'production',\n capability_template: 'merchant_connect_dev',\n status: 'active',\n allowed_origins: ['https://merchant.example'],\n credential_version: 3,\n} satisfies MerchantAppProjection\n\n/** Read-projection fixture proving future templates remain forward-compatible. */\nexport const merchantFutureTemplateProjectionFixture = {\n app_id: 'app_fixture_future',\n display_name: 'Future template fixture',\n environment: 'dev',\n capability_template: 'merchant_connect_dev_with_diagnostics',\n status: 'active',\n allowed_origins: ['https://merchant.example'],\n credential_version: 1,\n} satisfies MerchantAppProjection\n\n// Retain the original internal name for existing source-level tests.\nexport const futureTemplateApp = merchantFutureTemplateProjectionFixture\n"],"mappings":"yaAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,8CAAAE,EAAA,sCAAAC,EAAA,uCAAAC,EAAA,6BAAAC,GAAA,uCAAAC,EAAA,gBAAAC,EAAA,iBAAAC,GAAA,0BAAAC,EAAA,4CAAAC,EAA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cAAe,wBAAyB,EAAI,CAAC,EAC3E,GAAIA,IAAW,YACX,CACE,SAAU,iBACV,OAAQ,KAAK,IAAI,OAAO,EAAE,CAAC,GAC3B,WAAY,0BACd,EACA,CAAC,EACL,UAAWhB,EACX,UAAW,0BACb,CACF,CAEA,SAASiB,GAAyC,CAChD,MAAO,CACL,SAAU,iBACV,UAAW,eACX,OAAQ,YACR,OAAQ,OACR,SAAU,OACV,OAAQ,wBACR,kBAAmB,0BACnB,UAAWjB,CACb,CACF,CAEA,SAASkB,GAAkD,CACzD,MAAO,CACL,kBAAmB,kBACnB,IAAK,0CACL,cAAe,CAAC,oBAAqB,gBAAgB,EACrD,OAAQ,UACR,UAAWlB,CACb,CACF,CAEA,SAASW,EAAKS,EAAeJ,EAAS,IAAe,CACnD,OAAO,IAAI,SAAS,KAAK,UAAUI,CAAI,EAAG,CACxC,OAAAJ,EACA,QAAS,CAAE,eAAgB,kBAAmB,CAChD,CAAC,CACH","names":["testing_exports","__export","MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS","MerchantPartnerWorkspaceMockError","createFactoConnectFixtureTransport","createFactoTestTransport","createMerchantPartnerWorkspaceMock","devFixtures","devScenarios","merchantDevAppFixture","merchantFutureTemplateProjectionFixture","merchantProductionAppNegativeFixture","__toCommonJS","MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS","MERCHANT_CAPABILITY_TEMPLATE_ALLOWLIST","MerchantPartnerWorkspaceMockError","message","status","createMerchantPartnerWorkspaceMock","options","requests","apps","cloneApp","sessionScopes","now","createIdempotency","rotationIdempotency","nextApp","environment","app","idempotencyKey","body","normalizedIdempotencyKey","validateIdempotencyKey","bodyRecord","validateRequestObject","displayName","validateTrimmedString","isMerchantCapabilityTemplate","requestBody","canonicalizeAllowedOrigins","fingerprint","createRequestFingerprint","replay","idempotencyConflict","input","reason","rotationRequestFingerprint","candidate","oldVersion","oldVersionExpiresAt","response","value","invalidRequest","normalized","allowedProperties","allowed","property","field","minimum","maximum","length","invalidAllowedOrigins","canonicalOrigins","seen","exactOrigin","parsed","rawHostname","rawAuthorityHostname","authority","closingBracket","portSeparator","appId","operationId","merchantDevAppFixture","merchantProductionAppNegativeFixture","merchantFutureTemplateProjectionFixture","devScenarios","devFixtures","name","CREATED_AT","WALLET","createFactoConnectFixtureTransport","options","scenario","statusIndex","input","init","url","method","path","json","mandateAuthorizationFixture","mandateFixture","paymentFixture","statuses","status","refundFixture","webhookEndpointFixture","createFactoTestTransport","body"]}
@@ -0,0 +1,143 @@
1
+ import { FactoConnectTransport, DevCapabilities, DevFaucetTransfer, DevSimulation, WebhookTestDeliveryAccepted } from '../server/index.cjs';
2
+ import '@facto-to/engine-wire';
3
+
4
+ declare const MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS: readonly ["listMerchantWorkspaceApps", "createMerchantDevApp", "rotateMerchantWorkspaceCredential"];
5
+ type MerchantPartnerWorkspaceOperationId = (typeof MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS)[number];
6
+ type PartnerWorkspaceEnvironment = 'dev' | 'mainnet_staging' | 'production';
7
+ type MerchantCapabilityTemplate = 'merchant_connect_dev' | 'merchant_webhook_dev';
8
+ interface MerchantAppProjection {
9
+ app_id: string;
10
+ display_name: string;
11
+ environment: PartnerWorkspaceEnvironment;
12
+ capability_template: string;
13
+ status: 'draft' | 'ready' | 'active' | 'disabled';
14
+ allowed_origins: string[];
15
+ credential_version?: number;
16
+ }
17
+ interface CreateMerchantDevAppRequest {
18
+ display_name: string;
19
+ capability_template: MerchantCapabilityTemplate;
20
+ allowed_origins: string[];
21
+ }
22
+ interface CredentialRotationResult {
23
+ credential_id: string;
24
+ new_version: number;
25
+ old_version_expires_at: string;
26
+ retrieval_mode: 'show_once' | 'protected_retrieval_handle';
27
+ one_time_secret?: string;
28
+ retrieval_handle?: string;
29
+ }
30
+ interface MerchantPartnerWorkspaceClient {
31
+ listMerchantWorkspaceApps(input: {
32
+ environment: PartnerWorkspaceEnvironment;
33
+ }): Promise<{
34
+ items: MerchantAppProjection[];
35
+ }>;
36
+ createMerchantDevApp(input: {
37
+ idempotencyKey: string;
38
+ body: CreateMerchantDevAppRequest;
39
+ }): Promise<MerchantAppProjection>;
40
+ rotateMerchantWorkspaceCredential(input: {
41
+ appId: string;
42
+ idempotencyKey: string;
43
+ body: {
44
+ reason: string;
45
+ };
46
+ }): Promise<CredentialRotationResult>;
47
+ }
48
+ type PartnerSessionScope = 'step_up';
49
+ type MerchantPartnerWorkspaceRequest = {
50
+ operationId: 'listMerchantWorkspaceApps';
51
+ method: 'GET';
52
+ path: '/api/partner-workspace/merchant/apps';
53
+ query: {
54
+ environment: PartnerWorkspaceEnvironment;
55
+ };
56
+ } | {
57
+ operationId: 'createMerchantDevApp';
58
+ method: 'POST';
59
+ path: '/api/partner-workspace/merchant/apps';
60
+ headers: {
61
+ 'Idempotency-Key': string;
62
+ };
63
+ body: CreateMerchantDevAppRequest;
64
+ } | {
65
+ operationId: 'rotateMerchantWorkspaceCredential';
66
+ method: 'POST';
67
+ path: string;
68
+ headers: {
69
+ 'Idempotency-Key': string;
70
+ };
71
+ authorization: 'partnerSession:step_up';
72
+ body: {
73
+ reason: string;
74
+ };
75
+ };
76
+ declare class MerchantPartnerWorkspaceMockError extends Error {
77
+ readonly status: number;
78
+ constructor(message: string, status: number);
79
+ }
80
+ declare function createMerchantPartnerWorkspaceMock(options?: {
81
+ initialApps?: readonly MerchantAppProjection[];
82
+ authenticatedSession?: {
83
+ scopes: readonly PartnerSessionScope[];
84
+ };
85
+ now?: () => Date;
86
+ }): {
87
+ client: MerchantPartnerWorkspaceClient;
88
+ requests: MerchantPartnerWorkspaceRequest[];
89
+ };
90
+
91
+ /** Safe dev projection for Merchant Partner Workspace testing. */
92
+ declare const merchantDevAppFixture: {
93
+ app_id: string;
94
+ display_name: string;
95
+ environment: "dev";
96
+ capability_template: string;
97
+ status: "draft";
98
+ allowed_origins: string[];
99
+ };
100
+ /** Negative fixture proving that the testing helper cannot rotate Production apps. */
101
+ declare const merchantProductionAppNegativeFixture: {
102
+ app_id: string;
103
+ display_name: string;
104
+ environment: "production";
105
+ capability_template: string;
106
+ status: "active";
107
+ allowed_origins: string[];
108
+ credential_version: number;
109
+ };
110
+ /** Read-projection fixture proving future templates remain forward-compatible. */
111
+ declare const merchantFutureTemplateProjectionFixture: {
112
+ app_id: string;
113
+ display_name: string;
114
+ environment: "dev";
115
+ capability_template: string;
116
+ status: "active";
117
+ allowed_origins: string[];
118
+ credential_version: number;
119
+ };
120
+
121
+ type FactoConnectFixtureScenario = 'happy_path' | 'setup_required' | 'idempotency_conflict' | 'declined_before_money' | 'status_progression';
122
+ interface FactoConnectFixtureTransportOptions {
123
+ scenario?: FactoConnectFixtureScenario;
124
+ }
125
+ /** Contract-aligned Dev scenarios for zero-network consumer tests. */
126
+ declare const devScenarios: readonly ["approved", "declined_setup", "declined_limit", "payment_failed"];
127
+ /** Deterministic public Dev projections. They model contract data, not deployment availability. */
128
+ declare const devFixtures: Readonly<{
129
+ capabilities: DevCapabilities;
130
+ faucetTransfer: DevFaucetTransfer;
131
+ simulation: DevSimulation;
132
+ webhookTestDelivery: WebhookTestDeliveryAccepted;
133
+ }>;
134
+ /**
135
+ * Create a deterministic, in-memory transport for server SDK tests and demos.
136
+ * It never performs DNS resolution or network I/O and returns payloads through
137
+ * the same strict parsers used by the real client.
138
+ */
139
+ declare function createFactoConnectFixtureTransport(options?: FactoConnectFixtureTransportOptions): FactoConnectTransport;
140
+ /** Alias named by `dev-sdk-surface-v1`; remains fully in-memory. */
141
+ declare const createFactoTestTransport: typeof createFactoConnectFixtureTransport;
142
+
143
+ export { type CreateMerchantDevAppRequest, type CredentialRotationResult, type FactoConnectFixtureScenario, type FactoConnectFixtureTransportOptions, MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS, type MerchantAppProjection, type MerchantCapabilityTemplate, type MerchantPartnerWorkspaceClient, MerchantPartnerWorkspaceMockError, type MerchantPartnerWorkspaceOperationId, type MerchantPartnerWorkspaceRequest, type PartnerSessionScope, type PartnerWorkspaceEnvironment, createFactoConnectFixtureTransport, createFactoTestTransport, createMerchantPartnerWorkspaceMock, devFixtures, devScenarios, merchantDevAppFixture, merchantFutureTemplateProjectionFixture, merchantProductionAppNegativeFixture };
@@ -0,0 +1,143 @@
1
+ import { FactoConnectTransport, DevCapabilities, DevFaucetTransfer, DevSimulation, WebhookTestDeliveryAccepted } from '../server/index.js';
2
+ import '@facto-to/engine-wire';
3
+
4
+ declare const MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS: readonly ["listMerchantWorkspaceApps", "createMerchantDevApp", "rotateMerchantWorkspaceCredential"];
5
+ type MerchantPartnerWorkspaceOperationId = (typeof MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS)[number];
6
+ type PartnerWorkspaceEnvironment = 'dev' | 'mainnet_staging' | 'production';
7
+ type MerchantCapabilityTemplate = 'merchant_connect_dev' | 'merchant_webhook_dev';
8
+ interface MerchantAppProjection {
9
+ app_id: string;
10
+ display_name: string;
11
+ environment: PartnerWorkspaceEnvironment;
12
+ capability_template: string;
13
+ status: 'draft' | 'ready' | 'active' | 'disabled';
14
+ allowed_origins: string[];
15
+ credential_version?: number;
16
+ }
17
+ interface CreateMerchantDevAppRequest {
18
+ display_name: string;
19
+ capability_template: MerchantCapabilityTemplate;
20
+ allowed_origins: string[];
21
+ }
22
+ interface CredentialRotationResult {
23
+ credential_id: string;
24
+ new_version: number;
25
+ old_version_expires_at: string;
26
+ retrieval_mode: 'show_once' | 'protected_retrieval_handle';
27
+ one_time_secret?: string;
28
+ retrieval_handle?: string;
29
+ }
30
+ interface MerchantPartnerWorkspaceClient {
31
+ listMerchantWorkspaceApps(input: {
32
+ environment: PartnerWorkspaceEnvironment;
33
+ }): Promise<{
34
+ items: MerchantAppProjection[];
35
+ }>;
36
+ createMerchantDevApp(input: {
37
+ idempotencyKey: string;
38
+ body: CreateMerchantDevAppRequest;
39
+ }): Promise<MerchantAppProjection>;
40
+ rotateMerchantWorkspaceCredential(input: {
41
+ appId: string;
42
+ idempotencyKey: string;
43
+ body: {
44
+ reason: string;
45
+ };
46
+ }): Promise<CredentialRotationResult>;
47
+ }
48
+ type PartnerSessionScope = 'step_up';
49
+ type MerchantPartnerWorkspaceRequest = {
50
+ operationId: 'listMerchantWorkspaceApps';
51
+ method: 'GET';
52
+ path: '/api/partner-workspace/merchant/apps';
53
+ query: {
54
+ environment: PartnerWorkspaceEnvironment;
55
+ };
56
+ } | {
57
+ operationId: 'createMerchantDevApp';
58
+ method: 'POST';
59
+ path: '/api/partner-workspace/merchant/apps';
60
+ headers: {
61
+ 'Idempotency-Key': string;
62
+ };
63
+ body: CreateMerchantDevAppRequest;
64
+ } | {
65
+ operationId: 'rotateMerchantWorkspaceCredential';
66
+ method: 'POST';
67
+ path: string;
68
+ headers: {
69
+ 'Idempotency-Key': string;
70
+ };
71
+ authorization: 'partnerSession:step_up';
72
+ body: {
73
+ reason: string;
74
+ };
75
+ };
76
+ declare class MerchantPartnerWorkspaceMockError extends Error {
77
+ readonly status: number;
78
+ constructor(message: string, status: number);
79
+ }
80
+ declare function createMerchantPartnerWorkspaceMock(options?: {
81
+ initialApps?: readonly MerchantAppProjection[];
82
+ authenticatedSession?: {
83
+ scopes: readonly PartnerSessionScope[];
84
+ };
85
+ now?: () => Date;
86
+ }): {
87
+ client: MerchantPartnerWorkspaceClient;
88
+ requests: MerchantPartnerWorkspaceRequest[];
89
+ };
90
+
91
+ /** Safe dev projection for Merchant Partner Workspace testing. */
92
+ declare const merchantDevAppFixture: {
93
+ app_id: string;
94
+ display_name: string;
95
+ environment: "dev";
96
+ capability_template: string;
97
+ status: "draft";
98
+ allowed_origins: string[];
99
+ };
100
+ /** Negative fixture proving that the testing helper cannot rotate Production apps. */
101
+ declare const merchantProductionAppNegativeFixture: {
102
+ app_id: string;
103
+ display_name: string;
104
+ environment: "production";
105
+ capability_template: string;
106
+ status: "active";
107
+ allowed_origins: string[];
108
+ credential_version: number;
109
+ };
110
+ /** Read-projection fixture proving future templates remain forward-compatible. */
111
+ declare const merchantFutureTemplateProjectionFixture: {
112
+ app_id: string;
113
+ display_name: string;
114
+ environment: "dev";
115
+ capability_template: string;
116
+ status: "active";
117
+ allowed_origins: string[];
118
+ credential_version: number;
119
+ };
120
+
121
+ type FactoConnectFixtureScenario = 'happy_path' | 'setup_required' | 'idempotency_conflict' | 'declined_before_money' | 'status_progression';
122
+ interface FactoConnectFixtureTransportOptions {
123
+ scenario?: FactoConnectFixtureScenario;
124
+ }
125
+ /** Contract-aligned Dev scenarios for zero-network consumer tests. */
126
+ declare const devScenarios: readonly ["approved", "declined_setup", "declined_limit", "payment_failed"];
127
+ /** Deterministic public Dev projections. They model contract data, not deployment availability. */
128
+ declare const devFixtures: Readonly<{
129
+ capabilities: DevCapabilities;
130
+ faucetTransfer: DevFaucetTransfer;
131
+ simulation: DevSimulation;
132
+ webhookTestDelivery: WebhookTestDeliveryAccepted;
133
+ }>;
134
+ /**
135
+ * Create a deterministic, in-memory transport for server SDK tests and demos.
136
+ * It never performs DNS resolution or network I/O and returns payloads through
137
+ * the same strict parsers used by the real client.
138
+ */
139
+ declare function createFactoConnectFixtureTransport(options?: FactoConnectFixtureTransportOptions): FactoConnectTransport;
140
+ /** Alias named by `dev-sdk-surface-v1`; remains fully in-memory. */
141
+ declare const createFactoTestTransport: typeof createFactoConnectFixtureTransport;
142
+
143
+ export { type CreateMerchantDevAppRequest, type CredentialRotationResult, type FactoConnectFixtureScenario, type FactoConnectFixtureTransportOptions, MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS, type MerchantAppProjection, type MerchantCapabilityTemplate, type MerchantPartnerWorkspaceClient, MerchantPartnerWorkspaceMockError, type MerchantPartnerWorkspaceOperationId, type MerchantPartnerWorkspaceRequest, type PartnerSessionScope, type PartnerWorkspaceEnvironment, createFactoConnectFixtureTransport, createFactoTestTransport, createMerchantPartnerWorkspaceMock, devFixtures, devScenarios, merchantDevAppFixture, merchantFutureTemplateProjectionFixture, merchantProductionAppNegativeFixture };
@@ -0,0 +1,2 @@
1
+ var q=["listMerchantWorkspaceApps","createMerchantDevApp","rotateMerchantWorkspaceCredential"],L=new Set(["merchant_connect_dev","merchant_webhook_dev"]),d=class extends Error{status;constructor(t,i){super(t),this.name="MerchantPartnerWorkspaceMockError",this.status=i}};function j(e={}){let t=[],i=(e.initialApps??[]).map(x),s=new Set(e.authenticatedSession?.scopes??[]),u=e.now??(()=>new Date),o=new Map,r=new Map,n=i.length+1;return{client:{async listMerchantWorkspaceApps({environment:c}){if(t.push({operationId:"listMerchantWorkspaceApps",method:"GET",path:"/api/partner-workspace/merchant/apps",query:{environment:c}}),c!=="dev")throw new d("Environment filter is outside the mock server-derived context.",403);return{items:i.filter(h=>h.environment===c).map(x)}},async createMerchantDevApp({idempotencyKey:c,body:h}){let y=S(c),m=I(h,["display_name","capability_template","allowed_origins"]),k=C(m.display_name,"Display name",1,160);if(!z(m.capability_template))throw new d("Capability template is not approved for Merchant dev app creation.",400);let l={display_name:k,capability_template:m.capability_template,allowed_origins:U(m.allowed_origins)};t.push({operationId:"createMerchantDevApp",method:"POST",path:"/api/partner-workspace/merchant/apps",headers:{"Idempotency-Key":y},body:l});let p=K(l),g=o.get(y);if(g){if(g.fingerprint!==p)throw E("createMerchantDevApp");return x(g.response)}let w={app_id:`dev_mcid_mock_${String(n).padStart(2,"0")}`,display_name:l.display_name,environment:"dev",capability_template:l.capability_template,status:"draft",allowed_origins:[...l.allowed_origins]};return n+=1,i.push(w),o.set(y,{fingerprint:p,response:x(w)}),x(w)},async rotateMerchantWorkspaceCredential(c){let h=S(c.idempotencyKey),y=I(c.body,["reason"]),m=C(y.reason,"Rotation reason",3,500);t.push({operationId:"rotateMerchantWorkspaceCredential",method:"POST",path:`/api/partner-workspace/merchant/apps/${encodeURIComponent(c.appId)}/credential-rotations`,headers:{"Idempotency-Key":h},authorization:"partnerSession:step_up",body:{reason:m}});let k=G(c.appId,m),l=r.get(h);if(l){if(l.fingerprint!==k)throw E("rotateMerchantWorkspaceCredential");return{...l.response}}if(!s.has("step_up"))throw new d("Recent step-up authentication is required.",403);let p=i.find(F=>F.app_id===c.appId);if(!p)throw new d("Merchant app is not visible in the active server-derived context.",409);if(p.environment!=="dev")throw new d("Merchant app is outside the mock server-derived context.",403);let g=p.credential_version??0;p.credential_version=g+1;let w=new Date(u().getTime()+300*1e3).toISOString(),R={credential_id:`credential:${p.app_id}`,new_version:p.credential_version,old_version_expires_at:w,retrieval_mode:"protected_retrieval_handle",retrieval_handle:`mock-retrieval:${p.app_id}:${p.credential_version}`};return r.set(h,{fingerprint:k,response:{...R}}),R}},requests:t}}function x(e){return{...e,allowed_origins:[...e.allowed_origins]}}function z(e){return L.has(e)}function S(e){if(typeof e!="string")throw _("Idempotency-Key must contain between 16 and 128 characters.");let t=e.trim();if(t.length<16||t.length>128)throw _("Idempotency-Key must contain between 16 and 128 characters.");return t}function I(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw _("Request body must be an object.");let i=new Set(t);if(Reflect.ownKeys(e).some(s=>typeof s!="string"||!i.has(s)))throw _("Request body contains an unsupported property.");return e}function C(e,t,i,s){if(typeof e!="string")throw _(`${t} must be a string.`);let u=e.trim(),o=Array.from(u).length;if(o<i||o>s)throw _(`${t} must contain between ${i} and ${s} characters.`);return u}function U(e){if(!Array.isArray(e)||e.length>20)throw f("Allowed origins must be an array with at most 20 entries.");let t=[],i=new Set;for(let s of e){if(typeof s!="string"||s.length===0||/\s/.test(s))throw f("Each allowed origin must be a non-empty exact URL origin.");let u=/^(https?):\/\/([^/?#\\]+)\/?$/i.exec(s);if(!u)throw f("Allowed origins cannot include a path, query, or fragment.");let o;try{o=new URL(s)}catch{throw f("Allowed origin URL parsing failed.")}if(o.protocol!=="https:"&&o.protocol!=="http:"||o.username!==""||o.password!==""||o.pathname!=="/"||o.search!==""||o.hash!=="")throw f("Allowed origins must be credential-free exact HTTP(S) origins.");if(o.protocol==="http:"){let r=N(u[2]??"").toLowerCase();if(!(r==="localhost"||r==="127.0.0.1"||r==="[::1]"))throw f("Plain HTTP is allowed only for exact loopback origins.")}if(i.has(o.origin))throw f("Allowed origins must be unique after canonicalization.");i.add(o.origin),t.push(o.origin)}return t}function N(e){if(e.startsWith("[")){let i=e.indexOf("]");return i===-1?e:e.slice(0,i+1)}let t=e.lastIndexOf(":");return t===-1?e:e.slice(0,t)}function f(e){return new d(e,400)}function _(e){return new d(e,400)}function K(e){return JSON.stringify({display_name:e.display_name,capability_template:e.capability_template,allowed_origins:[...e.allowed_origins].sort()})}function G(e,t){return JSON.stringify({app_id:e,reason:t})}function E(e){return new d(`Idempotency key was already used for a different ${e} request.`,409)}var $={app_id:"dev_mcid_fixture_01",display_name:"Fixture storefront",environment:"dev",capability_template:"merchant_connect_dev",status:"draft",allowed_origins:["https://merchant.example"]},Z={app_id:"production_mcid_fixture_01",display_name:"Production boundary fixture",environment:"production",capability_template:"merchant_connect_dev",status:"active",allowed_origins:["https://merchant.example"],credential_version:3},H={app_id:"app_fixture_future",display_name:"Future template fixture",environment:"dev",capability_template:"merchant_connect_dev_with_diagnostics",status:"active",allowed_origins:["https://merchant.example"],credential_version:1};var Y=Object.freeze(["approved","declined_setup","declined_limit","payment_failed"]),v=Object.freeze({capabilities:{environment:"dev",contractVersion:"2026-07-09",checkedAt:"2026-07-10T00:00:00.000Z",capabilities:[{name:"fixtures",status:"ready",evidenceLevel:"verified",reasonCode:null,verifiedAt:"2026-07-10T00:00:00.000Z",limits:{networkCalls:0}},...["synthetic_identity","faucet","simulation","money_loop","webhook_test_delivery"].map(e=>({name:e,status:"unavailable",evidenceLevel:"contract",reasonCode:"DEV_NOT_DEPLOYED",verifiedAt:null,limits:{}}))]},faucetTransfer:{faucetTransferId:"sft_fixture_1001",userLinkRef:"ul_fixture_buyer_01",amount:{amount:"10.00",currency:"USDC"},status:"accepted",createdAt:"2026-07-10T00:00:00.000Z"},simulation:{simulationId:"sim_fixture_1001",scenario:"approved",executionMode:"pre_admission",status:"accepted",reasonCode:null,authorizationRef:null,chargeRef:null,createdAt:"2026-07-10T00:00:00.000Z",updatedAt:"2026-07-10T00:00:00.000Z"},webhookTestDelivery:{eventId:"evt_fixturetestping1001",deliveryId:"wd_fixturetestping1001",status:"queued",createdAt:"2026-07-10T00:00:00.000Z"}}),b="2026-07-10T00:00:00.000Z",W="0x1111111111111111111111111111111111111111";function V(e={}){let t=e.scenario??"happy_path",i=0;return async(s,u)=>{let o=new URL(s),r=(u?.method??"GET").toUpperCase(),n=o.pathname;if(r==="POST"&&n==="/api/merchant/user-links/exchange")return a({appId:"app_fixture",userLinkRef:"ul_fixture_buyer_01",factoUserId:"user_fixture",factoServerWalletAddress:W,grantStatus:"active",pipelineReady:t!=="setup_required",scopes:["wallet.read","payments.write"]});if(r==="POST"&&n==="/api/merchant/payment-readiness")return a({appId:"app_fixture",userLinkRef:"ul_fixture_buyer_01",factoUserId:"user_fixture",factoServerWalletAddress:W,selectedPipelineId:"pipeline_fixture",chainId:84532,protocolId:"aave-v3",assetSymbol:"USDC",spendMode:"direct",pipelineReady:t!=="setup_required",...t==="setup_required"?{notReadyReason:"payment_route_not_provisioned"}:{}});if(r==="POST"&&n==="/api/merchant/checkout-sessions")return a({sessionId:"checkout_fixture",checkoutUrl:"https://dev.facto.to/checkout/checkout_fixture",status:"pending",amount:"9.99",assetSymbol:"USDC",orderRef:"order_fixture"});if(r==="GET"&&n.startsWith("/api/merchant/checkout-sessions/"))return a({sessionId:"checkout_fixture",status:"charged",amount:"9.99",assetSymbol:"USDC",orderRef:"order_fixture",chargeId:"charge_fixture",confirmedAt:b});if(r==="POST"&&n==="/api/merchant/authorization-sessions")return a(O("created"));if(r==="GET"&&n.startsWith("/api/merchant/authorization-sessions/"))return a(O("authorized"));if(r==="GET"&&n.startsWith("/api/merchant/payment-authorizations/"))return a(D());if(r==="POST"&&n==="/api/merchant/payment-options")return a({paymentOptions:[{paymentOptionId:"fpo_fixture",label:"Fixture Direct",ready:t!=="setup_required",isDefault:!0,chainId:84532,chainLabel:"Base Sepolia",protocolLabel:"Aave V3",assetSymbol:"USDC",spendMode:"direct",settlementPath:"direct",...t==="setup_required"?{blockingReason:"setup_required"}:{}}],defaultPaymentOptionId:"fpo_fixture"});if(r==="POST"&&n==="/api/merchant/payments")return t==="idempotency_conflict"?a({code:"idempotency_conflict",message:"fixture idempotency conflict"},409):a(A(t==="declined_before_money"?"declined":"charging"));if(r==="GET"&&n.startsWith("/api/merchant/payments/")){let M=t==="status_progression"?["charging","finalizing","succeeded"]:["succeeded"],c=M[Math.min(i,M.length-1)]??"succeeded";return i+=1,a(A(c))}return r==="DELETE"&&n.startsWith("/api/merchant/user-links/")?new Response(null,{status:204}):r==="GET"&&n==="/api/merchant/payments"?a({data:[A("succeeded")],hasMore:!1}):r==="GET"&&n==="/api/merchant/payment-authorizations"?a({data:[D()],hasMore:!1}):r==="POST"&&n==="/api/merchant/refunds"?a(P()):r==="GET"&&n==="/api/merchant/refunds"?a({data:[P()],hasMore:!1}):r==="GET"&&n.startsWith("/api/merchant/refunds/")?a(P()):r==="POST"&&n==="/api/merchant/webhook-endpoints"?a({...T(),secret:"whsec_fixture_only"}):r==="GET"&&n==="/api/dev/capabilities"?a(v.capabilities):r==="POST"&&n==="/api/dev/faucet/usdc"?a(v.faucetTransfer,202):r==="POST"&&n==="/api/dev/simulate/charge"?a(v.simulation,202):r==="GET"&&n.startsWith("/api/dev/simulations/")?a(v.simulation):r==="POST"&&n.endsWith("/test-delivery")&&n.startsWith("/api/merchant/webhook-endpoints/")?a(v.webhookTestDelivery,202):r==="GET"&&n==="/api/merchant/webhook-endpoints"?a({data:[T()]}):r==="POST"&&n.endsWith("/rotate-secret")&&n.startsWith("/api/merchant/webhook-endpoints/")?a({...T(),secret:"whsec_fixture_rotated"}):r==="GET"&&n.startsWith("/api/merchant/webhook-endpoints/")?a(T()):r==="DELETE"&&n.startsWith("/api/merchant/webhook-endpoints/")?new Response(null,{status:204}):a({code:"fixture_route_not_found",method:r,path:n},404)}}var Q=V;function O(e){return{sessionId:"mauth_fixture",authorizationUrl:"https://dev.facto.to/merchant-mandates/authorize?session=mauth_fixture",status:e,...e==="authorized"?{mandateId:"mandate_fixture"}:{},expiresAt:"2026-07-10T00:15:00.000Z",state:"state_fixture"}}function D(){return{mandateId:"mandate_fixture",appId:"app_fixture",status:"active",allowedUseCases:["immediate","recurring","metered"],limits:{perTxAmount:"100.00",periodAmount:"500.00",period:"monthly"},paymentPath:{ready:!0,summary:"Fixture payment path ready"},createdAt:b}}function A(e){return{paymentId:"mpay_fixture",mandateId:"mandate_fixture",merchantPaymentRef:"payment_fixture",status:e,amount:e==="declined"?"75.00":"9.99",currency:"USDC",useCase:e==="declined"?"metered":"recurring",...e==="declined"?{declineReason:"mandate_limit_exceeded"}:{},...e==="succeeded"?{chargeId:"charge_fixture",txHash:`0x${"1".repeat(64)}`,terminalAt:"2026-07-10T00:00:03.000Z"}:{},createdAt:b,updatedAt:"2026-07-10T00:00:03.000Z"}}function P(){return{refundId:"refund_fixture",paymentId:"mpay_fixture",status:"succeeded",amount:"9.99",currency:"USDC",reason:"requested_by_customer",merchantRefundRef:"merchant_refund_fixture",createdAt:b}}function T(){return{webhookEndpointId:"webhook_fixture",url:"https://merchant.example/facto-webhooks",enabledEvents:["payment.succeeded","payment.failed"],status:"enabled",createdAt:b}}function a(e,t=200){return new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json"}})}export{q as MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS,d as MerchantPartnerWorkspaceMockError,V as createFactoConnectFixtureTransport,Q as createFactoTestTransport,j as createMerchantPartnerWorkspaceMock,v as devFixtures,Y as devScenarios,$ as merchantDevAppFixture,H as merchantFutureTemplateProjectionFixture,Z as merchantProductionAppNegativeFixture};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/testing/partner-workspace/index.ts","../../src/testing/partner-workspace/fixtures.ts","../../src/testing/index.ts"],"sourcesContent":["export const MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS = [\n 'listMerchantWorkspaceApps',\n 'createMerchantDevApp',\n 'rotateMerchantWorkspaceCredential',\n] as const\n\nexport type MerchantPartnerWorkspaceOperationId =\n (typeof MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS)[number]\n\nexport type PartnerWorkspaceEnvironment = 'dev' | 'mainnet_staging' | 'production'\n\nexport type MerchantCapabilityTemplate =\n | 'merchant_connect_dev'\n | 'merchant_webhook_dev'\n\nconst MERCHANT_CAPABILITY_TEMPLATE_ALLOWLIST = new Set<MerchantCapabilityTemplate>([\n 'merchant_connect_dev',\n 'merchant_webhook_dev',\n])\n\nexport interface MerchantAppProjection {\n app_id: string\n display_name: string\n environment: PartnerWorkspaceEnvironment\n capability_template: string\n status: 'draft' | 'ready' | 'active' | 'disabled'\n allowed_origins: string[]\n credential_version?: number\n}\n\nexport interface CreateMerchantDevAppRequest {\n display_name: string\n capability_template: MerchantCapabilityTemplate\n allowed_origins: string[]\n}\n\nexport interface CredentialRotationResult {\n credential_id: string\n new_version: number\n old_version_expires_at: string\n retrieval_mode: 'show_once' | 'protected_retrieval_handle'\n one_time_secret?: string\n retrieval_handle?: string\n}\n\nexport interface MerchantPartnerWorkspaceClient {\n listMerchantWorkspaceApps(input: {\n environment: PartnerWorkspaceEnvironment\n }): Promise<{ items: MerchantAppProjection[] }>\n createMerchantDevApp(input: {\n idempotencyKey: string\n body: CreateMerchantDevAppRequest\n }): Promise<MerchantAppProjection>\n rotateMerchantWorkspaceCredential(input: {\n appId: string\n idempotencyKey: string\n body: { reason: string }\n }): Promise<CredentialRotationResult>\n}\n\nexport type PartnerSessionScope = 'step_up'\n\nexport type MerchantPartnerWorkspaceRequest =\n | {\n operationId: 'listMerchantWorkspaceApps'\n method: 'GET'\n path: '/api/partner-workspace/merchant/apps'\n query: { environment: PartnerWorkspaceEnvironment }\n }\n | {\n operationId: 'createMerchantDevApp'\n method: 'POST'\n path: '/api/partner-workspace/merchant/apps'\n headers: { 'Idempotency-Key': string }\n body: CreateMerchantDevAppRequest\n }\n | {\n operationId: 'rotateMerchantWorkspaceCredential'\n method: 'POST'\n path: string\n headers: { 'Idempotency-Key': string }\n authorization: 'partnerSession:step_up'\n body: { reason: string }\n }\n\nexport class MerchantPartnerWorkspaceMockError extends Error {\n readonly status: number\n\n constructor(message: string, status: number) {\n super(message)\n this.name = 'MerchantPartnerWorkspaceMockError'\n this.status = status\n }\n}\n\nexport function createMerchantPartnerWorkspaceMock(options: {\n initialApps?: readonly MerchantAppProjection[]\n authenticatedSession?: { scopes: readonly PartnerSessionScope[] }\n now?: () => Date\n} = {}): {\n client: MerchantPartnerWorkspaceClient\n requests: MerchantPartnerWorkspaceRequest[]\n} {\n const requests: MerchantPartnerWorkspaceRequest[] = []\n const apps = (options.initialApps ?? []).map(cloneApp)\n const sessionScopes = new Set(options.authenticatedSession?.scopes ?? [])\n const now = options.now ?? (() => new Date())\n const createIdempotency = new Map<\n string,\n { fingerprint: string; response: MerchantAppProjection }\n >()\n const rotationIdempotency = new Map<\n string,\n { fingerprint: string; response: CredentialRotationResult }\n >()\n let nextApp = apps.length + 1\n\n const client: MerchantPartnerWorkspaceClient = {\n async listMerchantWorkspaceApps({ environment }) {\n requests.push({\n operationId: 'listMerchantWorkspaceApps',\n method: 'GET',\n path: '/api/partner-workspace/merchant/apps',\n query: { environment },\n })\n\n if (environment !== 'dev') {\n throw new MerchantPartnerWorkspaceMockError(\n 'Environment filter is outside the mock server-derived context.',\n 403,\n )\n }\n\n return {\n items: apps.filter((app) => app.environment === environment).map(cloneApp),\n }\n },\n\n async createMerchantDevApp({ idempotencyKey, body }) {\n const normalizedIdempotencyKey = validateIdempotencyKey(idempotencyKey)\n const bodyRecord = validateRequestObject(body, [\n 'display_name',\n 'capability_template',\n 'allowed_origins',\n ])\n const displayName = validateTrimmedString(bodyRecord.display_name, 'Display name', 1, 160)\n if (!isMerchantCapabilityTemplate(bodyRecord.capability_template)) {\n throw new MerchantPartnerWorkspaceMockError(\n 'Capability template is not approved for Merchant dev app creation.',\n 400,\n )\n }\n const requestBody: CreateMerchantDevAppRequest = {\n display_name: displayName,\n capability_template: bodyRecord.capability_template,\n allowed_origins: canonicalizeAllowedOrigins(bodyRecord.allowed_origins),\n }\n requests.push({\n operationId: 'createMerchantDevApp',\n method: 'POST',\n path: '/api/partner-workspace/merchant/apps',\n headers: { 'Idempotency-Key': normalizedIdempotencyKey },\n body: requestBody,\n })\n\n const fingerprint = createRequestFingerprint(requestBody)\n const replay = createIdempotency.get(normalizedIdempotencyKey)\n if (replay) {\n if (replay.fingerprint !== fingerprint) {\n throw idempotencyConflict('createMerchantDevApp')\n }\n return cloneApp(replay.response)\n }\n\n const app: MerchantAppProjection = {\n app_id: `dev_mcid_mock_${String(nextApp).padStart(2, '0')}`,\n display_name: requestBody.display_name,\n environment: 'dev',\n capability_template: requestBody.capability_template,\n status: 'draft',\n allowed_origins: [...requestBody.allowed_origins],\n }\n nextApp += 1\n apps.push(app)\n createIdempotency.set(normalizedIdempotencyKey, {\n fingerprint,\n response: cloneApp(app),\n })\n return cloneApp(app)\n },\n\n async rotateMerchantWorkspaceCredential(input) {\n const normalizedIdempotencyKey = validateIdempotencyKey(input.idempotencyKey)\n const bodyRecord = validateRequestObject(input.body, ['reason'])\n const reason = validateTrimmedString(bodyRecord.reason, 'Rotation reason', 3, 500)\n requests.push({\n operationId: 'rotateMerchantWorkspaceCredential',\n method: 'POST',\n path: `/api/partner-workspace/merchant/apps/${encodeURIComponent(input.appId)}/credential-rotations`,\n headers: { 'Idempotency-Key': normalizedIdempotencyKey },\n authorization: 'partnerSession:step_up',\n body: { reason },\n })\n\n const fingerprint = rotationRequestFingerprint(input.appId, reason)\n const replay = rotationIdempotency.get(normalizedIdempotencyKey)\n if (replay) {\n if (replay.fingerprint !== fingerprint) {\n throw idempotencyConflict('rotateMerchantWorkspaceCredential')\n }\n return { ...replay.response }\n }\n\n if (!sessionScopes.has('step_up')) {\n throw new MerchantPartnerWorkspaceMockError(\n 'Recent step-up authentication is required.',\n 403,\n )\n }\n\n const app = apps.find((candidate) => candidate.app_id === input.appId)\n if (!app) {\n throw new MerchantPartnerWorkspaceMockError(\n 'Merchant app is not visible in the active server-derived context.',\n 409,\n )\n }\n if (app.environment !== 'dev') {\n throw new MerchantPartnerWorkspaceMockError(\n 'Merchant app is outside the mock server-derived context.',\n 403,\n )\n }\n\n const oldVersion = app.credential_version ?? 0\n app.credential_version = oldVersion + 1\n const oldVersionExpiresAt = new Date(now().getTime() + 5 * 60 * 1000).toISOString()\n\n const response: CredentialRotationResult = {\n credential_id: `credential:${app.app_id}`,\n new_version: app.credential_version,\n old_version_expires_at: oldVersionExpiresAt,\n retrieval_mode: 'protected_retrieval_handle',\n retrieval_handle: `mock-retrieval:${app.app_id}:${app.credential_version}`,\n }\n rotationIdempotency.set(normalizedIdempotencyKey, {\n fingerprint,\n response: { ...response },\n })\n return response\n },\n }\n\n return { client, requests }\n}\n\nfunction cloneApp(app: MerchantAppProjection): MerchantAppProjection {\n return { ...app, allowed_origins: [...app.allowed_origins] }\n}\n\nfunction isMerchantCapabilityTemplate(value: unknown): value is MerchantCapabilityTemplate {\n return MERCHANT_CAPABILITY_TEMPLATE_ALLOWLIST.has(value as MerchantCapabilityTemplate)\n}\n\nfunction validateIdempotencyKey(value: unknown): string {\n if (typeof value !== 'string') {\n throw invalidRequest('Idempotency-Key must contain between 16 and 128 characters.')\n }\n const normalized = value.trim()\n if (normalized.length < 16 || normalized.length > 128) {\n throw invalidRequest('Idempotency-Key must contain between 16 and 128 characters.')\n }\n return normalized\n}\n\nfunction validateRequestObject(\n value: unknown,\n allowedProperties: readonly string[],\n): Record<string, unknown> {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n throw invalidRequest('Request body must be an object.')\n }\n const allowed = new Set(allowedProperties)\n if (\n Reflect.ownKeys(value).some(\n (property) => typeof property !== 'string' || !allowed.has(property),\n )\n ) {\n throw invalidRequest('Request body contains an unsupported property.')\n }\n return value as Record<string, unknown>\n}\n\nfunction validateTrimmedString(\n value: unknown,\n field: string,\n minimum: number,\n maximum: number,\n): string {\n if (typeof value !== 'string') {\n throw invalidRequest(`${field} must be a string.`)\n }\n const normalized = value.trim()\n const length = Array.from(normalized).length\n if (length < minimum || length > maximum) {\n throw invalidRequest(`${field} must contain between ${minimum} and ${maximum} characters.`)\n }\n return normalized\n}\n\nfunction canonicalizeAllowedOrigins(value: unknown): string[] {\n if (!Array.isArray(value) || value.length > 20) {\n throw invalidAllowedOrigins('Allowed origins must be an array with at most 20 entries.')\n }\n\n const canonicalOrigins: string[] = []\n const seen = new Set<string>()\n\n for (const candidate of value) {\n if (typeof candidate !== 'string' || candidate.length === 0 || /\\s/.test(candidate)) {\n throw invalidAllowedOrigins('Each allowed origin must be a non-empty exact URL origin.')\n }\n\n const exactOrigin = /^(https?):\\/\\/([^/?#\\\\]+)\\/?$/i.exec(candidate)\n if (!exactOrigin) {\n throw invalidAllowedOrigins('Allowed origins cannot include a path, query, or fragment.')\n }\n\n let parsed: URL\n try {\n parsed = new URL(candidate)\n } catch {\n throw invalidAllowedOrigins('Allowed origin URL parsing failed.')\n }\n\n if (\n (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') ||\n parsed.username !== '' ||\n parsed.password !== '' ||\n parsed.pathname !== '/' ||\n parsed.search !== '' ||\n parsed.hash !== ''\n ) {\n throw invalidAllowedOrigins('Allowed origins must be credential-free exact HTTP(S) origins.')\n }\n\n if (parsed.protocol === 'http:') {\n const rawHostname = rawAuthorityHostname(exactOrigin[2] ?? '').toLowerCase()\n const isExactLoopback =\n rawHostname === 'localhost' ||\n rawHostname === '127.0.0.1' ||\n rawHostname === '[::1]'\n if (!isExactLoopback) {\n throw invalidAllowedOrigins('Plain HTTP is allowed only for exact loopback origins.')\n }\n }\n\n if (seen.has(parsed.origin)) {\n throw invalidAllowedOrigins('Allowed origins must be unique after canonicalization.')\n }\n seen.add(parsed.origin)\n canonicalOrigins.push(parsed.origin)\n }\n\n return canonicalOrigins\n}\n\nfunction rawAuthorityHostname(authority: string): string {\n if (authority.startsWith('[')) {\n const closingBracket = authority.indexOf(']')\n return closingBracket === -1 ? authority : authority.slice(0, closingBracket + 1)\n }\n const portSeparator = authority.lastIndexOf(':')\n return portSeparator === -1 ? authority : authority.slice(0, portSeparator)\n}\n\nfunction invalidAllowedOrigins(message: string): MerchantPartnerWorkspaceMockError {\n return new MerchantPartnerWorkspaceMockError(message, 400)\n}\n\nfunction invalidRequest(message: string): MerchantPartnerWorkspaceMockError {\n return new MerchantPartnerWorkspaceMockError(message, 400)\n}\n\nfunction createRequestFingerprint(body: CreateMerchantDevAppRequest): string {\n return JSON.stringify({\n display_name: body.display_name,\n capability_template: body.capability_template,\n allowed_origins: [...body.allowed_origins].sort(),\n })\n}\n\nfunction rotationRequestFingerprint(appId: string, reason: string): string {\n return JSON.stringify({ app_id: appId, reason })\n}\n\nfunction idempotencyConflict(operationId: MerchantPartnerWorkspaceOperationId): Error {\n return new MerchantPartnerWorkspaceMockError(\n `Idempotency key was already used for a different ${operationId} request.`,\n 409,\n )\n}\n","import type { MerchantAppProjection } from './index'\n\n/** Safe dev projection for Merchant Partner Workspace testing. */\nexport const merchantDevAppFixture = {\n app_id: 'dev_mcid_fixture_01',\n display_name: 'Fixture storefront',\n environment: 'dev',\n capability_template: 'merchant_connect_dev',\n status: 'draft',\n allowed_origins: ['https://merchant.example'],\n} satisfies MerchantAppProjection\n\n/** Negative fixture proving that the testing helper cannot rotate Production apps. */\nexport const merchantProductionAppNegativeFixture = {\n app_id: 'production_mcid_fixture_01',\n display_name: 'Production boundary fixture',\n environment: 'production',\n capability_template: 'merchant_connect_dev',\n status: 'active',\n allowed_origins: ['https://merchant.example'],\n credential_version: 3,\n} satisfies MerchantAppProjection\n\n/** Read-projection fixture proving future templates remain forward-compatible. */\nexport const merchantFutureTemplateProjectionFixture = {\n app_id: 'app_fixture_future',\n display_name: 'Future template fixture',\n environment: 'dev',\n capability_template: 'merchant_connect_dev_with_diagnostics',\n status: 'active',\n allowed_origins: ['https://merchant.example'],\n credential_version: 1,\n} satisfies MerchantAppProjection\n\n// Retain the original internal name for existing source-level tests.\nexport const futureTemplateApp = merchantFutureTemplateProjectionFixture\n","import type {\n FactoConnectTransport,\n MandatePaymentStatus,\n DevCapabilities,\n DevFaucetTransfer,\n DevSimulation,\n WebhookTestDeliveryAccepted,\n} from '../server/index'\n\nexport {\n createMerchantPartnerWorkspaceMock,\n MerchantPartnerWorkspaceMockError,\n MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS,\n} from './partner-workspace/index'\nexport type {\n CreateMerchantDevAppRequest,\n CredentialRotationResult,\n MerchantAppProjection,\n MerchantCapabilityTemplate,\n MerchantPartnerWorkspaceClient,\n MerchantPartnerWorkspaceOperationId,\n MerchantPartnerWorkspaceRequest,\n PartnerSessionScope,\n PartnerWorkspaceEnvironment,\n} from './partner-workspace/index'\nexport {\n merchantFutureTemplateProjectionFixture,\n merchantProductionAppNegativeFixture,\n merchantDevAppFixture,\n} from './partner-workspace/fixtures'\n\nexport type FactoConnectFixtureScenario =\n | 'happy_path'\n | 'setup_required'\n | 'idempotency_conflict'\n | 'declined_before_money'\n | 'status_progression'\n\nexport interface FactoConnectFixtureTransportOptions {\n scenario?: FactoConnectFixtureScenario\n}\n\n/** Contract-aligned Dev scenarios for zero-network consumer tests. */\nexport const devScenarios = Object.freeze([\n 'approved',\n 'declined_setup',\n 'declined_limit',\n 'payment_failed',\n] as const)\n\n/** Deterministic public Dev projections. They model contract data, not deployment availability. */\nexport const devFixtures: Readonly<{\n capabilities: DevCapabilities\n faucetTransfer: DevFaucetTransfer\n simulation: DevSimulation\n webhookTestDelivery: WebhookTestDeliveryAccepted\n}> = Object.freeze({\n capabilities: {\n environment: 'dev',\n contractVersion: '2026-07-09',\n checkedAt: '2026-07-10T00:00:00.000Z',\n capabilities: [\n {\n name: 'fixtures',\n status: 'ready',\n evidenceLevel: 'verified',\n reasonCode: null,\n verifiedAt: '2026-07-10T00:00:00.000Z',\n limits: { networkCalls: 0 },\n },\n ...(['synthetic_identity', 'faucet', 'simulation', 'money_loop', 'webhook_test_delivery'] as const).map(\n (name) => ({\n name,\n status: 'unavailable' as const,\n evidenceLevel: 'contract' as const,\n reasonCode: 'DEV_NOT_DEPLOYED',\n verifiedAt: null,\n limits: {},\n }),\n ),\n ],\n },\n faucetTransfer: {\n faucetTransferId: 'sft_fixture_1001',\n userLinkRef: 'ul_fixture_buyer_01',\n amount: { amount: '10.00', currency: 'USDC' },\n status: 'accepted',\n createdAt: '2026-07-10T00:00:00.000Z',\n },\n simulation: {\n simulationId: 'sim_fixture_1001',\n scenario: 'approved',\n executionMode: 'pre_admission',\n status: 'accepted',\n reasonCode: null,\n authorizationRef: null,\n chargeRef: null,\n createdAt: '2026-07-10T00:00:00.000Z',\n updatedAt: '2026-07-10T00:00:00.000Z',\n },\n webhookTestDelivery: {\n eventId: 'evt_fixturetestping1001',\n deliveryId: 'wd_fixturetestping1001',\n status: 'queued',\n createdAt: '2026-07-10T00:00:00.000Z',\n },\n})\n\nconst CREATED_AT = '2026-07-10T00:00:00.000Z'\nconst WALLET = '0x1111111111111111111111111111111111111111'\n\n/**\n * Create a deterministic, in-memory transport for server SDK tests and demos.\n * It never performs DNS resolution or network I/O and returns payloads through\n * the same strict parsers used by the real client.\n */\nexport function createFactoConnectFixtureTransport(\n options: FactoConnectFixtureTransportOptions = {},\n): FactoConnectTransport {\n const scenario = options.scenario ?? 'happy_path'\n let statusIndex = 0\n\n return async (input, init) => {\n const url = new URL(input)\n const method = (init?.method ?? 'GET').toUpperCase()\n const path = url.pathname\n\n if (method === 'POST' && path === '/api/merchant/user-links/exchange') {\n return json({\n appId: 'app_fixture',\n userLinkRef: 'ul_fixture_buyer_01',\n factoUserId: 'user_fixture',\n factoServerWalletAddress: WALLET,\n grantStatus: 'active',\n pipelineReady: scenario !== 'setup_required',\n scopes: ['wallet.read', 'payments.write'],\n })\n }\n\n if (method === 'POST' && path === '/api/merchant/payment-readiness') {\n return json({\n appId: 'app_fixture',\n userLinkRef: 'ul_fixture_buyer_01',\n factoUserId: 'user_fixture',\n factoServerWalletAddress: WALLET,\n selectedPipelineId: 'pipeline_fixture',\n chainId: 84532,\n protocolId: 'aave-v3',\n assetSymbol: 'USDC',\n spendMode: 'direct',\n pipelineReady: scenario !== 'setup_required',\n ...(scenario === 'setup_required'\n ? { notReadyReason: 'payment_route_not_provisioned' }\n : {}),\n })\n }\n\n if (method === 'POST' && path === '/api/merchant/checkout-sessions') {\n return json({\n sessionId: 'checkout_fixture',\n checkoutUrl: 'https://dev.facto.to/checkout/checkout_fixture',\n status: 'pending',\n amount: '9.99',\n assetSymbol: 'USDC',\n orderRef: 'order_fixture',\n })\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/checkout-sessions/')) {\n return json({\n sessionId: 'checkout_fixture',\n status: 'charged',\n amount: '9.99',\n assetSymbol: 'USDC',\n orderRef: 'order_fixture',\n chargeId: 'charge_fixture',\n confirmedAt: CREATED_AT,\n })\n }\n\n if (method === 'POST' && path === '/api/merchant/authorization-sessions') {\n return json(mandateAuthorizationFixture('created'))\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/authorization-sessions/')) {\n return json(mandateAuthorizationFixture('authorized'))\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/payment-authorizations/')) {\n return json(mandateFixture())\n }\n\n if (method === 'POST' && path === '/api/merchant/payment-options') {\n return json({\n paymentOptions: [\n {\n paymentOptionId: 'fpo_fixture',\n label: 'Fixture Direct',\n ready: scenario !== 'setup_required',\n isDefault: true,\n chainId: 84532,\n chainLabel: 'Base Sepolia',\n protocolLabel: 'Aave V3',\n assetSymbol: 'USDC',\n spendMode: 'direct',\n settlementPath: 'direct',\n ...(scenario === 'setup_required' ? { blockingReason: 'setup_required' } : {}),\n },\n ],\n // A mock earns its keep only by emitting what the engine emits. The\n // engine's key here is `defaultPaymentOptionId`; this mock said\n // `selectedPaymentOptionId` (the checkout-state DTO's key) and so\n // agreed with the SDK's broken parser instead of with the engine —\n // the two-way fake green of Facto-to/facto#472 B.\n defaultPaymentOptionId: 'fpo_fixture',\n })\n }\n\n if (method === 'POST' && path === '/api/merchant/payments') {\n if (scenario === 'idempotency_conflict') {\n return json(\n { code: 'idempotency_conflict', message: 'fixture idempotency conflict' },\n 409,\n )\n }\n if (scenario === 'declined_before_money') {\n return json(paymentFixture('declined'))\n }\n return json(paymentFixture('charging'))\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/payments/')) {\n const statuses: readonly MandatePaymentStatus[] =\n scenario === 'status_progression'\n ? ['charging', 'finalizing', 'succeeded']\n : ['succeeded']\n const status = statuses[Math.min(statusIndex, statuses.length - 1)] ?? 'succeeded'\n statusIndex += 1\n return json(paymentFixture(status))\n }\n\n if (method === 'DELETE' && path.startsWith('/api/merchant/user-links/')) {\n return new Response(null, { status: 204 })\n }\n\n if (method === 'GET' && path === '/api/merchant/payments') {\n return json({ data: [paymentFixture('succeeded')], hasMore: false })\n }\n\n if (method === 'GET' && path === '/api/merchant/payment-authorizations') {\n return json({ data: [mandateFixture()], hasMore: false })\n }\n\n if (method === 'POST' && path === '/api/merchant/refunds') {\n return json(refundFixture())\n }\n\n if (method === 'GET' && path === '/api/merchant/refunds') {\n return json({ data: [refundFixture()], hasMore: false })\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/refunds/')) {\n return json(refundFixture())\n }\n\n if (method === 'POST' && path === '/api/merchant/webhook-endpoints') {\n return json({ ...webhookEndpointFixture(), secret: 'whsec_fixture_only' })\n }\n\n if (method === 'GET' && path === '/api/dev/capabilities') {\n return json(devFixtures.capabilities)\n }\n\n if (method === 'POST' && path === '/api/dev/faucet/usdc') {\n return json(devFixtures.faucetTransfer, 202)\n }\n\n if (method === 'POST' && path === '/api/dev/simulate/charge') {\n return json(devFixtures.simulation, 202)\n }\n\n if (method === 'GET' && path.startsWith('/api/dev/simulations/')) {\n return json(devFixtures.simulation)\n }\n\n if (\n method === 'POST' &&\n path.endsWith('/test-delivery') &&\n path.startsWith('/api/merchant/webhook-endpoints/')\n ) {\n return json(devFixtures.webhookTestDelivery, 202)\n }\n\n if (method === 'GET' && path === '/api/merchant/webhook-endpoints') {\n return json({ data: [webhookEndpointFixture()] })\n }\n\n if (\n method === 'POST' &&\n path.endsWith('/rotate-secret') &&\n path.startsWith('/api/merchant/webhook-endpoints/')\n ) {\n return json({ ...webhookEndpointFixture(), secret: 'whsec_fixture_rotated' })\n }\n\n if (method === 'GET' && path.startsWith('/api/merchant/webhook-endpoints/')) {\n return json(webhookEndpointFixture())\n }\n\n if (method === 'DELETE' && path.startsWith('/api/merchant/webhook-endpoints/')) {\n return new Response(null, { status: 204 })\n }\n\n return json({ code: 'fixture_route_not_found', method, path }, 404)\n }\n}\n\n/** Alias named by `dev-sdk-surface-v1`; remains fully in-memory. */\nexport const createFactoTestTransport = createFactoConnectFixtureTransport\n\nfunction mandateAuthorizationFixture(status: 'created' | 'authorized'): Record<string, unknown> {\n return {\n sessionId: 'mauth_fixture',\n authorizationUrl: 'https://dev.facto.to/merchant-mandates/authorize?session=mauth_fixture',\n status,\n ...(status === 'authorized' ? { mandateId: 'mandate_fixture' } : {}),\n expiresAt: '2026-07-10T00:15:00.000Z',\n state: 'state_fixture',\n }\n}\n\nfunction mandateFixture(): Record<string, unknown> {\n return {\n mandateId: 'mandate_fixture',\n appId: 'app_fixture',\n status: 'active',\n allowedUseCases: ['immediate', 'recurring', 'metered'],\n limits: { perTxAmount: '100.00', periodAmount: '500.00', period: 'monthly' },\n paymentPath: { ready: true, summary: 'Fixture payment path ready' },\n createdAt: CREATED_AT,\n }\n}\n\nfunction paymentFixture(status: MandatePaymentStatus): Record<string, unknown> {\n return {\n paymentId: 'mpay_fixture',\n mandateId: 'mandate_fixture',\n merchantPaymentRef: 'payment_fixture',\n status,\n amount: status === 'declined' ? '75.00' : '9.99',\n currency: 'USDC',\n useCase: status === 'declined' ? 'metered' : 'recurring',\n ...(status === 'declined' ? { declineReason: 'mandate_limit_exceeded' } : {}),\n ...(status === 'succeeded'\n ? {\n chargeId: 'charge_fixture',\n txHash: `0x${'1'.repeat(64)}`,\n terminalAt: '2026-07-10T00:00:03.000Z',\n }\n : {}),\n createdAt: CREATED_AT,\n updatedAt: '2026-07-10T00:00:03.000Z',\n }\n}\n\nfunction refundFixture(): Record<string, unknown> {\n return {\n refundId: 'refund_fixture',\n paymentId: 'mpay_fixture',\n status: 'succeeded',\n amount: '9.99',\n currency: 'USDC',\n reason: 'requested_by_customer',\n merchantRefundRef: 'merchant_refund_fixture',\n createdAt: CREATED_AT,\n }\n}\n\nfunction webhookEndpointFixture(): Record<string, unknown> {\n return {\n webhookEndpointId: 'webhook_fixture',\n url: 'https://merchant.example/facto-webhooks',\n enabledEvents: ['payment.succeeded', 'payment.failed'],\n status: 'enabled',\n createdAt: CREATED_AT,\n }\n}\n\nfunction json(body: unknown, status = 200): Response {\n return new Response(JSON.stringify(body), {\n status,\n headers: { 'content-type': 'application/json' },\n })\n}\n"],"mappings":"AAAO,IAAMA,EAA2C,CACtD,4BACA,uBACA,mCACF,EAWMC,EAAyC,IAAI,IAAgC,CACjF,uBACA,sBACF,CAAC,EAmEYC,EAAN,cAAgD,KAAM,CAClD,OAET,YAAYC,EAAiBC,EAAgB,CAC3C,MAAMD,CAAO,EACb,KAAK,KAAO,oCACZ,KAAK,OAASC,CAChB,CACF,EAEO,SAASC,EAAmCC,EAI/C,CAAC,EAGH,CACA,IAAMC,EAA8C,CAAC,EAC/CC,GAAQF,EAAQ,aAAe,CAAC,GAAG,IAAIG,CAAQ,EAC/CC,EAAgB,IAAI,IAAIJ,EAAQ,sBAAsB,QAAU,CAAC,CAAC,EAClEK,EAAML,EAAQ,MAAQ,IAAM,IAAI,MAChCM,EAAoB,IAAI,IAIxBC,EAAsB,IAAI,IAI5BC,EAAUN,EAAK,OAAS,EA0I5B,MAAO,CAAE,OAxIsC,CAC7C,MAAM,0BAA0B,CAAE,YAAAO,CAAY,EAAG,CAQ/C,GAPAR,EAAS,KAAK,CACZ,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ATE_ALLOWLIST","MerchantPartnerWorkspaceMockError","message","status","createMerchantPartnerWorkspaceMock","options","requests","apps","cloneApp","sessionScopes","now","createIdempotency","rotationIdempotency","nextApp","environment","app","idempotencyKey","body","normalizedIdempotencyKey","validateIdempotencyKey","bodyRecord","validateRequestObject","displayName","validateTrimmedString","isMerchantCapabilityTemplate","requestBody","canonicalizeAllowedOrigins","fingerprint","createRequestFingerprint","replay","idempotencyConflict","input","reason","rotationRequestFingerprint","candidate","oldVersion","oldVersionExpiresAt","response","value","invalidRequest","normalized","allowedProperties","allowed","property","field","minimum","maximum","length","invalidAllowedOrigins","canonicalOrigins","seen","exactOrigin","parsed","rawHostname","rawAuthorityHostname","authority","closingBracket","portSeparator","appId","operationId","merchantDevAppFixture","merchantProductionAppNegativeFixture","merchantFutureTemplateProjectionFixture","devScenarios","devFixtures","name","CREATED_AT","WALLET","createFactoConnectFixtureTransport","options","scenario","statusIndex","input","init","url","method","path","json","mandateAuthorizationFixture","mandateFixture","paymentFixture","statuses","status","refundFixture","webhookEndpointFixture","createFactoTestTransport","body"]}