@eyepop.ai/eyepop 0.13.0 → 0.14.0

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/index.mjs CHANGED
@@ -8599,11 +8599,11 @@ var require_mime_types = __commonJS({
8599
8599
  }
8600
8600
  return exts[0];
8601
8601
  }
8602
- function lookup(path) {
8603
- if (!path || typeof path !== "string") {
8602
+ function lookup(path2) {
8603
+ if (!path2 || typeof path2 !== "string") {
8604
8604
  return false;
8605
8605
  }
8606
- var extension2 = extname("x." + path).toLowerCase().substr(1);
8606
+ var extension2 = extname("x." + path2).toLowerCase().substr(1);
8607
8607
  if (!extension2) {
8608
8608
  return false;
8609
8609
  }
@@ -9284,6 +9284,7 @@ function v4(options, buf, offset) {
9284
9284
  var v4_default = v4;
9285
9285
 
9286
9286
  // src/webrtc_base.ts
9287
+ import path from "path";
9287
9288
  var WebrtcBase = class _WebrtcBase {
9288
9289
  constructor(getSession, client, ingressId, urlBasePath, requestLogger) {
9289
9290
  this._getSession = getSession;
@@ -9293,6 +9294,7 @@ var WebrtcBase = class _WebrtcBase {
9293
9294
  this._urlPath = `${urlBasePath}/${this._ingressId}`;
9294
9295
  this._pc = null;
9295
9296
  this._eTag = "";
9297
+ this._location = null;
9296
9298
  this._queuedCandidates = [];
9297
9299
  this._offerData = null;
9298
9300
  }
@@ -9331,6 +9333,7 @@ var WebrtcBase = class _WebrtcBase {
9331
9333
  return Promise.reject(`unknown status code for POST '${ingressUrl}': ${response.status} (${response.statusText})`);
9332
9334
  }
9333
9335
  this._eTag = response.headers.get("ETag") ?? "";
9336
+ this._location = response.headers.get("Location");
9334
9337
  return this.onRemoteAnswer(new RTCSessionDescription({
9335
9338
  type: "answer",
9336
9339
  sdp: await response.text()
@@ -9340,8 +9343,14 @@ var WebrtcBase = class _WebrtcBase {
9340
9343
  if (!this._offerData) {
9341
9344
  throw new Error("sendLocalCandidates no offerData");
9342
9345
  }
9346
+ let urlPath = void 0;
9343
9347
  const session = await this._getSession();
9344
- const ingressUrl = new URL(this._urlPath, session.baseUrl);
9348
+ if (this._location) {
9349
+ urlPath = path.join(this._urlPath, this._location);
9350
+ } else {
9351
+ urlPath = this._urlPath;
9352
+ }
9353
+ const ingressUrl = new URL(urlPath, session.baseUrl);
9345
9354
  this._requestLogger.debug("before PATCH: %s", ingressUrl);
9346
9355
  const headers = {
9347
9356
  "Authorization": `Bearer ${session.accessToken}`,
@@ -10005,6 +10014,7 @@ var Endpoint = class {
10005
10014
  }
10006
10015
  async uploadPath(source) {
10007
10016
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10017
+ console.log(this);
10008
10018
  throw new Error("endpoint not connected, use connect() before process()");
10009
10019
  }
10010
10020
  await this._limit.acquire();
@@ -10138,7 +10148,8 @@ var Endpoint = class {
10138
10148
  }
10139
10149
  config = await response.json();
10140
10150
  }
10141
- this._baseUrl = config.base_url;
10151
+ const baseUrl = new URL(config.base_url, this.eyepopUrl());
10152
+ this._baseUrl = baseUrl.toString();
10142
10153
  this._pipelineId = config.pipeline_id;
10143
10154
  this._popName = config.name;
10144
10155
  this._requestLogger.debug("after GET %s: %s / %s", config_url, this._baseUrl, this._pipelineId);
@@ -10323,46 +10334,60 @@ var readEnv = (env) => {
10323
10334
  return void 0;
10324
10335
  };
10325
10336
  var _EyePopSdk = class _EyePopSdk {
10326
- static endpoint({
10327
- auth = this.defaultAuth,
10328
- popId = readEnv("EYEPOP_POP_ID"),
10329
- eyepopUrl = readEnv("EYEPOP_URL"),
10330
- autoStart = true,
10331
- stopJobs = true,
10332
- jobQueueLength = 1024,
10333
- logger,
10334
- ...opts
10335
- } = {}) {
10336
- if (auth.oAuth2 !== void 0 && popId) {
10337
- if (typeof auth.oAuth2 === "boolean") {
10338
- auth = {
10339
- oAuth2: {
10340
- domain: "eyepop.us.auth0.com",
10341
- clientId: "Lb9ubA9Hf3jlaqWLUx8XgA0zvotgViCl",
10342
- audience: "https://api.eyepop.ai",
10343
- scope: "admin:clouds"
10344
- }
10345
- };
10337
+ static endpoint(opts = {}) {
10338
+ if (typeof opts.auth == "undefined") {
10339
+ if (typeof _EyePopSdk.defaultAuth == "undefined") {
10340
+ throw new Error("auth option or EYEPOP_SECRET_KEY environment variable is required");
10346
10341
  }
10342
+ opts.auth = _EyePopSdk.defaultAuth;
10343
+ }
10344
+ if (typeof opts.popId == "undefined") {
10345
+ opts.popId = readEnv("EYEPOP_POP_ID");
10346
+ }
10347
+ if (typeof opts.eyepopUrl == "undefined") {
10348
+ opts.eyepopUrl = readEnv("EYEPOP_URL") || "https://api.eyepop.ai";
10349
+ }
10350
+ if (typeof opts.autoStart == "undefined") {
10351
+ opts.autoStart = true;
10352
+ }
10353
+ if (typeof opts.stopJobs == "undefined") {
10354
+ opts.stopJobs = true;
10355
+ }
10356
+ if (typeof opts.jobQueueLength == "undefined") {
10357
+ opts.jobQueueLength = 1024;
10347
10358
  }
10348
- if (auth.session !== void 0) {
10349
- if (auth.session.popId) {
10350
- popId = auth.session.popId;
10359
+ if (typeof opts.auth.oAuth2 != "undefined" && opts.popId) {
10360
+ if (typeof opts.auth.oAuth2 === "boolean") {
10361
+ if (opts.eyepopUrl.startsWith("https://staging-api.eyepop.ai")) {
10362
+ opts.auth = {
10363
+ oAuth2: {
10364
+ domain: "dev-eyepop.us.auth0.com",
10365
+ clientId: "jktx3YO2UnbkNPvr05PQWf26t1kNTJyg",
10366
+ audience: "https://dev-app.eyepop.ai",
10367
+ scope: "admin:clouds"
10368
+ }
10369
+ };
10370
+ } else {
10371
+ opts.auth = {
10372
+ oAuth2: {
10373
+ domain: "eyepop.us.auth0.com",
10374
+ clientId: "Lb9ubA9Hf3jlaqWLUx8XgA0zvotgViCl",
10375
+ audience: "https://api.eyepop.ai",
10376
+ scope: "admin:clouds"
10377
+ }
10378
+ };
10379
+ }
10351
10380
  }
10352
- if (auth.session.eyepopUrl) {
10353
- eyepopUrl = auth.session.eyepopUrl;
10381
+ }
10382
+ if (opts.auth.session !== void 0) {
10383
+ if (opts.auth.session.popId) {
10384
+ opts.popId = opts.auth.session.popId;
10385
+ }
10386
+ if (opts.auth.session.eyepopUrl) {
10387
+ opts.eyepopUrl = opts.auth.session.eyepopUrl;
10354
10388
  }
10355
10389
  }
10356
- const options = {
10357
- auth,
10358
- popId,
10359
- eyepopUrl: eyepopUrl ?? "https://api.eyepop.ai",
10360
- autoStart,
10361
- stopJobs,
10362
- jobQueueLength,
10363
- logger
10364
- };
10365
- const endpoint = new Endpoint(options);
10390
+ const endpoint = new Endpoint(opts);
10366
10391
  return endpoint;
10367
10392
  }
10368
10393
  static plot(context) {