npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dpdpguard/js

v2.1.0

Published

DPDP Guard JS core - pure HTTP client over the Consent API for web/RN-unsupported/lite integrations

Downloads

588

Readme

dpdpguard-js-sdk

DPDP Guard JS core - pure HTTP client over the Consent API for web/RN-unsupported/lite integrations

Package: @dpdpguard/js

Part of the DPDP Guard SDK family. See the design spec: https://github.com/chintans/dpdpbot/blob/main/docs/specs/mobile-server-sdk.md

Status

Early scaffold. Covers the /api/v1 public, unauthenticated surface only (org lookup, notices, banner config, anonymous consent) — the brokered-token and service-API-key surfaces (DSR, grievances, nomination, token broker) live in @dpdpguard/server.

Usage

import { DpdpGuardClient } from "@dpdpguard/js";

const client = new DpdpGuardClient({ baseUrl: "https://your-deployment.convex.site" });

const org = await client.getOrgBySlug("acme");
const { notices } = await client.getNoticesForOrg(org.orgId);
const bannerConfig = await client.getBannerConfig(org.orgId, { domain: "acme.com" });

await client.giveConsentAnonymous({
  organizationId: org.orgId,
  noticeId: notices[0]._id,
  purpose: "Marketing",
  dataTypes: ["email"],
  anonymousId: crypto.randomUUID(),
});

Non-2xx responses throw DpdpGuardApiError — branch on .code (the ADR-002 D2 stable error catalog), not the free-text .error message.

Architecture: generated vs. hand-written

Per spec §11, this SDK splits into two layers — only the first is ever regenerated:

  • src/generated/schema.ts — TypeScript types generated from @dpdpguard/contract's openapi/v1.yaml. Regenerate with npm run generate whenever the installed @dpdpguard/contract version bumps. Do not hand-edit.
  • src/client.ts — the hand-written HTTP client built on those types.

Why a custom generator instead of openapi-typescript

scripts/generate-schema.mjs is a small, dependency-light generator instead of a stock OpenAPI-to-TS tool: openapi-typescript 7.x builds its output via the typescript compiler API (ts.factory), and this repo's pinned typescript@^7.0.2 (the newer native/Corsa line) doesn't expose that API in the same shape yet, so the two currently crash together. The custom generator only needs a YAML parser (yaml) and string templating. Revisit this once openapi-typescript ships TS7 support.

It emits every schema under components.schemas generically, plus named request/response types for the specific operations this SDK implements (see the OPERATIONS list in the script) — those particular shapes are inline in the spec's path definitions rather than components.schemas. Adding a new endpoint to this SDK means adding an entry there, not hand-writing a type.

Tolerant reader (ADR-002 D4 enabling rule)

Generated response enums are widened to "a" | "b" | (string & {}) rather than a closed union, so a new enum value added upstream (a minor, non-breaking contract change per ADR-002 D4) doesn't require a client type change or runtime failure.

Conformance gate (ADR-002 D5)

src/__conformance__/audit-hash-vectors.conformance.test.ts runs against the golden vectors published in @dpdpguard/contract's conformance/audit-hash-vectors.json, checking that canonicalizeDataTypes (used before every giveConsentAnonymous call) sorts dataTypes the same way the server's audit-hash canonicalization does. This SDK never computes the hash itself — that requires the server's HMAC secret, which a client must never hold — only the client-side half of the canonicalization is checked here. This is a required, non-optional CI gate: a failing conformance test blocks release (see .github/workflows/ci.yml).

Scripts

| Script | What it does | |---|---| | npm run generate | Regenerate src/generated/schema.ts from the installed @dpdpguard/contract. | | npm run typecheck | Full project typecheck, including tests. | | npm test | Unit + conformance tests (vitest). | | npm run build | Regenerate, then compile src/ (excluding tests) to dist/. |

Publishing

.github/workflows/publish.yml publishes to npm via OIDC trusted publishing (no NPM_TOKEN secret), triggered by pushing a v* tag or manually via workflow_dispatch. One-time setup required before this can succeed: register @dpdpguard/js on npmjs.com with GitHub Actions as a Trusted Publisher (Organization/repo/workflow filename = this repo / publish.yml) — same one-time step already done for dpdpbot's @dpdpguard/contract.