Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f56cd4a
add auth proxy supper, sync client, start on auth abstractions
moeodeh3 Oct 6, 2025
ec9d513
start on passkey abstractions
moeodeh3 Oct 15, 2025
62676db
Adds rpId to config
taylorjdawson Oct 17, 2025
6b250ba
implements login/signup with passkey + message signing via authproxy
taylorjdawson Oct 20, 2025
224f072
Adds config builder parity with react native wallet kit
taylorjdawson Oct 20, 2025
34656bd
implement robust config handling
taylorjdawson Oct 20, 2025
bde39ab
Implement GoogleOauth
taylorjdawson Oct 21, 2025
0bd1071
implement appleoauth
taylorjdawson Oct 23, 2025
0470cff
implement discord & x oauth
taylorjdawson Oct 24, 2025
a500414
Merge pull request #27 from tkhq/taylor/swift-sdk-auth-proxy
moeodeh3 Oct 27, 2025
fdb130f
client and type generation refactor
moeodeh3 Oct 30, 2025
f788071
centralize codegen logic
moeodeh3 Oct 30, 2025
32ee1ce
params cleanup
moeodeh3 Oct 31, 2025
e393e20
passkey one tap signup
moeodeh3 Oct 31, 2025
2f282e4
start cleanup
moeodeh3 Nov 1, 2025
51fc5c0
more cleanup
moeodeh3 Nov 2, 2025
2781e69
more cleanup
moeodeh3 Nov 2, 2025
6b978e1
more cleanup
moeodeh3 Nov 3, 2025
cff38f6
remove example server, verify state in oAuth2 flow
moeodeh3 Nov 3, 2025
c61c222
add wallet, user, session state
moeodeh3 Nov 4, 2025
dcc7453
organization
moeodeh3 Nov 4, 2025
dc366a7
comment headers
moeodeh3 Nov 4, 2025
e7d2780
Adds secure storage and secure enclave stamper
taylorjdawson Oct 31, 2025
a6fd921
Integrate secure storage/enclave stampers into Stamper class + sessio…
taylorjdawson Nov 3, 2025
cdafe3b
Add option to force a specific on device stamper
taylorjdawson Nov 3, 2025
79d66ec
Format + fix merge conflict residules
taylorjdawson Nov 4, 2025
c9d606d
Address Pr comments
taylorjdawson Nov 5, 2025
f6e05e6
add protocol that stampers implement
moeodeh3 Nov 5, 2025
f639240
use constant for max value
taylorjdawson Nov 5, 2025
8dacbb7
fix sessionKey logic for handle oAuth functions
moeodeh3 Nov 5, 2025
0c05b21
Merge pull request #28 from tkhq/taylor/secure-stampers
moeodeh3 Nov 5, 2025
d6562f7
Merge pull request #30 from tkhq/moeO/oAuth2
moeodeh3 Nov 5, 2025
33146ce
persist session fix
moeodeh3 Nov 5, 2025
98a8f43
added @discardableResult to the respective functions
moeodeh3 Nov 5, 2025
2084370
fix build warning
moeodeh3 Nov 5, 2025
dcb3ae3
fix session client not including authProxy config
moeodeh3 Nov 5, 2025
6918936
readme, remove all references of SecureStore
moeodeh3 Nov 5, 2025
7002acb
update readmes
moeodeh3 Nov 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 37 additions & 67 deletions Examples/swift-demo-wallet/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
# Swift Demo Wallet 
# Swift Demo Wallet

The Swift Demo Wallet is a sample iOS/macOS application that demonstrates how to build a simple wallet experience using Turnkey infrastructure. It showcases session handling, wallet creation/import, and transaction signing in a native SwiftUI application.
A minimal iOS/macOS application demonstrating how to build an embedded wallet experience using Turnkey infrastructure and Auth Proxy.

---
## What this demo shows

## Quick Start
A high-level summary of the user experience and what you can see on screen:

### 1. Clone the Repository
- **Authentication**: Log in with passkeys, OTP (email/SMS), or OAuth (Google, Apple, Discord, X)
- **Session Management**: Automatic session handling with secure key storage in Secure Enclave
- **Wallet Operations**: Create, import, and export wallets with mnemonic phrases
- **Message Signing**: Sign messages and raw payloads with wallet accounts
- **User Management**: Update email/phone and view wallet details

```
## Getting started

### 1/ Cloning the example

Make sure you have Xcode 15+ installed.

```bash
git clone https://github.com/tkhq/swift-sdk
cd Examples/swift-demo-wallet
cd swift-sdk/Examples/swift-demo-wallet
```

### 2. Open the Project
### 2/ Setting up Turnkey

Open the `Examples/swift-demo-wallet` folder and build the project in Xcode.
1. Set up your Turnkey organization and account. You'll need your **parent organization ID**.
2. Enable **Auth Proxy** from your Turnkey dashboard:
- Choose the user auth methods (Email OTP, SMS OTP, OAuth providers)
- Configure redirect URLs for OAuth (if using)
- Copy your **Auth Proxy Config ID** for the next step
3. (Optional) For passkey authentication, set up your **RP ID** domain with associated domains

### 3. Configure Constants
### 3/ Configure Constants

Edit `Helpers/Constants.swift` and fill in the required values:
Edit `swift-demo-wallet/Helpers/Constants.swift` and add your values:

```swift
enum Constants {
enum App {
static let appName = "Swift Demo Wallet App"
static let rpId = "<your_rp_id>" // e.g. passkeyapp.tkhqlabs.xyz
static let backendBaseUrl = "<your_backend_url>" // e.g. http://localhost:3000
static let rpId = "<your_rp_id>" // required for passkeys
}

enum Turnkey {
static let organizationId = "<your_organization_id>"
static let sessionDuration = "900" // session duration in seconds
static let apiUrl = "https://api.turnkey.com"

// Auth Proxy Configuration
static let authProxyUrl = "https://auth.turnkey.com"
static let authProxyConfigId = "<your_auth_proxy_config_id>"

// Default accounts to create when using the "Create Wallet" button
// Customize this array to create wallets with different curves, paths, or address formats
static let defaultEthereumAccounts: [Components.Schemas.WalletAccountParams] = [
Components.Schemas.WalletAccountParams(
curve: .CURVE_SECP256K1,
Expand All @@ -51,65 +70,16 @@ enum Constants {
}
```

---

## Backend Setup

### Why Do We Need a Backend?

Turnkey requires authentication requests (sign-up/login) to be validated (stamped) using your root user API key-pair. Since this key-pair must remain private, it cannot be used directly in the frontend. Instead, authentication requests must be processed and stamped through a backend server before being forwarded to Turnkey.

### 1. Configure Environment Variables

Create a `.env` file inside the `example-server` folder:

```
PORT="3000"

TURNKEY_API_URL="https://api.turnkey.com"
TURNKEY_ORGANIZATION_ID="<your_turnkey_organization_id>"

TURNKEY_API_PUBLIC_KEY="<your_turnkey_api_public_key>"
TURNKEY_API_PRIVATE_KEY="<your_turnkey_api_private_key>"
```

### 2. Start the Server
### 4/ Running the demo

```
cd example-server
npm install
npm run start
```

---

## Passkey Setup

To enable passkey authentication, you must configure your domain and app settings correctly:

### Associated Domains

1. In your app's `Signing & Capabilities` tab, add the `Associated Domains` capability.
2. Add your domain:

```
webcredentials:<your_rpid_domain>
```

3. Host an `apple-app-site-association` file at `https://<your_rpid_domain>/.well-known/apple-app-site-association`

4. Ensure your `rpId` in Constants.swift matches the domain:

```swift
static let rpId = "<your_rpid_domain>"
```
Open `swift-demo-wallet.xcodeproj` in Xcode and run the app on your device or simulator.

---

## Requirements

- iOS 17+ / macOS 13.0+
- Swift 5.7+
- iOS 17+ / macOS 14.0+
- Swift 5.9+
- Xcode 15+

---
7 changes: 0 additions & 7 deletions Examples/swift-demo-wallet/example-server/.env.example

This file was deleted.

48 changes: 0 additions & 48 deletions Examples/swift-demo-wallet/example-server/index.ts

This file was deleted.

Loading