Skip to content

Commit

Permalink
Merge branch 'main' into verifiable-presentation-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
nitro-neal committed Feb 14, 2024
2 parents 6c0127d + 69e5380 commit 720eff6
Show file tree
Hide file tree
Showing 160 changed files with 17,678 additions and 8,229 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '28 12 * * 3'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
language: [ 'javascript-typescript' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@0b21cf2492b6b02c465a3e5d7c473717ad7721ba #v3.23.1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@0b21cf2492b6b02c465a3e5d7c473717ad7721ba #v3.23.1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@0b21cf2492b6b02c465a3e5d7c473717ad7721ba #v3.23.1
with:
category: "/language:${{matrix.language}}"
20 changes: 17 additions & 3 deletions .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: 'npm'
cache: "npm"

- name: Install dependencies
run: npm ci
Expand All @@ -38,10 +38,24 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
report_changed_scope_only: false
fail_on_error: false
group_docs: true
entry_points: |
- file: packages/api/src/index.ts
docsReporter: api-extractor
docsGenerator: typedoc-markdown
docsReporter: typedoc
docsGenerator: typedoc-html
readmeFile: packages/api/README.md
- file: packages/crypto/src/index.ts
docsReporter: typedoc
docsGenerator: typedoc-html
readmeFile: packages/crypto/README.md
- file: packages/crypto-aws-kms/src/index.ts
docsReporter: typedoc
docsGenerator: typedoc-html
readmeFile: packages/crypto-aws-kms/README.md
- file: packages/dids/src/index.ts
docsReporter: typedoc
docsGenerator: typedoc-html
readmeFile: packages/dids/README.md
- name: Save Artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 #v3.1.3
Expand Down
47 changes: 33 additions & 14 deletions .github/workflows/docs-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,40 @@ jobs:
- 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
echo "Select from the menu on the left to view API reference documentation." >> README-docs.md
npx jsdoc -c jsdoc.json
curl -o docs/favicon.ico https://developer.tbd.website/img/favicon.ico
- name: Build all workspace packages
run: npm run build

- name: TBDocs Reporter
id: tbdocs-reporter-protocol
uses: TBD54566975/tbdocs@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_error: true
group_docs: true
entry_points: |
- file: packages/api/src/index.ts
docsReporter: typedoc
docsGenerator: typedoc-html
readmeFile: packages/api/README.md
- file: packages/crypto/src/index.ts
docsReporter: typedoc
docsGenerator: typedoc-html
readmeFile: packages/crypto/README.md
- file: packages/crypto-aws-kms/src/index.ts
docsReporter: typedoc
docsGenerator: typedoc-html
readmeFile: packages/crypto-aws-kms/README.md
- file: packages/dids/src/index.ts
docsReporter: typedoc
docsGenerator: typedoc-html
readmeFile: packages/dids/README.md
- name: Upload documentation artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 #v3.1.3
with:
name: jsdoc
path: ./docs
name: tbdocs-output
path: ./.tbdocs

deploy:
# Add a dependency to the build job
Expand All @@ -77,16 +96,16 @@ jobs:
- name: Setup Pages
uses: actions/configure-pages@v3

- name: Download JSDoc artifacts
- name: Download TBDocs Artifacts
uses: actions/download-artifact@v3
with:
name: jsdoc
path: ./docs
name: tbdocs-output
path: ./tbdocs

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: "./docs"
path: "./tbdocs/docs"

- name: Deploy to GitHub Pages
id: deployment
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
submodules: true

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
Expand All @@ -44,7 +46,7 @@ jobs:
run: npm ci

- name: Build all workspace packages
run: npm run build
run: npm run build:esm --ws && npm run build:cjs --ws

- name: Run linter for all packages
run: npm run lint --ws
Expand Down Expand Up @@ -81,9 +83,9 @@ jobs:
app-id: ${{ secrets.CICD_ROBOT_GITHUB_APP_ID }}
private-key: ${{ secrets.CICD_ROBOT_GITHUB_APP_PRIVATE_KEY }}
owner: TBD54566975
repositories: sdk-development
repositories: sdk-report-runner

- name: Trigger sdk-development report build
- name: Trigger sdk-report-runner report build
if: github.ref == 'refs/heads/main'
run: |
curl -L \
Expand All @@ -92,27 +94,29 @@ jobs:
-H "Content-Type: application/json" \
--fail \
--data '{"ref": "main"}' \
https://api.github.com/repos/TBD54566975/sdk-development/actions/workflows/build-report.yaml/dispatches
https://api.github.com/repos/TBD54566975/sdk-report-runner/actions/workflows/build-report.yaml/dispatches
env:
APP_TOKEN: ${{ steps.generate_token.outputs.token }}

test-with-browsers:
name: test-with-browsers (group ${{ matrix.group }})
# Run browser tests using macOS so that WebKit tests don't fail under a Linux environment
runs-on: macos-latest
runs-on: macos-14
strategy:
# parallelism strategy: agent takes as long as roughly all other pkgs combined.
matrix:
include:
- group: "A"
packages: "--workspace packages/agent"
- group: "B"
packages: "--workspace packages/crypto --workspace packages/dids --workspace packages/proxy-agent --workspace packages/identity-agent --workspace packages/user-agent"
packages: "--workspace packages/credentials --workspace packages/crypto --workspace packages/dids --workspace packages/proxy-agent --workspace packages/identity-agent --workspace packages/user-agent"
- group: "C"
packages: "--workspace packages/api --workspace packages/common --workspace packages/credentials"
packages: "--workspace packages/api --workspace packages/common"
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
submodules: true

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
Expand All @@ -127,7 +131,7 @@ jobs:
- name: Get Playwright Version (for cache)
id: get-playwright-version
run: |
PLAYWRIGHT_VERSION=$(npm view @playwright/test version)
PLAYWRIGHT_VERSION=$(npm ls @playwright/test --workspace=./packages/api | grep '@playwright/test' | awk 'NR==1{print $2}')
echo "Playwright Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,7 @@ dist
# IntelliJ
.idea

results.xml
results.xml

.tbdocs
temp
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "web5-spec"]
path = web5-spec
url = https://github.com/TBD54566975/web5-spec
22 changes: 21 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ to your valuable work:
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
[this beginner's guide to squashing commits](https://medium.com/@slamflipstrom/a-beginners-guide-to-squashing-commits-with-git-rebase-8185cf6e62ec)
[this beginner's guide to squashing commits](https://medium.com/@slamflipstrom/a-beginners-guide-to-squashing-commits-with-git-rebase-8185cf6e62ec)
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.
Expand Down Expand Up @@ -134,6 +134,26 @@ To maintain the robustness and reliability of the codebase, we highly value test
[Discord](https://discord.com/channels/937858703112155166/969272658501976117)
channel.

### Documentation Generator

We are using [tbdocs](https://github.com/TBD54566975/tbdocs) to check, generate and publish our SDK API Reference docs automatically to GH Pages.

To see if the docs are being generated properly without errors, and to preview the generated docs locally execute the following script:

```sh
./scripts/tbdocs-check-local.sh

# to see if there are any doc errors
open .tbdocs/docs-report.md

# to serve the generated docs locally using a static server (e.g. `npm i -g http-server`)
http-server .tbdocs/docs
```

The errors can be found at `./tbdocs/summary.md`

_PS: You need to have docker installed on your computer._

### Project Versioning Guidelines

This section provides guidelines for versioning Web5 JS packages. All releases are published to the
Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ Interested in contributing instantly? You can make your updates directly without

[![Button to click and edit code in CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/github/TBD54566975/web5-js/main)


## Prerequisites

### Cloning
This repository uses git submodules. To clone this repo with submodules
```sh
git clone --recurse-submodules [email protected]:TBD54566975/web5-js.git
```
Or to add submodules after cloning
```sh
git submodule update --init
```
We recommend this config which will only checkout the files relevant to web5-js
```sh
git -C web5-spec sparse-checkout set test-vectors
```

## Installation

_NPM_
Expand Down Expand Up @@ -177,6 +194,10 @@ Each `Record` instance has the following instance methods:
- **`text`** - _`function`_: returns the data as a string.
- **`send`** - _`function`_: sends the record the instance represents to the DWeb Node endpoints of a provided DID.
- **`update`** - _`function`_: takes in a new request object matching the expected method signature of a `write` and overwrites the record. This is a convenience method that allows you to easily overwrite records with less verbosity.
- **`store`** - _`function`_: stores the record in the local DWN instance, offering the following options:
- `import`: imports the record as with an owner-signed override (still subject to Protocol rules, when a record is Protocol-based)
- **`import`** - _`function`_: signs a record with an owner override to import the record into the local DWN instance:
- `store` - _`boolean`_: when false is passed, the record will only be signed with an owner override, not stored in the local DWN instance. Defaults to `true`.

### **`web5.dwn.records.query(request)`**

Expand Down Expand Up @@ -477,6 +498,24 @@ The `create` method under the `did` object enables generation of DIDs for a supp
const myDid = await Web5.did.create("ion");
```

## Working with the `web5-spec` submodule

### Pulling
You may need to update the `web5-spec` submodule after pulling.
```sh
git pull
git submodule update
```

### Pushing
If you have made changes to the `web5-spec` submodule, you should push your changes to the `web5-spec` remote as well as pushing changes to `web5-js`.
```sh
cd web5-spec
git push
cd ..
git push
```

## Project Resources

| Resource | Description |
Expand Down
Loading

0 comments on commit 720eff6

Please sign in to comment.