fiberx-backend-toolkit 1.0.12 → 1.0.14
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/fibase/clients/base_fibase_app_client.d.ts +26 -0
- package/dist/fibase/clients/base_fibase_app_client.js +133 -0
- package/dist/fibase/clients/generated_fibase_registered_app_client.d.ts +10 -0
- package/dist/fibase/clients/generated_fibase_registered_app_client.js +16 -0
- package/dist/fibase/clients/v1/fibase_v1_client.d.ts +15 -0
- package/dist/fibase/clients/v1/fibase_v1_client.js +23 -0
- package/dist/fibase/clients/v1/fibase_v1_identity_client.d.ts +16 -0
- package/dist/fibase/clients/v1/fibase_v1_identity_client.js +28 -0
- package/dist/fibase/clients/v1/fibase_v1_identity_wallet_client.d.ts +18 -0
- package/dist/fibase/clients/v1/fibase_v1_identity_wallet_client.js +37 -0
- package/dist/fibase/clients/v1/fibase_v1_payment_config_client.d.ts +16 -0
- package/dist/fibase/clients/v1/fibase_v1_payment_config_client.js +31 -0
- package/dist/fibase/clients/v1/fibase_v1_transaction_client.d.ts +29 -0
- package/dist/fibase/clients/v1/fibase_v1_transaction_client.js +49 -0
- package/dist/fibase/clients/v1/main.d.ts +6 -0
- package/dist/fibase/clients/v1/main.js +17 -0
- package/dist/fibase/fibase_app_client.d.ts +8 -43
- package/dist/fibase/fibase_app_client.js +8 -134
- package/dist/fibase/main.d.ts +7 -2
- package/dist/fibase/main.js +25 -3
- package/dist/fibase/registered_app_api_routes.d.ts +87 -0
- package/dist/fibase/registered_app_api_routes.js +102 -0
- package/dist/mailer/processors/email_enqueue_processor.js +1 -1
- package/dist/types/fibase_registered_app_api_type.d.ts +393 -0
- package/dist/types/fibase_registered_app_api_type.js +2 -0
- package/dist/types/fibase_type.d.ts +2 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/main.js +1 -0
- package/package.json +19 -17
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LoggerUtil } from "../../utils/main";
|
|
2
|
+
import { FibaseAppClientConfigInterface, FibaseHeaderNamesInterface, FibaseHttpResponseInterface, FibaseRequestOptionsInterface, FibaseSignedRequestDataInterface, FibaseSignedRequestInputInterface } from "../../types/fibase_type";
|
|
3
|
+
/** Shared signing, route-building, and HTTP behavior for every Fibase API version. */
|
|
4
|
+
declare abstract class BaseFibaseAppClient {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
protected readonly logger: LoggerUtil;
|
|
7
|
+
protected readonly config: FibaseAppClientConfigInterface;
|
|
8
|
+
protected readonly headers: FibaseHeaderNamesInterface;
|
|
9
|
+
private static readonly DEFAULT_HEADERS;
|
|
10
|
+
constructor(config: FibaseAppClientConfigInterface, client_name?: string);
|
|
11
|
+
/** Validate the values required to sign every Fibase request. */
|
|
12
|
+
private validateConfig;
|
|
13
|
+
/** Normalize paths to the same value Fibase uses when checking signatures. */
|
|
14
|
+
private normalizePath;
|
|
15
|
+
/** Fill named route parameters with safely encoded values. */
|
|
16
|
+
protected buildRoute(template: string, params: Record<string, string | number>): string;
|
|
17
|
+
/** Build the body digest used in Fibase's canonical request string. */
|
|
18
|
+
hashBody(body: unknown): string;
|
|
19
|
+
/** Build the canonical string signed by registered apps. */
|
|
20
|
+
buildCanonicalString(method: string, path: string, timestamp: string, nonce: string, body: unknown): string;
|
|
21
|
+
/** Build a signed request without sending it. */
|
|
22
|
+
buildSignedRequest<TBody = unknown>(input: FibaseSignedRequestInputInterface<TBody>): FibaseSignedRequestDataInterface<TBody>;
|
|
23
|
+
/** Send one signed request through the shared Axios transport. */
|
|
24
|
+
request<TResponse = unknown, TBody = unknown>(method: string, path: string, body?: TBody, options?: FibaseRequestOptionsInterface): Promise<FibaseHttpResponseInterface<TResponse>>;
|
|
25
|
+
}
|
|
26
|
+
export default BaseFibaseAppClient;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const main_1 = require("../../utils/main");
|
|
8
|
+
/** Shared signing, route-building, and HTTP behavior for every Fibase API version. */
|
|
9
|
+
class BaseFibaseAppClient {
|
|
10
|
+
name;
|
|
11
|
+
logger;
|
|
12
|
+
config;
|
|
13
|
+
headers;
|
|
14
|
+
static DEFAULT_HEADERS = {
|
|
15
|
+
app_id: "X-App-Id",
|
|
16
|
+
app_key_version: "X-Key-Version",
|
|
17
|
+
timestamp: "X-Timestamp",
|
|
18
|
+
nonce: "X-Nonce",
|
|
19
|
+
signature: "x-Signature",
|
|
20
|
+
request_id: "X-Request-Id",
|
|
21
|
+
content_type: "Content-Type",
|
|
22
|
+
};
|
|
23
|
+
constructor(config, client_name = "base_fibase_app_client") {
|
|
24
|
+
this.name = client_name;
|
|
25
|
+
this.logger = new main_1.LoggerUtil(this.name);
|
|
26
|
+
this.config = {
|
|
27
|
+
...config,
|
|
28
|
+
base_url: config.base_url.replace(/\/+$/, ""),
|
|
29
|
+
key_algorithm: config.key_algorithm ?? "sha256",
|
|
30
|
+
timeout_ms: config.timeout_ms ?? 30000,
|
|
31
|
+
};
|
|
32
|
+
this.headers = { ...BaseFibaseAppClient.DEFAULT_HEADERS, ...(config.headers ?? {}) };
|
|
33
|
+
this.validateConfig();
|
|
34
|
+
}
|
|
35
|
+
/** Validate the values required to sign every Fibase request. */
|
|
36
|
+
validateConfig() {
|
|
37
|
+
if (!this.config.base_url) {
|
|
38
|
+
throw new Error("Fibase base_url is required");
|
|
39
|
+
}
|
|
40
|
+
if (!this.config.app_id) {
|
|
41
|
+
throw new Error("Fibase app_id is required");
|
|
42
|
+
}
|
|
43
|
+
if (!this.config.app_private_key) {
|
|
44
|
+
throw new Error("Fibase app_private_key is required");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Normalize paths to the same value Fibase uses when checking signatures. */
|
|
48
|
+
normalizePath(path) {
|
|
49
|
+
const [pathname] = path.split("?");
|
|
50
|
+
return pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
51
|
+
}
|
|
52
|
+
/** Fill named route parameters with safely encoded values. */
|
|
53
|
+
buildRoute(template, params) {
|
|
54
|
+
return template.replace(/:([A-Za-z0-9_]+)/g, (_match, name) => {
|
|
55
|
+
const value = params[name];
|
|
56
|
+
if (value === undefined) {
|
|
57
|
+
throw new Error(`Missing Fibase route parameter: ${name}`);
|
|
58
|
+
}
|
|
59
|
+
return encodeURIComponent(String(value));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Build the body digest used in Fibase's canonical request string. */
|
|
63
|
+
hashBody(body) {
|
|
64
|
+
return main_1.CryptoKeyUtil.hash(JSON.stringify(body ?? {}), "sha256", "hex");
|
|
65
|
+
}
|
|
66
|
+
/** Build the canonical string signed by registered apps. */
|
|
67
|
+
buildCanonicalString(method, path, timestamp, nonce, body) {
|
|
68
|
+
return [
|
|
69
|
+
method.toUpperCase(),
|
|
70
|
+
this.normalizePath(path),
|
|
71
|
+
timestamp,
|
|
72
|
+
nonce,
|
|
73
|
+
this.hashBody(body),
|
|
74
|
+
].join("\n");
|
|
75
|
+
}
|
|
76
|
+
/** Build a signed request without sending it. */
|
|
77
|
+
buildSignedRequest(input) {
|
|
78
|
+
const method = input.method.toUpperCase();
|
|
79
|
+
const path = this.normalizePath(input.path);
|
|
80
|
+
const body = (input.body ?? {});
|
|
81
|
+
const timestamp = input.timestamp ?? Date.now().toString();
|
|
82
|
+
const nonce = input.nonce ?? main_1.UUIDGeneratorUtil.generateUUIDV2("NONCE");
|
|
83
|
+
const canonical = this.buildCanonicalString(method, path, timestamp, nonce, body);
|
|
84
|
+
const signature = main_1.CryptoKeyUtil.sign(canonical, this.config.app_private_key, this.config.key_algorithm, "base64");
|
|
85
|
+
return {
|
|
86
|
+
url: `${this.config.base_url}${path}`,
|
|
87
|
+
method,
|
|
88
|
+
path,
|
|
89
|
+
body,
|
|
90
|
+
canonical,
|
|
91
|
+
signature,
|
|
92
|
+
headers: {
|
|
93
|
+
[this.headers.content_type]: "application/json",
|
|
94
|
+
[this.headers.app_id]: this.config.app_id,
|
|
95
|
+
[this.headers.app_key_version]: String(this.config.app_key_version ?? 1),
|
|
96
|
+
[this.headers.timestamp]: timestamp,
|
|
97
|
+
[this.headers.nonce]: nonce,
|
|
98
|
+
[this.headers.signature]: signature,
|
|
99
|
+
[this.headers.request_id]: input.request_id ?? main_1.UUIDGeneratorUtil.generateUUIDV2("REQ"),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** Send one signed request through the shared Axios transport. */
|
|
104
|
+
async request(method, path, body, options = {}) {
|
|
105
|
+
const signed_request = this.buildSignedRequest({
|
|
106
|
+
method,
|
|
107
|
+
path,
|
|
108
|
+
body,
|
|
109
|
+
request_id: options.request_id,
|
|
110
|
+
});
|
|
111
|
+
const request_config = {
|
|
112
|
+
url: signed_request.url,
|
|
113
|
+
method: signed_request.method,
|
|
114
|
+
data: signed_request.body,
|
|
115
|
+
headers: { ...signed_request.headers, ...(options.headers ?? {}) },
|
|
116
|
+
params: options.params,
|
|
117
|
+
timeout: this.config.timeout_ms,
|
|
118
|
+
};
|
|
119
|
+
this.logger.info("Sending signed Fibase app request", {
|
|
120
|
+
method: signed_request.method,
|
|
121
|
+
path: signed_request.path,
|
|
122
|
+
request_id: signed_request.headers[this.headers.request_id],
|
|
123
|
+
});
|
|
124
|
+
const response = await axios_1.default.request(request_config);
|
|
125
|
+
return {
|
|
126
|
+
status: response.status,
|
|
127
|
+
status_text: response.statusText,
|
|
128
|
+
data: response.data,
|
|
129
|
+
headers: response.headers,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.default = BaseFibaseAppClient;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Generated by scripts/generate-fibase-registered-app-routes.js. */
|
|
2
|
+
import { FibaseAppClientConfigInterface } from "../../types/fibase_type";
|
|
3
|
+
import BaseFibaseAppClient from "./base_fibase_app_client";
|
|
4
|
+
import FibaseV1Client from "./v1/fibase_v1_client";
|
|
5
|
+
/** Generated API-version properties shared by the main Fibase client. */
|
|
6
|
+
declare class GeneratedFibaseRegisteredAppClient extends BaseFibaseAppClient {
|
|
7
|
+
readonly v1: FibaseV1Client;
|
|
8
|
+
constructor(config: FibaseAppClientConfigInterface, client_name?: string);
|
|
9
|
+
}
|
|
10
|
+
export default GeneratedFibaseRegisteredAppClient;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const base_fibase_app_client_1 = __importDefault(require("./base_fibase_app_client"));
|
|
7
|
+
const fibase_v1_client_1 = __importDefault(require("./v1/fibase_v1_client"));
|
|
8
|
+
/** Generated API-version properties shared by the main Fibase client. */
|
|
9
|
+
class GeneratedFibaseRegisteredAppClient extends base_fibase_app_client_1.default {
|
|
10
|
+
v1;
|
|
11
|
+
constructor(config, client_name = "fibase_app_client") {
|
|
12
|
+
super(config, client_name);
|
|
13
|
+
this.v1 = new fibase_v1_client_1.default(config);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = GeneratedFibaseRegisteredAppClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Generated by scripts/generate-fibase-registered-app-routes.js. */
|
|
2
|
+
import { FibaseAppClientConfigInterface } from "../../../types/fibase_type";
|
|
3
|
+
import FibaseV1IdentityClient from "./fibase_v1_identity_client";
|
|
4
|
+
import FibaseV1IdentityWalletClient from "./fibase_v1_identity_wallet_client";
|
|
5
|
+
import FibaseV1PaymentConfigClient from "./fibase_v1_payment_config_client";
|
|
6
|
+
import FibaseV1TransactionClient from "./fibase_v1_transaction_client";
|
|
7
|
+
/** Resource clients for Fibase's registered-app v1 API. */
|
|
8
|
+
declare class FibaseV1Client {
|
|
9
|
+
readonly identity: FibaseV1IdentityClient;
|
|
10
|
+
readonly identity_wallet: FibaseV1IdentityWalletClient;
|
|
11
|
+
readonly payment_config: FibaseV1PaymentConfigClient;
|
|
12
|
+
readonly transaction: FibaseV1TransactionClient;
|
|
13
|
+
constructor(config: FibaseAppClientConfigInterface);
|
|
14
|
+
}
|
|
15
|
+
export default FibaseV1Client;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fibase_v1_identity_client_1 = __importDefault(require("./fibase_v1_identity_client"));
|
|
7
|
+
const fibase_v1_identity_wallet_client_1 = __importDefault(require("./fibase_v1_identity_wallet_client"));
|
|
8
|
+
const fibase_v1_payment_config_client_1 = __importDefault(require("./fibase_v1_payment_config_client"));
|
|
9
|
+
const fibase_v1_transaction_client_1 = __importDefault(require("./fibase_v1_transaction_client"));
|
|
10
|
+
/** Resource clients for Fibase's registered-app v1 API. */
|
|
11
|
+
class FibaseV1Client {
|
|
12
|
+
identity;
|
|
13
|
+
identity_wallet;
|
|
14
|
+
payment_config;
|
|
15
|
+
transaction;
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.identity = new fibase_v1_identity_client_1.default(config);
|
|
18
|
+
this.identity_wallet = new fibase_v1_identity_wallet_client_1.default(config);
|
|
19
|
+
this.payment_config = new fibase_v1_payment_config_client_1.default(config);
|
|
20
|
+
this.transaction = new fibase_v1_transaction_client_1.default(config);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = FibaseV1Client;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/generate-fibase-registered-app-routes.js.
|
|
3
|
+
* Update the route or contract registry, then rerun the generator.
|
|
4
|
+
*/
|
|
5
|
+
import BaseFibaseAppClient from "../base_fibase_app_client";
|
|
6
|
+
import { FibaseAppClientConfigInterface } from "../../../types/fibase_type";
|
|
7
|
+
import { FibaseRegisteredAppRequestOptionsInterface, FibaseResolveAppIdentityInputInterface, FibaseResolveAppIdentityResponse, FibaseGetAppIdentityResponse } from "../../../types/fibase_registered_app_api_type";
|
|
8
|
+
/** Fibase v1 registered-app identity endpoints. */
|
|
9
|
+
declare class FibaseV1IdentityClient extends BaseFibaseAppClient {
|
|
10
|
+
constructor(config: FibaseAppClientConfigInterface);
|
|
11
|
+
/** POST /api/app/v1/identity/resolve */
|
|
12
|
+
getOrCreateAppIdentityRecord(input: FibaseResolveAppIdentityInputInterface, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseResolveAppIdentityResponse>;
|
|
13
|
+
/** GET /api/app/v1/identity/:member_public_id */
|
|
14
|
+
getAppIdentityRecord(member_public_id: string, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseGetAppIdentityResponse>;
|
|
15
|
+
}
|
|
16
|
+
export default FibaseV1IdentityClient;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/**
|
|
7
|
+
* Generated by scripts/generate-fibase-registered-app-routes.js.
|
|
8
|
+
* Update the route or contract registry, then rerun the generator.
|
|
9
|
+
*/
|
|
10
|
+
const base_fibase_app_client_1 = __importDefault(require("../base_fibase_app_client"));
|
|
11
|
+
const registered_app_api_routes_1 = __importDefault(require("../../registered_app_api_routes"));
|
|
12
|
+
/** Fibase v1 registered-app identity endpoints. */
|
|
13
|
+
class FibaseV1IdentityClient extends base_fibase_app_client_1.default {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
super(config, "fibase_v1_identity_client");
|
|
16
|
+
}
|
|
17
|
+
/** POST /api/app/v1/identity/resolve */
|
|
18
|
+
async getOrCreateAppIdentityRecord(input, options = {}) {
|
|
19
|
+
return this.request("POST", registered_app_api_routes_1.default.v1.getOrCreateAppIdentityRecord, input, options);
|
|
20
|
+
}
|
|
21
|
+
/** GET /api/app/v1/identity/:member_public_id */
|
|
22
|
+
async getAppIdentityRecord(member_public_id, options = {}) {
|
|
23
|
+
return this.request("GET", this.buildRoute(registered_app_api_routes_1.default.v1.getAppIdentityRecord, {
|
|
24
|
+
member_public_id: member_public_id,
|
|
25
|
+
}), undefined, options);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = FibaseV1IdentityClient;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/generate-fibase-registered-app-routes.js.
|
|
3
|
+
* Update the route or contract registry, then rerun the generator.
|
|
4
|
+
*/
|
|
5
|
+
import BaseFibaseAppClient from "../base_fibase_app_client";
|
|
6
|
+
import { FibaseAppClientConfigInterface } from "../../../types/fibase_type";
|
|
7
|
+
import { FibaseRegisteredAppRequestOptionsInterface, FibaseGetAppIdentityWalletListInputInterface, FibaseGetAppIdentityWalletListResponse, FibaseResolveAppIdentityCurrencyWalletInputInterface, FibaseResolveAppIdentityCurrencyWalletResponse, FibaseGetAppIdentityCurrencyWalletInputInterface, FibaseGetAppIdentityCurrencyWalletResponse } from "../../../types/fibase_registered_app_api_type";
|
|
8
|
+
/** Fibase v1 registered-app identity_wallet endpoints. */
|
|
9
|
+
declare class FibaseV1IdentityWalletClient extends BaseFibaseAppClient {
|
|
10
|
+
constructor(config: FibaseAppClientConfigInterface);
|
|
11
|
+
/** GET /api/app/v1/identity/:identity_public_id/wallets */
|
|
12
|
+
getAppIdentityWalletList(input: FibaseGetAppIdentityWalletListInputInterface, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseGetAppIdentityWalletListResponse>;
|
|
13
|
+
/** POST /api/app/v1/identity/:identity_public_id/wallets/resolve */
|
|
14
|
+
getOrCreateAppIdentityCurrencyWallet(input: FibaseResolveAppIdentityCurrencyWalletInputInterface, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseResolveAppIdentityCurrencyWalletResponse>;
|
|
15
|
+
/** GET /api/app/v1/identity/:identity_public_id/wallets/:currency_id */
|
|
16
|
+
getAppIdentityCurrencyWallet(input: FibaseGetAppIdentityCurrencyWalletInputInterface, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseGetAppIdentityCurrencyWalletResponse>;
|
|
17
|
+
}
|
|
18
|
+
export default FibaseV1IdentityWalletClient;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/**
|
|
7
|
+
* Generated by scripts/generate-fibase-registered-app-routes.js.
|
|
8
|
+
* Update the route or contract registry, then rerun the generator.
|
|
9
|
+
*/
|
|
10
|
+
const base_fibase_app_client_1 = __importDefault(require("../base_fibase_app_client"));
|
|
11
|
+
const registered_app_api_routes_1 = __importDefault(require("../../registered_app_api_routes"));
|
|
12
|
+
/** Fibase v1 registered-app identity_wallet endpoints. */
|
|
13
|
+
class FibaseV1IdentityWalletClient extends base_fibase_app_client_1.default {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
super(config, "fibase_v1_identity_wallet_client");
|
|
16
|
+
}
|
|
17
|
+
/** GET /api/app/v1/identity/:identity_public_id/wallets */
|
|
18
|
+
async getAppIdentityWalletList(input, options = {}) {
|
|
19
|
+
return this.request("GET", this.buildRoute(registered_app_api_routes_1.default.v1.getAppIdentityWalletList, {
|
|
20
|
+
identity_public_id: input.identity_public_id,
|
|
21
|
+
}), undefined, { ...options, params: { ...(input.query ?? {}) } });
|
|
22
|
+
}
|
|
23
|
+
/** POST /api/app/v1/identity/:identity_public_id/wallets/resolve */
|
|
24
|
+
async getOrCreateAppIdentityCurrencyWallet(input, options = {}) {
|
|
25
|
+
return this.request("POST", this.buildRoute(registered_app_api_routes_1.default.v1.getOrCreateAppIdentityCurrencyWallet, {
|
|
26
|
+
identity_public_id: input.identity_public_id,
|
|
27
|
+
}), { currency_id: input.currency_id }, options);
|
|
28
|
+
}
|
|
29
|
+
/** GET /api/app/v1/identity/:identity_public_id/wallets/:currency_id */
|
|
30
|
+
async getAppIdentityCurrencyWallet(input, options = {}) {
|
|
31
|
+
return this.request("GET", this.buildRoute(registered_app_api_routes_1.default.v1.getAppIdentityCurrencyWallet, {
|
|
32
|
+
identity_public_id: input.identity_public_id,
|
|
33
|
+
currency_id: input.currency_id,
|
|
34
|
+
}), undefined, options);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.default = FibaseV1IdentityWalletClient;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/generate-fibase-registered-app-routes.js.
|
|
3
|
+
* Update the route or contract registry, then rerun the generator.
|
|
4
|
+
*/
|
|
5
|
+
import BaseFibaseAppClient from "../base_fibase_app_client";
|
|
6
|
+
import { FibaseAppClientConfigInterface } from "../../../types/fibase_type";
|
|
7
|
+
import { FibaseRegisteredAppRequestOptionsInterface, FibaseGetAppCurrencyListInputInterface, FibaseGetAppCurrencyListResponse, FibaseGetAppCurrencyPaymentOptionsResponse } from "../../../types/fibase_registered_app_api_type";
|
|
8
|
+
/** Fibase v1 registered-app payment_config endpoints. */
|
|
9
|
+
declare class FibaseV1PaymentConfigClient extends BaseFibaseAppClient {
|
|
10
|
+
constructor(config: FibaseAppClientConfigInterface);
|
|
11
|
+
/** GET /api/app/v1/payment-config/currencies */
|
|
12
|
+
getAppCurrencyList(input: FibaseGetAppCurrencyListInputInterface, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseGetAppCurrencyListResponse>;
|
|
13
|
+
/** GET /api/app/v1/payment-config/currencies/:currency_id/options */
|
|
14
|
+
getAppCurrencyPaymentOptions(currency_id: string | number, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseGetAppCurrencyPaymentOptionsResponse>;
|
|
15
|
+
}
|
|
16
|
+
export default FibaseV1PaymentConfigClient;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/**
|
|
7
|
+
* Generated by scripts/generate-fibase-registered-app-routes.js.
|
|
8
|
+
* Update the route or contract registry, then rerun the generator.
|
|
9
|
+
*/
|
|
10
|
+
const base_fibase_app_client_1 = __importDefault(require("../base_fibase_app_client"));
|
|
11
|
+
const registered_app_api_routes_1 = __importDefault(require("../../registered_app_api_routes"));
|
|
12
|
+
/** Fibase v1 registered-app payment_config endpoints. */
|
|
13
|
+
class FibaseV1PaymentConfigClient extends base_fibase_app_client_1.default {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
super(config, "fibase_v1_payment_config_client");
|
|
16
|
+
}
|
|
17
|
+
/** GET /api/app/v1/payment-config/currencies */
|
|
18
|
+
async getAppCurrencyList(input, options = {}) {
|
|
19
|
+
return this.request("GET", registered_app_api_routes_1.default.v1.getAppCurrencyList, undefined, {
|
|
20
|
+
...options,
|
|
21
|
+
params: { ...(input.query ?? {}) },
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/** GET /api/app/v1/payment-config/currencies/:currency_id/options */
|
|
25
|
+
async getAppCurrencyPaymentOptions(currency_id, options = {}) {
|
|
26
|
+
return this.request("GET", this.buildRoute(registered_app_api_routes_1.default.v1.getAppCurrencyPaymentOptions, {
|
|
27
|
+
currency_id: currency_id,
|
|
28
|
+
}), undefined, options);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = FibaseV1PaymentConfigClient;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/generate-fibase-registered-app-routes.js.
|
|
3
|
+
* Update the route or contract registry, then rerun the generator.
|
|
4
|
+
*/
|
|
5
|
+
import BaseFibaseAppClient from "../base_fibase_app_client";
|
|
6
|
+
import { FibaseAppClientConfigInterface } from "../../../types/fibase_type";
|
|
7
|
+
import { FibaseRegisteredAppRequestOptionsInterface, FibaseInitiateAppDepositTransactionInputInterface, FibaseInitiateAppDepositTransactionResponse, FibaseGetAppTransactionResponse, FibaseVerifyAppTransactionResponse } from "../../../types/fibase_registered_app_api_type";
|
|
8
|
+
/** Fibase v1 registered-app transaction endpoints. */
|
|
9
|
+
declare class FibaseV1TransactionClient extends BaseFibaseAppClient {
|
|
10
|
+
constructor(config: FibaseAppClientConfigInterface);
|
|
11
|
+
/** POST /api/app/v1/transactions/deposits */
|
|
12
|
+
initiateAppDepositTransaction(input: FibaseInitiateAppDepositTransactionInputInterface, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseInitiateAppDepositTransactionResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* GET /api/app/v1/transactions/reference/:app_reference
|
|
15
|
+
* Fibase currently returns `501 service_not_implemented` for this route.
|
|
16
|
+
*/
|
|
17
|
+
getAppTransactionByReference(app_reference: string, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseGetAppTransactionResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* POST /api/app/v1/transactions/:transaction_public_id/verify
|
|
20
|
+
* Fibase currently returns `501 service_not_implemented` for this route.
|
|
21
|
+
*/
|
|
22
|
+
verifyAppTransaction(transaction_public_id: string, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseVerifyAppTransactionResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* GET /api/app/v1/transactions/:transaction_public_id
|
|
25
|
+
* Fibase currently returns `501 service_not_implemented` for this route.
|
|
26
|
+
*/
|
|
27
|
+
getAppTransactionRecord(transaction_public_id: string, options?: FibaseRegisteredAppRequestOptionsInterface): Promise<FibaseGetAppTransactionResponse>;
|
|
28
|
+
}
|
|
29
|
+
export default FibaseV1TransactionClient;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/**
|
|
7
|
+
* Generated by scripts/generate-fibase-registered-app-routes.js.
|
|
8
|
+
* Update the route or contract registry, then rerun the generator.
|
|
9
|
+
*/
|
|
10
|
+
const base_fibase_app_client_1 = __importDefault(require("../base_fibase_app_client"));
|
|
11
|
+
const registered_app_api_routes_1 = __importDefault(require("../../registered_app_api_routes"));
|
|
12
|
+
/** Fibase v1 registered-app transaction endpoints. */
|
|
13
|
+
class FibaseV1TransactionClient extends base_fibase_app_client_1.default {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
super(config, "fibase_v1_transaction_client");
|
|
16
|
+
}
|
|
17
|
+
/** POST /api/app/v1/transactions/deposits */
|
|
18
|
+
async initiateAppDepositTransaction(input, options = {}) {
|
|
19
|
+
return this.request("POST", registered_app_api_routes_1.default.v1.initiateAppDepositTransaction, input, options);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* GET /api/app/v1/transactions/reference/:app_reference
|
|
23
|
+
* Fibase currently returns `501 service_not_implemented` for this route.
|
|
24
|
+
*/
|
|
25
|
+
async getAppTransactionByReference(app_reference, options = {}) {
|
|
26
|
+
return this.request("GET", this.buildRoute(registered_app_api_routes_1.default.v1.getAppTransactionByReference, {
|
|
27
|
+
app_reference: app_reference,
|
|
28
|
+
}), undefined, options);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* POST /api/app/v1/transactions/:transaction_public_id/verify
|
|
32
|
+
* Fibase currently returns `501 service_not_implemented` for this route.
|
|
33
|
+
*/
|
|
34
|
+
async verifyAppTransaction(transaction_public_id, options = {}) {
|
|
35
|
+
return this.request("POST", this.buildRoute(registered_app_api_routes_1.default.v1.verifyAppTransaction, {
|
|
36
|
+
transaction_public_id: transaction_public_id,
|
|
37
|
+
}), {}, options);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* GET /api/app/v1/transactions/:transaction_public_id
|
|
41
|
+
* Fibase currently returns `501 service_not_implemented` for this route.
|
|
42
|
+
*/
|
|
43
|
+
async getAppTransactionRecord(transaction_public_id, options = {}) {
|
|
44
|
+
return this.request("GET", this.buildRoute(registered_app_api_routes_1.default.v1.getAppTransactionRecord, {
|
|
45
|
+
transaction_public_id: transaction_public_id,
|
|
46
|
+
}), undefined, options);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.default = FibaseV1TransactionClient;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Generated by scripts/generate-fibase-registered-app-routes.js. */
|
|
2
|
+
export { default as FibaseV1Client } from "./fibase_v1_client";
|
|
3
|
+
export { default as FibaseV1IdentityClient } from "./fibase_v1_identity_client";
|
|
4
|
+
export { default as FibaseV1IdentityWalletClient } from "./fibase_v1_identity_wallet_client";
|
|
5
|
+
export { default as FibaseV1PaymentConfigClient } from "./fibase_v1_payment_config_client";
|
|
6
|
+
export { default as FibaseV1TransactionClient } from "./fibase_v1_transaction_client";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FibaseV1TransactionClient = exports.FibaseV1PaymentConfigClient = exports.FibaseV1IdentityWalletClient = exports.FibaseV1IdentityClient = exports.FibaseV1Client = void 0;
|
|
7
|
+
/** Generated by scripts/generate-fibase-registered-app-routes.js. */
|
|
8
|
+
var fibase_v1_client_1 = require("./fibase_v1_client");
|
|
9
|
+
Object.defineProperty(exports, "FibaseV1Client", { enumerable: true, get: function () { return __importDefault(fibase_v1_client_1).default; } });
|
|
10
|
+
var fibase_v1_identity_client_1 = require("./fibase_v1_identity_client");
|
|
11
|
+
Object.defineProperty(exports, "FibaseV1IdentityClient", { enumerable: true, get: function () { return __importDefault(fibase_v1_identity_client_1).default; } });
|
|
12
|
+
var fibase_v1_identity_wallet_client_1 = require("./fibase_v1_identity_wallet_client");
|
|
13
|
+
Object.defineProperty(exports, "FibaseV1IdentityWalletClient", { enumerable: true, get: function () { return __importDefault(fibase_v1_identity_wallet_client_1).default; } });
|
|
14
|
+
var fibase_v1_payment_config_client_1 = require("./fibase_v1_payment_config_client");
|
|
15
|
+
Object.defineProperty(exports, "FibaseV1PaymentConfigClient", { enumerable: true, get: function () { return __importDefault(fibase_v1_payment_config_client_1).default; } });
|
|
16
|
+
var fibase_v1_transaction_client_1 = require("./fibase_v1_transaction_client");
|
|
17
|
+
Object.defineProperty(exports, "FibaseV1TransactionClient", { enumerable: true, get: function () { return __importDefault(fibase_v1_transaction_client_1).default; } });
|
|
@@ -1,52 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import GeneratedFibaseRegisteredAppClient from "./clients/generated_fibase_registered_app_client";
|
|
2
|
+
import { FibaseAppClientConfigInterface, FibaseAppClientEnvOptionsInterface, FibaseAppEventBuildInputInterface, FibaseHttpResponseInterface, FibaseSendAppEventOptionsInterface } from "../types/fibase_type";
|
|
3
|
+
/** Main Fibase client and entry point for versioned API clients. */
|
|
4
|
+
declare class FibaseAppClient extends GeneratedFibaseRegisteredAppClient {
|
|
3
5
|
private static instance;
|
|
4
|
-
readonly name = "fibase_app_client";
|
|
5
|
-
private readonly logger;
|
|
6
|
-
private readonly config;
|
|
7
|
-
private readonly headers;
|
|
8
|
-
private static readonly DEFAULT_HEADERS;
|
|
9
6
|
private static readonly DEFAULT_BASE_URLS;
|
|
10
7
|
constructor(config: FibaseAppClientConfigInterface);
|
|
11
|
-
/**
|
|
12
|
-
* Create a singleton client for applications that prefer process-wide reuse.
|
|
13
|
-
*/
|
|
8
|
+
/** Create a process-wide Fibase client. */
|
|
14
9
|
static initialize(config: FibaseAppClientConfigInterface): FibaseAppClient;
|
|
15
|
-
/**
|
|
16
|
-
* Return the initialized singleton client.
|
|
17
|
-
*/
|
|
10
|
+
/** Return the initialized process-wide client. */
|
|
18
11
|
static getInstance(): FibaseAppClient;
|
|
19
|
-
/**
|
|
20
|
-
* Build a client from environment variables loaded by EnvManagerUtil.
|
|
21
|
-
*/
|
|
12
|
+
/** Build a client from Fibase environment variables. */
|
|
22
13
|
static fromEnv(options?: FibaseAppClientEnvOptionsInterface): FibaseAppClient;
|
|
23
|
-
/**
|
|
24
|
-
* Validate the minimum data required to sign Fibase app requests.
|
|
25
|
-
*/
|
|
26
|
-
private validateConfig;
|
|
27
|
-
/**
|
|
28
|
-
* Normalize request paths so signature generation matches the server authenticator.
|
|
29
|
-
*/
|
|
30
|
-
private normalizePath;
|
|
31
|
-
/**
|
|
32
|
-
* Build the same body hash format used by Fibase's RequestAuthenticatorUtil.
|
|
33
|
-
*/
|
|
34
|
-
hashBody(body: unknown): string;
|
|
35
|
-
/**
|
|
36
|
-
* Build the canonical string signed by external apps and verified by Fibase.
|
|
37
|
-
*/
|
|
38
|
-
buildCanonicalString(method: string, path: string, timestamp: string, nonce: string, body: unknown): string;
|
|
39
|
-
/**
|
|
40
|
-
* Build a signed request without sending it. Useful for tests and custom transports.
|
|
41
|
-
*/
|
|
42
|
-
buildSignedRequest<TBody = unknown>(input: FibaseSignedRequestInputInterface<TBody>): FibaseSignedRequestDataInterface<TBody>;
|
|
43
|
-
/**
|
|
44
|
-
* Send a signed request to Fibase using the standard app-auth headers.
|
|
45
|
-
*/
|
|
46
|
-
request<TResponse = unknown, TBody = unknown>(method: string, path: string, body?: TBody, options?: FibaseRequestOptionsInterface): Promise<FibaseHttpResponseInterface<TResponse>>;
|
|
47
|
-
/**
|
|
48
|
-
* Build and send a standard app event to the Fibase central app.
|
|
49
|
-
*/
|
|
14
|
+
/** Build and send a standard app event to Fibase. */
|
|
50
15
|
sendAppEvent<TPayload, TResponse = unknown>(input: FibaseAppEventBuildInputInterface<TPayload>, options?: FibaseSendAppEventOptionsInterface): Promise<FibaseHttpResponseInterface<TResponse>>;
|
|
51
16
|
}
|
|
52
17
|
export default FibaseAppClient;
|