@@ -70,7 +70,7 @@ export const tailscaleCreateAuthKeyTool: ToolConfig<
7070 `https://api.tailscale.com/api/v2/tailnet/${ encodeURIComponent ( params . tailnet . trim ( ) ) } /keys` ,
7171 method : 'POST' ,
7272 headers : ( params ) => ( {
73- Authorization : `Bearer ${ params . apiKey } ` ,
73+ Authorization : `Bearer ${ params . apiKey . trim ( ) } ` ,
7474 'Content-Type' : 'application/json' ,
7575 } ) ,
7676 body : ( params ) => {
@@ -100,16 +100,16 @@ export const tailscaleCreateAuthKeyTool: ToolConfig<
100100 }
101101
102102 if ( params . description ) body . description = params . description
103- if ( params . expirySeconds ) body . expirySeconds = params . expirySeconds
103+ if ( params . expirySeconds !== undefined && params . expirySeconds !== null )
104+ body . expirySeconds = params . expirySeconds
104105
105106 return body
106107 } ,
107108 } ,
108109
109110 transformResponse : async ( response ) => {
110- const data = await response . json ( )
111-
112111 if ( ! response . ok ) {
112+ const data = await response . json ( ) . catch ( ( ) => ( { } ) )
113113 return {
114114 success : false ,
115115 output : {
@@ -121,10 +121,11 @@ export const tailscaleCreateAuthKeyTool: ToolConfig<
121121 revoked : '' ,
122122 capabilities : { reusable : false , ephemeral : false , preauthorized : false , tags : [ ] } ,
123123 } ,
124- error : data . message ?? 'Failed to create auth key' ,
124+ error : ( data as Record < string , string > ) . message ?? 'Failed to create auth key' ,
125125 }
126126 }
127127
128+ const data = await response . json ( )
128129 const deviceCaps = data . capabilities ?. devices ?. create ?? { }
129130
130131 return {
0 commit comments