@opexa/portal-sdk 0.59.75 → 0.59.77

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.
@@ -4479,7 +4479,7 @@ var AuthService = class {
4479
4479
  }
4480
4480
  async createSession(input, version = 1) {
4481
4481
  const headers = new Headers(this.headers);
4482
- if (version === 3) {
4482
+ if (version === 3 || version === 4) {
4483
4483
  const fingerprint = await getFingerPrint();
4484
4484
  if (fingerprint) {
4485
4485
  headers.append("Fingerprint", fingerprint);
@@ -4517,14 +4517,12 @@ var AuthService = class {
4517
4517
  headers.set("test-pass", input.testPass);
4518
4518
  }
4519
4519
  try {
4520
- const res = await fetch(
4521
- `${this.url}${version === 3 ? "/v3/sessions" : "/sessions"}`,
4522
- {
4523
- method: "POST",
4524
- headers,
4525
- body: JSON.stringify(input)
4526
- }
4527
- );
4520
+ const res = await fetch(`${this.url}${version !== 1 ? `/v${version}/sessions` : "/sessions"}`, {
4521
+ method: "POST",
4522
+ headers,
4523
+ body: JSON.stringify(input),
4524
+ ...version === 4 && { credentials: "include" }
4525
+ });
4528
4526
  const data = await res.json();
4529
4527
  if (res.ok) {
4530
4528
  return {
@@ -4605,14 +4603,26 @@ var AuthService = class {
4605
4603
  }
4606
4604
  throw new Error("Invalid input 'type'");
4607
4605
  }
4608
- async refreshSession(refreshToken) {
4606
+ async refreshSession(refreshToken, version = 1) {
4609
4607
  const headers = new Headers(this.headers);
4610
- headers.append("Authorization", `Bearer ${refreshToken}`);
4608
+ if (version !== 4) {
4609
+ headers.append("Authorization", `Bearer ${refreshToken}`);
4610
+ }
4611
+ if (version === 3 || version === 4) {
4612
+ const fingerprint = await getFingerPrint();
4613
+ if (fingerprint) {
4614
+ headers.append("Fingerprint", fingerprint);
4615
+ }
4616
+ }
4611
4617
  try {
4612
- const res = await fetch(`${this.url}/session:refresh`, {
4613
- method: "POST",
4614
- headers
4615
- });
4618
+ const res = await fetch(
4619
+ `${this.url}${version !== 1 ? `/v${version}/session/refresh` : "/session:refresh"}`,
4620
+ {
4621
+ method: "POST",
4622
+ headers,
4623
+ ...version === 4 && { credentials: "include" }
4624
+ }
4625
+ );
4616
4626
  const data = await res.json();
4617
4627
  if (res.ok) {
4618
4628
  return {
@@ -4649,14 +4659,20 @@ var AuthService = class {
4649
4659
  };
4650
4660
  }
4651
4661
  }
4652
- async destroySession(accessToken) {
4662
+ async destroySession(accessToken, version = 1) {
4653
4663
  const headers = new Headers(this.headers);
4654
- headers.append("Authorization", `Bearer ${accessToken}`);
4664
+ if (version !== 4) {
4665
+ headers.append("Authorization", `Bearer ${accessToken}`);
4666
+ }
4655
4667
  try {
4656
- const res = await fetch(`${this.url}/session`, {
4657
- method: "DELETE",
4658
- headers
4659
- });
4668
+ const res = await fetch(
4669
+ `${this.url}${version !== 1 ? `/v${version}/session` : "/session"}`,
4670
+ {
4671
+ method: "DELETE",
4672
+ headers,
4673
+ ...version === 4 && { credentials: "include" }
4674
+ }
4675
+ );
4660
4676
  return res.ok ? { ok: true } : { ok: false, error: statusCodeToOperationError(res.status) };
4661
4677
  } catch {
4662
4678
  return { ok: false, error: statusCodeToOperationError(500) };