-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add utopia-ambulance-driver OBv3 example credential #143
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
Open
applesnort
wants to merge
3
commits into
credential-handler:main
Choose a base branch
from
applesnort:feat/utopia-ambulance-driver
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
|
|
||
| const svgPath = path.join(import.meta.dirname, 'badge.svg'); | ||
| const jsonPath = path.join(import.meta.dirname, 'credential.json'); | ||
|
|
||
| const svgContent = fs.readFileSync(svgPath, 'utf8'); | ||
| // put SVG on a single line and remove excess whitespace | ||
| const minifiedSvg = svgContent | ||
| .replace(/\r?\n|\r/g, ' ') | ||
| .replace(/\s{2,}/g, ' ') | ||
| .replace(/>\s+</g, '><') | ||
| .trim(); | ||
|
|
||
| // add the SVG as the `template` value of the first `renderMethod` property | ||
| const json = JSON.parse(fs.readFileSync(jsonPath, 'utf8')); | ||
| json.renderMethod[0].template = minifiedSvg; | ||
| fs.writeFileSync(jsonPath, JSON.stringify(json, null, 2) + '\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "@context": [ | ||
| "https://www.w3.org/ns/credentials/v2", | ||
| "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json", | ||
| "https://w3id.org/vc/render-method/v2rc1" | ||
| ], | ||
| "id": "urn:uuid:f47ac10b-58cc-4372-a567-0e02b2c3d479", | ||
| "type": [ | ||
| "VerifiableCredential", | ||
| "OpenBadgeCredential" | ||
| ], | ||
| "name": "Ambulance Driver Certificate", | ||
| "description": "Utopia Ambulance Driver Certificate.", | ||
| "renderMethod": [ | ||
| { | ||
| "name": "Utopia Ambulance Driver Certificate", | ||
| "type": "SvgRenderingTemplate2024", | ||
| "mediaType": "image/svg+xml", | ||
| "template": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" width=\"512\" height=\"512\"><defs><filter id=\"hexShadow\" x=\"-20%\" y=\"-20%\" width=\"140%\" height=\"140%\"><feDropShadow dx=\"0\" dy=\"4\" stdDeviation=\"8\" flood-color=\"rgba(0,0,0,0.15)\"/></filter><linearGradient id=\"hexGradient\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\"><stop offset=\"0%\" stop-color=\"#ffffff\"/><stop offset=\"100%\" stop-color=\"#f5f8ff\"/></linearGradient></defs><polygon points=\"256,20 472,138 472,374 256,492 40,374 40,138\" fill=\"url(#hexGradient)\" stroke=\"#1e3a8a\" stroke-width=\"4\" filter=\"url(#hexShadow)\"/><polygon points=\"256,50 442,158 442,354 256,462 70,354 70,158\" fill=\"none\" stroke=\"#dc2626\" stroke-width=\"2\" opacity=\"0.55\"/><g transform=\"translate(256, 256)\"><!-- 1. Ambulance icon - 3x (72x72), top y=-135 to y=-63 --><g transform=\"translate(-36, -135) scale(3)\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path stroke=\"#dc2626\" d=\"M 10 10 L 6 10\"/><path stroke=\"#1e3a8a\" d=\"M 14 18 L 14 6 C 14 4.895432 13.104569 4 12 4 L 4 4 C 2.895431 4 2 4.895432 2 6 L 2 17 C 2 17.552284 2.447715 18 3 18 L 5 18\"/><path stroke=\"#1e3a8a\" d=\"M 19 18 L 21 18 C 21.552284 18 22 17.552284 22 17 L 22 13.72 C 21.999674 13.289761 21.724194 12.907955 21.316 12.772 L 19.393 12.131 C 19.141373 12.04696 18.933451 11.866378 18.815001 11.629 L 17.275999 8.553 C 17.106737 8.214271 16.760666 8.000202 16.382 8 L 14 8\"/><path stroke=\"#dc2626\" d=\"M 8 8 L 8 12\"/><path stroke=\"#1e3a8a\" d=\"M 9 18 L 15 18\"/><path stroke=\"#1e3a8a\" d=\"M 19 18 C 19 19.10457 18.10457 20 17 20 C 15.895431 20 15 19.10457 15 18 C 15 16.89543 15.895431 16 17 16 C 18.10457 16 19 16.89543 19 18 Z\"/><path stroke=\"#1e3a8a\" d=\"M 9 18 C 9 19.10457 8.104569 20 7 20 C 5.895431 20 5 19.10457 5 18 C 5 16.89543 5.895431 16 7 16 C 8.104569 16 9 16.89543 9 18 Z\"/></g><!-- 2. UTOPIA DMV - ~40px gap below icon bottom (y=-63) --><text x=\"0\" y=\"-14\" text-anchor=\"middle\" fill=\"#6b7280\" font-family=\"Arial, sans-serif\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"3\"> UTOPIA DMV </text><!-- 3. Holder name - ~40px gap below issuer, in widest part of hex --><text x=\"0\" y=\"50\" text-anchor=\"middle\" fill=\"#1e3a8a\" font-family=\"Arial, sans-serif\" font-size=\"28\" font-weight=\"700\"> {{credentialSubject.name}} </text><!-- 4. AMBULANCE DRIVER - ~40px gap below name --><text x=\"0\" y=\"107\" text-anchor=\"middle\" fill=\"#dc2626\" font-family=\"Arial, sans-serif\" font-size=\"15\" font-weight=\"600\" letter-spacing=\"2.5\"> AMBULANCE DRIVER </text></g></svg>" | ||
| } | ||
| ], | ||
| "issuer": { | ||
| "id": "https://www.utopia-dmv.example", | ||
| "type": [ | ||
| "Profile" | ||
| ], | ||
| "name": "Utopia Department of Motor Vehicles" | ||
| }, | ||
| "validFrom": "2026-01-15T00:00:00Z", | ||
| "validUntil": "2028-01-14T23:59:59Z", | ||
| "credentialSubject": { | ||
| "id": "urn:uuid:c9a6a3b2-1d4e-4f5a-8b6c-7e8f9a0b1c2d", | ||
| "type": "AchievementSubject", | ||
| "name": "Alex Rivera", | ||
| "achievement": { | ||
| "id": "urn:uuid:a1b2c3d4-e5f6-7890-abcd-ef1234567890", | ||
| "type": [ | ||
| "Achievement" | ||
| ], | ||
| "achievementType": "Certificate", | ||
| "name": "Ambulance Driver Certificate", | ||
| "description": "Certifies the holder is authorized to operate an ambulance under applicable motor vehicle laws.", | ||
| "criteria": { | ||
| "narrative": "The holder has completed a certified ambulance driver training program, passed a written knowledge examination, and met all medical fitness requirements as prescribed by applicable state regulations." | ||
| }, | ||
| "image": { | ||
| "id": "https://examples.vcplayground.org/credentials/utopia-ambulance-driver/image.png", | ||
| "type": "Image" | ||
| } | ||
| } | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "web": { | ||
| "VerifiablePresentation": { | ||
| "query": [{ | ||
| "type": "QueryByExample", | ||
| "credentialQuery": [{ | ||
| "reason": "An Ambulance Driver Certificate is required.", | ||
| "example": { | ||
| "@context": [ | ||
| "https://www.w3.org/ns/credentials/v2", | ||
| "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json" | ||
| ], | ||
| "type": "OpenBadgeCredential" | ||
| } | ||
| }] | ||
| }] | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@applesnort cc: @BigBlueHat
We might want to update the image.png file here at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bparth24 because?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the note, Parth. Agreed — I've tracked it as DB-725 (sub-issue of DB-723) so it doesn't get lost. I'll swap in proper artwork once the full EMSA certificate type set is finalized.
Mind dismissing your review so this can merge? Benjamin has already approved.