Skip to content

feat: add uid2Refresh to SDK#281

Open
MO-Thibault wants to merge 1 commit into
Optable:masterfrom
MO-Thibault:mo/uid2-refresh
Open

feat: add uid2Refresh to SDK#281
MO-Thibault wants to merge 1 commit into
Optable:masterfrom
MO-Thibault:mo/uid2-refresh

Conversation

@MO-Thibault
Copy link
Copy Markdown
Contributor

Summary

  • Adds Uid2Refresh(refreshToken, refreshResponseKey) to lib/edge/uid2_token.ts — calls prod.uidapi.com/v2/token/refresh directly (no DCN involved)
  • Adds AES-GCM decryption via browser WebCrypto API (crypto.subtle) to handle the encrypted UID2 refresh response
  • Exposes sdk.uid2Refresh(refreshToken, refreshResponseKey) instance method on OptableSDK, consistent with the existing uid2Token pattern
  • Exports Uid2RefreshBody type for the decrypted response body (snake_case, matches UID2 v2 API)

Motivation

Several solution wrappers (e.g. Mediavine) implement this refresh+decrypt logic inline. Bringing it into the SDK eliminates duplication and makes it available to all publishers.

Test plan

  • Build passes (npm run build)
  • Call sdk.uid2Token(email) to get an initial identity, then sdk.uid2Refresh(identity.RefreshToken, identity.RefreshResponseKey) to verify refresh returns a new advertising_token

🤖 Generated with Claude Code

Adds client-side UID2 token refresh via the UID2 v2 API. The response
is AES-GCM encrypted and decrypted using the browser WebCrypto API.

Exposes:
- `Uid2Refresh(refreshToken, refreshResponseKey)` from edge/uid2_token
- `sdk.uid2Refresh(refreshToken, refreshResponseKey)` instance method
- `Uid2RefreshBody` type for the decrypted response body

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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