
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@curia_/cg-plugin-lib
Advanced tools
Drop-in replacement for Common Ground plugin client library with iframe sandboxing and postMessage API
Drop-in replacement for Common Ground's client-side plugin library. This package provides the exact same API as the original @common-ground-dao/cg-plugin-lib but communicates with our custom host system instead of Common Ground's servers.
This library allows existing Common Ground plugins to work without any code changes in your own hosting environment. Simply replace the package source and your plugins will seamlessly integrate with your custom host system.
# Replace the original CG library with ours
npm install @common-ground-dao/cg-plugin-lib
# Or with yarn
yarn add @common-ground-dao/cg-plugin-lib
import { CgPluginLib } from '@common-ground-dao/cg-plugin-lib';
// Initialize with iframe UID, signing endpoint, and public key
const cgPluginLib = await CgPluginLib.initialize(
iframeUid, // From URL parameters: ?iframeUid=...
'/api/sign', // Your plugin's signing endpoint
publicKey // Your plugin's public key
);
// Get current user information
const userResponse = await cgPluginLib.getUserInfo();
console.log(userResponse.data); // { id, name, email, roles, twitter, lukso, farcaster }
// Get community information
const communityResponse = await cgPluginLib.getCommunityInfo();
console.log(communityResponse.data); // { id, title, description, roles }
// Get user's friends/connections (with pagination)
const friendsResponse = await cgPluginLib.getUserFriends(10, 0);
console.log(friendsResponse.data.friends); // Array of friend objects
// Assign a role to a user
await cgPluginLib.giveRole('contributor', 'user_12345');
// After initialization, get the instance anywhere
const lib = CgPluginLib.getInstance();
const userInfo = await lib.getUserInfo();
CgPluginLib.initialize(iframeUid, signEndpoint, publicKey)Initialize the plugin library with host communication.
Parameters:
iframeUid: string - Unique iframe identifier from URL parameterssignEndpoint: string - Plugin's signing endpoint (e.g., '/api/sign')publicKey: string - Plugin's public key for signature verificationReturns: Promise<CgPluginLib> - Initialized instance
CgPluginLib.getInstance()Get the singleton instance after initialization.
Returns: CgPluginLib - The initialized instance
Throws: Error if not initialized
getUserInfo()Get current user's profile and authentication data.
Returns: Promise<ApiResponse<UserInfoResponsePayload>>
interface UserInfoResponsePayload {
id: string;
name: string;
email?: string;
roles: string[];
twitter?: { username: string };
lukso?: { username: string };
farcaster?: { username: string };
}
getCommunityInfo()Get community details and available roles.
Returns: Promise<ApiResponse<CommunityInfoResponsePayload>>
interface CommunityInfoResponsePayload {
id: string;
title: string;
description?: string;
roles: Array<{
id: string;
title: string;
description?: string;
assignmentRules?: {
type: string;
requirements?: any;
} | null;
}>;
}
getUserFriends(limit, offset)Get user's friends/connections with pagination.
Parameters:
limit: number - Maximum number of friends to returnoffset: number - Number of friends to skip (for pagination)Returns: Promise<ApiResponse<UserFriendsResponsePayload>>
interface UserFriendsResponsePayload {
friends: Array<{
id: string;
name: string;
imageUrl: string;
}>;
}
giveRole(roleId, userId)Assign a role to a user.
Parameters:
roleId: string - ID of the role to assignuserId: string - ID of the user to assign the role toReturns: Promise<ApiResponse<void>>
Plugin Code
↓
CgPluginLib.getUserInfo()
↓
Internal request signing via /api/sign
↓
postMessage to host with signed request
↓
Host validates signature and responds
↓
Response returned to plugin
getUserInfo())/api/sign endpoint'use client';
import { CgPluginLib } from '@common-ground-dao/cg-plugin-lib';
import { useSearchParams } from 'next/navigation';
import { useEffect, useState } from 'react';
export default function MyPlugin() {
const [userInfo, setUserInfo] = useState(null);
const searchParams = useSearchParams();
const iframeUid = searchParams.get('iframeUid');
useEffect(() => {
async function initPlugin() {
const lib = await CgPluginLib.initialize(
iframeUid || '',
'/api/sign',
process.env.NEXT_PUBLIC_PUBKEY
);
const response = await lib.getUserInfo();
setUserInfo(response.data);
}
initPlugin();
}, [iframeUid]);
return (
<div>
<h1>Welcome {userInfo?.name}!</h1>
{/* Your plugin UI here */}
</div>
);
}
// pages/api/sign.ts or app/api/sign/route.ts
import { CgPluginLibHost } from '@common-ground-dao/cg-plugin-lib-host';
export async function POST(req: Request) {
const body = await req.json();
const host = await CgPluginLibHost.initialize(
process.env.PRIVATE_KEY,
process.env.PUBLIC_KEY
);
const { request, signature } = await host.signRequest(body);
return Response.json({ request, signature });
}
If you have an existing Common Ground plugin, simply:
yarn add @common-ground-dao/cg-plugin-libMake sure your plugin has the required environment variables:
# .env
NEXT_PUBLIC_PUBKEY=your_public_key_here
NEXT_PRIVATE_PRIVKEY=your_private_key_here
The library provides comprehensive error handling:
try {
const userInfo = await lib.getUserInfo();
} catch (error) {
if (error.message.includes('timeout')) {
// Handle timeout
} else if (error.message.includes('signature')) {
// Handle signature validation error
} else {
// Handle other errors
}
}
# Build TypeScript to JavaScript
yarn build
# Watch for changes during development
yarn dev
Test the library using the host application:
# In the root directory
cd packages/host-app
yarn dev
# Load your plugin and test API calls
| Original CG Version | Our Implementation | Status |
|---|---|---|
| 0.9.6 | 0.9.6 | ✅ Fully compatible |
| Earlier versions | 0.9.6 | ✅ Forward compatible |
This package is part of the standalone embed system. See the root README for contribution guidelines.
MIT License
Note: This is a drop-in replacement library. All code examples that work with the original @common-ground-dao/cg-plugin-lib will work exactly the same with this implementation.
FAQs
Drop-in replacement for Common Ground plugin client library with iframe sandboxing and postMessage API
The npm package @curia_/cg-plugin-lib receives a total of 1 weekly downloads. As such, @curia_/cg-plugin-lib popularity was classified as not popular.
We found that @curia_/cg-plugin-lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.