@opexa/portal-sdk 0.50.7 → 0.51.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.
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var objectId = require('@opexa/object-id');
4
+ var core = require('@capacitor/core');
4
5
  var cookies = require('js-cookie');
5
6
 
6
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -819,6 +820,15 @@ var CREATE_MAYA_DEPOSIT_MUTATION = gql`
819
820
  }
820
821
  }
821
822
  `;
823
+ var CREATE_TEST_DEPOSIT_MUTATION = gql`
824
+ mutation CreateTestDeposit($input: CreateTestDepositInput!) {
825
+ createTestDeposit(input: $input) {
826
+ ... on WalletDoesNotExistError {
827
+ __typename
828
+ }
829
+ }
830
+ }
831
+ `;
822
832
  var CREATE_MAYA_APP_DEPOSIT_MUTATION = gql`
823
833
  mutation CreateMayaAppDeposit($input: CreateMayaAppDepositInput!) {
824
834
  createMayaAppDeposit(input: $input) {
@@ -4377,6 +4387,19 @@ var WalletService = class {
4377
4387
  ok: true
4378
4388
  };
4379
4389
  }
4390
+ async createTestDeposit(variables) {
4391
+ const res = await this.client.request(CREATE_TEST_DEPOSIT_MUTATION, variables);
4392
+ if (!res.ok) return res;
4393
+ if (res.data.createTestDeposit) {
4394
+ return {
4395
+ ok: false,
4396
+ error: createOperationError(res.data.createTestDeposit.__typename)
4397
+ };
4398
+ }
4399
+ return {
4400
+ ok: true
4401
+ };
4402
+ }
4380
4403
  async createAIOQRPHDeposit(variables) {
4381
4404
  const { reCAPTCHAResponse, ...others } = variables;
4382
4405
  const res = await this.client.request(CREATE_AIO_QRPH_DEPOSIT_MUTATION, others, {
@@ -5357,65 +5380,6 @@ var CellexpertManager = class {
5357
5380
  }
5358
5381
  };
5359
5382
 
5360
- // src/sdk/domain-manager.ts
5361
- var DomainManager = class {
5362
- logger;
5363
- platform;
5364
- environment;
5365
- constructor(config) {
5366
- this.logger = config.logger;
5367
- this.platform = config.platform;
5368
- this.environment = config.environment;
5369
- }
5370
- get domain() {
5371
- if (this.isServer) {
5372
- this.logger.warn("Cannot determine domain on the server.");
5373
- return null;
5374
- }
5375
- if (this.isIOSApp) return `ios/${this.platform}`.toLowerCase();
5376
- if (this.isAndroidApp) return `android/${this.platform}`.toLowerCase();
5377
- const url = new URL(window.location.href);
5378
- const rootDomain = url.hostname;
5379
- const mParam = url.searchParams.get("m");
5380
- return mParam ? `${rootDomain}/${mParam}` : rootDomain;
5381
- }
5382
- get metaPixelId() {
5383
- const url = new URL(window.location.href);
5384
- const map = {
5385
- "crazywin.ph": "587374767622209",
5386
- "crazywin.asia": "702641112314597",
5387
- "crazywinph.ph": "704042541995028",
5388
- "happybingo.ph": "617045164450475",
5389
- "happybingo.games": "704042541995028",
5390
- "happybingo.fun": "1209809170790877",
5391
- ...this.environment === "production" && {
5392
- "crazywinph.ph": "587374767622209"
5393
- }
5394
- };
5395
- const metaPixelId = map[url.hostname] ? map[url.hostname] : url.hostname;
5396
- return metaPixelId.toLowerCase();
5397
- }
5398
- get isServer() {
5399
- return typeof window === "undefined";
5400
- }
5401
- get isNative() {
5402
- return !!(window.Capacitor?.isNativePlatform?.() || window.cordova !== void 0);
5403
- }
5404
- get isIOSApp() {
5405
- return ([
5406
- "iPad Simulator",
5407
- "iPhone Simulator",
5408
- "iPod Simulator",
5409
- "iPad",
5410
- "iPhone",
5411
- "iPod"
5412
- ].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in window) && this.isNative;
5413
- }
5414
- get isAndroidApp() {
5415
- return this.isNative && /Android/i.test(navigator.userAgent) && (window.Capacitor?.isNativePlatform?.() || window.cordova !== void 0 || /(wv|Version\/)/i.test(navigator.userAgent));
5416
- }
5417
- };
5418
-
5419
5383
  // src/sdk/logger.ts
5420
5384
  var Logger = class {
5421
5385
  enabled;
@@ -7763,7 +7727,6 @@ var Sdk = class {
7763
7727
  sessionManager;
7764
7728
  adManager;
7765
7729
  cellexpertManager;
7766
- domainManager;
7767
7730
  transformer;
7768
7731
  logger;
7769
7732
  cache;
@@ -7783,11 +7746,6 @@ var Sdk = class {
7783
7746
  });
7784
7747
  const adManager = new AdManager({ logger });
7785
7748
  const cellexpertManager = new CellexpertManager({ logger });
7786
- const domainManager = new DomainManager({
7787
- logger,
7788
- platform,
7789
- environment
7790
- });
7791
7749
  const transformer = new Transformer();
7792
7750
  const authUrl = ENDPOINTS[environment].auth;
7793
7751
  const walletUrl = ENDPOINTS[environment].wallet;
@@ -7867,7 +7825,6 @@ var Sdk = class {
7867
7825
  this.logger = logger;
7868
7826
  this.adManager = adManager;
7869
7827
  this.cellexpertManager = cellexpertManager;
7870
- this.domainManager = domainManager;
7871
7828
  this.transformer = transformer;
7872
7829
  this.authService = authService;
7873
7830
  this.gameService = gameService;
@@ -7955,10 +7912,7 @@ var Sdk = class {
7955
7912
  this.logger.info("Checking for session");
7956
7913
  const res = await this.sessionManager.get();
7957
7914
  if (res.data) {
7958
- request.headers.append(
7959
- "Authorization",
7960
- `Bearer ${res.data.accessToken}`
7961
- );
7915
+ request.headers.set("Authorization", `Bearer ${res.data.accessToken}`);
7962
7916
  this.logger.info("Session found");
7963
7917
  this.logger.success("Added 'Authorization' header");
7964
7918
  } else {
@@ -7974,16 +7928,16 @@ var Sdk = class {
7974
7928
  */
7975
7929
  get domainMiddleware() {
7976
7930
  return async (request) => {
7977
- if (this.sessionManager.onMaya) {
7978
- request.headers.append("Domain", `maya/${this.config.platform}`);
7931
+ if (this.sessionManager.onMaya || this.sessionManager.onCabinet) {
7932
+ request.headers.delete("Domain");
7979
7933
  return request;
7980
7934
  }
7981
- if (this.sessionManager.onCabinet) {
7982
- request.headers.delete("Domain");
7935
+ const domain = typeof window === "undefined" ? null : !core.Capacitor.isNativePlatform() ? null : core.Capacitor.getPlatform() === "ios" ? `ios/${this.config.platform}`.toLowerCase() : core.Capacitor.getPlatform() === "android" ? `android/${this.config.platform}`.toLowerCase() : null;
7936
+ if (domain) {
7937
+ request.headers.set("Domain", domain);
7983
7938
  return request;
7984
7939
  }
7985
- const domain = this.domainManager.domain;
7986
- if (domain) request.headers.append("Domain", domain);
7940
+ request.headers.delete("Domain");
7987
7941
  return request;
7988
7942
  };
7989
7943
  }
@@ -7995,7 +7949,7 @@ var Sdk = class {
7995
7949
  get miscMiddleware() {
7996
7950
  return async (request) => {
7997
7951
  const adClickId = this.adManager.clickId;
7998
- if (adClickId) request.headers.append("Ad-Click-Id", adClickId);
7952
+ if (adClickId) request.headers.set("Ad-Click-Id", adClickId);
7999
7953
  return request;
8000
7954
  };
8001
7955
  }
@@ -8678,6 +8632,16 @@ var Sdk = class {
8678
8632
  async createDeposit(input) {
8679
8633
  const id = input.id ?? objectId.ObjectId.generate(ObjectType.Deposit).toString();
8680
8634
  const environment = this.config.environment ?? "development";
8635
+ if (input.type === "TEST") {
8636
+ const res = await this.walletService.createTestDeposit({
8637
+ input: {
8638
+ id,
8639
+ amount: input.amount.toString(),
8640
+ promo: input.promo
8641
+ }
8642
+ });
8643
+ if (!res.ok) return res;
8644
+ }
8681
8645
  if (input.type === "MAYA") {
8682
8646
  const res = await this.walletService.createMayaDeposit({
8683
8647
  input: {