validateBasicAuth

View as MarkdownOpen in Claude

Validate a supplied username/password pair against the service’s configured Basic Auth credentials using a constant-time comparison, so the secret is not leaked through timing. Returns false when no credentials are configured.

Parameters

username
stringRequired

Username to compare against the configured credentials.

password
stringRequired

Password to compare against the configured credentials.

Returns

boolean | Promise<boolean>true when both values match the configured credentials; false when they do not match or no credentials are set.

Example

1import { SWMLService } from '@signalwire/sdk';
2
3const service = new SWMLService({ name: 'my-service', basicAuth: ['user', 'secret'] });
4
5const ok = service.validateBasicAuth('user', 'secret');
6console.log(ok); // true

Retrieve the configured credentials with getBasicAuthCredentials().