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
21115918
Commit
21115918
authored
Apr 1, 2024
by
henry
Browse files
Options
Downloads
Patches
Plain Diff
fixup! Lox integration
Bug 42489: Change "loxid" to "loxId". This follows the camel case convention.
parent
a2c8eab3
Loading
Loading
1 merge request
!970
Update Lox module
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
toolkit/components/lox/Lox.sys.mjs
+42
-42
42 additions, 42 deletions
toolkit/components/lox/Lox.sys.mjs
with
42 additions
and
42 deletions
toolkit/components/lox/Lox.sys.mjs
+
42
−
42
View file @
21115918
...
...
@@ -143,25 +143,25 @@ class LoxImpl {
/**
* Formats and returns bridges from the stored Lox credential.
*
* @param {string} lox
i
d The id string associated with a lox credential.
* @param {string} lox
I
d The id string associated with a lox credential.
*
* @returns {string[]} An array of formatted bridge lines. The array is empty
* if there are no bridges.
*/
getBridges
(
lox
i
d
)
{
getBridges
(
lox
I
d
)
{
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
if
(
lox
i
d
===
null
)
{
if
(
lox
I
d
===
null
)
{
return
[];
}
if
(
!
this
.
#credentials
[
lox
i
d
])
{
if
(
!
this
.
#credentials
[
lox
I
d
])
{
// This lox id doesn't correspond to a stored credential
throw
new
LoxError
(
LoxErrors
.
MissingCredential
);
}
// 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
.
#credentials
[
lox
i
d
]).
bridgelines
;
let
bridgelines
=
JSON
.
parse
(
this
.
#credentials
[
lox
I
d
]).
bridgelines
;
let
bridges
=
[];
for
(
const
bridge
of
bridgelines
)
{
let
addr
=
bridge
.
addr
;
...
...
@@ -318,11 +318,11 @@ class LoxImpl {
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
const
lox
i
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
const
lox
I
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
try
{
const
levelup
=
await
this
.
#attemptUpgrade
(
lox
i
d
);
const
levelup
=
await
this
.
#attemptUpgrade
(
lox
I
d
);
if
(
levelup
)
{
const
level
=
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
i
d
]);
const
level
=
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
I
d
]);
const
newEvent
=
{
type
:
"
levelup
"
,
newlevel
:
level
,
...
...
@@ -334,9 +334,9 @@ class LoxImpl {
lazy
.
logger
.
error
(
err
);
}
try
{
const
leveldown
=
await
this
.
#blockageMigration
(
lox
i
d
);
const
leveldown
=
await
this
.
#blockageMigration
(
lox
I
d
);
if
(
leveldown
)
{
let
level
=
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
i
d
]);
let
level
=
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
I
d
]);
const
newEvent
=
{
type
:
"
blockage
"
,
newlevel
:
level
,
...
...
@@ -438,7 +438,7 @@ class LoxImpl {
* Redeems a Lox invitation to obtain a credential and bridges.
*
* @param {string} invite A Lox invitation.
* @returns {string} The lox
i
d of the associated credential on success.
* @returns {string} The lox
I
d of the associated credential on success.
*/
async
redeemInvite
(
invite
)
{
if
(
!
this
.
#initialized
)
{
...
...
@@ -496,18 +496,18 @@ class LoxImpl {
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
const
lox
i
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
i
d
||
!
this
.
#credentials
[
lox
i
d
])
{
const
lox
I
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
I
d
||
!
this
.
#credentials
[
lox
I
d
])
{
throw
new
LoxError
(
LoxErrors
.
MissingCredential
);
}
await
this
.
#getPubKeys
();
await
this
.
#getEncTable
();
let
level
=
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
i
d
]);
let
level
=
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
I
d
]);
if
(
level
<
1
)
{
throw
new
LoxError
(
LoxErrors
.
NoInvitations
);
}
let
request
=
lazy
.
issue_invite
(
JSON
.
stringify
(
this
.
#credentials
[
lox
i
d
]),
JSON
.
stringify
(
this
.
#credentials
[
lox
I
d
]),
this
.
#encTable
,
this
.
#pubKeys
);
...
...
@@ -524,7 +524,7 @@ class LoxImpl {
lazy
.
logger
.
error
(
response
.
error
);
throw
new
LoxError
(
LoxErrors
.
NoInvitations
);
}
else
{
this
.
#credentials
[
lox
i
d
]
=
response
;
this
.
#credentials
[
lox
I
d
]
=
response
;
const
invite
=
lazy
.
prepare_invite
(
response
);
this
.
#invites
.
push
(
invite
);
// cap length of stored invites
...
...
@@ -545,21 +545,21 @@ class LoxImpl {
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
const
lox
i
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
i
d
||
!
this
.
#credentials
[
lox
i
d
])
{
const
lox
I
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
I
d
||
!
this
.
#credentials
[
lox
I
d
])
{
throw
new
LoxError
(
LoxErrors
.
MissingCredential
);
}
return
parseInt
(
lazy
.
get_invites_remaining
(
this
.
#credentials
[
lox
i
d
]));
return
parseInt
(
lazy
.
get_invites_remaining
(
this
.
#credentials
[
lox
I
d
]));
}
async
#blockageMigration
(
lox
i
d
)
{
if
(
!
lox
i
d
||
!
this
.
#credentials
[
lox
i
d
])
{
async
#blockageMigration
(
lox
I
d
)
{
if
(
!
lox
I
d
||
!
this
.
#credentials
[
lox
I
d
])
{
throw
new
LoxError
(
LoxErrors
.
MissingCredential
);
}
await
this
.
#getPubKeys
();
let
request
;
try
{
request
=
lazy
.
check_blockage
(
this
.
#credentials
[
lox
i
d
],
this
.
#pubKeys
);
request
=
lazy
.
check_blockage
(
this
.
#credentials
[
lox
I
d
],
this
.
#pubKeys
);
}
catch
{
lazy
.
logger
.
log
(
"
Not ready for blockage migration
"
);
return
false
;
...
...
@@ -570,11 +570,11 @@ class LoxImpl {
throw
new
LoxError
(
LoxErrors
.
LoxServerUnreachable
);
}
const
migrationCred
=
lazy
.
handle_check_blockage
(
this
.
#credentials
[
lox
i
d
],
this
.
#credentials
[
lox
I
d
],
JSON
.
stringify
(
response
)
);
request
=
lazy
.
blockage_migration
(
this
.
#credentials
[
lox
i
d
],
this
.
#credentials
[
lox
I
d
],
migrationCred
,
this
.
#pubKeys
);
...
...
@@ -584,11 +584,11 @@ class LoxImpl {
throw
new
LoxError
(
LoxErrors
.
LoxServerUnreachable
);
}
const
cred
=
lazy
.
handle_blockage_migration
(
this
.
#credentials
[
lox
i
d
],
this
.
#credentials
[
lox
I
d
],
JSON
.
stringify
(
response
),
this
.
#pubKeys
);
this
.
#credentials
[
lox
i
d
]
=
cred
;
this
.
#credentials
[
lox
I
d
]
=
cred
;
this
.
#store
();
return
true
;
}
...
...
@@ -598,15 +598,15 @@ class LoxImpl {
*
* @returns {boolean} whether a levelup event occured
*/
async
#attemptUpgrade
(
lox
i
d
)
{
if
(
!
lox
i
d
||
!
this
.
#credentials
[
lox
i
d
])
{
async
#attemptUpgrade
(
lox
I
d
)
{
if
(
!
lox
I
d
||
!
this
.
#credentials
[
lox
I
d
])
{
throw
new
LoxError
(
LoxErrors
.
MissingCredential
);
}
await
this
.
#getPubKeys
();
await
this
.
#getEncTable
();
await
this
.
#getConstants
();
let
success
=
false
;
let
level
=
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
i
d
]);
let
level
=
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
I
d
]);
if
(
level
<
1
)
{
// attempt trust promotion instead
try
{
...
...
@@ -617,7 +617,7 @@ class LoxImpl {
}
}
else
{
let
request
=
lazy
.
level_up
(
this
.
#credentials
[
lox
i
d
],
this
.
#credentials
[
lox
I
d
],
this
.
#encTable
,
this
.
#pubKeys
);
...
...
@@ -631,7 +631,7 @@ class LoxImpl {
JSON
.
stringify
(
response
),
this
.
#pubKeys
);
this
.
#credentials
[
lox
i
d
]
=
cred
;
this
.
#credentials
[
lox
I
d
]
=
cred
;
return
true
;
}
return
success
;
...
...
@@ -644,15 +644,15 @@ class LoxImpl {
* was successfully migrated.
*/
async
#trustMigration
()
{
const
lox
i
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
i
d
||
!
this
.
#credentials
[
lox
i
d
])
{
const
lox
I
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
I
d
||
!
this
.
#credentials
[
lox
I
d
])
{
throw
new
LoxError
(
LoxErrors
.
MissingCredential
);
}
await
this
.
#getPubKeys
();
return
new
Promise
((
resolve
,
reject
)
=>
{
let
request
=
""
;
try
{
request
=
lazy
.
trust_promotion
(
this
.
#credentials
[
lox
i
d
],
this
.
#pubKeys
);
request
=
lazy
.
trust_promotion
(
this
.
#credentials
[
lox
I
d
],
this
.
#pubKeys
);
}
catch
(
err
)
{
lazy
.
logger
.
debug
(
"
Not ready to upgrade
"
);
resolve
(
false
);
...
...
@@ -670,7 +670,7 @@ class LoxImpl {
);
lazy
.
logger
.
debug
(
"
Formatted promotion cred
"
);
request
=
lazy
.
trust_migration
(
this
.
#credentials
[
lox
i
d
],
this
.
#credentials
[
lox
I
d
],
promoCred
,
this
.
#pubKeys
);
...
...
@@ -686,7 +686,7 @@ class LoxImpl {
}
lazy
.
logger
.
debug
(
"
Got new credential
"
);
let
cred
=
lazy
.
handle_trust_migration
(
request
,
response
);
this
.
#credentials
[
lox
i
d
]
=
cred
;
this
.
#credentials
[
lox
I
d
]
=
cred
;
this
.
#store
();
resolve
(
true
);
})
...
...
@@ -722,8 +722,8 @@ class LoxImpl {
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
const
lox
i
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
i
d
||
!
this
.
#credentials
[
lox
i
d
])
{
const
lox
I
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
I
d
||
!
this
.
#credentials
[
lox
I
d
])
{
throw
new
LoxError
(
LoxErrors
.
MissingCredential
);
}
return
this
.
#events
;
...
...
@@ -768,15 +768,15 @@ class LoxImpl {
if
(
!
this
.
#initialized
)
{
throw
new
LoxError
(
LoxErrors
.
NotInitialized
);
}
const
lox
i
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
i
d
||
!
this
.
#credentials
[
lox
i
d
])
{
const
lox
I
d
=
lazy
.
TorSettings
.
bridges
.
lox_id
;
if
(
!
lox
I
d
||
!
this
.
#credentials
[
lox
I
d
])
{
throw
new
LoxError
(
LoxErrors
.
MissingCredential
);
}
await
this
.
#getConstants
();
let
nextUnlocks
=
JSON
.
parse
(
lazy
.
get_next_unlock
(
this
.
#constants
,
this
.
#credentials
[
lox
i
d
])
lazy
.
get_next_unlock
(
this
.
#constants
,
this
.
#credentials
[
lox
I
d
])
);
const
level
=
parseInt
(
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
i
d
]));
const
level
=
parseInt
(
lazy
.
get_trust_level
(
this
.
#credentials
[
lox
I
d
]));
const
unlocks
=
{
date
:
nextUnlocks
.
trust_level_unlock_date
,
nextLevel
:
level
+
1
,
...
...
...
...
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