Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ Optional permissions (requested by specific providers at runtime):
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
```

To use Reclaim InAppSdk in your project, follow the [Usage guide](/android/usage).
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -45,46 +45,10 @@ ReclaimVerification.startVerification(
)
```

## Example

[Complete Android example](https://github.com/reclaimprotocol/reclaim-inapp-android-sdk/tree/main/example) with Jetpack Compose

# Advanced Options
## Complete Request Parameters

```kotlin
val request = ReclaimVerification.Request(
// Required
appId = "YOUR_APP_ID",
secret = "YOUR_APP_SECRET",
providerId = "YOUR_PROVIDER_ID",
The returned result `ReclaimVerification.ResultHandler.onResponse` in is a `ReclaimVerification.Response` object. This object contains a response that has proofs, exception, and the sessionId if the verification is successful.

// Optional
session = ReclaimVerification.ReclaimSessionInformation(
sessionId = "session-id",
timestamp = "1234567890",
signature = "signature"
),
If the verification is cancelled or failed, the handler's `ReclaimVerification.ResultHandler.onException` method is called with a `ReclaimVerification.ReclaimVerificationException` object.

contextString = "additional-context", // Additional context data

parameters = mapOf( // Custom provider parameters
"customParam" to "value"
),

providerVersion = ReclaimVerification.Request // Specify provider version
.ProviderVersion.resolved("1.0.0")
)
```

## Troubleshooting

### Cronet Errors (Devices without Google Play Services)

If you see Cronet-related errors on devices without Play Services, add embedded Cronet:
## Example

```gradle
dependencies {
implementation("org.chromium.net:cronet-embedded:141.7340.3")
}
```
[Complete Android example](https://github.com/reclaimprotocol/reclaim-inapp-android-sdk/tree/main/example) with Jetpack Compose
53 changes: 37 additions & 16 deletions content/docs/flutter/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Installation
description: Flutter SDK for Reclaim Protocol
---

import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';

## Prerequisites
- An Android device or emulator running Android 5.0 or later.

Expand All @@ -14,15 +16,18 @@ Setup your project using the [Get API Key guide](/api-key).
### Using Flutter CLI

```bash
flutter pub add reclaim_inapp_sdk
flutter pub add https://github.com/reclaimprotocol/reclaim-inapp-flutter-sdk.git
```

### Manual Installation

Add the following to your `pubspec.yaml`:
```yaml
dependencies:
reclaim_inapp_sdk: ^latest_version
reclaim_inapp_flutter_sdk:
git:
url: https://github.com/reclaimprotocol/reclaim-inapp-flutter-sdk.git
ref: 0.15.0
```

Then run:
Expand All @@ -41,28 +46,44 @@ Update your `android/app/build.gradle`:
```gradle
android {
defaultConfig {
minSdkVersion 21 // Minimum Android 5.0
targetSdkVersion 34
minSdkVersion 24
targetSdkVersion 36
}
}
```

#### Cronet for Devices Without Play Services

If you need to support Android devices without Google Play Services, add the embedded Cronet library:

```gradle
dependencies {
// Use embedded cronet for devices without play services
implementation("org.chromium.net:cronet-embedded:119.6045.31")
}
```

### iOS Configuration

Update your `ios/Podfile`:

```ruby
platform :ios, '13.0' # Minimum iOS 13.0
platform :ios, '14.0'
```

#### Update Environment Variables for XCScheme

<Accordions>
<Accordion title="Updating Environment Variables for XCScheme">

1. Open your project in Xcode.
2. Click on the project target.
3. Click on the **Scheme** dropdown.

<img src="https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk/raw/53a19f88c8d90df485a60dc20190f740cd9fd108/Screenshots/Install/10.png" alt="Edit current xcscheme in Xcode" width="500" />

4. Click on the **Edit Scheme** button.
5. Click on the **Run** tab.
6. Click on the **Arguments** tab and check the **Environment Variables** section.

<img src="https://github.com/reclaimprotocol/reclaim-inapp-ios-sdk/raw/53a19f88c8d90df485a60dc20190f740cd9fd108/Screenshots/Install/12.png" alt="Enable Debug executable in Xcode" width="500" />

7. Add the following environment variable:
- Key: `GODEBUG`
- Value: `asyncpreemptoff=1`
8. Click on the **Close** button in the dialog and build the project.
9. Run the app on a physical device.

</Accordion>
</Accordions>

To use Reclaim InAppSdk in your project, follow the [Usage guide](/flutter/usage).
13 changes: 12 additions & 1 deletion content/docs/flutter/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const String providerId = String.fromEnvironment('PROVIDER_ID');
- You can get the `APP_ID` and `APP_SECRET` using [this guide](/api-key)
- The `PROVIDER_ID` is the proof you want the user to generate. You can see all the [available providers here](https://dev.reclaimprotocol.org/explore).


## Starting Verification
Create a `ReclaimVerification` instance from your BuildContext:

Expand All @@ -46,6 +45,18 @@ final proofs = result.proofs;
print('Received ${proofs.length} proofs');
```

### Pre-warming

For better performance, you can pre-warm the SDK before use:

```dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
ReclaimInAppSdk.preWarm();
runApp(MyApp());
}
```

## Verifying proofs

The `startVerification()` method returns a `ReclaimVerificationResult` containing:
Expand Down
195 changes: 195 additions & 0 deletions content/docs/inapp-sdks/advanced/attestor-auth.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
---
title: Attestor Authentication
description: Reclaim Protocol's InApp SDKs setup when using an attestor with authentication
---

import { Tab, Tabs } from 'fumadocs-ui/components/tabs';

# Get Started

A private attestor can have authentication enabled which blocks all un-authenticated connections and can also be used to limit the hosts that can be connected to. InApp SDKs can be configured to use another attestor and include an auth request in the claim sent to this attestor.

Read more about [attestors authentication here](https://github.com/reclaimprotocol/attestor-core/blob/main/docs/run-server.md#enabling-authentication).

## Basic Usage

An auth request can be created anywhere, even on your server. JS library @reclaimprotocol/attestor-core from npm can be used for creating an auth request.

```typescript
import { createAuthRequest, B64_JSON_REPLACER } from '@reclaimprotocol/attestor-core'

// this can happen on another server, on the client or anywhere you'd
// like
const authRequest = await createAuthRequest(
{
// optional user ID -- to identify the user
// all logs on the backend will be tagged with this
id: 'optional-user-id',
// only allow the user to tunnel requests to one of
// these hosts
hostWhitelist: ['github.com', 'example.com']
},
keyPairs.privateKey
)
const yourAttestorAuthRequest = JSON.stringify(
authRequest,
B64_JSON_REPLACER,
2
)
console.info({ yourAttestorAuthRequest });
```

An auth request looks like this:

```json
{
"data": {
"userId": "optional-user-id",
"hostWhitelist": ["api.abcd.xyz"]
},
"signature": {
"type": "uint8array",
"value": "base64-encoded-signature"
}
}
```

This can be used in the `setVerificationOptions` method of the InApp SDK, which allows you to set a callback for providing an auth request to the attestor.


<Tabs items={['Typescript', 'Kotlin', 'Swift']}>
```typescript tabs="Typescript"
const reclaimVerification = new ReclaimVerification();

// This is how you may be using a different attestor with overrides
await reclaimVerification.setOverrides({
featureOptions: {
// overridden attestor browser rpc url
attestorBrowserRpcUrl: 'https://myattestor.example.org/browser-rpc',
// other overrides (removed for brevity)
},
});

// Provide a callback to provide attestor auth request.
await reclaimVerification.setVerificationOptions({
fetchAttestorAuthenticationRequest: async (providerInformationJsonString: string) => {
// sample attestor auth request
return JSON.stringify({
"data": {
"createdAt": 1741648166,
"expiresAt": 1741649066,
"id": "optional-user-id",
"hostWhitelist": [
"github.com",
"example.com"
]
},
"signature": {
"type": "uint8array",
"value": "gSCbBMZSdNJjrxGUTPoERj5S8jtkwQEnGWmmMXx+j3wrd7pspRkfhE96DauFQTVcp+ErB7zWaBDAWwThOu4Fkxw="
}
});
},
});
```

```kotlin tabs="Kotlin"
ReclaimVerification.setOverrides(
context = context,
featureOptions = ReclaimOverrides.FeatureOptions(
// overridden attestor browser rpc url
attestorBrowserRpcUrl = "https://myattestor.example.org/browser-rpc"
// other overrides (removed for brevity)
)
) { result ->
result
.onSuccess {
Log.d("MainActivity", "Reclaim Overrides set")
}
.onFailure { e ->
Log.e("MainActivity", "Could not set overrides", e)
}
}

ReclaimVerification.setVerificationOptions(
context = context,
options = ReclaimVerification.VerificationOptions(
attestorAuthRequestProvider = object : ReclaimVerification.VerificationOptions.AttestorAuthRequestProvider {
override fun fetchAttestorAuthenticationRequest(
reclaimHttpProvider: Map<Any?, Any?>,
callback: (Result<String>) -> Unit
) {
// sample attestor auth request
callback(Result.success("""
{
"data": {
"createdAt": 1741648166,
"expiresAt": 1741649066,
"id": "optional-user-id",
"hostWhitelist": [
"github.com",
"example.com"
]
},
"signature": {
"type": "uint8array",
"value": "gSCbBMZSdNJjrxGUTPoERj5S8jtkwQEnGWmmMXx+j3wrd7pspRkfhE96DauFQTVcp+ErB7zWaBDAWwThOu4Fkxw="
}
}
""".trimIndent()))
}
}
)
) { result ->
result
.onSuccess {
Log.d("MainActivity", "Reclaim Verification options set")
}
.onFailure { e ->
Log.e("MainActivity", "Could not set verification options", e)
}
}
```

```swift tabs="Swift"
// This is how you may be using a different attestor with overrides
try await ReclaimVerification.setOverrides(
featureOptions: .init(
// overridden attestor browser rpc url
attestorBrowserRpcUrl: "https://myattestor.example.org/browser-rpc"
// other overrides (removed for brevity)
)
)

class AttestorAuthRequestProviderImpl : ReclaimVerification.VerificationOptions.AttestorAuthRequestProvider {
func fetchAttestorAuthenticationRequest(
reclaimHttpProvider: [AnyHashable?: (any Sendable)?],
completion: @escaping (Result<String, any Error>) -> Void
) {
// sample attestor auth request
completion(.success("""
{
"data": {
"createdAt": 1741648166,
"expiresAt": 1741649066,
"id": "optional-user-id",
"hostWhitelist": [
"github.com",
"example.com"
]
},
"signature": {
"type": "uint8array",
"value": "gSCbBMZSdNJjrxGUTPoERj5S8jtkwQEnGWmmMXx+j3wrd7pspRkfhE96DauFQTVcp+ErB7zWaBDAWwThOu4Fkxw="
}
}
"""))
}
}

try await ReclaimVerification.setVerificationOptions(options: .init(
attestorAuthRequestProvider: AttestorAuthRequestProviderImpl()
))
```

</Tabs>
14 changes: 14 additions & 0 deletions content/docs/inapp-sdks/advanced/intro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Usage
description: Documentation for advanced usage of Reclaim InApp SDKs.
---

# More about Reclaim InApp SDKs

The InApp SDKs also allows more functionalities, like overriding several configurations used in the verification process by the SDK.

## Table of Contents

* [Verification Options](./verification-options)
* [Attestor Auth](./attestor-auth)
* [Overrides](./overrides)
9 changes: 9 additions & 0 deletions content/docs/inapp-sdks/advanced/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"title": "Usage",
"pages": [
"intro",
"verification-options",
"attestor-auth",
"overrides"
]
}
Loading