Skip to content

Commit 65c91fa

Browse files
committed
refactor(oidc-client): complete rename of parAuthorizeµ to createParAuthorizeUrlµ
Update all remaining touchpoints: JSDoc @function tag, test section header, and test description strings. Fix Prettier formatting for longer call sites.
1 parent f3bf912 commit 65c91fa

3 files changed

Lines changed: 48 additions & 38 deletions

File tree

packages/oidc-client/src/lib/authorize.request.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function dispatchAuthorizeµ(
5959
// ─── PAR flow ─────────────────────────────────────────────────────────────────
6060

6161
/**
62-
* @function parAuthorizeµ
62+
* @function createParAuthorizeUrlµ
6363
* @description Pushed Authorization Request (RFC 9126): POSTs all authorize
6464
* parameters to the PAR endpoint, then returns a slim URL containing only
6565
* `client_id` and `request_uri` — keeping sensitive params out of the
@@ -75,7 +75,7 @@ function dispatchAuthorizeµ(
7575
* @returns A `Micro` that resolves to the slim authorize URL string or
7676
* fails with a typed `AuthorizationError`.
7777
*/
78-
export function parAuthorizeµ(
78+
export function createParAuthorizeUrlµ(
7979
wellknown: WellknownResponse,
8080
config: OidcConfig,
8181
log: CustomLogger,
@@ -160,7 +160,7 @@ export function authorizeµ(
160160
...options,
161161
};
162162

163-
const parFlow = parAuthorizeµ(wellknown, config, log, store, options).pipe(
163+
const parFlow = createParAuthorizeUrlµ(wellknown, config, log, store, options).pipe(
164164
Micro.tap((url) => log.debug('PAR authorize URL created', url)),
165165
Micro.tapError((err) =>
166166
Micro.sync(() => log.error(`PAR authorize failed [${err.type}]: ${err.error}`, err)),

packages/oidc-client/src/lib/authorize.request.utils.test.ts

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { it, expect } from '@effect/vitest';
88
import { Micro } from 'effect';
99
import { vi, afterEach } from 'vitest';
1010
import * as sdkOidc from '@forgerock/sdk-oidc';
11-
import { parAuthorizeµ, authorizeµ } from './authorize.request.js';
11+
import { createParAuthorizeUrlµ, authorizeµ } from './authorize.request.js';
1212
import {
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

223227
it.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>;

packages/oidc-client/src/lib/client.store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { createStorage } from '@forgerock/storage';
1010
import { Micro } from 'effect';
1111
import { causeIsDie, exitIsFail, exitIsSuccess } from 'effect/Micro';
1212

13-
import { authorizeµ, parAuthorizeµ } from './authorize.request.js';
13+
import { authorizeµ, createParAuthorizeUrlµ } from './authorize.request.js';
1414
import { buildTokenExchangeµ } from './exchange.request.js';
1515
import { createClientStore, createTokenError } from './client.store.utils.js';
1616
import { oidcApi } from './oidc.api.js';
@@ -132,7 +132,7 @@ export async function oidc<ActionType extends ActionTypes = ActionTypes>({
132132

133133
if (useParFlow) {
134134
const result = await Micro.runPromiseExit(
135-
parAuthorizeµ(wellknown, config, log, store, options).pipe(
135+
createParAuthorizeUrlµ(wellknown, config, log, store, options).pipe(
136136
Micro.tapError((err) =>
137137
Micro.sync(() =>
138138
log.error(`PAR authorize.url() failed [${err.type}]: ${err.error}`, err),

0 commit comments

Comments
 (0)