-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
Problem
When using authManager.createEoaAuthContext(), the SIWE message is always created with chainId: 1 (Ethereum mainnet). There is no way to specify a different chain ID through the authConfig parameter.
This breaks authentication for wallets on non-Ethereum networks. For example, the LUKSO Universal Profile Browser Extension rejects the signature request with:
"The login message requests a network (Chain ID: 1) that your profile does not support."
Root Cause
createSiweMessageWithResources in @lit-protocol/auth-helpers already supports a chainId parameter (BaseSiweMessage includes chainId?: number), but the EOA auth flow never passes it through:
getEoaAuthContextAdapter.js— explicitly picks fields fromvalidatedAuthConfigbut omitschainIdgetEoaAuthContext.js— explicitly picks fields fromauthConfigbut omitschainIdwhen callingcreateSiweMessageWithResourcesAuthConfigV2type — does not includechainId
So createSiweMessage always falls back to chainId: params?.chainId ?? 1.
Suggested Fix
diff --git a/src/lib/AuthManager/authAdapters/getEoaAuthContextAdapter.js b/src/lib/AuthManager/authAdapters/getEoaAuthContextAdapter.js
--- a/src/lib/AuthManager/authAdapters/getEoaAuthContextAdapter.js
+++ b/src/lib/AuthManager/authAdapters/getEoaAuthContextAdapter.js
authConfig: {
domain: validatedAuthConfig.domain,
resources: validatedAuthConfig.resources,
capabilityAuthSigs: validatedAuthConfig.capabilityAuthSigs,
expiration: validatedAuthConfig.expiration,
statement: validatedAuthConfig.statement,
+ chainId: params.authConfig.chainId,
},
diff --git a/src/lib/AuthManager/authContexts/getEoaAuthContext.js b/src/lib/AuthManager/authContexts/getEoaAuthContext.js
--- a/src/lib/AuthManager/authContexts/getEoaAuthContext.js
+++ b/src/lib/AuthManager/authContexts/getEoaAuthContext.js
resources: _params.authConfig.resources,
walletAddress: walletAddressForSiwe,
nonce: _params.deps.nonce,
+ chainId: _params.authConfig.chainId,
});
diff --git a/src/lib/authenticators/types.d.ts b/src/lib/authenticators/types.d.ts
--- a/src/lib/authenticators/types.d.ts
+++ b/src/lib/authenticators/types.d.ts
export type AuthConfigV2 = Partial<Omit<z.infer<typeof AuthConfigSchema>, 'resources'>> & {
resources: ShorthandResources;
+ chainId?: number;
};Expected Usage
const authContext = await authManager.createEoaAuthContext({
config: { account: walletClient },
authConfig: {
domain: "localhost",
chainId: 42, // LUKSO Mainnet
resources: [["access-control-condition-decryption", "*"]],
},
litClient,
});Package Version
@lit-protocol/[email protected]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels