diff --git a/api/src/services/documentLoader/context/index.ts b/api/src/services/documentLoader/context/index.ts index ce02592..00d58b9 100644 --- a/api/src/services/documentLoader/context/index.ts +++ b/api/src/services/documentLoader/context/index.ts @@ -1,4 +1,4 @@ -import { statusList2021Context } from "./status-list-2021"; +import { statusList2021Context } from "./status-list-2021.js"; export const contexts = new Map([ ['https://w3id.org/vc/status-list/2021/v1', statusList2021Context] diff --git a/frontend/package-lock.json b/frontend/package-lock.json index bdec954..3fab5d8 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,18 +1,19 @@ { "name": "verifier_frontend", - "version": "1.5.2", + "version": "1.7.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "verifier_frontend", - "version": "1.5.2", + "version": "1.7.4", "license": "AGPL-3.0", "dependencies": { "axios": "^1.1.3", "bootstrap": "^5.2.3", "bootstrap-icons": "^1.9.1", "export-from-json": "^1.7.0", + "jose": "^4.15.4", "jshashes": "^1.0.8", "jsonld": "^8.1.0", "pdfmake": "^0.2.7", @@ -12173,6 +12174,14 @@ "@sideway/pinpoint": "^2.0.0" } }, + "node_modules/jose": { + "version": "4.15.4", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.4.tgz", + "integrity": "sha512-W+oqK4H+r5sITxfxpSU+MMdr/YSWGvgZMQDIsNoBDGGy4i7GBPTtvFKibQzW06n3U3TqHjhvBJsirShsEJ6eeQ==", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, "node_modules/js-beautify": { "version": "1.14.7", "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.14.7.tgz", @@ -27754,6 +27763,11 @@ "@sideway/pinpoint": "^2.0.0" } }, + "jose": { + "version": "4.15.4", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.4.tgz", + "integrity": "sha512-W+oqK4H+r5sITxfxpSU+MMdr/YSWGvgZMQDIsNoBDGGy4i7GBPTtvFKibQzW06n3U3TqHjhvBJsirShsEJ6eeQ==" + }, "js-beautify": { "version": "1.14.7", "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.14.7.tgz", diff --git a/frontend/package.json b/frontend/package.json index 3466c86..e9b47bb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -28,6 +28,7 @@ "bootstrap": "^5.2.3", "bootstrap-icons": "^1.9.1", "export-from-json": "^1.7.0", + "jose": "^4.15.4", "jshashes": "^1.0.8", "jsonld": "^8.1.0", "pdfmake": "^0.2.7", @@ -61,4 +62,4 @@ "sass": "^1.32.7", "sass-loader": "^12.0.0" } -} \ No newline at end of file +} diff --git a/frontend/src/utils.js b/frontend/src/utils.js index f47bb08..f61112b 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -1,5 +1,6 @@ import jsonld from 'jsonld'; import { demoAuthPresentation } from './store/demoAuth'; +import { decodeProtectedHeader } from "jose"; export const VerifiableType = { CREDENTIAL: 'VerifiableCredential', @@ -43,6 +44,19 @@ export function getHolder(presentation) { return proof.verificationMethod.split('#')[0]; } +export function SDJWTtoVP(jwt) { + console.log(jwt) + const decodedHeader = decodeProtectedHeader(jwt) + //const decodedJWT = decodeJwt(jwt) + console.log(decodedHeader) + //console.log(decodedJWT) + return { + jwt, + type: [VerifiableType.PRESENTATION], + holder: decodedHeader.kid.split('#')[0] + } +} + export async function fetchIPFS(IPFSUrl) { var document; diff --git a/frontend/src/views/Entry.vue b/frontend/src/views/Entry.vue index 8e6f52d..80e0dd0 100644 --- a/frontend/src/views/Entry.vue +++ b/frontend/src/views/Entry.vue @@ -77,6 +77,7 @@ <script> import { Tooltip } from "bootstrap"; import { useToast } from "vue-toastification"; +import { SDJWTtoVP } from "../utils.js" import AuthModal from "@/components/AuthModal.vue"; import ScanModal from "@/components/ScanModal.vue" @@ -117,7 +118,7 @@ export default { }) else new Response(file).text().then(text => { - this.$store.dispatch("addVerifiables", [{ jwt: text }]); + this.$store.dispatch("addVerifiables", [SDJWTtoVP(text)]); }) }) diff --git a/frontend/src/views/Verify.vue b/frontend/src/views/Verify.vue index 1f4b4b9..6821931 100644 --- a/frontend/src/views/Verify.vue +++ b/frontend/src/views/Verify.vue @@ -328,6 +328,7 @@ export default { return } catch (error) { + console.log(error) this.toast.error(error.response ? error.response.data : `Something went wrong verifying the credentials!\n${error}`); }