npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-opcua-role-set-client

v2.175.6

Published

pure nodejs OPCUA SDK - client-side role-set management (OPC 10000-18)

Readme

node-opcua-role-set-client

Client-side helpers for managing OPC UA Roles (OPC 10000-18 — Role-Based Security).

This package lets an OPC UA client discover the Roles published by a Server in its RoleSet object, read the identities currently mapped to each Role, and call the AddIdentity / RemoveIdentity methods on a Role.

It works against any session that implements IBasicSessionAsync — a real ClientSession, a PseudoSession (in-process), or any compatible session — and resolves the Role method/property NodeIds via translateBrowsePath, so no hard-coded NodeIds are required.

see http://node-opcua.github.io/

Installation

$ npm install node-opcua-role-set-client

Exports

| Export | Description | |--------|-------------| | ClientRoleSet | Recommended entry point — wraps a session and exposes the RoleSet as cached ClientRole objects. | | ClientRole | Wrapper around a single Role node (read / add / remove identities). | | RoleIdentitiesResult | { roleNodeId, roleName, identities }. | | browseRoles(session) | Low-level: browse the RoleSet, return NodeId + name of every Role. | | readAllRoleIdentities(session) | Low-level: read the identities of every Role. | | ClientUserManagement | Drive the UserManagement Methods: addUser / modifyUser / removeUser / changePassword / readUsers (§5). | | ModifyUserArgs | Options for ClientUserManagement.modifyUser (password?, userConfiguration?, description?). | | sessionRequiresPasswordChange(session) | True when the activated session must change its password first (§5.2.8). |

The same code works against a remote ClientSession and an in-process PseudoSessionClientRoleSet is the single, recommended way to interact with a RoleSet whether in-process or out-of-process.

ClientRoleSet — the recommended entry point

import { OPCUAClient } from "node-opcua-client";
import { ClientRoleSet } from "node-opcua-role-set-client";

const client = OPCUAClient.create({});
await client.withSessionAsync("opc.tcp://localhost:4840", async (session) => {
    const roleSet = new ClientRoleSet(session);

    // discover the roles
    const roles = await roleSet.getRoles();
    console.log(roles.map((r) => r.roleName));
    // -> ["Anonymous", "AuthenticatedUser", "Observer", "Operator", ...]

    // read the identities of every role
    const all = await roleSet.readAllRoleIdentities();
    for (const { roleName, identities } of all) {
        console.log(roleName, "->", identities.map((i) => i.criteria));
    }
});

Working with a single role

Obtain a ClientRole from the ClientRoleSet by name; it resolves the AddIdentity, RemoveIdentity and Identities NodeIds on first use, then caches them.

import { ClientRoleSet } from "node-opcua-role-set-client";
import { IdentityCriteriaType, IdentityMappingRuleType } from "node-opcua-types";

const roleSet = new ClientRoleSet(session);
const role = await roleSet.getRole("SecurityAdmin");
if (!role) throw new Error("SecurityAdmin role not found");

// read the current identities
const current = await role.readIdentities();

// grant the role to user "admin"
const rule = new IdentityMappingRuleType({
    criteriaType: IdentityCriteriaType.UserName,
    criteria: "admin"
});
const addResult = await role.addIdentity(rule);
if (addResult.statusCode.isNotGood()) {
    throw new Error("AddIdentity failed: " + addResult.statusCode.toString());
}

// ...and later revoke it
await role.removeIdentity(rule);

ClientRole API

| Method | Description | |--------|-------------| | readIdentities(): Promise<IdentityMappingRuleType[]> | Read the Identities property of the Role. | | addIdentity(rule): Promise<CallMethodResult> | Call the Role's AddIdentity method. | | removeIdentity(rule): Promise<CallMethodResult> | Call the Role's RemoveIdentity method. |

addIdentity / removeIdentity throw if the corresponding Method is not exposed by the Role; modifying the RoleSet typically requires a session authenticated with sufficient privileges (e.g. SecurityAdmin).

Related packages

License

Node-OPCUA is made available to you under the MIT open source license.

See LICENSE for details.

Copyright

Copyright (c) 2022-2026 Sterfive SAS - https://www.sterfive.com

Copyright (c) 2014-2022 Etienne Rossignon