@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.
@@ -1,4 +1,5 @@
1
1
  import { gql, statusCodeToOperationError, callIfFn } from './chunk-WVFSGB7Y.js';
2
+ import { Thumbmark } from '@thumbmarkjs/thumbmarkjs';
2
3
 
3
4
  // src/services/queries.ts
4
5
  var FILE_FRAGMENT = gql`
@@ -4325,6 +4326,26 @@ var AccountService = class {
4325
4326
  };
4326
4327
  }
4327
4328
  };
4329
+ var thumbmark_instance;
4330
+ async function getFingerPrint() {
4331
+ if (typeof window === "undefined") return null;
4332
+ if (!thumbmark_instance) {
4333
+ thumbmark_instance = new Thumbmark({
4334
+ logging: false,
4335
+ timeout: 3e4,
4336
+ cache_lifetime_in_ms: 1 * 60 * 60 * 1e3
4337
+ });
4338
+ }
4339
+ try {
4340
+ const cached = sessionStorage.getItem("fingerprint");
4341
+ if (cached) return cached;
4342
+ const result = await thumbmark_instance.get();
4343
+ sessionStorage.setItem("fingerprint", result.thumbmark);
4344
+ return result.thumbmark;
4345
+ } catch {
4346
+ return null;
4347
+ }
4348
+ }
4328
4349
 
4329
4350
  // src/services/auth.service.ts
4330
4351
  var AuthService = class {
@@ -4340,8 +4361,14 @@ var AuthService = class {
4340
4361
  headers.append("Content-Type", "application/json");
4341
4362
  return headers;
4342
4363
  }
4343
- async createSession(input) {
4364
+ async createSession(input, version = 1) {
4344
4365
  const headers = new Headers(this.headers);
4366
+ if (version === 3) {
4367
+ const fingerprint = await getFingerPrint();
4368
+ if (fingerprint) {
4369
+ headers.append("Fingerprint", fingerprint);
4370
+ }
4371
+ }
4345
4372
  if (input.channel) {
4346
4373
  headers.append("Channel", input.channel);
4347
4374
  }
@@ -4374,9 +4401,10 @@ var AuthService = class {
4374
4401
  headers.set("test-pass", input.testPass);
4375
4402
  }
4376
4403
  try {
4377
- const res = await fetch(`${this.url}/sessions`, {
4404
+ const res = await fetch(`${this.url}${version === 3 ? "/v3/sessions" : "/sessions"}`, {
4378
4405
  method: "POST",
4379
- headers
4406
+ headers,
4407
+ body: JSON.stringify(input)
4380
4408
  });
4381
4409
  const data = await res.json();
4382
4410
  if (res.ok) {
@@ -4528,7 +4556,7 @@ var AuthService = class {
4528
4556
  return true;
4529
4557
  }
4530
4558
  }
4531
- async sendVerificationCode(input) {
4559
+ async sendVerificationCode(input, recaptchaResponse) {
4532
4560
  if (input.channel === "EMAIL")
4533
4561
  throw new Error("Email channel is not yet supported");
4534
4562
  function getErrorCode(message) {
@@ -4546,8 +4574,15 @@ var AuthService = class {
4546
4574
  try {
4547
4575
  const res = await fetch(`${this.url}/otps`, {
4548
4576
  method: "POST",
4549
- headers: this.headers,
4550
- body: JSON.stringify(input)
4577
+ headers: {
4578
+ ...this.headers,
4579
+ ...recaptchaResponse && {
4580
+ "google-recaptcha-response": recaptchaResponse
4581
+ }
4582
+ },
4583
+ body: JSON.stringify({
4584
+ ...input
4585
+ })
4551
4586
  });
4552
4587
  if (res.status === 403) {
4553
4588
  const data = await res.json();
@@ -6287,6 +6322,6 @@ var ExtensionService = class {
6287
6322
  }
6288
6323
  };
6289
6324
 
6290
- export { AccountService, AuthService, CmsPortalService, ExtensionService, FileService, GameService, PortalService, ReportService, TriggerService, WalletService };
6291
- //# sourceMappingURL=chunk-AKP5LBV2.js.map
6292
- //# sourceMappingURL=chunk-AKP5LBV2.js.map
6325
+ export { AccountService, AuthService, CmsPortalService, ExtensionService, FileService, GameService, PortalService, ReportService, TriggerService, WalletService, getFingerPrint };
6326
+ //# sourceMappingURL=chunk-FUFD2LUS.js.map
6327
+ //# sourceMappingURL=chunk-FUFD2LUS.js.map