Skip to content

feat(addresszen): add Addresszen plugin - #353

Merged
devjain32 merged 8 commits into
corsairdev:mainfrom
Ayush7614:feat/addresszen-plugin
Aug 6, 2026
Merged

feat(addresszen): add Addresszen plugin#353
devjain32 merged 8 commits into
corsairdev:mainfrom
Ayush7614:feat/addresszen-plugin

Conversation

@Ayush7614

@Ayush7614 Ayush7614 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Description

Adds @corsair-dev/addresszen with API-key auth and four read endpoints:

  • key.availabilityGET /v1/keys/{key} (catalog: ADDRESSZEN_KEY_AVAILABILITY)
  • resolve.addressUsaGET /v1/autocomplete/addresses/{id}/usa (catalog: ADDRESSZEN_RESOLVE_ADDRESS_USA)
  • autocomplete.addressesGET /v1/autocomplete/addresses
  • verify.addressPOST /v1/verify/addresses

Includes Zod input/output schemas, error handlers, local DB entities, and Jest live API tests.

Claimed integration: https://corsair.dev/oss/addresszen

Closes #352

Checklist

Before submitting your PR, please verify the following:

  • I have run pnpm lint and all checks pass
  • I have run pnpm typecheck and there are no TypeScript errors
  • I have run pnpm build and all packages build successfully
  • I have run pnpm test and all tests pass
  • I have added or updated tests where applicable
  • I have added or updated necessary documentation

Screenshots / Demos (if applicable)

Screenshot 2026-08-05 at 5 50 04 PM

Live API tests passing:

Command used:
ADDRESSZEN_API_KEY='YOUR_KEY' pnpm --filter @corsair-dev/addresszen test

Summary by CodeRabbit

  • New Features

    • Added Addresszen integration for API-key availability, address autocomplete, U.S. address resolution, and address verification.
    • Added typed request and response validation for Addresszen operations.
    • Added configurable authentication, persistence, and endpoint metadata support.
    • Added automatic handling and retry behavior for rate-limit and server errors.
  • Tests

    • Added integration and type coverage for key availability, autocomplete, address resolution, and verification workflows, including full and split address inputs.

@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

@Ayush7614 is attempting to deploy a commit to the corsair Team on Vercel.

A member of the Team first needs to authorize it.

@Ayush7614
Ayush7614 force-pushed the feat/addresszen-plugin branch 2 times, most recently from 210ca96 to b36a8be Compare July 5, 2026 08:48
@greptile-apps

greptile-apps Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a new Addresszen integration with API-key authentication, typed schemas, persistence entities, error handling, and live endpoint tests.

  • Implements address autocomplete, US address resolution, address verification, and key-availability operations.
  • Registers Addresszen in the shared provider catalog.
  • Adds package build, type-check, and Jest configuration.

Confidence Score: 5/5

The PR appears safe to merge, with no blocking failure remaining.

No blocking failure remains; the only outstanding prior concern is the non-blocking exposure inherent in placing the API key in the key-availability request path.

Important Files Changed

Filename Overview
packages/addresszen/client.ts Adds the shared Addresszen HTTP transport, Authorization-header authentication, and provider-specific error normalization.
packages/addresszen/index.ts Defines the plugin factory, endpoint bindings, schemas, metadata, authentication configuration, and key resolution.
packages/addresszen/endpoints/types.ts Defines the Zod request and response contracts for all four Addresszen operations.
packages/addresszen/endpoints/autocomplete.ts Implements paginated address autocomplete with optional result persistence and event logging.
packages/addresszen/endpoints/resolve.ts Implements US address resolution with encoded address IDs and optional persistence.
packages/addresszen/endpoints/verify.ts Implements address verification with structured persistence keys and event logging.
packages/addresszen/error-handlers.ts Maps rate-limit, authentication, not-found, server, and default errors to retry policies.
packages/addresszen/package.json Configures the publishable Addresszen package and now declares the test suite's dotenv dependency.
packages/corsair/core/constants.ts Registers the Addresszen provider ID and display name in the shared core catalog.

Sequence Diagram

sequenceDiagram
  participant App as Host application
  participant Corsair as Corsair endpoint binding
  participant Plugin as Addresszen plugin
  participant API as Addresszen API
  participant DB as Optional local database
  App->>Corsair: Call addresszen.api endpoint
  Corsair->>Corsair: Validate input and resolve API key
  Corsair->>Plugin: Invoke bound endpoint
  Plugin->>API: Send authenticated HTTP request
  API-->>Plugin: Return address result
  opt Database entity configured
    Plugin->>DB: Upsert response data
  end
  Plugin-->>Corsair: Return typed response
  Corsair->>Corsair: Validate output
  Corsair-->>App: Return endpoint result
Loading

Reviews (5): Last reviewed commit: "fix(addresszen): omit auth header on pub..." | Re-trigger Greptile

Comment thread packages/addresszen/package.json
@Ayush7614
Ayush7614 force-pushed the feat/addresszen-plugin branch from b36a8be to 5afb3ea Compare July 5, 2026 08:52
Implements the Addresszen OSS integration with API-key auth, autocomplete
suggestions, USPS CASS address verification, local DB entities, and tests.

Uses Authorization header auth, adds dotenv devDependency, and documents
unknown API fields per plugin conventions.

Closes corsairdev#352
@Ayush7614
Ayush7614 force-pushed the feat/addresszen-plugin branch from 5afb3ea to bf65e86 Compare July 5, 2026 08:54
@Ayush7614

Copy link
Copy Markdown
Contributor Author

@greptileai

Cover the OSS catalog surface and keep autocomplete/verify.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e78b873-8f86-42c7-bd80-138b708846b7

📥 Commits

Reviewing files that changed from the base of the PR and between 7bd78a4 and a61c5c9.

📒 Files selected for processing (4)
  • packages/addresszen/api.test.ts
  • packages/addresszen/client.ts
  • packages/addresszen/endpoints/key.ts
  • packages/corsair/core/constants.ts

📝 Walkthrough

Walkthrough

Adds a new @corsair-dev/addresszen package with typed Addresszen API access, four endpoints, persistence schemas, retry handling, plugin integration, provider registration, and integration tests.

Changes

Addresszen integration

Layer / File(s) Summary
Package and endpoint contracts
packages/addresszen/package.json, packages/addresszen/tsconfig.json, packages/addresszen/jest.config.cjs, packages/addresszen/tsup.config.ts, packages/addresszen/schema/*, packages/addresszen/endpoints/types.ts
Adds package build and test configuration, database schemas, endpoint schemas, inferred types, and endpoint schema registries.
API client and retry handling
packages/addresszen/client.ts, packages/addresszen/error-handlers.ts
Adds authenticated Addresszen requests, HTTP error normalization, query and JSON body handling, and retry policies for rate-limit and server errors.
Endpoint implementations
packages/addresszen/endpoints/*
Adds autocomplete, key availability, US address resolution, and address verification handlers with optional persistence and completion logging.
Plugin factory and integration validation
packages/addresszen/index.ts, packages/addresszen/api.test.ts, packages/corsair/core/constants.ts
Adds the Addresszen plugin factory, authentication configuration, endpoint metadata, integration tests, and provider registration.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant AddresszenPlugin
  participant AddresszenAPI
  participant CorsairDatabase
  Caller->>AddresszenPlugin: invoke typed endpoint
  AddresszenPlugin->>AddresszenAPI: send authenticated request
  AddresszenAPI-->>AddresszenPlugin: return typed response
  AddresszenPlugin->>CorsairDatabase: optionally persist response
  AddresszenPlugin-->>Caller: return endpoint response
Loading

Possibly related PRs

  • corsairdev/corsair#344: Adds a structurally parallel provider plugin with typed clients, schemas, error handling, and packaging.
  • corsairdev/corsair#512: Adds an analogous address-validation integration with shared provider registration patterns.
  • corsairdev/corsair#471: Adds a first-class Corsair provider with endpoint schemas, authentication, error handling, and package tooling.

Suggested labels: plugin, needs-maintainer

Suggested reviewers: mayank-saraswal, dhirenderchoudhary, omkarbansod02

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR adds key.availability and resolve.addressUsa, which issue #352 does not request. Remove the unrequested endpoints, or update issue #352 to explicitly include their requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The implementation covers autocomplete, verification, API-key authentication, the required base URL, schemas, and no webhook support from issue #352.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the addition of the Addresszen plugin.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
www Skipped Skipped Aug 5, 2026 12:26pm

Request Review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/addresszen/api.test.ts`:
- Around line 11-13: Update the Addresszen API test suite around TEST_API_KEY
and “Addresszen API Type Tests” so it does not run live requests when
ADDRESSZEN_API_KEY is absent. Replace the non-null assertion with an explicit
presence check and conditionally skip the suite, or gate it behind the project’s
established integration-test setting; preserve normal execution when a valid
test key is configured.

In `@packages/addresszen/endpoints/key.ts`:
- Around line 24-30: Update the keyAvailability persistence call in the
upsertByEntityId flow to use the account’s non-secret identifier from await
ctx.$getAccountId() instead of ctx.key, while preserving the existing
availability payload and update behavior.

In `@packages/addresszen/endpoints/types.ts`:
- Around line 15-21: The autocomplete request contract is missing pagination
fields and uses the wrong provider query key. In
packages/addresszen/endpoints/types.ts lines 15-21, update
AutocompleteAddressesInputSchema to include optional public limit and page
fields; in packages/addresszen/endpoints/autocomplete.ts lines 20-22, map query
to provider parameter q and forward limit and page.

In `@packages/addresszen/endpoints/verify.ts`:
- Around line 28-43: Update the verified-address entity schema and the verify
endpoint’s entity-ID construction and upsert payload to include input.context.
Ensure context participates in identity so distinct contexts create separate
records, while preserving the existing address fields and storing the metadata
on each record.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b119b8b7-d657-45d1-8b89-23cde0b1b193

📥 Commits

Reviewing files that changed from the base of the PR and between 7c94b16 and 7c53ef7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (18)
  • demo/testing/package.json
  • demo/testing/src/server/corsair.ts
  • packages/addresszen/api.test.ts
  • packages/addresszen/client.ts
  • packages/addresszen/endpoints/autocomplete.ts
  • packages/addresszen/endpoints/index.ts
  • packages/addresszen/endpoints/key.ts
  • packages/addresszen/endpoints/resolve.ts
  • packages/addresszen/endpoints/types.ts
  • packages/addresszen/endpoints/verify.ts
  • packages/addresszen/error-handlers.ts
  • packages/addresszen/index.ts
  • packages/addresszen/jest.config.cjs
  • packages/addresszen/package.json
  • packages/addresszen/schema/database.ts
  • packages/addresszen/schema/index.ts
  • packages/addresszen/tsconfig.json
  • packages/addresszen/tsup.config.ts

Comment thread packages/addresszen/api.test.ts Outdated
Comment thread packages/addresszen/endpoints/key.ts Outdated
Comment thread packages/addresszen/endpoints/types.ts
Comment thread packages/addresszen/endpoints/verify.ts
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile Review

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Plugin PR scorecard — packages/addresszen

Check Status Notes
R1 — Scope: plugin files only
R2 — Tests with assertions
R3 — Description complete
R3 — Linked issue / claim
R4 — Demo video / recording

Rules: PLUGIN_PR_RULES.md · re-runs on every push

@github-actions github-actions Bot added the gate:failed Plugin PR gate checks failing label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Hey @Ayush7614, thanks for the contribution! 🏴‍☠️ Before a maintainer reviews, please fix the items below — the review re-runs automatically on your next push.

Must fix

  • P1 packages/addresszen/package.json:45Missing dotenv devDependency
    packages/addresszen/api.test.ts imports 'dotenv/config' at the top, but dotenv is not listed in the package's devDependencies. Under pnpm's strict isolation model each package can only resolve its own declared dependencies, so pnpm --filter @corsair-dev/addresszen test will fail with a module-not-found error for any developer who runs it without dotenv being hoisted from elsewhere in the workspace.

PR requirements (rules)

  • R1 — Out of scope: demo/testing/package.json, demo/testing/src/server/corsair.ts

If anything remains after your next push, a bot commit will clean it up; a maintainer always does the final review and merge.

@github-actions github-actions Bot added the bot:round-1 Review bot posted consolidated findings label Aug 5, 2026
@github-actions github-actions Bot added the core Changes in packages/corsair label Aug 5, 2026
@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile Review

) => {
const response = await makeAddresszenRequest<
AddresszenEndpointOutputs['keyAvailability']
>(`keys/${encodeURIComponent(ctx.key)}`, ctx.key, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security API key remains in URL

When a caller invokes key.availability, this endpoint interpolates the live API key into the request path, causing the credential to be retained by provider, proxy, or access-log infrastructure despite the new Authorization header. How this was verified: The endpoint passes ctx.key in keys/{key} while the client separately sends the same key in the Authorization header.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddressZen documents this as GET /keys/:key (public availability) there is no header-only variant (verified: /keys, /keys/me, /keys/current all 404). The path segment is the resource id, not optional auth.

Mitigation in 2544721: omit the Authorization header for this call so the key isn’t sent twice. Remaining path usage is provider-mandated; dropping the op would remove catalog ADDRESSZEN_KEY_AVAILABILITY.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation already has auth: false in the call — the mitigation is in place. The original concern was about the key being sent twice (path + header), and commit 2544721 resolved exactly that by adding the auth flag to makeAddresszenRequest.

Since the path is provider-mandated and the Authorization header is now suppressed for this endpoint, the concern is addressed. Fair point — withdrawing this comment.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@github-actions github-actions Bot added bot:round-2 Review bot pushed an automated fix and removed gate:failed Plugin PR gate checks failing labels Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Remaining findings are being fixed by a bot commit — it will be re-reviewed automatically.

@Dhirenderchoudhary

Copy link
Copy Markdown
Collaborator

@greptile review

@devjain32
devjain32 merged commit 5b72ec3 into corsairdev:main Aug 6, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:round-1 Review bot posted consolidated findings bot:round-2 Review bot pushed an automated fix core Changes in packages/corsair

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Integration request]: Addresszen

3 participants