-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add manifest for BankId credentials and update API endpoints
- Loading branch information
1 parent
81f2051
commit 978e116
Showing
4 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,94 @@ | ||
# KycDataCredential | ||
|
||
```json | ||
{ | ||
"@context": [ | ||
"https://www.w3.org/2018/credentials/v1" | ||
], | ||
"type": [ | ||
"VerifiableCredential", | ||
"KycCredential" | ||
], | ||
"id": "urn:uuid:fd0e0f93-5011-4fa2-9020-fa7da57df947", | ||
"credentialSubject": { | ||
"id": "did:key:z6MkgjsyqQUvtW4wPWKkqffiygdCDathYK1vvpSkxC7qCmqr#z6MkgjsyqQUvtW4wPWKkqffiygdCDathYK1vvpSkxC7qCmqr", | ||
"givenName": "HASSAN MOUSA MOHAMMAD ABUHELWEH", | ||
"surname": "ABUHELWEH", | ||
"verifiedEmail": "[email protected]", | ||
"verifiedPhone": "+971557032203", | ||
"documentNumber": "R301855", | ||
"personalNumber": "R301855", | ||
"birthDate": "1984-10-06", | ||
"expiryDate": "2027-11-15", | ||
"documentType": "P", | ||
"issuingState": "JOR", | ||
"nationality": "Jordan", | ||
"sex": "M", | ||
"faceMatch": 0.8, | ||
"faceLiveness": "Genuine", | ||
"authenticityLiveness": "Genuine", | ||
"documents": [ | ||
{ | ||
"name": "Face", | ||
"url": "" | ||
}, | ||
{ | ||
"name": "document_front", | ||
"url": "" | ||
}, | ||
{ | ||
"name": "document_back", | ||
"url": "" | ||
} | ||
] | ||
}, | ||
"issuer": { | ||
"id": "did:key:z6MkjoRhq1jSNJdLiruSXrFFxagqrztZaXHqHGUTKJbcNywp", | ||
"name": "KYC Provider" | ||
}, | ||
"issuanceDate": "2024-05-13T08:29:25.744750031Z", | ||
"validFrom": "2024-05-13T08:29:25.744775222Z", | ||
"expirationDate": "2025-05-13T08:29:25.744794971Z" | ||
} | ||
``` | ||
|
||
## Manifest | ||
|
||
```json | ||
{ | ||
"claims": { | ||
"Name": "$.credentialSubject.givenName", | ||
"Surname": "$.credentialSubject.surname", | ||
"Email": "$.credentialSubject.verifiedEmail", | ||
"Phone": "$.credentialSubject.verifiedPhone", | ||
"Document Number": "$.credentialSubject.documentNumber", | ||
"Personal Number": "$.credentialSubject.personalNumber", | ||
"Birth Date": "$.credentialSubject.birthDate", | ||
"Expiry Date": "$.credentialSubject.expiryDate", | ||
"Document Type": "$.credentialSubject.documentType", | ||
"Issuing State": "$.credentialSubject.issuingState", | ||
"Nationality": "$.credentialSubject.nationality", | ||
"Sex": "$.credentialSubject.sex", | ||
"Face Match": "$.credentialSubject.faceMatch", | ||
"Face Liveness": "$.credentialSubject.faceLiveness", | ||
"Authenticity Liveness": "$.credentialSubject.authenticityLiveness" | ||
} | ||
} | ||
``` | ||
|
||
## Mapping example | ||
|
||
```json | ||
{ | ||
"id": "<uuid>", | ||
"credentialSubject": { | ||
"id": "<subjectDid>" | ||
}, | ||
"issuer": { | ||
"id": "<issuerDid>" | ||
}, | ||
"issuanceDate": "<timestamp>", | ||
"validFrom": "<timestamp>", | ||
"expirationDate": "<timestamp-in:365d>" | ||
} | ||
``` |
This file contains 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
This file contains 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,58 @@ | ||
import { serverQueryContent } from "#content/server"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
const name = getRouterParam(event, "name"); | ||
if (name === undefined) { | ||
setResponseStatus(event, 400); | ||
return "error: No name set!"; | ||
} | ||
|
||
const contentQuery = await serverQueryContent(event).find(); | ||
|
||
const matchedContent = contentQuery.find((content) => { | ||
return content._path?.startsWith("/credentials/") && content.title === name; | ||
}); | ||
|
||
if (matchedContent === undefined) { | ||
const n = contentQuery | ||
.filter((content) => { | ||
return content.navigation === undefined; | ||
}) | ||
.map((content) => { | ||
return content.title; | ||
}); | ||
|
||
setResponseStatus(event, 400); | ||
return `error: No credential found named: \"${name}\". Available credentials: ${n.join(", ")}`; | ||
} | ||
|
||
const codeblocksAndTitles = matchedContent.body?.children.filter((elem) => { | ||
return (elem.tag === "pre" && elem.props?.language === "json") || elem.tag === "h2"; | ||
}); | ||
|
||
if (!codeblocksAndTitles) { | ||
setResponseStatus(event, 400); | ||
return "error: no-credential"; | ||
} | ||
|
||
let manifestInTitle = false; | ||
for (const codeblockOrTitle of codeblocksAndTitles) { | ||
if ( | ||
codeblockOrTitle.tag === "h2" && | ||
codeblockOrTitle?.children | ||
?.find((c) => c.type === "text") | ||
?.value?.toLowerCase() | ||
?.includes("manifest") === true | ||
) { | ||
manifestInTitle = true; | ||
continue; | ||
} | ||
|
||
if (manifestInTitle && codeblockOrTitle.tag === "pre" && codeblockOrTitle.props?.language === "json") { | ||
return JSON.parse(codeblockOrTitle.props.code); | ||
} | ||
} | ||
|
||
setResponseStatus(event, 400); | ||
return "error: no-mapping"; | ||
}); |