Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Pod::Spec.new do |s|
s.authors = 'The Chromium Authors'
s.source = { :path => '.' }

s.source_files = 'firebase_auth/Sources/firebase_auth/**/*.{h,m}'
s.public_header_files = 'firebase_auth/Sources/firebase_auth/include/Public/**/*.h'
s.private_header_files = 'firebase_auth/Sources/firebase_auth/include/Private/**/*.h'
s.source_files = 'firebase_auth/Sources/firebase_auth/**/*.swift'

s.swift_version = '5.0'

s.ios.deployment_target = '15.0'
s.dependency 'Flutter'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ let package = Package(
.process("Resources")
],
cSettings: [
.headerSearchPath("include/Private"),
.headerSearchPath("include/Public"),
.define("LIBRARY_VERSION", to: "\"\(libraryVersion)\""),
.define("LIBRARY_NAME", to: "\"flutter-fire-auth\""),
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2025 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

let kFLTFirebaseAuthChannelName = "plugins.flutter.io/firebase_auth"
let kFirebaseAuthLibraryName = "flutter-fire-auth"
let kFirebaseAuthLibraryVersion = "6.5.7"

let kSignInMethodPassword = "password"
let kSignInMethodEmailLink = "emailLink"
let kSignInMethodFacebook = "facebook.com"
let kSignInMethodGoogle = "google.com"
let kSignInMethodGameCenter = "gc.apple.com"
let kSignInMethodTwitter = "twitter.com"
let kSignInMethodGithub = "github.com"
let kSignInMethodApple = "apple.com"
let kSignInMethodPhone = "phone"
let kSignInMethodOAuth = "oauth"

let kErrCodeNoCurrentUser = "no-current-user"
let kErrMsgNoCurrentUser = "No user currently signed in."
let kErrCodeInvalidCredential = "invalid-credential"
let kErrMsgInvalidCredential =
"The supplied auth credential is malformed, has expired or is not currently supported."
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright 2025 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import FirebaseAuth
import Foundation

#if os(iOS)
import Flutter
#elseif os(macOS)
import FlutterMacOS
#endif

enum AuthErrors {
static func convertToFlutterError(_ error: Error?) -> FlutterError {
var code = "unknown"
var message = "An unknown error has occurred."

guard let error = error as NSError? else {
return FlutterError(code: code, message: message, details: [:])
}

if let firebaseErrorCode = error.userInfo[AuthErrorUserInfoNameKey] as? String {
code = firebaseErrorCode.replacingOccurrences(of: "ERROR_", with: "")
.replacingOccurrences(of: "_", with: "-")
.lowercased()
}

if let localized = error.userInfo[NSLocalizedDescriptionKey] as? String {
message = localized
}

var additionalData: [String: Any] = [:]
if let email = error.userInfo[AuthErrorUserInfoEmailKey] as? String {
additionalData["email"] = email
}

let token = FLTFirebaseAuthPlugin.storeAuthCredentialIfPresent(error)
if let authCredential = error.userInfo[AuthErrorUserInfoUpdatedCredentialKey] as? AuthCredential
{
additionalData["authCredential"] = PigeonParser.getPigeonAuthCredential(
authCredential, token: token)
}

if message == "The password must be 6 characters long or more." {
message = "Password should be at least 6 characters"
}

return FlutterError(code: code, message: message, details: additionalData)
}

static func convertAppleAuthorizationErrorToFlutterError(_ error: Error) -> FlutterError {
let nsError = error as NSError
var message = "An unknown error has occurred."
if !nsError.localizedDescription.isEmpty {
message = nsError.localizedDescription
}

var additionalData: [String: Any] = [:]
let nativeErrorDomain = nsError.domain.isEmpty ? "unknown" : nsError.domain
additionalData["nativeErrorDomain"] = nativeErrorDomain
additionalData["nativeErrorCode"] = nsError.code

var underlyingMessage = ""
if let underlyingError = nsError.userInfo[NSUnderlyingErrorKey] as? NSError {
let underlyingErrorDomain =
underlyingError.domain.isEmpty ? "unknown" : underlyingError.domain
additionalData["underlyingNativeErrorDomain"] = underlyingErrorDomain
additionalData["underlyingNativeErrorCode"] = underlyingError.code
underlyingMessage =
", Underlying Domain=\(underlyingErrorDomain) Code=\(underlyingError.code)"
}

let detailMessage =
"\(message) (Domain=\(nativeErrorDomain) Code=\(nsError.code)\(underlyingMessage))"
return FlutterError(code: "unknown", message: detailMessage, details: additionalData)
}

static func noCurrentUser() -> FlutterError {
FlutterError(code: kErrCodeNoCurrentUser, message: kErrMsgNoCurrentUser, details: nil)
}

static func invalidCredential() -> FlutterError {
FlutterError(
code: kErrCodeInvalidCredential, message: kErrMsgInvalidCredential, details: nil)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import FirebaseAuth
import Foundation

#if os(iOS)
import Flutter
#elseif os(macOS)
import FlutterMacOS
#endif

final class FLTAuthStateChannelStreamHandler: NSObject, FlutterStreamHandler {
private let auth: Auth
private var handle: AuthStateDidChangeListenerHandle?

init(auth: Auth) {
self.auth = auth
}

func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink)
-> FlutterError?
{
var initialAuthState = true
handle = auth.addStateDidChangeListener { auth, user in
if initialAuthState {
initialAuthState = false
return
}

if user != nil, let currentUser = auth.currentUser {
events(["user": PigeonParser.getManualList(PigeonParser.getPigeonDetails(currentUser))])
} else {
events(["user": NSNull()])
}
}
return nil
}

func onCancel(withArguments arguments: Any?) -> FlutterError? {
if let handle {
auth.removeStateDidChangeListener(handle)
}
handle = nil
return nil
}
}
Loading
Loading