Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
cms-bluebutton-sdk
Advanced tools
This is an SDK for interacting with CMS Blue Button 2.0 API, the API allows applications to obtain a beneficiary's (who has login account with medicare.gov) grant to access his/her medicare claims data - through OAUTH2 (RFC 6749) authorization flow.
By using the SDK, the development of applications accessing Blue Button 2.0 API can be greatly simplified.
Note, following the OAUTH2 best practices, OAUTH2 PKCE etension (RFC 7636) is always enabled.
Using npm:
$ npm install cms-bluebutton-sdk
When develop with typescript
$ npm install --save-dev @types/cms-bluebutton-sdk
Using yarn:
$ yarn add cms-bluebutton-sdk
When develop with typescript
$ yarn add --dev @types/cms-bluebutton-sdk
the SDK needs to be properly configured to work, the parameters are:
the configuration is in json format and stored in a local file, the default location is current working directory with file name: .bluebutton-config.json
A sample configuration json:
{
"clientId": "foo",
"clientSecret": "bar",
"callbackUrl": "https://www.fake.com/",
}
parameter | value | Comments |
---|---|---|
clientId | "foo" | oauth2 client id of the app |
clientSecret | "bar" | oauth2 client secret of the app |
callbackUrl | "https://www.fake.com/" | oauth2 callback url of the app |
For application registration and client id and client secret, please refer to: Blue Button 2.0 API Docs - Try the API
Below are psuedo code snippets showing SDK used with node express server.
import express, { Request, Response } from 'express';
import BlueButton from 'cms-bluebutton-sdk';
import { AuthorizationToken } from 'cms-bluebutton-sdk';
const app = express();
const bb = new BlueButton();
const authData = bb.generateAuthData();
// AuthorizationToken holds access grant info:
// access token, expire in, expire at, token type, scope, refreh token, etc.
// it is associated with current logged in user in real app,
// check SDK js docs for more details.
let authToken: AuthorizationToken;
// start authorize flow: response with URL to redirect to Medicare.gov beneficiary login
app.get('/', (req, res) => {
const redirectUrl = bb.generateAuthorizeUrl(authData);
res.redirect(redirectUrl);
})
// oauth2 call back: obtain access token, optionally check scope, and fetch data
app.get('api/bluebutton/callback', async (req: Request, res: Response) => {
let results = {};
try {
authToken = await bb.getAuthorizationToken(authData, req.query.code, req.query.state, req.query.error);
// now access token obtained, note, during authorization, the beneficiary can grant
// access to his/her demographic data and claims data or only claims data, check the scope
// of the current access token as shown below:
const scopes: string[] = authToken.scope;
// iterate scope entries here or check if a permission is in the scope
if (authToken.scope.index("patient/Patient.read") > -1) {
// patient info access granted
}
/**
* 1. access token scope where demagraphic info included:
*
* scope: [
* "patient/Coverage.read",
* "patient/ExplanationOfBenefit.read",
* "patient/Patient.read",
* "profile",
* ]
*
* 2. access token scope where demagraphic info not included:
*
* scope: [
* "patient/Coverage.read",
* "patient/ExplanationOfBenefit.read",
* ]
*/
// data flow: after access granted
// the app logic can fetch the beneficiary's data in app specific ways:
// e.g. download EOB periodically etc.
// access token can expire, SDK automatically refresh access token when that happens.
eobResults = await bb.getExplanationOfBenefitData(authToken);
authToken = eobResults.token; // in case authToken got refreshed during fhir call
patientResults = await bb.getPatientData(authToken);
authToken = patientResults.token;
coverageResults = await bb.getCoverageData(authToken);
authToken = coverageResults.token;
profileResults = await bb.getProfileData(authToken);
authToken = profileResults.token;
results = {
eob: eobResults.response.data,
patient: patientResults.response.data,
coverage: coverageResults.response.data,
profile: profileResults.response.data
}
} catch (e) {
console.log(e);
}
res.json(results)
});
A Node JS React sample app can be found at: CMS Blue Button Node JS Sample App
From two environments: PRODUCTION and SANDBOX, Blue Button API is available in v1 and v2, data served from v1 is in FHIR STU2 format, and data from v2 is in FHIR R4 format, an application's target environment and API version can be set in the SDK configuration as shown by example below:
{
"clientId": "foo",
"clientSecret": "bar",
"callbackUrl": "https://www.fake.com/",
"version": "2",
"environment": "PRODUCTION"
}
The default API version is v2, and default environment is SANDBOX.
Web location of the environments:
FAQs
An sdk used for interacting with the CMS Blue Button 2.0 API
The npm package cms-bluebutton-sdk receives a total of 9 weekly downloads. As such, cms-bluebutton-sdk popularity was classified as not popular.
We found that cms-bluebutton-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.