@shipstatic/ship 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.d.ts CHANGED
@@ -159,9 +159,10 @@ declare class SimpleEvents {
159
159
  */
160
160
  declare class ApiHttp extends SimpleEvents {
161
161
  private readonly apiUrl;
162
- private readonly apiKey;
163
- private readonly deployToken;
164
- constructor(options: ShipClientOptions);
162
+ private readonly getAuthHeadersCallback;
163
+ constructor(options: ShipClientOptions & {
164
+ getAuthHeaders: () => Record<string, string>;
165
+ });
165
166
  /**
166
167
  * Transfer events to another client (clean intentional API)
167
168
  */
@@ -171,13 +172,9 @@ declare class ApiHttp extends SimpleEvents {
171
172
  */
172
173
  private request;
173
174
  /**
174
- * Generate auth headers
175
+ * Generate auth headers from Ship instance callback
175
176
  */
176
177
  private getAuthHeaders;
177
- /**
178
- * Check if credentials are needed
179
- */
180
- private needsCredentials;
181
178
  /**
182
179
  * Safely clone response for events
183
180
  */
@@ -236,7 +233,7 @@ declare class ApiHttp extends SimpleEvents {
236
233
  * @file Ship SDK resource implementations for deployments, domains, and accounts.
237
234
  */
238
235
 
239
- declare function createDeploymentResource(getApi: () => ApiHttp, clientDefaults?: ShipClientOptions, ensureInit?: () => Promise<void>, processInput?: (input: DeployInput, options: DeploymentOptions) => Promise<StaticFile[]>): DeploymentResource;
236
+ declare function createDeploymentResource(getApi: () => ApiHttp, clientDefaults?: ShipClientOptions, ensureInit?: () => Promise<void>, processInput?: (input: DeployInput, options: DeploymentOptions) => Promise<StaticFile[]>, hasAuth?: () => boolean): DeploymentResource;
240
237
  declare function createDomainResource(getApi: () => ApiHttp, ensureInit?: () => Promise<void>): DomainResource;
241
238
  declare function createAccountResource(getApi: () => ApiHttp, ensureInit?: () => Promise<void>): AccountResource;
242
239
  declare function createTokenResource(getApi: () => ApiHttp, ensureInit?: () => Promise<void>): TokenResource;
@@ -252,6 +249,8 @@ declare abstract class Ship$1 {
252
249
  protected readonly clientOptions: ShipClientOptions;
253
250
  protected initPromise: Promise<void> | null;
254
251
  protected _config: ConfigResponse | null;
252
+ private auth;
253
+ private readonly authHeadersCallback;
255
254
  protected _deployments: DeploymentResource;
256
255
  protected _domains: DomainResource;
257
256
  protected _account: AccountResource;
@@ -315,6 +314,30 @@ declare abstract class Ship$1 {
315
314
  * @protected
316
315
  */
317
316
  protected replaceHttpClient(newClient: ApiHttp): void;
317
+ /**
318
+ * Sets the deploy token for authentication.
319
+ * This will override any previously set API key or deploy token.
320
+ * @param token The deploy token (format: token-<64-char-hex>)
321
+ */
322
+ setDeployToken(token: string): void;
323
+ /**
324
+ * Sets the API key for authentication.
325
+ * This will override any previously set API key or deploy token.
326
+ * @param key The API key (format: ship-<64-char-hex>)
327
+ */
328
+ setApiKey(key: string): void;
329
+ /**
330
+ * Generate authorization headers based on current auth state
331
+ * Called dynamically on each request to ensure latest credentials are used
332
+ * @private
333
+ */
334
+ private getAuthHeaders;
335
+ /**
336
+ * Check if authentication credentials are configured
337
+ * Used by resources to fail fast if auth is required
338
+ * @private
339
+ */
340
+ private hasAuth;
318
341
  }
319
342
 
320
343
  /**