@spritz-finance/service-client 0.5.6 → 0.5.8
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/lib/bridge/bridgeServiceClient.d.ts +1 -1
- package/lib/bridge/bridgeServiceClient.js +24 -14
- package/lib/bridge/types.d.ts +4 -4
- package/lib/checkbook/checkbookServiceClient.d.ts +6 -4
- package/lib/checkbook/checkbookServiceClient.js +24 -12
- package/lib/config.js +59 -59
- package/lib/createGraphClient.d.ts +1 -1
- package/lib/createGraphClient.js +6 -5
- package/lib/credentials.js +25 -15
- package/lib/exchangeRates/exchangeRatesServiceClient.d.ts +2 -2
- package/lib/exchangeRates/exchangeRatesServiceClient.js +21 -11
- package/lib/features/featuresServiceClient.js +24 -16
- package/lib/graphClient.d.ts +2 -2
- package/lib/graphClient.js +1 -1
- package/lib/growth/growthServiceClient.d.ts +4 -4
- package/lib/growth/growthServiceClient.js +24 -14
- package/lib/growth/types.d.ts +1 -1
- package/lib/index.d.ts +38 -38
- package/lib/liabilities/liabilitiesServiceClient.d.ts +8 -8
- package/lib/liabilities/liabilitiesServiceClient.js +37 -27
- package/lib/liabilities/types.d.ts +12 -12
- package/lib/lib/graphClient/generated.d.ts +123 -38
- package/lib/lib/graphClient/generated.js +7 -16
- package/lib/onramp/onrampServiceClient.d.ts +4 -4
- package/lib/onramp/onrampServiceClient.js +23 -13
- package/lib/onramp/types.d.ts +1 -1
- package/lib/params.d.ts +1 -1
- package/lib/params.js +3 -2
- package/lib/payableAccounts/payableAccountsServiceClient.d.ts +35 -35
- package/lib/payableAccounts/payableAccountsServiceClient.js +30 -20
- package/lib/payableAccounts/types.d.ts +8 -8
- package/lib/paymentAddress/paymentAddressServiceClient.d.ts +1 -1
- package/lib/paymentAddress/paymentAddressServiceClient.js +20 -10
- package/lib/payments/paymentsClient.d.ts +4 -4
- package/lib/payments/paymentsClient.js +35 -25
- package/lib/payments/types.d.ts +4 -4
- package/lib/payments/types.js +1 -1
- package/lib/payouts/payoutsServiceClient.d.ts +3 -3
- package/lib/payouts/payoutsServiceClient.js +24 -14
- package/lib/payouts/types.d.ts +7 -7
- package/lib/payouts/types.js +2 -10
- package/lib/platform/platformServiceClient.d.ts +3 -2
- package/lib/platform/platformServiceClient.js +27 -10
- package/lib/platform/types.d.ts +6 -0
- package/lib/rain/rainServiceClient.d.ts +1 -1
- package/lib/rain/rainServiceClient.js +31 -21
- package/lib/serviceClient.d.ts +1 -1
- package/lib/serviceClient.js +7 -6
- package/lib/transactions/transactionsServiceClient.d.ts +2 -2
- package/lib/transactions/transactionsServiceClient.js +25 -15
- package/lib/types.d.ts +5 -5
- package/lib/unblock/unblockServiceClient.d.ts +3 -3
- package/lib/unblock/unblockServiceClient.js +28 -20
- package/lib/users/usersServiceClient.d.ts +4 -4
- package/lib/users/usersServiceClient.js +27 -17
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +10 -13
- package/lib/verification/types.d.ts +1 -1
- package/lib/verification/verificationServiceClient.js +25 -15
- package/lib/web3/web3ServiceClient.d.ts +2 -2
- package/lib/web3/web3ServiceClient.js +26 -16
- package/package.json +11 -10
- package/lib/graphClient.test.d.ts +0 -1
- package/lib/graphClient.test.js +0 -121
- package/lib/serviceClient.test.d.ts +0 -1
- package/lib/serviceClient.test.js +0 -187
|
@@ -7,7 +7,7 @@ export declare function getTransferHashes(externalPaymentIds: string[]): Promise
|
|
|
7
7
|
hash: string | null;
|
|
8
8
|
}>>;
|
|
9
9
|
export declare function createBridgeBankAccount(userId: string, accountId: string, input: CreateBridgeAccountParams): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<BridgeExternalAccount>>;
|
|
10
|
-
export declare function getBridgeUser(userId: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<BridgeUser>>;
|
|
10
|
+
export declare function getBridgeUser(userId: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<BridgeUser | null>>;
|
|
11
11
|
export declare function validateTransfer({ userId, transferId, amount, toAddress, }: {
|
|
12
12
|
userId: string;
|
|
13
13
|
transferId: string;
|
|
@@ -15,15 +15,31 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
36
|
+
exports.BridgeClient = void 0;
|
|
37
|
+
exports.getTransferHashes = getTransferHashes;
|
|
38
|
+
exports.createBridgeBankAccount = createBridgeBankAccount;
|
|
39
|
+
exports.getBridgeUser = getBridgeUser;
|
|
40
|
+
exports.validateTransfer = validateTransfer;
|
|
41
|
+
exports.createBridgeTransfer = createBridgeTransfer;
|
|
42
|
+
exports.getExternalPayments = getExternalPayments;
|
|
27
43
|
exports.BridgeClient = __importStar(require("./bridgeServiceClient"));
|
|
28
44
|
const serviceClient_1 = require("../serviceClient");
|
|
29
45
|
const ONRAMP_ENDPOINT = "/bridge";
|
|
@@ -33,19 +49,16 @@ async function getTransferHashes(externalPaymentIds) {
|
|
|
33
49
|
.post(`${ONRAMP_ROUTER_ENDPOINT}/off-ramps/blockchain-transactions`, { externalPaymentIds })
|
|
34
50
|
.then((res) => res.data);
|
|
35
51
|
}
|
|
36
|
-
exports.getTransferHashes = getTransferHashes;
|
|
37
52
|
async function createBridgeBankAccount(userId, accountId, input) {
|
|
38
53
|
return serviceClient_1.baseClient
|
|
39
54
|
.post(`${ONRAMP_ENDPOINT}/user/${userId}/bank-account/${accountId}`, input)
|
|
40
55
|
.then((res) => res.data);
|
|
41
56
|
}
|
|
42
|
-
exports.createBridgeBankAccount = createBridgeBankAccount;
|
|
43
57
|
async function getBridgeUser(userId) {
|
|
44
58
|
return serviceClient_1.baseClient
|
|
45
59
|
.get(`${ONRAMP_ENDPOINT}/user/${userId}`)
|
|
46
60
|
.then((res) => res.data);
|
|
47
61
|
}
|
|
48
|
-
exports.getBridgeUser = getBridgeUser;
|
|
49
62
|
async function validateTransfer({ userId, transferId, amount, toAddress, }) {
|
|
50
63
|
return serviceClient_1.baseClient
|
|
51
64
|
.post(`${ONRAMP_ENDPOINT}/transfer/validate`, {
|
|
@@ -56,16 +69,13 @@ async function validateTransfer({ userId, transferId, amount, toAddress, }) {
|
|
|
56
69
|
})
|
|
57
70
|
.then((res) => res.data);
|
|
58
71
|
}
|
|
59
|
-
exports.validateTransfer = validateTransfer;
|
|
60
72
|
async function createBridgeTransfer(userId, input) {
|
|
61
73
|
return serviceClient_1.baseClient
|
|
62
74
|
.post(`${ONRAMP_ENDPOINT}/user/${userId}/transfer`, input)
|
|
63
75
|
.then((res) => res.data);
|
|
64
76
|
}
|
|
65
|
-
exports.createBridgeTransfer = createBridgeTransfer;
|
|
66
77
|
async function getExternalPayments(paymentIds) {
|
|
67
78
|
return serviceClient_1.baseClient
|
|
68
79
|
.get(`${ONRAMP_ENDPOINT}/external-payments?paymentIds=${paymentIds.join(",")}`)
|
|
69
80
|
.then((res) => res.data);
|
|
70
81
|
}
|
|
71
|
-
exports.getExternalPayments = getExternalPayments;
|
package/lib/bridge/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type BridgeExternalAccount = {
|
|
|
6
6
|
active: boolean;
|
|
7
7
|
createdAt: string;
|
|
8
8
|
account: {
|
|
9
|
-
checking_or_savings:
|
|
9
|
+
checking_or_savings: "checking" | "savings";
|
|
10
10
|
routing_number: string;
|
|
11
11
|
last_4: string;
|
|
12
12
|
};
|
|
@@ -16,7 +16,7 @@ export type CreateBridgeAccountParams = {
|
|
|
16
16
|
accountName: string;
|
|
17
17
|
ownerFirstName: string;
|
|
18
18
|
ownerLastName: string;
|
|
19
|
-
accountType:
|
|
19
|
+
accountType: "checking" | "savings";
|
|
20
20
|
address: {
|
|
21
21
|
street_line_1: string;
|
|
22
22
|
street_line_2: string | null | undefined;
|
|
@@ -26,11 +26,11 @@ export type CreateBridgeAccountParams = {
|
|
|
26
26
|
country: string;
|
|
27
27
|
};
|
|
28
28
|
} & ({
|
|
29
|
-
type:
|
|
29
|
+
type: "us";
|
|
30
30
|
accountNumber: string;
|
|
31
31
|
routingNumber: string;
|
|
32
32
|
} | {
|
|
33
|
-
type:
|
|
33
|
+
type: "iban";
|
|
34
34
|
iban: string;
|
|
35
35
|
bic?: string;
|
|
36
36
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export * as CheckbookClient from
|
|
2
|
-
import { RunBatchConfig } from
|
|
3
|
-
export declare function triggerBatch({ config, currency, }: {
|
|
4
|
-
config
|
|
1
|
+
export * as CheckbookClient from "./checkbookServiceClient";
|
|
2
|
+
import { RunBatchConfig } from "./types";
|
|
3
|
+
export declare function triggerBatch({ config, configs, reserve, currency, }: {
|
|
4
|
+
config?: RunBatchConfig;
|
|
5
|
+
configs?: RunBatchConfig[];
|
|
6
|
+
reserve?: number;
|
|
5
7
|
currency: string;
|
|
6
8
|
}): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<boolean>>;
|
|
7
9
|
export declare function getBatchBalances(): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<{
|
|
@@ -15,30 +15,42 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
36
|
+
exports.CheckbookClient = void 0;
|
|
37
|
+
exports.triggerBatch = triggerBatch;
|
|
38
|
+
exports.getBatchBalances = getBatchBalances;
|
|
27
39
|
exports.CheckbookClient = __importStar(require("./checkbookServiceClient"));
|
|
28
40
|
const serviceClient_1 = require("../serviceClient");
|
|
29
|
-
const CHECKBOOK_ENDPOINT =
|
|
30
|
-
async function triggerBatch({ config, currency, }) {
|
|
41
|
+
const CHECKBOOK_ENDPOINT = "/liabilities";
|
|
42
|
+
async function triggerBatch({ config, configs, reserve, currency, }) {
|
|
31
43
|
return serviceClient_1.baseClient
|
|
32
44
|
.post(`${CHECKBOOK_ENDPOINT}/checkbook/batch`, {
|
|
33
45
|
config,
|
|
34
46
|
currency,
|
|
47
|
+
reserve,
|
|
48
|
+
configs,
|
|
35
49
|
})
|
|
36
50
|
.then((res) => res.data);
|
|
37
51
|
}
|
|
38
|
-
exports.triggerBatch = triggerBatch;
|
|
39
52
|
async function getBatchBalances() {
|
|
40
53
|
return serviceClient_1.baseClient
|
|
41
54
|
.get(`${CHECKBOOK_ENDPOINT}/checkbook/batch/balances`)
|
|
42
55
|
.then((res) => res.data);
|
|
43
56
|
}
|
|
44
|
-
exports.getBatchBalances = getBatchBalances;
|
package/lib/config.js
CHANGED
|
@@ -5,71 +5,71 @@ exports.config = void 0;
|
|
|
5
5
|
const config_1 = require("@spritz-finance/config");
|
|
6
6
|
const envConfigs = {
|
|
7
7
|
base: {
|
|
8
|
-
env: (_b = (_a = process.env.STAGE) !== null && _a !== void 0 ? _a : process.env.NODE_ENV) !== null && _b !== void 0 ? _b :
|
|
9
|
-
region: (_c = process.env.REGION) !== null && _c !== void 0 ? _c :
|
|
10
|
-
serviceClientKeyArn: (_d = process.env.SERVICE_CLIENT_KEY_ARN) !== null && _d !== void 0 ? _d :
|
|
11
|
-
baseEndpoint:
|
|
12
|
-
authEndpoint:
|
|
13
|
-
graphEndpoint:
|
|
14
|
-
verificationServiceEndpoint:
|
|
15
|
-
transactionsServiceEndpoint:
|
|
16
|
-
usersServiceEndpoint:
|
|
17
|
-
liabilitiesServiceEndpoint:
|
|
18
|
-
payableAccountsServiceEndpoint:
|
|
19
|
-
growthServiceEndpoint:
|
|
20
|
-
exchangeRatesServiceEndpoint:
|
|
21
|
-
web3ServiceEndpoint:
|
|
22
|
-
unblockServiceEndpoint:
|
|
23
|
-
onrampServiceEndpoint:
|
|
24
|
-
platformEndpoint:
|
|
8
|
+
env: (_b = (_a = process.env.STAGE) !== null && _a !== void 0 ? _a : process.env.NODE_ENV) !== null && _b !== void 0 ? _b : "dev",
|
|
9
|
+
region: (_c = process.env.REGION) !== null && _c !== void 0 ? _c : "us-east-1",
|
|
10
|
+
serviceClientKeyArn: (_d = process.env.SERVICE_CLIENT_KEY_ARN) !== null && _d !== void 0 ? _d : "",
|
|
11
|
+
baseEndpoint: "https://api-dev.spritz.finance",
|
|
12
|
+
authEndpoint: "https://auth-dev.spritz.finance/oauth2/token",
|
|
13
|
+
graphEndpoint: "https://api-dev.spritz.finance/graphql",
|
|
14
|
+
verificationServiceEndpoint: "https://api-dev.spritz.finance/verification",
|
|
15
|
+
transactionsServiceEndpoint: "https://api-dev.spritz.finance/transactions",
|
|
16
|
+
usersServiceEndpoint: "https://api-dev.spritz.finance/users",
|
|
17
|
+
liabilitiesServiceEndpoint: "https://api-dev.spritz.finance/liabilities",
|
|
18
|
+
payableAccountsServiceEndpoint: "https://api-dev.spritz.finance/payable-accounts",
|
|
19
|
+
growthServiceEndpoint: "https://api-dev.spritz.finance/growth",
|
|
20
|
+
exchangeRatesServiceEndpoint: "https://api-dev.spritz.finance/exchange-rates",
|
|
21
|
+
web3ServiceEndpoint: "https://api-dev.spritz.finance/web3",
|
|
22
|
+
unblockServiceEndpoint: "https://api-dev.spritz.finance/unblock",
|
|
23
|
+
onrampServiceEndpoint: "https://api-dev.spritz.finance/bridge",
|
|
24
|
+
platformEndpoint: "http://internal-InternalApiLoad-kzfntbsu-1503066598.us-east-1.elb.amazonaws.com:50051",
|
|
25
25
|
},
|
|
26
26
|
test: {
|
|
27
|
-
env:
|
|
28
|
-
authEndpoint:
|
|
29
|
-
baseEndpoint:
|
|
30
|
-
graphEndpoint:
|
|
31
|
-
verificationServiceEndpoint:
|
|
32
|
-
transactionsServiceEndpoint:
|
|
33
|
-
usersServiceEndpoint:
|
|
34
|
-
liabilitiesServiceEndpoint:
|
|
35
|
-
payableAccountsServiceEndpoint:
|
|
36
|
-
growthServiceEndpoint:
|
|
37
|
-
exchangeRatesServiceEndpoint:
|
|
38
|
-
web3ServiceEndpoint:
|
|
39
|
-
onrampServiceEndpoint:
|
|
40
|
-
platformEndpoint:
|
|
27
|
+
env: "staging",
|
|
28
|
+
authEndpoint: "https://auth-staging.spritz.finance/oauth2/token",
|
|
29
|
+
baseEndpoint: "https://api-staging.spritz.finance",
|
|
30
|
+
graphEndpoint: "https://api-staging.spritz.finance/router/graph",
|
|
31
|
+
verificationServiceEndpoint: "https://api-staging.spritz.finance/verification",
|
|
32
|
+
transactionsServiceEndpoint: "https://api-staging.spritz.finance/transactions",
|
|
33
|
+
usersServiceEndpoint: "https://api-staging.spritz.finance/users",
|
|
34
|
+
liabilitiesServiceEndpoint: "https://api-staging.spritz.finance/liabilities",
|
|
35
|
+
payableAccountsServiceEndpoint: "https://api-staging.spritz.finance/payable-accounts",
|
|
36
|
+
growthServiceEndpoint: "https://api-staging.spritz.finance/growth",
|
|
37
|
+
exchangeRatesServiceEndpoint: "https://api-staging.spritz.finance/exchange-rates",
|
|
38
|
+
web3ServiceEndpoint: "https://api-staging.spritz.finance/web3",
|
|
39
|
+
onrampServiceEndpoint: "https://api-staging.spritz.finance/bridge",
|
|
40
|
+
platformEndpoint: "http://internal-InternalApiLoad-kzfntbsu-1503066598.us-east-1.elb.amazonaws.com:50051",
|
|
41
41
|
},
|
|
42
42
|
staging: {
|
|
43
|
-
baseEndpoint:
|
|
44
|
-
authEndpoint:
|
|
45
|
-
graphEndpoint:
|
|
46
|
-
verificationServiceEndpoint:
|
|
47
|
-
transactionsServiceEndpoint:
|
|
48
|
-
usersServiceEndpoint:
|
|
49
|
-
liabilitiesServiceEndpoint:
|
|
50
|
-
payableAccountsServiceEndpoint:
|
|
51
|
-
growthServiceEndpoint:
|
|
52
|
-
exchangeRatesServiceEndpoint:
|
|
53
|
-
web3ServiceEndpoint:
|
|
54
|
-
unblockServiceEndpoint:
|
|
55
|
-
onrampServiceEndpoint:
|
|
56
|
-
platformEndpoint:
|
|
43
|
+
baseEndpoint: "https://api-staging.spritz.finance",
|
|
44
|
+
authEndpoint: "https://auth-staging.spritz.finance/oauth2/token",
|
|
45
|
+
graphEndpoint: "https://api-staging.spritz.finance/router/graph",
|
|
46
|
+
verificationServiceEndpoint: "https://api-staging.spritz.finance/verification",
|
|
47
|
+
transactionsServiceEndpoint: "https://api-staging.spritz.finance/transactions",
|
|
48
|
+
usersServiceEndpoint: "https://api-staging.spritz.finance/users",
|
|
49
|
+
liabilitiesServiceEndpoint: "https://api-staging.spritz.finance/liabilities",
|
|
50
|
+
payableAccountsServiceEndpoint: "https://api-staging.spritz.finance/payable-accounts",
|
|
51
|
+
growthServiceEndpoint: "https://api-staging.spritz.finance/growth",
|
|
52
|
+
exchangeRatesServiceEndpoint: "https://api-staging.spritz.finance/exchange-rates",
|
|
53
|
+
web3ServiceEndpoint: "https://api-staging.spritz.finance/web3",
|
|
54
|
+
unblockServiceEndpoint: "https://api-staging.spritz.finance/unblock",
|
|
55
|
+
onrampServiceEndpoint: "https://api-staging.spritz.finance/bridge",
|
|
56
|
+
platformEndpoint: "http://internal-InternalApiLoad-kzfntbsu-1503066598.us-east-1.elb.amazonaws.com:50051",
|
|
57
57
|
},
|
|
58
58
|
production: {
|
|
59
|
-
baseEndpoint:
|
|
60
|
-
authEndpoint:
|
|
61
|
-
graphEndpoint:
|
|
62
|
-
verificationServiceEndpoint:
|
|
63
|
-
transactionsServiceEndpoint:
|
|
64
|
-
usersServiceEndpoint:
|
|
65
|
-
liabilitiesServiceEndpoint:
|
|
66
|
-
payableAccountsServiceEndpoint:
|
|
67
|
-
growthServiceEndpoint:
|
|
68
|
-
exchangeRatesServiceEndpoint:
|
|
69
|
-
web3ServiceEndpoint:
|
|
70
|
-
unblockServiceEndpoint:
|
|
71
|
-
onrampServiceEndpoint:
|
|
72
|
-
platformEndpoint:
|
|
59
|
+
baseEndpoint: "https://api.spritz.finance",
|
|
60
|
+
authEndpoint: "https://auth.spritz.finance/oauth2/token",
|
|
61
|
+
graphEndpoint: "https://api.spritz.finance/router/graph",
|
|
62
|
+
verificationServiceEndpoint: "https://api.spritz.finance/verification",
|
|
63
|
+
transactionsServiceEndpoint: "https://api.spritz.finance/transactions",
|
|
64
|
+
usersServiceEndpoint: "https://api.spritz.finance/users",
|
|
65
|
+
liabilitiesServiceEndpoint: "https://api.spritz.finance/liabilities",
|
|
66
|
+
payableAccountsServiceEndpoint: "https://api.spritz.finance/payable-accounts",
|
|
67
|
+
growthServiceEndpoint: "https://api.spritz.finance/growth",
|
|
68
|
+
exchangeRatesServiceEndpoint: "https://api.spritz.finance/exchange-rates",
|
|
69
|
+
web3ServiceEndpoint: "https://api.spritz.finance/web3",
|
|
70
|
+
unblockServiceEndpoint: "https://api.spritz.finance/unblock",
|
|
71
|
+
onrampServiceEndpoint: "https://api.spritz.finance/bridge",
|
|
72
|
+
platformEndpoint: "http://internal-InternalApiLoad-htweehsc-1470283600.us-east-1.elb.amazonaws.com:50051",
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
75
|
exports.config = (0, config_1.setupEnvConfig)(envConfigs);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from
|
|
1
|
+
import { AxiosRequestConfig } from "axios";
|
|
2
2
|
export declare const createGraphClient: (config: AxiosRequestConfig) => import("axios").AxiosInstance;
|
package/lib/createGraphClient.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createGraphClient = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
// @ts-expect-error no type declarations for axios-token-interceptor
|
|
8
9
|
const axios_token_interceptor_1 = __importDefault(require("axios-token-interceptor"));
|
|
9
10
|
const logger_1 = __importDefault(require("@spritz-finance/logger"));
|
|
10
11
|
const credentials_1 = require("./credentials");
|
|
@@ -13,7 +14,7 @@ const getMaxAge = (res) => {
|
|
|
13
14
|
return res.expires_in * 1000 - EXPIRATION_BUFFER_MS;
|
|
14
15
|
};
|
|
15
16
|
const headerFormatter = (res) => {
|
|
16
|
-
return
|
|
17
|
+
return "Bearer " + res.access_token;
|
|
17
18
|
};
|
|
18
19
|
const interceptor = function (tokenProvider, authenticate) {
|
|
19
20
|
const getToken = tokenProvider.tokenCache(authenticate, { getMaxAge });
|
|
@@ -28,18 +29,18 @@ const createGraphClient = (config) => {
|
|
|
28
29
|
requestConfig.headers = requestConfig.headers || {};
|
|
29
30
|
const correlationId = (_a = logger_1.default.defaultMeta) === null || _a === void 0 ? void 0 : _a.correlationId;
|
|
30
31
|
if (correlationId) {
|
|
31
|
-
requestConfig.headers[
|
|
32
|
+
requestConfig.headers["x-correlation-id"] = correlationId;
|
|
32
33
|
}
|
|
33
34
|
const annotations = (_b = logger_1.default.defaultMeta) === null || _b === void 0 ? void 0 : _b.annotations;
|
|
34
35
|
if (annotations) {
|
|
35
36
|
if (annotations.requestId) {
|
|
36
|
-
requestConfig.headers[
|
|
37
|
+
requestConfig.headers["x-request-id"] = annotations.requestId;
|
|
37
38
|
}
|
|
38
39
|
if (annotations.userId) {
|
|
39
|
-
requestConfig.headers[
|
|
40
|
+
requestConfig.headers["x-user-id"] = annotations.userId;
|
|
40
41
|
}
|
|
41
42
|
const currentDepth = annotations.depth || 0;
|
|
42
|
-
requestConfig.headers[
|
|
43
|
+
requestConfig.headers["x-request-depth"] = String(currentDepth + 1);
|
|
43
44
|
}
|
|
44
45
|
return requestConfig;
|
|
45
46
|
});
|
package/lib/credentials.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -36,17 +46,17 @@ const qs = __importStar(require("qs"));
|
|
|
36
46
|
const config_1 = require("./config");
|
|
37
47
|
const params_1 = require("./params");
|
|
38
48
|
function createSecret(key) {
|
|
39
|
-
return (0, crypto_1.createSecretKey)(Buffer.from(key,
|
|
49
|
+
return (0, crypto_1.createSecretKey)(Uint8Array.from(Buffer.from(key, "utf8")));
|
|
40
50
|
}
|
|
41
51
|
async function createJWT(secretKey, expMinutes = 30) {
|
|
42
52
|
const now = Math.floor(Date.now() / 1000);
|
|
43
53
|
const expirationTime = new Date(Date.now() + expMinutes * 60 * 1000);
|
|
44
54
|
return new jose_1.SignJWT({
|
|
45
55
|
iat: now,
|
|
46
|
-
iss:
|
|
47
|
-
sub:
|
|
56
|
+
iss: "spritz-service-client",
|
|
57
|
+
sub: "service-auth",
|
|
48
58
|
})
|
|
49
|
-
.setProtectedHeader({ alg:
|
|
59
|
+
.setProtectedHeader({ alg: "HS256" })
|
|
50
60
|
.setExpirationTime(expirationTime)
|
|
51
61
|
.setIssuedAt(now)
|
|
52
62
|
.sign(secretKey);
|
|
@@ -54,7 +64,7 @@ async function createJWT(secretKey, expMinutes = 30) {
|
|
|
54
64
|
async function getServiceClientKey() {
|
|
55
65
|
const arn = config_1.config.serviceClientKeyArn;
|
|
56
66
|
if (!arn)
|
|
57
|
-
throw new Error(
|
|
67
|
+
throw new Error("serviceClientKeyArn is not set");
|
|
58
68
|
const client = new client_secrets_manager_1.SecretsManagerClient({ region: config_1.config.region });
|
|
59
69
|
const command = new client_secrets_manager_1.GetSecretValueCommand({ SecretId: arn });
|
|
60
70
|
const response = await client.send(command);
|
|
@@ -64,7 +74,7 @@ const getServiceCredentials = async () => {
|
|
|
64
74
|
try {
|
|
65
75
|
const key = await getServiceClientKey();
|
|
66
76
|
if (!key) {
|
|
67
|
-
throw new Error(
|
|
77
|
+
throw new Error("Failed to get service client key");
|
|
68
78
|
}
|
|
69
79
|
const secretKey = createSecret(key);
|
|
70
80
|
const jwt = await createJWT(secretKey);
|
|
@@ -82,8 +92,8 @@ const getGraphCredentials = async () => {
|
|
|
82
92
|
const clientSecretParam = `/${config_1.config.env}/auth/serviceClientSecret`;
|
|
83
93
|
const paramsByKey = await (0, params_1.getParams)([clientIdParam, clientSecretParam]);
|
|
84
94
|
const { data } = await axios_1.default.post(config_1.config.authEndpoint, qs.stringify({
|
|
85
|
-
grant_type:
|
|
86
|
-
scope:
|
|
95
|
+
grant_type: "client_credentials",
|
|
96
|
+
scope: "spritz/service",
|
|
87
97
|
client_id: paramsByKey[clientIdParam],
|
|
88
98
|
client_secret: paramsByKey[clientSecretParam],
|
|
89
99
|
}));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * as ExchangeRatesClient from
|
|
2
|
-
import { ExchangeRate } from
|
|
1
|
+
export * as ExchangeRatesClient from "./exchangeRatesServiceClient";
|
|
2
|
+
import { ExchangeRate } from "./types";
|
|
3
3
|
export declare function getLatestRate(target: string, base?: string): Promise<ExchangeRate>;
|
|
@@ -15,19 +15,30 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
36
|
+
exports.ExchangeRatesClient = void 0;
|
|
37
|
+
exports.getLatestRate = getLatestRate;
|
|
27
38
|
exports.ExchangeRatesClient = __importStar(require("./exchangeRatesServiceClient"));
|
|
28
39
|
const serviceClient_1 = require("../serviceClient");
|
|
29
|
-
const EXCHANGE_RATE_ENDPOINT =
|
|
30
|
-
async function getLatestRate(target, base =
|
|
40
|
+
const EXCHANGE_RATE_ENDPOINT = "/exchange-rates";
|
|
41
|
+
async function getLatestRate(target, base = "USD") {
|
|
31
42
|
return serviceClient_1.baseClient
|
|
32
43
|
.get(`${EXCHANGE_RATE_ENDPOINT}/latest`, {
|
|
33
44
|
params: {
|
|
@@ -37,4 +48,3 @@ async function getLatestRate(target, base = 'USD') {
|
|
|
37
48
|
})
|
|
38
49
|
.then((res) => res.data);
|
|
39
50
|
}
|
|
40
|
-
exports.getLatestRate = getLatestRate;
|
|
@@ -15,15 +15,30 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
36
|
+
exports.FeaturesClient = void 0;
|
|
37
|
+
exports.updateFeatureFlag = updateFeatureFlag;
|
|
38
|
+
exports.getFeatureFlags = getFeatureFlags;
|
|
39
|
+
exports.isFeatureFlagEnabled = isFeatureFlagEnabled;
|
|
40
|
+
exports.isPaymentsEnabled = isPaymentsEnabled;
|
|
41
|
+
exports.isFeatureEnabled = isFeatureEnabled;
|
|
27
42
|
exports.FeaturesClient = __importStar(require("./featuresServiceClient"));
|
|
28
43
|
const serviceClient_1 = require("../serviceClient");
|
|
29
44
|
const utils_1 = require("../utils");
|
|
@@ -67,13 +82,9 @@ function updateFeatureFlag(input) {
|
|
|
67
82
|
};
|
|
68
83
|
return serviceClient_1.baseClient.post(FEATURES_ENDPOINT, payload);
|
|
69
84
|
}
|
|
70
|
-
exports.updateFeatureFlag = updateFeatureFlag;
|
|
71
85
|
async function getFeatureFlags() {
|
|
72
|
-
return serviceClient_1.baseClient
|
|
73
|
-
.get(FEATURES_ENDPOINT)
|
|
74
|
-
.then((res) => res.data);
|
|
86
|
+
return serviceClient_1.baseClient.get(FEATURES_ENDPOINT).then((res) => res.data);
|
|
75
87
|
}
|
|
76
|
-
exports.getFeatureFlags = getFeatureFlags;
|
|
77
88
|
async function isFeatureFlagEnabled(flag) {
|
|
78
89
|
var _a, _b;
|
|
79
90
|
const response = await getFeatureFlags();
|
|
@@ -82,7 +93,6 @@ async function isFeatureFlagEnabled(flag) {
|
|
|
82
93
|
const flags = response.data;
|
|
83
94
|
return (_b = (_a = flags[flag]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : false;
|
|
84
95
|
}
|
|
85
|
-
exports.isFeatureFlagEnabled = isFeatureFlagEnabled;
|
|
86
96
|
async function getFlags() {
|
|
87
97
|
const response = await getFeatureFlags();
|
|
88
98
|
if ((0, utils_1.isApiError)(response))
|
|
@@ -102,7 +112,6 @@ async function isPaymentsEnabled(network, allFlags) {
|
|
|
102
112
|
// this will default to true if we have not handled the network yet
|
|
103
113
|
return networkFlag ? ((_c = (_b = flags[networkFlag]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : true) : true;
|
|
104
114
|
}
|
|
105
|
-
exports.isPaymentsEnabled = isPaymentsEnabled;
|
|
106
115
|
/**
|
|
107
116
|
* Synchronously checks if a feature flag is enabled from a provided flags object.
|
|
108
117
|
* Use this when you already have the flags and want to avoid refetching them.
|
|
@@ -114,4 +123,3 @@ async function isFeatureEnabled(flag, allFlags) {
|
|
|
114
123
|
return false;
|
|
115
124
|
return (_b = (_a = flags[flag]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : false;
|
|
116
125
|
}
|
|
117
|
-
exports.isFeatureEnabled = isFeatureEnabled;
|
package/lib/graphClient.d.ts
CHANGED
package/lib/graphClient.js
CHANGED
|
@@ -13,7 +13,7 @@ class GraphClient {
|
|
|
13
13
|
async query({ query, variables }) {
|
|
14
14
|
var _a, _b, _c;
|
|
15
15
|
return this.client
|
|
16
|
-
.post(
|
|
16
|
+
.post("", {
|
|
17
17
|
query: (0, graphql_1.print)(query),
|
|
18
18
|
variables,
|
|
19
19
|
operationName: (_c = (_b = (_a = query === null || query === void 0 ? void 0 : query.definitions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.value,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * as GrowthClient from
|
|
2
|
-
import { PayableAccountType } from
|
|
3
|
-
import { PointsRedemption, PointsRedemptionOption } from
|
|
4
|
-
export declare function getUserReferrer(userId: string): Promise<string>;
|
|
1
|
+
export * as GrowthClient from "./growthServiceClient";
|
|
2
|
+
import { PayableAccountType } from "../lib/graphClient/generated";
|
|
3
|
+
import { PointsRedemption, PointsRedemptionOption } from "./types";
|
|
4
|
+
export declare function getUserReferrer(userId: string): Promise<string | null>;
|
|
5
5
|
export declare function initializePointsRedemption(input: {
|
|
6
6
|
userId: string;
|
|
7
7
|
paymentRequestId: string;
|