apps-sdk 1.0.11 → 1.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -110,12 +110,33 @@ class Networking {
110
110
  headers: headers,
111
111
  body: JSON.stringify(data)
112
112
  });
113
- return await response.json();
113
+ if (encrypt) {
114
+ return await this.decryptData(await response.json());
115
+ } else {
116
+ return await response.json();
117
+ }
114
118
  } catch (error) {
115
119
  console.log(error)
116
120
  }
117
121
  }
118
122
 
123
+ decryptData = async (data) => {
124
+ if (data && data.data) {
125
+ try {
126
+ const decryptedData = await Crypto.digestStringAsync(
127
+ Crypto.CryptoDigestAlgorithm.SHA256,
128
+ data.data,
129
+ { encoding: Crypto.CryptoEncoding.BASE64 }
130
+ );
131
+ return JSON.parse(decryptedData);
132
+ } catch (error) {
133
+ console.error(error);
134
+ return null;
135
+ }
136
+ }
137
+ return data;
138
+ }
139
+
119
140
  setEndpoints(domains) {
120
141
  // domains.events && (config.ENDPOINTS.TRACKING = domains.events);
121
142
  // domains.audiences && (config.ENDPOINTS.SET_ATTRIBUTION = domains.audiences);