@@ -81,7 +81,7 @@ public func encode(_ payload:Payload, algorithm:Algorithm) -> String {
81
81
return nil
82
82
}
83
83
84
- let header = encodeJSON ( [ " typ " : " JWT " as AnyObject , " alg " : algorithm. description as AnyObject ] ) !
84
+ let header = encodeJSON ( [ " typ " : " JWT " , " alg " : algorithm. description] ) !
85
85
let payload = encodeJSON ( payload) !
86
86
let signingInput = " \( header) . \( payload) "
87
87
let signature = algorithm. sign ( signingInput)
@@ -91,25 +91,25 @@ public func encode(_ payload:Payload, algorithm:Algorithm) -> String {
91
91
open class PayloadBuilder {
92
92
var payload = Payload ( )
93
93
94
- open var issuer : String ? {
94
+ open var issuer : String ? {
95
95
get {
96
96
return payload [ " iss " ] as? String
97
97
}
98
98
set {
99
- payload [ " iss " ] = newValue as AnyObject ?
99
+ payload [ " iss " ] = newValue
100
100
}
101
101
}
102
102
103
- open var audience : String ? {
103
+ open var audience : String ? {
104
104
get {
105
105
return payload [ " aud " ] as? String
106
106
}
107
107
set {
108
- payload [ " aud " ] = newValue as AnyObject ?
108
+ payload [ " aud " ] = newValue
109
109
}
110
110
}
111
111
112
- open var expiration : Date ? {
112
+ open var expiration : Date ? {
113
113
get {
114
114
if let expiration = payload [ " exp " ] as? TimeInterval {
115
115
return Date ( timeIntervalSince1970: expiration)
@@ -118,11 +118,11 @@ open class PayloadBuilder {
118
118
return nil
119
119
}
120
120
set {
121
- payload [ " exp " ] = newValue? . timeIntervalSince1970 as AnyObject ?
121
+ payload [ " exp " ] = newValue? . timeIntervalSince1970
122
122
}
123
123
}
124
124
125
- open var notBefore : Date ? {
125
+ open var notBefore : Date ? {
126
126
get {
127
127
if let notBefore = payload [ " nbf " ] as? TimeInterval {
128
128
return Date ( timeIntervalSince1970: notBefore)
@@ -131,11 +131,11 @@ open class PayloadBuilder {
131
131
return nil
132
132
}
133
133
set {
134
- payload [ " nbf " ] = newValue? . timeIntervalSince1970 as AnyObject ?
134
+ payload [ " nbf " ] = newValue? . timeIntervalSince1970
135
135
}
136
136
}
137
137
138
- open var issuedAt : Date ? {
138
+ open var issuedAt : Date ? {
139
139
get {
140
140
if let issuedAt = payload [ " iat " ] as? TimeInterval {
141
141
return Date ( timeIntervalSince1970: issuedAt)
@@ -144,11 +144,11 @@ open class PayloadBuilder {
144
144
return nil
145
145
}
146
146
set {
147
- payload [ " iat " ] = newValue? . timeIntervalSince1970 as AnyObject ?
147
+ payload [ " iat " ] = newValue? . timeIntervalSince1970
148
148
}
149
149
}
150
150
151
- open subscript( key: String ) -> Any {
151
+ open subscript( key: String ) -> Any ? {
152
152
get {
153
153
return payload [ key]
154
154
}
0 commit comments