@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,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var thumbmarkjs = require('@thumbmarkjs/thumbmarkjs');
4
+
3
5
  // src/utils/gql.ts
4
6
  function gql(strings, ...values) {
5
7
  let result = "";
@@ -4335,6 +4337,26 @@ var AccountService = class {
4335
4337
  };
4336
4338
  }
4337
4339
  };
4340
+ var thumbmark_instance;
4341
+ async function getFingerPrint() {
4342
+ if (typeof window === "undefined") return null;
4343
+ if (!thumbmark_instance) {
4344
+ thumbmark_instance = new thumbmarkjs.Thumbmark({
4345
+ logging: false,
4346
+ timeout: 3e4,
4347
+ cache_lifetime_in_ms: 1 * 60 * 60 * 1e3
4348
+ });
4349
+ }
4350
+ try {
4351
+ const cached = sessionStorage.getItem("fingerprint");
4352
+ if (cached) return cached;
4353
+ const result = await thumbmark_instance.get();
4354
+ sessionStorage.setItem("fingerprint", result.thumbmark);
4355
+ return result.thumbmark;
4356
+ } catch {
4357
+ return null;
4358
+ }
4359
+ }
4338
4360
 
4339
4361
  // src/utils/status-code-to-operation-error.ts
4340
4362
  function statusCodeToOperationError(value, message) {
@@ -4368,8 +4390,14 @@ var AuthService = class {
4368
4390
  headers.append("Content-Type", "application/json");
4369
4391
  return headers;
4370
4392
  }
4371
- async createSession(input) {
4393
+ async createSession(input, version = 1) {
4372
4394
  const headers = new Headers(this.headers);
4395
+ if (version === 3) {
4396
+ const fingerprint = await getFingerPrint();
4397
+ if (fingerprint) {
4398
+ headers.append("Fingerprint", fingerprint);
4399
+ }
4400
+ }
4373
4401
  if (input.channel) {
4374
4402
  headers.append("Channel", input.channel);
4375
4403
  }
@@ -4402,9 +4430,10 @@ var AuthService = class {
4402
4430
  headers.set("test-pass", input.testPass);
4403
4431
  }
4404
4432
  try {
4405
- const res = await fetch(`${this.url}/sessions`, {
4433
+ const res = await fetch(`${this.url}${version === 3 ? "/v3/sessions" : "/sessions"}`, {
4406
4434
  method: "POST",
4407
- headers
4435
+ headers,
4436
+ body: JSON.stringify(input)
4408
4437
  });
4409
4438
  const data = await res.json();
4410
4439
  if (res.ok) {
@@ -4556,7 +4585,7 @@ var AuthService = class {
4556
4585
  return true;
4557
4586
  }
4558
4587
  }
4559
- async sendVerificationCode(input) {
4588
+ async sendVerificationCode(input, recaptchaResponse) {
4560
4589
  if (input.channel === "EMAIL")
4561
4590
  throw new Error("Email channel is not yet supported");
4562
4591
  function getErrorCode(message) {
@@ -4574,8 +4603,15 @@ var AuthService = class {
4574
4603
  try {
4575
4604
  const res = await fetch(`${this.url}/otps`, {
4576
4605
  method: "POST",
4577
- headers: this.headers,
4578
- body: JSON.stringify(input)
4606
+ headers: {
4607
+ ...this.headers,
4608
+ ...recaptchaResponse && {
4609
+ "google-recaptcha-response": recaptchaResponse
4610
+ }
4611
+ },
4612
+ body: JSON.stringify({
4613
+ ...input
4614
+ })
4579
4615
  });
4580
4616
  if (res.status === 403) {
4581
4617
  const data = await res.json();