GithubHelp home page GithubHelp logo

ecomplus / auth Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 1.0 2.39 MB

JS client for E-Com Plus admin authentication

License: GNU Affero General Public License v3.0

JavaScript 96.12% HTML 3.88%
ecomplus authentication admin-login

auth's Introduction

E-Com Plus Auth

Publish CodeFactor npm version License AGPL

JS client for E-Com Plus admin authentication

CHANGELOG

Usage

The @ecomplus/auth package can be used to handle login and persist/manipulate admin account data and resources permitted trough E-Com Plus Store API.

It's available for both Node.js and browser environments.

Example

import ecomAuth from '@ecomplus/auth'

ecomAuth.login(localStorage.getItem('username'), localStorage.getItem('password'))

ecomAuth.on('login', self => {
  console.log('Login OK!', self)
  ecomAuth.createEcomplusSession().then(r => console.log(r))
})

ecomAuth.on('logout', self => {
  console.log('Out!', self)
})

auth's People

Contributors

dependabot[bot] avatar leomp12 avatar renovate[bot] avatar talissonf avatar

Watchers

 avatar  avatar  avatar

Forkers

thiagoabreudev

auth's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/create-release.yml
  • actions/checkout v4
  • actions/create-release v1
.github/workflows/publish.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/cache v4
npm
package.json
  • @ecomplus/client ^2.3.1
  • axios ^1.6.8
  • blueimp-md5 ^2.19.0
  • eventemitter3 ^5.0.1
  • @babel/core ^7.24.3
  • @babel/preset-env ^7.24.3
  • @commitlint/cli ^17.8.1
  • @commitlint/config-conventional ^17.8.1
  • @ecomplus/utils ^1.4.1
  • babel-loader ^8.3.0
  • core-js ^3.36.1
  • docdash ^2.0.2
  • husky ^3.1.0
  • jsdoc ^4.0.2
  • standard ^17.1.0
  • standard-version ^9.3.2
  • webpack ^4.47.0
  • webpack-cli ^3.3.12
  • webpack-dev-server ^3.11.3
  • core-js ^3.36.1
  • @ecomplus/utils ^1.4.1

  • Check this box to trigger a request for Renovate to run again on this repository

Documentation

We need documentation for lib methods with jsdoc and give some examples 📝

Request API method

Access token must be private, so user will not be able to pass token when calling ecomClient.store.

We should provide a method to call Store API with authentication (such as requestApi from EcomPassport), imo it can be just a wrapper for ecomClient.store, but already adding the correct storeId, authenticationId and accessToken, something like:

options => ecomClient.store({
  storeId,
  authenticationId,
  accessToken,
  ...options
})

Security problems

We're exposing session with access token, it's a public property on instance object and it's a problem 💀

My suggestion is to set session object as a private member and pass it as argument to method functions, reference:
https://www.crockford.com/javascript/private.html

Also, we must edit getAuth method (and any other returning access token) to return only my_id, without token.

New useful methods

Suggested TODOs:

  • getAuthenticationId: just pass session.my_id 🍰;
  • fetchAuthentication: fetch Store API and return respective authentication (current session) body;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.