ContactsManager Node.js SDK
A Node.js SDK for the ContactsManager API that handles authentication and token generation for contactsmanager.io integration.
Overview
The ContactsManager SDK enables developers to easily integrate social features into their applications. It provides secure authentication and token management, helping you build features like activity feeds, follow/unfollow functionality, and contact management while ensuring user data privacy and security.
Installation
npm install @contactsmanager/server
Usage
const { ContactsManagerClient } = require("@contactsmanager/server");
const client = new ContactsManagerClient({
apiKey: "your_api_key",
apiSecret: "your_api_secret",
orgId: "your_org_id",
});
async function generateUserToken() {
try {
const tokenResponse = await client.generateToken({
userId: "user123",
deviceInfo: {
deviceType: "mobile",
os: "Android",
appVersion: "1.0.0",
},
});
console.log(`Token: ${tokenResponse.token}`);
console.log(`Expires at: ${tokenResponse.expiresAt}`);
} catch (error) {
console.error("Error generating token:", error);
}
}
generateUserToken();
Features
- Simple API for generating JWT tokens for contactsmanager.io services
- TypeScript support with type definitions
- Comprehensive test coverage
- Support for custom token expiration
- Promise-based API
- Military-grade security for user data protection
Advanced Usage
Custom Token Expiration
By default, tokens expire after 24 hours (86400 seconds). You can customize this:
const tokenResponse = await client.generateToken({
userId: "user123",
expirationSeconds: 3600,
});
Requirements
- Node.js 14+
- jsonwebtoken >= 9.0.0
Development
Setting up development environment
git clone https://github.com/arpwal/contactmanager.git
cd contactmanager/sdk/nodejs
npm install
npm test
Releasing new versions
The SDK uses an automated process for releases:
-
Update the version in package.json
using npm:
npm version patch
-
Commit and push the change to the main branch:
git push origin main --follow-tags
-
The GitHub Actions workflow will automatically:
- Run all tests
- Build the package
- Publish to npm (using the NPM_TOKEN stored in GitHub secrets)
- Create a new GitHub release with the version tag
Alternatively, you can manually trigger the workflow by going to the "Actions" tab in the GitHub repository and using the "Run workflow" button on the "Build and Publish" workflow.
License
MIT License
About ContactsManager.io
ContactsManager.io provides a platform for app developers to integrate social features into their applications. Our SDK ensures that contact information stays with users only, with multi-layer encryption and military-grade security to prevent spam and data misuse.
For more information and documentation, visit contactsmanager.io.