@@ -27,16 +27,7 @@ import {
2727 Nodes ,
2828 UpdateNode ,
2929} from './resources/nodes' ;
30- import {
31- VmListResponse ,
32- VmLogsParams ,
33- VmLogsResponse ,
34- VmReplaceParams ,
35- VmReplaceResponse ,
36- VmSSHParams ,
37- VmSSHResponse ,
38- Vms ,
39- } from './resources/vms/vms' ;
30+ import { VmLogsParams , VmLogsResponse , VmSSHParams , VmSSHResponse , Vms } from './resources/vms/vms' ;
4031import { type Fetch } from './internal/builtin-types' ;
4132import { HeadersLike , NullableHeaders , buildHeaders } from './internal/headers' ;
4233import { FinalRequestOptions , RequestOptions } from './internal/request-options' ;
@@ -52,9 +43,9 @@ import { isEmptyObj } from './internal/utils/values';
5243
5344export interface ClientOptions {
5445 /**
55- * Defaults to process.env['SFC_BEARER_TOKEN '].
46+ * Defaults to process.env['SFC_API_KEY '].
5647 */
57- bearerToken ?: string | null | undefined ;
48+ apiKey ?: string | null | undefined ;
5849
5950 /**
6051 * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
@@ -129,7 +120,7 @@ export interface ClientOptions {
129120 * API Client for interfacing with the SFC Nodes API.
130121 */
131122export class SFCNodes {
132- bearerToken : string | null ;
123+ apiKey : string | null ;
133124
134125 baseURL : string ;
135126 maxRetries : number ;
@@ -146,7 +137,7 @@ export class SFCNodes {
146137 /**
147138 * API Client for interfacing with the SFC Nodes API.
148139 *
149- * @param {string | null | undefined } [opts.bearerToken =process.env['SFC_BEARER_TOKEN '] ?? null]
140+ * @param {string | null | undefined } [opts.apiKey =process.env['SFC_API_KEY '] ?? null]
150141 * @param {string } [opts.baseURL=process.env['SFC_NODES_BASE_URL'] ?? https://api.sfcompute.com] - Override the default base URL for the API.
151142 * @param {number } [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
152143 * @param {MergedRequestInit } [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
@@ -157,11 +148,11 @@ export class SFCNodes {
157148 */
158149 constructor ( {
159150 baseURL = readEnv ( 'SFC_NODES_BASE_URL' ) ,
160- bearerToken = readEnv ( 'SFC_BEARER_TOKEN ' ) ?? null ,
151+ apiKey = readEnv ( 'SFC_API_KEY ' ) ?? null ,
161152 ...opts
162153 } : ClientOptions = { } ) {
163154 const options : ClientOptions = {
164- bearerToken ,
155+ apiKey ,
165156 ...opts ,
166157 baseURL : baseURL || `https://api.sfcompute.com` ,
167158 } ;
@@ -183,7 +174,7 @@ export class SFCNodes {
183174
184175 this . _options = options ;
185176
186- this . bearerToken = bearerToken ;
177+ this . apiKey = apiKey ;
187178 }
188179
189180 /**
@@ -199,7 +190,7 @@ export class SFCNodes {
199190 logLevel : this . logLevel ,
200191 fetch : this . fetch ,
201192 fetchOptions : this . fetchOptions ,
202- bearerToken : this . bearerToken ,
193+ apiKey : this . apiKey ,
203194 ...options ,
204195 } ) ;
205196 return client ;
@@ -217,23 +208,23 @@ export class SFCNodes {
217208 }
218209
219210 protected validateHeaders ( { values, nulls } : NullableHeaders ) {
220- if ( this . bearerToken && values . get ( 'authorization' ) ) {
211+ if ( this . apiKey && values . get ( 'authorization' ) ) {
221212 return ;
222213 }
223214 if ( nulls . has ( 'authorization' ) ) {
224215 return ;
225216 }
226217
227218 throw new Error (
228- 'Could not resolve authentication method. Expected the bearerToken to be set. Or for the "Authorization" headers to be explicitly omitted' ,
219+ 'Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted' ,
229220 ) ;
230221 }
231222
232223 protected async authHeaders ( opts : FinalRequestOptions ) : Promise < NullableHeaders | undefined > {
233- if ( this . bearerToken == null ) {
224+ if ( this . apiKey == null ) {
234225 return undefined ;
235226 }
236- return buildHeaders ( [ { Authorization : `Bearer ${ this . bearerToken } ` } ] ) ;
227+ return buildHeaders ( [ { Authorization : `Bearer ${ this . apiKey } ` } ] ) ;
237228 }
238229
239230 /**
@@ -750,12 +741,9 @@ export declare namespace SFCNodes {
750741
751742 export {
752743 Vms as Vms ,
753- type VmListResponse as VmListResponse ,
754744 type VmLogsResponse as VmLogsResponse ,
755- type VmReplaceResponse as VmReplaceResponse ,
756745 type VmSSHResponse as VmSSHResponse ,
757746 type VmLogsParams as VmLogsParams ,
758- type VmReplaceParams as VmReplaceParams ,
759747 type VmSSHParams as VmSSHParams ,
760748 } ;
761749
0 commit comments