@wix/himalaya-cli 0.2047.0 → 0.2048.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 (24) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/index.d.ts +5 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/monitoring.d.ts +81 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +1 -1
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/apple-iap-contract.d.ts +7 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/checkout-monitoring.d.ts +23 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -1
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -1
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -1
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +1 -1
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +530 -68
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap.mjs +198 -0
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -1
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +1 -1
  14. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -1
  15. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +532 -70
  16. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -1
  17. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -1
  18. package/dist/browser-plane/assets.json +5 -5
  19. package/dist/browser-plane/preview-deferred/{bfa6093b86d3106ef891a717dc0da1b1c0d9d1a456259753c25398bbafbcef8e.bin → 78e9187a8551e2a63e7bc9f5cda8449c6a39ba3d9bcfa40947713322e68a3e3b.bin} +1 -1
  20. package/dist/browser-plane/sw.js +7 -7
  21. package/dist/cli.mjs +48 -47
  22. package/dist/preview-assets.generated.bin +0 -0
  23. package/guides/sdk-reference.json +121 -2
  24. package/package.json +2 -2
@@ -1624,6 +1624,192 @@ var numeric = (value) => typeof value === "number" ? value : void 0;
1624
1624
  var boolean = (value) => typeof value === "boolean" ? value : void 0;
1625
1625
  var zeroPrice = (value) => typeof value === "string" && /^0+(?:\.0+)?$/.test(value);
1626
1626
 
1627
+ // ../../core/sdk/iap/src/monitoring.ts
1628
+ var FORBIDDEN_IAP_FIELDS = [
1629
+ "memberid",
1630
+ "contactid",
1631
+ "sitememberid",
1632
+ "userid",
1633
+ "appuserid",
1634
+ "uuid",
1635
+ "visitorid",
1636
+ "signedtransaction",
1637
+ "jws",
1638
+ "signedinstance",
1639
+ "instance",
1640
+ "signedpayload",
1641
+ "cookie",
1642
+ "cookies",
1643
+ "authorization",
1644
+ "token",
1645
+ "accesstoken",
1646
+ "appaccounttoken",
1647
+ "refreshtoken",
1648
+ "session",
1649
+ "email",
1650
+ "emailaddress",
1651
+ "name",
1652
+ "firstname",
1653
+ "lastname",
1654
+ "fullname",
1655
+ "nickname",
1656
+ "phone"
1657
+ ];
1658
+ var FORBIDDEN = new Set(FORBIDDEN_IAP_FIELDS);
1659
+ var JWS = /^[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}$/;
1660
+ var EMAIL = /[^\s@]+@[^\s@]+\.[^\s@]+/;
1661
+ var HTTP_FAILURE = /^HTTP (\d{3})(?: \[([A-Za-z0-9_]+)\])?/;
1662
+ var TRANSACTION = "IapPurchase";
1663
+ var isForbiddenKey = (key) => FORBIDDEN.has(key.toLowerCase().replace(/[_-]/g, ""));
1664
+ var isForbiddenValue = (value) => typeof value === "string" && (JWS.test(value) || EMAIL.test(value));
1665
+ function scrubIapData(data) {
1666
+ return scrubObject(data, 0);
1667
+ }
1668
+ var MAX_DEPTH = 3;
1669
+ function scrubObject(data, depth) {
1670
+ const kept = {};
1671
+ for (const [key, value] of Object.entries(data)) {
1672
+ if (isForbiddenKey(key)) continue;
1673
+ const scrubbed = scrubValue(value, depth);
1674
+ if (scrubbed !== void 0) kept[key] = scrubbed;
1675
+ }
1676
+ return kept;
1677
+ }
1678
+ function scrubValue(value, depth) {
1679
+ if (value === void 0 || isForbiddenValue(value)) return void 0;
1680
+ if (Array.isArray(value) || isPlainObject2(value)) {
1681
+ if (depth >= MAX_DEPTH) return void 0;
1682
+ return Array.isArray(value) ? value.map((item) => scrubValue(item, depth + 1)).filter((item) => item !== void 0) : scrubObject(value, depth + 1);
1683
+ }
1684
+ return value === null || ["string", "number", "boolean"].includes(typeof value) ? value : void 0;
1685
+ }
1686
+ function describeIapError(error) {
1687
+ try {
1688
+ if (error === void 0 || error === null) return {};
1689
+ const failure3 = typeof error === "object" ? error : {};
1690
+ const http = typeof failure3.message === "string" ? HTTP_FAILURE.exec(failure3.message) : null;
1691
+ const status = failure3.httpStatus ?? failure3.status ?? (http ? Number(http[1]) : void 0);
1692
+ const code = failure3.code ?? failure3.kind ?? http?.[2];
1693
+ return defined({
1694
+ // `httpStatus`, not `status`: an outcome's `status` is the purchase's (bought, failed…).
1695
+ httpStatus: typeof status === "number" ? status : void 0,
1696
+ code: typeof code === "string" ? code : void 0,
1697
+ requestId: typeof failure3.requestId === "string" ? failure3.requestId : void 0,
1698
+ // The error's type, never its message: the bridge copies part of the server's response into
1699
+ // the message, and no filter can recognise every id or token that text may echo.
1700
+ // Read by shape: a rejection can come from another realm.
1701
+ error: typeof failure3.name === "string" && typeof failure3.message === "string" ? failure3.name : void 0
1702
+ });
1703
+ } catch {
1704
+ return {};
1705
+ }
1706
+ }
1707
+ function outcomeLevel(outcome) {
1708
+ if (outcome.status === "failed" || outcome.status === "error") return outcome.charged === true ? "error" : "warn";
1709
+ return "info";
1710
+ }
1711
+ function createIapMonitor(options) {
1712
+ const { sink } = options;
1713
+ const now = options.now ?? Date.now;
1714
+ const newId = options.newId ?? newFlowId;
1715
+ let gateLogged = false;
1716
+ function log(type, data = {}, level = "info") {
1717
+ safely(() => {
1718
+ const shared2 = safeContext(options.context);
1719
+ sink({ type, level, data: scrubIapData({ ...shared2, ...data, eventAt: now() }) });
1720
+ });
1721
+ }
1722
+ function bug(fingerprint, error, data = {}) {
1723
+ log(`iap.bug.${fingerprint.replace("himi-iap-", "")}`, { ...data, ...describeIapError(error), fingerprint }, "error");
1724
+ }
1725
+ function gate(gate2) {
1726
+ if (gateLogged) return;
1727
+ gateLogged = true;
1728
+ log("iap.gate", gate2);
1729
+ }
1730
+ return { log, bug, gate, flow: (entry, ids = {}) => createIapFlow(entry, ids, { log, now, flowId: newId() }) };
1731
+ }
1732
+ function createIapFlow(entry, initial, host) {
1733
+ const { flowId } = host;
1734
+ const ids = {};
1735
+ const stepMs = {};
1736
+ const notes = {};
1737
+ const startedAt = host.now();
1738
+ let stepStartedAt = startedAt;
1739
+ let lastStep;
1740
+ const add = (next) => {
1741
+ Object.assign(ids, defined(next));
1742
+ };
1743
+ const data = (extra = {}) => ({ flowId, entry, ...ids, ...extra });
1744
+ const transaction = () => ({ transaction: TRANSACTION, id: flowId, flowId, entry });
1745
+ const closeStep = () => {
1746
+ const at = host.now();
1747
+ if (lastStep) stepMs[lastStep] = (stepMs[lastStep] ?? 0) + at - stepStartedAt;
1748
+ stepStartedAt = at;
1749
+ };
1750
+ add(initial);
1751
+ return {
1752
+ flowId,
1753
+ entry,
1754
+ add,
1755
+ get knownIds() {
1756
+ return { ...ids };
1757
+ },
1758
+ at(step) {
1759
+ closeStep();
1760
+ lastStep = step;
1761
+ },
1762
+ note(extra) {
1763
+ Object.assign(notes, defined(extra));
1764
+ },
1765
+ started(extra = {}) {
1766
+ host.log("iap.purchase.started", data(extra));
1767
+ host.log("iap.transaction.start", transaction());
1768
+ },
1769
+ failed(step, error, extra = {}, level = extra.charged === true ? "error" : "warn") {
1770
+ host.log(`iap.${step}.failed`, data({ ...describeIapError(error), ...extra }), level);
1771
+ },
1772
+ outcome(outcome, messageKey, extra = {}) {
1773
+ closeStep();
1774
+ host.log("iap.purchase.outcome", data({
1775
+ ...notes,
1776
+ ...outcome,
1777
+ messageKey,
1778
+ lastStep,
1779
+ stepMs: { ...stepMs },
1780
+ durationMs: host.now() - startedAt,
1781
+ ...extra
1782
+ }), outcomeLevel(outcome));
1783
+ if (outcome.status === "bought") host.log("iap.transaction.finish", transaction());
1784
+ }
1785
+ };
1786
+ }
1787
+ function safeContext(context) {
1788
+ try {
1789
+ return context ? { ...context() } : {};
1790
+ } catch {
1791
+ return {};
1792
+ }
1793
+ }
1794
+ function safely(run) {
1795
+ try {
1796
+ run();
1797
+ } catch {
1798
+ }
1799
+ }
1800
+ function defined(data) {
1801
+ return Object.fromEntries(Object.entries(data).filter(([, value]) => value !== void 0));
1802
+ }
1803
+ function isPlainObject2(value) {
1804
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
1805
+ const prototype = Object.getPrototypeOf(value);
1806
+ return prototype === Object.prototype || prototype === null;
1807
+ }
1808
+ function newFlowId() {
1809
+ const random = globalThis.crypto?.randomUUID?.();
1810
+ return random ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
1811
+ }
1812
+
1627
1813
  // ../../core/sdk/iap/src/index.ts
1628
1814
  async function getPaywallConfig() {
1629
1815
  const r = await dispatch("capability.iap.getPaywallConfig");
@@ -1643,6 +1829,12 @@ async function storefrontCountryCode() {
1643
1829
  return null;
1644
1830
  }
1645
1831
  }
1832
+ var nativeIapEventSink = (event) => {
1833
+ try {
1834
+ dispatch("capability.iap.logEvent", { type: event.type, level: event.level, data: JSON.stringify(event.data) }).catch(() => void 0);
1835
+ } catch {
1836
+ }
1837
+ };
1646
1838
  async function getProducts(productIds) {
1647
1839
  if (!productIds || productIds.length === 0) return [];
1648
1840
  const r = await dispatch("capability.iap.getProducts", {
@@ -1766,6 +1958,7 @@ export {
1766
1958
  APPLE_PRICING_RULES,
1767
1959
  APPLE_PROVISIONING_RULES,
1768
1960
  APPLE_SALE_RULES,
1961
+ FORBIDDEN_IAP_FIELDS,
1769
1962
  HIMALAYA_SERVE_IAP_ROUTE,
1770
1963
  IAP_CATALOG_KINDS,
1771
1964
  MAX_AUTOMATIC_ATTEMPTS,
@@ -1782,9 +1975,11 @@ export {
1782
1975
  consume,
1783
1976
  createHostSession,
1784
1977
  createIapCatalogPricing,
1978
+ createIapMonitor,
1785
1979
  createPricingController,
1786
1980
  createPurchaseCoordinator,
1787
1981
  createWixIapClient,
1982
+ describeIapError,
1788
1983
  entitlements,
1789
1984
  finishTransaction,
1790
1985
  getPaywallConfig,
@@ -1794,11 +1989,14 @@ export {
1794
1989
  hostSessionFromGlobal,
1795
1990
  iapPriceFields,
1796
1991
  memberIdentityOf,
1992
+ nativeIapEventSink,
1797
1993
  onlineProgramItem,
1994
+ outcomeLevel,
1798
1995
  purchase,
1799
1996
  purchaseForVerification,
1800
1997
  readIdentityBound,
1801
1998
  restore,
1999
+ scrubIapData,
1802
2000
  sharedHostAppBindingSource,
1803
2001
  storefrontCountryCode,
1804
2002
  ticketAttendanceOf,
@@ -33,7 +33,7 @@ var CAPABILITY_REGISTRY = {
33
33
  "haptic": ["play", "sequence", "vibrate"],
34
34
  "health": ["availability", "getPermissionStatus", "query", "requestPermission", "saveWorkout"],
35
35
  "himi_apps": ["canOpen", "current", "hostInfo", "open"],
36
- "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore", "storefront"],
36
+ "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "logEvent", "purchase", "purchaseForVerification", "restore", "storefront"],
37
37
  "image_labeling": ["availability", "label"],
38
38
  "keyboard": ["dismiss"],
39
39
  "legacy_import": ["ack", "read"],
@@ -33,7 +33,7 @@ var CAPABILITY_REGISTRY = {
33
33
  "haptic": ["play", "sequence", "vibrate"],
34
34
  "health": ["availability", "getPermissionStatus", "query", "requestPermission", "saveWorkout"],
35
35
  "himi_apps": ["canOpen", "current", "hostInfo", "open"],
36
- "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore", "storefront"],
36
+ "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "logEvent", "purchase", "purchaseForVerification", "restore", "storefront"],
37
37
  "image_labeling": ["availability", "label"],
38
38
  "keyboard": ["dismiss"],
39
39
  "legacy_import": ["ack", "read"],
@@ -33,7 +33,7 @@ var CAPABILITY_REGISTRY = {
33
33
  "haptic": ["play", "sequence", "vibrate"],
34
34
  "health": ["availability", "getPermissionStatus", "query", "requestPermission", "saveWorkout"],
35
35
  "himi_apps": ["canOpen", "current", "hostInfo", "open"],
36
- "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "purchase", "purchaseForVerification", "restore", "storefront"],
36
+ "iap": ["appBinding", "consume", "entitlements", "finishTransaction", "getPaywallConfig", "getProducts", "getUnfinishedTransactions", "logEvent", "purchase", "purchaseForVerification", "restore", "storefront"],
37
37
  "image_labeling": ["availability", "label"],
38
38
  "keyboard": ["dismiss"],
39
39
  "legacy_import": ["ack", "read"],