@elizaos/project-tee-starter 1.5.12 → 1.5.13-alpha.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.js CHANGED
@@ -28455,7 +28455,8 @@ var require_dist5 = __commonJS((exports) => {
28455
28455
  return result;
28456
28456
  }
28457
28457
  close(code, data) {
28458
- this.socket.close(code || 1000, data);
28458
+ if (this.socket)
28459
+ this.socket.close(code || 1000, data);
28459
28460
  }
28460
28461
  setAutoReconnect(reconnect) {
28461
28462
  this.reconnect = reconnect;
@@ -28466,6 +28467,18 @@ var require_dist5 = __commonJS((exports) => {
28466
28467
  setMaxReconnects(max_reconnects) {
28467
28468
  this.max_reconnects = max_reconnects;
28468
28469
  }
28470
+ getCurrentReconnects() {
28471
+ return this.current_reconnects;
28472
+ }
28473
+ getMaxReconnects() {
28474
+ return this.max_reconnects;
28475
+ }
28476
+ isReconnecting() {
28477
+ return this.reconnect_timer_id !== undefined;
28478
+ }
28479
+ willReconnect() {
28480
+ return this.reconnect && (this.max_reconnects === 0 || this.current_reconnects < this.max_reconnects);
28481
+ }
28469
28482
  _connect(address, options) {
28470
28483
  clearTimeout(this.reconnect_timer_id);
28471
28484
  this.socket = this.webSocketFactory(address, options);
@@ -28524,6 +28537,9 @@ var require_dist5 = __commonJS((exports) => {
28524
28537
  this.current_reconnects++;
28525
28538
  if (this.reconnect && (this.max_reconnects > this.current_reconnects || this.max_reconnects === 0))
28526
28539
  this.reconnect_timer_id = setTimeout(() => this._connect(address, options), this.reconnect_interval);
28540
+ else if (this.reconnect && this.max_reconnects > 0 && this.current_reconnects >= this.max_reconnects) {
28541
+ setTimeout(() => this.emit("max_reconnects_reached", code, reason), 1);
28542
+ }
28527
28543
  });
28528
28544
  }
28529
28545
  };
@@ -35176,7 +35192,7 @@ var configSchema = z.object({
35176
35192
  if (!val)
35177
35193
  return true;
35178
35194
  return ["OFF", "LOCAL", "DOCKER", "PRODUCTION"].includes(val);
35179
- }, "TEE_MODE must be one of: OFF, LOCAL, DOCKER, PRODUCTION"),
35195
+ }, { message: "TEE_MODE must be one of: OFF, LOCAL, DOCKER, PRODUCTION" }),
35180
35196
  TEE_VENDOR: z.string().optional().transform((val) => {
35181
35197
  if (false) {}
35182
35198
  return val;
@@ -35184,34 +35200,33 @@ var configSchema = z.object({
35184
35200
  if (!val)
35185
35201
  return true;
35186
35202
  return val === "phala";
35187
- }, "TEE_VENDOR must be: phala"),
35203
+ }, { message: "TEE_VENDOR must be: phala" }),
35188
35204
  WALLET_SECRET_SALT: z.string().optional().transform((val) => {
35189
35205
  if (false) {}
35190
35206
  if (!val) {
35191
35207
  logger.warn("Warning: Wallet secret salt is not provided");
35208
+ return val;
35192
35209
  }
35193
- return val;
35210
+ return val.trim();
35194
35211
  }).refine((val) => {
35195
- if (!val)
35212
+ if (val === undefined)
35196
35213
  return true;
35197
- const trimmedVal = val.trim();
35198
- return trimmedVal.length >= 8 && trimmedVal.length <= 128;
35199
- }, (val) => {
35200
- if (!val)
35201
- return { message: "Wallet secret salt is required" };
35202
- const trimmedVal = val.trim();
35203
- if (trimmedVal.length < 8) {
35204
- return { message: "Wallet secret salt must be at least 8 characters long for security" };
35205
- }
35206
- if (trimmedVal.length > 128) {
35207
- return { message: "Wallet secret salt must not exceed 128 characters" };
35208
- }
35209
- return { message: "Invalid wallet secret salt" };
35210
- })
35214
+ if (!val || val.length === 0)
35215
+ return false;
35216
+ return val.length >= 8;
35217
+ }, {
35218
+ message: "Wallet secret salt must be at least 8 characters long for security (excluding whitespace)"
35219
+ }).refine((val) => {
35220
+ if (val === undefined)
35221
+ return true;
35222
+ if (!val || val.length === 0)
35223
+ return false;
35224
+ return val.length <= 128;
35225
+ }, { message: "Wallet secret salt must not exceed 128 characters (excluding whitespace)" })
35211
35226
  });
35212
35227
  var createTeeServiceConfig = (runtime) => ({
35213
35228
  teeClient: new import_dstack_sdk.TappdClient,
35214
- secretSalt: process.env.WALLET_SECRET_SALT || "secret_salt",
35229
+ secretSalt: (process.env.WALLET_SECRET_SALT || "secret_salt").trim(),
35215
35230
  runtime
35216
35231
  });
35217
35232
  var deriveEcdsaKeypair = (deriveKeyResponse) => {
@@ -35308,7 +35323,22 @@ var teeStarterPlugin = {
35308
35323
  }
35309
35324
  } catch (error) {
35310
35325
  if (error instanceof z.ZodError) {
35311
- throw new Error(`Invalid plugin configuration: ${error.errors.map((e) => e.message).join(", ")}`);
35326
+ const hasInvalidMode = error.issues.some((e) => e.path[0] === "TEE_MODE" && e.message.includes("TEE_MODE must be"));
35327
+ if (hasInvalidMode) {
35328
+ const teeError = error.issues.find((e) => e.path[0] === "TEE_MODE");
35329
+ throw new Error(teeError?.message || "TEE_MODE must be one of: OFF, LOCAL, DOCKER, PRODUCTION");
35330
+ }
35331
+ const hasInvalidVendor = error.issues.some((e) => e.path[0] === "TEE_VENDOR" && e.message.includes("TEE_VENDOR must be"));
35332
+ if (hasInvalidVendor) {
35333
+ const vendorError = error.issues.find((e) => e.path[0] === "TEE_VENDOR");
35334
+ throw new Error(vendorError?.message || "TEE_VENDOR must be: phala");
35335
+ }
35336
+ const hasSaltError = error.issues.some((e) => e.path[0] === "WALLET_SECRET_SALT");
35337
+ if (hasSaltError) {
35338
+ const saltError = error.issues.find((e) => e.path[0] === "WALLET_SECRET_SALT");
35339
+ throw new Error(saltError?.message || "Invalid wallet secret salt");
35340
+ }
35341
+ throw new Error("Invalid plugin configuration");
35312
35342
  }
35313
35343
  throw error;
35314
35344
  }
@@ -35636,5 +35666,5 @@ export {
35636
35666
  StarterService
35637
35667
  };
35638
35668
 
35639
- //# debugId=9407D5FBB03532A064756E2164756E21
35669
+ //# debugId=8F12EBB04074C17A64756E2164756E21
35640
35670
  //# sourceMappingURL=index.js.map