Skip to content

Commit 420128c

Browse files
Update chat token generator to be async
1 parent c67bf0f commit 420128c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/commands/token/chat.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,28 @@ class ChatTokenGenerator extends TwilioClientCommand {
1111
this.showHeaders = true;
1212
}
1313

14-
validateChatServiceSid() {
14+
validateChatServiceSid(sid) {
1515
return (
16-
this.flags['chat-service-sid'].startsWith('IS') &&
17-
this.flags['chat-service-sid'].length === 34
16+
sid.startsWith('IS') &&
17+
sid.length === 34
1818
);
1919
}
2020

2121
async run() {
2222
await super.run();
2323

24+
const chatServiceSid = await this.flags['chat-service-sid'];
2425
const accessToken = createToken.call(this);
2526

26-
if (!this.validateChatServiceSid()) {
27+
if (!this.validateChatServiceSid(chatServiceSid)) {
2728
this.logger.error(
2829
'Invalid Chat Service SID, must look like ISxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
2930
);
3031
process.exit(1);
3132
}
3233

3334
let chatGrant = new Twilio.jwt.AccessToken.ChatGrant({
34-
serviceSid: this.flags['chat-service-sid'],
35+
serviceSid: chatServiceSid
3536
});
3637
accessToken.addGrant(chatGrant);
3738

0 commit comments

Comments
 (0)