Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
614 changes: 316 additions & 298 deletions bun.lock

Large diffs are not rendered by default.

54 changes: 0 additions & 54 deletions e2e/bun.lock

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"private": true,
"dependencies": {
"@dotenvx/dotenvx": "^1.6.4",
"@lit-protocol/contracts": "^0.2.0",
"@lit-protocol/contracts": "^0.2.3",
"@lit-protocol/nacl": "7.1.1",
"@lit-protocol/uint8arrays": "7.1.1",
"@metamask/eth-sig-util": "5.0.2",
Expand Down Expand Up @@ -65,7 +65,7 @@
"viem": "2.29.4",
"wagmi": "^2.15.4",
"zod": "3.24.3",
"zod-validation-error": "^3.4.0"
"zod-validation-error": "3.4.0"
},
"devDependencies": {
"@changesets/cli": "^2.29.4",
Expand Down
6 changes: 3 additions & 3 deletions packages/auth-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@elysiajs/cors": "^1.2.0",
"@elysiajs/static": "^1.3.0",
"@elysiajs/swagger": "^1.2.0",
"@lit-protocol/contracts": "^0.1.23",
"@lit-protocol/contracts": "^0.2.3",
"@simplewebauthn/server": "6.2.1",
"@simplewebauthn/typescript-types": "^8.3.4",
"@t3-oss/env-core": "^0.12.0",
Expand All @@ -35,7 +35,7 @@
"jose": "^6.0.7",
"json-with-bigint": "^2.4.2",
"pino": "^9.6.0",
"pino-caller": "^3.4.0",
"pino-caller": "3.4.0",
"pino-pretty": "^13.0.0",
"redis": "^4.6.13",
"stytch": "^12.4.0",
Expand All @@ -44,7 +44,7 @@
"viem": "2.29.4",
"wagmi": "^2.14.11",
"zod": "^3.24.2",
"zod-validation-error": "^3.4.0"
"zod-validation-error": "3.4.0"
},
"devDependencies": {
"bun-types": "^1.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/constants/src/lib/constants/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ export const GLOBAL_OVERWRITE_IPFS_CODE_BY_NETWORK: Record<
* - DECRYPTION (0): Used for decryption operations
* - SIGN (1): Used for signing operations
* - LA (2): Used for Lit Actions execution
* - SIGN_SESSION_KEY (3): Used for sign session key operations
*/
export const PRODUCT_IDS = {
DECRYPTION: 0, // For decryption operations
SIGN: 1, // For signing operations
LIT_ACTION: 2, // For Lit Actions execution
SIGN_SESSION_KEY: 3, // For sign session key operations
} as const;
export type PRODUCT_ID_TYPE = ConstantKeys<typeof PRODUCT_IDS>;
export type PRODUCT_ID_VALUES = ConstantValues<typeof PRODUCT_IDS>;
2 changes: 1 addition & 1 deletion packages/networks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"directory": "../../dist/packages/networks"
},
"dependencies": {
"@lit-protocol/contracts": "^0.2.1",
"@lit-protocol/contracts": "^0.2.3",
"@lit-protocol/nacl": "7.1.1",
"@noble/curves": "^1.8.1",
"@wagmi/core": "^2.17.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const handleEncryptedError = (
// Try to decrypt the error payload to get the actual error message
try {
_logger.info(
`${operationName}: Attempting to decrypt error payload for detailed error information...`
`"${operationName}": Attempting to decrypt error payload for detailed error information...`
);

const errorAsEncryptedPayload = {
Expand All @@ -145,7 +145,7 @@ const handleEncryptedError = (
);

_logger.error(
`${operationName}: Decrypted error details from nodes:`,
`"${operationName}": Decrypted error details from nodes:`,
decryptedErrorValues
);

Expand All @@ -157,35 +157,35 @@ const handleEncryptedError = (
? `. Details: ${firstError.errorObject}`
: '';
throw new Error(
`${operationName} failed. ${errorMessage}${errorDetails}`
`"${operationName}" failed. ${errorMessage}${errorDetails}`
);
}

// If no specific error field, show the full decrypted response
throw new Error(
`${operationName} failed. ${JSON.stringify(decryptedErrorValues)}`
`"${operationName}" failed. ${JSON.stringify(decryptedErrorValues)}`
);
} catch (decryptError) {
_logger.error(
`${operationName}: Failed to decrypt error payload:`,
`"${operationName}": Failed to decrypt error payload:`,
decryptError
);

// If the decryptError is actually our thrown error with the node's message, re-throw it
if (
decryptError instanceof Error &&
decryptError.message.includes(`${operationName} failed.`)
decryptError.message.includes(`"${operationName}" failed.`)
) {
throw decryptError;
}

throw new Error(
`${operationName} failed. The nodes returned an encrypted error response that could not be decrypted. ` +
`This may indicate a configuration or network connectivity issue.`
`"${operationName}" failed. The nodes returned an encrypted error response that could not be decrypted. ` +
`This may indicate a configuration or network connectivity issue. ${JSON.stringify(errorResult)}`
);
}
} else {
throw new Error(`${operationName} failed with no error details provided`);
throw new Error(`"${operationName}" failed. ${JSON.stringify(errorResult)}`);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,15 @@ const networkModuleObject = {
requestId: string,
jitContext: NagaJitContext
) => {

if (!result.success) {
E2EERequestManager.handleEncryptedError(
result,
jitContext,
'PKP Sign'
);
}

const decryptedValues = E2EERequestManager.decryptBatchResponse(
result,
jitContext,
Expand Down Expand Up @@ -828,6 +837,7 @@ const networkModuleObject = {
curveType: 'BLS' as const,
epoch: requestBody.epoch,
nodeSet: requestBody.nodeSet,
maxPrice: getUserMaxPrice({ product: 'SIGN_SESSION_KEY' }).toString(),
};

// Encrypt the request data using the E2EE manager
Expand Down Expand Up @@ -876,6 +886,14 @@ const networkModuleObject = {
'signSessionKey:handleResponse: Processing signSessionKey response'
);

if (!result.success) {
E2EERequestManager.handleEncryptedError(
result,
jitContext,
'Session key signing'
);
}

// Decrypt the batch response using the E2EE manager
const decryptedValues = E2EERequestManager.decryptBatchResponse(
result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const getUserMaxPrice = (params: {
DECRYPTION: BigInt(-1),
SIGN: BigInt(-1),
LIT_ACTION: BigInt(-1),
SIGN_SESSION_KEY: BigInt(-1),
};

if (defaultMaxPriceByProduct[params.product] === BigInt(-1)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ export const UNSIGNED_128_MAX =
* - DECRYPTION (0): Used for decryption operations
* - SIGN (1): Used for signing operations
* - LIT_ACTION (2): Used for Lit Actions execution
* - SIGN_SESSION_KEY (3): Used for sign session key operations
*/
export const PRODUCT_IDS = {
DECRYPTION: 0n, // For decryption operations
SIGN: 1n, // For signing operations
LIT_ACTION: 2n, // For Lit Actions execution
SIGN_SESSION_KEY: 3n, // For sign session key operations
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const handleEncryptedError = (
// Try to decrypt the error payload to get the actual error message
try {
_logger.info(
`${operationName}: Attempting to decrypt error payload for detailed error information...`
`"${operationName}": Attempting to decrypt error payload for detailed error information...`
);

const errorAsEncryptedPayload = {
Expand All @@ -145,7 +145,7 @@ const handleEncryptedError = (
);

_logger.error(
`${operationName}: Decrypted error details from nodes:`,
`"${operationName}": Decrypted error details from nodes:`,
decryptedErrorValues
);

Expand All @@ -157,35 +157,35 @@ const handleEncryptedError = (
? `. Details: ${firstError.errorObject}`
: '';
throw new Error(
`${operationName} failed. ${errorMessage}${errorDetails}`
`"${operationName}" failed. ${errorMessage}${errorDetails}`
);
}

// If no specific error field, show the full decrypted response
throw new Error(
`${operationName} failed. ${JSON.stringify(decryptedErrorValues)}`
`"${operationName}" failed. ${JSON.stringify(decryptedErrorValues)}`
);
} catch (decryptError) {
_logger.error(
`${operationName}: Failed to decrypt error payload:`,
`"${operationName}": Failed to decrypt error payload:`,
decryptError
);

// If the decryptError is actually our thrown error with the node's message, re-throw it
if (
decryptError instanceof Error &&
decryptError.message.includes(`${operationName} failed.`)
decryptError.message.includes(`"${operationName}" failed.`)
) {
throw decryptError;
}

throw new Error(
`${operationName} failed. The nodes returned an encrypted error response that could not be decrypted. ` +
`This may indicate a configuration or network connectivity issue.`
`"${operationName}" failed. The nodes returned an encrypted error response that could not be decrypted. ` +
`This may indicate a configuration or network connectivity issue. ${JSON.stringify(errorResult)}`
);
}
} else {
throw new Error(`${operationName} failed with no error details provided`);
throw new Error(`"${operationName}" failed. ${JSON.stringify(errorResult)}`);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type CreateChainManagerReturn = {
pkpPermissionsManager: (
pkpIdentifier: PkpIdentifierRaw
) => InstanceType<typeof api.PKPPermissionsManager>;
paymentManager: () => InstanceType<typeof api.PaymentManager>;
getPKPsByAuthData: (
authData: {
authMethodType: number | bigint;
Expand Down Expand Up @@ -81,6 +82,12 @@ export const createChainManager = (
accountOrWalletClient
);
},
paymentManager: () => {
return new api.PaymentManager(
_networkConfig,
accountOrWalletClient
);
},
getPKPsByAuthData: (
authData: {
authMethodType: number | bigint;
Expand Down
Loading
Loading