expo-crypto 9.1.0 → 10.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/android/build.gradle +30 -14
- package/android/src/main/java/expo/modules/crypto/CryptoModule.kt +46 -0
- package/android/src/main/java/expo/modules/crypto/CryptoPackage.kt +9 -0
- package/build/Crypto.js +2 -2
- package/build/Crypto.js.map +1 -1
- package/build/ExpoCrypto.d.ts +1 -1
- package/build/ExpoCrypto.js +1 -1
- package/build/ExpoCrypto.js.map +1 -1
- package/build/ExpoCrypto.web.js +2 -2
- package/build/ExpoCrypto.web.js.map +1 -1
- package/ios/EXCrypto/EXCrypto.h +2 -2
- package/ios/EXCrypto/EXCrypto.m +4 -4
- package/ios/EXCrypto.podspec +3 -2
- package/package.json +5 -5
- package/src/Crypto.ts +1 -1
- package/src/ExpoCrypto.ts +1 -1
- package/src/ExpoCrypto.web.ts +2 -2
- package/android/src/main/java/expo/modules/crypto/CryptoModule.java +0 -59
- package/android/src/main/java/expo/modules/crypto/CryptoPackage.java +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,42 @@
|
|
|
8
8
|
|
|
9
9
|
### 🐛 Bug fixes
|
|
10
10
|
|
|
11
|
+
### 💡 Others
|
|
12
|
+
|
|
13
|
+
## 10.0.2 — 2021-10-15
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 10.0.1 — 2021-10-01
|
|
18
|
+
|
|
19
|
+
_This version does not introduce any user-facing changes._
|
|
20
|
+
|
|
21
|
+
## 10.0.0 — 2021-09-28
|
|
22
|
+
|
|
23
|
+
### 🛠 Breaking changes
|
|
24
|
+
|
|
25
|
+
- Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach))
|
|
26
|
+
|
|
27
|
+
### 🐛 Bug fixes
|
|
28
|
+
|
|
29
|
+
- Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo))
|
|
30
|
+
|
|
31
|
+
### 💡 Others
|
|
32
|
+
|
|
33
|
+
- Rewrite Android code to Kotlin. ([#14425](https://github.com/expo/expo/pull/14425) by [@kkafar](https://github.com/kkafar))
|
|
34
|
+
- Add tests. ([#13592](https://github.com/expo/expo/pull/13592) by [@mstach60161](https://github.com/mstach60161))
|
|
35
|
+
- Migrated from `@unimodules/core` to `expo-modules-core`. ([#13757](https://github.com/expo/expo/pull/13757) by [@tsapeta](https://github.com/tsapeta))
|
|
36
|
+
|
|
37
|
+
## 9.2.0 — 2021-06-16
|
|
38
|
+
|
|
39
|
+
### 🐛 Bug fixes
|
|
40
|
+
|
|
41
|
+
- Enable kotlin in all modules. ([#12716](https://github.com/expo/expo/pull/12716) by [@wschurman](https://github.com/wschurman))
|
|
42
|
+
|
|
43
|
+
### 💡 Others
|
|
44
|
+
|
|
45
|
+
- Build Android code using Java 8 to fix Android instrumented test build error. ([#12939](https://github.com/expo/expo/pull/12939) by [@kudo](https://github.com/kudo))
|
|
46
|
+
|
|
11
47
|
## 9.1.0 — 2021-03-10
|
|
12
48
|
|
|
13
49
|
### 🎉 New features
|
package/android/build.gradle
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'kotlin-android'
|
|
2
3
|
apply plugin: 'maven'
|
|
3
4
|
|
|
4
5
|
group = 'host.exp.exponent'
|
|
5
|
-
version = '
|
|
6
|
+
version = '10.0.2'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
buildscript {
|
|
9
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
10
|
+
ext.safeExtGet = { prop, fallback ->
|
|
11
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
repositories {
|
|
15
|
+
mavenCentral()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
dependencies {
|
|
19
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.21')}")
|
|
20
|
+
}
|
|
10
21
|
}
|
|
11
22
|
|
|
12
23
|
// Upload android library to maven with javadoc and android sources
|
|
@@ -37,25 +48,30 @@ uploadArchives {
|
|
|
37
48
|
android {
|
|
38
49
|
compileSdkVersion safeExtGet("compileSdkVersion", 30)
|
|
39
50
|
|
|
51
|
+
compileOptions {
|
|
52
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
53
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
54
|
+
}
|
|
55
|
+
|
|
40
56
|
defaultConfig {
|
|
41
57
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
42
58
|
targetSdkVersion safeExtGet("targetSdkVersion", 30)
|
|
43
59
|
versionCode 25
|
|
44
|
-
versionName "
|
|
60
|
+
versionName "10.0.2"
|
|
45
61
|
}
|
|
46
62
|
lintOptions {
|
|
47
63
|
abortOnError false
|
|
48
64
|
}
|
|
49
65
|
}
|
|
50
66
|
|
|
51
|
-
if (new File(rootProject.projectDir.parentFile, 'package.json').exists()) {
|
|
52
|
-
apply from: project(":unimodules-core").file("../unimodules-core.gradle")
|
|
53
|
-
} else {
|
|
54
|
-
throw new GradleException(
|
|
55
|
-
"'unimodules-core.gradle' was not found in the usual React Native dependency location. " +
|
|
56
|
-
"This package can only be used in such projects. Are you sure you've installed the dependencies properly?")
|
|
57
|
-
}
|
|
58
|
-
|
|
59
67
|
dependencies {
|
|
60
|
-
|
|
68
|
+
implementation project(':expo-modules-core')
|
|
69
|
+
|
|
70
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
|
|
71
|
+
|
|
72
|
+
if (project.findProject(':unimodules-test-core')) {
|
|
73
|
+
testImplementation project(':unimodules-test-core')
|
|
74
|
+
}
|
|
75
|
+
testImplementation 'junit:junit:4.12'
|
|
76
|
+
testImplementation "org.robolectric:robolectric:4.3.1"
|
|
61
77
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
package expo.modules.crypto
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.util.Base64
|
|
5
|
+
|
|
6
|
+
import expo.modules.core.ExportedModule
|
|
7
|
+
import expo.modules.core.Promise
|
|
8
|
+
import expo.modules.core.interfaces.ExpoMethod
|
|
9
|
+
|
|
10
|
+
import java.security.MessageDigest
|
|
11
|
+
import java.security.NoSuchAlgorithmException
|
|
12
|
+
|
|
13
|
+
class CryptoModule(context: Context) : ExportedModule(context) {
|
|
14
|
+
override fun getName() = "ExpoCrypto"
|
|
15
|
+
|
|
16
|
+
@ExpoMethod
|
|
17
|
+
fun digestStringAsync(algorithm: String, data: String, options: Map<String, Any?>, promise: Promise) {
|
|
18
|
+
val encoding = options["encoding"] as String?
|
|
19
|
+
|
|
20
|
+
val messageDigest = try {
|
|
21
|
+
MessageDigest.getInstance(algorithm).apply { update(data.toByteArray()) }
|
|
22
|
+
} catch (e: NoSuchAlgorithmException) {
|
|
23
|
+
promise.reject("ERR_CRYPTO_DIGEST", e)
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
val digest: ByteArray = messageDigest.digest()
|
|
28
|
+
when (encoding) {
|
|
29
|
+
"base64" -> {
|
|
30
|
+
val output = Base64.encodeToString(digest, Base64.NO_WRAP)
|
|
31
|
+
promise.resolve(output)
|
|
32
|
+
}
|
|
33
|
+
"hex" -> {
|
|
34
|
+
val output = digest.joinToString(separator = "") { byte ->
|
|
35
|
+
((byte.toInt() and 0xff) + 0x100)
|
|
36
|
+
.toString(radix = 16)
|
|
37
|
+
.substring(startIndex = 1)
|
|
38
|
+
}
|
|
39
|
+
promise.resolve(output)
|
|
40
|
+
}
|
|
41
|
+
else -> {
|
|
42
|
+
promise.reject("ERR_CRYPTO_DIGEST", "Invalid encoding type provided.")
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package expo.modules.crypto
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import expo.modules.core.BasePackage
|
|
5
|
+
import expo.modules.core.ExportedModule
|
|
6
|
+
|
|
7
|
+
class CryptoPackage : BasePackage() {
|
|
8
|
+
override fun createExportedModules(context: Context): List<ExportedModule> = listOf(CryptoModule(context))
|
|
9
|
+
}
|
package/build/Crypto.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { UnavailabilityError } from '
|
|
1
|
+
import { UnavailabilityError } from 'expo-modules-core';
|
|
2
2
|
import { CryptoDigestAlgorithm, CryptoEncoding } from './Crypto.types';
|
|
3
3
|
import ExpoCrypto from './ExpoCrypto';
|
|
4
4
|
export * from './Crypto.types';
|
|
5
5
|
class CryptoError extends TypeError {
|
|
6
|
+
code = 'ERR_CRYPTO';
|
|
6
7
|
constructor(message) {
|
|
7
8
|
super(`expo-crypto: ${message}`);
|
|
8
|
-
this.code = 'ERR_CRYPTO';
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
function assertAlgorithm(algorithm) {
|
package/build/Crypto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../src/Crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../src/Crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAA+B,MAAM,gBAAgB,CAAC;AACpG,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,cAAc,gBAAgB,CAAC;AAE/B,MAAM,WAAY,SAAQ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O,CAAC,CAAC;AACtE,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { CryptoDigestAlgorithm, CryptoEncoding, CryptoDigestOptions, Digest } from './Crypto.types';\nimport ExpoCrypto from './ExpoCrypto';\n\nexport * from './Crypto.types';\n\nclass CryptoError extends TypeError {\n code = 'ERR_CRYPTO';\n\n constructor(message: string) {\n super(`expo-crypto: ${message}`);\n }\n}\n\nfunction assertAlgorithm(algorithm: CryptoDigestAlgorithm): void {\n if (!Object.values(CryptoDigestAlgorithm).includes(algorithm)) {\n throw new CryptoError(\n `Invalid algorithm provided. Expected one of: CryptoDigestAlgorithm.${Object.keys(\n CryptoDigestAlgorithm\n ).join(', AlgCryptoDigestAlgorithmorithm.')}`\n );\n }\n}\n\nfunction assertData(data: string): void {\n if (typeof data !== 'string') {\n throw new CryptoError(`Invalid data provided. Expected a string.`);\n }\n}\n\nfunction assertEncoding(encoding: CryptoEncoding): void {\n if (!Object.values(CryptoEncoding).includes(encoding)) {\n throw new CryptoError(\n `Invalid encoding provided. Expected one of: CryptoEncoding.${Object.keys(\n CryptoEncoding\n ).join(', CryptoEncoding.')}`\n );\n }\n}\n\nexport async function digestStringAsync(\n algorithm: CryptoDigestAlgorithm,\n data: string,\n options: CryptoDigestOptions = { encoding: CryptoEncoding.HEX }\n): Promise<Digest> {\n if (!ExpoCrypto.digestStringAsync) {\n throw new UnavailabilityError('expo-crypto', 'digestStringAsync');\n }\n\n assertAlgorithm(algorithm);\n assertData(data);\n assertEncoding(options.encoding);\n\n return await ExpoCrypto.digestStringAsync(algorithm, data, options);\n}\n"]}
|
package/build/ExpoCrypto.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("
|
|
1
|
+
declare const _default: import("expo-modules-core").ProxyNativeModule;
|
|
2
2
|
export default _default;
|
package/build/ExpoCrypto.js
CHANGED
package/build/ExpoCrypto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoCrypto.js","sourceRoot":"","sources":["../src/ExpoCrypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ExpoCrypto.js","sourceRoot":"","sources":["../src/ExpoCrypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,eAAe,kBAAkB,CAAC,UAAU,CAAC","sourcesContent":["import { NativeModulesProxy } from 'expo-modules-core';\nexport default NativeModulesProxy.ExpoCrypto;\n"]}
|
package/build/ExpoCrypto.web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodedError } from '
|
|
1
|
+
import { CodedError } from 'expo-modules-core';
|
|
2
2
|
import { CryptoEncoding } from './Crypto.types';
|
|
3
3
|
export default {
|
|
4
4
|
get name() {
|
|
@@ -22,7 +22,7 @@ export default {
|
|
|
22
22
|
};
|
|
23
23
|
function hexString(buffer) {
|
|
24
24
|
const byteArray = new Uint8Array(buffer);
|
|
25
|
-
const hexCodes = [...byteArray].map(value => {
|
|
25
|
+
const hexCodes = [...byteArray].map((value) => {
|
|
26
26
|
const hexCode = value.toString(16);
|
|
27
27
|
const paddedHexCode = hexCode.padStart(2, '0');
|
|
28
28
|
return paddedHexCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoCrypto.web.js","sourceRoot":"","sources":["../src/ExpoCrypto.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ExpoCrypto.web.js","sourceRoot":"","sources":["../src/ExpoCrypto.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAyB,cAAc,EAAuB,MAAM,gBAAgB,CAAC;AAE5F,eAAe;IACb,IAAI,IAAI;QACN,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,KAA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nimport { CryptoDigestAlgorithm, CryptoEncoding, CryptoDigestOptions } from './Crypto.types';\n\nexport default {\n get name(): string {\n return 'ExpoCrypto';\n },\n async digestStringAsync(\n algorithm: CryptoDigestAlgorithm,\n data: string,\n options: CryptoDigestOptions\n ): Promise<string> {\n if (!crypto.subtle) {\n throw new CodedError(\n 'ERR_CRYPTO_UNAVAILABLE',\n 'Access to the WebCrypto API is restricted to secure origins (https).'\n );\n }\n const encoder = new TextEncoder();\n const buffer = encoder.encode(data);\n const hashedData = await crypto.subtle.digest(algorithm, buffer);\n if (options.encoding === CryptoEncoding.HEX) {\n return hexString(hashedData);\n } else if (options.encoding === CryptoEncoding.BASE64) {\n return btoa(String.fromCharCode(...new Uint8Array(hashedData)));\n }\n throw new CodedError('ERR_CRYPTO_DIGEST', 'Invalid encoding type provided.');\n },\n};\n\nfunction hexString(buffer: ArrayBuffer): string {\n const byteArray = new Uint8Array(buffer);\n\n const hexCodes = [...byteArray].map((value) => {\n const hexCode = value.toString(16);\n const paddedHexCode = hexCode.padStart(2, '0');\n return paddedHexCode;\n });\n\n return hexCodes.join('');\n}\n"]}
|
package/ios/EXCrypto/EXCrypto.h
CHANGED
package/ios/EXCrypto/EXCrypto.m
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
@implementation EXCrypto
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
EX_EXPORT_MODULE(ExpoCrypto);
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
EX_EXPORT_METHOD_AS(digestStringAsync,
|
|
11
11
|
digestStringAsync:(NSString *)algorithm
|
|
12
12
|
data:(NSString *)data
|
|
13
13
|
options:(NSDictionary *)options
|
|
14
|
-
resolver:(
|
|
15
|
-
rejecter:(
|
|
14
|
+
resolver:(EXPromiseResolveBlock)resolve
|
|
15
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
16
16
|
{
|
|
17
17
|
NSString *encoding = options[@"encoding"];
|
|
18
18
|
|
package/ios/EXCrypto.podspec
CHANGED
|
@@ -10,10 +10,11 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.homepage = package['homepage']
|
|
13
|
-
s.platform = :ios, '
|
|
13
|
+
s.platform = :ios, '12.0'
|
|
14
14
|
s.source = { git: 'https://github.com/expo/expo.git' }
|
|
15
|
+
s.static_framework = true
|
|
15
16
|
|
|
16
|
-
s.dependency '
|
|
17
|
+
s.dependency 'ExpoModulesCore'
|
|
17
18
|
|
|
18
19
|
if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
|
|
19
20
|
s.source_files = "#{s.name}/**/*.h"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-crypto",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.2",
|
|
4
4
|
"description": "Expo universal module for crypto",
|
|
5
5
|
"main": "build/Crypto.js",
|
|
6
6
|
"types": "build/Crypto.d.ts",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
},
|
|
35
35
|
"author": "650 Industries, Inc.",
|
|
36
36
|
"license": "MIT",
|
|
37
|
-
"homepage": "https://docs.expo.
|
|
37
|
+
"homepage": "https://docs.expo.dev/versions/latest/sdk/crypto/",
|
|
38
38
|
"jest": {
|
|
39
39
|
"preset": "expo-module-scripts"
|
|
40
40
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"expo-modules-core": "~0.4.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"expo-module-scripts": "^2.0.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "d23e1ac491da96b51c25eb2533efcd56499ee287"
|
|
48
48
|
}
|
package/src/Crypto.ts
CHANGED
package/src/ExpoCrypto.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NativeModulesProxy } from '
|
|
1
|
+
import { NativeModulesProxy } from 'expo-modules-core';
|
|
2
2
|
export default NativeModulesProxy.ExpoCrypto;
|
package/src/ExpoCrypto.web.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodedError } from '
|
|
1
|
+
import { CodedError } from 'expo-modules-core';
|
|
2
2
|
|
|
3
3
|
import { CryptoDigestAlgorithm, CryptoEncoding, CryptoDigestOptions } from './Crypto.types';
|
|
4
4
|
|
|
@@ -32,7 +32,7 @@ export default {
|
|
|
32
32
|
function hexString(buffer: ArrayBuffer): string {
|
|
33
33
|
const byteArray = new Uint8Array(buffer);
|
|
34
34
|
|
|
35
|
-
const hexCodes = [...byteArray].map(value => {
|
|
35
|
+
const hexCodes = [...byteArray].map((value) => {
|
|
36
36
|
const hexCode = value.toString(16);
|
|
37
37
|
const paddedHexCode = hexCode.padStart(2, '0');
|
|
38
38
|
return paddedHexCode;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
package expo.modules.crypto;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.util.Base64;
|
|
5
|
-
|
|
6
|
-
import java.security.MessageDigest;
|
|
7
|
-
import java.security.NoSuchAlgorithmException;
|
|
8
|
-
import java.util.Map;
|
|
9
|
-
|
|
10
|
-
import org.unimodules.core.ExportedModule;
|
|
11
|
-
import org.unimodules.core.ModuleRegistry;
|
|
12
|
-
import org.unimodules.core.Promise;
|
|
13
|
-
import org.unimodules.core.interfaces.ExpoMethod;
|
|
14
|
-
|
|
15
|
-
public class CryptoModule extends ExportedModule {
|
|
16
|
-
|
|
17
|
-
public CryptoModule(Context context) {
|
|
18
|
-
super(context);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Override
|
|
22
|
-
public void onCreate(ModuleRegistry moduleRegistry) {
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@Override
|
|
26
|
-
public String getName() {
|
|
27
|
-
return "ExpoCrypto";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@ExpoMethod
|
|
31
|
-
public void digestStringAsync(String algorithm, String data, final Map<String, Object> options, final Promise promise) {
|
|
32
|
-
String encoding = (String) options.get("encoding");
|
|
33
|
-
|
|
34
|
-
MessageDigest md;
|
|
35
|
-
try {
|
|
36
|
-
md = MessageDigest.getInstance(algorithm);
|
|
37
|
-
md.update(data.getBytes());
|
|
38
|
-
} catch (NoSuchAlgorithmException e) {
|
|
39
|
-
promise.reject("ERR_CRYPTO_DIGEST", e);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
byte[] digest = md.digest();
|
|
44
|
-
if (encoding.equals("base64")) {
|
|
45
|
-
String output = Base64.encodeToString(digest, Base64.NO_WRAP);
|
|
46
|
-
promise.resolve(output);
|
|
47
|
-
} else if (encoding.equals("hex")) {
|
|
48
|
-
StringBuilder stringBuilder = new StringBuilder(digest.length * 2);
|
|
49
|
-
for (int i = 0; i < digest.length; i++) {
|
|
50
|
-
stringBuilder.append(Integer.toString((digest[i] & 0xff) +
|
|
51
|
-
0x100, 16).substring(1));
|
|
52
|
-
}
|
|
53
|
-
String output = stringBuilder.toString();
|
|
54
|
-
promise.resolve(output);
|
|
55
|
-
} else {
|
|
56
|
-
promise.reject("ERR_CRYPTO_DIGEST", "Invalid encoding type provided.");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
package expo.modules.crypto;
|
|
3
|
-
|
|
4
|
-
import android.content.Context;
|
|
5
|
-
|
|
6
|
-
import java.util.Collections;
|
|
7
|
-
import java.util.List;
|
|
8
|
-
|
|
9
|
-
import org.unimodules.core.BasePackage;
|
|
10
|
-
import org.unimodules.core.ExportedModule;
|
|
11
|
-
import org.unimodules.core.ViewManager;
|
|
12
|
-
|
|
13
|
-
public class CryptoPackage extends BasePackage {
|
|
14
|
-
@Override
|
|
15
|
-
public List<ExportedModule> createExportedModules(Context context) {
|
|
16
|
-
return Collections.singletonList((ExportedModule) new CryptoModule(context));
|
|
17
|
-
}
|
|
18
|
-
}
|