
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@ternion/opc-link-client
Advanced tools
A lightweight TypeScript client library for interacting with the TERNION-OPC-REST-API
A lightweight TypeScript client library for interacting with the QNetLinks OPC REST API. This library provides a type-safe interface for reading and writing OPC UA node values through a RESTful API.
TernionOpcLinkClient for easy instantiationfetch API (Node.js 18+)fetch API)http://localhost:9990 (default, configurable)npm install @ternion/opc-link-client
import { TernionOpcLinkClient } from '@ternion/opc-link-client';
// Create a client instance (uses default URL: http://localhost:9990/opc/api/v1)
const client = new TernionOpcLinkClient();
// Or specify a custom API URL
const client = new TernionOpcLinkClient('http://your-api-host:port/opc/api/v1');
// Get API information
const info = await client.getApiInfo();
console.log(info);
// Check API health
const health = await client.getHealth();
console.log(health);
import { TernionOpcLinkClient } from '@ternion/opc-link-client';
const client = new TernionOpcLinkClient();
// Get all cached values
const values = await client.getValues();
console.log(values);
import { TernionOpcLinkClient } from '@ternion/opc-link-client';
const client = new TernionOpcLinkClient();
// Read a specific node by ID
const value = await client.getValue('ns=1;s=Boolean.0');
// Read by alias (channel 0 of bool type)
const aliasValue = await client.getAlias('bool', 0);
// Get all aliases of a type
const allBools = await client.getAllAliases('bool');
// Force a fresh read (bypass cache)
const freshValue = await client.readNode({
nodeId: 'ns=1;s=Boolean.0',
forceRefresh: true
});
import { TernionOpcLinkClient } from '@ternion/opc-link-client';
const client = new TernionOpcLinkClient();
// Write using convenience helpers
await client.writeBoolean(0, true); // Write to Boolean.0
await client.writeInt16(1, 42); // Write to Int16.1
await client.writeFloat(2, 3.14159); // Write to Float.2
// Write using generic writeNode method
await client.writeNode({
nodeId: 'ns=1;s=CustomNode',
dataType: 'Boolean',
value: true,
refreshCache: true
});
All methods throw errors on failure. Always wrap calls in try-catch:
try {
await client.writeBoolean(0, true);
} catch (error) {
console.error('Write failed:', error);
// Handle error appropriately
}
new TernionOpcLinkClient(apiBaseUrl?: string)
Creates a new client instance. The apiBaseUrl parameter is optional and defaults to "http://localhost:9990/opc/api/v1".
getApiInfo(): Promise<ApiInfo> - Get API metadata and available endpointsgetHealth(): Promise<HealthStatus> - Get current health status of the bridgegetValues(): Promise<NodeValue[]> - Get all cached node valuesgetValue(nodeId: string): Promise<NodeValue> - Get cached value for a specific nodegetAlias(type: AliasType, channel: number): Promise<NodeValue> - Get value by alias and channelgetAllAliases(type: AliasType): Promise<AliasCollection> - Get all channels for an alias typereadNode(request: ReadRequest): Promise<NodeValue> - Read a node (optionally force refresh)readBoolean(channel: number, forceRefresh?: boolean): Promise<NodeValue> - Read Boolean channelreadInt16(channel: number, forceRefresh?: boolean): Promise<NodeValue> - Read Int16 channelreadFloat(channel: number, forceRefresh?: boolean): Promise<NodeValue> - Read Float channelreadBooleanVector(forceRefresh?: boolean): Promise<NodeValue> - Read BooleanVector nodereadInt16Vector(forceRefresh?: boolean): Promise<NodeValue> - Read Int16Vector nodereadFloatVector(forceRefresh?: boolean): Promise<NodeValue> - Read FloatVector nodewriteNode(request: WriteRequest): Promise<WriteResponse> - Generic write functionwriteBoolean(channel: number, data: boolean): Promise<WriteResponse> - Write boolean valuewriteInt16(channel: number, data: number): Promise<WriteResponse> - Write 16-bit integer (-32768 to 32767)writeFloat(channel: number, data: number): Promise<WriteResponse> - Write floating-point valueTernionOpcLinkClient.validateChannel(channel: number): void - Validate channel indexTernionOpcLinkClient.validateAliasType(type: string): asserts type is AliasType - Validate alias typetype AliasType = 'bool' | 'int16' | 'float';
interface ReadRequest {
nodeId: string;
forceRefresh?: boolean;
}
interface WriteRequest {
nodeId: string;
dataType: 'Boolean' | 'Int16' | 'Float' | string | number;
value: unknown;
arrayType?: string | number;
refreshCache?: boolean;
}
interface WriteResponse {
status: string;
nodeId: string;
result: NodeValue;
}
interface NodeValue {
nodeId: string;
value: unknown;
dataType: string;
arrayType: string;
statusCode: string;
sourceTimestamp: string;
serverTimestamp: string;
updatedAt: string;
}
interface ApiInfo {
[key: string]: unknown;
}
API metadata information returned by the root endpoint.
interface HealthStatus {
[key: string]: unknown;
}
Health status information returned by the health endpoint.
type AliasCollection = NodeValue[];
Collection of alias values returned by getAllAliases().
See the examples/ directory for complete usage examples.
Run the demo example:
npm start
Or directly:
npx tsx examples/demo.ts
npm run build
This compiles TypeScript to the dist/ directory.
npx tsc --noEmit
npm run clean
Removes the dist/ directory.
@ternion/opc-link-client/
├── src/
│ ├── index.ts # Main entry point
│ └── ternion-opc-link-client/
│ └── ternion-opc-link-client.ts # Client implementation
├── dist/ # Compiled output (generated)
├── examples/ # Example code
│ └── demo.ts
├── package.json
├── tsconfig.json
└── README.md
MIT
Promise<unknown> return types with proper TypeScript interfaces
getApiInfo() now returns Promise<ApiInfo>getHealth() now returns Promise<HealthStatus>getValues() now returns Promise<NodeValue[]>getValue(), getAlias(), readNode(), and all convenience read methods now return Promise<NodeValue>getAllAliases() now returns Promise<AliasCollection>ApiInfo, HealthStatus, and AliasCollectionFAQs
A lightweight TypeScript client library for interacting with the TERNION-OPC-REST-API
We found that @ternion/opc-link-client 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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.