@smartico/public-api 0.0.394 → 0.0.396

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.394",
3
+ "version": "0.0.396",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { SAWTemplate } from "src/MiniGames";
1
+ import { SAWTemplate } from "../MiniGames";
2
2
  import { QuizAnswersValueType } from "./MarketsAnswers";
3
3
  import { SAWGPMarketType } from "./MarketsType";
4
4
 
@@ -1,4 +1,4 @@
1
- import { IntUtils } from "src/IntUtils";
1
+ import { IntUtils } from "../IntUtils";
2
2
  import { AchievementAvailabilityStatus } from "./AchievementAvailabilityStatus";
3
3
  import { AchievementStatus } from "./AchievementStatus";
4
4
  import { UserAchievement } from "./UserAchievement";
@@ -157,6 +157,32 @@ const GAMES_API_URL = 'https://r-games-api.smr.vc';
157
157
  const AVATAR_DOMAIN = 'https://img{ENV_ID}.smr.vc';
158
158
  const DEFAULT_LANG_EN = 'EN';
159
159
 
160
+ const SMR_TO_CLOUDFRONT_DOMAINS: { [key: string]: string } = {
161
+ 'img.smr.vc': 'd1am61onjxtys8.cloudfront.net',
162
+ 'img3.smr.vc': 'd3dubbodzd2q05.cloudfront.net',
163
+ 'img4.smr.vc': 'dvm0p9vsezqr2.cloudfront.net',
164
+ 'img5.smr.vc': 'd3gen1ksvxhac8.cloudfront.net',
165
+ 'img6.smr.vc': 'db1kmyg7iufeo.cloudfront.net',
166
+ 'img7.smr.vc': 'd36om2g86xefo6.cloudfront.net',
167
+ 'img8.smr.vc': 'd2zme31v54n5pb.cloudfront.net',
168
+
169
+ 'static.smr.vc': 'dtt380pweilws.cloudfront.net',
170
+ 'static3.smr.vc': 'd1qt8ake8g4imn.cloudfront.net',
171
+ 'static4.smr.vc': 'd146b4m7rkvjkw.cloudfront.net',
172
+ 'static5.smr.vc': 'd3l7suk1kl9rwh.cloudfront.net',
173
+ 'static6.smr.vc': 'd121pfj16xdfcq.cloudfront.net',
174
+ 'static7.smr.vc': 'd21deilz814qgl.cloudfront.net',
175
+ 'static8.smr.vc': 'd1uffsroxjy2ku.cloudfront.net',
176
+ };
177
+
178
+ // Single combined matcher built once, so a call is one pass instead of one per domain.
179
+ const SMR_DOMAIN_REGEX = new RegExp(
180
+ Object.keys(SMR_TO_CLOUDFRONT_DOMAINS)
181
+ .map((d) => d.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
182
+ .join('|'),
183
+ 'g',
184
+ );
185
+
160
186
  interface Tracker {
161
187
  label_api_key: string;
162
188
  userPublicProps: any;
@@ -241,34 +267,23 @@ class SmarticoAPI {
241
267
  return value as T;
242
268
  }
243
269
 
244
- const domains = {
245
- 'img.smr.vc': 'd1am61onjxtys8.cloudfront.net',
246
- 'img3.smr.vc': 'd3dubbodzd2q05.cloudfront.net',
247
- 'img4.smr.vc': 'dvm0p9vsezqr2.cloudfront.net',
248
- 'img5.smr.vc': 'd3gen1ksvxhac8.cloudfront.net',
249
- 'img6.smr.vc': 'db1kmyg7iufeo.cloudfront.net',
250
- 'img7.smr.vc': 'd36om2g86xefo6.cloudfront.net',
251
- 'img8.smr.vc': 'd2zme31v54n5pb.cloudfront.net',
252
-
253
- 'static.smr.vc': 'dtt380pweilws.cloudfront.net',
254
- 'static3.smr.vc': 'd1qt8ake8g4imn.cloudfront.net',
255
- 'static4.smr.vc': 'd146b4m7rkvjkw.cloudfront.net',
256
- 'static5.smr.vc': 'd3l7suk1kl9rwh.cloudfront.net',
257
- 'static6.smr.vc': 'd121pfj16xdfcq.cloudfront.net',
258
- 'static7.smr.vc': 'd21deilz814qgl.cloudfront.net',
259
- 'static8.smr.vc': 'd1uffsroxjy2ku.cloudfront.net',
260
- }
270
+ const isString = typeof value === 'string';
271
+ const source = isString ? (value as string) : JSON.stringify(value);
272
+ if (!source.includes('smr.vc')) return value as T; // ← skip even the regex
261
273
 
262
- const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
274
+ const replaced = source.replace(SMR_DOMAIN_REGEX, (match) => SMR_TO_CLOUDFRONT_DOMAINS[match]);
263
275
 
264
- let replacedValue = typeof value === 'string' ? value : JSON.stringify(value);
276
+ // No domain matched: skip the JSON re-parse and return the input untouched.
277
+ if (replaced === source) {
278
+ return value as T;
279
+ }
265
280
 
266
- for (const [oldDomain, newDomain] of Object.entries(domains)) {
267
- replacedValue = replacedValue.replace(new RegExp(escapeRegExp(oldDomain), 'g'), newDomain);
281
+ if (isString) {
282
+ return replaced as T;
268
283
  }
269
284
 
270
285
  try {
271
- return typeof value === 'string' ? replacedValue as T : JSON.parse(replacedValue)
286
+ return JSON.parse(replaced);
272
287
  } catch (err) {
273
288
  return value as T;
274
289
  }
@@ -1,6 +1,6 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
- import { BadgesTimeLimitStates } from "src/Missions";
3
+ import { BadgesTimeLimitStates } from "../Missions";
4
4
 
5
5
  declare enum CJMActivityType {
6
6
  Root = 0,
@@ -1,4 +1,4 @@
1
- import { GamePickGameInfo, GamePickRequestParams, GamePickRound, GamePickRoundBoard, GamePickRoundRequestParams, GamePickUserInfo, GamesApiResponse } from 'src/GamePick';
1
+ import { GamePickGameInfo, GamePickRequestParams, GamePickRound, GamePickRoundBoard, GamePickRoundRequestParams, GamePickUserInfo, GamesApiResponse } from '../GamePick';
2
2
  import { WSAPIAvatars } from './WSAPIAvatars';
3
3
 
4
4
  /** @group GamePick */