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

chilli-pepper

v1.2.0

Published

Tiny JS client library for CoovaChilli JSON Interface

Downloads

8

Readme

(chilli) Pepper

Build Status

Tiny JS client library for CoovaChilli JSON Interface.

Basically it's a rewrite of ChilliLibrary.js with some improvements:

  • code is more modular
  • works with Browserify, AMD or simply including the minified script and use it globally.
  • can be used both in browser or in Node.js
  • functional tests
  • examples

Examples

Browserify / Node.js / io.js

npm install chilli-pepper, then:

var Pepper = require('chilli-pepper');

var pepper = Pepper({
  host: '192.168.1.1',
  port: 3990
});

pepper.logon('john', 'd0E', function(err, data) {

  if (data.clientState === 1) {
    // User is now logged in
  }

  // ...

});

Global

For globally use Pepper you must build it first. It's very easy:

  1. git clone this repo
  2. Run npm install
  3. Build Pepper running npm run build or npm run build-min (if you want a minified version). You'll find builded version in ./dist folder
  4. Include the builded script in your webapp

Then you'll have a global Pepper object ready to use:


var pepper = Pepper({
  host: '192.168.1.1',
  port: 3990
});

pepper.logon('john', 'd0E', function(err, data) {

  if (data.clientState === 1) {
    // User is now logged in
  }

  // ...

});

var pepper = Pepper(options)

Get a new Pepper instance. Available options are listed below.

Note that all options are optional: by default Pepper will try to extract required data from CoovaChilli redirect querystring.

  • host: String. Host name (or IP address) of CoovaChilli. If not specified, Pepper will try to extract host from CoovaChilli redirect querystring.

  • port: Number. Port of CoovaChilli. If not specified, Pepper will try to extract host from CoovaChilli redirect querystring.

  • ssl: Boolean. If you're using SSL on CoovaChilli, turn this on. By default, Pepper will automatically set this according to window.location.protocol.

  • ident: String. Hex encoded string used for CHAP-Password calculation. Default is 00.

  • interval: Number. If specified, Pepper will update status informations (clientState, ...) every {interval} ms.

  • uamservice: String. If specified, Pepper will do a JSONP call to this service in order to obtain a CHAP-Password (instead of calculating on the client side). See documentation below for more informations.

  • querystring String: Optional parameter if you want to manually pass CoovaChilli redirect querystring.

Note that Pepper will throw an exception if fails to build base CoovaChilli API url. This usually happens if:

  • You don't specify host/port
  • Pepper can't extract required data from CoovaChilli redirect querystring

Public methods

.refresh(callback)

Update internal status calling CoovaChilli status API. Callback is optional.

Callback arguments are:

  • err: Any error encountered during procedure
  • data: CoovaChilli status response.

.logon(username, password[, options], callback)

  • username: String user's username
  • password: String user's password
  • options: Object optional logon options (see below)
  • callback: Function callback function.

Performs a logon (checking current status first).

Available options are:

  • protocol: String authentication protocol. Currently, PAP and CHAP are supported, and the default is CHAP.

Callback arguments are:

  • err: Any error encountered during procedure
  • data: CoovaChilli logon response. If user is correctly authenticated, clientState property will be 1 (see examples above).

.logoff(callback)

Performs a logoff. Callback is optional.

Callback arguments are:

  • err: Any error encountered during procedure
  • data: CoovaChilli logoff response.

.startAutoRefresh(interval)

  • interval: Number. Interval length in milliseconds.

Starts automatic status refresh every interval ms.

Note that this function is called automatically if you specify interval option when creating Pepper instance, but you can also call it manually whenever you want.

.stopAutoRefresh()

Stops automatic status refresh.

Public properties

.status

User's status object. This will be updated:

  • Everytime you call logon, logoff, or refresh methods
  • Every interval ms (if specified)

Debug

This library is builded with debug module.

If you want to see debug messages in browser:

localStorage.debug = '*' // in a JS console

If you want to see debug messages in Node.js:

DEBUG=* {yourScript}.js

Test

Run tests in Node.js (using jsdom):

npm test

Run tests in browser:

npm run test-server

Then go to http://localhost:4000

TODO

  • write more tests
  • add test coverage info

License

The MIT License (MIT)

Copyright (c) 2015 Michele Pangrazzi <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.