# @codehelios/verify-tokenid

> Lightweight zero dependency library to verify firebase ID Token in Cloudflare Workers.

Latest version **0.3.1** (published 2022-07-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @codehelios/verify-tokenid
pnpm add @codehelios/verify-tokenid
yarn add @codehelios/verify-tokenid
bun add @codehelios/verify-tokenid
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2022-07-15 |
| First published | 2022-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 16.13 <17 |
| Dependencies | 0 |
| Unpacked size | 177.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Codehelios |
| Maintainers | codehelios-com |
| Keywords | firebase, workers, cloudflare, workers, firebase, tokenId |

## Links

- npm: https://www.npmjs.com/package/@codehelios/verify-tokenid
- Repository: https://github.com/codehelios/verify-tokenid
- Homepage: https://github.com/codehelios/verify-tokenid#readme
- Issues: https://github.com/codehelios/verify-tokenid/issues
- npm.io page: https://npm.io/package/@codehelios/verify-tokenid

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2022-07-15
- 0.3.0 — 2022-07-15
- 0.2.9 — 2022-07-03
- 0.2.8 — 2022-07-03
- 0.2.7 — 2022-07-03
- 0.2.6 — 2022-07-02
- 0.2.5 — 2022-07-02
- 0.2.3 — 2022-07-02
- 0.2.2 — 2022-07-02
- 0.2.1 — 2022-07-02
- 0.2.0 — 2022-07-02
- 0.1.1 — 2022-07-02
- 0.1.0 — 2022-07-01

## README

# Verify TokenId  &nbsp; [![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/codehelios/verify-tokenid/blob/main/LICENSE)  [![NPM Verison](https://img.shields.io/npm/v/@codehelios/verify-tokenid)](https://www.npmjs.com/package/@codehelios/verify-tokenid)


Lightweight zero dependency library to verify Firebase ID Token in Cloudflare Workers.


&nbsp;
## Usage/Examples


#### Verify ID Token

```javascript
import { verifyTokenId } from "@codehelios/verify-tokenid";

const { isValid, decoded, error } = await verifyTokenId(tokenId, "https://securetoken.google.com/<projectId>", "<projectId>");
```

&nbsp;

## API Reference

### Verify ID Token
Verifies Firebase ID Token and returns  `object` containing `{ isValid, decoded, error }` 

```
  verifyTokenId(token, issure, audience)
```

#### Arguments

| Parameter | Type     | Description                       |
| :-------- | :------- | :-------------------------------- |
| `token`      | `string` | **Required**. Firebase ID Token  |
| `issure`      | `string` | **Required**. Must be "https://securetoken.google.com/<projectId>", where <projectId> is the same project ID used for aud above. |
| `audience`      | `string` | **Required**. Must be your Firebase project ID, the unique identifier for your Firebase project, which can be found in the URL of that project's console.  |

#### Returns
`object` containing `{ isValid, decoded, error }` 

| Property | Type     | Description                       |
| :-------- | :------- | :-------------------------------- |
| `isValid`      | `boolen` | Indicates whether given Firebase ID Token is valid or not  |
| `decoded`      | `object` or `null` | If ID Token is valid this will be decoded JWT Object `{ header, payload }` |
| `error`      | `string` or `null` | If `isValid` is `false` then this will be error message saying why `isValid` is `false` otherwise `null`  |


&nbsp;
## License

[MIT](https://github.com/codehelios/verify-tokenid/blob/main/LICENSE)

&nbsp;
## Authors

- [@codehelios](https://www.github.com/codehelios)
- [@pyshivam](https://www.github.com/pyshivam)

&nbsp;
## Acknowledgements

 - [Verify ID Token](https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_a_third-party_jwt_library)
 - [JWT Verification Library](https://github.com/panva/jose)

---
_Source: https://npm.io/package/@codehelios/verify-tokenid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
