@@ -10,21 +10,19 @@ import { vi, afterEach } from 'vitest';
1010import * as sdkOidc from '@forgerock/sdk-oidc' ;
1111import * as sdkUtilities from '@forgerock/sdk-utilities' ;
1212
13- import {
14- generateAuthValues ,
15- generatePkceChallenge ,
16- storeAuthOptions ,
17- } from './authorize.request.effects.js' ;
1813import {
1914 buildParBody ,
2015 validateParResponse ,
2116 handleDispatchError ,
2217 createAuthorizeUrlMicro ,
2318} from './authorize.request.utils.js' ;
2419import {
25- buildParSlimUrl ,
26- dispatchAuthorizeFetch ,
27- dispatchAuthorizeIframe ,
20+ buildParSlimUrlµ ,
21+ dispatchAuthorizeFetchµ ,
22+ dispatchAuthorizeIframeµ ,
23+ generateAuthValuesµ ,
24+ generatePkceChallengeµ ,
25+ storeAuthOptionsµ ,
2826} from './authorize.request.micros.js' ;
2927
3028import type { OidcConfig } from './config.types.js' ;
@@ -62,12 +60,12 @@ afterEach(() => {
6260 vi . restoreAllMocks ( ) ;
6361} ) ;
6462
65- // ─── generateAuthValues ───────────────────────────────────────────────────────
63+ // ─── generateAuthValuesµ ───────────────────────────────────────────────────────
6664
67- it . effect ( 'generateAuthValues returns auth URL options and store function' , ( ) =>
65+ it . effect ( 'generateAuthValuesµ returns auth URL options and store function' , ( ) =>
6866 Micro . gen ( function * ( ) {
6967 vi . stubGlobal ( 'sessionStorage' , sessionStorageStub ) ;
70- const result = yield * generateAuthValues ( config , wellknown ) ;
68+ const result = yield * generateAuthValuesµ ( config , wellknown ) ;
7169 const [ opts , storeFn ] = result ;
7270 expect ( opts . clientId ) . toBe ( clientId ) ;
7371 expect ( typeof opts . state ) . toBe ( 'string' ) ;
@@ -76,39 +74,39 @@ it.effect('generateAuthValues returns auth URL options and store function', () =
7674 } ) ,
7775) ;
7876
79- it . effect ( 'generateAuthValues fails with auth_error when sessionStorage throws' , ( ) =>
77+ it . effect ( 'generateAuthValuesµ fails with auth_error when sessionStorage throws' , ( ) =>
8078 Micro . gen ( function * ( ) {
8179 vi . spyOn ( sdkOidc , 'generateAndStoreAuthUrlValues' ) . mockImplementation ( ( ) => {
8280 throw new Error ( 'storage unavailable' ) ;
8381 } ) ;
84- const exit = yield * Micro . exit ( generateAuthValues ( config , wellknown ) ) ;
82+ const exit = yield * Micro . exit ( generateAuthValuesµ ( config , wellknown ) ) ;
8583 expect ( Micro . exitIsFailure ( exit ) ) . toBe ( true ) ;
8684 if ( ! Micro . exitIsFailure ( exit ) || ! Micro . causeIsFail ( exit . cause ) ) return ;
8785 expect ( exit . cause . error . type ) . toBe ( 'auth_error' ) ;
8886 expect ( exit . cause . error . error ) . toBe ( 'PAR_PARAM_BUILD_ERROR' ) ;
8987 } ) ,
9088) ;
9189
92- // ─── generatePkceChallenge ────────────────────────────────────────────────────
90+ // ─── generatePkceChallengeµ ────────────────────────────────────────────────────
9391
94- it . effect ( 'generatePkceChallenge returns a non-empty challenge string' , ( ) =>
92+ it . effect ( 'generatePkceChallengeµ returns a non-empty challenge string' , ( ) =>
9593 Micro . gen ( function * ( ) {
9694 vi . stubGlobal ( 'crypto' , {
9795 subtle : {
9896 digest : vi . fn ( ) . mockResolvedValue ( new ArrayBuffer ( 32 ) ) ,
9997 } ,
10098 getRandomValues : vi . fn ( ( arr : Uint8Array ) => arr . fill ( 1 ) ) ,
10199 } ) ;
102- const challenge = yield * generatePkceChallenge ( 'test-verifier' ) ;
100+ const challenge = yield * generatePkceChallengeµ ( 'test-verifier' ) ;
103101 expect ( typeof challenge ) . toBe ( 'string' ) ;
104102 expect ( challenge . length ) . toBeGreaterThan ( 0 ) ;
105103 } ) ,
106104) ;
107105
108- it . effect ( 'generatePkceChallenge fails with auth_error when createChallenge throws' , ( ) =>
106+ it . effect ( 'generatePkceChallengeµ fails with auth_error when createChallenge throws' , ( ) =>
109107 Micro . gen ( function * ( ) {
110108 vi . spyOn ( sdkUtilities , 'createChallenge' ) . mockRejectedValue ( new Error ( 'crypto unavailable' ) ) ;
111- const exit = yield * Micro . exit ( generatePkceChallenge ( 'bad-verifier' ) ) ;
109+ const exit = yield * Micro . exit ( generatePkceChallengeµ ( 'bad-verifier' ) ) ;
112110 expect ( Micro . exitIsFailure ( exit ) ) . toBe ( true ) ;
113111 if ( ! Micro . exitIsFailure ( exit ) || ! Micro . causeIsFail ( exit . cause ) ) return ;
114112 expect ( exit . cause . error . type ) . toBe ( 'auth_error' ) ;
@@ -149,11 +147,11 @@ it.effect('buildParBody fails with auth_error when buildAuthorizeParams throws',
149147 } ) ,
150148) ;
151149
152- // ─── buildParSlimUrl ──────────────────────────────────────────────────────────
150+ // ─── buildParSlimUrlµ ──────────────────────────────────────────────────────────
153151
154- it . effect ( 'buildParSlimUrl returns URL with only client_id and request_uri' , ( ) =>
152+ it . effect ( 'buildParSlimUrlµ returns URL with only client_id and request_uri' , ( ) =>
155153 Micro . gen ( function * ( ) {
156- const url = yield * buildParSlimUrl (
154+ const url = yield * buildParSlimUrlµ (
157155 wellknown . authorization_endpoint ,
158156 clientId ,
159157 'urn:ietf:params:oauth:request_uri:abc123' ,
@@ -165,9 +163,9 @@ it.effect('buildParSlimUrl returns URL with only client_id and request_uri', ()
165163 } ) ,
166164) ;
167165
168- it . effect ( 'buildParSlimUrl includes prompt when provided' , ( ) =>
166+ it . effect ( 'buildParSlimUrlµ includes prompt when provided' , ( ) =>
169167 Micro . gen ( function * ( ) {
170- const url = yield * buildParSlimUrl (
168+ const url = yield * buildParSlimUrlµ (
171169 wellknown . authorization_endpoint ,
172170 clientId ,
173171 'urn:ietf:params:oauth:request_uri:abc123' ,
@@ -177,20 +175,20 @@ it.effect('buildParSlimUrl includes prompt when provided', () =>
177175 } ) ,
178176) ;
179177
180- // ─── storeAuthOptions ─────────────────────────────────────────────────────────
178+ // ─── storeAuthOptionsµ ─────────────────────────────────────────────────────────
181179
182- it . effect ( 'storeAuthOptions calls the provided store function' , ( ) =>
180+ it . effect ( 'storeAuthOptionsµ calls the provided store function' , ( ) =>
183181 Micro . gen ( function * ( ) {
184182 const storeFn = vi . fn ( ) ;
185- yield * storeAuthOptions ( storeFn ) ;
183+ yield * storeAuthOptionsµ ( storeFn ) ;
186184 expect ( storeFn ) . toHaveBeenCalledOnce ( ) ;
187185 } ) ,
188186) ;
189187
190- it . effect ( 'storeAuthOptions fails with unknown_error when store function throws' , ( ) =>
188+ it . effect ( 'storeAuthOptionsµ fails with unknown_error when store function throws' , ( ) =>
191189 Micro . gen ( function * ( ) {
192190 const exit = yield * Micro . exit (
193- storeAuthOptions ( ( ) => {
191+ storeAuthOptionsµ ( ( ) => {
194192 throw new Error ( 'storage write failed' ) ;
195193 } ) ,
196194 ) ;
@@ -329,16 +327,16 @@ it.effect('handleDispatchError builds redirect URL for non-config errors', () =>
329327 } ) ,
330328) ;
331329
332- // ─── dispatchAuthorizeFetch ───────────────────────────────────────────────────
330+ // ─── dispatchAuthorizeFetchµ ───────────────────────────────────────────────────
333331
334- it . effect ( 'dispatchAuthorizeFetch succeeds with authorizeResponse' , ( ) =>
332+ it . effect ( 'dispatchAuthorizeFetchµ succeeds with authorizeResponse' , ( ) =>
335333 Micro . gen ( function * ( ) {
336334 const authorizeResponse = { code : 'auth-code-abc' , state : 'state-xyz' } ;
337335 vi . mocked ( mockStore . dispatch ) . mockResolvedValueOnce ( {
338336 data : { authorizeResponse } ,
339337 } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
340338
341- const result = yield * dispatchAuthorizeFetch (
339+ const result = yield * dispatchAuthorizeFetchµ (
342340 mockStore ,
343341 'https://example.com/authorize?request_uri=...' ,
344342 wellknown ,
@@ -349,15 +347,15 @@ it.effect('dispatchAuthorizeFetch succeeds with authorizeResponse', () =>
349347) ;
350348
351349it . effect (
352- 'dispatchAuthorizeFetch fails with unknown_error when data has no authorizeResponse' ,
350+ 'dispatchAuthorizeFetchµ fails with unknown_error when data has no authorizeResponse' ,
353351 ( ) =>
354352 Micro . gen ( function * ( ) {
355353 vi . mocked ( mockStore . dispatch ) . mockResolvedValueOnce ( {
356354 data : { } ,
357355 } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
358356
359357 const exit = yield * Micro . exit (
360- dispatchAuthorizeFetch ( mockStore , 'https://example.com/authorize' , wellknown , {
358+ dispatchAuthorizeFetchµ ( mockStore , 'https://example.com/authorize' , wellknown , {
361359 clientId,
362360 redirectUri,
363361 scope,
@@ -370,16 +368,16 @@ it.effect(
370368 } ) ,
371369) ;
372370
373- // ─── dispatchAuthorizeIframe ──────────────────────────────────────────────────
371+ // ─── dispatchAuthorizeIframeµ ──────────────────────────────────────────────────
374372
375- it . effect ( 'dispatchAuthorizeIframe succeeds with iframe data' , ( ) =>
373+ it . effect ( 'dispatchAuthorizeIframeµ succeeds with iframe data' , ( ) =>
376374 Micro . gen ( function * ( ) {
377375 const iframeData = { code : 'iframe-code' , state : 'state-abc' } ;
378376 vi . mocked ( mockStore . dispatch ) . mockResolvedValueOnce ( {
379377 data : iframeData ,
380378 } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
381379
382- const result = yield * dispatchAuthorizeIframe (
380+ const result = yield * dispatchAuthorizeIframeµ (
383381 mockStore ,
384382 'https://example.com/authorize' ,
385383 wellknown ,
@@ -389,14 +387,14 @@ it.effect('dispatchAuthorizeIframe succeeds with iframe data', () =>
389387 } ) ,
390388) ;
391389
392- it . effect ( 'dispatchAuthorizeIframe fails with unknown_error when data is undefined' , ( ) =>
390+ it . effect ( 'dispatchAuthorizeIframeµ fails with unknown_error when data is undefined' , ( ) =>
393391 Micro . gen ( function * ( ) {
394392 vi . mocked ( mockStore . dispatch ) . mockResolvedValueOnce ( {
395393 data : undefined ,
396394 } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
397395
398396 const exit = yield * Micro . exit (
399- dispatchAuthorizeIframe ( mockStore , 'https://example.com/authorize' , wellknown , {
397+ dispatchAuthorizeIframeµ ( mockStore , 'https://example.com/authorize' , wellknown , {
400398 clientId,
401399 redirectUri,
402400 scope,
@@ -409,14 +407,14 @@ it.effect('dispatchAuthorizeIframe fails with unknown_error when data is undefin
409407 } ) ,
410408) ;
411409
412- it . effect ( 'dispatchAuthorizeIframe fails with unknown_error when data has no code or state' , ( ) =>
410+ it . effect ( 'dispatchAuthorizeIframeµ fails with unknown_error when data has no code or state' , ( ) =>
413411 Micro . gen ( function * ( ) {
414412 vi . mocked ( mockStore . dispatch ) . mockResolvedValueOnce ( {
415413 data : { unexpected : 'shape' } ,
416414 } as unknown as ReturnType < typeof mockStore . dispatch > ) ;
417415
418416 const exit = yield * Micro . exit (
419- dispatchAuthorizeIframe (
417+ dispatchAuthorizeIframeµ (
420418 mockStore ,
421419 'https://example.com/authorize?foo=bar' ,
422420 wellknown ,
0 commit comments