Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

c8osdkjscore

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

c8osdkjscore - npm Package Compare versions

Comparing version 0.0.0-beta5 to 0.0.0-beta6

2

package.json
{
"name": "c8osdkjscore",
"version": "0.0.0-beta5",
"version": "0.0.0-beta6",
"description": "convertigo's sdk js core",

@@ -5,0 +5,0 @@ "main": "bundle/index.umd.js",

import { C8oBase } from "./c8oBase";
import { C8oHttpInterface } from "./c8oHttpInterface";
import { C8oHttpInterfaceCore } from "./c8oHttpInterface";
import { C8oLogger } from "./c8oLogger";

@@ -44,3 +44,3 @@ import { C8oLogLevel } from "./c8oLogLevel";

protected _automaticRemoveSplashsCreen: boolean;
httpInterface: C8oHttpInterface;
httpInterface: C8oHttpInterfaceCore;
c8oLogger: C8oLogger;

@@ -47,0 +47,0 @@ c8oFullSync: C8oFullSync;

import {C8oBase} from "./c8oBase";
import {C8oUtilsCore} from "./c8oUtilsCore";
import {C8oHttpInterface} from "./c8oHttpInterface";
import {C8oHttpInterfaceCore} from "./c8oHttpInterface";
import {C8oLogger} from "./c8oLogger";

@@ -144,3 +144,3 @@ import {C8oLogLevel} from "./c8oLogLevel";

*/
httpInterface: C8oHttpInterface;
httpInterface: C8oHttpInterfaceCore;

@@ -147,0 +147,0 @@ /**

@@ -5,3 +5,3 @@ import { C8oCore } from "./c8oCore";

import { C8oProgress } from "./c8oProgress";
export declare class C8oHttpInterface {
export declare abstract class C8oHttpInterfaceCore {
c8o: C8oCore;

@@ -13,12 +13,11 @@ timeout: number;

constructor(c8o: C8oCore);
checkFile(parameters: Object): number;
transformRequest(parameters: Object): string;
transformRequestformdata(parameters: Object): FormData;
transformRequestfilecordova(parameters: Object): any;
private isCordova();
handleRequest(url: string, parameters: Object, c8oResponseListener?: C8oResponseListener): Promise<any>;
uploadfilePluginCordova(url: string, parameters: Object, c8oResponseListener: C8oResponseListener): Promise<any>;
uplaodfilesHttpClient(url: string, parameters: Object): Promise<any>;
uploadfilesHttpClientRequest(url: string, form: FormData, parameters: Object, c8oResponseListener: C8oResponseListener): Promise<any>;
handleProgress(event: any, progress: C8oProgress, parameters: any, c8oResponseListener: C8oResponseListener, varNull: JSON): void;
abstract checkFile(parameters: Object): number;
abstract transformRequest(parameters: Object): string;
abstract transformRequestformdata(parameters: Object): FormData;
abstract transformRequestfileNative(parameters: Object): any;
abstract handleRequest(url: string, parameters: Object, c8oResponseListener?: C8oResponseListener): Promise<any>;
abstract uploadfilePluginNative(url: string, parameters: Object, c8oResponseListener: C8oResponseListener): Promise<any>;
abstract uplaodfilesHttpClient(url: string, parameters: Object): Promise<any>;
abstract uploadfilesHttpClientRequest(url: string, form: FormData, parameters: Object, c8oResponseListener: C8oResponseListener): Promise<any>;
abstract handleProgress(event: any, progress: C8oProgress, parameters: any, c8oResponseListener: C8oResponseListener, varNull: JSON): void;
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var c8oCore_1 = require("./c8oCore");
require("rxjs/add/operator/retry");
var c8oProgress_1 = require("./c8oProgress");
var C8oHttpInterface = (function () {
function C8oHttpInterface(c8o) {
var C8oHttpInterfaceCore = (function () {
function C8oHttpInterfaceCore(c8o) {
this.firstCall = true;

@@ -48,184 +11,5 @@ this._isCordova = null;

}
C8oHttpInterface.prototype.checkFile = function (parameters) {
for (var p in parameters) {
if (parameters[p] instanceof Array) {
for (var p1 in parameters[p]) {
if (parameters[p][p1] instanceof FileList) {
return 1;
}
else if (this.isCordova()) {
if (parameters[p][p1] instanceof URL) {
return 2;
}
}
}
}
else {
if (parameters[p] instanceof FileList) {
return 1;
}
else if (this.isCordova()) {
if (parameters[p] instanceof URL) {
return 2;
}
}
}
}
return 0;
};
C8oHttpInterface.prototype.transformRequest = function (parameters) {
var str = [];
for (var p in parameters) {
if (parameters[p] instanceof Array) {
for (var p1 in parameters[p]) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(parameters[p][p1]));
}
}
else {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(parameters[p]));
}
}
var query = str.join("&");
return (query + "&__removeNamespaces=true");
};
C8oHttpInterface.prototype.transformRequestformdata = function (parameters) {
var formdata = new FormData();
for (var p in parameters) {
if (parameters[p] instanceof Array) {
for (var p1 in parameters[p]) {
if (parameters[p][p1] instanceof FileList) {
for (var i = 0; i < parameters[p][p1].length; i++) {
formdata.append(p, parameters[p][p1][i], parameters[p][p1][i].name);
}
}
else {
formdata.append(p, parameters[p][p1]);
}
}
}
else {
if (parameters[p] instanceof FileList) {
for (var j = 0; j < parameters[p].length; j++) {
formdata.append(p, parameters[p][j], parameters[p][j].name);
}
}
else {
formdata.append(p, parameters[p]);
}
}
}
return formdata;
};
C8oHttpInterface.prototype.transformRequestfilecordova = function (parameters) {
var file = new Array();
var params = new Object();
for (var p in parameters) {
if (parameters[p] instanceof Array) {
for (var p1 in parameters[p]) {
if (parameters[p][p1] instanceof URL) {
file.push([p1, parameters[p][p1]]);
}
else {
params[p1] = parameters[p][p1]["href"];
}
}
}
else {
if (parameters[p] instanceof URL) {
file.push([p, parameters[p]["href"]]);
}
else {
params[p] = parameters[p];
}
}
}
return [file, params];
};
C8oHttpInterface.prototype.isCordova = function () {
if (this._isCordova == null) {
if (window["cordova"] != undefined) {
this._isCordova = true;
}
else {
this._isCordova = false;
}
}
return this._isCordova;
};
C8oHttpInterface.prototype.handleRequest = function (url, parameters, c8oResponseListener) {
return __awaiter(this, void 0, void 0, function () {
var form;
return __generator(this, function (_a) {
if (parameters["__sequence"] !== undefined) {
if (parameters["__sequence"].indexOf("#") !== -1) {
parameters["__sequence"] = parameters["__sequence"].substring(0, parameters["__sequence"].indexOf("#"));
}
}
switch (this.checkFile(parameters)) {
case 0: {
return [2, this.uplaodfilesHttpClient(url, parameters)];
}
case 1: {
form = this.transformRequestformdata(parameters);
return [2, this.uploadfilesHttpClientRequest(url, form, parameters, c8oResponseListener)];
}
case 2: {
return [2, this.uploadfilePluginCordova(url, parameters, c8oResponseListener)];
}
}
return [2];
});
});
};
C8oHttpInterface.prototype.uploadfilePluginCordova = function (url, parameters, c8oResponseListener) {
var _this = this;
var progress = new c8oProgress_1.C8oProgress();
progress.pull = false;
var varNull = null;
var data = this.transformRequestfilecordova(parameters);
var files = data[0];
var options = new window["FileUploadOptions"]();
options.fileKey = files[0][0];
options.fileName = files[0][1].substr(files[0][1].lastIndexOf('/') + 1);
options.params = data[1];
var headersObject = { 'Accept': 'application/json', 'x-convertigo-sdk': this.c8o.sdkVersion };
Object.assign(headersObject, this.c8o.headers);
options.headers = headersObject;
return new Promise(function (resolve, reject) {
Promise.all([_this.p1]).then(function () {
var ft = new window["FileTransfer"]();
ft.onprogress = function (progressEvent) {
if (progressEvent.lengthComputable) {
_this.handleProgress(progressEvent, progress, parameters, c8oResponseListener, varNull);
}
};
ft.upload(files[0][1], encodeURI(url), ((function (resp) {
resolve(resp);
})), (function (err) {
reject(err);
}), options);
});
});
};
C8oHttpInterface.prototype.uplaodfilesHttpClient = function (url, parameters) {
return null;
};
C8oHttpInterface.prototype.uploadfilesHttpClientRequest = function (url, form, parameters, c8oResponseListener) {
return null;
};
C8oHttpInterface.prototype.handleProgress = function (event, progress, parameters, c8oResponseListener, varNull) {
progress.current = event.loaded;
progress.total = event.total;
if (event.loaded != event.total) {
progress.finished = false;
}
else {
progress.finished = true;
}
parameters[c8oCore_1.C8oCore.ENGINE_PARAMETER_PROGRESS] = progress;
c8oResponseListener.onJsonResponse(varNull, parameters);
};
return C8oHttpInterface;
return C8oHttpInterfaceCore;
}());
exports.C8oHttpInterface = C8oHttpInterface;
exports.C8oHttpInterfaceCore = C8oHttpInterfaceCore;
//# sourceMappingURL=c8oHttpInterface.js.map
import {C8oCore} from "./c8oCore";
import 'rxjs/add/operator/retry';
import {C8oExceptionMessage} from "./Exception/c8oExceptionMessage";
import {C8oHttpRequestException} from "./Exception/c8oHttpRequestException";
import {C8oResponseJsonListener, C8oResponseListener, C8oResponseProgressListener} from "./c8oResponse";
import { C8oResponseListener} from "./c8oResponse";
import {C8oProgress} from "./c8oProgress";
export class C8oHttpInterface {
export abstract class C8oHttpInterfaceCore {
c8o: C8oCore;

@@ -28,30 +26,3 @@ timeout: number;

*/
checkFile(parameters: Object): number{
for (let p in parameters) {
if (parameters[p] instanceof Array) {
for (let p1 in parameters[p]) {
//noinspection JSUnfilteredForInLoop
if(parameters[p][p1] instanceof FileList){
return 1;
}
else if(this.isCordova()){
if(parameters[p][p1] instanceof URL){
return 2;
}
}
}
}
else {
if(parameters[p] instanceof FileList){
return 1;
}
else if(this.isCordova()){
if(parameters[p]instanceof URL){
return 2;
}
}
}
}
return 0;
}
abstract checkFile(parameters: Object): number;

@@ -63,20 +34,3 @@ /**

*/
transformRequest(parameters: Object): string {
let str = [];
for (let p in parameters) {
if (parameters[p] instanceof Array) {
for (let p1 in parameters[p]) {
//noinspection JSUnfilteredForInLoop
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(parameters[p][p1]));
}
}
else {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(parameters[p]));
}
}
let query = str.join("&");
// Add this to instruct Convertigo server to remove any name space in the jSON keys
// to prevent keys like this: 'namespace:key'
return (query + "&__removeNamespaces=true");
}
abstract transformRequest(parameters: Object): string;

@@ -88,30 +42,3 @@ /**

*/
transformRequestformdata(parameters: Object): FormData {
let formdata : FormData= new FormData();
for (let p in parameters) {
if (parameters[p] instanceof Array) {
for (let p1 in parameters[p]) {
if(parameters[p][p1] instanceof FileList){
for (var i = 0; i < parameters[p][p1].length; i++) {
formdata.append(p, parameters[p][p1][i], parameters[p][p1][i].name);
}
}
else{
formdata.append(p, parameters[p][p1])
}
}
}
else {
if(parameters[p] instanceof FileList) {
for (var j = 0; j < parameters[p].length; j++) {
formdata.append(p, parameters[p][j], parameters[p][j].name);
}
}
else{
formdata.append(p, parameters[p]);
}
}
}
return formdata;
}
abstract transformRequestformdata(parameters: Object): FormData ;

@@ -124,43 +51,4 @@

*/
transformRequestfilecordova(parameters: Object): any {
let file: Array<any> = new Array();
let params: Object = new Object();
for (let p in parameters) {
if (parameters[p] instanceof Array) {
for (let p1 in parameters[p]) {
if(parameters[p][p1] instanceof URL){
file.push([p1, parameters[p][p1]]);
}
else{
params[p1] = parameters[p][p1]["href"];
}
}
}
else {
if(parameters[p] instanceof URL) {
file.push([p, parameters[p]["href"]]);
}
else{
params[p] = parameters[p];
}
}
}
return [file, params];
}
abstract transformRequestfileNative(parameters: Object): any;
/**
* Check if we are in cordova environment
* @return {boolean}
*/
private isCordova():boolean{
if(this._isCordova == null){
if(window["cordova"]!= undefined){
this._isCordova = true;
}
else{
this._isCordova = false;
}
}
return this._isCordova;
}

@@ -174,25 +62,6 @@ /**

*/
async handleRequest(url: string, parameters: Object, c8oResponseListener?: C8oResponseListener): Promise<any> {
if (parameters["__sequence"] !== undefined) {
if (parameters["__sequence"].indexOf("#") !== -1) {
parameters["__sequence"] = parameters["__sequence"].substring(0, parameters["__sequence"].indexOf("#"));
}
}
switch (this.checkFile(parameters)){
case 0: {
return this.uplaodfilesHttpClient(url, parameters);
}
case 1: {
let form = this.transformRequestformdata(parameters);
return this.uploadfilesHttpClientRequest(url,form,parameters,c8oResponseListener);
}
case 2: {
return this.uploadfilePluginCordova(url, parameters, c8oResponseListener);
}
}
abstract async handleRequest(url: string, parameters: Object, c8oResponseListener?: C8oResponseListener): Promise<any>;
}
/**
* Upload file with cordova plugin
* Upload file with native plugin
* @param {string} url

@@ -203,31 +72,3 @@ * @param {Object} parameters

*/
uploadfilePluginCordova(url: string, parameters: Object, c8oResponseListener: C8oResponseListener):Promise<any>{
let progress: C8oProgress = new C8oProgress();
progress.pull = false;
let varNull: JSON = null;
let data = this.transformRequestfilecordova(parameters);
let files = data[0];
let options = new window["FileUploadOptions"]();
options.fileKey = files[0][0];
options.fileName = files[0][1].substr(files[0][1].lastIndexOf('/') + 1);
options.params = data[1];
let headersObject = {'Accept':'application/json', 'x-convertigo-sdk': this.c8o.sdkVersion};
Object.assign(headersObject, this.c8o.headers);
options.headers = headersObject;
return new Promise((resolve,reject)=>{
Promise.all([this.p1]).then(() => {
var ft = new window["FileTransfer"]();
ft.onprogress = (progressEvent) => {
if (progressEvent.lengthComputable) {
this.handleProgress(progressEvent, progress, parameters, c8oResponseListener, varNull);
}
};
ft.upload(files[0][1], encodeURI(url), ((resp => {
resolve(resp);
})), ((err) => {
reject(err);
}), options);
});
});
}
abstract uploadfilePluginNative(url: string, parameters: Object, c8oResponseListener: C8oResponseListener):Promise<any>;

@@ -240,5 +81,3 @@ /**

*/
uplaodfilesHttpClient(url: string, parameters: Object): Promise<any>{
return null;
}
abstract uplaodfilesHttpClient(url: string, parameters: Object): Promise<any>;

@@ -253,5 +92,3 @@ /**

*/
uploadfilesHttpClientRequest(url: string, form: FormData, parameters: Object, c8oResponseListener: C8oResponseListener): Promise<any>{
return null;
}
abstract uploadfilesHttpClientRequest(url: string, form: FormData, parameters: Object, c8oResponseListener: C8oResponseListener): Promise<any>;

@@ -266,14 +103,3 @@ /**

*/
handleProgress(event: any, progress: C8oProgress, parameters: any, c8oResponseListener: C8oResponseListener, varNull: JSON){
progress.current = event.loaded;
progress.total = event.total;
if(event.loaded != event.total){
progress.finished = false;
}
else{
progress.finished = true;
}
parameters[C8oCore.ENGINE_PARAMETER_PROGRESS] = progress;
(c8oResponseListener as C8oResponseJsonListener).onJsonResponse(varNull, parameters);
}
abstract handleProgress(event: any, progress: C8oProgress, parameters: any, c8oResponseListener: C8oResponseListener, varNull: JSON): void;
}

Sorry, the diff of this file is not supported yet

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