Skip to content

Commit

Permalink
adding credentialSchema JS (#1408)
Browse files Browse the repository at this point in the history
* adding credentialSchema

* Update site/docs/tbdex/issuer/kcc/kcc-issuer.mdx

Co-authored-by: Angie Jones <[email protected]>

---------

Co-authored-by: Angie Jones <[email protected]>
  • Loading branch information
EbonyLouis and angiejones committed May 1, 2024
1 parent 2ef7f7f commit af1d7bc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 31 deletions.
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` referenced in the `credentialSchema` field must correspond to a valid JSON schema that is hosted on an accessible server.
- 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

0 comments on commit af1d7bc

Please sign in to comment.