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

View File

@@ -0,0 +1,42 @@
/// <reference types="node" />
/// <reference types="node" />
import * as http from 'http';
import { CryptoProvider } from '../crypto/CryptoProvider.js';
import { EventEmitter } from 'events';
import { HttpClient, NodeHttpClientInterface } from '../net/HttpClient.js';
import { PlatformFunctions } from './PlatformFunctions.js';
import { MultipartRequestData, RequestData, BufferedFile } from '../Types.js';
/**
* Specializes WebPlatformFunctions using APIs available in Node.js.
*/
export declare class NodePlatformFunctions extends PlatformFunctions {
/** @override */
uuid4(): string;
/** @override */
getPlatformInfo(): string;
/** @override */
emitWarning(warning: string): void;
/** @override */
getEnv(): Record<string, string | undefined>;
/** @override */
getRuntimeVersion(): string;
private getUname;
/** @override */
getSourceHash(): string | null;
/**
* @override
* Secure compare, from https://github.com/freewil/scmp
*/
secureCompare(a: string, b: string): boolean;
createEmitter(): EventEmitter;
/** @override */
tryBufferData(data: MultipartRequestData): Promise<RequestData | BufferedFile>;
/** @override */
createNodeHttpClient(agent?: http.Agent): NodeHttpClientInterface;
/** @override */
createDefaultHttpClient(): HttpClient;
/** @override */
createNodeCryptoProvider(): CryptoProvider;
/** @override */
createDefaultCryptoProvider(): CryptoProvider;
}

View File

@@ -0,0 +1,146 @@
import * as crypto from 'crypto';
import * as os from 'os';
import { EventEmitter } from 'events';
import { NodeCryptoProvider } from '../crypto/NodeCryptoProvider.js';
import { NodeHttpClient } from '../net/NodeHttpClient.js';
import { PlatformFunctions } from './PlatformFunctions.js';
import { StripeError } from '../Error.js';
import { concat } from '../utils.js';
class StreamProcessingError extends StripeError {
}
/**
* Specializes WebPlatformFunctions using APIs available in Node.js.
*/
export class NodePlatformFunctions extends PlatformFunctions {
/** @override */
uuid4() {
// available in: v14.17.x+
if (crypto.randomUUID) {
return crypto.randomUUID();
}
return super.uuid4();
}
/** @override */
getPlatformInfo() {
return `${process.platform} ${os.release()} ${os.arch()}`;
}
/** @override */
emitWarning(warning) {
if (typeof process.emitWarning === 'function') {
process.emitWarning(warning, 'Stripe');
}
else {
super.emitWarning(warning);
}
}
/** @override */
getEnv() {
return process.env;
}
/** @override */
getRuntimeVersion() {
return process.version;
}
getUname() {
try {
const parts = [os.type(), os.release(), os.arch()];
// os.version() returns detailed kernel version, available since Node 10.7.0
// It may not exist in older typings, so access carefully
const version = os.version?.();
if (version)
parts.push(version);
try {
parts.push(os.hostname());
// eslint-disable-next-line no-empty
}
catch (_e) { }
return parts.join(' ');
}
catch {
return null;
}
}
/** @override */
getSourceHash() {
try {
const uname = this.getUname();
return uname
? crypto
.createHash('md5')
.update(uname)
.digest('hex')
: null;
}
catch {
return null;
}
}
/**
* @override
* Secure compare, from https://github.com/freewil/scmp
*/
secureCompare(a, b) {
if (!a || !b) {
throw new Error('secureCompare must receive two arguments');
}
// return early here if buffer lengths are not equal since timingSafeEqual
// will throw if buffer lengths are not equal
if (a.length !== b.length) {
return false;
}
// use crypto.timingSafeEqual if available (since Node.js v6.6.0),
// otherwise use our own scmp-internal function.
if (crypto.timingSafeEqual) {
const textEncoder = new TextEncoder();
const aEncoded = textEncoder.encode(a);
const bEncoded = textEncoder.encode(b);
return crypto.timingSafeEqual(aEncoded, bEncoded);
}
return super.secureCompare(a, b);
}
createEmitter() {
return new EventEmitter();
}
/** @override */
tryBufferData(data) {
if (!(data.file.data instanceof EventEmitter)) {
return Promise.resolve(data);
}
const bufferArray = [];
return new Promise((resolve, reject) => {
data.file.data
.on('data', (line) => {
bufferArray.push(line);
})
.once('end', () => {
// @ts-ignore
const bufferData = Object.assign({}, data);
bufferData.file.data = concat(bufferArray);
resolve(bufferData);
})
.on('error', (err) => {
reject(new StreamProcessingError({
message: 'An error occurred while attempting to process the file for upload.',
detail: err,
}));
});
});
}
/** @override */
createNodeHttpClient(agent) {
return new NodeHttpClient(agent);
}
/** @override */
createDefaultHttpClient() {
return new NodeHttpClient();
}
/** @override */
createNodeCryptoProvider() {
return new NodeCryptoProvider();
}
/** @override */
createDefaultCryptoProvider() {
return this.createNodeCryptoProvider();
}
}
//# sourceMappingURL=NodePlatformFunctions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodePlatformFunctions.js","sourceRoot":"","sources":["../../src/platform/NodePlatformFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAGnC,MAAM,qBAAsB,SAAQ,WAAW;CAAG;AAElD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAC1D,gBAAgB;IAChB,KAAK;QACH,0BAA0B;QAC1B,IAAI,MAAM,CAAC,UAAU,EAAE;YACrB,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;SAC5B;QACD,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED,gBAAgB;IAChB,eAAe;QACb,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;IAC5D,CAAC;IAED,gBAAgB;IAChB,WAAW,CAAC,OAAe;QACzB,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU,EAAE;YAC7C,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;SACxC;aAAM;YACL,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;SAC5B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,EAAE,CAAC,OAAO,EAAE,CAAC,GAAU,EAAE,EAAE;gBAC1B,MAAM,CACJ,IAAI,qBAAqB,CAAC;oBACxB,OAAO,EACL,oEAAoE;oBACtE,MAAM,EAAE,GAAG;iBACZ,CAAC,CACH,CAAC;YACJ,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB;IAChB,oBAAoB,CAAC,KAAkB;QACrC,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,gBAAgB;IAChB,uBAAuB;QACrB,OAAO,IAAI,cAAc,EAAE,CAAC;IAC9B,CAAC;IAED,gBAAgB;IAChB,wBAAwB;QACtB,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED,gBAAgB;IAChB,2BAA2B;QACzB,OAAO,IAAI,CAAC,wBAAwB,EAAE,CAAC;IACzC,CAAC;CACF"}

View File

@@ -0,0 +1,78 @@
/// <reference types="node" />
/// <reference types="node" />
import * as http from 'http';
import { CryptoProvider } from '../crypto/CryptoProvider.js';
import { EventEmitter } from 'events';
import { HttpClient, NodeHttpClientInterface, FetchHttpClientInterface } from '../net/HttpClient.js';
import { StripeEmitter } from '../StripeEmitter.js';
import { MultipartRequestData, RequestData, BufferedFile } from '../Types.js';
/**
* Interface encapsulating various utility functions whose
* implementations depend on the platform / JS runtime.
*/
export declare class PlatformFunctions {
_fetchFn: any | null;
_agent: http.Agent | null;
constructor();
/**
* Returns platform info string for telemetry, or null if unavailable.
*/
getPlatformInfo(): string | null;
getSourceHash(): string | null;
/**
* Emits a warning. Node.js uses process.emitWarning; other runtimes
* fall back to console.warn.
*/
emitWarning(warning: string): void;
/**
* Returns environment variables, or null if unavailable.
*/
getEnv(): Record<string, string | undefined> | null;
/**
* Returns the runtime version string, or null if unavailable.
*/
getRuntimeVersion(): string | null;
/**
* Generates a v4 UUID. See https://stackoverflow.com/a/2117523
*/
uuid4(): string;
/**
* Compares strings in constant time.
*/
secureCompare(a: string, b: string): boolean;
/**
* Creates an event emitter.
*/
createEmitter(): StripeEmitter | EventEmitter;
/**
* Checks if the request data is a stream. If so, read the entire stream
* to a buffer and return the buffer.
*/
tryBufferData(data: MultipartRequestData): Promise<RequestData | BufferedFile>;
/**
* Creates an HTTP client which uses the Node `http` and `https` packages
* to issue requests.
*/
createNodeHttpClient(agent?: http.Agent): NodeHttpClientInterface;
/**
* Creates an HTTP client for issuing Stripe API requests which uses the Web
* Fetch API.
*
* A fetch function can optionally be passed in as a parameter. If none is
* passed, will default to the default `fetch` function in the global scope.
*/
createFetchHttpClient(fetchFn?: typeof fetch): FetchHttpClientInterface;
/**
* Creates an HTTP client using runtime-specific APIs.
*/
createDefaultHttpClient(): HttpClient;
/**
* Creates a CryptoProvider which uses the Node `crypto` package for its computations.
*/
createNodeCryptoProvider(): CryptoProvider;
/**
* Creates a CryptoProvider which uses the SubtleCrypto interface of the Web Crypto API.
*/
createSubtleCryptoProvider(subtleCrypto?: typeof crypto.subtle): CryptoProvider;
createDefaultCryptoProvider(): CryptoProvider;
}

119
node_modules/stripe/esm/platform/PlatformFunctions.js generated vendored Normal file
View File

@@ -0,0 +1,119 @@
import { FetchHttpClient } from '../net/FetchHttpClient.js';
import { SubtleCryptoProvider } from '../crypto/SubtleCryptoProvider.js';
/**
* Interface encapsulating various utility functions whose
* implementations depend on the platform / JS runtime.
*/
export class PlatformFunctions {
constructor() {
this._fetchFn = null;
this._agent = null;
}
/**
* Returns platform info string for telemetry, or null if unavailable.
*/
getPlatformInfo() {
return null;
}
getSourceHash() {
return null;
}
/**
* Emits a warning. Node.js uses process.emitWarning; other runtimes
* fall back to console.warn.
*/
emitWarning(warning) {
/* eslint-disable no-console */
console.warn(`Stripe: ${warning}`);
/* eslint-enable no-console */
}
/**
* Returns environment variables, or null if unavailable.
*/
getEnv() {
return null;
}
/**
* Returns the runtime version string, or null if unavailable.
*/
getRuntimeVersion() {
return null;
}
/**
* Generates a v4 UUID. See https://stackoverflow.com/a/2117523
*/
uuid4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
/**
* Compares strings in constant time.
*/
secureCompare(a, b) {
// return early here if buffer lengths are not equal
if (a.length !== b.length) {
return false;
}
const len = a.length;
let result = 0;
for (let i = 0; i < len; ++i) {
result |= a.charCodeAt(i) ^ b.charCodeAt(i);
}
return result === 0;
}
/**
* Creates an event emitter.
*/
createEmitter() {
throw new Error('createEmitter not implemented.');
}
/**
* Checks if the request data is a stream. If so, read the entire stream
* to a buffer and return the buffer.
*/
tryBufferData(data) {
throw new Error('tryBufferData not implemented.');
}
/**
* Creates an HTTP client which uses the Node `http` and `https` packages
* to issue requests.
*/
createNodeHttpClient(agent) {
throw new Error('createNodeHttpClient not implemented.');
}
/**
* Creates an HTTP client for issuing Stripe API requests which uses the Web
* Fetch API.
*
* A fetch function can optionally be passed in as a parameter. If none is
* passed, will default to the default `fetch` function in the global scope.
*/
createFetchHttpClient(fetchFn) {
return new FetchHttpClient(fetchFn);
}
/**
* Creates an HTTP client using runtime-specific APIs.
*/
createDefaultHttpClient() {
throw new Error('createDefaultHttpClient not implemented.');
}
/**
* Creates a CryptoProvider which uses the Node `crypto` package for its computations.
*/
createNodeCryptoProvider() {
throw new Error('createNodeCryptoProvider not implemented.');
}
/**
* Creates a CryptoProvider which uses the SubtleCrypto interface of the Web Crypto API.
*/
createSubtleCryptoProvider(subtleCrypto) {
return new SubtleCryptoProvider(subtleCrypto);
}
createDefaultCryptoProvider() {
throw new Error('createDefaultCryptoProvider not implemented.');
}
}
//# sourceMappingURL=PlatformFunctions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PlatformFunctions.js","sourceRoot":"","sources":["../../src/platform/PlatformFunctions.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AA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AAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YAC5B,MAAM,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SAC7C;QACD,OAAO,MAAM,KAAK,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,aAAa;QACX,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACH,aAAa,CACX,IAA0B;QAE1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACH,oBAAoB,CAAC,KAAkB;QACrC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACH,qBAAqB,CAAC,OAAsB;QAC1C,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,uBAAuB;QACrB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,wBAAwB;QACtB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,0BAA0B,CACxB,YAAmC;QAEnC,OAAO,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAChD,CAAC;IAED,2BAA2B;QACzB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;CACF"}

View File

@@ -0,0 +1,22 @@
import { CryptoProvider } from '../crypto/CryptoProvider.js';
import { HttpClient, NodeHttpClientInterface } from '../net/HttpClient.js';
import { PlatformFunctions } from './PlatformFunctions.js';
import { StripeEmitter } from '../StripeEmitter.js';
import { MultipartRequestData, RequestData, BufferedFile } from '../Types.js';
/**
* Specializes WebPlatformFunctions using APIs available in Web workers.
*/
export declare class WebPlatformFunctions extends PlatformFunctions {
/** @override */
createEmitter(): StripeEmitter;
/** @override */
tryBufferData(data: MultipartRequestData): Promise<RequestData | BufferedFile>;
/** @override */
createNodeHttpClient(): NodeHttpClientInterface;
/** @override */
createDefaultHttpClient(): HttpClient;
/** @override */
createNodeCryptoProvider(): CryptoProvider;
/** @override */
createDefaultCryptoProvider(): CryptoProvider;
}

View File

@@ -0,0 +1,35 @@
import { PlatformFunctions } from './PlatformFunctions.js';
import { StripeEmitter } from '../StripeEmitter.js';
/**
* Specializes WebPlatformFunctions using APIs available in Web workers.
*/
export class WebPlatformFunctions extends PlatformFunctions {
/** @override */
createEmitter() {
return new StripeEmitter();
}
/** @override */
tryBufferData(data) {
if (data.file.data instanceof ReadableStream) {
throw new Error('Uploading a file as a stream is not supported in non-Node environments. Please open or upvote an issue at github.com/stripe/stripe-node if you use this, detailing your use-case.');
}
return Promise.resolve(data);
}
/** @override */
createNodeHttpClient() {
throw new Error('Stripe: `createNodeHttpClient()` is not available in non-Node environments. Please use `createFetchHttpClient()` instead.');
}
/** @override */
createDefaultHttpClient() {
return super.createFetchHttpClient();
}
/** @override */
createNodeCryptoProvider() {
throw new Error('Stripe: `createNodeCryptoProvider()` is not available in non-Node environments. Please use `createSubtleCryptoProvider()` instead.');
}
/** @override */
createDefaultCryptoProvider() {
return this.createSubtleCryptoProvider();
}
}
//# sourceMappingURL=WebPlatformFunctions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"WebPlatformFunctions.js","sourceRoot":"","sources":["../../src/platform/WebPlatformFunctions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IACzD,gBAAgB;IAChB,aAAa;QACX,OAAO,IAAI,aAAa,EAAE,CAAC;IAC7B,CAAC;IAED,gBAAgB;IAChB,aAAa,CACX,IAA0B;QAE1B,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,YAAY,cAAc,EAAE;YAC5C,MAAM,IAAI,KAAK,CACb,mLAAmL,CACpL,CAAC;SACH;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,gBAAgB;IAChB,oBAAoB;QAClB,MAAM,IAAI,KAAK,CACb,2HAA2H,CAC5H,CAAC;IACJ,CAAC;IAED,gBAAgB;IAChB,uBAAuB;QACrB,OAAO,KAAK,CAAC,qBAAqB,EAAE,CAAC;IACvC,CAAC;IAED,gBAAgB;IAChB,wBAAwB;QACtB,MAAM,IAAI,KAAK,CACb,oIAAoI,CACrI,CAAC;IACJ,CAAC;IAED,gBAAgB;IAChB,2BAA2B;QACzB,OAAO,IAAI,CAAC,0BAA0B,EAAE,CAAC;IAC3C,CAAC;CACF"}