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

humanapi-connect-client

v2.4.4

Published

[![NPM](https://nodei.co/npm/humanapi-connect-client.png)](https://nodei.co/npm/humanapi-connect-client/)

Downloads

4,998

Readme

Human API Connect Client

NPM

Table of contents

Looking for 1.x documentation?

The documentation below is for humanapi-connect-client@2. We have recently released a new Connect integration client version that replaces the old 1.x.x version that has been deprecated.

It is recommended that you use this new client version which is backwards compatible to make the transition easier.

Click here for [email protected] documentation.


Description

Connect is the authentication widget for your application to allow users to share their health data. After a user has successfully granted you access to their health data using Connect, you'll be able to query their disparate data directly from Human API.

Please refer to the connect guide for full instructions on how to use the Connect client.

Installation

This module can be used by loading the script from our CDN or by installing the npm module.

CDN

To use the library via our CDN you can include the following script source:

<script src="https://cdn.humanapi.co/[email protected]">

NPM module

To install the npm module and use it with e.g. React:

npm install --save humanapi-connect-client

Usage

To use this library regardless of the method used, you first need to acquire a session token and set it as the data-attribute data-hapi-token of an element that supports the onclick event (e.g. a button). Then, you need to add the class hapi__token-container to the parent of the element that has the token value, e.g.:

<div class="hapi__token-container">
    <button data-hapi-token="<your session token>">Open Connect</button>
</div>

Note: Make sure that the element containing the class hapi__token-container is rendered on page load.

The library will then automatically configure all elements with the data-hapi-token attribute under that parent, to allow them to open the Connect window.

Lifecycle hooks

humanapi-connect-client can be configured to respond to the following lifecycle hooks:

  • connect: This event will be fired after a source has been successfully connected
  • disconnect: This event will be fired after a source has been disconnected
  • close: This event will be fired after the Connect window is closed, regardless of whether sources were connected or not
  • error: This event fires in case theres an error with the library e.g. a token container element is not found

To add a lifecycle hook to a particular event you have to use the on(eventName, eventListener) method, e.g.:

HumanConnect.on("close", (response) => {console.log("close", response)});
HumanConnect.on("connect", (response) => {console.log("connect", response)});
HumanConnect.on("disconnect", (response) => {console.log("disconnect", response)});
HumanConnect.on("error", (response) => {console.error("error", response)});

Any function listening for lifecycle events defined by Connect will receive a payload with the following schema:

 {
     sessionResults: {
         // List of sources the user connected during this session
         connectedSources: [
             {
                 name: "Starfleet Pharmacy",
                 id: "5b1daf3f079c652eaf41fd23"
             }
         ],
         // List of sources the user disconnected during this session
         disconnectedSources: [],
         // List of sources the user requested during this session
         requestedSources: [
             {
                 address: "742 Evergreen Terrace, OH",
                 healthSystem: "N/A",
                 location: {
                     latitude: 41.3289,
                     longitude: -105.6928
                 },
                 physician: "Dr. John Smith",
                 website: "drjohnsmith.example.com"
             }
         ]
     },
     // List of sources the user currently has connected with your app
     currentConnections: [
         {
             name: "Starfleet Pharmacy",
             id: "5b1daf3f079c652eaf41fd23"
         }
     ],
     // List of sources the user has requested
     requestedProviders: [
             {
                 address: "742 Evergreen Terrace, OH",
                 healthSystem: "N/A",
                 location: {
                     latitude: 41.3289,
                     longitude: -105.6928
                 },
                 physician: "Dr. John Smith",
                 website: "drjohnsmith.example.com"
             }
     ]
 }

Upgrade from 1.x.x

CDN

  • If you are using the script via the CDN and the source location is src=https://cdn.humanapi.co/[email protected] you will be upgraded automatically. The new version is backwards compatible so there is no other change needed for the time being.

  • If you are using a specific version of the library, e.g. src=https://cdn.humanapi.co/[email protected] you can just use [email protected] or specify a 2.x.x version, e.g. [email protected]

npm

  • Install the latest package with npm install humanapi-connect-client

Contributing

Note: This project uses Node 14.

Generate a prerelease version

To generate a new pre-release version, you can run the following command:

npm version prerelease --preid=beta

This will bump the version to the next pre-release version, e.g. from 2.0.0 to 2.0.1-beta.0. After that you can publish the new version with:

npm publish --tag beta

And then push the new tag to the repository:

# Example
git push origin v2.0.1-beta.0

Generate a new version

To generate a new version, you can run the following command:

npm version patch

After that you can publish the new version with:

npm publish

And then push the new tag to the repository:

# Example
git push origin v2.0.1