Skip to content

Commit

Permalink
Merge branch 'main' into eng-1441
Browse files Browse the repository at this point in the history
  • Loading branch information
turnekybc committed Dec 17, 2024
2 parents a2c45af + 559e400 commit 2d4c70f
Show file tree
Hide file tree
Showing 137 changed files with 10,158 additions and 799 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-clocks-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@turnkey/sdk-browser": minor
---

Fix readWrite session to use credentialBundle and add loginWithAuthBundle to create a session when you already have a credentialBundle
7 changes: 7 additions & 0 deletions .changeset/shiny-coats-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@turnkey/sdk-browser": patch
"@turnkey/sdk-server": patch
"@turnkey/http": patch
---

Update api endpoints - NEW: User verification, SMS customization params
2 changes: 1 addition & 1 deletion examples/oauth/.env.local.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
API_PUBLIC_KEY="<Turnkey API Public Key (that starts with 02 or 03)>"
API_PRIVATE_KEY="<Turnkey API Private Key>"
NEXT_PUBLIC_ORGANIZATION_ID="<Turnkey organization ID>"
NEXT_PUBLIC_GOOGLE_CLIENT_ID="<Google OIDC client ID"
NEXT_PUBLIC_GOOGLE_CLIENT_ID="<Google OIDC client ID>"
NEXT_PUBLIC_BASE_URL="https://api.turnkey.com"
# Can be changed to a localhost iframe if you're modifying the auth flow
# For production, the URL should not be changed and point to the primary Turnkey domain.
Expand Down
14 changes: 14 additions & 0 deletions examples/react-components/.env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## SERVER SIDE
TURNKEY_API_PUBLIC_KEY="<Turnkey API Public Key (that starts with 02 or 03)>"
TURNKEY_API_PRIVATE_KEY="<Turnkey API Private Key>"

## CLIENT SIDE
NEXT_PUBLIC_BASE_URL="https://api.turnkey.com"
NEXT_PUBLIC_ORGANIZATION_ID="<Turnkey organization ID>"
NEXT_PUBLIC_AUTH_IFRAME_URL="https://auth.turnkey.com"
NEXT_PUBLIC_EXPORT_IFRAME_URL="https://export.turnkey.com"
NEXT_PUBLIC_IMPORT_IFRAME_URL="https://import.turnkey.com"
NEXT_PUBLIC_GOOGLE_CLIENT_ID="<Google OIDC client ID>"
NEXT_PUBLIC_APPLE_CLIENT_ID="<Apple OIDC client ID>"
NEXT_PUBLIC_FACEBOOK_CLIENT_ID="<Facebook OIDC client ID>"
NEXT_PUBLIC_OAUTH_REDIRECT_URI="http://localhost:3000/" # Where your login page is - make sure to have a trailing "/" NOTE: Sign in with Apple and Google does not support localhost redirects! You can use ngrok to test locally
3 changes: 3 additions & 0 deletions examples/react-components/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
35 changes: 35 additions & 0 deletions examples/react-components/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
66 changes: 66 additions & 0 deletions examples/react-components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Example: `react-components`

This example shows an example app created using our react components from @turnkey/sdk-react. For more information [check out our documentation](https://docs.turnkey.com/features/TODO). #TODO docs for react components and is also hosted [here](TODO) #TODO add hosted URL - e.g demo.turnkey.com

## Getting started

### 1/ Cloning the example

Make sure you have `node` installed locally; we recommend using Node v18+. You will also need NextJS v13+ (for use-server/use-client directives and /app directory structure). Our components leverage use-server to make server side calls using private API keys without requiring developers to setup their own backend for Turnkey authentication

```bash
$ git clone https://github.com/tkhq/sdk
$ cd sdk/
$ corepack enable # Install `pnpm`
$ pnpm install -r # Install dependencies
$ pnpm run build-all # Compile source code
$ cd examples/react-components/
```

### 2/ Setting up Turnkey

The first step is to set up your Turnkey organization and account. By following the [Quickstart](https://docs.turnkey.com/getting-started/quickstart) guide, you should have:

- A public/private API key pair for Turnkey
- An organization ID

Once you've gathered these values, add them to a new `.env.local` file. Notice that your API private key should be securely managed and **_never_** be committed to git.

```bash
$ cp .env.local.example .env.local
```

Now open `.env.local` and add the missing environment variables:

- `TURNKEY_API_PUBLIC_KEY`
- `TURNKEY_API_PRIVATE_KEY`
- `NEXT_PUBLIC_BASE_URL` (the `NEXT_PUBLIC` prefix makes the env variable accessible to the frontend app)
- `NEXT_PUBLIC_ORGANIZATION_ID`
- `NEXT_PUBLIC_GOOGLE_CLIENT_ID`
- `NEXT_PUBLIC_FACEBOOK_CLIENT_ID`
- `NEXT_PUBLIC_APPLE_CLIENT_ID`
- `NEXT_PUBLIC_AUTH_IFRAME_URL`
- `NEXT_PUBLIC_IMPORT_IFRAME_URL`
- `NEXT_PUBLIC_EXPORT_IFRAME_URL`
- `NEXT_PUBLIC_OAUTH_REDIRECT_URI`

### 3/ Running the app

```bash
$ pnpm run dev
```

This command will run a NextJS app on port 3000. If you navigate to http://localhost:3000 in your browser, the example app using auth components should be ready to use!

### 4/ Using ngrok for OAuth

To enable OAuth flows like Google, Facebook, or Apple on your local environment, you’ll need to use [ngrok](https://ngrok.com) to expose your localhost server to the internet. This is necessary because OIDC providers require a publicly accessible redirect URI during the authentication process.

#### Steps:

1. **Install ngrok**: Follow the [ngrok installation guide](https://ngrok.com/download) to install ngrok on your machine.
2. **Run ngrok**: Start ngrok and point it to port 3000 (the port your app runs on):

```bash
$ ngrok http 3000
```
5 changes: 5 additions & 0 deletions examples/react-components/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
4 changes: 4 additions & 0 deletions examples/react-components/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

module.exports = nextConfig;
43 changes: 43 additions & 0 deletions examples/react-components/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@turnkey/example-react-components",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@hello-pangea/dnd": "^17.0.0",
"@mui/icons-material": "^6.1.5",
"@mui/material": "^6.1.5",
"@noble/hashes": "1.4.0",
"@solana/web3.js": "^1.95.8",
"@turnkey/sdk-browser": "workspace:*",
"@turnkey/sdk-react": "workspace:*",
"@turnkey/sdk-server": "workspace:*",
"@types/node": "20.3.1",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
"axios": "^1.7.4",
"buffer": "^6.0.3",
"encoding": "^0.1.13",
"eslint": "8.43.0",
"eslint-config-next": "14.2.10",
"esm": "^3.2.25",
"ethers": "^6.10.0",
"install": "^0.13.0",
"next": "^14.2.10",
"npm": "^9.7.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-international-phone": "^4.3.0",
"sonner": "^1.4.41",
"tweetnacl": "^1.0.3",
"typescript": "5.1.3"
}
}
1 change: 1 addition & 0 deletions examples/react-components/public/apple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/react-components/public/dots.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions examples/react-components/public/eth-hover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions examples/react-components/public/eth.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/react-components/public/facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions examples/react-components/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions examples/react-components/public/google.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2d4c70f

Please sign in to comment.