LineSDKJWT.swift 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // LineSDKJWT.swift
  3. //
  4. // Copyright (c) 2016-present, LY Corporation. All rights reserved.
  5. //
  6. // You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
  7. // copy and distribute this software in source code or binary form for use
  8. // in connection with the web services and APIs provided by LY Corporation.
  9. //
  10. // As with any software that integrates with the LY Corporation platform, your use of this software
  11. // is subject to the LINE Developers Agreement [http://terms2.line.me/LINE_Developers_Agreement].
  12. // This copyright notice shall be included in all copies or substantial portions of the software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  15. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  17. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. //
  21. @objcMembers
  22. public class LineSDKJWT: NSObject {
  23. public let payload: LineSDKJWTPayload
  24. init(_ value: JWT) {
  25. payload = LineSDKJWTPayload(value.payload)
  26. }
  27. }
  28. @objcMembers
  29. public class LineSDKJWTPayload: NSObject {
  30. let value: JWT.Payload
  31. init(_ value: JWT.Payload) {
  32. self.value = value
  33. }
  34. public func getString(forKey key: String) -> String? {
  35. return value[key, String.self]
  36. }
  37. public func getNumber(forKey key: String) -> NSNumber? {
  38. if let value = value[key, Int.self] {
  39. return .init(value: value)
  40. } else if let value = value[key, Int.self] {
  41. return .init(value: value)
  42. } else if let value = value[key, Int.self] {
  43. return .init(value: value)
  44. } else {
  45. return nil
  46. }
  47. }
  48. public var issuer: String? { return value.issuer }
  49. public var subject: String? { return value.subject }
  50. public var audience: String? { return value.audience }
  51. public var expiration: Date? { return value.expiration }
  52. public var issueAt: Date? { return value.issueAt }
  53. public var name: String? { return value.name }
  54. public var picture: URL? { return value.pictureURL }
  55. public var email: String? { return value.email }
  56. public var amr: [String]? { return value.amr }
  57. }