@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/{chunk-AKP5LBV2.js → chunk-FUFD2LUS.js} +44 -9
- package/dist/chunk-FUFD2LUS.js.map +1 -0
- package/dist/index.cjs +112 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +73 -71
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +42 -6
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +2 -2
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AKP5LBV2.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -4358,6 +4358,26 @@ var AccountService = class {
|
|
|
4358
4358
|
};
|
|
4359
4359
|
}
|
|
4360
4360
|
};
|
|
4361
|
+
var thumbmark_instance;
|
|
4362
|
+
async function getFingerPrint() {
|
|
4363
|
+
if (typeof window === "undefined") return null;
|
|
4364
|
+
if (!thumbmark_instance) {
|
|
4365
|
+
thumbmark_instance = new thumbmarkjs.Thumbmark({
|
|
4366
|
+
logging: false,
|
|
4367
|
+
timeout: 3e4,
|
|
4368
|
+
cache_lifetime_in_ms: 1 * 60 * 60 * 1e3
|
|
4369
|
+
});
|
|
4370
|
+
}
|
|
4371
|
+
try {
|
|
4372
|
+
const cached = sessionStorage.getItem("fingerprint");
|
|
4373
|
+
if (cached) return cached;
|
|
4374
|
+
const result = await thumbmark_instance.get();
|
|
4375
|
+
sessionStorage.setItem("fingerprint", result.thumbmark);
|
|
4376
|
+
return result.thumbmark;
|
|
4377
|
+
} catch {
|
|
4378
|
+
return null;
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4361
4381
|
|
|
4362
4382
|
// src/utils/status-code-to-operation-error.ts
|
|
4363
4383
|
function statusCodeToOperationError(value, message) {
|
|
@@ -4391,8 +4411,14 @@ var AuthService = class {
|
|
|
4391
4411
|
headers.append("Content-Type", "application/json");
|
|
4392
4412
|
return headers;
|
|
4393
4413
|
}
|
|
4394
|
-
async createSession(input) {
|
|
4414
|
+
async createSession(input, version = 1) {
|
|
4395
4415
|
const headers = new Headers(this.headers);
|
|
4416
|
+
if (version === 3) {
|
|
4417
|
+
const fingerprint = await getFingerPrint();
|
|
4418
|
+
if (fingerprint) {
|
|
4419
|
+
headers.append("Fingerprint", fingerprint);
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4396
4422
|
if (input.channel) {
|
|
4397
4423
|
headers.append("Channel", input.channel);
|
|
4398
4424
|
}
|
|
@@ -4425,9 +4451,10 @@ var AuthService = class {
|
|
|
4425
4451
|
headers.set("test-pass", input.testPass);
|
|
4426
4452
|
}
|
|
4427
4453
|
try {
|
|
4428
|
-
const res = await fetch(`${this.url}/sessions`, {
|
|
4454
|
+
const res = await fetch(`${this.url}${version === 3 ? "/v3/sessions" : "/sessions"}`, {
|
|
4429
4455
|
method: "POST",
|
|
4430
|
-
headers
|
|
4456
|
+
headers,
|
|
4457
|
+
body: JSON.stringify(input)
|
|
4431
4458
|
});
|
|
4432
4459
|
const data = await res.json();
|
|
4433
4460
|
if (res.ok) {
|
|
@@ -4579,7 +4606,7 @@ var AuthService = class {
|
|
|
4579
4606
|
return true;
|
|
4580
4607
|
}
|
|
4581
4608
|
}
|
|
4582
|
-
async sendVerificationCode(input) {
|
|
4609
|
+
async sendVerificationCode(input, recaptchaResponse) {
|
|
4583
4610
|
if (input.channel === "EMAIL")
|
|
4584
4611
|
throw new Error("Email channel is not yet supported");
|
|
4585
4612
|
function getErrorCode(message) {
|
|
@@ -4597,8 +4624,15 @@ var AuthService = class {
|
|
|
4597
4624
|
try {
|
|
4598
4625
|
const res = await fetch(`${this.url}/otps`, {
|
|
4599
4626
|
method: "POST",
|
|
4600
|
-
headers:
|
|
4601
|
-
|
|
4627
|
+
headers: {
|
|
4628
|
+
...this.headers,
|
|
4629
|
+
...recaptchaResponse && {
|
|
4630
|
+
"google-recaptcha-response": recaptchaResponse
|
|
4631
|
+
}
|
|
4632
|
+
},
|
|
4633
|
+
body: JSON.stringify({
|
|
4634
|
+
...input
|
|
4635
|
+
})
|
|
4602
4636
|
});
|
|
4603
4637
|
if (res.status === 403) {
|
|
4604
4638
|
const data = await res.json();
|
|
@@ -6723,6 +6757,8 @@ function addHours(date, hours) {
|
|
|
6723
6757
|
result.setHours(result.getHours() + hours);
|
|
6724
6758
|
return result;
|
|
6725
6759
|
}
|
|
6760
|
+
|
|
6761
|
+
// src/sdk/utils.ts
|
|
6726
6762
|
function getLocaleByCurrency(currency) {
|
|
6727
6763
|
if (currency === "INR") return "en-IN";
|
|
6728
6764
|
if (currency === "MYR") return "en-MY";
|
|
@@ -6752,26 +6788,6 @@ function parseFbCxd(input) {
|
|
|
6752
6788
|
const fbAdditionalCxd = input.split(cxd)[1].slice(1);
|
|
6753
6789
|
return { cxd, fbAdditionalCxd };
|
|
6754
6790
|
}
|
|
6755
|
-
var thumbmark_instance;
|
|
6756
|
-
async function getFingerprint() {
|
|
6757
|
-
if (typeof window === "undefined") return null;
|
|
6758
|
-
if (!thumbmark_instance) {
|
|
6759
|
-
thumbmark_instance = new thumbmarkjs.Thumbmark({
|
|
6760
|
-
logging: false,
|
|
6761
|
-
timeout: 3e4,
|
|
6762
|
-
cache_lifetime_in_ms: 1 * 60 * 60 * 1e3
|
|
6763
|
-
});
|
|
6764
|
-
}
|
|
6765
|
-
try {
|
|
6766
|
-
const cached = sessionStorage.getItem("fingerprint");
|
|
6767
|
-
if (cached) return cached;
|
|
6768
|
-
const result = await thumbmark_instance.get();
|
|
6769
|
-
sessionStorage.setItem("fingerprint", result.thumbmark);
|
|
6770
|
-
return result.thumbmark;
|
|
6771
|
-
} catch {
|
|
6772
|
-
return null;
|
|
6773
|
-
}
|
|
6774
|
-
}
|
|
6775
6791
|
function getCookie(name) {
|
|
6776
6792
|
if (typeof document === "undefined") return null;
|
|
6777
6793
|
const nameLenPlus = name.length + 1;
|
|
@@ -6911,7 +6927,7 @@ var SessionManager = class {
|
|
|
6911
6927
|
set refreshing(value) {
|
|
6912
6928
|
this._refreshing = value;
|
|
6913
6929
|
}
|
|
6914
|
-
async create(input) {
|
|
6930
|
+
async create(input, version = 1) {
|
|
6915
6931
|
if (this.isServer) {
|
|
6916
6932
|
this.logger.warn("'localStorage' is not available on the server.");
|
|
6917
6933
|
return {
|
|
@@ -6940,7 +6956,7 @@ var SessionManager = class {
|
|
|
6940
6956
|
}
|
|
6941
6957
|
};
|
|
6942
6958
|
}
|
|
6943
|
-
const f1 = () => this.authService.createSession(input);
|
|
6959
|
+
const f1 = () => this.authService.createSession(input, version);
|
|
6944
6960
|
const r1 = await pollable(f1, {
|
|
6945
6961
|
until: (r) => r.ok,
|
|
6946
6962
|
interval: 1e3,
|
|
@@ -6962,7 +6978,7 @@ var SessionManager = class {
|
|
|
6962
6978
|
};
|
|
6963
6979
|
}
|
|
6964
6980
|
if (input.type === "MOBILE_NUMBER") {
|
|
6965
|
-
const res2 = await this.authService.createSession(input);
|
|
6981
|
+
const res2 = await this.authService.createSession(input, version);
|
|
6966
6982
|
if (res2.ok) {
|
|
6967
6983
|
const now2 = /* @__PURE__ */ new Date();
|
|
6968
6984
|
localStorage.setItem(
|
|
@@ -6981,11 +6997,14 @@ var SessionManager = class {
|
|
|
6981
6997
|
return res2;
|
|
6982
6998
|
}
|
|
6983
6999
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
6984
|
-
const res2 = await this.authService.createSession(
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
7000
|
+
const res2 = await this.authService.createSession(
|
|
7001
|
+
{
|
|
7002
|
+
type: "SOCIALS",
|
|
7003
|
+
token: input.token,
|
|
7004
|
+
channel: input.channel
|
|
7005
|
+
},
|
|
7006
|
+
version
|
|
7007
|
+
);
|
|
6989
7008
|
if (res2.ok) {
|
|
6990
7009
|
const now2 = /* @__PURE__ */ new Date();
|
|
6991
7010
|
localStorage.setItem(
|
|
@@ -7005,7 +7024,7 @@ var SessionManager = class {
|
|
|
7005
7024
|
}
|
|
7006
7025
|
if (input.type === "CABINET") {
|
|
7007
7026
|
localStorage.setItem(this.platformStorageKey, "CABINET");
|
|
7008
|
-
const res2 = await this.authService.createSession(input);
|
|
7027
|
+
const res2 = await this.authService.createSession(input, version);
|
|
7009
7028
|
if (res2.ok) {
|
|
7010
7029
|
const now2 = /* @__PURE__ */ new Date();
|
|
7011
7030
|
localStorage.setItem(
|
|
@@ -7023,7 +7042,7 @@ var SessionManager = class {
|
|
|
7023
7042
|
}
|
|
7024
7043
|
return res2;
|
|
7025
7044
|
}
|
|
7026
|
-
const res = await this.authService.createSession(input);
|
|
7045
|
+
const res = await this.authService.createSession(input, version);
|
|
7027
7046
|
if (!res.ok) return res;
|
|
7028
7047
|
if (res.data.authenticator) {
|
|
7029
7048
|
return {
|
|
@@ -7272,7 +7291,7 @@ var SessionManagerCookie = class {
|
|
|
7272
7291
|
set refreshing(value) {
|
|
7273
7292
|
this._refreshing = value;
|
|
7274
7293
|
}
|
|
7275
|
-
async create(input) {
|
|
7294
|
+
async create(input, version = 1) {
|
|
7276
7295
|
if (input.type === "MAYA") {
|
|
7277
7296
|
localStorage.setItem(this.platformStorageKey, "MAYA");
|
|
7278
7297
|
const f0 = () => this.walletService.mayaSession({ id: input.sessionId });
|
|
@@ -7291,7 +7310,7 @@ var SessionManagerCookie = class {
|
|
|
7291
7310
|
}
|
|
7292
7311
|
};
|
|
7293
7312
|
}
|
|
7294
|
-
const f1 = () => this.authService.createSession(input);
|
|
7313
|
+
const f1 = () => this.authService.createSession(input, version);
|
|
7295
7314
|
const r1 = await pollable(f1, {
|
|
7296
7315
|
until: (r) => r.ok,
|
|
7297
7316
|
interval: 1e3,
|
|
@@ -7314,7 +7333,7 @@ var SessionManagerCookie = class {
|
|
|
7314
7333
|
};
|
|
7315
7334
|
}
|
|
7316
7335
|
if (input.type === "MOBILE_NUMBER") {
|
|
7317
|
-
const res2 = await this.authService.createSession(input);
|
|
7336
|
+
const res2 = await this.authService.createSession(input, version);
|
|
7318
7337
|
if (res2.ok) {
|
|
7319
7338
|
const now2 = /* @__PURE__ */ new Date();
|
|
7320
7339
|
cookies__default.default.set(
|
|
@@ -7336,10 +7355,13 @@ var SessionManagerCookie = class {
|
|
|
7336
7355
|
return res2;
|
|
7337
7356
|
}
|
|
7338
7357
|
if (input.type === "SOCIALS" || input.type === "TOKEN") {
|
|
7339
|
-
const res2 = await this.authService.createSession(
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7358
|
+
const res2 = await this.authService.createSession(
|
|
7359
|
+
{
|
|
7360
|
+
type: "SOCIALS",
|
|
7361
|
+
token: input.token
|
|
7362
|
+
},
|
|
7363
|
+
version
|
|
7364
|
+
);
|
|
7343
7365
|
if (res2.ok) {
|
|
7344
7366
|
const now2 = /* @__PURE__ */ new Date();
|
|
7345
7367
|
cookies__default.default.set(
|
|
@@ -7360,7 +7382,7 @@ var SessionManagerCookie = class {
|
|
|
7360
7382
|
}
|
|
7361
7383
|
if (input.type === "CABINET") {
|
|
7362
7384
|
localStorage.setItem(this.platformStorageKey, "CABINET");
|
|
7363
|
-
const res2 = await this.authService.createSession(input);
|
|
7385
|
+
const res2 = await this.authService.createSession(input, version);
|
|
7364
7386
|
if (res2.ok) {
|
|
7365
7387
|
const now2 = /* @__PURE__ */ new Date();
|
|
7366
7388
|
cookies__default.default.set(
|
|
@@ -7379,7 +7401,7 @@ var SessionManagerCookie = class {
|
|
|
7379
7401
|
}
|
|
7380
7402
|
return res2;
|
|
7381
7403
|
}
|
|
7382
|
-
const res = await this.authService.createSession(input);
|
|
7404
|
+
const res = await this.authService.createSession(input, version);
|
|
7383
7405
|
if (!res.ok) return res;
|
|
7384
7406
|
if (res.data.authenticator) {
|
|
7385
7407
|
return {
|
|
@@ -9742,7 +9764,7 @@ var Sdk = class {
|
|
|
9742
9764
|
};
|
|
9743
9765
|
}
|
|
9744
9766
|
async fingerprint() {
|
|
9745
|
-
return await
|
|
9767
|
+
return await getFingerPrint();
|
|
9746
9768
|
}
|
|
9747
9769
|
get miscMiddleware() {
|
|
9748
9770
|
return async (request) => {
|
|
@@ -9768,7 +9790,7 @@ var Sdk = class {
|
|
|
9768
9790
|
this.fbp = fbp;
|
|
9769
9791
|
}
|
|
9770
9792
|
}
|
|
9771
|
-
async signIn(input) {
|
|
9793
|
+
async signIn(input, version = 1) {
|
|
9772
9794
|
if (input.type === "TOKEN") {
|
|
9773
9795
|
console.warn(
|
|
9774
9796
|
"'TOKEN (signIn)' is deprecated. Please use 'SOCIALS' instead."
|
|
@@ -9776,10 +9798,13 @@ var Sdk = class {
|
|
|
9776
9798
|
}
|
|
9777
9799
|
switch (input.type) {
|
|
9778
9800
|
case "NAME_AND_PASSWORD": {
|
|
9779
|
-
const res = await this.sessionManager.create(
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9801
|
+
const res = await this.sessionManager.create(
|
|
9802
|
+
{
|
|
9803
|
+
...input,
|
|
9804
|
+
password: await sha256(input.password)
|
|
9805
|
+
},
|
|
9806
|
+
version
|
|
9807
|
+
);
|
|
9783
9808
|
if (!res.ok) return res;
|
|
9784
9809
|
if (res.data) {
|
|
9785
9810
|
return {
|
|
@@ -9799,42 +9824,54 @@ var Sdk = class {
|
|
|
9799
9824
|
}
|
|
9800
9825
|
case "SOCIALS":
|
|
9801
9826
|
case "TOKEN": {
|
|
9802
|
-
const res = await this.sessionManager.create(
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9827
|
+
const res = await this.sessionManager.create(
|
|
9828
|
+
{
|
|
9829
|
+
type: "SOCIALS",
|
|
9830
|
+
token: input.token,
|
|
9831
|
+
channel: input.channel
|
|
9832
|
+
},
|
|
9833
|
+
version
|
|
9834
|
+
);
|
|
9807
9835
|
return res.ok ? { ok: true } : res;
|
|
9808
9836
|
}
|
|
9809
9837
|
case "CABINET": {
|
|
9810
|
-
const res = await this.sessionManager.create(
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9838
|
+
const res = await this.sessionManager.create(
|
|
9839
|
+
{
|
|
9840
|
+
type: "CABINET",
|
|
9841
|
+
token: input.token,
|
|
9842
|
+
channel: input.channel
|
|
9843
|
+
},
|
|
9844
|
+
version
|
|
9845
|
+
);
|
|
9815
9846
|
return res.ok ? { ok: true } : res;
|
|
9816
9847
|
}
|
|
9817
9848
|
case "MOBILE_NUMBER": {
|
|
9818
|
-
const res = await this.sessionManager.create(
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9849
|
+
const res = await this.sessionManager.create(
|
|
9850
|
+
{
|
|
9851
|
+
type: "MOBILE_NUMBER",
|
|
9852
|
+
mobileNumber: addAreaCode(input.mobileNumber, await this.locale),
|
|
9853
|
+
verificationCode: input.verificationCode,
|
|
9854
|
+
reCAPTCHAResponse: input.reCAPTCHAResponse,
|
|
9855
|
+
testPass: input.testPass,
|
|
9856
|
+
channel: input.channel
|
|
9857
|
+
},
|
|
9858
|
+
version
|
|
9859
|
+
);
|
|
9826
9860
|
return res.ok ? { ok: true } : res;
|
|
9827
9861
|
}
|
|
9828
9862
|
case "SINGLE_USE_TOKEN": {
|
|
9829
|
-
const res = await this.sessionManager.create(
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9863
|
+
const res = await this.sessionManager.create(
|
|
9864
|
+
{
|
|
9865
|
+
type: "SINGLE_USE_TOKEN",
|
|
9866
|
+
token: input.token,
|
|
9867
|
+
channel: input.channel
|
|
9868
|
+
},
|
|
9869
|
+
version
|
|
9870
|
+
);
|
|
9834
9871
|
return res.ok ? { ok: true } : res;
|
|
9835
9872
|
}
|
|
9836
9873
|
default: {
|
|
9837
|
-
const res = await this.sessionManager.create(input);
|
|
9874
|
+
const res = await this.sessionManager.create(input, version);
|
|
9838
9875
|
return res.ok ? { ok: true } : res;
|
|
9839
9876
|
}
|
|
9840
9877
|
}
|