@wikha/sdk 1.1.13 → 1.1.14
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/README.md +6 -0
- package/dist/src/sdk.js +5 -2
- package/dist/wikha-sdk.umd.js +1 -1
- package/dist/wikha-sdk.umd.js.LICENSE.txt +0 -2
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -18,6 +18,12 @@ console.log(WikhaSDK.Environment.sandbox);
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
# Processing a Payment
|
|
21
|
+
|
|
22
|
+
## Security & Payload Encryption
|
|
23
|
+
By default, when using this SDK in a browser environment, it will send the data in **plaintext** (`{ data: ... }`) if the `crypto` module is not present. However, if you are using Node.js (or if a Polyfill is provided), the SDK will automatically compress and encrypt your payload in RSA using the `encryptedData` field.
|
|
24
|
+
|
|
25
|
+
The Wikha API accepts both formats but we strongly encourage RSA encryption for production usage.
|
|
26
|
+
|
|
21
27
|
## Use the processPayment method to initiate a payment.
|
|
22
28
|
You'll need to provide a WikhaPayload object with the necessary payment details.
|
|
23
29
|
|
package/dist/src/sdk.js
CHANGED
|
@@ -59,7 +59,9 @@ class WikhaSDK {
|
|
|
59
59
|
}
|
|
60
60
|
if (isNode) {
|
|
61
61
|
try {
|
|
62
|
-
|
|
62
|
+
// Use eval('require') to evade webpack/esbuild statically evaluating node-fetch for browsers
|
|
63
|
+
const req = eval('require');
|
|
64
|
+
return req('node-fetch');
|
|
63
65
|
}
|
|
64
66
|
catch (e) {
|
|
65
67
|
console.warn("Native fetch not found and 'node-fetch' not installed.");
|
|
@@ -95,7 +97,8 @@ class WikhaSDK {
|
|
|
95
97
|
}
|
|
96
98
|
const dataString = JSON.stringify({ ...data, merchant_id: this.merchantId });
|
|
97
99
|
if (isNode) {
|
|
98
|
-
const
|
|
100
|
+
const req = eval('require');
|
|
101
|
+
const crypto = req('crypto');
|
|
99
102
|
try {
|
|
100
103
|
const encrypted = crypto.publicEncrypt({
|
|
101
104
|
key: this.publicKey,
|