n8n-nodes-corbit-sms 0.0.0-stage → 1.0.1
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/LICENSE.md +21 -0
- package/README.md +66 -2
- package/dist/credentials/CorbitSmsApi.credentials.d.ts +10 -0
- package/dist/credentials/CorbitSmsApi.credentials.js +49 -0
- package/dist/credentials/CorbitSmsApi.credentials.js.map +1 -0
- package/dist/icons/corbit.dark.svg +1 -0
- package/dist/icons/corbit.svg +1 -0
- package/dist/nodes/CorbitSms/CorbitSms.node.d.ts +10 -0
- package/dist/nodes/CorbitSms/CorbitSms.node.js +168 -0
- package/dist/nodes/CorbitSms/CorbitSms.node.js.map +1 -0
- package/dist/nodes/CorbitSms/CorbitSms.node.json +18 -0
- package/dist/nodes/CorbitSms/CorbitSmsDescription.d.ts +2 -0
- package/dist/nodes/CorbitSms/CorbitSmsDescription.js +201 -0
- package/dist/nodes/CorbitSms/CorbitSmsDescription.js.map +1 -0
- package/dist/nodes/CorbitSms/GenericFunctions.d.ts +14 -0
- package/dist/nodes/CorbitSms/GenericFunctions.js +129 -0
- package/dist/nodes/CorbitSms/GenericFunctions.js.map +1 -0
- package/dist/package.json +63 -0
- package/package.json +61 -4
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ahmed Gamal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# n8n-nodes-corbit-sms
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This is an n8n community node for [Corbit SMS](https://sms.corbit.sa), an SMS gateway in Saudi Arabia. Use it to send SMS messages from your workflows, check whether they were delivered, and read your balance and sender names.
|
|
4
|
+
|
|
5
|
+
[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/sustainable-use-license/) workflow automation platform.
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Operations](#operations)
|
|
9
|
+
- [Credentials](#credentials)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Compatibility](#compatibility)
|
|
12
|
+
- [Resources](#resources)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
In n8n, open **Settings → Community Nodes → Install**, enter `n8n-nodes-corbit-sms` and confirm. For more details, see the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n documentation.
|
|
17
|
+
|
|
18
|
+
## Operations
|
|
19
|
+
|
|
20
|
+
| Resource | Operation | What it does |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| SMS | Send | Sends an SMS to one mobile number |
|
|
23
|
+
| SMS | Send Bulk | Sends the same SMS to many numbers in one request |
|
|
24
|
+
| SMS | Get Status | Returns the current status of a sent message |
|
|
25
|
+
| SMS | Get Delivery Report | Returns the delivery result for each recipient |
|
|
26
|
+
| Account | Get Balance | Returns the remaining SMS balance |
|
|
27
|
+
| Sender Name | Get Many | Lists your sender names and their approval status |
|
|
28
|
+
|
|
29
|
+
The node can also be used as a tool by the n8n AI Agent.
|
|
30
|
+
|
|
31
|
+
## Credentials
|
|
32
|
+
|
|
33
|
+
You need a Corbit SMS account and an API token.
|
|
34
|
+
|
|
35
|
+
1. Sign in at [sms.corbit.sa](https://sms.corbit.sa).
|
|
36
|
+
2. Open the API settings and copy your API token.
|
|
37
|
+
3. In n8n, create a **Corbit SMS API** credential and paste the token.
|
|
38
|
+
|
|
39
|
+
Keep **Base URL** as `https://api.corbit.sa` unless Corbit support gives you another address. n8n checks the credential by reading your balance.
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
**Phone numbers.** Use the international format, for example `9665XXXXXXXX`. Spaces, dashes, a leading `+` or `00` are removed. Saudi local numbers such as `05XXXXXXXX` are converted to `9665XXXXXXXX`.
|
|
44
|
+
|
|
45
|
+
**Sender name.** Only approved sender names appear in the list. You can also enter one with an expression.
|
|
46
|
+
|
|
47
|
+
**Send Bulk.** Enter the numbers separated by commas or new lines, or pass an array with an expression. Duplicates are removed. If any number is invalid, the node stops before sending, because Corbit SMS rejects the whole request.
|
|
48
|
+
|
|
49
|
+
**Message length.** Up to 1600 characters.
|
|
50
|
+
|
|
51
|
+
**Duplicate protection.** Corbit SMS blocks the same text to the same number within one hour. To send it again on purpose (for example an OTP resend), turn on **Allow Duplicate** under **Options**.
|
|
52
|
+
|
|
53
|
+
**Safe retries.** Set an **Idempotency Key** under **Options** (for example `{{ $execution.id }}-{{ $json.orderId }}`). If the request is retried with the same key, Corbit SMS returns the first result and does not send again.
|
|
54
|
+
|
|
55
|
+
**Rate limit.** 1000 requests per minute per token. If you hit it, turn on **Retry On Fail** in the node settings.
|
|
56
|
+
|
|
57
|
+
**Output.** Send returns `messageId`, `status`, `to` and `senderName`. Use `messageId` with Get Status or Get Delivery Report.
|
|
58
|
+
|
|
59
|
+
## Compatibility
|
|
60
|
+
|
|
61
|
+
Tested with n8n 2.46.6 on Node.js 24.
|
|
62
|
+
|
|
63
|
+
## Resources
|
|
64
|
+
|
|
65
|
+
- [n8n community nodes documentation](https://docs.n8n.io/integrations/#community-nodes)
|
|
66
|
+
- [Corbit SMS API documentation](https://api.corbit.sa/doc)
|
|
67
|
+
- [Corbit support](https://corbit.zohodesk.sa/portal/en/newticket) · support@corbit.sa · 920006900
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IAuthenticateGeneric, Icon, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class CorbitSmsApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
icon: Icon;
|
|
6
|
+
documentationUrl: string;
|
|
7
|
+
properties: INodeProperties[];
|
|
8
|
+
authenticate: IAuthenticateGeneric;
|
|
9
|
+
test: ICredentialTestRequest;
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CorbitSmsApi = void 0;
|
|
4
|
+
class CorbitSmsApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'corbitSmsApi';
|
|
7
|
+
this.displayName = 'Corbit SMS API';
|
|
8
|
+
this.icon = { light: 'file:../icons/corbit.svg', dark: 'file:../icons/corbit.dark.svg' };
|
|
9
|
+
this.documentationUrl = 'https://api.corbit.sa/doc';
|
|
10
|
+
this.properties = [
|
|
11
|
+
{
|
|
12
|
+
displayName: 'API Token',
|
|
13
|
+
name: 'apiToken',
|
|
14
|
+
type: 'string',
|
|
15
|
+
typeOptions: { password: true },
|
|
16
|
+
required: true,
|
|
17
|
+
default: '',
|
|
18
|
+
description: 'The API token from your Corbit SMS account at sms.corbit.sa',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
displayName: 'Base URL',
|
|
22
|
+
name: 'baseUrl',
|
|
23
|
+
type: 'string',
|
|
24
|
+
default: 'https://api.corbit.sa',
|
|
25
|
+
description: 'Leave as it is unless Corbit support gives you another address',
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
this.authenticate = {
|
|
29
|
+
type: 'generic',
|
|
30
|
+
properties: {
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: '=Bearer {{$credentials.apiToken}}',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
this.test = {
|
|
37
|
+
request: {
|
|
38
|
+
baseURL: '={{$credentials.baseUrl.replace(/\\/+$/, "")}}',
|
|
39
|
+
url: '/api/v1/get-balance',
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: {
|
|
42
|
+
Accept: 'application/json',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.CorbitSmsApi = CorbitSmsApi;
|
|
49
|
+
//# sourceMappingURL=CorbitSmsApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CorbitSmsApi.credentials.js","sourceRoot":"","sources":["../../credentials/CorbitSmsApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,YAAY;IAAzB;QACC,SAAI,GAAG,cAAc,CAAC;QAEtB,gBAAW,GAAG,gBAAgB,CAAC;QAE/B,SAAI,GAAS,EAAE,KAAK,EAAE,0BAA0B,EAAE,IAAI,EAAE,+BAA+B,EAAE,CAAC;QAE1F,qBAAgB,GAAG,2BAA2B,CAAC;QAE/C,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EACV,6DAA6D;aAC9D;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,uBAAuB;gBAChC,WAAW,EAAE,gEAAgE;aAC7E;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,aAAa,EAAE,mCAAmC;iBAClD;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,gDAAgD;gBACzD,GAAG,EAAE,qBAAqB;gBAC1B,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACR,MAAM,EAAE,kBAAkB;iBAC1B;aACD;SACD,CAAC;IACH,CAAC;CAAA;AAhDD,oCAgDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#F7934C"/><stop offset="1" stop-color="#E91E8C"/></linearGradient></defs><path d="M12.95 43.00A22 22 0 0 1 30.08 10.08" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M43.00 12.95A22 22 0 0 1 48.85 46.14" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M43.00 51.05A22 22 0 0 1 21.00 51.05" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M9.16 42.17A25 25 0 0 1 28.09 7.31" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M46.34 11.52A25 25 0 0 1 52.73 45.98" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M42.96 54.47A25 25 0 0 1 20.65 54.28" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M5.37 40.65A28 28 0 0 1 25.70 4.72" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M50.00 10.55A28 28 0 0 1 56.72 45.15" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M42.49 57.96A28 28 0 0 1 20.61 57.58" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M24 20h16a4 4 0 0 1 4 4v10a4 4 0 0 1-4 4H30l-6 5v-5a4 4 0 0 1-4-4V24a4 4 0 0 1 4-4z" fill="url(#g)"/><circle cx="26.5" cy="29" r="2" fill="#fff"/><circle cx="32" cy="29" r="2" fill="#fff"/><circle cx="37.5" cy="29" r="2" fill="#fff"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#F7934C"/><stop offset="1" stop-color="#E91E8C"/></linearGradient></defs><path d="M12.95 43.00A22 22 0 0 1 30.08 10.08" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M43.00 12.95A22 22 0 0 1 48.85 46.14" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M43.00 51.05A22 22 0 0 1 21.00 51.05" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M9.16 42.17A25 25 0 0 1 28.09 7.31" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M46.34 11.52A25 25 0 0 1 52.73 45.98" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M42.96 54.47A25 25 0 0 1 20.65 54.28" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M5.37 40.65A28 28 0 0 1 25.70 4.72" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M50.00 10.55A28 28 0 0 1 56.72 45.15" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M42.49 57.96A28 28 0 0 1 20.61 57.58" stroke="url(#g)" stroke-width="1.6" fill="none" stroke-linecap="round"/><path d="M24 20h16a4 4 0 0 1 4 4v10a4 4 0 0 1-4 4H30l-6 5v-5a4 4 0 0 1-4-4V24a4 4 0 0 1 4-4z" fill="url(#g)"/><circle cx="26.5" cy="29" r="2" fill="#fff"/><circle cx="32" cy="29" r="2" fill="#fff"/><circle cx="37.5" cy="29" r="2" fill="#fff"/></svg>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class CorbitSms implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getSenderNames(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CorbitSms = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
|
+
const CorbitSmsDescription_1 = require("./CorbitSmsDescription");
|
|
7
|
+
class CorbitSms {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.description = {
|
|
10
|
+
displayName: 'Corbit SMS',
|
|
11
|
+
name: 'corbitSms',
|
|
12
|
+
icon: { light: 'file:../../icons/corbit.svg', dark: 'file:../../icons/corbit.dark.svg' },
|
|
13
|
+
group: ['output'],
|
|
14
|
+
version: 1,
|
|
15
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
16
|
+
description: 'Send SMS messages and check delivery with Corbit SMS',
|
|
17
|
+
defaults: {
|
|
18
|
+
name: 'Corbit SMS',
|
|
19
|
+
},
|
|
20
|
+
usableAsTool: true,
|
|
21
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
22
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
23
|
+
credentials: [
|
|
24
|
+
{
|
|
25
|
+
name: 'corbitSmsApi',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
properties: CorbitSmsDescription_1.nodeProperties,
|
|
30
|
+
};
|
|
31
|
+
this.methods = {
|
|
32
|
+
loadOptions: {
|
|
33
|
+
async getSenderNames() {
|
|
34
|
+
const senders = await GenericFunctions_1.getAllSenderNames.call(this);
|
|
35
|
+
return senders
|
|
36
|
+
.filter((s) => String(s.status).toLowerCase() === 'approved')
|
|
37
|
+
.map((s) => ({ name: String(s.name), value: String(s.name) }))
|
|
38
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async execute() {
|
|
44
|
+
var _a, _b, _c, _d, _e, _f;
|
|
45
|
+
const items = this.getInputData();
|
|
46
|
+
const returnData = [];
|
|
47
|
+
const node = this.getNode();
|
|
48
|
+
for (let i = 0; i < items.length; i++) {
|
|
49
|
+
try {
|
|
50
|
+
const resource = this.getNodeParameter('resource', i);
|
|
51
|
+
const operation = this.getNodeParameter('operation', i);
|
|
52
|
+
if (resource === 'sms' && (operation === 'send' || operation === 'sendBulk')) {
|
|
53
|
+
const senderName = String(this.getNodeParameter('senderName', i)).trim();
|
|
54
|
+
const message = this.getNodeParameter('message', i);
|
|
55
|
+
const options = this.getNodeParameter('options', i, {});
|
|
56
|
+
if (senderName === '') {
|
|
57
|
+
throw new n8n_workflow_1.NodeOperationError(node, 'Choose a sender name', { itemIndex: i });
|
|
58
|
+
}
|
|
59
|
+
(0, GenericFunctions_1.checkMessage)(node, message, i);
|
|
60
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
61
|
+
if (options.idempotencyKey)
|
|
62
|
+
headers['Idempotency-Key'] = String(options.idempotencyKey);
|
|
63
|
+
if (options.allowDuplicate === true)
|
|
64
|
+
headers['X-Allow-Duplicate'] = 'true';
|
|
65
|
+
if (operation === 'send') {
|
|
66
|
+
const raw = this.getNodeParameter('to', i);
|
|
67
|
+
const number = (0, GenericFunctions_1.normalizeNumber)(raw);
|
|
68
|
+
if (!number) {
|
|
69
|
+
throw new n8n_workflow_1.NodeOperationError(node, `"${raw}" is not a valid mobile number (use the international format, e.g. 9665XXXXXXXX)`, { itemIndex: i });
|
|
70
|
+
}
|
|
71
|
+
const response = await GenericFunctions_1.corbitApiRequest.call(this, 'POST', '/api/v1/send', { senderName, number, messageBody: message, sendAtOption: 'NOW' }, { headers, itemIndex: i });
|
|
72
|
+
const sent = ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : {});
|
|
73
|
+
returnData.push({
|
|
74
|
+
json: { messageId: sent.id, status: sent.status, to: number, senderName },
|
|
75
|
+
pairedItem: { item: i },
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const raw = (0, GenericFunctions_1.splitNumbers)(this.getNodeParameter('numbers', i));
|
|
80
|
+
const invalid = raw.filter((n) => !(0, GenericFunctions_1.normalizeNumber)(n));
|
|
81
|
+
if (invalid.length > 0) {
|
|
82
|
+
throw new n8n_workflow_1.NodeOperationError(node, `Invalid mobile number(s): ${invalid.slice(0, 5).join(', ')}${invalid.length > 5 ? ` and ${invalid.length - 5} more` : ''}`, {
|
|
83
|
+
itemIndex: i,
|
|
84
|
+
description: 'Corbit SMS rejects the whole request if any number is invalid, so nothing was sent.',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const numbers = [...new Set(raw.map((n) => (0, GenericFunctions_1.normalizeNumber)(n)))];
|
|
88
|
+
if (numbers.length === 0) {
|
|
89
|
+
throw new n8n_workflow_1.NodeOperationError(node, 'Add at least one mobile number', {
|
|
90
|
+
itemIndex: i,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const response = await GenericFunctions_1.corbitApiRequest.call(this, 'POST', '/api/v1/send-bulk', { senderName, numbers, messageBody: message, sendAtOption: 'Now' }, { headers, itemIndex: i });
|
|
94
|
+
const sent = ((_d = (_c = response.data) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : {});
|
|
95
|
+
returnData.push({
|
|
96
|
+
json: {
|
|
97
|
+
messageId: sent.id,
|
|
98
|
+
status: sent.status,
|
|
99
|
+
recipients: numbers.length,
|
|
100
|
+
numbers,
|
|
101
|
+
senderName,
|
|
102
|
+
},
|
|
103
|
+
pairedItem: { item: i },
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (resource === 'sms' && (operation === 'getStatus' || operation === 'getReport')) {
|
|
108
|
+
const messageId = String(this.getNodeParameter('messageId', i)).trim();
|
|
109
|
+
if (messageId === '') {
|
|
110
|
+
throw new n8n_workflow_1.NodeOperationError(node, 'Enter the message ID', { itemIndex: i });
|
|
111
|
+
}
|
|
112
|
+
const path = operation === 'getStatus' ? '/api/v1/message-status/' : '/api/v1/message-report/';
|
|
113
|
+
const response = await GenericFunctions_1.corbitApiRequest.call(this, 'POST', path + encodeURIComponent(messageId), undefined, { itemIndex: i });
|
|
114
|
+
if (operation === 'getStatus') {
|
|
115
|
+
const data = ((_e = response.data) !== null && _e !== void 0 ? _e : {});
|
|
116
|
+
returnData.push({
|
|
117
|
+
json: { messageId, status: data.status },
|
|
118
|
+
pairedItem: { item: i },
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
returnData.push({ json: { messageId, ...response }, pairedItem: { item: i } });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (resource === 'account' && operation === 'getBalance') {
|
|
126
|
+
const response = await GenericFunctions_1.corbitApiRequest.call(this, 'POST', '/api/v1/get-balance', undefined, {
|
|
127
|
+
itemIndex: i,
|
|
128
|
+
});
|
|
129
|
+
const data = ((_f = response.data) !== null && _f !== void 0 ? _f : {});
|
|
130
|
+
returnData.push({ json: { balance: data.balance }, pairedItem: { item: i } });
|
|
131
|
+
}
|
|
132
|
+
else if (resource === 'senderName' && operation === 'getAll') {
|
|
133
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
134
|
+
const filters = this.getNodeParameter('filters', i, {});
|
|
135
|
+
let senders = await GenericFunctions_1.getAllSenderNames.call(this);
|
|
136
|
+
if (filters.status) {
|
|
137
|
+
const wanted = String(filters.status).toLowerCase();
|
|
138
|
+
senders = senders.filter((s) => String(s.status).toLowerCase() === wanted);
|
|
139
|
+
}
|
|
140
|
+
if (!returnAll) {
|
|
141
|
+
const limit = this.getNodeParameter('limit', i);
|
|
142
|
+
senders = senders.slice(0, limit);
|
|
143
|
+
}
|
|
144
|
+
returnData.push(...senders.map((s) => ({ json: s, pairedItem: { item: i } })));
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
throw new n8n_workflow_1.NodeOperationError(node, `The operation "${operation}" is not supported for "${resource}"`, { itemIndex: i });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (this.continueOnFail()) {
|
|
152
|
+
returnData.push({
|
|
153
|
+
json: { error: error.message },
|
|
154
|
+
pairedItem: { item: i },
|
|
155
|
+
});
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (error instanceof n8n_workflow_1.NodeApiError) {
|
|
159
|
+
throw new n8n_workflow_1.NodeApiError(node, error, { itemIndex: i });
|
|
160
|
+
}
|
|
161
|
+
throw new n8n_workflow_1.NodeOperationError(node, error, { itemIndex: i });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return [returnData];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.CorbitSms = CorbitSms;
|
|
168
|
+
//# sourceMappingURL=CorbitSms.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CorbitSms.node.js","sourceRoot":"","sources":["../../../nodes/CorbitSms/CorbitSms.node.ts"],"names":[],"mappings":";;;AAaA,+CAAqF;AACrF,yDAM4B;AAC5B,iEAAwD;AAExD,MAAa,SAAS;IAAtB;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,YAAY;YACzB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,EAAE,KAAK,EAAE,6BAA6B,EAAE,IAAI,EAAE,kCAAkC,EAAE;YACxF,KAAK,EAAE,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,sDAAsD;YACnE,QAAQ,EAAE;gBACT,IAAI,EAAE,YAAY;aAClB;YACD,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,cAAc;oBACpB,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,UAAU,EAAE,qCAAc;SAC1B,CAAC;QAEF,YAAO,GAAG;YACT,WAAW,EAAE;gBACZ,KAAK,CAAC,cAAc;oBACnB,MAAM,OAAO,GAAG,MAAM,oCAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACnD,OAAO,OAAO;yBACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC;yBAC5D,GAAG,CAAC,CAA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AC;oBACnC,MAAM,IAAI,2BAAY,CAAC,IAAI,EAAE,KAA8B,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;gBAChF,CAAC;gBACD,MAAM,IAAI,iCAAkB,CAAC,IAAI,EAAE,KAAc,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;YACtE,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AAnMD,8BAmMC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-corbit-sms.corbitSms",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["Communication"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://api.corbit.sa/doc"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://github.com/agamalsa/n8n-nodes-corbit-sms#readme"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nodeProperties = void 0;
|
|
4
|
+
const sendOps = ['send', 'sendBulk'];
|
|
5
|
+
exports.nodeProperties = [
|
|
6
|
+
{
|
|
7
|
+
displayName: 'Resource',
|
|
8
|
+
name: 'resource',
|
|
9
|
+
type: 'options',
|
|
10
|
+
noDataExpression: true,
|
|
11
|
+
options: [
|
|
12
|
+
{ name: 'Account', value: 'account' },
|
|
13
|
+
{ name: 'Sender Name', value: 'senderName' },
|
|
14
|
+
{ name: 'SMS', value: 'sms' },
|
|
15
|
+
],
|
|
16
|
+
default: 'sms',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Operation',
|
|
20
|
+
name: 'operation',
|
|
21
|
+
type: 'options',
|
|
22
|
+
noDataExpression: true,
|
|
23
|
+
displayOptions: { show: { resource: ['sms'] } },
|
|
24
|
+
options: [
|
|
25
|
+
{
|
|
26
|
+
name: 'Get Delivery Report',
|
|
27
|
+
value: 'getReport',
|
|
28
|
+
action: 'Get the delivery report of a message',
|
|
29
|
+
description: 'Get the delivery result for each recipient of a message',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Get Status',
|
|
33
|
+
value: 'getStatus',
|
|
34
|
+
action: 'Get the status of a message',
|
|
35
|
+
description: 'Get the current status of a sent message',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Send',
|
|
39
|
+
value: 'send',
|
|
40
|
+
action: 'Send an SMS',
|
|
41
|
+
description: 'Send an SMS to one mobile number',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Send Bulk',
|
|
45
|
+
value: 'sendBulk',
|
|
46
|
+
action: 'Send an SMS to many numbers',
|
|
47
|
+
description: 'Send the same SMS to many mobile numbers in one request',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
default: 'send',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
displayName: 'Operation',
|
|
54
|
+
name: 'operation',
|
|
55
|
+
type: 'options',
|
|
56
|
+
noDataExpression: true,
|
|
57
|
+
displayOptions: { show: { resource: ['account'] } },
|
|
58
|
+
options: [
|
|
59
|
+
{
|
|
60
|
+
name: 'Get Balance',
|
|
61
|
+
value: 'getBalance',
|
|
62
|
+
action: 'Get the account balance',
|
|
63
|
+
description: 'Get the remaining SMS balance of the account',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
default: 'getBalance',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
displayName: 'Operation',
|
|
70
|
+
name: 'operation',
|
|
71
|
+
type: 'options',
|
|
72
|
+
noDataExpression: true,
|
|
73
|
+
displayOptions: { show: { resource: ['senderName'] } },
|
|
74
|
+
options: [
|
|
75
|
+
{
|
|
76
|
+
name: 'Get Many',
|
|
77
|
+
value: 'getAll',
|
|
78
|
+
action: 'Get many sender names',
|
|
79
|
+
description: 'Get the sender names on the account and their approval status',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
default: 'getAll',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
displayName: 'Sender Name or ID',
|
|
86
|
+
name: 'senderName',
|
|
87
|
+
type: 'options',
|
|
88
|
+
typeOptions: { loadOptionsMethod: 'getSenderNames' },
|
|
89
|
+
required: true,
|
|
90
|
+
default: '',
|
|
91
|
+
displayOptions: { show: { resource: ['sms'], operation: sendOps } },
|
|
92
|
+
description: 'Approved sender name the message is sent from. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
displayName: 'To',
|
|
96
|
+
name: 'to',
|
|
97
|
+
type: 'string',
|
|
98
|
+
required: true,
|
|
99
|
+
default: '',
|
|
100
|
+
placeholder: '9665XXXXXXXX',
|
|
101
|
+
displayOptions: { show: { resource: ['sms'], operation: ['send'] } },
|
|
102
|
+
description: 'Mobile number in international format. Saudi local numbers such as 05XXXXXXXX are converted automatically.',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
displayName: 'Numbers',
|
|
106
|
+
name: 'numbers',
|
|
107
|
+
type: 'string',
|
|
108
|
+
typeOptions: { rows: 4 },
|
|
109
|
+
required: true,
|
|
110
|
+
default: '',
|
|
111
|
+
placeholder: '9665XXXXXXXX, 9665YYYYYYYY',
|
|
112
|
+
displayOptions: { show: { resource: ['sms'], operation: ['sendBulk'] } },
|
|
113
|
+
description: 'Mobile numbers separated by commas or new lines, or an array from an expression. If any number is invalid nothing is sent.',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
displayName: 'Message',
|
|
117
|
+
name: 'message',
|
|
118
|
+
type: 'string',
|
|
119
|
+
typeOptions: { rows: 4 },
|
|
120
|
+
required: true,
|
|
121
|
+
default: '',
|
|
122
|
+
displayOptions: { show: { resource: ['sms'], operation: sendOps } },
|
|
123
|
+
description: 'Text of the SMS, up to 1600 characters',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
displayName: 'Options',
|
|
127
|
+
name: 'options',
|
|
128
|
+
type: 'collection',
|
|
129
|
+
placeholder: 'Add Option',
|
|
130
|
+
default: {},
|
|
131
|
+
displayOptions: { show: { resource: ['sms'], operation: sendOps } },
|
|
132
|
+
options: [
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Allow Duplicate',
|
|
135
|
+
name: 'allowDuplicate',
|
|
136
|
+
type: 'boolean',
|
|
137
|
+
default: false,
|
|
138
|
+
description: 'Whether to send the message even if the same text went to the same number in the last hour (for example an OTP resend)',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
displayName: 'Idempotency Key',
|
|
142
|
+
name: 'idempotencyKey',
|
|
143
|
+
type: 'string',
|
|
144
|
+
default: '',
|
|
145
|
+
description: 'A unique value (up to 255 characters). If the request is retried with the same key, the first result is returned and nothing is sent again.',
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
displayName: 'Message ID',
|
|
151
|
+
name: 'messageId',
|
|
152
|
+
type: 'string',
|
|
153
|
+
required: true,
|
|
154
|
+
default: '',
|
|
155
|
+
displayOptions: { show: { resource: ['sms'], operation: ['getStatus', 'getReport'] } },
|
|
156
|
+
description: 'The message ID returned by the Send or Send Bulk operation',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
displayName: 'Return All',
|
|
160
|
+
name: 'returnAll',
|
|
161
|
+
type: 'boolean',
|
|
162
|
+
default: false,
|
|
163
|
+
displayOptions: { show: { resource: ['senderName'], operation: ['getAll'] } },
|
|
164
|
+
description: 'Whether to return all results or only up to a given limit',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
displayName: 'Limit',
|
|
168
|
+
name: 'limit',
|
|
169
|
+
type: 'number',
|
|
170
|
+
typeOptions: { minValue: 1 },
|
|
171
|
+
default: 50,
|
|
172
|
+
displayOptions: {
|
|
173
|
+
show: { resource: ['senderName'], operation: ['getAll'], returnAll: [false] },
|
|
174
|
+
},
|
|
175
|
+
description: 'Max number of results to return',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
displayName: 'Filters',
|
|
179
|
+
name: 'filters',
|
|
180
|
+
type: 'collection',
|
|
181
|
+
placeholder: 'Add Filter',
|
|
182
|
+
default: {},
|
|
183
|
+
displayOptions: { show: { resource: ['senderName'], operation: ['getAll'] } },
|
|
184
|
+
options: [
|
|
185
|
+
{
|
|
186
|
+
displayName: 'Status',
|
|
187
|
+
name: 'status',
|
|
188
|
+
type: 'options',
|
|
189
|
+
options: [
|
|
190
|
+
{ name: 'Approved', value: 'approved' },
|
|
191
|
+
{ name: 'Expired', value: 'expired' },
|
|
192
|
+
{ name: 'Pending', value: 'pending' },
|
|
193
|
+
{ name: 'Rejected', value: 'rejected' },
|
|
194
|
+
],
|
|
195
|
+
default: 'approved',
|
|
196
|
+
description: 'Return only sender names with this status',
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
];
|
|
201
|
+
//# sourceMappingURL=CorbitSmsDescription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CorbitSmsDescription.js","sourceRoot":"","sources":["../../../nodes/CorbitSms/CorbitSmsDescription.ts"],"names":[],"mappings":";;;AAEA,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAExB,QAAA,cAAc,GAAsB;IAChD;QACC,WAAW,EAAE,UAAU;QACvB,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE;YACR,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAA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BACnB,WAAW,EAAE,2CAA2C;aACxD;SACD;KACD;CACD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IDataObject, IExecuteFunctions, IHttpRequestMethods, ILoadOptionsFunctions, INode } from 'n8n-workflow';
|
|
2
|
+
export declare const MAX_MESSAGE_LENGTH = 1600;
|
|
3
|
+
type Context = IExecuteFunctions | ILoadOptionsFunctions;
|
|
4
|
+
export interface CorbitRequestExtras {
|
|
5
|
+
qs?: IDataObject;
|
|
6
|
+
headers?: IDataObject;
|
|
7
|
+
itemIndex?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function normalizeNumber(raw: unknown): string | undefined;
|
|
10
|
+
export declare function splitNumbers(value: unknown): string[];
|
|
11
|
+
export declare function checkMessage(node: INode, message: string, itemIndex: number): void;
|
|
12
|
+
export declare function corbitApiRequest(this: Context, method: IHttpRequestMethods, path: string, body?: IDataObject, extras?: CorbitRequestExtras): Promise<IDataObject>;
|
|
13
|
+
export declare function getAllSenderNames(this: Context): Promise<IDataObject[]>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_MESSAGE_LENGTH = void 0;
|
|
4
|
+
exports.normalizeNumber = normalizeNumber;
|
|
5
|
+
exports.splitNumbers = splitNumbers;
|
|
6
|
+
exports.checkMessage = checkMessage;
|
|
7
|
+
exports.corbitApiRequest = corbitApiRequest;
|
|
8
|
+
exports.getAllSenderNames = getAllSenderNames;
|
|
9
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
10
|
+
exports.MAX_MESSAGE_LENGTH = 1600;
|
|
11
|
+
function normalizeNumber(raw) {
|
|
12
|
+
if (raw === null || raw === undefined)
|
|
13
|
+
return undefined;
|
|
14
|
+
let digits = String(raw).replace(/\D/g, '');
|
|
15
|
+
if (digits.startsWith('00'))
|
|
16
|
+
digits = digits.slice(2);
|
|
17
|
+
if (/^05\d{8}$/.test(digits))
|
|
18
|
+
digits = '966' + digits.slice(1);
|
|
19
|
+
else if (/^5\d{8}$/.test(digits))
|
|
20
|
+
digits = '966' + digits;
|
|
21
|
+
return /^\d{8,15}$/.test(digits) ? digits : undefined;
|
|
22
|
+
}
|
|
23
|
+
function splitNumbers(value) {
|
|
24
|
+
if (Array.isArray(value))
|
|
25
|
+
return value.flatMap((v) => splitNumbers(v));
|
|
26
|
+
if (value === null || value === undefined)
|
|
27
|
+
return [];
|
|
28
|
+
return String(value)
|
|
29
|
+
.split(/[,;\r\n]+/)
|
|
30
|
+
.map((v) => v.trim())
|
|
31
|
+
.filter((v) => v !== '');
|
|
32
|
+
}
|
|
33
|
+
function checkMessage(node, message, itemIndex) {
|
|
34
|
+
if (message.trim() === '') {
|
|
35
|
+
throw new n8n_workflow_1.NodeOperationError(node, 'The message is empty', { itemIndex });
|
|
36
|
+
}
|
|
37
|
+
if (message.length > exports.MAX_MESSAGE_LENGTH) {
|
|
38
|
+
throw new n8n_workflow_1.NodeOperationError(node, `The message is ${message.length} characters; the limit is ${exports.MAX_MESSAGE_LENGTH}`, { itemIndex });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function errorFromBody(node, statusCode, body, headers, itemIndex) {
|
|
42
|
+
const apiMessage = typeof body.message === 'string' && body.message ? body.message : '';
|
|
43
|
+
const code = typeof body.code === 'string' ? body.code : '';
|
|
44
|
+
let description = code ? `Error code: ${code}` : undefined;
|
|
45
|
+
if (statusCode === 401) {
|
|
46
|
+
description = 'The API token was rejected. Check the token in the Corbit SMS credential.';
|
|
47
|
+
}
|
|
48
|
+
else if (statusCode === 429) {
|
|
49
|
+
const retryAfter = headers['retry-after'];
|
|
50
|
+
description = `Too many requests. ${retryAfter ? `Try again in ${String(retryAfter)} seconds. ` : ''}You can turn on "Retry On Fail" in the node settings.`;
|
|
51
|
+
}
|
|
52
|
+
else if (code === 'DUPLICATE') {
|
|
53
|
+
description =
|
|
54
|
+
'The same text was sent to the same number within the last hour. Turn on "Allow Duplicate" to send it again on purpose.';
|
|
55
|
+
}
|
|
56
|
+
return new n8n_workflow_1.NodeApiError(node, body, {
|
|
57
|
+
message: apiMessage || `Corbit SMS returned HTTP ${statusCode}`,
|
|
58
|
+
description,
|
|
59
|
+
httpCode: String(statusCode),
|
|
60
|
+
itemIndex,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async function corbitApiRequest(method, path, body, extras = {}) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
const credentials = await this.getCredentials('corbitSmsApi');
|
|
66
|
+
const baseUrl = String(credentials.baseUrl || 'https://api.corbit.sa').replace(/\/+$/, '');
|
|
67
|
+
const options = {
|
|
68
|
+
method,
|
|
69
|
+
url: `${baseUrl}${path}`,
|
|
70
|
+
headers: { Accept: 'application/json', ...((_a = extras.headers) !== null && _a !== void 0 ? _a : {}) },
|
|
71
|
+
json: true,
|
|
72
|
+
returnFullResponse: true,
|
|
73
|
+
ignoreHttpStatusErrors: true,
|
|
74
|
+
};
|
|
75
|
+
if (body !== undefined)
|
|
76
|
+
options.body = body;
|
|
77
|
+
if (extras.qs !== undefined)
|
|
78
|
+
options.qs = extras.qs;
|
|
79
|
+
let response;
|
|
80
|
+
try {
|
|
81
|
+
response = (await this.helpers.httpRequestWithAuthentication.call(this, 'corbitSmsApi', options));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, { itemIndex: extras.itemIndex });
|
|
85
|
+
}
|
|
86
|
+
const statusCode = Number(response.statusCode);
|
|
87
|
+
let data = response.body;
|
|
88
|
+
if (typeof data === 'string') {
|
|
89
|
+
try {
|
|
90
|
+
data = JSON.parse(data);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
data = { message: data };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const parsed = data && typeof data === 'object' && !Array.isArray(data) ? data : {};
|
|
97
|
+
if (statusCode >= 400 || parsed.status === 'Error') {
|
|
98
|
+
throw errorFromBody(this.getNode(), statusCode >= 400 ? statusCode : 400, parsed, (_b = response.headers) !== null && _b !== void 0 ? _b : {}, extras.itemIndex);
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(data))
|
|
101
|
+
return { data };
|
|
102
|
+
return parsed;
|
|
103
|
+
}
|
|
104
|
+
async function getAllSenderNames() {
|
|
105
|
+
var _a;
|
|
106
|
+
const perPage = 50;
|
|
107
|
+
const all = [];
|
|
108
|
+
for (let page = 1; page <= 100; page++) {
|
|
109
|
+
const response = await corbitApiRequest.call(this, 'GET', '/api/v1/sendernames', undefined, {
|
|
110
|
+
qs: { per_page: perPage, page },
|
|
111
|
+
});
|
|
112
|
+
const items = Array.isArray(response.data) ? response.data : [];
|
|
113
|
+
all.push(...items);
|
|
114
|
+
const pagination = ((_a = response.pagination) !== null && _a !== void 0 ? _a : {});
|
|
115
|
+
const total = Number(pagination.total);
|
|
116
|
+
const currentPage = Number(pagination.current_page);
|
|
117
|
+
const pageSize = Number(pagination.per_page) || perPage;
|
|
118
|
+
if (items.length === 0)
|
|
119
|
+
break;
|
|
120
|
+
if (Number.isFinite(total) && all.length >= total)
|
|
121
|
+
break;
|
|
122
|
+
if (!Number.isFinite(total) && items.length < pageSize)
|
|
123
|
+
break;
|
|
124
|
+
if (Number.isFinite(currentPage) && currentPage !== page)
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return all;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=GenericFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenericFunctions.js","sourceRoot":"","sources":["../../../nodes/CorbitSms/GenericFunctions.ts"],"names":[],"mappings":";;;AA0BA,0CAOC;AAGD,oCAOC;AAED,oCAWC;AAmCD,4CAuDC;AAGD,8CAoBC;AAhKD,+CAAgE;AAEnD,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAevC,SAAgB,eAAe,CAA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AqB,EAAE,SAAS,EAAE;YAC3F,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE;SAC/B,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,QAAQ,CAAC,IAAsB,CAAC,CAAC,CAAC,EAAE,CAAC;QACnF,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QACnB,MAAM,UAAU,GAAG,CAAC,MAAA,QAAQ,CAAC,UAAU,mCAAI,EAAE,CAAgB,CAAC;QAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACvC,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC;QACxD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM;QAC9B,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,KAAK;YAAE,MAAM;QACzD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,QAAQ;YAAE,MAAM;QAE9D,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,KAAK,IAAI;YAAE,MAAM;IACjE,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-corbit-sms",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "n8n node for Corbit SMS: send SMS (single and bulk), check delivery status and reports, read the balance and sender names.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/agamalsa/n8n-nodes-corbit-sms#readme",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"n8n-community-node-package",
|
|
9
|
+
"n8n",
|
|
10
|
+
"corbit",
|
|
11
|
+
"sms",
|
|
12
|
+
"saudi-arabia",
|
|
13
|
+
"otp"
|
|
14
|
+
],
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Ahmed Gamal",
|
|
17
|
+
"email": "a.gamal@corbit.sa"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/agamalsa/n8n-nodes-corbit-sms.git"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "n8n-node build",
|
|
25
|
+
"build:watch": "tsc --watch",
|
|
26
|
+
"dev": "n8n-node dev",
|
|
27
|
+
"lint": "n8n-node lint",
|
|
28
|
+
"lint:fix": "n8n-node lint --fix",
|
|
29
|
+
"release": "n8n-node release",
|
|
30
|
+
"prepublishOnly": "n8n-node prerelease",
|
|
31
|
+
"test": "node --test test/*.test.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"!dist/tsconfig.tsbuildinfo"
|
|
36
|
+
],
|
|
37
|
+
"n8n": {
|
|
38
|
+
"n8nNodesApiVersion": 1,
|
|
39
|
+
"strict": true,
|
|
40
|
+
"credentials": [
|
|
41
|
+
"dist/credentials/CorbitSmsApi.credentials.js"
|
|
42
|
+
],
|
|
43
|
+
"nodes": [
|
|
44
|
+
"dist/nodes/CorbitSms/CorbitSms.node.js"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@n8n/node-cli": "*",
|
|
49
|
+
"eslint": "9.32.0",
|
|
50
|
+
"prettier": "3.6.2",
|
|
51
|
+
"release-it": "^21.1.0",
|
|
52
|
+
"typescript": "5.9.2"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"n8n-workflow": "*"
|
|
56
|
+
},
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/agamalsa/n8n-nodes-corbit-sms/issues"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-corbit-sms",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "n8n node for Corbit SMS: send SMS (single and bulk), check delivery status and reports, read the balance and sender names.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/agamalsa/n8n-nodes-corbit-sms#readme",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"n8n-community-node-package",
|
|
9
|
+
"n8n",
|
|
10
|
+
"corbit",
|
|
11
|
+
"sms",
|
|
12
|
+
"saudi-arabia",
|
|
13
|
+
"otp"
|
|
14
|
+
],
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Ahmed Gamal",
|
|
17
|
+
"email": "a.gamal@corbit.sa"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/agamalsa/n8n-nodes-corbit-sms.git"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "n8n-node build",
|
|
25
|
+
"build:watch": "tsc --watch",
|
|
26
|
+
"dev": "n8n-node dev",
|
|
27
|
+
"lint": "n8n-node lint",
|
|
28
|
+
"lint:fix": "n8n-node lint --fix",
|
|
29
|
+
"release": "n8n-node release",
|
|
30
|
+
"prepublishOnly": "n8n-node prerelease",
|
|
31
|
+
"test": "node --test test/*.test.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"!dist/tsconfig.tsbuildinfo"
|
|
36
|
+
],
|
|
37
|
+
"n8n": {
|
|
38
|
+
"n8nNodesApiVersion": 1,
|
|
39
|
+
"strict": true,
|
|
40
|
+
"credentials": [
|
|
41
|
+
"dist/credentials/CorbitSmsApi.credentials.js"
|
|
42
|
+
],
|
|
43
|
+
"nodes": [
|
|
44
|
+
"dist/nodes/CorbitSms/CorbitSms.node.js"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@n8n/node-cli": "*",
|
|
49
|
+
"eslint": "9.32.0",
|
|
50
|
+
"prettier": "3.6.2",
|
|
51
|
+
"release-it": "^21.1.0",
|
|
52
|
+
"typescript": "5.9.2"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"n8n-workflow": "*"
|
|
56
|
+
},
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/agamalsa/n8n-nodes-corbit-sms/issues"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
}
|
|
63
|
+
}
|