Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ matrix:
include:
- name: "iOS Build & Test"
language: objective-c
sudo: false
os: osx
osx_image: xcode12.5

Expand All @@ -28,21 +29,23 @@ matrix:

- name: "Android Build & Test"
language: android

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -rf $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
sudo: required

android:
components:
- tools
- platform-tools
- build-tools-30.0.1
- android-28
- extra-android-support
- extra-android-m2repository
- extra-google-m2repository

before_install:
- export LANG=en_US.UTF-8 &&
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&
sudo apt-get install -y nodejs
- yes | sdkmanager "tools" "build-tools;30.0.3" "platforms;android-30" "extras;android;m2repository" "extras;google;m2repository"
- yes | sdkmanager --update

install:
- npm install
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Cordova Advanced HTTP
[![downloads/month](https://img.shields.io/npm/dm/cordova-plugin-advanced-http.svg)](https://www.npmjs.com/package/cordova-plugin-advanced-http)

[![Travis Build Status](https://img.shields.io/travis/com/silkimen/cordova-plugin-advanced-http/master?label=Travis%20CI)](https://app.travis-ci.com/silkimen/cordova-plugin-advanced-http)
[![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/silkimen/cordova-plugin-advanced-http/.github/workflows/ci.yml?branch=master)](https://github.com/silkimen/cordova-plugin-advanced-http/actions)
[![GitHub Build Status](https://img.shields.io/github/workflow/status/silkimen/cordova-plugin-advanced-http/Cordova%20HTTP%20Plugin%20CI/master?label=GitHub%20Actions)](https://github.com/silkimen/cordova-plugin-advanced-http/actions)


Cordova / Phonegap plugin for communicating with HTTP servers. Supports iOS, Android and [Browser](#browserSupport).
Expand Down Expand Up @@ -163,7 +163,7 @@ cordova.plugin.http.getCookieString(url);
```

### setCookie
Add a custom cookie. Takes a URL, a cookie string and an options object. See [ToughCookie documentation](https://github.com/salesforce/tough-cookie#setcookiecookieorstring-currenturl-options-cberrcookie) for allowed options. Cookie will persist until removed with [removeCookies](#removecookies) or [clearCookies](#clearcookies).
Add a custom cookie. Takes a URL, a cookie string and an options object. See [ToughCookie documentation](https://github.com/salesforce/tough-cookie#setcookiecookieorstring-currenturl-options-cberrcookie) for allowed options.

```js
cordova.plugin.http.setCookie(url, cookie, options);
Expand Down
415 changes: 415 additions & 0 deletions dist/index.d.ts

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { IonicNativePlugin, cordova, cordovaPropertyGet, cordovaPropertySet } from '@ionic-native/core';
var HTTPOriginal = /** @class */ (function (_super) {
__extends(HTTPOriginal, _super);
function HTTPOriginal() {
return _super !== null && _super.apply(this, arguments) || this;
}
HTTPOriginal.prototype.getBasicAuthHeader = function (username, password) { return cordova(this, "getBasicAuthHeader", { "sync": true }, arguments); };
HTTPOriginal.prototype.useBasicAuth = function (username, password) { return cordova(this, "useBasicAuth", { "sync": true }, arguments); };
HTTPOriginal.prototype.getHeaders = function (host) { return cordova(this, "getHeaders", { "sync": true }, arguments); };
HTTPOriginal.prototype.setHeader = function (host, header, value) { return cordova(this, "setHeader", { "sync": true }, arguments); };
HTTPOriginal.prototype.getDataSerializer = function () { return cordova(this, "getDataSerializer", { "sync": true }, arguments); };
HTTPOriginal.prototype.setDataSerializer = function (serializer) { return cordova(this, "setDataSerializer", { "sync": true }, arguments); };
HTTPOriginal.prototype.setCookie = function (url, cookie) { return cordova(this, "setCookie", { "sync": true }, arguments); };
HTTPOriginal.prototype.clearCookies = function () { return cordova(this, "clearCookies", { "sync": true }, arguments); };
HTTPOriginal.prototype.removeCookies = function (url, cb) { return cordova(this, "removeCookies", { "sync": true }, arguments); };
HTTPOriginal.prototype.getCookieString = function (url) { return cordova(this, "getCookieString", { "sync": true }, arguments); };
HTTPOriginal.prototype.getRequestTimeout = function () { return cordova(this, "getRequestTimeout", { "sync": true }, arguments); };
HTTPOriginal.prototype.setRequestTimeout = function (timeout) { return cordova(this, "setRequestTimeout", { "sync": true }, arguments); };
HTTPOriginal.prototype.getFollowRedirect = function () { return cordova(this, "getFollowRedirect", { "sync": true }, arguments); };
HTTPOriginal.prototype.setFollowRedirect = function (follow) { return cordova(this, "setFollowRedirect", { "sync": true }, arguments); };
HTTPOriginal.prototype.setServerTrustMode = function (mode) { return cordova(this, "setServerTrustMode", {}, arguments); };
HTTPOriginal.prototype.post = function (url, body, headers) { return cordova(this, "post", {}, arguments); };
HTTPOriginal.prototype.postSync = function (url, body, headers, success, failure) { return cordova(this, "post", { "methodName": "post", "sync": true }, arguments); };
HTTPOriginal.prototype.get = function (url, parameters, headers) { return cordova(this, "get", {}, arguments); };
HTTPOriginal.prototype.getSync = function (url, parameters, headers, success, failure) { return cordova(this, "get", { "methodName": "get", "sync": true }, arguments); };
HTTPOriginal.prototype.put = function (url, body, headers) { return cordova(this, "put", {}, arguments); };
HTTPOriginal.prototype.putSync = function (url, body, headers, success, failure) { return cordova(this, "put", { "methodName": "put", "sync": true }, arguments); };
HTTPOriginal.prototype.patch = function (url, body, headers) { return cordova(this, "patch", {}, arguments); };
HTTPOriginal.prototype.patchSync = function (url, body, headers, success, failure) { return cordova(this, "patch", { "methodName": "patch", "sync": true }, arguments); };
HTTPOriginal.prototype.delete = function (url, parameters, headers) { return cordova(this, "delete", {}, arguments); };
HTTPOriginal.prototype.deleteSync = function (url, parameters, headers, success, failure) { return cordova(this, "delete", { "methodName": "delete", "sync": true }, arguments); };
HTTPOriginal.prototype.head = function (url, parameters, headers) { return cordova(this, "head", {}, arguments); };
HTTPOriginal.prototype.headSync = function (url, parameters, headers, success, failure) { return cordova(this, "head", { "methodName": "head", "sync": true }, arguments); };
HTTPOriginal.prototype.options = function (url, parameters, headers) { return cordova(this, "options", {}, arguments); };
HTTPOriginal.prototype.optionsSync = function (url, parameters, headers, success, failure) { return cordova(this, "options", { "methodName": "options", "sync": true }, arguments); };
HTTPOriginal.prototype.uploadFile = function (url, body, headers, filePath, name) { return cordova(this, "uploadFile", {}, arguments); };
HTTPOriginal.prototype.uploadFileSync = function (url, body, headers, filePath, name, success, failure) { return cordova(this, "uploadFile", { "methodName": "uploadFile", "sync": true }, arguments); };
HTTPOriginal.prototype.downloadFile = function (url, body, headers, filePath) { return cordova(this, "downloadFile", {}, arguments); };
HTTPOriginal.prototype.downloadFileSync = function (url, body, headers, filePath, success, failure) { return cordova(this, "downloadFile", { "methodName": "downloadFile", "sync": true }, arguments); };
HTTPOriginal.prototype.sendRequest = function (url, options) { return cordova(this, "sendRequest", {}, arguments); };
HTTPOriginal.prototype.sendRequestSync = function (url, options, success, failure) { return cordova(this, "sendRequest", { "methodName": "sendRequest", "sync": true }, arguments); };
HTTPOriginal.prototype.abort = function (requestId) { return cordova(this, "abort", {}, arguments); };
Object.defineProperty(HTTPOriginal.prototype, "ErrorCode", {
get: function () { return cordovaPropertyGet(this, "ErrorCode"); },
set: function (value) { cordovaPropertySet(this, "ErrorCode", value); },
enumerable: false,
configurable: true
});
HTTPOriginal.pluginName = "HTTP";
HTTPOriginal.plugin = "cordova-plugin-advanced-http";
HTTPOriginal.pluginRef = "cordova.plugin.http";
HTTPOriginal.repo = "https://github.com/silkimen/cordova-plugin-advanced-http";
HTTPOriginal.platforms = ["Android", "iOS"];
return HTTPOriginal;
}(IonicNativePlugin));
var HTTP = new HTTPOriginal();
export { HTTP };
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "cordova-plugin-advanced-http",
"version": "3.3.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"description": "Cordova / Phonegap plugin for communicating with HTTP servers using SSL pinning",
"scripts": {
"update:cert": "node ./scripts/update-e2e-server-cert.js && node ./scripts/update-e2e-client-cert.js",
Expand Down Expand Up @@ -64,6 +66,6 @@
"mocha": "9.2.2",
"umd-tough-cookie": "3.0.0",
"wd": "1.14.0",
"xml2js": "0.5.0"
"xml2js": "0.4.23"
}
}
10 changes: 1 addition & 9 deletions src/android/com/silkimen/cordovahttp/CordovaServerTrust.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void run() {
this.tlsConfiguration.setTrustManagers(this.noOpTrustManagers);
} else if ("pinned".equals(this.mode)) {
this.tlsConfiguration.setHostnameVerifier(null);
this.tlsConfiguration.setTrustManagers(this.getTrustManagers(this.getCertsFromBundle(getWebAssetDir() + "/certificates")));
this.tlsConfiguration.setTrustManagers(this.getTrustManagers(this.getCertsFromBundle("public")));
} else {
this.tlsConfiguration.setHostnameVerifier(null);
this.tlsConfiguration.setTrustManagers(this.getTrustManagers(this.getCertsFromKeyStore("AndroidCAStore")));
Expand All @@ -84,14 +84,6 @@ public void run() {
}
}

private String getWebAssetDir() {
return isRunningOnCapacitor()? "public" : "www";
}

private boolean isRunningOnCapacitor() {
return this.activity.getClass().getSuperclass().getName().contains("com.getcapacitor");
}

private TrustManager[] getTrustManagers(KeyStore store) throws GeneralSecurityException {
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
Expand Down
Loading