@stellar/typescript-wallet-sdk 3.0.2 → 3.0.3
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 +8 -0
- package/lib/bundle.js +42 -2
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +42 -2
- package/lib/bundle_browser.js.map +1 -1
- package/lib/walletSdk/Types/sep7.d.ts +18 -0
- package/package.json +1 -1
- package/src/walletSdk/Types/sep7.ts +22 -0
- package/src/walletSdk/Uri/Sep7Base.ts +14 -1
- package/src/walletSdk/Uri/sep7Parser.ts +14 -0
- package/test/sep7.test.ts +138 -1
package/lib/bundle_browser.js
CHANGED
|
@@ -4853,7 +4853,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
4853
4853
|
"use strict";
|
|
4854
4854
|
|
|
4855
4855
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4856
|
-
exports.URI_REPLACE_MAX_LENGTH = exports.URI_MSG_MAX_LENGTH = exports.Sep7OperationType = exports.WEB_STELLAR_SCHEME = void 0;
|
|
4856
|
+
exports.isValidFullyQualifiedDomainName = exports.FULLY_QUALIFIED_DOMAIN_NAME_REGEX = exports.URI_REPLACE_MAX_LENGTH = exports.URI_MSG_MAX_LENGTH = exports.Sep7OperationType = exports.WEB_STELLAR_SCHEME = void 0;
|
|
4857
4857
|
exports.WEB_STELLAR_SCHEME = "web+stellar:";
|
|
4858
4858
|
var Sep7OperationType;
|
|
4859
4859
|
(function (Sep7OperationType) {
|
|
@@ -4862,6 +4862,27 @@ var Sep7OperationType;
|
|
|
4862
4862
|
})(Sep7OperationType = exports.Sep7OperationType || (exports.Sep7OperationType = {}));
|
|
4863
4863
|
exports.URI_MSG_MAX_LENGTH = 300;
|
|
4864
4864
|
exports.URI_REPLACE_MAX_LENGTH = 4096;
|
|
4865
|
+
/**
|
|
4866
|
+
* Matches a fully qualified domain name (e.g. "example.com", "sub.example.co.uk").
|
|
4867
|
+
*
|
|
4868
|
+
* Rejects userinfo ('@'), ports (':'), paths/queries ('/', '?'), scheme
|
|
4869
|
+
* prefixes ('//'), bare hostnames like 'localhost', and raw IPv4/IPv6
|
|
4870
|
+
* addresses (the all-numeric final label fails the alphabetic TLD rule).
|
|
4871
|
+
*
|
|
4872
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0007.md#verifying-the-signature step 3.
|
|
4873
|
+
*/
|
|
4874
|
+
exports.FULLY_QUALIFIED_DOMAIN_NAME_REGEX = /^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/;
|
|
4875
|
+
/**
|
|
4876
|
+
* Returns true if the given string is a valid fully qualified domain name.
|
|
4877
|
+
*
|
|
4878
|
+
* @param {string} domain the domain string to validate.
|
|
4879
|
+
*
|
|
4880
|
+
* @returns {boolean} true if 'domain' is a valid fully qualified domain name.
|
|
4881
|
+
*/
|
|
4882
|
+
var isValidFullyQualifiedDomainName = function (domain) {
|
|
4883
|
+
return exports.FULLY_QUALIFIED_DOMAIN_NAME_REGEX.test(domain);
|
|
4884
|
+
};
|
|
4885
|
+
exports.isValidFullyQualifiedDomainName = isValidFullyQualifiedDomainName;
|
|
4865
4886
|
|
|
4866
4887
|
|
|
4867
4888
|
/***/ }),
|
|
@@ -5181,6 +5202,14 @@ var Sep7Base = /** @class */ (function () {
|
|
|
5181
5202
|
if (!originDomain || !signature) {
|
|
5182
5203
|
return [2 /*return*/, false];
|
|
5183
5204
|
}
|
|
5205
|
+
// SEP-7 step 3: "If the origin_domain is not a valid fully qualified
|
|
5206
|
+
// domain name, do not allow the user to sign the transaction." This must
|
|
5207
|
+
// be enforced before resolving the stellar.toml, otherwise a malformed
|
|
5208
|
+
// origin_domain (e.g. containing userinfo, a port, or a path) could
|
|
5209
|
+
// redirect the trust-anchoring TOML fetch to an attacker-controlled host.
|
|
5210
|
+
if (!(0, Types_1.isValidFullyQualifiedDomainName)(originDomain)) {
|
|
5211
|
+
return [2 /*return*/, false];
|
|
5212
|
+
}
|
|
5184
5213
|
_a.label = 1;
|
|
5185
5214
|
case 1:
|
|
5186
5215
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -5751,6 +5780,7 @@ var isValidSep7Uri = function (uri) {
|
|
|
5751
5780
|
var networkPassphrase = url.searchParams.get("network_passphrase") || stellar_sdk_1.Networks.PUBLIC;
|
|
5752
5781
|
var destination = url.searchParams.get("destination");
|
|
5753
5782
|
var msg = url.searchParams.get("msg");
|
|
5783
|
+
var originDomain = url.searchParams.get("origin_domain");
|
|
5754
5784
|
if (![Types_1.Sep7OperationType.tx, Types_1.Sep7OperationType.pay].includes(type)) {
|
|
5755
5785
|
return {
|
|
5756
5786
|
result: false,
|
|
@@ -5798,6 +5828,16 @@ var isValidSep7Uri = function (uri) {
|
|
|
5798
5828
|
reason: "the 'msg' parameter should be no longer than ".concat(Types_1.URI_MSG_MAX_LENGTH, " characters"),
|
|
5799
5829
|
};
|
|
5800
5830
|
}
|
|
5831
|
+
// 'origin_domain' is optional (SEP-7), but when present it must be a valid
|
|
5832
|
+
// fully qualified domain name (SEP-7 step 3), otherwise a malformed value
|
|
5833
|
+
// could later redirect the trust-anchoring stellar.toml fetch in
|
|
5834
|
+
// Sep7Base.verifySignature() to an attacker-controlled host.
|
|
5835
|
+
if (originDomain && !(0, Types_1.isValidFullyQualifiedDomainName)(originDomain)) {
|
|
5836
|
+
return {
|
|
5837
|
+
result: false,
|
|
5838
|
+
reason: "the provided 'origin_domain' parameter is not a valid fully qualified domain name",
|
|
5839
|
+
};
|
|
5840
|
+
}
|
|
5801
5841
|
return {
|
|
5802
5842
|
result: true,
|
|
5803
5843
|
};
|
|
@@ -56509,7 +56549,7 @@ function decode(arr) {
|
|
|
56509
56549
|
/***/ ((module) => {
|
|
56510
56550
|
|
|
56511
56551
|
"use strict";
|
|
56512
|
-
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"3.0.
|
|
56552
|
+
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"3.0.3","engines":{"node":">=20"},"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","express":"^4.19.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":"15.0.1","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:sep10Server":"ts-node examples/sep10/sep10Server.ts","example:sep10Wallet":"ts-node examples/sep10/sep10Wallet.ts","example:sep24":"ts-node examples/sep24/sep24.ts","example:sep12":"ts-node examples/sep12/sep12.ts"}}');
|
|
56513
56553
|
|
|
56514
56554
|
/***/ }),
|
|
56515
56555
|
|