@opexa/portal-sdk 0.57.21 → 0.58.1

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/dist/index.cjs CHANGED
@@ -1642,6 +1642,9 @@ var MEMBER_ACCOUNT_QUERY_DEVELOPMENT = gql`
1642
1642
  agent {
1643
1643
  code
1644
1644
  }
1645
+ gigRewardsQuestDetails {
1646
+ gigUserId
1647
+ }
1645
1648
  }
1646
1649
  }
1647
1650
  }
@@ -1678,7 +1681,6 @@ var MEMBER_ACCOUNT_QUERY = gql`
1678
1681
  dateTimeLastUpdated
1679
1682
  domain
1680
1683
  branchCode
1681
-
1682
1684
  }
1683
1685
  }
1684
1686
  }
@@ -6142,6 +6144,7 @@ function subMinutes(date, minutes) {
6142
6144
 
6143
6145
  // src/sdk/ad-manager.ts
6144
6146
  var AD_CLICK_ID_STORAGE_KEY = "sdk/ad-click-id";
6147
+ var FBP_STORAGE_KEY = "sdk/fbp";
6145
6148
  var AdManager = class {
6146
6149
  logger;
6147
6150
  constructor(config) {
@@ -6186,6 +6189,45 @@ var AdManager = class {
6186
6189
  return null;
6187
6190
  }
6188
6191
  }
6192
+ set fbp(value) {
6193
+ if (this.isServer) {
6194
+ this.logger.warn("'localStorage' is not available on the server.");
6195
+ return;
6196
+ }
6197
+ if (value === null) {
6198
+ localStorage.removeItem(FBP_STORAGE_KEY);
6199
+ return;
6200
+ }
6201
+ const n = /* @__PURE__ */ new Date();
6202
+ const o = JSON.stringify({
6203
+ value,
6204
+ expiresAt: subMinutes(addDays(n, 90), 2).getTime()
6205
+ });
6206
+ localStorage.setItem(FBP_STORAGE_KEY, o);
6207
+ }
6208
+ get fbp() {
6209
+ if (this.isServer) {
6210
+ this.logger.warn("'localStorage' is not available on the server.");
6211
+ return null;
6212
+ }
6213
+ const v = localStorage.getItem(FBP_STORAGE_KEY);
6214
+ if (!v) return null;
6215
+ try {
6216
+ const o = JSON.parse(v);
6217
+ if (!o.value) return null;
6218
+ if (!o.expiresAt) return null;
6219
+ const d = new Date(o.expiresAt);
6220
+ const n = /* @__PURE__ */ new Date();
6221
+ if (isAfter(n, d)) {
6222
+ localStorage.removeItem(FBP_STORAGE_KEY);
6223
+ return null;
6224
+ }
6225
+ return o.value;
6226
+ } catch {
6227
+ localStorage.removeItem(FBP_STORAGE_KEY);
6228
+ return null;
6229
+ }
6230
+ }
6189
6231
  get isServer() {
6190
6232
  return typeof window === "undefined";
6191
6233
  }
@@ -6248,6 +6290,15 @@ async function getFingerprint() {
6248
6290
  return null;
6249
6291
  }
6250
6292
  }
6293
+ function getCookie(name) {
6294
+ if (typeof document === "undefined") return null;
6295
+ const nameLenPlus = name.length + 1;
6296
+ return document.cookie.split(";").map((c) => c.trim()).filter((cookie) => {
6297
+ return cookie.substring(0, nameLenPlus) === `${name}=`;
6298
+ }).map((cookie) => {
6299
+ return decodeURIComponent(cookie.substring(nameLenPlus));
6300
+ })[0] || null;
6301
+ }
6251
6302
 
6252
6303
  // src/sdk/cellexpert-manager.ts
6253
6304
  var CXD_STORAGE_KEY = "sdk/cxd";
@@ -8011,7 +8062,8 @@ var Transformer = class {
8011
8062
  agent: data.agent ?? null,
8012
8063
  level: data.level ?? 0,
8013
8064
  dateTimeLastActive: data.dateTimeLastActive ? new Date(data.dateTimeLastActive) : void 0,
8014
- partition: data.partition
8065
+ partition: data.partition,
8066
+ gigRewardsQuestDetails: data.gigRewardsQuestDetails ?? void 0
8015
8067
  };
8016
8068
  return compact(o);
8017
8069
  }
@@ -8872,6 +8924,7 @@ var Sdk = class {
8872
8924
  sitePlatform,
8873
8925
  logs
8874
8926
  };
8927
+ this.collectMetaDetails();
8875
8928
  }
8876
8929
  _fetch = null;
8877
8930
  _middleware;
@@ -8953,6 +9006,12 @@ var Sdk = class {
8953
9006
  get adClickId() {
8954
9007
  return this.adManager.clickId;
8955
9008
  }
9009
+ set fbp(value) {
9010
+ this.adManager.fbp = value;
9011
+ }
9012
+ get fbp() {
9013
+ return this.adManager.fbp;
9014
+ }
8956
9015
  /*
8957
9016
  *=============================================
8958
9017
  * CXD
@@ -9021,18 +9080,30 @@ var Sdk = class {
9021
9080
  async fingerprint() {
9022
9081
  return await getFingerprint();
9023
9082
  }
9024
- /*
9025
- *=============================================
9026
- * MISCELLANEOUS MIDDLEWARE
9027
- *=============================================
9028
- */
9029
9083
  get miscMiddleware() {
9030
9084
  return async (request) => {
9031
9085
  const adClickId = this.adManager.clickId;
9032
9086
  if (adClickId) request.headers.set("Ad-Click-Id", adClickId);
9087
+ const fbp = this.adManager.fbp;
9088
+ if (fbp) request.headers.set("fbp", fbp);
9033
9089
  return request;
9034
9090
  };
9035
9091
  }
9092
+ collectMetaDetails() {
9093
+ if (typeof window === "undefined") return;
9094
+ const searchParams = new URLSearchParams(window.location.search);
9095
+ const fbclid = searchParams.get("fbclid");
9096
+ const fbc = getCookie("_fbc");
9097
+ const fbp = getCookie("_fbp");
9098
+ if (fbclid) {
9099
+ this.adClickId = fbclid;
9100
+ } else if (fbc) {
9101
+ this.adClickId = fbc.includes(".") ? fbc.split(".").pop() || fbc : fbc;
9102
+ }
9103
+ if (fbp) {
9104
+ this.fbp = fbp;
9105
+ }
9106
+ }
9036
9107
  async signIn(input) {
9037
9108
  if (input.type === "TOKEN") {
9038
9109
  console.warn(
@@ -9329,7 +9400,8 @@ var Sdk = class {
9329
9400
  domain: input.domain,
9330
9401
  birthDay: typeof input.dateOfBirth === "string" ? input.dateOfBirth : this.formatYmd(input.dateOfBirth),
9331
9402
  password: await sha256(input.password),
9332
- mobileNumber: addAreaCode(input.mobileNumber, await this.locale)
9403
+ mobileNumber: addAreaCode(input.mobileNumber, await this.locale),
9404
+ gigRewardsQuestDetails: input.gigRewardsQuestDetails
9333
9405
  },
9334
9406
  referralCode: input.referralCode,
9335
9407
  verificationCode: input.verificationCode,
@@ -9355,7 +9427,8 @@ var Sdk = class {
9355
9427
  agentCode: input.agentCode,
9356
9428
  ...this.cxd && {
9357
9429
  cellxpertCxd: this.cxd
9358
- }
9430
+ },
9431
+ gigRewardsQuestDetails: input.gigRewardsQuestDetails
9359
9432
  },
9360
9433
  referralCode: input.referralCode,
9361
9434
  verificationCode: input.verificationCode,
@@ -9374,7 +9447,8 @@ var Sdk = class {
9374
9447
  id,
9375
9448
  password: await sha256(input.password),
9376
9449
  realName: input.realName,
9377
- mobileNumber: addAreaCode(input.mobileNumber, await this.locale)
9450
+ mobileNumber: addAreaCode(input.mobileNumber, await this.locale),
9451
+ gigRewardsQuestDetails: input.gigRewardsQuestDetails
9378
9452
  },
9379
9453
  mobileNumberVerificationCode: input.mobileVerificationCode,
9380
9454
  testPass: input.testPass,
@@ -9394,7 +9468,8 @@ var Sdk = class {
9394
9468
  btag: input.btag,
9395
9469
  domain: input.domain,
9396
9470
  password: await sha256(input.password),
9397
- mobileNumber: input.mobileNumber ? addAreaCode(input.mobileNumber, await this.locale) : void 0
9471
+ mobileNumber: input.mobileNumber ? addAreaCode(input.mobileNumber, await this.locale) : void 0,
9472
+ gigRewardsQuestDetails: input.gigRewardsQuestDetails
9398
9473
  },
9399
9474
  reCAPTCHAResponse: input.reCAPTCHAResponse,
9400
9475
  ...this.marketDomain && {
@@ -9411,7 +9486,8 @@ var Sdk = class {
9411
9486
  mobileNumberVerificationCode: input.mobileNumberVerificationCode,
9412
9487
  emailAddress: input.emailAddress,
9413
9488
  branchCode: input.branchCode,
9414
- agentCode: input.agentCode
9489
+ agentCode: input.agentCode,
9490
+ gigRewardsQuestDetails: input.gigRewardsQuestDetails
9415
9491
  },
9416
9492
  testPass: input.testPass,
9417
9493
  reCAPTCHAResponse: input.reCAPTCHAResponse,
@@ -9428,7 +9504,8 @@ var Sdk = class {
9428
9504
  input: {
9429
9505
  id,
9430
9506
  name: input.name,
9431
- password: await sha256(input.password)
9507
+ password: await sha256(input.password),
9508
+ gigRewardsQuestDetails: input.gigRewardsQuestDetails
9432
9509
  },
9433
9510
  reCAPTCHAResponse: input.reCAPTCHAResponse,
9434
9511
  ...this.marketDomain && {
@@ -9473,6 +9550,7 @@ var Sdk = class {
9473
9550
  mobileNumber,
9474
9551
  secretAnswer,
9475
9552
  transactionPassword,
9553
+ gigRewardsQuestDetails,
9476
9554
  ...others
9477
9555
  } = input;
9478
9556
  return await this.accountService.updateMemberAccount({
@@ -9484,7 +9562,8 @@ var Sdk = class {
9484
9562
  transactionPassword: transactionPassword ? await sha256(transactionPassword) : void 0,
9485
9563
  mobileNumber: mobileNumber ? addAreaCode(mobileNumber, await this.locale) : void 0,
9486
9564
  secretAnswer: secretAnswer ? await sha256(secretAnswer) : void 0,
9487
- birthDay: dateOfBirth ? typeof dateOfBirth === "string" ? dateOfBirth : this.formatYmd(dateOfBirth) : void 0
9565
+ birthDay: dateOfBirth ? typeof dateOfBirth === "string" ? dateOfBirth : this.formatYmd(dateOfBirth) : void 0,
9566
+ gigRewardsQuestDetails
9488
9567
  }
9489
9568
  }
9490
9569
  });