Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

ntfy

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ntfy - npm Package Compare versions

Comparing version
1.14.1
to
1.14.2
+1
-1
dist/index.d.ts

@@ -0,2 +1,2 @@

export * from './interfaces.js';
export * from './NtfyClient.js';
export * from './interfaces.js';

@@ -0,2 +1,2 @@

export * from './interfaces.js';
export * from './NtfyClient.js';
export * from './interfaces.js';
export declare enum MessagePriority {
/** Really long vibration bursts, default notification sound with a pop-over notification. */
MAX = 5,
/** No vibration or sound. The notification will be under the fold in "Other notifications". */
MIN = 1,
/** No vibration or sound. Notification will not visibly show up until notification drawer is pulled down. */
LOW = 2,
/** Short default vibration and sound. Default notification behavior. */
DEFAULT = 3,
/** Long vibration burst, default notification sound with a pop-over notification. */
HIGH = 4,
/** Short default vibration and sound. Default notification behavior. */
DEFAULT = 3,
/** No vibration or sound. Notification will not visibly show up until notification drawer is pulled down. */
LOW = 2,
/** No vibration or sound. The notification will be under the fold in "Other notifications". */
MIN = 1
/** Really long vibration bursts, default notification sound with a pop-over notification. */
MAX = 5
}
export type ResponseData<T extends Config> = T & {
id: string;
time: number;
};
export interface FileURL {
filename: string;
url: string;
}
/**
* The broadcast action sends an Android broadcast intent when the action button is tapped. This allows integration
* into automation apps such as MacroDroid or Tasker, which basically means you can do everything your phone is
* capable of. Examples include taking pictures, launching/killing apps, change device settings, write/read files,
* etc.
*
* By default, the intent action **`io.heckel.ntfy.USER_ACTION`** is broadcast, though this can be changed with the
* `intent` parameter. To send extras, use the `extras` parameter. Currently, only string extras are supported.
*/
export interface BroadcastAction {
/** Clear notification after action button is tapped, default is `false`. */
clear?: boolean;
/** Android intent extras. */
extras?: Record<string, string>;
/** Android intent name, default is `io.heckel.ntfy.USER_ACTION`. */
intent?: string;
/** Label of the action button in the notification. */
label: string;
}
export type HTTPMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
export interface HTTPAction {
/** HTTP body. */
body?: string;
/**
* Clear notification after HTTP request succeeds. If the request fails, the notification is not cleared.
* Default is `false`.
*/
clear?: boolean;
/** HTTP headers to pass in request. */
headers?: Record<string, string>;
/** Label of the action button in the notification. */
label: string;
/** HTTP method to use for request, default is POST ⚠️. */
method?: HTTPMethod;
/** URL to which the HTTP request will be sent. */
url: string;
}
/**
* The view action **opens a website or app when the action button is tapped**, e.g. a browser, a Google Maps location,
* or even a deep link into Twitter or a show ntfy topic. How exactly the action is handled depends on how Android and
* your desktop browser treat the links. Normally it'll just open a link in the browser.
*
* Examples:
*
* * `http://` or `https://` will open your browser (or an app if it registered for a URL)
* * `mailto:` links will open your mail app, e.g. `mailto:phil@example.com`
* * `geo:` links will open Google Maps, e.g. `geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA`
* * `ntfy://` links will open ntfy (see [ntfy:// links](https://docs.ntfy.sh/subscribe/phone/#ntfy-links)), e.g.
* `ntfy://ntfy.sh/stats`
* * `twitter://` links will open Twitter, e.g. `twitter://user?screen_name=..`
* * ...
*/
export interface ViewAction {
/** Clear notification after action button is tapped, default is `false`. */
clear?: boolean;
/** Label of the action button in the notification */
label: string;
/** URL to open when action is tapped */
url: string;
}
export type Action = ({
type: 'view';
} & ViewAction) | ({
type: 'broadcast';
} & BroadcastAction) | ({
type: 'http';
} & HTTPAction);
export type Config = AttachmentConfig | MessageConfig;
export type AttachmentConfig = Omit<BaseConfig, 'fileURL'> & {
} & HTTPAction) | ({
type: 'view';
} & ViewAction);
export type AttachmentConfig = {
/**

@@ -101,9 +32,3 @@ * You can send images and other files to your phone as attachments to a notification. The attachments are then

fileAttachment: string;
};
export type MessageConfig = BaseConfig & {
/**
* Main body of the message as shown in the notification.
*/
message: string;
};
} & Omit<BaseConfig, 'fileURL'>;
export interface BaseConfig {

@@ -233,3 +158,3 @@ /**

*/
fileURL?: string | FileURL;
fileURL?: FileURL | string;
/**

@@ -272,1 +197,76 @@ * You can include an icon that will appear next to the text of the notification. Simply specify the URL that the icon

}
/**
* The broadcast action sends an Android broadcast intent when the action button is tapped. This allows integration
* into automation apps such as MacroDroid or Tasker, which basically means you can do everything your phone is
* capable of. Examples include taking pictures, launching/killing apps, change device settings, write/read files,
* etc.
*
* By default, the intent action **`io.heckel.ntfy.USER_ACTION`** is broadcast, though this can be changed with the
* `intent` parameter. To send extras, use the `extras` parameter. Currently, only string extras are supported.
*/
export interface BroadcastAction {
/** Clear notification after action button is tapped, default is `false`. */
clear?: boolean;
/** Android intent extras. */
extras?: Record<string, string>;
/** Android intent name, default is `io.heckel.ntfy.USER_ACTION`. */
intent?: string;
/** Label of the action button in the notification. */
label: string;
}
export type Config = AttachmentConfig | MessageConfig;
export interface FileURL {
filename: string;
url: string;
}
export interface HTTPAction {
/** HTTP body. */
body?: string;
/**
* Clear notification after HTTP request succeeds. If the request fails, the notification is not cleared.
* Default is `false`.
*/
clear?: boolean;
/** HTTP headers to pass in request. */
headers?: Record<string, string>;
/** Label of the action button in the notification. */
label: string;
/** HTTP method to use for request, default is POST ⚠️. */
method?: HTTPMethod;
/** URL to which the HTTP request will be sent. */
url: string;
}
export type HTTPMethod = 'delete' | 'DELETE' | 'get' | 'GET' | 'head' | 'HEAD' | 'link' | 'LINK' | 'options' | 'OPTIONS' | 'patch' | 'PATCH' | 'post' | 'POST' | 'purge' | 'PURGE' | 'put' | 'PUT' | 'unlink' | 'UNLINK';
export type MessageConfig = {
/**
* Main body of the message as shown in the notification.
*/
message: string;
} & BaseConfig;
export type ResponseData<T extends Config> = {
id: string;
time: number;
} & T;
/**
* The view action **opens a website or app when the action button is tapped**, e.g. a browser, a Google Maps location,
* or even a deep link into Twitter or a show ntfy topic. How exactly the action is handled depends on how Android and
* your desktop browser treat the links. Normally it'll just open a link in the browser.
*
* Examples:
*
* * `http://` or `https://` will open your browser (or an app if it registered for a URL)
* * `mailto:` links will open your mail app, e.g. `mailto:phil@example.com`
* * `geo:` links will open Google Maps, e.g. `geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA`
* * `ntfy://` links will open ntfy (see [ntfy:// links](https://docs.ntfy.sh/subscribe/phone/#ntfy-links)), e.g.
* `ntfy://ntfy.sh/stats`
* * `twitter://` links will open Twitter, e.g. `twitter://user?screen_name=..`
* * ...
*/
export interface ViewAction {
/** Clear notification after action button is tapped, default is `false`. */
clear?: boolean;
/** Label of the action button in the notification */
label: string;
/** URL to open when action is tapped */
url: string;
}

@@ -0,13 +1,14 @@

/* eslint-disable no-magic-numbers */
export var MessagePriority;
(function (MessagePriority) {
/** No vibration or sound. The notification will be under the fold in "Other notifications". */
MessagePriority[MessagePriority["MIN"] = 1] = "MIN";
/** No vibration or sound. Notification will not visibly show up until notification drawer is pulled down. */
MessagePriority[MessagePriority["LOW"] = 2] = "LOW";
/** Short default vibration and sound. Default notification behavior. */
MessagePriority[MessagePriority["DEFAULT"] = 3] = "DEFAULT";
/** Long vibration burst, default notification sound with a pop-over notification. */
MessagePriority[MessagePriority["HIGH"] = 4] = "HIGH";
/** Really long vibration bursts, default notification sound with a pop-over notification. */
MessagePriority[MessagePriority["MAX"] = 5] = "MAX";
/** Long vibration burst, default notification sound with a pop-over notification. */
MessagePriority[MessagePriority["HIGH"] = 4] = "HIGH";
/** Short default vibration and sound. Default notification behavior. */
MessagePriority[MessagePriority["DEFAULT"] = 3] = "DEFAULT";
/** No vibration or sound. Notification will not visibly show up until notification drawer is pulled down. */
MessagePriority[MessagePriority["LOW"] = 2] = "LOW";
/** No vibration or sound. The notification will be under the fold in "Other notifications". */
MessagePriority[MessagePriority["MIN"] = 1] = "MIN";
})(MessagePriority || (MessagePriority = {}));

@@ -0,3 +1,3 @@

import fs from 'node:fs/promises';
import { URL } from 'node:url';
import fs from 'node:fs/promises';
const defaultServerURL = 'https://ntfy.sh';

@@ -16,48 +16,2 @@ export class NtfyClient {

}
function buildBroadcastActionString(action) {
let str = `${action.type}, ${action.label}`;
if (action.clear) {
str += ', clear=true';
}
if (action.extras && Object.keys(action.extras).length) {
str += `, ${Object.entries(action.extras)
.map(([key, value]) => `extras.${key}=${value}`)
.join(', ')}`;
}
if (action.intent) {
str += `, intent=${action.intent}`;
}
return str;
}
function ConfigHasAttachment(config) {
return !!config.fileAttachment;
}
function ConfigHasMessage(config) {
return !!config.message;
}
function buildHTTPActionString(action) {
let str = `${action.type}, ${action.label}, ${action.url}`;
if (action.method) {
str += `, method=${action.method.toUpperCase()}`;
}
if (action.clear) {
str += ', clear=true';
}
if (action.headers && Object.keys(action.headers).length) {
str += `, ${Object.entries(action.headers)
.map(([key, value]) => `headers.${key}=${value}`)
.join(', ')}`;
}
if (action.body) {
str += `, ${action.body}`;
}
return str;
}
function buildViewActionString(action) {
let str = `${action.type}, ${action.label}, ${action.url}`;
if (action.clear) {
str += ', clear=true';
}
return str;
}
export async function publish(publishConfig) {

@@ -156,1 +110,47 @@ const requestConfig = { headers: {} };

}
function buildBroadcastActionString(action) {
let str = `${action.type}, ${action.label}`;
if (action.clear) {
str += ', clear=true';
}
if (action.extras && Object.keys(action.extras).length) {
str += `, ${Object.entries(action.extras)
.map(([key, value]) => `extras.${key}=${value}`)
.join(', ')}`;
}
if (action.intent) {
str += `, intent=${action.intent}`;
}
return str;
}
function buildHTTPActionString(action) {
let str = `${action.type}, ${action.label}, ${action.url}`;
if (action.method) {
str += `, method=${action.method.toUpperCase()}`;
}
if (action.clear) {
str += ', clear=true';
}
if (action.headers && Object.keys(action.headers).length) {
str += `, ${Object.entries(action.headers)
.map(([key, value]) => `headers.${key}=${value}`)
.join(', ')}`;
}
if (action.body) {
str += `, ${action.body}`;
}
return str;
}
function buildViewActionString(action) {
let str = `${action.type}, ${action.label}, ${action.url}`;
if (action.clear) {
str += ', clear=true';
}
return str;
}
function ConfigHasAttachment(config) {
return !!config.fileAttachment;
}
function ConfigHasMessage(config) {
return !!config.message;
}

@@ -30,4 +30,4 @@ {

"type": "module",
"version": "1.14.1",
"gitHead": "ba772186f0c4fb05492ef586666b8e44faefe71d"
"version": "1.14.2",
"gitHead": "59997e7c64b551213644945256b13ff3ba1ccfcd"
}