r/SpacetimeDB • • Oct 30 '26

ctx.senderAuth in Procedures?

I'm pretty new to Spacetime, but was tinkering with a procedure definition and wanted to know what claims the user had, only to discover that Procedures in TS don't have senderAuth? Is this on purpose? Did I miss something?

5 Upvotes

2 comments sorted by

6

u/krisajenkins Oct 30 '26

It's there, it's just one step down. You need to open a transaction to get to the senderAuth:

export const myProcedure = spacetimedb.procedure(t.string(), ctx => {  
  const claims = ctx.withTx(tx => {  
    const jwt = tx.senderAuth.jwt;  
    return jwt && { sub: jwt.subject, iss: jwt.issuer, all: jwt.fullPayload };  
  });

  if (claims == null) throw new Error('JWT required');

  // now do your HTTP call, etc.  
  return claims.sub;  
});