Registry / security / decentraland-crypto-fetch

decentraland-crypto-fetch

JSON →
library2.0.1jsnpmunverified

An HTTP fetch library that signs requests using a Decentraland Identity, preserving the native Fetch API. Version 2.0.1 runs on Node >=12 and browsers. It simplifies authenticated communication with Decentraland services by automatically adding signed headers (including optional metadata) to each request. Key differentiators: works with standard `fetch`, supports generator functions and factory injection for custom fetch implementations, and includes a CLI tool. Built on top of `@dcl/crypto` for identity management.

npm install decentraland-crypto-fetch
INSTALL
IMPORT
SIG · DECENTRALAND-CRYPT
D
decentraland-crypto-fetch
securityjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetch
import fetch from 'decentraland-crypto-fetch'
const { fetch } = require('decentraland-crypto-fetch')
Default export for signed fetch function.
signedFetchFactory
import { signedFetchFactory } from 'decentraland-crypto-fetch/lib/factory'
import { signedFetchFactory } from 'decentraland-crypto-fetch'
Factory is in a sub-path; cannot be imported from main entry.
SignedFetchOptions
import type { SignedFetchOptions } from 'decentraland-crypto-fetch'
TypeScript type import for options parameter.

Shows how to import and use the signed fetch with an ephemeral identity and metadata.

import fetch from 'decentraland-crypto-fetch'; import { Authenticator } from '@dcl/crypto'; // Generate an identity (or load existing) const identity = Authenticator.initializeEphemeralIdentity(); // Signed request const response = await fetch('https://api.decentraland.org/v1/places', { method: 'GET', identity, metadata: { timestamp: Date.now() } }); const data = await response.json(); console.log(data);
Debug
Known issues
deprecatedUsing `identity` as a string is deprecated in favor of an Identity object.
fix
Pass an Identity object obtained from @dcl/crypto instead of a string.
affects: >=2.0.0
gotchaWorks only with HTTP/HTTPS; not for other protocols.
fix
Ensure URLs use http or https scheme.
affects: all
breakingIn version 2.0.0, the default export changed from an object with a `fetch` method to a direct function.
fix
Use `import fetch from 'decentraland-crypto-fetch'` instead of `import { fetch } from 'decentraland-crypto-fetch'` (for named export, it's now default).
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: fetch is not a function
Using CommonJS require incorrectly.
fix
Use `const fetch = require('decentraland-crypto-fetch').default` or switch to ES modules.
Cannot find module '@dcl/crypto'
Missing peer dependency.
fix
Install @dcl/crypto: `npm install @dcl/crypto`.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
@dcl/cryptorequiredRequired for identity generation and signing.
Agent activity
21 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
decentraland-crypto-fetch — npm install decentraland-crypto-fetch · libregistry