Verified Commit 43113cc4 authored by henry's avatar henry Committed by Pier Angelo Vendrame
Browse files

fixup! Lox integration

Bug 42492: Lint Lox.sys.mjs
parent 5686dd36
Loading
Loading
Loading
Loading
+23 −44
Changes for toolkit/components/lox/Lox.sys.mjs: 23 added lines, 44 removed lines.
Original line number Diff line number Diff line
@@ -475,11 +475,7 @@ class LoxImpl {
        // The UpdateCredOption rust struct serializes to "req" rather than
        // "request".
        const { updated, req: request } = JSON.parse(
          lazy.check_lox_pubkeys_update(
            pubKeys,
            prevKeys,
            cred
          )
          lazy.check_lox_pubkeys_update(pubKeys, prevKeys, cred)
        );
        if (!updated) {
          return null;
@@ -813,11 +809,7 @@ class LoxImpl {
    }

    const cred = await this.#changeCredentials(loxId, async cred => {
    let request = lazy.issue_invite(
      cred,
      this.#encTable,
      this.#pubKeys
    );
      let request = lazy.issue_invite(cred, this.#encTable, this.#pubKeys);
      let response = await this.#makeRequest("issueinvite", request);
      // TODO: Do we ever expect handle_issue_invite to fail (beyond
      // implementation bugs)?
@@ -855,7 +847,8 @@ class LoxImpl {
  }

  async #blockageMigration(loxId) {
    return Boolean(await this.#changeCredentials(loxId, async cred => {
    return Boolean(
      await this.#changeCredentials(loxId, async cred => {
        let request;
        try {
          request = lazy.check_blockage(cred, this.#pubKeys);
@@ -868,22 +861,12 @@ class LoxImpl {
        // from the Lox authority. So there shouldn't be any adverse side effects to
        // loosing migrationCred.
        // TODO: Confirm this is safe to lose.
    const migrationCred = lazy.handle_check_blockage(
      cred,
      response
    );
    request = lazy.blockage_migration(
      cred,
      migrationCred,
      this.#pubKeys
    );
        const migrationCred = lazy.handle_check_blockage(cred, response);
        request = lazy.blockage_migration(cred, migrationCred, this.#pubKeys);
        response = await this.#makeRequest("blockagemigration", request);
    return lazy.handle_blockage_migration(
      cred,
      response,
      this.#pubKeys
        return lazy.handle_blockage_migration(cred, response, this.#pubKeys);
      })
    );
    }));
  }

  /**
@@ -901,17 +884,17 @@ class LoxImpl {
      // attempt trust promotion instead
      return this.#trustMigration(loxId);
    }
    return Boolean(await this.#changeCredentials(loxId, async cred => {
    let request = lazy.level_up(
      cred,
      this.#encTable,
      this.#pubKeys
    );
    return Boolean(
      await this.#changeCredentials(loxId, async cred => {
        let request = lazy.level_up(cred, this.#encTable, this.#pubKeys);
        let response;
        try {
          response = await this.#makeRequest("levelup", request);
        } catch (error) {
      if (error instanceof LoxError && error.code === LoxError.ErrorResponse) {
          if (
            error instanceof LoxError &&
            error.code === LoxError.ErrorResponse
          ) {
            // Not an error.
            lazy.logger.debug("Not ready for level up", error);
            return null;
@@ -919,7 +902,8 @@ class LoxImpl {
          throw error;
        }
        return lazy.handle_level_up(request, response, this.#pubKeys);
    }));
      })
    );
  }

  /**
@@ -935,13 +919,11 @@ class LoxImpl {
      this.#getPubKeys();
      return false;
    }
    return Boolean(await this.#changeCredentials(loxId, async cred => {
    return Boolean(
      await this.#changeCredentials(loxId, async cred => {
        let request;
        try {
      request = lazy.trust_promotion(
        cred,
        this.#pubKeys
      );
          request = lazy.trust_promotion(cred, this.#pubKeys);
        } catch (err) {
          // This function is called routinely during the background tasks without
          // previous checks on whether an upgrade is possible, so it is expected to
@@ -958,11 +940,7 @@ class LoxImpl {
        let promoCred = lazy.handle_trust_promotion(request, response);
        lazy.logger.debug("Formatted promotion cred: ", promoCred);

    request = lazy.trust_migration(
      cred,
      promoCred,
      this.#pubKeys
    );
        request = lazy.trust_migration(cred, promoCred, this.#pubKeys);
        response = await this.#makeRequest("trustmig", request);
        lazy.logger.debug("Got new credential: ", response);

@@ -970,7 +948,8 @@ class LoxImpl {
        // fails. The Lox authority will not accept a re-request to "trustmig" with
        // the same credentials.
        return lazy.handle_trust_migration(request, response);
    }));
      })
    );
  }

  /**