web5-js
web5-js copied to clipboard
Status List Credential Implementation
StatusListCredential
represents a digitally verifiable status list credential according to the W3C Verifiable Credentials Status List v2021.
When a status list is published, the result is a verifiable credential that encapsulates the status list.
Implements status list credential create
and validateCredentialInStatusList
create
/**
* Create a [StatusListCredential] with a specific purpose, e.g., for revocation.
*
* @param statusListCredentialId The id used for the resolvable path to the status list credential [String].
* @param issuer The issuer URI of the credential, as a [String].
* @param statusPurpose The status purpose of the status list cred, eg: revocation, as a [StatusPurpose].
* @param issuedCredentials The credentials to be included in the status list credential, eg: revoked credentials, list of type [VerifiableCredential].
* @returns A special [VerifiableCredential] instance that is a StatusListCredential.
* @throws Error If the status list credential cannot be created.
*
* Example:
* ```
StatusListCredential.create({
statusListCredentialId : 'https://statuslistcred.com/123',
issuer : issuerDid.uri,
statusPurpose : StatusPurpose.REVOCATION,
issuedCredentials : [credWithCredStatus]
})
* ```
*/
validateCredentialInStatusList
/**
* Validates if a given credential is part of the status list represented by a [VerifiableCredential].
*
* @param credentialToValidate The [VerifiableCredential] to be validated against the status list.
* @param statusListCredential The [VerifiableCredential] representing the status list.
* @returns A [Boolean] indicating whether the `credentialToValidate` is part of the status list.
*
* This function checks if the given `credentialToValidate`'s status list index is present in the expanded status list derived from the `statusListCredential`.
*
* Example:
* ```
* const isRevoked = StatusListCredential.validateCredentialInStatusList(credentialToCheck, statusListCred);
* ```
*/
Closes: https://github.com/TBD54566975/web5-js/issues/380
Codecov Report
Merging #448 (eced7f6) into main (eba12e9) will decrease coverage by
0.01%
. Report is 4 commits behind head on main. The diff coverage is92.30%
.
Additional details and impacted files
@@ Coverage Diff @@
## main #448 +/- ##
==========================================
- Coverage 93.35% 93.34% -0.01%
==========================================
Files 80 81 +1
Lines 23831 24083 +252
Branches 1891 1915 +24
==========================================
+ Hits 22247 22481 +234
- Misses 1544 1562 +18
Partials 40 40
Components | Coverage Δ | |
---|---|---|
agent | 88.72% <ø> (ø) |
|
api | 97.30% <ø> (ø) |
|
common | 98.68% <ø> (ø) |
|
credentials | 94.35% <92.30%> (-0.43%) |
:arrow_down: |
crypto | 93.81% <ø> (+<0.01%) |
:arrow_up: |
dids | 97.51% <ø> (ø) |
|
identity-agent | 56.81% <ø> (ø) |
|
crypto-aws-kms | 100.00% <ø> (ø) |
|
proxy-agent | 58.43% <ø> (ø) |
|
user-agent | 55.22% <ø> (ø) |
🦋 Changeset detected
Latest commit: 28614727faa47c444dd167263d499e459dbd50e7
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 | Patch |
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
TBDocs Report
🛑 Errors: 0 ⚠️ Warnings: 1
@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
📄 File: ./packages/credentials/src/status-list-credential.ts |
---|
⚠️ extractor:typedoc:missing-reference : StatusList2021Entry is referenced by VerifiableCredentialCreateOptions.__type.credentialStatus but not included in the documentation. |
TBDocs Report Updated at 2024-05-02T22:52:46Z 2861472
Adding test vectors here https://github.com/TBD54566975/web5-spec/pull/151/files
Codecov Report
Attention: Patch coverage is 93.07692%
with 18 lines
in your changes are missing coverage. Please review.
Project coverage is 90.83%. Comparing base (
1d59f71
) to head (2861472
).
Additional details and impacted files
@@ Coverage Diff @@
## main #448 +/- ##
==========================================
+ Coverage 90.81% 90.83% +0.01%
==========================================
Files 116 117 +1
Lines 29442 29700 +258
Branches 2156 2179 +23
==========================================
+ Hits 26739 26979 +240
- Misses 2668 2686 +18
Partials 35 35
Components | Coverage Δ | |
---|---|---|
agent | 79.90% <ø> (ø) |
|
api | 97.92% <ø> (ø) |
|
common | 98.68% <ø> (ø) |
|
credentials | 94.86% <93.07%> (-0.40%) |
:arrow_down: |
crypto | 93.81% <ø> (ø) |
|
dids | 97.66% <ø> (ø) |
|
identity-agent | 96.70% <ø> (ø) |
|
crypto-aws-kms | 100.00% <ø> (ø) |
|
proxy-agent | 96.70% <ø> (ø) |
|
user-agent | 96.70% <ø> (ø) |
Updated and merged in your updates.