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

liquicode_membership

v0.2.12

Published

A NodeJS library providing rudimentary membership services (e.g. Signup, Login, GetData, PutData).

Downloads

33

Readme

liquicode_membership

A NodeJS library providing rudimentary membership services (e.g. Signup, Login, GetData, PutData).

Installation

Using NPM for installation

npm install liquicode_membership

or: Clone the source code

git clone https://github.com/agbowlin/liquicode_membership.git

or: Download the source code

https://github.com/agbowlin/liquicode_membership/archive/master.zip

Getting Started

The liquicode_membership package contains source files required for both server and client operation.

Server will be running Socket.IO on top of NodeJS and will include the Membership.js file.

Clients will include the MembershipClient.js file.

Using on NodeJS (Server)

Instantiate and configure the Membership module.

var Membership = require('liquicode_membership/Membership.js');
Membership.RootFolder = npm_path.resolve(__dirname, '../members');

Wire the Membership module into a newly connected Socket.IO socket.

SocketIo.on('connection',
	function(Socket) {
		// ...
		Membership.WireSocketEvents(Socket, null);
		// ...
	});

Using on Browser (Client)

Include the Membership module into your html source file.

<script src="/node_modules/liquicode_membership/MembershipClient.js"></script>

Instantiate and configure the Membership module.

var socket = io.connect();
var cookies = SomeBrowserCookiesImplementation();

// Initialize the Membership object.
var Member = MembershipClient.GetMember('MyExampleApp', socket, cookies);
// Member will be preloaded with any membership info from browser cookies.
// i.e. Member.member_logged_in, Member.member_name, Member.session_id

Manipulate the Membership object to authenticate and use the Membership service.

Member.member_name = 'john';
Member.member_password = 'john-password';
Member.MemberLogin();
Member.OnMemberLogin = function(Success)
{
	console.log('OnMemberLogin returned ' + Success + ' for ' + Member.member_name);
};

Membership Security

By default, user passwords are stored in json files as salted hashes where each user has a unique and random salt.

This functionality is controlled by an internal flag within Membership.js called PASSWORDS_USE_SALTED_HASH. This is initially set to true within the code. Change this setting to false if you want to store passwords in plain text.

Membership Client API

  • MemberSignup(MemberName, MemberEmail, MemberPassword) : Register a new member name and email with the server. A member data file is created on the server. A new session will be created for the member (i.e. member will be logged in). Returns the new session id and the member data object.

    • MemberName (required) : The member name to register.
    • MemberEmail (optional) : The email address to be associated with this member. This is needed to further authenticate a member in the case of lost password.
    • MemberPassword (required) : The password used to authenticate this member.
  • MemberLogin(MemberName, MemberEmail, MemberPassword) : Authenticates a member and creates a new session. Returns the new session id and the member data object.

    • MemberName (required) : The name of the member to log in.
    • MemberPassword (required) : The password used to authenticate this member.
  • MemberLogout(SessionID, MemberName) : Destroys any existing session for the member. Returns true if successful.

  • GetMemberData(SessionID, MemberName) Retrieves the member data object for a member.

    • SessionID (required) : An active session id obtained from MemberSignup or MemberLogin.
    • MemberName (required) : The name of the member.
  • PutMemberData(SessionID, MemberName, MemberData) Updates the member data object for a member.

    • SessionID (required) : An active session id obtained from MemberSignup or MemberLogin.
    • MemberName (required) : The name of the member.
    • MemberData (required) : The new member data object to store.
  • PathList(Path, Recurse) : Lists all folders and files found under Path. Folder names will always end with a /.

  • PathRead(Path) : Reads content from the file specified by Path and returns it.

  • PathWrite(Path, Content) : Write Content to the file specified by Path. Path is created if it does not exist.

  • PathMake(Path) : Creates a new path. Creates any required parent folders.

  • PathClean(Path) : Removes all files and subfolders from a folder. Does not delete the folder itself.

  • PathDelete(Path) : Deletes the file or folder specified by Path. If Path is a folder, then it will be cleaned first.

Working with the Membership Client

The client implementation (to be included in your web pages) creates a Membership object containing a set fields and functions for invoking membership functions on the server.

Your code can use the Membership object authenticate users. Once a user has been authenticated via MemberSignup or MemberLogin, the resulting session id can be used to read and write user specific data to the server.

To invoke Membership functions, set the appropriate fields within a Membership object and then call one or more functions. For example, to call the MemberLogin function, set the member_name and member_password fields and then call MemberLogin() without any parameters.

Here is a list of API parameters and the Membership field which corresponds to it:

API Parameter Name | Membership field ------------------------|------------------------ MemberName | member_name MemberEmail | member_email MemberPassword | member_password SessionID | session_id MemberData | member_data

In code:

Membership.OnMemberLogin = function(Success) { console.log('Login status: ' + Success); };
Membership.member_name = 'john';
Membership.member_password = 'john-password';
Membership.MemberLogin();

Dependencies

Server: Membership.js

Client: MembershipClient.js

The Membership client currently relies on AngularJS and its cookies implementation.