Skip to content

Commit

Permalink
fix(pam): fix revoke token method signature
Browse files Browse the repository at this point in the history
Fix revoke token method signature where mistakenly expected object with `token` field.
  • Loading branch information
parfeon committed May 22, 2024
1 parent 5607747 commit af181c9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 31 deletions.
6 changes: 3 additions & 3 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -12513,14 +12513,14 @@
/**
* 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* () {
const request = new RevokeTokenRequest(Object.assign(Object.assign({}, 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
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/core/pubnub-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1117,14 +1117,14 @@ 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* () {
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
7 changes: 1 addition & 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,7 @@ 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;
};
export type RevokeParameters = string;
/**
* Response with revoked access token.
*/
Expand Down
5 changes: 4 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,10 @@ 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 @@ -1824,33 +1824,33 @@ 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> {
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
8 changes: 2 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,8 @@ 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

0 comments on commit af181c9

Please sign in to comment.