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 🙏

© 2024 – Pkg Stats / Ryan Hefner

axis-configuration

v5.0.1

Published

A Node.js library written in TypeScript capable of configuring Axis Communication cameras.

Downloads

98

Readme

axis-configuration

axis-configuration npm version SemVer compatible

A Node.js library written in TypeScript capable of configuring Axis Communication cameras.

Table of contents


Super simple to use

const connection = new Connection(Protocol.Http, '192.168.1.102', 80, 'root', '32naJzkJdZ!7*HK&Dz');

//// Parameters
const parameters = new Parameters(connection);
let root: { [name: string]: string };

// Get parameter
root = await parameters.get('Network.Bonjour.FriendlyName');
// => { 'Network.Bonjour.FriendlyName': 'Some name' }

// Get parameters using wildcard
root = await parameters.get('Network.*.FriendlyName');
// => { 'Network.Bonjour.FriendlyName': 'Some name', 'Network.UPnP.FriendlyName': 'Some name' }

// Get parameter group
root = await parameters.get('Network.Bonjour');
// => { 'Network.Bonjour.FriendlyName': 'Some name', 'Network.Bonjour.Enabled': 'yes' }

// Update parameter
await parameters.update({ 'Network.Bonjour.FriendlyName': 'Some new name' });

// Update parameters
await parameters.update({
    'Network.Bonjour.FriendlyName': 'Some new name',
    'Network.UPnP.FriendlyName': 'Some new name'
});

//// Users
const userAccounts = new UserAccounts(connection);

// Get all user accounts
const users = await userAccounts.getAll();
// => [ User { name: 'root', password: undefined, accessRights: 2, ptz: true } ]

// Add user account
const user = new User('John', 'D2fK$xFpBaxtH@RQ5j', AccessRights.Viewer, true);
await userAccounts.add(user);

// Update user account
const promotion = new User(user.name, user.password, AccessRights.Operator, user.ptz);
await userAccounts.update(promotion);

// Remove user account
await userAccounts.remove(user.name);

Installation

npm install axis-configuration
# or
yarn add axis-configuration

Prerequisites

The library support cameras with the following characteristics:

  • Property: Properties.API.HTTP.Version=3
  • Firmware: 5.00 and later

Parameters

The HTTP-based Axis camera interface called VAPIX® provides the functionality for getting and setting internal parameter values. The following classes will enable you to focus on the code in your application instead of having to deal with the intricate nature of HTTP requests and responses.

Parameters

The Parameters class exposes parameter related operations on the camera. With it you can read and write parameters. Please note that the parameters you can read and write depend on the access rights of the user you specify to carry out these operations.

/**
 * Class responsible getting and setting non-dynamic parameter values. Non-dynamic parameters are
 * pre-configured and already exist in your Axis product. A non-dynamic parameter has one or more
 * values. Some non-dynamic parameters are configurable and some are read only.
 */
class Parameters {
    /**
     * Gets parameters and their current values.
     * @param parameterGroups A sequence of parameters named '{group}.{name}'. If {name} is
     * omitted, all the parameters of the {group} are returned. Wildcard (*) can be used filter
     * parameters. E.g. 'Network.*.FriendlyName' will return the two parameters
     * 'Network.Bonjour.FriendlyName' and 'Network.SSDP.FriendlyName'.
     * @throws {UnauthorizedError} User is not authorized to perform operation.
     * @throws {RequestError} Request failed.
     */
    get(...parameterGroups: string[]): Promise<{ [name: string]: string }>;

    /**
     * Updates parameters with new values.
     * @param parameters An object with parameters named '{group}.{name}' and their corresponding
     * new value.
     * @throws {UpdateParametersError} Updating one or many of the parameters failed.
     * @throws {UnauthorizedError} User is not authorized to perform operation.
     * @throws {RequestError} Request failed.
     */
    update(parameters: { [name: string]: string }): Promise<void>;
}

User accounts

The HTTP-based AXIS camera interface called VAPIX® provides the functionality for adding a new user account with password and group membership, modify the information and remove a user account. The following classes will enable you to focus on the code in your application instead of having to deal with the intricate nature of HTTP requests and responses.

UserAccounts

The UserAccounts class exposes all user account related operations on the camera. With it you can add, read, update and remove user accounts. Please note that you need an existing user with administrator access rights to carry out these operations.

/**
 * Class responsible for adding a new user account with password and group membership, modify the
 * information and remove a user account.
 */
class UserAccounts {
    /**
     * Adds a new user.
     * @param user The user to add. Please note that the password must be specified.
     * @throws {UserAlreadyExistsError} User already exists.
     * @throws {UnauthorizedError} User is not authorized to perform operation.
     * @throws {RequestError} Request failed.
     * @throws {UnknownError} Error cause is unknown.
     */
    add(user: User): Promise<void>;

    /**
     * Gets all users.
     * @throws {UnauthorizedError} User is not authorized to perform operation.
     * @throws {RequestError} Request failed.
     */
    getAll(): Promise<User[]>;

    /**
     * Updates a user.
     * @param user The user to update. Please note that the password must be specified.
     * @throws {UnauthorizedError} User is not authorized to perform operation.
     * @throws {RequestError} Request failed.
     * @throws {UnknownError} Error cause is unknown.
     */
    update(user: User): Promise<void>;

    /**
     * Removes a user.
     * @param username The name of the user to remove.
     * @throws {UnauthorizedError} User is not authorized to perform operation.
     * @throws {RequestError} Request failed.
     * @throws {UnknownError} Error cause is unknown.
     */
    remove(username: string): Promise<void>;
}

User

The User class is a immutable description of a user account on the camera.

/**
 * Class describing a user.
 */
class User {
    /**
     * The user account name (1-14 characters). Valid characters are a-z, A-Z and 0-9.
     */
    readonly name: string;

    /**
     * The unencrypted password (1-64 characters) for the account. ASCII characters from
     * character code 32 to 126 are valid.
     */
    readonly password: string | undefined;

    /**
     * The access rights for the user.
     */
    readonly accessRights: AccessRights;

    /**
     * Whether user has access rights for PTZ control.
     */
    readonly ptz: boolean;
}