@aforoai/storefront-widgets 1.0.2 → 1.0.4

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.
@@ -5,7 +5,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  // src/vanilla/index.ts
6
6
 
7
7
  // src/core/version.ts
8
- var VERSION = "1.0.2";
8
+ var VERSION = "1.0.4";
9
9
 
10
10
  // src/core/AforoEmbed.ts
11
11
  var mountedElements = /* @__PURE__ */ new WeakMap();
@@ -389,7 +389,7 @@ var BridgeClientError = class extends Error {
389
389
  this.retryable = retryable;
390
390
  }
391
391
  };
392
- var DEFAULT_BASE = "https://embed.aforo.ai";
392
+ var DEFAULT_BASE = "https://storefront.aforo.ai";
393
393
  var DEFAULT_TIMEOUT_MS = 15e3;
394
394
  function uuidv4() {
395
395
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
@@ -577,10 +577,23 @@ var _BridgeClient = class _BridgeClient {
577
577
  /**
578
578
  * Headless config — the PricingCard widget's primary read path.
579
579
  *
580
- * Mirrors `GET /api/v1/portal/headless/config` which returns
581
- * `{branding, offerings, ratePlans, themeTokens, customPages, ...}`
582
- * denormalized JSON. The endpoint is 60s Caffeine-cached server-side; we
583
- * cache once per widget instance on the client.
580
+ * Hits `GET /api/v1/portal/embed/tenant-config/{slug}` the SAME
581
+ * embed-key-authenticated endpoint {@link getTenantBrandKit} uses, now
582
+ * extended server-side with `offerings` + `embeddableWidget`. This was
583
+ * previously wired to `GET /api/v1/portal/headless/config`, an unrelated
584
+ * T6 Headless-tier endpoint that requires `X-Storefront-Key`/
585
+ * `X-Tenant-Id` auth — headers the embed key flow never sends. Every
586
+ * embed-tier fetch against that URL failed 400 "Missing tenant
587
+ * identification" by construction; this endpoint is scoped to the same
588
+ * `EmbedKeyAuthFilter` gate as the rest of the embed plane, so the
589
+ * `Authorization: Bearer <embed_key>` header `buildHeaders()` already
590
+ * sends is sufficient.
591
+ *
592
+ * The backend response is still a flat record (`tenantSlug,
593
+ * primaryColor, secondaryColor, logoUrl, fontFamily, offerings,
594
+ * embeddableWidget`) — kept flat so `getTenantBrandKit()`'s existing
595
+ * consumers (the ThemeReader cascade) are unaffected. This method nests
596
+ * the branding fields into the shape `HeadlessConfigResponse` expects.
584
597
  *
585
598
  * Pattern #18 fail-soft — returns `null` on transport failure, 404, or
586
599
  * malformed JSON. Widgets fall through to their empty / error state and
@@ -595,7 +608,7 @@ var _BridgeClient = class _BridgeClient {
595
608
  }
596
609
  const target = slug || this.tenantSlug;
597
610
  if (!target) return null;
598
- const url = `${this.baseUrl}/api/v1/portal/headless/config?tenantSlug=${encodeURIComponent(target)}`;
611
+ const url = `${this.baseUrl}/api/v1/portal/embed/tenant-config/${encodeURIComponent(target)}`;
599
612
  let resp;
600
613
  try {
601
614
  resp = await this.send(url, {
@@ -608,7 +621,18 @@ var _BridgeClient = class _BridgeClient {
608
621
  if (!resp.ok) return null;
609
622
  try {
610
623
  const body = await resp.json();
611
- return body && typeof body === "object" ? body : null;
624
+ if (!body || typeof body !== "object") return null;
625
+ return {
626
+ tenantSlug: body.tenantSlug,
627
+ branding: {
628
+ primaryColor: body.primaryColor ?? null,
629
+ secondaryColor: body.secondaryColor ?? null,
630
+ logoUrl: body.logoUrl ?? null,
631
+ fontFamily: body.fontFamily ?? null
632
+ },
633
+ offerings: Array.isArray(body.offerings) ? body.offerings : [],
634
+ embeddableWidget: body.embeddableWidget ?? null
635
+ };
612
636
  } catch {
613
637
  return null;
614
638
  }
@@ -2113,9 +2137,10 @@ var AforoSession = {
2113
2137
  };
2114
2138
  sessions.set(k, entry);
2115
2139
  if (config.bridgeToken) {
2116
- entry.pendingExchange = refreshSession(entry).catch((err) => {
2117
- throw err;
2140
+ const exchangePromise = refreshSession(entry);
2141
+ exchangePromise.catch(() => {
2118
2142
  });
2143
+ entry.pendingExchange = exchangePromise;
2119
2144
  } else if (config.magicLinkMode) {
2120
2145
  const tokenInUrl = readMagicTokenFromUrl();
2121
2146
  if (tokenInUrl) {
@@ -2125,6 +2150,8 @@ var AforoSession = {
2125
2150
  pending = runMagicLinkVerify(entry, tokenInUrl).finally(() => {
2126
2151
  pendingMagicLinkVerifies.delete(dedupKey);
2127
2152
  });
2153
+ pending.catch(() => {
2154
+ });
2128
2155
  pendingMagicLinkVerifies.set(dedupKey, pending);
2129
2156
  }
2130
2157
  entry.pendingExchange = pending;
@@ -28,7 +28,7 @@ var React7__namespace = /*#__PURE__*/_interopNamespace(React7);
28
28
  // src/vue/index.ts
29
29
 
30
30
  // src/core/version.ts
31
- var VERSION = "1.0.2";
31
+ var VERSION = "1.0.4";
32
32
 
33
33
  // src/core/AforoEmbed.ts
34
34
  var mountedElements = /* @__PURE__ */ new WeakMap();
@@ -412,7 +412,7 @@ var BridgeClientError = class extends Error {
412
412
  this.retryable = retryable;
413
413
  }
414
414
  };
415
- var DEFAULT_BASE = "https://embed.aforo.ai";
415
+ var DEFAULT_BASE = "https://storefront.aforo.ai";
416
416
  var DEFAULT_TIMEOUT_MS = 15e3;
417
417
  function uuidv4() {
418
418
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
@@ -600,10 +600,23 @@ var _BridgeClient = class _BridgeClient {
600
600
  /**
601
601
  * Headless config — the PricingCard widget's primary read path.
602
602
  *
603
- * Mirrors `GET /api/v1/portal/headless/config` which returns
604
- * `{branding, offerings, ratePlans, themeTokens, customPages, ...}`
605
- * denormalized JSON. The endpoint is 60s Caffeine-cached server-side; we
606
- * cache once per widget instance on the client.
603
+ * Hits `GET /api/v1/portal/embed/tenant-config/{slug}` the SAME
604
+ * embed-key-authenticated endpoint {@link getTenantBrandKit} uses, now
605
+ * extended server-side with `offerings` + `embeddableWidget`. This was
606
+ * previously wired to `GET /api/v1/portal/headless/config`, an unrelated
607
+ * T6 Headless-tier endpoint that requires `X-Storefront-Key`/
608
+ * `X-Tenant-Id` auth — headers the embed key flow never sends. Every
609
+ * embed-tier fetch against that URL failed 400 "Missing tenant
610
+ * identification" by construction; this endpoint is scoped to the same
611
+ * `EmbedKeyAuthFilter` gate as the rest of the embed plane, so the
612
+ * `Authorization: Bearer <embed_key>` header `buildHeaders()` already
613
+ * sends is sufficient.
614
+ *
615
+ * The backend response is still a flat record (`tenantSlug,
616
+ * primaryColor, secondaryColor, logoUrl, fontFamily, offerings,
617
+ * embeddableWidget`) — kept flat so `getTenantBrandKit()`'s existing
618
+ * consumers (the ThemeReader cascade) are unaffected. This method nests
619
+ * the branding fields into the shape `HeadlessConfigResponse` expects.
607
620
  *
608
621
  * Pattern #18 fail-soft — returns `null` on transport failure, 404, or
609
622
  * malformed JSON. Widgets fall through to their empty / error state and
@@ -618,7 +631,7 @@ var _BridgeClient = class _BridgeClient {
618
631
  }
619
632
  const target = slug || this.tenantSlug;
620
633
  if (!target) return null;
621
- const url = `${this.baseUrl}/api/v1/portal/headless/config?tenantSlug=${encodeURIComponent(target)}`;
634
+ const url = `${this.baseUrl}/api/v1/portal/embed/tenant-config/${encodeURIComponent(target)}`;
622
635
  let resp;
623
636
  try {
624
637
  resp = await this.send(url, {
@@ -631,7 +644,18 @@ var _BridgeClient = class _BridgeClient {
631
644
  if (!resp.ok) return null;
632
645
  try {
633
646
  const body = await resp.json();
634
- return body && typeof body === "object" ? body : null;
647
+ if (!body || typeof body !== "object") return null;
648
+ return {
649
+ tenantSlug: body.tenantSlug,
650
+ branding: {
651
+ primaryColor: body.primaryColor ?? null,
652
+ secondaryColor: body.secondaryColor ?? null,
653
+ logoUrl: body.logoUrl ?? null,
654
+ fontFamily: body.fontFamily ?? null
655
+ },
656
+ offerings: Array.isArray(body.offerings) ? body.offerings : [],
657
+ embeddableWidget: body.embeddableWidget ?? null
658
+ };
635
659
  } catch {
636
660
  return null;
637
661
  }
@@ -2136,9 +2160,10 @@ var AforoSession = {
2136
2160
  };
2137
2161
  sessions.set(k, entry);
2138
2162
  if (config.bridgeToken) {
2139
- entry.pendingExchange = refreshSession(entry).catch((err) => {
2140
- throw err;
2163
+ const exchangePromise = refreshSession(entry);
2164
+ exchangePromise.catch(() => {
2141
2165
  });
2166
+ entry.pendingExchange = exchangePromise;
2142
2167
  } else if (config.magicLinkMode) {
2143
2168
  const tokenInUrl = readMagicTokenFromUrl();
2144
2169
  if (tokenInUrl) {
@@ -2148,6 +2173,8 @@ var AforoSession = {
2148
2173
  pending = runMagicLinkVerify(entry, tokenInUrl).finally(() => {
2149
2174
  pendingMagicLinkVerifies.delete(dedupKey);
2150
2175
  });
2176
+ pending.catch(() => {
2177
+ });
2151
2178
  pendingMagicLinkVerifies.set(dedupKey, pending);
2152
2179
  }
2153
2180
  entry.pendingExchange = pending;
@@ -1,5 +1,5 @@
1
1
  import * as vue from 'vue';
2
- import { T as ThemeTokenOverrides } from '../types-Dm6cp_Cc.cjs';
2
+ import { T as ThemeTokenOverrides } from '../types-BbQw2_32.cjs';
3
3
 
4
4
  declare const AforoPricingCard: vue.DefineComponent<{
5
5
  tenantSlug: string;
@@ -1,5 +1,5 @@
1
1
  import * as vue from 'vue';
2
- import { T as ThemeTokenOverrides } from '../types-Dm6cp_Cc.js';
2
+ import { T as ThemeTokenOverrides } from '../types-BbQw2_32.js';
3
3
 
4
4
  declare const AforoPricingCard: vue.DefineComponent<{
5
5
  tenantSlug: string;
@@ -6,7 +6,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  // src/vue/index.ts
7
7
 
8
8
  // src/core/version.ts
9
- var VERSION = "1.0.2";
9
+ var VERSION = "1.0.4";
10
10
 
11
11
  // src/core/AforoEmbed.ts
12
12
  var mountedElements = /* @__PURE__ */ new WeakMap();
@@ -390,7 +390,7 @@ var BridgeClientError = class extends Error {
390
390
  this.retryable = retryable;
391
391
  }
392
392
  };
393
- var DEFAULT_BASE = "https://embed.aforo.ai";
393
+ var DEFAULT_BASE = "https://storefront.aforo.ai";
394
394
  var DEFAULT_TIMEOUT_MS = 15e3;
395
395
  function uuidv4() {
396
396
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
@@ -578,10 +578,23 @@ var _BridgeClient = class _BridgeClient {
578
578
  /**
579
579
  * Headless config — the PricingCard widget's primary read path.
580
580
  *
581
- * Mirrors `GET /api/v1/portal/headless/config` which returns
582
- * `{branding, offerings, ratePlans, themeTokens, customPages, ...}`
583
- * denormalized JSON. The endpoint is 60s Caffeine-cached server-side; we
584
- * cache once per widget instance on the client.
581
+ * Hits `GET /api/v1/portal/embed/tenant-config/{slug}` the SAME
582
+ * embed-key-authenticated endpoint {@link getTenantBrandKit} uses, now
583
+ * extended server-side with `offerings` + `embeddableWidget`. This was
584
+ * previously wired to `GET /api/v1/portal/headless/config`, an unrelated
585
+ * T6 Headless-tier endpoint that requires `X-Storefront-Key`/
586
+ * `X-Tenant-Id` auth — headers the embed key flow never sends. Every
587
+ * embed-tier fetch against that URL failed 400 "Missing tenant
588
+ * identification" by construction; this endpoint is scoped to the same
589
+ * `EmbedKeyAuthFilter` gate as the rest of the embed plane, so the
590
+ * `Authorization: Bearer <embed_key>` header `buildHeaders()` already
591
+ * sends is sufficient.
592
+ *
593
+ * The backend response is still a flat record (`tenantSlug,
594
+ * primaryColor, secondaryColor, logoUrl, fontFamily, offerings,
595
+ * embeddableWidget`) — kept flat so `getTenantBrandKit()`'s existing
596
+ * consumers (the ThemeReader cascade) are unaffected. This method nests
597
+ * the branding fields into the shape `HeadlessConfigResponse` expects.
585
598
  *
586
599
  * Pattern #18 fail-soft — returns `null` on transport failure, 404, or
587
600
  * malformed JSON. Widgets fall through to their empty / error state and
@@ -596,7 +609,7 @@ var _BridgeClient = class _BridgeClient {
596
609
  }
597
610
  const target = slug || this.tenantSlug;
598
611
  if (!target) return null;
599
- const url = `${this.baseUrl}/api/v1/portal/headless/config?tenantSlug=${encodeURIComponent(target)}`;
612
+ const url = `${this.baseUrl}/api/v1/portal/embed/tenant-config/${encodeURIComponent(target)}`;
600
613
  let resp;
601
614
  try {
602
615
  resp = await this.send(url, {
@@ -609,7 +622,18 @@ var _BridgeClient = class _BridgeClient {
609
622
  if (!resp.ok) return null;
610
623
  try {
611
624
  const body = await resp.json();
612
- return body && typeof body === "object" ? body : null;
625
+ if (!body || typeof body !== "object") return null;
626
+ return {
627
+ tenantSlug: body.tenantSlug,
628
+ branding: {
629
+ primaryColor: body.primaryColor ?? null,
630
+ secondaryColor: body.secondaryColor ?? null,
631
+ logoUrl: body.logoUrl ?? null,
632
+ fontFamily: body.fontFamily ?? null
633
+ },
634
+ offerings: Array.isArray(body.offerings) ? body.offerings : [],
635
+ embeddableWidget: body.embeddableWidget ?? null
636
+ };
613
637
  } catch {
614
638
  return null;
615
639
  }
@@ -2114,9 +2138,10 @@ var AforoSession = {
2114
2138
  };
2115
2139
  sessions.set(k, entry);
2116
2140
  if (config.bridgeToken) {
2117
- entry.pendingExchange = refreshSession(entry).catch((err) => {
2118
- throw err;
2141
+ const exchangePromise = refreshSession(entry);
2142
+ exchangePromise.catch(() => {
2119
2143
  });
2144
+ entry.pendingExchange = exchangePromise;
2120
2145
  } else if (config.magicLinkMode) {
2121
2146
  const tokenInUrl = readMagicTokenFromUrl();
2122
2147
  if (tokenInUrl) {
@@ -2126,6 +2151,8 @@ var AforoSession = {
2126
2151
  pending = runMagicLinkVerify(entry, tokenInUrl).finally(() => {
2127
2152
  pendingMagicLinkVerifies.delete(dedupKey);
2128
2153
  });
2154
+ pending.catch(() => {
2155
+ });
2129
2156
  pendingMagicLinkVerifies.set(dedupKey, pending);
2130
2157
  }
2131
2158
  entry.pendingExchange = pending;