@@ -19,9 +19,12 @@ export type ClientRegistrationHandlerOptions = {
1919 clientsStore : OAuthRegisteredClientsStore ;
2020
2121 /**
22- * The number of seconds after which to expire issued client secrets, or 0 to prevent expiration of client secrets (not recommended).
23- *
24- * If not set, defaults to 30 days.
22+ * The number of seconds after which to expire issued client secrets.
23+ * - If set to a positive number, client secrets will expire after that many seconds.
24+ * - If set to 0, client_secret_expires_at will be 0 (meaning no expiration per RFC 7591).
25+ * - If not set (undefined), client_secret_expires_at will be omitted from the response (no expiration).
26+ *
27+ * Defaults to undefined (no expiration), consistent with Python SDK behavior.
2528 */
2629 clientSecretExpirySeconds ?: number ;
2730
@@ -40,11 +43,9 @@ export type ClientRegistrationHandlerOptions = {
4043 clientIdGeneration ?: boolean ;
4144} ;
4245
43- const DEFAULT_CLIENT_SECRET_EXPIRY_SECONDS = 30 * 24 * 60 * 60 ; // 30 days
44-
4546export function clientRegistrationHandler ( {
4647 clientsStore,
47- clientSecretExpirySeconds = DEFAULT_CLIENT_SECRET_EXPIRY_SECONDS ,
48+ clientSecretExpirySeconds,
4849 rateLimit : rateLimitConfig ,
4950 clientIdGeneration = true ,
5051} : ClientRegistrationHandlerOptions ) : RequestHandler {
@@ -92,9 +93,18 @@ export function clientRegistrationHandler({
9293 const clientIdIssuedAt = Math . floor ( Date . now ( ) / 1000 ) ;
9394
9495 // Calculate client secret expiry time
95- const clientsDoExpire = clientSecretExpirySeconds > 0
96- const secretExpiryTime = clientsDoExpire ? clientIdIssuedAt + clientSecretExpirySeconds : 0
97- const clientSecretExpiresAt = isPublicClient ? undefined : secretExpiryTime
96+ // - undefined: omit client_secret_expires_at (no expiration)
97+ // - 0: set to 0 (no expiration per RFC 7591)
98+ // - positive number: set to now + seconds
99+ let clientSecretExpiresAt : number | undefined ;
100+ if ( ! isPublicClient ) {
101+ if ( clientSecretExpirySeconds !== undefined && clientSecretExpirySeconds > 0 ) {
102+ clientSecretExpiresAt = clientIdIssuedAt + clientSecretExpirySeconds ;
103+ } else if ( clientSecretExpirySeconds === 0 ) {
104+ clientSecretExpiresAt = 0 ;
105+ }
106+ // else: undefined - omit from response (no expiration)
107+ }
98108
99109 let clientInfo : Omit < OAuthClientInformationFull , "client_id" > & { client_id ?: string } = {
100110 ...clientMetadata ,
0 commit comments