From 69218f8586e4edbc727df16859d5f621fbce476a Mon Sep 17 00:00:00 2001 From: rokanraja1 Date: Mon, 11 Mar 2024 14:28:36 +0530 Subject: [PATCH 1/9] Capacitor adjust done --- .travis.yml | 23 +- README.md | 4 +- dist/index.d.ts | 415 ++++++++++++++++++ dist/index.js | 70 +++ package.json | 4 +- .../silkimen/cordovahttp/CordovaHttpBase.java | 1 + .../cordovahttp/CordovaServerTrust.java | 10 +- src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m | 14 +- 8 files changed, 507 insertions(+), 34 deletions(-) create mode 100644 dist/index.d.ts create mode 100644 dist/index.js diff --git a/.travis.yml b/.travis.yml index 2e1f6aa3..5c5c8603 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ matrix: include: - name: "iOS Build & Test" language: objective-c + sudo: false os: osx osx_image: xcode12.5 @@ -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 diff --git a/README.md b/README.md index a70bc800..bcc6515d 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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); diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 00000000..5dd2768e --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,415 @@ + +export interface HTTPResponse { + /** + * The HTTP status number of the response or a negative internal error code. + */ + status: number; + /** + * The headers of the response. + */ + headers: { + [key: string]: string; + }; + /** + * The URL of the response. This property will be the final URL obtained after any redirects. + */ + url: string; + /** + * The data that is in the response. This property usually exists when a promise returned by a request method resolves. + */ + data?: any; + /** + * Error response from the server. This property usually exists when a promise returned by a request method rejects. + */ + error?: string; +} +interface AbortedResponse { + aborted: boolean; +} +/** + * @name HTTP + * @description + * Cordova / Phonegap plugin for communicating with HTTP servers. Supports iOS and Android. + * + * Advantages over Javascript requests: + * - SSL / TLS Pinning + * - CORS restrictions do not apply + * - Handling of HTTP code 401 - read more at [Issue CB-2415](https://issues.apache.org/jira/browse/CB-2415) + * + * @usage + * ```typescript + * import { HTTP } from '@ionic-native/http/ngx'; + * + * constructor(private http: HTTP) {} + * + * ... + * + * this.http.get('http://ionic.io', {}, {}) + * .then(data => { + * + * console.log(data.status); + * console.log(data.data); // data received by server + * console.log(data.headers); + * + * }) + * .catch(error => { + * + * console.log(error.status); + * console.log(error.error); // error message as string + * console.log(error.headers); + * + * }); + * + * ``` + * @interfaces + * HTTPResponse + */ +export declare class HTTPOriginal { + /** + * This enum represents the internal error codes which can be returned in a HTTPResponse object. + * @readonly + */ + readonly ErrorCode: { + GENERIC: number; + SSL_EXCEPTION: number; + SERVER_NOT_FOUND: number; + TIMEOUT: number; + UNSUPPORTED_URL: number; + NOT_CONNECTED: number; + POST_PROCESSING_FAILED: number; + ABORTED: number; + }; + /** + * This returns an object representing a basic HTTP Authorization header of the form. + * @param username {string} Username + * @param password {string} Password + * @returns {Object} an object representing a basic HTTP Authorization header of the form {'Authorization': 'Basic base64EncodedUsernameAndPassword'} + */ + getBasicAuthHeader(username: string, password: string): { + Authorization: string; + }; + /** + * This sets up all future requests to use Basic HTTP authentication with the given username and password. + * @param username {string} Username + * @param password {string} Password + */ + useBasicAuth(username: string, password: string): void; + /** + * Get all headers defined for a given hostname. + * @param host {string} The hostname + * @returns {string} return all headers defined for the hostname + */ + getHeaders(host: string): string; + /** + * Set a header for all future requests. Takes a hostname, a header and a value. + * @param host {string} The hostname to be used for scoping this header + * @param header {string} The name of the header + * @param value {string} The value of the header + */ + setHeader(host: string, header: string, value: string): void; + /** + * Get the name of the data serializer which will be used for all future POST and PUT requests. + * @returns {string} returns the name of the configured data serializer + */ + getDataSerializer(): string; + /** + * Set the data serializer which will be used for all future POST, PUT and PATCH requests. Takes a string representing the name of the serializer. + * @param serializer {string} The name of the serializer. + * @see https://github.com/silkimen/cordova-plugin-advanced-http#setdataserializer + */ + setDataSerializer(serializer: 'urlencoded' | 'json' | 'utf8' | 'multipart' | 'raw'): void; + /** + * Add a custom cookie. + * @param url {string} Scope of the cookie + * @param cookie {string} RFC compliant cookie string + */ + setCookie(url: string, cookie: string): void; + /** + * Clear all cookies. + */ + clearCookies(): void; + /** + * Remove cookies for given URL. + * @param url {string} + * @param cb + */ + removeCookies(url: string, cb: () => void): void; + /** + * Resolve cookie string for given URL. + * @param url {string} + */ + getCookieString(url: string): string; + /** + * Get global request timeout value in seconds. + * @returns {number} returns the global request timeout value + */ + getRequestTimeout(): number; + /** + * Set global request timeout value in seconds. + * @param timeout {number} The timeout in seconds. Default 60 + */ + setRequestTimeout(timeout: number): void; + /** + * Resolve if it should follow redirects automatically. + * @returns {boolean} returns true if it is configured to follow redirects automatically + */ + getFollowRedirect(): boolean; + /** + * Configure if it should follow redirects automatically. + * @param follow {boolean} Set to false to disable following redirects automatically + */ + setFollowRedirect(follow: boolean): void; + /** + * Set server trust mode, being one of the following values: + * default: default SSL trustship and hostname verification handling using system's CA certs; + * legacy: use legacy default behavior (< 2.0.3), excluding user installed CA certs (only for Android); + * nocheck: disable SSL certificate checking and hostname verification, trusting all certs (meant to be used only for testing purposes); + * pinned: trust only provided certificates; + * @see https://github.com/silkimen/cordova-plugin-advanced-http#setservertrustmode + * @param {string} mode server trust mode + */ + setServerTrustMode(mode: 'default' | 'legacy' | 'nocheck' | 'pinned'): Promise; + /** + * Make a POST request + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @returns {Promise} returns a promise that will resolve on success, and reject on failure + */ + post(url: string, body: any, headers: any): Promise; + /** + * Make a sync POST request + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * @returns {string} returns a string that represents the requestId + */ + postSync(url: string, body: any, headers: any, success: (result: HTTPResponse) => void, failure: (error: any) => void): string; + /** + * Make a GET request + * @param url {string} The url to send the request to + * @param parameters {Object} Parameters to send with the request + * @param headers {Object} The headers to set for this request + * @returns {Promise} returns a promise that will resolve on success, and reject on failure + */ + get(url: string, parameters: any, headers: any): Promise; + /** + * Make a sync GET request + * @param url {string} The url to send the request to + * @param parameters {Object} Parameters to send with the request + * @param headers {Object} The headers to set for this request + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * @returns {string} returns a string that represents the requestId + */ + getSync(url: string, parameters: any, headers: any, success: (result: HTTPResponse) => void, failure: (error: any) => void): string; + /** + * Make a PUT request + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @returns {Promise} returns a promise that will resolve on success, and reject on failure + */ + put(url: string, body: any, headers: any): Promise; + /** + * Make a sync PUT request + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * @returns {string} returns a string that represents the requestId + */ + putSync(url: string, body: any, headers: any, success: (result: HTTPResponse) => void, failure: (error: any) => void): string; + /** + * Make a PATCH request + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @returns {Promise} returns a promise that will resolve on success, and reject on failure + */ + patch(url: string, body: any, headers: any): Promise; + /** + * Make a sync PATCH request + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * @returns {string} returns a string that represents the requestId + */ + patchSync(url: string, body: any, headers: any, success: (result: HTTPResponse) => void, failure: (error: any) => void): string; + /** + * Make a DELETE request + * @param url {string} The url to send the request to + * @param parameters {Object} Parameters to send with the request + * @param headers {Object} The headers to set for this request + * @returns {Promise} returns a promise that will resolve on success, and reject on failure + */ + delete(url: string, parameters: any, headers: any): Promise; + /** + * Make a sync DELETE request + * @param url {string} The url to send the request to + * @param parameters {Object} Parameters to send with the request + * @param headers {Object} The headers to set for this request + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * @returns {string} returns a string that represents the requestId + */ + deleteSync(url: string, parameters: any, headers: any, success: (result: HTTPResponse) => void, failure: (error: any) => void): string; + /** + * Make a HEAD request + * @param url {string} The url to send the request to + * @param parameters {Object} Parameters to send with the request + * @param headers {Object} The headers to set for this request + * @returns {Promise} returns a promise that will resolve on success, and reject on failure + */ + head(url: string, parameters: any, headers: any): Promise; + /** + * Make a sync HEAD request + * @param url {string} The url to send the request to + * @param parameters {Object} Parameters to send with the request + * @param headers {Object} The headers to set for this request + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * @returns {string} returns a string that represents the requestId + */ + headSync(url: string, parameters: any, headers: any, success: (result: HTTPResponse) => void, failure: (error: any) => void): string; + /** + * Make an OPTIONS request + * @param url {string} The url to send the request to + * @param parameters {Object} Parameters to send with the request + * @param headers {Object} The headers to set for this request + * @returns {Promise} returns a promise that will resolve on success, and reject on failure + */ + options(url: string, parameters: any, headers: any): Promise; + /** + * Make an sync OPTIONS request + * @param url {string} The url to send the request to + * @param parameters {Object} Parameters to send with the request + * @param headers {Object} The headers to set for this request + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * @returns {string} returns a string that represents the requestId + */ + optionsSync(url: string, parameters: any, headers: any, success: (result: HTTPResponse) => void, failure: (error: any) => void): string; + /** + * + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @param filePath {string} The local path(s) of the file(s) to upload + * @param name {string} The name(s) of the parameter to pass the file(s) along as + * @returns {Promise} returns a FileEntry promise that will resolve on success, and reject on failure + */ + uploadFile(url: string, body: any, headers: any, filePath: string | string[], name: string | string[]): Promise; + /** + * + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @param filePath {string} The local path(s) of the file(s) to upload + * @param name {string} The name(s) of the parameter to pass the file(s) along as + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * @returns {string} returns a string that represents the requestId + */ + uploadFileSync(url: string, body: any, headers: any, filePath: string | string[], name: string | string[], success: (result: any) => void, failure: (error: any) => void): string; + /** + * + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @param filePath {string} The path to download the file to, including the file name. + * @returns {Promise} returns a FileEntry promise that will resolve on success, and reject on failure + */ + downloadFile(url: string, body: any, headers: any, filePath: string): Promise; + /** + * + * @param url {string} The url to send the request to + * @param body {Object} The body of the request + * @param headers {Object} The headers to set for this request + * @param filePath {string} The path to download the file to, including the file name. + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * @returns {string} returns a string that represents the requestId + */ + downloadFileSync(url: string, body: any, headers: any, filePath: string, success: (result: any) => void, failure: (error: any) => void): string; + /** + * + * @param url {string} The url to send the request to + * @param options {Object} options for individual request + * @param options.method {string} request method + * @param options.data {Object} payload to be send to the server (only applicable on post, put or patch methods) + * @param options.params {Object} query params to be appended to the URL (only applicable on get, head, delete, upload or download methods) + * @param options.serializer {string} data serializer to be used (only applicable on post, put or patch methods), defaults to global serializer value, see setDataSerializer for supported values + * @param options.timeout {number} timeout value for the request in seconds, defaults to global timeout value + * @param options.headers {Object} headers object (key value pair), will be merged with global values + * @param options.filePath {string} file path(s) to be used during upload and download see uploadFile and downloadFile for detailed information + * @param options.name {string} name(s) to be used during upload see uploadFile for detailed information + * @param options.responseType {string} response type, defaults to text + * + * @returns {Promise} returns a promise that will resolve on success, and reject on failure + */ + sendRequest(url: string, options: { + method: 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete' | 'options' | 'upload' | 'download'; + data?: { + [index: string]: any; + }; + params?: { + [index: string]: string | number; + }; + serializer?: 'json' | 'urlencoded' | 'utf8' | 'multipart' | 'raw'; + timeout?: number; + headers?: { + [index: string]: string; + }; + filePath?: string | string[]; + name?: string | string[]; + responseType?: 'text' | 'arraybuffer' | 'blob' | 'json'; + }): Promise; + /** + * + * @param url {string} The url to send the request to + * @param options {Object} options for individual request + * @param options.method {string} request method + * @param options.data {Object} payload to be send to the server (only applicable on post, put or patch methods) + * @param options.params {Object} query params to be appended to the URL (only applicable on get, head, delete, upload or download methods) + * @param options.serializer {string} data serializer to be used (only applicable on post, put or patch methods), defaults to global serializer value, see setDataSerializer for supported values + * @param options.timeout {number} timeout value for the request in seconds, defaults to global timeout value + * @param options.headers {Object} headers object (key value pair), will be merged with global values + * @param options.filePath {string} file path(s) to be used during upload and download see uploadFile and downloadFile for detailed information + * @param options.name {string} name(s) to be used during upload see uploadFile for detailed information + * @param options.responseType {string} response type, defaults to text + * @param success {function} A callback that is called when the request succeed + * @param failure {function} A callback that is called when the request failed + * + * @returns {string} returns a string that represents the requestId + */ + sendRequestSync(url: string, options: { + method: 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete' | 'options' | 'upload' | 'download'; + data?: { + [index: string]: any; + }; + params?: { + [index: string]: string | number; + }; + serializer?: 'json' | 'urlencoded' | 'utf8' | 'multipart'; + timeout?: number; + headers?: { + [index: string]: string; + }; + filePath?: string | string[]; + name?: string | string[]; + responseType?: 'text' | 'arraybuffer' | 'blob' | 'json'; + }, success: (result: HTTPResponse) => void, failure: (error: any) => void): string; + /** + * @param requestId {string} The RequestId of the request to abort + */ + abort(requestId: string): Promise; +} +export {}; + +export declare const HTTP: HTTPOriginal; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 00000000..7efd19b7 --- /dev/null +++ b/dist/index.js @@ -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 }; \ No newline at end of file diff --git a/package.json b/package.json index 08bf8404..43b4fae7 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } } diff --git a/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java b/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java index a89f5b3c..aded9797 100644 --- a/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java +++ b/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java @@ -133,6 +133,7 @@ protected void prepareRequest(HttpRequest request) throws JSONException, IOExcep request.followRedirects(this.followRedirects); request.connectTimeout(this.connectTimeout); request.readTimeout(this.readTimeout); + request.acceptCharset("UTF-8"); request.uncompress(true); if (this.tlsConfiguration.getHostnameVerifier() != null) { diff --git a/src/android/com/silkimen/cordovahttp/CordovaServerTrust.java b/src/android/com/silkimen/cordovahttp/CordovaServerTrust.java index 5e973646..ca4f103f 100644 --- a/src/android/com/silkimen/cordovahttp/CordovaServerTrust.java +++ b/src/android/com/silkimen/cordovahttp/CordovaServerTrust.java @@ -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"))); @@ -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); diff --git a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m index 7319e408..eacaab33 100644 --- a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m +++ b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m @@ -155,18 +155,8 @@ @interface SM_AFSecurityPolicy() @implementation SM_AFSecurityPolicy -+(BOOL) isRunningOnCapacitor { - return NSClassFromString(@"CAPPlugin") != nil; -} - + (NSSet *)certificatesInBundle:(NSBundle *)bundle { - NSString* assetDir = @"www"; - if([self isRunningOnCapacitor]) { - // we are running on capacitor and its assets dir is 'public' - assetDir = @"public"; - } - - NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory: [NSString stringWithFormat:@"%@/certificates", assetDir]]; + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"public"]; NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]]; for (NSString *path in paths) { @@ -181,7 +171,7 @@ + (NSSet *)defaultPinnedCertificates { static NSSet *_defaultPinnedCertificates = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - NSBundle *bundle = [self isRunningOnCapacitor] ? [NSBundle mainBundle] : [NSBundle bundleForClass:[self class]]; + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; _defaultPinnedCertificates = [self certificatesInBundle:bundle]; }); From aa6ff390d3dd830e55f65313d8a561e690c95311 Mon Sep 17 00:00:00 2001 From: rokanraja1 Date: Mon, 11 Mar 2024 16:25:31 +0530 Subject: [PATCH 2/9] Adjust ios ssl pinnig --- src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m index eacaab33..fa0b8772 100644 --- a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m +++ b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m @@ -267,7 +267,13 @@ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust case AFSSLPinningModeCertificate: { NSMutableArray *pinnedCertificates = [NSMutableArray array]; for (NSData *certificateData in self.pinnedCertificates) { - [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; + if (certificateData != nil) { + SecCertificateRef certificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData); + if (certificate != NULL) { + [pinnedCertificates addObject:(__bridge id)certificate]; + CFRelease(certificate); + } + } } SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); From 8395e6015fb5ae9900136eb11ad4670601a12817 Mon Sep 17 00:00:00 2001 From: rokanraja1 Date: Mon, 11 Mar 2024 16:43:01 +0530 Subject: [PATCH 3/9] Adjust ios ssl pinnig --- src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m index fa0b8772..42ac7fe3 100644 --- a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m +++ b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m @@ -272,7 +272,11 @@ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust if (certificate != NULL) { [pinnedCertificates addObject:(__bridge id)certificate]; CFRelease(certificate); + } else { + NSLog(@"Failed to create certificate from data: %@", certificateData); } + } else { + NSLog(@"Encountered nil certificateData in self.pinnedCertificates"); } } SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); From f69dae8879adfb791833bd810440aaf6b6f9d73a Mon Sep 17 00:00:00 2001 From: rokanraja1 Date: Mon, 11 Mar 2024 17:08:24 +0530 Subject: [PATCH 4/9] Adjust ios ssl pinnig --- src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m index 42ac7fe3..c472bb87 100644 --- a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m +++ b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m @@ -100,18 +100,29 @@ static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { return isValid; } -static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { +NSArray *AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; for (CFIndex i = 0; i < certificateCount; i++) { SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); - [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate); + + if (certificateData != nil) { + SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData); + if (cert != NULL) { + [trustChain addObject:(__bridge id)cert]; + CFRelease(cert); + } else { + NSLog(@"Failed to create certificate from data: %@", certificateData); + } + } else { + NSLog(@"Empty certificateData at index %ld", i); + } } - return [NSArray arrayWithArray:trustChain]; + return [trustChain copy]; } - static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { SecPolicyRef policy = SecPolicyCreateBasicX509(); CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); From 30e75149427c4ea43f4fd455b1a6bbba403c38e8 Mon Sep 17 00:00:00 2001 From: rokanraja1 Date: Thu, 21 Mar 2024 13:44:21 +0530 Subject: [PATCH 5/9] Adjust http request --- src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m | 4 ++-- www/helpers.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m index c472bb87..a77b935f 100644 --- a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m +++ b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m @@ -100,7 +100,7 @@ static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { return isValid; } -NSArray *AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { +static NSArray *AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; @@ -121,7 +121,7 @@ static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { } } - return [trustChain copy]; + return [NSArray arrayWithArray:trustChain]; } static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { SecPolicyRef policy = SecPolicyCreateBasicX509(); diff --git a/www/helpers.js b/www/helpers.js index ed070fe6..070ac6f8 100644 --- a/www/helpers.js +++ b/www/helpers.js @@ -225,7 +225,7 @@ module.exports = function init(global, jsUtil, cookieHandler, messages, base64, } function checkParamsObject(params) { - return checkKeyValuePairObject(params, ['String', 'Array'], messages.TYPE_MISMATCH_PARAMS); + return checkKeyValuePairObject(params, ['String', 'Array', 'Number'], messages.TYPE_MISMATCH_PARAMS); } function checkDownloadFilePath(filePath) { From 8b1d07ff3eda6d485a13fbda8eb807994a4c828a Mon Sep 17 00:00:00 2001 From: rokanraja1 <124552992+rokanraja1@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:52:38 +0000 Subject: [PATCH 6/9] options params adjust done --- www/helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/helpers.js b/www/helpers.js index 070ac6f8..e69d5549 100644 --- a/www/helpers.js +++ b/www/helpers.js @@ -225,7 +225,7 @@ module.exports = function init(global, jsUtil, cookieHandler, messages, base64, } function checkParamsObject(params) { - return checkKeyValuePairObject(params, ['String', 'Array', 'Number'], messages.TYPE_MISMATCH_PARAMS); + return checkKeyValuePairObject(params, ['String', 'Array', 'Number', 'Boolean', 'Null', 'Object'], messages.TYPE_MISMATCH_PARAMS); } function checkDownloadFilePath(filePath) { From 2aa368dafeca4fc09974520e26a6b29cb11646a9 Mon Sep 17 00:00:00 2001 From: rokanraja1 <124552992+rokanraja1@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:21:46 +0000 Subject: [PATCH 7/9] ios app crash issue fixed --- src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m index a77b935f..e7b8dc54 100644 --- a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m +++ b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m @@ -103,23 +103,21 @@ static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { static NSArray *AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; - - for (CFIndex i = 0; i < certificateCount; i++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); - NSData *certificateData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate); - - if (certificateData != nil) { - SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData); - if (cert != NULL) { - [trustChain addObject:(__bridge id)cert]; - CFRelease(cert); - } else { - NSLog(@"Failed to create certificate from data: %@", certificateData); + @try { + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + if (certificate != NULL) { + NSData *certData = (__bridge_transfer NSData *)SecCertificateCopyData(certificate); + if (certData) { + [trustChain addObject:certData]; + } } - } else { - NSLog(@"Empty certificateData at index %ld", i); } } + @catch (NSException *exception) { + NSLog(@"Error retrieving certificate data: %@", exception); + return nil; + } return [NSArray arrayWithArray:trustChain]; } From 88c429296a9038ae4c646715b837e743550f2683 Mon Sep 17 00:00:00 2001 From: rokanraja1 <124552992+rokanraja1@users.noreply.github.com> Date: Sat, 30 Nov 2024 12:28:03 +0000 Subject: [PATCH 8/9] try catch added done --- src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m | 140 ++++++++++-------- 1 file changed, 77 insertions(+), 63 deletions(-) diff --git a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m index e7b8dc54..0b00d25a 100644 --- a/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m +++ b/src/ios/SM_AFNetworking/SM_AFSecurityPolicy.m @@ -241,88 +241,102 @@ - (void)setPinnedCertificates:(NSSet *)pinnedCertificates { - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust forDomain:(NSString *)domain { - if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) { - // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html - // According to the docs, you should only trust your provided certs for evaluation. - // Pinned certificates are added to the trust. Without pinned certificates, - // there is nothing to evaluate against. - // - // From Apple Docs: - // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors). - // Instead, add your own (self-signed) CA certificate to the list of trusted anchors." - NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning."); - return NO; - } - - NSMutableArray *policies = [NSMutableArray array]; - if (self.validatesDomainName) { - [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; - } else { - [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; - } + @try { + if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) { + // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html + // According to the docs, you should only trust your provided certs for evaluation. + // Pinned certificates are added to the trust. Without pinned certificates, + // there is nothing to evaluate against. + // + // From Apple Docs: + // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors). + // Instead, add your own (self-signed) CA certificate to the list of trusted anchors." + NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning."); + return NO; + } - SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); + NSMutableArray *policies = [NSMutableArray array]; + if (self.validatesDomainName) { + [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; + } else { + [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; + } - if (self.SSLPinningMode == AFSSLPinningModeNone) { - return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust); - } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { - return NO; - } + SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); - switch (self.SSLPinningMode) { - case AFSSLPinningModeNone: - default: + if (self.SSLPinningMode == AFSSLPinningModeNone) { + return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust); + } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { return NO; - case AFSSLPinningModeCertificate: { - NSMutableArray *pinnedCertificates = [NSMutableArray array]; - for (NSData *certificateData in self.pinnedCertificates) { - if (certificateData != nil) { - SecCertificateRef certificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData); - if (certificate != NULL) { - [pinnedCertificates addObject:(__bridge id)certificate]; - CFRelease(certificate); + } + + switch (self.SSLPinningMode) { + case AFSSLPinningModeNone: + default: + return NO; + case AFSSLPinningModeCertificate: { + NSMutableArray *pinnedCertificates = [NSMutableArray array]; + for (NSData *certificateData in self.pinnedCertificates) { + if (certificateData != nil) { + @try { + SecCertificateRef certificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData); + if (certificate != NULL) { + [pinnedCertificates addObject:(__bridge id)certificate]; + CFRelease(certificate); + } else { + NSLog(@"Failed to create certificate from data: %@", certificateData); + } + } @catch (NSException *exception) { + NSLog(@"Exception occurred while creating certificate: %@", exception); + return NO; // or you could return YES or rethrow depending on the severity + } } else { - NSLog(@"Failed to create certificate from data: %@", certificateData); + NSLog(@"Encountered nil certificateData in self.pinnedCertificates"); } - } else { - NSLog(@"Encountered nil certificateData in self.pinnedCertificates"); } - } - SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); - if (!AFServerTrustIsValid(serverTrust)) { - return NO; - } + if (!AFServerTrustIsValid(serverTrust)) { + return NO; + } - // obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA) - NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); + // obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA) + NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); - for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) { - if ([self.pinnedCertificates containsObject:trustChainCertificate]) { - return YES; + for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) { + if ([self.pinnedCertificates containsObject:trustChainCertificate]) { + return YES; + } } - } - return NO; - } - case AFSSLPinningModePublicKey: { - NSUInteger trustedPublicKeyCount = 0; - NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); - - for (id trustChainPublicKey in publicKeys) { - for (id pinnedPublicKey in self.pinnedPublicKeys) { - if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { - trustedPublicKeyCount += 1; + return NO; + } + case AFSSLPinningModePublicKey: { + NSUInteger trustedPublicKeyCount = 0; + NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); + + for (id trustChainPublicKey in publicKeys) { + for (id pinnedPublicKey in self.pinnedPublicKeys) { + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { + trustedPublicKeyCount += 1; + } } } + return trustedPublicKeyCount > 0; } - return trustedPublicKeyCount > 0; } } - - return NO; + @catch (NSException *exception) { + // Handle the exception here (log it, rethrow, or return a fallback value) + NSLog(@"Exception during server trust evaluation: %@", exception); + return NO; // Or handle the exception based on your needs + } + @finally { + // Any cleanup code if needed + } } + #pragma mark - NSKeyValueObserving + (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { From 17efaaa9a653ed904dedaf57d4d97e2d0d93eb46 Mon Sep 17 00:00:00 2001 From: rokanraja1 <124552992+rokanraja1@users.noreply.github.com> Date: Mon, 10 Feb 2025 06:46:46 +0000 Subject: [PATCH 9/9] Mod security due to remove the header --- src/android/com/silkimen/cordovahttp/CordovaHttpBase.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java b/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java index aded9797..a89f5b3c 100644 --- a/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java +++ b/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java @@ -133,7 +133,6 @@ protected void prepareRequest(HttpRequest request) throws JSONException, IOExcep request.followRedirects(this.followRedirects); request.connectTimeout(this.connectTimeout); request.readTimeout(this.readTimeout); - request.acceptCharset("UTF-8"); request.uncompress(true); if (this.tlsConfiguration.getHostnameVerifier() != null) {