@morambacrypto/connect 0.0.2 → 0.0.4
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 +33 -1
- package/dist/MorambaClient.d.ts +11 -0
- package/dist/MorambaClient.js +12 -0
- package/dist/apis/auth.api.d.ts +7 -0
- package/dist/apis/auth.api.js +8 -0
- package/dist/apis/index.d.ts +0 -0
- package/dist/apis/index.js +1 -0
- package/dist/client/HttpClient.d.ts +6 -0
- package/dist/client/HttpClient.js +16 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -5
- package/dist/types/auth.types.d.ts +15 -0
- package/dist/types/auth.types.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -2,4 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
## Documentation
|
|
4
4
|
|
|
5
|
-
- [API](https://morambacrypto.readme.io/)
|
|
5
|
+
- [API](https://morambacrypto.readme.io/)
|
|
6
|
+
|
|
7
|
+
npm install @morambacrypto/connect
|
|
8
|
+
|
|
9
|
+
import { MorambaClient } from "@morambacrypto/connect";
|
|
10
|
+
|
|
11
|
+
const client = new MorambaClient({
|
|
12
|
+
baseURL: "https://crypto.moramba.io",
|
|
13
|
+
apiKey: "YOUR_API_KEY",
|
|
14
|
+
partnerId: "YOUR_PARTNER_ID",
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const response = await client.auth.createJwtToken({
|
|
18
|
+
userid: "email@example.com",
|
|
19
|
+
partner_id: "YOUR_PARTNER_ID",
|
|
20
|
+
api_key: "YOUR_API_KEY",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
console.log("JWT Token:", response.data.token);
|
|
24
|
+
console.log("Issued At:", response.data.iat);
|
|
25
|
+
console.log("Expires At:", response.data.exp);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
🛠 Requirements
|
|
31
|
+
|
|
32
|
+
Node.js 16+
|
|
33
|
+
|
|
34
|
+
Valid api_key and partner_id
|
|
35
|
+
|
|
36
|
+
Stable internet connection
|
|
37
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthAPI } from "./apis/auth.api";
|
|
2
|
+
export interface MorambaClientConfig {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
partnerId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class MorambaClient {
|
|
8
|
+
auth: AuthAPI;
|
|
9
|
+
private http;
|
|
10
|
+
constructor(config: MorambaClientConfig);
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HttpClient } from "./client/HttpClient";
|
|
2
|
+
import { AuthAPI } from "./apis/auth.api";
|
|
3
|
+
export class MorambaClient {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.http = new HttpClient(config.baseURL, {
|
|
6
|
+
"Content-Type": "application/json",
|
|
7
|
+
"x-api-key": config.apiKey,
|
|
8
|
+
"x-partner-id": config.partnerId,
|
|
9
|
+
});
|
|
10
|
+
this.auth = new AuthAPI(this.http);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HttpClient } from "../client/HttpClient";
|
|
2
|
+
import { CreateJwtRequest, CreateJwtResponse } from "../types/auth.types";
|
|
3
|
+
export declare class AuthAPI {
|
|
4
|
+
private http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
createJwtToken(payload: CreateJwtRequest): Promise<CreateJwtResponse>;
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
export class HttpClient {
|
|
3
|
+
constructor(baseURL, headers = {}) {
|
|
4
|
+
this.client = axios.create({
|
|
5
|
+
baseURL,
|
|
6
|
+
headers,
|
|
7
|
+
timeout: 10000,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
post(url, data) {
|
|
11
|
+
return this.client.post(url, data).then(res => res.data);
|
|
12
|
+
}
|
|
13
|
+
get(url) {
|
|
14
|
+
return this.client.get(url).then(res => res.data);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./HttpClient";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./HttpClient";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from "./MorambaClient";
|
|
2
|
+
export * from "./types";
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface CreateJwtRequest {
|
|
2
|
+
userid: string;
|
|
3
|
+
partner_id: string;
|
|
4
|
+
api_key: string;
|
|
5
|
+
}
|
|
6
|
+
export interface JwtTokenData {
|
|
7
|
+
token: string;
|
|
8
|
+
iat: number;
|
|
9
|
+
exp: number;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateJwtResponse {
|
|
12
|
+
success: boolean;
|
|
13
|
+
message: string;
|
|
14
|
+
data: JwtTokenData;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth.types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth.types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morambacrypto/connect",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "This library use for interact with moramba-crypto project",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -18,5 +18,8 @@
|
|
|
18
18
|
"library"
|
|
19
19
|
],
|
|
20
20
|
"author": "Moramba Crypto",
|
|
21
|
-
"license": "MIT"
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"axios": "^1.13.2"
|
|
24
|
+
}
|
|
22
25
|
}
|