Skip to content
Closed
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
572 changes: 304 additions & 268 deletions bun.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions e2e/bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "@lit-protocol/e2e",
"dependencies": {
"viem": "2.29.4",
"zod": "^3.22.0",
"zod": "3.25.0",
},
"devDependencies": {
"@types/node": "^20.0.0",
Expand All @@ -31,7 +31,7 @@

"@scure/bip39": ["@scure/[email protected]", "", { "dependencies": { "@noble/hashes": "~1.7.1", "@scure/base": "~1.2.4" } }, "sha512-TFM4ni0vKvCfBpohoh+/lY05i9gRbSwXWngAsF4CABQxoaOHijxuaZ2R6cStDQ5CHtHO9aGJTr4ksVJASRRyMA=="],

"@types/node": ["@types/[email protected].0", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-hfrc+1tud1xcdVTABC2JiomZJEklMcXYNTVtZLAeqTVWD+qL5jkHKT+1lOtqDdGxt+mB53DTtiz673vfjU8D1Q=="],
"@types/node": ["@types/[email protected].8", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-HzbgCY53T6bfu4tT7Aq3TvViJyHjLjPNaAS3HOuMc9pw97KHsUtXNX4L+wu59g1WnjsZSko35MbEqnO58rihhw=="],

"abitype": ["[email protected]", "", { "peerDependencies": { "typescript": ">=5.0.4", "zod": "^3 >=3.22.0" }, "optionalPeers": ["typescript", "zod"] }, "sha512-ZeiI6h3GnW06uYDLx0etQtX/p8E24UaHHBj57RSjK7YBFe7iuVn07EDpOeP451D06sF27VOz9JJPlIKJmXgkEg=="],

Expand All @@ -49,6 +49,6 @@

"ws": ["[email protected]", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w=="],

"zod": ["[email protected].57", "", {}, "sha512-6tgzLuwVST5oLUxXTmBqoinKMd3JeesgbgseXeFasKKj8Q1FCZrHnbqJOyiEvr4cVAlbug+CgIsmJ8cl/pU5FA=="],
"zod": ["[email protected].0", "", {}, "sha512-ficnZKUW0mlNivqeJkosTEkGbJ6NKCtSaOHGx5aXbtfeWMdRyzXLbAIn19my4C/KB7WPY/p9vlGPt+qpOp6c4Q=="],
}
}
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"license": "MIT",
"dependencies": {
"viem": "2.29.4",
"zod": "^3.22.0"
"zod": "3.25.1"
},
"devDependencies": {
"@types/node": "^20.0.0",
Expand Down
6 changes: 3 additions & 3 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 @@ -64,8 +64,8 @@
"uint8arrays": "^4.0.3",
"viem": "2.29.4",
"wagmi": "^2.15.4",
"zod": "3.24.3",
"zod-validation-error": "^3.4.0"
"zod": "3.25.1",
"zod-validation-error": "3.5.3"
},
"devDependencies": {
"@changesets/cli": "^2.29.4",
Expand Down
2 changes: 1 addition & 1 deletion 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 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