xtool.git
Publicgit clone https://git.maproj.org/xtool.gitxtool.git / Sources / XKit / GrandSlam / Requests / Concrete / GrandSlamAuthInitRequest.swift
GrandSlamAuthInitRequest.swift44 lines · 1.0 KiBRaw
| 1 | // |
| 2 | // GrandSlamAuthInitRequest.swift |
| 3 | // XKit |
| 4 | // |
| 5 | // Created by Kabir Oberai on 19/11/19. |
| 6 | // Copyright © 2019 Kabir Oberai. All rights reserved. |
| 7 | // |
| 8 | |
| 9 | import Foundation |
| 10 | |
| 11 | struct GrandSlamAuthInitRequest: GrandSlamOperationRequest { |
| 12 | |
| 13 | typealias Decoder = GrandSlamOperationDecoder<Value> |
| 14 | struct Value: Decodable { |
| 15 | let selectedProtocol: GrandSlamAuthProtocol |
| 16 | let cookie: String |
| 17 | let salt: Data |
| 18 | let iterations: Int |
| 19 | let serverPublicKey: Data |
| 20 | |
| 21 | private enum CodingKeys: String, CodingKey { |
| 22 | case selectedProtocol = "sp" |
| 23 | case cookie = "c" |
| 24 | case salt = "s" |
| 25 | case iterations = "i" |
| 26 | case serverPublicKey = "B" |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | static let operation = "init" |
| 31 | |
| 32 | static let protocols: [String] = GrandSlamAuthProtocol.allCases.map { $0.rawValue } |
| 33 | |
| 34 | let username: String |
| 35 | let publicKey: Data |
| 36 | |
| 37 | var parameters: [String: Any] { |
| 38 | [ |
| 39 | "ps": Self.protocols, |
| 40 | "A2k": publicKey, |
| 41 | ] |
| 42 | } |
| 43 | |
| 44 | } |