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

@warerebel/azureblobstoragehelper

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@warerebel/azureblobstoragehelper - npm Package Compare versions

Comparing version 0.9.2 to 0.9.7

91

dist/azureBlobStorage.js

@@ -17,3 +17,3 @@ "use strict";

httpOptions.headers.Authorization = this.azureKeyAuth.getAuthHeaderValue(httpOptions);
let request = https_1.request(httpOptions, (response) => {
const request = https_1.request(httpOptions, (response) => {
let returnedContent = "";

@@ -39,3 +39,3 @@ response.on("error", (error) => {

if (options.force || this.knownFilesystems.indexOf(options.filesystem) < 0) {
let httpOptions = {
const httpOptions = {
method: "PUT",

@@ -51,3 +51,3 @@ protocol: "https:",

this.executeRequest(httpOptions, null, (error, response, content) => {
if (!error && response.statusCode < 400)
if (!error && response.statusCode && response.statusCode < 400)
this.knownFilesystems.push(options.filesystem);

@@ -62,51 +62,64 @@ callback(error, response, content);

createFile(options, callback) {
let createFileOptions = {
const createFileOptions = {
method: "PUT",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename, "?resource=file"),
path: "/".concat(options.filesystem, "/", options.filename || "", "?resource=file"),
headers: options.httpHeaders || {}
};
createFileOptions.headers["x-ms-date"] = new Date().toUTCString();
createFileOptions.headers["x-ms-version"] = "2019-02-02";
createFileOptions.headers["Content-Length"] = 0;
if (createFileOptions.headers) {
createFileOptions.headers["x-ms-date"] = new Date().toUTCString();
createFileOptions.headers["x-ms-version"] = "2019-02-02";
createFileOptions.headers["Content-Length"] = 0;
}
this.executeRequest(createFileOptions, null, callback);
}
writeContent(options, callback) {
let writeFileOptions = {
const writeFileOptions = {
method: "PATCH",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename, "?action=append&position=", typeof options.position !== "undefined" ? options.position.toString() : "0"),
path: "/".concat(options.filesystem, "/", options.filename || "", "?action=append&position=", typeof options.position !== "undefined" ? options.position.toString() : "0"),
headers: options.httpHeaders || {}
};
writeFileOptions.headers["x-ms-date"] = new Date().toUTCString();
writeFileOptions.headers["x-ms-version"] = "2019-02-02";
writeFileOptions.headers["Content-Length"] = Buffer.byteLength(options.content);
this.executeRequest(writeFileOptions, options.content, callback);
if (writeFileOptions.headers && options.content) {
writeFileOptions.headers["x-ms-date"] = new Date().toUTCString();
writeFileOptions.headers["x-ms-version"] = "2019-02-02";
writeFileOptions.headers["Content-Length"] = Buffer.byteLength(options.content);
}
if (options.content)
this.executeRequest(writeFileOptions, options.content, callback);
else
callback(new Error("No content provided"));
}
getPath(options, callback) {
let pathOptions = {
const pathOptions = {
method: "HEAD",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename),
path: "/".concat(options.filesystem, "/", options.filename || ""),
headers: options.httpHeaders || {}
};
pathOptions.headers["x-ms-date"] = new Date().toUTCString();
pathOptions.headers["x-ms-version"] = "2019-02-02";
pathOptions.headers["Content-Length"] = 0;
if (pathOptions.headers) {
pathOptions.headers["x-ms-date"] = new Date().toUTCString();
pathOptions.headers["x-ms-version"] = "2019-02-02";
pathOptions.headers["Content-Length"] = 0;
}
this.executeRequest(pathOptions, null, callback);
}
flushContent(options, callback) {
let flushOptions = {
if (!options.position)
options.position = 0;
const flushOptions = {
method: "PATCH",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename, "?action=flush&position=", options.position.toString()),
path: "/".concat(options.filesystem, "/", options.filename || "", "?action=flush&position=", options.position.toString()),
headers: options.httpHeaders || {}
};
flushOptions.headers["x-ms-date"] = new Date().toUTCString();
flushOptions.headers["x-ms-version"] = "2019-02-02";
flushOptions.headers["Content-Length"] = 0;
if (flushOptions.headers) {
flushOptions.headers["x-ms-date"] = new Date().toUTCString();
flushOptions.headers["x-ms-version"] = "2019-02-02";
flushOptions.headers["Content-Length"] = 0;
}
this.executeRequest(flushOptions, null, callback);

@@ -117,12 +130,14 @@ }

options.recursive = false;
let deleteOptions = {
const deleteOptions = {
method: "DELETE",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename, "?recursive=", options.recursive.toString()),
path: "/".concat(options.filesystem, "/", options.filename || "", "?recursive=", options.recursive.toString()),
headers: options.httpHeaders || {}
};
deleteOptions.headers["x-ms-date"] = new Date().toUTCString();
deleteOptions.headers["x-ms-version"] = "2019-02-02";
deleteOptions.headers["Content-Length"] = 0;
if (deleteOptions.headers) {
deleteOptions.headers["x-ms-date"] = new Date().toUTCString();
deleteOptions.headers["x-ms-version"] = "2019-02-02";
deleteOptions.headers["Content-Length"] = 0;
}
this.executeRequest(deleteOptions, null, callback);

@@ -136,5 +151,5 @@ }

stream.on("readable", () => {
let chunk = stream.read(options.readChunkSize);
const chunk = stream.read(options.readChunkSize);
if (chunk !== null) {
let chunkLength = Buffer.byteLength(chunk);
const chunkLength = Buffer.byteLength(chunk);
currentLength += chunkLength;

@@ -168,14 +183,16 @@ options.content = chunk;

getStream(options, callback) {
let getStreamOptions = {
const getStreamOptions = {
method: "GET",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename),
path: "/".concat(options.filesystem, "/", options.filename || ""),
headers: options.httpHeaders || {}
};
getStreamOptions.agent = this.agent;
getStreamOptions.headers["x-ms-date"] = new Date().toUTCString();
getStreamOptions.headers["x-ms-version"] = "2019-02-02";
getStreamOptions.headers.Authorization = this.azureKeyAuth.getAuthHeaderValue(getStreamOptions);
let request = https_1.request(getStreamOptions, (response) => {
if (getStreamOptions.headers) {
getStreamOptions.headers["x-ms-date"] = new Date().toUTCString();
getStreamOptions.headers["x-ms-version"] = "2019-02-02";
getStreamOptions.headers.Authorization = this.azureKeyAuth.getAuthHeaderValue(getStreamOptions);
}
const request = https_1.request(getStreamOptions, (response) => {
callback(null, response);

@@ -182,0 +199,0 @@ });

@@ -1,13 +0,13 @@

import {AzureSign, HttpOptions} from "@warerebel/azurerestauth";
import {AzureSign} from "@warerebel/azurerestauth";
import {Readable} from "stream";
export interface StorageOptions {
force?: boolean,
filesystem: string,
filename?: string,
position?: number,
recursive?: boolean,
httpHeaders?: object,
content?: any,
readChunkSize?: number
force?: boolean;
filesystem: string;
filename?: string;
position?: number;
recursive?: boolean;
httpHeaders?: object;
content?: string | Buffer | null;
readChunkSize?: number;
}

@@ -18,3 +18,2 @@

azureKeyAuth: AzureSign;
knownFilesystems: String[];

@@ -21,0 +20,0 @@ constructor(storageAccount: string, storageSAS: string);

{
"name": "@warerebel/azureblobstoragehelper",
"version": "0.9.2",
"version": "0.9.7",
"description": "Module to ease the storing of data in azure gen2 blob storage",

@@ -14,6 +14,13 @@ "main": "dist/azureBlobStorage.js",

"build": "node node_modules/typescript/bin/tsc",
"test": "node node_modules/nyc/bin/nyc node_modules/mocha/bin/mocha test/*.spec.js",
"lint": "node node_modules/eslint/bin/eslint **/*.js",
"test": "node node_modules/nyc/bin/nyc node_modules/mocha/bin/mocha",
"lint": "node node_modules/eslint/bin/eslint **/*.ts",
"coverage": "node node_modules/nyc/bin/nyc report --reporter=text-lcov | node_modules/coveralls/bin/coveralls.js"
},
"nyc": {
"extends": "@istanbuljs/nyc-config-typescript",
"reporter": [
"text",
"lcov"
]
},
"repository": {

@@ -39,3 +46,6 @@ "type": "git",

"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^0.1.3",
"@types/mocha": "^5.2.7",
"@types/node": "^12.7.11",
"@types/sinon": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^2.3.2",

@@ -48,4 +58,6 @@ "@typescript-eslint/parser": "^2.3.2",

"sinon": "^7.5.0",
"source-map-support": "^0.5.13",
"ts-node": "^8.4.1",
"typescript": "^3.6.3"
}
}

@@ -7,10 +7,10 @@ import {request as httpsRequest, Agent} from "https";

export interface StorageOptions {
force?: boolean,
filesystem: string,
filename?: string,
position?: number,
recursive?: boolean,
httpHeaders?: object,
content?: any,
readChunkSize?: number
force?: boolean;
filesystem: string;
filename?: string;
position?: number;
recursive?: boolean;
httpHeaders?: object;
content?: string | Buffer | null;
readChunkSize?: number;
}

@@ -22,3 +22,3 @@

azureKeyAuth: AzureSign;
knownFilesystems: String[];
knownFilesystems: string[];
agent: Agent;

@@ -33,9 +33,9 @@

executeRequest(httpOptions: HttpOptions, content: any, callback: Function): void {
executeRequest(httpOptions: HttpOptions, content: string | Buffer | null, callback: Function): void {
if(typeof httpOptions.headers === "undefined")
httpOptions.headers = {}
httpOptions.headers = {};
httpOptions.agent = this.agent;
httpOptions.headers.Authorization = this.azureKeyAuth.getAuthHeaderValue(httpOptions);
let request = httpsRequest(httpOptions, (response: http.IncomingMessage) => {
let returnedContent: string = "";
const request = httpsRequest(httpOptions, (response: http.IncomingMessage) => {
let returnedContent = "";
response.on("error", (error: Error) => {

@@ -61,3 +61,3 @@ callback(error);

if (options.force || this.knownFilesystems.indexOf(options.filesystem) < 0) {
let httpOptions: HttpOptions = {
const httpOptions: HttpOptions = {
method: "PUT",

@@ -72,4 +72,4 @@ protocol: "https:",

};
this.executeRequest(httpOptions, null, (error: Error, response: http.IncomingMessage, content: any) => {
if(!error && response.statusCode! < 400)
this.executeRequest(httpOptions, null, (error: Error, response: http.IncomingMessage, content: string | Buffer | null) => {
if(!error && response.statusCode && response.statusCode < 400)
this.knownFilesystems.push(options.filesystem);

@@ -85,12 +85,14 @@ callback(error, response, content);

createFile(options: StorageOptions, callback: Function): void {
let createFileOptions: HttpOptions = {
const createFileOptions: HttpOptions = {
method: "PUT",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename!, "?resource=file"),
path: "/".concat(options.filesystem, "/", options.filename || "", "?resource=file"),
headers: options.httpHeaders || {}
};
createFileOptions.headers!["x-ms-date"] = new Date().toUTCString();
createFileOptions.headers!["x-ms-version"] = "2019-02-02";
createFileOptions.headers!["Content-Length"] = 0;
if(createFileOptions.headers){
createFileOptions.headers["x-ms-date"] = new Date().toUTCString();
createFileOptions.headers["x-ms-version"] = "2019-02-02";
createFileOptions.headers["Content-Length"] = 0;
}
this.executeRequest(createFileOptions, null, callback);

@@ -100,26 +102,33 @@ }

writeContent(options: StorageOptions, callback: Function): void {
let writeFileOptions: HttpOptions = {
const writeFileOptions: HttpOptions = {
method: "PATCH",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename!, "?action=append&position=" , typeof options.position !== "undefined" ? options.position.toString() : "0"),
path: "/".concat(options.filesystem, "/", options.filename || "", "?action=append&position=" , typeof options.position !== "undefined" ? options.position.toString() : "0"),
headers: options.httpHeaders || {}
};
writeFileOptions.headers!["x-ms-date"] = new Date().toUTCString();
writeFileOptions.headers!["x-ms-version"] = "2019-02-02";
writeFileOptions.headers!["Content-Length"] = Buffer.byteLength(options.content);
this.executeRequest(writeFileOptions, options.content, callback);
if(writeFileOptions.headers && options.content){
writeFileOptions.headers["x-ms-date"] = new Date().toUTCString();
writeFileOptions.headers["x-ms-version"] = "2019-02-02";
writeFileOptions.headers["Content-Length"] = Buffer.byteLength(options.content);
}
if(options.content)
this.executeRequest(writeFileOptions, options.content, callback);
else
callback(new Error("No content provided"));
}
getPath(options: StorageOptions, callback: Function): void {
let pathOptions: HttpOptions = {
const pathOptions: HttpOptions = {
method: "HEAD",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename!),
path: "/".concat(options.filesystem, "/", options.filename || ""),
headers: options.httpHeaders || {}
};
pathOptions.headers!["x-ms-date"] = new Date().toUTCString();
pathOptions.headers!["x-ms-version"] = "2019-02-02";
pathOptions.headers!["Content-Length"] = 0;
if(pathOptions.headers){
pathOptions.headers["x-ms-date"] = new Date().toUTCString();
pathOptions.headers["x-ms-version"] = "2019-02-02";
pathOptions.headers["Content-Length"] = 0;
}
this.executeRequest(pathOptions, null, callback);

@@ -129,12 +138,16 @@ }

flushContent(options: StorageOptions, callback: Function): void {
let flushOptions: HttpOptions = {
if(!options.position)
options.position = 0;
const flushOptions: HttpOptions = {
method: "PATCH",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename!, "?action=flush&position=", options.position!.toString()),
path: "/".concat(options.filesystem, "/", options.filename || "", "?action=flush&position=", options.position.toString()),
headers: options.httpHeaders || {}
};
flushOptions.headers!["x-ms-date"] = new Date().toUTCString();
flushOptions.headers!["x-ms-version"] = "2019-02-02";
flushOptions.headers!["Content-Length"] = 0;
if(flushOptions.headers){
flushOptions.headers["x-ms-date"] = new Date().toUTCString();
flushOptions.headers["x-ms-version"] = "2019-02-02";
flushOptions.headers["Content-Length"] = 0;
}
this.executeRequest(flushOptions, null, callback);

@@ -146,12 +159,14 @@ }

options.recursive = false;
let deleteOptions: HttpOptions = {
const deleteOptions: HttpOptions = {
method: "DELETE",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename!, "?recursive=", options.recursive.toString()),
path: "/".concat(options.filesystem, "/", options.filename || "", "?recursive=", options.recursive.toString()),
headers: options.httpHeaders || {}
};
deleteOptions.headers!["x-ms-date"] = new Date().toUTCString();
deleteOptions.headers!["x-ms-version"] = "2019-02-02";
deleteOptions.headers!["Content-Length"] = 0;
if(deleteOptions.headers){
deleteOptions.headers["x-ms-date"] = new Date().toUTCString();
deleteOptions.headers["x-ms-version"] = "2019-02-02";
deleteOptions.headers["Content-Length"] = 0;
}
this.executeRequest(deleteOptions, null, callback);

@@ -167,5 +182,5 @@ }

stream.on("readable", () => {
let chunk = stream.read(options.readChunkSize);
const chunk = stream.read(options.readChunkSize);
if(chunk !== null){
let chunkLength = Buffer.byteLength(chunk);
const chunkLength = Buffer.byteLength(chunk);
currentLength += chunkLength;

@@ -176,3 +191,3 @@ options.content = chunk;

queueLength++;
this.writeContent(options, (error: Error, response: http.IncomingMessage, content: any) => {
this.writeContent(options, (error: Error, response: http.IncomingMessage, content: string | Buffer | null) => {
queueLength--;

@@ -202,14 +217,16 @@ if(error)

getStream(options: StorageOptions, callback: Function): void{
let getStreamOptions: HttpOptions = {
const getStreamOptions: HttpOptions = {
method: "GET",
protocol: "https:",
host: this.storageAccount.concat(".dfs.core.windows.net"),
path: "/".concat(options.filesystem, "/", options.filename!),
path: "/".concat(options.filesystem, "/", options.filename || ""),
headers: options.httpHeaders || {}
};
getStreamOptions.agent = this.agent;
getStreamOptions.headers!["x-ms-date"] = new Date().toUTCString();
getStreamOptions.headers!["x-ms-version"] = "2019-02-02";
getStreamOptions.headers!.Authorization = this.azureKeyAuth.getAuthHeaderValue(getStreamOptions);
let request = httpsRequest(getStreamOptions, (response: http.IncomingMessage) => {
if(getStreamOptions.headers){
getStreamOptions.headers["x-ms-date"] = new Date().toUTCString();
getStreamOptions.headers["x-ms-version"] = "2019-02-02";
getStreamOptions.headers.Authorization = this.azureKeyAuth.getAuthHeaderValue(getStreamOptions);
}
const request = httpsRequest(getStreamOptions, (response: http.IncomingMessage) => {
callback(null, response);

@@ -216,0 +233,0 @@ });

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