@morambacrypto/connect 0.0.5 → 0.0.7
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 +6 -13
- package/dist/MorambaClient.js +1 -3
- package/dist/apis/auth.api.d.ts +5 -3
- package/dist/apis/auth.api.js +9 -2
- package/dist/client/HttpClient.d.ts +2 -0
- package/dist/client/HttpClient.js +5 -2
- package/dist/types/auth.types.d.ts +1 -5
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -23,23 +23,16 @@ import { MorambaClient } from "@morambacrypto/connect";
|
|
|
23
23
|
|
|
24
24
|
const client = new MorambaClient({
|
|
25
25
|
baseURL: "https://crypto.moramba.io",
|
|
26
|
-
apiKey: "
|
|
27
|
-
partnerId: "
|
|
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
|
-
|
|
36
|
-
partner_id: "YOUR_PARTNER_ID",
|
|
37
|
-
api_key: "YOUR_API_KEY"
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
console.log("JWT Token:", response.data.token);
|
|
41
|
-
console.log("Issued At:", response.data.iat);
|
|
42
|
-
console.log("Expires At:", response.data.exp);
|
|
34
|
+
const response = await client.auth.createJwtToken({ userid: "test@gmail.com" });
|
|
35
|
+
console.log(response.data.token);
|
|
43
36
|
```
|
|
44
37
|
|
|
45
38
|
## API Reference
|
|
@@ -90,11 +83,11 @@ const client = new MorambaClient({
|
|
|
90
83
|
|
|
91
84
|
## Support
|
|
92
85
|
|
|
93
|
-
For issues and questions, please visit the [
|
|
86
|
+
For issues and questions, please visit the [moramba.xyz](https://moramba.xyz).
|
|
94
87
|
|
|
95
88
|
## Documentation
|
|
96
89
|
|
|
97
|
-
For complete API documentation, visit [API Documentation](https://
|
|
90
|
+
For complete API documentation, visit [API Documentation](https://morambacrypto.readme.io/).
|
|
98
91
|
|
|
99
92
|
## License
|
|
100
93
|
|
package/dist/MorambaClient.js
CHANGED
|
@@ -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
|
}
|
package/dist/apis/auth.api.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { HttpClient } from "../client/HttpClient";
|
|
2
|
-
import {
|
|
2
|
+
import { CreateJwtPayload, CreateJwtResponse } from "../types/auth.types";
|
|
3
3
|
export declare class AuthAPI {
|
|
4
4
|
private http;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
private partnerId;
|
|
6
|
+
private apiKey;
|
|
7
|
+
constructor(http: HttpClient, partnerId: string, apiKey: string);
|
|
8
|
+
createJwtToken(payload: CreateJwtPayload): Promise<CreateJwtResponse>;
|
|
7
9
|
}
|
package/dist/apis/auth.api.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.0.7",
|
|
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
|
}
|