@prelude.so/react-native-sdk 0.2.0 → 0.3.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/android/build.gradle +4 -3
- package/android/src/main/java/so/prelude/reactnative/sdk/PreludeReactNativeSdkModule.kt +50 -46
- package/build/index.d.ts +8 -7
- package/build/index.d.ts.map +1 -1
- package/build/index.js +9 -5
- package/build/index.js.map +1 -1
- package/ios/PreludeReactNativeSdkModule.swift +45 -41
- package/package.json +4 -4
- package/src/index.ts +20 -10
- package/build/PreludeReactNativeSdk.types.d.ts +0 -10
- package/build/PreludeReactNativeSdk.types.d.ts.map +0 -1
- package/build/PreludeReactNativeSdk.types.js +0 -2
- package/build/PreludeReactNativeSdk.types.js.map +0 -1
- package/src/PreludeReactNativeSdk.types.ts +0 -10
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'so.prelude.reactnative.sdk'
|
|
4
|
-
version = '0.2.
|
|
4
|
+
version = '0.2.1'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -35,7 +35,7 @@ android {
|
|
|
35
35
|
namespace "so.prelude.reactnative.sdk"
|
|
36
36
|
defaultConfig {
|
|
37
37
|
versionCode 1
|
|
38
|
-
versionName
|
|
38
|
+
versionName version
|
|
39
39
|
}
|
|
40
40
|
lintOptions {
|
|
41
41
|
abortOnError false
|
|
@@ -43,5 +43,6 @@ android {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
dependencies {
|
|
46
|
-
|
|
46
|
+
compileOnly('com.squareup.okhttp3:okhttp:4.12.0')
|
|
47
|
+
implementation('so.prelude.android:sdk:0.2.1')
|
|
47
48
|
}
|
|
@@ -5,70 +5,74 @@ import expo.modules.kotlin.modules.Module
|
|
|
5
5
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
6
6
|
import so.prelude.android.sdk.Configuration
|
|
7
7
|
import so.prelude.android.sdk.Configuration.Companion.DEFAULT_REQUEST_TIMEOUT
|
|
8
|
-
import so.prelude.android.sdk.DispatchStatusListener
|
|
9
8
|
import so.prelude.android.sdk.Endpoint
|
|
9
|
+
import so.prelude.android.sdk.Features
|
|
10
10
|
import so.prelude.android.sdk.Prelude
|
|
11
11
|
import java.net.URL
|
|
12
12
|
|
|
13
13
|
class PreludeReactNativeSdkModule : Module() {
|
|
14
|
-
override fun definition() =
|
|
15
|
-
|
|
14
|
+
override fun definition() =
|
|
15
|
+
ModuleDefinition {
|
|
16
|
+
Name("PreludeReactNativeSdk")
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
AsyncFunction("dispatchSignals") Coroutine {
|
|
19
|
+
sdkKey: String,
|
|
20
|
+
endpointUrl: String?,
|
|
21
|
+
timeoutMilliseconds: Long?,
|
|
22
|
+
implementedFeaturesRawValue: Long?,
|
|
23
|
+
->
|
|
24
|
+
dispatchSignals(endpointUrl, sdkKey, timeoutMilliseconds, implementedFeaturesRawValue ?: 0L)
|
|
25
|
+
}
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
sdkKey = sdkKey,
|
|
26
|
-
requestUrl = requestUrl
|
|
27
|
-
)
|
|
27
|
+
AsyncFunction("verifySilent") Coroutine { sdkKey: String, requestUrl: String ->
|
|
28
|
+
verifySilent(
|
|
29
|
+
sdkKey = sdkKey,
|
|
30
|
+
requestUrl = requestUrl,
|
|
31
|
+
)
|
|
32
|
+
}
|
|
28
33
|
}
|
|
29
|
-
}
|
|
30
34
|
|
|
31
|
-
private fun dispatchSignals(
|
|
35
|
+
private suspend fun dispatchSignals(
|
|
32
36
|
endpointUrl: String?,
|
|
33
37
|
sdkKey: String,
|
|
34
|
-
timeoutMilliseconds: Long
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
timeoutMilliseconds: Long?,
|
|
39
|
+
implementedFeaturesRawValue: Long = 0L,
|
|
40
|
+
): String {
|
|
41
|
+
val endpoint: Endpoint =
|
|
42
|
+
endpointUrl?.let {
|
|
43
|
+
Endpoint.Custom(
|
|
44
|
+
address = it,
|
|
45
|
+
)
|
|
46
|
+
} ?: Endpoint.Default
|
|
39
47
|
|
|
40
|
-
val context =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
it.applicationContext,
|
|
45
|
-
sdkKey,
|
|
46
|
-
endpoint,
|
|
47
|
-
requestTimeout = timeoutMilliseconds ?: DEFAULT_REQUEST_TIMEOUT
|
|
48
|
+
val context =
|
|
49
|
+
appContext.reactContext
|
|
50
|
+
?: throw IllegalStateException(
|
|
51
|
+
"Invalid React Android Context. Cannot dispatch signals",
|
|
48
52
|
)
|
|
53
|
+
|
|
54
|
+
val config =
|
|
55
|
+
Configuration(
|
|
56
|
+
context = context.applicationContext,
|
|
57
|
+
sdkKey = sdkKey,
|
|
58
|
+
endpoint = endpoint,
|
|
59
|
+
requestTimeout = timeoutMilliseconds ?: DEFAULT_REQUEST_TIMEOUT,
|
|
60
|
+
implementedFeatures = Features.fromRawValue(implementedFeaturesRawValue),
|
|
49
61
|
)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"status" to status,
|
|
54
|
-
"dispatchID" to dispatchId
|
|
55
|
-
)
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
62
|
+
val prelude = Prelude(config)
|
|
63
|
+
|
|
64
|
+
return prelude.dispatchSignals().getOrThrow()
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
private suspend fun verifySilent(
|
|
62
68
|
sdkKey: String,
|
|
63
69
|
requestUrl: String,
|
|
64
|
-
): String
|
|
65
|
-
val context =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
}
|
|
70
|
+
): String {
|
|
71
|
+
val context =
|
|
72
|
+
appContext.reactContext
|
|
73
|
+
?: throw IllegalStateException(
|
|
74
|
+
"Invalid React Android Context. Cannot perform silent verification",
|
|
75
|
+
)
|
|
72
76
|
|
|
73
77
|
if (sdkKey.isBlank() || requestUrl.isBlank()) {
|
|
74
78
|
throw IllegalArgumentException("SDK Key and Request URL must both be provided.")
|
|
@@ -76,6 +80,6 @@ class PreludeReactNativeSdkModule : Module() {
|
|
|
76
80
|
|
|
77
81
|
val prelude = Prelude(context.applicationContext, sdkKey)
|
|
78
82
|
|
|
79
|
-
return prelude.verifySilent(URL(requestUrl)).
|
|
83
|
+
return prelude.verifySilent(URL(requestUrl)).getOrThrow()
|
|
80
84
|
}
|
|
81
85
|
}
|
package/build/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { DispatchingSignalsStatus } from './PreludeReactNativeSdk.types';
|
|
3
|
-
export declare function dispatchSignals(configuration: {
|
|
1
|
+
export declare function dispatchSignals(configuration?: {
|
|
4
2
|
sdk_key: string;
|
|
5
3
|
endpoint?: string;
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
timeout_milliseconds?: number;
|
|
5
|
+
implemented_features?: Features[];
|
|
6
|
+
}): Promise<string>;
|
|
8
7
|
export declare function verifySilent(configuration: {
|
|
9
8
|
sdk_key: string;
|
|
10
9
|
request_url: string;
|
|
11
|
-
}): Promise<
|
|
12
|
-
export
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
export declare enum Features {
|
|
12
|
+
SilentVerification = 1
|
|
13
|
+
}
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,wBAAsB,eAAe,CACnC,aAAa,GAAE;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oBAAoB,CAAC,EAAE,QAAQ,EAAE,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAOpC;AAED,wBAAsB,YAAY,CAAC,aAAa,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAE3G;AAED,oBAAY,QAAQ;IAClB,kBAAkB,IAAS;CAC5B"}
|
package/build/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import PreludeReactNativeSdkModule from './PreludeReactNativeSdkModule';
|
|
2
|
-
export async function dispatchSignals(configuration) {
|
|
3
|
-
return await PreludeReactNativeSdkModule.dispatchSignals(configuration.sdk_key, configuration.endpoint);
|
|
4
|
-
}
|
|
5
|
-
export function onDispatchingSignals(listener) {
|
|
6
|
-
return PreludeReactNativeSdkModule.addListener('onDispatchingSignals', listener);
|
|
2
|
+
export async function dispatchSignals(configuration = { sdk_key: '' }) {
|
|
3
|
+
return await PreludeReactNativeSdkModule.dispatchSignals(configuration.sdk_key, configuration.endpoint, configuration.timeout_milliseconds, toRawValue(configuration.implemented_features || []));
|
|
7
4
|
}
|
|
8
5
|
export async function verifySilent(configuration) {
|
|
9
6
|
return await PreludeReactNativeSdkModule.verifySilent(configuration.sdk_key, configuration.request_url);
|
|
10
7
|
}
|
|
8
|
+
export var Features;
|
|
9
|
+
(function (Features) {
|
|
10
|
+
Features[Features["SilentVerification"] = 1] = "SilentVerification";
|
|
11
|
+
})(Features || (Features = {}));
|
|
12
|
+
function toRawValue(features) {
|
|
13
|
+
return features.reduce((acc, feature) => acc | feature, 0);
|
|
14
|
+
}
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,MAAM,+BAA+B,CAAC;AAExE,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,gBAKI,EAAC,OAAO,EAAE,EAAE,EAAC;IACjB,OAAO,MAAM,2BAA2B,CAAC,eAAe,CACpD,aAAa,CAAC,OAAO,EACrB,aAAa,CAAC,QAAQ,EACtB,aAAa,CAAC,oBAAoB,EAClC,UAAU,CAAC,aAAa,CAAC,oBAAoB,IAAI,EAAE,CAAC,CACvD,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,aAAuD;IACxF,OAAO,MAAM,2BAA2B,CAAC,YAAY,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;AAC1G,CAAC;AAED,MAAM,CAAN,IAAY,QAEX;AAFD,WAAY,QAAQ;IAClB,mEAA2B,CAAA;AAC7B,CAAC,EAFW,QAAQ,KAAR,QAAQ,QAEnB;AAED,SAAS,UAAU,CAAC,QAAoB;IACtC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,GAAG,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import PreludeReactNativeSdkModule from './PreludeReactNativeSdkModule';\n\nexport async function dispatchSignals(\n configuration: {\n sdk_key: string;\n endpoint?: string;\n timeout_milliseconds?: number;\n implemented_features?: Features[];\n } = {sdk_key: ''}): Promise<string> {\n return await PreludeReactNativeSdkModule.dispatchSignals(\n configuration.sdk_key,\n configuration.endpoint,\n configuration.timeout_milliseconds,\n toRawValue(configuration.implemented_features || []),\n );\n}\n\nexport async function verifySilent(configuration: { sdk_key: string, request_url: string }): Promise<string> {\n return await PreludeReactNativeSdkModule.verifySilent(configuration.sdk_key, configuration.request_url);\n}\n\nexport enum Features {\n SilentVerification = 1 << 0,\n}\n\nfunction toRawValue(features: Features[]): number {\n return features.reduce((acc, feature) => acc | feature, 0);\n}"]}
|
|
@@ -1,51 +1,55 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
|
|
3
3
|
public class PreludeReactNativeSdkModule: Module {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
AsyncFunction("verifySilent") { (sdkKey: String, requestUrl: String) in
|
|
28
|
-
if sdkKey.isEmpty || requestUrl.isEmpty {
|
|
29
|
-
throw Exception(name: "IllegalArguments",
|
|
30
|
-
description: "SDK Key and Request URL must both be provided.",
|
|
31
|
-
code: "ILLEGAL_ARGUMENTS_EMPTY_FIELD"
|
|
4
|
+
public func definition() -> ModuleDefinition {
|
|
5
|
+
Name("PreludeReactNativeSdk")
|
|
6
|
+
|
|
7
|
+
AsyncFunction("dispatchSignals") { (sdkKey: String, endpointUrl: String?, timeoutMilliseconds: Int64?, implementedFeaturesRawValue: Int64?) in
|
|
8
|
+
let endpoint = endpointUrl != nil ? Endpoint.custom(endpointUrl!) : .default
|
|
9
|
+
let timeout = timeoutMilliseconds != nil ? TimeInterval(timeoutMilliseconds!) / 1000 : 2.0
|
|
10
|
+
|
|
11
|
+
let implementedFeatures: Features
|
|
12
|
+
if let rawValue = implementedFeaturesRawValue {
|
|
13
|
+
let uintRawValue = rawValue >= 0 ? rawValue : 0
|
|
14
|
+
implementedFeatures = Features(rawValue: UInt64(uintRawValue))
|
|
15
|
+
} else {
|
|
16
|
+
implementedFeatures = []
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let configuration = Configuration(
|
|
20
|
+
sdkKey: sdkKey,
|
|
21
|
+
endpoint: endpoint,
|
|
22
|
+
implementedFeatures: implementedFeatures,
|
|
23
|
+
timeout: timeout
|
|
32
24
|
)
|
|
25
|
+
|
|
26
|
+
let prelude = Prelude(configuration)
|
|
27
|
+
|
|
28
|
+
return try await prelude.dispatchSignals()
|
|
33
29
|
}
|
|
34
|
-
|
|
35
|
-
let configuration = Configuration(
|
|
36
|
-
sdkKey: sdkKey,
|
|
37
|
-
)
|
|
38
30
|
|
|
39
|
-
|
|
31
|
+
AsyncFunction("verifySilent") { (sdkKey: String, requestUrl: String) in
|
|
32
|
+
if sdkKey.isEmpty || requestUrl.isEmpty {
|
|
33
|
+
throw Exception(name: "IllegalArguments",
|
|
34
|
+
description: "SDK Key and Request URL must both be provided.",
|
|
35
|
+
code: "ILLEGAL_ARGUMENTS_EMPTY_FIELD"
|
|
36
|
+
)
|
|
37
|
+
}
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)
|
|
39
|
+
let configuration = Configuration(
|
|
40
|
+
sdkKey: sdkKey,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
let prelude = Prelude(configuration)
|
|
44
|
+
|
|
45
|
+
guard let url = URL(string: requestUrl) else {
|
|
46
|
+
throw Exception(name: "IllegalArguments",
|
|
47
|
+
description: "Request URL must be a valid URL.",
|
|
48
|
+
code: "ILLEGAL_ARGUMENTS_INVALID_URL"
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return try await prelude.verifySilent(url: url)
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
return try await prelude.verifySilent(url: url)
|
|
49
54
|
}
|
|
50
|
-
}
|
|
51
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prelude.so/react-native-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Prelude SDK for React Native",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"homepage": "https://github.com/prelude-so/react-native-sdk#readme",
|
|
42
42
|
"dependencies": {},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/react": "
|
|
44
|
+
"@types/react": "^18.3.0",
|
|
45
45
|
"expo": "~52.0.46",
|
|
46
46
|
"expo-module-scripts": "^4.0.2",
|
|
47
|
-
"react": "18.3.
|
|
47
|
+
"react": "^18.3.0",
|
|
48
48
|
"react-native": "0.76.9"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"react-native": "*"
|
|
54
54
|
},
|
|
55
55
|
"so_prelude": {
|
|
56
|
-
"apple_sdk_tag": "0.2.
|
|
56
|
+
"apple_sdk_tag": "0.2.2"
|
|
57
57
|
}
|
|
58
58
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import { EventSubscription } from 'expo-modules-core';
|
|
2
|
-
|
|
3
1
|
import PreludeReactNativeSdkModule from './PreludeReactNativeSdkModule';
|
|
4
|
-
import { DispatchingSignalsStatus } from './PreludeReactNativeSdk.types';
|
|
5
2
|
|
|
6
|
-
export async function dispatchSignals(
|
|
7
|
-
|
|
3
|
+
export async function dispatchSignals(
|
|
4
|
+
configuration: {
|
|
5
|
+
sdk_key: string;
|
|
6
|
+
endpoint?: string;
|
|
7
|
+
timeout_milliseconds?: number;
|
|
8
|
+
implemented_features?: Features[];
|
|
9
|
+
} = {sdk_key: ''}): Promise<string> {
|
|
10
|
+
return await PreludeReactNativeSdkModule.dispatchSignals(
|
|
11
|
+
configuration.sdk_key,
|
|
12
|
+
configuration.endpoint,
|
|
13
|
+
configuration.timeout_milliseconds,
|
|
14
|
+
toRawValue(configuration.implemented_features || []),
|
|
15
|
+
);
|
|
8
16
|
}
|
|
9
17
|
|
|
10
|
-
export function
|
|
11
|
-
return PreludeReactNativeSdkModule.
|
|
18
|
+
export async function verifySilent(configuration: { sdk_key: string, request_url: string }): Promise<string> {
|
|
19
|
+
return await PreludeReactNativeSdkModule.verifySilent(configuration.sdk_key, configuration.request_url);
|
|
12
20
|
}
|
|
13
21
|
|
|
14
|
-
export
|
|
15
|
-
|
|
22
|
+
export enum Features {
|
|
23
|
+
SilentVerification = 1 << 0,
|
|
16
24
|
}
|
|
17
25
|
|
|
18
|
-
|
|
26
|
+
function toRawValue(features: Features[]): number {
|
|
27
|
+
return features.reduce((acc, feature) => acc | feature, 0);
|
|
28
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreludeReactNativeSdk.types.d.ts","sourceRoot":"","sources":["../src/PreludeReactNativeSdk.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreludeReactNativeSdk.types.js","sourceRoot":"","sources":["../src/PreludeReactNativeSdk.types.ts"],"names":[],"mappings":"","sourcesContent":["export type DispatchingSignalsStatus = {\n status: string,\n dispatchID: string;\n};\n\nexport type Configuration = {\n sdk_key: string;\n endpoint?: string;\n timeout_milliseconds?: number;\n}"]}
|