Skip to content

Commit 37e2f25

Browse files
authored
Framework update (#2)
* Change to use @digitalbazaar/did-io and upstream changes from @dsnp/did-resolver * Add a demo webapp
1 parent cbcaade commit 37e2f25

30 files changed

+14250
-2073
lines changed

.env.example

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Environment variables for testnet
2-
FREQUENCY_NODE="wss://rpc.rococo.frequency.xyz"
2+
FREQUENCY_NODE="wss://0.rpc.testnet.amplica.io"
33

4-
# If running locally, use this instead
4+
# If running against mainnet
5+
#FREQUENCY_NODE="wss://1.rpc.frequency.xyz"
6+
7+
# If running locally
58
#FREQUENCY_NODE="ws://127.0.0.1:9944"

.github/ISSUE_TEMPLATE/BUG_Issue.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Bug Report
3+
about: Report an issue found in the Frequency Schemas
4+
title: ""
5+
labels: ""
6+
assignees: ""
7+
---
8+
Thanks for reporting an issue!
9+
10+
### Steps to reproduce
11+
Tell us how to reproduce this issue.
12+
13+
### Expected behaviour
14+
Tell us what should happen
15+
16+
### Actual behaviour
17+
Tell us what happens instead
18+
19+
### Any logs, error output, etc?
20+
...
21+
22+
### Any other comments?
23+
...

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Issue Template
4+

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Problem
2+
=======
3+
problem statement
4+
5+
Closes: <!-- GitHub Issue ->
6+
7+
Solution
8+
========
9+
What I/we did to solve this problem
10+
11+
with @pairperson1
12+
13+
Double Checks:
14+
---------------
15+
- [] Did you update the changelog?
16+
- [] Do you have good documentation on exported methods?
17+
18+
Change summary:
19+
---------------
20+
* Tidy, well formulated commit message
21+
* Another great commit message
22+
* Something else I/we did
23+
24+
Steps to Verify:
25+
----------------
26+
1. A setup step / beginning state
27+
1. What to do next
28+
1. Any other instructions
29+
1. Expected behavior
30+
1. Suggestions for testing

.github/workflows/deploy.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Deploy to GitHub Pages
3+
4+
on:
5+
push:
6+
tags:
7+
- 'v[0-9]+.[0-9]+.[0-9]+' # ex. v1.0.0
8+
branches:
9+
- main
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14+
permissions:
15+
contents: read
16+
pages: write
17+
id-token: write
18+
19+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
20+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
21+
concurrency:
22+
group: 'deploy-pages'
23+
cancel-in-progress: false
24+
25+
jobs:
26+
# Build job
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Pages
34+
uses: actions/configure-pages@v4
35+
36+
- name: Install Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: 20
40+
cache: npm
41+
42+
- name: Install dependencies
43+
run: npm install
44+
45+
- name: Build
46+
env:
47+
# Replace with / if deploying to a root domain
48+
BASE_PATH: '/dsnp-did-resolver-frequency'
49+
run: |
50+
npm run build
51+
touch build/.nojekyll
52+
cd demo
53+
npm install
54+
npm run build
55+
56+
- name: Upload artifact
57+
uses: actions/upload-pages-artifact@v3
58+
with:
59+
path: ./demo/build
60+
61+
# Deployment job
62+
deploy:
63+
environment:
64+
name: github-pages
65+
url: ${{ steps.deployment.outputs.page_url }}
66+
runs-on: ubuntu-latest
67+
needs: build
68+
69+
steps:
70+
- name: Deploy to GitHub Pages
71+
id: deployment
72+
uses: actions/deploy-pages@v4

.github/workflows/main.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Tests CI
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
branches: [ '**' ]
7+
jobs:
8+
test:
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Use Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 18
18+
registry-url: 'https://registry.npmjs.org'
19+
cache-dependency-path: package-lock.json
20+
21+
- name: Install 💾
22+
run: npm ci
23+
24+
- name: Lint
25+
run: npm run lint
26+
27+
- name: Test
28+
run: npm run test
29+
30+
- name: Build
31+
run: npm run build
32+
33+
- name: Publish Dry Run
34+
run: npm publish --dry-run
35+
working-directory: dist

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release Package
2+
on:
3+
release:
4+
types: [ released ]
5+
jobs:
6+
publish-to-npm:
7+
runs-on: ubuntu-22.04
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v4
11+
12+
- name: Use Node.js
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: 18
16+
registry-url: 'https://registry.npmjs.org'
17+
cache-dependency-path: package-lock.json
18+
19+
- name: Install 💾
20+
run: npm ci
21+
22+
- name: Build
23+
run: npm run build
24+
25+
- name: Version ⬆️
26+
run: npm version --new-version ${{ github.event.release.tag_name }} --no-git-tag-version
27+
working-directory: dist
28+
29+
- name: Publish 🚂
30+
run: npm publish --tag latest
31+
working-directory: dist
32+
env:
33+
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}

README.md

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,45 +43,41 @@ Summary of options:
4343

4444
See `.env.example` for example configuration.
4545

46-
Here's a full usage example with the DID resolver framework:
46+
Here's a full usage example with the `did-io` DID resolver framework:
4747

4848
```
49-
import { Resolver } from "did-resolver";
50-
import dsnp from "@dsnp/did-resolver";
49+
import { CachedResolver } from "@digitalbazaar/did-io";
50+
import didDsnp from "@dsnp/did-resolver";
51+
import { FrequencyResolver } from "@dsnp/did-resolver-frequency";
5152
5253
const frequencyResolver = new FrequencyResolver({
53-
providerUri: "wss://rpc.rococo.frequency.xyz",
54+
providerUri: "wss://1.rpc.frequency.xyz",
5455
});
5556
56-
const resolver = new Resolver(dsnp.getResolver([frequencyResolver]));
57-
const myDid = "did:dsnp:13972";
58-
const result = await resolver.resolve(myDid);
57+
const resolver = new CachedResolver();
58+
resolver.use(didDsnp.driver([ frequencyResolver ]));
59+
const did = "did:dsnp:123456";
60+
const result = await resolver.get({ did });
5961
console.log(JSON.stringify(result, null, 2));
6062
61-
frequencyResolver.disconnect();
63+
await frequencyResolver.disconnect();
6264
6365
/* Example output:
6466
{
65-
"didResolutionMetadata": {
66-
"contentType": "application/did+ld+json"
67-
},
68-
"didDocument": {
69-
"@context": [
70-
"https://www.w3.org/ns/did/v1"
71-
],
72-
"id": "did:dsnp:13972",
73-
"assertionMethod": [
74-
{
75-
"@context": "https://w3id.org/security/multikey/v1",
76-
"id": "did:dsnp:13972#z6MkuzE4hBVHTmwFff37ZuPQs9sbkdJo8jifN9sZ1jXbgyMp",
77-
"type": "Multikey",
78-
"controller": "did:dsnp:13972",
79-
"publicKeyMultibase": "z6MkuzE4hBVHTmwFff37ZuPQs9sbkdJo8jifN9sZ1jXbgyMp"
80-
}
81-
],
82-
"keyAgreement": []
83-
},
84-
"didDocumentMetadata": {}
67+
"@context": [
68+
"https://www.w3.org/ns/did/v1"
69+
],
70+
"id": "did:dsnp:1",
71+
"assertionMethod": [
72+
{
73+
"@context": "https://w3id.org/security/multikey/v1",
74+
"id": "did:dsnp:1#z6MktEsFq4c5qFZkj3wq5FZDurXLpG1s9gD7oWDZoS8S5F27",
75+
"type": "Multikey",
76+
"controller": "did:dsnp:1",
77+
"publicKeyMultibase": "z6MktEsFq4c5qFZkj3wq5FZDurXLpG1s9gD7oWDZoS8S5F27"
78+
}
79+
],
80+
"keyAgreement": []
8581
}
8682
*/
8783
```
@@ -92,16 +88,19 @@ The example above is provided as a command line script.
9288

9389
```
9490
cp .env.example .env
91+
# uncomment the desired node endpoint
9592
npm run resolve -- 13972
9693
```
9794

9895
# Features
9996

10097
Currently this resolver implements the minimal functionality required to support lookup of public keys by DSNP applications.
10198

102-
- DSNP public keys with `keyType` 1 are listed in the `keyAgreement` array.
103-
- DSNP public keys with `keyType` 2 are listed in the `assertionMethod` array.
99+
- DSNP control keys are listed in the `authentication` array.
100+
- DSNP `keyAgreementPublicKeys` are listed in the `keyAgreement` array.
101+
- DSNP `assertionMethodPublicKeys` are listed in the `assertionMethod` array.
102+
- A user's Frequency handle, if one exists, is noted in the `alsoKnownAs` array with a `did:frqcy:handle:` prefix.
104103

105-
Public keys are encoded using the `Multikey` type.
104+
All public keys are encoded using the `Multikey` type.
106105
The `id` consists of the DSNP DID and a URL fragment that is the same as the `publicKeyMultibase` value, which is a multicodec value in `base58btc` encoding.
107106
The decoded value for `ed25519-pub` keys will be 34 bytes, including the two-byte multicodec identifier.

avro-js.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

demo/.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
node_modules
2+
3+
# Output
4+
.output
5+
.vercel
6+
/.svelte-kit
7+
/build
8+
9+
# OS
10+
.DS_Store
11+
Thumbs.db
12+
13+
# Env
14+
.env
15+
.env.*
16+
!.env.example
17+
!.env.test
18+
19+
# Vite
20+
vite.config.js.timestamp-*
21+
vite.config.ts.timestamp-*

demo/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

demo/.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Package Managers
2+
package-lock.json
3+
pnpm-lock.yaml
4+
yarn.lock

demo/.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"useTabs": true,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"printWidth": 100,
6+
"plugins": ["prettier-plugin-svelte"],
7+
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
8+
}

demo/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# create-svelte
2+
3+
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
4+
5+
## Creating a project
6+
7+
If you're seeing this, you've probably already done this step. Congrats!
8+
9+
```bash
10+
# create a new project in the current directory
11+
npm create svelte@latest
12+
13+
# create a new project in my-app
14+
npm create svelte@latest my-app
15+
```
16+
17+
## Developing
18+
19+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
20+
21+
```bash
22+
npm run dev
23+
24+
# or start the server and open the app in a new browser tab
25+
npm run dev -- --open
26+
```
27+
28+
## Building
29+
30+
To create a production version of your app:
31+
32+
```bash
33+
npm run build
34+
```
35+
36+
You can preview the production build with `npm run preview`.
37+
38+
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.

0 commit comments

Comments
 (0)