auth.d.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import * as z from 'zod/v4';
  2. /**
  3. * Reusable URL validation that disallows javascript: scheme
  4. */
  5. export declare const SafeUrlSchema: z.ZodURL;
  6. /**
  7. * RFC 9728 OAuth Protected Resource Metadata
  8. */
  9. export declare const OAuthProtectedResourceMetadataSchema: z.ZodObject<{
  10. resource: z.ZodString;
  11. authorization_servers: z.ZodOptional<z.ZodArray<z.ZodURL>>;
  12. jwks_uri: z.ZodOptional<z.ZodString>;
  13. scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  14. bearer_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  15. resource_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  16. resource_name: z.ZodOptional<z.ZodString>;
  17. resource_documentation: z.ZodOptional<z.ZodString>;
  18. resource_policy_uri: z.ZodOptional<z.ZodString>;
  19. resource_tos_uri: z.ZodOptional<z.ZodString>;
  20. tls_client_certificate_bound_access_tokens: z.ZodOptional<z.ZodBoolean>;
  21. authorization_details_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  22. dpop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  23. dpop_bound_access_tokens_required: z.ZodOptional<z.ZodBoolean>;
  24. }, z.core.$loose>;
  25. /**
  26. * RFC 8414 OAuth 2.0 Authorization Server Metadata
  27. */
  28. export declare const OAuthMetadataSchema: z.ZodObject<{
  29. issuer: z.ZodString;
  30. authorization_endpoint: z.ZodURL;
  31. token_endpoint: z.ZodURL;
  32. registration_endpoint: z.ZodOptional<z.ZodURL>;
  33. scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  34. response_types_supported: z.ZodArray<z.ZodString>;
  35. response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  36. grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  37. token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  38. token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  39. service_documentation: z.ZodOptional<z.ZodURL>;
  40. revocation_endpoint: z.ZodOptional<z.ZodURL>;
  41. revocation_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  42. revocation_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  43. introspection_endpoint: z.ZodOptional<z.ZodString>;
  44. introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  45. introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  46. code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  47. client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
  48. }, z.core.$loose>;
  49. /**
  50. * OpenID Connect Discovery 1.0 Provider Metadata
  51. * see: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
  52. */
  53. export declare const OpenIdProviderMetadataSchema: z.ZodObject<{
  54. issuer: z.ZodString;
  55. authorization_endpoint: z.ZodURL;
  56. token_endpoint: z.ZodURL;
  57. userinfo_endpoint: z.ZodOptional<z.ZodURL>;
  58. jwks_uri: z.ZodURL;
  59. registration_endpoint: z.ZodOptional<z.ZodURL>;
  60. scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  61. response_types_supported: z.ZodArray<z.ZodString>;
  62. response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  63. grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  64. acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  65. subject_types_supported: z.ZodArray<z.ZodString>;
  66. id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
  67. id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  68. id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  69. userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  70. userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  71. userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  72. request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  73. request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  74. request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  75. token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  76. token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  77. display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  78. claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  79. claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  80. service_documentation: z.ZodOptional<z.ZodString>;
  81. claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  82. ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  83. claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
  84. request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
  85. request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
  86. require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
  87. op_policy_uri: z.ZodOptional<z.ZodURL>;
  88. op_tos_uri: z.ZodOptional<z.ZodURL>;
  89. client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
  90. }, z.core.$loose>;
  91. /**
  92. * OpenID Connect Discovery metadata that may include OAuth 2.0 fields
  93. * This schema represents the real-world scenario where OIDC providers
  94. * return a mix of OpenID Connect and OAuth 2.0 metadata fields
  95. */
  96. export declare const OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<{
  97. code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  98. issuer: z.ZodString;
  99. authorization_endpoint: z.ZodURL;
  100. token_endpoint: z.ZodURL;
  101. userinfo_endpoint: z.ZodOptional<z.ZodURL>;
  102. jwks_uri: z.ZodURL;
  103. registration_endpoint: z.ZodOptional<z.ZodURL>;
  104. scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  105. response_types_supported: z.ZodArray<z.ZodString>;
  106. response_modes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  107. grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  108. acr_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  109. subject_types_supported: z.ZodArray<z.ZodString>;
  110. id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
  111. id_token_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  112. id_token_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  113. userinfo_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  114. userinfo_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  115. userinfo_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  116. request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  117. request_object_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  118. request_object_encryption_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  119. token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  120. token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  121. display_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  122. claim_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  123. claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  124. service_documentation: z.ZodOptional<z.ZodString>;
  125. claims_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  126. ui_locales_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
  127. claims_parameter_supported: z.ZodOptional<z.ZodBoolean>;
  128. request_parameter_supported: z.ZodOptional<z.ZodBoolean>;
  129. request_uri_parameter_supported: z.ZodOptional<z.ZodBoolean>;
  130. require_request_uri_registration: z.ZodOptional<z.ZodBoolean>;
  131. op_policy_uri: z.ZodOptional<z.ZodURL>;
  132. op_tos_uri: z.ZodOptional<z.ZodURL>;
  133. client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
  134. }, z.core.$strip>;
  135. /**
  136. * OAuth 2.1 token response
  137. */
  138. export declare const OAuthTokensSchema: z.ZodObject<{
  139. access_token: z.ZodString;
  140. id_token: z.ZodOptional<z.ZodString>;
  141. token_type: z.ZodString;
  142. expires_in: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
  143. scope: z.ZodOptional<z.ZodString>;
  144. refresh_token: z.ZodOptional<z.ZodString>;
  145. }, z.core.$strip>;
  146. /**
  147. * OAuth 2.1 error response
  148. */
  149. export declare const OAuthErrorResponseSchema: z.ZodObject<{
  150. error: z.ZodString;
  151. error_description: z.ZodOptional<z.ZodString>;
  152. error_uri: z.ZodOptional<z.ZodString>;
  153. }, z.core.$strip>;
  154. /**
  155. * Optional version of SafeUrlSchema that allows empty string for retrocompatibility on tos_uri and logo_uri
  156. */
  157. export declare const OptionalSafeUrlSchema: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
  158. /**
  159. * RFC 7591 OAuth 2.0 Dynamic Client Registration metadata
  160. */
  161. export declare const OAuthClientMetadataSchema: z.ZodObject<{
  162. redirect_uris: z.ZodArray<z.ZodURL>;
  163. token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
  164. grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
  165. response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
  166. client_name: z.ZodOptional<z.ZodString>;
  167. client_uri: z.ZodOptional<z.ZodURL>;
  168. logo_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
  169. scope: z.ZodOptional<z.ZodString>;
  170. contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
  171. tos_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
  172. policy_uri: z.ZodOptional<z.ZodString>;
  173. jwks_uri: z.ZodOptional<z.ZodURL>;
  174. jwks: z.ZodOptional<z.ZodAny>;
  175. software_id: z.ZodOptional<z.ZodString>;
  176. software_version: z.ZodOptional<z.ZodString>;
  177. software_statement: z.ZodOptional<z.ZodString>;
  178. }, z.core.$strip>;
  179. /**
  180. * RFC 7591 OAuth 2.0 Dynamic Client Registration client information
  181. */
  182. export declare const OAuthClientInformationSchema: z.ZodObject<{
  183. client_id: z.ZodString;
  184. client_secret: z.ZodOptional<z.ZodString>;
  185. client_id_issued_at: z.ZodOptional<z.ZodNumber>;
  186. client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
  187. }, z.core.$strip>;
  188. /**
  189. * RFC 7591 OAuth 2.0 Dynamic Client Registration full response (client information plus metadata)
  190. */
  191. export declare const OAuthClientInformationFullSchema: z.ZodObject<{
  192. redirect_uris: z.ZodArray<z.ZodURL>;
  193. token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
  194. grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
  195. response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
  196. client_name: z.ZodOptional<z.ZodString>;
  197. client_uri: z.ZodOptional<z.ZodURL>;
  198. logo_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
  199. scope: z.ZodOptional<z.ZodString>;
  200. contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
  201. tos_uri: z.ZodUnion<[z.ZodOptional<z.ZodURL>, z.ZodPipe<z.ZodLiteral<"">, z.ZodTransform<undefined, "">>]>;
  202. policy_uri: z.ZodOptional<z.ZodString>;
  203. jwks_uri: z.ZodOptional<z.ZodURL>;
  204. jwks: z.ZodOptional<z.ZodAny>;
  205. software_id: z.ZodOptional<z.ZodString>;
  206. software_version: z.ZodOptional<z.ZodString>;
  207. software_statement: z.ZodOptional<z.ZodString>;
  208. client_id: z.ZodString;
  209. client_secret: z.ZodOptional<z.ZodString>;
  210. client_id_issued_at: z.ZodOptional<z.ZodNumber>;
  211. client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
  212. }, z.core.$strip>;
  213. /**
  214. * RFC 7591 OAuth 2.0 Dynamic Client Registration error response
  215. */
  216. export declare const OAuthClientRegistrationErrorSchema: z.ZodObject<{
  217. error: z.ZodString;
  218. error_description: z.ZodOptional<z.ZodString>;
  219. }, z.core.$strip>;
  220. /**
  221. * RFC 7009 OAuth 2.0 Token Revocation request
  222. */
  223. export declare const OAuthTokenRevocationRequestSchema: z.ZodObject<{
  224. token: z.ZodString;
  225. token_type_hint: z.ZodOptional<z.ZodString>;
  226. }, z.core.$strip>;
  227. export type OAuthMetadata = z.infer<typeof OAuthMetadataSchema>;
  228. export type OpenIdProviderMetadata = z.infer<typeof OpenIdProviderMetadataSchema>;
  229. export type OpenIdProviderDiscoveryMetadata = z.infer<typeof OpenIdProviderDiscoveryMetadataSchema>;
  230. export type OAuthTokens = z.infer<typeof OAuthTokensSchema>;
  231. export type OAuthErrorResponse = z.infer<typeof OAuthErrorResponseSchema>;
  232. export type OAuthClientMetadata = z.infer<typeof OAuthClientMetadataSchema>;
  233. export type OAuthClientInformation = z.infer<typeof OAuthClientInformationSchema>;
  234. export type OAuthClientInformationFull = z.infer<typeof OAuthClientInformationFullSchema>;
  235. export type OAuthClientInformationMixed = OAuthClientInformation | OAuthClientInformationFull;
  236. export type OAuthClientRegistrationError = z.infer<typeof OAuthClientRegistrationErrorSchema>;
  237. export type OAuthTokenRevocationRequest = z.infer<typeof OAuthTokenRevocationRequestSchema>;
  238. export type OAuthProtectedResourceMetadata = z.infer<typeof OAuthProtectedResourceMetadataSchema>;
  239. export type AuthorizationServerMetadata = OAuthMetadata | OpenIdProviderDiscoveryMetadata;
  240. //# sourceMappingURL=auth.d.ts.map