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