@facto-to/connect 0.0.1-beta.1 → 0.0.1-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +140 -81
  2. package/dist/browser/index.cjs +29 -20
  3. package/dist/browser/index.d.cts +1 -31
  4. package/dist/browser/index.d.ts +1 -31
  5. package/dist/browser/index.js +28 -19
  6. package/dist/card-transport--tl4vJa5.d.cts +73 -0
  7. package/dist/card-transport--tl4vJa5.d.ts +73 -0
  8. package/dist/chunk-GJFQH2I6.js +2 -0
  9. package/dist/chunk-VQJMKCAN.js +1 -0
  10. package/dist/cli/index.cjs +6 -0
  11. package/dist/cli/index.d.cts +1 -0
  12. package/dist/cli/index.d.ts +1 -0
  13. package/dist/cli/index.js +5 -0
  14. package/dist/index.d-oRLzr8gp.d.cts +1124 -0
  15. package/dist/index.d-oRLzr8gp.d.ts +1124 -0
  16. package/dist/react/index.cjs +0 -1
  17. package/dist/react/index.js +0 -1
  18. package/dist/server/card-connect-admin-client.cjs +2 -0
  19. package/dist/server/card-connect-admin-client.d.cts +318 -0
  20. package/dist/server/card-connect-admin-client.d.ts +318 -0
  21. package/dist/server/card-connect-admin-client.js +1 -0
  22. package/dist/server/index.cjs +1 -2
  23. package/dist/server/index.d.cts +1202 -291
  24. package/dist/server/index.d.ts +1202 -291
  25. package/dist/server/index.js +1 -2
  26. package/dist/testing/index.cjs +1 -2
  27. package/dist/testing/index.d.cts +6 -14
  28. package/dist/testing/index.d.ts +6 -14
  29. package/dist/testing/index.js +1 -2
  30. package/package.json +64 -17
  31. package/dist/browser/index.cjs.map +0 -1
  32. package/dist/browser/index.js.map +0 -1
  33. package/dist/react/index.cjs.map +0 -1
  34. package/dist/react/index.js.map +0 -1
  35. package/dist/server/index.cjs.map +0 -1
  36. package/dist/server/index.js.map +0 -1
  37. package/dist/testing/index.cjs.map +0 -1
  38. package/dist/testing/index.js.map +0 -1
@@ -1,2 +1 @@
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
1
+ "use strict";var M=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var i in t)M(e,i,{get:t[i],enumerable:!0})},Y=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of Z(t))!B.call(e,c)&&c!==i&&M(e,c,{get:()=>t[c],enumerable:!(s=$(t,c))||s.enumerable});return e};var J=e=>Y(M({},"__esModule",{value:!0}),e);var oe={};V(oe,{CANONICAL_MERCHANT_CAPABILITY_TEMPLATES:()=>P,MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS:()=>D,MerchantPartnerWorkspaceMockError:()=>u,createFactoConnectFixtureTransport:()=>K,createFactoTestTransport:()=>ie,createMerchantPartnerWorkspaceMock:()=>q,devFixtures:()=>g,devScenarios:()=>ae,merchantDevAppFixture:()=>L,merchantFutureTemplateProjectionFixture:()=>N,merchantProductionAppNegativeFixture:()=>F});module.exports=J(oe);var D=["listMerchantWorkspaceApps","createMerchantDevApp","rotateMerchantWorkspaceCredential"],P=["merchant_connect_sandbox","merchant_webhook_sandbox","merchant_mandate_sandbox","merchant_storefront_sandbox"],Q=new Set([...P,"merchant_connect_dev","merchant_webhook_dev"]),u=class extends Error{status;constructor(t,i){super(t),this.name="MerchantPartnerWorkspaceMockError",this.status=i}};function q(e={}){let t=[],i=(e.initialApps??[]).map(T),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 u("Environment filter is outside the mock server-derived context.",403);return{items:i.filter(h=>h.environment===p).map(T)}},async createMerchantDevApp({idempotencyKey:p,body:h}){let x=I(p),f=E(h,["display_name","capability_template","allowed_origins"]),k=W(f.display_name,"Display name",1,160);if(!X(f.capability_template))throw new u("Capability template is not approved for Merchant dev app creation.",400);let m={display_name:k,capability_template:f.capability_template,allowed_origins:ee(f.allowed_origins)};t.push({operationId:"createMerchantDevApp",method:"POST",path:"/api/partner-workspace/merchant/apps",headers:{"Idempotency-Key":x},body:m});let l=ne(m),w=o.get(x);if(w){if(w.fingerprint!==l)throw O("createMerchantDevApp");return T(w.response)}let v={app_id:`dev_mcid_mock_${String(n).padStart(2,"0")}`,display_name:m.display_name,environment:"dev",capability_template:m.capability_template,status:"draft",allowed_origins:[...m.allowed_origins]};return n+=1,i.push(v),o.set(x,{fingerprint:l,response:T(v)}),T(v)},async rotateMerchantWorkspaceCredential(p){let h=I(p.idempotencyKey),x=E(p.body,["reason"]),f=W(x.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:f}});let k=re(p.appId,f),m=r.get(h);if(m){if(m.fingerprint!==k)throw O("rotateMerchantWorkspaceCredential");return{...m.response}}if(!s.has("step_up"))throw new u("Recent step-up authentication is required.",403);let l=i.find(H=>H.app_id===p.appId);if(!l)throw new u("Merchant app is not visible in the active server-derived context.",409);if(l.environment!=="dev")throw new u("Merchant app is outside the mock server-derived context.",403);let w=l.credential_version??0;l.credential_version=w+1;let v=new Date(c().getTime()+300*1e3).toISOString(),S={credential_id:`credential:${l.app_id}`,new_version:l.credential_version,old_version_expires_at:v,retrieval_mode:"protected_retrieval_handle",retrieval_handle:`mock-retrieval:${l.app_id}:${l.credential_version}`};return r.set(h,{fingerprint:k,response:{...S}}),S}},requests:t}}function T(e){return{...e,allowed_origins:[...e.allowed_origins]}}function X(e){return Q.has(e)}function I(e){if(typeof e!="string")throw y("Idempotency-Key must contain between 16 and 128 characters.");let t=e.trim();if(t.length<16||t.length>128)throw y("Idempotency-Key must contain between 16 and 128 characters.");return t}function E(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw y("Request body must be an object.");let i=new Set(t);if(Reflect.ownKeys(e).some(s=>typeof s!="string"||!i.has(s)))throw y("Request body contains an unsupported property.");return e}function W(e,t,i,s){if(typeof e!="string")throw y(`${t} must be a string.`);let c=e.trim(),o=Array.from(c).length;if(o<i||o>s)throw y(`${t} must contain between ${i} and ${s} characters.`);return c}function ee(e){if(!Array.isArray(e)||e.length>20)throw _("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 _("Each allowed origin must be a non-empty exact URL origin.");let c=/^(https?):\/\/([^/?#\\]+)\/?$/i.exec(s);if(!c)throw _("Allowed origins cannot include a path, query, or fragment.");let o;try{o=new URL(s)}catch{throw _("Allowed origin URL parsing failed.")}if(o.protocol!=="https:"&&o.protocol!=="http:"||o.username!==""||o.password!==""||o.pathname!=="/"||o.search!==""||o.hash!=="")throw _("Allowed origins must be credential-free exact HTTP(S) origins.");if(o.protocol==="http:"){let r=te(c[2]??"").toLowerCase();if(!(r==="localhost"||r==="127.0.0.1"||r==="[::1]"))throw _("Plain HTTP is allowed only for exact loopback origins.")}if(i.has(o.origin))throw _("Allowed origins must be unique after canonicalization.");i.add(o.origin),t.push(o.origin)}return t}function te(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 _(e){return new u(e,400)}function y(e){return new u(e,400)}function ne(e){return JSON.stringify({display_name:e.display_name,capability_template:e.capability_template,allowed_origins:[...e.allowed_origins].sort()})}function re(e,t){return JSON.stringify({app_id:e,reason:t})}function O(e){return new u(`Idempotency key was already used for a different ${e} request.`,409)}var L={app_id:"dev_mcid_fixture_01",display_name:"Fixture storefront",environment:"dev",capability_template:"merchant_connect_sandbox",status:"draft",allowed_origins:["https://merchant.example"]},F={app_id:"production_mcid_fixture_01",display_name:"Production boundary fixture",environment:"production",capability_template:"merchant_connect_sandbox",status:"active",allowed_origins:["https://merchant.example"],credential_version:3},N={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 ae=Object.freeze(["approved","declined_setup","declined_limit","payment_failed"]),g=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",z="0x1111111111111111111111111111111111111111";function K(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:z,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:z,readinessScope:"account_default",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(j("created"));if(r==="GET"&&n.startsWith("/api/merchant/authorization-sessions/"))return a(j("authorized"));if(r==="GET"&&n.startsWith("/api/merchant/payment-authorizations/"))return a(U());if(r==="DELETE"&&n.startsWith("/api/merchant/payment-authorizations/")){let d=decodeURIComponent(n.slice(37));return a({mandateId:d||"mandate_fixture",status:"revoked",revokedByThisRequest:!0})}if(r==="POST"&&n==="/api/merchant/mandate-path-change-sessions")return a(G("pending"));if(r==="GET"&&n.startsWith("/api/merchant/mandate-path-change-sessions/"))return a(G("completed"));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({error:{category:"conflict",code:"conflict",message:"fixture idempotency conflict",request_id:"req_fixture_idempotency_conflict",retryable:!1}},409):t==="declined_before_money"?a(A("declined"),402):a(A("charging"));if(r==="GET"&&n.startsWith("/api/merchant/payments/")){let d=t==="status_progression"?["charging","finalizing","succeeded"]:["succeeded"],p=d[Math.min(i,d.length-1)]??"succeeded";return i+=1,a(A(p))}if(r==="GET"&&n.startsWith("/api/merchant/user-links/")){let d=decodeURIComponent(n.slice(25));return a({appId:"app_fixture",userLinkRef:d||"ul_fixture_buyer_01",grantStatus:"active",paymentReady:t!=="setup_required",scopes:["wallet.read","payments.write"]})}if(r==="DELETE"&&n.startsWith("/api/merchant/user-links/"))return new Response(null,{status:204});if(r==="GET"&&n==="/api/merchant/payments")return a({data:[A("succeeded")],hasMore:!1});if(r==="GET"&&n==="/api/merchant/payment-authorizations")return a({data:[U()],hasMore:!1});if(r==="POST"&&n==="/api/merchant/refunds")return a(C());if(r==="GET"&&n==="/api/merchant/refunds")return a({data:[C()],hasMore:!1});if(r==="GET"&&n.startsWith("/api/merchant/refunds/"))return a(C());if(r==="POST"&&n==="/api/merchant/webhook-endpoints")return a({...R(),secret:"whsec_fixture_only"});if(r==="GET"&&n==="/api/dev/capabilities")return a(g.capabilities);if(r==="POST"&&n==="/api/dev/faucet/usdc")return a(g.faucetTransfer,202);if(r==="POST"&&n==="/api/dev/simulate/charge")return a(g.simulation,202);if(r==="GET"&&n.startsWith("/api/dev/simulations/"))return a(g.simulation);if(r==="POST"&&n==="/api/dev/test-mandates")return a({mandateId:"mandate_fixture",settlementMode:"simulated"},201);if(r==="POST"&&n.startsWith("/api/dev/test-mandates/")&&n.endsWith("/settle")){let d={};if(typeof c?.body=="string")try{d=JSON.parse(c.body)}catch{d={}}let p=d.outcome==="failed"?"failed":"succeeded",h=A(p);return p==="failed"&&d.declineReason&&(h.declineReason=d.declineReason),a(h)}return r==="POST"&&n.endsWith("/test-delivery")&&n.startsWith("/api/merchant/webhook-endpoints/")?a(g.webhookTestDelivery,202):r==="GET"&&n==="/api/merchant/webhook-endpoints"?a({data:[R()]}):r==="POST"&&n.endsWith("/rotate-secret")&&n.startsWith("/api/merchant/webhook-endpoints/")?a({...R(),secret:"whsec_fixture_rotated"}):r==="GET"&&n.startsWith("/api/merchant/webhook-endpoints/")?a(R()):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 ie=K;function j(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 G(e){return{sessionId:"mpcs_fixture00000000000000000001",pathChangeUrl:"https://dev.facto.to/mandates/change-path?session=mpcs_fixture00000000000000000001",status:e,state:"state_path_change_fixture_000001",targetOrigin:"https://merchant.example",expiresAt:"2026-07-10T00:15:00.000Z"}}function C(){return{refundId:"re_fixture000000000000000000000001",paymentId:"mpay_fixture",status:"succeeded",amount:"9.99",currency:"USDC",reason:"requested_by_customer",merchantRefundRef:"merchant_refund_fixture",createdAt:b}}function R(){return{webhookEndpointId:"we_fixture000000000000000000000001",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"}})}
@@ -1,10 +1,13 @@
1
1
  import { FactoConnectTransport, DevCapabilities, DevFaucetTransfer, DevSimulation, WebhookTestDeliveryAccepted } from '../server/index.cjs';
2
- import '@facto-to/engine-wire';
2
+ import '../card-transport--tl4vJa5.cjs';
3
+ import '../index.d-oRLzr8gp.cjs';
3
4
 
4
5
  declare const MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS: readonly ["listMerchantWorkspaceApps", "createMerchantDevApp", "rotateMerchantWorkspaceCredential"];
5
6
  type MerchantPartnerWorkspaceOperationId = (typeof MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS)[number];
6
7
  type PartnerWorkspaceEnvironment = 'dev' | 'mainnet_staging' | 'production';
7
- type MerchantCapabilityTemplate = 'merchant_connect_dev' | 'merchant_webhook_dev';
8
+ declare const CANONICAL_MERCHANT_CAPABILITY_TEMPLATES: readonly ["merchant_connect_sandbox", "merchant_webhook_sandbox", "merchant_mandate_sandbox", "merchant_storefront_sandbox"];
9
+ type CanonicalMerchantCapabilityTemplate = (typeof CANONICAL_MERCHANT_CAPABILITY_TEMPLATES)[number];
10
+ type MerchantCapabilityTemplate = CanonicalMerchantCapabilityTemplate | 'merchant_connect_dev' | 'merchant_webhook_dev';
8
11
  interface MerchantAppProjection {
9
12
  app_id: string;
10
13
  display_name: string;
@@ -88,7 +91,6 @@ declare function createMerchantPartnerWorkspaceMock(options?: {
88
91
  requests: MerchantPartnerWorkspaceRequest[];
89
92
  };
90
93
 
91
- /** Safe dev projection for Merchant Partner Workspace testing. */
92
94
  declare const merchantDevAppFixture: {
93
95
  app_id: string;
94
96
  display_name: string;
@@ -97,7 +99,6 @@ declare const merchantDevAppFixture: {
97
99
  status: "draft";
98
100
  allowed_origins: string[];
99
101
  };
100
- /** Negative fixture proving that the testing helper cannot rotate Production apps. */
101
102
  declare const merchantProductionAppNegativeFixture: {
102
103
  app_id: string;
103
104
  display_name: string;
@@ -107,7 +108,6 @@ declare const merchantProductionAppNegativeFixture: {
107
108
  allowed_origins: string[];
108
109
  credential_version: number;
109
110
  };
110
- /** Read-projection fixture proving future templates remain forward-compatible. */
111
111
  declare const merchantFutureTemplateProjectionFixture: {
112
112
  app_id: string;
113
113
  display_name: string;
@@ -122,22 +122,14 @@ type FactoConnectFixtureScenario = 'happy_path' | 'setup_required' | 'idempotenc
122
122
  interface FactoConnectFixtureTransportOptions {
123
123
  scenario?: FactoConnectFixtureScenario;
124
124
  }
125
- /** Contract-aligned Dev scenarios for zero-network consumer tests. */
126
125
  declare const devScenarios: readonly ["approved", "declined_setup", "declined_limit", "payment_failed"];
127
- /** Deterministic public Dev projections. They model contract data, not deployment availability. */
128
126
  declare const devFixtures: Readonly<{
129
127
  capabilities: DevCapabilities;
130
128
  faucetTransfer: DevFaucetTransfer;
131
129
  simulation: DevSimulation;
132
130
  webhookTestDelivery: WebhookTestDeliveryAccepted;
133
131
  }>;
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
132
  declare function createFactoConnectFixtureTransport(options?: FactoConnectFixtureTransportOptions): FactoConnectTransport;
140
- /** Alias named by `dev-sdk-surface-v1`; remains fully in-memory. */
141
133
  declare const createFactoTestTransport: typeof createFactoConnectFixtureTransport;
142
134
 
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 };
135
+ export { CANONICAL_MERCHANT_CAPABILITY_TEMPLATES, type CanonicalMerchantCapabilityTemplate, 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 };
@@ -1,10 +1,13 @@
1
1
  import { FactoConnectTransport, DevCapabilities, DevFaucetTransfer, DevSimulation, WebhookTestDeliveryAccepted } from '../server/index.js';
2
- import '@facto-to/engine-wire';
2
+ import '../card-transport--tl4vJa5.js';
3
+ import '../index.d-oRLzr8gp.js';
3
4
 
4
5
  declare const MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS: readonly ["listMerchantWorkspaceApps", "createMerchantDevApp", "rotateMerchantWorkspaceCredential"];
5
6
  type MerchantPartnerWorkspaceOperationId = (typeof MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS)[number];
6
7
  type PartnerWorkspaceEnvironment = 'dev' | 'mainnet_staging' | 'production';
7
- type MerchantCapabilityTemplate = 'merchant_connect_dev' | 'merchant_webhook_dev';
8
+ declare const CANONICAL_MERCHANT_CAPABILITY_TEMPLATES: readonly ["merchant_connect_sandbox", "merchant_webhook_sandbox", "merchant_mandate_sandbox", "merchant_storefront_sandbox"];
9
+ type CanonicalMerchantCapabilityTemplate = (typeof CANONICAL_MERCHANT_CAPABILITY_TEMPLATES)[number];
10
+ type MerchantCapabilityTemplate = CanonicalMerchantCapabilityTemplate | 'merchant_connect_dev' | 'merchant_webhook_dev';
8
11
  interface MerchantAppProjection {
9
12
  app_id: string;
10
13
  display_name: string;
@@ -88,7 +91,6 @@ declare function createMerchantPartnerWorkspaceMock(options?: {
88
91
  requests: MerchantPartnerWorkspaceRequest[];
89
92
  };
90
93
 
91
- /** Safe dev projection for Merchant Partner Workspace testing. */
92
94
  declare const merchantDevAppFixture: {
93
95
  app_id: string;
94
96
  display_name: string;
@@ -97,7 +99,6 @@ declare const merchantDevAppFixture: {
97
99
  status: "draft";
98
100
  allowed_origins: string[];
99
101
  };
100
- /** Negative fixture proving that the testing helper cannot rotate Production apps. */
101
102
  declare const merchantProductionAppNegativeFixture: {
102
103
  app_id: string;
103
104
  display_name: string;
@@ -107,7 +108,6 @@ declare const merchantProductionAppNegativeFixture: {
107
108
  allowed_origins: string[];
108
109
  credential_version: number;
109
110
  };
110
- /** Read-projection fixture proving future templates remain forward-compatible. */
111
111
  declare const merchantFutureTemplateProjectionFixture: {
112
112
  app_id: string;
113
113
  display_name: string;
@@ -122,22 +122,14 @@ type FactoConnectFixtureScenario = 'happy_path' | 'setup_required' | 'idempotenc
122
122
  interface FactoConnectFixtureTransportOptions {
123
123
  scenario?: FactoConnectFixtureScenario;
124
124
  }
125
- /** Contract-aligned Dev scenarios for zero-network consumer tests. */
126
125
  declare const devScenarios: readonly ["approved", "declined_setup", "declined_limit", "payment_failed"];
127
- /** Deterministic public Dev projections. They model contract data, not deployment availability. */
128
126
  declare const devFixtures: Readonly<{
129
127
  capabilities: DevCapabilities;
130
128
  faucetTransfer: DevFaucetTransfer;
131
129
  simulation: DevSimulation;
132
130
  webhookTestDelivery: WebhookTestDeliveryAccepted;
133
131
  }>;
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
132
  declare function createFactoConnectFixtureTransport(options?: FactoConnectFixtureTransportOptions): FactoConnectTransport;
140
- /** Alias named by `dev-sdk-surface-v1`; remains fully in-memory. */
141
133
  declare const createFactoTestTransport: typeof createFactoConnectFixtureTransport;
142
134
 
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 };
135
+ export { CANONICAL_MERCHANT_CAPABILITY_TEMPLATES, type CanonicalMerchantCapabilityTemplate, 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 };
@@ -1,2 +1 @@
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
1
+ var N=["listMerchantWorkspaceApps","createMerchantDevApp","rotateMerchantWorkspaceCredential"],W=["merchant_connect_sandbox","merchant_webhook_sandbox","merchant_mandate_sandbox","merchant_storefront_sandbox"],z=new Set([...W,"merchant_connect_dev","merchant_webhook_dev"]),l=class extends Error{status;constructor(r,i){super(r),this.name="MerchantPartnerWorkspaceMockError",this.status=i}};function j(e={}){let r=[],i=(e.initialApps??[]).map(v),c=new Set(e.authenticatedSession?.scopes??[]),d=e.now??(()=>new Date),o=new Map,n=new Map,t=i.length+1;return{client:{async listMerchantWorkspaceApps({environment:s}){if(r.push({operationId:"listMerchantWorkspaceApps",method:"GET",path:"/api/partner-workspace/merchant/apps",query:{environment:s}}),s!=="dev")throw new l("Environment filter is outside the mock server-derived context.",403);return{items:i.filter(h=>h.environment===s).map(v)}},async createMerchantDevApp({idempotencyKey:s,body:h}){let g=C(s),f=S(h,["display_name","capability_template","allowed_origins"]),k=I(f.display_name,"Display name",1,160);if(!U(f.capability_template))throw new l("Capability template is not approved for Merchant dev app creation.",400);let m={display_name:k,capability_template:f.capability_template,allowed_origins:G(f.allowed_origins)};r.push({operationId:"createMerchantDevApp",method:"POST",path:"/api/partner-workspace/merchant/apps",headers:{"Idempotency-Key":g},body:m});let u=H(m),x=o.get(g);if(x){if(x.fingerprint!==u)throw E("createMerchantDevApp");return v(x.response)}let w={app_id:`dev_mcid_mock_${String(t).padStart(2,"0")}`,display_name:m.display_name,environment:"dev",capability_template:m.capability_template,status:"draft",allowed_origins:[...m.allowed_origins]};return t+=1,i.push(w),o.set(g,{fingerprint:u,response:v(w)}),v(w)},async rotateMerchantWorkspaceCredential(s){let h=C(s.idempotencyKey),g=S(s.body,["reason"]),f=I(g.reason,"Rotation reason",3,500);r.push({operationId:"rotateMerchantWorkspaceCredential",method:"POST",path:`/api/partner-workspace/merchant/apps/${encodeURIComponent(s.appId)}/credential-rotations`,headers:{"Idempotency-Key":h},authorization:"partnerSession:step_up",body:{reason:f}});let k=$(s.appId,f),m=n.get(h);if(m){if(m.fingerprint!==k)throw E("rotateMerchantWorkspaceCredential");return{...m.response}}if(!c.has("step_up"))throw new l("Recent step-up authentication is required.",403);let u=i.find(F=>F.app_id===s.appId);if(!u)throw new l("Merchant app is not visible in the active server-derived context.",409);if(u.environment!=="dev")throw new l("Merchant app is outside the mock server-derived context.",403);let x=u.credential_version??0;u.credential_version=x+1;let w=new Date(d().getTime()+300*1e3).toISOString(),P={credential_id:`credential:${u.app_id}`,new_version:u.credential_version,old_version_expires_at:w,retrieval_mode:"protected_retrieval_handle",retrieval_handle:`mock-retrieval:${u.app_id}:${u.credential_version}`};return n.set(h,{fingerprint:k,response:{...P}}),P}},requests:r}}function v(e){return{...e,allowed_origins:[...e.allowed_origins]}}function U(e){return z.has(e)}function C(e){if(typeof e!="string")throw y("Idempotency-Key must contain between 16 and 128 characters.");let r=e.trim();if(r.length<16||r.length>128)throw y("Idempotency-Key must contain between 16 and 128 characters.");return r}function S(e,r){if(e===null||typeof e!="object"||Array.isArray(e))throw y("Request body must be an object.");let i=new Set(r);if(Reflect.ownKeys(e).some(c=>typeof c!="string"||!i.has(c)))throw y("Request body contains an unsupported property.");return e}function I(e,r,i,c){if(typeof e!="string")throw y(`${r} must be a string.`);let d=e.trim(),o=Array.from(d).length;if(o<i||o>c)throw y(`${r} must contain between ${i} and ${c} characters.`);return d}function G(e){if(!Array.isArray(e)||e.length>20)throw _("Allowed origins must be an array with at most 20 entries.");let r=[],i=new Set;for(let c of e){if(typeof c!="string"||c.length===0||/\s/.test(c))throw _("Each allowed origin must be a non-empty exact URL origin.");let d=/^(https?):\/\/([^/?#\\]+)\/?$/i.exec(c);if(!d)throw _("Allowed origins cannot include a path, query, or fragment.");let o;try{o=new URL(c)}catch{throw _("Allowed origin URL parsing failed.")}if(o.protocol!=="https:"&&o.protocol!=="http:"||o.username!==""||o.password!==""||o.pathname!=="/"||o.search!==""||o.hash!=="")throw _("Allowed origins must be credential-free exact HTTP(S) origins.");if(o.protocol==="http:"){let n=K(d[2]??"").toLowerCase();if(!(n==="localhost"||n==="127.0.0.1"||n==="[::1]"))throw _("Plain HTTP is allowed only for exact loopback origins.")}if(i.has(o.origin))throw _("Allowed origins must be unique after canonicalization.");i.add(o.origin),r.push(o.origin)}return r}function K(e){if(e.startsWith("[")){let i=e.indexOf("]");return i===-1?e:e.slice(0,i+1)}let r=e.lastIndexOf(":");return r===-1?e:e.slice(0,r)}function _(e){return new l(e,400)}function y(e){return new l(e,400)}function H(e){return JSON.stringify({display_name:e.display_name,capability_template:e.capability_template,allowed_origins:[...e.allowed_origins].sort()})}function $(e,r){return JSON.stringify({app_id:e,reason:r})}function E(e){return new l(`Idempotency key was already used for a different ${e} request.`,409)}var Z={app_id:"dev_mcid_fixture_01",display_name:"Fixture storefront",environment:"dev",capability_template:"merchant_connect_sandbox",status:"draft",allowed_origins:["https://merchant.example"]},B={app_id:"production_mcid_fixture_01",display_name:"Production boundary fixture",environment:"production",capability_template:"merchant_connect_sandbox",status:"active",allowed_origins:["https://merchant.example"],credential_version:3},V={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 X=Object.freeze(["approved","declined_setup","declined_limit","payment_failed"]),T=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",O="0x1111111111111111111111111111111111111111";function Y(e={}){let r=e.scenario??"happy_path",i=0;return async(c,d)=>{let o=new URL(c),n=(d?.method??"GET").toUpperCase(),t=o.pathname;if(n==="POST"&&t==="/api/merchant/user-links/exchange")return a({appId:"app_fixture",userLinkRef:"ul_fixture_buyer_01",factoUserId:"user_fixture",factoServerWalletAddress:O,grantStatus:"active",pipelineReady:r!=="setup_required",scopes:["wallet.read","payments.write"]});if(n==="POST"&&t==="/api/merchant/payment-readiness")return a({appId:"app_fixture",userLinkRef:"ul_fixture_buyer_01",factoUserId:"user_fixture",factoServerWalletAddress:O,readinessScope:"account_default",chainId:84532,protocolId:"aave-v3",assetSymbol:"USDC",spendMode:"direct",pipelineReady:r!=="setup_required",...r==="setup_required"?{notReadyReason:"payment_route_not_provisioned"}:{}});if(n==="POST"&&t==="/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(n==="GET"&&t.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(n==="POST"&&t==="/api/merchant/authorization-sessions")return a(D("created"));if(n==="GET"&&t.startsWith("/api/merchant/authorization-sessions/"))return a(D("authorized"));if(n==="GET"&&t.startsWith("/api/merchant/payment-authorizations/"))return a(q());if(n==="DELETE"&&t.startsWith("/api/merchant/payment-authorizations/")){let p=decodeURIComponent(t.slice(37));return a({mandateId:p||"mandate_fixture",status:"revoked",revokedByThisRequest:!0})}if(n==="POST"&&t==="/api/merchant/mandate-path-change-sessions")return a(L("pending"));if(n==="GET"&&t.startsWith("/api/merchant/mandate-path-change-sessions/"))return a(L("completed"));if(n==="POST"&&t==="/api/merchant/payment-options")return a({paymentOptions:[{paymentOptionId:"fpo_fixture",label:"Fixture Direct",ready:r!=="setup_required",isDefault:!0,chainId:84532,chainLabel:"Base Sepolia",protocolLabel:"Aave V3",assetSymbol:"USDC",spendMode:"direct",settlementPath:"direct",...r==="setup_required"?{blockingReason:"setup_required"}:{}}],defaultPaymentOptionId:"fpo_fixture"});if(n==="POST"&&t==="/api/merchant/payments")return r==="idempotency_conflict"?a({error:{category:"conflict",code:"conflict",message:"fixture idempotency conflict",request_id:"req_fixture_idempotency_conflict",retryable:!1}},409):r==="declined_before_money"?a(A("declined"),402):a(A("charging"));if(n==="GET"&&t.startsWith("/api/merchant/payments/")){let p=r==="status_progression"?["charging","finalizing","succeeded"]:["succeeded"],s=p[Math.min(i,p.length-1)]??"succeeded";return i+=1,a(A(s))}if(n==="GET"&&t.startsWith("/api/merchant/user-links/")){let p=decodeURIComponent(t.slice(25));return a({appId:"app_fixture",userLinkRef:p||"ul_fixture_buyer_01",grantStatus:"active",paymentReady:r!=="setup_required",scopes:["wallet.read","payments.write"]})}if(n==="DELETE"&&t.startsWith("/api/merchant/user-links/"))return new Response(null,{status:204});if(n==="GET"&&t==="/api/merchant/payments")return a({data:[A("succeeded")],hasMore:!1});if(n==="GET"&&t==="/api/merchant/payment-authorizations")return a({data:[q()],hasMore:!1});if(n==="POST"&&t==="/api/merchant/refunds")return a(M());if(n==="GET"&&t==="/api/merchant/refunds")return a({data:[M()],hasMore:!1});if(n==="GET"&&t.startsWith("/api/merchant/refunds/"))return a(M());if(n==="POST"&&t==="/api/merchant/webhook-endpoints")return a({...R(),secret:"whsec_fixture_only"});if(n==="GET"&&t==="/api/dev/capabilities")return a(T.capabilities);if(n==="POST"&&t==="/api/dev/faucet/usdc")return a(T.faucetTransfer,202);if(n==="POST"&&t==="/api/dev/simulate/charge")return a(T.simulation,202);if(n==="GET"&&t.startsWith("/api/dev/simulations/"))return a(T.simulation);if(n==="POST"&&t==="/api/dev/test-mandates")return a({mandateId:"mandate_fixture",settlementMode:"simulated"},201);if(n==="POST"&&t.startsWith("/api/dev/test-mandates/")&&t.endsWith("/settle")){let p={};if(typeof d?.body=="string")try{p=JSON.parse(d.body)}catch{p={}}let s=p.outcome==="failed"?"failed":"succeeded",h=A(s);return s==="failed"&&p.declineReason&&(h.declineReason=p.declineReason),a(h)}return n==="POST"&&t.endsWith("/test-delivery")&&t.startsWith("/api/merchant/webhook-endpoints/")?a(T.webhookTestDelivery,202):n==="GET"&&t==="/api/merchant/webhook-endpoints"?a({data:[R()]}):n==="POST"&&t.endsWith("/rotate-secret")&&t.startsWith("/api/merchant/webhook-endpoints/")?a({...R(),secret:"whsec_fixture_rotated"}):n==="GET"&&t.startsWith("/api/merchant/webhook-endpoints/")?a(R()):n==="DELETE"&&t.startsWith("/api/merchant/webhook-endpoints/")?new Response(null,{status:204}):a({code:"fixture_route_not_found",method:n,path:t},404)}}var ee=Y;function D(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 q(){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 L(e){return{sessionId:"mpcs_fixture00000000000000000001",pathChangeUrl:"https://dev.facto.to/mandates/change-path?session=mpcs_fixture00000000000000000001",status:e,state:"state_path_change_fixture_000001",targetOrigin:"https://merchant.example",expiresAt:"2026-07-10T00:15:00.000Z"}}function M(){return{refundId:"re_fixture000000000000000000000001",paymentId:"mpay_fixture",status:"succeeded",amount:"9.99",currency:"USDC",reason:"requested_by_customer",merchantRefundRef:"merchant_refund_fixture",createdAt:b}}function R(){return{webhookEndpointId:"we_fixture000000000000000000000001",url:"https://merchant.example/facto-webhooks",enabledEvents:["payment.succeeded","payment.failed"],status:"enabled",createdAt:b}}function a(e,r=200){return new Response(JSON.stringify(e),{status:r,headers:{"content-type":"application/json"}})}export{W as CANONICAL_MERCHANT_CAPABILITY_TEMPLATES,N as MERCHANT_PARTNER_WORKSPACE_OPERATION_IDS,l as MerchantPartnerWorkspaceMockError,Y as createFactoConnectFixtureTransport,ee as createFactoTestTransport,j as createMerchantPartnerWorkspaceMock,T as devFixtures,X as devScenarios,Z as merchantDevAppFixture,V as merchantFutureTemplateProjectionFixture,B as merchantProductionAppNegativeFixture};
package/package.json CHANGED
@@ -1,7 +1,18 @@
1
1
  {
2
2
  "name": "@facto-to/connect",
3
- "version": "0.0.1-beta.1",
3
+ "version": "0.0.1-beta.14",
4
4
  "description": "Facto Connect SDK for linking partner users to Facto accounts and payment routes.",
5
+ "homepage": "https://facto.to",
6
+ "author": "Facto (https://facto.to)",
7
+ "keywords": [
8
+ "facto",
9
+ "payments",
10
+ "connect",
11
+ "stablecoin",
12
+ "checkout",
13
+ "merchant",
14
+ "sdk"
15
+ ],
5
16
  "repository": {
6
17
  "type": "git",
7
18
  "url": "git+https://github.com/Facto-to/sdk.git",
@@ -9,29 +20,62 @@
9
20
  },
10
21
  "type": "module",
11
22
  "sideEffects": false,
23
+ "bin": {
24
+ "facto-connect": "./dist/cli/index.js"
25
+ },
12
26
  "main": "./dist/browser/index.cjs",
13
27
  "module": "./dist/browser/index.js",
14
28
  "types": "./dist/browser/index.d.ts",
15
29
  "exports": {
16
30
  ".": {
17
- "types": "./dist/browser/index.d.ts",
18
- "import": "./dist/browser/index.js",
19
- "require": "./dist/browser/index.cjs"
31
+ "import": {
32
+ "types": "./dist/browser/index.d.ts",
33
+ "default": "./dist/browser/index.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/browser/index.d.cts",
37
+ "default": "./dist/browser/index.cjs"
38
+ }
20
39
  },
21
40
  "./server": {
22
- "types": "./dist/server/index.d.ts",
23
- "import": "./dist/server/index.js",
24
- "require": "./dist/server/index.cjs"
41
+ "import": {
42
+ "types": "./dist/server/index.d.ts",
43
+ "default": "./dist/server/index.js"
44
+ },
45
+ "require": {
46
+ "types": "./dist/server/index.d.cts",
47
+ "default": "./dist/server/index.cjs"
48
+ }
49
+ },
50
+ "./card-connect-admin": {
51
+ "import": {
52
+ "types": "./dist/server/card-connect-admin-client.d.ts",
53
+ "default": "./dist/server/card-connect-admin-client.js"
54
+ },
55
+ "require": {
56
+ "types": "./dist/server/card-connect-admin-client.d.cts",
57
+ "default": "./dist/server/card-connect-admin-client.cjs"
58
+ }
25
59
  },
26
60
  "./testing": {
27
- "types": "./dist/testing/index.d.ts",
28
- "import": "./dist/testing/index.js",
29
- "require": "./dist/testing/index.cjs"
61
+ "import": {
62
+ "types": "./dist/testing/index.d.ts",
63
+ "default": "./dist/testing/index.js"
64
+ },
65
+ "require": {
66
+ "types": "./dist/testing/index.d.cts",
67
+ "default": "./dist/testing/index.cjs"
68
+ }
30
69
  },
31
70
  "./react": {
32
- "types": "./dist/react/index.d.ts",
33
- "import": "./dist/react/index.js",
34
- "require": "./dist/react/index.cjs"
71
+ "import": {
72
+ "types": "./dist/react/index.d.ts",
73
+ "default": "./dist/react/index.js"
74
+ },
75
+ "require": {
76
+ "types": "./dist/react/index.d.cts",
77
+ "default": "./dist/react/index.cjs"
78
+ }
35
79
  },
36
80
  "./package.json": "./package.json"
37
81
  },
@@ -58,15 +102,18 @@
58
102
  "prepublishOnly": "npm run build"
59
103
  },
60
104
  "devDependencies": {
61
- "@facto-to/chains": "0.0.1-beta.1",
105
+ "@facto-to/chains": "0.0.1-beta.14",
62
106
  "@facto-to/engine-wire": "0.2.0",
63
- "@types/node": "^25.9.3",
64
- "jsdom": "^27.1.0",
107
+ "@types/node": "^26.4.0",
108
+ "jsdom": "^30.0.1",
65
109
  "tsup": "^8.5.0",
66
110
  "typescript": "^5.9.3",
67
- "vitest": "^3.2.1"
111
+ "vitest": "^4.1.11"
68
112
  },
69
113
  "publishConfig": {
70
114
  "access": "restricted"
115
+ },
116
+ "engines": {
117
+ "node": ">=20.9.0"
71
118
  }
72
119
  }