New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

atlassian-connect-js-request

Package Overview
Dependencies
Maintainers
5
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atlassian-connect-js-request - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

log

12

dist/connect-host-request.js

@@ -83,3 +83,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.connectHostRequest = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

/**
* Execute an XMLHttpRequest in the context of the host application. The format of the response (dataType) will always be set to "text" - even if specified.
* Execute an XMLHttpRequest as a Promise, or via callbacks, in the context of the host application. The format of the response (dataType) will always be set to "text" - even if specified.
*

@@ -95,4 +95,4 @@ * @param {String} url Either the URI to request or an options object (as below) containing at least a 'url' property;<br />

* @param {Object} [options.headers] An object containing headers to set; supported headers are: 'Accept', 'If-Match' and 'If-None-Match'.
* @param {Function} [options.success] A callback function executed on a 200 success status code.
* @param {Function} [options.error] A callback function executed when a HTTP status error code is returned.
* @param {Function} [options.success] An optional callback function executed on a 200 success status code.
* @param {Function} [options.error] An optional callback function executed when a HTTP status error code is returned.
* @param {Boolean} [options.experimental=false] If this is set to true, the developer acknowledges that the API endpoint which is being called may be in beta state, and thus may also have a shorter deprecation cycle than stable APIs.

@@ -125,2 +125,8 @@ * @example

* });
* @example
* // Get the current user info using a Promise
*
* AP.request('/rest/api/2/myself')
* .then(data => alert(data.body))
* .catch(e => alert(e.err));
*/

@@ -127,0 +133,0 @@ request: function request(args, callback) {

@@ -97,40 +97,50 @@ // {}, function => new

function request(options, callback) {
if (typeof options === "string") {
if (typeof callback === "object") {
callback.url = options;
options = callback;
} else {
options = { url: options };
}
}
// find callbacks in old syntax
if (options.success) {
var success = options.success;
delete options.success;
var error = options.error || function () {};
delete options.error;
callback = function (err, response, body) {
if (err === false) {
success(body, "success", Xhr(response));
return new AP._promise(function (resolve, reject) {
if (typeof options === "string") {
if (typeof callback === "object") {
callback.url = options;
options = callback;
} else {
error(Xhr(response), "error", err);
options = { url: options };
}
};
}
}
if (options.contentType === 'multipart/form-data') {
Object.keys(options.data).forEach(function (key) {
var item = options.data[key];
if (Array.isArray(item)) {
item.forEach(function (val, index) {
options.data[key][index] = wrapBlob(val);
});
} else {
options.data[key] = wrapBlob(item);
}
});
}
// find callbacks in old syntax
if (options.success) {
var success = options.success;
delete options.success;
var error = options.error || function () {};
delete options.error;
callback = function (err, response, body) {
if (err === false) {
success(body, "success", Xhr(response));
} else {
error(Xhr(response), "error", err);
}
};
} else if (typeof callback !== "function") {
callback = function (err, response, body) {
if (err === false) {
resolve({ body: body, xhr: Xhr(response) });
} else {
reject({ xhr: Xhr(response), err: err });
}
};
}
original_request(options, callback);
if (options.contentType === 'multipart/form-data') {
Object.keys(options.data).forEach(function (key) {
var item = options.data[key];
if (Array.isArray(item)) {
item.forEach(function (val, index) {
options.data[key][index] = wrapBlob(val);
});
} else {
options.data[key] = wrapBlob(item);
}
});
}
original_request(options, callback);
});
}

@@ -137,0 +147,0 @@

{
"name": "atlassian-connect-js-request",
"version": "0.2.1",
"version": "0.2.2",
"description": "Request module for Atlassian Connect",
"devDependencies": {
"babelify": "^6.0.2",
"browserify": "^9.0.8",
"envify": "^3.4.0",

@@ -11,2 +12,3 @@ "gulp": "^3.8.11",

"gulp-concat": "^2.5.2",
"gulp-derequire": "^2.1.0",
"gulp-uglify": "^1.2.0",

@@ -16,4 +18,3 @@ "gulp-util": "^3.0.4",

"lodash": "^3.7.0",
"browserify": "^9.0.8",
"gulp-derequire": "^2.1.0",
"promise-polyfill": "6.0.2",
"unreachable-branch-transform": "^0.2.3",

@@ -20,0 +21,0 @@ "vinyl-buffer": "^1.0.0",

@@ -9,3 +9,4 @@ describe('request plugin', () => {

},
request: requestStub
request: requestStub,
_promise: Promise
}

@@ -119,2 +120,15 @@

it('promise is resolved', done => {
options = {url: 'some/url'};
const testBody = 'some test body';
const testReponse = 'some response';
AP.request(options).then(obj => {
expect(obj.body).toEqual(testBody);
done();
});
expect(requestStub).toHaveBeenCalled();
const callback = requestStub.calls.first().args[1];
callback(false, testReponse, testBody);
});
it('error is called', () => {

@@ -134,2 +148,28 @@ AP.request(options);

it('promise is rejected', done => {
options = {url: 'some/url'};
const testError = 'some test error';
const testReponse = 'some response';
AP.request(options).catch(obj => {
expect(obj.err).toEqual(testError);
done();
});
expect(requestStub).toHaveBeenCalled();
const callback = requestStub.calls.first().args[1];
callback(testError, testReponse, testError);
});
it('promise is not rejected if success callback exists', () => {
options = {url: 'some/url', success: successSpy};
const testError = 'some test error';
const testReponse = 'some response';
AP.request(options).catch(obj => {
fail('promise was rejected');
});
expect(requestStub).toHaveBeenCalled();
const callback = requestStub.calls.first().args[1];
callback(testError, testReponse, testError);
expect(errorSpy).not.toHaveBeenCalled();
});
});

@@ -136,0 +176,0 @@

@@ -49,3 +49,3 @@ /**

Object.keys(ajaxOptions.data).forEach(function (key) {
var formValue = ajaxOptions.data[key];
var formValue = ajaxOptions.data[key];
if (Array.isArray(formValue)) {

@@ -69,3 +69,3 @@ formValue.forEach(function (val, index) {

/**
* Execute an XMLHttpRequest in the context of the host application. The format of the response (dataType) will always be set to "text" - even if specified.
* Execute an XMLHttpRequest as a Promise, or via callbacks, in the context of the host application. The format of the response (dataType) will always be set to "text" - even if specified.
*

@@ -81,4 +81,4 @@ * @param {String} url Either the URI to request or an options object (as below) containing at least a 'url' property;<br />

* @param {Object} [options.headers] An object containing headers to set; supported headers are: 'Accept', 'If-Match' and 'If-None-Match'.
* @param {Function} [options.success] A callback function executed on a 200 success status code.
* @param {Function} [options.error] A callback function executed when a HTTP status error code is returned.
* @param {Function} [options.success] An optional callback function executed on a 200 success status code.
* @param {Function} [options.error] An optional callback function executed when a HTTP status error code is returned.
* @param {Boolean} [options.experimental=false] If this is set to true, the developer acknowledges that the API endpoint which is being called may be in beta state, and thus may also have a shorter deprecation cycle than stable APIs.

@@ -112,2 +112,9 @@ * @example

* });
* @example
* // Get the current user info using a Promise
*
* AP.request('/rest/api/2/myself')
* .then(data => alert(data.body))
* .catch(e => alert(e.err));
*/

@@ -114,0 +121,0 @@ request: function(args, callback){

@@ -20,3 +20,3 @@ // {}, function => new

}
}
}

@@ -96,40 +96,50 @@ // universal iterator utility

function request(options, callback){
if (typeof options === "string") {
if(typeof callback === "object") {
callback.url = options;
options = callback;
} else {
options = {url: options};
return new AP._promise((resolve, reject) => {
if (typeof options === "string") {
if(typeof callback === "object") {
callback.url = options;
options = callback;
} else {
options = {url: options};
}
}
}
// find callbacks in old syntax
if(options.success){
var success = options.success;
delete options.success;
var error = options.error || function(){};
delete options.error;
callback = function(err, response, body){
if (err === false) {
success(body, "success", Xhr(response));
} else {
error(Xhr(response), "error", err);
// find callbacks in old syntax
if(options.success){
var success = options.success;
delete options.success;
var error = options.error || function(){};
delete options.error;
callback = function(err, response, body){
if (err === false) {
success(body, "success", Xhr(response));
} else {
error(Xhr(response), "error", err);
}
};
} else if (typeof callback !== "function"){
callback = function(err, response, body) {
if (err === false) {
resolve({body, xhr: Xhr(response)});
} else {
reject({xhr: Xhr(response), err})
}
}
};
}
}
if (options.contentType === 'multipart/form-data') {
Object.keys(options.data).forEach(function(key) {
var item = options.data[key];
if (Array.isArray(item)) {
item.forEach(function (val, index) {
options.data[key][index] = wrapBlob(val);
})
} else {
options.data[key] = wrapBlob(item);
}
})
}
original_request(options, callback);
if (options.contentType === 'multipart/form-data') {
Object.keys(options.data).forEach(function(key) {
var item = options.data[key];
if (Array.isArray(item)) {
item.forEach(function (val, index) {
options.data[key][index] = wrapBlob(val);
})
} else {
options.data[key] = wrapBlob(item);
}
})
}
original_request(options, callback);
});
}

@@ -140,4 +150,2 @@

}());
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc