Skip to content

Commit b51ea11

Browse files
committed
chore(oidc-client): re-export necessary types
1 parent 2501169 commit b51ea11

21 files changed

+94
-121
lines changed

e2e/oidc-app/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
"serve": "pnpm nx nxServe"
1010
},
1111
"dependencies": {
12-
"@forgerock/javascript-sdk": "^4.8.2",
13-
"@forgerock/oidc-client": "workspace:*",
14-
"@forgerock/sdk-types": "workspace:*"
12+
"@forgerock/oidc-client": "workspace:*"
1513
},
1614
"nx": {
1715
"tags": ["scope:e2e"]

e2e/oidc-app/tsconfig.app.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
],
2020
"include": ["src/**/*.ts"],
2121
"references": [
22-
{
23-
"path": "../../packages/sdk-types/tsconfig.lib.json"
24-
},
2522
{
2623
"path": "../../packages/oidc-client/tsconfig.lib.json"
2724
}

e2e/oidc-app/tsconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
"files": [],
44
"include": [],
55
"references": [
6-
{
7-
"path": "../../packages/sdk-types"
8-
},
96
{
107
"path": "../../packages/oidc-client"
118
},

packages/oidc-client/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ A generic OpenID Connect (OIDC) client library for JavaScript and TypeScript, de
44

55
```js
66
// Initialize OIDC Client
7-
const oidcClient = oidc({
7+
const oidcClient = await oidc({
88
/* config */
99
});
1010

1111
// Authorize API
12-
const authResponse = oidcClient.authorize.background(); // Returns code and state if successful, error and Auth URL if not
13-
const authUrl = oidcClient.authorize.url(); // Returns Auth URL or error
12+
const authResponse = await oidcClient.authorize.background(); // Returns code and state if successful, error if not
13+
const authUrl = await oidcClient.authorize.url(); // Returns Auth URL or error
1414

1515
// Tokens API
16-
const newTokens = oidcClient.token.exchange({
16+
const newTokens = await oidcClient.token.exchange({
1717
/* code, state */
1818
}); // Returns new tokens or error
19-
const existingTokens = oidcClient.token.get(); // Returns existing tokens or error
19+
const existingTokens = await oidcClient.token.get(); // Returns existing tokens or error
20+
const response = await oidcClient.token.revoke(); // Revokes an access token and returns the response or an error
2021

2122
// User API
22-
const user = oidcClient.user.info(); // Returns user object or error
23-
const logoutResponse = oidcClient.user.logout(); // Returns null or error
23+
const user = await oidcClient.user.info(); // Returns user object or error
24+
const logoutResponse = await oidcClient.user.logout(); // Logs the user out and returns the response or an error
2425
```

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ import {
1212
buildAuthorizeOptionsµ,
1313
createAuthorizeErrorµ,
1414
} from './authorize.request.utils.js';
15+
import { oidcApi } from './oidc.api.js';
1516

17+
import type { ClientStore } from './client.types.js';
1618
import type { GetAuthorizationUrlOptions, WellKnownResponse } from '@forgerock/sdk-types';
17-
1819
import type { AuthorizationError, AuthorizationSuccess } from './authorize.request.types.js';
19-
import type { createClientStore } from './client.store.utils.js';
2020
import type { OidcConfig } from './config.types.js';
21-
import { oidcApi } from './oidc.api.js';
2221

2322
/**
2423
* @function authorizeµ
2524
* @description Creates an authorization URL for the OIDC client.
2625
* @param {WellKnownResponse} wellknown - The well-known configuration for the OIDC server.
2726
* @param {OidcConfig} config - The OIDC client configuration.
2827
* @param {CustomLogger} log - The logger instance for logging debug information.
28+
* @param {ClientStore} store - The Redux store instance for managing OIDC state.
2929
* @param {GetAuthorizationUrlOptions} options - Optional parameters for the authorization request.
3030
* @returns {Micro.Micro<AuthorizationSuccess, AuthorizationError, never>} - A micro effect that resolves to the authorization response.
3131
*/
3232
export function authorizeµ(
3333
wellknown: WellKnownResponse,
3434
config: OidcConfig,
3535
log: CustomLogger,
36-
store: ReturnType<typeof createClientStore>,
36+
store: ClientStore,
3737
options?: GetAuthorizationUrlOptions,
3838
) {
3939
return buildAuthorizeOptionsµ(wellknown, config, options).pipe(

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7+
import type { GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
8+
9+
export type BuildAuthorizationData = [string, GetAuthorizationUrlOptions];
10+
export type OptionalAuthorizeOptions = Partial<GetAuthorizationUrlOptions>;
711
export interface AuthorizeErrorResponse {
812
id?: string;
913
code?: string;

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ import { createAuthorizeUrl } from '@forgerock/sdk-oidc';
88
import { Micro } from 'effect';
99

1010
import type { WellKnownResponse, GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
11-
12-
import type { AuthorizationError, AuthorizationSuccess } from './authorize.request.types.js';
11+
import type {
12+
AuthorizationError,
13+
AuthorizationSuccess,
14+
BuildAuthorizationData,
15+
OptionalAuthorizeOptions,
16+
} from './authorize.request.types.js';
1317
import type { OidcConfig } from './config.types.js';
1418

15-
type BuildAuthorizationData = [string, GetAuthorizationUrlOptions];
16-
export type OptionalAuthorizeOptions = Partial<GetAuthorizationUrlOptions>;
17-
1819
/**
1920
* @function buildAuthorizeOptionsµ
2021
* @description Builds the authorization options for the OIDC client.
2122
* @param {WellKnownResponse} wellknown - The well-known configuration for the OIDC server.
2223
* @param {OptionalAuthorizeOptions} options - Optional parameters for the authorization request.
23-
* @returns {Micro.Micro<BuildAuthorizationData, AuthorizeErrorResponse, never>}
24+
* @returns {Micro.Micro<BuildAuthorizationData, AuthorizationError, never>}
2425
*/
2526
export function buildAuthorizeOptionsµ(
2627
wellknown: WellKnownResponse,
@@ -50,7 +51,7 @@ export function buildAuthorizeOptionsµ(
5051
* @param {WellKnownResponse} wellknown- The well-known configuration for the OIDC server.
5152
* @param { OidcConfig } config- The OIDC client configuration.
5253
* @param { GetAuthorizationUrlOptions } options- Optional parameters for the authorization request.
53-
* @returns { Micro.Micro<never, AuthorizeErrorResponse, never> }
54+
* @returns { Micro.Micro<never, AuthorizationError, never> }
5455
*/
5556
export function createAuthorizeErrorµ(
5657
res: { error: string; error_description: string },
@@ -121,7 +122,6 @@ export function createAuthorizeUrlµ(
121122
export function handleResponseµ(
122123
response: AuthorizationSuccess | AuthorizationError,
123124
wellknown: WellKnownResponse,
124-
config: OidcConfig,
125125
options: GetAuthorizationUrlOptions,
126126
): Micro.Micro<AuthorizationSuccess, AuthorizationError, never> {
127127
if ('code' in response) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
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+
*/
17
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query';
28

39
const authorizeSlice = createApi({

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import { CustomLogger, logger as loggerFn, LogLevel } from '@forgerock/sdk-logger';
7+
import { logger as loggerFn } from '@forgerock/sdk-logger';
88
import { createAuthorizeUrl } from '@forgerock/sdk-oidc';
9-
import { createStorage, StorageConfig } from '@forgerock/storage';
9+
import { createStorage } from '@forgerock/storage';
1010
import { Micro } from 'effect';
1111
import { exitIsFail, exitIsSuccess } from 'effect/Micro';
1212

@@ -18,6 +18,8 @@ import { wellknownApi, wellknownSelector } from './wellknown.api.js';
1818

1919
import type { ActionTypes, RequestMiddleware } from '@forgerock/sdk-request-middleware';
2020
import type { GenericError, GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
21+
import type { CustomLogger, LogLevel } from '@forgerock/sdk-logger';
22+
import type { StorageConfig } from '@forgerock/storage';
2123

2224
import type {
2325
GetTokensOptions,

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* of the MIT license. See the LICENSE file for details.
66
*/
77
import type { ActionTypes, RequestMiddleware } from '@forgerock/sdk-request-middleware';
8-
import type { logger as loggerFn } from '@forgerock/sdk-logger';
8+
import { logger as loggerFn } from '@forgerock/sdk-logger';
99

10-
import { configureStore, SerializedError } from '@reduxjs/toolkit';
10+
import { configureStore, type SerializedError } from '@reduxjs/toolkit';
1111
import { oidcApi } from './oidc.api.js';
1212
import { wellknownApi } from './wellknown.api.js';
1313

1414
import type { GenericError } from '@forgerock/sdk-types';
15-
import { FetchBaseQueryError } from '@reduxjs/toolkit/query';
15+
import type { FetchBaseQueryError } from '@reduxjs/toolkit/query';
1616

1717
/**
1818
* @function createClientStore
@@ -113,9 +113,3 @@ export function createTokenError(type: 'no_tokens' | 'no_access_token' | 'no_id_
113113

114114
return error;
115115
}
116-
117-
type ClientStore = typeof createClientStore;
118-
119-
export type RootState = ReturnType<ReturnType<ClientStore>['getState']>;
120-
121-
export type AppDispatch = ReturnType<ReturnType<ClientStore>['dispatch']>;

0 commit comments

Comments
 (0)