Skip to content
Open
Changes from 1 commit
Commits
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
128 changes: 126 additions & 2 deletions Auth0.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,129 @@ Pod::Spec.new do |s|
s.visionos.deployment_target = '1.0'
s.visionos.pod_target_xcconfig = {
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
Comment on lines +33 to +35

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.visionos.deployment_target = '1.0'
s.visionos.pod_target_xcconfig = {
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
}

Comment on lines +33 to +35

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.visionos.deployment_target = '1.0'
s.visionos.pod_target_xcconfig = {
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
}

Comment on lines +33 to +35

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.visionos.deployment_target = '1.0'
s.visionos.pod_target_xcconfig = {
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
}

Comment on lines +33 to +35

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.visionos.deployment_target = '1.0'
s.visionos.pod_target_xcconfig = {
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
}

Comment on lines +33 to +35

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.visionos.deployment_target = '1.0'
s.visionos.pod_target_xcconfig = {
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'

Comment on lines +33 to +35

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.visionos.deployment_target = '1.0'
s.visionos.pod_target_xcconfig = {
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
}

Comment on lines +33 to +35

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.visionos.deployment_target = '1.0'
s.visionos.pod_target_xcconfig = {
'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM PASSKEYS_PLATFORM'
}

}
end
}.package(url: "https://github.com/auth0/Auth0.swift", from: "2.22.0")
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ClientId</key>
<string>VTG0v4XJMwkQsmsJHzHNpVt7jiEsaTHw</string>
<key>Domain</key>
<string>dev-rqdegco5aoxhffiq.us.auth0.com</string>
<key>CallbackMode</key>
<string>custom-scheme</string>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
</dict>import SwiftUI
import Auth0

struct ContentView: View {
// Stores credentials in the Keychain so the session survives app restarts.
private let credentialsManager = CredentialsManager(authentication: Auth0.authentication())

// The user profile is read straight from the stored ID token's claims.
@State private var user: UserInfo?
@State private var isLoading = true
@State private var errorMessage: String?

private static let useUniversalLinks: Bool = {
guard let path = Bundle.main.path(forResource: "Auth0", ofType: "plist"),
let values = NSDictionary(contentsOfFile: path) else {
return false
}
return values["CallbackMode"] as? String == "universal-links"
}()

private func webAuth() -> WebAuth {
let webAuth = Auth0.webAuth()
return Self.useUniversalLinks ? webAuth.useHTTPS() : webAuth
}

var body: some View {
VStack(spacing: 16) {
if isLoading {
Text("Loading...")
} else if let user {
Text("Logged in as \(user.email ?? "unknown")")
.font(.title)
VStack(alignment: .leading, spacing: 4) {
Text("sub: \(user.sub)")
Text("name: \(user.name ?? "")")
Text("email: \(user.email ?? "")")
Text("email_verified: \(user.emailVerified.map(String.init) ?? "")")
Text("nickname: \(user.nickname ?? "")")
Text("picture: \(user.picture?.absoluteString ?? "")")
}
.font(.body)
Button("Log Out", action: logout)
.font(.title3)
} else {
Button("Sign Up") { login(screenHint: "signup") }
.font(.title3)
Button("Log In") { login() }
.font(.title3)
Text(Self.useUniversalLinks
? "Using HTTPS (Universal Links) for callbacks"
: "Using custom URL scheme for callbacks")
.font(.footnote)
.foregroundColor(.secondary)
}
if let errorMessage {
Text(errorMessage).foregroundColor(.red).font(.callout)
}
}
.padding(.horizontal, 16)
// Renew the session from the Keychain on launch. `credentials()` uses the
// stored refresh token to silently renew an expired access token (and stores
// the result), so the session survives past ID token expiry. `user` is read
// from the returned credentials' ID token claims.
.onAppear {
guard credentialsManager.canRenew() else {
isLoading = false
return
}
credentialsManager.credentials { result in
if case .success = result {
user = credentialsManager.user
}
isLoading = false
}
}
}

private func login(screenHint: String? = nil) {
errorMessage = nil
var webAuth = webAuth()
.scope("openid profile email offline_access")
if let screenHint {
webAuth = webAuth.parameters(["screen_hint": screenHint])
}
webAuth.start { result in
switch result {
case .success(let credentials):
errorMessage = nil
_ = credentialsManager.store(credentials: credentials)
user = credentialsManager.user
case .failure(let error):
errorMessage = error.localizedDescription
print("Login failed: \(error)")
}
}
}

private func logout() {
errorMessage = nil
webAuth()
.clearSession { result in
switch result {
case .success:
errorMessage = nil
_ = credentialsManager.clear()
user = nil
case .failure(let error):
errorMessage = error.localizedDescription
print("Logout failed: \(error)")
}
}
}
}

</plist>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated