Creates a middleware authenticating requests with the Basic scheme.
Decorates a Fetch implementation with one adding an Authorization header carrying the given credentials to
every request, alongside the headers supplied by the caller; credentials already carried by the request are replaced,
so the middleware is best applied to a client dedicated to a single origin.
Requests are normalised as Request objects before the
header is attached, preserving the headers and the options carried by a Request input alongside the overrides
supplied through init.
Credentials are joined as usr:pwd, normalised to Unicode NFC, and encoded as UTF-8 base64 once when the middleware
is created, leaving nothing to compute on the request path.
Warning
Base64 is not encryption: Basic credentials travel in a form any observer of the exchange may decode.
Confine them to https exchanges, as RFC 7617 § 4 requires.
Parameters
usr: string
The user id to authenticate as; must contain no colon, which delimits the two credentials
Creates a middleware authenticating requests with the
Basicscheme.Decorates a Fetch implementation with one adding an
Authorizationheader carrying the given credentials to every request, alongside the headers supplied by the caller; credentials already carried by the request are replaced, so the middleware is best applied to a client dedicated to a single origin.Requests are normalised as
Requestobjects before the header is attached, preserving the headers and the options carried by aRequestinput alongside the overrides supplied throughinit.Credentials are joined as
usr:pwd, normalised to Unicode NFC, and encoded as UTF-8 base64 once when the middleware is created, leaving nothing to compute on the request path.Base64 is not encryption:
Basiccredentials travel in a form any observer of the exchange may decode. Confine them tohttpsexchanges, as RFC 7617 § 4 requires.