@paydock/client-sdk 1.10.79-beta → 1.10.80-beta
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 +10 -10
- package/bundles/widget.umd.js +80 -65
- package/bundles/widget.umd.min.js +1 -1
- package/lib/components/param.d.ts +1 -0
- package/lib/components/param.js.map +1 -1
- package/lib/helper/access-token.d.ts +5 -0
- package/lib/helper/access-token.js +9 -0
- package/lib/helper/access-token.js.map +1 -1
- package/lib/widget/configuration.d.ts +3 -3
- package/lib/widget/configuration.js +8 -7
- package/lib/widget/configuration.js.map +1 -1
- package/lib/widget/multi-widget.d.ts +10 -10
- package/lib/widget/multi-widget.js +15 -9
- package/lib/widget/multi-widget.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1901,7 +1901,7 @@ Class Configuration include methods for creating configuration token
|
|
|
1901
1901
|
* [.setMeta(object)](#w_Configuration+setMeta)
|
|
1902
1902
|
* [.setEnv(env, [alias])](#w_Configuration+setEnv)
|
|
1903
1903
|
* [.setLabel(label)](#w_Configuration+setLabel)
|
|
1904
|
-
* [.createToken(
|
|
1904
|
+
* [.createToken(accessToken, cb, errorCb)](#w_Configuration+createToken)
|
|
1905
1905
|
|
|
1906
1906
|
<a name="w_new_Configuration_new" id="w_new_Configuration_new"></a>
|
|
1907
1907
|
|
|
@@ -2041,14 +2041,14 @@ config.setLabel('custom label');
|
|
|
2041
2041
|
```
|
|
2042
2042
|
<a name="w_Configuration+createToken" id="w_Configuration+createToken"></a>
|
|
2043
2043
|
|
|
2044
|
-
### configuration.createToken(
|
|
2044
|
+
### configuration.createToken(accessToken, cb, errorCb)
|
|
2045
2045
|
createToken - method which exactly create payment one time token
|
|
2046
2046
|
|
|
2047
2047
|
**Kind**: instance method of [<code>Configuration</code>](#w_Configuration)
|
|
2048
2048
|
|
|
2049
2049
|
| Param | Type | Description |
|
|
2050
2050
|
| --- | --- | --- |
|
|
2051
|
-
|
|
|
2051
|
+
| accessToken | <code>string</code> | Customer access token or public key which provided for each client |
|
|
2052
2052
|
| cb | <code>createToken~requestCallback</code> | The callback that handles the success response. |
|
|
2053
2053
|
| errorCb | <code>createToken~requestCallback</code> | The callback that handles the failed response. |
|
|
2054
2054
|
|
|
@@ -2070,7 +2070,7 @@ Class MultiWidget include method for for creating iframe url
|
|
|
2070
2070
|
**Kind**: global class
|
|
2071
2071
|
|
|
2072
2072
|
* [MultiWidget](#w_MultiWidget)
|
|
2073
|
-
* [new exports.MultiWidget(
|
|
2073
|
+
* [new exports.MultiWidget(accessToken, conf)](#w_new_MultiWidget_new)
|
|
2074
2074
|
* [.setStyles(fields)](#w_MultiWidget+setStyles)
|
|
2075
2075
|
* [.usePhoneCountryMask([options])](#w_MultiWidget+usePhoneCountryMask)
|
|
2076
2076
|
* [.setTexts(fields)](#w_MultiWidget+setTexts)
|
|
@@ -2090,23 +2090,23 @@ Class MultiWidget include method for for creating iframe url
|
|
|
2090
2090
|
|
|
2091
2091
|
<a name="w_new_MultiWidget_new" id="w_new_MultiWidget_new"></a>
|
|
2092
2092
|
|
|
2093
|
-
### new exports.MultiWidget(
|
|
2093
|
+
### new exports.MultiWidget(accessToken, conf)
|
|
2094
2094
|
|
|
2095
2095
|
| Param | Type | Description |
|
|
2096
2096
|
| --- | --- | --- |
|
|
2097
|
-
|
|
|
2097
|
+
| accessToken | <code>string</code> | PayDock users access token or public key |
|
|
2098
2098
|
| conf | [<code>Configuration</code>](#w_Configuration) \| <code>string</code> \| [<code>Array.<Configuration></code>](#w_Configuration) \| <code>Array.<string></code> | exemplar[s] Configuration class OR configuration token |
|
|
2099
2099
|
|
|
2100
2100
|
**Example**
|
|
2101
2101
|
|
|
2102
2102
|
```javascript
|
|
2103
|
-
var widget = new MultiWidget('
|
|
2103
|
+
var widget = new MultiWidget('accessToken','configurationToken'); // With a pre-created configuration token
|
|
2104
2104
|
|
|
2105
|
-
var widget = new MultiWidget('
|
|
2105
|
+
var widget = new MultiWidget('accessToken',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
|
|
2106
2106
|
|
|
2107
|
-
var widget = new MultiWidget('
|
|
2107
|
+
var widget = new MultiWidget('accessToken', new Configuration('gatewayId')); With Configuration
|
|
2108
2108
|
|
|
2109
|
-
var widget = new MultiWidget('
|
|
2109
|
+
var widget = new MultiWidget('accessToken',[ With Configurations
|
|
2110
2110
|
Configuration('gatewayId'),
|
|
2111
2111
|
Configuration('gatewayId', 'bank_account')
|
|
2112
2112
|
]);
|
package/bundles/widget.umd.js
CHANGED
|
@@ -160,6 +160,66 @@
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
+
var ACCESS_HEADER_NAME = {
|
|
164
|
+
accessToken: 'x-access-token',
|
|
165
|
+
publicKey: 'x-user-public-key'
|
|
166
|
+
};
|
|
167
|
+
var AccessToken = function () {
|
|
168
|
+
function AccessToken() {
|
|
169
|
+
classCallCheck(this, AccessToken);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
createClass(AccessToken, null, [{
|
|
173
|
+
key: 'validateJWT',
|
|
174
|
+
value: function validateJWT(jwt) {
|
|
175
|
+
if (!jwt) return null;
|
|
176
|
+
|
|
177
|
+
var _jwt$split = jwt.split("."),
|
|
178
|
+
_jwt$split2 = slicedToArray(_jwt$split, 3),
|
|
179
|
+
rawHead = _jwt$split2[0],
|
|
180
|
+
rawBody = _jwt$split2[1],
|
|
181
|
+
signature = _jwt$split2[2];
|
|
182
|
+
|
|
183
|
+
if (!rawHead || !rawBody || !signature) return null;
|
|
184
|
+
if (2 + rawHead.length + rawBody.length + signature.length !== jwt.length) return null;
|
|
185
|
+
try {
|
|
186
|
+
var head = JSON.parse(atob(rawHead));
|
|
187
|
+
var body = JSON.parse(atob(rawBody));
|
|
188
|
+
return { head: head, body: body, signature: signature };
|
|
189
|
+
} catch (_a) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: 'extractData',
|
|
195
|
+
value: function extractData(body) {
|
|
196
|
+
try {
|
|
197
|
+
return JSON.parse(atob(body.meta));
|
|
198
|
+
} catch (_a) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
key: 'extractMeta',
|
|
204
|
+
value: function extractMeta(body) {
|
|
205
|
+
try {
|
|
206
|
+
var _JSON$parse = JSON.parse(atob(body.meta)),
|
|
207
|
+
meta = _JSON$parse.meta;
|
|
208
|
+
|
|
209
|
+
return meta;
|
|
210
|
+
} catch (_a) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}, {
|
|
215
|
+
key: 'getAccessHeaderNameByToken',
|
|
216
|
+
value: function getAccessHeaderNameByToken(token) {
|
|
217
|
+
return !!AccessToken.validateJWT(token) ? ACCESS_HEADER_NAME.accessToken : ACCESS_HEADER_NAME.publicKey;
|
|
218
|
+
}
|
|
219
|
+
}]);
|
|
220
|
+
return AccessToken;
|
|
221
|
+
}();
|
|
222
|
+
|
|
163
223
|
var ENV = {
|
|
164
224
|
SANDBOX: 'sandbox',
|
|
165
225
|
SANDBOX_KOVENA: 'sandbox-kovena',
|
|
@@ -641,28 +701,28 @@
|
|
|
641
701
|
* console.log(error);
|
|
642
702
|
* });
|
|
643
703
|
*
|
|
644
|
-
* @param {string}
|
|
704
|
+
* @param {string} accessToken - Customer access token or public key which provided for each client
|
|
645
705
|
* @param {createToken~requestCallback} cb - The callback that handles the success response.
|
|
646
706
|
* @param {createToken~requestCallback} errorCb - The callback that handles the failed response.
|
|
647
707
|
*/
|
|
648
708
|
|
|
649
709
|
}, {
|
|
650
710
|
key: 'createToken',
|
|
651
|
-
value: function createToken(
|
|
711
|
+
value: function createToken(accessToken, cb) {
|
|
652
712
|
var errorCb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (err) {};
|
|
653
713
|
|
|
654
|
-
this.send(
|
|
714
|
+
this.send(accessToken, function (data, status) {
|
|
655
715
|
if (status >= 200 && status < 300) return cb(data.resource.data.configuration_token);
|
|
656
716
|
if (typeof data.error === "undefined" || typeof data.error.message === "undefined") errorCb('unknown error');else errorCb(data.error.message);
|
|
657
717
|
});
|
|
658
718
|
}
|
|
659
719
|
}, {
|
|
660
720
|
key: 'send',
|
|
661
|
-
value: function send(
|
|
721
|
+
value: function send(accessToken, cb) {
|
|
662
722
|
var request = new XMLHttpRequest();
|
|
663
723
|
request.open('POST', this.getUrl(), true);
|
|
664
724
|
request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
|
665
|
-
request.setRequestHeader(
|
|
725
|
+
request.setRequestHeader(AccessToken.getAccessHeaderNameByToken(accessToken), accessToken);
|
|
666
726
|
request.send(JSON.stringify(this.getConfigs()));
|
|
667
727
|
request.onload = function () {
|
|
668
728
|
var res = {};
|
|
@@ -684,7 +744,7 @@
|
|
|
684
744
|
}
|
|
685
745
|
}], [{
|
|
686
746
|
key: 'createEachToken',
|
|
687
|
-
value: function createEachToken(
|
|
747
|
+
value: function createEachToken(accessToken, configs, cb) {
|
|
688
748
|
var errorCb = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (errors) {};
|
|
689
749
|
|
|
690
750
|
var tokens = new Array(configs.length);
|
|
@@ -692,7 +752,7 @@
|
|
|
692
752
|
var counter = 0;
|
|
693
753
|
|
|
694
754
|
var _loop = function _loop(index) {
|
|
695
|
-
if (configs.hasOwnProperty(index)) configs[index].createToken(
|
|
755
|
+
if (configs.hasOwnProperty(index)) configs[index].createToken(accessToken, function (token) {
|
|
696
756
|
tokens[index] = token;
|
|
697
757
|
counter++;
|
|
698
758
|
if (configs.length === counter) Configuration.finishCreatingEachToken(tokens, errors, cb, errorCb);
|
|
@@ -909,30 +969,34 @@
|
|
|
909
969
|
* Class MultiWidget include method for for creating iframe url
|
|
910
970
|
* @constructor
|
|
911
971
|
*
|
|
912
|
-
* @param {string}
|
|
972
|
+
* @param {string} accessToken - PayDock users access token or public key
|
|
913
973
|
* @param {(Configuration | string | Configuration[] | string[])} conf - exemplar[s] Configuration class OR configuration token
|
|
914
974
|
*
|
|
915
975
|
* @example
|
|
916
|
-
* var widget = new MultiWidget('
|
|
976
|
+
* var widget = new MultiWidget('accessToken','configurationToken'); // With a pre-created configuration token
|
|
917
977
|
*
|
|
918
|
-
* var widget = new MultiWidget('
|
|
978
|
+
* var widget = new MultiWidget('accessToken',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
|
|
919
979
|
*
|
|
920
|
-
* var widget = new MultiWidget('
|
|
980
|
+
* var widget = new MultiWidget('accessToken', new Configuration('gatewayId')); With Configuration
|
|
921
981
|
*
|
|
922
|
-
* var widget = new MultiWidget('
|
|
982
|
+
* var widget = new MultiWidget('accessToken',[ With Configurations
|
|
923
983
|
* Configuration('gatewayId'),
|
|
924
984
|
* Configuration('gatewayId', 'bank_account')
|
|
925
985
|
* ]);
|
|
926
986
|
**/
|
|
927
987
|
var MultiWidget = function () {
|
|
928
|
-
function MultiWidget(
|
|
988
|
+
function MultiWidget(accessToken, conf) {
|
|
929
989
|
classCallCheck(this, MultiWidget);
|
|
930
990
|
|
|
931
991
|
this.configs = [];
|
|
932
992
|
this.configTokens = [];
|
|
933
993
|
this.link = new Link(WIDGET_LINK);
|
|
934
|
-
|
|
935
|
-
|
|
994
|
+
if (!!AccessToken.validateJWT(accessToken)) {
|
|
995
|
+
this.link.setParams({ token: accessToken });
|
|
996
|
+
} else {
|
|
997
|
+
this.link.setParams({ public_key: accessToken });
|
|
998
|
+
}
|
|
999
|
+
this.accessToken = accessToken;
|
|
936
1000
|
if (!conf || Array.isArray(conf) && !conf.length) throw Error('configuration token is required');
|
|
937
1001
|
if (typeof conf === 'string') this.configTokens.push(conf);else if (conf instanceof Configuration) this.configs.push(conf);else if (Array.isArray(conf) && typeof conf[0] === 'string') this.configTokens = conf;else if (Array.isArray(conf) && conf[0] instanceof Configuration) this.configs = conf;else throw Error('Unsupported type of configuration token');
|
|
938
1002
|
}
|
|
@@ -1307,7 +1371,7 @@
|
|
|
1307
1371
|
this.link.setParams({ configuration_tokens: this.configTokens.join(',') });
|
|
1308
1372
|
return cb(this.link.getUrl());
|
|
1309
1373
|
}
|
|
1310
|
-
Configuration.createEachToken(this.
|
|
1374
|
+
Configuration.createEachToken(this.accessToken, this.configs, function (tokens) {
|
|
1311
1375
|
_this2.link.concatParams({ configuration_tokens: tokens.join(',') });
|
|
1312
1376
|
return cb(_this2.link.getUrl());
|
|
1313
1377
|
}, function (errors) {
|
|
@@ -6160,55 +6224,6 @@
|
|
|
6160
6224
|
return MastercardWalletService;
|
|
6161
6225
|
}(WalletService);
|
|
6162
6226
|
|
|
6163
|
-
var AccessToken = function () {
|
|
6164
|
-
function AccessToken() {
|
|
6165
|
-
classCallCheck(this, AccessToken);
|
|
6166
|
-
}
|
|
6167
|
-
|
|
6168
|
-
createClass(AccessToken, null, [{
|
|
6169
|
-
key: "validateJWT",
|
|
6170
|
-
value: function validateJWT(jwt) {
|
|
6171
|
-
var _jwt$split = jwt.split("."),
|
|
6172
|
-
_jwt$split2 = slicedToArray(_jwt$split, 3),
|
|
6173
|
-
rawHead = _jwt$split2[0],
|
|
6174
|
-
rawBody = _jwt$split2[1],
|
|
6175
|
-
signature = _jwt$split2[2];
|
|
6176
|
-
|
|
6177
|
-
if (!rawHead || !rawBody || !signature) return null;
|
|
6178
|
-
if (2 + rawHead.length + rawBody.length + signature.length !== jwt.length) return null;
|
|
6179
|
-
try {
|
|
6180
|
-
var head = JSON.parse(atob(rawHead));
|
|
6181
|
-
var body = JSON.parse(atob(rawBody));
|
|
6182
|
-
return { head: head, body: body, signature: signature };
|
|
6183
|
-
} catch (_a) {
|
|
6184
|
-
return null;
|
|
6185
|
-
}
|
|
6186
|
-
}
|
|
6187
|
-
}, {
|
|
6188
|
-
key: "extractData",
|
|
6189
|
-
value: function extractData(body) {
|
|
6190
|
-
try {
|
|
6191
|
-
return JSON.parse(atob(body.meta));
|
|
6192
|
-
} catch (_a) {
|
|
6193
|
-
return null;
|
|
6194
|
-
}
|
|
6195
|
-
}
|
|
6196
|
-
}, {
|
|
6197
|
-
key: "extractMeta",
|
|
6198
|
-
value: function extractMeta(body) {
|
|
6199
|
-
try {
|
|
6200
|
-
var _JSON$parse = JSON.parse(atob(body.meta)),
|
|
6201
|
-
meta = _JSON$parse.meta;
|
|
6202
|
-
|
|
6203
|
-
return meta;
|
|
6204
|
-
} catch (_a) {
|
|
6205
|
-
return null;
|
|
6206
|
-
}
|
|
6207
|
-
}
|
|
6208
|
-
}]);
|
|
6209
|
-
return AccessToken;
|
|
6210
|
-
}();
|
|
6211
|
-
|
|
6212
6227
|
var API_AUTH_TYPE;
|
|
6213
6228
|
(function (API_AUTH_TYPE) {
|
|
6214
6229
|
API_AUTH_TYPE[API_AUTH_TYPE["PUBLIC_KEY"] = 0] = "PUBLIC_KEY";
|