@lostgradient/mcp 0.1.0 → 0.2.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.
Files changed (84) hide show
  1. package/README.md +68 -8
  2. package/dist/chunk-11p5d5a1.js +909 -0
  3. package/dist/chunk-3ek3knfm.js +73 -0
  4. package/dist/{chunk-v14p4gng.js → chunk-3rr24vhh.js} +4 -1
  5. package/dist/chunk-6ekjtvcq.js +273 -0
  6. package/dist/chunk-88nhf6xt.js +449 -0
  7. package/dist/{chunk-psnez3q2.js → chunk-k6fm3cmk.js} +23 -2
  8. package/dist/{chunk-mf3t0afg.js → chunk-nfvwew92.js} +1 -1
  9. package/dist/chunk-rxnyn7tf.js +19 -0
  10. package/dist/{chunk-wmkqd45r.js → chunk-xcf742mf.js} +1 -1
  11. package/dist/chunk-yf4nw40e.js +1102 -0
  12. package/dist/conformance.d.ts +43 -0
  13. package/dist/env.d.ts +1 -1
  14. package/dist/env.js +2 -2
  15. package/dist/environment-schema.d.ts +1 -1
  16. package/dist/environment-schema.js +1 -1
  17. package/dist/http/authenticate.d.ts +35 -0
  18. package/dist/http/authorization-header.d.ts +5 -0
  19. package/dist/http/grant-revocation-channel.d.ts +24 -0
  20. package/dist/http/handler.d.ts +32 -0
  21. package/dist/http/index.d.ts +27 -0
  22. package/dist/http/index.js +813 -0
  23. package/dist/http/request-context.d.ts +17 -0
  24. package/dist/http/responses.d.ts +11 -0
  25. package/dist/http/serving-layer.d.ts +18 -0
  26. package/dist/http/user-handler-cache.d.ts +37 -0
  27. package/dist/http/user-server-event-bus.d.ts +35 -0
  28. package/dist/index.d.ts +5 -1
  29. package/dist/index.js +230 -940
  30. package/dist/logger.d.ts +20 -0
  31. package/dist/logger.js +9 -5
  32. package/dist/oauth/authorize-endpoint.d.ts +5 -0
  33. package/dist/oauth/canonicalize-ip-address.d.ts +20 -0
  34. package/dist/oauth/client-authentication.d.ts +10 -0
  35. package/dist/oauth/client-metadata-documents.d.ts +52 -0
  36. package/dist/oauth/client-metadata-documents.js +19 -0
  37. package/dist/oauth/discovery-metadata.d.ts +19 -0
  38. package/dist/oauth/endpoint-rate-limits.d.ts +10 -0
  39. package/dist/oauth/endpoint-responses.d.ts +10 -0
  40. package/dist/oauth/index.d.ts +214 -0
  41. package/dist/oauth/index.js +69 -0
  42. package/dist/oauth/network-identity.d.ts +32 -0
  43. package/dist/oauth/pkce-validation.d.ts +2 -0
  44. package/dist/oauth/postgres/client-store.d.ts +12 -0
  45. package/dist/oauth/postgres/code-store.d.ts +14 -0
  46. package/dist/oauth/postgres/database.d.ts +18 -0
  47. package/dist/oauth/postgres/index.d.ts +11 -0
  48. package/dist/oauth/postgres/index.js +584 -0
  49. package/dist/oauth/postgres/schema.d.ts +1455 -0
  50. package/dist/oauth/postgres/token-store.d.ts +16 -0
  51. package/dist/oauth/postgres/transaction-store.d.ts +14 -0
  52. package/dist/oauth/redirect-uri-matching.d.ts +2 -0
  53. package/dist/oauth/registration-endpoint.d.ts +2 -0
  54. package/dist/oauth/request-body.d.ts +14 -0
  55. package/dist/oauth/revocation-endpoint.d.ts +2 -0
  56. package/dist/oauth/safe-public-https-fetch.d.ts +28 -0
  57. package/dist/oauth/scope-utilities.d.ts +15 -0
  58. package/dist/oauth/security-utilities.d.ts +8 -0
  59. package/dist/oauth/stores.d.ts +225 -0
  60. package/dist/oauth/stores.js +0 -0
  61. package/dist/oauth/testing/contract-fixtures.d.ts +134 -0
  62. package/dist/oauth/testing/index.d.ts +56 -0
  63. package/dist/oauth/testing/index.js +330 -0
  64. package/dist/oauth/token-endpoint.d.ts +2 -0
  65. package/dist/oauth-scope-configuration.d.ts +3 -0
  66. package/dist/rate-limit/in-memory-sliding-window-store.d.ts +3 -0
  67. package/dist/rate-limit/index.d.ts +23 -0
  68. package/dist/rate-limit/index.js +29 -0
  69. package/dist/rate-limit/mcp-concurrency-limiter.d.ts +26 -0
  70. package/dist/rate-limit/rate-limit-response.d.ts +1 -0
  71. package/dist/rate-limit/redis-sliding-window-store.d.ts +2 -0
  72. package/dist/rate-limit/request-rate-limiter.d.ts +10 -0
  73. package/dist/rate-limit/sliding-window-rate-limiter.d.ts +16 -0
  74. package/dist/scopes.d.ts +1 -1
  75. package/dist/server.d.ts +1 -1
  76. package/dist/sveltekit-mount-state.d.ts +4 -0
  77. package/dist/sveltekit-mount.d.ts +43 -0
  78. package/dist/sveltekit-mount.js +332 -0
  79. package/dist/tool-response.d.ts +6 -0
  80. package/dist/types/primitives.d.ts +1 -1
  81. package/dist/ui-extension-support.d.ts +2 -2
  82. package/dist/version.d.ts +1 -1
  83. package/dist/version.js +1 -1
  84. package/package.json +56 -4
@@ -0,0 +1,16 @@
1
+ import type { AccessToken, TokenStore } from '../stores.js';
2
+ import { type PostgresOAuthDatabase } from './database.js';
3
+ import type { PostgresOAuthSchema } from './schema.js';
4
+ export declare class PostgresTokenStore implements TokenStore {
5
+ private readonly database;
6
+ private readonly schema;
7
+ constructor(database: PostgresOAuthDatabase, schema: PostgresOAuthSchema);
8
+ issueAuthorizationGrant(input: Parameters<TokenStore['issueAuthorizationGrant']>[0]): Promise<void>;
9
+ findByHash(tokenHash: string): Promise<AccessToken | null>;
10
+ rotateRefreshToken(input: Parameters<TokenStore['rotateRefreshToken']>[0]): ReturnType<TokenStore['rotateRefreshToken']>;
11
+ revokeAccessToken(tokenHash: string, clientId: string): Promise<boolean>;
12
+ revokeRefreshToken(tokenHash: string, clientId: string): ReturnType<TokenStore['revokeRefreshToken']>;
13
+ revokeFamily(familyId: string): Promise<number>;
14
+ deleteAllForUser(userId: string): Promise<number>;
15
+ purgeExpired(now: Date): Promise<number>;
16
+ }
@@ -0,0 +1,14 @@
1
+ import type { ConsumedAuthorizationTransaction, TransactionStore } from '../stores.js';
2
+ import { type PostgresOAuthDatabase } from './database.js';
3
+ import type { PostgresOAuthSchema } from './schema.js';
4
+ export declare class PostgresTransactionStore implements TransactionStore {
5
+ private readonly database;
6
+ private readonly schema;
7
+ constructor(database: PostgresOAuthDatabase, schema: PostgresOAuthSchema);
8
+ create(input: Parameters<TransactionStore['create']>[0]): Promise<void>;
9
+ consume(transactionId: string, csrfToken: string, binding: string, subjectId: string): Promise<ConsumedAuthorizationTransaction | null>;
10
+ unconsume(transactionId: string, consumedAt: Date): Promise<boolean>;
11
+ deleteByBinding(value: string): Promise<number>;
12
+ deleteAllForUser(userId: string): Promise<number>;
13
+ purgeExpired(now: Date): Promise<number>;
14
+ }
@@ -0,0 +1,2 @@
1
+ /** RFC 8252 port-flexible matching for native loopback redirects; every other URI matches exactly. */
2
+ export declare function redirectUriMatchesRegistered(requestedUri: string, registeredUris: readonly string[]): boolean;
@@ -0,0 +1,2 @@
1
+ import type { OAuthRequestContext, OAuthStatelessHostSeams } from './index.js';
2
+ export declare function handleOauthRegisterPost<Scope extends string>(context: OAuthRequestContext, seams: OAuthStatelessHostSeams<Scope>): Promise<Response>;
@@ -0,0 +1,14 @@
1
+ export declare const oauthRegisterMaximumBodyBytes: number;
2
+ export declare const oauthTokenMaximumBodyBytes: number;
3
+ export declare const oauthRevokeMaximumBodyBytes: number;
4
+ export declare const oauthAuthorizeApproveMaximumBodyBytes: number;
5
+ export declare const oauthAuthorizeDenyMaximumBodyBytes: number;
6
+ export declare class PayloadTooLargeError extends Error {
7
+ }
8
+ export declare class InvalidOauthRequestBodyError extends Error {
9
+ readonly kind: 'unsupported_content_type' | 'invalid_request';
10
+ constructor(message: string, kind?: 'unsupported_content_type' | 'invalid_request');
11
+ }
12
+ export declare function readBoundedText(request: Request, maximumBytes: number): Promise<string>;
13
+ export declare function readOauthJson(request: Request, maximumBytes: number): Promise<unknown>;
14
+ export declare function readOauthParameters(request: Request, maximumBytes: number): Promise<Record<string, string>>;
@@ -0,0 +1,2 @@
1
+ import type { OAuthRequestContext, OAuthStatelessHostSeams } from './index.js';
2
+ export declare function handleOauthRevokePost<Scope extends string>(context: OAuthRequestContext, seams: OAuthStatelessHostSeams<Scope>): Promise<Response>;
@@ -0,0 +1,28 @@
1
+ export declare class ClientMetadataDocumentFetchError extends Error {
2
+ readonly reason: string;
3
+ constructor(reason: string);
4
+ }
5
+ export type DnsLookupAllFunction = (hostname: string, options: {
6
+ all: true;
7
+ verbatim: true;
8
+ }) => Promise<{
9
+ address: string;
10
+ family: number;
11
+ }[]>;
12
+ export type SafePublicHttpsFetchOptions = {
13
+ fetchImpl?: typeof fetch;
14
+ lookupImpl?: DnsLookupAllFunction;
15
+ dnsTimeoutMs?: number;
16
+ fetchTimeoutMs?: number;
17
+ headers?: HeadersInit;
18
+ };
19
+ /**
20
+ * Fetches one client-supplied HTTPS URL through the complete SSRF boundary:
21
+ * HTTPS-only, literal-IP blocking, every resolved address checked, and no redirects.
22
+ * The resolve-then-connect gap is additionally bounded by normal HTTPS certificate
23
+ * validation: a name rebound to an internal service cannot present a valid certificate
24
+ * for the original public hostname.
25
+ */
26
+ export declare function safeFetchPublicHttpsUrl(input: string | URL, options?: SafePublicHttpsFetchOptions): Promise<Response>;
27
+ /** Test-only: clears process-global DNS concurrency state between isolated cases. */
28
+ export declare function resetDnsLookupConcurrencyLimiterForTests(): void;
@@ -0,0 +1,15 @@
1
+ export declare function splitScopes(value: string): string[];
2
+ export declare function canonicalizeScopes(values: readonly string[]): string;
3
+ export declare function parseRequestedScope<Scope extends string>(value: string | null, supportedScopes: readonly Scope[]): {
4
+ ok: true;
5
+ scope: string;
6
+ } | {
7
+ ok: false;
8
+ unknownScopes: string[];
9
+ };
10
+ export declare function parseRefreshScope<Scope extends string>(value: string | undefined, supportedScopes: readonly Scope[]): {
11
+ ok: true;
12
+ requestedScope?: string;
13
+ } | {
14
+ ok: false;
15
+ };
@@ -0,0 +1,8 @@
1
+ export declare function isAddressInCidr(address: string, cidr: string): boolean;
2
+ export declare function isValidCidr(cidr: string): boolean;
3
+ export declare function isValidRedirectUri(uri: string): boolean;
4
+ export declare function isValidClientName(name: string): boolean;
5
+ export declare function isExactContentType(value: string | null, expectedMediaType: string): boolean;
6
+ /** Compares UTF-8 credentials without data-dependent comparison timing. */
7
+ export declare function constantTimeEquals(leftValue: string, rightValue: string): boolean;
8
+ export declare function withDeadline<T>(promise: Promise<T>, timeoutMilliseconds: number): Promise<T>;
@@ -0,0 +1,225 @@
1
+ export type AuthorizationTransaction = {
2
+ /** Store-derived hash of the opaque transaction identifier. */
3
+ transactionIdHash: string;
4
+ userId: string;
5
+ clientId: string;
6
+ redirectUri: string;
7
+ codeChallenge: string;
8
+ codeChallengeMethod: string;
9
+ state: string | null;
10
+ issuer: string;
11
+ resource: string;
12
+ scope: string;
13
+ expiresAt: Date;
14
+ consumedAt: Date | null;
15
+ createdAt: Date;
16
+ };
17
+ export type AuthorizationCode = {
18
+ /** Hash of the one-time credential; plaintext authorization codes are never persisted. */
19
+ codeHash: string;
20
+ clientId: string;
21
+ userId: string;
22
+ redirectUri: string;
23
+ codeChallenge: string;
24
+ codeChallengeMethod: string;
25
+ scope: string | null;
26
+ state: string | null;
27
+ resource: string;
28
+ expiresAt: Date;
29
+ usedAt: Date | null;
30
+ createdAt: Date;
31
+ };
32
+ export type AccessToken = {
33
+ /** Hash of the bearer credential; plaintext access tokens are never persisted. */
34
+ accessTokenHash: string;
35
+ clientId: string;
36
+ userId: string;
37
+ scope: string | null;
38
+ resource: string;
39
+ expiresAt: Date;
40
+ revokedAt: Date | null;
41
+ createdAt: Date;
42
+ };
43
+ export type RefreshToken = {
44
+ /** Hash of the bearer credential; plaintext refresh tokens are never persisted. */
45
+ refreshTokenHash: string;
46
+ clientId: string;
47
+ userId: string;
48
+ scope: string | null;
49
+ resource: string;
50
+ accessTokenHash: string;
51
+ familyId: string;
52
+ expiresAt: Date;
53
+ revokedAt: Date | null;
54
+ createdAt: Date;
55
+ };
56
+ export type RegisteredClient = {
57
+ clientId: string;
58
+ /** Hash of the client credential; null for public clients. */
59
+ clientSecretHash: string | null;
60
+ clientName: string;
61
+ clientType: string;
62
+ tokenEndpointAuthMethod: string;
63
+ applicationType: string | null;
64
+ redirectUris: string[];
65
+ grantTypes: string[];
66
+ responseTypes: string[];
67
+ clientIdMetadataUrl: string | null;
68
+ /** Null preserves the legacy meaning that no client-secret expiry is enforced. */
69
+ clientSecretExpiresAt: Date | null;
70
+ createdAt: Date;
71
+ updatedAt: Date;
72
+ };
73
+ export type ConsumedAuthorizationTransaction = AuthorizationTransaction & {
74
+ consumedAt: Date;
75
+ };
76
+ export type ConsumedAuthorizationCode = AuthorizationCode & {
77
+ usedAt: Date;
78
+ };
79
+ export interface TransactionStore {
80
+ /**
81
+ * Persists hashes of both plaintext secrets using one store-owned hashing
82
+ * scheme. The plaintext values must never be retained in the record.
83
+ */
84
+ create(input: {
85
+ record: Omit<AuthorizationTransaction, 'transactionIdHash'>;
86
+ transactionId: string;
87
+ csrfToken: string;
88
+ consentBinding: string;
89
+ }): Promise<void>;
90
+ /**
91
+ * Atomically consumes a live, unused transaction matching the transaction
92
+ * identifier, CSRF token, durable subject, and identity binding. The implementation must
93
+ * enforce every predicate in one operation; read-then-write stores are
94
+ * non-conforming because concurrent approvals could both succeed.
95
+ */
96
+ consume(transactionId: string, csrfToken: string, binding: string, subjectId: string): Promise<ConsumedAuthorizationTransaction | null>;
97
+ /** Reopens only the exact consumption returned by `consume`. */
98
+ unconsume(transactionId: string, consumedAt: Date): Promise<boolean>;
99
+ /**
100
+ * Deletes every transaction whose opaque consent binding equals `value`.
101
+ * The store compares the value for equality and must never parse or infer
102
+ * identity granularity from it.
103
+ */
104
+ deleteByBinding(value: string): Promise<number>;
105
+ /** Deletes every authorization transaction attributed to the durable subject. */
106
+ deleteAllForUser(userId: string): Promise<number>;
107
+ purgeExpired(now: Date): Promise<number>;
108
+ }
109
+ export interface CodeStore {
110
+ /** Persists an authorization-code record containing only the code hash. */
111
+ issue(record: AuthorizationCode): Promise<void>;
112
+ /** Reads validation predicates by hash without spending the code. */
113
+ findByHash(codeHash: string): Promise<AuthorizationCode | null>;
114
+ /**
115
+ * Atomically consumes an unused code whose expiry is later than `now`. A
116
+ * second consume call for the same hash, or a call at or after expiry,
117
+ * returns null.
118
+ */
119
+ consume(codeHash: string, now: Date): Promise<ConsumedAuthorizationCode | null>;
120
+ /** Reopens only the exact consumption returned by `consume`. */
121
+ unconsume(codeHash: string, usedAt: Date): Promise<boolean>;
122
+ /** Deletes every authorization code attributed to the durable subject. */
123
+ deleteAllForUser(userId: string): Promise<number>;
124
+ purgeExpired(now: Date): Promise<number>;
125
+ }
126
+ export type RefreshTokenRevocationTarget = {
127
+ /** Subject whose live MCP streams must be disconnected after revocation. */
128
+ userId: string;
129
+ /** Token family whose replay was detected or whose grant was revoked. */
130
+ familyId: string;
131
+ };
132
+ export interface TokenStore {
133
+ /** Atomically persists the hashed access token and optional hashed root refresh token. */
134
+ issueAuthorizationGrant(input: {
135
+ accessToken: AccessToken;
136
+ refreshToken?: RefreshToken;
137
+ }): Promise<void>;
138
+ findByHash(tokenHash: string): Promise<AccessToken | null>;
139
+ /**
140
+ * Loads and validates the prior opaque token, then derives subject, scope,
141
+ * resource, and family fields for both replacements inside one operation.
142
+ * Successful rotation also revokes the access token paired with the prior
143
+ * refresh token before returning the replacement credentials.
144
+ * A requested scope must be a subset of the stored grant and is rejected
145
+ * without consuming the prior token otherwise. Replaying an already-rotated
146
+ * token atomically revokes its family before returning `replay_revoked`.
147
+ */
148
+ rotateRefreshToken(input: {
149
+ priorHash: string;
150
+ clientId: string;
151
+ resource: string;
152
+ /** Optional normalized scope request; the store rejects any non-subset. */
153
+ requestedScope?: string;
154
+ nextAccessTokenHash: string;
155
+ nextRefreshTokenHash: string;
156
+ accessTokenExpiresAt: Date;
157
+ refreshTokenExpiresAt: Date;
158
+ createdAt: Date;
159
+ }): Promise<{
160
+ status: 'rotated';
161
+ accessToken: AccessToken;
162
+ refreshToken: RefreshToken;
163
+ } | ({
164
+ status: 'replay_revoked';
165
+ } & RefreshTokenRevocationTarget) | {
166
+ status: 'scope_rejected';
167
+ } | {
168
+ status: 'invalid';
169
+ }>;
170
+ /** Revokes a client-owned access token and its paired refresh token, if any. */
171
+ revokeAccessToken(tokenHash: string, clientId: string): Promise<boolean>;
172
+ /**
173
+ * Revokes a client-owned refresh token and its paired access token. Replaying
174
+ * a rotated token atomically revokes its family and returns `replay_revoked`.
175
+ */
176
+ revokeRefreshToken(tokenHash: string, clientId: string): Promise<({
177
+ status: 'revoked' | 'replay_revoked';
178
+ } & RefreshTokenRevocationTarget) | {
179
+ status: 'invalid';
180
+ }>;
181
+ /**
182
+ * Revokes the refresh-token family and all access tokens descended from it
183
+ * in one atomic statement or an equivalently non-interleavable operation.
184
+ */
185
+ revokeFamily(familyId: string): Promise<number>;
186
+ /** Deletes every access and refresh token attributed to the durable subject. */
187
+ deleteAllForUser(userId: string): Promise<number>;
188
+ /**
189
+ * Deletes expired access tokens and refresh tokens whose `expiresAt` is at
190
+ * or before `now`. A rotated refresh token remains observable until its own
191
+ * expiry so presenting it again can still trigger family replay revocation;
192
+ * rotation alone never makes a refresh token eligible for this purge.
193
+ */
194
+ purgeExpired(now: Date): Promise<number>;
195
+ }
196
+ /**
197
+ * Client registrations are not user-owned and therefore have no
198
+ * `deleteAllForUser` operation. Secret expiry is enforced when the client
199
+ * authenticates; deleting the registration would prevent secret rotation.
200
+ */
201
+ export interface ClientStore {
202
+ register(record: RegisteredClient): Promise<void>;
203
+ /** Atomically creates or replaces a client sourced from refreshed metadata. */
204
+ upsert(record: RegisteredClient): Promise<void>;
205
+ findById(clientId: string): Promise<RegisteredClient | null>;
206
+ update(clientId: string, patch: Partial<RegisteredClient>): Promise<void>;
207
+ }
208
+ export type OAuthUserDeletionResult = {
209
+ transactions: number;
210
+ codes: number;
211
+ tokens: number;
212
+ };
213
+ export type OAuthStores = {
214
+ transactions: TransactionStore;
215
+ codes: CodeStore;
216
+ tokens: TokenStore;
217
+ clients: ClientStore;
218
+ /**
219
+ * Deletes all user-owned OAuth state across the transaction, code, and token
220
+ * stores. A Postgres adapter may satisfy this through referential cascade;
221
+ * a backing store without referential integrity must explicitly fan out to
222
+ * all three stores.
223
+ */
224
+ deleteAllForUser(userId: string): Promise<OAuthUserDeletionResult>;
225
+ };
File without changes
@@ -0,0 +1,134 @@
1
+ import type { MinimalRedisClient } from '../index.js';
2
+ import type { ClientStore } from '../stores.js';
3
+ type ClientStoreOmitsUserDeletion = 'deleteAllForUser' extends keyof ClientStore ? never : true;
4
+ export declare const clientStoreOmitsUserDeletionContractFixture: ClientStoreOmitsUserDeletion;
5
+ export declare const storeContractFixture: {
6
+ transactions: {
7
+ create: () => Promise<void>;
8
+ consume: () => Promise<null>;
9
+ unconsume: () => Promise<boolean>;
10
+ deleteByBinding: () => Promise<number>;
11
+ deleteAllForUser: () => Promise<number>;
12
+ purgeExpired: () => Promise<number>;
13
+ };
14
+ codes: {
15
+ issue: () => Promise<void>;
16
+ findByHash: () => Promise<null>;
17
+ consume: () => Promise<null>;
18
+ unconsume: () => Promise<boolean>;
19
+ deleteAllForUser: () => Promise<number>;
20
+ purgeExpired: () => Promise<number>;
21
+ };
22
+ tokens: {
23
+ issueAuthorizationGrant: () => Promise<void>;
24
+ findByHash: () => Promise<null>;
25
+ rotateRefreshToken: () => Promise<{
26
+ status: "invalid";
27
+ }>;
28
+ revokeAccessToken: () => Promise<boolean>;
29
+ revokeRefreshToken: () => Promise<{
30
+ status: "invalid";
31
+ }>;
32
+ revokeFamily: () => Promise<number>;
33
+ deleteAllForUser: () => Promise<number>;
34
+ purgeExpired: () => Promise<number>;
35
+ };
36
+ clients: {
37
+ register: () => Promise<void>;
38
+ upsert: () => Promise<void>;
39
+ findById: () => Promise<null>;
40
+ update: () => Promise<void>;
41
+ };
42
+ deleteAllForUser: () => Promise<{
43
+ transactions: number;
44
+ codes: number;
45
+ tokens: number;
46
+ }>;
47
+ };
48
+ export declare const identityContractFixture: () => Promise<null>;
49
+ export declare const userProfileContractFixture: () => Promise<null>;
50
+ export declare const unauthenticatedAuthorizationContractFixture: () => Response;
51
+ export declare const consentContractFixture: () => Response;
52
+ export declare const scopeContractFixture: import("../index.js").OAuthScopeConfiguration<"repositories:read">;
53
+ export declare const configurationContractFixture: {
54
+ issuer: string;
55
+ baseUrl: URL;
56
+ resource: URL;
57
+ accessTokenTtlSeconds: number;
58
+ refreshTokenTtlSeconds: number;
59
+ clientSecretTtlSeconds: number;
60
+ isTrustedOrigin: () => true;
61
+ trustedProxy: {
62
+ trustedProxyCidrs: never[];
63
+ trustedProxyHeader: undefined;
64
+ trustedProxyHopCount: number;
65
+ };
66
+ rateLimits: {
67
+ categories: {
68
+ oauth_authorize: {
69
+ maximumRequests: number;
70
+ windowSeconds: number;
71
+ };
72
+ oauth_register: {
73
+ maximumRequests: number;
74
+ windowSeconds: number;
75
+ };
76
+ oauth_token_network: {
77
+ maximumRequests: number;
78
+ windowSeconds: number;
79
+ };
80
+ oauth_token_client: {
81
+ maximumRequests: number;
82
+ windowSeconds: number;
83
+ };
84
+ oauth_revoke: {
85
+ maximumRequests: number;
86
+ windowSeconds: number;
87
+ };
88
+ mcp_network: {
89
+ maximumRequests: number;
90
+ windowSeconds: number;
91
+ };
92
+ mcp_user: {
93
+ maximumRequests: number;
94
+ windowSeconds: number;
95
+ };
96
+ failed_authentication: {
97
+ maximumRequests: number;
98
+ windowSeconds: number;
99
+ };
100
+ };
101
+ maximumConcurrent: number;
102
+ };
103
+ mcpUiExtension: {
104
+ enabled: true;
105
+ };
106
+ rateLimitStores: {
107
+ slidingWindow: {
108
+ consume: () => Promise<{
109
+ allowed: true;
110
+ retryAfterMilliseconds: number;
111
+ remainingRequests: number;
112
+ }>;
113
+ peek: () => Promise<number>;
114
+ };
115
+ concurrencySlots: {
116
+ acquire: () => Promise<null>;
117
+ renew: () => Promise<boolean>;
118
+ release: () => Promise<void>;
119
+ };
120
+ };
121
+ };
122
+ export declare const crossInstanceMessagingContractFixture: {
123
+ publish: () => Promise<void>;
124
+ subscribe: () => Promise<() => Promise<void>>;
125
+ };
126
+ export declare const requestContextContractFixture: {
127
+ request: Request;
128
+ requestUrl: URL;
129
+ requestId: string;
130
+ socketAddress: string;
131
+ identity: null;
132
+ };
133
+ export declare const structuralRedisClientContractFixture: MinimalRedisClient;
134
+ export {};
@@ -0,0 +1,56 @@
1
+ import type { AccessToken, AuthorizationCode, AuthorizationTransaction, ClientStore, CodeStore, ConsumedAuthorizationCode, ConsumedAuthorizationTransaction, OAuthStores, RefreshToken, RegisteredClient, TokenStore, TransactionStore } from '../stores.js';
2
+ export declare class InMemoryTransactionStore implements TransactionStore {
3
+ #private;
4
+ create(input: {
5
+ record: Omit<AuthorizationTransaction, 'transactionIdHash'>;
6
+ transactionId: string;
7
+ csrfToken: string;
8
+ consentBinding: string;
9
+ }): Promise<void>;
10
+ consume(transactionId: string, csrfToken: string, binding: string, subjectId: string): Promise<ConsumedAuthorizationTransaction | null>;
11
+ unconsume(transactionId: string, consumedAt: Date): Promise<boolean>;
12
+ deleteByBinding(value: string): Promise<number>;
13
+ deleteAllForUser(userId: string): Promise<number>;
14
+ purgeExpired(now: Date): Promise<number>;
15
+ }
16
+ export declare class InMemoryCodeStore implements CodeStore {
17
+ #private;
18
+ issue(record: AuthorizationCode): Promise<void>;
19
+ findByHash(codeHash: string): Promise<AuthorizationCode | null>;
20
+ consume(codeHash: string, now: Date): Promise<ConsumedAuthorizationCode | null>;
21
+ unconsume(codeHash: string, usedAt: Date): Promise<boolean>;
22
+ deleteAllForUser(userId: string): Promise<number>;
23
+ purgeExpired(now: Date): Promise<number>;
24
+ }
25
+ export declare class InMemoryTokenStore implements TokenStore {
26
+ #private;
27
+ issueAuthorizationGrant(input: {
28
+ accessToken: AccessToken;
29
+ refreshToken?: RefreshToken;
30
+ }): Promise<void>;
31
+ findByHash(tokenHash: string): Promise<AccessToken | null>;
32
+ rotateRefreshToken(input: {
33
+ priorHash: string;
34
+ clientId: string;
35
+ resource: string;
36
+ requestedScope?: string;
37
+ nextAccessTokenHash: string;
38
+ nextRefreshTokenHash: string;
39
+ accessTokenExpiresAt: Date;
40
+ refreshTokenExpiresAt: Date;
41
+ createdAt: Date;
42
+ }): ReturnType<TokenStore['rotateRefreshToken']>;
43
+ revokeAccessToken(tokenHash: string, clientId: string): Promise<boolean>;
44
+ revokeRefreshToken(tokenHash: string, clientId: string): ReturnType<TokenStore['revokeRefreshToken']>;
45
+ revokeFamily(familyId: string): Promise<number>;
46
+ deleteAllForUser(userId: string): Promise<number>;
47
+ purgeExpired(now: Date): Promise<number>;
48
+ }
49
+ export declare class InMemoryClientStore implements ClientStore {
50
+ #private;
51
+ register(record: RegisteredClient): Promise<void>;
52
+ upsert(record: RegisteredClient): Promise<void>;
53
+ findById(clientId: string): Promise<RegisteredClient | null>;
54
+ update(clientId: string, patch: Partial<RegisteredClient>): Promise<void>;
55
+ }
56
+ export declare function createInMemoryOAuthStores(): OAuthStores;