New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@alligatorjazz/sg-edge

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alligatorjazz/sg-edge - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

6

dist/index.d.ts

@@ -23,2 +23,8 @@ /// <reference types="node" />

export declare function addContact(contact: SendgridContact): Promise<string>;
export declare function getContactsByEmail(...emails: string[]): Promise<{
[email: string]: {
contact: SendgridContact;
};
}>;
export declare function checkIfUnsubscribed(email: string): Promise<boolean>;
export {};

77

dist/index.js

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.addContact = exports.sendEmails = exports.fetchAllContacts = exports.fetchJSONContactsExport = exports.createJSONContactsExport = exports.loadSendgridAPI = void 0;
exports.checkIfUnsubscribed = exports.getContactsByEmail = exports.addContact = exports.sendEmails = exports.fetchAllContacts = exports.fetchJSONContactsExport = exports.createJSONContactsExport = exports.loadSendgridAPI = void 0;
const mail_1 = __importDefault(require("@sendgrid/mail"));

@@ -158,15 +158,64 @@ const client_1 = __importDefault(require("@sendgrid/client"));

// }
// export async function getContactsByEmail(...emails: string[]) {
// const request: ClientRequest = {
// url: "/v3/marketing/contacts/search/emails",
// method: "POST",
// body: { emails }
// };
// const result = await sgClient.request(request);
// if (result[0].statusCode == 200 && "result" in result[0].body) {
// return result[0].body["result"] as SendgridContact & { id: string };
// } else {
// throw new Error("Could not get contacts by email. Response: " + JSON.stringify(result, null, 4));
// }
// }
function getContactsByEmail(...emails) {
return __awaiter(this, void 0, void 0, function* () {
const request = {
url: "/v3/marketing/contacts/search/emails",
method: "POST",
body: { emails }
};
const result = yield client_1.default.request(request);
if (result[0].statusCode == 200 && "result" in result[0].body) {
return result[0].body["result"];
}
else {
throw new Error("Could not get contacts by email. Response: " + JSON.stringify(result, null, 4));
}
});
}
exports.getContactsByEmail = getContactsByEmail;
function checkIfUnsubscribed(email) {
return __awaiter(this, void 0, void 0, function* () {
// TODO: add second request for global unsubscribe endpoint
// check for global unsubscribe
const checkGlobalUnsubscribe = () => __awaiter(this, void 0, void 0, function* () {
const request = {
url: `/v3/asm/suppressions/global/${email}`,
method: "GET"
};
const [response] = yield client_1.default.request(request);
// console.log(JSON.stringify(response.body, null, 4));
if (response.statusCode !== 200) {
console.error(`Unable to retrieve global unsubscribe info for ${email} - assuming unsubscribed`);
return true;
}
if ("recipient_email" in response.body) {
return true;
}
return false;
});
const checkGroupUnsubscribe = () => __awaiter(this, void 0, void 0, function* () {
const request = {
url: `/v3/asm/suppressions/${email}`,
method: "GET"
};
const [response] = yield client_1.default.request(request);
// console.log(JSON.stringify(response.body, null, 4));
if (response.statusCode !== 200) {
console.error(`Unable to retrieve unsubscribe info for ${email} - assuming unsubscribed`);
return true;
}
if (response.body.suppressions.filter(suppression => suppression.suppressed).length > 0) {
return true;
}
return false;
});
if ((yield checkGlobalUnsubscribe())) {
return true;
}
else {
return yield checkGroupUnsubscribe();
}
});
}
exports.checkIfUnsubscribed = checkIfUnsubscribed;
// export async function checkJobStatus(jobId: string) {

@@ -173,0 +222,0 @@ // const request: ClientRequest = {

5

package.json
{
"name": "@alligatorjazz/sg-edge",
"version": "1.2.0",
"version": "1.2.1",
"description": "Utility functions for using the Sendgrid API on edge / cloud functions.",

@@ -8,3 +8,4 @@ "main": "dist/index.js",

"test": "vitest",
"build": "tsc"
"build": "tsc",
"publish": "npm run build && npm publish"
},

@@ -11,0 +12,0 @@ "author": "Falchion Studios",

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