Skip to content

feat: complete SipConfiguration attributes for API 2026-04-16#42

Merged
Fivell merged 5 commits into
mainfrom
feat/incoming-auth-credentials
May 5, 2026
Merged

feat: complete SipConfiguration attributes for API 2026-04-16#42
Fivell merged 5 commits into
mainfrom
feat/incoming-auth-credentials

Conversation

@Fivell

@Fivell Fivell commented Apr 30, 2026

Copy link
Copy Markdown
Member

Summary

Completes the API 2026-04-16 SipConfiguration attribute set. Mirrors the Ruby reference PR #80.

5 writable attributes (missed during the original 2026-04-16 rollout)

These attributes the server accepts under API 2026-04-16 and are listed in the public 2026-04-16 changelog, but were absent from both this SDK and the public Postman collection. Server is authoritative — added all five:

TypeScript field Wire Type
enabledSipRegistration enabled_sip_registration boolean
useDidInRuri use_did_in_ruri boolean
networkProtocolPriority network_protocol_priority force_ipv4 | force_ipv6 | any | prefer_ipv4 | prefer_ipv6
diversionInjectMode diversion_inject_mode none | did_number
cnamLookup cnam_lookup boolean

Two new TypeScript enums added: DiversionInjectMode, NetworkProtocolPriority.

2 read-only attributes

Server-generated, returned only when enabledSipRegistration: true:

  • incomingAuthUsername
  • incomingAuthPassword

The API rejects writes (400 Param not allowed). The SDK enforces this in two layers:

  1. Type-level: a new SipConfigurationInput type used by the sipConfiguration() builder excludes the read-only keys via Omit<>.
  2. Runtime defense: serializeTrunkConfiguration strips incomingAuthUsername / incomingAuthPassword from the outgoing JSON:API attributes, so callers who mutate a read-shape object loaded from a GET response cannot accidentally echo them back.

Misc

  • Bumped to 3.1.0 (package.json + package-lock.json).

Test plan

  • npm run typecheck — clean
  • npm test — 506 tests passing (47 files), 100% coverage
  • New tests: serialize writable 2026-04-16 attrs, deserialize read-only incomingAuth*, strip read-only on round-trip serialize
  • CI green

@Fivell Fivell changed the title feat: complete V3.5 SipConfiguration attributes for API 2026-04-16 feat: complete SipConfiguration attributes for API 2026-04-16 May 4, 2026
@Fivell Fivell force-pushed the feat/incoming-auth-credentials branch from c83e2d6 to 8f20362 Compare May 4, 2026 15:01
Fivell added 2 commits May 4, 2026 17:36
Adds the 5 writable + 2 read-only SIP registration attributes
introduced in API 2026-04-16: enabled_sip_registration,
use_did_in_ruri, cnam_lookup, network_protocol_priority,
diversion_inject_mode plus server-generated incoming_auth_username
and incoming_auth_password (returned only when sip_registration is
enabled, stripped from POST/PATCH bodies because the API rejects
writes with 400 Param not allowed).

Includes wire-format coverage of the create / read / disable PATCH
flows, fixture alignment with real sandbox responses, and the
SDK-specific changes needed to land the feature cleanly (typing /
nullability fixes, read-only enforcement at the type level,
constructor / builder ergonomics).
Override the SDK's idiomatic debug/log surface to replace credential
field values with [FILTERED] before they reach default print(),
logger output, debugger inspection, or unhandled exception traces.
The wire payload is unaffected — serializers continue to emit the
real values (or strip read-only ones via the existing read-only
mechanism).

Marks SIP auth_password and the server-generated incoming_auth_*
on SipConfiguration, plus username and password on the
credentials_and_ip authentication method, as sensitive.
@Fivell Fivell force-pushed the feat/incoming-auth-credentials branch 3 times, most recently from 8f8b346 to 6d66359 Compare May 4, 2026 16:38
Fivell added 2 commits May 5, 2026 00:00
Apply server-enforced field dependencies (API 2026-04-16) inside the
serializeTrunkConfiguration cascade so the on-the-wire SIP
configuration always satisfies the server's validation rules without
the caller having to enumerate them:

  - host non-blank             -> enabledSipRegistration: false,
                                   useDidInRuri: false
  - enabledSipRegistration     -> host: null, port: null
    explicitly true              (always emitted so a PATCH against
                                   an existing trunk that has them
                                   persisted is told to clear them)
  - enabledSipRegistration     -> useDidInRuri: false
    explicitly false

Cascade runs only on serialize, never during
deserializeTrunkConfiguration — server-returned shapes (regular SIP
trunk with host: present + sip_registration: false + use_did_in_ruri:
true) deserialize as-is.

Includes regression coverage for the fresh-config case (the cascade
must emit host=null / port=null even when the local input config does
not carry those keys — a PATCH against a trunk that already has host
persisted on the server side requires explicit nullification on the
wire), plus an end-to-end sandbox example
(examples/voice-in-trunk-sip-registration.ts).
Add a SIP registration usage section to the README that explains
the cascade rules and shows the enable / disable examples. The
disable example is a single setHost() / config.host = '...' call —
the cascade flips the dependent fields automatically.
@Fivell Fivell force-pushed the feat/incoming-auth-credentials branch from 6d66359 to 784fb38 Compare May 4, 2026 22:00
The same shallow-copy + replace-non-null-keys-with-[FILTERED] body was
duplicated in redactSipConfiguration (src/nested/trunk-configuration.ts)
and redactCredentialsAndIpAuthenticationMethod
(src/nested/authentication-method.ts). Extract it into
src/redact.ts as redactSensitiveKeys, generic over the object type
and the list of keys. Both per-resource redactors are now one-liners
that delegate to the shared helper.

Behaviour is unchanged — the helper body is byte-for-byte identical
to the previous inline loops, and the existing redaction tests on
both types continue to pass.
@sonarqubecloud

sonarqubecloud Bot commented May 4, 2026

Copy link
Copy Markdown

@Fivell Fivell merged commit 4a09f69 into main May 5, 2026
7 checks passed
@Fivell Fivell deleted the feat/incoming-auth-credentials branch May 5, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant