@omnixhq/ucp-client 2.4.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/adapters/anthropic.cjs +2 -6
  2. package/dist/adapters/anthropic.cjs.map +1 -1
  3. package/dist/adapters/anthropic.d.cts +1 -1
  4. package/dist/adapters/anthropic.d.ts +1 -1
  5. package/dist/adapters/anthropic.js +2 -6
  6. package/dist/adapters/anthropic.js.map +1 -1
  7. package/dist/adapters/langchain.cjs +1 -1
  8. package/dist/adapters/langchain.d.cts +1 -1
  9. package/dist/adapters/langchain.d.ts +1 -1
  10. package/dist/adapters/langchain.js +1 -1
  11. package/dist/adapters/mcp.cjs +2 -6
  12. package/dist/adapters/mcp.cjs.map +1 -1
  13. package/dist/adapters/mcp.d.cts +1 -1
  14. package/dist/adapters/mcp.d.ts +1 -1
  15. package/dist/adapters/mcp.js +2 -6
  16. package/dist/adapters/mcp.js.map +1 -1
  17. package/dist/adapters/openai.cjs +2 -6
  18. package/dist/adapters/openai.cjs.map +1 -1
  19. package/dist/adapters/openai.d.cts +1 -1
  20. package/dist/adapters/openai.d.ts +1 -1
  21. package/dist/adapters/openai.js +2 -6
  22. package/dist/adapters/openai.js.map +1 -1
  23. package/dist/adapters/vercel-ai.cjs +1 -1
  24. package/dist/adapters/vercel-ai.d.cts +1 -1
  25. package/dist/adapters/vercel-ai.d.ts +1 -1
  26. package/dist/adapters/vercel-ai.js +1 -1
  27. package/dist/{catch-errors-CO8dAo6Q.d.cts → catch-errors-B4orhUQa.d.cts} +2125 -386
  28. package/dist/catch-errors-B4orhUQa.d.cts.map +1 -0
  29. package/dist/{catch-errors-Cpn2vHir.js → catch-errors-CLgZxgI8.js} +9 -2
  30. package/dist/catch-errors-CLgZxgI8.js.map +1 -0
  31. package/dist/{catch-errors-C8MBfxB5.d.ts → catch-errors-CM_1SIc1.d.ts} +2128 -389
  32. package/dist/catch-errors-CM_1SIc1.d.ts.map +1 -0
  33. package/dist/{catch-errors-BZP237w4.cjs → catch-errors-tAkTCXMe.cjs} +14 -1
  34. package/dist/catch-errors-tAkTCXMe.cjs.map +1 -0
  35. package/dist/index.cjs +1237 -129
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +5 -5
  38. package/dist/index.d.cts.map +1 -1
  39. package/dist/index.d.ts +5 -5
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +359 -23
  42. package/dist/index.js.map +1 -1
  43. package/package.json +2 -2
  44. package/dist/catch-errors-BZP237w4.cjs.map +0 -1
  45. package/dist/catch-errors-C8MBfxB5.d.ts.map +0 -1
  46. package/dist/catch-errors-CO8dAo6Q.d.cts.map +0 -1
  47. package/dist/catch-errors-Cpn2vHir.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AccountInfoSchema, AdapterOptions, AdjustmentSchema, AdjustmentStatusEnumSchema, AgentTool, Ap2MandateAp2WithCheckoutMandateSchema, Ap2MandateAp2WithMerchantAuthorizationSchema, Ap2MandateCheckoutMandateSchema, Ap2MandateErrorCodeSchema, Ap2MandateMerchantAuthorizationSchema, AuthorizationParams, BindingSchema, BusinessFulfillmentConfigSchema, BuyerConsent, BuyerConsentBuyerSchema, BuyerConsentConsentSchema, BuyerSchema, CapabilityBaseSchema, CapabilityBusinessSchema, CapabilityPlatformSchema, CapabilityResponseSchema, CardCredential, CardCredentialCardNumberTypeEnumSchema, CardCredentialSchema, CardPaymentInstrumentSchema, CheckoutCapability, CheckoutCompleteRequestSchema, CheckoutCreateRequestSchema, CheckoutExtensions, CheckoutResponseSchema, CheckoutResponseStatusSchema, CheckoutSchema, CheckoutSession, CheckoutSessionSchema, CheckoutSessionStatus, CheckoutStatusEnumSchema, CheckoutUpdateRequestSchema, CompleteCheckoutPayload, CompleteCheckoutRequestSchema, ConnectedClient, ContextSchema, CreateCheckoutPayload, CreateCheckoutRequestSchema, DEFAULT_UCP_VERSION, DiscountAllocationSchema, DiscountAppliedDiscountMethodEnumSchema, DiscountAppliedDiscountSchema, DiscountDiscountsObjectSchema, EmbeddedConfigSchema, ExpectationMethodTypeEnumSchema, ExpectationSchema, FulfillmentAvailableMethodSchema, FulfillmentAvailableMethodTypeEnumSchema, FulfillmentDestinationSchema, FulfillmentEventSchema, FulfillmentExtensionFulfillmentAvailableMethodSchema, FulfillmentExtensionFulfillmentGroupSchema, FulfillmentExtensionFulfillmentMethodSchema, FulfillmentExtensionFulfillmentOptionSchema, FulfillmentExtensionFulfillmentSchema, FulfillmentGroupSchema, FulfillmentGroupUpdatePayload, FulfillmentGroupUpdateRequestSchema, FulfillmentMethodCreatePayload, FulfillmentMethodCreateRequestSchema, FulfillmentMethodResponseSchema, FulfillmentMethodSchema, FulfillmentMethodTypeEnumSchema, FulfillmentMethodUpdatePayload, FulfillmentMethodUpdateRequestSchema, FulfillmentOptionSchema, FulfillmentResponseSchema, FulfillmentSchema, IdentityLinkingCapability, ItemResponseSchema, ItemSchema, JWK, JsonSchema, LineItemResponseSchema, LineItemSchema, LineItemUpdatePayload, LineItemUpdateRequestSchema, LinkSchema, LocalizationContext, MerchantFulfillmentConfigSchema, MessageErrorContentTypeEnumSchema, MessageErrorSchema, MessageErrorSeverityEnumSchema, MessageInfoContentTypeEnumSchema, MessageInfoSchema, MessageSchema, MessageWarningContentTypeEnumSchema, MessageWarningSchema, OAuthServerMetadata, OrderCapability, OrderConfirmationSchema, OrderLineItemSchema, OrderLineItemStatusEnumSchema, OrderSchema, OrderUpdate, OrderUpdateSchema, PaymentCredential, PaymentCredentialSchema, PaymentHandlerBaseSchema, PaymentHandlerBusinessSchema, PaymentHandlerInstance, PaymentHandlerMap, PaymentHandlerPlatformSchema, PaymentHandlerResponseSchema, PaymentIdentitySchema, PaymentInstrument, PaymentInstrumentResponseSchema, PaymentInstrumentSchema, PaymentResponseSchema, PaymentSchema, PlatformFulfillmentConfigSchema, PostalAddress, PostalAddressSchema, ProfileSchemaBaseSchema, ProfileSchemaBusinessProfileSchema, ProfileSchemaPlatformProfileSchema, ProfileSchemaSigningKeySchema, ProfileSchemaSigningKeyUseEnumSchema, RetailLocationSchema, ServiceBaseSchema, ServiceBaseTransportEnumSchema, ServiceBusinessSchema, ServicePlatformSchema, ServiceResponseSchema, ShippingDestinationSchema, TokenCredential, TokenCredentialSchema, TokenExchangeParams, TokenRefreshParams, TokenResponse, TokenRevokeParams, ToolDescriptor, ToolErrorResult, TotalResponseSchema, TotalSchema, TotalTypeEnumSchema, UCPClient, UCPClientConfig, UCPProfile, UCPProfileSchema, UCPSpecOrder, UCP_CAPABILITIES, UcpBaseSchema, UcpBusinessSchema, UcpDiscoveryBusinessProfileSchema, UcpDiscoveryPlatformProfileSchema, UcpEntitySchema, UcpPlatformSchema, UcpResponseCheckoutSchema, UcpResponseOrderSchema, UcpReverseDomainNameSchema, UcpSigningKeySchema, UcpVersionSchema, UpdateCheckoutPayload, UpdateCheckoutRequestSchema, WebhookEvent, WebhookEventSchema, connect, getAgentTools } from "./catch-errors-C8MBfxB5.js";
1
+ import { AccountInfoSchema, AdapterOptions, AdjustmentSchema, AdjustmentStatusEnumSchema, AgentTool, AmountSchema, Ap2MandateAp2WithCheckoutMandateSchema, Ap2MandateAp2WithMerchantAuthorizationSchema, Ap2MandateCheckoutMandateSchema, Ap2MandateErrorCodeSchema, Ap2MandateMerchantAuthorizationSchema, AuthorizationParams, AvailablePaymentInstrumentSchema, BindingSchema, BusinessFulfillmentConfigSchema, BuyerConsent, BuyerConsentBuyerSchema, BuyerConsentConsentSchema, BuyerSchema, CapabilityBaseSchema, CapabilityBusinessSchema, CapabilityPlatformSchema, CapabilityResponseSchema, CardCredential, CardCredentialCardNumberTypeEnumSchema, CardCredentialSchema, CardPaymentInstrumentAvailableCardPaymentInstrumentSchema, Cart, CartCapability, CartCreatePayload, CartCreateRequestSchema, CartResponseSchema, CartSchema, CartUpdatePayload, CartUpdateRequestSchema, CatalogCapability, CatalogExtensions, CatalogLookupResponse, CatalogLookupSchema, CatalogSearchResponse, CatalogSearchSchema, CategorySchema, CheckoutCapability, CheckoutCompleteRequestSchema, CheckoutCreateRequestSchema, CheckoutExtensions, CheckoutResponseSchema, CheckoutResponseStatusSchema, CheckoutSchema, CheckoutSession, CheckoutSessionSchema, CheckoutSessionStatus, CheckoutStatusEnumSchema, CheckoutUpdateRequestSchema, CompleteCheckoutPayload, CompleteCheckoutRequestSchema, ConnectedClient, ContextSchema, CreateCheckoutPayload, CreateCheckoutRequestSchema, DEFAULT_UCP_VERSION, DescriptionSchema, DetailOptionValue, DetailOptionValueSchema, DiscountAllocationSchema, DiscountAppliedDiscountMethodEnumSchema, DiscountAppliedDiscountSchema, DiscountDiscountsObjectSchema, EmbeddedConfigSchema, ErrorCodeSchema, ErrorResponseSchema, ExpectationMethodTypeEnumSchema, ExpectationSchema, FulfillmentAvailableMethodSchema, FulfillmentAvailableMethodTypeEnumSchema, FulfillmentDestinationSchema, FulfillmentEventSchema, FulfillmentExtensionFulfillmentAvailableMethodSchema, FulfillmentExtensionFulfillmentGroupSchema, FulfillmentExtensionFulfillmentMethodSchema, FulfillmentExtensionFulfillmentOptionSchema, FulfillmentExtensionFulfillmentSchema, FulfillmentGroupSchema, FulfillmentGroupUpdatePayload, FulfillmentGroupUpdateRequestSchema, FulfillmentMethodCreatePayload, FulfillmentMethodCreateRequestSchema, FulfillmentMethodResponseSchema, FulfillmentMethodSchema, FulfillmentMethodTypeEnumSchema, FulfillmentMethodUpdatePayload, FulfillmentMethodUpdateRequestSchema, FulfillmentOptionSchema, FulfillmentResponseSchema, FulfillmentSchema, IdentityLinkingCapability, InputCorrelationSchema, ItemResponseSchema, ItemSchema, JWK, JsonSchema, LineItemResponseSchema, LineItemSchema, LineItemUpdatePayload, LineItemUpdateRequestSchema, LinkSchema, LocalizationContext, MediaSchema, MerchantFulfillmentConfigSchema, MessageErrorContentTypeEnumSchema, MessageErrorSchema, MessageErrorSeverityEnumSchema, MessageInfoContentTypeEnumSchema, MessageInfoSchema, MessageSchema, MessageWarningContentTypeEnumSchema, MessageWarningSchema, OAuthServerMetadata, OptionValueSchema, OrderCapability, OrderConfirmationSchema, OrderLineItemSchema, OrderLineItemStatusEnumSchema, OrderUpdate, OrderUpdatePayload, OrderUpdateSchema, Pagination, PaginationSchema, PaymentCredential, PaymentCredentialSchema, PaymentHandlerBaseSchema, PaymentHandlerBusinessSchema, PaymentHandlerInstance, PaymentHandlerMap, PaymentHandlerPlatformSchema, PaymentHandlerResponseSchema, PaymentIdentitySchema, PaymentInstrument, PaymentInstrumentResponseSchema, PaymentInstrumentSchema, PaymentResponseSchema, PaymentSchema, PlatformFulfillmentConfigSchema, PostalAddress, PostalAddressSchema, PriceFilterSchema, PriceRangeSchema, PriceSchema, Product, ProductOptionSchema, ProductSchema, ProfileSchemaBaseSchema, ProfileSchemaBusinessProfileSchema, ProfileSchemaPlatformProfileSchema, ProfileSchemaSigningKeySchema, ProfileSchemaSigningKeyUseEnumSchema, RatingSchema, RetailLocationSchema, ReverseDomainNameSchema, SearchFilters, SearchFiltersSchema, SelectedOptionSchema, ServiceBaseSchema, ServiceBaseTransportEnumSchema, ServiceBusinessSchema, ServicePlatformSchema, ServiceResponseSchema, ShippingDestinationSchema, SignalsSchema, SignedAmountSchema, TokenCredential, TokenCredentialSchema, TokenExchangeParams, TokenRefreshParams, TokenResponse, TokenRevokeParams, ToolDescriptor, ToolErrorResult, TotalResponseSchema, TotalSchema, TotalsSchema, UCPClient, UCPClientConfig, UCPProfile, UCPProfileSchema, UCPSpecOrder, UCPSpecOrderSchema, UCP_CAPABILITIES, UcpBaseSchema, UcpBaseStatusEnumSchema, UcpBusinessSchema, UcpDiscoveryBusinessProfileSchema, UcpDiscoveryPlatformProfileSchema, UcpEntitySchema, UcpErrorSchema, UcpPlatformSchema, UcpRequiresSchema, UcpResponseCartSchema, UcpResponseCatalogSchema, UcpResponseCheckoutSchema, UcpResponseOrderSchema, UcpSigningKeySchema, UcpSigningKeySchema$1, UcpSuccessSchema, UcpVersionConstraintSchema, UcpVersionSchema, UpdateCheckoutPayload, UpdateCheckoutRequestSchema, Variant, VariantSchema, WebhookEvent, WebhookEventSchema, connect, getAgentTools } from "./catch-errors-CM_1SIc1.js";
2
2
 
3
3
  //#region src/verify-signature.d.ts
4
4
  /**
@@ -49,9 +49,9 @@ interface WebhookVerifier {
49
49
  * if (!valid) return res.status(401).send('Invalid signature');
50
50
  * ```
51
51
  */
52
- declare function createWebhookVerifier(gatewayUrl: string): WebhookVerifier;
53
-
54
- //#endregion
52
+ declare function createWebhookVerifier(gatewayUrl: string, options?: {
53
+ readonly refetchCooldownMs?: number;
54
+ }): WebhookVerifier; //#endregion
55
55
  //#region src/parse-webhook-event.d.ts
56
56
  //# sourceMappingURL=verify-signature.d.ts.map
57
57
  /**
@@ -130,5 +130,5 @@ declare class UCPOAuthError extends Error {
130
130
  //#endregion
131
131
  //# sourceMappingURL=errors.d.ts.map
132
132
 
133
- export { AccountInfoSchema, AdapterOptions, AdjustmentSchema, AdjustmentStatusEnumSchema, AgentTool, Ap2MandateAp2WithCheckoutMandateSchema, Ap2MandateAp2WithMerchantAuthorizationSchema, Ap2MandateCheckoutMandateSchema, Ap2MandateErrorCodeSchema, Ap2MandateMerchantAuthorizationSchema, AuthorizationParams, BindingSchema, BusinessFulfillmentConfigSchema, BuyerConsent, BuyerConsentBuyerSchema, BuyerConsentConsentSchema, BuyerSchema, CapabilityBaseSchema, CapabilityBusinessSchema, CapabilityPlatformSchema, CapabilityResponseSchema, CardCredential, CardCredentialCardNumberTypeEnumSchema, CardCredentialSchema, CardPaymentInstrumentSchema, CheckoutCapability, CheckoutCompleteRequestSchema, CheckoutCreateRequestSchema, CheckoutExtensions, CheckoutResponseSchema, CheckoutResponseStatusSchema, CheckoutSchema, CheckoutSession, CheckoutSessionSchema, CheckoutSessionStatus, CheckoutStatusEnumSchema, CheckoutUpdateRequestSchema, CompleteCheckoutPayload, CompleteCheckoutRequestSchema, ConnectedClient, ContentType, ContextSchema, CreateCheckoutPayload, CreateCheckoutRequestSchema, DEFAULT_UCP_VERSION, DiscountAllocationSchema, DiscountAppliedDiscountMethodEnumSchema, DiscountAppliedDiscountSchema, DiscountDiscountsObjectSchema, EmbeddedConfigSchema, ExpectationMethodTypeEnumSchema, ExpectationSchema, FulfillmentAvailableMethodSchema, FulfillmentAvailableMethodTypeEnumSchema, FulfillmentDestinationSchema, FulfillmentEventSchema, FulfillmentExtensionFulfillmentAvailableMethodSchema, FulfillmentExtensionFulfillmentGroupSchema, FulfillmentExtensionFulfillmentMethodSchema, FulfillmentExtensionFulfillmentOptionSchema, FulfillmentExtensionFulfillmentSchema, FulfillmentGroupSchema, FulfillmentGroupUpdatePayload, FulfillmentGroupUpdateRequestSchema, FulfillmentMethodCreatePayload, FulfillmentMethodCreateRequestSchema, FulfillmentMethodResponseSchema, FulfillmentMethodSchema, FulfillmentMethodTypeEnumSchema, FulfillmentMethodUpdatePayload, FulfillmentMethodUpdateRequestSchema, FulfillmentOptionSchema, FulfillmentResponseSchema, FulfillmentSchema, IdentityLinkingCapability, ItemResponseSchema, ItemSchema, JWK, UcpSigningKeySchema as JWKSchema, JsonSchema, LineItemResponseSchema, LineItemSchema, LineItemUpdatePayload, LineItemUpdateRequestSchema, LinkSchema, LocalizationContext, MerchantFulfillmentConfigSchema, MessageErrorContentTypeEnumSchema, MessageErrorSchema, MessageErrorSeverityEnumSchema, MessageInfoContentTypeEnumSchema, MessageInfoSchema, MessageSchema, MessageSeverity, MessageType, MessageWarningContentTypeEnumSchema, MessageWarningSchema, OAuthServerMetadata, OrderCapability, OrderConfirmationSchema, OrderLineItemSchema, OrderLineItemStatusEnumSchema, OrderUpdate, OrderUpdateSchema, PaymentCredential, PaymentCredentialSchema, PaymentHandlerBaseSchema, PaymentHandlerBusinessSchema, PaymentHandlerInstance, PaymentHandlerMap, PaymentHandlerPlatformSchema, PaymentHandlerResponseSchema, PaymentIdentitySchema, PaymentInstrument, PaymentInstrumentResponseSchema, PaymentInstrumentSchema, PaymentResponseSchema, PaymentSchema, PlatformFulfillmentConfigSchema, PostalAddress, PostalAddressSchema, ProfileSchemaBaseSchema, ProfileSchemaBusinessProfileSchema, ProfileSchemaPlatformProfileSchema, ProfileSchemaSigningKeySchema, ProfileSchemaSigningKeyUseEnumSchema, RetailLocationSchema, ServiceBaseSchema, ServiceBaseTransportEnumSchema, ServiceBusinessSchema, ServicePlatformSchema, ServiceResponseSchema, ShippingDestinationSchema, TokenCredential, TokenCredentialSchema, TokenExchangeParams, TokenRefreshParams, TokenResponse, TokenRevokeParams, ToolDescriptor, ToolErrorResult, TotalResponseSchema, TotalSchema, TotalTypeEnumSchema, UCPClient, UCPClientConfig, UCPError, UCPEscalationError, UCPIdempotencyConflictError, UCPMessage, UCPOAuthError, UCPProfile, UCPProfileSchema, UCPSpecOrder, OrderSchema as UCPSpecOrderSchema, UCP_CAPABILITIES, UcpBaseSchema, UcpBusinessSchema, UcpDiscoveryBusinessProfileSchema, UcpDiscoveryPlatformProfileSchema, UcpEntitySchema, UcpPlatformSchema, UcpResponseCheckoutSchema, UcpResponseOrderSchema, UcpReverseDomainNameSchema, UcpSigningKeySchema, UcpVersionSchema, UpdateCheckoutPayload, UpdateCheckoutRequestSchema, WebhookEvent, WebhookEventSchema, WebhookVerifier, connect, createWebhookVerifier, getAgentTools, parseWebhookEvent, verifyRequestSignature };
133
+ export { AccountInfoSchema, AdapterOptions, AdjustmentSchema, AdjustmentStatusEnumSchema, AgentTool, AmountSchema, Ap2MandateAp2WithCheckoutMandateSchema, Ap2MandateAp2WithMerchantAuthorizationSchema, Ap2MandateCheckoutMandateSchema, Ap2MandateErrorCodeSchema, Ap2MandateMerchantAuthorizationSchema, AuthorizationParams, AvailablePaymentInstrumentSchema, BindingSchema, BusinessFulfillmentConfigSchema, BuyerConsent, BuyerConsentBuyerSchema, BuyerConsentConsentSchema, BuyerSchema, CapabilityBaseSchema, CapabilityBusinessSchema, CapabilityPlatformSchema, CapabilityResponseSchema, CardCredential, CardCredentialCardNumberTypeEnumSchema, CardCredentialSchema, CardPaymentInstrumentAvailableCardPaymentInstrumentSchema, Cart, CartCapability, CartCreatePayload, CartCreateRequestSchema, CartResponseSchema, CartSchema, CartUpdatePayload, CartUpdateRequestSchema, CatalogCapability, CatalogExtensions, CatalogLookupResponse, CatalogLookupSchema, CatalogSearchResponse, CatalogSearchSchema, CategorySchema, CheckoutCapability, CheckoutCompleteRequestSchema, CheckoutCreateRequestSchema, CheckoutExtensions, CheckoutResponseSchema, CheckoutResponseStatusSchema, CheckoutSchema, CheckoutSession, CheckoutSessionSchema, CheckoutSessionStatus, CheckoutStatusEnumSchema, CheckoutUpdateRequestSchema, CompleteCheckoutPayload, CompleteCheckoutRequestSchema, ConnectedClient, ContentType, ContextSchema, CreateCheckoutPayload, CreateCheckoutRequestSchema, DEFAULT_UCP_VERSION, DescriptionSchema, DetailOptionValue, DetailOptionValueSchema, DiscountAllocationSchema, DiscountAppliedDiscountMethodEnumSchema, DiscountAppliedDiscountSchema, DiscountDiscountsObjectSchema, EmbeddedConfigSchema, ErrorCodeSchema, ErrorResponseSchema, ExpectationMethodTypeEnumSchema, ExpectationSchema, FulfillmentAvailableMethodSchema, FulfillmentAvailableMethodTypeEnumSchema, FulfillmentDestinationSchema, FulfillmentEventSchema, FulfillmentExtensionFulfillmentAvailableMethodSchema, FulfillmentExtensionFulfillmentGroupSchema, FulfillmentExtensionFulfillmentMethodSchema, FulfillmentExtensionFulfillmentOptionSchema, FulfillmentExtensionFulfillmentSchema, FulfillmentGroupSchema, FulfillmentGroupUpdatePayload, FulfillmentGroupUpdateRequestSchema, FulfillmentMethodCreatePayload, FulfillmentMethodCreateRequestSchema, FulfillmentMethodResponseSchema, FulfillmentMethodSchema, FulfillmentMethodTypeEnumSchema, FulfillmentMethodUpdatePayload, FulfillmentMethodUpdateRequestSchema, FulfillmentOptionSchema, FulfillmentResponseSchema, FulfillmentSchema, IdentityLinkingCapability, InputCorrelationSchema, ItemResponseSchema, ItemSchema, JWK, UcpSigningKeySchema$1 as JWKSchema, JsonSchema, LineItemResponseSchema, LineItemSchema, LineItemUpdatePayload, LineItemUpdateRequestSchema, LinkSchema, LocalizationContext, MediaSchema, MerchantFulfillmentConfigSchema, MessageErrorContentTypeEnumSchema, MessageErrorSchema, MessageErrorSeverityEnumSchema, MessageInfoContentTypeEnumSchema, MessageInfoSchema, MessageSchema, MessageSeverity, MessageType, MessageWarningContentTypeEnumSchema, MessageWarningSchema, OAuthServerMetadata, OptionValueSchema, OrderCapability, OrderConfirmationSchema, OrderLineItemSchema, OrderLineItemStatusEnumSchema, OrderUpdate, OrderUpdatePayload, OrderUpdateSchema, Pagination, PaginationSchema, PaymentCredential, PaymentCredentialSchema, PaymentHandlerBaseSchema, PaymentHandlerBusinessSchema, PaymentHandlerInstance, PaymentHandlerMap, PaymentHandlerPlatformSchema, PaymentHandlerResponseSchema, PaymentIdentitySchema, PaymentInstrument, PaymentInstrumentResponseSchema, PaymentInstrumentSchema, PaymentResponseSchema, PaymentSchema, PlatformFulfillmentConfigSchema, PostalAddress, PostalAddressSchema, PriceFilterSchema, PriceRangeSchema, PriceSchema, Product, ProductOptionSchema, ProductSchema, ProfileSchemaBaseSchema, ProfileSchemaBusinessProfileSchema, ProfileSchemaPlatformProfileSchema, ProfileSchemaSigningKeySchema, ProfileSchemaSigningKeyUseEnumSchema, RatingSchema, RetailLocationSchema, ReverseDomainNameSchema, SearchFilters, SearchFiltersSchema, SelectedOptionSchema, ServiceBaseSchema, ServiceBaseTransportEnumSchema, ServiceBusinessSchema, ServicePlatformSchema, ServiceResponseSchema, ShippingDestinationSchema, SignalsSchema, SignedAmountSchema, TokenCredential, TokenCredentialSchema, TokenExchangeParams, TokenRefreshParams, TokenResponse, TokenRevokeParams, ToolDescriptor, ToolErrorResult, TotalResponseSchema, TotalSchema, TotalsSchema, UCPClient, UCPClientConfig, UCPError, UCPEscalationError, UCPIdempotencyConflictError, UCPMessage, UCPOAuthError, UCPProfile, UCPProfileSchema, UCPSpecOrder, UCPSpecOrderSchema, UCP_CAPABILITIES, UcpBaseSchema, UcpBaseStatusEnumSchema, UcpBusinessSchema, UcpDiscoveryBusinessProfileSchema, UcpDiscoveryPlatformProfileSchema, UcpEntitySchema, UcpErrorSchema, UcpPlatformSchema, UcpRequiresSchema, UcpResponseCartSchema, UcpResponseCatalogSchema, UcpResponseCheckoutSchema, UcpResponseOrderSchema, UcpSigningKeySchema, UcpSuccessSchema, UcpVersionConstraintSchema, UcpVersionSchema, UpdateCheckoutPayload, UpdateCheckoutRequestSchema, Variant, VariantSchema, WebhookEvent, WebhookEventSchema, WebhookVerifier, connect, createWebhookVerifier, getAgentTools, parseWebhookEvent, verifyRequestSignature };
134
134
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/verify-signature.ts","../src/parse-webhook-event.ts","../src/errors.ts"],"sourcesContent":null,"mappings":";;;;;;;;;;;;;;;;;;;iBAWsB,sBAAA,wDAGE,QACrB;;AAJH;;;;AAIU;;UAsEO,eAAA;;;;;wDAKuC;AALxD;;;;;;;;;;;;;;;;;;AAyBgB,iBAAA,qBAAA,CAA2C,UAAe,EAAA,MAAA,CAAA,EAAf,eAAe;;;;;;;;;;;;;;;AAnG1E;;;;AAIU;;;;;;;;AAsEV;iBC1DgB,iBAAA,gBAAiC;;;;;KC3BrC,WAAA;KACA,eAAA;KAKA,WAAA;;UAGK,UAAA;iBACA;;;sBAGK;;;EFFA,SAAA,YAAA,CAAA,EEKI,WFLkB;;;AAIzC,cEKU,QAAA,SAAiB,KAAA,CFL3B;EAAO,SAAA,IAAA,EAAA,MAAA;iBEOO;;;;wBAIO;;8BAEM;EFyDb,WAAA,CAAA,IAAA,EAAe,MAAA,EAAA,OAKwB,EAAA,MAAO,EAAA,IAAA,CAAA,EEzDrD,WFyDqD,EAAA,UAAA,CAAA,EAAA,MAAA,EAAA,QAAA,EAAA;;2BErDlC;iCACM;;;;cAetB,2BAAA,SAAoC,QAAQ;;;;cAQ5C,kBAAA,SAA2B,KAAK;;;;;;cAYhC,aAAA,SAAsB,KAAK;EFqCxB,SAAA,UAAA,EAAA,MAAqB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/verify-signature.ts","../src/parse-webhook-event.ts","../src/errors.ts"],"sourcesContent":null,"mappings":";;;;;;;;;;;;;;;;;;;iBAWsB,sBAAA,wDAGE,QACrB;;AAJH;;;;AAIU;;UAsEO,eAAA;;;;;wDAKuC;AALxD;;;;;;;;;;;;;;;;;;AAyBgB,iBAAA,qBAAA,CAGb,UAAe,EAAA,MAAA,EAAA,QAAA,EAAA;;IAAf;;;;;;;;;;;;;AAtGH;;;;AAIU;;;;;;;;AAsEV;iBC1DgB,iBAAA,gBAAiC;;;;;KC3BrC,WAAA;KACA,eAAA;KAKA,WAAA;;UAGK,UAAA;iBACA;;;sBAGK;;;EFFA,SAAA,YAAA,CAAA,EEKI,WFLkB;;;AAIzC,cEKU,QAAA,SAAiB,KAAA,CFL3B;EAAO,SAAA,IAAA,EAAA,MAAA;iBEOO;;;;wBAIO;;8BAEM;EFyDb,WAAA,CAAA,IAAA,EAAe,MAAA,EAAA,OAKwB,EAAA,MAAO,EAAA,IAAA,CAAA,EEzDrD,WFyDqD,EAAA,UAAA,CAAA,EAAA,MAAA,EAAA,QAAA,EAAA;;2BErDlC;iCACM;;;;cAetB,2BAAA,SAAoC,QAAQ;;;;cAQ5C,kBAAA,SAA2B,KAAK;;;;;;cAYhC,aAAA,SAAsB,KAAK;EFqCxB,SAAA,UAAA,EAAA,MAAqB"}
package/dist/index.js CHANGED
@@ -1,14 +1,15 @@
1
1
  import { UCPError, UCPEscalationError, UCPIdempotencyConflictError, UCPOAuthError } from "./errors-DX7yw6Gl.js";
2
2
  import { z } from "zod";
3
3
  import { randomUUID } from "node:crypto";
4
- import { AccountInfoSchema, AdjustmentSchema, AdjustmentStatusEnumSchema, Ap2MandateAp2WithCheckoutMandateSchema, Ap2MandateAp2WithMerchantAuthorizationSchema, Ap2MandateCheckoutMandateSchema, Ap2MandateErrorCodeSchema, Ap2MandateMerchantAuthorizationSchema, BindingSchema, BusinessFulfillmentConfigSchema, BuyerConsentBuyerSchema, BuyerConsentConsentSchema, BuyerSchema, CapabilityBaseSchema, CapabilityBusinessSchema, CapabilityPlatformSchema, CapabilityResponseSchema, CardCredentialCardNumberTypeEnumSchema, CardCredentialSchema, CardPaymentInstrumentSchema, CheckoutCompleteRequestSchema, CheckoutCreateRequestSchema, CheckoutResponseSchema, CheckoutResponseStatusSchema, CheckoutSchema, CheckoutStatusEnumSchema, CheckoutUpdateRequestSchema, ContextSchema, DiscountAllocationSchema, DiscountAppliedDiscountMethodEnumSchema, DiscountAppliedDiscountSchema, DiscountDiscountsObjectSchema, EmbeddedConfigSchema, ExpectationMethodTypeEnumSchema, ExpectationSchema, FulfillmentAvailableMethodSchema, FulfillmentAvailableMethodTypeEnumSchema, FulfillmentDestinationSchema, FulfillmentEventSchema, FulfillmentExtensionFulfillmentAvailableMethodSchema, FulfillmentExtensionFulfillmentGroupSchema, FulfillmentExtensionFulfillmentMethodSchema, FulfillmentExtensionFulfillmentOptionSchema, FulfillmentExtensionFulfillmentSchema, FulfillmentGroupSchema, FulfillmentGroupUpdateRequestSchema, FulfillmentMethodCreateRequestSchema, FulfillmentMethodResponseSchema, FulfillmentMethodSchema, FulfillmentMethodTypeEnumSchema, FulfillmentMethodUpdateRequestSchema, FulfillmentOptionSchema, FulfillmentResponseSchema, FulfillmentSchema, ItemResponseSchema, ItemSchema, LineItemResponseSchema, LineItemSchema, LineItemUpdateRequestSchema, LinkSchema, MerchantFulfillmentConfigSchema, MessageErrorContentTypeEnumSchema, MessageErrorSchema, MessageErrorSeverityEnumSchema, MessageInfoContentTypeEnumSchema, MessageInfoSchema, MessageSchema, MessageWarningContentTypeEnumSchema, MessageWarningSchema, OrderConfirmationSchema, OrderLineItemSchema, OrderLineItemStatusEnumSchema, OrderSchema, OrderUpdateSchema, PaymentCredentialSchema, PaymentHandlerBaseSchema, PaymentHandlerBusinessSchema, PaymentHandlerPlatformSchema, PaymentHandlerResponseSchema, PaymentIdentitySchema, PaymentInstrumentResponseSchema, PaymentInstrumentSchema, PaymentResponseSchema, PaymentSchema, PlatformFulfillmentConfigSchema, PostalAddressSchema, ProfileSchemaBaseSchema, ProfileSchemaBusinessProfileSchema, ProfileSchemaPlatformProfileSchema, ProfileSchemaSigningKeySchema, ProfileSchemaSigningKeyUseEnumSchema, RetailLocationSchema, ServiceBaseSchema, ServiceBaseTransportEnumSchema, ServiceBusinessSchema, ServicePlatformSchema, ServiceResponseSchema, ShippingDestinationSchema, TokenCredentialSchema, TotalResponseSchema, TotalSchema, TotalTypeEnumSchema, UcpBaseSchema, UcpBusinessSchema, UcpDiscoveryBusinessProfileSchema, UcpDiscoveryPlatformProfileSchema, UcpDiscoveryProfileSchema, UcpEntitySchema, UcpPlatformSchema, UcpResponseCheckoutSchema, UcpResponseOrderSchema, UcpReverseDomainNameSchema, UcpSigningKeySchema, UcpVersionSchema } from "@omnixhq/ucp-js-sdk";
4
+ import { AccountInfoSchema, AdjustmentSchema, AdjustmentStatusEnumSchema, AmountSchema, Ap2MandateAp2WithCheckoutMandateSchema, Ap2MandateAp2WithMerchantAuthorizationSchema, Ap2MandateCheckoutMandateSchema, Ap2MandateErrorCodeSchema, Ap2MandateMerchantAuthorizationSchema, AvailablePaymentInstrumentSchema, BindingSchema, BusinessFulfillmentConfigSchema, BuyerConsentBuyerSchema, BuyerConsentConsentSchema, BuyerSchema, CapabilityBaseSchema, CapabilityBusinessSchema, CapabilityPlatformSchema, CapabilityResponseSchema, CardCredentialCardNumberTypeEnumSchema, CardCredentialSchema, CardPaymentInstrumentAvailableCardPaymentInstrumentSchema, CartCreateRequestSchema, CartSchema, CartSchema as CartSchema$1, CartUpdateRequestSchema, CatalogLookupSchema, CatalogSearchSchema, CategorySchema, CheckoutCompleteRequestSchema, CheckoutCompleteRequestSchema as CheckoutCompleteRequestSchema$1, CheckoutCreateRequestSchema, CheckoutCreateRequestSchema as CheckoutCreateRequestSchema$1, CheckoutResponseSchema, CheckoutResponseSchema as CheckoutResponseSchema$1, CheckoutResponseStatusSchema, CheckoutSchema, CheckoutStatusEnumSchema, CheckoutUpdateRequestSchema, CheckoutUpdateRequestSchema as CheckoutUpdateRequestSchema$1, ContextSchema, DescriptionSchema, DetailOptionValueSchema, DiscountAllocationSchema, DiscountAppliedDiscountMethodEnumSchema, DiscountAppliedDiscountSchema, DiscountDiscountsObjectSchema, EmbeddedConfigSchema, ErrorCodeSchema, ErrorResponseSchema, ExpectationMethodTypeEnumSchema, ExpectationSchema, FulfillmentAvailableMethodSchema, FulfillmentAvailableMethodTypeEnumSchema, FulfillmentDestinationSchema, FulfillmentEventSchema, FulfillmentExtensionFulfillmentAvailableMethodSchema, FulfillmentExtensionFulfillmentGroupSchema, FulfillmentExtensionFulfillmentMethodSchema, FulfillmentExtensionFulfillmentOptionSchema, FulfillmentExtensionFulfillmentSchema, FulfillmentGroupSchema, FulfillmentGroupUpdateRequestSchema, FulfillmentMethodCreateRequestSchema, FulfillmentMethodResponseSchema, FulfillmentMethodSchema, FulfillmentMethodTypeEnumSchema, FulfillmentMethodUpdateRequestSchema, FulfillmentOptionSchema, FulfillmentResponseSchema, FulfillmentSchema, InputCorrelationSchema, ItemResponseSchema, ItemSchema, LineItemResponseSchema, LineItemSchema, LineItemUpdateRequestSchema, LinkSchema, MediaSchema, MerchantFulfillmentConfigSchema, MessageErrorContentTypeEnumSchema, MessageErrorSchema, MessageErrorSeverityEnumSchema, MessageInfoContentTypeEnumSchema, MessageInfoSchema, MessageSchema, MessageWarningContentTypeEnumSchema, MessageWarningSchema, OptionValueSchema, OrderConfirmationSchema, OrderLineItemSchema, OrderLineItemStatusEnumSchema, OrderSchema, OrderSchema as UCPSpecOrderSchema, OrderUpdateSchema, PaginationSchema, PaymentCredentialSchema, PaymentHandlerBaseSchema, PaymentHandlerBusinessSchema, PaymentHandlerPlatformSchema, PaymentHandlerResponseSchema, PaymentIdentitySchema, PaymentInstrumentResponseSchema, PaymentInstrumentSchema, PaymentResponseSchema, PaymentSchema, PlatformFulfillmentConfigSchema, PostalAddressSchema, PriceFilterSchema, PriceRangeSchema, PriceSchema, ProductOptionSchema, ProductSchema, ProfileSchemaBaseSchema, ProfileSchemaBusinessProfileSchema, ProfileSchemaPlatformProfileSchema, ProfileSchemaSigningKeySchema, ProfileSchemaSigningKeyUseEnumSchema, RatingSchema, RetailLocationSchema, ReverseDomainNameSchema, SearchFiltersSchema, SelectedOptionSchema, ServiceBaseSchema, ServiceBaseTransportEnumSchema, ServiceBusinessSchema, ServicePlatformSchema, ServiceResponseSchema, ShippingDestinationSchema, SignalsSchema, SignedAmountSchema, TokenCredentialSchema, TotalResponseSchema, TotalSchema, TotalsSchema, UcpBaseSchema, UcpBaseStatusEnumSchema, UcpBusinessSchema, UcpDiscoveryBusinessProfileSchema, UcpDiscoveryPlatformProfileSchema, UcpDiscoveryProfileSchema, UcpEntitySchema, UcpErrorSchema, UcpPlatformSchema, UcpRequiresSchema, UcpResponseCartSchema, UcpResponseCatalogSchema, UcpResponseCheckoutSchema, UcpResponseOrderSchema, UcpSigningKeySchema, UcpSigningKeySchema as UcpSigningKeySchema$1, UcpSuccessSchema, UcpVersionConstraintSchema, UcpVersionSchema, VariantSchema } from "@omnixhq/ucp-js-sdk";
5
5
 
6
6
  //#region src/schemas.ts
7
- const CheckoutSessionSchema = CheckoutResponseSchema;
7
+ const CheckoutSessionSchema = CheckoutResponseSchema$1;
8
8
  const UCPProfileSchema = UcpDiscoveryProfileSchema;
9
- const CreateCheckoutRequestSchema = CheckoutCreateRequestSchema;
10
- const UpdateCheckoutRequestSchema = CheckoutUpdateRequestSchema;
11
- const CompleteCheckoutRequestSchema = CheckoutCompleteRequestSchema;
9
+ const CartResponseSchema = CartSchema$1;
10
+ const CreateCheckoutRequestSchema = CheckoutCreateRequestSchema$1;
11
+ const UpdateCheckoutRequestSchema = CheckoutUpdateRequestSchema$1;
12
+ const CompleteCheckoutRequestSchema = CheckoutCompleteRequestSchema$1;
12
13
  const WebhookEventSchema = z.object({
13
14
  event_id: z.string(),
14
15
  created_time: z.string(),
@@ -30,7 +31,7 @@ var HttpClient = class HttpClient {
30
31
  this.ucpVersion = config.ucpVersion;
31
32
  this.requestSignature = config.requestSignature;
32
33
  this.accessToken = config.accessToken;
33
- this.onValidationWarning = config.onValidationWarning ?? ((msg, detail) => console.warn(msg, detail));
34
+ this.onValidationWarning = config.onValidationWarning ?? (() => void 0);
34
35
  }
35
36
  withAccessToken(token) {
36
37
  return new HttpClient({
@@ -58,7 +59,7 @@ var HttpClient = class HttpClient {
58
59
  headers,
59
60
  ...body !== void 0 ? { body: JSON.stringify(body) } : {}
60
61
  });
61
- const data = await res.json().catch(() => ({}));
62
+ const data = await this.parseResponseBody(res);
62
63
  if (!res.ok) this.throwFromResponse(data, res.status);
63
64
  return data;
64
65
  }
@@ -70,6 +71,18 @@ var HttpClient = class HttpClient {
70
71
  }
71
72
  return result.data;
72
73
  }
74
+ async parseResponseBody(res) {
75
+ if (typeof res.text === "function") {
76
+ const text = await res.text();
77
+ try {
78
+ return JSON.parse(text);
79
+ } catch {
80
+ if (!res.ok) throw new UCPError("HTTP_ERROR", `Gateway returned ${res.status} with non-JSON body: ${text.slice(0, 200)}`, "error", res.status);
81
+ return {};
82
+ }
83
+ }
84
+ return await res.json().catch(() => ({}));
85
+ }
73
86
  throwFromResponse(data, statusCode) {
74
87
  if (typeof data === "object" && data !== null && Array.isArray(data["messages"])) {
75
88
  const rawMessages = data["messages"];
@@ -131,7 +144,7 @@ function parseMessages(rawMessages) {
131
144
  const type = validTypes.includes(rawType) ? rawType : "error";
132
145
  return {
133
146
  type,
134
- content: String(record["content"] ?? "Unknown error"),
147
+ content: String(record["content"] ?? record["text"] ?? record["message"] ?? "Unknown error"),
135
148
  ...record["code"] !== void 0 ? { code: String(record["code"]) } : {}
136
149
  };
137
150
  });
@@ -232,7 +245,7 @@ var OrderCapability = class {
232
245
  /** Retrieve an order by ID. Returns the UCP spec-compliant Order object. */
233
246
  async get(id) {
234
247
  const data = await this.http.request("GET", `/orders/${encodeURIComponent(id)}`);
235
- return this.http.validate(data, OrderSchema);
248
+ return this.http.validate(data, UCPSpecOrderSchema);
236
249
  }
237
250
  /** Update an order with fulfillment events, adjustments, or status changes. */
238
251
  async update(id, payload) {
@@ -246,6 +259,58 @@ var OrderCapability = class {
246
259
  }
247
260
  };
248
261
 
262
+ //#endregion
263
+ //#region src/capabilities/catalog.ts
264
+ /**
265
+ * Catalog operations. Available when the server declares
266
+ * `dev.ucp.shopping.catalog.search` and/or `dev.ucp.shopping.catalog.lookup`.
267
+ */
268
+ var CatalogCapability = class {
269
+ extensions;
270
+ constructor(http, extensions) {
271
+ this.http = http;
272
+ this.extensions = extensions;
273
+ }
274
+ async search(query, filters, pagination) {
275
+ const payload = {
276
+ query,
277
+ ...filters !== void 0 ? { filters } : {},
278
+ ...pagination !== void 0 ? { pagination } : {}
279
+ };
280
+ const data = await this.http.request("POST", "/catalog/search", payload);
281
+ return this.http.validate(data, CatalogSearchSchema);
282
+ }
283
+ async getProduct(productId) {
284
+ const data = await this.http.request("POST", "/catalog/product", { id: productId });
285
+ return this.http.validate(data, CatalogLookupSchema);
286
+ }
287
+ };
288
+
289
+ //#endregion
290
+ //#region src/capabilities/cart.ts
291
+ /** Cart operations. Available when the server declares `dev.ucp.shopping.cart`. */
292
+ var CartCapability = class {
293
+ constructor(http) {
294
+ this.http = http;
295
+ }
296
+ async create(payload) {
297
+ const data = await this.http.request("POST", "/carts", payload);
298
+ return this.http.validate(data, CartResponseSchema);
299
+ }
300
+ async get(id) {
301
+ const data = await this.http.request("GET", `/carts/${encodeURIComponent(id)}`);
302
+ return this.http.validate(data, CartResponseSchema);
303
+ }
304
+ async update(id, payload) {
305
+ const data = await this.http.request("PUT", `/carts/${encodeURIComponent(id)}`, payload);
306
+ return this.http.validate(data, CartResponseSchema);
307
+ }
308
+ async cancel(id) {
309
+ const data = await this.http.request("POST", `/carts/${encodeURIComponent(id)}/cancel`);
310
+ return this.http.validate(data, CartResponseSchema);
311
+ }
312
+ };
313
+
249
314
  //#endregion
250
315
  //#region src/capabilities/identity-linking.ts
251
316
  const TokenResponseSchema = z.object({
@@ -313,8 +378,16 @@ var IdentityLinkingCapability = class {
313
378
  },
314
379
  body: body.toString()
315
380
  });
316
- if (!res.ok) throw new UCPOAuthError(`Token exchange failed with status ${res.status}`, res.status);
317
- const raw = await res.json();
381
+ if (!res.ok) {
382
+ const errorBody = await res.text().catch(() => "");
383
+ throw new UCPOAuthError(`Token exchange failed with status ${res.status}${errorBody ? `: ${errorBody.slice(0, 200)}` : ""}`, res.status);
384
+ }
385
+ let raw;
386
+ try {
387
+ raw = await res.json();
388
+ } catch {
389
+ throw new UCPOAuthError("Token endpoint returned non-JSON response", res.status);
390
+ }
318
391
  const parsed = TokenResponseSchema.safeParse(raw);
319
392
  if (!parsed.success) throw new UCPOAuthError(`Invalid token response: ${parsed.error.message}`, res.status);
320
393
  return parsed.data;
@@ -333,6 +406,9 @@ const UCP_CAPABILITIES = {
333
406
  DISCOUNT: "dev.ucp.shopping.discount",
334
407
  BUYER_CONSENT: "dev.ucp.shopping.buyer_consent",
335
408
  ORDER: "dev.ucp.shopping.order",
409
+ CATALOG_SEARCH: "dev.ucp.shopping.catalog.search",
410
+ CATALOG_LOOKUP: "dev.ucp.shopping.catalog.lookup",
411
+ CART: "dev.ucp.shopping.cart",
336
412
  IDENTITY_LINKING: "dev.ucp.common.identity_linking",
337
413
  AP2_MANDATE: "dev.ucp.shopping.ap2_mandate"
338
414
  };
@@ -381,6 +457,11 @@ function getAgentTools(client) {
381
457
  if (client.checkout.extensions.discount) tools.push(...discountTools(client));
382
458
  }
383
459
  if (client.order) tools.push(...orderTools(client));
460
+ if (client.catalog) {
461
+ if (client.catalog.extensions.search) tools.push(...catalogSearchTools(client));
462
+ if (client.catalog.extensions.lookup) tools.push(...catalogLookupTools(client));
463
+ }
464
+ if (client.cart) tools.push(...cartTools(client));
384
465
  if (client.identityLinking) tools.push(...identityLinkingTools(client));
385
466
  return tools;
386
467
  }
@@ -815,6 +896,180 @@ function orderTools(client) {
815
896
  }
816
897
  ];
817
898
  }
899
+ function catalogSearchTools(client) {
900
+ return [{
901
+ name: "search_catalog",
902
+ description: "Search the product catalog by query. Returns matching products with pagination.",
903
+ parameters: {
904
+ type: "object",
905
+ properties: {
906
+ query: {
907
+ type: "string",
908
+ description: "Search query string"
909
+ },
910
+ filters: {
911
+ type: "object",
912
+ description: "Optional search filters",
913
+ properties: {
914
+ categories: {
915
+ type: "array",
916
+ items: {
917
+ type: "object",
918
+ properties: {
919
+ value: { type: "string" },
920
+ taxonomy: { type: "string" }
921
+ }
922
+ },
923
+ description: "Category filters"
924
+ },
925
+ price: {
926
+ type: "object",
927
+ description: "Price range filter",
928
+ properties: {
929
+ min: { type: "number" },
930
+ max: { type: "number" }
931
+ }
932
+ }
933
+ }
934
+ },
935
+ pagination: {
936
+ type: "object",
937
+ description: "Pagination parameters"
938
+ }
939
+ },
940
+ required: ["query"]
941
+ },
942
+ execute: async (params) => client.catalog.search(params["query"], params["filters"], params["pagination"])
943
+ }];
944
+ }
945
+ function catalogLookupTools(client) {
946
+ return [{
947
+ name: "get_product",
948
+ description: "Get full product details by ID, including variants, pricing, and media.",
949
+ parameters: {
950
+ type: "object",
951
+ properties: { product_id: {
952
+ type: "string",
953
+ description: "Product ID"
954
+ } },
955
+ required: ["product_id"]
956
+ },
957
+ execute: async (params) => client.catalog.getProduct(params["product_id"])
958
+ }];
959
+ }
960
+ function cartTools(client) {
961
+ return [
962
+ {
963
+ name: "create_cart",
964
+ description: "Create a new cart with line items. Returns the cart with an ID for subsequent operations.",
965
+ parameters: {
966
+ type: "object",
967
+ properties: {
968
+ line_items: {
969
+ type: "array",
970
+ description: "Items to add to the cart",
971
+ items: {
972
+ type: "object",
973
+ properties: {
974
+ item: {
975
+ type: "object",
976
+ properties: { id: {
977
+ type: "string",
978
+ description: "Product or variant ID"
979
+ } },
980
+ required: ["id"]
981
+ },
982
+ quantity: {
983
+ type: "number",
984
+ description: "Quantity"
985
+ }
986
+ },
987
+ required: ["item", "quantity"]
988
+ }
989
+ },
990
+ context: {
991
+ type: "object",
992
+ description: "Localization context"
993
+ },
994
+ buyer: {
995
+ type: "object",
996
+ description: "Buyer information"
997
+ }
998
+ },
999
+ required: ["line_items"]
1000
+ },
1001
+ execute: async (params) => client.cart.create(params)
1002
+ },
1003
+ {
1004
+ name: "get_cart",
1005
+ description: "Get the current state of a cart by ID, including line items, totals, and messages.",
1006
+ parameters: {
1007
+ type: "object",
1008
+ properties: { id: {
1009
+ type: "string",
1010
+ description: "Cart ID"
1011
+ } },
1012
+ required: ["id"]
1013
+ },
1014
+ execute: async (params) => client.cart.get(params["id"])
1015
+ },
1016
+ {
1017
+ name: "update_cart",
1018
+ description: "Update an existing cart with changed line items, context, or buyer information.",
1019
+ parameters: {
1020
+ type: "object",
1021
+ properties: {
1022
+ id: {
1023
+ type: "string",
1024
+ description: "Cart ID"
1025
+ },
1026
+ line_items: {
1027
+ type: "array",
1028
+ description: "Updated line items",
1029
+ items: {
1030
+ type: "object",
1031
+ properties: {
1032
+ item: {
1033
+ type: "object",
1034
+ properties: { id: { type: "string" } },
1035
+ required: ["id"]
1036
+ },
1037
+ quantity: { type: "number" }
1038
+ },
1039
+ required: ["item", "quantity"]
1040
+ }
1041
+ },
1042
+ context: {
1043
+ type: "object",
1044
+ description: "Updated localization context"
1045
+ },
1046
+ buyer: {
1047
+ type: "object",
1048
+ description: "Updated buyer information"
1049
+ }
1050
+ },
1051
+ required: ["id"]
1052
+ },
1053
+ execute: async (params) => {
1054
+ const { id,...payload } = params;
1055
+ return client.cart.update(id, payload);
1056
+ }
1057
+ },
1058
+ {
1059
+ name: "cancel_cart",
1060
+ description: "Cancel a cart by ID. Returns the final cart state before cleanup.",
1061
+ parameters: {
1062
+ type: "object",
1063
+ properties: { id: {
1064
+ type: "string",
1065
+ description: "Cart ID"
1066
+ } },
1067
+ required: ["id"]
1068
+ },
1069
+ execute: async (params) => client.cart.cancel(params["id"])
1070
+ }
1071
+ ];
1072
+ }
818
1073
  function identityLinkingTools(client) {
819
1074
  return [
820
1075
  {
@@ -954,6 +1209,8 @@ async function connect(config, options) {
954
1209
  const capabilityNames = extractCapabilityNames(profile);
955
1210
  const checkout = buildCheckoutCapability(http, capabilityNames);
956
1211
  const order = capabilityNames.has(UCP_CAPABILITIES.ORDER) ? new OrderCapability(http) : null;
1212
+ const catalog = buildCatalogCapability(http, capabilityNames);
1213
+ const cart = capabilityNames.has(UCP_CAPABILITIES.CART) ? new CartCapability(http) : null;
957
1214
  const identityLinking = await buildIdentityLinking(config, capabilityNames);
958
1215
  const paymentHandlers = extractPaymentHandlers(profile);
959
1216
  const signingKeys = extractSigningKeys(profile);
@@ -962,9 +1219,11 @@ async function connect(config, options) {
962
1219
  signingKeys,
963
1220
  checkout,
964
1221
  order,
1222
+ catalog,
1223
+ cart,
965
1224
  identityLinking,
966
1225
  paymentHandlers,
967
- describeTools: () => buildToolDescriptors(checkout, order, identityLinking),
1226
+ describeTools: () => buildToolDescriptors(checkout, order, catalog, cart, identityLinking),
968
1227
  getAgentTools: () => getAgentTools(client)
969
1228
  };
970
1229
  return Object.freeze(client);
@@ -974,9 +1233,17 @@ var UCPClient = class {
974
1233
  static connect = connect;
975
1234
  };
976
1235
  function validateConfig(config) {
977
- new URL(config.gatewayUrl);
1236
+ try {
1237
+ new URL(config.gatewayUrl);
1238
+ } catch {
1239
+ throw new Error(`UCPClient: gatewayUrl is not a valid URL: "${config.gatewayUrl}"`);
1240
+ }
978
1241
  if (config.agentProfileUrl.includes("\"") || config.agentProfileUrl.includes("\n")) throw new Error("agentProfileUrl must not contain double quotes or newlines");
979
- new URL(config.agentProfileUrl);
1242
+ try {
1243
+ new URL(config.agentProfileUrl);
1244
+ } catch {
1245
+ throw new Error(`UCPClient: agentProfileUrl is not a valid URL: "${config.agentProfileUrl}"`);
1246
+ }
980
1247
  }
981
1248
  function extractCapabilityNames(profile) {
982
1249
  const capabilities = profile.ucp?.capabilities;
@@ -1011,6 +1278,14 @@ function buildCheckoutCapability(http, capabilityNames) {
1011
1278
  };
1012
1279
  return new CheckoutCapability(http, extensions);
1013
1280
  }
1281
+ function buildCatalogCapability(http, capabilityNames) {
1282
+ const extensions = {
1283
+ search: capabilityNames.has(UCP_CAPABILITIES.CATALOG_SEARCH),
1284
+ lookup: capabilityNames.has(UCP_CAPABILITIES.CATALOG_LOOKUP)
1285
+ };
1286
+ if (!extensions.search && !extensions.lookup) return null;
1287
+ return new CatalogCapability(http, extensions);
1288
+ }
1014
1289
  const OAuthServerMetadataSchema = z.object({
1015
1290
  issuer: z.string(),
1016
1291
  authorization_endpoint: z.string().url(),
@@ -1028,12 +1303,17 @@ async function buildIdentityLinking(config, capabilityNames) {
1028
1303
  const metadataUrl = `${gatewayUrl}/.well-known/oauth-authorization-server`;
1029
1304
  const res = await fetch(metadataUrl);
1030
1305
  if (!res.ok) throw new Error(`Identity linking capability declared but OAuth metadata fetch failed: ${res.status} from ${metadataUrl}`);
1031
- const raw = await res.json();
1306
+ let raw;
1307
+ try {
1308
+ raw = await res.json();
1309
+ } catch {
1310
+ throw new Error(`Identity linking OAuth metadata endpoint returned non-JSON response from ${metadataUrl}`);
1311
+ }
1032
1312
  const parsed = OAuthServerMetadataSchema.safeParse(raw);
1033
1313
  if (!parsed.success) throw new Error(`Identity linking OAuth metadata validation failed: ${parsed.error.message}`);
1034
1314
  return new IdentityLinkingCapability(parsed.data);
1035
1315
  }
1036
- function buildToolDescriptors(checkout, order, identityLinking) {
1316
+ function buildToolDescriptors(checkout, order, catalog, cart, identityLinking) {
1037
1317
  const tools = [];
1038
1318
  if (checkout) {
1039
1319
  tools.push({
@@ -1101,6 +1381,35 @@ function buildToolDescriptors(checkout, order, identityLinking) {
1101
1381
  capability: "order",
1102
1382
  description: "Update a line item within an order"
1103
1383
  });
1384
+ if (catalog) {
1385
+ if (catalog.extensions.search) tools.push({
1386
+ name: "search_catalog",
1387
+ capability: "catalog",
1388
+ description: "Search the product catalog"
1389
+ });
1390
+ if (catalog.extensions.lookup) tools.push({
1391
+ name: "get_product",
1392
+ capability: "catalog",
1393
+ description: "Get product details by ID"
1394
+ });
1395
+ }
1396
+ if (cart) tools.push({
1397
+ name: "create_cart",
1398
+ capability: "cart",
1399
+ description: "Create a new cart"
1400
+ }, {
1401
+ name: "get_cart",
1402
+ capability: "cart",
1403
+ description: "Get cart by ID"
1404
+ }, {
1405
+ name: "update_cart",
1406
+ capability: "cart",
1407
+ description: "Update an existing cart"
1408
+ }, {
1409
+ name: "cancel_cart",
1410
+ capability: "cart",
1411
+ description: "Cancel a cart"
1412
+ });
1104
1413
  if (identityLinking) tools.push({
1105
1414
  name: "get_authorization_url",
1106
1415
  capability: "identity_linking",
@@ -1188,16 +1497,31 @@ async function verifyRequestSignature(body, signature, signingKeys) {
1188
1497
  * if (!valid) return res.status(401).send('Invalid signature');
1189
1498
  * ```
1190
1499
  */
1191
- function createWebhookVerifier(gatewayUrl) {
1500
+ function createWebhookVerifier(gatewayUrl, options) {
1192
1501
  const baseUrl = gatewayUrl.replace(/\/+$/, "");
1502
+ const refetchCooldownMs = options?.refetchCooldownMs ?? 6e4;
1193
1503
  const keyCache = new Map();
1194
1504
  let fetched = false;
1505
+ let lastRefetchTime = 0;
1506
+ let loadingPromise = null;
1195
1507
  async function loadKeys() {
1196
1508
  const res = await fetch(`${baseUrl}/.well-known/ucp`);
1197
- if (!res.ok) return;
1198
- const profile = await res.json();
1509
+ if (!res.ok) {
1510
+ fetched = true;
1511
+ return;
1512
+ }
1513
+ let profile;
1514
+ try {
1515
+ profile = await res.json();
1516
+ } catch {
1517
+ fetched = true;
1518
+ return;
1519
+ }
1199
1520
  const rawKeys = profile["signing_keys"];
1200
- if (!Array.isArray(rawKeys)) return;
1521
+ if (!Array.isArray(rawKeys)) {
1522
+ fetched = true;
1523
+ return;
1524
+ }
1201
1525
  keyCache.clear();
1202
1526
  for (const item of rawKeys) {
1203
1527
  const parsed = UcpSigningKeySchema.safeParse(item);
@@ -1205,11 +1529,23 @@ function createWebhookVerifier(gatewayUrl) {
1205
1529
  }
1206
1530
  fetched = true;
1207
1531
  }
1532
+ function ensureKeys() {
1533
+ loadingPromise ??= loadKeys().finally(() => {
1534
+ loadingPromise = null;
1535
+ });
1536
+ return loadingPromise;
1537
+ }
1208
1538
  return { async verify(body, signature) {
1209
1539
  const kid = extractKid(signature);
1210
1540
  if (kid === null) return false;
1211
- if (!fetched) await loadKeys();
1212
- if (!keyCache.has(kid)) await loadKeys();
1541
+ if (!fetched) await ensureKeys();
1542
+ if (!keyCache.has(kid)) {
1543
+ const now = Date.now();
1544
+ if (now - lastRefetchTime >= refetchCooldownMs) {
1545
+ lastRefetchTime = now;
1546
+ await ensureKeys();
1547
+ }
1548
+ }
1213
1549
  const key = keyCache.get(kid);
1214
1550
  if (!key) return false;
1215
1551
  return verifyRequestSignature(body, signature, [key]);
@@ -1273,5 +1609,5 @@ function parseWebhookEvent(body) {
1273
1609
  }
1274
1610
 
1275
1611
  //#endregion
1276
- export { AccountInfoSchema, AdjustmentSchema, AdjustmentStatusEnumSchema, Ap2MandateAp2WithCheckoutMandateSchema, Ap2MandateAp2WithMerchantAuthorizationSchema, Ap2MandateCheckoutMandateSchema, Ap2MandateErrorCodeSchema, Ap2MandateMerchantAuthorizationSchema, BindingSchema, BusinessFulfillmentConfigSchema, BuyerConsentBuyerSchema, BuyerConsentConsentSchema, BuyerSchema, CapabilityBaseSchema, CapabilityBusinessSchema, CapabilityPlatformSchema, CapabilityResponseSchema, CardCredentialCardNumberTypeEnumSchema, CardCredentialSchema, CardPaymentInstrumentSchema, CheckoutCapability, CheckoutCompleteRequestSchema, CheckoutCreateRequestSchema, CheckoutResponseSchema, CheckoutResponseStatusSchema, CheckoutSchema, CheckoutSessionSchema, CheckoutStatusEnumSchema, CheckoutUpdateRequestSchema, CompleteCheckoutRequestSchema, ContextSchema, CreateCheckoutRequestSchema, DEFAULT_UCP_VERSION, DiscountAllocationSchema, DiscountAppliedDiscountMethodEnumSchema, DiscountAppliedDiscountSchema, DiscountDiscountsObjectSchema, EmbeddedConfigSchema, ExpectationMethodTypeEnumSchema, ExpectationSchema, FulfillmentAvailableMethodSchema, FulfillmentAvailableMethodTypeEnumSchema, FulfillmentDestinationSchema, FulfillmentEventSchema, FulfillmentExtensionFulfillmentAvailableMethodSchema, FulfillmentExtensionFulfillmentGroupSchema, FulfillmentExtensionFulfillmentMethodSchema, FulfillmentExtensionFulfillmentOptionSchema, FulfillmentExtensionFulfillmentSchema, FulfillmentGroupSchema, FulfillmentGroupUpdateRequestSchema, FulfillmentMethodCreateRequestSchema, FulfillmentMethodResponseSchema, FulfillmentMethodSchema, FulfillmentMethodTypeEnumSchema, FulfillmentMethodUpdateRequestSchema, FulfillmentOptionSchema, FulfillmentResponseSchema, FulfillmentSchema, IdentityLinkingCapability, ItemResponseSchema, ItemSchema, UcpSigningKeySchema as JWKSchema, LineItemResponseSchema, LineItemSchema, LineItemUpdateRequestSchema, LinkSchema, MerchantFulfillmentConfigSchema, MessageErrorContentTypeEnumSchema, MessageErrorSchema, MessageErrorSeverityEnumSchema, MessageInfoContentTypeEnumSchema, MessageInfoSchema, MessageSchema, MessageWarningContentTypeEnumSchema, MessageWarningSchema, OrderCapability, OrderConfirmationSchema, OrderLineItemSchema, OrderLineItemStatusEnumSchema, OrderUpdateSchema, PaymentCredentialSchema, PaymentHandlerBaseSchema, PaymentHandlerBusinessSchema, PaymentHandlerPlatformSchema, PaymentHandlerResponseSchema, PaymentIdentitySchema, PaymentInstrumentResponseSchema, PaymentInstrumentSchema, PaymentResponseSchema, PaymentSchema, PlatformFulfillmentConfigSchema, PostalAddressSchema, ProfileSchemaBaseSchema, ProfileSchemaBusinessProfileSchema, ProfileSchemaPlatformProfileSchema, ProfileSchemaSigningKeySchema, ProfileSchemaSigningKeyUseEnumSchema, RetailLocationSchema, ServiceBaseSchema, ServiceBaseTransportEnumSchema, ServiceBusinessSchema, ServicePlatformSchema, ServiceResponseSchema, ShippingDestinationSchema, TokenCredentialSchema, TotalResponseSchema, TotalSchema, TotalTypeEnumSchema, UCPClient, UCPError, UCPEscalationError, UCPIdempotencyConflictError, UCPOAuthError, UCPProfileSchema, OrderSchema as UCPSpecOrderSchema, UCP_CAPABILITIES, UcpBaseSchema, UcpBusinessSchema, UcpDiscoveryBusinessProfileSchema, UcpDiscoveryPlatformProfileSchema, UcpEntitySchema, UcpPlatformSchema, UcpResponseCheckoutSchema, UcpResponseOrderSchema, UcpReverseDomainNameSchema, UcpSigningKeySchema, UcpVersionSchema, UpdateCheckoutRequestSchema, WebhookEventSchema, connect, createWebhookVerifier, getAgentTools, parseWebhookEvent, verifyRequestSignature };
1612
+ export { AccountInfoSchema, AdjustmentSchema, AdjustmentStatusEnumSchema, AmountSchema, Ap2MandateAp2WithCheckoutMandateSchema, Ap2MandateAp2WithMerchantAuthorizationSchema, Ap2MandateCheckoutMandateSchema, Ap2MandateErrorCodeSchema, Ap2MandateMerchantAuthorizationSchema, AvailablePaymentInstrumentSchema, BindingSchema, BusinessFulfillmentConfigSchema, BuyerConsentBuyerSchema, BuyerConsentConsentSchema, BuyerSchema, CapabilityBaseSchema, CapabilityBusinessSchema, CapabilityPlatformSchema, CapabilityResponseSchema, CardCredentialCardNumberTypeEnumSchema, CardCredentialSchema, CardPaymentInstrumentAvailableCardPaymentInstrumentSchema, CartCapability, CartCreateRequestSchema, CartResponseSchema, CartSchema, CartUpdateRequestSchema, CatalogCapability, CatalogLookupSchema, CatalogSearchSchema, CategorySchema, CheckoutCapability, CheckoutCompleteRequestSchema, CheckoutCreateRequestSchema, CheckoutResponseSchema, CheckoutResponseStatusSchema, CheckoutSchema, CheckoutSessionSchema, CheckoutStatusEnumSchema, CheckoutUpdateRequestSchema, CompleteCheckoutRequestSchema, ContextSchema, CreateCheckoutRequestSchema, DEFAULT_UCP_VERSION, DescriptionSchema, DetailOptionValueSchema, DiscountAllocationSchema, DiscountAppliedDiscountMethodEnumSchema, DiscountAppliedDiscountSchema, DiscountDiscountsObjectSchema, EmbeddedConfigSchema, ErrorCodeSchema, ErrorResponseSchema, ExpectationMethodTypeEnumSchema, ExpectationSchema, FulfillmentAvailableMethodSchema, FulfillmentAvailableMethodTypeEnumSchema, FulfillmentDestinationSchema, FulfillmentEventSchema, FulfillmentExtensionFulfillmentAvailableMethodSchema, FulfillmentExtensionFulfillmentGroupSchema, FulfillmentExtensionFulfillmentMethodSchema, FulfillmentExtensionFulfillmentOptionSchema, FulfillmentExtensionFulfillmentSchema, FulfillmentGroupSchema, FulfillmentGroupUpdateRequestSchema, FulfillmentMethodCreateRequestSchema, FulfillmentMethodResponseSchema, FulfillmentMethodSchema, FulfillmentMethodTypeEnumSchema, FulfillmentMethodUpdateRequestSchema, FulfillmentOptionSchema, FulfillmentResponseSchema, FulfillmentSchema, IdentityLinkingCapability, InputCorrelationSchema, ItemResponseSchema, ItemSchema, UcpSigningKeySchema as JWKSchema, LineItemResponseSchema, LineItemSchema, LineItemUpdateRequestSchema, LinkSchema, MediaSchema, MerchantFulfillmentConfigSchema, MessageErrorContentTypeEnumSchema, MessageErrorSchema, MessageErrorSeverityEnumSchema, MessageInfoContentTypeEnumSchema, MessageInfoSchema, MessageSchema, MessageWarningContentTypeEnumSchema, MessageWarningSchema, OptionValueSchema, OrderCapability, OrderConfirmationSchema, OrderLineItemSchema, OrderLineItemStatusEnumSchema, OrderUpdateSchema, PaginationSchema, PaymentCredentialSchema, PaymentHandlerBaseSchema, PaymentHandlerBusinessSchema, PaymentHandlerPlatformSchema, PaymentHandlerResponseSchema, PaymentIdentitySchema, PaymentInstrumentResponseSchema, PaymentInstrumentSchema, PaymentResponseSchema, PaymentSchema, PlatformFulfillmentConfigSchema, PostalAddressSchema, PriceFilterSchema, PriceRangeSchema, PriceSchema, ProductOptionSchema, ProductSchema, ProfileSchemaBaseSchema, ProfileSchemaBusinessProfileSchema, ProfileSchemaPlatformProfileSchema, ProfileSchemaSigningKeySchema, ProfileSchemaSigningKeyUseEnumSchema, RatingSchema, RetailLocationSchema, ReverseDomainNameSchema, SearchFiltersSchema, SelectedOptionSchema, ServiceBaseSchema, ServiceBaseTransportEnumSchema, ServiceBusinessSchema, ServicePlatformSchema, ServiceResponseSchema, ShippingDestinationSchema, SignalsSchema, SignedAmountSchema, TokenCredentialSchema, TotalResponseSchema, TotalSchema, TotalsSchema, UCPClient, UCPError, UCPEscalationError, UCPIdempotencyConflictError, UCPOAuthError, UCPProfileSchema, UCPSpecOrderSchema, UCP_CAPABILITIES, UcpBaseSchema, UcpBaseStatusEnumSchema, UcpBusinessSchema, UcpDiscoveryBusinessProfileSchema, UcpDiscoveryPlatformProfileSchema, UcpEntitySchema, UcpErrorSchema, UcpPlatformSchema, UcpRequiresSchema, UcpResponseCartSchema, UcpResponseCatalogSchema, UcpResponseCheckoutSchema, UcpResponseOrderSchema, UcpSigningKeySchema$1 as UcpSigningKeySchema, UcpSuccessSchema, UcpVersionConstraintSchema, UcpVersionSchema, UpdateCheckoutRequestSchema, VariantSchema, WebhookEventSchema, connect, createWebhookVerifier, getAgentTools, parseWebhookEvent, verifyRequestSignature };
1277
1613
  //# sourceMappingURL=index.js.map