cloudinary
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -31,14 +31,17 @@ "use strict"; | ||
// | ||
// var cloudinary = require('../cloudinary').v2; | ||
// | ||
// var r; | ||
// var listAllResources = allCursors(cloudinary.api.resources, (result)=> result.resources); | ||
// | ||
// listAllResources((resources)=> {console.log("got " + resources.length + " resources");r = resources;}); | ||
// | ||
// var listAllTransformations= allCursors(cloudinary.api.transformations, (result)=> result.transformations); | ||
// listAllTransformations(function (transformations) { | ||
// console.log("got " + transformations.length + " transformations"); | ||
// r = transformations; | ||
// }); | ||
// | ||
var cloudinary = require('../cloudinary').v2; | ||
var r; | ||
var listAllResources = allCursors(cloudinary.api.resources, (result)=> result.resources); | ||
listAllResources((resources)=> {console.log("got " + resources.length + " resources");r = resources;}); | ||
var listAllTransformations= allCursors(cloudinary.api.transformations, (result)=> result.transformations); | ||
listAllTransformations(function (transformations) { | ||
console.log("got " + transformations.length + " transformations"); | ||
r = transformations; | ||
}); | ||
module.exports = allCursors; |
@@ -7,3 +7,3 @@ import cloudinary from '../cloudinary.v2'; | ||
export default function deleteAllResources(next_cursor) { | ||
export function deleteAllResources(next_cursor) { | ||
if(!nextCursor) { return []} | ||
@@ -10,0 +10,0 @@ cloudinary.api.delete_all_resources( { next_cursor, max_results}, (error, result)->{ |
1.7.1 / 2017-02-23 | ||
================== | ||
* Refactor `generate_auth_token` | ||
* Update utils documentation. | ||
* Add URL authorization token. | ||
* Rename token function. | ||
* Support nested keys in CLOUDINARY_URL | ||
* Allow tests to run concurrently | ||
1.7.0 / 2017-02-08 | ||
@@ -3,0 +13,0 @@ ================== |
// Generated by CoffeeScript 1.12.2 | ||
(function() { | ||
var _, cloudinary_config; | ||
var _, cloudinary_config, isNestedKey, putNestedValue; | ||
@@ -9,2 +9,37 @@ _ = require("lodash"); | ||
isNestedKey = function(key) { | ||
return key.match(/\w+\[\w+\]/); | ||
}; | ||
/*** | ||
* Assign a value to a nested object | ||
* @function putNestedValue | ||
* @param params the parent object - this argument will be modified! | ||
* @param key key in the form nested[innerkey] | ||
* @param value the value to assign | ||
* @return the modified params object | ||
*/ | ||
putNestedValue = function(params, key, value) { | ||
var chain, inner, innerKey, j, lastKey, len, outer; | ||
chain = key.split(/[\[\]]+/).filter((function(_this) { | ||
return function(i) { | ||
return i.length; | ||
}; | ||
})(this)); | ||
outer = params; | ||
lastKey = chain.pop(); | ||
for (j = 0, len = chain.length; j < len; j++) { | ||
innerKey = chain[j]; | ||
inner = outer[innerKey]; | ||
if (inner == null) { | ||
inner = {}; | ||
outer[innerKey] = inner; | ||
} | ||
outer = inner; | ||
} | ||
return outer[lastKey] = value; | ||
}; | ||
module.exports = function(new_config, new_value) { | ||
@@ -27,3 +62,7 @@ var cloudinary_url, k, ref, uri, v; | ||
v = ref[k]; | ||
cloudinary_config[k] = v; | ||
if (isNestedKey(k)) { | ||
putNestedValue(cloudinary_config, k, v); | ||
} else { | ||
cloudinary_config[k] = v; | ||
} | ||
} | ||
@@ -30,0 +69,0 @@ } |
// Generated by CoffeeScript 1.12.2 | ||
/** | ||
* Utilities | ||
* @module utils | ||
* @borrows module:auth_token as generate_auth_token | ||
*/ | ||
(function() { | ||
var CLOUDINARY_JS_CONFIG_PARAMS, CONDITIONAL_OPERATORS, CONDITIONAL_PARAMETERS, DEFAULT_RESPONSIVE_WIDTH_TRANSFORMATION, LAYER_KEYWORD_PARAMS, _, build_custom_headers, build_eager, config, crc32, crypto, finalize_resource_type, finalize_source, hashToQuery, join_pair, norm_range_value, number_pattern, offset_any_pattern, offset_any_pattern_re, process_if, process_layer, process_video_params, querystring, smart_escape, split_range, textStyle, unsigned_url_prefix, utf8_encode, utils, v1_adapter, v1_result_adapter, | ||
var CLOUDINARY_JS_CONFIG_PARAMS, CONDITIONAL_OPERATORS, CONDITIONAL_PARAMETERS, DEFAULT_RESPONSIVE_WIDTH_TRANSFORMATION, LAYER_KEYWORD_PARAMS, _, build_custom_headers, build_eager, config, crc32, crypto, finalize_resource_type, finalize_source, generate_token, hashToQuery, join_pair, norm_range_value, number_pattern, offset_any_pattern, offset_any_pattern_re, process_if, process_layer, process_video_params, querystring, smart_escape, split_range, textStyle, unsigned_url_prefix, url, utf8_encode, utils, v1_adapter, v1_result_adapter, | ||
slice = [].slice; | ||
@@ -14,6 +21,14 @@ | ||
url = require('url'); | ||
utils = exports; | ||
exports.generateAkamaiToken = require("./generateAkamaiToken"); | ||
generate_token = require("./auth_token"); | ||
exports.generate_auth_token = function(options) { | ||
var token_options; | ||
token_options = Object.assign({}, config().auth_token, options); | ||
return generate_token(token_options); | ||
}; | ||
exports.CF_SHARED_CDN = "d3jpl91pxevbkh.cloudfront.net"; | ||
@@ -524,3 +539,3 @@ | ||
exports.url = function(public_id, options) { | ||
var api_secret, cdn_subdomain, cloud_name, cname, format, original_source, prefix, preloaded, private_cdn, ref, ref1, resource_type, secure, secure_cdn_subdomain, secure_distribution, shasum, shorten, sign_url, signature, source_to_sign, ssl_detected, to_sign, transformation, type, url, url_suffix, use_root_path, version; | ||
var api_secret, auth_token, cdn_subdomain, cloud_name, cname, format, original_source, prefix, preloaded, private_cdn, ref, ref1, resource_type, resultUrl, secure, secure_cdn_subdomain, secure_distribution, shasum, shorten, sign_url, signature, source_to_sign, ssl_detected, to_sign, token, transformation, type, url_suffix, use_root_path, version; | ||
if (options == null) { | ||
@@ -558,2 +573,6 @@ options = {}; | ||
use_root_path = utils.option_consume(options, "use_root_path", config().use_root_path); | ||
auth_token = utils.option_consume(options, "auth_token"); | ||
if (auth_token !== false) { | ||
auth_token = exports.merge(config().auth_token, auth_token); | ||
} | ||
preloaded = /^(image|raw)\/([a-z0-9_]+)\/v(\d+)\/([^#]+)$/.exec(public_id); | ||
@@ -588,3 +607,3 @@ if (preloaded) { | ||
transformation = transformation.replace(/([^:])\/\//g, '$1/'); | ||
if (sign_url) { | ||
if (sign_url && _.isEmpty(auth_token)) { | ||
to_sign = [transformation, source_to_sign].filter(function(part) { | ||
@@ -599,6 +618,11 @@ return (part != null) && part !== ''; | ||
prefix = unsigned_url_prefix(public_id, cloud_name, private_cdn, cdn_subdomain, secure_cdn_subdomain, cname, secure, secure_distribution); | ||
url = [prefix, resource_type, type, signature, transformation, version, public_id].filter(function(part) { | ||
resultUrl = [prefix, resource_type, type, signature, transformation, version, public_id].filter(function(part) { | ||
return (part != null) && part !== ''; | ||
}).join('/'); | ||
return url; | ||
if (sign_url && !_.isEmpty(auth_token)) { | ||
auth_token.url = url.parse(resultUrl).path; | ||
token = generate_token(auth_token); | ||
resultUrl += "?" + token; | ||
} | ||
return resultUrl; | ||
}; | ||
@@ -944,25 +968,25 @@ | ||
* @param options [Hash] | ||
* @option options [String|Symbol] :resource_type The resource type of files to include in the archive. Must be one of :image | :video | :raw | ||
* @option options [String|Symbol] :type (:upload) The specific file type of resources: :upload|:private|:authenticated | ||
* @option options [String|Symbol|Array] :tags (nil) list of tags to include in the archive | ||
* @option options [String|Array<String>] :public_ids (nil) list of public_ids to include in the archive | ||
* @option options [String|Array<String>] :prefixes (nil) Optional list of prefixes of public IDs (e.g., folders). | ||
* @option options [String|Array<String>] :transformations Optional list of transformations. | ||
* @param {string} [options.resource_type="image"] The resource type of files to include in the archive. Must be one of :image | :video | :raw | ||
* @param {string} [options.type="upload"] The specific file type of resources: :upload|:private|:authenticated | ||
* @param {string|Array} [options.tags] list of tags to include in the archive | ||
* @param {string|Array<string>} [options.public_ids] list of public_ids to include in the archive | ||
* @param {string|Array<string>} [options.prefixes] list of prefixes of public IDs (e.g., folders). | ||
* @param {string|Array<string>} [options.transformations] list of transformations. | ||
* The derived images of the given transformations are included in the archive. Using the string representation of | ||
* multiple chained transformations as we use for the 'eager' upload parameter. | ||
* @option options [String|Symbol] :mode (:create) return the generated archive file or to store it as a raw resource and | ||
* @param {string} [options.mode="create"] return the generated archive file or to store it as a raw resource and | ||
* return a JSON with URLs for accessing the archive. Possible values: :download, :create | ||
* @option options [String|Symbol] :target_format (:zip) | ||
* @option options [String] :target_public_id Optional public ID of the generated raw resource. | ||
* @param {string} [options.target_format="zip"] | ||
* @param {string} [options.target_public_id] public ID of the generated raw resource. | ||
* Relevant only for the create mode. If not specified, random public ID is generated. | ||
* @option options [boolean] :flatten_folders (false) If true, flatten public IDs with folders to be in the root of the archive. | ||
* @param {boolean} [options.flatten_folders=false] If true, flatten public IDs with folders to be in the root of the archive. | ||
* Add numeric counter to the file name in case of a name conflict. | ||
* @option options [boolean] :flatten_transformations (false) If true, and multiple transformations are given, | ||
* @param {boolean} [options.flatten_transformations=false] If true, and multiple transformations are given, | ||
* flatten the folder structure of derived images and store the transformation details on the file name instead. | ||
* @option options [boolean] :use_original_filename Use the original file name of included images (if available) instead of the public ID. | ||
* @option options [boolean] :async (false) If true, return immediately and perform the archive creation in the background. | ||
* @param {boolean} [options.use_original_filename] Use the original file name of included images (if available) instead of the public ID. | ||
* @param {boolean} [options.async=false] If true, return immediately and perform the archive creation in the background. | ||
* Relevant only for the create mode. | ||
* @option options [String] :notification_url Optional URL to send an HTTP post request (webhook) when the archive creation is completed. | ||
* @option options [String|Array<String] :target_tags Optional array. Allows assigning one or more tag to the generated archive file (for later housekeeping via the admin API). | ||
* @option options [String] :keep_derived (false) keep the derived images used for generating the archive | ||
* @param {string} [options.notification_url] URL to send an HTTP post request (webhook) when the archive creation is completed. | ||
* @param {string|Array<string} [options.target_tags=] array. Allows assigning one or more tag to the generated archive file (for later housekeeping via the admin API). | ||
* @param {string} [options.keep_derived=false] keep the derived images used for generating the archive | ||
* @return [String] archive url | ||
@@ -969,0 +993,0 @@ */ |
@@ -5,3 +5,3 @@ { | ||
"description": "Cloudinary NPM for node.js integration", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"homepage": "http://cloudinary.com", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1761219
103
10
8
1
9070