payu-upi-bolt-ui-rn 0.0.1-dev5 → 0.0.1-dev6
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/android/build.gradle
CHANGED
|
@@ -90,7 +90,7 @@ dependencies {
|
|
|
90
90
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
91
91
|
implementation fileTree(include: ['*.aar'], dir: 'libs')
|
|
92
92
|
// implementation project(path: ':one-payu-biz-sdk-wrapper-android')
|
|
93
|
-
implementation 'in.payu:payu-upi-bolt-ui-sdk:0.0.
|
|
93
|
+
implementation 'in.payu:payu-upi-bolt-ui-sdk:0.0.1-dev3'
|
|
94
94
|
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package com.payuupiboltui;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.ContextWrapper;
|
|
5
|
+
import android.content.pm.PackageManager;
|
|
6
|
+
import android.content.pm.Signature;
|
|
7
|
+
import android.util.Base64;
|
|
8
|
+
import android.util.Log;
|
|
9
|
+
|
|
10
|
+
import java.nio.charset.StandardCharsets;
|
|
11
|
+
import java.security.MessageDigest;
|
|
12
|
+
import java.security.NoSuchAlgorithmException;
|
|
13
|
+
import java.util.ArrayList;
|
|
14
|
+
import java.util.Arrays;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This is a helper class to generate your message hash to be included in your SMS message.
|
|
18
|
+
*
|
|
19
|
+
* Without the correct hash, your app won't recieve the message callback. This only needs to be
|
|
20
|
+
* generated once per app and stored. Then you can remove this helper class from your code.
|
|
21
|
+
*/
|
|
22
|
+
public class AppSignatureHelper extends ContextWrapper {
|
|
23
|
+
public static final String TAG = AppSignatureHelper.class.getSimpleName();
|
|
24
|
+
|
|
25
|
+
private static final String HASH_TYPE = "SHA-256";
|
|
26
|
+
public static final int NUM_HASHED_BYTES = 9;
|
|
27
|
+
public static final int NUM_BASE64_CHAR = 11;
|
|
28
|
+
|
|
29
|
+
public AppSignatureHelper(Context context) {
|
|
30
|
+
super(context);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get all the app signatures for the current package
|
|
35
|
+
* @return
|
|
36
|
+
*/
|
|
37
|
+
public ArrayList<String> getAppSignatures() {
|
|
38
|
+
ArrayList<String> appCodes = new ArrayList<>();
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
// Get all package signatures for the current package
|
|
42
|
+
String packageName = getPackageName();
|
|
43
|
+
PackageManager packageManager = getPackageManager();
|
|
44
|
+
Signature[] signatures = packageManager.getPackageInfo(packageName,
|
|
45
|
+
PackageManager.GET_SIGNATURES).signatures;
|
|
46
|
+
|
|
47
|
+
// For each signature create a compatible hash
|
|
48
|
+
for (Signature signature : signatures) {
|
|
49
|
+
String hash = hash(packageName, signature.toCharsString());
|
|
50
|
+
if (hash != null) {
|
|
51
|
+
appCodes.add(String.format("%s", hash));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch (PackageManager.NameNotFoundException e) {
|
|
55
|
+
Log.e(TAG, "Unable to find package to obtain hash.", e);
|
|
56
|
+
}
|
|
57
|
+
return appCodes;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private static String hash(String packageName, String signature) {
|
|
61
|
+
String appInfo = packageName + " " + signature;
|
|
62
|
+
try {
|
|
63
|
+
MessageDigest messageDigest = MessageDigest.getInstance(HASH_TYPE);
|
|
64
|
+
messageDigest.update(appInfo.getBytes(StandardCharsets.UTF_8));
|
|
65
|
+
byte[] hashSignature = messageDigest.digest();
|
|
66
|
+
|
|
67
|
+
// truncated into NUM_HASHED_BYTES
|
|
68
|
+
hashSignature = Arrays.copyOfRange(hashSignature, 0, NUM_HASHED_BYTES);
|
|
69
|
+
// encode into Base64
|
|
70
|
+
String base64Hash = Base64.encodeToString(hashSignature, Base64.NO_PADDING | Base64.NO_WRAP);
|
|
71
|
+
base64Hash = base64Hash.substring(0, NUM_BASE64_CHAR);
|
|
72
|
+
|
|
73
|
+
Log.d(TAG, String.format("pkg: %s -- hash: %s", packageName, base64Hash));
|
|
74
|
+
return base64Hash;
|
|
75
|
+
} catch (NoSuchAlgorithmException e) {
|
|
76
|
+
Log.e(TAG, "hash:NoSuchAlgorithm", e);
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payu-upi-bolt-ui-rn",
|
|
3
3
|
"title": "PayU UPI Bolt Plugin React Native Module",
|
|
4
|
-
"version": "0.0.1-
|
|
4
|
+
"version": "0.0.1-dev6",
|
|
5
5
|
"description": "React native wrapper built upon PayU's UPI Bolt plugin SDK for Android and iOS",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|