@stacksjs/rpx 0.11.20 → 0.11.21

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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * If `pathname` is an ACME http-01 challenge request, return the token's
3
+ * key-authorization contents from `<webroot>/<token>`; otherwise (or on any
4
+ * unsafe/missing token) return `null` so the caller falls through to its normal
5
+ * handling.
6
+ *
7
+ * The token must be a single path segment of ACME's `base64url` alphabet — this
8
+ * never rejects a real Let's Encrypt token, but refuses slashes, `..`, and other
9
+ * traversal so a crafted request can't read outside the challenge directory.
10
+ */
11
+ export declare function readAcmeChallenge(webroot: string, pathname: string): string | null;
12
+ /** The fixed request prefix Let's Encrypt fetches an http-01 token from. */
13
+ export declare const ACME_CHALLENGE_PREFIX: '/.well-known/acme-challenge/';
package/dist/auth.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { BasicAuthConfig } from './types';
2
+ /** Parse an htpasswd file body into a `user → hash` map (last entry wins). */
3
+ export declare function parseHtpasswd(body: string): Map<string, string>;
4
+ /**
5
+ * Resolve a {@link BasicAuthConfig} into an enforceable policy, or `undefined`
6
+ * when no usable credentials are configured (treated as "no auth"). The htpasswd
7
+ * file, when given, is read once here so request handling stays allocation-free.
8
+ */
9
+ export declare function resolveAuth(cfg?: BasicAuthConfig): ResolvedAuth | undefined;
10
+ /**
11
+ * Enforce a route's Basic auth policy against a request. Returns `undefined`
12
+ * when the request is authorized (handling continues) or a `401` challenge
13
+ * `Response` when it is not. ACME http-01 challenge requests are always allowed
14
+ * so on-demand certificate issuance for a protected host still works.
15
+ */
16
+ export declare function enforceBasicAuth(req: Request, pathname: string, auth: ResolvedAuth): Response | undefined;
17
+ /** A resolved, ready-to-enforce auth policy for one route. */
18
+ export declare interface ResolvedAuth {
19
+ realm: string
20
+ verify: (username: string, password: string) => boolean
21
+ }