Skip to content

Commit 188d245

Browse files
authored
Merge pull request #877 from LIT-Protocol/fix/type-issues
Fix/type issues
2 parents 908cff8 + 00f733a commit 188d245

File tree

23 files changed

+7988
-7696
lines changed

23 files changed

+7988
-7696
lines changed

packages/access-control-conditions/src/lib/humanizer.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,16 @@ export const humanizeEvmBasicAccessControlConditions = async ({
331331
}
332332

333333
// Fallback for unhandled conditions - provide debugging information
334-
logger.warn('Unhandled access control condition', {
335-
standardContractType: acc.standardContractType,
336-
method: acc.method,
337-
contractAddress: acc.contractAddress,
338-
chain: acc.chain,
339-
conditionType: acc.conditionType,
340-
});
334+
logger.warn(
335+
{
336+
standardContractType: acc.standardContractType,
337+
method: acc.method,
338+
contractAddress: acc.contractAddress,
339+
chain: acc.chain,
340+
conditionType: acc.conditionType,
341+
},
342+
'Unhandled access control condition'
343+
);
341344

342345
return `Unhandled condition: ${
343346
acc.standardContractType || 'unknown'

packages/auth-services/src/queue-manager/src/genericWorker.ts

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,43 @@ export function createGenericWorker() {
1313
const worker = new Worker(
1414
mainQueueName,
1515
async (job) => {
16-
logger.info(`Picked up job ${job.id} with name ${job.name}`, {
17-
jobId: job.id,
18-
jobName: job.name,
19-
});
16+
logger.info(
17+
{
18+
jobId: job.id,
19+
jobName: job.name,
20+
},
21+
`Picked up job ${job.id} with name ${job.name}`
22+
);
2023
const handler = jobRegistry[job.name as JobName];
2124

2225
if (handler) {
2326
try {
2427
const result = await handler(job.data);
25-
logger.info(`Job ${job.id} (${job.name}) completed successfully.`, {
26-
jobId: job.id,
27-
jobName: job.name,
28-
});
28+
logger.info(
29+
{
30+
jobId: job.id,
31+
jobName: job.name,
32+
},
33+
`Job ${job.id} (${job.name}) completed successfully.`
34+
);
2935
return result; // Result is stored by BullMQ
3036
} catch (error: any) {
3137
logger.error(
32-
`Handler for job ${job.id} (${job.name}) failed: ${error.message}`,
3338
{
3439
jobId: job.id,
3540
jobName: job.name,
3641
errorMessage: error.message,
3742
stack: error.stack,
3843
errorObject:
3944
typeof error === 'object' && error !== null ? error : undefined,
40-
}
45+
},
46+
`Handler for job ${job.id} (${job.name}) failed: ${error.message}`
4147
);
4248
throw error;
4349
}
4450
} else {
4551
const errorMessage = `No handler found for job name: ${job.name}. Job ID: ${job.id}`;
46-
logger.error(errorMessage, { jobId: job.id, jobName: job.name });
52+
logger.error({ jobId: job.id, jobName: job.name }, errorMessage);
4753
throw new Error(errorMessage); // Mark job as failed if no handler
4854
}
4955
},
@@ -55,10 +61,13 @@ export function createGenericWorker() {
5561

5662
worker.on('completed', (job, result) => {
5763
if (job) {
58-
logger.info(`Job ${job.id} (${job.name}) final state: completed.`, {
59-
jobId: job.id,
60-
jobName: job.name,
61-
});
64+
logger.info(
65+
{
66+
jobId: job.id,
67+
jobName: job.name,
68+
},
69+
`Job ${job.id} (${job.name}) final state: completed.`
70+
);
6271
} else {
6372
logger.warn(
6473
'A job completed, but job details are unavailable in the event.'
@@ -69,29 +78,32 @@ export function createGenericWorker() {
6978
worker.on('failed', (job, err) => {
7079
if (job) {
7180
logger.error(
72-
`Job ${job.id} (${job.name}) final state: failed. Error: ${err.message}`,
7381
{
7482
jobId: job.id,
7583
jobName: job.name,
7684
errorMessage: err.message,
7785
errorStack: err.stack,
78-
}
86+
},
87+
`Job ${job.id} (${job.name}) final state: failed. Error: ${err.message}`
7988
);
8089
} else {
8190
logger.error(
82-
`A job failed, but job details are unavailable in the event. Error: ${err.message}`,
83-
{ errorMessage: err.message, errorStack: err.stack }
91+
{ errorMessage: err.message, errorStack: err.stack },
92+
`A job failed, but job details are unavailable in the event. Error: ${err.message}`
8493
);
8594
}
8695
});
8796

8897
worker.on('error', (err) => {
8998
// This is for errors in the worker itself, not necessarily job failures
90-
logger.error('Generic BullMQ worker instance encountered an error:', {
91-
errorMessage: err.message,
92-
errorStack: err.stack,
93-
errorObject: typeof err === 'object' && err !== null ? err : undefined,
94-
});
99+
logger.error(
100+
{
101+
errorMessage: err.message,
102+
errorStack: err.stack,
103+
errorObject: typeof err === 'object' && err !== null ? err : undefined,
104+
},
105+
'Generic BullMQ worker instance encountered an error:'
106+
);
95107
});
96108

97109
return worker;

packages/auth/src/lib/AuthManager/authContexts/getCustomAuthContext.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,12 @@ const prepareCustomAuthRequestBody = async (
146146
export const getCustomAuthContext = async (
147147
params: z.infer<typeof GetCustomAuthContextSchema>
148148
) => {
149-
_logger.info('getCustomAuthContext: params', {
150-
params,
151-
});
149+
_logger.info(
150+
{
151+
params,
152+
},
153+
'getCustomAuthContext: params'
154+
);
152155

153156
// const _params = GetCustomAuthContextSchema.parse(params);
154157
const _params = params;
@@ -186,9 +189,12 @@ export const getCustomAuthContext = async (
186189
}),
187190
});
188191

189-
_logger.info('getCustomAuthContext: delegationAuthSig', {
190-
delegationAuthSig,
191-
});
192+
_logger.info(
193+
{
194+
delegationAuthSig,
195+
},
196+
'getCustomAuthContext: delegationAuthSig'
197+
);
192198

193199
return {
194200
chain: 'ethereum',

packages/auth/src/lib/AuthManager/authContexts/getPkpAuthContext.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,12 @@ const preparePkpAuthRequestBody = async (
116116
export const getPkpAuthContext = async (
117117
params: z.infer<typeof GetPkpAuthContextSchema>
118118
) => {
119-
_logger.info('getPkpAuthContext: params', {
120-
params,
121-
});
119+
_logger.info(
120+
{
121+
params,
122+
},
123+
'getPkpAuthContext: params'
124+
);
122125

123126
const _params = GetPkpAuthContextSchema.parse(params);
124127
const _nodeInfo = NodeInfoSchema.parse(params.deps.connection.nodeUrls);
@@ -155,9 +158,12 @@ export const getPkpAuthContext = async (
155158
}),
156159
});
157160

158-
_logger.info('getPkpAuthContext: delegationAuthSig', {
159-
delegationAuthSig,
160-
});
161+
_logger.info(
162+
{
163+
delegationAuthSig,
164+
},
165+
'getPkpAuthContext: delegationAuthSig'
166+
);
161167

162168
return {
163169
chain: 'ethereum',

packages/auth/src/lib/AuthManager/try-getters/tryGetCachedAuthData.ts

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,59 +37,65 @@ export async function tryGetCachedAuthData(params: {
3737
address: params.address,
3838
})) as LitAuthData | null; // Allow null if nothing is found
3939

40-
_logger.info('tryGetCachedAuthData: Attempting to read from cache', {
41-
address: params.address,
42-
foundInCache: !!authData,
43-
});
40+
_logger.info(
41+
{
42+
address: params.address,
43+
foundInCache: !!authData,
44+
},
45+
'tryGetCachedAuthData: Attempting to read from cache'
46+
);
4447

4548
if (authData && authData.sessionKey && authData.sessionKey.expiresAt) {
4649
try {
4750
const expirationDate = new Date(authData.sessionKey.expiresAt);
4851
if (expirationDate.getTime() > Date.now()) {
4952
_logger.info(
50-
'tryGetCachedAuthData: Found valid (unexpired) cached auth data',
5153
{
5254
address: params.address,
5355
expiresAt: authData.sessionKey.expiresAt,
54-
}
56+
},
57+
'tryGetCachedAuthData: Found valid (unexpired) cached auth data'
5558
);
5659
return authData; // Return valid, unexpired authData
5760
} else {
58-
_logger.info('tryGetCachedAuthData: Cached auth data has expired', {
59-
address: params.address,
60-
expiredAt: authData.sessionKey.expiresAt,
61-
});
61+
_logger.info(
62+
{
63+
address: params.address,
64+
expiredAt: authData.sessionKey.expiresAt,
65+
},
66+
'tryGetCachedAuthData: Cached auth data has expired'
67+
);
6268
authData = null; // Treat as not found if expired
6369
}
6470
} catch (e: any) {
6571
_logger.warn(
66-
'tryGetCachedAuthData: Error parsing expirationDate from cached auth data. Will regenerate.',
6772
{
6873
address: params.address,
6974
expiresAtValue: authData!.sessionKey!.expiresAt,
7075
error: e.message || e,
71-
}
76+
},
77+
'tryGetCachedAuthData: Error parsing expirationDate from cached auth data. Will regenerate.'
7278
);
7379
authData = null; // Treat as not found if parsing fails
7480
}
7581
} else if (authData) {
7682
_logger.warn(
77-
'tryGetCachedAuthData: Cached auth data found, but sessionKey or expiresAt is missing. Will regenerate.',
7883
{
7984
address: params.address,
8085
authDataPreview: JSON.stringify(authData).substring(0, 200),
81-
}
86+
},
87+
'tryGetCachedAuthData: Cached auth data found, but sessionKey or expiresAt is missing. Will regenerate.'
8288
);
8389
authData = null; // Treat as not found if incomplete
8490
}
8591

8692
// If authData is null at this point (either not found, expired, or invalid), generate new.
8793
if (!authData) {
8894
_logger.info(
89-
'tryGetCachedAuthData: No valid cached auth data found or cache expired/invalid. Generating new auth data.',
9095
{
9196
address: params.address,
92-
}
97+
},
98+
'tryGetCachedAuthData: No valid cached auth data found or cache expired/invalid. Generating new auth data.'
9399
);
94100

95101
const _expiration = ExpirationSchema.parse(params.expiration);
@@ -108,9 +114,12 @@ export async function tryGetCachedAuthData(params: {
108114
address: params.address,
109115
authData,
110116
});
111-
_logger.info('tryGetCachedAuthData: Generated and saved new auth data.', {
112-
address: params.address,
113-
});
117+
_logger.info(
118+
{
119+
address: params.address,
120+
},
121+
'tryGetCachedAuthData: Generated and saved new auth data.'
122+
);
114123
}
115124

116125
// Final check to ensure authData is not null, which should be guaranteed by the logic above.
@@ -124,10 +133,13 @@ export async function tryGetCachedAuthData(params: {
124133

125134
const finalAuthData: LitAuthData = authData;
126135

127-
_logger.info('tryGetCachedAuthData: Success, returning auth data.', {
128-
address: params.address,
129-
// authData, // Avoid logging full authData which may contain sensitive info like keyPair and also resolves linter issue.
130-
});
136+
_logger.info(
137+
{
138+
address: params.address,
139+
// authData, // Avoid logging full authData which may contain sensitive info like keyPair and also resolves linter issue.
140+
},
141+
'tryGetCachedAuthData: Success, returning auth data.'
142+
);
131143

132144
return finalAuthData;
133145
}

0 commit comments

Comments
 (0)