{"_id":"@aneesha_0/dwn-sdk","name":"@aneesha_0/dwn-sdk","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@aneesha_0/dwn-sdk","version":"1.0.0","description":"A reference implementation of https://identity.foundation/decentralized-web-node/spec/","repository":{"type":"git","url":"git+https://github.com/AneeshaKota/dwn-sdk-js.git"},"license":"Apache-2.0","homepage":"https://github.com/AneeshaKota/dwn-sdk-js#readme","bugs":{"url":"https://github.com/AneeshaKota/dwn-sdk-js/issues"},"contributors":[{"name":"Daniel Buchner","url":"https://github.com/csuwildcat"},{"name":"Diane Huxley","url":"https://github.com/diehuxx"},{"name":"Henry Tsai","url":"https://github.com/thehenrytsai"},{"name":"Moe Jangda","url":"https://github.com/mistermoe"},{"name":"Aneesha Kota","url":"https://github.com/AneeshaKota"}],"type":"module","types":"./dist/types/src/index.d.ts","@comment files":["the files property informs npm about which files we want to include in our published package.","dist will include all transpiled js. There's no point in including .ts files"],"engines":{"node":">= 16"},"main":"./dist/cjs/src/index.js","module":"./dist/esm/src/index.js","exports":{"import":"./dist/esm/src/index.js","require":"./dist/cjs/src/index.js","types":"./dist/types/src/index.d.ts"},"browser":{"./dist/esm/src/index.js":"./dist/bundles/browser.js","./dist/cjs/src/index.js":"./dist/bundles/browser.js"},"@comment react-native":["directive for metro (react native build tool)."],"react-native":{"./dist/esm/src/index.js":"./dist/esm/src/index.js","./dist/cjs/src/index.js":"./dist/esm/src/index.js"},"dependencies":{"@ipld/dag-cbor":"9.0.3","@js-temporal/polyfill":"0.4.4","@noble/ed25519":"2.0.0","@noble/secp256k1":"2.0.0","abstract-level":"1.0.3","ajv":"8.12.0","blockstore-core":"4.2.0","cross-fetch":"3.1.6","eciesjs":"0.4.0","flat":"5.0.2","interface-blockstore":"5.2.3","interface-store":"5.1.2","ipfs-unixfs-exporter":"13.1.5","ipfs-unixfs-importer":"15.1.5","level":"8.0.0","lodash":"4.17.21","lru-cache":"9.1.2","make-dir":"4.0.0","ms":"2.1.3","multiformats":"11.0.2","randombytes":"2.1.0","readable-stream":"4.4.0","secp256k1":"5.0.0","ulid":"2.3.0","uuid":"8.3.2","varint":"6.0.0"},"devDependencies":{"@types/chai":"4.3.0","@types/chai-as-promised":"7.1.5","@types/flat":"^5.0.2","@types/karma":"^6.3.3","@types/lodash":"4.14.179","@types/mocha":"9.1.0","@types/ms":"0.7.31","@types/node":"^18.13.0","@types/randombytes":"2.0.0","@types/readable-stream":"2.3.15","@types/secp256k1":"4.0.3","@types/sinon":"10.0.11","@types/uuid":"^9.0.1","@types/varint":"6.0.0","@typescript-eslint/eslint-plugin":"5.37.0","@typescript-eslint/parser":"5.37.0","c8":"^8.0.0","chai":"4.3.6","chai-as-promised":"7.1.1","cross-env":"7.0.3","esbuild":"0.16.17","eslint":"^8.43.0","eslint-plugin-todo-plz":"1.3.0","events":"3.3.0","istanbul-badges-readme":"1.8.1","karma":"6.4.1","karma-chai":"0.1.0","karma-chrome-launcher":"3.1.1","karma-esbuild":"2.2.5","karma-firefox-launcher":"2.1.2","karma-mocha":"2.0.1","karma-mocha-reporter":"2.2.5","karma-webkit-launcher":"2.1.0","license-report":"6.3.0","mkdirp":"1.0.4","mocha":"10.1.0","mockdate":"3.0.5","ms":"2.1.3","node-stdlib-browser":"1.2.0","playwright":"1.29.2","rimraf":"3.0.2","search-index":"3.4.0","sinon":"13.0.1","ts-sinon":"^2.0.2","typescript":"4.8.2","util":"0.12.4"},"overrides":{"c8":{"istanbul-lib-report":{"make-dir":"^4.0.0"}}},"scripts":{"build:esm":"tsc","build:cjs":"tsc --project tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json","build":"npm run clean && npm run compile-validators && npm run build:esm && npm run build:cjs && npm run bundle","bundle":"node ./build/create-browser-bundle.cjs","clean":"rimraf dist && rimraf generated/*","compile-validators":"node ./build/compile-validators.js","lint":"eslint . --ext .ts --max-warnings 0","lint:fix":"eslint . --ext .ts --fix","make-coverage-badges":"istanbul-badges-readme","make-coverage-badges:ci":"npm run make-coverage-badges -- --ci","test:node":"npm run compile-validators && tsc && c8 mocha \"dist/esm/tests/**/*.spec.js\" && npm run make-coverage-badges","test:node:ci":"npm run compile-validators && tsc && c8 mocha \"dist/esm/tests/**/*.spec.js\"","test:browser":"npm run compile-validators && cross-env karma start karma.conf.cjs","test:browser-debug":"npm run compile-validators && cross-env karma start karma.conf.debug.cjs","license-check":"license-report --only=prod > license-report.json && node ./build/license-check.cjs","publish:unstable":"./build/publish-unstable.sh"},"gitHead":"55c7471b4a7b6b603ccf3664d23db725b8c04641","_id":"@aneesha_0/dwn-sdk@1.0.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-2LhfCFdBCJcGmxU+jX64DRXlfsXv1OtF0K7GAReScAz4XXx/reN0ZR1qVYHP+eWgI565mxBWYi94Tf3Hl9SyLQ==","shasum":"fcbea1271dd131389beb2f7d44dae1e858bf1807","tarball":"https://registry.npmjs.org/@aneesha_0/dwn-sdk/-/dwn-sdk-1.0.0.tgz","fileCount":777,"unpackedSize":10318801,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAhzK1vrHhIWH+GbxRAHnvwLudNNQ9oZswgu4W8VWEf5AiA60UJCg2oU4tqwybi1aDI0IEW0mQ4cHWnRw8Qi1+YqQQ=="}]},"_npmUser":{"name":"aneesha_0","email":"aneeshakota@gmail.com"},"directories":{},"maintainers":[{"name":"aneesha_0","email":"aneeshakota@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dwn-sdk_1.0.0_1688466991034_0.6023566473622204"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-04T10:36:30.973Z","1.0.0":"2023-07-04T10:36:31.255Z","modified":"2023-07-04T10:36:31.536Z"},"maintainers":[{"name":"aneesha_0","email":"aneeshakota@gmail.com"}],"description":"A reference implementation of https://identity.foundation/decentralized-web-node/spec/","homepage":"https://github.com/AneeshaKota/dwn-sdk-js#readme","repository":{"type":"git","url":"git+https://github.com/AneeshaKota/dwn-sdk-js.git"},"contributors":[{"name":"Daniel Buchner","url":"https://github.com/csuwildcat"},{"name":"Diane Huxley","url":"https://github.com/diehuxx"},{"name":"Henry Tsai","url":"https://github.com/thehenrytsai"},{"name":"Moe Jangda","url":"https://github.com/mistermoe"},{"name":"Aneesha Kota","url":"https://github.com/AneeshaKota"}],"bugs":{"url":"https://github.com/AneeshaKota/dwn-sdk-js/issues"},"license":"Apache-2.0","readme":"<!-- @format -->\n\n# Decentralized Web Node (DWN) SDK\n\nCode Coverage\n![Statements](https://img.shields.io/badge/statements-97.32%25-brightgreen.svg?style=flat) ![Branches](https://img.shields.io/badge/branches-94%25-brightgreen.svg?style=flat) ![Functions](https://img.shields.io/badge/functions-93.68%25-brightgreen.svg?style=flat) ![Lines](https://img.shields.io/badge/lines-97.32%25-brightgreen.svg?style=flat)\n\n## Introduction\n\nThis repository contains a reference implementation of Decentralized Web Node (DWN) as per the [specification](https://identity.foundation/decentralized-web-node/spec/). This specification is in a draft state and very much so a WIP. For the foreseeable future, a lot of the work on DWN will be split across this repo and the repo that houses the specification, which you can find [here](https://github.com/decentralized-identity/decentralized-web-node). The current implementation does not include all interfaces described in the DWN spec, but is enough to begin building test applications.\n\nThis project is used as a dependency by several other projects.\n\nProposals and issues for the specification itself should be submitted as pull requests to the [spec repo](https://github.com/decentralized-identity/decentralized-web-node).\n\n## Installation\n\nIf you are interested in using DWNs and web5 in your web app, you probably want to look at web5-js, instead of this repository. Head on over here: https://github.com/TBD54566975/web5-js.\n\nFor advanced users wishing to use this repo directly:\n\n```bash\nnpm install @tbd54566975/dwn-sdk-js\n```\n\n## Additional Steps\n\nThis package has dependency on [`@noble/ed25519`](https://github.com/paulmillr/noble-ed25519#usage) and [`@noble/secp256k1`](https://github.com/paulmillr/noble-secp256k1#usage) v2, additional steps are needed for some environments:\n\n- Node.js <= 18\n\n```js\n// node.js 18 and earlier,  needs globalThis.crypto polyfill\nimport { webcrypto } from \"node:crypto\";\n// @ts-ignore\nif (!globalThis.crypto) globalThis.crypto = webcrypto;\n```\n\n- React Native:\n\n```js\n// If you're on react native. React Native needs crypto.getRandomValues polyfill and sha512\nimport \"react-native-get-random-values\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha256 } from \"@noble/hashes/sha256\";\nimport { sha512 } from \"@noble/hashes/sha512\";\ned.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m));\ned.etc.sha512Async = (...m) => Promise.resolve(ed.etc.sha512Sync(...m));\n\nsecp.etc.hmacSha256Sync = (k, ...m) =>\n  hmac(sha256, k, secp.etc.concatBytes(...m));\nsecp.etc.hmacSha256Async = (k, ...m) =>\n  Promise.resolve(secp.etc.hmacSha256Sync(k, ...m));\n```\n\n## Usage\n\n[API docs](https://tbd54566975.github.io/dwn-sdk-js/)\n\n```javascript\n\nimport { Dwn, DataStream, DidKeyResolver, Jws, RecordsWrite, RecordsQuery } from '@tbd54566975/dwn-sdk-js';\n\nexport const dwn = await Dwn.create();\n\n...\nconst didKey = await DidKeyResolver.generate(); // generate a did:key DID\nconst signatureMaterial = Jws.createSignatureInput(didKey);\nconst data = randomBytes(32); // in node.js\n// or in web\n// const data = new Uint8Array(32);\n// window.crypto.getRandomValues(data);\n\nconst recordsWrite = await RecordsWrite.create({\n  data,\n  dataFormat                  : 'application/json',\n  published                   : true,\n  schema                      : 'yeeter/post',\n  authorizationSignatureInput : signatureMaterial\n});\n\nconst dataStream = DataStream.fromBytes(data);\nconst result = await dwn.processMessage(didKey.did, recordsWrite.message, dataStream);\n\n```\n\nWith a web wallet installed:\n\n```javascript\nconst result = await window.web5.dwn.processMessage({\n  method: \"RecordsQuery\",\n  message: {\n    filter: {\n      schema: \"http://some-schema-registry.org/todo\",\n    },\n    dateSort: \"createdAscending\",\n  },\n});\n```\n\n## Release/Build Process\n\nThe DWN JS SDK releases builds to [npmjs.com](https://www.npmjs.com/package/@tbd54566975/dwn-sdk-js). There are two build types: stable build and unstable build.\n\n### Stable Build\n\nThis is triggered manually by:\n\n1.  Increment `version` in `package.json` in [Semantic Versioning (semver)](https://semver.org/) format.\n2.  Merge the change into `main` branch\n3.  Create a release from GitHub.\n\nAn official build with version matching the `package.json` will be published to [npmjs.com](https://www.npmjs.com/package/@tbd54566975/dwn-sdk-js).\n\n### Unstable Build\n\nEvery push to the `main` branch will automatically trigger an unstable build to [npmjs.com](https://www.npmjs.com/package/@tbd54566975/dwn-sdk-js) for developers to experiment and test.\n\nThe version string contains the date as well as the commit hash of the last change.\n\nAn example version string:\n\n`0.0.26-unstable-2023-03-16-36ec2ce`\n\n- `0.0.26` came from `version` in `package.json`\n- `2023-03-16` indicates the date of March 16th 2023\n- `36ec2ce` is the commit hash of the last change\n\n## Some projects that use this library:\n\n- [Web5 JS SDK](https://github.com/TBD54566975/web5-js)\n- [Example CLI](https://github.com/TBD54566975/dwn-cli)\n- [Example with a web wallet](https://github.com/TBD54566975/incubating-web5-labs/)\n- [Server side aggregator](https://github.com/TBD54566975/dwn-server)\n\n## Architecture\n\n<img src=\"./images/dwn-architecture.png\" alt=\"Architecture of DWN SDN\" width=\"700\">\n\n> NOTE: The diagram is a conceptual view of the architecture, the actual component abstraction and names in source file may differ.\n\n## Project Resources\n\n| Resource                                                                                     | Description                                                                   |\n| -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |\n| [CODEOWNERS](https://github.com/TBD54566975/dwn-sdk-js/blob/main/CODEOWNERS)                 | Outlines the project lead(s)                                                  |\n| [CODE_OF_CONDUCT.md](https://github.com/TBD54566975/dwn-sdk-js/blob/main/CODE_OF_CONDUCT.md) | Expected behavior for project contributors, promoting a welcoming environment |\n| [CONTRIBUTING.md](https://github.com/TBD54566975/dwn-sdk-js/blob/main/CONTRIBUTING.md)       | Developer guide to build, test, run, access CI, chat, discuss, file issues    |\n| [GOVERNANCE.md](https://github.com/TBD54566975/dwn-sdk-js/blob/main/GOVERNANCE.md)           | Project governance                                                            |\n| [LICENSE](https://github.com/TBD54566975/dwn-sdk-js/blob/main/LICENSE)                       | Apache License, Version 2.0                                                   |\n| [Q_AND_A.md](https://github.com/TBD54566975/dwn-sdk-js/blob/main/Q_AND_A.md)                 | Questions and answers on DWN                                                  |\n","readmeFilename":"README.md"}