ggez-banking-sdk 0.3.31 → 0.4.2
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/account.d.ts +2 -3
- package/dist/account.js +2 -2
- package/dist/api/api.d.ts +37 -25
- package/dist/api/api.js +109 -89
- package/dist/api/{clients → client}/account.d.ts +6 -6
- package/dist/api/{clients → client}/account.js +8 -12
- package/dist/api/client/auth.d.ts +26 -0
- package/dist/api/client/auth.js +86 -0
- package/dist/api/client/base.d.ts +13 -0
- package/dist/api/client/base.js +15 -0
- package/dist/api/{clients → client}/blockchain.d.ts +8 -7
- package/dist/api/{clients → client}/blockchain.js +12 -16
- package/dist/api/{clients → client}/ipAddressAndLocation.d.ts +5 -4
- package/dist/api/client/ipAddressAndLocation.js +41 -0
- package/dist/api/{clients → client}/limited.d.ts +13 -12
- package/dist/api/{clients → client}/limited.js +22 -30
- package/dist/api/{clients → client}/order.d.ts +5 -4
- package/dist/api/{clients → client}/order.js +6 -10
- package/dist/api/{clients → client}/organization.d.ts +11 -9
- package/dist/api/{clients → client}/organization.js +18 -22
- package/dist/api/{clients → client}/program.d.ts +7 -6
- package/dist/api/{clients → client}/program.js +10 -21
- package/dist/api/{clients → client}/promotion.d.ts +8 -7
- package/dist/api/{clients → client}/promotion.js +10 -14
- package/dist/api/{clients → client}/transaction.d.ts +9 -8
- package/dist/api/{clients → client}/transaction.js +14 -18
- package/dist/api/{clients → client}/user.d.ts +199 -202
- package/dist/api/{clients → client}/user.js +157 -198
- package/dist/api/context/defaultClientContextProvider.d.ts +32 -0
- package/dist/api/context/defaultClientContextProvider.js +52 -0
- package/dist/api/context/index.d.ts +1 -0
- package/dist/api/context/index.js +1 -0
- package/dist/api/index.d.ts +4 -2
- package/dist/api/index.js +4 -2
- package/dist/api/proxy/account.d.ts +10 -0
- package/dist/api/proxy/account.js +17 -0
- package/dist/api/proxy/auth.d.ts +42 -0
- package/dist/api/proxy/auth.js +65 -0
- package/dist/api/proxy/base.d.ts +17 -0
- package/dist/api/proxy/base.js +32 -0
- package/dist/api/proxy/blockchain.d.ts +13 -0
- package/dist/api/proxy/blockchain.js +25 -0
- package/dist/api/proxy/index.d.ts +11 -0
- package/dist/api/proxy/index.js +11 -0
- package/dist/api/proxy/ipAddressAndLocation.d.ts +9 -0
- package/dist/api/proxy/ipAddressAndLocation.js +13 -0
- package/dist/api/proxy/limited.d.ts +25 -0
- package/dist/api/proxy/limited.js +54 -0
- package/dist/api/proxy/order.d.ts +10 -0
- package/dist/api/proxy/order.js +13 -0
- package/dist/api/proxy/organization.d.ts +14 -0
- package/dist/api/proxy/organization.js +29 -0
- package/dist/api/proxy/program.d.ts +11 -0
- package/dist/api/proxy/program.js +21 -0
- package/dist/api/proxy/promotion.d.ts +14 -0
- package/dist/api/proxy/promotion.js +21 -0
- package/dist/api/proxy/transaction.d.ts +12 -0
- package/dist/api/proxy/transaction.js +17 -0
- package/dist/api/proxy/user.d.ts +97 -0
- package/dist/api/proxy/user.js +306 -0
- package/dist/api/service/account.d.ts +11 -0
- package/dist/api/{services → service}/account.js +5 -10
- package/dist/api/{services → service}/auth.d.ts +3 -4
- package/dist/api/{services → service}/auth.js +4 -6
- package/dist/api/service/base.d.ts +26 -0
- package/dist/api/service/base.js +49 -0
- package/dist/api/service/blockchain.d.ts +12 -0
- package/dist/api/{services → service}/blockchain.js +8 -10
- package/dist/api/service/ipAddressAndLocation.d.ts +9 -0
- package/dist/api/{services → service}/ipAddressAndLocation.js +2 -4
- package/dist/api/service/limited.d.ts +14 -0
- package/dist/api/service/limited.js +34 -0
- package/dist/api/service/order.d.ts +9 -0
- package/dist/api/{services → service}/order.js +4 -9
- package/dist/api/service/organization.d.ts +13 -0
- package/dist/api/{services → service}/organization.js +12 -17
- package/dist/api/service/program.d.ts +12 -0
- package/dist/api/{services → service}/program.js +9 -13
- package/dist/api/service/promotion.d.ts +13 -0
- package/dist/api/{services → service}/promotion.js +6 -8
- package/dist/api/{services → service}/transaction.d.ts +4 -5
- package/dist/api/{services → service}/transaction.js +6 -11
- package/dist/api/service/user.d.ts +79 -0
- package/dist/api/service/user.js +284 -0
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +2 -2
- package/dist/blockchain.d.ts +2 -3
- package/dist/blockchain.js +2 -2
- package/dist/helper/geoHelper.d.ts +7 -4
- package/dist/ip-location.d.ts +2 -3
- package/dist/ip-location.js +2 -2
- package/dist/limited.d.ts +2 -3
- package/dist/limited.js +2 -2
- package/dist/order.d.ts +2 -3
- package/dist/order.js +2 -2
- package/dist/organization.d.ts +2 -3
- package/dist/organization.js +2 -2
- package/dist/program.d.ts +2 -3
- package/dist/program.js +2 -2
- package/dist/promotion.d.ts +2 -3
- package/dist/promotion.js +2 -2
- package/dist/transaction.d.ts +2 -3
- package/dist/transaction.js +2 -2
- package/dist/types/api/client/auth.d.ts +22 -8
- package/dist/types/api/client/clientData.d.ts +15 -5
- package/dist/types/api/client/index.d.ts +1 -11
- package/dist/types/api/context/clientContext.d.ts +23 -0
- package/dist/types/api/context/index.d.ts +1 -0
- package/dist/types/api/index.d.ts +2 -0
- package/dist/types/api/proxy/auth.d.ts +17 -0
- package/dist/types/api/proxy/index.d.ts +1 -0
- package/dist/types/api/service/auth.d.ts +1 -3
- package/dist/types/api/service/base.d.ts +3 -8
- package/dist/types/api/service/limited.d.ts +1 -3
- package/dist/types/api/service/program.d.ts +1 -3
- package/dist/user.d.ts +2 -3
- package/dist/user.js +2 -2
- package/package.json +2 -2
- package/dist/api/clients/auth.d.ts +0 -52
- package/dist/api/clients/auth.js +0 -69
- package/dist/api/clients/base.d.ts +0 -8
- package/dist/api/clients/base.js +0 -12
- package/dist/api/clients/ipAddressAndLocation.js +0 -42
- package/dist/api/services/account.d.ts +0 -12
- package/dist/api/services/base.d.ts +0 -18
- package/dist/api/services/base.js +0 -52
- package/dist/api/services/blockchain.d.ts +0 -12
- package/dist/api/services/ipAddressAndLocation.d.ts +0 -9
- package/dist/api/services/limited.d.ts +0 -14
- package/dist/api/services/limited.js +0 -54
- package/dist/api/services/order.d.ts +0 -9
- package/dist/api/services/organization.d.ts +0 -13
- package/dist/api/services/program.d.ts +0 -12
- package/dist/api/services/promotion.d.ts +0 -13
- package/dist/api/services/user.d.ts +0 -79
- package/dist/api/services/user.js +0 -286
- package/dist/types/api/client/account.d.ts +0 -8
- package/dist/types/api/client/blockchain.d.ts +0 -8
- package/dist/types/api/client/ipAddressAndLocation.d.ts +0 -8
- package/dist/types/api/client/limited.d.ts +0 -8
- package/dist/types/api/client/order.d.ts +0 -8
- package/dist/types/api/client/order.js +0 -1
- package/dist/types/api/client/organization.d.ts +0 -8
- package/dist/types/api/client/organization.js +0 -1
- package/dist/types/api/client/program.d.ts +0 -11
- package/dist/types/api/client/program.js +0 -1
- package/dist/types/api/client/promotion.d.ts +0 -8
- package/dist/types/api/client/promotion.js +0 -1
- package/dist/types/api/client/transaction.d.ts +0 -9
- package/dist/types/api/client/transaction.js +0 -1
- package/dist/types/api/client/user.d.ts +0 -8
- package/dist/types/api/client/user.js +0 -1
- /package/dist/api/{clients → client}/index.d.ts +0 -0
- /package/dist/api/{clients → client}/index.js +0 -0
- /package/dist/api/{services → service}/index.d.ts +0 -0
- /package/dist/api/{services → service}/index.js +0 -0
- /package/dist/types/api/{client/account.js → context/clientContext.js} +0 -0
- /package/dist/types/api/{client/blockchain.js → context/index.js} +0 -0
- /package/dist/types/api/{client/ipAddressAndLocation.js → proxy/auth.js} +0 -0
- /package/dist/types/api/{client/limited.js → proxy/index.js} +0 -0
package/dist/account.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { AccountClient } from "./api/
|
|
2
|
-
export { AccountService } from "./api/
|
|
1
|
+
export { AccountClient } from "./api/client/account";
|
|
2
|
+
export { AccountService } from "./api/service/account";
|
|
3
3
|
export * from "./api/data/account";
|
|
4
|
-
export type * from "./types/api/client/account";
|
|
5
4
|
export type * from "./types/api/data/account";
|
|
6
5
|
export type * from "./types/api/service/account";
|
package/dist/account.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Account-related exports - Complete account domain
|
|
2
|
-
export { AccountClient } from "./api/
|
|
3
|
-
export { AccountService } from "./api/
|
|
2
|
+
export { AccountClient } from "./api/client/account";
|
|
3
|
+
export { AccountService } from "./api/service/account";
|
|
4
4
|
// Account data exports
|
|
5
5
|
export * from "./api/data/account";
|
package/dist/api/api.d.ts
CHANGED
|
@@ -1,29 +1,41 @@
|
|
|
1
|
-
import { AccountClient, AuthClient, BlockchainClient,
|
|
1
|
+
import { AccountClient, AuthClient, BlockchainClient, IPAddressAndLocationClient, LimitedClient, OrderClient, OrganizationClient, ProgramClient, PromotionClient, TransactionClient, UserClient } from "./client";
|
|
2
|
+
import type { ClientData, ErrorHandler } from "../types";
|
|
3
|
+
import type { ClientContextProvider } from "../types/api/context/clientContext";
|
|
4
|
+
/**
|
|
5
|
+
* SDK entry point. Constructs the full dependency graph in one shot:
|
|
6
|
+
*
|
|
7
|
+
* ClientContext + CookiesHelper
|
|
8
|
+
* → Services (axios transport)
|
|
9
|
+
* → Proxies (read context to build per-call axios config; cross-entity
|
|
10
|
+
* orchestration like AuthProxy → UserProxy)
|
|
11
|
+
* → Clients (consumer-facing payload/response shaping)
|
|
12
|
+
*
|
|
13
|
+
* Consumers interact with `api.<client>` methods only. Credentials and
|
|
14
|
+
* language are mutated via the exposed `context` setters. Session
|
|
15
|
+
* invalidation (token expiry detection, device-credential refresh,
|
|
16
|
+
* redirect to login) is the consumer's responsibility — the SDK is
|
|
17
|
+
* stateless about session lifecycle.
|
|
18
|
+
*/
|
|
2
19
|
declare class API {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
private
|
|
20
|
+
readonly context: ClientContextProvider;
|
|
21
|
+
readonly account: AccountClient;
|
|
22
|
+
readonly auth: AuthClient;
|
|
23
|
+
readonly blockchain: BlockchainClient;
|
|
24
|
+
readonly ipAddress: IPAddressAndLocationClient;
|
|
25
|
+
readonly limited: LimitedClient;
|
|
26
|
+
readonly order: OrderClient;
|
|
27
|
+
readonly organization: OrganizationClient;
|
|
28
|
+
readonly program: ProgramClient;
|
|
29
|
+
readonly promotion: PromotionClient;
|
|
30
|
+
readonly transaction: TransactionClient;
|
|
31
|
+
readonly user: UserClient;
|
|
32
|
+
private readonly cookiesHelper;
|
|
33
|
+
private readonly authProxy;
|
|
16
34
|
constructor(clientData: ClientData, errorHandler: ErrorHandler);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
get order(): OrderClient;
|
|
23
|
-
get organization(): OrganizationClient;
|
|
24
|
-
get program(): ProgramClient;
|
|
25
|
-
get promotion(): PromotionClient;
|
|
26
|
-
get transaction(): TransactionClient;
|
|
27
|
-
get user(): UserClient;
|
|
35
|
+
/**
|
|
36
|
+
* Clear session state on explicit user logout: zero the in-memory
|
|
37
|
+
* context, then drop the cookies.
|
|
38
|
+
*/
|
|
39
|
+
logout(): Promise<void>;
|
|
28
40
|
}
|
|
29
41
|
export { API };
|
package/dist/api/api.js
CHANGED
|
@@ -1,95 +1,115 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosHelper } from "../helper/api/axiosHelper";
|
|
2
|
+
import { CookiesHelper } from "../helper/storage/cookiesHelper";
|
|
3
|
+
import { AccountClient, AuthClient, BlockchainClient, IPAddressAndLocationClient, LimitedClient, OrderClient, OrganizationClient, ProgramClient, PromotionClient, TransactionClient, UserClient, } from "./client";
|
|
4
|
+
import { AccountService, AuthService, BlockchainService, IPAddressAndLocationService, LimitedService, OrderService, OrganizationService, ProgramService, PromotionService, TransactionService, UserService, } from "./service";
|
|
5
|
+
import { AccountProxy, AuthProxy, BlockchainProxy, IPAddressAndLocationProxy, LimitedProxy, OrderProxy, OrganizationProxy, ProgramProxy, PromotionProxy, TransactionProxy, UserProxy, } from "./proxy";
|
|
6
|
+
import { DefaultClientContextProvider } from "./context";
|
|
7
|
+
/**
|
|
8
|
+
* SDK entry point. Constructs the full dependency graph in one shot:
|
|
9
|
+
*
|
|
10
|
+
* ClientContext + CookiesHelper
|
|
11
|
+
* → Services (axios transport)
|
|
12
|
+
* → Proxies (read context to build per-call axios config; cross-entity
|
|
13
|
+
* orchestration like AuthProxy → UserProxy)
|
|
14
|
+
* → Clients (consumer-facing payload/response shaping)
|
|
15
|
+
*
|
|
16
|
+
* Consumers interact with `api.<client>` methods only. Credentials and
|
|
17
|
+
* language are mutated via the exposed `context` setters. Session
|
|
18
|
+
* invalidation (token expiry detection, device-credential refresh,
|
|
19
|
+
* redirect to login) is the consumer's responsibility — the SDK is
|
|
20
|
+
* stateless about session lifecycle.
|
|
21
|
+
*/
|
|
2
22
|
class API {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// #endregion
|
|
18
|
-
// #region "Constructor"
|
|
23
|
+
context;
|
|
24
|
+
account;
|
|
25
|
+
auth;
|
|
26
|
+
blockchain;
|
|
27
|
+
ipAddress;
|
|
28
|
+
limited;
|
|
29
|
+
order;
|
|
30
|
+
organization;
|
|
31
|
+
program;
|
|
32
|
+
promotion;
|
|
33
|
+
transaction;
|
|
34
|
+
user;
|
|
35
|
+
cookiesHelper;
|
|
36
|
+
authProxy;
|
|
19
37
|
constructor(clientData, errorHandler) {
|
|
20
|
-
this.
|
|
21
|
-
|
|
38
|
+
this.context = new DefaultClientContextProvider({
|
|
39
|
+
baseUrl: clientData.baseUrl,
|
|
40
|
+
nodeUrl: clientData.nodeUrl,
|
|
41
|
+
programId: clientData.programId,
|
|
42
|
+
lang: clientData.lang,
|
|
43
|
+
installationId: clientData.installationId,
|
|
44
|
+
});
|
|
45
|
+
this.cookiesHelper = new CookiesHelper(String(clientData.programId), clientData.domain ?? "", errorHandler);
|
|
46
|
+
// axios baseURL is sticky per-instance, so we build one config per
|
|
47
|
+
// base-URL variant from clientData. Per-call headers (Authorization,
|
|
48
|
+
// Source_Id, Time_Zone) are written by the proxy layer at call time.
|
|
49
|
+
const authConfig = AxiosHelper.getAuthAxiosConfig(clientData.baseUrl, clientData.lang, "");
|
|
50
|
+
const sessionConfig = AxiosHelper.getAxiosConfig("", clientData.baseUrl, clientData.lang, clientData.installationId);
|
|
51
|
+
const promotionConfig = AxiosHelper.getAuthAxiosConfig(clientData.nodeUrl, clientData.lang, "");
|
|
52
|
+
const shared = { context: this.context };
|
|
53
|
+
const authService = new AuthService({ config: authConfig, ...shared });
|
|
54
|
+
const userService = new UserService({ config: sessionConfig, ...shared });
|
|
55
|
+
const accountService = new AccountService({ config: sessionConfig, ...shared });
|
|
56
|
+
const blockchainService = new BlockchainService({ config: sessionConfig, ...shared });
|
|
57
|
+
const ipAddressAndLocationService = new IPAddressAndLocationService({
|
|
58
|
+
config: sessionConfig,
|
|
59
|
+
...shared,
|
|
60
|
+
});
|
|
61
|
+
const limitedService = new LimitedService({ config: sessionConfig, ...shared });
|
|
62
|
+
const orderService = new OrderService({ config: sessionConfig, ...shared });
|
|
63
|
+
const organizationService = new OrganizationService({
|
|
64
|
+
config: sessionConfig,
|
|
65
|
+
...shared,
|
|
66
|
+
});
|
|
67
|
+
const programService = new ProgramService({ config: sessionConfig, ...shared });
|
|
68
|
+
const promotionService = new PromotionService({
|
|
69
|
+
config: promotionConfig,
|
|
70
|
+
...shared,
|
|
71
|
+
});
|
|
72
|
+
const transactionService = new TransactionService({
|
|
73
|
+
config: sessionConfig,
|
|
74
|
+
...shared,
|
|
75
|
+
});
|
|
76
|
+
// AuthProxy and UserProxy reference each other (α2 login → getUser).
|
|
77
|
+
// Build AuthProxy first, then UserProxy, then wire via setUserProxy.
|
|
78
|
+
// AuthProxy and LimitedProxy are pre-session (mint their own auth) and
|
|
79
|
+
// don't extend BaseProxy. Every other proxy takes context so it can
|
|
80
|
+
// build session-authenticated configs.
|
|
81
|
+
this.authProxy = new AuthProxy(authService, this.context, this.cookiesHelper);
|
|
82
|
+
const userProxy = new UserProxy(this.context, userService, this.authProxy);
|
|
83
|
+
this.authProxy.setUserProxy(userProxy);
|
|
84
|
+
const accountProxy = new AccountProxy(this.context, accountService);
|
|
85
|
+
const blockchainProxy = new BlockchainProxy(this.context, blockchainService);
|
|
86
|
+
const ipAddressAndLocationProxy = new IPAddressAndLocationProxy(this.context, ipAddressAndLocationService);
|
|
87
|
+
const limitedProxy = new LimitedProxy(limitedService, this.authProxy, this.context);
|
|
88
|
+
const orderProxy = new OrderProxy(this.context, orderService);
|
|
89
|
+
const organizationProxy = new OrganizationProxy(this.context, organizationService);
|
|
90
|
+
const programProxy = new ProgramProxy(this.context, programService);
|
|
91
|
+
const promotionProxy = new PromotionProxy(this.context, promotionService);
|
|
92
|
+
const transactionProxy = new TransactionProxy(this.context, transactionService);
|
|
93
|
+
this.auth = new AuthClient(this.authProxy, this.context, errorHandler);
|
|
94
|
+
this.user = new UserClient(userProxy, errorHandler);
|
|
95
|
+
this.account = new AccountClient(accountProxy, errorHandler);
|
|
96
|
+
this.blockchain = new BlockchainClient(blockchainProxy, errorHandler);
|
|
97
|
+
this.ipAddress = new IPAddressAndLocationClient(ipAddressAndLocationProxy, errorHandler);
|
|
98
|
+
this.limited = new LimitedClient(limitedProxy, errorHandler);
|
|
99
|
+
this.order = new OrderClient(orderProxy, errorHandler);
|
|
100
|
+
this.organization = new OrganizationClient(organizationProxy, this.context, errorHandler);
|
|
101
|
+
this.program = new ProgramClient(programProxy, errorHandler);
|
|
102
|
+
this.promotion = new PromotionClient(promotionProxy, errorHandler);
|
|
103
|
+
this.transaction = new TransactionClient(transactionProxy, errorHandler);
|
|
22
104
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
get auth() {
|
|
32
|
-
if (!this._auth) {
|
|
33
|
-
this._auth = new AuthClient(this.clientData, this.errorHandler);
|
|
34
|
-
}
|
|
35
|
-
return this._auth;
|
|
36
|
-
}
|
|
37
|
-
get blockchain() {
|
|
38
|
-
if (!this._blockchain) {
|
|
39
|
-
this._blockchain = new BlockchainClient(this.clientData, this.errorHandler);
|
|
40
|
-
}
|
|
41
|
-
return this._blockchain;
|
|
42
|
-
}
|
|
43
|
-
get ipAddress() {
|
|
44
|
-
if (!this._ipAddress) {
|
|
45
|
-
this._ipAddress = new IPAddressAndLocationClient(this.clientData, this.errorHandler);
|
|
46
|
-
}
|
|
47
|
-
return this._ipAddress;
|
|
48
|
-
}
|
|
49
|
-
get limited() {
|
|
50
|
-
if (!this._limited) {
|
|
51
|
-
this._limited = new LimitedClient(this.clientData, this.errorHandler);
|
|
52
|
-
}
|
|
53
|
-
return this._limited;
|
|
54
|
-
}
|
|
55
|
-
get order() {
|
|
56
|
-
if (!this._order) {
|
|
57
|
-
this._order = new OrderClient(this.clientData, this.errorHandler);
|
|
58
|
-
}
|
|
59
|
-
return this._order;
|
|
60
|
-
}
|
|
61
|
-
get organization() {
|
|
62
|
-
if (!this._organization) {
|
|
63
|
-
this._organization = new OrganizationClient(this.clientData, this.errorHandler);
|
|
64
|
-
}
|
|
65
|
-
return this._organization;
|
|
66
|
-
}
|
|
67
|
-
get program() {
|
|
68
|
-
if (!this._program) {
|
|
69
|
-
this._program = new ProgramClient(this.clientData, this.errorHandler);
|
|
70
|
-
}
|
|
71
|
-
return this._program;
|
|
72
|
-
}
|
|
73
|
-
get promotion() {
|
|
74
|
-
if (!this._promotion) {
|
|
75
|
-
this._promotion = new PromotionClient(this.clientData, this.errorHandler);
|
|
76
|
-
}
|
|
77
|
-
return this._promotion;
|
|
78
|
-
}
|
|
79
|
-
get transaction() {
|
|
80
|
-
if (!this._transaction) {
|
|
81
|
-
this._transaction = new TransactionClient(this.clientData, this.errorHandler);
|
|
82
|
-
}
|
|
83
|
-
return this._transaction;
|
|
84
|
-
}
|
|
85
|
-
get user() {
|
|
86
|
-
if (!this._user) {
|
|
87
|
-
this._user = new UserClient(this.clientData, this.errorHandler);
|
|
88
|
-
}
|
|
89
|
-
return this._user;
|
|
105
|
+
/**
|
|
106
|
+
* Clear session state on explicit user logout: zero the in-memory
|
|
107
|
+
* context, then drop the cookies.
|
|
108
|
+
*/
|
|
109
|
+
async logout() {
|
|
110
|
+
this.context.setToken("");
|
|
111
|
+
this.context.setUserId(0);
|
|
112
|
+
await this.cookiesHelper.clearCredentialCookies();
|
|
90
113
|
}
|
|
91
114
|
}
|
|
92
|
-
const api = new API({}, (error) => {
|
|
93
|
-
console.error("API Error:", error);
|
|
94
|
-
});
|
|
95
115
|
export { API };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ErrorHandler } from "../../types";
|
|
2
|
+
import type { AccountProxy } from "../proxy/account";
|
|
3
3
|
import { BaseClient } from "./base";
|
|
4
4
|
declare class AccountClient extends BaseClient {
|
|
5
|
-
private
|
|
6
|
-
constructor(
|
|
7
|
-
get: (accountId: number
|
|
5
|
+
private accountProxy;
|
|
6
|
+
constructor(accountProxy: AccountProxy, errorHandler: ErrorHandler);
|
|
7
|
+
get: (accountId: number) => Promise<{
|
|
8
8
|
data: import("../..").AccountData;
|
|
9
9
|
success: boolean;
|
|
10
10
|
message: string;
|
|
@@ -15,7 +15,7 @@ declare class AccountClient extends BaseClient {
|
|
|
15
15
|
message: string;
|
|
16
16
|
error: string;
|
|
17
17
|
}>;
|
|
18
|
-
getLimits: (accountId: number
|
|
18
|
+
getLimits: (accountId: number) => Promise<{
|
|
19
19
|
data: import("../..").AccountData;
|
|
20
20
|
success: boolean;
|
|
21
21
|
message: string;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { AxiosHelper } from "../../helper/api/axiosHelper";
|
|
2
1
|
import { createDefaultAccountData, fillResultByError } from "../data";
|
|
3
|
-
import { AccountService } from "../services";
|
|
4
2
|
import { BaseClient } from "./base";
|
|
5
3
|
class AccountClient extends BaseClient {
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
8
|
-
super(
|
|
9
|
-
|
|
10
|
-
const config = AxiosHelper.getAxiosConfig(token, baseUrl, lang, installationId);
|
|
11
|
-
this.accountService = new AccountService({ config, userId });
|
|
4
|
+
accountProxy;
|
|
5
|
+
constructor(accountProxy, errorHandler) {
|
|
6
|
+
super(errorHandler);
|
|
7
|
+
this.accountProxy = accountProxy;
|
|
12
8
|
}
|
|
13
9
|
// #region "GET"
|
|
14
|
-
get = async (accountId
|
|
10
|
+
get = async (accountId) => {
|
|
15
11
|
try {
|
|
16
|
-
const response = await this.
|
|
12
|
+
const response = await this.accountProxy.get(accountId);
|
|
17
13
|
return this.responseHelper.getResponse(response.data);
|
|
18
14
|
}
|
|
19
15
|
catch (error) {
|
|
@@ -22,9 +18,9 @@ class AccountClient extends BaseClient {
|
|
|
22
18
|
return this.responseHelper.getErrorResponse(accountData, "get");
|
|
23
19
|
}
|
|
24
20
|
};
|
|
25
|
-
getLimits = async (accountId
|
|
21
|
+
getLimits = async (accountId) => {
|
|
26
22
|
try {
|
|
27
|
-
const response = await this.
|
|
23
|
+
const response = await this.accountProxy.getLimits(accountId);
|
|
28
24
|
return this.responseHelper.getResponse(response.data);
|
|
29
25
|
}
|
|
30
26
|
catch (error) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ErrorHandler, IGenerateLimitedTokenData, ILoginDeviceCredentialsData, ILoginGoogleCredentialsData, ILoginUserCredentialsData, LoginClientResponse } from "../../types";
|
|
2
|
+
import type { ClientContextProvider } from "../../types/api/context/clientContext";
|
|
3
|
+
import type { AuthProxy } from "../proxy/auth";
|
|
4
|
+
import { BaseClient } from "./base";
|
|
5
|
+
declare class AuthClient extends BaseClient {
|
|
6
|
+
private authProxy;
|
|
7
|
+
private context;
|
|
8
|
+
constructor(authProxy: AuthProxy, context: ClientContextProvider, errorHandler: ErrorHandler);
|
|
9
|
+
loginUserCredentials: (data: ILoginUserCredentialsData) => Promise<LoginClientResponse>;
|
|
10
|
+
loginDeviceCredentials: (data: ILoginDeviceCredentialsData) => Promise<LoginClientResponse>;
|
|
11
|
+
loginGoogleCredentials: (data: ILoginGoogleCredentialsData) => Promise<LoginClientResponse>;
|
|
12
|
+
generateLimitedToken: (data: IGenerateLimitedTokenData) => Promise<{
|
|
13
|
+
data: import("../..").NodeTokenData;
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
error: null;
|
|
17
|
+
} | {
|
|
18
|
+
data: import("../..").TokenData;
|
|
19
|
+
success: boolean;
|
|
20
|
+
message: string;
|
|
21
|
+
error: string;
|
|
22
|
+
}>;
|
|
23
|
+
private shapeLoginResponse;
|
|
24
|
+
private shapeLoginError;
|
|
25
|
+
}
|
|
26
|
+
export { AuthClient };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { fillGenerateLimitedTokenData, fillLoginDeviceCredentialsData, fillLoginGoogleCredentialsData, fillLoginUserCredentialsData, fillResult, fillResultByError, createDefaultTokenData, } from "../data";
|
|
2
|
+
import { ResultHelper } from "../../helper/api/resultHelper";
|
|
3
|
+
import { BaseClient } from "./base";
|
|
4
|
+
class AuthClient extends BaseClient {
|
|
5
|
+
authProxy;
|
|
6
|
+
context;
|
|
7
|
+
constructor(authProxy, context, errorHandler) {
|
|
8
|
+
super(errorHandler);
|
|
9
|
+
this.authProxy = authProxy;
|
|
10
|
+
this.context = context;
|
|
11
|
+
}
|
|
12
|
+
// #region "POST"
|
|
13
|
+
loginUserCredentials = async (data) => {
|
|
14
|
+
try {
|
|
15
|
+
const credentials = fillLoginUserCredentialsData(this.context.getProgramId(), data);
|
|
16
|
+
const result = await this.authProxy.loginAndFetchUser(credentials);
|
|
17
|
+
return this.shapeLoginResponse(result);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return this.shapeLoginError(error, "loginUserCredentials");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
loginDeviceCredentials = async (data) => {
|
|
24
|
+
try {
|
|
25
|
+
const credentials = fillLoginDeviceCredentialsData(this.context.getProgramId(), data);
|
|
26
|
+
const result = await this.authProxy.loginAndFetchUser(credentials);
|
|
27
|
+
return this.shapeLoginResponse(result);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return this.shapeLoginError(error, "loginDeviceCredentials");
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
loginGoogleCredentials = async (data) => {
|
|
34
|
+
try {
|
|
35
|
+
const credentials = fillLoginGoogleCredentialsData(this.context.getProgramId(), data);
|
|
36
|
+
const result = await this.authProxy.loginAndFetchUser(credentials);
|
|
37
|
+
return this.shapeLoginResponse(result);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return this.shapeLoginError(error, "loginGoogleCredentials");
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
generateLimitedToken = async (data) => {
|
|
44
|
+
try {
|
|
45
|
+
const tokenData = fillGenerateLimitedTokenData(data);
|
|
46
|
+
const response = await this.authProxy.generateLimitedToken(tokenData);
|
|
47
|
+
response.data.result = fillResult(response.data);
|
|
48
|
+
return this.responseHelper.getResponse(response.data);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const result = fillResultByError(error);
|
|
52
|
+
const tokenData = createDefaultTokenData({ result });
|
|
53
|
+
return this.responseHelper.getErrorResponse(tokenData, "generateLimitedToken");
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// #endregion
|
|
57
|
+
shapeLoginResponse(result) {
|
|
58
|
+
const tokenBody = result.tokenData.data;
|
|
59
|
+
tokenBody.result = fillResult(tokenBody);
|
|
60
|
+
const success = ResultHelper.isApproved(tokenBody.result);
|
|
61
|
+
return {
|
|
62
|
+
data: {
|
|
63
|
+
tokenData: tokenBody,
|
|
64
|
+
userData: result.userData ? result.userData.data : null,
|
|
65
|
+
},
|
|
66
|
+
success,
|
|
67
|
+
message: tokenBody.result.message,
|
|
68
|
+
error: null,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
shapeLoginError(error, functionName) {
|
|
72
|
+
const result = fillResultByError(error);
|
|
73
|
+
const tokenData = createDefaultTokenData({ result });
|
|
74
|
+
this.errorHandler(`${result.message}, ${functionName}`);
|
|
75
|
+
return {
|
|
76
|
+
data: {
|
|
77
|
+
tokenData,
|
|
78
|
+
userData: null,
|
|
79
|
+
},
|
|
80
|
+
success: false,
|
|
81
|
+
message: result.message,
|
|
82
|
+
error: result.message,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export { AuthClient };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ResponseHelper } from "../../helper/api/responseHelper";
|
|
2
|
+
import type { ErrorHandler } from "../../types";
|
|
3
|
+
/**
|
|
4
|
+
* BaseClient is the consumer-facing layer. It no longer holds transport
|
|
5
|
+
* state — Services own axios, Proxies own orchestration, Clients only shape
|
|
6
|
+
* payloads (via fillX) and responses (via ResponseHelper).
|
|
7
|
+
*/
|
|
8
|
+
declare abstract class BaseClient {
|
|
9
|
+
protected errorHandler: ErrorHandler;
|
|
10
|
+
protected responseHelper: ResponseHelper;
|
|
11
|
+
constructor(errorHandler: ErrorHandler);
|
|
12
|
+
}
|
|
13
|
+
export { BaseClient };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ResponseHelper } from "../../helper/api/responseHelper";
|
|
2
|
+
/**
|
|
3
|
+
* BaseClient is the consumer-facing layer. It no longer holds transport
|
|
4
|
+
* state — Services own axios, Proxies own orchestration, Clients only shape
|
|
5
|
+
* payloads (via fillX) and responses (via ResponseHelper).
|
|
6
|
+
*/
|
|
7
|
+
class BaseClient {
|
|
8
|
+
errorHandler;
|
|
9
|
+
responseHelper;
|
|
10
|
+
constructor(errorHandler) {
|
|
11
|
+
this.errorHandler = errorHandler;
|
|
12
|
+
this.responseHelper = new ResponseHelper(errorHandler);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export { BaseClient };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ErrorHandler, IBlockchainDelegateRequestData, IBlockchainMultiSendRequestData, IBlockchainSendRequestData, IBlockchainUndelegateRequestData } from "../../types";
|
|
2
|
+
import type { BlockchainProxy } from "../proxy/blockchain";
|
|
2
3
|
import { BaseClient } from "./base";
|
|
3
4
|
declare class BlockchainClient extends BaseClient {
|
|
4
|
-
private
|
|
5
|
-
constructor(
|
|
6
|
-
send: (data: IBlockchainSendRequestData
|
|
5
|
+
private blockchainProxy;
|
|
6
|
+
constructor(blockchainProxy: BlockchainProxy, errorHandler: ErrorHandler);
|
|
7
|
+
send: (data: IBlockchainSendRequestData) => Promise<{
|
|
7
8
|
data: import("../..").BlockchainData;
|
|
8
9
|
success: boolean;
|
|
9
10
|
message: string;
|
|
@@ -14,7 +15,7 @@ declare class BlockchainClient extends BaseClient {
|
|
|
14
15
|
message: string;
|
|
15
16
|
error: string;
|
|
16
17
|
}>;
|
|
17
|
-
multiSend: (data: IBlockchainMultiSendRequestData
|
|
18
|
+
multiSend: (data: IBlockchainMultiSendRequestData) => Promise<{
|
|
18
19
|
data: import("../..").BlockchainData;
|
|
19
20
|
success: boolean;
|
|
20
21
|
message: string;
|
|
@@ -25,7 +26,7 @@ declare class BlockchainClient extends BaseClient {
|
|
|
25
26
|
message: string;
|
|
26
27
|
error: string;
|
|
27
28
|
}>;
|
|
28
|
-
delegate: (data: IBlockchainDelegateRequestData
|
|
29
|
+
delegate: (data: IBlockchainDelegateRequestData) => Promise<{
|
|
29
30
|
data: import("../..").BlockchainData;
|
|
30
31
|
success: boolean;
|
|
31
32
|
message: string;
|
|
@@ -36,7 +37,7 @@ declare class BlockchainClient extends BaseClient {
|
|
|
36
37
|
message: string;
|
|
37
38
|
error: string;
|
|
38
39
|
}>;
|
|
39
|
-
undelegate: (data: IBlockchainUndelegateRequestData
|
|
40
|
+
undelegate: (data: IBlockchainUndelegateRequestData) => Promise<{
|
|
40
41
|
data: import("../..").BlockchainData;
|
|
41
42
|
success: boolean;
|
|
42
43
|
message: string;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { AxiosHelper } from "../../helper/api/axiosHelper";
|
|
2
1
|
import { createDefaultBlockchainData, fillBlockchainDelegateData, fillBlockchainMultiSendData, fillBlockchainSendData, fillBlockchainUndelegateData, fillResultByError, } from "../data";
|
|
3
|
-
import { BlockchainService } from "../services";
|
|
4
2
|
import { BaseClient } from "./base";
|
|
5
3
|
class BlockchainClient extends BaseClient {
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
8
|
-
super(
|
|
9
|
-
|
|
10
|
-
const config = AxiosHelper.getAxiosConfig(token, baseUrl, lang, installationId);
|
|
11
|
-
this.blockchainService = new BlockchainService({ config, userId });
|
|
4
|
+
blockchainProxy;
|
|
5
|
+
constructor(blockchainProxy, errorHandler) {
|
|
6
|
+
super(errorHandler);
|
|
7
|
+
this.blockchainProxy = blockchainProxy;
|
|
12
8
|
}
|
|
13
9
|
// #region "POST"
|
|
14
|
-
send = async (data
|
|
10
|
+
send = async (data) => {
|
|
15
11
|
try {
|
|
16
12
|
const blockchainSendData = fillBlockchainSendData(data);
|
|
17
|
-
const response = await this.
|
|
13
|
+
const response = await this.blockchainProxy.send(blockchainSendData);
|
|
18
14
|
return this.responseHelper.getResponse(response.data);
|
|
19
15
|
}
|
|
20
16
|
catch (error) {
|
|
@@ -23,10 +19,10 @@ class BlockchainClient extends BaseClient {
|
|
|
23
19
|
return this.responseHelper.getErrorResponse(blockchainData, "send");
|
|
24
20
|
}
|
|
25
21
|
};
|
|
26
|
-
multiSend = async (data
|
|
22
|
+
multiSend = async (data) => {
|
|
27
23
|
try {
|
|
28
24
|
const blockchainMultiSendData = fillBlockchainMultiSendData(data);
|
|
29
|
-
const response = await this.
|
|
25
|
+
const response = await this.blockchainProxy.multiSend(blockchainMultiSendData);
|
|
30
26
|
return this.responseHelper.getResponse(response.data);
|
|
31
27
|
}
|
|
32
28
|
catch (error) {
|
|
@@ -35,10 +31,10 @@ class BlockchainClient extends BaseClient {
|
|
|
35
31
|
return this.responseHelper.getErrorResponse(blockchainData, "multiSend");
|
|
36
32
|
}
|
|
37
33
|
};
|
|
38
|
-
delegate = async (data
|
|
34
|
+
delegate = async (data) => {
|
|
39
35
|
try {
|
|
40
36
|
const blockchainDelegateData = fillBlockchainDelegateData(data);
|
|
41
|
-
const response = await this.
|
|
37
|
+
const response = await this.blockchainProxy.delegate(blockchainDelegateData);
|
|
42
38
|
return this.responseHelper.getResponse(response.data);
|
|
43
39
|
}
|
|
44
40
|
catch (error) {
|
|
@@ -47,10 +43,10 @@ class BlockchainClient extends BaseClient {
|
|
|
47
43
|
return this.responseHelper.getErrorResponse(blockchainData, "delegate");
|
|
48
44
|
}
|
|
49
45
|
};
|
|
50
|
-
undelegate = async (data
|
|
46
|
+
undelegate = async (data) => {
|
|
51
47
|
try {
|
|
52
48
|
const blockchainUndelegateData = fillBlockchainUndelegateData(data);
|
|
53
|
-
const response = await this.
|
|
49
|
+
const response = await this.blockchainProxy.undelegate(blockchainUndelegateData);
|
|
54
50
|
return this.responseHelper.getResponse(response.data);
|
|
55
51
|
}
|
|
56
52
|
catch (error) {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { ErrorHandler
|
|
1
|
+
import type { ErrorHandler } from "../../types";
|
|
2
|
+
import type { IPAddressAndLocationProxy } from "../proxy/ipAddressAndLocation";
|
|
2
3
|
import { BaseClient } from "./base";
|
|
3
4
|
declare class IPAddressAndLocationClient extends BaseClient {
|
|
4
|
-
private
|
|
5
|
-
constructor(
|
|
5
|
+
private ipAddressAndLocationProxy;
|
|
6
|
+
constructor(ipAddressAndLocationProxy: IPAddressAndLocationProxy, errorHandler: ErrorHandler);
|
|
6
7
|
getGeoCoordinates: () => Promise<import("../..").GeoCoordinates> | {
|
|
7
8
|
latitude: number;
|
|
8
9
|
longitude: number;
|
|
9
10
|
position_description: string;
|
|
10
11
|
};
|
|
11
|
-
getIPAddress: () => Promise<string
|
|
12
|
+
getIPAddress: () => "" | Promise<string>;
|
|
12
13
|
getGeoCoordinatesAndIPAddress: () => Promise<{
|
|
13
14
|
geo_coordinates: import("../..").GeoCoordinates;
|
|
14
15
|
ip_address: string;
|