
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
The PAKT SDK is an advanced software development kit, purpose-built for web applications, that empowers developers to construct innovative products on the PAKT Operating System.
PAKT SDK is a comprehensive software development kit for building applications on the PAKT Operating System. It provides a complete suite of tools for project collaboration, blockchain payments, user management, and more.collaboration, blockchain payments, user management, and more.
To install PAKT SDK, simply
npm install pakt-sdk
# OR
yarn add pakt-sdk
# OR
pnpm add pakt-sdk
import { PaktSDK } from "pakt-sdk";
const sdk = await PaktSDK.init({
baseUrl: "https://api.pakt.world", // Required: API base URL
verbose: true, // Optional: Enable detailed logging
testnet: false, // Optional: Use testnet environment
});
// Now you can use all SDK features
const loginResponse = await sdk.auth.login({
email: "user@example.com",
password: "yourpassword",
});
The authentication module provides complete user registration, login, password management, and OAuth integration.
import { LoginPayload } from "pakt-sdk";
const loginData: LoginPayload = {
email: "user@example.com",
password: "yourpassword",
};
const sdkInit = await PaktSDK.init(configData);
const response = await sdk.auth.login(loginData);
if (response.status === "success") {
console.log("Logged in successfully");
console.log("User data:", response.data);
// Token is automatically stored for subsequent requests
}
import { LoginTwoFAPayload } from "pakt-sdk";
const loginData: LoginTwoFAPayload = {
code: "123456",
tempToken:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1OWJlYTQRmZWQ4IiwiaWF0IjoxNzA0Nzg3MjkwLCJleHAiOjE3Nzc4NjAwMzB9.cPkZ-",
};
const sdkInit = await PaktSDK.init(configData);
const response = await sdk.auth.loginTwoFa(loginData);
if (response.status === "success") {
console.log("Logged in successfully");
console.log("User data:", response.data);
// Token is automatically stored for subsequent requests
}
import { RegisterPayload } from "pakt-sdk";
const registrationData: RegisterPayload = {
firstName: "John",
lastName: "Doe",
email: "john@example.com",
password: "securepassword",
confirmPassword: "securepassword",
referral: "optional-referral-code", // Optional
type: "talent", // Optional: "talent" or "business"
};
const sdkInit = await PaktSDK.init(configData);
const response = await sdk.auth.register(registrationData);
if (response.status === "success") {
// Registration successful, but account needs verification
console.log("Registration successful, check email for verification");
}
After registration, users need to verify their account:
const verificationResponse = await sdk.auth.verifyAccount({
tempToken: "token-from-registration",
token: "verification-token-from-email",
});
if (verificationResponse.status === "success") {
console.log("Account verified successfully");
// User is now fully authenticated
}
// Send password reset email
await sdk.auth.resetPassword({
email: "user@example.com",
});
// Change password with reset token
await sdk.auth.changePassword({
token: "reset-token-from-email",
tempToken: "temp-token",
password: "newpassword",
});
// Step 1: Generate OAuth URL
const oauthResponse = await sdk.auth.googleOAuthGenerateState();
const { googleAuthUrl, state } = oauthResponse.data;
// Redirect user to googleAuthUrl
// Step 2: Validate OAuth callback
const validationResponse = await sdk.auth.googleOAuthValidateState({
state: "state-from-step-1",
code: "authorization-code-from-callback",
});
if (validationResponse.data.type === "sign_up") {
// New user registered via Google
} else {
// Existing user signed in
}
const referralResponse = await sdk.auth.validateReferral("referral-token");
if (referralResponse.data.valid) {
console.log(`Valid referral from user ${referralResponse.data.userId}`);
console.log(
`Referral counts: ${referralResponse.data.referralCounts}/${referralResponse.data.totalAllowedReferrals}`,
);
}
const userProfile = await sdk.account.getUser();
console.log("Current user:", userProfile.data);
import { UpdateUserDto } from "pakt-sdk";
const profileUpdate: UpdateUserDto = {
profile: {
contact: {
city: "New York",
state: "NY",
country: "USA",
phone: "+1234567890",
},
bio: {
title: "Full-Stack Developer",
description: "Experienced developer with expertise in React and Node.js",
},
talent: {
availability: "available", // "available" | "busy" | "working"
tags: ["React", "Node.js", "TypeScript"],
tagsIds: ["tag-id-1", "tag-id-2"],
tagsCategory: "development",
about: "I love building scalable web applications",
},
socials: {
github: "https://github.com/username",
linkedin: "https://linkedin.com/in/username",
twitter: "https://twitter.com/username",
},
},
isPrivate: false,
};
const response = await sdk.account.updateAccount(profileUpdate);
Complete the initial onboarding process:
import { UserOnboardDto } from "pakt-sdk";
const onboardingData: UserOnboardDto = {
profile: {
bio: {
title: "Software Developer",
description: "Building amazing applications",
},
talent: {
availability: "available",
tags: ["JavaScript", "React"],
tagsCategory: "development",
},
},
};
await sdk.account.onboardEndpoint(onboardingData);
// Initiate 2FA setup
const twoFAResponse = await sdk.account.initate2FA({
type: "google_auth", // or "email"
password: "current-password",
});
// For Google Authenticator, use the provided QR code
console.log("QR Code:", twoFAResponse.data.qrCode);
// Activate 2FA with verification code
await sdk.account.activate2FA({
code: "123456", // Code from authenticator app
type: "google_auth",
});
// When 2FA is enabled, use email 2FA
await sdk.account.sendEmailTwoFA({
type: "email",
tempToken: "temp-token-from-login",
});
```
### User Search and Discovery
````typescript
import { FilterUserDto } from "pakt-sdk";
const searchFilters: FilterUserDto = {
tags: ["React", "Node.js"],
type: "talent",
scoreRange: { min: 80, max: 100 },
limit: 20,
offset: 0,
};
const users = await sdk.account.getUsers(searchFilters);
Collections are the core entity representing projects, jobs, or collaborative work in the PAKT ecosystem.
import { CreateCollectionDto } from "pakt-sdk";
const newCollection: CreateCollectionDto = {
name: "E-commerce Website Development",
description: "Build a modern e-commerce platform",
collectionType: "development-project",
isPrivate: false,
deliveryDate: new Date("2024-12-31"),
tags: ["React", "Node.js", "E-commerce"],
maxParticipants: 3,
budget: {
amount: 5000,
currency: "USD",
},
};
const collection = await sdk.collection.create(newCollection);
console.log("Collection created:", collection.data._id);
// Get all collections with filters
const collections = await sdk.collection.getAll({
status: "ongoing",
limit: 10,
offset: 0,
});
// Get specific collection
const collection = await sdk.collection.getById("collectionId");
import { UpdateCollectionDto } from "pakt-sdk";
const updates: UpdateCollectionDto = {
description: "Updated project description",
status: "ongoing",
deliveryDate: new Date("2024-12-31"),
};
await sdk.collection.updateCollection("collection-id", updates);
```
### Collection Types
````typescript
// Get all available collection types
const types = await sdk.collection.getTypes();
// Get specific collection type
const type = await sdk.collection.getACollectionType("_id");
// Create multiple collections
const collectionsData = [
/* array of CreateCollectionDto */
];
await sdk.collection.createMany(collectionsData);
// Update multiple collections
const updates = [
/* array of updates with IDs */
];
await sdk.collection.updateManyCollections(updates);
Comprehensive blockchain-based payment system with multi-cryptocurrency support.
// Get all user wallets
const wallets = await sdk.wallet.getWallets();
wallets.data.forEach((wallet) => {
console.log(`${wallet.coin.toUpperCase()}: $${wallet.balance.spendable} available`);
console.log(`Locked: $${wallet.balance.locked}`);
});
// Get specific wallet by cryptocurrency
const usdcWallet = await sdk.wallet.getSingleWalletByCoin("usdc");
const avaxWallet = await sdk.wallet.getSingleWalletByCoin("avax");
import { ICreatePaymentDto } from "pakt-sdk";
// Create payment order
const paymentOrder: ICreatePaymentDto = {
coin: "usdc", // or "avax"
collectionId: "collectionId",
};
const payment = await sdk.payment.create(paymentOrder);
if (payment.status === "success") {
console.log("Payment order created");
console.log("Amount to pay:", payment.data.amount);
console.log("Blockchain address:", payment.data.address);
console.log("Required confirmations:", payment.data.confirmation);
}
// Validate payment transaction
const validation = await sdk.payment.validate({
paymentId: "payment-id",
transactionHash: "blockchain-tx-hash",
});
// Release escrowed payment (for collection completion)
await sdk.payment.release({
collectionId: "collectionId",
recipientId: "user-id",
});
// Get all transactions
const transactions = await sdk.wallet.getTransactions({
limit: 50,
offset: 0,
type: "sent", // Optional: filter by transaction type
});
// Get specific transaction
const transaction = await sdk.wallet.getATransaction("transaction-id");
// Get transaction statistics
const stats = await sdk.wallet.getTransactionStats("usdc");
console.log("Total sent:", stats.data.totalSent);
console.log("Total received:", stats.data.totalReceived);
// Get current exchange rates
const exchange = await sdk.wallet.getExchange();
console.log("USDC to USD:", exchange.data.usdc.usd);
console.log("AVAX to USD:", exchange.data.avax.usd);
import { CreateWithdrawal } from "pakt-sdk";
const withdrawalRequest: CreateWithdrawal = {
coin: "usdc",
amount: 100.5,
address: "0x742d35Cc6634C0532925a3b8D6cf1C4394c64DF8",
password: "account-password",
};
const withdrawal = await sdk.withdrawal.createWithdrawal(withdrawalRequest);
// Check withdrawal status
const withdrawals = await sdk.withdrawal.fetchWithdrawal({
limit: 10,
offset: 0,
});
Direct deposits allow for streamlined collection funding and validation without going through the traditional escrow process.
import { ICreateDirectDepositPayload } from "pakt-sdk";
const directDepositData: ICreateDirectDepositPayload = {
collectionType: "development-project",
amount: 1000,
coin: "usdc", // or "avax"
name: "Project Direct Funding",
description: "Direct deposit for project completion",
owner: "user-id",
systemDeposit: true,
};
const directDeposit = await sdk.directDeposit.createDirectDeposit({
authToken: "your-auth-token",
payload: directDepositData,
});
if (directDeposit.status === "success") {
console.log("Direct deposit created");
console.log("Collection ID:", directDeposit.data.collectionId);
console.log("Payment address:", directDeposit.data.address);
console.log("Amount to pay:", directDeposit.data.amountToPay);
console.log("Expected fee:", directDeposit.data.expectedFee);
console.log("Chain ID:", directDeposit.data.chainId);
}
import { IValidateDirectDepositPayload } from "pakt-sdk";
const validationData: IValidateDirectDepositPayload = {
collection: "collection-id",
method: "blockchain", // validation method
status: "completed", // deposit status
owner: "owner-user-id",
meta: {
transactionHash: "0x...",
blockNumber: 123456,
},
release: true, // whether to release funds immediately
};
const validation = await sdk.directDeposit.validateDirectDeposit({
authToken: "your-auth-token",
payload: validationData,
});
if (validation.status === "success") {
console.log("Direct deposit validated");
console.log("Collection updated:", validation.data);
}
// Get available blockchain payment methods for direct deposits
const paymentMethods = await sdk.directDeposit.fetchPaymentMethods("your-auth-token");
paymentMethods.data.forEach((coin) => {
console.log(`${coin.name} (${coin.symbol})`);
console.log(`Contract: ${coin.contractAddress}`);
console.log(`Chain ID: ${coin.rpcChainId}`);
console.log(`Active: ${coin.active}`);
});
// Get current blockchain RPC server configuration
const rpcConfig = await sdk.directDeposit.fetchActiveRPC("your-auth-token");
if (rpcConfig.status === "success") {
console.log("RPC Name:", rpcConfig.data.rpcName);
console.log("Chain ID:", rpcConfig.data.rpcChainId);
console.log("RPC URLs:", rpcConfig.data.rpcUrls);
console.log("Block Explorer:", rpcConfig.data.blockExplorerUrls);
console.log("Native Currency:", rpcConfig.data.rpcNativeCurrency);
}
Direct deposits offer several advantages over regular escrow payments:
Use direct deposits when:
Send and manage project collaboration invites:
import { SendInviteDto } from "pakt-sdk";
// Send invite
const inviteData: SendInviteDto = {
receiverId: "user-id",
collectionId: "project-id",
};
const invite = await sdk.invite.sendInvite(inviteData);
// Manage invites
await sdk.invite.acceptInvite("invite-id");
await sdk.invite.declineInvite("invite-id");
await sdk.invite.cancelInvite("invite-id");
// Get all invites
const invites = await sdk.invite.getAll({
status: "pending",
limit: 10,
});
// Get user messages/conversations
const messages = await sdk.chat.getUserMessages({
limit: 50,
offset: 0,
});
messages.data.forEach((conversation) => {
console.log("Conversation with:", conversation.recipients);
conversation.messages.forEach((message) => {
console.log(`${message.sender}: ${message.content}`);
});
});
// Get all notifications
const notifications = await sdk.notifications.getAll({
limit: 20,
offset: 0,
});
// Mark notifications as read
await sdk.notifications.markAll(); // Mark all as read
await sdk.notifications.markOneAsRead("notification-id"); // Mark specific notification
import { CreateFeedDto } from "pakt-sdk";
// Create feed entry
const feedEntry: CreateFeedDto = {
type: "COLLECTION_CREATED",
title: "New Project Created",
description: "Started working on e-commerce platform",
isPublic: true,
data: "collectionId",
};
await sdk.feed.create(feedEntry);
// Get activity feeds
const feeds = await sdk.feed.getAll({
limit: 10,
isPublic: true,
});
// Dismiss feeds
await sdk.feed.dismissAFeed("feed-id");
await sdk.feed.dismissAllFeeds();
import { CreateFileUpload } from "pakt-sdk";
const fileData: CreateFileUpload = {
file: fileBuffer, // or file data
fileName: "document.pdf",
fileType: "application/pdf",
};
const upload = await sdk.file.fileUpload(fileData);
console.log("File uploaded:", upload.data.url);
// Get all uploaded files
const files = await sdk.file.getFileUploads({
limit: 20,
offset: 0,
});
// Get specific file
const file = await sdk.file.getAFileUpload("file-id");
Complete identity verification system using third-party verification services.
import { ICreateSessionPayload } from "pakt-sdk";
const verificationData: ICreateSessionPayload = {
firstName: "John",
lastName: "Doe",
dateOfBirth: "1990-01-01",
address: {
street: "123 Main St",
city: "New York",
state: "NY",
postalCode: "10001",
country: "US",
},
documentType: "passport", // or "driving_license", "national_id"
documentCountry: "US",
};
const session = await sdk.userVerification.createSession(verificationData);
console.log("Verification session created:", session.data.sessionId);
import { ISendSessionMedia } from "pakt-sdk";
// Upload document photo
const documentMedia: ISendSessionMedia = {
sessionId: "session-id",
mediaType: "document",
file: documentImageBuffer,
};
await sdk.userVerification.sendSessionMedia(documentMedia);
// Upload face photo for verification
const faceMedia: ISendSessionMedia = {
sessionId: "session-id",
mediaType: "face",
file: facePhotoBuffer,
};
await sdk.userVerification.sendSessionMedia(faceMedia);
// Get verification attempts
const attempts = await sdk.userVerification.getSessionAttempts({
limit: 10,
offset: 0,
});
// Get user verification status
const verifications = await sdk.userVerification.getUserVerifications({
limit: 5,
offset: 0,
});
verifications.data.forEach((verification) => {
console.log("Status:", verification.status);
console.log("Provider:", verification.provider);
console.log("Document verified:", verification.documentVerified);
console.log("Face verified:", verification.faceVerified);
});
import { createBookMarkDto } from "pakt-sdk";
// Create bookmark
const bookmark: createBookMarkDto = {
data: "collectionId", // or feed-id, user-id, invite-id
type: "collection", // or "feed", "user", "invite"
};
await sdk.bookmark.create(bookmark);
// Get bookmarks
const bookmarks = await sdk.bookmark.getAll({
type: "collection",
limit: 10,
});
// Delete bookmark
await sdk.bookmark.delete("bookmark-id");
import { AddReviewDto } from "pakt-sdk";
// Add review for completed collection
const reviewData: AddReviewDto = {
collectionId: "collection-id",
receiverId: "user-id",
rating: 5, // 1-5 scale
text: "Excellent work, highly recommended!",
};
await sdk.review.addReview(reviewData);
// Get reviews
const reviews = await sdk.review.viewAll({
collectionId: "collection-id",
limit: 10,
});
import { CreateConnectionFilterDto } from "pakt-sdk";
// Create automatic connection filter
const filter: CreateConnectionFilterDto = {
event: "CREATE_CONVERSATION",
key: "afroScore",
value: "80",
decider: "greater_than", // Only connect with users having score > 80
};
await sdk.connectionFilter.create(filter);
// Get user's connection filters
const filters = await sdk.connectionFilter.getForAUser("user-id");
All SDK methods return a consistent response format:
interface ResponseDto<T> {
status: "success" | "error";
message: string;
data: T;
statusCode?: number;
code?: number;
}
// Example error handling
try {
const response = await sdk.auth.login(loginData);
if (response.status === "error") {
console.error("Login failed:", response.message);
return;
}
// Success - use response.data
console.log("User:", response.data);
} catch (error) {
console.error("Network or unexpected error:", error);
}
The SDK is built with TypeScript and provides comprehensive type definitions:
import { PaktSDK, LoginPayload, RegisterPayload, CreateCollectionDto, IUser, IWalletDto, ResponseDto } from "pakt-sdk";
// All interfaces and types are available for import
const loginPayload: LoginPayload = {
email: "user@example.com",
password: "password",
};
const response: ResponseDto<LoginDto> = await sdk.auth.login(loginPayload);
interface PaktConfig {
baseUrl: string; // Required: API base URL
testnet?: boolean; // Optional: Use testnet environment (default: false)
verbose?: boolean; // Optional: Enable detailed logging (default: false)
}
const sdk = await PaktSDK.init({
baseUrl: "https://api.pakt.world",
testnet: false,
verbose: true,
});
BSD-3-Clause © PAKT
FAQs
The PAKT SDK is an advanced software development kit, purpose-built for web applications, that empowers developers to construct innovative products on the PAKT Operating System.
The npm package pakt-sdk receives a total of 217 weekly downloads. As such, pakt-sdk popularity was classified as not popular.
We found that pakt-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.