Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Vanilla javascript Web Component Demo

Learn how to embed Hydrogen Card Components using Vanilla javascript and Node.

Documentation

Read our guides below to become more familiar with how our components are authenticated and embedded in this app.

Web Component Guide

Authentication Guide

Technical Requirements

  1. Node.js Compatible with <= v14.17.4
  2. IP & Domain Whitelist

You must run the app on a real domain that you can whitelist on the Hydrogen portal in #2 above (localhost cannot be whitelisted), otherwise you will receive CORS Access-Control errors on the components. If you do wish to run the app locally, the app will still generate tokens and embed the components, as well as allow you to login.

Web Components

The following Hydrogen Web Components are used in the sample app.

Pre-Login

  1. Card Issuance

Uses the client_credentials OAuth grant type to issue a card for a brand new client that hasn't yet been created. If you wish to issue a card for a client that has already been signed up, you can either pass in a Nucleus client-id to the embed code, or embed post-login using the password grant type below.

Post-Login

  1. Card Balance
  2. Card Transactions

Uses the password OAuth grant type to only pull in balance and transaction data for the authenticated cardholder.

Setup

  1. Navigate to the .env file in the backend-node folder
  2. Update the following fields:
TENANT_NAME={YOUR OAUTH CLIENT_ID}
TENANT_PASSWORD={YOUR OAUTH CLIENT_SECRET}
PUBLIC_KEY={YOUR PUBLIC KEY}
BASE_PATH=https://api.hydrogenplatform.com/component/v1

You can find your credentials on the "API Keys & Whitelists" link on the header of the account portal.

  1. To test components post-login that use the password OAuth grant, you will need to create a username and password in the admin user service. Please read our docs here.

Installation

Open the command line, and follow the instructions below.

  1. Navigate to the node-sdk folder and then run the following command:
sudo npm link
  1. Navigate out of the current folder to the app-token-vanilla folder, and run the following commands:
sudo npm install http-server -g
http-server . -p 7029

Your browser should open at http://localhost:7029/ with a Login screen displayed.

  1. Finally, we will run the backend app. Open a new tab. Then navigate out of the current folder to the backend-node folder, and run the following commands:
sudo npm link ../node-sdk
node server.js

The backend Node server should now be running with a message Server is listening on port 3005. If you refresh the browser window now, you should see the Card Issuance component display.