Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Tor Browser
Commits
a61b54ea
Commit
a61b54ea
authored
Apr 1, 2024
by
henry
Committed by
Pier Angelo Vendrame
Apr 10, 2024
Browse files
Options
Downloads
Patches
Plain Diff
fixup! Lox integration
Bug 42489: Add #assertInitialized.
parent
8bc9824b
Branches
mullvad-browser-115.11.0esr-13.0-1
No related tags found
1 merge request
!980
Bug 42512: Rebased alpha onto Firefox 115.10.0esr
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
toolkit/components/lox/Lox.sys.mjs
+20
-33
20 additions, 33 deletions
toolkit/components/lox/Lox.sys.mjs
with
20 additions
and
33 deletions
toolkit/components/lox/Lox.sys.mjs
+
20
−
33
View file @
a61b54ea
...
...
@@ -200,6 +200,15 @@ class LoxImpl {
}
}
/**
* Assert that the module is initialized.
*/
#assertInitialized
()
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
}
get
#inuse
()
{
return
(
Boolean
(
this
.
#activeLoxId
)
&&
...
...
@@ -267,9 +276,7 @@ class LoxImpl {
* if there are no bridges.
*/
getBridges
(
loxId
)
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
// Note: this is messy now but can be mostly removed after we have
// https://gitlab.torproject.org/tpo/anti-censorship/lox/-/issues/46
let
bridgelines
=
JSON
.
parse
(
this
.
#getCredentials
(
loxId
)).
bridgelines
;
...
...
@@ -424,9 +431,7 @@ class LoxImpl {
* If either blockages or a levelup happened, add an event to the event queue
*/
async
#backgroundTasks
()
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
let
addedEvent
=
false
;
// Only run background tasks for the active lox ID.
const
loxId
=
this
.
#activeLoxId
;
...
...
@@ -529,9 +534,7 @@ class LoxImpl {
* @returns {bool} Whether the value passed in was a Lox invitation.
*/
validateInvitation
(
invite
)
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
try
{
lazy
.
invitation_is_trusted
(
invite
);
}
catch
(
err
)
{
...
...
@@ -544,9 +547,7 @@ class LoxImpl {
// Note: This is only here for testing purposes. We're going to be using telegram
// to issue open invitations for Lox bridges.
async
requestOpenInvite
()
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
let
invite
=
await
this
.
#makeRequest
(
"
invite
"
,
[]);
lazy
.
logger
.
debug
(
invite
);
return
invite
;
...
...
@@ -559,9 +560,7 @@ class LoxImpl {
* @returns {string} The loxId of the associated credential on success.
*/
async
redeemInvite
(
invite
)
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
await
this
.
#getPubKeys
();
let
request
=
await
lazy
.
open_invite
(
JSON
.
parse
(
invite
).
invite
);
let
response
;
...
...
@@ -599,9 +598,7 @@ class LoxImpl {
* @returns {string[]} A list of all historical invites.
*/
getInvites
()
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
// Return a copy.
return
structuredClone
(
this
.
#invites
);
}
...
...
@@ -618,9 +615,7 @@ class LoxImpl {
* @returns {string} A valid Lox invitation.
*/
async
generateInvite
(
loxId
)
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
await
this
.
#getPubKeys
();
await
this
.
#getEncTable
();
let
level
=
lazy
.
get_trust_level
(
this
.
#getCredentials
(
loxId
));
...
...
@@ -668,9 +663,7 @@ class LoxImpl {
* user's credential.
*/
getRemainingInviteCount
(
loxId
)
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
return
parseInt
(
lazy
.
get_invites_remaining
(
this
.
#getCredentials
(
loxId
)));
}
...
...
@@ -834,9 +827,7 @@ class LoxImpl {
* associated with a user's credential.
*/
getEventData
(
loxId
)
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
if
(
loxId
!==
this
.
#activeLoxId
)
{
lazy
.
logger
.
warn
(
`No event data for loxId
${
loxId
}
since it was replaced by
${
...
...
@@ -857,9 +848,7 @@ class LoxImpl {
* @param {string} loxId - The ID to clear events for.
*/
clearEventData
(
loxId
)
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
if
(
loxId
!==
this
.
#activeLoxId
)
{
lazy
.
logger
.
warn
(
`Not clearing event data for loxId
${
loxId
}
since it was replaced by
${
...
...
@@ -891,9 +880,7 @@ class LoxImpl {
* @returns {UnlockData} - Details about the next unlock.
*/
async
getNextUnlock
(
loxId
)
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
this
.
#assertInitialized
();
await
this
.
#getConstants
();
let
nextUnlock
=
JSON
.
parse
(
lazy
.
get_next_unlock
(
this
.
#constants
,
this
.
#getCredentials
(
loxId
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment