@discomedia/utils 1.0.65 → 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-frontend.cjs +188 -11
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +188 -11
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +234 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +234 -63
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +6 -6
- package/dist/test.js +236 -65
- package/dist/test.js.map +1 -1
- package/dist/types/alpaca-market-data-api.d.ts +10 -0
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
- package/dist/types-frontend/alpaca-market-data-api.d.ts +10 -0
- package/dist/types-frontend/alpaca-market-data-api.d.ts.map +1 -1
- package/package.json +6 -6
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
|
|
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';
|
|
@@ -1563,6 +1563,37 @@ class InvalidWebhookSignatureError extends Error {
|
|
|
1563
1563
|
super(message);
|
|
1564
1564
|
}
|
|
1565
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
|
+
}
|
|
1566
1597
|
|
|
1567
1598
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
1568
1599
|
// https://url.spec.whatwg.org/#url-scheme-string
|
|
@@ -1615,7 +1646,7 @@ const safeJSON = (text) => {
|
|
|
1615
1646
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
1616
1647
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1617
1648
|
|
|
1618
|
-
const VERSION = '6.
|
|
1649
|
+
const VERSION = '6.34.0'; // x-release-please-version
|
|
1619
1650
|
|
|
1620
1651
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
1621
1652
|
const isRunningInBrowser = () => {
|
|
@@ -2996,6 +3027,91 @@ class ConversationCursorPage extends AbstractPage {
|
|
|
2996
3027
|
}
|
|
2997
3028
|
}
|
|
2998
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
|
+
|
|
2999
3115
|
const checkFileSupport = () => {
|
|
3000
3116
|
if (typeof File === 'undefined') {
|
|
3001
3117
|
const { process } = globalThis;
|
|
@@ -8301,6 +8417,7 @@ _Webhooks_instances = new WeakSet(), _Webhooks_validateSecret = function _Webhoo
|
|
|
8301
8417
|
|
|
8302
8418
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
8303
8419
|
var _OpenAI_instances, _a$1, _OpenAI_encoder, _OpenAI_baseURLOverridden;
|
|
8420
|
+
const WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER = 'workload-identity-auth';
|
|
8304
8421
|
/**
|
|
8305
8422
|
* API Client for interfacing with the OpenAI API.
|
|
8306
8423
|
*/
|
|
@@ -8321,7 +8438,7 @@ class OpenAI {
|
|
|
8321
8438
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
8322
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.
|
|
8323
8440
|
*/
|
|
8324
|
-
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 } = {}) {
|
|
8325
8442
|
_OpenAI_instances.add(this);
|
|
8326
8443
|
_OpenAI_encoder.set(this, void 0);
|
|
8327
8444
|
/**
|
|
@@ -8376,14 +8493,21 @@ class OpenAI {
|
|
|
8376
8493
|
this.containers = new Containers(this);
|
|
8377
8494
|
this.skills = new Skills(this);
|
|
8378
8495
|
this.videos = new Videos(this);
|
|
8379
|
-
if (
|
|
8380
|
-
|
|
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.');
|
|
8381
8504
|
}
|
|
8382
8505
|
const options = {
|
|
8383
8506
|
apiKey,
|
|
8384
8507
|
organization,
|
|
8385
8508
|
project,
|
|
8386
8509
|
webhookSecret,
|
|
8510
|
+
workloadIdentity,
|
|
8387
8511
|
...opts,
|
|
8388
8512
|
baseURL: baseURL || `https://api.openai.com/v1`,
|
|
8389
8513
|
};
|
|
@@ -8405,6 +8529,9 @@ class OpenAI {
|
|
|
8405
8529
|
this.fetch = options.fetch ?? getDefaultFetch();
|
|
8406
8530
|
__classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder);
|
|
8407
8531
|
this._options = options;
|
|
8532
|
+
if (workloadIdentity) {
|
|
8533
|
+
this._workloadIdentityAuth = new WorkloadIdentityAuth(workloadIdentity, this.fetch);
|
|
8534
|
+
}
|
|
8408
8535
|
this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
|
|
8409
8536
|
this.organization = organization;
|
|
8410
8537
|
this.project = project;
|
|
@@ -8424,6 +8551,7 @@ class OpenAI {
|
|
|
8424
8551
|
fetch: this.fetch,
|
|
8425
8552
|
fetchOptions: this.fetchOptions,
|
|
8426
8553
|
apiKey: this.apiKey,
|
|
8554
|
+
workloadIdentity: this._options.workloadIdentity,
|
|
8427
8555
|
organization: this.organization,
|
|
8428
8556
|
project: this.project,
|
|
8429
8557
|
webhookSecret: this.webhookSecret,
|
|
@@ -8550,7 +8678,7 @@ class OpenAI {
|
|
|
8550
8678
|
throw new APIUserAbortError();
|
|
8551
8679
|
}
|
|
8552
8680
|
const controller = new AbortController();
|
|
8553
|
-
const response = await this.
|
|
8681
|
+
const response = await this.fetchWithAuth(url, req, timeout, controller).catch(castToError);
|
|
8554
8682
|
const headersTime = Date.now();
|
|
8555
8683
|
if (response instanceof globalThis.Error) {
|
|
8556
8684
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
@@ -8580,6 +8708,9 @@ class OpenAI {
|
|
|
8580
8708
|
durationMs: headersTime - startTime,
|
|
8581
8709
|
message: response.message,
|
|
8582
8710
|
}));
|
|
8711
|
+
if (response instanceof OAuthError || response instanceof SubjectTokenProviderError) {
|
|
8712
|
+
throw response;
|
|
8713
|
+
}
|
|
8583
8714
|
if (isTimeout) {
|
|
8584
8715
|
throw new APIConnectionTimeoutError();
|
|
8585
8716
|
}
|
|
@@ -8591,6 +8722,20 @@ class OpenAI {
|
|
|
8591
8722
|
.join('');
|
|
8592
8723
|
const responseInfo = `[${requestLogID}${retryLogStr}${specialHeaders}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
8593
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
|
+
}
|
|
8594
8739
|
const shouldRetry = await this.shouldRetry(response);
|
|
8595
8740
|
if (retriesRemaining && shouldRetry) {
|
|
8596
8741
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
@@ -8641,6 +8786,18 @@ class OpenAI {
|
|
|
8641
8786
|
const request = this.makeRequest(options, null, undefined);
|
|
8642
8787
|
return new PagePromise(this, request, Page);
|
|
8643
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
|
+
}
|
|
8644
8801
|
async fetchWithTimeout(url, init, ms, controller) {
|
|
8645
8802
|
const { signal, method, ...options } = init || {};
|
|
8646
8803
|
const abort = this._makeAbort(controller);
|
|
@@ -8737,7 +8894,13 @@ class OpenAI {
|
|
|
8737
8894
|
if ('timeout' in options)
|
|
8738
8895
|
validatePositiveInteger('timeout', options.timeout);
|
|
8739
8896
|
options.timeout = options.timeout ?? this.timeout;
|
|
8740
|
-
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
|
+
}
|
|
8741
8904
|
const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
8742
8905
|
const req = {
|
|
8743
8906
|
method,
|
|
@@ -8784,9 +8947,18 @@ class OpenAI {
|
|
|
8784
8947
|
}
|
|
8785
8948
|
buildBody({ options: { body, headers: rawHeaders } }) {
|
|
8786
8949
|
if (!body) {
|
|
8787
|
-
return { bodyHeaders: undefined, body: undefined };
|
|
8950
|
+
return { bodyHeaders: undefined, body: undefined, isStreamingBody: false };
|
|
8788
8951
|
}
|
|
8789
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);
|
|
8790
8962
|
if (
|
|
8791
8963
|
// Pass raw type verbatim
|
|
8792
8964
|
ArrayBuffer.isView(body) ||
|
|
@@ -8802,23 +8974,28 @@ class OpenAI {
|
|
|
8802
8974
|
// `URLSearchParams` -> `application/x-www-form-urlencoded`
|
|
8803
8975
|
body instanceof URLSearchParams ||
|
|
8804
8976
|
// Send chunked stream (each chunk has own `length`)
|
|
8805
|
-
|
|
8806
|
-
return { bodyHeaders: undefined, body: body };
|
|
8977
|
+
isReadableStream) {
|
|
8978
|
+
return { bodyHeaders: undefined, body: body, isStreamingBody: !isRetryableBody };
|
|
8807
8979
|
}
|
|
8808
8980
|
else if (typeof body === 'object' &&
|
|
8809
8981
|
(Symbol.asyncIterator in body ||
|
|
8810
8982
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
8811
|
-
return {
|
|
8983
|
+
return {
|
|
8984
|
+
bodyHeaders: undefined,
|
|
8985
|
+
body: ReadableStreamFrom(body),
|
|
8986
|
+
isStreamingBody: true,
|
|
8987
|
+
};
|
|
8812
8988
|
}
|
|
8813
8989
|
else if (typeof body === 'object' &&
|
|
8814
8990
|
headers.values.get('content-type') === 'application/x-www-form-urlencoded') {
|
|
8815
8991
|
return {
|
|
8816
8992
|
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
8817
8993
|
body: this.stringifyQuery(body),
|
|
8994
|
+
isStreamingBody: false,
|
|
8818
8995
|
};
|
|
8819
8996
|
}
|
|
8820
8997
|
else {
|
|
8821
|
-
return __classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers });
|
|
8998
|
+
return { ...__classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers }), isStreamingBody: false };
|
|
8822
8999
|
}
|
|
8823
9000
|
}
|
|
8824
9001
|
}
|
|
@@ -13507,6 +13684,9 @@ function requirePermessageDeflate () {
|
|
|
13507
13684
|
* acknowledge disabling of client context takeover
|
|
13508
13685
|
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
13509
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
|
|
13510
13690
|
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
13511
13691
|
* use of a custom server window size
|
|
13512
13692
|
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
@@ -13517,16 +13697,13 @@ function requirePermessageDeflate () {
|
|
|
13517
13697
|
* deflate
|
|
13518
13698
|
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
13519
13699
|
* inflate
|
|
13520
|
-
* @param {Boolean} [isServer=false] Create the instance in either server or
|
|
13521
|
-
* client mode
|
|
13522
|
-
* @param {Number} [maxPayload=0] The maximum allowed message length
|
|
13523
13700
|
*/
|
|
13524
|
-
constructor(options
|
|
13525
|
-
this._maxPayload = maxPayload | 0;
|
|
13701
|
+
constructor(options) {
|
|
13526
13702
|
this._options = options || {};
|
|
13527
13703
|
this._threshold =
|
|
13528
13704
|
this._options.threshold !== undefined ? this._options.threshold : 1024;
|
|
13529
|
-
this.
|
|
13705
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
13706
|
+
this._isServer = !!this._options.isServer;
|
|
13530
13707
|
this._deflate = null;
|
|
13531
13708
|
this._inflate = null;
|
|
13532
13709
|
|
|
@@ -16008,7 +16185,7 @@ function requireWebsocket () {
|
|
|
16008
16185
|
const https = require$$1;
|
|
16009
16186
|
const http = require$$2;
|
|
16010
16187
|
const net = require$$3$1;
|
|
16011
|
-
const tls = require$$4
|
|
16188
|
+
const tls = require$$4;
|
|
16012
16189
|
const { randomBytes, createHash } = require$$3;
|
|
16013
16190
|
const { Duplex, Readable } = require$$0$2;
|
|
16014
16191
|
const { URL } = require$$7;
|
|
@@ -16695,7 +16872,7 @@ function requireWebsocket () {
|
|
|
16695
16872
|
} else {
|
|
16696
16873
|
try {
|
|
16697
16874
|
parsedUrl = new URL(address);
|
|
16698
|
-
} catch
|
|
16875
|
+
} catch {
|
|
16699
16876
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
16700
16877
|
}
|
|
16701
16878
|
}
|
|
@@ -16757,11 +16934,11 @@ function requireWebsocket () {
|
|
|
16757
16934
|
opts.timeout = opts.handshakeTimeout;
|
|
16758
16935
|
|
|
16759
16936
|
if (opts.perMessageDeflate) {
|
|
16760
|
-
perMessageDeflate = new PerMessageDeflate(
|
|
16761
|
-
opts.perMessageDeflate
|
|
16762
|
-
false,
|
|
16763
|
-
opts.maxPayload
|
|
16764
|
-
);
|
|
16937
|
+
perMessageDeflate = new PerMessageDeflate({
|
|
16938
|
+
...opts.perMessageDeflate,
|
|
16939
|
+
isServer: false,
|
|
16940
|
+
maxPayload: opts.maxPayload
|
|
16941
|
+
});
|
|
16765
16942
|
opts.headers['Sec-WebSocket-Extensions'] = format({
|
|
16766
16943
|
[PerMessageDeflate.extensionName]: perMessageDeflate.offer()
|
|
16767
16944
|
});
|
|
@@ -17568,13 +17745,14 @@ function requireStream () {
|
|
|
17568
17745
|
|
|
17569
17746
|
requireStream();
|
|
17570
17747
|
|
|
17748
|
+
requireExtension();
|
|
17749
|
+
|
|
17750
|
+
requirePermessageDeflate();
|
|
17751
|
+
|
|
17571
17752
|
requireReceiver();
|
|
17572
17753
|
|
|
17573
17754
|
requireSender();
|
|
17574
17755
|
|
|
17575
|
-
var websocketExports = requireWebsocket();
|
|
17576
|
-
var WebSocket = /*@__PURE__*/getDefaultExportFromCjs(websocketExports);
|
|
17577
|
-
|
|
17578
17756
|
var subprotocol;
|
|
17579
17757
|
var hasRequiredSubprotocol;
|
|
17580
17758
|
|
|
@@ -17645,6 +17823,11 @@ function requireSubprotocol () {
|
|
|
17645
17823
|
return subprotocol;
|
|
17646
17824
|
}
|
|
17647
17825
|
|
|
17826
|
+
requireSubprotocol();
|
|
17827
|
+
|
|
17828
|
+
var websocketExports = requireWebsocket();
|
|
17829
|
+
var WebSocket = /*@__PURE__*/getDefaultExportFromCjs(websocketExports);
|
|
17830
|
+
|
|
17648
17831
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */
|
|
17649
17832
|
|
|
17650
17833
|
var websocketServer;
|
|
@@ -17945,11 +18128,11 @@ function requireWebsocketServer () {
|
|
|
17945
18128
|
this.options.perMessageDeflate &&
|
|
17946
18129
|
secWebSocketExtensions !== undefined
|
|
17947
18130
|
) {
|
|
17948
|
-
const perMessageDeflate = new PerMessageDeflate(
|
|
17949
|
-
this.options.perMessageDeflate,
|
|
17950
|
-
true,
|
|
17951
|
-
this.options.maxPayload
|
|
17952
|
-
);
|
|
18131
|
+
const perMessageDeflate = new PerMessageDeflate({
|
|
18132
|
+
...this.options.perMessageDeflate,
|
|
18133
|
+
isServer: true,
|
|
18134
|
+
maxPayload: this.options.maxPayload
|
|
18135
|
+
});
|
|
17953
18136
|
|
|
17954
18137
|
try {
|
|
17955
18138
|
const offers = extension.parse(secWebSocketExtensions);
|
|
@@ -18213,10 +18396,6 @@ var config = {};
|
|
|
18213
18396
|
|
|
18214
18397
|
var main = {exports: {}};
|
|
18215
18398
|
|
|
18216
|
-
var version = "17.3.1";
|
|
18217
|
-
var require$$4 = {
|
|
18218
|
-
version: version};
|
|
18219
|
-
|
|
18220
18399
|
var hasRequiredMain;
|
|
18221
18400
|
|
|
18222
18401
|
function requireMain () {
|
|
@@ -18226,25 +18405,17 @@ function requireMain () {
|
|
|
18226
18405
|
const path = require$$1$1;
|
|
18227
18406
|
const os = require$$2$1;
|
|
18228
18407
|
const crypto = require$$3;
|
|
18229
|
-
const packageJson = require$$4;
|
|
18230
|
-
|
|
18231
|
-
const version = packageJson.version;
|
|
18232
18408
|
|
|
18233
18409
|
// Array of tips to display randomly
|
|
18234
18410
|
const TIPS = [
|
|
18235
|
-
'
|
|
18236
|
-
'
|
|
18237
|
-
'
|
|
18238
|
-
'
|
|
18239
|
-
'
|
|
18240
|
-
'
|
|
18241
|
-
'
|
|
18242
|
-
'
|
|
18243
|
-
'⚙️ enable debug logging with { debug: true }',
|
|
18244
|
-
'⚙️ override existing env vars with { override: true }',
|
|
18245
|
-
'⚙️ suppress all logs with { quiet: true }',
|
|
18246
|
-
'⚙️ write to custom object with { processEnv: myObject }',
|
|
18247
|
-
'⚙️ 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\'] }'
|
|
18248
18419
|
];
|
|
18249
18420
|
|
|
18250
18421
|
// Get a random tip from the tips array
|
|
@@ -18352,15 +18523,15 @@ function requireMain () {
|
|
|
18352
18523
|
}
|
|
18353
18524
|
|
|
18354
18525
|
function _warn (message) {
|
|
18355
|
-
console.error(
|
|
18526
|
+
console.error(`⚠ ${message}`);
|
|
18356
18527
|
}
|
|
18357
18528
|
|
|
18358
18529
|
function _debug (message) {
|
|
18359
|
-
console.log(
|
|
18530
|
+
console.log(`┆ ${message}`);
|
|
18360
18531
|
}
|
|
18361
18532
|
|
|
18362
18533
|
function _log (message) {
|
|
18363
|
-
console.log(
|
|
18534
|
+
console.log(`◇ ${message}`);
|
|
18364
18535
|
}
|
|
18365
18536
|
|
|
18366
18537
|
function _dotenvKey (options) {
|
|
@@ -18454,7 +18625,7 @@ function requireMain () {
|
|
|
18454
18625
|
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
18455
18626
|
|
|
18456
18627
|
if (debug || !quiet) {
|
|
18457
|
-
_log('
|
|
18628
|
+
_log('loading env from encrypted .env.vault');
|
|
18458
18629
|
}
|
|
18459
18630
|
|
|
18460
18631
|
const parsed = DotenvModule._parseVault(options);
|
|
@@ -18483,7 +18654,7 @@ function requireMain () {
|
|
|
18483
18654
|
encoding = options.encoding;
|
|
18484
18655
|
} else {
|
|
18485
18656
|
if (debug) {
|
|
18486
|
-
_debug('
|
|
18657
|
+
_debug('no encoding is specified (UTF-8 is used by default)');
|
|
18487
18658
|
}
|
|
18488
18659
|
}
|
|
18489
18660
|
|
|
@@ -18511,7 +18682,7 @@ function requireMain () {
|
|
|
18511
18682
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
18512
18683
|
} catch (e) {
|
|
18513
18684
|
if (debug) {
|
|
18514
|
-
_debug(`
|
|
18685
|
+
_debug(`failed to load ${path} ${e.message}`);
|
|
18515
18686
|
}
|
|
18516
18687
|
lastError = e;
|
|
18517
18688
|
}
|
|
@@ -18532,13 +18703,13 @@ function requireMain () {
|
|
|
18532
18703
|
shortPaths.push(relative);
|
|
18533
18704
|
} catch (e) {
|
|
18534
18705
|
if (debug) {
|
|
18535
|
-
_debug(`
|
|
18706
|
+
_debug(`failed to load ${filePath} ${e.message}`);
|
|
18536
18707
|
}
|
|
18537
18708
|
lastError = e;
|
|
18538
18709
|
}
|
|
18539
18710
|
}
|
|
18540
18711
|
|
|
18541
|
-
_log(`
|
|
18712
|
+
_log(`injected env (${keysCount}) from ${shortPaths.join(',')} ${dim(`// tip: ${_getRandomTip()}`)}`);
|
|
18542
18713
|
}
|
|
18543
18714
|
|
|
18544
18715
|
if (lastError) {
|
|
@@ -18559,7 +18730,7 @@ function requireMain () {
|
|
|
18559
18730
|
|
|
18560
18731
|
// dotenvKey exists but .env.vault file does not exist
|
|
18561
18732
|
if (!vaultPath) {
|
|
18562
|
-
_warn(`
|
|
18733
|
+
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
|
|
18563
18734
|
|
|
18564
18735
|
return DotenvModule.configDotenv(options)
|
|
18565
18736
|
}
|
|
@@ -19089,7 +19260,7 @@ class AlpacaMarketDataAPI extends EventEmitter {
|
|
|
19089
19260
|
pageCount++;
|
|
19090
19261
|
const requestParams = {
|
|
19091
19262
|
...params,
|
|
19092
|
-
adjustment: DEFAULT_ADJUSTMENT,
|
|
19263
|
+
adjustment: params.adjustment ?? DEFAULT_ADJUSTMENT,
|
|
19093
19264
|
feed: DEFAULT_FEED,
|
|
19094
19265
|
...(pageToken && { page_token: pageToken }),
|
|
19095
19266
|
};
|