├── IpfsApi ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── PathModel.swift │ ├── KeysModel.swift │ ├── LsModel.swift │ ├── PeersModel.swift │ ├── DiffsModel.swift │ ├── KeypairsModel.swift │ ├── MessageModel.swift │ ├── EntriesModel.swift │ ├── StreamsModel.swift │ ├── StringsModel.swift │ ├── CommandOptionsModel.swift │ ├── ListenersModel.swift │ ├── PinnedObjectsModel.swift │ ├── ReferenceModel.swift │ ├── ResponseRepoVersionModel.swift │ ├── ResponseSwarmPeersModel.swift │ ├── BlockModel.swift │ ├── ResponseMessageInfoModel.swift │ ├── ResponseRepoGcModel.swift │ ├── AddressModel.swift │ ├── PinsModel.swift │ ├── ResponseBitswapRmModel.swift │ ├── ListenerModel.swift │ ├── PinStatusModel.swift │ ├── FileLsModel.swift │ ├── ResponsePinVerifyModel.swift │ ├── ResponseRepoVerifyModel.swift │ ├── IPNSModel.swift │ ├── CidModel.swift │ ├── MountModel.swift │ ├── DiffModel.swift │ ├── ResponsePingModel.swift │ ├── CommandModel.swift │ ├── ArgumentsFilesCpModel.swift │ ├── ArgumentsPubsubPubModel.swift │ ├── ArgumentsFilesMvModel.swift │ ├── PeerModel.swift │ ├── ResponseStatsBwModel.swift │ ├── ArgumentsObjectPatchRmLinkModel.swift │ ├── ResponseDhtModel.swift │ ├── ArgumentsP2pListenerOpenModel.swift │ ├── ResponseVersionModel.swift │ ├── ArgumentsKeyRmModel.swift │ ├── ArgumentsIdModel.swift │ ├── ArgumentsFilesLsModel.swift │ ├── ArgumentsFilesRmModel.swift │ ├── ArgumentsPingModel.swift │ ├── ArgumentsP2pStreamCloseModel.swift │ ├── ArgumentsDhtGetModel.swift │ ├── KeypairModel.swift │ ├── ArgumentsP2pListenerCloseModel.swift │ ├── MessageInfoModel.swift │ ├── ArgumentsDhtQueryModel.swift │ ├── ArgumentsFilesMkdirModel.swift │ ├── ArgumentsResolveModel.swift │ ├── IDInfoModel.swift │ ├── ArgumentsDhtFindpeerModel.swift │ ├── ArgumentsPinVerifyModel.swift │ ├── ArgumentsDnsModel.swift │ ├── FilestoreObjectModel.swift │ ├── ResponseRepoStatModel.swift │ ├── ArgumentsPubsubSubModel.swift │ ├── ArgumentsPinRmModel.swift │ ├── ResponseBitswapLedgerModel.swift │ ├── ObjectStatModel.swift │ ├── ArgumentsLogLevelModel.swift │ ├── StreamModel.swift │ ├── ArgumentsObjectLinksModel.swift │ ├── ArgumentsObjectDiffModel.swift │ ├── ArgumentsKeyRenameModel.swift │ ├── ArgumentsDhtPutModel.swift │ ├── ArgumentsPinUpdateModel.swift │ ├── ArgumentsKeyGenModel.swift │ ├── ArgumentsFilesReadModel.swift │ ├── ArgumentsFilestoreLsModel.swift │ ├── ArgumentsBlockRmModel.swift │ ├── ArgumentsRepoGcModel.swift │ ├── ArgumentsMountModel.swift │ ├── ArgumentsFilestoreVerifyModel.swift │ ├── ArgumentsP2pStreamDialModel.swift │ ├── ArgumentsPinAddModel.swift │ ├── ArgumentsDhtProvideModel.swift │ ├── ArgumentsObjectPatchAddLinkModel.swift │ ├── ArgumentsPinLsModel.swift │ ├── ArgumentsSwarmPeersModel.swift │ ├── ArgumentsNameResolveModel.swift │ ├── ObjectModel.swift │ ├── ArgumentsObjectPutModel.swift │ ├── ArgumentsBlockPutModel.swift │ ├── ResponseBitswapStatModel.swift │ ├── ArgumentsVersionModel.swift │ ├── ArgumentsDhtFindprovsModel.swift │ ├── ArgumentsLsModel.swift │ ├── ArgumentsFilesWriteModel.swift │ ├── ArgumentsStatsBwModel.swift │ ├── ArgumentsDagPutModel.swift │ ├── ArgumentsFilesStatModel.swift │ ├── ArgumentsNamePublishModel.swift │ ├── ArgumentsGetModel.swift │ └── ArgumentsAddModel.swift ├── Cartfile ├── _Pods.xcodeproj ├── Example ├── Pods │ ├── Target Support Files │ │ ├── Moya │ │ │ ├── Moya.modulemap │ │ │ ├── Moya-dummy.m │ │ │ ├── Moya-prefix.pch │ │ │ ├── Moya-umbrella.h │ │ │ ├── Moya.xcconfig │ │ │ └── Info.plist │ │ ├── Result │ │ │ ├── Result.modulemap │ │ │ ├── Result-dummy.m │ │ │ ├── Result-prefix.pch │ │ │ ├── Result-umbrella.h │ │ │ ├── Result.xcconfig │ │ │ └── Info.plist │ │ ├── IpfsApi │ │ │ ├── IpfsApi.modulemap │ │ │ ├── IpfsApi-dummy.m │ │ │ ├── IpfsApi-prefix.pch │ │ │ ├── IpfsApi-umbrella.h │ │ │ ├── IpfsApi.xcconfig │ │ │ └── Info.plist │ │ ├── Alamofire │ │ │ ├── Alamofire.modulemap │ │ │ ├── Alamofire-dummy.m │ │ │ ├── Alamofire-prefix.pch │ │ │ ├── Alamofire-umbrella.h │ │ │ ├── Alamofire.xcconfig │ │ │ └── Info.plist │ │ ├── Pods-IpfsApi_Tests │ │ │ ├── Pods-IpfsApi_Tests.modulemap │ │ │ ├── Pods-IpfsApi_Tests-acknowledgements.markdown │ │ │ ├── Pods-IpfsApi_Tests-dummy.m │ │ │ ├── Pods-IpfsApi_Tests-acknowledgements.plist │ │ │ ├── Pods-IpfsApi_Tests-umbrella.h │ │ │ ├── Info.plist │ │ │ ├── Pods-IpfsApi_Tests.debug.xcconfig │ │ │ └── Pods-IpfsApi_Tests.release.xcconfig │ │ └── Pods-IpfsApi_Example │ │ │ ├── Pods-IpfsApi_Example.modulemap │ │ │ ├── Pods-IpfsApi_Example-dummy.m │ │ │ ├── Pods-IpfsApi_Example-acknowledgements.plist │ │ │ ├── Pods-IpfsApi_Example-umbrella.h │ │ │ ├── Info.plist │ │ │ ├── Pods-IpfsApi_Example.debug.xcconfig │ │ │ └── Pods-IpfsApi_Example.release.xcconfig │ ├── Moya │ │ ├── Sources │ │ │ └── Moya │ │ │ │ ├── Image.swift │ │ │ │ ├── AnyEncodable.swift │ │ │ │ ├── URL+Moya.swift │ │ │ │ ├── Cancellable.swift │ │ │ │ ├── Plugins │ │ │ │ ├── CredentialsPlugin.swift │ │ │ │ ├── NetworkActivityPlugin.swift │ │ │ │ ├── AccessTokenPlugin.swift │ │ │ │ └── NetworkLoggerPlugin.swift │ │ │ │ ├── URLRequest+Encoding.swift │ │ │ │ ├── TargetType.swift │ │ │ │ ├── ValidationType.swift │ │ │ │ ├── MultiTarget.swift │ │ │ │ ├── MoyaProvider+Defaults.swift │ │ │ │ ├── Task.swift │ │ │ │ ├── Plugin.swift │ │ │ │ ├── MultipartFormData.swift │ │ │ │ ├── MoyaError.swift │ │ │ │ └── Moya+Alamofire.swift │ │ └── License.md │ ├── Local Podspecs │ │ └── IpfsApi.podspec.json │ ├── Result │ │ ├── LICENSE │ │ └── README.md │ ├── Alamofire │ │ ├── LICENSE │ │ └── Source │ │ │ ├── DispatchQueue+Alamofire.swift │ │ │ └── Notifications.swift │ └── Manifest.lock ├── IpfsApi.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── IpfsApi-Example.xcscheme ├── IpfsApi │ ├── ModelProtocol.swift │ ├── Peer.swift │ ├── DemoCell.swift │ ├── Cell.swift │ ├── PeerCell.swift │ ├── ViewModel.swift │ ├── ListVCProtocol.swift │ ├── Pinned.swift │ ├── Demo.swift │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── TextFieldVC.swift │ ├── ListVC.swift │ ├── Info.plist │ ├── PinnedLSC.swift │ ├── DemoLSC.swift │ ├── PeerLSC.swift │ ├── PinnedCell.swift │ ├── PeersVC.swift │ ├── PinnedVC.swift │ ├── AppDelegate.swift │ ├── ViewController.swift │ └── Base.lproj │ │ └── LaunchScreen.xib ├── IpfsApi.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Tests │ ├── Info.plist │ └── Tests.swift └── Podfile ├── Cartfile.resolved ├── ios-ipfs-api.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── ios-ipfs-api.xcscheme ├── .travis.yml ├── ios-ipfs-api ├── ios_ipfs_api.h └── Info.plist ├── .gitignore ├── LICENSE ├── IpfsApi.podspec └── README.md /IpfsApi/Assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /IpfsApi/Classes/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Cartfile: -------------------------------------------------------------------------------- 1 | github "Moya/Moya" 2 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Moya/Moya.modulemap: -------------------------------------------------------------------------------- 1 | framework module Moya { 2 | umbrella header "Moya-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Moya/Moya-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Moya : NSObject 3 | @end 4 | @implementation PodsDummy_Moya 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Result/Result.modulemap: -------------------------------------------------------------------------------- 1 | framework module Result { 2 | umbrella header "Result-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/IpfsApi/IpfsApi.modulemap: -------------------------------------------------------------------------------- 1 | framework module Ipfs { 2 | umbrella header "IpfsApi-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Result/Result-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Result : NSObject 3 | @end 4 | @implementation PodsDummy_Result 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap: -------------------------------------------------------------------------------- 1 | framework module Alamofire { 2 | umbrella header "Alamofire-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/IpfsApi/IpfsApi-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_IpfsApi : NSObject 3 | @end 4 | @implementation PodsDummy_IpfsApi 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Alamofire : NSObject 3 | @end 4 | @implementation PodsDummy_Alamofire 5 | @end 6 | -------------------------------------------------------------------------------- /Cartfile.resolved: -------------------------------------------------------------------------------- 1 | github "Alamofire/Alamofire" "4.7.3" 2 | github "Moya/Moya" "11.0.2" 3 | github "ReactiveCocoa/ReactiveSwift" "3.1.0" 4 | github "ReactiveX/RxSwift" "4.2.0" 5 | github "antitypical/Result" "3.2.4" 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Tests/Pods-IpfsApi_Tests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_IpfsApi_Tests { 2 | umbrella header "Pods-IpfsApi_Tests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Example/Pods-IpfsApi_Example.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_IpfsApi_Example { 2 | umbrella header "Pods-IpfsApi_Example-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Tests/Pods-IpfsApi_Tests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Tests/Pods-IpfsApi_Tests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_IpfsApi_Tests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_IpfsApi_Tests 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Example/Pods-IpfsApi_Example-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_IpfsApi_Example : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_IpfsApi_Example 5 | @end 6 | -------------------------------------------------------------------------------- /Example/IpfsApi.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/IpfsApi/ModelProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ModelProtocol.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 9. 6.. 6 | // 7 | 8 | import Foundation 9 | public protocol ModelProtocol { 10 | var id: NSString { get } 11 | } 12 | -------------------------------------------------------------------------------- /ios-ipfs-api.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Tests/Pods-IpfsApi_Tests-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Moya/Moya-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Example/Pods-IpfsApi_Example-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/IpfsApi/IpfsApi-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Result/Result-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/IpfsApi.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/IpfsApi.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /IpfsApi/Classes/PathModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PathModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PathModel: Codable { 11 | public let path: String? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case path = "Path" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ios-ipfs-api.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /IpfsApi/Classes/KeysModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KeysModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct KeysModel: Codable { 11 | public let keys: [String]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case keys = "Keys" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/Image.swift: -------------------------------------------------------------------------------- 1 | #if os(iOS) || os(watchOS) || os(tvOS) 2 | import UIKit.UIImage 3 | public typealias ImageType = UIImage 4 | #elseif os(OSX) 5 | import AppKit.NSImage 6 | public typealias ImageType = NSImage 7 | #endif 8 | 9 | /// An alias for the SDK's image type. 10 | public typealias Image = ImageType 11 | -------------------------------------------------------------------------------- /IpfsApi/Classes/LsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct LsModel: Codable { 11 | public let objects: [ObjectModel]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case objects = "Objects" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/PeersModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PeersModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PeersModel: Codable { 11 | public let peers: [String]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case peers = "Peers" 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /IpfsApi/Classes/DiffsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DiffsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct DiffsModel: Codable { 11 | public let changes: [DiffModel]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case changes = "Changes" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/KeypairsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KeypairsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct KeypairsModel: Codable { 11 | public let keys: [KeypairModel]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case keys = "Keys" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/MessageModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MessageModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct MessageModel: Codable { 11 | public let message: String? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case message = "Message" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/EntriesModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EntriesModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct EntriesModel: Codable{ 11 | public let entries: [ObjectModel]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case entries = "Entries" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/StreamsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StreamsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct StreamsModel: Codable { 11 | public let streams: [StreamModel]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case streams = "Streams" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/StringsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StringsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct StringsModel: Codable { 11 | public let strings: [String]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case strings = "Strings" 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /IpfsApi/Classes/CommandOptionsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CommandOptionsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct CommandOptionsModel: Codable { 11 | public let names: [String]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case names = "Names" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/AnyEncodable.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AnyEncodable: Encodable { 4 | 5 | private let encodable: Encodable 6 | 7 | public init(_ encodable: Encodable) { 8 | self.encodable = encodable 9 | } 10 | 11 | func encode(to encoder: Encoder) throws { 12 | try encodable.encode(to: encoder) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ListenersModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListenersModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ListenersModel: Codable { 11 | public let listeners: [ListenerModel]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case listeners = "Listeners" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/PinnedObjectsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PinnedObjectsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PinnedObjectsModel: Codable { 11 | public let keys: [String:ObjectModel]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case keys = "Keys" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ReferenceModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ReferenceModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ReferenceModel: Codable { 11 | public let ref, error: String? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case ref = "Ref" 15 | case error = "Err" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseRepoVersionModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseRepoVersionModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseRepoVersionModel: Codable { 11 | public let version: String? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case version = "Version" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseSwarmPeersModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseSwarmPeersModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseSwarmPeersModel: Codable { 11 | public let peers: [PeerModel]? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case peers = "Peers" 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /IpfsApi/Classes/BlockModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BlockModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct BlockModel: Codable { 11 | public let key: String? 12 | public let size: Int? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case key = "Key" 16 | case size = "Size" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseMessageInfoModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseMessageInfoModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseMessageInfoModel: Codable { 11 | public let message: MessageInfoModel? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case message = "Message" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseRepoGcModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseRepoGcModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseRepoGcModel: Codable { 11 | public let key, error: String? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case key = "Key" 15 | case error = "Error" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /IpfsApi/Classes/AddressModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AddressModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct AddressModel: Codable { 11 | public let id: String? 12 | public let addrs: [String]? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case id = "ID" 16 | case addrs = "Addrs" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IpfsApi/Classes/PinsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PinsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PinsModel: Codable { 11 | public let pins: [String]? 12 | public let progress: Int? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case pins = "Pins" 16 | case progress = "Progress" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseBitswapRmModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseBitswapRmModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseBlockRmModel: Codable { 11 | public let hash, error: String? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case hash = "Hash" 15 | case error = "Error" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Moya/Moya-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double MoyaVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char MoyaVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/IpfsApi/IpfsApi-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double IpfsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char IpfsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Result/Result-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double ResultVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char ResultVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ListenerModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListenerModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ListenerModel: Codable { 11 | public let listenerProtocol, address: String? 12 | 13 | enum CodingKeys: String, CodingKey { 14 | case listenerProtocol = "Protocol" 15 | case address = "Address" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /IpfsApi/Classes/PinStatusModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PinStatusModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PinStatusModel: Codable { 11 | public let ok: Bool? 12 | public let badNodes: [CidModel]? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case ok = "Ok" 16 | case badNodes = "BadNodes" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double AlamofireVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char AlamofireVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/IpfsApi/Peer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Peer.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 6.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import IGListKit 11 | import Ipfs 12 | 13 | extension PeerModel : ModelProtocol { 14 | public var id: NSString { 15 | return self.addr! as NSString 16 | } 17 | } 18 | 19 | class PeerVM: ViewModel { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/FileLsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FileLsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct FileLsModel: Codable{ 11 | public let arguments: [String:String]? 12 | public let objects: [String:ObjectModel]? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case arguments = "Arguments" 16 | case objects = "Objects" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponsePinVerifyModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponsePinVerifyModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponsePinVerifyModel: Codable { 11 | public let cid: String? 12 | public let pinStatus: PinStatusModel? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case cid = "Cid" 16 | case pinStatus = "PinStatus" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseRepoVerifyModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseRepoVerifyModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseRepoVerifyModel: Codable { 11 | public let message: String? 12 | public let progress: Int? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case message = "Message" 16 | case progress = "Progress" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IpfsApi/Classes/IPNSModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IPNSModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct IPNSModel: Codable { 11 | public let name: String? 12 | public let value: String? 13 | public let path: String? 14 | 15 | enum CodingKeys: String, CodingKey { 16 | case name = "Name" 17 | case value = "Value" 18 | case path = "Path" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Tests/Pods-IpfsApi_Tests-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_IpfsApi_TestsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_IpfsApi_TestsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/CidModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CidModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct CidModel: Codable { 11 | public let cid: String? 12 | public let remPath: String? 13 | public let error: String? 14 | 15 | enum CodingKeys: String, CodingKey { 16 | case cid = "Cid" 17 | case remPath = "RemPath" 18 | case error = "Err" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /IpfsApi/Classes/MountModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MountModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct MountModel: Codable { 11 | public let ipfs, ipns: String? 12 | public let fuseAllowOther: Bool? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case ipfs = "IPFS" 16 | case ipns = "IPNS" 17 | case fuseAllowOther = "FuseAllowOther" 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Example/Pods-IpfsApi_Example-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_IpfsApi_ExampleVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_IpfsApi_ExampleVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /IpfsApi/Classes/DiffModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DiffModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct DiffModel: Codable { 11 | public let type: Int? 12 | public let path, before, after: String? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case type = "Type" 16 | case path = "Path" 17 | case before = "Before" 18 | case after = "After" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Example/IpfsApi/DemoCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DemoCell.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 6.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class DemoCell: Cell { 12 | typealias Item = DemoVM 13 | @IBOutlet weak var titleLabel: UILabel! 14 | override func update(_ item: Item? = nil) { 15 | guard let item = item else { return } 16 | self.titleLabel.text = item.title 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponsePingModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponsePingModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponsePingModel: Codable { 11 | public let success: Bool? 12 | public let time: Int64? 13 | public let text: String? 14 | 15 | enum CodingKeys: String, CodingKey { 16 | case success = "Success" 17 | case time = "Time" 18 | case text = "Text" 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/CommandModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CommandModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct CommandModel: Codable { 11 | public let name: String? 12 | public let subcommands: [CommandModel]? 13 | public let options: [CommandOptionsModel]? 14 | 15 | enum CodingKeys: String, CodingKey { 16 | case name = "Name" 17 | case subcommands = "Subcommands" 18 | case options = "Options" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilesCpModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilesCpModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilesCpModel: Codable { 11 | // arg [string]: Source object to copy. Required: yes. 12 | // arg [string]: Destination to copy object to. Required: yes. 13 | public let arg: [String] 14 | 15 | init(source: String, 16 | dest: String) { 17 | self.arg = [source, dest] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsPubsubPubModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsPubsubPubModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsPubsubPubModel: Codable { 11 | // arg [string]: Topic to publish to. Required: yes. 12 | // arg [string]: Payload of message to publish. Required: yes. 13 | public let arg: [String] 14 | 15 | init(topic: String, 16 | data: String) { 17 | self.arg = [topic, data] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilesMvModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilesMvModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilesMvModel: Codable { 11 | // arg [string]: Source file to move. Required: yes. 12 | // arg [string]: Destination path for file to be moved to. Required: yes. 13 | public let arg: [String] 14 | 15 | init(source: String, 16 | dest: String) { 17 | self.arg = [source, dest] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IpfsApi/Classes/PeerModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PeerModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct PeerModel: Codable { 11 | public let addr, peer, latency, muxer: String? 12 | public let streams: [StreamModel]? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case addr = "Addr" 16 | case peer = "Peer" 17 | case latency = "Latency" 18 | case muxer = "Muxer" 19 | case streams = "Streams" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Result/Result.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Result 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -suppress-warnings 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Result 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseStatsBwModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseStatsBwModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseStatsBWModel: Codable { 11 | public let totalIn, totalOut: Int64? 12 | public let rateIn, rateOut: Float64? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case totalIn = "TotalIn" 16 | case totalOut = "TotalOut" 17 | case rateIn = "RateIn" 18 | case rateOut = "RateOut" 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Example/IpfsApi/Cell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Cell.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 4.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | class Cell: UICollectionViewCell { 13 | typealias Item = T 14 | override var isHighlighted: Bool { 15 | didSet { 16 | self.contentView.backgroundColor = isHighlighted ? UIColor(white: 0.0, alpha: 0.02) : .white 17 | } 18 | } 19 | func update(_ item: Item? = nil) { 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Alamofire 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -suppress-warnings 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Alamofire 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsObjectPatchRmLinkModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsObjectPatchRmLinkModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsObjectPatchRmLinkModel: Codable { 11 | // arg [string]: The hash of the node to modify. Required: yes. 12 | // arg [string]: Name of the link to remove. Required: yes. 13 | public let arg: [String] 14 | 15 | init(root: String, 16 | link: String) { 17 | self.arg = [root, link] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseDhtModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseDhtModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseDhtModel: Codable { 11 | public let id: String? 12 | public let type: Int? 13 | public let responses: [AddressModel]? 14 | public let extra: String? 15 | 16 | enum CodingKeys: String, CodingKey { 17 | case id = "ID" 18 | case type = "Type" 19 | case responses = "Responses" 20 | case extra = "Extra" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsP2pListenerOpenModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsP2pListenerOpenModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsP2pListenerOpenModel: Codable { 11 | // arg [string]: Protocol identifier. Required: yes. 12 | // arg [string]: Request handling application address. Required: yes. 13 | public let arg: [String] 14 | 15 | init(protocolID: String, 16 | address: String) { 17 | self.arg = [protocolID, address] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseVersionModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseVersionModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseVersionModel: Codable { 11 | public let version, commit, repo, system: String? 12 | public let golang: String? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case version = "Version" 16 | case commit = "Commit" 17 | case repo = "Repo" 18 | case system = "System" 19 | case golang = "Golang" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsKeyRmModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsKeyRmModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsKeyRmModel: Codable { 11 | // arg [string]: names of keys to remove Required: yes. 12 | public let arg: String 13 | // l [bool]: Show extra information about keys. Required: no. 14 | public let l: Bool? 15 | 16 | init(name: String, 17 | information: Bool? = nil) { 18 | self.arg = name 19 | self.l = information 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsIdModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsIdModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsIdModel: Codable { 11 | // arg [string]: Peer.ID of node to look up. Required: no. 12 | public let arg: String? 13 | // format [string]: Optional output format. Required: no. 14 | public let format: String? 15 | 16 | init(peerID: String? = nil, 17 | format: String? = nil) { 18 | self.arg = peerID 19 | self.format = format 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilesLsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilesLsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilesLsModel: Codable { 11 | // arg [string]: Path to show listing for. Defaults to ‘/’. Required: no. 12 | public let arg: String? 13 | // l [bool]: Use long listing format. Required: no. 14 | public let l: Bool? 15 | 16 | init(path: String? = nil, 17 | long: Bool? = nil) { 18 | self.arg = path 19 | self.l = long 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/ 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode9.3 6 | language: swift 7 | cache: cocoapods 8 | podfile: Example/Podfile 9 | before_install: 10 | - gem install cocoapods --pre # Since Travis is not always on latest version 11 | - pod install --project-directory=Example 12 | script: 13 | #- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/IpfsApi.xcworkspace -scheme IpfsApi-Example -sdk iPhoneSimulator11.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/IpfsApi/PeerCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PeerCell.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 6.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class PeerCell: Cell { 12 | typealias Item = PeerVM 13 | @IBOutlet weak var titleLabel: UILabel! 14 | @IBOutlet weak var subtitleLabel: UILabel! 15 | override func update(_ item: Item? = nil) { 16 | guard let item = item else { return } 17 | titleLabel.text = item.model.addr 18 | subtitleLabel.text = item.model.peer 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilesRmModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilesRmModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilesRmModel: Codable { 11 | // arg [string]: File to remove. Required: yes. 12 | public let arg: String 13 | // recursive [bool]: Recursively remove directories. Required: no. 14 | public let recursive: Bool? 15 | 16 | init(path: String, 17 | recursive: Bool? = nil) { 18 | self.arg = path 19 | self.recursive = recursive 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsPingModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsPingModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsPingModel: Codable { 11 | // arg [string]: ID of peer to be pinged. Required: yes. 12 | public let arg: String 13 | // count [int]: Number of ping messages to send. Default: “10”. Required: no. 14 | public let count: Int? 15 | 16 | init(peerID: String, 17 | count: Int? = nil) { 18 | self.arg = peerID 19 | self.count = count 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsP2pStreamCloseModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsP2pStreamCloseModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsP2pStreamCloseModel: Codable { 11 | // arg [string]: Stream HandlerID Required: no. 12 | public let arg: String? 13 | // all [bool]: Close all streams. Default: “false”. Required: no. 14 | public let all: Bool? 15 | 16 | init(arg: String? = nil, 17 | all: Bool? = nil) { 18 | self.arg = arg 19 | self.all = all 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsDhtGetModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsDhtGetModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsDhtGetModel: Codable { 11 | // arg [string]: The key to find a value for. Required: yes. 12 | public let arg: String 13 | // verbose [bool]: Print extra information. Default: “false”. Required: no. 14 | public let verbose: Bool? 15 | 16 | init(key: String, 17 | verbose: Bool? = nil) { 18 | self.arg = key 19 | self.verbose = verbose 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/KeypairModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KeypairModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct KeypairModel: Codable { 11 | public let id: String? 12 | public let name: String? 13 | public let was: String? 14 | public let now: String? 15 | public let overwrite: Bool? 16 | 17 | enum CodingKeys: String, CodingKey { 18 | case id = "Id" 19 | case name = "Name" 20 | case was = "Was" 21 | case now = "Now" 22 | case overwrite = "Overwrite" 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /ios-ipfs-api/ios_ipfs_api.h: -------------------------------------------------------------------------------- 1 | // 2 | // ios_ipfs_api.h 3 | // ios-ipfs-api 4 | // 5 | // Created by we on 2018. 9. 5.. 6 | // Copyright © 2018년 jaylee. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for ios_ipfs_api. 12 | FOUNDATION_EXPORT double ios_ipfs_apiVersionNumber; 13 | 14 | //! Project version string for ios_ipfs_api. 15 | FOUNDATION_EXPORT const unsigned char ios_ipfs_apiVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsP2pListenerCloseModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsP2pListenerCloseModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsP2pListenerCloseModel: Codable { 11 | // arg [string]: P2P listener protocol Required: no. 12 | public let arg: String? 13 | // all [bool]: Close all listeners. Default: “false”. Required: no. 14 | public let all: Bool? 15 | 16 | init(arg: String? = nil, 17 | all: Bool? = nil) { 18 | self.arg = arg 19 | self.all = all 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/MessageInfoModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MessageInfoModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct MessageInfoModel: Codable { 11 | public let from, data, seqno: [Int]? 12 | public let topicIDs: [String]? 13 | public let xxxUnrecognized: [Int]? 14 | 15 | enum CodingKeys: String, CodingKey { 16 | case from = "From" 17 | case data = "Data" 18 | case seqno = "Seqno" 19 | case topicIDs = "TopicIDs" 20 | case xxxUnrecognized = "XXX_unrecognized" 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsDhtQueryModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsDhtQueryModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsDhtQueryModel: Codable { 11 | // arg [string]: The peerID to run the query against. Required: yes. 12 | public let arg: String 13 | // verbose [bool]: Print extra information. Default: “false”. Required: no. 14 | public let verbose: Bool? 15 | 16 | init(arg: String, 17 | verbose: Bool? = nil) { 18 | self.arg = arg 19 | self.verbose = verbose 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilesMkdirModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilesMkdirModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilesMkdirModel: Codable { 11 | // arg [string]: Path to dir to make. Required: yes. 12 | public let arg: String 13 | // parents [bool]: No error if existing, make parent directories as needed. Required: no. 14 | public let parents: Bool? 15 | 16 | init(path: String, 17 | parents: Bool? = nil) { 18 | self.arg = path 19 | self.parents = parents 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsResolveModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsResolveModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsResolveModel: Codable { 11 | // arg [string]: The name to resolve. Required: yes. 12 | public let arg: String 13 | // recursive [bool]: Resolve until the result is an IPFS name. Default: “false”. Required: no. 14 | public let recursive: Bool? 15 | 16 | init(arg: String, 17 | recursive: Bool? = nil) { 18 | self.arg = arg 19 | self.recursive = recursive 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/IDInfoModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IDInfoModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct IDInfoModel: Codable { 11 | public let id, publicKey: String? 12 | public let addresses: [String]? 13 | public let agentVersion, protocolVersion: String? 14 | 15 | enum CodingKeys: String, CodingKey { 16 | case id = "ID" 17 | case publicKey = "PublicKey" 18 | case addresses = "Addresses" 19 | case agentVersion = "AgentVersion" 20 | case protocolVersion = "ProtocolVersion" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsDhtFindpeerModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsDhtFindpeerModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 17.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsDhtFindpeerModel: Codable { 11 | // arg [string]: The ID of the peer to search for. Required: yes. 12 | public let arg: String 13 | // verbose [bool]: Print extra information. Default: “false”. Required: no. 14 | public let verbose: Bool? 15 | 16 | init(peerID: String, 17 | verbose: Bool? = nil) { 18 | self.arg = peerID 19 | self.verbose = verbose 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsPinVerifyModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsPinVerifyModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsPinVerifyModel: Codable { 11 | // verbose [bool]: Also write the hashes of non-broken pins. Required: no. 12 | public let verbose: Bool? 13 | // quiet [bool]: Write just hashes of broken pins. Required: no. 14 | public let quiet: Bool? 15 | 16 | init(verbose: Bool? = nil, 17 | quiet: Bool? = nil) { 18 | self.verbose = verbose 19 | self.quiet = quiet 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsDnsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsDnsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsDnsModel: Codable { 11 | // arg [string]: The domain-name name to resolve. Required: yes. 12 | public let arg: String 13 | // recursive [bool]: Resolve until the result is not a DNS link. Default: “false”. Required: no. 14 | public let recursive: Bool? 15 | 16 | init(domain: String, 17 | recursive: Bool? = nil) { 18 | self.arg = domain 19 | self.recursive = recursive 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/FilestoreObjectModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FilestoreObjectModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct FilestoreObjectModel: Codable { 11 | public let status: Int32? 12 | public let errorMsg, key, filePath: String? 13 | public let offset, size: UInt64? 14 | 15 | enum CodingKeys: String, CodingKey { 16 | case status = "Status" 17 | case errorMsg = "ErrorMsg" 18 | case key = "Key" 19 | case filePath = "FilePath" 20 | case offset = "Offset" 21 | case size = "Size" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseRepoStatModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseRepoStatModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseRepoStatModel: Codable { 11 | public let numObjects, repoSize: UInt64? 12 | public let repoPath, version: String? 13 | public let storageMax: UInt64? 14 | 15 | enum CodingKeys: String, CodingKey { 16 | case numObjects = "NumObjects" 17 | case repoSize = "RepoSize" 18 | case repoPath = "RepoPath" 19 | case version = "Version" 20 | case storageMax = "StorageMax" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsPubsubSubModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsPubsubSubModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsPubsubSubModel: Codable { 11 | // arg [string]: String name of topic to subscribe to. Required: yes. 12 | public let arg: String 13 | // discover [bool]: try to discover other peers subscribed to the same topic. Required: no. 14 | public let discover: Bool? 15 | 16 | init(topic: String, 17 | discover: Bool? = nil) { 18 | self.arg = topic 19 | self.discover = discover 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/URL+Moya.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public extension URL { 4 | 5 | /// Initialize URL from Moya's `TargetType`. 6 | init(target: T) { 7 | // When a TargetType's path is empty, URL.appendingPathComponent may introduce trailing /, which may not be wanted in some cases 8 | // See: https://github.com/Moya/Moya/pull/1053 9 | // And: https://github.com/Moya/Moya/issues/1049 10 | if target.path.isEmpty { 11 | self = target.baseURL 12 | } else { 13 | self = target.baseURL.appendingPathComponent(target.path) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Example/IpfsApi/ViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewModel.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 4.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import IGListKit 11 | import Ipfs 12 | 13 | class ViewModel: ListDiffable { 14 | var model: T 15 | init(model:T) { 16 | self.model = model 17 | } 18 | func diffIdentifier() -> NSObjectProtocol { 19 | return self.model.id 20 | } 21 | func isEqual(toDiffableObject object: ListDiffable?) -> Bool { 22 | return self.diffIdentifier().isEqual(object?.diffIdentifier()) 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsPinRmModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsPinRmModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsPinRmModel: Codable { 11 | // arg [string]: Path to object(s) to be unpinned. Required: yes. 12 | public let arg: String 13 | // recursive [bool]: Recursively unpin the object linked to by the specified object(s). Default: “true”. Required: no. 14 | public let recursive: Bool? 15 | 16 | init(path: String, 17 | recursive: Bool? = nil) { 18 | self.arg = path 19 | self.recursive = recursive 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseBitswapLedgerModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseBitswapLedgerModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 17.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseBitswapLedgerModel: Codable { 11 | public let peer: String? 12 | public let value: Float64? 13 | public let sent: UInt64? 14 | public let recv: UInt64? 15 | public let exchanged: UInt64? 16 | 17 | enum CodingKeys: String, CodingKey { 18 | case peer = "Peer" 19 | case value = "Value" 20 | case sent = "Sent" 21 | case recv = "Recv" 22 | case exchanged = "Exchanged" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ObjectStatModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectStatModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ObjectStatModel: Codable { 11 | public let hash: String? 12 | public let numLinks, blockSize, linksSize, dataSize: Int? 13 | public let cumulativeSize: Int? 14 | 15 | enum CodingKeys: String, CodingKey { 16 | case hash = "Hash" 17 | case numLinks = "NumLinks" 18 | case blockSize = "BlockSize" 19 | case linksSize = "LinksSize" 20 | case dataSize = "DataSize" 21 | case cumulativeSize = "CumulativeSize" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsLogLevelModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsLogLevelModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsLogLevelModel: Codable { 11 | // arg [string]: The subsystem logging identifier. Use ‘all’ for all subsystems. Required: yes. 12 | // arg [string]: The log level, with ‘debug’ the most verbose and ‘critical’ the least verbose. One of: debug, info, warning, error, critical. Required: yes. 13 | public let arg: [String] 14 | 15 | init(subsystem: String, 16 | level: String) { 17 | self.arg = [subsystem, level] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IpfsApi/Classes/StreamModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StreamModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct StreamModel: Codable { 11 | public let handlerID, streamProtocol, localPeer, localAddress: String? 12 | public let remotePeer, remoteAddress: String? 13 | 14 | enum CodingKeys: String, CodingKey { 15 | case handlerID = "HandlerID" 16 | case streamProtocol = "Protocol" 17 | case localPeer = "LocalPeer" 18 | case localAddress = "LocalAddress" 19 | case remotePeer = "RemotePeer" 20 | case remoteAddress = "RemoteAddress" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsObjectLinksModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsObjectLinksModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsObjectLinksModel: Codable { 11 | // arg [string]: Key of the object to retrieve, in base58-encoded multihash format. Required: yes. 12 | public let arg: String 13 | // headers [bool]: Print table headers (Hash, Size, Name). Default: “false”. Required: no. 14 | public let headers: Bool? 15 | 16 | init(multihash: String, 17 | headers: Bool? = nil) { 18 | self.arg = multihash 19 | self.headers = headers 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsObjectDiffModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsObjectDiffModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsObjectDiffModel: Codable { 11 | // arg [string]: Object to diff against. Required: yes. 12 | // arg [string]: Object to diff. Required: yes. 13 | public let arg: [String] 14 | // verbose [bool]: Print extra information. Required: no. 15 | public let verbose: Bool? 16 | 17 | init(objA: String, 18 | objB: String, 19 | verbose: Bool? = nil) { 20 | self.arg = [objA, objB] 21 | self.verbose = verbose 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsKeyRenameModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsKeyRenameModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsKeyRenameModel: Codable { 11 | // arg [string]: name of key to rename Required: yes. 12 | // arg [string]: new name of the key Required: yes. 13 | public let arg: [String] 14 | // force [bool]: Allow to overwrite an existing key. Required: no. 15 | public let force: Bool? 16 | 17 | init(oldName: String, 18 | newName: String, 19 | force: Bool? = nil) { 20 | self.arg = [oldName, newName] 21 | self.force = force 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsDhtPutModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsDhtPutModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsDhtPutModel: Codable { 11 | // arg [string]: The key to store the value at. Required: yes. 12 | // arg [string]: The value to store. Required: yes. 13 | public let arg: [String] 14 | // verbose [bool]: Print extra information. Default: “false”. Required: no. 15 | public let verbose: Bool? 16 | 17 | init(key: String, 18 | value: String, 19 | verbose: Bool? = nil) { 20 | self.arg = [key, value] 21 | self.verbose = verbose 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsPinUpdateModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsPinUpdateModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsPinUpdateModel: Codable { 11 | // arg [string]: Path to old object. Required: yes. 12 | // arg [string]: Path to new object to be pinned. Required: yes. 13 | public let arg: [String] 14 | // unpin [bool]: Remove the old pin. Default: “true”. Required: no. 15 | public let unpin: Bool? 16 | 17 | init(fromPath: String, 18 | toPath: String, 19 | unpin: Bool? = nil) { 20 | self.arg = [fromPath, toPath] 21 | self.unpin = unpin 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsKeyGenModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsKeyGenModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsKeyGenModel: Codable { 11 | // arg [string]: name of key to create Required: yes. 12 | public let arg: String 13 | // type [string]: type of the key to create [rsa, ed25519]. Required: no. 14 | public let type: String? 15 | // size [int]: size of the key to generate. Required: no. 16 | public let size: Int? 17 | 18 | init(name: String, 19 | type: String? = nil, 20 | size: Int? = nil) { 21 | self.arg = name 22 | self.type = type 23 | self.size = size 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilesReadModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilesReadModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilesReadModel: Codable { 11 | // arg [string]: Path to file to be read. Required: yes. 12 | public let arg: String 13 | // offset [int]: Byte offset to begin reading from. Required: no. 14 | public let offset: Int? 15 | // count [int]: Maximum number of bytes to read. Required: no. 16 | public let count: Int? 17 | 18 | init(path: String, 19 | offset: Int? = nil, 20 | count: Int? = nil) { 21 | self.arg = path 22 | self.offset = offset 23 | self.count = count 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilestoreLsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilestoreLsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilestoreLsModel: Codable { 11 | // arg [string]: Cid of objects to list. Required: no. 12 | public let arg: String? 13 | // file-order [bool]: sort the results based on the path of the backing file. Required: no. 14 | public let fileOrder: Bool? 15 | 16 | init(arg: String? = nil, 17 | fileOrder: Bool? = nil) { 18 | self.arg = arg 19 | self.fileOrder = fileOrder 20 | } 21 | 22 | enum CodingKeys: String, CodingKey { 23 | case arg 24 | case fileOrder = "file-order" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsBlockRmModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsBlockRmModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 17.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsBlockRmModel: Codable { 11 | //arg [string]: Bash58 encoded multihash of block(s) to remove. Required: yes. 12 | public let arg: String 13 | //force [bool]: Ignore nonexistent blocks. Default: “false”. Required: no. 14 | public let force: Bool? 15 | //quiet [bool]: Write minimal output. Default: “false”. Required: no. 16 | public let quiet: Bool? 17 | 18 | init(arg: String, 19 | force: Bool? = nil, 20 | quiet: Bool? = nil) { 21 | self.arg = arg 22 | self.force = force 23 | self.quiet = quiet 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsRepoGcModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsRepoGcModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsRepoGcModel: Codable { 11 | // quiet [bool]: Write minimal output. Default: “false”. Required: no. 12 | public let quiet: Bool? 13 | // stream-errors [bool]: Stream errors. Default: “false”. Required: no. 14 | public let streamErrors: Bool? 15 | 16 | init(quiet: Bool? = nil, 17 | streamErrors: Bool? = nil) { 18 | self.quiet = quiet 19 | self.streamErrors = streamErrors 20 | } 21 | 22 | enum CodingKeys: String, CodingKey { 23 | case quiet 24 | case streamErrors = "stream-errors" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsMountModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsMountModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsMountModel: Codable { 11 | // ipfs-path [string]: The path where IPFS should be mounted. Required: no. 12 | public let ipfsPath: String? 13 | // ipns-path [string]: The path where IPNS should be mounted. Required: no. 14 | public let ipnsPath: String? 15 | 16 | init(ipfsPath: String? = nil, 17 | ipnsPath: String? = nil) { 18 | self.ipfsPath = ipfsPath 19 | self.ipnsPath = ipnsPath 20 | } 21 | enum CodingKeys: String, CodingKey { 22 | case ipfsPath = "ipfs-path" 23 | case ipnsPath = "ipns-path" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilestoreVerifyModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilestoreVerifyModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilestoreVerifyModel: Codable { 11 | // arg [string]: Cid of objects to verify. Required: no. 12 | public let arg: String? 13 | // file-order [bool]: verify the objects based on the order of the backing file. Required: no. 14 | public let fileOrder: Bool? 15 | 16 | init(arg: String? = nil, 17 | fileOrder: Bool? = nil) { 18 | self.arg = arg 19 | self.fileOrder = fileOrder 20 | } 21 | 22 | enum CodingKeys: String, CodingKey { 23 | case arg 24 | case fileOrder = "file-order" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/Cancellable.swift: -------------------------------------------------------------------------------- 1 | /// Protocol to define the opaque type returned from a request. 2 | public protocol Cancellable { 3 | 4 | /// A Boolean value stating whether a request is cancelled. 5 | var isCancelled: Bool { get } 6 | 7 | /// Cancels the represented request. 8 | func cancel() 9 | } 10 | 11 | internal class CancellableWrapper: Cancellable { 12 | internal var innerCancellable: Cancellable = SimpleCancellable() 13 | 14 | var isCancelled: Bool { return innerCancellable.isCancelled } 15 | 16 | internal func cancel() { 17 | innerCancellable.cancel() 18 | } 19 | } 20 | 21 | internal class SimpleCancellable: Cancellable { 22 | var isCancelled = false 23 | func cancel() { 24 | isCancelled = true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Example/IpfsApi/ListVCProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListVC.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 5.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import IGListKit 11 | 12 | protocol AdaptedCollectionViewProtocol { 13 | var collectionView: UICollectionView! { get set } 14 | } 15 | 16 | protocol ListVCProtocol where Self: UIViewController { 17 | associatedtype Item: ListDiffable 18 | var adapter: ListAdapter? { get set } 19 | var items: [Item] { get set } 20 | } 21 | 22 | extension ListVCProtocol where Self: AdaptedCollectionViewProtocol { 23 | func initializeListView() { 24 | adapter?.collectionView = collectionView 25 | adapter?.dataSource = self as? ListAdapterDataSource 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/Plugins/CredentialsPlugin.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Result 3 | 4 | /// Provides each request with optional URLCredentials. 5 | public final class CredentialsPlugin: PluginType { 6 | 7 | public typealias CredentialClosure = (TargetType) -> URLCredential? 8 | let credentialsClosure: CredentialClosure 9 | 10 | /// Initializes a CredentialsPlugin. 11 | public init(credentialsClosure: @escaping CredentialClosure) { 12 | self.credentialsClosure = credentialsClosure 13 | } 14 | 15 | // MARK: Plugin 16 | 17 | public func willSend(_ request: RequestType, target: TargetType) { 18 | if let credentials = credentialsClosure(target) { 19 | _ = request.authenticate(usingCredential: credentials) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsP2pStreamDialModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsP2pStreamDialModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsP2pStreamDialModel: Codable { 11 | // arg [string]: Remote peer to connect to Required: yes. 12 | // arg [string]: Protocol identifier. Required: yes. 13 | // arg [string]: Address to listen for connection/s (default: /ip4/127.0.0.1/tcp/0). Required: no. 14 | public let arg: [String] 15 | 16 | init(peer: String, 17 | protocolID: String, 18 | bindAddress: String? = nil) { 19 | var args = [peer, protocolID] 20 | if let address = bindAddress { 21 | args.append(address) 22 | } 23 | self.arg = args 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Moya/Moya.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Moya 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/Result" "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "Foundation" -framework "Result" -framework "RxSwift" 5 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -suppress-warnings 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Moya 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsPinAddModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsPinAddModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsPinAddModel: Codable { 11 | // arg [string]: Path to object(s) to be pinned. Required: yes. 12 | public let arg: String 13 | // recursive [bool]: Recursively pin the object linked to by the specified object(s). Default: “true”. Required: no. 14 | public let recursive: Bool? 15 | // progress [bool]: Show progress. Required: no. 16 | public let progress: Bool? 17 | 18 | init(path: String, 19 | recursive: Bool? = nil, 20 | progress: Bool? = nil) { 21 | self.arg = path 22 | self.recursive = recursive 23 | self.progress = progress 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsDhtProvideModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsDhtProvideModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsDhtProvideModel: Codable { 11 | // arg [string]: The key[s] to send provide records for. Required: yes. 12 | public let arg: String 13 | // verbose [bool]: Print extra information. Default: “false”. Required: no. 14 | public let verbose: Bool? 15 | // recursive [bool]: Recursively provide entire graph. Default: “false”. Required: no. 16 | public let recursive: Bool? 17 | 18 | init(key: String, 19 | verbose: Bool? = nil, 20 | recursive: Bool? = nil) { 21 | self.arg = key 22 | self.verbose = verbose 23 | self.recursive = recursive 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsObjectPatchAddLinkModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsObjectPatchAddLinkModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsObjectPatchAddLinkModel: Codable { 11 | // arg [string]: The hash of the node to modify. Required: yes. 12 | // arg [string]: Name of link to create. Required: yes. 13 | // arg [string]: IPFS object to add link to. Required: yes. 14 | public let arg: [String] 15 | // create [bool]: Create intermediary nodes. Default: “false”. Required: no. 16 | public let verbose: Bool? 17 | 18 | init(root: String, 19 | name: String, 20 | ref: String, 21 | verbose: Bool? = nil) { 22 | self.arg = [root, name, ref] 23 | self.verbose = verbose 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsPinLsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsPinLsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsPinLsModel: Codable { 11 | // arg [string]: Path to object(s) to be listed. Required: no. 12 | public let arg: String? 13 | // type [string]: The type of pinned keys to list. Can be “direct”, “indirect”, “recursive”, or “all”. Default: “all”. Required: no. 14 | public let type: String? 15 | // quiet [bool]: Write just hashes of objects. Default: “false”. Required: no. 16 | public let quiet: Bool? 17 | 18 | init(path: String? = nil, 19 | type: String? = nil, 20 | quiet: Bool? = nil) { 21 | self.arg = path 22 | self.type = type 23 | self.quiet = quiet 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsSwarmPeersModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsSwarmPeersModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsSwarmPeersModel: Codable { 11 | // verbose [bool]: display all extra information. Required: no. 12 | public let verbose: Bool? 13 | // streams [bool]: Also list information about open streams for each peer. Required: no. 14 | public let streams: Bool? 15 | // latency [bool]: Also list information about latency to each peer. Required: no. 16 | public let latency: Bool? 17 | 18 | init(verbose: Bool? = nil, 19 | streams: Bool? = nil, 20 | latency: Bool? = nil) { 21 | self.verbose = verbose 22 | self.streams = streams 23 | self.latency = latency 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Example/IpfsApi/Pinned.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Pinned.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 7.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import IGListKit 11 | import Ipfs 12 | 13 | struct Pinned : ModelProtocol { 14 | typealias Handler = ()->() 15 | var id: NSString 16 | var key: String? 17 | let pinnedObject: ObjectModel? 18 | } 19 | 20 | class PinnedVM: ViewModel { 21 | typealias Handler = ()->() 22 | var image: UIImage? 23 | var key: String? 24 | { 25 | set { 26 | self.model.key = newValue 27 | } 28 | get { 29 | return self.model.key 30 | } 31 | } 32 | var type: String? 33 | { 34 | get { 35 | return self.model.pinnedObject?.type 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | platform :ios, '9.0' 4 | 5 | target 'IpfsApi_Example' do 6 | # Ignore all warnings from all pods 7 | inhibit_all_warnings! 8 | pod 'IpfsApi', :path => '../' 9 | pod 'Moya/RxSwift', '~> 11.0' 10 | pod 'Hero' 11 | pod 'FontAwesomeKit' 12 | pod 'Viewer' 13 | pod 'IGListKit' 14 | pod 'IQKeyboardManagerSwift' 15 | pod 'TUSafariActivity' 16 | pod 'PopupDialog' 17 | pod 'AlamofireImage' 18 | 19 | target 'IpfsApi_Tests' do 20 | inherit! :search_paths 21 | 22 | end 23 | 24 | post_install do |installer| 25 | installer.pods_project.build_configurations.each do |config| 26 | config.build_settings.delete('CODE_SIGNING_ALLOWED') 27 | config.build_settings.delete('CODE_SIGNING_REQUIRED') 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /Example/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Ipfs 3 | 4 | class Tests: XCTestCase { 5 | 6 | override func setUp() { 7 | super.setUp() 8 | // Put setup code here. This method is called before the invocation of each test method in the class. 9 | } 10 | 11 | override func tearDown() { 12 | // Put teardown code here. This method is called after the invocation of each test method in the class. 13 | super.tearDown() 14 | } 15 | 16 | func testExample() { 17 | // This is an example of a functional test case. 18 | XCTAssert(true, "Pass") 19 | } 20 | 21 | func testPerformanceExample() { 22 | // This is an example of a performance test case. 23 | self.measure() { 24 | // Put the code you want to measure the time of here. 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsNameResolveModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsNameResolveModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsNameResolveModel: Codable { 11 | // arg [string]: The IPNS name to resolve. Defaults to your node’s peerID. Required: no. 12 | public let arg: String? 13 | // recursive [bool]: Resolve until the result is not an IPNS name. Default: “false”. Required: no. 14 | public let recursive: Bool? 15 | // nocache [bool]: Do not use cached entries. Default: “false”. Required: no. 16 | public let nocache: Bool? 17 | 18 | 19 | init(name: String? = nil, 20 | recursive: Bool? = nil, 21 | nocache: Bool? = nil) { 22 | self.arg = name 23 | self.recursive = recursive 24 | self.nocache = nocache 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ios-ipfs-api/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/IpfsApi/IpfsApi.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/IpfsApi 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/Moya" "${PODS_CONFIGURATION_BUILD_DIR}/Result" "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "Foundation" -framework "Moya" -framework "Result" -framework "RxSwift" 5 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -suppress-warnings 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | -------------------------------------------------------------------------------- /Example/IpfsApi/Demo.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Demo.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 6.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import IGListKit 11 | import Ipfs 12 | 13 | struct Demo : ModelProtocol { 14 | typealias Handler = ()->() 15 | var id: NSString 16 | var title: String? 17 | var handler: Handler? 18 | } 19 | 20 | class DemoVM: ViewModel { 21 | typealias Handler = ()->() 22 | var title: String? 23 | { 24 | set { 25 | self.model.title = newValue 26 | } 27 | get { 28 | return self.model.title 29 | } 30 | } 31 | var handler: Handler? 32 | { 33 | set { 34 | self.model.handler = newValue 35 | } 36 | get { 37 | return self.model.handler 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ObjectModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ObjectModel: Codable { 11 | public let hash: String? 12 | public let size: String? 13 | public let type: String? 14 | public let links: [ObjectModel]? 15 | public let name: String? 16 | public let bytes: Int64? 17 | public let blocks: Int? 18 | public let cumulativeSize: UInt64? 19 | public let data: String? 20 | 21 | enum CodingKeys: String, CodingKey { 22 | case hash = "Hash" 23 | case size = "Size" 24 | case type = "Type" 25 | case links = "Links" 26 | case name = "Name" 27 | case bytes = "Bytes" 28 | case blocks = "Blocks" 29 | case cumulativeSize = "CumulativeSize" 30 | case data = "Data" 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 26 | # Carthage/Checkouts 27 | # Carthage/Build 28 | Carthage 29 | 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 33 | # 34 | # Note: if you ignore the Pods directory, make sure to uncomment 35 | # `pod install` in .travis.yml 36 | # 37 | Pods/ 38 | Podfile.lock 39 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsObjectPutModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsObjectPutModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsObjectPutModel: Codable { 11 | // inputenc [string]: Encoding type of input data. One of: {“protobuf”, “json”}. Default: “json”. Required: no. 12 | public let inputenc: String? 13 | // datafieldenc [string]: Encoding type of the data field, either “text” or “base64”. Default: “text”. Required: no. 14 | public let datafieldenc: String? 15 | // pin [bool]: Pin this object when adding. Default: “false”. Required: no. 16 | public let pin: Bool? 17 | 18 | init(inputenc: String? = nil, 19 | datafieldenc: String? = nil, 20 | pin: Bool? = nil) { 21 | self.inputenc = inputenc 22 | self.datafieldenc = datafieldenc 23 | self.pin = pin 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsBlockPutModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsBlockPutModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 17.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsBlockPutModel: Codable { 11 | // format [string]: cid format for blocks to be created with. Default: “v0”. Required: no. 12 | public let format: String? 13 | // mhtype [string]: multihash hash function. Default: “sha2-256”. Required: no. 14 | public let mhtype: String? 15 | // mhlen [int]: multihash hash length. Default: “-1”. Required: no. 16 | public let mhlen:Int? 17 | 18 | init(format: String? = nil, 19 | mhtype: String? = nil, 20 | mhlen: Int? = nil) { 21 | self.format = format 22 | self.mhtype = mhtype 23 | self.mhlen = mhlen 24 | } 25 | 26 | enum CodingKeys: String, CodingKey { 27 | case format 28 | case mhtype 29 | case mhlen 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/IpfsApi.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "IpfsApi", 3 | "version": "0.2.0", 4 | "summary": "A wrapper of the IPFS Client HTTP-API for iOS.", 5 | "module_name": "Ipfs", 6 | "description": "A client library for the IPFS HTTP API, implemented in Swift. Check out IPFS Docs(https://ipfs.io/docs/api/) for the full command reference.", 7 | "homepage": "https://github.com/kjaylee/ios-ipfs-api", 8 | "license": { 9 | "type": "MIT", 10 | "file": "LICENSE" 11 | }, 12 | "authors": { 13 | "kjaylee": "k.jaylee@gmail.com" 14 | }, 15 | "source": { 16 | "git": "https://github.com/kjaylee/ios-ipfs-api.git", 17 | "tag": "0.2.0" 18 | }, 19 | "social_media_url": "https://twitter.com/kjaylee", 20 | "platforms": { 21 | "ios": "8.0", 22 | "osx": "10.10" 23 | }, 24 | "swift_version": "4.1", 25 | "source_files": "IpfsApi/Classes/*.swift", 26 | "dependencies": { 27 | "Moya": [ 28 | "~> 11.0" 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Alamofire/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 4.7.3 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/IpfsApi/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Moya/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 11.0.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Result/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 3.2.4 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ResponseBitswapStatModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseBitswapStatModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 21.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ResponseBitswapStatModel: Codable { 11 | public let provideBufLen: Int? 12 | public let wantlist: [String]? 13 | public let peers: [String]? 14 | public let blocksReceived, dataReceived, blocksSent, dataSent: UInt64? 15 | public let dupBlksReceived, dupDataReceived: UInt64? 16 | 17 | enum CodingKeys: String, CodingKey { 18 | case provideBufLen = "ProvideBufLen" 19 | case wantlist = "Wantlist" 20 | case peers = "Peers" 21 | case blocksReceived = "BlocksReceived" 22 | case dataReceived = "DataReceived" 23 | case blocksSent = "BlocksSent" 24 | case dataSent = "DataSent" 25 | case dupBlksReceived = "DupBlksReceived" 26 | case dupDataReceived = "DupDataReceived" 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsVersionModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsVersionModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsVersionModel: Codable { 11 | // number [bool]: Only show the version number. Default: “false”. Required: no. 12 | public let number: Bool? 13 | // commit [bool]: Show the commit hash. Default: “false”. Required: no. 14 | public let commit: Bool? 15 | // repo [bool]: Show repo version. Default: “false”. Required: no. 16 | public let repo: Bool? 17 | // all [bool]: Show all version information. Default: “false”. Required: no. 18 | public let all: Bool? 19 | 20 | init(number: Bool? = nil, 21 | commit: Bool? = nil, 22 | repo: Bool? = nil, 23 | all: Bool? = nil) { 24 | self.number = number 25 | self.commit = commit 26 | self.repo = repo 27 | self.all = all 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsDhtFindprovsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsDhtFindprovsModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsDhtFindprovsModel: Codable { 11 | // arg [string]: The key to find providers for. Required: yes. 12 | public let arg: String 13 | // verbose [bool]: Print extra information. Default: “false”. Required: no. 14 | public let verbose: Bool? 15 | // num-providers [int]: The number of providers to find. Default: “20”. Required: no. 16 | public let numProviders: Int? 17 | 18 | init(key: String, 19 | verbose: Bool? = nil, 20 | numProviders: Int? = nil) { 21 | self.arg = key 22 | self.verbose = verbose 23 | self.numProviders = numProviders 24 | } 25 | 26 | enum CodingKeys: String, CodingKey { 27 | case arg 28 | case verbose 29 | case numProviders = "num-providers" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsLsModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsLsModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsLsModel: Codable { 11 | // arg [string]: The path to the IPFS object(s) to list links from. Required: yes. 12 | public let arg: String 13 | // headers [bool]: Print table headers (Hash, Size, Name). Default: “false”. Required: no. 14 | public let headers: Bool? 15 | // resolve-type [bool]: Resolve linked objects to find out their types. Default: “true”. Required: no. 16 | public let resolveType: Bool? 17 | 18 | init(arg: String, 19 | headers: Bool? = nil, 20 | resolveType: Bool? = nil) { 21 | self.arg = arg 22 | self.headers = headers 23 | self.resolveType = resolveType 24 | } 25 | 26 | enum CodingKeys: String, CodingKey { 27 | case arg 28 | case headers 29 | case resolveType = "resolve-type" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/URLRequest+Encoding.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal extension URLRequest { 4 | 5 | mutating func encoded(encodable: Encodable, encoder: JSONEncoder = JSONEncoder()) throws -> URLRequest { 6 | do { 7 | let encodable = AnyEncodable(encodable) 8 | httpBody = try encoder.encode(encodable) 9 | 10 | let contentTypeHeaderName = "Content-Type" 11 | if value(forHTTPHeaderField: contentTypeHeaderName) == nil { 12 | setValue("application/json", forHTTPHeaderField: contentTypeHeaderName) 13 | } 14 | 15 | return self 16 | } catch { 17 | throw MoyaError.encodableMapping(error) 18 | } 19 | } 20 | 21 | func encoded(parameters: [String: Any], parameterEncoding: ParameterEncoding) throws -> URLRequest { 22 | do { 23 | return try parameterEncoding.encode(self, with: parameters) 24 | } catch { 25 | throw MoyaError.parameterEncoding(error) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilesWriteModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilesWriteModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilesWriteModel: Codable { 11 | // arg [string]: Path to write to. Required: yes. 12 | public let arg: String 13 | // offset [int]: Byte offset to begin writing at. Required: no. 14 | public let offset: Int? 15 | // create [bool]: Create the file if it does not exist. Required: no. 16 | public let create: Bool? 17 | // truncate [bool]: Truncate the file to size zero before writing. Required: no. 18 | public let truncate: Bool? 19 | // count [int]: Maximum number of bytes to read. Required: no. 20 | public let count: Int? 21 | 22 | init(path: String, 23 | offset: Int? = nil, 24 | create: Bool? = nil, 25 | truncate: Bool? = nil, 26 | count: Int? = nil) { 27 | self.arg = path 28 | self.offset = offset 29 | self.create = create 30 | self.truncate = truncate 31 | self.count = count 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Example/IpfsApi/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 kjaylee 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Example/Pods/Result/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Rob Rix 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsStatsBwModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsStatsBwModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsStatsBwModel: Codable { 11 | // peer [string]: Specify a peer to print bandwidth for. Required: no. 12 | public let peer: String? 13 | // proto [string]: Specify a protocol to print bandwidth for. Required: no. 14 | public let proto: String? 15 | // poll [bool]: Print bandwidth at an interval. Default: “false”. Required: no. 16 | public let poll: Bool? 17 | // interval [string]: Time interval to wait between updating output, if ‘poll’ is true. 18 | // This accepts durations such as “300s”, “1.5h” or “2h45m”. Valid time units are: “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”. Default: “1s”. Required: no. 19 | public let interval: String? 20 | 21 | init(peer: String? = nil, 22 | proto: String? = nil, 23 | poll: Bool? = nil, 24 | interval: String? = nil) { 25 | self.peer = peer 26 | self.proto = proto 27 | self.poll = poll 28 | self.interval = interval 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Example/Pods/Alamofire/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Example/Pods/Moya/License.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-present Artsy, Ash Furrow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsDagPutModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsDagPutModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 17.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsDagPutModel: Codable { 11 | // format [string]: Format that the object will be added as. Default: “cbor”. Required: no. 12 | public let format: String? 13 | // input-enc [string]: Format that the input object will be. Default: “json”. Required: no. 14 | public let inputEnc: String? 15 | // pin [bool]: Pin this object when adding. Default: “false”. Required: no. 16 | public let pin: Bool? 17 | // hash [string]: Hash function to use. Default: . Required: no. 18 | public let hash: String? 19 | 20 | init(format: String? = nil, 21 | inputEnc: String? = nil, 22 | pin: Bool? = nil, 23 | hash: String? = nil) { 24 | self.format = format 25 | self.inputEnc = inputEnc 26 | self.pin = pin 27 | self.hash = hash 28 | } 29 | 30 | enum CodingKeys: String, CodingKey { 31 | case format 32 | case inputEnc = "input-enc" 33 | case pin 34 | case hash 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsFilesStatModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsFilesStatModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsFilesStatModel: Codable { 11 | // arg [string]: Path to node to stat. Required: yes. 12 | public let arg: String 13 | // format [string]: Print statistics in given format. Allowed tokens: . Conflicts with other format options. Default: Size: CumulativeSize: ChildBlocks: Type: . Default: “ Size: CumulativeSize: ChildBlocks: Type: ”. Required: no. 14 | public let format: String? 15 | // hash [bool]: Print only hash. Implies ‘–format=’. Conflicts with other format options. Default: “false”. Required: no. 16 | public let hash: Bool? 17 | // size [bool]: Print only size. Implies ‘–format=’. Conflicts with other format options. Default: “false”. Required: no. 18 | public let size: Bool? 19 | 20 | init(path: String, 21 | format: String? = nil, 22 | hash: Bool? = nil, 23 | size: Bool? = nil) { 24 | self.arg = path 25 | self.format = format 26 | self.hash = hash 27 | self.size = size 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/Plugins/NetworkActivityPlugin.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Result 3 | 4 | /// Network activity change notification type. 5 | public enum NetworkActivityChangeType { 6 | case began, ended 7 | } 8 | 9 | /// Notify a request's network activity changes (request begins or ends). 10 | public final class NetworkActivityPlugin: PluginType { 11 | 12 | public typealias NetworkActivityClosure = (_ change: NetworkActivityChangeType, _ target: TargetType) -> Void 13 | let networkActivityClosure: NetworkActivityClosure 14 | 15 | /// Initializes a NetworkActivityPlugin. 16 | public init(networkActivityClosure: @escaping NetworkActivityClosure) { 17 | self.networkActivityClosure = networkActivityClosure 18 | } 19 | 20 | // MARK: Plugin 21 | 22 | /// Called by the provider as soon as the request is about to start 23 | public func willSend(_ request: RequestType, target: TargetType) { 24 | networkActivityClosure(.began, target) 25 | } 26 | 27 | /// Called by the provider as soon as a response arrives, even if the request is canceled. 28 | public func didReceive(_ result: Result, target: TargetType) { 29 | networkActivityClosure(.ended, target) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/IpfsApi/TextFieldVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextFieldVC.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 5.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class TextFieldVC: UIViewController { 12 | 13 | @IBOutlet weak var titleLabel: UILabel! 14 | @IBOutlet weak var subtitleLabel: UILabel! 15 | @IBOutlet weak var textField: UITextField! 16 | 17 | override var title: String? 18 | { 19 | didSet { 20 | if titleLabel != nil { 21 | self.titleLabel.text = self.title 22 | } 23 | } 24 | } 25 | var subtitle: String? 26 | { 27 | didSet { 28 | if subtitleLabel != nil { 29 | self.subtitleLabel.text = self.subtitle 30 | } 31 | } 32 | } 33 | var placeholder: String? 34 | { 35 | didSet { 36 | if textField != nil { 37 | self.textField.placeholder = placeholder 38 | } 39 | } 40 | } 41 | 42 | override func viewDidLoad() { 43 | super.viewDidLoad() 44 | self.titleLabel.text = self.title 45 | self.subtitleLabel.text = self.subtitle 46 | self.textField.placeholder = placeholder 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Example/IpfsApi/ListVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListVC.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 5.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import IGListKit 11 | 12 | class ListVC: 13 | UIViewController, ListVCProtocol, ListAdapterDataSource { 14 | 15 | var workingRangeSize: Int = 3 16 | 17 | lazy var adapter: ListAdapter? = { 18 | return ListAdapter(updater: ListAdapterUpdater(), 19 | viewController: self, 20 | workingRangeSize: workingRangeSize) 21 | }() 22 | 23 | var items: [T] = [] 24 | 25 | var emptyView: UIView? 26 | 27 | typealias Item = T 28 | typealias ListSC = LSC 29 | 30 | 31 | override func viewDidLoad() { 32 | super.viewDidLoad() 33 | } 34 | 35 | 36 | func objects(for listAdapter: ListAdapter) -> [ListDiffable] { 37 | return self.items as [ListDiffable] 38 | } 39 | 40 | func listAdapter(_ listAdapter: ListAdapter, sectionControllerFor object: Any) -> ListSectionController { 41 | return ListSC() 42 | } 43 | 44 | func emptyView(for listAdapter: ListAdapter) -> UIView? { 45 | return emptyView 46 | 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/TargetType.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// The protocol used to define the specifications necessary for a `MoyaProvider`. 4 | public protocol TargetType { 5 | 6 | /// The target's base `URL`. 7 | var baseURL: URL { get } 8 | 9 | /// The path to be appended to `baseURL` to form the full `URL`. 10 | var path: String { get } 11 | 12 | /// The HTTP method used in the request. 13 | var method: Moya.Method { get } 14 | 15 | /// Provides stub data for use in testing. 16 | var sampleData: Data { get } 17 | 18 | /// The type of HTTP task to be performed. 19 | var task: Task { get } 20 | 21 | /// The type of validation to perform on the request. Default is `.none`. 22 | var validationType: ValidationType { get } 23 | 24 | /// The headers to be used in the request. 25 | var headers: [String: String]? { get } 26 | } 27 | 28 | public extension TargetType { 29 | 30 | /// The type of validation to perform on the request. Default is `.none`. 31 | var validationType: ValidationType { 32 | return .none 33 | } 34 | } 35 | 36 | // MARK: - Deprecated 37 | 38 | extension TargetType { 39 | @available(*, deprecated: 11.0, message: 40 | "TargetType's validate property has been deprecated in 11.0. Please use validationType: ValidationType.") 41 | var validate: Bool { 42 | return false 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Example/IpfsApi/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSCameraUsageDescription 26 | access camera 27 | NSPhotoLibraryUsageDescription 28 | access album 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIMainStoryboardFile 32 | Main 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsNamePublishModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsNamePublishModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsNamePublishModel: Codable { 11 | // arg [string]: ipfs path of the object to be published. Required: yes. 12 | public let arg: String 13 | // resolve [bool]: Resolve given path before publishing. Default: “true”. Required: no. 14 | public let resolve: Bool? 15 | // lifetime [string]: Time duration that the record will be valid for. This accepts durations such as “300s”, “1.5h” or “2h45m”. Valid time units are “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”. Default: “24h”. Required: no. 16 | public let lifetime: String? 17 | // ttl [string]: Time duration this record should be cached for (caution: experimental). Required: no. 18 | public let ttl: String? 19 | // key [string]: Name of the key to be used or a valid PeerID, as listed by ‘ipfs key list -l’. Default:. Default: “self”. Required: no. 20 | public let key: String? 21 | 22 | init(path: String, 23 | resolve: Bool? = nil, 24 | lifetime: String? = nil, 25 | ttl: String? = nil, 26 | key: String? = nil) { 27 | self.arg = path 28 | self.resolve = resolve 29 | self.lifetime = lifetime 30 | self.ttl = ttl 31 | self.key = key 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/ValidationType.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Represents the status codes to validate through Alamofire. 4 | public enum ValidationType { 5 | 6 | /// No validation. 7 | case none 8 | 9 | /// Validate success codes (only 2xx). 10 | case successCodes 11 | 12 | /// Validate success codes and redirection codes (only 2xx and 3xx). 13 | case successAndRedirectCodes 14 | 15 | /// Validate only the given status codes. 16 | case customCodes([Int]) 17 | 18 | /// The list of HTTP status codes to validate. 19 | var statusCodes: [Int] { 20 | switch self { 21 | case .successCodes: 22 | return Array(200..<300) 23 | case .successAndRedirectCodes: 24 | return Array(200..<400) 25 | case .customCodes(let codes): 26 | return codes 27 | case .none: 28 | return [] 29 | } 30 | } 31 | } 32 | 33 | extension ValidationType: Equatable { 34 | 35 | public static func == (lhs: ValidationType, rhs: ValidationType) -> Bool { 36 | switch (lhs, rhs) { 37 | case (.none, .none), 38 | (.successCodes, .successCodes), 39 | (.successAndRedirectCodes, .successAndRedirectCodes): 40 | return true 41 | case (.customCodes(let code1), .customCodes(let code2)): 42 | return code1 == code2 43 | default: 44 | return false 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsGetModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsGetModel.swift 3 | // IpfsApi 4 | // 5 | // Created by we on 2018. 8. 20.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsGetModel: Codable { 11 | // arg [string]: The path to the IPFS object(s) to be outputted. Required: yes. 12 | public let arg: String 13 | // output [string]: The path where the output should be stored. Required: no. 14 | public let output: String? 15 | // archive [bool]: Output a TAR archive. Default: “false”. Required: no. 16 | public let archive: Bool? 17 | // compress [bool]: Compress the output with GZIP compression. Default: “false”. Required: no. 18 | public let compress: Bool? 19 | // compression-level [int]: The level of compression (1-9). Default: “-1”. Required: no. 20 | public let compressionLevel: Int? 21 | 22 | init(arg: String, 23 | output: String? = nil, 24 | archive: Bool? = nil, 25 | compress: Bool? = nil, 26 | compressionLevel: Int? = nil) { 27 | self.arg = arg 28 | self.output = output 29 | self.archive = archive 30 | self.compress = compress 31 | self.compressionLevel = compressionLevel 32 | } 33 | 34 | enum CodingKeys: String, CodingKey { 35 | case arg 36 | case output 37 | case archive 38 | case compress 39 | case compressionLevel = "compression-level" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Example/IpfsApi/PinnedLSC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PinnedLSC.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 7.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import IGListKit 11 | 12 | class PinnedLSC: ListSectionController { 13 | typealias Item = PinnedVM 14 | var item: Item! 15 | override init(){ 16 | super.init() 17 | inset = UIEdgeInsets(top:0, left:0, bottom: 1, right: 0) 18 | } 19 | override func numberOfItems() -> Int { 20 | return 1 21 | } 22 | override func sizeForItem(at index: Int) -> CGSize { 23 | guard let context = collectionContext, let _ = item else { return .zero } 24 | let width = context.containerSize.width 25 | let height: CGFloat = 90.0 26 | return CGSize(width: width, height: height) 27 | } 28 | override func cellForItem(at index: Int) -> UICollectionViewCell { 29 | let cellIdentifier = "PinnedCell" 30 | guard let cell = collectionContext?.dequeueReusableCellFromStoryboard(withIdentifier: cellIdentifier, for: self, at: index) as? PinnedCell else {fatalError()} 31 | cell.update(item) 32 | 33 | return cell 34 | } 35 | override func didUpdate(to object: Any) { 36 | item = object as? Item 37 | } 38 | override func didSelectItem(at index: Int) { 39 | collectionContext?.cellForItem(at: index, sectionController: self)?.isSelected = false 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Example/IpfsApi/DemoLSC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DemoLSC.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 4.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import IGListKit 11 | 12 | class DemoLSC: ListSectionController { 13 | typealias Item = DemoVM 14 | var item: Item! 15 | override init(){ 16 | super.init() 17 | inset = UIEdgeInsets(top:0, left:0, bottom: 1, right: 0) 18 | } 19 | override func numberOfItems() -> Int { 20 | return 1 21 | } 22 | override func sizeForItem(at index: Int) -> CGSize { 23 | guard let context = collectionContext, let _ = item else { return .zero } 24 | let width = context.containerSize.width 25 | let height: CGFloat = 48.0 26 | return CGSize(width: width, height: height) 27 | } 28 | override func cellForItem(at index: Int) -> UICollectionViewCell { 29 | let cellIdentifier = "DemoCell" 30 | guard let cell = collectionContext?.dequeueReusableCellFromStoryboard(withIdentifier: cellIdentifier, for: self, at: index) as? DemoCell else {fatalError()} 31 | cell.update(item) 32 | 33 | return cell 34 | } 35 | override func didUpdate(to object: Any) { 36 | item = object as? Item 37 | } 38 | override func didSelectItem(at index: Int) { 39 | collectionContext?.cellForItem(at: index, sectionController: self)?.isSelected = false 40 | self.item.handler?() 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Example/IpfsApi/PeerLSC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PeerLSC.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 6.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import IGListKit 11 | 12 | class PeerLSC: ListSectionController { 13 | typealias Item = PeerVM 14 | 15 | var item: Item! 16 | override init(){ 17 | super.init() 18 | inset = UIEdgeInsets(top:0, left:0, bottom: 1, right: 0) 19 | } 20 | 21 | override func numberOfItems() -> Int { 22 | return 1 23 | } 24 | 25 | override func sizeForItem(at index: Int) -> CGSize { 26 | guard let context = collectionContext, let _ = item else { return .zero } 27 | let width = context.containerSize.width 28 | let height: CGFloat = 60.0 29 | return CGSize(width: width, height: height) 30 | } 31 | 32 | override func cellForItem(at index: Int) -> UICollectionViewCell { 33 | let cellIdentifier = "PeerCell" 34 | guard let cell = collectionContext?.dequeueReusableCellFromStoryboard(withIdentifier: cellIdentifier, for: self, at: index) as? PeerCell else {fatalError()} 35 | cell.update(item) 36 | 37 | return cell 38 | } 39 | 40 | 41 | 42 | override func didUpdate(to object: Any) { 43 | item = object as? Item 44 | } 45 | 46 | override func didSelectItem(at index: Int) { 47 | collectionContext?.cellForItem(at: index, sectionController: self)?.isSelected = false 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /IpfsApi.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint IpfsApi.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'IpfsApi' 11 | s.version = '0.2.0' 12 | s.summary = 'A wrapper of the IPFS Client HTTP-API for iOS.' 13 | s.module_name = 'Ipfs' 14 | s.description = <<-DESC 15 | A client library for the IPFS HTTP API, implemented in Swift. Check out IPFS Docs(https://ipfs.io/docs/api/) for the full command reference. 16 | DESC 17 | 18 | s.homepage = 'https://github.com/kjaylee/ios-ipfs-api' 19 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' 20 | s.license = { :type => 'MIT', :file => 'LICENSE' } 21 | s.author = { 'kjaylee' => 'k.jaylee@gmail.com' } 22 | s.source = { :git => 'https://github.com/kjaylee/ios-ipfs-api.git', :tag => s.version.to_s } 23 | s.social_media_url = 'https://twitter.com/kjaylee' 24 | 25 | s.ios.deployment_target = '8.0' 26 | s.osx.deployment_target = '10.10' 27 | s.swift_version = '4.1' 28 | s.source_files = 'IpfsApi/Classes/*.swift' 29 | 30 | # s.resource_bundles = { 31 | # 'IpfsApi' => ['IpfsApi/Assets/*.png'] 32 | # } 33 | 34 | # s.public_header_files = 'Pod/Classes/**/*.h' 35 | # s.frameworks = 'UIKit', 'MapKit' 36 | s.dependency 'Moya', '~> 11.0' 37 | end 38 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/MultiTarget.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A `TargetType` used to enable `MoyaProvider` to process multiple `TargetType`s. 4 | public enum MultiTarget: TargetType { 5 | /// The embedded `TargetType`. 6 | case target(TargetType) 7 | 8 | /// Initializes a `MultiTarget`. 9 | public init(_ target: TargetType) { 10 | self = MultiTarget.target(target) 11 | } 12 | 13 | /// The embedded target's base `URL`. 14 | public var path: String { 15 | return target.path 16 | } 17 | 18 | /// The baseURL of the embedded target. 19 | public var baseURL: URL { 20 | return target.baseURL 21 | } 22 | 23 | /// The HTTP method of the embedded target. 24 | public var method: Moya.Method { 25 | return target.method 26 | } 27 | 28 | /// The sampleData of the embedded target. 29 | public var sampleData: Data { 30 | return target.sampleData 31 | } 32 | 33 | /// The `Task` of the embedded target. 34 | public var task: Task { 35 | return target.task 36 | } 37 | 38 | /// The `ValidationType` of the embedded target. 39 | public var validationType: ValidationType { 40 | return target.validationType 41 | } 42 | 43 | /// The headers of the embedded target. 44 | public var headers: [String: String]? { 45 | return target.headers 46 | } 47 | 48 | /// The embedded `TargetType`. 49 | public var target: TargetType { 50 | switch self { 51 | case .target(let target): return target 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/MoyaProvider+Defaults.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// These functions are default mappings to `MoyaProvider`'s properties: endpoints, requests, manager, etc. 4 | public extension MoyaProvider { 5 | public final class func defaultEndpointMapping(for target: Target) -> Endpoint { 6 | return Endpoint( 7 | url: URL(target: target).absoluteString, 8 | sampleResponseClosure: { .networkResponse(200, target.sampleData) }, 9 | method: target.method, 10 | task: target.task, 11 | httpHeaderFields: target.headers 12 | ) 13 | } 14 | 15 | public final class func defaultRequestMapping(for endpoint: Endpoint, closure: RequestResultClosure) { 16 | do { 17 | let urlRequest = try endpoint.urlRequest() 18 | closure(.success(urlRequest)) 19 | } catch MoyaError.requestMapping(let url) { 20 | closure(.failure(MoyaError.requestMapping(url))) 21 | } catch MoyaError.parameterEncoding(let error) { 22 | closure(.failure(MoyaError.parameterEncoding(error))) 23 | } catch { 24 | closure(.failure(MoyaError.underlying(error, nil))) 25 | } 26 | } 27 | 28 | public final class func defaultAlamofireManager() -> Manager { 29 | let configuration = URLSessionConfiguration.default 30 | configuration.httpAdditionalHeaders = Manager.defaultHTTPHeaders 31 | 32 | let manager = Manager(configuration: configuration) 33 | manager.startRequestsImmediately = false 34 | return manager 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/Task.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Represents an HTTP task. 4 | public enum Task { 5 | 6 | /// A request with no additional data. 7 | case requestPlain 8 | 9 | /// A requests body set with data. 10 | case requestData(Data) 11 | 12 | /// A request body set with `Encodable` type 13 | case requestJSONEncodable(Encodable) 14 | 15 | /// A request body set with `Encodable` type and custom encoder 16 | case requestCustomJSONEncodable(Encodable, encoder: JSONEncoder) 17 | 18 | /// A requests body set with encoded parameters. 19 | case requestParameters(parameters: [String: Any], encoding: ParameterEncoding) 20 | 21 | /// A requests body set with data, combined with url parameters. 22 | case requestCompositeData(bodyData: Data, urlParameters: [String: Any]) 23 | 24 | /// A requests body set with encoded parameters combined with url parameters. 25 | case requestCompositeParameters(bodyParameters: [String: Any], bodyEncoding: ParameterEncoding, urlParameters: [String: Any]) 26 | 27 | /// A file upload task. 28 | case uploadFile(URL) 29 | 30 | /// A "multipart/form-data" upload task. 31 | case uploadMultipart([MultipartFormData]) 32 | 33 | /// A "multipart/form-data" upload task combined with url parameters. 34 | case uploadCompositeMultipart([MultipartFormData], urlParameters: [String: Any]) 35 | 36 | /// A file download task to a destination. 37 | case downloadDestination(DownloadDestination) 38 | 39 | /// A file download task to a destination with extra parameters using the given encoding. 40 | case downloadParameters(parameters: [String: Any], encoding: ParameterEncoding, destination: DownloadDestination) 41 | } 42 | -------------------------------------------------------------------------------- /Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DispatchQueue+Alamofire.swift 3 | // 4 | // Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | 25 | import Dispatch 26 | import Foundation 27 | 28 | extension DispatchQueue { 29 | static var userInteractive: DispatchQueue { return DispatchQueue.global(qos: .userInteractive) } 30 | static var userInitiated: DispatchQueue { return DispatchQueue.global(qos: .userInitiated) } 31 | static var utility: DispatchQueue { return DispatchQueue.global(qos: .utility) } 32 | static var background: DispatchQueue { return DispatchQueue.global(qos: .background) } 33 | 34 | func after(_ delay: TimeInterval, execute closure: @escaping () -> Void) { 35 | asyncAfter(deadline: .now() + delay, execute: closure) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Example/IpfsApi/PinnedCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PinnedCell.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 7.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Alamofire 11 | import AlamofireImage 12 | import FontAwesomeKit 13 | 14 | 15 | class PinnedCell: Cell { 16 | typealias Item = PinnedVM 17 | @IBOutlet weak var titleLabel: UILabel! 18 | @IBOutlet weak var imageView: UIImageView! 19 | @IBOutlet weak var typeLabel: UILabel! 20 | var request: Request? 21 | override func update(_ item: Item? = nil) { 22 | guard let item = item else { return } 23 | self.imageView.image = FAKFontAwesome.cloudDownloadIcon(withSize: 50).fontToImage() 24 | self.titleLabel.text = item.key 25 | self.typeLabel.text = item.type 26 | guard let hash = item.key else { return } 27 | guard let url = URL(string: "https://ipfs.io/ipfs/\(hash)") else { return } 28 | if let image = item.image { 29 | self.imageView.image = image 30 | } 31 | else { 32 | Alamofire.request(url.absoluteString).responseImage { [weak self] response in 33 | if let image = response.result.value, 34 | response.request?.url?.absoluteString == url.absoluteString { 35 | self?.imageView.image = image 36 | item.image = image 37 | } 38 | else if response.request?.url?.absoluteString == url.absoluteString { 39 | self?.imageView.image = FAKFontAwesome.cloudIcon(withSize: 50).fontToImage(color: .black) 40 | } 41 | } 42 | } 43 | } 44 | } 45 | fileprivate extension FAKIcon { 46 | func fontToImage(color:UIColor = .lightGray) -> UIImage { 47 | self.addAttribute(NSAttributedStringKey.foregroundColor.rawValue, value: color) 48 | return (self.image(with: CGSize(width: 90, height: 90)))! 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Example/IpfsApi/PeersVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PeersVC.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 6.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import RxSwift 11 | import Moya 12 | import Ipfs 13 | import IGListKit 14 | import PopupDialog 15 | 16 | class PeersVC: ListVC, AdaptedCollectionViewProtocol { 17 | typealias Item = PeerVM 18 | @IBOutlet weak var collectionView: UICollectionView! 19 | let disposeBag = DisposeBag() 20 | var count: Int = 0 21 | override func viewDidLoad() { 22 | super.viewDidLoad() 23 | self.title = "Swarm peers" 24 | initializeListView() 25 | request() 26 | self.navigationItem.setRightBarButton(UIBarButtonItem(title: "Reload", style: .plain, target: self, action: #selector(self.request)), animated: true) 27 | } 28 | @objc func request() { 29 | let service = IAService.swarmPeers(arguments: nil) 30 | let queue = DispatchQueue(label: service.path, qos: .utility, attributes: [.concurrent]) 31 | Ipfs.shared().rx.request(MultiTarget(service), callbackQueue: queue) 32 | .filterSuccessfulStatusCodes() 33 | .map(ResponseSwarmPeersModel.self) 34 | .subscribe(onSuccess: { (model) in 35 | print("model count: \(model.peers?.count ?? 0)") 36 | print("model peers: \(String(describing: model.peers ?? nil))") 37 | self.items = (model.peers?.map { PeerVM(model:$0) }) ?? [] 38 | self.count = model.peers?.count ?? 0 39 | self.reloadData() 40 | }) { (error) in 41 | print("failure: \(error.localizedDescription)") 42 | let alert = PopupDialog(title: "Error", message: error.localizedDescription) 43 | self.present(alert, animated: true, completion: { 44 | 45 | }) 46 | }.disposed(by: self.disposeBag) 47 | } 48 | func reloadData() { 49 | DispatchQueue.main.async { 50 | self.title = "Swarm peers - \(self.count)" 51 | self.adapter?.reloadData(completion: { (bool) in 52 | }) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/Plugin.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Result 3 | 4 | /// A Moya Plugin receives callbacks to perform side effects wherever a request is sent or received. 5 | /// 6 | /// for example, a plugin may be used to 7 | /// - log network requests 8 | /// - hide and show a network activity indicator 9 | /// - inject additional information into a request 10 | public protocol PluginType { 11 | /// Called to modify a request before sending. 12 | func prepare(_ request: URLRequest, target: TargetType) -> URLRequest 13 | 14 | /// Called immediately before a request is sent over the network (or stubbed). 15 | func willSend(_ request: RequestType, target: TargetType) 16 | 17 | /// Called after a response has been received, but before the MoyaProvider has invoked its completion handler. 18 | func didReceive(_ result: Result, target: TargetType) 19 | 20 | /// Called to modify a result before completion. 21 | func process(_ result: Result, target: TargetType) -> Result 22 | } 23 | 24 | public extension PluginType { 25 | func prepare(_ request: URLRequest, target: TargetType) -> URLRequest { return request } 26 | func willSend(_ request: RequestType, target: TargetType) { } 27 | func didReceive(_ result: Result, target: TargetType) { } 28 | func process(_ result: Result, target: TargetType) -> Result { return result } 29 | } 30 | 31 | /// Request type used by `willSend` plugin function. 32 | public protocol RequestType { 33 | 34 | // Note: 35 | // 36 | // We use this protocol instead of the Alamofire request to avoid leaking that abstraction. 37 | // A plugin should not know about Alamofire at all. 38 | 39 | /// Retrieve an `NSURLRequest` representation. 40 | var request: URLRequest? { get } 41 | 42 | /// Authenticates the request with a username and password. 43 | func authenticate(user: String, password: String, persistence: URLCredential.Persistence) -> Self 44 | 45 | /// Authenticates the request with an `NSURLCredential` instance. 46 | func authenticate(usingCredential credential: URLCredential) -> Self 47 | } 48 | -------------------------------------------------------------------------------- /Example/IpfsApi/PinnedVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PinnedVC.swift 3 | // IpfsApi_Example 4 | // 5 | // Created by we on 2018. 9. 7.. 6 | // Copyright © 2018년 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Ipfs 11 | import PopupDialog 12 | 13 | class PinnedVC: ListVC, AdaptedCollectionViewProtocol { 14 | typealias Item = PinnedVM 15 | @IBOutlet weak var collectionView: UICollectionView! 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | self.title = "Pinned files" 19 | initializeListView() 20 | request() 21 | } 22 | } 23 | 24 | extension PinnedVC { 25 | func request() { 26 | Ipfs.pin.ls { (result) in 27 | switch result { 28 | case let .success(moyaResponse): 29 | let data = moyaResponse.data 30 | let statusCode = moyaResponse.statusCode 31 | // do something with the response data or statusCode 32 | print("statusCode: \(statusCode)") 33 | print("result: \(data)") 34 | self.items = (try? moyaResponse.map(PinnedObjectsModel.self))?.keys?.map { 35 | PinnedVM(model: Pinned(id: $0.0 as NSString, key: $0.0, pinnedObject: $0.1)) 36 | } ?? [PinnedVM]() 37 | self.reloadData() 38 | break 39 | case let .failure(error): 40 | // this means there was a network failure - either the request 41 | // wasn't sent (connectivity), or no response was received (server 42 | // timed out). If the server responds with a 4xx or 5xx error, that 43 | // will be sent as a ".success"-ful response. 44 | print("failure: \(error.localizedDescription)") 45 | let alert = PopupDialog(title: "Error", message: error.localizedDescription) 46 | self.present(alert, animated: true, completion: { 47 | 48 | }) 49 | break 50 | } 51 | } 52 | } 53 | func reloadData() { 54 | DispatchQueue.main.async { 55 | self.title = "Pinned files - \(self.items.count)" 56 | self.adapter?.reloadData(completion: { (bool) in 57 | }) 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Example/IpfsApi/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // IpfsApi 4 | // 5 | // Created by kjaylee on 08/17/2018. 6 | // Copyright (c) 2018 kjaylee. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/Plugins/AccessTokenPlugin.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Result 3 | 4 | // MARK: - AccessTokenAuthorizable 5 | 6 | /// A protocol for controlling the behavior of `AccessTokenPlugin`. 7 | public protocol AccessTokenAuthorizable { 8 | 9 | /// Represents the authorization header to use for requests. 10 | var authorizationType: AuthorizationType { get } 11 | } 12 | 13 | // MARK: - AuthorizationType 14 | 15 | /// An enum representing the header to use with an `AccessTokenPlugin` 16 | public enum AuthorizationType: String { 17 | /// No header. 18 | case none 19 | 20 | /// The `"Basic"` header. 21 | case basic = "Basic" 22 | 23 | /// The `"Bearer"` header. 24 | case bearer = "Bearer" 25 | } 26 | 27 | // MARK: - AccessTokenPlugin 28 | 29 | /** 30 | A plugin for adding basic or bearer-type authorization headers to requests. Example: 31 | 32 | ``` 33 | Authorization: Bearer 34 | Authorization: Basic 35 | ``` 36 | 37 | */ 38 | public struct AccessTokenPlugin: PluginType { 39 | 40 | /// A closure returning the access token to be applied in the header. 41 | public let tokenClosure: () -> String 42 | 43 | /** 44 | Initialize a new `AccessTokenPlugin`. 45 | 46 | - parameters: 47 | - tokenClosure: A closure returning the token to be applied in the pattern `Authorization: ` 48 | */ 49 | public init(tokenClosure: @escaping @autoclosure () -> String) { 50 | self.tokenClosure = tokenClosure 51 | } 52 | 53 | /** 54 | Prepare a request by adding an authorization header if necessary. 55 | 56 | - parameters: 57 | - request: The request to modify. 58 | - target: The target of the request. 59 | - returns: The modified `URLRequest`. 60 | */ 61 | public func prepare(_ request: URLRequest, target: TargetType) -> URLRequest { 62 | guard let authorizable = target as? AccessTokenAuthorizable else { return request } 63 | 64 | let authorizationType = authorizable.authorizationType 65 | 66 | var request = request 67 | 68 | switch authorizationType { 69 | case .basic, .bearer: 70 | let authValue = authorizationType.rawValue + " " + tokenClosure() 71 | request.addValue(authValue, forHTTPHeaderField: "Authorization") 72 | case .none: 73 | break 74 | } 75 | 76 | return request 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/MultipartFormData.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Alamofire 3 | 4 | /// Represents "multipart/form-data" for an upload. 5 | public struct MultipartFormData { 6 | 7 | /// Method to provide the form data. 8 | public enum FormDataProvider { 9 | case data(Foundation.Data) 10 | case file(URL) 11 | case stream(InputStream, UInt64) 12 | } 13 | 14 | public init(provider: FormDataProvider, name: String, fileName: String? = nil, mimeType: String? = nil) { 15 | self.provider = provider 16 | self.name = name 17 | self.fileName = fileName 18 | self.mimeType = mimeType 19 | } 20 | 21 | /// The method being used for providing form data. 22 | public let provider: FormDataProvider 23 | 24 | /// The name. 25 | public let name: String 26 | 27 | /// The file name. 28 | public let fileName: String? 29 | 30 | /// The MIME type 31 | public let mimeType: String? 32 | 33 | } 34 | 35 | // MARK: RequestMultipartFormData appending 36 | internal extension RequestMultipartFormData { 37 | func append(data: Data, bodyPart: MultipartFormData) { 38 | if let mimeType = bodyPart.mimeType { 39 | if let fileName = bodyPart.fileName { 40 | append(data, withName: bodyPart.name, fileName: fileName, mimeType: mimeType) 41 | } else { 42 | append(data, withName: bodyPart.name, mimeType: mimeType) 43 | } 44 | } else { 45 | append(data, withName: bodyPart.name) 46 | } 47 | } 48 | 49 | func append(fileURL url: URL, bodyPart: MultipartFormData) { 50 | if let fileName = bodyPart.fileName, let mimeType = bodyPart.mimeType { 51 | append(url, withName: bodyPart.name, fileName: fileName, mimeType: mimeType) 52 | } else { 53 | append(url, withName: bodyPart.name) 54 | } 55 | } 56 | 57 | func append(stream: InputStream, length: UInt64, bodyPart: MultipartFormData) { 58 | append(stream, withLength: length, name: bodyPart.name, fileName: bodyPart.fileName ?? "", mimeType: bodyPart.mimeType ?? "") 59 | } 60 | 61 | func applyMoyaMultipartFormData(_ multipartBody: [Moya.MultipartFormData]) { 62 | for bodyPart in multipartBody { 63 | switch bodyPart.provider { 64 | case .data(let data): 65 | append(data: data, bodyPart: bodyPart) 66 | case .file(let url): 67 | append(fileURL: url, bodyPart: bodyPart) 68 | case .stream(let stream, let length): 69 | append(stream: stream, length: length, bodyPart: bodyPart) 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Tests/Pods-IpfsApi_Tests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/AlamofireImage" "${PODS_CONFIGURATION_BUILD_DIR}/DynamicBlurView" "${PODS_CONFIGURATION_BUILD_DIR}/FontAwesomeKit" "${PODS_CONFIGURATION_BUILD_DIR}/Hero" "${PODS_CONFIGURATION_BUILD_DIR}/IGListKit" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" "${PODS_CONFIGURATION_BUILD_DIR}/IpfsApi" "${PODS_CONFIGURATION_BUILD_DIR}/Moya" "${PODS_CONFIGURATION_BUILD_DIR}/PopupDialog" "${PODS_CONFIGURATION_BUILD_DIR}/Result" "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift" "${PODS_CONFIGURATION_BUILD_DIR}/TUSafariActivity" "${PODS_CONFIGURATION_BUILD_DIR}/Viewer" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AlamofireImage/AlamofireImage.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/DynamicBlurView/DynamicBlurView.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/FontAwesomeKit/FontAwesomeKit.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Hero/Hero.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IGListKit/IGListKit.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IpfsApi/Ipfs.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Moya/Moya.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/PopupDialog/PopupDialog.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Result/Result.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift/RxSwift.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/TUSafariActivity/TUSafariActivity.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Viewer/Viewer.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -l"c++" -framework "Accelerate" -framework "Alamofire" -framework "AlamofireImage" -framework "CoreGraphics" -framework "CoreText" -framework "DynamicBlurView" -framework "FontAwesomeKit" -framework "Foundation" -framework "Hero" -framework "IGListKit" -framework "IQKeyboardManagerSwift" -framework "Ipfs" -framework "Moya" -framework "PopupDialog" -framework "QuartzCore" -framework "Result" -framework "RxSwift" -framework "TUSafariActivity" -framework "UIKit" -framework "Viewer" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Tests/Pods-IpfsApi_Tests.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/AlamofireImage" "${PODS_CONFIGURATION_BUILD_DIR}/DynamicBlurView" "${PODS_CONFIGURATION_BUILD_DIR}/FontAwesomeKit" "${PODS_CONFIGURATION_BUILD_DIR}/Hero" "${PODS_CONFIGURATION_BUILD_DIR}/IGListKit" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" "${PODS_CONFIGURATION_BUILD_DIR}/IpfsApi" "${PODS_CONFIGURATION_BUILD_DIR}/Moya" "${PODS_CONFIGURATION_BUILD_DIR}/PopupDialog" "${PODS_CONFIGURATION_BUILD_DIR}/Result" "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift" "${PODS_CONFIGURATION_BUILD_DIR}/TUSafariActivity" "${PODS_CONFIGURATION_BUILD_DIR}/Viewer" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AlamofireImage/AlamofireImage.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/DynamicBlurView/DynamicBlurView.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/FontAwesomeKit/FontAwesomeKit.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Hero/Hero.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IGListKit/IGListKit.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IpfsApi/Ipfs.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Moya/Moya.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/PopupDialog/PopupDialog.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Result/Result.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift/RxSwift.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/TUSafariActivity/TUSafariActivity.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Viewer/Viewer.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -l"c++" -framework "Accelerate" -framework "Alamofire" -framework "AlamofireImage" -framework "CoreGraphics" -framework "CoreText" -framework "DynamicBlurView" -framework "FontAwesomeKit" -framework "Foundation" -framework "Hero" -framework "IGListKit" -framework "IQKeyboardManagerSwift" -framework "Ipfs" -framework "Moya" -framework "PopupDialog" -framework "QuartzCore" -framework "Result" -framework "RxSwift" -framework "TUSafariActivity" -framework "UIKit" -framework "Viewer" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Example/Pods-IpfsApi_Example.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/AlamofireImage" "${PODS_CONFIGURATION_BUILD_DIR}/DynamicBlurView" "${PODS_CONFIGURATION_BUILD_DIR}/FontAwesomeKit" "${PODS_CONFIGURATION_BUILD_DIR}/Hero" "${PODS_CONFIGURATION_BUILD_DIR}/IGListKit" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" "${PODS_CONFIGURATION_BUILD_DIR}/IpfsApi" "${PODS_CONFIGURATION_BUILD_DIR}/Moya" "${PODS_CONFIGURATION_BUILD_DIR}/PopupDialog" "${PODS_CONFIGURATION_BUILD_DIR}/Result" "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift" "${PODS_CONFIGURATION_BUILD_DIR}/TUSafariActivity" "${PODS_CONFIGURATION_BUILD_DIR}/Viewer" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AlamofireImage/AlamofireImage.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/DynamicBlurView/DynamicBlurView.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/FontAwesomeKit/FontAwesomeKit.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Hero/Hero.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IGListKit/IGListKit.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IpfsApi/Ipfs.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Moya/Moya.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/PopupDialog/PopupDialog.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Result/Result.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift/RxSwift.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/TUSafariActivity/TUSafariActivity.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Viewer/Viewer.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -l"c++" -framework "Accelerate" -framework "Alamofire" -framework "AlamofireImage" -framework "CoreGraphics" -framework "CoreText" -framework "DynamicBlurView" -framework "FontAwesomeKit" -framework "Foundation" -framework "Hero" -framework "IGListKit" -framework "IQKeyboardManagerSwift" -framework "Ipfs" -framework "Moya" -framework "PopupDialog" -framework "QuartzCore" -framework "Result" -framework "RxSwift" -framework "TUSafariActivity" -framework "UIKit" -framework "Viewer" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-IpfsApi_Example/Pods-IpfsApi_Example.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/AlamofireImage" "${PODS_CONFIGURATION_BUILD_DIR}/DynamicBlurView" "${PODS_CONFIGURATION_BUILD_DIR}/FontAwesomeKit" "${PODS_CONFIGURATION_BUILD_DIR}/Hero" "${PODS_CONFIGURATION_BUILD_DIR}/IGListKit" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" "${PODS_CONFIGURATION_BUILD_DIR}/IpfsApi" "${PODS_CONFIGURATION_BUILD_DIR}/Moya" "${PODS_CONFIGURATION_BUILD_DIR}/PopupDialog" "${PODS_CONFIGURATION_BUILD_DIR}/Result" "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift" "${PODS_CONFIGURATION_BUILD_DIR}/TUSafariActivity" "${PODS_CONFIGURATION_BUILD_DIR}/Viewer" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AlamofireImage/AlamofireImage.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/DynamicBlurView/DynamicBlurView.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/FontAwesomeKit/FontAwesomeKit.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Hero/Hero.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IGListKit/IGListKit.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/IpfsApi/Ipfs.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Moya/Moya.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/PopupDialog/PopupDialog.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Result/Result.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/RxSwift/RxSwift.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/TUSafariActivity/TUSafariActivity.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Viewer/Viewer.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -l"c++" -framework "Accelerate" -framework "Alamofire" -framework "AlamofireImage" -framework "CoreGraphics" -framework "CoreText" -framework "DynamicBlurView" -framework "FontAwesomeKit" -framework "Foundation" -framework "Hero" -framework "IGListKit" -framework "IQKeyboardManagerSwift" -framework "Ipfs" -framework "Moya" -framework "PopupDialog" -framework "QuartzCore" -framework "Result" -framework "RxSwift" -framework "TUSafariActivity" -framework "UIKit" -framework "Viewer" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/IpfsApi/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // IpfsApi 4 | // 5 | // Created by kjaylee on 08/17/2018. 6 | // Copyright (c) 2018 kjaylee. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import RxSwift 11 | import Moya 12 | import Ipfs 13 | import IGListKit 14 | import PopupDialog 15 | import Hero 16 | 17 | class ViewController: ListVC, AdaptedCollectionViewProtocol { 18 | typealias Item = DemoVM 19 | @IBOutlet weak var collectionView: UICollectionView! 20 | let disposeBag = DisposeBag() 21 | override func viewDidLoad() { 22 | super.viewDidLoad() 23 | self.title = "ios-ipfs-api Demo" 24 | initializeItems() 25 | initializeListView() 26 | } 27 | override func viewWillAppear(_ animated: Bool) { 28 | super.viewWillAppear(animated) 29 | } 30 | } 31 | extension ViewController { 32 | func initializeItems() { 33 | self.items.removeAll() 34 | self.items.append(Item(model: Demo(id: "1", title:"Change Host", handler: { 35 | guard let vc = self.storyboard?.instantiateViewController(withIdentifier: "TextFieldVC") as? TextFieldVC else { return } 36 | vc.title = "Change host" 37 | vc.subtitle = "host address" 38 | vc.placeholder = Ipfs.shared().address() 39 | let alert = PopupDialog(viewController: vc) 40 | alert.addButtons([ 41 | DefaultButton(title: "Save", action: { 42 | if vc.textField != nil { 43 | Ipfs.shared().setBase(fullAddress: vc.textField.text!) 44 | } 45 | }), 46 | DefaultButton(title: "Reset", action: { 47 | Ipfs.shared().setBase(fullAddress:"http://127.0.0.1:5001/api/v0") 48 | }), 49 | CancelButton(title: "Cancel", action: nil) 50 | ]) 51 | self.present(alert, animated: true, completion: { 52 | 53 | }) 54 | }))) 55 | self.items.append(Item(model: Demo(id: "2", title:"Swarm peers", handler: { 56 | guard let vc = self.storyboard?.instantiateViewController(withIdentifier: "PeersVC") as? PeersVC else { return } 57 | self.navigationController?.pushViewController(vc, animated: true) 58 | }))) 59 | self.items.append(Item(model: Demo(id: "3", title:"File add&pin test", handler: { 60 | guard let vc = self.storyboard?.instantiateViewController(withIdentifier: "FileVC") as? FileVC else { return } 61 | self.navigationController?.pushViewController(vc, animated: true) 62 | }))) 63 | self.items.append(Item(model: Demo(id: "4", title:"Pinned files", handler: { 64 | guard let vc = self.storyboard?.instantiateViewController(withIdentifier: "PinnedVC") as? PinnedVC else { return } 65 | self.navigationController?.pushViewController(vc, animated: true) 66 | }))) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/MoyaError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A type representing possible errors Moya can throw. 4 | public enum MoyaError: Swift.Error { 5 | 6 | /// Indicates a response failed to map to an image. 7 | case imageMapping(Response) 8 | 9 | /// Indicates a response failed to map to a JSON structure. 10 | case jsonMapping(Response) 11 | 12 | /// Indicates a response failed to map to a String. 13 | case stringMapping(Response) 14 | 15 | /// Indicates a response failed to map to a Decodable object. 16 | case objectMapping(Swift.Error, Response) 17 | 18 | /// Indicates that Encodable couldn't be encoded into Data 19 | case encodableMapping(Swift.Error) 20 | 21 | /// Indicates a response failed with an invalid HTTP status code. 22 | case statusCode(Response) 23 | 24 | /// Indicates a response failed due to an underlying `Error`. 25 | case underlying(Swift.Error, Response?) 26 | 27 | /// Indicates that an `Endpoint` failed to map to a `URLRequest`. 28 | case requestMapping(String) 29 | 30 | /// Indicates that an `Endpoint` failed to encode the parameters for the `URLRequest`. 31 | case parameterEncoding(Swift.Error) 32 | } 33 | 34 | public extension MoyaError { 35 | /// Depending on error type, returns a `Response` object. 36 | var response: Moya.Response? { 37 | switch self { 38 | case .imageMapping(let response): return response 39 | case .jsonMapping(let response): return response 40 | case .stringMapping(let response): return response 41 | case .objectMapping(_, let response): return response 42 | case .statusCode(let response): return response 43 | case .underlying(_, let response): return response 44 | case .encodableMapping: return nil 45 | case .requestMapping: return nil 46 | case .parameterEncoding: return nil 47 | } 48 | } 49 | } 50 | 51 | // MARK: - Error Descriptions 52 | 53 | extension MoyaError: LocalizedError { 54 | public var errorDescription: String? { 55 | switch self { 56 | case .imageMapping: 57 | return "Failed to map data to an Image." 58 | case .jsonMapping: 59 | return "Failed to map data to JSON." 60 | case .stringMapping: 61 | return "Failed to map data to a String." 62 | case .objectMapping: 63 | return "Failed to map data to a Decodable object." 64 | case .encodableMapping: 65 | return "Failed to encode Encodable object into data." 66 | case .statusCode: 67 | return "Status code didn't fall within the given range." 68 | case .requestMapping: 69 | return "Failed to map Endpoint to a URLRequest." 70 | case .parameterEncoding(let error): 71 | return "Failed to encode parameters for URLRequest. \(error.localizedDescription)" 72 | case .underlying(let error, _): 73 | return error.localizedDescription 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Example/Pods/Alamofire/Source/Notifications.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Notifications.swift 3 | // 4 | // Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | 25 | import Foundation 26 | 27 | extension Notification.Name { 28 | /// Used as a namespace for all `URLSessionTask` related notifications. 29 | public struct Task { 30 | /// Posted when a `URLSessionTask` is resumed. The notification `object` contains the resumed `URLSessionTask`. 31 | public static let DidResume = Notification.Name(rawValue: "org.alamofire.notification.name.task.didResume") 32 | 33 | /// Posted when a `URLSessionTask` is suspended. The notification `object` contains the suspended `URLSessionTask`. 34 | public static let DidSuspend = Notification.Name(rawValue: "org.alamofire.notification.name.task.didSuspend") 35 | 36 | /// Posted when a `URLSessionTask` is cancelled. The notification `object` contains the cancelled `URLSessionTask`. 37 | public static let DidCancel = Notification.Name(rawValue: "org.alamofire.notification.name.task.didCancel") 38 | 39 | /// Posted when a `URLSessionTask` is completed. The notification `object` contains the completed `URLSessionTask`. 40 | public static let DidComplete = Notification.Name(rawValue: "org.alamofire.notification.name.task.didComplete") 41 | } 42 | } 43 | 44 | // MARK: - 45 | 46 | extension Notification { 47 | /// Used as a namespace for all `Notification` user info dictionary keys. 48 | public struct Key { 49 | /// User info dictionary key representing the `URLSessionTask` associated with the notification. 50 | public static let Task = "org.alamofire.notification.key.task" 51 | 52 | /// User info dictionary key representing the responseData associated with the notification. 53 | public static let ResponseData = "org.alamofire.notification.key.responseData" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ios-ipfs-api.xcodeproj/xcshareddata/xcschemes/ios-ipfs-api.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Alamofire (4.7.3) 3 | - AlamofireImage (3.3.1): 4 | - Alamofire (~> 4.5) 5 | - DynamicBlurView (2.0.2) 6 | - FontAwesomeKit (2.2.1): 7 | - FontAwesomeKit/Core (= 2.2.1) 8 | - FontAwesomeKit/FontAwesome (= 2.2.1) 9 | - FontAwesomeKit/FoundationIcons (= 2.2.1) 10 | - FontAwesomeKit/IonIcons (= 2.2.1) 11 | - FontAwesomeKit/Material (= 2.2.1) 12 | - FontAwesomeKit/Octicons (= 2.2.1) 13 | - FontAwesomeKit/Zocial (= 2.2.1) 14 | - FontAwesomeKit/Core (2.2.1) 15 | - FontAwesomeKit/FontAwesome (2.2.1): 16 | - FontAwesomeKit/Core 17 | - FontAwesomeKit/FoundationIcons (2.2.1): 18 | - FontAwesomeKit/Core 19 | - FontAwesomeKit/IonIcons (2.2.1): 20 | - FontAwesomeKit/Core 21 | - FontAwesomeKit/Material (2.2.1): 22 | - FontAwesomeKit/Core 23 | - FontAwesomeKit/Octicons (2.2.1): 24 | - FontAwesomeKit/Core 25 | - FontAwesomeKit/Zocial (2.2.1): 26 | - FontAwesomeKit/Core 27 | - Hero (1.3.0) 28 | - IGListKit (3.4.0): 29 | - IGListKit/Default (= 3.4.0) 30 | - IGListKit/Default (3.4.0): 31 | - IGListKit/Diffing 32 | - IGListKit/Diffing (3.4.0) 33 | - IpfsApi (0.2.0): 34 | - Moya (~> 11.0) 35 | - IQKeyboardManagerSwift (6.1.1) 36 | - Moya (11.0.2): 37 | - Moya/Core (= 11.0.2) 38 | - Moya/Core (11.0.2): 39 | - Alamofire (~> 4.1) 40 | - Result (~> 3.0) 41 | - Moya/RxSwift (11.0.2): 42 | - Moya/Core 43 | - RxSwift (~> 4.0) 44 | - PopupDialog (0.8.1): 45 | - DynamicBlurView (~> 2.0) 46 | - Result (3.2.4) 47 | - RxSwift (4.2.0) 48 | - TUSafariActivity (1.0.4) 49 | - Viewer (3.0.0) 50 | 51 | DEPENDENCIES: 52 | - AlamofireImage 53 | - FontAwesomeKit 54 | - Hero 55 | - IGListKit 56 | - IpfsApi (from `../`) 57 | - IQKeyboardManagerSwift 58 | - Moya/RxSwift (~> 11.0) 59 | - PopupDialog 60 | - TUSafariActivity 61 | - Viewer 62 | 63 | SPEC REPOS: 64 | https://github.com/cocoapods/specs.git: 65 | - Alamofire 66 | - AlamofireImage 67 | - DynamicBlurView 68 | - FontAwesomeKit 69 | - Hero 70 | - IGListKit 71 | - IQKeyboardManagerSwift 72 | - Moya 73 | - PopupDialog 74 | - Result 75 | - RxSwift 76 | - TUSafariActivity 77 | - Viewer 78 | 79 | EXTERNAL SOURCES: 80 | IpfsApi: 81 | :path: "../" 82 | 83 | SPEC CHECKSUMS: 84 | Alamofire: c7287b6e5d7da964a70935e5db17046b7fde6568 85 | AlamofireImage: 3b35b586853abaf94ca1250f4e94cff3c21a4c0d 86 | DynamicBlurView: aa6db4defc6e537eb86fc5e58dd3991666178399 87 | FontAwesomeKit: 3614979b3dbb0ec3f7fac1bd760b91f66c31db67 88 | Hero: 3eecd3fd62dd2425cbc7e35505c557b86d5a379e 89 | IGListKit: 7a5d788e9fb746bcd402baa8e8b24bc3bd2a5a07 90 | IpfsApi: d4905c68b8105377c1350f1ab4d4dfc7cce9f95e 91 | IQKeyboardManagerSwift: 977affaeb4d6e971975c7790a6850f31d38f1207 92 | Moya: a725035953bc1c0eb1be505ab903984501d82440 93 | PopupDialog: 3d4e8e0795c3a614f407d730986c9b9af9781123 94 | Result: d2d07204ce72856f1fd9130bbe42c35a7b0fea10 95 | RxSwift: 99e10317ddfcc7fbe01356aafd118fde4a0be104 96 | TUSafariActivity: afc55a00965377939107ce4fdc7f951f62454546 97 | Viewer: 1820d06cfe48054775a3e979567208dc37eb270d 98 | 99 | PODFILE CHECKSUM: 5839c54888570522d8cb5c5974b3a518937873f2 100 | 101 | COCOAPODS: 1.6.0.beta.1 102 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/Moya+Alamofire.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Alamofire 3 | 4 | public typealias Manager = Alamofire.SessionManager 5 | internal typealias Request = Alamofire.Request 6 | internal typealias DownloadRequest = Alamofire.DownloadRequest 7 | internal typealias UploadRequest = Alamofire.UploadRequest 8 | internal typealias DataRequest = Alamofire.DataRequest 9 | 10 | internal typealias URLRequestConvertible = Alamofire.URLRequestConvertible 11 | 12 | /// Represents an HTTP method. 13 | public typealias Method = Alamofire.HTTPMethod 14 | 15 | /// Choice of parameter encoding. 16 | public typealias ParameterEncoding = Alamofire.ParameterEncoding 17 | public typealias JSONEncoding = Alamofire.JSONEncoding 18 | public typealias URLEncoding = Alamofire.URLEncoding 19 | public typealias PropertyListEncoding = Alamofire.PropertyListEncoding 20 | 21 | /// Multipart form. 22 | public typealias RequestMultipartFormData = Alamofire.MultipartFormData 23 | 24 | /// Multipart form data encoding result. 25 | public typealias MultipartFormDataEncodingResult = Manager.MultipartFormDataEncodingResult 26 | public typealias DownloadDestination = Alamofire.DownloadRequest.DownloadFileDestination 27 | 28 | /// Make the Alamofire Request type conform to our type, to prevent leaking Alamofire to plugins. 29 | extension Request: RequestType { } 30 | 31 | /// Internal token that can be used to cancel requests 32 | public final class CancellableToken: Cancellable, CustomDebugStringConvertible { 33 | let cancelAction: () -> Void 34 | let request: Request? 35 | 36 | public fileprivate(set) var isCancelled = false 37 | 38 | fileprivate var lock: DispatchSemaphore = DispatchSemaphore(value: 1) 39 | 40 | public func cancel() { 41 | _ = lock.wait(timeout: DispatchTime.distantFuture) 42 | defer { lock.signal() } 43 | guard !isCancelled else { return } 44 | isCancelled = true 45 | cancelAction() 46 | } 47 | 48 | public init(action: @escaping () -> Void) { 49 | self.cancelAction = action 50 | self.request = nil 51 | } 52 | 53 | init(request: Request) { 54 | self.request = request 55 | self.cancelAction = { 56 | request.cancel() 57 | } 58 | } 59 | 60 | /// A textual representation of this instance, suitable for debugging. 61 | public var debugDescription: String { 62 | guard let request = self.request else { 63 | return "Empty Request" 64 | } 65 | return request.debugDescription 66 | } 67 | 68 | } 69 | 70 | internal typealias RequestableCompletion = (HTTPURLResponse?, URLRequest?, Data?, Swift.Error?) -> Void 71 | 72 | internal protocol Requestable { 73 | func response(callbackQueue: DispatchQueue?, completionHandler: @escaping RequestableCompletion) -> Self 74 | } 75 | 76 | extension DataRequest: Requestable { 77 | internal func response(callbackQueue: DispatchQueue?, completionHandler: @escaping RequestableCompletion) -> Self { 78 | return response(queue: callbackQueue) { handler in 79 | completionHandler(handler.response, handler.request, handler.data, handler.error) 80 | } 81 | } 82 | } 83 | 84 | extension DownloadRequest: Requestable { 85 | internal func response(callbackQueue: DispatchQueue?, completionHandler: @escaping RequestableCompletion) -> Self { 86 | return response(queue: callbackQueue) { handler in 87 | completionHandler(handler.response, handler.request, nil, handler.error) 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /IpfsApi/Classes/ArgumentsAddModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentsAddModel.swift 3 | // Alamofire 4 | // 5 | // Created by we on 2018. 8. 17.. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct ArgumentsAddModel: Codable { 11 | // recursive [bool]: Add directory paths recursively. Default: “false”. Required: no. 12 | public let recursive: Bool? 13 | // quiet [bool]: Write minimal output. Required: no. 14 | public let quiet: Bool? 15 | // quieter [bool]: Write only final hash. Required: no. 16 | public let quieter: Bool? 17 | // silent [bool]: Write no output. Required: no. 18 | public let silent: Bool? 19 | // progress [bool]: Stream progress data. Required: no. 20 | public let progress: Bool? 21 | // trickle [bool]: Use trickle-dag format for dag generation. Required: no. 22 | public let triclke: Bool? 23 | // only-hash [bool]: Only chunk and hash - do not write to disk. Required: no. 24 | public let onlyHash: Bool? 25 | // wrap-with-directory [bool]: Wrap files with a directory object. Required: no. 26 | public let wrapWithDirectory: Bool? 27 | // hidden [bool]: Include files that are hidden. Only takes effect on recursive add. Required: no. 28 | public let hidden: Bool? 29 | // chunker [string]: Chunking algorithm to use. Required: no. 30 | public let chunker: String? 31 | // pin [bool]: Pin this object when adding. Default: “true”. Required: no. 32 | public let pin: Bool? 33 | // raw-leaves [bool]: Use raw blocks for leaf nodes. (experimental). Required: no. 34 | public let rawLeaves: Bool? 35 | // nocopy [bool]: Add the file using filestore. (experimental). Required: no. 36 | public let nocopy: Bool? 37 | // fscache [bool]: Check the filestore for pre-existing blocks. (experimental). Required: no. 38 | public let fscache: Bool? 39 | // cid-version [int]: Cid version. Non-zero value will change default of ‘raw-leaves’ to true. (experimental). Default: “0”. Required: no. 40 | public let cidVersion: Int? 41 | // hash [string]: Hash function to use. Will set Cid version to 1 if used. (experimental). Default: “sha2-256”. Required: no. 42 | public let hash: String? 43 | 44 | init(recursive: Bool? = nil, 45 | quiet: Bool? = nil, 46 | quieter: Bool? = nil, 47 | silent: Bool? = nil, 48 | progress: Bool? = nil, 49 | triclke: Bool? = nil, 50 | onlyHash: Bool? = nil, 51 | wrapWithDirectory: Bool? = nil, 52 | hidden: Bool? = nil, 53 | chunker: String? = nil, 54 | pin: Bool? = nil, 55 | rawLeaves: Bool? = nil, 56 | nocopy: Bool? = nil, 57 | fscache: Bool? = nil, 58 | cidVersion: Int? = nil, 59 | hash: String? = nil 60 | ) { 61 | self.recursive = recursive 62 | self.quiet = quiet 63 | self.quieter = quieter 64 | self.silent = silent 65 | self.progress = progress 66 | self.triclke = triclke 67 | self.onlyHash = onlyHash 68 | self.wrapWithDirectory = wrapWithDirectory 69 | self.hidden = hidden 70 | self.chunker = chunker 71 | self.pin = pin 72 | self.rawLeaves = rawLeaves 73 | self.nocopy = nocopy 74 | self.fscache = fscache 75 | self.cidVersion = cidVersion 76 | self.hash = hash 77 | } 78 | 79 | enum CodingKeys: String, CodingKey { 80 | case recursive 81 | case quiet 82 | case quieter 83 | case silent 84 | case progress 85 | case triclke 86 | case onlyHash = "only-hash" 87 | case wrapWithDirectory = "wrap-with-directory" 88 | case hidden 89 | case chunker 90 | case pin 91 | case rawLeaves = "raw-leaves" 92 | case nocopy 93 | case fscache 94 | case cidVersion = "cid-version" 95 | case hash 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Example/IpfsApi/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Example/IpfsApi.xcodeproj/xcshareddata/xcschemes/IpfsApi-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /Example/Pods/Moya/Sources/Moya/Plugins/NetworkLoggerPlugin.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Result 3 | 4 | /// Logs network activity (outgoing requests and incoming responses). 5 | public final class NetworkLoggerPlugin: PluginType { 6 | fileprivate let loggerId = "Moya_Logger" 7 | fileprivate let dateFormatString = "dd/MM/yyyy HH:mm:ss" 8 | fileprivate let dateFormatter = DateFormatter() 9 | fileprivate let separator = ", " 10 | fileprivate let terminator = "\n" 11 | fileprivate let cURLTerminator = "\\\n" 12 | fileprivate let output: (_ separator: String, _ terminator: String, _ items: Any...) -> Void 13 | fileprivate let requestDataFormatter: ((Data) -> (String))? 14 | fileprivate let responseDataFormatter: ((Data) -> (Data))? 15 | 16 | /// A Boolean value determing whether response body data should be logged. 17 | public let isVerbose: Bool 18 | public let cURL: Bool 19 | 20 | /// Initializes a NetworkLoggerPlugin. 21 | public init(verbose: Bool = false, cURL: Bool = false, output: ((_ separator: String, _ terminator: String, _ items: Any...) -> Void)? = nil, requestDataFormatter: ((Data) -> (String))? = nil, responseDataFormatter: ((Data) -> (Data))? = nil) { 22 | self.cURL = cURL 23 | self.isVerbose = verbose 24 | self.output = output ?? NetworkLoggerPlugin.reversedPrint 25 | self.requestDataFormatter = requestDataFormatter 26 | self.responseDataFormatter = responseDataFormatter 27 | } 28 | 29 | public func willSend(_ request: RequestType, target: TargetType) { 30 | if let request = request as? CustomDebugStringConvertible, cURL { 31 | output(separator, terminator, request.debugDescription) 32 | return 33 | } 34 | outputItems(logNetworkRequest(request.request as URLRequest?)) 35 | } 36 | 37 | public func didReceive(_ result: Result, target: TargetType) { 38 | if case .success(let response) = result { 39 | outputItems(logNetworkResponse(response.response, data: response.data, target: target)) 40 | } else { 41 | outputItems(logNetworkResponse(nil, data: nil, target: target)) 42 | } 43 | } 44 | 45 | fileprivate func outputItems(_ items: [String]) { 46 | if isVerbose { 47 | items.forEach { output(separator, terminator, $0) } 48 | } else { 49 | output(separator, terminator, items) 50 | } 51 | } 52 | } 53 | 54 | private extension NetworkLoggerPlugin { 55 | 56 | var date: String { 57 | dateFormatter.dateFormat = dateFormatString 58 | dateFormatter.locale = Locale(identifier: "en_US_POSIX") 59 | return dateFormatter.string(from: Date()) 60 | } 61 | 62 | func format(_ loggerId: String, date: String, identifier: String, message: String) -> String { 63 | return "\(loggerId): [\(date)] \(identifier): \(message)" 64 | } 65 | 66 | func logNetworkRequest(_ request: URLRequest?) -> [String] { 67 | 68 | var output = [String]() 69 | 70 | output += [format(loggerId, date: date, identifier: "Request", message: request?.description ?? "(invalid request)")] 71 | 72 | if let headers = request?.allHTTPHeaderFields { 73 | output += [format(loggerId, date: date, identifier: "Request Headers", message: headers.description)] 74 | } 75 | 76 | if let bodyStream = request?.httpBodyStream { 77 | output += [format(loggerId, date: date, identifier: "Request Body Stream", message: bodyStream.description)] 78 | } 79 | 80 | if let httpMethod = request?.httpMethod { 81 | output += [format(loggerId, date: date, identifier: "HTTP Request Method", message: httpMethod)] 82 | } 83 | 84 | if let body = request?.httpBody, let stringOutput = requestDataFormatter?(body) ?? String(data: body, encoding: .utf8), isVerbose { 85 | output += [format(loggerId, date: date, identifier: "Request Body", message: stringOutput)] 86 | } 87 | 88 | return output 89 | } 90 | 91 | func logNetworkResponse(_ response: HTTPURLResponse?, data: Data?, target: TargetType) -> [String] { 92 | guard let response = response else { 93 | return [format(loggerId, date: date, identifier: "Response", message: "Received empty network response for \(target).")] 94 | } 95 | 96 | var output = [String]() 97 | 98 | output += [format(loggerId, date: date, identifier: "Response", message: response.description)] 99 | 100 | if let data = data, let stringData = String(data: responseDataFormatter?(data) ?? data, encoding: String.Encoding.utf8), isVerbose { 101 | output += [stringData] 102 | } 103 | 104 | return output 105 | } 106 | } 107 | 108 | fileprivate extension NetworkLoggerPlugin { 109 | static func reversedPrint(_ separator: String, terminator: String, items: Any...) { 110 | for item in items { 111 | print(item, separator: separator, terminator: terminator) 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ios-ipfs-api 2 | 3 | A wrapper of the IPFS Client HTTP-API for iOS. 4 | 5 | [![CI Status](https://img.shields.io/travis/com/kjaylee/ios-ipfs-api.svg?style=popout)](https://travis-ci.com/kjaylee/ios-ipfs-api) 6 | [![Version](https://img.shields.io/cocoapods/v/IpfsApi.svg?style=popout)](https://cocoapods.org/pods/IpfsApi) 7 | [![License](https://img.shields.io/cocoapods/l/IpfsApi.svg?style=popout)](https://cocoapods.org/pods/IpfsApi) 8 | [![Platform](https://img.shields.io/cocoapods/p/IpfsApi.svg?style=popout)](https://cocoapods.org/pods/IpfsApi) 9 | 10 | Check out [the client API reference](https://ipfs.io/docs/api/) for the full command reference. 11 | 12 | ## TODO 13 | 14 | - [ ] test case. 15 | - [ ] support OSX. 16 | - [x] example app. 17 | - [x] support carthage. 18 | 19 | 20 | ## Example 21 | 22 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 23 | 24 | [![iOS example](http://img.youtube.com/vi/Mh9OITAbNhY/0.jpg)](https://www.youtube.com/watch?v=Mh9OITAbNhY "iOS example") 25 | 26 | 27 | ```swift 28 | import Ipfs 29 | 30 | 31 | //Default base address: "http://127.0.0.1:5001/api/v0" 32 | 33 | //Do nothing... 34 | //Or 35 | Ipfs.shared().setBase(address: "http://your.ipfs.address") 36 | //Or 37 | Ipfs.shared().setBase(address: "http://your.ipfs.address", port: 5001) 38 | //Or 39 | Ipfs.shared().setBase(address: "http://your.ipfs.address", port: 5001, apiVersionPath: "/api/v0") 40 | 41 | ``` 42 | 43 | ```swift 44 | import Ipfs 45 | import Moya 46 | 47 | // /swarm/peers 48 | Ipfs.swarm.peers { (result) in 49 | switch result { 50 | case let .success(moyaResponse): 51 | let data = moyaResponse.data 52 | let statusCode = moyaResponse.statusCode 53 | // do something with the response data or statusCode 54 | print("statusCode: \(statusCode)") 55 | print("result: \(data)") 56 | break 57 | case let .failure(error): 58 | // this means there was a network failure - either the request 59 | // wasn't sent (connectivity), or no response was received (server 60 | // timed out). If the server responds with a 4xx or 5xx error, that 61 | // will be sent as a ".success"-ful response. 62 | print("failure: \(error.localizedDescription)") 63 | break 64 | } 65 | } 66 | 67 | ``` 68 | 69 | ```swift 70 | import Ipfs 71 | import Moya //pod 'Moya/RxSwift' 72 | import RxSwift 73 | 74 | let service = IAService.swarmPeers(arguments: nil) 75 | let queue = DispatchQueue(label: service.path, qos: .utility, attributes: [.concurrent]) 76 | Ipfs.shared().rx.request(MultiTarget(service), callbackQueue: queue) 77 | .filterSuccessfulStatusCodes() 78 | .map(ResponseSwarmPeersModel.self) 79 | .subscribe(onSuccess: { (model) in 80 | print("model count: \(model.peers?.count ?? 0)") 81 | print("model peers: \(String(describing: model.peers ?? nil))") 82 | }) { (error) in 83 | print("failure: \(error.localizedDescription)") 84 | }.disposed(by: disposeBag) 85 | 86 | ``` 87 | 88 | ## Requirements 89 | 90 | - iOS 8.0+ 91 | - Xcode 9.3+ 92 | - Swift 4.1+ 93 | 94 | 95 | ## Installation 96 | 97 | IpfsApi is available through [CocoaPods](https://cocoapods.org). To install 98 | it, simply add the following line to your Podfile: 99 | 100 | ```ruby 101 | pod 'IpfsApi' 102 | ``` 103 | 104 | 105 | ## Test environment setup 106 | 107 | ### Docker usage(https://github.com/ipfs/go-ipfs) 108 | 109 | An IPFS docker image is hosted at [hub.docker.com/r/ipfs/go-ipfs](https://hub.docker.com/r/ipfs/go-ipfs/). 110 | To make files visible inside the container you need to mount a host directory 111 | with the `-v` option to docker. Choose a directory that you want to use to 112 | import/export files from IPFS. You should also choose a directory to store 113 | IPFS files that will persist when you restart the container. 114 | 115 | export ipfs_staging= 116 | export ipfs_data= 117 | 118 | Start a container running ipfs and expose ports 4001, 5001 and 8080: 119 | 120 | docker run -d --name ipfs_host -v $ipfs_staging:/export -v \ 121 | $ipfs_data:/data/ipfs -p 4001:4001 -p 127.0.0.1:8080:8080 \ 122 | -p 127.0.0.1:5001:5001 ipfs/go-ipfs:latest 123 | 124 | Watch the ipfs log: 125 | 126 | docker logs -f ipfs_host 127 | 128 | Wait for ipfs to start. ipfs is running when you see: 129 | 130 | Gateway (readonly) server 131 | listening on /ip4/0.0.0.0/tcp/8080 132 | 133 | You can now stop watching the log. 134 | 135 | Run ipfs commands: 136 | 137 | docker exec ipfs_host ipfs 138 | 139 | For example: connect to peers 140 | 141 | docker exec ipfs_host ipfs swarm peers 142 | 143 | Add files: 144 | 145 | cp -r $ipfs_staging 146 | docker exec ipfs_host ipfs add -r /export/ 147 | 148 | Stop the running container: 149 | 150 | docker stop ipfs_host 151 | 152 | 153 | ## Author 154 | 155 | kjaylee, k.jaylee@gmail.com 156 | 157 | ## License 158 | 159 | IpfsApi is available under the MIT license. See the LICENSE file for more info. 160 | -------------------------------------------------------------------------------- /Example/Pods/Result/README.md: -------------------------------------------------------------------------------- 1 | # Result 2 | 3 | [![Build Status](https://travis-ci.org/antitypical/Result.svg?branch=master)](https://travis-ci.org/antitypical/Result) 4 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 5 | [![CocoaPods](https://img.shields.io/cocoapods/v/Result.svg)](https://cocoapods.org/) 6 | [![Reference Status](https://www.versioneye.com/objective-c/result/reference_badge.svg?style=flat)](https://www.versioneye.com/objective-c/result/references) 7 | 8 | This is a Swift µframework providing `Result`. 9 | 10 | `Result` values are either successful (wrapping `Value`) or failed (wrapping `Error`). This is similar to Swift’s native `Optional` type: `success` is like `some`, and `failure` is like `none` except with an associated `Error` value. The addition of an associated `Error` allows errors to be passed along for logging or displaying to the user. 11 | 12 | Using this µframework instead of rolling your own `Result` type allows you to easily interface with other frameworks that also use `Result`. 13 | 14 | ## Use 15 | 16 | Use `Result` whenever an operation has the possibility of failure. Consider the following example of a function that tries to extract a `String` for a given key from a JSON `Dictionary`. 17 | 18 | ```swift 19 | typealias JSONObject = [String: Any] 20 | 21 | enum JSONError: Error { 22 | case noSuchKey(String) 23 | case typeMismatch 24 | } 25 | 26 | func stringForKey(json: JSONObject, key: String) -> Result { 27 | guard let value = json[key] else { 28 | return .failure(.noSuchKey(key)) 29 | } 30 | 31 | if let value = value as? String { 32 | return .success(value) 33 | } 34 | else { 35 | return .failure(.typeMismatch) 36 | } 37 | } 38 | ``` 39 | 40 | This function provides a more robust wrapper around the default subscripting provided by `Dictionary`. Rather than return `Any?`, it returns a `Result` that either contains the `String` value for the given key, or an `ErrorType` detailing what went wrong. 41 | 42 | One simple way to handle a `Result` is to deconstruct it using a `switch` statement. 43 | 44 | ```swift 45 | switch stringForKey(json, key: "email") { 46 | 47 | case let .success(email): 48 | print("The email is \(email)") 49 | 50 | case let .failure(.noSuchKey(key)): 51 | print("\(key) is not a valid key") 52 | 53 | case .failure(.typeMismatch): 54 | print("Didn't have the right type") 55 | } 56 | ``` 57 | 58 | Using a `switch` statement allows powerful pattern matching, and ensures all possible results are covered. Swift 2.0 offers new ways to deconstruct enums like the `if-case` statement, but be wary as such methods do not ensure errors are handled. 59 | 60 | Other methods available for processing `Result` are detailed in the [API documentation](http://cocoadocs.org/docsets/Result/). 61 | 62 | ## Result vs. Throws 63 | 64 | Swift 2.0 introduces error handling via throwing and catching `Error`. `Result` accomplishes the same goal by encapsulating the result instead of hijacking control flow. The `Result` abstraction enables powerful functionality such as `map` and `flatMap`, making `Result` more composable than `throw`. 65 | 66 | Since dealing with APIs that throw is common, you can convert such functions into a `Result` by using the `materialize` method. Conversely, a `Result` can be used to throw an error by calling `dematerialize`. 67 | 68 | ## Higher Order Functions 69 | 70 | `map` and `flatMap` operate the same as `Optional.map` and `Optional.flatMap` except they apply to `Result`. 71 | 72 | `map` transforms a `Result` into a `Result` of a new type. It does this by taking a function that transforms the `Value` type into a new value. This transformation is only applied in the case of a `success`. In the case of a `failure`, the associated error is re-wrapped in the new `Result`. 73 | 74 | ```swift 75 | // transforms a Result to a Result 76 | let idResult = intForKey(json, key:"id").map { id in String(id) } 77 | ``` 78 | 79 | Here, the final result is either the id as a `String`, or carries over the `failure` from the previous result. 80 | 81 | `flatMap` is similar to `map` in that in transforms the `Result` into another `Result`. However, the function passed into `flatMap` must return a `Result`. 82 | 83 | An in depth discussion of `map` and `flatMap` is beyond the scope of this documentation. If you would like a deeper understanding, read about functors and monads. This article is a good place to [start](http://www.javiersoto.me/post/106875422394). 84 | 85 | ## Integration 86 | 87 | ### Carthage 88 | 89 | 1. Add this repository as a submodule and/or [add it to your Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile) if you’re using [carthage](https://github.com/Carthage/Carthage/) to manage your dependencies. 90 | 2. Drag `Result.xcodeproj` into your project or workspace. 91 | 3. Link your target against `Result.framework`. 92 | 4. Application targets should ensure that the framework gets copied into their application bundle. (Framework targets should instead require the application linking them to include Result.) 93 | 94 | ### Cocoapods 95 | 96 | ```ruby 97 | pod 'Result', '~> 3.0.0' 98 | ``` 99 | 100 | ### Swift Package Manager 101 | 102 | ```swift 103 | import PackageDescription 104 | 105 | let package = Package( 106 | name: "MyProject", 107 | targets: [], 108 | dependencies: [ 109 | .Package(url: "https://github.com/antitypical/Result.git", 110 | majorVersion: 3) 111 | ] 112 | ) 113 | ``` 114 | --------------------------------------------------------------------------------