atsign-foundation/at_tools

Incorrect handling of public:cached keys in AtKey.fromString()

Closed this issue · 0 comments

Describe the bug

AtKey.fromString() is expecting all cached keys to be in the form of 'cached:@sharedWith:key@sharedBy', which works perfectly fine for shared keys. But incase the key is cached:public, the method is still behaving/responding as if the key is cached shared key.

Steps to reproduce

  1. First I manually constructed a public cached key say 'cached:public:test_key@bob'
  2. Then I pass the previously constructed atKey to AtKey.fromString()
  3. And then an exception is thrown Exception: Exception: atSign public does not start with an "@"
  4. My inference is that the method is assuming 'public' is the sharedWith atsign. And this is an issue because cached:public does not have a sharedWith atsign also public should not be read as an atsign.

Expected behavior

Expected behaviour from AtKey.fromString() for a key 'cached:public:test_key@bob' should be as follows:

  • public keyword in the key should indicate that it is a shared key
  • 'test_key' should be considered as the key
  • '@bob' should be considered the sharedBy atsign
  • sharedWith of this key should be null

Screenshots

No response

Smartphones

  • Device: NA
  • OS: NA
  • Browser NA
  • Version NA

Were you using an atApplication when the bug was found?

No response

Additional context

No response