@wavebirdai/api 0.1.0-beta.6 → 0.1.0-beta.7

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/server.js CHANGED
@@ -59,8 +59,14 @@ function normalizeOptions(options) {
59
59
  options.blockedCategories.some(value => typeof value !== "string" || !value.trim())))
60
60
  throw new Error("publisher_blocked_categories_invalid");
61
61
  if (!["chat", "code", "image", "voice", "agent"].includes(options.jobType) || typeof options.locale !== "string" || !options.locale) throw new Error("publisher_job_invalid");
62
- const base = String(options.apiBaseUrl || "https://api.wavebird.ai").trim().replace(/\/+$/, "").replace(/\/v1$/, "") + "/v1";
63
- if (!/^https:\/\//.test(base)) throw new Error("publisher_api_https_required");
62
+ const apiBaseUrl = options.apiBaseUrl === undefined ? "https://api.wavebird.ai" : options.apiBaseUrl;
63
+ if (typeof apiBaseUrl !== "string" || !apiBaseUrl.trim() || /[\\?#]/.test(apiBaseUrl)) throw new Error("publisher_api_https_required");
64
+ const endpoint = apiBaseUrl.trim();
65
+ let parsedEndpoint;
66
+ try { parsedEndpoint = new URL(endpoint); } catch { throw new Error("publisher_api_https_required"); }
67
+ if (parsedEndpoint.protocol !== "https:" || !parsedEndpoint.hostname || parsedEndpoint.username || parsedEndpoint.password ||
68
+ parsedEndpoint.search || parsedEndpoint.hash) throw new Error("publisher_api_https_required");
69
+ const base = endpoint.replace(/\/+$/, "").replace(/\/v1$/, "") + "/v1";
64
70
  {
65
71
  if (!Array.isArray(options.publicOrigins) || options.publicOrigins.length < 1 || options.publicOrigins.length > 8) throw new Error("publisher_public_origins_invalid");
66
72
  for (const origin of options.publicOrigins) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavebirdai/api",
3
- "version": "0.1.0-beta.6",
3
+ "version": "0.1.0-beta.7",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Integrate Banner, Native, and Clip placements into authenticated chat apps with server-side keys, consent, and generation lifecycle handling",
package/src/server.js CHANGED
@@ -59,8 +59,14 @@ function normalizeOptions(options) {
59
59
  options.blockedCategories.some(value => typeof value !== "string" || !value.trim())))
60
60
  throw new Error("publisher_blocked_categories_invalid");
61
61
  if (!["chat", "code", "image", "voice", "agent"].includes(options.jobType) || typeof options.locale !== "string" || !options.locale) throw new Error("publisher_job_invalid");
62
- const base = String(options.apiBaseUrl || "https://api.wavebird.ai").trim().replace(/\/+$/, "").replace(/\/v1$/, "") + "/v1";
63
- if (!/^https:\/\//.test(base)) throw new Error("publisher_api_https_required");
62
+ const apiBaseUrl = options.apiBaseUrl === undefined ? "https://api.wavebird.ai" : options.apiBaseUrl;
63
+ if (typeof apiBaseUrl !== "string" || !apiBaseUrl.trim() || /[\\?#]/.test(apiBaseUrl)) throw new Error("publisher_api_https_required");
64
+ const endpoint = apiBaseUrl.trim();
65
+ let parsedEndpoint;
66
+ try { parsedEndpoint = new URL(endpoint); } catch { throw new Error("publisher_api_https_required"); }
67
+ if (parsedEndpoint.protocol !== "https:" || !parsedEndpoint.hostname || parsedEndpoint.username || parsedEndpoint.password ||
68
+ parsedEndpoint.search || parsedEndpoint.hash) throw new Error("publisher_api_https_required");
69
+ const base = endpoint.replace(/\/+$/, "").replace(/\/v1$/, "") + "/v1";
64
70
  {
65
71
  if (!Array.isArray(options.publicOrigins) || options.publicOrigins.length < 1 || options.publicOrigins.length > 8) throw new Error("publisher_public_origins_invalid");
66
72
  for (const origin of options.publicOrigins) {