Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1jehuang Jcode oauthAccount

From Leeroopedia
Knowledge Sources
Domains Telemetry, Privacy
Last Updated 2026-10-18 00:00 GMT

Overview

Concrete tool for tracking model-provider OAuth account membership with SHA-256 email hashing and installation-scoped queries, provided by the telemetry worker.

Description

The oauthAccount function handles two endpoints: POST /v1/oauth-account (insert) and POST /v1/oauth-account/check (membership query). On insert, it validates the UUID, provider, and email, lowercases the email, computes a SHA-256 hash, and stores the record with ON CONFLICT DO NOTHING deduplication. On check, it first verifies the installation UUID is known before querying email hash membership. The function forbids CORS (no browser access), limits body to 1 KiB, and never echoes database errors or payloads.

Usage

  • Insert account: POST /v1/oauth-account with {id, provider, email}.
  • Check membership: POST /v1/oauth-account/check with {id, provider, email_hash}.

Code Reference

Source Location

  • Repository: jcode
  • File: telemetry-worker/src/oauth-account.js

Signature

export async function oauthAccount(request, env, check)

// Constants:
const PROVIDERS = new Set(["anthropic", "openai", "gemini", "copilot", "antigravity"]);
const MAX_BYTES = 1024;
// UUID and SHA-256 hash regex patterns

Import

import { oauthAccount } from "./oauth-account.js";

I/O Contract

Inputs

Name Type Required Description
body.id string Yes /// UUID telemetry installation identifier
body.provider string Yes /// One of: anthropic, openai, gemini, copilot, antigravity
body.email string Yes (insert) /// Email address (lowercased, hashed)
body.email_hash string Yes (check) /// SHA-256 hash of email

Outputs

Name Type Description
insert response {ok: true} /// Always returns ok; dedup status never exposed
check response {installation_known: bool, email_tracked: bool} /// Membership query result

Usage Examples

Insert Account

curl -X POST https://telemetry.jcode.sh/v1/oauth-account \
  -H "Content-Type: application/json" \
  -d '{"id": "uuid-here", "provider": "anthropic", "email": "user@example.com"}'
# Response: {"ok": true}

Check Membership

curl -X POST https://telemetry.jcode.sh/v1/oauth-account/check \
  -H "Content-Type: application/json" \
  -d '{"id": "uuid-here", "provider": "anthropic", "email_hash": "sha256hash"}'
# Response: {"installation_known": true, "email_tracked": true}

Related Pages

Implements Principle

Requires Environment

Uses Heuristics

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment