Skip to content

Commit

Permalink
Removed old NSSecureCoding conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Sosna committed Sep 9, 2024
1 parent 6b18d73 commit 9c51669
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions Auth0/Credentials.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,42 +155,3 @@ extension Credentials: Codable {
try values.encode(expiresIn.timeIntervalSinceNow, forKey: .expiresIn)
}
}

// MARK: - NSSecureCoding

extension Credentials: NSSecureCoding {

/// `NSSecureCoding` decoding initializer.
public convenience init?(coder aDecoder: NSCoder) {
let accessToken = aDecoder.decodeObject(of: NSString.self, forKey: "accessToken")
let tokenType = aDecoder.decodeObject(of: NSString.self, forKey: "tokenType")
let idToken = aDecoder.decodeObject(of: NSString.self, forKey: "idToken")
let refreshToken = aDecoder.decodeObject(of: NSString.self, forKey: "refreshToken")
let expiresIn = aDecoder.decodeObject(of: NSDate.self, forKey: "expiresIn")
let scope = aDecoder.decodeObject(of: NSString.self, forKey: "scope")
let recoveryCode = aDecoder.decodeObject(of: NSString.self, forKey: "recoveryCode")

self.init(accessToken: accessToken as String? ?? "",
tokenType: tokenType as String? ?? "",
idToken: idToken as String? ?? "",
refreshToken: refreshToken as String?,
expiresIn: expiresIn as Date? ?? Date(),
scope: scope as String?,
recoveryCode: recoveryCode as String?)
}

/// `NSSecureCoding` encoding method.
public func encode(with aCoder: NSCoder) {
aCoder.encode(self.accessToken as NSString, forKey: "accessToken")
aCoder.encode(self.tokenType as NSString, forKey: "tokenType")
aCoder.encode(self.idToken as NSString, forKey: "idToken")
aCoder.encode(self.refreshToken as NSString?, forKey: "refreshToken")
aCoder.encode(self.expiresIn as NSDate, forKey: "expiresIn")
aCoder.encode(self.scope as NSString?, forKey: "scope")
aCoder.encode(self.recoveryCode as NSString?, forKey: "recoveryCode")
}

/// Property that enables secure coding. Equals to `true`.
public static var supportsSecureCoding: Bool { return true }

}

0 comments on commit 9c51669

Please sign in to comment.