@opexa/portal-sdk 0.59.79 → 0.59.81
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/{chunk-AIJL2W7N.js → chunk-443LKA6K.js} +18 -6
- package/dist/chunk-443LKA6K.js.map +1 -0
- package/dist/index.cjs +66 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +52 -9
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +16 -4
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AIJL2W7N.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -4485,6 +4485,13 @@ var ERROR_MAP = {
|
|
|
4485
4485
|
};
|
|
4486
4486
|
|
|
4487
4487
|
// src/services/auth.service.ts
|
|
4488
|
+
function isWebPlatform() {
|
|
4489
|
+
try {
|
|
4490
|
+
return core.Capacitor.getPlatform() === "web";
|
|
4491
|
+
} catch {
|
|
4492
|
+
return false;
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4488
4495
|
var AuthService = class {
|
|
4489
4496
|
url;
|
|
4490
4497
|
options;
|
|
@@ -4538,7 +4545,9 @@ var AuthService = class {
|
|
|
4538
4545
|
headers.set("test-pass", input.testPass);
|
|
4539
4546
|
}
|
|
4540
4547
|
try {
|
|
4541
|
-
const
|
|
4548
|
+
const isWeb = isWebPlatform();
|
|
4549
|
+
const queryParam = isWeb && version === 4 ? "?type=web" : "";
|
|
4550
|
+
const res = await fetch(`${this.url}${version !== 1 ? `/v${version}/sessions` : "/sessions"}${queryParam}`, {
|
|
4542
4551
|
method: "POST",
|
|
4543
4552
|
headers,
|
|
4544
4553
|
body: JSON.stringify(input),
|
|
@@ -4636,8 +4645,10 @@ var AuthService = class {
|
|
|
4636
4645
|
}
|
|
4637
4646
|
}
|
|
4638
4647
|
try {
|
|
4648
|
+
const isWeb = isWebPlatform();
|
|
4649
|
+
const queryParam = isWeb && version === 4 ? "?type=web" : "";
|
|
4639
4650
|
const res = await fetch(
|
|
4640
|
-
`${this.url}${version !== 1 ? `/v${version}/session/refresh` : "/session:refresh"}`,
|
|
4651
|
+
`${this.url}${version !== 1 ? `/v${version}/session/refresh` : "/session:refresh"}${queryParam}`,
|
|
4641
4652
|
{
|
|
4642
4653
|
method: "POST",
|
|
4643
4654
|
headers,
|
|
@@ -4716,7 +4727,7 @@ var AuthService = class {
|
|
|
4716
4727
|
return true;
|
|
4717
4728
|
}
|
|
4718
4729
|
}
|
|
4719
|
-
async sendVerificationCode(input) {
|
|
4730
|
+
async sendVerificationCode(input, version = 1) {
|
|
4720
4731
|
if (input.channel === "EMAIL")
|
|
4721
4732
|
throw new Error("Email channel is not yet supported");
|
|
4722
4733
|
function getErrorCode(message) {
|
|
@@ -4732,7 +4743,7 @@ var AuthService = class {
|
|
|
4732
4743
|
}
|
|
4733
4744
|
}
|
|
4734
4745
|
try {
|
|
4735
|
-
const res = await fetch(`${this.url}/otps`, {
|
|
4746
|
+
const res = await fetch(`${this.url}${version !== 1 ? `/v${version}/otps` : "/otps"}`, {
|
|
4736
4747
|
method: "POST",
|
|
4737
4748
|
headers: this.headers,
|
|
4738
4749
|
body: JSON.stringify(input)
|
|
@@ -7497,6 +7508,14 @@ var SessionManagerCookie = class {
|
|
|
7497
7508
|
this.logger.warn("'client cookies' is not available on the server.");
|
|
7498
7509
|
return true;
|
|
7499
7510
|
}
|
|
7511
|
+
const val = cookies__default.default.get(this.storageKey);
|
|
7512
|
+
if (val) {
|
|
7513
|
+
try {
|
|
7514
|
+
const stored = JSON.parse(val);
|
|
7515
|
+
if (stored.version === 4) return await this.verifyV4();
|
|
7516
|
+
} catch {
|
|
7517
|
+
}
|
|
7518
|
+
}
|
|
7500
7519
|
const s = await this.get();
|
|
7501
7520
|
if (s.error?.name === "InvalidTokenError") return false;
|
|
7502
7521
|
if (s.error?.name === "SessionExpiredError") return false;
|
|
@@ -7508,6 +7527,18 @@ var SessionManagerCookie = class {
|
|
|
7508
7527
|
}
|
|
7509
7528
|
return v;
|
|
7510
7529
|
}
|
|
7530
|
+
async verifyV4() {
|
|
7531
|
+
if (!this.v4AccessToken || !this.v4AccessTokenExpiresAt || isAfter(/* @__PURE__ */ new Date(), new Date(this.v4AccessTokenExpiresAt))) {
|
|
7532
|
+
return true;
|
|
7533
|
+
}
|
|
7534
|
+
const v = await this.authService.verifySession(this.v4AccessToken);
|
|
7535
|
+
if (!v) {
|
|
7536
|
+
cookies__default.default.remove(this.storageKey);
|
|
7537
|
+
this.v4AccessToken = null;
|
|
7538
|
+
this.v4AccessTokenExpiresAt = null;
|
|
7539
|
+
}
|
|
7540
|
+
return v;
|
|
7541
|
+
}
|
|
7511
7542
|
get onMaya() {
|
|
7512
7543
|
if (this.isServer) {
|
|
7513
7544
|
this.logger.warn("'client cookies' is not available on the server.");
|
|
@@ -7944,6 +7975,14 @@ var SessionManager = class {
|
|
|
7944
7975
|
this.logger.warn("'localStorage' is not available on the server.");
|
|
7945
7976
|
return true;
|
|
7946
7977
|
}
|
|
7978
|
+
const val = localStorage.getItem(this.storageKey);
|
|
7979
|
+
if (val) {
|
|
7980
|
+
try {
|
|
7981
|
+
const stored = JSON.parse(val);
|
|
7982
|
+
if (stored.version === 4) return await this.verifyV4();
|
|
7983
|
+
} catch {
|
|
7984
|
+
}
|
|
7985
|
+
}
|
|
7947
7986
|
const s = await this.get();
|
|
7948
7987
|
if (s.error?.name === "InvalidTokenError") return false;
|
|
7949
7988
|
if (s.error?.name === "SessionExpiredError") return false;
|
|
@@ -7955,6 +7994,18 @@ var SessionManager = class {
|
|
|
7955
7994
|
}
|
|
7956
7995
|
return v;
|
|
7957
7996
|
}
|
|
7997
|
+
async verifyV4() {
|
|
7998
|
+
if (!this.v4AccessToken || !this.v4AccessTokenExpiresAt || isAfter(/* @__PURE__ */ new Date(), new Date(this.v4AccessTokenExpiresAt))) {
|
|
7999
|
+
return true;
|
|
8000
|
+
}
|
|
8001
|
+
const v = await this.authService.verifySession(this.v4AccessToken);
|
|
8002
|
+
if (!v) {
|
|
8003
|
+
localStorage.removeItem(this.storageKey);
|
|
8004
|
+
this.v4AccessToken = null;
|
|
8005
|
+
this.v4AccessTokenExpiresAt = null;
|
|
8006
|
+
}
|
|
8007
|
+
return v;
|
|
8008
|
+
}
|
|
7958
8009
|
get onMaya() {
|
|
7959
8010
|
if (this.isServer) {
|
|
7960
8011
|
this.logger.warn("'localStorage' is not available on the server.");
|
|
@@ -10753,15 +10804,18 @@ var Sdk = class {
|
|
|
10753
10804
|
}
|
|
10754
10805
|
});
|
|
10755
10806
|
}
|
|
10756
|
-
async sendVerificationCode__next(input) {
|
|
10807
|
+
async sendVerificationCode__next(input, version = 1) {
|
|
10757
10808
|
if (input.type === "SMS") {
|
|
10758
|
-
return this.authService.sendVerificationCode(
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10809
|
+
return this.authService.sendVerificationCode(
|
|
10810
|
+
{
|
|
10811
|
+
channel: "SMS",
|
|
10812
|
+
recipient: addAreaCode(input.mobileNumber, await this.locale),
|
|
10813
|
+
...input.strict && {
|
|
10814
|
+
verificationType: "MEMBER"
|
|
10815
|
+
}
|
|
10816
|
+
},
|
|
10817
|
+
version
|
|
10818
|
+
);
|
|
10765
10819
|
}
|
|
10766
10820
|
throw new Error("'Email' verification code is not yet supported");
|
|
10767
10821
|
}
|