Skip to content

Commit 480340e

Browse files
authored
feat: Allow custom refresh token duration (#511)
For SDK calls initiated by MGMT SDK related to descope/etc#10354
1 parent 1432b25 commit 480340e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/management/jwt.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ const withJWT = (sdk: CoreSdk, managementKey?: string) => ({
2424
validateConsent: boolean,
2525
customClaims?: Record<string, any>,
2626
selectedTenant?: string,
27+
refreshDuration?: number,
2728
): Promise<SdkResponse<UpdateJWTResponse>> =>
2829
transformResponse(
2930
sdk.httpClient.post(
3031
apiPaths.jwt.impersonate,
31-
{ impersonatorId, loginId, validateConsent, customClaims, selectedTenant },
32+
{ impersonatorId, loginId, validateConsent, customClaims, selectedTenant, refreshDuration },
3233
{ token: managementKey },
3334
),
3435
),
@@ -67,11 +68,12 @@ const withJWT = (sdk: CoreSdk, managementKey?: string) => ({
6768
anonymous: (
6869
customClaims?: Record<string, any>,
6970
selectedTenant?: string,
71+
refreshDuration?: number,
7072
): Promise<SdkResponse<AnonymousJWTResponse>> =>
7173
transformResponse(
7274
sdk.httpClient.post(
7375
apiPaths.jwt.anonymous,
74-
{ customClaims, selectedTenant },
76+
{ customClaims, selectedTenant, refreshDuration },
7577
{ token: managementKey },
7678
),
7779
),

lib/management/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,13 @@ export type CheckResponseRelation = {
812812
// should have the type of loginoptions expect templateId and templateOptions
813813
export type MgmtLoginOptions = Omit<LoginOptions, 'templateId' | 'templateOptions'> & {
814814
jwt?: string;
815+
refreshDuration?: number;
815816
};
816817

817818
export type MgmtSignUpOptions = {
818819
// we can replace this with partial `SignUpOptions` from core-js-sdk once its exported
819820
customClaims?: Record<string, any>;
821+
refreshDuration?: number;
820822
};
821823

822824
export interface UserOptions {

0 commit comments

Comments
 (0)