@prelude.so/react-native-sdk 0.3.0 → 0.3.2
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 +67 -34
- package/android/build.gradle +4 -3
- package/android/src/main/java/so/prelude/reactnative/sdk/PreludeReactNativeSdkModule.kt +45 -30
- package/build/index.d.ts +5 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +9 -2
- package/build/index.js.map +1 -1
- package/ios/PreludeReactNativeSdkModule.swift +45 -36
- package/package.json +2 -2
- package/src/index.ts +16 -2
package/README.md
CHANGED
|
@@ -1,51 +1,59 @@
|
|
|
1
1
|
# Readme
|
|
2
2
|
## Using the Expo React Native SDK
|
|
3
3
|
|
|
4
|
-
The Expo React Native SDK allows you to
|
|
4
|
+
The Expo React Native SDK allows you to gather device signals and perform silent verification of mobile devices.
|
|
5
|
+
|
|
6
|
+
### Gathering Device Signals
|
|
7
|
+
The SDK allows you to capture certain device signals (both in Android and iOS) that will be reported back to Prelude.
|
|
5
8
|
|
|
6
9
|
It is provided as an Expo module that you can integrate into your React Native Expo Application.
|
|
7
10
|
|
|
8
|
-
The Android `minSdkVersion` value in the SDK is set to 26 (Android 8.0). If
|
|
11
|
+
The Android `minSdkVersion` value in the SDK is set to 26 (Android 8.0). If you application has a lower value you may need to update it.
|
|
12
|
+
|
|
13
|
+
#### Configuring the project
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
First install the SDK dependency in your app:
|
|
11
16
|
|
|
12
17
|
```
|
|
13
18
|
npm install @prelude.so/react-native-sdk
|
|
14
19
|
```
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
***Important: When you generate the SDK key in the Prelude dashboard you will be able to copy it and you should store it somewhere secure, as the dashboard will not allow you to display the same key again.***
|
|
19
|
-
|
|
20
|
-
### Gathering Device Signals
|
|
21
|
-
|
|
22
|
-
**Note**: Starting with v0.3.0 of the SDK, we have removed the status event and made the `dispatchSignals` function return a promise that resolves to the dispatch identifier, simplifying its usage.
|
|
23
|
-
|
|
24
|
-
To collect the device signals in your application you can use code like this:
|
|
21
|
+
Then, where ever in your application you want to report the device signals you can use code like this:
|
|
25
22
|
|
|
26
23
|
```
|
|
27
24
|
...
|
|
25
|
+
// Import the react state types
|
|
26
|
+
import { useEffect, useState } from "react";
|
|
28
27
|
// Import the SDK types
|
|
29
28
|
import * as PreludeReactNativeSdk from '@prelude.so/react-native-sdk';
|
|
30
29
|
...
|
|
31
30
|
|
|
31
|
+
// Define a state to receive status updates
|
|
32
|
+
const [dispatchStatus, setDispatchStatus] = useState({ dispatchID: "", status: "" });
|
|
33
|
+
|
|
34
|
+
...
|
|
35
|
+
// Subscribe to the event
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const subscription = PreludeReactNativeSdk.onDispatchingSignals((dispatchingSignalsStatus) => {
|
|
38
|
+
console.log("Dispatch status: " + dispatchingSignalsStatus.status + ". Id: " + dispatchingSignalsStatus.dispatchID);
|
|
39
|
+
setDispatchStatus(dispatchingSignalsStatus);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return () => {
|
|
43
|
+
subscription.remove();
|
|
44
|
+
}
|
|
45
|
+
}, [dispatchStatus]);
|
|
46
|
+
|
|
32
47
|
...
|
|
33
48
|
// Submit the signals in any of your app event handlers (here is a button example)
|
|
34
|
-
<Button title={`Dispatch Signals`} onPress={
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// e.g., store it or continue with verification here
|
|
43
|
-
alert(`Dispatch ID: ${dispatchId}`);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
alert(`Signals dispatch error: ${error.message}`);
|
|
46
|
-
}
|
|
47
|
-
}}
|
|
48
|
-
/>
|
|
49
|
+
<Button title={`Dispatch Signals`} onPress={() =>
|
|
50
|
+
PreludeReactNativeSdk.dispatchSignals({
|
|
51
|
+
sdk_key: "YOUR-SDK-KEY"
|
|
52
|
+
})
|
|
53
|
+
.catch((error) => {
|
|
54
|
+
console.log("Dispatch error: " + error);
|
|
55
|
+
})
|
|
56
|
+
} />
|
|
49
57
|
|
|
50
58
|
```
|
|
51
59
|
|
|
@@ -61,16 +69,41 @@ or
|
|
|
61
69
|
npx expo run:android
|
|
62
70
|
```
|
|
63
71
|
|
|
64
|
-
Once you get the dispatch
|
|
65
|
-
|
|
66
|
-
There is no restriction on when to call this API, you just need to take this action before you need to report back the dispatch ID.
|
|
72
|
+
Once you get the dispatch ID through the event, you can report it back to your own API to be forwarded in subsequent network calls.
|
|
67
73
|
|
|
68
|
-
|
|
74
|
+
There is no restriction on when to call this API, you just need to take this action before you need to report back the dispatch ID. It is advisable to make the request early on during the user onboarding process to have the dispatch id available when required.
|
|
69
75
|
|
|
70
76
|
### Silent Verification
|
|
71
77
|
|
|
72
|
-
The Silent Verification feature allows you to verify a phone number without requiring the user to
|
|
78
|
+
The Silent Verification feature allows you to verify a phone number without requiring the user to enter a verification code. It is available for certain carriers and requires a server-side service to handle the verification process.
|
|
73
79
|
|
|
74
|
-
|
|
80
|
+
The SDK provides a simple API to initiate the verification process and handle the response.
|
|
75
81
|
|
|
76
|
-
|
|
82
|
+
We assume here that you have a server-side service that exposes the 2 endpoints, one to start the verification and another to check the final code. In this sample code we expose those endpoints via an `Api` module that will call each endpoint via a separate function.
|
|
83
|
+
|
|
84
|
+
When calling the verification API, you will need to provide the phone number to verify. The API will return a request URL that the SDK will navigate to in order to complete the verification process.
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
// Import the SDK types and your API module
|
|
88
|
+
import * as PreludeReactNativeSdk from '@prelude.so/react-native-sdk';
|
|
89
|
+
import * as Api from './YourBackendApi';
|
|
90
|
+
|
|
91
|
+
// Call the verification endpoint with the phone number.
|
|
92
|
+
// If the phone number is compatible with the Silent Verification feature,
|
|
93
|
+
// the API will return a request URL that the SDK will navigate to.
|
|
94
|
+
const request_url = await Api.verify(phone_number);
|
|
95
|
+
|
|
96
|
+
// Then call the verifySilent method with the SDK key and the request URL.
|
|
97
|
+
// If the verification is successful, the SDK will return a code that you
|
|
98
|
+
// can use to check the verification status.
|
|
99
|
+
var code = await PreludeReactNativeSdk.verifySilent({
|
|
100
|
+
sdk_key: sdk_key,
|
|
101
|
+
request_url: request_url,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Finally, call the checkSilent method with the phone number and the code
|
|
105
|
+
// Your API should handle the check and return the verification status.
|
|
106
|
+
const check_status = await Api.check(phone_number, code);
|
|
107
|
+
|
|
108
|
+
// Handle the verification status as needed in your application
|
|
109
|
+
```
|
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.2'
|
|
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.2')
|
|
47
48
|
}
|
|
@@ -6,47 +6,61 @@ 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
8
|
import so.prelude.android.sdk.Endpoint
|
|
9
|
+
import so.prelude.android.sdk.Features
|
|
9
10
|
import so.prelude.android.sdk.Prelude
|
|
10
11
|
import java.net.URL
|
|
11
12
|
|
|
12
13
|
class PreludeReactNativeSdkModule : Module() {
|
|
13
|
-
override fun definition() =
|
|
14
|
-
|
|
14
|
+
override fun definition() =
|
|
15
|
+
ModuleDefinition {
|
|
16
|
+
Name("PreludeReactNativeSdk")
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
}
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
AsyncFunction("verifySilent") Coroutine { sdkKey: String, requestUrl: String ->
|
|
28
|
+
verifySilent(
|
|
29
|
+
sdkKey = sdkKey,
|
|
30
|
+
requestUrl = requestUrl,
|
|
31
|
+
)
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
|
-
}
|
|
27
34
|
|
|
28
35
|
private suspend fun dispatchSignals(
|
|
29
36
|
endpointUrl: String?,
|
|
30
37
|
sdkKey: String,
|
|
31
|
-
timeoutMilliseconds: Long
|
|
38
|
+
timeoutMilliseconds: Long?,
|
|
39
|
+
implementedFeaturesRawValue: Long = 0L,
|
|
32
40
|
): String {
|
|
33
|
-
val endpoint: Endpoint =
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
val endpoint: Endpoint =
|
|
42
|
+
endpointUrl?.let {
|
|
43
|
+
Endpoint.Custom(
|
|
44
|
+
address = it,
|
|
45
|
+
)
|
|
46
|
+
} ?: Endpoint.Default
|
|
36
47
|
|
|
37
|
-
val context =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
val context =
|
|
49
|
+
appContext.reactContext
|
|
50
|
+
?: throw IllegalStateException(
|
|
51
|
+
"Invalid React Android Context. Cannot dispatch signals",
|
|
52
|
+
)
|
|
41
53
|
|
|
42
|
-
val config =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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),
|
|
61
|
+
)
|
|
48
62
|
val prelude = Prelude(config)
|
|
49
|
-
|
|
63
|
+
|
|
50
64
|
return prelude.dispatchSignals().getOrThrow()
|
|
51
65
|
}
|
|
52
66
|
|
|
@@ -54,10 +68,11 @@ class PreludeReactNativeSdkModule : Module() {
|
|
|
54
68
|
sdkKey: String,
|
|
55
69
|
requestUrl: String,
|
|
56
70
|
): String {
|
|
57
|
-
val context =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
val context =
|
|
72
|
+
appContext.reactContext
|
|
73
|
+
?: throw IllegalStateException(
|
|
74
|
+
"Invalid React Android Context. Cannot perform silent verification",
|
|
75
|
+
)
|
|
61
76
|
|
|
62
77
|
if (sdkKey.isBlank() || requestUrl.isBlank()) {
|
|
63
78
|
throw IllegalArgumentException("SDK Key and Request URL must both be provided.")
|
package/build/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export declare function dispatchSignals(configuration
|
|
1
|
+
export declare function dispatchSignals(configuration?: {
|
|
2
2
|
sdk_key: string;
|
|
3
3
|
endpoint?: string;
|
|
4
4
|
timeout_milliseconds?: number;
|
|
5
|
+
implemented_features?: Features[];
|
|
5
6
|
}): Promise<string>;
|
|
6
7
|
export declare function verifySilent(configuration: {
|
|
7
8
|
sdk_key: string;
|
|
8
9
|
request_url: string;
|
|
9
10
|
}): Promise<string>;
|
|
11
|
+
export declare enum Features {
|
|
12
|
+
SilentVerification = 1
|
|
13
|
+
}
|
|
10
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":"AAEA,wBAAsB,eAAe,CACnC,aAAa,
|
|
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,8 +1,15 @@
|
|
|
1
1
|
import PreludeReactNativeSdkModule from './PreludeReactNativeSdkModule';
|
|
2
|
-
export async function dispatchSignals(configuration) {
|
|
3
|
-
return await PreludeReactNativeSdkModule.dispatchSignals(configuration.sdk_key, configuration.endpoint, configuration.timeout_milliseconds);
|
|
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 || []));
|
|
4
4
|
}
|
|
5
5
|
export async function verifySilent(configuration) {
|
|
6
6
|
return await PreludeReactNativeSdkModule.verifySilent(configuration.sdk_key, configuration.request_url);
|
|
7
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
|
+
}
|
|
8
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":"AAAA,OAAO,2BAA2B,MAAM,+BAA+B,CAAC;AAExE,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,
|
|
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,46 +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
|
-
throw Exception(name: "IllegalArguments",
|
|
25
|
-
description: "SDK Key and Request URL must both be provided.",
|
|
26
|
-
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
|
|
27
24
|
)
|
|
25
|
+
|
|
26
|
+
let prelude = Prelude(configuration)
|
|
27
|
+
|
|
28
|
+
return try await prelude.dispatchSignals()
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
let configuration = Configuration(
|
|
31
|
-
sdkKey: sdkKey,
|
|
32
|
-
)
|
|
33
30
|
|
|
34
|
-
|
|
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
|
+
}
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
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)
|
|
41
53
|
}
|
|
42
|
-
|
|
43
|
-
return try await prelude.verifySilent(url: url)
|
|
44
54
|
}
|
|
45
|
-
}
|
|
46
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prelude.so/react-native-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Prelude SDK for React Native",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -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.3"
|
|
57
57
|
}
|
|
58
58
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,10 +5,24 @@ export async function dispatchSignals(
|
|
|
5
5
|
sdk_key: string;
|
|
6
6
|
endpoint?: string;
|
|
7
7
|
timeout_milliseconds?: number;
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
);
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
export async function verifySilent(configuration: { sdk_key: string, request_url: string }): Promise<string> {
|
|
13
19
|
return await PreludeReactNativeSdkModule.verifySilent(configuration.sdk_key, configuration.request_url);
|
|
14
20
|
}
|
|
21
|
+
|
|
22
|
+
export enum Features {
|
|
23
|
+
SilentVerification = 1 << 0,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function toRawValue(features: Features[]): number {
|
|
27
|
+
return features.reduce((acc, feature) => acc | feature, 0);
|
|
28
|
+
}
|