@@ -31,6 +31,7 @@ import {
3131 stringTranslateToId ,
3232 undefinedDef ,
3333 updateFromUserInput ,
34+ urlValidateFn ,
3435} from '@smartthings/cli-lib'
3536import { awsHelpText } from '../aws-utils'
3637import { chooseOrganization } from './organization-util'
@@ -55,13 +56,16 @@ export const arnDef = (name: string, inChina: boolean, initialValue?: SchemaAppR
5556 { initiallyActive } )
5657}
5758
59+ // The SmartThings services handling Schema Apps are limited to connecting to apps in the range 80-8002.
60+ export const schemaOutURLValidate = urlValidateFn ( { httpsRequired : true , minPort : 80 , maxPort : 8002 } )
61+
5862export const webHookUrlDef = ( inChina : boolean , initialValue ?: SchemaAppRequest ) : InputDefinition < string | undefined > => {
5963 if ( inChina ) {
6064 return undefinedDef
6165 }
6266
6367 const initiallyActive = initialValue ?. hostingType === 'webhook'
64- return optionalDef ( stringDef ( 'Webhook URL' ) ,
68+ return optionalDef ( stringDef ( 'Webhook URL' , { validate : schemaOutURLValidate } ) ,
6569 ( context ?: unknown [ ] ) => ( context ?. [ 0 ] as Pick < SchemaAppRequest , 'hostingType' > ) ?. hostingType === 'webhook' ,
6670 { initiallyActive } )
6771}
@@ -133,8 +137,8 @@ export const buildInputDefinition = async (
133137 appName : optionalStringDef ( 'App Name' , {
134138 default : ( context ?: unknown [ ] ) => ( context ?. [ 0 ] as Pick < SchemaAppRequest , 'partnerName' > ) ?. partnerName ?? '' ,
135139 } ) ,
136- oAuthAuthorizationUrl : stringDef ( 'OAuth Authorization URL' , { validate : httpsURLValidate } ) ,
137- oAuthTokenUrl : stringDef ( 'Partner OAuth Refresh Token URL' , { validate : httpsURLValidate } ) ,
140+ oAuthAuthorizationUrl : stringDef ( 'OAuth Authorization URL' , { validate : schemaOutURLValidate } ) ,
141+ oAuthTokenUrl : stringDef ( 'Partner OAuth Refresh Token URL' , { validate : schemaOutURLValidate } ) ,
138142 icon : optionalStringDef ( 'Icon URL' , { validate : httpsURLValidate } ) ,
139143 icon2x : optionalStringDef ( '2x Icon URL' , { validate : httpsURLValidate } ) ,
140144 icon3x : optionalStringDef ( '3x Icon URL' , { validate : httpsURLValidate } ) ,
0 commit comments