Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ if (status.status === "verified") {
// for an existing operator credential.
await client.createSession({ address: "0x..." });
await client.createSession({ operator_token: "opc_..." }); // KYC refresh
await client.createSession({ kind: "sign_in" }); // registration-only: account sign-in, no identity documents
```

### Wallet resolution
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agent-score/sdk",
"version": "2.7.9",
"version": "2.7.10",
"description": "TypeScript client for the AgentScore APIs",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class AgentScore {
if (options?.product_name) body.product_name = options.product_name;
if (options?.address) body.address = options.address;
if (options?.operator_token) body.operator_token = options.operator_token;
if (options?.kind) body.kind = options.kind;

return this.request<SessionCreateResponse>('/v1/sessions', {
method: 'POST',
Expand Down
7 changes: 7 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,11 @@ export interface SessionCreateOptions {
address?: string;
/** Pre-associate the session with an existing operator credential — e.g. refresh KYC for an `opc_...`. */
operator_token?: string;
/** Session kind. `'kyc'` (the default) runs identity verification; `'sign_in'` is
* registration-only (the buyer signs in with an AgentScore account, no identity documents)
* and mints a `sign_in`-scoped credential, for merchants that key durable state on the
* account without any compliance policy. */
kind?: 'kyc' | 'sign_in';
}

export interface SessionCreateNextSteps {
Expand All @@ -581,6 +586,8 @@ export interface SessionCreateResponse {
verify_url: string;
poll_url: string;
expires_at: string;
/** The kind the session was minted with; absent on older API responses. */
kind?: 'kyc' | 'sign_in';
/** Structured `next_steps.action: 'deliver_verify_url_and_poll'` with step-by-step
* instructions for consuming the session. */
next_steps?: SessionCreateNextSteps;
Expand Down
13 changes: 12 additions & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1296,21 +1296,32 @@ describe('AgentScore.createSession()', () => {
expect(JSON.parse(call[1].body as string)).toEqual({});
});

it('includes context, product_name, address, and operator_token when provided', async () => {
it('includes context, product_name, address, operator_token, and kind when provided', async () => {
mockFetchOk(SESSION_CREATE_RESPONSE);
const client = new AgentScore({ apiKey: API_KEY });
await client.createSession({
context: 'checkout',
product_name: 'Widget',
address: WALLET,
operator_token: 'opc_sess',
kind: 'sign_in',
});
const call = (global.fetch as ReturnType<typeof vi.fn>).mock.calls[0];
const body = JSON.parse(call[1].body as string) as Record<string, unknown>;
expect(body.context).toBe('checkout');
expect(body.product_name).toBe('Widget');
expect(body.address).toBe(WALLET);
expect(body.operator_token).toBe('opc_sess');
expect(body.kind).toBe('sign_in');
});

it('omits kind from the body when not provided, so the API applies its default', async () => {
mockFetchOk(SESSION_CREATE_RESPONSE);
const client = new AgentScore({ apiKey: API_KEY });
await client.createSession({ context: 'checkout' });
const call = (global.fetch as ReturnType<typeof vi.fn>).mock.calls[0];
const body = JSON.parse(call[1].body as string) as Record<string, unknown>;
expect('kind' in body).toBe(false);
});
});

Expand Down