Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-jars-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smartthings/cli": patch
---

Update scopes available when creating an API Access Smart App.
73 changes: 56 additions & 17 deletions src/lib/command/util/smartapps-input-primitives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,62 @@ import { localhostOrHTTPSValidate } from '../../validate-util.js'
import { arrayDef, CheckboxChoice, checkboxDef, stringDef } from '../../item-input/index.js'


const availableScopes = [
'r:devices:*',
'w:devices:*',
'x:devices:*',
'r:hubs:*',
'r:locations:*',
'w:locations:*',
'x:locations:*',
'r:scenes:*',
'x:scenes:*',
'r:rules:*',
'w:rules:*',
'r:installedapps',
'w:installedapps',
type ScopeInfo = { scope: string; description: string }

const availableScopes: ScopeInfo[] = [
{
scope: 'r:devices:*',
description: 'Read a specific device or all devices.',
},
{
scope: 'w:devices:*',
description: 'Write to a specific device or all devices.',
},
{
scope: 'x:devices:*',
description: 'Execute commands on a specific device or all devices.',
},
{
scope: 'r:hubs:*',
description: 'Read a specific hub or all hubs.',
},
{
scope: 'r:locations:*',
description: 'Read all locations. An installed app can only read the location it is installed in.',
},
{
scope: 'w:locations:*',
description: 'Write all locations.',
},
{
scope: 'x:locations:*',
description: 'Change the mode of a location.',
},
{
scope: 'r:scenes:*',
description: 'Read a specific scene or all scenes.',
},
{
scope: 'x:scenes:*',
description: 'Execute a specific scene or all scenes.',
},
{
scope: 'r:rules:*',
description: 'Read one or all rules.',
},
{
scope: 'w:rules:*',
description: 'Write one or all rules.',
},
{
scope: 'sse',
description: 'Read and Write permissions required to use the SSE Subscription API.',
},
]

export const oauthAppScopeDef = checkboxDef<string>('Scopes', availableScopes, {
const scopeItems = availableScopes.map(({ scope, description }) => ({ name: `${scope} - ${description}`, value: scope }))

export const oauthAppScopeDef = checkboxDef<string>('Scopes', scopeItems, {
helpText: 'More information on OAuth 2 Scopes can be found at:\n' +
' https://www.oauth.com/oauth2-servers/scope/\n\n' +
'To determine which scopes you need for the application, see documentation for the' +
Expand All @@ -43,5 +82,5 @@ export const corsDomainsDef = arrayDef(
{ minItems: 0, maxItems: 10, helpText: corsDomainsHelpText },
)

export const smartAppHelpText = 'More information on writing SmartApps can be found at\n' +
' https://developer.smartthings.com/docs/connected-services/smartapp-basics'
export const smartAppHelpText = 'More information on writing API Access Smart Apps can be found at\n' +
' https://developer.smartthings.com/docs/service-integrations/get-started'
Loading