@asymmetrik/sof-scope-checker

中文文档
1.0.7发布于 2020/09/23MITCommonJS零依赖近 30 天下载 3310

Smart on FHIR scope checker

原始使用文档

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

版本与发布记录

@asymmetrik/sof-scope-checker 共发布 6 个版本,首次发布于 2018/12/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.7latest2020/09/236 年前
1.0.62020/09/146 年前
1.0.42020/09/026 年前
1.0.22019/02/137 年前
1.0.12018/12/207 年前
1.0.02018/12/197 年前

关于 @asymmetrik/sof-scope-checker 的常见问题

@asymmetrik/sof-scope-checker 是什么?

Smart on FHIR scope checker

如何安装 @asymmetrik/sof-scope-checker?

在项目目录运行 npm install @asymmetrik/sof-scope-checker,或使用 pnpm add / yarn add / bun add。

@asymmetrik/sof-scope-checker 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/asymmetrik__sof-scope-checker 是否存在。

@asymmetrik/sof-scope-checker 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@asymmetrik/sof-scope-checker 可以商用吗?

@asymmetrik/sof-scope-checker 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@asymmetrik/sof-scope-checker 的下载量有多少?

根据 npm 官方下载统计,@asymmetrik/sof-scope-checker 在 2026/10/07 – 2026/11/05 这 30 天内被下载 3,310 次,日均约 110 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@asymmetrik/sof-scope-checker 还在维护吗?

最新版本 1.0.7 发布于 2020/09/23(6 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/12/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。