@cimplify/sdk 0.66.0 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/advanced.d.mts +1 -1
  2. package/dist/advanced.d.ts +1 -1
  3. package/dist/advanced.js +20 -20
  4. package/dist/advanced.mjs +1 -1
  5. package/dist/{chunk-J3MGY6AU.js → chunk-5HAUJBOK.js} +36 -82
  6. package/dist/chunk-E6T5VJMG.mjs +156 -0
  7. package/dist/{chunk-3G4QCENX.mjs → chunk-FVGVJ4TC.mjs} +12 -50
  8. package/dist/chunk-IQLJJW2H.js +168 -0
  9. package/dist/{chunk-227XTAEB.mjs → chunk-KNPE4WCQ.mjs} +2 -48
  10. package/dist/{chunk-H6DBPHMZ.js → chunk-NGQCWFKF.js} +4 -4
  11. package/dist/{chunk-R6363CC7.mjs → chunk-SOV4H6PQ.mjs} +509 -79
  12. package/dist/{chunk-HCZTBWU4.js → chunk-SXGFJEME.js} +12 -50
  13. package/dist/{chunk-MWI5GAUF.mjs → chunk-TAKORJP4.mjs} +2 -2
  14. package/dist/{chunk-AVQL3TSJ.js → chunk-WCSAZRNC.js} +519 -78
  15. package/dist/{client-CUrA1uQ0.d.mts → client-CBE7ksYC.d.mts} +1 -1
  16. package/dist/{client-Bo5rujc2.d.ts → client-CfeQRwhl.d.ts} +55 -21
  17. package/dist/{client-DasPHOJh.d.ts → client-DlXfZy7N.d.ts} +1 -1
  18. package/dist/{client-Dka2cGhu.d.mts → client-Dyo3dvNy.d.mts} +55 -21
  19. package/dist/index.d.mts +2 -2
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.js +104 -88
  22. package/dist/index.mjs +16 -12
  23. package/dist/mock/cli.mjs +12 -50
  24. package/dist/mock/library.js +12 -50
  25. package/dist/mock/library.mjs +12 -50
  26. package/dist/mock/msw.js +12 -50
  27. package/dist/mock/msw.mjs +12 -50
  28. package/dist/react.d.mts +44 -44
  29. package/dist/react.d.ts +44 -44
  30. package/dist/react.js +298 -175
  31. package/dist/react.mjs +240 -117
  32. package/dist/server.d.mts +2 -2
  33. package/dist/server.d.ts +2 -2
  34. package/dist/server.js +16 -9
  35. package/dist/server.mjs +11 -4
  36. package/dist/{sign-in-dr7m09nm.d.ts → sign-in-DQlIdqsi.d.mts} +14 -1
  37. package/dist/{sign-in-dr7m09nm.d.mts → sign-in-DQlIdqsi.d.ts} +14 -1
  38. package/dist/styles.css +1 -1
  39. package/dist/testing/msw.js +2 -2
  40. package/dist/testing/msw.mjs +1 -1
  41. package/dist/testing/suite.d.mts +2 -2
  42. package/dist/testing/suite.d.ts +2 -2
  43. package/dist/testing/suite.js +23 -23
  44. package/dist/testing/suite.mjs +4 -4
  45. package/dist/testing.d.mts +17 -17
  46. package/dist/testing.d.ts +17 -17
  47. package/dist/testing.js +79 -79
  48. package/dist/testing.mjs +5 -5
  49. package/package.json +1 -1
  50. package/registry/index.json +0 -9
  51. package/dist/chunk-3Z3FQH7X.mjs +0 -323
  52. package/dist/chunk-7BKKBJQM.mjs +0 -52
  53. package/dist/chunk-GDAGM26J.js +0 -338
  54. package/dist/chunk-KWYI2TTA.js +0 -60
  55. package/registry/account.json +0 -15
package/dist/react.mjs CHANGED
@@ -1,9 +1,8 @@
1
1
  "use client";
2
- import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, resolveGallery, startSignIn, RENDER_HINT } from './chunk-3Z3FQH7X.mjs';
3
- export { getVariantDisplayName } from './chunk-3Z3FQH7X.mjs';
4
- import './chunk-7BKKBJQM.mjs';
5
- import { createCimplifyClient } from './chunk-227XTAEB.mjs';
6
- import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-R6363CC7.mjs';
2
+ import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, resolveGallery, RENDER_HINT } from './chunk-E6T5VJMG.mjs';
3
+ export { getVariantDisplayName } from './chunk-E6T5VJMG.mjs';
4
+ import { createCimplifyClient } from './chunk-KNPE4WCQ.mjs';
5
+ import { ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-SOV4H6PQ.mjs';
7
6
  import { formatPrice, parsePrice, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-TD3AY34U.mjs';
8
7
  import { isSupportedCurrency } from './chunk-AMZXALF6.mjs';
9
8
  import './chunk-3G6RQLXK.mjs';
@@ -1658,100 +1657,6 @@ function CimplifyCheckout({
1658
1657
  function cn(...inputs) {
1659
1658
  return twMerge(clsx(inputs));
1660
1659
  }
1661
- var DEFAULT_LINK_URL = "https://link.cimplify.io";
1662
- function CimplifyAccount({
1663
- client: clientProp,
1664
- linkUrl,
1665
- section,
1666
- businessId: businessIdProp,
1667
- merchantName,
1668
- appearance,
1669
- onLogout,
1670
- className
1671
- }) {
1672
- const context = useOptionalCimplify();
1673
- const client = clientProp ?? context?.client;
1674
- const resolvedLinkUrl = linkUrl || DEFAULT_LINK_URL;
1675
- const resolvedBusinessId = businessIdProp || client?.getBusinessId?.() || "";
1676
- const iframeRef = useRef(null);
1677
- const [height, setHeight] = useState(400);
1678
- const [isReady, setIsReady] = useState(false);
1679
- const iframeSrc = useMemo(() => {
1680
- const path = section ? `/elements/account/${section}` : "/elements/account";
1681
- const url = new URL(path, resolvedLinkUrl);
1682
- if (resolvedBusinessId) url.searchParams.set("businessId", resolvedBusinessId);
1683
- return url.toString();
1684
- }, [resolvedLinkUrl, section, resolvedBusinessId]);
1685
- useEffect(() => {
1686
- function handleMessage(event) {
1687
- if (!event.data || typeof event.data !== "object") return;
1688
- if (iframeRef.current?.contentWindow && event.source !== iframeRef.current.contentWindow) {
1689
- return;
1690
- }
1691
- switch (event.data.type) {
1692
- case "ready":
1693
- setIsReady(true);
1694
- if (typeof event.data.height === "number") {
1695
- setHeight(event.data.height);
1696
- }
1697
- sendInit();
1698
- break;
1699
- case "height_change":
1700
- if (typeof event.data.height === "number") {
1701
- setHeight(event.data.height);
1702
- }
1703
- break;
1704
- case "logout_complete":
1705
- onLogout?.();
1706
- break;
1707
- }
1708
- }
1709
- window.addEventListener("message", handleMessage);
1710
- return () => window.removeEventListener("message", handleMessage);
1711
- }, [appearance, client, onLogout]);
1712
- function sendInit() {
1713
- const contentWindow = iframeRef.current?.contentWindow;
1714
- if (!contentWindow) return;
1715
- const token = client?.getAccessToken?.();
1716
- contentWindow.postMessage(
1717
- {
1718
- type: "init",
1719
- token: token ?? void 0,
1720
- appearance: appearance ?? void 0,
1721
- businessId: resolvedBusinessId || void 0,
1722
- merchantName: merchantName ?? void 0
1723
- },
1724
- resolvedLinkUrl
1725
- );
1726
- }
1727
- return /* @__PURE__ */ jsxs(
1728
- "div",
1729
- {
1730
- "data-cimplify-account": true,
1731
- className: cn("relative overflow-hidden", className),
1732
- children: [
1733
- !isReady && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsx("div", { className: "w-6 h-6 border-2 border-border border-t-foreground rounded-full animate-spin" }) }),
1734
- /* @__PURE__ */ jsx(
1735
- "iframe",
1736
- {
1737
- ref: iframeRef,
1738
- src: iframeSrc,
1739
- style: {
1740
- border: "none",
1741
- width: "100%",
1742
- height: `${height}px`,
1743
- display: isReady ? "block" : "none",
1744
- overflow: "hidden",
1745
- background: "transparent"
1746
- },
1747
- allow: "geolocation",
1748
- sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"
1749
- }
1750
- )
1751
- ]
1752
- }
1753
- );
1754
- }
1755
1660
  var BUTTON_BASE = "inline-flex items-center justify-center gap-2 font-semibold leading-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 disabled:opacity-50 disabled:cursor-not-allowed [font-family:inherit] cursor-pointer rounded-[10px]";
1756
1661
  var BUTTON_VARIANTS = {
1757
1662
  primary: "bg-foreground text-background hover:bg-foreground/90",
@@ -1983,6 +1888,17 @@ function Toast({ title, description, onUndo, onDismiss, className }) {
1983
1888
  }
1984
1889
  );
1985
1890
  }
1891
+
1892
+ // src/react/utils/avatar.ts
1893
+ function avatarGradient(seed) {
1894
+ let hash = 0;
1895
+ for (let i = 0; i < seed.length; i++) hash = (hash << 5) - hash + seed.charCodeAt(i) | 0;
1896
+ const hue = (Math.abs(hash) % 60 + 20) % 360;
1897
+ return `linear-gradient(135deg, oklch(0.78 0.10 ${hue}), oklch(0.55 0.16 ${hue - 8}))`;
1898
+ }
1899
+ function initials(name) {
1900
+ return name.trim().split(/\s+/).map((p) => p[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
1901
+ }
1986
1902
  function AccountShell({ sidebar, children, className }) {
1987
1903
  return /* @__PURE__ */ jsxs(
1988
1904
  "div",
@@ -2017,15 +1933,6 @@ function AccountSidebar({ children, scopeNote, className }) {
2017
1933
  }
2018
1934
  );
2019
1935
  }
2020
- function avatarGradient(seed) {
2021
- let hash = 0;
2022
- for (let i = 0; i < seed.length; i++) hash = (hash << 5) - hash + seed.charCodeAt(i) | 0;
2023
- const hue = (Math.abs(hash) % 60 + 20) % 360;
2024
- return `linear-gradient(135deg, oklch(0.78 0.10 ${hue}), oklch(0.55 0.16 ${hue - 8}))`;
2025
- }
2026
- function initials(name) {
2027
- return name.trim().split(/\s+/).map((p) => p[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
2028
- }
2029
1936
  function AccountIdentityStrip({
2030
1937
  name,
2031
1938
  email,
@@ -3346,6 +3253,229 @@ function useCimplifySession(options) {
3346
3253
  }, [fetchSession]);
3347
3254
  return { session, loading, refresh: fetchSession };
3348
3255
  }
3256
+ var DEFAULT_LINKS = [
3257
+ {
3258
+ label: "Your orders",
3259
+ href: "/account/orders",
3260
+ icon: /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
3261
+ /* @__PURE__ */ jsx("path", { d: "M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z" }),
3262
+ /* @__PURE__ */ jsx("path", { d: "M3 6h18" }),
3263
+ /* @__PURE__ */ jsx("path", { d: "M16 10a4 4 0 0 1-8 0" })
3264
+ ] })
3265
+ },
3266
+ {
3267
+ label: "Addresses",
3268
+ href: "/account/addresses",
3269
+ icon: /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
3270
+ /* @__PURE__ */ jsx("path", { d: "M12 21s-7-5.5-7-11a7 7 0 0 1 14 0c0 5.5-7 11-7 11Z" }),
3271
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "10", r: "2.5" })
3272
+ ] })
3273
+ },
3274
+ {
3275
+ label: "Payment methods",
3276
+ href: "/account/payment",
3277
+ icon: /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
3278
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
3279
+ /* @__PURE__ */ jsx("path", { d: "M2 10h20" })
3280
+ ] })
3281
+ },
3282
+ {
3283
+ label: "Account",
3284
+ href: "/account",
3285
+ icon: /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
3286
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" }),
3287
+ /* @__PURE__ */ jsx("path", { d: "M12 2v3M12 19v3M4.2 4.2l2.1 2.1M17.7 17.7l2.1 2.1M2 12h3M19 12h3M4.2 19.8l2.1-2.1M17.7 6.3l2.1-2.1" })
3288
+ ] })
3289
+ }
3290
+ ];
3291
+ var LinkIcon = /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
3292
+ /* @__PURE__ */ jsx("path", { d: "M10 13.5a4 4 0 0 0 5.6 0l3-3a4 4 0 0 0-5.6-5.6L11.5 6.4" }),
3293
+ /* @__PURE__ */ jsx("path", { d: "M14 10.5a4 4 0 0 0-5.6 0l-3 3a4 4 0 0 0 5.6 5.6l1.5-1.5" })
3294
+ ] });
3295
+ var ExternalIcon = /* @__PURE__ */ jsx("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": true, className: "ml-auto opacity-50", children: /* @__PURE__ */ jsx("path", { d: "M7 17 17 7M9 7h8v8" }) });
3296
+ function Avatar({ seed, name, size }) {
3297
+ return /* @__PURE__ */ jsx(
3298
+ "span",
3299
+ {
3300
+ "aria-hidden": true,
3301
+ className: "grid place-items-center rounded-full font-serif font-semibold text-white shrink-0",
3302
+ style: { width: size, height: size, fontSize: size * 0.4, background: avatarGradient(seed) },
3303
+ children: initials(name)
3304
+ }
3305
+ );
3306
+ }
3307
+ function CimplifyUserButton({
3308
+ session: controlledSession,
3309
+ sessionUri,
3310
+ links = DEFAULT_LINKS,
3311
+ identityUrl = "https://link.cimplify.io",
3312
+ signOutHref = "/auth/signout",
3313
+ onSignOut,
3314
+ clientId,
3315
+ redirectUri,
3316
+ signInLabel,
3317
+ onSignIn,
3318
+ hideName,
3319
+ align = "end",
3320
+ className
3321
+ }) {
3322
+ const controlled = controlledSession !== void 0;
3323
+ const hook = useCimplifySession({ sessionUri });
3324
+ const session = controlled ? controlledSession : hook.session;
3325
+ const loading = controlled ? false : hook.loading;
3326
+ const [open, setOpen] = useState(false);
3327
+ const rootRef = useRef(null);
3328
+ const menuId = useId();
3329
+ useEffect(() => {
3330
+ if (!open) return;
3331
+ const onDocClick = (e) => {
3332
+ if (!rootRef.current?.contains(e.target)) setOpen(false);
3333
+ };
3334
+ const onKey = (e) => {
3335
+ if (e.key === "Escape") setOpen(false);
3336
+ };
3337
+ document.addEventListener("mousedown", onDocClick);
3338
+ document.addEventListener("keydown", onKey);
3339
+ return () => {
3340
+ document.removeEventListener("mousedown", onDocClick);
3341
+ document.removeEventListener("keydown", onKey);
3342
+ };
3343
+ }, [open]);
3344
+ if (loading) {
3345
+ return /* @__PURE__ */ jsx("div", { className: cn("inline-flex items-center", className), "data-cimplify-user-button": "loading", children: /* @__PURE__ */ jsx("span", { className: "size-8 rounded-full bg-muted/60 animate-pulse" }) });
3346
+ }
3347
+ if (!session) {
3348
+ if (!clientId || !redirectUri) return null;
3349
+ return /* @__PURE__ */ jsx(
3350
+ CimplifySignInButton,
3351
+ {
3352
+ variant: "outline",
3353
+ label: signInLabel ?? "Sign in",
3354
+ clientId,
3355
+ redirectUri,
3356
+ onSuccess: onSignIn,
3357
+ className
3358
+ }
3359
+ );
3360
+ }
3361
+ const name = session.name?.trim() || session.email || "Account";
3362
+ const seed = session.sub || name;
3363
+ return /* @__PURE__ */ jsxs("div", { ref: rootRef, className: cn("relative inline-block", className), "data-cimplify-user-button": true, children: [
3364
+ /* @__PURE__ */ jsxs(
3365
+ "button",
3366
+ {
3367
+ type: "button",
3368
+ onClick: () => setOpen((v) => !v),
3369
+ "aria-haspopup": "menu",
3370
+ "aria-expanded": open,
3371
+ "aria-controls": menuId,
3372
+ className: cn(
3373
+ "inline-flex items-center gap-2 rounded-full border border-border bg-card p-1 pr-2.5",
3374
+ "shadow-[0_1px_2px_rgba(16,24,40,0.06)] transition-colors cursor-pointer",
3375
+ "hover:border-foreground/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
3376
+ hideName && "pr-1"
3377
+ ),
3378
+ children: [
3379
+ /* @__PURE__ */ jsx(Avatar, { seed, name, size: 28 }),
3380
+ !hideName && /* @__PURE__ */ jsx("span", { className: "max-w-[120px] truncate text-[13px] font-semibold text-foreground", children: session.name?.split(/\s+/)[0] || name }),
3381
+ /* @__PURE__ */ jsx(
3382
+ "svg",
3383
+ {
3384
+ width: "13",
3385
+ height: "13",
3386
+ viewBox: "0 0 24 24",
3387
+ fill: "none",
3388
+ stroke: "currentColor",
3389
+ strokeWidth: "2.2",
3390
+ "aria-hidden": true,
3391
+ className: cn("text-foreground/45 transition-transform", open && "rotate-180"),
3392
+ children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
3393
+ }
3394
+ )
3395
+ ]
3396
+ }
3397
+ ),
3398
+ open && /* @__PURE__ */ jsxs(
3399
+ "div",
3400
+ {
3401
+ id: menuId,
3402
+ role: "menu",
3403
+ className: cn(
3404
+ "absolute top-[calc(100%+8px)] z-50 w-[280px] overflow-hidden",
3405
+ "rounded-[14px] border border-border bg-card",
3406
+ "shadow-[0_1px_2px_rgba(16,24,40,0.04),0_16px_40px_-16px_rgba(16,24,40,0.24)]",
3407
+ align === "end" ? "right-0" : "left-0"
3408
+ ),
3409
+ children: [
3410
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 border-b border-border/60 p-3.5", children: [
3411
+ /* @__PURE__ */ jsx(Avatar, { seed, name, size: 40 }),
3412
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
3413
+ /* @__PURE__ */ jsx("div", { className: "truncate text-[14px] font-semibold text-foreground", children: name }),
3414
+ session.email && /* @__PURE__ */ jsx("div", { className: "truncate text-[12px] text-foreground/55", children: session.email })
3415
+ ] })
3416
+ ] }),
3417
+ /* @__PURE__ */ jsxs("div", { className: "p-1.5", children: [
3418
+ links.map((link) => /* @__PURE__ */ jsxs(
3419
+ "a",
3420
+ {
3421
+ role: "menuitem",
3422
+ href: link.href,
3423
+ target: link.external ? "_blank" : void 0,
3424
+ rel: link.external ? "noreferrer" : void 0,
3425
+ className: "flex items-center gap-3 rounded-[9px] px-3 py-2 text-[13.5px] text-foreground hover:bg-muted/50",
3426
+ children: [
3427
+ /* @__PURE__ */ jsx("span", { className: "text-foreground/45", children: link.icon }),
3428
+ link.label,
3429
+ link.external && ExternalIcon
3430
+ ]
3431
+ },
3432
+ link.href
3433
+ )),
3434
+ /* @__PURE__ */ jsx("div", { className: "my-1.5 h-px bg-border/60" }),
3435
+ /* @__PURE__ */ jsxs(
3436
+ "a",
3437
+ {
3438
+ role: "menuitem",
3439
+ href: identityUrl,
3440
+ target: "_blank",
3441
+ rel: "noreferrer",
3442
+ className: "flex items-center gap-3 rounded-[9px] px-3 py-2 text-[13.5px] text-foreground hover:bg-muted/50",
3443
+ children: [
3444
+ /* @__PURE__ */ jsx("span", { className: "text-foreground/45", children: LinkIcon }),
3445
+ "Manage Cimplify identity",
3446
+ ExternalIcon
3447
+ ]
3448
+ }
3449
+ ),
3450
+ /* @__PURE__ */ jsx(
3451
+ "form",
3452
+ {
3453
+ method: "post",
3454
+ action: signOutHref,
3455
+ onSubmit: onSignOut ? () => onSignOut() : void 0,
3456
+ children: /* @__PURE__ */ jsxs(
3457
+ "button",
3458
+ {
3459
+ type: "submit",
3460
+ role: "menuitem",
3461
+ className: "flex w-full items-center gap-3 rounded-[9px] px-3 py-2 text-[13.5px] text-destructive hover:bg-destructive/10",
3462
+ children: [
3463
+ /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": true, children: [
3464
+ /* @__PURE__ */ jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
3465
+ /* @__PURE__ */ jsx("path", { d: "m16 17 5-5-5-5M21 12H9" })
3466
+ ] }),
3467
+ "Sign out"
3468
+ ]
3469
+ }
3470
+ )
3471
+ }
3472
+ )
3473
+ ] })
3474
+ ]
3475
+ }
3476
+ )
3477
+ ] });
3478
+ }
3349
3479
  function Price({ amount, currency, className, prefix }) {
3350
3480
  const context = useOptionalCimplify();
3351
3481
  const resolvedCurrency = currency ?? context?.displayCurrency ?? "USD";
@@ -5095,7 +5225,6 @@ function AuthElement({
5095
5225
  prefillEmail,
5096
5226
  onReady,
5097
5227
  onAuthenticated,
5098
- onRequiresOtp,
5099
5228
  onError
5100
5229
  }) {
5101
5230
  const containerRef = useRef(null);
@@ -5103,14 +5232,12 @@ function AuthElement({
5103
5232
  const elements = useElements();
5104
5233
  const onReadyRef = useRef(onReady);
5105
5234
  const onAuthenticatedRef = useRef(onAuthenticated);
5106
- const onRequiresOtpRef = useRef(onRequiresOtp);
5107
5235
  const onErrorRef = useRef(onError);
5108
5236
  useEffect(() => {
5109
5237
  onReadyRef.current = onReady;
5110
5238
  onAuthenticatedRef.current = onAuthenticated;
5111
- onRequiresOtpRef.current = onRequiresOtp;
5112
5239
  onErrorRef.current = onError;
5113
- }, [onReady, onAuthenticated, onRequiresOtp, onError]);
5240
+ }, [onReady, onAuthenticated, onError]);
5114
5241
  useEffect(() => {
5115
5242
  if (!elements || !containerRef.current) return;
5116
5243
  const element = elements.create(ELEMENT_TYPES.AUTH, { prefillEmail });
@@ -5120,10 +5247,6 @@ function AuthElement({
5120
5247
  EVENT_TYPES.AUTHENTICATED,
5121
5248
  (data) => onAuthenticatedRef.current?.(data)
5122
5249
  );
5123
- element.on(
5124
- EVENT_TYPES.REQUIRES_OTP,
5125
- (data) => onRequiresOtpRef.current?.(data)
5126
- );
5127
5250
  element.on(
5128
5251
  EVENT_TYPES.ERROR,
5129
5252
  (data) => onErrorRef.current?.(data)
@@ -15665,4 +15788,4 @@ function SparkleIcon({ className }) {
15665
15788
  );
15666
15789
  }
15667
15790
 
15668
- export { AccommodationCard, AccountContent, AccountDashboardPage, AccountHero, AccountIdentityStrip, AccountNav, AccountOrderDetailPage, AccountOrdersPage, AccountShell, AccountSidebar, AccountSignedOutPrompt, AccountSubscriptionDetailPage, AccountSubscriptionsPage, Ad, AdProvider, AddOnSelector, AddressElement, AuthElement, AvailabilityBadge, BackLink, BillingPlanSelector, BookingCard, BookingList, BookingPage, BookingsPage, BoxIcon24, BundleProductCard, BundleProductLayout, BundleSelector, Button, CardImage, CardShell, CardVariant, CartDrawer, CartDrawerProvider, CartPage, CartSummary, CartTemplate, CatalogueCollectionLayout, CataloguePage, CatalogueTemplate, CategoryFilter, CategoryGrid, ChatWidget, CheckIcon, CheckoutPage, CimplifyAccount, CimplifyCheckout, CimplifyProvider, CimplifySignInButton, CollectionPage, CollectionTemplate, CompactCartLayout, CompactCatalogueLayout, CompactSearchLayout, CompactServiceCard, CompositeProductCard, CompositeProductLayout, CompositeSelector, ContextCard, ContinuityCard, CurrencySelector, CustomAttributesTable, CustomerInputFields, DashboardIcon, DashboardIcon20, DatePicker, DateSlotPicker, DealBanner, DealsPage, DefaultCartLayout, DefaultCatalogueLayout, DefaultCollectionLayout, DefaultProductLayout, DefaultSearchLayout, DeliveryEstimate, DeliveryTruckIcon, DigitalProductCard, DigitalProductLayout, DiscountInput, ElementsProvider, EmptyState, ErrorState, FeaturedCollectionLayout, FilterTabs, FoodProductCard, FoodProductLayout, HappeningCard, IdentityIcon, IdentityOfframp, InventoryBadge, ItemsCard, LeaseServiceCard, LocationPicker, MediaGallery, MetadataStringList, MobileAccountShell, MobileBackButton, MobileMoreButton, MobileTabBar, NextDeliveryCard, OrderDetailHeader, OrderDetailMetaPipe, OrderDetailPage, OrderHistory, OrderHistoryPage, OrderList, OrderRow, OrderSummary, OrderTimeline, OrderTotals, OrdersIcon, OrdersIcon20, OvenIcon, PackageIcon, PaymentElement, Price, PriceRange, ProductCard, ProductCustomizer, ProductGrid, ProductImageGallery, ProductModel3D, ProductPage, ProductSheet, ProductTemplate, PropertiesTable, QuantitySelector, QuickAddButton, RecentlyViewed, RecommendationCarousel, RelatedProductsSection, RentalServiceCard, ResourcePicker, RetailProductCard, RichText, SaleBadge, ScheduleServiceCard, SearchInput, SearchPage, SearchTemplate, Section, SectionMore, ServiceProductLayout, SessionMessageBanner, SignOutIcon, Skeleton, SlotPicker, SoldOutOverlay, StaffPicker, StandardServiceCard, Status, StoreNav, StoreVideo, SubscriptionCard, SubscriptionList, SubscriptionRow, SubscriptionsIcon, SubscriptionsIcon20, TagPills, TimePicker, Toast, TwoColumnGrid, VariantSelector, VolumePricing, WelcomeCard, WholesaleProductCard, WholesaleProductLayout, WishlistButton, cn, roomToResource, sanitizeRichTextHtml, stripHtmlToText, useActivityState, useAds, useAttributeDefinitions, useAvailableSlots, useBillingPlans, useBookings, useBootstrap, useBundles, useCart, useCartDrawer, useCategories, useChat, useCheckout, useCimplify, useCimplifyClient, useCimplifySession, useCollection, useCollections, useDeals, useDeliveryFee, useElements, useElementsReady, useFxRate, useLocations, useOptionalCimplify, useOrder, useOrders, useProduct, useProductAvailability, useProductDeals, useProductPrice, useProductSchedules, useProducts, useProductsOnSale, usePropertyFacets, useQuote, useRecommendations, useSearch, useServiceAvailability, useServices, useSubscription, useSubscriptions, useTaxonomies, useTaxonomy, useTaxonomyPath, useValidateDiscount, useVariantSelector };
15791
+ export { AccommodationCard, AccountContent, AccountDashboardPage, AccountHero, AccountIdentityStrip, AccountNav, AccountOrderDetailPage, AccountOrdersPage, AccountShell, AccountSidebar, AccountSignedOutPrompt, AccountSubscriptionDetailPage, AccountSubscriptionsPage, Ad, AdProvider, AddOnSelector, AddressElement, AuthElement, AvailabilityBadge, BackLink, BillingPlanSelector, BookingCard, BookingList, BookingPage, BookingsPage, BoxIcon24, BundleProductCard, BundleProductLayout, BundleSelector, Button, CardImage, CardShell, CardVariant, CartDrawer, CartDrawerProvider, CartPage, CartSummary, CartTemplate, CatalogueCollectionLayout, CataloguePage, CatalogueTemplate, CategoryFilter, CategoryGrid, ChatWidget, CheckIcon, CheckoutPage, CimplifyCheckout, CimplifyProvider, CimplifySignInButton, CimplifyUserButton, CollectionPage, CollectionTemplate, CompactCartLayout, CompactCatalogueLayout, CompactSearchLayout, CompactServiceCard, CompositeProductCard, CompositeProductLayout, CompositeSelector, ContextCard, ContinuityCard, CurrencySelector, CustomAttributesTable, CustomerInputFields, DashboardIcon, DashboardIcon20, DatePicker, DateSlotPicker, DealBanner, DealsPage, DefaultCartLayout, DefaultCatalogueLayout, DefaultCollectionLayout, DefaultProductLayout, DefaultSearchLayout, DeliveryEstimate, DeliveryTruckIcon, DigitalProductCard, DigitalProductLayout, DiscountInput, ElementsProvider, EmptyState, ErrorState, FeaturedCollectionLayout, FilterTabs, FoodProductCard, FoodProductLayout, HappeningCard, IdentityIcon, IdentityOfframp, InventoryBadge, ItemsCard, LeaseServiceCard, LocationPicker, MediaGallery, MetadataStringList, MobileAccountShell, MobileBackButton, MobileMoreButton, MobileTabBar, NextDeliveryCard, OrderDetailHeader, OrderDetailMetaPipe, OrderDetailPage, OrderHistory, OrderHistoryPage, OrderList, OrderRow, OrderSummary, OrderTimeline, OrderTotals, OrdersIcon, OrdersIcon20, OvenIcon, PackageIcon, PaymentElement, Price, PriceRange, ProductCard, ProductCustomizer, ProductGrid, ProductImageGallery, ProductModel3D, ProductPage, ProductSheet, ProductTemplate, PropertiesTable, QuantitySelector, QuickAddButton, RecentlyViewed, RecommendationCarousel, RelatedProductsSection, RentalServiceCard, ResourcePicker, RetailProductCard, RichText, SaleBadge, ScheduleServiceCard, SearchInput, SearchPage, SearchTemplate, Section, SectionMore, ServiceProductLayout, SessionMessageBanner, SignOutIcon, Skeleton, SlotPicker, SoldOutOverlay, StaffPicker, StandardServiceCard, Status, StoreNav, StoreVideo, SubscriptionCard, SubscriptionList, SubscriptionRow, SubscriptionsIcon, SubscriptionsIcon20, TagPills, TimePicker, Toast, TwoColumnGrid, VariantSelector, VolumePricing, WelcomeCard, WholesaleProductCard, WholesaleProductLayout, WishlistButton, cn, roomToResource, sanitizeRichTextHtml, stripHtmlToText, useActivityState, useAds, useAttributeDefinitions, useAvailableSlots, useBillingPlans, useBookings, useBootstrap, useBundles, useCart, useCartDrawer, useCategories, useChat, useCheckout, useCimplify, useCimplifyClient, useCimplifySession, useCollection, useCollections, useDeals, useDeliveryFee, useElements, useElementsReady, useFxRate, useLocations, useOptionalCimplify, useOrder, useOrders, useProduct, useProductAvailability, useProductDeals, useProductPrice, useProductSchedules, useProducts, useProductsOnSale, usePropertyFacets, useQuote, useRecommendations, useSearch, useServiceAvailability, useServices, useSubscription, useSubscriptions, useTaxonomies, useTaxonomy, useTaxonomyPath, useValidateDiscount, useVariantSelector };
package/dist/server.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { ac as CimplifyClient } from './client-Dka2cGhu.mjs';
2
- export { J as CacheOptions, c7 as ReadRequestOptions, ct as Result } from './client-Dka2cGhu.mjs';
1
+ import { ac as CimplifyClient } from './client-Dyo3dvNy.mjs';
2
+ export { J as CacheOptions, ce as ReadRequestOptions, cA as Result } from './client-Dyo3dvNy.mjs';
3
3
  export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-B_kS4Oxa.mjs';
4
4
  import { JWTVerifyResult } from 'jose';
5
5
  import './payment-DVS7ZUEp.mjs';
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ac as CimplifyClient } from './client-Bo5rujc2.js';
2
- export { J as CacheOptions, c7 as ReadRequestOptions, ct as Result } from './client-Bo5rujc2.js';
1
+ import { ac as CimplifyClient } from './client-CfeQRwhl.js';
2
+ export { J as CacheOptions, ce as ReadRequestOptions, cA as Result } from './client-CfeQRwhl.js';
3
3
  export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-B_kS4Oxa.js';
4
4
  import { JWTVerifyResult } from 'jose';
5
5
  import './payment-sn-yGL7v.js';
package/dist/server.js CHANGED
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkKWYI2TTA_js = require('./chunk-KWYI2TTA.js');
4
- var chunkJ3MGY6AU_js = require('./chunk-J3MGY6AU.js');
5
- require('./chunk-AVQL3TSJ.js');
3
+ var chunk5HAUJBOK_js = require('./chunk-5HAUJBOK.js');
4
+ var chunkWCSAZRNC_js = require('./chunk-WCSAZRNC.js');
6
5
  require('./chunk-7Y2O3E4D.js');
7
6
  var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.js');
8
7
  require('./chunk-OWW5GUSB.js');
@@ -27,7 +26,7 @@ function readEnv(...keys) {
27
26
  var getServerClient = react.cache((opts = {}) => {
28
27
  const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
29
28
  const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
30
- const client = chunkJ3MGY6AU_js.createCimplifyClient({
29
+ const client = chunk5HAUJBOK_js.createCimplifyClient({
31
30
  baseUrl,
32
31
  publicKey,
33
32
  suppressPublicKeyWarning: true
@@ -251,7 +250,7 @@ var QUERY_AUTH_ERROR = "cimplify_auth_error";
251
250
  var discoveryCache = /* @__PURE__ */ new Map();
252
251
  var jwksCache = /* @__PURE__ */ new Map();
253
252
  function issuerBase(cfg) {
254
- return (cfg.issuer ?? cfg.authUrl ?? chunkKWYI2TTA_js.DEFAULT_ISSUER).replace(/\/$/, "");
253
+ return (cfg.issuer ?? cfg.authUrl ?? chunkWCSAZRNC_js.DEFAULT_ISSUER).replace(/\/$/, "");
255
254
  }
256
255
  function cookieName(cfg) {
257
256
  return cfg.cookieName ?? SESSION_COOKIE;
@@ -454,16 +453,24 @@ async function handleOidcCallback(req, opts) {
454
453
  buildRefreshTokenCookie(opts, tokens.refreshToken, REFRESH_COOKIE_MAX_AGE_SECONDS)
455
454
  );
456
455
  }
457
- return new Response(JSON.stringify({ ok: true }), { status: 200, headers });
456
+ return new Response(
457
+ JSON.stringify({
458
+ ok: true,
459
+ accessToken: tokens.accessToken,
460
+ expiresIn: tokens.expiresIn,
461
+ scope: tokens.scope
462
+ }),
463
+ { status: 200, headers }
464
+ );
458
465
  }
459
466
  function readPkceCookie(cookieHeader) {
460
467
  if (!cookieHeader) return null;
461
- const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkKWYI2TTA_js.PKCE_COOKIE}=`));
468
+ const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkWCSAZRNC_js.PKCE_COOKIE}=`));
462
469
  if (!match) return null;
463
- return chunkKWYI2TTA_js.decodePkceState(match.slice(chunkKWYI2TTA_js.PKCE_COOKIE.length + 1));
470
+ return chunkWCSAZRNC_js.decodePkceState(match.slice(chunkWCSAZRNC_js.PKCE_COOKIE.length + 1));
464
471
  }
465
472
  function buildPkceClearCookie() {
466
- return `${chunkKWYI2TTA_js.PKCE_COOKIE}=; Path=${chunkKWYI2TTA_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
473
+ return `${chunkWCSAZRNC_js.PKCE_COOKIE}=; Path=${chunkWCSAZRNC_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
467
474
  }
468
475
  function safeReturnPath(returnTo, fallback) {
469
476
  if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
package/dist/server.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-7BKKBJQM.mjs';
2
- import { createCimplifyClient } from './chunk-227XTAEB.mjs';
3
- import './chunk-R6363CC7.mjs';
1
+ import { createCimplifyClient } from './chunk-KNPE4WCQ.mjs';
2
+ import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-SOV4H6PQ.mjs';
4
3
  import './chunk-TD3AY34U.mjs';
5
4
  export { CimplifyError } from './chunk-AMZXALF6.mjs';
6
5
  import './chunk-3G6RQLXK.mjs';
@@ -452,7 +451,15 @@ async function handleOidcCallback(req, opts) {
452
451
  buildRefreshTokenCookie(opts, tokens.refreshToken, REFRESH_COOKIE_MAX_AGE_SECONDS)
453
452
  );
454
453
  }
455
- return new Response(JSON.stringify({ ok: true }), { status: 200, headers });
454
+ return new Response(
455
+ JSON.stringify({
456
+ ok: true,
457
+ accessToken: tokens.accessToken,
458
+ expiresIn: tokens.expiresIn,
459
+ scope: tokens.scope
460
+ }),
461
+ { status: 200, headers }
462
+ );
456
463
  }
457
464
  function readPkceCookie(cookieHeader) {
458
465
  if (!cookieHeader) return null;
@@ -37,6 +37,7 @@ interface SignInOptions {
37
37
  authUrl?: string;
38
38
  loginHint?: string;
39
39
  prompt?: "none" | "login" | "consent";
40
+ uiMode?: "checkout" | "default";
40
41
  /**
41
42
  * "redirect" (default) navigates the top-level window to the IdP and back —
42
43
  * works in every browser, on any domain, because the IdP is first-party
@@ -44,13 +45,25 @@ interface SignInOptions {
44
45
  * cookies are allowed (Chrome today; not Safari/Firefox).
45
46
  */
46
47
  mode?: "redirect" | "modal";
48
+ /**
49
+ * In modal mode, first try a hidden prompt=none authorize request. If the
50
+ * shopper already has a valid Cimplify SSO session, the caller receives the
51
+ * access token without showing UI; otherwise the regular modal opens.
52
+ */
53
+ silentFirst?: boolean;
54
+ silentTimeoutMs?: number;
47
55
  /** Where to land after a successful redirect sign-in. Defaults to the current path. */
48
56
  returnTo?: string;
49
57
  onError?: (err: {
50
58
  error: string;
51
59
  description?: string;
52
60
  }) => void;
53
- onSuccess?: () => void;
61
+ onSuccess?: (result: SignInSuccess) => void;
62
+ }
63
+ interface SignInSuccess {
64
+ accessToken?: string;
65
+ expiresIn?: number;
66
+ scope?: string;
54
67
  }
55
68
  declare function startSignIn(opts: SignInOptions): Promise<void>;
56
69
 
@@ -37,6 +37,7 @@ interface SignInOptions {
37
37
  authUrl?: string;
38
38
  loginHint?: string;
39
39
  prompt?: "none" | "login" | "consent";
40
+ uiMode?: "checkout" | "default";
40
41
  /**
41
42
  * "redirect" (default) navigates the top-level window to the IdP and back —
42
43
  * works in every browser, on any domain, because the IdP is first-party
@@ -44,13 +45,25 @@ interface SignInOptions {
44
45
  * cookies are allowed (Chrome today; not Safari/Firefox).
45
46
  */
46
47
  mode?: "redirect" | "modal";
48
+ /**
49
+ * In modal mode, first try a hidden prompt=none authorize request. If the
50
+ * shopper already has a valid Cimplify SSO session, the caller receives the
51
+ * access token without showing UI; otherwise the regular modal opens.
52
+ */
53
+ silentFirst?: boolean;
54
+ silentTimeoutMs?: number;
47
55
  /** Where to land after a successful redirect sign-in. Defaults to the current path. */
48
56
  returnTo?: string;
49
57
  onError?: (err: {
50
58
  error: string;
51
59
  description?: string;
52
60
  }) => void;
53
- onSuccess?: () => void;
61
+ onSuccess?: (result: SignInSuccess) => void;
62
+ }
63
+ interface SignInSuccess {
64
+ accessToken?: string;
65
+ expiresIn?: number;
66
+ scope?: string;
54
67
  }
55
68
  declare function startSignIn(opts: SignInOptions): Promise<void>;
56
69