-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[webview_flutter_wkwebview] Fixes loadFlutterAsset exception and updates native wrapper for SecTrust and SecCertificate
#9016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5a6b18f
start of implementation
bparrishMines c724beb
finish implementations
bparrishMines 86d6f62
update protectionspace tests
bparrishMines b8608b1
all swift tests
bparrishMines 364dbcf
move call to background thread
bparrishMines 2cc5c3d
move tests for ios to darwin
bparrishMines 879aecb
fix macos build
bparrishMines ff51a5c
update project pbxproj
bparrishMines 637d376
fix tests on macos
bparrishMines 5c53007
formatting and regen
bparrishMines fecf4ca
add integration test
bparrishMines d28bf6b
unused imports and bad comments
bparrishMines b90ecc8
fix format
bparrishMines 51d2286
version bump
bparrishMines 52c530b
add security imports
bparrishMines ddca458
add docs
bparrishMines 2469fec
remove any
bparrishMines 8611414
unused import and better test name
bparrishMines 1f7e55f
Merge branch 'main' of github.com:flutter/packages into sec_methods
bparrishMines f0f4579
proper fix
bparrishMines File filter
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
commit 5a6b18f38411d8267a2f99ac7951929197edd305
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
.../webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/GetTrustResultResponse.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
..._wkwebview/Sources/webview_flutter_wkwebview/GetTrustResultResponseProxyAPIDelegate.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
..._flutter_wkwebview/Sources/webview_flutter_wkwebview/SecCertificateProxyAPIDelegate.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } | ||
| } | ||
42 changes: 42 additions & 0 deletions
42
...ebview_flutter_wkwebview/Sources/webview_flutter_wkwebview/SecTrustProxyAPIDelegate.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
bparrishMines marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #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) | ||
| } | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
...view/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/SecWrappers.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.