Skip to content

Commit

Permalink
Fix revoke token method signature (#375)
Browse files Browse the repository at this point in the history
fix(pam): fix revoke token method signature

Fix revoke token method signature where mistakenly expected object with `token` field.

refactor(typo): fix typo in PAM types file name
  • Loading branch information
parfeon authored May 22, 2024
1 parent 25b4c94 commit fe9f173
Show file tree
Hide file tree
Showing 18 changed files with 57 additions and 45 deletions.
11 changes: 8 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
changelog:
- date: 2024-05-22
version: v8.2.1
changes:
- type: bug
text: "Fix revoke token method signature where mistakenly expected object with `token` field."
- date: 2024-05-21
version: v8.2.0
changes:
Expand Down Expand Up @@ -988,7 +993,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '8.2.0'
version: '8.2.1'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1004,7 +1009,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.2.0.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.2.1.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -1675,7 +1680,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v8.2.0/pubnub.8.2.0.js
location: https://github.com/pubnub/javascript/releases/download/v8.2.1/pubnub.8.2.1.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v8.2.1
May 22 2024

#### Fixed
- Fix revoke token method signature where mistakenly expected object with `token` field.

## v8.2.0
May 21 2024

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
npm install pubnub
```
* or download one of our builds from our CDN:
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.0.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.0.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.1.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.1.min.js
2. Configure your keys:
Expand Down
6 changes: 3 additions & 3 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -3810,7 +3810,7 @@
return base.PubNubFile;
},
get version() {
return '8.2.0';
return '8.2.1';
},
getVersion() {
return this.version;
Expand Down 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
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/core/components/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
return base.PubNubFile;
},
get version() {
return '8.2.0';
return '8.2.1';
},
getVersion() {
return this.version;
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
File renamed without changes.
10 changes: 5 additions & 5 deletions lib/types/core/pubnub-common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as History from './types/api/history';
import * as MessageAction from './types/api/message-action';
import * as FileSharing from './types/api/file-sharing';
import { PubNubFileInterface } from './types/file';
import * as PAM from './types/api/access-panager';
import * as PAM from './types/api/access-manager';
import { SubscriptionOptions } from '../entities/commonTypes';
import { ChannelMetadata } from '../entities/ChannelMetadata';
import { SubscriptionSet } from '../entities/SubscriptionSet';
Expand Down 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
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pubnub",
"version": "8.2.0",
"version": "8.2.1",
"author": "PubNub <[email protected]>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const makeConfiguration = (
return base.PubNubFile;
},
get version(): string {
return '8.2.0';
return '8.2.1';
},
getVersion(): string {
return this.version;
Expand Down
2 changes: 1 addition & 1 deletion src/core/endpoints/access_manager/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { TransportResponse } from '../../types/transport-response';
import { PubNubAPIError } from '../../../errors/pubnub-api-error';
import { AbstractRequest } from '../../components/request';
import RequestOperation from '../../constants/operations';
import * as PAM from '../../types/api/access-panager';
import * as PAM from '../../types/api/access-manager';
import { KeySet, Query } from '../../types/api';

// --------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/core/endpoints/access_manager/grant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { TransportResponse } from '../../types/transport-response';
import { PubNubAPIError } from '../../../errors/pubnub-api-error';
import { AbstractRequest } from '../../components/request';
import RequestOperation from '../../constants/operations';
import * as PAM from '../../types/api/access-panager';
import * as PAM from '../../types/api/access-manager';
import { KeySet, Query } from '../../types/api';

// --------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/core/endpoints/access_manager/grant_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PubNubAPIError } from '../../../errors/pubnub-api-error';
import { TransportMethod } from '../../types/transport-request';
import { AbstractRequest } from '../../components/request';
import RequestOperation from '../../constants/operations';
import * as PAM from '../../types/api/access-panager';
import * as PAM from '../../types/api/access-manager';
import { KeySet } from '../../types/api';

// --------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions src/core/endpoints/access_manager/revoke_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PubNubAPIError } from '../../../errors/pubnub-api-error';
import { TransportMethod } from '../../types/transport-request';
import { AbstractRequest } from '../../components/request';
import RequestOperation from '../../constants/operations';
import * as PAM from '../../types/api/access-panager';
import * as PAM from '../../types/api/access-manager';
import { encodeString } from '../../utils';
import { KeySet } from '../../types/api';

Expand All @@ -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
16 changes: 8 additions & 8 deletions src/core/pubnub-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import { RevokeTokenRequest } from './endpoints/access_manager/revoke_token';
import { GrantTokenRequest } from './endpoints/access_manager/grant_token';
import { GrantRequest } from './endpoints/access_manager/grant';
import { AuditRequest } from './endpoints/access_manager/audit';
import * as PAM from './types/api/access-panager';
import * as PAM from './types/api/access-manager';
// endregion
// region Entities
import { SubscriptionOptions } from '../entities/commonTypes';
Expand Down 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
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

0 comments on commit fe9f173

Please sign in to comment.