Socket
Socket
Sign inDemoInstall

ngx-plaid-link

Package Overview
Dependencies
5
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-plaid-link

Angular Plaid Link Directive & Button Component


Version published
Weekly downloads
5K
decreased by-9.97%
Maintainers
1
Install size
228 kB
Created
Weekly downloads
 

Changelog

Source

14.0.0

  • Refactored interfaces to better support Plaid Link going forward
    • Renamed: PlaidConfig to LegacyPlaidConfig
    • New Interface: PlaidConfig, only supports latest parameters of Plaid Link create docs
    • New Type: PlaidCreateConfig - a union between LegacyPlaidConfig and PlaidConfig which is used to pass to
  • ngxPlaidLink directive allows button to be programmatically disabled eg. fetching token from backend.

Breaking Changes

I tried to make as few breaking changes as possible, but there is one scenario where you could need to update your code.

  • PlaidConfig interface - If you used the exported PlaidConfig interface in your code, you may need to change it to LegacyPlaidConfig if you're using the old publicKey flow which is deprecated and will eventually be turned off.

Readme

Source

A wrapper component to make using Plaid Link easy in Angular 6+.

This has been tested to work in at least 1 Angular 5 app as well

How to use

1a) Install from NPM
$ npm install ngx-plaid-link
1b) Or Yarn
$ yarn add ngx-plaid-link
2) Import the NgxPlaidLinkModule
import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";

import { AppComponent } from "./app.component";
import { NgxPlaidLinkModule } from "ngx-plaid-link";

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, NgxPlaidLinkModule],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}
<button ngxPlaidLink
  env="sandbox"
  publicKey="YOURPUBLICKEY"
  institution=""
  [countryCodes]="['US', 'CA', 'GB']"
  (Success)="onPlaidSuccess($event)"
  (Exit)="onPlaidExit($event)"
  (Load)="onPlaidLoad($event)"
  (Event)="onPlaidEvent($event)"
  (Click)="onPlaidClick($event)"
>Link Your Bank Account</button>
3b) The easy way, with the provided button
<mr-ngx-plaid-link-button
  env="sandbox"
  publicKey="YOURPUBLICKEY"
  institution=""
  [countryCodes]="['US', 'CA', 'GB']"
  (Success)="onPlaidSuccess($event)"
  (Exit)="onPlaidExit($event)"
  (Load)="onPlaidLoad($event)"
  (Event)="onPlaidEvent($event)"
  className="launch-plaid-link-button"
  buttonText="Link Your Bank Account"
  (Click)="onPlaidClick($event)"
></mr-ngx-plaid-link-button>
3b) The less easy way, implement yourself

Since most of the functionality is through the service you can imlpement this yourself to customize to your needs further.

import { Component, AfterViewInit } from "@angular/core";
import {
  PlaidErrorMetadata,
  PlaidErrorObject,
  PlaidEventMetadata,
  PlaidOnEventArgs,
  PlaidOnExitArgs,
  PlaidOnSuccessArgs,
  PlaidSuccessMetadata,
  PlaidConfig,
  NgxPlaidLinkService,
  PlaidLinkHandler
} from "ngx-plaid-link";

export class ComponentThatImplementsPlaidLink implements AfterViewInit {
  private plaidLinkHandler: PlaidLinkHandler;

  private config: PlaidConfig = {
    apiVersion: "v2",
    env: "sandbox",
    institution: null,
    selectAccount: false,
    token: null,
    webhook: "",
    product: ["auth"],
    countryCodes: ['US', 'CA', 'GB']
    key: "YOURPUBLICKEY"
  };

  constructor(private plaidLinkService: NgxPlaidLinkService) {}

  // Create and open programatically once the library is loaded.
  ngAfterViewInit() {
    this.plaidLinkService
      .createPlaid(
        Object.assign({}, config, {
          onSuccess: (token, metadata) => this.onSuccess(token, metadata),
          onExit: (error, metadata) => this.onExit(error, metadata),
          onEvent: (eventName, metadata) => this.onEvent(eventName, metadata)
        })
      )
      .then((handler: PlaidLinkHandler) => {
        this.plaidLinkHandler = handler;
        this.open();
      });
  }

  open() {
    this.plaidLinkHandler.open();
  }

  exit() {
    this.plaidLinkHandler.exit();
  }

  onSuccess(token, metadata) {
    console.log("We got a token:", token);
    console.log("We got metadata:", metadata);
  }

  onEvent(eventName, metadata) {
    console.log("We got an event:", eventName);
    console.log("We got metadata:", metadata);
  }

  onExit(error, metadata) {
    console.log("We exited:", error);
    console.log("We got metadata:", metadata);
  }
}

Angular Compatibility Chart

The following chart can be used to determine what version of ngx-plaid-link should be used within your angular project.

  • Note the omission of angular@12 support within the chart; this is because there has never been a version of ngx-plaid-link published that officially supports angular@12. ngx-plaid-link@1.0.3 should work fine with angular@12 (albeit with peer dependency warnings during installation) but official advice is to upgrade your project to angular@13 or later.
angular versionngx-plaid-link version
61.0.3
71.0.3
81.0.3
91.0.3
101.0.3
111.0.3
1313.0.0

Available Configuration

This is all there in the types, but here they are for convenience.

Attribute/propinput/outputoptional/requiredTypeDefaultDescription
apiVersioninputoptionalstringv2The version of the Plaid Link api to use
buttonTextinputoptionalstringLog In To Your Bank AccountYou can customize the text on the button by providing text here.
classNameinputoptionalstringnullA class or classes to apply to the button inside the component
clientNameinputrequiredstringnullThe name of your application, gets used in the Plaid Link UI.
countryCodesinputoptionalstring[]['US']An array of strings of Plaid supported country codes
envinputoptionalstringsandboxCan be one of available plaid environments: sandbox, development, or production
institutioninputoptionalstringnullIf you want to launch a specific institution
productinputoptionalstring[]['auth']An array of the names of the products you'd like to authorize. Available options are transactions, auth, and identity.
publicKeyinputconditionalstringnullThe key (publiKey) parameter in PlaidLink create is deprecated. The public key from your Plaid account Make sure it's the public key and not the private key
tokeninputconditionalstringnullIf you're using link_tokens this field is required and will be the link_token. If you're still using the public key (legacy), then this field is optional and is for if you are re-authenticating or updating an item that has previously been linked.
styleinputoptionalobjectAn object of stylesAn ngStyle object that can be used to apply styles and customize the plaid link button to match your app.
selectAccountinputoptionalbooleanfalseSetting this to TRUE will allow the user to select their bank account from a list through the plaid modal. FALSE does not show the account list prompt.
webhookinputoptionalstringnullYou can provide a webhook for each item that Plaid will send events to.
receivedRedirectUriinputoptionalstringnullA receivedRedirectUri is required to support OAuth authentication flows when re-launching Link on a mobile device and using one or more European country codes. In addition to configuring the URI here, you will also need to enable the URI on the developer dashboard.
isWebviewinputoptionalbooleanfalseSet to true if launching Link within a WebView.
Exitoutputrequiredfunctionn/aPasses the result from the onExit function to your component
Successoutputrequiredfunctionn/aPasses the result from the onSuccess function to your component
Clickoutputoptionalfunctionn/aLets you act on the event when the button is clicked
Eventoutputoptionalfunctionn/aPasses the result from the onEvent function to your component
Loadoutputoptionalfunctionn/aLets you act on the event when the Plaid Link stuff is all loaded

How to contribute

Coming soon...

FAQs

Last updated on 12 Jul 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc