File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed
Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
33const Twilio = require ( 'twilio' ) ;
44const createToken = require ( '../../helpers/accessToken.js' ) ;
55const globalFlags = require ( '../../helpers/globalFlags.js' ) ;
6+ const { validateSid } = require ( '../../helpers/validation-helpers.js' ) ;
67
78class ChatTokenGenerator extends TwilioClientCommand {
89 constructor ( argv , config ) {
@@ -11,20 +12,13 @@ class ChatTokenGenerator extends TwilioClientCommand {
1112 this . showHeaders = true ;
1213 }
1314
14- validateChatServiceSid ( sid ) {
15- return (
16- sid . startsWith ( 'IS' ) &&
17- sid . length === 34
18- ) ;
19- }
20-
2115 async run ( ) {
2216 await super . run ( ) ;
2317
2418 const chatServiceSid = await this . flags [ 'chat-service-sid' ] ;
2519 const accessToken = createToken . call ( this ) ;
2620
27- if ( ! this . validateChatServiceSid ( chatServiceSid ) ) {
21+ if ( ! validateSid ( 'IS' , chatServiceSid ) ) {
2822 this . logger . error (
2923 'Invalid Chat Service SID, must look like ISxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
3024 ) ;
Original file line number Diff line number Diff line change 1+ const validateSid = function ( prefix , sid ) {
2+ return ( sid . startsWith ( prefix ) &&
3+ sid . length === 34
4+ ) ;
5+ } ;
6+
7+ module . exports = { validateSid } ;
You can’t perform that action at this time.
0 commit comments