From 27e959800aa2d643600b32e2b684a7192eed4bb6 Mon Sep 17 00:00:00 2001 From: Sefa Ilkimen Date: Sun, 27 May 2018 20:33:02 +0200 Subject: [PATCH] remove deprecated AngularJS integration service --- CHANGELOG.md | 3 +- README.md | 21 ++------- plugin.xml | 3 +- test/js-mocha-specs.js | 1 - www/advanced-http.js | 3 -- www/angular-integration.js | 96 -------------------------------------- 6 files changed, 7 insertions(+), 120 deletions(-) delete mode 100644 www/angular-integration.js diff --git a/CHANGELOG.md b/CHANGELOG.md index cfb8dab..6516a72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ - Feature #103: implement HTTP SSL cert modes -- :warning: **Breaking Change**: Removed "enableSSLPinning" and "acceptAllCerts", use "setSSLCertMode" instead. +- :warning: **Breaking Change**: Removed AngularJS (v1) integration service +- :warning: **Breaking Change**: Removed "enableSSLPinning" and "acceptAllCerts", use "setSSLCertMode" instead ## 1.11.1 diff --git a/README.md b/README.md index ad8bb7e..b2c3d9b 100644 --- a/README.md +++ b/README.md @@ -41,19 +41,6 @@ This plugin registers a global object located at `cordova.plugin.http`. Check the [Ionic docs](https://ionicframework.com/docs/native/http/) for how to use this plugin with Ionic-native. -### With AngularJS (Deprecated) - -:warning: *This feature is deprecated and will be removed anytime soon.* :warning: - -This plugin creates a cordovaHTTP service inside of a cordovaHTTP module. You must load the module when you create your app's module. - -```js -var app = angular.module('myApp', ['ngRoute', 'ngAnimate', 'cordovaHTTP']); -``` - -You can then inject the cordovaHTTP service into your controllers. The functions can then be used identically to the examples shown below except that instead of accepting success and failure callback functions, each function returns a promise. For more information on promises in AngularJS read the [AngularJS docs](http://docs.angularjs.org/api/ng/service/$q). For more info on promises in general check out this article on [html5rocks](http://www.html5rocks.com/en/tutorials/es6/promises/). Make sure that you load cordova.js or phonegap.js after AngularJS is loaded. - - ## Synchronous Functions ### getBasicAuthHeader @@ -175,10 +162,10 @@ cordova.plugin.http.setSSLCertMode('nocheck', function() { }); ``` -### enableSSLPinning +### enableSSLPinning (obsolete) This function was removed in 2.0.0. Use ["setSSLCertMode"](#setSSLCertMode) to enable SSL pinning (mode "pinned"). -### acceptAllCerts +### acceptAllCerts (obsolete) This function was removed in 2.0.0. Use ["setSSLCertMode"](#setSSLCertMode) to disable checking certs (mode "nocheck"). ### disableRedirect @@ -192,8 +179,8 @@ cordova.plugin.http.disableRedirect(true, function() { }); ``` -### validateDomainName -This function was removed in v1.6.2. Domain name validation is disabled automatically when you enable "acceptAllCerts". +### validateDomainName (obsolete) +This function was removed in v1.6.2. Domain name validation is disabled automatically when you set SSL cert mode to "nocheck". ### removeCookies Remove all cookies associated with a given URL. diff --git a/plugin.xml b/plugin.xml index 72ddbb5..6c62841 100644 --- a/plugin.xml +++ b/plugin.xml @@ -13,7 +13,6 @@ - @@ -80,4 +79,4 @@ - \ No newline at end of file + diff --git a/test/js-mocha-specs.js b/test/js-mocha-specs.js index 9ec8fd6..11ee709 100644 --- a/test/js-mocha-specs.js +++ b/test/js-mocha-specs.js @@ -28,7 +28,6 @@ describe('Advanced HTTP www interface', function() { mock(`${PLUGIN_ID}.cookie-handler`, {}); mock(`${HELPERS_ID}.cookie-handler`, {}); mock(`${HELPERS_ID}.messages`, require('../www/messages')); - mock(`${PLUGIN_ID}.angular-integration`, { registerService: noop }); loadHttp(); }); diff --git a/www/advanced-http.js b/www/advanced-http.js index 403dd04..74173c8 100644 --- a/www/advanced-http.js +++ b/www/advanced-http.js @@ -5,7 +5,6 @@ var pluginId = module.id.slice(0, module.id.lastIndexOf('.')); var exec = require('cordova/exec'); -var angularIntegration = require(pluginId +'.angular-integration'); var cookieHandler = require(pluginId + '.cookie-handler'); var helpers = require(pluginId + '.helpers'); @@ -123,6 +122,4 @@ var publicInterface = { } }; -// angular service is deprecated and will be removed anytime soon -angularIntegration.registerService(publicInterface); module.exports = publicInterface; diff --git a/www/angular-integration.js b/www/angular-integration.js deleted file mode 100644 index 39820f5..0000000 --- a/www/angular-integration.js +++ /dev/null @@ -1,96 +0,0 @@ -function registerService(http) { - if (typeof angular === 'undefined') return; - - angular.module('cordovaHTTP', []).factory('cordovaHTTP', function ($timeout, $q) { - function makePromise(fn, args, async) { - var deferred = $q.defer(); - - var success = function (response) { - if (async) { - $timeout(function () { - deferred.resolve(response); - }); - } else { - deferred.resolve(response); - } - }; - - var fail = function (response) { - if (async) { - $timeout(function () { - deferred.reject(response); - }); - } else { - deferred.reject(response); - } - }; - - args.push(success); - args.push(fail); - - fn.apply(http, args); - - return deferred.promise; - } - - var cordovaHTTP = { - getBasicAuthHeader: http.getBasicAuthHeader, - useBasicAuth: function (username, password) { - return http.useBasicAuth(username, password); - }, - setHeader: function (host, header, value) { - return http.setHeader(host, header, value); - }, - setDataSerializer: function (serializer) { - return http.setDataSerializer(serializer); - }, - clearCookies: function () { - return http.clearCookies(); - }, - removeCookies: function (url) { - return http.removeCookies(url); - }, - setRequestTimeout: function (timeout) { - return http.setRequestTimeout(timeout); - }, - enableSSLPinning: function (enable) { - return makePromise(http.enableSSLPinning, [enable]); - }, - acceptAllCerts: function (allow) { - return makePromise(http.acceptAllCerts, [allow]); - }, - disableRedirect: function(disable) { - return makePromise(http.disableRedirect, [disable]); - }, - validateDomainName: function (validate) { - return makePromise(http.validateDomainName, [validate]); - }, - post: function (url, data, headers) { - return makePromise(http.post, [url, data, headers], true); - }, - get: function (url, params, headers) { - return makePromise(http.get, [url, params, headers], true); - }, - put: function (url, data, headers) { - return makePromise(http.put, [url, data, headers], true); - }, - delete: function (url, params, headers) { - return makePromise(http.delete, [url, params, headers], true); - }, - head: function (url, params, headers) { - return makePromise(http.head, [url, params, headers], true); - }, - uploadFile: function (url, params, headers, filePath, name) { - return makePromise(http.uploadFile, [url, params, headers, filePath, name], true); - }, - downloadFile: function (url, params, headers, filePath) { - return makePromise(http.downloadFile, [url, params, headers, filePath], true); - } - }; - return cordovaHTTP; - }); -} - -module.exports = { - registerService: registerService -};