diff --git a/README.md b/README.md index 9035938..d077462 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.json b/package.json index c1c850a..44c2a98 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.ts b/src/index.ts index 09ade4a..b87b4cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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('/v1/sessions', { method: 'POST', diff --git a/src/types.ts b/src/types.ts index 17bd4f4..7a3c3ed 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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 { @@ -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; diff --git a/tests/index.test.ts b/tests/index.test.ts index 63432dd..2992940 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -1296,7 +1296,7 @@ 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({ @@ -1304,6 +1304,7 @@ describe('AgentScore.createSession()', () => { product_name: 'Widget', address: WALLET, operator_token: 'opc_sess', + kind: 'sign_in', }); const call = (global.fetch as ReturnType).mock.calls[0]; const body = JSON.parse(call[1].body as string) as Record; @@ -1311,6 +1312,16 @@ describe('AgentScore.createSession()', () => { 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).mock.calls[0]; + const body = JSON.parse(call[1].body as string) as Record; + expect('kind' in body).toBe(false); }); });