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
|
||||
|
||||
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")
|
||||
return digest.digest(data)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,11 @@ public class ExpoBlueskyOAuthClientModule: Module {
|
||||
public func definition() -> ModuleDefinition {
|
||||
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))
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ export class ReactNativeCryptoImplementation implements CryptoImplementation {
|
||||
bytes: Uint8Array,
|
||||
algorithm: DigestAlgorithm,
|
||||
): Promise<Uint8Array> {
|
||||
console.log(algorithm)
|
||||
return OauthClientReactNative.digest(bytes, algorithm.name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user