paj_ramp 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -4
- package/dist/lib/{core → utility/bank}/addBankAccount.js +2 -2
- package/dist/lib/{core → utility/bank}/getBankAccounts.js +2 -2
- package/dist/lib/{off_ramp → utility/bank}/getBanks.js +1 -1
- package/dist/lib/{off_ramp → utility/bank}/resolveBankAccount.js +1 -1
- package/dist/lib/{off_ramp → utility/deprecated}/addWallet.js +2 -2
- package/dist/lib/{core → utility/deprecated}/getTXPoolAddress.js +1 -1
- package/dist/lib/{core → utility/deprecated}/getWallet.js +1 -1
- package/dist/lib/{core → utility/deprecated}/switchWalletBankAccount.js +2 -2
- package/dist/lib/{core → utility/rate}/getAllRate.js +1 -1
- package/dist/lib/{core → utility/rate}/getRateByAmount.js +1 -1
- package/dist/lib/{core → utility/rate}/getRateByType.d.ts +1 -1
- package/dist/lib/{core → utility/rate}/getRateByType.js +1 -1
- package/dist/lib/{core → utility/rate}/getTokenValue.js +1 -1
- package/dist/lib/utility/session/initiate.d.ts +5 -0
- package/dist/lib/utility/session/initiate.js +18 -0
- package/dist/lib/utility/session/verify.d.ts +15 -0
- package/dist/lib/utility/session/verify.js +15 -0
- package/dist/lib/{core → utility/transaction}/getAllTransactions.js +1 -1
- package/dist/lib/{core → utility/transaction}/getTransaction.d.ts +1 -1
- package/dist/lib/{core → utility/transaction}/getTransaction.js +1 -1
- package/dist/sdk.d.ts +12 -12
- package/dist/sdk.js +13 -13
- package/lib/utility/{addBankAccount.ts → bank/addBankAccount.ts} +2 -2
- package/lib/utility/{getBankAccounts.ts → bank/getBankAccounts.ts} +2 -2
- package/lib/utility/{getBanks.ts → bank/getBanks.ts} +1 -1
- package/lib/utility/{resolveBankAccount.ts → bank/resolveBankAccount.ts} +1 -1
- package/lib/utility/{addWallet.ts → deprecated/addWallet.ts} +2 -2
- package/lib/utility/{getTXPoolAddress.ts → deprecated/getTXPoolAddress.ts} +1 -1
- package/lib/utility/{getWallet.ts → deprecated/getWallet.ts} +1 -1
- package/lib/utility/{switchWalletBankAccount.ts → deprecated/switchWalletBankAccount.ts} +2 -2
- package/lib/utility/{getAllRate.ts → rate/getAllRate.ts} +1 -2
- package/lib/utility/{getRateByAmount.ts → rate/getRateByAmount.ts} +1 -1
- package/lib/utility/{getRateByType.ts → rate/getRateByType.ts} +2 -2
- package/lib/utility/{getTokenValue.ts → rate/getTokenValue.ts} +2 -5
- package/lib/utility/session/initiate.ts +22 -0
- package/lib/utility/session/verify.ts +35 -0
- package/lib/utility/{getAllTransactions.ts → transaction/getAllTransactions.ts} +1 -1
- package/lib/utility/{getTransaction.ts → transaction/getTransaction.ts} +2 -2
- package/package.json +1 -1
- package/sdk.ts +12 -12
- package/dist/lib/core/addWallet.js +0 -27
- package/dist/lib/core/getAllTranstions.d.ts +0 -12
- package/dist/lib/core/getAllTranstions.js +0 -18
- package/dist/lib/core/getBanks.js +0 -22
- package/dist/lib/core/initiate.d.ts +0 -18
- package/dist/lib/core/initiate.js +0 -23
- package/dist/lib/core/resolveBankAccount.js +0 -26
- package/dist/lib/core/verify.d.ts +0 -30
- package/dist/lib/core/verify.js +0 -29
- package/dist/lib/direct_off_ramp/directCreateOrder.d.ts +0 -19
- package/dist/lib/direct_off_ramp/directCreateOrder.js +0 -23
- package/dist/lib/off_ramp/addBankAccount.d.ts +0 -23
- package/dist/lib/off_ramp/addBankAccount.js +0 -30
- package/dist/lib/off_ramp/addWallet.d.ts +0 -12
- package/dist/lib/off_ramp/getAllRate.d.ts +0 -27
- package/dist/lib/off_ramp/getAllRate.js +0 -20
- package/dist/lib/off_ramp/getBankAccounts.d.ts +0 -18
- package/dist/lib/off_ramp/getBankAccounts.js +0 -22
- package/dist/lib/off_ramp/getBanks.d.ts +0 -17
- package/dist/lib/off_ramp/getRate.d.ts +0 -110
- package/dist/lib/off_ramp/getRate.js +0 -106
- package/dist/lib/off_ramp/getRateByAmount.d.ts +0 -27
- package/dist/lib/off_ramp/getRateByAmount.js +0 -23
- package/dist/lib/off_ramp/getRateByType.d.ts +0 -21
- package/dist/lib/off_ramp/getRateByType.js +0 -24
- package/dist/lib/off_ramp/getTXPoolAddress.d.ts +0 -13
- package/dist/lib/off_ramp/getTXPoolAddress.js +0 -20
- package/dist/lib/off_ramp/getTokenValue.d.ts +0 -20
- package/dist/lib/off_ramp/getTokenValue.js +0 -24
- package/dist/lib/off_ramp/getWallet.d.ts +0 -24
- package/dist/lib/off_ramp/getWallet.js +0 -23
- package/dist/lib/off_ramp/initiate.d.ts +0 -18
- package/dist/lib/off_ramp/initiate.js +0 -23
- package/dist/lib/off_ramp/resolveBankAccount.d.ts +0 -26
- package/dist/lib/off_ramp/switchWalletBankAccount.d.ts +0 -2
- package/dist/lib/off_ramp/switchWalletBankAccount.js +0 -18
- package/dist/lib/off_ramp/verify.d.ts +0 -30
- package/dist/lib/off_ramp/verify.js +0 -29
- package/lib/utility/initiate.ts +0 -31
- package/lib/utility/verify.ts +0 -54
- /package/dist/lib/{core → utility/bank}/addBankAccount.d.ts +0 -0
- /package/dist/lib/{core → utility/bank}/getBankAccounts.d.ts +0 -0
- /package/dist/lib/{core → utility/bank}/getBanks.d.ts +0 -0
- /package/dist/lib/{core → utility/bank}/resolveBankAccount.d.ts +0 -0
- /package/dist/lib/{core → utility/deprecated}/addWallet.d.ts +0 -0
- /package/dist/lib/{core → utility/deprecated}/getTXPoolAddress.d.ts +0 -0
- /package/dist/lib/{core → utility/deprecated}/getWallet.d.ts +0 -0
- /package/dist/lib/{core → utility/deprecated}/switchWalletBankAccount.d.ts +0 -0
- /package/dist/lib/{core → utility/rate}/getAllRate.d.ts +0 -0
- /package/dist/lib/{core → utility/rate}/getRateByAmount.d.ts +0 -0
- /package/dist/lib/{core → utility/rate}/getTokenValue.d.ts +0 -0
- /package/dist/lib/{core → utility/transaction}/getAllTransactions.d.ts +0 -0
package/README.md
CHANGED
|
@@ -28,8 +28,13 @@ initializeSDK('staging'); // or production
|
|
|
28
28
|
```typescript
|
|
29
29
|
import { initiate } from 'paj_ramp';
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
//
|
|
31
|
+
// You can get otp by either adding your phone number or email address
|
|
32
|
+
// Phone number must start with a country code
|
|
33
|
+
const initiated = await initiate(
|
|
34
|
+
'your_email@gmail.com' // +2349053231563
|
|
35
|
+
'business_api_key'
|
|
36
|
+
);
|
|
37
|
+
// Response: { email?: string, phone?: string}
|
|
33
38
|
```
|
|
34
39
|
|
|
35
40
|
### Verify Session
|
|
@@ -37,8 +42,10 @@ const initiated = await initiate('your_email@gmail.com', 'business_api_key');
|
|
|
37
42
|
```typescript
|
|
38
43
|
import { verify } from 'paj_ramp';
|
|
39
44
|
|
|
45
|
+
// You can get otp by either adding your phone number or email address
|
|
46
|
+
// Phone number must start with a country code
|
|
40
47
|
const verified = await verify(
|
|
41
|
-
'your_email@gmail.com',
|
|
48
|
+
'your_email@gmail.com', // or +2349053231563
|
|
42
49
|
'otp',
|
|
43
50
|
{
|
|
44
51
|
uuid: string,
|
|
@@ -50,7 +57,13 @@ const verified = await verify(
|
|
|
50
57
|
},
|
|
51
58
|
'business_api_key'
|
|
52
59
|
);
|
|
53
|
-
|
|
60
|
+
/* Response: {
|
|
61
|
+
email?: string,
|
|
62
|
+
phone?: string,
|
|
63
|
+
isActive: string,
|
|
64
|
+
expiresAt: string,
|
|
65
|
+
token: string
|
|
66
|
+
} */
|
|
54
67
|
```
|
|
55
68
|
|
|
56
69
|
## Utility Endpoints
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { post } from
|
|
1
|
+
import { post } from '../../../utils/api.js';
|
|
2
2
|
/**
|
|
3
3
|
* Adds a new bank account by sending the provided token, bank ID, and account number to the public API.
|
|
4
4
|
* Returns the added bank account details or throws an error if the request fails.
|
|
@@ -24,7 +24,7 @@ export const addBankAccount = async (token, bankId, accountNumber) => {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
catch (err) {
|
|
27
|
-
console.error(
|
|
27
|
+
console.error('Error adding bank account:', err);
|
|
28
28
|
throw err;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from
|
|
1
|
+
import { get } from '../../../utils/api.js';
|
|
2
2
|
/**
|
|
3
3
|
* Fetches a list of added bank accounts from the public API endpoint.
|
|
4
4
|
* Returns an array of bank account objects or throws an error if the request fails.
|
|
@@ -16,7 +16,7 @@ export const getBankAccounts = async (apiKey) => {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
catch (err) {
|
|
19
|
-
console.error(
|
|
19
|
+
console.error('Error fetching bank accounts:', err);
|
|
20
20
|
throw err;
|
|
21
21
|
}
|
|
22
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from '
|
|
1
|
+
import { get } from '../../../utils/api.js';
|
|
2
2
|
/**
|
|
3
3
|
* Resolves and fetches bank account details for a given bank ID and account number from the public API.
|
|
4
4
|
* Returns the account name, account number, and bank details or throws an error if the request fails.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { post } from "
|
|
2
|
-
import { getWalletBody } from "
|
|
1
|
+
import { post } from "../../../utils/api.js";
|
|
2
|
+
import { getWalletBody } from "../../../utils/getWalletBody.js";
|
|
3
3
|
/**
|
|
4
4
|
* Adds a new wallet for the user.
|
|
5
5
|
* Returns the added wallet object or throws an error if the request fails.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from "
|
|
1
|
+
import { get } from "../../../utils/api.js";
|
|
2
2
|
/**
|
|
3
3
|
* Fetches wallet details for a given public key from the public API endpoint.
|
|
4
4
|
* Returns the wallet information including bank account details or throws an error if the request fails.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { patch } from "
|
|
2
|
-
import { getWalletBody } from "
|
|
1
|
+
import { patch } from "../../../utils/api.js";
|
|
2
|
+
import { getWalletBody } from "../../../utils/getWalletBody.js";
|
|
3
3
|
export const switchWalletBankAccount = async (apiKey, accountId, walletId, secretKey) => {
|
|
4
4
|
try {
|
|
5
5
|
const body = await getWalletBody(accountId, secretKey);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from '
|
|
1
|
+
import { get } from '../../../utils/api.js';
|
|
2
2
|
/**
|
|
3
3
|
* The function `getRateByAmount` fetches a rate based on a specified amount asynchronously.
|
|
4
4
|
* @param {number} amount - The `amount` parameter in the `getRateByAmount` function is a number
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from '
|
|
1
|
+
import { get } from '../../../utils/api.js';
|
|
2
2
|
/**
|
|
3
3
|
* This function fetches a rate based on a specified rate type asynchronously.
|
|
4
4
|
* @param {RateType} rateType - RateType is a type that specifies the type of rate being requested,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { post } from '../../../utils/api.js';
|
|
2
|
+
export const initiate = async (recipient, apiKey) => {
|
|
3
|
+
let body;
|
|
4
|
+
try {
|
|
5
|
+
if (isNaN(+recipient))
|
|
6
|
+
body = { email: recipient };
|
|
7
|
+
else
|
|
8
|
+
body = { phone: recipient };
|
|
9
|
+
return await post('/pub/initiate', body, {
|
|
10
|
+
'x-api-key': apiKey,
|
|
11
|
+
'Content-Type': 'application/json',
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
console.error('Error initiating:', err);
|
|
16
|
+
throw err;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type VerifyType = {
|
|
2
|
+
recipient: string;
|
|
3
|
+
isActive: string;
|
|
4
|
+
expiresAt: string;
|
|
5
|
+
token: string;
|
|
6
|
+
};
|
|
7
|
+
type deviceSignatureType = {
|
|
8
|
+
uuid: string;
|
|
9
|
+
device: string;
|
|
10
|
+
os?: string;
|
|
11
|
+
browser?: string;
|
|
12
|
+
ip?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const verify: (recipient: string, otp: string, device: deviceSignatureType, apiKey: string) => Promise<VerifyType>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { post } from '../../../utils/api.js';
|
|
2
|
+
export const verify = async (recipient, otp, device, apiKey) => {
|
|
3
|
+
let body;
|
|
4
|
+
try {
|
|
5
|
+
if (isNaN(+recipient))
|
|
6
|
+
body = { email: recipient, otp, device };
|
|
7
|
+
else
|
|
8
|
+
body = { phone: recipient, otp, device };
|
|
9
|
+
return await post('/pub/verify', body, { 'x-api-key': apiKey });
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
console.error('Error verifying:', err);
|
|
13
|
+
throw err;
|
|
14
|
+
}
|
|
15
|
+
};
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export declare const initializeSDK: (env: "staging" | "production") => void;
|
|
2
|
-
export { initiate } from './lib/
|
|
3
|
-
export { verify } from './lib/
|
|
4
|
-
export { getAllRate } from './lib/
|
|
5
|
-
export { getRateByAmount } from './lib/
|
|
6
|
-
export { getRateByType } from './lib/
|
|
7
|
-
export { getTokenValue } from './lib/
|
|
8
|
-
export { getBanks } from './lib/
|
|
9
|
-
export { resolveBankAccount } from './lib/
|
|
10
|
-
export { addBankAccount } from './lib/
|
|
11
|
-
export { getBankAccounts } from './lib/
|
|
12
|
-
export { getAllTransactions } from './lib/
|
|
13
|
-
export { getTransaction } from './lib/
|
|
2
|
+
export { initiate } from './lib/utility/session/initiate.js';
|
|
3
|
+
export { verify } from './lib/utility/session/verify.js';
|
|
4
|
+
export { getAllRate } from './lib/utility/rate/getAllRate.js';
|
|
5
|
+
export { getRateByAmount } from './lib/utility/rate/getRateByAmount.js';
|
|
6
|
+
export { getRateByType } from './lib/utility/rate/getRateByType.js';
|
|
7
|
+
export { getTokenValue } from './lib/utility/rate/getTokenValue.js';
|
|
8
|
+
export { getBanks } from './lib/utility/bank/getBanks.js';
|
|
9
|
+
export { resolveBankAccount } from './lib/utility/bank/resolveBankAccount.js';
|
|
10
|
+
export { addBankAccount } from './lib/utility/bank/addBankAccount.js';
|
|
11
|
+
export { getBankAccounts } from './lib/utility/bank/getBankAccounts.js';
|
|
12
|
+
export { getAllTransactions } from './lib/utility/transaction/getAllTransactions.js';
|
|
13
|
+
export { getTransaction } from './lib/utility/transaction/getTransaction.js';
|
|
14
14
|
export { offRampCreateOrder } from './lib/off_ramp/directCreateOrder.js';
|
|
15
15
|
export { createOrder } from './lib/on_ramp/createOrder.js';
|
|
16
16
|
export { RateType, Currency, TransactionType, TransactionStatus, } from './utils/enums.js';
|
package/dist/sdk.js
CHANGED
|
@@ -9,23 +9,23 @@ export const initializeSDK = (env) => {
|
|
|
9
9
|
setBaseUrl('https://api.paj.cash');
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
//
|
|
12
|
+
// UTILITY ENDPOINTS
|
|
13
13
|
// Session Management
|
|
14
|
-
export { initiate } from './lib/
|
|
15
|
-
export { verify } from './lib/
|
|
14
|
+
export { initiate } from './lib/utility/session/initiate.js';
|
|
15
|
+
export { verify } from './lib/utility/session/verify.js';
|
|
16
16
|
// Rate Operations
|
|
17
|
-
export { getAllRate } from './lib/
|
|
18
|
-
export { getRateByAmount } from './lib/
|
|
19
|
-
export { getRateByType } from './lib/
|
|
20
|
-
export { getTokenValue } from './lib/
|
|
17
|
+
export { getAllRate } from './lib/utility/rate/getAllRate.js';
|
|
18
|
+
export { getRateByAmount } from './lib/utility/rate/getRateByAmount.js';
|
|
19
|
+
export { getRateByType } from './lib/utility/rate/getRateByType.js';
|
|
20
|
+
export { getTokenValue } from './lib/utility/rate/getTokenValue.js';
|
|
21
21
|
// Banking Operations
|
|
22
|
-
export { getBanks } from './lib/
|
|
23
|
-
export { resolveBankAccount } from './lib/
|
|
24
|
-
export { addBankAccount } from './lib/
|
|
25
|
-
export { getBankAccounts } from './lib/
|
|
22
|
+
export { getBanks } from './lib/utility/bank/getBanks.js';
|
|
23
|
+
export { resolveBankAccount } from './lib/utility/bank/resolveBankAccount.js';
|
|
24
|
+
export { addBankAccount } from './lib/utility/bank/addBankAccount.js';
|
|
25
|
+
export { getBankAccounts } from './lib/utility/bank/getBankAccounts.js';
|
|
26
26
|
// Transaction History
|
|
27
|
-
export { getAllTransactions } from './lib/
|
|
28
|
-
export { getTransaction } from './lib/
|
|
27
|
+
export { getAllTransactions } from './lib/utility/transaction/getAllTransactions.js';
|
|
28
|
+
export { getTransaction } from './lib/utility/transaction/getTransaction.js';
|
|
29
29
|
// OFF RAMP
|
|
30
30
|
// DIRECT OFF RAMP
|
|
31
31
|
export { offRampCreateOrder } from './lib/off_ramp/directCreateOrder.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { post } from
|
|
1
|
+
import { post } from '../../../utils/api.js';
|
|
2
2
|
|
|
3
3
|
type AddBankAccountType = {
|
|
4
4
|
id: string;
|
|
@@ -39,7 +39,7 @@ export const addBankAccount = async (
|
|
|
39
39
|
}
|
|
40
40
|
);
|
|
41
41
|
} catch (err) {
|
|
42
|
-
console.error(
|
|
42
|
+
console.error('Error adding bank account:', err);
|
|
43
43
|
throw err;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from
|
|
1
|
+
import { get } from '../../../utils/api.js';
|
|
2
2
|
|
|
3
3
|
type GetBankAccountsType = {
|
|
4
4
|
id: string;
|
|
@@ -27,7 +27,7 @@ export const getBankAccounts = async (apiKey: string) => {
|
|
|
27
27
|
}
|
|
28
28
|
);
|
|
29
29
|
} catch (err) {
|
|
30
|
-
console.error(
|
|
30
|
+
console.error('Error fetching bank accounts:', err);
|
|
31
31
|
throw err;
|
|
32
32
|
}
|
|
33
33
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { post } from "
|
|
2
|
-
import { getWalletBody } from "
|
|
1
|
+
import { post } from "../../../utils/api.js";
|
|
2
|
+
import { getWalletBody } from "../../../utils/getWalletBody.js";
|
|
3
3
|
import { WalletType } from "./getWallet.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { patch } from "
|
|
2
|
-
import { getWalletBody } from "
|
|
1
|
+
import { patch } from "../../../utils/api.js";
|
|
2
|
+
import { getWalletBody } from "../../../utils/getWalletBody.js";
|
|
3
3
|
import { WalletType } from "./getWallet.js";
|
|
4
4
|
|
|
5
5
|
export const switchWalletBankAccount = async (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from '
|
|
1
|
+
import { get } from '../../../utils/api.js';
|
|
2
2
|
|
|
3
3
|
type AllRateResponseType = {
|
|
4
4
|
onRampRate: {
|
|
@@ -17,7 +17,6 @@ type AllRateResponseType = {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
/**
|
|
22
21
|
* This TypeScript function asynchronously fetches all rates from a specified URL and handles any
|
|
23
22
|
* errors that may occur.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get } from '
|
|
1
|
+
import { get } from '../../../utils/api.js';
|
|
2
2
|
|
|
3
3
|
type TokenValueType = {
|
|
4
4
|
amount: number;
|
|
@@ -19,10 +19,7 @@ type TokenValueType = {
|
|
|
19
19
|
* making an HTTP request to fetch the token value based on the provided amount and mint token. If
|
|
20
20
|
* successful, the function will return the token value. If there is an error during
|
|
21
21
|
*/
|
|
22
|
-
export const getTokenValue = async (
|
|
23
|
-
amount: number,
|
|
24
|
-
mint_token: string
|
|
25
|
-
) => {
|
|
22
|
+
export const getTokenValue = async (amount: number, mint_token: string) => {
|
|
26
23
|
const url: string = '/pub/rate';
|
|
27
24
|
|
|
28
25
|
try {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { post } from '../../../utils/api.js';
|
|
2
|
+
|
|
3
|
+
type InitiateResponse = {
|
|
4
|
+
recipient: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const initiate = async (recipient: string, apiKey: string) => {
|
|
8
|
+
let body;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
if (isNaN(+recipient)) body = { email: recipient };
|
|
12
|
+
else body = { phone: recipient };
|
|
13
|
+
|
|
14
|
+
return await post<InitiateResponse>('/pub/initiate', body, {
|
|
15
|
+
'x-api-key': apiKey,
|
|
16
|
+
'Content-Type': 'application/json',
|
|
17
|
+
});
|
|
18
|
+
} catch (err) {
|
|
19
|
+
console.error('Error initiating:', err);
|
|
20
|
+
throw err;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { post } from '../../../utils/api.js';
|
|
2
|
+
|
|
3
|
+
type VerifyType = {
|
|
4
|
+
recipient: string;
|
|
5
|
+
isActive: string;
|
|
6
|
+
expiresAt: string;
|
|
7
|
+
token: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type deviceSignatureType = {
|
|
11
|
+
uuid: string;
|
|
12
|
+
device: string;
|
|
13
|
+
os?: string;
|
|
14
|
+
browser?: string;
|
|
15
|
+
ip?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const verify = async (
|
|
19
|
+
recipient: string,
|
|
20
|
+
otp: string,
|
|
21
|
+
device: deviceSignatureType,
|
|
22
|
+
apiKey: string
|
|
23
|
+
) => {
|
|
24
|
+
let body;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
if (isNaN(+recipient)) body = { email: recipient, otp, device };
|
|
28
|
+
else body = { phone: recipient, otp, device };
|
|
29
|
+
|
|
30
|
+
return await post<VerifyType>('/pub/verify', body, { 'x-api-key': apiKey });
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error('Error verifying:', err);
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { get } from '
|
|
1
|
+
import { get } from '../../../utils/api.js';
|
|
2
2
|
import {
|
|
3
3
|
Currency,
|
|
4
4
|
TransactionStatus,
|
|
5
5
|
TransactionType,
|
|
6
|
-
} from '
|
|
6
|
+
} from '../../../utils/enums.js';
|
|
7
7
|
|
|
8
8
|
export type TransactionResponse = {
|
|
9
9
|
id: string;
|
package/package.json
CHANGED
package/sdk.ts
CHANGED
|
@@ -14,24 +14,24 @@ export const initializeSDK = (env: 'staging' | 'production') => {
|
|
|
14
14
|
// UTILITY ENDPOINTS
|
|
15
15
|
|
|
16
16
|
// Session Management
|
|
17
|
-
export { initiate } from './lib/utility/initiate.js';
|
|
18
|
-
export { verify } from './lib/utility/verify.js';
|
|
17
|
+
export { initiate } from './lib/utility/session/initiate.js';
|
|
18
|
+
export { verify } from './lib/utility/session/verify.js';
|
|
19
19
|
|
|
20
20
|
// Rate Operations
|
|
21
|
-
export { getAllRate } from './lib/utility/getAllRate.js';
|
|
22
|
-
export { getRateByAmount } from './lib/utility/getRateByAmount.js';
|
|
23
|
-
export { getRateByType } from './lib/utility/getRateByType.js';
|
|
24
|
-
export { getTokenValue } from './lib/utility/getTokenValue.js';
|
|
21
|
+
export { getAllRate } from './lib/utility/rate/getAllRate.js';
|
|
22
|
+
export { getRateByAmount } from './lib/utility/rate/getRateByAmount.js';
|
|
23
|
+
export { getRateByType } from './lib/utility/rate/getRateByType.js';
|
|
24
|
+
export { getTokenValue } from './lib/utility/rate/getTokenValue.js';
|
|
25
25
|
|
|
26
26
|
// Banking Operations
|
|
27
|
-
export { getBanks } from './lib/utility/getBanks.js';
|
|
28
|
-
export { resolveBankAccount } from './lib/utility/resolveBankAccount.js';
|
|
29
|
-
export { addBankAccount } from './lib/utility/addBankAccount.js';
|
|
30
|
-
export { getBankAccounts } from './lib/utility/getBankAccounts.js';
|
|
27
|
+
export { getBanks } from './lib/utility/bank/getBanks.js';
|
|
28
|
+
export { resolveBankAccount } from './lib/utility/bank/resolveBankAccount.js';
|
|
29
|
+
export { addBankAccount } from './lib/utility/bank/addBankAccount.js';
|
|
30
|
+
export { getBankAccounts } from './lib/utility/bank/getBankAccounts.js';
|
|
31
31
|
|
|
32
32
|
// Transaction History
|
|
33
|
-
export { getAllTransactions } from './lib/utility/getAllTransactions.js';
|
|
34
|
-
export { getTransaction } from './lib/utility/getTransaction.js';
|
|
33
|
+
export { getAllTransactions } from './lib/utility/transaction/getAllTransactions.js';
|
|
34
|
+
export { getTransaction } from './lib/utility/transaction/getTransaction.js';
|
|
35
35
|
|
|
36
36
|
// OFF RAMP
|
|
37
37
|
// DIRECT OFF RAMP
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { post } from "../../utils/api.js";
|
|
2
|
-
import { getWalletBody } from "../../utils/getWalletBody.js";
|
|
3
|
-
/**
|
|
4
|
-
* Adds a new wallet for the user.
|
|
5
|
-
* Returns the added wallet object or throws an error if the request fails.
|
|
6
|
-
*
|
|
7
|
-
* Returns:
|
|
8
|
-
* An object containing id, accountName, accountNumber, and bank of the bank account.
|
|
9
|
-
*
|
|
10
|
-
* Raises:
|
|
11
|
-
* Throws an error if the wallet file is not found or if the secret key is invalid.
|
|
12
|
-
*/
|
|
13
|
-
export const addWallet = async (apiKey, accountId, secretKey) => {
|
|
14
|
-
try {
|
|
15
|
-
const body = await getWalletBody(accountId, secretKey);
|
|
16
|
-
if (!body) {
|
|
17
|
-
throw new Error("Failed to get wallet body");
|
|
18
|
-
}
|
|
19
|
-
return await post("/pub/wallet", body, {
|
|
20
|
-
Authorization: `Bearer ${apiKey}`,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
catch (err) {
|
|
24
|
-
console.error("Error adding wallet:", err);
|
|
25
|
-
throw err;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TransactionResponse } from './getTransaction.js';
|
|
2
|
-
type TransactionsResponse = TransactionResponse[];
|
|
3
|
-
/**
|
|
4
|
-
* The function getAllTransactions fetches all transactions from a specified endpoint and handles any
|
|
5
|
-
* errors that occur.
|
|
6
|
-
* @returns The `getAllTransactions` function is returning the result of the `get` function called with
|
|
7
|
-
* the '/pub/transactions' endpoint. The result is expected to be of type `TransactionsResponse`. If
|
|
8
|
-
* successful, the function will return the transactions data. If an error occurs during the API call,
|
|
9
|
-
* it will be caught, logged to the console, and rethrown.
|
|
10
|
-
*/
|
|
11
|
-
export declare const getAllTransactions: () => Promise<TransactionsResponse>;
|
|
12
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { get } from '../../utils/api.js';
|
|
2
|
-
/**
|
|
3
|
-
* The function getAllTransactions fetches all transactions from a specified endpoint and handles any
|
|
4
|
-
* errors that occur.
|
|
5
|
-
* @returns The `getAllTransactions` function is returning the result of the `get` function called with
|
|
6
|
-
* the '/pub/transactions' endpoint. The result is expected to be of type `TransactionsResponse`. If
|
|
7
|
-
* successful, the function will return the transactions data. If an error occurs during the API call,
|
|
8
|
-
* it will be caught, logged to the console, and rethrown.
|
|
9
|
-
*/
|
|
10
|
-
export const getAllTransactions = async () => {
|
|
11
|
-
try {
|
|
12
|
-
return await get('/pub/transactions');
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
console.error('Error fetching Transactions:', err);
|
|
16
|
-
throw err;
|
|
17
|
-
}
|
|
18
|
-
};
|