@@ -8,7 +8,7 @@ import { it, expect } from '@effect/vitest';
88import { Micro } from 'effect' ;
99import { vi , afterEach } from 'vitest' ;
1010import * as sdkOidc from '@forgerock/sdk-oidc' ;
11- import { parAuthorizeµ , authorizeµ } from './authorize.request.js' ;
11+ import { createParAuthorizeUrlµ , authorizeµ } from './authorize.request.js' ;
1212import {
1313 toAuthorizationError ,
1414 isFetchBaseQueryError ,
@@ -128,12 +128,14 @@ it('toDispatchError delegates to toAuthorizationError for FetchBaseQueryError',
128128 } ) ;
129129} ) ;
130130
131- // ─── parAuthorizeµ ───────────────────────────────────────────────────────────
131+ // ─── createParAuthorizeUrlµ ───────────────────────────────────────────────────────────
132132
133- it . effect ( 'parAuthorizeµ fails with PAR_NOT_CONFIGURED when par endpoint is missing' , ( ) =>
133+ it . effect ( 'createParAuthorizeUrlµ fails with PAR_NOT_CONFIGURED when par endpoint is missing' , ( ) =>
134134 Micro . gen ( function * ( ) {
135135 const configWithPar : OidcConfig = { ...config , par : true } ;
136- const result = yield * Micro . exit ( parAuthorizeµ ( wellknown , configWithPar , mockLog , mockStore ) ) ;
136+ const result = yield * Micro . exit (
137+ createParAuthorizeUrlµ ( wellknown , configWithPar , mockLog , mockStore ) ,
138+ ) ;
137139 expect ( Micro . exitIsFailure ( result ) ) . toBe ( true ) ;
138140 if ( ! Micro . exitIsFailure ( result ) ) return ;
139141 expect ( Micro . causeIsFail ( result . cause ) ) . toBe ( true ) ;
@@ -147,7 +149,7 @@ it.effect('parAuthorizeµ fails with PAR_NOT_CONFIGURED when par endpoint is mis
147149 } ) ,
148150) ;
149151
150- it . effect ( 'parAuthorizeµ succeeds and returns slim authorize URL' , ( ) =>
152+ it . effect ( 'createParAuthorizeUrlµ succeeds and returns slim authorize URL' , ( ) =>
151153 Micro . gen ( function * ( ) {
152154 const configWithPar : OidcConfig = { ...config , par : true } ;
153155 const requestUri = 'urn:ietf:params:oauth:request_uri:abc123' ;
@@ -157,7 +159,7 @@ it.effect('parAuthorizeµ succeeds and returns slim authorize URL', () =>
157159 data : { request_uri : requestUri , expires_in : 60 } ,
158160 } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
159161
160- const url = yield * parAuthorizeµ ( wellknownWithPar , configWithPar , mockLog , mockStore ) ;
162+ const url = yield * createParAuthorizeUrlµ ( wellknownWithPar , configWithPar , mockLog , mockStore ) ;
161163
162164 expect ( url ) . toContain ( 'client_id=123456789' ) ;
163165 expect ( url ) . toContain ( `request_uri=${ encodeURIComponent ( requestUri ) } ` ) ;
@@ -167,7 +169,7 @@ it.effect('parAuthorizeµ succeeds and returns slim authorize URL', () =>
167169 } ) ,
168170) ;
169171
170- it . effect ( 'parAuthorizeµ fails with network_error when PAR POST returns error' , ( ) =>
172+ it . effect ( 'createParAuthorizeUrlµ fails with network_error when PAR POST returns error' , ( ) =>
171173 Micro . gen ( function * ( ) {
172174 const configWithPar : OidcConfig = { ...config , par : true } ;
173175
@@ -181,7 +183,7 @@ it.effect('parAuthorizeµ fails with network_error when PAR POST returns error',
181183 } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
182184
183185 const result = yield * Micro . exit (
184- parAuthorizeµ ( wellknownWithPar , configWithPar , mockLog , mockStore ) ,
186+ createParAuthorizeUrlµ ( wellknownWithPar , configWithPar , mockLog , mockStore ) ,
185187 ) ;
186188
187189 expect ( Micro . exitIsFailure ( result ) ) . toBe ( true ) ;
@@ -194,34 +196,36 @@ it.effect('parAuthorizeµ fails with network_error when PAR POST returns error',
194196 } ) ,
195197) ;
196198
197- it . effect ( 'parAuthorizeµ fails with network_error when PAR response is missing request_uri' , ( ) =>
198- Micro . gen ( function * ( ) {
199- const configWithPar : OidcConfig = { ...config , par : true } ;
200-
201- vi . stubGlobal ( 'sessionStorage' , sessionStorageStub ) ;
202- vi . mocked ( mockStore . dispatch ) . mockResolvedValueOnce ( {
203- data : { } ,
204- } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
199+ it . effect (
200+ 'createParAuthorizeUrlµ fails with network_error when PAR response is missing request_uri' ,
201+ ( ) =>
202+ Micro . gen ( function * ( ) {
203+ const configWithPar : OidcConfig = { ...config , par : true } ;
205204
206- const result = yield * Micro . exit (
207- parAuthorizeµ ( wellknownWithPar , configWithPar , mockLog , mockStore ) ,
208- ) ;
205+ vi . stubGlobal ( 'sessionStorage' , sessionStorageStub ) ;
206+ vi . mocked ( mockStore . dispatch ) . mockResolvedValueOnce ( {
207+ data : { } ,
208+ } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
209209
210- expect ( Micro . exitIsFailure ( result ) ) . toBe ( true ) ;
211- if ( ! Micro . exitIsFailure ( result ) ) return ;
212- expect ( Micro . causeIsFail ( result . cause ) ) . toBe ( true ) ;
213- if ( Micro . causeIsFail ( result . cause ) ) {
214- expect ( result . cause . error . type ) . toBe ( 'network_error' ) ;
215- expect ( result . cause . error . error_description ) . toBe (
216- "PAR response missing required 'request_uri' field" ,
210+ const result = yield * Micro . exit (
211+ createParAuthorizeUrlµ ( wellknownWithPar , configWithPar , mockLog , mockStore ) ,
217212 ) ;
218- }
219- expect ( sessionStorageStub . setItem ) . not . toHaveBeenCalled ( ) ;
220- } ) ,
213+
214+ expect ( Micro . exitIsFailure ( result ) ) . toBe ( true ) ;
215+ if ( ! Micro . exitIsFailure ( result ) ) return ;
216+ expect ( Micro . causeIsFail ( result . cause ) ) . toBe ( true ) ;
217+ if ( Micro . causeIsFail ( result . cause ) ) {
218+ expect ( result . cause . error . type ) . toBe ( 'network_error' ) ;
219+ expect ( result . cause . error . error_description ) . toBe (
220+ "PAR response missing required 'request_uri' field" ,
221+ ) ;
222+ }
223+ expect ( sessionStorageStub . setItem ) . not . toHaveBeenCalled ( ) ;
224+ } ) ,
221225) ;
222226
223227it . effect (
224- 'parAuthorizeµ with prompt=none includes prompt on slim authorize URL and in PAR body' ,
228+ 'createParAuthorizeUrlµ with prompt=none includes prompt on slim authorize URL and in PAR body' ,
225229 ( ) =>
226230 Micro . gen ( function * ( ) {
227231 const configWithPar : OidcConfig = { ...config , par : true } ;
@@ -235,9 +239,15 @@ it.effect(
235239 data : { request_uri : requestUri , expires_in : 60 } ,
236240 } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
237241
238- const url = yield * parAuthorizeµ ( wellknownWithPar , configWithPar , mockLog , mockStore , {
239- prompt : 'none' ,
240- } ) ;
242+ const url = yield * createParAuthorizeUrlµ (
243+ wellknownWithPar ,
244+ configWithPar ,
245+ mockLog ,
246+ mockStore ,
247+ {
248+ prompt : 'none' ,
249+ } ,
250+ ) ;
241251
242252 expect ( url ) . toContain ( 'prompt=none' ) ;
243253 const parBodyArg = buildParamsSpy . mock . calls [ 0 ] [ 0 ] as unknown as Record < string , unknown > ;
0 commit comments