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

Resolution and Validation of VC CredentialSchema #737

Merged
merged 16 commits into from
Jul 19, 2024
Merged

Conversation

nitro-neal
Copy link
Contributor

@nitro-neal nitro-neal commented Jul 2, 2024

Resolution and Validation of VC CredentialSchema

This adds the actual fetch and validation of credentialSchema.

kyc schema hosted here - https://purple-charming-snail-690.mypinata.cloud/ipfs/QmZbPpfPXsp4bFQvQvWRaexCu9Vxmj6qkwWerVfPwY9kQS

credential schema validation example:

      const vc = await VerifiableCredential.create({
        type: 'KnowYourCustomerCred',
        subject: subjectDid.uri,
        issuer: issuerDid.uri,
        issuanceDate: '2023-05-19T08:02:04Z',
        expirationDate: `2055-05-19T08:02:04Z`,
        data: {
          id: subjectDid.uri,
          country_of_residence: 'US',
          tier: 'Tier 1'
        },
        credentialSchema: {
          id: 'https://purple-charming-snail-690.mypinata.cloud/ipfs/QmZbPpfPXsp4bFQvQvWRaexCu9Vxmj6qkwWerVfPwY9kQS',
          type: 'JsonSchema'
        },
        evidence: [
          { kind: 'document_verification', checks: ['passport', 'utility_bill'] },
          { kind: 'sanctions_check', checks: ['daily'] }
        ]
      });

      const vcJwt = await vc.sign({ did: issuerDid });

      await VerifiableCredential.verify({ vcJwt });

This code will now fetch the id in credential schema, and then validate that the credential matches the schema

Copy link

changeset-bot bot commented Jul 2, 2024

🦋 Changeset detected

Latest commit: 8898ff3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@web5/credentials Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jul 2, 2024

TBDocs Report

✅ No errors or warnings

@web5/api

  • Project entry file: packages/api/src/index.ts

@web5/crypto

  • Project entry file: packages/crypto/src/index.ts

@web5/crypto-aws-kms

  • Project entry file: packages/crypto-aws-kms/src/index.ts

@web5/dids

  • Project entry file: packages/dids/src/index.ts

@web5/credentials

  • Project entry file: packages/credentials/src/index.ts

TBDocs Report Updated at 2024-07-19T18:40:49Z 8898ff3

@nitro-neal
Copy link
Contributor Author

resolves #711

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

Attention: Patch coverage is 97.29730% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.80%. Comparing base (57ac130) to head (8898ff3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #737      +/-   ##
==========================================
+ Coverage   92.78%   92.80%   +0.01%     
==========================================
  Files         109      109              
  Lines       29961    29998      +37     
  Branches     2311     2321      +10     
==========================================
+ Hits        27800    27839      +39     
+ Misses       2125     2122       -3     
- Partials       36       37       +1     
Components Coverage Δ
agent 85.22% <ø> (ø)
api 98.99% <ø> (ø)
common 98.68% <ø> (ø)
credentials 94.95% <97.29%> (+0.26%) ⬆️
crypto 93.81% <ø> (ø)
dids 97.77% <ø> (ø)
identity-agent 96.70% <ø> (ø)
crypto-aws-kms 100.00% <ø> (ø)
proxy-agent 96.70% <ø> (ø)
user-agent 96.70% <ø> (ø)

Copy link
Contributor

@thehenrytsai thehenrytsai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for completing this P1 work item!!

🎖️ 🎸

Some comments.

packages/credentials/package.json Outdated Show resolved Hide resolved
packages/credentials/src/validators.ts Show resolved Hide resolved
packages/credentials/tests/ssi-validator.spec.ts Outdated Show resolved Hide resolved
packages/credentials/tests/ssi-validator.spec.ts Outdated Show resolved Hide resolved
packages/credentials/tests/ssi-validator.spec.ts Outdated Show resolved Hide resolved
packages/credentials/tests/ssi-validator.spec.ts Outdated Show resolved Hide resolved
packages/credentials/tests/ssi-validator.spec.ts Outdated Show resolved Hide resolved
packages/credentials/tests/verifiable-credential.spec.ts Outdated Show resolved Hide resolved
packages/credentials/tests/verifiable-credential.spec.ts Outdated Show resolved Hide resolved
packages/credentials/src/validators.ts Show resolved Hide resolved
@frankhinek
Copy link
Contributor

@nitro-neal for awareness: TBD54566975/schemas#1

Copy link
Contributor

@thehenrytsai thehenrytsai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏 💯 🚀

@nitro-neal nitro-neal merged commit 4d01119 into main Jul 19, 2024
35 checks passed
@nitro-neal nitro-neal deleted the cred-schema-impl2 branch July 19, 2024 19:21
@github-actions github-actions bot mentioned this pull request Jul 19, 2024
This was referenced Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants