apps 0.0.1-beta.10 → 0.0.1-beta.11

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.
@@ -15,6 +15,10 @@ export declare const OAuthClientAuth: Schema.Literals<readonly ["none", "client_
15
15
  export type OAuthClientAuth = typeof OAuthClientAuth.Type;
16
16
  /** Machine clients always authenticate; public clients cannot use the client-credentials grant. */
17
17
  export declare const OAuthSecretClientAuth: Schema.Literals<readonly ["client_secret_post", "client_secret_basic", "client_secret_basic_raw"]>;
18
+ /** Parameters the host sets on every authorization request; a declaration cannot replace them. */
19
+ export declare const reservedAuthorizationParams: readonly ["response_type", "client_id", "redirect_uri", "state", "scope", "code_challenge", "code_challenge_method", "nonce", "resource", "request", "request_uri"];
20
+ /** A protocol parameter only the host sets on the authorization request. */
21
+ export type ReservedAuthorizationParam = (typeof reservedAuthorizationParams)[number];
18
22
  /**
19
23
  * Extra authorization request parameters, such as `access_type: "offline"`. RFC 6749 §3.1
20
24
  * lets services define their own; the protocol and security parameters stay host-owned.
@@ -36,6 +40,7 @@ export declare const OAuth2Config: Schema.Union<readonly [Schema.Struct<{
36
40
  readonly tokenEndpointAuthMethod: Schema.optionalKey<Schema.Literals<readonly ["none", "client_secret_post", "client_secret_basic", "client_secret_basic_raw"]>>;
37
41
  readonly resource: Schema.optionalKey<Schema.NullOr<Schema.String>>;
38
42
  }>, Schema.Struct<{
43
+ /** Its query is kept; it cannot set protocol parameters or repeat `authorizationParams`. */
39
44
  readonly authorizationUrl: Schema.String;
40
45
  readonly tokenUrl: Schema.String;
41
46
  readonly revocationUrl: Schema.optionalKey<Schema.String>;
@@ -8,13 +8,13 @@ export { CacheError } from "../../app-cache/src/contracts/cache.js";
8
8
  import { type Schema as EffectSchema } from "effect";
9
9
  import type { WebhookContext } from "./contracts/context.js";
10
10
  import { type JsonResponse as NativeResponse } from "./contracts/http.js";
11
- import { type OAuth2Config, type OAuth2Method as NativeOAuth2Method, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
11
+ import { type OAuth2Config as NativeOAuth2Config, type OAuth2Method as NativeOAuth2Method, type ReservedAuthorizationParam, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
12
12
  import type { Webhook as NativeWebhook } from "./contracts/webhooks.js";
13
13
  import { type PromiseMethods } from "./implementation/authoring.js";
14
14
  import { type Fields, type Infer, type ObjectSchema, type Schema } from "./implementation/schema.js";
15
15
  export { type JsonObject, type JsonValue, ValidationError } from "./contracts/schema.js";
16
16
  export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, } from "./implementation/schema.js";
17
- export { type AccountCheckContext, type AccountCheckResult, type AccountInfo, type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type OAuth2Config, type Provider, } from "./contracts/provider.js";
17
+ export { type AccountCheckContext, type AccountCheckResult, type AccountInfo, type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type Provider, type ReservedAuthorizationParam, } from "./contracts/provider.js";
18
18
  export { defineProvider, type ProviderOptions } from "./implementation/provider.js";
19
19
  export { accountRouter } from "./implementation/account-router.js";
20
20
  export { router, dynamicRouter, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
@@ -29,12 +29,26 @@ export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAut
29
29
  export declare const OAuth2AccessToken: Schema<{
30
30
  readonly access_token: string;
31
31
  }, false>;
32
+ /**
33
+ * OAuth options as authors write them. `authorizationParams` naming a host-owned protocol
34
+ * parameter such as `state` or `scope` is a type error as well as a declaration failure.
35
+ */
36
+ export type OAuth2Config = WithoutReservedParams<NativeOAuth2Config>;
37
+ type WithoutReservedParams<Config> = Config extends unknown ? "authorizationParams" extends keyof Config ? Config & {
38
+ readonly authorizationParams?: {
39
+ readonly [Key in ReservedAuthorizationParam]?: never;
40
+ };
41
+ } : Config : never;
32
42
  /** Declare a secrets method without requiring an Effect schema from the author. */
33
43
  export declare const secrets: <const F extends Fields>(options: {
34
44
  readonly label: string;
35
45
  readonly fields: ObjectSchema<F>;
36
46
  }) => SecretsMethod<ObjectSchema<F>>;
37
- /** Declare OAuth discovery/endpoints and an optional app-visible response projection. */
47
+ /**
48
+ * Declare OAuth discovery/endpoints and an optional app-visible response projection.
49
+ * `authorizationParams` adds service-defined sign-in parameters; a declared `authorizationUrl`
50
+ * keeps its own query. Neither can set host-owned parameters, and each parameter appears once.
51
+ */
38
52
  export declare function oauth2(options: OAuth2Config): OAuth2Method<typeof OAuth2AccessToken>;
39
53
  export declare function oauth2<Response extends Schema<unknown, boolean>>(options: OAuth2Config & {
40
54
  readonly response: Response;