@morambacrypto/connect 0.0.6 → 0.0.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/README.md CHANGED
@@ -23,21 +23,16 @@ import { MorambaClient } from "@morambacrypto/connect";
23
23
 
24
24
  const client = new MorambaClient({
25
25
  baseURL: "https://crypto.moramba.io",
26
- apiKey: "YOUR_API_KEY",
27
- partnerId: "YOUR_PARTNER_ID"
26
+ apiKey: "abcd123",
27
+ partnerId: "partner_001",
28
28
  });
29
29
  ```
30
30
 
31
31
  ### Creating a JWT Token
32
32
 
33
33
  ```javascript
34
- const response = await client.auth.createJwtToken({
35
- userid: "email@example.com",
36
- partner_id: "YOUR_PARTNER_ID",
37
- api_key: "YOUR_API_KEY"
38
- });
39
-
40
- console.log("JWT Token:", response.data.token);
34
+ const response = await client.auth.createJwtToken({ userid: "test@gmail.com" });
35
+ console.log(response.data.token);
41
36
  ```
42
37
 
43
38
  ## API Reference
@@ -88,11 +83,11 @@ const client = new MorambaClient({
88
83
 
89
84
  ## Support
90
85
 
91
- For issues and questions, please visit the [npm package page](https://npmjs.com/package/@morambacrypto/connect).
86
+ For issues and questions, please visit the [moramba.xyz](https://moramba.xyz){:target="_blank"}.
92
87
 
93
88
  ## Documentation
94
89
 
95
- For complete API documentation, visit [API Documentation](https://npmjs.com/package/@morambacrypto/connect).
90
+ For complete API documentation, visit [API Documentation](https://morambacrypto.readme.io/){:target="_blank"}.
96
91
 
97
92
  ## License
98
93
 
@@ -4,9 +4,7 @@ export class MorambaClient {
4
4
  constructor(config) {
5
5
  this.http = new HttpClient(config.baseURL, {
6
6
  "Content-Type": "application/json",
7
- "x-api-key": config.apiKey,
8
- "x-partner-id": config.partnerId,
9
7
  });
10
- this.auth = new AuthAPI(this.http);
8
+ this.auth = new AuthAPI(this.http, config.partnerId, config.apiKey);
11
9
  }
12
10
  }
@@ -1,7 +1,9 @@
1
1
  import { HttpClient } from "../client/HttpClient";
2
- import { CreateJwtRequest, CreateJwtResponse } from "../types/auth.types";
2
+ import { CreateJwtPayload, CreateJwtResponse } from "../types/auth.types";
3
3
  export declare class AuthAPI {
4
4
  private http;
5
- constructor(http: HttpClient);
6
- createJwtToken(payload: CreateJwtRequest): Promise<CreateJwtResponse>;
5
+ private partnerId;
6
+ private apiKey;
7
+ constructor(http: HttpClient, partnerId: string, apiKey: string);
8
+ createJwtToken(payload: CreateJwtPayload): Promise<CreateJwtResponse>;
7
9
  }
@@ -1,8 +1,15 @@
1
1
  export class AuthAPI {
2
- constructor(http) {
2
+ constructor(http, partnerId, apiKey) {
3
3
  this.http = http;
4
+ this.partnerId = partnerId;
5
+ this.apiKey = apiKey;
4
6
  }
5
7
  createJwtToken(payload) {
6
- return this.http.post("/api/v1/morambacypto/create/jwt_token", payload);
8
+ const fullBody = {
9
+ ...payload, // { userid }
10
+ partner_id: this.partnerId,
11
+ api_key: this.apiKey,
12
+ };
13
+ return this.http.post("/api/v1/morambacypto/create/jwt_token", fullBody);
7
14
  }
8
15
  }
@@ -1,6 +1,8 @@
1
+ import { AxiosInstance } from "axios";
1
2
  export declare class HttpClient {
2
3
  private client;
3
4
  constructor(baseURL: string, headers?: Record<string, string>);
5
+ get axiosInstance(): AxiosInstance;
4
6
  post<T = any>(url: string, data: any): Promise<T>;
5
7
  get<T = any>(url: string): Promise<T>;
6
8
  }
@@ -7,10 +7,13 @@ export class HttpClient {
7
7
  timeout: 10000,
8
8
  });
9
9
  }
10
+ get axiosInstance() {
11
+ return this.client;
12
+ }
10
13
  post(url, data) {
11
- return this.client.post(url, data).then(res => res.data);
14
+ return this.client.post(url, data).then((res) => res.data);
12
15
  }
13
16
  get(url) {
14
- return this.client.get(url).then(res => res.data);
17
+ return this.client.get(url).then((res) => res.data);
15
18
  }
16
19
  }
@@ -1,12 +1,8 @@
1
- export interface CreateJwtRequest {
1
+ export interface CreateJwtPayload {
2
2
  userid: string;
3
- partner_id: string;
4
- api_key: string;
5
3
  }
6
4
  export interface JwtTokenData {
7
5
  token: string;
8
- iat: number;
9
- exp: number;
10
6
  }
11
7
  export interface CreateJwtResponse {
12
8
  success: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morambacrypto/connect",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "This library use for interact with moramba-crypto project",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -8,7 +8,8 @@
8
8
  "scripts": {
9
9
  "build": "tsc",
10
10
  "clean": "rm -rf dist",
11
- "prepublishOnly": "npm run clean && npm run build"
11
+ "prepublishOnly": "npm run clean && npm run build",
12
+ "test": "jest"
12
13
  },
13
14
  "files": [
14
15
  "dist"
@@ -20,6 +21,13 @@
20
21
  "author": "Moramba Crypto",
21
22
  "license": "MIT",
22
23
  "dependencies": {
23
- "axios": "^1.13.2"
24
+ "axios": "^1.13.2",
25
+ "dotenv": "^17.2.3"
26
+ },
27
+ "devDependencies": {
28
+ "@types/jest": "^30.0.0",
29
+ "axios-mock-adapter": "^2.1.0",
30
+ "jest": "^30.2.0",
31
+ "ts-jest": "^29.4.5"
24
32
  }
25
33
  }