Skip to content

Review js-id usage for NodeId, VaultId, NotificationId, PermId, ClaimId, Gestalts and GenericIdTypes.ts #299

@joshuakarp

Description

@joshuakarp

Specification

The current GenericIdTypes module is slightly out of place within the larger architecture of the js-polykey codebase. We should find some time to review this, and refactor its required implementation to more suitable areas of the codebase. It was originally introduced in order to facilitate usage of the js-id module within Polykey.

Additional context

Tasks

  1. Add some of the encoding wrappers into the IdInternal class, this requires a new PR in js-id. Include toMultibase and toUUID and toBuffer as instance methods, and the fromString, fromMultibase, fromUUID, and fromBuffer as static methods (these represent alternatives of creating the IdInternal). Make sure that these functions return Id as the type and not IdInternal.
  2. Create a new PR for addressing the NodeId changes that fixes Refactor NodeId as a proxy/singleton instance #254 and relates to Review js-id usage for NodeId, VaultId, NotificationId, PermId, ClaimId, Gestalts and GenericIdTypes.ts #299 (this requires more work to be done, not just node id).
  3. This PR will focus on applying the new NodeId which is an opaque alias of Id (which itself is an alias of IdInternal & number).
  4. All the areas which is currently using NodeId is expecting an encoded string. These will need to be changed to expect a sort of type NodeIdEncoded = string;, you still need a nodesUtils.encodeNodeId.
  5. The encoding functions and decoding functions of NodeId should be inside nodes/utils.ts. This should be similar to how I'm doing it for VaultId. An alternative might be to create class extension or generics, but this seems complicated.
  6. Raw usage of the NodeId will mostly occur inside the nodes domain, in particular the NodeGraph can use the Uint8Array directly. Note that the js-db currently doesn't yet allow direct usage of the Id, because it requires a Buffer type. However there is an issue Use bufferWrap to support ArrayBuffer, Uint8Array and Buffer js-db#3 to allow it to eventually take Id, so for now, just use idUtils.toBuffer and idUtils.fromBuffer when interacting with the DB.
  7. Once this PR is merged into master, rebase Introducing vault sharing and the restrictions of pulling and cloning with vault permissions #266 and Extracting Node Connection Management out of NodeManager to NodeConnectionManager #310 on top to benefit from it.
  8. Then the GenericIdTypes.ts can be removed once all other areas of code stop using it.

Metadata

Metadata

Labels

developmentStandard developmentdiscussionRequires discussionenhancementNew feature or requestepicBig issue with multiple subissuesr&d:polykey:core activity 3Peer to Peer Federated Hierarchy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions