@smartcrab/server 0.1.0
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.
- package/LICENSE +202 -0
- package/dist/base64.d.ts +14 -0
- package/dist/base64.js +56 -0
- package/dist/cookies.d.ts +33 -0
- package/dist/cookies.js +54 -0
- package/dist/errors.d.ts +86 -0
- package/dist/errors.js +72 -0
- package/dist/http.d.ts +32 -0
- package/dist/http.js +79 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +13 -0
- package/dist/oidc-client.d.ts +36 -0
- package/dist/oidc-client.js +414 -0
- package/dist/result.d.ts +39 -0
- package/dist/result.js +55 -0
- package/dist/sealing.d.ts +7 -0
- package/dist/sealing.js +76 -0
- package/dist/security.d.ts +49 -0
- package/dist/security.js +159 -0
- package/dist/server-auth.d.ts +129 -0
- package/dist/server-auth.js +586 -0
- package/dist/session.d.ts +42 -0
- package/dist/session.js +56 -0
- package/dist/webhook.d.ts +42 -0
- package/dist/webhook.js +95 -0
- package/package.json +44 -0
- package/src/base64.ts +58 -0
- package/src/cookies.ts +72 -0
- package/src/errors.ts +113 -0
- package/src/http.ts +112 -0
- package/src/index.ts +39 -0
- package/src/oidc-client.ts +551 -0
- package/src/result.ts +90 -0
- package/src/sealing.test.ts +57 -0
- package/src/sealing.ts +106 -0
- package/src/security.test.ts +134 -0
- package/src/security.ts +188 -0
- package/src/server-auth.test.ts +1108 -0
- package/src/server-auth.ts +887 -0
- package/src/session.ts +76 -0
- package/src/webhook.test.ts +96 -0
- package/src/webhook.ts +151 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ServerAuthError } from "./errors.js";
|
|
2
|
+
import { type ResultAsync } from "./result.js";
|
|
3
|
+
/** Cryptographically random opaque string (base64url, default 256 bits). */
|
|
4
|
+
export declare const generateOpaqueToken: (bytes?: number) => string;
|
|
5
|
+
export interface PkceMaterial {
|
|
6
|
+
/** 64 base64url chars (48 random bytes) — inside the RFC 7636 43..128 window. */
|
|
7
|
+
readonly verifier: string;
|
|
8
|
+
readonly challenge: string;
|
|
9
|
+
readonly state: string;
|
|
10
|
+
readonly nonce: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const generatePkceMaterial: () => ResultAsync<PkceMaterial, ServerAuthError>;
|
|
13
|
+
/**
|
|
14
|
+
* Length-agnostic-ish constant-time string comparison. Lengths leak (they are
|
|
15
|
+
* not secret: both sides are 256-bit random values), contents do not.
|
|
16
|
+
*/
|
|
17
|
+
export declare const timingSafeEqual: (a: string, b: string) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The SDK's CSRF defence for mutation handlers, chosen and documented per the
|
|
20
|
+
* assignment (§32.2 "CSRF token" **or** Origin/Referer validation):
|
|
21
|
+
*
|
|
22
|
+
* 1. `SameSite=Lax` on every cookie (see cookies.ts) already blocks cross-site
|
|
23
|
+
* POSTs from carrying the session — the browser-enforced first layer.
|
|
24
|
+
* 2. This check is the explicit second layer: for unsafe methods (POST etc.)
|
|
25
|
+
* the `Origin` header must match the request's own origin (or an explicitly
|
|
26
|
+
* allowlisted origin); if `Origin` is absent we fall back to the `Referer`
|
|
27
|
+
* origin; if neither is present the request is rejected (fail closed).
|
|
28
|
+
* 3. Safe methods (GET/HEAD/OPTIONS) pass — they are top-level navigations
|
|
29
|
+
* protected by `state` + PKCE + the single-use handshake cookie instead.
|
|
30
|
+
*
|
|
31
|
+
* Returns a boolean rather than a Result: the check is pure.
|
|
32
|
+
*/
|
|
33
|
+
export declare const isRequestOriginValid: (request: Request, extraAllowedOrigins: readonly string[]) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Stricter-than-navigation check used on GET handlers: if an `Origin` header
|
|
36
|
+
* is present at all on a GET (some fetch-based flows send one), it must match.
|
|
37
|
+
* Plain browser navigations send no `Origin` on GET and pass.
|
|
38
|
+
*/
|
|
39
|
+
export declare const hasInvalidNavigationOrigin: (request: Request, extraAllowedOrigins: readonly string[]) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Post-login/post-logout targets may only be relative paths or byte-for-byte
|
|
42
|
+
* members of the configured allowlist (design.md §32.2 "open redirect禁止",
|
|
43
|
+
* §15.9 "byte-for-byte完全一致" applied to the allowlist). Anything else
|
|
44
|
+
* silently degrades to `fallback` — the SDK never redirects to an
|
|
45
|
+
* attacker-supplied absolute URL.
|
|
46
|
+
*/
|
|
47
|
+
export declare const sanitizeRedirectTarget: (target: string | null, allowlist: readonly string[], fallback: string) => string;
|
|
48
|
+
/** True when `value` is a safe relative path or an https absolute URL. */
|
|
49
|
+
export declare const isAllowedConfiguredTarget: (value: string) => boolean;
|
package/dist/security.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { base64UrlEncode } from "./base64.js";
|
|
2
|
+
import { Result } from "./result.js";
|
|
3
|
+
/**
|
|
4
|
+
* Web security primitives (design.md §32.1, §32.2):
|
|
5
|
+
*
|
|
6
|
+
* - PKCE S256 material + `state`/`nonce` generation (§32.1: "state / nonce必須"),
|
|
7
|
+
* - timing-safe comparison for `state` (design.md §15.9: "callback後は`state`を定数時間比較"),
|
|
8
|
+
* - Origin/Referer validation — the SDK's chosen CSRF defence for the mutation
|
|
9
|
+
* handlers (§32.2 offers "CSRF token" and "Origin / Referer検証"; see the
|
|
10
|
+
* note in `isRequestOriginValid`),
|
|
11
|
+
* - post-login/logout redirect-target sanitization (§32.2: "open redirect禁止").
|
|
12
|
+
*/
|
|
13
|
+
const textEncoder = new TextEncoder();
|
|
14
|
+
/** Cryptographically random opaque string (base64url, default 256 bits). */
|
|
15
|
+
export const generateOpaqueToken = (bytes = 32) => {
|
|
16
|
+
const buffer = new Uint8Array(bytes);
|
|
17
|
+
crypto.getRandomValues(buffer);
|
|
18
|
+
return base64UrlEncode(buffer);
|
|
19
|
+
};
|
|
20
|
+
const sha256Base64Url = Result.fn({
|
|
21
|
+
try: async (value) => {
|
|
22
|
+
const digest = await crypto.subtle.digest("SHA-256", textEncoder.encode(value));
|
|
23
|
+
return base64UrlEncode(new Uint8Array(digest));
|
|
24
|
+
},
|
|
25
|
+
catch: () => ({ type: "crypto_operation_failed", operation: "sha256_digest" }),
|
|
26
|
+
});
|
|
27
|
+
export const generatePkceMaterial = () => {
|
|
28
|
+
const verifier = generateOpaqueToken(48);
|
|
29
|
+
return Result.mapAsync(sha256Base64Url(verifier), (challenge) => ({
|
|
30
|
+
verifier,
|
|
31
|
+
challenge,
|
|
32
|
+
state: generateOpaqueToken(32),
|
|
33
|
+
nonce: generateOpaqueToken(32),
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Length-agnostic-ish constant-time string comparison. Lengths leak (they are
|
|
38
|
+
* not secret: both sides are 256-bit random values), contents do not.
|
|
39
|
+
*/
|
|
40
|
+
export const timingSafeEqual = (a, b) => {
|
|
41
|
+
const aBytes = textEncoder.encode(a);
|
|
42
|
+
const bBytes = textEncoder.encode(b);
|
|
43
|
+
if (aBytes.byteLength !== bBytes.byteLength)
|
|
44
|
+
return false;
|
|
45
|
+
let diff = 0;
|
|
46
|
+
for (let i = 0; i < aBytes.byteLength; i += 1) {
|
|
47
|
+
diff |= (aBytes[i] ?? 0) ^ (bBytes[i] ?? 0);
|
|
48
|
+
}
|
|
49
|
+
return diff === 0;
|
|
50
|
+
};
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Origin / Referer validation (CSRF — design.md §32.2)
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
const SAFE_METHODS = new Set(["GET", "HEAD", "OPTIONS"]);
|
|
55
|
+
/**
|
|
56
|
+
* Extracts the `scheme://host[:port]` prefix from an absolute URL string
|
|
57
|
+
* without `new URL` (which throws on invalid input and would force an async
|
|
58
|
+
* `Result.fn` boundary into this synchronous check). Fail-closed: anything
|
|
59
|
+
* unparseable yields `null` and is rejected by the caller. Ambiguous input
|
|
60
|
+
* (e.g. userinfo tricks like `https://evil@real/`) simply never matches the
|
|
61
|
+
* expected origin, which is the safe direction.
|
|
62
|
+
*/
|
|
63
|
+
const extractOriginPrefix = (url) => {
|
|
64
|
+
const match = /^([a-z][a-z0-9+.-]*:\/\/[^\/?#]+)/i.exec(url);
|
|
65
|
+
const origin = match?.[1];
|
|
66
|
+
return origin === undefined ? null : origin.toLowerCase();
|
|
67
|
+
};
|
|
68
|
+
const requestOrigin = (request) => extractOriginPrefix(request.url);
|
|
69
|
+
const isOriginAllowed = (origin, ownOrigin, extraAllowedOrigins) => origin === ownOrigin || extraAllowedOrigins.includes(origin);
|
|
70
|
+
/**
|
|
71
|
+
* The SDK's CSRF defence for mutation handlers, chosen and documented per the
|
|
72
|
+
* assignment (§32.2 "CSRF token" **or** Origin/Referer validation):
|
|
73
|
+
*
|
|
74
|
+
* 1. `SameSite=Lax` on every cookie (see cookies.ts) already blocks cross-site
|
|
75
|
+
* POSTs from carrying the session — the browser-enforced first layer.
|
|
76
|
+
* 2. This check is the explicit second layer: for unsafe methods (POST etc.)
|
|
77
|
+
* the `Origin` header must match the request's own origin (or an explicitly
|
|
78
|
+
* allowlisted origin); if `Origin` is absent we fall back to the `Referer`
|
|
79
|
+
* origin; if neither is present the request is rejected (fail closed).
|
|
80
|
+
* 3. Safe methods (GET/HEAD/OPTIONS) pass — they are top-level navigations
|
|
81
|
+
* protected by `state` + PKCE + the single-use handshake cookie instead.
|
|
82
|
+
*
|
|
83
|
+
* Returns a boolean rather than a Result: the check is pure.
|
|
84
|
+
*/
|
|
85
|
+
export const isRequestOriginValid = (request, extraAllowedOrigins) => {
|
|
86
|
+
if (SAFE_METHODS.has(request.method))
|
|
87
|
+
return true;
|
|
88
|
+
const ownOrigin = requestOrigin(request);
|
|
89
|
+
if (ownOrigin === null)
|
|
90
|
+
return false;
|
|
91
|
+
const origin = request.headers.get("origin");
|
|
92
|
+
if (origin !== null) {
|
|
93
|
+
if (origin === "null")
|
|
94
|
+
return false;
|
|
95
|
+
return isOriginAllowed(origin.toLowerCase(), ownOrigin, extraAllowedOrigins);
|
|
96
|
+
}
|
|
97
|
+
const referer = request.headers.get("referer");
|
|
98
|
+
if (referer !== null) {
|
|
99
|
+
const refererOrigin = extractOriginPrefix(referer);
|
|
100
|
+
return refererOrigin !== null && isOriginAllowed(refererOrigin, ownOrigin, extraAllowedOrigins);
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Stricter-than-navigation check used on GET handlers: if an `Origin` header
|
|
106
|
+
* is present at all on a GET (some fetch-based flows send one), it must match.
|
|
107
|
+
* Plain browser navigations send no `Origin` on GET and pass.
|
|
108
|
+
*/
|
|
109
|
+
export const hasInvalidNavigationOrigin = (request, extraAllowedOrigins) => {
|
|
110
|
+
const origin = request.headers.get("origin");
|
|
111
|
+
if (origin === null)
|
|
112
|
+
return false;
|
|
113
|
+
const ownOrigin = requestOrigin(request);
|
|
114
|
+
if (ownOrigin === null || origin === "null")
|
|
115
|
+
return true;
|
|
116
|
+
return !isOriginAllowed(origin.toLowerCase(), ownOrigin, extraAllowedOrigins);
|
|
117
|
+
};
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Redirect-target sanitization (design.md §32.2: "open redirect禁止")
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
const MAX_TARGET_LENGTH = 2048;
|
|
122
|
+
/**
|
|
123
|
+
* A target is safe when it is a relative path starting with exactly one `/`
|
|
124
|
+
* (protocol-relative `//evil.example` is rejected), contains no backslashes
|
|
125
|
+
* (browsers treat `\` as `/`, enabling `\\evil.example` smuggling) and no
|
|
126
|
+
* control characters (header-injection defence).
|
|
127
|
+
*/
|
|
128
|
+
const isSafeRelativePath = (value) => {
|
|
129
|
+
if (!value.startsWith("/") || value.startsWith("//"))
|
|
130
|
+
return false;
|
|
131
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
132
|
+
const code = value.charCodeAt(i);
|
|
133
|
+
if (code <= 0x1f || code === 0x7f || code === 0x5c)
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Post-login/post-logout targets may only be relative paths or byte-for-byte
|
|
140
|
+
* members of the configured allowlist (design.md §32.2 "open redirect禁止",
|
|
141
|
+
* §15.9 "byte-for-byte完全一致" applied to the allowlist). Anything else
|
|
142
|
+
* silently degrades to `fallback` — the SDK never redirects to an
|
|
143
|
+
* attacker-supplied absolute URL.
|
|
144
|
+
*/
|
|
145
|
+
export const sanitizeRedirectTarget = (target, allowlist, fallback) => {
|
|
146
|
+
if (target === null || target.length === 0 || target.length > MAX_TARGET_LENGTH)
|
|
147
|
+
return fallback;
|
|
148
|
+
if (isSafeRelativePath(target))
|
|
149
|
+
return target;
|
|
150
|
+
if (allowlist.includes(target))
|
|
151
|
+
return target;
|
|
152
|
+
return fallback;
|
|
153
|
+
};
|
|
154
|
+
/** True when `value` is a safe relative path or an https absolute URL. */
|
|
155
|
+
export const isAllowedConfiguredTarget = (value) => {
|
|
156
|
+
if (isSafeRelativePath(value))
|
|
157
|
+
return true;
|
|
158
|
+
return value.startsWith("https://");
|
|
159
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { JWTPayload } from "jose";
|
|
2
|
+
import type { ServerAuthError } from "./errors.js";
|
|
3
|
+
import type { FetchLike } from "./http.js";
|
|
4
|
+
import { type ResultAsync } from "./result.js";
|
|
5
|
+
import type { Session } from "./session.js";
|
|
6
|
+
/**
|
|
7
|
+
* `createServerAuth` — the Web BFF surface of design.md §22.2:
|
|
8
|
+
*
|
|
9
|
+
* - `loginHandler` — builds the authorize redirect (Authorization Code +
|
|
10
|
+
* PKCE S256, state/nonce from WebCrypto) and stores the handshake in a
|
|
11
|
+
* short-lived, single-use `__Host-auth-pkce` cookie,
|
|
12
|
+
* - `callbackHandler` — validates state (constant-time), exchanges the code
|
|
13
|
+
* at the token endpoint, verifies the ID token (ES256/kid/iss/aud/exp/
|
|
14
|
+
* nonce), and issues the `__Host-auth-session` cookie (Secure, HttpOnly,
|
|
15
|
+
* SameSite=Lax, Path=/, **no Domain** — the `__Host-` prefix forbids one
|
|
16
|
+
* and this module enforces that by construction),
|
|
17
|
+
* - `logoutHandler` — revokes the refresh token family (§15.8, best-effort)
|
|
18
|
+
* and destroys the local session,
|
|
19
|
+
* - `getSession` / `requireSession` / `refreshSession` — session resolution
|
|
20
|
+
* with transparent access-token refresh,
|
|
21
|
+
* - refresh uses a per-instance, process-wide mutex: concurrent requests
|
|
22
|
+
* never trigger two refreshes (design.md §21.7 "同時refreshを禁止"), the
|
|
23
|
+
* latest rotated refresh token is stored atomically under that mutex, and
|
|
24
|
+
* `invalid_grant` wipes the local session while transient failures keep it
|
|
25
|
+
* (§21.7),
|
|
26
|
+
* - CSRF: SameSite=Lax cookies plus Origin/Referer validation on mutation
|
|
27
|
+
* handlers (the assignment's "choose and document" — see security.ts);
|
|
28
|
+
* login/callback/logout all validate state and/or origin,
|
|
29
|
+
* - open-redirect prevention: post-login/logout targets must be relative
|
|
30
|
+
* paths or byte-for-byte allowlisted URLs (§32.2).
|
|
31
|
+
*
|
|
32
|
+
* Configuration errors are programmer errors and throw `TypeError` at
|
|
33
|
+
* construction (fail fast at startup); runtime failures are always typed
|
|
34
|
+
* `Result`s or problem responses — never thrown.
|
|
35
|
+
*/
|
|
36
|
+
export interface ServerAuthConfig {
|
|
37
|
+
/** Issuer base URL, e.g. `https://id.example-auth.com/e/env_xxx` (https only). */
|
|
38
|
+
readonly issuer: string;
|
|
39
|
+
readonly clientId: string;
|
|
40
|
+
readonly clientSecret: string;
|
|
41
|
+
/** Byte-for-byte registered callback URL (design.md §15.9). */
|
|
42
|
+
readonly redirectUri: string;
|
|
43
|
+
/** >=32 chars of entropy; HKDF-derives the AES-256-GCM cookie-sealing key. */
|
|
44
|
+
readonly cookieSecret: string;
|
|
45
|
+
/** Mount point used when building login redirects. Default `"/auth"`. */
|
|
46
|
+
readonly basePath?: string;
|
|
47
|
+
/** Default `["openid", "profile", "email", "offline_access"]`. */
|
|
48
|
+
readonly scopes?: readonly string[];
|
|
49
|
+
/** Default `"/"`. Relative path or https URL. */
|
|
50
|
+
readonly postLoginRedirect?: string;
|
|
51
|
+
/** Default `"/"`. Relative path or https URL. */
|
|
52
|
+
readonly postLogoutRedirect?: string;
|
|
53
|
+
/** Extra byte-for-byte allowed absolute redirect targets (open-redirect allowlist). */
|
|
54
|
+
readonly allowedRedirectTargets?: readonly string[];
|
|
55
|
+
/** Extra allowed Origins beyond the request's own origin (CSRF check). */
|
|
56
|
+
readonly allowedOrigins?: readonly string[];
|
|
57
|
+
/** Session cookie lifetime. Default: refresh-token idle TTL (30 days, §15.5). */
|
|
58
|
+
readonly sessionTtlSeconds?: number;
|
|
59
|
+
/** PKCE handshake cookie lifetime. Default: 600s. */
|
|
60
|
+
readonly pkceCookieTtlSeconds?: number;
|
|
61
|
+
/** Refresh when the access token expires within this window. Default: 60s. */
|
|
62
|
+
readonly refreshLeewaySeconds?: number;
|
|
63
|
+
/** Fetch implementation override (tests, custom transports). */
|
|
64
|
+
readonly fetch?: FetchLike;
|
|
65
|
+
/**
|
|
66
|
+
* Unsupported — rejected at construction. The `__Host-` cookie prefix
|
|
67
|
+
* (design.md §22.2) forbids a Domain attribute, so the SDK never emits one.
|
|
68
|
+
*/
|
|
69
|
+
readonly cookieDomain?: string;
|
|
70
|
+
}
|
|
71
|
+
export type UnauthenticatedReason = "no_session" | "invalid_session_cookie" | "session_expired" | "refresh_rejected" | "refresh_unavailable";
|
|
72
|
+
export type GetSessionOutcome = {
|
|
73
|
+
readonly status: "authenticated";
|
|
74
|
+
readonly session: Session;
|
|
75
|
+
/** Present when the session was refreshed/rotated — append to the response as `Set-Cookie`. */
|
|
76
|
+
readonly setCookie?: string;
|
|
77
|
+
} | {
|
|
78
|
+
readonly status: "unauthenticated";
|
|
79
|
+
readonly reason: UnauthenticatedReason;
|
|
80
|
+
/** Present when the local session must be destroyed — append to the response as `Set-Cookie`. */
|
|
81
|
+
readonly clearCookie?: string;
|
|
82
|
+
};
|
|
83
|
+
export type RequireSessionOutcome = {
|
|
84
|
+
readonly ok: true;
|
|
85
|
+
readonly session: Session;
|
|
86
|
+
readonly setCookie?: string;
|
|
87
|
+
} | {
|
|
88
|
+
readonly ok: false;
|
|
89
|
+
readonly reason: UnauthenticatedReason;
|
|
90
|
+
/** Ready-to-return response: 302 to the login handler, 401 JSON (`onUnauthenticated: "json"`), or 503 on transient refresh failure. */
|
|
91
|
+
readonly response: Response;
|
|
92
|
+
};
|
|
93
|
+
export interface RequireSessionOptions {
|
|
94
|
+
/** `"redirect"` (default) sends browsers to login; `"json"` answers 401 problem JSON. */
|
|
95
|
+
readonly onUnauthenticated?: "redirect" | "json";
|
|
96
|
+
}
|
|
97
|
+
export interface VerifiedAccessToken {
|
|
98
|
+
readonly sub: string;
|
|
99
|
+
readonly scope: string;
|
|
100
|
+
readonly clientId?: string;
|
|
101
|
+
readonly expiresAt?: number;
|
|
102
|
+
/** Full verified claims (jose `JWTPayload`) for resource-server authorization logic. */
|
|
103
|
+
readonly claims: JWTPayload;
|
|
104
|
+
}
|
|
105
|
+
export interface ServerAuth {
|
|
106
|
+
readonly loginHandler: (request: Request) => Promise<Response>;
|
|
107
|
+
readonly callbackHandler: (request: Request) => Promise<Response>;
|
|
108
|
+
readonly logoutHandler: (request: Request) => Promise<Response>;
|
|
109
|
+
readonly getSession: (request: Request) => Promise<GetSessionOutcome>;
|
|
110
|
+
/** Forces an access-token refresh (serialized by the same process-wide mutex). */
|
|
111
|
+
readonly refreshSession: (request: Request) => Promise<GetSessionOutcome>;
|
|
112
|
+
readonly requireSession: (request: Request, options?: RequireSessionOptions) => Promise<RequireSessionOutcome>;
|
|
113
|
+
/** Resource-server helper: verifies a platform access token (`at+jwt`) against the issuer JWKS. */
|
|
114
|
+
readonly verifyAccessToken: (token: string, audience?: string | readonly string[]) => ResultAsync<VerifiedAccessToken, ServerAuthError>;
|
|
115
|
+
readonly basePath: string;
|
|
116
|
+
readonly sessionCookieName: string;
|
|
117
|
+
}
|
|
118
|
+
export interface AccessTokenVerifierOptions {
|
|
119
|
+
readonly issuer: string;
|
|
120
|
+
readonly audience?: string | readonly string[];
|
|
121
|
+
readonly fetch?: FetchLike;
|
|
122
|
+
}
|
|
123
|
+
export declare const createServerAuth: (config: ServerAuthConfig) => ServerAuth;
|
|
124
|
+
/**
|
|
125
|
+
* Standalone resource-server verifier (design.md §3.1: "その他のバックエンド
|
|
126
|
+
* は OIDC/JWKS で統合"). Same verification rules as the BFF: ES256 only,
|
|
127
|
+
* mandatory `kid`, iss/aud/exp/typ(`at+jwt`) checked against the issuer JWKS.
|
|
128
|
+
*/
|
|
129
|
+
export declare const createAccessTokenVerifier: (options: AccessTokenVerifierOptions) => ((token: string) => ResultAsync<VerifiedAccessToken, ServerAuthError>);
|