# @graffiticode/auth

> Auth service for GC applications

Latest version **2.1.2** (published 2023-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @graffiticode/auth
pnpm add @graffiticode/auth
yarn add @graffiticode/auth
bun add @graffiticode/auth
```

Provides the command `auth`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2023-07-17 |
| First published | 2022-10-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 69 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Art Compiler LLC |
| Maintainers | skidder, jeffdyer |
| Keywords | graffiticode |

## Links

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

## Dependencies (8)

- [bent](https://npm.io/package/bent.md) ^7.3.12
- [jose](https://npm.io/package/jose.md) ^4.14.4
- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [express](https://npm.io/package/express.md) ^4.18.2
- [firebase-admin](https://npm.io/package/firebase-admin.md) ^11.10.0
- [@ethereumjs/util](https://npm.io/package/@ethereumjs/util.md) ^8.0.0
- [@graffiticode/common](https://npm.io/package/@graffiticode/common.md) *
- [@graffiticode/tracing](https://npm.io/package/@graffiticode/tracing.md) ^0.3.0

## Recent versions

- 2.1.2 (latest) — 2023-07-17
- 2.1.1 — 2023-07-10
- 2.1.0 — 2023-07-10
- 2.0.2 — 2023-07-09
- 2.0.1 — 2023-07-09
- 2.0.0 — 2023-06-29
- 1.0.2 — 2023-02-19
- 1.0.1 — 2023-02-01
- 1.0.0 — 2022-10-20

## README

# GC Auth

Auth application for [Graffiticode](https://graffiticode.org) applications.

## API

- `uid`: user id, in practice this is a non `0x` prefixed ethereum address.

### `GET /certs`

Gets a JSON Web Key Set for the current set of keys being used to sign tokens.

- __AUTH__: `none`

### `GET /authenticate/ethereum/:address`

Returns the current nonce for an ethereum address. This will generate a nonce if one does not currently exist.

- __AUTH__: `none`
- Request
  - `address`: used as the user id
- Response
  - `nonce`: Opaque random string used for authenticating with ethereum.

### `POST /authenticate/ethereum/:address`

Performs Sign In With Ethereum processing for an address. If authentication succeeds a `accessToken` and `refreshToken` are issued to the caller.

- __AUTH__: `none`
- Request
  - `address`: used as the user id
  - `signature`: signed ethereum message with contents "Nonce: \<nonce\>"
- Response
  - `accessToken`: a short lived JWT that can be used to make authenticated calls to GC APIs (i.e. compilers or the API). This is optimization over the client having to call `POST /authenticate/refresh_token`.
  - `refreshToken`: a long lived opaque token for retrieving auth `accessToken`s.

### `POST /authenticate/refresh_token`

Exchanges a `refreshToken` issued during authentication for a short lived JWT that can be used to make authenticated calls to the GC APIs.

- __AUTH__: `none`
- Request
  - `refreshToken`: the token issued during authentication
- Response
  - `accessToken`: a short lived JWT that can be used to make authenticated calls to GC APIs.

## Development

1. Start firebase emulators (_NOTE_: you only to do this once per GCP project).

```bash
npx firebase emulators:start
```

1. Run GC Auth application (in another terminal)

```bash
npm run dev
```

1. Run example usage

```bash
# Generate a signing key
curl -i -X POST http://localhost:4100/certs

node tools/run-ethereum.js
```

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