web5-js icon indicating copy to clipboard operation
web5-js copied to clipboard

`@web5/agent` Adding `DwnServerInfo` to RPC Clients

Open LiranCohen opened this issue 2 months ago • 3 comments

  • Added a DwnServerInfo HTTP client to get info from the dwn-server's /info endpoint
export type ServerInfo = {
  /** the maximum file size the user can request to store */
  maxFileSize: number,
  /**
   * an array of strings representing the server's registration requirements.
   *
   * ie. ['proof-of-work-sha256-v0', 'terms-of-service']
   * */
  registrationRequirements: string[],
  /** whether web socket support is enabled on this server */
  webSocketSupport: boolean,
}

This is helpful for retrieving registration requirements and whether the server supports sockets.

LiranCohen avatar Apr 11 '24 01:04 LiranCohen

🦋 Changeset detected

Latest commit: 1fbb6b5025971d235f7d2821adda124d001b3930

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

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

changeset-bot[bot] avatar Apr 11 '24 01:04 changeset-bot[bot]

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-05-02T21:24:04Z 1fbb6b5

github-actions[bot] avatar Apr 11 '24 02:04 github-actions[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.03%. Comparing base (1d59f71) to head (1fbb6b5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #489      +/-   ##
==========================================
+ Coverage   90.81%   91.03%   +0.21%     
==========================================
  Files         116      116              
  Lines       29442    29526      +84     
  Branches     2156     2174      +18     
==========================================
+ Hits        26739    26878     +139     
+ Misses       2668     2613      -55     
  Partials       35       35              
Components Coverage Δ
agent 80.62% <100.00%> (+0.72%) :arrow_up:
api 97.92% <ø> (ø)
common 98.68% <ø> (ø)
credentials 95.26% <ø> (ø)
crypto 93.81% <ø> (ø)
dids 97.66% <ø> (ø)
identity-agent 96.70% <ø> (ø)
crypto-aws-kms 100.00% <ø> (ø)
proxy-agent 96.70% <ø> (ø)
user-agent 96.70% <ø> (ø)

codecov-commenter avatar Apr 12 '24 14:04 codecov-commenter

@shamilovtim good call outs on the unnecessary caching implementations. We can add ones if there is a need but I think a memory TTL cache is all that we currently need.

Could the two caches somehow reuse the MemoryStore or LevelStore interfaces? It seems like we've written that same API a handful of time already in web5 SDK

The MemoryStore is simply a map where as the TTLCache has a bit more logic to evict data once a size is hit. I would like to create an issue to create an AsyncTTLCache or something of that nature that would fit an async interface better, effectively a generic version of what DwnServerInfoCacheMemory is doing. We could create that in @web5/common and then replace some of these other wrappers that are just doing the same thing by extending the AsyncTTLCache.

Let me know what you think about the approach and I'll create an issue.

LiranCohen avatar May 02 '24 21:05 LiranCohen