@cimplify/sdk 0.58.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-VV3GTDIP.js → chunk-3QPO2UK5.js} +29 -7
- package/dist/chunk-LA2T2TPA.js +25 -0
- package/dist/{chunk-W6FRIYYU.mjs → chunk-TGAROSXB.mjs} +29 -7
- package/dist/chunk-ZKTXRWP6.mjs +19 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -15
- package/dist/index.mjs +3 -2
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +48 -47
- package/dist/react.mjs +3 -2
- package/dist/server.d.mts +12 -1
- package/dist/server.d.ts +12 -1
- package/dist/server.js +57 -0
- package/dist/server.mjs +57 -1
- package/dist/{sign-in-TL01-awQ.d.mts → sign-in-CZ2ioBAP.d.mts} +9 -0
- package/dist/{sign-in-TL01-awQ.d.ts → sign-in-CZ2ioBAP.d.ts} +9 -0
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkLA2T2TPA_js = require('./chunk-LA2T2TPA.js');
|
|
4
|
+
|
|
3
5
|
// src/gallery.ts
|
|
4
6
|
function dedupe(urls) {
|
|
5
7
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -155,20 +157,17 @@ function openModalIframe(opts) {
|
|
|
155
157
|
});
|
|
156
158
|
const card = document.createElement("div");
|
|
157
159
|
Object.assign(card.style, {
|
|
158
|
-
width: `${opts.width ??
|
|
160
|
+
width: `${opts.width ?? 480}px`,
|
|
159
161
|
maxWidth: "calc(100vw - 24px)",
|
|
160
|
-
height: `${opts.height ??
|
|
161
|
-
maxHeight: "calc(100vh -
|
|
162
|
-
background: "#fff",
|
|
163
|
-
borderRadius: "14px",
|
|
164
|
-
overflow: "hidden",
|
|
165
|
-
boxShadow: "0 24px 64px rgba(0,0,0,0.25)"
|
|
162
|
+
height: `${opts.height ?? 720}px`,
|
|
163
|
+
maxHeight: "calc(100vh - 32px)"
|
|
166
164
|
});
|
|
167
165
|
const iframe = document.createElement("iframe");
|
|
168
166
|
iframe.src = opts.src;
|
|
169
167
|
iframe.style.width = "100%";
|
|
170
168
|
iframe.style.height = "100%";
|
|
171
169
|
iframe.style.border = "none";
|
|
170
|
+
iframe.style.background = "transparent";
|
|
172
171
|
iframe.setAttribute(
|
|
173
172
|
"sandbox",
|
|
174
173
|
opts.sandbox ?? "allow-scripts allow-same-origin allow-forms allow-popups"
|
|
@@ -200,6 +199,10 @@ async function startSignIn(opts) {
|
|
|
200
199
|
const callbackUri = opts.callbackUri ?? "/auth/callback";
|
|
201
200
|
const pkce = await generatePkce();
|
|
202
201
|
const state = generateState();
|
|
202
|
+
if ((opts.mode ?? "redirect") === "redirect") {
|
|
203
|
+
startRedirectSignIn(opts, authUrl, pkce, state);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
203
206
|
const params = new URLSearchParams({
|
|
204
207
|
response_type: "code",
|
|
205
208
|
response_mode: "web_message",
|
|
@@ -258,6 +261,25 @@ async function startSignIn(opts) {
|
|
|
258
261
|
};
|
|
259
262
|
window.addEventListener("message", handler);
|
|
260
263
|
}
|
|
264
|
+
function startRedirectSignIn(opts, authUrl, pkce, state) {
|
|
265
|
+
const returnTo = opts.returnTo ?? window.location.pathname + window.location.search;
|
|
266
|
+
const cookieValue = chunkLA2T2TPA_js.encodePkceState({ verifier: pkce.verifier, state, returnTo });
|
|
267
|
+
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
268
|
+
document.cookie = `${chunkLA2T2TPA_js.PKCE_COOKIE}=${cookieValue}; Path=${chunkLA2T2TPA_js.PKCE_COOKIE_PATH}; Max-Age=${chunkLA2T2TPA_js.PKCE_COOKIE_MAX_AGE_SECONDS}; SameSite=Lax${secure}`;
|
|
269
|
+
const params = new URLSearchParams({
|
|
270
|
+
response_type: "code",
|
|
271
|
+
response_mode: "query",
|
|
272
|
+
client_id: opts.clientId,
|
|
273
|
+
redirect_uri: opts.redirectUri,
|
|
274
|
+
scope: opts.scope ?? DEFAULT_SCOPE,
|
|
275
|
+
state,
|
|
276
|
+
code_challenge: pkce.challenge,
|
|
277
|
+
code_challenge_method: pkce.method
|
|
278
|
+
});
|
|
279
|
+
if (opts.loginHint) params.set("login_hint", opts.loginHint);
|
|
280
|
+
if (opts.prompt) params.set("prompt", opts.prompt);
|
|
281
|
+
window.location.assign(`${authUrl}/oauth/authorize?${params.toString()}`);
|
|
282
|
+
}
|
|
261
283
|
|
|
262
284
|
// src/assets/url.ts
|
|
263
285
|
var DEFAULT_CDN_BASE_URL = "https://storefrontassetscdn.cimplify.io";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/internal/pkce-cookie.ts
|
|
4
|
+
var PKCE_COOKIE = "cimplify_pkce";
|
|
5
|
+
var PKCE_COOKIE_PATH = "/auth";
|
|
6
|
+
var PKCE_COOKIE_MAX_AGE_SECONDS = 600;
|
|
7
|
+
function encodePkceState(state) {
|
|
8
|
+
return encodeURIComponent(JSON.stringify(state));
|
|
9
|
+
}
|
|
10
|
+
function decodePkceState(raw) {
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(decodeURIComponent(raw));
|
|
13
|
+
if (typeof parsed?.verifier === "string" && typeof parsed.state === "string" && typeof parsed.returnTo === "string") {
|
|
14
|
+
return { verifier: parsed.verifier, state: parsed.state, returnTo: parsed.returnTo };
|
|
15
|
+
}
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.PKCE_COOKIE = PKCE_COOKIE;
|
|
22
|
+
exports.PKCE_COOKIE_MAX_AGE_SECONDS = PKCE_COOKIE_MAX_AGE_SECONDS;
|
|
23
|
+
exports.PKCE_COOKIE_PATH = PKCE_COOKIE_PATH;
|
|
24
|
+
exports.decodePkceState = decodePkceState;
|
|
25
|
+
exports.encodePkceState = encodePkceState;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { encodePkceState, PKCE_COOKIE, PKCE_COOKIE_PATH, PKCE_COOKIE_MAX_AGE_SECONDS } from './chunk-ZKTXRWP6.mjs';
|
|
2
|
+
|
|
1
3
|
// src/gallery.ts
|
|
2
4
|
function dedupe(urls) {
|
|
3
5
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -153,20 +155,17 @@ function openModalIframe(opts) {
|
|
|
153
155
|
});
|
|
154
156
|
const card = document.createElement("div");
|
|
155
157
|
Object.assign(card.style, {
|
|
156
|
-
width: `${opts.width ??
|
|
158
|
+
width: `${opts.width ?? 480}px`,
|
|
157
159
|
maxWidth: "calc(100vw - 24px)",
|
|
158
|
-
height: `${opts.height ??
|
|
159
|
-
maxHeight: "calc(100vh -
|
|
160
|
-
background: "#fff",
|
|
161
|
-
borderRadius: "14px",
|
|
162
|
-
overflow: "hidden",
|
|
163
|
-
boxShadow: "0 24px 64px rgba(0,0,0,0.25)"
|
|
160
|
+
height: `${opts.height ?? 720}px`,
|
|
161
|
+
maxHeight: "calc(100vh - 32px)"
|
|
164
162
|
});
|
|
165
163
|
const iframe = document.createElement("iframe");
|
|
166
164
|
iframe.src = opts.src;
|
|
167
165
|
iframe.style.width = "100%";
|
|
168
166
|
iframe.style.height = "100%";
|
|
169
167
|
iframe.style.border = "none";
|
|
168
|
+
iframe.style.background = "transparent";
|
|
170
169
|
iframe.setAttribute(
|
|
171
170
|
"sandbox",
|
|
172
171
|
opts.sandbox ?? "allow-scripts allow-same-origin allow-forms allow-popups"
|
|
@@ -198,6 +197,10 @@ async function startSignIn(opts) {
|
|
|
198
197
|
const callbackUri = opts.callbackUri ?? "/auth/callback";
|
|
199
198
|
const pkce = await generatePkce();
|
|
200
199
|
const state = generateState();
|
|
200
|
+
if ((opts.mode ?? "redirect") === "redirect") {
|
|
201
|
+
startRedirectSignIn(opts, authUrl, pkce, state);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
201
204
|
const params = new URLSearchParams({
|
|
202
205
|
response_type: "code",
|
|
203
206
|
response_mode: "web_message",
|
|
@@ -256,6 +259,25 @@ async function startSignIn(opts) {
|
|
|
256
259
|
};
|
|
257
260
|
window.addEventListener("message", handler);
|
|
258
261
|
}
|
|
262
|
+
function startRedirectSignIn(opts, authUrl, pkce, state) {
|
|
263
|
+
const returnTo = opts.returnTo ?? window.location.pathname + window.location.search;
|
|
264
|
+
const cookieValue = encodePkceState({ verifier: pkce.verifier, state, returnTo });
|
|
265
|
+
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
266
|
+
document.cookie = `${PKCE_COOKIE}=${cookieValue}; Path=${PKCE_COOKIE_PATH}; Max-Age=${PKCE_COOKIE_MAX_AGE_SECONDS}; SameSite=Lax${secure}`;
|
|
267
|
+
const params = new URLSearchParams({
|
|
268
|
+
response_type: "code",
|
|
269
|
+
response_mode: "query",
|
|
270
|
+
client_id: opts.clientId,
|
|
271
|
+
redirect_uri: opts.redirectUri,
|
|
272
|
+
scope: opts.scope ?? DEFAULT_SCOPE,
|
|
273
|
+
state,
|
|
274
|
+
code_challenge: pkce.challenge,
|
|
275
|
+
code_challenge_method: pkce.method
|
|
276
|
+
});
|
|
277
|
+
if (opts.loginHint) params.set("login_hint", opts.loginHint);
|
|
278
|
+
if (opts.prompt) params.set("prompt", opts.prompt);
|
|
279
|
+
window.location.assign(`${authUrl}/oauth/authorize?${params.toString()}`);
|
|
280
|
+
}
|
|
259
281
|
|
|
260
282
|
// src/assets/url.ts
|
|
261
283
|
var DEFAULT_CDN_BASE_URL = "https://storefrontassetscdn.cimplify.io";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/internal/pkce-cookie.ts
|
|
2
|
+
var PKCE_COOKIE = "cimplify_pkce";
|
|
3
|
+
var PKCE_COOKIE_PATH = "/auth";
|
|
4
|
+
var PKCE_COOKIE_MAX_AGE_SECONDS = 600;
|
|
5
|
+
function encodePkceState(state) {
|
|
6
|
+
return encodeURIComponent(JSON.stringify(state));
|
|
7
|
+
}
|
|
8
|
+
function decodePkceState(raw) {
|
|
9
|
+
try {
|
|
10
|
+
const parsed = JSON.parse(decodeURIComponent(raw));
|
|
11
|
+
if (typeof parsed?.verifier === "string" && typeof parsed.state === "string" && typeof parsed.returnTo === "string") {
|
|
12
|
+
return { verifier: parsed.verifier, state: parsed.state, returnTo: parsed.returnTo };
|
|
13
|
+
}
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { PKCE_COOKIE, PKCE_COOKIE_MAX_AGE_SECONDS, PKCE_COOKIE_PATH, decodePkceState, encodePkceState };
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ export { A as AUTHORIZATION_TYPE, a as AUTH_MUTATION, b as AbortablePromise, c a
|
|
|
2
2
|
import { b9 as ProductWithDetails, j as ApiError } from './product-B_kS4Oxa.mjs';
|
|
3
3
|
export { A as AddOn, a as AddOnDetails, b as AddOnGroupDetails, c as AddOnOption, d as AddOnOptionDetails, e as AddOnOptionPrice, f as AddOnWithOptions, g as AddToCartInput, h as AddressValue, i as AdjustmentType, k as AppliedDiscount, l as AttributeAppliesTo, m as AttributeType, n as AttributeValidationRules, o as AttributeVisibility, B as BenefitType, p as BillingFrequency, q as BillingMarkupType, r as BillingPlanType, s as Bundle, t as BundleComponentData, u as BundleComponentInfo, v as BundleComponentVariantView, w as BundleComponentView, x as BundlePriceType, y as BundleProduct, z as BundleSelectionData, C as BundleSelectionInput, D as BundleStoredSelection, E as BundleSummary, F as BundleWithDetails, G as Cart, H as CartAddOn, I as CartChannel, J as CartItem, K as CartItemDetails, L as CartMutationResult, M as CartNotice, N as CartStatus, O as CartSummary, P as CartTotals, Q as Category, R as CategorySummary, S as ChosenPrice, T as CimplifyError, U as Collection, V as CollectionProduct, W as CollectionSummary, X as ComponentGroup, Y as ComponentGroupWithComponents, Z as ComponentPriceBreakdown, _ as ComponentSchedulingData, $ as ComponentSelectionInput, a0 as ComponentSourceType, a1 as Composite, a2 as CompositeComponent, a3 as CompositeComponentView, a4 as CompositeGroupView, a5 as CompositePriceBreakdown, a6 as CompositePriceResult, a7 as CompositePricingMode, a8 as CompositeSelectionData, $ as CompositeSelectionInput, a9 as CompositeStoredSelection, aa as CompositeWithDetails, ab as CurrencyCode, ac as CustomAttributeDefinition, ad as CustomAttributeValue, ae as CustomerInputValue, af as DURATION_UNIT, ag as DateRangeValue, ah as Deal, ai as DealBenefitType, aj as DepositType, ak as DigitalProductType, al as DiscountBreakdown, am as DiscountDetails, an as DiscountValidation, ao as DisplayAddOn, ap as DisplayAddOnOption, aq as DisplayCart, ar as DisplayCartItem, as as DisplayMode, at as DurationUnit, au as ERROR_HINTS, av as EligiblePlansQuery, aw as ErrorCode, ax as ErrorCodeType, ay as ErrorHint, az as FacetValue, aA as FormattedPlanOption, aB as GroupPricingBehavior, aC as INPUT_FIELD_TYPE, aD as IdempotencyMismatchError, aE as InputFieldType, aF as InputFieldValidation, aG as InventoryType, aH as KnowledgeArticle, aI as LineConfiguration, aJ as LocationProductPrice, aK as LocationValue, aL as MeasurementValue, aM as Money, aN as PRODUCT_TYPE, aO as Pagination, aP as PaginationParams, aQ as PhoneValue, aR as Price, aS as PriceAdjustment, aT as PriceDecisionPath, aU as PriceEntryType, aV as PricePathTaxInfo, aW as PriceSource, aX as Product, aY as ProductAddOn, aZ as ProductAvailability, a_ as ProductAvailabilityNow, a$ as ProductBillingPlan, b0 as ProductDealInfo, b1 as ProductInputField, b2 as ProductProperty, b3 as ProductRenderHint, b4 as ProductTaxonomy, b5 as ProductTimeProfile, b6 as ProductType, b7 as ProductVariant, b8 as ProductVariantValue, ba as PropertyFacet, bb as PropertySource, bc as QuantityPricingTier, bd as RENDER_HINT, be as RelatedProductView, bf as SalesChannel, bg as SchedulingMode, bh as SelectedAddOnOption, bi as SemanticKind, bj as SignatureValue, bk as Subscription, bl as SubscriptionInvoice, bm as SubscriptionItem, bn as SubscriptionStatus, bo as SubscriptionWithDetails, bp as Tag, bq as TagsResponse, br as TaxPathComponent, bs as TaxonomyAttributeTemplate, bt as TaxonomyWithChildren, bu as UICart, bv as UICartBusiness, bw as UICartCustomer, bx as UICartLocation, by as UICartPricing, bz as UpdateCartItemInput, bA as VariantAxis, bB as VariantAxisSelection, bC as VariantAxisValue, bD as VariantAxisValueView, bE as VariantAxisView, bF as VariantAxisWithValues, bG as VariantDetails, bH as VariantDetailsDTO, bI as VariantDisplayAttribute, bJ as VariantLocationAvailability, bK as VariantStrategy, bL as VariantView, bM as ZERO, bN as currencyCode, bO as enrichError, bP as getErrorHint, bQ as isCimplifyError, bR as isIdempotencyMismatchError, bS as isQuoteConflictRequiringConsent, bT as isQuoteError, bU as isRetryableError, bV as isSupportedCurrency, bW as money, bX as moneyFromNumber } from './product-B_kS4Oxa.mjs';
|
|
4
4
|
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, c as categorizePaymentError, d as detectMobileMoneyProvider, f as formatMoney, a as formatNumberCompact, b as formatPrice, e as formatPriceAdjustment, g as formatPriceCompact, h as formatPriceRange, i as formatPriceWithTax, j as formatProductPrice, k as getBasePrice, l as getCurrencySymbol, m as getDiscountPercentage, n as getDisplayPrice, o as getMarkupPercentage, p as getPriceRange, q as getProductCurrency, r as getTaxAmount, s as getUnitPriceAtQuantity, t as hasTaxInfo, u as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, y as isTaxInclusive, z as isValidPhoneForContext, A as normalizePaymentResponse, B as normalizePhoneToE164, D as normalizeStatusResponse, E as parsePrice, F as resolvePhoneCountryCode } from './index-D8vnKlOQ.mjs';
|
|
5
|
-
export { A as AdConfig, a as AdContextValue, b as AdCreative, c as AdPosition, d as AdSlot, e as AdTheme, S as SignInOptions, g as getVariantDisplayName, s as startSignIn } from './sign-in-
|
|
5
|
+
export { A as AdConfig, a as AdContextValue, b as AdCreative, c as AdPosition, d as AdSlot, e as AdTheme, S as SignInOptions, g as getVariantDisplayName, s as startSignIn } from './sign-in-CZ2ioBAP.mjs';
|
|
6
6
|
export { A as AddressAuthorizationData, a as AuthorizationType, I as InitializePaymentResult, P as Payment, b as PaymentErrorDetails, c as PaymentMethod, d as PaymentMethodType, e as PaymentProcessingState, f as PaymentProvider, g as PaymentResponse, h as PaymentStatus, i as PaymentStatusResponse, S as SubmitAuthorizationInput } from './payment-DVS7ZUEp.mjs';
|
|
7
7
|
export { F as FormatCompactOptions, a as FormatPriceOptions, P as ProductWithPrice } from './price-Cm0tU0V5.mjs';
|
|
8
8
|
export { generateIdempotencyKey } from './advanced.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { A as AUTHORIZATION_TYPE, a as AUTH_MUTATION, b as AbortablePromise, c a
|
|
|
2
2
|
import { b9 as ProductWithDetails, j as ApiError } from './product-B_kS4Oxa.js';
|
|
3
3
|
export { A as AddOn, a as AddOnDetails, b as AddOnGroupDetails, c as AddOnOption, d as AddOnOptionDetails, e as AddOnOptionPrice, f as AddOnWithOptions, g as AddToCartInput, h as AddressValue, i as AdjustmentType, k as AppliedDiscount, l as AttributeAppliesTo, m as AttributeType, n as AttributeValidationRules, o as AttributeVisibility, B as BenefitType, p as BillingFrequency, q as BillingMarkupType, r as BillingPlanType, s as Bundle, t as BundleComponentData, u as BundleComponentInfo, v as BundleComponentVariantView, w as BundleComponentView, x as BundlePriceType, y as BundleProduct, z as BundleSelectionData, C as BundleSelectionInput, D as BundleStoredSelection, E as BundleSummary, F as BundleWithDetails, G as Cart, H as CartAddOn, I as CartChannel, J as CartItem, K as CartItemDetails, L as CartMutationResult, M as CartNotice, N as CartStatus, O as CartSummary, P as CartTotals, Q as Category, R as CategorySummary, S as ChosenPrice, T as CimplifyError, U as Collection, V as CollectionProduct, W as CollectionSummary, X as ComponentGroup, Y as ComponentGroupWithComponents, Z as ComponentPriceBreakdown, _ as ComponentSchedulingData, $ as ComponentSelectionInput, a0 as ComponentSourceType, a1 as Composite, a2 as CompositeComponent, a3 as CompositeComponentView, a4 as CompositeGroupView, a5 as CompositePriceBreakdown, a6 as CompositePriceResult, a7 as CompositePricingMode, a8 as CompositeSelectionData, $ as CompositeSelectionInput, a9 as CompositeStoredSelection, aa as CompositeWithDetails, ab as CurrencyCode, ac as CustomAttributeDefinition, ad as CustomAttributeValue, ae as CustomerInputValue, af as DURATION_UNIT, ag as DateRangeValue, ah as Deal, ai as DealBenefitType, aj as DepositType, ak as DigitalProductType, al as DiscountBreakdown, am as DiscountDetails, an as DiscountValidation, ao as DisplayAddOn, ap as DisplayAddOnOption, aq as DisplayCart, ar as DisplayCartItem, as as DisplayMode, at as DurationUnit, au as ERROR_HINTS, av as EligiblePlansQuery, aw as ErrorCode, ax as ErrorCodeType, ay as ErrorHint, az as FacetValue, aA as FormattedPlanOption, aB as GroupPricingBehavior, aC as INPUT_FIELD_TYPE, aD as IdempotencyMismatchError, aE as InputFieldType, aF as InputFieldValidation, aG as InventoryType, aH as KnowledgeArticle, aI as LineConfiguration, aJ as LocationProductPrice, aK as LocationValue, aL as MeasurementValue, aM as Money, aN as PRODUCT_TYPE, aO as Pagination, aP as PaginationParams, aQ as PhoneValue, aR as Price, aS as PriceAdjustment, aT as PriceDecisionPath, aU as PriceEntryType, aV as PricePathTaxInfo, aW as PriceSource, aX as Product, aY as ProductAddOn, aZ as ProductAvailability, a_ as ProductAvailabilityNow, a$ as ProductBillingPlan, b0 as ProductDealInfo, b1 as ProductInputField, b2 as ProductProperty, b3 as ProductRenderHint, b4 as ProductTaxonomy, b5 as ProductTimeProfile, b6 as ProductType, b7 as ProductVariant, b8 as ProductVariantValue, ba as PropertyFacet, bb as PropertySource, bc as QuantityPricingTier, bd as RENDER_HINT, be as RelatedProductView, bf as SalesChannel, bg as SchedulingMode, bh as SelectedAddOnOption, bi as SemanticKind, bj as SignatureValue, bk as Subscription, bl as SubscriptionInvoice, bm as SubscriptionItem, bn as SubscriptionStatus, bo as SubscriptionWithDetails, bp as Tag, bq as TagsResponse, br as TaxPathComponent, bs as TaxonomyAttributeTemplate, bt as TaxonomyWithChildren, bu as UICart, bv as UICartBusiness, bw as UICartCustomer, bx as UICartLocation, by as UICartPricing, bz as UpdateCartItemInput, bA as VariantAxis, bB as VariantAxisSelection, bC as VariantAxisValue, bD as VariantAxisValueView, bE as VariantAxisView, bF as VariantAxisWithValues, bG as VariantDetails, bH as VariantDetailsDTO, bI as VariantDisplayAttribute, bJ as VariantLocationAvailability, bK as VariantStrategy, bL as VariantView, bM as ZERO, bN as currencyCode, bO as enrichError, bP as getErrorHint, bQ as isCimplifyError, bR as isIdempotencyMismatchError, bS as isQuoteConflictRequiringConsent, bT as isQuoteError, bU as isRetryableError, bV as isSupportedCurrency, bW as money, bX as moneyFromNumber } from './product-B_kS4Oxa.js';
|
|
4
4
|
export { C as CURRENCY_SYMBOLS, M as MOBILE_MONEY_PROVIDERS, c as categorizePaymentError, d as detectMobileMoneyProvider, f as formatMoney, a as formatNumberCompact, b as formatPrice, e as formatPriceAdjustment, g as formatPriceCompact, h as formatPriceRange, i as formatPriceWithTax, j as formatProductPrice, k as getBasePrice, l as getCurrencySymbol, m as getDiscountPercentage, n as getDisplayPrice, o as getMarkupPercentage, p as getPriceRange, q as getProductCurrency, r as getTaxAmount, s as getUnitPriceAtQuantity, t as hasTaxInfo, u as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, y as isTaxInclusive, z as isValidPhoneForContext, A as normalizePaymentResponse, B as normalizePhoneToE164, D as normalizeStatusResponse, E as parsePrice, F as resolvePhoneCountryCode } from './index-DIIlPUOC.js';
|
|
5
|
-
export { A as AdConfig, a as AdContextValue, b as AdCreative, c as AdPosition, d as AdSlot, e as AdTheme, S as SignInOptions, g as getVariantDisplayName, s as startSignIn } from './sign-in-
|
|
5
|
+
export { A as AdConfig, a as AdContextValue, b as AdCreative, c as AdPosition, d as AdSlot, e as AdTheme, S as SignInOptions, g as getVariantDisplayName, s as startSignIn } from './sign-in-CZ2ioBAP.js';
|
|
6
6
|
export { A as AddressAuthorizationData, a as AuthorizationType, I as InitializePaymentResult, P as Payment, b as PaymentErrorDetails, c as PaymentMethod, d as PaymentMethodType, e as PaymentProcessingState, f as PaymentProvider, g as PaymentResponse, h as PaymentStatus, i as PaymentStatusResponse, S as SubmitAuthorizationInput } from './payment-sn-yGL7v.js';
|
|
7
7
|
export { F as FormatCompactOptions, a as FormatPriceOptions, P as ProductWithPrice } from './price-9T1Y47oS.js';
|
|
8
8
|
export { generateIdempotencyKey } from './advanced.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk3QPO2UK5_js = require('./chunk-3QPO2UK5.js');
|
|
4
4
|
var chunkL5GKVQVJ_js = require('./chunk-L5GKVQVJ.js');
|
|
5
|
+
require('./chunk-LA2T2TPA.js');
|
|
5
6
|
var chunkMW7ICTVK_js = require('./chunk-MW7ICTVK.js');
|
|
6
7
|
var chunkJGBDWEPJ_js = require('./chunk-JGBDWEPJ.js');
|
|
7
8
|
var chunk7Y2O3E4D_js = require('./chunk-7Y2O3E4D.js');
|
|
@@ -24,8 +25,8 @@ async function signInSilent(opts) {
|
|
|
24
25
|
}
|
|
25
26
|
const authUrl = (opts.authUrl ?? DEFAULT_AUTH_URL).replace(/\/$/, "");
|
|
26
27
|
const callbackUri = opts.callbackUri ?? "/auth/callback";
|
|
27
|
-
const pkce = await
|
|
28
|
-
const state =
|
|
28
|
+
const pkce = await chunk3QPO2UK5_js.generatePkce();
|
|
29
|
+
const state = chunk3QPO2UK5_js.generateState();
|
|
29
30
|
const params = new URLSearchParams({
|
|
30
31
|
response_type: "code",
|
|
31
32
|
response_mode: "web_message",
|
|
@@ -95,51 +96,51 @@ async function signInSilent(opts) {
|
|
|
95
96
|
|
|
96
97
|
Object.defineProperty(exports, "CIMPLIFY_CDN_HOSTS", {
|
|
97
98
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
99
|
+
get: function () { return chunk3QPO2UK5_js.CIMPLIFY_CDN_HOSTS; }
|
|
99
100
|
});
|
|
100
101
|
Object.defineProperty(exports, "DEFAULT_CDN_BASE_URL", {
|
|
101
102
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
103
|
+
get: function () { return chunk3QPO2UK5_js.DEFAULT_CDN_BASE_URL; }
|
|
103
104
|
});
|
|
104
105
|
Object.defineProperty(exports, "DURATION_UNIT", {
|
|
105
106
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
107
|
+
get: function () { return chunk3QPO2UK5_js.DURATION_UNIT; }
|
|
107
108
|
});
|
|
108
109
|
Object.defineProperty(exports, "INPUT_FIELD_TYPE", {
|
|
109
110
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
111
|
+
get: function () { return chunk3QPO2UK5_js.INPUT_FIELD_TYPE; }
|
|
111
112
|
});
|
|
112
113
|
Object.defineProperty(exports, "PRODUCT_TYPE", {
|
|
113
114
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
115
|
+
get: function () { return chunk3QPO2UK5_js.PRODUCT_TYPE; }
|
|
115
116
|
});
|
|
116
117
|
Object.defineProperty(exports, "RENDER_HINT", {
|
|
117
118
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
119
|
+
get: function () { return chunk3QPO2UK5_js.RENDER_HINT; }
|
|
119
120
|
});
|
|
120
121
|
Object.defineProperty(exports, "allGalleryImages", {
|
|
121
122
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
123
|
+
get: function () { return chunk3QPO2UK5_js.allGalleryImages; }
|
|
123
124
|
});
|
|
124
125
|
Object.defineProperty(exports, "assetUrl", {
|
|
125
126
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
127
|
+
get: function () { return chunk3QPO2UK5_js.assetUrl; }
|
|
127
128
|
});
|
|
128
129
|
Object.defineProperty(exports, "getVariantDisplayName", {
|
|
129
130
|
enumerable: true,
|
|
130
|
-
get: function () { return
|
|
131
|
+
get: function () { return chunk3QPO2UK5_js.getVariantDisplayName; }
|
|
131
132
|
});
|
|
132
133
|
Object.defineProperty(exports, "isCimplifyAsset", {
|
|
133
134
|
enumerable: true,
|
|
134
|
-
get: function () { return
|
|
135
|
+
get: function () { return chunk3QPO2UK5_js.isCimplifyAsset; }
|
|
135
136
|
});
|
|
136
137
|
Object.defineProperty(exports, "resolveGallery", {
|
|
137
138
|
enumerable: true,
|
|
138
|
-
get: function () { return
|
|
139
|
+
get: function () { return chunk3QPO2UK5_js.resolveGallery; }
|
|
139
140
|
});
|
|
140
141
|
Object.defineProperty(exports, "startSignIn", {
|
|
141
142
|
enumerable: true,
|
|
142
|
-
get: function () { return
|
|
143
|
+
get: function () { return chunk3QPO2UK5_js.startSignIn; }
|
|
143
144
|
});
|
|
144
145
|
Object.defineProperty(exports, "isValidPhoneForContext", {
|
|
145
146
|
enumerable: true,
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { generatePkce, generateState } from './chunk-
|
|
2
|
-
export { CIMPLIFY_CDN_HOSTS, DEFAULT_CDN_BASE_URL, DURATION_UNIT, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT, allGalleryImages, assetUrl, getVariantDisplayName, isCimplifyAsset, resolveGallery, startSignIn } from './chunk-
|
|
1
|
+
import { generatePkce, generateState } from './chunk-TGAROSXB.mjs';
|
|
2
|
+
export { CIMPLIFY_CDN_HOSTS, DEFAULT_CDN_BASE_URL, DURATION_UNIT, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT, allGalleryImages, assetUrl, getVariantDisplayName, isCimplifyAsset, resolveGallery, startSignIn } from './chunk-TGAROSXB.mjs';
|
|
3
3
|
export { isValidPhoneForContext, normalizePhoneToE164, resolvePhoneCountryCode } from './chunk-YOIVZ6OA.mjs';
|
|
4
|
+
import './chunk-ZKTXRWP6.mjs';
|
|
4
5
|
export { ActivityService, CimplifyClient, DeliveryService, PlacesService, SubscriptionService, SupportService, UploadService, createCimplifyClient } from './chunk-SQ7U3BWY.mjs';
|
|
5
6
|
export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, SchedulingService, combine, combineObject, createElements, err, flatMap, fromPromise, generateIdempotencyKey, getOrElse, isErr, isOk, mapError, mapResult, ok, toNullable, tryCatch, unwrap } from './chunk-I4IXPQIX.mjs';
|
|
6
7
|
export { CURRENCY_SYMBOLS, MOBILE_MONEY_PROVIDERS, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceRange, formatPriceWithTax, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getPriceRange, getProductCurrency, getTaxAmount, getUnitPriceAtQuantity, hasTaxInfo, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isTaxInclusive, normalizePaymentResponse, normalizeStatusResponse, parsePrice } from './chunk-TD3AY34U.mjs';
|
package/dist/react.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React$1, { ReactNode } from 'react';
|
|
2
|
-
import { d as AdSlot, c as AdPosition, a as AdContextValue, S as SignInOptions } from './sign-in-
|
|
3
|
-
export { A as AdConfig, g as getVariantDisplayName } from './sign-in-
|
|
2
|
+
import { d as AdSlot, c as AdPosition, a as AdContextValue, S as SignInOptions } from './sign-in-CZ2ioBAP.mjs';
|
|
3
|
+
export { A as AdConfig, g as getVariantDisplayName } from './sign-in-CZ2ioBAP.mjs';
|
|
4
4
|
import { ac as CimplifyClient, c0 as ProcessCheckoutResult, a9 as CheckoutStatus, aa as CheckoutStatusContext, w as Business, bd as Location, ch as ReorderResult, bK as OrderStatus, bt as Order, c2 as QuoteBundleSelectionInput, c3 as QuoteCompositeSelectionInput, bY as PriceQuote, c6 as QuoteUiMessage, cC as Service, r as AvailableSlot, au as DayAvailability, am as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, cL as SessionMessage, c as ActivityRecommendation, aw as DeliveryFeeResponse, aX as FxRateResponse, cU as StorefrontBootstrap, X as ChatWidgetStarter, W as ChatMessage, h as AddressInfo, n as AuthenticatedData, aL as ElementsOptions, bS as PaymentMethodInfo, aJ as ElementsCheckoutResult, b$ as ProcessCheckoutOptions, af as CimplifyElements, b4 as LineItem, cO as Staff, cx as Room } from './client-DKg-5OWu.mjs';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { ab as CurrencyCode, aX as Product, aO as Pagination, T as CimplifyError, b9 as ProductWithDetails, Q as Category, aM as Money, C as BundleSelectionInput, $ as ComponentSelectionInput, z as BundleSelectionData, a8 as CompositeSelectionData, U as Collection, b4 as ProductTaxonomy, bt as TaxonomyWithChildren, b5 as ProductTimeProfile, ah as Deal, b0 as ProductDealInfo, an as DiscountValidation, E as BundleSummary, a6 as CompositePriceResult, bo as SubscriptionWithDetails, bn as SubscriptionStatus, bk as Subscription, ac as CustomAttributeDefinition, ba as PropertyFacet, a$ as ProductBillingPlan, bL as VariantView, bF as VariantAxisWithValues, f as AddOnWithOptions, w as BundleComponentView, x as BundlePriceType, a4 as CompositeGroupView, aq as DisplayCart, b1 as ProductInputField, bg as SchedulingMode, at as DurationUnit, ad as CustomAttributeValue, b2 as ProductProperty, bc as QuantityPricingTier } from './product-B_kS4Oxa.mjs';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React$1, { ReactNode } from 'react';
|
|
2
|
-
import { d as AdSlot, c as AdPosition, a as AdContextValue, S as SignInOptions } from './sign-in-
|
|
3
|
-
export { A as AdConfig, g as getVariantDisplayName } from './sign-in-
|
|
2
|
+
import { d as AdSlot, c as AdPosition, a as AdContextValue, S as SignInOptions } from './sign-in-CZ2ioBAP.js';
|
|
3
|
+
export { A as AdConfig, g as getVariantDisplayName } from './sign-in-CZ2ioBAP.js';
|
|
4
4
|
import { ac as CimplifyClient, c0 as ProcessCheckoutResult, a9 as CheckoutStatus, aa as CheckoutStatusContext, w as Business, bd as Location, ch as ReorderResult, bK as OrderStatus, bt as Order, c2 as QuoteBundleSelectionInput, c3 as QuoteCompositeSelectionInput, bY as PriceQuote, c6 as QuoteUiMessage, cC as Service, r as AvailableSlot, au as DayAvailability, am as CustomerBooking, L as CancelBookingResult, f as ActivityStateResponse, cL as SessionMessage, c as ActivityRecommendation, aw as DeliveryFeeResponse, aX as FxRateResponse, cU as StorefrontBootstrap, X as ChatWidgetStarter, W as ChatMessage, h as AddressInfo, n as AuthenticatedData, aL as ElementsOptions, bS as PaymentMethodInfo, aJ as ElementsCheckoutResult, b$ as ProcessCheckoutOptions, af as CimplifyElements, b4 as LineItem, cO as Staff, cx as Room } from './client-Dfg_hmkP.js';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { ab as CurrencyCode, aX as Product, aO as Pagination, T as CimplifyError, b9 as ProductWithDetails, Q as Category, aM as Money, C as BundleSelectionInput, $ as ComponentSelectionInput, z as BundleSelectionData, a8 as CompositeSelectionData, U as Collection, b4 as ProductTaxonomy, bt as TaxonomyWithChildren, b5 as ProductTimeProfile, ah as Deal, b0 as ProductDealInfo, an as DiscountValidation, E as BundleSummary, a6 as CompositePriceResult, bo as SubscriptionWithDetails, bn as SubscriptionStatus, bk as Subscription, ac as CustomAttributeDefinition, ba as PropertyFacet, a$ as ProductBillingPlan, bL as VariantView, bF as VariantAxisWithValues, f as AddOnWithOptions, w as BundleComponentView, x as BundlePriceType, a4 as CompositeGroupView, aq as DisplayCart, b1 as ProductInputField, bg as SchedulingMode, at as DurationUnit, ad as CustomAttributeValue, b2 as ProductProperty, bc as QuantityPricingTier } from './product-B_kS4Oxa.js';
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk3QPO2UK5_js = require('./chunk-3QPO2UK5.js');
|
|
5
|
+
require('./chunk-LA2T2TPA.js');
|
|
5
6
|
var chunkMW7ICTVK_js = require('./chunk-MW7ICTVK.js');
|
|
6
7
|
var chunkJGBDWEPJ_js = require('./chunk-JGBDWEPJ.js');
|
|
7
8
|
var chunk7Y2O3E4D_js = require('./chunk-7Y2O3E4D.js');
|
|
@@ -2714,7 +2715,7 @@ function CimplifySignInButton({
|
|
|
2714
2715
|
const onClick = async () => {
|
|
2715
2716
|
if (busy || disabled) return;
|
|
2716
2717
|
setBusy(true);
|
|
2717
|
-
await
|
|
2718
|
+
await chunk3QPO2UK5_js.startSignIn({
|
|
2718
2719
|
...signInOpts,
|
|
2719
2720
|
onSuccess: () => {
|
|
2720
2721
|
setBusy(false);
|
|
@@ -5463,7 +5464,7 @@ function VariantSelector({
|
|
|
5463
5464
|
{
|
|
5464
5465
|
"data-cimplify-variant-name": true,
|
|
5465
5466
|
className: cn("flex-1 min-w-0 text-sm", classNames?.name),
|
|
5466
|
-
children:
|
|
5467
|
+
children: chunk3QPO2UK5_js.getVariantDisplayName(variant, productName)
|
|
5467
5468
|
}
|
|
5468
5469
|
),
|
|
5469
5470
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-pricing": true, className: cn("text-sm text-muted-foreground", classNames?.pricing), children: [
|
|
@@ -6936,12 +6937,12 @@ function FieldInput({
|
|
|
6936
6937
|
classNames?.input
|
|
6937
6938
|
);
|
|
6938
6939
|
switch (field.field_type) {
|
|
6939
|
-
case
|
|
6940
|
-
case
|
|
6940
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Text:
|
|
6941
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Url:
|
|
6941
6942
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6942
6943
|
"input",
|
|
6943
6944
|
{
|
|
6944
|
-
type: field.field_type ===
|
|
6945
|
+
type: field.field_type === chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Url ? "url" : "text",
|
|
6945
6946
|
value: typeof value === "string" ? value : "",
|
|
6946
6947
|
onChange: (e) => onValueChange(e.target.value),
|
|
6947
6948
|
placeholder: field.placeholder,
|
|
@@ -6950,7 +6951,7 @@ function FieldInput({
|
|
|
6950
6951
|
className: inputClass
|
|
6951
6952
|
}
|
|
6952
6953
|
);
|
|
6953
|
-
case
|
|
6954
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Textarea:
|
|
6954
6955
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6955
6956
|
"textarea",
|
|
6956
6957
|
{
|
|
@@ -6963,7 +6964,7 @@ function FieldInput({
|
|
|
6963
6964
|
className: cn(inputClass, "resize-none", classNames?.textarea)
|
|
6964
6965
|
}
|
|
6965
6966
|
);
|
|
6966
|
-
case
|
|
6967
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Number:
|
|
6967
6968
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6968
6969
|
"input",
|
|
6969
6970
|
{
|
|
@@ -6977,7 +6978,7 @@ function FieldInput({
|
|
|
6977
6978
|
className: inputClass
|
|
6978
6979
|
}
|
|
6979
6980
|
);
|
|
6980
|
-
case
|
|
6981
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Select:
|
|
6981
6982
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6982
6983
|
"select",
|
|
6983
6984
|
{
|
|
@@ -6991,7 +6992,7 @@ function FieldInput({
|
|
|
6991
6992
|
]
|
|
6992
6993
|
}
|
|
6993
6994
|
);
|
|
6994
|
-
case
|
|
6995
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Radio:
|
|
6995
6996
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("space-y-2", classNames?.radioGroup), children: (field.options || []).map((opt) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6996
6997
|
"label",
|
|
6997
6998
|
{
|
|
@@ -7016,7 +7017,7 @@ function FieldInput({
|
|
|
7016
7017
|
},
|
|
7017
7018
|
opt
|
|
7018
7019
|
)) });
|
|
7019
|
-
case
|
|
7020
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Checkbox:
|
|
7020
7021
|
return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: cn("flex items-center gap-2 text-sm cursor-pointer", classNames?.checkboxLabel), children: [
|
|
7021
7022
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7022
7023
|
"input",
|
|
@@ -7029,7 +7030,7 @@ function FieldInput({
|
|
|
7029
7030
|
),
|
|
7030
7031
|
field.placeholder || field.name
|
|
7031
7032
|
] });
|
|
7032
|
-
case
|
|
7033
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Color:
|
|
7033
7034
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7034
7035
|
"input",
|
|
7035
7036
|
{
|
|
@@ -7039,7 +7040,7 @@ function FieldInput({
|
|
|
7039
7040
|
className: cn("w-12 h-10 rounded-md border border-input cursor-pointer", classNames?.colorInput)
|
|
7040
7041
|
}
|
|
7041
7042
|
);
|
|
7042
|
-
case
|
|
7043
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Date:
|
|
7043
7044
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7044
7045
|
DatePicker,
|
|
7045
7046
|
{
|
|
@@ -7050,8 +7051,8 @@ function FieldInput({
|
|
|
7050
7051
|
"aria-label": field.name
|
|
7051
7052
|
}
|
|
7052
7053
|
);
|
|
7053
|
-
case
|
|
7054
|
-
case
|
|
7054
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.File:
|
|
7055
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Image:
|
|
7055
7056
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7056
7057
|
FileUploadInput,
|
|
7057
7058
|
{
|
|
@@ -7062,7 +7063,7 @@ function FieldInput({
|
|
|
7062
7063
|
classNames
|
|
7063
7064
|
}
|
|
7064
7065
|
);
|
|
7065
|
-
case
|
|
7066
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Email:
|
|
7066
7067
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7067
7068
|
"input",
|
|
7068
7069
|
{
|
|
@@ -7074,7 +7075,7 @@ function FieldInput({
|
|
|
7074
7075
|
className: inputClass
|
|
7075
7076
|
}
|
|
7076
7077
|
);
|
|
7077
|
-
case
|
|
7078
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.DateTime: {
|
|
7078
7079
|
const stringValue = typeof value === "string" ? value : "";
|
|
7079
7080
|
const [datePart, timePartRaw] = stringValue.includes("T") ? stringValue.split("T", 2) : [stringValue, ""];
|
|
7080
7081
|
const timePart = (timePartRaw ?? "").slice(0, 5);
|
|
@@ -7113,7 +7114,7 @@ function FieldInput({
|
|
|
7113
7114
|
)
|
|
7114
7115
|
] });
|
|
7115
7116
|
}
|
|
7116
|
-
case
|
|
7117
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Time:
|
|
7117
7118
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7118
7119
|
TimePicker,
|
|
7119
7120
|
{
|
|
@@ -7124,7 +7125,7 @@ function FieldInput({
|
|
|
7124
7125
|
"aria-label": field.name
|
|
7125
7126
|
}
|
|
7126
7127
|
);
|
|
7127
|
-
case
|
|
7128
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.MultiSelect:
|
|
7128
7129
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7129
7130
|
MultiSelectInput,
|
|
7130
7131
|
{
|
|
@@ -7134,7 +7135,7 @@ function FieldInput({
|
|
|
7134
7135
|
classNames
|
|
7135
7136
|
}
|
|
7136
7137
|
);
|
|
7137
|
-
case
|
|
7138
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.DateRange:
|
|
7138
7139
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7139
7140
|
DateRangeInput,
|
|
7140
7141
|
{
|
|
@@ -7144,7 +7145,7 @@ function FieldInput({
|
|
|
7144
7145
|
classNames
|
|
7145
7146
|
}
|
|
7146
7147
|
);
|
|
7147
|
-
case
|
|
7148
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Address:
|
|
7148
7149
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7149
7150
|
AddressInput,
|
|
7150
7151
|
{
|
|
@@ -7155,7 +7156,7 @@ function FieldInput({
|
|
|
7155
7156
|
inputClass
|
|
7156
7157
|
}
|
|
7157
7158
|
);
|
|
7158
|
-
case
|
|
7159
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Location:
|
|
7159
7160
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7160
7161
|
LocationInput,
|
|
7161
7162
|
{
|
|
@@ -7166,7 +7167,7 @@ function FieldInput({
|
|
|
7166
7167
|
inputClass
|
|
7167
7168
|
}
|
|
7168
7169
|
);
|
|
7169
|
-
case
|
|
7170
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Phone:
|
|
7170
7171
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7171
7172
|
PhoneInput,
|
|
7172
7173
|
{
|
|
@@ -7177,7 +7178,7 @@ function FieldInput({
|
|
|
7177
7178
|
inputClass
|
|
7178
7179
|
}
|
|
7179
7180
|
);
|
|
7180
|
-
case
|
|
7181
|
+
case chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Signature:
|
|
7181
7182
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7182
7183
|
SignatureInput,
|
|
7183
7184
|
{
|
|
@@ -7210,7 +7211,7 @@ function FileUploadInput({
|
|
|
7210
7211
|
const [isUploading, setIsUploading] = React12__default.default.useState(false);
|
|
7211
7212
|
const fileUrl = typeof value === "string" ? value : void 0;
|
|
7212
7213
|
const acceptedFormats = field.validation?.accepted_formats;
|
|
7213
|
-
const accept = acceptedFormats ? acceptedFormats.map((f) => `.${f}`).join(",") : field.field_type ===
|
|
7214
|
+
const accept = acceptedFormats ? acceptedFormats.map((f) => `.${f}`).join(",") : field.field_type === chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Image ? "image/*" : void 0;
|
|
7214
7215
|
const handleFile = async (file) => {
|
|
7215
7216
|
if (!onFileUpload) return;
|
|
7216
7217
|
if (field.validation?.max_size_mb) {
|
|
@@ -7228,7 +7229,7 @@ function FileUploadInput({
|
|
|
7228
7229
|
}
|
|
7229
7230
|
};
|
|
7230
7231
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("space-y-2", classNames?.fileInput), children: fileUrl ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
7231
|
-
field.field_type ===
|
|
7232
|
+
field.field_type === chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Image && /* @__PURE__ */ jsxRuntime.jsx("img", { src: fileUrl, alt: "Uploaded", className: "w-16 h-16 object-cover rounded-md border border-border" }),
|
|
7232
7233
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-foreground truncate", children: fileUrl.split("/").pop() }) }),
|
|
7233
7234
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7234
7235
|
"button",
|
|
@@ -7254,7 +7255,7 @@ function FileUploadInput({
|
|
|
7254
7255
|
}
|
|
7255
7256
|
),
|
|
7256
7257
|
isUploading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Uploading..." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7257
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: field.placeholder || `Upload ${field.field_type ===
|
|
7258
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: field.placeholder || `Upload ${field.field_type === chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Image ? "image" : "file"}` }),
|
|
7258
7259
|
acceptedFormats && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground/60 mt-1", children: [
|
|
7259
7260
|
acceptedFormats.map((f) => f.toUpperCase()).join(", "),
|
|
7260
7261
|
field.validation?.max_size_mb && ` \xB7 Max ${field.validation.max_size_mb}MB`
|
|
@@ -8876,7 +8877,7 @@ function CartLineItemRow({
|
|
|
8876
8877
|
const isOptimistic = item.isOptimistic === true;
|
|
8877
8878
|
const lineTotal = chunk7Y2O3E4D_js.parsePrice(unitPrice) * item.quantity;
|
|
8878
8879
|
const imageUrl = item.product.image_url;
|
|
8879
|
-
const variantLabel = item.variant ?
|
|
8880
|
+
const variantLabel = item.variant ? chunk3QPO2UK5_js.getVariantDisplayName(item.variant, item.product.name) : null;
|
|
8880
8881
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8881
8882
|
"div",
|
|
8882
8883
|
{
|
|
@@ -8976,7 +8977,7 @@ function CartLineItemRow({
|
|
|
8976
8977
|
input.field_name,
|
|
8977
8978
|
":"
|
|
8978
8979
|
] }),
|
|
8979
|
-
/* @__PURE__ */ jsxRuntime.jsx("dd", { "data-cimplify-cart-input-value": true, className: "text-foreground m-0 truncate", children: input.field_type ===
|
|
8980
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { "data-cimplify-cart-input-value": true, className: "text-foreground m-0 truncate", children: input.field_type === chunk3QPO2UK5_js.INPUT_FIELD_TYPE.File || input.field_type === chunk3QPO2UK5_js.INPUT_FIELD_TYPE.Image ? String(input.value).split("/").pop() || "Uploaded file" : String(input.value) })
|
|
8980
8981
|
] }, input.field_id)) }),
|
|
8981
8982
|
(item.lineType === "service" || item.product.type === "service") && item.scheduledStart && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-service-info": true, className: cn("mt-1.5 flex items-center gap-1.5 text-xs text-muted-foreground", classNames?.serviceInfo), children: [
|
|
8982
8983
|
/* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-3.5 h-3.5 shrink-0", fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 24 24", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }) }),
|
|
@@ -9532,7 +9533,7 @@ function FoodProductCard({
|
|
|
9532
9533
|
const tags = product.tags || [];
|
|
9533
9534
|
const isSignature = product.metadata?.is_signature === true;
|
|
9534
9535
|
const isNew = product.metadata?.is_new === true;
|
|
9535
|
-
const isComposite = product.type ===
|
|
9536
|
+
const isComposite = product.type === chunk3QPO2UK5_js.PRODUCT_TYPE.Composite;
|
|
9536
9537
|
return /* @__PURE__ */ jsxRuntime.jsxs(CardShell, { product, renderLink, className, children: [
|
|
9537
9538
|
/* @__PURE__ */ jsxRuntime.jsxs(CardImage, { src: image, alt: product.name, aspectRatio: "square", renderImage, children: [
|
|
9538
9539
|
isSignature && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "absolute top-3 left-3 inline-flex items-center gap-1 text-[11px] font-semibold tracking-wide bg-amber-50 text-amber-700 border border-amber-200/60 px-2 py-0.5 rounded-md", children: [
|
|
@@ -10285,26 +10286,26 @@ var BUILT_IN_CARDS = {
|
|
|
10285
10286
|
["composite" /* Composite */]: CompositeProductCard,
|
|
10286
10287
|
["subscription" /* Subscription */]: SubscriptionCard
|
|
10287
10288
|
};
|
|
10288
|
-
var RENTAL_UNITS = /* @__PURE__ */ new Set([
|
|
10289
|
-
var LEASE_UNITS = /* @__PURE__ */ new Set([
|
|
10289
|
+
var RENTAL_UNITS = /* @__PURE__ */ new Set([chunk3QPO2UK5_js.DURATION_UNIT.Days, chunk3QPO2UK5_js.DURATION_UNIT.Hours]);
|
|
10290
|
+
var LEASE_UNITS = /* @__PURE__ */ new Set([chunk3QPO2UK5_js.DURATION_UNIT.Weeks, chunk3QPO2UK5_js.DURATION_UNIT.Months, chunk3QPO2UK5_js.DURATION_UNIT.Years]);
|
|
10290
10291
|
function resolveCardVariant(product) {
|
|
10291
|
-
if (product.type ===
|
|
10292
|
+
if (product.type === chunk3QPO2UK5_js.PRODUCT_TYPE.Bundle) {
|
|
10292
10293
|
return "bundle" /* Bundle */;
|
|
10293
10294
|
}
|
|
10294
|
-
if (product.type ===
|
|
10295
|
+
if (product.type === chunk3QPO2UK5_js.PRODUCT_TYPE.Composite) {
|
|
10295
10296
|
return "composite" /* Composite */;
|
|
10296
10297
|
}
|
|
10297
10298
|
if (product.quantity_pricing && product.quantity_pricing.length > 1) {
|
|
10298
10299
|
return "wholesale" /* Wholesale */;
|
|
10299
10300
|
}
|
|
10300
|
-
if (product.type ===
|
|
10301
|
+
if (product.type === chunk3QPO2UK5_js.PRODUCT_TYPE.Digital) {
|
|
10301
10302
|
return "digital" /* Digital */;
|
|
10302
10303
|
}
|
|
10303
|
-
if (product.type ===
|
|
10304
|
+
if (product.type === chunk3QPO2UK5_js.PRODUCT_TYPE.Service) {
|
|
10304
10305
|
if (product.duration_unit && RENTAL_UNITS.has(product.duration_unit)) {
|
|
10305
10306
|
return "rental" /* Rental */;
|
|
10306
10307
|
}
|
|
10307
|
-
if (product.duration_unit ===
|
|
10308
|
+
if (product.duration_unit === chunk3QPO2UK5_js.DURATION_UNIT.Nights) {
|
|
10308
10309
|
return "accommodation" /* Accommodation */;
|
|
10309
10310
|
}
|
|
10310
10311
|
if (product.duration_unit && LEASE_UNITS.has(product.duration_unit)) {
|
|
@@ -10315,10 +10316,10 @@ function resolveCardVariant(product) {
|
|
|
10315
10316
|
}
|
|
10316
10317
|
return "standard" /* Standard */;
|
|
10317
10318
|
}
|
|
10318
|
-
if (product.render_hint ===
|
|
10319
|
+
if (product.render_hint === chunk3QPO2UK5_js.RENDER_HINT.Food) {
|
|
10319
10320
|
return "food" /* Food */;
|
|
10320
10321
|
}
|
|
10321
|
-
if (product.render_hint ===
|
|
10322
|
+
if (product.render_hint === chunk3QPO2UK5_js.RENDER_HINT.Physical) {
|
|
10322
10323
|
return "retail" /* Retail */;
|
|
10323
10324
|
}
|
|
10324
10325
|
return "retail" /* Retail */;
|
|
@@ -12624,7 +12625,7 @@ function DefaultProductLayout({
|
|
|
12624
12625
|
className
|
|
12625
12626
|
}) {
|
|
12626
12627
|
const [selectedVariantId, setSelectedVariantId] = React12__default.default.useState();
|
|
12627
|
-
const images =
|
|
12628
|
+
const images = chunk3QPO2UK5_js.resolveGallery(product, selectedVariantId);
|
|
12628
12629
|
const hasRange = product.quantity_pricing && product.quantity_pricing.length > 1 || product.variants && product.variants.length > 1;
|
|
12629
12630
|
const onSale = chunk7Y2O3E4D_js.isOnSale(product);
|
|
12630
12631
|
const hasPhysicalDetails = product.sku || product.vendor || product.material;
|
|
@@ -13260,25 +13261,25 @@ function resolveTemplateKey(product) {
|
|
|
13260
13261
|
if (typeof metaTemplate === "string" && metaTemplate.trim()) {
|
|
13261
13262
|
return metaTemplate.trim();
|
|
13262
13263
|
}
|
|
13263
|
-
if (product.type ===
|
|
13264
|
+
if (product.type === chunk3QPO2UK5_js.PRODUCT_TYPE.Bundle) {
|
|
13264
13265
|
return "bundle" /* Bundle */;
|
|
13265
13266
|
}
|
|
13266
|
-
if (product.type ===
|
|
13267
|
+
if (product.type === chunk3QPO2UK5_js.PRODUCT_TYPE.Composite) {
|
|
13267
13268
|
return "composite" /* Composite */;
|
|
13268
13269
|
}
|
|
13269
13270
|
if (product.quantity_pricing && product.quantity_pricing.length > 1) {
|
|
13270
13271
|
return "wholesale" /* Wholesale */;
|
|
13271
13272
|
}
|
|
13272
|
-
if (product.type ===
|
|
13273
|
+
if (product.type === chunk3QPO2UK5_js.PRODUCT_TYPE.Service) {
|
|
13273
13274
|
return "service" /* Service */;
|
|
13274
13275
|
}
|
|
13275
|
-
if (product.type ===
|
|
13276
|
+
if (product.type === chunk3QPO2UK5_js.PRODUCT_TYPE.Digital) {
|
|
13276
13277
|
return "digital" /* Digital */;
|
|
13277
13278
|
}
|
|
13278
|
-
if (product.render_hint ===
|
|
13279
|
+
if (product.render_hint === chunk3QPO2UK5_js.RENDER_HINT.Food) {
|
|
13279
13280
|
return "food" /* Food */;
|
|
13280
13281
|
}
|
|
13281
|
-
if (product.render_hint ===
|
|
13282
|
+
if (product.render_hint === chunk3QPO2UK5_js.RENDER_HINT.Physical) {
|
|
13282
13283
|
return "physical" /* Physical */;
|
|
13283
13284
|
}
|
|
13284
13285
|
return "default" /* Default */;
|
|
@@ -15504,7 +15505,7 @@ function SparkleIcon({ className }) {
|
|
|
15504
15505
|
|
|
15505
15506
|
Object.defineProperty(exports, "getVariantDisplayName", {
|
|
15506
15507
|
enumerable: true,
|
|
15507
|
-
get: function () { return
|
|
15508
|
+
get: function () { return chunk3QPO2UK5_js.getVariantDisplayName; }
|
|
15508
15509
|
});
|
|
15509
15510
|
exports.AccommodationCard = AccommodationCard;
|
|
15510
15511
|
exports.AccountContent = AccountContent;
|
package/dist/react.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, resolveGallery, startSignIn, RENDER_HINT } from './chunk-
|
|
3
|
-
export { getVariantDisplayName } from './chunk-
|
|
2
|
+
import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, resolveGallery, startSignIn, RENDER_HINT } from './chunk-TGAROSXB.mjs';
|
|
3
|
+
export { getVariantDisplayName } from './chunk-TGAROSXB.mjs';
|
|
4
|
+
import './chunk-ZKTXRWP6.mjs';
|
|
4
5
|
import { createCimplifyClient } from './chunk-SQ7U3BWY.mjs';
|
|
5
6
|
import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-I4IXPQIX.mjs';
|
|
6
7
|
import { formatPrice, parsePrice, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-TD3AY34U.mjs';
|
package/dist/server.d.mts
CHANGED
|
@@ -233,7 +233,18 @@ interface CallbackHandlerOptions extends OidcConfig {
|
|
|
233
233
|
redirectUri: string;
|
|
234
234
|
}
|
|
235
235
|
declare function handleOidcCallback(req: Request, opts: CallbackHandlerOptions): Promise<Response>;
|
|
236
|
+
interface RedirectCallbackOptions extends OidcConfig {
|
|
237
|
+
redirectUri: string;
|
|
238
|
+
defaultReturnTo?: string;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Completes the redirect sign-in flow. The browser lands here (a top-level GET
|
|
242
|
+
* to the storefront's registered redirect_uri) carrying ?code&state; the PKCE
|
|
243
|
+
* verifier rides along in the first-party cimplify_pkce cookie. Exchanges the
|
|
244
|
+
* code server-side, sets the session cookies, and 302s back to returnTo.
|
|
245
|
+
*/
|
|
246
|
+
declare function handleRedirectCallback(req: Request, opts: RedirectCallbackOptions): Promise<Response>;
|
|
236
247
|
declare function handleSessionRequest(req: Request, cfg: OidcConfig): Promise<Response>;
|
|
237
248
|
declare function getSessionFromCookieHeader(cfg: OidcConfig, cookieHeader: string | null | undefined): Promise<CimplifySession | null>;
|
|
238
249
|
|
|
239
|
-
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, type CallbackHandlerOptions, CimplifyClient, type CimplifySession, type CodeExchangeOptions, type CodeExchangeResult, type OidcConfig, type RevalidateProfile, type ServerClientOptions, buildAccessTokenCookie, buildSessionCookie, buildSignoutCookie, buildSignoutCookies, exchangeCode, getAccessTokenFromCookieHeader, getServerClient, getSessionFromCookieHeader, handleOidcCallback, handleSessionRequest, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions, verifyIdToken };
|
|
250
|
+
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, type CallbackHandlerOptions, CimplifyClient, type CimplifySession, type CodeExchangeOptions, type CodeExchangeResult, type OidcConfig, type RedirectCallbackOptions, type RevalidateProfile, type ServerClientOptions, buildAccessTokenCookie, buildSessionCookie, buildSignoutCookie, buildSignoutCookies, exchangeCode, getAccessTokenFromCookieHeader, getServerClient, getSessionFromCookieHeader, handleOidcCallback, handleRedirectCallback, handleSessionRequest, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions, verifyIdToken };
|
package/dist/server.d.ts
CHANGED
|
@@ -233,7 +233,18 @@ interface CallbackHandlerOptions extends OidcConfig {
|
|
|
233
233
|
redirectUri: string;
|
|
234
234
|
}
|
|
235
235
|
declare function handleOidcCallback(req: Request, opts: CallbackHandlerOptions): Promise<Response>;
|
|
236
|
+
interface RedirectCallbackOptions extends OidcConfig {
|
|
237
|
+
redirectUri: string;
|
|
238
|
+
defaultReturnTo?: string;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Completes the redirect sign-in flow. The browser lands here (a top-level GET
|
|
242
|
+
* to the storefront's registered redirect_uri) carrying ?code&state; the PKCE
|
|
243
|
+
* verifier rides along in the first-party cimplify_pkce cookie. Exchanges the
|
|
244
|
+
* code server-side, sets the session cookies, and 302s back to returnTo.
|
|
245
|
+
*/
|
|
246
|
+
declare function handleRedirectCallback(req: Request, opts: RedirectCallbackOptions): Promise<Response>;
|
|
236
247
|
declare function handleSessionRequest(req: Request, cfg: OidcConfig): Promise<Response>;
|
|
237
248
|
declare function getSessionFromCookieHeader(cfg: OidcConfig, cookieHeader: string | null | undefined): Promise<CimplifySession | null>;
|
|
238
249
|
|
|
239
|
-
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, type CallbackHandlerOptions, CimplifyClient, type CimplifySession, type CodeExchangeOptions, type CodeExchangeResult, type OidcConfig, type RevalidateProfile, type ServerClientOptions, buildAccessTokenCookie, buildSessionCookie, buildSignoutCookie, buildSignoutCookies, exchangeCode, getAccessTokenFromCookieHeader, getServerClient, getSessionFromCookieHeader, handleOidcCallback, handleSessionRequest, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions, verifyIdToken };
|
|
250
|
+
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, type CacheLifeDefault, type CacheLifeProbe, type CallbackHandlerOptions, CimplifyClient, type CimplifySession, type CodeExchangeOptions, type CodeExchangeResult, type OidcConfig, type RedirectCallbackOptions, type RevalidateProfile, type ServerClientOptions, buildAccessTokenCookie, buildSessionCookie, buildSignoutCookie, buildSignoutCookies, exchangeCode, getAccessTokenFromCookieHeader, getServerClient, getSessionFromCookieHeader, handleOidcCallback, handleRedirectCallback, handleSessionRequest, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions, verifyIdToken };
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkLA2T2TPA_js = require('./chunk-LA2T2TPA.js');
|
|
3
4
|
var chunkMW7ICTVK_js = require('./chunk-MW7ICTVK.js');
|
|
4
5
|
require('./chunk-JGBDWEPJ.js');
|
|
5
6
|
require('./chunk-7Y2O3E4D.js');
|
|
@@ -240,6 +241,11 @@ async function refreshPage() {
|
|
|
240
241
|
var DEFAULT_AUTH_URL = "https://auth.cimplify.io";
|
|
241
242
|
var SESSION_COOKIE = "cimplify_session";
|
|
242
243
|
var ACCESS_TOKEN_COOKIE = "cimplify_access";
|
|
244
|
+
var HEADER_LOCATION = "Location";
|
|
245
|
+
var PARAM_CODE = "code";
|
|
246
|
+
var PARAM_STATE = "state";
|
|
247
|
+
var PARAM_ERROR = "error";
|
|
248
|
+
var QUERY_AUTH_ERROR = "cimplify_auth_error";
|
|
243
249
|
var discoveryCache = /* @__PURE__ */ new Map();
|
|
244
250
|
var jwksCache = /* @__PURE__ */ new Map();
|
|
245
251
|
function authUrl(cfg) {
|
|
@@ -415,6 +421,56 @@ async function handleOidcCallback(req, opts) {
|
|
|
415
421
|
headers.append("Set-Cookie", buildAccessTokenCookie(opts, tokens.accessToken, tokens.expiresIn));
|
|
416
422
|
return new Response(JSON.stringify({ ok: true }), { status: 200, headers });
|
|
417
423
|
}
|
|
424
|
+
function readPkceCookie(cookieHeader) {
|
|
425
|
+
if (!cookieHeader) return null;
|
|
426
|
+
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkLA2T2TPA_js.PKCE_COOKIE}=`));
|
|
427
|
+
if (!match) return null;
|
|
428
|
+
return chunkLA2T2TPA_js.decodePkceState(match.slice(chunkLA2T2TPA_js.PKCE_COOKIE.length + 1));
|
|
429
|
+
}
|
|
430
|
+
function buildPkceClearCookie() {
|
|
431
|
+
return `${chunkLA2T2TPA_js.PKCE_COOKIE}=; Path=${chunkLA2T2TPA_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
|
|
432
|
+
}
|
|
433
|
+
function safeReturnPath(returnTo, fallback) {
|
|
434
|
+
if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
|
|
435
|
+
return fallback;
|
|
436
|
+
}
|
|
437
|
+
function withAuthError(path, reason) {
|
|
438
|
+
const sep = path.includes("?") ? "&" : "?";
|
|
439
|
+
return `${path}${sep}${QUERY_AUTH_ERROR}=${encodeURIComponent(reason)}`;
|
|
440
|
+
}
|
|
441
|
+
async function handleRedirectCallback(req, opts) {
|
|
442
|
+
const url = new URL(req.url);
|
|
443
|
+
const code = url.searchParams.get(PARAM_CODE);
|
|
444
|
+
const urlState = url.searchParams.get(PARAM_STATE);
|
|
445
|
+
const authError = url.searchParams.get(PARAM_ERROR);
|
|
446
|
+
const pkce = readPkceCookie(req.headers.get("cookie"));
|
|
447
|
+
const returnTo = safeReturnPath(pkce?.returnTo, opts.defaultReturnTo ?? "/");
|
|
448
|
+
const fail = (reason) => {
|
|
449
|
+
const headers2 = new Headers({ [HEADER_LOCATION]: withAuthError(returnTo, reason) });
|
|
450
|
+
headers2.append("Set-Cookie", buildPkceClearCookie());
|
|
451
|
+
return new Response(null, { status: 302, headers: headers2 });
|
|
452
|
+
};
|
|
453
|
+
if (authError) return fail(authError);
|
|
454
|
+
if (!code || !pkce) return fail("missing_code");
|
|
455
|
+
if (!urlState || urlState !== pkce.state) return fail("state_mismatch");
|
|
456
|
+
let tokens;
|
|
457
|
+
try {
|
|
458
|
+
tokens = await exchangeCode({ ...opts, code, codeVerifier: pkce.verifier });
|
|
459
|
+
} catch {
|
|
460
|
+
return fail("exchange_failed");
|
|
461
|
+
}
|
|
462
|
+
if (!tokens.idToken) return fail("missing_id_token");
|
|
463
|
+
try {
|
|
464
|
+
await verifyIdToken(opts, tokens.idToken);
|
|
465
|
+
} catch {
|
|
466
|
+
return fail("id_token_invalid");
|
|
467
|
+
}
|
|
468
|
+
const headers = new Headers({ [HEADER_LOCATION]: returnTo });
|
|
469
|
+
headers.append("Set-Cookie", buildSessionCookie(opts, tokens.idToken, tokens.expiresIn));
|
|
470
|
+
headers.append("Set-Cookie", buildAccessTokenCookie(opts, tokens.accessToken, tokens.expiresIn));
|
|
471
|
+
headers.append("Set-Cookie", buildPkceClearCookie());
|
|
472
|
+
return new Response(null, { status: 302, headers });
|
|
473
|
+
}
|
|
418
474
|
async function handleSessionRequest(req, cfg) {
|
|
419
475
|
const session = await getSessionFromCookieHeader(cfg, req.headers.get("cookie"));
|
|
420
476
|
if (!session) {
|
|
@@ -458,6 +514,7 @@ exports.getAccessTokenFromCookieHeader = getAccessTokenFromCookieHeader;
|
|
|
458
514
|
exports.getServerClient = getServerClient;
|
|
459
515
|
exports.getSessionFromCookieHeader = getSessionFromCookieHeader;
|
|
460
516
|
exports.handleOidcCallback = handleOidcCallback;
|
|
517
|
+
exports.handleRedirectCallback = handleRedirectCallback;
|
|
461
518
|
exports.handleSessionRequest = handleSessionRequest;
|
|
462
519
|
exports.refreshPage = refreshPage;
|
|
463
520
|
exports.revalidateAddOn = revalidateAddOn;
|
package/dist/server.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH } from './chunk-ZKTXRWP6.mjs';
|
|
1
2
|
import { createCimplifyClient } from './chunk-SQ7U3BWY.mjs';
|
|
2
3
|
import './chunk-I4IXPQIX.mjs';
|
|
3
4
|
import './chunk-TD3AY34U.mjs';
|
|
@@ -238,6 +239,11 @@ async function refreshPage() {
|
|
|
238
239
|
var DEFAULT_AUTH_URL = "https://auth.cimplify.io";
|
|
239
240
|
var SESSION_COOKIE = "cimplify_session";
|
|
240
241
|
var ACCESS_TOKEN_COOKIE = "cimplify_access";
|
|
242
|
+
var HEADER_LOCATION = "Location";
|
|
243
|
+
var PARAM_CODE = "code";
|
|
244
|
+
var PARAM_STATE = "state";
|
|
245
|
+
var PARAM_ERROR = "error";
|
|
246
|
+
var QUERY_AUTH_ERROR = "cimplify_auth_error";
|
|
241
247
|
var discoveryCache = /* @__PURE__ */ new Map();
|
|
242
248
|
var jwksCache = /* @__PURE__ */ new Map();
|
|
243
249
|
function authUrl(cfg) {
|
|
@@ -413,6 +419,56 @@ async function handleOidcCallback(req, opts) {
|
|
|
413
419
|
headers.append("Set-Cookie", buildAccessTokenCookie(opts, tokens.accessToken, tokens.expiresIn));
|
|
414
420
|
return new Response(JSON.stringify({ ok: true }), { status: 200, headers });
|
|
415
421
|
}
|
|
422
|
+
function readPkceCookie(cookieHeader) {
|
|
423
|
+
if (!cookieHeader) return null;
|
|
424
|
+
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${PKCE_COOKIE}=`));
|
|
425
|
+
if (!match) return null;
|
|
426
|
+
return decodePkceState(match.slice(PKCE_COOKIE.length + 1));
|
|
427
|
+
}
|
|
428
|
+
function buildPkceClearCookie() {
|
|
429
|
+
return `${PKCE_COOKIE}=; Path=${PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
|
|
430
|
+
}
|
|
431
|
+
function safeReturnPath(returnTo, fallback) {
|
|
432
|
+
if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
|
|
433
|
+
return fallback;
|
|
434
|
+
}
|
|
435
|
+
function withAuthError(path, reason) {
|
|
436
|
+
const sep = path.includes("?") ? "&" : "?";
|
|
437
|
+
return `${path}${sep}${QUERY_AUTH_ERROR}=${encodeURIComponent(reason)}`;
|
|
438
|
+
}
|
|
439
|
+
async function handleRedirectCallback(req, opts) {
|
|
440
|
+
const url = new URL(req.url);
|
|
441
|
+
const code = url.searchParams.get(PARAM_CODE);
|
|
442
|
+
const urlState = url.searchParams.get(PARAM_STATE);
|
|
443
|
+
const authError = url.searchParams.get(PARAM_ERROR);
|
|
444
|
+
const pkce = readPkceCookie(req.headers.get("cookie"));
|
|
445
|
+
const returnTo = safeReturnPath(pkce?.returnTo, opts.defaultReturnTo ?? "/");
|
|
446
|
+
const fail = (reason) => {
|
|
447
|
+
const headers2 = new Headers({ [HEADER_LOCATION]: withAuthError(returnTo, reason) });
|
|
448
|
+
headers2.append("Set-Cookie", buildPkceClearCookie());
|
|
449
|
+
return new Response(null, { status: 302, headers: headers2 });
|
|
450
|
+
};
|
|
451
|
+
if (authError) return fail(authError);
|
|
452
|
+
if (!code || !pkce) return fail("missing_code");
|
|
453
|
+
if (!urlState || urlState !== pkce.state) return fail("state_mismatch");
|
|
454
|
+
let tokens;
|
|
455
|
+
try {
|
|
456
|
+
tokens = await exchangeCode({ ...opts, code, codeVerifier: pkce.verifier });
|
|
457
|
+
} catch {
|
|
458
|
+
return fail("exchange_failed");
|
|
459
|
+
}
|
|
460
|
+
if (!tokens.idToken) return fail("missing_id_token");
|
|
461
|
+
try {
|
|
462
|
+
await verifyIdToken(opts, tokens.idToken);
|
|
463
|
+
} catch {
|
|
464
|
+
return fail("id_token_invalid");
|
|
465
|
+
}
|
|
466
|
+
const headers = new Headers({ [HEADER_LOCATION]: returnTo });
|
|
467
|
+
headers.append("Set-Cookie", buildSessionCookie(opts, tokens.idToken, tokens.expiresIn));
|
|
468
|
+
headers.append("Set-Cookie", buildAccessTokenCookie(opts, tokens.accessToken, tokens.expiresIn));
|
|
469
|
+
headers.append("Set-Cookie", buildPkceClearCookie());
|
|
470
|
+
return new Response(null, { status: 302, headers });
|
|
471
|
+
}
|
|
416
472
|
async function handleSessionRequest(req, cfg) {
|
|
417
473
|
const session = await getSessionFromCookieHeader(cfg, req.headers.get("cookie"));
|
|
418
474
|
if (!session) {
|
|
@@ -441,4 +497,4 @@ async function getSessionFromCookieHeader(cfg, cookieHeader) {
|
|
|
441
497
|
}
|
|
442
498
|
}
|
|
443
499
|
|
|
444
|
-
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, buildAccessTokenCookie, buildSessionCookie, buildSignoutCookie, buildSignoutCookies, exchangeCode, getAccessTokenFromCookieHeader, getServerClient, getSessionFromCookieHeader, handleOidcCallback, handleSessionRequest, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions, verifyIdToken };
|
|
500
|
+
export { CACHE_LIFE_DEFAULT, CACHE_LIFE_PROBE, buildAccessTokenCookie, buildSessionCookie, buildSignoutCookie, buildSignoutCookies, exchangeCode, getAccessTokenFromCookieHeader, getServerClient, getSessionFromCookieHeader, handleOidcCallback, handleRedirectCallback, handleSessionRequest, refreshPage, revalidateAddOn, revalidateAddOns, revalidateBrand, revalidateBusiness, revalidateByTag, revalidateCategories, revalidateCategory, revalidateCollection, revalidateCollections, revalidateLocation, revalidateLocations, revalidatePricing, revalidateProduct, revalidateProducts, revalidateStock, revalidateSubscription, revalidateSubscriptions, tags, updateAddOn, updateAddOns, updateBrand, updateBusiness, updateByTag, updateCategories, updateCategory, updateCollection, updateCollections, updateLocation, updateLocations, updatePricing, updateProduct, updateProducts, updateStock, updateSubscription, updateSubscriptions, verifyIdToken };
|
|
@@ -33,6 +33,15 @@ interface SignInOptions {
|
|
|
33
33
|
authUrl?: string;
|
|
34
34
|
loginHint?: string;
|
|
35
35
|
prompt?: "none" | "login" | "consent";
|
|
36
|
+
/**
|
|
37
|
+
* "redirect" (default) navigates the top-level window to the IdP and back —
|
|
38
|
+
* works in every browser, on any domain, because the IdP is first-party
|
|
39
|
+
* during the hop. "modal" opens an iframe and only works where third-party
|
|
40
|
+
* cookies are allowed (Chrome today; not Safari/Firefox).
|
|
41
|
+
*/
|
|
42
|
+
mode?: "redirect" | "modal";
|
|
43
|
+
/** Where to land after a successful redirect sign-in. Defaults to the current path. */
|
|
44
|
+
returnTo?: string;
|
|
36
45
|
onError?: (err: {
|
|
37
46
|
error: string;
|
|
38
47
|
description?: string;
|
|
@@ -33,6 +33,15 @@ interface SignInOptions {
|
|
|
33
33
|
authUrl?: string;
|
|
34
34
|
loginHint?: string;
|
|
35
35
|
prompt?: "none" | "login" | "consent";
|
|
36
|
+
/**
|
|
37
|
+
* "redirect" (default) navigates the top-level window to the IdP and back —
|
|
38
|
+
* works in every browser, on any domain, because the IdP is first-party
|
|
39
|
+
* during the hop. "modal" opens an iframe and only works where third-party
|
|
40
|
+
* cookies are allowed (Chrome today; not Safari/Firefox).
|
|
41
|
+
*/
|
|
42
|
+
mode?: "redirect" | "modal";
|
|
43
|
+
/** Where to land after a successful redirect sign-in. Defaults to the current path. */
|
|
44
|
+
returnTo?: string;
|
|
36
45
|
onError?: (err: {
|
|
37
46
|
error: string;
|
|
38
47
|
description?: string;
|