@discomedia/utils 1.0.64 → 1.0.66

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/index.mjs CHANGED
@@ -2,7 +2,7 @@ import require$$0$3, { EventEmitter } from 'events';
2
2
  import require$$1 from 'https';
3
3
  import require$$2 from 'http';
4
4
  import require$$3$1 from 'net';
5
- import require$$4$1 from 'tls';
5
+ import require$$4 from 'tls';
6
6
  import require$$3 from 'crypto';
7
7
  import require$$0$2 from 'stream';
8
8
  import require$$7 from 'url';
@@ -1146,6 +1146,7 @@ function isOpenRouterModel(model) {
1146
1146
  const openRouterModels = [
1147
1147
  'openai/gpt-5',
1148
1148
  'openai/gpt-5-mini',
1149
+ 'openai/gpt-5.4-mini',
1149
1150
  'openai/gpt-5-nano',
1150
1151
  'openai/gpt-5.1',
1151
1152
  'openai/gpt-5.4',
@@ -1562,6 +1563,37 @@ class InvalidWebhookSignatureError extends Error {
1562
1563
  super(message);
1563
1564
  }
1564
1565
  }
1566
+ /**
1567
+ * Error thrown by the API server during OAuth token exchange.
1568
+ * Can have status codes 400, 401, or 403.
1569
+ * Other status codes from OAuth endpoints are raised as normal APIError types.
1570
+ */
1571
+ class OAuthError extends APIError {
1572
+ constructor(status, error, headers) {
1573
+ let finalMessage = 'OAuth2 authentication error';
1574
+ let error_code = undefined;
1575
+ if (error && typeof error === 'object') {
1576
+ const errorData = error;
1577
+ error_code = errorData['error'];
1578
+ const description = errorData['error_description'];
1579
+ if (description && typeof description === 'string') {
1580
+ finalMessage = description;
1581
+ }
1582
+ else if (error_code) {
1583
+ finalMessage = error_code;
1584
+ }
1585
+ }
1586
+ super(status, error, finalMessage, headers);
1587
+ this.error_code = error_code;
1588
+ }
1589
+ }
1590
+ class SubjectTokenProviderError extends OpenAIError {
1591
+ constructor(message, provider, cause) {
1592
+ super(message);
1593
+ this.provider = provider;
1594
+ this.cause = cause;
1595
+ }
1596
+ }
1565
1597
 
1566
1598
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1567
1599
  // https://url.spec.whatwg.org/#url-scheme-string
@@ -1614,7 +1646,7 @@ const safeJSON = (text) => {
1614
1646
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1615
1647
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1616
1648
 
1617
- const VERSION = '6.31.0'; // x-release-please-version
1649
+ const VERSION = '6.34.0'; // x-release-please-version
1618
1650
 
1619
1651
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1620
1652
  const isRunningInBrowser = () => {
@@ -2995,6 +3027,91 @@ class ConversationCursorPage extends AbstractPage {
2995
3027
  }
2996
3028
  }
2997
3029
 
3030
+ const SUBJECT_TOKEN_TYPES = {
3031
+ jwt: 'urn:ietf:params:oauth:token-type:jwt',
3032
+ id: 'urn:ietf:params:oauth:token-type:id_token',
3033
+ };
3034
+ const TOKEN_EXCHANGE_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:token-exchange';
3035
+ class WorkloadIdentityAuth {
3036
+ constructor(config, fetch) {
3037
+ this.cachedToken = null;
3038
+ this.refreshPromise = null;
3039
+ this.tokenExchangeUrl = 'https://auth.openai.com/oauth/token';
3040
+ this.config = config;
3041
+ this.fetch = fetch ?? getDefaultFetch();
3042
+ }
3043
+ async getToken() {
3044
+ if (!this.cachedToken || this.isTokenExpired(this.cachedToken)) {
3045
+ if (this.refreshPromise) {
3046
+ return await this.refreshPromise;
3047
+ }
3048
+ this.refreshPromise = this.refreshToken();
3049
+ try {
3050
+ const token = await this.refreshPromise;
3051
+ return token;
3052
+ }
3053
+ finally {
3054
+ this.refreshPromise = null;
3055
+ }
3056
+ }
3057
+ if (this.needsRefresh(this.cachedToken) && !this.refreshPromise) {
3058
+ this.refreshPromise = this.refreshToken().finally(() => {
3059
+ this.refreshPromise = null;
3060
+ });
3061
+ }
3062
+ return this.cachedToken.token;
3063
+ }
3064
+ async refreshToken() {
3065
+ const subjectToken = await this.config.provider.getToken();
3066
+ const response = await this.fetch(this.tokenExchangeUrl, {
3067
+ method: 'POST',
3068
+ headers: {
3069
+ 'Content-Type': 'application/json',
3070
+ },
3071
+ body: JSON.stringify({
3072
+ grant_type: TOKEN_EXCHANGE_GRANT_TYPE,
3073
+ client_id: this.config.clientId,
3074
+ subject_token: subjectToken,
3075
+ subject_token_type: SUBJECT_TOKEN_TYPES[this.config.provider.tokenType],
3076
+ identity_provider_id: this.config.identityProviderId,
3077
+ service_account_id: this.config.serviceAccountId,
3078
+ }),
3079
+ });
3080
+ if (!response.ok) {
3081
+ const errorText = await response.text();
3082
+ let body = undefined;
3083
+ try {
3084
+ body = JSON.parse(errorText);
3085
+ }
3086
+ catch { }
3087
+ if (response.status === 400 || response.status === 401 || response.status === 403) {
3088
+ throw new OAuthError(response.status, body, response.headers);
3089
+ }
3090
+ throw APIError.generate(response.status, body, `Token exchange failed with status ${response.status}`, response.headers);
3091
+ }
3092
+ const tokenResponse = (await response.json());
3093
+ const expiresIn = tokenResponse.expires_in || 3600;
3094
+ const expiresAt = Date.now() + expiresIn * 1000;
3095
+ this.cachedToken = {
3096
+ token: tokenResponse.access_token,
3097
+ expiresAt,
3098
+ };
3099
+ return tokenResponse.access_token;
3100
+ }
3101
+ isTokenExpired(cachedToken) {
3102
+ return Date.now() >= cachedToken.expiresAt;
3103
+ }
3104
+ needsRefresh(cachedToken) {
3105
+ const bufferSeconds = this.config.refreshBufferSeconds ?? 1200;
3106
+ const bufferMs = bufferSeconds * 1000;
3107
+ return Date.now() >= cachedToken.expiresAt - bufferMs;
3108
+ }
3109
+ invalidateToken() {
3110
+ this.cachedToken = null;
3111
+ this.refreshPromise = null;
3112
+ }
3113
+ }
3114
+
2998
3115
  const checkFileSupport = () => {
2999
3116
  if (typeof File === 'undefined') {
3000
3117
  const { process } = globalThis;
@@ -8300,6 +8417,7 @@ _Webhooks_instances = new WeakSet(), _Webhooks_validateSecret = function _Webhoo
8300
8417
 
8301
8418
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
8302
8419
  var _OpenAI_instances, _a$1, _OpenAI_encoder, _OpenAI_baseURLOverridden;
8420
+ const WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER = 'workload-identity-auth';
8303
8421
  /**
8304
8422
  * API Client for interfacing with the OpenAI API.
8305
8423
  */
@@ -8320,7 +8438,7 @@ class OpenAI {
8320
8438
  * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
8321
8439
  * @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
8322
8440
  */
8323
- constructor({ baseURL = readEnv('OPENAI_BASE_URL'), apiKey = readEnv('OPENAI_API_KEY'), organization = readEnv('OPENAI_ORG_ID') ?? null, project = readEnv('OPENAI_PROJECT_ID') ?? null, webhookSecret = readEnv('OPENAI_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
8441
+ constructor({ baseURL = readEnv('OPENAI_BASE_URL'), apiKey = readEnv('OPENAI_API_KEY'), organization = readEnv('OPENAI_ORG_ID') ?? null, project = readEnv('OPENAI_PROJECT_ID') ?? null, webhookSecret = readEnv('OPENAI_WEBHOOK_SECRET') ?? null, workloadIdentity, ...opts } = {}) {
8324
8442
  _OpenAI_instances.add(this);
8325
8443
  _OpenAI_encoder.set(this, void 0);
8326
8444
  /**
@@ -8375,14 +8493,21 @@ class OpenAI {
8375
8493
  this.containers = new Containers(this);
8376
8494
  this.skills = new Skills(this);
8377
8495
  this.videos = new Videos(this);
8378
- if (apiKey === undefined) {
8379
- throw new OpenAIError('Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.');
8496
+ if (workloadIdentity) {
8497
+ if (apiKey && apiKey !== WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER) {
8498
+ throw new OpenAIError('The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.');
8499
+ }
8500
+ apiKey = WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER;
8501
+ }
8502
+ else if (apiKey === undefined) {
8503
+ throw new OpenAIError('Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.');
8380
8504
  }
8381
8505
  const options = {
8382
8506
  apiKey,
8383
8507
  organization,
8384
8508
  project,
8385
8509
  webhookSecret,
8510
+ workloadIdentity,
8386
8511
  ...opts,
8387
8512
  baseURL: baseURL || `https://api.openai.com/v1`,
8388
8513
  };
@@ -8404,6 +8529,9 @@ class OpenAI {
8404
8529
  this.fetch = options.fetch ?? getDefaultFetch();
8405
8530
  __classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder);
8406
8531
  this._options = options;
8532
+ if (workloadIdentity) {
8533
+ this._workloadIdentityAuth = new WorkloadIdentityAuth(workloadIdentity, this.fetch);
8534
+ }
8407
8535
  this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
8408
8536
  this.organization = organization;
8409
8537
  this.project = project;
@@ -8423,6 +8551,7 @@ class OpenAI {
8423
8551
  fetch: this.fetch,
8424
8552
  fetchOptions: this.fetchOptions,
8425
8553
  apiKey: this.apiKey,
8554
+ workloadIdentity: this._options.workloadIdentity,
8426
8555
  organization: this.organization,
8427
8556
  project: this.project,
8428
8557
  webhookSecret: this.webhookSecret,
@@ -8549,7 +8678,7 @@ class OpenAI {
8549
8678
  throw new APIUserAbortError();
8550
8679
  }
8551
8680
  const controller = new AbortController();
8552
- const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
8681
+ const response = await this.fetchWithAuth(url, req, timeout, controller).catch(castToError);
8553
8682
  const headersTime = Date.now();
8554
8683
  if (response instanceof globalThis.Error) {
8555
8684
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
@@ -8579,6 +8708,9 @@ class OpenAI {
8579
8708
  durationMs: headersTime - startTime,
8580
8709
  message: response.message,
8581
8710
  }));
8711
+ if (response instanceof OAuthError || response instanceof SubjectTokenProviderError) {
8712
+ throw response;
8713
+ }
8582
8714
  if (isTimeout) {
8583
8715
  throw new APIConnectionTimeoutError();
8584
8716
  }
@@ -8590,6 +8722,20 @@ class OpenAI {
8590
8722
  .join('');
8591
8723
  const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
8592
8724
  if (!response.ok) {
8725
+ if (response.status === 401 &&
8726
+ this._workloadIdentityAuth &&
8727
+ !options.__metadata?.['hasStreamingBody'] &&
8728
+ !options.__metadata?.['workloadIdentityTokenRefreshed']) {
8729
+ await CancelReadableStream(response.body);
8730
+ this._workloadIdentityAuth.invalidateToken();
8731
+ return this.makeRequest({
8732
+ ...options,
8733
+ __metadata: {
8734
+ ...options.__metadata,
8735
+ workloadIdentityTokenRefreshed: true,
8736
+ },
8737
+ }, retriesRemaining, retryOfRequestLogID ?? requestLogID);
8738
+ }
8593
8739
  const shouldRetry = await this.shouldRetry(response);
8594
8740
  if (retriesRemaining && shouldRetry) {
8595
8741
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
@@ -8640,6 +8786,18 @@ class OpenAI {
8640
8786
  const request = this.makeRequest(options, null, undefined);
8641
8787
  return new PagePromise(this, request, Page);
8642
8788
  }
8789
+ async fetchWithAuth(url, init, timeout, controller) {
8790
+ if (this._workloadIdentityAuth) {
8791
+ const headers = init.headers;
8792
+ const authHeader = headers.get('Authorization');
8793
+ if (!authHeader || authHeader === `Bearer ${WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER}`) {
8794
+ const token = await this._workloadIdentityAuth.getToken();
8795
+ headers.set('Authorization', `Bearer ${token}`);
8796
+ }
8797
+ }
8798
+ const response = await this.fetchWithTimeout(url, init, timeout, controller);
8799
+ return response;
8800
+ }
8643
8801
  async fetchWithTimeout(url, init, ms, controller) {
8644
8802
  const { signal, method, ...options } = init || {};
8645
8803
  const abort = this._makeAbort(controller);
@@ -8736,7 +8894,13 @@ class OpenAI {
8736
8894
  if ('timeout' in options)
8737
8895
  validatePositiveInteger('timeout', options.timeout);
8738
8896
  options.timeout = options.timeout ?? this.timeout;
8739
- const { bodyHeaders, body } = this.buildBody({ options });
8897
+ const { bodyHeaders, body, isStreamingBody } = this.buildBody({ options });
8898
+ if (isStreamingBody) {
8899
+ inputOptions.__metadata = {
8900
+ ...inputOptions.__metadata,
8901
+ hasStreamingBody: true,
8902
+ };
8903
+ }
8740
8904
  const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
8741
8905
  const req = {
8742
8906
  method,
@@ -8783,9 +8947,18 @@ class OpenAI {
8783
8947
  }
8784
8948
  buildBody({ options: { body, headers: rawHeaders } }) {
8785
8949
  if (!body) {
8786
- return { bodyHeaders: undefined, body: undefined };
8950
+ return { bodyHeaders: undefined, body: undefined, isStreamingBody: false };
8787
8951
  }
8788
8952
  const headers = buildHeaders([rawHeaders]);
8953
+ const isReadableStream = typeof globalThis.ReadableStream !== 'undefined' &&
8954
+ body instanceof globalThis.ReadableStream;
8955
+ const isRetryableBody = !isReadableStream &&
8956
+ (typeof body === 'string' ||
8957
+ body instanceof ArrayBuffer ||
8958
+ ArrayBuffer.isView(body) ||
8959
+ (typeof globalThis.Blob !== 'undefined' && body instanceof globalThis.Blob) ||
8960
+ body instanceof URLSearchParams ||
8961
+ body instanceof FormData);
8789
8962
  if (
8790
8963
  // Pass raw type verbatim
8791
8964
  ArrayBuffer.isView(body) ||
@@ -8801,23 +8974,28 @@ class OpenAI {
8801
8974
  // `URLSearchParams` -> `application/x-www-form-urlencoded`
8802
8975
  body instanceof URLSearchParams ||
8803
8976
  // Send chunked stream (each chunk has own `length`)
8804
- (globalThis.ReadableStream && body instanceof globalThis.ReadableStream)) {
8805
- return { bodyHeaders: undefined, body: body };
8977
+ isReadableStream) {
8978
+ return { bodyHeaders: undefined, body: body, isStreamingBody: !isRetryableBody };
8806
8979
  }
8807
8980
  else if (typeof body === 'object' &&
8808
8981
  (Symbol.asyncIterator in body ||
8809
8982
  (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
8810
- return { bodyHeaders: undefined, body: ReadableStreamFrom(body) };
8983
+ return {
8984
+ bodyHeaders: undefined,
8985
+ body: ReadableStreamFrom(body),
8986
+ isStreamingBody: true,
8987
+ };
8811
8988
  }
8812
8989
  else if (typeof body === 'object' &&
8813
8990
  headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
8814
8991
  return {
8815
8992
  bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
8816
8993
  body: this.stringifyQuery(body),
8994
+ isStreamingBody: false,
8817
8995
  };
8818
8996
  }
8819
8997
  else {
8820
- return __classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers });
8998
+ return { ...__classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers }), isStreamingBody: false };
8821
8999
  }
8822
9000
  }
8823
9001
  }
@@ -11700,6 +11878,11 @@ const openAiModelCosts = {
11700
11878
  cacheHitCost: 0.025 / 1_000_000,
11701
11879
  outputCost: 2 / 1_000_000,
11702
11880
  },
11881
+ 'gpt-5.4-mini': {
11882
+ inputCost: 0.25 / 1_000_000,
11883
+ cacheHitCost: 0.025 / 1_000_000,
11884
+ outputCost: 2 / 1_000_000,
11885
+ },
11703
11886
  'gpt-5-nano': {
11704
11887
  inputCost: 0.05 / 1_000_000,
11705
11888
  cacheHitCost: 0.005 / 1_000_000,
@@ -12210,6 +12393,7 @@ const isSupportedModel = (model) => {
12210
12393
  'gpt-4.1-nano',
12211
12394
  'gpt-5',
12212
12395
  'gpt-5-mini',
12396
+ 'gpt-5.4-mini',
12213
12397
  'gpt-5-nano',
12214
12398
  'gpt-5.1',
12215
12399
  'gpt-5.4',
@@ -12238,6 +12422,7 @@ function supportsTemperature(model) {
12238
12422
  'o3',
12239
12423
  'gpt-5',
12240
12424
  'gpt-5-mini',
12425
+ 'gpt-5.4-mini',
12241
12426
  'gpt-5-nano',
12242
12427
  'gpt-5.1',
12243
12428
  'gpt-5.4',
@@ -12267,6 +12452,7 @@ function isGPT5Model(model) {
12267
12452
  const gpt5Models = [
12268
12453
  'gpt-5',
12269
12454
  'gpt-5-mini',
12455
+ 'gpt-5.4-mini',
12270
12456
  'gpt-5-nano',
12271
12457
  'gpt-5.1',
12272
12458
  'gpt-5.4',
@@ -12576,6 +12762,7 @@ const MULTIMODAL_VISION_MODELS = new Set([
12576
12762
  'gpt-4o',
12577
12763
  'gpt-5',
12578
12764
  'gpt-5-mini',
12765
+ 'gpt-5.4-mini',
12579
12766
  'gpt-5-nano',
12580
12767
  'gpt-5.1',
12581
12768
  'gpt-5.4',
@@ -13497,6 +13684,9 @@ function requirePermessageDeflate () {
13497
13684
  * acknowledge disabling of client context takeover
13498
13685
  * @param {Number} [options.concurrencyLimit=10] The number of concurrent
13499
13686
  * calls to zlib
13687
+ * @param {Boolean} [options.isServer=false] Create the instance in either
13688
+ * server or client mode
13689
+ * @param {Number} [options.maxPayload=0] The maximum allowed message length
13500
13690
  * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
13501
13691
  * use of a custom server window size
13502
13692
  * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
@@ -13507,16 +13697,13 @@ function requirePermessageDeflate () {
13507
13697
  * deflate
13508
13698
  * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
13509
13699
  * inflate
13510
- * @param {Boolean} [isServer=false] Create the instance in either server or
13511
- * client mode
13512
- * @param {Number} [maxPayload=0] The maximum allowed message length
13513
13700
  */
13514
- constructor(options, isServer, maxPayload) {
13515
- this._maxPayload = maxPayload | 0;
13701
+ constructor(options) {
13516
13702
  this._options = options || {};
13517
13703
  this._threshold =
13518
13704
  this._options.threshold !== undefined ? this._options.threshold : 1024;
13519
- this._isServer = !!isServer;
13705
+ this._maxPayload = this._options.maxPayload | 0;
13706
+ this._isServer = !!this._options.isServer;
13520
13707
  this._deflate = null;
13521
13708
  this._inflate = null;
13522
13709
 
@@ -15998,7 +16185,7 @@ function requireWebsocket () {
15998
16185
  const https = require$$1;
15999
16186
  const http = require$$2;
16000
16187
  const net = require$$3$1;
16001
- const tls = require$$4$1;
16188
+ const tls = require$$4;
16002
16189
  const { randomBytes, createHash } = require$$3;
16003
16190
  const { Duplex, Readable } = require$$0$2;
16004
16191
  const { URL } = require$$7;
@@ -16685,7 +16872,7 @@ function requireWebsocket () {
16685
16872
  } else {
16686
16873
  try {
16687
16874
  parsedUrl = new URL(address);
16688
- } catch (e) {
16875
+ } catch {
16689
16876
  throw new SyntaxError(`Invalid URL: ${address}`);
16690
16877
  }
16691
16878
  }
@@ -16747,11 +16934,11 @@ function requireWebsocket () {
16747
16934
  opts.timeout = opts.handshakeTimeout;
16748
16935
 
16749
16936
  if (opts.perMessageDeflate) {
16750
- perMessageDeflate = new PerMessageDeflate(
16751
- opts.perMessageDeflate !== true ? opts.perMessageDeflate : {},
16752
- false,
16753
- opts.maxPayload
16754
- );
16937
+ perMessageDeflate = new PerMessageDeflate({
16938
+ ...opts.perMessageDeflate,
16939
+ isServer: false,
16940
+ maxPayload: opts.maxPayload
16941
+ });
16755
16942
  opts.headers['Sec-WebSocket-Extensions'] = format({
16756
16943
  [PerMessageDeflate.extensionName]: perMessageDeflate.offer()
16757
16944
  });
@@ -17558,13 +17745,14 @@ function requireStream () {
17558
17745
 
17559
17746
  requireStream();
17560
17747
 
17748
+ requireExtension();
17749
+
17750
+ requirePermessageDeflate();
17751
+
17561
17752
  requireReceiver();
17562
17753
 
17563
17754
  requireSender();
17564
17755
 
17565
- var websocketExports = requireWebsocket();
17566
- var WebSocket = /*@__PURE__*/getDefaultExportFromCjs(websocketExports);
17567
-
17568
17756
  var subprotocol;
17569
17757
  var hasRequiredSubprotocol;
17570
17758
 
@@ -17635,6 +17823,11 @@ function requireSubprotocol () {
17635
17823
  return subprotocol;
17636
17824
  }
17637
17825
 
17826
+ requireSubprotocol();
17827
+
17828
+ var websocketExports = requireWebsocket();
17829
+ var WebSocket = /*@__PURE__*/getDefaultExportFromCjs(websocketExports);
17830
+
17638
17831
  /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */
17639
17832
 
17640
17833
  var websocketServer;
@@ -17935,11 +18128,11 @@ function requireWebsocketServer () {
17935
18128
  this.options.perMessageDeflate &&
17936
18129
  secWebSocketExtensions !== undefined
17937
18130
  ) {
17938
- const perMessageDeflate = new PerMessageDeflate(
17939
- this.options.perMessageDeflate,
17940
- true,
17941
- this.options.maxPayload
17942
- );
18131
+ const perMessageDeflate = new PerMessageDeflate({
18132
+ ...this.options.perMessageDeflate,
18133
+ isServer: true,
18134
+ maxPayload: this.options.maxPayload
18135
+ });
17943
18136
 
17944
18137
  try {
17945
18138
  const offers = extension.parse(secWebSocketExtensions);
@@ -18203,10 +18396,6 @@ var config = {};
18203
18396
 
18204
18397
  var main = {exports: {}};
18205
18398
 
18206
- var version = "17.3.1";
18207
- var require$$4 = {
18208
- version: version};
18209
-
18210
18399
  var hasRequiredMain;
18211
18400
 
18212
18401
  function requireMain () {
@@ -18216,25 +18405,17 @@ function requireMain () {
18216
18405
  const path = require$$1$1;
18217
18406
  const os = require$$2$1;
18218
18407
  const crypto = require$$3;
18219
- const packageJson = require$$4;
18220
-
18221
- const version = packageJson.version;
18222
18408
 
18223
18409
  // Array of tips to display randomly
18224
18410
  const TIPS = [
18225
- '🔐 encrypt with Dotenvx: https://dotenvx.com',
18226
- '🔐 prevent committing .env to code: https://dotenvx.com/precommit',
18227
- '🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
18228
- '🤖 agentic secret storage: https://dotenvx.com/as2',
18229
- '⚡️ secrets for agents: https://dotenvx.com/as2',
18230
- '🛡️ auth for agents: https://vestauth.com',
18231
- '🛠️ run anywhere with `dotenvx run -- yourcommand`',
18232
- '⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
18233
- '⚙️ enable debug logging with { debug: true }',
18234
- '⚙️ override existing env vars with { override: true }',
18235
- '⚙️ suppress all logs with { quiet: true }',
18236
- '⚙️ write to custom object with { processEnv: myObject }',
18237
- '⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
18411
+ ' encrypted .env [www.dotenvx.com]',
18412
+ ' secrets for agents [www.dotenvx.com]',
18413
+ ' auth for agents [www.vestauth.com]',
18414
+ ' custom filepath { path: \'/custom/path/.env\' }',
18415
+ ' enable debugging { debug: true }',
18416
+ ' override existing { override: true }',
18417
+ ' suppress logs { quiet: true }',
18418
+ ' multiple files { path: [\'.env.local\', \'.env\'] }'
18238
18419
  ];
18239
18420
 
18240
18421
  // Get a random tip from the tips array
@@ -18342,15 +18523,15 @@ function requireMain () {
18342
18523
  }
18343
18524
 
18344
18525
  function _warn (message) {
18345
- console.error(`[dotenv@${version}][WARN] ${message}`);
18526
+ console.error(`⚠ ${message}`);
18346
18527
  }
18347
18528
 
18348
18529
  function _debug (message) {
18349
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
18530
+ console.log(`┆ ${message}`);
18350
18531
  }
18351
18532
 
18352
18533
  function _log (message) {
18353
- console.log(`[dotenv@${version}] ${message}`);
18534
+ console.log(`◇ ${message}`);
18354
18535
  }
18355
18536
 
18356
18537
  function _dotenvKey (options) {
@@ -18444,7 +18625,7 @@ function requireMain () {
18444
18625
  const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
18445
18626
 
18446
18627
  if (debug || !quiet) {
18447
- _log('Loading env from encrypted .env.vault');
18628
+ _log('loading env from encrypted .env.vault');
18448
18629
  }
18449
18630
 
18450
18631
  const parsed = DotenvModule._parseVault(options);
@@ -18473,7 +18654,7 @@ function requireMain () {
18473
18654
  encoding = options.encoding;
18474
18655
  } else {
18475
18656
  if (debug) {
18476
- _debug('No encoding is specified. UTF-8 is used by default');
18657
+ _debug('no encoding is specified (UTF-8 is used by default)');
18477
18658
  }
18478
18659
  }
18479
18660
 
@@ -18501,7 +18682,7 @@ function requireMain () {
18501
18682
  DotenvModule.populate(parsedAll, parsed, options);
18502
18683
  } catch (e) {
18503
18684
  if (debug) {
18504
- _debug(`Failed to load ${path} ${e.message}`);
18685
+ _debug(`failed to load ${path} ${e.message}`);
18505
18686
  }
18506
18687
  lastError = e;
18507
18688
  }
@@ -18522,13 +18703,13 @@ function requireMain () {
18522
18703
  shortPaths.push(relative);
18523
18704
  } catch (e) {
18524
18705
  if (debug) {
18525
- _debug(`Failed to load ${filePath} ${e.message}`);
18706
+ _debug(`failed to load ${filePath} ${e.message}`);
18526
18707
  }
18527
18708
  lastError = e;
18528
18709
  }
18529
18710
  }
18530
18711
 
18531
- _log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`-- tip: ${_getRandomTip()}`)}`);
18712
+ _log(`injected env (${keysCount}) from ${shortPaths.join(',')} ${dim(`// tip: ${_getRandomTip()}`)}`);
18532
18713
  }
18533
18714
 
18534
18715
  if (lastError) {
@@ -18549,7 +18730,7 @@ function requireMain () {
18549
18730
 
18550
18731
  // dotenvKey exists but .env.vault file does not exist
18551
18732
  if (!vaultPath) {
18552
- _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
18733
+ _warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
18553
18734
 
18554
18735
  return DotenvModule.configDotenv(options)
18555
18736
  }
@@ -19079,7 +19260,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
19079
19260
  pageCount++;
19080
19261
  const requestParams = {
19081
19262
  ...params,
19082
- adjustment: DEFAULT_ADJUSTMENT,
19263
+ adjustment: params.adjustment ?? DEFAULT_ADJUSTMENT,
19083
19264
  feed: DEFAULT_FEED,
19084
19265
  ...(pageToken && { page_token: pageToken }),
19085
19266
  };