Adding web vc create
This PR adds the web5.vc.create api. This currently uses the agents connected did's key to generate a VC to the subject specified, and returns a signed vcJwt. In the future this will write as a DWN record.
Parameters
/**
* Issues a VC to the subject did
*
* @param issuer The issuer URI of the credential, as a [String].
* @param subject The subject URI of the credential, as a [String].
* @param dataType The type of the credential, as a [String].
* @param data The credential data, as a generic type [T].
* @param expirationDate The expiration date.
* @return A VerifiableCredential JWT.
*/
Usage
vc = new VcApi({ agent: testAgent.agent, connectedDid: identityDid });
const vcJwt = await vc.create(identityDid, identityDid, 'ExampleDataType', {example: 'goodStuff'});
In future PRs I want to have a write to dwn flag, when this is set to true the VcResponse object will be extended with a dwn records object and the vcJwt.
TBDocs Report
🛑 Errors: 0 ⚠️ Warnings: 6
@web5/api
- Project entry file:
packages/api/src/index.ts
| 📄 File: packages/api/src/vc-api.ts |
|---|
⚠️ docs:tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen #L20 |
⚠️ docs:tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen #L21 |
⚠️ docs:tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen #L22 |
⚠️ docs:tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen #L23 |
⚠️ docs:tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen #L24 |
⚠️ docs:tsdoc-undefined-tag: The TSDoc tag "@return" is not defined in this configuration #L25 |
Updated @ 2023-11-14T18:01:42.335Z - Commit: 9e2bc35
Codecov Report
Merging #269 (c20d3bb) into main (2421b28) will decrease coverage by
0.45%. The diff coverage is51.47%.
Additional details and impacted files
@@ Coverage Diff @@
## main #269 +/- ##
==========================================
- Coverage 90.34% 89.90% -0.45%
==========================================
Files 74 75 +1
Lines 14028 14184 +156
Branches 1382 1383 +1
==========================================
+ Hits 12674 12752 +78
- Misses 1328 1406 +78
Partials 26 26
| Components | Coverage Δ | |
|---|---|---|
| api | 95.10% <100.00%> (+0.05%) |
:arrow_up: |
| common | 95.00% <ø> (ø) |
|
| credentials | 94.50% <100.00%> (+<0.01%) |
:arrow_up: |
| crypto | 100.00% <ø> (ø) |
|
| dids | 88.75% <ø> (ø) |
|
| agent | 86.23% <45.21%> (-0.99%) |
:arrow_down: |
| identity-agent | 56.15% <40.00%> (-0.66%) |
:arrow_down: |
| proxy-agent | 58.43% <ø> (ø) |
|
| user-agent | 54.44% <37.50%> (-0.78%) |
:arrow_down: |
Super outdated, closing. Feel free to refresh and reopen.