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

New export example #145

Merged
merged 12 commits into from
Oct 27, 2023
Merged

New export example #145

merged 12 commits into from
Oct 27, 2023

Conversation

oliviathet
Copy link
Contributor

@oliviathet oliviathet commented Oct 24, 2023

Summary & Motivation

This PR demonstrates export functionality for Wallet resources.

  • wallet-export: get a list of your organization's wallets and export a wallet as a mnemonic.

This also adds iframeStyle as a configuration option for the iframe-stamper since we display the iframe if the export bundle is successfully injected.

Important Note on Security:

Turnkey's key export service will allow end-users to export their raw private key or wallet mnemonic by leveraging a secure channel directly between a Turnkey secure enclave and the user's device. This is achieved by the parent page embedding the Turnkey export page as an iframe using the @turnkey/iframe-stamper package introduced in #129. In the iframe, the end-user's keypair is generated and only the public key is ever shared with the parent page or Turnkey. A Turnkey secure enclave receives the public key, generates its own keypair, computes the shared secret, and encrypts the private key material to the shared secret. The resulting encrypted "export bundle" and public key from the Turnkey enclave are returned to the parent page. The parent page injects the "export bundle" in the Turnkey iframe stamper, which decrypts the bundle in the iframe. More information will be available soon in the official Turnkey docs.

@socket-security
Copy link

socket-security bot commented Oct 24, 2023

No top level dependency changes detected. Learn more about Socket for GitHub ↗︎

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 24, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Contributor

@r-n-o r-n-o left a comment

Choose a reason for hiding this comment

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

Nice work overall! My main concern is 1 vs 2 examples for export: I think we can get away with a single one? I don't have a super strong opinion about that though, so if you want to stick with 2 I'm definitely fine with it!

Comment on lines 29 to 30
iframeElementId: TurnkeyIframeElementId,
iframeStyle: "border: none; width: 600px; height: 200px;",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this styling can be achieved by targeting the iframe element ID (instead of having a new iframeStyle property):

#turnkey-iframe-element-id {
  border: none;
  width: 600px;
  height: 200px;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i tried this a few different ways before having a new iframeStyle property and i might be missing something, but it didn't work :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait a second... somehow i got something ELSE to work lol.... will push it in a second! but alas iframeStyle can be removed after all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.walletIframe iframe {
  border: none;
  width: 600px;
  height: 600px;
}

and

<div
  style={{ display: showWallet ? "block" : "none" }}
  id={TurnkeyIframeContainerId}
  className={styles.walletIframe}
/>

examples/key-export/src/pages/index.tsx Outdated Show resolved Hide resolved
examples/key-export/src/pages/index.tsx Outdated Show resolved Hide resolved
examples/key-export/src/pages/index.tsx Outdated Show resolved Hide resolved
examples/wallet-export/README.md Outdated Show resolved Hide resolved
@oliviathet oliviathet changed the title New export examples New export example Oct 26, 2023
@oliviathet oliviathet requested a review from r-n-o October 26, 2023 21:50
Copy link
Contributor

@r-n-o r-n-o left a comment

Choose a reason for hiding this comment

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

Awesome!

* Encryption should be performed with HPKE (RFC 9180).
* This is used during export flows.
*/
async injectKeyExportBundle(bundle: string): Promise<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note: it'd be nice to have some validation at this level (synchronous) to make sure the bundle has the right length / looks like a good bundle. Doesn't have to be part of this PR because this also affects injectRecoveryBundle :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for pointing that out! will add a reminder to self to add validation across the 3 injection functions

@oliviathet oliviathet merged commit 39f348c into main Oct 27, 2023
3 checks passed
@oliviathet oliviathet deleted the olivia/export-example branch October 27, 2023 00:12
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.

2 participants