Skip to content

Commit 6729371

Browse files
committed
feat: Add support for Linux
Closes #51
1 parent 50d8236 commit 6729371

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Sources/Base64.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Foundation
44
/// URI Safe base64 encode
55
func base64encode(_ input:Data) -> String {
66
let data = input.base64EncodedData(options: NSData.Base64EncodingOptions(rawValue: 0))
7-
let string = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as! String
7+
let string = String(data: data, encoding: .utf8)!
88
return string
99
.replacingOccurrences(of: "+", with: "-", options: NSString.CompareOptions(rawValue: 0), range: nil)
1010
.replacingOccurrences(of: "/", with: "_", options: NSString.CompareOptions(rawValue: 0), range: nil)

Sources/JWT.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public func encode(_ payload:Payload, algorithm:Algorithm) -> String {
8181
return nil
8282
}
8383

84-
let header = encodeJSON(["typ": "JWT" as AnyObject, "alg": algorithm.description as AnyObject])!
84+
let header = encodeJSON(["typ": "JWT", "alg": algorithm.description])!
8585
let payload = encodeJSON(payload)!
8686
let signingInput = "\(header).\(payload)"
8787
let signature = algorithm.sign(signingInput)
@@ -91,25 +91,25 @@ public func encode(_ payload:Payload, algorithm:Algorithm) -> String {
9191
open class PayloadBuilder {
9292
var payload = Payload()
9393

94-
open var issuer:String? {
94+
open var issuer: String? {
9595
get {
9696
return payload["iss"] as? String
9797
}
9898
set {
99-
payload["iss"] = newValue as AnyObject?
99+
payload["iss"] = newValue
100100
}
101101
}
102102

103-
open var audience:String? {
103+
open var audience: String? {
104104
get {
105105
return payload["aud"] as? String
106106
}
107107
set {
108-
payload["aud"] = newValue as AnyObject?
108+
payload["aud"] = newValue
109109
}
110110
}
111111

112-
open var expiration:Date? {
112+
open var expiration: Date? {
113113
get {
114114
if let expiration = payload["exp"] as? TimeInterval {
115115
return Date(timeIntervalSince1970: expiration)
@@ -118,11 +118,11 @@ open class PayloadBuilder {
118118
return nil
119119
}
120120
set {
121-
payload["exp"] = newValue?.timeIntervalSince1970 as AnyObject?
121+
payload["exp"] = newValue?.timeIntervalSince1970
122122
}
123123
}
124124

125-
open var notBefore:Date? {
125+
open var notBefore: Date? {
126126
get {
127127
if let notBefore = payload["nbf"] as? TimeInterval {
128128
return Date(timeIntervalSince1970: notBefore)
@@ -131,11 +131,11 @@ open class PayloadBuilder {
131131
return nil
132132
}
133133
set {
134-
payload["nbf"] = newValue?.timeIntervalSince1970 as AnyObject?
134+
payload["nbf"] = newValue?.timeIntervalSince1970
135135
}
136136
}
137137

138-
open var issuedAt:Date? {
138+
open var issuedAt: Date? {
139139
get {
140140
if let issuedAt = payload["iat"] as? TimeInterval {
141141
return Date(timeIntervalSince1970: issuedAt)
@@ -144,11 +144,11 @@ open class PayloadBuilder {
144144
return nil
145145
}
146146
set {
147-
payload["iat"] = newValue?.timeIntervalSince1970 as AnyObject?
147+
payload["iat"] = newValue?.timeIntervalSince1970
148148
}
149149
}
150150

151-
open subscript(key: String) -> Any {
151+
open subscript(key: String) -> Any? {
152152
get {
153153
return payload[key]
154154
}

0 commit comments

Comments
 (0)