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

@epitech.js/puppeteer-auth-provider

v0.1.0

Published

Auth provider for epitech.js using Puppeteer to provide authentication cookies for the intranet

Downloads

9

Readme

@epitech.js/puppeteer-auth-provider

Authentication provider for Epitech.js.

This provider is used by epitech.js to authenticate to the intranet without autologin.

It uses puppeteer to do the authentication and then stores the cookies in a file. Puppeteer is a headless browser. It can be used on servers or on local machines.

Puppeteer will only be used when the user is not authenticated. If the user is already authenticated and the last known authentication cookie is already valid, the browser will not be opened.

Install

npm install --save epitech.js @epitech.js/puppeteer-auth-provider

Usage

Import epitech.js and the provider in your project:

import { RawIntra } from 'epitech.js';
import { PuppeteerAuthProvider } from '@epitech.js/puppeteer-auth-provider';

// or

const { RawIntra } = require('epitech.js');
const { PuppeteerAuthProvider } = require('@epitech.js/puppeteer-auth-provider');

You can then use it with epitech.js like this:

const intra = new RawIntra({
    provider: new PuppeteerAuthProvider({
        // path to the file where the auth data will be stored
        storageFilePath: './auth.json',
    }),
});

// ...

console.log(await intra.getDashboard());

Troubleshooting

No graphical interface

If you are running on a server, you can't use the graphical interface.

But in order to do the first authentication, you will need to run your program in a machine with a graphical interface due to the required interactions.

Once you have done that, you can run the program again. It will automatically authenticate you, without requiring any interaction until you get logged out of Office 365. If you want to keep your session longer, don't forget to select "Yes" when asked if you want Microsoft to remember you.

Your session will be saved in the storage file you specified (e.g. auth.json). You can copy this file to another machine and run the program on that machine considering you specify the correct storage file path. Then, you will then be able to login without having to do any further interaction, until you get logged out of Office 365.

You can delete the storage file if you want to start over. The program will then ask you to authenticate again.

You may also disable the graphical interface by setting the showAuthDialog option to false in the provider constructor. This will make the program throw an error if you need to do an interactive authentication.

const intra = new RawIntra({
    provider: new PuppeteerAuthProvider({
        // ...
        showAuthDialog: false,
    }),
});

How to make it work on a Raspberry Pi?

You might encounter issues with the bundled Chrome revision (fail to load due to syntax error, etc.).

To make it work, you can download the chromium or chromium-browser package with your system package manager, and specify to use this one instead of the bundled one by setting puppeteer's executablePath option:

const intra = new RawIntra({
    provider: new PuppeteerAuthProvider({
        // ...
        puppeteer: {
            executablePath: '/usr/bin/chromium-browser',
        },
    }),
});

In Raspbian, you can install chromium like this:

# install chromium
sudo apt-get install chromium-browser

Permissions issues (e.g. root user)

It's possible that Puppeteer might refuse to run because of permissions issues, for example if you're running your program in a Docker container.

You may try to disable the sandbox by passing the --no-sandbox startup flag to Puppeteer Chrome instance.

const intra = new RawIntra({
    provider: new PuppeteerAuthProvider({
        // ...
        puppeteer: {
            executablePath: '/usr/bin/chromium',
            args: ['--no-sandbox'],
        },
    }),
});

In the case where --no-sandbox is not enough, you may want to use --disable-setuid-sandbox too.

const intra = new RawIntra({
    provider: new PuppeteerAuthProvider({
        // ...
        puppeteer: {
            executablePath: '/usr/bin/chromium',
            args: ['--no-sandbox', '--disable-setuid-sandbox'],
        },
    }),
});