公众号验证码功能完成 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

44
node_modules/openai/azure.js generated vendored
View File

@@ -2,10 +2,10 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.AzureOpenAI = void 0;
const tslib_1 = require("./internal/tslib.js");
const headers_1 = require("./internal/headers.js");
const Errors = tslib_1.__importStar(require("./error.js"));
const utils_1 = require("./internal/utils.js");
const client_1 = require("./client.js");
const headers_1 = require("./internal/headers.js");
/** API Client for interfacing with the Azure OpenAI API. */
class AzureOpenAI extends client_1.OpenAI {
/**
@@ -38,8 +38,6 @@ class AzureOpenAI extends client_1.OpenAI {
if (azureADTokenProvider && apiKey) {
throw new Errors.OpenAIError('The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.');
}
// define a sentinel value to avoid any typing issues
apiKey ?? (apiKey = API_KEY_SENTINEL);
opts.defaultQuery = { ...opts.defaultQuery, 'api-version': apiVersion };
if (!baseURL) {
if (!endpoint) {
@@ -56,13 +54,12 @@ class AzureOpenAI extends client_1.OpenAI {
}
}
super({
apiKey,
apiKey: azureADTokenProvider ?? apiKey,
baseURL,
...opts,
...(dangerouslyAllowBrowser !== undefined ? { dangerouslyAllowBrowser } : {}),
});
this.apiVersion = '';
this._azureADTokenProvider = azureADTokenProvider;
this.apiVersion = apiVersion;
this.deploymentName = deployment;
}
@@ -78,41 +75,11 @@ class AzureOpenAI extends client_1.OpenAI {
}
return super.buildRequest(options, props);
}
async _getAzureADToken() {
if (typeof this._azureADTokenProvider === 'function') {
const token = await this._azureADTokenProvider();
if (!token || typeof token !== 'string') {
throw new Errors.OpenAIError(`Expected 'azureADTokenProvider' argument to return a string but it returned ${token}`);
}
return token;
}
return undefined;
}
async authHeaders(opts) {
return;
}
async prepareOptions(opts) {
opts.headers = (0, headers_1.buildHeaders)([opts.headers]);
/**
* The user should provide a bearer token provider if they want
* to use Azure AD authentication. The user shouldn't set the
* Authorization header manually because the header is overwritten
* with the Azure AD token if a bearer token provider is provided.
*/
if (opts.headers.values.get('Authorization') || opts.headers.values.get('api-key')) {
return super.prepareOptions(opts);
if (typeof this._options.apiKey === 'string') {
return (0, headers_1.buildHeaders)([{ 'api-key': this.apiKey }]);
}
const token = await this._getAzureADToken();
if (token) {
opts.headers.values.set('Authorization', `Bearer ${token}`);
}
else if (this.apiKey !== API_KEY_SENTINEL) {
opts.headers.values.set('api-key', this.apiKey);
}
else {
throw new Errors.OpenAIError('Unable to handle auth');
}
return super.prepareOptions(opts);
return super.authHeaders(opts);
}
}
exports.AzureOpenAI = AzureOpenAI;
@@ -127,5 +94,4 @@ const _deployments_endpoints = new Set([
'/batches',
'/images/edits',
]);
const API_KEY_SENTINEL = '<Missing Key>';
//# sourceMappingURL=azure.js.map