DecaneDocs
Social sign-inCustom auth
Social sign-in

Custom auth

Google and email are the default social sign-in methods, but you can also bring your own identity provider — Auth0, Clerk, Firebase, Cognito, or your own backend’s JWT issuer. Register the issuer once in the dashboard; from then on the SDK exchanges a token your system already issues for a Decane session, and everything downstream (wallet creation, signing, recovery) is identical to Google/email sign-in. You write no auth code and store no secret with Decane — only public information (issuer URL, JWKS URL) ever reaches the dashboard.

Register a provider

Dashboard → your project → Custom Auth → Add provider.

FieldWhat it is
IssuerThe iss claim your tokens carry. Must match exactly.
JWKS URLWhere your public signing keys live. Must be https:// (or localhost for local dev) — a downgraded fetch would let an on-path attacker serve a forged key set.
Identity claimWhich claim identifies the user. Defaults to sub.
AudienceExpected aud claim. Optional — omit to accept any audience.
!

Issuer and identity claim are immutable once created. Every user’s wallet is derived from HMAC(providerId + claim value) — changing either would silently re-identify existing users with no error anywhere, just an empty-looking wallet. Register a second provider instead. For the same reason, a provider can’t be deleted once it has signed in at least one user — disable it instead; existing users keep working, no new ones are admitted.

Config

Add customAuth to SocialConfig. getToken runs when the user clicks the button — wire it to however you already obtain a token from your auth system (often: after your own login flow completes).

tsx
<DecaneKit
  config={{
    appId: "<your project id>",
    mode: "all",
    social: {
      apiKey: "<your api key>",
      authMethods: ["google", "email"],
      chains: ["evm:1", "solana:mainnet"],
      customAuth: {
        label: "Continue with Acme Inc",   // button text
        providerId: undefined,             // only needed with >1 provider
        getToken: async () => {
          const session = await myAuthClient.getSession();
          return session.accessToken;
        },
      },
    },
  }}
>
  {children}
</DecaneKit>

This renders a button in both WalletSelector and SocialWalletModal’s sign-in view, alongside Google/email — no other UI work needed.

Headless

Driving your own sign-in UI instead of the built-in modal:

tsx
import { useSocialAuth } from "decane-connect-kit";

function MySignInButton() {
  const { signInWithToken, tokenLoading } = useSocialAuth();

  async function handleClick() {
    const token = await myAuthClient.getAccessToken();
    await signInWithToken(token /*, { providerId: "..." } if you have >1 provider */);
  }

  return <button onClick={handleClick} disabled={tokenLoading}>Sign in</button>;
}

Or fully outside React, via the standalone social SDK:

ts
import { createDecaneConnect } from "decane-connect-kit";

const connect = await createDecaneConnect({
  appId: "<your project id>",
  apiKey: "<your api key>",
  authMethods: ["google", "email"],
  chains: ["evm:1", "solana:mainnet"],
});

const token = await myAuthClient.getAccessToken();
const { addresses, isNewUser } = await connect.connectWithToken(token);

connectWithToken returns the same ConnectResult shape as connectWithGoogle / verifyEmailCode.

JWKS format

Your JWKS URL must return a standard key set — a keys array containing the public key your tokens are signed with, matched by kid. RSA (RS256 — the default for Auth0, Clerk, and Firebase):

json
{
  "keys": [
    {
      "kty": "RSA",
      "kid": "your-key-id-1",
      "use": "sig",
      "alg": "RS256",
      "n": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtV...",
      "e": "AQAB"
    }
  ]
}

EC (ES256) is also supported — { kty: "EC", crv: "P-256", x, y } instead of n/e. Multiple keys in the array is how rotation works: the moment a token shows up with an unrecognized kid, the backend refetches your JWKS automatically — no coordination needed when you rotate your signing key.

Multiple providers

With more than one enabled custom provider on a project, pass providerId so the backend knows which issuer/JWKS to verify against — without it, trying every configured issuer in turn would let a token from a weak provider be accepted as if it came from a strong one. With exactly one provider configured, providerId can always be omitted.

Testing locally

packages/backend/mock-idp.mjs is a throwaway identity provider for exactly this — generates a keypair on boot, publishes a JWKS, and mints tokens on demand, no external account needed.

bash
node packages/backend/mock-idp.mjs
# then:
curl "http://localhost:4000/token?sub=alice&email=alice@example.com"
✓

Decane never sees your users’ credentials — only a token they already have, and only its signature, issuer, and one claim. A provider’s config is trusted for its own project only; a developer who controls it can assert any identity within their own project, which is inherent to “bring your own issuer” and not a Decane-specific risk.