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

goat account migration #768

Merged
merged 12 commits into from
Oct 2, 2024
Merged

goat account migration #768

merged 12 commits into from
Oct 2, 2024

Conversation

bnewbold
Copy link
Collaborator

This PR adds support for account migration using the goat CLI tool two different ways:

  • a bunch of account helper commands which individually enable doing an account migration: creating a new account using service auth and old DID; migrating all the data; swapping identity around
  • a helper command that automates all this (starting with a PLC op auth token)

The hope is that the migrate command should work in common cases, but the individual commands allow cleaning up in the case of partial success, and doing more complex stuff.

Missing pieces as future work:

  • did:web functionality
  • detection of current progress and only continue work that needs continuing (eg, don't try to re-create new account if it already exists and can auth with provided credentials)
  • proper support for inserting a recovery key when signing PLC op
  • more safety validation and guardrails

@bnewbold bnewbold requested a review from dholms September 30, 2024 02:06
return err
}

var op json.RawMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't do anything, json.RawMessage is []byte

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm, does it not validate that the bytes are valid JSON when doing this unmarshal? I do also like having the type wrapper, and it allows passing through to the outbound marshal step below in a way that wouldn't work if it was just []byte.

}

// display migration status
// TODO: should this loop? with a delay?
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah you could run this in a loop in the background to give like progress bars for blob uploads or something, but otherwise you can just do it in between steps to ensure that things finished correctly

}
unsignedOp.Token = &plcToken

// TODO: add some safety checks here around rotation key set intersection?
Copy link
Contributor

Choose a reason for hiding this comment

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

The new PDS does some checks on your behalf as well. But an extra check here wouldn't hurt. The TS script I wrote doesn't do any extra checks but before we start encouraging other folks to use this script en mass we should probably make it a bit more resilient

return err
}

// TODO: does this crash with unsupported preference types?
Copy link
Contributor

Choose a reason for hiding this comment

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

it shouldn't

I think the client is more accepting than the server. I believe the PDS will reject requests for preferences not in the app.bsky namespace. Which also means that users migrating off of our PDSs shouldn't run into any unsupported prefs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is an indigo thing: the default de-serialization will throw an error if it encounters a $type which isn't a Lexicon schema known at compile-time.

return err
}

// TODO: does this clobber unsupported preference types?
Copy link
Contributor

Choose a reason for hiding this comment

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

It shouldn't! But like above, it will reject any preference types that aren't app.bsky

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is partially an indigo issue: unlike in typescript, go data is deserialized in to a struct by default; re-serializing this discards and data/fields which are not in the codegen'd struct. This includes off-Lexicons fields; open union members from unknown Lexicons; and data from fields in newer versions of the Lexicon since the client code was generated.

@bnewbold
Copy link
Collaborator Author

bnewbold commented Oct 2, 2024

Updated comments in the code. Going to merge now to have this basic functionality available.

See also: https://whtwnd.com/bnewbold.net/3l5ii332pf32u

@bnewbold bnewbold merged commit 00b60c6 into main Oct 2, 2024
7 checks passed
@bnewbold bnewbold deleted the bnewbold/goat-account-migration branch October 2, 2024 00:40
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