profile
viewpoint

lowell/cappuccino 1

Web Application Framework in JavaScript and Objective-J

lowell/AFNetworking 0

A delightful iOS and OS X networking framework

lowell/AFOAuth2Manager 0

AFNetworking Extension for OAuth 2 Authentication

lowell/alison 0

A parser of Apple's summary of the Swift grammar.

lowell/Argo 0

Functional JSON parsing library for Swift

lowell/articles 0

Weekly articles for NSHipster.com

lowell/Backlight-for-XCode 0

Highlights the current editing line in Xcode

lowell/BugHub 0

An open source GitHub Issues client for OS X

lowell/Chameleon 0

A Lightweight x Powerful Flat Color Framework for iOS

pull request commentMoya/Moya

Combine: send progress response in completion

@sunshinejr @MaxDesiatov can you take a look at this? :)

bensLine

comment created time in a day

issue commentMoya/Moya

get request with Task.requestCompositeParameters

what the fuck. rubblish moya

InsectQY

comment created time in a day

PublicEvent
PublicEvent

issue openedMoya/Moya

OAuth2 SSO with Moya

Running:

  • Moya (14.0.0):
    • Moya/Core (= 14.0.0)
  • Moya/Core (14.0.0):
    • Alamofire (~> 5.0)

Is it possible (or even recommended) to adapt Moya for use with SSO OAuth2 purposes? (eg. sign-in to Github or Twitter) Any proven plugins that I could perhaps use? Or is it best to just use a separate OAuth2 cocoapod for acquiring the token?

created time in 5 days

PublicEvent

issue closedMoya/Moya

Moya ObjectMapper via SPM

I have been using Cocoapods in my project and I decided to switch to SPM. It seems like Moya ObjectMapper is missing from SPM. Is there a reason it's not included? Thanks in advance

closed time in 7 days

TarekSalama

issue commentMoya/Moya

Moya ObjectMapper via SPM

Oh I didn't know it was in a separate repo. Sorry for the trouble and thanks!

TarekSalama

comment created time in 7 days

issue commentMoya/Moya

Moya ObjectMapper via SPM

hey @TarekSalama - could you please create an issue on the Moya-ObjectMapper repository? we kinda don't really work on the extension, so it would be best to contact people there - though I see that there is a Package.swift, maybe it's just not updated? Not sure.

TarekSalama

comment created time in 7 days

issue openedMoya/Moya

Moya ObjectMapper via SPM

I have been using Cocoapods in my project and I decided to switch to SPM. It seems like Moya ObjectMapper is missing from SPM. Is there a reason it's not included? Thanks in advance

created time in 7 days

pull request commentMoya/Moya

Combine: send progress response in completion

Codecov Report

Merging #2105 (3a54ef3) into development (975110e) will increase coverage by 0.02%. The diff coverage is 100.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #2105      +/-   ##
===============================================
+ Coverage        88.78%   88.80%   +0.02%     
===============================================
  Files               30       30              
  Lines              972      974       +2     
===============================================
+ Hits               863      865       +2     
  Misses             109      109              
Impacted Files Coverage Δ
Sources/CombineMoya/MoyaProvider+Combine.swift 96.77% <100.00%> (+0.22%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9e58dc5...3a54ef3. Read the comment docs.

bensLine

comment created time in 10 days

pull request commentMoya/Moya

Combine: send progress response in completion

<!-- 0 failure: 2 warning: The library files..., Any changes to l... 3 messages

DangerID: danger-id-Danger; -->

<table> <thead> <tr> <th width="50"></th> <th width="100%" data-danger-table="true">Warnings</th> </tr> </thead> <tbody><tr> <td>:warning:</td> <td>The library files were changed, but the tests remained unmodified. Consider updating or adding to the tests to match the library changes.</td> </tr>

<tr> <td>:warning:</td> <td>

Any changes to library code should be reflected in the Changelog. Please consider adding a note there and adhere to the Changelog Guidelines. </td> </tr> </tbody> </table>

<table> <thead> <tr> <th width="50"></th> <th width="100%" data-danger-table="true">Messages</th> </tr> </thead> <tbody><tr> <td>:book:</td> <td>macOS: Executed 321 tests, with 0 failures (0 unexpected) in 16.572 (16.877) seconds</td> </tr>

<tr> <td>:book:</td> <td>tvOS: Executed 321 tests, with 0 failures (0 unexpected) in 14.120 (14.499) seconds</td> </tr>

<tr> <td>:book:</td> <td>iOS: Executed 321 tests, with 0 failures (0 unexpected) in 14.055 (14.435) seconds</td> </tr> </tbody> </table>

<p align="right"> Generated by :no_entry_sign: <a href="https://danger.systems/swift">Danger Swift</a> against 3a54ef39260bef7afbc48e61d06c8100839c8a3b </p>

bensLine

comment created time in 10 days

PR opened Moya/Moya

Combine: send progress response in completion

Fixes #2104

The response is only sent from the completion after it was processed by plugins. If a plugin returns an error the response is not sent at all, instead, an error is sent as completion.

The change did not break existing test cases but I had not time to get in detail into Moya's test suit to add an appropriate test. Would be great if one can point me to the right place or help out.

+3 -1

0 comment

1 changed file

pr created time in 10 days

issue openedMoya/Moya

Combine: response is published before it is processed by plugins ✨

Moya Combine - development branch

When using the Combine extension and performing a requestWithProgressPublisher the response is published before it was processed by plugins.

Expected: the response is published after it was processed by plugins. As result, the response might not be published at all, in case it was mapped to an error by a plugin which would lead to the completion of the stream.

<details> <summary> <b>Details</b> </summary> <br/> Here's an example to point out the issue:

  • we are downloading an image from an URL that does not exist and the backend returns a 404 HTTP status error.
  • the backend response data contains some error description
  • we use a plugin to filter status codes and return an error if it is not a 2xx status code.

Currently, a subscription to the progress publisher will receive the response before it is was processed by the plugin. This leads to unexpected behavior.

here is some made up code to explain it more:

moyaProvider.requestWithProgressPublisher(.image(name: "notFound"))
   .sink(receiveCompletion: { completion in
        guard case let .failure(error) = completion else { return }
        self.showErrorPopup(error)
    }, receiveValue: { progressResponse in
        guard let response = progressResponse.response else { return }
        do {
             self.image = try response.mapImage()
        } catch {
             self.image = .placehodler
        }
    }

Since the 404 response is published before it is processed by the plugins we end up in receiveValue and try to decode the error description in the response data as image. The decoding will fail and throw an error, in which case a placeholder image is used.

However, it's expected that the plugin processes the response before it is forwarded, and hence, maps it to an error. The error will be published as a completion event so we end up in receiveCompletion and show a popup with the error. </details>

created time in 10 days

MemberEvent

issue commentJK3Y/asepsis

What about make a new one that just like asepsis?

@davidkaufman If you want deleted .DS_Store anyway than keep it in a cage. There are several ways. It's much easier.

  1. Inject. You can fork my repo and make a little changes. It requires SIP disabled.
  2. A Daemon watches file created event,delete the file when matched. This one do not requires SIP disabled.
xiaozhuai

comment created time in 14 days

issue commentJK3Y/asepsis

What about make a new one that just like asepsis?

In fact, I prefer it.

xiaozhuai

comment created time in 14 days

issue commentJK3Y/asepsis

What about make a new one that just like asepsis?

I’m with dave: All my files are cross-platform so I don’t make use of any “MacOS specific” metadata, and as far as I’m concerned all finder windows can be in detail view sorted by name. If I want another view it’s for a specific use.

.DS_Store and all the other “dotfiles” can simply not exist and I’m perfectly happy.

xiaozhuai

comment created time in 14 days

issue commentJK3Y/asepsis

What about make a new one that just like asepsis?

Interesting conversation! I found this issue because I just upgraded to Catalina and (of course) Asepsis stopped working. And of course I'd installed this fork (thanks JK3Y!) last time it broke, which was when I upgraded to Mojave :-) but I'd totally forgotten I'd had to do that last time, till I found this cloned REPO in my dev dir lol

And Big Sur is coming soon! So, for the record, I'll be happy switching to @xiaozhuai's odourless fork right now, even without the directory-watching-renaming daemon. I really could not care less if my folder metadata is lost when I rename, move or delete them! In fact, I'd be happy to use an even simpler fork that just /dev/null'ed all the damn .DS files, not saving them anywhere! No need for the complexities of a daemon OR extended attributes then! Uber-simplification and at what cost? What "feature" is lost? Where I left the icons on my desktop?? That's is the only one folder I even remotely ever care about where I left the icons: my desktop, and I hardly ever look at that one!

I keep my finder in Details view. I DO like that folders "remember" whether I left them sorted by date, or by name, or size -- but I could live without that too! The .DS file pollution is way more aggravating than losing that would be. Rather than a daemon, I'd be thrilled to run a cleanup/pruning script from time to time that compares the caged directories to "reality" and deletes ay that are no longer found, just so the cage doesn't grow in size endlessly -- In fact, I'll contribute that script :-)

Long-term, I would pay good $$ for a solution that:

  • had a simple installer (even if I had to run it after every upgrade),
  • was reasonably well-maintained (i don't upgrade the MOMENT a new macOS release comes out, but not too long after)
  • and that didn't even TRY to preserve the "features" these folder metadata turds were designed to implement!

Please -- somebody start a GoFundMe and save me!

Oh and it would be nice if the old Asepsis page had a link near the top that pointed (here, for Mojave users, and) to whatever the current workaround is that all of us old Asepsis addicts need to keep us going, since we are so old now that we tend to forget... :-)

thanks!

-dave

xiaozhuai

comment created time in 14 days

issue commentMoya/Moya

Refreshing auth token confusion

I replied in #744, but I continue to experience difficulties trying to sort this out, so I've made a new thread.

I need to be able to pass a bearer token (for some of my calls) and refresh it when necessary. Currently, I have the following class to handle all of my API calls:

import Foundation
import Moya

enum ApiService {
    case signIn(email: String, password: String)
    case like(id: Int, type: String)
}

extension ApiService: TargetType, AccessTokenAuthorizable {
    var authorizationType: AuthorizationType {
        switch self {
        case .signIn(_, _):
            return .basic
        case .like(_, _):
            return .bearer
        }
    }

    var baseURL: URL {
        return URL(string: Constants.apiUrl)!
    }

    var path: String {
        switch self {
            case .signIn(_, _):
                return "user/signin"
            case .like(_, _):
                return "message/like"
        }
    }

    var method: Moya.Method {
        switch self {
            case .signIn, .like:
                return .post
        }
    }

    var task: Task {
        switch self {
            case let .signIn(email, password):
                return .requestParameters(parameters: ["email": email, "password": password], encoding: JSONEncoding.default)
            case let .like(id, type):
                return .requestParameters(parameters: ["messageId": id, "type": type], encoding: JSONEncoding.default)
        }
    }

    var sampleData: Data {
        return Data()
    }

    var headers: [String: String]? {
        return ["Content-type": "application/json"]
    }
}

private extension String {
    var urlEscaped: String {
        return addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
    }

    var utf8Encoded: Data {
        return data(using: .utf8)!
    }
}

As @pietrocaselani suggested, here, I have tried to make sense of how to implement this in accordance with my above code, but I've been stuck now for many days.

Here is what that class looks like right now:

import Foundation
import Moya

public final class ApiProvider {
    private var token: String = ""
    
    private func isTokenValid() -> Bool {
        // check expiration date
        return false
    }
    
    func createProvider() -> MoyaProvider<ApiService> {
        let requestClosure = createRequestClosure()
        
        return MoyaProvider<ApiService>(requestClosure: requestClosure)
    }
    
    func createRequestClosure() -> MoyaProvider<ApiService>.RequestClosure {
        let requestClosure = { [unowned self] (endpoint: Endpoint, done: @escaping MoyaProvider.RequestResultClosure) in
            guard let request = try? endpoint.urlRequest() else {
                done(.failure(MoyaError.requestMapping(endpoint.url)))
                return
            }
            
            if (self.isTokenValid()) {
                done(.success(request))
                return
            }

            // How do I make this request from this class?
            provider.request(.refreshAuthToken()) { result in
                switch result {
                case .success(let response):
                    print("Success")
                    done(.success(request))
                case .failure(let error):
                    print("Error")
                    done(.failure(error))
                }
            }
        }
    
        return requestClosure
    }
}

However, I'm unsure of a few things:

  1. How do I make the request to refresh the auth token in the class? provider.request is obviously wrong, and self.request does not work either.
  2. How would I use this class in other classes (for example, controllers) to make my calls? What if I wanted to make a call that doesn't require a bearer token?

@user6724161 Please let me know if you solved this and how. Thanks.

user6724161

comment created time in 16 days

MemberEvent
PublicEvent
PublicEvent
PublicEvent

issue closedMoya/Moya

How to handle same url with different http method?

My api is like: GET: /user POST: /user DELETE: /user

but moya target enum can not use same name, how can I handle this api style without custom diffrent enum name?

closed time in 22 days

syq7970

issue commentMoya/Moya

How to handle same url with different http method?

Thx for help!

syq7970

comment created time in 22 days

issue commentMoya/Moya

When I add "pod 'Moya/RxSwift', '~> 14.0'", there is a bug in Xcode. and I dont know how can I do

@sunshinejr Thank you. I will try downgrade.

zxiang2013

comment created time in a month

issue commentMoya/Moya

When I add "pod 'Moya/RxSwift', '~> 14.0'", there is a bug in Xcode. and I dont know how can I do

@yourshinsuke yeah that's likely an issue - we didn't prepare Moya 15 for RxSwift 6 yet - please try downgrading to 5.* for the time being.

zxiang2013

comment created time in a month

issue commentMoya/Moya

When I add "pod 'Moya/RxSwift', '~> 14.0'", there is a bug in Xcode. and I dont know how can I do

@sunshinejr Thank you for quick response. I use github "ReactiveX/RxSwift" "6.0.0-rc.1"

zxiang2013

comment created time in a month

more