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
Changes from 1 commit
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
Next Next commit
fix(pam): fix revoke token method signature
Fix revoke token method signature where mistakenly expected object with `token` field.
parfeon committed May 22, 2024
commit af181c9f33423976b49e6ec14d8a24ff27d9e74b
6 changes: 3 additions & 3 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
@@ -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);
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
@@ -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);
8 changes: 4 additions & 4 deletions lib/types/core/pubnub-common.d.ts
Original file line number Diff line number Diff line change
@@ -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.
*
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
@@ -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.
*/
5 changes: 4 additions & 1 deletion src/core/endpoints/access_manager/revoke_token.ts
Original file line number Diff line number Diff line change
@@ -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.
*/
14 changes: 7 additions & 7 deletions src/core/pubnub-common.ts
Original file line number Diff line number Diff line change
@@ -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);
8 changes: 2 additions & 6 deletions src/core/types/api/access-panager.ts
Original file line number Diff line number Diff line change
@@ -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.