{"version":3,"sources":["jsdelivr-header.js","/npm/@atproto/oauth-types@0.7.7/src/constants.ts","/npm/@atproto/oauth-types@0.7.7/src/util.ts","/npm/@atproto/oauth-types@0.7.7/src/uri.ts","/npm/@atproto/oauth-types@0.7.7/src/atproto-loopback-client-redirect-uris.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-scope.ts","/npm/@atproto/oauth-types@0.7.7/src/atproto-oauth-scope.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-client-id.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-redirect-uri.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-client-id-loopback.ts","/npm/@atproto/oauth-types@0.7.7/src/atproto-loopback-client-id.ts","/npm/@atproto/oauth-types@0.7.7/src/atproto-loopback-client-metadata.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-authorization-details.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-token-type.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-token-response.ts","/npm/@atproto/oauth-types@0.7.7/src/atproto-oauth-token-response.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-access-token.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-authorization-code-grant-token-request.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-authorization-request-jar.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-code-challenge-method.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-prompt-mode.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-response-mode.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-response-type.ts","/npm/@atproto/oauth-types@0.7.7/src/oidc-claims-parameter.ts","/npm/@atproto/oauth-types@0.7.7/src/oidc-claims-properties.ts","/npm/@atproto/oauth-types@0.7.7/src/oidc-entity-type.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-authorization-request-parameters.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-authorization-request-par.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-request-uri.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-authorization-request-uri.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-authorization-request-query.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-authorization-response-error.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-issuer-identifier.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-authorization-server-metadata.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-client-credentials-grant-token-request.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-client-credentials.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-client-id-discoverable.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-endpoint-auth-method.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-grant-type.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-client-metadata.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-endpoint-name.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-par-response.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-password-grant-token-request.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-protected-resource-metadata.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-refresh-token.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-refresh-token-grant-token-request.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-token-identification.ts","/npm/@atproto/oauth-types@0.7.7/src/oauth-token-request.ts","/npm/@atproto/oauth-types@0.7.7/src/oidc-authorization-error-response.ts","/npm/@atproto/oauth-types@0.7.7/src/oidc-userinfo.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,wOCNO,MAAM,EACX,yDCDW,EACX,IAAI,UAAU,KAAK,GAAG,IAEpB,GAA2B,CAC3B,GAAI,CACF,WAAI,IAAI,CAAM,EACP,EACT,MAAQ,CACN,MAAO,EACT,CACF,GAEI,SAAU,EAAa,EAAgB,CAK3C,MAHI,GAAA,EAAS,MAAM,sBAAsB,GAGrC,EAAS,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,EAAE,OAAO,CAC/D,WAAY,EAAE,QAAQ,eAAe,EACrC,cAAe,CAChB,CAAA,ECFY,GAAiC,EAAE,OAAO,CACrD,MAAO,EAAE,MAAM,CAAC,GAAwB,CAAuB,CAAC,EAChE,gBAAiB,EAAE,KAAK,CAAC,eAAgB,eAAe,CAAC,EAAE,SAAQ,CACpE,CAAA,ECDY,GAA0B,EAAE,mBAAmB,aAAc,CACxE,GACA,GACA,GACA,EACD,CAAA,ECNY,GAAuC,EAAE,KAAK,CAEzD,uBAEA,iBAEA,6BAEA,mBAEA,sBAEA,yBAEA,wBAEA,4BAEA,4BACD,CAAA,ECtBY,GAAqB,EAAE,OAAO,CACzC,IAAK,EAAE,OAAM,EACb,IAAK,EAAE,OAAM,EAAG,IAAG,EAAG,SAAQ,EAC9B,IAAK,EAAE,MAAM,CAAC,EAAE,OAAM,EAAI,EAAE,MAAM,EAAE,OAAM,CAAE,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,SAAQ,EAE/D,MAAO,EAAE,OAAM,EAAG,MAAK,EAAG,SAAQ,EAClC,eAAgB,EAAE,QAAO,EAAG,SAAQ,EACpC,KAAM,EAAE,OAAM,EAAG,SAAQ,EACzB,mBAAoB,EAAE,OAAM,EAAG,SAAQ,EACvC,QAAS,EAAE,OAAM,EAAG,IAAG,EAAG,SAAQ,CACnC,CAAA","file":"/npm/@atproto/oauth-types@0.7.7/dist/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1.\n * Original file: /npm/@atproto/oauth-types@0.7.7/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","export const CLIENT_ASSERTION_TYPE_JWT_BEARER =\n  'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'\n","export const canParseUrl =\n  URL.canParse?.bind(URL) ??\n  // URL.canParse is not available in Node.js < 18.7.0\n  ((urlStr: string): boolean => {\n    try {\n      new URL(urlStr)\n      return true\n    } catch {\n      return false\n    }\n  })\n\nexport function isHostnameIP(hostname: string) {\n  // IPv4\n  if (hostname.match(/^\\d+\\.\\d+\\.\\d+\\.\\d+$/)) return true\n\n  // IPv6\n  if (hostname.startsWith('[') && hostname.endsWith(']')) return true\n\n  return false\n}\n\nexport type LoopbackHost = 'localhost' | '127.0.0.1' | '[::1]'\n\nexport function isLoopbackHost(host: unknown): host is LoopbackHost {\n  return host === 'localhost' || host === '127.0.0.1' || host === '[::1]'\n}\n\nexport function isLocalHostname(hostname: string): boolean {\n  const parts = hostname.split('.')\n  if (parts.length < 2) return true\n\n  const tld = parts.at(-1)!.toLowerCase()\n  return (\n    tld === 'test' ||\n    tld === 'local' ||\n    tld === 'localhost' ||\n    tld === 'invalid' ||\n    tld === 'example'\n  )\n}\n\nexport function safeUrl(input: URL | string): URL | null {\n  try {\n    return new URL(input)\n  } catch {\n    return null\n  }\n}\n\nexport function extractUrlPath(url: string) {\n  // Extracts the path from a URL, without relying on the URL constructor\n  // (because it normalizes the URL)\n  const endOfProtocol = url.startsWith('https://')\n    ? 8\n    : url.startsWith('http://')\n      ? 7\n      : -1\n  if (endOfProtocol === -1) {\n    throw new TypeError('URL must use the \"https:\" or \"http:\" protocol')\n  }\n\n  const hashIdx = url.indexOf('#', endOfProtocol)\n  const questionIdx = url.indexOf('?', endOfProtocol)\n\n  const queryStrIdx =\n    questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx)\n      ? questionIdx\n      : -1\n\n  const pathEnd =\n    hashIdx === -1\n      ? queryStrIdx === -1\n        ? url.length\n        : queryStrIdx\n      : queryStrIdx === -1\n        ? hashIdx\n        : Math.min(hashIdx, queryStrIdx)\n\n  const slashIdx = url.indexOf('/', endOfProtocol)\n\n  const pathStart = slashIdx === -1 || slashIdx > pathEnd ? pathEnd : slashIdx\n\n  if (endOfProtocol === pathStart) {\n    throw new TypeError('URL must contain a host')\n  }\n\n  return url.substring(pathStart, pathEnd)\n}\n\nexport const jsonObjectPreprocess = (val: unknown) => {\n  if (typeof val === 'string' && val.startsWith('{') && val.endsWith('}')) {\n    try {\n      return JSON.parse(val)\n    } catch {\n      return val\n    }\n  }\n\n  return val\n}\n\nexport const numberPreprocess = (val: unknown): unknown => {\n  if (typeof val === 'string') {\n    const number = Number(val)\n    if (!Number.isNaN(number)) return number\n  }\n  return val\n}\n\n/**\n * Returns true if the two arrays contain the same elements, regardless of order\n * or duplicates.\n */\nexport function arrayEquivalent<T>(a: readonly T[], b: readonly T[]) {\n  if (a === b) return true\n  return a.every(includedIn, b) && b.every(includedIn, a)\n}\n\nexport function includedIn<T>(this: readonly T[], item: T) {\n  return this.includes(item)\n}\n\nexport function asArray<T>(\n  value: Iterable<T> | undefined,\n): undefined | readonly T[] {\n  if (value == null) return undefined\n  if (Array.isArray(value)) return value // already a (possibly readonly) array\n  return Array.from(value)\n}\n\nexport type SpaceSeparatedValue<Value extends string> =\n  `${'' | `${string} `}${Value}${'' | ` ${string}`}`\n\nexport const isSpaceSeparatedValue = <Value extends string>(\n  value: Value,\n  input: string,\n): input is SpaceSeparatedValue<Value> => {\n  if (value.length === 0) throw new TypeError('Value cannot be empty')\n  if (value.includes(' ')) throw new TypeError('Value cannot contain spaces')\n\n  // Optimized version of:\n  // return input.split(' ').includes(value)\n\n  const inputLength = input.length\n  const valueLength = value.length\n\n  if (inputLength < valueLength) return false\n\n  let idx = input.indexOf(value)\n  let idxEnd: number\n\n  while (idx !== -1) {\n    idxEnd = idx + valueLength\n\n    if (\n      // at beginning or preceded by space\n      (idx === 0 || input.charCodeAt(idx - 1) === 32) &&\n      // at end or followed by space\n      (idxEnd === inputLength || input.charCodeAt(idxEnd) === 32)\n    ) {\n      return true\n    }\n\n    idx = input.indexOf(value, idxEnd + 1)\n  }\n\n  return false\n}\n","import { type TypeOf, ZodIssueCode, z } from 'zod'\nimport {\n  canParseUrl,\n  isHostnameIP,\n  isLocalHostname,\n  isLoopbackHost,\n} from './util.js'\n\n/**\n * Valid, but potentially dangerous URL (`data:`, `file:`, `javascript:`, etc.).\n *\n * Any value that matches this schema is safe to parse using `new URL()`.\n */\nexport const dangerousUriSchema = z\n  .string()\n  .refine(\n    (data): data is `${string}:${string}` =>\n      data.includes(':') && canParseUrl(data),\n    {\n      message: 'Invalid URL',\n    },\n  )\n\n/**\n * Valid, but potentially dangerous URL (`data:`, `file:`, `javascript:`, etc.).\n */\nexport type DangerousUrl = TypeOf<typeof dangerousUriSchema>\n\nexport const loopbackUriSchema = dangerousUriSchema.superRefine(\n  (\n    value,\n    ctx,\n  ): value is\n    | `http://[::1]${string}`\n    | `http://localhost${'' | `${':' | '/' | '?' | '#'}${string}`}`\n    | `http://127.0.0.1${'' | `${':' | '/' | '?' | '#'}${string}`}` => {\n    // Loopback url must use the \"http:\" protocol\n    if (!value.startsWith('http://')) {\n      ctx.addIssue({\n        code: ZodIssueCode.custom,\n        message: 'URL must use the \"http:\" protocol',\n      })\n      return false\n    }\n\n    const url = new URL(value)\n\n    if (!isLoopbackHost(url.hostname)) {\n      ctx.addIssue({\n        code: ZodIssueCode.custom,\n        message: 'URL must use \"localhost\", \"127.0.0.1\" or \"[::1]\" as hostname',\n      })\n      return false\n    }\n\n    return true\n  },\n)\n\nexport type LoopbackUri = TypeOf<typeof loopbackUriSchema>\n\nexport const httpsUriSchema = dangerousUriSchema.superRefine(\n  (value, ctx): value is `https://${string}` => {\n    if (!value.startsWith('https://')) {\n      ctx.addIssue({\n        code: ZodIssueCode.custom,\n        message: 'URL must use the \"https:\" protocol',\n      })\n      return false\n    }\n\n    const url = new URL(value)\n\n    // Disallow loopback URLs with the `https:` protocol\n    if (isLoopbackHost(url.hostname)) {\n      ctx.addIssue({\n        code: ZodIssueCode.custom,\n        message: 'https: URL must not use a loopback host',\n      })\n      return false\n    }\n\n    if (isHostnameIP(url.hostname)) {\n      // Hostname is an IP address\n    } else {\n      // Hostname is a domain name\n      if (!url.hostname.includes('.')) {\n        // we don't depend on PSL here, so we only check for a dot\n        ctx.addIssue({\n          code: ZodIssueCode.custom,\n          message: 'Domain name must contain at least two segments',\n        })\n        return false\n      }\n\n      if (url.hostname.endsWith('.local')) {\n        ctx.addIssue({\n          code: ZodIssueCode.custom,\n          message: 'Domain name must not end with \".local\"',\n        })\n        return false\n      }\n    }\n\n    return true\n  },\n)\n\nexport type HttpsUri = TypeOf<typeof httpsUriSchema>\n\nexport const webUriSchema = z\n  .string()\n  .superRefine((value, ctx): value is LoopbackUri | HttpsUri => {\n    // discriminated union of `loopbackUriSchema` and `httpsUriSchema`\n    if (value.startsWith('http://')) {\n      const result = loopbackUriSchema.safeParse(value)\n      if (!result.success) result.error.issues.forEach(ctx.addIssue, ctx)\n      return result.success\n    }\n\n    if (value.startsWith('https://')) {\n      const result = httpsUriSchema.safeParse(value)\n      if (!result.success) result.error.issues.forEach(ctx.addIssue, ctx)\n      return result.success\n    }\n\n    ctx.addIssue({\n      code: ZodIssueCode.custom,\n      message: 'URL must use the \"http:\" or \"https:\" protocol',\n    })\n    return false\n  })\n\nexport type WebUri = TypeOf<typeof webUriSchema>\n\nexport const privateUseUriSchema = dangerousUriSchema.superRefine(\n  (value, ctx): value is `${string}.${string}:/${string}` => {\n    const dotIdx = value.indexOf('.')\n    const colonIdx = value.indexOf(':')\n\n    // Optimization: avoid parsing the URL if the protocol does not contain a \".\"\n    if (dotIdx === -1 || colonIdx === -1 || dotIdx > colonIdx) {\n      ctx.addIssue({\n        code: ZodIssueCode.custom,\n        message:\n          'Private-use URI scheme requires a \".\" as part of the protocol',\n      })\n      return false\n    }\n\n    const url = new URL(value)\n\n    // Should be covered by the check before, but let's be extra sure\n    if (!url.protocol.includes('.')) {\n      ctx.addIssue({\n        code: ZodIssueCode.custom,\n        message: 'Invalid private-use URI scheme',\n      })\n      return false\n    }\n\n    // https://datatracker.ietf.org/doc/html/rfc8252#section-7.1\n    //\n    // > When choosing a URI scheme to associate with the app, apps MUST use a\n    // > URI scheme based on a domain name under their control, expressed in\n    // > reverse order\n    //\n    // https://datatracker.ietf.org/doc/html/rfc8252#section-8.4\n    //\n    // > In addition to the collision-resistant properties, requiring a URI\n    // > scheme based on a domain name that is under the control of the app can\n    // > help to prove ownership in the event of a dispute where two apps claim\n    // > the same private-use URI scheme (where one app is acting maliciously).\n    //\n    // We can't check for ownership here (as there is no concept of proven\n    // ownership in a generic validation logic), besides excluding local domains\n    // as they can't be controlled/owned by the app.\n    //\n    // https://atproto.com/specs/oauth\n    //\n    // > Any custom scheme must match the `client_id` hostname in reverse-domain\n    // > order.\n    //\n    // This ATPROTO specific requirement cannot be enforced here, (as there is\n    // no concept of `client_id` in this context).\n\n    const uriScheme = url.protocol.slice(0, -1) // remove trailing \":\"\n    const urlDomain = uriScheme.split('.').reverse().join('.')\n\n    if (isLocalHostname(urlDomain)) {\n      ctx.addIssue({\n        code: ZodIssueCode.custom,\n        message: `Private-use URI Scheme redirect URI must not be a local hostname`,\n      })\n    }\n\n    // https://datatracker.ietf.org/doc/html/rfc8252#section-7.1\n    //\n    // > Following the requirements of Section 3.2 of [RFC3986], as there is no\n    // > naming authority for private-use URI scheme redirects, only a single\n    // > slash (\"/\") appears after the scheme component.\n    if (\n      url.href.startsWith(`${url.protocol}//`) ||\n      url.username ||\n      url.password ||\n      url.hostname ||\n      url.port\n    ) {\n      ctx.addIssue({\n        code: ZodIssueCode.custom,\n        message:\n          'Private-Use URI Scheme must be in the form <scheme>:/{path} (notice the single slash!) as per RFC 8252',\n      })\n      return false\n    }\n\n    return true\n  },\n)\n\nexport type PrivateUseUri = TypeOf<typeof privateUseUriSchema>\n","export const DEFAULT_LOOPBACK_CLIENT_REDIRECT_URIS = Object.freeze([\n  `http://127.0.0.1/`,\n  `http://[::1]/`,\n] as const)\n","import { z } from 'zod'\n\n// scope       = scope-token *( SP scope-token )\n// scope-token = 1*( %x21 / %x23-5B / %x5D-7E )\nexport const OAUTH_SCOPE_REGEXP =\n  /^[\\x21\\x23-\\x5B\\x5D-\\x7E]+(?: [\\x21\\x23-\\x5B\\x5D-\\x7E]+)*$/\n\nexport const isOAuthScope = (input: string): boolean =>\n  OAUTH_SCOPE_REGEXP.test(input)\n\n/**\n * A (single) space separated list of non empty printable ASCII char string\n * (except backslash and double quote).\n *\n * @see {@link https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-11#section-1.4.1}\n */\nexport const oauthScopeSchema = z.string().refine(isOAuthScope, {\n  message: 'Invalid OAuth scope',\n})\n\nexport type OAuthScope = z.infer<typeof oauthScopeSchema>\n","import { z } from 'zod'\nimport { type OAuthScope, isOAuthScope } from './oauth-scope.js'\nimport { type SpaceSeparatedValue, isSpaceSeparatedValue } from './util.js'\n\nexport const ATPROTO_SCOPE_VALUE = 'atproto'\nexport type AtprotoScopeValue = typeof ATPROTO_SCOPE_VALUE\n\nexport type AtprotoOAuthScope = OAuthScope &\n  SpaceSeparatedValue<AtprotoScopeValue>\n\nexport function isAtprotoOAuthScope(input: string): input is AtprotoOAuthScope {\n  return (\n    isOAuthScope(input) && isSpaceSeparatedValue(ATPROTO_SCOPE_VALUE, input)\n  )\n}\n\nexport function asAtprotoOAuthScope<I extends string>(input: I) {\n  if (isAtprotoOAuthScope(input)) return input\n  throw new TypeError(`Value must contain \"${ATPROTO_SCOPE_VALUE}\" scope value`)\n}\n\nexport function assertAtprotoOAuthScope(\n  input: string,\n): asserts input is AtprotoOAuthScope {\n  void asAtprotoOAuthScope(input)\n}\n\nexport const atprotoOAuthScopeSchema = z.string().refine(isAtprotoOAuthScope, {\n  message: 'Invalid ATProto OAuth scope',\n})\n\n// Default scope is for reading identity (did) only\nexport const DEFAULT_ATPROTO_OAUTH_SCOPE =\n  ATPROTO_SCOPE_VALUE satisfies AtprotoOAuthScope\n","import { z } from 'zod'\n\nexport const oauthClientIdSchema = z.string().min(1)\nexport type OAuthClientId = z.infer<typeof oauthClientIdSchema>\n","import { type TypeOf, ZodIssueCode, z } from 'zod'\nimport {\n  type HttpsUri,\n  type LoopbackUri,\n  type PrivateUseUri,\n  httpsUriSchema,\n  loopbackUriSchema,\n  privateUseUriSchema,\n} from './uri.js'\n\n/**\n * This is a {@link loopbackUriSchema} with the additional restriction that\n * the hostname `localhost` is not allowed.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc8252#section-8.3 Loopback Redirect Considerations} RFC8252\n *\n * > While redirect URIs using localhost (i.e.,\n * > \"http://localhost:{port}/{path}\") function similarly to loopback IP\n * > redirects described in Section 7.3, the use of localhost is NOT\n * > RECOMMENDED. Specifying a redirect URI with the loopback IP literal rather\n * > than localhost avoids inadvertently listening on network interfaces other\n * > than the loopback interface.  It is also less susceptible to client-side\n * > firewalls and misconfigured host name resolution on the user's device.\n */\nexport const loopbackRedirectURISchema = loopbackUriSchema.superRefine(\n  (value, ctx): value is Exclude<LoopbackUri, `http://localhost${string}`> => {\n    if (value.startsWith('http://localhost')) {\n      ctx.addIssue({\n        code: ZodIssueCode.custom,\n        message:\n          'Use of \"localhost\" hostname is not allowed (RFC 8252), use a loopback IP such as \"127.0.0.1\" instead',\n      })\n      return false\n    }\n\n    return true\n  },\n)\nexport type LoopbackRedirectURI = TypeOf<typeof loopbackRedirectURISchema>\n\nexport const oauthLoopbackClientRedirectUriSchema = loopbackRedirectURISchema\nexport type OAuthLoopbackRedirectURI = TypeOf<\n  typeof oauthLoopbackClientRedirectUriSchema\n>\n\nexport const oauthRedirectUriSchema = z\n  .string()\n  .superRefine(\n    (value, ctx): value is HttpsUri | LoopbackRedirectURI | PrivateUseUri => {\n      if (value.startsWith('https:')) {\n        const result = httpsUriSchema.safeParse(value)\n        if (!result.success) result.error.issues.forEach(ctx.addIssue, ctx)\n        return result.success\n      } else if (value.startsWith('http:')) {\n        const result = loopbackRedirectURISchema.safeParse(value)\n        if (!result.success) result.error.issues.forEach(ctx.addIssue, ctx)\n        return result.success\n      } else if (/^[^.:]+(?:\\.[^.:]+)+:/.test(value)) {\n        const result = privateUseUriSchema.safeParse(value)\n        if (!result.success) result.error.issues.forEach(ctx.addIssue, ctx)\n        return result.success\n      } else {\n        ctx.addIssue({\n          code: ZodIssueCode.custom,\n          message:\n            'URL must use the \"https:\" or \"http:\" protocol, or a private-use URI scheme (RFC 8252)',\n        })\n        return false\n      }\n    },\n  )\n\nexport type OAuthRedirectUri = TypeOf<typeof oauthRedirectUriSchema>\n","import { oauthClientIdSchema } from './oauth-client-id.js'\nimport {\n  type OAuthLoopbackRedirectURI,\n  oauthLoopbackClientRedirectUriSchema,\n} from './oauth-redirect-uri.js'\nimport { type OAuthScope, oauthScopeSchema } from './oauth-scope.js'\n\nexport const LOOPBACK_CLIENT_ID_ORIGIN = 'http://localhost'\n\n// @NOTE This is not actually based on a standard, but rather a convention\n// established by Bluesky in the Atproto specs and implementation. As such, and\n// in order to respect the convention from this package, these should be\n// prefixed with \"Atproto\" instead of \"OAuth\". For legacy reasons, we keep the\n// current names, but we should rename them in a future major release, unless\n// loopback client ids have since then been standardized.\n\nexport type OAuthClientIdLoopback =\n  `http://localhost${'' | `/`}${'' | `?${string}`}`\n\nexport type OAuthLoopbackClientIdParams = {\n  scope?: OAuthScope\n  redirect_uris?: [OAuthLoopbackRedirectURI, ...OAuthLoopbackRedirectURI[]]\n}\n\nexport const oauthClientIdLoopbackSchema = oauthClientIdSchema.superRefine(\n  (input, ctx): input is OAuthClientIdLoopback => {\n    const result = safeParseOAuthLoopbackClientId(input)\n    if (!result.success) {\n      ctx.addIssue({ code: 'custom', message: result.message })\n    }\n    return result.success\n  },\n)\n\nexport function assertOAuthLoopbackClientId(\n  input: string,\n): asserts input is OAuthClientIdLoopback {\n  void parseOAuthLoopbackClientId(input)\n}\n\nexport function isOAuthClientIdLoopback<T extends string>(\n  input: T,\n): input is T & OAuthClientIdLoopback {\n  return safeParseOAuthLoopbackClientId(input).success\n}\n\nexport function asOAuthClientIdLoopback<T extends string>(input: T) {\n  assertOAuthLoopbackClientId(input)\n  return input\n}\n\nexport function parseOAuthLoopbackClientId(\n  input: string,\n): OAuthLoopbackClientIdParams {\n  const result = safeParseOAuthLoopbackClientId(input)\n  if (result.success) return result.value\n\n  throw new TypeError(`Invalid loopback client ID: ${result.message}`)\n}\n\n/**\n * Similar to Zod's {@link SafeParseReturnType} but uses a simple \"message\"\n * string instead of an \"error\" Error object.\n */\ntype LightParseReturnType<T> =\n  { success: true; value: T } | { success: false; message: string }\n\nexport function safeParseOAuthLoopbackClientId(\n  input: string,\n): LightParseReturnType<OAuthLoopbackClientIdParams> {\n  // @NOTE Not using \"new URL\" to ensure input indeed matches the type\n  // OAuthClientIdLoopback\n\n  if (!input.startsWith(LOOPBACK_CLIENT_ID_ORIGIN)) {\n    return {\n      success: false,\n      message: `Value must start with \"${LOOPBACK_CLIENT_ID_ORIGIN}\"`,\n    }\n  }\n\n  if (input.includes('#', LOOPBACK_CLIENT_ID_ORIGIN.length)) {\n    return {\n      success: false,\n      message: 'Value must not contain a hash component',\n    }\n  }\n\n  // Since we don't allow a path component (except for a single \"/\") the query\n  // string starts after the origin (+ 1 if there is a \"/\")\n  const queryStringIdx =\n    input.length > LOOPBACK_CLIENT_ID_ORIGIN.length &&\n    input.charCodeAt(LOOPBACK_CLIENT_ID_ORIGIN.length) === 0x2f /* '/' */\n      ? LOOPBACK_CLIENT_ID_ORIGIN.length + 1\n      : LOOPBACK_CLIENT_ID_ORIGIN.length\n\n  // Since we determined the position of the query string based on the origin\n  // length (instead of looking for a \"?\"), we need to make sure the query\n  // string position (if any) indeed starts with a \"?\".\n  if (\n    input.length !== queryStringIdx &&\n    input.charCodeAt(queryStringIdx) !== 0x3f /* '?' */\n  ) {\n    return {\n      success: false,\n      message: 'Value must not contain a path component',\n    }\n  }\n\n  const queryString = input.slice(queryStringIdx + 1)\n  return safeParseOAuthLoopbackClientIdQueryString(queryString)\n}\n\nexport function safeParseOAuthLoopbackClientIdQueryString(\n  input: string | Iterable<[key: string, value: string]>,\n): LightParseReturnType<OAuthLoopbackClientIdParams> {\n  // Parse query params\n  const params: OAuthLoopbackClientIdParams = {}\n\n  const it = typeof input === 'string' ? new URLSearchParams(input) : input\n  for (const [key, value] of it) {\n    if (key === 'scope') {\n      if ('scope' in params) {\n        return {\n          success: false,\n          message: 'Duplicate \"scope\" query parameter',\n        }\n      }\n\n      const res = oauthScopeSchema.safeParse(value)\n      if (!res.success) {\n        const reason = res.error.issues.map((i) => i.message).join(', ')\n        return {\n          success: false,\n          message: `Invalid \"scope\" query parameter: ${reason || 'Validation failed'}`,\n        }\n      }\n\n      params.scope = res.data\n    } else if (key === 'redirect_uri') {\n      const res = oauthLoopbackClientRedirectUriSchema.safeParse(value)\n      if (!res.success) {\n        const reason = res.error.issues.map((i) => i.message).join(', ')\n        return {\n          success: false,\n          message: `Invalid \"redirect_uri\" query parameter: ${reason || 'Validation failed'}`,\n        }\n      }\n\n      if (params.redirect_uris == null) params.redirect_uris = [res.data]\n      else params.redirect_uris.push(res.data)\n    } else {\n      return {\n        success: false,\n        message: `Unexpected query parameter \"${key}\"`,\n      }\n    }\n  }\n\n  return {\n    success: true,\n    value: params,\n  }\n}\n","import { DEFAULT_LOOPBACK_CLIENT_REDIRECT_URIS } from './atproto-loopback-client-redirect-uris.js'\nimport {\n  type AtprotoOAuthScope,\n  DEFAULT_ATPROTO_OAUTH_SCOPE,\n  asAtprotoOAuthScope,\n  isAtprotoOAuthScope,\n} from './atproto-oauth-scope.js'\nimport {\n  LOOPBACK_CLIENT_ID_ORIGIN,\n  type OAuthClientIdLoopback,\n  parseOAuthLoopbackClientId,\n} from './oauth-client-id-loopback.js'\nimport {\n  type OAuthLoopbackRedirectURI,\n  oauthLoopbackClientRedirectUriSchema,\n} from './oauth-redirect-uri.js'\nimport { arrayEquivalent, asArray } from './util.js'\n\nexport type OAuthLoopbackClientIdConfig = {\n  scope?: string\n  redirect_uris?: Iterable<string>\n}\n\nexport function buildAtprotoLoopbackClientId(\n  config?: OAuthLoopbackClientIdConfig,\n): OAuthClientIdLoopback {\n  if (config) {\n    const params = new URLSearchParams()\n\n    const { scope } = config\n    if (scope != null && scope !== DEFAULT_ATPROTO_OAUTH_SCOPE) {\n      params.set('scope', asAtprotoOAuthScope(scope))\n    }\n\n    const redirectUris = asArray(config.redirect_uris)\n    if (\n      redirectUris &&\n      !arrayEquivalent(redirectUris, DEFAULT_LOOPBACK_CLIENT_REDIRECT_URIS)\n    ) {\n      if (!redirectUris.length) {\n        throw new TypeError(`Unexpected empty \"redirect_uris\" config`)\n      }\n      for (const uri of redirectUris) {\n        params.append(\n          'redirect_uri',\n          oauthLoopbackClientRedirectUriSchema.parse(uri),\n        )\n      }\n    }\n\n    if (params.size) {\n      return `${LOOPBACK_CLIENT_ID_ORIGIN}?${params.toString()}`\n    }\n  }\n\n  return LOOPBACK_CLIENT_ID_ORIGIN\n}\n\nexport type AtprotoLoopbackClientIdParams = {\n  scope: AtprotoOAuthScope\n  redirect_uris: [OAuthLoopbackRedirectURI, ...OAuthLoopbackRedirectURI[]]\n}\n\nexport function parseAtprotoLoopbackClientId(\n  clientId: string,\n): AtprotoLoopbackClientIdParams {\n  const { scope = DEFAULT_ATPROTO_OAUTH_SCOPE, redirect_uris } =\n    parseOAuthLoopbackClientId(clientId)\n  if (!isAtprotoOAuthScope(scope)) {\n    throw new TypeError(\n      'ATProto Loopback ClientID must include \"atproto\" scope',\n    )\n  }\n  return {\n    scope,\n    redirect_uris: redirect_uris ?? [...DEFAULT_LOOPBACK_CLIENT_REDIRECT_URIS],\n  }\n}\n","import {\n  type AtprotoLoopbackClientIdParams,\n  type OAuthLoopbackClientIdConfig,\n  buildAtprotoLoopbackClientId,\n  parseAtprotoLoopbackClientId,\n} from './atproto-loopback-client-id.js'\nimport type { AtprotoOAuthScope } from './atproto-oauth-scope.js'\nimport type { OAuthClientIdLoopback } from './oauth-client-id-loopback.js'\nimport type { OAuthClientMetadataInput } from './oauth-client-metadata.js'\nimport type { OAuthLoopbackRedirectURI } from './oauth-redirect-uri.js'\n\nexport type AtprotoLoopbackClientMetadata = OAuthClientMetadataInput & {\n  client_id: OAuthClientIdLoopback\n  scope: AtprotoOAuthScope\n  redirect_uris: [OAuthLoopbackRedirectURI, ...OAuthLoopbackRedirectURI[]]\n}\n\nexport function atprotoLoopbackClientMetadata(\n  clientId: string,\n): AtprotoLoopbackClientMetadata {\n  const params = parseAtprotoLoopbackClientId(clientId)\n  // Safe to cast because parseAtprotoLoopbackClientId ensures it's a loopback ID\n  return buildMetadataInternal(clientId as OAuthClientIdLoopback, params)\n}\n\nexport function buildAtprotoLoopbackClientMetadata(\n  config: OAuthLoopbackClientIdConfig,\n): AtprotoLoopbackClientMetadata {\n  const clientId = buildAtprotoLoopbackClientId(config)\n  return buildMetadataInternal(clientId, parseAtprotoLoopbackClientId(clientId))\n}\n\nfunction buildMetadataInternal(\n  clientId: OAuthClientIdLoopback,\n  clientParams: AtprotoLoopbackClientIdParams,\n): AtprotoLoopbackClientMetadata {\n  return {\n    client_id: clientId,\n    scope: clientParams.scope,\n    redirect_uris: clientParams.redirect_uris,\n    response_types: ['code'],\n    grant_types: ['authorization_code', 'refresh_token'],\n    token_endpoint_auth_method: 'none',\n    application_type: 'native',\n    dpop_bound_access_tokens: true,\n  }\n}\n","import { z } from 'zod'\nimport { dangerousUriSchema } from './uri.js'\n\n/**\n * @see {@link https://datatracker.ietf.org/doc/html/rfc9396#section-2 | RFC 9396, Section 2}\n */\nexport const oauthAuthorizationDetailSchema = z.object({\n  type: z.string(),\n  /**\n   * An array of strings representing the location of the resource or RS. These\n   * strings are typically URIs identifying the location of the RS.\n   */\n  locations: z.array(dangerousUriSchema).optional(),\n  /**\n   * An array of strings representing the kinds of actions to be taken at the\n   * resource.\n   */\n  actions: z.array(z.string()).optional(),\n  /**\n   * An array of strings representing the kinds of data being requested from the\n   * resource.\n   */\n  datatypes: z.array(z.string()).optional(),\n  /**\n   * A string identifier indicating a specific resource available at the API.\n   */\n  identifier: z.string().optional(),\n  /**\n   * An array of strings representing the types or levels of privilege being\n   * requested at the resource.\n   */\n  privileges: z.array(z.string()).optional(),\n})\n\nexport type OAuthAuthorizationDetail = z.infer<\n  typeof oauthAuthorizationDetailSchema\n>\n\n/**\n * @see {@link https://datatracker.ietf.org/doc/html/rfc9396#section-2 | RFC 9396, Section 2}\n */\nexport const oauthAuthorizationDetailsSchema = z.array(\n  oauthAuthorizationDetailSchema,\n)\n\nexport type OAuthAuthorizationDetails = z.infer<\n  typeof oauthAuthorizationDetailsSchema\n>\n","import { z } from 'zod'\n\n// Case insensitive input, normalized output\nexport const oauthTokenTypeSchema = z.union([\n  z\n    .string()\n    .regex(/^DPoP$/i)\n    .transform(() => 'DPoP' as const),\n  z\n    .string()\n    .regex(/^Bearer$/i)\n    .transform(() => 'Bearer' as const),\n])\n\nexport type OAuthTokenType = z.infer<typeof oauthTokenTypeSchema>\n","import { z } from 'zod'\nimport { signedJwtSchema } from '@atproto/jwk'\nimport { oauthAuthorizationDetailsSchema } from './oauth-authorization-details.js'\nimport { oauthTokenTypeSchema } from './oauth-token-type.js'\n\n/**\n * @see {@link https://www.rfc-editor.org/rfc/rfc6749.html#section-5.1 | RFC 6749 (OAuth2), Section 5.1}\n */\nexport const oauthTokenResponseSchema = z\n  .object({\n    // https://www.rfc-editor.org/rfc/rfc6749.html#section-5.1\n    access_token: z.string(),\n    token_type: oauthTokenTypeSchema,\n    scope: z.string().optional(),\n    refresh_token: z.string().optional(),\n    expires_in: z.number().optional(),\n    // https://openid.net/specs/openid-connect-core-1_0.html#TokenResponse\n    id_token: signedJwtSchema.optional(),\n    // https://datatracker.ietf.org/doc/html/rfc9396#name-enriched-authorization-deta\n    authorization_details: oauthAuthorizationDetailsSchema.optional(),\n  })\n  // https://www.rfc-editor.org/rfc/rfc6749.html#section-5.1\n  // > The client MUST ignore unrecognized value names in the response.\n  .passthrough()\n\n/**\n * @see {@link oauthTokenResponseSchema}\n */\nexport type OAuthTokenResponse = z.infer<typeof oauthTokenResponseSchema>\n","import { type TypeOf, z } from 'zod'\nimport { atprotoDidSchema } from '@atproto/did'\nimport { atprotoOAuthScopeSchema } from './atproto-oauth-scope.js'\nimport { oauthTokenResponseSchema } from './oauth-token-response.js'\n\nexport const atprotoOAuthTokenResponseSchema = oauthTokenResponseSchema.extend({\n  token_type: z.literal('DPoP'),\n  sub: atprotoDidSchema,\n  scope: atprotoOAuthScopeSchema,\n  // OpenID is not compatible with atproto identities\n  id_token: z.never().optional(),\n})\n\nexport type AtprotoOAuthTokenResponse = TypeOf<\n  typeof atprotoOAuthTokenResponseSchema\n>\n","import { z } from 'zod'\n\nexport const oauthAccessTokenSchema = z.string().min(1)\nexport type OAuthAccessToken = z.infer<typeof oauthAccessTokenSchema>\n","import { z } from 'zod'\nimport { oauthRedirectUriSchema } from './oauth-redirect-uri.js'\n\nexport const oauthAuthorizationCodeGrantTokenRequestSchema = z.object({\n  grant_type: z.literal('authorization_code'),\n  code: z.string().min(1),\n  redirect_uri: oauthRedirectUriSchema,\n  /** @see {@link https://datatracker.ietf.org/doc/html/rfc7636#section-4.1} */\n  code_verifier: z\n    .string()\n    .min(43)\n    .max(128)\n    .regex(/^[a-zA-Z0-9-._~]+$/)\n    .optional(),\n})\n\nexport type OAuthAuthorizationCodeGrantTokenRequest = z.infer<\n  typeof oauthAuthorizationCodeGrantTokenRequestSchema\n>\n","import { z } from 'zod'\nimport { signedJwtSchema, unsignedJwtSchema } from '@atproto/jwk'\n\nexport const oauthAuthorizationRequestJarSchema = z.object({\n  /**\n   * AuthorizationRequest inside a JWT:\n   * - \"iat\" is required and **MUST** be less than one minute\n   *\n   * @see {@link https://datatracker.ietf.org/doc/html/rfc9101}\n   */\n  request: z.union([signedJwtSchema, unsignedJwtSchema]),\n})\n\nexport type OAuthAuthorizationRequestJar = z.infer<\n  typeof oauthAuthorizationRequestJarSchema\n>\n","import { z } from 'zod'\n\nexport const oauthCodeChallengeMethodSchema = z.enum(['S256', 'plain'])\n","import { z } from 'zod'\n\n/**\n * - \"none\" will only be allowed if the user already allowed the client on the same device\n * - \"login\" will force the user to login again, unless he very recently logged in\n * - \"consent\" will force the user to consent again\n * - \"select_account\" will force the user to select an account\n * - \"create\" will force the user registration screen\n */\nexport const oauthPromptModeSchema = z.enum([\n  'none',\n  'login',\n  'consent',\n  'select_account',\n  'create',\n])\n\nexport type OAuthPromptMode = z.infer<typeof oauthPromptModeSchema>\n","import { z } from 'zod'\n\nexport const oauthResponseModeSchema = z.enum([\n  'query',\n  'fragment',\n  'form_post',\n])\n\nexport type OAuthResponseMode = z.infer<typeof oauthResponseModeSchema>\n","import { z } from 'zod'\n\nexport const oauthResponseTypeSchema = z.enum([\n  // OAuth2 (https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-10#section-4.1.1)\n  'code', // Authorization Code Grant\n  'token', // Implicit Grant\n\n  // OIDC (https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html)\n  'none',\n  'code id_token token',\n  'code id_token',\n  'code token',\n  'id_token token',\n  'id_token',\n])\n\nexport type OAuthResponseType = z.infer<typeof oauthResponseTypeSchema>\n","import { z } from 'zod'\n\nexport const oidcClaimsParameterSchema = z.enum([\n  // https://openid.net/specs/openid-provider-authentication-policy-extension-1_0.html#rfc.section.5.2\n  // if client metadata \"require_auth_time\" is true, this *must* be provided\n  'auth_time',\n\n  // OIDC\n  'nonce',\n  'acr',\n\n  // OpenID: \"profile\" scope\n  'name',\n  'family_name',\n  'given_name',\n  'middle_name',\n  'nickname',\n  'preferred_username',\n  'gender',\n  'picture',\n  'profile',\n  'website',\n  'birthdate',\n  'zoneinfo',\n  'locale',\n  'updated_at',\n\n  // OpenID: \"email\" scope\n  'email',\n  'email_verified',\n\n  // OpenID: \"phone\" scope\n  'phone_number',\n  'phone_number_verified',\n\n  // OpenID: \"address\" scope\n  'address',\n])\n\nexport type OidcClaimsParameter = z.infer<typeof oidcClaimsParameterSchema>\n","import { z } from 'zod'\n\nconst oidcClaimsValueSchema = z.union([z.string(), z.number(), z.boolean()])\n\nexport const oidcClaimsPropertiesSchema = z.object({\n  essential: z.boolean().optional(),\n  value: oidcClaimsValueSchema.optional(),\n  values: z.array(oidcClaimsValueSchema).optional(),\n})\n\nexport type OidcClaimsProperties = z.infer<typeof oidcClaimsPropertiesSchema>\n","import { z } from 'zod'\n\nexport const oidcEntityTypeSchema = z.enum(['userinfo', 'id_token'])\n\nexport type OidcEntityType = z.infer<typeof oidcEntityTypeSchema>\n","import { z } from 'zod'\nimport { signedJwtSchema } from '@atproto/jwk'\nimport { oauthAuthorizationDetailsSchema } from './oauth-authorization-details.js'\nimport { oauthClientIdSchema } from './oauth-client-id.js'\nimport { oauthCodeChallengeMethodSchema } from './oauth-code-challenge-method.js'\nimport { oauthPromptModeSchema } from './oauth-prompt-mode.js'\nimport { oauthRedirectUriSchema } from './oauth-redirect-uri.js'\nimport { oauthResponseModeSchema } from './oauth-response-mode.js'\nimport { oauthResponseTypeSchema } from './oauth-response-type.js'\nimport { oauthScopeSchema } from './oauth-scope.js'\nimport { oidcClaimsParameterSchema } from './oidc-claims-parameter.js'\nimport { oidcClaimsPropertiesSchema } from './oidc-claims-properties.js'\nimport { oidcEntityTypeSchema } from './oidc-entity-type.js'\nimport { jsonObjectPreprocess, numberPreprocess } from './util.js'\n\n/**\n * @note non string parameters will be converted from their string\n * representation since oauth request parameters are typically sent as URL\n * encoded form data or URL encoded query string.\n * @see {@link https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest | OIDC}\n */\nexport const oauthAuthorizationRequestParametersSchema = z.object({\n  client_id: oauthClientIdSchema,\n  state: z.string().optional(),\n  redirect_uri: oauthRedirectUriSchema.optional(),\n  scope: oauthScopeSchema.optional(),\n  response_type: oauthResponseTypeSchema,\n\n  // PKCE\n\n  // https://datatracker.ietf.org/doc/html/rfc7636#section-4.3\n  code_challenge: z.string().optional(),\n  code_challenge_method: oauthCodeChallengeMethodSchema.optional(),\n\n  // DPOP\n\n  // https://datatracker.ietf.org/doc/html/rfc9449#section-12.3\n  dpop_jkt: z.string().optional(),\n\n  // OIDC\n\n  // Default depend on response_type\n  response_mode: oauthResponseModeSchema.optional(),\n\n  nonce: z.string().optional(),\n\n  // Specifies the allowable elapsed time in seconds since the last time the\n  // End-User was actively authenticated by the OP. If the elapsed time is\n  // greater than this value, the OP MUST attempt to actively re-authenticate\n  // the End-User. (The max_age request parameter corresponds to the OpenID 2.0\n  // PAPE [OpenID.PAPE] max_auth_age request parameter.) When max_age is used,\n  // the ID Token returned MUST include an auth_time Claim Value. Note that\n  // max_age=0 is equivalent to prompt=login.\n  max_age: z.preprocess(numberPreprocess, z.number().int().min(0)).optional(),\n\n  claims: z\n    .preprocess(\n      jsonObjectPreprocess,\n      z.record(\n        oidcEntityTypeSchema,\n        z.record(\n          oidcClaimsParameterSchema,\n          z.union([z.literal(null), oidcClaimsPropertiesSchema]),\n        ),\n      ),\n    )\n    .optional(),\n\n  // https://openid.net/specs/openid-connect-core-1_0.html#RegistrationParameter\n  // Not supported by this library (yet?)\n  // registration: clientMetadataSchema.optional(),\n\n  login_hint: z.string().min(1).optional(),\n\n  ui_locales: z\n    .string()\n    .regex(/^[a-z]{2,3}(-[A-Z]{2})?( [a-z]{2,3}(-[A-Z]{2})?)*$/) // fr-CA fr en\n    .optional(),\n\n  // Previous ID Token, should be provided when prompt=none is used\n  id_token_hint: signedJwtSchema.optional(),\n\n  // Type of UI the AS is displayed on\n  display: z.enum(['page', 'popup', 'touch', 'wap']).optional(),\n\n  // How the AS should prompt the user for authorization:\n  prompt: oauthPromptModeSchema.optional(),\n\n  // https://datatracker.ietf.org/doc/html/rfc9396\n  authorization_details: z\n    .preprocess(jsonObjectPreprocess, oauthAuthorizationDetailsSchema)\n    .optional(),\n})\n\n/**\n * @see {oauthAuthorizationRequestParametersSchema}\n */\nexport type OAuthAuthorizationRequestParameters = z.infer<\n  typeof oauthAuthorizationRequestParametersSchema\n>\n","import { z } from 'zod'\nimport { oauthAuthorizationRequestJarSchema } from './oauth-authorization-request-jar.js'\nimport { oauthAuthorizationRequestParametersSchema } from './oauth-authorization-request-parameters.js'\n\nexport const oauthAuthorizationRequestParSchema = z.union([\n  oauthAuthorizationRequestParametersSchema,\n  oauthAuthorizationRequestJarSchema,\n])\n\nexport type OAuthAuthorizationRequestPar = z.infer<\n  typeof oauthAuthorizationRequestParSchema\n>\n","import { z } from 'zod'\n\nexport const oauthRequestUriSchema = z.string().min(1)\n\nexport type OAuthRequestUri = z.infer<typeof oauthRequestUriSchema>\n","import { z } from 'zod'\nimport { oauthRequestUriSchema } from './oauth-request-uri.js'\n\nexport const oauthAuthorizationRequestUriSchema = z.object({\n  request_uri: oauthRequestUriSchema,\n})\n\nexport type OAuthAuthorizationRequestUri = z.infer<\n  typeof oauthAuthorizationRequestUriSchema\n>\n","import { z } from 'zod'\nimport { oauthAuthorizationRequestJarSchema } from './oauth-authorization-request-jar.js'\nimport { oauthAuthorizationRequestParametersSchema } from './oauth-authorization-request-parameters.js'\nimport { oauthAuthorizationRequestUriSchema } from './oauth-authorization-request-uri.js'\nimport { oauthClientIdSchema } from './oauth-client-id.js'\n\nexport const oauthAuthorizationRequestQuerySchema = z.intersection(\n  z.object({\n    // REQUIRED. OAuth 2.0 [RFC6749] client_id.\n    client_id: oauthClientIdSchema,\n  }),\n  z.union([\n    oauthAuthorizationRequestParametersSchema,\n    oauthAuthorizationRequestJarSchema,\n    oauthAuthorizationRequestUriSchema,\n  ]),\n)\n\nexport type OAuthAuthorizationRequestQuery = z.infer<\n  typeof oauthAuthorizationRequestQuerySchema\n>\n","import { z } from 'zod'\n\n/**\n * @see {@link https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#name-error-response-2}\n */\nexport const oauthAuthorizationResponseErrorSchema = z.enum([\n  // The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.\n  'invalid_request',\n  // The client is not authorized to request an authorization code using this method.\n  'unauthorized_client',\n  // The resource owner or authorization server denied the request.\n  'access_denied',\n  // The authorization server does not support obtaining an authorization code using this method.\n  'unsupported_response_type',\n  // The requested scope is invalid, unknown, or malformed.\n  'invalid_scope',\n  // The authorization server encountered an unexpected condition that prevented it from fulfilling the request. (This error code is needed because a 500 Internal Server Error HTTP status code cannot be returned to the client via an HTTP redirect.)\n  'server_error',\n  // The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server. (This error code is needed because a 503 Service Unavailable HTTP status code cannot be returned to the client via an HTTP redirect.)\n  'temporarily_unavailable',\n])\n\nexport type OAuthAuthorizationResponseError = z.infer<\n  typeof oauthAuthorizationResponseErrorSchema\n>\n","import { z } from 'zod'\nimport { webUriSchema } from './uri.js'\n\nexport const oauthIssuerIdentifierSchema = webUriSchema.superRefine(\n  (value, ctx) => {\n    // Validate the issuer (MIX-UP attacks)\n\n    if (value.endsWith('/')) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: 'Issuer URL must not end with a slash',\n      })\n      return false\n    }\n\n    const url = new URL(value)\n\n    if (url.username || url.password) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: 'Issuer URL must not contain a username or password',\n      })\n      return false\n    }\n\n    if (url.hash || url.search) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: 'Issuer URL must not contain a query or fragment',\n      })\n      return false\n    }\n\n    const canonicalValue = url.pathname === '/' ? url.origin : url.href\n    if (value !== canonicalValue) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: 'Issuer URL must be in the canonical form',\n      })\n      return false\n    }\n\n    return true\n  },\n)\n\nexport type OAuthIssuerIdentifier = z.infer<typeof oauthIssuerIdentifierSchema>\n","import { z } from 'zod'\nimport { oauthCodeChallengeMethodSchema } from './oauth-code-challenge-method.js'\nimport { oauthIssuerIdentifierSchema } from './oauth-issuer-identifier.js'\nimport { oauthPromptModeSchema } from './oauth-prompt-mode.js'\nimport { webUriSchema } from './uri.js'\n\n/**\n * @see {@link https://datatracker.ietf.org/doc/html/rfc8414}\n * @note we do not enforce https: scheme in URIs to support development\n * environments. Make sure to validate the URIs before using it in a production\n * environment.\n */\nexport const oauthAuthorizationServerMetadataSchema = z.object({\n  issuer: oauthIssuerIdentifierSchema,\n\n  claims_supported: z.array(z.string()).optional(),\n  claims_locales_supported: z.array(z.string()).optional(),\n  claims_parameter_supported: z.boolean().optional(),\n  request_parameter_supported: z.boolean().optional(),\n  request_uri_parameter_supported: z.boolean().optional(),\n  require_request_uri_registration: z.boolean().optional(),\n  scopes_supported: z.array(z.string()).optional(),\n  subject_types_supported: z.array(z.string()).optional(),\n  response_types_supported: z.array(z.string()).optional(),\n  response_modes_supported: z.array(z.string()).optional(),\n  grant_types_supported: z.array(z.string()).optional(),\n  code_challenge_methods_supported: z\n    .array(oauthCodeChallengeMethodSchema)\n    .min(1)\n    .optional(),\n  ui_locales_supported: z.array(z.string()).optional(),\n  id_token_signing_alg_values_supported: z.array(z.string()).optional(),\n  display_values_supported: z.array(z.string()).optional(),\n  request_object_signing_alg_values_supported: z.array(z.string()).optional(),\n  authorization_response_iss_parameter_supported: z.boolean().optional(),\n  authorization_details_types_supported: z.array(z.string()).optional(),\n  request_object_encryption_alg_values_supported: z\n    .array(z.string())\n    .optional(),\n  request_object_encryption_enc_values_supported: z\n    .array(z.string())\n    .optional(),\n\n  jwks_uri: webUriSchema.optional(),\n\n  authorization_endpoint: webUriSchema, // .optional(),\n\n  token_endpoint: webUriSchema, // .optional(),\n  // https://www.rfc-editor.org/rfc/rfc8414.html#section-2\n  token_endpoint_auth_methods_supported: z\n    .array(z.string())\n    // > If omitted, the default is \"client_secret_basic\" [...].\n    .default(['client_secret_basic']),\n  token_endpoint_auth_signing_alg_values_supported: z\n    .array(z.string())\n    .optional(),\n\n  revocation_endpoint: webUriSchema.optional(),\n  introspection_endpoint: webUriSchema.optional(),\n  pushed_authorization_request_endpoint: webUriSchema.optional(),\n\n  require_pushed_authorization_requests: z.boolean().optional(),\n\n  userinfo_endpoint: webUriSchema.optional(),\n  end_session_endpoint: webUriSchema.optional(),\n  registration_endpoint: webUriSchema.optional(),\n\n  // https://datatracker.ietf.org/doc/html/rfc9449#section-5.1\n  dpop_signing_alg_values_supported: z.array(z.string()).optional(),\n\n  // https://www.rfc-editor.org/rfc/rfc9728.html#section-4\n  protected_resources: z.array(webUriSchema).optional(),\n\n  // https://www.ietf.org/archive/id/draft-ietf-oauth-client-id-metadata-document-00.html\n  client_id_metadata_document_supported: z.boolean().optional(),\n\n  // https://openid.net/specs/openid-connect-prompt-create-1_0.html#section-4.2\n  prompt_values_supported: z.array(oauthPromptModeSchema).optional(),\n})\n\nexport type OAuthAuthorizationServerMetadata = z.infer<\n  typeof oauthAuthorizationServerMetadataSchema\n>\n\nexport const oauthAuthorizationServerMetadataValidator =\n  oauthAuthorizationServerMetadataSchema\n    .superRefine((data, ctx) => {\n      if (\n        data.require_pushed_authorization_requests &&\n        !data.pushed_authorization_request_endpoint\n      ) {\n        ctx.addIssue({\n          code: z.ZodIssueCode.custom,\n          message:\n            '\"pushed_authorization_request_endpoint\" required when \"require_pushed_authorization_requests\" is true',\n        })\n      }\n    })\n    .superRefine((data, ctx) => {\n      if (data.response_types_supported) {\n        if (!data.response_types_supported.includes('code')) {\n          ctx.addIssue({\n            code: z.ZodIssueCode.custom,\n            message: 'Response type \"code\" is required',\n          })\n        }\n      }\n    })\n    .superRefine((data, ctx) => {\n      if (\n        data.token_endpoint_auth_signing_alg_values_supported?.includes('none')\n      ) {\n        // https://openid.net/specs/openid-connect-discovery-1_0.html#rfc.section.3\n        // > The value `none` MUST NOT be used.\n        ctx.addIssue({\n          code: z.ZodIssueCode.custom,\n          message: 'Client authentication method \"none\" is not allowed',\n        })\n      }\n    })\n","import { z } from 'zod'\n\nexport const oauthClientCredentialsGrantTokenRequestSchema = z.object({\n  grant_type: z.literal('client_credentials'),\n})\n\nexport type OAuthClientCredentialsGrantTokenRequest = z.infer<\n  typeof oauthClientCredentialsGrantTokenRequestSchema\n>\n","import { z } from 'zod'\nimport { signedJwtSchema } from '@atproto/jwk'\nimport { CLIENT_ASSERTION_TYPE_JWT_BEARER } from './constants.js'\nimport { oauthClientIdSchema } from './oauth-client-id.js'\n\nexport const oauthClientCredentialsJwtBearerSchema = z.object({\n  client_id: oauthClientIdSchema,\n  client_assertion_type: z.literal(CLIENT_ASSERTION_TYPE_JWT_BEARER),\n  /**\n   * - \"sub\" the subject MUST be the \"client_id\" of the OAuth client\n   * - \"iat\" is required and MUST be less than one minute\n   * - \"aud\" must containing a value that identifies the authorization server\n   * - The JWT MAY contain a \"jti\" (JWT ID) claim that provides a unique identifier for the token.\n   * - Note that the authorization server may reject JWTs with an \"exp\" claim value that is unreasonably far in the future.\n   *\n   * @see {@link https://datatracker.ietf.org/doc/html/rfc7523#section-3}\n   */\n  client_assertion: signedJwtSchema,\n})\n\nexport type OAuthClientCredentialsJwtBearer = z.infer<\n  typeof oauthClientCredentialsJwtBearerSchema\n>\n\nexport const oauthClientCredentialsSecretPostSchema = z.object({\n  client_id: oauthClientIdSchema,\n  client_secret: z.string(),\n})\n\nexport type OAuthClientCredentialsSecretPost = z.infer<\n  typeof oauthClientCredentialsSecretPostSchema\n>\n\nexport const oauthClientCredentialsNoneSchema = z.object({\n  client_id: oauthClientIdSchema,\n})\n\nexport type OAuthClientCredentialsNone = z.infer<\n  typeof oauthClientCredentialsNoneSchema\n>\n\n//\n\nexport const oauthClientCredentialsSchema = z.union([\n  oauthClientCredentialsJwtBearerSchema,\n  oauthClientCredentialsSecretPostSchema,\n  // Must be last since it is less specific\n  oauthClientCredentialsNoneSchema,\n])\n\nexport type OAuthClientCredentials = z.infer<\n  typeof oauthClientCredentialsSchema\n>\n","import { type TypeOf, z } from 'zod'\nimport { oauthClientIdSchema } from './oauth-client-id.js'\nimport { httpsUriSchema } from './uri.js'\nimport { extractUrlPath, isHostnameIP } from './util.js'\n\n/**\n * @see {@link https://www.ietf.org/archive/id/draft-ietf-oauth-client-id-metadata-document-00.html}\n */\nexport const oauthClientIdDiscoverableSchema = z\n  .intersection(oauthClientIdSchema, httpsUriSchema)\n  .superRefine((value, ctx): value is `https://${string}/${string}` => {\n    const url = new URL(value)\n\n    if (url.username || url.password) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: 'ClientID must not contain credentials',\n      })\n      return false\n    }\n\n    if (url.hash) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: 'ClientID must not contain a fragment',\n      })\n      return false\n    }\n\n    if (url.pathname === '/') {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message:\n          'ClientID must contain a path component (e.g. \"/client-metadata.json\")',\n      })\n      return false\n    }\n\n    if (url.pathname.endsWith('/')) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: 'ClientID path must not end with a trailing slash',\n      })\n      return false\n    }\n\n    if (isHostnameIP(url.hostname)) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: 'ClientID hostname must not be an IP address',\n      })\n      return false\n    }\n\n    // URL constructor normalizes the URL, so we extract the path manually to\n    // avoid normalization, then compare it to the normalized path to ensure\n    // that the URL does not contain path traversal or other unexpected characters\n    if (extractUrlPath(value) !== url.pathname) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: `ClientID must be in canonical form (\"${url.href}\", got \"${value}\")`,\n      })\n      return false\n    }\n\n    return true\n  })\n\nexport type OAuthClientIdDiscoverable = TypeOf<\n  typeof oauthClientIdDiscoverableSchema\n>\n\nexport function isOAuthClientIdDiscoverable(\n  clientId: string,\n): clientId is OAuthClientIdDiscoverable {\n  return oauthClientIdDiscoverableSchema.safeParse(clientId).success\n}\n\nexport const conventionalOAuthClientIdSchema =\n  oauthClientIdDiscoverableSchema.superRefine(\n    (value, ctx): value is `https://${string}/oauth-client-metadata.json` => {\n      const url = new URL(value)\n\n      if (url.port) {\n        ctx.addIssue({\n          code: z.ZodIssueCode.custom,\n          message: 'ClientID must not contain a port',\n        })\n        return false\n      }\n\n      if (url.search) {\n        ctx.addIssue({\n          code: z.ZodIssueCode.custom,\n          message: 'ClientID must not contain a query string',\n        })\n        return false\n      }\n\n      if (url.pathname !== '/oauth-client-metadata.json') {\n        ctx.addIssue({\n          code: z.ZodIssueCode.custom,\n          message: 'ClientID must be \"/oauth-client-metadata.json\"',\n        })\n        return false\n      }\n\n      return true\n    },\n  )\n\nexport type ConventionalOAuthClientId = TypeOf<\n  typeof conventionalOAuthClientIdSchema\n>\n\nexport function isConventionalOAuthClientId(\n  clientId: string,\n): clientId is ConventionalOAuthClientId {\n  return conventionalOAuthClientIdSchema.safeParse(clientId).success\n}\n\nexport function assertOAuthDiscoverableClientId(\n  value: string,\n): asserts value is OAuthClientIdDiscoverable {\n  void oauthClientIdDiscoverableSchema.parse(value)\n}\n\nexport function parseOAuthDiscoverableClientId(clientId: string): URL {\n  return new URL(oauthClientIdDiscoverableSchema.parse(clientId))\n}\n","import { z } from 'zod'\n\nexport const oauthEndpointAuthMethod = z.enum([\n  'client_secret_basic',\n  'client_secret_jwt',\n  'client_secret_post',\n  'none',\n  'private_key_jwt',\n  'self_signed_tls_client_auth',\n  'tls_client_auth',\n])\n\nexport type OauthEndpointAuthMethod = z.infer<typeof oauthEndpointAuthMethod>\n","import { z } from 'zod'\n\nexport const oauthGrantTypeSchema = z.enum([\n  'authorization_code',\n  'implicit',\n  'refresh_token',\n  'password', // Not part of OAuth 2.1\n  'client_credentials',\n  'urn:ietf:params:oauth:grant-type:jwt-bearer',\n  'urn:ietf:params:oauth:grant-type:saml2-bearer',\n])\n\nexport type OAuthGrantType = z.infer<typeof oauthGrantTypeSchema>\n","import { z } from 'zod'\nimport { jwksPubSchema } from '@atproto/jwk'\nimport { oauthClientIdSchema } from './oauth-client-id.js'\nimport { oauthEndpointAuthMethod } from './oauth-endpoint-auth-method.js'\nimport { oauthGrantTypeSchema } from './oauth-grant-type.js'\nimport { oauthRedirectUriSchema } from './oauth-redirect-uri.js'\nimport { oauthResponseTypeSchema } from './oauth-response-type.js'\nimport { oauthScopeSchema } from './oauth-scope.js'\nimport { webUriSchema } from './uri.js'\n\n/**\n * @see {@link https://openid.net/specs/openid-connect-registration-1_0.html}\n * @see {@link https://datatracker.ietf.org/doc/html/rfc7591}\n * @note we do not enforce https: scheme in URIs to support development\n * environments. Make sure to validate the URIs before using it in a production\n * environment.\n */\nexport const oauthClientMetadataSchema = z.object({\n  /**\n   * @note redirect_uris require additional validation\n   */\n  // https://www.rfc-editor.org/rfc/rfc7591.html#section-2\n  redirect_uris: z.array(oauthRedirectUriSchema).nonempty(),\n  response_types: z\n    .array(oauthResponseTypeSchema)\n    .nonempty()\n    // > If omitted, the default is that the client will use only the \"code\"\n    // > response type.\n    .default(['code']),\n  grant_types: z\n    .array(oauthGrantTypeSchema)\n    .nonempty()\n    // > If omitted, the default behavior is that the client will use only the\n    // > \"authorization_code\" Grant Type.\n    .default(['authorization_code']),\n  scope: oauthScopeSchema.optional(),\n  // https://www.rfc-editor.org/rfc/rfc7591.html#section-2\n  token_endpoint_auth_method: oauthEndpointAuthMethod\n    // > If unspecified or omitted, the default is \"client_secret_basic\" [...].\n    .default('client_secret_basic'),\n  token_endpoint_auth_signing_alg: z.string().optional(),\n  userinfo_signed_response_alg: z.string().optional(),\n  userinfo_encrypted_response_alg: z.string().optional(),\n  jwks_uri: webUriSchema.optional(),\n  jwks: jwksPubSchema.optional(),\n  application_type: z.enum(['web', 'native']).default('web'), // default, per spec, is \"web\"\n  subject_type: z.enum(['public', 'pairwise']).default('public'),\n  request_object_signing_alg: z.string().optional(),\n  id_token_signed_response_alg: z.string().optional(),\n  authorization_signed_response_alg: z.string().default('RS256'),\n  authorization_encrypted_response_enc: z.enum(['A128CBC-HS256']).optional(),\n  authorization_encrypted_response_alg: z.string().optional(),\n  client_id: oauthClientIdSchema.optional(),\n  client_name: z.string().optional(),\n  client_uri: webUriSchema.optional(),\n  policy_uri: webUriSchema.optional(),\n  tos_uri: webUriSchema.optional(),\n  logo_uri: webUriSchema.optional(), // @TODO: allow data: uri ?\n\n  /**\n   * Default Maximum Authentication Age. Specifies that the End-User MUST be\n   * actively authenticated if the End-User was authenticated longer ago than\n   * the specified number of seconds. The max_age request parameter overrides\n   * this default value. If omitted, no default Maximum Authentication Age is\n   * specified.\n   */\n  default_max_age: z.number().optional(),\n  require_auth_time: z.boolean().optional(),\n  contacts: z.array(z.string().email()).optional(),\n  tls_client_certificate_bound_access_tokens: z.boolean().optional(),\n\n  // https://datatracker.ietf.org/doc/html/rfc9449#section-5.2\n  dpop_bound_access_tokens: z.boolean().optional(),\n\n  // https://datatracker.ietf.org/doc/html/rfc9396#section-14.5\n  authorization_details_types: z.array(z.string()).optional(),\n})\n\nexport type OAuthClientMetadata = z.infer<typeof oauthClientMetadataSchema>\nexport type OAuthClientMetadataInput = z.input<typeof oauthClientMetadataSchema>\n","export const OAUTH_ENDPOINT_NAMES = [\n  'token',\n  'revocation',\n  'introspection',\n  'pushed_authorization_request',\n] as const\n\nexport type OAuthEndpointName = (typeof OAUTH_ENDPOINT_NAMES)[number]\n","import { z } from 'zod'\n\nexport const oauthParResponseSchema = z.object({\n  request_uri: z.string(),\n  expires_in: z.number().int().positive(),\n})\n\nexport type OAuthParResponse = z.infer<typeof oauthParResponseSchema>\n","import { z } from 'zod'\n\nexport const oauthPasswordGrantTokenRequestSchema = z.object({\n  grant_type: z.literal('password'),\n  username: z.string(),\n  password: z.string(),\n})\n\nexport type OAuthPasswordGrantTokenRequest = z.infer<\n  typeof oauthPasswordGrantTokenRequestSchema\n>\n","import { z } from 'zod'\nimport { oauthIssuerIdentifierSchema } from './oauth-issuer-identifier.js'\nimport { webUriSchema } from './uri.js'\n\n/**\n * @see {@link https://www.rfc-editor.org/rfc/rfc9728.html#section-3.2}\n */\nexport const oauthProtectedResourceMetadataSchema = z.object({\n  /**\n   * REQUIRED. The protected resource's resource identifier, which is a URL that\n   * uses the https scheme and has no query or fragment components. Using these\n   * well-known resources is described in Section 3.\n   *\n   * @note This schema allows non https URLs for testing & development purposes.\n   * Make sure to validate the URL before using it in a production environment.\n   */\n  resource: webUriSchema\n    .refine((url) => !url.includes('?'), {\n      message: 'Resource URL must not contain query parameters',\n    })\n    .refine((url) => !url.includes('#'), {\n      message: 'Resource URL must not contain a fragment',\n    }),\n\n  /**\n   * OPTIONAL. JSON array containing a list of OAuth authorization server issuer\n   * identifiers, as defined in [RFC8414], for authorization servers that can be\n   * used with this protected resource. Protected resources MAY choose not to\n   * advertise some supported authorization servers even when this parameter is\n   * used. In some use cases, the set of authorization servers will not be\n   * enumerable, in which case this metadata parameter would not be used.\n   */\n  authorization_servers: z.array(oauthIssuerIdentifierSchema).optional(),\n\n  /**\n   * OPTIONAL. URL of the protected resource's JWK Set [JWK] document. This\n   * contains public keys belonging to the protected resource, such as signing\n   * key(s) that the resource server uses to sign resource responses. This URL\n   * MUST use the https scheme. When both signing and encryption keys are made\n   * available, a use (public key use) parameter value is REQUIRED for all keys\n   * in the referenced JWK Set to indicate each key's intended usage.\n   */\n  jwks_uri: webUriSchema.optional(),\n\n  /**\n   * RECOMMENDED. JSON array containing a list of the OAuth 2.0 [RFC6749] scope\n   * values that are used in authorization requests to request access to this\n   * protected resource. Protected resources MAY choose not to advertise some\n   * scope values supported even when this parameter is used.\n   */\n  scopes_supported: z.array(z.string()).optional(),\n\n  /**\n   * OPTIONAL. JSON array containing a list of the supported methods of sending\n   * an OAuth 2.0 Bearer Token [RFC6750] to the protected resource. Defined\n   * values are [\"header\", \"body\", \"query\"], corresponding to Sections 2.1, 2.2,\n   * and 2.3 of RFC 6750.\n   */\n  bearer_methods_supported: z\n    .array(z.enum(['header', 'body', 'query']))\n    .optional(),\n\n  /**\n   * OPTIONAL. JSON array containing a list of the JWS [JWS] signing algorithms\n   * (alg values) [JWA] supported by the protected resource for signing resource\n   * responses, for instance, as described in [FAPI.MessageSigning]. No default\n   * algorithms are implied if this entry is omitted. The value none MUST NOT be\n   * used.\n   */\n  resource_signing_alg_values_supported: z.array(z.string()).optional(),\n\n  /**\n   * OPTIONAL. URL of a page containing human-readable information that\n   * developers might want or need to know when using the protected resource\n   */\n  resource_documentation: webUriSchema.optional(),\n\n  /**\n   * OPTIONAL. URL that the protected resource provides to read about the\n   * protected resource's requirements on how the client can use the data\n   * provided by the protected resource\n   */\n  resource_policy_uri: webUriSchema.optional(),\n\n  /**\n   * OPTIONAL. URL that the protected resource provides to read about the\n   * protected resource's terms of service\n   */\n  resource_tos_uri: webUriSchema.optional(),\n})\n\nexport type OAuthProtectedResourceMetadata = z.infer<\n  typeof oauthProtectedResourceMetadataSchema\n>\n","import { z } from 'zod'\n\nexport const oauthRefreshTokenSchema = z.string().min(1)\nexport type OAuthRefreshToken = z.infer<typeof oauthRefreshTokenSchema>\n","import { z } from 'zod'\nimport { oauthRefreshTokenSchema } from './oauth-refresh-token.js'\n\nexport const oauthRefreshTokenGrantTokenRequestSchema = z.object({\n  grant_type: z.literal('refresh_token'),\n  refresh_token: oauthRefreshTokenSchema,\n})\n\nexport type OAuthRefreshTokenGrantTokenRequest = z.infer<\n  typeof oauthRefreshTokenGrantTokenRequestSchema\n>\n","import { z } from 'zod'\nimport { oauthAccessTokenSchema } from './oauth-access-token.js'\nimport { oauthRefreshTokenSchema } from './oauth-refresh-token.js'\n\nexport const oauthTokenIdentificationSchema = z.object({\n  token: z.union([oauthAccessTokenSchema, oauthRefreshTokenSchema]),\n  token_type_hint: z.enum(['access_token', 'refresh_token']).optional(),\n})\n\nexport type OAuthTokenIdentification = z.infer<\n  typeof oauthTokenIdentificationSchema\n>\n","import { z } from 'zod'\nimport { oauthAuthorizationCodeGrantTokenRequestSchema } from './oauth-authorization-code-grant-token-request.js'\nimport { oauthClientCredentialsGrantTokenRequestSchema } from './oauth-client-credentials-grant-token-request.js'\nimport { oauthPasswordGrantTokenRequestSchema } from './oauth-password-grant-token-request.js'\nimport { oauthRefreshTokenGrantTokenRequestSchema } from './oauth-refresh-token-grant-token-request.js'\n\nexport const oauthTokenRequestSchema = z.discriminatedUnion('grant_type', [\n  oauthAuthorizationCodeGrantTokenRequestSchema,\n  oauthRefreshTokenGrantTokenRequestSchema,\n  oauthPasswordGrantTokenRequestSchema,\n  oauthClientCredentialsGrantTokenRequestSchema,\n])\n\nexport type OAuthTokenRequest = z.infer<typeof oauthTokenRequestSchema>\n","import { z } from 'zod'\n\n/**\n * @see {@link https://openid.net/specs/openid-connect-core-1_0.html#AuthError}\n */\nexport const oidcAuthorizationResponseErrorSchema = z.enum([\n  // The Authorization Server requires End-User interaction of some form to proceed. This error MAY be returned when the prompt parameter value in the Authentication Request is none, but the Authentication Request cannot be completed without displaying a user interface for End-User interaction.\n  'interaction_required',\n  // The Authorization Server requires End-User authentication. This error MAY be returned when the prompt parameter value in the Authentication Request is none, but the Authentication Request cannot be completed without displaying a user interface for End-User authentication.\n  'login_required',\n  // The End-User is REQUIRED to select a session at the Authorization Server. The End-User MAY be authenticated at the Authorization Server with different associated accounts, but the End-User did not select a session. This error MAY be returned when the prompt parameter value in the Authentication Request is none, but the Authentication Request cannot be completed without displaying a user interface to prompt for a session to use.\n  'account_selection_required',\n  // The Authorization Server requires End-User consent. This error MAY be returned when the prompt parameter value in the Authentication Request is none, but the Authentication Request cannot be completed without displaying a user interface for End-User consent.\n  'consent_required',\n  // The request_uri in the Authorization Request returns an error or contains invalid data.\n  'invalid_request_uri',\n  // The request parameter contains an invalid Request Object.\n  'invalid_request_object',\n  // The OP does not support use of the request parameter defined in Section 6.\n  'request_not_supported',\n  // The OP does not support use of the request_uri parameter defined in Section 6.\n  'request_uri_not_supported',\n  // The OP does not support use of the registration parameter defined in Section 7.2.1.\n  'registration_not_supported',\n])\n\nexport type OidcAuthorizationResponseError = z.infer<\n  typeof oidcAuthorizationResponseErrorSchema\n>\n","import { z } from 'zod'\n\nexport const oidcUserinfoSchema = z.object({\n  sub: z.string(),\n  iss: z.string().url().optional(),\n  aud: z.union([z.string(), z.array(z.string()).min(1)]).optional(),\n\n  email: z.string().email().optional(),\n  email_verified: z.boolean().optional(),\n  name: z.string().optional(),\n  preferred_username: z.string().optional(),\n  picture: z.string().url().optional(),\n})\n\nexport type OidcUserinfo = z.infer<typeof oidcUserinfoSchema>\n"]}