Skip to content
Merged
Show file tree
Hide file tree
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
Next Next commit
start of implementation
  • Loading branch information
bparrishMines committed Apr 4, 2025
commit 5a6b18f38411d8267a2f99ac7951929197edd305
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2013 The Flutter 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 Darwin

/// Data class used to respond to `SecTrustGetTrustResult`.
///
/// The native method needs to return two values, so this custom class is
/// created to support this.
class GetTrustResultResponse {
let result: SecTrustResultType
let resultCode: OSStatus

init(result: SecTrustResultType, resultCode: OSStatus) {
self.result = result
self.resultCode = resultCode
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2013 The Flutter 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 Foundation

/// ProxyApi implementation for `GetTrustResultResponse`.
///
/// This class may handle instantiating native object instances that are attached to a Dart instance
/// or handle method calls on the associated native class or an instance of that class.
class GetTrustResultResponseProxyAPIDelegate : PigeonApiDelegateGetTrustResultResponse {
func result(pigeonApi: PigeonApiGetTrustResultResponse, pigeonInstance: GetTrustResultResponse) throws -> DartSecTrustResultType {
switch pigeonInstance.result {
case .unspecified:
return .unspecified
case .proceed:
return .proceed
case .deny:
return .deny
case .recoverableTrustFailure:
return .recoverableTrustFailure
case .fatalTrustFailure:
return .fatalTrustFailure
case .otherError:
return .otherError
case .invalid:
return .invalid
case .confirm:
return .confirm
@unknown default:
return .unknown
}
}

func resultCode(pigeonApi: PigeonApiGetTrustResultResponse, pigeonInstance: GetTrustResultResponse) throws -> Int64 {
return Int64(pigeonInstance.resultCode)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,16 @@ class ProxyAPIDelegate: WebKitLibraryPigeonProxyApiDelegate {
return PigeonApiWKWebpagePreferences(
pigeonRegistrar: registrar, delegate: WebpagePreferencesProxyAPIDelegate())
}

func pigeonApiGetTrustResultResponse(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) -> PigeonApiGetTrustResultResponse {
return PigeonApiGetTrustResultResponse(pigeonRegistrar: registrar, delegate: GetTrustResultResponseProxyAPIDelegate())
}

func pigeonApiSecTrust(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) -> PigeonApiSecTrust {
return PigeonApiSecTrust(pigeonRegistrar: registrar, delegate: SecTrustProxyAPIDelegate())
}

func pigeonApiSecCertificate(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) -> PigeonApiSecCertificate {
return PigeonApiSecCertificate(pigeonRegistrar: registrar, delegate: SecCertificateProxyAPIDelegate())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if os(iOS)
import Flutter
import UIKit
#elseif os(macOS)
import FlutterMacOS
import Foundation
#else
#error("Unsupported platform.")
#endif
import Foundation

/// ProxyApi implementation for `SecCertificate`.
///
/// This class may handle instantiating native object instances that are attached to a Dart instance
/// or handle method calls on the associated native class or an instance of that class.
class SecCertificateProxyAPIDelegate : PigeonApiDelegateSecCertificate {
func copyData(pigeonApi: PigeonApiSecCertificate, certificate: SecCertificateWrapper) throws -> FlutterStandardTypedData {
let data = SecCertificateCopyData(certificate.value)
return FlutterStandardTypedData(bytes: data as Data)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if os(iOS)
import Flutter
import UIKit
#elseif os(macOS)
import FlutterMacOS
import Foundation
#else
#error("Unsupported platform.")
#endif
import Foundation

/// ProxyApi implementation for `SecTrust`.
///
/// This class may handle instantiating native object instances that are attached to a Dart instance
/// or handle method calls on the associated native class or an instance of that class.
class SecTrustProxyAPIDelegate : PigeonApiDelegateSecTrust {
func evaluateWithError(pigeonApi: PigeonApiSecTrust, trust: SecTrustWrapper) throws -> Bool {
var error: Unmanaged<CFError>?
let result = SecTrustEvaluateWithError(trust.value, &error)
return result
}

func copyExceptions(pigeonApi: PigeonApiSecTrust, trust: SecTrustWrapper) throws -> FlutterStandardTypedData {
return SecTrust.copyExceptions(trust: trust)
}

func setExceptions(pigeonApi: PigeonApiSecTrust, trust: SecTrustWrapper, exceptions: FlutterStandardTypedData) throws -> Bool {
return SecTrust.setExceptions(trust: trust, exceptions: exceptions)
}

func getTrustResult(pigeonApi: PigeonApiSecTrust, trust: SecTrustWrapper) throws -> GetTrustResultResponse {
return SecTrust.getTrustResult(trust: trust)
}

func copyCertificateChain(pigeonApi: PigeonApiSecTrust, trust: SecTrustWrapper) throws -> [String] {
return SecTrust.copyCertificateChain(trust: trust)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// Wrapper for `SecTrust`.
///
/// Corefoundation types don't support being casted in Swift and will always succeed
/// by default. This wrapper is used to make the class compatible with generated pigeon
/// code. All instances of `SecTrust`should be replaced with this.
class SecTrustWrapper {
let value: SecTrust

init(value: SecTrust) {
self.value = value
}
}

/// Wrapper for `SecCertificate`.
///
/// Corefoundation types don't support being casted in Swift and will always succeed
/// by default. This wrapper is used to make the class compatible with generated pigeon
/// code. All instances of `SecCertificate`should be replaced with this.
class SecCertificateWrapper {
let value: SecCertificate

init(value: SecCertificate) {
self.value = value
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ class URLProtectionSpaceProxyAPIDelegate: PigeonApiDelegateURLProtectionSpace {
) throws -> String? {
return pigeonInstance.authenticationMethod
}

func getServerTrust(pigeonApi: PigeonApiURLProtectionSpace, pigeonInstance: URLProtectionSpace) throws -> SecTrustWrapper? {
if let serverTrust = pigeonInstance.serverTrust {
return SecTrustWrapper(value: serverTrust)
}

return nil
}
}
Loading