How to use the node-opcua-client.UserTokenType.UserName function in node-opcua-client

To help you get started, we’ve selected a few node-opcua-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / opcua-commander / lib / model / model.ts View on Github external
export function makeUserIdentity(argv: any): UserIdentityInfo {

    let userIdentity: UserIdentityInfo = { type: UserTokenType.Anonymous }; // anonymous

    if (argv.userName && argv.password) {
        userIdentity = {
            type: UserTokenType.UserName,
            userName: argv.userName,
            password: argv.password
        };

    } else if (argv.userCertificate && argv.userCertificatePrivateKey) {

        userIdentity = {
            type: UserTokenType.Certificate,
            certificateData: argv.userCertificate,
            privateKey: "todo"
        };

    }
    return userIdentity;
}
github node-opcua / node-opcua / packages / playground / sample1.ts View on Github external
(async () => {
    try {

        console.log(" about to connect");
        await client.connect("opc.tcp://opcuademo.sterfive.com:26543");
        console.log("connected");

        client.on("backoff", () => {
            console.log("Backoff");
        });

        const session = await client.createSession({
            password: "password1",
            type: UserTokenType.UserName,
            userName: "user1",
        });

        const a = await session.getArgumentDefinition("ns=0;i=12886");

        console.log(a.inputArguments.map((x: Variant) => x.toString()).join(" "));

        const result = await session.browse({
            nodeId: "i=2558"
        });

        for (const reference of result.references!) {
            console.log(reference.toString());
        }
        const registeredNodes = await session.registerNodes(["ns=1;s=FanSpeed", "ns=1;s=PumpSpeed"]);
github node-opcua / node-opcua / packages / playground / sample2Subscriptions.ts View on Github external
async function test2() {

    console.log("----------------------------------------------------");

    try {

        await client.connect("opc.tcp://opcuademo.sterfive.com:26543");

        const session: ClientSession = await client.createSession({
            type: UserTokenType.UserName,

            password: "password1",
            userName: "user1"
        });

        const subscription = ClientSubscription.create(session, {
            maxNotificationsPerPublish: 1000,
            publishingEnabled: true,
            requestedLifetimeCount: 100,
            requestedMaxKeepAliveCount: 10,
            requestedPublishingInterval: 500
        });

        subscription.on("error", (err) => {
            console.log(" Error :", err);
        });
github node-opcua / node-opcua / packages / playground / sample2Subscriptions.ts View on Github external
async function test1() {

    try {

        await client.connect("opc.tcp://opcuademo.sterfive.com:26543");

        const session: ClientSession = await client.createSession({
            type: UserTokenType.UserName,

            password: "password1",
            userName: "user1"
        });

        const subscription = await session.createSubscription2({
            maxNotificationsPerPublish: 1000,
            publishingEnabled: true,
            requestedLifetimeCount: 100,
            requestedMaxKeepAliveCount: 10,
            requestedPublishingInterval: 1000
        });

        subscription.on("raw_notification", (n) => {
            console.log(n.toString());
        });