{"_id":"@data.pub/fetch-client","_rev":"4-c685b655bf4a4327c8af916de3f26ce4","name":"@data.pub/fetch-client","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.0":{"name":"@data.pub/fetch-client","version":"1.0.0","license":"MIT","_id":"@data.pub/fetch-client@1.0.0","maintainers":[{"name":"gobengo","email":"bengoering@gmail.com"}],"contributors":[{"url":"https://bengo.is","name":"bengo"}],"dist":{"shasum":"1412f98c3c4b9b6fafd2f0857f4d93431599f4ae","tarball":"https://registry.npmjs.org/@data.pub/fetch-client/-/fetch-client-1.0.0.tgz","fileCount":74,"integrity":"sha512-gjMcHS/TEnGA93pTki064Nu4Uqu+y3UjgLDL5UjTunRC9JaNgSOxCilMLvjXMhLO5KSgIE6MZSwKKX8l6yWRSA==","signatures":[{"sig":"MEUCIQDptDERZwjSKl/r9rgwT9DB8I72dgy2bVzuBX/ctQ0RWQIgW85GSMu/bX9ETPxexHlDa8dSKdW14ZjG39vRN/NrZFc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":231963},"main":"lib/index.js","type":"module","types":"./lib/index.d.ts","exports":{".":{"types":"./index.ts","import":"./lib/index.js","default":"./lib/index.js"},"./types":{"types":"./types.ts","import":"./types.ts"}},"gitHead":"89506a0dded0225032fd164328ef202d5b8045c6","scripts":{"tsc":"tsc --build","lint":"eslint --ignore-pattern=lib .","test":"glob -c 'node --import tsx --test' '*.test.*'","prepare":"npm run tsc","byexample":"byexample -l javascript README.md"},"_npmUser":{"name":"gobengo","email":"bengoering@gmail.com"},"_npmVersion":"10.8.3","description":"interact with a [DataPub][] server via [`fetch`](https://fetch.spec.whatwg.org/#fetch-method).","directories":{},"_nodeVersion":"22.9.0","dependencies":{"zod":"^3.24.1","authorization-signature":"*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","glob":"^11.0.0","@eslint/js":"^9.18.0","typescript":"^5.7.2","@types/node":"^22.10.2","typescript-eslint":"^8.20.0","eslint-plugin-jsdoc":"^50.6.1","@did.coop/did-key-ed25519":"*"},"_npmOperationalInternal":{"tmp":"tmp/fetch-client_1.0.0_1737074920706_0.46359912140120607","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@data.pub/fetch-client","version":"1.0.1","license":"MIT","_id":"@data.pub/fetch-client@1.0.1","maintainers":[{"name":"gobengo","email":"bengoering@gmail.com"}],"contributors":[{"url":"https://bengo.is","name":"bengo"}],"dist":{"shasum":"3501fbcad27787e02b969c99a6b855c04d3a6a06","tarball":"https://registry.npmjs.org/@data.pub/fetch-client/-/fetch-client-1.0.1.tgz","fileCount":74,"integrity":"sha512-y/fC8CxZZTDsG1mCqSySca0prKqF7KMz0X5qlcU36VPt/lioEIlsW2YpMZBV6xxLb/GgwmAa3VGWf6ygQYNHVw==","signatures":[{"sig":"MEUCICIfS5VkoXVa8JHIRc5EmqpITe8dmyRfpdMiwqwd1e7uAiEA1P6chZcJRIn/SQfo8wng4znpt3X29+lM2t5zSFBBA3U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":233997},"main":"lib/index.js","type":"module","types":"./lib/index.d.ts","exports":{".":{"types":"./index.ts","import":"./lib/index.js","default":"./lib/index.js"},"./types":{"types":"./types.ts","import":"./types.ts"},"./test-utils":{"types":"./test-utils.ts","import":"./lib/test-utils.js"}},"gitHead":"32c83c8a9001f460c286d8921596ff1af34521fa","scripts":{"tsc":"tsc --build","lint":"eslint --ignore-pattern=lib .","test":"glob -c 'node --import tsx --test' '*.test.*'","prepare":"npm run tsc","byexample":"byexample -l javascript README.md"},"_npmUser":{"name":"gobengo","email":"bengoering@gmail.com"},"_npmVersion":"10.8.3","description":"interact with a [DataPub][] server via [`fetch`](https://fetch.spec.whatwg.org/#fetch-method).","directories":{},"_nodeVersion":"22.9.0","dependencies":{"zod":"^3.24.1","authorization-signature":"*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","glob":"^11.0.0","@eslint/js":"^9.18.0","typescript":"^5.7.2","@types/node":"^22.10.2","typescript-eslint":"^8.20.0","eslint-plugin-jsdoc":"^50.6.1","@did.coop/did-key-ed25519":"*"},"_npmOperationalInternal":{"tmp":"tmp/fetch-client_1.0.1_1737075658354_0.30176623079734566","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@data.pub/fetch-client","version":"1.1.0","license":"MIT","_id":"@data.pub/fetch-client@1.1.0","maintainers":[{"name":"gobengo","email":"bengoering@gmail.com"}],"contributors":[{"url":"https://bengo.is","name":"bengo"}],"dist":{"shasum":"55b5e0c21f8fe126dbdbb023a6447ce18cec8a25","tarball":"https://registry.npmjs.org/@data.pub/fetch-client/-/fetch-client-1.1.0.tgz","fileCount":78,"integrity":"sha512-B9eDjtJcLUIgJvqBpHxy2LHXb5+XA2Heivq2keMws7eSm6rfoN8AM0v8oD1a7Y31jfw2UgW92l3wgmx+5a5ucw==","signatures":[{"sig":"MEUCIGBhhvTMl3lSwTRF1sH6Hr+e+qw7yAjjdA8A46r981IOAiEA8etOm1VGpHk00saQ2xggHmBN07DzR1eAf7VoSW4bRzM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":250120},"main":"lib/index.js","type":"module","types":"./lib/index.d.ts","exports":{".":{"types":"./index.ts","import":"./lib/index.js","default":"./lib/index.js"},"./types":{"types":"./types.ts","import":"./types.ts"},"./test-utils":{"types":"./test-utils.ts","import":"./lib/test-utils.js"}},"gitHead":"bfa36d8c1e67d601dc0c477b4f4a584cbdf83e62","scripts":{"tsc":"tsc --build","lint":"eslint --ignore-pattern=lib .","test":"glob -c 'node --import tsx --test' '**/*.test.ts'","prepare":"npm run tsc","byexample":"byexample -l javascript README.md"},"_npmUser":{"name":"gobengo","email":"bengoering@gmail.com"},"_npmVersion":"10.8.3","description":"interact with a [DataPub][] server via [`fetch`](https://fetch.spec.whatwg.org/#fetch-method).","directories":{},"_nodeVersion":"22.9.0","dependencies":{"zod":"^3.24.1","authorization-signature":"*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","glob":"^11.0.0","@eslint/js":"^9.18.0","typescript":"^5.7.2","@types/node":"^22.10.2","typescript-eslint":"^8.20.0","@data.pub/did-sshpk":"*","eslint-plugin-jsdoc":"^50.6.1","@did.coop/did-key-ed25519":"*"},"_npmOperationalInternal":{"tmp":"tmp/fetch-client_1.1.0_1737691491563_0.3343277873443262","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@data.pub/fetch-client","version":"1.1.1","license":"MIT","_id":"@data.pub/fetch-client@1.1.1","maintainers":[{"name":"gobengo","email":"bengoering@gmail.com"}],"contributors":[{"url":"https://bengo.is","name":"bengo"}],"dist":{"shasum":"e7f98adea05f6bd0b214ded8cda3418e2afed9f4","tarball":"https://registry.npmjs.org/@data.pub/fetch-client/-/fetch-client-1.1.1.tgz","fileCount":78,"integrity":"sha512-bLl7Ckhlf33iM2Nk7pv5XwRHOXzs/fo+m5EscEUc+ITccnTdadXfBK6ajC6vHmnLWI6xy0X1roBTMkqeFIRqVQ==","signatures":[{"sig":"MEUCIQCQZMxQyrHjOwm4kem5pBs9F8QUzcFe8h08B9/DwhkonwIgPbC60vP1srtzaCmSXVQ94ZStYfp5n32czCgP44lLn4c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":254461},"main":"lib/index.js","type":"module","types":"./lib/index.d.ts","exports":{".":{"types":"./index.ts","import":"./lib/index.js","default":"./lib/index.js"},"./types":{"types":"./types.ts","import":"./types.ts"},"./test-utils":{"types":"./test-utils.ts","import":"./lib/test-utils.js"}},"gitHead":"065e8519e9e5175c7a114115ce4f757580a653d7","scripts":{"tsc":"tsc --build","lint":"eslint --ignore-pattern=lib .","test":"glob -c 'node --import tsx --test' '**/*.test.ts'","prepare":"npm run tsc","byexample":"byexample -l javascript README.md"},"_npmUser":{"name":"gobengo","email":"bengoering@gmail.com"},"_npmVersion":"10.9.2","description":"interact with a [DataPub][] server via [`fetch`](https://fetch.spec.whatwg.org/#fetch-method).","directories":{},"_nodeVersion":"22.9.0","dependencies":{"zod":"^3.24.1","authorization-signature":"*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","glob":"^11.0.0","@eslint/js":"^9.18.0","typescript":"^5.7.2","@types/node":"^22.10.2","typescript-eslint":"^8.20.0","@data.pub/did-sshpk":"*","eslint-plugin-jsdoc":"^50.6.1","@did.coop/did-key-ed25519":"*"},"_npmOperationalInternal":{"tmp":"tmp/fetch-client_1.1.1_1738115849910_0.26754970065145023","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@data.pub/fetch-client","type":"module","version":"1.1.2","main":"lib/index.js","license":"MIT","exports":{".":{"types":"./index.ts","default":"./lib/index.js"},"./test-utils":{"types":"./test-utils.ts","default":"./lib/test-utils.js"},"./types":{"types":"./types.ts","default":"./lib/types.js"}},"scripts":{"byexample":"byexample -l javascript README.md","lint":"eslint --ignore-pattern=lib .","prepare":"npm run tsc","test":"glob -c 'node --import tsx --test' '**/*.test.ts'","tsc":"tsc --build"},"dependencies":{"authorization-signature":"*","zod":"^3.24.1"},"devDependencies":{"@did.coop/did-key-ed25519":"*","@eslint/js":"^9.18.0","@types/node":"^22.10.2","eslint-plugin-jsdoc":"^50.6.1","glob":"^11.0.0","tsx":"^4.19.2","typescript":"^5.7.2","typescript-eslint":"^8.20.0","@data.pub/did-sshpk":"*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_id":"@data.pub/fetch-client@1.1.2","contributors":[{"name":"bengo","url":"https://bengo.is"}],"gitHead":"4bbc9224789b5137140a057968b0fd1fc0ed212c","types":"./lib/index.d.ts","description":"interact with a [DataPub][] server via [`fetch`](https://fetch.spec.whatwg.org/#fetch-method).","_nodeVersion":"22.9.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-Nn72FJot2cc6ocfQBUSGSPbnsX8xgYUEiLYuE+SInuGKKUrXSNfVfh+qguH1qL2B9okrjNtJ4t1P4Kd/37NldQ==","shasum":"f01742da32205d87bbfc6c6486c7168eb83b39e2","tarball":"https://registry.npmjs.org/@data.pub/fetch-client/-/fetch-client-1.1.2.tgz","fileCount":78,"unpackedSize":254433,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCRh3sPrkAV3AQXQhfagybWBfHK0GMHjh/4ZmvTHjH9fwIhANN9BQprMJY+urSNGe6sFv9kqcKrq+63JI7VFooAW48A"}]},"_npmUser":{"name":"gobengo","email":"bengoering@gmail.com"},"directories":{},"maintainers":[{"name":"gobengo","email":"bengoering@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fetch-client_1.1.2_1738187657272_0.649212100132351"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-17T00:48:40.597Z","modified":"2025-01-29T21:54:17.703Z","1.0.0":"2025-01-17T00:48:40.901Z","1.0.1":"2025-01-17T01:00:58.580Z","1.1.0":"2025-01-24T04:04:51.767Z","1.1.1":"2025-01-29T01:57:30.134Z","1.1.2":"2025-01-29T21:54:17.532Z"},"license":"MIT","description":"interact with a [DataPub][] server via [`fetch`](https://fetch.spec.whatwg.org/#fetch-method).","contributors":[{"name":"bengo","url":"https://bengo.is"}],"maintainers":[{"name":"gobengo","email":"bengoering@gmail.com"}],"readme":"# @data.pub/fetch-cient\n\ninteract with a [DataPub][] server via [`fetch`](https://fetch.spec.whatwg.org/#fetch-method).\n\n## Usage\n\n### with JavaScript\n\n```typescript\nimport { DataPubFetchClient } from \"@data.pub/fetch-client\";\nimport { Ed25519Signer } from \"@did.coop/did-key-ed25519\"\n\nconst datapub = new DataPubFetchClient(new URL('https://data.pub'))\n\n// This signer can create cryptographic signatures\nconst signer = await Ed25519Signer.generate()\n\n// create the space with signer so all requests get signed by it\nconst space = datapub.space({ signer })\n```\n\n#### Space PUT\n\n```typescript\n// we want to make sure the space has a controller.\n// wel'll do so by sending PUT w/ a representation of the space\n// with a controller property\nconst spaceObject = {\n  controller: signer.id,\n}\nconst spaceObjectBlob = new Blob(\n  [JSON.stringify(spaceObject)],\n  {type:'application/json'},\n)\n\n// send PUT request to update the space\nconst responseToPutSpace = await space.put(spaceObjectBlob)\nconsole.debug({ responseToPutSpace })\n```\n\n#### Space GET\n\n```typescript\n// GET space\nconst responseToGetSpace = await space.get()\nconsole.debug({ responseToGetSpace })\n```\n\n#### Resource PUT\n```typescript\n\n// PUT resource\nawait space.resource('foo').put(new Blob(['foo']))\n\n// requests with no signer should now be disallowed\nconst responseToGetWithoutSigner = await datapub.space({ id: space.id }).resource('foo').get()\nconsole.debug({responseToGetWithoutSigner})\n```\n\n#### Resource GET\n\n```typescript\n// GET resource\nconst responseToGetResource = await space.resource('foo').get()\nconsole.debug({responseToGetResource})\n```\n\n### byexample\n\nThese snippets should pass [byexample](https://byexamples.github.io/byexample/languages/javascript)\n\n> byexample -l javascript README.md\n\n```javascript\n> const { Ed25519Signer } = await import(\"@did.coop/did-key-ed25519\")\n> const { DataPubFetchClient } = await import(\"@data.pub/fetch-client\");\n> const { createMockFetchForMap } = await import(\"@data.pub/fetch-client/test-utils\");\n> const signer = Ed25519Signer.generate()\n> const storage = new Map\n> const fetch = createMockFetchForMap(storage) // byexample: +timeout=100\n> const pub = new DataPubFetchClient({ fetch, signer })\n> const space = pub.space()\n> const resource = space.resource()\n\n// store a message\n> const message = new Blob(['hi'],{type:'text/plain'})\n> await resource.put(message)\n\n// retrieve a message\n> const messageFromGet = await resource.get().then(r => r.blob())\n> const messageText = await messageFromGet.text()\n> messageText\n'hi'\n```\n\n[DataPub]: https://data.pub\n","readmeFilename":"README.md"}