@paydock/client-sdk 1.10.78-beta → 1.10.79-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 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(accessToken, cb, errorCb)](#w_Configuration+createToken)
1904
+ * [.createToken(publicKey, 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(accessToken, cb, errorCb)
2044
+ ### configuration.createToken(publicKey, 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
- | accessToken | <code>string</code> | Customer access token or public key which provided for each client |
2051
+ | publicKey | <code>string</code> | Customer 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(accessToken, conf)](#w_new_MultiWidget_new)
2073
+ * [new exports.MultiWidget(publicKey, 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(accessToken, conf)
2093
+ ### new exports.MultiWidget(publicKey, conf)
2094
2094
 
2095
2095
  | Param | Type | Description |
2096
2096
  | --- | --- | --- |
2097
- | accessToken | <code>string</code> | PayDock users access token or public key |
2097
+ | publicKey | <code>string</code> | PayDock users public key |
2098
2098
  | conf | [<code>Configuration</code>](#w_Configuration) \| <code>string</code> \| [<code>Array.&lt;Configuration&gt;</code>](#w_Configuration) \| <code>Array.&lt;string&gt;</code> | exemplar[s] Configuration class OR configuration token |
2099
2099
 
2100
2100
  **Example**
2101
2101
 
2102
2102
  ```javascript
2103
- var widget = new MultiWidget('accessToken','configurationToken'); // With a pre-created configuration token
2103
+ var widget = new MultiWidget('publicKey','configurationToken'); // With a pre-created configuration token
2104
2104
 
2105
- var widget = new MultiWidget('accessToken',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
2105
+ var widget = new MultiWidget('publicKey',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
2106
2106
 
2107
- var widget = new MultiWidget('accessToken', new Configuration('gatewayId')); With Configuration
2107
+ var widget = new MultiWidget('publicKey', new Configuration('gatewayId')); With Configuration
2108
2108
 
2109
- var widget = new MultiWidget('accessToken',[ With Configurations
2109
+ var widget = new MultiWidget('publicKey',[ With Configurations
2110
2110
  Configuration('gatewayId'),
2111
2111
  Configuration('gatewayId', 'bank_account')
2112
2112
  ]);
package/api.js ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/api';
@@ -160,66 +160,6 @@
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
-
223
163
  var ENV = {
224
164
  SANDBOX: 'sandbox',
225
165
  SANDBOX_KOVENA: 'sandbox-kovena',
@@ -701,28 +641,28 @@
701
641
  * console.log(error);
702
642
  * });
703
643
  *
704
- * @param {string} accessToken - Customer access token or public key which provided for each client
644
+ * @param {string} publicKey - Customer public key which provided for each client
705
645
  * @param {createToken~requestCallback} cb - The callback that handles the success response.
706
646
  * @param {createToken~requestCallback} errorCb - The callback that handles the failed response.
707
647
  */
708
648
 
709
649
  }, {
710
650
  key: 'createToken',
711
- value: function createToken(accessToken, cb) {
651
+ value: function createToken(publicKey, cb) {
712
652
  var errorCb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (err) {};
713
653
 
714
- this.send(accessToken, function (data, status) {
654
+ this.send(publicKey, function (data, status) {
715
655
  if (status >= 200 && status < 300) return cb(data.resource.data.configuration_token);
716
656
  if (typeof data.error === "undefined" || typeof data.error.message === "undefined") errorCb('unknown error');else errorCb(data.error.message);
717
657
  });
718
658
  }
719
659
  }, {
720
660
  key: 'send',
721
- value: function send(accessToken, cb) {
661
+ value: function send(publicKey, cb) {
722
662
  var request = new XMLHttpRequest();
723
663
  request.open('POST', this.getUrl(), true);
724
664
  request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
725
- request.setRequestHeader(AccessToken.getAccessHeaderNameByToken(accessToken), accessToken);
665
+ request.setRequestHeader('x-user-public-key', publicKey);
726
666
  request.send(JSON.stringify(this.getConfigs()));
727
667
  request.onload = function () {
728
668
  var res = {};
@@ -744,7 +684,7 @@
744
684
  }
745
685
  }], [{
746
686
  key: 'createEachToken',
747
- value: function createEachToken(accessToken, configs, cb) {
687
+ value: function createEachToken(publicKey, configs, cb) {
748
688
  var errorCb = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (errors) {};
749
689
 
750
690
  var tokens = new Array(configs.length);
@@ -752,7 +692,7 @@
752
692
  var counter = 0;
753
693
 
754
694
  var _loop = function _loop(index) {
755
- if (configs.hasOwnProperty(index)) configs[index].createToken(accessToken, function (token) {
695
+ if (configs.hasOwnProperty(index)) configs[index].createToken(publicKey, function (token) {
756
696
  tokens[index] = token;
757
697
  counter++;
758
698
  if (configs.length === counter) Configuration.finishCreatingEachToken(tokens, errors, cb, errorCb);
@@ -969,34 +909,30 @@
969
909
  * Class MultiWidget include method for for creating iframe url
970
910
  * @constructor
971
911
  *
972
- * @param {string} accessToken - PayDock users access token or public key
912
+ * @param {string} publicKey - PayDock users public key
973
913
  * @param {(Configuration | string | Configuration[] | string[])} conf - exemplar[s] Configuration class OR configuration token
974
914
  *
975
915
  * @example
976
- * var widget = new MultiWidget('accessToken','configurationToken'); // With a pre-created configuration token
916
+ * var widget = new MultiWidget('publicKey','configurationToken'); // With a pre-created configuration token
977
917
  *
978
- * var widget = new MultiWidget('accessToken',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
918
+ * var widget = new MultiWidget('publicKey',['configurationToken', 'configurationToken2']); // With pre-created configuration tokens
979
919
  *
980
- * var widget = new MultiWidget('accessToken', new Configuration('gatewayId')); With Configuration
920
+ * var widget = new MultiWidget('publicKey', new Configuration('gatewayId')); With Configuration
981
921
  *
982
- * var widget = new MultiWidget('accessToken',[ With Configurations
922
+ * var widget = new MultiWidget('publicKey',[ With Configurations
983
923
  * Configuration('gatewayId'),
984
924
  * Configuration('gatewayId', 'bank_account')
985
925
  * ]);
986
926
  **/
987
927
  var MultiWidget = function () {
988
- function MultiWidget(accessToken, conf) {
928
+ function MultiWidget(publicKey, conf) {
989
929
  classCallCheck(this, MultiWidget);
990
930
 
991
931
  this.configs = [];
992
932
  this.configTokens = [];
993
933
  this.link = new Link(WIDGET_LINK);
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;
934
+ this.link.setParams({ public_key: publicKey });
935
+ this.publicKey = publicKey;
1000
936
  if (!conf || Array.isArray(conf) && !conf.length) throw Error('configuration token is required');
1001
937
  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');
1002
938
  }
@@ -1371,7 +1307,7 @@
1371
1307
  this.link.setParams({ configuration_tokens: this.configTokens.join(',') });
1372
1308
  return cb(this.link.getUrl());
1373
1309
  }
1374
- Configuration.createEachToken(this.accessToken, this.configs, function (tokens) {
1310
+ Configuration.createEachToken(this.publicKey, this.configs, function (tokens) {
1375
1311
  _this2.link.concatParams({ configuration_tokens: tokens.join(',') });
1376
1312
  return cb(_this2.link.getUrl());
1377
1313
  }, function (errors) {
@@ -6224,6 +6160,55 @@
6224
6160
  return MastercardWalletService;
6225
6161
  }(WalletService);
6226
6162
 
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
+
6227
6212
  var API_AUTH_TYPE;
6228
6213
  (function (API_AUTH_TYPE) {
6229
6214
  API_AUTH_TYPE[API_AUTH_TYPE["PUBLIC_KEY"] = 0] = "PUBLIC_KEY";