Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plugin to pull in COSE, JWT, and SD-JWT rendering #241

Merged
merged 15 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
.idea
DS_Store
out.html
48 changes: 24 additions & 24 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta charset="utf-8" />
<title>Securing Verifiable Credentials using JOSE and COSE</title>
<script src="https://www.w3.org/Tools/respec/respec-w3c" class="remove"></script>
<script src="https://cdn.jsdelivr.net/gh/w3c/vc-jose-cose@fix-examples/plugin/dist/main.js"></script>
<script class="remove">
<script src="https://cdn.jsdelivr.net/gh/w3c/vc-jose-cose@2ba03be02a2a96a2362dd25e585ad343e2dd2362/plugin/dist/main.js"></script>
<script type="text/javascript" class="remove">
// See https://github.com/w3c/respec/wiki/ for how to configure
// ReSpec
var respecConfig = {
Expand Down Expand Up @@ -313,8 +313,8 @@ <h2>Securing JSON-LD Verifiable Presentations with JOSE</h2>
],
"type": "VerifiablePresentation",
"verifiableCredential": [{
"@context": ["https://www.w3.org/ns/credentials/v2"],
"type": ["EnvelopedVerifiableCredential"],
"@context": "https://www.w3.org/ns/credentials/v2",
"type": "EnvelopedVerifiableCredential",
"id": "data:application/vc+ld+json+sd-jwt;eyJhbGciOiJFUzM4NCIsImtpZCI6IlVRTV9fblE0UzZCTzhuUTRuT05YeHB4aHRob3lOeGI1M0xZZ1l6LTJBQnMiLCJ0eXAiOiJ2cCtsZCtqc29uK3NkLWp3dCIsImN0eSI6InZwK2xkK2pzb24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54Z0hEcE5oekZlQyIsInkiOiJMQnhVYnBVdFNGMVVKVTVpYnJIdkpINjBUSG5YMk1xa0xHZGltU1l0UGR4RlkxOEdhcldiS3FZV0djUkZHVE9BIn19fQ.kYD63YtBNYnLUTw6Szf1vs_Ug3UBXhPwCyqpNmPnPDa3rXZQhQLdB1BgaoO8zgQ-c3B41fxaXMnLHYV9-B20uboSpJP0B-2Vre917eQt1cSDswDGA_Ytvn4BSqYVBB2J~WyJFMkFsRzhsY2p0QVFrcllIbjlIbnVRIiwgInR5cGUiLCAiVmVyaWZpYWJsZVByZXNlbnRhdGlvbiJd~WyI5NldYMDRneno4cVZzOVZLU2wwYTVnIiwgImlkIiwgImh0dHA6Ly91bml2ZXJzaXR5LmV4YW1wbGUvY3JlZGVudGlhbHMvMTg3MiJd~WyJaekU2VFVaamtHMW1DWXBKMEhnc0l3IiwgInR5cGUiLCBbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwgIkV4YW1wbGVBbHVtbmlDcmVkZW50aWFsIl1d~WyItQ3NsS25GZGFYb2JiQWsyU0JBVGR3IiwgImlkIiwgImRpZDpleGFtcGxlOmViZmViMWY3MTJlYmM2ZjFjMjc2ZTEyZWMyMSJd~WyJuRm1OWl9IczB3WWNoOFdkeTdnQUNRIiwgImlkIiwgImRpZDpleGFtcGxlOmMyNzZlMTJlYzIxZWJmZWIxZjcxMmViYzZmMSJd"
}]
}
Expand Down Expand Up @@ -1722,27 +1722,27 @@ <h2>

<pre class="example vc-jose-cose" title="Presentation">
{
"@context": ["https://www.w3.org/ns/credentials/v2"],
"type": ["VerifiablePresentation"],
"holder": "urn:ietf:params:oauth:jwk-thumbprint:sha-256:_Fpfe27AuGmEljZE9s2lw2UH-qrZLRFNrWbJrWIe4SI",
"verifiableCredential": [{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"type": [
"VerifiableCredential"
],
"issuer": "https://issuer.example/issuers/68",
"validFrom": "2023-06-07T21:14:14.148Z",
"credentialSubject": {
"id": "https://subject.vendor.example"
}
"@context": [
"https://www.w3.org/ns/credentials/v2",
"https://www.w3.org/ns/credentials/examples/v2"
],
"type": "VerifiablePresentation",
"verifiableCredential": [
{
"@context": "https://www.w3.org/ns/credentials/v2",
"id": "data:application/vc+ld+json+cose;base64url,QzVjV...RMjU",
"type": "EnvelopedVerifiableCredential"
},
"https://vendor.example/credentials/42",
"did:example:123",
"urn:uuid:01ec9426-c175-4e39-a006-d30050e28214",
"urn:ietf:params:oauth:jwk-thumbprint:sha-256:_Fpfe27AuGmEljZE9s2lw2UH-qrZLRFNrWbJrWIe4SI",
"data:application/vc+ld+json+sd-jwt;eyJhbGciOiJFUzM4NCIsImtpZCI6IlNJM1JITm91aDhvODFOT09OUFFVQUw3RWdaLWtJNl94ajlvUkV2WDF4T3ciLCJ0eXAiOiJ2YytsZCtqc29uK3NkLWp3dCIsImN0eSI6InZjK2xkK2pzb24ifQ.eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvdjIiLCJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvZXhhbXBsZXMvdjIiXSwiaXNzdWVyIjoiaHR0cHM6Ly91bml2ZXJzaXR5LmV4YW1wbGUvaXNzdWVycy81NjUwNDkiLCJ2YWxpZEZyb20iOiIyMDEwLTAxLTAxVDE5OjIzOjI0WiIsImNyZWRlbnRpYWxTY2hlbWEiOnsiX3NkIjpbIkU3dU1sSWFyS29iYXJTdEZGRjctZm5qaV9sQVdnM3BGMkV5dVc4dWFYakUiLCJYelRaSVgyNGdDSWxSQVFHclFoNU5FRm1XWkQtZ3Z3dkIybzB5Y0FwNFZzIl19LCJjcmVkZW50aWFsU3ViamVjdCI6eyJkZWdyZWUiOnsibmFtZSI6IkJhY2hlbG9yIG9mIFNjaWVuY2UgYW5kIEFydHMiLCJfc2QiOlsiT3oxUEZIMG0tWk9TdEhwUVZyeGlmVlpKRzhvNmlQQmNnLVZ2SXQwd2plcyJdfSwiX3Nk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1ZERFp5X0RvYVFBIiwgInR5cGUiLCAiSnNvblNjaGVtYSJd~WyJuSnJlU3E1Nzg3RGZMSDJCbU03cXFRIiwgImlkIiwgImRpZDpleGFtcGxlOjEyMyJd~WyIxMjNNd3hNcHRiek02YUk2aW03ME1RIiwgInR5cGUiLCAiQmFjaGVsb3JEZWdyZWUiXQ"
{
"@context": "https://www.w3.org/ns/credentials/v2",
"id": "data:application/vc+ld+json+jwt;eyVjV...RMjU",
"type": "EnvelopedVerifiableCredential"
},
{
"@context": "https://www.w3.org/ns/credentials/v2",
"id": "data:application/vc+ld+json+sd-jwt;eyVjV...RMjU",
"type": "EnvelopedVerifiableCredential"
}
]
}
</pre>
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Verifiable Credential Service Worker Plugin for ReSpec

But with support for v2, and no JSON-LD processing.
Builds upon [respec-vc](https://github.com/w3c/respec-vc), but with support for v2, and no JSON-LD processing.
decentralgabe marked this conversation as resolved.
Show resolved Hide resolved

# Usage

To use this extension, add the `respec-plugins` directory to your spec,
then configure respect to use the worker to post process like so:
then configure ReSpec to use the worker to post-process like so:

```html
<head>
<title>Respec Service Worker Plugin Test</title>
<title>ReSpec Service Worker Plugin Test</title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8' />
<script src='https://www.w3.org/Tools/respec/respec-w3c' class='remove'></script>
<script src="https://cdn.jsdelivr.net/gh/w3c/vc-jose-cose/plugin/dist/main.js"></script>
Expand Down
12 changes: 4 additions & 8 deletions plugin/src/sdJwt.js → plugin/attic/sd-jwt/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import yaml from 'yaml'
import moment from 'moment';
import SD from '@transmute/vc-jwt-sd'
import { base64url, calculateJwkThumbprint } from 'jose';
import {base64url, calculateJwkThumbprint} from 'jose';

const digestName = 'sha-256'

Expand All @@ -12,8 +11,7 @@ const isVP = (json) => json.type.includes('VerifiablePresentation')
const salter = () => {
const array = new Uint8Array(16);
crypto.getRandomValues(array);
const encoded = base64url.encode(array);
return encoded
return base64url.encode(array)
}

const digester = {
Expand All @@ -26,8 +24,7 @@ const digester = {
}

export const generateIssuerClaims = (example)=> {
const generatedClaimsYaml = yaml.stringify(example).replace(/id\: /g, '!sd id: ').replace(/type\:/g, '!sd type:')
return generatedClaimsYaml
return yaml.stringify(example).replace(/id\: /g, '!sd id: ').replace(/type\:/g, '!sd type:')
}

export const generateHolderDisclosure = (example) => {
Expand All @@ -37,8 +34,7 @@ export const generateHolderDisclosure = (example) => {
// disclose types
const edited2 = edited1.replace(/\!sd type\:/g, `type:`)
// redact remaining ids
const edited3 = edited2.replace(/\!sd id\:/g, `id:`)
return edited3
return edited2.replace(/\!sd id\:/g, `id:`)
}

export const getExampleMetadata = async ({ alg, json }) => {
Expand Down
Loading
Loading