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

Protocol definitions for DwnDidStore, DwnKeyStore and DwnIdentityStore #743

Merged
merged 14 commits into from
Jul 12, 2024

Conversation

LiranCohen
Copy link
Member

@LiranCohen LiranCohen commented Jul 11, 2024

This PR requires DwnDataStore to use a protocol for the storage abstraction. The protocol is initialized when any data is set, the result of the initialization is cached in an in-memory map so that the DWN does not need to query for the installed protocol on each subsequent invocation of set.

This is split into two protocols, identity-store which is used for DwnIdentityStore and DwnDidStore

 {
    protocol  : 'http://identity.foundation/protocols/web5/identity-store',
    published : false,
    types     : {
      portableDid: {
        schema      : 'https://identity.foundation/schemas/web5/portable-did',
        dataFormats : [
          'application/json'
        ]
      },
      identityMetadata: {
        schema      : 'https://identity.foundation/schemas/web5/identity-metadata',
        dataFormats : [
          'application/json'
        ]
      }
    },
    structure: {
      portableDid      : {},
      identityMetadata : {}
    }
  };

And jwk-store which stores the privateJwk for a given key

 {
    protocol  : 'http://identity.foundation/protocols/web5/jwk-store',
    published : false,
    types     : {
      privateJwk: {
        schema      : 'https://identity.foundation/schemas/web5/private-jwk',
        dataFormats : [
          'application/json'
        ]
      },
    },
    structure: {
      privateJwk: {}
    }
  };

There can be improvements with these stores such as using tags instead of the cached index and scanning of all records, but that will be done in a separate PR after delegated/permissioned key functionality is complete.

Copy link

changeset-bot bot commented Jul 11, 2024

🦋 Changeset detected

Latest commit: 9ae5984

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

This PR includes changesets to release 5 packages
Name Type
@web5/agent Minor
@web5/identity-agent Minor
@web5/proxy-agent Minor
@web5/user-agent Minor
@web5/api 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

Copy link
Contributor

github-actions bot commented Jul 11, 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-12T23:01:43Z 9ae5984

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 97.70115% with 4 lines in your changes missing coverage. Please review.

Project coverage is 91.63%. Comparing base (60db3dc) to head (9ae5984).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #743      +/-   ##
==========================================
+ Coverage   90.30%   91.63%   +1.33%     
==========================================
  Files         118      118              
  Lines       30546    30269     -277     
  Branches     2292     2306      +14     
==========================================
+ Hits        27584    27738     +154     
+ Misses       2928     2496     -432     
- Partials       34       35       +1     
Components Coverage Δ
agent 81.99% <97.70%> (+0.24%) ⬆️
api 98.99% <ø> (+16.36%) ⬆️
common 98.68% <ø> (ø)
credentials 94.68% <ø> (ø)
crypto 93.81% <ø> (ø)
dids 97.77% <ø> (ø)
identity-agent 96.70% <ø> (ø)
crypto-aws-kms 100.00% <ø> (ø)
proxy-agent 96.70% <ø> (ø)
user-agent 96.70% <ø> (ø)

@LiranCohen LiranCohen force-pushed the lirancohen/jwk-storage-protocol branch 2 times, most recently from cc27497 to b0140b2 Compare July 12, 2024 18:45
thehenrytsai
thehenrytsai previously approved these changes Jul 12, 2024
Copy link
Member

@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.

Appreciate the PR description, making my first journey into the Store abstractions less treacherous. Code generally looks good, though can't say I understand everything.

I do find a lot of naming problematic, which is probably the source a lot of confusion. e.g.

  • DwnDataStore is a complete reuse of term in dwn-sdk-js but mean different thing.
  • the term "DID", "identify" and "tenant" all smell very similar, I wish there is one lineer documentation describing the intent/purpose of DwnDidStore and DwnIdentityStore.
  • getDataStoreTenant() - at a glance seem so odd having to pass tenant to get tenant. LOL.

@LiranCohen LiranCohen force-pushed the lirancohen/jwk-storage-protocol branch from e0b6c29 to 9ae5984 Compare July 12, 2024 22:58
@LiranCohen LiranCohen merged commit 44604a4 into main Jul 12, 2024
35 checks passed
@LiranCohen LiranCohen deleted the lirancohen/jwk-storage-protocol branch July 12, 2024 23:15
@github-actions github-actions bot mentioned this pull request Jul 12, 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