
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
@ixo/matrix
Advanced tools
The @ixo/matrix package is a robust wrapper around the Matrix.org client SDK, specifically designed for the ixo-oracles ecosystem. It provides a secure, type-safe interface for managing Matrix communications with end-to-end encryption.
# Install using pnpm (recommended)
pnpm install @ixo/matrix
# Or using npm
npm install @ixo/matrix
# Or using yarn
yarn add @ixo/matrix
The package requires several environment variables for proper operation:
MATRIX_BASE_URL=https://your-matrix-server.com # Your Matrix homeserver URL
MATRIX_ORACLE_ADMIN_ACCESS_TOKEN=your_token # Admin access token
MATRIX_ORACLE_ADMIN_USER_ID=@admin:your.server # Admin user ID
MATRIX_ORACLE_ADMIN_PASSWORD=your_password # Password for cross-signing
MATRIX_RECOVERY_PHRASE=your_recovery_phrase # For secret storage & key backup
All paths are created in the matrix-local-storage folder:
MATRIX_CRYPTO_STORE_PATH=./matrix-crypto-store # Crypto storage
MATRIX_STORE_PATH=./matrix-store # General storage
MATRIX_SECRET_STORAGE_KEYS_PATH=./matrix-secret-storage # Secret keys
The package uses Matrix's cross-signing feature for enhanced security. This requires specific environment variables:
MATRIX_ORACLE_ADMIN_PASSWORD: Required for authenticating cross-signing key uploads. When setting up cross-signing, the package needs to upload device signing keys to the server. This operation requires authentication using the admin password.
MATRIX_RECOVERY_PHRASE: Used for:
import { MatrixManager } from '@ixo/matrix';
async function main() {
// 1. Get the singleton instance
const manager = MatrixManager.getInstance();
// 2. Initialize the manager
await manager.init();
// 3. Create and join a room
const roomId = await manager.createRoomAndJoin({
did: 'did:ixo:123',
oracleName: 'myOracle',
userAccessToken: 'user_access_token',
});
// 4. Send a message
await manager.sendMessage({
roomId,
message: 'Hello World',
});
}
Rooms in the ixo-matrix ecosystem are secure, encrypted spaces for communication. Each room has:
// Rooms are named using a deterministic hash of DID and oracle name
const roomName = MatrixManager.generateRoomNameFromDidAndOracle(
'did:ixo:123',
'myOracle',
); // Results in format: 'ixo-{md5hash}'
// Room aliases are generated by replacing spaces with underscores
const roomAlias = MatrixManager.generateRoomAliasFromName(roomName);
// Create a room with all security features enabled
const roomId = await manager.createRoomAndJoin({
did: 'did:ixo:123',
oracleName: 'myOracle',
userAccessToken: 'user_token',
});
// Check if a user has access to a room
const hasAccess = await manager.checkIsUserInRoom({
roomId,
userAccessToken: 'user_token',
});
// Get room by ID
const room = manager.getRoom(roomId);
// Get room ID from DID and oracle name
const existingRoomId = await manager.getRoomId({
did: 'did:ixo:123',
oracleName: 'myOracle',
});
The package uses two types of tokens for different operations:
MATRIX_ORACLE_ADMIN_ACCESS_TOKEN)Used for:
Used only for:
Example usage:
// Operations using Admin Token (automatically handled)
await manager.sendMessage({
roomId,
message: 'Hello World',
});
// Operations requiring User Token
// the user token is used only for joining the room -- the rest of the operations are handled by the admin token
await manager.createRoomAndJoin({
did: 'did:ixo:123',
oracleName: 'myOracle',
userAccessToken: 'user_token', // User token required
});
// Check if the user is in the room using the user token
await manager.checkIsUserInRoom({
roomId,
userAccessToken: 'user_token', // User token required
});
Note: User tokens are temporary and automatically cleaned up after use. All other operations use the admin token internally.
The package supports various message types and threading: All the messages will be sent from the Oracle Admin client.
// Regular message
await manager.sendMessage({
roomId,
message: 'Hello World',
});
// Threaded reply
await manager.sendMessage({
roomId,
message: 'Reply',
threadId: 'original_message_id',
});
// Oracle admin message
await manager.sendMessage({
roomId,
message: 'Admin notification',
isOracleAdmin: true,
});
Type-safe state management with validation:
interface ProjectState {
status: string;
lastUpdate: number;
}
// Set state
await manager.stateManager.setState<ProjectState>({
roomId,
stateKey: 'oracle_project',
data: {
status: 'active',
lastUpdate: Date.now(),
},
});
// Get state
const state = await manager.stateManager.getState<ProjectState>(
roomId,
'oracle_project',
);
// Update state
await manager.stateManager.updateState<ProjectState>({
roomId,
stateKey: 'oracle_project',
data: {
status: 'completed',
},
});
The package provides a Matrix-based checkpointer implementation for LangChain graphs, allowing you to persist graph state in Matrix rooms:
import { MatrixCheckpointSaver } from '@ixo/matrix';
import { StateGraph } from '@langchain/langgraph';
// Create your graph
const workflow = new StateGraph(graphState)
.addNode('myNode', (state) => {
// Your node logic
})
.addEdge(START, 'myNode')
.addEdge('myNode', END);
// Compile the graph with Matrix checkpointing
const graph = workflow.compile({
checkpointer: new MatrixCheckpointSaver('your-graph-name'),
});
The main interface for Matrix operations:
getInstance(): Get singleton instanceinit(): Initialize the managercreateRoomAndJoin(): Create and join a roomsendMessage(): Send a messagestop(): Cleanup resourcesHandles state management:
setState<T>(): Set typed stategetState<T>(): Get typed stateupdateState<T>(): Update existing statelistStateEvents<T>(): List all state events# Run unit tests
pnpm test
# Run integration tests
pnpm test:e2e
# Run with coverage
pnpm test:coverage
try {
await manager.sendMessage({
roomId,
message: 'Hello',
});
} catch (error) {
if (error instanceof MatrixError) {
// Handle Matrix-specific errors
console.error('Matrix error:', error.errcode);
} else {
// Handle other errors
console.error('General error:', error);
}
}
Internal package - All rights reserved.
FAQs
## Overview
The npm package @ixo/matrix receives a total of 46 weekly downloads. As such, @ixo/matrix popularity was classified as not popular.
We found that @ixo/matrix demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.