@cimplify/sdk 0.7.5 → 0.7.7

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.
@@ -1,4 +1,4 @@
1
- export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, t as CimplifyElement, s as CimplifyElements, v as ELEMENT_TYPES, E as EVENT_TYPES, z as ElementEventType, x as ElementOptions, y as ElementType, w as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, o as SchedulingService, S as SearchOptions, u as createElements, k as generateIdempotencyKey } from './client-DvoI0EIX.mjs';
1
+ export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, t as CimplifyElement, s as CimplifyElements, v as ELEMENT_TYPES, E as EVENT_TYPES, z as ElementEventType, x as ElementOptions, y as ElementType, w as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, o as SchedulingService, S as SearchOptions, u as createElements, k as generateIdempotencyKey } from './client-DsmJAS8Q.mjs';
2
2
  import './payment-CLIWNMaP.mjs';
3
3
 
4
4
  type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
@@ -1,4 +1,4 @@
1
- export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, t as CimplifyElement, s as CimplifyElements, v as ELEMENT_TYPES, E as EVENT_TYPES, z as ElementEventType, x as ElementOptions, y as ElementType, w as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, o as SchedulingService, S as SearchOptions, u as createElements, k as generateIdempotencyKey } from './client-CIvQ1ZLZ.js';
1
+ export { A as AuthService, B as BusinessService, i as CartOperations, b as CatalogueQueries, j as CheckoutOperations, j as CheckoutService, t as CimplifyElement, s as CimplifyElements, v as ELEMENT_TYPES, E as EVENT_TYPES, z as ElementEventType, x as ElementOptions, y as ElementType, w as ElementsOptions, F as FetchQuoteInput, q as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, p as LiteService, M as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, o as SchedulingService, S as SearchOptions, u as createElements, k as generateIdempotencyKey } from './client-Rr78TLMS.js';
2
2
  import './payment-CLIWNMaP.js';
3
3
 
4
4
  type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
package/dist/advanced.js CHANGED
@@ -2186,6 +2186,12 @@ function toCheckoutError(code, message, recoverable) {
2186
2186
  };
2187
2187
  }
2188
2188
  var DEFAULT_LINK_URL = "https://link.cimplify.io";
2189
+ function generateNonce() {
2190
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
2191
+ return crypto.randomUUID().replace(/-/g, "").slice(0, 16);
2192
+ }
2193
+ return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
2194
+ }
2189
2195
  function isAllowedOrigin(origin) {
2190
2196
  try {
2191
2197
  const url = new URL(origin);
@@ -2560,6 +2566,7 @@ var CimplifyElement = class {
2560
2566
  this.linkUrl = linkUrl;
2561
2567
  this.options = options;
2562
2568
  this.parent = parent;
2569
+ this.nonce = generateNonce();
2563
2570
  this.boundHandleMessage = this.handleMessage.bind(this);
2564
2571
  if (typeof window !== "undefined") {
2565
2572
  window.addEventListener("message", this.boundHandleMessage);
@@ -2646,6 +2653,7 @@ var CimplifyElement = class {
2646
2653
  const iframe = document.createElement("iframe");
2647
2654
  const url = new URL(`${this.linkUrl}/elements/${this.type}`);
2648
2655
  url.searchParams.set("businessId", resolvedBusinessId);
2656
+ url.searchParams.set("nonce", this.nonce);
2649
2657
  if (this.options.prefillEmail) url.searchParams.set("email", this.options.prefillEmail);
2650
2658
  if (this.options.mode) url.searchParams.set("mode", this.options.mode);
2651
2659
  iframe.src = url.toString();
@@ -2681,9 +2689,14 @@ var CimplifyElement = class {
2681
2689
  if (!isAllowedOrigin(event.origin)) {
2682
2690
  return;
2683
2691
  }
2684
- const iframeWindow = this.iframe?.contentWindow;
2685
- if (iframeWindow && event.source && event.source !== iframeWindow) {
2686
- return;
2692
+ const data = event.data;
2693
+ if (data?.nonce) {
2694
+ if (data.nonce !== this.nonce) return;
2695
+ } else {
2696
+ const iframeWindow = this.iframe?.contentWindow;
2697
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
2698
+ return;
2699
+ }
2687
2700
  }
2688
2701
  const message = parseIframeMessage(event.data);
2689
2702
  if (!message) return;
package/dist/advanced.mjs CHANGED
@@ -2184,6 +2184,12 @@ function toCheckoutError(code, message, recoverable) {
2184
2184
  };
2185
2185
  }
2186
2186
  var DEFAULT_LINK_URL = "https://link.cimplify.io";
2187
+ function generateNonce() {
2188
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
2189
+ return crypto.randomUUID().replace(/-/g, "").slice(0, 16);
2190
+ }
2191
+ return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
2192
+ }
2187
2193
  function isAllowedOrigin(origin) {
2188
2194
  try {
2189
2195
  const url = new URL(origin);
@@ -2558,6 +2564,7 @@ var CimplifyElement = class {
2558
2564
  this.linkUrl = linkUrl;
2559
2565
  this.options = options;
2560
2566
  this.parent = parent;
2567
+ this.nonce = generateNonce();
2561
2568
  this.boundHandleMessage = this.handleMessage.bind(this);
2562
2569
  if (typeof window !== "undefined") {
2563
2570
  window.addEventListener("message", this.boundHandleMessage);
@@ -2644,6 +2651,7 @@ var CimplifyElement = class {
2644
2651
  const iframe = document.createElement("iframe");
2645
2652
  const url = new URL(`${this.linkUrl}/elements/${this.type}`);
2646
2653
  url.searchParams.set("businessId", resolvedBusinessId);
2654
+ url.searchParams.set("nonce", this.nonce);
2647
2655
  if (this.options.prefillEmail) url.searchParams.set("email", this.options.prefillEmail);
2648
2656
  if (this.options.mode) url.searchParams.set("mode", this.options.mode);
2649
2657
  iframe.src = url.toString();
@@ -2679,9 +2687,14 @@ var CimplifyElement = class {
2679
2687
  if (!isAllowedOrigin(event.origin)) {
2680
2688
  return;
2681
2689
  }
2682
- const iframeWindow = this.iframe?.contentWindow;
2683
- if (iframeWindow && event.source && event.source !== iframeWindow) {
2684
- return;
2690
+ const data = event.data;
2691
+ if (data?.nonce) {
2692
+ if (data.nonce !== this.nonce) return;
2693
+ } else {
2694
+ const iframeWindow = this.iframe?.contentWindow;
2695
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
2696
+ return;
2697
+ }
2685
2698
  }
2686
2699
  const message = parseIframeMessage(event.data);
2687
2700
  if (!message) return;
@@ -2124,6 +2124,7 @@ declare class CimplifyElement {
2124
2124
  private linkUrl;
2125
2125
  private options;
2126
2126
  private parent;
2127
+ private nonce;
2127
2128
  private iframe;
2128
2129
  private container;
2129
2130
  private mounted;
@@ -2124,6 +2124,7 @@ declare class CimplifyElement {
2124
2124
  private linkUrl;
2125
2125
  private options;
2126
2126
  private parent;
2127
+ private nonce;
2127
2128
  private iframe;
2128
2129
  private container;
2129
2130
  private mounted;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { aa as AUTHORIZATION_TYPE, af as AUTH_MUTATION, $ as AbortablePromise, cc as AddressData, cE as AddressInfo, aP as AmountToPay, cn as AuthResponse, A as AuthService, m as AuthStatus, cG as AuthenticatedCustomer, cI as AuthenticatedData, c0 as AvailabilityCheck, c1 as AvailabilityResult, bF as AvailableSlot, bI as Booking, bH as BookingStatus, bJ as BookingWithDetails, b7 as BufferTimes, bm as Business, bA as BusinessHours, bl as BusinessPreferences, B as BusinessService, bz as BusinessSettings, bk as BusinessType, bx as BusinessWithLocations, a3 as CHECKOUT_MODE, ag as CHECKOUT_MUTATION, a6 as CHECKOUT_STEP, ac as CONTACT_TYPE, bQ as CancelBookingInput, bR as CancelBookingResult, b1 as CancelOrderInput, b9 as CancellationPolicy, i as CartOperations, b as CatalogueQueries, aC as CatalogueResult, aD as CatalogueSnapshot, bB as CategoryInfo, bN as CheckSlotAvailabilityInput, bO as CheckSlotAvailabilityResult, cq as CheckoutAddressInfo, cs as CheckoutCustomerInfo, N as CheckoutFormData, a$ as CheckoutInput, D as CheckoutMode, j as CheckoutOperations, H as CheckoutOrderType, J as CheckoutPaymentMethod, V as CheckoutResult, j as CheckoutService, Z as CheckoutStatus, _ as CheckoutStatusContext, K as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, t as CimplifyElement, s as CimplifyElements, a2 as ContactType, c8 as CreateAddressInput, ca as CreateMobileMoneyInput, c3 as Customer, c4 as CustomerAddress, bL as CustomerBooking, bK as CustomerBookingServiceItem, c6 as CustomerLinkPreferences, c5 as CustomerMobileMoney, b6 as CustomerServicePreferences, ak as DEFAULT_COUNTRY, aj as DEFAULT_CURRENCY, ab as DEVICE_TYPE, bG as DayAvailability, bg as DepositResult, a1 as DeviceType, v as ELEMENT_TYPES, E as EVENT_TYPES, cD as ElementAppearance, cN as ElementEventHandler, z as ElementEventType, x as ElementOptions, y as ElementType, cJ as ElementsCheckoutData, cK as ElementsCheckoutResult, cH as ElementsCustomerInfo, w as ElementsOptions, ce as EnrollAndLinkOrderInput, ch as EnrollAndLinkOrderResult, cb as EnrollmentData, an as Err, aO as FeeBearerType, F as FetchQuoteInput, aM as FulfillmentLink, aL as FulfillmentStatus, aK as FulfillmentType, cu as FxQuote, ct as FxQuoteRequest, cv as FxRateResponse, q as FxService, bM as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, cM as IframeToParentMessage, I as InventoryService, c2 as InventorySummary, ae as LINK_MUTATION, ad as LINK_QUERY, aQ as LineItem, aH as LineType, c7 as LinkData, cg as LinkEnrollResult, L as LinkService, ci as LinkSession, cf as LinkStatusResult, r as LiteBootstrap, p as LiteService, bp as Location, bj as LocationAppointment, b$ as LocationStock, bn as LocationTaxBehavior, bo as LocationTaxOverrides, bs as LocationTimeProfile, by as LocationWithDetails, M as MESSAGE_TYPES, a9 as MOBILE_MONEY_PROVIDER, cd as MobileMoneyData, cr as MobileMoneyDetails, a0 as MobileMoneyProvider, ai as ORDER_MUTATION, a4 as ORDER_TYPE, cC as ObservabilityHooks, am as Ok, aR as Order, aG as OrderChannel, a_ as OrderFilter, aN as OrderFulfillmentSummary, aU as OrderGroup, aY as OrderGroupDetails, aV as OrderGroupPayment, aT as OrderGroupPaymentState, aX as OrderGroupPaymentSummary, aS as OrderHistory, aI as OrderLineState, aJ as OrderLineStatus, aZ as OrderPaymentEvent, O as OrderQueries, aW as OrderSplitDetail, aE as OrderStatus, n as OtpResult, a5 as PAYMENT_METHOD, ah as PAYMENT_MUTATION, a7 as PAYMENT_STATE, a8 as PICKUP_TIME_TYPE, cL as ParentToIframeMessage, cF as PaymentMethodInfo, aF as PaymentState, cp as PickupTime, co as PickupTimeType, P as PriceQuote, bb as PricingOverrides, Y as ProcessAndResolveOptions, W as ProcessCheckoutOptions, X as ProcessCheckoutResult, bZ as ProductStock, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, b2 as RefundOrderInput, b5 as ReminderMethod, b8 as ReminderSettings, cw as RequestContext, cz as RequestErrorEvent, cl as RequestOtpInput, cx as RequestStartEvent, cy as RequestSuccessEvent, bP as RescheduleBookingInput, bS as RescheduleBookingResult, be as ResourceAssignment, al as Result, cA as RetryEvent, ck as RevokeAllSessionsResult, cj as RevokeSessionResult, bu as Room, bc as SchedulingMetadata, bf as SchedulingResult, o as SchedulingService, S as SearchOptions, bC as Service, bT as ServiceAvailabilityParams, bU as ServiceAvailabilityResult, bv as ServiceCharge, ba as ServiceNotes, bh as ServiceScheduleRequest, b3 as ServiceStatus, cB as SessionChangeEvent, bD as Staff, bd as StaffAssignment, b4 as StaffRole, bi as StaffScheduleItem, bX as Stock, bY as StockLevel, bV as StockOwnershipType, bW as StockStatus, bw as StorefrontBootstrap, bt as Table, T as TableInfo, bq as TimeRange, br as TimeRanges, bE as TimeSlot, c9 as UpdateAddressInput, b0 as UpdateOrderStatusInput, U as UpdateProfileInput, b_ as VariantStock, cm as VerifyOtpInput, aA as combine, aB as combineObject, c as createCimplifyClient, u as createElements, ap as err, au as flatMap, ay as fromPromise, k as generateIdempotencyKey, av as getOrElse, ar as isErr, aq as isOk, at as mapError, as as mapResult, ao as ok, ax as toNullable, az as tryCatch, aw as unwrap } from './client-DvoI0EIX.mjs';
1
+ export { aa as AUTHORIZATION_TYPE, af as AUTH_MUTATION, $ as AbortablePromise, cc as AddressData, cE as AddressInfo, aP as AmountToPay, cn as AuthResponse, A as AuthService, m as AuthStatus, cG as AuthenticatedCustomer, cI as AuthenticatedData, c0 as AvailabilityCheck, c1 as AvailabilityResult, bF as AvailableSlot, bI as Booking, bH as BookingStatus, bJ as BookingWithDetails, b7 as BufferTimes, bm as Business, bA as BusinessHours, bl as BusinessPreferences, B as BusinessService, bz as BusinessSettings, bk as BusinessType, bx as BusinessWithLocations, a3 as CHECKOUT_MODE, ag as CHECKOUT_MUTATION, a6 as CHECKOUT_STEP, ac as CONTACT_TYPE, bQ as CancelBookingInput, bR as CancelBookingResult, b1 as CancelOrderInput, b9 as CancellationPolicy, i as CartOperations, b as CatalogueQueries, aC as CatalogueResult, aD as CatalogueSnapshot, bB as CategoryInfo, bN as CheckSlotAvailabilityInput, bO as CheckSlotAvailabilityResult, cq as CheckoutAddressInfo, cs as CheckoutCustomerInfo, N as CheckoutFormData, a$ as CheckoutInput, D as CheckoutMode, j as CheckoutOperations, H as CheckoutOrderType, J as CheckoutPaymentMethod, V as CheckoutResult, j as CheckoutService, Z as CheckoutStatus, _ as CheckoutStatusContext, K as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, t as CimplifyElement, s as CimplifyElements, a2 as ContactType, c8 as CreateAddressInput, ca as CreateMobileMoneyInput, c3 as Customer, c4 as CustomerAddress, bL as CustomerBooking, bK as CustomerBookingServiceItem, c6 as CustomerLinkPreferences, c5 as CustomerMobileMoney, b6 as CustomerServicePreferences, ak as DEFAULT_COUNTRY, aj as DEFAULT_CURRENCY, ab as DEVICE_TYPE, bG as DayAvailability, bg as DepositResult, a1 as DeviceType, v as ELEMENT_TYPES, E as EVENT_TYPES, cD as ElementAppearance, cN as ElementEventHandler, z as ElementEventType, x as ElementOptions, y as ElementType, cJ as ElementsCheckoutData, cK as ElementsCheckoutResult, cH as ElementsCustomerInfo, w as ElementsOptions, ce as EnrollAndLinkOrderInput, ch as EnrollAndLinkOrderResult, cb as EnrollmentData, an as Err, aO as FeeBearerType, F as FetchQuoteInput, aM as FulfillmentLink, aL as FulfillmentStatus, aK as FulfillmentType, cu as FxQuote, ct as FxQuoteRequest, cv as FxRateResponse, q as FxService, bM as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, cM as IframeToParentMessage, I as InventoryService, c2 as InventorySummary, ae as LINK_MUTATION, ad as LINK_QUERY, aQ as LineItem, aH as LineType, c7 as LinkData, cg as LinkEnrollResult, L as LinkService, ci as LinkSession, cf as LinkStatusResult, r as LiteBootstrap, p as LiteService, bp as Location, bj as LocationAppointment, b$ as LocationStock, bn as LocationTaxBehavior, bo as LocationTaxOverrides, bs as LocationTimeProfile, by as LocationWithDetails, M as MESSAGE_TYPES, a9 as MOBILE_MONEY_PROVIDER, cd as MobileMoneyData, cr as MobileMoneyDetails, a0 as MobileMoneyProvider, ai as ORDER_MUTATION, a4 as ORDER_TYPE, cC as ObservabilityHooks, am as Ok, aR as Order, aG as OrderChannel, a_ as OrderFilter, aN as OrderFulfillmentSummary, aU as OrderGroup, aY as OrderGroupDetails, aV as OrderGroupPayment, aT as OrderGroupPaymentState, aX as OrderGroupPaymentSummary, aS as OrderHistory, aI as OrderLineState, aJ as OrderLineStatus, aZ as OrderPaymentEvent, O as OrderQueries, aW as OrderSplitDetail, aE as OrderStatus, n as OtpResult, a5 as PAYMENT_METHOD, ah as PAYMENT_MUTATION, a7 as PAYMENT_STATE, a8 as PICKUP_TIME_TYPE, cL as ParentToIframeMessage, cF as PaymentMethodInfo, aF as PaymentState, cp as PickupTime, co as PickupTimeType, P as PriceQuote, bb as PricingOverrides, Y as ProcessAndResolveOptions, W as ProcessCheckoutOptions, X as ProcessCheckoutResult, bZ as ProductStock, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, b2 as RefundOrderInput, b5 as ReminderMethod, b8 as ReminderSettings, cw as RequestContext, cz as RequestErrorEvent, cl as RequestOtpInput, cx as RequestStartEvent, cy as RequestSuccessEvent, bP as RescheduleBookingInput, bS as RescheduleBookingResult, be as ResourceAssignment, al as Result, cA as RetryEvent, ck as RevokeAllSessionsResult, cj as RevokeSessionResult, bu as Room, bc as SchedulingMetadata, bf as SchedulingResult, o as SchedulingService, S as SearchOptions, bC as Service, bT as ServiceAvailabilityParams, bU as ServiceAvailabilityResult, bv as ServiceCharge, ba as ServiceNotes, bh as ServiceScheduleRequest, b3 as ServiceStatus, cB as SessionChangeEvent, bD as Staff, bd as StaffAssignment, b4 as StaffRole, bi as StaffScheduleItem, bX as Stock, bY as StockLevel, bV as StockOwnershipType, bW as StockStatus, bw as StorefrontBootstrap, bt as Table, T as TableInfo, bq as TimeRange, br as TimeRanges, bE as TimeSlot, c9 as UpdateAddressInput, b0 as UpdateOrderStatusInput, U as UpdateProfileInput, b_ as VariantStock, cm as VerifyOtpInput, aA as combine, aB as combineObject, c as createCimplifyClient, u as createElements, ap as err, au as flatMap, ay as fromPromise, k as generateIdempotencyKey, av as getOrElse, ar as isErr, aq as isOk, at as mapError, as as mapResult, ao as ok, ax as toNullable, az as tryCatch, aw as unwrap } from './client-DsmJAS8Q.mjs';
2
2
  export { QueryBuilder, query } from './advanced.mjs';
3
3
  import { A as ApiError } from './payment-CLIWNMaP.mjs';
4
4
  export { B as AddOn, at as AddOnDetails, aP as AddOnGroupDetails, G as AddOnOption, aO as AddOnOptionDetails, H as AddOnOptionPrice, F as AddOnWithOptions, aU as AddToCartInput, ai as AdjustmentType, ap as AppliedDiscount, a_ as AuthorizationType, ao as BenefitType, T as Bundle, Y as BundleComponentData, _ as BundleComponentInfo, R as BundlePriceType, W as BundleProduct, ay as BundleSelectionData, aw as BundleSelectionInput, ax as BundleStoredSelection, U as BundleSummary, X as BundleWithDetails, aD as Cart, au as CartAddOn, ag as CartChannel, aE as CartItem, aR as CartItemDetails, af as CartStatus, aW as CartSummary, aF as CartTotals, K as Category, L as CategorySummary, an as ChosenPrice, h as CimplifyError, N as Collection, Q as CollectionProduct, O as CollectionSummary, a4 as ComponentGroup, a5 as ComponentGroupWithComponents, a9 as ComponentPriceBreakdown, a7 as ComponentSelectionInput, a1 as ComponentSourceType, a2 as Composite, a6 as CompositeComponent, aA as CompositePriceBreakdown, a8 as CompositePriceResult, $ as CompositePricingMode, aB as CompositeSelectionData, a7 as CompositeSelectionInput, az as CompositeStoredSelection, a3 as CompositeWithDetails, b as Currency, C as CurrencyCode, p as DepositType, D as DigitalProductType, aq as DiscountBreakdown, ar as DiscountDetails, aI as DisplayAddOn, aJ as DisplayAddOnOption, aG as DisplayCart, aH as DisplayCartItem, g as ERROR_HINTS, E as ErrorCode, e as ErrorCodeType, f as ErrorHint, a0 as GroupPricingBehavior, b2 as InitializePaymentResult, I as InventoryType, aC as LineConfiguration, ac as LocationProductPrice, M as Money, d as Pagination, P as PaginationParams, b1 as Payment, b5 as PaymentErrorDetails, b0 as PaymentMethod, aZ as PaymentMethodType, a$ as PaymentProcessingState, aY as PaymentProvider, b3 as PaymentResponse, aX as PaymentStatus, b4 as PaymentStatusResponse, ab as Price, aj as PriceAdjustment, am as PriceDecisionPath, aa as PriceEntryType, al as PricePathTaxInfo, ah as PriceSource, q as Product, J as ProductAddOn, ad as ProductAvailability, o as ProductRenderHint, ae as ProductTimeProfile, n as ProductType, s as ProductVariant, x as ProductVariantValue, r as ProductWithDetails, S as SalesChannel, as as SelectedAddOnOption, b6 as SubmitAuthorizationInput, ak as TaxPathComponent, aS as UICart, aK as UICartBusiness, aM as UICartCustomer, aL as UICartLocation, aN as UICartPricing, aT as UICartResponse, aV as UpdateCartItemInput, u as VariantAxis, z as VariantAxisSelection, w as VariantAxisValue, v as VariantAxisWithValues, av as VariantDetails, aQ as VariantDetailsDTO, t as VariantDisplayAttribute, y as VariantLocationAvailability, V as VariantStrategy, Z as ZERO, c as currencyCode, k as enrichError, j as getErrorHint, i as isCimplifyError, l as isRetryableError, m as money, a as moneyFromNumber } from './payment-CLIWNMaP.mjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { aa as AUTHORIZATION_TYPE, af as AUTH_MUTATION, $ as AbortablePromise, cc as AddressData, cE as AddressInfo, aP as AmountToPay, cn as AuthResponse, A as AuthService, m as AuthStatus, cG as AuthenticatedCustomer, cI as AuthenticatedData, c0 as AvailabilityCheck, c1 as AvailabilityResult, bF as AvailableSlot, bI as Booking, bH as BookingStatus, bJ as BookingWithDetails, b7 as BufferTimes, bm as Business, bA as BusinessHours, bl as BusinessPreferences, B as BusinessService, bz as BusinessSettings, bk as BusinessType, bx as BusinessWithLocations, a3 as CHECKOUT_MODE, ag as CHECKOUT_MUTATION, a6 as CHECKOUT_STEP, ac as CONTACT_TYPE, bQ as CancelBookingInput, bR as CancelBookingResult, b1 as CancelOrderInput, b9 as CancellationPolicy, i as CartOperations, b as CatalogueQueries, aC as CatalogueResult, aD as CatalogueSnapshot, bB as CategoryInfo, bN as CheckSlotAvailabilityInput, bO as CheckSlotAvailabilityResult, cq as CheckoutAddressInfo, cs as CheckoutCustomerInfo, N as CheckoutFormData, a$ as CheckoutInput, D as CheckoutMode, j as CheckoutOperations, H as CheckoutOrderType, J as CheckoutPaymentMethod, V as CheckoutResult, j as CheckoutService, Z as CheckoutStatus, _ as CheckoutStatusContext, K as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, t as CimplifyElement, s as CimplifyElements, a2 as ContactType, c8 as CreateAddressInput, ca as CreateMobileMoneyInput, c3 as Customer, c4 as CustomerAddress, bL as CustomerBooking, bK as CustomerBookingServiceItem, c6 as CustomerLinkPreferences, c5 as CustomerMobileMoney, b6 as CustomerServicePreferences, ak as DEFAULT_COUNTRY, aj as DEFAULT_CURRENCY, ab as DEVICE_TYPE, bG as DayAvailability, bg as DepositResult, a1 as DeviceType, v as ELEMENT_TYPES, E as EVENT_TYPES, cD as ElementAppearance, cN as ElementEventHandler, z as ElementEventType, x as ElementOptions, y as ElementType, cJ as ElementsCheckoutData, cK as ElementsCheckoutResult, cH as ElementsCustomerInfo, w as ElementsOptions, ce as EnrollAndLinkOrderInput, ch as EnrollAndLinkOrderResult, cb as EnrollmentData, an as Err, aO as FeeBearerType, F as FetchQuoteInput, aM as FulfillmentLink, aL as FulfillmentStatus, aK as FulfillmentType, cu as FxQuote, ct as FxQuoteRequest, cv as FxRateResponse, q as FxService, bM as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, cM as IframeToParentMessage, I as InventoryService, c2 as InventorySummary, ae as LINK_MUTATION, ad as LINK_QUERY, aQ as LineItem, aH as LineType, c7 as LinkData, cg as LinkEnrollResult, L as LinkService, ci as LinkSession, cf as LinkStatusResult, r as LiteBootstrap, p as LiteService, bp as Location, bj as LocationAppointment, b$ as LocationStock, bn as LocationTaxBehavior, bo as LocationTaxOverrides, bs as LocationTimeProfile, by as LocationWithDetails, M as MESSAGE_TYPES, a9 as MOBILE_MONEY_PROVIDER, cd as MobileMoneyData, cr as MobileMoneyDetails, a0 as MobileMoneyProvider, ai as ORDER_MUTATION, a4 as ORDER_TYPE, cC as ObservabilityHooks, am as Ok, aR as Order, aG as OrderChannel, a_ as OrderFilter, aN as OrderFulfillmentSummary, aU as OrderGroup, aY as OrderGroupDetails, aV as OrderGroupPayment, aT as OrderGroupPaymentState, aX as OrderGroupPaymentSummary, aS as OrderHistory, aI as OrderLineState, aJ as OrderLineStatus, aZ as OrderPaymentEvent, O as OrderQueries, aW as OrderSplitDetail, aE as OrderStatus, n as OtpResult, a5 as PAYMENT_METHOD, ah as PAYMENT_MUTATION, a7 as PAYMENT_STATE, a8 as PICKUP_TIME_TYPE, cL as ParentToIframeMessage, cF as PaymentMethodInfo, aF as PaymentState, cp as PickupTime, co as PickupTimeType, P as PriceQuote, bb as PricingOverrides, Y as ProcessAndResolveOptions, W as ProcessCheckoutOptions, X as ProcessCheckoutResult, bZ as ProductStock, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, b2 as RefundOrderInput, b5 as ReminderMethod, b8 as ReminderSettings, cw as RequestContext, cz as RequestErrorEvent, cl as RequestOtpInput, cx as RequestStartEvent, cy as RequestSuccessEvent, bP as RescheduleBookingInput, bS as RescheduleBookingResult, be as ResourceAssignment, al as Result, cA as RetryEvent, ck as RevokeAllSessionsResult, cj as RevokeSessionResult, bu as Room, bc as SchedulingMetadata, bf as SchedulingResult, o as SchedulingService, S as SearchOptions, bC as Service, bT as ServiceAvailabilityParams, bU as ServiceAvailabilityResult, bv as ServiceCharge, ba as ServiceNotes, bh as ServiceScheduleRequest, b3 as ServiceStatus, cB as SessionChangeEvent, bD as Staff, bd as StaffAssignment, b4 as StaffRole, bi as StaffScheduleItem, bX as Stock, bY as StockLevel, bV as StockOwnershipType, bW as StockStatus, bw as StorefrontBootstrap, bt as Table, T as TableInfo, bq as TimeRange, br as TimeRanges, bE as TimeSlot, c9 as UpdateAddressInput, b0 as UpdateOrderStatusInput, U as UpdateProfileInput, b_ as VariantStock, cm as VerifyOtpInput, aA as combine, aB as combineObject, c as createCimplifyClient, u as createElements, ap as err, au as flatMap, ay as fromPromise, k as generateIdempotencyKey, av as getOrElse, ar as isErr, aq as isOk, at as mapError, as as mapResult, ao as ok, ax as toNullable, az as tryCatch, aw as unwrap } from './client-CIvQ1ZLZ.js';
1
+ export { aa as AUTHORIZATION_TYPE, af as AUTH_MUTATION, $ as AbortablePromise, cc as AddressData, cE as AddressInfo, aP as AmountToPay, cn as AuthResponse, A as AuthService, m as AuthStatus, cG as AuthenticatedCustomer, cI as AuthenticatedData, c0 as AvailabilityCheck, c1 as AvailabilityResult, bF as AvailableSlot, bI as Booking, bH as BookingStatus, bJ as BookingWithDetails, b7 as BufferTimes, bm as Business, bA as BusinessHours, bl as BusinessPreferences, B as BusinessService, bz as BusinessSettings, bk as BusinessType, bx as BusinessWithLocations, a3 as CHECKOUT_MODE, ag as CHECKOUT_MUTATION, a6 as CHECKOUT_STEP, ac as CONTACT_TYPE, bQ as CancelBookingInput, bR as CancelBookingResult, b1 as CancelOrderInput, b9 as CancellationPolicy, i as CartOperations, b as CatalogueQueries, aC as CatalogueResult, aD as CatalogueSnapshot, bB as CategoryInfo, bN as CheckSlotAvailabilityInput, bO as CheckSlotAvailabilityResult, cq as CheckoutAddressInfo, cs as CheckoutCustomerInfo, N as CheckoutFormData, a$ as CheckoutInput, D as CheckoutMode, j as CheckoutOperations, H as CheckoutOrderType, J as CheckoutPaymentMethod, V as CheckoutResult, j as CheckoutService, Z as CheckoutStatus, _ as CheckoutStatusContext, K as CheckoutStep, C as CimplifyClient, a as CimplifyConfig, t as CimplifyElement, s as CimplifyElements, a2 as ContactType, c8 as CreateAddressInput, ca as CreateMobileMoneyInput, c3 as Customer, c4 as CustomerAddress, bL as CustomerBooking, bK as CustomerBookingServiceItem, c6 as CustomerLinkPreferences, c5 as CustomerMobileMoney, b6 as CustomerServicePreferences, ak as DEFAULT_COUNTRY, aj as DEFAULT_CURRENCY, ab as DEVICE_TYPE, bG as DayAvailability, bg as DepositResult, a1 as DeviceType, v as ELEMENT_TYPES, E as EVENT_TYPES, cD as ElementAppearance, cN as ElementEventHandler, z as ElementEventType, x as ElementOptions, y as ElementType, cJ as ElementsCheckoutData, cK as ElementsCheckoutResult, cH as ElementsCustomerInfo, w as ElementsOptions, ce as EnrollAndLinkOrderInput, ch as EnrollAndLinkOrderResult, cb as EnrollmentData, an as Err, aO as FeeBearerType, F as FetchQuoteInput, aM as FulfillmentLink, aL as FulfillmentStatus, aK as FulfillmentType, cu as FxQuote, ct as FxQuoteRequest, cv as FxRateResponse, q as FxService, bM as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, cM as IframeToParentMessage, I as InventoryService, c2 as InventorySummary, ae as LINK_MUTATION, ad as LINK_QUERY, aQ as LineItem, aH as LineType, c7 as LinkData, cg as LinkEnrollResult, L as LinkService, ci as LinkSession, cf as LinkStatusResult, r as LiteBootstrap, p as LiteService, bp as Location, bj as LocationAppointment, b$ as LocationStock, bn as LocationTaxBehavior, bo as LocationTaxOverrides, bs as LocationTimeProfile, by as LocationWithDetails, M as MESSAGE_TYPES, a9 as MOBILE_MONEY_PROVIDER, cd as MobileMoneyData, cr as MobileMoneyDetails, a0 as MobileMoneyProvider, ai as ORDER_MUTATION, a4 as ORDER_TYPE, cC as ObservabilityHooks, am as Ok, aR as Order, aG as OrderChannel, a_ as OrderFilter, aN as OrderFulfillmentSummary, aU as OrderGroup, aY as OrderGroupDetails, aV as OrderGroupPayment, aT as OrderGroupPaymentState, aX as OrderGroupPaymentSummary, aS as OrderHistory, aI as OrderLineState, aJ as OrderLineStatus, aZ as OrderPaymentEvent, O as OrderQueries, aW as OrderSplitDetail, aE as OrderStatus, n as OtpResult, a5 as PAYMENT_METHOD, ah as PAYMENT_MUTATION, a7 as PAYMENT_STATE, a8 as PICKUP_TIME_TYPE, cL as ParentToIframeMessage, cF as PaymentMethodInfo, aF as PaymentState, cp as PickupTime, co as PickupTimeType, P as PriceQuote, bb as PricingOverrides, Y as ProcessAndResolveOptions, W as ProcessCheckoutOptions, X as ProcessCheckoutResult, bZ as ProductStock, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, b2 as RefundOrderInput, b5 as ReminderMethod, b8 as ReminderSettings, cw as RequestContext, cz as RequestErrorEvent, cl as RequestOtpInput, cx as RequestStartEvent, cy as RequestSuccessEvent, bP as RescheduleBookingInput, bS as RescheduleBookingResult, be as ResourceAssignment, al as Result, cA as RetryEvent, ck as RevokeAllSessionsResult, cj as RevokeSessionResult, bu as Room, bc as SchedulingMetadata, bf as SchedulingResult, o as SchedulingService, S as SearchOptions, bC as Service, bT as ServiceAvailabilityParams, bU as ServiceAvailabilityResult, bv as ServiceCharge, ba as ServiceNotes, bh as ServiceScheduleRequest, b3 as ServiceStatus, cB as SessionChangeEvent, bD as Staff, bd as StaffAssignment, b4 as StaffRole, bi as StaffScheduleItem, bX as Stock, bY as StockLevel, bV as StockOwnershipType, bW as StockStatus, bw as StorefrontBootstrap, bt as Table, T as TableInfo, bq as TimeRange, br as TimeRanges, bE as TimeSlot, c9 as UpdateAddressInput, b0 as UpdateOrderStatusInput, U as UpdateProfileInput, b_ as VariantStock, cm as VerifyOtpInput, aA as combine, aB as combineObject, c as createCimplifyClient, u as createElements, ap as err, au as flatMap, ay as fromPromise, k as generateIdempotencyKey, av as getOrElse, ar as isErr, aq as isOk, at as mapError, as as mapResult, ao as ok, ax as toNullable, az as tryCatch, aw as unwrap } from './client-Rr78TLMS.js';
2
2
  export { QueryBuilder, query } from './advanced.js';
3
3
  import { A as ApiError } from './payment-CLIWNMaP.js';
4
4
  export { B as AddOn, at as AddOnDetails, aP as AddOnGroupDetails, G as AddOnOption, aO as AddOnOptionDetails, H as AddOnOptionPrice, F as AddOnWithOptions, aU as AddToCartInput, ai as AdjustmentType, ap as AppliedDiscount, a_ as AuthorizationType, ao as BenefitType, T as Bundle, Y as BundleComponentData, _ as BundleComponentInfo, R as BundlePriceType, W as BundleProduct, ay as BundleSelectionData, aw as BundleSelectionInput, ax as BundleStoredSelection, U as BundleSummary, X as BundleWithDetails, aD as Cart, au as CartAddOn, ag as CartChannel, aE as CartItem, aR as CartItemDetails, af as CartStatus, aW as CartSummary, aF as CartTotals, K as Category, L as CategorySummary, an as ChosenPrice, h as CimplifyError, N as Collection, Q as CollectionProduct, O as CollectionSummary, a4 as ComponentGroup, a5 as ComponentGroupWithComponents, a9 as ComponentPriceBreakdown, a7 as ComponentSelectionInput, a1 as ComponentSourceType, a2 as Composite, a6 as CompositeComponent, aA as CompositePriceBreakdown, a8 as CompositePriceResult, $ as CompositePricingMode, aB as CompositeSelectionData, a7 as CompositeSelectionInput, az as CompositeStoredSelection, a3 as CompositeWithDetails, b as Currency, C as CurrencyCode, p as DepositType, D as DigitalProductType, aq as DiscountBreakdown, ar as DiscountDetails, aI as DisplayAddOn, aJ as DisplayAddOnOption, aG as DisplayCart, aH as DisplayCartItem, g as ERROR_HINTS, E as ErrorCode, e as ErrorCodeType, f as ErrorHint, a0 as GroupPricingBehavior, b2 as InitializePaymentResult, I as InventoryType, aC as LineConfiguration, ac as LocationProductPrice, M as Money, d as Pagination, P as PaginationParams, b1 as Payment, b5 as PaymentErrorDetails, b0 as PaymentMethod, aZ as PaymentMethodType, a$ as PaymentProcessingState, aY as PaymentProvider, b3 as PaymentResponse, aX as PaymentStatus, b4 as PaymentStatusResponse, ab as Price, aj as PriceAdjustment, am as PriceDecisionPath, aa as PriceEntryType, al as PricePathTaxInfo, ah as PriceSource, q as Product, J as ProductAddOn, ad as ProductAvailability, o as ProductRenderHint, ae as ProductTimeProfile, n as ProductType, s as ProductVariant, x as ProductVariantValue, r as ProductWithDetails, S as SalesChannel, as as SelectedAddOnOption, b6 as SubmitAuthorizationInput, ak as TaxPathComponent, aS as UICart, aK as UICartBusiness, aM as UICartCustomer, aL as UICartLocation, aN as UICartPricing, aT as UICartResponse, aV as UpdateCartItemInput, u as VariantAxis, z as VariantAxisSelection, w as VariantAxisValue, v as VariantAxisWithValues, av as VariantDetails, aQ as VariantDetailsDTO, t as VariantDisplayAttribute, y as VariantLocationAvailability, V as VariantStrategy, Z as ZERO, c as currencyCode, k as enrichError, j as getErrorHint, i as isCimplifyError, l as isRetryableError, m as money, a as moneyFromNumber } from './payment-CLIWNMaP.js';
package/dist/index.js CHANGED
@@ -2634,6 +2634,12 @@ function toCheckoutError(code, message, recoverable) {
2634
2634
  };
2635
2635
  }
2636
2636
  var DEFAULT_LINK_URL = "https://link.cimplify.io";
2637
+ function generateNonce() {
2638
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
2639
+ return crypto.randomUUID().replace(/-/g, "").slice(0, 16);
2640
+ }
2641
+ return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
2642
+ }
2637
2643
  function isAllowedOrigin(origin) {
2638
2644
  try {
2639
2645
  const url = new URL(origin);
@@ -3008,6 +3014,7 @@ var CimplifyElement = class {
3008
3014
  this.linkUrl = linkUrl;
3009
3015
  this.options = options;
3010
3016
  this.parent = parent;
3017
+ this.nonce = generateNonce();
3011
3018
  this.boundHandleMessage = this.handleMessage.bind(this);
3012
3019
  if (typeof window !== "undefined") {
3013
3020
  window.addEventListener("message", this.boundHandleMessage);
@@ -3094,6 +3101,7 @@ var CimplifyElement = class {
3094
3101
  const iframe = document.createElement("iframe");
3095
3102
  const url = new URL(`${this.linkUrl}/elements/${this.type}`);
3096
3103
  url.searchParams.set("businessId", resolvedBusinessId);
3104
+ url.searchParams.set("nonce", this.nonce);
3097
3105
  if (this.options.prefillEmail) url.searchParams.set("email", this.options.prefillEmail);
3098
3106
  if (this.options.mode) url.searchParams.set("mode", this.options.mode);
3099
3107
  iframe.src = url.toString();
@@ -3129,9 +3137,14 @@ var CimplifyElement = class {
3129
3137
  if (!isAllowedOrigin(event.origin)) {
3130
3138
  return;
3131
3139
  }
3132
- const iframeWindow = this.iframe?.contentWindow;
3133
- if (iframeWindow && event.source && event.source !== iframeWindow) {
3134
- return;
3140
+ const data = event.data;
3141
+ if (data?.nonce) {
3142
+ if (data.nonce !== this.nonce) return;
3143
+ } else {
3144
+ const iframeWindow = this.iframe?.contentWindow;
3145
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
3146
+ return;
3147
+ }
3135
3148
  }
3136
3149
  const message = parseIframeMessage(event.data);
3137
3150
  if (!message) return;
package/dist/index.mjs CHANGED
@@ -2632,6 +2632,12 @@ function toCheckoutError(code, message, recoverable) {
2632
2632
  };
2633
2633
  }
2634
2634
  var DEFAULT_LINK_URL = "https://link.cimplify.io";
2635
+ function generateNonce() {
2636
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
2637
+ return crypto.randomUUID().replace(/-/g, "").slice(0, 16);
2638
+ }
2639
+ return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
2640
+ }
2635
2641
  function isAllowedOrigin(origin) {
2636
2642
  try {
2637
2643
  const url = new URL(origin);
@@ -3006,6 +3012,7 @@ var CimplifyElement = class {
3006
3012
  this.linkUrl = linkUrl;
3007
3013
  this.options = options;
3008
3014
  this.parent = parent;
3015
+ this.nonce = generateNonce();
3009
3016
  this.boundHandleMessage = this.handleMessage.bind(this);
3010
3017
  if (typeof window !== "undefined") {
3011
3018
  window.addEventListener("message", this.boundHandleMessage);
@@ -3092,6 +3099,7 @@ var CimplifyElement = class {
3092
3099
  const iframe = document.createElement("iframe");
3093
3100
  const url = new URL(`${this.linkUrl}/elements/${this.type}`);
3094
3101
  url.searchParams.set("businessId", resolvedBusinessId);
3102
+ url.searchParams.set("nonce", this.nonce);
3095
3103
  if (this.options.prefillEmail) url.searchParams.set("email", this.options.prefillEmail);
3096
3104
  if (this.options.mode) url.searchParams.set("mode", this.options.mode);
3097
3105
  iframe.src = url.toString();
@@ -3127,9 +3135,14 @@ var CimplifyElement = class {
3127
3135
  if (!isAllowedOrigin(event.origin)) {
3128
3136
  return;
3129
3137
  }
3130
- const iframeWindow = this.iframe?.contentWindow;
3131
- if (iframeWindow && event.source && event.source !== iframeWindow) {
3132
- return;
3138
+ const data = event.data;
3139
+ if (data?.nonce) {
3140
+ if (data.nonce !== this.nonce) return;
3141
+ } else {
3142
+ const iframeWindow = this.iframe?.contentWindow;
3143
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
3144
+ return;
3145
+ }
3133
3146
  }
3134
3147
  const message = parseIframeMessage(event.data);
3135
3148
  if (!message) return;
package/dist/react.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CimplifyClient, X as ProcessCheckoutResult, Z as CheckoutStatus, _ as CheckoutStatusContext, bp as Location, bm as Business, aR as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, s as CimplifyElements, w as ElementsOptions, cI as AuthenticatedData, cE as AddressInfo, cF as PaymentMethodInfo, cK as ElementsCheckoutResult, W as ProcessCheckoutOptions } from './client-DvoI0EIX.mjs';
1
+ import { C as CimplifyClient, X as ProcessCheckoutResult, Z as CheckoutStatus, _ as CheckoutStatusContext, bp as Location, bm as Business, aR as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, s as CimplifyElements, w as ElementsOptions, cI as AuthenticatedData, cE as AddressInfo, cF as PaymentMethodInfo, cK as ElementsCheckoutResult, W as ProcessCheckoutOptions } from './client-DsmJAS8Q.mjs';
2
2
  import React, { ReactNode } from 'react';
3
3
  import { q as Product, d as Pagination, h as CimplifyError, r as ProductWithDetails, K as Category, aw as BundleSelectionInput, a7 as ComponentSelectionInput, N as Collection, X as BundleWithDetails, a3 as CompositeWithDetails, a8 as CompositePriceResult, C as CurrencyCode } from './payment-CLIWNMaP.mjs';
4
4
  import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-t3FBTU8p.mjs';
@@ -55,6 +55,7 @@ interface CimplifyCheckoutProps {
55
55
  businessId?: string;
56
56
  cartId?: string;
57
57
  locationId?: string;
58
+ linkUrl?: string;
58
59
  orderTypes?: CheckoutOrderType[];
59
60
  enrollInLink?: boolean;
60
61
  onComplete: (result: ProcessCheckoutResult) => void;
@@ -74,7 +75,7 @@ interface CimplifyCheckoutProps {
74
75
  demoMode?: boolean;
75
76
  className?: string;
76
77
  }
77
- declare function CimplifyCheckout({ client, businessId, cartId, locationId, orderTypes, enrollInLink, onComplete, onError, onStatusChange, appearance, demoMode, className, }: CimplifyCheckoutProps): React.ReactElement;
78
+ declare function CimplifyCheckout({ client, businessId, cartId, locationId, linkUrl, orderTypes, enrollInLink, onComplete, onError, onStatusChange, appearance, demoMode, className, }: CimplifyCheckoutProps): React.ReactElement;
78
79
 
79
80
  interface CimplifyContextValue {
80
81
  client: CimplifyClient;
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CimplifyClient, X as ProcessCheckoutResult, Z as CheckoutStatus, _ as CheckoutStatusContext, bp as Location, bm as Business, aR as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, s as CimplifyElements, w as ElementsOptions, cI as AuthenticatedData, cE as AddressInfo, cF as PaymentMethodInfo, cK as ElementsCheckoutResult, W as ProcessCheckoutOptions } from './client-CIvQ1ZLZ.js';
1
+ import { C as CimplifyClient, X as ProcessCheckoutResult, Z as CheckoutStatus, _ as CheckoutStatusContext, bp as Location, bm as Business, aR as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, s as CimplifyElements, w as ElementsOptions, cI as AuthenticatedData, cE as AddressInfo, cF as PaymentMethodInfo, cK as ElementsCheckoutResult, W as ProcessCheckoutOptions } from './client-Rr78TLMS.js';
2
2
  import React, { ReactNode } from 'react';
3
3
  import { q as Product, d as Pagination, h as CimplifyError, r as ProductWithDetails, K as Category, aw as BundleSelectionInput, a7 as ComponentSelectionInput, N as Collection, X as BundleWithDetails, a3 as CompositeWithDetails, a8 as CompositePriceResult, C as CurrencyCode } from './payment-CLIWNMaP.js';
4
4
  import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-t3FBTU8p.js';
@@ -55,6 +55,7 @@ interface CimplifyCheckoutProps {
55
55
  businessId?: string;
56
56
  cartId?: string;
57
57
  locationId?: string;
58
+ linkUrl?: string;
58
59
  orderTypes?: CheckoutOrderType[];
59
60
  enrollInLink?: boolean;
60
61
  onComplete: (result: ProcessCheckoutResult) => void;
@@ -74,7 +75,7 @@ interface CimplifyCheckoutProps {
74
75
  demoMode?: boolean;
75
76
  className?: string;
76
77
  }
77
- declare function CimplifyCheckout({ client, businessId, cartId, locationId, orderTypes, enrollInLink, onComplete, onError, onStatusChange, appearance, demoMode, className, }: CimplifyCheckoutProps): React.ReactElement;
78
+ declare function CimplifyCheckout({ client, businessId, cartId, locationId, linkUrl, orderTypes, enrollInLink, onComplete, onError, onStatusChange, appearance, demoMode, className, }: CimplifyCheckoutProps): React.ReactElement;
78
79
 
79
80
  interface CimplifyContextValue {
80
81
  client: CimplifyClient;
package/dist/react.js CHANGED
@@ -379,6 +379,7 @@ function CimplifyCheckout({
379
379
  businessId,
380
380
  cartId,
381
381
  locationId,
382
+ linkUrl,
382
383
  orderTypes,
383
384
  enrollInLink = true,
384
385
  onComplete,
@@ -411,6 +412,8 @@ function CimplifyCheckout({
411
412
  const demoRunRef = react.useRef(0);
412
413
  const isDemoCheckout = demoMode ?? client.getPublicKey().trim().length === 0;
413
414
  const isTestMode = client.isTestMode();
415
+ const primaryColor = appearance?.variables?.primaryColor || "#0a2540";
416
+ const isDark = appearance?.theme === "dark";
414
417
  const emitStatus = react.useCallback(
415
418
  (nextStatus, context = {}) => {
416
419
  setStatus(nextStatus);
@@ -517,7 +520,8 @@ function CimplifyCheckout({
517
520
  return;
518
521
  }
519
522
  const elements = client.elements(resolvedBusinessId, {
520
- appearance: initialAppearanceRef.current
523
+ appearance: initialAppearanceRef.current,
524
+ linkUrl
521
525
  });
522
526
  elementsRef.current = elements;
523
527
  const auth = elements.create("auth");
@@ -652,44 +656,53 @@ function CimplifyCheckout({
652
656
  }
653
657
  ),
654
658
  /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-section": "auth", children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: isDemoCheckout ? void 0 : authMountRef }) }),
655
- /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-section": "order-type", style: { marginTop: "12px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
656
- "div",
657
- {
658
- role: "group",
659
- "aria-label": "Order type",
660
- style: { display: "flex", gap: "8px", flexWrap: "wrap" },
661
- children: resolvedOrderTypes.map((type) => /* @__PURE__ */ jsxRuntime.jsx(
662
- "button",
663
- {
664
- type: "button",
665
- onClick: () => setOrderType(type),
666
- disabled: isSubmitting,
667
- "data-selected": orderType === type ? "true" : "false",
668
- style: {
669
- padding: "8px 12px",
670
- borderRadius: "8px",
671
- border: "1px solid #d4d4d8",
672
- background: orderType === type ? "#111827" : "#ffffff",
673
- color: orderType === type ? "#ffffff" : "#111827",
674
- cursor: isSubmitting ? "not-allowed" : "pointer",
675
- opacity: isSubmitting ? 0.6 : 1
659
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-section": "order-type", style: { marginTop: "20px" }, children: [
660
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "13px", fontWeight: 500, color: isDark ? "#a1a1aa" : "#71717a", marginBottom: "8px" }, children: "Order type" }),
661
+ /* @__PURE__ */ jsxRuntime.jsx(
662
+ "div",
663
+ {
664
+ role: "group",
665
+ "aria-label": "Order type",
666
+ style: { display: "flex", gap: "8px", flexWrap: "wrap" },
667
+ children: resolvedOrderTypes.map((type) => /* @__PURE__ */ jsxRuntime.jsx(
668
+ "button",
669
+ {
670
+ type: "button",
671
+ onClick: () => setOrderType(type),
672
+ disabled: isSubmitting,
673
+ "data-selected": orderType === type ? "true" : "false",
674
+ style: {
675
+ padding: "8px 14px",
676
+ borderRadius: "8px",
677
+ border: orderType === type ? "1px solid transparent" : `1px solid ${isDark ? "#3f3f46" : "#d4d4d8"}`,
678
+ background: orderType === type ? primaryColor : "transparent",
679
+ color: orderType === type ? "#ffffff" : isDark ? "#e4e4e7" : "#3f3f46",
680
+ cursor: isSubmitting ? "not-allowed" : "pointer",
681
+ opacity: isSubmitting ? 0.6 : 1,
682
+ fontSize: "14px",
683
+ fontWeight: 500,
684
+ transition: "all 150ms ease"
685
+ },
686
+ children: labelForOrderType(type)
676
687
  },
677
- children: labelForOrderType(type)
678
- },
679
- type
680
- ))
681
- }
682
- ) }),
688
+ type
689
+ ))
690
+ }
691
+ )
692
+ ] }),
683
693
  /* @__PURE__ */ jsxRuntime.jsx(
684
694
  "div",
685
695
  {
686
696
  "data-cimplify-section": "address",
687
- style: { marginTop: "12px", display: orderType === "delivery" ? "block" : "none" },
697
+ style: { marginTop: "16px", display: orderType === "delivery" ? "block" : "none" },
688
698
  children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: isDemoCheckout ? void 0 : addressMountRef })
689
699
  }
690
700
  ),
691
- /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-section": "payment", style: { marginTop: "12px" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: isDemoCheckout ? void 0 : paymentMountRef }) }),
692
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: "12px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
701
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-section": "payment", style: { marginTop: "20px" }, children: [
702
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "13px", fontWeight: 500, color: isDark ? "#a1a1aa" : "#71717a", marginBottom: "8px" }, children: "Payment method" }),
703
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: isDemoCheckout ? void 0 : paymentMountRef })
704
+ ] }),
705
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: "24px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
693
706
  "button",
694
707
  {
695
708
  type: "button",
@@ -697,12 +710,16 @@ function CimplifyCheckout({
697
710
  disabled: isSubmitting,
698
711
  style: {
699
712
  width: "100%",
700
- padding: "10px 14px",
713
+ padding: "12px 16px",
701
714
  borderRadius: "8px",
702
715
  border: "none",
703
- background: isSubmitting ? "#a1a1aa" : "#111827",
716
+ background: isSubmitting ? "#a1a1aa" : primaryColor,
704
717
  color: "#ffffff",
705
- cursor: isSubmitting ? "not-allowed" : "pointer"
718
+ cursor: isSubmitting ? "not-allowed" : "pointer",
719
+ fontWeight: 600,
720
+ fontSize: "15px",
721
+ boxShadow: isSubmitting ? "none" : "0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1)",
722
+ transition: "all 150ms ease"
706
723
  },
707
724
  children: isSubmitting ? "Processing..." : "Complete Order"
708
725
  }
@@ -2875,6 +2892,12 @@ function toCheckoutError(code, message, recoverable) {
2875
2892
  };
2876
2893
  }
2877
2894
  var DEFAULT_LINK_URL = "https://link.cimplify.io";
2895
+ function generateNonce() {
2896
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
2897
+ return crypto.randomUUID().replace(/-/g, "").slice(0, 16);
2898
+ }
2899
+ return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
2900
+ }
2878
2901
  function isAllowedOrigin(origin) {
2879
2902
  try {
2880
2903
  const url = new URL(origin);
@@ -3249,6 +3272,7 @@ var CimplifyElement = class {
3249
3272
  this.linkUrl = linkUrl;
3250
3273
  this.options = options;
3251
3274
  this.parent = parent;
3275
+ this.nonce = generateNonce();
3252
3276
  this.boundHandleMessage = this.handleMessage.bind(this);
3253
3277
  if (typeof window !== "undefined") {
3254
3278
  window.addEventListener("message", this.boundHandleMessage);
@@ -3335,6 +3359,7 @@ var CimplifyElement = class {
3335
3359
  const iframe = document.createElement("iframe");
3336
3360
  const url = new URL(`${this.linkUrl}/elements/${this.type}`);
3337
3361
  url.searchParams.set("businessId", resolvedBusinessId);
3362
+ url.searchParams.set("nonce", this.nonce);
3338
3363
  if (this.options.prefillEmail) url.searchParams.set("email", this.options.prefillEmail);
3339
3364
  if (this.options.mode) url.searchParams.set("mode", this.options.mode);
3340
3365
  iframe.src = url.toString();
@@ -3370,9 +3395,14 @@ var CimplifyElement = class {
3370
3395
  if (!isAllowedOrigin(event.origin)) {
3371
3396
  return;
3372
3397
  }
3373
- const iframeWindow = this.iframe?.contentWindow;
3374
- if (iframeWindow && event.source && event.source !== iframeWindow) {
3375
- return;
3398
+ const data = event.data;
3399
+ if (data?.nonce) {
3400
+ if (data.nonce !== this.nonce) return;
3401
+ } else {
3402
+ const iframeWindow = this.iframe?.contentWindow;
3403
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
3404
+ return;
3405
+ }
3376
3406
  }
3377
3407
  const message = parseIframeMessage(event.data);
3378
3408
  if (!message) return;
package/dist/react.mjs CHANGED
@@ -377,6 +377,7 @@ function CimplifyCheckout({
377
377
  businessId,
378
378
  cartId,
379
379
  locationId,
380
+ linkUrl,
380
381
  orderTypes,
381
382
  enrollInLink = true,
382
383
  onComplete,
@@ -409,6 +410,8 @@ function CimplifyCheckout({
409
410
  const demoRunRef = useRef(0);
410
411
  const isDemoCheckout = demoMode ?? client.getPublicKey().trim().length === 0;
411
412
  const isTestMode = client.isTestMode();
413
+ const primaryColor = appearance?.variables?.primaryColor || "#0a2540";
414
+ const isDark = appearance?.theme === "dark";
412
415
  const emitStatus = useCallback(
413
416
  (nextStatus, context = {}) => {
414
417
  setStatus(nextStatus);
@@ -515,7 +518,8 @@ function CimplifyCheckout({
515
518
  return;
516
519
  }
517
520
  const elements = client.elements(resolvedBusinessId, {
518
- appearance: initialAppearanceRef.current
521
+ appearance: initialAppearanceRef.current,
522
+ linkUrl
519
523
  });
520
524
  elementsRef.current = elements;
521
525
  const auth = elements.create("auth");
@@ -650,44 +654,53 @@ function CimplifyCheckout({
650
654
  }
651
655
  ),
652
656
  /* @__PURE__ */ jsx("div", { "data-cimplify-section": "auth", children: /* @__PURE__ */ jsx("div", { ref: isDemoCheckout ? void 0 : authMountRef }) }),
653
- /* @__PURE__ */ jsx("div", { "data-cimplify-section": "order-type", style: { marginTop: "12px" }, children: /* @__PURE__ */ jsx(
654
- "div",
655
- {
656
- role: "group",
657
- "aria-label": "Order type",
658
- style: { display: "flex", gap: "8px", flexWrap: "wrap" },
659
- children: resolvedOrderTypes.map((type) => /* @__PURE__ */ jsx(
660
- "button",
661
- {
662
- type: "button",
663
- onClick: () => setOrderType(type),
664
- disabled: isSubmitting,
665
- "data-selected": orderType === type ? "true" : "false",
666
- style: {
667
- padding: "8px 12px",
668
- borderRadius: "8px",
669
- border: "1px solid #d4d4d8",
670
- background: orderType === type ? "#111827" : "#ffffff",
671
- color: orderType === type ? "#ffffff" : "#111827",
672
- cursor: isSubmitting ? "not-allowed" : "pointer",
673
- opacity: isSubmitting ? 0.6 : 1
657
+ /* @__PURE__ */ jsxs("div", { "data-cimplify-section": "order-type", style: { marginTop: "20px" }, children: [
658
+ /* @__PURE__ */ jsx("p", { style: { fontSize: "13px", fontWeight: 500, color: isDark ? "#a1a1aa" : "#71717a", marginBottom: "8px" }, children: "Order type" }),
659
+ /* @__PURE__ */ jsx(
660
+ "div",
661
+ {
662
+ role: "group",
663
+ "aria-label": "Order type",
664
+ style: { display: "flex", gap: "8px", flexWrap: "wrap" },
665
+ children: resolvedOrderTypes.map((type) => /* @__PURE__ */ jsx(
666
+ "button",
667
+ {
668
+ type: "button",
669
+ onClick: () => setOrderType(type),
670
+ disabled: isSubmitting,
671
+ "data-selected": orderType === type ? "true" : "false",
672
+ style: {
673
+ padding: "8px 14px",
674
+ borderRadius: "8px",
675
+ border: orderType === type ? "1px solid transparent" : `1px solid ${isDark ? "#3f3f46" : "#d4d4d8"}`,
676
+ background: orderType === type ? primaryColor : "transparent",
677
+ color: orderType === type ? "#ffffff" : isDark ? "#e4e4e7" : "#3f3f46",
678
+ cursor: isSubmitting ? "not-allowed" : "pointer",
679
+ opacity: isSubmitting ? 0.6 : 1,
680
+ fontSize: "14px",
681
+ fontWeight: 500,
682
+ transition: "all 150ms ease"
683
+ },
684
+ children: labelForOrderType(type)
674
685
  },
675
- children: labelForOrderType(type)
676
- },
677
- type
678
- ))
679
- }
680
- ) }),
686
+ type
687
+ ))
688
+ }
689
+ )
690
+ ] }),
681
691
  /* @__PURE__ */ jsx(
682
692
  "div",
683
693
  {
684
694
  "data-cimplify-section": "address",
685
- style: { marginTop: "12px", display: orderType === "delivery" ? "block" : "none" },
695
+ style: { marginTop: "16px", display: orderType === "delivery" ? "block" : "none" },
686
696
  children: /* @__PURE__ */ jsx("div", { ref: isDemoCheckout ? void 0 : addressMountRef })
687
697
  }
688
698
  ),
689
- /* @__PURE__ */ jsx("div", { "data-cimplify-section": "payment", style: { marginTop: "12px" }, children: /* @__PURE__ */ jsx("div", { ref: isDemoCheckout ? void 0 : paymentMountRef }) }),
690
- /* @__PURE__ */ jsx("div", { style: { marginTop: "12px" }, children: /* @__PURE__ */ jsx(
699
+ /* @__PURE__ */ jsxs("div", { "data-cimplify-section": "payment", style: { marginTop: "20px" }, children: [
700
+ /* @__PURE__ */ jsx("p", { style: { fontSize: "13px", fontWeight: 500, color: isDark ? "#a1a1aa" : "#71717a", marginBottom: "8px" }, children: "Payment method" }),
701
+ /* @__PURE__ */ jsx("div", { ref: isDemoCheckout ? void 0 : paymentMountRef })
702
+ ] }),
703
+ /* @__PURE__ */ jsx("div", { style: { marginTop: "24px" }, children: /* @__PURE__ */ jsx(
691
704
  "button",
692
705
  {
693
706
  type: "button",
@@ -695,12 +708,16 @@ function CimplifyCheckout({
695
708
  disabled: isSubmitting,
696
709
  style: {
697
710
  width: "100%",
698
- padding: "10px 14px",
711
+ padding: "12px 16px",
699
712
  borderRadius: "8px",
700
713
  border: "none",
701
- background: isSubmitting ? "#a1a1aa" : "#111827",
714
+ background: isSubmitting ? "#a1a1aa" : primaryColor,
702
715
  color: "#ffffff",
703
- cursor: isSubmitting ? "not-allowed" : "pointer"
716
+ cursor: isSubmitting ? "not-allowed" : "pointer",
717
+ fontWeight: 600,
718
+ fontSize: "15px",
719
+ boxShadow: isSubmitting ? "none" : "0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1)",
720
+ transition: "all 150ms ease"
704
721
  },
705
722
  children: isSubmitting ? "Processing..." : "Complete Order"
706
723
  }
@@ -2873,6 +2890,12 @@ function toCheckoutError(code, message, recoverable) {
2873
2890
  };
2874
2891
  }
2875
2892
  var DEFAULT_LINK_URL = "https://link.cimplify.io";
2893
+ function generateNonce() {
2894
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
2895
+ return crypto.randomUUID().replace(/-/g, "").slice(0, 16);
2896
+ }
2897
+ return Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
2898
+ }
2876
2899
  function isAllowedOrigin(origin) {
2877
2900
  try {
2878
2901
  const url = new URL(origin);
@@ -3247,6 +3270,7 @@ var CimplifyElement = class {
3247
3270
  this.linkUrl = linkUrl;
3248
3271
  this.options = options;
3249
3272
  this.parent = parent;
3273
+ this.nonce = generateNonce();
3250
3274
  this.boundHandleMessage = this.handleMessage.bind(this);
3251
3275
  if (typeof window !== "undefined") {
3252
3276
  window.addEventListener("message", this.boundHandleMessage);
@@ -3333,6 +3357,7 @@ var CimplifyElement = class {
3333
3357
  const iframe = document.createElement("iframe");
3334
3358
  const url = new URL(`${this.linkUrl}/elements/${this.type}`);
3335
3359
  url.searchParams.set("businessId", resolvedBusinessId);
3360
+ url.searchParams.set("nonce", this.nonce);
3336
3361
  if (this.options.prefillEmail) url.searchParams.set("email", this.options.prefillEmail);
3337
3362
  if (this.options.mode) url.searchParams.set("mode", this.options.mode);
3338
3363
  iframe.src = url.toString();
@@ -3368,9 +3393,14 @@ var CimplifyElement = class {
3368
3393
  if (!isAllowedOrigin(event.origin)) {
3369
3394
  return;
3370
3395
  }
3371
- const iframeWindow = this.iframe?.contentWindow;
3372
- if (iframeWindow && event.source && event.source !== iframeWindow) {
3373
- return;
3396
+ const data = event.data;
3397
+ if (data?.nonce) {
3398
+ if (data.nonce !== this.nonce) return;
3399
+ } else {
3400
+ const iframeWindow = this.iframe?.contentWindow;
3401
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
3402
+ return;
3403
+ }
3374
3404
  }
3375
3405
  const message = parseIframeMessage(event.data);
3376
3406
  if (!message) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "keywords": [
6
6
  "cimplify",