@fingerly/lynx 0.1.0 → 0.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
@@ -20,7 +20,7 @@ The host app must enable [Lynx Native Library Autolink](https://lynxjs.org/guide
20
20
  `plugin 'cocoapods-lynx-library'` and `use_lynx_library!` to the Podfile, run
21
21
  `pod install`, then rebuild.
22
22
 
23
- The Android module depends on `io.fingerly:fingerly:0.1.0` from Fingerly's Maven
23
+ The Android module depends on `io.fingerly:fingerly:0.2.0` from Fingerly's Maven
24
24
  repository and declares no repositories of its own, so Android hosts add it to
25
25
  the repositories in `settings.gradle`:
26
26
 
@@ -28,10 +28,6 @@ the repositories in `settings.gradle`:
28
28
  maven { url 'https://maven.fingerly.io' }
29
29
  ```
30
30
 
31
- That repository is not live yet; see
32
- [Native SDK development dependencies](#native-sdk-development-dependencies) for
33
- the local route until it is.
34
-
35
31
  This bridge is licensed under Apache-2.0. The native SDK it depends on is a
36
32
  closed binary under the Fingerly SDK License.
37
33
 
@@ -168,6 +164,54 @@ no entry for the native SDK. The same binary is published as a Swift package at
168
164
  On Android, the module resolves `io.fingerly:fingerly` from
169
165
  `https://maven.fingerly.io`, added to the host's repositories as shown above.
170
166
 
167
+ **Installed-app checks are opt-in on Android.** From the Android SDK release
168
+ after 0.1.0, the checks for root managers, hooking frameworks and app cloners by
169
+ package name ship in a separate artifact, `io.fingerly:fingerly-app-checks`,
170
+ because Google Play treats the list of installed apps as personal and sensitive
171
+ data. This bridge depends on `io.fingerly:fingerly` only. If your app can
172
+ justify the package visibility in its Play review and wants these checks, add
173
+ the artifact to your app's Android module, at the same version as
174
+ `io.fingerly:fingerly`, and declare "App activity: Installed apps" in the Data
175
+ safety form:
176
+
177
+ ```kotlin
178
+ dependencies {
179
+ implementation("io.fingerly:fingerly-app-checks:<same version as io.fingerly:fingerly>")
180
+ }
181
+ ```
182
+
183
+ Without it, the report carries no installed-app fields and nothing about other
184
+ apps leaves the device; whether the app itself runs inside a cloner is still
185
+ reported.
186
+
187
+ **Play Integrity (Android, optional).** The Android SDK has an optional
188
+ artifact, `io.fingerly:fingerly-play-integrity` (server ADR 0026), that adds
189
+ Google Play Integrity verdicts to events. To use it, add the artifact to the
190
+ app and pass your Google Cloud project number, the one linked to the app in
191
+ Play Console, to `load`:
192
+
193
+ ```kotlin
194
+ // the app module's build.gradle.kts
195
+ dependencies {
196
+ implementation("io.fingerly:fingerly-play-integrity:<same version as io.fingerly:fingerly>")
197
+ }
198
+ ```
199
+
200
+ ```ts
201
+ const fingerly = await load({
202
+ apiKey: 'fly_pk_production_…',
203
+ playIntegrityCloudProjectNumber: 123456789012,
204
+ })
205
+ ```
206
+
207
+ The native SDK finds the artifact on its own; this bridge does not depend on
208
+ it. Without the artifact the number is ignored and nothing fails, and on iOS it
209
+ is ignored. The rest of the setup (the service account uploaded to your
210
+ Fingerly project, the daily budget) is in the Android SDK's
211
+ `fingerly-play-integrity/README.md`. This needs the Android SDK
212
+ release after 0.1.0, the first whose `FingerlyBridge.configure` takes a project
213
+ number; Gradle refuses to pair the artifact with a core of another version.
214
+
171
215
  ## Development
172
216
 
173
217
  Clone recursively so `@fingerly/types` is available:
@@ -21,5 +21,5 @@ dependencies {
21
21
  implementation("org.lynxsdk.lynx:lynx:4.1.0")
22
22
  implementation("org.lynxsdk.lynx:service-api:4.1.0")
23
23
  annotationProcessor("org.lynxsdk.lynx:lynx-processor:4.1.0")
24
- implementation("io.fingerly:fingerly:0.1.0")
24
+ implementation("io.fingerly:fingerly:0.2.0")
25
25
  }
@@ -24,10 +24,20 @@ public final class Fingerly extends FingerlySpec {
24
24
 
25
25
  @Override
26
26
  @LynxMethod
27
- public void configure(String apiKey, String endpoint, String platform, String consent) {
27
+ public void configure(
28
+ String apiKey,
29
+ String endpoint,
30
+ String platform,
31
+ String consent,
32
+ double playIntegrityCloudProjectNumber) {
28
33
  // `src/index.ts` always sends a consent, `pending` when the app passed none,
29
34
  // so the state is set rather than left as it was.
30
- FingerlyBridge.configure(applicationContext, apiKey, endpoint, platform, consent);
35
+ //
36
+ // The project number is 0 when the app passed none. The Android SDK builds
37
+ // the Play Integrity provider from the optional fingerly-play-integrity
38
+ // artifact when the app has it, and ignores the number when it does not.
39
+ FingerlyBridge.configure(
40
+ applicationContext, apiKey, endpoint, platform, consent, (long) playIntegrityCloudProjectNumber);
31
41
  }
32
42
 
33
43
  @Override
@@ -12,7 +12,7 @@ public abstract class FingerlySpec extends LynxContextModule {
12
12
  }
13
13
 
14
14
  @LynxMethod
15
- public abstract void configure(String apiKey, String endpoint, String platform, String consent);
15
+ public abstract void configure(String apiKey, String endpoint, String platform, String consent, double playIntegrityCloudProjectNumber);
16
16
 
17
17
  @LynxMethod
18
18
  public abstract void setConsent(String state);
@@ -3,7 +3,7 @@
3
3
  const ADDON_NAME = "Fingerly";
4
4
 
5
5
  export interface FingerlySpec {
6
- configure(apiKey: string, endpoint: string, platform: string, consent: string): void;
6
+ configure(apiKey: string, endpoint: string, platform: string, consent: string, playIntegrityCloudProjectNumber: number): void;
7
7
  setConsent(state: string): void;
8
8
  identify(tag: string | null, submit: boolean, automatic: boolean, success: (json: string) => void, failure: (error: string) => void): void;
9
9
  collect(success: (json: string) => void, failure: (error: string) => void): void;
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.1.0",
3
- "sha256": "c792d46d43ed21d67b7cca8731f616bfe1f7296a7a161ddaad1358b38ba096cf"
2
+ "version": "0.2.0",
3
+ "sha256": "af5be333b61f1e125fe8dbd9ce7ee32f616378bb62f5061c864e03dad7100ba5"
4
4
  }
@@ -9,7 +9,7 @@
9
9
 
10
10
  + (NSDictionary<NSString *, NSString *> *)methodLookup {
11
11
  return @{
12
- @"configure" : NSStringFromSelector(@selector(configure:endpoint:platform:consent:)),
12
+ @"configure" : NSStringFromSelector(@selector(configure:endpoint:platform:consent:playIntegrityCloudProjectNumber:)),
13
13
  @"setConsent" : NSStringFromSelector(@selector(setConsent:)),
14
14
  @"identify" : NSStringFromSelector(@selector(identify:submit:automatic:success:failure:)),
15
15
  @"collect" : NSStringFromSelector(@selector(collect:failure:)),
@@ -19,11 +19,13 @@
19
19
  }
20
20
 
21
21
  - (void)configure:(NSString *)apiKey
22
- endpoint:(NSString *)endpoint
23
- platform:(NSString *)platform
24
- consent:(NSString *)consent {
22
+ endpoint:(NSString *)endpoint
23
+ platform:(NSString *)platform
24
+ consent:(NSString *)consent
25
+ playIntegrityCloudProjectNumber:(double)playIntegrityCloudProjectNumber {
25
26
  // `src/index.ts` always sends a consent, `pending` when the app passed none.
26
27
  // The native bridge reads anything it does not recognise as `pending`.
28
+ // The Play Integrity project number is Android only and not read here.
27
29
  [FingerlyBridge configureWithApiKey:apiKey endpoint:endpoint platform:platform consent:consent];
28
30
  }
29
31
 
@@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN
6
6
 
7
7
  @protocol FingerlySpec <LynxModule>
8
8
 
9
- - (void)configure:(NSString *)apiKey endpoint:(NSString *)endpoint platform:(NSString *)platform consent:(NSString *)consent;
9
+ - (void)configure:(NSString *)apiKey endpoint:(NSString *)endpoint platform:(NSString *)platform consent:(NSString *)consent playIntegrityCloudProjectNumber:(double)playIntegrityCloudProjectNumber;
10
10
  - (void)setConsent:(NSString *)state;
11
11
  - (void)identify:(nullable NSString *)tag submit:(BOOL)submit automatic:(BOOL)automatic success:(id)success failure:(id)failure;
12
12
  - (void)collect:(id)success failure:(id)failure;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fingerly/lynx",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -28,7 +28,7 @@
28
28
  "README.md"
29
29
  ],
30
30
  "dependencies": {
31
- "@fingerly/types": "0.1.1"
31
+ "@fingerly/types": "0.1.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@lynx-js/autolink-codegen": "0.6.0",
package/src/index.ts CHANGED
@@ -13,7 +13,13 @@ import type {
13
13
  declare const SystemInfo: { platform?: string } | undefined
14
14
 
15
15
  interface FingerlyNativeModule {
16
- configure(apiKey: string, endpoint: string, platform: string, consent: ConsentState): void
16
+ configure(
17
+ apiKey: string,
18
+ endpoint: string,
19
+ platform: string,
20
+ consent: ConsentState,
21
+ playIntegrityCloudProjectNumber: number,
22
+ ): void
17
23
  setConsent(state: ConsentState): void
18
24
  identify(
19
25
  tag: string | null,
@@ -44,6 +50,15 @@ export interface FingerlyOptions extends MobileFingerlyOptions {
44
50
  * where another lawful basis applies.
45
51
  */
46
52
  consent?: ConsentState
53
+ /**
54
+ * Android only: your Google Cloud project number, the one linked to the app
55
+ * in Play Console, to add Play Integrity verdicts to events (server ADR
56
+ * 0026). It takes effect only when the app also depends on the optional
57
+ * `io.fingerly:fingerly-play-integrity` artifact; without it the number is
58
+ * ignored and nothing fails. Ignored on iOS. Omit it to leave Play
59
+ * Integrity off.
60
+ */
61
+ playIntegrityCloudProjectNumber?: number
47
62
  }
48
63
 
49
64
  export interface IdentifyOptions extends MobileIdentifyOptions {
@@ -120,6 +135,20 @@ function assertConsentState(state: unknown): asserts state is ConsentState {
120
135
  }
121
136
  }
122
137
 
138
+ /**
139
+ * A Google Cloud project number is a positive whole number. Anything else is a
140
+ * typo the app should hear about at `load`, not a Play Integrity setup that
141
+ * silently does nothing.
142
+ */
143
+ function assertCloudProjectNumber(value: unknown): asserts value is number | undefined {
144
+ if (value === undefined) return
145
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value <= 0) {
146
+ throw new TypeError(
147
+ `Fingerly playIntegrityCloudProjectNumber must be a positive whole number (received ${JSON.stringify(value)})`,
148
+ )
149
+ }
150
+ }
151
+
123
152
  /**
124
153
  * The state behind a native `consent_required` failure. iOS sends it as
125
154
  * `state`; Android sends only the message, which ends with it in a fixed form.
@@ -245,8 +274,8 @@ function isRecord(value: unknown): value is Record<string, unknown> {
245
274
  }
246
275
 
247
276
  // Named rather than spread, so what reaches the app is what the server said and
248
- // nothing else: a signal name or a conclusion from an older native build is
249
- // left behind here even if the native side still sends one.
277
+ // nothing else: a signal name, a conclusion or an unscored reason in the native
278
+ // JSON is left behind here.
250
279
  const SERVER_FIELDS = [
251
280
  'requestId',
252
281
  'visitorId',
@@ -255,7 +284,6 @@ const SERVER_FIELDS = [
255
284
  'identifiable',
256
285
  'duplicate',
257
286
  'state',
258
- 'reason',
259
287
  'suspectScore',
260
288
  'suspectLevel',
261
289
  'report',
@@ -356,10 +384,13 @@ export class FingerlyClient {
356
384
  export async function load(options: FingerlyOptions): Promise<FingerlyClient> {
357
385
  const consent = options.consent ?? 'pending'
358
386
  assertConsentState(consent)
387
+ const playIntegrity = options.playIntegrityCloudProjectNumber
388
+ assertCloudProjectNumber(playIntegrity)
359
389
 
360
390
  const native = nativeModule()
361
391
  try {
362
- native.configure(options.apiKey, options.endpoint ?? '', platformName(), consent)
392
+ // 0 means no Play Integrity; the iOS module accepts the argument and ignores it.
393
+ native.configure(options.apiKey, options.endpoint ?? '', platformName(), consent, playIntegrity ?? 0)
363
394
  } catch (error) {
364
395
  throw parseNativeError(error)
365
396
  }
@@ -1,6 +1,6 @@
1
1
  /** @lynxmodule */
2
2
  export declare class Fingerly {
3
- configure(apiKey: string, endpoint: string, platform: string, consent: string): void;
3
+ configure(apiKey: string, endpoint: string, platform: string, consent: string, playIntegrityCloudProjectNumber: number): void;
4
4
  setConsent(state: string): void;
5
5
  identify(tag: string | null, submit: boolean, automatic: boolean, success: (json: string) => void, failure: (error: string) => void): void;
6
6
  collect(success: (json: string) => void, failure: (error: string) => void): void;