Skip to content

Commit

Permalink
Add a basic example on DID Resolve
Browse files Browse the repository at this point in the history
sondreb committed Nov 30, 2022
1 parent 21aca86 commit 0a3e1d8
Showing 5 changed files with 95 additions and 9 deletions.
45 changes: 45 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -20,8 +20,10 @@
"@angular/platform-browser": "^14.2.0",
"@angular/platform-browser-dynamic": "^14.2.0",
"@angular/router": "^14.2.0",
"@blockcore/did-resolver": "^0.0.3",
"@blockcore/provider": "^0.0.12",
"bitcoinjs-message": "^2.2.0",
"did-resolver": "^4.0.1",
"rxjs": "~7.5.0",
"stream-browserify": "^3.0.0",
"tslib": "^2.3.0",
39 changes: 30 additions & 9 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -37,6 +37,25 @@
</p>
</div>

<mat-card class="card">
<mat-card-header>
<mat-card-title>DID Resolve (lookup)</mat-card-title>
</mat-card-header>
<mat-card-content>
This sample does not interact with the wallet, but performs an standard DID Resolve using the <a href="https://www.npmjs.com/package/@blockcore/did-resolver" target="_blank">@blockcore/did-resolver</a> library.

<mat-form-field class="input-full-width" appearance="outline">
<mat-label>DID ID</mat-label>
<input matInput type="text" [(ngModel)]="didLookup" />
</mat-form-field>

<p class="long" *ngIf="didLookupResponse">DID Document: {{ didLookupResponse | json }}</p>
</mat-card-content>
<mat-card-actions>
<button mat-flat-button color="primary" (click)="resolveDid()">DID Resolve</button>
</mat-card-actions>
</mat-card>

<div class="actions" *ngIf="provider">
<br />

@@ -107,9 +126,7 @@
<mat-card-title>DID Supported Methods</mat-card-title>
</mat-card-header>
<mat-card-content>
<p *ngIf="didSupportedMethodsResponse">
DID Methods: {{didSupportedMethodsResponse}}
</p>
<p *ngIf="didSupportedMethodsResponse">DID Methods: {{ didSupportedMethodsResponse }}</p>
</mat-card-content>
<mat-card-actions>
<button mat-flat-button color="primary" (click)="didSupportedMethods()">Supported DID Methods</button>
@@ -122,8 +139,9 @@
</mat-card-header>
<mat-card-content>
<p *ngIf="didRequestResponse">
DID: {{didRequestResponse.did}}<br>
Proof: {{didRequestResponse.proof}}<br>
DID: {{ didRequestResponse.did }}<br />
<span class="long">Proof: {{ didRequestResponse.proof }}</span
><br />
</p>
</mat-card-content>
<mat-card-actions>
@@ -157,16 +175,19 @@
</mat-form-field>

<p *ngIf="vcRequestResponse">
DID: {{vcRequestResponse.did}}<br><br>
VC: <span class="long">{{vcRequestResponse.vc}}</span><br>
DID: {{ vcRequestResponse.did }}<br /><br />
VC: <span class="long">{{ vcRequestResponse.vc }}</span
><br />
</p>
</mat-card-content>
<mat-card-actions>
<button mat-flat-button color="primary" (click)="vcRequest()">Send VC Request</button>
<button mat-flat-button color="primary" (click)="vcRequest()">Send VC Request</button>
</mat-card-actions>
</mat-card>



<router-outlet></router-outlet>
</div>
<br>
<br />
</div>
10 changes: 10 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { WebProvider } from '@blockcore/provider';
import * as bitcoinMessage from 'bitcoinjs-message';
const { v4: uuidv4 } = require('uuid');
import { DIDResolutionOptions, Resolver } from 'did-resolver';
import is from '@blockcore/did-resolver';

@Component({
selector: 'app-root',
@@ -187,6 +189,14 @@ export class AppComponent implements OnInit {
}

vcRequestResponse: any;
didLookup = 'did:is:0f254e55a2633d468e92aa7dd5a76c0c9101fab8e282c8c20b3fefde0d68f217';
didLookupResponse: any | undefined;

async resolveDid() {
const isResolver = is.getResolver();
const resolver = new Resolver(isResolver);
this.didLookupResponse = await resolver.resolve(this.didLookup, {});
}

async vcRequest() {
const result = await this.request('vc.request', [
8 changes: 8 additions & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
@@ -17,3 +17,11 @@ body {
padding-left: 1em;
padding-right: 1em;
}

a {
color: white;
}

a:hover {
color: silver;
}

0 comments on commit 0a3e1d8

Please sign in to comment.