Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
metager-webextension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
metager-webextension
Commits
bb01d8bb
Commit
bb01d8bb
authored
1 year ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
keep using remaining anonymous tokens when disabling feature
parent
dcce8a74
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
build/js/TokenManager.js
+13
-0
13 additions, 0 deletions
build/js/TokenManager.js
with
13 additions
and
0 deletions
build/js/TokenManager.js
+
13
−
0
View file @
bb01d8bb
...
...
@@ -55,6 +55,7 @@ export class TokenManager {
this
.
_recent_costs
=
storage
[
this
.
_storage_keys
.
tokens_recent_costs
];
this
.
_key_charge
=
storage
[
this
.
_storage_keys
.
key_charge
];
this
.
_initialized
=
true
;
setInterval
(
this
.
refill
.
bind
(
this
),
15000
);
return
this
.
refill
();
});
}
...
...
@@ -88,6 +89,12 @@ export class TokenManager {
async
handleRequestHeaders
(
details
)
{
await
this
.
init
();
// If the user disabled anonymous tokens we'll keep using the remaining ones until empty
if
(
!
this
.
_anonymous_tokens_enabled
&&
Math
.
min
(...
this
.
_recent_costs
)
>
this
.
_tokens
.
length
)
{
return
details
.
requestHeaders
;
}
let
url
=
new
URL
(
details
.
url
);
let
[
headers
,
cookies
]
=
this
.
_parseRequestHeadersForCookies
(
details
.
requestHeaders
...
...
@@ -115,6 +122,12 @@ export class TokenManager {
async
handleResponseHeaders
(
details
)
{
await
this
.
init
();
// If the user disabled anonymous tokens we'll keep using the remaining ones until empty
if
(
!
this
.
_anonymous_tokens_enabled
&&
Math
.
min
(...
this
.
_recent_costs
)
>
this
.
_tokens
.
length
)
{
return
details
.
requestHeaders
;
}
for
(
let
header
of
details
.
responseHeaders
)
{
if
(
header
.
name
.
match
(
/set-cookie/i
))
{
let
cookies
=
header
.
value
.
split
(
"
\n
"
);
...
...
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
register
or
sign in
to comment