Skip to content

Commit 26a96fc

Browse files
committed
Merge pull-request #19
2 parents d08b618 + 4619d54 commit 26a96fc

Some content is hidden

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

45 files changed

+199
-417
lines changed

.env.example

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Swift Demo Wallet 
2+
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.
4+
5+
---
6+
7+
## Quick Start
8+
9+
### 1. Clone the Repository
10+
11+
```
12+
git clone https://github.com/tkhq/swift-sdk
13+
cd Examples/swift-demo-wallet
14+
```
15+
16+
### 2. Open the Project
17+
18+
Open the `Examples/swift-demo-wallet` folder and build the project in Xcode.
19+
20+
### 3. Configure Constants
21+
22+
Edit `Helpers/Constants.swift` and fill in the required values:
23+
24+
```swift
25+
enum Constants {
26+
enum App {
27+
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
30+
}
31+
32+
enum Turnkey {
33+
static let organizationId = "<your_organization_id>"
34+
static let sessionDuration = "900" // session duration in seconds
35+
static let apiUrl = "https://api.turnkey.com"
36+
37+
static let defaultEthereumAccounts: [Components.Schemas.WalletAccountParams] = [
38+
Components.Schemas.WalletAccountParams(
39+
curve: .CURVE_SECP256K1,
40+
pathFormat: .PATH_FORMAT_BIP32,
41+
path: "m/44'/60'/0'/0/0",
42+
addressFormat: .ADDRESS_FORMAT_ETHEREUM
43+
)
44+
]
45+
}
46+
47+
enum Ethereum {
48+
static let rpcURL = "https://rpc.sepolia.org"
49+
static let coingeckoURL = "https://api.coingecko.com"
50+
}
51+
}
52+
```
53+
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
77+
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+
```
106+
107+
---
108+
109+
## Requirements
110+
111+
- iOS 17+ / macOS 13.0+
112+
- Swift 5.7+
113+
- Xcode 15+
114+
115+
---

Examples/swift-sdk-demo-wallet/example-server/.env.example renamed to Examples/swift-demo-wallet/example-server/.env.example

File renamed without changes.
File renamed without changes.

Examples/swift-sdk-demo-wallet/example-server/package-lock.json renamed to Examples/swift-demo-wallet/example-server/package-lock.json

File renamed without changes.

Examples/swift-sdk-demo-wallet/example-server/package.json renamed to Examples/swift-demo-wallet/example-server/package.json

File renamed without changes.

Examples/swift-sdk-demo-wallet/example-server/src/handler.ts renamed to Examples/swift-demo-wallet/example-server/src/handler.ts

File renamed without changes.

Examples/swift-sdk-demo-wallet/example-server/src/types.ts renamed to Examples/swift-demo-wallet/example-server/src/types.ts

File renamed without changes.

Examples/swift-sdk-demo-wallet/example-server/src/util.ts renamed to Examples/swift-demo-wallet/example-server/src/util.ts

File renamed without changes.

Examples/swift-sdk-demo-wallet/example-server/tsconfig.json renamed to Examples/swift-demo-wallet/example-server/tsconfig.json

File renamed without changes.

0 commit comments

Comments
 (0)