Skip to content

Commit

Permalink
plumbing
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkmin committed Nov 27, 2023
1 parent 252d565 commit f394a91
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 4,376 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
directory: ["recovery", "export"]
directory: ["recovery", "export", "auth"]

steps:
- name: Checkout
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ jobs:
projectName: export
directory: export
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Auth
uses: cloudflare/pages-action@f0a1cd58cd66095dee69bfa18fa5efd1dde93bca #v1.5.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: auth
directory: auth
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ COPY nginx.conf /etc/nginx/nginx.conf

COPY recovery /usr/share/nginx/recovery
COPY export /usr/share/nginx/export
COPY auth /usr/share/nginx/auth

EXPOSE 8080/tcp
EXPOSE 8081/tcp
EXPOSE 8082/tcp

CMD ["nginx"]
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Frames

This repository contains code for the recovery and export components of Turnkey. These components can be embedded as iframes by users to support end-users in recovery and export.
This repository contains code for the recovery, export, and auth components of Turnkey. These components can be embedded as iframes by users to support end-users.

## Email Recovery
This self-contained HTML page is meant to be used as a standalone document to help first-party Turnkey root users. It's also going to be embedded as an iframe to help with sub-org root recovery.
Expand All @@ -12,6 +12,11 @@ This self-contained HTML page is meant to be used as either a standalone documen

This page is hosted at https://export.turnkey.com/

## Auth (via Email)
This self-contained HTML page is meant to be used as either a standalone document or to be embedded as an iframe.

This page is hosted at https://auth.turnkey.com/

# Getting Started

Clone the repo:
Expand All @@ -30,14 +35,16 @@ Install dependencies:
```sh
cd recovery && npm install
cd export && npm install
cd auth && npm install
```

# Unit Testing

The export and recovery pages have tests. They run on CI automatically. If you want to run them locally:
The export, recovery, and auth pages each have tests. They run on CI automatically. If you want to run them locally:
```sh
cd recovery && npm test
cd export && npm test
cd auth && npm test
```

# Running Local Wallet Export
Expand All @@ -51,21 +58,37 @@ Clone the `sdk` repo.
git clone [email protected]:tkhq/sdk.git
```

Follow the README.md for the `key-export` example. Set the `NEXT_PUBLIC_EXPORT_IFRAME_URL="http://localhost:3000/export"` in the example's environment variables configuration. The `wallet-export` example embeds this page as an iframe.
Follow the README.md for the `wallet-export` [example](https://github.com/tkhq/sdk/tree/main/examples/wallet-export). Set the `NEXT_PUBLIC_EXPORT_IFRAME_URL="http://localhost:3000/"` in the example's environment variables configuration. The `wallet-export` example embeds this page as an iframe.
```sh
cd sdk/examples/wallet-export
```

# Running Local Auth
Start the server. This command will run a simple static server on port 8080.
```sh
npm start
```

Clone the `sdk` repo.
```sh
git clone [email protected]:tkhq/sdk.git
```

Follow the README.md for the `email-auth` [example](https://github.com/tkhq/sdk/tree/main/examples/email-auth). Set the `NEXT_PUBLIC_AUTH_IFRAME_URL="http://localhost:3000/"` in the example's environment variables configuration. The `email-auth` example embeds this page as an iframe.
```sh
cd sdk/examples/email-auth
```

# Building and running in Docker

To build:
```
docker build . -t frames
```

To run (mapping 8080 and 8081 to 18080/18081 because they're often busy):
To run (mapping `[8080, 8081, 8082]` to `[18080, 18081, 18082]` because they're often busy):
```
docker run -p18080:8080 -p18081:8081 -t frames
docker run -p18080:8080 -p18081:8081 -p18082:8082 -t frames
```

# Deploying to a test Kubernetes cluster
Expand Down
4 changes: 2 additions & 2 deletions auth/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ describe("TKHQ", () => {
})

it("imports auth credentials without errors", async () => {
let key = await TKHQ.importEmailAuthCredential(TKHQ.uint8arrayFromHexString("7632de7338577bc12c1731fa29f08019206af381f74af60f4d5e0395218f205c"));
let key = await TKHQ.importAuthCredential(TKHQ.uint8arrayFromHexString("7632de7338577bc12c1731fa29f08019206af381f74af60f4d5e0395218f205c"));
expect(key.constructor.name).toEqual("CryptoKey");
expect(key.algorithm).toEqual({ name: "ECDSA", namedCurve: "P-256"});
})

it("imports auth credentials correctly", async () => {
let key = await TKHQ.importEmailAuthCredential(TKHQ.uint8arrayFromHexString("7632de7338577bc12c1731fa29f08019206af381f74af60f4d5e0395218f205c"));
let key = await TKHQ.importAuthCredential(TKHQ.uint8arrayFromHexString("7632de7338577bc12c1731fa29f08019206af381f74af60f4d5e0395218f205c"));
let jwkPrivateKey = await crypto.subtle.exportKey("jwk", key);
let publicKey = await TKHQ.p256JWKPrivateToPublic(jwkPrivateKey);
let compressedPublicKey = TKHQ.compressRawPublicKey(publicKey);
Expand Down
Loading

0 comments on commit f394a91

Please sign in to comment.