Skip to content

Commit

Permalink
Merge pull request AgoraIO#68 from DreamTeamMobile/feature/typescript
Browse files Browse the repository at this point in the history
Add Typescript typings
  • Loading branch information
plutoless authored Apr 19, 2020
2 parents 42cefea + 06ba5f4 commit 1cae42b
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 3 deletions.
92 changes: 92 additions & 0 deletions DynamicKey/AgoraDynamicKey/nodejs/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

export namespace RtcRole {
export const PUBLISHER: number;
export const SUBSCRIBER: number;
}

export namespace RtcTokenBuilder {

/**
* Builds an RTC token using an Integer uid.
* @param {*} appID The App ID issued to you by Agora.
* @param {*} appCertificate Certificate of the application that you registered in the Agora Dashboard.
* @param {*} channelName The unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are:
* - The 26 lowercase English letters: a to z.
* - The 26 uppercase English letters: A to Z.
* - The 10 digits: 0 to 9.
* - The space.
* - "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
* @param {*} uid User ID. A 32-bit unsigned integer with a value ranging from 1 to (2^32-1).
* @param {*} role See #userRole.
* - Role.PUBLISHER; RECOMMENDED. Use this role for a voice/video call or a live broadcast.
* - Role.SUBSCRIBER: ONLY use this role if your live-broadcast scenario requires authentication for [Hosting-in](https://docs.agora.io/en/Agora%20Platform/terms?platform=All%20Platforms#hosting-in). In order for this role to take effect, please contact our support team to enable authentication for Hosting-in for you. Otherwise, Role_Subscriber still has the same privileges as Role_Publisher.
* @param {*} privilegeExpiredTs represented by the number of seconds elapsed since 1/1/1970. If, for example, you want to access the Agora Service within 10 minutes after the token is generated, set expireTimestamp as the current timestamp + 600 (seconds).
* @return The new Token.
*/
export function buildTokenWithUid(appID: string, appCertificate: string, channelName: string, uid: number, role: number, privilegeExpiredTs: number): string;

/**
* Builds an RTC token using an Integer uid.
* @param {*} appID The App ID issued to you by Agora.
* @param {*} appCertificate Certificate of the application that you registered in the Agora Dashboard.
* @param {*} channelName The unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are:
* - The 26 lowercase English letters: a to z.
* - The 26 uppercase English letters: A to Z.
* - The 10 digits: 0 to 9.
* - The space.
* - "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
* @param {*} account The user account.
* @param {*} role See #userRole.
* - Role.PUBLISHER; RECOMMENDED. Use this role for a voice/video call or a live broadcast.
* - Role.SUBSCRIBER: ONLY use this role if your live-broadcast scenario requires authentication for [Hosting-in](https://docs.agora.io/en/Agora%20Platform/terms?platform=All%20Platforms#hosting-in). In order for this role to take effect, please contact our support team to enable authentication for Hosting-in for you. Otherwise, Role_Subscriber still has the same privileges as Role_Publisher.
* @param {*} privilegeExpiredTs represented by the number of seconds elapsed since 1/1/1970. If, for example, you want to access the Agora Service within 10 minutes after the token is generated, set expireTimestamp as the current timestamp + 600 (seconds).
* @return The new Token.
*/
export function buildTokenWithAccount(appID: string, appCertificate: string, channelName: string, account: string, role: number, privilegeExpiredTs: number): string;
}

export namespace RtmTokenBuilder {

/**
* @param {*} appID: The App ID issued to you by Agora. Apply for a new App ID from
* Agora Dashboard if it is missing from your kit. See Get an App ID.
* @param {*} appCertificate: Certificate of the application that you registered in
* the Agora Dashboard. See Get an App Certificate.
* @param {*} account: The user account.
* @param {*} role : Role_Publisher = 1: A broadcaster (host) in a live-broadcast profile.
* Role_Subscriber = 2: (Default) A audience in a live-broadcast profile.
* @param {*} privilegeExpiredTs : represented by the number of seconds elapsed since
* 1/1/1970. If, for example, you want to access the
* Agora Service within 10 minutes after the token is
* generated, set expireTimestamp as the current
* @return token
*/
export function buildToken(appID: string, appCertificate: string, account: string | number, role: number, privilegeExpiredTs: number): string;

}

export namespace RtmRole {
export const Rtm_User: number;
}

export namespace RtmTokenBuilder {

/**
* @param {*} appID: The App ID issued to you by Agora. Apply for a new App ID from
* Agora Dashboard if it is missing from your kit. See Get an App ID.
* @param {*} appCertificate: Certificate of the application that you registered in
* the Agora Dashboard. See Get an App Certificate.
* @param {*} account: The user account.
* @param {*} role : Role_Publisher = 1: A broadcaster (host) in a live-broadcast profile.
* Role_Subscriber = 2: (Default) A audience in a live-broadcast profile.
* @param {*} privilegeExpiredTs : represented by the number of seconds elapsed since
* 1/1/1970. If, for example, you want to access the
* Agora Service within 10 minutes after the token is
* generated, set expireTimestamp as the current
* @return token
*/
export function buildToken(appID: string, appCertificate: string, account: string | number, role: number, privilegeExpiredTs: number): string;
}

module.exports.RtmTokenBuilder = RtmTokenBuilder
module.exports.Role = Role
6 changes: 3 additions & 3 deletions DynamicKey/AgoraDynamicKey/nodejs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions DynamicKey/AgoraDynamicKey/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"types": "index.d.ts",
"author": "",
"license": "ISC",
"dependencies": {
Expand Down

0 comments on commit 1cae42b

Please sign in to comment.