Initial project import

This commit is contained in:
drjones
2026-06-13 17:36:44 -07:00
commit ad2a18cc8d
18471 changed files with 4497570 additions and 0 deletions

27
node_modules/stripe/esm/net/FetchHttpClient.d.ts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import { RequestHeaders, ResponseHeaders } from '../Types.js';
import { HttpClient, HttpClientResponse, FetchHttpClientInterface, FetchHttpClientResponseInterface } from './HttpClient.js';
/**
* HTTP client which uses a `fetch` function to issue requests.
*
* By default relies on the global `fetch` function, but an optional function
* can be passed in. If passing in a function, it is expected to match the Web
* Fetch API. As an example, this could be the function provided by the
* node-fetch package (https://github.com/node-fetch/node-fetch).
*/
export declare class FetchHttpClient extends HttpClient implements FetchHttpClientInterface {
private readonly _fetchFn;
constructor(fetchFn?: typeof fetch);
private static makeFetchWithRaceTimeout;
private static makeFetchWithAbortTimeout;
/** @override. */
getClientName(): string;
makeRequest(host: string, port: string, path: string, method: string, headers: RequestHeaders, requestData: string, protocol: string, timeout: number): Promise<FetchHttpClientResponseInterface>;
}
export declare class FetchHttpClientResponse extends HttpClientResponse implements FetchHttpClientResponseInterface {
_res: Response;
constructor(res: Response);
getRawResponse(): Response;
toStream(streamCompleteCallback: () => void): ReadableStream<Uint8Array> | null;
toJSON(): Promise<any>;
static _transformHeadersToObject(headers: Headers): ResponseHeaders;
}

154
node_modules/stripe/esm/net/FetchHttpClient.js generated vendored Normal file
View File

@@ -0,0 +1,154 @@
import { parseHeadersForFetch } from '../utils.js';
import { HttpClient, HttpClientResponse, } from './HttpClient.js';
/**
* HTTP client which uses a `fetch` function to issue requests.
*
* By default relies on the global `fetch` function, but an optional function
* can be passed in. If passing in a function, it is expected to match the Web
* Fetch API. As an example, this could be the function provided by the
* node-fetch package (https://github.com/node-fetch/node-fetch).
*/
export class FetchHttpClient extends HttpClient {
constructor(fetchFn) {
super();
// Default to global fetch if available
if (!fetchFn) {
if (!globalThis.fetch) {
throw new Error('fetch() function not provided and is not defined in the global scope. ' +
'You must provide a fetch implementation.');
}
fetchFn = globalThis.fetch;
}
// Both timeout behaviors differs from Node:
// - Fetch uses a single timeout for the entire length of the request.
// - Node is more fine-grained and resets the timeout after each stage of the request.
if (globalThis.AbortController) {
// Utilise native AbortController if available
// AbortController was added in Node v15.0.0, v14.17.0
this._fetchFn = FetchHttpClient.makeFetchWithAbortTimeout(fetchFn);
}
else {
// Fall back to racing against a timeout promise if not available in the runtime
// This does not actually cancel the underlying fetch operation or resources
this._fetchFn = FetchHttpClient.makeFetchWithRaceTimeout(fetchFn);
}
}
static makeFetchWithRaceTimeout(fetchFn) {
return (url, init, timeout) => {
let pendingTimeoutId;
const timeoutPromise = new Promise((_, reject) => {
pendingTimeoutId = setTimeout(() => {
pendingTimeoutId = null;
reject(HttpClient.makeTimeoutError());
}, timeout);
});
const fetchPromise = fetchFn(url, init);
return Promise.race([fetchPromise, timeoutPromise]).finally(() => {
if (pendingTimeoutId) {
clearTimeout(pendingTimeoutId);
}
});
};
}
static makeFetchWithAbortTimeout(fetchFn) {
return async (url, init, timeout) => {
// Use AbortController because AbortSignal.timeout() was added later in Node v17.3.0, v16.14.0
const abort = new AbortController();
let timeoutId = setTimeout(() => {
timeoutId = null;
abort.abort(HttpClient.makeTimeoutError());
}, timeout);
try {
return await fetchFn(url, {
...init,
signal: abort.signal,
});
}
catch (err) {
// Some implementations, like node-fetch, do not respect the reason passed to AbortController.abort()
// and instead it always throws an AbortError
// We catch this case to normalise all timeout errors
if (err.name === 'AbortError') {
throw HttpClient.makeTimeoutError();
}
else {
throw err;
}
}
finally {
if (timeoutId) {
clearTimeout(timeoutId);
}
}
};
}
/** @override. */
getClientName() {
return 'fetch';
}
async makeRequest(host, port, path, method, headers, requestData, protocol, timeout) {
const isInsecureConnection = protocol === 'http';
if (!path.startsWith('/')) {
throw new Error(`Only relative paths are supported, got: "${path}"`);
}
const url = new URL(`${isInsecureConnection ? 'http' : 'https'}://${host}${path}`);
url.port = port;
// For methods which expect payloads, we should always pass a body value
// even when it is empty. Without this, some JS runtimes (eg. Deno) will
// inject a second Content-Length header. See https://github.com/stripe/stripe-node/issues/1519
// for more details.
const methodHasPayload = method == 'POST' || method == 'PUT' || method == 'PATCH';
const body = requestData || (methodHasPayload ? '' : undefined);
const res = await this._fetchFn(url.toString(), {
method,
headers: parseHeadersForFetch(headers),
body: body,
}, timeout);
return new FetchHttpClientResponse(res);
}
}
export class FetchHttpClientResponse extends HttpClientResponse {
constructor(res) {
super(res.status, FetchHttpClientResponse._transformHeadersToObject(res.headers));
this._res = res;
}
getRawResponse() {
return this._res;
}
toStream(streamCompleteCallback) {
// Unfortunately `fetch` does not have event handlers for when the stream is
// completely read. We therefore invoke the streamCompleteCallback right
// away. This callback emits a response event with metadata and completes
// metrics, so it's ok to do this without waiting for the stream to be
// completely read.
streamCompleteCallback();
// Fetch's `body` property is expected to be a readable stream of the body.
return this._res.body;
}
toJSON() {
return this._res.text().then((text) => {
try {
return JSON.parse(text);
}
catch (e) {
if (e instanceof Error) {
e.rawBody = text;
}
throw e;
}
});
}
static _transformHeadersToObject(headers) {
// Fetch uses a Headers instance so this must be converted to a barebones
// JS object to meet the HttpClient interface.
const headersObj = {};
for (const entry of headers) {
if (!Array.isArray(entry) || entry.length != 2) {
throw new Error('Response objects produced by the fetch function given to FetchHttpClient do not have an iterable headers map. Response#headers should be an iterable object.');
}
headersObj[entry[0]] = entry[1];
}
return headersObj;
}
}
//# sourceMappingURL=FetchHttpClient.js.map

1
node_modules/stripe/esm/net/FetchHttpClient.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"FetchHttpClient.js","sourceRoot":"","sources":["../../src/net/FetchHttpClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,UAAU,EACV,kBAAkB,GAGnB,MAAM,iBAAiB,CAAC;AAQzB;;;;;;;GAOG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAI7C,YAAY,OAAsB;QAChC,KAAK,E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AAC,IAAI,EAAE,EAAE;YACpC,IAAI;gBACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aACzB;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,CAAC,YAAY,KAAK,EAAE;oBACrB,CAAS,CAAC,OAAO,GAAG,IAAI,CAAC;iBAC3B;gBACD,MAAM,CAAC,CAAC;aACT;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,OAAgB;QAC/C,yEAAyE;QACzE,8CAA8C;QAC9C,MAAM,UAAU,GAAoB,EAAE,CAAC;QACvC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;gBAC9C,MAAM,IAAI,KAAK,CACb,8JAA8J,CAC/J,CAAC;aACH;YAED,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SACjC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}

63
node_modules/stripe/esm/net/HttpClient.d.ts generated vendored Normal file
View File

@@ -0,0 +1,63 @@
/// <reference types="node" />
import { RequestHeaders, ResponseHeaders } from '../Types.js';
type TimeoutError = TypeError & {
code?: string;
};
export interface HttpClientInterface {
getClientName: () => string;
makeRequest: (host: string, port: string, path: string, method: string, headers: RequestHeaders, requestData: string, protocol: string, timeout: number) => Promise<HttpClientResponseInterface>;
}
export interface HttpClientResponseInterface {
getStatusCode: () => number;
getHeaders: () => ResponseHeaders;
getRawResponse: () => unknown;
toStream: (streamCompleteCallback: () => void) => unknown;
toJSON: () => Promise<any>;
}
/**
* Interface for Node HTTP client with Node-specific stream types.
*/
export interface NodeHttpClientInterface extends HttpClientInterface {
makeRequest: (host: string, port: string, path: string, method: string, headers: RequestHeaders, requestData: string, protocol: string, timeout: number) => Promise<NodeHttpClientResponseInterface>;
}
export interface NodeHttpClientResponseInterface extends HttpClientResponseInterface {
toStream: (streamCompleteCallback: () => void) => NodeJS.ReadableStream;
}
/**
* Interface for Fetch HTTP client with Web Streams API types.
*/
export interface FetchHttpClientInterface extends HttpClientInterface {
makeRequest: (host: string, port: string, path: string, method: string, headers: RequestHeaders, requestData: string, protocol: string, timeout: number) => Promise<FetchHttpClientResponseInterface>;
}
export interface FetchHttpClientResponseInterface extends HttpClientResponseInterface {
toStream: (streamCompleteCallback: () => void) => ReadableStream<Uint8Array> | null;
}
/**
* Encapsulates the logic for issuing a request to the Stripe API.
*
* A custom HTTP client should should implement:
* 1. A response class which extends HttpClientResponse and wraps around their
* own internal representation of a response.
* 2. A client class which extends HttpClient and implements all methods,
* returning their own response class when making requests.
*/
export declare class HttpClient implements HttpClientInterface {
static CONNECTION_CLOSED_ERROR_CODES: string[];
static TIMEOUT_ERROR_CODE: string;
/** The client name used for diagnostics. */
getClientName(): string;
makeRequest(host: string, port: string, path: string, method: string, headers: RequestHeaders, requestData: string, protocol: string, timeout: number): Promise<HttpClientResponseInterface>;
/** Helper to make a consistent timeout error across implementations. */
static makeTimeoutError(): TimeoutError;
}
export declare class HttpClientResponse implements HttpClientResponseInterface {
_statusCode: number;
_headers: ResponseHeaders;
constructor(statusCode: number, headers: ResponseHeaders);
getStatusCode(): number;
getHeaders(): ResponseHeaders;
getRawResponse(): unknown;
toStream(streamCompleteCallback: () => void): unknown;
toJSON(): any;
}
export {};

49
node_modules/stripe/esm/net/HttpClient.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
/**
* Encapsulates the logic for issuing a request to the Stripe API.
*
* A custom HTTP client should should implement:
* 1. A response class which extends HttpClientResponse and wraps around their
* own internal representation of a response.
* 2. A client class which extends HttpClient and implements all methods,
* returning their own response class when making requests.
*/
export class HttpClient {
/** The client name used for diagnostics. */
getClientName() {
throw new Error('getClientName not implemented.');
}
makeRequest(host, port, path, method, headers, requestData, protocol, timeout) {
throw new Error('makeRequest not implemented.');
}
/** Helper to make a consistent timeout error across implementations. */
static makeTimeoutError() {
const timeoutErr = new TypeError(HttpClient.TIMEOUT_ERROR_CODE);
timeoutErr.code = HttpClient.TIMEOUT_ERROR_CODE;
return timeoutErr;
}
}
// Public API accessible via Stripe.HttpClient
HttpClient.CONNECTION_CLOSED_ERROR_CODES = ['ECONNRESET', 'EPIPE'];
HttpClient.TIMEOUT_ERROR_CODE = 'ETIMEDOUT';
export class HttpClientResponse {
constructor(statusCode, headers) {
this._statusCode = statusCode;
this._headers = headers;
}
getStatusCode() {
return this._statusCode;
}
getHeaders() {
return this._headers;
}
getRawResponse() {
throw new Error('getRawResponse not implemented.');
}
toStream(streamCompleteCallback) {
throw new Error('toStream not implemented.');
}
toJSON() {
throw new Error('toJSON not implemented.');
}
}
//# sourceMappingURL=HttpClient.js.map

1
node_modules/stripe/esm/net/HttpClient.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"HttpClient.js","sourceRoot":"","sources":["../../src/net/HttpClient.ts"],"names":[],"mappings":"AAwEA;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAU;IAIrB,4CAA4C;IAC5C,aAAa;QACX,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,WAAW,CACT,IAAY,EACZ,IAAY,EACZ,IAAY,EACZ,MAAc,EACd,OAAuB,EACvB,WAAmB,EACnB,QAAgB,EAChB,OAAe;QAEf,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,wEAAwE;IACxE,MAAM,CAAC,gBAAgB;QACrB,MAAM,UAAU,GAAiB,IAAI,SAAS,CAC5C,UAAU,CAAC,kBAAkB,CAC9B,CAAC;QACF,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,kBAAkB,CAAC;QAChD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAED,8CAA8C;AAC9C,UAAU,CAAC,6BAA6B,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AACnE,UAAU,CAAC,kBAAkB,GAAG,WAAW,CAAC;AAE5C,MAAM,OAAO,kBAAkB;IAI7B,YAAY,UAAkB,EAAE,OAAwB;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,cAAc;QACZ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,QAAQ,CAAC,sBAAkC;QACzC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF"}

24
node_modules/stripe/esm/net/NodeHttpClient.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
/// <reference types="node" />
/// <reference types="node" />
import * as http_ from 'http';
import * as https_ from 'https';
import { RequestHeaders } from '../Types.js';
import { HttpClient, HttpClientResponse, NodeHttpClientInterface, NodeHttpClientResponseInterface } from './HttpClient.js';
/**
* HTTP client which uses the Node `http` and `https` packages to issue
* requests.`
*/
export declare class NodeHttpClient extends HttpClient implements NodeHttpClientInterface {
_agent?: http_.Agent | https_.Agent | undefined;
constructor(agent?: http_.Agent | https_.Agent);
/** @override. */
getClientName(): string;
makeRequest(host: string, port: string, path: string, method: string, headers: RequestHeaders, requestData: string, protocol: string, timeout: number): Promise<NodeHttpClientResponseInterface>;
}
export declare class NodeHttpClientResponse extends HttpClientResponse implements NodeHttpClientResponseInterface {
_res: http_.IncomingMessage;
constructor(res: http_.IncomingMessage);
getRawResponse(): http_.IncomingMessage;
toStream(streamCompleteCallback: () => void): http_.IncomingMessage;
toJSON(): any;
}

107
node_modules/stripe/esm/net/NodeHttpClient.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
import * as http_ from 'http';
import * as https_ from 'https';
import { HttpClient, HttpClientResponse, } from './HttpClient.js';
// `import * as http_ from 'http'` creates a "Module Namespace Exotic Object"
// which is immune to monkey-patching, whereas http_.default (in an ES Module context)
// will resolve to the same thing as require('http'), which is
// monkey-patchable. We care about this because users in their test
// suites might be using a library like "nock" which relies on the ability
// to monkey-patch and intercept calls to http.request.
const http = http_.default || http_;
const https = https_.default || https_;
const defaultHttpAgent = new http.Agent({ keepAlive: true });
const defaultHttpsAgent = new https.Agent({ keepAlive: true });
/**
* HTTP client which uses the Node `http` and `https` packages to issue
* requests.`
*/
export class NodeHttpClient extends HttpClient {
constructor(agent) {
super();
this._agent = agent;
}
/** @override. */
getClientName() {
return 'node';
}
makeRequest(host, port, path, method, headers, requestData, protocol, timeout) {
const isInsecureConnection = protocol === 'http';
let agent = this._agent;
if (!agent) {
agent = isInsecureConnection ? defaultHttpAgent : defaultHttpsAgent;
}
const requestPromise = new Promise((resolve, reject) => {
const req = (isInsecureConnection ? http : https).request({
host: host,
port: port,
path,
method,
agent,
headers,
ciphers: 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5',
});
req.setTimeout(timeout, () => {
req.destroy(HttpClient.makeTimeoutError());
});
req.on('response', (res) => {
resolve(new NodeHttpClientResponse(res));
});
req.on('error', (error) => {
reject(error);
});
req.once('socket', (socket) => {
if (socket.connecting) {
socket.once(isInsecureConnection ? 'connect' : 'secureConnect', () => {
// Send payload; we're safe:
req.write(requestData);
req.end();
});
}
else {
// we're already connected
req.write(requestData);
req.end();
}
});
});
return requestPromise;
}
}
export class NodeHttpClientResponse extends HttpClientResponse {
constructor(res) {
// @ts-ignore
super(res.statusCode, res.headers || {});
this._res = res;
}
getRawResponse() {
return this._res;
}
toStream(streamCompleteCallback) {
// The raw response is itself the stream, so we just return that. To be
// backwards compatible, we should invoke the streamCompleteCallback only
// once the stream has been fully consumed.
this._res.once('end', () => streamCompleteCallback());
return this._res;
}
toJSON() {
return new Promise((resolve, reject) => {
let response = '';
this._res.setEncoding('utf8');
this._res.on('data', (chunk) => {
response += chunk;
});
this._res.once('end', () => {
try {
resolve(JSON.parse(response));
}
catch (e) {
if (e instanceof Error) {
e.rawBody = response;
}
reject(e);
}
});
});
}
}
//# sourceMappingURL=NodeHttpClient.js.map

1
node_modules/stripe/esm/net/NodeHttpClient.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeHttpClient.js","sourceRoot":"","sources":["../../src/net/NodeHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,MAAM,MAAM,OAAO,CAAC;AAEhC,OAAO,EACL,UAAU,EACV,kBAAkB,GAGnB,MAAM,iBAAiB,CAAC;AAEzB,6EAA6E;AAC7E,sFAAsF;AACtF,8DAA8D;AAC9D,mEAAmE;AACnE,0EAA0E;AAC1E,uDAAuD;AACvD,MAAM,IAAI,GAAK,KAA6C,CAAC,OAAO,IAAI,KAAK,CAAC;AAC9E,MAAM,KAAK,GACP,MAA+C,CAAC,OAAO,IAAI,MAAM,CAAC;AAEtE,MAAM,gBAAgB,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;AAC3D,MAAM,iBAAiB,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAI5C,YAAY,KAAkC;QAC5C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,iBAAiB;IACjB,aAAa;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,WAAW,CACT,IAAY,EACZ,IAAY,EACZ,IAAY,EACZ,MAAc,EACd,OAAuB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