@fountispanel/connect-react-native 0.0.0-stage → 1.1.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 (60) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +24 -0
  3. package/README.md +92 -2
  4. package/android/build.gradle +37 -0
  5. package/android/connect-sdk/main/assets/fountis-connect/engine.html +47 -0
  6. package/android/connect-sdk/main/assets/fountis-connect/i18n/ar.json +70 -0
  7. package/android/connect-sdk/main/assets/fountis-connect/i18n/en.json +70 -0
  8. package/android/connect-sdk/main/assets/fountis-connect/i18n/kmr.json +70 -0
  9. package/android/connect-sdk/main/assets/fountis-connect/i18n/ku.json +70 -0
  10. package/android/connect-sdk/main/kotlin/org/fountis/connect/ApiClient.kt +179 -0
  11. package/android/connect-sdk/main/kotlin/org/fountis/connect/Attest.kt +234 -0
  12. package/android/connect-sdk/main/kotlin/org/fountis/connect/FountisConnect.kt +641 -0
  13. package/android/connect-sdk/main/kotlin/org/fountis/connect/FountisSurveyActivity.kt +321 -0
  14. package/android/connect-sdk/main/kotlin/org/fountis/connect/LocalState.kt +143 -0
  15. package/android/connect-sdk/main/kotlin/org/fountis/connect/Matcher.kt +167 -0
  16. package/android/connect-sdk/main/kotlin/org/fountis/connect/Models.kt +144 -0
  17. package/android/connect-sdk/main/kotlin/org/fountis/connect/Notifier.kt +109 -0
  18. package/android/connect-sdk/main/kotlin/org/fountis/connect/PlayIntegrityAttestor.kt +70 -0
  19. package/android/connect-sdk/main/kotlin/org/fountis/connect/RequestDeadline.kt +74 -0
  20. package/android/connect-sdk/main/kotlin/org/fountis/connect/Strings.kt +45 -0
  21. package/android/connect-sdk/main/kotlin/org/fountis/connect/TokenProviderCall.kt +72 -0
  22. package/android/connect-sdk/main/res/drawable/fountis_ic_notification.xml +12 -0
  23. package/android/connect-sdk/main/res/values/fountis_styles.xml +13 -0
  24. package/android/connect-sdk/main/res/values-v27/fountis_styles.xml +12 -0
  25. package/android/src/main/AndroidManifest.xml +18 -0
  26. package/android/src/main/java/org/fountis/connect/rn/FountisConnectModule.kt +113 -0
  27. package/app.plugin.js +41 -0
  28. package/build/index.d.ts +34 -0
  29. package/build/index.js +126 -0
  30. package/build/index.web.d.ts +22 -0
  31. package/build/index.web.js +57 -0
  32. package/build/types.d.ts +23 -0
  33. package/build/types.js +1 -0
  34. package/expo-module.config.json +10 -0
  35. package/ios/FountisConnectAppDelegateSubscriber.swift +16 -0
  36. package/ios/FountisConnectBundle.swift +15 -0
  37. package/ios/FountisConnectModule.swift +131 -0
  38. package/ios/FountisConnectReactNative.podspec +35 -0
  39. package/ios/FountisConnectSDK/ApiClient.swift +137 -0
  40. package/ios/FountisConnectSDK/Attestation.swift +276 -0
  41. package/ios/FountisConnectSDK/Engine/engine.html +47 -0
  42. package/ios/FountisConnectSDK/Engine/i18n/ar.json +70 -0
  43. package/ios/FountisConnectSDK/Engine/i18n/en.json +70 -0
  44. package/ios/FountisConnectSDK/Engine/i18n/kmr.json +70 -0
  45. package/ios/FountisConnectSDK/Engine/i18n/ku.json +70 -0
  46. package/ios/FountisConnectSDK/FountisConnect.swift +441 -0
  47. package/ios/FountisConnectSDK/LocalState.swift +81 -0
  48. package/ios/FountisConnectSDK/Matcher.swift +102 -0
  49. package/ios/FountisConnectSDK/Models.swift +133 -0
  50. package/ios/FountisConnectSDK/Notifier.swift +63 -0
  51. package/ios/FountisConnectSDK/PrivacyInfo.xcprivacy +23 -0
  52. package/ios/FountisConnectSDK/RequestDeadline.swift +93 -0
  53. package/ios/FountisConnectSDK/SheetController.swift +259 -0
  54. package/ios/FountisConnectSDK/Strings.swift +34 -0
  55. package/ios/FountisConnectSDK/TokenProviderCall.swift +91 -0
  56. package/package.json +67 -4
  57. package/scripts/vendor-native.sh +16 -0
  58. package/src/index.ts +142 -0
  59. package/src/index.web.ts +64 -0
  60. package/src/types.ts +26 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 1.1.0 — 2026-10-19
4
+
5
+ - Android: guest device check with Google Play Integrity when FOUNTIS asks for it for your app (see the Android SDK changelog). The Android build now depends on `com.google.android.play:integrity:1.6.0`. Link the FOUNTIS Google Cloud project to your app in Play Console (App integrity, Play Integrity API).
6
+ - iOS: guest device attestation with App Attest, from the bundled iOS SDK (see its changelog). If FOUNTIS asks for it on your guests, add the App Attest capability to the iOS app (entitlement `com.apple.developer.devicecheck.appattest-environment`; in Expo `ios.entitlements`). Nothing changes when attestation is off.
7
+ - npm package renamed to `@fountispanel/connect-react-native`. Nothing else changes; install and import it under the new name.
8
+ - Android: every API request now has an overall 15 second deadline (connection, request and the whole response), the same as the Web SDK, so a server that keeps sending a few bytes cannot keep `show()` busy. The failure ends as `noFill` like any network error. This comes from the bundled Android SDK (see its changelog).
9
+ - Docs: the Android minimum now names Android System WebView 88 or later next to API 23 (on an older WebView `show()` returns `noFill`), and the README token example reads the `{ "token": "..." }` reply of the sample server, treating a reply without a token as a failure.
10
+ - On React Native Web, the Web SDK it wraps now gives the study screen its own close button and a load timeout (see the Web SDK changelog).
11
+ - iOS: every API request now ends after 15 s in total, including a slowly trickling response body (was 30 s); the call fails as `noFill`.
12
+ - The bundled survey engine now also closes on the Escape key (hardware keyboard), exactly like its x button (it asks first once something is answered).
13
+ - The bundled survey engine's "leave?" card (shown when the x is pressed after answering) now moves keyboard focus to Stay when it opens, keeps the screen behind it out of reach of Tab and screen readers (where the WebView supports `inert`), and puts focus back where it was when you stay.
14
+
15
+ ## 1.0.0
16
+
17
+ First stable release of `@fountispanel/connect-react-native`.
18
+
19
+ - Shows a short FOUNTIS study teaser to partner users who match, and runs the study inside the partner app or site.
20
+ - Matching happens on the device from partner-signed user attributes. People are never linked to a FOUNTIS panelist account.
21
+ - Public API with the same names on every platform: `start`, `setUserToken`, `enableNotifications`, `show`, `setUserConsent`, `signOut`, `onEvent`.
22
+ - Studies run in the bundled FOUNTIS survey engine, localized in English, Sorani Kurdish, Bahdini Kurdish and Arabic (right-to-left supported).
23
+ - Failures are silent: the SDK never throws into the host app and reports `noFill` instead.
24
+ - Sandbox keys (`pk_test_`) accept unsigned tokens so you can try the SDK before your server signs tokens.
25
+ - React Native and Expo (development builds, not Expo Go): wraps the native iOS and Android SDKs.
26
+ - Expo config plugin adds the iOS background mode and task id, and the publishable key.
27
+ - On React Native Web it wraps the Web SDK `@fountispanel/connect`.
28
+ - A token function that throws or rejects (on iOS and Android also one that does not answer within 10 seconds) now shows nothing (`noFill`) instead of being treated as signed out, so a signed-in person is never offered guest studies. Return `null` only when nobody is signed in.
29
+ - Background checks that run while JavaScript is not running now get no token answer and show nothing. Before, they timed out to `null` and could offer guest studies.
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ FOUNTIS Connect SDK License
2
+
3
+ Copyright (c) 2026 FOUNTIS. All rights reserved.
4
+
5
+ 1. Permission. You may download, install and use this software development kit
6
+ (the "SDK") only to integrate FOUNTIS Connect into your own app or website,
7
+ and only while you have a valid FOUNTIS Connect partner agreement with FOUNTIS.
8
+
9
+ 2. Restrictions. You may not sell, sublicense or redistribute the SDK on its own,
10
+ use it to build a competing product or service, or remove this notice. You may
11
+ ship the SDK inside your app or website as part of your integration.
12
+
13
+ 3. Ownership. FOUNTIS keeps all rights in the SDK not expressly granted here.
14
+
15
+ 4. End. These rights end when your partner agreement ends or when you breach this
16
+ license. You must then stop using the SDK in new releases of your app or website.
17
+
18
+ 5. No warranty. THE SDK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
+ OR IMPLIED, INCLUDING FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20
+
21
+ 6. Limitation of liability. TO THE EXTENT ALLOWED BY LAW, FOUNTIS IS NOT LIABLE FOR
22
+ ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM THE SDK OR ITS USE.
23
+
24
+ If your partner agreement sets different terms, the partner agreement prevails.
package/README.md CHANGED
@@ -1,3 +1,93 @@
1
- # Temporary Holding Version
1
+ # FOUNTIS Connect for React Native and Expo
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@fountispanel/connect-react-native` shows FOUNTIS studies to the people in your app. On iOS and Android it wraps the
4
+ native FOUNTIS Connect SDKs (the survey opens full screen, in native code). On React Native Web it wraps the Web SDK
5
+ `@fountispanel/connect`. The API has the same names everywhere.
6
+
7
+ It needs native code, so use an **Expo development build** (or a bare React Native app). It does **not** run in Expo Go.
8
+
9
+ Minimums: iOS 15.1, and on Android 6.0 (API 23) with Android System WebView 88 or later. On an older WebView `show()` returns `noFill`.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npx expo install @fountispanel/connect-react-native
15
+ ```
16
+
17
+ Add the config plugin to `app.json` (or `app.config.js`):
18
+
19
+ ```json
20
+ {
21
+ "expo": {
22
+ "plugins": [["@fountispanel/connect-react-native", { "key": "pk_live_..." }]]
23
+ }
24
+ }
25
+ ```
26
+
27
+ The plugin adds the iOS `fetch` background mode and the `org.fountis.connect.refresh` background task id, and writes
28
+ your publishable key (`pk_...`, safe to ship) so the SDK can start while the app launches. That early start is what
29
+ lets iOS run the background check. Then rebuild: `npx expo prebuild` and `npx expo run:ios` / `run:android`
30
+ (or a new EAS development build).
31
+
32
+ Bare React Native: run `npx pod-install`, and add the same two Info.plist entries yourself
33
+ (`UIBackgroundModes` = `fetch`, `BGTaskSchedulerPermittedIdentifiers` = `org.fountis.connect.refresh`).
34
+ Without them the SDK still works while the app is open; only the background check is off.
35
+
36
+ ## Use
37
+
38
+ ```ts
39
+ import * as Fountis from '@fountispanel/connect-react-native';
40
+
41
+ Fountis.start({ key: 'pk_live_...' }); // safe to call again; the plugin may already have started it
42
+ Fountis.setUserToken(async () => {
43
+ const r = await fetch('https://your-server.example/fountis/token', { credentials: 'include' });
44
+ if (r.status === 401) return null; // null only when nobody is signed in (here: your endpoint answers 401)
45
+ if (!r.ok) throw new Error('token request failed'); // a failed request is not "signed out": throw
46
+ const { token } = await r.json(); // your endpoint answers { "token": "..." } (see samples/server-node)
47
+ if (!token) throw new Error('no token in response'); // a reply without a token is a failure, not "signed out"
48
+ return token;
49
+ });
50
+ Fountis.enableNotifications(); // optional: one local notification a day at most
51
+
52
+ const result = await Fountis.show(); // 'noFill' | 'dismissed' | 'completed'
53
+ const off = Fountis.onEvent((e) => console.log(e.type, e.offerId)); // shown, dismissed, completed, noFill, notified
54
+ ```
55
+
56
+ | Call | What it does |
57
+ |---|---|
58
+ | `start({ key, apiBase? })` | Starts the SDK. `apiBase` is only for testing against another backend. |
59
+ | `setUserToken(fn)` | `fn` returns the token signed by **your server** (see `@fountispanel/connect-server`), or `null` when nobody is signed in, and throws when it cannot get a token. It is called when the SDK needs a token; it is not stored. |
60
+ | `enableNotifications()` | Turns on the background check and asks for the notification permission. |
61
+ | `show()` | Looks for a matching study and shows it. `noFill` comes back fast when there is none. |
62
+ | `handlePush(data)` | Call from your push handler. Resolves `true` if it was a FOUNTIS push (has a `fountis` key). |
63
+ | `setUserConsent(bool)` | Your own consent switch. Default `true`. |
64
+ | `signOut()` | Forgets the person on this device. |
65
+ | `onEvent(fn)` | Anonymous events, no titles or answers. Returns a function that removes the listener. |
66
+
67
+ Every failure is silent and becomes `noFill`. The SDK never throws into your app.
68
+
69
+ The token function has four outcomes:
70
+
71
+ - It returns a token: the person is signed in and sees the studies that match them.
72
+ - It returns `null` (or `undefined`): nobody is signed in. The SDK offers guest studies if your app allows guests.
73
+ - It throws or rejects: nothing is shown (`noFill`), and the person is never treated as a guest. No answer within 10 seconds also counts as a failure.
74
+ - An empty string is not "signed out": nothing is shown.
75
+
76
+ Notes:
77
+
78
+ - The token function runs in JavaScript. A background check that wakes the app without JavaScript running gets no answer
79
+ and does nothing; checks work while the app is open or recently used, and the study also appears on app open.
80
+ - **Guests:** when the token function returns `null` and FOUNTIS has switched guests on for your app (adult-only apps only), the SDK offers the free studies marked open to guests, after an 18+ confirmation. There is nothing to call; an app without accounts can pass `setUserToken(() => null)`. Guests never see a reward. If your token request fails, throw instead of returning `null`, so a signed-in person is not shown guest studies.
81
+ - **Android guest device check:** when FOUNTIS asks for it, an Android guest's device is checked with Google Play Integrity before the guest session starts. Link the FOUNTIS Google Cloud project to your app in Play Console (App integrity, Play Integrity API); FOUNTIS gives you the project number. Nothing to call, and signed-in users are not checked. See the Android SDK README.
82
+ - **Guest attestation (iOS):** if FOUNTIS asks for device attestation on your guests, add the App Attest capability to the iOS app (entitlement `com.apple.developer.devicecheck.appattest-environment` = `production`; in Expo set it under `ios.entitlements`). There is nothing to call.
83
+ - On the web, `enableNotifications()` turns on the in-page invitation, and `handlePush` always resolves `false`.
84
+ - `start` also takes `engineUrl` on the web, to point at another hosted engine.
85
+
86
+ ## In this repository
87
+
88
+ The native SDKs live in `../ios` and `../android`. The podspec copies the Swift sources into `ios/FountisConnectSDK`
89
+ when `pod install` runs (re-run it after changing the SDK), and `android/build.gradle` reads `../../android/connect`
90
+ in place. `npm pack` copies both into the package (`scripts/vendor-native.sh`), so the tarball is self-contained.
91
+
92
+ Sample app: `../samples/react-native` (`npm install && npx expo prebuild && npx expo run:ios`).
93
+ `npm run typecheck` checks the TypeScript.
@@ -0,0 +1,37 @@
1
+ plugins {
2
+ id 'com.android.library'
3
+ id 'expo-module-gradle-plugin'
4
+ }
5
+
6
+ group = 'org.fountis'
7
+ version = '1.1.0'
8
+
9
+ // In this repository the Kotlin SDK is next to this package. In the npm package, scripts/vendor-native.sh
10
+ // copies it to android/connect-sdk (run automatically on `npm pack`).
11
+ def inRepo = file('../../android/connect/src/main').exists()
12
+ def sdkMain = inRepo ? file('../../android/connect/src/main') : file('connect-sdk/main')
13
+
14
+ android {
15
+ // Same namespace as the SDK, so its R class (notification icon, styles) resolves unchanged.
16
+ namespace 'org.fountis.connect'
17
+ defaultConfig {
18
+ versionCode 1
19
+ versionName '1.1.0'
20
+ }
21
+ sourceSets {
22
+ main {
23
+ java.srcDirs += new File(sdkMain, 'kotlin')
24
+ res.srcDirs += new File(sdkMain, 'res')
25
+ assets.srcDirs += new File(sdkMain, 'assets')
26
+ }
27
+ }
28
+ }
29
+
30
+ dependencies {
31
+ implementation 'androidx.core:core-ktx:1.15.0'
32
+ implementation 'androidx.work:work-runtime-ktx:2.10.0'
33
+ implementation 'androidx.webkit:webkit:1.12.1'
34
+ implementation 'androidx.lifecycle:lifecycle-process:2.8.7'
35
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0'
36
+ implementation 'com.google.android.play:integrity:1.6.0'
37
+ }