@@ -22,71 +22,71 @@ const ADMIN_ROUTES_PASSWORD = env.THIRDWEB_API_SECRET_KEY;
22
22
23
23
// Add queues to monitor here.
24
24
const QUEUES : Queue [ ] = [
25
- SendWebhookQueue . q ,
26
- ProcessEventsLogQueue . q ,
27
- ProcessTransactionReceiptsQueue . q ,
28
- SendTransactionQueue . q ,
29
- MineTransactionQueue . q ,
30
- CancelRecycledNoncesQueue . q ,
31
- PruneTransactionsQueue . q ,
32
- NonceResyncQueue . q ,
33
- NonceHealthCheckQueue . q ,
25
+ SendWebhookQueue . q ,
26
+ ProcessEventsLogQueue . q ,
27
+ ProcessTransactionReceiptsQueue . q ,
28
+ SendTransactionQueue . q ,
29
+ MineTransactionQueue . q ,
30
+ CancelRecycledNoncesQueue . q ,
31
+ PruneTransactionsQueue . q ,
32
+ NonceResyncQueue . q ,
33
+ NonceHealthCheckQueue . q ,
34
34
] ;
35
35
36
36
export const withAdminRoutes = async ( fastify : FastifyInstance ) => {
37
- fastify . after ( async ( ) => {
38
- // Create a new route for Bullboard routes.
39
- const serverAdapter = new FastifyAdapter ( ) ;
40
- serverAdapter . setBasePath ( ADMIN_QUEUES_BASEPATH ) ;
37
+ fastify . after ( async ( ) => {
38
+ // Create a new route for Bullboard routes.
39
+ const serverAdapter = new FastifyAdapter ( ) ;
40
+ serverAdapter . setBasePath ( ADMIN_QUEUES_BASEPATH ) ;
41
41
42
- createBullBoard ( {
43
- queues : QUEUES . map ( ( q ) => new BullMQAdapter ( q ) ) ,
44
- serverAdapter,
45
- } ) ;
42
+ createBullBoard ( {
43
+ queues : QUEUES . map ( ( q ) => new BullMQAdapter ( q ) ) ,
44
+ serverAdapter,
45
+ } ) ;
46
46
47
- await fastify . register ( serverAdapter . registerPlugin ( ) , {
48
- basePath : ADMIN_QUEUES_BASEPATH ,
49
- prefix : ADMIN_QUEUES_BASEPATH ,
50
- } ) ;
47
+ await fastify . register ( serverAdapter . registerPlugin ( ) , {
48
+ basePath : ADMIN_QUEUES_BASEPATH ,
49
+ prefix : ADMIN_QUEUES_BASEPATH ,
50
+ } ) ;
51
51
52
- fastify . addHook ( "onRequest" , async ( req , reply ) => {
53
- if ( req . url . startsWith ( ADMIN_QUEUES_BASEPATH ) ) {
54
- const authHeader = req . headers . authorization ;
52
+ fastify . addHook ( "onRequest" , async ( req , reply ) => {
53
+ if ( req . url . startsWith ( ADMIN_QUEUES_BASEPATH ) ) {
54
+ const authHeader = req . headers . authorization ;
55
55
56
- if ( ! authHeader || ! authHeader . startsWith ( "Basic " ) ) {
57
- reply
58
- . status ( StatusCodes . UNAUTHORIZED )
59
- . header ( "WWW-Authenticate" , 'Basic realm="Admin Routes"' )
60
- . send ( { error : "Unauthorized" } ) ;
61
- return ;
62
- }
56
+ if ( ! authHeader || ! authHeader . startsWith ( "Basic " ) ) {
57
+ reply
58
+ . status ( StatusCodes . UNAUTHORIZED )
59
+ . header ( "WWW-Authenticate" , 'Basic realm="Admin Routes"' )
60
+ . send ( { error : "Unauthorized" } ) ;
61
+ return ;
62
+ }
63
63
64
- // Parse the basic auth credentials (`Basic <base64 of username:password>`).
65
- const base64Credentials = authHeader . split ( " " ) [ 1 ] ;
66
- const credentials = Buffer . from ( base64Credentials , "base64" ) . toString (
67
- "utf8" ,
68
- ) ;
69
- const [ username , password ] = credentials . split ( ":" ) ;
64
+ // Parse the basic auth credentials (`Basic <base64 of username:password>`).
65
+ const base64Credentials = authHeader . split ( " " ) [ 1 ] ;
66
+ const credentials = Buffer . from ( base64Credentials , "base64" ) . toString (
67
+ "utf8" ,
68
+ ) ;
69
+ const [ username , password ] = credentials . split ( ":" ) ;
70
70
71
- if ( ! assertAdminBasicAuth ( username , password ) ) {
72
- reply
73
- . status ( StatusCodes . UNAUTHORIZED )
74
- . header ( "WWW-Authenticate" , 'Basic realm="Admin Routes"' )
75
- . send ( { error : "Unauthorized" } ) ;
76
- return ;
77
- }
78
- }
79
- } ) ;
80
- } ) ;
71
+ if ( ! assertAdminBasicAuth ( username , password ) ) {
72
+ reply
73
+ . status ( StatusCodes . UNAUTHORIZED )
74
+ . header ( "WWW-Authenticate" , 'Basic realm="Admin Routes"' )
75
+ . send ( { error : "Unauthorized" } ) ;
76
+ return ;
77
+ }
78
+ }
79
+ } ) ;
80
+ } ) ;
81
81
} ;
82
82
83
83
const assertAdminBasicAuth = ( username : string , password : string ) => {
84
- if ( username === ADMIN_ROUTES_USERNAME ) {
85
- try {
86
- const buf1 = Buffer . from ( password . padEnd ( 100 ) ) ;
87
- const buf2 = Buffer . from ( ADMIN_ROUTES_PASSWORD . padEnd ( 100 ) ) ;
88
- return timingSafeEqual ( buf1 , buf2 ) ;
89
- } catch { }
90
- }
91
- return false ;
84
+ if ( username === ADMIN_ROUTES_USERNAME ) {
85
+ try {
86
+ const buf1 = Buffer . from ( password . padEnd ( 100 ) ) ;
87
+ const buf2 = Buffer . from ( ADMIN_ROUTES_PASSWORD . padEnd ( 100 ) ) ;
88
+ return timingSafeEqual ( buf1 , buf2 ) ;
89
+ } catch { }
90
+ }
91
+ return false ;
92
92
} ;
0 commit comments