ggez-banking-sdk 0.4.3 → 0.4.5
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 +1 -1
- package/dist/account.js +1 -1
- package/dist/api/api.d.ts +12 -32
- package/dist/api/api.js +13 -81
- package/dist/api/index.d.ts +1 -2
- package/dist/api/index.js +1 -2
- package/dist/api/proxy/account.d.ts +4 -4
- package/dist/api/proxy/account.js +11 -11
- package/dist/api/proxy/auth.d.ts +9 -34
- package/dist/api/proxy/auth.js +24 -52
- package/dist/api/proxy/base.d.ts +3 -14
- package/dist/api/proxy/base.js +3 -28
- package/dist/api/proxy/blockchain.d.ts +6 -7
- package/dist/api/proxy/blockchain.js +18 -19
- package/dist/api/proxy/ipAddressAndLocation.d.ts +8 -3
- package/dist/api/proxy/ipAddressAndLocation.js +21 -7
- package/dist/api/proxy/limited.d.ts +13 -21
- package/dist/api/proxy/limited.js +36 -51
- package/dist/api/proxy/order.d.ts +3 -4
- package/dist/api/proxy/order.js +9 -7
- package/dist/api/proxy/organization.d.ts +9 -8
- package/dist/api/proxy/organization.js +29 -23
- package/dist/api/proxy/program.d.ts +5 -5
- package/dist/api/proxy/program.js +7 -15
- package/dist/api/proxy/promotion.d.ts +5 -6
- package/dist/api/proxy/promotion.js +16 -15
- package/dist/api/proxy/transaction.d.ts +7 -6
- package/dist/api/proxy/transaction.js +23 -11
- package/dist/api/proxy/user.d.ts +80 -91
- package/dist/api/proxy/user.js +81 -293
- package/dist/api/service/account.d.ts +2 -3
- package/dist/api/service/account.js +4 -6
- package/dist/api/service/auth.d.ts +2 -3
- package/dist/api/service/auth.js +4 -4
- package/dist/api/service/base.d.ts +15 -17
- package/dist/api/service/base.js +34 -21
- package/dist/api/service/blockchain.d.ts +4 -5
- package/dist/api/service/blockchain.js +8 -8
- package/dist/api/service/ipAddressAndLocation.d.ts +1 -2
- package/dist/api/service/ipAddressAndLocation.js +2 -2
- package/dist/api/service/limited.d.ts +6 -7
- package/dist/api/service/limited.js +12 -12
- package/dist/api/service/order.d.ts +1 -2
- package/dist/api/service/order.js +2 -2
- package/dist/api/service/organization.d.ts +5 -6
- package/dist/api/service/organization.js +10 -10
- package/dist/api/service/program.d.ts +3 -4
- package/dist/api/service/program.js +6 -6
- package/dist/api/service/promotion.d.ts +3 -4
- package/dist/api/service/promotion.js +6 -6
- package/dist/api/service/transaction.d.ts +2 -3
- package/dist/api/service/transaction.js +4 -4
- package/dist/api/service/user.d.ts +64 -65
- package/dist/api/service/user.js +128 -128
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +1 -1
- package/dist/blockchain.d.ts +1 -1
- package/dist/blockchain.js +1 -1
- package/dist/helper/api/axiosHelper.d.ts +2 -2
- package/dist/helper/api/axiosHelper.js +20 -3
- package/dist/helper/api/responseHelper.d.ts +4 -7
- package/dist/helper/api/responseHelper.js +6 -9
- package/dist/helper/api/resultHelper.js +4 -0
- package/dist/ip-location.d.ts +1 -1
- package/dist/ip-location.js +1 -1
- package/dist/limited.d.ts +1 -1
- package/dist/limited.js +1 -1
- package/dist/order.d.ts +1 -1
- package/dist/order.js +1 -1
- package/dist/organization.d.ts +1 -1
- package/dist/organization.js +1 -1
- package/dist/program.d.ts +1 -1
- package/dist/program.js +1 -1
- package/dist/promotion.d.ts +1 -1
- package/dist/promotion.js +1 -1
- package/dist/transaction.d.ts +1 -1
- package/dist/transaction.js +1 -1
- package/dist/types/api/client/auth.d.ts +6 -12
- package/dist/types/api/index.d.ts +0 -1
- package/dist/types/api/service/base.d.ts +1 -2
- package/dist/types/helper/api/axiosHelper.d.ts +3 -1
- package/dist/types/helper/api/requestBuilder.d.ts +4 -0
- package/dist/types/helper/index.d.ts +1 -0
- package/dist/user.d.ts +1 -1
- package/dist/user.js +1 -1
- package/package.json +1 -1
- package/dist/api/client/account.d.ts +0 -30
- package/dist/api/client/account.js +0 -33
- package/dist/api/client/auth.d.ts +0 -26
- package/dist/api/client/auth.js +0 -86
- package/dist/api/client/base.d.ts +0 -13
- package/dist/api/client/base.js +0 -15
- package/dist/api/client/blockchain.d.ts +0 -52
- package/dist/api/client/blockchain.js +0 -59
- package/dist/api/client/index.d.ts +0 -11
- package/dist/api/client/index.js +0 -11
- package/dist/api/client/ipAddressAndLocation.d.ts +0 -24
- package/dist/api/client/ipAddressAndLocation.js +0 -41
- package/dist/api/client/limited.d.ts +0 -107
- package/dist/api/client/limited.js +0 -123
- package/dist/api/client/order.d.ts +0 -19
- package/dist/api/client/order.js +0 -23
- package/dist/api/client/organization.d.ts +0 -66
- package/dist/api/client/organization.js +0 -78
- package/dist/api/client/program.d.ts +0 -41
- package/dist/api/client/program.js +0 -44
- package/dist/api/client/promotion.d.ts +0 -43
- package/dist/api/client/promotion.js +0 -54
- package/dist/api/client/transaction.d.ts +0 -63
- package/dist/api/client/transaction.js +0 -73
- package/dist/api/client/user.d.ts +0 -846
- package/dist/api/client/user.js +0 -902
- package/dist/types/api/proxy/auth.d.ts +0 -17
- package/dist/types/api/proxy/index.d.ts +0 -1
- package/dist/types/api/proxy/index.js +0 -1
- /package/dist/types/{api/proxy/auth.js → helper/api/requestBuilder.js} +0 -0
package/dist/account.d.ts
CHANGED
package/dist/account.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Account-related exports - Complete account domain
|
|
2
|
-
export {
|
|
2
|
+
export { AccountProxy } from "./api/proxy/account";
|
|
3
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,41 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AccountProxy, AuthProxy, BlockchainProxy, IPAddressAndLocationProxy, LimitedProxy, OrderProxy, OrganizationProxy, ProgramProxy, PromotionProxy, TransactionProxy, UserProxy } from "./proxy";
|
|
2
2
|
import type { ClientData, ErrorHandler } from "../types";
|
|
3
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
|
-
*/
|
|
19
4
|
declare class API {
|
|
20
5
|
readonly context: ClientContextProvider;
|
|
21
|
-
readonly account:
|
|
22
|
-
readonly auth:
|
|
23
|
-
readonly blockchain:
|
|
24
|
-
readonly ipAddress:
|
|
25
|
-
readonly limited:
|
|
26
|
-
readonly order:
|
|
27
|
-
readonly organization:
|
|
28
|
-
readonly program:
|
|
29
|
-
readonly promotion:
|
|
30
|
-
readonly transaction:
|
|
31
|
-
readonly user:
|
|
6
|
+
readonly account: AccountProxy;
|
|
7
|
+
readonly auth: AuthProxy;
|
|
8
|
+
readonly blockchain: BlockchainProxy;
|
|
9
|
+
readonly ipAddress: IPAddressAndLocationProxy;
|
|
10
|
+
readonly limited: LimitedProxy;
|
|
11
|
+
readonly order: OrderProxy;
|
|
12
|
+
readonly organization: OrganizationProxy;
|
|
13
|
+
readonly program: ProgramProxy;
|
|
14
|
+
readonly promotion: PromotionProxy;
|
|
15
|
+
readonly transaction: TransactionProxy;
|
|
16
|
+
readonly user: UserProxy;
|
|
32
17
|
private readonly cookiesHelper;
|
|
33
|
-
private readonly authProxy;
|
|
34
18
|
constructor(clientData: ClientData, errorHandler: ErrorHandler);
|
|
35
|
-
/**
|
|
36
|
-
* Clear session state on explicit user logout: zero the in-memory
|
|
37
|
-
* context, then drop the cookies.
|
|
38
|
-
*/
|
|
39
19
|
logout(): Promise<void>;
|
|
40
20
|
}
|
|
41
21
|
export { API };
|
package/dist/api/api.js
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
import { AxiosHelper } from "../helper/api/axiosHelper";
|
|
2
1
|
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
2
|
import { AccountProxy, AuthProxy, BlockchainProxy, IPAddressAndLocationProxy, LimitedProxy, OrderProxy, OrganizationProxy, ProgramProxy, PromotionProxy, TransactionProxy, UserProxy, } from "./proxy";
|
|
3
|
+
import { AuthService } from "./service";
|
|
6
4
|
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
|
-
*/
|
|
22
5
|
class API {
|
|
23
6
|
context;
|
|
24
7
|
account;
|
|
@@ -33,7 +16,6 @@ class API {
|
|
|
33
16
|
transaction;
|
|
34
17
|
user;
|
|
35
18
|
cookiesHelper;
|
|
36
|
-
authProxy;
|
|
37
19
|
constructor(clientData, errorHandler) {
|
|
38
20
|
this.context = new DefaultClientContextProvider({
|
|
39
21
|
baseUrl: clientData.baseUrl,
|
|
@@ -43,69 +25,19 @@ class API {
|
|
|
43
25
|
installationId: clientData.installationId,
|
|
44
26
|
});
|
|
45
27
|
this.cookiesHelper = new CookiesHelper(String(clientData.programId), clientData.domain ?? "", errorHandler);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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);
|
|
28
|
+
const authService = new AuthService({ context: this.context, errorHandler });
|
|
29
|
+
this.auth = new AuthProxy(this.context, authService, this.cookiesHelper);
|
|
30
|
+
this.account = new AccountProxy(this.context, errorHandler);
|
|
31
|
+
this.blockchain = new BlockchainProxy(this.context, errorHandler);
|
|
32
|
+
this.order = new OrderProxy(this.context, errorHandler);
|
|
33
|
+
this.limited = new LimitedProxy(this.context, errorHandler);
|
|
34
|
+
this.organization = new OrganizationProxy(this.context, errorHandler);
|
|
35
|
+
this.program = new ProgramProxy(this.context, errorHandler);
|
|
36
|
+
this.promotion = new PromotionProxy(this.context, errorHandler);
|
|
37
|
+
this.ipAddress = new IPAddressAndLocationProxy(this.context, errorHandler);
|
|
38
|
+
this.transaction = new TransactionProxy(this.context, errorHandler);
|
|
39
|
+
this.user = new UserProxy(this.context, errorHandler);
|
|
104
40
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Clear session state on explicit user logout: zero the in-memory
|
|
107
|
-
* context, then drop the cookies.
|
|
108
|
-
*/
|
|
109
41
|
async logout() {
|
|
110
42
|
this.context.setToken("");
|
|
111
43
|
this.context.setUserId(0);
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ErrorHandler } from "../../types";
|
|
2
2
|
import type { ClientContextProvider } from "../../types/api/context/clientContext";
|
|
3
3
|
import { BaseProxy } from "./base";
|
|
4
4
|
declare class AccountProxy extends BaseProxy {
|
|
5
5
|
private accountService;
|
|
6
|
-
constructor(context: ClientContextProvider,
|
|
7
|
-
get(accountId: number)
|
|
8
|
-
getLimits(accountId: number)
|
|
6
|
+
constructor(context: ClientContextProvider, errorHandler: ErrorHandler);
|
|
7
|
+
get: (accountId: number) => Promise<import("axios").AxiosResponse<import("../..").AccountData, any, {}>>;
|
|
8
|
+
getLimits: (accountId: number) => Promise<import("axios").AxiosResponse<import("../..").AccountData, any, {}>>;
|
|
9
9
|
}
|
|
10
10
|
export { AccountProxy };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { AccountService } from "../service/account";
|
|
1
2
|
import { BaseProxy } from "./base";
|
|
2
3
|
class AccountProxy extends BaseProxy {
|
|
3
4
|
accountService;
|
|
4
|
-
constructor(context,
|
|
5
|
-
super(
|
|
6
|
-
this.accountService =
|
|
7
|
-
}
|
|
8
|
-
async get(accountId) {
|
|
9
|
-
const config = this.buildSessionConfig();
|
|
10
|
-
return this.accountService.get(accountId, config);
|
|
11
|
-
}
|
|
12
|
-
async getLimits(accountId) {
|
|
13
|
-
const config = this.buildSessionConfig();
|
|
14
|
-
return this.accountService.getLimits(accountId, config);
|
|
5
|
+
constructor(context, errorHandler) {
|
|
6
|
+
super(errorHandler);
|
|
7
|
+
this.accountService = new AccountService({ context, errorHandler });
|
|
15
8
|
}
|
|
9
|
+
// #region "GET"
|
|
10
|
+
get = async (accountId) => {
|
|
11
|
+
return this.accountService.get(accountId);
|
|
12
|
+
};
|
|
13
|
+
getLimits = async (accountId) => {
|
|
14
|
+
return this.accountService.getLimits(accountId);
|
|
15
|
+
};
|
|
16
16
|
}
|
|
17
17
|
export { AccountProxy };
|
package/dist/api/proxy/auth.d.ts
CHANGED
|
@@ -1,42 +1,17 @@
|
|
|
1
|
-
import type { AxiosResponse } from "axios";
|
|
2
1
|
import type { AuthService } from "../service/auth";
|
|
3
|
-
import type { UserProxy } from "./user";
|
|
4
2
|
import type { ClientContextProvider } from "../../types/api/context/clientContext";
|
|
5
3
|
import type { IGenerateLimitedTokenData } from "../../types/api/data/auth";
|
|
6
|
-
import type {
|
|
7
|
-
import
|
|
8
|
-
import type { CookiesHelper } from "../../helper/storage/cookiesHelper";
|
|
9
|
-
/**
|
|
10
|
-
* AuthProxy owns the post-login cross-entity orchestration (α2): after a
|
|
11
|
-
* successful credential exchange it updates the context with the new session
|
|
12
|
-
* token + user id, then asks UserProxy for the user record. The result is
|
|
13
|
-
* fused into a single `LoginResult` so the Client can shape one response.
|
|
14
|
-
*
|
|
15
|
-
* `userProxy` is wired via `setUserProxy` after construction — AuthProxy and
|
|
16
|
-
* UserProxy reference each other and cannot both be constructor-injected.
|
|
17
|
-
*/
|
|
4
|
+
import type { ILoginDeviceCredentialsData, ILoginGoogleCredentialsData, ILoginUserCredentialsData } from "../../types";
|
|
5
|
+
import { CookiesHelper } from "../../helper/storage/cookiesHelper";
|
|
18
6
|
declare class AuthProxy {
|
|
19
|
-
private authService;
|
|
20
7
|
private context;
|
|
8
|
+
private authService;
|
|
21
9
|
private cookiesHelper;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* user fetch would slow every retry for no consumer benefit.
|
|
29
|
-
*/
|
|
30
|
-
login(data: string, config?: AxiosRequestConfig): Promise<AxiosResponse<import("../..").TokenData, any, {}>>;
|
|
31
|
-
/**
|
|
32
|
-
* Credential exchange fused with a post-login user fetch. Used by the
|
|
33
|
-
* Client's three initial-login entry points (user, device, google).
|
|
34
|
-
*
|
|
35
|
-
* On rare race (another login invalidates the just-minted token before
|
|
36
|
-
* getUser lands) userData is `null`; the next user-scoped call self-heals
|
|
37
|
-
* through the refresh interceptor.
|
|
38
|
-
*/
|
|
39
|
-
loginAndFetchUser(data: string, config?: AxiosRequestConfig): Promise<LoginResult>;
|
|
40
|
-
generateLimitedToken(data: IGenerateLimitedTokenData, config?: AxiosRequestConfig): Promise<AxiosResponse<import("../..").NodeTokenData, any, {}>>;
|
|
10
|
+
constructor(context: ClientContextProvider, authService: AuthService, cookiesHelper: CookiesHelper);
|
|
11
|
+
private login;
|
|
12
|
+
loginUserCredentials(data: ILoginUserCredentialsData): Promise<import("axios").AxiosResponse<import("../..").TokenData, any, {}>>;
|
|
13
|
+
loginDeviceCredentials(data: ILoginDeviceCredentialsData): Promise<import("axios").AxiosResponse<import("../..").TokenData, any, {}>>;
|
|
14
|
+
loginGoogleCredentials(data: ILoginGoogleCredentialsData): Promise<import("axios").AxiosResponse<import("../..").TokenData, any, {}>>;
|
|
15
|
+
generateLimitedToken(data: IGenerateLimitedTokenData): Promise<import("axios").AxiosResponse<import("../..").NodeTokenData, any, {}>>;
|
|
41
16
|
}
|
|
42
17
|
export { AuthProxy };
|
package/dist/api/proxy/auth.js
CHANGED
|
@@ -1,65 +1,37 @@
|
|
|
1
1
|
import { ResultHelper } from "../../helper/api/resultHelper";
|
|
2
|
-
|
|
3
|
-
* AuthProxy owns the post-login cross-entity orchestration (α2): after a
|
|
4
|
-
* successful credential exchange it updates the context with the new session
|
|
5
|
-
* token + user id, then asks UserProxy for the user record. The result is
|
|
6
|
-
* fused into a single `LoginResult` so the Client can shape one response.
|
|
7
|
-
*
|
|
8
|
-
* `userProxy` is wired via `setUserProxy` after construction — AuthProxy and
|
|
9
|
-
* UserProxy reference each other and cannot both be constructor-injected.
|
|
10
|
-
*/
|
|
2
|
+
import { fillLoginDeviceCredentialsData, fillLoginGoogleCredentialsData, fillLoginUserCredentialsData, } from "../data";
|
|
11
3
|
class AuthProxy {
|
|
12
|
-
authService;
|
|
13
4
|
context;
|
|
5
|
+
authService;
|
|
14
6
|
cookiesHelper;
|
|
15
|
-
|
|
16
|
-
constructor(authService, context, cookiesHelper) {
|
|
17
|
-
this.authService = authService;
|
|
7
|
+
constructor(context, authService, cookiesHelper) {
|
|
18
8
|
this.context = context;
|
|
9
|
+
this.authService = authService;
|
|
19
10
|
this.cookiesHelper = cookiesHelper;
|
|
20
11
|
}
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
async login(data) {
|
|
13
|
+
const response = await this.authService.login(data);
|
|
14
|
+
if (ResultHelper.isApproved(response?.data?.result)) {
|
|
15
|
+
this.context.setToken(response.data.access_token);
|
|
16
|
+
this.context.setUserId(Number(response.data.user_id));
|
|
17
|
+
await this.cookiesHelper.setCredentialCookiesByTokenData(response.data);
|
|
18
|
+
}
|
|
19
|
+
return response;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* user fetch would slow every retry for no consumer benefit.
|
|
28
|
-
*/
|
|
29
|
-
login(data, config) {
|
|
30
|
-
return this.authService.login(data, config);
|
|
21
|
+
loginUserCredentials(data) {
|
|
22
|
+
const credentials = fillLoginUserCredentialsData(this.context.getProgramId(), data);
|
|
23
|
+
return this.login(credentials);
|
|
31
24
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*/
|
|
40
|
-
async loginAndFetchUser(data, config) {
|
|
41
|
-
const tokenResp = await this.authService.login(data, config);
|
|
42
|
-
if (!ResultHelper.isApproved(tokenResp.data.result)) {
|
|
43
|
-
return { tokenData: tokenResp, userData: null };
|
|
44
|
-
}
|
|
45
|
-
this.context.setToken(tokenResp.data.access_token);
|
|
46
|
-
this.context.setUserId(Number(tokenResp.data.user_id));
|
|
47
|
-
await this.cookiesHelper.setCredentialCookiesByTokenData(tokenResp.data);
|
|
48
|
-
let userData = null;
|
|
49
|
-
try {
|
|
50
|
-
if (!this.userProxy) {
|
|
51
|
-
throw new Error("AuthProxy.userProxy not wired");
|
|
52
|
-
}
|
|
53
|
-
const userResp = await this.userProxy.getUser();
|
|
54
|
-
userData = ResultHelper.isApproved(userResp.data.result) ? userResp : null;
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
userData = null;
|
|
58
|
-
}
|
|
59
|
-
return { tokenData: tokenResp, userData };
|
|
25
|
+
loginDeviceCredentials(data) {
|
|
26
|
+
const credentials = fillLoginDeviceCredentialsData(this.context.getProgramId(), data);
|
|
27
|
+
return this.login(credentials);
|
|
28
|
+
}
|
|
29
|
+
loginGoogleCredentials(data) {
|
|
30
|
+
const credentials = fillLoginGoogleCredentialsData(this.context.getProgramId(), data);
|
|
31
|
+
return this.login(credentials);
|
|
60
32
|
}
|
|
61
|
-
generateLimitedToken(data
|
|
62
|
-
return this.authService.generateLimitedToken(data
|
|
33
|
+
generateLimitedToken(data) {
|
|
34
|
+
return this.authService.generateLimitedToken(data);
|
|
63
35
|
}
|
|
64
36
|
}
|
|
65
37
|
export { AuthProxy };
|
package/dist/api/proxy/base.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ClientContextProvider } from "../../types/api/context/clientContext";
|
|
3
|
-
/**
|
|
4
|
-
* Common base for proxies that issue session-authenticated calls. The
|
|
5
|
-
* proxy is the layer that reads `ClientContextProvider` to assemble
|
|
6
|
-
* per-call axios config — Service is pure transport, the request
|
|
7
|
-
* interceptor only handles body-property injection.
|
|
8
|
-
*
|
|
9
|
-
* Proxies that mint their own auth (LimitedProxy, UserProxy's createUser
|
|
10
|
-
* path) build their config inline and do not call this helper.
|
|
11
|
-
*/
|
|
1
|
+
import type { ErrorHandler } from "../../types";
|
|
12
2
|
declare abstract class BaseProxy {
|
|
13
|
-
protected
|
|
14
|
-
constructor(
|
|
15
|
-
protected buildSessionConfig(showSensitive?: boolean): AxiosRequestConfig;
|
|
3
|
+
protected errorHandler: ErrorHandler;
|
|
4
|
+
constructor(errorHandler: ErrorHandler);
|
|
16
5
|
}
|
|
17
6
|
export { BaseProxy };
|
package/dist/api/proxy/base.js
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import { AxiosHeaders } from "axios";
|
|
2
|
-
import { HeaderKeys } from "../../constant/constant";
|
|
3
|
-
import { DateTimeHelper } from "../../helper/dateTimeHelper";
|
|
4
|
-
import { generateSourceID } from "../../utils/data/generation";
|
|
5
|
-
/**
|
|
6
|
-
* Common base for proxies that issue session-authenticated calls. The
|
|
7
|
-
* proxy is the layer that reads `ClientContextProvider` to assemble
|
|
8
|
-
* per-call axios config — Service is pure transport, the request
|
|
9
|
-
* interceptor only handles body-property injection.
|
|
10
|
-
*
|
|
11
|
-
* Proxies that mint their own auth (LimitedProxy, UserProxy's createUser
|
|
12
|
-
* path) build their config inline and do not call this helper.
|
|
13
|
-
*/
|
|
14
1
|
class BaseProxy {
|
|
15
|
-
|
|
16
|
-
constructor(
|
|
17
|
-
this.
|
|
18
|
-
}
|
|
19
|
-
buildSessionConfig(showSensitive) {
|
|
20
|
-
const headers = new AxiosHeaders();
|
|
21
|
-
headers.set(HeaderKeys.Authorization, `Bearer ${this.context.getToken()}`);
|
|
22
|
-
headers.set(HeaderKeys.SourceID, generateSourceID(this.context.getUserId()));
|
|
23
|
-
headers.set(HeaderKeys.TimeZone, DateTimeHelper.getClientTimeZone());
|
|
24
|
-
if (showSensitive) {
|
|
25
|
-
headers.set(HeaderKeys.ShowSensitiveData, "1");
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
headers,
|
|
29
|
-
};
|
|
2
|
+
errorHandler;
|
|
3
|
+
constructor(errorHandler) {
|
|
4
|
+
this.errorHandler = errorHandler;
|
|
30
5
|
}
|
|
31
6
|
}
|
|
32
7
|
export { BaseProxy };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BlockchainData } from "../../types";
|
|
1
|
+
import type { ErrorHandler, IBlockchainDelegateRequestData, IBlockchainMultiSendRequestData, IBlockchainSendRequestData, IBlockchainUndelegateRequestData } from "../../types";
|
|
3
2
|
import type { ClientContextProvider } from "../../types/api/context/clientContext";
|
|
4
3
|
import { BaseProxy } from "./base";
|
|
5
4
|
declare class BlockchainProxy extends BaseProxy {
|
|
6
5
|
private blockchainService;
|
|
7
|
-
constructor(context: ClientContextProvider,
|
|
8
|
-
send(
|
|
9
|
-
multiSend(
|
|
10
|
-
delegate(
|
|
11
|
-
undelegate(
|
|
6
|
+
constructor(context: ClientContextProvider, errorHandler: ErrorHandler);
|
|
7
|
+
send: (data: IBlockchainSendRequestData) => Promise<import("axios").AxiosResponse<import("../..").BlockchainData, any, {}>>;
|
|
8
|
+
multiSend: (data: IBlockchainMultiSendRequestData) => Promise<import("axios").AxiosResponse<import("../..").BlockchainData, any, {}>>;
|
|
9
|
+
delegate: (data: IBlockchainDelegateRequestData) => Promise<import("axios").AxiosResponse<import("../..").BlockchainData, any, {}>>;
|
|
10
|
+
undelegate: (data: IBlockchainUndelegateRequestData) => Promise<import("axios").AxiosResponse<import("../..").BlockchainData, any, {}>>;
|
|
12
11
|
}
|
|
13
12
|
export { BlockchainProxy };
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
+
import { fillBlockchainDelegateData, fillBlockchainMultiSendData, fillBlockchainSendData, fillBlockchainUndelegateData, } from "../data";
|
|
2
|
+
import { BlockchainService } from "../service/blockchain";
|
|
1
3
|
import { BaseProxy } from "./base";
|
|
2
4
|
class BlockchainProxy extends BaseProxy {
|
|
3
5
|
blockchainService;
|
|
4
|
-
constructor(context,
|
|
5
|
-
super(
|
|
6
|
-
this.blockchainService =
|
|
7
|
-
}
|
|
8
|
-
async send(payload) {
|
|
9
|
-
const config = this.buildSessionConfig();
|
|
10
|
-
return this.blockchainService.send(payload, config);
|
|
11
|
-
}
|
|
12
|
-
async multiSend(payload) {
|
|
13
|
-
const config = this.buildSessionConfig();
|
|
14
|
-
return this.blockchainService.multiSend(payload, config);
|
|
15
|
-
}
|
|
16
|
-
async delegate(payload) {
|
|
17
|
-
const config = this.buildSessionConfig();
|
|
18
|
-
return this.blockchainService.delegate(payload, config);
|
|
19
|
-
}
|
|
20
|
-
async undelegate(payload) {
|
|
21
|
-
const config = this.buildSessionConfig();
|
|
22
|
-
return this.blockchainService.undelegate(payload, config);
|
|
6
|
+
constructor(context, errorHandler) {
|
|
7
|
+
super(errorHandler);
|
|
8
|
+
this.blockchainService = new BlockchainService({ context, errorHandler });
|
|
23
9
|
}
|
|
10
|
+
// #region "POST"
|
|
11
|
+
send = async (data) => {
|
|
12
|
+
return this.blockchainService.send(fillBlockchainSendData(data));
|
|
13
|
+
};
|
|
14
|
+
multiSend = async (data) => {
|
|
15
|
+
return this.blockchainService.multiSend(fillBlockchainMultiSendData(data));
|
|
16
|
+
};
|
|
17
|
+
delegate = async (data) => {
|
|
18
|
+
return this.blockchainService.delegate(fillBlockchainDelegateData(data));
|
|
19
|
+
};
|
|
20
|
+
undelegate = async (data) => {
|
|
21
|
+
return this.blockchainService.undelegate(fillBlockchainUndelegateData(data));
|
|
22
|
+
};
|
|
24
23
|
}
|
|
25
24
|
export { BlockchainProxy };
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ErrorHandler } from "../../types";
|
|
2
2
|
import type { ClientContextProvider } from "../../types/api/context/clientContext";
|
|
3
3
|
import { BaseProxy } from "./base";
|
|
4
4
|
declare class IPAddressAndLocationProxy extends BaseProxy {
|
|
5
5
|
private ipAddressAndLocationService;
|
|
6
|
-
constructor(context: ClientContextProvider,
|
|
7
|
-
|
|
6
|
+
constructor(context: ClientContextProvider, errorHandler: ErrorHandler);
|
|
7
|
+
getGeoCoordinates: () => Promise<import("../..").GeoCoordinates>;
|
|
8
|
+
getIPAddress: () => Promise<string>;
|
|
9
|
+
getGeoCoordinatesAndIPAddress: () => Promise<{
|
|
10
|
+
geo_coordinates: import("../..").GeoCoordinates;
|
|
11
|
+
ip_address: string;
|
|
12
|
+
}>;
|
|
8
13
|
}
|
|
9
14
|
export { IPAddressAndLocationProxy };
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
+
import { GeoHelper } from "../../helper/geoHelper";
|
|
2
|
+
import { IPAddressAndLocationService } from "../service/ipAddressAndLocation";
|
|
1
3
|
import { BaseProxy } from "./base";
|
|
2
4
|
class IPAddressAndLocationProxy extends BaseProxy {
|
|
3
5
|
ipAddressAndLocationService;
|
|
4
|
-
constructor(context,
|
|
5
|
-
super(
|
|
6
|
-
this.ipAddressAndLocationService =
|
|
7
|
-
}
|
|
8
|
-
async getIPAddressAndLocation() {
|
|
9
|
-
const config = this.buildSessionConfig();
|
|
10
|
-
return this.ipAddressAndLocationService.getIPAddressAndLocation(config);
|
|
6
|
+
constructor(context, errorHandler) {
|
|
7
|
+
super(errorHandler);
|
|
8
|
+
this.ipAddressAndLocationService = new IPAddressAndLocationService({ context, errorHandler });
|
|
11
9
|
}
|
|
10
|
+
// #region "GET"
|
|
11
|
+
getGeoCoordinates = () => {
|
|
12
|
+
return GeoHelper.getGeoCoordinates({
|
|
13
|
+
getIPAddressAndLocation: () => this.ipAddressAndLocationService.getIPAddressAndLocation(),
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
getIPAddress = () => {
|
|
17
|
+
return GeoHelper.getIPAddress({
|
|
18
|
+
getIPAddressAndLocation: () => this.ipAddressAndLocationService.getIPAddressAndLocation(),
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
getGeoCoordinatesAndIPAddress = () => {
|
|
22
|
+
return GeoHelper.getGeoCoordinatesAndIPAddress({
|
|
23
|
+
getIPAddressAndLocation: () => this.ipAddressAndLocationService.getIPAddressAndLocation(),
|
|
24
|
+
});
|
|
25
|
+
};
|
|
12
26
|
}
|
|
13
27
|
export { IPAddressAndLocationProxy };
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AuthProxy } from "./auth";
|
|
1
|
+
import type { IConfirmEmailData, IConfirmPhoneData, IValidateEmailData, IValidatePhoneData, IVerifyEmailData, IVerifyPhoneData, IValidateForgetPasswordData, IConfirmForgetPasswordData, ErrorHandler, ICheckForgetPasswordData } from "../../types";
|
|
3
2
|
import type { ClientContextProvider } from "../../types/api/context/clientContext";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
* LimitedProxy mints a fresh limited token via AuthProxy and sets it as
|
|
7
|
-
* `Authorization` directly on each call. BaseService's request interceptor
|
|
8
|
-
* treats a pre-set `Authorization` header as "caller owns auth," so it
|
|
9
|
-
* skips the session-token injection and the refresh gate — limited calls
|
|
10
|
-
* are orthogonal to the session lifecycle.
|
|
11
|
-
*/
|
|
12
|
-
declare class LimitedProxy {
|
|
3
|
+
import { BaseProxy } from "./base";
|
|
4
|
+
declare class LimitedProxy extends BaseProxy {
|
|
13
5
|
private limitedService;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
constructor(context: ClientContextProvider, errorHandler: ErrorHandler);
|
|
7
|
+
checkForgetPassword: (data: ICheckForgetPasswordData) => Promise<import("axios").AxiosResponse<import("../..").ForgetSecurityData, any, {}>>;
|
|
8
|
+
validateForgetPassword: (data: IValidateForgetPasswordData) => Promise<import("axios").AxiosResponse<import("../..").ForgetSecurityData, any, {}>>;
|
|
9
|
+
confirmForgetPassword: (data: IConfirmForgetPasswordData) => Promise<import("axios").AxiosResponse<import("../..").ForgetSecurityData, any, {}>>;
|
|
10
|
+
validateEmail: (data: IValidateEmailData) => Promise<import("axios").AxiosResponse<import("../..").ValidateLimitedSecurity, any, {}>>;
|
|
11
|
+
validatePhone: (data: IValidatePhoneData) => Promise<import("axios").AxiosResponse<import("../..").ValidateLimitedSecurity, any, {}>>;
|
|
12
|
+
verifyEmail: (data: IVerifyEmailData) => Promise<import("axios").AxiosResponse<import("../..").VerifyUserSecurity, any, {}>>;
|
|
13
|
+
verifyPhone: (data: IVerifyPhoneData) => Promise<import("axios").AxiosResponse<import("../..").VerifyUserSecurity, any, {}>>;
|
|
14
|
+
confirmEmail: (data: IConfirmEmailData) => Promise<import("axios").AxiosResponse<import("../..").ConfirmUserSecurity, any, {}>>;
|
|
15
|
+
confirmPhone: (data: IConfirmPhoneData) => Promise<import("axios").AxiosResponse<import("../..").ConfirmUserSecurity, any, {}>>;
|
|
24
16
|
}
|
|
25
17
|
export { LimitedProxy };
|