fast-azure-storage
Advanced tools
Comparing version 3.1.6 to 4.0.0
@@ -1,6 +0,6 @@ | ||
'use strict'; | ||
import https from "https"; | ||
import debugModule from "debug"; | ||
import util from "util"; | ||
var https = require('https'); | ||
var debug = require('debug')('azure:agent'); | ||
var util = require('util'); | ||
const debug = debugModule("azure:agent"); | ||
@@ -49,7 +49,7 @@ /* | ||
*/ | ||
var Agent = function(options) { | ||
var Agent = function (options) { | ||
https.Agent.call(this, options); | ||
// Listen for free sockets | ||
this.on('free', function(socket) { | ||
this.on('free', function (socket) { | ||
// Ignore errors from free sockets | ||
@@ -95,20 +95,10 @@ socket.on('error', freeSocketErrorHandler); | ||
// Don't do anything for node 0.10 | ||
if (/^0\.10/.test(process.versions.node)) { | ||
Agent = https.Agent; | ||
} | ||
// Some relatively sane defaults, 100 is a bit high depending on hardware | ||
Agent.globalAgent = new Agent({ | ||
keepAlive: true, | ||
maxSockets: 100, | ||
maxFreeSockets: 100, | ||
}); | ||
// Create global agent | ||
if (/^0\.10/.test(process.versions.node)) { | ||
Agent.globalAgent = https.globalAgent; | ||
} else { | ||
// Some relatively sane defaults, 100 is a bit high depending on hardware | ||
Agent.globalAgent = new Agent({ | ||
keepAlive: true, | ||
maxSockets: 100, | ||
maxFreeSockets: 100 | ||
}); | ||
} | ||
// Export Agent | ||
module.exports = Agent; | ||
export default Agent; | ||
export { Agent }; |
@@ -1,4 +0,5 @@ | ||
var querystring = require('querystring'); | ||
var debug = require('debug')('azure:authorization'); | ||
var utils = require('./utils'); | ||
import querystring from 'querystring'; | ||
import debugFactory from 'debug'; | ||
import * as utils from './utils.js'; | ||
const debug = debugFactory('azure:authorization'); | ||
@@ -10,3 +11,3 @@ /* | ||
*/ | ||
var authorizeWithRefreshSAS = function authorizeWithRefreshSAS(method, path, query, headers) { | ||
export const authorizeWithRefreshSAS = function authorizeWithRefreshSAS(method, path, query, headers) { | ||
var self = this; | ||
@@ -63,4 +64,2 @@ // Check if we should refresh SAS | ||
exports.authorizeWithRefreshSAS = authorizeWithRefreshSAS; | ||
/* | ||
@@ -71,3 +70,3 @@ * Authorize the request with a shared-access-signature that is given with | ||
*/ | ||
function authorizeWithSAS(method, path, query, headers) { | ||
export function authorizeWithSAS(method, path, query, headers) { | ||
// Serialize query-string | ||
@@ -89,4 +88,2 @@ var qs = querystring.stringify(query); | ||
exports.authorizeWithSAS = authorizeWithSAS; | ||
/* | ||
@@ -100,3 +97,3 @@ * Authorize the request with shared key | ||
*/ | ||
var authorizeWithSharedKey = function (service, queryParamsSupported) { | ||
export const authorizeWithSharedKey = function (service, queryParamsSupported) { | ||
var self = this; | ||
@@ -190,3 +187,1 @@ return function(method, path, query, headers) { | ||
} | ||
exports.authorizeWithSharedKey = authorizeWithSharedKey; |
@@ -10,20 +10,8 @@ 'use strict'; | ||
/* Export module from `path` under `property` */ | ||
var lazyExportModule = function(property, path) { | ||
var module = undefined; | ||
Object.defineProperty(exports, property, { | ||
enumerable: true, | ||
get: function() { | ||
if (module === undefined) { | ||
module = require(path); | ||
} | ||
return module; | ||
} | ||
}); | ||
}; | ||
import { Table } from './table.js'; | ||
import { Blob } from './blob.js'; | ||
import { Queue } from './queue.js'; | ||
import { Agent } from './agent.js'; | ||
// Lazy load all sub-modules, so don't load anything we don't strictly need. | ||
lazyExportModule('Queue', './queue'); | ||
lazyExportModule('Blob', './blob'); | ||
lazyExportModule('Table', './table'); | ||
lazyExportModule('Agent', './agent'); | ||
export { Table, Blob, Queue, Agent }; | ||
export default { Table, Blob, Queue, Agent }; |
'use strict'; | ||
var assert = require('assert'); | ||
var debug = require('debug')('azure:queue'); | ||
var querystring = require('querystring'); | ||
var crypto = require('crypto'); | ||
var events = require('events'); | ||
var util = require('util'); | ||
var agent = require('./agent'); | ||
var utils = require('./utils'); | ||
var xml = require('./xml-parser'); | ||
var auth = require('./authorization'); | ||
import assert from 'assert'; | ||
import debugFactory from 'debug'; | ||
import querystring from 'querystring'; | ||
import crypto from 'crypto'; | ||
import events from 'events'; | ||
import util from 'util'; | ||
import * as agent from './agent.js'; | ||
import * as utils from './utils.js'; | ||
import * as xml from './xml-parser.js'; | ||
import * as auth from './authorization.js'; | ||
const debug = debugFactory('azure:queue'); | ||
/* | ||
@@ -107,3 +109,3 @@ * Azure storage service version | ||
*/ | ||
function Queue(options) { | ||
export function Queue(options) { | ||
// Initialize EventEmitter parent class | ||
@@ -170,3 +172,3 @@ events.EventEmitter.call(this); | ||
// Export Queue | ||
module.exports = Queue; | ||
export default Queue; | ||
@@ -173,0 +175,0 @@ // Subclass EventEmitter |
'use strict'; | ||
var assert = require('assert'); | ||
var debug = require('debug')('azure:table'); | ||
var querystring = require('querystring'); | ||
var crypto = require('crypto'); | ||
var events = require('events'); | ||
var util = require('util'); | ||
var agent = require('./agent'); | ||
var utils = require('./utils'); | ||
var auth = require('./authorization'); | ||
import assert from 'assert'; | ||
import debugFactory from 'debug'; | ||
const debug = debugFactory('azure:table'); | ||
import querystring from 'querystring'; | ||
import events from 'events'; | ||
import util from 'util'; | ||
import agent from './agent.js'; | ||
import * as utils from './utils.js'; | ||
import * as auth from './authorization.js'; | ||
@@ -136,3 +136,3 @@ /* Transient error codes (we'll retry request when encountering these codes */ | ||
*/ | ||
function Table(options) { | ||
export function Table(options) { | ||
// Initialize EventEmitter parent class | ||
@@ -210,3 +210,3 @@ events.EventEmitter.call(this); | ||
// Export Table | ||
module.exports = Table; | ||
export default Table; | ||
@@ -213,0 +213,0 @@ /** |
'use strict'; | ||
var https = require('https'); | ||
var crypto = require('crypto'); | ||
var querystring = require('querystring'); | ||
var debug = require('debug')('azure:utils'); | ||
var assert = require('assert'); | ||
import https from 'https'; | ||
import crypto from 'crypto'; | ||
import querystring from 'querystring'; | ||
import debugFactory from 'debug'; | ||
import assert from 'assert'; | ||
const debug = debugFactory('azure:utils'); | ||
/* | ||
@@ -15,3 +17,3 @@ * Return promise to sleep for a `delay` ms | ||
*/ | ||
var sleep = function sleep(delay) { | ||
export const sleep = function sleep(delay) { | ||
return new Promise(function(resolve) { | ||
@@ -22,5 +24,2 @@ setTimeout(resolve, delay); | ||
// Export sleep | ||
exports.sleep = sleep; | ||
/* | ||
@@ -30,3 +29,3 @@ * Transient error codes from node https module | ||
*/ | ||
var TRANSIENT_HTTP_ERROR_CODES = [ | ||
export const TRANSIENT_HTTP_ERROR_CODES = [ | ||
'ETIMEDOUT', | ||
@@ -42,5 +41,2 @@ 'ECONNRESET', | ||
// Export TRANSIENT_HTTP_ERROR_CODES | ||
exports.TRANSIENT_HTTP_ERROR_CODES = TRANSIENT_HTTP_ERROR_CODES; | ||
/* | ||
@@ -82,3 +78,3 @@ * Retry the asynchronous function `f` until we have exhausted all `retries`, | ||
*/ | ||
var retry = function retry(f, options) { | ||
export const retry = function retry(f, options) { | ||
var retry = 0; | ||
@@ -123,5 +119,2 @@ function attempt() { | ||
// Export retry | ||
exports.retry = retry; | ||
/* | ||
@@ -137,3 +130,3 @@ * Auxiliary function to create `https.request` with `options` send `data` as | ||
*/ | ||
var request = function request(options, data, timeout) { | ||
export const request = function request(options, data, timeout) { | ||
return new Promise(function(resolve, reject) { | ||
@@ -209,5 +202,2 @@ // Create https request | ||
// Export request | ||
exports.request = request; | ||
/* | ||
@@ -219,9 +209,6 @@ * Convert Date object to JSON format without milliseconds | ||
*/ | ||
var dateToISOWithoutMS = function dateToISOWithoutMS(date) { | ||
export const dateToISOWithoutMS = function dateToISOWithoutMS(date) { | ||
return date.toJSON().replace(/\.\d+(?=Z$)/, ''); | ||
}; | ||
// Export dateToISOWithoutMS | ||
exports.dateToISOWithoutMS = dateToISOWithoutMS; | ||
/* | ||
@@ -234,3 +221,3 @@ * Parse JSON exactly like `JSON.parse(data)`, but wrap the error so that the | ||
*/ | ||
var parseJSON = function parseJSON(data) { | ||
export const parseJSON = function parseJSON(data) { | ||
try { | ||
@@ -245,5 +232,2 @@ return JSON.parse(data); | ||
// Export parseJSON | ||
exports.parseJSON = parseJSON; | ||
/* | ||
@@ -255,3 +239,3 @@ * Extracts the metadata from HTTP response header | ||
*/ | ||
var extractMetadataFromHeaders = function extractMetadataFromHeaders(response) { | ||
export const extractMetadataFromHeaders = function extractMetadataFromHeaders(response) { | ||
var metadata = {}; | ||
@@ -279,4 +263,2 @@ /* | ||
exports.extractMetadataFromHeaders = extractMetadataFromHeaders; | ||
/* | ||
@@ -300,3 +282,3 @@ * Checks if the given value is a valid GUID | ||
*/ | ||
var isValidGUID = function isValidGUID(value) { | ||
export const isValidGUID = function isValidGUID(value) { | ||
// remove all embedded whitespaces | ||
@@ -321,4 +303,2 @@ value = value.replace(/\s/g, ''); | ||
exports.isValidGUID = isValidGUID; | ||
/* | ||
@@ -337,3 +317,3 @@ * @param {object} headers - request headers | ||
*/ | ||
var setConditionalHeaders = function setConditionalHeaders(headers, conditionalHeaders, onlyDateSupport) { | ||
export const setConditionalHeaders = function setConditionalHeaders(headers, conditionalHeaders, onlyDateSupport) { | ||
if (conditionalHeaders) { | ||
@@ -357,4 +337,2 @@ if (conditionalHeaders.ifModifiedSince){ | ||
exports.setConditionalHeaders = setConditionalHeaders; | ||
/* | ||
@@ -367,3 +345,3 @@ * Computes a signature for the specified string using the HMAC-SHA256 algorithm. | ||
*/ | ||
var hmacSha256 = function hmacSha256(accessKey, stringToSign) { | ||
export const hmacSha256 = function hmacSha256(accessKey, stringToSign) { | ||
return crypto | ||
@@ -375,8 +353,6 @@ .createHmac('sha256', accessKey) | ||
exports.hmacSha256 = hmacSha256; | ||
/* | ||
* Calculate MD5sum for the content | ||
*/ | ||
var md5 = function md5(content) { | ||
export const md5 = function md5(content) { | ||
return crypto | ||
@@ -387,3 +363,1 @@ .createHash('md5') | ||
} | ||
exports.md5 = md5; |
@@ -1,2 +0,2 @@ | ||
const xml2js = require('xml2js'); | ||
import xml2js from 'xml2js'; | ||
@@ -31,3 +31,3 @@ // xml2js uses a callback calling pattern for a sync operation. Ok.. happily, | ||
/* Parse queue error, return: {message, code, detail} */ | ||
exports.parseError = function parseError(res) { | ||
export const parseError = function parseError(res) { | ||
// Parse payload for error message and code | ||
@@ -66,3 +66,3 @@ const result = { | ||
/* Parse list of queues and return object for listQueues */ | ||
exports.queueParseListQueues = function queueParseListQueues(res) { | ||
export const queueParseListQueues = function queueParseListQueues(res) { | ||
// Get results | ||
@@ -99,3 +99,3 @@ const xml = parseString(res.payload); | ||
/* Parse list of peeked messages */ | ||
exports.queueParsePeekMessages = function queueParsePeekMessages(res) { | ||
export const queueParsePeekMessages = function queueParsePeekMessages(res) { | ||
const xml = parseString(res.payload); | ||
@@ -115,3 +115,3 @@ const msgs = array(getValue(xml, 'QueueMessagesList', 'QueueMessage')); | ||
/* Parse list of messages */ | ||
exports.queueParseGetMessages = function queueParseGetMessages(res) { | ||
export const queueParseGetMessages = function queueParseGetMessages(res) { | ||
const xml = parseString(res.payload); | ||
@@ -133,3 +133,3 @@ const msgs = array(getValue(xml, 'QueueMessagesList', 'QueueMessage')); | ||
/* Parse list of containers and return object for listContainers */ | ||
exports.blobParseListContainers = function blobParseListContainers(res) { | ||
export const blobParseListContainers = function blobParseListContainers(res) { | ||
// Get results | ||
@@ -161,7 +161,7 @@ const xml = parseString(res.payload); | ||
properties.leaseState = getValue(props, 'LeaseState', 0); | ||
leaseDuration = getValue(props, 'LeaseDuration', 0); | ||
let leaseDuration = getValue(props, 'LeaseDuration', 0); | ||
if (leaseDuration) { | ||
properties.leaseDuration = leaseDuration; | ||
} | ||
publicAccessLevel = getValue(props, 'PublicAccess', 0); | ||
let publicAccessLevel = getValue(props, 'PublicAccess', 0); | ||
if (publicAccessLevel) { | ||
@@ -203,3 +203,3 @@ properties.publicAccessLevel = publicAccessLevel; | ||
/* Parse container ACL and return object to getContainerACL */ | ||
exports.blobParseContainerACL = function blobParseContainerACL(response) { | ||
export const blobParseContainerACL = function blobParseContainerACL(response) { | ||
const xml = parseString(response.payload); | ||
@@ -249,3 +249,3 @@ const signedIdentifiers = array(getValue(xml, 'SignedIdentifiers', 'SignedIdentifier')); | ||
/* Parse list of blobs and return object for listBlobs */ | ||
exports.blobParseListBlobs = function blobParseListBlobs(response) { | ||
export const blobParseListBlobs = function blobParseListBlobs(response) { | ||
const xml = parseString(response.payload); | ||
@@ -336,3 +336,3 @@ const blobs = array(getValue(xml, 'EnumerationResults', 'Blobs', 0, 'Blob')); | ||
/* Parse list of blocks and return object for getBlockList */ | ||
exports.blobParseListBlock = function blobParseListBlock(response) { | ||
export const blobParseListBlock = function blobParseListBlock(response) { | ||
const xml = parseString(response.payload); | ||
@@ -362,3 +362,3 @@ const result = {committedBlocks: [], uncommittedBlocks: []}; | ||
/* Parse the blob service properties and return object for getServiceProperties */ | ||
exports.blobParseServiceProperties = function blobParseServiceProperties(response) { | ||
export const blobParseServiceProperties = function blobParseServiceProperties(response) { | ||
const xml = parseString(response.payload); | ||
@@ -365,0 +365,0 @@ const result = {}; |
{ | ||
"name": "fast-azure-storage", | ||
"version": "3.1.6", | ||
"version": "4.0.0", | ||
"author": "Jonas Finnemann Jensen <jopsen@gmail.com>, Elena Solomon <elenasolomon28@gmail.com>", | ||
@@ -8,2 +8,3 @@ "description": "Fast client library for azure storage services", | ||
"main": "lib/index.js", | ||
"type": "module", | ||
"scripts": { | ||
@@ -22,3 +23,3 @@ "test": "mocha test/*.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=20" | ||
}, | ||
@@ -38,3 +39,3 @@ "dependencies": { | ||
"mocha": "10.2.0", | ||
"taskcluster-client": "52.0.0", | ||
"taskcluster-client": "68.0.0", | ||
"yuidoc-lucid-theme": "jonasfj/yuidoc-lucid-theme", | ||
@@ -41,0 +42,0 @@ "yuidocjs": "0.10.2" |
@@ -26,3 +26,3 @@ Fast Azure Storage Client for Node.js | ||
// Load fast-azure-storage client | ||
var azure = require('fast-azure-storage'); | ||
import * as azure from 'fast-azure-storage'; | ||
@@ -97,3 +97,3 @@ // Common options using shared key authentication | ||
// Load fast-azure-storage client | ||
var azure = require('fast-azure-storage'); | ||
import azure from 'fast-azure-storage'; | ||
@@ -142,3 +142,3 @@ var table = new azure.Table({ | ||
// Load fast-azure-storage client | ||
var azure = require('fast-azure-storage'); | ||
import azure from 'fast-azure-storage'; | ||
@@ -189,3 +189,3 @@ var queue = new azure.Queue({ | ||
// Load fast-azure-storage client | ||
var azure = require('fast-azure-storage'); | ||
import azure from 'fast-azure-storage'; | ||
@@ -201,3 +201,3 @@ var blob = new azure.Blob({ | ||
return blob.putBlob('mycontainer', 'myblob', { | ||
type: 'BlockBlob', // Type of the blob | ||
type: 'BlockBlob', // Type of the blob | ||
}, blobContent); | ||
@@ -204,0 +204,0 @@ }); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
0
Yes
230151
4778