@eyepop.ai/eyepop 0.13.0 → 0.14.1

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}`,
@@ -9516,7 +9525,7 @@ var WebrtcBase = class _WebrtcBase {
9516
9525
  };
9517
9526
 
9518
9527
  // src/webrtc_whip.ts
9519
- var WebrtcWhip = class _WebrtcWhip extends WebrtcBase {
9528
+ var WebrtcWhip = class extends WebrtcBase {
9520
9529
  constructor(stream, getSession, client, requestLogger) {
9521
9530
  super(getSession, client, v4_default().toString(), "/liveIngress/whip", requestLogger);
9522
9531
  this._stream = stream;
@@ -9548,17 +9557,6 @@ var WebrtcWhip = class _WebrtcWhip extends WebrtcBase {
9548
9557
  if (!this._pc) {
9549
9558
  throw new Error("onLocalOffer no peer connection");
9550
9559
  }
9551
- answer = new RTCSessionDescription({
9552
- type: "answer",
9553
- sdp: _WebrtcWhip.editAnswer(
9554
- answer.sdp,
9555
- "h264/90000",
9556
- void 0,
9557
- 5e3,
9558
- void 0,
9559
- true
9560
- )
9561
- });
9562
9560
  await this._pc.setRemoteDescription(new RTCSessionDescription(answer));
9563
9561
  if (this._queuedCandidates.length !== 0) {
9564
9562
  await this.sendLocalCandidates(this._queuedCandidates);
@@ -10005,6 +10003,7 @@ var Endpoint = class {
10005
10003
  }
10006
10004
  async uploadPath(source) {
10007
10005
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10006
+ console.log(this);
10008
10007
  throw new Error("endpoint not connected, use connect() before process()");
10009
10008
  }
10010
10009
  await this._limit.acquire();
@@ -10138,7 +10137,8 @@ var Endpoint = class {
10138
10137
  }
10139
10138
  config = await response.json();
10140
10139
  }
10141
- this._baseUrl = config.base_url;
10140
+ const baseUrl = new URL(config.base_url, this.eyepopUrl());
10141
+ this._baseUrl = baseUrl.toString();
10142
10142
  this._pipelineId = config.pipeline_id;
10143
10143
  this._popName = config.name;
10144
10144
  this._requestLogger.debug("after GET %s: %s / %s", config_url, this._baseUrl, this._pipelineId);
@@ -10323,46 +10323,60 @@ var readEnv = (env) => {
10323
10323
  return void 0;
10324
10324
  };
10325
10325
  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
- };
10326
+ static endpoint(opts = {}) {
10327
+ if (typeof opts.auth == "undefined") {
10328
+ if (typeof _EyePopSdk.defaultAuth == "undefined") {
10329
+ throw new Error("auth option or EYEPOP_SECRET_KEY environment variable is required");
10346
10330
  }
10331
+ opts.auth = _EyePopSdk.defaultAuth;
10332
+ }
10333
+ if (typeof opts.popId == "undefined") {
10334
+ opts.popId = readEnv("EYEPOP_POP_ID");
10335
+ }
10336
+ if (typeof opts.eyepopUrl == "undefined") {
10337
+ opts.eyepopUrl = readEnv("EYEPOP_URL") || "https://api.eyepop.ai";
10338
+ }
10339
+ if (typeof opts.autoStart == "undefined") {
10340
+ opts.autoStart = true;
10341
+ }
10342
+ if (typeof opts.stopJobs == "undefined") {
10343
+ opts.stopJobs = true;
10347
10344
  }
10348
- if (auth.session !== void 0) {
10349
- if (auth.session.popId) {
10350
- popId = auth.session.popId;
10345
+ if (typeof opts.jobQueueLength == "undefined") {
10346
+ opts.jobQueueLength = 1024;
10347
+ }
10348
+ if (typeof opts.auth.oAuth2 != "undefined" && opts.popId) {
10349
+ if (typeof opts.auth.oAuth2 === "boolean") {
10350
+ if (opts.eyepopUrl.startsWith("https://staging-api.eyepop.ai")) {
10351
+ opts.auth = {
10352
+ oAuth2: {
10353
+ domain: "dev-eyepop.us.auth0.com",
10354
+ clientId: "jktx3YO2UnbkNPvr05PQWf26t1kNTJyg",
10355
+ audience: "https://dev-app.eyepop.ai",
10356
+ scope: "admin:clouds"
10357
+ }
10358
+ };
10359
+ } else {
10360
+ opts.auth = {
10361
+ oAuth2: {
10362
+ domain: "eyepop.us.auth0.com",
10363
+ clientId: "Lb9ubA9Hf3jlaqWLUx8XgA0zvotgViCl",
10364
+ audience: "https://api.eyepop.ai",
10365
+ scope: "admin:clouds"
10366
+ }
10367
+ };
10368
+ }
10351
10369
  }
10352
- if (auth.session.eyepopUrl) {
10353
- eyepopUrl = auth.session.eyepopUrl;
10370
+ }
10371
+ if (opts.auth.session !== void 0) {
10372
+ if (opts.auth.session.popId) {
10373
+ opts.popId = opts.auth.session.popId;
10374
+ }
10375
+ if (opts.auth.session.eyepopUrl) {
10376
+ opts.eyepopUrl = opts.auth.session.eyepopUrl;
10354
10377
  }
10355
10378
  }
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);
10379
+ const endpoint = new Endpoint(opts);
10366
10380
  return endpoint;
10367
10381
  }
10368
10382
  static plot(context) {