diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml deleted file mode 100644 index dd433bdaa..000000000 --- a/.github/workflows/ci-test.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: ci test - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - test-on-node: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18.8.0 - registry-url: https://registry.npmjs.org/ - - run: npm install - - run: npm run test:node - - test-on-browsers: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18.8.0 - registry-url: https://registry.npmjs.org/ - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - run: npm install - - run: npm run test:browser - diff --git a/.github/workflows/docs-publish.yml b/.github/workflows/docs-publish.yml index d39cf11f8..f9ec9c786 100644 --- a/.github/workflows/docs-publish.yml +++ b/.github/workflows/docs-publish.yml @@ -3,9 +3,9 @@ name: Build and Deploy Docs on: # Runs on pushes targeting the default branch - push: - branches: - - main + # push: + # branches: + # - main # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -17,28 +17,28 @@ concurrency: cancel-in-progress: false jobs: - build: permissions: - contents: write # to write documentation files to the repo - + contents: write # to write documentation files to the repo + runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Checkout source + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version: 18 + registry-url: https://registry.npmjs.org/ - name: Install dependencies run: | npm ci npm i jsdoc npm i clean-jsdoc-theme - + - name: Generate documentation run: | echo "# Web5 JS SDK" > README-docs.md @@ -55,13 +55,13 @@ jobs: deploy: # Add a dependency to the build job needs: build - + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment permissions: - contents: read # to read from project repo - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source - + contents: read # to read from project repo + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + # Deploy to the github-pages environment environment: name: github-pages @@ -85,7 +85,7 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: - path: './docs' + path: "./docs" - name: Deploy to GitHub Pages id: deployment diff --git a/.github/workflows/npm-publish-stable.yml b/.github/workflows/npm-publish-stable.yml deleted file mode 100644 index 37d063da2..000000000 --- a/.github/workflows/npm-publish-stable.yml +++ /dev/null @@ -1,28 +0,0 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages - -name: publish stable - -on: - release: - types: [created] - -jobs: - publish-npm: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18.8.0 - registry-url: https://registry.npmjs.org/ - - run: npm install - # builds all bundles - - run: npm run build - # Note - this is not required but it gives a clean failure prior to attempting a release if the GH workflow runner is not authenticated with npm.js - - run: npm whoami - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} \ No newline at end of file diff --git a/.github/workflows/npm-publish-unstable.yml b/.github/workflows/npm-publish-unstable.yml deleted file mode 100644 index cc15101be..000000000 --- a/.github/workflows/npm-publish-unstable.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: publish unstable - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - - publish-npm-unstable: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18.8.0 - registry-url: https://registry.npmjs.org/ - - run: npm install - # builds all bundles - - run: npm run build - # Note - this is not required but it gives a clean failure prior to attempting a release if the GH workflow runner is not authenticated with npm.js - - run: npm whoami - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - - run: npm run publish:unstable - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml new file mode 100644 index 000000000..caeec0ac8 --- /dev/null +++ b/.github/workflows/release-npm.yml @@ -0,0 +1,46 @@ +name: Release to NPM Registry + +on: + release: + types: [created] + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +permissions: + contents: read + id-token: write + +jobs: + publish-npm: + name: Release NPM Package + runs-on: ubuntu-latest + + steps: + - name: Checkout source + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + + - name: Install latest npm + run: npm install -g npm@latest + + - name: Install dependencies + run: npm ci + + - name: Build all workspace packages + run: npm run build + + # Note - this is not required but it gives a clean failure prior to attempting a release if the GH workflow runner is not authenticated with NPMjs.com + - name: Display the npm username of the currently logged-in user + run: npm whoami + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + + - name: Publish Release to NPM Public Registry + run: npm publish --ws --access public --provenance + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.github/workflows/tests-ci.yml b/.github/workflows/tests-ci.yml new file mode 100644 index 000000000..02155adfb --- /dev/null +++ b/.github/workflows/tests-ci.yml @@ -0,0 +1,58 @@ +name: Run Tests in Node and Browsers + +on: + push: + branches: + - main + pull_request: + branches: + - main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + test-on-node: + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + + - name: Install latest npm + run: npm install -g npm@latest + + - name: Install dependencies + run: npm ci + + - name: Run tests for all packages + run: npm run test:node --ws + + test-on-browsers: + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + + - name: Install latest npm + run: npm install -g npm@latest + + - name: Install Playwright Browsers + run: npx playwright install --with-deps + + - name: Install dependencies + run: npm ci + + - name: Run tests for all packages + run: npm run test:browser --ws diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 72973dde2..6efe393c4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,213 +1,112 @@ -# Contribution Guide +# Contribution Guide There are many ways to be an open source contributor, and we're here to help you on your way! You may: -* Propose ideas in our Web5 [discord](https://discord.com/channels/937858703112155166/969272658501976117) channel -* Raise an issue or feature request in our [issue tracker](https://github.com/TBD54566975/web5-js/issues) -* Help another contributor with one of their questions, or a code review -* Suggest improvements to our Getting Started documentation by supplying a Pull Request -* Evangelize our work together in conferences, podcasts, and social media spaces. +- Propose ideas in our Web5 [discord](https://discord.com/channels/937858703112155166/969272658501976117) channel +- Raise an issue or feature request in our [issue tracker](https://github.com/TBD54566975/web5-js/issues) +- Help another contributor with one of their questions, or a code review +- Suggest improvements to our Getting Started documentation by supplying a Pull Request +- Evangelize our work together in conferences, podcasts, and social media spaces. This guide is for you. -## Development Prerequisites - -___***UPDATE TABLE OF PROJECT DEPS AND INSTALLATION NOTES***___ - -| Requirement | Tested Version | Installation Instructions | -|-------------|----------------|------------------------------------------------------| -| Go | 1.17.6 |[go.dev](https://go.dev/doc/tutorial/compile-install) | -| Mage | 1.12.1 |[magefile.org](https://magefile.org/) | -| Java | 17.0.2 | Below, recommended via [SDKMan](https://sdkman.io) | - -### Go - -This project is written in Go, a modern, open source programming language. - -You may verify your `go` installation via the terminal: - -``` -$> go version -go version go1.17.6 darwin/amd64 -``` - -If you do not have go, we recommend installing it by: - -#### MacOS - -##### Homebrew -``` -$> brew install go -``` - -#### Linux - -See the [Go Installation Documentation](https://go.dev/doc/install). - -### Mage - -The build is run by Mage. - -You may verify your `mage` installation via the terminal: - -``` -$> mage --version -Mage Build Tool 1.12.1 -Build Date: 2021-12-15T21:00:02Z -Commit: 2f1ec40 -built with: go1.17.6 -``` - -#### MacOS - -##### Homebrew - -``` -$> brew install mage -``` - -#### Linux - -Installation instructions are on the [Magefile home page](https://magefile.org/). - -### Java - -This project is written in Java, a typesafe, compiled programming language. - -You may verify your `java` installation via the terminal by running `java -version`. - -If you do not have Java, we recommend installing it -via [SDKMan](https://sdkman.io/install). This is a project which will allow you -to easily install the Java Development Kit (JDK), runtime (JRE), and related frameworks, -build tools, and runtimes. - -After you've installed SDKMan, you may install Java: - -#### SDKMan (cross-platform instructions) +## Communications -```shell -$> sdk install java - ... -Do you want java 17.0.2-open to be set as default? (Y/n): Y -Setting java 17.0.2-open as default. -``` +### Issues -You may test your installation: +Anyone from the community is welcome (and encouraged!) to raise issues via +[GitHub Issues](https://github.com/TBD54566975/web5-js/issues). -```shell -$> java -version -openjdk version "17.0.2" 2022-01-18 -OpenJDK Runtime Environment (build 17.0.2+8-86) -OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing) -``` +As we work our way towards a beta release and beyond, we'll be creating more focused issues with the following labels: ---- -**NOTE** +- `bug` +- `documentation` +- `good first issue` +- `help wanted` -You may additionally look for other Java versions to install by running `sdk list java`: +These issues are excellent canditates for contribution and we'd be thrilled to get all the help we can get! You can take a look at all of the Issues that match the labels above [here](https://github.com/TBD54566975/web5-js/issues?q=is%3Aopen+label%3A%22help+wanted%22%2C%22good+first+issue%22%2C%22documentation%22%2C%22bug%22+). -...or other installation candidates like Apache Ant, Apache Maven, etc, by running `sdk list`. +We suggest the following process when picking up one of these issues: -Consult the SDKMan documentation for more info. +- Check to see if anyone is already working on the issue by looking to see if the issue has a `WIP` tag. +- Fork the repo and create a branch named the issue number you're taking on. +- Push that branch and create a draft PR. +- Paste a link to the draft PR in the issue you're tackling. +- We'll add the `WIP` tag for you. +- Work away. Feel free to ask any/all questions that crop up along the way. +- Switch the draft PR to "Ready for review". ---- +### Discussions -## Build (Mage) +Design discussions and proposals take place on our Web5 [discord](https://discord.com/channels/937858703112155166/969272658501976117) channel. -``` -$> mage build -``` +We advocate an asynchronous, written debate model - so write up your thoughts and invite the community to join in! -## Build (Java / Gradle) +### Continuous Integration -### macOS / Linux -```shell -$> ./gradlew build -``` +Build and Test cycles are run on every commit to every branch using [GitHub Actions](https://github.com/TBD54566975/web5-js/actions). -### Windows -```shell -$> gradlew.bat build -``` +## Development Prerequisites -## Test (Mage) +| Requirement | Tested Version | Installation Instructions | +| ----------- | -------------- | ---------------------------------------------------------------------------------------------- | +| Node.js | 18.16.0 | [Introduction to Node.js](https://nodejs.dev/en/learn/) | +| NPM | 9.6.3 | [NPM Package Manager](https://nodejs.dev/en/learn/an-introduction-to-the-npm-package-manager/) | -``` -$> mage test -``` +### TypeScript -## Test (Java / Gradle) +This project is written in TypeScript, a strongly typed programming language that builds on JavaScript. -### macOS / Linux -```shell -$> ./gradlew test -``` +You may verify your `node` and `npm` installation via the terminal: -### Windows -```shell -$> gradlew.bat test ``` - ---- -**NOTE** - -You may also combine Gradle build targets in one call, like: - -```shell -$> ./gradlew clean build test +$ node --version +v18.16.0 +$ npm --version +9.6.3 ``` ---- - -## Communications - -### Issues - -Anyone from the community is welcome (and encouraged!) to raise issues via -[GitHub Issues](LINK_HERE) ___***FIX LINK AND REMOVE THIS NOTICE***___. - -### Discussions - -Design discussions and proposals take place on our Web5 [discord](https://discord.com/channels/937858703112155166/969272658501976117) channel. - -We advocate an asynchronous, written debate model - so write up your thoughts and invite the community to join in! - -### Continuous Integration - -Build and Test cycles are run on every commit to every branch on [CircleCI](LINK_HERE). - - ___***FIX LINK ABOVE AND REMOVE THIS NOTICE***___ +If you do not have Node.js installed, we recommend following the +[Introduction to Node.js](https://nodejs.dev/en/learn/) guide. ## Contribution -We review contributions to the codebase via GitHub's Pull Request mechanism. We have -the following guidelines to ease your experience and help our leads respond quickly +We review contributions to the codebase via GitHub's Pull Request mechanism. We have +the following guidelines to ease your experience and help our leads respond quickly to your valuable work: -* Start by proposing a change either in Issues (most appropriate for small - change requests or bug fixes) or in Discussions (most appropriate for design - and architecture considerations, proposing a new feature, or where you'd +- Start by proposing a change either in Issues (most appropriate for small + change requests or bug fixes) or in Discussions (most appropriate for design + and architecture considerations, proposing a new feature, or where you'd like insight and feedback) -* Cultivate consensus around your ideas; the project leads will help you - pre-flight how beneficial the proposal might be to the project. Developing early - buy-in will help others understand what you're looking to do, and give you a - greater chance of your contributions making it into the codebase! No one wants to +- Cultivate consensus around your ideas; the project leads will help you + pre-flight how beneficial the proposal might be to the project. Developing early + buy-in will help others understand what you're looking to do, and give you a + greater chance of your contributions making it into the codebase! No one wants to see work done in an area that's unlikely to be incorporated into the codebase. -* Fork the repo into your own namespace/remote -* Work in a dedicated feature branch. Atlassian wrote a great +- Fork the repo into your own namespace/remote +- Work in a dedicated feature branch. Atlassian wrote a great [description of this workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow) -* When you're ready to offer your work to the project, first: -* Squash your commits into a single one (or an appropriate small number of commits), and - rebase atop the upstream `main` branch. This will limit the potential for merge - conflicts during review, and helps keep the audit trail clean. A good writeup for - how this is done is - [here](https://medium.com/@slamflipstrom/a-beginners-guide-to-squashing-commits-with-git-rebase-8185cf6e62ec), and if you're - having trouble - feel free to ask a member or the community for help or leave the commits as-is, and flag that you'd like +- When you're ready to offer your work to the project, first: +- Squash your commits into a single one (or an appropriate small number of commits), and + rebase atop the upstream `main` branch. This will limit the potential for merge + conflicts during review, and helps keep the audit trail clean. A good writeup for + how this is done is + [here](https://medium.com/@slamflipstrom/a-beginners-guide-to-squashing-commits-with-git-rebase-8185cf6e62ec), and if you're + having trouble - feel free to ask a member or the community for help or leave the commits as-is, and flag that you'd like rebasing assistance in your PR! We're here to support you. -* Open a PR in the project to bring in the code from your feature branch. -* The maintainers noted in the [`CODEOWNERS`](https://github.com/TBD54566975/web5-js/blob/main/CODEOWNERS) file will review your PR and optionally +- Open a PR in the project to bring in the code from your feature branch. +- The maintainers noted in the [`CODEOWNERS`](https://github.com/TBD54566975/web5-js/blob/main/CODEOWNERS) file will review your PR and optionally open a discussion about its contents before moving forward. -* Remain responsive to follow-up questions, be open to making requested changes, and... +- Remain responsive to follow-up questions, be open to making requested changes, and... You're a contributor! -* And remember to respect everyone in our global development community. Guidelines +- And remember to respect everyone in our global development community. Guidelines are established in our [`CODE_OF_CONDUCT.md`](https://github.com/TBD54566975/web5-js/blob/main/CODE_OF_CONDUCT.md). + +### Running tests + +- Running the `npm run test:node --ws` command from the root of the project will run all tests using node. + - This is run via CI whenever a pull request is opened, or a commit is pushed to a branch that has an open PR +- Running the `npm run test:browser --ws` command from the root of the project will run the tests in a browser environment + - Please make sure there are no failing tests before switching your PR to ready for review! We hope to have this automated via a github action very soon. +- You can also run `npm run test:node -w=packages/DIR` or `npm run test:browser -w=packages/DIR` from the root of the project to run tests for a single package. For example, to run the tests only for the `web5` package run `npm run test:node -w=packages/web5`. diff --git a/package-lock.json b/package-lock.json index 329fe9a80..f7d7d3caf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7600,15 +7600,19 @@ "packages/crypto": { "name": "@tbd54566975/crypto", "version": "0.1.0", + "license": "Apache-2.0", "dependencies": { "ed2curve": "0.3.0", "multiformats": "11.0.2" }, "devDependencies": { + "@types/chai": "4.3.0", "@types/ed2curve": "0.2.2", "@types/eslint": "8.37.0", + "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", + "chai": "4.3.7", "esbuild": "0.16.7", "eslint": "8.39.0", "karma": "6.4.1", @@ -7624,11 +7628,15 @@ "playwright": "1.31.2", "rimraf": "4.4.0", "typescript": "5.0.4" + }, + "engines": { + "node": ">=18.0.0" } }, "packages/dids": { "name": "@tbd54566975/dids", "version": "0.1.0", + "license": "Apache-2.0", "dependencies": { "@decentralized-identity/ion-tools": "1.0.7", "@tbd54566975/crypto": "0.1.0", @@ -7657,6 +7665,9 @@ "playwright": "1.31.2", "rimraf": "4.4.0", "typescript": "5.0.4" + }, + "engines": { + "node": ">=18.0.0" } }, "packages/web5": { @@ -7678,7 +7689,7 @@ }, "devDependencies": { "@types/chai": "4.3.0", - "@types/chai-as-promised": "^7.1.5", + "@types/chai-as-promised": "7.1.5", "@types/ms": "0.7.31", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", @@ -7701,23 +7712,44 @@ "sinon": "15.0.2", "source-map-loader": "4.0.1", "typescript": "5.0.4" + }, + "engines": { + "node": ">=18.0.0" } }, "packages/web5-agent": { "name": "@tbd54566975/web5-agent", "version": "0.1.0", + "license": "Apache-2.0", "dependencies": { "@tbd54566975/dwn-sdk-js": "0.0.32-unstable-2023-05-15-1350300", "readable-stream": "4.4.0" }, "devDependencies": { + "@types/chai": "4.3.0", "@types/eslint": "8.37.0", + "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", + "chai": "4.3.7", "esbuild": "0.16.7", "eslint": "8.39.0", + "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", + "mocha": "10.2.0", + "node-stdlib-browser": "1.2.0", + "playwright": "1.31.2", "rimraf": "4.4.0", "typescript": "5.0.4" + }, + "engines": { + "node": ">=18.0.0" } }, "packages/web5-agent/node_modules/readable-stream": { @@ -7737,14 +7769,19 @@ "packages/web5-proxy-agent": { "name": "@tbd54566975/web5-proxy-agent", "version": "0.1.0", + "license": "Apache-2.0", "dependencies": { "@tbd54566975/web5-agent": "0.1.0" }, "devDependencies": { + "@types/chai": "4.3.0", "@types/ed2curve": "0.2.2", "@types/eslint": "8.37.0", + "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", + "chai": "4.3.7", + "chai-as-promised": "7.1.1", "dts-bundle-generator": "^8.0.1", "esbuild": "0.16.7", "eslint": "8.39.0", @@ -7761,6 +7798,9 @@ "playwright": "1.31.2", "rimraf": "4.4.0", "typescript": "5.0.4" + }, + "engines": { + "node": ">=18.0.0" } }, "packages/web5-user-agent": { @@ -7779,7 +7819,7 @@ "uuid": "9.0.0" }, "devDependencies": { - "@playwright/test": "^1.33.0", + "@playwright/test": "1.33.0", "@types/flat": "5.0.2", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", @@ -7802,6 +7842,9 @@ "sinon": "15.0.2", "source-map-loader": "4.0.1", "typescript": "5.0.4" + }, + "engines": { + "node": ">=18.0.0" } }, "packages/web5-user-agent/node_modules/@esbuild/android-arm": { @@ -9192,10 +9235,13 @@ "@tbd54566975/crypto": { "version": "file:packages/crypto", "requires": { + "@types/chai": "4.3.0", "@types/ed2curve": "0.2.2", "@types/eslint": "8.37.0", + "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", + "chai": "4.3.7", "ed2curve": "0.3.0", "esbuild": "0.16.7", "eslint": "8.39.0", @@ -9313,7 +9359,7 @@ "@tbd54566975/web5-proxy-agent": "0.1.0", "@tbd54566975/web5-user-agent": "0.1.0", "@types/chai": "4.3.0", - "@types/chai-as-promised": "^7.1.5", + "@types/chai-as-promised": "7.1.5", "@types/ms": "0.7.31", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", @@ -9532,11 +9578,25 @@ "version": "file:packages/web5-agent", "requires": { "@tbd54566975/dwn-sdk-js": "0.0.32-unstable-2023-05-15-1350300", + "@types/chai": "4.3.0", "@types/eslint": "8.37.0", + "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", + "chai": "4.3.7", "esbuild": "0.16.7", "eslint": "8.39.0", + "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", + "mocha": "10.2.0", + "node-stdlib-browser": "1.2.0", + "playwright": "1.31.2", "readable-stream": "4.4.0", "rimraf": "4.4.0", "typescript": "5.0.4" @@ -9559,10 +9619,14 @@ "version": "file:packages/web5-proxy-agent", "requires": { "@tbd54566975/web5-agent": "0.1.0", + "@types/chai": "4.3.0", "@types/ed2curve": "0.2.2", "@types/eslint": "8.37.0", + "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", + "chai": "4.3.7", + "chai-as-promised": "7.1.1", "dts-bundle-generator": "^8.0.1", "esbuild": "0.16.7", "eslint": "8.39.0", @@ -9585,7 +9649,7 @@ "version": "file:packages/web5-user-agent", "requires": { "@decentralized-identity/ion-tools": "1.0.7", - "@playwright/test": "^1.33.0", + "@playwright/test": "1.33.0", "@tbd54566975/dids": "0.1.0", "@tbd54566975/dwn-sdk-js": "0.0.32-unstable-2023-05-15-1350300", "@types/flat": "5.0.2", diff --git a/packages/crypto/LICENSE b/packages/crypto/LICENSE new file mode 100644 index 000000000..f49a4e16e --- /dev/null +++ b/packages/crypto/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/crypto/README.md b/packages/crypto/README.md new file mode 100644 index 000000000..e3007f27c --- /dev/null +++ b/packages/crypto/README.md @@ -0,0 +1 @@ +# Web5 Crypto diff --git a/packages/crypto/karma.conf.cjs b/packages/crypto/karma.conf.cjs new file mode 100644 index 000000000..1a3e8269c --- /dev/null +++ b/packages/crypto/karma.conf.cjs @@ -0,0 +1,75 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +// Karma is what we're using to run our tests in browser environments +// Karma does not support .mjs + +// playwright acts as a safari executable on windows and mac +const playwright = require('playwright'); +const esbuildBrowserConfig = require('./build/esbuild-browser-config.cjs'); + +// use playwright chrome exec path as run target for chromium tests +process.env.CHROME_BIN = playwright.chromium.executablePath(); + +// use playwright webkit exec path as run target for safari tests +process.env.WEBKIT_HEADLESS_BIN = playwright.webkit.executablePath(); + +// use playwright firefox exec path as run target for firefox tests +process.env.FIREFOX_BIN = playwright.firefox.executablePath(); + +module.exports = function (config) { + config.set({ + plugins: [ + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-webkit-launcher', + 'karma-esbuild', + 'karma-mocha', + 'karma-mocha-reporter', + ], + + // frameworks to use + // available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter + frameworks: ['mocha'], + + + // list of files / patterns to load in the browser + files: [ + { pattern: 'tests/**/*.spec.ts', watched: false }, + ], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor + preprocessors: { + 'tests/**/*.spec.ts': ['esbuild'], + }, + + esbuild: esbuildBrowserConfig, + + // list of files / patterns to exclude + exclude: [], + + // test results reporter to use + // available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter + reporters: ['mocha'], + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || + // config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + concurrency: 1, + + // start these browsers + // available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher + browsers: ['ChromeHeadless', 'FirefoxHeadless', 'WebkitHeadless'], + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, + }); +}; diff --git a/packages/crypto/package.json b/packages/crypto/package.json index eab294746..c67bd1697 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -1,10 +1,44 @@ { "name": "@tbd54566975/crypto", - "type": "module", "version": "0.1.0", + "description": "TBD crypto library", + "type": "module", "main": "./dist/cjs/main.cjs", "module": "./dist/esm/main.mjs", "types": "./dist/types/main.d.ts", + "scripts": { + "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", + "lint": "eslint . --ext .js --max-warnings 0", + "lint:fix": "eslint . --ext .js --fix", + "test:node": "rimraf __tests__ && tsc -p tsconfig.test.json && mocha \"__tests__/**/*.spec.js\" --exit", + "test:browser": "karma start karma.conf.cjs" + }, + "homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/crypto#readme", + "bugs": "https://github.com/TBD54566975/web5-js/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/TBD54566975/web5-js", + "directory": "packages/crypto" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Daniel Buchner", + "url": "https://github.com/csuwildcat" + }, + { + "name": "Frank Hinek", + "url": "https://github.com/frankhinek" + }, + { + "name": "Moe Jangda", + "url": "https://github.com/mistermoe" + } + ], + "files": [ + "dist", + "src" + ], "exports": { ".": { "import": "./dist/esm/main.mjs", @@ -22,15 +56,30 @@ "./dist/cjs/index.js": "./dist/browser.js", "types": "./dist/types/main.d.ts" }, + "keywords": [ + "cryptography", + "ed25519", + "secp256k1", + "web5" + ], + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=18.0.0" + }, "dependencies": { "ed2curve": "0.3.0", "multiformats": "11.0.2" }, "devDependencies": { + "@types/chai": "4.3.0", "@types/ed2curve": "0.2.2", "@types/eslint": "8.37.0", + "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", + "chai": "4.3.7", "esbuild": "0.16.7", "eslint": "8.39.0", "karma": "6.4.1", @@ -46,17 +95,5 @@ "playwright": "1.31.2", "rimraf": "4.4.0", "typescript": "5.0.4" - }, - "files": [ - "dist", - "src" - ], - "scripts": { - "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", - "lint": "eslint . --ext .js --max-warnings 0", - "lint:fix": "eslint . --ext .js --fix", - "publish:unstable": "./build/publish-unstable.sh", - "test:node": "mocha \"tests/**/*.spec.js\" --exit", - "test:browser": "karma start karma.conf.cjs" } } diff --git a/packages/crypto/tests/needed.spec.ts b/packages/crypto/tests/needed.spec.ts new file mode 100644 index 000000000..652d167f3 --- /dev/null +++ b/packages/crypto/tests/needed.spec.ts @@ -0,0 +1,3 @@ +describe('@tbd54566975/crypto', () => { + xit('should have tests'); +}); \ No newline at end of file diff --git a/packages/crypto/tsconfig.test.json b/packages/crypto/tsconfig.test.json new file mode 100644 index 000000000..4a800997e --- /dev/null +++ b/packages/crypto/tsconfig.test.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "lib": [ + "DOM", + "ES6" + ], + "target": "es6", + "module": "ESNext", // Required for enabling JavaScript import assertion support + "declaration": true, + "declarationMap": true, + "outDir": "__tests__", + "declarationDir": "__tests__/types", + "sourceMap": true, + // `NodeNext` will throw compilation errors if relative import paths are missing file extension + // reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#ecmascript-module-support-in-node-js + "moduleResolution": "NodeNext", + // allows us to import json files + "resolveJsonModule": true, + "esModuleInterop": true + }, + "include": [ + "src", + "tests", + "typings" + ], + "exclude": [ + "node_modules", + "dist" + ] +} \ No newline at end of file diff --git a/packages/dids/LICENSE b/packages/dids/LICENSE new file mode 100644 index 000000000..f49a4e16e --- /dev/null +++ b/packages/dids/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/dids/README.md b/packages/dids/README.md new file mode 100644 index 000000000..3557ba69f --- /dev/null +++ b/packages/dids/README.md @@ -0,0 +1 @@ +# Web5 DID diff --git a/packages/dids/package.json b/packages/dids/package.json index f402e2d6f..8e197033a 100644 --- a/packages/dids/package.json +++ b/packages/dids/package.json @@ -1,10 +1,44 @@ { "name": "@tbd54566975/dids", - "type": "module", "version": "0.1.0", + "description": "TBD DIDs library", + "type": "module", "main": "./dist/cjs/main.cjs", "module": "./dist/esm/main.mjs", "types": "./dist/types/main.d.ts", + "scripts": { + "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", + "lint": "eslint . --ext .js --max-warnings 0", + "lint:fix": "eslint . --ext .js --fix", + "test:node": "rimraf __tests__ && tsc -p tsconfig.test.json && mocha \"__tests__/**/*.spec.js\" --exit", + "test:browser": "karma start karma.conf.cjs" + }, + "homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/dids#readme", + "bugs": "https://github.com/TBD54566975/web5-js/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/TBD54566975/web5-js", + "directory": "packages/dids" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Daniel Buchner", + "url": "https://github.com/csuwildcat" + }, + { + "name": "Frank Hinek", + "url": "https://github.com/frankhinek" + }, + { + "name": "Moe Jangda", + "url": "https://github.com/mistermoe" + } + ], + "files": [ + "dist", + "src" + ], "exports": { ".": { "import": "./dist/esm/main.mjs", @@ -22,6 +56,22 @@ "./dist/cjs/index.js": "./dist/browser.js", "types": "./dist/types/main.d.ts" }, + "keywords": [ + "decentralized", + "decentralized-identity", + "DID", + "did:ion", + "did:key", + "did-utils", + "self-sovereign-identity", + "web5" + ], + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=18.0.0" + }, "dependencies": { "@decentralized-identity/ion-tools": "1.0.7", "@tbd54566975/crypto": "0.1.0", @@ -50,12 +100,5 @@ "playwright": "1.31.2", "rimraf": "4.4.0", "typescript": "5.0.4" - }, - "scripts": { - "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", - "lint": "eslint . --ext .js --max-warnings 0", - "lint:fix": "eslint . --ext .js --fix", - "test:node": "tsc -p tsconfig.test.json && mocha \"__tests__/**/*.spec.js\"", - "test:browser": "karma start karma.conf.cjs" } } \ No newline at end of file diff --git a/packages/dids/tests/did-key.spec.ts b/packages/dids/tests/did-key.spec.ts index 0fd7af831..d9033e38f 100644 --- a/packages/dids/tests/did-key.spec.ts +++ b/packages/dids/tests/did-key.spec.ts @@ -4,7 +4,7 @@ import { DidKeyApi } from '../src/did-key.js'; const DidKey = new DidKeyApi(); describe('DidKeyApi', () => { - it('works', async () => { + it.only('works', async () => { const didState = await DidKey.create(); expect(didState.id).to.exist; @@ -14,8 +14,7 @@ describe('DidKeyApi', () => { expect(didState.methodData).to.exist; expect(Object.keys(didState.methodData).length).to.equal(0); - expect(didState.services).to.exist; - expect(didState.services.length).to.equal(0); + expect((didState as any).services).to.not.exist; for (let key of didState.keys) { expect(key.id).to.exist; diff --git a/packages/dids/tsconfig.test.json b/packages/dids/tsconfig.test.json index 30ae6d872..4a800997e 100644 --- a/packages/dids/tsconfig.test.json +++ b/packages/dids/tsconfig.test.json @@ -10,9 +10,12 @@ "declarationMap": true, "outDir": "__tests__", "declarationDir": "__tests__/types", + "sourceMap": true, // `NodeNext` will throw compilation errors if relative import paths are missing file extension // reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#ecmascript-module-support-in-node-js "moduleResolution": "NodeNext", + // allows us to import json files + "resolveJsonModule": true, "esModuleInterop": true }, "include": [ diff --git a/packages/web5-agent/LICENSE b/packages/web5-agent/LICENSE new file mode 100644 index 000000000..f49a4e16e --- /dev/null +++ b/packages/web5-agent/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/web5-agent/README.md b/packages/web5-agent/README.md new file mode 100644 index 000000000..84d278e78 --- /dev/null +++ b/packages/web5-agent/README.md @@ -0,0 +1 @@ +# Web5 Agent diff --git a/packages/web5-agent/karma.conf.cjs b/packages/web5-agent/karma.conf.cjs new file mode 100644 index 000000000..1a3e8269c --- /dev/null +++ b/packages/web5-agent/karma.conf.cjs @@ -0,0 +1,75 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +// Karma is what we're using to run our tests in browser environments +// Karma does not support .mjs + +// playwright acts as a safari executable on windows and mac +const playwright = require('playwright'); +const esbuildBrowserConfig = require('./build/esbuild-browser-config.cjs'); + +// use playwright chrome exec path as run target for chromium tests +process.env.CHROME_BIN = playwright.chromium.executablePath(); + +// use playwright webkit exec path as run target for safari tests +process.env.WEBKIT_HEADLESS_BIN = playwright.webkit.executablePath(); + +// use playwright firefox exec path as run target for firefox tests +process.env.FIREFOX_BIN = playwright.firefox.executablePath(); + +module.exports = function (config) { + config.set({ + plugins: [ + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-webkit-launcher', + 'karma-esbuild', + 'karma-mocha', + 'karma-mocha-reporter', + ], + + // frameworks to use + // available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter + frameworks: ['mocha'], + + + // list of files / patterns to load in the browser + files: [ + { pattern: 'tests/**/*.spec.ts', watched: false }, + ], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://www.npmjs.com/search?q=keywords:karma-preprocessor + preprocessors: { + 'tests/**/*.spec.ts': ['esbuild'], + }, + + esbuild: esbuildBrowserConfig, + + // list of files / patterns to exclude + exclude: [], + + // test results reporter to use + // available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter + reporters: ['mocha'], + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || + // config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + concurrency: 1, + + // start these browsers + // available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher + browsers: ['ChromeHeadless', 'FirefoxHeadless', 'WebkitHeadless'], + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, + }); +}; diff --git a/packages/web5-agent/package.json b/packages/web5-agent/package.json index 96e911c73..3ef1d25d8 100644 --- a/packages/web5-agent/package.json +++ b/packages/web5-agent/package.json @@ -1,9 +1,44 @@ { "name": "@tbd54566975/web5-agent", "version": "0.1.0", - "main": "", + "description": "Web5 Agent", "type": "module", + "main": "./dist/cjs/main.cjs", + "module": "./dist/esm/main.mjs", "types": "./dist/types/main.d.ts", + "scripts": { + "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", + "lint": "eslint . --ext .js --max-warnings 0", + "lint:fix": "eslint . --ext .js --fix", + "test:node": "rimraf __tests__ && tsc -p tsconfig.test.json && mocha \"__tests__/**/*.spec.js\" --exit", + "test:browser": "karma start karma.conf.cjs" + }, + "homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/web5-agent#readme", + "bugs": "https://github.com/TBD54566975/web5-js/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/TBD54566975/web5-js", + "directory": "packages/web5-agent" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Daniel Buchner", + "url": "https://github.com/csuwildcat" + }, + { + "name": "Frank Hinek", + "url": "https://github.com/frankhinek" + }, + { + "name": "Moe Jangda", + "url": "https://github.com/mistermoe" + } + ], + "files": [ + "dist", + "src" + ], "exports": { ".": { "import": "./dist/esm/main.mjs", @@ -21,10 +56,18 @@ "./dist/cjs/index.js": "./dist/browser.js", "types": "./dist/types/main.d.ts" }, - "scripts": { - "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", - "lint": "eslint . --ext .js --max-warnings 0", - "lint:fix": "eslint . --ext .js --fix" + "keywords": [ + "decentralized", + "decentralized-applications", + "decentralized-identity", + "decentralized-web", + "web5" + ], + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=18.0.0" }, "dependencies": { "readable-stream": "4.4.0", @@ -33,9 +76,23 @@ "devDependencies": { "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", + "@types/chai": "4.3.0", "@types/eslint": "8.37.0", + "@types/mocha": "10.0.1", + "chai": "4.3.7", "esbuild": "0.16.7", "eslint": "8.39.0", + "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", + "mocha": "10.2.0", + "node-stdlib-browser": "1.2.0", + "playwright": "1.31.2", "rimraf": "4.4.0", "typescript": "5.0.4" } diff --git a/packages/web5-agent/tests/needed.spec.ts b/packages/web5-agent/tests/needed.spec.ts new file mode 100644 index 000000000..0d79f4598 --- /dev/null +++ b/packages/web5-agent/tests/needed.spec.ts @@ -0,0 +1,3 @@ +describe('@tbd54566975/web5-agent', () => { + xit('should have tests'); +}); \ No newline at end of file diff --git a/packages/web5-agent/tsconfig.test.json b/packages/web5-agent/tsconfig.test.json new file mode 100644 index 000000000..7e40c3908 --- /dev/null +++ b/packages/web5-agent/tsconfig.test.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "lib": [ + "DOM", + "ES6" + ], + "target": "es6", + "module": "ESNext", // Required for enabling JavaScript import assertion support + "declaration": true, + "declarationMap": true, + "outDir": "__tests__", + "declarationDir": "__tests__/types", + "sourceMap": true, + // `NodeNext` will throw compilation errors if relative import paths are missing file extension + // reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#ecmascript-module-support-in-node-js + "moduleResolution": "NodeNext", + // allows us to import json files + "resolveJsonModule": true, + "esModuleInterop": true + }, + "include": [ + "src", + "tests", + ], + "exclude": [ + "node_modules", + "dist" + ] +} \ No newline at end of file diff --git a/packages/web5-proxy-agent/LICENSE b/packages/web5-proxy-agent/LICENSE new file mode 100644 index 000000000..f49a4e16e --- /dev/null +++ b/packages/web5-proxy-agent/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/web5-proxy-agent/README.md b/packages/web5-proxy-agent/README.md new file mode 100644 index 000000000..65e8a724d --- /dev/null +++ b/packages/web5-proxy-agent/README.md @@ -0,0 +1 @@ +# Web5 Proxy Agent diff --git a/packages/web5-proxy-agent/package.json b/packages/web5-proxy-agent/package.json index d66837038..4aefdadc7 100644 --- a/packages/web5-proxy-agent/package.json +++ b/packages/web5-proxy-agent/package.json @@ -1,10 +1,44 @@ { "name": "@tbd54566975/web5-proxy-agent", - "type": "module", "version": "0.1.0", + "description": "Web5 Proxy Agent", + "type": "module", "main": "./dist/cjs/main.cjs", "module": "./dist/esm/main.mjs", - "types": "./dist/main.d.ts", + "types": "./dist/types/main.d.ts", + "scripts": { + "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", + "lint": "eslint . --ext .js --max-warnings 0", + "lint:fix": "eslint . --ext .js --fix", + "test:node": "rimraf __tests__ && tsc -p tsconfig.test.json && mocha \"__tests__/**/*.spec.js\" --exit", + "test:browser": "karma start karma.conf.cjs" + }, + "homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/web5-proxy-agent#readme", + "bugs": "https://github.com/TBD54566975/web5-js/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/TBD54566975/web5-js", + "directory": "packages/web5-proxy-agent" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Daniel Buchner", + "url": "https://github.com/csuwildcat" + }, + { + "name": "Frank Hinek", + "url": "https://github.com/frankhinek" + }, + { + "name": "Moe Jangda", + "url": "https://github.com/mistermoe" + } + ], + "files": [ + "dist", + "src" + ], "exports": { ".": { "import": "./dist/esm/main.mjs", @@ -22,14 +56,31 @@ "./dist/cjs/index.js": "./dist/browser.js", "types": "./dist/types/main.d.ts" }, + "keywords": [ + "decentralized", + "decentralized-applications", + "decentralized-identity", + "decentralized-web", + "web5" + ], + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=18.0.0" + }, "dependencies": { "@tbd54566975/web5-agent": "0.1.0" }, "devDependencies": { + "@types/chai": "4.3.0", "@types/ed2curve": "0.2.2", "@types/eslint": "8.37.0", + "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", + "chai": "4.3.7", + "chai-as-promised": "7.1.1", "dts-bundle-generator": "^8.0.1", "esbuild": "0.16.7", "eslint": "8.39.0", @@ -46,17 +97,5 @@ "playwright": "1.31.2", "rimraf": "4.4.0", "typescript": "5.0.4" - }, - "files": [ - "dist", - "src" - ], - "scripts": { - "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", - "lint": "eslint . --ext .js --max-warnings 0", - "lint:fix": "eslint . --ext .js --fix", - "publish:unstable": "./build/publish-unstable.sh", - "test:node": "mocha \"tests/**/*.spec.js\" --exit", - "test:browser": "karma start karma.conf.cjs" } } \ No newline at end of file diff --git a/packages/web5-proxy-agent/tests/needed.spec.ts b/packages/web5-proxy-agent/tests/needed.spec.ts new file mode 100644 index 000000000..7747d7cd6 --- /dev/null +++ b/packages/web5-proxy-agent/tests/needed.spec.ts @@ -0,0 +1,3 @@ +describe('@tbd54566975/web5-proxy-agent', () => { + xit('should have tests'); +}); \ No newline at end of file diff --git a/packages/web5-proxy-agent/tsconfig.test.json b/packages/web5-proxy-agent/tsconfig.test.json index 57759b714..7e40c3908 100644 --- a/packages/web5-proxy-agent/tsconfig.test.json +++ b/packages/web5-proxy-agent/tsconfig.test.json @@ -1,6 +1,5 @@ { "compilerOptions": { - "strict": true, "lib": [ "DOM", "ES6" @@ -11,9 +10,12 @@ "declarationMap": true, "outDir": "__tests__", "declarationDir": "__tests__/types", + "sourceMap": true, // `NodeNext` will throw compilation errors if relative import paths are missing file extension // reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#ecmascript-module-support-in-node-js "moduleResolution": "NodeNext", + // allows us to import json files + "resolveJsonModule": true, "esModuleInterop": true }, "include": [ diff --git a/packages/web5-user-agent/LICENSE b/packages/web5-user-agent/LICENSE new file mode 100644 index 000000000..f49a4e16e --- /dev/null +++ b/packages/web5-user-agent/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/web5-user-agent/README.md b/packages/web5-user-agent/README.md new file mode 100644 index 000000000..f7a47b9d1 --- /dev/null +++ b/packages/web5-user-agent/README.md @@ -0,0 +1 @@ +# Web5 User Agent diff --git a/packages/web5-user-agent/package.json b/packages/web5-user-agent/package.json index dee740427..93e99617d 100644 --- a/packages/web5-user-agent/package.json +++ b/packages/web5-user-agent/package.json @@ -1,11 +1,44 @@ { "name": "@tbd54566975/web5-user-agent", "version": "0.1.0", - "description": "SDK for accessing the features and capabilities of Web5", + "description": "Web5 User Agent", "type": "module", "main": "./dist/cjs/main.cjs", "module": "./dist/esm/main.mjs", "types": "./dist/types/main.d.ts", + "scripts": { + "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", + "lint": "eslint . --ext .js --max-warnings 0", + "lint:fix": "eslint . --ext .js --fix", + "test:node": "rimraf __tests__ && tsc -p tsconfig.test.json && mocha \"__tests__/**/*.spec.js\" --exit", + "test:browser": "karma start karma.conf.cjs" + }, + "homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/web5-user-agent#readme", + "bugs": "https://github.com/TBD54566975/web5-js/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/TBD54566975/web5-js", + "directory": "packages/web5-user-agent" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Daniel Buchner", + "url": "https://github.com/csuwildcat" + }, + { + "name": "Frank Hinek", + "url": "https://github.com/frankhinek" + }, + { + "name": "Moe Jangda", + "url": "https://github.com/mistermoe" + } + ], + "files": [ + "dist", + "src" + ], "exports": { ".": { "import": "./dist/esm/main.mjs", @@ -23,34 +56,19 @@ "./dist/cjs/index.js": "./dist/browser.js", "types": "./dist/types/main.d.ts" }, - "files": [ - "dist", - "src" + "keywords": [ + "decentralized", + "decentralized-applications", + "decentralized-identity", + "decentralized-web", + "web5" ], - "scripts": { - "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", - "lint": "eslint . --ext .js --max-warnings 0", - "lint:fix": "eslint . --ext .js --fix", - "publish:unstable": "./build/publish-unstable.sh", - "test:node": "rimraf __tests__ && tsc -p tsconfig.test.json && mocha \"__tests__/**/*.spec.js\" --exit", - "test:browser": "karma start karma.conf.cjs" + "publishConfig": { + "access": "public" }, - "keywords": [], - "author": { - "name": "Daniel Buchner", - "email": "dbuchner@tbd.email" + "engines": { + "node": ">=18.0.0" }, - "contributors": [ - { - "name": "Frank Hinek", - "email": "frankhinek@tbd.email" - }, - { - "name": "Moe Jangda", - "email": "moe@tbd.email" - } - ], - "license": "Apache-2.0", "dependencies": { "@decentralized-identity/ion-tools": "1.0.7", "@tbd54566975/dids": "0.1.0", @@ -63,7 +81,7 @@ "uuid": "9.0.0" }, "devDependencies": { - "@playwright/test": "^1.33.0", + "@playwright/test": "1.33.0", "@types/flat": "5.0.2", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", diff --git a/packages/web5/LICENSE b/packages/web5/LICENSE new file mode 100644 index 000000000..f49a4e16e --- /dev/null +++ b/packages/web5/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/web5/README.md b/packages/web5/README.md new file mode 100644 index 000000000..a5136ec87 --- /dev/null +++ b/packages/web5/README.md @@ -0,0 +1,390 @@ +# Web5 JS SDK + +Making developing with Web5 components at least 5 times easier to work with. + +⚠️ WEB5 JS SDK IS IN A PRE-BETA STATE ⚠️ + +## Introduction + +Web5 consists of the following components: + +- Decentralized Identifiers +- Verifiable Credentials +- DWeb Node personal datastores + +The SDK sets out to gather the most oft used functionality from all three of these +pillar technologies to provide a simple library that is as close to effortless as +possible. + +## Docs + +[API Reference](https://tbd54566975.github.io/web5-js/) + +### **`new Web5([options])`** + +Creates an isolated API object for doing Web5 things, split into three main top-level objects: `did`, `dwn`, and `vc`. + +#### **`options`** + +When creating a `Web5` instance the following options can be provided: + +##### **`dwn`** + +This object contains options related to `web5.dwn`. + +- **`node`** - _`Dwn`_: A customizable `Dwn` instance to use instead of a default one created by `web5.dwn`. This can be used to customize the storage location/structure/etc. of the `Dwn`, how DIDs are resolved, etc.. + +### **`web5.did.create(method, options)`** + +The `create` method under the `did` scope enables generation of DIDs for a supported set of DID Methods. The output is method-specific, and handles things like key generation and assembly of DID Documents that can be published to decentralized DID networks. + +#### **Example** + +```javascript +const myDid = await web5.did.create("ion"); +``` + +### **`web5.did.manager.set(did, parameters)`** + +The package provides a DID manager mechanism that handles interactions with a DID that is being 'managed' by the local code (be it in a web page, agent app, or elsewhere). By adding a DID to the manager, the library ensures that all interactions with that DID, including things like signing and encryption, are handled automatically. + +#### **Example** + +Assuming the `myDid` instance is present from the example above, you would pass the following values to add it to the DID manager: + +```javascript +await web5.did.manager.set(myDid.id, { + connected: true, + endpoint: "app://dwn", //this points to the user's local DWN + keys: { + "#dwn": { + keyPair: myDid.keys.find((key) => key.id === "dwn").keyPair, + }, + }, +}); +``` + +### **`web5.dwn.records.query(target, request)`** + +Method for querying the DWeb Node of a provided `target` DID. + +#### **`request`** + +The query `request` must contain the following: + +- **`author`** - _`string`_: The decentralized identifier of the DID signing the query. This may be the same as the `target` parameter if the target and the signer of the query are the same entity, which is common for an app querying the DWeb Node of its own user. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. + +#### **Example** + +```javascript +const web5 = new Web5(); +const response = await web5.dwn.records.query("did:example:bob", { + author: "did:example:alice", + message: { + filter: { + schema: "https://schema.org/Playlist", + dataFormat: "application/json", + }, + }, +}); + +console.log(response.entries); // logs array of Record class instances +``` + +### **`web5.dwn.records.create(target, request)`** + +Method for writing a record to the DWeb Node of a provided `target` DID. + +#### **`request`** + +The write `request` must contain the following: + +- **`author`** - _`string`_: The decentralized identifier of the DID signing the query. This may be the same as the `target` parameter if the target and the signer of the query are the same entity, which is common for an app querying the DWeb Node of its own user. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. +- **`data`** - _`blob | stream | file`_: The data object of the bytes to be sent. + +#### **Example** + +```javascript +const web5 = new Web5(); +const { record } = await web5.dwn.records.create("did:example:alice", { + author: "did:example:alice", + data: "Hello World!", + message: { + dataFormat: "text/plain", + }, +}); + +console.log(record.data.text()); // logs "Hello World!" in console +``` + +### **`Record` response instances** + +Every modifying method (`create`, `write`, etc.) and query entries return an instance of `Record` class, which is a representation of the Record(s) involved. `Record` class instances have the following properties: + +- **`recordId`** - _`string`_: The unique identifier based on the record entry's composition. Note: all entries across all records are deterministically unique. +- **`descriptor`** - _`object`_: The descriptor object for the constructed DWeb Node message. +- **`data`** - _`object`_: a object with the following convenience methods that read out the data of the record entry in the following formats: + - **`text`** - _`function`_: produces a textual representation of the data. + - **`json`** - _`function`_: if the value is JSON data, this method will return a parsed JSON object. + - **`stream`** - _`function`_: returns the raw stream of bytes for the data. + +### **`web5.dwn.records.write(target, request)`** + +Method for writing a record to the DWeb Node of a provided `target` DID. + +#### **`request`** + +The write `request` must contain the following: + +- **`author`** - _`string`_: The decentralized identifier of the DID signing the query. This may be the same as the `target` parameter if the target and the signer of the query are the same entity, which is common for an app querying the DWeb Node of its own user. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. +- **`data`** - _`blob | stream | file`_: The data object of the bytes to be sent. + +#### **Example** + +For this example we assume we have created the record and are using the output `Record` instance from above to overwrite the data of the record with a subsequent `write`: + +```javascript +const web5 = new Web5(); +const { record } = await web5.dwn.records.write("did:example:alice", { + author: "did:example:alice", + data: "Hello again!", + message: { + recordId: record.recordId, + dataFormat: "text/plain", + }, +}); + +console.log(record.data.text()); // prints "Hello again!" in console +``` + +### **`web5.dwn.records.read(target, request)`** + +Method for writing a record to the DWeb Node of a provided `target` DID. + +#### **`request`** + +The write `request` must contain the following: + +- **`author`** - _`string`_: The decentralized identifier of the DID signing the query. This may be the same as the `target` parameter if the target and the signer of the query are the same entity, which is common for an app querying the DWeb Node of its own user. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. + - **`recordId`** - _`string`_: the required record ID string that identifies the record data you are fetching. + +#### **Example** + +```javascript +const web5 = new Web5(); +const response = await web5.dwn.records.read("did:example:alice", { + author: "did:example:alice", + message: { + recordId: "bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5", + }, +}); +``` + +### **`web5.dwn.records.delete(target, request)`** + +Method for deleting a record in the DWeb Node of a provided `target` DID. + +#### **`request`** + +The delete `request` must contain the following: + +- **`author`** - _`string`_: The decentralized identifier of the DID signing the query. This may be the same as the `target` parameter if the target and the signer of the query are the same entity, which is common for an app querying the DWeb Node of its own user. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. + - **`recordId`** - _`string`_: the required record ID string that identifies the record being deleted. + +#### **Example** + +```javascript +const web5 = new Web5(); +const response = await web5.dwn.records.delete("did:example:alice", { + author: "did:example:alice", + message: { + recordId: "bfw35evr6e54c4cqa4c589h4cq3v7w4nc534c9w7h5", + }, +}); +``` + +### **`web5.dwn.protocols.query(target, request)`** + +Method for querying the protocols that a `target` DID has added configurations for in their DWeb Node. + +#### **`request`** + +The query `request` must contain the following: + +- **`author`** - _`string`_: The decentralized identifier of the DID signing the query. This may be the same as the `target` parameter if the target and the signer of the query are the same entity, which is common for an app querying the DWeb Node of its own user. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. + - **`filter`** - _`object`_: an object that defines a set of properties to filter results. + - **`protocol`** - _`URI string`_: a URI that represents the protocol being queried for. + +#### **Example** + +```javascript +const web5 = new Web5(); +const response = await web5.dwn.protocols.query("did:example:alice", { + author: "did:example:alice", + message: { + filter: { + protocol: "https://decentralized-music.org/protocol", + }, + }, +}); +``` + +### **`web5.dwn.protocols.configure(target, request)`** + +Method for deleting a record in the DWeb Node of a provided `target` DID. + +#### **`request`** + +The configuration `request` must contain the following: + +- **`author`** - _`string`_: The decentralized identifier of the DID signing the query. This may be the same as the `target` parameter if the target and the signer of the query are the same entity, which is common for an app querying the DWeb Node of its own user. +- **`message`** - _`object`_: The properties of the DWeb Node Message Descriptor that will be used to construct a valid DWeb Node message. + - **`protocol`** - _`URI string`_: a URI that represents the protocol being configured via the `definition` object. + - **`definition`** - _`object`_: an object that defines the ruleset that will be applied to the records and activities under the protocol. + - **`labels`** - _`object`_: an object that defines the composition of records that will be used in the `records` tree below. + - **`records`** - _`object`_: a recursive object that defines the structure of an app, including data relationships and constraints on which entities can perform various activities. + +#### **Example** + +```javascript +const web5 = new Web5(); +const response = await web5.dwn.protocols.configure("did:example:alice", { + author: "did:example:alice", + message: { + protocol: "https://decentralized-music.org/protocol", + definition: { + labels: { + playlist: { + schema: "https://decentralized-music.org/protocol/playlist", + dataFormat: ["application/json"], + }, + track: { + schema: "https://decentralized-music.org/protocol/track", + dataFormat: ["application/json"], + }, + audio: { + schema: "https://decentralized-music.org/protocol/audio", + dataFormat: ["audio/aac", "audio/mp4"], + }, + }, + records: { + playlist: {}, + track: { + records: { + audio: {}, + }, + }, + }, + }, + }, +}); +``` + +### **`web5.connect([options])`** + +Enables an app to request connection to a user's local identity app, or generate an in-app DID to represent the user (e.g. if the user does not have an identity app). + +> NOTE: This method **_MUST_** be invoked within the scope of a 'trusted user action', which is something the browser/OS decides. For browsers this is generally some direct user intent, like clicking a link or button. + +#### **`options`** + +The `connect` method optionally accepts an object with the following properties: + +##### **`storage`** + +Used by `connect` to store connection data/keys/etc. for reuse when calling `connect` again (e.g. during another session). + +If provided, `storage` must be an object that has the same methods as [`Storage`](/TBD54566975/web5-js/tree/main/src/storage/Storage.js). + +If not provided, an instance of [`LocalStorage`](/TBD54566975/web5-js/tree/main/src/storage/LocalStorage.js) is used instead. + +##### **`connectionLocation`** + +Controls where in `storage` the connection data is stored. + +Defaults to `'web5-connection'`. + +##### **`keysLocation`** + +Controls where in `storage` the connection keys are stored. + +Defaults to `'web5-keys'`. + +##### **`silent`** + +Controls whether to prompt the user to start a new connection if a connection has not already been established. + +Defaults to `false`. + +#### **Events** + +After calling `connect`, at least one of the following events will be dispatched on the `Web5` instance: + +##### **`'open'`** + +A `'open'` event is dispatched if a local identity app is found, containing a verification pin and port number used for the connection. + +- **`event.detail.pin`** - _`number`_: 1-4 digit numerical code that must be displayed to the user to ensure they are connecting to the desired local identity app. +- **`event.detail.port`** - _`number`_: The port number used by the the local identity app to listen for connections. + +##### **`'connection'`** + +A `'connection'` event is dispatched if the user accepts the connection, containing the DID the user selected in the local identity app. + +- **`event.details.did`** - _`string`_: The DID selected by the user in the local identity app. + +##### **`'close'`** + +A `'close'` event is dispatched if the user refuses to accept or respond to the connection attempt for any reason. + +##### **`'error'`** + +An `'error'` event is dispached if anything goes wrong (e.g. `Web5` was unable to find any local identity apps). + +#### **Example** + +```javascript +document + .querySelector("#connect_button") + .addEventListener("click", async (event) => { + event.preventDefault(); + + const web5 = new Web5(); + + web5.addEventListener("open", (event) => { + const { pin } = event.detail; + document.querySelector("#pin_code_text").textContent = pin; + }); + + web5.addEventListener("connection", (event) => { + const { did } = event.detail; + alert("Connection succeeded! Connected to DID: " + did); + }); + + web5.addEventListener("close", (event) => { + alert("Connection was denied"); + }); + + web5.addEventListener("error", (event) => { + console.error(event); + }); + + web5.connect(); + }); +``` + +## Project Resources + +| Resource | Description | +| ---------------------------------------------- | ----------------------------------------------------------------------------- | +| [CODEOWNERS](../../CODEOWNERS) | Outlines the project lead(s) | +| [CODE_OF_CONDUCT.md](../../CODE_OF_CONDUCT.md) | Expected behavior for project contributors, promoting a welcoming environment | +| [CONTRIBUTING.md](../../CONTRIBUTING.md) | Developer guide to build, test, run, access CI, chat, discuss, file issues | +| [GOVERNANCE.md](../../GOVERNANCE.md) | Project governance | +| [LICENSE](../../LICENSE) | Apache License, Version 2.0 | diff --git a/packages/web5/package.json b/packages/web5/package.json index 0aaa98919..1451a1135 100644 --- a/packages/web5/package.json +++ b/packages/web5/package.json @@ -6,6 +6,39 @@ "main": "./dist/cjs/main.cjs", "module": "./dist/esm/main.mjs", "types": "./dist/types/main.d.ts", + "scripts": { + "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", + "lint": "eslint . --ext .js --max-warnings 0", + "lint:fix": "eslint . --ext .js --fix", + "test:node": "rimraf __tests__ && tsc -p tsconfig.test.json && mocha \"__tests__/**/*.spec.js\" --exit", + "test:browser": "karma start karma.conf.cjs" + }, + "homepage": "https://github.com/TBD54566975/web5-js/tree/main/packages/web5#readme", + "bugs": "https://github.com/TBD54566975/web5-js/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/TBD54566975/web5-js", + "directory": "packages/web5" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Daniel Buchner", + "url": "https://github.com/csuwildcat" + }, + { + "name": "Frank Hinek", + "url": "https://github.com/frankhinek" + }, + { + "name": "Moe Jangda", + "url": "https://github.com/mistermoe" + } + ], + "files": [ + "dist", + "src" + ], "exports": { ".": { "import": "./dist/esm/main.mjs", @@ -23,34 +56,23 @@ "./dist/cjs/index.js": "./dist/browser.js", "types": "./dist/types/main.d.ts" }, - "files": [ - "dist", - "src" + "keywords": [ + "decentralized", + "decentralized-applications", + "decentralized-identity", + "decentralized-web", + "DID", + "sdk", + "verifiable-credentials", + "web5", + "web5-sdk" ], - "scripts": { - "build": "rimraf dist && node build/bundles.js && echo '{\"type\": \"commonjs\"}' > ./dist/cjs/package.json && tsc", - "lint": "eslint . --ext .js --max-warnings 0", - "lint:fix": "eslint . --ext .js --fix", - "publish:unstable": "./build/publish-unstable.sh", - "test:node": "tsc -p tsconfig.test.json && mocha \"__tests__/**/*.spec.js\" --exit", - "test:browser": "karma start karma.conf.cjs" + "publishConfig": { + "access": "public" }, - "keywords": [], - "author": { - "name": "Daniel Buchner", - "email": "dbuchner@tbd.email" + "engines": { + "node": ">=18.0.0" }, - "contributors": [ - { - "name": "Frank Hinek", - "email": "frankhinek@tbd.email" - }, - { - "name": "Moe Jangda", - "email": "moe@tbd.email" - } - ], - "license": "Apache-2.0", "dependencies": { "@decentralized-identity/ion-tools": "1.0.7", "@tbd54566975/crypto": "0.1.0", @@ -66,7 +88,7 @@ }, "devDependencies": { "@types/chai": "4.3.0", - "@types/chai-as-promised": "^7.1.5", + "@types/chai-as-promised": "7.1.5", "@types/ms": "0.7.31", "@typescript-eslint/eslint-plugin": "5.59.0", "@typescript-eslint/parser": "5.59.0", diff --git a/packages/web5/tests/fixtures/protocol-definitions/message.json b/packages/web5/tests/fixtures/protocol-definitions/message.json index 12f46611e..fb512b5e8 100644 --- a/packages/web5/tests/fixtures/protocol-definitions/message.json +++ b/packages/web5/tests/fixtures/protocol-definitions/message.json @@ -1,4 +1,5 @@ { + "protocol": "http://message-protocol.xyz", "types": { "message": { "schema": "https://protocols.xyz/message/schema/message", diff --git a/packages/web5/tsconfig.test.json b/packages/web5/tsconfig.test.json index 3708176a3..7e40c3908 100644 --- a/packages/web5/tsconfig.test.json +++ b/packages/web5/tsconfig.test.json @@ -4,7 +4,7 @@ "DOM", "ES6" ], - "target": "ESNext", + "target": "es6", "module": "ESNext", // Required for enabling JavaScript import assertion support "declaration": true, "declarationMap": true,