ntfy 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,15 +2,16 @@
2
2
 
3
3
  Send notifications over [ntfy.sh](https://ntfy.sh).
4
4
 
5
+ ## Prerequisites
6
+
7
+ - [Node.js](https://nodejs.org) >= 14
8
+ - npm (preinstalled) or [yarn](https://classic.yarnpkg.com)
9
+
5
10
  ## Installation
6
11
 
7
- ```
8
- npm install ntfy
9
- ```
12
+ ℹ️ This is a hybrid [CommonJS](https://nodejs.org/docs/latest/api/modules.html#modules-commonjs-modules) / [ESM](https://nodejs.org/api/esm.html#introduction) module.
10
13
 
11
- ```
12
- yarn add ntft
13
- ```
14
+ Run `yarn add ntfy` or `npm i ntfy`.
14
15
 
15
16
  ## Usage
16
17
 
@@ -19,7 +20,7 @@ yarn add ntft
19
20
  ```ts
20
21
  import {publish} from 'ntfy';
21
22
 
22
- await ntfyClient.publish({
23
+ await publish({
23
24
  message: 'This is an example message.',
24
25
  topic: 'mytopic',
25
26
  });
@@ -30,7 +31,7 @@ await ntfyClient.publish({
30
31
  ```ts
31
32
  import {publish, MessagePriority} from 'ntfy';
32
33
 
33
- await ntfyClient.publish({
34
+ await publish({
34
35
  actions: [
35
36
  {
36
37
  clear: true,
@@ -1,4 +1,4 @@
1
- import type { Config, ResponseData } from './interfaces';
1
+ import type { Config, ResponseData } from './interfaces.js';
2
2
  export declare class NtfyClient {
3
3
  private readonly serverURL;
4
4
  /**
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,13 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.publish = exports.NtfyClient = void 0;
13
- const axios_1 = require("axios");
14
- const url_1 = require("url");
15
- const fs_1 = require("fs");
10
+ import axios, { AxiosHeaders } from 'axios';
11
+ import { URL } from 'node:url';
12
+ import { promises as fs } from 'node:fs';
16
13
  const defaultServerURL = 'https://ntfy.sh';
17
- class NtfyClient {
14
+ export class NtfyClient {
18
15
  /**
19
16
  * @param serverURL Specify your own ntfy Server. See [Self-hosting](https://docs.ntfy.sh/install/).
20
17
  */
@@ -25,7 +22,6 @@ class NtfyClient {
25
22
  return publish(Object.assign({ server: this.serverURL }, config));
26
23
  }
27
24
  }
28
- exports.NtfyClient = NtfyClient;
29
25
  function buildBroadcastActionString(action) {
30
26
  let str = `${action.type}, ${action.label}`;
31
27
  if (action.clear) {
@@ -72,9 +68,9 @@ function buildViewActionString(action) {
72
68
  }
73
69
  return str;
74
70
  }
75
- function publish(config) {
71
+ export function publish(config) {
76
72
  return __awaiter(this, void 0, void 0, function* () {
77
- const axiosConfig = { headers: new axios_1.AxiosHeaders() };
73
+ const axiosConfig = { headers: new AxiosHeaders() };
78
74
  let postData;
79
75
  if (config.actions && config.actions.length) {
80
76
  axiosConfig.headers.set('X-Actions', config.actions
@@ -121,7 +117,7 @@ function publish(config) {
121
117
  }
122
118
  if (ConfigHasAttachment(config)) {
123
119
  try {
124
- postData = yield fs_1.promises.readFile(config.fileAttachment);
120
+ postData = yield fs.readFile(config.fileAttachment);
125
121
  }
126
122
  catch (error) {
127
123
  console.error('Error while reading file:', error.message);
@@ -145,10 +141,9 @@ function publish(config) {
145
141
  if (config.title) {
146
142
  axiosConfig.headers.set('X-Title', config.title);
147
143
  }
148
- const url = new url_1.URL(config.topic, config.server || defaultServerURL);
149
- const { data } = yield axios_1.default.post(url.href, postData, axiosConfig);
144
+ const url = new URL(config.topic, config.server || defaultServerURL);
145
+ const { data } = yield axios.post(url.href, postData, axiosConfig);
150
146
  return data;
151
147
  });
152
148
  }
153
- exports.publish = publish;
154
149
  //# sourceMappingURL=NtfyClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NtfyClient.js","sourceRoot":"","sources":["../../src/NtfyClient.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAC,YAAY,EAAqB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAC,QAAQ,IAAI,EAAE,EAAC,MAAM,SAAS,CAAC;AAYvC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,MAAM,OAAO,UAAU;IAGrB;;OAEG;IACH,YAAY,SAAkB;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,gBAAgB,CAAC;IACjD,CAAC;IAED,OAAO,CAAmB,MAAS;QACjC,OAAO,OAAO,iBACZ,MAAM,EAAE,IAAI,CAAC,SAAS,IACnB,MAAM,EACT,CAAC;IACL,CAAC;CACF;AAED,SAAS,0BAA0B,CAAC,MAA6C;IAC/E,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;IAE5C,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,GAAG,IAAI,cAAc,CAAC;KACvB;IAED,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE;QACtD,GAAG,IAAI,KAAK,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;aACtC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,UAAU,GAAG,IAAI,KAAK,EAAE,CAAC;aAC/C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACjB;IAED,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,GAAG,IAAI,YAAY,MAAM,CAAC,MAAM,EAAE,C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AAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE;YACrC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SAC1G;QAED,IAAI,MAAM,CAAC,KAAK,EAAE;YAChB,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;SAClD;QAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,IAAI,gBAAgB,CAAC,CAAC;QAErE,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './NtfyClient.js';
2
+ export * from './interfaces.js';
@@ -0,0 +1,3 @@
1
+ export * from './NtfyClient.js';
2
+ export * from './interfaces.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessagePriority = void 0;
4
- var MessagePriority;
1
+ export var MessagePriority;
5
2
  (function (MessagePriority) {
6
3
  /** Really long vibration bursts, default notification sound with a pop-over notification. */
7
4
  MessagePriority[MessagePriority["MAX"] = 5] = "MAX";
@@ -13,5 +10,5 @@ var MessagePriority;
13
10
  MessagePriority[MessagePriority["LOW"] = 2] = "LOW";
14
11
  /** No vibration or sound. The notification will be under the fold in "Other notifications". */
15
12
  MessagePriority[MessagePriority["MIN"] = 1] = "MIN";
16
- })(MessagePriority = exports.MessagePriority || (exports.MessagePriority = {}));
13
+ })(MessagePriority || (MessagePriority = {}));
17
14
  //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,eAWX;AAXD,WAAY,eAAe;IACzB,6FAA6F;IAC7F,mDAAO,CAAA;IACP,qFAAqF;IACrF,qDAAQ,CAAA;IACR,wEAAwE;IACxE,2DAAW,CAAA;IACX,6GAA6G;IAC7G,mDAAO,CAAA;IACP,+FAA+F;IAC/F,mDAAO,CAAA;AACT,CAAC,EAXW,eAAe,KAAf,eAAe,QAW1B"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,10 @@
1
+ import type { Config, ResponseData } from './interfaces.js';
2
+ export declare class NtfyClient {
3
+ private readonly serverURL;
4
+ /**
5
+ * @param serverURL Specify your own ntfy Server. See [Self-hosting](https://docs.ntfy.sh/install/).
6
+ */
7
+ constructor(serverURL?: string);
8
+ publish<T extends Config>(config: T): Promise<ResponseData<T>>;
9
+ }
10
+ export declare function publish<T extends Config>(config: T): Promise<ResponseData<T>>;
@@ -0,0 +1,138 @@
1
+ import axios, { AxiosHeaders } from 'axios';
2
+ import { URL } from 'node:url';
3
+ import { promises as fs } from 'node:fs';
4
+ const defaultServerURL = 'https://ntfy.sh';
5
+ export class NtfyClient {
6
+ /**
7
+ * @param serverURL Specify your own ntfy Server. See [Self-hosting](https://docs.ntfy.sh/install/).
8
+ */
9
+ constructor(serverURL) {
10
+ this.serverURL = serverURL || defaultServerURL;
11
+ }
12
+ publish(config) {
13
+ return publish(Object.assign({ server: this.serverURL }, config));
14
+ }
15
+ }
16
+ function buildBroadcastActionString(action) {
17
+ let str = `${action.type}, ${action.label}`;
18
+ if (action.clear) {
19
+ str += ', clear=true';
20
+ }
21
+ if (action.extras && Object.keys(action.extras).length) {
22
+ str += `, ${Object.entries(action.extras)
23
+ .map(([key, value]) => `extras.${key}=${value}`)
24
+ .join(', ')}`;
25
+ }
26
+ if (action.intent) {
27
+ str += `, intent=${action.intent}`;
28
+ }
29
+ return str;
30
+ }
31
+ function ConfigHasAttachment(config) {
32
+ return !!config.fileAttachment;
33
+ }
34
+ function ConfigHasMessage(config) {
35
+ return !!config.message;
36
+ }
37
+ function buildHTTPActionString(action) {
38
+ let str = `${action.type}, ${action.label}, ${action.url}`;
39
+ if (action.method) {
40
+ str += `, method=${action.method.toUpperCase()}`;
41
+ }
42
+ if (action.clear) {
43
+ str += ', clear=true';
44
+ }
45
+ if (action.headers && Object.keys(action.headers).length) {
46
+ str += `, ${Object.entries(action.headers)
47
+ .map(([key, value]) => `headers.${key}=${value}`)
48
+ .join(', ')}`;
49
+ }
50
+ if (action.body) {
51
+ str += `, ${action.body}`;
52
+ }
53
+ return str;
54
+ }
55
+ function buildViewActionString(action) {
56
+ let str = `${action.type}, ${action.label}, ${action.url}`;
57
+ if (action.clear) {
58
+ str += ', clear=true';
59
+ }
60
+ return str;
61
+ }
62
+ export async function publish(config) {
63
+ const axiosConfig = { headers: new AxiosHeaders() };
64
+ let postData;
65
+ if (config.actions && config.actions.length) {
66
+ axiosConfig.headers.set('X-Actions', config.actions
67
+ .map(action => {
68
+ switch (action.type) {
69
+ case 'broadcast': {
70
+ return buildBroadcastActionString(action);
71
+ }
72
+ case 'http': {
73
+ return buildHTTPActionString(action);
74
+ }
75
+ case 'view': {
76
+ return buildViewActionString(action);
77
+ }
78
+ default: {
79
+ return '';
80
+ }
81
+ }
82
+ })
83
+ .join('; '));
84
+ }
85
+ if (config.authorization) {
86
+ axiosConfig.withCredentials = true;
87
+ axiosConfig.auth = config.authorization;
88
+ }
89
+ if (config.delay) {
90
+ axiosConfig.headers.set('X-Delay', config.delay);
91
+ }
92
+ if (config.disableCache) {
93
+ axiosConfig.headers.set('X-Cache', 'no');
94
+ }
95
+ if (config.disableFirebase) {
96
+ axiosConfig.headers.set('X-Firebase', 'no');
97
+ }
98
+ if (config.emailAddress) {
99
+ axiosConfig.headers.set('X-Email', config.emailAddress);
100
+ }
101
+ if (ConfigHasMessage(config) && config.fileURL) {
102
+ if (typeof config.fileURL === 'string') {
103
+ axiosConfig.headers.set('X-Attach', config.fileURL);
104
+ }
105
+ axiosConfig.headers.set('X-Attach', config.fileURL.url);
106
+ axiosConfig.headers.set('X-Filename', config.fileURL.filename);
107
+ }
108
+ if (ConfigHasAttachment(config)) {
109
+ try {
110
+ postData = await fs.readFile(config.fileAttachment);
111
+ }
112
+ catch (error) {
113
+ console.error('Error while reading file:', error.message);
114
+ }
115
+ }
116
+ else if (config.message) {
117
+ postData = config.message;
118
+ }
119
+ else {
120
+ throw new Error('No message or file attachment specified');
121
+ }
122
+ if (config.iconURL) {
123
+ axiosConfig.headers.set('X-Icon', config.iconURL);
124
+ }
125
+ if (config.priority) {
126
+ axiosConfig.headers.set('X-Priority', config.priority);
127
+ }
128
+ if (config.tags && config.tags.length) {
129
+ axiosConfig.headers.set('X-Tags', typeof config.tags === 'string' ? config.tags : config.tags.join(','));
130
+ }
131
+ if (config.title) {
132
+ axiosConfig.headers.set('X-Title', config.title);
133
+ }
134
+ const url = new URL(config.topic, config.server || defaultServerURL);
135
+ const { data } = await axios.post(url.href, postData, axiosConfig);
136
+ return data;
137
+ }
138
+ //# sourceMappingURL=NtfyClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NtfyClient.js","sourceRoot":"","sources":["../../src/NtfyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,YAAY,EAAqB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAC,QAAQ,IAAI,EAAE,EAAC,MAAM,SAAS,CAA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AC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;KAClD;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,IAAI,gBAAgB,CAAC,CAAC;IAErE,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IACjE,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './NtfyClient.js';
2
+ export * from './interfaces.js';
@@ -0,0 +1,3 @@
1
+ export * from './NtfyClient.js';
2
+ export * from './interfaces.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,264 @@
1
+ import type { AxiosBasicCredentials as HTTPAuth, Method as HTTPMethod } from 'axios';
2
+ export declare enum MessagePriority {
3
+ /** Really long vibration bursts, default notification sound with a pop-over notification. */
4
+ MAX = 5,
5
+ /** Long vibration burst, default notification sound with a pop-over notification. */
6
+ HIGH = 4,
7
+ /** Short default vibration and sound. Default notification behavior. */
8
+ DEFAULT = 3,
9
+ /** No vibration or sound. Notification will not visibly show up until notification drawer is pulled down. */
10
+ LOW = 2,
11
+ /** No vibration or sound. The notification will be under the fold in "Other notifications". */
12
+ MIN = 1
13
+ }
14
+ export type ResponseData<T extends Config> = T & {
15
+ id: string;
16
+ time: number;
17
+ };
18
+ export interface FileURL {
19
+ filename: string;
20
+ url: string;
21
+ }
22
+ /**
23
+ * The broadcast action sends an Android broadcast intent when the action button is tapped. This allows integration
24
+ * into automation apps such as MacroDroid or Tasker, which basically means you can do everything your phone is
25
+ * capable of. Examples include taking pictures, launching/killing apps, change device settings, write/read files,
26
+ * etc.
27
+ *
28
+ * By default, the intent action **`io.heckel.ntfy.USER_ACTION`** is broadcast, though this can be changed with the
29
+ * `intent` parameter. To send extras, use the `extras` parameter. Currently, only string extras are supported.
30
+ */
31
+ export interface BroadcastAction {
32
+ /** Clear notification after action button is tapped, default is `false`. */
33
+ clear?: boolean;
34
+ /** Android intent extras. */
35
+ extras?: Record<string, string>;
36
+ /** Android intent name, default is `io.heckel.ntfy.USER_ACTION`. */
37
+ intent?: string;
38
+ /** Label of the action button in the notification. */
39
+ label: string;
40
+ }
41
+ export interface HTTPAction {
42
+ /** HTTP body. */
43
+ body?: string;
44
+ /**
45
+ * Clear notification after HTTP request succeeds. If the request fails, the notification is not cleared.
46
+ * Default is `false`.
47
+ */
48
+ clear?: boolean;
49
+ /** HTTP headers to pass in request. */
50
+ headers?: Record<string, string>;
51
+ /** Label of the action button in the notification. */
52
+ label: string;
53
+ /** HTTP method to use for request, default is POST ⚠️. */
54
+ method?: HTTPMethod;
55
+ /** URL to which the HTTP request will be sent. */
56
+ url: string;
57
+ }
58
+ /**
59
+ * The view action **opens a website or app when the action button is tapped**, e.g. a browser, a Google Maps location,
60
+ * or even a deep link into Twitter or a show ntfy topic. How exactly the action is handled depends on how Android and
61
+ * your desktop browser treat the links. Normally it'll just open a link in the browser.
62
+ *
63
+ * Examples:
64
+ *
65
+ * * `http://` or `https://` will open your browser (or an app if it registered for a URL)
66
+ * * `mailto:` links will open your mail app, e.g. `mailto:phil@example.com`
67
+ * * `geo:` links will open Google Maps, e.g. `geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA`
68
+ * * `ntfy://` links will open ntfy (see [ntfy:// links](https://docs.ntfy.sh/subscribe/phone/#ntfy-links)), e.g.
69
+ * `ntfy://ntfy.sh/stats`
70
+ * * `twitter://` links will open Twitter, e.g. `twitter://user?screen_name=..`
71
+ * * ...
72
+ */
73
+ export interface ViewAction {
74
+ /** Clear notification after action button is tapped, default is `false`. */
75
+ clear?: boolean;
76
+ /** Label of the action button in the notification */
77
+ label: string;
78
+ /** URL to open when action is tapped */
79
+ url: string;
80
+ }
81
+ export type Action = ({
82
+ type: 'view';
83
+ } & ViewAction) | ({
84
+ type: 'broadcast';
85
+ } & BroadcastAction) | ({
86
+ type: 'http';
87
+ } & HTTPAction);
88
+ export type Config = AttachmentConfig | MessageConfig;
89
+ export type AttachmentConfig = Omit<BaseConfig, 'fileURL'> & {
90
+ /**
91
+ * You can send images and other files to your phone as attachments to a notification. The attachments are then
92
+ * downloaded onto your phone (depending on size and setting automatically), and can be used from the Downloads
93
+ * folder.
94
+ *
95
+ * There are two different ways to send attachments:
96
+ *
97
+ * * sending a local file, e.g. from `~/Flowers/flower.jpg` or `ringtone.mp3`
98
+ * * or by passing an external URL as an attachment, e.g. `https://f-droid.org/F-Droid.apk`
99
+ */
100
+ fileAttachment: string;
101
+ };
102
+ export type MessageConfig = BaseConfig & {
103
+ /**
104
+ * Main body of the message as shown in the notification.
105
+ */
106
+ message: string;
107
+ };
108
+ export interface BaseConfig {
109
+ /**
110
+ * You can add action buttons to notifications to allow yourself to react to a notification directly. This is
111
+ * incredibly useful and has countless applications.
112
+ *
113
+ * You can control your home appliances (open/close garage door, change temperature on thermostat, ...), react to
114
+ * common monitoring alerts (clear logs when disk is full, ...), and many other things. The sky is the limit.
115
+ *
116
+ * As of today, the following actions are supported:
117
+ *
118
+ * * [`view`](https://docs.ntfy.sh/publish/#open-websiteapp): Opens a website or app when the action button is tapped
119
+ * * [`broadcast`](https://docs.ntfy.sh/publish/#send-android-broadcast): Sends an
120
+ * [Android broadcast](https://developer.android.com/guide/components/broadcasts) intent when the action button is
121
+ * tapped (only supported on Android)
122
+ * * [`http`](https://docs.ntfy.sh/publish/#send-http-request): Sends HTTP POST/GET/PUT request when the action button
123
+ * is tapped
124
+ */
125
+ actions?: Action[];
126
+ /**
127
+ * Depending on whether the server is configured to support
128
+ * [access control](https://docs.ntfy.sh/config/#access-control), some topics may be read/write protected so that only
129
+ * users with the correct credentials can subscribe or publish to them.
130
+ */
131
+ authorization?: HTTPAuth;
132
+ /**
133
+ * You can define which URL to open when a notification is clicked. This may be useful if your notification is related
134
+ * to a Zabbix alert or a transaction that you'd like to provide the deep-link for. Tapping the notification will open
135
+ * the web browser (or the app) and open the website.
136
+ *
137
+ * If you pass a website URL (`http://` or `https://`) the web browser will open. If you pass another URI that can be
138
+ * handled by another app, the responsible app may open.
139
+ *
140
+ * Examples:
141
+ *
142
+ * * `http://` or `https://` will open your browser (or an app if it registered for a URL)
143
+ * * `mailto:` links will open your mail app, e.g. `mailto:phil@example.com`
144
+ * * `geo:` links will open Google Maps, e.g. `geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA`
145
+ * * `ntfy://` links will open ntfy (see [ntfy:// links](https://docs.ntfy.sh/subscribe/phone/#ntfy-links)), e.g.
146
+ * `ntfy://ntfy.sh/stats`
147
+ * * `twitter://` links will open Twitter, e.g. `twitter://user?screen_name=..`
148
+ * * ...
149
+
150
+ */
151
+ clickURL?: string;
152
+ /**
153
+ * You can delay the delivery of messages and let ntfy send them at a later date. This can be used to send yourself
154
+ * reminders or even to execute commands at a later date (if your subscriber acts on messages).
155
+ *
156
+ * Usage is pretty straight forward. You can set the delivery time either by specifying a Unix timestamp (e.g.
157
+ * `1639194738`), a duration (e.g. `30m`, `3h`, `2 days`), or a natural language time string (e.g. `10am`, `8:30pm`,
158
+ * `tomorrow`, `3pm`, `Tuesday`, `7am`, [and more](https://github.com/olebedev/when)).
159
+ *
160
+ * As of today, the minimum delay you can set is 10 seconds and the maximum delay is 3 days. This can currently not be
161
+ * configured otherwise ([let the author know](https://github.com/binwiederhier/ntfy/issues) if you'd like to change
162
+ * these limits).
163
+ *
164
+ * For the purposes of [message caching](https://docs.ntfy.sh/config/#message-cache), scheduled messages are kept in
165
+ * the cache until 12 hours after they were delivered (or whatever the server-side cache duration is set to). For
166
+ * instance, if a message is scheduled to be delivered in 3 days, it'll remain in the cache for 3 days and 12 hours.
167
+ * Also note that naturally, [turning off server-side caching](https://docs.ntfy.sh/publish/#message-caching) is not
168
+ * possible in combination with this feature.
169
+ */
170
+ delay?: string;
171
+ /**
172
+ * **INFO**: If caching is disabled, messages will only be delivered to connected subscribers, and won't be
173
+ * re-delivered if a client re-connects. If a subscriber has (temporary) network issues or is reconnecting
174
+ * momentarily, **messages might be missed**.
175
+ *
176
+ * ---
177
+ *
178
+ * By default, the ntfy server caches messages on disk for 12 hours (see
179
+ * [message caching](https://docs.ntfy.sh/config/#message-cache)), so all messages you publish are stored server-side
180
+ * for a little while. The reason for this is to overcome temporary client-side network disruptions, but arguably this
181
+ * feature also may raise privacy concerns.
182
+ *
183
+ * To avoid messages being cached server-side entirely, you can disable caching. This will make sure that your message
184
+ * is not cached on the server, even if server-side caching is enabled. Messages are still delivered to connected
185
+ * subscribers, but [`since=`](https://docs.ntfy.sh/subscribe/api/#fetch-cached-messages) and
186
+ * [`poll=1`](https://docs.ntfy.sh/subscribe/api/#poll-for-messages) won't return the message anymore.
187
+ */
188
+ disableCache?: boolean;
189
+ /**
190
+ * **INFO**: If Firebase is disabled and instant delivery isn't enabled in the Android app (Google Play variant only),
191
+ * message delivery will be significantly delayed (up to 15 minutes). To overcome this delay, simply enable instant
192
+ * delivery.
193
+ *
194
+ * ---
195
+ *
196
+ * The ntfy server can be configured to use Firebase Cloud Messaging (FCM) (see Firebase config) for message delivery
197
+ * on Android (to minimize the app's battery footprint). The ntfy.sh server is configured this way, meaning that all
198
+ * messages published to ntfy.sh are also published to corresponding FCM topics.
199
+ *
200
+ * If you'd like to avoid forwarding messages to Firebase, you can disabled Firebase. This will instruct the server
201
+ * not to forward messages to Firebase.
202
+ */
203
+ disableFirebase?: boolean;
204
+ /**
205
+ * You can forward messages to e-mail by specifying an address in the header. This can be useful for messages that
206
+ * you'd like to persist longer, or to blast-notify yourself on all possible channels.
207
+ *
208
+ * Only one e-mail address is supported.
209
+ *
210
+ * Since ntfy does not provide auth (yet), the rate limiting is pretty strict (see
211
+ * [limitations](https://docs.ntfy.sh/publish/#limitations)). In the default configuration, you get 16 e-mails per
212
+ * visitor (IP address) and then after that one per hour. On top of that, your IP address appears in the e-mail body.
213
+ * This is to prevent abuse.
214
+ */
215
+ emailAddress?: string;
216
+ /**
217
+ * Instead of sending a local file to your phone, you can use an external URL to specify where the attachment is
218
+ * hosted. This could be a Dropbox link, a file from social media, or any other publicly available URL. Since the
219
+ * files are externally hosted, the expiration or size limits from above do not apply here.
220
+ *
221
+ * To attach an external file, simple pass the `fileURL` parameter to specify the attachment URL. It can be any
222
+ * type of file.
223
+ *
224
+ * ntfy will automatically try to derive the file name from the URL (e.g https://example.com/flower.jpg will yield a
225
+ * filename flower.jpg). To override this filename, you may send use the `FileURL` object.
226
+ */
227
+ fileURL?: string | FileURL;
228
+ /**
229
+ * You can include an icon that will appear next to the text of the notification. Simply specify the URL that the icon
230
+ * is located at. The client will automatically download the icon (unless it is already cached locally, and less than
231
+ * 24 hours old), and show it in the notification. Icons are cached locally in the client until the notification is
232
+ * deleted. **Only JPEG and PNG images are supported at this time**.
233
+ */
234
+ iconURL?: string;
235
+ /**
236
+ * All messages have a priority, which defines how urgently your phone notifies you. On Android, you can set custom
237
+ * notification sounds and vibration patterns on your phone to map to these priorities (see
238
+ * [Android config](https://docs.ntfy.sh/subscribe/phone/)).
239
+ */
240
+ priority?: MessagePriority;
241
+ /**
242
+ * Specify a custom ntfy Server. See [Self-hosting](https://docs.ntfy.sh/install/).
243
+ */
244
+ server?: string;
245
+ /**
246
+ * You can tag messages with emojis and other relevant strings:
247
+ *
248
+ * * Emojis: If a tag matches an [emoji short code](https://docs.ntfy.sh/emojis/), it'll be converted to an emoji and
249
+ * prepended to title or message.
250
+ * * Other tags: If a tag doesn't match, it will be listed below the notification.
251
+ *
252
+ * This feature is useful for things like warnings (⚠️, ️🚨, or 🚩), but also to simply tag messages otherwise (e.g.
253
+ * script names, hostnames, etc.). Use [the emoji short code list](https://docs.ntfy.sh/emojis/) to figure out what
254
+ * tags can be converted to emojis.
255
+ */
256
+ tags?: string | string[];
257
+ /** The notification title is typically set to the topic short URL (e.g. `ntfy.sh/mytopic`). */
258
+ title?: string;
259
+ /**
260
+ * Your topic to publish and subscribe to. Because there is no sign-up, the topic is essentially a password, so pick
261
+ * something that's not easily guessable.
262
+ */
263
+ topic: string;
264
+ }
@@ -0,0 +1,14 @@
1
+ export var MessagePriority;
2
+ (function (MessagePriority) {
3
+ /** Really long vibration bursts, default notification sound with a pop-over notification. */
4
+ MessagePriority[MessagePriority["MAX"] = 5] = "MAX";
5
+ /** Long vibration burst, default notification sound with a pop-over notification. */
6
+ MessagePriority[MessagePriority["HIGH"] = 4] = "HIGH";
7
+ /** Short default vibration and sound. Default notification behavior. */
8
+ MessagePriority[MessagePriority["DEFAULT"] = 3] = "DEFAULT";
9
+ /** No vibration or sound. Notification will not visibly show up until notification drawer is pulled down. */
10
+ MessagePriority[MessagePriority["LOW"] = 2] = "LOW";
11
+ /** No vibration or sound. The notification will be under the fold in "Other notifications". */
12
+ MessagePriority[MessagePriority["MIN"] = 1] = "MIN";
13
+ })(MessagePriority || (MessagePriority = {}));
14
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,eAWX;AAXD,WAAY,eAAe;IACzB,6FAA6F;IAC7F,mDAAO,CAAA;IACP,qFAAqF;IACrF,qDAAQ,CAAA;IACR,wEAAwE;IACxE,2DAAW,CAAA;IACX,6GAA6G;IAC7G,mDAAO,CAAA;IACP,+FAA+F;IAC/F,mDAAO,CAAA;AACT,CAAC,EAXW,eAAe,KAAf,eAAe,QAW1B"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json CHANGED
@@ -1,46 +1,45 @@
1
1
  {
2
2
  "author": "Florian Imdahl <git@ffflorian.de>",
3
3
  "dependencies": {
4
- "axios": "1.3.5"
4
+ "axios": "1.6.0"
5
5
  },
6
6
  "description": "Send notifications over ntfy.sh.",
7
7
  "devDependencies": {
8
- "rimraf": "5.0.0",
9
- "typescript": "5.0.4"
8
+ "rimraf": "5.0.5",
9
+ "typescript": "5.2.2"
10
10
  },
11
11
  "engines": {
12
- "node": ">= 10.9"
12
+ "node": ">= 14.16"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/mjs/index.js",
17
+ "require": "./dist/cjs/index.js"
18
+ }
13
19
  },
14
20
  "files": [
15
- "NtfyClient.d.ts",
16
- "NtfyClient.js",
17
- "NtfyClient.js.map",
18
- "index.d.ts",
19
- "index.js",
20
- "index.js.map",
21
- "interfaces.d.ts",
22
- "interfaces.js",
23
- "interfaces.js.map"
21
+ "dist"
24
22
  ],
25
23
  "keywords": [
26
24
  "ntfy",
27
25
  "typescript"
28
26
  ],
29
27
  "license": "GPL-3.0",
30
- "main": "index.js",
28
+ "main": "dist/cjs/index.js",
29
+ "module": "dist/mjs/index.js",
31
30
  "name": "ntfy",
32
- "publishConfig": {
33
- "directory": "flattened"
34
- },
35
31
  "repository": "https://github.com/ffflorian/node-packages/tree/main/packages/ntfy",
36
32
  "scripts": {
37
- "build": "tsc",
33
+ "build": "yarn build:cjs && yarn build:mjs && yarn generate:packagejson",
34
+ "build:cjs": "tsc -p tsconfig.cjs.json",
35
+ "build:mjs": "tsc -p tsconfig.json",
38
36
  "clean": "rimraf dist",
39
37
  "dist": "yarn clean && yarn build",
40
- "flatten": "node ../publish-flat/dist/cli.js -o flattened",
41
- "postversion": "node ../publish-flat/dist/cli-copy.js -o flattened/package.json version",
42
- "start": "ts-node src/cli.ts",
43
- "test": "ts-node -P tsconfig.jasmine.json ../../node_modules/jasmine/bin/jasmine.js"
38
+ "generate:packagejson": "../../bin/generate-hybrid-package-json.sh",
39
+ "start": "ts-node-esm src/cli.ts",
40
+ "test": "ts-node-esm -P tsconfig.jasmine.json ../../node_modules/.bin/jasmine"
44
41
  },
45
- "version": "1.3.0"
42
+ "type": "module",
43
+ "version": "1.4.0",
44
+ "gitHead": "e7bb24502cde477597fa401ea467f8d463323cda"
46
45
  }
package/NtfyClient.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"NtfyClient.js","sourceRoot":"","sources":["../src/NtfyClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAA8D;AAC9D,6BAAwB;AACxB,2BAAkC;AAYlC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,MAAa,UAAU;IAGrB;;OAEG;IACH,YAAY,SAAkB;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,gBAAgB,CAAC;IACjD,CAAC;IAED,OAAO,CAAmB,MAAS;QACjC,OAAO,OAAO,iBACZ,MAAM,EAAE,IAAI,CAAC,SAAS,IACnB,MAAM,EACT,CAAC;IACL,CAAC;CACF;AAhBD,gCAgBC;AAED,SAAS,0BAA0B,CAAC,MAA6C;IAC/E,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;IAE5C,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,GAAG,IAAI,cAAc,CAAC;KACvB;IAED,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE;QACtD,GAAG,IAAI,KAAK,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;aACtC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,UAAU,GAAG,IAAI,KAAK,EAAE,CAAC;aAC/C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACjB;IAED,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,GAAG,IAAI,YAAY,MAAM,CAAC,MAAM,EAAE,CAAC;KACpC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAW;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O,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SAC1G;QAED,IAAI,MAAM,CAAC,KAAK,EAAE;YAChB,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;SAClD;QAED,MAAM,GAAG,GAAG,IAAI,SAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,IAAI,gBAAgB,CAAC,CAAC;QAErE,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AA1FD,0BA0FC"}
package/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './NtfyClient';
2
- export * from './interfaces';
package/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./NtfyClient"), exports);
18
- __exportStar(require("./interfaces"), exports);
19
- //# sourceMappingURL=index.js.map
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B"}
package/interfaces.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AAEA,IAAY,eAWX;AAXD,WAAY,eAAe;IACzB,6FAA6F;IAC7F,mDAAO,CAAA;IACP,qFAAqF;IACrF,qDAAQ,CAAA;IACR,wEAAwE;IACxE,2DAAW,CAAA;IACX,6GAA6G;IAC7G,mDAAO,CAAA;IACP,+FAA+F;IAC/F,mDAAO,CAAA;AACT,CAAC,EAXW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAW1B"}
File without changes