@opexa/portal-sdk 0.59.60 → 0.59.62

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.d.cts CHANGED
@@ -84,13 +84,13 @@ declare class Sdk {
84
84
  fingerprint(): Promise<string | null>;
85
85
  private get miscMiddleware();
86
86
  collectMetaDetails(): void;
87
- signIn(input: NameAndPasswordSignInInput): Promise<NameAndPasswordSignInReturn>;
88
- signIn(input: MobileNumberSignInInput): Promise<MobileNumberSignInReturn>;
89
- signIn(input: MayaSignInInput): Promise<MayaSignInReturn>;
90
- signIn(input: TokenSignInInput): Promise<TokenSignInReturn>;
91
- signIn(input: SocialsSignInInput): Promise<SocialsSignInReturn>;
92
- signIn(input: CabinetSignInInput): Promise<CabinetSignInReturn>;
93
- signIn(input: SingleUseTokenSignInInput): Promise<SingleUseTokenSignInReturn>;
87
+ signIn(input: NameAndPasswordSignInInput, version?: 1 | 3): Promise<NameAndPasswordSignInReturn>;
88
+ signIn(input: MobileNumberSignInInput, version?: 1 | 3): Promise<MobileNumberSignInReturn>;
89
+ signIn(input: MayaSignInInput, version?: 1 | 3): Promise<MayaSignInReturn>;
90
+ signIn(input: TokenSignInInput, version?: 1 | 3): Promise<TokenSignInReturn>;
91
+ signIn(input: SocialsSignInInput, version?: 1 | 3): Promise<SocialsSignInReturn>;
92
+ signIn(input: CabinetSignInInput, version?: 1 | 3): Promise<CabinetSignInReturn>;
93
+ signIn(input: SingleUseTokenSignInInput, version?: 1 | 3): Promise<SingleUseTokenSignInReturn>;
94
94
  authenticate(input: AuthenticateInput): Promise<AuthenticateReturn>;
95
95
  signOut(): Promise<void>;
96
96
  watchSession(input: WatchSessionInput): () => void;
package/dist/index.d.ts CHANGED
@@ -84,13 +84,13 @@ declare class Sdk {
84
84
  fingerprint(): Promise<string | null>;
85
85
  private get miscMiddleware();
86
86
  collectMetaDetails(): void;
87
- signIn(input: NameAndPasswordSignInInput): Promise<NameAndPasswordSignInReturn>;
88
- signIn(input: MobileNumberSignInInput): Promise<MobileNumberSignInReturn>;
89
- signIn(input: MayaSignInInput): Promise<MayaSignInReturn>;
90
- signIn(input: TokenSignInInput): Promise<TokenSignInReturn>;
91
- signIn(input: SocialsSignInInput): Promise<SocialsSignInReturn>;
92
- signIn(input: CabinetSignInInput): Promise<CabinetSignInReturn>;
93
- signIn(input: SingleUseTokenSignInInput): Promise<SingleUseTokenSignInReturn>;
87
+ signIn(input: NameAndPasswordSignInInput, version?: 1 | 3): Promise<NameAndPasswordSignInReturn>;
88
+ signIn(input: MobileNumberSignInInput, version?: 1 | 3): Promise<MobileNumberSignInReturn>;
89
+ signIn(input: MayaSignInInput, version?: 1 | 3): Promise<MayaSignInReturn>;
90
+ signIn(input: TokenSignInInput, version?: 1 | 3): Promise<TokenSignInReturn>;
91
+ signIn(input: SocialsSignInInput, version?: 1 | 3): Promise<SocialsSignInReturn>;
92
+ signIn(input: CabinetSignInInput, version?: 1 | 3): Promise<CabinetSignInReturn>;
93
+ signIn(input: SingleUseTokenSignInInput, version?: 1 | 3): Promise<SingleUseTokenSignInReturn>;
94
94
  authenticate(input: AuthenticateInput): Promise<AuthenticateReturn>;
95
95
  signOut(): Promise<void>;
96
96
  watchSession(input: WatchSessionInput): () => void;
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
- import { CmsPortalService, GameService, ExtensionService, FileService, WalletService, AccountService, ReportService, PortalService, TriggerService, AuthService } from './chunk-AKP5LBV2.js';
1
+ import { CmsPortalService, GameService, ExtensionService, FileService, WalletService, AccountService, ReportService, PortalService, TriggerService, AuthService, getFingerPrint } from './chunk-FUFD2LUS.js';
2
2
  import { GraphQLClient, isPlainObject } from './chunk-JTAO2DVT.js';
3
3
  import './chunk-WVFSGB7Y.js';
4
4
  import { ObjectId } from '@opexa/object-id';
5
5
  export { ObjectId } from '@opexa/object-id';
6
6
  import { Capacitor } from '@capacitor/core';
7
- import { Thumbmark } from '@thumbmarkjs/thumbmarkjs';
8
7
  import cookies from 'js-cookie';
9
8
 
10
9
  // src/sdk/object-type.ts
@@ -189,6 +188,8 @@ function addHours(date, hours) {
189
188
  result.setHours(result.getHours() + hours);
190
189
  return result;
191
190
  }
191
+
192
+ // src/sdk/utils.ts
192
193
  function getLocaleByCurrency(currency) {
193
194
  if (currency === "INR") return "en-IN";
194
195
  if (currency === "MYR") return "en-MY";
@@ -218,26 +219,6 @@ function parseFbCxd(input) {
218
219
  const fbAdditionalCxd = input.split(cxd)[1].slice(1);
219
220
  return { cxd, fbAdditionalCxd };
220
221
  }
221
- var thumbmark_instance;
222
- async function getFingerprint() {
223
- if (typeof window === "undefined") return null;
224
- if (!thumbmark_instance) {
225
- thumbmark_instance = new Thumbmark({
226
- logging: false,
227
- timeout: 3e4,
228
- cache_lifetime_in_ms: 1 * 60 * 60 * 1e3
229
- });
230
- }
231
- try {
232
- const cached = sessionStorage.getItem("fingerprint");
233
- if (cached) return cached;
234
- const result = await thumbmark_instance.get();
235
- sessionStorage.setItem("fingerprint", result.thumbmark);
236
- return result.thumbmark;
237
- } catch {
238
- return null;
239
- }
240
- }
241
222
  function getCookie(name) {
242
223
  if (typeof document === "undefined") return null;
243
224
  const nameLenPlus = name.length + 1;
@@ -377,7 +358,7 @@ var SessionManager = class {
377
358
  set refreshing(value) {
378
359
  this._refreshing = value;
379
360
  }
380
- async create(input) {
361
+ async create(input, version = 1) {
381
362
  if (this.isServer) {
382
363
  this.logger.warn("'localStorage' is not available on the server.");
383
364
  return {
@@ -406,7 +387,7 @@ var SessionManager = class {
406
387
  }
407
388
  };
408
389
  }
409
- const f1 = () => this.authService.createSession(input);
390
+ const f1 = () => this.authService.createSession(input, version);
410
391
  const r1 = await pollable(f1, {
411
392
  until: (r) => r.ok,
412
393
  interval: 1e3,
@@ -428,7 +409,7 @@ var SessionManager = class {
428
409
  };
429
410
  }
430
411
  if (input.type === "MOBILE_NUMBER") {
431
- const res2 = await this.authService.createSession(input);
412
+ const res2 = await this.authService.createSession(input, version);
432
413
  if (res2.ok) {
433
414
  const now2 = /* @__PURE__ */ new Date();
434
415
  localStorage.setItem(
@@ -447,11 +428,14 @@ var SessionManager = class {
447
428
  return res2;
448
429
  }
449
430
  if (input.type === "SOCIALS" || input.type === "TOKEN") {
450
- const res2 = await this.authService.createSession({
451
- type: "SOCIALS",
452
- token: input.token,
453
- channel: input.channel
454
- });
431
+ const res2 = await this.authService.createSession(
432
+ {
433
+ type: "SOCIALS",
434
+ token: input.token,
435
+ channel: input.channel
436
+ },
437
+ version
438
+ );
455
439
  if (res2.ok) {
456
440
  const now2 = /* @__PURE__ */ new Date();
457
441
  localStorage.setItem(
@@ -471,7 +455,7 @@ var SessionManager = class {
471
455
  }
472
456
  if (input.type === "CABINET") {
473
457
  localStorage.setItem(this.platformStorageKey, "CABINET");
474
- const res2 = await this.authService.createSession(input);
458
+ const res2 = await this.authService.createSession(input, version);
475
459
  if (res2.ok) {
476
460
  const now2 = /* @__PURE__ */ new Date();
477
461
  localStorage.setItem(
@@ -489,7 +473,7 @@ var SessionManager = class {
489
473
  }
490
474
  return res2;
491
475
  }
492
- const res = await this.authService.createSession(input);
476
+ const res = await this.authService.createSession(input, version);
493
477
  if (!res.ok) return res;
494
478
  if (res.data.authenticator) {
495
479
  return {
@@ -738,7 +722,7 @@ var SessionManagerCookie = class {
738
722
  set refreshing(value) {
739
723
  this._refreshing = value;
740
724
  }
741
- async create(input) {
725
+ async create(input, version = 1) {
742
726
  if (input.type === "MAYA") {
743
727
  localStorage.setItem(this.platformStorageKey, "MAYA");
744
728
  const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
@@ -757,7 +741,7 @@ var SessionManagerCookie = class {
757
741
  }
758
742
  };
759
743
  }
760
- const f1 = () => this.authService.createSession(input);
744
+ const f1 = () => this.authService.createSession(input, version);
761
745
  const r1 = await pollable(f1, {
762
746
  until: (r) => r.ok,
763
747
  interval: 1e3,
@@ -780,7 +764,7 @@ var SessionManagerCookie = class {
780
764
  };
781
765
  }
782
766
  if (input.type === "MOBILE_NUMBER") {
783
- const res2 = await this.authService.createSession(input);
767
+ const res2 = await this.authService.createSession(input, version);
784
768
  if (res2.ok) {
785
769
  const now2 = /* @__PURE__ */ new Date();
786
770
  cookies.set(
@@ -802,10 +786,13 @@ var SessionManagerCookie = class {
802
786
  return res2;
803
787
  }
804
788
  if (input.type === "SOCIALS" || input.type === "TOKEN") {
805
- const res2 = await this.authService.createSession({
806
- type: "SOCIALS",
807
- token: input.token
808
- });
789
+ const res2 = await this.authService.createSession(
790
+ {
791
+ type: "SOCIALS",
792
+ token: input.token
793
+ },
794
+ version
795
+ );
809
796
  if (res2.ok) {
810
797
  const now2 = /* @__PURE__ */ new Date();
811
798
  cookies.set(
@@ -826,7 +813,7 @@ var SessionManagerCookie = class {
826
813
  }
827
814
  if (input.type === "CABINET") {
828
815
  localStorage.setItem(this.platformStorageKey, "CABINET");
829
- const res2 = await this.authService.createSession(input);
816
+ const res2 = await this.authService.createSession(input, version);
830
817
  if (res2.ok) {
831
818
  const now2 = /* @__PURE__ */ new Date();
832
819
  cookies.set(
@@ -845,7 +832,7 @@ var SessionManagerCookie = class {
845
832
  }
846
833
  return res2;
847
834
  }
848
- const res = await this.authService.createSession(input);
835
+ const res = await this.authService.createSession(input, version);
849
836
  if (!res.ok) return res;
850
837
  if (res.data.authenticator) {
851
838
  return {
@@ -3208,7 +3195,7 @@ var Sdk = class {
3208
3195
  };
3209
3196
  }
3210
3197
  async fingerprint() {
3211
- return await getFingerprint();
3198
+ return await getFingerPrint();
3212
3199
  }
3213
3200
  get miscMiddleware() {
3214
3201
  return async (request) => {
@@ -3234,7 +3221,7 @@ var Sdk = class {
3234
3221
  this.fbp = fbp;
3235
3222
  }
3236
3223
  }
3237
- async signIn(input) {
3224
+ async signIn(input, version = 1) {
3238
3225
  if (input.type === "TOKEN") {
3239
3226
  console.warn(
3240
3227
  "'TOKEN (signIn)' is deprecated. Please use 'SOCIALS' instead."
@@ -3242,10 +3229,13 @@ var Sdk = class {
3242
3229
  }
3243
3230
  switch (input.type) {
3244
3231
  case "NAME_AND_PASSWORD": {
3245
- const res = await this.sessionManager.create({
3246
- ...input,
3247
- password: await sha256(input.password)
3248
- });
3232
+ const res = await this.sessionManager.create(
3233
+ {
3234
+ ...input,
3235
+ password: await sha256(input.password)
3236
+ },
3237
+ version
3238
+ );
3249
3239
  if (!res.ok) return res;
3250
3240
  if (res.data) {
3251
3241
  return {
@@ -3265,42 +3255,54 @@ var Sdk = class {
3265
3255
  }
3266
3256
  case "SOCIALS":
3267
3257
  case "TOKEN": {
3268
- const res = await this.sessionManager.create({
3269
- type: "SOCIALS",
3270
- token: input.token,
3271
- channel: input.channel
3272
- });
3258
+ const res = await this.sessionManager.create(
3259
+ {
3260
+ type: "SOCIALS",
3261
+ token: input.token,
3262
+ channel: input.channel
3263
+ },
3264
+ version
3265
+ );
3273
3266
  return res.ok ? { ok: true } : res;
3274
3267
  }
3275
3268
  case "CABINET": {
3276
- const res = await this.sessionManager.create({
3277
- type: "CABINET",
3278
- token: input.token,
3279
- channel: input.channel
3280
- });
3269
+ const res = await this.sessionManager.create(
3270
+ {
3271
+ type: "CABINET",
3272
+ token: input.token,
3273
+ channel: input.channel
3274
+ },
3275
+ version
3276
+ );
3281
3277
  return res.ok ? { ok: true } : res;
3282
3278
  }
3283
3279
  case "MOBILE_NUMBER": {
3284
- const res = await this.sessionManager.create({
3285
- type: "MOBILE_NUMBER",
3286
- mobileNumber: addAreaCode(input.mobileNumber, await this.locale),
3287
- verificationCode: input.verificationCode,
3288
- reCAPTCHAResponse: input.reCAPTCHAResponse,
3289
- testPass: input.testPass,
3290
- channel: input.channel
3291
- });
3280
+ const res = await this.sessionManager.create(
3281
+ {
3282
+ type: "MOBILE_NUMBER",
3283
+ mobileNumber: addAreaCode(input.mobileNumber, await this.locale),
3284
+ verificationCode: input.verificationCode,
3285
+ reCAPTCHAResponse: input.reCAPTCHAResponse,
3286
+ testPass: input.testPass,
3287
+ channel: input.channel
3288
+ },
3289
+ version
3290
+ );
3292
3291
  return res.ok ? { ok: true } : res;
3293
3292
  }
3294
3293
  case "SINGLE_USE_TOKEN": {
3295
- const res = await this.sessionManager.create({
3296
- type: "SINGLE_USE_TOKEN",
3297
- token: input.token,
3298
- channel: input.channel
3299
- });
3294
+ const res = await this.sessionManager.create(
3295
+ {
3296
+ type: "SINGLE_USE_TOKEN",
3297
+ token: input.token,
3298
+ channel: input.channel
3299
+ },
3300
+ version
3301
+ );
3300
3302
  return res.ok ? { ok: true } : res;
3301
3303
  }
3302
3304
  default: {
3303
- const res = await this.sessionManager.create(input);
3305
+ const res = await this.sessionManager.create(input, version);
3304
3306
  return res.ok ? { ok: true } : res;
3305
3307
  }
3306
3308
  }