Skip to content

Commit b3fc41d

Browse files
committed
prettier/docs
1 parent 7a89d56 commit b3fc41d

File tree

6 files changed

+69
-77
lines changed

6 files changed

+69
-77
lines changed

README.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ API Docs: https://docs.turnkey.com/
66

77
## Packages
88

9-
| Package | NPM | Description | Changelog |
10-
| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | ---------------------------------------------------- |
11-
| [`@turnkey/ethers`](/packages/ethers) | [![npm](https://img.shields.io/npm/v/@turnkey/ethers?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/ethers) | Turnkey Signer for Ethers | [CHANGELOG](/packages/ethers/CHANGELOG.md) |
12-
| [`@turnkey/viem`](/packages/viem) | [![npm](https://img.shields.io/npm/v/@turnkey/viem?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/viem) | (Experimental) Turnkey Helpers to work with Viem | [CHANGELOG](/packages/viem/CHANGELOG.md) |
13-
| [`@turnkey/cosmjs`](/packages/cosmjs) | [![npm](https://img.shields.io/npm/v/@turnkey/cosmjs?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/cosmjs) | (Experimental) Turnkey Cosmos Signer for CosmJS | [CHANGELOG](/packages/cosmjs/CHANGELOG.md) |
14-
| [`@turnkey/http`](/packages/http) | [![npm](https://img.shields.io/npm/v/@turnkey/http?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/http) | Lower-level, fully typed HTTP client for interacting with Turnkey API | [CHANGELOG](/packages/http/CHANGELOG.md) |
15-
| [`@turnkey/api-key-stamper`](/packages/api-key-stamper) | [![npm](https://img.shields.io/npm/v/@turnkey/api-key-stamper?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/api-key-stamper) | Provide API key signatures over Turnkey requests | [CHANGELOG](/packages/api-key-stamper/CHANGELOG.md) |
16-
| [`@turnkey/webauthn-stamper`](/packages/webauthn-stamper) | [![npm](https://img.shields.io/npm/v/@turnkey/webauthn-stamper?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/webauthn-stamper) | Provide Webauthn signatures over Turnkey requests | [CHANGELOG](/packages/webauthn-stamper/CHANGELOG.md) |
9+
| Package | NPM | Description | Changelog |
10+
| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------- |
11+
| [`@turnkey/ethers`](/packages/ethers) | [![npm](https://img.shields.io/npm/v/@turnkey/ethers?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/ethers) | Turnkey Signer for Ethers | [CHANGELOG](/packages/ethers/CHANGELOG.md) |
12+
| [`@turnkey/viem`](/packages/viem) | [![npm](https://img.shields.io/npm/v/@turnkey/viem?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/viem) | (Experimental) Turnkey Helpers to work with Viem | [CHANGELOG](/packages/viem/CHANGELOG.md) |
13+
| [`@turnkey/cosmjs`](/packages/cosmjs) | [![npm](https://img.shields.io/npm/v/@turnkey/cosmjs?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/cosmjs) | (Experimental) Turnkey Cosmos Signer for CosmJS | [CHANGELOG](/packages/cosmjs/CHANGELOG.md) |
14+
| [`@turnkey/http`](/packages/http) | [![npm](https://img.shields.io/npm/v/@turnkey/http?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/http) | Lower-level, fully typed HTTP client for interacting with Turnkey API | [CHANGELOG](/packages/http/CHANGELOG.md) |
15+
| [`@turnkey/api-key-stamper`](/packages/api-key-stamper) | [![npm](https://img.shields.io/npm/v/@turnkey/api-key-stamper?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/api-key-stamper) | Provide API key signatures over Turnkey requests | [CHANGELOG](/packages/api-key-stamper/CHANGELOG.md) |
16+
| [`@turnkey/iframe-stamper`](/packages/iframe-stamper) | [![npm](https://img.shields.io/npm/v/@turnkey/iframe-stamper?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/iframe-stamper) | Provide API key signatures over Turnkey requests within iframe contexts | [CHANGELOG](/packages/iframe-stamper/CHANGELOG.md) |
17+
| [`@turnkey/webauthn-stamper`](/packages/webauthn-stamper) | [![npm](https://img.shields.io/npm/v/@turnkey/webauthn-stamper?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/webauthn-stamper) | Provide Webauthn signatures over Turnkey requests | [CHANGELOG](/packages/webauthn-stamper/CHANGELOG.md) |
1718

1819
## Code Examples
1920

@@ -24,6 +25,9 @@ API Docs: https://docs.turnkey.com/
2425
| [`demo-ethers-passkeys`](https://github.com/tkhq/demo-ethers-passkeys) | A NextJS app that demonstrates how to use `@turnkey/ethers` to build a passkey-powered application |
2526
| [`demo-viem-passkeys`](https://github.com/tkhq/demo-viem-passkeys) | A NextJS app that demonstrates how to use `@turnkey/viem` to build a passkey-powered application |
2627
| [`deployer`](/examples/deployer/) | Compile and deploy a smart contract |
28+
| [`email-auth`](/examples/email-auth/) | A NextJS app demonstrating a complete email auth flow |
29+
| [`email-recovery`](/examples/email-recovery/) | A NextJS app demonstrating a complete email recovery flow |
30+
| [`wallet-export`](/examples/wallet-export/) | A NextJS app demonstrating a complete wallet export flow |
2731
| [`rebalancer`](/examples/rebalancer/) | A demo application which showcases an example of how to use Turnkey for managing multiple types of keys & users |
2832
| [`sweeper`](/examples/sweeper/) | Sweep funds from one address to a different address |
2933
| [`trading-runner`](/examples/trading-runner/) | A sample application demonstrating a trading operation, using various private keys, users, and policies, powered by Uniswap |

examples/email-auth/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This example shows a complete email auth flow. It contains a NextJS app with:
66
- a backend application
77

88
The overall flow for email auth is outlined below:
9-
![Email auth flow diagram](./auth.png)
9+
![Email auth flow diagram](./email_auth_steps.png)
1010

1111
This example contains an example auth page as well as a stub API endpoint for "your business" (where the email is resolved into an organization ID). The creation of the hidden iframe is abstracted by our `@turnkey/iframe-stamper` package. For more information on email auth, [check out our documentation](https://docs.turnkey.com/getting-started/email-auth).
1212

@@ -44,7 +44,7 @@ Now open `.env.local` and add the missing environment variables:
4444
- `API_PRIVATE_KEY`
4545
- `NEXT_PUBLIC_ORGANIZATION_ID`
4646
- `NEXT_PUBLIC_BASE_URL` (the `NEXT_PUBLIC` prefix makes the env variable accessible to the frontend app)
47-
- `NEXT_PUBLIC_RECOVERY_IFRAME_URL`
47+
- `NEXT_PUBLIC_AUTH_IFRAME_URL`
4848

4949
### 3/ Running the app
5050

427 KB
Loading
-488 KB
Binary file not shown.

examples/email-auth/src/pages/index.tsx

+54-66
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,12 @@ const base64UrlEncode = (challenge: ArrayBuffer): string => {
5454
};
5555

5656
export default function AuthPage() {
57-
const [authResponse, setAuthResponse] =
58-
useState<AuthResponse | null>(null);
57+
const [authResponse, setAuthResponse] = useState<AuthResponse | null>(null);
5958
const [iframeStamper, setIframeStamper] = useState<IframeStamper | null>(
6059
null
6160
);
62-
const {
63-
register: authFormRegister,
64-
handleSubmit: authFormSubmit,
65-
} = useForm<AuthFormData>();
61+
const { register: authFormRegister, handleSubmit: authFormSubmit } =
62+
useForm<AuthFormData>();
6663
const {
6764
register: injectCredentialsFormRegister,
6865
handleSubmit: injectCredentialsFormSubmit,
@@ -131,10 +128,8 @@ export default function AuthPage() {
131128
const walletId = refineNonNull(wallet.walletId);
132129
const address = refineNonNull(wallet.addresses[0]);
133130

134-
// // Instead of simply alerting, redirect the user to your app's login page.
135-
alert(
136-
`SUCCESS! Wallet and new address created: ${address} `
137-
);
131+
// Instead of simply alerting, redirect the user to your app's login page.
132+
alert(`SUCCESS! Wallet and new address created: ${address} `);
138133
};
139134

140135
return (
@@ -162,64 +157,57 @@ export default function AuthPage() {
162157

163158
{!iframeStamper && <p>Loading...</p>}
164159

165-
{iframeStamper &&
166-
iframeStamper.publicKey() &&
167-
authResponse === null && (
168-
<form
169-
className={styles.form}
170-
onSubmit={authFormSubmit(auth)}
171-
>
172-
<label className={styles.label}>
173-
Email
174-
<input
175-
className={styles.input}
176-
{...authFormRegister("email")}
177-
placeholder="Email"
178-
/>
179-
</label>
180-
<label className={styles.label}>
181-
Encryption Target from iframe:
182-
<br />
183-
<code title={iframeStamper.publicKey()!}>
184-
{iframeStamper.publicKey()!.substring(0, 30)}...
185-
</code>
186-
</label>
187-
160+
{iframeStamper && iframeStamper.publicKey() && authResponse === null && (
161+
<form className={styles.form} onSubmit={authFormSubmit(auth)}>
162+
<label className={styles.label}>
163+
Email
164+
<input
165+
className={styles.input}
166+
{...authFormRegister("email")}
167+
placeholder="Email"
168+
/>
169+
</label>
170+
<label className={styles.label}>
171+
Encryption Target from iframe:
172+
<br />
173+
<code title={iframeStamper.publicKey()!}>
174+
{iframeStamper.publicKey()!.substring(0, 30)}...
175+
</code>
176+
</label>
177+
178+
<input className={styles.button} type="submit" value="Auth" />
179+
</form>
180+
)}
181+
182+
{iframeStamper && iframeStamper.publicKey() && authResponse !== null && (
183+
<form
184+
className={styles.form}
185+
onSubmit={injectCredentialsFormSubmit(injectCredentials)}
186+
>
187+
<label className={styles.label}>
188+
Auth Bundle
189+
<input
190+
className={styles.input}
191+
{...injectCredentialsFormRegister("authBundle")}
192+
placeholder="Paste your auth bundle here"
193+
/>
194+
</label>
195+
<label className={styles.label}>
196+
New wallet name
188197
<input
189-
className={styles.button}
190-
type="submit"
191-
value="Auth"
198+
className={styles.input}
199+
{...injectCredentialsFormRegister("walletName")}
200+
placeholder="Wallet name"
192201
/>
193-
</form>
194-
)}
195-
196-
{iframeStamper &&
197-
iframeStamper.publicKey() &&
198-
authResponse !== null && (
199-
<form
200-
className={styles.form}
201-
onSubmit={injectCredentialsFormSubmit(injectCredentials)}
202-
>
203-
<label className={styles.label}>
204-
Auth Bundle
205-
<input
206-
className={styles.input}
207-
{...injectCredentialsFormRegister("authBundle")}
208-
placeholder="Paste your auth bundle here"
209-
/>
210-
</label>
211-
<label className={styles.label}>
212-
New wallet name
213-
<input
214-
className={styles.input}
215-
{...injectCredentialsFormRegister("walletName")}
216-
placeholder="Wallet name"
217-
/>
218-
</label>
219-
220-
<input className={styles.button} type="submit" value="Create Wallet" />
221-
</form>
222-
)}
202+
</label>
203+
204+
<input
205+
className={styles.button}
206+
type="submit"
207+
value="Create Wallet"
208+
/>
209+
</form>
210+
)}
223211
</main>
224212
);
225213
}

packages/iframe-stamper/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class IframeStamper {
138138
return new Promise((resolve, reject) => {
139139
this.iframe.contentWindow?.postMessage(
140140
{
141-
type: IframeEventType.InjectAuthBundle,
141+
type: IframeEventType.InjectRecoveryBundle,
142142
value: bundle,
143143
},
144144
"*"

0 commit comments

Comments
 (0)