@capxul/mcp 4.20.0-beta.20 → 4.20.0-beta.22

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 (2) hide show
  1. package/dist/main.mjs +214 -65
  2. package/package.json +2 -2
package/dist/main.mjs CHANGED
@@ -13404,6 +13404,7 @@ const PreparedOfferCheckoutExecutionSchema = Schema.Struct({
13404
13404
  });
13405
13405
  /** Link holders receive payment terms, not the private Invoice document. */
13406
13406
  const InvoiceCheckoutSummarySchema = Schema.Struct({
13407
+ documentKind: Schema.optional(Schema.Literals(["memo", "invoice"])),
13407
13408
  linkToken: text$3(128),
13408
13409
  issuerLabel: text$3(256),
13409
13410
  dueAt: InvoiceDraftSchema.fields.dueAt,
@@ -13465,6 +13466,44 @@ const PreparedInvoiceCheckoutExecutionSchema = Schema.Struct({
13465
13466
  ...registeredCheckoutExecutionFields,
13466
13467
  invoice: InvoiceCheckoutSummarySchema
13467
13468
  });
13469
+ /** Generic request checkout uses the same fixed obligation and receipt contract. */
13470
+ const RequestCheckoutSummarySchema = Schema.Struct({
13471
+ ...InvoiceCheckoutSummarySchema.fields,
13472
+ documentKind: Schema.Literals(["memo", "invoice"])
13473
+ });
13474
+ const RequestCheckoutPreparationSchema = Schema.Struct({
13475
+ request: RequestCheckoutSummarySchema,
13476
+ sourceWallet: InvoiceCheckoutPreparationSchema.fields.sourceWallet,
13477
+ allowance: InvoiceCheckoutPreparationSchema.fields.allowance,
13478
+ approval: InvoiceCheckoutPreparationSchema.fields.approval,
13479
+ payment: InvoiceCheckoutPreparationSchema.fields.payment
13480
+ });
13481
+ const RequestCheckoutStateSchema = Schema.Struct({
13482
+ request: RequestCheckoutSummarySchema,
13483
+ verification: InvoiceCheckoutStateSchema.fields.verification,
13484
+ receipt: InvoiceCheckoutStateSchema.fields.receipt,
13485
+ latePayment: InvoiceCheckoutStateSchema.fields.latePayment
13486
+ });
13487
+ const RequestCheckoutReconciliationSchema = Schema.Union([
13488
+ Schema.Struct({
13489
+ status: Schema.Literal("verified"),
13490
+ receipt: CheckoutReceiptSchema,
13491
+ state: RequestCheckoutStateSchema
13492
+ }),
13493
+ Schema.Struct({
13494
+ status: Schema.Literals(["pending", "provider_failure"]),
13495
+ state: RequestCheckoutStateSchema
13496
+ }),
13497
+ Schema.Struct({
13498
+ status: Schema.Literal("mismatch"),
13499
+ code: Schema.String,
13500
+ state: RequestCheckoutStateSchema
13501
+ })
13502
+ ]);
13503
+ const PreparedRequestCheckoutExecutionSchema = Schema.Struct({
13504
+ ...registeredCheckoutExecutionFields,
13505
+ request: RequestCheckoutSummarySchema
13506
+ });
13468
13507
  //#endregion
13469
13508
  //#region ../../packages/wire/src/bootstrap.ts
13470
13509
  const PUBLIC_POSTHOG_PROJECT_TOKEN = /^phc_[A-Za-z0-9_-]{1,191}$/u;
@@ -13583,6 +13622,13 @@ const CAPXUL_FUNCTIONS = {
13583
13622
  state: "financialOps/offerCheckoutSettlement:state",
13584
13623
  reconcile: "financialOps/offerCheckoutSettlement:reconcile"
13585
13624
  },
13625
+ "financialOps/requestCheckouts": {
13626
+ summary: "financialOps/requestCheckouts:summary",
13627
+ prepare: "financialOps/requestCheckouts:prepare",
13628
+ state: "financialOps/requestCheckouts:state",
13629
+ reconcile: "financialOps/requestCheckouts:reconcile",
13630
+ prepareRegistered: "financialOps/requestCheckouts:prepareRegistered"
13631
+ },
13586
13632
  "financialOps/invoiceCheckouts": {
13587
13633
  summary: "financialOps/invoiceCheckouts:summary",
13588
13634
  prepare: "financialOps/invoiceCheckouts:prepare",
@@ -15153,6 +15199,11 @@ const CAPXUL_OPERATIONS = {
15153
15199
  deactivate: "offers.deactivate"
15154
15200
  },
15155
15201
  checkouts: {
15202
+ request: "checkouts.request",
15203
+ prepareRequest: "checkouts.prepareRequest",
15204
+ requestState: "checkouts.requestState",
15205
+ reconcileRequest: "checkouts.reconcileRequest",
15206
+ prepareRequestRegistered: "checkouts.prepareRequestRegistered",
15156
15207
  invoice: "checkouts.invoice",
15157
15208
  prepareInvoice: "checkouts.prepareInvoice",
15158
15209
  invoiceState: "checkouts.invoiceState",
@@ -17352,7 +17403,7 @@ function signerFailure(source, operation, cause) {
17352
17403
  }
17353
17404
  //#endregion
17354
17405
  //#region ../../packages/sdk/package.json
17355
- var version$3 = "4.20.0-beta.20";
17406
+ var version$3 = "4.20.0-beta.22";
17356
17407
  //#endregion
17357
17408
  //#region ../../packages/sdk/src/telemetry/exception-projection.ts
17358
17409
  /** Fixed fallback for failures that have no safe message. */
@@ -19594,19 +19645,41 @@ function itemFactsMatch(source, item, observation) {
19594
19645
  if (exact.denomination !== 1 || item.tokenAddress.toLowerCase() !== asset?.tokenAddress.toLowerCase() || (item.operation === "send" ? item.rawAmount : item.totalAmount) !== exact.minorUnits || !operationMatches(source, item) || observation !== void 0 && "to" in source && !recipientMatches$1(source, observation, item.recipientSafe.toLowerCase())) return null;
19595
19646
  return exact;
19596
19647
  }
19648
+ /** Retry keeps the original request instruction. Ordinary Payment retries keep actor context. */
19649
+ function requestRetryInstruction(input) {
19650
+ const request = input.evidence.request;
19651
+ const original = input.evidence.sourceCommand;
19652
+ if (!("kind" in request) || request.kind !== "retry" || original?.kind !== "birth" || original.lineage?.kind !== "payment_request" && original.lineage?.kind !== "invoice_checkout" || original.lineage.requestId !== original.requestKey || !input.evidence.sourcePaymentIds?.includes(request.paymentId)) return void 0;
19653
+ const document = original.items[input.index]?.document;
19654
+ if (document?.kind !== "envelope") return void 0;
19655
+ const bytes = decodeCanonicalBase64V3(document.bytesBase64);
19656
+ const envelope = decodeSupportedPaymentDocumentEnvelope(bytes);
19657
+ if (envelope.primaryType !== "Memo" && envelope.primaryType !== "Invoice") return void 0;
19658
+ return {
19659
+ documentHash: hashSupportedPaymentDocument(envelope),
19660
+ contentHash: hashPaymentDocumentContentV3(bytes),
19661
+ role: "instruction",
19662
+ kind: envelope.primaryType === "Memo" ? "memo" : "invoice",
19663
+ format: envelope.version === 4 ? "envelope-v4" : "envelope-v3",
19664
+ issuedAt: envelope.message.issuedAt
19665
+ };
19666
+ }
19597
19667
  async function documentContextMatches(input, command, item, bundle, ref, exact) {
19598
19668
  const envelope = bundle.envelope;
19599
- const originId = hashDocumentOriginIdV3({
19669
+ const request = input.evidence.request;
19670
+ const confirmedInstruction = "kind" in request && request.kind === "payment_request" ? request.confirmation.instruction : requestRetryInstruction(input);
19671
+ const originId = confirmedInstruction === void 0 ? hashDocumentOriginIdV3({
19600
19672
  chainId: input.evidence.chainId,
19601
19673
  actorKind: input.actorKind,
19602
19674
  actorId: input.actorId,
19603
19675
  requestKey: input.requestKey,
19604
19676
  itemIndex: input.index
19605
- });
19606
- return bundle.originId === originId && verifySupportedPaymentDocumentContext(envelope, {
19677
+ }) : envelope.message.originId;
19678
+ const source = confirmedInstruction !== void 0 && envelope.primaryType === "Memo" ? envelope.message.source : command.senderSafe.toLowerCase();
19679
+ return (confirmedInstruction === void 0 || documentJson$1(ref) === documentJson$1(confirmedInstruction)) && bundle.originId === originId && verifySupportedPaymentDocumentContext(envelope, {
19607
19680
  chainId: input.evidence.chainId,
19608
19681
  originId,
19609
- source: command.senderSafe.toLowerCase(),
19682
+ source,
19610
19683
  target: item.recipientSafe.toLowerCase(),
19611
19684
  amount: {
19612
19685
  asset: exact.asset,
@@ -19786,7 +19859,7 @@ function verifiesOfferCheckoutBirthEvidence(evidence, checkout, chainId) {
19786
19859
  /** Invoice checkout binds public fixed terms and the caller-selected funding Safe. */
19787
19860
  function verifiesInvoiceCheckoutBirthEvidence(evidence, invoice, chainId, sourceWallet) {
19788
19861
  const item = evidence.preparedCommand?.items[0];
19789
- return "kind" in evidence.request && evidence.request.kind === "invoice_checkout" && evidence.request.linkToken === invoice.linkToken && evidence.preparedCommand?.items.length === 1 && item?.operation === "send" && evidence.preparedCommand.senderSafe.toLowerCase() === sourceWallet.toLowerCase() && evidence.preparedCommand.contractAddress.toLowerCase() === invoice.contractAddress.toLowerCase() && item.settlementId === invoice.settlementId && item.documentHash === invoice.documentHash && item.recipientSafe.toLowerCase() === invoice.recipientSafe.toLowerCase() && item.tokenAddress.toLowerCase() === invoice.tokenAddress.toLowerCase() && item.rawAmount === invoice.rawAmount && item.kind === 1 && invoice.chainId === chainId;
19862
+ return "kind" in evidence.request && evidence.request.kind === "invoice_checkout" && evidence.request.linkToken === invoice.linkToken && evidence.preparedCommand?.items.length === 1 && item?.operation === "send" && evidence.preparedCommand.senderSafe.toLowerCase() === sourceWallet.toLowerCase() && evidence.preparedCommand.contractAddress.toLowerCase() === invoice.contractAddress.toLowerCase() && item.settlementId === invoice.settlementId && item.documentHash === invoice.documentHash && item.recipientSafe.toLowerCase() === invoice.recipientSafe.toLowerCase() && item.tokenAddress.toLowerCase() === invoice.tokenAddress.toLowerCase() && item.rawAmount === invoice.rawAmount && item.kind === (invoice.documentKind === "memo" ? 0 : 1) && invoice.chainId === chainId;
19790
19863
  }
19791
19864
  //#endregion
19792
19865
  //#region ../../packages/sdk/src/surface/payment-command-execution.ts
@@ -65601,8 +65674,14 @@ function makeOnboardingMethods(deps) {
65601
65674
  //#region ../../packages/sdk/src/contract/checkouts.ts
65602
65675
  const fns = CAPXUL_FUNCTIONS["financialOps/offerCheckouts"];
65603
65676
  const settlement = CAPXUL_FUNCTIONS["financialOps/offerCheckoutSettlement"];
65677
+ const requests = CAPXUL_FUNCTIONS["financialOps/requestCheckouts"];
65604
65678
  const invoices = CAPXUL_FUNCTIONS["financialOps/invoiceCheckouts"];
65605
65679
  const checkoutContract = {
65680
+ request: makeFunctionReference(requests.summary),
65681
+ prepareRequest: makeFunctionReference(requests.prepare),
65682
+ requestState: makeFunctionReference(requests.state),
65683
+ reconcileRequest: makeFunctionReference(requests.reconcile),
65684
+ prepareRequestRegistered: makeFunctionReference(requests.prepareRegistered),
65606
65685
  invoice: makeFunctionReference(invoices.summary),
65607
65686
  prepareInvoice: makeFunctionReference(invoices.prepare),
65608
65687
  invoiceState: makeFunctionReference(invoices.state),
@@ -65622,9 +65701,96 @@ const missing = async () => ({
65622
65701
  ok: false,
65623
65702
  error: Errors.notImplemented("checkouts", "convex")
65624
65703
  });
65704
+ const decodeCheckoutResponse = (read) => Effect.try({
65705
+ try: read,
65706
+ catch: (cause) => ({ publicError: isCapxulError(cause) ? cause : Errors.unknown(cause) })
65707
+ });
65708
+ function decodeObligationSummary(value, generic) {
65709
+ if (generic) return Schema.decodeUnknownSync(RequestCheckoutSummarySchema)(value);
65710
+ const invoice = Schema.decodeUnknownSync(InvoiceCheckoutSummarySchema)(value);
65711
+ if (invoice.documentKind === "memo") throw Errors.invalidInput("invoice", "Invoice checkout cannot use a Memo");
65712
+ return invoice;
65713
+ }
65714
+ function decodeRegisteredObligation(value, generic) {
65715
+ if (generic) {
65716
+ const { request, ...evidence } = Schema.decodeUnknownSync(PreparedRequestCheckoutExecutionSchema, { onExcessProperty: "error" })(value);
65717
+ return {
65718
+ snapshot: request,
65719
+ evidence
65720
+ };
65721
+ }
65722
+ const { invoice, ...evidence } = Schema.decodeUnknownSync(PreparedInvoiceCheckoutExecutionSchema, { onExcessProperty: "error" })(value);
65723
+ if (invoice.documentKind === "memo") throw Errors.invalidInput("invoice", "Invoice checkout cannot use a Memo");
65724
+ return {
65725
+ snapshot: invoice,
65726
+ evidence
65727
+ };
65728
+ }
65729
+ async function payObligationRegistered(deps, input, options, generic) {
65730
+ const port = deps.convexCall;
65731
+ if (port === void 0 || deps.execution === void 0) return missing();
65732
+ const lifetime = deps.execution.actor.authLifetime();
65733
+ const authUserId = deps.execution.actor.authSession()?.authUserId;
65734
+ if (authUserId === void 0) return {
65735
+ ok: false,
65736
+ error: Errors.notAuthenticated()
65737
+ };
65738
+ const controls = deps.invocationControls?.(options) ?? options;
65739
+ const sourceWallet = Schema.decodeUnknownResult(AddressSchema$1)(input.sourceWallet);
65740
+ if (sourceWallet._tag === "Failure") return {
65741
+ ok: false,
65742
+ error: Errors.invalidInput("sourceWallet", "selected funding wallet is invalid")
65743
+ };
65744
+ const frozen = await runPortEffect(port.query(generic ? checkoutContract.request : checkoutContract.invoice, copyInvocationObservation(controls, { linkToken: input.linkToken })).pipe(Effect.flatMap((value) => decodeCheckoutResponse(() => value === null ? null : decodeObligationSummary(value, generic)))), controls, generic ? CAPXUL_OPERATIONS.checkouts.request : CAPXUL_OPERATIONS.checkouts.invoice, deps.runPromise);
65745
+ if (!deps.execution.actor.matchesAuthLifetime(lifetime, authUserId)) return {
65746
+ ok: false,
65747
+ error: Errors.cancelled({ operation: "checkouts" })
65748
+ };
65749
+ if (!frozen.ok) return frozen;
65750
+ if (frozen.value === null || frozen.value.linkToken !== input.linkToken) return {
65751
+ ok: false,
65752
+ error: Errors.invalidInput(generic ? "request" : "invoice", generic ? "Request is unavailable" : "Invoice is unavailable")
65753
+ };
65754
+ const snapshot = frozen.value;
65755
+ const { sourceWallet: _sourceWallet, ...wireInput } = input;
65756
+ const request = {
65757
+ kind: "invoice_checkout",
65758
+ linkToken: input.linkToken,
65759
+ payer: input.payer,
65760
+ ...input.permissionId === void 0 ? {} : { permissionId: input.permissionId }
65761
+ };
65762
+ return executePrepared(deps.execution, async (signerAddress) => {
65763
+ const prepared = await runPortEffect(generic ? port.action(checkoutContract.prepareRequestRegistered, copyInvocationObservation(controls, { input: {
65764
+ ...wireInput,
65765
+ signerAddress
65766
+ } })).pipe(Effect.flatMap((value) => decodeCheckoutResponse(() => decodeRegisteredObligation(value, true)))) : port.action(checkoutContract.prepareInvoiceRegistered, copyInvocationObservation(controls, { input: {
65767
+ ...wireInput,
65768
+ signerAddress
65769
+ } })).pipe(Effect.flatMap((value) => decodeCheckoutResponse(() => decodeRegisteredObligation(value, false)))), controls, generic ? CAPXUL_OPERATIONS.checkouts.prepareRequestRegistered : CAPXUL_OPERATIONS.moneyExecution.prepareInvoiceCheckoutExecution, deps.runPromise);
65770
+ if (!prepared.ok) return prepared;
65771
+ if (canonicalJson(prepared.value.snapshot) !== canonicalJson(snapshot)) return {
65772
+ ok: false,
65773
+ error: Errors.invalidInput(generic ? "request" : "invoice", "prepared checkout differs from frozen terms")
65774
+ };
65775
+ return {
65776
+ ok: true,
65777
+ value: {
65778
+ ...prepared.value.evidence,
65779
+ request,
65780
+ emitPaymentInitiated: false,
65781
+ recipientObservations: []
65782
+ }
65783
+ };
65784
+ }, async (actual) => canonicalJson(actual) === canonicalJson(request), false, void 0, controls?.signal, controls, void 0, void 0, snapshot, sourceWallet.success);
65785
+ }
65625
65786
  function makeCheckoutMethods(deps) {
65626
65787
  const port = deps.convexCall;
65627
65788
  if (port === void 0) return {
65789
+ request: missing,
65790
+ prepareRequest: missing,
65791
+ requestState: missing,
65792
+ reconcileRequest: missing,
65793
+ payRequestRegistered: missing,
65628
65794
  invoice: missing,
65629
65795
  prepareInvoice: missing,
65630
65796
  invoiceState: missing,
@@ -65641,82 +65807,65 @@ function makeCheckoutMethods(deps) {
65641
65807
  const offer = Schema.decodeUnknownSync(FixedOfferSchema);
65642
65808
  const checkout = Schema.decodeUnknownSync(OfferCheckoutSchema);
65643
65809
  return {
65810
+ request: (linkToken, options) => {
65811
+ const controls = deps.invocationControls?.(options) ?? options;
65812
+ return runPortEffect(port.query(checkoutContract.request, copyInvocationObservation(controls, { linkToken })).pipe(Effect.map((value) => value === null ? null : Schema.decodeUnknownSync(RequestCheckoutSummarySchema)(value))), controls, CAPXUL_OPERATIONS.checkouts.request, deps.runPromise);
65813
+ },
65814
+ prepareRequest: (input, options) => {
65815
+ const controls = deps.invocationControls?.(options) ?? options;
65816
+ return runPortEffect(port.mutation(checkoutContract.prepareRequest, copyInvocationObservation(controls, {
65817
+ linkToken: input.linkToken,
65818
+ sourceWallet: input.sourceWallet
65819
+ })).pipe(Effect.map((value) => Schema.decodeUnknownSync(RequestCheckoutPreparationSchema)(value))), controls, CAPXUL_OPERATIONS.checkouts.prepareRequest, deps.runPromise);
65820
+ },
65821
+ requestState: (linkToken, options) => {
65822
+ const controls = deps.invocationControls?.(options) ?? options;
65823
+ return runPortEffect(port.action(checkoutContract.requestState, copyInvocationObservation(controls, { linkToken })).pipe(Effect.map((value) => value === null ? null : Schema.decodeUnknownSync(RequestCheckoutStateSchema)(value))), controls, CAPXUL_OPERATIONS.checkouts.requestState, deps.runPromise);
65824
+ },
65825
+ reconcileRequest: (input, options) => {
65826
+ const controls = deps.invocationControls?.(options) ?? options;
65827
+ return runPortEffect(port.action(checkoutContract.reconcileRequest, copyInvocationObservation(controls, {
65828
+ linkToken: input.linkToken,
65829
+ transactionHash: input.transactionHash
65830
+ })).pipe(Effect.map((value) => Schema.decodeUnknownSync(RequestCheckoutReconciliationSchema)(value))), controls, CAPXUL_OPERATIONS.checkouts.reconcileRequest, deps.runPromise);
65831
+ },
65644
65832
  invoice: (linkToken, options) => {
65645
65833
  const controls = deps.invocationControls?.(options) ?? options;
65646
- return runPortEffect(port.query(checkoutContract.invoice, copyInvocationObservation(controls, { linkToken })).pipe(Effect.map((value) => value === null ? null : Schema.decodeUnknownSync(InvoiceCheckoutSummarySchema)(value))), controls, CAPXUL_OPERATIONS.checkouts.invoice, deps.runPromise);
65834
+ return runPortEffect(port.query(checkoutContract.invoice, copyInvocationObservation(controls, { linkToken })).pipe(Effect.flatMap((value) => decodeCheckoutResponse(() => value === null ? null : decodeObligationSummary(value, false)))), controls, CAPXUL_OPERATIONS.checkouts.invoice, deps.runPromise);
65647
65835
  },
65648
65836
  prepareInvoice: (input, options) => {
65649
65837
  const controls = deps.invocationControls?.(options) ?? options;
65650
65838
  return runPortEffect(port.query(checkoutContract.prepareInvoice, copyInvocationObservation(controls, {
65651
65839
  linkToken: input.linkToken,
65652
65840
  sourceWallet: input.sourceWallet
65653
- })).pipe(Effect.map((value) => Schema.decodeUnknownSync(InvoiceCheckoutPreparationSchema)(value))), controls, CAPXUL_OPERATIONS.checkouts.prepareInvoice, deps.runPromise);
65841
+ })).pipe(Effect.flatMap((value) => decodeCheckoutResponse(() => {
65842
+ const decoded = Schema.decodeUnknownSync(InvoiceCheckoutPreparationSchema)(value);
65843
+ decodeObligationSummary(decoded.invoice, false);
65844
+ return decoded;
65845
+ }))), controls, CAPXUL_OPERATIONS.checkouts.prepareInvoice, deps.runPromise);
65654
65846
  },
65655
65847
  invoiceState: (linkToken, options) => {
65656
65848
  const controls = deps.invocationControls?.(options) ?? options;
65657
- return runPortEffect(port.action(checkoutContract.invoiceState, copyInvocationObservation(controls, { linkToken })).pipe(Effect.map((value) => value === null ? null : Schema.decodeUnknownSync(InvoiceCheckoutStateSchema)(value))), controls, CAPXUL_OPERATIONS.checkouts.invoiceState, deps.runPromise);
65849
+ return runPortEffect(port.action(checkoutContract.invoiceState, copyInvocationObservation(controls, { linkToken })).pipe(Effect.flatMap((value) => decodeCheckoutResponse(() => {
65850
+ if (value === null) return null;
65851
+ const decoded = Schema.decodeUnknownSync(InvoiceCheckoutStateSchema)(value);
65852
+ decodeObligationSummary(decoded.invoice, false);
65853
+ return decoded;
65854
+ }))), controls, CAPXUL_OPERATIONS.checkouts.invoiceState, deps.runPromise);
65658
65855
  },
65659
65856
  reconcileInvoice: (input, options) => {
65660
65857
  const controls = deps.invocationControls?.(options) ?? options;
65661
65858
  return runPortEffect(port.action(checkoutContract.reconcileInvoice, copyInvocationObservation(controls, {
65662
65859
  linkToken: input.linkToken,
65663
65860
  transactionHash: input.transactionHash
65664
- })).pipe(Effect.map((value) => Schema.decodeUnknownSync(InvoiceCheckoutReconciliationSchema)(value))), controls, CAPXUL_OPERATIONS.checkouts.reconcileInvoice, deps.runPromise);
65665
- },
65666
- payInvoiceRegistered: async (input, options) => {
65667
- if (deps.execution === void 0) return missing();
65668
- const lifetime = deps.execution.actor.authLifetime();
65669
- const authUserId = deps.execution.actor.authSession()?.authUserId;
65670
- if (authUserId === void 0) return {
65671
- ok: false,
65672
- error: Errors.notAuthenticated()
65673
- };
65674
- const controls = deps.invocationControls?.(options) ?? options;
65675
- const sourceWallet = Schema.decodeUnknownResult(AddressSchema$1)(input.sourceWallet);
65676
- if (sourceWallet._tag === "Failure") return {
65677
- ok: false,
65678
- error: Errors.invalidInput("sourceWallet", "selected funding wallet is invalid")
65679
- };
65680
- const frozen = await runPortEffect(port.query(checkoutContract.invoice, copyInvocationObservation(controls, { linkToken: input.linkToken })).pipe(Effect.map((value) => value === null ? null : Schema.decodeUnknownSync(InvoiceCheckoutSummarySchema)(value))), controls, CAPXUL_OPERATIONS.checkouts.invoice, deps.runPromise);
65681
- if (!deps.execution.actor.matchesAuthLifetime(lifetime, authUserId)) return {
65682
- ok: false,
65683
- error: Errors.cancelled({ operation: "checkouts" })
65684
- };
65685
- if (!frozen.ok) return frozen;
65686
- if (frozen.value === null || frozen.value.linkToken !== input.linkToken) return {
65687
- ok: false,
65688
- error: Errors.invalidInput("invoice", "Invoice is unavailable")
65689
- };
65690
- const snapshot = frozen.value;
65691
- const { sourceWallet: _sourceWallet, ...wireInput } = input;
65692
- const request = {
65693
- kind: "invoice_checkout",
65694
- linkToken: input.linkToken,
65695
- payer: input.payer,
65696
- ...input.permissionId === void 0 ? {} : { permissionId: input.permissionId }
65697
- };
65698
- return executePrepared(deps.execution, async (signerAddress) => {
65699
- const prepared = await runPortEffect(port.action(checkoutContract.prepareInvoiceRegistered, copyInvocationObservation(controls, { input: {
65700
- ...wireInput,
65701
- signerAddress
65702
- } })).pipe(Effect.map((value) => Schema.decodeUnknownSync(PreparedInvoiceCheckoutExecutionSchema, { onExcessProperty: "error" })(value))), controls, CAPXUL_OPERATIONS.moneyExecution.prepareInvoiceCheckoutExecution, deps.runPromise);
65703
- if (!prepared.ok) return prepared;
65704
- if (canonicalJson(prepared.value.invoice) !== canonicalJson(snapshot)) return {
65705
- ok: false,
65706
- error: Errors.invalidInput("invoice", "prepared Invoice differs from frozen terms")
65707
- };
65708
- const { invoice: _invoice, ...evidence } = prepared.value;
65709
- return {
65710
- ok: true,
65711
- value: {
65712
- ...evidence,
65713
- request,
65714
- emitPaymentInitiated: false,
65715
- recipientObservations: []
65716
- }
65717
- };
65718
- }, async (actual) => canonicalJson(actual) === canonicalJson(request), false, void 0, controls?.signal, controls, void 0, void 0, snapshot, sourceWallet.success);
65861
+ })).pipe(Effect.flatMap((value) => decodeCheckoutResponse(() => {
65862
+ const decoded = Schema.decodeUnknownSync(InvoiceCheckoutReconciliationSchema)(value);
65863
+ decodeObligationSummary(decoded.state.invoice, false);
65864
+ return decoded;
65865
+ }))), controls, CAPXUL_OPERATIONS.checkouts.reconcileInvoice, deps.runPromise);
65719
65866
  },
65867
+ payInvoiceRegistered: (input, options) => payObligationRegistered(deps, input, options, false),
65868
+ payRequestRegistered: (input, options) => payObligationRegistered(deps, input, options, true),
65720
65869
  payRegistered: async (input, options) => {
65721
65870
  if (deps.execution === void 0) return missing();
65722
65871
  const lifetime = deps.execution.actor.authLifetime();
@@ -69743,7 +69892,7 @@ function stdioIdentity(env = process.env, options = {}) {
69743
69892
  }
69744
69893
  //#endregion
69745
69894
  //#region package.json
69746
- var version = "4.20.0-beta.20";
69895
+ var version = "4.20.0-beta.22";
69747
69896
  //#endregion
69748
69897
  //#region src/deps.ts
69749
69898
  const NO_IDENTITY = async () => void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/mcp",
3
- "version": "4.20.0-beta.20",
3
+ "version": "4.20.0-beta.22",
4
4
  "private": false,
5
5
  "description": "Capxul MCP server for auth, Account readiness, identity, Organizations, relationships, requests, destinations, and testnet funding over Streamable HTTP.",
6
6
  "keywords": [
@@ -51,7 +51,7 @@
51
51
  "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
52
52
  "vite-plus": "0.3.0",
53
53
  "@capxul/config": "0.4.0-beta.1",
54
- "@capxul/sdk": "4.20.0-beta.20",
54
+ "@capxul/sdk": "4.20.0-beta.22",
55
55
  "@capxul/typescript-config": "0.0.0"
56
56
  },
57
57
  "scripts": {