From 985bc492c589a4106b761776bcff04c5885ae858 Mon Sep 17 00:00:00 2001 From: Benjamin Young Date: Mon, 17 Nov 2025 09:55:25 -0500 Subject: [PATCH 1/3] Export `examples` for use in other projects. --- lib/index.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/index.js b/lib/index.js index c9525fa..56ca393 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,9 +2,42 @@ * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved. */ import {fileURLToPath} from 'node:url'; +import fs from 'node:fs/promises'; import path from 'node:path'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); export const contextsDir = path.resolve(__dirname, '..', 'contexts'); export const credentialsDir = path.resolve(__dirname, '..', 'credentials'); + +const entries = await fs.readdir(credentialsDir, {withFileTypes: true}); +const credentialDirs = entries.filter(e => e.isDirectory()).map(d => d.name); + +const credentials = {}; +for(const dirName of credentialDirs) { + const dirPath = path.join(credentialsDir, dirName); + const credentialJsonPath = path.join(dirPath, 'credential.json'); + const queriesJsonPath = path.join(dirPath, 'queries.json'); + + let credential = null; + let queries = null; + + try { + const credText = await fs.readFile(credentialJsonPath, 'utf8'); + credential = JSON.parse(credText); + } catch(e) { + throw new Error(`Failed to read/parse ${credentialJsonPath}: ${e.message}`); + } + + try { + const queriesText = await fs.readFile(queriesJsonPath, 'utf8'); + queries = JSON.parse(queriesText); + } catch(e) { + // if queries.json is missing or invalid, keep as null + queries = null; + } + + credentials[dirName] = {credential, queries}; +} + +export const examples = {credentials}; From 3eb1629d3f573697d286eefb882660023399a0e2 Mon Sep 17 00:00:00 2001 From: Benjamin Young Date: Tue, 25 Nov 2025 11:41:32 -0500 Subject: [PATCH 2/3] Use build instead of publish; add watch. Also fix `repository.url` in package.json. --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b9c9f80..2e35e46 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,9 @@ "scripts": { "check": "node test/safe-mode-check.js", "extract": "node test/safe-mode-check.js extract", - "publish": "eleventy", + "build": "eleventy", "serve": "wrangler pages dev _site/ --compatibility-date=2025-04-02", + "watch": "eleventy --watch", "test": "npm run lint && npm run test-node", "test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 10000 test/*.spec.js", "lint": "eslint ." @@ -33,7 +34,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/credential-handler/vc-examples" + "url": "git+https://github.com/credential-handler/vc-examples.git" }, "engines": { "node": ">=18" From 13b837e4dab9057117cf87ad9e2205e0fe94154e Mon Sep 17 00:00:00 2001 From: Benjamin Young Date: Tue, 25 Nov 2025 11:50:01 -0500 Subject: [PATCH 3/3] Add `credentials/index.json` for remote listing. Useful for projects that want to use the list of VC Examples in their own UX/tooling. --- src/credentials/index.liquid | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/credentials/index.liquid diff --git a/src/credentials/index.liquid b/src/credentials/index.liquid new file mode 100644 index 0000000..a430a5d --- /dev/null +++ b/src/credentials/index.liquid @@ -0,0 +1,14 @@ +--- +layout: false +permalink: credentials/index.json +--- +{ +{% for example in examples %} + {{ example[0] | json }}: { + "credential": "{{ example[0] | append: '/credential.json' }}", + "queries": "{{ example[0] | append: '/queries.json' }}", + "image": "{{ example[0] | append: '/image.png' }}" + } + {% if forloop.last == false %},{% endif %} +{% endfor %} +}