@authfn/oauth-provider 0.1.1 → 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 (60) hide show
  1. package/README.md +62 -2
  2. package/dist/authorize/index.d.ts.map +1 -1
  3. package/dist/authorize/index.js +6 -6
  4. package/dist/authorize/index.js.map +1 -1
  5. package/dist/device/index.d.ts +39 -0
  6. package/dist/device/index.d.ts.map +1 -0
  7. package/dist/device/index.js +409 -0
  8. package/dist/device/index.js.map +1 -0
  9. package/dist/device/store.d.ts +129 -0
  10. package/dist/device/store.d.ts.map +1 -0
  11. package/dist/device/store.js +325 -0
  12. package/dist/device/store.js.map +1 -0
  13. package/dist/device/types.d.ts +87 -0
  14. package/dist/device/types.d.ts.map +1 -0
  15. package/dist/device/types.js +3 -0
  16. package/dist/device/types.js.map +1 -0
  17. package/dist/http.d.ts +2 -2
  18. package/dist/http.d.ts.map +1 -1
  19. package/dist/http.js +2 -2
  20. package/dist/http.js.map +1 -1
  21. package/dist/index.d.ts +7 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +24 -5
  24. package/dist/index.js.map +1 -1
  25. package/dist/metadata/index.d.ts.map +1 -1
  26. package/dist/metadata/index.js +7 -1
  27. package/dist/metadata/index.js.map +1 -1
  28. package/dist/registration/document.d.ts +53 -0
  29. package/dist/registration/document.d.ts.map +1 -0
  30. package/dist/registration/document.js +173 -0
  31. package/dist/registration/document.js.map +1 -0
  32. package/dist/registration/index.d.ts +38 -0
  33. package/dist/registration/index.d.ts.map +1 -0
  34. package/dist/registration/index.js +264 -0
  35. package/dist/registration/index.js.map +1 -0
  36. package/dist/registration/metadata.d.ts +27 -0
  37. package/dist/registration/metadata.d.ts.map +1 -0
  38. package/dist/registration/metadata.js +74 -0
  39. package/dist/registration/metadata.js.map +1 -0
  40. package/dist/registration/store.d.ts +86 -0
  41. package/dist/registration/store.d.ts.map +1 -0
  42. package/dist/registration/store.js +187 -0
  43. package/dist/registration/store.js.map +1 -0
  44. package/dist/revocation/index.js +1 -1
  45. package/dist/revocation/index.js.map +1 -1
  46. package/dist/runtime.d.ts +10 -0
  47. package/dist/runtime.d.ts.map +1 -1
  48. package/dist/runtime.js +5 -1
  49. package/dist/runtime.js.map +1 -1
  50. package/dist/store.d.ts +34 -5
  51. package/dist/store.d.ts.map +1 -1
  52. package/dist/store.js +37 -14
  53. package/dist/store.js.map +1 -1
  54. package/dist/token/index.d.ts.map +1 -1
  55. package/dist/token/index.js +6 -2
  56. package/dist/token/index.js.map +1 -1
  57. package/dist/types.d.ts +44 -1
  58. package/dist/types.d.ts.map +1 -1
  59. package/dist/types.js.map +1 -1
  60. package/package.json +2 -2
package/README.md CHANGED
@@ -5,9 +5,11 @@ OAuth 2.1 authorization server for AuthFn. It serves:
5
5
  - `GET {basePath}/.well-known/oauth-authorization-server`: metadata (RFC 8414)
6
6
  - `GET {basePath}/oauth/authorize`: authorization code with PKCE `S256` only
7
7
  - `POST {basePath}/oauth/authorize`: the consent decision
8
- - `POST {basePath}/oauth/token`: code exchange; refresh with rotation and reuse detection
8
+ - `POST {basePath}/oauth/token`: code exchange; refresh with rotation and reuse detection; the device code grant (RFC 8628) when `deviceAuthorization` is configured
9
9
  - `POST {basePath}/oauth/revoke`: revocation (RFC 7009)
10
10
  - `POST {basePath}/oauth/introspect`: introspection (RFC 7662)
11
+ - `POST {basePath}/oauth/register`: dynamic client registration (RFC 7591), when `registration.dynamic` is on
12
+ - `POST {basePath}/oauth/device_authorization`, `GET`/`POST {basePath}/oauth/device`: the device authorization grant (RFC 8628) for CLIs, when `deviceAuthorization` is configured
11
13
 
12
14
  Every token is bound to one resource (RFC 8707) and carries the scopes the user granted, using the AuthFn scope registry.
13
15
 
@@ -49,7 +51,65 @@ const auth = app.createServer({
49
51
  - Client authentication failures are `invalid_client`: 401 with a `Basic` challenge when the client sent an `Authorization` header, otherwise 400. A public or `client_secret_post` client that sends any `Authorization` header fails.
50
52
  - A `trusted` client asks for consent once per resource; later requests within the consented scopes skip the page. Any other client asks every time.
51
53
  - Tokens stop working when their grant is revoked or their user is deleted or disabled (`metadata.disabled`).
52
- - A code or refresh token is spent by a conditional write that also stores a claim ID, and the request that reads its own claim ID back wins; adapter row counts are not used. The new access and refresh tokens are stored first, each recording that claim ID, and a token is valid only while the code or refresh token it was issued for stores the same claim ID. So the claim is the single commit point and nothing is ever undone: a failure before it leaves the credential unspent and the stored tokens inert, and the loser of a concurrent exchange gets nothing usable. If the claim write fails, its read-back still decides, since the write may have committed. After the claim commits, the exchange checks the grant and user again: a disconnect, a revocation or a disabled or deleted user that took effect before the commit gets `invalid_grant`, never tokens; one that takes effect later revokes the tokens delivered. Only when the response is lost after the claim commits (including a lost write acknowledgement whose read-back also fails) is the credential spent without the client holding the tokens; presenting it again is a replay that revokes the grant, so the user authorizes again. Because validity reads the code or parent refresh token row, keep code rows and rotated refresh token rows while a token issued from them can still be valid (up to 30 days after their own refresh token was issued); deleting them makes those tokens inactive.
54
+ - A code, device code or refresh token is spent by a conditional write that also stores a claim ID, and the request that reads its own claim ID back wins; adapter row counts are not used. The new access and refresh tokens are stored first, each recording that claim ID, and a token is valid only while the code or refresh token it was issued for stores the same claim ID. So the claim is the single commit point and nothing is ever undone: a failure before it leaves the credential unspent and the stored tokens inert, and the loser of a concurrent exchange gets nothing usable. If the claim write fails, its read-back still decides, since the write may have committed. After the claim commits, the exchange checks the grant and user again: a disconnect, a revocation or a disabled or deleted user that took effect before the commit gets `invalid_grant`, never tokens; one that takes effect later revokes the tokens delivered. Only when the response is lost after the claim commits (including a lost write acknowledgement whose read-back also fails) is the credential spent without the client holding the tokens; presenting it again is a replay that revokes the grant, so the user authorizes again. Because validity reads the code, device code or parent refresh token row, keep code rows, exchanged device code rows and rotated refresh token rows while a token issued from them can still be valid (up to 30 days after their own refresh token was issued); deleting them makes those tokens inactive. The provider itself deletes a device code row only once no token issued for it can be valid (see Device authorization).
55
+
56
+ ## Client registration
57
+
58
+ MCP hosts and other public clients can register themselves. Both ways are off until `pluginRuntime.oauthProvider.registration` turns them on:
59
+
60
+ ```ts
61
+ registration: {
62
+ dynamic: true, // RFC 7591 at {basePath}/oauth/register
63
+ metadataDocuments: true, // an https client_id URL serving the client's metadata
64
+ rateLimit: { perIp: 20, global: 200, windowSeconds: 3600 }, // the defaults
65
+ // Only behind Cloudflare, which overwrites cf-connecting-ip; see below.
66
+ resolveClientIp: (request) => request.headers.get('cf-connecting-ip') ?? undefined,
67
+ fetch: egressRestrictedFetch // required with metadataDocuments
68
+ }
69
+ ```
70
+
71
+ `resolveClientIp` must return an address that your own ingress sets, never a header a caller can send: `cf-connecting-ip` only when every request passes through Cloudflare, which overwrites it, and `x-forwarded-for` only as appended by a proxy you run. Otherwise a caller picks a new "IP" for each request and only the overall limit holds.
72
+
73
+ - Only public clients are accepted: `token_endpoint_auth_method` must be `none` (or absent), and metadata carrying `client_secret` is refused with `invalid_client_metadata`. `grant_types`, when supplied, must include `authorization_code` and may add `refresh_token`; `response_types` may only be `code`. Other metadata is ignored.
74
+ - `redirect_uris` lists 1 to 10 URIs, each `https` or `http://127.0.0.1[:port]` (the port may vary at authorization), under the same rules as configured redirect URIs; anything else, including `http://localhost`, `http://[::1]` and native app schemes, is `invalid_redirect_uri`. An authorization request whose `redirect_uri` is not registered is refused without a redirect.
75
+ - A registered client is never `trusted`: it asks for consent on every authorization. Its name on the consent page is its `client_name`, or its `client_id` without one. RFC 7592 client management is not offered, and registered clients keep working after `dynamic` is turned off, which only stops new registrations.
76
+ - **Client ID Metadata Documents.** A `client_id` that is an `https` URL is resolved by fetching it. The URL must have a path and no query, fragment or credentials (not even an empty `?` or `#`), be written in normalized form, be at most 255 characters, and name a public DNS host of valid labels: IP literals, single-label names, empty labels such as `foo..example.com` and `localhost`, `.local`, `.internal`, `.localdomain` and `.home.arpa` names are refused without a request. The fetch does not follow redirects, must answer `200` within 5 seconds (body included) and at most 64 KB, and the document must name that exact URL as its `client_id` and pass the registration rules above. A usable document is stored and shared by every instance. A known client (one that has served a usable document) is refetched at most once per 5 minutes across all instances, so a changed document takes effect within about 10 minutes. These refetches are not rate-limited and do not use up the limit, so flooding only refuses new clients. When the host gives no usable answer (a network error, no complete answer within 5 seconds, a `5xx`, `408` or `429`), a known client keeps its last document. Any other answer that is not a usable UTF-8 JSON document makes the client unknown and drops its stored document. Only the request holding the current refetch claim stores or drops what it fetched; a refetch that stalls past its 5-minute claim, or runs on an instance whose clock is behind, changes nothing and serves the document stored by the newer claim. A public host name can still resolve to a private address, so `metadataDocuments` requires a `fetch` and the server refuses to start without one: pass one that cannot reach private or internal addresses (for example through an egress proxy that refuses them). Where the platform's own `fetch` already cannot reach them, pass that explicitly.
77
+ - **Rate limit.** Registrations and first fetches of unknown metadata document clients are limited separately, per client IP and overall, in fixed windows stored in the database, so every instance shares them. Over the limit the answer is `429` `temporarily_unavailable` with `Retry-After`. Without `resolveClientIp` (or AuthFn's `rateLimit.resolveClientIp`) only the overall limit applies. Concurrent requests never exceed a limit; at its edge they may all be refused, and refused requests do not use it up. A registration body must arrive complete within 5 seconds and be at most 64 KB, so a slow upload cannot hold a request open before it is counted.
78
+ - **Storage.** Registration uses the tables `oauth_provider_clients`, `oauth_provider_document_clients` and `oauth_provider_registration_events`. A custom plugin `schema` that leaves them out gets them added (one it defines itself is kept), so migrate them even while registration is off.
79
+
80
+ ## Device authorization (CLI login)
81
+
82
+ A CLI or other device without a browser signs in with the device authorization grant (RFC 8628). It is off until `pluginRuntime.oauthProvider.deviceAuthorization` turns it on:
83
+
84
+ ```ts
85
+ deviceAuthorization: {
86
+ verification: (input) => renderDevicePage(input),
87
+ rateLimit: { perUser: 10, global: 1000, windowSeconds: 600 }, // user code lookups; the defaults
88
+ authorizationRateLimit: { perIp: 20, global: 1000, windowSeconds: 600 }, // device authorization requests; the defaults
89
+ resolveClientIp: (request) => request.headers.get('cf-connecting-ip') // only behind Cloudflare; see Client registration
90
+ }
91
+ ```
92
+
93
+ 1. The CLI POSTs `client_id`, `resource` and optionally `scope` (form-encoded) to `{basePath}/oauth/device_authorization`. It gets `device_code`, `user_code`, `verification_uri`, `verification_uri_complete`, `expires_in: 600` and `interval: 5`, and shows the user the code and the URI. Over `authorizationRateLimit` it gets `429` `temporarily_unavailable` with `Retry-After`, and nothing is stored. A body over 8 KB, declared or sent, or one that has not arrived within 5 seconds is an `invalid_request`, before the client is authenticated or the request counted.
94
+ 2. The user opens `verification_uri` (`{basePath}/oauth/device`). Without a session the page answers through `loginRequired`, with the page URL as `returnTo`. `verification` renders the page. Without a `user_code` query parameter it asks for the code; its form submits `user_code` with GET to `verificationUrl`. With one, `verification` receives the `authorization` it names (client, resource, scopes), or an `error`: `invalid_user_code` (unknown, malformed, already decided, or for a client that is no longer configured), `expired_user_code` or `too_many_attempts` with `retryAfterSeconds`. The page POSTs `{ user_code, decision: 'approve' | 'deny' }` as JSON to `decisionUrl` with the session cookie and the `x-authfn-csrf` header; the response's `data.decision` is `approved` or `denied`. A code that cannot be decided answers `invalid_grant`, and over the rate limit `429` `temporarily_unavailable` with `Retry-After`.
95
+ 3. Meanwhile the CLI polls the token endpoint with `grant_type=urn:ietf:params:oauth:grant-type:device_code`, `device_code` and its client authentication, and optionally `resource`. After an approval it gets the same response as an authorization code exchange: an access token for the approved scopes and resource and a refresh token that rotates. Otherwise the answer is a `400` with one of:
96
+ - `authorization_pending`: the user has not decided yet.
97
+ - `slow_down`: the poll came within the interval (below).
98
+ - `access_denied`: the user denied the request, or the approved grant was revoked before the exchange (the app was disconnected, also during the approval, or the user was disabled or deleted).
99
+ - `expired_token`: the code is 10 minutes old, decided or not.
100
+ - `invalid_target`: `resource` is not the one requested in step 1; the code is not spent.
101
+ - `invalid_grant`: the code is unknown or was issued to another client, or it was already exchanged (which revokes the grant, below), or the grant was revoked while the exchange ran.
102
+
103
+ A poll that loses 16 rounds to concurrent polls of one code, or that cannot tell whether it was stored because 16 or more polls of the code were stored meanwhile, gets `429` `temporarily_unavailable`, never tokens or `slow_down`; in the second case it may already count as the last poll and have added its 5 seconds. Its `Retry-After` is the time left until the last stored poll time plus the code's interval as stored after the concurrent polls (0 once that has passed), plus those 5 seconds when they may count, so a poll after it is not too fast.
104
+
105
+ - User codes are 8 letters from `BCDFGHJKLMNPQRSTVWXZ` (no vowels, nothing that looks like a digit), shown as `XXXX-XXXX`; the page accepts them in any case, with or without the dash and spaces. They and device codes are valid for 10 minutes and stored only as hashes.
106
+ - A poll less than `interval` seconds after the previous one gets `slow_down` and adds 5 seconds to that device code's interval, and counts as the previous poll, so a client that keeps polling early keeps being slowed. Each poll gets one answer and is stored once: of concurrent polls of one code at most one is admitted, the others get `slow_down` and each adds its 5 seconds, so the stored interval is 5 plus 5 for each `slow_down` answered (plus 5 for each early poll answered `429` because it could not tell whether it was stored, above). A poll that arrives with an earlier clock reading than the last one is too fast and does not move the last poll time back.
107
+ - Every user code lookup by the page or the decision endpoint counts toward the rate limit, found or not: per signed-in user and overall, in fixed windows shared by every instance through the registration event table. 20^8 codes and at most `global` guesses per window keep the chance of hitting someone's pending code small.
108
+ - Each code is decided once; of concurrent decisions exactly one is recorded. An approval creates its own grant (so disconnecting the app or revoking the grant ends it like any other) and follows the same disconnect rule as an authorization code approval: it checks the disconnect generation after creating the grant and only then records the decision, so the device cannot exchange the code before that check. An app disconnected while the approval runs gets no usable grant: the decision answers `access_denied` and the request is recorded as denied. Expiry is checked just before and again after the decision is recorded; an approval that crosses it revokes its grant and answers `invalid_grant`, and the device gets `expired_token`. One that crosses it before the write records nothing; one that crosses it after the write spends the code, unless the device already exchanged it. An exchange judges expiry with a clock read after it read the approval, so one that wins shows the approval was recorded in time: the approval stands and the tokens stay valid. An approval interrupted before it records the decision leaves the request pending. The user always sees the approval page, even for a `trusted` client, and the approval is not remembered as consent.
109
+ - The device code works once. Presenting it again after the exchange revokes the grant and every token issued under it, as a replayed authorization code does. It is bound to the client it was issued to.
110
+ - Only configured clients may use the grant; a self-registered client gets `unauthorized_client`. When the grant is off, its endpoints do not exist and the token endpoint answers `unsupported_grant_type` for it.
111
+ - Every device authorization request counts toward `authorizationRateLimit`, per client IP and overall, in the same shared windows as the user code lookups; refused requests store no code and do not use the limit up. The client IP comes from `resolveClientIp`, or AuthFn's `rateLimit.resolveClientIp`; without either only the overall limit applies, and the same rule as for registration applies to where it reads the address.
112
+ - **Storage.** The grant uses the table `oauth_provider_device_codes`, which a custom plugin `schema` gets added like the registration tables, so migrate it even while the grant is off. Each admitted device authorization request deletes codes never exchanged 10 minutes after they expired. An exchanged code is kept while tokens issued for it can be valid (30 days after the exchange), since they stay valid only while its row exists, as for authorization code rows; after that it is kept while its grant is unrevoked and holds an unexpired refresh token that was not rotated or revoked, so that replaying it still revokes the grant and the tokens refreshed under it, and deleted once neither holds. Its user code lookups and requests are counted in `oauth_provider_registration_events`.
53
113
 
54
114
  ## Host responsibilities
55
115
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorize/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAOlD,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AAWvB,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAsKvD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,KAAK,EAAE,CA+G5E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorize/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAOlD,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AAWvB,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAwKvD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,KAAK,EAAE,CAmH5E"}
@@ -13,9 +13,9 @@ export const OAUTH_AUTHORIZE_PATH = '/oauth/authorize';
13
13
  * cannot be trusted with a redirect (RFC 6749 4.1.2.1); anything else is
14
14
  * returned for an error redirect.
15
15
  */
16
- function validateAuthorizationRequest(runtime, params) {
16
+ async function validateAuthorizationRequest(runtime, request, params) {
17
17
  const clientId = params.get('client_id');
18
- const client = clientId ? runtime.findClient(clientId) : undefined;
18
+ const client = clientId ? await runtime.resolveClient(clientId, request) : undefined;
19
19
  if (!client) {
20
20
  throw new OAuthError('invalid_request', 'Unknown client_id');
21
21
  }
@@ -58,9 +58,9 @@ function validateAuthorizationRequest(runtime, params) {
58
58
  }
59
59
  }
60
60
  /** Validates, answering a client or redirect URI problem directly. */
61
- function validateOrRespond(runtime, readParams) {
61
+ async function validateOrRespond(runtime, request, readParams) {
62
62
  try {
63
- return validateAuthorizationRequest(runtime, readParams());
63
+ return await validateAuthorizationRequest(runtime, request, readParams());
64
64
  }
65
65
  catch (error) {
66
66
  if (error instanceof OAuthError) {
@@ -151,7 +151,7 @@ export function createAuthorizeRoutes(runtime) {
151
151
  path: OAUTH_AUTHORIZE_PATH,
152
152
  meta: createAuthFnRouteMeta('oauthAuthorize', 'OAuth 2.1 authorization endpoint', { mode: 'hybrid' }),
153
153
  handler: async (request) => {
154
- const validated = validateOrRespond(runtime, () => readSingleParams(new URL(request.url).searchParams));
154
+ const validated = await validateOrRespond(runtime, request, () => readSingleParams(new URL(request.url).searchParams));
155
155
  if (validated instanceof Response) {
156
156
  return validated;
157
157
  }
@@ -209,7 +209,7 @@ export function createAuthorizeRoutes(runtime) {
209
209
  return oauthErrorResponse(new OAuthError('invalid_request', 'The decision body must be a JSON object'));
210
210
  }
211
211
  const params = new Map();
212
- const validated = validateOrRespond(runtime, () => {
212
+ const validated = await validateOrRespond(runtime, request, () => {
213
213
  for (const [name, value] of Object.entries(body)) {
214
214
  if (typeof value !== 'string') {
215
215
  throw new OAuthError('invalid_request', `Parameter ${name} must be a string`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authorize/index.ts"],"names":[],"mappings":"AACA,OA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K,CAAC,CAAC;gBACjE,CAAC;qBAAM,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;oBAClC,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;oBAC9E,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,mBAAmB,CAC7E,IAAI,UAAU,CAAC,eAAe,EAAE,6DAA6D,CAAC,EAC9F,SAAS,CAAC,MAAM,CAAC,KAAK,CACvB,CAAC;gBACJ,CAAC;qBAAM,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;oBAC/B,MAAM,GAAG,mBAAmB,CAC1B,IAAI,UAAU,CAAC,eAAe,EAAE,2CAA2C,CAAC,EAC5E,SAAS,CAAC,MAAM,CAAC,KAAK,CACvB,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,OAAO,kBAAkB,CAAC,IAAI,UAAU,CAAC,iBAAiB,EAAE,kCAAkC,CAAC,CAAC,CAAC;gBACnG,CAAC;gBAED,MAAM,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC;gBACzF,OAAO,WAAW,CAAC,OAAO,EAAE;oBAC1B,UAAU,EAAE,MAAM,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC;iBAC3E,EAAE,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;YACnD,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { Route } from '@superfunctions/http';
2
+ import { type OAuthProviderRuntime } from '../runtime.js';
3
+ import { type IssuedTokens } from '../store.js';
4
+ import type { OAuthProviderClient } from '../types.js';
5
+ export { createDeviceSchema, OAUTH_DEVICE_CODE_TTL_SECONDS, OAUTH_DEVICE_POLL_INTERVAL_SECONDS } from './store.js';
6
+ export * from './types.js';
7
+ export declare const OAUTH_DEVICE_AUTHORIZATION_PATH = "/oauth/device_authorization";
8
+ export declare const OAUTH_DEVICE_VERIFICATION_PATH = "/oauth/device";
9
+ /** Rejects a malformed `pluginRuntime.oauthProvider.deviceAuthorization` at startup. */
10
+ export declare function validateDeviceConfig(device: unknown): void;
11
+ /**
12
+ * The device authorization endpoint (RFC 8628 3.1, 3.2), the verification
13
+ * page with its decision endpoint (3.3), when `deviceAuthorization` is
14
+ * configured. The token endpoint accepts the device code grant through
15
+ * `exchangeDeviceCode`.
16
+ */
17
+ export declare function createDeviceRoutes(runtime: OAuthProviderRuntime): Route[];
18
+ /**
19
+ * Device access token request (RFC 8628 3.4, 3.5). The device polls with its
20
+ * device code: `authorization_pending` until the user decides, `slow_down`
21
+ * for a poll within the interval of the previous one (which adds 5 seconds
22
+ * to it), `access_denied` after a denial or once the approved grant was
23
+ * revoked (the app was disconnected, or the user disabled) and
24
+ * `expired_token` after 10 minutes. A `resource` other than the requested
25
+ * one is `invalid_target` and leaves the code as it was. A poll that loses to
26
+ * 16 concurrent polls, or cannot tell whether it was stored, is a 429
27
+ * `temporarily_unavailable` whose `Retry-After` is the time left until the
28
+ * stored last poll time plus the stored interval (none once that has passed),
29
+ * plus 5 seconds when its own `slow_down` may count.
30
+ * An approval yields the same tokens as an authorization code: an
31
+ * access token for the approved scopes and a refresh token under the grant.
32
+ * The exchange is judged unexpired with a clock read after the row read that
33
+ * showed the approval, and its tokens are issued at that time; tokens whose
34
+ * exchange was judged in time stay valid even when the claim commits later.
35
+ * The device code works once; when its client presents it again after the
36
+ * exchange, the grant is revoked, as for a replayed authorization code.
37
+ */
38
+ export declare function exchangeDeviceCode(runtime: OAuthProviderRuntime, client: OAuthProviderClient, params: Map<string, string>): Promise<IssuedTokens>;
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/device/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAiBlD,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAML,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,mBAAmB,EAAqB,MAAM,aAAa,CAAC;AAkB1E,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAC;AACnH,cAAc,YAAY,CAAC;AAE3B,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAC7E,eAAO,MAAM,8BAA8B,kBAAkB,CAAC;AAiB9D,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAkB1D;AAwKD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,KAAK,EAAE,CAgIzE;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,OAAO,CAAC,YAAY,CAAC,CA8DvB"}