Enforce bind direction, cap segments per message and pin the README examples

This commit is contained in:
2026-08-27 14:07:42 +02:00
parent 8d245c82c4
commit 366fa26b1c
14 changed files with 568 additions and 31 deletions
+25
View File
@@ -243,6 +243,31 @@ describe('sendSms()', () => {
assert.ok(sent.err instanceof Error);
assert.equal(attempts.length, 0);
});
// Most handsets and SMSCs stop well short of the 255 a UDH can number.
test('refuses a message needing more segments than the caller allows', async () => {
const attempts: PduObjectInput[] = [];
const deps = {
log: silentLog,
reference: 3,
send: (input: PduObjectInput) => {
attempts.push(input);
return Promise.resolve({ pduObj: submitResp(attempts.length, `landed-${String(attempts.length)}`) });
},
};
const message = 'a'.repeat(153 * 4);
const refused = await submitSms(deps, { from: '46701113311', maxSegments: 3, message, to: '46709771337' });
assert.ok(refused.err instanceof Error);
assert.equal(attempts.length, 0);
const sent = await submitSms(deps, { from: '46701113311', maxSegments: 4, message, to: '46709771337' });
assert.equal(sent.err, undefined);
assert.equal(attempts.length, 4);
});
});
describe('reconnect', () => {