@stellar/typescript-wallet-sdk 1.6.0 → 1.7.0-beta.1720449817870
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/CHANGELOG.MD +20 -0
- package/jest.e2e.config.js +1 -0
- package/jest.integration.config.js +1 -0
- package/lib/bundle.js +180 -97
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +208 -108
- package/lib/bundle_browser.js.map +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/walletSdk/Anchor/Sep24.d.ts +4 -0
- package/lib/walletSdk/Anchor/Sep38.d.ts +4 -0
- package/lib/walletSdk/Anchor/Sep6.d.ts +4 -0
- package/lib/walletSdk/Anchor/index.d.ts +5 -10
- package/lib/walletSdk/Asset/index.d.ts +3 -0
- package/lib/walletSdk/Auth/index.d.ts +5 -1
- package/lib/walletSdk/Customer/index.d.ts +4 -0
- package/package.json +4 -3
- package/src/index.ts +18 -3
- package/src/walletSdk/Anchor/Sep24.ts +5 -0
- package/src/walletSdk/Anchor/Sep38.ts +5 -0
- package/src/walletSdk/Anchor/Sep6.ts +5 -0
- package/src/walletSdk/Anchor/index.ts +5 -15
- package/src/walletSdk/Asset/index.ts +3 -0
- package/src/walletSdk/Auth/AuthHeaderSigner.ts +3 -5
- package/src/walletSdk/Auth/index.ts +6 -1
- package/src/walletSdk/Customer/index.ts +5 -0
package/CHANGELOG.MD
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# Release notes - Typescript Wallet SDK - 1.7.0
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
* Replace `tweetnacl-util` with `@stablelib` packages (#149)
|
|
5
|
+
* this fixes the lib `crashing` on `React Native` environment
|
|
6
|
+
* Export missing classes and aliases (#150)
|
|
7
|
+
* with this change devs can now access the following classes:
|
|
8
|
+
* `Sep6`
|
|
9
|
+
* `Sep12`
|
|
10
|
+
* `Sep38`
|
|
11
|
+
* `StellarAssetId`
|
|
12
|
+
* `DomainSigner`
|
|
13
|
+
* And aliases:
|
|
14
|
+
* `Transfer` (alias for `Sep6` class)
|
|
15
|
+
* `Auth` (alias for `Sep10` class)
|
|
16
|
+
* `Customer` (alias for `Sep12` class)
|
|
17
|
+
* `Interactive` (alias for `Sep24` class)
|
|
18
|
+
* `Quote` (alias for `Sep38` class)
|
|
19
|
+
* `XLM` (alias for `NativeAssetId` class)
|
|
20
|
+
|
|
1
21
|
# Release notes - Typescript Wallet SDK - 1.6.0
|
|
2
22
|
|
|
3
23
|
### Added
|
package/jest.e2e.config.js
CHANGED
package/lib/bundle.js
CHANGED
|
@@ -43,7 +43,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
43
43
|
return result;
|
|
44
44
|
};
|
|
45
45
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
46
|
-
exports.Keypair = exports.walletSdk = exports.Server = exports.Exceptions = exports.Utils = exports.Watcher = exports.sep7ReplacementsToString = exports.sep7ReplacementsFromString = exports.parseSep7Uri = exports.isValidSep7Uri = exports.Sep7Tx = exports.Sep7Pay = exports.Sep7Base = exports.Recovery = exports.SponsoringBuilder = exports.TransactionBuilder = exports.CommonTransactionBuilder = exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = exports.AccountKeypair = exports.DomainAuthHeaderSigner = exports.DefaultAuthHeaderSigner = exports.DefaultSigner = exports.Sep10 = exports.FiatAssetId = exports.NativeAssetId = exports.IssuedAssetId = exports.Sep24 = exports.Anchor = exports.ApplicationConfiguration = exports.StellarConfiguration = exports.Config = exports.Wallet = exports.Types = void 0;
|
|
46
|
+
exports.Keypair = exports.walletSdk = exports.Server = exports.Exceptions = exports.Utils = exports.Watcher = exports.sep7ReplacementsToString = exports.sep7ReplacementsFromString = exports.parseSep7Uri = exports.isValidSep7Uri = exports.Sep7Tx = exports.Sep7Pay = exports.Sep7Base = exports.Recovery = exports.SponsoringBuilder = exports.TransactionBuilder = exports.CommonTransactionBuilder = exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = exports.AccountKeypair = exports.Sep12 = exports.DomainAuthHeaderSigner = exports.DefaultAuthHeaderSigner = exports.DomainSigner = exports.DefaultSigner = exports.Sep10 = exports.FiatAssetId = exports.NativeAssetId = exports.IssuedAssetId = exports.StellarAssetId = exports.Sep38 = exports.Sep24 = exports.Sep6 = exports.Anchor = exports.ApplicationConfiguration = exports.StellarConfiguration = exports.Config = exports.Wallet = exports.Types = void 0;
|
|
47
47
|
/**
|
|
48
48
|
* Types
|
|
49
49
|
*/
|
|
@@ -59,18 +59,26 @@ Object.defineProperty(exports, "StellarConfiguration", ({ enumerable: true, get:
|
|
|
59
59
|
Object.defineProperty(exports, "ApplicationConfiguration", ({ enumerable: true, get: function () { return walletSdk_1.ApplicationConfiguration; } }));
|
|
60
60
|
var Anchor_1 = __webpack_require__(/*! ./walletSdk/Anchor */ "./src/walletSdk/Anchor/index.ts");
|
|
61
61
|
Object.defineProperty(exports, "Anchor", ({ enumerable: true, get: function () { return Anchor_1.Anchor; } }));
|
|
62
|
+
var Sep6_1 = __webpack_require__(/*! ./walletSdk/Anchor/Sep6 */ "./src/walletSdk/Anchor/Sep6.ts");
|
|
63
|
+
Object.defineProperty(exports, "Sep6", ({ enumerable: true, get: function () { return Sep6_1.Sep6; } }));
|
|
62
64
|
var Sep24_1 = __webpack_require__(/*! ./walletSdk/Anchor/Sep24 */ "./src/walletSdk/Anchor/Sep24.ts");
|
|
63
65
|
Object.defineProperty(exports, "Sep24", ({ enumerable: true, get: function () { return Sep24_1.Sep24; } }));
|
|
66
|
+
var Sep38_1 = __webpack_require__(/*! ./walletSdk/Anchor/Sep38 */ "./src/walletSdk/Anchor/Sep38.ts");
|
|
67
|
+
Object.defineProperty(exports, "Sep38", ({ enumerable: true, get: function () { return Sep38_1.Sep38; } }));
|
|
64
68
|
var Asset_1 = __webpack_require__(/*! ./walletSdk/Asset */ "./src/walletSdk/Asset/index.ts");
|
|
69
|
+
Object.defineProperty(exports, "StellarAssetId", ({ enumerable: true, get: function () { return Asset_1.StellarAssetId; } }));
|
|
65
70
|
Object.defineProperty(exports, "IssuedAssetId", ({ enumerable: true, get: function () { return Asset_1.IssuedAssetId; } }));
|
|
66
71
|
Object.defineProperty(exports, "NativeAssetId", ({ enumerable: true, get: function () { return Asset_1.NativeAssetId; } }));
|
|
67
72
|
Object.defineProperty(exports, "FiatAssetId", ({ enumerable: true, get: function () { return Asset_1.FiatAssetId; } }));
|
|
68
73
|
var Auth_1 = __webpack_require__(/*! ./walletSdk/Auth */ "./src/walletSdk/Auth/index.ts");
|
|
69
74
|
Object.defineProperty(exports, "Sep10", ({ enumerable: true, get: function () { return Auth_1.Sep10; } }));
|
|
70
75
|
Object.defineProperty(exports, "DefaultSigner", ({ enumerable: true, get: function () { return Auth_1.DefaultSigner; } }));
|
|
76
|
+
Object.defineProperty(exports, "DomainSigner", ({ enumerable: true, get: function () { return Auth_1.DomainSigner; } }));
|
|
71
77
|
var AuthHeaderSigner_1 = __webpack_require__(/*! ./walletSdk/Auth/AuthHeaderSigner */ "./src/walletSdk/Auth/AuthHeaderSigner.ts");
|
|
72
78
|
Object.defineProperty(exports, "DefaultAuthHeaderSigner", ({ enumerable: true, get: function () { return AuthHeaderSigner_1.DefaultAuthHeaderSigner; } }));
|
|
73
79
|
Object.defineProperty(exports, "DomainAuthHeaderSigner", ({ enumerable: true, get: function () { return AuthHeaderSigner_1.DomainAuthHeaderSigner; } }));
|
|
80
|
+
var Customer_1 = __webpack_require__(/*! ./walletSdk/Customer */ "./src/walletSdk/Customer/index.ts");
|
|
81
|
+
Object.defineProperty(exports, "Sep12", ({ enumerable: true, get: function () { return Customer_1.Sep12; } }));
|
|
74
82
|
var Horizon_1 = __webpack_require__(/*! ./walletSdk/Horizon */ "./src/walletSdk/Horizon/index.ts");
|
|
75
83
|
Object.defineProperty(exports, "AccountKeypair", ({ enumerable: true, get: function () { return Horizon_1.AccountKeypair; } }));
|
|
76
84
|
Object.defineProperty(exports, "PublicKeypair", ({ enumerable: true, get: function () { return Horizon_1.PublicKeypair; } }));
|
|
@@ -1401,9 +1409,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
1401
1409
|
};
|
|
1402
1410
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1403
1411
|
exports.DomainAuthHeaderSigner = exports.DefaultAuthHeaderSigner = void 0;
|
|
1412
|
+
var utf8_1 = __webpack_require__(/*! @stablelib/utf8 */ "../../node_modules/@stablelib/utf8/lib/utf8.js");
|
|
1404
1413
|
var stellar_sdk_1 = __webpack_require__(/*! @stellar/stellar-sdk */ "../../node_modules/@stellar/stellar-sdk/lib/index.js");
|
|
1405
1414
|
var tweetnacl_1 = __importDefault(__webpack_require__(/*! tweetnacl */ "../../node_modules/tweetnacl/nacl-fast.js"));
|
|
1406
|
-
var tweetnacl_util_1 = __importDefault(__webpack_require__(/*! tweetnacl-util */ "../../node_modules/tweetnacl-util/nacl-util.js"));
|
|
1407
1415
|
var base64url_1 = __importDefault(__webpack_require__(/*! base64url */ "../../node_modules/base64url/index.js"));
|
|
1408
1416
|
var Account_1 = __webpack_require__(/*! ../Horizon/Account */ "./src/walletSdk/Horizon/Account.ts");
|
|
1409
1417
|
var __1 = __webpack_require__(/*! ../ */ "./src/walletSdk/index.ts");
|
|
@@ -1433,7 +1441,7 @@ var DefaultAuthHeaderSigner = /** @class */ (function () {
|
|
|
1433
1441
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1434
1442
|
clientDomain = _a.clientDomain, issuer = _a.issuer;
|
|
1435
1443
|
return __awaiter(this, void 0, void 0, function () {
|
|
1436
|
-
var issuedAt, timeExp, rawSeed, naclKP, header, encodedHeader, encodedPayload, signature, encodedSignature, jwt;
|
|
1444
|
+
var issuedAt, timeExp, rawSeed, naclKP, header, encodedHeader, encodedPayload, utf8Jwt, signature, encodedSignature, jwt;
|
|
1437
1445
|
return __generator(this, function (_b) {
|
|
1438
1446
|
if (!(issuer instanceof Account_1.SigningKeypair)) {
|
|
1439
1447
|
throw new Exceptions_1.AuthHeaderSigningKeypairRequiredError();
|
|
@@ -1445,7 +1453,8 @@ var DefaultAuthHeaderSigner = /** @class */ (function () {
|
|
|
1445
1453
|
header = { alg: "EdDSA" };
|
|
1446
1454
|
encodedHeader = (0, base64url_1.default)(JSON.stringify(header));
|
|
1447
1455
|
encodedPayload = (0, base64url_1.default)(JSON.stringify(__assign(__assign({}, claims), { exp: timeExp, iat: issuedAt })));
|
|
1448
|
-
|
|
1456
|
+
utf8Jwt = (0, utf8_1.encode)("".concat(encodedHeader, ".").concat(encodedPayload));
|
|
1457
|
+
signature = tweetnacl_1.default.sign.detached(utf8Jwt, naclKP.secretKey);
|
|
1449
1458
|
encodedSignature = (0, base64url_1.default)(Buffer.from(signature));
|
|
1450
1459
|
jwt = "".concat(encodedHeader, ".").concat(encodedPayload, ".").concat(encodedSignature);
|
|
1451
1460
|
return [2 /*return*/, jwt];
|
|
@@ -1692,12 +1701,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
1692
1701
|
}
|
|
1693
1702
|
};
|
|
1694
1703
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1695
|
-
exports.Sep10 = exports.DefaultSigner = void 0;
|
|
1704
|
+
exports.Sep10 = exports.DefaultSigner = exports.DomainSigner = void 0;
|
|
1696
1705
|
var stellar_sdk_1 = __webpack_require__(/*! @stellar/stellar-sdk */ "../../node_modules/@stellar/stellar-sdk/lib/index.js");
|
|
1697
1706
|
var jws_1 = __webpack_require__(/*! jws */ "../../node_modules/jws/index.js");
|
|
1698
1707
|
var Exceptions_1 = __webpack_require__(/*! ../Exceptions */ "./src/walletSdk/Exceptions/index.ts");
|
|
1699
1708
|
var Types_1 = __webpack_require__(/*! ../Types */ "./src/walletSdk/Types/index.ts");
|
|
1700
1709
|
var WalletSigner_1 = __webpack_require__(/*! ./WalletSigner */ "./src/walletSdk/Auth/WalletSigner.ts");
|
|
1710
|
+
Object.defineProperty(exports, "DomainSigner", ({ enumerable: true, get: function () { return WalletSigner_1.DomainSigner; } }));
|
|
1701
1711
|
Object.defineProperty(exports, "DefaultSigner", ({ enumerable: true, get: function () { return WalletSigner_1.DefaultSigner; } }));
|
|
1702
1712
|
/**
|
|
1703
1713
|
* Sep-10 used for authentication to an external server.
|
|
@@ -51532,97 +51542,6 @@ module.exports = (function() {
|
|
|
51532
51542
|
})();
|
|
51533
51543
|
|
|
51534
51544
|
|
|
51535
|
-
/***/ }),
|
|
51536
|
-
|
|
51537
|
-
/***/ "../../node_modules/tweetnacl-util/nacl-util.js":
|
|
51538
|
-
/*!******************************************************!*\
|
|
51539
|
-
!*** ../../node_modules/tweetnacl-util/nacl-util.js ***!
|
|
51540
|
-
\******************************************************/
|
|
51541
|
-
/***/ (function(module) {
|
|
51542
|
-
|
|
51543
|
-
// Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
|
|
51544
|
-
// Public domain.
|
|
51545
|
-
(function(root, f) {
|
|
51546
|
-
'use strict';
|
|
51547
|
-
if ( true && module.exports) module.exports = f();
|
|
51548
|
-
else if (root.nacl) root.nacl.util = f();
|
|
51549
|
-
else {
|
|
51550
|
-
root.nacl = {};
|
|
51551
|
-
root.nacl.util = f();
|
|
51552
|
-
}
|
|
51553
|
-
}(this, function() {
|
|
51554
|
-
'use strict';
|
|
51555
|
-
|
|
51556
|
-
var util = {};
|
|
51557
|
-
|
|
51558
|
-
function validateBase64(s) {
|
|
51559
|
-
if (!(/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(s))) {
|
|
51560
|
-
throw new TypeError('invalid encoding');
|
|
51561
|
-
}
|
|
51562
|
-
}
|
|
51563
|
-
|
|
51564
|
-
util.decodeUTF8 = function(s) {
|
|
51565
|
-
if (typeof s !== 'string') throw new TypeError('expected string');
|
|
51566
|
-
var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
|
|
51567
|
-
for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
|
|
51568
|
-
return b;
|
|
51569
|
-
};
|
|
51570
|
-
|
|
51571
|
-
util.encodeUTF8 = function(arr) {
|
|
51572
|
-
var i, s = [];
|
|
51573
|
-
for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
|
|
51574
|
-
return decodeURIComponent(escape(s.join('')));
|
|
51575
|
-
};
|
|
51576
|
-
|
|
51577
|
-
if (typeof atob === 'undefined') {
|
|
51578
|
-
// Node.js
|
|
51579
|
-
|
|
51580
|
-
if (typeof Buffer.from !== 'undefined') {
|
|
51581
|
-
// Node v6 and later
|
|
51582
|
-
util.encodeBase64 = function (arr) { // v6 and later
|
|
51583
|
-
return Buffer.from(arr).toString('base64');
|
|
51584
|
-
};
|
|
51585
|
-
|
|
51586
|
-
util.decodeBase64 = function (s) {
|
|
51587
|
-
validateBase64(s);
|
|
51588
|
-
return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
|
|
51589
|
-
};
|
|
51590
|
-
|
|
51591
|
-
} else {
|
|
51592
|
-
// Node earlier than v6
|
|
51593
|
-
util.encodeBase64 = function (arr) { // v6 and later
|
|
51594
|
-
return (new Buffer(arr)).toString('base64');
|
|
51595
|
-
};
|
|
51596
|
-
|
|
51597
|
-
util.decodeBase64 = function(s) {
|
|
51598
|
-
validateBase64(s);
|
|
51599
|
-
return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
|
|
51600
|
-
};
|
|
51601
|
-
}
|
|
51602
|
-
|
|
51603
|
-
} else {
|
|
51604
|
-
// Browsers
|
|
51605
|
-
|
|
51606
|
-
util.encodeBase64 = function(arr) {
|
|
51607
|
-
var i, s = [], len = arr.length;
|
|
51608
|
-
for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
|
|
51609
|
-
return btoa(s.join(''));
|
|
51610
|
-
};
|
|
51611
|
-
|
|
51612
|
-
util.decodeBase64 = function(s) {
|
|
51613
|
-
validateBase64(s);
|
|
51614
|
-
var i, d = atob(s), b = new Uint8Array(d.length);
|
|
51615
|
-
for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
|
|
51616
|
-
return b;
|
|
51617
|
-
};
|
|
51618
|
-
|
|
51619
|
-
}
|
|
51620
|
-
|
|
51621
|
-
return util;
|
|
51622
|
-
|
|
51623
|
-
}));
|
|
51624
|
-
|
|
51625
|
-
|
|
51626
51545
|
/***/ }),
|
|
51627
51546
|
|
|
51628
51547
|
/***/ "../../node_modules/tweetnacl/nacl-fast.js":
|
|
@@ -67024,6 +66943,170 @@ module.exports = axios;
|
|
|
67024
66943
|
//# sourceMappingURL=axios.cjs.map
|
|
67025
66944
|
|
|
67026
66945
|
|
|
66946
|
+
/***/ }),
|
|
66947
|
+
|
|
66948
|
+
/***/ "../../node_modules/@stablelib/utf8/lib/utf8.js":
|
|
66949
|
+
/*!******************************************************!*\
|
|
66950
|
+
!*** ../../node_modules/@stablelib/utf8/lib/utf8.js ***!
|
|
66951
|
+
\******************************************************/
|
|
66952
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
66953
|
+
|
|
66954
|
+
"use strict";
|
|
66955
|
+
__webpack_require__.r(__webpack_exports__);
|
|
66956
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
66957
|
+
/* harmony export */ decode: () => (/* binding */ decode),
|
|
66958
|
+
/* harmony export */ encode: () => (/* binding */ encode),
|
|
66959
|
+
/* harmony export */ encodedLength: () => (/* binding */ encodedLength)
|
|
66960
|
+
/* harmony export */ });
|
|
66961
|
+
// Copyright (C) 2016 Dmitry Chestnykh
|
|
66962
|
+
// MIT License. See LICENSE file for details.
|
|
66963
|
+
/**
|
|
66964
|
+
* Package utf8 implements UTF-8 encoding and decoding.
|
|
66965
|
+
*/
|
|
66966
|
+
const INVALID_UTF16 = "utf8: invalid string";
|
|
66967
|
+
const INVALID_UTF8 = "utf8: invalid source encoding";
|
|
66968
|
+
/**
|
|
66969
|
+
* Encodes the given string into UTF-8 byte array.
|
|
66970
|
+
* Throws if the source string has invalid UTF-16 encoding.
|
|
66971
|
+
*/
|
|
66972
|
+
function encode(s) {
|
|
66973
|
+
// Calculate result length and allocate output array.
|
|
66974
|
+
// encodedLength() validates string and throws errors,
|
|
66975
|
+
// so we don't need repeat validation here.
|
|
66976
|
+
const arr = new Uint8Array(encodedLength(s));
|
|
66977
|
+
let pos = 0;
|
|
66978
|
+
for (let i = 0; i < s.length; i++) {
|
|
66979
|
+
let c = s.charCodeAt(i);
|
|
66980
|
+
if (c >= 0xd800 && c <= 0xdbff) {
|
|
66981
|
+
c = ((c - 0xd800) << 10) + (s.charCodeAt(++i) - 0xdc00) + 0x10000;
|
|
66982
|
+
}
|
|
66983
|
+
if (c < 0x80) {
|
|
66984
|
+
arr[pos++] = c;
|
|
66985
|
+
}
|
|
66986
|
+
else if (c < 0x800) {
|
|
66987
|
+
arr[pos++] = 0xc0 | (c >> 6);
|
|
66988
|
+
arr[pos++] = 0x80 | (c & 0x3f);
|
|
66989
|
+
}
|
|
66990
|
+
else if (c < 0x10000) {
|
|
66991
|
+
arr[pos++] = 0xe0 | (c >> 12);
|
|
66992
|
+
arr[pos++] = 0x80 | ((c >> 6) & 0x3f);
|
|
66993
|
+
arr[pos++] = 0x80 | (c & 0x3f);
|
|
66994
|
+
}
|
|
66995
|
+
else {
|
|
66996
|
+
arr[pos++] = 0xf0 | (c >> 18);
|
|
66997
|
+
arr[pos++] = 0x80 | ((c >> 12) & 0x3f);
|
|
66998
|
+
arr[pos++] = 0x80 | ((c >> 6) & 0x3f);
|
|
66999
|
+
arr[pos++] = 0x80 | (c & 0x3f);
|
|
67000
|
+
}
|
|
67001
|
+
}
|
|
67002
|
+
return arr;
|
|
67003
|
+
}
|
|
67004
|
+
/**
|
|
67005
|
+
* Returns the number of bytes required to encode the given string into UTF-8.
|
|
67006
|
+
* Throws if the source string has invalid UTF-16 encoding.
|
|
67007
|
+
*/
|
|
67008
|
+
function encodedLength(s) {
|
|
67009
|
+
let result = 0;
|
|
67010
|
+
for (let i = 0; i < s.length; i++) {
|
|
67011
|
+
let c = s.charCodeAt(i);
|
|
67012
|
+
if (c >= 0xd800 && c <= 0xdbff) {
|
|
67013
|
+
// surrogate pair
|
|
67014
|
+
if (i === s.length - 1) {
|
|
67015
|
+
throw new Error(INVALID_UTF16);
|
|
67016
|
+
}
|
|
67017
|
+
i++;
|
|
67018
|
+
const c2 = s.charCodeAt(i);
|
|
67019
|
+
if (c2 < 0xdc00 || c2 > 0xdfff) {
|
|
67020
|
+
throw new Error(INVALID_UTF16);
|
|
67021
|
+
}
|
|
67022
|
+
c = ((c - 0xd800) << 10) + (c2 - 0xdc00) + 0x10000;
|
|
67023
|
+
}
|
|
67024
|
+
if (c < 0x80) {
|
|
67025
|
+
result += 1;
|
|
67026
|
+
}
|
|
67027
|
+
else if (c < 0x800) {
|
|
67028
|
+
result += 2;
|
|
67029
|
+
}
|
|
67030
|
+
else if (c < 0x10000) {
|
|
67031
|
+
result += 3;
|
|
67032
|
+
}
|
|
67033
|
+
else {
|
|
67034
|
+
result += 4;
|
|
67035
|
+
}
|
|
67036
|
+
}
|
|
67037
|
+
return result;
|
|
67038
|
+
}
|
|
67039
|
+
/**
|
|
67040
|
+
* Decodes the given byte array from UTF-8 into a string.
|
|
67041
|
+
* Throws if encoding is invalid.
|
|
67042
|
+
*/
|
|
67043
|
+
function decode(arr) {
|
|
67044
|
+
const chars = [];
|
|
67045
|
+
for (let i = 0; i < arr.length; i++) {
|
|
67046
|
+
let b = arr[i];
|
|
67047
|
+
if (b & 0x80) {
|
|
67048
|
+
let min;
|
|
67049
|
+
if (b < 0xe0) {
|
|
67050
|
+
// Need 1 more byte.
|
|
67051
|
+
if (i >= arr.length) {
|
|
67052
|
+
throw new Error(INVALID_UTF8);
|
|
67053
|
+
}
|
|
67054
|
+
const n1 = arr[++i];
|
|
67055
|
+
if ((n1 & 0xc0) !== 0x80) {
|
|
67056
|
+
throw new Error(INVALID_UTF8);
|
|
67057
|
+
}
|
|
67058
|
+
b = (b & 0x1f) << 6 | (n1 & 0x3f);
|
|
67059
|
+
min = 0x80;
|
|
67060
|
+
}
|
|
67061
|
+
else if (b < 0xf0) {
|
|
67062
|
+
// Need 2 more bytes.
|
|
67063
|
+
if (i >= arr.length - 1) {
|
|
67064
|
+
throw new Error(INVALID_UTF8);
|
|
67065
|
+
}
|
|
67066
|
+
const n1 = arr[++i];
|
|
67067
|
+
const n2 = arr[++i];
|
|
67068
|
+
if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {
|
|
67069
|
+
throw new Error(INVALID_UTF8);
|
|
67070
|
+
}
|
|
67071
|
+
b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);
|
|
67072
|
+
min = 0x800;
|
|
67073
|
+
}
|
|
67074
|
+
else if (b < 0xf8) {
|
|
67075
|
+
// Need 3 more bytes.
|
|
67076
|
+
if (i >= arr.length - 2) {
|
|
67077
|
+
throw new Error(INVALID_UTF8);
|
|
67078
|
+
}
|
|
67079
|
+
const n1 = arr[++i];
|
|
67080
|
+
const n2 = arr[++i];
|
|
67081
|
+
const n3 = arr[++i];
|
|
67082
|
+
if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {
|
|
67083
|
+
throw new Error(INVALID_UTF8);
|
|
67084
|
+
}
|
|
67085
|
+
b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);
|
|
67086
|
+
min = 0x10000;
|
|
67087
|
+
}
|
|
67088
|
+
else {
|
|
67089
|
+
throw new Error(INVALID_UTF8);
|
|
67090
|
+
}
|
|
67091
|
+
if (b < min || (b >= 0xd800 && b <= 0xdfff)) {
|
|
67092
|
+
throw new Error(INVALID_UTF8);
|
|
67093
|
+
}
|
|
67094
|
+
if (b >= 0x10000) {
|
|
67095
|
+
// Surrogate pair.
|
|
67096
|
+
if (b > 0x10ffff) {
|
|
67097
|
+
throw new Error(INVALID_UTF8);
|
|
67098
|
+
}
|
|
67099
|
+
b -= 0x10000;
|
|
67100
|
+
chars.push(String.fromCharCode(0xd800 | (b >> 10)));
|
|
67101
|
+
b = 0xdc00 | (b & 0x3ff);
|
|
67102
|
+
}
|
|
67103
|
+
}
|
|
67104
|
+
chars.push(String.fromCharCode(b));
|
|
67105
|
+
}
|
|
67106
|
+
return chars.join("");
|
|
67107
|
+
}
|
|
67108
|
+
//# sourceMappingURL=utf8.js.map
|
|
67109
|
+
|
|
67027
67110
|
/***/ }),
|
|
67028
67111
|
|
|
67029
67112
|
/***/ "./package.json":
|
|
@@ -67033,7 +67116,7 @@ module.exports = axios;
|
|
|
67033
67116
|
/***/ ((module) => {
|
|
67034
67117
|
|
|
67035
67118
|
"use strict";
|
|
67036
|
-
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"1.
|
|
67119
|
+
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"1.7.0","engines":{"node":">=18"},"browser":"./lib/bundle_browser.js","main":"./lib/bundle.js","types":"./lib/index.d.ts","license":"Apache-2.0","private":false,"devDependencies":{"@babel/preset-env":"^7.20.2","@babel/preset-typescript":"^7.23.3","@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","@typescript-eslint/eslint-plugin":"^6.7.5","@typescript-eslint/parser":"^6.7.5","babel-jest":"^29.4.1","crypto-browserify":"^3.12.0","dotenv":"^16.3.1","eslint":"^8.51.0","eslint-config-prettier":"^9.0.0","eslint-plugin-jsdoc":"^46.8.2","husky":"^8.0.0","jest":"^29.4.1","lint-staged":"^14.0.1","npm-run-all":"^4.1.5","playwright":"^1.43.1","prettier":"^2.0.5","pretty-quick":"^2.0.1","process":"^0.11.10","sinon":"^15.1.0","stream-browserify":"^3.0.0","ts-jest":"^29.0.5","ts-loader":"^9.4.2","ts-node":"^10.9.1","tslib":"^2.5.0","typescript":"^5.0.4","webpack":"^5.83.1","webpack-cli":"^5.1.1"},"dependencies":{"@stablelib/base64":"^2.0.0","@stablelib/utf8":"^2.0.0","@stellar/stellar-sdk":"12.1.0","axios":"^1.4.0","base64url":"^3.0.1","https-browserify":"^1.0.0","jws":"^4.0.0","lodash":"^4.17.21","query-string":"^7.1.3","stream-http":"^3.2.0","tweetnacl":"^1.0.3","url":"^0.11.0","util":"^0.12.5","utility-types":"^3.10.0","vm-browserify":"^1.1.2"},"scripts":{"test":"jest --watchAll","test:ci":"jest --ci","test:e2e:ci":"jest --config jest.e2e.config.js --ci","test:recovery:ci":"jest --config jest.integration.config.js recovery.test.ts --ci","test:anchorplatform:ci":"yarn jest --config jest.integration.config.js anchorplatform.test.ts --ci","build:web":"webpack --config webpack.config.js","build:node":"webpack --env NODE=true --config webpack.config.js","build":"run-p build:web build:node","example:sep24":"ts-node examples/sep24/sep24.ts"}}');
|
|
67037
67120
|
|
|
67038
67121
|
/***/ }),
|
|
67039
67122
|
|