Setting up the FIDO SDK
The FIDO SDK is a browser-based JavaScript SDK that is intended to assist integration of Cardinal FIDO into your transaction flow. Before beginning to use the SDK, you will need to get Artifactory credentials. Your Cardinal solution Engineer or Account Manager can help you begin this process. See this article for more information:
Setting Up Credentials for JFrog Artifactory
Table of Contents
Configuring the FIDO SDK
The Cardinal FIDO SDK is hosted on a private npm repo that is scoped behind the @cardinal
name. This allows you to configure npm to pull only the @cardinal
scoped packages from the private cardinal npm repo. To get access to this repo you should work with your Cardinal account manager to get access credentials.
The below blob can be used to scaffold out a setup for your local .npmrc
file to pull from the Cardinal private registry only for packages scoped as @cardinal
. This can be configured along side any other npm registries you may have already configured and should not cause any issues since it is a scoped entry. When NPM encounters a scoped package using the @cardinal
entry it should pull only from the Cardinal private registry. Be sure to change the values in the below blob to configure it to your specific account details.
Sample .npmrc file |
---|
@cardinal:registry=https://cardinalcommerceprod.jfrog.io/artifactory/api/npm/cardinal-npm/
//cardinalcommerceprod.jfrog.io/artifactory/api/npm/cardinal-npm/:_password=<BASE64_APIKEY>
//cardinalcommerceprod.jfrog.io/artifactory/api/npm/cardinal-npm/:username=<CARDINAL_ARTIFACTORY_USERNAME>
//cardinalcommerceprod.jfrog.io/artifactory/api/npm/cardinal-npm/:email=youremail@email.com
//cardinalcommerceprod.jfrog.io/artifactory/api/npm/cardinal-npm/:always-auth=true |
Installing the npm Package
Once the Artifactory repository has been configured on your machine, you can install the package like any other npm dependency:
Install Command |
---|
npm install --save @cardinal/fidosdk |
Using the FIDO SDK
The FIDO SDK library is built using a UMD module definition which allows it to be imported using CommonJS, AMD, or as a global variable. ES modules are not currently supported.
Importing the FIDO SDK as a Module
The library can be imported as a module using AMD or CommonJS module loading. Below is an example of how to import the module using CommonJS. Currently ES modules are not supported.
Import Sample |
---|
|
Importing the FIDO SDK as a Global Library
The library can be loaded into the webpage directly as a separate file or built into a building system. You will need to host the file to your users. When the Cardinal FIDO SDK loads into the browser it creates a new global namespace of CardinalFido
. All Cardinal-provided functions and features will be isolated into this global variable. This is not configurable and cannot be changed. All global variables should be given unique names.