Giter Site home page Giter Site logo

ios-sdk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-sdk's Issues

Deploy SDK to CocoaPod and Deploying Resource Bundle

  1. Make current repository public
  2. Create a new release and publish release
  3. Lint the project (pod lib lint)
  4. Make a Trunk account

Now Trunk isn’t exactly an account; it’s a session. So basically there is no need for a password, just an email.
The process is incredibly simple:
pod trunk register <Your Email>
You should quickly get an email from CocoaPods to verify your ‘session’. Verify your account by clicking the link provided in the email. CocoaPods will greet you with friendly message: ACE, YOU ARE SET UP!

  1. Push pod (pod trunk push SmartcarOAuthSDK.podspec)

Invalid default state parameter

Hello,

I have noticed the newly added state parameter for requests is not working properly:

  • currently it is set at "", cf SmartcarAuth.swift:45
  • it somehow gets dropped while in SFSafariViewController
  • when resumeAuthorizationFlow(with url: URL) is called the given url doesn't contain the state parameter anymore which causes a crash at let state = query?[1].value

I also tried setting it to " " but it prevents a valid URL from being created because it is not escaped properly, which causes a crash in:

let safariVC = SFSafariViewController(url: URL(string: authorizationURL)!)

Setting it to "%20" fixes the crash above, but the test in resumeAuthorizationFlow(with url: URL) doesn't handle escaping right and we end end comparing " " and "%20".

I set it to a random UUID string which seems to have fixes the problem.

I would highly recommend using a valid default value, or manage the case where the value is empty. To prevent crashes I would also suggest refactoring resumeAuthorizationFlow(with url: URL) as follows :

public func resumeAuthorizationFlow(with url: URL) throws -> String {
    let urlComp = URLComponents(url: url, resolvingAgainstBaseURL: false)
    guard let query = urlComp?.queryItems else {
        // declare a new error maybe?
        throw AuthorizationError.missingURL
    }

    guard let code = query.filter({ $0.name == "code" }).first?.value else {
        throw AuthorizationError.missingURL
    }
        
    guard let state = query.filter({ $0.name == "state" }).first?.value else {
        throw AuthorizationError.missingState
    }
        
    if state != self.request.state {
        throw AuthorizationError.invalidState
    }
    return code
}

Using query parameter names instead of probable indexes guarantees to find the right element if it exists, and this will prevent further crashes when accessing index out of bounds.

Thanks for considering,

Stan

Fix badges on the README

Remove the duplicate cocoapods badges and set travis badge properly:

Build Status

[![Build Status](https://travis-ci.com/smartcar/ios-sdk.svg?token=jMbuVtXPGeJMPdsn7RQ5&branch=master)](https://travis-ci.com/smartcar/ios-sdk)

Incorrect access level of AuthorizationError variables and inner ErrorType enum

It looks like we have an incorrect access level of variables of AuthorizationError class as well as the inner ErrorType enum.

This is the current implementation:

@objc public class AuthorizationError: NSObject, Error {
    enum ErrorType {
        ...
    }

    var type: ErrorType
    var errorDescription: String?
    var vehicleInfo: VehicleInfo?

    init(type: ErrorType, errorDescription: String? = nil, vehicleInfo: VehicleInfo? = nil) {
        ...
    }
}

This implementation doesn't let to know anything about the instance of the AuthorizationError class because all variables have the internal access level.

Update README

  • Document 'sc' prefix instead of 'sk'
  • Document replacing the clientID and redirect URI in the example code with the developer's own, and to update Example/Info.plist with the custom scheme

Documentation missing for AuthorizationError

When a user denies access to an application, the SDK returns an AuthorizationError to the completion handler. There are a few different cases this error is returned as we can see in the callback handling code below:

@objc public func handleCallback(with url: URL) -> Any? {
let urlComp = URLComponents(url: url, resolvingAgainstBaseURL: false)
guard let query = urlComp?.queryItems else {
return completion(AuthorizationError.missingQueryParameters, nil, nil)
}
let queryState = query.filter({ $0.name == "state"}).first?.value
if query.filter({ $0.name == "error"}).first?.value != nil {
return completion(AuthorizationError.accessDenied, nil, queryState)
}
guard let code = query.filter({ $0.name == "code"}).first?.value else {
return completion(AuthorizationError.missingAuthCode, nil, queryState)
}
return completion(nil, code, queryState)
}

There is no documentation around this error. In addition, the detailed error_description returned by the Smartcar Connect flow is also not surfaced.

Add support for Swift Package Manager

Since XCode now supporting swift package manager natively, I've been migrating all my dependencies from cocoapods to it. One exception is SmartcarAuth, which doesn't yet support it.

The change should be minimal, just adding the manifest file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.