Skip to content

createEoaAuthContext does not support chainId in SIWE message — defaults to Ethereum mainnet (1) #1072

@studioluftbruecke

Description

@studioluftbruecke

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:

  1. getEoaAuthContextAdapter.js — explicitly picks fields from validatedAuthConfig but omits chainId
  2. getEoaAuthContext.js — explicitly picks fields from authConfig but omits chainId when calling createSiweMessageWithResources
  3. AuthConfigV2 type — does not include chainId

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions