Skip to content

feat(token): detect internal users proxying as a client - #33

Merged
priosshrsth merged 3 commits into
mainfrom
feat/token-proxy-detection
Aug 18, 2026
Merged

feat(token): detect internal users proxying as a client#33
priosshrsth merged 3 commits into
mainfrom
feat/token-proxy-detection

Conversation

@priosshrsth

Copy link
Copy Markdown
Collaborator

Assembly tokens can carry both internalUserId and clientId when an internal user previews as a client from the CRM. Today both isClientUser and isInternalUser return true and both ensureIs* guards pass, so if (token.isInternalUser) {...} else {...} picks a branch by ordering rather than intent — an app can show the admin surface to a proxied client session, or the client view to a real IU. This adds token.isProxying so the case is nameable.

API calls are unaffected: the SDK never reads identity from the token, the compound key is unchanged, and the backend resolves proxy permissions.

What to look at:

  • src/token/assembly-token.ts — the new getter only; isClientUser/isInternalUser/ensureIs* semantics are deliberately unchanged, since both identities genuinely are present. Whether a proxy session should count as internal for a given guard is app policy.
  • README.mdisClientUser was documented as requiring companyId; it only checks clientId.

Verified: bun run test (195 pass) and vp check clean, including a new PROXY_TOKEN fixture covering the dual-ID payload end to end through decrypt + validate. Not verified against a real CRM-issued proxy token — the fixture is SDK-encrypted, so field names are assumed to match production.

🤖 Generated with Claude Code

priosshrsth and others added 3 commits August 18, 2026 09:09
Assembly tokens can carry both internalUserId and clientId when an internal
user proxies as a client from the CRM. Both isClientUser and isInternalUser
return true in that case, so a plain if/else on either one silently picks a
branch based on ordering. isProxying makes the case nameable.

Also corrects the README claim that isClientUser requires companyId.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@priosshrsth
priosshrsth merged commit aa58320 into main Aug 18, 2026
5 checks passed
@priosshrsth
priosshrsth deleted the feat/token-proxy-detection branch August 18, 2026 11:57
This was referenced Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant