Skip to content

Commit e81b87e

Browse files
committed
refactor(oidc-client): finalize authorize.request layer split — remove bridge re-exports
1 parent d8cdecf commit e81b87e

8 files changed

Lines changed: 1015 additions & 295 deletions

packages/davinci-client/api-report/davinci-client.api.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,13 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
277277
resume: (input: {
278278
continueToken: string;
279279
}) => Promise<InternalErrorResponse | NodeStates>;
280-
start: <QueryParams extends OutgoingQueryParams = OutgoingQueryParams>(options?: StartOptions<QueryParams> | undefined) => Promise<ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode>;
280+
start: <QueryParams extends OutgoingQueryParams = OutgoingQueryParams>(options?: StartOptions<QueryParams> | undefined) => Promise<ContinueNode | ErrorNode | StartNode | SuccessNode | FailureNode>;
281281
update: <T extends SingleValueCollectors | MultiSelectCollector | ObjectValueCollectors | AutoCollectors>(collector: T) => Updater<T>;
282282
validate: (collector: SingleValueCollectors | ObjectValueCollectors | MultiValueCollectors | AutoCollectors) => Validator;
283283
pollStatus: (collector: PollingCollector) => Poller;
284284
getClient: () => {
285+
status: "start";
286+
} | {
285287
action: string;
286288
collectors: Collectors[];
287289
description?: string;
@@ -293,21 +295,19 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
293295
description?: string;
294296
name?: string;
295297
status: "error";
296-
} | {
297-
status: "failure";
298-
} | {
299-
status: "start";
300298
} | {
301299
authorization?: {
302300
code?: string;
303301
state?: string;
304302
};
305303
status: "success";
304+
} | {
305+
status: "failure";
306306
} | null;
307307
getCollectors: () => Collectors[];
308308
getError: () => DaVinciError | null;
309309
getErrorCollectors: () => CollectorErrors[];
310-
getNode: () => ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode;
310+
getNode: () => ContinueNode | ErrorNode | StartNode | SuccessNode | FailureNode;
311311
getServer: () => {
312312
_links?: Links;
313313
id?: string;
@@ -316,6 +316,8 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
316316
href?: string;
317317
eventName?: string;
318318
status: "continue";
319+
} | {
320+
status: "start";
319321
} | {
320322
_links?: Links;
321323
eventName?: string;
@@ -326,22 +328,20 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
326328
} | {
327329
_links?: Links;
328330
eventName?: string;
329-
href?: string;
330331
id?: string;
331332
interactionId?: string;
332333
interactionToken?: string;
333-
status: "failure";
334-
} | {
335-
status: "start";
334+
href?: string;
335+
session?: string;
336+
status: "success";
336337
} | {
337338
_links?: Links;
338339
eventName?: string;
340+
href?: string;
339341
id?: string;
340342
interactionId?: string;
341343
interactionToken?: string;
342-
href?: string;
343-
session?: string;
344-
status: "success";
344+
status: "failure";
345345
} | null;
346346
cache: {
347347
getLatestResponse: () => ((state: RootState< {

packages/davinci-client/api-report/davinci-client.types.api.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,13 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
277277
resume: (input: {
278278
continueToken: string;
279279
}) => Promise<InternalErrorResponse | NodeStates>;
280-
start: <QueryParams extends OutgoingQueryParams = OutgoingQueryParams>(options?: StartOptions<QueryParams> | undefined) => Promise<ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode>;
280+
start: <QueryParams extends OutgoingQueryParams = OutgoingQueryParams>(options?: StartOptions<QueryParams> | undefined) => Promise<ContinueNode | ErrorNode | StartNode | SuccessNode | FailureNode>;
281281
update: <T extends SingleValueCollectors | MultiSelectCollector | ObjectValueCollectors | AutoCollectors>(collector: T) => Updater<T>;
282282
validate: (collector: SingleValueCollectors | ObjectValueCollectors | MultiValueCollectors | AutoCollectors) => Validator;
283283
pollStatus: (collector: PollingCollector) => Poller;
284284
getClient: () => {
285+
status: "start";
286+
} | {
285287
action: string;
286288
collectors: Collectors[];
287289
description?: string;
@@ -293,21 +295,19 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
293295
description?: string;
294296
name?: string;
295297
status: "error";
296-
} | {
297-
status: "failure";
298-
} | {
299-
status: "start";
300298
} | {
301299
authorization?: {
302300
code?: string;
303301
state?: string;
304302
};
305303
status: "success";
304+
} | {
305+
status: "failure";
306306
} | null;
307307
getCollectors: () => Collectors[];
308308
getError: () => DaVinciError | null;
309309
getErrorCollectors: () => CollectorErrors[];
310-
getNode: () => ContinueNode | ErrorNode | FailureNode | StartNode | SuccessNode;
310+
getNode: () => ContinueNode | ErrorNode | StartNode | SuccessNode | FailureNode;
311311
getServer: () => {
312312
_links?: Links;
313313
id?: string;
@@ -316,6 +316,8 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
316316
href?: string;
317317
eventName?: string;
318318
status: "continue";
319+
} | {
320+
status: "start";
319321
} | {
320322
_links?: Links;
321323
eventName?: string;
@@ -326,22 +328,20 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
326328
} | {
327329
_links?: Links;
328330
eventName?: string;
329-
href?: string;
330331
id?: string;
331332
interactionId?: string;
332333
interactionToken?: string;
333-
status: "failure";
334-
} | {
335-
status: "start";
334+
href?: string;
335+
session?: string;
336+
status: "success";
336337
} | {
337338
_links?: Links;
338339
eventName?: string;
340+
href?: string;
339341
id?: string;
340342
interactionId?: string;
341343
interactionToken?: string;
342-
href?: string;
343-
session?: string;
344-
status: "success";
344+
status: "failure";
345345
} | null;
346346
cache: {
347347
getLatestResponse: () => ((state: RootState< {
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
3+
*
4+
* This software may be modified and distributed under the terms
5+
* of the MIT license. See the LICENSE file for details.
6+
*/
7+
import { generateAndStoreAuthUrlValues } from '@forgerock/sdk-oidc';
8+
import { createChallenge } from '@forgerock/sdk-utilities';
9+
import { Micro } from 'effect';
10+
11+
import type { WellknownResponse } from '@forgerock/sdk-types';
12+
import type { AuthorizationError, OptionalAuthorizeOptions } from './authorize.request.types.js';
13+
import type { OidcConfig } from './config.types.js';
14+
15+
// ─── Crypto / sessionStorage side effects ────────────────────────────────────
16+
17+
export const generateAuthValues = (
18+
config: OidcConfig,
19+
wellknown: WellknownResponse,
20+
options?: OptionalAuthorizeOptions,
21+
): Micro.Micro<ReturnType<typeof generateAndStoreAuthUrlValues>, AuthorizationError, never> =>
22+
Micro.try({
23+
try: () =>
24+
generateAndStoreAuthUrlValues({
25+
clientId: config.clientId,
26+
serverConfig: { baseUrl: new URL(wellknown.authorization_endpoint).origin },
27+
responseType: config.responseType || 'code',
28+
redirectUri: config.redirectUri,
29+
scope: config.scope || 'openid',
30+
...options,
31+
}),
32+
catch: (err): AuthorizationError => ({
33+
error: 'PAR_PARAM_BUILD_ERROR',
34+
error_description: err instanceof Error ? err.message : 'Failed to generate auth URL values',
35+
type: 'auth_error',
36+
}),
37+
});
38+
39+
export const generatePkceChallenge = (
40+
verifier: string,
41+
): Micro.Micro<string, AuthorizationError, never> =>
42+
Micro.tryPromise({
43+
try: () => createChallenge(verifier),
44+
catch: (err): AuthorizationError => ({
45+
error: 'PAR_CHALLENGE_ERROR',
46+
error_description: err instanceof Error ? err.message : 'Failed to generate PKCE challenge',
47+
type: 'auth_error',
48+
}),
49+
});
50+
51+
export const storeAuthOptions = (
52+
storeOptions: () => void,
53+
): Micro.Micro<void, AuthorizationError, never> =>
54+
Micro.try({
55+
try: () => storeOptions(),
56+
catch: (err): AuthorizationError => ({
57+
error: 'PAR_STORAGE_ERROR',
58+
error_description: err instanceof Error ? err.message : 'Failed to store PAR session options',
59+
type: 'unknown_error',
60+
}),
61+
});

0 commit comments

Comments
 (0)