Git Product home page Git Product logo

transparent-supply-extension-starter's Introduction

Extension starter for IBM Blockchain Transparent Supply

Stay up to date with the source

Overview

The web application for IBM Blockchain Transparent Supply allows for the integration of external third-party applications (extensions).

This is done by loading the extensions as iframes within the parent application, and then using a proprietary interface over postMessage to send data and commands back and forth.

This repository contains a "starter" application that implements this cross-frame interface, and demonstrates how to use a number of key integration features:

  • How to subscribe to a user token, so that they will not have to sign in separately to the extension;
  • How to use the token to call IBM Blockchain Transparent Supply APIs;
  • How to use integrated routing, so that the browser URL changes as users navigate within the extension;
  • How to link to other modules of the IBM Blockchain Transparent Supply, or other extensions.

This example application is built using Angular 9, but the postMessage interface is agnostic to libraries and frameworks used within the extension.

This example also uses the Carbon Design System, and it is recommended that extensions use this library so that their theme can match the main application.

Development

Getting Started

# install dependencies
npm install

# run full development environment 
npm start 

# Done! your server should be running on http://localhost:5000

Pointing to the correct instance

By default, this app proxies to https://developer.transparentsupply.ibm.com. If this is not the IBM Blockchain Transparent Supply instance you want to use, change the target in proxy.conf.json.

When started, the extension will detect if it is running inside an iframe to determine which Routing Strategy to use. If not in a frame, the extension will prompt you to enter your authorization token (JWT). You can acquire a token by logging in here.

Testing inside a frame

To develop and test inside the context of the parent application, you can load your extension here. This special route will attempt to load an extension at https://localhost:5000 with all permissions.

If you get an error message in your browser, such as The webpage at https://localhost:5000/ might be temporarily down, you likely have to accept the self-signed certificate that the Angular development tool generates. Navigate to https://localhost:5000/ directly and your browser should prompt you to do so.

Routing Strategy

When loaded inside a frame, the application swaps out Angular's LocationStrategy Class with an implementation that sends messages to the parent application. When the user navigates within your extension, it will send a message to the main application requesting a route change. When a user hits Back or Forward in their browser, the main application will send a message notifying the extension, which this implementation will react to. Existing angular routing methods like <a [routerLink]="['/some-route', { id: 'some_route_param' }]">some link text</a> will continue to work.

For an example of how to link other modules in the main application, see product-details.component.ts. This component constructs a special Navigation message with an absolute URL, indicating to the main application that it would like to route outside of the extension.

Deployment

When your extension is deployed and you are ready to integrate, contact IBM Blockchain Transparent Supply support with the URL for the extension, so that your instance can be properly configured. Note that you should be sure to protect your extension against XSS vulnerabilities, and that you will be required to sign a Statement of Understanding of Risk.

There are no self-service deployment options at this time.

Proxying

By default, this app makes requests to the relative path /ift/api/*. Therefore, when deployed, it is expected that your server will proxy requests made to /ift/api/* to the appropriate IBM Blockchain Transparent Supply instance. Nginx is a very popular web server that can be configured to do this.

Some IBM Blockchain Transparent Supply APIs allow for CORS requests, which would let your app run serverless. However, your origin must be added to an allowlist. Open a ticket with support if this option is right for you.


© Copyright IBM Corp. 2020 All Rights Reserved.

transparent-supply-extension-starter's People

Contributors

cwgormanibm avatar imgbotapp avatar johnwalicki avatar nrbarry avatar patricklowry avatar stevemar avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.