1.0.21 • Published 5 months ago
earthid-web-sdk v1.0.21
EarthID SDK
A simple SDK for interacting with EarthID's web based features.
Installation
npm install earthid-sdk
Usage
Importing and Initializing the SDK
import EarthIDSDK from "earthid-sdk";
const sdk = new EarthIDSDK({
apiKey: "YOUR_API_KEY",
baseUrl: "https://stage-apiv2.myearth.id",
socketUrl: "https://stage-socketv2.myearth.id"
});
Available Functions
1. Get Vendor Information
sdk.getVendor("VENDOR_API_KEY", "SESSION_ID")
.then(data => console.log("Vendor Info:", data))
.catch(error => console.error("Error:", error));
- Description: Fetches the vendor information associated with the API key.
- Parameters:
vendorApiKey
(string): The vendor's API key.sessionId
(string): The session ID for tracking the request.
- Returns: Vendor details including API key and secret key.
2. Generate Hash
const hash = sdk.getHash("VENDOR_SECRET_KEY", "VENDOR_API_KEY");
console.log("Generated Hash:", hash);
- Description: Generates a cryptographic HMAC hash for authentication.
- Parameters:
vendorSecretKey
(string): The vendor's secret key.vendorApiKey
(string): The vendor's API key.
- Returns: A secure HMAC SHA-256 hash.
3. Generate QR Code (Nested Authentication)
sdk.generateQrCodeNest(hash, "VENDOR_API_KEY", "document")
.then(data => console.log("QR Code Data:", data))
.catch(error => console.error("Error:", error));
- Description: Generates a QR code with additional security parameters.
- Parameters:
hash
(string): A cryptographic hash for security.vendorApiKey
(string): The vendor's API key.requestType
(string): The type of request (e.g., "document").
- Returns: QR code details.
4. Listen for Service Provider Responses
sdk.listenForServiceProviderResponse((err, data) => {
if (err) console.error("Error:", err);
else console.log("Service Provider Response:", data);
});
- Description: Listens for responses from a service provider.
5. Listen for User Data
sdk.listenForUserData((err, data) => {
if (err) console.error("Error:", err);
else console.log("User Data:", data);
});
- Description: Listens for user authentication responses.
6. Disconnect Socket
sdk.disconnectSocket();
- Description: Disconnects the socket connection.
License
This project is licensed under the MIT License.
1.0.19
5 months ago
1.0.2
5 months ago
1.0.18
5 months ago
1.0.1
5 months ago
1.0.17
5 months ago
1.0.16
5 months ago
1.0.9
5 months ago
1.0.8
5 months ago
1.0.7
5 months ago
1.0.6
5 months ago
1.0.5
5 months ago
1.0.4
5 months ago
1.0.3
5 months ago
1.0.11
5 months ago
1.0.21
5 months ago
1.0.10
5 months ago
1.0.20
5 months ago
1.0.15
5 months ago
1.0.14
5 months ago
1.0.13
5 months ago
1.0.12
5 months ago
1.0.0
5 months ago