@@ -49,9 +49,9 @@ import { isEmptyObj } from './internal/utils/values';
4949
5050export interface ClientOptions {
5151 /**
52- * Defaults to process.env['SFC_API_KEY '].
52+ * Defaults to process.env['SFC_NODES_BEARER_TOKEN '].
5353 */
54- apiKey ?: string | null | undefined ;
54+ bearerToken ?: string | null | undefined ;
5555
5656 /**
5757 * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
@@ -126,7 +126,7 @@ export interface ClientOptions {
126126 * API Client for interfacing with the SFC Nodes API.
127127 */
128128export class SFCNodes {
129- apiKey : string | null ;
129+ bearerToken : string | null ;
130130
131131 baseURL : string ;
132132 maxRetries : number ;
@@ -143,7 +143,7 @@ export class SFCNodes {
143143 /**
144144 * API Client for interfacing with the SFC Nodes API.
145145 *
146- * @param {string | null | undefined } [opts.apiKey =process.env['SFC_API_KEY '] ?? null]
146+ * @param {string | null | undefined } [opts.bearerToken =process.env['SFC_NODES_BEARER_TOKEN '] ?? null]
147147 * @param {string } [opts.baseURL=process.env['SFC_NODES_BASE_URL'] ?? https://api.sfcompute.com] - Override the default base URL for the API.
148148 * @param {number } [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
149149 * @param {MergedRequestInit } [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
@@ -154,11 +154,11 @@ export class SFCNodes {
154154 */
155155 constructor ( {
156156 baseURL = readEnv ( 'SFC_NODES_BASE_URL' ) ,
157- apiKey = readEnv ( 'SFC_API_KEY ' ) ?? null ,
157+ bearerToken = readEnv ( 'SFC_NODES_BEARER_TOKEN ' ) ?? null ,
158158 ...opts
159159 } : ClientOptions = { } ) {
160160 const options : ClientOptions = {
161- apiKey ,
161+ bearerToken ,
162162 ...opts ,
163163 baseURL : baseURL || `https://api.sfcompute.com` ,
164164 } ;
@@ -180,7 +180,7 @@ export class SFCNodes {
180180
181181 this . _options = options ;
182182
183- this . apiKey = apiKey ;
183+ this . bearerToken = bearerToken ;
184184 }
185185
186186 /**
@@ -196,7 +196,7 @@ export class SFCNodes {
196196 logLevel : this . logLevel ,
197197 fetch : this . fetch ,
198198 fetchOptions : this . fetchOptions ,
199- apiKey : this . apiKey ,
199+ bearerToken : this . bearerToken ,
200200 ...options ,
201201 } ) ;
202202 return client ;
@@ -214,23 +214,23 @@ export class SFCNodes {
214214 }
215215
216216 protected validateHeaders ( { values, nulls } : NullableHeaders ) {
217- if ( this . apiKey && values . get ( 'authorization' ) ) {
217+ if ( this . bearerToken && values . get ( 'authorization' ) ) {
218218 return ;
219219 }
220220 if ( nulls . has ( 'authorization' ) ) {
221221 return ;
222222 }
223223
224224 throw new Error (
225- 'Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted' ,
225+ 'Could not resolve authentication method. Expected the bearerToken to be set. Or for the "Authorization" headers to be explicitly omitted' ,
226226 ) ;
227227 }
228228
229229 protected async authHeaders ( opts : FinalRequestOptions ) : Promise < NullableHeaders | undefined > {
230- if ( this . apiKey == null ) {
230+ if ( this . bearerToken == null ) {
231231 return undefined ;
232232 }
233- return buildHeaders ( [ { Authorization : `Bearer ${ this . apiKey } ` } ] ) ;
233+ return buildHeaders ( [ { Authorization : `Bearer ${ this . bearerToken } ` } ] ) ;
234234 }
235235
236236 /**
0 commit comments