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 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-laravel-passport

v1.0.2

Published

Conector for laravel passport oauth for node applications

Readme

NODE LARAVEL PASSPORT CONNECTOR

This package performs Oauth between your NODE application and a LARAVEL application that uses Passport as authentication.

INSTALL

npm install node-laravel-passport

Now you can import with:

import Passport from 'node-laravel-passport'

Or

const Passport = require('node-laravel-passport');

CONFIG LARAVEL APPLICATION

In your laravel application you run the command

php artisan passport:client

which will generate a client with a client_id, secret_id and a callback url.

CONFIG YOUR NODE APPLICATION

You must have two endpoints in your node application so that you can receive calls from LARAVEL... I advise a call 'youapplicationurl' + 'redirect'...This is the entry url And another is your callback registered in "passport:client". So y Then you will have something like this:

Route.get('/redirect','PassportController.redirect');
Route.get('/auth/callback','PassportController.callback')

CONFIG YOUR CONTROLLER AND PACKAGE

create an instance of our Passporte connector and connection client

  • client_id - string -provided in passport:client
  • secrect_id - string -provided in passport:client
  • callback_url - string -provided in passport:client
  • laravelPassportApi - your laravel application (ex: http://localhost:8000)
 const passport = new Passport();
 passport.createClient(client_id, secret_id, callback_url, laravelPassportApi);

After this process, you should do a redirect requesting your client's code. The passportCreateUriAutorize method creates this url and you just have to redirect it in your application

    redirect({request, response}) {
    const uriAuthoriize = this.passport.passportCreateUriAutorize();
    response.redirect(uriAuthoriize)
  }

As you can see this redirect method is called in the 'redirect' route that comes from the application

The return of this redirect will be exactly the 'auth/callback' route or the route you registered as a callback in passport:client Now we can take our access_token and establish authorization between the two applications

    async callback({request, response}) {
    const code = request.all().code
    let oatuhAcessToken = await this.passport.passporGetAccessToken(code);
  }

The return of passporGetAccessToken will be an object with its access_token, token_type, expires_in and a refresh_token

{
  "token_type": "Bearer",
  "expires_in": "",
  "access_token": "",
  "refresh_token": ""
}

FULL CLASS EXEMPLE

'use strict'

const Passport = require('node-laravel-passport');

const client_id = '';
const secret_id = '';
const callback_url = 'http://127.0.0.1:3333/auth/callback';
const laravelPassportApi = 'http://127.0.0.1:8000'

class PassportController {

  constructor() {
    this.passport = new Passport();
    this.passport.createClient(client_id, secret_id, callback_url, laravelPassportApi);
  }


  redirect({request, response}) {
    const uriAuthoriize = this.passport.passportCreateUriAutorize();
    response.redirect(uriAuthoriize)
  }

  async callback({request, response}) {
    const code = request.all().code
    let oatuhAcessToken = await this.passport.passporGetAccessToken(code);
  }

}

module.exports = PassportController