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

mailchimp-buddy

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mailchimp-buddy - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

4

lib/index.d.ts

@@ -16,6 +16,6 @@ import { AxiosResponse } from 'axios';

}>>;
get(email: string): Promise<AxiosResponse<Member>>;
get(emailOrMd5: string): Promise<AxiosResponse<Member>>;
setStatus(email: string, status: Status): Promise<AxiosResponse<any>>;
setStatusIfNew(email: string, status: Status): Promise<AxiosResponse<any>>;
remove(email: string): Promise<AxiosResponse<any>>;
remove(emailOrMd5: string): Promise<AxiosResponse<any>>;
};

@@ -24,5 +24,5 @@ "use strict";

},
get(email) {
get(emailOrMd5) {
return __awaiter(this, void 0, void 0, function* () {
return yield axios_1.default.get(`${baseUrl}/${md5(email)}`, { headers });
return yield axios_1.default.get(`${baseUrl}/${ensureMd5(emailOrMd5)}`, { headers });
});

@@ -38,9 +38,9 @@ },

return __awaiter(this, void 0, void 0, function* () {
const data = { email_address: email, status_if_new: status };
const data = { email_address: email.toLowerCase(), status_if_new: status };
return yield axios_1.default.put(`${baseUrl}/${md5(email)}`, data, { headers });
});
},
remove(email) {
remove(emailOrMd5) {
return __awaiter(this, void 0, void 0, function* () {
return yield axios_1.default.delete(`${baseUrl}/${md5(email)}`, { headers });
return yield axios_1.default.delete(`${baseUrl}/${ensureMd5(emailOrMd5)}`, { headers });
});

@@ -51,4 +51,11 @@ },

exports.default = default_1;
function ensureMd5(emailOrMd5) {
return isEmail(emailOrMd5) ? md5(emailOrMd5) : emailOrMd5;
}
function isEmail(emailOrMd5) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(emailOrMd5).toLowerCase());
}
function md5(email) {
return crypto.createHash('md5').update(email.toLowerCase()).digest('hex');
}
{
"name": "mailchimp-buddy",
"version": "0.3.2",
"version": "0.3.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index",

@@ -28,4 +28,4 @@ import * as crypto from 'crypto';

async get(email: string): Promise<AxiosResponse<Member>> {
return await axios.get<Member>(`${baseUrl}/${md5(email)}`, { headers });
async get(emailOrMd5: string): Promise<AxiosResponse<Member>> {
return await axios.get<Member>(`${baseUrl}/${ensureMd5(emailOrMd5)}`, { headers });
},

@@ -39,8 +39,8 @@

async setStatusIfNew(email: string, status: Status) {
const data = { email_address: email, status_if_new: status };
const data = { email_address: email.toLowerCase(), status_if_new: status };
return await axios.put(`${baseUrl}/${md5(email)}`, data, { headers });
},
async remove(email: string) {
return await axios.delete(`${baseUrl}/${md5(email)}`, { headers });
async remove(emailOrMd5: string) {
return await axios.delete(`${baseUrl}/${ensureMd5(emailOrMd5)}`, { headers });
},

@@ -50,4 +50,13 @@ }

function ensureMd5(emailOrMd5: string): string {
return isEmail(emailOrMd5) ? md5(emailOrMd5) : emailOrMd5;
}
function isEmail(emailOrMd5: string): boolean {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(emailOrMd5).toLowerCase());
}
function md5(email: string) {
return crypto.createHash('md5').update(email.toLowerCase()).digest('hex');
}
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