@stellar/typescript-wallet-sdk 1.0.0-alpha.2 → 1.0.0-beta.0
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/lib/bundle.js +1979 -259
- package/lib/bundle.js.map +1 -1
- package/lib/index.d.ts +25 -0
- package/lib/walletSdk/Exceptions/index.d.ts +22 -0
- package/lib/walletSdk/Types/anchor.d.ts +148 -0
- package/lib/walletSdk/Types/auth.d.ts +34 -0
- package/lib/walletSdk/Types/horizon.d.ts +4 -0
- package/lib/walletSdk/Types/index.d.ts +32 -0
- package/lib/walletSdk/Types/interactive.d.ts +27 -0
- package/lib/walletSdk/Types/utils.d.ts +77 -0
- package/lib/walletSdk/Types/watcher.d.ts +30 -0
- package/lib/walletSdk/Utils/camelToSnakeCase.d.ts +2 -0
- package/lib/walletSdk/Utils/index.d.ts +3 -0
- package/lib/walletSdk/Utils/toml.d.ts +3 -0
- package/lib/walletSdk/Utils/url.d.ts +1 -0
- package/lib/walletSdk/Watcher/Types.d.ts +65 -0
- package/lib/walletSdk/Watcher/index.d.ts +33 -0
- package/lib/walletSdk/anchor/Types.d.ts +75 -0
- package/lib/walletSdk/anchor/index.d.ts +65 -9
- package/lib/walletSdk/auth/WalletSigner.d.ts +4 -0
- package/lib/walletSdk/auth/index.d.ts +18 -6
- package/lib/walletSdk/exception/index.d.ts +9 -0
- package/lib/walletSdk/horizon/Account.d.ts +18 -0
- package/lib/walletSdk/horizon/AccountService.d.ts +8 -0
- package/lib/walletSdk/horizon/Stellar.d.ts +5 -1
- package/lib/walletSdk/horizon/index.d.ts +3 -0
- package/lib/walletSdk/index.d.ts +18 -18
- package/lib/walletSdk/interactive/index.d.ts +11 -11
- package/lib/walletSdk/recovery/index.d.ts +18 -0
- package/lib/walletSdk/util/camelToSnakeCase.d.ts +2 -0
- package/lib/walletSdk/util/sleep.d.ts +1 -0
- package/package.json +12 -6
- package/src/index.ts +39 -1
- package/src/walletSdk/Anchor/index.ts +252 -27
- package/src/walletSdk/Auth/WalletSigner.ts +27 -3
- package/src/walletSdk/Auth/index.ts +87 -32
- package/src/walletSdk/Exceptions/index.ts +51 -0
- package/src/walletSdk/Horizon/Account.ts +50 -0
- package/src/walletSdk/Horizon/AccountService.ts +19 -0
- package/src/walletSdk/Horizon/Stellar.ts +15 -0
- package/src/walletSdk/Horizon/index.ts +3 -0
- package/src/walletSdk/Interactive/index.ts +126 -0
- package/src/walletSdk/Recovery/index.ts +37 -0
- package/src/walletSdk/Types/anchor.ts +174 -0
- package/src/walletSdk/Types/auth.ts +42 -0
- package/src/walletSdk/{horizon/constants.ts → Types/horizon.ts} +1 -1
- package/src/walletSdk/Types/index.ts +40 -0
- package/src/walletSdk/Types/interactive.ts +36 -0
- package/src/walletSdk/Types/utils.ts +77 -0
- package/src/walletSdk/Types/watcher.ts +34 -0
- package/src/walletSdk/Utils/camelToSnakeCase.ts +13 -0
- package/src/walletSdk/Utils/index.ts +3 -0
- package/src/walletSdk/Utils/toml.ts +103 -0
- package/src/walletSdk/{util → Utils}/url.ts +1 -1
- package/src/walletSdk/Watcher/index.ts +367 -0
- package/src/walletSdk/index.ts +103 -58
- package/test/account.test.ts +30 -0
- package/test/fixtures/TransactionsResponse.ts +230 -0
- package/test/wallet.test.ts +1719 -0
- package/src/walletSdk/exception/index.ts +0 -27
- package/src/walletSdk/horizon/Account.ts +0 -0
- package/src/walletSdk/horizon/AccountService.ts +0 -0
- package/src/walletSdk/horizon/Stellar.ts +0 -6
- package/src/walletSdk/interactive/index.ts +0 -103
- package/src/walletSdk/recovery/Recovery.ts +0 -6
- package/src/walletSdk/toml/index.ts +0 -179
- package/test/index.test.ts +0 -73
package/lib/bundle.js
CHANGED
|
@@ -6129,6 +6129,111 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6129
6129
|
});
|
|
6130
6130
|
|
|
6131
6131
|
|
|
6132
|
+
/***/ }),
|
|
6133
|
+
|
|
6134
|
+
/***/ "./node_modules/decode-uri-component/index.js":
|
|
6135
|
+
/*!****************************************************!*\
|
|
6136
|
+
!*** ./node_modules/decode-uri-component/index.js ***!
|
|
6137
|
+
\****************************************************/
|
|
6138
|
+
/***/ ((module) => {
|
|
6139
|
+
|
|
6140
|
+
"use strict";
|
|
6141
|
+
|
|
6142
|
+
var token = '%[a-f0-9]{2}';
|
|
6143
|
+
var singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');
|
|
6144
|
+
var multiMatcher = new RegExp('(' + token + ')+', 'gi');
|
|
6145
|
+
|
|
6146
|
+
function decodeComponents(components, split) {
|
|
6147
|
+
try {
|
|
6148
|
+
// Try to decode the entire string first
|
|
6149
|
+
return [decodeURIComponent(components.join(''))];
|
|
6150
|
+
} catch (err) {
|
|
6151
|
+
// Do nothing
|
|
6152
|
+
}
|
|
6153
|
+
|
|
6154
|
+
if (components.length === 1) {
|
|
6155
|
+
return components;
|
|
6156
|
+
}
|
|
6157
|
+
|
|
6158
|
+
split = split || 1;
|
|
6159
|
+
|
|
6160
|
+
// Split the array in 2 parts
|
|
6161
|
+
var left = components.slice(0, split);
|
|
6162
|
+
var right = components.slice(split);
|
|
6163
|
+
|
|
6164
|
+
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
|
6165
|
+
}
|
|
6166
|
+
|
|
6167
|
+
function decode(input) {
|
|
6168
|
+
try {
|
|
6169
|
+
return decodeURIComponent(input);
|
|
6170
|
+
} catch (err) {
|
|
6171
|
+
var tokens = input.match(singleMatcher) || [];
|
|
6172
|
+
|
|
6173
|
+
for (var i = 1; i < tokens.length; i++) {
|
|
6174
|
+
input = decodeComponents(tokens, i).join('');
|
|
6175
|
+
|
|
6176
|
+
tokens = input.match(singleMatcher) || [];
|
|
6177
|
+
}
|
|
6178
|
+
|
|
6179
|
+
return input;
|
|
6180
|
+
}
|
|
6181
|
+
}
|
|
6182
|
+
|
|
6183
|
+
function customDecodeURIComponent(input) {
|
|
6184
|
+
// Keep track of all the replacements and prefill the map with the `BOM`
|
|
6185
|
+
var replaceMap = {
|
|
6186
|
+
'%FE%FF': '\uFFFD\uFFFD',
|
|
6187
|
+
'%FF%FE': '\uFFFD\uFFFD'
|
|
6188
|
+
};
|
|
6189
|
+
|
|
6190
|
+
var match = multiMatcher.exec(input);
|
|
6191
|
+
while (match) {
|
|
6192
|
+
try {
|
|
6193
|
+
// Decode as big chunks as possible
|
|
6194
|
+
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
|
6195
|
+
} catch (err) {
|
|
6196
|
+
var result = decode(match[0]);
|
|
6197
|
+
|
|
6198
|
+
if (result !== match[0]) {
|
|
6199
|
+
replaceMap[match[0]] = result;
|
|
6200
|
+
}
|
|
6201
|
+
}
|
|
6202
|
+
|
|
6203
|
+
match = multiMatcher.exec(input);
|
|
6204
|
+
}
|
|
6205
|
+
|
|
6206
|
+
// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
|
|
6207
|
+
replaceMap['%C2'] = '\uFFFD';
|
|
6208
|
+
|
|
6209
|
+
var entries = Object.keys(replaceMap);
|
|
6210
|
+
|
|
6211
|
+
for (var i = 0; i < entries.length; i++) {
|
|
6212
|
+
// Replace all decoded components
|
|
6213
|
+
var key = entries[i];
|
|
6214
|
+
input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
|
|
6215
|
+
}
|
|
6216
|
+
|
|
6217
|
+
return input;
|
|
6218
|
+
}
|
|
6219
|
+
|
|
6220
|
+
module.exports = function (encodedURI) {
|
|
6221
|
+
if (typeof encodedURI !== 'string') {
|
|
6222
|
+
throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');
|
|
6223
|
+
}
|
|
6224
|
+
|
|
6225
|
+
try {
|
|
6226
|
+
encodedURI = encodedURI.replace(/\+/g, ' ');
|
|
6227
|
+
|
|
6228
|
+
// Try the built in decoder first
|
|
6229
|
+
return decodeURIComponent(encodedURI);
|
|
6230
|
+
} catch (err) {
|
|
6231
|
+
// Fallback to a more advanced decoder
|
|
6232
|
+
return customDecodeURIComponent(encodedURI);
|
|
6233
|
+
}
|
|
6234
|
+
};
|
|
6235
|
+
|
|
6236
|
+
|
|
6132
6237
|
/***/ }),
|
|
6133
6238
|
|
|
6134
6239
|
/***/ "./node_modules/detect-node/browser.js":
|
|
@@ -8327,6 +8432,34 @@ function getOrigin (url) {
|
|
|
8327
8432
|
}
|
|
8328
8433
|
|
|
8329
8434
|
|
|
8435
|
+
/***/ }),
|
|
8436
|
+
|
|
8437
|
+
/***/ "./node_modules/filter-obj/index.js":
|
|
8438
|
+
/*!******************************************!*\
|
|
8439
|
+
!*** ./node_modules/filter-obj/index.js ***!
|
|
8440
|
+
\******************************************/
|
|
8441
|
+
/***/ ((module) => {
|
|
8442
|
+
|
|
8443
|
+
"use strict";
|
|
8444
|
+
|
|
8445
|
+
module.exports = function (obj, predicate) {
|
|
8446
|
+
var ret = {};
|
|
8447
|
+
var keys = Object.keys(obj);
|
|
8448
|
+
var isArr = Array.isArray(predicate);
|
|
8449
|
+
|
|
8450
|
+
for (var i = 0; i < keys.length; i++) {
|
|
8451
|
+
var key = keys[i];
|
|
8452
|
+
var val = obj[key];
|
|
8453
|
+
|
|
8454
|
+
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
|
|
8455
|
+
ret[key] = val;
|
|
8456
|
+
}
|
|
8457
|
+
}
|
|
8458
|
+
|
|
8459
|
+
return ret;
|
|
8460
|
+
};
|
|
8461
|
+
|
|
8462
|
+
|
|
8330
8463
|
/***/ }),
|
|
8331
8464
|
|
|
8332
8465
|
/***/ "./node_modules/for-each/index.js":
|
|
@@ -18714,6 +18847,51 @@ function isEmpty(value) {
|
|
|
18714
18847
|
module.exports = isEmpty;
|
|
18715
18848
|
|
|
18716
18849
|
|
|
18850
|
+
/***/ }),
|
|
18851
|
+
|
|
18852
|
+
/***/ "./node_modules/lodash/isEqual.js":
|
|
18853
|
+
/*!****************************************!*\
|
|
18854
|
+
!*** ./node_modules/lodash/isEqual.js ***!
|
|
18855
|
+
\****************************************/
|
|
18856
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
18857
|
+
|
|
18858
|
+
var baseIsEqual = __webpack_require__(/*! ./_baseIsEqual */ "./node_modules/lodash/_baseIsEqual.js");
|
|
18859
|
+
|
|
18860
|
+
/**
|
|
18861
|
+
* Performs a deep comparison between two values to determine if they are
|
|
18862
|
+
* equivalent.
|
|
18863
|
+
*
|
|
18864
|
+
* **Note:** This method supports comparing arrays, array buffers, booleans,
|
|
18865
|
+
* date objects, error objects, maps, numbers, `Object` objects, regexes,
|
|
18866
|
+
* sets, strings, symbols, and typed arrays. `Object` objects are compared
|
|
18867
|
+
* by their own, not inherited, enumerable properties. Functions and DOM
|
|
18868
|
+
* nodes are compared by strict equality, i.e. `===`.
|
|
18869
|
+
*
|
|
18870
|
+
* @static
|
|
18871
|
+
* @memberOf _
|
|
18872
|
+
* @since 0.1.0
|
|
18873
|
+
* @category Lang
|
|
18874
|
+
* @param {*} value The value to compare.
|
|
18875
|
+
* @param {*} other The other value to compare.
|
|
18876
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
18877
|
+
* @example
|
|
18878
|
+
*
|
|
18879
|
+
* var object = { 'a': 1 };
|
|
18880
|
+
* var other = { 'a': 1 };
|
|
18881
|
+
*
|
|
18882
|
+
* _.isEqual(object, other);
|
|
18883
|
+
* // => true
|
|
18884
|
+
*
|
|
18885
|
+
* object === other;
|
|
18886
|
+
* // => false
|
|
18887
|
+
*/
|
|
18888
|
+
function isEqual(value, other) {
|
|
18889
|
+
return baseIsEqual(value, other);
|
|
18890
|
+
}
|
|
18891
|
+
|
|
18892
|
+
module.exports = isEqual;
|
|
18893
|
+
|
|
18894
|
+
|
|
18717
18895
|
/***/ }),
|
|
18718
18896
|
|
|
18719
18897
|
/***/ "./node_modules/lodash/isFinite.js":
|
|
@@ -21769,6 +21947,499 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.3.2 by @mathia
|
|
|
21769
21947
|
}(this));
|
|
21770
21948
|
|
|
21771
21949
|
|
|
21950
|
+
/***/ }),
|
|
21951
|
+
|
|
21952
|
+
/***/ "./node_modules/query-string/index.js":
|
|
21953
|
+
/*!********************************************!*\
|
|
21954
|
+
!*** ./node_modules/query-string/index.js ***!
|
|
21955
|
+
\********************************************/
|
|
21956
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
21957
|
+
|
|
21958
|
+
"use strict";
|
|
21959
|
+
|
|
21960
|
+
const strictUriEncode = __webpack_require__(/*! strict-uri-encode */ "./node_modules/strict-uri-encode/index.js");
|
|
21961
|
+
const decodeComponent = __webpack_require__(/*! decode-uri-component */ "./node_modules/decode-uri-component/index.js");
|
|
21962
|
+
const splitOnFirst = __webpack_require__(/*! split-on-first */ "./node_modules/split-on-first/index.js");
|
|
21963
|
+
const filterObject = __webpack_require__(/*! filter-obj */ "./node_modules/filter-obj/index.js");
|
|
21964
|
+
|
|
21965
|
+
const isNullOrUndefined = value => value === null || value === undefined;
|
|
21966
|
+
|
|
21967
|
+
const encodeFragmentIdentifier = Symbol('encodeFragmentIdentifier');
|
|
21968
|
+
|
|
21969
|
+
function encoderForArrayFormat(options) {
|
|
21970
|
+
switch (options.arrayFormat) {
|
|
21971
|
+
case 'index':
|
|
21972
|
+
return key => (result, value) => {
|
|
21973
|
+
const index = result.length;
|
|
21974
|
+
|
|
21975
|
+
if (
|
|
21976
|
+
value === undefined ||
|
|
21977
|
+
(options.skipNull && value === null) ||
|
|
21978
|
+
(options.skipEmptyString && value === '')
|
|
21979
|
+
) {
|
|
21980
|
+
return result;
|
|
21981
|
+
}
|
|
21982
|
+
|
|
21983
|
+
if (value === null) {
|
|
21984
|
+
return [...result, [encode(key, options), '[', index, ']'].join('')];
|
|
21985
|
+
}
|
|
21986
|
+
|
|
21987
|
+
return [
|
|
21988
|
+
...result,
|
|
21989
|
+
[encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join('')
|
|
21990
|
+
];
|
|
21991
|
+
};
|
|
21992
|
+
|
|
21993
|
+
case 'bracket':
|
|
21994
|
+
return key => (result, value) => {
|
|
21995
|
+
if (
|
|
21996
|
+
value === undefined ||
|
|
21997
|
+
(options.skipNull && value === null) ||
|
|
21998
|
+
(options.skipEmptyString && value === '')
|
|
21999
|
+
) {
|
|
22000
|
+
return result;
|
|
22001
|
+
}
|
|
22002
|
+
|
|
22003
|
+
if (value === null) {
|
|
22004
|
+
return [...result, [encode(key, options), '[]'].join('')];
|
|
22005
|
+
}
|
|
22006
|
+
|
|
22007
|
+
return [...result, [encode(key, options), '[]=', encode(value, options)].join('')];
|
|
22008
|
+
};
|
|
22009
|
+
|
|
22010
|
+
case 'colon-list-separator':
|
|
22011
|
+
return key => (result, value) => {
|
|
22012
|
+
if (
|
|
22013
|
+
value === undefined ||
|
|
22014
|
+
(options.skipNull && value === null) ||
|
|
22015
|
+
(options.skipEmptyString && value === '')
|
|
22016
|
+
) {
|
|
22017
|
+
return result;
|
|
22018
|
+
}
|
|
22019
|
+
|
|
22020
|
+
if (value === null) {
|
|
22021
|
+
return [...result, [encode(key, options), ':list='].join('')];
|
|
22022
|
+
}
|
|
22023
|
+
|
|
22024
|
+
return [...result, [encode(key, options), ':list=', encode(value, options)].join('')];
|
|
22025
|
+
};
|
|
22026
|
+
|
|
22027
|
+
case 'comma':
|
|
22028
|
+
case 'separator':
|
|
22029
|
+
case 'bracket-separator': {
|
|
22030
|
+
const keyValueSep = options.arrayFormat === 'bracket-separator' ?
|
|
22031
|
+
'[]=' :
|
|
22032
|
+
'=';
|
|
22033
|
+
|
|
22034
|
+
return key => (result, value) => {
|
|
22035
|
+
if (
|
|
22036
|
+
value === undefined ||
|
|
22037
|
+
(options.skipNull && value === null) ||
|
|
22038
|
+
(options.skipEmptyString && value === '')
|
|
22039
|
+
) {
|
|
22040
|
+
return result;
|
|
22041
|
+
}
|
|
22042
|
+
|
|
22043
|
+
// Translate null to an empty string so that it doesn't serialize as 'null'
|
|
22044
|
+
value = value === null ? '' : value;
|
|
22045
|
+
|
|
22046
|
+
if (result.length === 0) {
|
|
22047
|
+
return [[encode(key, options), keyValueSep, encode(value, options)].join('')];
|
|
22048
|
+
}
|
|
22049
|
+
|
|
22050
|
+
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
|
|
22051
|
+
};
|
|
22052
|
+
}
|
|
22053
|
+
|
|
22054
|
+
default:
|
|
22055
|
+
return key => (result, value) => {
|
|
22056
|
+
if (
|
|
22057
|
+
value === undefined ||
|
|
22058
|
+
(options.skipNull && value === null) ||
|
|
22059
|
+
(options.skipEmptyString && value === '')
|
|
22060
|
+
) {
|
|
22061
|
+
return result;
|
|
22062
|
+
}
|
|
22063
|
+
|
|
22064
|
+
if (value === null) {
|
|
22065
|
+
return [...result, encode(key, options)];
|
|
22066
|
+
}
|
|
22067
|
+
|
|
22068
|
+
return [...result, [encode(key, options), '=', encode(value, options)].join('')];
|
|
22069
|
+
};
|
|
22070
|
+
}
|
|
22071
|
+
}
|
|
22072
|
+
|
|
22073
|
+
function parserForArrayFormat(options) {
|
|
22074
|
+
let result;
|
|
22075
|
+
|
|
22076
|
+
switch (options.arrayFormat) {
|
|
22077
|
+
case 'index':
|
|
22078
|
+
return (key, value, accumulator) => {
|
|
22079
|
+
result = /\[(\d*)\]$/.exec(key);
|
|
22080
|
+
|
|
22081
|
+
key = key.replace(/\[\d*\]$/, '');
|
|
22082
|
+
|
|
22083
|
+
if (!result) {
|
|
22084
|
+
accumulator[key] = value;
|
|
22085
|
+
return;
|
|
22086
|
+
}
|
|
22087
|
+
|
|
22088
|
+
if (accumulator[key] === undefined) {
|
|
22089
|
+
accumulator[key] = {};
|
|
22090
|
+
}
|
|
22091
|
+
|
|
22092
|
+
accumulator[key][result[1]] = value;
|
|
22093
|
+
};
|
|
22094
|
+
|
|
22095
|
+
case 'bracket':
|
|
22096
|
+
return (key, value, accumulator) => {
|
|
22097
|
+
result = /(\[\])$/.exec(key);
|
|
22098
|
+
key = key.replace(/\[\]$/, '');
|
|
22099
|
+
|
|
22100
|
+
if (!result) {
|
|
22101
|
+
accumulator[key] = value;
|
|
22102
|
+
return;
|
|
22103
|
+
}
|
|
22104
|
+
|
|
22105
|
+
if (accumulator[key] === undefined) {
|
|
22106
|
+
accumulator[key] = [value];
|
|
22107
|
+
return;
|
|
22108
|
+
}
|
|
22109
|
+
|
|
22110
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
22111
|
+
};
|
|
22112
|
+
|
|
22113
|
+
case 'colon-list-separator':
|
|
22114
|
+
return (key, value, accumulator) => {
|
|
22115
|
+
result = /(:list)$/.exec(key);
|
|
22116
|
+
key = key.replace(/:list$/, '');
|
|
22117
|
+
|
|
22118
|
+
if (!result) {
|
|
22119
|
+
accumulator[key] = value;
|
|
22120
|
+
return;
|
|
22121
|
+
}
|
|
22122
|
+
|
|
22123
|
+
if (accumulator[key] === undefined) {
|
|
22124
|
+
accumulator[key] = [value];
|
|
22125
|
+
return;
|
|
22126
|
+
}
|
|
22127
|
+
|
|
22128
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
22129
|
+
};
|
|
22130
|
+
|
|
22131
|
+
case 'comma':
|
|
22132
|
+
case 'separator':
|
|
22133
|
+
return (key, value, accumulator) => {
|
|
22134
|
+
const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator);
|
|
22135
|
+
const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator));
|
|
22136
|
+
value = isEncodedArray ? decode(value, options) : value;
|
|
22137
|
+
const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options);
|
|
22138
|
+
accumulator[key] = newValue;
|
|
22139
|
+
};
|
|
22140
|
+
|
|
22141
|
+
case 'bracket-separator':
|
|
22142
|
+
return (key, value, accumulator) => {
|
|
22143
|
+
const isArray = /(\[\])$/.test(key);
|
|
22144
|
+
key = key.replace(/\[\]$/, '');
|
|
22145
|
+
|
|
22146
|
+
if (!isArray) {
|
|
22147
|
+
accumulator[key] = value ? decode(value, options) : value;
|
|
22148
|
+
return;
|
|
22149
|
+
}
|
|
22150
|
+
|
|
22151
|
+
const arrayValue = value === null ?
|
|
22152
|
+
[] :
|
|
22153
|
+
value.split(options.arrayFormatSeparator).map(item => decode(item, options));
|
|
22154
|
+
|
|
22155
|
+
if (accumulator[key] === undefined) {
|
|
22156
|
+
accumulator[key] = arrayValue;
|
|
22157
|
+
return;
|
|
22158
|
+
}
|
|
22159
|
+
|
|
22160
|
+
accumulator[key] = [].concat(accumulator[key], arrayValue);
|
|
22161
|
+
};
|
|
22162
|
+
|
|
22163
|
+
default:
|
|
22164
|
+
return (key, value, accumulator) => {
|
|
22165
|
+
if (accumulator[key] === undefined) {
|
|
22166
|
+
accumulator[key] = value;
|
|
22167
|
+
return;
|
|
22168
|
+
}
|
|
22169
|
+
|
|
22170
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
22171
|
+
};
|
|
22172
|
+
}
|
|
22173
|
+
}
|
|
22174
|
+
|
|
22175
|
+
function validateArrayFormatSeparator(value) {
|
|
22176
|
+
if (typeof value !== 'string' || value.length !== 1) {
|
|
22177
|
+
throw new TypeError('arrayFormatSeparator must be single character string');
|
|
22178
|
+
}
|
|
22179
|
+
}
|
|
22180
|
+
|
|
22181
|
+
function encode(value, options) {
|
|
22182
|
+
if (options.encode) {
|
|
22183
|
+
return options.strict ? strictUriEncode(value) : encodeURIComponent(value);
|
|
22184
|
+
}
|
|
22185
|
+
|
|
22186
|
+
return value;
|
|
22187
|
+
}
|
|
22188
|
+
|
|
22189
|
+
function decode(value, options) {
|
|
22190
|
+
if (options.decode) {
|
|
22191
|
+
return decodeComponent(value);
|
|
22192
|
+
}
|
|
22193
|
+
|
|
22194
|
+
return value;
|
|
22195
|
+
}
|
|
22196
|
+
|
|
22197
|
+
function keysSorter(input) {
|
|
22198
|
+
if (Array.isArray(input)) {
|
|
22199
|
+
return input.sort();
|
|
22200
|
+
}
|
|
22201
|
+
|
|
22202
|
+
if (typeof input === 'object') {
|
|
22203
|
+
return keysSorter(Object.keys(input))
|
|
22204
|
+
.sort((a, b) => Number(a) - Number(b))
|
|
22205
|
+
.map(key => input[key]);
|
|
22206
|
+
}
|
|
22207
|
+
|
|
22208
|
+
return input;
|
|
22209
|
+
}
|
|
22210
|
+
|
|
22211
|
+
function removeHash(input) {
|
|
22212
|
+
const hashStart = input.indexOf('#');
|
|
22213
|
+
if (hashStart !== -1) {
|
|
22214
|
+
input = input.slice(0, hashStart);
|
|
22215
|
+
}
|
|
22216
|
+
|
|
22217
|
+
return input;
|
|
22218
|
+
}
|
|
22219
|
+
|
|
22220
|
+
function getHash(url) {
|
|
22221
|
+
let hash = '';
|
|
22222
|
+
const hashStart = url.indexOf('#');
|
|
22223
|
+
if (hashStart !== -1) {
|
|
22224
|
+
hash = url.slice(hashStart);
|
|
22225
|
+
}
|
|
22226
|
+
|
|
22227
|
+
return hash;
|
|
22228
|
+
}
|
|
22229
|
+
|
|
22230
|
+
function extract(input) {
|
|
22231
|
+
input = removeHash(input);
|
|
22232
|
+
const queryStart = input.indexOf('?');
|
|
22233
|
+
if (queryStart === -1) {
|
|
22234
|
+
return '';
|
|
22235
|
+
}
|
|
22236
|
+
|
|
22237
|
+
return input.slice(queryStart + 1);
|
|
22238
|
+
}
|
|
22239
|
+
|
|
22240
|
+
function parseValue(value, options) {
|
|
22241
|
+
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
|
|
22242
|
+
value = Number(value);
|
|
22243
|
+
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
|
|
22244
|
+
value = value.toLowerCase() === 'true';
|
|
22245
|
+
}
|
|
22246
|
+
|
|
22247
|
+
return value;
|
|
22248
|
+
}
|
|
22249
|
+
|
|
22250
|
+
function parse(query, options) {
|
|
22251
|
+
options = Object.assign({
|
|
22252
|
+
decode: true,
|
|
22253
|
+
sort: true,
|
|
22254
|
+
arrayFormat: 'none',
|
|
22255
|
+
arrayFormatSeparator: ',',
|
|
22256
|
+
parseNumbers: false,
|
|
22257
|
+
parseBooleans: false
|
|
22258
|
+
}, options);
|
|
22259
|
+
|
|
22260
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
22261
|
+
|
|
22262
|
+
const formatter = parserForArrayFormat(options);
|
|
22263
|
+
|
|
22264
|
+
// Create an object with no prototype
|
|
22265
|
+
const ret = Object.create(null);
|
|
22266
|
+
|
|
22267
|
+
if (typeof query !== 'string') {
|
|
22268
|
+
return ret;
|
|
22269
|
+
}
|
|
22270
|
+
|
|
22271
|
+
query = query.trim().replace(/^[?#&]/, '');
|
|
22272
|
+
|
|
22273
|
+
if (!query) {
|
|
22274
|
+
return ret;
|
|
22275
|
+
}
|
|
22276
|
+
|
|
22277
|
+
for (const param of query.split('&')) {
|
|
22278
|
+
if (param === '') {
|
|
22279
|
+
continue;
|
|
22280
|
+
}
|
|
22281
|
+
|
|
22282
|
+
let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, ' ') : param, '=');
|
|
22283
|
+
|
|
22284
|
+
// Missing `=` should be `null`:
|
|
22285
|
+
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
|
22286
|
+
value = value === undefined ? null : ['comma', 'separator', 'bracket-separator'].includes(options.arrayFormat) ? value : decode(value, options);
|
|
22287
|
+
formatter(decode(key, options), value, ret);
|
|
22288
|
+
}
|
|
22289
|
+
|
|
22290
|
+
for (const key of Object.keys(ret)) {
|
|
22291
|
+
const value = ret[key];
|
|
22292
|
+
if (typeof value === 'object' && value !== null) {
|
|
22293
|
+
for (const k of Object.keys(value)) {
|
|
22294
|
+
value[k] = parseValue(value[k], options);
|
|
22295
|
+
}
|
|
22296
|
+
} else {
|
|
22297
|
+
ret[key] = parseValue(value, options);
|
|
22298
|
+
}
|
|
22299
|
+
}
|
|
22300
|
+
|
|
22301
|
+
if (options.sort === false) {
|
|
22302
|
+
return ret;
|
|
22303
|
+
}
|
|
22304
|
+
|
|
22305
|
+
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
|
|
22306
|
+
const value = ret[key];
|
|
22307
|
+
if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) {
|
|
22308
|
+
// Sort object keys, not values
|
|
22309
|
+
result[key] = keysSorter(value);
|
|
22310
|
+
} else {
|
|
22311
|
+
result[key] = value;
|
|
22312
|
+
}
|
|
22313
|
+
|
|
22314
|
+
return result;
|
|
22315
|
+
}, Object.create(null));
|
|
22316
|
+
}
|
|
22317
|
+
|
|
22318
|
+
exports.extract = extract;
|
|
22319
|
+
exports.parse = parse;
|
|
22320
|
+
|
|
22321
|
+
exports.stringify = (object, options) => {
|
|
22322
|
+
if (!object) {
|
|
22323
|
+
return '';
|
|
22324
|
+
}
|
|
22325
|
+
|
|
22326
|
+
options = Object.assign({
|
|
22327
|
+
encode: true,
|
|
22328
|
+
strict: true,
|
|
22329
|
+
arrayFormat: 'none',
|
|
22330
|
+
arrayFormatSeparator: ','
|
|
22331
|
+
}, options);
|
|
22332
|
+
|
|
22333
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
22334
|
+
|
|
22335
|
+
const shouldFilter = key => (
|
|
22336
|
+
(options.skipNull && isNullOrUndefined(object[key])) ||
|
|
22337
|
+
(options.skipEmptyString && object[key] === '')
|
|
22338
|
+
);
|
|
22339
|
+
|
|
22340
|
+
const formatter = encoderForArrayFormat(options);
|
|
22341
|
+
|
|
22342
|
+
const objectCopy = {};
|
|
22343
|
+
|
|
22344
|
+
for (const key of Object.keys(object)) {
|
|
22345
|
+
if (!shouldFilter(key)) {
|
|
22346
|
+
objectCopy[key] = object[key];
|
|
22347
|
+
}
|
|
22348
|
+
}
|
|
22349
|
+
|
|
22350
|
+
const keys = Object.keys(objectCopy);
|
|
22351
|
+
|
|
22352
|
+
if (options.sort !== false) {
|
|
22353
|
+
keys.sort(options.sort);
|
|
22354
|
+
}
|
|
22355
|
+
|
|
22356
|
+
return keys.map(key => {
|
|
22357
|
+
const value = object[key];
|
|
22358
|
+
|
|
22359
|
+
if (value === undefined) {
|
|
22360
|
+
return '';
|
|
22361
|
+
}
|
|
22362
|
+
|
|
22363
|
+
if (value === null) {
|
|
22364
|
+
return encode(key, options);
|
|
22365
|
+
}
|
|
22366
|
+
|
|
22367
|
+
if (Array.isArray(value)) {
|
|
22368
|
+
if (value.length === 0 && options.arrayFormat === 'bracket-separator') {
|
|
22369
|
+
return encode(key, options) + '[]';
|
|
22370
|
+
}
|
|
22371
|
+
|
|
22372
|
+
return value
|
|
22373
|
+
.reduce(formatter(key), [])
|
|
22374
|
+
.join('&');
|
|
22375
|
+
}
|
|
22376
|
+
|
|
22377
|
+
return encode(key, options) + '=' + encode(value, options);
|
|
22378
|
+
}).filter(x => x.length > 0).join('&');
|
|
22379
|
+
};
|
|
22380
|
+
|
|
22381
|
+
exports.parseUrl = (url, options) => {
|
|
22382
|
+
options = Object.assign({
|
|
22383
|
+
decode: true
|
|
22384
|
+
}, options);
|
|
22385
|
+
|
|
22386
|
+
const [url_, hash] = splitOnFirst(url, '#');
|
|
22387
|
+
|
|
22388
|
+
return Object.assign(
|
|
22389
|
+
{
|
|
22390
|
+
url: url_.split('?')[0] || '',
|
|
22391
|
+
query: parse(extract(url), options)
|
|
22392
|
+
},
|
|
22393
|
+
options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {}
|
|
22394
|
+
);
|
|
22395
|
+
};
|
|
22396
|
+
|
|
22397
|
+
exports.stringifyUrl = (object, options) => {
|
|
22398
|
+
options = Object.assign({
|
|
22399
|
+
encode: true,
|
|
22400
|
+
strict: true,
|
|
22401
|
+
[encodeFragmentIdentifier]: true
|
|
22402
|
+
}, options);
|
|
22403
|
+
|
|
22404
|
+
const url = removeHash(object.url).split('?')[0] || '';
|
|
22405
|
+
const queryFromUrl = exports.extract(object.url);
|
|
22406
|
+
const parsedQueryFromUrl = exports.parse(queryFromUrl, {sort: false});
|
|
22407
|
+
|
|
22408
|
+
const query = Object.assign(parsedQueryFromUrl, object.query);
|
|
22409
|
+
let queryString = exports.stringify(query, options);
|
|
22410
|
+
if (queryString) {
|
|
22411
|
+
queryString = `?${queryString}`;
|
|
22412
|
+
}
|
|
22413
|
+
|
|
22414
|
+
let hash = getHash(object.url);
|
|
22415
|
+
if (object.fragmentIdentifier) {
|
|
22416
|
+
hash = `#${options[encodeFragmentIdentifier] ? encode(object.fragmentIdentifier, options) : object.fragmentIdentifier}`;
|
|
22417
|
+
}
|
|
22418
|
+
|
|
22419
|
+
return `${url}${queryString}${hash}`;
|
|
22420
|
+
};
|
|
22421
|
+
|
|
22422
|
+
exports.pick = (input, filter, options) => {
|
|
22423
|
+
options = Object.assign({
|
|
22424
|
+
parseFragmentIdentifier: true,
|
|
22425
|
+
[encodeFragmentIdentifier]: false
|
|
22426
|
+
}, options);
|
|
22427
|
+
|
|
22428
|
+
const {url, query, fragmentIdentifier} = exports.parseUrl(input, options);
|
|
22429
|
+
return exports.stringifyUrl({
|
|
22430
|
+
url,
|
|
22431
|
+
query: filterObject(query, filter),
|
|
22432
|
+
fragmentIdentifier
|
|
22433
|
+
}, options);
|
|
22434
|
+
};
|
|
22435
|
+
|
|
22436
|
+
exports.exclude = (input, filter, options) => {
|
|
22437
|
+
const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value);
|
|
22438
|
+
|
|
22439
|
+
return exports.pick(input, exclusionFilter, options);
|
|
22440
|
+
};
|
|
22441
|
+
|
|
22442
|
+
|
|
21772
22443
|
/***/ }),
|
|
21773
22444
|
|
|
21774
22445
|
/***/ "./node_modules/querystring/decode.js":
|
|
@@ -25925,6 +26596,39 @@ Sha512.prototype._hash = function () {
|
|
|
25925
26596
|
module.exports = Sha512
|
|
25926
26597
|
|
|
25927
26598
|
|
|
26599
|
+
/***/ }),
|
|
26600
|
+
|
|
26601
|
+
/***/ "./node_modules/split-on-first/index.js":
|
|
26602
|
+
/*!**********************************************!*\
|
|
26603
|
+
!*** ./node_modules/split-on-first/index.js ***!
|
|
26604
|
+
\**********************************************/
|
|
26605
|
+
/***/ ((module) => {
|
|
26606
|
+
|
|
26607
|
+
"use strict";
|
|
26608
|
+
|
|
26609
|
+
|
|
26610
|
+
module.exports = (string, separator) => {
|
|
26611
|
+
if (!(typeof string === 'string' && typeof separator === 'string')) {
|
|
26612
|
+
throw new TypeError('Expected the arguments to be of type `string`');
|
|
26613
|
+
}
|
|
26614
|
+
|
|
26615
|
+
if (separator === '') {
|
|
26616
|
+
return [string];
|
|
26617
|
+
}
|
|
26618
|
+
|
|
26619
|
+
const separatorIndex = string.indexOf(separator);
|
|
26620
|
+
|
|
26621
|
+
if (separatorIndex === -1) {
|
|
26622
|
+
return [string];
|
|
26623
|
+
}
|
|
26624
|
+
|
|
26625
|
+
return [
|
|
26626
|
+
string.slice(0, separatorIndex),
|
|
26627
|
+
string.slice(separatorIndex + separator.length)
|
|
26628
|
+
];
|
|
26629
|
+
};
|
|
26630
|
+
|
|
26631
|
+
|
|
25928
26632
|
/***/ }),
|
|
25929
26633
|
|
|
25930
26634
|
/***/ "./node_modules/stellar-base/lib/account.js":
|
|
@@ -45354,6 +46058,19 @@ IncomingMessage.prototype._onXHRProgress = function (resetTimers) {
|
|
|
45354
46058
|
}
|
|
45355
46059
|
|
|
45356
46060
|
|
|
46061
|
+
/***/ }),
|
|
46062
|
+
|
|
46063
|
+
/***/ "./node_modules/strict-uri-encode/index.js":
|
|
46064
|
+
/*!*************************************************!*\
|
|
46065
|
+
!*** ./node_modules/strict-uri-encode/index.js ***!
|
|
46066
|
+
\*************************************************/
|
|
46067
|
+
/***/ ((module) => {
|
|
46068
|
+
|
|
46069
|
+
"use strict";
|
|
46070
|
+
|
|
46071
|
+
module.exports = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
46072
|
+
|
|
46073
|
+
|
|
45357
46074
|
/***/ }),
|
|
45358
46075
|
|
|
45359
46076
|
/***/ "./node_modules/string_decoder/lib/string_decoder.js":
|
|
@@ -49770,7 +50487,46 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
49770
50487
|
return result;
|
|
49771
50488
|
};
|
|
49772
50489
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
49773
|
-
exports.Keypair = exports.walletSdk = void 0;
|
|
50490
|
+
exports.Keypair = exports.walletSdk = exports.Exceptions = exports.Utils = exports.Watcher = exports.Recovery = exports.Interactive = exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = exports.DefaultSigner = exports.Auth = exports.Anchor = exports.ApplicationConfiguration = exports.StellarConfiguration = exports.Config = exports.Wallet = exports.Types = void 0;
|
|
50491
|
+
/**
|
|
50492
|
+
* Types
|
|
50493
|
+
*/
|
|
50494
|
+
var Types = __importStar(__webpack_require__(/*! ./walletSdk/Types */ "./src/walletSdk/Types/index.ts"));
|
|
50495
|
+
exports.Types = Types;
|
|
50496
|
+
/**
|
|
50497
|
+
* Classes
|
|
50498
|
+
*/
|
|
50499
|
+
var walletSdk_1 = __webpack_require__(/*! ./walletSdk */ "./src/walletSdk/index.ts");
|
|
50500
|
+
Object.defineProperty(exports, "Wallet", ({ enumerable: true, get: function () { return walletSdk_1.Wallet; } }));
|
|
50501
|
+
Object.defineProperty(exports, "Config", ({ enumerable: true, get: function () { return walletSdk_1.Config; } }));
|
|
50502
|
+
Object.defineProperty(exports, "StellarConfiguration", ({ enumerable: true, get: function () { return walletSdk_1.StellarConfiguration; } }));
|
|
50503
|
+
Object.defineProperty(exports, "ApplicationConfiguration", ({ enumerable: true, get: function () { return walletSdk_1.ApplicationConfiguration; } }));
|
|
50504
|
+
var Anchor_1 = __webpack_require__(/*! ./walletSdk/Anchor */ "./src/walletSdk/Anchor/index.ts");
|
|
50505
|
+
Object.defineProperty(exports, "Anchor", ({ enumerable: true, get: function () { return Anchor_1.Anchor; } }));
|
|
50506
|
+
var Auth_1 = __webpack_require__(/*! ./walletSdk/Auth */ "./src/walletSdk/Auth/index.ts");
|
|
50507
|
+
Object.defineProperty(exports, "Auth", ({ enumerable: true, get: function () { return Auth_1.Auth; } }));
|
|
50508
|
+
Object.defineProperty(exports, "DefaultSigner", ({ enumerable: true, get: function () { return Auth_1.DefaultSigner; } }));
|
|
50509
|
+
var Horizon_1 = __webpack_require__(/*! ./walletSdk/Horizon */ "./src/walletSdk/Horizon/index.ts");
|
|
50510
|
+
Object.defineProperty(exports, "PublicKeypair", ({ enumerable: true, get: function () { return Horizon_1.PublicKeypair; } }));
|
|
50511
|
+
Object.defineProperty(exports, "SigningKeypair", ({ enumerable: true, get: function () { return Horizon_1.SigningKeypair; } }));
|
|
50512
|
+
Object.defineProperty(exports, "AccountService", ({ enumerable: true, get: function () { return Horizon_1.AccountService; } }));
|
|
50513
|
+
Object.defineProperty(exports, "Stellar", ({ enumerable: true, get: function () { return Horizon_1.Stellar; } }));
|
|
50514
|
+
var Interactive_1 = __webpack_require__(/*! ./walletSdk/Interactive */ "./src/walletSdk/Interactive/index.ts");
|
|
50515
|
+
Object.defineProperty(exports, "Interactive", ({ enumerable: true, get: function () { return Interactive_1.Interactive; } }));
|
|
50516
|
+
var Recovery_1 = __webpack_require__(/*! ./walletSdk/Recovery */ "./src/walletSdk/Recovery/index.ts");
|
|
50517
|
+
Object.defineProperty(exports, "Recovery", ({ enumerable: true, get: function () { return Recovery_1.Recovery; } }));
|
|
50518
|
+
var Watcher_1 = __webpack_require__(/*! ./walletSdk/Watcher */ "./src/walletSdk/Watcher/index.ts");
|
|
50519
|
+
Object.defineProperty(exports, "Watcher", ({ enumerable: true, get: function () { return Watcher_1.Watcher; } }));
|
|
50520
|
+
/**
|
|
50521
|
+
* Utils
|
|
50522
|
+
*/
|
|
50523
|
+
var Utils = __importStar(__webpack_require__(/*! ./walletSdk/Utils */ "./src/walletSdk/Utils/index.ts"));
|
|
50524
|
+
exports.Utils = Utils;
|
|
50525
|
+
/**
|
|
50526
|
+
* Exceptions
|
|
50527
|
+
*/
|
|
50528
|
+
var Exceptions = __importStar(__webpack_require__(/*! ./walletSdk/Exceptions */ "./src/walletSdk/Exceptions/index.ts"));
|
|
50529
|
+
exports.Exceptions = Exceptions;
|
|
49774
50530
|
var walletSdk = __importStar(__webpack_require__(/*! ./walletSdk */ "./src/walletSdk/index.ts"));
|
|
49775
50531
|
exports.walletSdk = walletSdk;
|
|
49776
50532
|
var stellar_sdk_1 = __webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js");
|
|
@@ -49788,6 +50544,17 @@ exports["default"] = { walletSdk: walletSdk };
|
|
|
49788
50544
|
|
|
49789
50545
|
"use strict";
|
|
49790
50546
|
|
|
50547
|
+
var __assign = (this && this.__assign) || function () {
|
|
50548
|
+
__assign = Object.assign || function(t) {
|
|
50549
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
50550
|
+
s = arguments[i];
|
|
50551
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
50552
|
+
t[p] = s[p];
|
|
50553
|
+
}
|
|
50554
|
+
return t;
|
|
50555
|
+
};
|
|
50556
|
+
return __assign.apply(this, arguments);
|
|
50557
|
+
};
|
|
49791
50558
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
49792
50559
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
49793
50560
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -49829,30 +50596,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
49829
50596
|
};
|
|
49830
50597
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
49831
50598
|
exports.Anchor = void 0;
|
|
50599
|
+
var query_string_1 = __importDefault(__webpack_require__(/*! query-string */ "./node_modules/query-string/index.js"));
|
|
49832
50600
|
var stellar_sdk_1 = __webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js");
|
|
49833
|
-
var axios_1 = __importDefault(__webpack_require__(/*! axios */ "./node_modules/axios/dist/browser/axios.cjs"));
|
|
49834
50601
|
var Auth_1 = __webpack_require__(/*! ../Auth */ "./src/walletSdk/Auth/index.ts");
|
|
49835
|
-
var
|
|
49836
|
-
var
|
|
49837
|
-
var
|
|
50602
|
+
var Exceptions_1 = __webpack_require__(/*! ../Exceptions */ "./src/walletSdk/Exceptions/index.ts");
|
|
50603
|
+
var Interactive_1 = __webpack_require__(/*! ../Interactive */ "./src/walletSdk/Interactive/index.ts");
|
|
50604
|
+
var Types_1 = __webpack_require__(/*! ../Types */ "./src/walletSdk/Types/index.ts");
|
|
50605
|
+
var Watcher_1 = __webpack_require__(/*! ../Watcher */ "./src/walletSdk/Watcher/index.ts");
|
|
50606
|
+
var Utils_1 = __webpack_require__(/*! ../Utils */ "./src/walletSdk/Utils/index.ts");
|
|
49838
50607
|
// Do not create this object directly, use the Wallet class.
|
|
49839
50608
|
var Anchor = /** @class */ (function () {
|
|
49840
|
-
function Anchor(
|
|
49841
|
-
|
|
49842
|
-
this.
|
|
50609
|
+
function Anchor(params) {
|
|
50610
|
+
var cfg = params.cfg, homeDomain = params.homeDomain, httpClient = params.httpClient, language = params.language;
|
|
50611
|
+
this.cfg = cfg;
|
|
49843
50612
|
this.homeDomain = homeDomain;
|
|
49844
50613
|
this.httpClient = httpClient;
|
|
49845
|
-
this.
|
|
50614
|
+
this.language = language;
|
|
49846
50615
|
}
|
|
49847
|
-
Anchor.prototype.getInfo = function () {
|
|
50616
|
+
Anchor.prototype.getInfo = function (shouldRefresh) {
|
|
49848
50617
|
return __awaiter(this, void 0, void 0, function () {
|
|
49849
|
-
var
|
|
50618
|
+
var stellarToml, parsedToml;
|
|
49850
50619
|
return __generator(this, function (_a) {
|
|
49851
50620
|
switch (_a.label) {
|
|
49852
|
-
case 0:
|
|
50621
|
+
case 0:
|
|
50622
|
+
// return cached TOML values by default
|
|
50623
|
+
if (this.toml && !shouldRefresh) {
|
|
50624
|
+
return [2 /*return*/, this.toml];
|
|
50625
|
+
}
|
|
50626
|
+
return [4 /*yield*/, stellar_sdk_1.StellarTomlResolver.resolve(this.homeDomain)];
|
|
49853
50627
|
case 1:
|
|
49854
|
-
|
|
49855
|
-
|
|
50628
|
+
stellarToml = _a.sent();
|
|
50629
|
+
parsedToml = (0, Utils_1.parseToml)(stellarToml);
|
|
50630
|
+
this.toml = parsedToml;
|
|
50631
|
+
return [2 /*return*/, parsedToml];
|
|
49856
50632
|
}
|
|
49857
50633
|
});
|
|
49858
50634
|
});
|
|
@@ -49865,17 +50641,26 @@ var Anchor = /** @class */ (function () {
|
|
|
49865
50641
|
case 0: return [4 /*yield*/, this.getInfo()];
|
|
49866
50642
|
case 1:
|
|
49867
50643
|
tomlInfo = _a.sent();
|
|
49868
|
-
return [2 /*return*/, new Auth_1.Auth(
|
|
50644
|
+
return [2 /*return*/, new Auth_1.Auth({
|
|
50645
|
+
cfg: this.cfg,
|
|
50646
|
+
webAuthEndpoint: tomlInfo.webAuthEndpoint,
|
|
50647
|
+
homeDomain: this.homeDomain,
|
|
50648
|
+
httpClient: this.httpClient
|
|
50649
|
+
})];
|
|
49869
50650
|
}
|
|
49870
50651
|
});
|
|
49871
50652
|
});
|
|
49872
50653
|
};
|
|
49873
50654
|
Anchor.prototype.interactive = function () {
|
|
49874
|
-
return new
|
|
50655
|
+
return new Interactive_1.Interactive({ anchor: this, httpClient: this.httpClient });
|
|
50656
|
+
};
|
|
50657
|
+
Anchor.prototype.watcher = function () {
|
|
50658
|
+
return new Watcher_1.Watcher(this);
|
|
49875
50659
|
};
|
|
49876
|
-
Anchor.prototype.getServicesInfo = function () {
|
|
50660
|
+
Anchor.prototype.getServicesInfo = function (lang) {
|
|
50661
|
+
if (lang === void 0) { lang = this.language; }
|
|
49877
50662
|
return __awaiter(this, void 0, void 0, function () {
|
|
49878
|
-
var toml, transferServerEndpoint, resp, e_1;
|
|
50663
|
+
var toml, transferServerEndpoint, resp, servicesInfo, e_1;
|
|
49879
50664
|
return __generator(this, function (_a) {
|
|
49880
50665
|
switch (_a.label) {
|
|
49881
50666
|
case 0: return [4 /*yield*/, this.getInfo()];
|
|
@@ -49885,25 +50670,195 @@ var Anchor = /** @class */ (function () {
|
|
|
49885
50670
|
_a.label = 2;
|
|
49886
50671
|
case 2:
|
|
49887
50672
|
_a.trys.push([2, 4, , 5]);
|
|
49888
|
-
return [4 /*yield*/,
|
|
50673
|
+
return [4 /*yield*/, this.httpClient.get("".concat(transferServerEndpoint, "/info?lang=").concat(lang), {
|
|
49889
50674
|
headers: {
|
|
49890
50675
|
"Content-Type": "application/json",
|
|
49891
50676
|
},
|
|
49892
50677
|
})];
|
|
49893
50678
|
case 3:
|
|
49894
50679
|
resp = _a.sent();
|
|
49895
|
-
|
|
50680
|
+
servicesInfo = resp.data;
|
|
50681
|
+
return [2 /*return*/, servicesInfo];
|
|
49896
50682
|
case 4:
|
|
49897
50683
|
e_1 = _a.sent();
|
|
49898
|
-
throw new
|
|
50684
|
+
throw new Exceptions_1.ServerRequestFailedError(e_1);
|
|
50685
|
+
case 5: return [2 /*return*/];
|
|
50686
|
+
}
|
|
50687
|
+
});
|
|
50688
|
+
});
|
|
50689
|
+
};
|
|
50690
|
+
/**
|
|
50691
|
+
* Get single transaction's current status and details. One of the [id], [stellarTransactionId],
|
|
50692
|
+
* [externalTransactionId] must be provided.
|
|
50693
|
+
*
|
|
50694
|
+
* @param authToken auth token of the account authenticated with the anchor
|
|
50695
|
+
* @param id transaction ID
|
|
50696
|
+
* @param stellarTransactionId stellar transaction ID
|
|
50697
|
+
* @param externalTransactionId external transaction ID
|
|
50698
|
+
* @return transaction object
|
|
50699
|
+
* @throws [MissingTransactionIdError] if none of the id params is provided
|
|
50700
|
+
* @throws [InvalidTransactionResponseError] if Anchor returns an invalid transaction
|
|
50701
|
+
* @throws [ServerRequestFailedError] if server request fails
|
|
50702
|
+
*/
|
|
50703
|
+
Anchor.prototype.getTransactionBy = function (_a) {
|
|
50704
|
+
var authToken = _a.authToken, id = _a.id, stellarTransactionId = _a.stellarTransactionId, externalTransactionId = _a.externalTransactionId, _b = _a.lang, lang = _b === void 0 ? this.language : _b;
|
|
50705
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50706
|
+
var toml, transferServerEndpoint, qs, resp, transaction, e_2;
|
|
50707
|
+
return __generator(this, function (_c) {
|
|
50708
|
+
switch (_c.label) {
|
|
50709
|
+
case 0:
|
|
50710
|
+
if (!id && !stellarTransactionId && !externalTransactionId) {
|
|
50711
|
+
throw new Exceptions_1.MissingTransactionIdError();
|
|
50712
|
+
}
|
|
50713
|
+
return [4 /*yield*/, this.getInfo()];
|
|
50714
|
+
case 1:
|
|
50715
|
+
toml = _c.sent();
|
|
50716
|
+
transferServerEndpoint = toml.transferServerSep24;
|
|
50717
|
+
qs = {};
|
|
50718
|
+
if (id) {
|
|
50719
|
+
qs = { id: id };
|
|
50720
|
+
}
|
|
50721
|
+
else if (stellarTransactionId) {
|
|
50722
|
+
qs = { stellar_transaction_id: stellarTransactionId };
|
|
50723
|
+
}
|
|
50724
|
+
else if (externalTransactionId) {
|
|
50725
|
+
qs = { external_transaction_id: externalTransactionId };
|
|
50726
|
+
}
|
|
50727
|
+
qs = __assign({ lang: lang }, qs);
|
|
50728
|
+
_c.label = 2;
|
|
50729
|
+
case 2:
|
|
50730
|
+
_c.trys.push([2, 4, , 5]);
|
|
50731
|
+
return [4 /*yield*/, this.httpClient.get("".concat(transferServerEndpoint, "/transaction?").concat(query_string_1.default.stringify(qs)), {
|
|
50732
|
+
headers: {
|
|
50733
|
+
Authorization: "Bearer ".concat(authToken),
|
|
50734
|
+
},
|
|
50735
|
+
})];
|
|
50736
|
+
case 3:
|
|
50737
|
+
resp = _c.sent();
|
|
50738
|
+
transaction = resp.data.transaction;
|
|
50739
|
+
if (!transaction || Object.keys(transaction).length === 0) {
|
|
50740
|
+
throw new Exceptions_1.InvalidTransactionResponseError(transaction);
|
|
50741
|
+
}
|
|
50742
|
+
return [2 /*return*/, transaction];
|
|
50743
|
+
case 4:
|
|
50744
|
+
e_2 = _c.sent();
|
|
50745
|
+
throw new Exceptions_1.ServerRequestFailedError(e_2);
|
|
50746
|
+
case 5: return [2 /*return*/];
|
|
50747
|
+
}
|
|
50748
|
+
});
|
|
50749
|
+
});
|
|
50750
|
+
};
|
|
50751
|
+
/**
|
|
50752
|
+
* Get account's transactions specified by asset and other params.
|
|
50753
|
+
*
|
|
50754
|
+
* @param authToken auth token of the account authenticated with the anchor
|
|
50755
|
+
* @param assetCode target asset to query for
|
|
50756
|
+
* @param noOlderThan response should contain transactions starting on or after this date & time
|
|
50757
|
+
* @param limit response should contain at most 'limit' transactions
|
|
50758
|
+
* @param kind kind of transaction that is desired. E.g.: 'deposit', 'withdrawal'
|
|
50759
|
+
* @param pagingId response should contain transactions starting prior to this ID (exclusive)
|
|
50760
|
+
* @param lang desired language (localization), it can also accept locale in the format 'en-US'
|
|
50761
|
+
* @return list of transactions as requested by the client, sorted in time-descending order
|
|
50762
|
+
* @throws [InvalidTransactionsResponseError] if Anchor returns an invalid response
|
|
50763
|
+
* @throws [ServerRequestFailedError] if server request fails
|
|
50764
|
+
*/
|
|
50765
|
+
Anchor.prototype.getTransactionsForAsset = function (_a) {
|
|
50766
|
+
var authToken = _a.authToken, assetCode = _a.assetCode, noOlderThan = _a.noOlderThan, limit = _a.limit, kind = _a.kind, pagingId = _a.pagingId, _b = _a.lang, lang = _b === void 0 ? this.language : _b;
|
|
50767
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50768
|
+
var toml, transferServerEndpoint, apiParams, resp, transactions, e_3;
|
|
50769
|
+
return __generator(this, function (_c) {
|
|
50770
|
+
switch (_c.label) {
|
|
50771
|
+
case 0: return [4 /*yield*/, this.getInfo()];
|
|
50772
|
+
case 1:
|
|
50773
|
+
toml = _c.sent();
|
|
50774
|
+
transferServerEndpoint = toml.transferServerSep24;
|
|
50775
|
+
apiParams = (0, Utils_1.camelToSnakeCaseObject)({
|
|
50776
|
+
assetCode: assetCode,
|
|
50777
|
+
noOlderThan: noOlderThan,
|
|
50778
|
+
limit: limit,
|
|
50779
|
+
kind: kind,
|
|
50780
|
+
pagingId: pagingId,
|
|
50781
|
+
lang: lang,
|
|
50782
|
+
});
|
|
50783
|
+
_c.label = 2;
|
|
50784
|
+
case 2:
|
|
50785
|
+
_c.trys.push([2, 4, , 5]);
|
|
50786
|
+
return [4 /*yield*/, this.httpClient.get("".concat(transferServerEndpoint, "/transactions?").concat(query_string_1.default.stringify(apiParams)), {
|
|
50787
|
+
headers: {
|
|
50788
|
+
Authorization: "Bearer ".concat(authToken),
|
|
50789
|
+
},
|
|
50790
|
+
})];
|
|
50791
|
+
case 3:
|
|
50792
|
+
resp = _c.sent();
|
|
50793
|
+
transactions = resp.data.transactions;
|
|
50794
|
+
if (!transactions || !Array.isArray(transactions)) {
|
|
50795
|
+
throw new Exceptions_1.InvalidTransactionsResponseError(transactions);
|
|
50796
|
+
}
|
|
50797
|
+
return [2 /*return*/, transactions];
|
|
50798
|
+
case 4:
|
|
50799
|
+
e_3 = _c.sent();
|
|
50800
|
+
throw new Exceptions_1.ServerRequestFailedError(e_3);
|
|
49899
50801
|
case 5: return [2 /*return*/];
|
|
49900
50802
|
}
|
|
49901
50803
|
});
|
|
49902
50804
|
});
|
|
49903
50805
|
};
|
|
49904
|
-
|
|
49905
|
-
|
|
49906
|
-
|
|
50806
|
+
/**
|
|
50807
|
+
* Get all successfully finished (either completed or refunded) account transactions for specified
|
|
50808
|
+
* asset. Optional field implementation depends on anchor.
|
|
50809
|
+
*
|
|
50810
|
+
* @param authToken auth token of the account authenticated with the anchor
|
|
50811
|
+
* @param assetCode target asset to query for
|
|
50812
|
+
* @param noOlderThan response should contain transactions starting on or after this date & time
|
|
50813
|
+
* @param limit response should contain at most 'limit' transactions
|
|
50814
|
+
* @param kind kind of transaction that is desired. E.g.: 'deposit', 'withdrawal'
|
|
50815
|
+
* @param pagingId response should contain transactions starting prior to this ID (exclusive)
|
|
50816
|
+
* @param lang desired language (localization), it can also accept locale in the format 'en-US'
|
|
50817
|
+
* @return list of filtered transactions that achieved a final state (completed or refunded)
|
|
50818
|
+
* @throws [AssetNotSupportedError] if asset is not supported by the anchor
|
|
50819
|
+
* @throws [InvalidTransactionsResponseError] if Anchor returns an invalid response
|
|
50820
|
+
* @throws [ServerRequestFailedError] if server request fails
|
|
50821
|
+
*/
|
|
50822
|
+
Anchor.prototype.getHistory = function (_a) {
|
|
50823
|
+
var _b;
|
|
50824
|
+
var authToken = _a.authToken, assetCode = _a.assetCode, noOlderThan = _a.noOlderThan, limit = _a.limit, kind = _a.kind, pagingId = _a.pagingId, _c = _a.lang, lang = _c === void 0 ? this.language : _c;
|
|
50825
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50826
|
+
var toml, transactions, finishedTransactions;
|
|
50827
|
+
return __generator(this, function (_d) {
|
|
50828
|
+
switch (_d.label) {
|
|
50829
|
+
case 0: return [4 /*yield*/, this.getInfo()];
|
|
50830
|
+
case 1:
|
|
50831
|
+
toml = _d.sent();
|
|
50832
|
+
if (!((_b = toml.currencies) === null || _b === void 0 ? void 0 : _b.find(function (_a) {
|
|
50833
|
+
var code = _a.code;
|
|
50834
|
+
return code === assetCode;
|
|
50835
|
+
}))) {
|
|
50836
|
+
throw new Exceptions_1.AssetNotSupportedError(null, assetCode);
|
|
50837
|
+
}
|
|
50838
|
+
return [4 /*yield*/, this.getTransactionsForAsset({
|
|
50839
|
+
authToken: authToken,
|
|
50840
|
+
assetCode: assetCode,
|
|
50841
|
+
noOlderThan: noOlderThan,
|
|
50842
|
+
limit: limit,
|
|
50843
|
+
kind: kind,
|
|
50844
|
+
pagingId: pagingId,
|
|
50845
|
+
lang: lang,
|
|
50846
|
+
})];
|
|
50847
|
+
case 2:
|
|
50848
|
+
transactions = _d.sent();
|
|
50849
|
+
finishedTransactions = transactions
|
|
50850
|
+
.filter(function (_a) {
|
|
50851
|
+
var status = _a.status;
|
|
50852
|
+
return [
|
|
50853
|
+
Types_1.TransactionStatus.completed,
|
|
50854
|
+
Types_1.TransactionStatus.refunded
|
|
50855
|
+
].includes(status);
|
|
50856
|
+
});
|
|
50857
|
+
return [2 /*return*/, finishedTransactions];
|
|
50858
|
+
}
|
|
50859
|
+
});
|
|
50860
|
+
});
|
|
50861
|
+
};
|
|
49907
50862
|
return Anchor;
|
|
49908
50863
|
}());
|
|
49909
50864
|
exports.Anchor = Anchor;
|
|
@@ -49919,10 +50874,18 @@ exports.Anchor = Anchor;
|
|
|
49919
50874
|
|
|
49920
50875
|
"use strict";
|
|
49921
50876
|
|
|
49922
|
-
// TODO - https://stellarorg.atlassian.net/browse/WAL-813?atlOrigin=eyJpIjoiODBkZTQ1MDMzYTJmNDFjOWI0NDM3MTQ2YWYxNTEzNTgiLCJwIjoiaiJ9
|
|
49923
50877
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
49924
50878
|
exports.DefaultSigner = void 0;
|
|
49925
|
-
exports.DefaultSigner = {
|
|
50879
|
+
exports.DefaultSigner = {
|
|
50880
|
+
signWithClientAccount: function (_a) {
|
|
50881
|
+
var transaction = _a.transaction, accountKp = _a.accountKp;
|
|
50882
|
+
transaction.sign(accountKp);
|
|
50883
|
+
return transaction;
|
|
50884
|
+
},
|
|
50885
|
+
signWithDomainAccount: function () {
|
|
50886
|
+
throw new Error("The DefaultSigner can't sign transactions with domain account");
|
|
50887
|
+
},
|
|
50888
|
+
};
|
|
49926
50889
|
|
|
49927
50890
|
|
|
49928
50891
|
/***/ }),
|
|
@@ -49975,82 +50938,107 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
49975
50938
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49976
50939
|
};
|
|
49977
50940
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
49978
|
-
exports.Auth = void 0;
|
|
49979
|
-
var axios_1 = __importDefault(__webpack_require__(/*! axios */ "./node_modules/axios/dist/browser/axios.cjs"));
|
|
50941
|
+
exports.Auth = exports.DefaultSigner = void 0;
|
|
49980
50942
|
var stellar_sdk_1 = __importDefault(__webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js"));
|
|
49981
|
-
var
|
|
50943
|
+
var Exceptions_1 = __webpack_require__(/*! ../Exceptions */ "./src/walletSdk/Exceptions/index.ts");
|
|
50944
|
+
var WalletSigner_1 = __webpack_require__(/*! ./WalletSigner */ "./src/walletSdk/Auth/WalletSigner.ts");
|
|
50945
|
+
Object.defineProperty(exports, "DefaultSigner", ({ enumerable: true, get: function () { return WalletSigner_1.DefaultSigner; } }));
|
|
49982
50946
|
// Do not create this object directly, use the Wallet class.
|
|
49983
50947
|
var Auth = /** @class */ (function () {
|
|
49984
|
-
|
|
49985
|
-
|
|
49986
|
-
this.
|
|
50948
|
+
function Auth(params) {
|
|
50949
|
+
var cfg = params.cfg, webAuthEndpoint = params.webAuthEndpoint, homeDomain = params.homeDomain, httpClient = params.httpClient;
|
|
50950
|
+
this.cfg = cfg;
|
|
49987
50951
|
this.webAuthEndpoint = webAuthEndpoint;
|
|
50952
|
+
this.homeDomain = homeDomain;
|
|
50953
|
+
this.httpClient = httpClient;
|
|
49988
50954
|
}
|
|
49989
|
-
Auth.prototype.authenticate = function (
|
|
50955
|
+
Auth.prototype.authenticate = function (_a) {
|
|
50956
|
+
var accountKp = _a.accountKp, walletSigner = _a.walletSigner, memoId = _a.memoId, clientDomain = _a.clientDomain;
|
|
49990
50957
|
return __awaiter(this, void 0, void 0, function () {
|
|
49991
|
-
var challengeResponse,
|
|
49992
|
-
return __generator(this, function (
|
|
49993
|
-
switch (
|
|
49994
|
-
case 0: return [4 /*yield*/, this.challenge(
|
|
50958
|
+
var challengeResponse, signedTransaction;
|
|
50959
|
+
return __generator(this, function (_b) {
|
|
50960
|
+
switch (_b.label) {
|
|
50961
|
+
case 0: return [4 /*yield*/, this.challenge({
|
|
50962
|
+
accountKp: accountKp,
|
|
50963
|
+
memoId: memoId,
|
|
50964
|
+
clientDomain: clientDomain
|
|
50965
|
+
})];
|
|
49995
50966
|
case 1:
|
|
49996
|
-
challengeResponse =
|
|
49997
|
-
|
|
49998
|
-
|
|
49999
|
-
|
|
50967
|
+
challengeResponse = _b.sent();
|
|
50968
|
+
signedTransaction = this.sign({
|
|
50969
|
+
accountKp: accountKp,
|
|
50970
|
+
challengeResponse: challengeResponse,
|
|
50971
|
+
walletSigner: walletSigner !== null && walletSigner !== void 0 ? walletSigner : this.cfg.app.defaultSigner
|
|
50972
|
+
});
|
|
50973
|
+
return [2 /*return*/, this.getToken(signedTransaction)];
|
|
50000
50974
|
}
|
|
50001
50975
|
});
|
|
50002
50976
|
});
|
|
50003
50977
|
};
|
|
50004
|
-
Auth.prototype.challenge = function (
|
|
50978
|
+
Auth.prototype.challenge = function (_a) {
|
|
50979
|
+
var accountKp = _a.accountKp, memoId = _a.memoId, clientDomain = _a.clientDomain;
|
|
50005
50980
|
return __awaiter(this, void 0, void 0, function () {
|
|
50006
|
-
var url,
|
|
50007
|
-
return __generator(this, function (
|
|
50008
|
-
switch (
|
|
50981
|
+
var url, resp, challengeResponse, e_1;
|
|
50982
|
+
return __generator(this, function (_b) {
|
|
50983
|
+
switch (_b.label) {
|
|
50009
50984
|
case 0:
|
|
50010
50985
|
if (memoId && parseInt(memoId) < 0) {
|
|
50011
|
-
throw new
|
|
50986
|
+
throw new Exceptions_1.InvalidMemoError();
|
|
50012
50987
|
}
|
|
50013
50988
|
if (clientDomain && memoId) {
|
|
50014
|
-
throw new
|
|
50989
|
+
throw new Exceptions_1.ClientDomainWithMemoError();
|
|
50015
50990
|
}
|
|
50016
|
-
url = "".concat(this.webAuthEndpoint, "?account=").concat(accountKp.publicKey()).concat(memoId ? "&memo=".concat(memoId) : "").concat(clientDomain ? "&client_domain=".concat(clientDomain) : "");
|
|
50017
|
-
|
|
50991
|
+
url = "".concat(this.webAuthEndpoint, "?account=").concat(accountKp.publicKey()).concat(memoId ? "&memo=".concat(memoId) : "").concat(clientDomain ? "&client_domain=".concat(clientDomain) : "").concat(this.homeDomain ? "&home_domain=".concat(this.homeDomain) : "");
|
|
50992
|
+
_b.label = 1;
|
|
50018
50993
|
case 1:
|
|
50019
|
-
|
|
50020
|
-
return [4 /*yield*/,
|
|
50994
|
+
_b.trys.push([1, 3, , 4]);
|
|
50995
|
+
return [4 /*yield*/, this.httpClient.get(url)];
|
|
50021
50996
|
case 2:
|
|
50022
|
-
|
|
50023
|
-
|
|
50997
|
+
resp = _b.sent();
|
|
50998
|
+
challengeResponse = resp.data;
|
|
50999
|
+
return [2 /*return*/, challengeResponse];
|
|
50024
51000
|
case 3:
|
|
50025
|
-
e_1 =
|
|
50026
|
-
throw new
|
|
51001
|
+
e_1 = _b.sent();
|
|
51002
|
+
throw new Exceptions_1.ServerRequestFailedError(e_1);
|
|
50027
51003
|
case 4: return [2 /*return*/];
|
|
50028
51004
|
}
|
|
50029
51005
|
});
|
|
50030
51006
|
});
|
|
50031
51007
|
};
|
|
50032
|
-
|
|
50033
|
-
|
|
50034
|
-
var transaction = stellar_sdk_1.default.TransactionBuilder.fromXDR(
|
|
50035
|
-
|
|
51008
|
+
Auth.prototype.sign = function (_a) {
|
|
51009
|
+
var accountKp = _a.accountKp, challengeResponse = _a.challengeResponse, walletSigner = _a.walletSigner;
|
|
51010
|
+
var transaction = stellar_sdk_1.default.TransactionBuilder.fromXDR(challengeResponse.transaction, challengeResponse.network_passphrase);
|
|
51011
|
+
// check if verifying client domain as well
|
|
51012
|
+
for (var _i = 0, _b = transaction.operations; _i < _b.length; _i++) {
|
|
51013
|
+
var op = _b[_i];
|
|
51014
|
+
if (op.type === "manageData" && op.name === "client_domain") {
|
|
51015
|
+
transaction = walletSigner.signWithDomainAccount({
|
|
51016
|
+
transactionXDR: challengeResponse.transaction,
|
|
51017
|
+
networkPassphrase: challengeResponse.network_passphrase,
|
|
51018
|
+
accountKp: accountKp
|
|
51019
|
+
});
|
|
51020
|
+
}
|
|
51021
|
+
}
|
|
51022
|
+
walletSigner.signWithClientAccount({ transaction: transaction, accountKp: accountKp });
|
|
50036
51023
|
return transaction;
|
|
50037
51024
|
};
|
|
50038
|
-
Auth.prototype.getToken = function (
|
|
51025
|
+
Auth.prototype.getToken = function (signedTransaction) {
|
|
50039
51026
|
return __awaiter(this, void 0, void 0, function () {
|
|
50040
|
-
var resp, e_2;
|
|
51027
|
+
var resp, authToken, e_2;
|
|
50041
51028
|
return __generator(this, function (_a) {
|
|
50042
51029
|
switch (_a.label) {
|
|
50043
51030
|
case 0:
|
|
50044
51031
|
_a.trys.push([0, 2, , 3]);
|
|
50045
|
-
return [4 /*yield*/,
|
|
50046
|
-
transaction:
|
|
51032
|
+
return [4 /*yield*/, this.httpClient.post(this.webAuthEndpoint, {
|
|
51033
|
+
transaction: signedTransaction.toXDR(),
|
|
50047
51034
|
})];
|
|
50048
51035
|
case 1:
|
|
50049
51036
|
resp = _a.sent();
|
|
50050
|
-
|
|
51037
|
+
authToken = resp.data.token;
|
|
51038
|
+
return [2 /*return*/, authToken];
|
|
50051
51039
|
case 2:
|
|
50052
51040
|
e_2 = _a.sent();
|
|
50053
|
-
throw new
|
|
51041
|
+
throw new Exceptions_1.ServerRequestFailedError(e_2);
|
|
50054
51042
|
case 3: return [2 /*return*/];
|
|
50055
51043
|
}
|
|
50056
51044
|
});
|
|
@@ -50063,10 +51051,10 @@ exports.Auth = Auth;
|
|
|
50063
51051
|
|
|
50064
51052
|
/***/ }),
|
|
50065
51053
|
|
|
50066
|
-
/***/ "./src/walletSdk/
|
|
50067
|
-
|
|
50068
|
-
!*** ./src/walletSdk/
|
|
50069
|
-
|
|
51054
|
+
/***/ "./src/walletSdk/Exceptions/index.ts":
|
|
51055
|
+
/*!*******************************************!*\
|
|
51056
|
+
!*** ./src/walletSdk/Exceptions/index.ts ***!
|
|
51057
|
+
\*******************************************/
|
|
50070
51058
|
/***/ (function(__unused_webpack_module, exports) {
|
|
50071
51059
|
|
|
50072
51060
|
"use strict";
|
|
@@ -50087,11 +51075,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
50087
51075
|
};
|
|
50088
51076
|
})();
|
|
50089
51077
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
50090
|
-
exports.ClientDomainWithMemoError = exports.InvalidMemoError = exports.AssetNotSupportedError = exports.ServerRequestFailedError = void 0;
|
|
51078
|
+
exports.InvalidTransactionsResponseError = exports.InvalidTransactionResponseError = exports.MissingTransactionIdError = exports.ClientDomainWithMemoError = exports.InvalidMemoError = exports.AssetNotSupportedError = exports.ServerRequestFailedError = void 0;
|
|
50091
51079
|
var ServerRequestFailedError = /** @class */ (function (_super) {
|
|
50092
51080
|
__extends(ServerRequestFailedError, _super);
|
|
50093
51081
|
function ServerRequestFailedError(e) {
|
|
50094
|
-
var _this = _super.call(this, "
|
|
51082
|
+
var _this = _super.call(this, "Server request failed with error: ".concat(e)) || this;
|
|
50095
51083
|
Object.setPrototypeOf(_this, ServerRequestFailedError.prototype);
|
|
50096
51084
|
return _this;
|
|
50097
51085
|
}
|
|
@@ -50101,7 +51089,7 @@ exports.ServerRequestFailedError = ServerRequestFailedError;
|
|
|
50101
51089
|
var AssetNotSupportedError = /** @class */ (function (_super) {
|
|
50102
51090
|
__extends(AssetNotSupportedError, _super);
|
|
50103
51091
|
function AssetNotSupportedError(type, assetCode) {
|
|
50104
|
-
var _this = _super.call(this, "
|
|
51092
|
+
var _this = _super.call(this, "Asset ".concat(assetCode, " not supported") + (type ? " for ".concat(type) : "")) || this;
|
|
50105
51093
|
Object.setPrototypeOf(_this, AssetNotSupportedError.prototype);
|
|
50106
51094
|
return _this;
|
|
50107
51095
|
}
|
|
@@ -50128,147 +51116,198 @@ var ClientDomainWithMemoError = /** @class */ (function (_super) {
|
|
|
50128
51116
|
return ClientDomainWithMemoError;
|
|
50129
51117
|
}(Error));
|
|
50130
51118
|
exports.ClientDomainWithMemoError = ClientDomainWithMemoError;
|
|
51119
|
+
var MissingTransactionIdError = /** @class */ (function (_super) {
|
|
51120
|
+
__extends(MissingTransactionIdError, _super);
|
|
51121
|
+
function MissingTransactionIdError() {
|
|
51122
|
+
var _this = _super.call(this, "One of id, stellarTransactionId or externalTransactionId is required") || this;
|
|
51123
|
+
Object.setPrototypeOf(_this, MissingTransactionIdError.prototype);
|
|
51124
|
+
return _this;
|
|
51125
|
+
}
|
|
51126
|
+
return MissingTransactionIdError;
|
|
51127
|
+
}(Error));
|
|
51128
|
+
exports.MissingTransactionIdError = MissingTransactionIdError;
|
|
51129
|
+
var InvalidTransactionResponseError = /** @class */ (function (_super) {
|
|
51130
|
+
__extends(InvalidTransactionResponseError, _super);
|
|
51131
|
+
function InvalidTransactionResponseError(transactionResponse) {
|
|
51132
|
+
var _this = _super.call(this, "Invalid transaction in response data: ".concat(JSON.stringify(transactionResponse))) || this;
|
|
51133
|
+
Object.setPrototypeOf(_this, InvalidTransactionResponseError.prototype);
|
|
51134
|
+
return _this;
|
|
51135
|
+
}
|
|
51136
|
+
return InvalidTransactionResponseError;
|
|
51137
|
+
}(Error));
|
|
51138
|
+
exports.InvalidTransactionResponseError = InvalidTransactionResponseError;
|
|
51139
|
+
var InvalidTransactionsResponseError = /** @class */ (function (_super) {
|
|
51140
|
+
__extends(InvalidTransactionsResponseError, _super);
|
|
51141
|
+
function InvalidTransactionsResponseError(transactionsResponse) {
|
|
51142
|
+
var _this = _super.call(this, "Invalid transactions in response data: ".concat(JSON.stringify(transactionsResponse))) || this;
|
|
51143
|
+
Object.setPrototypeOf(_this, InvalidTransactionsResponseError.prototype);
|
|
51144
|
+
return _this;
|
|
51145
|
+
}
|
|
51146
|
+
return InvalidTransactionsResponseError;
|
|
51147
|
+
}(Error));
|
|
51148
|
+
exports.InvalidTransactionsResponseError = InvalidTransactionsResponseError;
|
|
50131
51149
|
|
|
50132
51150
|
|
|
50133
51151
|
/***/ }),
|
|
50134
51152
|
|
|
50135
|
-
/***/ "./src/walletSdk/
|
|
51153
|
+
/***/ "./src/walletSdk/Horizon/Account.ts":
|
|
50136
51154
|
/*!******************************************!*\
|
|
50137
|
-
!*** ./src/walletSdk/
|
|
51155
|
+
!*** ./src/walletSdk/Horizon/Account.ts ***!
|
|
50138
51156
|
\******************************************/
|
|
50139
|
-
/***/ ((__unused_webpack_module, exports)
|
|
51157
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
50140
51158
|
|
|
50141
51159
|
"use strict";
|
|
50142
51160
|
|
|
50143
|
-
|
|
51161
|
+
var __extends = (this && this.__extends) || (function () {
|
|
51162
|
+
var extendStatics = function (d, b) {
|
|
51163
|
+
extendStatics = Object.setPrototypeOf ||
|
|
51164
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
51165
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
51166
|
+
return extendStatics(d, b);
|
|
51167
|
+
};
|
|
51168
|
+
return function (d, b) {
|
|
51169
|
+
if (typeof b !== "function" && b !== null)
|
|
51170
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
51171
|
+
extendStatics(d, b);
|
|
51172
|
+
function __() { this.constructor = d; }
|
|
51173
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
51174
|
+
};
|
|
51175
|
+
})();
|
|
50144
51176
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
50145
|
-
exports.
|
|
50146
|
-
|
|
50147
|
-
var
|
|
50148
|
-
function
|
|
51177
|
+
exports.SigningKeypair = exports.PublicKeypair = void 0;
|
|
51178
|
+
var stellar_sdk_1 = __webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js");
|
|
51179
|
+
var AccountKeypair = /** @class */ (function () {
|
|
51180
|
+
function AccountKeypair(keypair) {
|
|
51181
|
+
this.keypair = keypair;
|
|
50149
51182
|
}
|
|
50150
|
-
|
|
51183
|
+
Object.defineProperty(AccountKeypair.prototype, "publicKey", {
|
|
51184
|
+
get: function () {
|
|
51185
|
+
return this.keypair.publicKey();
|
|
51186
|
+
},
|
|
51187
|
+
enumerable: false,
|
|
51188
|
+
configurable: true
|
|
51189
|
+
});
|
|
51190
|
+
AccountKeypair.prototype.toString = function () {
|
|
51191
|
+
return "".concat(this.constructor.name, "(address=").concat(this.publicKey, ")");
|
|
51192
|
+
};
|
|
51193
|
+
return AccountKeypair;
|
|
50151
51194
|
}());
|
|
50152
|
-
exports.
|
|
51195
|
+
var PublicKeypair = exports.PublicKeypair = /** @class */ (function (_super) {
|
|
51196
|
+
__extends(PublicKeypair, _super);
|
|
51197
|
+
function PublicKeypair(keypair) {
|
|
51198
|
+
return _super.call(this, keypair) || this;
|
|
51199
|
+
}
|
|
51200
|
+
PublicKeypair.fromPublicKey = function (publicKey) {
|
|
51201
|
+
return new PublicKeypair(stellar_sdk_1.Keypair.fromPublicKey(publicKey));
|
|
51202
|
+
};
|
|
51203
|
+
return PublicKeypair;
|
|
51204
|
+
}(AccountKeypair));
|
|
51205
|
+
var SigningKeypair = exports.SigningKeypair = /** @class */ (function (_super) {
|
|
51206
|
+
__extends(SigningKeypair, _super);
|
|
51207
|
+
function SigningKeypair(keypair) {
|
|
51208
|
+
if (!keypair.canSign()) {
|
|
51209
|
+
throw new Error("This keypair doesn't have a secret key and can't sign");
|
|
51210
|
+
}
|
|
51211
|
+
return _super.call(this, keypair) || this;
|
|
51212
|
+
}
|
|
51213
|
+
Object.defineProperty(SigningKeypair.prototype, "secretKey", {
|
|
51214
|
+
get: function () {
|
|
51215
|
+
return this.keypair.secret();
|
|
51216
|
+
},
|
|
51217
|
+
enumerable: false,
|
|
51218
|
+
configurable: true
|
|
51219
|
+
});
|
|
51220
|
+
SigningKeypair.prototype.sign = function (transaction) {
|
|
51221
|
+
transaction.sign(this.keypair);
|
|
51222
|
+
return transaction;
|
|
51223
|
+
};
|
|
51224
|
+
SigningKeypair.fromSecret = function (secretKey) {
|
|
51225
|
+
return new SigningKeypair(stellar_sdk_1.Keypair.fromSecret(secretKey));
|
|
51226
|
+
};
|
|
51227
|
+
return SigningKeypair;
|
|
51228
|
+
}(AccountKeypair));
|
|
50153
51229
|
|
|
50154
51230
|
|
|
50155
51231
|
/***/ }),
|
|
50156
51232
|
|
|
50157
|
-
/***/ "./src/walletSdk/
|
|
50158
|
-
|
|
50159
|
-
!*** ./src/walletSdk/
|
|
50160
|
-
|
|
50161
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
51233
|
+
/***/ "./src/walletSdk/Horizon/AccountService.ts":
|
|
51234
|
+
/*!*************************************************!*\
|
|
51235
|
+
!*** ./src/walletSdk/Horizon/AccountService.ts ***!
|
|
51236
|
+
\*************************************************/
|
|
51237
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
50162
51238
|
|
|
50163
51239
|
"use strict";
|
|
50164
51240
|
|
|
50165
51241
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
50166
|
-
exports.
|
|
50167
|
-
var
|
|
50168
|
-
(
|
|
50169
|
-
|
|
50170
|
-
|
|
50171
|
-
|
|
51242
|
+
exports.AccountService = void 0;
|
|
51243
|
+
var stellar_sdk_1 = __webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js");
|
|
51244
|
+
var Account_1 = __webpack_require__(/*! ./Account */ "./src/walletSdk/Horizon/Account.ts");
|
|
51245
|
+
// Do not create this object directly, use the Wallet class.
|
|
51246
|
+
var AccountService = /** @class */ (function () {
|
|
51247
|
+
function AccountService(cfg) {
|
|
51248
|
+
this.server = cfg.stellar.server;
|
|
51249
|
+
this.network = cfg.stellar.network;
|
|
51250
|
+
}
|
|
51251
|
+
AccountService.prototype.createKeypair = function () {
|
|
51252
|
+
return new Account_1.SigningKeypair(stellar_sdk_1.Keypair.random());
|
|
51253
|
+
};
|
|
51254
|
+
return AccountService;
|
|
51255
|
+
}());
|
|
51256
|
+
exports.AccountService = AccountService;
|
|
50172
51257
|
|
|
50173
51258
|
|
|
50174
51259
|
/***/ }),
|
|
50175
51260
|
|
|
50176
|
-
/***/ "./src/walletSdk/
|
|
50177
|
-
|
|
50178
|
-
!*** ./src/walletSdk/
|
|
50179
|
-
|
|
51261
|
+
/***/ "./src/walletSdk/Horizon/Stellar.ts":
|
|
51262
|
+
/*!******************************************!*\
|
|
51263
|
+
!*** ./src/walletSdk/Horizon/Stellar.ts ***!
|
|
51264
|
+
\******************************************/
|
|
50180
51265
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
50181
51266
|
|
|
50182
51267
|
"use strict";
|
|
50183
51268
|
|
|
50184
51269
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
50185
|
-
exports.
|
|
50186
|
-
var
|
|
50187
|
-
|
|
50188
|
-
var
|
|
50189
|
-
|
|
50190
|
-
|
|
50191
|
-
var Recovery_1 = __webpack_require__(/*! ./recovery/Recovery */ "./src/walletSdk/recovery/Recovery.ts");
|
|
50192
|
-
var url_1 = __webpack_require__(/*! ./util/url */ "./src/walletSdk/util/url.ts");
|
|
50193
|
-
var HttpClient = /** @class */ (function () {
|
|
50194
|
-
function HttpClient() {
|
|
50195
|
-
}
|
|
50196
|
-
return HttpClient;
|
|
50197
|
-
}());
|
|
50198
|
-
var Config = /** @class */ (function () {
|
|
50199
|
-
function Config(stellarCfg, appCfg) {
|
|
50200
|
-
this.stellar = stellarCfg;
|
|
50201
|
-
this.app = appCfg;
|
|
50202
|
-
}
|
|
50203
|
-
return Config;
|
|
50204
|
-
}());
|
|
50205
|
-
var Wallet = exports.Wallet = /** @class */ (function () {
|
|
50206
|
-
function Wallet(stellarConfiguration, applicationConfiguration) {
|
|
50207
|
-
if (applicationConfiguration === void 0) { applicationConfiguration = new ApplicationConfiguration(); }
|
|
50208
|
-
this.clients = [];
|
|
50209
|
-
this.cfg = new Config(stellarConfiguration, applicationConfiguration);
|
|
51270
|
+
exports.Stellar = void 0;
|
|
51271
|
+
var AccountService_1 = __webpack_require__(/*! ./AccountService */ "./src/walletSdk/Horizon/AccountService.ts");
|
|
51272
|
+
// Do not create this object directly, use the Wallet class.
|
|
51273
|
+
var Stellar = /** @class */ (function () {
|
|
51274
|
+
function Stellar(cfg) {
|
|
51275
|
+
this.cfg = cfg;
|
|
50210
51276
|
}
|
|
50211
|
-
|
|
50212
|
-
|
|
50213
|
-
var url = homeDomain.indexOf("://") !== -1 ? homeDomain : "https://".concat(homeDomain);
|
|
50214
|
-
return new Anchor_1.Anchor(this.cfg, (0, url_1.getUrlDomain)(url), this.getClient(httpClientConfig));
|
|
51277
|
+
Stellar.prototype.account = function () {
|
|
51278
|
+
return new AccountService_1.AccountService(this.cfg);
|
|
50215
51279
|
};
|
|
50216
|
-
|
|
50217
|
-
return new Stellar_1.Stellar(this.cfg);
|
|
50218
|
-
};
|
|
50219
|
-
Wallet.prototype.recover = function (servers, httpClientConfig) {
|
|
50220
|
-
return new Recovery_1.Recovery(this.cfg, this.stellar(), this.getClient(httpClientConfig), servers);
|
|
50221
|
-
};
|
|
50222
|
-
Wallet.prototype.getClient = function (httpClientConfig) {
|
|
50223
|
-
// TODO - create an httpClient object from the passed in config object
|
|
50224
|
-
var httpClient = null;
|
|
50225
|
-
if (httpClient) {
|
|
50226
|
-
this.clients.push(httpClient);
|
|
50227
|
-
}
|
|
50228
|
-
return httpClient ? httpClient : this.cfg.app.defaultClient;
|
|
50229
|
-
};
|
|
50230
|
-
Wallet.TestNet = function () {
|
|
50231
|
-
return new Wallet(StellarConfiguration.TestNet());
|
|
50232
|
-
};
|
|
50233
|
-
Wallet.MainNet = function () {
|
|
50234
|
-
return new Wallet(StellarConfiguration.MainNet());
|
|
50235
|
-
};
|
|
50236
|
-
return Wallet;
|
|
50237
|
-
}());
|
|
50238
|
-
var StellarConfiguration = exports.StellarConfiguration = /** @class */ (function () {
|
|
50239
|
-
function StellarConfiguration(network, horizonUrl, baseFee) {
|
|
50240
|
-
if (baseFee === void 0) { baseFee = 100; }
|
|
50241
|
-
this.network = network;
|
|
50242
|
-
this.baseFee = baseFee;
|
|
50243
|
-
this.horizonUrl = horizonUrl;
|
|
50244
|
-
this.server = new stellar_sdk_1.Server(horizonUrl);
|
|
50245
|
-
}
|
|
50246
|
-
StellarConfiguration.TestNet = function () {
|
|
50247
|
-
return new StellarConfiguration(stellar_sdk_1.Networks.TESTNET, constants_1.NETWORK_URLS.TESTNET);
|
|
50248
|
-
};
|
|
50249
|
-
StellarConfiguration.MainNet = function () {
|
|
50250
|
-
return new StellarConfiguration(stellar_sdk_1.Networks.PUBLIC, constants_1.NETWORK_URLS.PUBLIC);
|
|
50251
|
-
};
|
|
50252
|
-
return StellarConfiguration;
|
|
50253
|
-
}());
|
|
50254
|
-
var ApplicationConfiguration = /** @class */ (function () {
|
|
50255
|
-
function ApplicationConfiguration(defaultSigner, defaultCliengConfig) {
|
|
50256
|
-
if (defaultSigner === void 0) { defaultSigner = WalletSigner_1.DefaultSigner; }
|
|
50257
|
-
if (defaultCliengConfig === void 0) { defaultCliengConfig = {}; }
|
|
50258
|
-
this.defaultSigner = defaultSigner;
|
|
50259
|
-
// TODO - default client
|
|
50260
|
-
this.defaultClient = new HttpClient();
|
|
50261
|
-
}
|
|
50262
|
-
return ApplicationConfiguration;
|
|
51280
|
+
return Stellar;
|
|
50263
51281
|
}());
|
|
50264
|
-
exports.
|
|
51282
|
+
exports.Stellar = Stellar;
|
|
51283
|
+
|
|
51284
|
+
|
|
51285
|
+
/***/ }),
|
|
51286
|
+
|
|
51287
|
+
/***/ "./src/walletSdk/Horizon/index.ts":
|
|
51288
|
+
/*!****************************************!*\
|
|
51289
|
+
!*** ./src/walletSdk/Horizon/index.ts ***!
|
|
51290
|
+
\****************************************/
|
|
51291
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
51292
|
+
|
|
51293
|
+
"use strict";
|
|
51294
|
+
|
|
51295
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51296
|
+
exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = void 0;
|
|
51297
|
+
var Account_1 = __webpack_require__(/*! ./Account */ "./src/walletSdk/Horizon/Account.ts");
|
|
51298
|
+
Object.defineProperty(exports, "PublicKeypair", ({ enumerable: true, get: function () { return Account_1.PublicKeypair; } }));
|
|
51299
|
+
Object.defineProperty(exports, "SigningKeypair", ({ enumerable: true, get: function () { return Account_1.SigningKeypair; } }));
|
|
51300
|
+
var AccountService_1 = __webpack_require__(/*! ./AccountService */ "./src/walletSdk/Horizon/AccountService.ts");
|
|
51301
|
+
Object.defineProperty(exports, "AccountService", ({ enumerable: true, get: function () { return AccountService_1.AccountService; } }));
|
|
51302
|
+
var Stellar_1 = __webpack_require__(/*! ./Stellar */ "./src/walletSdk/Horizon/Stellar.ts");
|
|
51303
|
+
Object.defineProperty(exports, "Stellar", ({ enumerable: true, get: function () { return Stellar_1.Stellar; } }));
|
|
50265
51304
|
|
|
50266
51305
|
|
|
50267
51306
|
/***/ }),
|
|
50268
51307
|
|
|
50269
|
-
/***/ "./src/walletSdk/
|
|
51308
|
+
/***/ "./src/walletSdk/Interactive/index.ts":
|
|
50270
51309
|
/*!********************************************!*\
|
|
50271
|
-
!*** ./src/walletSdk/
|
|
51310
|
+
!*** ./src/walletSdk/Interactive/index.ts ***!
|
|
50272
51311
|
\********************************************/
|
|
50273
51312
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
50274
51313
|
|
|
@@ -50321,82 +51360,88 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50321
51360
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50322
51361
|
}
|
|
50323
51362
|
};
|
|
50324
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50325
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
50326
|
-
};
|
|
50327
51363
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
50328
|
-
exports.Interactive =
|
|
50329
|
-
var
|
|
50330
|
-
var
|
|
50331
|
-
var FLOW_TYPE;
|
|
50332
|
-
(function (FLOW_TYPE) {
|
|
50333
|
-
FLOW_TYPE["DEPOSIT"] = "deposit";
|
|
50334
|
-
FLOW_TYPE["WITHDRAW"] = "withdraw";
|
|
50335
|
-
})(FLOW_TYPE = exports.FLOW_TYPE || (exports.FLOW_TYPE = {}));
|
|
51364
|
+
exports.Interactive = void 0;
|
|
51365
|
+
var Exceptions_1 = __webpack_require__(/*! ../Exceptions */ "./src/walletSdk/Exceptions/index.ts");
|
|
51366
|
+
var Types_1 = __webpack_require__(/*! ../Types */ "./src/walletSdk/Types/index.ts");
|
|
50336
51367
|
// Do not create this object directly, use the Wallet class.
|
|
50337
51368
|
var Interactive = /** @class */ (function () {
|
|
50338
|
-
function Interactive(
|
|
50339
|
-
|
|
50340
|
-
this.anchor = null;
|
|
50341
|
-
this.homeDomain = homeDomain;
|
|
51369
|
+
function Interactive(params) {
|
|
51370
|
+
var anchor = params.anchor, httpClient = params.httpClient;
|
|
50342
51371
|
this.anchor = anchor;
|
|
51372
|
+
this.httpClient = httpClient;
|
|
50343
51373
|
}
|
|
50344
|
-
Interactive.prototype.deposit = function (
|
|
51374
|
+
Interactive.prototype.deposit = function (_a) {
|
|
51375
|
+
var accountAddress = _a.accountAddress, assetCode = _a.assetCode, authToken = _a.authToken, lang = _a.lang, extraFields = _a.extraFields, fundsAccountAddress = _a.fundsAccountAddress;
|
|
50345
51376
|
return __awaiter(this, void 0, void 0, function () {
|
|
50346
|
-
return __generator(this, function (
|
|
50347
|
-
|
|
50348
|
-
|
|
50349
|
-
|
|
50350
|
-
|
|
51377
|
+
return __generator(this, function (_b) {
|
|
51378
|
+
return [2 /*return*/, this.flow({
|
|
51379
|
+
accountAddress: accountAddress,
|
|
51380
|
+
assetCode: assetCode,
|
|
51381
|
+
authToken: authToken,
|
|
51382
|
+
lang: lang,
|
|
51383
|
+
extraFields: extraFields,
|
|
51384
|
+
fundsAccountAddress: fundsAccountAddress,
|
|
51385
|
+
type: Types_1.FLOW_TYPE.DEPOSIT,
|
|
51386
|
+
})];
|
|
50351
51387
|
});
|
|
50352
51388
|
});
|
|
50353
51389
|
};
|
|
50354
|
-
Interactive.prototype.withdraw = function (
|
|
51390
|
+
Interactive.prototype.withdraw = function (_a) {
|
|
51391
|
+
var accountAddress = _a.accountAddress, assetCode = _a.assetCode, authToken = _a.authToken, lang = _a.lang, extraFields = _a.extraFields, fundsAccountAddress = _a.fundsAccountAddress;
|
|
50355
51392
|
return __awaiter(this, void 0, void 0, function () {
|
|
50356
|
-
return __generator(this, function (
|
|
50357
|
-
|
|
50358
|
-
|
|
50359
|
-
|
|
50360
|
-
|
|
51393
|
+
return __generator(this, function (_b) {
|
|
51394
|
+
return [2 /*return*/, this.flow({
|
|
51395
|
+
accountAddress: accountAddress,
|
|
51396
|
+
assetCode: assetCode,
|
|
51397
|
+
authToken: authToken,
|
|
51398
|
+
lang: lang,
|
|
51399
|
+
extraFields: extraFields,
|
|
51400
|
+
fundsAccountAddress: fundsAccountAddress,
|
|
51401
|
+
type: Types_1.FLOW_TYPE.WITHDRAW,
|
|
51402
|
+
})];
|
|
50361
51403
|
});
|
|
50362
51404
|
});
|
|
50363
51405
|
};
|
|
50364
|
-
Interactive.prototype.flow = function (
|
|
51406
|
+
Interactive.prototype.flow = function (params) {
|
|
50365
51407
|
return __awaiter(this, void 0, void 0, function () {
|
|
50366
|
-
var toml, transferServerEndpoint, serviceInfo, assets, resp, e_1;
|
|
50367
|
-
return __generator(this, function (
|
|
50368
|
-
switch (
|
|
50369
|
-
case 0:
|
|
51408
|
+
var accountAddress, assetCode, authToken, _a, lang, extraFields, _b, fundsAccountAddress, type, toml, transferServerEndpoint, serviceInfo, assets, resp, interactiveResponse, e_1;
|
|
51409
|
+
return __generator(this, function (_c) {
|
|
51410
|
+
switch (_c.label) {
|
|
51411
|
+
case 0:
|
|
51412
|
+
accountAddress = params.accountAddress, assetCode = params.assetCode, authToken = params.authToken, _a = params.lang, lang = _a === void 0 ? this.anchor.language : _a, extraFields = params.extraFields, _b = params.fundsAccountAddress, fundsAccountAddress = _b === void 0 ? accountAddress : _b, type = params.type;
|
|
51413
|
+
return [4 /*yield*/, this.anchor.getInfo()];
|
|
50370
51414
|
case 1:
|
|
50371
|
-
toml =
|
|
51415
|
+
toml = _c.sent();
|
|
50372
51416
|
transferServerEndpoint = toml.transferServerSep24;
|
|
50373
51417
|
return [4 /*yield*/, this.anchor.getServicesInfo()];
|
|
50374
51418
|
case 2:
|
|
50375
|
-
serviceInfo =
|
|
50376
|
-
if (type === FLOW_TYPE.DEPOSIT) {
|
|
51419
|
+
serviceInfo = _c.sent();
|
|
51420
|
+
if (type === Types_1.FLOW_TYPE.DEPOSIT) {
|
|
50377
51421
|
assets = Object.keys(serviceInfo.deposit);
|
|
50378
51422
|
}
|
|
50379
51423
|
else {
|
|
50380
51424
|
assets = Object.keys(serviceInfo.withdraw);
|
|
50381
51425
|
}
|
|
50382
51426
|
if (!assets.includes(assetCode)) {
|
|
50383
|
-
throw new
|
|
51427
|
+
throw new Exceptions_1.AssetNotSupportedError(type, assetCode);
|
|
50384
51428
|
}
|
|
50385
|
-
|
|
51429
|
+
_c.label = 3;
|
|
50386
51430
|
case 3:
|
|
50387
|
-
|
|
50388
|
-
return [4 /*yield*/,
|
|
51431
|
+
_c.trys.push([3, 5, , 6]);
|
|
51432
|
+
return [4 /*yield*/, this.httpClient.post("".concat(transferServerEndpoint, "/transactions/").concat(type, "/interactive"), __assign({ asset_code: assetCode, lang: lang, account: fundsAccountAddress }, extraFields), {
|
|
50389
51433
|
headers: {
|
|
50390
51434
|
"Content-Type": "application/json",
|
|
50391
51435
|
Authorization: "Bearer ".concat(authToken),
|
|
50392
51436
|
},
|
|
50393
51437
|
})];
|
|
50394
51438
|
case 4:
|
|
50395
|
-
resp =
|
|
50396
|
-
|
|
51439
|
+
resp = _c.sent();
|
|
51440
|
+
interactiveResponse = resp.data;
|
|
51441
|
+
return [2 /*return*/, interactiveResponse];
|
|
50397
51442
|
case 5:
|
|
50398
|
-
e_1 =
|
|
50399
|
-
throw new
|
|
51443
|
+
e_1 = _c.sent();
|
|
51444
|
+
throw new Exceptions_1.ServerRequestFailedError(e_1);
|
|
50400
51445
|
case 6: return [2 /*return*/];
|
|
50401
51446
|
}
|
|
50402
51447
|
});
|
|
@@ -50409,20 +51454,24 @@ exports.Interactive = Interactive;
|
|
|
50409
51454
|
|
|
50410
51455
|
/***/ }),
|
|
50411
51456
|
|
|
50412
|
-
/***/ "./src/walletSdk/
|
|
50413
|
-
|
|
50414
|
-
!*** ./src/walletSdk/
|
|
50415
|
-
|
|
51457
|
+
/***/ "./src/walletSdk/Recovery/index.ts":
|
|
51458
|
+
/*!*****************************************!*\
|
|
51459
|
+
!*** ./src/walletSdk/Recovery/index.ts ***!
|
|
51460
|
+
\*****************************************/
|
|
50416
51461
|
/***/ ((__unused_webpack_module, exports) => {
|
|
50417
51462
|
|
|
50418
51463
|
"use strict";
|
|
50419
51464
|
|
|
50420
|
-
// TODO - https://stellarorg.atlassian.net/browse/WAL-815?atlOrigin=eyJpIjoiYTE4MTdlZDIwMDU1NGU2YjlhZjQ3MDFlYmJhZWM1NTciLCJwIjoiaiJ9
|
|
50421
51465
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
50422
51466
|
exports.Recovery = void 0;
|
|
50423
51467
|
// Do not create this object directly, use the Wallet class.
|
|
50424
51468
|
var Recovery = /** @class */ (function () {
|
|
50425
|
-
function Recovery(
|
|
51469
|
+
function Recovery(params) {
|
|
51470
|
+
var cfg = params.cfg, stellar = params.stellar, httpClient = params.httpClient, servers = params.servers;
|
|
51471
|
+
this.cfg = cfg;
|
|
51472
|
+
this.stellar = stellar;
|
|
51473
|
+
this.httpClient = httpClient;
|
|
51474
|
+
this.servers = servers;
|
|
50426
51475
|
}
|
|
50427
51476
|
return Recovery;
|
|
50428
51477
|
}());
|
|
@@ -50431,9 +51480,259 @@ exports.Recovery = Recovery;
|
|
|
50431
51480
|
|
|
50432
51481
|
/***/ }),
|
|
50433
51482
|
|
|
50434
|
-
/***/ "./src/walletSdk/
|
|
51483
|
+
/***/ "./src/walletSdk/Types/anchor.ts":
|
|
51484
|
+
/*!***************************************!*\
|
|
51485
|
+
!*** ./src/walletSdk/Types/anchor.ts ***!
|
|
51486
|
+
\***************************************/
|
|
51487
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
51488
|
+
|
|
51489
|
+
"use strict";
|
|
51490
|
+
|
|
51491
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51492
|
+
exports.TransactionStatus = void 0;
|
|
51493
|
+
var TransactionStatus;
|
|
51494
|
+
(function (TransactionStatus) {
|
|
51495
|
+
/**
|
|
51496
|
+
* There is not yet enough information for this transaction to be initiated. Perhaps the user has
|
|
51497
|
+
* not yet entered necessary info in an interactive flow
|
|
51498
|
+
*/
|
|
51499
|
+
TransactionStatus["incomplete"] = "incomplete";
|
|
51500
|
+
/**
|
|
51501
|
+
* The user has not yet initiated their transfer to the anchor. This is the next necessary step in
|
|
51502
|
+
* any deposit or withdrawal flow after transitioning from `incomplete`
|
|
51503
|
+
*/
|
|
51504
|
+
TransactionStatus["pending_user_transfer_start"] = "pending_user_transfer_start";
|
|
51505
|
+
/**
|
|
51506
|
+
* The Stellar payment has been successfully received by the anchor and the off-chain funds are
|
|
51507
|
+
* available for the customer to pick up. Only used for withdrawal transactions.
|
|
51508
|
+
*/
|
|
51509
|
+
TransactionStatus["pending_user_transfer_complete"] = "pending_user_transfer_complete";
|
|
51510
|
+
/**
|
|
51511
|
+
* Pending External deposit/withdrawal has been submitted to external network, but is not yet
|
|
51512
|
+
* confirmed. This is the status when waiting on Bitcoin or other external crypto network to
|
|
51513
|
+
* complete a transaction, or when waiting on a bank transfer.
|
|
51514
|
+
*/
|
|
51515
|
+
TransactionStatus["pending_external"] = "pending_external";
|
|
51516
|
+
/**
|
|
51517
|
+
* Deposit/withdrawal is being processed internally by anchor. This can also be used when the
|
|
51518
|
+
* anchor must verify KYC information prior to deposit/withdrawal.
|
|
51519
|
+
*/
|
|
51520
|
+
TransactionStatus["pending_anchor"] = "pending_anchor";
|
|
51521
|
+
/**
|
|
51522
|
+
* Deposit/withdrawal operation has been submitted to Stellar network, but is not yet confirmed.
|
|
51523
|
+
*/
|
|
51524
|
+
TransactionStatus["pending_stellar"] = "pending_stellar";
|
|
51525
|
+
/** The user must add a trustline for the asset for the deposit to complete. */
|
|
51526
|
+
TransactionStatus["pending_trust"] = "pending_trust";
|
|
51527
|
+
/**
|
|
51528
|
+
* The user must take additional action before the deposit / withdrawal can complete, for example
|
|
51529
|
+
* an email or 2fa confirmation of a withdrawal.
|
|
51530
|
+
*/
|
|
51531
|
+
TransactionStatus["pending_user"] = "pending_user";
|
|
51532
|
+
/** Deposit/withdrawal fully completed */
|
|
51533
|
+
TransactionStatus["completed"] = "completed";
|
|
51534
|
+
/** The deposit/withdrawal is fully refunded */
|
|
51535
|
+
TransactionStatus["refunded"] = "refunded";
|
|
51536
|
+
/**
|
|
51537
|
+
* Funds were never received by the anchor and the transaction is considered abandoned by the
|
|
51538
|
+
* user. Anchors are responsible for determining when transactions are considered expired.
|
|
51539
|
+
*/
|
|
51540
|
+
TransactionStatus["expired"] = "expired";
|
|
51541
|
+
/**
|
|
51542
|
+
* Could not complete deposit because no satisfactory asset/XLM market was available to create the
|
|
51543
|
+
* account
|
|
51544
|
+
*/
|
|
51545
|
+
TransactionStatus["no_market"] = "no_market";
|
|
51546
|
+
/** Deposit/withdrawal size less than min_amount. */
|
|
51547
|
+
TransactionStatus["too_small"] = "too_small";
|
|
51548
|
+
/** Deposit/withdrawal size exceeded max_amount. */
|
|
51549
|
+
TransactionStatus["too_large"] = "too_large";
|
|
51550
|
+
/** Catch-all for any error not enumerated above. */
|
|
51551
|
+
TransactionStatus["error"] = "error";
|
|
51552
|
+
})(TransactionStatus = exports.TransactionStatus || (exports.TransactionStatus = {}));
|
|
51553
|
+
|
|
51554
|
+
|
|
51555
|
+
/***/ }),
|
|
51556
|
+
|
|
51557
|
+
/***/ "./src/walletSdk/Types/auth.ts":
|
|
51558
|
+
/*!*************************************!*\
|
|
51559
|
+
!*** ./src/walletSdk/Types/auth.ts ***!
|
|
51560
|
+
\*************************************/
|
|
51561
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
51562
|
+
|
|
51563
|
+
"use strict";
|
|
51564
|
+
|
|
51565
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51566
|
+
|
|
51567
|
+
|
|
51568
|
+
/***/ }),
|
|
51569
|
+
|
|
51570
|
+
/***/ "./src/walletSdk/Types/horizon.ts":
|
|
51571
|
+
/*!****************************************!*\
|
|
51572
|
+
!*** ./src/walletSdk/Types/horizon.ts ***!
|
|
51573
|
+
\****************************************/
|
|
51574
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
51575
|
+
|
|
51576
|
+
"use strict";
|
|
51577
|
+
|
|
51578
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51579
|
+
exports.NETWORK_URLS = void 0;
|
|
51580
|
+
var NETWORK_URLS;
|
|
51581
|
+
(function (NETWORK_URLS) {
|
|
51582
|
+
NETWORK_URLS["PUBLIC"] = "https://horizon.stellar.org";
|
|
51583
|
+
NETWORK_URLS["TESTNET"] = "https://horizon-testnet.stellar.org";
|
|
51584
|
+
})(NETWORK_URLS = exports.NETWORK_URLS || (exports.NETWORK_URLS = {}));
|
|
51585
|
+
|
|
51586
|
+
|
|
51587
|
+
/***/ }),
|
|
51588
|
+
|
|
51589
|
+
/***/ "./src/walletSdk/Types/index.ts":
|
|
51590
|
+
/*!**************************************!*\
|
|
51591
|
+
!*** ./src/walletSdk/Types/index.ts ***!
|
|
51592
|
+
\**************************************/
|
|
51593
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
51594
|
+
|
|
51595
|
+
"use strict";
|
|
51596
|
+
|
|
51597
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
51598
|
+
if (k2 === undefined) k2 = k;
|
|
51599
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
51600
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
51601
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
51602
|
+
}
|
|
51603
|
+
Object.defineProperty(o, k2, desc);
|
|
51604
|
+
}) : (function(o, m, k, k2) {
|
|
51605
|
+
if (k2 === undefined) k2 = k;
|
|
51606
|
+
o[k2] = m[k];
|
|
51607
|
+
}));
|
|
51608
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
51609
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
51610
|
+
};
|
|
51611
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51612
|
+
// Export all other types from walletSdk/Types.ts
|
|
51613
|
+
__exportStar(__webpack_require__(/*! ./anchor */ "./src/walletSdk/Types/anchor.ts"), exports);
|
|
51614
|
+
__exportStar(__webpack_require__(/*! ./auth */ "./src/walletSdk/Types/auth.ts"), exports);
|
|
51615
|
+
__exportStar(__webpack_require__(/*! ./horizon */ "./src/walletSdk/Types/horizon.ts"), exports);
|
|
51616
|
+
__exportStar(__webpack_require__(/*! ./interactive */ "./src/walletSdk/Types/interactive.ts"), exports);
|
|
51617
|
+
__exportStar(__webpack_require__(/*! ./utils */ "./src/walletSdk/Types/utils.ts"), exports);
|
|
51618
|
+
__exportStar(__webpack_require__(/*! ./watcher */ "./src/walletSdk/Types/watcher.ts"), exports);
|
|
51619
|
+
|
|
51620
|
+
|
|
51621
|
+
/***/ }),
|
|
51622
|
+
|
|
51623
|
+
/***/ "./src/walletSdk/Types/interactive.ts":
|
|
51624
|
+
/*!********************************************!*\
|
|
51625
|
+
!*** ./src/walletSdk/Types/interactive.ts ***!
|
|
51626
|
+
\********************************************/
|
|
51627
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
51628
|
+
|
|
51629
|
+
"use strict";
|
|
51630
|
+
|
|
51631
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51632
|
+
exports.InteractiveResponseType = exports.FLOW_TYPE = void 0;
|
|
51633
|
+
var FLOW_TYPE;
|
|
51634
|
+
(function (FLOW_TYPE) {
|
|
51635
|
+
FLOW_TYPE["DEPOSIT"] = "deposit";
|
|
51636
|
+
FLOW_TYPE["WITHDRAW"] = "withdraw";
|
|
51637
|
+
})(FLOW_TYPE = exports.FLOW_TYPE || (exports.FLOW_TYPE = {}));
|
|
51638
|
+
var InteractiveResponseType;
|
|
51639
|
+
(function (InteractiveResponseType) {
|
|
51640
|
+
InteractiveResponseType["authentication_required"] = "authentication_required";
|
|
51641
|
+
InteractiveResponseType["interactive_customer_info_needed"] = "interactive_customer_info_needed";
|
|
51642
|
+
InteractiveResponseType["error"] = "error";
|
|
51643
|
+
})(InteractiveResponseType = exports.InteractiveResponseType || (exports.InteractiveResponseType = {}));
|
|
51644
|
+
|
|
51645
|
+
|
|
51646
|
+
/***/ }),
|
|
51647
|
+
|
|
51648
|
+
/***/ "./src/walletSdk/Types/utils.ts":
|
|
51649
|
+
/*!**************************************!*\
|
|
51650
|
+
!*** ./src/walletSdk/Types/utils.ts ***!
|
|
51651
|
+
\**************************************/
|
|
51652
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
51653
|
+
|
|
51654
|
+
"use strict";
|
|
51655
|
+
|
|
51656
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51657
|
+
|
|
51658
|
+
|
|
51659
|
+
/***/ }),
|
|
51660
|
+
|
|
51661
|
+
/***/ "./src/walletSdk/Types/watcher.ts":
|
|
51662
|
+
/*!****************************************!*\
|
|
51663
|
+
!*** ./src/walletSdk/Types/watcher.ts ***!
|
|
51664
|
+
\****************************************/
|
|
51665
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
51666
|
+
|
|
51667
|
+
"use strict";
|
|
51668
|
+
|
|
51669
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51670
|
+
|
|
51671
|
+
|
|
51672
|
+
/***/ }),
|
|
51673
|
+
|
|
51674
|
+
/***/ "./src/walletSdk/Utils/camelToSnakeCase.ts":
|
|
51675
|
+
/*!*************************************************!*\
|
|
51676
|
+
!*** ./src/walletSdk/Utils/camelToSnakeCase.ts ***!
|
|
51677
|
+
\*************************************************/
|
|
51678
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
51679
|
+
|
|
51680
|
+
"use strict";
|
|
51681
|
+
|
|
51682
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51683
|
+
exports.camelToSnakeCaseObject = exports.camelToSnakeCaseKey = void 0;
|
|
51684
|
+
var camelToSnakeCaseKey = function (key) {
|
|
51685
|
+
return key.replace(/[A-Z]/g, function (upperCaseLetter) { return "_".concat(upperCaseLetter.toLowerCase()); });
|
|
51686
|
+
};
|
|
51687
|
+
exports.camelToSnakeCaseKey = camelToSnakeCaseKey;
|
|
51688
|
+
var camelToSnakeCaseObject = function (obj) {
|
|
51689
|
+
var snakeCasedObj = {};
|
|
51690
|
+
for (var key in obj) {
|
|
51691
|
+
if (obj.hasOwnProperty(key)) {
|
|
51692
|
+
var snakeCaseKey = (0, exports.camelToSnakeCaseKey)(key);
|
|
51693
|
+
snakeCasedObj[snakeCaseKey] = obj[key];
|
|
51694
|
+
}
|
|
51695
|
+
}
|
|
51696
|
+
return snakeCasedObj;
|
|
51697
|
+
};
|
|
51698
|
+
exports.camelToSnakeCaseObject = camelToSnakeCaseObject;
|
|
51699
|
+
|
|
51700
|
+
|
|
51701
|
+
/***/ }),
|
|
51702
|
+
|
|
51703
|
+
/***/ "./src/walletSdk/Utils/index.ts":
|
|
51704
|
+
/*!**************************************!*\
|
|
51705
|
+
!*** ./src/walletSdk/Utils/index.ts ***!
|
|
51706
|
+
\**************************************/
|
|
51707
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
51708
|
+
|
|
51709
|
+
"use strict";
|
|
51710
|
+
|
|
51711
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
51712
|
+
if (k2 === undefined) k2 = k;
|
|
51713
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
51714
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
51715
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
51716
|
+
}
|
|
51717
|
+
Object.defineProperty(o, k2, desc);
|
|
51718
|
+
}) : (function(o, m, k, k2) {
|
|
51719
|
+
if (k2 === undefined) k2 = k;
|
|
51720
|
+
o[k2] = m[k];
|
|
51721
|
+
}));
|
|
51722
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
51723
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
51724
|
+
};
|
|
51725
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51726
|
+
__exportStar(__webpack_require__(/*! ./camelToSnakeCase */ "./src/walletSdk/Utils/camelToSnakeCase.ts"), exports);
|
|
51727
|
+
__exportStar(__webpack_require__(/*! ./toml */ "./src/walletSdk/Utils/toml.ts"), exports);
|
|
51728
|
+
__exportStar(__webpack_require__(/*! ./url */ "./src/walletSdk/Utils/url.ts"), exports);
|
|
51729
|
+
|
|
51730
|
+
|
|
51731
|
+
/***/ }),
|
|
51732
|
+
|
|
51733
|
+
/***/ "./src/walletSdk/Utils/toml.ts":
|
|
50435
51734
|
/*!*************************************!*\
|
|
50436
|
-
!*** ./src/walletSdk/toml
|
|
51735
|
+
!*** ./src/walletSdk/Utils/toml.ts ***!
|
|
50437
51736
|
\*************************************/
|
|
50438
51737
|
/***/ ((__unused_webpack_module, exports) => {
|
|
50439
51738
|
|
|
@@ -50478,39 +51777,39 @@ var parseToml = function (toml) {
|
|
|
50478
51777
|
var tomlCurrencies = toml["CURRENCIES"] || [];
|
|
50479
51778
|
var currencies = tomlCurrencies.map(function (tc) {
|
|
50480
51779
|
return {
|
|
50481
|
-
code:
|
|
50482
|
-
codeTemplate:
|
|
50483
|
-
issuer:
|
|
50484
|
-
status:
|
|
50485
|
-
displayDecimals:
|
|
50486
|
-
name:
|
|
50487
|
-
desc:
|
|
50488
|
-
conditions:
|
|
50489
|
-
image:
|
|
50490
|
-
fixedNumber:
|
|
50491
|
-
maxNumber:
|
|
50492
|
-
isUnlimited:
|
|
50493
|
-
isAssetAnchored:
|
|
50494
|
-
anchorAssetType:
|
|
50495
|
-
anchorAsset:
|
|
50496
|
-
attestationOfReserve:
|
|
50497
|
-
redemptionInstructions:
|
|
50498
|
-
collateralAddresses:
|
|
50499
|
-
collateralAddressMessages:
|
|
50500
|
-
collateralAddressSignatures:
|
|
50501
|
-
regulated:
|
|
50502
|
-
approvalServer:
|
|
50503
|
-
approvalCriteria:
|
|
51780
|
+
code: tc["code"],
|
|
51781
|
+
codeTemplate: tc["code_template"],
|
|
51782
|
+
issuer: tc["issuer"],
|
|
51783
|
+
status: tc["status"],
|
|
51784
|
+
displayDecimals: tc["display_decimals"],
|
|
51785
|
+
name: tc["name"],
|
|
51786
|
+
desc: tc["desc"],
|
|
51787
|
+
conditions: tc["conditions"],
|
|
51788
|
+
image: tc["image"],
|
|
51789
|
+
fixedNumber: tc["fixed_number"],
|
|
51790
|
+
maxNumber: tc["max_number"],
|
|
51791
|
+
isUnlimited: tc["is_unlimited"],
|
|
51792
|
+
isAssetAnchored: tc["is_asset_anchored"],
|
|
51793
|
+
anchorAssetType: tc["anchor_asset_type"],
|
|
51794
|
+
anchorAsset: tc["anchor_asset"],
|
|
51795
|
+
attestationOfReserve: tc["attestation_of_reserve"],
|
|
51796
|
+
redemptionInstructions: tc["redemption_instructions"],
|
|
51797
|
+
collateralAddresses: tc["collateral_addresses"],
|
|
51798
|
+
collateralAddressMessages: tc["collateral_address_messages"],
|
|
51799
|
+
collateralAddressSignatures: tc["collateral_address_signatures"],
|
|
51800
|
+
regulated: tc["regulated"],
|
|
51801
|
+
approvalServer: tc["approval_server"],
|
|
51802
|
+
approvalCriteria: tc["approval_criteria"],
|
|
50504
51803
|
};
|
|
50505
51804
|
});
|
|
50506
51805
|
var tomlValidators = toml["VALIDATORS"] || [];
|
|
50507
51806
|
var validators = tomlValidators.map(function (tv) {
|
|
50508
51807
|
return {
|
|
50509
|
-
alias:
|
|
50510
|
-
displayName:
|
|
50511
|
-
publicKey:
|
|
50512
|
-
host:
|
|
50513
|
-
history:
|
|
51808
|
+
alias: tv["ALIAS"],
|
|
51809
|
+
displayName: tv["DISPLAY_NAME"],
|
|
51810
|
+
publicKey: tv["PUBLIC_KEY"],
|
|
51811
|
+
host: tv["HOST"],
|
|
51812
|
+
history: tv["HISTORY"],
|
|
50514
51813
|
};
|
|
50515
51814
|
});
|
|
50516
51815
|
return {
|
|
@@ -50539,10 +51838,10 @@ exports.parseToml = parseToml;
|
|
|
50539
51838
|
|
|
50540
51839
|
/***/ }),
|
|
50541
51840
|
|
|
50542
|
-
/***/ "./src/walletSdk/
|
|
50543
|
-
|
|
50544
|
-
!*** ./src/walletSdk/
|
|
50545
|
-
|
|
51841
|
+
/***/ "./src/walletSdk/Utils/url.ts":
|
|
51842
|
+
/*!************************************!*\
|
|
51843
|
+
!*** ./src/walletSdk/Utils/url.ts ***!
|
|
51844
|
+
\************************************/
|
|
50546
51845
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
50547
51846
|
|
|
50548
51847
|
"use strict";
|
|
@@ -50563,6 +51862,416 @@ var getUrlDomain = function (url) {
|
|
|
50563
51862
|
exports.getUrlDomain = getUrlDomain;
|
|
50564
51863
|
|
|
50565
51864
|
|
|
51865
|
+
/***/ }),
|
|
51866
|
+
|
|
51867
|
+
/***/ "./src/walletSdk/Watcher/index.ts":
|
|
51868
|
+
/*!****************************************!*\
|
|
51869
|
+
!*** ./src/walletSdk/Watcher/index.ts ***!
|
|
51870
|
+
\****************************************/
|
|
51871
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
51872
|
+
|
|
51873
|
+
"use strict";
|
|
51874
|
+
|
|
51875
|
+
var __assign = (this && this.__assign) || function () {
|
|
51876
|
+
__assign = Object.assign || function(t) {
|
|
51877
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
51878
|
+
s = arguments[i];
|
|
51879
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
51880
|
+
t[p] = s[p];
|
|
51881
|
+
}
|
|
51882
|
+
return t;
|
|
51883
|
+
};
|
|
51884
|
+
return __assign.apply(this, arguments);
|
|
51885
|
+
};
|
|
51886
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
51887
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51888
|
+
};
|
|
51889
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51890
|
+
exports.Watcher = void 0;
|
|
51891
|
+
var isEqual_1 = __importDefault(__webpack_require__(/*! lodash/isEqual */ "./node_modules/lodash/isEqual.js"));
|
|
51892
|
+
var Types_1 = __webpack_require__(/*! ../Types */ "./src/walletSdk/Types/index.ts");
|
|
51893
|
+
// Do not create this object directly, use the Anchor class.
|
|
51894
|
+
var Watcher = /** @class */ (function () {
|
|
51895
|
+
function Watcher(anchor) {
|
|
51896
|
+
this.anchor = anchor;
|
|
51897
|
+
this._oneTransactionWatcher = {};
|
|
51898
|
+
this._allTransactionsWatcher = undefined;
|
|
51899
|
+
this._watchOneTransactionRegistry = {};
|
|
51900
|
+
this._watchAllTransactionsRegistry = {};
|
|
51901
|
+
this._transactionsRegistry = {};
|
|
51902
|
+
this._transactionsIgnoredRegistry = {};
|
|
51903
|
+
}
|
|
51904
|
+
/**
|
|
51905
|
+
* Watch all transactions returned from a transfer server. When new or
|
|
51906
|
+
* updated transactions come in, run an `onMessage` callback.
|
|
51907
|
+
*
|
|
51908
|
+
* On initial load, it'll return ALL pending transactions via onMessage.
|
|
51909
|
+
* Subsequent messages will be any one of these events:
|
|
51910
|
+
* - Any new transaction appears
|
|
51911
|
+
* - Any of the initial pending transactions change any state
|
|
51912
|
+
*
|
|
51913
|
+
* You may also provide an array of transaction ids, `watchlist`, and this
|
|
51914
|
+
* watcher will always react to transactions whose ids are in the watchlist.
|
|
51915
|
+
*/
|
|
51916
|
+
Watcher.prototype.watchAllTransactions = function (_a) {
|
|
51917
|
+
var _this = this;
|
|
51918
|
+
var authToken = _a.authToken, assetCode = _a.assetCode, onMessage = _a.onMessage, onError = _a.onError, _b = _a.watchlist, watchlist = _b === void 0 ? [] : _b, _c = _a.timeout, timeout = _c === void 0 ? 5000 : _c, _d = _a.isRetry, isRetry = _d === void 0 ? false : _d, _e = _a.lang, lang = _e === void 0 ? this.anchor.language : _e, kind = _a.kind, noOlderThan = _a.noOlderThan;
|
|
51919
|
+
var allParams = {
|
|
51920
|
+
authToken: authToken,
|
|
51921
|
+
assetCode: assetCode,
|
|
51922
|
+
onMessage: onMessage,
|
|
51923
|
+
onError: onError,
|
|
51924
|
+
watchlist: watchlist,
|
|
51925
|
+
timeout: timeout,
|
|
51926
|
+
isRetry: isRetry,
|
|
51927
|
+
lang: lang,
|
|
51928
|
+
kind: kind,
|
|
51929
|
+
noOlderThan: noOlderThan,
|
|
51930
|
+
};
|
|
51931
|
+
// make an object map out of watchlist
|
|
51932
|
+
var watchlistMap = watchlist.reduce(function (memo, id) {
|
|
51933
|
+
var _a;
|
|
51934
|
+
return (__assign(__assign({}, memo), (_a = {}, _a[id] = true, _a)));
|
|
51935
|
+
}, {});
|
|
51936
|
+
// make sure to initiate registries for the given asset code
|
|
51937
|
+
// to prevent 'Cannot read properties of undefined' errors
|
|
51938
|
+
if (!this._transactionsRegistry[assetCode]) {
|
|
51939
|
+
this._transactionsRegistry[assetCode] = {};
|
|
51940
|
+
}
|
|
51941
|
+
if (!this._transactionsIgnoredRegistry[assetCode]) {
|
|
51942
|
+
this._transactionsIgnoredRegistry[assetCode] = {};
|
|
51943
|
+
}
|
|
51944
|
+
// if it's a first run, drop it in the registry for the given asset code
|
|
51945
|
+
if (!isRetry) {
|
|
51946
|
+
this._watchAllTransactionsRegistry[assetCode] = true;
|
|
51947
|
+
}
|
|
51948
|
+
this.anchor.getTransactionsForAsset({
|
|
51949
|
+
authToken: authToken,
|
|
51950
|
+
assetCode: assetCode,
|
|
51951
|
+
lang: lang,
|
|
51952
|
+
kind: kind,
|
|
51953
|
+
noOlderThan: noOlderThan
|
|
51954
|
+
}).then(function (transactions) {
|
|
51955
|
+
// make sure we're still watching
|
|
51956
|
+
if (!_this._watchAllTransactionsRegistry[assetCode]) {
|
|
51957
|
+
return;
|
|
51958
|
+
}
|
|
51959
|
+
try {
|
|
51960
|
+
var newTransactions = transactions.filter(function (transaction) {
|
|
51961
|
+
var isInProgress = transaction.status.indexOf("pending") === 0 ||
|
|
51962
|
+
transaction.status === Types_1.TransactionStatus.incomplete;
|
|
51963
|
+
var registeredTransaction = _this._transactionsRegistry[assetCode][transaction.id];
|
|
51964
|
+
// if this is the first watch, only keep the pending ones
|
|
51965
|
+
if (!isRetry) {
|
|
51966
|
+
// always show transactions on the watchlist
|
|
51967
|
+
if (watchlistMap[transaction.id]) {
|
|
51968
|
+
return true;
|
|
51969
|
+
}
|
|
51970
|
+
// if we're not in progress, then save this in an ignore reg
|
|
51971
|
+
if (!isInProgress) {
|
|
51972
|
+
_this._transactionsIgnoredRegistry[assetCode][transaction.id] = transaction;
|
|
51973
|
+
}
|
|
51974
|
+
return isInProgress;
|
|
51975
|
+
}
|
|
51976
|
+
// if we've had the transaction before, only report updates
|
|
51977
|
+
if (registeredTransaction) {
|
|
51978
|
+
return !(0, isEqual_1.default)(registeredTransaction, transaction);
|
|
51979
|
+
}
|
|
51980
|
+
// if it's NOT a registered transaction, and it's not the first
|
|
51981
|
+
// roll, maybe it's a new transaction that achieved a final
|
|
51982
|
+
// status immediately so register that!
|
|
51983
|
+
if ([
|
|
51984
|
+
Types_1.TransactionStatus.completed,
|
|
51985
|
+
Types_1.TransactionStatus.refunded,
|
|
51986
|
+
Types_1.TransactionStatus.expired,
|
|
51987
|
+
Types_1.TransactionStatus.error,
|
|
51988
|
+
].includes(transaction.status) &&
|
|
51989
|
+
isRetry &&
|
|
51990
|
+
!_this._transactionsIgnoredRegistry[assetCode][transaction.id]) {
|
|
51991
|
+
return true;
|
|
51992
|
+
}
|
|
51993
|
+
// always use in progress transactions
|
|
51994
|
+
if (isInProgress) {
|
|
51995
|
+
return true;
|
|
51996
|
+
}
|
|
51997
|
+
return false;
|
|
51998
|
+
});
|
|
51999
|
+
newTransactions.forEach(function (transaction) {
|
|
52000
|
+
_this._transactionsRegistry[assetCode][transaction.id] = transaction;
|
|
52001
|
+
if (transaction.status === Types_1.TransactionStatus.error) {
|
|
52002
|
+
onError(transaction);
|
|
52003
|
+
}
|
|
52004
|
+
else {
|
|
52005
|
+
onMessage(transaction);
|
|
52006
|
+
}
|
|
52007
|
+
});
|
|
52008
|
+
}
|
|
52009
|
+
catch (e) {
|
|
52010
|
+
onError(e);
|
|
52011
|
+
return;
|
|
52012
|
+
}
|
|
52013
|
+
// call it again
|
|
52014
|
+
if (_this._allTransactionsWatcher) {
|
|
52015
|
+
clearTimeout(_this._allTransactionsWatcher);
|
|
52016
|
+
}
|
|
52017
|
+
_this._allTransactionsWatcher = setTimeout(function () {
|
|
52018
|
+
_this.watchAllTransactions(__assign(__assign({}, allParams), { isRetry: true }));
|
|
52019
|
+
}, timeout);
|
|
52020
|
+
})
|
|
52021
|
+
.catch(function (e) {
|
|
52022
|
+
onError(e);
|
|
52023
|
+
});
|
|
52024
|
+
return {
|
|
52025
|
+
refresh: function () {
|
|
52026
|
+
// don't do that if we stopped watching
|
|
52027
|
+
if (!_this._watchAllTransactionsRegistry[assetCode]) {
|
|
52028
|
+
return;
|
|
52029
|
+
}
|
|
52030
|
+
if (_this._allTransactionsWatcher) {
|
|
52031
|
+
clearTimeout(_this._allTransactionsWatcher);
|
|
52032
|
+
}
|
|
52033
|
+
_this.watchAllTransactions(__assign(__assign({}, allParams), { isRetry: true }));
|
|
52034
|
+
},
|
|
52035
|
+
stop: function () {
|
|
52036
|
+
if (_this._allTransactionsWatcher) {
|
|
52037
|
+
_this._watchAllTransactionsRegistry[assetCode] = false;
|
|
52038
|
+
_this._transactionsRegistry[assetCode] = {};
|
|
52039
|
+
_this._transactionsIgnoredRegistry[assetCode] = {};
|
|
52040
|
+
clearTimeout(_this._allTransactionsWatcher);
|
|
52041
|
+
}
|
|
52042
|
+
},
|
|
52043
|
+
};
|
|
52044
|
+
};
|
|
52045
|
+
/**
|
|
52046
|
+
* Watch a transaction until it stops pending. Takes three callbacks:
|
|
52047
|
+
* * onMessage - When the transaction comes back as pending_ or incomplete.
|
|
52048
|
+
* * onSuccess - When the transaction comes back as completed / refunded / expired.
|
|
52049
|
+
* * onError - When there's a runtime error, or the transaction comes back as
|
|
52050
|
+
* no_market / too_small / too_large / error.
|
|
52051
|
+
*/
|
|
52052
|
+
Watcher.prototype.watchOneTransaction = function (_a) {
|
|
52053
|
+
var _b;
|
|
52054
|
+
var _this = this;
|
|
52055
|
+
var authToken = _a.authToken, assetCode = _a.assetCode, id = _a.id, onMessage = _a.onMessage, onSuccess = _a.onSuccess, onError = _a.onError, _c = _a.timeout, timeout = _c === void 0 ? 5000 : _c, _d = _a.isRetry, isRetry = _d === void 0 ? false : _d, _e = _a.lang, lang = _e === void 0 ? this.anchor.language : _e;
|
|
52056
|
+
var allParams = {
|
|
52057
|
+
authToken: authToken,
|
|
52058
|
+
assetCode: assetCode,
|
|
52059
|
+
id: id,
|
|
52060
|
+
onMessage: onMessage,
|
|
52061
|
+
onSuccess: onSuccess,
|
|
52062
|
+
onError: onError,
|
|
52063
|
+
timeout: timeout,
|
|
52064
|
+
isRetry: isRetry,
|
|
52065
|
+
lang: lang,
|
|
52066
|
+
};
|
|
52067
|
+
// make sure to initiate registries for the given asset code
|
|
52068
|
+
// to prevent 'Cannot read properties of undefined' errors
|
|
52069
|
+
if (!this._transactionsRegistry[assetCode]) {
|
|
52070
|
+
this._transactionsRegistry[assetCode] = {};
|
|
52071
|
+
}
|
|
52072
|
+
if (!this._oneTransactionWatcher[assetCode]) {
|
|
52073
|
+
this._oneTransactionWatcher[assetCode] = {};
|
|
52074
|
+
}
|
|
52075
|
+
// if it's a first run, drop it in the registry for the given asset code
|
|
52076
|
+
if (!isRetry) {
|
|
52077
|
+
this._watchOneTransactionRegistry[assetCode] = __assign(__assign({}, (this._watchOneTransactionRegistry[assetCode] || {})), (_b = {}, _b[id] = true, _b));
|
|
52078
|
+
}
|
|
52079
|
+
// do this all asynchronously (since this func needs to return a cancel fun)
|
|
52080
|
+
this.anchor.getTransactionBy({ authToken: authToken, id: id, lang: lang })
|
|
52081
|
+
.then(function (transaction) {
|
|
52082
|
+
var _a;
|
|
52083
|
+
// make sure we're still watching
|
|
52084
|
+
if (!((_a = _this._watchOneTransactionRegistry[assetCode]) === null || _a === void 0 ? void 0 : _a[id])) {
|
|
52085
|
+
return;
|
|
52086
|
+
}
|
|
52087
|
+
var registeredTransaction = _this._transactionsRegistry[assetCode][transaction.id];
|
|
52088
|
+
// if we've had the transaction before, only report if there is a change
|
|
52089
|
+
if (registeredTransaction &&
|
|
52090
|
+
(0, isEqual_1.default)(registeredTransaction, transaction)) {
|
|
52091
|
+
return;
|
|
52092
|
+
}
|
|
52093
|
+
_this._transactionsRegistry[assetCode][transaction.id] = transaction;
|
|
52094
|
+
if (transaction.status.indexOf("pending") === 0 ||
|
|
52095
|
+
transaction.status === Types_1.TransactionStatus.incomplete) {
|
|
52096
|
+
if (_this._oneTransactionWatcher[assetCode][id]) {
|
|
52097
|
+
clearTimeout(_this._oneTransactionWatcher[assetCode][id]);
|
|
52098
|
+
}
|
|
52099
|
+
_this._oneTransactionWatcher[assetCode][id] = setTimeout(function () {
|
|
52100
|
+
_this.watchOneTransaction(__assign(__assign({}, allParams), { isRetry: true }));
|
|
52101
|
+
}, timeout);
|
|
52102
|
+
onMessage(transaction);
|
|
52103
|
+
}
|
|
52104
|
+
else if ([
|
|
52105
|
+
Types_1.TransactionStatus.completed,
|
|
52106
|
+
Types_1.TransactionStatus.refunded,
|
|
52107
|
+
Types_1.TransactionStatus.expired
|
|
52108
|
+
].includes(transaction.status)) {
|
|
52109
|
+
onSuccess(transaction);
|
|
52110
|
+
}
|
|
52111
|
+
else {
|
|
52112
|
+
onError(transaction);
|
|
52113
|
+
}
|
|
52114
|
+
})
|
|
52115
|
+
.catch(function (e) {
|
|
52116
|
+
onError(e);
|
|
52117
|
+
});
|
|
52118
|
+
return {
|
|
52119
|
+
refresh: function () {
|
|
52120
|
+
var _a;
|
|
52121
|
+
// don't do that if we stopped watching
|
|
52122
|
+
if (!((_a = _this._watchOneTransactionRegistry[assetCode]) === null || _a === void 0 ? void 0 : _a[id])) {
|
|
52123
|
+
return;
|
|
52124
|
+
}
|
|
52125
|
+
if (_this._oneTransactionWatcher[assetCode][id]) {
|
|
52126
|
+
clearTimeout(_this._oneTransactionWatcher[assetCode][id]);
|
|
52127
|
+
}
|
|
52128
|
+
_this.watchOneTransaction(__assign(__assign({}, allParams), { isRetry: true }));
|
|
52129
|
+
},
|
|
52130
|
+
stop: function () {
|
|
52131
|
+
if (_this._oneTransactionWatcher[assetCode][id]) {
|
|
52132
|
+
_this._watchOneTransactionRegistry[assetCode][id] = false;
|
|
52133
|
+
clearTimeout(_this._oneTransactionWatcher[assetCode][id]);
|
|
52134
|
+
}
|
|
52135
|
+
},
|
|
52136
|
+
};
|
|
52137
|
+
};
|
|
52138
|
+
return Watcher;
|
|
52139
|
+
}());
|
|
52140
|
+
exports.Watcher = Watcher;
|
|
52141
|
+
|
|
52142
|
+
|
|
52143
|
+
/***/ }),
|
|
52144
|
+
|
|
52145
|
+
/***/ "./src/walletSdk/index.ts":
|
|
52146
|
+
/*!********************************!*\
|
|
52147
|
+
!*** ./src/walletSdk/index.ts ***!
|
|
52148
|
+
\********************************/
|
|
52149
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
52150
|
+
|
|
52151
|
+
"use strict";
|
|
52152
|
+
|
|
52153
|
+
var __assign = (this && this.__assign) || function () {
|
|
52154
|
+
__assign = Object.assign || function(t) {
|
|
52155
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
52156
|
+
s = arguments[i];
|
|
52157
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
52158
|
+
t[p] = s[p];
|
|
52159
|
+
}
|
|
52160
|
+
return t;
|
|
52161
|
+
};
|
|
52162
|
+
return __assign.apply(this, arguments);
|
|
52163
|
+
};
|
|
52164
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
52165
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52166
|
+
};
|
|
52167
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
52168
|
+
exports.ApplicationConfiguration = exports.StellarConfiguration = exports.Config = exports.Wallet = void 0;
|
|
52169
|
+
var axios_1 = __importDefault(__webpack_require__(/*! axios */ "./node_modules/axios/dist/browser/axios.cjs"));
|
|
52170
|
+
var stellar_sdk_1 = __webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js");
|
|
52171
|
+
var Anchor_1 = __webpack_require__(/*! ./Anchor */ "./src/walletSdk/Anchor/index.ts");
|
|
52172
|
+
var Auth_1 = __webpack_require__(/*! ./Auth */ "./src/walletSdk/Auth/index.ts");
|
|
52173
|
+
var Horizon_1 = __webpack_require__(/*! ./Horizon */ "./src/walletSdk/Horizon/index.ts");
|
|
52174
|
+
var Recovery_1 = __webpack_require__(/*! ./Recovery */ "./src/walletSdk/Recovery/index.ts");
|
|
52175
|
+
var Types_1 = __webpack_require__(/*! ./Types */ "./src/walletSdk/Types/index.ts");
|
|
52176
|
+
var Utils_1 = __webpack_require__(/*! ./Utils */ "./src/walletSdk/Utils/index.ts");
|
|
52177
|
+
/* tslint:disable-next-line:no-var-requires */
|
|
52178
|
+
var version = (__webpack_require__(/*! ../../package.json */ "./package.json").version);
|
|
52179
|
+
var walletHeaders = {
|
|
52180
|
+
"X-Client-Name": "typescript-wallet-sdk",
|
|
52181
|
+
"X-Client-Version": version,
|
|
52182
|
+
};
|
|
52183
|
+
var Wallet = exports.Wallet = /** @class */ (function () {
|
|
52184
|
+
function Wallet(_a) {
|
|
52185
|
+
var stellarConfiguration = _a.stellarConfiguration, _b = _a.applicationConfiguration, applicationConfiguration = _b === void 0 ? new ApplicationConfiguration() : _b,
|
|
52186
|
+
// Defaults wallet language to "en", this will reflect in all Anchor API calls
|
|
52187
|
+
_c = _a.language,
|
|
52188
|
+
// Defaults wallet language to "en", this will reflect in all Anchor API calls
|
|
52189
|
+
language = _c === void 0 ? "en" : _c;
|
|
52190
|
+
this.cfg = new Config({ stellarConfiguration: stellarConfiguration, applicationConfiguration: applicationConfiguration });
|
|
52191
|
+
this.language = language;
|
|
52192
|
+
}
|
|
52193
|
+
Wallet.prototype.anchor = function (_a) {
|
|
52194
|
+
var homeDomain = _a.homeDomain, _b = _a.httpClientConfig, httpClientConfig = _b === void 0 ? {} : _b, _c = _a.language, language = _c === void 0 ? this.language : _c;
|
|
52195
|
+
var url = homeDomain.indexOf("://") !== -1 ? homeDomain : "https://".concat(homeDomain);
|
|
52196
|
+
return new Anchor_1.Anchor({
|
|
52197
|
+
cfg: this.cfg,
|
|
52198
|
+
homeDomain: (0, Utils_1.getUrlDomain)(url),
|
|
52199
|
+
httpClient: this.getClient(httpClientConfig),
|
|
52200
|
+
language: language,
|
|
52201
|
+
});
|
|
52202
|
+
};
|
|
52203
|
+
Wallet.prototype.stellar = function () {
|
|
52204
|
+
return new Horizon_1.Stellar(this.cfg);
|
|
52205
|
+
};
|
|
52206
|
+
Wallet.prototype.recovery = function (_a) {
|
|
52207
|
+
var servers = _a.servers, _b = _a.httpClientConfig, httpClientConfig = _b === void 0 ? {} : _b;
|
|
52208
|
+
return new Recovery_1.Recovery({
|
|
52209
|
+
cfg: this.cfg,
|
|
52210
|
+
stellar: this.stellar(),
|
|
52211
|
+
httpClient: this.getClient(httpClientConfig),
|
|
52212
|
+
servers: servers
|
|
52213
|
+
});
|
|
52214
|
+
};
|
|
52215
|
+
Wallet.prototype.getClient = function (httpClientConfig) {
|
|
52216
|
+
if (httpClientConfig === void 0) { httpClientConfig = {}; }
|
|
52217
|
+
return axios_1.default.create(__assign({ headers: __assign(__assign({}, walletHeaders), httpClientConfig.headers) }, httpClientConfig));
|
|
52218
|
+
};
|
|
52219
|
+
Wallet.TestNet = function () {
|
|
52220
|
+
return new Wallet({
|
|
52221
|
+
stellarConfiguration: StellarConfiguration.TestNet()
|
|
52222
|
+
});
|
|
52223
|
+
};
|
|
52224
|
+
Wallet.MainNet = function () {
|
|
52225
|
+
return new Wallet({
|
|
52226
|
+
stellarConfiguration: StellarConfiguration.MainNet()
|
|
52227
|
+
});
|
|
52228
|
+
};
|
|
52229
|
+
return Wallet;
|
|
52230
|
+
}());
|
|
52231
|
+
var Config = /** @class */ (function () {
|
|
52232
|
+
function Config(_a) {
|
|
52233
|
+
var stellarConfiguration = _a.stellarConfiguration, applicationConfiguration = _a.applicationConfiguration;
|
|
52234
|
+
this.stellar = stellarConfiguration;
|
|
52235
|
+
this.app = applicationConfiguration;
|
|
52236
|
+
}
|
|
52237
|
+
return Config;
|
|
52238
|
+
}());
|
|
52239
|
+
exports.Config = Config;
|
|
52240
|
+
var StellarConfiguration = exports.StellarConfiguration = /** @class */ (function () {
|
|
52241
|
+
function StellarConfiguration(_a) {
|
|
52242
|
+
var network = _a.network, horizonUrl = _a.horizonUrl, _b = _a.baseFee, baseFee = _b === void 0 ? 100 : _b;
|
|
52243
|
+
this.network = network;
|
|
52244
|
+
this.horizonUrl = horizonUrl;
|
|
52245
|
+
this.baseFee = baseFee;
|
|
52246
|
+
this.server = new stellar_sdk_1.Server(horizonUrl);
|
|
52247
|
+
}
|
|
52248
|
+
StellarConfiguration.TestNet = function () {
|
|
52249
|
+
return new StellarConfiguration({
|
|
52250
|
+
network: stellar_sdk_1.Networks.TESTNET,
|
|
52251
|
+
horizonUrl: Types_1.NETWORK_URLS.TESTNET
|
|
52252
|
+
});
|
|
52253
|
+
};
|
|
52254
|
+
StellarConfiguration.MainNet = function () {
|
|
52255
|
+
return new StellarConfiguration({
|
|
52256
|
+
network: stellar_sdk_1.Networks.PUBLIC,
|
|
52257
|
+
horizonUrl: Types_1.NETWORK_URLS.PUBLIC
|
|
52258
|
+
});
|
|
52259
|
+
};
|
|
52260
|
+
return StellarConfiguration;
|
|
52261
|
+
}());
|
|
52262
|
+
var ApplicationConfiguration = /** @class */ (function () {
|
|
52263
|
+
function ApplicationConfiguration(defaultSigner) {
|
|
52264
|
+
if (defaultSigner === void 0) { defaultSigner = Auth_1.DefaultSigner; }
|
|
52265
|
+
this.defaultSigner = defaultSigner;
|
|
52266
|
+
this.defaultClient = axios_1.default.create({
|
|
52267
|
+
headers: __assign({}, walletHeaders),
|
|
52268
|
+
});
|
|
52269
|
+
}
|
|
52270
|
+
return ApplicationConfiguration;
|
|
52271
|
+
}());
|
|
52272
|
+
exports.ApplicationConfiguration = ApplicationConfiguration;
|
|
52273
|
+
|
|
52274
|
+
|
|
50566
52275
|
/***/ }),
|
|
50567
52276
|
|
|
50568
52277
|
/***/ "./node_modules/tweetnacl/nacl-fast.js":
|
|
@@ -62162,6 +63871,17 @@ module.exports = axios;
|
|
|
62162
63871
|
"use strict";
|
|
62163
63872
|
module.exports = JSON.parse('{"name":"stellar-sdk","version":"10.4.1","description":"stellar-sdk is a library for working with the Stellar Horizon server.","main":"./lib/index.js","types":"./lib/index.d.ts","files":["/types","/lib","/dist"],"scripts":{"prepare":"gulp build","test":"babel-node ./node_modules/.bin/gulp test","test:watch":"babel-node ./node_modules/.bin/gulp test:watch","build:docs":"gulp build:docs","docs":"yarn build:docs && jsdoc -c .jsdoc.json","preversion":"gulp test","version":"gulp build","postversion":"git push && git push --tags","prettier-all":"prettier --write **/*.{js,ts}"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"prettier":"@stellar/prettier-config","lint-staged":{"lib/*.{js,json}":["prettier --write","git add"],"lib/*.js":["eslint --fix --max-warnings 0","git add"],"**/*.ts":["prettier --write","tslint --fix","git add"]},"keywords":["stellar"],"repository":{"type":"git","url":"https://github.com/stellar/js-stellar-sdk.git"},"author":"Stellar Development Foundation <hello@stellar.org>","license":"Apache-2.0","bugs":{"url":"https://github.com/stellar/js-stellar-sdk/issues"},"homepage":"https://github.com/stellar/js-stellar-sdk","devDependencies":{"@kollavarsham/gulp-coveralls":"0.2.8","@stellar/prettier-config":"^1.0.1","@stellar/tsconfig":"^1.0.1","@stellar/tslint-config":"^1.0.3","@types/detect-node":"^2.0.0","@types/lodash":"^4.14.130","axios-mock-adapter":"^1.16.0","babel-cli":"^6.26.0","babel-core":"~6.26.3","babel-eslint":"^10.0.1","babel-istanbul":"^0.12.2","babel-loader":"^7.0.0","babel-plugin-transform-builtin-extend":"^1.1.2","babel-preset-es2015":"^6.24.1","babel-register":"^6.26.0","body-parser":"^1.12.2","chai":"^2.2.0","chai-as-promised":"^5.2.0","chai-http":"^4.3.0","clear":"^0.1.0","coveralls":"3.0.2","del":"^5.1.0","eslint":"^5.12.1","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.6.0","eslint-plugin-import":"^2.15.0","eslint-plugin-node":"^8.0.1","eslint-plugin-prefer-import":"^0.0.1","eslint-plugin-prettier":"^3.0.1","ghooks":"^0.3.0","gulp":"^4.0.0","gulp-babel":"^6.1.3","gulp-eslint":"^5.0.0","gulp-insert":"^0.5.0","gulp-istanbul":"^1.1.3","gulp-load-plugins":"1.5.0","gulp-mocha":"^7.0.2","gulp-plumber":"^1.0.0","gulp-rename":"~1.2.0","gulp-tslint":"^8.1.4","husky":"^1.3.1","isparta":"^4.1.1","istanbul":"^0.4.5","jsdoc":"3.5.5","json-loader":"^0.5.1","karma":"^6.3.0","karma-chai":"^0.1.0","karma-chai-as-promised":"^0.1.2","karma-chrome-launcher":"^3.1.0","karma-commonjs":"^1.0.0","karma-firefox-launcher":"^2.1.2","karma-mocha":"^2.0.1","karma-phantomjs-launcher":"^1.0.4","karma-sauce-launcher":"2.0.2","karma-sinon":"^1.0.5","karma-sinon-chai":"2.0.2","karma-webpack":"5.0.0","lint-staged":"7.3.0","minami":"^1.1.1","mocha":"^9.1.4","prettier":"^1.17.1","sinon":"^1.14.1","sinon-chai":"^2.7.0","terser-webpack-plugin":"^1.3.0","ts-loader":"^5.0.0","tslint":"^5.16.0","typescript":"^3.4.5","webpack":"^4.33.0","webpack-cli":"^3.3.3","webpack-stream":"^5.2.1"},"dependencies":{"@types/eventsource":"^1.1.2","@types/node":">= 8","@types/randombytes":"^2.0.0","@types/urijs":"^1.19.6","axios":"0.25.0","bignumber.js":"^4.0.0","detect-node":"^2.0.4","es6-promise":"^4.2.4","eventsource":"^1.1.1","lodash":"^4.17.21","randombytes":"^2.1.0","stellar-base":"^8.2.2","toml":"^2.3.0","tslib":"^1.10.0","urijs":"^1.19.1","utility-types":"^3.7.0"}}');
|
|
62164
63873
|
|
|
63874
|
+
/***/ }),
|
|
63875
|
+
|
|
63876
|
+
/***/ "./package.json":
|
|
63877
|
+
/*!**********************!*\
|
|
63878
|
+
!*** ./package.json ***!
|
|
63879
|
+
\**********************/
|
|
63880
|
+
/***/ ((module) => {
|
|
63881
|
+
|
|
63882
|
+
"use strict";
|
|
63883
|
+
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"1.0.0-beta.0","engines":{"node":">=18"},"main":"./lib/bundle.js","types":"./lib/index.d.ts","license":"Apache-2.0","private":false,"devDependencies":{"@babel/preset-env":"^7.20.2","@stellar/eslint-config":"^2.1.2","@stellar/prettier-config":"^1.0.1","@stellar/tsconfig":"^1.0.2","@types/jest":"^29.4.0","@types/lodash":"^4.14.194","@types/sinon":"^10.0.15","babel-jest":"^29.4.1","eslint":"^8.33.0","jest":"^29.4.1","sinon":"^15.1.0","ts-jest":"^29.0.5","ts-loader":"^9.4.2","tslib":"^2.5.0","typescript":"^5.0.4","webpack":"^5.83.1","webpack-cli":"^5.1.1"},"dependencies":{"axios":"^1.4.0","https-browserify":"^1.0.0","lodash":"^4.17.21","query-string":"^7.1.3","stellar-sdk":"^10.4.1","stream-http":"^3.2.0","url":"^0.11.0","util":"^0.12.5","utility-types":"^3.10.0"},"scripts":{"prepare":"yarn build","test":"jest --watchAll","build":"webpack --config webpack.config.js"}}');
|
|
63884
|
+
|
|
62165
63885
|
/***/ })
|
|
62166
63886
|
|
|
62167
63887
|
/******/ });
|