Skip to content

Commit d2bf98a

Browse files
committed
Merge pull-request #26
2 parents c108fe5 + 7002acb commit d2bf98a

File tree

93 files changed

+33700
-45112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+33700
-45112
lines changed
Lines changed: 37 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,58 @@
1-
# Swift Demo Wallet 
1+
# Swift Demo Wallet
22

3-
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.
3+
A minimal iOS/macOS application demonstrating how to build an embedded wallet experience using Turnkey infrastructure and Auth Proxy.
44

5-
---
5+
## What this demo shows
66

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

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

11-
```
15+
## Getting started
16+
17+
### 1/ Cloning the example
18+
19+
Make sure you have Xcode 15+ installed.
20+
21+
```bash
1222
git clone https://github.com/tkhq/swift-sdk
13-
cd Examples/swift-demo-wallet
23+
cd swift-sdk/Examples/swift-demo-wallet
1424
```
1525

16-
### 2. Open the Project
26+
### 2/ Setting up Turnkey
1727

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

20-
### 3. Configure Constants
35+
### 3/ Configure Constants
2136

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

2439
```swift
2540
enum Constants {
2641
enum App {
2742
static let appName = "Swift Demo Wallet App"
28-
static let rpId = "<your_rp_id>" // e.g. passkeyapp.tkhqlabs.xyz
29-
static let backendBaseUrl = "<your_backend_url>" // e.g. http://localhost:3000
43+
static let rpId = "<your_rp_id>" // required for passkeys
3044
}
3145

3246
enum Turnkey {
3347
static let organizationId = "<your_organization_id>"
34-
static let sessionDuration = "900" // session duration in seconds
3548
static let apiUrl = "https://api.turnkey.com"
49+
50+
// Auth Proxy Configuration
51+
static let authProxyUrl = "https://auth.turnkey.com"
52+
static let authProxyConfigId = "<your_auth_proxy_config_id>"
3653

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

54-
---
55-
56-
## Backend Setup
57-
58-
### Why Do We Need a Backend?
59-
60-
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.
61-
62-
### 1. Configure Environment Variables
63-
64-
Create a `.env` file inside the `example-server` folder:
65-
66-
```
67-
PORT="3000"
68-
69-
TURNKEY_API_URL="https://api.turnkey.com"
70-
TURNKEY_ORGANIZATION_ID="<your_turnkey_organization_id>"
71-
72-
TURNKEY_API_PUBLIC_KEY="<your_turnkey_api_public_key>"
73-
TURNKEY_API_PRIVATE_KEY="<your_turnkey_api_private_key>"
74-
```
75-
76-
### 2. Start the Server
73+
### 4/ Running the demo
7774

78-
```
79-
cd example-server
80-
npm install
81-
npm run start
82-
```
83-
84-
---
85-
86-
## Passkey Setup
87-
88-
To enable passkey authentication, you must configure your domain and app settings correctly:
89-
90-
### Associated Domains
91-
92-
1. In your app's `Signing & Capabilities` tab, add the `Associated Domains` capability.
93-
2. Add your domain:
94-
95-
```
96-
webcredentials:<your_rpid_domain>
97-
```
98-
99-
3. Host an `apple-app-site-association` file at `https://<your_rpid_domain>/.well-known/apple-app-site-association`
100-
101-
4. Ensure your `rpId` in Constants.swift matches the domain:
102-
103-
```swift
104-
static let rpId = "<your_rpid_domain>"
105-
```
75+
Open `swift-demo-wallet.xcodeproj` in Xcode and run the app on your device or simulator.
10676

10777
---
10878

10979
## Requirements
11080

111-
- iOS 17+ / macOS 13.0+
112-
- Swift 5.7+
81+
- iOS 17+ / macOS 14.0+
82+
- Swift 5.9+
11383
- Xcode 15+
11484

11585
---

Examples/swift-demo-wallet/example-server/.env.example

Lines changed: 0 additions & 7 deletions
This file was deleted.

Examples/swift-demo-wallet/example-server/index.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)