Skip to content

Commit 51f02d7

Browse files
authored
Merge pull request #33 from xiaoshenlin/main
Allow `createKindeBrowserClient` with custom `SessionManager`
2 parents 75d395c + 5be1808 commit 51f02d7

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

lib/sdk/clients/browser/authcode-with-pkce.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import type {
1313
CreateOrgURLOptions,
1414
RegisterURLOptions,
1515
LoginURLOptions,
16-
PKCEClientOptions,
16+
BrowserPKCEClientOptions,
1717
} from '../types.js';
1818

19-
const createAuthCodeWithPKCEClient = (options: PKCEClientOptions) => {
19+
const createAuthCodeWithPKCEClient = (options: BrowserPKCEClientOptions) => {
2020
const { featureFlags, tokenClaims } = utilities;
21-
const sessionManager = new BrowserSessionManager();
21+
const sessionManager = options.sessionManager ?? new BrowserSessionManager();
2222
const client = new AuthCodeWithPKCE(options);
2323

2424
/**

lib/sdk/clients/browser/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import createAuthCodeWithPKCEClient from './authcode-with-pkce.js';
22
import { isBrowserEnvironment } from '../../environment.js';
3-
import type { PKCEClientOptions } from '../types.js';
3+
import type { BrowserPKCEClientOptions } from '../types.js';
44

5-
export const createKindeBrowserClient = (options: PKCEClientOptions) => {
5+
export const createKindeBrowserClient = (options: BrowserPKCEClientOptions) => {
66
if (!isBrowserEnvironment()) {
77
throw new Error('this method must be invoked in a browser environment');
88
}

lib/sdk/clients/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import type {
66
AuthorizationCodeOptions,
77
AuthURLOptions,
88
} from '../oauth2-flows/index.js';
9+
import { type SessionManager} from "../session-managers";
10+
11+
export interface BrowserPKCEClientOptions extends AuthorizationCodeOptions {
12+
sessionManager?: SessionManager
13+
}
914

1015
export interface PKCEClientOptions extends AuthorizationCodeOptions {}
1116
export interface CCClientOptions extends ClientCredentialsOptions {}

0 commit comments

Comments
 (0)