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

feat: add capabilities #231

Merged
merged 1 commit into from
Aug 31, 2023
Merged

feat: add capabilities #231

merged 1 commit into from
Aug 31, 2023

Conversation

gmaclennan
Copy link
Member

@gmaclennan gmaclennan commented Aug 28, 2023

Implements #189

More complete tests are blocked by the ability to invite and sync devices, tracking that in #238

This PR adds an internal this.#capabilities instance to the MapeoProject instance. It's initial use will be for assigning roles (part of the invite process) and for checking capabilities for sync when syncing with other devices. Checking capabilities for reading/writing mapeo docs is post-MVP. Also need to expose in the API, tracking that in #239

Post-MVP we will implement the ability have custom roles and capabilities, but hard-coding is ok for now.

@gmaclennan gmaclennan self-assigned this Aug 28, 2023
@gmaclennan gmaclennan force-pushed the feat/core-ownership-writes branch from 8b647a1 to f7b5703 Compare August 30, 2023 15:17
Base automatically changed from feat/core-ownership-writes to main August 30, 2023 15:58
@gmaclennan gmaclennan force-pushed the feat/capabilities branch 2 times, most recently from d56f73a to a591214 Compare August 31, 2023 11:40
@gmaclennan gmaclennan changed the title [WIP] feat: add capabilities feat: add capabilities Aug 31, 2023
@gmaclennan gmaclennan marked this pull request as ready for review August 31, 2023 11:53
@gmaclennan gmaclennan requested a review from achou11 August 31, 2023 11:53
Copy link
Member

@achou11 achou11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of questions but nothing truly blocking. good stuff!

Comment on lines +174 to +175
const isAssigningProjectCreatorRole =
authCoreId === this.#projectCreatorAuthCoreId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somewhat of a nit but initially read this as assigning a role called project creator

Suggested change
const isAssigningProjectCreatorRole =
authCoreId === this.#projectCreatorAuthCoreId
const isAssigningToProjectCreator =
authCoreId === this.#projectCreatorAuthCoreId

coreStorage: () => new RAM(),
})
const ownDeviceId = km.getIdentityKeypair().publicKey.toString('hex')
console.log('deviceId', ownDeviceId.slice(0, 7))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove?

try {
const roleAssignment = await this.#dataType.getByDocId(deviceId)
roleId = roleAssignment.roleId
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint doesn't complain about this being unused?

Suggested change
} catch (e) {
} catch {

Comment on lines +53 to +58
docs: mapObject(currentSchemaVersions, (key) => {
return [
key,
{ readOwn: true, writeOwn: true, readOthers: true, writeOthers: false },
]
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's happening here with these object mappings? hard to tell at a glance without needing to dive into the currentSchemaVersions code

@gmaclennan gmaclennan merged commit 107bf8f into main Aug 31, 2023
@gmaclennan gmaclennan linked an issue Aug 31, 2023 that may be closed by this pull request
5 tasks
@gmaclennan gmaclennan mentioned this pull request Aug 31, 2023
5 tasks
gmaclennan added a commit that referenced this pull request Sep 6, 2023
* main: (25 commits)
  add initial implementation of MemberApi (#232)
  feat: $blobs.getUrl and $blobs.create methods (#184)
  chore: update manager e2e tests (#237)
  feat: add capabilities (#231)
  feat: coreOwnership integration [3/3] (#230)
  feat: CoreOwnership class w getOwner & getCoreKey [2/3] (#229)
  feat: handle `coreOwnership` records in `IndexWriter` [1/3] (#214)
  fix: adjust storage options for MapeoManager and MapeoProject (#235)
  implement addProject method for MapeoManager class (#215)
  implement listProjects method for MapeoManager class (#208)
  feat: expose blobStore.writerDriveId (#219)
  implement wrapper client containing createProject and getProject methods (#199)
  add project settings functionality to MapeoProject (#187)
  feat: Add encode/decode for project keys [3/3] (#203)
  feat: update protobuf for RPC [2/3] (#202)
  chore: move protobuf messages into src/generated [1/3] (#201)
  feat: Add internal `dataType.createWithDocId()` (#192)
  chore: explicitly set "mode" opt for encryptionKeys column creation (#186)
  chore: fix linting and type checking (#183)
  chore: consolidate encryption key columns in projectKeys table (#181)
  ...
@gmaclennan gmaclennan deleted the feat/capabilities branch October 26, 2023 02:02
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.

Add role records
2 participants