From e6660dbb5aa9b58b72f5821a8377e6326f5f0fd5 Mon Sep 17 00:00:00 2001 From: Jax DesMarais-Leder Date: Wed, 5 Feb 2025 09:14:35 -0600 Subject: [PATCH] Update to use `NSSecureCoding` protocol (#1509) * update to use NSSecureCoding --- CHANGELOG.md | 2 ++ Sources/BraintreeCore/Authorization/BTClientToken.swift | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fc54a42fc..970c62bbc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Sources/BraintreeCore/Authorization/BTClientToken.swift b/Sources/BraintreeCore/Authorization/BTClientToken.swift index 061ae0539c..aed9ae5e80 100644 --- a/Sources/BraintreeCore/Authorization/BTClientToken.swift +++ b/Sources/BraintreeCore/Authorization/BTClientToken.swift @@ -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 @@ -86,7 +86,9 @@ 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") @@ -94,7 +96,7 @@ import Foundation 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 ?? "" ) }