@blocklet/launcher-util 2.3.49 → 2.3.50

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/es/util.js CHANGED
@@ -129,14 +129,16 @@ const getBlockletUrlOnStore = ({ did, baseUrl }) => {
129
129
  }
130
130
  };
131
131
  const getDefaultTrialEnd = () => moment().add(1, "years").unix();
132
- const getProductFreeTrial = (typeName, freeTrialProducts) => {
133
- const result = { isFreeTrial: false };
132
+ const getProductFreeTrial = ({ typeName, freeTrialProducts, currencyId }) => {
134
133
  if (!Array.isArray(freeTrialProducts)) {
135
- return result;
134
+ return null;
136
135
  }
137
- const matched = freeTrialProducts.find((x) => x.productTypeName === typeName && x.isFreeTrial);
136
+ const matched = freeTrialProducts.find((x) => {
137
+ const paymentCurrencies = x.paymentCurrencies.split(",").map((y) => y.trim()).filter(Boolean);
138
+ return x.productTypeName === typeName && x.isFreeTrial && paymentCurrencies.includes(currencyId);
139
+ });
138
140
  if (!matched) {
139
- return result;
141
+ return null;
140
142
  }
141
143
  return matched;
142
144
  };
package/lib/util.js CHANGED
@@ -131,14 +131,16 @@ const getBlockletUrlOnStore = ({ did, baseUrl }) => {
131
131
  }
132
132
  };
133
133
  const getDefaultTrialEnd = () => moment().add(1, "years").unix();
134
- const getProductFreeTrial = (typeName, freeTrialProducts) => {
135
- const result = { isFreeTrial: false };
134
+ const getProductFreeTrial = ({ typeName, freeTrialProducts, currencyId }) => {
136
135
  if (!Array.isArray(freeTrialProducts)) {
137
- return result;
136
+ return null;
138
137
  }
139
- const matched = freeTrialProducts.find((x) => x.productTypeName === typeName && x.isFreeTrial);
138
+ const matched = freeTrialProducts.find((x) => {
139
+ const paymentCurrencies = x.paymentCurrencies.split(",").map((y) => y.trim()).filter(Boolean);
140
+ return x.productTypeName === typeName && x.isFreeTrial && paymentCurrencies.includes(currencyId);
141
+ });
140
142
  if (!matched) {
141
- return result;
143
+ return null;
142
144
  }
143
145
  return matched;
144
146
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-util",
3
- "version": "2.3.49",
3
+ "version": "2.3.50",
4
4
  "description": "Common constants",
5
5
  "keywords": [
6
6
  "constant"
@@ -35,7 +35,7 @@
35
35
  "url": "https://github.com/blocklet/launcher/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@blocklet/sdk": "1.16.29",
38
+ "@blocklet/sdk": "1.16.30",
39
39
  "@ocap/util": "^1.18.132",
40
40
  "axios": "^0.27.2",
41
41
  "flat": "^5.0.2",
@@ -48,5 +48,5 @@
48
48
  "vite": "^5.4.2",
49
49
  "vite-plugin-build": "^0.10.0"
50
50
  },
51
- "gitHead": "823c6e1af3fb5e3f8bb4cc451bc7667fcc8a235e"
51
+ "gitHead": "1fce965a3faefe5ed5bf0f98f04b6daaaa6437b1"
52
52
  }