@dpdpguard/react-native 0.0.0 → 1.0.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.
Files changed (67) hide show
  1. package/README.md +26 -8
  2. package/package.json +18 -28
  3. package/src/client.ts +27 -0
  4. package/src/{index.tsx → index.ts} +0 -2
  5. package/.github/workflows/ci.yml +0 -15
  6. package/ReactNative.podspec +0 -20
  7. package/android/build.gradle +0 -51
  8. package/android/src/main/AndroidManifest.xml +0 -2
  9. package/android/src/main/java/com/dpdpguard/reactnative/ReactNativeModule.kt +0 -15
  10. package/android/src/main/java/com/dpdpguard/reactnative/ReactNativePackage.kt +0 -31
  11. package/example/.bundle/config +0 -2
  12. package/example/.watchmanconfig +0 -1
  13. package/example/Gemfile +0 -17
  14. package/example/README.md +0 -97
  15. package/example/android/app/build.gradle +0 -119
  16. package/example/android/app/debug.keystore +0 -0
  17. package/example/android/app/proguard-rules.pro +0 -10
  18. package/example/android/app/src/main/AndroidManifest.xml +0 -27
  19. package/example/android/app/src/main/java/com/dpdpguard.reactnative.example/MainActivity.kt +0 -22
  20. package/example/android/app/src/main/java/com/dpdpguard.reactnative.example/MainApplication.kt +0 -27
  21. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -37
  22. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  23. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  24. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  25. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  26. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  27. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  28. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  29. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  30. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  31. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  32. package/example/android/app/src/main/res/values/strings.xml +0 -3
  33. package/example/android/app/src/main/res/values/styles.xml +0 -9
  34. package/example/android/build.gradle +0 -21
  35. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  36. package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -7
  37. package/example/android/gradle.properties +0 -44
  38. package/example/android/gradlew +0 -248
  39. package/example/android/gradlew.bat +0 -98
  40. package/example/android/settings.gradle +0 -6
  41. package/example/app.json +0 -4
  42. package/example/babel.config.js +0 -12
  43. package/example/index.js +0 -5
  44. package/example/ios/.xcode.env +0 -11
  45. package/example/ios/Podfile +0 -34
  46. package/example/ios/ReactNativeExample/AppDelegate.swift +0 -48
  47. package/example/ios/ReactNativeExample/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
  48. package/example/ios/ReactNativeExample/Images.xcassets/Contents.json +0 -6
  49. package/example/ios/ReactNativeExample/Info.plist +0 -59
  50. package/example/ios/ReactNativeExample/LaunchScreen.storyboard +0 -47
  51. package/example/ios/ReactNativeExample/PrivacyInfo.xcprivacy +0 -37
  52. package/example/ios/ReactNativeExample.xcodeproj/project.pbxproj +0 -475
  53. package/example/ios/ReactNativeExample.xcodeproj/xcshareddata/xcschemes/ReactNativeExample.xcscheme +0 -88
  54. package/example/jest.config.js +0 -3
  55. package/example/metro.config.js +0 -11
  56. package/example/package.json +0 -34
  57. package/example/react-native.config.js +0 -21
  58. package/ios/ReactNative.h +0 -5
  59. package/ios/ReactNative.mm +0 -21
  60. package/jest.config.js +0 -6
  61. package/src/NativeReactNative.ts +0 -7
  62. package/src/client.test.ts +0 -119
  63. package/src/consentGate.test.ts +0 -17
  64. package/src/errorCatalog.test.ts +0 -19
  65. package/src/multiply.native.tsx +0 -5
  66. package/src/multiply.tsx +0 -3
  67. package/tsconfig.json +0 -18
@@ -1,88 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Scheme
3
- LastUpgradeVersion = "1210"
4
- version = "1.3">
5
- <BuildAction
6
- parallelizeBuildables = "YES"
7
- buildImplicitDependencies = "YES">
8
- <BuildActionEntries>
9
- <BuildActionEntry
10
- buildForTesting = "YES"
11
- buildForRunning = "YES"
12
- buildForProfiling = "YES"
13
- buildForArchiving = "YES"
14
- buildForAnalyzing = "YES">
15
- <BuildableReference
16
- BuildableIdentifier = "primary"
17
- BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
18
- BuildableName = "ReactNativeExample.app"
19
- BlueprintName = "ReactNativeExample"
20
- ReferencedContainer = "container:ReactNativeExample.xcodeproj">
21
- </BuildableReference>
22
- </BuildActionEntry>
23
- </BuildActionEntries>
24
- </BuildAction>
25
- <TestAction
26
- buildConfiguration = "Debug"
27
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29
- shouldUseLaunchSchemeArgsEnv = "YES">
30
- <Testables>
31
- <TestableReference
32
- skipped = "NO">
33
- <BuildableReference
34
- BuildableIdentifier = "primary"
35
- BlueprintIdentifier = "00E356ED1AD99517003FC87E"
36
- BuildableName = "ReactNativeExampleTests.xctest"
37
- BlueprintName = "ReactNativeExampleTests"
38
- ReferencedContainer = "container:ReactNativeExample.xcodeproj">
39
- </BuildableReference>
40
- </TestableReference>
41
- </Testables>
42
- </TestAction>
43
- <LaunchAction
44
- buildConfiguration = "Debug"
45
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
46
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
47
- launchStyle = "0"
48
- useCustomWorkingDirectory = "NO"
49
- ignoresPersistentStateOnLaunch = "NO"
50
- debugDocumentVersioning = "YES"
51
- debugServiceExtension = "internal"
52
- allowLocationSimulation = "YES">
53
- <BuildableProductRunnable
54
- runnableDebuggingMode = "0">
55
- <BuildableReference
56
- BuildableIdentifier = "primary"
57
- BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
58
- BuildableName = "ReactNativeExample.app"
59
- BlueprintName = "ReactNativeExample"
60
- ReferencedContainer = "container:ReactNativeExample.xcodeproj">
61
- </BuildableReference>
62
- </BuildableProductRunnable>
63
- </LaunchAction>
64
- <ProfileAction
65
- buildConfiguration = "Release"
66
- shouldUseLaunchSchemeArgsEnv = "YES"
67
- savedToolIdentifier = ""
68
- useCustomWorkingDirectory = "NO"
69
- debugDocumentVersioning = "YES">
70
- <BuildableProductRunnable
71
- runnableDebuggingMode = "0">
72
- <BuildableReference
73
- BuildableIdentifier = "primary"
74
- BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
75
- BuildableName = "ReactNativeExample.app"
76
- BlueprintName = "ReactNativeExample"
77
- ReferencedContainer = "container:ReactNativeExample.xcodeproj">
78
- </BuildableReference>
79
- </BuildableProductRunnable>
80
- </ProfileAction>
81
- <AnalyzeAction
82
- buildConfiguration = "Debug">
83
- </AnalyzeAction>
84
- <ArchiveAction
85
- buildConfiguration = "Release"
86
- revealArchiveInOrganizer = "YES">
87
- </ArchiveAction>
88
- </Scheme>
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- preset: '@react-native/jest-preset',
3
- };
@@ -1,11 +0,0 @@
1
- const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
2
-
3
- /**
4
- * Metro configuration
5
- * https://reactnative.dev/docs/metro
6
- *
7
- * @type {import('@react-native/metro-config').MetroConfig}
8
- */
9
- const config = {};
10
-
11
- module.exports = mergeConfig(getDefaultConfig(__dirname), config);
@@ -1,34 +0,0 @@
1
- {
2
- "name": "@dpdpguard/react-native-example",
3
- "version": "0.0.1",
4
- "private": true,
5
- "scripts": {
6
- "android": "react-native run-android",
7
- "ios": "react-native run-ios",
8
- "start": "react-native start",
9
- "build:android": "react-native build-android --extra-params \"--no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a\"",
10
- "build:ios": "react-native build-ios --mode Debug"
11
- },
12
- "dependencies": {
13
- "react": "19.2.3",
14
- "react-native": "0.85.0"
15
- },
16
- "devDependencies": {
17
- "@babel/core": "^7.25.2",
18
- "@babel/preset-env": "^7.25.3",
19
- "@babel/runtime": "^7.25.0",
20
- "@react-native-community/cli": "20.1.0",
21
- "@react-native-community/cli-platform-android": "20.1.0",
22
- "@react-native-community/cli-platform-ios": "20.1.0",
23
- "@react-native/babel-preset": "0.85.0",
24
- "@react-native/jest-preset": "0.85.0",
25
- "@react-native/metro-config": "0.85.0",
26
- "@react-native/typescript-config": "0.85.0",
27
- "@types/react": "^19.2.0",
28
- "react-native-builder-bob": "^0.41.0",
29
- "react-native-monorepo-config": "^0.4.0"
30
- },
31
- "engines": {
32
- "node": ">= 22.11.0"
33
- }
34
- }
@@ -1,21 +0,0 @@
1
- const path = require('path');
2
- const pkg = require('../package.json');
3
-
4
- module.exports = {
5
- project: {
6
- ios: {
7
- automaticPodsInstallation: true,
8
- },
9
- },
10
- dependencies: {
11
- [pkg.name]: {
12
- root: path.join(__dirname, '..'),
13
- platforms: {
14
- // Codegen script incorrectly fails without this
15
- // So we explicitly specify the platforms with empty object
16
- ios: {},
17
- android: {},
18
- },
19
- },
20
- },
21
- };
package/ios/ReactNative.h DELETED
@@ -1,5 +0,0 @@
1
- #import <ReactNativeSpec/ReactNativeSpec.h>
2
-
3
- @interface ReactNative : NSObject <NativeReactNativeSpec>
4
-
5
- @end
@@ -1,21 +0,0 @@
1
- #import "ReactNative.h"
2
-
3
- @implementation ReactNative
4
- - (NSNumber *)multiply:(double)a b:(double)b {
5
- NSNumber *result = @(a * b);
6
-
7
- return result;
8
- }
9
-
10
- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
11
- (const facebook::react::ObjCTurboModule::InitParams &)params
12
- {
13
- return std::make_shared<facebook::react::NativeReactNativeSpecJSI>(params);
14
- }
15
-
16
- + (NSString *)moduleName
17
- {
18
- return @"ReactNative";
19
- }
20
-
21
- @end
package/jest.config.js DELETED
@@ -1,6 +0,0 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- module.exports = {
3
- preset: 'ts-jest',
4
- testEnvironment: 'node',
5
- testMatch: ['<rootDir>/src/**/*.test.ts'],
6
- };
@@ -1,7 +0,0 @@
1
- import { TurboModuleRegistry, type TurboModule } from 'react-native';
2
-
3
- export interface Spec extends TurboModule {
4
- multiply(a: number, b: number): number;
5
- }
6
-
7
- export default TurboModuleRegistry.getEnforcing<Spec>('ReactNative');
@@ -1,119 +0,0 @@
1
- import { DpdpGuardClient } from "./client";
2
- import { DpdpGuardApiError } from "./errorCatalog";
3
-
4
- function jsonResponse(status: number, body: unknown): Response {
5
- return new Response(JSON.stringify(body), {
6
- status,
7
- headers: { "Content-Type": "application/json" },
8
- });
9
- }
10
-
11
- describe("DpdpGuardClient", () => {
12
- test("getOrganization calls the public endpoint with no Authorization header", async () => {
13
- const fetchImpl = jest
14
- .fn()
15
- .mockResolvedValue(
16
- jsonResponse(200, { orgId: "org_1", name: "Acme", slug: "acme" }),
17
- );
18
- const client = new DpdpGuardClient({
19
- baseUrl: "https://example.convex.site",
20
- fetchImpl,
21
- });
22
-
23
- const org = await client.getOrganization("acme");
24
-
25
- expect(org).toEqual({ orgId: "org_1", name: "Acme", slug: "acme" });
26
- const [url, init] = fetchImpl.mock.calls[0];
27
- expect(url).toBe("https://example.convex.site/api/v1/org/acme");
28
- expect(init.headers.Authorization).toBeUndefined();
29
- });
30
-
31
- test("an authenticated call without setAccessToken() throws before hitting the network", async () => {
32
- const fetchImpl = jest.fn();
33
- const client = new DpdpGuardClient({
34
- baseUrl: "https://example.convex.site",
35
- fetchImpl,
36
- });
37
-
38
- await expect(client.listDsrRequests()).rejects.toThrow(/access token/i);
39
- expect(fetchImpl).not.toHaveBeenCalled();
40
- });
41
-
42
- test("setAccessToken() makes subsequent authenticated calls use the new token", async () => {
43
- const fetchImpl = jest.fn().mockResolvedValue(jsonResponse(200, { requests: [] }));
44
- const client = new DpdpGuardClient({
45
- baseUrl: "https://example.convex.site",
46
- fetchImpl,
47
- });
48
-
49
- client.setAccessToken("token-from-my-backend");
50
- await client.listDsrRequests();
51
-
52
- const [, init] = fetchImpl.mock.calls[0];
53
- expect(init.headers.Authorization).toBe("Bearer token-from-my-backend");
54
- });
55
-
56
- test("a constructor-supplied accessToken is used immediately", async () => {
57
- const fetchImpl = jest.fn().mockResolvedValue(jsonResponse(200, { requests: [] }));
58
- const client = new DpdpGuardClient({
59
- baseUrl: "https://example.convex.site",
60
- accessToken: "initial-token",
61
- fetchImpl,
62
- });
63
-
64
- await client.listDsrRequests();
65
-
66
- const [, init] = fetchImpl.mock.calls[0];
67
- expect(init.headers.Authorization).toBe("Bearer initial-token");
68
- });
69
-
70
- test("a non-2xx response is thrown as a typed DpdpGuardApiError", async () => {
71
- const fetchImpl = jest
72
- .fn()
73
- .mockImplementation(() =>
74
- Promise.resolve(
75
- jsonResponse(404, { code: "NOT_FOUND", error: "No such organization" }),
76
- ),
77
- );
78
- const client = new DpdpGuardClient({
79
- baseUrl: "https://example.convex.site",
80
- fetchImpl,
81
- });
82
-
83
- await expect(client.getOrganization("missing")).rejects.toMatchObject({
84
- code: "NOT_FOUND",
85
- status: 404,
86
- });
87
- await expect(client.getOrganization("missing")).rejects.toBeInstanceOf(
88
- DpdpGuardApiError,
89
- );
90
- });
91
-
92
- test("createDsrRequest forwards an Idempotency-Key header when provided", async () => {
93
- const fetchImpl = jest.fn().mockResolvedValue(
94
- jsonResponse(201, {
95
- _id: "dsr_1",
96
- organizationId: "org_1",
97
- type: "erasure",
98
- }),
99
- );
100
- const client = new DpdpGuardClient({
101
- baseUrl: "https://example.convex.site",
102
- accessToken: "token-abc",
103
- fetchImpl,
104
- });
105
-
106
- await client.createDsrRequest(
107
- { organizationId: "org_1", type: "erasure" },
108
- "idem-key-1",
109
- );
110
-
111
- const [, init] = fetchImpl.mock.calls[0];
112
- expect(init.headers["Idempotency-Key"]).toBe("idem-key-1");
113
- });
114
-
115
- test("has no brokerToken method — mobile apps must never hold the service API key", () => {
116
- const client = new DpdpGuardClient({ baseUrl: "https://example.convex.site" });
117
- expect((client as unknown as Record<string, unknown>).brokerToken).toBeUndefined();
118
- });
119
- });
@@ -1,17 +0,0 @@
1
- import { hasConsent } from "./consentGate";
2
-
3
- describe("hasConsent", () => {
4
- test("true when a matching purpose has no withdrawnAt", () => {
5
- expect(hasConsent([{ purpose: "Analytics" }], "Analytics")).toBe(true);
6
- });
7
-
8
- test("false when the matching purpose was withdrawn", () => {
9
- expect(
10
- hasConsent([{ purpose: "Analytics", withdrawnAt: 123 }], "Analytics"),
11
- ).toBe(false);
12
- });
13
-
14
- test("false when no record matches the purpose", () => {
15
- expect(hasConsent([{ purpose: "Marketing" }], "Analytics")).toBe(false);
16
- });
17
- });
@@ -1,19 +0,0 @@
1
- import { ERROR_CATALOG } from "./errorCatalog";
2
-
3
- describe("ERROR_CATALOG", () => {
4
- test("loads all 10 codes from the installed @dpdpguard/contract package", () => {
5
- const codes = ERROR_CATALOG.map((entry) => entry.code);
6
- expect(codes).toEqual([
7
- "MINOR_TRACKING_BLOCKED",
8
- "NOTICE_NOT_PUBLISHED",
9
- "ALREADY_CONSENTED",
10
- "NOT_ASSOCIATED_WITH_ORG",
11
- "INVALID_STATUS_TRANSITION",
12
- "SDK_VERSION_UNSUPPORTED",
13
- "NOT_FOUND",
14
- "UNAUTHORIZED",
15
- "RATE_LIMITED",
16
- "VALIDATION_ERROR",
17
- ]);
18
- });
19
- });
@@ -1,5 +0,0 @@
1
- import ReactNative from './NativeReactNative';
2
-
3
- export function multiply(a: number, b: number): number {
4
- return ReactNative.multiply(a, b);
5
- }
package/src/multiply.tsx DELETED
@@ -1,3 +0,0 @@
1
- export function multiply(a: number, b: number): number {
2
- return a * b;
3
- }
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2020",
4
- "module": "commonjs",
5
- "moduleResolution": "node",
6
- "lib": ["es2020"],
7
- "jsx": "react-native",
8
- "strict": true,
9
- "resolveJsonModule": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "declaration": true,
13
- "outDir": "lib",
14
- "rootDir": "src"
15
- },
16
- "include": ["src"],
17
- "exclude": ["src/**/*.test.ts", "src/generated", "lib"]
18
- }