-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from tw-mosip/update-API-def
Update Tuvali API definitions (Move away from Google Nearby API definitions)
- Loading branch information
Showing
60 changed files
with
1,023 additions
and
39,057 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
android/src/main/java/io/mosip/tuvali/common/advertisementPayload/AdvertisementPayload.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.mosip.tuvali.common.advertisementPayload | ||
|
||
import org.bouncycastle.util.encoders.Hex | ||
|
||
class AdvertisementPayload { | ||
companion object { | ||
fun getAdvPayload(identifier: String, key: ByteArray): ByteArray { | ||
return identifier.toByteArray() + "_".toByteArray() + key.copyOfRange(0, 5) | ||
} | ||
|
||
fun getAdvPayload(identifier: String, hexKey: String): ByteArray { | ||
val key = Hex.decode(hexKey) | ||
return getAdvPayload(identifier, key) | ||
} | ||
|
||
fun getScanRespPayload(key: ByteArray): ByteArray { | ||
return key.copyOfRange(5, 32) | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
android/src/main/java/io/mosip/tuvali/common/uri/openId4vpURI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.mosip.tuvali.common.uri | ||
|
||
import android.net.Uri | ||
import android.text.TextUtils.isEmpty | ||
|
||
private const val URI_IDENTIFIER = "OPENID4VP" | ||
private const val NAME_QUERY_PARAM_NAME = "name" | ||
private const val KEY_QUERY_PARAM_NAME = "key" | ||
|
||
class OpenId4vpURI { | ||
private var uri: Uri | ||
|
||
constructor(name: String, hexPK: String) { | ||
this.uri = Uri.Builder() | ||
.scheme("$URI_IDENTIFIER://connect") | ||
.appendQueryParameter(NAME_QUERY_PARAM_NAME, name) | ||
.appendQueryParameter(KEY_QUERY_PARAM_NAME, hexPK).build() | ||
} | ||
|
||
constructor(uri: String) { | ||
try { | ||
this.uri = Uri.parse(uri) | ||
} catch (e: Exception) { | ||
this.uri = Uri.EMPTY | ||
} | ||
} | ||
|
||
fun getName() = uri.getQueryParameter(NAME_QUERY_PARAM_NAME).orEmpty() | ||
|
||
fun getHexPK() = uri.getQueryParameter(KEY_QUERY_PARAM_NAME).orEmpty() | ||
|
||
fun isValid() = !(isEmpty(getName()) || isEmpty(getHexPK())) | ||
|
||
override fun toString() = uri.toString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.