Skip to content

Commit 91a68f3

Browse files
committed
Merge pull-request #34
2 parents 3f96634 + a16af53 commit 91a68f3

File tree

12 files changed

+3399
-306
lines changed

12 files changed

+3399
-306
lines changed

Examples/swift-demo-wallet/swift-demo-wallet/AppView.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@ struct AuthFlow: View {
2222
switch route {
2323
case let .otp(id, contact, otpType):
2424
OtpView(otpId: id, contact: contact, otpType: otpType) { otpCode in
25-
try await turnkey.completeOtp(
26-
otpId: id,
27-
otpCode: otpCode,
28-
contact: contact,
29-
otpType: otpType
30-
)
25+
Task {
26+
do {
27+
try await turnkey.completeOtp(
28+
otpId: id,
29+
otpCode: otpCode,
30+
contact: contact,
31+
otpType: otpType
32+
)
33+
} catch {
34+
let message = formatError(error, fallback: "Failed to complete OTP")
35+
print("[AppView] complete OTP failed: \(message)")
36+
}
37+
}
3138
}
3239
}
3340
}

Examples/swift-demo-wallet/swift-demo-wallet/Helpers/Constants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ enum Constants {
1111

1212
enum Turnkey {
1313
static let organizationId = "<your_organization_id>"
14-
static let apiUrl = "https://api.turnkey.com"
14+
static let apiUrl = "https://api.turnkey.com"
1515

1616
static let authProxyUrl = "https://authproxy.turnkey.com"
1717
static let authProxyConfigId = "<your_auth_proxy_config_id>"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Foundation
2+
3+
func formatError(_ error: Error, fallback: String) -> String {
4+
if let turnkeyError = error.turnkeyRequestError {
5+
return "\(fallback): \(turnkeyError.fullMessage)"
6+
}
7+
if let localized = (error as? LocalizedError)?.errorDescription {
8+
return "\(fallback): \(localized)"
9+
}
10+
return "\(fallback): \(String(describing: error))"
11+
}

Examples/swift-demo-wallet/swift-demo-wallet/Views/AuthView.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,6 @@ struct AuthView: View {
223223
.windows
224224
.first(where: { $0.isKeyWindow })
225225
}
226-
227-
private func formatError(_ error: Error, fallback: String) -> String {
228-
if let turnkeyError = error.turnkeyRequestError {
229-
return "\(fallback): \(turnkeyError.fullMessage)"
230-
}
231-
if let localized = (error as? LocalizedError)?.errorDescription {
232-
return "\(fallback): \(localized)"
233-
}
234-
return "\(fallback): \(String(describing: error))"
235-
}
236226

237227
private struct OrSeparator: View {
238228
var label: String = "OR"

Scripts/Sources/Internal/Resources/auth_proxy.swagger.json

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@
270270
}
271271
},
272272
"definitions": {
273+
"externaldatav1SignatureScheme": {
274+
"type": "string",
275+
"enum": ["SIGNATURE_SCHEME_EPHEMERAL_KEY_P256"]
276+
},
273277
"protobufAny": {
274278
"type": "object",
275279
"properties": {
@@ -373,7 +377,7 @@
373377
"type": "object",
374378
"properties": {
375379
"scheme": {
376-
"$ref": "#/definitions/v1SignatureScheme",
380+
"$ref": "#/definitions/externaldatav1SignatureScheme",
377381
"description": "Scheme of signing key."
378382
},
379383
"publicKey": {
@@ -449,6 +453,32 @@
449453
"AUTHENTICATOR_TRANSPORT_HYBRID"
450454
]
451455
},
456+
"v1ClientSignature": {
457+
"type": "object",
458+
"properties": {
459+
"publicKey": {
460+
"type": "string",
461+
"description": "The public component of a cryptographic key pair used to create the signature."
462+
},
463+
"scheme": {
464+
"$ref": "#/definitions/v1ClientSignatureScheme",
465+
"description": "The signature scheme used to generate the client signature."
466+
},
467+
"message": {
468+
"type": "string",
469+
"description": "The message that was signed."
470+
},
471+
"signature": {
472+
"type": "string",
473+
"description": "The cryptographic signature over the message."
474+
}
475+
},
476+
"required": ["publicKey", "scheme", "message", "signature"]
477+
},
478+
"v1ClientSignatureScheme": {
479+
"type": "string",
480+
"enum": ["CLIENT_SIGNATURE_SCHEME_API_P256"]
481+
},
452482
"v1Curve": {
453483
"type": "string",
454484
"enum": ["CURVE_SECP256K1", "CURVE_ED25519"]
@@ -669,8 +699,8 @@
669699
"description": "Unique identifier for a given Organization. If provided, this organization id will be used directly. If omitted, uses the verification token to look up the verified sub-organization based on the contact and verification type."
670700
},
671701
"clientSignature": {
672-
"type": "string",
673-
"description": "Optional signature associated with the public key passed into the verification step. This must be a hex-encoded ECDSA signature over the verification token. Only required if a public key was provided during the verification step."
702+
"$ref": "#/definitions/v1ClientSignature",
703+
"description": "Optional signature proving authorization for this login. The signature is over the verification token ID and the public key. Only required if a public key was provided during the verification step."
674704
}
675705
},
676706
"required": ["verificationToken", "publicKey"]
@@ -689,10 +719,6 @@
689719
"type": "string",
690720
"enum": ["PATH_FORMAT_BIP32"]
691721
},
692-
"v1SignatureScheme": {
693-
"type": "string",
694-
"enum": ["SIGNATURE_SCHEME_EPHEMERAL_KEY_P256"]
695-
},
696722
"v1SignupRequest": {
697723
"type": "object",
698724
"properties": {
@@ -741,6 +767,10 @@
741767
"wallet": {
742768
"$ref": "#/definitions/v1WalletParams",
743769
"description": "The wallet to create for the sub-organization"
770+
},
771+
"clientSignature": {
772+
"$ref": "#/definitions/v1ClientSignature",
773+
"description": "Optional signature proving authorization for this signup. The signature is over the verification token ID and the root user parameters for the root user associated with the verification token. Only required if a public key was provided during the verification step."
744774
}
745775
},
746776
"required": ["apiKeys", "authenticators", "oauthProviders"]
@@ -767,7 +797,7 @@
767797
"type": "object",
768798
"$ref": "#/definitions/v1AppProof"
769799
},
770-
"description": "A list of app proofs generated by enclaves during activity execution, providing verifiable attestations of performed operations."
800+
"description": "A list of App Proofs generated by enclaves during activity execution, providing verifiable attestations of performed operations."
771801
}
772802
},
773803
"required": ["organizationId", "userId"]

0 commit comments

Comments
 (0)