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

adding credentialSchema JS #1408

Merged
merged 4 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
53 changes: 32 additions & 21 deletions site/docs/tbdex/issuer/kcc/kcc-issuer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ customer’s verified country of residence (ex: US)
- `tier`: The tier your customer falls into,
assuming you perform tier-based KYC.

- `credentialSchema`: Schema used to define the shape of the credential including its required fields.

- `evidence`: Is an Array of objects, where each object contains `kind` (String) and `checks` (array of Strings). `kind` states the **type** of evidence and `checks` details the specific proofs or checks used during IDV.

:::info
Expand Down Expand Up @@ -398,7 +400,8 @@ Before issuing a Known Customer Credential, it's important to complete all neces
/>

:::info
Signing will return a VC [JSON Web Token](https://jwt.io/), which is ideal for secure transmission of the credential.
- The `id` within the `credentialSchema` field needs to correspond to a real JSON schema that is hosted somewhere. This is essential for the validation process, ensuring the credential conforms to the specified schema.
EbonyLouis marked this conversation as resolved.
Show resolved Hide resolved
- Signing will return a VC [JSON Web Token](https://jwt.io/), which is ideal for secure transmission of the credential.
:::

To convert the signed VC JWT into a `VerifiableCredential` object you can use the [`parseJwt()` method](/docs/web5/build/verifiable-credentials/jwt-to-vc#decoding-jwt). Here is what your decoded **Known Customer Credential** would look like:
Expand All @@ -416,21 +419,25 @@ To convert the signed VC JWT into a `VerifiableCredential` object you can use th
"issuer": "did:dht:z6Mkn4w6nSaWe4fjNJRvaHZwFnMm5VexvjzDeozEu2G7jC34",
"issuanceDate": "2024-05-29T19:23:24Z",
"expirationDate": "2026-05-19T08:02:04Z",
"credentialSubject": {
"id": "did:dht:z6MkjGSeekPGE9QfczHWyW8v2ZzJU68kqSHzV7L2dmQyuyDu",
"country_of_residence": "US",
"tier": "Gold"
},
"credentialSchema": {
id: "https://schema.org/PFI",
type: "JsonSchema"
},
"evidence": [
{
kind: "document_verification",
checks: ["passport", "utility_bill"]
"kind": "document_verification",
"checks": ["passport", "utility_bill"]
},
{
kind: "sanction_screening",
checks: ["PEP"]
"kind": "sanction_screening",
"checks": ["PEP"]
}
],
"credentialSubject": {
"id": "did:dht:z6MkjGSeekPGE9QfczHWyW8v2ZzJU68kqSHzV7L2dmQyuyDu",
"country_of_residence": "US",
"tier": "Gold"
}
]
}
}
```
Expand All @@ -450,21 +457,25 @@ To convert the signed VC JWT into a `VerifiableCredential` object you can use th
"issuer": "did:dht:z6Mkn4w6nSaWe4fjNJRvaHZwFnMm5VexvjzDeozEu2G7jC34",
"issuanceDate": "2024-01-01T19:23:24Z",
"expirationDate": "2026-05-19T08:02:04Z",
"credentialSubject": {
"id": "did:dht:z6MkjGSeekPGE9QfczHWyW8v2ZzJU68kqSHzV7L2dmQyuyDu",
"country_of_residence": "US",
"tier": "Gold"
},
"credentialSchema": {
id: "https://schema.org/PFI",
type: "JsonSchema"
},
"evidence": [
{
kind: "document_verification",
checks: ["passport", "utility_bill"]
"kind": "document_verification",
"checks": ["passport", "utility_bill"]
},
{
kind: "sanction_screening",
checks: ["PEP"]
"kind": "sanction_screening",
"checks": ["PEP"]
}
],
"credentialSubject": {
"id": "did:dht:z6MkjGSeekPGE9QfczHWyW8v2ZzJU68kqSHzV7L2dmQyuyDu",
"country_of_residence": "US",
"tier": "Gold"
}
]
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,12 @@ app.post('/token', async (req, res) => {

// :snippet-start: KnownCustomerCredentialsClass
class KccCredential {
constructor(country, tier, evidence) {
constructor(country, tier, credentialSchema, evidence) {
this.data = {
country_of_residence: country,
tier: tier, // optional
};
this.credentialSchema = credentialSchema;
this.evidence = evidence; // optional
}
}
Expand Down Expand Up @@ -418,16 +419,21 @@ app.post('/credentials', async (req, res) => {
/***********************************************
* Create and sign the credential
************************************************/
const kccCredentialInstance = new KccCredential('US', 'Gold', [
{
kind: 'document_verification',
checks: ['passport', 'utility_bill'],
const kccCredentialInstance = new KccCredential('US', 'Gold', {
id: "https://schema.org/PFI",
type: "JsonSchema"
},
{
kind: 'sanction_screening',
checks: ['PEP'],
},
]);
[
{
kind: 'document_verification',
checks: ['passport', 'utility_bill'],
},
{
kind: 'sanction_screening',
checks: ['PEP'],
},
]
);

const known_customer_credential = await VerifiableCredential.create({
type: 'KnownCustomerCredential',
Expand All @@ -438,6 +444,7 @@ app.post('/credentials', async (req, res) => {
country_of_residence: kccCredentialInstance.data.country_of_residence,
tier: kccCredentialInstance.data.tier, // optional
},
credentialSchema: kccCredentialInstance.credentialSchema,
evidence: kccCredentialInstance.evidence, // optional
});

Expand Down
Loading