Skip to content

Commit a0b8888

Browse files
authored
Merge pull request #435 from NipuniBhagya/main
Add new tokenLifecycle configuration to replace legacy periodicTokenRefresh
2 parents 0cbc523 + 5611bc2 commit a0b8888

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

.changeset/petite-taxes-press.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@asgardeo/javascript': minor
3+
'@asgardeo/react': minor
4+
---
5+
6+
Add tokenLifecycle.refreshToken.autoRefresh config to replace legacy periodicTokenRefresh

packages/javascript/src/models/config.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
2+
* Copyright (c) 2025-2026, WSO2 LLC. (https://www.wso2.com).
33
*
44
* WSO2 LLC. licenses this file to you under the Apache License,
55
* Version 2.0 (the "License"); you may not use this file except
@@ -307,6 +307,21 @@ export interface BaseConfig<T = unknown> extends WithPreferences {
307307
*/
308308
syncSession?: boolean;
309309

310+
/**
311+
* Configuration for token lifecycle management.
312+
*/
313+
tokenLifecycle?: {
314+
/**
315+
* Configuration for refresh token behavior.
316+
*/
317+
refreshToken?: {
318+
/**
319+
* Whether to automatically refresh the access token periodically before it expires.
320+
*/
321+
autoRefresh?: boolean;
322+
};
323+
};
324+
310325
/**
311326
* Token validation configuration.
312327
* This allows you to configure how the SDK validates tokens received from the authorization server.

packages/react/src/AsgardeoReactClient.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
2+
* Copyright (c) 2025-2026, WSO2 LLC. (https://www.wso2.com).
33
*
44
* WSO2 LLC. licenses this file to you under the Apache License,
55
* Version 2.0 (the "License"); you may not use this file except
@@ -126,7 +126,12 @@ class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactConfig> e
126126
}
127127

128128
return this.withLoading(async () => {
129-
this.initializeConfig = {...config, organizationHandle: resolvedOrganizationHandle};
129+
this.initializeConfig = {
130+
...config,
131+
organizationHandle: resolvedOrganizationHandle,
132+
periodicTokenRefresh: config?.tokenLifecycle?.refreshToken?.autoRefresh
133+
?? (config as any)?.periodicTokenRefresh,
134+
};
130135

131136
return this.asgardeo.init(this.initializeConfig as any);
132137
});

0 commit comments

Comments
 (0)