Socket
Book a DemoInstallSign in
Socket

@asymmetrik/sof-scope-checker

Package Overview
Dependencies
Maintainers
8
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asymmetrik/sof-scope-checker

Smart on FHIR scope checker

1.0.7
latest
Source
npmnpm
Version published
Weekly downloads
1.3K
-29.8%
Maintainers
8
Weekly downloads
 
Created
Source

SOF-Scope-Checker

Utility for validating patient and user level scopes for the SMART on FHIR specification.

Install

yarn add @asymmetrik/sof-scope-checker

Usage

const scopeChecker = require('@asymmetrik/sof-scope-checker');

let hasValidScopes = (name, action) => {
  return function (req, res, next) {
    let scopes = parseScopes(req && req.user);
    let { error, success } = scopeChecker(name, action, scopes);

    // Log the error, wrap in operation outcome or GraphQL specific error
    // You can check the type of the error as well since we use custom errors

    if (error) {
      next(error);
    } else {
      next();
    }
  }
};

app.get(
  '/Patient',
  hasValidScopes('Patient', 'read'),
  patientController
)

See sof-scope-checker tests for more usage examples.

NOTE: The error returned is an extension of the native JS error. It adds a type property to the error which can have a value of 'internal' representing a misconfiguration, or 'forbidden' representing a case where the scopes are not sufficient.

Arguments

@asymmetrik/sof-scope-checker exports a single function which takes three arguments.

name

Name of the resource or patient.

Type: String
Required: true

action

The action the user wants to take. Can be read, write, or *.

Type: String
Required: true

scopes

The scopes available to the user.

Type: Array<String>
Required: true

FAQs

Package last updated on 23 Sep 2020

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.