パッケージの詳細

@ecomplus/passport-client

ecomplus811MIT1.2.1

Handle customer authentication with E-Com Plus Passport

ecomplus, storefront, passport, login

readme

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.

更新履歴

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.2.1 (2023-11-06)

Bug Fixes

  • properly checking ECOMCLIENT_API_PASSPORT env and prevent error with conditional chain (20a8fc6)

1.2.0 (2023-11-05)

Features

  • edit requestApi to support direct calls to Store API v2 (cf9f755)

1.1.2 (2023-01-09)

Bug Fixes

  • deps: accept eventemitter3 v4 and v5 (70ece44)
  • deps: update dependency eventemitter3 to v5 (#193) (0d4535b)

1.1.1 (2021-09-17)

Bug Fixes

  • check-login: check for auth and id instead of name (may be empty) (2d711a6)

1.1.0 (2021-09-13)

Features

  • fetch-login: new optional emailCode param for login with email and verification code (6e0abb4)
  • send-email-code: send verification code by email before login/signup (9589c2f)

Bug Fixes

  • deps: update dependency eventemitter3 to ^4.0.4 (#65) (85b19e1)

1.0.10 (2020-05-16)

Bug Fixes

  • set-cookie: save cookie with sameSite=strict (1ecfb1f)

1.0.9 (2020-04-03)

1.0.8 (2020-04-02)

Bug Fixes

  • fetch-oauth-providers: returning passport requst promise (ba3e2e9)

1.0.7 (2020-03-30)

Bug Fixes

  • iframe: add name attr for a11y support (#51) (86771f0)
  • oauth-popup: send 'session_uri' param to redirect if no cookie set (66bfe81)

1.0.6 (2020-01-19)

Bug Fixes

  • request-api: stop checking verification manually here (02458ca)

1.0.5 (2020-01-08)

Bug Fixes

  • set-customer: save self.customer on localStorage (9465a16)

1.0.4 (2020-01-07)

Bug Fixes

  • check-authorization: make authotization dependent of login (dd3b5fc)
  • check-verification: make verification dependent of authorization (68b953b)

1.0.3 (2020-01-07)

1.0.2 (2020-01-02)

1.0.1 (2019-12-26)

1.0.0 (2019-12-26)

⚠ BREAKING CHANGES

  • events: edited events payload
  • methods: removed initSession method
  • methods: removed isLogged, isAuthorized, isVerified methods
  • webpack: root export changed
  • exports: changed default exported object
  • deps: ecomplus/utils and core-js no more direct dependencies

build

  • webpack: fix output var name to ecomPassport (ac8e455)
  • deps: fix dependencies (peer) (f654491)
  • events: emit login/logout without payload (remove self) (a6fb8f4)
  • exports: returning instance by default (70848bf)
  • methods: renaming boolean methods to checkAny (4a65ef6)
  • methods: renaming initSession to loadStoredSession (d6eb03e)

0.7.13 (2019-11-17)

0.7.12 (2019-11-14)

Bug Fixes

  • fetch-orders-list: fix orders sorting (345903b)

0.7.11 (2019-11-14)

Bug Fixes

  • init-session: just update instance session object on event (9df8449)

0.7.10 (2019-11-14)

Bug Fixes

  • reactive-session: introduce session update internal event (d31827b)
  • set-customer: limit customer fields to prevent excedent cookie size (b3c1a60)

0.7.9 (2019-11-13)

Bug Fixes

  • request-api: ensure method is lowercased (d435bfb)
  • set-customer: update cookie value with new customer (a023bbf)

0.7.8 (2019-11-13)

Features

  • set-customer: add new 'setCustomer' method (e8a9b73)

Bug Fixes

  • request-api: also update current session customer object (42844a2)

0.7.7 (2019-11-13)

Bug Fixes

  • fetch-orders-list: must sort orders again due to async results push (71e419b)

0.7.6 (2019-11-13)

Bug Fixes

  • fetch-orders-list: sort by order number desc (f505e77)

0.7.5 (2019-10-25)

Bug Fixes

  • fetch-order: fix endpoint, start using self.requestApi (#13) (784e8fe)
  • order resource and access_token (091829d)

0.7.4 (2019-10-17)

Bug Fixes

  • push only response data to order list (#9) (89767f3)

0.7.3 (2019-10-03)

Bug Fixes

  • request-api: fix checking authorization (0bf47b5)

0.7.2 (2019-09-25)

Bug Fixes

  • request-api: fix url with api prefix and handle token correctly (a77a3d9)

0.7.1 (2019-08-29)

Build System

  • webpack: fix webpack externals default config (bfa8f7f)

0.7.0 (2019-08-26)

Features

  • oauth-iframe: setup oauth session iframe to create cookies (6cea93d)

0.6.0 (2019-08-25)

Bug Fixes

  • fetch-oauth-providers: fix method name (camel case) (b0c53b8)

BREAKING CHANGES

  • fetch-oauth-providers: ftechOAuthProviders no more working (fixed name)

0.5.0 (2019-08-24)

Bug Fixes

  • constructor: events are global, set it on constructor (486be86)
  • constructor: get store id from config dynamically (9ab041b)
  • get-customer-name: call getCustomer method correctly (07a5dbb)

Features

  • emitter: emit events with self (instance) as argument (3443952)

Tests

  • events: update handling events (from constructor) (b719bc0)

BREAKING CHANGES

  • constructor: instance have no more on, off, once fn

0.4.0 (2019-08-23)

Bug Fixes

  • fetch: must use self.storeId to request store and passport api (298441e)

chore

  • rest-api: renaming method to 'restApi' only (af320af)

BREAKING CHANGES

  • rest-api: old 'requestRestApi' no more working

0.3.0 (2019-08-23)

Bug Fixes

  • fetch-oauth: fixing fetch methods names and handlers (fb1eade)
  • fetch-orders: fix names and handle fetch order and orders list (aeeeb72)
  • get-customer: fixing get methods names and handlers (651fd3c)
  • logout: ensure cookie unset (777926a)
  • logout: fix unseting cookie (5d87191)
  • logout: return self instance (as a setter) (8dd4baf)
  • post-login: fix method to login with email/doc (ae85bde)
  • set-session: check auth level with isAuthorized (9ae8521)
  • set-session: save to cookie with expiration time, emit with level (6ba50dc)
  • state-getters: handling is authorized and is logged (bools) (f2311cb)

Features

  • init-session: try to get stored session, create session id (b59d84c)
  • is-verified: method to check last authorization level (a588273)
  • popups: popup for oauth direct link and login menu (1c97122)
  • request-rest-api: send authenticated request to passport rest api (ceb0368)

refactor

  • consturctor: renaming methods, removing unecessary members (f47705a)

Tests

  • fix: update with new methods (ccb16f0)

BREAKING CHANGES

  • consturctor: methods renamed, old methods will no more work

0.2.0 (2019-08-22)

Bug Fixes

  • list-orders: fix method to output errors, add pagination (5bef449)
  • (#4) (903f47e)
  • customerName method returning display_name property (1414529)
  • edit popup size, height 500, width based on screen width (9aef895)

Build System

  • webpack: fix lib name and externals config (a242277)

Features

  • init: try to get cookie from session (dafbeab)
  • login: by email and doc_number (197a9ea)
  • login: popup with providers list (5bb241e)
  • method: checks if user is logged (240fd7d)
  • method: return data from single order (728d94e)
  • method: return list of orders from logged customer (85f3db2)
  • method: return list of providers (187cbff)
  • method: return user session (08b40aa)
  • method: set customer session (2be6bf9)
  • method: user logout (48c61f2)
  • methods: edit customer (73d9fd8)
  • methods: edit order (fe09e14)
  • methods: return customer name (d83ec25)
  • methods: return customer object (7645bd0)
  • methods: return session object (7fbc42e)
  • login via rest (e17ab8e)

Tests