/frames

Primary LanguageHTMLApache License 2.0Apache-2.0

Frames

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

Auth

This self-contained HTML page is meant to be used for the following use cases:

  • As a standalone document to enable first-party Turnkey root users to perform recovery and auth
  • Embedded as an iframe for sub-org root recovery and auth

This page is hosted at https://auth.turnkey.com/, but we will retain https://recovery.turnkey.com/ for compatibility.

Key and Wallet Export

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://export.turnkey.com/

Getting Started

Clone the repo:

git clone git@github.com:tkhq/frames.git
cd frames/

Install Node:

nvm use

(the command above installs the version specified in .nvmrc, but any Node version >= v18 should do)

Install dependencies:

cd auth && npm install
cd export && npm install
cd import && npm install

Unit Testing

The auth and recovery pages each have tests. They run on CI automatically. If you want to run them locally:

cd auth && npm test
cd export  && npm test
cd import && npm test

Running Local Wallet Import/Export

Start the server. This command will run a simple static server on port 8080.

npm start

Clone the sdk repo.

git clone git@github.com:tkhq/sdk.git

Follow the README.md for the wallet-export example. 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.

cd sdk/examples/wallet-export

Running Local Auth

Start the server. This command will run a simple static server on port 8080.

npm start

Clone the sdk repo.

git clone git@github.com:tkhq/sdk.git

Follow the README.md for the email-auth example. 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.

cd sdk/examples/email-auth

Building and running in Docker

To build:

docker build . -t frames

To run (mapping [8080, 8081, ...] to [18080, 18081, ...] because they're often busy):

docker run -p18080:8080 -p18081:8081 -t frames

Deploying to a test Kubernetes cluster

This requires k3d to be installed:

# Create a local cluster
k3d cluster create frames

# Deploy to it
kubectl kustomize kustomize | kubectl --context k3d-frames apply -f-

# Be able to access locally (8080 as an example)
kubectl port-forward svc/frames 8080:8080

To clean things up:

k3d cluster delete frames