ggez-banking-sdk 0.4.33 → 0.5.6
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/api/api.js +9 -1
- package/dist/api/bc-api.d.ts +6 -0
- package/dist/api/bc-api.js +7 -0
- package/dist/api/service/baseBlockchainService.d.ts +8 -0
- package/dist/api/service/baseBlockchainService.js +14 -0
- package/dist/api/service/index.d.ts +1 -0
- package/dist/api/service/index.js +1 -0
- package/dist/api/service/programService.d.ts +2 -0
- package/dist/api/service/programService.js +10 -0
- package/dist/helper/storage/cookiesHelper.js +4 -4
- package/dist/types/api/bc-api.d.ts +4 -0
- package/dist/types/api/bc-api.js +1 -0
- package/dist/types/api/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/api/api.js
CHANGED
|
@@ -39,7 +39,15 @@ class API {
|
|
|
39
39
|
this.user = new UserProxy(proxyData);
|
|
40
40
|
}
|
|
41
41
|
async logout() {
|
|
42
|
-
|
|
42
|
+
try {
|
|
43
|
+
const deviceId = await this.cookiesHelper.getDeviceId();
|
|
44
|
+
if (deviceId) {
|
|
45
|
+
await this.user.logoutDevice({ id: deviceId });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
await this.cookiesHelper.clearCredentialCookies();
|
|
50
|
+
}
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
53
|
export { API };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BlockchainAPIConfig, ErrorHandler } from "../types";
|
|
2
|
+
import { BaseBlockchainService } from "./service";
|
|
3
|
+
declare class BlockchainAPI extends BaseBlockchainService {
|
|
4
|
+
constructor(config: BlockchainAPIConfig, errorHandler: ErrorHandler);
|
|
5
|
+
}
|
|
6
|
+
export { BlockchainAPI };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { BlockchainAPIConfig, ErrorHandler } from "../../types";
|
|
3
|
+
declare abstract class BaseBlockchainService {
|
|
4
|
+
private readonly errorHandler;
|
|
5
|
+
protected readonly axiosInstance: AxiosInstance;
|
|
6
|
+
constructor(config: BlockchainAPIConfig, errorHandler: ErrorHandler);
|
|
7
|
+
}
|
|
8
|
+
export { BaseBlockchainService };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
class BaseBlockchainService {
|
|
3
|
+
errorHandler;
|
|
4
|
+
axiosInstance;
|
|
5
|
+
constructor(config, errorHandler) {
|
|
6
|
+
this.errorHandler = errorHandler;
|
|
7
|
+
this.axiosInstance = axios.create({ baseURL: config.baseUrl });
|
|
8
|
+
this.axiosInstance.interceptors.response.use((res) => res, (err) => {
|
|
9
|
+
this.errorHandler(err);
|
|
10
|
+
return Promise.reject(err);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export { BaseBlockchainService };
|
|
@@ -3,7 +3,9 @@ import type { ProgramServiceParameter } from "../../types";
|
|
|
3
3
|
import type { ProgramData } from "../../types/banking/program";
|
|
4
4
|
declare class ProgramService extends BaseService {
|
|
5
5
|
protected endpoint: string;
|
|
6
|
+
private authService;
|
|
6
7
|
constructor(data: ProgramServiceParameter);
|
|
8
|
+
private onProgramRequest;
|
|
7
9
|
getSystemFeatures(): Promise<import("../..").ApiResponse<ProgramData>>;
|
|
8
10
|
getBin(): Promise<import("../..").ApiResponse<ProgramData>>;
|
|
9
11
|
getSignUp(): Promise<import("../..").ApiResponse<ProgramData>>;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { BaseService } from "./baseService";
|
|
2
2
|
import { Endpoints, ProgramEndpoints } from "../../constant/constant";
|
|
3
|
+
import { AxiosHelper } from "../../helper";
|
|
4
|
+
import { AuthService } from "./authService";
|
|
3
5
|
class ProgramService extends BaseService {
|
|
4
6
|
endpoint = Endpoints.Program;
|
|
7
|
+
authService;
|
|
5
8
|
constructor(data) {
|
|
6
9
|
super(data);
|
|
10
|
+
this.authService = new AuthService(data);
|
|
11
|
+
this.axiosInstance.interceptors.request.use((req) => this.onProgramRequest(req));
|
|
12
|
+
}
|
|
13
|
+
// #region "Interceptors Handlers"
|
|
14
|
+
async onProgramRequest(req) {
|
|
15
|
+
await AxiosHelper.injectLimitedToken(req, this.authService, this.cookiesHelper);
|
|
16
|
+
return req;
|
|
7
17
|
}
|
|
8
18
|
//#region "GET"
|
|
9
19
|
getSystemFeatures() {
|
|
@@ -499,16 +499,16 @@ class CookiesHelper {
|
|
|
499
499
|
}
|
|
500
500
|
async clearCredentialCookies() {
|
|
501
501
|
try {
|
|
502
|
+
this.cachedUSR = null;
|
|
503
|
+
this.cachedDEK = null;
|
|
504
|
+
this.cachedAccessToken = null;
|
|
505
|
+
this.cachedJWTToken = null;
|
|
502
506
|
await Promise.all([
|
|
503
507
|
this.remove("USR"),
|
|
504
508
|
this.remove("DEK"),
|
|
505
509
|
this.remove("access_token"),
|
|
506
510
|
this.remove("jwt_token"),
|
|
507
511
|
]);
|
|
508
|
-
this.cachedUSR = null;
|
|
509
|
-
this.cachedDEK = null;
|
|
510
|
-
this.cachedAccessToken = null;
|
|
511
|
-
this.cachedJWTToken = null;
|
|
512
512
|
}
|
|
513
513
|
catch (error) {
|
|
514
514
|
this.errorHandler(error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ggez-banking-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "A Node.js package to handle GGEZ Banking API endpoints, Simplify the process of managing CRUD operations with this efficient and easy-to-use package.",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|