Pidgeon Auth · Live demo
An agent signs in
No person present: the agent signs a token exchange with its Passport key, then sends the ID token with a request signed by the same key, so a copied token is useless alone.
import { signedFetch } from '@pidgeon-ai/sdk';
import { signInAsAgent } from '@pidgeon-ai/sdk/auth';
import { keyIdOf } from '@pidgeon-ai/sdk/credential';
// Your agent's key and directory, as the dashboard gave them.
const privateJwk = JSON.parse(process.env.PIDGEON_AGENT_KEY);
const directory = process.env.PIDGEON_DIRECTORY;
const kid = await keyIdOf({ kty: 'OKP', crv: 'Ed25519', x: privateJwk.x });
const { idToken } = await signInAsAgent({
site: 'site_fdqftfCyGcONAyXP',
key: { kid, privateJwk },
directory,
});
const answer = await signedFetch(
'https://demo.pidgeon.ai/api/whoami',
{ headers: { authorization: `Bearer ${idToken}` } },
{ privateJwk, directory },
);
console.log(await answer.json()); // the claims this site accepted