Merge branch 'hailey/expo-oauth-helper' into hailey/oauth
This commit is contained in:
+2
-1
@@ -11,7 +11,8 @@ import com.nimbusds.jose.jwk.KeyUse
|
|||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
class CryptoUtil {
|
class CryptoUtil {
|
||||||
fun digest(data: ByteArray): ByteArray {
|
fun digest(data: ByteArray, algorithmName: String): ByteArray {
|
||||||
|
if(algorithmName != "sha256") throw Exception("Unsupported algorithm")
|
||||||
val digest = MessageDigest.getInstance("sha256")
|
val digest = MessageDigest.getInstance("sha256")
|
||||||
return digest.digest(data)
|
return digest.digest(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,11 @@ public class ExpoBlueskyOAuthClientModule: Module {
|
|||||||
public func definition() -> ModuleDefinition {
|
public func definition() -> ModuleDefinition {
|
||||||
Name("ExpoBlueskyOAuthClient")
|
Name("ExpoBlueskyOAuthClient")
|
||||||
|
|
||||||
AsyncFunction("digest") { (data: Data, promise: Promise) in
|
AsyncFunction("digest") { (data: Data, algorithmName: String, promise: Promise) in
|
||||||
|
if algorithmName != "sha256" {
|
||||||
|
promise.reject("Error", "Algorithim not supported")
|
||||||
|
return
|
||||||
|
}
|
||||||
promise.resolve(CryptoUtil.digest(data: data))
|
promise.resolve(CryptoUtil.digest(data: data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export class ReactNativeCryptoImplementation implements CryptoImplementation {
|
|||||||
bytes: Uint8Array,
|
bytes: Uint8Array,
|
||||||
algorithm: DigestAlgorithm,
|
algorithm: DigestAlgorithm,
|
||||||
): Promise<Uint8Array> {
|
): Promise<Uint8Array> {
|
||||||
|
console.log(algorithm)
|
||||||
return OauthClientReactNative.digest(bytes, algorithm.name)
|
return OauthClientReactNative.digest(bytes, algorithm.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user