@aforoai/storefront-widgets 1.0.5 → 1.0.11
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/CHANGELOG.md +111 -0
- package/dist/{AforoEmbed-VYb6_GXB.d.cts → AforoEmbed-BX2HPXWT.d.cts} +1 -1
- package/dist/{AforoEmbed-BkJF1hAN.d.ts → AforoEmbed-PsTY7zh0.d.ts} +1 -1
- package/dist/index.cjs +72 -45
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +72 -45
- package/dist/loader.js +1 -1
- package/dist/loader.mjs +1 -1
- package/dist/sri.json +11 -11
- package/dist/{types-BbQw2_32.d.cts → types-RMTEXoGw.d.cts} +7 -2
- package/dist/{types-BbQw2_32.d.ts → types-RMTEXoGw.d.ts} +7 -2
- package/dist/vanilla/index.cjs +74 -45
- package/dist/vanilla/index.d.cts +2 -2
- package/dist/vanilla/index.d.ts +2 -2
- package/dist/vanilla/index.mjs +74 -45
- package/dist/vue/index.cjs +74 -45
- package/dist/vue/index.d.cts +1 -1
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.mjs +74 -45
- package/dist/widgets/checkout-flow.js +5 -5
- package/dist/widgets/invoice-list.js +5 -5
- package/dist/widgets/payment-method.js +5 -5
- package/dist/widgets/pricing-card.js +8 -8
- package/dist/widgets/subscribe-button.js +7 -7
- package/dist/widgets/subscription-manager.js +5 -5
- package/dist/widgets/upgrade-cancel.js +5 -5
- package/dist/widgets/usage-meter.js +7 -7
- package/loader.sri.txt +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -488,8 +488,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
488
488
|
}
|
|
489
489
|
if (!resp.ok) return emptyPage;
|
|
490
490
|
try {
|
|
491
|
-
const
|
|
492
|
-
if (!
|
|
491
|
+
const raw = await resp.json();
|
|
492
|
+
if (!raw || typeof raw !== "object") return emptyPage;
|
|
493
|
+
const body = raw.data ?? raw;
|
|
493
494
|
return {
|
|
494
495
|
content: Array.isArray(body.content) ? body.content : [],
|
|
495
496
|
totalElements: typeof body.totalElements === "number" && Number.isFinite(body.totalElements) ? body.totalElements : 0,
|
|
@@ -532,7 +533,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
532
533
|
}
|
|
533
534
|
if (!resp.ok) return null;
|
|
534
535
|
try {
|
|
535
|
-
const
|
|
536
|
+
const raw = await resp.json();
|
|
537
|
+
const body = raw ? raw.data ?? raw : null;
|
|
536
538
|
if (!body || typeof body.downloadUrl !== "string" || body.downloadUrl.length === 0) {
|
|
537
539
|
return null;
|
|
538
540
|
}
|
|
@@ -621,7 +623,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
621
623
|
}
|
|
622
624
|
let body;
|
|
623
625
|
try {
|
|
624
|
-
|
|
626
|
+
const raw = await resp.json();
|
|
627
|
+
body = raw?.data ?? raw;
|
|
625
628
|
} catch {
|
|
626
629
|
throw new BridgeClientError(
|
|
627
630
|
"Malformed invoice-payment-initiate response (not JSON)",
|
|
@@ -932,9 +935,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
932
935
|
if (!resp.ok) {
|
|
933
936
|
throw await this.parseError(resp);
|
|
934
937
|
}
|
|
935
|
-
let
|
|
938
|
+
let raw;
|
|
936
939
|
try {
|
|
937
|
-
|
|
940
|
+
raw = await resp.json();
|
|
938
941
|
} catch {
|
|
939
942
|
throw new BridgeClientError(
|
|
940
943
|
"Malformed confirmCart response (not JSON)",
|
|
@@ -943,6 +946,7 @@ var _BridgeClient = class _BridgeClient {
|
|
|
943
946
|
false
|
|
944
947
|
);
|
|
945
948
|
}
|
|
949
|
+
const body = raw?.data ?? raw ?? {};
|
|
946
950
|
if (!body.cartId || !body.status) {
|
|
947
951
|
throw new BridgeClientError(
|
|
948
952
|
"Malformed confirmCart response (missing required fields)",
|
|
@@ -1007,9 +1011,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1007
1011
|
* undefined access.
|
|
1008
1012
|
*/
|
|
1009
1013
|
async parseCartResponse(resp, methodName) {
|
|
1010
|
-
let
|
|
1014
|
+
let raw;
|
|
1011
1015
|
try {
|
|
1012
|
-
|
|
1016
|
+
raw = await resp.json();
|
|
1013
1017
|
} catch {
|
|
1014
1018
|
throw new BridgeClientError(
|
|
1015
1019
|
`Malformed ${methodName} response (not JSON)`,
|
|
@@ -1018,7 +1022,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1018
1022
|
false
|
|
1019
1023
|
);
|
|
1020
1024
|
}
|
|
1021
|
-
|
|
1025
|
+
const data = raw?.data ?? raw ?? {};
|
|
1026
|
+
if (!data.cartId || !data.cartType || !data.status || !data.targetId) {
|
|
1022
1027
|
throw new BridgeClientError(
|
|
1023
1028
|
`Malformed ${methodName} response (missing required fields)`,
|
|
1024
1029
|
500,
|
|
@@ -1027,21 +1032,21 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1027
1032
|
);
|
|
1028
1033
|
}
|
|
1029
1034
|
return {
|
|
1030
|
-
cartId:
|
|
1031
|
-
cartType:
|
|
1032
|
-
targetId:
|
|
1033
|
-
status:
|
|
1034
|
-
totalCents: typeof
|
|
1035
|
-
currency: typeof
|
|
1036
|
-
gatewayProvider:
|
|
1037
|
-
gatewayClientSecret:
|
|
1038
|
-
gatewayOrderId:
|
|
1039
|
-
gatewayApprovalUrl:
|
|
1040
|
-
gatewaySandboxMode:
|
|
1041
|
-
subscriptionId:
|
|
1042
|
-
invoiceId:
|
|
1043
|
-
expiresAt: typeof
|
|
1044
|
-
completedAt:
|
|
1035
|
+
cartId: data.cartId,
|
|
1036
|
+
cartType: data.cartType,
|
|
1037
|
+
targetId: data.targetId,
|
|
1038
|
+
status: data.status,
|
|
1039
|
+
totalCents: typeof data.totalCents === "number" && Number.isFinite(data.totalCents) ? data.totalCents : 0,
|
|
1040
|
+
currency: typeof data.currency === "string" ? data.currency : "USD",
|
|
1041
|
+
gatewayProvider: data.gatewayProvider ?? null,
|
|
1042
|
+
gatewayClientSecret: data.gatewayClientSecret ?? null,
|
|
1043
|
+
gatewayOrderId: data.gatewayOrderId ?? null,
|
|
1044
|
+
gatewayApprovalUrl: data.gatewayApprovalUrl ?? null,
|
|
1045
|
+
gatewaySandboxMode: data.gatewaySandboxMode ?? null,
|
|
1046
|
+
subscriptionId: data.subscriptionId ?? null,
|
|
1047
|
+
invoiceId: data.invoiceId ?? null,
|
|
1048
|
+
expiresAt: typeof data.expiresAt === "string" ? data.expiresAt : (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
1049
|
+
completedAt: data.completedAt ?? null
|
|
1045
1050
|
};
|
|
1046
1051
|
}
|
|
1047
1052
|
/** Public liveness probe. Returns null on failure (not an error). */
|
|
@@ -1402,14 +1407,17 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1402
1407
|
idempotencyKey,
|
|
1403
1408
|
sessionJwt
|
|
1404
1409
|
}),
|
|
1405
|
-
|
|
1410
|
+
// 2026-08-29 fix: same bug as cancelSubscription() below — EmbedUpgradeRequest
|
|
1411
|
+
// requires idempotencyKey as a @NotBlank BODY field, but this only ever sent
|
|
1412
|
+
// it via the Idempotency-Key header.
|
|
1413
|
+
body: JSON.stringify({ ...request, idempotencyKey })
|
|
1406
1414
|
});
|
|
1407
1415
|
if (!resp.ok) {
|
|
1408
1416
|
throw await this.parseError(resp);
|
|
1409
1417
|
}
|
|
1410
|
-
let
|
|
1418
|
+
let raw;
|
|
1411
1419
|
try {
|
|
1412
|
-
|
|
1420
|
+
raw = await resp.json();
|
|
1413
1421
|
} catch {
|
|
1414
1422
|
throw new BridgeClientError(
|
|
1415
1423
|
"Malformed upgrade response (not JSON)",
|
|
@@ -1418,6 +1426,7 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1418
1426
|
false
|
|
1419
1427
|
);
|
|
1420
1428
|
}
|
|
1429
|
+
const body = raw ? raw.data ?? raw : {};
|
|
1421
1430
|
if (!body.subscriptionId || !body.previousOfferingId || !body.newOfferingId || !body.status) {
|
|
1422
1431
|
throw new BridgeClientError(
|
|
1423
1432
|
"Malformed upgrade response (missing required fields)",
|
|
@@ -1481,14 +1490,19 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1481
1490
|
idempotencyKey,
|
|
1482
1491
|
sessionJwt
|
|
1483
1492
|
}),
|
|
1484
|
-
|
|
1493
|
+
// 2026-08-29 fix: EmbedCancelRequest (storefront-service) requires
|
|
1494
|
+
// idempotencyKey as a @NotBlank BODY field — this only ever sent it
|
|
1495
|
+
// via the Idempotency-Key header, so every real cancellation 400'd
|
|
1496
|
+
// with "idempotencyKey is required" regardless of any other field.
|
|
1497
|
+
// Confirmed live against production.
|
|
1498
|
+
body: JSON.stringify({ ...request, idempotencyKey })
|
|
1485
1499
|
});
|
|
1486
1500
|
if (!resp.ok) {
|
|
1487
1501
|
throw await this.parseError(resp);
|
|
1488
1502
|
}
|
|
1489
|
-
let
|
|
1503
|
+
let raw;
|
|
1490
1504
|
try {
|
|
1491
|
-
|
|
1505
|
+
raw = await resp.json();
|
|
1492
1506
|
} catch {
|
|
1493
1507
|
throw new BridgeClientError(
|
|
1494
1508
|
"Malformed cancel response (not JSON)",
|
|
@@ -1497,7 +1511,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1497
1511
|
false
|
|
1498
1512
|
);
|
|
1499
1513
|
}
|
|
1500
|
-
|
|
1514
|
+
const body = raw ? raw.data ?? raw : null;
|
|
1515
|
+
if (!body || !body.subscriptionId || !body.status || !body.effectiveAt) {
|
|
1501
1516
|
throw new BridgeClientError(
|
|
1502
1517
|
"Malformed cancel response (missing required fields)",
|
|
1503
1518
|
500,
|
|
@@ -1510,7 +1525,7 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1510
1525
|
status: body.status,
|
|
1511
1526
|
cancelledAt: body.cancelledAt ?? null,
|
|
1512
1527
|
effectiveAt: body.effectiveAt,
|
|
1513
|
-
feedbackId: body.feedbackId,
|
|
1528
|
+
feedbackId: body.feedbackId ?? null,
|
|
1514
1529
|
creditNoteId: body.creditNoteId ?? null
|
|
1515
1530
|
};
|
|
1516
1531
|
}
|
|
@@ -1540,7 +1555,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1540
1555
|
if (!resp.ok) {
|
|
1541
1556
|
return { methods: [], defaultMethodId: null };
|
|
1542
1557
|
}
|
|
1543
|
-
const
|
|
1558
|
+
const raw = await resp.json();
|
|
1559
|
+
const body = raw ? raw.data ?? raw : {};
|
|
1544
1560
|
return {
|
|
1545
1561
|
methods: Array.isArray(body.methods) ? body.methods : [],
|
|
1546
1562
|
defaultMethodId: body.defaultMethodId ?? null
|
|
@@ -1570,7 +1586,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1570
1586
|
body: JSON.stringify({})
|
|
1571
1587
|
});
|
|
1572
1588
|
if (!resp.ok) return null;
|
|
1573
|
-
const
|
|
1589
|
+
const raw = await resp.json();
|
|
1590
|
+
const body = raw ? raw.data ?? raw : {};
|
|
1574
1591
|
if (!body.clientSecret) return null;
|
|
1575
1592
|
return {
|
|
1576
1593
|
clientSecret: body.clientSecret,
|
|
@@ -2650,6 +2667,7 @@ function WidgetShell(props) {
|
|
|
2650
2667
|
var DEFAULT_LAYOUT = "horizontal";
|
|
2651
2668
|
var DEFAULT_MAX_PLANS = 4;
|
|
2652
2669
|
var DEFAULT_CTA_TEXT = "Get Started";
|
|
2670
|
+
var DEFAULT_CARD_RADIUS = 12;
|
|
2653
2671
|
function clampLayout(raw) {
|
|
2654
2672
|
return raw === "horizontal" || raw === "vertical" || raw === "table" ? raw : void 0;
|
|
2655
2673
|
}
|
|
@@ -2660,7 +2678,7 @@ function setTenantDefaultsIdempotent(setter, next) {
|
|
|
2660
2678
|
setter((prev) => {
|
|
2661
2679
|
if (prev === next) return prev;
|
|
2662
2680
|
if (!prev && !next) return prev;
|
|
2663
|
-
if (prev && next && prev.layout === next.layout && prev.theme === next.theme && prev.maxPlans === next.maxPlans && prev.showFeatures === next.showFeatures && prev.ctaText === next.ctaText) {
|
|
2681
|
+
if (prev && next && prev.layout === next.layout && prev.theme === next.theme && prev.maxPlans === next.maxPlans && prev.showFeatures === next.showFeatures && prev.ctaText === next.ctaText && prev.borderRadius === next.borderRadius) {
|
|
2664
2682
|
return prev;
|
|
2665
2683
|
}
|
|
2666
2684
|
return next;
|
|
@@ -2675,7 +2693,8 @@ function extractTenantDefaults(config) {
|
|
|
2675
2693
|
theme: typeof raw.theme === "string" ? raw.theme : void 0,
|
|
2676
2694
|
maxPlans: typeof raw.maxPlans === "number" && Number.isFinite(raw.maxPlans) ? raw.maxPlans : void 0,
|
|
2677
2695
|
showFeatures: typeof raw.showFeatures === "boolean" ? raw.showFeatures : void 0,
|
|
2678
|
-
ctaText: typeof raw.ctaText === "string" && raw.ctaText.length > 0 ? raw.ctaText : void 0
|
|
2696
|
+
ctaText: typeof raw.ctaText === "string" && raw.ctaText.length > 0 ? raw.ctaText : void 0,
|
|
2697
|
+
borderRadius: typeof raw.borderRadius === "number" && Number.isFinite(raw.borderRadius) ? raw.borderRadius : void 0
|
|
2679
2698
|
};
|
|
2680
2699
|
}
|
|
2681
2700
|
var DARK_TOKEN_OVERLAY = {
|
|
@@ -2797,6 +2816,7 @@ function PricingCardBody(props) {
|
|
|
2797
2816
|
theme: themeProp,
|
|
2798
2817
|
locale: localeProp,
|
|
2799
2818
|
maxPlans: maxPlansProp,
|
|
2819
|
+
borderRadius: borderRadiusProp,
|
|
2800
2820
|
showFeatures: showFeaturesProp,
|
|
2801
2821
|
ctaText: ctaTextProp,
|
|
2802
2822
|
ctaUrl: ctaUrlProp,
|
|
@@ -2810,6 +2830,7 @@ function PricingCardBody(props) {
|
|
|
2810
2830
|
const maxPlans = typeof maxPlansProp === "number" && Number.isFinite(maxPlansProp) ? maxPlansProp : typeof tenantDefaults?.maxPlans === "number" && Number.isFinite(tenantDefaults.maxPlans) ? tenantDefaults.maxPlans : DEFAULT_MAX_PLANS;
|
|
2811
2831
|
const showFeatures = typeof showFeaturesProp === "boolean" ? showFeaturesProp : typeof tenantDefaults?.showFeatures === "boolean" ? tenantDefaults.showFeatures : true;
|
|
2812
2832
|
const ctaTextEffective = ctaTextProp ?? tenantDefaults?.ctaText ?? void 0;
|
|
2833
|
+
const cardRadius = typeof borderRadiusProp === "number" && Number.isFinite(borderRadiusProp) ? borderRadiusProp : typeof tenantDefaults?.borderRadius === "number" && Number.isFinite(tenantDefaults.borderRadius) ? tenantDefaults.borderRadius : DEFAULT_CARD_RADIUS;
|
|
2813
2834
|
const shell = useWidgetShell();
|
|
2814
2835
|
const { tokens: shellTokens, bridgeClient, telemetry, bus, tenantSlug } = shell;
|
|
2815
2836
|
const isDark = React7.useMemo(() => {
|
|
@@ -3027,7 +3048,8 @@ function PricingCardBody(props) {
|
|
|
3027
3048
|
{
|
|
3028
3049
|
layout,
|
|
3029
3050
|
tokens,
|
|
3030
|
-
prefersReducedMotion
|
|
3051
|
+
prefersReducedMotion,
|
|
3052
|
+
cardRadius
|
|
3031
3053
|
}
|
|
3032
3054
|
)
|
|
3033
3055
|
}
|
|
@@ -3099,7 +3121,8 @@ function PricingCardBody(props) {
|
|
|
3099
3121
|
ctaTextProp: ctaTextEffective,
|
|
3100
3122
|
featuredOverride: featuredOfferingId,
|
|
3101
3123
|
onCtaClick: handleCtaClick,
|
|
3102
|
-
intlOverride
|
|
3124
|
+
intlOverride,
|
|
3125
|
+
cardRadius
|
|
3103
3126
|
}
|
|
3104
3127
|
)
|
|
3105
3128
|
}
|
|
@@ -3114,7 +3137,8 @@ function PlanGrid({
|
|
|
3114
3137
|
ctaTextProp,
|
|
3115
3138
|
featuredOverride,
|
|
3116
3139
|
onCtaClick,
|
|
3117
|
-
intlOverride
|
|
3140
|
+
intlOverride,
|
|
3141
|
+
cardRadius
|
|
3118
3142
|
}) {
|
|
3119
3143
|
const isHorizontal = layout === "horizontal";
|
|
3120
3144
|
const gridStyle2 = isHorizontal ? {
|
|
@@ -3137,7 +3161,8 @@ function PlanGrid({
|
|
|
3137
3161
|
ctaTextProp,
|
|
3138
3162
|
featured: offeringIsFeatured(o, featuredOverride),
|
|
3139
3163
|
onCtaClick,
|
|
3140
|
-
intlOverride
|
|
3164
|
+
intlOverride,
|
|
3165
|
+
cardRadius
|
|
3141
3166
|
},
|
|
3142
3167
|
o.offeringId
|
|
3143
3168
|
)) });
|
|
@@ -3150,7 +3175,8 @@ function PlanCard({
|
|
|
3150
3175
|
ctaTextProp,
|
|
3151
3176
|
featured,
|
|
3152
3177
|
onCtaClick,
|
|
3153
|
-
intlOverride
|
|
3178
|
+
intlOverride,
|
|
3179
|
+
cardRadius
|
|
3154
3180
|
}) {
|
|
3155
3181
|
const { text: price, unitSuffix } = resolveDisplayPrice(offering, locale, intlOverride);
|
|
3156
3182
|
const isContactSales = price === "\u2014";
|
|
@@ -3161,7 +3187,7 @@ function PlanCard({
|
|
|
3161
3187
|
display: "flex",
|
|
3162
3188
|
flexDirection: "column",
|
|
3163
3189
|
padding: 24,
|
|
3164
|
-
borderRadius:
|
|
3190
|
+
borderRadius: cardRadius,
|
|
3165
3191
|
border: featured ? `2px solid ${tokens.primary}` : `1px solid ${tokens.border}`,
|
|
3166
3192
|
background: tokens.bg,
|
|
3167
3193
|
color: tokens.text,
|
|
@@ -3511,7 +3537,8 @@ function cellAria(label, feature) {
|
|
|
3511
3537
|
function LoadingSkeleton({
|
|
3512
3538
|
layout,
|
|
3513
3539
|
tokens,
|
|
3514
|
-
prefersReducedMotion
|
|
3540
|
+
prefersReducedMotion,
|
|
3541
|
+
cardRadius
|
|
3515
3542
|
}) {
|
|
3516
3543
|
const shimmerStyle = prefersReducedMotion ? { background: tokens.border, opacity: 0.6 } : {
|
|
3517
3544
|
background: `linear-gradient(90deg, ${tokens.border} 0%, ${tokens.bg} 50%, ${tokens.border} 100%)`,
|
|
@@ -3544,7 +3571,7 @@ function LoadingSkeleton({
|
|
|
3544
3571
|
"aria-hidden": "true",
|
|
3545
3572
|
style: {
|
|
3546
3573
|
padding: 24,
|
|
3547
|
-
borderRadius:
|
|
3574
|
+
borderRadius: cardRadius,
|
|
3548
3575
|
border: `1px solid ${tokens.border}`,
|
|
3549
3576
|
background: tokens.bg,
|
|
3550
3577
|
minHeight: 280,
|
|
@@ -12176,7 +12203,7 @@ function ResultPanel({
|
|
|
12176
12203
|
}
|
|
12177
12204
|
|
|
12178
12205
|
// src/core/version.ts
|
|
12179
|
-
var VERSION = "1.0.
|
|
12206
|
+
var VERSION = "1.0.11";
|
|
12180
12207
|
|
|
12181
12208
|
// src/core/AforoEmbed.ts
|
|
12182
12209
|
var mountedElements = /* @__PURE__ */ new WeakMap();
|
package/dist/loader.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var AforoEmbedLoader=(function(exports){'use strict';var T="1.0.
|
|
1
|
+
var AforoEmbedLoader=(function(exports){'use strict';var T="1.0.11";var y=new WeakMap,c=new Map,f={},A=false;function h(){A||typeof window!="undefined"&&(window.addEventListener("message",e=>{let t=e.data;!t||typeof t!="object"||typeof t.type!="string"||t.type.startsWith("aforo.")&&$(t);}),A=true);}function $(e){let t=c.get(e.type);if(t)for(let o of t)try{o(e);}catch(i){}let n=c.get("*");if(n)for(let o of n)try{o(e);}catch(i){}}var p=new Map;function N(e,t){p.set(e,t);}function w(e){return typeof e=="object"&&e!==null&&typeof e.tagName=="string"}var b={version:T,configure(e){f={...f,...e};},getConfig(){return {...f}},mount(e,t){var r,l,u,s,d;if(!w(e)||y.has(e))return false;let n=t.widget,o=p.get(n);if(!o)return typeof console!="undefined"&&console.warn(`[aforo:embed] No mount handler registered for widget "${n}". Loader bundle may not have finished loading.`),false;let i={widget:n,tenantSlug:(l=(r=t.tenantSlug)!=null?r:f.tenantSlug)!=null?l:"",embedKey:(s=(u=t.embedKey)!=null?u:f.embedKey)!=null?s:"",bridgeToken:(d=t.bridgeToken)!=null?d:f.bridgeToken,layout:t.layout,themeOverrides:t.themeOverrides,config:t.config};if(!i.tenantSlug||!i.embedKey)return typeof console!="undefined"&&console.error(`[aforo:embed] Widget "${n}" requires tenantSlug + embedKey. Provide via AforoEmbed.configure() or data-* attributes.`),false;h();let a=o(e,i);return y.set(e,{element:e,widget:n,teardown:a}),true},unmount(e){if(!w(e))return false;let t=y.get(e);if(!t)return false;try{t.teardown();}catch(n){}return y.delete(e),true},on(e,t){h();let n=c.get(e);return n||(n=new Set,c.set(e,n)),n.add(t),()=>{let o=c.get(e);o&&(o.delete(t),o.size===0&&c.delete(e));}},_registerWidget:N,_registeredWidgetsForTesting(){return Array.from(p.keys())},_resetForTesting(){p.clear(),c.clear(),f={};}};function k(e){if(!e)return {};try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){let n={},o=["primary","primaryContrast","text","textMuted","bg","border","radius","fontFamily"],i=t;for(let a of o){let r=i[a];typeof r=="string"&&r.length>0&&(n[a]=r);}return n}}catch(t){}return {}}var U=new Set(["pricing-card","subscribe-button","checkout-flow","subscription-manager","invoice-list","usage-meter","payment-method","upgrade-cancel"]),B="https://embed.aforo.ai/v1/widgets",g="[aforo:loader]";function D(){let e=typeof document!="undefined"?document.currentScript:null;if(e&&e.tagName==="SCRIPT")return e;if(typeof document!="undefined"){let t=document.getElementsByTagName("script");for(let n=t.length-1;n>=0;n--){let o=t[n];if(!o)continue;let i=o.getAttribute("src")||"";if(/(\/v1)?\/loader(\.umd)?\.js$/.test(i))return o}}return null}function G(e){let t=e==null?void 0:e.getAttribute("src");if(!t)return null;try{let n=typeof location!="undefined"?location.href:void 0,o=new URL(t,n),i=o.pathname.replace(/\/loader(\.umd)?\.js$/,"");return `${o.origin}${i}/widgets`}catch(n){return null}}function v(e,t){let n=e.getAttribute(t);if(n==null||n.trim()==="")return;let o=Number(n);return Number.isFinite(o)?o:void 0}function j(e,t){let n=e.getAttribute(t);if(n==null)return;let o=n.trim().toLowerCase();if(o==="true")return true;if(o==="false")return false}function V(e){let t=(e.getAttribute("data-aforo-widget")||"").trim(),n=e.getAttribute("data-tenant-slug")||e.getAttribute("data-tenant")||"",o=e.getAttribute("data-embed-key")||"",i=e.getAttribute("data-bridge-token")||void 0,a=e.getAttribute("data-layout")||void 0,r=k(e.getAttribute("data-theme-overrides")),l=e.getAttribute("data-offering-id")||void 0,u=e.getAttribute("data-subscription-id")||void 0,s=e.getAttribute("data-metric")||void 0,d=e.getAttribute("data-featured-offering-id")||void 0,m=e.getAttribute("data-mode")||void 0,M=e.getAttribute("data-return-url")||void 0,S=e.getAttribute("data-default-status")||void 0,F=e.getAttribute("data-render-mode")||void 0,_=e.getAttribute("data-locale")||void 0,C=v(e,"data-page-size"),O=v(e,"data-poll-interval-ms"),I=e.getAttribute("data-theme")||void 0,R=e.getAttribute("data-cart-type")||void 0,W=e.getAttribute("data-target-id")||void 0,H=e.getAttribute("data-cta-text")||void 0,x=e.getAttribute("data-cta-url")||void 0,P=v(e,"data-max-plans"),K=j(e,"data-show-features");return {widget:t,tenantSlug:n,embedKey:o,bridgeToken:i,layout:a,themeOverrides:r,config:{offeringId:l,subscriptionId:u,metricName:s,featuredOfferingId:d,mode:m,returnUrl:M,defaultStatus:S,renderMode:F,locale:_,pageSize:C,pollIntervalMs:O,theme:I,cartType:R,targetId:W,ctaText:H,ctaUrl:x,maxPlans:P,showFeatures:K}}}function z(e,t,n){return new Promise((o,i)=>{if(typeof document=="undefined")return i(new Error("no document"));let a=document.querySelector(`script[data-aforo-bundle="${e}"]`);if(a){if(a.dataset.aforoLoaded==="1")return o();a.addEventListener("load",()=>o()),a.addEventListener("error",()=>i(new Error(`bundle load failed: ${e}`)));return}let r=document.createElement("script");r.src=`${t}/${e}.js`,r.async=true,r.crossOrigin="anonymous",r.dataset.aforoBundle=e,n&&r.setAttribute("nonce",n),r.addEventListener("load",()=>{r.dataset.aforoLoaded="1",o();}),r.addEventListener("error",()=>i(new Error(`bundle load failed: ${e}`))),document.head.appendChild(r);})}function L(e){if(!e.__aforoEmbedReadyFired){e.__aforoEmbedReadyFired=true;try{typeof e.aforoEmbedReady=="function"&&e.aforoEmbedReady();}catch(t){typeof console!="undefined"&&console.error(`${g} aforoEmbedReady callback threw`,t);}if(typeof document!="undefined"&&typeof CustomEvent!="undefined")try{document.dispatchEvent(new CustomEvent("aforoEmbedReady"));}catch(t){}}}async function E(e){if(typeof window=="undefined"||typeof document=="undefined")return;let t=window;if(window.location.protocol!=="https:"&&window.location.hostname!=="localhost"){typeof console!="undefined"&&console.error(`${g} Refusing to mount Aforo widgets on a non-HTTPS page. Embed Plugin requires HTTPS (FR-TIER-12). Current origin: ${window.location.origin}`);return}if(t.__aforoEmbedLoaderInitialized){typeof console!="undefined"&&console.warn(`${g} Loader already initialised on this page \u2014 skipping duplicate run.`);return}t.__aforoEmbedLoaderInitialized=true,t.aforoEmbed||(t.aforoEmbed=b);let n=D(),o=(n==null?void 0:n.getAttribute("nonce"))||null,i=(e==null?void 0:e.bundleBaseUrl)||G(n)||B,a=Array.from(document.querySelectorAll("[data-aforo-widget]"));if(a.length===0){L(t);return}let r=new Map;for(let u of a){let s=(u.getAttribute("data-aforo-widget")||"").trim();if(!U.has(s)){typeof console!="undefined"&&console.warn(`${g} Unknown widget id "${s}" \u2014 skipping`);continue}let d=r.get(s);d||(d=[],r.set(s,d)),d.push(u);}let l=Array.from(r.entries()).map(async([u,s])=>{try{await z(u,i,o);for(let d of s){let m=V(d);if(!m.widget||!m.tenantSlug||!m.embedKey){typeof console!="undefined"&&console.error(`${g} Placeholder missing required attributes (data-tenant-slug + data-embed-key). Skipping element.`,d);continue}b.mount(d,m);}}catch(d){typeof console!="undefined"&&console.error(`${g} Failed to load bundle for "${u}"`,d);}});await Promise.all(l).catch(()=>{}),L(t);}typeof document!="undefined"&&document.readyState!=="loading"?Promise.resolve().then(()=>{E();}):typeof document!="undefined"&&document.addEventListener("DOMContentLoaded",()=>{E();});b._loader={bootstrap:E};
|
|
2
2
|
exports.AforoEmbed=b;exports.bootstrap=E;return exports;})({});//# sourceMappingURL=loader.js.map
|
|
3
3
|
//# sourceMappingURL=loader.js.map
|
package/dist/loader.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var T="1.0.
|
|
1
|
+
var T="1.0.11";var y=new WeakMap,c=new Map,f={},A=false;function h(){A||typeof window!="undefined"&&(window.addEventListener("message",e=>{let t=e.data;!t||typeof t!="object"||typeof t.type!="string"||t.type.startsWith("aforo.")&&$(t);}),A=true);}function $(e){let t=c.get(e.type);if(t)for(let o of t)try{o(e);}catch(i){}let n=c.get("*");if(n)for(let o of n)try{o(e);}catch(i){}}var p=new Map;function N(e,t){p.set(e,t);}function w(e){return typeof e=="object"&&e!==null&&typeof e.tagName=="string"}var b={version:T,configure(e){f={...f,...e};},getConfig(){return {...f}},mount(e,t){var r,l,u,s,d;if(!w(e)||y.has(e))return false;let n=t.widget,o=p.get(n);if(!o)return typeof console!="undefined"&&console.warn(`[aforo:embed] No mount handler registered for widget "${n}". Loader bundle may not have finished loading.`),false;let i={widget:n,tenantSlug:(l=(r=t.tenantSlug)!=null?r:f.tenantSlug)!=null?l:"",embedKey:(s=(u=t.embedKey)!=null?u:f.embedKey)!=null?s:"",bridgeToken:(d=t.bridgeToken)!=null?d:f.bridgeToken,layout:t.layout,themeOverrides:t.themeOverrides,config:t.config};if(!i.tenantSlug||!i.embedKey)return typeof console!="undefined"&&console.error(`[aforo:embed] Widget "${n}" requires tenantSlug + embedKey. Provide via AforoEmbed.configure() or data-* attributes.`),false;h();let a=o(e,i);return y.set(e,{element:e,widget:n,teardown:a}),true},unmount(e){if(!w(e))return false;let t=y.get(e);if(!t)return false;try{t.teardown();}catch(n){}return y.delete(e),true},on(e,t){h();let n=c.get(e);return n||(n=new Set,c.set(e,n)),n.add(t),()=>{let o=c.get(e);o&&(o.delete(t),o.size===0&&c.delete(e));}},_registerWidget:N,_registeredWidgetsForTesting(){return Array.from(p.keys())},_resetForTesting(){p.clear(),c.clear(),f={};}};function k(e){if(!e)return {};try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){let n={},o=["primary","primaryContrast","text","textMuted","bg","border","radius","fontFamily"],i=t;for(let a of o){let r=i[a];typeof r=="string"&&r.length>0&&(n[a]=r);}return n}}catch(t){}return {}}var U=new Set(["pricing-card","subscribe-button","checkout-flow","subscription-manager","invoice-list","usage-meter","payment-method","upgrade-cancel"]),B="https://embed.aforo.ai/v1/widgets",g="[aforo:loader]";function D(){let e=typeof document!="undefined"?document.currentScript:null;if(e&&e.tagName==="SCRIPT")return e;if(typeof document!="undefined"){let t=document.getElementsByTagName("script");for(let n=t.length-1;n>=0;n--){let o=t[n];if(!o)continue;let i=o.getAttribute("src")||"";if(/(\/v1)?\/loader(\.umd)?\.js$/.test(i))return o}}return null}function G(e){let t=e==null?void 0:e.getAttribute("src");if(!t)return null;try{let n=typeof location!="undefined"?location.href:void 0,o=new URL(t,n),i=o.pathname.replace(/\/loader(\.umd)?\.js$/,"");return `${o.origin}${i}/widgets`}catch(n){return null}}function v(e,t){let n=e.getAttribute(t);if(n==null||n.trim()==="")return;let o=Number(n);return Number.isFinite(o)?o:void 0}function j(e,t){let n=e.getAttribute(t);if(n==null)return;let o=n.trim().toLowerCase();if(o==="true")return true;if(o==="false")return false}function V(e){let t=(e.getAttribute("data-aforo-widget")||"").trim(),n=e.getAttribute("data-tenant-slug")||e.getAttribute("data-tenant")||"",o=e.getAttribute("data-embed-key")||"",i=e.getAttribute("data-bridge-token")||void 0,a=e.getAttribute("data-layout")||void 0,r=k(e.getAttribute("data-theme-overrides")),l=e.getAttribute("data-offering-id")||void 0,u=e.getAttribute("data-subscription-id")||void 0,s=e.getAttribute("data-metric")||void 0,d=e.getAttribute("data-featured-offering-id")||void 0,m=e.getAttribute("data-mode")||void 0,M=e.getAttribute("data-return-url")||void 0,S=e.getAttribute("data-default-status")||void 0,F=e.getAttribute("data-render-mode")||void 0,_=e.getAttribute("data-locale")||void 0,C=v(e,"data-page-size"),O=v(e,"data-poll-interval-ms"),I=e.getAttribute("data-theme")||void 0,R=e.getAttribute("data-cart-type")||void 0,W=e.getAttribute("data-target-id")||void 0,H=e.getAttribute("data-cta-text")||void 0,x=e.getAttribute("data-cta-url")||void 0,P=v(e,"data-max-plans"),K=j(e,"data-show-features");return {widget:t,tenantSlug:n,embedKey:o,bridgeToken:i,layout:a,themeOverrides:r,config:{offeringId:l,subscriptionId:u,metricName:s,featuredOfferingId:d,mode:m,returnUrl:M,defaultStatus:S,renderMode:F,locale:_,pageSize:C,pollIntervalMs:O,theme:I,cartType:R,targetId:W,ctaText:H,ctaUrl:x,maxPlans:P,showFeatures:K}}}function z(e,t,n){return new Promise((o,i)=>{if(typeof document=="undefined")return i(new Error("no document"));let a=document.querySelector(`script[data-aforo-bundle="${e}"]`);if(a){if(a.dataset.aforoLoaded==="1")return o();a.addEventListener("load",()=>o()),a.addEventListener("error",()=>i(new Error(`bundle load failed: ${e}`)));return}let r=document.createElement("script");r.src=`${t}/${e}.js`,r.async=true,r.crossOrigin="anonymous",r.dataset.aforoBundle=e,n&&r.setAttribute("nonce",n),r.addEventListener("load",()=>{r.dataset.aforoLoaded="1",o();}),r.addEventListener("error",()=>i(new Error(`bundle load failed: ${e}`))),document.head.appendChild(r);})}function L(e){if(!e.__aforoEmbedReadyFired){e.__aforoEmbedReadyFired=true;try{typeof e.aforoEmbedReady=="function"&&e.aforoEmbedReady();}catch(t){typeof console!="undefined"&&console.error(`${g} aforoEmbedReady callback threw`,t);}if(typeof document!="undefined"&&typeof CustomEvent!="undefined")try{document.dispatchEvent(new CustomEvent("aforoEmbedReady"));}catch(t){}}}async function E(e){if(typeof window=="undefined"||typeof document=="undefined")return;let t=window;if(window.location.protocol!=="https:"&&window.location.hostname!=="localhost"){typeof console!="undefined"&&console.error(`${g} Refusing to mount Aforo widgets on a non-HTTPS page. Embed Plugin requires HTTPS (FR-TIER-12). Current origin: ${window.location.origin}`);return}if(t.__aforoEmbedLoaderInitialized){typeof console!="undefined"&&console.warn(`${g} Loader already initialised on this page \u2014 skipping duplicate run.`);return}t.__aforoEmbedLoaderInitialized=true,t.aforoEmbed||(t.aforoEmbed=b);let n=D(),o=(n==null?void 0:n.getAttribute("nonce"))||null,i=(e==null?void 0:e.bundleBaseUrl)||G(n)||B,a=Array.from(document.querySelectorAll("[data-aforo-widget]"));if(a.length===0){L(t);return}let r=new Map;for(let u of a){let s=(u.getAttribute("data-aforo-widget")||"").trim();if(!U.has(s)){typeof console!="undefined"&&console.warn(`${g} Unknown widget id "${s}" \u2014 skipping`);continue}let d=r.get(s);d||(d=[],r.set(s,d)),d.push(u);}let l=Array.from(r.entries()).map(async([u,s])=>{try{await z(u,i,o);for(let d of s){let m=V(d);if(!m.widget||!m.tenantSlug||!m.embedKey){typeof console!="undefined"&&console.error(`${g} Placeholder missing required attributes (data-tenant-slug + data-embed-key). Skipping element.`,d);continue}b.mount(d,m);}}catch(d){typeof console!="undefined"&&console.error(`${g} Failed to load bundle for "${u}"`,d);}});await Promise.all(l).catch(()=>{}),L(t);}typeof document!="undefined"&&document.readyState!=="loading"?Promise.resolve().then(()=>{E();}):typeof document!="undefined"&&document.addEventListener("DOMContentLoaded",()=>{E();});b._loader={bootstrap:E};
|
|
2
2
|
export{b as AforoEmbed,E as bootstrap};//# sourceMappingURL=loader.mjs.map
|
|
3
3
|
//# sourceMappingURL=loader.mjs.map
|
package/dist/sri.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
3
|
-
"generatedAt": "2026-08-
|
|
2
|
+
"version": "1.0.11",
|
|
3
|
+
"generatedAt": "2026-08-30T06:56:50.009Z",
|
|
4
4
|
"bundles": {
|
|
5
|
-
"loader.js": "sha384-
|
|
6
|
-
"widgets/checkout-flow.js": "sha384-
|
|
7
|
-
"widgets/invoice-list.js": "sha384-
|
|
8
|
-
"widgets/payment-method.js": "sha384-
|
|
9
|
-
"widgets/pricing-card.js": "sha384-
|
|
10
|
-
"widgets/subscribe-button.js": "sha384-
|
|
11
|
-
"widgets/subscription-manager.js": "sha384-
|
|
12
|
-
"widgets/upgrade-cancel.js": "sha384-
|
|
13
|
-
"widgets/usage-meter.js": "sha384-
|
|
5
|
+
"loader.js": "sha384-uTXiwN0zz6PH9Cpjfpfro+Kv3SjiWC5zDWrnoU7ztiiJZ53k6t5tOTuFQO0gNdsb",
|
|
6
|
+
"widgets/checkout-flow.js": "sha384-58hUZ91oYLzHGFTyCWPrPDYY794p2DOmLc6UsGEqT+idZHGPUVPWiNC7goGziA3a",
|
|
7
|
+
"widgets/invoice-list.js": "sha384-9yX9pfTTxyNk4/gzoNtwR/QjCr6zVCm2+gHFU2mVTt9CkMiIcu8e3mIUiGOyb4US",
|
|
8
|
+
"widgets/payment-method.js": "sha384-52GbGJhqU38OQcJQI8QROQ/O2jB+Zdo4U6CnwupTrJw9UZA/+1OS2NjNpkfawTDo",
|
|
9
|
+
"widgets/pricing-card.js": "sha384-WOmeOXYvgpDb+fgP88LQz14UE4znbtf9qatp1/piTb9rqEVen7IAAj+HNmvRNlr+",
|
|
10
|
+
"widgets/subscribe-button.js": "sha384-9kmGVVkWriGzhZMtRfR+pIJdjO0kpVStTcbQnO4ByZf1vyQ/OorqAfOyNN1He0KS",
|
|
11
|
+
"widgets/subscription-manager.js": "sha384-F3Jm5kORXyoIG7wZiV21zW4LXWFaCVooKch8z2EgcdjYFvuZYyX8wFVmje2MmV7I",
|
|
12
|
+
"widgets/upgrade-cancel.js": "sha384-Q+qTSjxOvB45ql6Erx/jTL6OxIjnfEp3z9LCI3/BOPjrhMMQgTJxP/oJkfD83BiJ",
|
|
13
|
+
"widgets/usage-meter.js": "sha384-dsxc/4fyzinNYVkFFU720jpF/SQpibGuO++gtUOcJKWdiKVqQXvk/7c8Q6kDs5Dk"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1030,8 +1030,13 @@ interface CancelResponse {
|
|
|
1030
1030
|
cancelledAt: string | null;
|
|
1031
1031
|
/** ISO-8601 timestamp the cancellation takes/took effect (today for IMMEDIATE, period end for PERIOD_END). */
|
|
1032
1032
|
effectiveAt: string;
|
|
1033
|
-
/**
|
|
1034
|
-
|
|
1033
|
+
/**
|
|
1034
|
+
* V50 feedback row id — useful for audit cross-reference. Nullable:
|
|
1035
|
+
* storefront-service's cancel endpoint doesn't read it back from
|
|
1036
|
+
* pricing-service after writing it (documented follow-up), so it's
|
|
1037
|
+
* omitted from the response today (2026-08-29).
|
|
1038
|
+
*/
|
|
1039
|
+
feedbackId: string | null;
|
|
1035
1040
|
/** Credit note produced by an IMMEDIATE cancel with prorated refund. */
|
|
1036
1041
|
creditNoteId: string | null;
|
|
1037
1042
|
}
|
|
@@ -1030,8 +1030,13 @@ interface CancelResponse {
|
|
|
1030
1030
|
cancelledAt: string | null;
|
|
1031
1031
|
/** ISO-8601 timestamp the cancellation takes/took effect (today for IMMEDIATE, period end for PERIOD_END). */
|
|
1032
1032
|
effectiveAt: string;
|
|
1033
|
-
/**
|
|
1034
|
-
|
|
1033
|
+
/**
|
|
1034
|
+
* V50 feedback row id — useful for audit cross-reference. Nullable:
|
|
1035
|
+
* storefront-service's cancel endpoint doesn't read it back from
|
|
1036
|
+
* pricing-service after writing it (documented follow-up), so it's
|
|
1037
|
+
* omitted from the response today (2026-08-29).
|
|
1038
|
+
*/
|
|
1039
|
+
feedbackId: string | null;
|
|
1035
1040
|
/** Credit note produced by an IMMEDIATE cancel with prorated refund. */
|
|
1036
1041
|
creditNoteId: string | null;
|
|
1037
1042
|
}
|