66 */
77import { describe , expectTypeOf , it } from 'vitest' ;
88import type { DaVinciConfig , InternalDaVinciConfig } from './config.types.js' ;
9- import type { AsyncLegacyConfigOptions } from '@forgerock/sdk-types' ;
10- import type { WellknownResponse } from './wellknown.types.js' ;
9+ import type { AsyncLegacyConfigOptions , WellknownResponse } from '@forgerock/sdk-types' ;
1110
1211describe ( 'Config Types' , ( ) => {
1312 describe ( 'DaVinciConfig' , ( ) => {
@@ -51,30 +50,9 @@ describe('Config Types', () => {
5150 authorization_endpoint : 'https://example.com/auth' ,
5251 token_endpoint : 'https://example.com/token' ,
5352 userinfo_endpoint : 'https://example.com/userinfo' ,
54- jwks_uri : 'https://example.com/jwks' ,
55- revocation_endpoint : 'https://example.com/register' ,
5653 end_session_endpoint : 'https://example.com/logout' ,
57- pushed_authorization_request_endpoint : '' ,
58- check_session_iframe : '' ,
59- introspection_endpoint : '' ,
60- device_authorization_endpoint : '' ,
61- claims_parameter_supported : '' ,
62- request_parameter_supported : '' ,
63- request_uri_parameter_supported : '' ,
64- require_pushed_authorization_requests : '' ,
65- scopes_supported : [ ] ,
66- response_types_supported : [ ] ,
67- response_modes_supported : [ ] ,
68- grant_types_supported : [ ] ,
69- subject_types_supported : [ ] ,
70- id_token_signing_alg_values_supported : [ ] ,
71- userinfo_signing_alg_values_supported : [ ] ,
72- request_object_signing_alg_values_supported : [ ] ,
73- token_endpoint_auth_methods_supported : [ ] ,
74- token_endpoint_auth_signing_alg_values_supported : [ ] ,
75- claim_types_supported : [ ] ,
76- claims_supported : [ ] ,
77- code_challenge_methods_supported : [ ] ,
54+ introspection_endpoint : 'https://example.com/introspect' ,
55+ revocation_endpoint : 'https://example.com/revoke' ,
7856 } ,
7957 responseType : 'code' ,
8058 serverConfig : { } ,
@@ -85,7 +63,6 @@ describe('Config Types', () => {
8563
8664 it ( 'should combine DaVinciConfig and wellknownResponse' , ( ) => {
8765 const config : InternalDaVinciConfig = {
88- // DaVinciConfig properties
8966 clientId : 'test-client' ,
9067 scope : 'openid profile' ,
9168 serverConfig : {
@@ -94,36 +71,16 @@ describe('Config Types', () => {
9471 } ,
9572 redirectUri : 'https://app.example.com/callback' ,
9673 responseType : 'code' ,
97- // InternalDaVinciConfig specific property
9874 wellknownResponse : {
9975 issuer : 'https://example.com' ,
10076 authorization_endpoint : 'https://example.com/auth' ,
10177 token_endpoint : 'https://example.com/token' ,
10278 userinfo_endpoint : 'https://example.com/userinfo' ,
103- jwks_uri : 'https://example.com/jwks' ,
104- revocation_endpoint : 'https://example.com/revoke' ,
10579 end_session_endpoint : 'https://example.com/logout' ,
106- pushed_authorization_request_endpoint : '' ,
107- check_session_iframe : '' ,
108- introspection_endpoint : '' ,
109- device_authorization_endpoint : '' ,
110- claims_parameter_supported : '' ,
111- request_parameter_supported : '' ,
112- request_uri_parameter_supported : '' ,
113- require_pushed_authorization_requests : '' ,
114- scopes_supported : [ ] ,
115- response_types_supported : [ ] ,
116- response_modes_supported : [ ] ,
117- grant_types_supported : [ ] ,
118- subject_types_supported : [ ] ,
119- id_token_signing_alg_values_supported : [ ] ,
120- userinfo_signing_alg_values_supported : [ ] ,
121- request_object_signing_alg_values_supported : [ ] ,
122- token_endpoint_auth_methods_supported : [ ] ,
123- token_endpoint_auth_signing_alg_values_supported : [ ] ,
124- claim_types_supported : [ ] ,
125- claims_supported : [ ] ,
126- code_challenge_methods_supported : [ ] ,
80+ introspection_endpoint : 'https://example.com/introspect' ,
81+ revocation_endpoint : 'https://example.com/revoke' ,
82+ jwks_uri : 'https://example.com/jwks' ,
83+ scopes_supported : [ 'openid' , 'profile' ] ,
12784 } ,
12885 } ;
12986 expectTypeOf ( config ) . toMatchTypeOf < InternalDaVinciConfig > ( ) ;
@@ -132,45 +89,24 @@ describe('Config Types', () => {
13289} ) ;
13390
13491describe ( 'WellknownResponse' , ( ) => {
135- it ( 'should have all required OIDC properties' , ( ) => {
92+ it ( 'should have required OIDC properties' , ( ) => {
13693 const wellknown : WellknownResponse = {
13794 issuer : 'https://example.com' ,
13895 authorization_endpoint : 'https://example.com/auth' ,
13996 token_endpoint : 'https://example.com/token' ,
14097 userinfo_endpoint : 'https://example.com/userinfo' ,
141- jwks_uri : 'https://example.com/jwks' ,
142- revocation_endpoint : 'https://example.com/revoke' ,
14398 end_session_endpoint : 'https://example.com/logout' ,
144- pushed_authorization_request_endpoint : '' ,
145- check_session_iframe : '' ,
146- introspection_endpoint : '' ,
147- device_authorization_endpoint : '' ,
148- claims_parameter_supported : '' ,
149- request_parameter_supported : '' ,
150- request_uri_parameter_supported : '' ,
151- require_pushed_authorization_requests : '' ,
152- scopes_supported : [ ] ,
153- response_types_supported : [ ] ,
154- response_modes_supported : [ ] ,
155- grant_types_supported : [ ] ,
156- subject_types_supported : [ ] ,
157- id_token_signing_alg_values_supported : [ ] ,
158- userinfo_signing_alg_values_supported : [ ] ,
159- request_object_signing_alg_values_supported : [ ] ,
160- token_endpoint_auth_methods_supported : [ ] ,
161- token_endpoint_auth_signing_alg_values_supported : [ ] ,
162- claim_types_supported : [ ] ,
163- claims_supported : [ ] ,
164- code_challenge_methods_supported : [ ] ,
99+ introspection_endpoint : 'https://example.com/introspect' ,
100+ revocation_endpoint : 'https://example.com/revoke' ,
165101 } ;
166102
167103 expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'issuer' ) . toBeString ( ) ;
168104 expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'authorization_endpoint' ) . toBeString ( ) ;
169105 expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'token_endpoint' ) . toBeString ( ) ;
170106 expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'userinfo_endpoint' ) . toBeString ( ) ;
171- expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'jwks_uri' ) . toBeString ( ) ;
172- expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'revocation_endpoint' ) . toBeString ( ) ;
173107 expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'end_session_endpoint' ) . toBeString ( ) ;
108+ expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'introspection_endpoint' ) . toBeString ( ) ;
109+ expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'revocation_endpoint' ) . toBeString ( ) ;
174110
175111 expectTypeOf ( wellknown ) . toMatchTypeOf < WellknownResponse > ( ) ;
176112 } ) ;
@@ -181,93 +117,58 @@ describe('WellknownResponse', () => {
181117 authorization_endpoint : 'https://example.com/auth' ,
182118 token_endpoint : 'https://example.com/token' ,
183119 userinfo_endpoint : 'https://example.com/userinfo' ,
184- jwks_uri : 'https://example.com/jwks' ,
185- revocation_endpoint : 'https://example.com/revoke' ,
186120 end_session_endpoint : 'https://example.com/logout' ,
187- // Optional properties
121+ introspection_endpoint : 'https://example.com/introspect' ,
122+ revocation_endpoint : 'https://example.com/revoke' ,
123+ jwks_uri : 'https://example.com/jwks' ,
188124 scopes_supported : [ 'openid' , 'profile' , 'email' ] ,
189125 response_types_supported : [ 'code' , 'token' ] ,
190126 grant_types_supported : [ 'authorization_code' , 'refresh_token' ] ,
191127 subject_types_supported : [ 'public' ] ,
192128 id_token_signing_alg_values_supported : [ 'RS256' ] ,
193129 token_endpoint_auth_methods_supported : [ 'client_secret_basic' ] ,
194- pushed_authorization_request_endpoint : '' ,
195- check_session_iframe : '' ,
196- introspection_endpoint : '' ,
197- device_authorization_endpoint : '' ,
198- claims_parameter_supported : '' ,
199- request_parameter_supported : '' ,
200- request_uri_parameter_supported : '' ,
201- require_pushed_authorization_requests : '' ,
202- response_modes_supported : [ ] ,
203- userinfo_signing_alg_values_supported : [ ] ,
204- request_object_signing_alg_values_supported : [ ] ,
205- token_endpoint_auth_signing_alg_values_supported : [ ] ,
206- claim_types_supported : [ ] ,
207- claims_supported : [ ] ,
208- code_challenge_methods_supported : [ ] ,
209130 } ;
210131
211- // Test optional properties are allowed but not required
212132 expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'scopes_supported' ) ;
213133 expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'response_types_supported' ) ;
214134 expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'grant_types_supported' ) ;
135+ expectTypeOf < WellknownResponse > ( ) . toHaveProperty ( 'jwks_uri' ) ;
215136
216137 expectTypeOf ( wellknownWithOptionals ) . toMatchTypeOf < WellknownResponse > ( ) ;
217138 } ) ;
218139
219- it ( 'should validate property types' , ( ) => {
220- // Test that array properties must contain strings
221- expectTypeOf < WellknownResponse [ 'scopes_supported' ] > ( ) . toEqualTypeOf < string [ ] > ( ) ;
222- expectTypeOf < WellknownResponse [ 'response_types_supported' ] > ( ) . toEqualTypeOf < string [ ] > ( ) ;
223- expectTypeOf < WellknownResponse [ 'grant_types_supported' ] > ( ) . toEqualTypeOf < string [ ] > ( ) ;
224- expectTypeOf < WellknownResponse [ 'subject_types_supported' ] > ( ) . toEqualTypeOf < string [ ] > ( ) ;
140+ it ( 'should validate optional array property types' , ( ) => {
141+ expectTypeOf < WellknownResponse [ 'scopes_supported' ] > ( ) . toEqualTypeOf < string [ ] | undefined > ( ) ;
142+ expectTypeOf < WellknownResponse [ 'response_types_supported' ] > ( ) . toEqualTypeOf <
143+ string [ ] | undefined
144+ > ( ) ;
145+ expectTypeOf < WellknownResponse [ 'grant_types_supported' ] > ( ) . toEqualTypeOf <
146+ string [ ] | undefined
147+ > ( ) ;
148+ expectTypeOf < WellknownResponse [ 'subject_types_supported' ] > ( ) . toEqualTypeOf <
149+ string [ ] | undefined
150+ > ( ) ;
225151 expectTypeOf < WellknownResponse [ 'id_token_signing_alg_values_supported' ] > ( ) . toEqualTypeOf <
226- string [ ]
152+ string [ ] | undefined
227153 > ( ) ;
228154 expectTypeOf < WellknownResponse [ 'token_endpoint_auth_methods_supported' ] > ( ) . toEqualTypeOf <
229- string [ ]
155+ string [ ] | undefined
230156 > ( ) ;
231157 } ) ;
232158
233- it ( 'should enforce URL format for endpoint properties' , ( ) => {
159+ it ( 'should enforce URL format for required endpoint properties' , ( ) => {
234160 const wellknown : WellknownResponse = {
235161 issuer : 'https://example.com' ,
236162 authorization_endpoint : 'https://example.com/auth' ,
237163 token_endpoint : 'https://example.com/token' ,
238164 userinfo_endpoint : 'https://example.com/userinfo' ,
239- jwks_uri : 'https://example.com/jwks' ,
240- revocation_endpoint : 'https://example.com/register' ,
241165 end_session_endpoint : 'https://example.com/logout' ,
242- pushed_authorization_request_endpoint : '' ,
243- check_session_iframe : '' ,
244- introspection_endpoint : '' ,
245- device_authorization_endpoint : '' ,
246- claims_parameter_supported : '' ,
247- request_parameter_supported : '' ,
248- request_uri_parameter_supported : '' ,
249- require_pushed_authorization_requests : '' ,
250- scopes_supported : [ ] ,
251- response_types_supported : [ ] ,
252- response_modes_supported : [ ] ,
253- grant_types_supported : [ ] ,
254- subject_types_supported : [ ] ,
255- id_token_signing_alg_values_supported : [ ] ,
256- userinfo_signing_alg_values_supported : [ ] ,
257- request_object_signing_alg_values_supported : [ ] ,
258- token_endpoint_auth_methods_supported : [ ] ,
259- token_endpoint_auth_signing_alg_values_supported : [ ] ,
260- claim_types_supported : [ ] ,
261- claims_supported : [ ] ,
262- code_challenge_methods_supported : [ ] ,
166+ introspection_endpoint : 'https://example.com/introspect' ,
167+ revocation_endpoint : 'https://example.com/revoke' ,
263168 } ;
264169
265- // Type assertion to ensure all endpoint properties are strings (URLs)
266170 expectTypeOf ( wellknown . authorization_endpoint ) . toBeString ( ) ;
267171 expectTypeOf ( wellknown . token_endpoint ) . toBeString ( ) ;
268172 expectTypeOf ( wellknown . userinfo_endpoint ) . toBeString ( ) ;
269- expectTypeOf ( wellknown . jwks_uri ) . toBeString ( ) ;
270- expectTypeOf ( wellknown . revocation_endpoint ) . toBeString ( ) ;
271- expectTypeOf ( wellknown . end_session_endpoint ) . toBeString ( ) ;
272173 } ) ;
273174} ) ;
0 commit comments