# cds-common-jwt-support

> support common jwt with jose for @sap/cap

Latest version **0.0.2** (published 2022-04-13) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install cds-common-jwt-support
pnpm add cds-common-jwt-support
yarn add cds-common-jwt-support
bun add cds-common-jwt-support
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2022-04-13 |
| First published | 2022-02-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 464.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Theo Sun |
| Maintainers | suntao |
| Keywords | CAP, @sap/cds, cds, auth, jwt |

## Links

- npm: https://www.npmjs.com/package/cds-common-jwt-support
- npm.io page: https://npm.io/package/cds-common-jwt-support

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 0.0.2 (latest) — 2022-04-13
- 0.0.2-alpha.0 — 2022-02-22

## README

# cds common jwt support

> support `jwt` without xsuaa ans xssec, and give user much more features with [`jose`](https://github.com/panva/jose)

[![node-test](https://github.com/Soontao/cds-common-jwt-support/actions/workflows/nodejs.yml/badge.svg)](https://github.com/Soontao/cds-common-jwt-support/actions/workflows/nodejs.yml)
[![codecov](https://codecov.io/gh/Soontao/cds-common-jwt-support/branch/main/graph/badge.svg?token=LKyd87mOZw)](https://codecov.io/gh/Soontao/cds-common-jwt-support)
[![npm](https://img.shields.io/npm/v/cds-common-jwt-support)](https://www.npmjs.com/package/cds-common-jwt-support)

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Soontao_cds-common-jwt-support&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Soontao_cds-common-jwt-support)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Soontao_cds-common-jwt-support&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=Soontao_cds-common-jwt-support)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Soontao_cds-common-jwt-support&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=Soontao_cds-common-jwt-support)


## Get Started

> simply integrate the `cds-common-jwt-support` to you CAP nodejs project


```bash
npm i -S cds-common-jwt-support jose
```


`server.js`


```ts
const cds = require("@sap/cds");
const { configureJwt } = require("cds-common-jwt-support");
const jose = require("jose")

const publicKey = `
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7g4mOYr136bOzOB4hd+e
......
-----END PUBLIC KEY-----
`

cds.on("bootstrap", async (app) => {
  configureJwt(app, {
    key: await jose.importSPKI(publicKey, "PS256")
  });
});

module.exports = cds.server;
```

`package.json`

```json
{
  "requires": {
    "auth": {
      "kind": "common-jwt"
    },
    "common-jwt": {
      "impl": "cds-common-jwt-support"
    }
  }
}
```

## [CHANGELOG](./CHANGELOG.md)

## [LICENSE](./LICENSE)

---
_Source: https://npm.io/package/cds-common-jwt-support · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
