@dpdpguard/react-native 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,6 +78,25 @@ Every non-2xx response throws a `DpdpGuardApiError` with a `code` from the
78
78
  ADR-002 error catalog (`err.code`, e.g. `"NOT_FOUND"`) and the HTTP
79
79
  `status`.
80
80
 
81
+ ### Types
82
+
83
+ The wire types are generated from `@dpdpguard/contract`'s `openapi/v1.yaml`
84
+ and re-exported, so you can name what the client returns instead of
85
+ re-declaring it:
86
+
87
+ ```ts
88
+ import type { DsrRequest, Notice, components } from '@dpdpguard/react-native';
89
+
90
+ const notice: Notice = await client.getNotice(noticeId);
91
+
92
+ // Endpoints this SDK deliberately doesn't wrap are still typed:
93
+ type GateDecision = components['schemas']['ConsentGateDecision'];
94
+ ```
95
+
96
+ The contract version these were generated from is recorded in
97
+ `src/CONTRACT_VERSION`; `src/contractVersion.test.ts` fails if an install
98
+ drifts off it.
99
+
81
100
  ## Contract
82
101
 
83
102
  Depends on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dpdpguard/react-native",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "DPDP Guard React Native SDK - typed HTTP client over the DPDP Guard /api/v1 surface, usable via plain fetch (no native module)",
5
5
  "main": "src/index",
6
6
  "files": [
@@ -31,6 +31,6 @@
31
31
  "typescript": "~5.8"
32
32
  },
33
33
  "dependencies": {
34
- "@dpdpguard/contract": "^1.5.0"
34
+ "@dpdpguard/contract": "^1.6.0"
35
35
  }
36
36
  }
@@ -0,0 +1 @@
1
+ 1.6.0
@@ -330,6 +330,26 @@ export interface paths {
330
330
  patch?: never;
331
331
  trace?: never;
332
332
  };
333
+ "/api/v1/consent-status": {
334
+ parameters: {
335
+ query?: never;
336
+ header?: never;
337
+ path?: never;
338
+ cookie?: never;
339
+ };
340
+ /**
341
+ * Look up an org's per-purpose consent state by email (docs/specs/ecommerce-cms-plugins.md, §4).
342
+ * @description Read-only: a WooCommerce/Shopify plugin's only fact about a customer is an email address from its own storefront — every other consent-reading route requires a dpdpbot-internal consent id or a brokered principal token. This resolves an email to the calling organization's own current per-purpose consent grants, so a plugin can gate a marketing sync in real time. `found: false` (not a 404) means the identifier is not yet a customer of record for this organization — distinct from "known, with no active consent", which is `found: true` and an empty or all-opted-out `purposes` array. Requires the `dpdp_consent_status_lookup_enabled` flag; while it is off, this route behaves as if it doesn't exist (404). Write access to consent stays `POST`/`DELETE /cm/v1/consent` — there is no corresponding write route here (ADR-007 D3).
343
+ */
344
+ get: operations["getConsentStatus"];
345
+ put?: never;
346
+ post?: never;
347
+ delete?: never;
348
+ options?: never;
349
+ head?: never;
350
+ patch?: never;
351
+ trace?: never;
352
+ };
333
353
  "/api/v1/breaches": {
334
354
  parameters: {
335
355
  query?: never;
@@ -1939,6 +1959,69 @@ export interface operations {
1939
1959
  };
1940
1960
  };
1941
1961
  };
1962
+ getConsentStatus: {
1963
+ parameters: {
1964
+ query: {
1965
+ email: string;
1966
+ };
1967
+ header?: never;
1968
+ path?: never;
1969
+ cookie?: never;
1970
+ };
1971
+ requestBody?: never;
1972
+ responses: {
1973
+ /** @description The calling key's organization's consent status for this email. */
1974
+ 200: {
1975
+ headers: {
1976
+ [name: string]: unknown;
1977
+ };
1978
+ content: {
1979
+ "application/json": {
1980
+ identifier: string;
1981
+ /** @enum {string} */
1982
+ identifierType: "email";
1983
+ found: boolean;
1984
+ purposes: {
1985
+ purposeKey: string;
1986
+ /** @enum {string} */
1987
+ category: "essential" | "non_essential";
1988
+ /** @enum {string} */
1989
+ status: "opt_in" | "opt_out";
1990
+ /** @description Epoch ms this purpose was withdrawn, if any. */
1991
+ withdrawnAt?: number;
1992
+ }[];
1993
+ };
1994
+ };
1995
+ };
1996
+ /** @description Missing `email` query parameter. */
1997
+ 400: {
1998
+ headers: {
1999
+ [name: string]: unknown;
2000
+ };
2001
+ content: {
2002
+ "application/json": components["schemas"]["ApiError"];
2003
+ };
2004
+ };
2005
+ /** @description Missing or invalid API key. */
2006
+ 401: {
2007
+ headers: {
2008
+ [name: string]: unknown;
2009
+ };
2010
+ content: {
2011
+ "application/json": components["schemas"]["ApiError"];
2012
+ };
2013
+ };
2014
+ /** @description The `dpdp_consent_status_lookup_enabled` flag is off. */
2015
+ 404: {
2016
+ headers: {
2017
+ [name: string]: unknown;
2018
+ };
2019
+ content: {
2020
+ "application/json": components["schemas"]["ApiError"];
2021
+ };
2022
+ };
2023
+ };
2024
+ };
1942
2025
  listBreaches: {
1943
2026
  parameters: {
1944
2027
  query?: never;
package/src/index.ts CHANGED
@@ -4,3 +4,30 @@ export { DpdpGuardApiError, ERROR_CATALOG } from './errorCatalog';
4
4
  export type { ApiErrorCode, ErrorCatalogEntry } from './errorCatalog';
5
5
  export { hasConsent } from './consentGate';
6
6
  export type { ConsentRecord } from './consentGate';
7
+
8
+ // The openapi-typescript output generated from the installed
9
+ // @dpdpguard/contract's openapi/v1.yaml, re-exported so consumers can name
10
+ // the wire types this client returns (and reach endpoints `DpdpGuardClient`
11
+ // deliberately doesn't wrap) instead of re-declaring them by hand. Mirrors
12
+ // dpdpguard-ios-sdk, which exposes its whole generated `DPDPGuardConsentAPI`
13
+ // target alongside the hand-written facade.
14
+ export type {
15
+ components,
16
+ operations,
17
+ paths,
18
+ } from './generated/api-types';
19
+
20
+ import type { components } from './generated/api-types';
21
+
22
+ export type OrgSummary = components['schemas']['OrgSummary'];
23
+ export type Notice = components['schemas']['Notice'];
24
+ export type DsrRequest = components['schemas']['DsrRequest'];
25
+ export type Grievance = components['schemas']['Grievance'];
26
+ export type Nomination = components['schemas']['Nomination'];
27
+ export type ApiError = components['schemas']['ApiError'];
28
+ /**
29
+ * The wire-level consent record from `/cm/v1/consent`. Distinct from this
30
+ * package's own {@link ConsentRecord}, which is the minimal shape
31
+ * {@link hasConsent} gates on.
32
+ */
33
+ export type ApiConsentRecord = components['schemas']['ConsentRecord'];