{"id":13836451,"url":"https://github.com/decentraland/decentraland-crypto-middleware","last_synced_at":"2025-06-29T05:33:23.440Z","repository":{"id":44582255,"uuid":"413862325","full_name":"decentraland/decentraland-crypto-middleware","owner":"decentraland","description":"A multi framework middleware to authenticate request signed with @decentraland/SignedFetch","archived":false,"fork":false,"pushed_at":"2025-02-24T20:39:40.000Z","size":153,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-06-14T17:15:28.944Z","etag":null,"topics":["decentraland","express","koa","passportjs","well-known-components"],"latest_commit_sha":null,"homepage":"https://docs.decentraland.org/development-guide/SDK-101/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/decentraland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-10-05T14:54:48.000Z","updated_at":"2025-02-24T20:16:19.000Z","dependencies_parsed_at":"2025-04-12T10:47:19.242Z","dependency_job_id":null,"html_url":"https://github.com/decentraland/decentraland-crypto-middleware","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/decentraland/decentraland-crypto-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentraland%2Fdecentraland-crypto-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentraland%2Fdecentraland-crypto-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentraland%2Fdecentraland-crypto-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentraland%2Fdecentraland-crypto-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decentraland","download_url":"https://codeload.github.com/decentraland/decentraland-crypto-middleware/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decentraland%2Fdecentraland-crypto-middleware/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262543862,"owners_count":23326626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decentraland","express","koa","passportjs","well-known-components"],"created_at":"2024-08-04T15:00:45.717Z","updated_at":"2025-06-29T05:33:23.417Z","avatar_url":"https://github.com/decentraland.png","language":"TypeScript","funding_links":[],"categories":["Libraries"],"sub_categories":["SDK 6"],"readme":"# Decentraland Authentication Middleware\n\n[![Coverage Status](https://coveralls.io/repos/github/decentraland/decentraland-crypto-middleware/badge.svg?branch=main)](https://coveralls.io/github/decentraland/decentraland-crypto-middleware?branch=main)\n\nA multi framework middleware to authenticate request signed with `@decentraland/SignedFetch`\n\n## Index\n\n- [Install](#install)\n- [Use with Express](#use-with-express)\n- [Use with Koa](#use-with-koa)\n- [Use with Well Known Components](#use-with-well-known-components)\n- [Use with PassportJS](#use-with-passportjs)\n- [Options](#options)\n- [Auth Chain Generator](#auth-chain-generator)\n- [Develop](#develop)\n\n## Install\n\n```bash\n  npm install -s decentraland-crypto-middleware\n```\n\n## Use with [Express](https://expressjs.com/)\n\n```typescript\nimport { Request } from 'express'\nimport * as dcl from 'decentraland-crypto-middleware'\n\napp.get(\n  '/user/required',\n  dcl.express(),\n  (req: Request \u0026 dcl.DecentralandSignatureData) =\u003e {\n    const address: string = req.auth\n    const metadata: Record\u003cstring, any\u003e = req.authMetadata\n  }\n)\n\napp.get(\n  '/user/optional',\n  dcl.express({ optional: true }),\n  (req: Request \u0026 dcl.DecentralandSignatureData) =\u003e {\n    const address: string | undefined = req.auth\n    const metadata: Record\u003cstring, any\u003e | undefined = req.authMetadata\n  }\n)\n```\n\n## Use with [Koa](https://koajs.com/)\n\n```typescript\nimport { Context } from 'koa'\nimport * as dcl from 'decentraland-crypto-middleware'\n\napp.get(\n  '/user/required',\n  dcl.koa(),\n  (ctx: Context \u0026 dcl.DecentralandSignatureData) =\u003e {\n    const address: string = ctx.auth\n    const metadata: Record\u003cstring, any\u003e = ctx.authMetadata\n  }\n)\n\napp.get(\n  '/user/optional',\n  dcl.koa({ optional: true }),\n  (ctx: Context \u0026 dcl.DecentralandSignatureData) =\u003e {\n    const address: string | undefined = ctx.auth\n    const metadata: Record\u003cstring, any\u003e | undefined = ctx.authMetadata\n  }\n)\n```\n\n## Use with [Well Known Components](https://github.com/well-known-components)\n\n```typescript\nimport type { IHttpServerComponent } from '@well-known-components/interfaces'\nimport * as dcl from 'decentraland-crypto-middleware'\n\napp.use('/user/required', dcl.wellKnownComponents())\napp.get('/user/required', (ctx: dcl.DecentralandSignatureRequiredContext) =\u003e {\n  const address: string = ctx.verification.auth\n  const metadata: Record\u003cstring, any\u003e = ctx.verification.authMetadata\n})\n\napp.use('/user/optional', dcl.wellKnownComponents({ optional: true })\napp.get('/user/optional', (ctx: dcl.DecentralandSignatureContext\u003c{}\u003e) =\u003e {\n  const address: string | undefined= ctx.verification?.auth\n  const metadata: Record\u003cstring, any\u003e | undefined = ctx.verification?.authMetadata\n})\n```\n\n## Use with [PassportJS](http://www.passportjs.org/)\n\n```typescript\nimport { Context } from 'koa'\nimport * as dcl from 'decentraland-crypto-middleware'\n\npassport.use(dcl.passport())\n\napp.get(\n  '/user/required',\n  passport.authenticate('decentraland'),\n  (req: Request \u0026 dcl.DecentralandSignatureData) =\u003e {\n    const address: string = req.auth\n    const metadata: Record\u003cstring, any\u003e = req.authMetadata\n  }\n)\n\napp.get(\n  '/user/required',\n  passport.authenticate('decentraland', { optional: true }),\n  (req: Request \u0026 dcl.DecentralandSignatureData) =\u003e {\n    const address: string | undefined = req.auth\n    const metadata: Record\u003cstring, any\u003e | undefined = req.authMetadata\n  }\n)\n```\n\n## Options\n\n| `name`       | `type`                                         | `description`                                                                                                |\n| ------------ | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |\n| `optional`   | `boolean`                                      | if `false` request will fail if there is no signature or if is invalid (default: `false`)                    |\n| `expiration` | `number`                                       | time in milliseconds where a signature is considered valid (default: `60_000`)                               |\n| `catalyst`   | `string`                                       | catalyst url to validate contract wallet signatures (default: `https://peer-lb.decentraland.org/`)           |\n| `onError`    | `(err: Error \u0026 { statusCode: number }) =\u003e any` | formats the response body when an error occurred (default: `(err) =\u003e ({ ok: false, message: err.message })`) |\n\n### Auth Chain Generator\n\nIf you want to simulate signed headers you can use the [`Auth Chain Generator`](https://git.io/Jimns)\n\n## Develop\n\nIf you want to contribute make you will need to setup `husky` otherwise your commit may fail because is not following the format standard\n\n```bash\n  npm run husky-setup\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecentraland%2Fdecentraland-crypto-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecentraland%2Fdecentraland-crypto-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecentraland%2Fdecentraland-crypto-middleware/lists"}