mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[pubnub] Add grant method
This commit is contained in:
parent
c807902931
commit
971d40fedc
29
types/pubnub/index.d.ts
vendored
29
types/pubnub/index.d.ts
vendored
@ -4,7 +4,8 @@
|
||||
// rollymaduk <https://github.com/rollymaduk>,
|
||||
// vitosamson <https://github.com/vitosamson>,
|
||||
// FlorianDr <https://github.com/FlorianDr>,
|
||||
// danduh <https://github.com/danduh>
|
||||
// danduh <https://github.com/danduh>,
|
||||
// ChristianBoehlke <https://github.com/ChristianBoehlke>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// @see https://www.pubnub.com/docs/web-javascript/api-reference-configuration
|
||||
// TypeScript Version: 2.2
|
||||
@ -99,6 +100,15 @@ declare class Pubnub {
|
||||
params: Pubnub.SetStateParameters
|
||||
): Promise<Pubnub.SetStateResponse>;
|
||||
|
||||
grant(
|
||||
params: Pubnub.GrantParameters,
|
||||
callback: (status: Pubnub.GrantStatus, response: {}) => void
|
||||
): void;
|
||||
|
||||
grant(
|
||||
params: Pubnub.GrantParameters
|
||||
): Promise<{}>;
|
||||
|
||||
encrypt(
|
||||
data: string,
|
||||
customCipherKey?: string,
|
||||
@ -348,6 +358,23 @@ declare namespace Pubnub {
|
||||
};
|
||||
}
|
||||
|
||||
// grant
|
||||
interface GrantParameters {
|
||||
channels?: string[];
|
||||
channelGroups?: string[];
|
||||
authKeys?: string[];
|
||||
ttl?: number;
|
||||
read?: boolean;
|
||||
write?: boolean;
|
||||
manage?: boolean;
|
||||
}
|
||||
|
||||
interface GrantStatus {
|
||||
error: boolean;
|
||||
operation: string;
|
||||
statusCode: number;
|
||||
}
|
||||
|
||||
// encrypt & decrypt
|
||||
interface CryptoParameters {
|
||||
encryptKey?: boolean;
|
||||
|
||||
@ -87,6 +87,17 @@ pubnub.setState({ channels: [] }).then(res => {
|
||||
console.log(res.state);
|
||||
});
|
||||
|
||||
const grantOptions = {
|
||||
channels: ['channel-1'],
|
||||
authKeys: ['auth-key'],
|
||||
read: true,
|
||||
write: false,
|
||||
manage: false
|
||||
};
|
||||
pubnub.grant(grantOptions).then(status => {
|
||||
console.log(status);
|
||||
});
|
||||
|
||||
pubnub.history({channel: 'channel-1', count: 2}, (status, res) => {
|
||||
console.log(status);
|
||||
console.log(res);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user