npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cybrid/cybrid-sdk-ui-js

v0.0.486

Published

A javascript library of web components that integrate with Cybrid's api. View our documentation at https://github.com/Cybrid-app/cybrid-sdk-web/

Downloads

147

Readme

@cybrid/cybrid-sdk-ui-js

This package includes a bundled javascript web component (application) containing a variety of styled components that interface with Cybrid's api.

Install

npm install @cybrid/cybrid-sdk-ui-js@latest --save

Quick Start

Cross-Origin Resource Sharing (CORS)

The following URL's will have to be whitelisted to properly view the components:

Crypto currency icon assets: https://images.cybrid.xyz/

HTML

To use the application via html load it into your index.html as a script.

The script registers cybrid-app as a web-component in your window.

NOTE: If you are embedding this library in an Angular application you will want to omit cybrid-sdk-ui.polyfills.js to avoid duplication of zone.js

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Host Application</title>

    // Omit if already importing zone.js in an Angular application
    <script type="module" src="cybrid-sdk-ui.polyfills.js"></script>

    // Main, runtime, and css bundle
    <script type="module" src="cybrid-sdk-ui.min.js"></script>
  </head>
  <body>
    <cybrid-app
      [auth]="token"
      [config]="config"
      [component]="component"
    ></cybrid-app>
  </body>
</html>

Javascript

You can generate the application in Javascript instead of using the selector in HTML:

NOTE: You must still reference 'cybrid-app' in document.createElement()

<script>
  const cybrid = document.createElement('cybrid-app');
  cybrid.auth = 'your_JWT';
  cybrid.config = 'config';
  cybrid.component = 'component';
  document.body.append(cybrid);
</script>

If you want to append the application elsewhere than the body try:

document.getElementById('your-element').append(cybrid);

Configuration

You can change configuration during runtime. The application:

  • Accepts an auth, config, and component property
  • Emits events via eventLog and errorLog

auth (required)

Expects a JSON Web Token. The component won't display unless the bound JWT is valid.

Example:

<cybrid-app auth="ey...."></cybrid-app>

hostConfig (required)

A default component configuration is set if no config is bound. The full configuration object must be defined.

NOTE: Config is currently required due to the necessity of a customer GUID. In the future this will be removed and revert to a default config if undefined. The customer GUID will be embedded in the JWT.

interface ComponentConfig {
  refreshInterval: number;
  routing: boolean;
  locale: string;
  theme: string;
  customer: string;
  fiat: string;
  features: Array<string>;
  environment: string;
  redirectUri?: string;
}

Example:

your_config = {
  refreshInterval: 10000,
  routing: true,
  locale: 'fr-CA',
  theme: 'DARK',
  customer: '969c744a02b11ed', //example GUID,
  fiat: 'USD',
  features: ['kyc_identity_verifications'],
  environment: 'sandbox',
  redirectUri: 'https://app.com/bank-account-connect'
};
<cybrid-app [config]="your_config"></cybrid-app>

Parameters

refreshInterval

The number in milliseconds the component waits before refreshing data. Default: 5000

routing

A routing flag to enable or disable internal routing between components. Default: true

NOTE: Disabling routing will also remove routing elements from the ui, like the back button in trade. The app will still fire events where routing would have occurred such as completing a trade, or clicking an asset in the price-list. See 'Events' below for more information.

locale

The current locale. Supports: 'en-US' | 'fr-CA' Default: 'en-US'

theme

Light mode or dark mode styling. Supports: 'LIGHT' | 'DARK' Default: 'LIGHT'

fiat

The current fiat currency (counter asset for all value calculation). Supports: 'USD | CAD' Default: 'USD'

features

The banks features. Supports: 'attestation_identity_records' | 'kyc_identity_verifications' Default: []

environment

The environment that you are authenticated against. Supports: 'sandbox' | 'production'

``redirectUri`

The redirect Uri that the Plaid SDK uses to return from a mobile OAuth flow. It must be registered with Cybrid so that we may add it to an internal Plaid allow-list. If this is undefined and on web-mobile the bank-account-connect component will return an Error, and serve a message to the user that explains mobile access is unavailable. The query parameter 'oauth_state_id' returned from Plaid must be present in the url when you re-render the bank-account-connect component after authentication.

NOTE: We cannot register a URI that uses a hash location strategy, ex: https://app.com/#/bank-account-connect

component (optional)

The currently displayed component. By default, the price-list component is rendered.

Components:

  • price-list
  • trade
  • account-list
  • identity-verification (Kyc configured banks only)
  • bank-account-connect (Plaid configured banks only)
  • bank-account-list (Plaid configured banks only)
  • transfer (Plaid configured banks only)

Example:

<cybrid-app component="trade"></cybrid-app>

bank-account-connect

Query params:

  1. oauth_state_id. Returned by Plaid during a mobile OAuth flow. Completes the OAuth flow.
  2. external_bank_account. An external bank account guid. Pass to reconnect a bank account in the refresh_required state.

Events

An event logging service that can be subscribed to. Emits application events and errors as an eventLog Object:

interface EventLog {
  level: LEVEL;
  code: CODE;
  message: string;
  data?: any;
}

Example:

<cybrid-app (eventLog)="handleEvent($event)"></cybrid-app>

Javascript:

cybridApp.addEventListener('eventLog', (event) => {
  console.log(event.detail);
});

Errors

An error logging service that can be subscribed to. Emits application errors, as well as pass through api errors as an errorLog Object:

interface ErrorLog {
  // 'Error' for an application error or the status code from an http error
  code: number | string;
  message: string;
  data?: any;
}

Example:

<cybrid-app (errorLog)="handleError($event)"></cybrid-app>

Javascript:

cybridApp.addEventListener('errorLog', (event) => {
  console.log(event.detail);
});

License

This project is licensed under Apache 2.0, found in LICENSE