@opexa/portal-sdk 0.8.2 → 0.10.0
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/README.md +1623 -1623
- package/dist/index.cjs +52 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -7
- package/dist/index.d.ts +11 -7
- package/dist/index.js +52 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2437,10 +2437,10 @@ var AuthService = class {
|
|
|
2437
2437
|
headers.set("Authorization", `Token ${input.token}`);
|
|
2438
2438
|
}
|
|
2439
2439
|
if (input.type === "CABINET") {
|
|
2440
|
-
headers.set("Authorization", `
|
|
2440
|
+
headers.set("Authorization", `Opexa-Cabinet-Token ${input.token}`);
|
|
2441
2441
|
}
|
|
2442
|
-
if (input.type === "
|
|
2443
|
-
headers.set("Authorization", `
|
|
2442
|
+
if (input.type === "SINGLE_USE_TOKEN") {
|
|
2443
|
+
headers.set("Authorization", `Single-Use-Token ${input.token}`);
|
|
2444
2444
|
}
|
|
2445
2445
|
if (input.reCAPTCHAResponse) {
|
|
2446
2446
|
headers.set("google-recaptcha-response", input.reCAPTCHAResponse);
|
|
@@ -2642,6 +2642,38 @@ var AuthService = class {
|
|
|
2642
2642
|
};
|
|
2643
2643
|
}
|
|
2644
2644
|
}
|
|
2645
|
+
async createSingleUseToken(accessToken) {
|
|
2646
|
+
const headers = new Headers(this.headers);
|
|
2647
|
+
headers.append("Authorization", `Bearer ${accessToken}`);
|
|
2648
|
+
try {
|
|
2649
|
+
const res = await fetch(`${this.url}/token`, {
|
|
2650
|
+
method: "POST",
|
|
2651
|
+
headers
|
|
2652
|
+
});
|
|
2653
|
+
const data = await res.json();
|
|
2654
|
+
if (res.ok) {
|
|
2655
|
+
return {
|
|
2656
|
+
ok: true,
|
|
2657
|
+
data
|
|
2658
|
+
};
|
|
2659
|
+
}
|
|
2660
|
+
if (res.status === 403 || res.status === 401) {
|
|
2661
|
+
return {
|
|
2662
|
+
ok: false,
|
|
2663
|
+
error: createOperationError("InvalidTokenError")
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
return {
|
|
2667
|
+
ok: false,
|
|
2668
|
+
error: statusCodeToOperationError(res.status)
|
|
2669
|
+
};
|
|
2670
|
+
} catch {
|
|
2671
|
+
return {
|
|
2672
|
+
ok: false,
|
|
2673
|
+
error: statusCodeToOperationError(500)
|
|
2674
|
+
};
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2645
2677
|
};
|
|
2646
2678
|
|
|
2647
2679
|
// src/services/cms-portal.service.ts
|
|
@@ -5476,9 +5508,9 @@ var Sdk = class {
|
|
|
5476
5508
|
});
|
|
5477
5509
|
return res.ok ? { ok: true } : res;
|
|
5478
5510
|
}
|
|
5479
|
-
case "
|
|
5511
|
+
case "SINGLE_USE_TOKEN": {
|
|
5480
5512
|
const res = await this.sessionManager.create({
|
|
5481
|
-
type: "
|
|
5513
|
+
type: "SINGLE_USE_TOKEN",
|
|
5482
5514
|
token: input.token
|
|
5483
5515
|
});
|
|
5484
5516
|
return res.ok ? { ok: true } : res;
|
|
@@ -5545,6 +5577,21 @@ var Sdk = class {
|
|
|
5545
5577
|
async validateMayaSession() {
|
|
5546
5578
|
return await this.walletService.validateMayaSession();
|
|
5547
5579
|
}
|
|
5580
|
+
async createSingleUseToken() {
|
|
5581
|
+
const res0 = await this.sessionManager.get();
|
|
5582
|
+
if (!res0.ok || !res0.data) {
|
|
5583
|
+
return {
|
|
5584
|
+
ok: false,
|
|
5585
|
+
error: {
|
|
5586
|
+
name: "UnknownError",
|
|
5587
|
+
message: "Something went wrong"
|
|
5588
|
+
}
|
|
5589
|
+
};
|
|
5590
|
+
}
|
|
5591
|
+
const res1 = await this.authService.createSingleUseToken(res0.data.accessToken);
|
|
5592
|
+
if (!res1.ok) return res1;
|
|
5593
|
+
return { ok: true, data: res1.data.token };
|
|
5594
|
+
}
|
|
5548
5595
|
/**/
|
|
5549
5596
|
/*+----------------------------------------+*/
|
|
5550
5597
|
/*+ SITE +*/
|