Skip to content

Commit 425b878

Browse files
committed
1 parent 9d5dcb8 commit 425b878

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

src/management/__generated/managers/sessions-manager.ts

+26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { InitOverride, ApiResponse } from '../../../lib/runtime.js';
33
import type {
44
GetSession200Response,
55
DeleteSessionRequest,
6+
RevokeSessionRequest,
67
GetSessionRequest,
78
} from '../models/index.js';
89

@@ -35,6 +36,31 @@ export class SessionsManager extends BaseAPI {
3536
return runtime.VoidApiResponse.fromResponse(response);
3637
}
3738

39+
/**
40+
* Revokes a session by ID and all associated refresh tokens.
41+
*
42+
* @throws {RequiredError}
43+
*/
44+
async revoke(
45+
requestParameters: RevokeSessionRequest,
46+
initOverrides?: InitOverride
47+
): Promise<ApiResponse<void>> {
48+
runtime.validateRequiredRequestParams(requestParameters, ['id']);
49+
50+
const response = await this.request(
51+
{
52+
path: `/sessions/{id}/revoke`.replace(
53+
'{id}',
54+
encodeURIComponent(String(requestParameters.id))
55+
),
56+
method: 'POST',
57+
},
58+
initOverrides
59+
);
60+
61+
return runtime.VoidApiResponse.fromResponse(response);
62+
}
63+
3864
/**
3965
* Retrieve session information.
4066
* Get session

src/management/__generated/models/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -20719,6 +20719,16 @@ export interface DeleteSessionRequest {
2071920719
*/
2072020720
id: string;
2072120721
}
20722+
/**
20723+
*
20724+
*/
20725+
export interface RevokeSessionRequest {
20726+
/**
20727+
* ID of the session to revoke.
20728+
*
20729+
*/
20730+
id: string;
20731+
}
2072220732
/**
2072320733
*
2072420734
*/

test/management/sessions.test.ts

+48
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,54 @@ describe('SessionsManager', () => {
133133
sessions.delete({ id }).then(() => {
134134
expect(request.isDone()).toBe(true);
135135

136+
done();
137+
});
138+
});
139+
});
140+
describe('#revoke', () => {
141+
const id = '6';
142+
143+
let request: nock.Scope;
144+
145+
beforeEach(() => {
146+
request = nock(API_URL).post(`/sessions/${id}/revoke`).reply(200, {});
147+
});
148+
149+
it('should return a promise when no callback is given', (done) => {
150+
sessions.revoke({ id }).then(done.bind(null, null));
151+
});
152+
153+
it(`should perform a revoke request to /sessions/${id}/revoke`, (done) => {
154+
sessions.revoke({ id }).then(() => {
155+
expect(request.isDone()).toBe(true);
156+
157+
done();
158+
});
159+
});
160+
161+
it('should pass any errors to the promise catch handler', (done) => {
162+
nock.cleanAll();
163+
164+
nock(API_URL).post(`/sessions/${id}/revoke`).reply(500, {});
165+
166+
sessions.revoke({ id }).catch((err) => {
167+
expect(err).toBeDefined();
168+
169+
done();
170+
});
171+
});
172+
173+
it('should include the token in the authorization header', (done) => {
174+
nock.cleanAll();
175+
176+
const request = nock(API_URL)
177+
.post(`/sessions/${id}/revoke`)
178+
.matchHeader('authorization', `Bearer ${token}`)
179+
.reply(200, {});
180+
181+
sessions.revoke({ id }).then(() => {
182+
expect(request.isDone()).toBe(true);
183+
136184
done();
137185
});
138186
});

0 commit comments

Comments
 (0)