公众号验证码功能完成 yeah!!!

This commit is contained in:
2025-11-21 15:33:03 +08:00
parent ad35173301
commit 6330f6faa1
614 changed files with 31574 additions and 4571 deletions

37
node_modules/openai/client.mjs generated vendored
View File

@@ -22,6 +22,7 @@ import { Files, } from "./resources/files.mjs";
import { Images, } from "./resources/images.mjs";
import { Models } from "./resources/models.mjs";
import { Moderations, } from "./resources/moderations.mjs";
import { Videos, } from "./resources/videos.mjs";
import { Webhooks } from "./resources/webhooks.mjs";
import { Audio } from "./resources/audio/audio.mjs";
import { Beta } from "./resources/beta/beta.mjs";
@@ -31,6 +32,7 @@ import { Conversations } from "./resources/conversations/conversations.mjs";
import { Evals, } from "./resources/evals/evals.mjs";
import { FineTuning } from "./resources/fine-tuning/fine-tuning.mjs";
import { Graders } from "./resources/graders/graders.mjs";
import { Realtime } from "./resources/realtime/realtime.mjs";
import { Responses } from "./resources/responses/responses.mjs";
import { Uploads as UploadsAPIUploads, } from "./resources/uploads/uploads.mjs";
import { VectorStores, } from "./resources/vector-stores/vector-stores.mjs";
@@ -78,11 +80,13 @@ export class OpenAI {
this.batches = new API.Batches(this);
this.uploads = new API.Uploads(this);
this.responses = new API.Responses(this);
this.realtime = new API.Realtime(this);
this.conversations = new API.Conversations(this);
this.evals = new API.Evals(this);
this.containers = new API.Containers(this);
this.videos = new API.Videos(this);
if (apiKey === undefined) {
throw new Errors.OpenAIError("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");
throw new Errors.OpenAIError('Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.');
}
const options = {
apiKey,
@@ -110,7 +114,7 @@ export class OpenAI {
this.fetch = options.fetch ?? Shims.getDefaultFetch();
__classPrivateFieldSet(this, _OpenAI_encoder, Opts.FallbackEncoder, "f");
this._options = options;
this.apiKey = apiKey;
this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
this.organization = organization;
this.project = project;
this.webhookSecret = webhookSecret;
@@ -157,6 +161,27 @@ export class OpenAI {
makeStatusError(status, error, message, headers) {
return Errors.APIError.generate(status, error, message, headers);
}
async _callApiKey() {
const apiKey = this._options.apiKey;
if (typeof apiKey !== 'function')
return false;
let token;
try {
token = await apiKey();
}
catch (err) {
if (err instanceof Errors.OpenAIError)
throw err;
throw new Errors.OpenAIError(`Failed to get token from 'apiKey' function: ${err.message}`,
// @ts-ignore
{ cause: err });
}
if (typeof token !== 'string' || !token) {
throw new Errors.OpenAIError(`Expected 'apiKey' function argument to return a string but it returned ${token}`);
}
this.apiKey = token;
return true;
}
buildURL(path, query, defaultBaseURL) {
const baseURL = (!__classPrivateFieldGet(this, _OpenAI_instances, "m", _OpenAI_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
const url = isAbsoluteURL(path) ?
@@ -174,7 +199,9 @@ export class OpenAI {
/**
* Used as a callback for mutating the given `FinalRequestOptions` object.
*/
async prepareOptions(options) { }
async prepareOptions(options) {
await this._callApiKey();
}
/**
* Used as a callback for mutating the given `RequestInit` object.
*
@@ -233,7 +260,7 @@ export class OpenAI {
const controller = new AbortController();
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
const headersTime = Date.now();
if (response instanceof Error) {
if (response instanceof globalThis.Error) {
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
if (options.signal?.aborted) {
throw new Errors.APIUserAbortError();
@@ -524,7 +551,9 @@ OpenAI.Beta = Beta;
OpenAI.Batches = Batches;
OpenAI.Uploads = UploadsAPIUploads;
OpenAI.Responses = Responses;
OpenAI.Realtime = Realtime;
OpenAI.Conversations = Conversations;
OpenAI.Evals = Evals;
OpenAI.Containers = Containers;
OpenAI.Videos = Videos;
//# sourceMappingURL=client.mjs.map