[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-115.7.0esr-13.5-1] 3 commits: Temporary commit: manually place generated wasm files



Title: GitLab

Pier Angelo Vendrame pushed to branch tor-browser-115.7.0esr-13.5-1 at The Tor Project / Applications / Tor Browser

Commits:

  • ebfac0ab
    by Cecylia Bocovich at 2024-01-26T16:27:01+00:00
    Temporary commit: manually place generated wasm files
    
    These files are built reproducibly using tor-browser-build: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/merge_requests/715
    
    We're manually adding them here while working on the interface, but
    eventually these should be placed in the right location using
    tor-browser-build.
    
  • 10d5eb0b
    by Cecylia Bocovich at 2024-01-26T16:27:01+00:00
    Lox integration
    
  • 478ddecb
    by Cecylia Bocovich at 2024-01-26T16:27:01+00:00
    fixup! Bug 40597: Implement TorSettings module
    
    Implement Lox backend.
    

9 changed files:

Changes:

  • dom/security/nsContentSecurityUtils.cpp
    ... ... @@ -618,6 +618,9 @@ bool nsContentSecurityUtils::IsEvalAllowed(JSContext* cx,
    618 618
     
    
    619 619
           // The Browser Toolbox/Console
    
    620 620
           "debugger"_ns,
    
    621
    +
    
    622
    +      // Tor Browser's Lox wasm integration
    
    623
    +      "resource://gre/modules/lox_wasm.jsm"_ns,
    
    621 624
       };
    
    622 625
     
    
    623 626
       // We also permit two specific idioms in eval()-like contexts. We'd like to
    

  • toolkit/components/lox/Lox.sys.mjs
    1
    +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
    
    2
    +import {
    
    3
    +  clearInterval,
    
    4
    +  setInterval,
    
    5
    +} from "resource://gre/modules/Timer.sys.mjs";
    
    6
    +
    
    7
    +const lazy = {};
    
    8
    +ChromeUtils.defineESModuleGetters(lazy, {
    
    9
    +  DomainFrontRequestBuilder:
    
    10
    +    "resource://gre/modules/DomainFrontedRequests.sys.mjs",
    
    11
    +  TorConnect: "resource://gre/modules/TorConnect.sys.mjs",
    
    12
    +  TorConnectState: "resource://gre/modules/TorConnect.sys.mjs",
    
    13
    +  TorSettings: "resource://gre/modules/TorSettings.sys.mjs",
    
    14
    +  TorSettingsTopics: "resource://gre/modules/TorSettings.sys.mjs",
    
    15
    +  TorBridgeSource: "resource://gre/modules/TorSettings.sys.mjs",
    
    16
    +});
    
    17
    +XPCOMUtils.defineLazyModuleGetters(lazy, {
    
    18
    +  init: "resource://gre/modules/lox_wasm.jsm",
    
    19
    +  open_invite: "resource://gre/modules/lox_wasm.jsm",
    
    20
    +  handle_new_lox_credential: "resource://gre/modules/lox_wasm.jsm",
    
    21
    +  set_panic_hook: "resource://gre/modules/lox_wasm.jsm",
    
    22
    +  invitation_is_trusted: "resource://gre/modules/lox_wasm.jsm",
    
    23
    +  issue_invite: "resource://gre/modules/lox_wasm.jsm",
    
    24
    +  prepare_invite: "resource://gre/modules/lox_wasm.jsm",
    
    25
    +  get_invites_remaining: "resource://gre/modules/lox_wasm.jsm",
    
    26
    +  get_trust_level: "resource://gre/modules/lox_wasm.jsm",
    
    27
    +  level_up: "resource://gre/modules/lox_wasm.jsm",
    
    28
    +  handle_level_up: "resource://gre/modules/lox_wasm.jsm",
    
    29
    +  trust_promotion: "resource://gre/modules/lox_wasm.jsm",
    
    30
    +  handle_trust_promotion: "resource://gre/modules/lox_wasm.jsm",
    
    31
    +  trust_migration: "resource://gre/modules/lox_wasm.jsm",
    
    32
    +  handle_trust_migration: "resource://gre/modules/lox_wasm.jsm",
    
    33
    +  get_next_unlock: "resource://gre/modules/lox_wasm.jsm",
    
    34
    +  check_blockage: "resource://gre/modules/lox_wasm.jsm",
    
    35
    +  handle_check_blockage: "resource://gre/modules/lox_wasm.jsm",
    
    36
    +  blockage_migration: "resource://gre/modules/lox_wasm.jsm",
    
    37
    +  handle_blockage_migration: "resource://gre/modules/lox_wasm.jsm",
    
    38
    +});
    
    39
    +
    
    40
    +export const LoxErrors = Object.freeze({
    
    41
    +  BadInvite: "BadInvite",
    
    42
    +  MissingCredential: "MissingCredential",
    
    43
    +  LoxServerUnreachable: "LoxServerUnreachable",
    
    44
    +  NoInvitations: "NoInvitations",
    
    45
    +  InitError: "InitializationError",
    
    46
    +  NotInitialized: "NotInitialized",
    
    47
    +});
    
    48
    +
    
    49
    +const LoxSettingsPrefs = Object.freeze({
    
    50
    +  /* string: the lox credential */
    
    51
    +  credentials: "lox.settings.credentials",
    
    52
    +  invites: "lox.settings.invites",
    
    53
    +  events: "lox.settings.events",
    
    54
    +  pubkeys: "lox.settings.pubkeys",
    
    55
    +  enctable: "lox.settings.enctable",
    
    56
    +  constants: "lox.settings.constants",
    
    57
    +});
    
    58
    +
    
    59
    +class LoxError extends Error {
    
    60
    +  constructor(type) {
    
    61
    +    super("");
    
    62
    +    this.type = type;
    
    63
    +  }
    
    64
    +}
    
    65
    +
    
    66
    +class LoxImpl {
    
    67
    +  #initialized = false;
    
    68
    +  #window = null;
    
    69
    +  #pubKeyPromise = null;
    
    70
    +  #encTablePromise = null;
    
    71
    +  #constantsPromise = null;
    
    72
    +  #domainFrontedRequests = null;
    
    73
    +  #invites = null;
    
    74
    +  #pubKeys = null;
    
    75
    +  #encTable = null;
    
    76
    +  #constants = null;
    
    77
    +  #credentials = null;
    
    78
    +  #events = [];
    
    79
    +  #backgroundInterval = null;
    
    80
    +
    
    81
    +  observe(subject, topic, data) {
    
    82
    +    switch (topic) {
    
    83
    +      case lazy.TorSettingsTopics.SettingsChanged:
    
    84
    +        const { changes } = subject.wrappedJSObject;
    
    85
    +        if (
    
    86
    +          changes.includes("bridges.enabled") ||
    
    87
    +          changes.includes("bridges.source") ||
    
    88
    +          changes.includes("bridges.lox_id")
    
    89
    +        ) {
    
    90
    +          // if lox_id has changed, clear event and invite queues
    
    91
    +          if (changes.includes("bridges.lox_id")) {
    
    92
    +            this.clearEventData();
    
    93
    +            this.clearInvites();
    
    94
    +          }
    
    95
    +
    
    96
    +          // Only run background tasks if Lox is enabled
    
    97
    +          if (this.#inuse) {
    
    98
    +            if (!this.#backgroundInterval) {
    
    99
    +              this.#backgroundInterval = setInterval(
    
    100
    +                this.#backgroundTasks.bind(this),
    
    101
    +                1000 * 60 * 60 * 12
    
    102
    +              );
    
    103
    +            }
    
    104
    +          } else if (this.#backgroundInterval) {
    
    105
    +            clearInterval(this.#backgroundInterval);
    
    106
    +            this.#backgroundInterval = null;
    
    107
    +          }
    
    108
    +        }
    
    109
    +        break;
    
    110
    +      case lazy.TorSettingsTopics.Ready:
    
    111
    +        // Run background tasks every 12 hours if Lox is enabled
    
    112
    +        if (this.#inuse) {
    
    113
    +          this.#backgroundInterval = setInterval(
    
    114
    +            this.#backgroundTasks.bind(this),
    
    115
    +            1000 * 60 * 60 * 12
    
    116
    +          );
    
    117
    +        }
    
    118
    +        break;
    
    119
    +    }
    
    120
    +  }
    
    121
    +
    
    122
    +  get #inuse() {
    
    123
    +    return (
    
    124
    +      lazy.TorSettings.bridges.enabled === true &&
    
    125
    +      lazy.TorSettings.bridges.source === lazy.TorBridgeSource.Lox &&
    
    126
    +      lazy.TorSettings.bridges.lox_id
    
    127
    +    );
    
    128
    +  }
    
    129
    +
    
    130
    +  /**
    
    131
    +   * Formats and returns bridges from the stored Lox credential
    
    132
    +   *
    
    133
    +   * @param {string} loxid The id string associated with a lox credential
    
    134
    +   *
    
    135
    +   * @returns {string[]} An array of formatted bridge lines. The array is empty
    
    136
    +   * if there are no bridges.
    
    137
    +   */
    
    138
    +  getBridges(loxid) {
    
    139
    +    if (!this.#initialized) {
    
    140
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    141
    +    }
    
    142
    +    if (loxid === null) {
    
    143
    +      return [];
    
    144
    +    }
    
    145
    +    if (!this.#credentials[loxid]) {
    
    146
    +      // This lox id doesn't correspond to a stored credential
    
    147
    +      throw new LoxError(LoxErrors.MissingCredential);
    
    148
    +    }
    
    149
    +    // Note: this is messy now but can be mostly removed after we have
    
    150
    +    // https://gitlab.torproject.org/tpo/anti-censorship/lox/-/issues/46
    
    151
    +    let bridgelines = JSON.parse(this.#credentials[loxid]).bridgelines;
    
    152
    +    let bridges = [];
    
    153
    +    for (const bridge of bridgelines) {
    
    154
    +      let addr = bridge.addr;
    
    155
    +      while (addr[addr.length - 1] === 0) {
    
    156
    +        addr.pop();
    
    157
    +      }
    
    158
    +      addr = new Uint8Array(addr);
    
    159
    +      let decoder = new TextDecoder("utf-8");
    
    160
    +      addr = decoder.decode(addr);
    
    161
    +
    
    162
    +      let info = bridge.info;
    
    163
    +      while (info[info.length - 1] === 0) {
    
    164
    +        info.pop();
    
    165
    +      }
    
    166
    +      info = new Uint8Array(info);
    
    167
    +      info = decoder.decode(info);
    
    168
    +
    
    169
    +      let regexpTransport = /type=([a-zA-Z0-9]*)/;
    
    170
    +      let transport = info.match(regexpTransport);
    
    171
    +      if (transport !== null) {
    
    172
    +        transport = transport[1];
    
    173
    +      } else {
    
    174
    +        transport = "";
    
    175
    +      }
    
    176
    +
    
    177
    +      let regexpFingerprint = /fingerprint=\"([a-zA-Z0-9]*)\"/;
    
    178
    +      let fingerprint = info.match(regexpFingerprint);
    
    179
    +      if (fingerprint !== null) {
    
    180
    +        fingerprint = fingerprint[1];
    
    181
    +      } else {
    
    182
    +        fingerprint = "";
    
    183
    +      }
    
    184
    +
    
    185
    +      let regexpParams = /params=Some\(\{(.*)\}\)/;
    
    186
    +      let params = info.match(regexpParams);
    
    187
    +      if (params !== null) {
    
    188
    +        params = params[1]
    
    189
    +          .replaceAll('"', "")
    
    190
    +          .replaceAll(": ", "=")
    
    191
    +          .replaceAll(",", " ");
    
    192
    +      } else {
    
    193
    +        params = "";
    
    194
    +      }
    
    195
    +
    
    196
    +      bridges.push(
    
    197
    +        `${transport} ${addr}:${bridge.port} ${fingerprint} ${params}`
    
    198
    +      );
    
    199
    +    }
    
    200
    +    return bridges;
    
    201
    +  }
    
    202
    +
    
    203
    +  #store() {
    
    204
    +    Services.prefs.setStringPref(LoxSettingsPrefs.pubkeys, this.#pubKeys);
    
    205
    +    Services.prefs.setStringPref(LoxSettingsPrefs.enctable, this.#encTable);
    
    206
    +    Services.prefs.setStringPref(LoxSettingsPrefs.constants, this.#constants);
    
    207
    +    Services.prefs.setStringPref(
    
    208
    +      LoxSettingsPrefs.credentials,
    
    209
    +      JSON.stringify(this.#credentials)
    
    210
    +    );
    
    211
    +    Services.prefs.setStringPref(
    
    212
    +      LoxSettingsPrefs.invites,
    
    213
    +      JSON.stringify(this.#invites)
    
    214
    +    );
    
    215
    +    Services.prefs.setStringPref(
    
    216
    +      LoxSettingsPrefs.events,
    
    217
    +      JSON.stringify(this.#events)
    
    218
    +    );
    
    219
    +  }
    
    220
    +
    
    221
    +  #load() {
    
    222
    +    if (this.#credentials === null) {
    
    223
    +      let cred = Services.prefs.getStringPref(LoxSettingsPrefs.credentials, "");
    
    224
    +      this.#credentials = cred !== "" ? JSON.parse(cred) : {};
    
    225
    +      let invites = Services.prefs.getStringPref(LoxSettingsPrefs.invites, "");
    
    226
    +      if (invites !== "") {
    
    227
    +        this.#invites = JSON.parse(invites);
    
    228
    +      }
    
    229
    +      let events = Services.prefs.getStringPref(LoxSettingsPrefs.events, "");
    
    230
    +      if (events !== "") {
    
    231
    +        this.#events = JSON.parse(events);
    
    232
    +      }
    
    233
    +    }
    
    234
    +    this.#pubKeys = Services.prefs.getStringPref(
    
    235
    +      LoxSettingsPrefs.pubkeys,
    
    236
    +      null
    
    237
    +    );
    
    238
    +    this.#encTable = Services.prefs.getStringPref(
    
    239
    +      LoxSettingsPrefs.enctable,
    
    240
    +      null
    
    241
    +    );
    
    242
    +    this.#constants = Services.prefs.getStringPref(
    
    243
    +      LoxSettingsPrefs.constants,
    
    244
    +      null
    
    245
    +    );
    
    246
    +  }
    
    247
    +
    
    248
    +  async #getPubKeys() {
    
    249
    +    if (this.#pubKeyPromise === null) {
    
    250
    +      this.#pubKeyPromise = this.#makeRequest("pubkeys", [])
    
    251
    +        .then(pubKeys => {
    
    252
    +          this.#pubKeys = JSON.stringify(pubKeys);
    
    253
    +        })
    
    254
    +        .catch(() => {
    
    255
    +          // We always try to update, but if that doesn't work fall back to stored data
    
    256
    +          if (!this.#pubKeys) {
    
    257
    +            throw new LoxError(LoxErrors.LoxServerUnreachable);
    
    258
    +          }
    
    259
    +        });
    
    260
    +    }
    
    261
    +    await this.#pubKeyPromise;
    
    262
    +  }
    
    263
    +
    
    264
    +  async #getEncTable() {
    
    265
    +    if (this.#encTablePromise === null) {
    
    266
    +      this.#encTablePromise = this.#makeRequest("reachability", [])
    
    267
    +        .then(encTable => {
    
    268
    +          this.#encTable = JSON.stringify(encTable);
    
    269
    +        })
    
    270
    +        .catch(() => {
    
    271
    +          // Try to update first, but if that doesn't work fall back to stored data
    
    272
    +          if (!this.#encTable) {
    
    273
    +            throw new LoxError(LoxErrors.LoxServerUnreachable);
    
    274
    +          }
    
    275
    +        });
    
    276
    +    }
    
    277
    +    await this.#encTablePromise;
    
    278
    +  }
    
    279
    +
    
    280
    +  async #getConstants() {
    
    281
    +    if (this.#constantsPromise === null) {
    
    282
    +      // Try to update first, but if that doesn't work fall back to stored data
    
    283
    +      this.#constantsPromise = this.#makeRequest("constants", [])
    
    284
    +        .then(constants => {
    
    285
    +          this.#constants = JSON.stringify(constants);
    
    286
    +        })
    
    287
    +        .catch(() => {
    
    288
    +          if (!this.#constants) {
    
    289
    +            throw new LoxError(LoxErrors.LoxServerUnreachable);
    
    290
    +          }
    
    291
    +        });
    
    292
    +    }
    
    293
    +    await this.#constantsPromise;
    
    294
    +  }
    
    295
    +
    
    296
    +  /**
    
    297
    +   * Check for blockages and attempt to perform a levelup
    
    298
    +   *
    
    299
    +   * If either blockages or a levelup happened, add an event to the event queue
    
    300
    +   */
    
    301
    +  async #backgroundTasks() {
    
    302
    +    if (!this.#initialized) {
    
    303
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    304
    +    }
    
    305
    +    const loxid = lazy.TorSettings.bridges.lox_id;
    
    306
    +    try {
    
    307
    +      const levelup = await this.#attemptUpgrade(loxid);
    
    308
    +      if (levelup) {
    
    309
    +        const level = lazy.get_trust_level(this.#credentials[loxid]);
    
    310
    +        const newEvent = {
    
    311
    +          type: "levelup",
    
    312
    +          newlevel: level,
    
    313
    +        };
    
    314
    +        this.#events.push(newEvent);
    
    315
    +        this.#store();
    
    316
    +      }
    
    317
    +    } catch (err) {
    
    318
    +      console.log(err);
    
    319
    +    }
    
    320
    +    try {
    
    321
    +      const leveldown = await this.#blockageMigration(loxid);
    
    322
    +      if (leveldown) {
    
    323
    +        let level = lazy.get_trust_level(this.#credentials[loxid]);
    
    324
    +        const newEvent = {
    
    325
    +          type: "blockage",
    
    326
    +          newlevel: level,
    
    327
    +        };
    
    328
    +        this.#events.push(newEvent);
    
    329
    +        this.#store();
    
    330
    +      }
    
    331
    +    } catch (err) {
    
    332
    +      console.log(err);
    
    333
    +    }
    
    334
    +  }
    
    335
    +
    
    336
    +  /**
    
    337
    +   * Generates a new random lox id to be associated with an invitation/credential
    
    338
    +   */
    
    339
    +  #genLoxId() {
    
    340
    +    return crypto.randomUUID();
    
    341
    +  }
    
    342
    +
    
    343
    +  async init() {
    
    344
    +    // If lox_id is set, load it
    
    345
    +    Services.obs.addObserver(this, lazy.TorSettingsTopics.SettingsChanged);
    
    346
    +    Services.obs.addObserver(this, lazy.TorSettingsTopics.Ready);
    
    347
    +
    
    348
    +    // Hack to make the generated wasm happy
    
    349
    +    this.#window = {
    
    350
    +      crypto,
    
    351
    +    };
    
    352
    +    this.#window.window = this.#window;
    
    353
    +    await lazy.init(this.#window);
    
    354
    +    lazy.set_panic_hook();
    
    355
    +    if (typeof lazy.open_invite !== "function") {
    
    356
    +      throw new LoxError(LoxErrors.InitError);
    
    357
    +    }
    
    358
    +    this.#invites = [];
    
    359
    +    this.#events = [];
    
    360
    +    this.#load();
    
    361
    +    this.#initialized = true;
    
    362
    +  }
    
    363
    +
    
    364
    +  async uninit() {
    
    365
    +    Services.obs.removeObserver(this, lazy.TorSettingsTopics.SettingsChanged);
    
    366
    +    Services.obs.removeObserver(this, lazy.TorSettingsTopics.Ready);
    
    367
    +    if (this.#domainFrontedRequests !== null) {
    
    368
    +      try {
    
    369
    +        const domainFronting = await this.#domainFrontedRequests;
    
    370
    +        domainFronting.uninit();
    
    371
    +      } catch {}
    
    372
    +      this.#domainFrontedRequests = null;
    
    373
    +    }
    
    374
    +    this.#initialized = false;
    
    375
    +    this.#window = null;
    
    376
    +    this.#invites = null;
    
    377
    +    this.#pubKeys = null;
    
    378
    +    this.#encTable = null;
    
    379
    +    this.#constants = null;
    
    380
    +    this.#pubKeyPromise = null;
    
    381
    +    this.#encTablePromise = null;
    
    382
    +    this.#constantsPromise = null;
    
    383
    +    this.#credentials = null;
    
    384
    +    this.#events = [];
    
    385
    +    if (this.#backgroundInterval) {
    
    386
    +      clearInterval(this.#backgroundInterval);
    
    387
    +    }
    
    388
    +    this.#backgroundInterval = null;
    
    389
    +  }
    
    390
    +
    
    391
    +  /**
    
    392
    +   * Parses an input string to check if it is a valid Lox invitation
    
    393
    +   *
    
    394
    +   * @param {string} invite A Lox invitation
    
    395
    +   * @returns {Promise<bool>} A promise that resolves to true if the value passed
    
    396
    +   * in was a Lox invitation and false if it is not
    
    397
    +   */
    
    398
    +  async validateInvitation(invite) {
    
    399
    +    if (!this.#initialized) {
    
    400
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    401
    +    }
    
    402
    +    try {
    
    403
    +      await lazy.invitation_is_trusted(invite);
    
    404
    +    } catch (err) {
    
    405
    +      console.log(err);
    
    406
    +      return false;
    
    407
    +    }
    
    408
    +    return true;
    
    409
    +  }
    
    410
    +
    
    411
    +  // Note: This is only here for testing purposes. We're going to be using telegram
    
    412
    +  // to issue open invitations for Lox bridges.
    
    413
    +  async requestOpenInvite() {
    
    414
    +    if (!this.#initialized) {
    
    415
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    416
    +    }
    
    417
    +    let invite = await this.#makeRequest("invite", []);
    
    418
    +    console.log(invite);
    
    419
    +    return invite;
    
    420
    +  }
    
    421
    +
    
    422
    +  /**
    
    423
    +   * Redeems a Lox invitation to obtain a credential and bridges
    
    424
    +   *
    
    425
    +   * @param {string} invite A Lox invitation
    
    426
    +   * @returns {Promise<string>} A promise with the loxid of the associated credential on success
    
    427
    +   */
    
    428
    +  async redeemInvite(invite) {
    
    429
    +    if (!this.#initialized) {
    
    430
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    431
    +    }
    
    432
    +    await this.#getPubKeys();
    
    433
    +    let request = await lazy.open_invite(invite.invite);
    
    434
    +    let id = this.#genLoxId();
    
    435
    +    let response = await this.#makeRequest(
    
    436
    +      "openreq",
    
    437
    +      JSON.parse(request).request
    
    438
    +    );
    
    439
    +    console.log("openreq response: ", response);
    
    440
    +    if (response.hasOwnProperty("error")) {
    
    441
    +      throw new LoxError(LoxErrors.BadInvite);
    
    442
    +    }
    
    443
    +    let cred = lazy.handle_new_lox_credential(
    
    444
    +      request,
    
    445
    +      JSON.stringify(response),
    
    446
    +      this.#pubKeys
    
    447
    +    );
    
    448
    +    this.#credentials[id] = cred;
    
    449
    +    this.#store();
    
    450
    +    return id;
    
    451
    +  }
    
    452
    +
    
    453
    +  /**
    
    454
    +   * Get metadata on all invites historically generated by this credential
    
    455
    +   *
    
    456
    +   * @returns {object[]} A list of all historical invites
    
    457
    +   */
    
    458
    +  getInvites() {
    
    459
    +    if (!this.#initialized) {
    
    460
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    461
    +    }
    
    462
    +    return this.#invites;
    
    463
    +  }
    
    464
    +
    
    465
    +  /**
    
    466
    +   * Generates a new trusted Lox invitation that a user can pass to their contacts
    
    467
    +   *
    
    468
    +   * @returns {Promise<string>} A promise that resolves to a valid Lox invitation. The promise
    
    469
    +   *    will reject if:
    
    470
    +   *      - there is no saved Lox credential
    
    471
    +   *      - the saved credential does not have any invitations available
    
    472
    +   */
    
    473
    +  async generateInvite() {
    
    474
    +    if (!this.#initialized) {
    
    475
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    476
    +    }
    
    477
    +    const loxid = lazy.TorSettings.bridges.lox_id;
    
    478
    +    if (!loxid || !this.#credentials[loxid]) {
    
    479
    +      throw new LoxError(LoxErrors.MissingCredential);
    
    480
    +    }
    
    481
    +    await this.#getPubKeys();
    
    482
    +    await this.#getEncTable();
    
    483
    +    let level = lazy.get_trust_level(this.#credentials[loxid]);
    
    484
    +    if (level < 1) {
    
    485
    +      throw new LoxError(LoxErrors.NoInvitations);
    
    486
    +    }
    
    487
    +    let request = lazy.issue_invite(
    
    488
    +      JSON.stringify(this.#credentials[loxid]),
    
    489
    +      this.#encTable,
    
    490
    +      this.#pubKeys
    
    491
    +    );
    
    492
    +    let response;
    
    493
    +    try {
    
    494
    +      response = await this.#makeRequest(
    
    495
    +        "issueinvite",
    
    496
    +        JSON.parse(request).request
    
    497
    +      );
    
    498
    +    } catch {
    
    499
    +      throw new LoxError(LoxErrors.LoxServerUnreachable);
    
    500
    +    }
    
    501
    +    if (response.hasOwnProperty("error")) {
    
    502
    +      console.log(response.error);
    
    503
    +      throw new LoxError(LoxErrors.NoInvitations);
    
    504
    +    } else {
    
    505
    +      this.#credentials[loxid] = response;
    
    506
    +      const invite = lazy.prepare_invite(response);
    
    507
    +      this.#invites.push(invite);
    
    508
    +      // cap length of stored invites
    
    509
    +      if (this.#invites.len > 50) {
    
    510
    +        this.#invites.shift();
    
    511
    +      }
    
    512
    +      return invite;
    
    513
    +    }
    
    514
    +  }
    
    515
    +
    
    516
    +  /**
    
    517
    +   * Get the number of invites that a user has remaining
    
    518
    +   *
    
    519
    +   * @returns {Promise<int>} A promise with the number of invites that can still be generated
    
    520
    +   *    by a user's credential. This promise will reject if:
    
    521
    +   *        - There is no credential
    
    522
    +   */
    
    523
    +  getRemainingInviteCount() {
    
    524
    +    if (!this.#initialized) {
    
    525
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    526
    +    }
    
    527
    +    const loxid = lazy.TorSettings.bridges.lox_id;
    
    528
    +    if (!loxid || !this.#credentials[loxid]) {
    
    529
    +      throw new LoxError(LoxErrors.MissingCredential);
    
    530
    +    }
    
    531
    +    return parseInt(lazy.get_invites_remaining(this.#credentials[loxid]));
    
    532
    +  }
    
    533
    +
    
    534
    +  async #blockageMigration(loxid) {
    
    535
    +    if (!loxid || !this.#credentials[loxid]) {
    
    536
    +      throw new LoxError(LoxErrors.MissingCredential);
    
    537
    +    }
    
    538
    +    await this.#getPubKeys();
    
    539
    +    let request;
    
    540
    +    try {
    
    541
    +      request = lazy.check_blockage(this.#credentials[loxid], this.#pubKeys);
    
    542
    +    } catch {
    
    543
    +      console.log("Not ready for blockage migration");
    
    544
    +      return false;
    
    545
    +    }
    
    546
    +    let response = await this.#makeRequest("checkblockage", request);
    
    547
    +    if (response.hasOwnProperty("error")) {
    
    548
    +      console.log(response.error);
    
    549
    +      throw new LoxError(LoxErrors.LoxServerUnreachable);
    
    550
    +    }
    
    551
    +    const migrationCred = lazy.handle_check_blockage(
    
    552
    +      this.#credentials[loxid],
    
    553
    +      JSON.stringify(response)
    
    554
    +    );
    
    555
    +    request = lazy.blockage_migration(
    
    556
    +      this.#credentials[loxid],
    
    557
    +      migrationCred,
    
    558
    +      this.#pubKeys
    
    559
    +    );
    
    560
    +    response = await this.#makeRequest("blockagemigration", request);
    
    561
    +    if (response.hasOwnProperty("error")) {
    
    562
    +      console.log(response.error);
    
    563
    +      throw new LoxError(LoxErrors.LoxServerUnreachable);
    
    564
    +    }
    
    565
    +    const cred = lazy.handle_blockage_migration(
    
    566
    +      this.#credentials[loxid],
    
    567
    +      JSON.stringify(response),
    
    568
    +      this.#pubKeys
    
    569
    +    );
    
    570
    +    this.#credentials[loxid] = cred;
    
    571
    +    this.#store();
    
    572
    +    return true;
    
    573
    +  }
    
    574
    +
    
    575
    +  /** Attempts to upgrade the currently saved Lox credential.
    
    576
    +   *  If an upgrade is available, save an event in the event list.
    
    577
    +   *
    
    578
    +   *  @returns {boolean} whether a levelup event occured
    
    579
    +   */
    
    580
    +  async #attemptUpgrade(loxid) {
    
    581
    +    if (!loxid || !this.#credentials[loxid]) {
    
    582
    +      throw new LoxError(LoxErrors.MissingCredential);
    
    583
    +    }
    
    584
    +    await this.#getPubKeys();
    
    585
    +    await this.#getEncTable();
    
    586
    +    await this.#getConstants();
    
    587
    +    let success = false;
    
    588
    +    let level = lazy.get_trust_level(this.#credentials[loxid]);
    
    589
    +    if (level < 1) {
    
    590
    +      // attempt trust promotion instead
    
    591
    +      try {
    
    592
    +        success = await this.#trustMigration();
    
    593
    +      } catch (err) {
    
    594
    +        console.log(err);
    
    595
    +        return false;
    
    596
    +      }
    
    597
    +    } else {
    
    598
    +      let request = lazy.level_up(
    
    599
    +        this.#credentials[loxid],
    
    600
    +        this.#encTable,
    
    601
    +        this.#pubKeys
    
    602
    +      );
    
    603
    +      const response = await this.#makeRequest("levelup", request);
    
    604
    +      if (response.hasOwnProperty("error")) {
    
    605
    +        console.log(response.error);
    
    606
    +        throw new LoxError(LoxErrors.LoxServerUnreachable);
    
    607
    +      }
    
    608
    +      const cred = lazy.handle_level_up(
    
    609
    +        request,
    
    610
    +        JSON.stringify(response),
    
    611
    +        this.#pubKeys
    
    612
    +      );
    
    613
    +      this.#credentials[loxid] = cred;
    
    614
    +      return true;
    
    615
    +    }
    
    616
    +    return success;
    
    617
    +  }
    
    618
    +
    
    619
    +  /**
    
    620
    +   * Attempt to migrate from an untrusted to a trusted Lox credential
    
    621
    +   *
    
    622
    +   * @returns {Promise<bool>} A bool value indicated whether the credential
    
    623
    +   *    was successfully migrated.
    
    624
    +   */
    
    625
    +  async #trustMigration() {
    
    626
    +    const loxid = lazy.TorSettings.bridges.lox_id;
    
    627
    +    if (!loxid || !this.#credentials[loxid]) {
    
    628
    +      throw new LoxError(LoxErrors.MissingCredential);
    
    629
    +    }
    
    630
    +    await this.#getPubKeys();
    
    631
    +    return new Promise((resolve, reject) => {
    
    632
    +      let request = "";
    
    633
    +      try {
    
    634
    +        request = lazy.trust_promotion(this.#credentials[loxid], this.#pubKeys);
    
    635
    +      } catch (err) {
    
    636
    +        console.log("Not ready to upgrade");
    
    637
    +        resolve(false);
    
    638
    +      }
    
    639
    +      this.#makeRequest("trustpromo", JSON.parse(request).request)
    
    640
    +        .then(response => {
    
    641
    +          if (response.hasOwnProperty("error")) {
    
    642
    +            resolve(false);
    
    643
    +          }
    
    644
    +          console.log("Got promotion cred");
    
    645
    +          console.log(response);
    
    646
    +          console.log(request);
    
    647
    +          let promoCred = lazy.handle_trust_promotion(
    
    648
    +            request,
    
    649
    +            JSON.stringify(response)
    
    650
    +          );
    
    651
    +          console.log("Formatted promotion cred");
    
    652
    +          request = lazy.trust_migration(
    
    653
    +            this.#credentials[loxid],
    
    654
    +            promoCred,
    
    655
    +            this.#pubKeys
    
    656
    +          );
    
    657
    +          console.log("Formatted migration request");
    
    658
    +          this.#makeRequest("trustmig", JSON.parse(request).request)
    
    659
    +            .then(response => {
    
    660
    +              if (response.hasOwnProperty("error")) {
    
    661
    +                resolve(false);
    
    662
    +              }
    
    663
    +              console.log("Got new credential");
    
    664
    +              let cred = lazy.handle_trust_migration(request, response);
    
    665
    +              this.#credentials[loxid] = cred;
    
    666
    +              this.#store();
    
    667
    +              resolve(true);
    
    668
    +            })
    
    669
    +            .catch(err => {
    
    670
    +              console.log(err);
    
    671
    +              console.log("Failed trust migration");
    
    672
    +              resolve(false);
    
    673
    +            });
    
    674
    +        })
    
    675
    +        .catch(err => {
    
    676
    +          console.log(err);
    
    677
    +          console.log("Failed trust promotion");
    
    678
    +          resolve(false);
    
    679
    +        });
    
    680
    +    });
    
    681
    +  }
    
    682
    +
    
    683
    +  /**
    
    684
    +   * @typedef {object} EventData
    
    685
    +   *
    
    686
    +   * @property {string} [type] - the type of event. This should be one of:
    
    687
    +   *   ("levelup", "blockage")
    
    688
    +   * @property {integer} [newlevel] - the new level, after the event. Levels count
    
    689
    +   * from 0, but "blockage" events can never take the user to 0, so this will always
    
    690
    +   * be 1 or greater.
    
    691
    +   */
    
    692
    +
    
    693
    +  /**
    
    694
    +   * Get a list of accumulated events
    
    695
    +   *
    
    696
    +   * @returns {Promise<EventData[]>} A promise with a list of the accumulated,
    
    697
    +   *   unacknowledged events associated with a user's credential. This promise will reject if
    
    698
    +   *        - There is no credential
    
    699
    +   */
    
    700
    +  getEventData() {
    
    701
    +    if (!this.#initialized) {
    
    702
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    703
    +    }
    
    704
    +    const loxid = lazy.TorSettings.bridges.lox_id;
    
    705
    +    if (!loxid || !this.#credentials[loxid]) {
    
    706
    +      throw new LoxError(LoxErrors.MissingCredential);
    
    707
    +    }
    
    708
    +    return this.#events;
    
    709
    +  }
    
    710
    +
    
    711
    +  /**
    
    712
    +   * Clears accumulated event data
    
    713
    +   */
    
    714
    +  clearEventData() {
    
    715
    +    if (!this.#initialized) {
    
    716
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    717
    +    }
    
    718
    +    this.#events = [];
    
    719
    +    this.#store();
    
    720
    +  }
    
    721
    +
    
    722
    +  /**
    
    723
    +   * Clears accumulated invitations
    
    724
    +   */
    
    725
    +  clearInvites() {
    
    726
    +    if (!this.#initialized) {
    
    727
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    728
    +    }
    
    729
    +    this.#invites = [];
    
    730
    +    this.#store();
    
    731
    +  }
    
    732
    +
    
    733
    +  /**
    
    734
    +   * @typedef {object} UnlockData
    
    735
    +   *
    
    736
    +   * @property {string} date - The date-time for the next level up, formatted as YYYY-MM-DDTHH:mm:ssZ.
    
    737
    +   * @property {integer} nextLevel - The next level. Levels count from 0, so this will be 1 or greater.
    
    738
    +   *
    
    739
    +   */
    
    740
    +
    
    741
    +  /**
    
    742
    +   * Get dates at which access to new features will unlock
    
    743
    +   */
    
    744
    +  async getNextUnlock() {
    
    745
    +    if (!this.#initialized) {
    
    746
    +      throw new LoxError(LoxErrors.NotInitialized);
    
    747
    +    }
    
    748
    +    const loxid = lazy.TorSettings.bridges.lox_id;
    
    749
    +    if (!loxid || !this.#credentials[loxid]) {
    
    750
    +      throw new LoxError(LoxErrors.MissingCredential);
    
    751
    +    }
    
    752
    +    await this.#getConstants();
    
    753
    +    let nextUnlocks = JSON.parse(
    
    754
    +      lazy.get_next_unlock(this.#constants, this.#credentials[loxid])
    
    755
    +    );
    
    756
    +    const level = lazy.get_trust_level(this.#credentials[loxid]);
    
    757
    +    const unlocks = {
    
    758
    +      date: nextUnlocks.trust_level_unlock_date,
    
    759
    +      level: level + 1,
    
    760
    +    };
    
    761
    +    return unlocks;
    
    762
    +  }
    
    763
    +
    
    764
    +  async #makeRequest(procedure, args) {
    
    765
    +    // TODO: Customize to for Lox
    
    766
    +    const serviceUrl = "https://rdsys-frontend-01.torproject.org/lox";
    
    767
    +    const url = `${serviceUrl}/${procedure}`;
    
    768
    +
    
    769
    +    if (lazy.TorConnect.state === lazy.TorConnectState.Bootstrapped) {
    
    770
    +      const request = await fetch(url, {
    
    771
    +        method: "POST",
    
    772
    +        headers: {
    
    773
    +          "Content-Type": "application/vnd.api+json",
    
    774
    +        },
    
    775
    +        body: JSON.stringify(args),
    
    776
    +      });
    
    777
    +      return request.json();
    
    778
    +    }
    
    779
    +
    
    780
    +    if (this.#domainFrontedRequests === null) {
    
    781
    +      this.#domainFrontedRequests = new Promise((resolve, reject) => {
    
    782
    +        // TODO: Customize to the values for Lox
    
    783
    +        const reflector = Services.prefs.getStringPref(
    
    784
    +          "extensions.torlauncher.bridgedb_reflector"
    
    785
    +        );
    
    786
    +        const front = Services.prefs.getStringPref(
    
    787
    +          "extensions.torlauncher.bridgedb_front"
    
    788
    +        );
    
    789
    +        const builder = new lazy.DomainFrontRequestBuilder();
    
    790
    +        builder
    
    791
    +          .init(reflector, front)
    
    792
    +          .then(() => resolve(builder))
    
    793
    +          .catch(reject);
    
    794
    +      });
    
    795
    +    }
    
    796
    +    const builder = await this.#domainFrontedRequests;
    
    797
    +    return builder.buildPostRequest(url, args);
    
    798
    +  }
    
    799
    +}
    
    800
    +
    
    801
    +export const Lox = new LoxImpl();

  • toolkit/components/lox/content/lox_wasm_bg.wasm
    No preview for this file type
  • toolkit/components/lox/jar.mn
    1
    +toolkit.jar:
    
    2
    +    content/global/lox/lox_wasm_bg.wasm                      (content/lox_wasm_bg.wasm)

  • toolkit/components/lox/lox_wasm.jsm
    1
    +var EXPORTED_SYMBOLS = ["set_panic_hook", "open_invite", "handle_new_lox_credential", "trust_promotion", "handle_trust_promotion", "trust_migration", "handle_trust_migration", "level_up", "handle_level_up", "issue_invite", "handle_issue_invite", "prepare_invite", "redeem_invite", "handle_redeem_invite", "check_blockage", "handle_check_blockage", "blockage_migration", "handle_blockage_migration", "get_last_upgrade_time", "get_trust_level", "get_invites_remaining", "get_issued_invite_expiry", "get_received_invite_expiry", "get_bridgelines_from_bucket", "invitation_is_trusted", "get_next_unlock", "init", "initSync"];
    
    2
    +
    
    3
    +let wasm;
    
    4
    +let module;
    
    5
    +
    
    6
    +const heap = new Array(128).fill(undefined);
    
    7
    +
    
    8
    +heap.push(undefined, null, true, false);
    
    9
    +
    
    10
    +function getObject(idx) { return heap[idx]; }
    
    11
    +
    
    12
    +let heap_next = heap.length;
    
    13
    +
    
    14
    +function dropObject(idx) {
    
    15
    +    if (idx < 132) return;
    
    16
    +    heap[idx] = heap_next;
    
    17
    +    heap_next = idx;
    
    18
    +}
    
    19
    +
    
    20
    +function takeObject(idx) {
    
    21
    +    const ret = getObject(idx);
    
    22
    +    dropObject(idx);
    
    23
    +    return ret;
    
    24
    +}
    
    25
    +
    
    26
    +const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
    
    27
    +
    
    28
    +if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
    
    29
    +
    
    30
    +let cachedUint8Memory0 = null;
    
    31
    +
    
    32
    +function getUint8Memory0() {
    
    33
    +    if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
    
    34
    +        cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
    
    35
    +    }
    
    36
    +    return cachedUint8Memory0;
    
    37
    +}
    
    38
    +
    
    39
    +function getStringFromWasm0(ptr, len) {
    
    40
    +    ptr = ptr >>> 0;
    
    41
    +    return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
    
    42
    +}
    
    43
    +
    
    44
    +function addHeapObject(obj) {
    
    45
    +    if (heap_next === heap.length) heap.push(heap.length + 1);
    
    46
    +    const idx = heap_next;
    
    47
    +    heap_next = heap[idx];
    
    48
    +
    
    49
    +    heap[idx] = obj;
    
    50
    +    return idx;
    
    51
    +}
    
    52
    +/**
    
    53
    +*/
    
    54
    +function set_panic_hook() {
    
    55
    +    wasm.set_panic_hook();
    
    56
    +}
    
    57
    +
    
    58
    +let WASM_VECTOR_LEN = 0;
    
    59
    +
    
    60
    +function passArray8ToWasm0(arg, malloc) {
    
    61
    +    const ptr = malloc(arg.length * 1, 1) >>> 0;
    
    62
    +    getUint8Memory0().set(arg, ptr / 1);
    
    63
    +    WASM_VECTOR_LEN = arg.length;
    
    64
    +    return ptr;
    
    65
    +}
    
    66
    +
    
    67
    +let cachedInt32Memory0 = null;
    
    68
    +
    
    69
    +function getInt32Memory0() {
    
    70
    +    if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
    
    71
    +        cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
    
    72
    +    }
    
    73
    +    return cachedInt32Memory0;
    
    74
    +}
    
    75
    +/**
    
    76
    +* @param {Uint8Array} invite
    
    77
    +* @returns {string}
    
    78
    +*/
    
    79
    +function open_invite(invite) {
    
    80
    +    let deferred3_0;
    
    81
    +    let deferred3_1;
    
    82
    +    try {
    
    83
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    84
    +        const ptr0 = passArray8ToWasm0(invite, wasm.__wbindgen_malloc);
    
    85
    +        const len0 = WASM_VECTOR_LEN;
    
    86
    +        wasm.open_invite(retptr, ptr0, len0);
    
    87
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    88
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    89
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    90
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    91
    +        var ptr2 = r0;
    
    92
    +        var len2 = r1;
    
    93
    +        if (r3) {
    
    94
    +            ptr2 = 0; len2 = 0;
    
    95
    +            throw takeObject(r2);
    
    96
    +        }
    
    97
    +        deferred3_0 = ptr2;
    
    98
    +        deferred3_1 = len2;
    
    99
    +        return getStringFromWasm0(ptr2, len2);
    
    100
    +    } finally {
    
    101
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    102
    +        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
    
    103
    +    }
    
    104
    +}
    
    105
    +
    
    106
    +const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
    
    107
    +
    
    108
    +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
    
    109
    +    ? function (arg, view) {
    
    110
    +    return cachedTextEncoder.encodeInto(arg, view);
    
    111
    +}
    
    112
    +    : function (arg, view) {
    
    113
    +    const buf = cachedTextEncoder.encode(arg);
    
    114
    +    view.set(buf);
    
    115
    +    return {
    
    116
    +        read: arg.length,
    
    117
    +        written: buf.length
    
    118
    +    };
    
    119
    +});
    
    120
    +
    
    121
    +function passStringToWasm0(arg, malloc, realloc) {
    
    122
    +
    
    123
    +    if (realloc === undefined) {
    
    124
    +        const buf = cachedTextEncoder.encode(arg);
    
    125
    +        const ptr = malloc(buf.length, 1) >>> 0;
    
    126
    +        getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
    
    127
    +        WASM_VECTOR_LEN = buf.length;
    
    128
    +        return ptr;
    
    129
    +    }
    
    130
    +
    
    131
    +    let len = arg.length;
    
    132
    +    let ptr = malloc(len, 1) >>> 0;
    
    133
    +
    
    134
    +    const mem = getUint8Memory0();
    
    135
    +
    
    136
    +    let offset = 0;
    
    137
    +
    
    138
    +    for (; offset < len; offset++) {
    
    139
    +        const code = arg.charCodeAt(offset);
    
    140
    +        if (code > 0x7F) break;
    
    141
    +        mem[ptr + offset] = code;
    
    142
    +    }
    
    143
    +
    
    144
    +    if (offset !== len) {
    
    145
    +        if (offset !== 0) {
    
    146
    +            arg = arg.slice(offset);
    
    147
    +        }
    
    148
    +        ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
    
    149
    +        const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
    
    150
    +        const ret = encodeString(arg, view);
    
    151
    +
    
    152
    +        offset += ret.written;
    
    153
    +    }
    
    154
    +
    
    155
    +    WASM_VECTOR_LEN = offset;
    
    156
    +    return ptr;
    
    157
    +}
    
    158
    +/**
    
    159
    +* @param {string} open_lox_result
    
    160
    +* @param {string} open_lox_response
    
    161
    +* @param {string} lox_pub
    
    162
    +* @returns {string}
    
    163
    +*/
    
    164
    +function handle_new_lox_credential(open_lox_result, open_lox_response, lox_pub) {
    
    165
    +    let deferred5_0;
    
    166
    +    let deferred5_1;
    
    167
    +    try {
    
    168
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    169
    +        const ptr0 = passStringToWasm0(open_lox_result, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    170
    +        const len0 = WASM_VECTOR_LEN;
    
    171
    +        const ptr1 = passStringToWasm0(open_lox_response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    172
    +        const len1 = WASM_VECTOR_LEN;
    
    173
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    174
    +        const len2 = WASM_VECTOR_LEN;
    
    175
    +        wasm.handle_new_lox_credential(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    176
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    177
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    178
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    179
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    180
    +        var ptr4 = r0;
    
    181
    +        var len4 = r1;
    
    182
    +        if (r3) {
    
    183
    +            ptr4 = 0; len4 = 0;
    
    184
    +            throw takeObject(r2);
    
    185
    +        }
    
    186
    +        deferred5_0 = ptr4;
    
    187
    +        deferred5_1 = len4;
    
    188
    +        return getStringFromWasm0(ptr4, len4);
    
    189
    +    } finally {
    
    190
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    191
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    192
    +    }
    
    193
    +}
    
    194
    +
    
    195
    +/**
    
    196
    +* @param {string} open_lox_cred
    
    197
    +* @param {string} lox_pub
    
    198
    +* @returns {string}
    
    199
    +*/
    
    200
    +function trust_promotion(open_lox_cred, lox_pub) {
    
    201
    +    let deferred4_0;
    
    202
    +    let deferred4_1;
    
    203
    +    try {
    
    204
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    205
    +        const ptr0 = passStringToWasm0(open_lox_cred, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    206
    +        const len0 = WASM_VECTOR_LEN;
    
    207
    +        const ptr1 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    208
    +        const len1 = WASM_VECTOR_LEN;
    
    209
    +        wasm.trust_promotion(retptr, ptr0, len0, ptr1, len1);
    
    210
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    211
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    212
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    213
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    214
    +        var ptr3 = r0;
    
    215
    +        var len3 = r1;
    
    216
    +        if (r3) {
    
    217
    +            ptr3 = 0; len3 = 0;
    
    218
    +            throw takeObject(r2);
    
    219
    +        }
    
    220
    +        deferred4_0 = ptr3;
    
    221
    +        deferred4_1 = len3;
    
    222
    +        return getStringFromWasm0(ptr3, len3);
    
    223
    +    } finally {
    
    224
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    225
    +        wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
    
    226
    +    }
    
    227
    +}
    
    228
    +
    
    229
    +/**
    
    230
    +* @param {string} trust_promo_request
    
    231
    +* @param {string} trust_promo_response
    
    232
    +* @returns {string}
    
    233
    +*/
    
    234
    +function handle_trust_promotion(trust_promo_request, trust_promo_response) {
    
    235
    +    let deferred4_0;
    
    236
    +    let deferred4_1;
    
    237
    +    try {
    
    238
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    239
    +        const ptr0 = passStringToWasm0(trust_promo_request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    240
    +        const len0 = WASM_VECTOR_LEN;
    
    241
    +        const ptr1 = passStringToWasm0(trust_promo_response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    242
    +        const len1 = WASM_VECTOR_LEN;
    
    243
    +        wasm.handle_trust_promotion(retptr, ptr0, len0, ptr1, len1);
    
    244
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    245
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    246
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    247
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    248
    +        var ptr3 = r0;
    
    249
    +        var len3 = r1;
    
    250
    +        if (r3) {
    
    251
    +            ptr3 = 0; len3 = 0;
    
    252
    +            throw takeObject(r2);
    
    253
    +        }
    
    254
    +        deferred4_0 = ptr3;
    
    255
    +        deferred4_1 = len3;
    
    256
    +        return getStringFromWasm0(ptr3, len3);
    
    257
    +    } finally {
    
    258
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    259
    +        wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
    
    260
    +    }
    
    261
    +}
    
    262
    +
    
    263
    +/**
    
    264
    +* @param {string} open_lox_cred
    
    265
    +* @param {string} trust_promo_cred
    
    266
    +* @param {string} lox_pub
    
    267
    +* @returns {string}
    
    268
    +*/
    
    269
    +function trust_migration(open_lox_cred, trust_promo_cred, lox_pub) {
    
    270
    +    let deferred5_0;
    
    271
    +    let deferred5_1;
    
    272
    +    try {
    
    273
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    274
    +        const ptr0 = passStringToWasm0(open_lox_cred, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    275
    +        const len0 = WASM_VECTOR_LEN;
    
    276
    +        const ptr1 = passStringToWasm0(trust_promo_cred, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    277
    +        const len1 = WASM_VECTOR_LEN;
    
    278
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    279
    +        const len2 = WASM_VECTOR_LEN;
    
    280
    +        wasm.trust_migration(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    281
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    282
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    283
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    284
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    285
    +        var ptr4 = r0;
    
    286
    +        var len4 = r1;
    
    287
    +        if (r3) {
    
    288
    +            ptr4 = 0; len4 = 0;
    
    289
    +            throw takeObject(r2);
    
    290
    +        }
    
    291
    +        deferred5_0 = ptr4;
    
    292
    +        deferred5_1 = len4;
    
    293
    +        return getStringFromWasm0(ptr4, len4);
    
    294
    +    } finally {
    
    295
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    296
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    297
    +    }
    
    298
    +}
    
    299
    +
    
    300
    +/**
    
    301
    +* @param {string} trust_migration_request
    
    302
    +* @param {string} trust_migration_response
    
    303
    +* @param {string} lox_pub
    
    304
    +* @returns {string}
    
    305
    +*/
    
    306
    +function handle_trust_migration(trust_migration_request, trust_migration_response, lox_pub) {
    
    307
    +    let deferred5_0;
    
    308
    +    let deferred5_1;
    
    309
    +    try {
    
    310
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    311
    +        const ptr0 = passStringToWasm0(trust_migration_request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    312
    +        const len0 = WASM_VECTOR_LEN;
    
    313
    +        const ptr1 = passStringToWasm0(trust_migration_response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    314
    +        const len1 = WASM_VECTOR_LEN;
    
    315
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    316
    +        const len2 = WASM_VECTOR_LEN;
    
    317
    +        wasm.handle_trust_migration(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    318
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    319
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    320
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    321
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    322
    +        var ptr4 = r0;
    
    323
    +        var len4 = r1;
    
    324
    +        if (r3) {
    
    325
    +            ptr4 = 0; len4 = 0;
    
    326
    +            throw takeObject(r2);
    
    327
    +        }
    
    328
    +        deferred5_0 = ptr4;
    
    329
    +        deferred5_1 = len4;
    
    330
    +        return getStringFromWasm0(ptr4, len4);
    
    331
    +    } finally {
    
    332
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    333
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    334
    +    }
    
    335
    +}
    
    336
    +
    
    337
    +/**
    
    338
    +* @param {string} level_one_cred
    
    339
    +* @param {string} encrypted_table
    
    340
    +* @param {string} lox_pub
    
    341
    +* @returns {string}
    
    342
    +*/
    
    343
    +function level_up(level_one_cred, encrypted_table, lox_pub) {
    
    344
    +    let deferred5_0;
    
    345
    +    let deferred5_1;
    
    346
    +    try {
    
    347
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    348
    +        const ptr0 = passStringToWasm0(level_one_cred, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    349
    +        const len0 = WASM_VECTOR_LEN;
    
    350
    +        const ptr1 = passStringToWasm0(encrypted_table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    351
    +        const len1 = WASM_VECTOR_LEN;
    
    352
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    353
    +        const len2 = WASM_VECTOR_LEN;
    
    354
    +        wasm.level_up(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    355
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    356
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    357
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    358
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    359
    +        var ptr4 = r0;
    
    360
    +        var len4 = r1;
    
    361
    +        if (r3) {
    
    362
    +            ptr4 = 0; len4 = 0;
    
    363
    +            throw takeObject(r2);
    
    364
    +        }
    
    365
    +        deferred5_0 = ptr4;
    
    366
    +        deferred5_1 = len4;
    
    367
    +        return getStringFromWasm0(ptr4, len4);
    
    368
    +    } finally {
    
    369
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    370
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    371
    +    }
    
    372
    +}
    
    373
    +
    
    374
    +/**
    
    375
    +* @param {string} levelup_request
    
    376
    +* @param {string} levelup_response
    
    377
    +* @param {string} lox_pub
    
    378
    +* @returns {string}
    
    379
    +*/
    
    380
    +function handle_level_up(levelup_request, levelup_response, lox_pub) {
    
    381
    +    let deferred5_0;
    
    382
    +    let deferred5_1;
    
    383
    +    try {
    
    384
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    385
    +        const ptr0 = passStringToWasm0(levelup_request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    386
    +        const len0 = WASM_VECTOR_LEN;
    
    387
    +        const ptr1 = passStringToWasm0(levelup_response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    388
    +        const len1 = WASM_VECTOR_LEN;
    
    389
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    390
    +        const len2 = WASM_VECTOR_LEN;
    
    391
    +        wasm.handle_level_up(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    392
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    393
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    394
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    395
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    396
    +        var ptr4 = r0;
    
    397
    +        var len4 = r1;
    
    398
    +        if (r3) {
    
    399
    +            ptr4 = 0; len4 = 0;
    
    400
    +            throw takeObject(r2);
    
    401
    +        }
    
    402
    +        deferred5_0 = ptr4;
    
    403
    +        deferred5_1 = len4;
    
    404
    +        return getStringFromWasm0(ptr4, len4);
    
    405
    +    } finally {
    
    406
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    407
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    408
    +    }
    
    409
    +}
    
    410
    +
    
    411
    +/**
    
    412
    +* @param {string} trusted_cred
    
    413
    +* @param {string} encrypted_table
    
    414
    +* @param {string} lox_pub
    
    415
    +* @returns {string}
    
    416
    +*/
    
    417
    +function issue_invite(trusted_cred, encrypted_table, lox_pub) {
    
    418
    +    let deferred5_0;
    
    419
    +    let deferred5_1;
    
    420
    +    try {
    
    421
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    422
    +        const ptr0 = passStringToWasm0(trusted_cred, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    423
    +        const len0 = WASM_VECTOR_LEN;
    
    424
    +        const ptr1 = passStringToWasm0(encrypted_table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    425
    +        const len1 = WASM_VECTOR_LEN;
    
    426
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    427
    +        const len2 = WASM_VECTOR_LEN;
    
    428
    +        wasm.issue_invite(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    429
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    430
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    431
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    432
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    433
    +        var ptr4 = r0;
    
    434
    +        var len4 = r1;
    
    435
    +        if (r3) {
    
    436
    +            ptr4 = 0; len4 = 0;
    
    437
    +            throw takeObject(r2);
    
    438
    +        }
    
    439
    +        deferred5_0 = ptr4;
    
    440
    +        deferred5_1 = len4;
    
    441
    +        return getStringFromWasm0(ptr4, len4);
    
    442
    +    } finally {
    
    443
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    444
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    445
    +    }
    
    446
    +}
    
    447
    +
    
    448
    +/**
    
    449
    +* @param {string} issue_invite_request
    
    450
    +* @param {string} issue_invite_response
    
    451
    +* @param {string} lox_pub
    
    452
    +* @returns {string}
    
    453
    +*/
    
    454
    +function handle_issue_invite(issue_invite_request, issue_invite_response, lox_pub) {
    
    455
    +    let deferred5_0;
    
    456
    +    let deferred5_1;
    
    457
    +    try {
    
    458
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    459
    +        const ptr0 = passStringToWasm0(issue_invite_request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    460
    +        const len0 = WASM_VECTOR_LEN;
    
    461
    +        const ptr1 = passStringToWasm0(issue_invite_response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    462
    +        const len1 = WASM_VECTOR_LEN;
    
    463
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    464
    +        const len2 = WASM_VECTOR_LEN;
    
    465
    +        wasm.handle_issue_invite(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    466
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    467
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    468
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    469
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    470
    +        var ptr4 = r0;
    
    471
    +        var len4 = r1;
    
    472
    +        if (r3) {
    
    473
    +            ptr4 = 0; len4 = 0;
    
    474
    +            throw takeObject(r2);
    
    475
    +        }
    
    476
    +        deferred5_0 = ptr4;
    
    477
    +        deferred5_1 = len4;
    
    478
    +        return getStringFromWasm0(ptr4, len4);
    
    479
    +    } finally {
    
    480
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    481
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    482
    +    }
    
    483
    +}
    
    484
    +
    
    485
    +/**
    
    486
    +* @param {string} invitation_cred
    
    487
    +* @returns {string}
    
    488
    +*/
    
    489
    +function prepare_invite(invitation_cred) {
    
    490
    +    let deferred3_0;
    
    491
    +    let deferred3_1;
    
    492
    +    try {
    
    493
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    494
    +        const ptr0 = passStringToWasm0(invitation_cred, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    495
    +        const len0 = WASM_VECTOR_LEN;
    
    496
    +        wasm.prepare_invite(retptr, ptr0, len0);
    
    497
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    498
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    499
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    500
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    501
    +        var ptr2 = r0;
    
    502
    +        var len2 = r1;
    
    503
    +        if (r3) {
    
    504
    +            ptr2 = 0; len2 = 0;
    
    505
    +            throw takeObject(r2);
    
    506
    +        }
    
    507
    +        deferred3_0 = ptr2;
    
    508
    +        deferred3_1 = len2;
    
    509
    +        return getStringFromWasm0(ptr2, len2);
    
    510
    +    } finally {
    
    511
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    512
    +        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
    
    513
    +    }
    
    514
    +}
    
    515
    +
    
    516
    +/**
    
    517
    +* @param {string} invitation
    
    518
    +* @param {string} lox_pub
    
    519
    +* @returns {string}
    
    520
    +*/
    
    521
    +function redeem_invite(invitation, lox_pub) {
    
    522
    +    let deferred4_0;
    
    523
    +    let deferred4_1;
    
    524
    +    try {
    
    525
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    526
    +        const ptr0 = passStringToWasm0(invitation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    527
    +        const len0 = WASM_VECTOR_LEN;
    
    528
    +        const ptr1 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    529
    +        const len1 = WASM_VECTOR_LEN;
    
    530
    +        wasm.redeem_invite(retptr, ptr0, len0, ptr1, len1);
    
    531
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    532
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    533
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    534
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    535
    +        var ptr3 = r0;
    
    536
    +        var len3 = r1;
    
    537
    +        if (r3) {
    
    538
    +            ptr3 = 0; len3 = 0;
    
    539
    +            throw takeObject(r2);
    
    540
    +        }
    
    541
    +        deferred4_0 = ptr3;
    
    542
    +        deferred4_1 = len3;
    
    543
    +        return getStringFromWasm0(ptr3, len3);
    
    544
    +    } finally {
    
    545
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    546
    +        wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
    
    547
    +    }
    
    548
    +}
    
    549
    +
    
    550
    +/**
    
    551
    +* @param {string} redeem_invite_request
    
    552
    +* @param {string} redeem_invite_response
    
    553
    +* @param {string} lox_pub
    
    554
    +* @returns {string}
    
    555
    +*/
    
    556
    +function handle_redeem_invite(redeem_invite_request, redeem_invite_response, lox_pub) {
    
    557
    +    let deferred5_0;
    
    558
    +    let deferred5_1;
    
    559
    +    try {
    
    560
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    561
    +        const ptr0 = passStringToWasm0(redeem_invite_request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    562
    +        const len0 = WASM_VECTOR_LEN;
    
    563
    +        const ptr1 = passStringToWasm0(redeem_invite_response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    564
    +        const len1 = WASM_VECTOR_LEN;
    
    565
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    566
    +        const len2 = WASM_VECTOR_LEN;
    
    567
    +        wasm.handle_redeem_invite(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    568
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    569
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    570
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    571
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    572
    +        var ptr4 = r0;
    
    573
    +        var len4 = r1;
    
    574
    +        if (r3) {
    
    575
    +            ptr4 = 0; len4 = 0;
    
    576
    +            throw takeObject(r2);
    
    577
    +        }
    
    578
    +        deferred5_0 = ptr4;
    
    579
    +        deferred5_1 = len4;
    
    580
    +        return getStringFromWasm0(ptr4, len4);
    
    581
    +    } finally {
    
    582
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    583
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    584
    +    }
    
    585
    +}
    
    586
    +
    
    587
    +/**
    
    588
    +* @param {string} lox_cred
    
    589
    +* @param {string} lox_pub
    
    590
    +* @returns {string}
    
    591
    +*/
    
    592
    +function check_blockage(lox_cred, lox_pub) {
    
    593
    +    let deferred4_0;
    
    594
    +    let deferred4_1;
    
    595
    +    try {
    
    596
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    597
    +        const ptr0 = passStringToWasm0(lox_cred, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    598
    +        const len0 = WASM_VECTOR_LEN;
    
    599
    +        const ptr1 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    600
    +        const len1 = WASM_VECTOR_LEN;
    
    601
    +        wasm.check_blockage(retptr, ptr0, len0, ptr1, len1);
    
    602
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    603
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    604
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    605
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    606
    +        var ptr3 = r0;
    
    607
    +        var len3 = r1;
    
    608
    +        if (r3) {
    
    609
    +            ptr3 = 0; len3 = 0;
    
    610
    +            throw takeObject(r2);
    
    611
    +        }
    
    612
    +        deferred4_0 = ptr3;
    
    613
    +        deferred4_1 = len3;
    
    614
    +        return getStringFromWasm0(ptr3, len3);
    
    615
    +    } finally {
    
    616
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    617
    +        wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
    
    618
    +    }
    
    619
    +}
    
    620
    +
    
    621
    +/**
    
    622
    +* @param {string} check_blockage_request
    
    623
    +* @param {string} check_blockage_response
    
    624
    +* @returns {string}
    
    625
    +*/
    
    626
    +function handle_check_blockage(check_blockage_request, check_blockage_response) {
    
    627
    +    let deferred4_0;
    
    628
    +    let deferred4_1;
    
    629
    +    try {
    
    630
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    631
    +        const ptr0 = passStringToWasm0(check_blockage_request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    632
    +        const len0 = WASM_VECTOR_LEN;
    
    633
    +        const ptr1 = passStringToWasm0(check_blockage_response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    634
    +        const len1 = WASM_VECTOR_LEN;
    
    635
    +        wasm.handle_check_blockage(retptr, ptr0, len0, ptr1, len1);
    
    636
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    637
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    638
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    639
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    640
    +        var ptr3 = r0;
    
    641
    +        var len3 = r1;
    
    642
    +        if (r3) {
    
    643
    +            ptr3 = 0; len3 = 0;
    
    644
    +            throw takeObject(r2);
    
    645
    +        }
    
    646
    +        deferred4_0 = ptr3;
    
    647
    +        deferred4_1 = len3;
    
    648
    +        return getStringFromWasm0(ptr3, len3);
    
    649
    +    } finally {
    
    650
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    651
    +        wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
    
    652
    +    }
    
    653
    +}
    
    654
    +
    
    655
    +/**
    
    656
    +* @param {string} lox_cred
    
    657
    +* @param {string} check_migration_cred
    
    658
    +* @param {string} lox_pub
    
    659
    +* @returns {string}
    
    660
    +*/
    
    661
    +function blockage_migration(lox_cred, check_migration_cred, lox_pub) {
    
    662
    +    let deferred5_0;
    
    663
    +    let deferred5_1;
    
    664
    +    try {
    
    665
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    666
    +        const ptr0 = passStringToWasm0(lox_cred, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    667
    +        const len0 = WASM_VECTOR_LEN;
    
    668
    +        const ptr1 = passStringToWasm0(check_migration_cred, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    669
    +        const len1 = WASM_VECTOR_LEN;
    
    670
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    671
    +        const len2 = WASM_VECTOR_LEN;
    
    672
    +        wasm.blockage_migration(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    673
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    674
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    675
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    676
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    677
    +        var ptr4 = r0;
    
    678
    +        var len4 = r1;
    
    679
    +        if (r3) {
    
    680
    +            ptr4 = 0; len4 = 0;
    
    681
    +            throw takeObject(r2);
    
    682
    +        }
    
    683
    +        deferred5_0 = ptr4;
    
    684
    +        deferred5_1 = len4;
    
    685
    +        return getStringFromWasm0(ptr4, len4);
    
    686
    +    } finally {
    
    687
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    688
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    689
    +    }
    
    690
    +}
    
    691
    +
    
    692
    +/**
    
    693
    +* @param {string} blockage_migration_request
    
    694
    +* @param {string} blockage_migration_response
    
    695
    +* @param {string} lox_pub
    
    696
    +* @returns {string}
    
    697
    +*/
    
    698
    +function handle_blockage_migration(blockage_migration_request, blockage_migration_response, lox_pub) {
    
    699
    +    let deferred5_0;
    
    700
    +    let deferred5_1;
    
    701
    +    try {
    
    702
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    703
    +        const ptr0 = passStringToWasm0(blockage_migration_request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    704
    +        const len0 = WASM_VECTOR_LEN;
    
    705
    +        const ptr1 = passStringToWasm0(blockage_migration_response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    706
    +        const len1 = WASM_VECTOR_LEN;
    
    707
    +        const ptr2 = passStringToWasm0(lox_pub, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    708
    +        const len2 = WASM_VECTOR_LEN;
    
    709
    +        wasm.handle_blockage_migration(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
    
    710
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    711
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    712
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    713
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    714
    +        var ptr4 = r0;
    
    715
    +        var len4 = r1;
    
    716
    +        if (r3) {
    
    717
    +            ptr4 = 0; len4 = 0;
    
    718
    +            throw takeObject(r2);
    
    719
    +        }
    
    720
    +        deferred5_0 = ptr4;
    
    721
    +        deferred5_1 = len4;
    
    722
    +        return getStringFromWasm0(ptr4, len4);
    
    723
    +    } finally {
    
    724
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    725
    +        wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
    
    726
    +    }
    
    727
    +}
    
    728
    +
    
    729
    +/**
    
    730
    +* @param {string} lox_cred_str
    
    731
    +* @returns {string}
    
    732
    +*/
    
    733
    +function get_last_upgrade_time(lox_cred_str) {
    
    734
    +    let deferred3_0;
    
    735
    +    let deferred3_1;
    
    736
    +    try {
    
    737
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    738
    +        const ptr0 = passStringToWasm0(lox_cred_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    739
    +        const len0 = WASM_VECTOR_LEN;
    
    740
    +        wasm.get_last_upgrade_time(retptr, ptr0, len0);
    
    741
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    742
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    743
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    744
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    745
    +        var ptr2 = r0;
    
    746
    +        var len2 = r1;
    
    747
    +        if (r3) {
    
    748
    +            ptr2 = 0; len2 = 0;
    
    749
    +            throw takeObject(r2);
    
    750
    +        }
    
    751
    +        deferred3_0 = ptr2;
    
    752
    +        deferred3_1 = len2;
    
    753
    +        return getStringFromWasm0(ptr2, len2);
    
    754
    +    } finally {
    
    755
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    756
    +        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
    
    757
    +    }
    
    758
    +}
    
    759
    +
    
    760
    +/**
    
    761
    +* @param {string} lox_cred_str
    
    762
    +* @returns {string}
    
    763
    +*/
    
    764
    +function get_trust_level(lox_cred_str) {
    
    765
    +    let deferred3_0;
    
    766
    +    let deferred3_1;
    
    767
    +    try {
    
    768
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    769
    +        const ptr0 = passStringToWasm0(lox_cred_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    770
    +        const len0 = WASM_VECTOR_LEN;
    
    771
    +        wasm.get_trust_level(retptr, ptr0, len0);
    
    772
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    773
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    774
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    775
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    776
    +        var ptr2 = r0;
    
    777
    +        var len2 = r1;
    
    778
    +        if (r3) {
    
    779
    +            ptr2 = 0; len2 = 0;
    
    780
    +            throw takeObject(r2);
    
    781
    +        }
    
    782
    +        deferred3_0 = ptr2;
    
    783
    +        deferred3_1 = len2;
    
    784
    +        return getStringFromWasm0(ptr2, len2);
    
    785
    +    } finally {
    
    786
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    787
    +        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
    
    788
    +    }
    
    789
    +}
    
    790
    +
    
    791
    +/**
    
    792
    +* @param {string} lox_cred_str
    
    793
    +* @returns {string}
    
    794
    +*/
    
    795
    +function get_invites_remaining(lox_cred_str) {
    
    796
    +    let deferred3_0;
    
    797
    +    let deferred3_1;
    
    798
    +    try {
    
    799
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    800
    +        const ptr0 = passStringToWasm0(lox_cred_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    801
    +        const len0 = WASM_VECTOR_LEN;
    
    802
    +        wasm.get_invites_remaining(retptr, ptr0, len0);
    
    803
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    804
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    805
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    806
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    807
    +        var ptr2 = r0;
    
    808
    +        var len2 = r1;
    
    809
    +        if (r3) {
    
    810
    +            ptr2 = 0; len2 = 0;
    
    811
    +            throw takeObject(r2);
    
    812
    +        }
    
    813
    +        deferred3_0 = ptr2;
    
    814
    +        deferred3_1 = len2;
    
    815
    +        return getStringFromWasm0(ptr2, len2);
    
    816
    +    } finally {
    
    817
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    818
    +        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
    
    819
    +    }
    
    820
    +}
    
    821
    +
    
    822
    +/**
    
    823
    +* @param {string} lox_cred_str
    
    824
    +* @returns {string}
    
    825
    +*/
    
    826
    +function get_issued_invite_expiry(lox_cred_str) {
    
    827
    +    let deferred3_0;
    
    828
    +    let deferred3_1;
    
    829
    +    try {
    
    830
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    831
    +        const ptr0 = passStringToWasm0(lox_cred_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    832
    +        const len0 = WASM_VECTOR_LEN;
    
    833
    +        wasm.get_issued_invite_expiry(retptr, ptr0, len0);
    
    834
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    835
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    836
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    837
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    838
    +        var ptr2 = r0;
    
    839
    +        var len2 = r1;
    
    840
    +        if (r3) {
    
    841
    +            ptr2 = 0; len2 = 0;
    
    842
    +            throw takeObject(r2);
    
    843
    +        }
    
    844
    +        deferred3_0 = ptr2;
    
    845
    +        deferred3_1 = len2;
    
    846
    +        return getStringFromWasm0(ptr2, len2);
    
    847
    +    } finally {
    
    848
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    849
    +        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
    
    850
    +    }
    
    851
    +}
    
    852
    +
    
    853
    +/**
    
    854
    +* @param {string} invite_cred_str
    
    855
    +* @returns {string}
    
    856
    +*/
    
    857
    +function get_received_invite_expiry(invite_cred_str) {
    
    858
    +    let deferred3_0;
    
    859
    +    let deferred3_1;
    
    860
    +    try {
    
    861
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    862
    +        const ptr0 = passStringToWasm0(invite_cred_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    863
    +        const len0 = WASM_VECTOR_LEN;
    
    864
    +        wasm.get_received_invite_expiry(retptr, ptr0, len0);
    
    865
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    866
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    867
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    868
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    869
    +        var ptr2 = r0;
    
    870
    +        var len2 = r1;
    
    871
    +        if (r3) {
    
    872
    +            ptr2 = 0; len2 = 0;
    
    873
    +            throw takeObject(r2);
    
    874
    +        }
    
    875
    +        deferred3_0 = ptr2;
    
    876
    +        deferred3_1 = len2;
    
    877
    +        return getStringFromWasm0(ptr2, len2);
    
    878
    +    } finally {
    
    879
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    880
    +        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
    
    881
    +    }
    
    882
    +}
    
    883
    +
    
    884
    +/**
    
    885
    +* @param {string} lox_cred_str
    
    886
    +* @param {string} encrypted_table
    
    887
    +* @returns {string}
    
    888
    +*/
    
    889
    +function get_bridgelines_from_bucket(lox_cred_str, encrypted_table) {
    
    890
    +    let deferred4_0;
    
    891
    +    let deferred4_1;
    
    892
    +    try {
    
    893
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    894
    +        const ptr0 = passStringToWasm0(lox_cred_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    895
    +        const len0 = WASM_VECTOR_LEN;
    
    896
    +        const ptr1 = passStringToWasm0(encrypted_table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    897
    +        const len1 = WASM_VECTOR_LEN;
    
    898
    +        wasm.get_bridgelines_from_bucket(retptr, ptr0, len0, ptr1, len1);
    
    899
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    900
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    901
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    902
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    903
    +        var ptr3 = r0;
    
    904
    +        var len3 = r1;
    
    905
    +        if (r3) {
    
    906
    +            ptr3 = 0; len3 = 0;
    
    907
    +            throw takeObject(r2);
    
    908
    +        }
    
    909
    +        deferred4_0 = ptr3;
    
    910
    +        deferred4_1 = len3;
    
    911
    +        return getStringFromWasm0(ptr3, len3);
    
    912
    +    } finally {
    
    913
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    914
    +        wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
    
    915
    +    }
    
    916
    +}
    
    917
    +
    
    918
    +/**
    
    919
    +* @param {string} unspecified_invitation_str
    
    920
    +* @returns {boolean}
    
    921
    +*/
    
    922
    +function invitation_is_trusted(unspecified_invitation_str) {
    
    923
    +    try {
    
    924
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    925
    +        const ptr0 = passStringToWasm0(unspecified_invitation_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    926
    +        const len0 = WASM_VECTOR_LEN;
    
    927
    +        wasm.invitation_is_trusted(retptr, ptr0, len0);
    
    928
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    929
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    930
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    931
    +        if (r2) {
    
    932
    +            throw takeObject(r1);
    
    933
    +        }
    
    934
    +        return r0 !== 0;
    
    935
    +    } finally {
    
    936
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    937
    +    }
    
    938
    +}
    
    939
    +
    
    940
    +/**
    
    941
    +* @param {string} constants_str
    
    942
    +* @param {string} lox_cred_str
    
    943
    +* @returns {string}
    
    944
    +*/
    
    945
    +function get_next_unlock(constants_str, lox_cred_str) {
    
    946
    +    let deferred4_0;
    
    947
    +    let deferred4_1;
    
    948
    +    try {
    
    949
    +        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
    
    950
    +        const ptr0 = passStringToWasm0(constants_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    951
    +        const len0 = WASM_VECTOR_LEN;
    
    952
    +        const ptr1 = passStringToWasm0(lox_cred_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    953
    +        const len1 = WASM_VECTOR_LEN;
    
    954
    +        wasm.get_next_unlock(retptr, ptr0, len0, ptr1, len1);
    
    955
    +        var r0 = getInt32Memory0()[retptr / 4 + 0];
    
    956
    +        var r1 = getInt32Memory0()[retptr / 4 + 1];
    
    957
    +        var r2 = getInt32Memory0()[retptr / 4 + 2];
    
    958
    +        var r3 = getInt32Memory0()[retptr / 4 + 3];
    
    959
    +        var ptr3 = r0;
    
    960
    +        var len3 = r1;
    
    961
    +        if (r3) {
    
    962
    +            ptr3 = 0; len3 = 0;
    
    963
    +            throw takeObject(r2);
    
    964
    +        }
    
    965
    +        deferred4_0 = ptr3;
    
    966
    +        deferred4_1 = len3;
    
    967
    +        return getStringFromWasm0(ptr3, len3);
    
    968
    +    } finally {
    
    969
    +        wasm.__wbindgen_add_to_stack_pointer(16);
    
    970
    +        wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
    
    971
    +    }
    
    972
    +}
    
    973
    +
    
    974
    +function handleError(f, args) {
    
    975
    +    try {
    
    976
    +        return f.apply(this, args);
    
    977
    +    } catch (e) {
    
    978
    +        wasm.__wbindgen_exn_store(addHeapObject(e));
    
    979
    +    }
    
    980
    +}
    
    981
    +
    
    982
    +async function __wbg_load(module, imports) {
    
    983
    +    if (typeof Response === 'function' && module instanceof Response) {
    
    984
    +        if (typeof WebAssembly.instantiateStreaming === 'function') {
    
    985
    +            try {
    
    986
    +                return await WebAssembly.instantiateStreaming(module, imports);
    
    987
    +
    
    988
    +            } catch (e) {
    
    989
    +                if (module.headers.get('Content-Type') != 'application/wasm') {
    
    990
    +                    console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
    
    991
    +
    
    992
    +                } else {
    
    993
    +                    throw e;
    
    994
    +                }
    
    995
    +            }
    
    996
    +        }
    
    997
    +
    
    998
    +        const bytes = await module.arrayBuffer();
    
    999
    +        return await WebAssembly.instantiate(bytes, imports);
    
    1000
    +
    
    1001
    +    } else {
    
    1002
    +        const instance = await WebAssembly.instantiate(module, imports);
    
    1003
    +
    
    1004
    +        if (instance instanceof WebAssembly.Instance) {
    
    1005
    +            return { instance, module };
    
    1006
    +
    
    1007
    +        } else {
    
    1008
    +            return instance;
    
    1009
    +        }
    
    1010
    +    }
    
    1011
    +}
    
    1012
    +
    
    1013
    +function __wbg_get_imports(window) {
    
    1014
    +    const imports = {};
    
    1015
    +    imports.wbg = {};
    
    1016
    +    imports.wbg.__wbg_new0_622c21a64f3d83ea = function() {
    
    1017
    +        const ret = new Date();
    
    1018
    +        return addHeapObject(ret);
    
    1019
    +    };
    
    1020
    +    imports.wbg.__wbg_getTime_9272be78826033e1 = function(arg0) {
    
    1021
    +        const ret = getObject(arg0).getTime();
    
    1022
    +        return ret;
    
    1023
    +    };
    
    1024
    +    imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
    
    1025
    +        takeObject(arg0);
    
    1026
    +    };
    
    1027
    +    imports.wbg.__wbg_log_9b9925d843c39805 = function(arg0, arg1) {
    
    1028
    +        console.log(getStringFromWasm0(arg0, arg1));
    
    1029
    +    };
    
    1030
    +    imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
    
    1031
    +        const ret = getStringFromWasm0(arg0, arg1);
    
    1032
    +        return addHeapObject(ret);
    
    1033
    +    };
    
    1034
    +    imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
    
    1035
    +        const ret = new Error();
    
    1036
    +        return addHeapObject(ret);
    
    1037
    +    };
    
    1038
    +    imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
    
    1039
    +        const ret = getObject(arg1).stack;
    
    1040
    +        const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
    
    1041
    +        const len1 = WASM_VECTOR_LEN;
    
    1042
    +        getInt32Memory0()[arg0 / 4 + 1] = len1;
    
    1043
    +        getInt32Memory0()[arg0 / 4 + 0] = ptr1;
    
    1044
    +    };
    
    1045
    +    imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
    
    1046
    +        let deferred0_0;
    
    1047
    +        let deferred0_1;
    
    1048
    +        try {
    
    1049
    +            deferred0_0 = arg0;
    
    1050
    +            deferred0_1 = arg1;
    
    1051
    +            console.error(getStringFromWasm0(arg0, arg1));
    
    1052
    +        } finally {
    
    1053
    +            wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
    
    1054
    +        }
    
    1055
    +    };
    
    1056
    +    imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
    
    1057
    +        const ret = getObject(arg0);
    
    1058
    +        return addHeapObject(ret);
    
    1059
    +    };
    
    1060
    +    imports.wbg.__wbg_crypto_c48a774b022d20ac = function(arg0) {
    
    1061
    +        const ret = getObject(arg0).crypto;
    
    1062
    +        return addHeapObject(ret);
    
    1063
    +    };
    
    1064
    +    imports.wbg.__wbindgen_is_object = function(arg0) {
    
    1065
    +        const val = getObject(arg0);
    
    1066
    +        const ret = typeof(val) === 'object' && val !== null;
    
    1067
    +        return ret;
    
    1068
    +    };
    
    1069
    +    imports.wbg.__wbg_process_298734cf255a885d = function(arg0) {
    
    1070
    +        const ret = getObject(arg0).process;
    
    1071
    +        return addHeapObject(ret);
    
    1072
    +    };
    
    1073
    +    imports.wbg.__wbg_versions_e2e78e134e3e5d01 = function(arg0) {
    
    1074
    +        const ret = getObject(arg0).versions;
    
    1075
    +        return addHeapObject(ret);
    
    1076
    +    };
    
    1077
    +    imports.wbg.__wbg_node_1cd7a5d853dbea79 = function(arg0) {
    
    1078
    +        const ret = getObject(arg0).node;
    
    1079
    +        return addHeapObject(ret);
    
    1080
    +    };
    
    1081
    +    imports.wbg.__wbindgen_is_string = function(arg0) {
    
    1082
    +        const ret = typeof(getObject(arg0)) === 'string';
    
    1083
    +        return ret;
    
    1084
    +    };
    
    1085
    +    imports.wbg.__wbg_require_8f08ceecec0f4fee = function() { return handleError(function () {
    
    1086
    +        const ret = module.require;
    
    1087
    +        return addHeapObject(ret);
    
    1088
    +    }, arguments) };
    
    1089
    +    imports.wbg.__wbindgen_is_function = function(arg0) {
    
    1090
    +        const ret = typeof(getObject(arg0)) === 'function';
    
    1091
    +        return ret;
    
    1092
    +    };
    
    1093
    +    imports.wbg.__wbg_call_5da1969d7cd31ccd = function() { return handleError(function (arg0, arg1, arg2) {
    
    1094
    +        const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
    
    1095
    +        return addHeapObject(ret);
    
    1096
    +    }, arguments) };
    
    1097
    +    imports.wbg.__wbg_msCrypto_bcb970640f50a1e8 = function(arg0) {
    
    1098
    +        const ret = getObject(arg0).msCrypto;
    
    1099
    +        return addHeapObject(ret);
    
    1100
    +    };
    
    1101
    +    imports.wbg.__wbg_newwithlength_6c2df9e2f3028c43 = function(arg0) {
    
    1102
    +        const ret = new Uint8Array(arg0 >>> 0);
    
    1103
    +        return addHeapObject(ret);
    
    1104
    +    };
    
    1105
    +    imports.wbg.__wbg_self_f0e34d89f33b99fd = function() { return handleError(function () {
    
    1106
    +        const ret = window;
    
    1107
    +        return addHeapObject(ret);
    
    1108
    +    }, arguments) };
    
    1109
    +    imports.wbg.__wbg_window_d3b084224f4774d7 = function() { return handleError(function () {
    
    1110
    +        const ret = window.window;
    
    1111
    +        return addHeapObject(ret);
    
    1112
    +    }, arguments) };
    
    1113
    +    imports.wbg.__wbg_globalThis_9caa27ff917c6860 = function() { return handleError(function () {
    
    1114
    +        const ret = globalThis.globalThis;
    
    1115
    +        return addHeapObject(ret);
    
    1116
    +    }, arguments) };
    
    1117
    +    imports.wbg.__wbg_global_35dfdd59a4da3e74 = function() { return handleError(function () {
    
    1118
    +        const ret = global.global;
    
    1119
    +        return addHeapObject(ret);
    
    1120
    +    }, arguments) };
    
    1121
    +    imports.wbg.__wbindgen_is_undefined = function(arg0) {
    
    1122
    +        const ret = getObject(arg0) === undefined;
    
    1123
    +        return ret;
    
    1124
    +    };
    
    1125
    +    imports.wbg.__wbg_newnoargs_c62ea9419c21fbac = function(arg0, arg1) {
    
    1126
    +        const ret = new Function(getStringFromWasm0(arg0, arg1));
    
    1127
    +        return addHeapObject(ret);
    
    1128
    +    };
    
    1129
    +    imports.wbg.__wbg_call_90c26b09837aba1c = function() { return handleError(function (arg0, arg1) {
    
    1130
    +        const ret = getObject(arg0).call(getObject(arg1));
    
    1131
    +        return addHeapObject(ret);
    
    1132
    +    }, arguments) };
    
    1133
    +    imports.wbg.__wbindgen_memory = function() {
    
    1134
    +        const ret = wasm.memory;
    
    1135
    +        return addHeapObject(ret);
    
    1136
    +    };
    
    1137
    +    imports.wbg.__wbg_buffer_a448f833075b71ba = function(arg0) {
    
    1138
    +        const ret = getObject(arg0).buffer;
    
    1139
    +        return addHeapObject(ret);
    
    1140
    +    };
    
    1141
    +    imports.wbg.__wbg_newwithbyteoffsetandlength_d0482f893617af71 = function(arg0, arg1, arg2) {
    
    1142
    +        const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
    
    1143
    +        return addHeapObject(ret);
    
    1144
    +    };
    
    1145
    +    imports.wbg.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) {
    
    1146
    +        getObject(arg0).randomFillSync(takeObject(arg1));
    
    1147
    +    }, arguments) };
    
    1148
    +    imports.wbg.__wbg_subarray_2e940e41c0f5a1d9 = function(arg0, arg1, arg2) {
    
    1149
    +        const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
    
    1150
    +        return addHeapObject(ret);
    
    1151
    +    };
    
    1152
    +    imports.wbg.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) {
    
    1153
    +        getObject(arg0).getRandomValues(getObject(arg1));
    
    1154
    +    }, arguments) };
    
    1155
    +    imports.wbg.__wbg_new_8f67e318f15d7254 = function(arg0) {
    
    1156
    +        const ret = new Uint8Array(getObject(arg0));
    
    1157
    +        return addHeapObject(ret);
    
    1158
    +    };
    
    1159
    +    imports.wbg.__wbg_set_2357bf09366ee480 = function(arg0, arg1, arg2) {
    
    1160
    +        getObject(arg0).set(getObject(arg1), arg2 >>> 0);
    
    1161
    +    };
    
    1162
    +    imports.wbg.__wbindgen_throw = function(arg0, arg1) {
    
    1163
    +        throw new Error(getStringFromWasm0(arg0, arg1));
    
    1164
    +    };
    
    1165
    +
    
    1166
    +    return imports;
    
    1167
    +}
    
    1168
    +
    
    1169
    +function __wbg_init_memory(imports, maybe_memory) {
    
    1170
    +
    
    1171
    +}
    
    1172
    +
    
    1173
    +function __wbg_finalize_init(instance, module) {
    
    1174
    +    wasm = instance.exports;
    
    1175
    +    init.__wbindgen_wasm_module = module;
    
    1176
    +    cachedInt32Memory0 = null;
    
    1177
    +    cachedUint8Memory0 = null;
    
    1178
    +
    
    1179
    +
    
    1180
    +    return wasm;
    
    1181
    +}
    
    1182
    +
    
    1183
    +function initSync(module, window) {
    
    1184
    +    if (wasm !== undefined) return wasm;
    
    1185
    +
    
    1186
    +    const imports = __wbg_get_imports(window);
    
    1187
    +
    
    1188
    +    __wbg_init_memory(imports);
    
    1189
    +
    
    1190
    +    if (!(module instanceof WebAssembly.Module)) {
    
    1191
    +        module = new WebAssembly.Module(module);
    
    1192
    +    }
    
    1193
    +
    
    1194
    +    const instance = new WebAssembly.Instance(module, imports);
    
    1195
    +
    
    1196
    +    return __wbg_finalize_init(instance, module);
    
    1197
    +}
    
    1198
    +
    
    1199
    +async function init(window, input) {
    
    1200
    +    if (wasm !== undefined) return wasm;
    
    1201
    +
    
    1202
    +    if (typeof input === 'undefined') {{
    
    1203
    +        input = "chrome://global/content/lox/lox_wasm_bg.wasm";
    
    1204
    +    }}
    
    1205
    +    const imports = __wbg_get_imports(window);
    
    1206
    +
    
    1207
    +    if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
    
    1208
    +        input = fetch(input);
    
    1209
    +    }
    
    1210
    +
    
    1211
    +    __wbg_init_memory(imports);
    
    1212
    +
    
    1213
    +    const { instance, module } = await __wbg_load(await input, imports);
    
    1214
    +
    
    1215
    +    return __wbg_finalize_init(instance, module);
    
    1216
    +}
    
    1217
    +

  • toolkit/components/lox/moz.build
    1
    +EXTRA_JS_MODULES += [
    
    2
    +  "Lox.sys.mjs",
    
    3
    +  # Let's keep the old jsm format until wasm-bindgen is updated
    
    4
    +  "lox_wasm.jsm",
    
    5
    +]
    
    6
    +
    
    7
    +JAR_MANIFESTS += ["jar.mn"]

  • toolkit/components/moz.build
    ... ... @@ -46,6 +46,7 @@ DIRS += [
    46 46
         "httpsonlyerror",
    
    47 47
         "jsoncpp/src/lib_json",
    
    48 48
         "kvstore",
    
    49
    +    "lox",
    
    49 50
         "mediasniffer",
    
    50 51
         "mozintl",
    
    51 52
         "mozprotocol",
    

  • toolkit/components/tor-launcher/TorStartupService.sys.mjs
    ... ... @@ -54,5 +54,6 @@ export class TorStartupService {
    54 54
     
    
    55 55
         lazy.TorProviderBuilder.uninit();
    
    56 56
         lazy.TorLauncherUtil.cleanupTempDirectories();
    
    57
    +    lazy.TorSettings.uninit();
    
    57 58
       }
    
    58 59
     }

  • toolkit/modules/TorSettings.sys.mjs
    ... ... @@ -8,6 +8,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
    8 8
       TorLauncherUtil: "resource://gre/modules/TorLauncherUtil.sys.mjs",
    
    9 9
       TorProviderBuilder: "resource://gre/modules/TorProviderBuilder.sys.mjs",
    
    10 10
       TorProviderTopics: "resource://gre/modules/TorProviderBuilder.sys.mjs",
    
    11
    +  Lox: "resource://gre/modules/Lox.sys.mjs",
    
    11 12
     });
    
    12 13
     
    
    13 14
     ChromeUtils.defineLazyGetter(lazy, "logger", () => {
    
    ... ... @@ -40,6 +41,8 @@ const TorSettingsPrefs = Object.freeze({
    40 41
         enabled: "torbrowser.settings.bridges.enabled",
    
    41 42
         /* int: See TorBridgeSource */
    
    42 43
         source: "torbrowser.settings.bridges.source",
    
    44
    +    /* string: output of crypto.randomUUID() */
    
    45
    +    lox_id: "torbrowser.settings.bridges.lox_id",
    
    43 46
         /* string: obfs4|meek-azure|snowflake|etc */
    
    44 47
         builtin_type: "torbrowser.settings.bridges.builtin_type",
    
    45 48
         /* preference branch: each child branch should be a bridge string */
    
    ... ... @@ -86,6 +89,7 @@ export const TorBridgeSource = Object.freeze({
    86 89
       BuiltIn: 0,
    
    87 90
       BridgeDB: 1,
    
    88 91
       UserProvided: 2,
    
    92
    +  Lox: 3,
    
    89 93
     });
    
    90 94
     
    
    91 95
     export const TorProxyType = Object.freeze({
    
    ... ... @@ -159,6 +163,7 @@ class TorSettingsImpl {
    159 163
         bridges: {
    
    160 164
           enabled: false,
    
    161 165
           source: TorBridgeSource.Invalid,
    
    166
    +      lox_id: "",
    
    162 167
           builtin_type: "",
    
    163 168
           bridge_strings: [],
    
    164 169
         },
    
    ... ... @@ -292,6 +297,20 @@ class TorSettingsImpl {
    292 297
               this.bridges.source = TorBridgeSource.Invalid;
    
    293 298
             },
    
    294 299
           },
    
    300
    +      /**
    
    301
    +       * The lox id is used with the Lox "source", and remains set with the stored value when
    
    302
    +       * other sources are used.
    
    303
    +       *
    
    304
    +       * @type {string}
    
    305
    +       */
    
    306
    +      lox_id: {
    
    307
    +        callback: (val, addError) => {
    
    308
    +          if (!val) {
    
    309
    +            return;
    
    310
    +          }
    
    311
    +          this.bridges.bridge_strings = lazy.Lox.getBridges(val);
    
    312
    +        },
    
    313
    +      },
    
    295 314
         });
    
    296 315
         this.#addProperties("proxy", {
    
    297 316
           enabled: {},
    
    ... ... @@ -379,6 +398,9 @@ class TorSettingsImpl {
    379 398
           if (this.bridges.source !== TorBridgeSource.BuiltIn) {
    
    380 399
             this.bridges.builtin_type = "";
    
    381 400
           }
    
    401
    +      if (this.bridges.source !== TorBridgeSource.Lox) {
    
    402
    +        this.bridges.lox_id = "";
    
    403
    +      }
    
    382 404
           if (!this.proxy.enabled) {
    
    383 405
             this.proxy.type = TorProxyType.Invalid;
    
    384 406
             this.proxy.address = "";
    
    ... ... @@ -639,6 +661,14 @@ class TorSettingsImpl {
    639 661
           lazy.logger.error("Could not load the built-in PT config.", e);
    
    640 662
         }
    
    641 663
     
    
    664
    +    // Initialize this before loading from prefs because we need Lox initialized before
    
    665
    +    // any calls to Lox.getBridges()
    
    666
    +    try {
    
    667
    +      await lazy.Lox.init();
    
    668
    +    } catch (e) {
    
    669
    +      lazy.logger.error("Could not initialize Lox.", e.type);
    
    670
    +    }
    
    671
    +
    
    642 672
         // TODO: We could use a shared promise, and wait for it to be fullfilled
    
    643 673
         // instead of Service.obs.
    
    644 674
         if (lazy.TorLauncherUtil.shouldStartAndOwnTor) {
    
    ... ... @@ -668,6 +698,13 @@ class TorSettingsImpl {
    668 698
         }
    
    669 699
       }
    
    670 700
     
    
    701
    +  /**
    
    702
    +   * Unload or uninit our settings, and unregister observers.
    
    703
    +   */
    
    704
    +  async uninit() {
    
    705
    +    await lazy.Lox.uninit();
    
    706
    +  }
    
    707
    +
    
    671 708
       /**
    
    672 709
        * Check whether the object has been successfully initialized, and throw if
    
    673 710
        * it has not.
    
    ... ... @@ -738,6 +775,10 @@ class TorSettingsImpl {
    738 775
           TorSettingsPrefs.bridges.source,
    
    739 776
           TorBridgeSource.Invalid
    
    740 777
         );
    
    778
    +    this.bridges.lox_id = Services.prefs.getStringPref(
    
    779
    +      TorSettingsPrefs.bridges.lox_id,
    
    780
    +      ""
    
    781
    +    );
    
    741 782
         if (this.bridges.source == TorBridgeSource.BuiltIn) {
    
    742 783
           this.bridges.builtin_type = Services.prefs.getStringPref(
    
    743 784
             TorSettingsPrefs.bridges.builtin_type,
    
    ... ... @@ -823,6 +864,10 @@ class TorSettingsImpl {
    823 864
           TorSettingsPrefs.bridges.builtin_type,
    
    824 865
           this.bridges.builtin_type
    
    825 866
         );
    
    867
    +    Services.prefs.setStringPref(
    
    868
    +      TorSettingsPrefs.bridges.lox_id,
    
    869
    +      this.bridges.lox_id
    
    870
    +    );
    
    826 871
         // erase existing bridge strings
    
    827 872
         const bridgeBranchPrefs = Services.prefs
    
    828 873
           .getBranch(TorSettingsPrefs.bridges.bridge_strings)
    
    ... ... @@ -1013,6 +1058,9 @@ class TorSettingsImpl {
    1013 1058
               case TorBridgeSource.BuiltIn:
    
    1014 1059
                 this.bridges.builtin_type = settings.bridges.builtin_type;
    
    1015 1060
                 break;
    
    1061
    +          case TorBridgeSource.Lox:
    
    1062
    +            this.bridges.lox_id = settings.bridges.lox_id;
    
    1063
    +            break;
    
    1016 1064
               case TorBridgeSource.Invalid:
    
    1017 1065
                 break;
    
    1018 1066
             }
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits