@adcp/sdk API Reference - v7.9.0
    Preparing search index...

    Class InMemoryImplicitAccountStore<TCtxMeta>

    In-memory AccountStore for resolution: 'implicit' platforms.

    Wire contract:

    1. Buyer calls sync_accounts → framework calls upsert() → store records authKey → accounts[].
    2. Buyer calls any tool (e.g. create_media_buy) without ext.account_ref → framework calls resolve(undefined, ctx) → store looks up by authKey.
    3. If no prior sync: resolve() returns null → framework emits ACCOUNT_NOT_FOUND. Do NOT return AUTH_REQUIRED — that signals missing credentials, not a missing pre-sync.

    This class is intentionally minimal. Copy-and-adapt for durable stores (Postgres, Redis); see docs/guides/account-resolution.md for the DDL reference and the key-derivation rationale.

    import { InMemoryImplicitAccountStore } from '@adcp/sdk/server';

    const accountStore = new InMemoryImplicitAccountStore({
    buildAccount: async (ref, ctx) => {
    const upstream = await myPlatform.findOrCreate(ref, ctx?.authInfo);
    return {
    id: upstream.id,
    name: upstream.name,
    status: 'active',
    ctx_metadata: { upstreamId: upstream.id },
    };
    },
    });

    // Wire into createAdcpServer:
    createAdcpServer({ accounts: accountStore, ... });

    Type Parameters

    • TCtxMeta = Record<string, unknown>

    Implements

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    resolution: "implicit" = ...

    How buyers reference accounts on this platform.

    • 'explicit' — buyer passes account_id inline on every request (Snap, Meta, GAM via Network/Company id). The default.
    • 'implicit' — buyer must sync_accounts first; subsequent requests are resolved from the auth principal's pre-synced linkage (LinkedIn, some retail-media operators). Framework refuses inline account_id references for these platforms — emits AdcpError('INVALID_REQUEST', { field: 'account.account_id' }) before reaching accounts.resolve. The brand+operator union arm is permitted (used during the initial sync_accounts flow); only account_id-shaped references are rejected.
    • 'derived' — single-tenant agents where there is no account_id on the wire at all and the auth principal alone identifies the tenant. Most self-hosted broadcasters and retail-media operators in proxy mode. Framework refuses inline account_id references for these platforms — same AdcpError('INVALID_REQUEST', { field: 'account.account_id' }) shape as 'implicit', but with a single-tenant message instead of the sync_accounts-first guidance (no sync_accounts step exists in derived mode). The brand+operator union arm is permitted.

    Defaults to 'explicit' when omitted.

    Accessors

    Methods

    • Resolve the caller's account from the auth-principal→account mapping populated by a prior sync_accounts call.

      Returns null (→ ACCOUNT_NOT_FOUND) when:

      • No prior sync_accounts was called for this principal
      • The stored entry has exceeded ttlMs
      • ctx.authInfo is absent or carries no extractable key

      Multi-account note. When a buyer synced multiple refs in one sync_accounts call, this implementation returns the first stored account. If your platform requires per-request account disambiguation (e.g., different brands on the same buyer), switch to 'explicit' mode so buyers pass ext.account_ref on each request, or override keyFn to encode the brand into the key.

      Parameters

      Returns Promise<Account<TCtxMeta> | null>

    • Process a sync_accounts payload: build accounts from refs and store them under the caller's auth key.

      The auth key is extracted from ctx.authInfo via keyFn. When the key cannot be derived (no credential or unrecognized credential kind), all refs are returned as SYNC_FAILED rows — a silent-success-then- mystery-failure sequence is worse than an explicit error. Check your authenticate callback and keyFn if you see this error.

      When ctx.authInfo is absent (unauthenticated call), all refs fail with UNAUTHENTICATED. Your authenticate callback in serve({ authenticate }) should reject unauthenticated requests before reaching this method.

      Parameters

      Returns Promise<SyncAccountsResultRow[]>

    • Return the auth key that would be derived from authInfo. Useful in tests to assert that a specific principal's linkage was stored.

      Parameters

      • authInfo: ResolvedAuthInfo

      Returns string | undefined