Skip to content

Commit ac735c3

Browse files
authored
Allow updating jwt expiry via SDK (#427)
Supported as part of jwt update flow +test fixes descope/etc#8900
1 parent 7dcdd44 commit ac735c3

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lib/management/jwt.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ describe('Management JWT', () => {
2828
};
2929
mockHttpClient.post.mockResolvedValue(httpResponse);
3030

31-
const resp: SdkResponse<UpdateJWTResponse> = await management.jwt.update('jwt', {
32-
foo: 'bar',
33-
});
31+
const resp: SdkResponse<UpdateJWTResponse> = await management.jwt.update(
32+
'jwt',
33+
{
34+
foo: 'bar',
35+
},
36+
4,
37+
);
3438

3539
expect(mockHttpClient.post).toHaveBeenCalledWith(
3640
apiPaths.jwt.update,
37-
{ jwt: 'jwt', customClaims: { foo: 'bar' } },
41+
{ jwt: 'jwt', customClaims: { foo: 'bar' }, refreshDuration: 4 },
3842
{ token: 'key' },
3943
);
4044

lib/management/jwt.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ const withJWT = (sdk: CoreSdk, managementKey?: string) => ({
77
update: (
88
jwt: string,
99
customClaims?: Record<string, any>,
10+
refreshDuration?: number,
1011
): Promise<SdkResponse<UpdateJWTResponse>> =>
1112
transformResponse(
12-
sdk.httpClient.post(apiPaths.jwt.update, { jwt, customClaims }, { token: managementKey }),
13+
sdk.httpClient.post(
14+
apiPaths.jwt.update,
15+
{ jwt, customClaims, refreshDuration },
16+
{ token: managementKey },
17+
),
1318
),
1419
impersonate: (
1520
impersonatorId: string,

0 commit comments

Comments
 (0)