@befroosh/n8n-nodes 0.1.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 ADDED
@@ -0,0 +1,66 @@
1
+ # @befroosh/n8n-nodes
2
+
3
+ Custom **n8n** nodes for Befroosh. This package is the home for any n8n node we build;
4
+ right now it ships the **Befroosh SMS** node.
5
+
6
+ ## Layout
7
+
8
+ ```
9
+ apps/n8n-nodes/
10
+ ├── credentials/ # one ICredentialType per SMS provider
11
+ │ ├── NotrikaSmsApi.credentials.ts
12
+ │ ├── BatabjamSmsApi.credentials.ts
13
+ │ ├── MeliPayamakSmsApi.credentials.ts
14
+ │ └── BatabjamAboardSmsApi.credentials.ts
15
+ ├── nodes/
16
+ │ └── BefrooshSms/
17
+ │ ├── BefrooshSms.node.ts
18
+ │ └── sms.svg
19
+ ├── scripts/copy-icons.mjs # copies .svg/.png into dist after tsc
20
+ ├── tsconfig.json
21
+ └── package.json # the "n8n" field registers nodes + credentials
22
+ ```
23
+
24
+ ## Develop
25
+
26
+ ```bash
27
+ pnpm --filter @befroosh/n8n-nodes build # tsc → dist + icons
28
+ pnpm --filter @befroosh/n8n-nodes check-types # type-check only
29
+ pnpm --filter @befroosh/n8n-nodes dev # tsc --watch
30
+ ```
31
+
32
+ ### Add another node
33
+
34
+ 1. Create `nodes/<MyNode>/<MyNode>.node.ts` exporting a class that implements `INodeType`
35
+ (and an icon next to it).
36
+ 2. If it needs secrets, add `credentials/<MyApi>.credentials.ts` implementing `ICredentialType`.
37
+ 3. Register both in the `"n8n"` field of `package.json` (point at the compiled `dist/...js`).
38
+ 4. `pnpm --filter @befroosh/n8n-nodes build`.
39
+
40
+ ## Befroosh SMS node
41
+
42
+ One node, **Provider** dropdown selects which backend SMS service to use. Each provider has
43
+ its own credential (shown only when that provider is selected). Request shapes mirror
44
+ `apps/core/src/providers/sms/services/*`:
45
+
46
+ | Provider | Endpoint | Auth | Operations |
47
+ |----------|----------|------|------------|
48
+ | Notrika | `POST api.notrikaco.ir/api/v1/messages/send/template` | `X-Api-Key` | Send Message, Send OTP |
49
+ | Batabjam | `POST smsapi.pishgamrayan.com/Messages/Send` | `Authorization` token | Send Message |
50
+ | MeliPayamak | `GET sms.toolzi.ir/post/Send.asmx/...` | username/password in query | Send Message, Send OTP |
51
+ | Batabjam Aboard | login `/api/login.php` → `POST /api/send-bulk-sms.php` | bearer (from login) | Send Message, Send OTP |
52
+
53
+ Fields: **To** (Batabjam/Aboard accept comma-separated numbers), **Message** (Send Message)
54
+ or **OTP Code** (Send OTP). Set the node to *Continue On Fail* if a send must never break a
55
+ workflow.
56
+
57
+ ## Install into an n8n instance
58
+
59
+ A custom node has to be loaded by the n8n runtime (it is **not** importable as a workflow):
60
+
61
+ - **Self-hosted:** build, then either `npm i /path/to/apps/n8n-nodes` into the n8n install,
62
+ drop the built package under `~/.n8n/custom/`, or publish to npm and use
63
+ **Settings → Community Nodes → Install**. Restart n8n.
64
+ - **Managed/hosted (e.g. koochaa):** only works if the host allows custom/community nodes.
65
+ If it doesn't, use the HTTP-Request / sub-workflow approach in `Back/integrations/n8n/`
66
+ instead.
@@ -0,0 +1,7 @@
1
+ import { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class BatabjamAboardSmsApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BatabjamAboardSmsApi = void 0;
4
+ class BatabjamAboardSmsApi {
5
+ constructor() {
6
+ this.name = 'batabjamAboardSmsApi';
7
+ this.displayName = 'Batabjam Aboard SMS API';
8
+ this.documentationUrl = 'https://panel.batabjam.com';
9
+ this.properties = [
10
+ {
11
+ displayName: 'Username',
12
+ name: 'username',
13
+ type: 'string',
14
+ default: '',
15
+ required: true,
16
+ description: 'Used to log in at /api/login.php to obtain a bearer token',
17
+ },
18
+ {
19
+ displayName: 'Password',
20
+ name: 'password',
21
+ type: 'string',
22
+ typeOptions: { password: true },
23
+ default: '',
24
+ required: true,
25
+ },
26
+ ];
27
+ }
28
+ }
29
+ exports.BatabjamAboardSmsApi = BatabjamAboardSmsApi;
30
+ //# sourceMappingURL=BatabjamAboardSmsApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BatabjamAboardSmsApi.credentials.js","sourceRoot":"","sources":["../../credentials/BatabjamAboardSmsApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,oBAAoB;IAAjC;QACI,SAAI,GAAG,sBAAsB,CAAC;QAE9B,gBAAW,GAAG,yBAAyB,CAAC;QAExC,qBAAgB,GAAG,4BAA4B,CAAC;QAEhD,eAAU,GAAsB;YAC5B;gBACI,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,2DAA2D;aAC3E;YACD;gBACI,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;aACjB;SACJ,CAAC;IACN,CAAC;CAAA;AAzBD,oDAyBC"}
@@ -0,0 +1,7 @@
1
+ import { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class BatabjamSmsApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BatabjamSmsApi = void 0;
4
+ class BatabjamSmsApi {
5
+ constructor() {
6
+ this.name = 'batabjamSmsApi';
7
+ this.displayName = 'Batabjam SMS API';
8
+ this.documentationUrl = 'https://smsapi.pishgamrayan.com';
9
+ this.properties = [
10
+ {
11
+ displayName: 'Authorization Token',
12
+ name: 'token',
13
+ type: 'string',
14
+ typeOptions: { password: true },
15
+ default: '',
16
+ required: true,
17
+ description: 'Sent verbatim in the Authorization header',
18
+ },
19
+ {
20
+ displayName: 'Sender Number',
21
+ name: 'senderNumber',
22
+ type: 'string',
23
+ default: '',
24
+ required: true,
25
+ },
26
+ ];
27
+ }
28
+ }
29
+ exports.BatabjamSmsApi = BatabjamSmsApi;
30
+ //# sourceMappingURL=BatabjamSmsApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BatabjamSmsApi.credentials.js","sourceRoot":"","sources":["../../credentials/BatabjamSmsApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,cAAc;IAA3B;QACI,SAAI,GAAG,gBAAgB,CAAC;QAExB,gBAAW,GAAG,kBAAkB,CAAC;QAEjC,qBAAgB,GAAG,iCAAiC,CAAC;QAErD,eAAU,GAAsB;YAC5B;gBACI,WAAW,EAAE,qBAAqB;gBAClC,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,2CAA2C;aAC3D;YACD;gBACI,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;aACjB;SACJ,CAAC;IACN,CAAC;CAAA;AAzBD,wCAyBC"}
@@ -0,0 +1,7 @@
1
+ import { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class MeliPayamakSmsApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MeliPayamakSmsApi = void 0;
4
+ class MeliPayamakSmsApi {
5
+ constructor() {
6
+ this.name = 'meliPayamakSmsApi';
7
+ this.displayName = 'MeliPayamak SMS API';
8
+ this.documentationUrl = 'http://sms.toolzi.ir';
9
+ this.properties = [
10
+ {
11
+ displayName: 'Username',
12
+ name: 'username',
13
+ type: 'string',
14
+ default: '',
15
+ required: true,
16
+ },
17
+ {
18
+ displayName: 'Password',
19
+ name: 'password',
20
+ type: 'string',
21
+ typeOptions: { password: true },
22
+ default: '',
23
+ required: true,
24
+ },
25
+ {
26
+ displayName: 'Sender Number (From)',
27
+ name: 'senderNumber',
28
+ type: 'string',
29
+ default: '',
30
+ required: true,
31
+ },
32
+ {
33
+ displayName: 'OTP Base Number / Body ID',
34
+ name: 'otpBodyId',
35
+ type: 'string',
36
+ default: '302565',
37
+ description: 'bodyId used by SendByBaseNumber for OTP',
38
+ },
39
+ ];
40
+ }
41
+ }
42
+ exports.MeliPayamakSmsApi = MeliPayamakSmsApi;
43
+ //# sourceMappingURL=MeliPayamakSmsApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MeliPayamakSmsApi.credentials.js","sourceRoot":"","sources":["../../credentials/MeliPayamakSmsApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,iBAAiB;IAA9B;QACI,SAAI,GAAG,mBAAmB,CAAC;QAE3B,gBAAW,GAAG,qBAAqB,CAAC;QAEpC,qBAAgB,GAAG,sBAAsB,CAAC;QAE1C,eAAU,GAAsB;YAC5B;gBACI,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;aACjB;YACD;gBACI,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;aACjB;YACD;gBACI,WAAW,EAAE,sBAAsB;gBACnC,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;aACjB;YACD;gBACI,WAAW,EAAE,2BAA2B;gBACxC,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,QAAQ;gBACjB,WAAW,EAAE,yCAAyC;aACzD;SACJ,CAAC;IACN,CAAC;CAAA;AAtCD,8CAsCC"}
@@ -0,0 +1,7 @@
1
+ import { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class NotrikaSmsApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotrikaSmsApi = void 0;
4
+ class NotrikaSmsApi {
5
+ constructor() {
6
+ this.name = 'notrikaSmsApi';
7
+ this.displayName = 'Notrika SMS API';
8
+ this.documentationUrl = 'https://api.notrikaco.ir';
9
+ this.properties = [
10
+ {
11
+ displayName: 'API Key (X-Api-Key)',
12
+ name: 'apiKey',
13
+ type: 'string',
14
+ typeOptions: { password: true },
15
+ default: '',
16
+ required: true,
17
+ },
18
+ {
19
+ displayName: 'Sender Number',
20
+ name: 'senderNumber',
21
+ type: 'string',
22
+ default: '',
23
+ required: true,
24
+ },
25
+ {
26
+ displayName: 'Message Template ID',
27
+ name: 'messageTemplateId',
28
+ type: 'string',
29
+ default: '',
30
+ description: 'Template id used for free-text messages',
31
+ },
32
+ {
33
+ displayName: 'OTP Template ID',
34
+ name: 'otpTemplateId',
35
+ type: 'string',
36
+ default: '',
37
+ description: 'Template id used for OTP codes',
38
+ },
39
+ ];
40
+ }
41
+ }
42
+ exports.NotrikaSmsApi = NotrikaSmsApi;
43
+ //# sourceMappingURL=NotrikaSmsApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotrikaSmsApi.credentials.js","sourceRoot":"","sources":["../../credentials/NotrikaSmsApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAA1B;QACI,SAAI,GAAG,eAAe,CAAC;QAEvB,gBAAW,GAAG,iBAAiB,CAAC;QAEhC,qBAAgB,GAAG,0BAA0B,CAAC;QAE9C,eAAU,GAAsB;YAC5B;gBACI,WAAW,EAAE,qBAAqB;gBAClC,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;aACjB;YACD;gBACI,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;aACjB;YACD;gBACI,WAAW,EAAE,qBAAqB;gBAClC,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,yCAAyC;aACzD;YACD;gBACI,WAAW,EAAE,iBAAiB;gBAC9B,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,gCAAgC;aAChD;SACJ,CAAC;IACN,CAAC;CAAA;AAtCD,sCAsCC"}
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class BefrooshSms implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BefrooshSms = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ /** Split a recipient field that may hold several comma/newline separated numbers. */
6
+ function toRecipients(raw) {
7
+ return raw
8
+ .split(/[\n,]/)
9
+ .map((s) => s.trim())
10
+ .filter(Boolean);
11
+ }
12
+ class BefrooshSms {
13
+ constructor() {
14
+ this.description = {
15
+ displayName: 'Befroosh SMS',
16
+ name: 'befrooshSms',
17
+ icon: 'file:sms.svg',
18
+ group: ['output'],
19
+ version: 1,
20
+ subtitle: '={{ $parameter["operation"] + " · " + $parameter["provider"] }}',
21
+ description: 'Send SMS through the Befroosh SMS providers',
22
+ defaults: { name: 'Befroosh SMS' },
23
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
24
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
25
+ credentials: [
26
+ {
27
+ name: 'notrikaSmsApi',
28
+ required: true,
29
+ displayOptions: { show: { provider: ['notrika'] } },
30
+ },
31
+ {
32
+ name: 'batabjamSmsApi',
33
+ required: true,
34
+ displayOptions: { show: { provider: ['batabjam'] } },
35
+ },
36
+ {
37
+ name: 'meliPayamakSmsApi',
38
+ required: true,
39
+ displayOptions: { show: { provider: ['melipayamak'] } },
40
+ },
41
+ {
42
+ name: 'batabjamAboardSmsApi',
43
+ required: true,
44
+ displayOptions: { show: { provider: ['batabjamAboard'] } },
45
+ },
46
+ ],
47
+ properties: [
48
+ {
49
+ displayName: 'Provider',
50
+ name: 'provider',
51
+ type: 'options',
52
+ noDataExpression: true,
53
+ default: 'notrika',
54
+ options: [
55
+ { name: 'Notrika', value: 'notrika' },
56
+ { name: 'Batabjam', value: 'batabjam' },
57
+ { name: 'MeliPayamak', value: 'melipayamak' },
58
+ { name: 'Batabjam Aboard', value: 'batabjamAboard' },
59
+ ],
60
+ },
61
+ {
62
+ displayName: 'Operation',
63
+ name: 'operation',
64
+ type: 'options',
65
+ noDataExpression: true,
66
+ default: 'sendMessage',
67
+ options: [
68
+ { name: 'Send Message', value: 'sendMessage', action: 'Send an SMS message' },
69
+ { name: 'Send OTP', value: 'sendOtp', action: 'Send an OTP code' },
70
+ ],
71
+ },
72
+ {
73
+ displayName: 'OTP is not supported for Batabjam; use Send Message instead.',
74
+ name: 'batabjamOtpNotice',
75
+ type: 'notice',
76
+ default: '',
77
+ displayOptions: { show: { provider: ['batabjam'], operation: ['sendOtp'] } },
78
+ },
79
+ {
80
+ displayName: 'To',
81
+ name: 'to',
82
+ type: 'string',
83
+ default: '',
84
+ required: true,
85
+ placeholder: '09120000000',
86
+ description: 'Recipient phone number. Batabjam / Batabjam Aboard also accept several numbers separated by commas.',
87
+ },
88
+ {
89
+ displayName: 'Message',
90
+ name: 'message',
91
+ type: 'string',
92
+ typeOptions: { rows: 3 },
93
+ default: '',
94
+ required: true,
95
+ displayOptions: { show: { operation: ['sendMessage'] } },
96
+ },
97
+ {
98
+ displayName: 'OTP Code',
99
+ name: 'otpCode',
100
+ type: 'string',
101
+ default: '',
102
+ required: true,
103
+ displayOptions: { show: { operation: ['sendOtp'] } },
104
+ },
105
+ ],
106
+ };
107
+ }
108
+ async execute() {
109
+ const items = this.getInputData();
110
+ const returnData = [];
111
+ for (let i = 0; i < items.length; i++) {
112
+ try {
113
+ const provider = this.getNodeParameter('provider', i);
114
+ const operation = this.getNodeParameter('operation', i);
115
+ const to = this.getNodeParameter('to', i).trim();
116
+ const message = operation === 'sendMessage'
117
+ ? this.getNodeParameter('message', i)
118
+ : '';
119
+ const otpCode = operation === 'sendOtp' ? this.getNodeParameter('otpCode', i) : '';
120
+ let response;
121
+ if (provider === 'notrika') {
122
+ const c = await this.getCredentials('notrikaSmsApi', i);
123
+ const isOtp = operation === 'sendOtp';
124
+ response = await this.helpers.httpRequest({
125
+ method: 'POST',
126
+ url: 'https://api.notrikaco.ir/api/v1/messages/send/template',
127
+ headers: {
128
+ 'X-Api-Key': c.apiKey,
129
+ Accept: 'application/json',
130
+ 'Cache-Control': 'no-cache',
131
+ },
132
+ body: {
133
+ senderNumber: c.senderNumber,
134
+ recipientNumber: to,
135
+ templateId: isOtp
136
+ ? c.otpTemplateId
137
+ : c.messageTemplateId,
138
+ parameters: isOtp
139
+ ? [{ name: 'code', value: otpCode }]
140
+ : [{ name: 'message', value: message }],
141
+ },
142
+ json: true,
143
+ });
144
+ }
145
+ else if (provider === 'batabjam') {
146
+ if (operation === 'sendOtp') {
147
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Batabjam does not support OTP — use Send Message.', { itemIndex: i });
148
+ }
149
+ const c = await this.getCredentials('batabjamSmsApi', i);
150
+ const recipients = toRecipients(to);
151
+ response = await this.helpers.httpRequest({
152
+ method: 'POST',
153
+ url: 'https://smsapi.pishgamrayan.com/Messages/Send',
154
+ headers: { Authorization: c.token },
155
+ body: {
156
+ senderNumber: c.senderNumber,
157
+ recipientNumbers: recipients,
158
+ messageBodies: [message],
159
+ },
160
+ json: true,
161
+ });
162
+ }
163
+ else if (provider === 'melipayamak') {
164
+ const c = await this.getCredentials('meliPayamakSmsApi', i);
165
+ const enc = encodeURIComponent;
166
+ // NOTE: this provider exposes a legacy ASMX service that ONLY accepts
167
+ // HTTP GET (an HTTP POST form binding returns 404), so the credentials
168
+ // must travel in the query string — they cannot be moved to a body.
169
+ // We use HTTPS (valid cert) so the whole request, query string included,
170
+ // is encrypted in transit. The backend's NotrikaService used plain http;
171
+ // here we upgrade to https. Residual: the URL (with creds) is still
172
+ // recorded in n8n execution snapshots and the provider's own access logs
173
+ // — inherent to this provider's GET-only API.
174
+ const base = 'https://sms.toolzi.ir/post/Send.asmx';
175
+ const url = operation === 'sendOtp'
176
+ ? `${base}/SendByBaseNumber?username=${enc(c.username)}&password=${enc(c.password)}&to=${enc(to)}&text=${enc(otpCode)}&bodyId=${enc(c.otpBodyId || '302565')}`
177
+ : `${base}/SendSimpleSMS2?username=${enc(c.username)}&password=${enc(c.password)}&to=${enc(to)}&from=${enc(c.senderNumber)}&text=${enc(message)}&isFlash=false`;
178
+ response = await this.helpers.httpRequest({
179
+ method: 'GET',
180
+ url,
181
+ });
182
+ }
183
+ else {
184
+ // batabjamAboard: login → bearer token → bulk send
185
+ const c = await this.getCredentials('batabjamAboardSmsApi', i);
186
+ const login = (await this.helpers.httpRequest({
187
+ method: 'POST',
188
+ url: 'https://panel.batabjam.com/api/login.php',
189
+ body: { username: c.username, password: c.password },
190
+ json: true,
191
+ }));
192
+ const token = login.token;
193
+ if (!token) {
194
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Batabjam Aboard login did not return a token.', { itemIndex: i });
195
+ }
196
+ const text = operation === 'sendOtp' ? `کد تایید بفروش شما: ${otpCode}` : message;
197
+ response = await this.helpers.httpRequest({
198
+ method: 'POST',
199
+ url: 'https://panel.batabjam.com/api/send-bulk-sms.php',
200
+ headers: { Authorization: `Bearer ${token}` },
201
+ body: { numbers: toRecipients(to), message: text },
202
+ json: true,
203
+ });
204
+ }
205
+ returnData.push({
206
+ json: {
207
+ provider,
208
+ operation,
209
+ to,
210
+ success: true,
211
+ response: response,
212
+ },
213
+ pairedItem: { item: i },
214
+ });
215
+ }
216
+ catch (error) {
217
+ if (this.continueOnFail()) {
218
+ returnData.push({
219
+ json: { success: false, error: error.message },
220
+ pairedItem: { item: i },
221
+ });
222
+ continue;
223
+ }
224
+ throw error;
225
+ }
226
+ }
227
+ return [returnData];
228
+ }
229
+ }
230
+ exports.BefrooshSms = BefrooshSms;
231
+ //# sourceMappingURL=BefrooshSms.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BefrooshSms.node.js","sourceRoot":"","sources":["../../../nodes/BefrooshSms/BefrooshSms.node.ts"],"names":[],"mappings":";;;AAAA,+CASsB;AAKtB,qFAAqF;AACrF,SAAS,YAAY,CAAC,GAAW;IAC7B,OAAO,GAAG;SACL,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CAAC;AACz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AC,EAAE;iBAC1B,CAAC,CAAC;YACP,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBACxB,UAAU,CAAC,IAAI,CAAC;wBACZ,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE;wBACzD,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;qBAC1B,CAAC,CAAC;oBACH,SAAS;gBACb,CAAC;gBACD,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;CACJ;AA9OD,kCA8OC"}
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
2
+ <path fill="#2E7D32" d="M4 3h16a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H9l-5 4v-4H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"/>
3
+ <g fill="#FFFFFF">
4
+ <rect x="6" y="8" width="3.2" height="2" rx="1"/>
5
+ <rect x="10.4" y="8" width="3.2" height="2" rx="1"/>
6
+ <rect x="14.8" y="8" width="3.2" height="2" rx="1"/>
7
+ </g>
8
+ </svg>
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@befroosh/n8n-nodes",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Befroosh custom n8n nodes (SMS providers, etc.)",
6
+ "license": "UNLICENSED",
7
+ "author": "Befroosh",
8
+ "keywords": ["n8n", "n8n-community-node-package", "sms"],
9
+ "engines": {
10
+ "node": ">=18"
11
+ },
12
+ "main": "index.js",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "scripts": {
17
+ "build": "rm -rf dist && tsc && node scripts/copy-icons.mjs",
18
+ "dev": "tsc --watch",
19
+ "check-types": "tsc --noEmit",
20
+ "lint": "echo \"(no lint configured for @befroosh/n8n-nodes)\"",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "n8n": {
24
+ "n8nNodesApiVersion": 1,
25
+ "credentials": [
26
+ "dist/credentials/NotrikaSmsApi.credentials.js",
27
+ "dist/credentials/BatabjamSmsApi.credentials.js",
28
+ "dist/credentials/MeliPayamakSmsApi.credentials.js",
29
+ "dist/credentials/BatabjamAboardSmsApi.credentials.js"
30
+ ],
31
+ "nodes": [
32
+ "dist/nodes/BefrooshSms/BefrooshSms.node.js"
33
+ ]
34
+ },
35
+ "files": ["dist"],
36
+ "devDependencies": {
37
+ "@types/node": "^20.11.0",
38
+ "n8n-workflow": "*",
39
+ "typescript": "5.8.2"
40
+ },
41
+ "peerDependencies": {
42
+ "n8n-workflow": "*"
43
+ }
44
+ }