mailchimp-api-v3
Advanced tools
+7
-3
@@ -17,6 +17,6 @@ "use strict"; | ||
| function Mailchimp (api_key) { | ||
| function Mailchimp (api_key, dc = null) { | ||
| var api_key_regex = /.+\-.+/ | ||
| if (!api_key_regex.test(api_key)) { | ||
| if (!api_key_regex.test(api_key) && dc === null) { | ||
| throw new Error('missing or invalid api key: ' + api_key) | ||
@@ -27,3 +27,7 @@ } | ||
| this.__api_key = api_key; | ||
| this.__base_url = "https://"+ this.__api_key.split('-')[1] + ".api.mailchimp.com/3.0" | ||
| if(dc !== null){ | ||
| this.__base_url = "https://"+ dc + ".api.mailchimp.com/3.0" | ||
| }else{ | ||
| this.__base_url = "https://"+ this.__api_key.split('-')[1] + ".api.mailchimp.com/3.0" | ||
| } | ||
| } | ||
@@ -30,0 +34,0 @@ |
+1
-1
| { | ||
| "name": "mailchimp-api-v3", | ||
| "version": "1.14.0", | ||
| "version": "1.15.0", | ||
| "description": "Mailchimp wrapper for v3 of the mailchimp api, with transparant handling of batch operations", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+100
-0
| var api_key = process.env.MAILCHIMP_TEST_API_KEY | ||
| var oauth_token = process.env.MAILCHIMP_TEST_OAUTH_TOKEN | ||
| var assert = require('assert') | ||
| var dc = process.env.DC | ||
@@ -28,2 +30,6 @@ var Mailchimp = require('../index'); | ||
| }) | ||
| it('should work for correctly formated oauth token with a DC', function () { | ||
| var mailchimp = new Mailchimp('token', 'us19') | ||
| }) | ||
| }) | ||
@@ -125,2 +131,96 @@ | ||
| describe('basic mailchimp api methods with oauth token and dc', function () { | ||
| var mailchimp = new Mailchimp(oauth_token, dc); | ||
| it('should handle simple get', function (done) { | ||
| mailchimp.get({ | ||
| path : '/lists', | ||
| }, function (err, result) { | ||
| assert.equal(err, null); | ||
| assert.ok(result) | ||
| assert.ok(result.lists) | ||
| done() | ||
| }) | ||
| }) | ||
| it('should handle simple get with promise', function (done) { | ||
| mailchimp.get({ | ||
| path : '/lists', | ||
| }).then(function (result) { | ||
| assert.ok(result) | ||
| assert.ok(result.lists) | ||
| done() | ||
| }).catch(function (err) { | ||
| done(new Error(err)); | ||
| }) | ||
| }) | ||
| it('should handle wrong path', function (done) { | ||
| mailchimp.get({ | ||
| path : '/wrong', | ||
| }, function (err, result) { | ||
| assert.equal(err.status, 404); | ||
| done() | ||
| }) | ||
| }) | ||
| it('should handle wrong path with promise', function (done) { | ||
| mailchimp.get({ | ||
| path : '/wrong', | ||
| }).then(function (result) { | ||
| //Error | ||
| done(result) | ||
| }).catch(function (err) { | ||
| assert.equal(err.status, 404); | ||
| done() | ||
| }) | ||
| }) | ||
| it('should handle get with just a path', function (done) { | ||
| mailchimp.get('/lists', function (err, result) { | ||
| assert.equal(err, null); | ||
| assert.ok(result) | ||
| assert.ok(result.lists) | ||
| done() | ||
| }) | ||
| }) | ||
| it('should handle get with just a path with promise', function (done) { | ||
| mailchimp.get('/lists') | ||
| .then(function (result) { | ||
| assert.ok(result); | ||
| assert.ok(result.lists); | ||
| done(); | ||
| }) | ||
| .catch(function (err) { | ||
| done(new Error(err)) | ||
| }) | ||
| }) | ||
| it('should handle get with a path and query', function (done) { | ||
| mailchimp.get('/lists', {offset : 1}, function (err, result) { | ||
| assert.equal(err, null); | ||
| assert.ok(result) | ||
| assert.ok(result.lists) | ||
| done() | ||
| }) | ||
| }) | ||
| it('should handle get with a path and query with promise', function (done) { | ||
| mailchimp.get('/lists', {offset : 1}) | ||
| .then(function (result) { | ||
| assert.ok(result) | ||
| assert.ok(result.lists) | ||
| done() | ||
| }) | ||
| .catch(function (err) { | ||
| done(new Error(err)) | ||
| }) | ||
| }) | ||
| }) | ||
| describe('batch mailchimp api methods', function () { | ||
@@ -127,0 +227,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
33392
8.15%1023
9.65%5
66.67%