Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix revoke token method signature #375

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -12234,12 +12234,12 @@
/**
* Revoke token permission.
*
* @param parameters - Request configuration parameters.
* @param token - Access token for which permissions should be revoked.
* @param [callback] - Request completion handler callback.
*
* @returns Asynchronous revoke token response or `void` in case if `callback` provided.
*/
revokeToken(parameters, callback) {
revokeToken(token, callback) {
return __awaiter(this, void 0, void 0, function* () {
throw new Error('Revoke Token error: PAM module disabled');
});
Expand Down
6 changes: 3 additions & 3 deletions lib/core/pubnub-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1267,15 +1267,15 @@ class PubNubCore {
/**
* Revoke token permission.
*
* @param parameters - Request configuration parameters.
* @param token - Access token for which permissions should be revoked.
* @param [callback] - Request completion handler callback.
*
* @returns Asynchronous revoke token response or `void` in case if `callback` provided.
*/
revokeToken(parameters, callback) {
revokeToken(token, callback) {
return __awaiter(this, void 0, void 0, function* () {
if (process.env.PAM_MODULE !== 'disabled') {
const request = new revoke_token_1.RevokeTokenRequest(Object.assign(Object.assign({}, parameters), { keySet: this._configuration.keySet }));
const request = new revoke_token_1.RevokeTokenRequest({ token, keySet: this._configuration.keySet });
if (callback)
return this.sendRequest(request, callback);
return this.sendRequest(request);
Expand Down
8 changes: 4 additions & 4 deletions lib/types/core/pubnub-common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,18 +692,18 @@ export declare class PubNubCore<CryptographyTypes, FileConstructorParameters, Pl
/**
* Revoke token permission.
*
* @param parameters - Request configuration parameters.
* @param token - Access token for which permissions should be revoked.
* @param callback - Request completion handler callback.
*/
revokeToken(parameters: PAM.RevokeParameters, callback: ResultCallback<PAM.RevokeTokenResponse>): void;
revokeToken(token: PAM.RevokeParameters, callback: ResultCallback<PAM.RevokeTokenResponse>): void;
/**
* Revoke token permission.
*
* @param parameters - Request configuration parameters.
* @param token - Access token for which permissions should be revoked.
*
* @returns Asynchronous revoke token response.
*/
revokeToken(parameters: PAM.RevokeParameters): Promise<PAM.RevokeTokenResponse>;
revokeToken(token: PAM.RevokeParameters): Promise<PAM.RevokeTokenResponse>;
/**
* Get current access token.
*
Expand Down
10 changes: 4 additions & 6 deletions lib/types/core/types/api/access-panager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,10 @@ export type GrantTokenParameters = {
* Response with generated access token.
*/
export type GrantTokenResponse = string;
export type RevokeParameters = {
/**
* Access token for which permissions should be revoked.
*/
token: string;
};
/**
* Access token for which permissions should be revoked.
*/
export type RevokeParameters = string;
/**
* Response with revoked access token.
*/
Expand Down
7 changes: 6 additions & 1 deletion src/core/endpoints/access_manager/revoke_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import { KeySet } from '../../types/api';
/**
* Request configuration parameters.
*/
type RequestParameters = PAM.RevokeParameters & {
type RequestParameters = {
/**
* Access token for which permissions should be revoked.
*/
token: string;

/**
* PubNub REST API access key set.
*/
Expand Down
14 changes: 7 additions & 7 deletions src/core/pubnub-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1906,34 +1906,34 @@ export class PubNubCore<
/**
* Revoke token permission.
*
* @param parameters - Request configuration parameters.
* @param token - Access token for which permissions should be revoked.
* @param callback - Request completion handler callback.
*/
public revokeToken(parameters: PAM.RevokeParameters, callback: ResultCallback<PAM.RevokeTokenResponse>): void;
public revokeToken(token: PAM.RevokeParameters, callback: ResultCallback<PAM.RevokeTokenResponse>): void;

/**
* Revoke token permission.
*
* @param parameters - Request configuration parameters.
* @param token - Access token for which permissions should be revoked.
*
* @returns Asynchronous revoke token response.
*/
public async revokeToken(parameters: PAM.RevokeParameters): Promise<PAM.RevokeTokenResponse>;
public async revokeToken(token: PAM.RevokeParameters): Promise<PAM.RevokeTokenResponse>;

/**
* Revoke token permission.
*
* @param parameters - Request configuration parameters.
* @param token - Access token for which permissions should be revoked.
* @param [callback] - Request completion handler callback.
*
* @returns Asynchronous revoke token response or `void` in case if `callback` provided.
*/
async revokeToken(
parameters: PAM.RevokeParameters,
token: PAM.RevokeParameters,
callback?: ResultCallback<PAM.RevokeTokenResponse>,
): Promise<PAM.RevokeTokenResponse | void> {
if (process.env.PAM_MODULE !== 'disabled') {
const request = new RevokeTokenRequest({ ...parameters, keySet: this._configuration.keySet });
const request = new RevokeTokenRequest({ token, keySet: this._configuration.keySet });

if (callback) return this.sendRequest(request, callback);
return this.sendRequest(request);
Expand Down
10 changes: 4 additions & 6 deletions src/core/types/api/access-panager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,10 @@ export type GrantTokenResponse = string;
// endregion

// region Revoke
export type RevokeParameters = {
/**
* Access token for which permissions should be revoked.
*/
token: string;
};
/**
* Access token for which permissions should be revoked.
*/
export type RevokeParameters = string;

/**
* Response with revoked access token.
Expand Down
Loading