GithubHelp home page GithubHelp logo

wordpress-mobile / wordpresskit-ios Goto Github PK

View Code? Open in Web Editor NEW
42.0 10.0 16.0 6 MB

WordPressKit offers a clean and simple WordPress.com and WordPress.org network API.

Home Page: http://www.wordpress.com

License: GNU General Public License v2.0

Ruby 0.23% Objective-C 24.45% Swift 75.18% C 0.01% HTML 0.07% Shell 0.07%

wordpresskit-ios's Introduction

WordPressKit for iOS

About

WordPressKit offers a clean and simple WordPress.com and WordPress.org API.

Requirements

  • iOS 9 and above
  • Xcode 9.3 and above

Integrating the Library with CocoaPods

WordPressKit-iOS is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "WordPressKit"

License

WordPressKit-iOS is available under the GPLv2 license. See the LICENSE file for more info.

wordpresskit-ios's People

Contributors

aerych avatar astralbodies avatar bummytime avatar crazytonyli avatar ctarda avatar danielebogo avatar diegoreymendez avatar dvdchr avatar elibud avatar etoledom avatar frosty avatar guarani avatar jklausa avatar jkmassel avatar jleandroperez avatar jtreanor avatar kean avatar koke avatar leandroalonso avatar loremattei avatar mindgraffiti avatar mkevins avatar mokagio avatar momo-ozawa avatar sabaranski avatar salimbraksa avatar scoutharris avatar sergioestevao avatar staskus avatar wargcm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

wordpresskit-ios's Issues

Implement AtomicAuthenticationServiceRemote.

Implement class AtomicAuthenticationServiceRemote with a method to perform a GET request to:

https://public-api.wordpress.com/wpcom/v2/sites/atomicdiegotravel.wordpress.com/atomic-auth-proxy/read-access-cookies

No parameters are required although the bearer token must be sent.

The return valuewill be JSON data looking like this:

{"url":"https://atomicdiegotravel.wpcomstaging.com",
"cookies" [{
    "expires":1582858181,
    "path":"/",
    "domain":"atomicdiegotravel.wpcomstaging.com",
    "name":"wordpress_logged_in_<some_value>",
    "value":"<data_removed>"
}]}

Parse this return data into a new object type named RemoteCookie and return it on success.

Blaze: Manage Campaigns - Implement the endpoint and logic to fetch Campaigns for dashboard card

Description

Implement the endpoint to fetch the recent campaign for dashboard card

Links

Design ref - 1Osrn9gb2xLaKG6lIft3WC-fi-1461_9777

Tasks

Modify existing services to leverage locale handling

Expected behavior

The changes in #78 support more consistent locale handling within WordPressKit, but a few services still explicitly set the locale parameter.

Actual behavior

At the time of this writing, the following services set locale explicitly:

We should be able to remove this and rely on the implicit framework behavior.

Steps to reproduce the behavior

N/A

WordPressKit Environment

All devices & versions of WordPressKit, Xcode & iOS.

  • WordPressKit Version [e.g. 22] : all versions
  • OS: [e.g. iOS 12.1.3 (16D40)] : all versions
  • Device: [e.g. iPhone XS] : all devices
  • Xcode Version: [e.g. Xcode 10.1 (10B61)] : all versions
Additional Context

N/A

Modify locale handling to inspect request parameters

Description

The default behavior of WordPressComRestApi appends a locale parameter to requests. To do so, it inspects & modifies the path of a given request if needed.

If a caller were to specify locale in the request parameters, however, the specified value is not properly de-duplicated. For example, composing a GET request with the default behavior enabled, passing locale : foo in the request parameters evinces a request with the following URL : https://public-api.wordpress.com/wpcom/v2/<path>?locale=en&locale=foo.

Potential Solution

The client should inspect the parameters associated with the request, and de-duplicate those if necessary. It might be worth using URLComponents for this purpose.

Update domains/suggestions endpoint to use new segment_id parameter

We have a new domains suggestion parameter which replaces all other parameters. Now, we simply pass segment_id=INT and if it matches a blog type, we'll get .blog subdomains back (coffee.shop.blog) along with the normal wordpress.com subdomains (coffee.wordpress.com)

If it doesn't match a blog type, we'll simply get wordpress.com subdomains back.

Standardize logging of HTTP interactions in the framework

Expected behavior

It should be possible to easily log the nature of HTTP invocations, including performance metrics, request & response content, and the like. This should be limited in Production contexts to both respect user privacy and conserve log resources.

URLSessionTaskDelegate might provide a centralized location to intercept requests & responses, as well as performance metrics via URLSessionTaskMetrics.

Actual behavior

At the moment, it is possible to inspect this information via manual debugging, but the logging in-place is not uniform. Performance metrics require manual instrumentation, as observed in this PR.

Steps to reproduce the behavior

N/A

WordPressKit Environment
  • WordPressKit Version : WordPressKit v4.0.0 & before
  • OS : iOS 10.x - 12.x
  • Device : all devices
  • Xcode Version : Xcode 10.2
Additional Context

N/A

Conform to Community Standards

To promote consistency across WordPress-iOS frameworks & to conform to recommended community standards, we should update this repository to include all of the following:

  • Description
  • README
  • Code of conduct
  • Contributing
  • License
  • Issue templates
  • Pull request template

We should also modify the PR checks we have in place for consistency with WordPress-iOS (e.g., build checks, approval / merge requirements, etc.).

Bug: Logging of Social Login exposes OAuth Bearer token to log files

Expected behavior

Log entries shouldn't include sensitive data like bearer tokens.

Actual behavior

When logging in with social login the entire response object is dumped to the log and exposes the bearer token to the app's log file.

DDLogVerbose("Received Social Login Oauth response: \(self.cleanedUpResponseForLogging(responseObject as AnyObject? ?? "nil" as AnyObject))")

2019/04/27 12:57:11:934  Received Social Login Oauth response: {
    data =     {
        "bearer_token" = "manually redacted by me for demo purposes";
        "token_links" =         (
            "https://jetpack.com/remote-login.php?wpcom_remote_login=validate&wpcomid=xx&token=xx&host=https%3A%2F%2Fjetpack.com"
        );
    };
    success = 1;
}

Steps to reproduce the behavior

  1. Use Social Login and look at the log file.

Remove @objc annotation for method incompatible with Objective-C

Expected behavior

WordPressKit should compile successfully and work correctly.

Actual behavior

WordPressKit does not compile successfully with Xcode 10.2. When attempting to build it, the following error is reported:

~WordPressKit-iOS/WordPressKit/PlanServiceRemote_ApiVersion1_3.swift:9:23: Method cannot be marked @objc because the type of the parameter 2 cannot be represented in Objective-C

In this case, the tuple is problematic. Because it is not currently possible to consume this method from Objective-C, removing the annotation is arguable not a breaking change.

Steps to reproduce the behavior

  1. Open the WordPressKit workspace & attempt to build with Xcode Version 10.2 (10E125).
  2. Observe the error noted above
WordPressKit Environment
  • WordPressKit Version : WordPressKit v3.2.0 & before
  • OS : iOS 12.x
  • Device : all devices
  • Xcode Version : Xcode 10.2
Additional Context

N/A

Error parsing plans response - raw price can be decimal.

Expected behavior

No error in the logs when loading the Plan screen.

Actual behavior

It seems the parser is expecting int values for the prices but they should instead be doubles.

2020-03-04 15:56:59:708 Error parsing plans response for site dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "rawPrice", intValue: nil)], debugDescription: "Parsed JSON number <9.5> does not fit in Int.", underlyingError: nil))

Adding WordPressKit-iOS to the project failed! Failed to resolve dependencies beacuse root depends on 'wordpresskit-ios' 17.2.0..<18.0.0

Expected behavior

ℹ I want to add and use this Package

Actual behavior

ℹ Add fails and reports an error, if you force it then xcode will not compile and you will not be able to remove any Packages, once removed Xcode will exit with an error

图片

Steps to reproduce the behavior

  1. Update your system to macOS 15.0.
  2. Download Xcode 16.0-beta.
  3. Create a new project and add WordPressKit-iOS [Note that the following Package has been added before trying to add this Package].

图片

WordPressKit Environment
  • WordPressKit 17.2.0
  • Operating System: macOS 15.0
  • Device: M1 Pro
  • Xcode version: Version 16.0 beta (16A5171c) Device: M1 Pro
Additional Context

ℹ Xcode 16.0Beta Download Links: https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_16_beta/Xcode_16_beta.xip

Parameters are not included in multipart POST requests

Expected behavior

Parameters argument of multipartPOST function should be included in the POST request.

Actual behavior

Parameters are not included.

Steps to reproduce the behavior

multipartPOST function is only used in the following places:

The easiest way to reproduce the bug is by adding items from the free photo library as they include as the caption value its photo credit in the upload parameters.

  1. Go to the media screen.
  2. Tap on + button.
  3. Tap on Free Photo Library.
  4. Search any term.
  5. Tap one or multiple items.
  6. Tap on Add button.
  7. Wait for the items to be uploaded.
  8. Tap on one of the uploaded items.
  9. Check that the caption value is empty.
WordPressKit Environment
  • WordPressKit Version 4.25-beta
  • OS: iOS 14.0
  • Device: iPhone 8 (simulator)
  • Xcode Version: Xcode 12.0
Additional Context

No.

v2 endpoints require modified locale key

Expected behavior

As per p77Llu-byF-p2, v2 endpoints must pass _locale rather than locale. Prior versions should still use locale.

From the perspective of semantic versioning, implementing this may be a breaking change.

Actual behavior

In the default case where appendsPreferredLanguageLocale is true, a localization identifier is added to requests with a key of locale. This needs to change based on the endpoint version.

Steps to reproduce the behavior

Inspect a request constructed via WordPressKit and scrutinize the query string. Note the value locale is used for all endpoint versions.

WordPressKit Environment

All devices & versions of WordPressKit, Xcode & iOS.

  • WordPressKit Version [e.g. 22] : all versions
  • OS: [e.g. iOS 12.1.3 (16D40)] : all versions
  • Device: [e.g. iPhone XS] : all devices
  • Xcode Version: [e.g. Xcode 10.1 (10B61)] : all versions
Additional Context

N/A

Update `wpxmlrpc` pod to `0.8.5-beta.1`

Enhancement

The podfile should point to the latest version of the wpxmlrpc pod. Once updated, run pod install to update the podfile.lock. The podspec should become 4.6.0-beta.1

Improve the separation of URL construction & execution concerns

Expected behavior

Request construction & execution should be separate concerns.

Actual behavior

As discussed in #78, responsibilities for request construction are shared between both ServiceRemoteWordPressComREST & WordPressComRestApi. WordPressComRestApi currently executes requests.

We might benefit from the approach taken by our Woo counterparts.

Steps to reproduce the behavior

N/A

WordPressKit Environment

All devices & versions of WordPressKit, Xcode & iOS.

  • WordPressKit Version [e.g. 22] : all versions
  • OS: [e.g. iOS 12.1.3 (16D40)] : all versions
  • Device: [e.g. iPhone XS] : all devices
  • Xcode Version: [e.g. Xcode 10.1 (10B61)] : all versions
Additional Context

N/A

Map the `is_wpcom_atomic` blog option.

We need to change the logic here:

NSArray *optionsDirectMapKeys = @[
@"active_modules",
@"admin_url",
@"login_url",
@"image_default_link_type",
@"software_version",
@"videopress_enabled",
@"timezone",
@"gmt_offset",
@"allowed_file_types",
@"frame_nonce",
@"jetpack_version",
@"is_automated_transfer",
@"blog_public",
@"max_upload_size"
];

So that we also map key is_wpcom_atomic directly making it accessible for Apps using this library.

[Question] Demo, Sample

Hello
Is there a demo or sample on how to setup/use this pod?
I am using this path: wp-json/wp/v2 to get the responses, is it supported ?
Thanks,

Tidy up project file structure

In p77Llu-bIn-p2, @aerych observed:

WordPressKit has a flat file structure that doesn’t match the grouping in the project.

We should remedy that.

@frosty offered that tools like synx exist that might facilitate that transition.

Fix Lint Warnings

This is the result of running pod spec lint WordPressKit.podspec:

-> WordPressKit (1.5.0)
- WARN | url: There was a problem validating the URL http://apps.wordpress.com.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')
- WARN | xcodebuild: wpxmlrpc/WPXMLRPC/WPXMLRPCEncoder.h:50:9: warning: parameter 'parameters' not found in the function declaration [-Wdocumentation]
- NOTE | xcodebuild: wpxmlrpc/WPXMLRPC/WPXMLRPCEncoder.h:50:9: note: did you mean 'params'?
- WARN | xcodebuild: wpxmlrpc/WPXMLRPC/WPXMLRPCEncoder.h:92:3: warning: '@param' command used in a comment that is not attached to a function declaration [-Wdocumentation]

We should clean this up to build cleanly.

Tokens should not print to console

Access tokens, bearer tokens, and token links should not print out in the console log, nor the Activity Logs.

Steps to reproduce

  1. Be logged out of a host app that uses SIWA
  2. Log in using SIWA
  3. Go to Me > Help & Support > Activity Logs > Current. Look for the JSON response printed out, with the fields bearer_token, token_links.

Expected: The values should be redacted
Actual: They are not redacted

WordPressKit Environment
  • WordPressKit version 4.8.0 and below
  • OS: iOS 12.0+
  • Device: iPhone Pro Max (but should be reproducible on all)
  • Xcode Version: 11.4.1

Modify WordPressKit for Swift 5 support

Expected behavior

We should adapt the framework to support Swift 5.

Actual behavior

At the moment the framework uses Swift 4.2.

Steps to reproduce the behavior

For all targets in the project, SWIFT_VERSION is currently set to 4.2.

WordPressKit Environment
  • WordPressKit Version : WordPressKit v1.8.0 & before
  • OS : iOS 12.x
  • Device : all devices
  • Xcode Version : Xcode 10.2 beta
Additional Context

Swift 5 Release Notes for Xcode 10.2 beta

Stats Streak fetching can run into default limit on high-traffic sites

By default, the endpoint returning data for StatsPostingStreakInsight returns a limited amount of data (around ~1k datapoints), which on high-traffic sites can be not enough data to show a years worth of posting activity.

We should bump that limit up and ask for a specific time-frame of data.

Update terms in code to use more inclusive language

A quick ack of the repo shows whitelist and blacklist referenced in several places. Let's update these references in our code and repo documentation (e.g. README) to use more inclusive terms. Suggestions: allowlist or blockedlist. For references in third-party libs, we can see if there is an updated version of that lib and whether there is any blockers to switching to that version.

Refs wordpress-mobile/WordPress-iOS#15522

See wp.me/paaHJt-15h-p2 for more.

Start only one login sequence at a time when retrying requests that responded with `401` status code

Expected behavior

When retrying a request due to the response error 401 - Unauthorized (reference), we should ensure that only one login sequence is triggered at a time.

Actual behavior

Currently, we check the value of isAuthenticating for this purpose. However, it's never set to true, and therefore the login sequence can be triggered several times. This might lead to generating a lot of login requests, and in some cases API request blocks due to a high volume of login attempts, if such restrictions are set up in the hosting.

Steps to reproduce the behavior

Preparation:
Reproducing this issue requires modifying somehow the requests to fail with status code 401. This can be achieved by using a proxy, like the Charles proxy app, and rewriting the responses to return the desired status code.

  1. Listen for requests made using CookieNonceAuthenticator and select one endpoint for modifying its response.
    NOTE: Currently, this authenticator is used in WordPress-iOS for requests made to .ORG sites via API rest.
  2. Force the status code response for the selected endpoint to be 401 (this can be achieved with a proxy and bypassing requests).
  3. Trigger multiple requests to the selected endpoint and observe that each one triggers a login sequence (i.e. requests to the login URL).
WordPressKit Environment
  • WordPressKit Version [e.g. 22]: 4.49.0
  • OS: [e.g. iOS 12.1.3 (16D40)] iOS 15.4
  • Device: [e.g. iPhone XS] iPhone 13
  • Xcode Version: [e.g. Xcode 10.1 (10B61)] N/A
Additional Context

More information about this issue can be found in p1650593568370329-slack-C011BKNU1V5.

Replace manually configured RFC3339 DateFormatter instances with ISO8601DateFormatter

Expected behavior

It should be possible to replace manually configured RFC3339 DateFormatter instances with ISO8601DateFormatter.

Actual behavior

Examples include both NSDate+WordPressJSON.m & WPStatsServiceRemote.m

Steps to reproduce the behavior

N/A

WordPressKit Environment
  • WordPressKit Version : WordPressKit v2.1.1 & before
  • OS : iOS 12.x
  • Device : all devices
  • Xcode Version : Xcode 10.2 beta
Additional Context

N/A

Passing nil request parameters defeats appendsPreferredLanguageLocale

Expected behavior

By default, WordPressComRestApi automatically appends locale to requests when appendsPreferredLanguageLocale is enabled (i.e., the default state). For requests where nil parameters are passed to WordPressComRestApi.buildRequestURLFor(path:parameters:), locale is does not honor that request.

Requests that specify locale are not impacted.

Actual behavior

Passing nil to WordPressComRestApi.buildRequestURLFor(path:parameters:) should result in a URL that includes locale when appendsPreferredLanguageLocale is enabled.

Steps to reproduce the behavior

WordPressKit Environment
  • WordPressKit Version : WordPressKit v2.0.0 & later
  • OS : iOS 12.x
  • Device : all devices
  • Xcode Version : Xcode 10.2 beta
Additional Context

See related discussion in p1551132833014600-slack-build-and-ship.

Incorrect logic for querying if blog's plan is free

Expected behavior

RemoteBlog.hasPaidPlan should return true on WP.com sites that have a paid plan, false otherwise.

Actual behavior

The logic of RemoteBlog.hasPaidPlan is reversed. It returns true on WP.com sites that have a free plan, otherwise true.

Steps to reproduce the behavior

I noticed this when calling hasPaidPlans in wordpress-mobile/WordPress-iOS#20163. It unexpectedly returned false on a site that has a paid plan.

WordPressKit Environment
  • WordPressKit Version 6.1.0-beta
  • OS: iOS 16.2
  • Device: iPhone 14 Pro Max
  • Xcode Version: Xcode 14.2
Additional Context

In #558, it appears that the refactor inadvertently flipped the logic on the hasPaidPlan bool.

Migrate from Alamofire 4.x to 5.x

In order to fully support Swift 5 and to remove the warning in Xcode, Alamofire will need migrated from 4.x to 5.x. There are significant breaking changes involved, which is why this was not addressed during the current hack week.

WordPressKit Environment
  • WordPressKit Version 4.6.0-beta.6
  • OS: 13.x
  • Device: any
  • Xcode Version: 11.3.1

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.