Skip to content

Commit

Permalink
Update to use NSSecureCoding protocol (#1509)
Browse files Browse the repository at this point in the history
* update to use NSSecureCoding
  • Loading branch information
jaxdesmarais authored Feb 5, 2025
1 parent d33df60 commit e6660db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## unreleased
* BraintreeVenmo
* Allow universal links to be set without a return URL scheme (fixes #1505)
* BraintreeCore
* Update to use `NSSecureCoding` protocol (fixes #1508)
* BraintreePayPal
* Add `shopperSessionID` to `BTPayPalCheckoutRequest` and `BTPayPalVaultRequest`
* BraintreeShopperInsights (BETA)
Expand Down
8 changes: 5 additions & 3 deletions Sources/BraintreeCore/Authorization/BTClientToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

/// An authorization string used to initialize the Braintree SDK
@_documentation(visibility: private)
@objcMembers public class BTClientToken: NSObject, NSCoding, NSCopying, ClientAuthorization {
@objcMembers public class BTClientToken: NSObject, NSSecureCoding, NSCopying, ClientAuthorization {

// NEXT_MAJOR_VERSION (v7): properties exposed for Objective-C interoperability + Drop-in access.
// Once the entire SDK is in Swift, determine if we want public properties to be internal and
Expand Down Expand Up @@ -86,15 +86,17 @@ import Foundation
return BTJSON(value: clientTokenJSON)
}

// MARK: - NSCoding conformance
// MARK: - NSSecureCoding conformance

public static var supportsSecureCoding: Bool = true

public func encode(with coder: NSCoder) {
coder.encode(originalValue, forKey: "originalValue")
}

public required convenience init?(coder: NSCoder) {
try? self.init(
clientToken: coder.decodeObject(forKey: "originalValue") as? String ?? ""
clientToken: coder.decodeObject(of: NSString.self, forKey: "originalValue") as? String ?? ""
)
}

Expand Down

0 comments on commit e6660db

Please sign in to comment.