Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @ecomplus/passport-client with all npm packages installed. Try it out:

require("@ecomplus/utils/package.json"); // @ecomplus/utils is a peer dependency. var passportClient = require("@ecomplus/passport-client")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@ecomplus/passport-client v1.0.10

Handle customer authentication with E-Com Plus Passport

E-Com Plus Passport Client

Publish CodeFactor npm version License MIT

Handle customer authentication with E-Com Plus Passport

CHANGELOG

Usage

The @ecomplus/passport-client package can be used to handle login and persist/manipulate customer account data trough E-Com Plus Passport and Store APIs.

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

Example

import ecomPassport from '@ecomplus/passport-client'

ecomPassport.fetchLogin(localStorage.getItem('email'), localStorage.getItem('doc_number'))

ecomPassport.on('logout', () => {
  console.log('User logged OUT')
})

ecomPassport.on('login', () => {
  console.log('User logged IN', ecomPassport.getCustomer())
  ecomPassport.fetchOrdersList()
    .then(orders => {
      console.log('Listing customer orders', orders)
    })
})

Installation

It may require and doesn't include core-js (optional) and @ecomplus/utils (peer dependency).

Webpack

npm i --save core-js @ecomplus/utils @ecomplus/passport-client

Node.js

npm i --save @ecomplus/utils @ecomplus/passport-client

CDN

<script src="https://cdn.jsdelivr.net/npm/@ecomplus/passport-client/dist/ecom-passport.var.min.js"></script>

When importing from CDN, EventEmitter3, ecomUtils and ecomClient libraries must be included separately and available on window scope.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free