@lostgradient/mcp 0.2.5 → 0.3.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 (123) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -173
  3. package/dist/http.d.ts +35 -0
  4. package/dist/http.js +251 -0
  5. package/dist/internal/cryptography/encryption.d.ts +108 -0
  6. package/dist/internal/cryptography/encryption.js +241 -0
  7. package/dist/internal/cryptography/hash.d.ts +72 -0
  8. package/dist/internal/cryptography/hash.js +233 -0
  9. package/dist/internal/cryptography/index.d.ts +4 -0
  10. package/dist/internal/cryptography/index.js +2 -0
  11. package/dist/oauth/canonicalize-ip-address.d.ts +0 -6
  12. package/dist/oauth/canonicalize-ip-address.js +113 -0
  13. package/dist/oauth/client-metadata-documents.d.ts +2 -22
  14. package/dist/oauth/client-metadata-documents.js +205 -19
  15. package/dist/oauth/index.d.ts +9 -213
  16. package/dist/oauth/index.js +6 -69
  17. package/dist/oauth/issuer.d.ts +103 -0
  18. package/dist/oauth/issuer.js +564 -0
  19. package/dist/oauth/postgres.d.ts +12 -0
  20. package/dist/oauth/postgres.js +76 -0
  21. package/dist/oauth/safe-public-https-fetch.d.ts +3 -5
  22. package/dist/oauth/safe-public-https-fetch.js +114 -0
  23. package/dist/oauth/security-utilities.d.ts +0 -3
  24. package/dist/oauth/security-utilities.js +93 -0
  25. package/dist/oauth-store.d.ts +108 -0
  26. package/dist/oauth-store.js +321 -0
  27. package/package.json +50 -124
  28. package/dist/chunk-3ek3knfm.js +0 -73
  29. package/dist/chunk-3rr24vhh.js +0 -28
  30. package/dist/chunk-6ekjtvcq.js +0 -273
  31. package/dist/chunk-88nhf6xt.js +0 -449
  32. package/dist/chunk-en76akaq.js +0 -1107
  33. package/dist/chunk-k6fm3cmk.js +0 -132
  34. package/dist/chunk-qxwd8est.js +0 -916
  35. package/dist/chunk-rxnyn7tf.js +0 -19
  36. package/dist/chunk-taxyscge.js +0 -67
  37. package/dist/chunk-wsnfttyg.js +0 -4
  38. package/dist/chunk-xcf742mf.js +0 -14
  39. package/dist/conformance-fixture-registration.d.ts +0 -30
  40. package/dist/conformance-server.d.ts +0 -1
  41. package/dist/conformance.d.ts +0 -43
  42. package/dist/env.d.ts +0 -59
  43. package/dist/env.js +0 -9
  44. package/dist/environment-schema.d.ts +0 -29
  45. package/dist/environment-schema.js +0 -6
  46. package/dist/golden-prompts.d.ts +0 -42
  47. package/dist/handler-context.d.ts +0 -16
  48. package/dist/http/authenticate.d.ts +0 -35
  49. package/dist/http/authorization-header.d.ts +0 -5
  50. package/dist/http/grant-revocation-channel.d.ts +0 -24
  51. package/dist/http/handler.d.ts +0 -32
  52. package/dist/http/index.d.ts +0 -27
  53. package/dist/http/index.js +0 -870
  54. package/dist/http/listen-inspection.d.ts +0 -11
  55. package/dist/http/request-context.d.ts +0 -17
  56. package/dist/http/responses.d.ts +0 -13
  57. package/dist/http/serving-layer.d.ts +0 -25
  58. package/dist/http/user-handler-cache.d.ts +0 -37
  59. package/dist/http/user-server-event-bus.d.ts +0 -35
  60. package/dist/index.d.ts +0 -29
  61. package/dist/index.js +0 -616
  62. package/dist/localhost-request-validation.d.ts +0 -2
  63. package/dist/logger.d.ts +0 -59
  64. package/dist/logger.js +0 -18
  65. package/dist/long-running-operation-support.d.ts +0 -34
  66. package/dist/metrics.d.ts +0 -64
  67. package/dist/metrics.js +0 -6
  68. package/dist/oauth/authorize-endpoint.d.ts +0 -5
  69. package/dist/oauth/client-authentication.d.ts +0 -10
  70. package/dist/oauth/discovery-metadata.d.ts +0 -19
  71. package/dist/oauth/endpoint-rate-limits.d.ts +0 -10
  72. package/dist/oauth/endpoint-responses.d.ts +0 -10
  73. package/dist/oauth/network-identity.d.ts +0 -32
  74. package/dist/oauth/pkce-validation.d.ts +0 -2
  75. package/dist/oauth/postgres/client-store.d.ts +0 -12
  76. package/dist/oauth/postgres/code-store.d.ts +0 -14
  77. package/dist/oauth/postgres/database.d.ts +0 -59
  78. package/dist/oauth/postgres/index.d.ts +0 -11
  79. package/dist/oauth/postgres/index.js +0 -616
  80. package/dist/oauth/postgres/schema.d.ts +0 -1476
  81. package/dist/oauth/postgres/token-store.d.ts +0 -16
  82. package/dist/oauth/postgres/transaction-store.d.ts +0 -14
  83. package/dist/oauth/redirect-uri-matching.d.ts +0 -2
  84. package/dist/oauth/registration-endpoint.d.ts +0 -2
  85. package/dist/oauth/request-body.d.ts +0 -14
  86. package/dist/oauth/revocation-endpoint.d.ts +0 -2
  87. package/dist/oauth/scope-utilities.d.ts +0 -15
  88. package/dist/oauth/stores.d.ts +0 -225
  89. package/dist/oauth/stores.js +0 -0
  90. package/dist/oauth/testing/contract-fixtures.d.ts +0 -134
  91. package/dist/oauth/testing/index.d.ts +0 -56
  92. package/dist/oauth/testing/index.js +0 -330
  93. package/dist/oauth/token-endpoint.d.ts +0 -2
  94. package/dist/oauth-scope-configuration.d.ts +0 -3
  95. package/dist/prompts/index.d.ts +0 -5
  96. package/dist/prompts/summarize.d.ts +0 -4
  97. package/dist/rate-limit/in-memory-sliding-window-store.d.ts +0 -3
  98. package/dist/rate-limit/index.d.ts +0 -23
  99. package/dist/rate-limit/index.js +0 -29
  100. package/dist/rate-limit/mcp-concurrency-limiter.d.ts +0 -26
  101. package/dist/rate-limit/rate-limit-response.d.ts +0 -1
  102. package/dist/rate-limit/redis-sliding-window-store.d.ts +0 -2
  103. package/dist/rate-limit/request-rate-limiter.d.ts +0 -10
  104. package/dist/rate-limit/sliding-window-rate-limiter.d.ts +0 -16
  105. package/dist/resources/index.d.ts +0 -4
  106. package/dist/resources/user-profile.d.ts +0 -1
  107. package/dist/scope-vocabulary.d.ts +0 -127
  108. package/dist/scopes.d.ts +0 -49
  109. package/dist/server.d.ts +0 -113
  110. package/dist/supported-scopes.d.ts +0 -25
  111. package/dist/sveltekit-mount-state.d.ts +0 -4
  112. package/dist/sveltekit-mount.d.ts +0 -43
  113. package/dist/sveltekit-mount.js +0 -344
  114. package/dist/template-registry.d.ts +0 -16
  115. package/dist/tool-response.d.ts +0 -100
  116. package/dist/tools/get-user-profile.d.ts +0 -8
  117. package/dist/tools/index.d.ts +0 -16
  118. package/dist/tools/list-audit-events.d.ts +0 -11
  119. package/dist/type-assertions.d.ts +0 -1
  120. package/dist/types/primitives.d.ts +0 -130
  121. package/dist/ui-extension-support.d.ts +0 -20
  122. package/dist/version.d.ts +0 -23
  123. package/dist/version.js +0 -6
@@ -0,0 +1,76 @@
1
+ import { PostgresStorage } from '@lostgradient/storage-postgres';
2
+ import { OAuthStore } from "../oauth-store.js";
3
+ export function createPostgresOAuthStores(options) {
4
+ const storage = new PostgresStorage(options);
5
+ const store = new OAuthStore(storage);
6
+ return Object.assign(store, { [Symbol.asyncDispose]: () => storage[Symbol.asyncDispose]() });
7
+ }
8
+ /** Cross-host revocation hints. Durable authority remains the source of truth. */
9
+ export async function createPostgresGrantRevocationChannel(options) {
10
+ options = { ...options };
11
+ const { default: pg } = await import('pg');
12
+ const client = new pg.Client({ connectionString: options.url });
13
+ const listeners = new Map();
14
+ let available = true;
15
+ const closeStreams = () => {
16
+ available = false;
17
+ for (const callbacks of listeners.values())
18
+ for (const callback of callbacks)
19
+ callback();
20
+ listeners.clear();
21
+ };
22
+ client.on('error', closeStreams);
23
+ client.on('end', closeStreams);
24
+ client.on('notification', (message) => {
25
+ if (message.channel !== 'corvidae_grant_revoked' || !message.payload)
26
+ return;
27
+ try {
28
+ const payload = JSON.parse(message.payload);
29
+ if (typeof payload !== 'object' ||
30
+ payload === null ||
31
+ !('issuer' in payload) ||
32
+ !('grantId' in payload) ||
33
+ payload.issuer !== options.issuer ||
34
+ typeof payload.grantId !== 'string')
35
+ return;
36
+ for (const callback of listeners.get(payload.grantId) ?? [])
37
+ callback();
38
+ }
39
+ catch {
40
+ /* Invalid notices cannot grant authority. */
41
+ }
42
+ });
43
+ await client.connect();
44
+ await client.query('LISTEN corvidae_grant_revoked');
45
+ return {
46
+ async publish(grantId) {
47
+ if (!available)
48
+ throw new Error('Grant revocation channel unavailable');
49
+ await client.query('SELECT pg_notify($1, $2)', [
50
+ 'corvidae_grant_revoked',
51
+ JSON.stringify({ issuer: options.issuer, grantId }),
52
+ ]);
53
+ },
54
+ subscribe(grantId, callback) {
55
+ if (!available) {
56
+ queueMicrotask(callback);
57
+ return () => { };
58
+ }
59
+ let callbacks = listeners.get(grantId);
60
+ if (!callbacks) {
61
+ callbacks = new Set();
62
+ listeners.set(grantId, callbacks);
63
+ }
64
+ callbacks.add(callback);
65
+ return () => {
66
+ callbacks.delete(callback);
67
+ if (callbacks.size === 0)
68
+ listeners.delete(grantId);
69
+ };
70
+ },
71
+ async [Symbol.asyncDispose]() {
72
+ closeStreams();
73
+ await client.end();
74
+ },
75
+ };
76
+ }
@@ -10,9 +10,9 @@ export type DnsLookupAllFunction = (hostname: string, options: {
10
10
  family: number;
11
11
  }[]>;
12
12
  export type SafePublicHttpsFetchOptions = {
13
- fetchImpl?: typeof fetch;
14
- lookupImpl?: DnsLookupAllFunction;
15
- dnsTimeoutMs?: number;
13
+ fetchImpl?: ((input: string | URL | Request, init?: RequestInit) => Promise<Response>) | undefined;
14
+ lookupImpl?: DnsLookupAllFunction | undefined;
15
+ dnsTimeoutMs?: number | undefined;
16
16
  fetchTimeoutMs?: number;
17
17
  headers?: HeadersInit;
18
18
  };
@@ -24,5 +24,3 @@ export type SafePublicHttpsFetchOptions = {
24
24
  * for the original public hostname.
25
25
  */
26
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,114 @@
1
+ import { lookup as defaultDnsLookup } from 'node:dns/promises';
2
+ import { isIPv4, isIPv6 } from 'node:net';
3
+ import { isAddressInCidr, withDeadline } from "./security-utilities.js";
4
+ const defaultFetchTimeoutMilliseconds = 5_000;
5
+ const blockedIpCidrs = [
6
+ '0.0.0.0/8',
7
+ '10.0.0.0/8',
8
+ '100.64.0.0/10',
9
+ '127.0.0.0/8',
10
+ '169.254.0.0/16',
11
+ '172.16.0.0/12',
12
+ '192.0.0.0/24',
13
+ '192.0.2.0/24',
14
+ '192.88.99.0/24',
15
+ '192.168.0.0/16',
16
+ '198.18.0.0/15',
17
+ '198.51.100.0/24',
18
+ '203.0.113.0/24',
19
+ '224.0.0.0/4',
20
+ '240.0.0.0/4',
21
+ '255.255.255.255/32',
22
+ '::1/128',
23
+ '::/128',
24
+ '64:ff9b::/96',
25
+ '::ffff:0:0/96',
26
+ '100::/64',
27
+ '2001:db8::/32',
28
+ 'fc00::/7',
29
+ 'fe80::/10',
30
+ 'ff00::/8',
31
+ ];
32
+ function isBlockedIpAddress(address) {
33
+ return blockedIpCidrs.some((cidr) => isAddressInCidr(address, cidr));
34
+ }
35
+ function stripIpv6Brackets(hostname) {
36
+ return hostname.startsWith('[') && hostname.endsWith(']') ? hostname.slice(1, -1) : hostname;
37
+ }
38
+ export class ClientMetadataDocumentFetchError extends Error {
39
+ reason;
40
+ constructor(reason) {
41
+ super(reason);
42
+ this.reason = reason;
43
+ this.name = 'ClientMetadataDocumentFetchError';
44
+ }
45
+ }
46
+ const lookupAll = (hostname, options) => defaultDnsLookup(hostname, options);
47
+ const dnsLookupConcurrencyLimit = 16;
48
+ let outstandingDnsLookupCount = 0;
49
+ const inFlightDnsLookupsByHostname = new Map();
50
+ // DNS lookup has no cancellable deadline. Coalescing a hostname prevents one
51
+ // stalled name from consuming repeated resolver work, while the global limit
52
+ // fails closed instead of creating an unbounded queue of distinct names. This
53
+ // is deliberately not a TTL cache: every later request must resolve and check
54
+ // the current complete address set again.
55
+ function boundedCoalescedLookup(hostname, lookupImpl) {
56
+ const inFlight = inFlightDnsLookupsByHostname.get(hostname);
57
+ if (inFlight)
58
+ return inFlight;
59
+ if (outstandingDnsLookupCount >= dnsLookupConcurrencyLimit) {
60
+ return Promise.reject(new Error('DNS lookup concurrency limit exceeded'));
61
+ }
62
+ outstandingDnsLookupCount += 1;
63
+ const lookupPromise = lookupImpl(hostname, { all: true, verbatim: true }).finally(() => {
64
+ outstandingDnsLookupCount -= 1;
65
+ inFlightDnsLookupsByHostname.delete(hostname);
66
+ });
67
+ inFlightDnsLookupsByHostname.set(hostname, lookupPromise);
68
+ return lookupPromise;
69
+ }
70
+ async function assertHostnameIsPubliclyRoutable(hostname, lookupImpl, dnsTimeoutMilliseconds) {
71
+ if (isIPv4(hostname) || isIPv6(hostname)) {
72
+ if (isBlockedIpAddress(hostname)) {
73
+ throw new ClientMetadataDocumentFetchError('blocked_address');
74
+ }
75
+ return;
76
+ }
77
+ let records;
78
+ try {
79
+ records = await withDeadline(boundedCoalescedLookup(hostname, lookupImpl), dnsTimeoutMilliseconds);
80
+ }
81
+ catch {
82
+ throw new ClientMetadataDocumentFetchError('dns_resolution_failed');
83
+ }
84
+ if (records.length === 0)
85
+ throw new ClientMetadataDocumentFetchError('dns_resolution_failed');
86
+ if (records.some((record) => isBlockedIpAddress(record.address))) {
87
+ throw new ClientMetadataDocumentFetchError('blocked_address');
88
+ }
89
+ }
90
+ /**
91
+ * Fetches one client-supplied HTTPS URL through the complete SSRF boundary:
92
+ * HTTPS-only, literal-IP blocking, every resolved address checked, and no redirects.
93
+ * The resolve-then-connect gap is additionally bounded by normal HTTPS certificate
94
+ * validation: a name rebound to an internal service cannot present a valid certificate
95
+ * for the original public hostname.
96
+ */
97
+ export async function safeFetchPublicHttpsUrl(input, options = {}) {
98
+ const url = input instanceof URL ? input : new URL(input);
99
+ if (url.protocol !== 'https:')
100
+ throw new ClientMetadataDocumentFetchError('https_required');
101
+ await assertHostnameIsPubliclyRoutable(stripIpv6Brackets(url.hostname), options.lookupImpl ?? lookupAll, options.dnsTimeoutMs ?? defaultFetchTimeoutMilliseconds);
102
+ // workerd rejects `redirect: 'error'`, so fetch with `manual` and refuse any redirect ourselves.
103
+ const response = await (options.fetchImpl ?? fetch)(url, {
104
+ method: 'GET',
105
+ redirect: 'manual',
106
+ ...(options.headers ? { headers: options.headers } : {}),
107
+ signal: AbortSignal.timeout(options.fetchTimeoutMs ?? defaultFetchTimeoutMilliseconds),
108
+ });
109
+ if (response.type === 'opaqueredirect' || (response.status >= 300 && response.status < 400)) {
110
+ await response.body?.cancel().catch(() => { });
111
+ throw new ClientMetadataDocumentFetchError('redirect_refused');
112
+ }
113
+ return response;
114
+ }
@@ -1,8 +1,5 @@
1
1
  export declare function isAddressInCidr(address: string, cidr: string): boolean;
2
- export declare function isValidCidr(cidr: string): boolean;
3
2
  export declare function isValidRedirectUri(uri: string): boolean;
4
3
  export declare function isValidClientName(name: string): boolean;
5
4
  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
5
  export declare function withDeadline<T>(promise: Promise<T>, timeoutMilliseconds: number): Promise<T>;
@@ -0,0 +1,93 @@
1
+ import { isIPv4, isIPv6 } from 'node:net';
2
+ import { canonicalizeIpAddress, expandIpv6Groups } from "./canonicalize-ip-address.js";
3
+ function ipToBigInt(address) {
4
+ if (isIPv4(address)) {
5
+ return {
6
+ family: 4,
7
+ value: address
8
+ .split('.')
9
+ .map(Number)
10
+ .reduce((value, octet) => (value << 8n) + BigInt(octet), 0n),
11
+ };
12
+ }
13
+ if (!isIPv6(address))
14
+ return null;
15
+ return {
16
+ family: 6,
17
+ value: expandIpv6Groups(address).reduce((value, group) => (value << 16n) + BigInt(Number.parseInt(group, 16)), 0n),
18
+ };
19
+ }
20
+ function parseCidr(cidr) {
21
+ const [address, prefixText, extra] = cidr.split('/');
22
+ if (!address || !prefixText || extra !== undefined || !/^\d+$/.test(prefixText))
23
+ return null;
24
+ const range = ipToBigInt(canonicalizeIpAddress(address));
25
+ if (!range)
26
+ return null;
27
+ const prefixLength = Number.parseInt(prefixText, 10);
28
+ if (prefixLength > (range.family === 4 ? 32 : 128))
29
+ return null;
30
+ return { ...range, prefixLength };
31
+ }
32
+ export function isAddressInCidr(address, cidr) {
33
+ const range = parseCidr(cidr);
34
+ const candidate = ipToBigInt(canonicalizeIpAddress(address));
35
+ if (!range || !candidate || candidate.family !== range.family)
36
+ return false;
37
+ if (range.prefixLength === 0)
38
+ return true;
39
+ const shift = BigInt((candidate.family === 4 ? 32 : 128) - range.prefixLength);
40
+ return candidate.value >> shift === range.value >> shift;
41
+ }
42
+ export function isValidRedirectUri(uri) {
43
+ let parsed;
44
+ try {
45
+ parsed = new URL(uri);
46
+ }
47
+ catch {
48
+ return false;
49
+ }
50
+ if (parsed.hash || parsed.username || parsed.password || parsed.hostname.includes('*'))
51
+ return false;
52
+ if (parsed.protocol === 'https:')
53
+ return true;
54
+ return (parsed.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(parsed.hostname));
55
+ }
56
+ // Control characters are the security boundary this expression enforces.
57
+ // eslint-disable-next-line no-control-regex
58
+ const controlCharacterPattern = /[\u0000-\u001F\u007F-\u009F]/;
59
+ const bidiControlCharacterPattern = /[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/;
60
+ const zeroWidthCharacterPattern = /[\u200B-\u200D\uFEFF]/;
61
+ const latinScriptCharacterPattern = /\p{Script=Latin}/u;
62
+ const confusableWithLatinScriptCharacterPattern = /\p{Script=Cyrillic}|\p{Script=Greek}/u;
63
+ export function isValidClientName(name) {
64
+ return (Boolean(name) &&
65
+ !controlCharacterPattern.test(name) &&
66
+ !bidiControlCharacterPattern.test(name) &&
67
+ !zeroWidthCharacterPattern.test(name) &&
68
+ !(latinScriptCharacterPattern.test(name) && confusableWithLatinScriptCharacterPattern.test(name)));
69
+ }
70
+ export function isExactContentType(value, expectedMediaType) {
71
+ if (value === null)
72
+ return false;
73
+ let inQuotes = false;
74
+ for (const character of value) {
75
+ if (character === '"')
76
+ inQuotes = !inQuotes;
77
+ else if (character === ',' && !inQuotes)
78
+ return false;
79
+ }
80
+ return value.split(';')[0]?.trim().toLowerCase() === expectedMediaType;
81
+ }
82
+ export function withDeadline(promise, timeoutMilliseconds) {
83
+ return new Promise((resolve, reject) => {
84
+ const timer = setTimeout(() => reject(new Error(`Timed out after ${timeoutMilliseconds}ms`)), timeoutMilliseconds);
85
+ promise.then((value) => {
86
+ clearTimeout(timer);
87
+ return resolve(value);
88
+ }, (error) => {
89
+ clearTimeout(timer);
90
+ return reject(error instanceof Error ? error : new Error(String(error)));
91
+ });
92
+ });
93
+ }
@@ -0,0 +1,108 @@
1
+ import { type ConditionalBatchCondition, type Storage } from '@lostgradient/storage';
2
+ type Consent = {
3
+ issuer: string;
4
+ client: string;
5
+ redirect: string;
6
+ csrf: string;
7
+ binding: string;
8
+ subject: string;
9
+ challenge: string;
10
+ expiresAt: number;
11
+ tenant: string;
12
+ resource: string;
13
+ scopes: string[];
14
+ state: string;
15
+ };
16
+ type ConsentBinding = Pick<Consent, 'issuer' | 'client' | 'csrf' | 'binding' | 'subject'>;
17
+ type Approval = {
18
+ grantId: string;
19
+ code: string;
20
+ tenant: string;
21
+ subject: string;
22
+ resource: string;
23
+ scopes: string[];
24
+ };
25
+ export type OAuthGrant = Omit<Approval, 'code'> & {
26
+ issuer: string;
27
+ client: string;
28
+ active: boolean;
29
+ approvedAt: number | null;
30
+ };
31
+ type Grant = OAuthGrant;
32
+ type Code = {
33
+ grantId: string;
34
+ client: string;
35
+ redirect: string;
36
+ challenge: string;
37
+ expiresAt: number;
38
+ };
39
+ type Exchange = {
40
+ issuer: string;
41
+ code: string;
42
+ client: string;
43
+ redirect: string;
44
+ resource: string;
45
+ verifier: string;
46
+ access: string;
47
+ refresh: string | null;
48
+ accessExpiresAt: number;
49
+ refreshExpiresAt: number;
50
+ };
51
+ type Rotation = {
52
+ issuer: string;
53
+ refresh: string;
54
+ client: string;
55
+ resource: string;
56
+ access: string;
57
+ nextRefresh: string;
58
+ accessExpiresAt: number;
59
+ refreshExpiresAt: number;
60
+ scopes: string[];
61
+ };
62
+ export type OAuthClient = {
63
+ issuer: string;
64
+ clientId: string;
65
+ name: string;
66
+ redirectUris: string[];
67
+ grantTypes: string[];
68
+ authentication: 'none' | 'client_secret_post';
69
+ secretHash: string | null;
70
+ secretExpiresAt: number | null;
71
+ };
72
+ export declare class OAuthStore {
73
+ private readonly storage;
74
+ constructor(storage: Storage);
75
+ usesStorage(storage: Storage): boolean;
76
+ registerClient(client: OAuthClient): Promise<boolean>;
77
+ getClient(id: string): Promise<OAuthClient | null>;
78
+ createConsent(id: string, consent: Consent): Promise<boolean>;
79
+ getConsent(id: string, binding: ConsentBinding): Promise<Consent | null>;
80
+ denyConsent(id: string, binding: ConsentBinding, sessionCondition?: ConditionalBatchCondition & {
81
+ deadline?: number | undefined;
82
+ }): Promise<boolean>;
83
+ private matchesConsent;
84
+ approveConsent(id: string, binding: ConsentBinding, approval: Approval, sessionCondition?: ConditionalBatchCondition & {
85
+ deadline?: number | undefined;
86
+ }): Promise<boolean>;
87
+ getGrant(id: string): Promise<Grant | null>;
88
+ listGrants(identity: {
89
+ issuer: string;
90
+ tenant: string;
91
+ subject: string;
92
+ }): Promise<OAuthGrant[]>;
93
+ revokeOwnedGrant(id: string, identity: {
94
+ issuer: string;
95
+ tenant: string;
96
+ subject: string;
97
+ }): Promise<boolean>;
98
+ getCode(id: string): Promise<Code | null>;
99
+ exchange(input: Exchange): Promise<boolean>;
100
+ getAccess(token: string): Promise<(Grant & {
101
+ expiresAt: number;
102
+ }) | null>;
103
+ getRefreshGrant(token: string): Promise<Grant | null>;
104
+ revokeToken(token: string, issuer: string, client: string): Promise<void>;
105
+ revokeGrant(id: string): Promise<boolean>;
106
+ rotate(input: Rotation): Promise<'rotated' | 'invalid' | 'replay_revoked' | 'scope_rejected'>;
107
+ }
108
+ export {};