@fingerly/lynx 0.0.0-stage → 0.1.1
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/LICENSE +202 -0
- package/README.md +183 -2
- package/android/build.gradle.kts +25 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +2 -0
- package/android/gradlew +251 -0
- package/android/gradlew.bat +94 -0
- package/android/settings.gradle.kts +21 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/io/fingerly/lynx/Fingerly.java +118 -0
- package/android/src/main/java/io/fingerly/lynx/generated/FingerlySpec.java +31 -0
- package/generated/Fingerly.ts +66 -0
- package/ios/fetch-fingerly-xcframework.sh +52 -0
- package/ios/fingerly-binary.json +4 -0
- package/ios/fingerly-lynx.podspec +36 -0
- package/ios/src/Fingerly.h +12 -0
- package/ios/src/Fingerly.m +119 -0
- package/ios/src/generated/FingerlySpec.h +18 -0
- package/ios/src/generated/FingerlySpec.m +2 -0
- package/lynx.lib.json +12 -0
- package/package.json +43 -3
- package/src/index.ts +409 -0
- package/types/index.d.ts +2 -0
- package/types/platform-native-module.d.ts +9 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@rem
|
|
2
|
+
@rem Copyright 2015 the original author or authors.
|
|
3
|
+
@rem
|
|
4
|
+
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
@rem you may not use this file except in compliance with the License.
|
|
6
|
+
@rem You may obtain a copy of the License at
|
|
7
|
+
@rem
|
|
8
|
+
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
@rem
|
|
10
|
+
@rem Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
@rem See the License for the specific language governing permissions and
|
|
14
|
+
@rem limitations under the License.
|
|
15
|
+
@rem
|
|
16
|
+
@rem SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
@rem
|
|
18
|
+
|
|
19
|
+
@if "%DEBUG%"=="" @echo off
|
|
20
|
+
@rem ##########################################################################
|
|
21
|
+
@rem
|
|
22
|
+
@rem Gradle startup script for Windows
|
|
23
|
+
@rem
|
|
24
|
+
@rem ##########################################################################
|
|
25
|
+
|
|
26
|
+
@rem Set local scope for the variables with windows NT shell
|
|
27
|
+
if "%OS%"=="Windows_NT" setlocal
|
|
28
|
+
|
|
29
|
+
set DIRNAME=%~dp0
|
|
30
|
+
if "%DIRNAME%"=="" set DIRNAME=.
|
|
31
|
+
@rem This is normally unused
|
|
32
|
+
set APP_BASE_NAME=%~n0
|
|
33
|
+
set APP_HOME=%DIRNAME%
|
|
34
|
+
|
|
35
|
+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
36
|
+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
37
|
+
|
|
38
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
39
|
+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
40
|
+
|
|
41
|
+
@rem Find java.exe
|
|
42
|
+
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
43
|
+
|
|
44
|
+
set JAVA_EXE=java.exe
|
|
45
|
+
%JAVA_EXE% -version >NUL 2>&1
|
|
46
|
+
if %ERRORLEVEL% equ 0 goto execute
|
|
47
|
+
|
|
48
|
+
echo. 1>&2
|
|
49
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
|
50
|
+
echo. 1>&2
|
|
51
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
52
|
+
echo location of your Java installation. 1>&2
|
|
53
|
+
|
|
54
|
+
goto fail
|
|
55
|
+
|
|
56
|
+
:findJavaFromJavaHome
|
|
57
|
+
set JAVA_HOME=%JAVA_HOME:"=%
|
|
58
|
+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
59
|
+
|
|
60
|
+
if exist "%JAVA_EXE%" goto execute
|
|
61
|
+
|
|
62
|
+
echo. 1>&2
|
|
63
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
|
64
|
+
echo. 1>&2
|
|
65
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
66
|
+
echo location of your Java installation. 1>&2
|
|
67
|
+
|
|
68
|
+
goto fail
|
|
69
|
+
|
|
70
|
+
:execute
|
|
71
|
+
@rem Setup the command line
|
|
72
|
+
|
|
73
|
+
set CLASSPATH=
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@rem Execute Gradle
|
|
77
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
|
78
|
+
|
|
79
|
+
:end
|
|
80
|
+
@rem End local scope for the variables with windows NT shell
|
|
81
|
+
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
82
|
+
|
|
83
|
+
:fail
|
|
84
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
85
|
+
rem the _cmd.exe /c_ return code!
|
|
86
|
+
set EXIT_CODE=%ERRORLEVEL%
|
|
87
|
+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
88
|
+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
89
|
+
exit /b %EXIT_CODE%
|
|
90
|
+
|
|
91
|
+
:mainEnd
|
|
92
|
+
if "%OS%"=="Windows_NT" endlocal
|
|
93
|
+
|
|
94
|
+
:omega
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
pluginManagement {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
gradlePluginPortal()
|
|
6
|
+
}
|
|
7
|
+
plugins {
|
|
8
|
+
id("com.android.library") version "8.11.1"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
dependencyResolutionManagement {
|
|
13
|
+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
|
14
|
+
repositories {
|
|
15
|
+
google()
|
|
16
|
+
mavenCentral()
|
|
17
|
+
mavenLocal()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
rootProject.name = "fingerly-lynx"
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
package io.fingerly.lynx;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.lynx.jsbridge.LynxMethod;
|
|
6
|
+
import com.lynx.jsbridge.LynxNativeModule;
|
|
7
|
+
import com.lynx.react.bridge.Callback;
|
|
8
|
+
import com.lynx.tasm.behavior.LynxContext;
|
|
9
|
+
import io.fingerly.lynx.generated.FingerlySpec;
|
|
10
|
+
import io.fingerly.sdk.bridge.FingerlyBridge;
|
|
11
|
+
import io.fingerly.sdk.bridge.BridgeCallback;
|
|
12
|
+
import org.json.JSONException;
|
|
13
|
+
import org.json.JSONObject;
|
|
14
|
+
|
|
15
|
+
/** Thin Lynx adapter. Collection, transport and scoring remain in the Android SDK. */
|
|
16
|
+
@LynxNativeModule(name = "Fingerly")
|
|
17
|
+
public final class Fingerly extends FingerlySpec {
|
|
18
|
+
private final Context applicationContext;
|
|
19
|
+
|
|
20
|
+
public Fingerly(LynxContext context) {
|
|
21
|
+
super(context);
|
|
22
|
+
applicationContext = context.getContext().getApplicationContext();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
@LynxMethod
|
|
27
|
+
public void configure(String apiKey, String endpoint, String platform, String consent) {
|
|
28
|
+
// `src/index.ts` always sends a consent, `pending` when the app passed none,
|
|
29
|
+
// so the state is set rather than left as it was.
|
|
30
|
+
FingerlyBridge.configure(applicationContext, apiKey, endpoint, platform, consent);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Override
|
|
34
|
+
@LynxMethod
|
|
35
|
+
public void setConsent(String state) {
|
|
36
|
+
FingerlyBridge.setConsent(state);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
@LynxMethod
|
|
41
|
+
public void identify(
|
|
42
|
+
@Nullable String tag, boolean submit, boolean automatic, Object success, Object failure) {
|
|
43
|
+
// `automatic` is not read: the native Android bridge has no such option
|
|
44
|
+
// yet, so every call is identified as a user's call.
|
|
45
|
+
FingerlyBridge.identify(tag, submit, settle(success, failure));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Override
|
|
49
|
+
@LynxMethod
|
|
50
|
+
public void collect(Object success, Object failure) {
|
|
51
|
+
FingerlyBridge.collect(settle(success, failure));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Deletes the install record, for a user's erasure or account deletion. Needs
|
|
56
|
+
* neither `configure` nor consent. A failure is `delete_failed`, the code the
|
|
57
|
+
* iOS adapter uses for the same thing.
|
|
58
|
+
*/
|
|
59
|
+
@Override
|
|
60
|
+
@LynxMethod
|
|
61
|
+
public void deleteStoredIdentity(Object success, Object failure) {
|
|
62
|
+
boolean deleted;
|
|
63
|
+
try {
|
|
64
|
+
deleted = FingerlyBridge.deleteStoredIdentity(applicationContext);
|
|
65
|
+
} catch (RuntimeException error) {
|
|
66
|
+
deleted = false;
|
|
67
|
+
}
|
|
68
|
+
if (deleted) {
|
|
69
|
+
((Callback) success).invoke();
|
|
70
|
+
} else {
|
|
71
|
+
((Callback) failure).invoke(
|
|
72
|
+
errorJson("delete_failed", "Fingerly could not delete its stored install record"));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
@LynxMethod
|
|
78
|
+
public String sdkVersion() {
|
|
79
|
+
return FingerlyBridge.sdkVersion();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private static BridgeCallback settle(Object success, Object failure) {
|
|
83
|
+
Callback successCallback = (Callback) success;
|
|
84
|
+
Callback failureCallback = (Callback) failure;
|
|
85
|
+
return new BridgeCallback() {
|
|
86
|
+
@Override
|
|
87
|
+
public void onSuccess(String json) {
|
|
88
|
+
successCallback.invoke(json);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@Override
|
|
92
|
+
public void onError(String code, String message) {
|
|
93
|
+
failureCallback.invoke(errorJson(code, message, null));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@Override
|
|
97
|
+
public void onError(String code, String message, Long retryAfterMs) {
|
|
98
|
+
failureCallback.invoke(errorJson(code, message, retryAfterMs));
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private static String errorJson(String code, String message) {
|
|
104
|
+
return errorJson(code, message, null);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private static String errorJson(String code, String message, Long retryAfterMs) {
|
|
108
|
+
try {
|
|
109
|
+
JSONObject error = new JSONObject().put("code", code).put("message", message);
|
|
110
|
+
if (retryAfterMs != null) {
|
|
111
|
+
error.put("retryAfterMs", retryAfterMs.longValue());
|
|
112
|
+
}
|
|
113
|
+
return error.toString();
|
|
114
|
+
} catch (JSONException ignored) {
|
|
115
|
+
return "{\"code\":\"-1\",\"message\":\"Native SDK failure\"}";
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Generated by @lynx-js/autolink-codegen. Do not edit.
|
|
2
|
+
package io.fingerly.lynx.generated;
|
|
3
|
+
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.lynx.jsbridge.LynxContextModule;
|
|
6
|
+
import com.lynx.jsbridge.LynxMethod;
|
|
7
|
+
import com.lynx.tasm.behavior.LynxContext;
|
|
8
|
+
|
|
9
|
+
public abstract class FingerlySpec extends LynxContextModule {
|
|
10
|
+
public FingerlySpec(LynxContext context) {
|
|
11
|
+
super(context);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@LynxMethod
|
|
15
|
+
public abstract void configure(String apiKey, String endpoint, String platform, String consent);
|
|
16
|
+
|
|
17
|
+
@LynxMethod
|
|
18
|
+
public abstract void setConsent(String state);
|
|
19
|
+
|
|
20
|
+
@LynxMethod
|
|
21
|
+
public abstract void identify(@Nullable String tag, boolean submit, boolean automatic, Object success, Object failure);
|
|
22
|
+
|
|
23
|
+
@LynxMethod
|
|
24
|
+
public abstract void collect(Object success, Object failure);
|
|
25
|
+
|
|
26
|
+
@LynxMethod
|
|
27
|
+
public abstract void deleteStoredIdentity(Object success, Object failure);
|
|
28
|
+
|
|
29
|
+
@LynxMethod
|
|
30
|
+
public abstract String sdkVersion();
|
|
31
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Generated by @lynx-js/autolink-codegen. Do not edit.
|
|
2
|
+
|
|
3
|
+
const ADDON_NAME = "Fingerly";
|
|
4
|
+
|
|
5
|
+
export interface FingerlySpec {
|
|
6
|
+
configure(apiKey: string, endpoint: string, platform: string, consent: string): void;
|
|
7
|
+
setConsent(state: string): void;
|
|
8
|
+
identify(tag: string | null, submit: boolean, automatic: boolean, success: (json: string) => void, failure: (error: string) => void): void;
|
|
9
|
+
collect(success: (json: string) => void, failure: (error: string) => void): void;
|
|
10
|
+
deleteStoredIdentity(success: () => void, failure: (error: string) => void): void;
|
|
11
|
+
sdkVersion(): string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type AddonExports = Record<string, unknown>;
|
|
15
|
+
|
|
16
|
+
declare let NativeModules: Record<string, unknown>;
|
|
17
|
+
|
|
18
|
+
declare global {
|
|
19
|
+
interface LynxNapiLoader {
|
|
20
|
+
load(moduleName: string): AddonExports | null | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line no-var
|
|
24
|
+
var __lynxNapiLoader: LynxNapiLoader | undefined;
|
|
25
|
+
|
|
26
|
+
function getNapiLoader(): LynxNapiLoader | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare const lynx: {
|
|
30
|
+
getModuleLoader?(): LynxNapiLoader | undefined;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function getNativeModules(): Record<string, unknown> | undefined {
|
|
34
|
+
const globalObject = globalThis as unknown as {
|
|
35
|
+
NativeModules?: Record<string, unknown>;
|
|
36
|
+
};
|
|
37
|
+
return typeof NativeModules !== 'undefined'
|
|
38
|
+
? NativeModules
|
|
39
|
+
: globalObject.NativeModules;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function installFingerlyShim(): void {
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function requireFingerly(): FingerlySpec {
|
|
47
|
+
const nativeModules = getNativeModules();
|
|
48
|
+
const existingModule = nativeModules?.[ADDON_NAME];
|
|
49
|
+
if (existingModule !== undefined && existingModule !== null) {
|
|
50
|
+
return existingModule as FingerlySpec;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
throw new Error(`Native module "${ADDON_NAME}" is unavailable.`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const Fingerly = new Proxy({}, {
|
|
59
|
+
get(_target, property) {
|
|
60
|
+
return requireFingerly()[property as keyof FingerlySpec];
|
|
61
|
+
},
|
|
62
|
+
}) as FingerlySpec;
|
|
63
|
+
|
|
64
|
+
installFingerlyShim();
|
|
65
|
+
|
|
66
|
+
export default Fingerly;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Puts Fingerly.xcframework in <pod root>/Frameworks. Run by the podspec.
|
|
4
|
+
#
|
|
5
|
+
# fetch-fingerly-xcframework.sh <version> <sha256> <pod root>
|
|
6
|
+
#
|
|
7
|
+
# The release writes the checksum of the published zip into fingerly-binary.json
|
|
8
|
+
# before packing, so a package from npm only ever installs the exact binary it
|
|
9
|
+
# was released against. The checksum is empty only in a git checkout.
|
|
10
|
+
#
|
|
11
|
+
# Stdout stays silent because `pod ipc spec` prints its JSON there.
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
|
|
14
|
+
version="$1"
|
|
15
|
+
sha256="$2"
|
|
16
|
+
dest="$3/Frameworks"
|
|
17
|
+
stamp="$dest/.fingerly-binary"
|
|
18
|
+
wanted="$version $sha256"
|
|
19
|
+
|
|
20
|
+
if [ -d "$dest/Fingerly.xcframework" ] && [ "$(cat "$stamp" 2>/dev/null)" = "$wanted" ]; then
|
|
21
|
+
exit 0
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
url="https://maven.fingerly.io/ios/Fingerly-$version.xcframework.zip"
|
|
25
|
+
work="$(mktemp -d "${TMPDIR:-/tmp}/fingerly-xcframework.XXXXXX")"
|
|
26
|
+
trap 'rm -rf "$work"' EXIT
|
|
27
|
+
|
|
28
|
+
if ! curl --fail --silent --show-error --location --proto '=https' --retry 3 --output "$work/sdk.zip" "$url"; then
|
|
29
|
+
echo "error: could not download $url" >&2
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
if [ -n "$sha256" ]; then
|
|
34
|
+
actual="$(shasum -a 256 "$work/sdk.zip" | cut -d' ' -f1)"
|
|
35
|
+
if [ "$actual" != "$sha256" ]; then
|
|
36
|
+
echo "error: $url has checksum $actual, expected $sha256" >&2
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
else
|
|
40
|
+
echo "warning: no checksum recorded, $url was not verified (expected only in a git checkout)" >&2
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
unzip -q "$work/sdk.zip" -d "$work/expanded"
|
|
44
|
+
if [ ! -d "$work/expanded/Fingerly.xcframework" ]; then
|
|
45
|
+
echo "error: $url does not contain Fingerly.xcframework" >&2
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
rm -rf "$dest"
|
|
50
|
+
mkdir -p "$dest"
|
|
51
|
+
mv "$work/expanded/Fingerly.xcframework" "$dest/"
|
|
52
|
+
printf '%s' "$wanted" > "$stamp"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The native SDK comes in as a vendored XCFramework from Fingerly's own host
|
|
3
|
+
# rather than as `s.dependency 'Fingerly'`, because CocoaPods trunk accepts no
|
|
4
|
+
# new podspecs after 2026-12-02.
|
|
5
|
+
#
|
|
6
|
+
# The fetch runs while the podspec is evaluated, not as a `prepare_command`:
|
|
7
|
+
# CocoaPods skips the prepare step for a pod it considers unchanged, so
|
|
8
|
+
# reinstalling node_modules would leave the framework missing for good. The
|
|
9
|
+
# script does nothing once the right binary is in place.
|
|
10
|
+
#
|
|
11
|
+
require 'json'
|
|
12
|
+
|
|
13
|
+
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
14
|
+
binary = JSON.parse(File.read(File.join(__dir__, 'fingerly-binary.json')))
|
|
15
|
+
|
|
16
|
+
unless system('bash', File.join(__dir__, 'fetch-fingerly-xcframework.sh'),
|
|
17
|
+
binary['version'], binary['sha256'].to_s, __dir__)
|
|
18
|
+
raise "Could not fetch Fingerly.xcframework #{binary['version']}. See the message above."
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Pod::Spec.new do |s|
|
|
22
|
+
s.name = 'fingerly-lynx'
|
|
23
|
+
s.version = package['version']
|
|
24
|
+
s.summary = 'Fingerly native bridge for Lynx'
|
|
25
|
+
s.homepage = 'https://fingerly.io'
|
|
26
|
+
s.license = { :type => 'Apache-2.0', :file => '../LICENSE' }
|
|
27
|
+
s.author = 'Fingerly'
|
|
28
|
+
s.platform = :ios, '13.0'
|
|
29
|
+
s.swift_version = '5.9'
|
|
30
|
+
# The Lynx autolinker installs this pod by path and never reads the source.
|
|
31
|
+
# It names the published tarball so the field still points at something public.
|
|
32
|
+
s.source = { :http => "https://registry.npmjs.org/@fingerly/lynx/-/lynx-#{s.version}.tgz" }
|
|
33
|
+
s.source_files = 'src/**/*.{h,m,mm}'
|
|
34
|
+
s.vendored_frameworks = 'Frameworks/Fingerly.xcframework'
|
|
35
|
+
s.dependency 'Lynx', '4.1.0'
|
|
36
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#import "Fingerly.h"
|
|
2
|
+
#import <Fingerly/Fingerly-Swift.h>
|
|
3
|
+
|
|
4
|
+
@implementation Fingerly
|
|
5
|
+
|
|
6
|
+
+ (NSString *)name {
|
|
7
|
+
return @"Fingerly";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
+ (NSDictionary<NSString *, NSString *> *)methodLookup {
|
|
11
|
+
return @{
|
|
12
|
+
@"configure" : NSStringFromSelector(@selector(configure:endpoint:platform:consent:)),
|
|
13
|
+
@"setConsent" : NSStringFromSelector(@selector(setConsent:)),
|
|
14
|
+
@"identify" : NSStringFromSelector(@selector(identify:submit:automatic:success:failure:)),
|
|
15
|
+
@"collect" : NSStringFromSelector(@selector(collect:failure:)),
|
|
16
|
+
@"deleteStoredIdentity" : NSStringFromSelector(@selector(deleteStoredIdentity:failure:)),
|
|
17
|
+
@"sdkVersion" : NSStringFromSelector(@selector(sdkVersion)),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
- (void)configure:(NSString *)apiKey
|
|
22
|
+
endpoint:(NSString *)endpoint
|
|
23
|
+
platform:(NSString *)platform
|
|
24
|
+
consent:(NSString *)consent {
|
|
25
|
+
// `src/index.ts` always sends a consent, `pending` when the app passed none.
|
|
26
|
+
// The native bridge reads anything it does not recognise as `pending`.
|
|
27
|
+
[FingerlyBridge configureWithApiKey:apiKey endpoint:endpoint platform:platform consent:consent];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
- (void)setConsent:(NSString *)state {
|
|
31
|
+
[FingerlyBridge setConsent:state];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
- (void)identify:(nullable NSString *)tag
|
|
35
|
+
submit:(BOOL)submit
|
|
36
|
+
automatic:(BOOL)automatic
|
|
37
|
+
success:(id)success
|
|
38
|
+
failure:(id)failure {
|
|
39
|
+
void (^successCallback)(id) = (void (^)(id))success;
|
|
40
|
+
void (^failureCallback)(id) = (void (^)(id))failure;
|
|
41
|
+
// `automatic` marks a call the app made on its own, which joins the
|
|
42
|
+
// identification already in flight instead of starting another.
|
|
43
|
+
[FingerlyBridge identifyWithTag:tag
|
|
44
|
+
submit:submit
|
|
45
|
+
automatic:automatic
|
|
46
|
+
completion:^(NSString *json, NSError *error) {
|
|
47
|
+
if (error != nil) {
|
|
48
|
+
failureCallback([self errorJSON:error]);
|
|
49
|
+
} else if (json != nil) {
|
|
50
|
+
successCallback(json);
|
|
51
|
+
} else {
|
|
52
|
+
failureCallback(@"{\"code\":\"-1\",\"message\":\"The SDK produced no report\"}");
|
|
53
|
+
}
|
|
54
|
+
}];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (void)collect:(id)success failure:(id)failure {
|
|
58
|
+
void (^successCallback)(id) = (void (^)(id))success;
|
|
59
|
+
void (^failureCallback)(id) = (void (^)(id))failure;
|
|
60
|
+
[FingerlyBridge collectWithCompletion:^(NSString *json, NSError *error) {
|
|
61
|
+
if (error != nil) {
|
|
62
|
+
failureCallback([self errorJSON:error]);
|
|
63
|
+
} else if (json != nil) {
|
|
64
|
+
successCallback(json);
|
|
65
|
+
} else {
|
|
66
|
+
failureCallback(@"{\"code\":\"-1\",\"message\":\"The SDK produced no report\"}");
|
|
67
|
+
}
|
|
68
|
+
}];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
- (void)deleteStoredIdentity:(id)success failure:(id)failure {
|
|
72
|
+
// A keychain delete, synchronous and quick. A refusal carries the
|
|
73
|
+
// `delete_failed` code in `userInfo`, which `errorJSON:` passes on.
|
|
74
|
+
//
|
|
75
|
+
// Both are Lynx callback blocks, `void (^)(id result)`, and are called with
|
|
76
|
+
// their one argument. Calling the success block through a zero-argument
|
|
77
|
+
// cast would hand Lynx whatever the argument register held as `result`,
|
|
78
|
+
// which it retains and converts to a JavaScript value.
|
|
79
|
+
void (^successCallback)(id) = (void (^)(id))success;
|
|
80
|
+
void (^failureCallback)(id) = (void (^)(id))failure;
|
|
81
|
+
NSError *error = [FingerlyBridge deleteStoredIdentity];
|
|
82
|
+
if (error != nil) {
|
|
83
|
+
failureCallback([self errorJSON:error]);
|
|
84
|
+
} else {
|
|
85
|
+
successCallback(nil);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
- (NSString *)sdkVersion {
|
|
90
|
+
return FingerlyBridge.sdkVersion;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (NSString *)errorJSON:(NSError *)error {
|
|
94
|
+
// A refusal for want of consent carries its string code (`consent_required`)
|
|
95
|
+
// and the refusing state in `userInfo`; every other failure uses the numeric
|
|
96
|
+
// code, which is the HTTP status where there was one.
|
|
97
|
+
id userInfoCode = error.userInfo[@"code"];
|
|
98
|
+
id userInfoState = error.userInfo[@"state"];
|
|
99
|
+
NSMutableDictionary *payload = [@{
|
|
100
|
+
@"code" : [userInfoCode isKindOfClass:[NSString class]]
|
|
101
|
+
? userInfoCode
|
|
102
|
+
: [NSString stringWithFormat:@"%ld", (long)error.code],
|
|
103
|
+
@"message" : error.localizedDescription ?: @"Native SDK failure",
|
|
104
|
+
} mutableCopy];
|
|
105
|
+
if ([userInfoState isKindOfClass:[NSString class]]) {
|
|
106
|
+
payload[@"state"] = userInfoState;
|
|
107
|
+
}
|
|
108
|
+
// The wait a 429 or 503 named in `Retry-After`, when the native bridge
|
|
109
|
+
// passed one on; `src/index.ts` reads it into `retryAfterMs`.
|
|
110
|
+
id userInfoRetryAfter = error.userInfo[@"retryAfterMs"];
|
|
111
|
+
if ([userInfoRetryAfter isKindOfClass:[NSNumber class]]) {
|
|
112
|
+
payload[@"retryAfterMs"] = userInfoRetryAfter;
|
|
113
|
+
}
|
|
114
|
+
NSData *data = [NSJSONSerialization dataWithJSONObject:payload options:0 error:nil];
|
|
115
|
+
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]
|
|
116
|
+
?: @"{\"code\":\"-1\",\"message\":\"Native SDK failure\"}";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by @lynx-js/autolink-codegen. Do not edit.
|
|
2
|
+
#import <Foundation/Foundation.h>
|
|
3
|
+
#import <Lynx/LynxModule.h>
|
|
4
|
+
|
|
5
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
6
|
+
|
|
7
|
+
@protocol FingerlySpec <LynxModule>
|
|
8
|
+
|
|
9
|
+
- (void)configure:(NSString *)apiKey endpoint:(NSString *)endpoint platform:(NSString *)platform consent:(NSString *)consent;
|
|
10
|
+
- (void)setConsent:(NSString *)state;
|
|
11
|
+
- (void)identify:(nullable NSString *)tag submit:(BOOL)submit automatic:(BOOL)automatic success:(id)success failure:(id)failure;
|
|
12
|
+
- (void)collect:(id)success failure:(id)failure;
|
|
13
|
+
- (void)deleteStoredIdentity:(id)success failure:(id)failure;
|
|
14
|
+
- (NSString *)sdkVersion;
|
|
15
|
+
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
NS_ASSUME_NONNULL_END
|
package/lynx.lib.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fingerly/lynx",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Lynx SDK backed by Fingerly's native iOS and Android SDKs",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/fingerly-io/sdks.git",
|
|
12
|
+
"directory": "client/mobile/lynx"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./src/index.ts",
|
|
16
|
+
"types": "./src/index.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"android",
|
|
19
|
+
"!android/build",
|
|
20
|
+
"!android/.gradle",
|
|
21
|
+
"generated",
|
|
22
|
+
"ios",
|
|
23
|
+
"!ios/Pods",
|
|
24
|
+
"!ios/Frameworks",
|
|
25
|
+
"src",
|
|
26
|
+
"types",
|
|
27
|
+
"lynx.lib.json",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@fingerly/types": "0.1.2"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@lynx-js/autolink-codegen": "0.6.0",
|
|
35
|
+
"typescript": "^5.7.2",
|
|
36
|
+
"vitest": "^2.1.8"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"codegen": "lynx-autolink-codegen",
|
|
40
|
+
"build:types": "pnpm --filter @fingerly/types build",
|
|
41
|
+
"build": "pnpm codegen && pnpm build:types && tsc --noEmit",
|
|
42
|
+
"lint": "pnpm build:types && tsc --noEmit",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"example:build": "pnpm --dir example build"
|
|
45
|
+
}
|
|
6
46
|
}
|