paj_ramp 1.2.2 → 1.2.3

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 CHANGED
@@ -13,11 +13,11 @@ A comprehensive SDK for PAJ Ramp onramp and offramp operations with real-time tr
13
13
  ## Installation
14
14
 
15
15
  ```bash
16
- npm install paj-ramp
16
+ npm install paj_ramp
17
17
  ```
18
18
 
19
19
  ```bash
20
- yarn add paj-ramp
20
+ yarn add paj_ramp
21
21
  ```
22
22
 
23
23
  ---
@@ -42,11 +42,7 @@ initializeSDK("staging"); // or production
42
42
  The SDK provides Socket.IO functionality to observe onramp orders in real-time:
43
43
 
44
44
  ```typescript
45
- import {
46
- observeOrder,
47
- createOrderObserver,
48
- createOnRampSocket,
49
- } from "paj-ramp";
45
+ import { observeOrder } from "paj_ramp";
50
46
 
51
47
  // Using observeOrder function
52
48
  const observer = observeOrder({
@@ -109,7 +105,7 @@ Creates an order observer.
109
105
  **Example:**
110
106
 
111
107
  ```typescript
112
- import { observeOrder } from "paj-ramp";
108
+ import { observeOrder } from "paj_ramp";
113
109
 
114
110
  const observer = observeOrder({
115
111
  orderId: "your_order_id",
@@ -171,7 +167,7 @@ Creates a new onramp order.
171
167
  **Example:**
172
168
 
173
169
  ```typescript
174
- import { createOrder } from "paj-ramp";
170
+ import { createOrder } from "paj_ramp";
175
171
 
176
172
  const order = await createOrder({
177
173
  fiatAmount: 10000,
@@ -187,7 +183,7 @@ const order = await createOrder({
187
183
  ### Usage Example
188
184
 
189
185
  ```typescript
190
- import { observeOrder } from "paj-ramp";
186
+ import { observeOrder } from "paj_ramp";
191
187
 
192
188
  async function example(orderId) {
193
189
  console.log("Observe Order");
@@ -257,7 +253,7 @@ The Offramp SDK provides a set of functions to help users convert Solana-based d
257
253
  ### Get TX Pool Address
258
254
 
259
255
  ```typescript
260
- import { getTXPoolAddress } from "paj-ramp";
256
+ import { getTXPoolAddress } from "paj_ramp";
261
257
 
262
258
  const txpooladdress = await getTXPoolAddress();
263
259
  // Response: { address: string }
@@ -266,43 +262,96 @@ const txpooladdress = await getTXPoolAddress();
266
262
  ### Get Rate
267
263
 
268
264
  ```typescript
269
- import { getRate } from "paj-ramp";
265
+ import { getRate } from "paj_ramp";
270
266
 
271
267
  const rate = await getRate();
272
- // Response: { baseCurrency: string, targetCurrency: string, rate: number }
268
+ /*
269
+ Response:
270
+ {
271
+ "onRampRate": {
272
+ "baseCurrency": "USD",
273
+ "targetCurrency": "NGN",
274
+ "isActive": true,
275
+ "rate": 1510,
276
+ "type": "onRamp"
277
+ },
278
+ "offRampRate": {
279
+ "baseCurrency": "USD",
280
+ "targetCurrency": "NGN",
281
+ "isActive": true,
282
+ "rate": 1525,
283
+ "type": "offRamp"
284
+ }
285
+ }*/
273
286
  ```
274
287
 
275
- ### Get Rate with Amount
288
+ ### Get Rate by Amount
276
289
 
277
290
  ```typescript
278
- import { getRate } from "paj-ramp";
291
+ import { getRate } from "paj_ramp";
279
292
 
280
293
  const rate = await getRate(50000);
281
- // Response:
282
- // {
283
- // rate: { baseCurrency: string, targetCurrency: string, rate: number },
284
- // amounts: { userTax: number, merchantTax: number, amountUSD: number, userAmountFiat: number }
285
- // }
294
+ /*
295
+ Response:
296
+ {
297
+ rate: {
298
+ baseCurrency: string,
299
+ targetCurrency: string,
300
+ rate: number
301
+ },
302
+ amounts: {
303
+ userTax": number,
304
+ merchantTax": number,
305
+ amountUSD": number,
306
+ userAmountFiat": number
307
+ }
308
+ }*/
309
+ ```
310
+
311
+ ### Get Rate by Rate Type
312
+
313
+ ```typescript
314
+ import { getRate, RateType } from "paj_ramp";
315
+
316
+ const rate = await getRate(RateType.offRamp); // or RateType.onRamp
317
+
318
+ /*
319
+ Response:
320
+ "offRampRate": {
321
+ "baseCurrency": "USD",
322
+ "targetCurrency": "NGN",
323
+ "isActive": true,
324
+ "rate": 1525,
325
+ "type": "offRamp"
326
+ }*/
286
327
  ```
287
328
 
288
329
  ### Initiate Session
289
330
 
290
331
  ```typescript
291
- import { initiate } from "paj-ramp";
332
+ import { initiate } from "paj_ramp";
292
333
 
293
- const initialized = await initiate("your_email@gmail.com");
334
+ const initialized = await initiate("your_email@gmail.com", "business_api_key");
294
335
  // Response: { email: string }
295
336
  ```
296
337
 
297
338
  ### Verify Session
298
339
 
299
340
  ```typescript
300
- import { verify } from "paj-ramp";
341
+ import { verify } from "paj_ramp";
301
342
 
302
343
  const verified = await verify(
303
344
  "your_email@gmail.com",
304
345
  "otp",
305
- "device signature"
346
+ {
347
+ uuid: string,
348
+ device: string,
349
+ //optionL ↓↓↓↓↓
350
+ os: string, //IOS
351
+ browser: string, //chrome
352
+ ip: string,
353
+ },
354
+ "business_api_key"
306
355
  );
307
356
  // Response: { email: string, isActive: string, expiresAt: string, token: string }
308
357
  ```
@@ -310,7 +359,7 @@ const verified = await verify(
310
359
  ### Get Banks
311
360
 
312
361
  ```typescript
313
- import { getBanks } from "paj-ramp";
362
+ import { getBanks } from "paj_ramp";
314
363
 
315
364
  const banks = await getBanks();
316
365
  // Response: [ { id: string, name: string, country: string } ]
@@ -319,7 +368,7 @@ const banks = await getBanks();
319
368
  ### Resolve Bank Account
320
369
 
321
370
  ```typescript
322
- import { resolveBankAccount } from "paj-ramp";
371
+ import { resolveBankAccount } from "paj_ramp";
323
372
 
324
373
  const resolvedBankAccount = await resolveBankAccount(
325
374
  "bank id",
@@ -331,7 +380,7 @@ const resolvedBankAccount = await resolveBankAccount(
331
380
  ### Add Bank Account
332
381
 
333
382
  ```typescript
334
- import { addBankAccount } from "paj-ramp";
383
+ import { addBankAccount } from "paj_ramp";
335
384
 
336
385
  const addedBankAccount = await addBankAccount(
337
386
  "token",
@@ -344,7 +393,7 @@ const addedBankAccount = await addBankAccount(
344
393
  ### Get Bank Accounts
345
394
 
346
395
  ```typescript
347
- import { getBankAccounts } from "paj-ramp";
396
+ import { getBankAccounts } from "paj_ramp";
348
397
 
349
398
  const accounts = await getBankAccounts("token");
350
399
  // Response: [ { id: string, accountName: string, accountNumber: string, bank: string } ]
@@ -353,7 +402,7 @@ const accounts = await getBankAccounts("token");
353
402
  ### Get Wallet Info
354
403
 
355
404
  ```typescript
356
- import { getWallet } from "paj-ramp";
405
+ import { getWallet } from "paj_ramp";
357
406
 
358
407
  const wallet = await getWallet("wallet public key");
359
408
  // Response: { id: string, publicKey: string, bankAccount: { id: string, accountName: string, accountNumber: string, bank: string } }
@@ -362,7 +411,7 @@ const wallet = await getWallet("wallet public key");
362
411
  ### Add Wallet
363
412
 
364
413
  ```typescript
365
- import { addWallet } from "paj-ramp";
414
+ import { addWallet } from "paj_ramp";
366
415
 
367
416
  // To create wallet.json file with an array of 64 numbers
368
417
  // npm install @solana/web3.js then run this code
@@ -401,7 +450,7 @@ const addedWallet = await addWallet("token", "bank account id", secretKey);
401
450
  ### Switch Bank Account on Wallet
402
451
 
403
452
  ```typescript
404
- import { switchWalletBankAccount } from "paj-ramp";
453
+ import { switchWalletBankAccount } from "paj_ramp";
405
454
 
406
455
  const switchedWallet = await switchWalletBankAccount(
407
456
  "token",
@@ -1,7 +1,25 @@
1
- type RateType = {
2
- baseCurrency: string;
3
- targetCurrency: string;
4
- rate: number;
1
+ type AllRateResponseType = {
2
+ onRampRate: {
3
+ baseCurrency: "USD";
4
+ targetCurrency: "NGN";
5
+ isActive: true;
6
+ rate: 1510;
7
+ type: "onRamp";
8
+ };
9
+ offRampRate: {
10
+ baseCurrency: "USD";
11
+ targetCurrency: "NGN";
12
+ isActive: true;
13
+ rate: 1525;
14
+ type: "offRamp";
15
+ };
16
+ };
17
+ type RateByAmountType = {
18
+ rate: {
19
+ baseCurrency: string;
20
+ targetCurrency: string;
21
+ rate: number;
22
+ };
5
23
  amounts: {
6
24
  userTax: number;
7
25
  merchantTax: number;
@@ -9,18 +27,59 @@ type RateType = {
9
27
  userAmountFiat: number;
10
28
  };
11
29
  };
30
+ type RateByRateTypeType = {
31
+ baseCurrency: "USD";
32
+ targetCurrency: "NGN";
33
+ isActive: true;
34
+ rate: 1525;
35
+ type: "offRamp";
36
+ };
37
+ export declare enum RateType {
38
+ onRamp = "onRamp",
39
+ offRamp = "offRamp"
40
+ }
41
+ /**
42
+ * Fetches rate information based on the provided parameter, which can be a number or a rate type.
43
+ * This function returns all rates, rates by amount, or rates by type depending on the input.
44
+ *
45
+ * Args:
46
+ * param: A number representing the amount or a RateType enum value.
47
+ *
48
+ * Returns:
49
+ * A promise resolving to the rate information relevant to the input parameter.
50
+ *
51
+ * Raises:
52
+ * Throws an error if the rate information cannot be fetched.
53
+ */
54
+ export declare const getRate: (param: number | RateType) => Promise<AllRateResponseType | RateByAmountType | RateByRateTypeType>;
55
+ /**
56
+ * Retrieves rate information based on a specific amount for on-ramp or off-ramp transactions.
57
+ * This function returns a promise that resolves to the rate and associated amounts for the given value.
58
+ *
59
+ * Args:
60
+ * url: The endpoint URL to fetch rate information from.
61
+ * amount: The amount for which the rate information is requested.
62
+ *
63
+ * Returns:
64
+ * A promise resolving to the rate and amount details for the specified value.
65
+ *
66
+ * Raises:
67
+ * Throws an error if the rate information cannot be fetched.
68
+ */
69
+ export declare const getRateByAmount: (url: string, amount: number) => Promise<RateByAmountType>;
12
70
  /**
13
- * Fetches the exchange rate and related amounts for a given amount from the public API.
14
- * Returns an object containing currency information, rate, and detailed amounts, or throws an error if the request fails.
71
+ * Retrieves rate information based on a specific rate type for on-ramp or off-ramp transactions.
72
+ * This function returns a promise that resolves to the rate details for the given rate type.
15
73
  *
16
74
  * Args:
17
- * amount: The amount for which to fetch the rate. If not provided or falsy, fetches the default rate.
75
+ * url: The endpoint URL to fetch rate information from.
76
+ * rateType: The type of rate to retrieve, specified as a RateType enum value.
18
77
  *
19
78
  * Returns:
20
- * An object with baseCurrency, targetCurrency, rate, and amounts (userTax, merchantTax, amountUSD, userAmountFiat).
79
+ * A promise resolving to the rate details for the specified rate type.
21
80
  *
22
81
  * Raises:
23
- * Throws an error if the request fails.
82
+ * Throws an error if the rate information cannot be fetched.
24
83
  */
25
- export declare const getRate: (amount: number) => Promise<RateType>;
84
+ export declare const getRateByRateType: (url: string, rateType: RateType) => Promise<RateByRateTypeType>;
26
85
  export {};
@@ -1,23 +1,105 @@
1
1
  import { get } from "../../utils/api.js";
2
+ export var RateType;
3
+ (function (RateType) {
4
+ RateType["onRamp"] = "onRamp";
5
+ RateType["offRamp"] = "offRamp";
6
+ })(RateType || (RateType = {}));
2
7
  /**
3
- * Fetches the exchange rate and related amounts for a given amount from the public API.
4
- * Returns an object containing currency information, rate, and detailed amounts, or throws an error if the request fails.
8
+ * Fetches rate information based on the provided parameter, which can be a number or a rate type.
9
+ * This function returns all rates, rates by amount, or rates by type depending on the input.
5
10
  *
6
11
  * Args:
7
- * amount: The amount for which to fetch the rate. If not provided or falsy, fetches the default rate.
12
+ * param: A number representing the amount or a RateType enum value.
8
13
  *
9
14
  * Returns:
10
- * An object with baseCurrency, targetCurrency, rate, and amounts (userTax, merchantTax, amountUSD, userAmountFiat).
15
+ * A promise resolving to the rate information relevant to the input parameter.
11
16
  *
12
17
  * Raises:
13
- * Throws an error if the request fails.
18
+ * Throws an error if the rate information cannot be fetched.
14
19
  */
15
- export const getRate = async (amount) => {
20
+ export const getRate = async (param) => {
16
21
  try {
17
- return await get(amount ? `/pub/rate/${amount}` : "/pub/rate");
22
+ const url = "/pub/rate";
23
+ if (!param) {
24
+ return getAllRate(url);
25
+ }
26
+ else if (typeof param === "number") {
27
+ return getRateByAmount(url, param);
28
+ }
29
+ else {
30
+ return getRateByRateType(url, param);
31
+ }
18
32
  }
19
33
  catch (err) {
20
34
  console.error("Error fetching Rate:", err);
21
35
  throw err;
22
36
  }
23
37
  };
38
+ /**
39
+ * Retrieves all available rate information for on-ramp and off-ramp transactions.
40
+ * This function returns a promise that resolves to the complete set of rate data.
41
+ *
42
+ * Args:
43
+ * url: The endpoint URL to fetch rate information from.
44
+ *
45
+ * Returns:
46
+ * A promise resolving to the full rate response data.
47
+ *
48
+ * Raises:
49
+ * Throws an error if the rate information cannot be fetched.
50
+ */
51
+ const getAllRate = async (url) => {
52
+ try {
53
+ return await get(url);
54
+ }
55
+ catch (err) {
56
+ console.error("Error fetching Rate:", err);
57
+ throw err;
58
+ }
59
+ };
60
+ /**
61
+ * Retrieves rate information based on a specific amount for on-ramp or off-ramp transactions.
62
+ * This function returns a promise that resolves to the rate and associated amounts for the given value.
63
+ *
64
+ * Args:
65
+ * url: The endpoint URL to fetch rate information from.
66
+ * amount: The amount for which the rate information is requested.
67
+ *
68
+ * Returns:
69
+ * A promise resolving to the rate and amount details for the specified value.
70
+ *
71
+ * Raises:
72
+ * Throws an error if the rate information cannot be fetched.
73
+ */
74
+ export const getRateByAmount = async (url, amount) => {
75
+ try {
76
+ return await get(`/pub/rate/${amount}`);
77
+ }
78
+ catch (err) {
79
+ console.error("Error fetching Rate by Amount:", err);
80
+ throw err;
81
+ }
82
+ };
83
+ /**
84
+ * Retrieves rate information based on a specific rate type for on-ramp or off-ramp transactions.
85
+ * This function returns a promise that resolves to the rate details for the given rate type.
86
+ *
87
+ * Args:
88
+ * url: The endpoint URL to fetch rate information from.
89
+ * rateType: The type of rate to retrieve, specified as a RateType enum value.
90
+ *
91
+ * Returns:
92
+ * A promise resolving to the rate details for the specified rate type.
93
+ *
94
+ * Raises:
95
+ * Throws an error if the rate information cannot be fetched.
96
+ */
97
+ export const getRateByRateType = async (url, rateType) => {
98
+ try {
99
+ return await get(`/pub/rate/${rateType}`);
100
+ }
101
+ catch (err) {
102
+ console.error("Error fetching Rate by Rate Type:", err);
103
+ throw err;
104
+ }
105
+ };
@@ -14,5 +14,5 @@ type InitiateResponse = {
14
14
  * Raises:
15
15
  * Throws an error if the request fails.
16
16
  */
17
- export declare const initiate: (email: string) => Promise<InitiateResponse>;
17
+ export declare const initiate: (email: string, apiKey: string) => Promise<InitiateResponse>;
18
18
  export {};
@@ -12,9 +12,9 @@ import { post } from "../../utils/api.js";
12
12
  * Raises:
13
13
  * Throws an error if the request fails.
14
14
  */
15
- export const initiate = async (email) => {
15
+ export const initiate = async (email, apiKey) => {
16
16
  try {
17
- return await post("/pub/initiate", { email }, { "x-api-key": "3ada687e-78d1-45f3-933d-c992adcc2bbb" });
17
+ return await post("/pub/initiate", { email }, { "x-api-key": apiKey, "Content-Type": "application/json" });
18
18
  }
19
19
  catch (err) {
20
20
  console.error("Error initiating:", err);
@@ -1,3 +1,16 @@
1
+ type VerifyType = {
2
+ email: 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
+ };
1
14
  /**
2
15
  * Verifies a user's identity using email, OTP, and device signature via the public API.
3
16
  * Returns verification details including email, activation status, expiration, and token, or throws an error if the request fails.
@@ -13,9 +26,5 @@
13
26
  * Raises:
14
27
  * Throws an error if the request fails.
15
28
  */
16
- export declare const verify: (email: string, otp: string, deviceSignature: string) => Promise<{
17
- email: string;
18
- isActive: string;
19
- expiresAt: string;
20
- token: string;
21
- }>;
29
+ export declare const verify: (email: string, otp: string, deviceSignature: deviceSignatureType, apiKey: string) => Promise<VerifyType>;
30
+ export {};
@@ -14,9 +14,13 @@ import { post } from "../../utils/api.js";
14
14
  * Raises:
15
15
  * Throws an error if the request fails.
16
16
  */
17
- export const verify = async (email, otp, deviceSignature) => {
17
+ export const verify = async (email, otp, deviceSignature, apiKey) => {
18
18
  try {
19
- return await post("/pub/verify", { email, otp, deviceSignature }, { "x-api-key": "3ada687e-78d1-45f3-933d-c992adcc2bbb" });
19
+ return await post("/pub/verify", {
20
+ email,
21
+ otp,
22
+ device: deviceSignature,
23
+ }, { "x-api-key": apiKey });
20
24
  }
21
25
  catch (err) {
22
26
  console.error("Error verifying:", err);
package/dist/sdk.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare const initializeSDK: (env: "staging" | "production") => void;
2
2
  export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
3
- export { getRate } from "./lib/off_ramp/getRate.js";
3
+ export { getRate, RateType } from "./lib/off_ramp/getRate.js";
4
4
  export { initiate } from "./lib/off_ramp/initiate.js";
5
5
  export { verify } from "./lib/off_ramp/verify.js";
6
6
  export { getBanks } from "./lib/off_ramp/getBanks.js";
package/dist/sdk.js CHANGED
@@ -12,7 +12,7 @@ export const initializeSDK = (env) => {
12
12
  // OFF RAMP
13
13
  // Wallet Info
14
14
  export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
15
- export { getRate } from "./lib/off_ramp/getRate.js";
15
+ export { getRate, RateType } from "./lib/off_ramp/getRate.js";
16
16
  // Session Management
17
17
  export { initiate } from "./lib/off_ramp/initiate.js";
18
18
  export { verify } from "./lib/off_ramp/verify.js";
@@ -1,9 +1,28 @@
1
1
  import { get } from "../../utils/api.js";
2
2
 
3
- type RateType = {
4
- baseCurrency: string;
5
- targetCurrency: string;
6
- rate: number;
3
+ type AllRateResponseType = {
4
+ onRampRate: {
5
+ baseCurrency: "USD";
6
+ targetCurrency: "NGN";
7
+ isActive: true;
8
+ rate: 1510;
9
+ type: "onRamp";
10
+ };
11
+ offRampRate: {
12
+ baseCurrency: "USD";
13
+ targetCurrency: "NGN";
14
+ isActive: true;
15
+ rate: 1525;
16
+ type: "offRamp";
17
+ };
18
+ };
19
+
20
+ type RateByAmountType = {
21
+ rate: {
22
+ baseCurrency: string;
23
+ targetCurrency: string;
24
+ rate: number;
25
+ };
7
26
  amounts: {
8
27
  userTax: number;
9
28
  merchantTax: number;
@@ -12,24 +31,113 @@ type RateType = {
12
31
  };
13
32
  };
14
33
 
34
+ type RateByRateTypeType = {
35
+ baseCurrency: "USD";
36
+ targetCurrency: "NGN";
37
+ isActive: true;
38
+ rate: 1525;
39
+ type: "offRamp";
40
+ };
41
+
42
+ export enum RateType {
43
+ onRamp = "onRamp",
44
+ offRamp = "offRamp",
45
+ }
46
+
47
+ /**
48
+ * Fetches rate information based on the provided parameter, which can be a number or a rate type.
49
+ * This function returns all rates, rates by amount, or rates by type depending on the input.
50
+ *
51
+ * Args:
52
+ * param: A number representing the amount or a RateType enum value.
53
+ *
54
+ * Returns:
55
+ * A promise resolving to the rate information relevant to the input parameter.
56
+ *
57
+ * Raises:
58
+ * Throws an error if the rate information cannot be fetched.
59
+ */
60
+ export const getRate = async (param: number | RateType) => {
61
+ try {
62
+ const url = "/pub/rate";
63
+
64
+ if (!param) {
65
+ return getAllRate(url);
66
+ } else if (typeof param === "number") {
67
+ return getRateByAmount(url, param);
68
+ } else {
69
+ return getRateByRateType(url, param);
70
+ }
71
+ } catch (err) {
72
+ console.error("Error fetching Rate:", err);
73
+ throw err;
74
+ }
75
+ };
76
+
15
77
  /**
16
- * Fetches the exchange rate and related amounts for a given amount from the public API.
17
- * Returns an object containing currency information, rate, and detailed amounts, or throws an error if the request fails.
78
+ * Retrieves all available rate information for on-ramp and off-ramp transactions.
79
+ * This function returns a promise that resolves to the complete set of rate data.
18
80
  *
19
81
  * Args:
20
- * amount: The amount for which to fetch the rate. If not provided or falsy, fetches the default rate.
82
+ * url: The endpoint URL to fetch rate information from.
21
83
  *
22
84
  * Returns:
23
- * An object with baseCurrency, targetCurrency, rate, and amounts (userTax, merchantTax, amountUSD, userAmountFiat).
85
+ * A promise resolving to the full rate response data.
24
86
  *
25
87
  * Raises:
26
- * Throws an error if the request fails.
88
+ * Throws an error if the rate information cannot be fetched.
27
89
  */
28
- export const getRate = async (amount: number) => {
90
+ const getAllRate = async (url: string) => {
29
91
  try {
30
- return await get<RateType>(amount ? `/pub/rate/${amount}` : "/pub/rate");
92
+ return await get<AllRateResponseType>(url);
31
93
  } catch (err) {
32
94
  console.error("Error fetching Rate:", err);
33
95
  throw err;
34
96
  }
35
97
  };
98
+
99
+ /**
100
+ * Retrieves rate information based on a specific amount for on-ramp or off-ramp transactions.
101
+ * This function returns a promise that resolves to the rate and associated amounts for the given value.
102
+ *
103
+ * Args:
104
+ * url: The endpoint URL to fetch rate information from.
105
+ * amount: The amount for which the rate information is requested.
106
+ *
107
+ * Returns:
108
+ * A promise resolving to the rate and amount details for the specified value.
109
+ *
110
+ * Raises:
111
+ * Throws an error if the rate information cannot be fetched.
112
+ */
113
+ export const getRateByAmount = async (url: string, amount: number) => {
114
+ try {
115
+ return await get<RateByAmountType>(`/pub/rate/${amount}`);
116
+ } catch (err) {
117
+ console.error("Error fetching Rate by Amount:", err);
118
+ throw err;
119
+ }
120
+ };
121
+
122
+ /**
123
+ * Retrieves rate information based on a specific rate type for on-ramp or off-ramp transactions.
124
+ * This function returns a promise that resolves to the rate details for the given rate type.
125
+ *
126
+ * Args:
127
+ * url: The endpoint URL to fetch rate information from.
128
+ * rateType: The type of rate to retrieve, specified as a RateType enum value.
129
+ *
130
+ * Returns:
131
+ * A promise resolving to the rate details for the specified rate type.
132
+ *
133
+ * Raises:
134
+ * Throws an error if the rate information cannot be fetched.
135
+ */
136
+ export const getRateByRateType = async (url: string, rateType: RateType) => {
137
+ try {
138
+ return await get<RateByRateTypeType>(`/pub/rate/${rateType}`);
139
+ } catch (err) {
140
+ console.error("Error fetching Rate by Rate Type:", err);
141
+ throw err;
142
+ }
143
+ };
@@ -17,12 +17,12 @@ type InitiateResponse = {
17
17
  * Raises:
18
18
  * Throws an error if the request fails.
19
19
  */
20
- export const initiate = async (email: string) => {
20
+ export const initiate = async (email: string, apiKey: string) => {
21
21
  try {
22
22
  return await post<InitiateResponse>(
23
23
  "/pub/initiate",
24
24
  { email },
25
- { "x-api-key": "3ada687e-78d1-45f3-933d-c992adcc2bbb" }
25
+ { "x-api-key": apiKey, "Content-Type": "application/json" }
26
26
  );
27
27
  } catch (err) {
28
28
  console.error("Error initiating:", err);
@@ -1,5 +1,20 @@
1
1
  import { post } from "../../utils/api.js";
2
2
 
3
+ type VerifyType = {
4
+ email: 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
+
3
18
  /**
4
19
  * Verifies a user's identity using email, OTP, and device signature via the public API.
5
20
  * Returns verification details including email, activation status, expiration, and token, or throws an error if the request fails.
@@ -15,21 +30,22 @@ import { post } from "../../utils/api.js";
15
30
  * Raises:
16
31
  * Throws an error if the request fails.
17
32
  */
33
+
18
34
  export const verify = async (
19
35
  email: string,
20
36
  otp: string,
21
- deviceSignature: string
37
+ deviceSignature: deviceSignatureType,
38
+ apiKey: string
22
39
  ) => {
23
40
  try {
24
- return await post<{
25
- email: string;
26
- isActive: string;
27
- expiresAt: string;
28
- token: string;
29
- }>(
41
+ return await post<VerifyType>(
30
42
  "/pub/verify",
31
- { email, otp, deviceSignature },
32
- { "x-api-key": "3ada687e-78d1-45f3-933d-c992adcc2bbb" }
43
+ {
44
+ email,
45
+ otp,
46
+ device: deviceSignature,
47
+ },
48
+ { "x-api-key": apiKey }
33
49
  );
34
50
  } catch (err) {
35
51
  console.error("Error verifying:", err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paj_ramp",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "paj offramp service",
5
5
  "main": "dist/sdk.js",
6
6
  "types": "dist/sdk.d.ts",
package/sdk.ts CHANGED
@@ -15,7 +15,7 @@ export const initializeSDK = (env: "staging" | "production") => {
15
15
 
16
16
  // Wallet Info
17
17
  export { getTXPoolAddress } from "./lib/off_ramp/getTXPoolAddress.js";
18
- export { getRate } from "./lib/off_ramp/getRate.js";
18
+ export { getRate, RateType } from "./lib/off_ramp/getRate.js";
19
19
 
20
20
  // Session Management
21
21
  export { initiate } from "./lib/off_ramp/initiate.js";
@@ -0,0 +1,41 @@
1
+ import axios from "axios";
2
+
3
+ // Test both HTTP and HTTPS to see which one works
4
+ async function testProtocols() {
5
+ const urls = [
6
+ "https://api-staging.paj.cash",
7
+ "http://api-staging.paj.cash",
8
+ "https://api.paj.cash",
9
+ "http://api.paj.cash"
10
+ ];
11
+
12
+ for (const url of urls) {
13
+ try {
14
+ console.log(`\nšŸ” Testing: ${url}`);
15
+
16
+ const response = await axios.get(`${url}/pub/rate`, {
17
+ timeout: 5000,
18
+ validateStatus: () => true // Don't throw on any status code
19
+ });
20
+
21
+ console.log(`āœ… SUCCESS: ${url}`);
22
+ console.log(` Status: ${response.status}`);
23
+ console.log(` Protocol: ${url.startsWith('https') ? 'HTTPS' : 'HTTP'}`);
24
+
25
+ } catch (error) {
26
+ console.log(`āŒ FAILED: ${url}`);
27
+ console.log(` Error: ${error.message}`);
28
+
29
+ if (error.code === 'ECONNREFUSED') {
30
+ console.log(` Reason: Connection refused (server not running or wrong port)`);
31
+ } else if (error.message.includes('wrong version number')) {
32
+ console.log(` Reason: Protocol mismatch (HTTPS client to HTTP server)`);
33
+ } else if (error.message.includes('ENOTFOUND')) {
34
+ console.log(` Reason: Domain not found`);
35
+ }
36
+ }
37
+ }
38
+ }
39
+
40
+ console.log("šŸš€ Testing PAJ API protocols...");
41
+ testProtocols().catch(console.error);
package/versions ADDED
File without changes