@cimplify/sdk 0.7.3 → 0.7.5

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-B0f__K5x.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-DvoI0EIX.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-C9aOFBo_.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-CIvQ1ZLZ.js';
2
2
  import './payment-CLIWNMaP.js';
3
3
 
4
4
  type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
package/dist/advanced.js CHANGED
@@ -2681,10 +2681,15 @@ var CimplifyElement = class {
2681
2681
  if (!isAllowedOrigin(event.origin)) {
2682
2682
  return;
2683
2683
  }
2684
+ const iframeWindow = this.iframe?.contentWindow;
2685
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
2686
+ return;
2687
+ }
2684
2688
  const message = parseIframeMessage(event.data);
2685
2689
  if (!message) return;
2686
2690
  switch (message.type) {
2687
2691
  case MESSAGE_TYPES.READY:
2692
+ if (this.iframe && message.height) this.iframe.style.height = `${message.height}px`;
2688
2693
  this.emit(EVENT_TYPES.READY, { height: message.height });
2689
2694
  break;
2690
2695
  case MESSAGE_TYPES.HEIGHT_CHANGE:
package/dist/advanced.mjs CHANGED
@@ -2679,10 +2679,15 @@ var CimplifyElement = class {
2679
2679
  if (!isAllowedOrigin(event.origin)) {
2680
2680
  return;
2681
2681
  }
2682
+ const iframeWindow = this.iframe?.contentWindow;
2683
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
2684
+ return;
2685
+ }
2682
2686
  const message = parseIframeMessage(event.data);
2683
2687
  if (!message) return;
2684
2688
  switch (message.type) {
2685
2689
  case MESSAGE_TYPES.READY:
2690
+ if (this.iframe && message.height) this.iframe.style.height = `${message.height}px`;
2686
2691
  this.emit(EVENT_TYPES.READY, { height: message.height });
2687
2692
  break;
2688
2693
  case MESSAGE_TYPES.HEIGHT_CHANGE:
@@ -2170,6 +2170,7 @@ declare class CimplifyClient {
2170
2170
  private publicKey;
2171
2171
  private credentials;
2172
2172
  private accessToken;
2173
+ private sessionToken;
2173
2174
  private timeout;
2174
2175
  private maxRetries;
2175
2176
  private retryDelay;
@@ -2216,6 +2217,9 @@ declare class CimplifyClient {
2216
2217
  resolveBusinessId(): Promise<string>;
2217
2218
  private loadAccessToken;
2218
2219
  private saveAccessToken;
2220
+ private loadSessionToken;
2221
+ private saveSessionToken;
2222
+ private captureSessionToken;
2219
2223
  private getHeaders;
2220
2224
  private resilientFetch;
2221
2225
  private getDedupeKey;
@@ -2170,6 +2170,7 @@ declare class CimplifyClient {
2170
2170
  private publicKey;
2171
2171
  private credentials;
2172
2172
  private accessToken;
2173
+ private sessionToken;
2173
2174
  private timeout;
2174
2175
  private maxRetries;
2175
2176
  private retryDelay;
@@ -2216,6 +2217,9 @@ declare class CimplifyClient {
2216
2217
  resolveBusinessId(): Promise<string>;
2217
2218
  private loadAccessToken;
2218
2219
  private saveAccessToken;
2220
+ private loadSessionToken;
2221
+ private saveSessionToken;
2222
+ private captureSessionToken;
2219
2223
  private getHeaders;
2220
2224
  private resilientFetch;
2221
2225
  private getDedupeKey;
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-B0f__K5x.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-DvoI0EIX.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-C9aOFBo_.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-CIvQ1ZLZ.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
@@ -3129,10 +3129,15 @@ var CimplifyElement = class {
3129
3129
  if (!isAllowedOrigin(event.origin)) {
3130
3130
  return;
3131
3131
  }
3132
+ const iframeWindow = this.iframe?.contentWindow;
3133
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
3134
+ return;
3135
+ }
3132
3136
  const message = parseIframeMessage(event.data);
3133
3137
  if (!message) return;
3134
3138
  switch (message.type) {
3135
3139
  case MESSAGE_TYPES.READY:
3140
+ if (this.iframe && message.height) this.iframe.style.height = `${message.height}px`;
3136
3141
  this.emit(EVENT_TYPES.READY, { height: message.height });
3137
3142
  break;
3138
3143
  case MESSAGE_TYPES.HEIGHT_CHANGE:
@@ -3187,7 +3192,9 @@ function createElements(client, businessId, options) {
3187
3192
 
3188
3193
  // src/client.ts
3189
3194
  var ACCESS_TOKEN_STORAGE_KEY = "cimplify_access_token";
3195
+ var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
3190
3196
  var ORDER_TOKEN_PREFIX = "cimplify_ot_";
3197
+ var SESSION_TOKEN_HEADER = "x-session-token";
3191
3198
  var DEFAULT_TIMEOUT_MS = 3e4;
3192
3199
  var DEFAULT_MAX_RETRIES = 3;
3193
3200
  var DEFAULT_RETRY_DELAY_MS = 1e3;
@@ -3272,6 +3279,7 @@ function getEnvPublicKey() {
3272
3279
  var CimplifyClient = class {
3273
3280
  constructor(config = {}) {
3274
3281
  this.accessToken = null;
3282
+ this.sessionToken = null;
3275
3283
  this.context = {};
3276
3284
  this.businessId = null;
3277
3285
  this.businessIdResolvePromise = null;
@@ -3286,6 +3294,7 @@ var CimplifyClient = class {
3286
3294
  this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY_MS;
3287
3295
  this.hooks = config.hooks ?? {};
3288
3296
  this.accessToken = this.loadAccessToken();
3297
+ this.sessionToken = this.loadSessionToken();
3289
3298
  if (!this.publicKey && !config.suppressPublicKeyWarning) {
3290
3299
  console.warn(
3291
3300
  '[Cimplify] No public key found. Set NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY in your environment, or pass { publicKey: "pk_..." } to createCimplifyClient().'
@@ -3322,7 +3331,11 @@ var CimplifyClient = class {
3322
3331
  clearSession() {
3323
3332
  const previous = this.accessToken;
3324
3333
  this.accessToken = null;
3334
+ this.sessionToken = null;
3325
3335
  this.saveAccessToken(null);
3336
+ if (typeof window !== "undefined" && window.localStorage) {
3337
+ localStorage.removeItem(SESSION_TOKEN_STORAGE_KEY);
3338
+ }
3326
3339
  this.hooks.onSessionChange?.({
3327
3340
  previousToken: previous,
3328
3341
  newToken: null,
@@ -3419,6 +3432,27 @@ var CimplifyClient = class {
3419
3432
  }
3420
3433
  }
3421
3434
  }
3435
+ loadSessionToken() {
3436
+ if (typeof window !== "undefined" && window.localStorage) {
3437
+ return localStorage.getItem(SESSION_TOKEN_STORAGE_KEY);
3438
+ }
3439
+ return null;
3440
+ }
3441
+ saveSessionToken(token) {
3442
+ if (typeof window !== "undefined" && window.localStorage) {
3443
+ try {
3444
+ localStorage.setItem(SESSION_TOKEN_STORAGE_KEY, token);
3445
+ } catch {
3446
+ }
3447
+ }
3448
+ }
3449
+ captureSessionToken(response) {
3450
+ const token = response.headers.get(SESSION_TOKEN_HEADER);
3451
+ if (token && token !== this.sessionToken) {
3452
+ this.sessionToken = token;
3453
+ this.saveSessionToken(token);
3454
+ }
3455
+ }
3422
3456
  getHeaders() {
3423
3457
  const headers = {
3424
3458
  "Content-Type": "application/json"
@@ -3430,6 +3464,9 @@ var CimplifyClient = class {
3430
3464
  if (this.accessToken) {
3431
3465
  headers["Authorization"] = `Bearer ${this.accessToken}`;
3432
3466
  }
3467
+ if (this.sessionToken) {
3468
+ headers[SESSION_TOKEN_HEADER] = this.sessionToken;
3469
+ }
3433
3470
  return headers;
3434
3471
  }
3435
3472
  async resilientFetch(url, options) {
@@ -3455,6 +3492,7 @@ var CimplifyClient = class {
3455
3492
  signal: controller.signal
3456
3493
  });
3457
3494
  clearTimeout(timeoutId);
3495
+ this.captureSessionToken(response);
3458
3496
  if (response.ok) {
3459
3497
  this.hooks.onRequestSuccess?.({
3460
3498
  ...context,
package/dist/index.mjs CHANGED
@@ -3127,10 +3127,15 @@ var CimplifyElement = class {
3127
3127
  if (!isAllowedOrigin(event.origin)) {
3128
3128
  return;
3129
3129
  }
3130
+ const iframeWindow = this.iframe?.contentWindow;
3131
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
3132
+ return;
3133
+ }
3130
3134
  const message = parseIframeMessage(event.data);
3131
3135
  if (!message) return;
3132
3136
  switch (message.type) {
3133
3137
  case MESSAGE_TYPES.READY:
3138
+ if (this.iframe && message.height) this.iframe.style.height = `${message.height}px`;
3134
3139
  this.emit(EVENT_TYPES.READY, { height: message.height });
3135
3140
  break;
3136
3141
  case MESSAGE_TYPES.HEIGHT_CHANGE:
@@ -3185,7 +3190,9 @@ function createElements(client, businessId, options) {
3185
3190
 
3186
3191
  // src/client.ts
3187
3192
  var ACCESS_TOKEN_STORAGE_KEY = "cimplify_access_token";
3193
+ var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
3188
3194
  var ORDER_TOKEN_PREFIX = "cimplify_ot_";
3195
+ var SESSION_TOKEN_HEADER = "x-session-token";
3189
3196
  var DEFAULT_TIMEOUT_MS = 3e4;
3190
3197
  var DEFAULT_MAX_RETRIES = 3;
3191
3198
  var DEFAULT_RETRY_DELAY_MS = 1e3;
@@ -3270,6 +3277,7 @@ function getEnvPublicKey() {
3270
3277
  var CimplifyClient = class {
3271
3278
  constructor(config = {}) {
3272
3279
  this.accessToken = null;
3280
+ this.sessionToken = null;
3273
3281
  this.context = {};
3274
3282
  this.businessId = null;
3275
3283
  this.businessIdResolvePromise = null;
@@ -3284,6 +3292,7 @@ var CimplifyClient = class {
3284
3292
  this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY_MS;
3285
3293
  this.hooks = config.hooks ?? {};
3286
3294
  this.accessToken = this.loadAccessToken();
3295
+ this.sessionToken = this.loadSessionToken();
3287
3296
  if (!this.publicKey && !config.suppressPublicKeyWarning) {
3288
3297
  console.warn(
3289
3298
  '[Cimplify] No public key found. Set NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY in your environment, or pass { publicKey: "pk_..." } to createCimplifyClient().'
@@ -3320,7 +3329,11 @@ var CimplifyClient = class {
3320
3329
  clearSession() {
3321
3330
  const previous = this.accessToken;
3322
3331
  this.accessToken = null;
3332
+ this.sessionToken = null;
3323
3333
  this.saveAccessToken(null);
3334
+ if (typeof window !== "undefined" && window.localStorage) {
3335
+ localStorage.removeItem(SESSION_TOKEN_STORAGE_KEY);
3336
+ }
3324
3337
  this.hooks.onSessionChange?.({
3325
3338
  previousToken: previous,
3326
3339
  newToken: null,
@@ -3417,6 +3430,27 @@ var CimplifyClient = class {
3417
3430
  }
3418
3431
  }
3419
3432
  }
3433
+ loadSessionToken() {
3434
+ if (typeof window !== "undefined" && window.localStorage) {
3435
+ return localStorage.getItem(SESSION_TOKEN_STORAGE_KEY);
3436
+ }
3437
+ return null;
3438
+ }
3439
+ saveSessionToken(token) {
3440
+ if (typeof window !== "undefined" && window.localStorage) {
3441
+ try {
3442
+ localStorage.setItem(SESSION_TOKEN_STORAGE_KEY, token);
3443
+ } catch {
3444
+ }
3445
+ }
3446
+ }
3447
+ captureSessionToken(response) {
3448
+ const token = response.headers.get(SESSION_TOKEN_HEADER);
3449
+ if (token && token !== this.sessionToken) {
3450
+ this.sessionToken = token;
3451
+ this.saveSessionToken(token);
3452
+ }
3453
+ }
3420
3454
  getHeaders() {
3421
3455
  const headers = {
3422
3456
  "Content-Type": "application/json"
@@ -3428,6 +3462,9 @@ var CimplifyClient = class {
3428
3462
  if (this.accessToken) {
3429
3463
  headers["Authorization"] = `Bearer ${this.accessToken}`;
3430
3464
  }
3465
+ if (this.sessionToken) {
3466
+ headers[SESSION_TOKEN_HEADER] = this.sessionToken;
3467
+ }
3431
3468
  return headers;
3432
3469
  }
3433
3470
  async resilientFetch(url, options) {
@@ -3453,6 +3490,7 @@ var CimplifyClient = class {
3453
3490
  signal: controller.signal
3454
3491
  });
3455
3492
  clearTimeout(timeoutId);
3493
+ this.captureSessionToken(response);
3456
3494
  if (response.ok) {
3457
3495
  this.hooks.onRequestSuccess?.({
3458
3496
  ...context,
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-B0f__K5x.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-DvoI0EIX.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';
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-C9aOFBo_.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-CIvQ1ZLZ.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';
package/dist/react.js CHANGED
@@ -3370,10 +3370,15 @@ var CimplifyElement = class {
3370
3370
  if (!isAllowedOrigin(event.origin)) {
3371
3371
  return;
3372
3372
  }
3373
+ const iframeWindow = this.iframe?.contentWindow;
3374
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
3375
+ return;
3376
+ }
3373
3377
  const message = parseIframeMessage(event.data);
3374
3378
  if (!message) return;
3375
3379
  switch (message.type) {
3376
3380
  case MESSAGE_TYPES.READY:
3381
+ if (this.iframe && message.height) this.iframe.style.height = `${message.height}px`;
3377
3382
  this.emit(EVENT_TYPES.READY, { height: message.height });
3378
3383
  break;
3379
3384
  case MESSAGE_TYPES.HEIGHT_CHANGE:
@@ -3428,7 +3433,9 @@ function createElements(client, businessId, options) {
3428
3433
 
3429
3434
  // src/client.ts
3430
3435
  var ACCESS_TOKEN_STORAGE_KEY = "cimplify_access_token";
3436
+ var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
3431
3437
  var ORDER_TOKEN_PREFIX = "cimplify_ot_";
3438
+ var SESSION_TOKEN_HEADER = "x-session-token";
3432
3439
  var DEFAULT_TIMEOUT_MS = 3e4;
3433
3440
  var DEFAULT_MAX_RETRIES = 3;
3434
3441
  var DEFAULT_RETRY_DELAY_MS = 1e3;
@@ -3513,6 +3520,7 @@ function getEnvPublicKey() {
3513
3520
  var CimplifyClient = class {
3514
3521
  constructor(config = {}) {
3515
3522
  this.accessToken = null;
3523
+ this.sessionToken = null;
3516
3524
  this.context = {};
3517
3525
  this.businessId = null;
3518
3526
  this.businessIdResolvePromise = null;
@@ -3527,6 +3535,7 @@ var CimplifyClient = class {
3527
3535
  this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY_MS;
3528
3536
  this.hooks = config.hooks ?? {};
3529
3537
  this.accessToken = this.loadAccessToken();
3538
+ this.sessionToken = this.loadSessionToken();
3530
3539
  if (!this.publicKey && !config.suppressPublicKeyWarning) {
3531
3540
  console.warn(
3532
3541
  '[Cimplify] No public key found. Set NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY in your environment, or pass { publicKey: "pk_..." } to createCimplifyClient().'
@@ -3563,7 +3572,11 @@ var CimplifyClient = class {
3563
3572
  clearSession() {
3564
3573
  const previous = this.accessToken;
3565
3574
  this.accessToken = null;
3575
+ this.sessionToken = null;
3566
3576
  this.saveAccessToken(null);
3577
+ if (typeof window !== "undefined" && window.localStorage) {
3578
+ localStorage.removeItem(SESSION_TOKEN_STORAGE_KEY);
3579
+ }
3567
3580
  this.hooks.onSessionChange?.({
3568
3581
  previousToken: previous,
3569
3582
  newToken: null,
@@ -3660,6 +3673,27 @@ var CimplifyClient = class {
3660
3673
  }
3661
3674
  }
3662
3675
  }
3676
+ loadSessionToken() {
3677
+ if (typeof window !== "undefined" && window.localStorage) {
3678
+ return localStorage.getItem(SESSION_TOKEN_STORAGE_KEY);
3679
+ }
3680
+ return null;
3681
+ }
3682
+ saveSessionToken(token) {
3683
+ if (typeof window !== "undefined" && window.localStorage) {
3684
+ try {
3685
+ localStorage.setItem(SESSION_TOKEN_STORAGE_KEY, token);
3686
+ } catch {
3687
+ }
3688
+ }
3689
+ }
3690
+ captureSessionToken(response) {
3691
+ const token = response.headers.get(SESSION_TOKEN_HEADER);
3692
+ if (token && token !== this.sessionToken) {
3693
+ this.sessionToken = token;
3694
+ this.saveSessionToken(token);
3695
+ }
3696
+ }
3663
3697
  getHeaders() {
3664
3698
  const headers = {
3665
3699
  "Content-Type": "application/json"
@@ -3671,6 +3705,9 @@ var CimplifyClient = class {
3671
3705
  if (this.accessToken) {
3672
3706
  headers["Authorization"] = `Bearer ${this.accessToken}`;
3673
3707
  }
3708
+ if (this.sessionToken) {
3709
+ headers[SESSION_TOKEN_HEADER] = this.sessionToken;
3710
+ }
3674
3711
  return headers;
3675
3712
  }
3676
3713
  async resilientFetch(url, options) {
@@ -3696,6 +3733,7 @@ var CimplifyClient = class {
3696
3733
  signal: controller.signal
3697
3734
  });
3698
3735
  clearTimeout(timeoutId);
3736
+ this.captureSessionToken(response);
3699
3737
  if (response.ok) {
3700
3738
  this.hooks.onRequestSuccess?.({
3701
3739
  ...context,
package/dist/react.mjs CHANGED
@@ -3368,10 +3368,15 @@ var CimplifyElement = class {
3368
3368
  if (!isAllowedOrigin(event.origin)) {
3369
3369
  return;
3370
3370
  }
3371
+ const iframeWindow = this.iframe?.contentWindow;
3372
+ if (iframeWindow && event.source && event.source !== iframeWindow) {
3373
+ return;
3374
+ }
3371
3375
  const message = parseIframeMessage(event.data);
3372
3376
  if (!message) return;
3373
3377
  switch (message.type) {
3374
3378
  case MESSAGE_TYPES.READY:
3379
+ if (this.iframe && message.height) this.iframe.style.height = `${message.height}px`;
3375
3380
  this.emit(EVENT_TYPES.READY, { height: message.height });
3376
3381
  break;
3377
3382
  case MESSAGE_TYPES.HEIGHT_CHANGE:
@@ -3426,7 +3431,9 @@ function createElements(client, businessId, options) {
3426
3431
 
3427
3432
  // src/client.ts
3428
3433
  var ACCESS_TOKEN_STORAGE_KEY = "cimplify_access_token";
3434
+ var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
3429
3435
  var ORDER_TOKEN_PREFIX = "cimplify_ot_";
3436
+ var SESSION_TOKEN_HEADER = "x-session-token";
3430
3437
  var DEFAULT_TIMEOUT_MS = 3e4;
3431
3438
  var DEFAULT_MAX_RETRIES = 3;
3432
3439
  var DEFAULT_RETRY_DELAY_MS = 1e3;
@@ -3511,6 +3518,7 @@ function getEnvPublicKey() {
3511
3518
  var CimplifyClient = class {
3512
3519
  constructor(config = {}) {
3513
3520
  this.accessToken = null;
3521
+ this.sessionToken = null;
3514
3522
  this.context = {};
3515
3523
  this.businessId = null;
3516
3524
  this.businessIdResolvePromise = null;
@@ -3525,6 +3533,7 @@ var CimplifyClient = class {
3525
3533
  this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY_MS;
3526
3534
  this.hooks = config.hooks ?? {};
3527
3535
  this.accessToken = this.loadAccessToken();
3536
+ this.sessionToken = this.loadSessionToken();
3528
3537
  if (!this.publicKey && !config.suppressPublicKeyWarning) {
3529
3538
  console.warn(
3530
3539
  '[Cimplify] No public key found. Set NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY in your environment, or pass { publicKey: "pk_..." } to createCimplifyClient().'
@@ -3561,7 +3570,11 @@ var CimplifyClient = class {
3561
3570
  clearSession() {
3562
3571
  const previous = this.accessToken;
3563
3572
  this.accessToken = null;
3573
+ this.sessionToken = null;
3564
3574
  this.saveAccessToken(null);
3575
+ if (typeof window !== "undefined" && window.localStorage) {
3576
+ localStorage.removeItem(SESSION_TOKEN_STORAGE_KEY);
3577
+ }
3565
3578
  this.hooks.onSessionChange?.({
3566
3579
  previousToken: previous,
3567
3580
  newToken: null,
@@ -3658,6 +3671,27 @@ var CimplifyClient = class {
3658
3671
  }
3659
3672
  }
3660
3673
  }
3674
+ loadSessionToken() {
3675
+ if (typeof window !== "undefined" && window.localStorage) {
3676
+ return localStorage.getItem(SESSION_TOKEN_STORAGE_KEY);
3677
+ }
3678
+ return null;
3679
+ }
3680
+ saveSessionToken(token) {
3681
+ if (typeof window !== "undefined" && window.localStorage) {
3682
+ try {
3683
+ localStorage.setItem(SESSION_TOKEN_STORAGE_KEY, token);
3684
+ } catch {
3685
+ }
3686
+ }
3687
+ }
3688
+ captureSessionToken(response) {
3689
+ const token = response.headers.get(SESSION_TOKEN_HEADER);
3690
+ if (token && token !== this.sessionToken) {
3691
+ this.sessionToken = token;
3692
+ this.saveSessionToken(token);
3693
+ }
3694
+ }
3661
3695
  getHeaders() {
3662
3696
  const headers = {
3663
3697
  "Content-Type": "application/json"
@@ -3669,6 +3703,9 @@ var CimplifyClient = class {
3669
3703
  if (this.accessToken) {
3670
3704
  headers["Authorization"] = `Bearer ${this.accessToken}`;
3671
3705
  }
3706
+ if (this.sessionToken) {
3707
+ headers[SESSION_TOKEN_HEADER] = this.sessionToken;
3708
+ }
3672
3709
  return headers;
3673
3710
  }
3674
3711
  async resilientFetch(url, options) {
@@ -3694,6 +3731,7 @@ var CimplifyClient = class {
3694
3731
  signal: controller.signal
3695
3732
  });
3696
3733
  clearTimeout(timeoutId);
3734
+ this.captureSessionToken(response);
3697
3735
  if (response.ok) {
3698
3736
  this.hooks.onRequestSuccess?.({
3699
3737
  ...context,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "keywords": [
6
6
  "cimplify",