Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

Repository files navigation

FunEncryptSDK

JitPack

FunEncryptSDK is a library that builds the headers for your API calls. It returns the encrypted API token along with all the required headers for the API call. Developers can easily integrate this dependency in their projects and encrypt their API tokens for better security and get all the required Headers.

Requires: minSdk 24, Kotlin 2.0+, and Firebase set up in your app.

Get Started

1. Add the dependency

Add maven repository in project level build.gradle or in latest project settings.gradle.kts file

repositories {
    google()
    mavenCentral()
    maven("https://jitpack.io") 
}

app/build.gradle.kts

dependencies {
    implementation("com.github.Funsol-Projects:FunEncryptSDK:v1.3")
}

Groovy: maven { url 'https://jitpack.io' } and implementation 'com.github.Funsol-Projects:FunEncryptSDK:v1.3'.

2. Get the headers

import com.example.funsolauthenticationsdk.GetEncryptedHeaders
import com.example.funsolauthenticationsdk.HeaderResult

GetEncryptedHeaders.getHeaders(context, "api_headers") { result ->
    when (result) {
        is HeaderResult.Success -> api.getUsers(result.headers).enqueue(callback)
        is HeaderResult.Error -> Log.e("FunEncrypt", result.type.message, result.exception)
    }
}

3. Example API Call Function

Example API Call function. This is how you will make parameter for the HeadersMap inside your API call function and then pass the HeadersMap which you got in return from the above getHeaders method.

// Retrofit
@GET("users")
fun getUsers(@HeaderMap headers: Map<String, String>): Call<List<User>>

result.headers contains:

Header Value
Authorization token <encrypted token>
X-RES-APP-ID app_id from the JSON
X-APP-ID Your applicationId, including any suffix such as .debug
X-APP-VERSION Your versionName
X-VERSION-NUMBER Your versionCode

Java: GetEncryptedHeaders.INSTANCE.getHeaders(context, "api_headers", result -> { ...; return kotlin.Unit.INSTANCE; });

Good to know

  • Get fresh ones before each request; don't store them. The device clock must be correct.
  • Each call sets your app's default FirebaseRemoteConfig minimum fetch interval to 0 and activates newly fetched values, which also affects your app's own Remote Config use.

Errors

HeaderResult.Error has a type (with a readable message) and an optional exception.

type Cause
REMOTE_CONFIG_FETCH_FAILED All 5 fetch attempts failed: no network, Firebase misconfigured, or Firebase throttling frequent fetches.
EMPTY_REMOTE_CONFIG Wrong parameter name, changes not published, or empty value.
MISSING_KEY / MISSING_IV / MISSING_TOKEN / MISSING_APP_ID That field is missing or empty in the JSON.
TOKEN_MODIFICATION_ERROR The token value is too short.
UNKNOWN_ERROR The value is not valid JSON, or your callback threw, in which case it is called a second time with this error. See result.exception.
PACKAGE_INFO_ERROR / ENCRYPTION_ERROR Unexpected failure. See result.exception.

License

MIT License

Copyright (c) [2025]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages