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

auth-imperial

v1.2.1

Published

A Promise-based authentication method for Imperial College student accounts

Downloads

16

Readme

node-auth-imperial

A Promise-based NodeJS authentication method for Imperial College student accounts. You may find this useful for any applications you are building for student development initiatives on Imperial's campus.

Latest Stable Version License NPM Downloads NPM Downloads

Installing

Assuming you have node and npm installed, the package can be installed from npm's public registry.

npm install auth-imperial

Usage

The module exports one simple default method. Usage examples are below.

const authImperial = require("auth-imperial");

(async () => {
    let loggedIn = await authImperial("SHORTCODE", "PASS");
    console.log(loggedIn);
})();

// OR

authImperial("SHORTCODE", "PASS").then(loggedIn => {
    console.log(loggedIn);
});

Inspiration

This came about through the lack of methods to authenticate Imperial student accounts externally of the Imperial College website, with the only other provider on campus requiring setting up a Kerberos instance within the Imperial network to communicate with.

This hindered the development of student projects involving Imperial accounts, having to seek very special permissions from the Imperial ICT team.

Original Method

After finding an undocumented public API upon the Imperial.ac.uk website, this module was created to allow for student-led projects to attach user accounts to their Imperial student accounts using this API. This was done via:

POST https://www.imperial.ac.uk/secure/login/

The body for the POST request is of the format

{
    uname: string, // Username / Imperial Shortcode
    pwd: string // Password for their Imperial account
}

The response from this endpoint would return the resulting HTML of the page to load, which will detail an error message just above the login form based on the success of the login, which was checked against using cheerio.

Current Method

After the Imperial ICT team reached out to us to note that the API endpoint would be deprecated as it was an old webpage that should have been removed long ago but activity from societies and student projects using the endpoint made the ICT team aware of this legacy endpoint.

Luckily, the Imperial College Student Union does offer an endpoint for students to use, which this module has been adapted to using.

POST https://eactivities.union.ic.ac.uk/user/login

The body for the POST request is of the format

{
    username: string, // Username / Imperial Shortcode
    password: string // Password for their Imperial account
}

If the username or password is incorrect, a HTTP 4XX ERROR is thrown, which is caught and regarded as a failed login attempt. If the user's details are correct, a HTTP 200 OK is returned, with the user understood to be verified.