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

@plunk/node

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plunk/node - npm Package Compare versions

Comparing version 1.1.1 to 1.1.3

2

dist/lib/Plunk.d.ts

@@ -5,3 +5,3 @@ import { PublishParams } from "../types/events";

private readonly key;
private readonly client;
private fetch;
constructor(key: string);

@@ -8,0 +8,0 @@ /**

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

const tslib_1 = require("tslib");
const axios_1 = tslib_1.__importDefault(require("axios"));
const request_1 = require("../utils/request");
const native_fetch_1 = require("native-fetch");
const NotFound_1 = require("../errors/NotFound");
const TokenError_1 = require("../errors/TokenError");
class Plunk {

@@ -21,6 +22,6 @@ constructor(key) {

track: (event) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return yield (0, request_1.request)(this.client, {
return yield this.fetch({
method: "POST",
url: "/track",
body: Object.assign({}, event),
url: "track",
json: Object.assign({}, event),
});

@@ -41,6 +42,6 @@ }),

send: (body) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return yield (0, request_1.request)(this.client, {
return yield this.fetch({
method: "POST",
url: "/send",
body: Object.assign({}, body),
url: "send",
json: Object.assign({}, body),
});

@@ -50,7 +51,20 @@ }),

this.key = key;
this.client = axios_1.default.create({
baseURL: "https://api.useplunk.com/v1",
headers: {
Authorization: `Bearer ${this.key}`,
},
}
fetch(_a) {
var _b;
var { json, url } = _a, options = tslib_1.__rest(_a, ["json", "url"]);
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const res = yield (0, native_fetch_1.fetch)(new URL(url, "https://api.useplunk.com/v1/").toString(), Object.assign(Object.assign({}, options), { headers: Object.assign(Object.assign({ Authorization: `Bearer ${this.key}` }, (json && { "Content-Type": "application/json" })), options.headers), body: json ? JSON.stringify(json) : undefined }));
const text = yield res.text();
const data = safeJsonParse(text);
if ((res === null || res === void 0 ? void 0 : res.status) === 401) {
throw new TokenError_1.TokenError(data === null || data === void 0 ? void 0 : data.message);
}
if ((res === null || res === void 0 ? void 0 : res.status) === 404) {
throw new NotFound_1.NotFoundError(data === null || data === void 0 ? void 0 : data.message);
}
if (!res.ok) {
throw new Error((_b = data === null || data === void 0 ? void 0 : data.message) !== null && _b !== void 0 ? _b : "Unknown API Error");
}
return data;
});

@@ -60,1 +74,9 @@ }

exports.Plunk = Plunk;
function safeJsonParse(text) {
try {
return JSON.parse(text);
}
catch (e) {
return text;
}
}
export interface SendParams {
to: string;
to: string | string[];
subject: string;

@@ -4,0 +4,0 @@ body: string;

{
"name": "@plunk/node",
"version": "1.1.1",
"version": "1.1.3",
"description": "Official Node.js library for useplunk.com",

@@ -22,4 +22,5 @@ "main": "dist/index.js",

"dependencies": {
"axios": "^0.27.2",
"tslib": "^2.4.0"
"native-fetch": "^4.0.2",
"tslib": "^2.4.0",
"undici": "^5.22.1"
},

@@ -26,0 +27,0 @@ "devDependencies": {

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