diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..845ef76 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,73 @@ +name: Main CI + +on: [push] + +permissions: {} + +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + node-version: [24.x] + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v7 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - name: Run eslint + run: npm run lint + test-karma: + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + node-version: [24.x] + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v7 + with: + node-version: ${{ matrix.node-version }} + - run: | + npm install + cd test + npm install + - name: Run test with Node.js ${{ matrix.node-version }} and Karma + run: | + cd test + npm test + # coverage: + # needs: [test-karma] + # runs-on: ubuntu-latest + # timeout-minutes: 10 + # strategy: + # matrix: + # node-version: [24.x] + # steps: + # - uses: actions/checkout@v7 + # - name: Use Node.js ${{ matrix.node-version }} + # uses: actions/setup-node@v7 + # with: + # node-version: ${{ matrix.node-version }} + # - run: | + # npm install + # cd test + # npm install + # - name: Generate coverage report + # run: | + # cd test + # npm run coverage-ci + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v7 + # with: + # files: ./test/coverage/lcov.info + # fail_ci_if_error: true + # token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f170d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.log +*.sw[nop] +*~ +.nyc_output +.project +.settings +.vscode +TAGS +coverage +node_modules +reports +.cache +dist +package-lock.json +test/package-lock.json \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..e9ee3cb --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +legacy-peer-deps=true \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9557023 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# @digitalbazaar/vc-html-render-method ChangeLog + +## 1.0.0 - 2026-XX-XX + +- Initial release: render Verifiable Credential HTML Render Methods in a + nested, sandboxed iframe (framework-agnostic; the consuming app's CSP is + untouched). +- `HtmlRenderer` render API: a `ready` promise, `resize`/`error`/`loaded` + events, and `destroy()`. +- Selective disclosure (`renderProperty` via `selectJsonLd`), + `renderMethodReady()` over a `MessageChannel`, and `outputPreference.style` + sizing. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..df549c2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2026, Digital Bazaar, Inc. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index e95d598..bf1d0d9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,115 @@ -# bedrock-web-vc-html-renderer -Bedrock library that renders Verifiable Credential HTML Render Methods inside a nested, sandboxed iframe. +# @digitalbazaar/vc-html-render-method + +Render a Verifiable Credential's **HTML Render Method** inside a nested, +sandboxed iframe — framework-agnostic, and without changing the consuming app's +own Content-Security-Policy. + +This library implements the `html` render suite of the +[W3C VC Render Method specification](https://w3c.github.io/vc-render-method/#the-html-render-suite): +an issuer-supplied HTML/CSS/JS template is rendered against a filtered copy of +the credential, fully isolated from the host application. + +## Why a nested iframe? + +- The spec requires the page hosting the template to set a strict CSP +(`frame-src 'none'`). Applying that to a whole application would break other +`